@arcgis/core 5.2.0-next.19 → 5.2.0-next.20
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.
- package/WebScene.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0a259137932211b80f0e.js +1 -0
- package/assets/esri/core/workers/chunks/{c318e6dbb8651433038f.js → 2dbd88566abac030e965.js} +2 -2
- package/assets/esri/core/workers/chunks/2ed81f1e490cb7e73405.js +1 -0
- package/assets/esri/core/workers/chunks/{aeeee92b86554962711e.js → 4104a0585969f8cd524c.js} +1 -1
- package/assets/esri/core/workers/chunks/{99c002015c2127e6cbfc.js → 44b30bce8e9a75b9e1b3.js} +2 -2
- package/assets/esri/core/workers/chunks/{c0b7b9d115dccb2924ff.js → 4fdd38d7362bf09a994b.js} +1 -1
- package/assets/esri/core/workers/chunks/{0d42322362e76f674d94.js → 501fa9b029df2e7b73c3.js} +2 -2
- package/assets/esri/core/workers/chunks/{fb81705cec1be2431876.js → 5216dd0544e901039c84.js} +1 -1
- package/assets/esri/core/workers/chunks/5d710b3e50f2211a765d.js +1 -0
- package/assets/esri/core/workers/chunks/5f0bc019add4aff3130c.js +1 -0
- package/assets/esri/core/workers/chunks/{2d7a4b669804d0c5029b.js → 5f63077ec5ba3560491b.js} +1 -1
- package/assets/esri/core/workers/chunks/6121cd0264b6841a5bac.js +1 -0
- package/assets/esri/core/workers/chunks/{dd3b0070081eaf805d95.js → 6ac09f4e85c664a17365.js} +1 -1
- package/assets/esri/core/workers/chunks/{5ea1113b7bdcf94b2822.js → 6e8b9c03240ec372b587.js} +1 -1
- package/assets/esri/core/workers/chunks/{29e6f4b19c3da9129439.js → 72edd08a2ff08970ba38.js} +1 -1
- package/assets/esri/core/workers/chunks/74922daaedb479ec6f03.js +1 -0
- package/assets/esri/core/workers/chunks/{169bfafec4d59be2beb0.js → 790462ab5f21491a4f75.js} +1 -1
- package/assets/esri/core/workers/chunks/{c8672a54c98d472aa24d.js → 82adfa2dbd40e1becaf4.js} +1 -1
- package/assets/esri/core/workers/chunks/{851fc5290497991ba001.js → 88df19742edb0cdc3e67.js} +1 -1
- package/assets/esri/core/workers/chunks/{1ea840b7ac1ffaa0c389.js → 8ce4fe00328173224ed2.js} +1 -1
- package/assets/esri/core/workers/chunks/912a8743a02f467b63b0.js +2 -0
- package/assets/esri/core/workers/chunks/9ad36947bb42ed7f97d3.js +1 -0
- package/assets/esri/core/workers/chunks/9def4619d102f1d41578.js +1 -0
- package/assets/esri/core/workers/chunks/9e0ea6c34940b1acf3c6.js +1 -0
- package/assets/esri/core/workers/chunks/{4e59e5a5d0ff887ff899.js → a856ae928273f9d6792f.js} +1 -1
- package/assets/esri/core/workers/chunks/aec46ec486912dca549d.js +1 -0
- package/assets/esri/core/workers/chunks/{f0924613f818dd165ad9.js → b375abfb2a2d9c63e20a.js} +1 -1
- package/assets/esri/core/workers/chunks/{888af532ad48fd86f285.js → c9e5d3f496cefb8e3934.js} +1 -1
- package/assets/esri/core/workers/chunks/cd892f429d5ffe8de99e.js +1 -0
- package/assets/esri/core/workers/chunks/d2387906b52624b4f7f1.js +1 -0
- package/assets/esri/core/workers/chunks/d34d41a350facfa9b7c0.js +1 -0
- package/assets/esri/core/workers/chunks/d8329c2000c0cc597adc.js +1 -0
- package/assets/esri/core/workers/chunks/{dfb19701b488089874fd.js → db26cf2c2735183294b8.js} +1 -1
- package/assets/esri/core/workers/chunks/dee339774131d7274137.js +1 -0
- package/assets/esri/core/workers/chunks/{05016e5a1de384994001.js → eccbddaec4be44c86f79.js} +2 -2
- package/assets/esri/core/workers/chunks/fee50ab6c92ef0327255.js +1 -0
- package/assets/esri/themes/base/widgets/_BatchAttributeForm.scss +1 -1
- package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +4 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/OITBlendEmission.glsl.js +2 -21
- package/config.js +1 -1
- package/kernel.js +1 -1
- package/layers/AnnotationFeatureLayer.d.ts +3 -3
- package/layers/AnnotationFeatureLayer.js +1 -1
- package/layers/DimensionFeatureLayer.js +1 -1
- package/layers/GaussianSplatLayer.d.ts +1 -2
- package/layers/VideoLayer.js +1 -1
- package/layers/mixins/SceneService.js +1 -1
- package/layers/support/arcgisLayers.js +1 -1
- package/layers/support/fetchService.js +1 -1
- package/libs/parquet/parquet.js +1 -1
- package/package.json +2 -2
- package/portal/support/layersLoader.js +1 -1
- package/portal/support/loadUtils.js +1 -1
- package/portal/support/portalLayers.js +1 -1
- package/portal/support/resourceUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/WebStyleSymbol.js +1 -1
- package/undoredo/support/ApplySetItem.js +1 -1
- package/views/2d/engine/webgl/TextureManager.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderParquet.js +1 -1
- package/views/2d/layers/support/annodime/virtualFields.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedConfiguration.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedDrawToolRenderer.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedPlacementController.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubVisualization.js +1 -1
- package/views/3d/analysis/Viewshed/placementUtils.js +1 -1
- package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWebStyleSymbol.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatTextureAtlas.js +1 -1
- package/views/3d/webgl-engine/effects/glow/Glow.js +1 -1
- package/views/3d/webgl-engine/effects/transparency/OITBlendEmission.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/transparency/oitBlendFragment.glsl.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.d.ts +6 -6
- package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/Editor/MergeFeaturesWorkflow.js +1 -1
- package/widgets/Editor/support/attachmentUtils.js +1 -1
- package/widgets/OrientedImageryViewer/css.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/Print/PrintViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/assets/esri/core/workers/chunks/00bcb04934972179b9ca.js +0 -1
- package/assets/esri/core/workers/chunks/0c13591347d51d684561.js +0 -1
- package/assets/esri/core/workers/chunks/35533c8ef541f7643497.js +0 -2
- package/assets/esri/core/workers/chunks/3d4ad7c728e02aa90551.js +0 -1
- package/assets/esri/core/workers/chunks/50c88e2545380800381f.js +0 -1
- package/assets/esri/core/workers/chunks/57a6572d440d2c62432b.js +0 -1
- package/assets/esri/core/workers/chunks/6a21a22b08f968fa8d60.js +0 -1
- package/assets/esri/core/workers/chunks/753e0b21e57c12c742ee.js +0 -1
- package/assets/esri/core/workers/chunks/85505a8b8b0794656d06.js +0 -1
- package/assets/esri/core/workers/chunks/93d08d82ceab19e314f8.js +0 -1
- package/assets/esri/core/workers/chunks/9802770413ad814dab29.js +0 -1
- package/assets/esri/core/workers/chunks/9d59cc5c0a63a4e41d99.js +0 -1
- package/assets/esri/core/workers/chunks/a32651777e4f07df5b6a.js +0 -1
- package/assets/esri/core/workers/chunks/a59a1fdcd37a875f179b.js +0 -1
- package/assets/esri/core/workers/chunks/aa5f36d7ed59c625ba78.js +0 -1
- package/assets/esri/core/workers/chunks/bb9232d9f63ec0c32447.js +0 -1
- package/assets/esri/core/workers/chunks/e3ea4b7217df16592def.js +0 -1
- /package/assets/esri/core/workers/chunks/{c318e6dbb8651433038f.js.LICENSE.txt → 2dbd88566abac030e965.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{0d42322362e76f674d94.js.LICENSE.txt → 44b30bce8e9a75b9e1b3.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{99c002015c2127e6cbfc.js.LICENSE.txt → 501fa9b029df2e7b73c3.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{35533c8ef541f7643497.js.LICENSE.txt → 912a8743a02f467b63b0.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{05016e5a1de384994001.js.LICENSE.txt → eccbddaec4be44c86f79.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{prefersRTL as t,substitute as i}from"../intl.js";import{prefersReducedMotion as a}from"../core/a11yUtils.js";import{createTask as s}from"../core/asyncUtils.js";import o from"../core/Collection.js";import{deprecateWidget as n,deprecatedProperty as r}from"../core/deprecate.js";import l from"../core/Logger.js";import{isAbortError as d}from"../core/promiseUtils.js";import{watch as c,initial as g,syncAndInitial as h,on as m,sync as u}from"../core/reactiveUtils.js";import{throttle as p}from"../core/throttle.js";import{property as v,subclass as y}from"../core/accessorSupport/decorators.js";import{or as w}from"../layers/orientedImagery/transformations/utils.js";import _ from"./Expand.js";import M from"./PanoramicVideoViewer.js";import T from"./PanoramicViewer.js";import b from"./Widget.js";import{getAllArcPath as C}from"./OrientedImageryViewer/arcUtils.js";import{getDelegatedEvents as f,defaultImageGeometryField as I,defaultOIObjectIDField as S,segmentArcs as A,featureCircleRadius as k,navigationToolDimensionLength as V,sectorsRadii as L}from"./OrientedImageryViewer/constants.js";import{css as E,navigation as O,navigationToolRotationFrom as P,navigationToolRotationTo as F,root as x}from"./OrientedImageryViewer/css.js";import{isFeatureAttachment as G,loadImageForAttachment as N,getThumbnailPixelBlock as D,renderImageWithRotation as H}from"./OrientedImageryViewer/galleryUtils.js";import j from"./OrientedImageryViewer/OrientedImageryViewerViewModel.js";import $ from"./OrientedImageryViewer/OrientedImageryViewerVisibleElements.js";import{loadAlertComponents as B,Alert as R}from"./OrientedImageryViewer/components/Alert.js";import q from"./OrientedImageryViewer/components/ImageLocationWidget.js";import U from"./OrientedImageryViewer/components/ImageViewer.js";import W from"./OrientedImageryViewer/components/NavigationUI.js";import Z from"./OrientedImageryViewer/components/NavigationUI360.js";import{SequentialNavigationUI as z}from"./OrientedImageryViewer/components/SequentialNavigationUI.js";import{loadVideoEnhancementComponents as J,renderEnhancementSlider as K,VideoEnhancementTools as Q}from"./OrientedImageryViewer/components/VideoEnhancementTools.js";import{NoImageLoadedError as X}from"./OrientedImageryViewer/navigation/errors.js";import{loadCalciteComponents as Y}from"./support/componentsUtils.js";import{globalCss as ee}from"./support/globalCss.js";import{iconByKind as te}from"./support/iconUtils.js";import{vmEvent as ie,messageBundle as ae,tsx as se}from"./support/widget.js";const oe={overlayed:"overlayed"};let ne=class extends b{constructor(e,t){super(e,t),this.dataCaptureEnabled=!1,this.galleryOpened=!1,this.imageEnhancementToolActive=!1,this.videoEnhancementToolActive=!1,this.imageOverlaysOpened=!1,this.navigationToolActive=!1,this.viewModel=new j,this.messagesCommon=null,this.messagesSketch=null,this.pixelMeasurementUnit="meters",this.pixelAreaMeasurementUnit="square-meters",this.selectedGroup=null,this.showCameraLocations=!1,this.showMapFeatures=!1,this.visibleElements=new $,this._defaultSuperimposeZOffsetPercentage=100,this._panoramicSuperimposeRadiusOffsetPercentage=100,this._imageOverlaysLoaderTask=null,this._imageMeasurementToolsLoaderTask=null,this._navigationSettingsLoaderTask=null,this._navigationTask=null,this._clearMeasurements=()=>{this.viewModel.measureType=null,this.viewModel.triangularMeasurementActive=!1,this.viewModel.clearPreviousMeasurements()},this._clearImageLocation=()=>{this.imageLocationToolActive=!1,this.triangularMeasurementActive=!1},this._createNavigationTask=async e=>(this._navigationTask?.abort(),this._navigationTask=s(async t=>await this.navigate({...e,signal:t})),this._navigationTask.promise),this._navigateNext=async()=>await this._createNavigationTask({step:1}),this._navigatePrevious=async()=>await this._createNavigationTask({step:-1}),this._navigationToolExpanded=!1,this._navigationTool=null,this._galleryController=new AbortController,this._galleryObserver=new IntersectionObserver(this._lazyLoadImage.bind(this)),this._overlayedLayers=new o,this._previousAction=null,this._closeImageSequenceAlert=()=>{this._set("noImageInSequenceError",!1)},this._handleDataCaptureLayerChange=async e=>{if(this.dataCaptureLayer&&await this.stopDataCapture(!0),this.dataCaptureLayer=this.dataCaptureLayer===e?null:e,this.dataCaptureLayer)return this.startDataCapture(this.dataCaptureLayer)},this._handleNavigationSettingsInputChange=(e,t)=>{this.set(`${e}Threshold`,t)},this._handleNavigationSettingsToggle=e=>{this.viewModel.preserveAngle=e},this._handleOverlayLayerDeselect=e=>{const t=e.layer;t===this.dataCaptureLayer&&(this.stopDataCapture(),this.dataCaptureLayer=null),this.removeOverlayedGraphicsOnImage(`${t.id}`)},this._handleOverlayLayerSelect=e=>{const t=e.layer;this.viewModel.overlayMapFeatures(t,this.showMapFeatures),this.addHandles(c(()=>t.visible,()=>{this.viewModel.toggleOverlayMapFeatures(t.id,t.visible,this.showMapFeatures)}),`${oe.overlayed}-${t.id}`)},this._highlight=e=>{const t=e.target?.dataset.objectid;t&&this.viewModel.highlight(t)},this._onAction=e=>{const{target:t}=e,{dataset:{action:i}}=t,{_previousAction:a}=this,s=a?.dataset.action,o=s?.includes("draw")??!1,n="select-feature"===s,r=s!==i;switch(i){case"draw-point":case"draw-polygon":case"draw-polyline":{a&&w(n,o&&r)&&(a.active=!1),t.active=!t.active;const e=i.replace("draw-","");this.viewModel.digitizeCreate(e),this._previousAction=t.active?t:null;break}case"save":this.viewModel.saveDrawing();break;case"select-feature":o&&(this._previousAction.active=!1),t.active=!t.active,this.viewModel.toggleSelection(t.active),this._previousAction=t.active?t:null;break;case"delete-feature":this.viewModel.digitizeDelete()}},this._onImageOverlayClosed=e=>{e.stopPropagation(),this.imageOverlaysOpened=!1},this._onShowCameraLocationsChanged=e=>{this.showCameraLocations=e},this._onShowMapFeaturesChanged=e=>{this.showMapFeatures=e},this._removeHighlight=()=>this.viewModel.removeHighlight(),this._restoreOverlays=async()=>Promise.all(this._overlayedLayers.map(e=>this.viewModel.overlayMapFeatures(e,this.showMapFeatures))),this._scaleNavigationTool=()=>{this._navigationToolExpanded=!this._navigationToolExpanded},this._sketchLoaderTask=null,this._settingsToggle=null,this._toggleImageNavigation=async e=>{const t=this.navigationMode;this._closeAllImageTools(),this.navigationMode=t!==e?e:null;const{activeViewer:i}=this.viewModel;if(!i)return;const{mode:a,preserveAngle:s}=this.viewModel;if("default"===a)if("directional"===this.navigationMode){const e=await this._loadNavigationSettings(),t="heading"===s||"both"===s,i="pitch"===s||"both"===s,{messages:a,messagesCommon:o}=this,n=new e({cameraHeadingThreshold:this.cameraHeadingThreshold,cameraPitchThreshold:this.cameraPitchThreshold,uiStrings:{configureNavigation:a.configureNavigation,preserveHeading:a.preserveHeading,preserveHeadingDescription:a.preserveHeadingDescription,preservePitch:a.preservePitch,preservePitchDescription:a.preservePitchDescription,settings:o.settings,thresholdLabel:a.thresholdLabel},onInputChange:this._handleNavigationSettingsInputChange,onToggle:this._handleNavigationSettingsToggle,preserveHeading:t,preservePitch:i});this._settingsToggle=new _({content:n,expandIcon:"configure"}),this.viewModel.activeViewer?.ui.add(this._settingsToggle,{position:"top-left"})}else this._settingsToggle&&(this._settingsToggle.expanded=!1,this.viewModel.activeViewer?.ui.remove(this._settingsToggle))},this._toggleImageAttributes=p(this.viewModel.toggleImageAttributes.bind(this.viewModel)),this.navigate=async e=>{let t=null;try{const{currentNode:i}=this.viewModel;if(!i)throw new X;t=await this.viewModel.navigate(i,e)}catch(i){d(i)||l.getLogger(this).error("Error occurred while navigating",i),["NoImageInSequenceError","NoSequenceFoundError"].includes(i.name)&&this._set("noImageInSequenceError",!0)}return t},this.reset=()=>{this._closeAllImageTools(),this.viewModel.reset()},this._loadImageFromGallery=this._loadImageFromGallery.bind(this),this._registerGalleryItem=this._registerGalleryItem.bind(this),this._unregisterGalleryItem=this._unregisterGalleryItem.bind(this),this.loadImageFromSource=this.loadImageFromSource.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this._handleVideoBrightnessChange=this._handleVideoBrightnessChange.bind(this),this._handleVideoContrastChange=this._handleVideoContrastChange.bind(this),this._handleBrightnessChange=this._handleBrightnessChange.bind(this),this._handleContrastChange=this._handleContrastChange.bind(this),this._handleSharpnessChange=this._handleSharpnessChange.bind(this),this._handleSuperimposeZOffsetChange=this._handleSuperimposeZOffsetChange.bind(this),this._toggleSuperimposeCameraLock=this._toggleSuperimposeCameraLock.bind(this),this._resetSuperimposeOffset=this._resetSuperimposeOffset.bind(this),this._resetVideoTools=this._resetVideoTools.bind(this),this._toggleEnhancementToolState=this._toggleEnhancementToolState.bind(this),this.announceDeprecation=()=>{n(l.getLogger(this),"Oriented Imagery Viewer","arcgis-oriented-imagery-viewer",{version:"5.0"})}}initialize(){this.addHandles([c(()=>[this.viewModel?.bestFeatureAngle,this._navigationTool],([e,t])=>{t&&this._updateNavigationTool(t)},g),c(()=>this.currentCoverageVisible,e=>this._onCurrentCoverageVisibilityChange(e)),c(()=>this.isAdditionalCoverageVisible,e=>this._onAdditionalCoverageVisibilityChange(e)),c(()=>this.isAdditionalPointSourcesVisible,e=>this._onAdditionalCameraLocationsVisibility(e)),c(()=>this.superimposeViewEnabled,e=>{e?(this._closeAllImageTools(),this.selectedGroup=null,this.shouldShowSelectedImage=!1,this.verticalFilterEnabled=!1):this._resetSuperimposeOffset()}),c(()=>({features:this.currentBestFeature,overlaysEnabled:this._imageOverlaysEnabled,showCameraLocations:this.showCameraLocations}),({overlaysEnabled:e,showCameraLocations:t})=>{e&&this.viewModel.overlayCameraLocations(t)},h),c(()=>({feature:this.currentBestFeature,overlaysEnabled:this._imageOverlaysEnabled,showMapFeatures:this.showMapFeatures}),async(e,t)=>{e.showMapFeatures!==t?.showMapFeatures&&await this.viewModel.toggleAllOverlayMapFeatures(e.showMapFeatures);const i=e.feature&&e.feature!==t?.feature,a=!e.overlaysEnabled&&!!t?.overlaysEnabled,s=e.overlaysEnabled&&!t?.overlaysEnabled,o="video"===this.viewModel.mode||"panoramic-video"===this.viewModel.mode;if(a&&o)return this.viewModel.removeAllOverlayMapFeatures(),void("video"===this.viewModel.mode&&this.viewModel.videoViewModel?.clearOverlayGraphics());(i||s)&&(i&&this.viewModel.removeAllOverlayMapFeatures(),e.overlaysEnabled&&(this.dataCaptureLayer&&this.stopDataCapture(),await this._restoreOverlays(),this.dataCaptureLayer&&(await this.startDataCapture(this.dataCaptureLayer),this._previousAction?.active&&(this._previousAction.active=!1,this._previousAction=null))))},g),m(()=>this.viewModel,"popup-open",async e=>{await(this.view?.openPopup(e))},u),m(()=>this.viewModel,"popup-close",()=>{this.view?.closePopup()},u),this._toggleImageAttributes])}loadDependencies(){return Promise.all([J(),Y({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),shell:()=>import("@esri/calcite-components/dist/components/calcite-shell"),dialog:()=>import("@esri/calcite-components/dist/components/calcite-dialog"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")}),B()])}destroy(){this._galleryController.abort(),this._galleryObserver.disconnect(),this.currentBestFeature=null}get accuracyParametersMissing(){return this.viewModel.accuracyParametersMissing}get activeLayer(){return r(l.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){r(l.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeVideoIcon(){const{videoElement:e,videoViewModel:t}=this.viewModel;return e?.loaded&&t?t.videoPaused?"play":"pause":"play"}get activeAudioIcon(){const{videoElement:e,videoViewModel:t}=this.viewModel;return e?.loaded&&t?.videoMuted?"sound-off":"sound"}get cameraHeadingThreshold(){return this.viewModel.cameraHeadingThreshold}set cameraHeadingThreshold(e){this.viewModel.cameraHeadingThreshold=e}get cameraPitchThreshold(){return this.viewModel.cameraPitchThreshold}set cameraPitchThreshold(e){this.viewModel.cameraPitchThreshold=e}get canNavigateSequentially(){return!!this.layer?.effectiveSequenceOrderField?.length}get currentBestFeature(){return this.viewModel.currentBestFeature}set currentBestFeature(e){this.viewModel.currentBestFeature=e}get currentCoverageVisible(){return this.viewModel.currentCoverageVisible}set currentCoverageVisible(e){this.viewModel.currentCoverageVisible=e}get dataCaptureLayer(){return this.viewModel.dataCaptureLayer}set dataCaptureLayer(e){this.viewModel.dataCaptureLayer=e}get depthImageNotSupported(){return this.viewModel.depthImageNotSupported}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get displayMessage(){return this.viewModel.displayMessage}get enhancementToolActive(){return"video"===this.viewModel.mode?this.videoEnhancementToolActive:this.imageEnhancementToolActive}set enhancementToolActive(e){"video"===this.viewModel.mode?this.videoEnhancementToolActive=e:this.imageEnhancementToolActive=e}get features(){return this.viewModel.features}get imagePointsInView(){return this.viewModel.imagePointsInView}get icon(){return"oriented-imagery-widget"}set icon(e){this._overrideIfSome("icon",e)}get imageGalleryEnabled(){return this.viewModel.imageGalleryEnabled}get imageLocationToolActive(){return this.viewModel.imageLocationToolState}set imageLocationToolActive(e){this.viewModel.imageLocationToolState=e}get invalidCameraHeading(){return this.viewModel.invalidCameraHeading}get isAdditionalCoverageVisible(){return this.viewModel.isAdditionalCoverageVisible}set isAdditionalCoverageVisible(e){this.viewModel.isAdditionalCoverageVisible=e}get isAdditionalPointSourcesVisible(){return this.viewModel.isAdditionalPointSourcesVisible}set isAdditionalPointSourcesVisible(e){this.viewModel.isAdditionalPointSourcesVisible=e}get mapImageConversionToolState(){return this.viewModel.mapImageConversionToolState}set mapImageConversionToolState(e){this.viewModel.setMapImageConversionToolState(e)}get measureType(){return this.viewModel.measureType}set measureType(e){this.viewModel.measureType=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get navigationMode(){return this.viewModel.navigationMode}set navigationMode(e){this.viewModel.navigationMode=e}get popupEnabled(){const{popupEnabled:e,state:t}=this.viewModel;return("image-loaded"===t||this.videoLoaded)&&e}get preloadMedia(){return this.viewModel.preloadMedia}set preloadMedia(e){this.viewModel.preloadMedia=e}get referencePoint(){return this.viewModel.referencePoint??null}get sketchViewModel(){return this.viewModel.sketch}get triangularMeasurementActive(){return this.viewModel.triangularMeasurementActive}set triangularMeasurementActive(e){this.viewModel.triangularMeasurementActive=e}get videoLoaded(){const{mode:e,videoElement:t,panoramicVideoLoaded:i}=this.viewModel;return("video"===e&&!0===t?.loaded||i)??!1}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set determineWorkflowForFeature(e){this.viewModel.determineWorkflowForFeature=e}get determineWorkflowForFeature(){return this.viewModel.determineWorkflowForFeature}get shouldShowSelectedImage(){return this.viewModel.shouldShowSelectedImage}set shouldShowSelectedImage(e){this.viewModel.shouldShowSelectedImage=e}get superimposeViewEnabled(){return this.viewModel.superimposeViewEnabled}set superimposeViewEnabled(e){this.viewModel.superimposeViewEnabled=e}get defaultSuperimposeCameraLockEnabled(){return this.viewModel.defaultSuperimposeCameraLockEnabled}set defaultSuperimposeCameraLockEnabled(e){this.viewModel.defaultSuperimposeCameraLockEnabled=e}set updateFootprint(e){this.viewModel.updateFootprint=e}get updateFootprint(){return this.viewModel.updateFootprint}get verticalFilterEnabled(){return this.viewModel.verticalFilterEnabled}set verticalFilterEnabled(e){this.viewModel.verticalFilterEnabled=e}_renderActionBar(){const{selectedGroup:e,superimposeViewEnabled:i}=this;if(i)return se("calcite-action-bar",{expandDisabled:!0,layout:"horizontal",slot:"action-bar"},se("calcite-action-group",null,this._superimposeViewToggle()));const a=t();return se("calcite-action-bar",{expandDisabled:!0,layout:"horizontal",slot:"action-bar"},!e&&se("calcite-action-group",null,this._searchGroupToggle(),this._overlaysGroupToggle(),this._navigationGroupToggle(),this._measurementsGroupToggle(),this._utilitiesGroupToggle()),this._renderGroupBackAction(a),"overlays"===e&&se("calcite-action-group",null,this._currentFootprintToggle(),this._additionalFootprintToggle(),this._additionalPointSourcesToggle(),this._mapImageConversionToggle(),this._imageOverlaysToggle()),"navigation"===e&&se("calcite-action-group",null,this._directionToolsToggle(),this._navigationToolToggle(),this._imageGalleryToggle()),"measurements"===e&&se("calcite-action-group",null,this._measurementToolToggle()),"utilities"===e&&se("calcite-action-group",null,this._imageEnhancementsToggle(),this._videoEnhancementsToggle(),this._superimposeViewToggle(),this._openPopupAction()),"search"===e&&se("calcite-action-group",null,this._exploreImagesToggle(),this._exploreImages3DToggle(),this._showSelectedImageToggle()))}_renderGroupBackAction(e){return this.selectedGroup?se("calcite-action",{bind:this,icon:e?"arrow-right":"arrow-left",key:"back-arrow",text:this.messages.previous,title:this.messages.previous,onclick:()=>this._toggleGroupSelection(null)}):null}get _activeMeasurementHeading(){const{measureType:e,messages:t,triangularMeasurementActive:i}=this,{groundArea:a,heightAboveGround:s,groundDistance:o,triangulatedAreaHeading:n,triangulatedDistanceHeading:r}=t;if(i)return"area"===e?n:r;switch(e){case"area":return a;case"height":return s;default:return o}}_additionalFootprintToggle(){const{isAdditionalCoverageVisible:e,invalidCameraHeading:t,visibleElements:{additionalFootprintToggle:i}}=this;return i?se("calcite-action",{active:e,bind:this,class:E.addCoverage,disabled:t,icon:"trapezoid-area",text:this.messages.additionalFootprints,title:this.messages.additionalFootprints,onclick:this._toggleAdditionalCoverage}):null}_additionalPointSourcesToggle(){const{isAdditionalPointSourcesVisible:e,invalidCameraHeading:t,visibleElements:{additionalCameraLocationsToggle:i}}=this;return i?se("calcite-action",{active:e,bind:this,class:E.addExpPoints,disabled:t,icon:"circle-area",text:this.messages.additionalCameraLocations,title:this.messages.additionalCameraLocations,onclick:this._toggleAdditionalCameraLocations}):null}get _measurementToggle(){const{viewModel:{state:e,measureType:t,currentBestFeatureMeasurementImage:i},triangularMeasurementActive:a,id:s}=this;if("image-loaded"!==e||!t||a&&!i)return;this._imageMeasurementToolsLoaderTask||this._loadImageMeasurementResources();const o=this._imageMeasurementToolsLoaderTask?.value;return o?se("calcite-dialog",{bind:this,dragEnabled:!0,escapeDisabled:!0,heading:this._activeMeasurementHeading,id:`${s}-${t}-measurement`,open:!0,placement:"bottom-start",resizable:!0,scale:"s",slot:"dialogs",width:"s",onCalciteDialogBeforeClose:this._clearMeasurements},se(o,{measurementType:t,measurementUnitMessages:this.measurementUnitMessages,messages:this.messages,oiViewModel:this.viewModel})):null}get _renderRoot(){const{viewModel:{state:e},triangularMeasurementActive:t}=this;return se("calcite-panel",{bind:this,class:t?E.viewerContainerMeasurement:E.viewerContainer,heading:this.visibleElements.header?this.messages.title:void 0,loading:e.includes("loading")&&!t},this.visibleElements.menu?this._renderActionBar():null,se("calcite-shell",null,se("calcite-panel",null,this._imageViewer,this._panoramicViewer,this._panoramicVideoViewer,this._videoViewer,this._messageBox,this.invalidCameraHeading?null:[this._imageGalleryPanel,this._renderNavigation,this._imageOverlaysPanel()],this._imageEnhancementTools,this._videoEnhancementTools,this._superimposeTools,this._renderSketch(),this._navigationUI),this._imageViewerTriangular,this._measurementToggle,this._locationToggle,this.invalidCameraHeading?this._renderWarning(this.messages.invalidCameraHeadingWarningTitle,this.messages.invalidCameraHeadingWarningDescription):null,this.depthImageNotSupported?this._renderWarning(this.messages.depthImageNotSupportedTitle,this.messages.depthImageNotSupportedDescription):null,this.noImageInSequenceError?this._renderWarning(this.messages.sequentialNavigationWarning,this.messages.sequentialNavigationWarning,this._closeImageSequenceAlert):null))}_currentFootprintToggle(){const{currentCoverageVisible:e,invalidCameraHeading:t}=this,{currentFootprintToggle:i}=this.visibleElements;return i?se("calcite-action",{active:e,bind:this,class:E.currentCoverage,disabled:t,icon:"trapezoid-area",text:this.messages.currentFootprint,title:this.messages.currentFootprint,onclick:this._toggleCurrentCoverage}):null}_exploreImagesToggle(){const{exploreImages:e}=this.messages;return this.visibleElements.exploreImages?se("calcite-action",{active:!this.disabled,bind:this,icon:"oriented-imagery-widget",text:e,title:e,onclick:this._toggleExploreImages}):null}get _imageEnhancementTools(){const{enhancementToolActive:e,viewModel:{brightness:t,contrast:i,sharpness:a,state:s}}=this;return e&&"image-loaded"===s?se("calcite-panel",{bind:this,class:E.imageEnhancementWrapper,closable:!0,closed:!e,heading:this.messages.imageEnhancement,key:this.messages.imageEnhancement,onCalcitePanelClose:this._toggleEnhancementToolState},se("div",{class:E.imageEnhancementTools},K({title:this.messages.brightness,value:t,max:10,min:-10,ticks:5,handleChange:this._handleBrightnessChange}),K({title:this.messages.contrast,value:i,max:10,min:-10,ticks:5,handleChange:this._handleContrastChange}),K({title:this.messages.sharpness,value:a,max:1,min:0,ticks:.5,step:.1,handleChange:this._handleSharpnessChange})),se("calcite-action",{bind:this,icon:"reset",slot:"header-actions-end",text:this.messagesCommon.reset,title:this.messagesCommon.reset,onclick:this._resetImageTools})):null}get _videoEnhancementTools(){const{enhancementToolActive:e,viewModel:{videoViewModel:t,mode:i},messages:{videoEnhancement:a,brightness:s,contrast:o},messagesCommon:{reset:n}}=this;return e&&"video"===i&&t?se(Q,{brightness:t.videoBrightness,constrast:t.videoContrast,handleBrightnessChange:this._handleVideoBrightnessChange,handleContrastChange:this._handleVideoContrastChange,resetTools:this._resetVideoTools,uiStrings:{videoEnhancement:a,brightness:s,contrast:o,reset:n},videoEnhancementToolActive:e,onClose:this._toggleEnhancementToolState}):null}get _superimposeTools(){const{superimposeViewEnabled:e,view:t,viewModel:{state:i,mode:a},messages:{superimposeSettings:s,superimposeSliderTitle:o,superimposeSliderTooltip:n}}=this,r="panoramic"===a;return e&&"3d"===t?.type&&"image-loaded"===i?se("calcite-panel",{bind:this,class:this.classes(E.imageEnhancementWrapper,E.superimposeTools),heading:s,key:"superimpose-settings"},se("div",{class:E.imageEnhancementTools},K({title:o,tooltip:n,value:r?this._panoramicSuperimposeRadiusOffsetPercentage:this._defaultSuperimposeZOffsetPercentage,max:100,min:0,ticks:10,step:1,handleChange:this._handleSuperimposeZOffsetChange})),se("calcite-action",{bind:this,icon:"reset",slot:"header-actions-end",text:this.messagesCommon.reset,title:this.messagesCommon.reset,onclick:this._resetSuperimposeOffset})):null}_imageEnhancementsToggle(){const{state:e,mode:t}=this.viewModel,{enhancementTool:i}=this.visibleElements;return i&&"video"!==t?se("calcite-action",{active:this.enhancementToolActive,bind:this,disabled:"default"!==t||"image-loaded"!==e,icon:"sliders-horizontal",text:this.messages.imageEnhancement,title:this.messages.imageEnhancement,onclick:this._toggleEnhancementToolState}):null}_exploreImages3DToggle(){const{exploreImages3D:e}=this.messages,t="3d"!==this.view?.type||!this.layer?.verticalSearchRange;return this.visibleElements.exploreImages3D?se("calcite-action",{active:this.verticalFilterEnabled,bind:this,disabled:t,icon:"i3DSearch",text:e,title:e,onclick:this._toggleVerticalSearchFilter}):null}_showSelectedImageToggle(){const{displayImages:e}=this.messages,t=this.viewModel.mode.includes("video");return this.visibleElements.showSelectedImage?se("calcite-action",{active:this.shouldShowSelectedImage,bind:this,disabled:t,icon:"show-oriented-imagery",text:e,title:e,onclick:this._toggleShowSelectedImage}):null}_superimposeViewToggle(){const{superimposeView:e}=this.messages,{mode:t,accuracyParametersMissing:i}=this.viewModel,a=!this.superimposeViewEnabled&&("3d"!==this.view?.type||t.includes("video")||i);return this.visibleElements.superimpose?se("calcite-action",{active:this.superimposeViewEnabled,bind:this,disabled:a,icon:"superimpose",text:e,title:e,onclick:this._toggleSuperimposeView}):null}_videoEnhancementsToggle(){const{mode:e}=this.viewModel,{videoEnhancement:t}=this.messages,{enhancementTool:i}=this.visibleElements;return i&&"video"===e?se("calcite-action",{active:this.enhancementToolActive,bind:this,disabled:"video"!==e,icon:"sliders-horizontal",text:t,title:t,onclick:this._toggleEnhancementToolState}):null}get _imageGalleryPanel(){const{container:e,galleryOpened:t,imageGalleryEnabled:i}=this;return i&&t&&e?this._imageGalleryContext:null}get _imageGalleryContext(){const{galleryOpened:e,invalidCameraHeading:t}=this;return se("calcite-panel",{bind:this,class:E.carousel,closable:!0,closed:!e,disabled:t,heading:this.messages.imageGallery,key:this.messages.imageGallery,onCalcitePanelClose:this._toggleImageGallery},se("div",{class:E.carouselContainer},this._renderThumbnails))}_imageGalleryToggle(){const{imageGalleryEnabled:e,invalidCameraHeading:t,visibleElements:{imageGallery:i}}=this;return i?se("calcite-action",{active:this.galleryOpened,bind:this,disabled:!e||t,icon:"images",text:this.messages.imageGallery,title:this.messages.imageGallery,onclick:this._toggleImageGallery}):null}get _imageOverlaysComponent(){const{_imageOverlayMessages:e,_imageOverlaysLoaderTask:t,_overlayedLayers:i,dataCaptureEnabled:a,dataCaptureLayer:o,imageOverlaysOpened:n,showCameraLocations:r,showMapFeatures:l,view:d,layer:c}=this;if(!c)return null;const g=c.imageGeometryField?.length?c.imageGeometryField:I,h=c.imageReferenceField?.length?c.imageReferenceField:S;t||(this._imageOverlaysLoaderTask=s(async()=>(await import("./OrientedImageryViewer/components/ImageOverlays.js")).default));const m=this._imageOverlaysLoaderTask?.value;return m?se(m,{closed:!n,dataCaptureEnabled:a,dataCaptureLayer:o,imageGeometryField:g,imageReferenceField:h,messages:e,overlayedLayers:i,showCameraLocations:r,showMapFeatures:l,view:d,onDataCaptureLayerChanged:this._handleDataCaptureLayerChange,onFilterCapturedFeatures:this.viewModel.filterCapturedFeatures,onImageOverlaysClosed:this._onImageOverlayClosed,onLayerDeselected:this._handleOverlayLayerDeselect,onLayerSelected:this._handleOverlayLayerSelect,onShowCameraLocationsChanged:this._onShowCameraLocationsChanged,onShowMapFeaturesChanged:this._onShowMapFeaturesChanged}):null}get _navigationUI(){const{navigationMode:e,viewModel:t}=this,{mode:i,state:a}=t;if(e&&("default"===i||"panoramic"===i)&&"image-loaded"===a)return"directional"===e?"default"===i?se(W,{cameraHeadingThreshold:this.cameraHeadingThreshold,cameraPitchThreshold:this.cameraPitchThreshold,currentNode:this.viewModel.currentNode,navigate:this._createNavigationTask,nodes:this.viewModel.navigationNodes,preserveAngle:this.viewModel.preserveAngle}):se(Z,{currentNode:this.viewModel.currentNode,navigate:this._createNavigationTask,nodes:this.viewModel.navigationNodes}):se(z,{layout:"horizontal",uiStrings:{end:this.messages.end,next:this.messages.next,previous:this.messages.previous,start:this.messages.start},onNext:this._navigateNext,onPrev:this._navigatePrevious})}get _imageOverlayMessages(){return{...this.messages,...this.messagesSketch}}get _imageSketchToolsMessages(){return{...this.messagesCommon,...this.messagesSketch}}_imageOverlaysPanel(){const{imageOverlaysOpened:e}=this,t=this.classes({[E.imageOverlaysContainer]:!0,[ee.hidden]:!e||!this._imageOverlaysEnabled});return se("div",{class:t,key:this.messages.imageOverlays},this._imageOverlaysComponent)}_imageOverlaysToggle(){const{imageOverlaysOpened:e,invalidCameraHeading:t,visibleElements:{imageOverlays:i}}=this;return i?se("calcite-action",{active:e,bind:this,disabled:!this._imageOverlaysEnabled||t,icon:"layers",text:this.messages.imageOverlays,title:this.messages.imageOverlays,onclick:this._toggleImageOverlays}):null}get _imageOverlaysEnabled(){return this.viewModel.overlayGraphicsEnabled}get _imageViewer(){const{displayMessage:e,loadImageViewer:t,mode:i,clickAction:a,state:s}=this.viewModel,o=null!=e||"default"!==i||s.includes("loading");return se(U,{afterCreate:t,clickAction:a,visible:!o})}get _imageViewerTriangular(){const{messages:e,triangularMeasurementActive:t}=this,{displayMessage:i,storeImageMeasurementViewer:a,storePanoramicMeasurementViewer:s,mode:o,state:n,clickAction:r}=this.viewModel,l=null!=i||"none"===o||"video"===o,d=this.classes({[E.viewer]:!l,[E.viewerHidden]:l});return t?se("calcite-panel",{class:E.viewerContainerMeasurement,heading:e.measurementViewerHeading,loading:n.includes("loading")},se("calcite-panel",{bind:this,class:d},"default"===o?se(U,{afterCreate:a,clickAction:r,uiStrings:e}):se(T,{afterCreate:s,clickAction:r,uiStrings:e}))):null}_utilitiesGroupToggle(){const{utilityTools:e}=this.messages;return this.visibleElements.utilityTools?se("calcite-action",{bind:this,icon:"tools",key:"utilities-group-toggle",text:e,title:e,onclick:()=>this._toggleGroupSelection("utilities")}):null}_searchGroupToggle(){const{searchTools:e}=this.messages;return this.visibleElements.searchTools?se("calcite-action",{bind:this,icon:"search",key:"search-group-toggle",text:e,title:e,onclick:()=>this._toggleGroupSelection("search")}):null}get _videoViewer(){const{mode:e,loadVideoViewer:t,videoViewModel:i}=this.viewModel,{control:a,reset:s}=this.messagesCommon,{mute:o,unmute:n}=this.messages,r="video"!==e,l=this.classes({[E.viewer]:!r,[E.viewerHidden]:r}),d="esri-image-viewer",c=`${d}__slider-container`;return se("calcite-panel",{bind:this,class:l},se("calcite-panel",{afterCreate:t,class:this.classes(ee.widget,d)}),se("calcite-block",{class:c,expanded:!0},se("calcite-slider",{bind:this,labelHandles:!0,labelTicks:!0,max:i?.videoDuration,minLabel:"0",value:i?.currentTime??0,onCalciteSliderChange:this._handleVideoSeek})),se("calcite-action-bar",{expandDisabled:!0,layout:"horizontal"},se("calcite-action-group",null,se("calcite-action",{bind:this,icon:this.activeVideoIcon,text:"Play",title:i?.videoPaused?a.play:a.pause,onclick:()=>i?.playVideoHandler()})),se("calcite-action-group",null,se("calcite-action",{bind:this,icon:"refresh",text:"Rewind",title:s,onclick:()=>i?.rewindVideoHandler()})),se("calcite-action-group",null,se("calcite-action",{bind:this,icon:this.activeAudioIcon,text:"Audio",title:i?.videoMuted?o:n,onclick:()=>i?.toggleAudio()}))))}get _locationToggle(){const{viewModel:{state:e,groundCoordinates:t,groundCoordinatesAccuracy:i,triangulatedPoint:a},imageLocationToolActive:s,triangularMeasurementActive:o,messages:{groundLocation:n,triangulatedLocationHeading:r}}=this;if("image-loaded"!==e||!t||!s)return;let l=t;if(o){if(!a)return;l=a}return se("calcite-dialog",{bind:this,dragEnabled:!0,escapeDisabled:!0,heading:o?r:n,id:n,open:!0,placement:"bottom-start",resizable:!0,scale:"s",slot:"dialogs",width:"s",onCalciteDialogBeforeClose:this._clearImageLocation},se(q,{accuracy:i,groundCoordinates:l,messages:this.messages}))}_mapImageConversionToggle(){const{mapImageConversionToolState:e,viewModel:{state:t,disabled:i},videoLoaded:a,invalidCameraHeading:s,visibleElements:{mapImageConversionTool:o}}=this,n=!("video"!==this.viewModel.mode||!a||!this.viewModel.videoViewModel?.videoPaused),r="panoramic-video"===this.viewModel.mode&&this.viewModel.panoramicVideoLoaded&&this.viewModel.panoramicVideoPaused;return o?se("calcite-action",{active:e,bind:this,disabled:"image-loaded"!==t&&!n&&!r||s||i,icon:"image-pin",text:this.messages.mapImageConversionTool,title:this.messages.mapImageConversionTool,onclick:this._toggleMapImageConversionToolState}):null}_measurementToolToggle(){const{measureType:e,viewModel:t,accuracyParametersMissing:i,messages:a,triangularMeasurementActive:s}=this,{state:o}=t,{groundDistance:n,groundArea:r,heightAboveGround:l,groundLocation:d,triangulatedDistanceHeading:c,triangulatedAreaHeading:g,triangulatedLocationHeading:h}=a,m="image-loaded"!==o||i;return se("calcite-action-group",{key:"measurement-tools",scale:"m"},se("calcite-action",{active:"distance"===e&&!s,bind:this,disabled:m,icon:"measure-line",key:"distance-measurement",text:n,title:n,onclick:e=>this._toggleMeasurementSketch(e,"distance")}),se("calcite-action",{active:"area"===e&&!s,bind:this,disabled:m,icon:"measure-area",key:"area-measurement",text:r,title:r,onclick:e=>this._toggleMeasurementSketch(e,"area")}),se("calcite-action",{active:"height"===e,bind:this,disabled:m,icon:"measure-building-height-top-base",key:"height-measurement",text:l,title:l,onclick:e=>this._toggleMeasurementSketch(e,"height")}),se("calcite-action",{active:!!this.imageLocationToolActive&&!s,bind:this,disabled:m,icon:"pin-tear",key:"surface-location",text:d,title:d,onclick:this._toggleLocationTool}),se("calcite-action",{active:!!s&&this.imageLocationToolActive,bind:this,disabled:m,icon:"dual-image-location",key:"triangular-location",text:h,title:h,onclick:this._toggleTriangularLocation}),se("calcite-action",{active:!!s&&"distance"===this.measureType,bind:this,disabled:m,icon:"dual-image-distance",key:"triangular-distance",text:c,title:c,onclick:this._toggleTriangularDistanceMeasurements}),se("calcite-action",{active:!!s&&"area"===this.measureType,bind:this,disabled:m,icon:"dual-image-area",key:"triangular-area",text:g,title:g,onclick:this._toggleTriangularAreaMeasurements}))}get _messageBox(){const{messages:e,viewModel:{displayMessage:t,mode:a}}=this;if(!t||"video"===a)return null;const{key:s,map:o,type:n}=t,r=`${o?i(e[s],o):e[s]}`,l="error"===n?"danger":"warn"===n?"warning":"info";return se("calcite-notice",{appearance:"transparent",class:E.notice,icon:te[l],kind:l,open:!0},se("div",{slot:"message"},r))}async _loadNavigationSettings(){return this._navigationSettingsLoaderTask||(this._navigationSettingsLoaderTask=s(async()=>(await import("./OrientedImageryViewer/components/NavigationSettings.js")).default)),await this._navigationSettingsLoaderTask.promise}_measurementsGroupToggle(){const{measurementTools:e}=this.messages,{state:t,accuracyParametersMissing:i}=this.viewModel,a="image-loaded"!==t||i;return this.visibleElements.measurementTools?se("calcite-action",{bind:this,disabled:a,icon:"measure-line",key:"measurements-group-toggle",text:e,title:e,onclick:()=>this._toggleGroupSelection("measurements")}):null}_navigationGroupToggle(){const{imageNavigation:e}=this.messages;return this.visibleElements.imageNavigationTools?se("calcite-action",{bind:this,icon:"absolute-direction",key:"navigation-group-toggle",text:e,title:e,onclick:()=>this._toggleGroupSelection("navigation")}):null}_navigationToolToggle(){const{state:e}=this.viewModel,{visibleElements:{navigationTool:t},videoLoaded:i}=this;return t?se("calcite-action",{active:this.navigationToolActive,bind:this,disabled:"image-loaded"!==e&&!i||this.invalidCameraHeading,icon:"explore",text:this.messages.navigationTool,title:this.messages.navigationTool,onclick:this._toggleNavigationTool}):null}_directionToolsToggle(){const{messages:e,viewModel:t,visibleElements:i}=this,{directionalNavigation:a,sequentialNavigation:s}=i,{state:o}=t,{directionalNavigation:n,directionalNavigationDescription:r,sequentialNavigation:l,sequentialNavigationDescription:d}=e;return se("calcite-action-group",{key:"navigation-tools",scale:"m"},a?se("calcite-action",{active:"directional"===this.navigationMode,bind:this,disabled:"image-loaded"!==o||this.invalidCameraHeading,icon:"directional-navigation",text:r,title:n,onclick:()=>{this._toggleImageNavigation("directional")}}):null,s?se("calcite-action",{active:"sequential"===this.navigationMode,bind:this,disabled:"image-loaded"!==o||this.invalidCameraHeading||!this.canNavigateSequentially,icon:"sequential-navigation",text:d,title:l,onclick:()=>{this._toggleImageNavigation("sequential")}}):null)}_overlaysGroupToggle(){const{overlays:e}=this.messages;return this.visibleElements.overlays?se("calcite-action",{bind:this,icon:"oriented-imagery-overlays",key:"overlays-group-toggle",text:e,title:e,onclick:()=>this._toggleGroupSelection("overlays")}):null}_openPopupAction(){const{showPopupsAction:e}=this.visibleElements;return e?se("calcite-action",{bind:this,disabled:!this.popupEnabled,icon:"popup",text:this.messages.showPopups,title:this.messages.showPopups,onclick:this._toggleImageAttributes}):null}get _panoramicVideoViewer(){const{displayMessage:e,loadPanoramicVideoViewer:t,mode:i,clickAction:a,state:s,currentBestFeature:o}=this.viewModel,n=o?.attributes.imagePath,r=null!=e||"panoramic-video"!==i||s.includes("loading")||!n;return se(M,{afterCreate:t,clickAction:a,oiViewModel:this.viewModel,videoSource:n,visible:!r})}get _panoramicViewer(){const{displayMessage:e,loadPanoramicViewer:t,mode:i,clickAction:a,state:s}=this.viewModel,o=null!=e||"panoramic"!==i||s.includes("loading");return se(T,{afterCreate:t,clickAction:a,visible:!o})}get noImageInSequenceError(){return this._get("noImageInSequenceError")??!1}_activateTriangulatedImageLocationTool(){this.navigationToolActive=!0,this.imageLocationToolActive=!0}_activateTriangulatedImageLocationWorkflow(e,t){this._closeAllImageTools(),this.imageLocationToolActive=!0,this.triangularMeasurementActive=!e,this.navigationToolActive=!!t||!t}_closeImageToolsAndToggleNavigation(e,t){this._closeAllImageTools(),this.triangularMeasurementActive=!e,this.navigationToolActive=!t}_resetMeasureTypeAndActivateImageLocationTool(){this.measureType=null,this.imageLocationToolActive=!0}_closeAllImageTools(){this.enhancementToolActive=!1,this.navigationToolActive=!1,this.imageOverlaysOpened=!1,this.galleryOpened=!1,this.measureType=null,this.imageLocationToolActive=!1,this.navigationMode=null,this.triangularMeasurementActive=!1,this._settingsToggle&&(this._settingsToggle.expanded=!1,this.viewModel.activeViewer?.ui.remove(this._settingsToggle))}_handleBrightnessChange(e){this.viewModel.brightness=e.currentTarget.value??0}_handleVideoBrightnessChange(e){this.viewModel.videoViewModel?.handleVideoBrightnessChange(e.target.value)}_handleContrastChange(e){this.viewModel.contrast=e.currentTarget.value??0}_handleVideoContrastChange(e){this.viewModel.videoViewModel?.handleVideoContrastChange(e.target.value)}_handleVideoSeek(e){const t=this.viewModel?.videoElement?.content;t&&(t.currentTime=e.target.value,t.play())}_handleSharpnessChange(e){this.viewModel.sharpness=e.currentTarget.value??0}_handleSuperimposeZOffsetChange(e){const t=e.currentTarget.value??0;if("default"===this.viewModel.mode)return this._defaultSuperimposeZOffsetPercentage=t,void this.viewModel.setDefaultSuperimposeZOffsetPercentage(100-t);this._panoramicSuperimposeRadiusOffsetPercentage=t,this.viewModel.setPanoramicSuperimposeRadiusPercentage(100-t)}_lazyLoadImage(e,t){e.forEach(async e=>{if(e.isIntersecting){const a=e.target,s=a.getAttribute("data-src"),o=a.getAttribute("data-rotation"),n=a.getAttribute("data-objectid"),r=o?parseFloat(o)%360:0,{layer:c,_galleryController:{signal:g}}=this;if(!s||!n)return;let h;try{h=G(s)?await N(c,n,{signal:g}):await D(s,{signal:g})}catch(i){d(i)||l.getLogger("esri.widgets.OrientedImageryViewer").error("#lazyLoadImage()",i)}finally{t.unobserve(a)}if(!h)return;H(h,a,r)}})}_loadImageFromGallery(e){const{target:t}=e;if(!t)return;const i=t.getAttribute("data-objectid");i&&this.viewModel.currentBestFeature?.attributes.objectId!==Number(i)&&this.viewModel.selectBestFeature(i)}_loadImageMeasurementResources(){this._imageMeasurementToolsLoaderTask=s(async()=>{const{default:e}=await import("./OrientedImageryViewer/components/ImageMeasurementWidget.js");return e})}_loadSketchResources(){this._sketchLoaderTask=s(async()=>(await import("./OrientedImageryViewer/components/SketchTools.js")).default)}_onAdditionalCoverageVisibilityChange(e){this.viewModel.setAdditionalCoverageVisibility(e)}_onAdditionalCameraLocationsVisibility(e){this.viewModel.setAdditionalCameraLocationsVisibility(e)}_onCurrentCoverageVisibilityChange(e){this.viewModel.setCurrentCoverageVisibility(e)}_registerGalleryItem(e){this._galleryObserver.observe(e)}_renderWarning(e,t,i){const{viewModel:{state:a}}=this;return"image-loaded"===a?se(R,{icon:"exclamation-mark-triangle-f",kind:"warning",message:t,open:!0,title:e,tooltip:t,topLayerDisabled:this.topLayerDisabled,onClose:i}):null}get _renderNavigation(){const{viewModel:{sectorData:e,navigatorCurrentBestFeature:t,currentBestFeature:i,state:s}}=this;if(!this.container||!i)return null;let o,n,r,l,d;if(t){const{x:e,y:i,direction:a}=t,[s,c,g,h]=A[a];o=`M ${e} ${i} L ${s} ${c} A ${L[2]} ${L[2]} 0 0 1 ${g} ${h} Z`,n=e,l=i,r=A[a][4],d=A[a][5]}const c=e=>{const t=e.target.dataset?.sector;t&&this.viewModel.handleSectorClick(+t)},g=e=>{const t=e.target.dataset;if(!t)return;const{featureIndexInSector:i,sector:a}=t;i&&a&&this.viewModel.handleFeatureClick({sector:a,featureIndexInSector:+i})},h=e=>{e.removeEventListener("click",g)},m=i.attributes.objectId,u=e?.map(e=>e?.items).filter(Boolean).flatMap(e=>e?.map(({x:e,y:t,objectID:i,featureIndexInSector:a,sector:s})=>se("circle",{afterRemoved:h,class:this.classes(E.feature,{selected:m===i}),cx:e,cy:t,"data-feature-index-in-sector":a,"data-sector":s,key:`${E.feature}-${i}`,r:k,onclick:g}))),p=e=>{e.removeEventListener("click",c)},v=this.classes({[E.navigationWrapper]:!0,[E.navigationZoomed]:this._navigationToolExpanded});return this.navigationToolActive&&("image-loaded"===s||this.videoLoaded)?se("div",{bind:this,class:v,key:this.messages.navigationTool},se("svg",{afterCreate:e=>this._storeNavigationToolReference(e),class:a()?O:E.rotateWithAnimation,focusable:"false",height:V,role:"img",width:V,xmlns:"http://www.w3.org/2000/svg"},se("defs",null,se("linearGradient",{gradientUnits:"userSpaceOnUse",id:`${this.id}-coverage-fill`,x1:n,x2:r,y1:l,y2:d},se("stop",{class:E.navigationPathOffset0,offset:0}),se("stop",{class:E.navigationPathOffset1,offset:1}))),se("g",null,se("circle",{class:this.classes(E.sector,E.outerSector),cx:L[3],cy:L[3],r:L[3],onclick:this._scaleNavigationTool}),se("circle",{class:E.sector,cx:L[3],cy:L[3],r:L[2]}),se("circle",{class:E.sector,cx:L[3],cy:L[3],r:L[1]}),se("circle",{class:E.sector,cx:L[3],cy:L[3],r:L[0]}),se("path",{class:E.pointer,d:"M 56.5 6.06217782649107 L 60 0 L 63.5 6.06217782649107 Z",key:`${E.pointer}-west`}),se("path",{class:this.classes(E.pointer,E.north),d:"M 113.93782217350893 56.5 L 120 60 L 113.93782217350893 63.5 Z",key:`${E.pointer}-north`}),se("path",{class:E.pointer,d:"M 56.5 113.93782217350893 L 60 120 L 63.5 113.93782217350893 Z",key:`${E.pointer}-east`}),se("path",{class:E.pointer,d:"M 6.06217782649107 56.5 L 0 60 L 6.06217782649107 63.5 Z",key:`${E.pointer}-south`}),se("path",{class:this.classes(E.sector,E.sectorSeparator),d:"M 23.937554159486076 23.937554159486076 L 96.06244584051393 96.06244584051393 M 23.937554159486076 96.06244584051393 L 96.06244584051393 23.937554159486076",key:E.sectorSeparator}),C([L[2],L[1],L[0]],L[3],L[3]).map((t,i)=>se("path",{afterRemoved:p,class:this.classes(E.sector,e?.[i]?.length?E.sectorEnabled:E.sectorDisabled),d:t,"data-sector":`${i}`,key:`${E.sector}-${i}`,onclick:c})),se("path",{class:this.classes(E.sector,E.sectorCross),d:"M 56.4 56.4 L 63.53 63.53 M 63.53 56.4 L 56.4 63.53",key:E.sectorCross}),u,i.attributes.cameraPitch>=5&&o?se("path",{class:E.selectedFeaturePath,d:o,fill:`url(#${this.id}-coverage-fill)`,key:E.selectedFeaturePath}):null))):null}_renderSketch(){const{dataCaptureLayer:e,imageOverlaysOpened:t}=this;if(!e||t)return null;if(this._sketchLoaderTask||this._loadSketchResources(),!this._sketchLoaderTask?.value)return null;const{geometryType:i}=e,a="point"===i?"pin":"polyline"===i?"line":"polygon",s=this._sketchLoaderTask.value;return se("div",{class:E.sketchTools},se(s,{icon:a,messages:this._imageSketchToolsMessages,type:i,onAction:this._onAction}))}get _renderThumbnails(){const{currentBestFeature:e,thumbnails:t}=this.viewModel;return e?se("div",{class:E.carouselContent},t?.items.map(({url:t,objectId:i,rotation:a},s)=>se("div",{class:`${E.carouselItemWrapper}${e.attributes.objectId===i?"--selected":""}`,key:`${E.carouselItemWrapper}-${s}`},se("canvas",{afterCreate:this._registerGalleryItem,afterRemoved:this._unregisterGalleryItem,alt:`thumbnail-${i}`,class:E.carouselItem,"data-objectid":`${i}`,"data-rotation":`${a}`,"data-src":t,onclick:this._loadImageFromGallery,onmouseenter:this._highlight,onmouseleave:this._removeHighlight})))):null}_resetImageTools(){this.viewModel.sharpness=this.viewModel.brightness=this.viewModel.contrast=0}_resetVideoTools(){this.viewModel.videoViewModel?.resetVideoEnhancementTools()}_storeNavigationToolReference(e){this._navigationTool=e}_toggleAdditionalCameraLocations(){this.isAdditionalPointSourcesVisible=!this.isAdditionalPointSourcesVisible}_toggleAdditionalCoverage(){this.isAdditionalCoverageVisible=!this.isAdditionalCoverageVisible}_toggleCurrentCoverage(){this.currentCoverageVisible=!this.currentCoverageVisible}_toggleShowSelectedImage(){this.shouldShowSelectedImage=!this.shouldShowSelectedImage,this._toggleDisabledViewer(this.shouldShowSelectedImage)}_resetSuperimposeOffset(){if("default"===this.viewModel.mode)return this._defaultSuperimposeZOffsetPercentage=100,void this.viewModel.setDefaultSuperimposeZOffsetPercentage(0);this._panoramicSuperimposeRadiusOffsetPercentage=100,this.viewModel.setPanoramicSuperimposeRadiusPercentage(0)}_toggleSuperimposeCameraLock(){this.viewModel.updateDefaultSuperimposeCameraLock(!this.defaultSuperimposeCameraLockEnabled)}_toggleSuperimposeView(){this.superimposeViewEnabled=!this.superimposeViewEnabled}_toggleVerticalSearchFilter(){this.verticalFilterEnabled=!this.verticalFilterEnabled,this._toggleDisabledViewer(this.verticalFilterEnabled)}_toggleDisabledViewer(e){e&&(this.disabled=!1)}_toggleEnhancementToolState(e){e.stopPropagation();const t=this.enhancementToolActive;this._closeAllImageTools(),this.enhancementToolActive=!t}_toggleExploreImages(){this.disabled=!this.disabled,this.disabled&&(this.shouldShowSelectedImage=!1,this.verticalFilterEnabled=!1)}_toggleGroupSelection(e){this.selectedGroup=e}_toggleImageOverlays(e){e.stopPropagation();const t=this.imageOverlaysOpened;this._closeAllImageTools(),this.imageOverlaysOpened=!t}_toggleImageGallery(e){e.stopPropagation();const t=this.galleryOpened;this._closeAllImageTools(),this.galleryOpened=!!this.imageGalleryEnabled&&!t}_toggleLocationTool(e){const t=this.imageLocationToolActive,i=this.triangularMeasurementActive&&t;this._closeAllImageTools(),this.imageLocationToolActive=i||!t,e.stopPropagation()}_toggleMeasurementSketch(e,t){e.stopPropagation();const i=this.measureType,a=this.triangularMeasurementActive;this._closeAllImageTools(),this.measureType=i!==t||a?t:null,this.measureType===t&&(this.viewModel.displayNewMeasurementButton=!0)}_toggleNavigationTool(){const e=this.navigationToolActive;this._closeAllImageTools(),this.navigationToolActive=!e}_toggleMapImageConversionToolState(){this.mapImageConversionToolState=!this.mapImageConversionToolState}_toggleTriangularAreaMeasurements(){this._toggleTriangularMeasurements("area")}_toggleTriangularDistanceMeasurements(){this._toggleTriangularMeasurements("distance")}_toggleTriangularLocation(){const e=this.triangularMeasurementActive,t=this.navigationToolActive;e?null===this.measureType?this.imageLocationToolActive?this._closeImageToolsAndToggleNavigation(e,t):this._activateTriangulatedImageLocationTool():this._resetMeasureTypeAndActivateImageLocationTool():this._activateTriangulatedImageLocationWorkflow(e,t)}_toggleTriangularMeasurements(e){const t=this.triangularMeasurementActive,i=this.viewModel.measureType,a=this.navigationToolActive;t?e===i?(this._closeAllImageTools(),this.triangularMeasurementActive=!t,this.navigationToolActive=!a):(this.imageLocationToolActive=!1,this.measureType=e):(this._closeAllImageTools(),this.measureType=e,this.triangularMeasurementActive=!t,this.navigationToolActive=!!a||!a)}_unregisterGalleryItem(e){this._galleryObserver.unobserve(e)}_updateNavigationTool(e){const{previousFeatureAngle:t,bestFeatureAngle:i}=this.viewModel,a=(i-t+540)%360-180;e.style.setProperty(P,`${t}deg`),e.style.setProperty(F,`${t+a}deg`)}async loadBestImage(e,t){return this.viewModel.loadBestImage(e,t)}loadImageFromSource(e,t,i){return"default"===e?this.viewModel.loadMediaSource(t,i):this.viewModel.loadPanoramicMediaSource(t,i)}async overlayMapFeatures(e,t){return this.removeHandles(`${oe.overlayed}-${e.id}`),this.addHandles(c(()=>e.visible,()=>{this.viewModel.toggleOverlayMapFeatures(e.id,e.visible,this.showMapFeatures)}),`${oe.overlayed}-${e.id}`),this._overlayedLayers.add(e),this.viewModel.overlayMapFeatures(e,t&&this.showMapFeatures)}async plotMapPoint(e){return this.viewModel.plotMapPoint(e)}plotReferencePointOnGround(e){this.viewModel.plotReferencePointOnGround(e)}plotReferencePointOnImage(e){this.viewModel.plotReferencePointOnImage(e)}removeOverlayedGraphicsOnImage(e){this.removeHandles(`${oe.overlayed}-${e}`),this._overlayedLayers.remove(this._overlayedLayers.find(t=>t.id===e)),this.viewModel.removeOverlayedGraphicsOnImage(e)}resetImage(){this.viewModel.resetImage()}render(){return se("div",{class:this.classes(ee.widget,x)},this._renderRoot)}async showImageByObjectId(e,t){return this.viewModel.showImageByObjectId(e,t)}async startDataCapture(e){return this.viewModel.startDataCapture(e)}async stopDataCapture(e){return this.viewModel.stopDataCapture(e)}updateSuitabilities(e){this.viewModel.updateSuitabilities(e)}};e([v({readOnly:!0})],ne.prototype,"accuracyParametersMissing",null),e([v()],ne.prototype,"activeLayer",null),e([v()],ne.prototype,"activeVideoIcon",null),e([v()],ne.prototype,"activeAudioIcon",null),e([v()],ne.prototype,"cameraHeadingThreshold",null),e([v()],ne.prototype,"cameraPitchThreshold",null),e([v()],ne.prototype,"canNavigateSequentially",null),e([v()],ne.prototype,"currentBestFeature",null),e([v()],ne.prototype,"currentCoverageVisible",null),e([v()],ne.prototype,"dataCaptureEnabled",void 0),e([v()],ne.prototype,"dataCaptureLayer",null),e([v()],ne.prototype,"depthImageNotSupported",null),e([v()],ne.prototype,"disabled",null),e([v()],ne.prototype,"enhancementToolActive",null),e([v()],ne.prototype,"features",null),e([v()],ne.prototype,"imagePointsInView",null),e([v()],ne.prototype,"galleryOpened",void 0),e([v()],ne.prototype,"icon",null),e([v()],ne.prototype,"imageEnhancementToolActive",void 0),e([v()],ne.prototype,"videoEnhancementToolActive",void 0),e([v({readOnly:!0})],ne.prototype,"imageGalleryEnabled",null),e([v()],ne.prototype,"imageLocationToolActive",null),e([v()],ne.prototype,"imageOverlaysOpened",void 0),e([v({readOnly:!0})],ne.prototype,"invalidCameraHeading",null),e([v()],ne.prototype,"isAdditionalCoverageVisible",null),e([v()],ne.prototype,"isAdditionalPointSourcesVisible",null),e([v()],ne.prototype,"mapImageConversionToolState",null),e([v()],ne.prototype,"measureType",null),e([v()],ne.prototype,"layer",null),e([v()],ne.prototype,"navigationToolActive",void 0),e([v()],ne.prototype,"navigationMode",null),e([ie(f()),v({type:j})],ne.prototype,"viewModel",void 0),e([v(),ae("esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer")],ne.prototype,"messages",void 0),e([v(),ae("esri/core/t9n/Units")],ne.prototype,"measurementUnitMessages",void 0),e([v(),ae("esri/t9n/common")],ne.prototype,"messagesCommon",void 0),e([v(),ae("esri/widgets/Sketch/t9n/Sketch")],ne.prototype,"messagesSketch",void 0),e([v()],ne.prototype,"pixelMeasurementUnit",void 0),e([v()],ne.prototype,"pixelAreaMeasurementUnit",void 0),e([v({readOnly:!0})],ne.prototype,"popupEnabled",null),e([v()],ne.prototype,"preloadMedia",null),e([v()],ne.prototype,"referencePoint",null),e([v()],ne.prototype,"selectedGroup",void 0),e([v()],ne.prototype,"showCameraLocations",void 0),e([v()],ne.prototype,"showMapFeatures",void 0),e([ie(["create","delete","redo","undo","update"]),v({readOnly:!0})],ne.prototype,"sketchViewModel",null),e([v()],ne.prototype,"triangularMeasurementActive",null),e([v()],ne.prototype,"videoLoaded",null),e([v()],ne.prototype,"view",null),e([v({type:$,nonNullable:!0})],ne.prototype,"visibleElements",void 0),e([v()],ne.prototype,"determineWorkflowForFeature",null),e([v()],ne.prototype,"shouldShowSelectedImage",null),e([v()],ne.prototype,"superimposeViewEnabled",null),e([v()],ne.prototype,"defaultSuperimposeCameraLockEnabled",null),e([v()],ne.prototype,"updateFootprint",null),e([v()],ne.prototype,"verticalFilterEnabled",null),e([v()],ne.prototype,"_defaultSuperimposeZOffsetPercentage",void 0),e([v()],ne.prototype,"_panoramicSuperimposeRadiusOffsetPercentage",void 0),e([v()],ne.prototype,"_activeMeasurementHeading",null),e([v()],ne.prototype,"_imageOverlaysLoaderTask",void 0),e([v()],ne.prototype,"_imageMeasurementToolsLoaderTask",void 0),e([v()],ne.prototype,"_navigationSettingsLoaderTask",void 0),e([v()],ne.prototype,"_navigationTask",void 0),e([v()],ne.prototype,"_measurementToggle",null),e([v()],ne.prototype,"_renderRoot",null),e([v()],ne.prototype,"_imageEnhancementTools",null),e([v()],ne.prototype,"_videoEnhancementTools",null),e([v()],ne.prototype,"_superimposeTools",null),e([v()],ne.prototype,"_imageGalleryPanel",null),e([v()],ne.prototype,"_imageGalleryContext",null),e([v()],ne.prototype,"_imageOverlaysComponent",null),e([v()],ne.prototype,"_navigationUI",null),e([v()],ne.prototype,"_imageOverlayMessages",null),e([v()],ne.prototype,"_imageSketchToolsMessages",null),e([v()],ne.prototype,"_imageOverlaysEnabled",null),e([v()],ne.prototype,"_imageViewer",null),e([v()],ne.prototype,"_imageViewerTriangular",null),e([v()],ne.prototype,"_videoViewer",null),e([v()],ne.prototype,"_locationToggle",null),e([v()],ne.prototype,"_messageBox",null),e([v()],ne.prototype,"_navigationToolExpanded",void 0),e([v()],ne.prototype,"_navigationTool",void 0),e([v()],ne.prototype,"_panoramicVideoViewer",null),e([v()],ne.prototype,"_panoramicViewer",null),e([v({readOnly:!0})],ne.prototype,"noImageInSequenceError",null),e([v()],ne.prototype,"_renderNavigation",null),e([v()],ne.prototype,"_renderThumbnails",null),e([v()],ne.prototype,"_sketchLoaderTask",void 0),ne=e([y("esri.widgets.OrientedImageryViewer")],ne);const re=ne;export{re as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{prefersRTL as t,substitute as i}from"../intl.js";import{prefersReducedMotion as a}from"../core/a11yUtils.js";import{createTask as s}from"../core/asyncUtils.js";import o from"../core/Collection.js";import{deprecateWidget as n,deprecatedProperty as r}from"../core/deprecate.js";import l from"../core/Logger.js";import{isAbortError as d}from"../core/promiseUtils.js";import{watch as c,initial as g,syncAndInitial as h,on as m,sync as u}from"../core/reactiveUtils.js";import{throttle as p}from"../core/throttle.js";import{property as v,subclass as y}from"../core/accessorSupport/decorators.js";import{or as w}from"../layers/orientedImagery/transformations/utils.js";import _ from"./Expand.js";import M from"./PanoramicVideoViewer.js";import T from"./PanoramicViewer.js";import b from"./Widget.js";import{getAllArcPath as C}from"./OrientedImageryViewer/arcUtils.js";import{getDelegatedEvents as f,defaultImageGeometryField as I,defaultOIObjectIDField as S,segmentArcs as A,featureCircleRadius as k,navigationToolDimensionLength as V,sectorsRadii as L}from"./OrientedImageryViewer/constants.js";import{css as E,navigation as O,navigationToolRotationFrom as P,navigationToolRotationTo as F,root as x}from"./OrientedImageryViewer/css.js";import{isFeatureAttachment as G,loadImageForAttachment as N,getThumbnailPixelBlock as D,renderImageWithRotation as H}from"./OrientedImageryViewer/galleryUtils.js";import j from"./OrientedImageryViewer/OrientedImageryViewerViewModel.js";import $ from"./OrientedImageryViewer/OrientedImageryViewerVisibleElements.js";import{loadAlertComponents as B,Alert as R}from"./OrientedImageryViewer/components/Alert.js";import W from"./OrientedImageryViewer/components/ImageLocationWidget.js";import q from"./OrientedImageryViewer/components/ImageViewer.js";import U from"./OrientedImageryViewer/components/NavigationUI.js";import Z from"./OrientedImageryViewer/components/NavigationUI360.js";import{SequentialNavigationUI as z}from"./OrientedImageryViewer/components/SequentialNavigationUI.js";import{loadVideoEnhancementComponents as J,renderEnhancementSlider as K,VideoEnhancementTools as Q}from"./OrientedImageryViewer/components/VideoEnhancementTools.js";import{NoImageLoadedError as X}from"./OrientedImageryViewer/navigation/errors.js";import{loadCalciteComponents as Y}from"./support/componentsUtils.js";import{globalCss as ee}from"./support/globalCss.js";import{iconByKind as te}from"./support/iconUtils.js";import{vmEvent as ie,messageBundle as ae,tsx as se}from"./support/widget.js";const oe={overlayed:"overlayed"};let ne=class extends b{constructor(e,t){super(e,t),this.dataCaptureEnabled=!1,this.galleryOpened=!1,this.imageEnhancementToolActive=!1,this.videoEnhancementToolActive=!1,this.imageOverlaysOpened=!1,this.navigationToolActive=!1,this.viewModel=new j,this.messagesCommon=null,this.messagesSketch=null,this.pixelMeasurementUnit="meters",this.pixelAreaMeasurementUnit="square-meters",this.selectedGroup=null,this.showCameraLocations=!1,this.showMapFeatures=!1,this.visibleElements=new $,this._defaultSuperimposeZOffsetPercentage=100,this._panoramicSuperimposeRadiusOffsetPercentage=100,this._imageOverlaysLoaderTask=null,this._imageMeasurementToolsLoaderTask=null,this._navigationSettingsLoaderTask=null,this._navigationTask=null,this._clearMeasurements=()=>{this.viewModel.measureType=null,this.viewModel.triangularMeasurementActive=!1,this.viewModel.clearPreviousMeasurements()},this._clearImageLocation=()=>{this.imageLocationToolActive=!1,this.triangularMeasurementActive=!1},this._createNavigationTask=async e=>(this._navigationTask?.abort(),this._navigationTask=s(async t=>await this.navigate({...e,signal:t})),this._navigationTask.promise),this._navigateNext=async()=>await this._createNavigationTask({step:1}),this._navigatePrevious=async()=>await this._createNavigationTask({step:-1}),this._navigationToolExpanded=!1,this._navigationTool=null,this._galleryController=new AbortController,this._galleryObserver=new IntersectionObserver(this._lazyLoadImage.bind(this)),this._overlayedLayers=new o,this._previousAction=null,this._closeImageSequenceAlert=()=>{this._set("noImageInSequenceError",!1)},this._handleDataCaptureLayerChange=async e=>{if(this.dataCaptureLayer&&await this.stopDataCapture(!0),this.dataCaptureLayer=this.dataCaptureLayer===e?null:e,this.dataCaptureLayer)return this.startDataCapture(this.dataCaptureLayer)},this._handleNavigationSettingsInputChange=(e,t)=>{this.set(`${e}Threshold`,t)},this._handleNavigationSettingsToggle=e=>{this.viewModel.preserveAngle=e},this._handleOverlayLayerDeselect=e=>{const t=e.layer;t===this.dataCaptureLayer&&(this.stopDataCapture(),this.dataCaptureLayer=null),this.removeOverlayedGraphicsOnImage(`${t.id}`)},this._handleOverlayLayerSelect=e=>{const t=e.layer;this.viewModel.overlayMapFeatures(t,this.showMapFeatures),this.addHandles(c(()=>t.visible,()=>{this.viewModel.toggleOverlayMapFeatures(t.id,t.visible,this.showMapFeatures)}),`${oe.overlayed}-${t.id}`)},this._highlight=e=>{const t=e.target?.dataset.objectid;t&&this.viewModel.highlight(t)},this._onAction=e=>{const{target:t}=e,{dataset:{action:i}}=t,{_previousAction:a}=this,s=a?.dataset.action,o=s?.includes("draw")??!1,n="select-feature"===s,r=s!==i;switch(i){case"draw-point":case"draw-polygon":case"draw-polyline":{a&&w(n,o&&r)&&(a.active=!1),t.active=!t.active;const e=i.replace("draw-","");this.viewModel.digitizeCreate(e),this._previousAction=t.active?t:null;break}case"save":this.viewModel.saveDrawing();break;case"select-feature":o&&(this._previousAction.active=!1),t.active=!t.active,this.viewModel.toggleSelection(t.active),this._previousAction=t.active?t:null;break;case"delete-feature":this.viewModel.digitizeDelete()}},this._onImageOverlayClosed=e=>{e.stopPropagation(),this.imageOverlaysOpened=!1},this._onShowCameraLocationsChanged=e=>{this.showCameraLocations=e},this._onShowMapFeaturesChanged=e=>{this.showMapFeatures=e},this._removeHighlight=()=>this.viewModel.removeHighlight(),this._restoreOverlays=async()=>Promise.all(this._overlayedLayers.map(e=>this.viewModel.overlayMapFeatures(e,this.showMapFeatures))),this._scaleNavigationTool=()=>{this._navigationToolExpanded=!this._navigationToolExpanded},this._sketchLoaderTask=null,this._settingsToggle=null,this._toggleImageNavigation=async e=>{const t=this.navigationMode;this._closeAllImageTools(),this.navigationMode=t!==e?e:null;const{activeViewer:i}=this.viewModel;if(!i)return;const{mode:a,preserveAngle:s}=this.viewModel;if("default"===a)if("directional"===this.navigationMode){const e=await this._loadNavigationSettings(),t="heading"===s||"both"===s,i="pitch"===s||"both"===s,{messages:a,messagesCommon:o}=this,n=new e({cameraHeadingThreshold:this.cameraHeadingThreshold,cameraPitchThreshold:this.cameraPitchThreshold,uiStrings:{configureNavigation:a.configureNavigation,preserveHeading:a.preserveHeading,preserveHeadingDescription:a.preserveHeadingDescription,preservePitch:a.preservePitch,preservePitchDescription:a.preservePitchDescription,settings:o.settings,thresholdLabel:a.thresholdLabel},onInputChange:this._handleNavigationSettingsInputChange,onToggle:this._handleNavigationSettingsToggle,preserveHeading:t,preservePitch:i});this._settingsToggle=new _({content:n,expandIcon:"configure"}),this.viewModel.activeViewer?.ui.add(this._settingsToggle,{position:"top-left"})}else this._settingsToggle&&(this._settingsToggle.expanded=!1,this.viewModel.activeViewer?.ui.remove(this._settingsToggle))},this._toggleImageAttributes=p(this.viewModel.toggleImageAttributes.bind(this.viewModel)),this.navigate=async e=>{let t=null;try{const{currentNode:i}=this.viewModel;if(!i)throw new X;t=await this.viewModel.navigate(i,e)}catch(i){d(i)||l.getLogger(this).error("Error occurred while navigating",i),["NoImageInSequenceError","NoSequenceFoundError"].includes(i.name)&&this._set("noImageInSequenceError",!0)}return t},this.reset=()=>{this._closeAllImageTools(),this.viewModel.reset()},this._loadImageFromGallery=this._loadImageFromGallery.bind(this),this._registerGalleryItem=this._registerGalleryItem.bind(this),this._unregisterGalleryItem=this._unregisterGalleryItem.bind(this),this.loadImageFromSource=this.loadImageFromSource.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this._handleVideoBrightnessChange=this._handleVideoBrightnessChange.bind(this),this._handleVideoContrastChange=this._handleVideoContrastChange.bind(this),this._handleBrightnessChange=this._handleBrightnessChange.bind(this),this._handleContrastChange=this._handleContrastChange.bind(this),this._handleSharpnessChange=this._handleSharpnessChange.bind(this),this._handleSuperimposeZOffsetChange=this._handleSuperimposeZOffsetChange.bind(this),this._toggleSuperimposeCameraLock=this._toggleSuperimposeCameraLock.bind(this),this._resetSuperimposeOffset=this._resetSuperimposeOffset.bind(this),this._resetVideoTools=this._resetVideoTools.bind(this),this._toggleEnhancementToolState=this._toggleEnhancementToolState.bind(this),this.announceDeprecation=()=>{n(l.getLogger(this),"Oriented Imagery Viewer","arcgis-oriented-imagery-viewer",{version:"5.0"})}}initialize(){this.addHandles([c(()=>[this.viewModel?.bestFeatureAngle,this._navigationTool],([e,t])=>{t&&this._updateNavigationTool(t)},g),c(()=>this.currentCoverageVisible,e=>this._onCurrentCoverageVisibilityChange(e)),c(()=>this.isAdditionalCoverageVisible,e=>this._onAdditionalCoverageVisibilityChange(e)),c(()=>this.isAdditionalPointSourcesVisible,e=>this._onAdditionalCameraLocationsVisibility(e)),c(()=>this.superimposeViewEnabled,e=>{e?(this._closeAllImageTools(),this.selectedGroup=null,this.shouldShowSelectedImage=!1,this.verticalFilterEnabled=!1):this._resetSuperimposeOffset()}),c(()=>({features:this.currentBestFeature,overlaysEnabled:this._imageOverlaysEnabled,showCameraLocations:this.showCameraLocations}),({overlaysEnabled:e,showCameraLocations:t})=>{e&&this.viewModel.overlayCameraLocations(t)},h),c(()=>({feature:this.currentBestFeature,overlaysEnabled:this._imageOverlaysEnabled,showMapFeatures:this.showMapFeatures}),async(e,t)=>{e.showMapFeatures!==t?.showMapFeatures&&await this.viewModel.toggleAllOverlayMapFeatures(e.showMapFeatures);const i=e.feature&&e.feature!==t?.feature,a=!e.overlaysEnabled&&!!t?.overlaysEnabled,s=e.overlaysEnabled&&!t?.overlaysEnabled,o="video"===this.viewModel.mode||"panoramic-video"===this.viewModel.mode;if(a&&o)return this.viewModel.removeAllOverlayMapFeatures(),void("video"===this.viewModel.mode&&this.viewModel.videoViewModel?.clearOverlayGraphics());(i||s)&&(i&&this.viewModel.removeAllOverlayMapFeatures(),e.overlaysEnabled&&(this.dataCaptureLayer&&this.stopDataCapture(),await this._restoreOverlays(),this.dataCaptureLayer&&(await this.startDataCapture(this.dataCaptureLayer),this._previousAction?.active&&(this._previousAction.active=!1,this._previousAction=null))))},g),m(()=>this.viewModel,"popup-open",async e=>{await(this.view?.openPopup(e))},u),m(()=>this.viewModel,"popup-close",()=>{this.view?.closePopup()},u),this._toggleImageAttributes])}loadDependencies(){return Promise.all([J(),Y({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),shell:()=>import("@esri/calcite-components/dist/components/calcite-shell"),dialog:()=>import("@esri/calcite-components/dist/components/calcite-dialog"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")}),B()])}destroy(){this._galleryController.abort(),this._galleryObserver.disconnect(),this.currentBestFeature=null}get accuracyParametersMissing(){return this.viewModel.accuracyParametersMissing}get activeLayer(){return r(l.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){r(l.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeVideoIcon(){const{videoElement:e,videoViewModel:t}=this.viewModel;return e?.loaded&&t?t.videoPaused?"play":"pause":"play"}get activeAudioIcon(){const{videoElement:e,videoViewModel:t}=this.viewModel;return e?.loaded&&t?.videoMuted?"sound-off":"sound"}get cameraHeadingThreshold(){return this.viewModel.cameraHeadingThreshold}set cameraHeadingThreshold(e){this.viewModel.cameraHeadingThreshold=e}get cameraPitchThreshold(){return this.viewModel.cameraPitchThreshold}set cameraPitchThreshold(e){this.viewModel.cameraPitchThreshold=e}get canNavigateSequentially(){return!!this.layer?.effectiveSequenceOrderField?.length}get currentBestFeature(){return this.viewModel.currentBestFeature}set currentBestFeature(e){this.viewModel.currentBestFeature=e}get currentCoverageVisible(){return this.viewModel.currentCoverageVisible}set currentCoverageVisible(e){this.viewModel.currentCoverageVisible=e}get dataCaptureLayer(){return this.viewModel.dataCaptureLayer}set dataCaptureLayer(e){this.viewModel.dataCaptureLayer=e}get depthImageNotSupported(){return this.viewModel.depthImageNotSupported}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get displayMessage(){return this.viewModel.displayMessage}get enhancementToolActive(){return"video"===this.viewModel.mode?this.videoEnhancementToolActive:this.imageEnhancementToolActive}set enhancementToolActive(e){"video"===this.viewModel.mode?this.videoEnhancementToolActive=e:this.imageEnhancementToolActive=e}get features(){return this.viewModel.features}get imagePointsInView(){return this.viewModel.imagePointsInView}get icon(){return"oriented-imagery-widget"}set icon(e){this._overrideIfSome("icon",e)}get imageGalleryEnabled(){return this.viewModel.imageGalleryEnabled}get imageLocationToolActive(){return this.viewModel.imageLocationToolState}set imageLocationToolActive(e){this.viewModel.imageLocationToolState=e}get invalidCameraHeading(){return this.viewModel.invalidCameraHeading}get isAdditionalCoverageVisible(){return this.viewModel.isAdditionalCoverageVisible}set isAdditionalCoverageVisible(e){this.viewModel.isAdditionalCoverageVisible=e}get isAdditionalPointSourcesVisible(){return this.viewModel.isAdditionalPointSourcesVisible}set isAdditionalPointSourcesVisible(e){this.viewModel.isAdditionalPointSourcesVisible=e}get mapImageConversionToolState(){return this.viewModel.mapImageConversionToolState}set mapImageConversionToolState(e){this.viewModel.setMapImageConversionToolState(e)}get measureType(){return this.viewModel.measureType}set measureType(e){this.viewModel.measureType=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get navigationMode(){return this.viewModel.navigationMode}set navigationMode(e){this.viewModel.navigationMode=e}get popupEnabled(){const{popupEnabled:e,state:t}=this.viewModel;return("image-loaded"===t||this.videoLoaded)&&e}get preloadMedia(){return this.viewModel.preloadMedia}set preloadMedia(e){this.viewModel.preloadMedia=e}get referencePoint(){return this.viewModel.referencePoint??null}get sketchViewModel(){return this.viewModel.sketch}get triangularMeasurementActive(){return this.viewModel.triangularMeasurementActive}set triangularMeasurementActive(e){this.viewModel.triangularMeasurementActive=e}get videoLoaded(){const{mode:e,videoElement:t,panoramicVideoLoaded:i}=this.viewModel;return("video"===e&&!0===t?.loaded||i)??!1}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set determineWorkflowForFeature(e){this.viewModel.determineWorkflowForFeature=e}get determineWorkflowForFeature(){return this.viewModel.determineWorkflowForFeature}get shouldShowSelectedImage(){return this.viewModel.shouldShowSelectedImage}set shouldShowSelectedImage(e){this.viewModel.shouldShowSelectedImage=e}get superimposeViewEnabled(){return this.viewModel.superimposeViewEnabled}set superimposeViewEnabled(e){this.viewModel.superimposeViewEnabled=e}get defaultSuperimposeCameraLockEnabled(){return this.viewModel.defaultSuperimposeCameraLockEnabled}set defaultSuperimposeCameraLockEnabled(e){this.viewModel.defaultSuperimposeCameraLockEnabled=e}set updateFootprint(e){this.viewModel.updateFootprint=e}get updateFootprint(){return this.viewModel.updateFootprint}get verticalFilterEnabled(){return this.viewModel.verticalFilterEnabled}set verticalFilterEnabled(e){this.viewModel.verticalFilterEnabled=e}_renderActionBar(){const{selectedGroup:e,superimposeViewEnabled:i}=this;if(i)return se("calcite-action-bar",{expandDisabled:!0,layout:"horizontal",slot:"action-bar"},se("calcite-action-group",null,this._superimposeViewToggle()));const a=t();return se("calcite-action-bar",{expandDisabled:!0,layout:"horizontal",slot:"action-bar"},!e&&se("calcite-action-group",null,this._searchGroupToggle(),this._overlaysGroupToggle(),this._navigationGroupToggle(),this._measurementsGroupToggle(),this._utilitiesGroupToggle()),this._renderGroupBackAction(a),"overlays"===e&&se("calcite-action-group",null,this._currentFootprintToggle(),this._additionalFootprintToggle(),this._additionalPointSourcesToggle(),this._mapImageConversionToggle(),this._imageOverlaysToggle()),"navigation"===e&&se("calcite-action-group",null,this._directionToolsToggle(),this._navigationToolToggle(),this._imageGalleryToggle()),"measurements"===e&&se("calcite-action-group",null,this._measurementToolToggle()),"utilities"===e&&se("calcite-action-group",null,this._imageEnhancementsToggle(),this._videoEnhancementsToggle(),this._superimposeViewToggle(),this._openPopupAction()),"search"===e&&se("calcite-action-group",null,this._exploreImagesToggle(),this._exploreImages3DToggle(),this._showSelectedImageToggle()))}_renderGroupBackAction(e){return this.selectedGroup?se("calcite-action",{bind:this,icon:e?"arrow-right":"arrow-left",key:"back-arrow",text:this.messages.previous,title:this.messages.previous,onclick:()=>this._toggleGroupSelection(null)}):null}get _activeMeasurementHeading(){const{measureType:e,messages:t,triangularMeasurementActive:i}=this,{groundArea:a,heightAboveGround:s,groundDistance:o,triangulatedAreaHeading:n,triangulatedDistanceHeading:r}=t;if(i)return"area"===e?n:r;switch(e){case"area":return a;case"height":return s;default:return o}}_additionalFootprintToggle(){const{isAdditionalCoverageVisible:e,invalidCameraHeading:t,visibleElements:{additionalFootprintToggle:i}}=this;return i?se("calcite-action",{active:e,bind:this,class:E.addCoverage,disabled:t,icon:"trapezoid-area",text:this.messages.additionalFootprints,title:this.messages.additionalFootprints,onclick:this._toggleAdditionalCoverage}):null}_additionalPointSourcesToggle(){const{isAdditionalPointSourcesVisible:e,invalidCameraHeading:t,visibleElements:{additionalCameraLocationsToggle:i}}=this;return i?se("calcite-action",{active:e,bind:this,class:E.addExpPoints,disabled:t,icon:"circle-area",text:this.messages.additionalCameraLocations,title:this.messages.additionalCameraLocations,onclick:this._toggleAdditionalCameraLocations}):null}get _measurementToggle(){const{viewModel:{state:e,measureType:t,currentBestFeatureMeasurementImage:i},triangularMeasurementActive:a,id:s}=this;if("image-loaded"!==e||!t||a&&!i)return;this._imageMeasurementToolsLoaderTask||this._loadImageMeasurementResources();const o=this._imageMeasurementToolsLoaderTask?.value;return o?se("calcite-dialog",{bind:this,dragEnabled:!0,escapeDisabled:!0,heading:this._activeMeasurementHeading,id:`${s}-${t}-measurement`,open:!0,placement:"bottom-start",resizable:!0,scale:"s",slot:"dialogs",width:"s",onCalciteDialogBeforeClose:this._clearMeasurements},se(o,{measurementType:t,measurementUnitMessages:this.measurementUnitMessages,messages:this.messages,oiViewModel:this.viewModel})):null}get _renderRoot(){const{viewModel:{state:e},triangularMeasurementActive:t}=this;return se("calcite-panel",{bind:this,class:t?E.viewerContainerMeasurement:E.viewerContainer,heading:this.visibleElements.header?this.messages.title:void 0,loading:e.includes("loading")&&!t},this.visibleElements.menu?this._renderActionBar():null,se("calcite-shell",null,se("calcite-panel",null,this._imageViewer,this._panoramicViewer,this._panoramicVideoViewer,this._videoViewer,this._messageBox,this.invalidCameraHeading?null:[this._imageGalleryPanel,this._renderNavigation,this._imageOverlaysPanel()],this._imageEnhancementTools,this._videoEnhancementTools,this._superimposeTools,this._renderSketch(),this._navigationUI),this._imageViewerTriangular,this._measurementToggle,this._locationToggle,this.invalidCameraHeading?this._renderWarning(this.messages.invalidCameraHeadingWarningTitle,this.messages.invalidCameraHeadingWarningDescription):null,this.depthImageNotSupported?this._renderWarning(this.messages.depthImageNotSupportedTitle,this.messages.depthImageNotSupportedDescription):null,this.noImageInSequenceError?this._renderWarning(this.messages.sequentialNavigationWarning,this.messages.sequentialNavigationWarning,this._closeImageSequenceAlert):null))}_currentFootprintToggle(){const{currentCoverageVisible:e,invalidCameraHeading:t}=this,{currentFootprintToggle:i}=this.visibleElements;return i?se("calcite-action",{active:e,bind:this,class:E.currentCoverage,disabled:t,icon:"trapezoid-area",text:this.messages.currentFootprint,title:this.messages.currentFootprint,onclick:this._toggleCurrentCoverage}):null}_exploreImagesToggle(){const{exploreImages:e}=this.messages;return this.visibleElements.exploreImages?se("calcite-action",{active:!this.disabled,bind:this,icon:"oriented-imagery-widget",text:e,title:e,onclick:this._toggleExploreImages}):null}get _imageEnhancementTools(){const{enhancementToolActive:e,viewModel:{brightness:t,contrast:i,sharpness:a,state:s}}=this;return e&&"image-loaded"===s?se("calcite-panel",{bind:this,class:E.imageEnhancementWrapper,closable:!0,closed:!e,heading:this.messages.imageEnhancement,key:this.messages.imageEnhancement,onCalcitePanelClose:this._toggleEnhancementToolState},se("div",{class:E.imageEnhancementTools},K({title:this.messages.brightness,value:t,max:10,min:-10,ticks:5,handleChange:this._handleBrightnessChange}),K({title:this.messages.contrast,value:i,max:10,min:-10,ticks:5,handleChange:this._handleContrastChange}),K({title:this.messages.sharpness,value:a,max:1,min:0,ticks:.5,step:.1,handleChange:this._handleSharpnessChange})),se("calcite-action",{bind:this,icon:"reset",slot:"header-actions-end",text:this.messagesCommon.reset,title:this.messagesCommon.reset,onclick:this._resetImageTools})):null}get _videoEnhancementTools(){const{enhancementToolActive:e,viewModel:{videoViewModel:t,mode:i},messages:{videoEnhancement:a,brightness:s,contrast:o},messagesCommon:{reset:n}}=this;return e&&"video"===i&&t?se(Q,{brightness:t.videoBrightness,constrast:t.videoContrast,handleBrightnessChange:this._handleVideoBrightnessChange,handleContrastChange:this._handleVideoContrastChange,resetTools:this._resetVideoTools,uiStrings:{videoEnhancement:a,brightness:s,contrast:o,reset:n},videoEnhancementToolActive:e,onClose:this._toggleEnhancementToolState}):null}get _superimposeTools(){const{superimposeViewEnabled:e,view:t,viewModel:{state:i,mode:a},messages:{superimposeSettings:s,superimposeSliderTitle:o,superimposeSliderTooltip:n}}=this,r="panoramic"===a;return e&&"3d"===t?.type&&"image-loaded"===i?se("calcite-panel",{bind:this,class:this.classes(E.imageEnhancementWrapper,E.superimposeTools),heading:s,key:"superimpose-settings"},se("div",{class:E.imageEnhancementTools},K({title:o,tooltip:n,value:r?this._panoramicSuperimposeRadiusOffsetPercentage:this._defaultSuperimposeZOffsetPercentage,max:100,min:0,ticks:10,step:1,handleChange:this._handleSuperimposeZOffsetChange})),se("calcite-action",{bind:this,icon:"reset",slot:"header-actions-end",text:this.messagesCommon.reset,title:this.messagesCommon.reset,onclick:this._resetSuperimposeOffset})):null}_imageEnhancementsToggle(){const{state:e,mode:t}=this.viewModel,{enhancementTool:i}=this.visibleElements;return i&&"video"!==t?se("calcite-action",{active:this.enhancementToolActive,bind:this,disabled:"default"!==t||"image-loaded"!==e,icon:"sliders-horizontal",text:this.messages.imageEnhancement,title:this.messages.imageEnhancement,onclick:this._toggleEnhancementToolState}):null}_exploreImages3DToggle(){const{exploreImages3D:e}=this.messages,t="3d"!==this.view?.type||!this.layer?.verticalSearchRange;return this.visibleElements.exploreImages3D?se("calcite-action",{active:this.verticalFilterEnabled,bind:this,disabled:t,icon:"i3DSearch",text:e,title:e,onclick:this._toggleVerticalSearchFilter}):null}_showSelectedImageToggle(){const{displayImages:e}=this.messages,t=this.viewModel.mode.includes("video");return this.visibleElements.showSelectedImage?se("calcite-action",{active:this.shouldShowSelectedImage,bind:this,disabled:t,icon:"show-oriented-imagery",text:e,title:e,onclick:this._toggleShowSelectedImage}):null}_superimposeViewToggle(){const{superimposeView:e}=this.messages,{mode:t,accuracyParametersMissing:i}=this.viewModel,a=!this.superimposeViewEnabled&&("3d"!==this.view?.type||t.includes("video")||i);return this.visibleElements.superimpose?se("calcite-action",{active:this.superimposeViewEnabled,bind:this,disabled:a,icon:"superimpose",text:e,title:e,onclick:this._toggleSuperimposeView}):null}_videoEnhancementsToggle(){const{mode:e}=this.viewModel,{videoEnhancement:t}=this.messages,{enhancementTool:i}=this.visibleElements;return i&&"video"===e?se("calcite-action",{active:this.enhancementToolActive,bind:this,disabled:"video"!==e,icon:"sliders-horizontal",text:t,title:t,onclick:this._toggleEnhancementToolState}):null}get _imageGalleryPanel(){const{container:e,galleryOpened:t,imageGalleryEnabled:i}=this;return i&&t&&e?this._imageGalleryContext:null}get _imageGalleryContext(){const{galleryOpened:e,invalidCameraHeading:t}=this;return se("calcite-panel",{bind:this,class:E.carousel,closable:!0,closed:!e,disabled:t,heading:this.messages.imageGallery,key:this.messages.imageGallery,onCalcitePanelClose:this._toggleImageGallery},se("div",{class:E.carouselContainer},this._renderThumbnails))}_imageGalleryToggle(){const{imageGalleryEnabled:e,invalidCameraHeading:t,visibleElements:{imageGallery:i}}=this;return i?se("calcite-action",{active:this.galleryOpened,bind:this,disabled:!e||t,icon:"images",text:this.messages.imageGallery,title:this.messages.imageGallery,onclick:this._toggleImageGallery}):null}get _imageOverlaysComponent(){const{_imageOverlayMessages:e,_imageOverlaysLoaderTask:t,_overlayedLayers:i,dataCaptureEnabled:a,dataCaptureLayer:o,imageOverlaysOpened:n,showCameraLocations:r,showMapFeatures:l,view:d,layer:c}=this,g=a&&!this.viewModel.mode.includes("video");if(!c)return null;const h=c.imageGeometryField?.length?c.imageGeometryField:I,m=c.imageReferenceField?.length?c.imageReferenceField:S;t||(this._imageOverlaysLoaderTask=s(async()=>(await import("./OrientedImageryViewer/components/ImageOverlays.js")).default));const u=this._imageOverlaysLoaderTask?.value;return u?se(u,{closed:!n,dataCaptureEnabled:g,dataCaptureLayer:o,imageGeometryField:h,imageReferenceField:m,messages:e,overlayedLayers:i,showCameraLocations:r,showMapFeatures:l,view:d,onDataCaptureLayerChanged:this._handleDataCaptureLayerChange,onFilterCapturedFeatures:this.viewModel.filterCapturedFeatures,onImageOverlaysClosed:this._onImageOverlayClosed,onLayerDeselected:this._handleOverlayLayerDeselect,onLayerSelected:this._handleOverlayLayerSelect,onShowCameraLocationsChanged:this._onShowCameraLocationsChanged,onShowMapFeaturesChanged:this._onShowMapFeaturesChanged}):null}get _navigationUI(){const{navigationMode:e,viewModel:t}=this,{mode:i,state:a}=t;if(e&&("default"===i||"panoramic"===i)&&"image-loaded"===a)return"directional"===e?"default"===i?se(U,{cameraHeadingThreshold:this.cameraHeadingThreshold,cameraPitchThreshold:this.cameraPitchThreshold,currentNode:this.viewModel.currentNode,navigate:this._createNavigationTask,nodes:this.viewModel.navigationNodes,preserveAngle:this.viewModel.preserveAngle}):se(Z,{currentNode:this.viewModel.currentNode,navigate:this._createNavigationTask,nodes:this.viewModel.navigationNodes}):se(z,{layout:"horizontal",uiStrings:{end:this.messages.end,next:this.messages.next,previous:this.messages.previous,start:this.messages.start},onNext:this._navigateNext,onPrev:this._navigatePrevious})}get _imageOverlayMessages(){return{...this.messages,...this.messagesSketch}}get _imageSketchToolsMessages(){return{...this.messagesCommon,...this.messagesSketch}}_imageOverlaysPanel(){const{imageOverlaysOpened:e}=this,t=this.classes({[E.imageOverlaysContainer]:!0,[ee.hidden]:!e||!this._imageOverlaysEnabled});return se("div",{class:t,key:this.messages.imageOverlays},this._imageOverlaysComponent)}_imageOverlaysToggle(){const{imageOverlaysOpened:e,invalidCameraHeading:t,visibleElements:{imageOverlays:i}}=this;return i?se("calcite-action",{active:e,bind:this,disabled:!this._imageOverlaysEnabled||t,icon:"layers",text:this.messages.imageOverlays,title:this.messages.imageOverlays,onclick:this._toggleImageOverlays}):null}get _imageOverlaysEnabled(){return this.viewModel.overlayGraphicsEnabled}get _imageViewer(){const{displayMessage:e,loadImageViewer:t,mode:i,clickAction:a,state:s}=this.viewModel,o=null!=e||"default"!==i||s.includes("loading");return se(q,{afterCreate:t,clickAction:a,visible:!o})}get _imageViewerTriangular(){const{messages:e,triangularMeasurementActive:t}=this,{displayMessage:i,storeImageMeasurementViewer:a,storePanoramicMeasurementViewer:s,mode:o,state:n,clickAction:r}=this.viewModel,l=null!=i||"none"===o||"video"===o,d=this.classes({[E.viewer]:!l,[E.viewerHidden]:l});return t?se("calcite-panel",{class:E.viewerContainerMeasurement,heading:e.measurementViewerHeading,loading:n.includes("loading")},se("calcite-panel",{bind:this,class:d},"default"===o?se(q,{afterCreate:a,clickAction:r,uiStrings:e}):se(T,{afterCreate:s,clickAction:r,uiStrings:e}))):null}_utilitiesGroupToggle(){const{utilityTools:e}=this.messages;return this.visibleElements.utilityTools?se("calcite-action",{bind:this,icon:"tools",key:"utilities-group-toggle",text:e,title:e,onclick:()=>this._toggleGroupSelection("utilities")}):null}_searchGroupToggle(){const{searchTools:e}=this.messages;return this.visibleElements.searchTools?se("calcite-action",{bind:this,icon:"search",key:"search-group-toggle",text:e,title:e,onclick:()=>this._toggleGroupSelection("search")}):null}get _videoViewer(){const{mode:e,loadVideoViewer:t,videoViewModel:i}=this.viewModel,{control:a,reset:s}=this.messagesCommon,{mute:o,unmute:n}=this.messages,r="video"!==e,l=this.classes({[E.viewer]:!r,[E.viewerHidden]:r}),d="esri-image-viewer",c=`${d}__slider-container`;return se("calcite-panel",{bind:this,class:l},se("calcite-panel",{afterCreate:t,class:this.classes(ee.widget,d)}),se("calcite-block",{class:c,expanded:!0},se("calcite-slider",{bind:this,labelHandles:!0,labelTicks:!0,max:i?.videoDuration,minLabel:"0",value:i?.currentTime??0,onCalciteSliderChange:this._handleVideoSeek})),se("calcite-action-bar",{expandDisabled:!0,layout:"horizontal"},se("calcite-action-group",null,se("calcite-action",{bind:this,icon:this.activeVideoIcon,text:"Play",title:i?.videoPaused?a.play:a.pause,onclick:()=>i?.playVideoHandler()})),se("calcite-action-group",null,se("calcite-action",{bind:this,icon:"refresh",text:"Rewind",title:s,onclick:()=>i?.rewindVideoHandler()})),se("calcite-action-group",null,se("calcite-action",{bind:this,icon:this.activeAudioIcon,text:"Audio",title:i?.videoMuted?o:n,onclick:()=>i?.toggleAudio()}))))}get _locationToggle(){const{viewModel:{state:e,groundCoordinates:t,groundCoordinatesAccuracy:i,triangulatedPoint:a},imageLocationToolActive:s,triangularMeasurementActive:o,messages:{groundLocation:n,triangulatedLocationHeading:r}}=this;if("image-loaded"!==e||!t||!s)return;let l=t;if(o){if(!a)return;l=a}return se("calcite-dialog",{bind:this,dragEnabled:!0,escapeDisabled:!0,heading:o?r:n,id:n,open:!0,placement:"bottom-start",resizable:!0,scale:"s",slot:"dialogs",width:"s",onCalciteDialogBeforeClose:this._clearImageLocation},se(W,{accuracy:i,groundCoordinates:l,messages:this.messages}))}_mapImageConversionToggle(){const{mapImageConversionToolState:e,viewModel:{state:t,disabled:i},videoLoaded:a,invalidCameraHeading:s,visibleElements:{mapImageConversionTool:o}}=this,n=!("video"!==this.viewModel.mode||!a||!this.viewModel.videoViewModel?.videoPaused),r="panoramic-video"===this.viewModel.mode&&this.viewModel.panoramicVideoLoaded&&this.viewModel.panoramicVideoPaused;return o?se("calcite-action",{active:e,bind:this,disabled:"image-loaded"!==t&&!n&&!r||s||i,icon:"image-pin",text:this.messages.mapImageConversionTool,title:this.messages.mapImageConversionTool,onclick:this._toggleMapImageConversionToolState}):null}_measurementToolToggle(){const{measureType:e,viewModel:t,accuracyParametersMissing:i,messages:a,triangularMeasurementActive:s}=this,{state:o}=t,{groundDistance:n,groundArea:r,heightAboveGround:l,groundLocation:d,triangulatedDistanceHeading:c,triangulatedAreaHeading:g,triangulatedLocationHeading:h}=a,m="image-loaded"!==o||i;return se("calcite-action-group",{key:"measurement-tools",scale:"m"},se("calcite-action",{active:"distance"===e&&!s,bind:this,disabled:m,icon:"measure-line",key:"distance-measurement",text:n,title:n,onclick:e=>this._toggleMeasurementSketch(e,"distance")}),se("calcite-action",{active:"area"===e&&!s,bind:this,disabled:m,icon:"measure-area",key:"area-measurement",text:r,title:r,onclick:e=>this._toggleMeasurementSketch(e,"area")}),se("calcite-action",{active:"height"===e,bind:this,disabled:m,icon:"measure-building-height-top-base",key:"height-measurement",text:l,title:l,onclick:e=>this._toggleMeasurementSketch(e,"height")}),se("calcite-action",{active:!!this.imageLocationToolActive&&!s,bind:this,disabled:m,icon:"pin-tear",key:"surface-location",text:d,title:d,onclick:this._toggleLocationTool}),se("calcite-action",{active:!!s&&this.imageLocationToolActive,bind:this,disabled:m,icon:"dual-image-location",key:"triangular-location",text:h,title:h,onclick:this._toggleTriangularLocation}),se("calcite-action",{active:!!s&&"distance"===this.measureType,bind:this,disabled:m,icon:"dual-image-distance",key:"triangular-distance",text:c,title:c,onclick:this._toggleTriangularDistanceMeasurements}),se("calcite-action",{active:!!s&&"area"===this.measureType,bind:this,disabled:m,icon:"dual-image-area",key:"triangular-area",text:g,title:g,onclick:this._toggleTriangularAreaMeasurements}))}get _messageBox(){const{messages:e,viewModel:{displayMessage:t,mode:a}}=this;if(!t||"video"===a)return null;const{key:s,map:o,type:n}=t,r=`${o?i(e[s],o):e[s]}`,l="error"===n?"danger":"warn"===n?"warning":"info";return se("calcite-notice",{appearance:"transparent",class:E.notice,icon:te[l],kind:l,open:!0},se("div",{slot:"message"},r))}async _loadNavigationSettings(){return this._navigationSettingsLoaderTask||(this._navigationSettingsLoaderTask=s(async()=>(await import("./OrientedImageryViewer/components/NavigationSettings.js")).default)),await this._navigationSettingsLoaderTask.promise}_measurementsGroupToggle(){const{measurementTools:e}=this.messages,{state:t,accuracyParametersMissing:i}=this.viewModel,a="image-loaded"!==t||i;return this.visibleElements.measurementTools?se("calcite-action",{bind:this,disabled:a,icon:"measure-line",key:"measurements-group-toggle",text:e,title:e,onclick:()=>this._toggleGroupSelection("measurements")}):null}_navigationGroupToggle(){const{imageNavigation:e}=this.messages;return this.visibleElements.imageNavigationTools?se("calcite-action",{bind:this,icon:"absolute-direction",key:"navigation-group-toggle",text:e,title:e,onclick:()=>this._toggleGroupSelection("navigation")}):null}_navigationToolToggle(){const{state:e}=this.viewModel,{visibleElements:{navigationTool:t},videoLoaded:i}=this;return t?se("calcite-action",{active:this.navigationToolActive,bind:this,disabled:"image-loaded"!==e&&!i||this.invalidCameraHeading,icon:"explore",text:this.messages.navigationTool,title:this.messages.navigationTool,onclick:this._toggleNavigationTool}):null}_directionToolsToggle(){const{messages:e,viewModel:t,visibleElements:i}=this,{directionalNavigation:a,sequentialNavigation:s}=i,{state:o}=t,{directionalNavigation:n,directionalNavigationDescription:r,sequentialNavigation:l,sequentialNavigationDescription:d}=e;return se("calcite-action-group",{key:"navigation-tools",scale:"m"},a?se("calcite-action",{active:"directional"===this.navigationMode,bind:this,disabled:"image-loaded"!==o||this.invalidCameraHeading,icon:"directional-navigation",text:r,title:n,onclick:()=>{this._toggleImageNavigation("directional")}}):null,s?se("calcite-action",{active:"sequential"===this.navigationMode,bind:this,disabled:"image-loaded"!==o||this.invalidCameraHeading||!this.canNavigateSequentially,icon:"sequential-navigation",text:d,title:l,onclick:()=>{this._toggleImageNavigation("sequential")}}):null)}_overlaysGroupToggle(){const{overlays:e}=this.messages;return this.visibleElements.overlays?se("calcite-action",{bind:this,icon:"oriented-imagery-overlays",key:"overlays-group-toggle",text:e,title:e,onclick:()=>this._toggleGroupSelection("overlays")}):null}_openPopupAction(){const{showPopupsAction:e}=this.visibleElements;return e?se("calcite-action",{bind:this,disabled:!this.popupEnabled,icon:"popup",text:this.messages.showPopups,title:this.messages.showPopups,onclick:this._toggleImageAttributes}):null}get _panoramicVideoViewer(){const{displayMessage:e,loadPanoramicVideoViewer:t,mode:i,clickAction:a,state:s,currentBestFeature:o}=this.viewModel,n=o?.attributes.imagePath,r=null!=e||"panoramic-video"!==i||s.includes("loading")||!n;return se(M,{afterCreate:t,clickAction:a,oiViewModel:this.viewModel,videoSource:n,visible:!r})}get _panoramicViewer(){const{displayMessage:e,loadPanoramicViewer:t,mode:i,clickAction:a,state:s}=this.viewModel,o=null!=e||"panoramic"!==i||s.includes("loading");return se(T,{afterCreate:t,clickAction:a,visible:!o})}get noImageInSequenceError(){return this._get("noImageInSequenceError")??!1}_activateTriangulatedImageLocationTool(){this.navigationToolActive=!0,this.imageLocationToolActive=!0}_activateTriangulatedImageLocationWorkflow(e,t){this._closeAllImageTools(),this.imageLocationToolActive=!0,this.triangularMeasurementActive=!e,this.navigationToolActive=!!t||!t}_closeImageToolsAndToggleNavigation(e,t){this._closeAllImageTools(),this.triangularMeasurementActive=!e,this.navigationToolActive=!t}_resetMeasureTypeAndActivateImageLocationTool(){this.measureType=null,this.imageLocationToolActive=!0}_closeAllImageTools(){this.enhancementToolActive=!1,this.navigationToolActive=!1,this.imageOverlaysOpened=!1,this.galleryOpened=!1,this.measureType=null,this.imageLocationToolActive=!1,this.navigationMode=null,this.triangularMeasurementActive=!1,this._settingsToggle&&(this._settingsToggle.expanded=!1,this.viewModel.activeViewer?.ui.remove(this._settingsToggle))}_handleBrightnessChange(e){this.viewModel.brightness=e.currentTarget.value??0}_handleVideoBrightnessChange(e){this.viewModel.videoViewModel?.handleVideoBrightnessChange(e.target.value)}_handleContrastChange(e){this.viewModel.contrast=e.currentTarget.value??0}_handleVideoContrastChange(e){this.viewModel.videoViewModel?.handleVideoContrastChange(e.target.value)}_handleVideoSeek(e){const t=this.viewModel?.videoElement?.content;t&&(t.currentTime=e.target.value,t.play())}_handleSharpnessChange(e){this.viewModel.sharpness=e.currentTarget.value??0}_handleSuperimposeZOffsetChange(e){const t=e.currentTarget.value??0;if("default"===this.viewModel.mode)return this._defaultSuperimposeZOffsetPercentage=t,void this.viewModel.setDefaultSuperimposeZOffsetPercentage(100-t);this._panoramicSuperimposeRadiusOffsetPercentage=t,this.viewModel.setPanoramicSuperimposeRadiusPercentage(100-t)}_lazyLoadImage(e,t){e.forEach(async e=>{if(e.isIntersecting){const a=e.target,s=a.getAttribute("data-src"),o=a.getAttribute("data-rotation"),n=a.getAttribute("data-objectid"),r=o?parseFloat(o)%360:0,{layer:c,_galleryController:{signal:g}}=this;if(!s||!n)return;let h;try{h=G(s)?await N(c,n,{signal:g}):await D(s,{signal:g})}catch(i){d(i)||l.getLogger("esri.widgets.OrientedImageryViewer").error("#lazyLoadImage()",i)}finally{t.unobserve(a)}if(!h)return;H(h,a,r)}})}_loadImageFromGallery(e){const{target:t}=e;if(!t)return;const i=t.getAttribute("data-objectid");i&&this.viewModel.currentBestFeature?.attributes.objectId!==Number(i)&&this.viewModel.selectBestFeature(i)}_loadImageMeasurementResources(){this._imageMeasurementToolsLoaderTask=s(async()=>{const{default:e}=await import("./OrientedImageryViewer/components/ImageMeasurementWidget.js");return e})}_loadSketchResources(){this._sketchLoaderTask=s(async()=>(await import("./OrientedImageryViewer/components/SketchTools.js")).default)}_onAdditionalCoverageVisibilityChange(e){this.viewModel.setAdditionalCoverageVisibility(e)}_onAdditionalCameraLocationsVisibility(e){this.viewModel.setAdditionalCameraLocationsVisibility(e)}_onCurrentCoverageVisibilityChange(e){this.viewModel.setCurrentCoverageVisibility(e)}_registerGalleryItem(e){this._galleryObserver.observe(e)}_renderWarning(e,t,i){const{viewModel:{state:a}}=this;return"image-loaded"===a?se(R,{icon:"exclamation-mark-triangle-f",kind:"warning",message:t,open:!0,title:e,tooltip:t,topLayerDisabled:this.topLayerDisabled,onClose:i}):null}get _renderNavigation(){const{viewModel:{sectorData:e,navigatorCurrentBestFeature:t,currentBestFeature:i,state:s}}=this;if(!this.container||!i)return null;let o,n,r,l,d;if(t){const{x:e,y:i,direction:a}=t,[s,c,g,h]=A[a];o=`M ${e} ${i} L ${s} ${c} A ${L[2]} ${L[2]} 0 0 1 ${g} ${h} Z`,n=e,l=i,r=A[a][4],d=A[a][5]}const c=e=>{const t=e.target.dataset?.sector;t&&this.viewModel.handleSectorClick(+t)},g=e=>{const t=e.target.dataset;if(!t)return;const{featureIndexInSector:i,sector:a}=t;i&&a&&this.viewModel.handleFeatureClick({sector:a,featureIndexInSector:+i})},h=e=>{e.removeEventListener("click",g)},m=i.attributes.objectId,u=e?.map(e=>e?.items).filter(Boolean).flatMap(e=>e?.map(({x:e,y:t,objectID:i,featureIndexInSector:a,sector:s})=>se("circle",{afterRemoved:h,class:this.classes(E.feature,{selected:m===i}),cx:e,cy:t,"data-feature-index-in-sector":a,"data-sector":s,key:`${E.feature}-${i}`,r:k,onclick:g}))),p=e=>{e.removeEventListener("click",c)},v=this.classes({[E.navigationWrapper]:!0,[E.navigationWrapperVideo]:this.viewModel.mode.includes("video"),[E.navigationZoomed]:this._navigationToolExpanded});return this.navigationToolActive&&("image-loaded"===s||this.videoLoaded)?se("div",{bind:this,class:v,key:this.messages.navigationTool},se("svg",{afterCreate:e=>this._storeNavigationToolReference(e),class:a()?O:E.rotateWithAnimation,focusable:"false",height:V,role:"img",width:V,xmlns:"http://www.w3.org/2000/svg"},se("defs",null,se("linearGradient",{gradientUnits:"userSpaceOnUse",id:`${this.id}-coverage-fill`,x1:n,x2:r,y1:l,y2:d},se("stop",{class:E.navigationPathOffset0,offset:0}),se("stop",{class:E.navigationPathOffset1,offset:1}))),se("g",null,se("circle",{class:this.classes(E.sector,E.outerSector),cx:L[3],cy:L[3],r:L[3],onclick:this._scaleNavigationTool}),se("circle",{class:E.sector,cx:L[3],cy:L[3],r:L[2]}),se("circle",{class:E.sector,cx:L[3],cy:L[3],r:L[1]}),se("circle",{class:E.sector,cx:L[3],cy:L[3],r:L[0]}),se("path",{class:E.pointer,d:"M 56.5 6.06217782649107 L 60 0 L 63.5 6.06217782649107 Z",key:`${E.pointer}-west`}),se("path",{class:this.classes(E.pointer,E.north),d:"M 113.93782217350893 56.5 L 120 60 L 113.93782217350893 63.5 Z",key:`${E.pointer}-north`}),se("path",{class:E.pointer,d:"M 56.5 113.93782217350893 L 60 120 L 63.5 113.93782217350893 Z",key:`${E.pointer}-east`}),se("path",{class:E.pointer,d:"M 6.06217782649107 56.5 L 0 60 L 6.06217782649107 63.5 Z",key:`${E.pointer}-south`}),se("path",{class:this.classes(E.sector,E.sectorSeparator),d:"M 23.937554159486076 23.937554159486076 L 96.06244584051393 96.06244584051393 M 23.937554159486076 96.06244584051393 L 96.06244584051393 23.937554159486076",key:E.sectorSeparator}),C([L[2],L[1],L[0]],L[3],L[3]).map((t,i)=>se("path",{afterRemoved:p,class:this.classes(E.sector,e?.[i]?.length?E.sectorEnabled:E.sectorDisabled),d:t,"data-sector":`${i}`,key:`${E.sector}-${i}`,onclick:c})),se("path",{class:this.classes(E.sector,E.sectorCross),d:"M 56.4 56.4 L 63.53 63.53 M 63.53 56.4 L 56.4 63.53",key:E.sectorCross}),u,i.attributes.cameraPitch>=5&&o?se("path",{class:E.selectedFeaturePath,d:o,fill:`url(#${this.id}-coverage-fill)`,key:E.selectedFeaturePath}):null))):null}_renderSketch(){const{dataCaptureLayer:e,imageOverlaysOpened:t}=this;if(!e||t)return null;if(this._sketchLoaderTask||this._loadSketchResources(),!this._sketchLoaderTask?.value)return null;const{geometryType:i}=e,a="point"===i?"pin":"polyline"===i?"line":"polygon",s=this._sketchLoaderTask.value;return se("div",{class:E.sketchTools},se(s,{icon:a,messages:this._imageSketchToolsMessages,type:i,onAction:this._onAction}))}get _renderThumbnails(){const{currentBestFeature:e,thumbnails:t}=this.viewModel;return e?se("div",{class:E.carouselContent},t?.items.map(({url:t,objectId:i,rotation:a},s)=>se("div",{class:`${E.carouselItemWrapper}${e.attributes.objectId===i?"--selected":""}`,key:`${E.carouselItemWrapper}-${s}`},se("canvas",{afterCreate:this._registerGalleryItem,afterRemoved:this._unregisterGalleryItem,alt:`thumbnail-${i}`,class:E.carouselItem,"data-objectid":`${i}`,"data-rotation":`${a}`,"data-src":t,onclick:this._loadImageFromGallery,onmouseenter:this._highlight,onmouseleave:this._removeHighlight})))):null}_resetImageTools(){this.viewModel.sharpness=this.viewModel.brightness=this.viewModel.contrast=0}_resetVideoTools(){this.viewModel.videoViewModel?.resetVideoEnhancementTools()}_storeNavigationToolReference(e){this._navigationTool=e}_toggleAdditionalCameraLocations(){this.isAdditionalPointSourcesVisible=!this.isAdditionalPointSourcesVisible}_toggleAdditionalCoverage(){this.isAdditionalCoverageVisible=!this.isAdditionalCoverageVisible}_toggleCurrentCoverage(){this.currentCoverageVisible=!this.currentCoverageVisible}_toggleShowSelectedImage(){this.shouldShowSelectedImage=!this.shouldShowSelectedImage,this._toggleDisabledViewer(this.shouldShowSelectedImage)}_resetSuperimposeOffset(){if("default"===this.viewModel.mode)return this._defaultSuperimposeZOffsetPercentage=100,void this.viewModel.setDefaultSuperimposeZOffsetPercentage(0);this._panoramicSuperimposeRadiusOffsetPercentage=100,this.viewModel.setPanoramicSuperimposeRadiusPercentage(0)}_toggleSuperimposeCameraLock(){this.viewModel.updateDefaultSuperimposeCameraLock(!this.defaultSuperimposeCameraLockEnabled)}_toggleSuperimposeView(){this.superimposeViewEnabled=!this.superimposeViewEnabled}_toggleVerticalSearchFilter(){this.verticalFilterEnabled=!this.verticalFilterEnabled,this._toggleDisabledViewer(this.verticalFilterEnabled)}_toggleDisabledViewer(e){e&&(this.disabled=!1)}_toggleEnhancementToolState(e){e.stopPropagation();const t=this.enhancementToolActive;this._closeAllImageTools(),this.enhancementToolActive=!t}_toggleExploreImages(){this.disabled=!this.disabled,this.disabled&&(this.shouldShowSelectedImage=!1,this.verticalFilterEnabled=!1)}_toggleGroupSelection(e){this.selectedGroup=e}_toggleImageOverlays(e){e.stopPropagation();const t=this.imageOverlaysOpened;this._closeAllImageTools(),this.imageOverlaysOpened=!t}_toggleImageGallery(e){e.stopPropagation();const t=this.galleryOpened;this._closeAllImageTools(),this.galleryOpened=!!this.imageGalleryEnabled&&!t}_toggleLocationTool(e){const t=this.imageLocationToolActive,i=this.triangularMeasurementActive&&t;this._closeAllImageTools(),this.imageLocationToolActive=i||!t,e.stopPropagation()}_toggleMeasurementSketch(e,t){e.stopPropagation();const i=this.measureType,a=this.triangularMeasurementActive;this._closeAllImageTools(),this.measureType=i!==t||a?t:null,this.measureType===t&&(this.viewModel.displayNewMeasurementButton=!0)}_toggleNavigationTool(){const e=this.navigationToolActive;this._closeAllImageTools(),this.navigationToolActive=!e}_toggleMapImageConversionToolState(){this.mapImageConversionToolState=!this.mapImageConversionToolState}_toggleTriangularAreaMeasurements(){this._toggleTriangularMeasurements("area")}_toggleTriangularDistanceMeasurements(){this._toggleTriangularMeasurements("distance")}_toggleTriangularLocation(){const e=this.triangularMeasurementActive,t=this.navigationToolActive;e?null===this.measureType?this.imageLocationToolActive?this._closeImageToolsAndToggleNavigation(e,t):this._activateTriangulatedImageLocationTool():this._resetMeasureTypeAndActivateImageLocationTool():this._activateTriangulatedImageLocationWorkflow(e,t)}_toggleTriangularMeasurements(e){const t=this.triangularMeasurementActive,i=this.viewModel.measureType,a=this.navigationToolActive;t?e===i?(this._closeAllImageTools(),this.triangularMeasurementActive=!t,this.navigationToolActive=!a):(this.imageLocationToolActive=!1,this.measureType=e):(this._closeAllImageTools(),this.measureType=e,this.triangularMeasurementActive=!t,this.navigationToolActive=!!a||!a)}_unregisterGalleryItem(e){this._galleryObserver.unobserve(e)}_updateNavigationTool(e){const{previousFeatureAngle:t,bestFeatureAngle:i}=this.viewModel,a=(i-t+540)%360-180;e.style.setProperty(P,`${t}deg`),e.style.setProperty(F,`${t+a}deg`)}async loadBestImage(e,t){return this.viewModel.loadBestImage(e,t)}loadImageFromSource(e,t,i){return"default"===e?this.viewModel.loadMediaSource(t,i):this.viewModel.loadPanoramicMediaSource(t,i)}async overlayMapFeatures(e,t){return this.removeHandles(`${oe.overlayed}-${e.id}`),this.addHandles(c(()=>e.visible,()=>{this.viewModel.toggleOverlayMapFeatures(e.id,e.visible,this.showMapFeatures)}),`${oe.overlayed}-${e.id}`),this._overlayedLayers.add(e),this.viewModel.overlayMapFeatures(e,t&&this.showMapFeatures)}async plotMapPoint(e){return this.viewModel.plotMapPoint(e)}plotReferencePointOnGround(e){this.viewModel.plotReferencePointOnGround(e)}plotReferencePointOnImage(e){this.viewModel.plotReferencePointOnImage(e)}removeOverlayedGraphicsOnImage(e){this.removeHandles(`${oe.overlayed}-${e}`),this._overlayedLayers.remove(this._overlayedLayers.find(t=>t.id===e)),this.viewModel.removeOverlayedGraphicsOnImage(e)}resetImage(){this.viewModel.resetImage()}render(){return se("div",{class:this.classes(ee.widget,x)},this._renderRoot)}async showImageByObjectId(e,t){return this.viewModel.showImageByObjectId(e,t)}async startDataCapture(e){return this.viewModel.startDataCapture(e)}async stopDataCapture(e){return this.viewModel.stopDataCapture(e)}updateSuitabilities(e){this.viewModel.updateSuitabilities(e)}};e([v({readOnly:!0})],ne.prototype,"accuracyParametersMissing",null),e([v()],ne.prototype,"activeLayer",null),e([v()],ne.prototype,"activeVideoIcon",null),e([v()],ne.prototype,"activeAudioIcon",null),e([v()],ne.prototype,"cameraHeadingThreshold",null),e([v()],ne.prototype,"cameraPitchThreshold",null),e([v()],ne.prototype,"canNavigateSequentially",null),e([v()],ne.prototype,"currentBestFeature",null),e([v()],ne.prototype,"currentCoverageVisible",null),e([v()],ne.prototype,"dataCaptureEnabled",void 0),e([v()],ne.prototype,"dataCaptureLayer",null),e([v()],ne.prototype,"depthImageNotSupported",null),e([v()],ne.prototype,"disabled",null),e([v()],ne.prototype,"enhancementToolActive",null),e([v()],ne.prototype,"features",null),e([v()],ne.prototype,"imagePointsInView",null),e([v()],ne.prototype,"galleryOpened",void 0),e([v()],ne.prototype,"icon",null),e([v()],ne.prototype,"imageEnhancementToolActive",void 0),e([v()],ne.prototype,"videoEnhancementToolActive",void 0),e([v({readOnly:!0})],ne.prototype,"imageGalleryEnabled",null),e([v()],ne.prototype,"imageLocationToolActive",null),e([v()],ne.prototype,"imageOverlaysOpened",void 0),e([v({readOnly:!0})],ne.prototype,"invalidCameraHeading",null),e([v()],ne.prototype,"isAdditionalCoverageVisible",null),e([v()],ne.prototype,"isAdditionalPointSourcesVisible",null),e([v()],ne.prototype,"mapImageConversionToolState",null),e([v()],ne.prototype,"measureType",null),e([v()],ne.prototype,"layer",null),e([v()],ne.prototype,"navigationToolActive",void 0),e([v()],ne.prototype,"navigationMode",null),e([ie(f()),v({type:j})],ne.prototype,"viewModel",void 0),e([v(),ae("esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer")],ne.prototype,"messages",void 0),e([v(),ae("esri/core/t9n/Units")],ne.prototype,"measurementUnitMessages",void 0),e([v(),ae("esri/t9n/common")],ne.prototype,"messagesCommon",void 0),e([v(),ae("esri/widgets/Sketch/t9n/Sketch")],ne.prototype,"messagesSketch",void 0),e([v()],ne.prototype,"pixelMeasurementUnit",void 0),e([v()],ne.prototype,"pixelAreaMeasurementUnit",void 0),e([v({readOnly:!0})],ne.prototype,"popupEnabled",null),e([v()],ne.prototype,"preloadMedia",null),e([v()],ne.prototype,"referencePoint",null),e([v()],ne.prototype,"selectedGroup",void 0),e([v()],ne.prototype,"showCameraLocations",void 0),e([v()],ne.prototype,"showMapFeatures",void 0),e([ie(["create","delete","redo","undo","update"]),v({readOnly:!0})],ne.prototype,"sketchViewModel",null),e([v()],ne.prototype,"triangularMeasurementActive",null),e([v()],ne.prototype,"videoLoaded",null),e([v()],ne.prototype,"view",null),e([v({type:$,nonNullable:!0})],ne.prototype,"visibleElements",void 0),e([v()],ne.prototype,"determineWorkflowForFeature",null),e([v()],ne.prototype,"shouldShowSelectedImage",null),e([v()],ne.prototype,"superimposeViewEnabled",null),e([v()],ne.prototype,"defaultSuperimposeCameraLockEnabled",null),e([v()],ne.prototype,"updateFootprint",null),e([v()],ne.prototype,"verticalFilterEnabled",null),e([v()],ne.prototype,"_defaultSuperimposeZOffsetPercentage",void 0),e([v()],ne.prototype,"_panoramicSuperimposeRadiusOffsetPercentage",void 0),e([v()],ne.prototype,"_activeMeasurementHeading",null),e([v()],ne.prototype,"_imageOverlaysLoaderTask",void 0),e([v()],ne.prototype,"_imageMeasurementToolsLoaderTask",void 0),e([v()],ne.prototype,"_navigationSettingsLoaderTask",void 0),e([v()],ne.prototype,"_navigationTask",void 0),e([v()],ne.prototype,"_measurementToggle",null),e([v()],ne.prototype,"_renderRoot",null),e([v()],ne.prototype,"_imageEnhancementTools",null),e([v()],ne.prototype,"_videoEnhancementTools",null),e([v()],ne.prototype,"_superimposeTools",null),e([v()],ne.prototype,"_imageGalleryPanel",null),e([v()],ne.prototype,"_imageGalleryContext",null),e([v()],ne.prototype,"_imageOverlaysComponent",null),e([v()],ne.prototype,"_navigationUI",null),e([v()],ne.prototype,"_imageOverlayMessages",null),e([v()],ne.prototype,"_imageSketchToolsMessages",null),e([v()],ne.prototype,"_imageOverlaysEnabled",null),e([v()],ne.prototype,"_imageViewer",null),e([v()],ne.prototype,"_imageViewerTriangular",null),e([v()],ne.prototype,"_videoViewer",null),e([v()],ne.prototype,"_locationToggle",null),e([v()],ne.prototype,"_messageBox",null),e([v()],ne.prototype,"_navigationToolExpanded",void 0),e([v()],ne.prototype,"_navigationTool",void 0),e([v()],ne.prototype,"_panoramicVideoViewer",null),e([v()],ne.prototype,"_panoramicViewer",null),e([v({readOnly:!0})],ne.prototype,"noImageInSequenceError",null),e([v()],ne.prototype,"_renderNavigation",null),e([v()],ne.prototype,"_renderThumbnails",null),e([v()],ne.prototype,"_sketchLoaderTask",void 0),ne=e([y("esri.widgets.OrientedImageryViewer")],ne);const re=ne;export{re as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import{isSome as e}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import{EventedAccessor as o}from"../../core/Evented.js";import{JSONMap as a}from"../../core/jsonMap.js";import{clone as r}from"../../core/lang.js";import{LoadableMixin as l}from"../../core/Loadable.js";import{EsriPromiseMixin as n}from"../../core/Promise.js";import p from"../../core/ReactiveMap.js";import{watch as m,initial as d,whenOnce as h}from"../../core/reactiveUtils.js";import{createScreenPoint as u}from"../../core/screenUtils.js";import{unitType as c,convertUnit as f,getMetersPerUnitForSR as y,inchesPerMeter as v}from"../../core/units.js";import{property as T,subclass as w}from"../../core/accessorSupport/decorators.js";import _ from"../../geometry/Extent.js";import I from"../../geometry/SpatialReference.js";import{formatDate as g,convertDateFormatToIntlOptions as b}from"../../intl/date.js";import{getLocaleLanguage as x}from"../../intl/locale.js";import O from"../../portal/Portal.js";import E from"../../portal/PortalQueryParams.js";import{execute as L,getPrintCache as P,getTaskInfo as S}from"../../rest/print.js";import{formatJsonMap as U}from"../../rest/support/fileFormat.js";import{fromJSON as k}from"../../rest/support/layoutTemplate.js";import C from"../../rest/support/LegendLayer.js";import j from"../../rest/support/PrintParameters.js";import{getVisibleLayerViews as F}from"../../rest/support/printTaskUtils.js";import M from"../../rest/support/PrintTemplate.js";import{getExtent as H}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as A}from"../../views/input/InputManager.js";import D from"../../views/overlay/BoxOverlayItem.js";import N from"./CustomTemplate.js";import W from"./FileLink.js";import R from"./TemplateOptions.js";import{fetchLayoutTemplateInfos as V,valueUnitKebabDict as z}from"./utils.js";const B=[30,144,255,255],q=[237,211,23,255],G=[216,48,32,255],J=/(\/GPServer\/).+/i,$=96,Q=i.ofType(N),K=i.ofType(W),X=new a({Feet:"feet",Miles:"miles",Meters:"meters",Kilometers:"kilometers"});function Y(t){t.layoutOptions??={},t.layoutOptions.customTextElements??=[];const e="date";if(!t.layoutOptions.customTextElements.find(t=>e in t)){const{customTextElements:e}=t.layoutOptions;let i=g(Date.now(),b("short-date"));"ar"===x()&&(i=""+i),e.push({date:i})}}function Z(t,e,i){const s=t.visible??!0,o=t.legendEnabled??!0;if(!s||!o)return;const a=0===e,r=t.minScale??0,l=t.maxScale??0;if(!(a||(0===r||e<=r)&&(0===l||e>=l)))return;const n=t.sublayers?.toArray();if(n)for(const p of n)Z(p,e,i);else null!=t.id&&i.push(String(t.id))}function tt(t,e,i,s){if(!e.layoutOptions)return;if(!i)return void(e.layoutOptions.legendLayers=[]);if(!t)return;let o=0;e.scalePreserved&&(o=e.outScale||t.scale);const a=F(t),r=[];for(const l of a)if(l.legendEnabled){const t="sublayers"in l.layer&&l.layer.sublayers?l.layer.sublayers.toArray():void 0,e=[];for(const i of t??[])Z(i,o,e);r.push(new C({layerId:l.layer.id,title:l.layer.title||void 0,subLayerIds:t?e:void 0,dynamicLegend:s}))}e.layoutOptions.legendLayers=r}function et(t,e,i){if(!e)return;!(e.visible===i)&&t.layoutOptions&&(t.layoutOptions.elementOverrides?t.layoutOptions.elementOverrides[e.name]={visible:i}:t.layoutOptions.elementOverrides={[e.name]:{visible:i}})}let it=class extends(l(n(o))){constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._templateIdToCustomTemplate=new p,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this._asyncPrintTaskUrl=null,this._layoutInfoTaskUrl=null,this._portalLayoutInfoTaskUrl=null,this._customLayoutOptions=null,this._exportedFileNameMap={},this._layoutTemplateInfosCache=new Map,this._tasksInfoCache=new Map,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new Q,this.datumTransformations=null,this.defaultTemplates=new Q,this.error=null,this.exportedLinks=new K,this.extraParameters=null,this.includeDefaultTemplates=!0,this.outSpatialReference=null,this.portal=O.getDefault(),this.portalTemplateIds=[],this.printServiceTemplates=new Q,this.defaultTemplate=null,this.showPrintAreaEnabled=!1,this.printServiceUrl=null,this.printTimeout=12e4,this.saveExportEnabled=!1,this.templatesInfo=null,this.updateDelay=1e3,this.view=null,this.templateCustomTextElements=null,this.templateOptions=new R}initialize(){this.addHandles([m(()=>[this.showPrintAreaEnabled,this.view],()=>{this.showPrintAreaEnabled?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))}),m(()=>[this.templateOptions.layout,this.templateOptions.layoutItem],()=>{this.loaded&&this._processTemplateOptions()}),m(()=>[this.allowedFormats,this.allowedLayouts],()=>{this.loaded&&this._loadTemplateInfos()}),m(()=>this.exportedLinks,()=>{const t={};for(const{name:e,extension:i}of this.exportedLinks){if(!e||!i)continue;const s=`${e}${i}`,o=t[s];t[s]=void 0!==o?o+1:0}this._exportedFileNameMap=t},d)])}destroy(){this.removeHandles("overlay-handler"),this.view&&(this._overlayItem&&(this.view.overlay?.removeItem(this._overlayItem),this._overlayItem.destroy(),this._overlayItem=null),this.view=null)}get effectivePrintServiceUrl(){return this.printServiceUrl??null}get effectiveTemplateCustomTextElements(){if(!this._serviceTemplateCustomTextElements)return{};const t=r(this._serviceTemplateCustomTextElements);return this.templateCustomTextElements&&Object.keys(this.templateCustomTextElements).forEach(e=>{const i=t[e];if(i){const t=this.templateCustomTextElements?.[e];i.forEach(e=>{const[i]=Object.entries(e)[0];t?.forEach(t=>{const[s,o]=Object.entries(t)[0];i===s&&(e[i]=o)})})}}),Object.freeze(t)}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}async print(t){const{view:e,extraParameters:i,updateDelay:o,outSpatialReference:a,datumTransformations:r}=this;if(!e)throw new s("print:view-required","view is not set");Y(t);const l=this._getOverlayItem(),n=t.scalePreserved||!this.showPrintAreaEnabled?void 0:H(new _,e.viewpoint,"map-only"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[l.boxWidth,l.boxHeight]),p=new j({view:e,template:t,extent:n,extraParameters:i,updateDelay:o,outSpatialReference:a,datumTransformations:r});try{const e=!!t.layoutItem?.id&&(this.defaultTemplates.some(e=>e.layoutItem?.id===t.layoutItem?.id)||this.browseTemplates.some(e=>e.layoutItem?.id===t.layoutItem?.id));return await L(e&&this._asyncPrintTaskUrl?this._asyncPrintTaskUrl:this.effectivePrintServiceUrl,p,{timeout:this.printTimeout})}catch(m){throw new s("print:export-error","An error occurred while exporting the web map.",{error:m})}}async load(t){return this.addResolvingPromise(this._loadResources(t).catch(t=>this.error=t)),this}toPrintTemplate({attributionEnabled:t,author:e,copyright:i,customTextElements:o,dpi:a,forceFeatureAttributes:r,format:l,height:n,id:p,includeTables:m,layout:d,layoutItem:h,legendEnabled:u,dynamicLegendEnabled:c,northArrowEnabled:f,scale:y,scaleBarEnabled:v,scaleBarUnit:T,scaleEnabled:w,title:_,width:I}){if(!d&&!h)throw new s("print:layout-required","layout is not set");const g={};e&&(g.authorText=e),i&&(g.copyrightText=i),o&&(g.customTextElements=o),_&&(g.titleText=_),v&&T&&(g.scalebarUnit=X.toJSON(T));const b=new M({attributionVisible:t,forceFeatureAttributes:r,format:l,includeTables:m,layout:d,layoutItem:h,layoutOptions:g,outScale:y??0,scalePreserved:w});if(I&&(b.exportOptions.width=I),n&&(b.exportOptions.height=n),a&&(b.exportOptions.dpi=a),b.layoutOptions){tt(this.view,b,u,c);const t=this.getLayoutTemplateById(p)?.mapSurroundInfoOptions;if(t){const e=t.northArrow;for(const t of e)et(b,t,f);const i=t.scaleBar;for(const t of i)et(b,t,v);const s=t.legend;for(const t of s)et(b,t,u)}}return b}getLayoutTemplateById(t){return t?this._templateIdToCustomTemplate.get(t):null}async addPortalTemplate(t){if(!this.portal||!t?.id)return;try{if("loading"===this.loadStatus&&await h(()=>this.loaded),!this.loaded)throw new s("print:load-required","PrintViewModel must be loaded before adding portal templates.");t.loaded||await t.load()}catch{return void this.applyTemplate(this.defaultTemplate)}const e=new N({type:"browse-template",layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl,label:t.title,layoutItem:t});this._templateIdToCustomTemplate.set(e.id,e),this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem&&this.templateOptions.id===t.layoutItem.id&&(this.defaultTemplate?this.applyTemplate(this.defaultTemplate):this.templateOptions.reset()),this.browseTemplates.remove(t),this._templateIdToCustomTemplate.delete(t.id)}async applyTemplate(t){if(t&&t===this.getLayoutTemplateById(this.templateOptions.id))return;if(this.templateOptions.reset(),!t)return;if("map-only"===t)return void(this.templateOptions.layout="map-only");!t.layout||!this.templatesInfo||this.templatesInfo.layout.choiceList.includes(t.layout)||(this.defaultTemplate?t=this.defaultTemplate:this.templateOptions.reset());const e=t.layout||t.layoutItem?.id,i=e?this.templateCustomTextElements?.[e]:void 0;if(await this.templateOptions.applyTemplate(t,{customTextElements:i,customLayoutOptions:this._customLayoutOptions}),e&&this._serviceTemplateCustomTextElements&&!this._serviceTemplateCustomTextElements[e]&&t.layoutTemplateInfo?.layoutOptions?.customTextElements){const i=r(this._serviceTemplateCustomTextElements);i[e]=t.layoutTemplateInfo.layoutOptions.customTextElements,this._serviceTemplateCustomTextElements=Object.freeze(i)}}createExportedFileLink(t){const e=this.toPrintTemplate(this.templateOptions).format.toLowerCase(),i=e.includes("png")?"png":e,s=t+i;return this._updateExportedFileNameMap(s),new W({name:t,extension:i,count:this._exportedFileNameMap[s]})}export(t){const e=this.createExportedFileLink(t);this.exportedLinks.add(e);const i=this.print(this.toPrintTemplate(this.templateOptions)).then(t=>e.set({url:t?.url,state:"ready"})).catch(t=>e.set({error:t,state:"error"}));return this.emit("submit",{link:e,saveExportEnabled:this.saveExportEnabled}),i.then(t=>this.emit("complete",{link:t,saveExportEnabled:this.saveExportEnabled})),{link:e,promise:i}}async _loadResources(t){if(!this.destroyed){if(await this._loadUrls(t),await this._loadTemplateInfos(t),this.effectivePrintServiceUrl){const e=await P(this.effectivePrintServiceUrl,t);this.cimVersion=e?.cimVersion}await this._updateOverLayItem()}}async _loadTemplateInfos(t){const e=[...this.defaultTemplates,...this.printServiceTemplates];for(const{id:o}of e)this._templateIdToCustomTemplate.delete(o);this.defaultTemplates.removeAll(),this.printServiceTemplates.removeAll();const[i,s]=await Promise.all([this._getLayoutToLayoutTemplateInfos(t),this._getPrintServiceTemplatesInfo(t)]);await this._loadAllTemplates(i,s,t),this._processPrintServiceTemplatesInfo(s),await this._processTemplateOptions()}_updateExportedFileNameMap(t){void 0!==this._exportedFileNameMap[t]?this._exportedFileNameMap[t]++:this._exportedFileNameMap[t]=0}async _processTemplateOptions(){const{layout:t,layoutItem:e}=this.templateOptions;if("map-only"!==t)if(this._customLayoutOptions={legend:this.templateOptions.legendEnabled,northArrow:this.templateOptions.northArrowEnabled,scaleBar:this.templateOptions.scaleBarEnabled},e?.id){try{e.loaded||await e.load()}catch{return void this.applyTemplate(this.defaultTemplate)}let t=this._templateIdToCustomTemplate.get(e.id);t||(t=new N({label:e.title,layoutItem:e,layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl}),this._templateIdToCustomTemplate.set(t.id,t)),await this.applyTemplate(t)}else if(t){const t=this.defaultTemplates.find(t=>t.layout===this.templateOptions.layout)??this.printServiceTemplates.find(t=>t.layout===this.templateOptions.layout);await this.applyTemplate(t??this.defaultTemplate)}}async _loadPortal(t){try{await this.portal.load(t)}catch(e){throw new s("print:could-not-load-portal","Cannot load print resource information from portal",{error:e,url:this.effectivePrintServiceUrl})}}async _loadUrls(t){if(this.printServiceUrl)this._set("effectivePrintServiceUrl",this.printServiceUrl),this._layoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(this.effectivePrintServiceUrl,t);else{await this._loadPortal(t);const{printTask:e,asyncPrintTask:i,layoutInfoTask:s}=this.portal?.helperServices??{};this._set("effectivePrintServiceUrl",e?.url),this._asyncPrintTaskUrl=i?.url,this._layoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(this.effectivePrintServiceUrl,t),s?.url&&this.effectivePrintServiceUrl!==s.url?this._portalLayoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(s.url,t):this._portalLayoutInfoTaskUrl=this._layoutInfoTaskUrl}const e=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!e?.includes("gpserver"))throw new s("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl})}async _getLayoutInfoTaskUrl(t,e){if(!t)return null;const i=await S(t,"GetLayoutTemplatesInfo",e);return i?t.replace(J,`$1${encodeURI(i.displayName)}`):null}_getPortalDefaultTemplates(t,e){return this.portal?.helperServices?.printTask?.templates?.filter(t=>"map_only"!==t.layout.toLowerCase()&&(!e||e.includes(k(t.layout))))?.map(e=>{const i=N.fromJSON(e);if(i.type="default-template",i.layoutInfoTaskUrl=this._layoutInfoTaskUrl,i.layout){const e=t.get(i.layout);e&&i.setLayoutTemplateInfo(e)}return i})??[]}async _getPortalCustomTemplates(t){if(this.printServiceUrl||!this.portal)return[];const{portal:e}=this,{layoutGroupQuery:i,sourceJSON:s}=e,{state:o,user:a}=s??{},{availableCredits:r=0,assignedCredits:l=0}=a??{},n="suspended"===o,p="active"===o&&r<=0&&l>0,m=a?.privileges?.includes("premium:user:print:customlayout");if(!i||n||p||!m)return[];const d=new E({query:i,disableExtraQuery:!0}),h=await this.portal.queryGroups(d,t);if(!h.total)return[];const u=h.results[0],c=new E({num:100,query:"type:Layout",sortField:u.sortField,sortOrder:u.sortOrder??void 0}),f=(await u.queryItems(c,t)).results;if(!f.length)return[];return f.map(t=>(this.portalTemplateIds.push(t.id),new N({type:"default-template",label:t.title,layoutItem:t,layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl})))}async _loadAllTemplates(t,e,i){let s=!1;const o=e?.layout?.choiceList;if(this.includeDefaultTemplates&&this.portal&&!this.printServiceUrl){const e=this._getPortalDefaultTemplates(t,o);s=!!e.length,this.defaultTemplates.addMany(e);const a=await this._getPortalCustomTemplates(i);this.defaultTemplates.addMany(a);for(const t of this.defaultTemplates)this._templateIdToCustomTemplate.set(t.id,t)}s||t.forEach((t,e)=>{if(!o||o.includes(e)){const i=new N({type:"print-service-template",layout:e,layoutInfoTaskUrl:this._layoutInfoTaskUrl});i.setLayoutTemplateInfo(t),this.printServiceTemplates.add(i),this._templateIdToCustomTemplate.set(i.id,i)}})}_processPrintServiceTemplatesInfo(t){this._set("templatesInfo",t);const e=t?.layout?.defaultValue;if(e&&"map-only"!==e){const t=this.defaultTemplates.find(t=>t.layout===e)??this.printServiceTemplates.find(t=>t.layout===e)??this.defaultTemplates.at(0)??this.printServiceTemplates.at(0);this._set("defaultTemplate",t)}}async _getLayoutToLayoutTemplateInfos(t){const e=this._layoutInfoTaskUrl,i=e?this._layoutTemplateInfosCache.get(e):void 0,s=i??await V(e,void 0,t);i||this._layoutTemplateInfosCache.set(e,s);const o=new Map,a={};for(const r of s){const t=k(r.layoutTemplate);o.set(t,r),a[t]=r.layoutOptions.customTextElements}return this._serviceTemplateCustomTextElements=Object.freeze(a),o}async _getPrintServiceTemplatesInfo(t){const e=this.effectivePrintServiceUrl?this._tasksInfoCache.get(this.effectivePrintServiceUrl):void 0,i=e??await S(this.effectivePrintServiceUrl,"ExportWebMap",t);if(!i)throw new s("print:unavailable-service-info","Can't fetch templates info from service");e||this._tasksInfoCache.set(this.effectivePrintServiceUrl,i);const{parameters:o}=i,a=o.find(({name:t})=>"Format"===t),r=o.find(({name:t})=>"Layout_Template"===t);return{format:this._getFormat(a),layout:this._getLayout(r)}}_getFormat(t){const i="all"===this.allowedFormats?t.choiceList:t.choiceList.filter(t=>"string"!=typeof this.allowedFormats&&this.allowedFormats.some(e=>new RegExp(`\\b${e}\\b`,"i").test(t))),s=(i.length?i:t.choiceList).map(t=>U.fromJSON(t)).filter(e),o=U.fromJSON(t.defaultValue),a=s.some(t=>new RegExp(`\\b${o}\\b`,"i").test(t))?o:s[0];return{choiceList:s,defaultValue:a}}_getLayout(t){const i=t.choiceList.filter(t=>"map_only"!==t.toLowerCase()),s="all"===this.allowedLayouts?i:i.filter(t=>this.allowedLayouts.includes(k(t))),o=(s.length?s:i).map(k).filter(e),a=k(t.defaultValue),r=o.includes(a)?a:o.find(t=>/(?=.*letter)(?=.*landscape)/i.test(t))??o.find(t=>/(?=.*a4)(?=.*landscape)/i.test(t))??o[0];return{choiceList:o,defaultValue:r}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new D({strokeDash:[5],strokeWidth:2,strokeColor:[30,144,255,255]})),this._overlayItem}_enablePrintPreview(){if(!this.view?.overlay)return;const t=this.templateOptions,e=this._getOverlayItem();this.addHandles([m(()=>[t.width,t.height,t.scaleEnabled,t.scale,t.layout,t.layoutItem,t.id,t.state,t.dpi,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding,this.loaded],()=>{this._updateOverLayItem()},d),this.view?.on("drag",["Shift"],t=>this._handleDrag(t),A.WIDGET),this.view?.on("key-down",["Escape"],()=>this._resetDrag(),A.WIDGET)],"overlay-handler"),this.view.overlay.addItem(e)}async _updateOverLayItem(){if(!this.view)return;await this.view.when();const t=this.templateOptions,e=this._getOverlayItem(),i=t.layoutItem?.id??t.layout,s=this.view,o=s.spatialReference,[a,r]=s.state.paddedViewState.size,l=s.state.padding;let n=0,p=0;if("map-only"===i)null!=t.width&&null!=t.height&&(n=t.width,p=t.height);else if(i){const e=t.id?this._templateIdToCustomTemplate.get(t.id):null,{webMapFrameSize:i,pageUnits:s}=e?.layoutTemplateInfo??{};let l=!1;if(i&&s)if(this._isFreeHand){const t=i[0]/i[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=z.fromJSON(s.toLowerCase()),e=o.unit;c(t)===c(e)?(n=f(i[0],t,e),p=f(i[1],t,e)):(l=!0,n=i[0],p=i[1])}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const t=l?Math.min(a/n,r/p):y(o)*v*$;n*=t,p*=t}else if(0===n||0===p)n=a,p=r;else{const t=(a-.1*a)/n,e=(r-.1*r)/p,i=Math.min(t,e);n*=i,p*=i}}const{scaleEnabled:m,scale:d}=t,h=m&&d?d/this.view.scale:1;if(e.boxWidth=n*h||a,e.boxHeight=p*h||r,l&&(e.padding=l),e.backgroundWidth=a??0,e.backgroundHeight=r??0,"loading"===this.loadStatus)e.strokeColor=q;else if("loaded"===this.loadStatus)switch(this.templateOptions.state){case"pending":e.strokeColor=q;break;case"ready":e.strokeColor=B;break;case"error":e.strokeColor=G}}_resetDrag(){this._isFreeHand=!1,this._updateOverLayItem()}_handleDrag(t){switch(t.action){case"start":this._start();break;case"update":this._update(t);break;case"end":this._end()}t.stopPropagation()}_start(){this._isFreeHand=!0}_update(t){const e=this._getOverlayItem(),{x:i,y:s}=t,{x:o,y:a}=t.origin;i>o?(e.x=o,e.boxWidth=i-o):(e.x=i,e.boxWidth=o-i),s>a?(e.y=a,e.boxHeight=s-a):(e.y=s,e.boxHeight=a-s)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,i=e.toMap(u(t.x+.5*t.boxWidth,t.y+.5*t.boxHeight));t.x=null,t.y=null,e.goTo({center:i}),this._freeHandWidth=t.boxWidth,this._freehandHeight=t.boxHeight,"map-only"===this.templateOptions.layout&&(this.templateOptions.width=this._freeHandWidth,this.templateOptions.height=this._freehandHeight),this.templateOptions.scale=this.view.scale,this._updateOverLayItem()}};t([T()],it.prototype,"_serviceTemplateCustomTextElements",void 0),t([T()],it.prototype,"_templateIdToCustomTemplate",void 0),t([T()],it.prototype,"allowedFormats",void 0),t([T()],it.prototype,"allowedLayouts",void 0),t([T({type:Q})],it.prototype,"browseTemplates",void 0),t([T()],it.prototype,"cimVersion",void 0),t([T()],it.prototype,"datumTransformations",void 0),t([T({type:Q})],it.prototype,"defaultTemplates",void 0),t([T()],it.prototype,"error",void 0),t([T({type:K})],it.prototype,"exportedLinks",void 0),t([T()],it.prototype,"extraParameters",void 0),t([T()],it.prototype,"includeDefaultTemplates",void 0),t([T({readOnly:!0})],it.prototype,"effectivePrintServiceUrl",null),t([T()],it.prototype,"effectiveTemplateCustomTextElements",null),t([T({type:I})],it.prototype,"outSpatialReference",void 0),t([T({type:O})],it.prototype,"portal",void 0),t([T()],it.prototype,"portalTemplateIds",void 0),t([T({type:Q})],it.prototype,"printServiceTemplates",void 0),t([T({readOnly:!0})],it.prototype,"defaultTemplate",void 0),t([T()],it.prototype,"showPrintAreaEnabled",void 0),t([T()],it.prototype,"printServiceUrl",void 0),t([T()],it.prototype,"printTimeout",void 0),t([T()],it.prototype,"saveExportEnabled",void 0),t([T({readOnly:!0})],it.prototype,"state",null),t([T({readOnly:!0})],it.prototype,"templatesInfo",void 0),t([T()],it.prototype,"updateDelay",void 0),t([T()],it.prototype,"view",void 0),t([T()],it.prototype,"templateCustomTextElements",void 0),t([T({type:R})],it.prototype,"templateOptions",void 0),it=t([w("esri.widgets.Print.PrintViewModel")],it);const st=it;export{st as default};
|
|
2
|
+
import{__decorate as t}from"tslib";import{isSome as e}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import{EventedAccessor as o}from"../../core/Evented.js";import{JSONMap as a}from"../../core/jsonMap.js";import{clone as r}from"../../core/lang.js";import{LoadableMixin as l}from"../../core/Loadable.js";import{EsriPromiseMixin as n}from"../../core/Promise.js";import p from"../../core/ReactiveMap.js";import{watch as m,initial as d,whenOnce as h}from"../../core/reactiveUtils.js";import{createScreenPoint as u}from"../../core/screenUtils.js";import{unitType as c,convertUnit as f,getMetersPerUnitForSR as y,inchesPerMeter as v}from"../../core/units.js";import{property as T,subclass as w}from"../../core/accessorSupport/decorators.js";import _ from"../../geometry/Extent.js";import I from"../../geometry/SpatialReference.js";import{formatDate as g,convertDateFormatToIntlOptions as b}from"../../intl/date.js";import{getLocaleLanguage as x}from"../../intl/locale.js";import O from"../../portal/Portal.js";import E from"../../portal/PortalQueryParams.js";import{execute as P,getPrintCache as S,getTaskInfo as L}from"../../rest/print.js";import{formatJsonMap as U}from"../../rest/support/fileFormat.js";import{fromJSON as k}from"../../rest/support/layoutTemplate.js";import C from"../../rest/support/LegendLayer.js";import j from"../../rest/support/PrintParameters.js";import{getVisibleLayerViews as F}from"../../rest/support/printTaskUtils.js";import M from"../../rest/support/PrintTemplate.js";import{getExtent as H}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as A}from"../../views/input/InputManager.js";import D from"../../views/overlay/BoxOverlayItem.js";import N from"./CustomTemplate.js";import W from"./FileLink.js";import R from"./TemplateOptions.js";import{fetchLayoutTemplateInfos as V,valueUnitKebabDict as z}from"./utils.js";const B=[30,144,255,255],q=[237,211,23,255],G=[216,48,32,255],J=/(\/GPServer\/).+/i,$=96,Q=i.ofType(N),K=i.ofType(W),X=new a({Feet:"feet",Miles:"miles",Meters:"meters",Kilometers:"kilometers"});function Y(t){t.layoutOptions??={},t.layoutOptions.customTextElements??=[];const e="date";if(!t.layoutOptions.customTextElements.find(t=>e in t)){const{customTextElements:e}=t.layoutOptions;let i=g(Date.now(),b("short-date"));"ar"===x()&&(i=""+i),e.push({date:i})}}function Z(t,e,i){const s=t.visible??!0,o=t.legendEnabled??!0;if(!s||!o)return;const a=0===e,r=t.minScale??0,l=t.maxScale??0;if(!(a||(0===r||e<=r)&&(0===l||e>=l)))return;const n=t.sublayers?.toArray();if(n)for(const p of n)Z(p,e,i);else null!=t.id&&i.push(String(t.id))}function tt(t,e,i,s){if(!e.layoutOptions)return;if(!i)return void(e.layoutOptions.legendLayers=[]);if(!t)return;let o=0;e.scalePreserved&&(o=e.outScale||t.scale);const a=F(t),r=[];for(const l of a)if(l.legendEnabled){const t="sublayers"in l.layer&&l.layer.sublayers?l.layer.sublayers.toArray():void 0,e=[];for(const i of t??[])Z(i,o,e);r.push(new C({layerId:l.layer.id,title:l.layer.title||void 0,subLayerIds:t?e:void 0,dynamicLegend:s}))}e.layoutOptions.legendLayers=r}function et(t,e,i){if(!e)return;!(e.visible===i)&&t.layoutOptions&&(t.layoutOptions.elementOverrides?t.layoutOptions.elementOverrides[e.name]={visible:i}:t.layoutOptions.elementOverrides={[e.name]:{visible:i}})}let it=class extends(l(n(o))){constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._templateIdToCustomTemplate=new p,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this._asyncPrintTaskUrl=null,this._layoutInfoTaskUrl=null,this._portalLayoutInfoTaskUrl=null,this._customLayoutOptions=null,this._exportedFileNameMap={},this._layoutTemplateInfosCache=new Map,this._tasksInfoCache=new Map,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new Q,this.datumTransformations=null,this.defaultTemplates=new Q,this.error=null,this.exportedLinks=new K,this.extraParameters=null,this.includeDefaultTemplates=!0,this.outSpatialReference=null,this.portal=O.getDefault(),this.portalTemplateIds=[],this.printServiceTemplates=new Q,this.defaultTemplate=null,this.showPrintAreaEnabled=!1,this.printServiceUrl=null,this.printTimeout=12e4,this.saveExportEnabled=!1,this.templatesInfo=null,this.updateDelay=1e3,this.view=null,this.templateCustomTextElements=null,this.templateOptions=new R}initialize(){this.addHandles([m(()=>[this.showPrintAreaEnabled,this.view],()=>{this.showPrintAreaEnabled?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))}),m(()=>[this.templateOptions.layout,this.templateOptions.layoutItem],()=>{this.loaded&&this._processTemplateOptions()}),m(()=>[this.allowedFormats,this.allowedLayouts],()=>{this.loaded&&this._loadTemplateInfos()}),m(()=>this.exportedLinks,()=>{const t={};for(const{name:e,extension:i}of this.exportedLinks){if(!e||!i)continue;const s=`${e}${i}`,o=t[s];t[s]=void 0!==o?o+1:0}this._exportedFileNameMap=t},d)])}destroy(){this.removeHandles("overlay-handler"),this.view&&(this._overlayItem&&(this.view.overlay?.removeItem(this._overlayItem),this._overlayItem.destroy(),this._overlayItem=null),this.view=null)}get effectivePrintServiceUrl(){return this.printServiceUrl??null}get effectiveTemplateCustomTextElements(){if(!this._serviceTemplateCustomTextElements)return{};const t=r(this._serviceTemplateCustomTextElements);return this.templateCustomTextElements&&Object.keys(this.templateCustomTextElements).forEach(e=>{const i=t[e];if(i){const t=this.templateCustomTextElements?.[e];i.forEach(e=>{const[i]=Object.entries(e)[0];t?.forEach(t=>{const[s,o]=Object.entries(t)[0];i===s&&(e[i]=o)})})}}),Object.freeze(t)}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}async print(t){const{view:e,extraParameters:i,updateDelay:o,outSpatialReference:a,datumTransformations:r}=this;if(!e)throw new s("print:view-required","view is not set");Y(t);const l=this._getOverlayItem(),n=t.scalePreserved||!this.showPrintAreaEnabled?void 0:H(new _,e.viewpoint,"map-only"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[l.boxWidth,l.boxHeight]),p=new j({view:e,template:t,extent:n,extraParameters:i,updateDelay:o,outSpatialReference:a,datumTransformations:r});try{const e=!!t.layoutItem?.id&&(this.defaultTemplates.some(e=>e.layoutItem?.id===t.layoutItem?.id)||this.browseTemplates.some(e=>e.layoutItem?.id===t.layoutItem?.id));return await P(e&&this._asyncPrintTaskUrl?this._asyncPrintTaskUrl:this.effectivePrintServiceUrl,p,{timeout:this.printTimeout})}catch(m){throw new s("print:export-error","An error occurred while exporting the web map.",{error:m})}}async load(t){return this.addResolvingPromise(this._loadResources(t).catch(t=>this.error=t)),this}toPrintTemplate({attributionEnabled:t,author:e,copyright:i,customTextElements:o,dpi:a,forceFeatureAttributes:r,format:l,height:n,id:p,includeTables:m,layout:d,layoutItem:h,legendEnabled:u,dynamicLegendEnabled:c,northArrowEnabled:f,scale:y,scaleBarEnabled:v,scaleBarUnit:T,scaleEnabled:w,title:_,width:I}){if(!d&&!h)throw new s("print:layout-required","layout is not set");const g={};e&&(g.authorText=e),i&&(g.copyrightText=i),o&&(g.customTextElements=o),_&&(g.titleText=_),v&&T&&(g.scalebarUnit=X.toJSON(T));const b=new M({attributionVisible:t,forceFeatureAttributes:r,format:l,includeTables:m,layout:d,layoutItem:h,layoutOptions:g,outScale:y??0,scalePreserved:w});if(I&&(b.exportOptions.width=I),n&&(b.exportOptions.height=n),a&&(b.exportOptions.dpi=a),b.layoutOptions){tt(this.view,b,u,c);const t=this.getLayoutTemplateById(p)?.mapSurroundInfoOptions;if(t){const e=t.northArrow;for(const t of e)et(b,t,f);const i=t.scaleBar;for(const t of i)et(b,t,v);const s=t.legend;for(const t of s)et(b,t,u)}}return b}getLayoutTemplateById(t){return t?this._templateIdToCustomTemplate.get(t):null}async addPortalTemplate(t){if(!this.portal||!t?.id)return;try{if("loading"===this.loadStatus&&await h(()=>this.loaded),!this.loaded)throw new s("print:load-required","PrintViewModel must be loaded before adding portal templates.");t.loaded||await t.load()}catch{return void this.applyTemplate(this.defaultTemplate)}const e=new N({type:"browse-template",layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl,label:t.title,layoutItem:t});this._templateIdToCustomTemplate.set(e.id,e),this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem&&this.templateOptions.id===t.layoutItem.id&&(this.defaultTemplate?this.applyTemplate(this.defaultTemplate):this.templateOptions.reset()),this.browseTemplates.remove(t),this._templateIdToCustomTemplate.delete(t.id)}async applyTemplate(t){if(t&&t===this.getLayoutTemplateById(this.templateOptions.id))return;if(this.templateOptions.reset(),!t)return;if("map-only"===t)return void(this.templateOptions.layout="map-only");!t.layout||!this.templatesInfo||this.templatesInfo.layout.choiceList.includes(t.layout)||(this.defaultTemplate?t=this.defaultTemplate:this.templateOptions.reset());const e=t.layout||t.layoutItem?.id,i=e?this.templateCustomTextElements?.[e]:void 0;if(await this.templateOptions.applyTemplate(t,{customTextElements:i,customLayoutOptions:this._customLayoutOptions}),e&&this._serviceTemplateCustomTextElements&&!this._serviceTemplateCustomTextElements[e]&&t.layoutTemplateInfo?.layoutOptions?.customTextElements){const i=r(this._serviceTemplateCustomTextElements);i[e]=t.layoutTemplateInfo.layoutOptions.customTextElements,this._serviceTemplateCustomTextElements=Object.freeze(i)}}createExportedFileLink(t){const e=this.toPrintTemplate(this.templateOptions).format.toLowerCase(),i=e.includes("png")?"png":e,s=t+i;return this._updateExportedFileNameMap(s),new W({name:t,extension:i,count:this._exportedFileNameMap[s]})}export(t){const e=this.createExportedFileLink(t);this.exportedLinks.add(e);const i=this.print(this.toPrintTemplate(this.templateOptions)).then(t=>e.set({url:t?.url,state:"ready"})).catch(t=>e.set({error:t,state:"error"}));return this.emit("submit",{link:e,saveExportEnabled:this.saveExportEnabled}),i.then(t=>this.emit("complete",{link:t,saveExportEnabled:this.saveExportEnabled})),{link:e,promise:i}}async _loadResources(t){if(!this.destroyed){if(await this._loadUrls(t),await this._loadTemplateInfos(t),this.effectivePrintServiceUrl){const e=await S(this.effectivePrintServiceUrl,t);this.cimVersion=e?.cimVersion}await this._updateOverLayItem()}}async _loadTemplateInfos(t){const e=[...this.defaultTemplates,...this.printServiceTemplates];for(const{id:o}of e)this._templateIdToCustomTemplate.delete(o);this.defaultTemplates.removeAll(),this.printServiceTemplates.removeAll();const[i,s]=await Promise.all([this._getLayoutToLayoutTemplateInfos(t),this._getPrintServiceTemplatesInfo(t)]);await this._loadAllTemplates(i,s,t),this._processPrintServiceTemplatesInfo(s),await this._processTemplateOptions()}_updateExportedFileNameMap(t){void 0!==this._exportedFileNameMap[t]?this._exportedFileNameMap[t]++:this._exportedFileNameMap[t]=0}async _processTemplateOptions(){const{layout:t,layoutItem:e}=this.templateOptions;if("map-only"!==t)if(this._customLayoutOptions={legend:this.templateOptions.legendEnabled,northArrow:this.templateOptions.northArrowEnabled,scaleBar:this.templateOptions.scaleBarEnabled},e?.id){try{e.loaded||await e.load()}catch{return void this.applyTemplate(this.defaultTemplate)}let t=this._templateIdToCustomTemplate.get(e.id);t||(t=new N({label:e.title,layoutItem:e,layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl}),this._templateIdToCustomTemplate.set(t.id,t)),await this.applyTemplate(t)}else if(t){const t=this.defaultTemplates.find(t=>t.layout===this.templateOptions.layout)??this.printServiceTemplates.find(t=>t.layout===this.templateOptions.layout);await this.applyTemplate(t??this.defaultTemplate)}}async _loadPortal(t){try{await this.portal.load(t)}catch(e){throw new s("print:could-not-load-portal","Cannot load print resource information from portal",{error:e,url:this.effectivePrintServiceUrl})}}async _loadUrls(t){if(this.printServiceUrl)this._set("effectivePrintServiceUrl",this.printServiceUrl),this._layoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(this.effectivePrintServiceUrl,t);else{await this._loadPortal(t);const{printTask:e,asyncPrintTask:i,layoutInfoTask:s}=this.portal?.helperServices??{};this._set("effectivePrintServiceUrl",e?.url),this._asyncPrintTaskUrl=i?.url,this._layoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(this.effectivePrintServiceUrl,t),s?.url&&this.effectivePrintServiceUrl!==s.url?this._portalLayoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(s.url,t):this._portalLayoutInfoTaskUrl=this._layoutInfoTaskUrl}const e=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!e?.includes("gpserver"))throw new s("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl})}async _getLayoutInfoTaskUrl(t,e){if(!t)return null;const i=await L(t,"GetLayoutTemplatesInfo",e);return i?t.replace(J,`$1${encodeURI(i.displayName)}`):null}_getPortalDefaultTemplates(t,e){return this.portal?.helperServices?.printTask?.templates?.filter(t=>"map_only"!==t.layout.toLowerCase()&&(!e||e.includes(k(t.layout))))?.map(e=>{const i=N.fromJSON(e);if(i.type="default-template",i.layoutInfoTaskUrl=this._layoutInfoTaskUrl,i.layout){const e=t.get(i.layout);e&&i.setLayoutTemplateInfo(e)}return i})??[]}async _getPortalCustomTemplates(t){if(this.printServiceUrl||!this.portal)return[];const{portal:e}=this,{layoutGroupQuery:i,sourceJSON:s}=e,{state:o,user:a}=s??{},{availableCredits:r=0,assignedCredits:l=0}=a??{},n="suspended"===o,p="active"===o&&r<=0&&l>0,m=a?.privileges?.includes("premium:user:print:customlayout");if(!i||n||p||!m)return[];const d=new E({query:i,disableExtraQuery:!0}),h=await this.portal.queryGroups(d,t);if(!h.total)return[];const u=h.results[0],c=new E({num:100,query:"type:Layout",sortField:u.sortField,sortOrder:u.sortOrder??void 0}),f=(await u.queryItems(c,t)).results;if(!f.length)return[];return f.map(t=>(this.portalTemplateIds.push(t.id),new N({type:"default-template",label:t.title,layoutItem:t,layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl})))}async _loadAllTemplates(t,e,i){let s=!1;const o=e?.layout?.choiceList;if(this.includeDefaultTemplates&&this.portal&&!this.printServiceUrl){const e=this._getPortalDefaultTemplates(t,o);s=!!e.length,this.defaultTemplates.addMany(e);const a=await this._getPortalCustomTemplates(i);this.defaultTemplates.addMany(a);for(const t of this.defaultTemplates)this._templateIdToCustomTemplate.set(t.id,t)}s||t.forEach((t,e)=>{if(!o||o.includes(e)){const i=new N({type:"print-service-template",layout:e,layoutInfoTaskUrl:this._layoutInfoTaskUrl});i.setLayoutTemplateInfo(t),this.printServiceTemplates.add(i),this._templateIdToCustomTemplate.set(i.id,i)}})}_processPrintServiceTemplatesInfo(t){this._set("templatesInfo",t);const e=t?.layout?.defaultValue;if(e&&"map-only"!==e){const t=this.defaultTemplates.find(t=>t.layout===e)??this.printServiceTemplates.find(t=>t.layout===e)??this.defaultTemplates.at(0)??this.printServiceTemplates.at(0);this._set("defaultTemplate",t)}}async _getLayoutToLayoutTemplateInfos(t){const e=this._layoutInfoTaskUrl,i=e?this._layoutTemplateInfosCache.get(e):void 0,s=i??(e?await V(e,void 0,t):[]);!i&&e&&this._layoutTemplateInfosCache.set(e,s);const o=new Map,a={};for(const r of s){const t=k(r.layoutTemplate);o.set(t,r),a[t]=r.layoutOptions.customTextElements}return this._serviceTemplateCustomTextElements=Object.freeze(a),o}async _getPrintServiceTemplatesInfo(t){const e=this.effectivePrintServiceUrl?this._tasksInfoCache.get(this.effectivePrintServiceUrl):void 0,i=e??(this.effectivePrintServiceUrl?await L(this.effectivePrintServiceUrl,"ExportWebMap",t):void 0);if(!i)throw new s("print:unavailable-service-info","Can't fetch templates info from service");!e&&this.effectivePrintServiceUrl&&this._tasksInfoCache.set(this.effectivePrintServiceUrl,i);const{parameters:o}=i,a=o.find(({name:t})=>"Format"===t),r=o.find(({name:t})=>"Layout_Template"===t);return{format:this._getFormat(a),layout:this._getLayout(r)}}_getFormat(t){const i="all"===this.allowedFormats?t.choiceList:t.choiceList.filter(t=>"string"!=typeof this.allowedFormats&&this.allowedFormats.some(e=>new RegExp(`\\b${e}\\b`,"i").test(t))),s=(i.length?i:t.choiceList).map(t=>U.fromJSON(t)).filter(e),o=U.fromJSON(t.defaultValue),a=s.some(t=>new RegExp(`\\b${o}\\b`,"i").test(t))?o:s[0];return{choiceList:s,defaultValue:a}}_getLayout(t){const i=t.choiceList.filter(t=>"map_only"!==t.toLowerCase()),s="all"===this.allowedLayouts?i:i.filter(t=>this.allowedLayouts.includes(k(t))),o=(s.length?s:i).map(k).filter(e),a=k(t.defaultValue),r=o.includes(a)?a:o.find(t=>/(?=.*letter)(?=.*landscape)/i.test(t))??o.find(t=>/(?=.*a4)(?=.*landscape)/i.test(t))??o[0];return{choiceList:o,defaultValue:r}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new D({strokeDash:[5],strokeWidth:2,strokeColor:[30,144,255,255]})),this._overlayItem}_enablePrintPreview(){if(!this.view?.overlay)return;const t=this.templateOptions,e=this._getOverlayItem();this.addHandles([m(()=>[t.width,t.height,t.scaleEnabled,t.scale,t.layout,t.layoutItem,t.id,t.state,t.dpi,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding,this.loaded],()=>{this._updateOverLayItem()},d),this.view?.on("drag",["Shift"],t=>this._handleDrag(t),A.WIDGET),this.view?.on("key-down",["Escape"],()=>this._resetDrag(),A.WIDGET)],"overlay-handler"),this.view.overlay.addItem(e)}async _updateOverLayItem(){if(!this.view)return;await this.view.when();const t=this.templateOptions,e=this._getOverlayItem(),i=t.layoutItem?.id??t.layout,s=this.view,o=s.spatialReference,[a,r]=s.state.paddedViewState.size,l=s.state.padding;let n=0,p=0;if("map-only"===i)null!=t.width&&null!=t.height&&(n=t.width,p=t.height);else if(i){const e=t.id?this._templateIdToCustomTemplate.get(t.id):null,{webMapFrameSize:i,pageUnits:s}=e?.layoutTemplateInfo??{};let l=!1;if(i&&s)if(this._isFreeHand){const t=i[0]/i[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=z.fromJSON(s.toLowerCase()),e=o.unit;c(t)===c(e)?(n=f(i[0],t,e),p=f(i[1],t,e)):(l=!0,n=i[0],p=i[1])}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const t=l?Math.min(a/n,r/p):y(o)*v*$;n*=t,p*=t}else if(0===n||0===p)n=a,p=r;else{const t=(a-.1*a)/n,e=(r-.1*r)/p,i=Math.min(t,e);n*=i,p*=i}}const{scaleEnabled:m,scale:d}=t,h=m&&d?d/this.view.scale:1;if(e.boxWidth=n*h||a,e.boxHeight=p*h||r,l&&(e.padding=l),e.backgroundWidth=a??0,e.backgroundHeight=r??0,"loading"===this.loadStatus)e.strokeColor=q;else if("loaded"===this.loadStatus)switch(this.templateOptions.state){case"pending":e.strokeColor=q;break;case"ready":e.strokeColor=B;break;case"error":e.strokeColor=G}}_resetDrag(){this._isFreeHand=!1,this._updateOverLayItem()}_handleDrag(t){switch(t.action){case"start":this._start();break;case"update":this._update(t);break;case"end":this._end()}t.stopPropagation()}_start(){this._isFreeHand=!0}_update(t){const e=this._getOverlayItem(),{x:i,y:s}=t,{x:o,y:a}=t.origin;i>o?(e.x=o,e.boxWidth=i-o):(e.x=i,e.boxWidth=o-i),s>a?(e.y=a,e.boxHeight=s-a):(e.y=s,e.boxHeight=a-s)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,i=e.toMap(u(t.x+.5*t.boxWidth,t.y+.5*t.boxHeight));t.x=null,t.y=null,e.goTo({center:i}),this._freeHandWidth=t.boxWidth,this._freehandHeight=t.boxHeight,"map-only"===this.templateOptions.layout&&(this.templateOptions.width=this._freeHandWidth,this.templateOptions.height=this._freehandHeight),this.templateOptions.scale=this.view.scale,this._updateOverLayItem()}};t([T()],it.prototype,"_serviceTemplateCustomTextElements",void 0),t([T()],it.prototype,"_templateIdToCustomTemplate",void 0),t([T()],it.prototype,"allowedFormats",void 0),t([T()],it.prototype,"allowedLayouts",void 0),t([T({type:Q})],it.prototype,"browseTemplates",void 0),t([T()],it.prototype,"cimVersion",void 0),t([T()],it.prototype,"datumTransformations",void 0),t([T({type:Q})],it.prototype,"defaultTemplates",void 0),t([T()],it.prototype,"error",void 0),t([T({type:K})],it.prototype,"exportedLinks",void 0),t([T()],it.prototype,"extraParameters",void 0),t([T()],it.prototype,"includeDefaultTemplates",void 0),t([T({readOnly:!0})],it.prototype,"effectivePrintServiceUrl",null),t([T()],it.prototype,"effectiveTemplateCustomTextElements",null),t([T({type:I})],it.prototype,"outSpatialReference",void 0),t([T({type:O})],it.prototype,"portal",void 0),t([T()],it.prototype,"portalTemplateIds",void 0),t([T({type:Q})],it.prototype,"printServiceTemplates",void 0),t([T({readOnly:!0})],it.prototype,"defaultTemplate",void 0),t([T()],it.prototype,"showPrintAreaEnabled",void 0),t([T()],it.prototype,"printServiceUrl",void 0),t([T()],it.prototype,"printTimeout",void 0),t([T()],it.prototype,"saveExportEnabled",void 0),t([T({readOnly:!0})],it.prototype,"state",null),t([T({readOnly:!0})],it.prototype,"templatesInfo",void 0),t([T()],it.prototype,"updateDelay",void 0),t([T()],it.prototype,"view",void 0),t([T()],it.prototype,"templateCustomTextElements",void 0),t([T({type:R})],it.prototype,"templateOptions",void 0),it=t([w("esri.widgets.Print.PrintViewModel")],it);const st=it;export{st as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{id as t}from"../../kernel.js";import r from"../../core/Collection.js";import{deprecatedModule as s}from"../../core/deprecate.js";import i from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import l from"../../core/Logger.js";import{whenOnce as o,once as n}from"../../core/reactiveUtils.js";import{property as c,subclass as u}from"../../core/accessorSupport/decorators.js";import{ensureArray as h}from"../../core/accessorSupport/ensureType.js";import{isPoint as p,isMultipoint as d}from"../../geometry/support/jsonTypeUtils.js";import{fetchMessageBundle as g}from"../../intl/messages.js";import y from"../../layers/FeatureLayer.js";import m from"../../layers/GraphicsLayer.js";import f from"../../layers/support/CodedValueDomain.js";import{isFeatureLayer as w,isSubtypeSublayer as b,getOwningPortalUrl as _}from"../../layers/support/layerUtils.js";import A from"../../networks/UtilityNetwork.js";import{getFeaturesFromLayers as v}from"../../networks/support/utils.js";import k from"../../portal/Portal.js";import{hasUserTypeExtension as I}from"../../portal/support/utils.js";import{trace as F}from"../../rest/networks/trace.js";import G from"../../rest/networks/support/TraceLocation.js";import R from"../../rest/networks/support/TraceParameters.js";import{addUniqueLayer as T}from"../../views/draw/support/layerUtils.js";import{GeometryHandler as L}from"./support/GeometryHandler.js";import{GraphicHandler as H,barrierColor as N,startingPointColor as S}from"./support/GraphicHandler.js";import{ResultAreaHandler as P}from"./support/ResultAreaHandler.js";import{UtilityHelper as U}from"./support/UtilityHelper.js";const B=()=>g("esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace"),j=()=>g("esri/core/t9n/Units"),V=`utility-network-trace-flags-${Date.now()}`,C=`utility-network-trace-results-${Date.now()}`,E=`utility-network-trace-sketch-${Date.now()}`;function O(e){return e instanceof f}function D(e){return"feature"===e.layer.type||"subtype-group"===e.layer.type}function M(e){return"layer"in e}function x(e){return void 0!==e.layerViews}function q(e){return"graphics"===e.type}function $(e){return"feature"===e.type||"subtype-group"===e.type||"group"===e.type}async function z(e){const t=new y({url:e.networkSystemLayers.dirtyAreasLayerUrl});await t.load();const r=t.version;if(Number(r)<=11.1){const t=await _(e.layerUrl),r=new k({url:t});await r.load();const s=r?.user?.username;return!!s&&I(r,s,"utilityNetwork")}return!0}s(l.getLogger("esri.widgets.UtilityNetworkTrace.UtilityNetworkTraceViewModel"),"UtilityNetworkTraceViewModel",{replacement:"Use esri/networks/UtilityNetworkTraceAnalysis instead",version:"5.0",warnOnce:!0});let Q=class extends a{constructor(e){super(e),this._activeProgress=!1,this._clickHandler=null,this._flags=[],this._flagId=0,this._geometryHandler=null,this._highlightHandler=[],this._resultAreaHandler=null,this._sketchViewModel=null,this._traceTimeout=6e5,this._utilityHelper=new U,this._validUNLayers=[],this._watchHandler=null,this.traces=[],this.graphicHandler=null,this.defaultGraphicColor={color:[255,255,0,.6],haloOpacity:.9,fillOpacity:.2,hex:"#FFFF00"},this.enableResultArea=!1,this.flags=[],this.messages=null,this.messagesUnits=null,this.defaultResultAreaProperties={type:"convexhull",distance:10,unit:"meters",areaUnit:"square-meters",color:{color:[255,165,0,.5],haloOpacity:.9,fillOpacity:.2,hex:"#ffa500"},show:!1},this.selectedTraces=[],this.selectOnComplete=!0,this.showGraphicsOnComplete=!0,this.showSelectionAttributes=!0,this.traceResults=[],this.utilityNetwork=null}initialize(){this._geometryHandler=new L,this.graphicHandler=new H,this._resultAreaHandler=new P;(async()=>{const[e,t]=await Promise.all([B(),j()]);this.set({messages:e,messagesUnits:t})})()}destroy(){this.view=null}get resultAreaProperties(){return this.defaultResultAreaProperties}set resultAreaProperties(e){this._set("resultAreaProperties",{...this.defaultResultAreaProperties,...e}),this.graphicHandler.addCustomColor(this.resultAreaProperties.color),this.traceResults.forEach(t=>{const r=t.resultArea?.show;t.resultArea={...this.defaultResultAreaProperties,...e},this.removeResultAreaFromMap(t),this.enableResultArea&&this.createResultAreaGraphic(t).then(s=>{if(s){t.resultAreaGraphic=s;const i=e?.show??r;t.resultArea&&(t.resultArea.show=i),i&&this.addResultAreaToMap(t,s)}})})}get state(){return this.view?.ready?"ready":"loading"}get view(){return this._get("view")}set view(e){e&&"2d"!==e.type&&l.getLogger(this).error(new i("view:invalid-view","SceneView is not supported",{view:e})),this._set("view",e),this.utilityNetwork&&this.reset(),this.utilityNetwork=null,this.loadUtilityNetwork().then(e=>{e&&this.selectTracesOnLoad()})}addFlagByHit(e,t){const r=!!this.view&&this.view.popupEnabled,s=e=>{this.view?.popup&&(this.view.popupEnabled=e)};return new Promise((i,a)=>{r&&s(!1),this._clickHandler?.remove(),this._clickHandler=this._sketchViewModel.on("create",l=>{if("complete"===l.state){const o=this._getGraphicLayer(E);o&&l.graphic&&o.remove(l.graphic),this.queryFlagByHitTest(l,e,t).then(r=>{this.emit("add-flag-complete",{type:e,symbol:t}),i(r)}).catch(r=>{this.emit("add-flag-error",{type:e,symbol:t}),a(r)}).finally(()=>{r&&s(!0),this._clickHandler?.remove()})}}),this._sketchViewModel.create("point"),this.emit("add-flag",{type:e})})}addNonspatialTraceLocation(e,t){const r=this._getDisplayField(e),s=this.utilityNetwork?.getTerminalConfiguration(e),i={terminalId:null,isFilterBarrier:!1,allTerminals:s,selectedTerminals:[s?s.terminals[0].id||null:1],displayValue:r};e.attributes={...e.attributes,...i};const a=e.attributes.hasOwnProperty("GLOBALID")?e.attributes.GLOBALID:e.attributes.globalid;if(!this._flags.some(e=>e.globalId===a&&e.type===t)){const r=this._createFlagProperty(e,t,null);this._flags.push(r),this.emit("add-flag-complete",{type:t})}this.emit("add-flag",{type:t})}async addFlagsOnLoad(){if(this._flags.length>0)return[];await o(()=>null!=this.view&&!this.view.updating);return(await Promise.all(this.flags.map(async e=>{if(!e.mapPoint)return null;const{type:t}=e,r=e.mapPoint.clone(),s="barrier"===t?N:S,i={graphic:this.graphicHandler.makeGraphic(r,s),state:"complete",tool:"point",toolEventInfo:null,type:"create"};try{return await this.queryFlagByHitTest(i,e.type,null),this.emit("add-flag-complete",{type:t}),null}catch(a){return this.emit("add-flag-error",{type:t}),"barrier"===t?"barrier":"starting-point"}}))).filter(e=>!e)}async addResultAreaToMap(e,t){if(this.view)if(e.resultArea.show=!0,t)this._resultAreaHandler?.addResultAreaToMap(t,this.view.map),this.emit("add-result-area",{graphic:t});else if(e.results){const t=await this.createResultAreaGraphic(e);t&&(e.resultAreaGraphic=t,this._resultAreaHandler?.addResultAreaToMap(t,this.view.map),this.emit("add-result-area",{graphic:t}))}}async addResultGraphicToView(e,t){const{view:r}=this,{results:s}=e;if(r&&s&&this.utilityNetwork)for(const i in s.aggregatedGeometry)if("line,multipoint,polygon".includes(i)){const a=i,l=s.aggregatedGeometry[a];if(null!=l){l.spatialReference=this.utilityNetwork.spatialReference,e.graphicEnabled=!0;const s=await this._geometryHandler.projectGeometry(l,r.spatialReference),i={globalid:e.trace.globalId};if(null!==s){const e=this.graphicHandler.makeGraphic(s,t.color,i,r.spatialReference);this._getGraphicLayer(C)?.add(e)}}}}addTerminal(e,t){const r=[...this._flags];r.forEach(r=>{r.globalId===t.globalId&&(t.selectedTerminals?.includes(parseInt(e,10))||r.selectedTerminals?.push(parseInt(e,10)))}),this._flags=r}async callTrace(){const e=this.traces.filter(e=>e.selected);return!!e.length&&(this.traceResults.length>0&&this.traceResults.forEach(e=>{this.removeResultGraphicFromView(e)}),this.traceResults=[],this.removeSelection(),await Promise.all(e.map(async(e,t)=>{const r=e,s=new R({gdbVersion:this.utilityNetwork?.gdbVersion,moment:this.utilityNetwork?.historicMoment,namedTraceConfigurationGlobalId:r.globalId,outSpatialReference:null,resultTypes:null,traceType:r.traceType,traceLocations:h(G,this._flags),traceConfiguration:null});await this.executeTrace(r,this.utilityNetwork?.networkServiceUrl,s).then(async e=>{if(e.hasOwnProperty("results")){const r={...e};if(null!==r.results){r.resultArea={...this.resultAreaProperties};const e=[...r.results.elements];r.results.elements.length=0;const s=new Map;for(const t of e)s.has(t.globalId)||(s.set(t.globalId,!0),r.results.elements.push(t));const i=[...this.traceResults];if(i.splice(t,0,r),this.traceResults=i,null!==r.results&&(this.selectOnComplete&&this.mergeSelection(!0,r.trace),this.showGraphicsOnComplete&&await this.addResultGraphicToView(r,r.graphicColor),this.enableResultArea)){const e=await this.createResultAreaGraphic(r);e&&(r.resultAreaGraphic=e,r.resultArea?.show&&await this.addResultAreaToMap(r,r.resultAreaGraphic))}}else{const r=[...this.traceResults];r.splice(t,0,e),this.traceResults=r}this._activeProgress=!1}else{this._activeProgress=!1;const r=[...this.traceResults];r.splice(t,0,e),this.traceResults=r}}).catch(e=>{throw this._activeProgress=!1,e})})),!0)}cancelAddFlagByHit(){this._sketchViewModel.cancel()}changeResultAreaColor(e,t){if(!e.resultArea)return;e.resultArea.color=t;const r=this._resultAreaHandler?.changeResultAreaColor(e.trace.globalId,t,this.view.map);e.resultAreaGraphic&&(e.resultAreaGraphic.symbol=r)}changeResultGraphicColor(e,t){const r=[...this.traceResults];r.length>0&&r.forEach(r=>{r.trace.globalId===t.trace.globalId&&(r.graphicColor=e,r.graphicEnabled=!0)}),this.traceResults=r,this.removeResultGraphicFromView(t),this.addResultGraphicToView(t,e)}changeFlagSymbol(e,t){this._flags.length>0&&this._flags.forEach(r=>{r.type===e&&t&&r.mapGraphic&&(r.mapGraphic.symbol=t)})}checkCanTrace(){const e={status:!0,issues:[]},t=this.traces.filter(e=>e.selected);t.length||(e.status=!1,e.issues.push("noTracesSelected"));this._flags.some(e=>"starting-point"===e.type)||(e.status=!1,e.issues.push("noStartingPoints"));return this._flags.filter(e=>null!==e.allTerminals).some(e=>!e.selectedTerminals.length)&&(e.status=!1,e.issues.push("noTerminalSelected")),e}checkSelectionExist(){return this._highlightHandler.some(e=>e)}clearResult(e){if(!this.view)return;let t=this.traceResults;if(t.length>0){const r=t.filter(t=>t.trace.globalId===e.globalId);r.length>0&&(this.removeResultGraphicFromView(r[0]),this.removeResultAreaFromMap(r[0])),t=t.filter(t=>t.trace.globalId!==e.globalId)}this.traceResults=t,0===t.length?(this.removeAllResultAreaGraphics(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]})):this.mergeSelection(!1,e)}createResultAreaGeometries(e,t,r){if(!this.view||!this.resultAreaProperties)return;let s;if(s="convexhull"===this.resultAreaProperties?.type?1===t.length&&(p(t[0])||d(t[0])&&1===t[0].points.length)?this._resultAreaHandler?.createBuffer(t,r,e.resultArea?.unit,!0):this._resultAreaHandler?.createConvexHull(t,e.resultArea?.distance,e.resultArea?.unit):this._resultAreaHandler?.createBuffer(t,r,e.resultArea?.unit,!0),!s)return;if(Array.isArray(s)){for(const t of s){const r=this.getResultAreaAttributes(e,t),s=this._resultAreaHandler?.createResultAreaGraphic(t,r,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color);if(s)return s}return}const i=this.getResultAreaAttributes(e,s);return this._resultAreaHandler?.createResultAreaGraphic(s,i,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color)}async createResultAreaGraphic(e){if(e.results){const t=await this._createResultAreaInputGeometry(e.results);if(t.length>0){const r=Array(t.length).fill(e.resultArea?.distance),s=this.createResultAreaGeometries(e,t,r);return this.emit("create-result-area",{graphic:s}),s}}}executeTrace(e,t,r){const s=this._processFlags(r.traceLocations);return r.traceLocations=s,F(t,r,{timeout:this._traceTimeout}).then(t=>({trace:e,results:t,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:"success",date:new Date})).catch(t=>({trace:e,results:null,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:t.message,date:new Date}))}async getNonspatialTraceLocationInitialFeature(){return new Promise((e,t)=>{this._clickHandler?.remove(),this._clickHandler=this._sketchViewModel.on("create",async r=>{if("complete"!==r.state)return;const s=this._getGraphicLayer(E);s&&r.graphic&&s.remove(r.graphic);const i=this.view?.toScreen(r.graphic?.geometry);if(!i)return;const a=await(this.view?.hitTest(i));if(a?.results.length){const r=a.results.find(e=>"graphic"===e.type&&this.utilityNetwork?.isUtilityLayer(e.layer));r?e(r):t(null)}}),this._sketchViewModel.create("point")})}getResultAreaAttributes(e,r){const{messages:s}=this,i=[],a=[];this._flags.forEach(e=>{const t=e.displayValue?.field+":"+e.displayValue?.value+";"+s.attributeStrings.globalid+":"+e.globalId+";"+s.attributeStrings.terminalid+":"+e.terminalId+";"+s.attributeStrings.x+":"+e.mapPoint?.x+";"+s.attributeStrings.y+":"+e.mapPoint?.y;"starting-point"===e.type?i.push(t):a.push(t)});const l=this.utilityNetwork?.gdbVersion;return{traceId:e.trace.globalId,traceName:e.trace.title,traceDescription:e.trace.description??"",startingPoints:i.toString(),barriers:a.toString(),version:l??void 0,username:t.credentials[0].userId,date:e.date,elementCount:e.results?.elements.length,functionResult:JSON.stringify(e.results?.globalFunctionResults),areaStatistic:r?this._geometryHandler.calculateArea(r,e.resultArea?.areaUnit):0}}getValidSources(){let e=[];const t=this.utilityNetwork?.dataElement?.domainNetworks??[];for(const r of t)e=e.concat(r.junctionSources),e=e.concat(r.edgeSources);return e}groupResultsByNetworkSource(e){return 0===e.length?[]:this._groupBy(e,"networkSourceId")}async loadUtilityNetwork(){const{view:e}=this;if(!e)return null;if(await e.when(),this.utilityNetwork){if(this.utilityNetwork.loaded||await this.utilityNetwork.load(),this.utilityNetwork instanceof A){try{const t=e.map;await t.loadAll()}catch(s){if("layer:unsupported-layer-type"!==s.name&&"subtype-grouplayer:missing-subtypes"!==s.name)throw s;console.error(s)}finally{this._loadUNSupportItems()}return this.utilityNetwork}return null}const t=e.map,r=t.utilityNetworks?.at(0);if(r){if(await r.load(),this.utilityNetwork=r,!await z(r))throw new i("utility-network:no-user-type-extension","User type extension not found");try{await t.loadAll()}catch(s){if("layer:unsupported-layer-type"!==s.name&&"subtype-grouplayer:missing-subtypes"!==s.name)throw s;console.error(s)}finally{this._loadUNSupportItems()}return r}return null}manageFilterBarrier(e,t){const r=[...this._flags];r.forEach(r=>{r.globalId===t.globalId&&"barrier"===t.type&&r.id===t.id&&(r.isFilterBarrier=e)}),this._flags=r}mergeSelection(e,t){let r=[];const s=[...this.traceResults],i=t.globalId;s.forEach(t=>{i===t.trace.globalId&&(t.selectionEnabled=e),t.selectionEnabled&&null!==t.results?.elements&&(r=[...r,...t.results?.elements??[]])}),this.selectResults([...new Set(r)])}async queryFeaturesById(e){const{view:t}=this;if(!t||!this.utilityNetwork)return null;const s=this.utilityNetwork.getObjectIdsFromElements(e),i={layerUrl:s[0].layerUrl,objectIds:s[0].objectIds,outFields:["*"]},a=t.map?.allTables.toArray().filter(e=>e?.parsedUrl?.path===s[0].layerUrl).filter(w)??[];this._getUniqueMapLayerViews(t).filter(({layer:e})=>e?.parsedUrl?.path===s[0].layerUrl).forEach(({layer:e})=>{"feature"!==e.type&&"subtype-group"!==e.type||a.push(e)});const l=(await Promise.all(a.map(async e=>{const s={layers:new r([e]),layerInfos:[i],returnGeometry:!0,outSpatialReference:t.spatialReference},[a]=await v(s,!1);return a}))).filter(({featureSet:e})=>e.features.length>0);return l.length>0?l:null}queryFlagByHitTest(e,t,r){return this._lookupFlagByHit(e).then(e=>{const{view:s}=this;if(!s)return!1;if(e.length>0){const s=[...this._flags],i=r;return e.forEach(e=>{const r=e.graphic,a=r.attributes.hasOwnProperty("GLOBALID")?r.attributes.GLOBALID:r.attributes.globalid;if(s.filter(e=>e.globalId===a).length<=0){const e=this.graphicHandler.getFlagGraphic(r.attributes.mapPoint,t,r,i);this._getGraphicLayer(V)?.add(e);const a=this._createFlagProperty(r,t,e);s.push(a)}else if(null!==r.attributes.percentAlong){const e=this.graphicHandler.getFlagGraphic(r.attributes.mapPoint,t,r,i);this._getGraphicLayer(V)?.add(e);const a=this._createFlagProperty(r,t,e);s.push(a)}}),this._flags=s,!0}return!1})}removeResultGraphicFromView(e){const{view:t}=this;if(!t)return;const r=this._getGraphicLayer(C)?.graphics;e.graphicEnabled=!1;const s=r?.filter(t=>t.attributes[t.attributes.hasOwnProperty("GLOBALID")?"GLOBALID":"globalid"]===e.trace.globalId);s?.forEach(e=>{this._getGraphicLayer(C)?.remove(e)})}removeFlag(e){const t=this._flags.filter(t=>{if(t.id!==e.id)return t});this._removeGraphic(e),this._flags=t}removeAllResultAreaGraphics(){this._resultAreaHandler?.removeAllResultAreaGraphics(this.view.map)}removeResultAreaFromMap(e){if(e.resultArea){e.resultArea.show=!1;const t=this._resultAreaHandler?.removeResultArea(e.trace.globalId,this.view?.map);t&&this.emit("remove-result-area",{graphic:t})}}removeSelection(){this._highlightHandler.forEach(e=>{e&&e.remove()}),this._highlightHandler=[]}removeTerminal(e,t){const r=[...this._flags];r.forEach(r=>{if(r.globalId===t.globalId&&t.selectedTerminals?.includes(parseInt(e,10))){const s=t.selectedTerminals.indexOf(parseInt(e,10));r.selectedTerminals?.splice(s,1)}}),this._flags=r}removeFlagsOnLoadWatcher(){this._watchHandler&&null!==this._watchHandler&&this._watchHandler.remove()}removeClickHandler(){this._clickHandler&&(this._sketchViewModel.cancel(),this._clickHandler.remove())}reset(){this._flags=[],this.traceResults=[];const e=[...this.traces];e.forEach(e=>{e.selected=!1}),this.traces=e,this.view&&(this._getGraphicLayer(E)?.removeAll(),this._getGraphicLayer(V)?.removeAll(),this._getGraphicLayer(C)?.removeAll(),this.removeAllResultAreaGraphics(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]}),this.emit("reset"))}selectFeaturesById(e){const{view:t}=this;if(!t||!this.utilityNetwork)return;const r=this.utilityNetwork.getObjectIdsFromElements(e);this._getUniqueMapLayerViews(t).forEach(e=>{M(e)&&e.layer?.parsedUrl?.path===r[0].layerUrl&&D(e)&&this._highlightHandler.push(e.highlight(r[0].objectIds))})}selectResults(e){if(e.length>0){this.removeSelection();const t=this.groupResultsByNetworkSource(e),r=[];for(const e in t)this.selectFeaturesById(t[e]),r.push(this.queryFeaturesById(t[e]));Promise.all(r).then(e=>{this.emit("select-features",{resultSet:e})})}else this.removeSelection(),this.emit("clear-selection",{resultSet:[]})}selectTraces(e,t){const r=[...this.traces];r.forEach(r=>{t===r.globalId&&(r.selected=e)}),this.traces=r}selectTracesOnLoad(){this.utilityNetwork?.hasOwnProperty("sharedNamedTraceConfigurations")&&(this.traces=[...this.utilityNetwork.sharedNamedTraceConfigurations],this.traces.forEach(e=>{e.selected=!1,this.selectedTraces.includes(e.globalId)&&(e.selected=!0)}))}zoomToAsset(e){this.view?.goTo(e).catch(e=>console.error(e))}async _createResultAreaInputGeometry(e){if(null!=e.aggregatedGeometry)return this._geometryHandler.mergeAggregatedToGeometries(e.aggregatedGeometry);const t=this.groupResultsByNetworkSource(e.elements),r=[];for(const s in t)r.push(this.queryFeaturesById(t[s]));try{const e=await Promise.all(r),t=[];for(const r of e)if(r)for(const e of r)for(const r of e.featureSet.features)r.geometry&&t.push(r.geometry);return t}catch{return[]}}_loadUNSupportItems(){if(!this.utilityNetwork)return;const{map:e}=this.view,{messages:t}=this;this._populateOutfields(),this._createGraphicLayer(E),this._createGraphicLayer(V),this._createGraphicLayer(C),this._resultAreaHandler?.createGraphicLayer(e,t?.alertsStrings.genericResultHeader),this._validUNLayers=this._utilityHelper.getValidUtilityNetworkLayers(e,this.utilityNetwork),this._sketchViewModel=this.graphicHandler.initializeSketch(this.view,this._getGraphicLayer(E),this._validUNLayers)}_getUniqueMapLayerViews(e){const t=[],r=e.layerViews.filter(({layer:{type:e}})=>"feature"===e||"group"===e||"subtype-group"===e).toArray(),s=e=>{for(const r of e.layerViews)x(r)?s(r):t.push(r)};return r.forEach(e=>{switch(e.layer.type){case"group":x(e)&&s(e);break;case"subtype-group":t.push(e);break;default:t.some(t=>t.layer.id===e.layer.id)||t.push(e)}}),t}_processFlags(e){const t=[];return e.forEach(e=>{if(null!==e.selectedTerminals&&e.selectedTerminals.length>0)e.selectedTerminals.forEach(r=>{const s=new G({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:r,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(s)});else{const r=new G({globalId:e.globalId,percentAlong:e.percentAlong,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(r)}}),t}_getDisplayField(e){return b(e?.sourceLayer)?this._getDisplayFieldBySublayer(e):this._getDisplayFieldByFeatureLayer(e)}_getDisplayFieldBySublayer(e){let t="",r="";const s=e.sourceLayer;t=this._checkParentForData(s,"displayField");for(const i in e.attributes){const a=i.toLowerCase();a===t?.toLowerCase()?(r=e.attributes[i],"assetgroup"===a||"assettype"===a?r=this._checkSubtype(s,s.subtypeCode):(r=this._checkDomain(s.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,s)))):(r=this._checkDomain(s.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,s)))}return{field:t,value:r?.toString()??s.title}}_getDisplayFieldByFeatureLayer(e){const t=e.sourceLayer;let r=t.displayField,s="";for(const i in e.attributes){const a=i.toLowerCase();if(a===r?.toLowerCase())if(s=e.attributes[i],"assetgroup"===a||"assettype"===a){let a=e.attributes[t.typeIdField.toUpperCase()];a||(a=e.attributes[t.typeIdField.toLowerCase()]),r=t.typeIdField,s=this._checkSubtype(t,a),""===r&&(t.templates&&t.templates.length>0?(r=t.templates[0]?.name,s=t.templates[0]?.name):(r=t.displayField,s=e.attributes[i]))}else s=this._checkDomain(t.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,t));else s=this._checkDomain(t.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,t))}return{field:r,value:s?s.toString():""}}_checkSubtype(e,t){let r=t;if("subtype-sublayer"===e.type){const s=this._checkParentForData(e,"subtypes");s?.length>0&&s.forEach(e=>{e.code===t&&(r=e.name)})}else if(null!=e.types&&e.types.length>0){const s=e.types.filter(e=>e.id===t);s.length>0&&(r=s[0].name)}return r}_checkDomain(e,t,r){let s=r;const i=e.filter(e=>e.name.toLowerCase()===t.toLowerCase());if(i.length>0&&O(i[0].domain)&&i[0].domain?.codedValues){const e=i[0].domain.codedValues.filter(({code:e})=>e===r);e.length>0&&(s=e[0].name)}return s}_checkParentForData(e,t){return e.parent?.[t]??null}_defaultDisplayField(e,t){return e.trim()?e:t.templates&&t.templates?.length>0?t.templates[0].name:t.title}get _uniqueFlagId(){return this._flagId++}_groupBy(e,t){return e.reduce((e,r)=>((e[r[t]]=e[r[t]]||[]).push(r),e),{})}async _lookupFlagByHit(e){const t=[];let r={};const s=e.graphic?.geometry,i=this.view?.toScreen(s),a=await(this.view?.hitTest(i,{include:this._validUNLayers}));if(!a?.results.length)return[];const l=a?.results.find(e=>null!==e.layer),o=l,c=o.graphic.geometry?.type,u=l?.layer,h=u.globalIdField??"globalid",p=u.objectIdField??"objectid";if(h&&!!o.graphic.attributes[h])r=o.graphic.attributes;else{const e=await(this.view?.whenLayerView(u)),t=e.createQuery();t.outFields=["assetgroup","assettype","globalid","objectid"],t.where=`${p} = ${o.graphic.attributes[p]}`,await n(()=>!e?.updating&&!e?.dataUpdating);const s=await(e?.queryFeatures(t)),i=s?.features[0],a=i?.attributes;r=a}const d=this._getDisplayField(o.graphic),g=o.mapPoint;let y={};if("point"===c||"polygon"===c){if(this.utilityNetwork){const e=this.utilityNetwork.getTerminalConfiguration(o.graphic);y={terminalId:e?e.terminals[0].id||null:1,isFilterBarrier:!1,allTerminals:e??null,selectedTerminals:[e?e.terminals[0].id||null:1],percentAlong:null,displayValue:d,mapPoint:g}}}else if("polyline"===c){const t=o.graphic,r=t.layer,s=t.getObjectId(),i=r.createQuery();i.objectIds=[s];const a=await r.queryFeatures(i),l=a?.features[0],n=l?.geometry;await this._geometryHandler.loadProjector();const c=this._geometryHandler.getPercentageAlong(n,e.graphic?.geometry,n.spatialReference);if(c[0]<0)return[];y={terminalId:null,isFilterBarrier:!1,allTerminals:null,selectedTerminals:null,percentAlong:c,displayValue:d,mapPoint:g}}return o.graphic.attributes={...r,...y},t.push(o),t}_createFlagProperty(e,t,r){const s=new G;s.terminalId=e.attributes.terminalId,s.isFilterBarrier=e.attributes.isFilterBarrier,s.percentAlong=e.attributes.percentAlong,s.globalId=e.attributes.globalid||e.attributes.GLOBALID,s.type=t;const i=s;return i.details=e,i.mapGraphic=r,i.id=this._uniqueFlagId,i.allTerminals=e.attributes.allTerminals,i.selectedTerminals=e.attributes.selectedTerminals,i.displayValue=e.attributes.displayValue,i.mapPoint=e.attributes.mapPoint,i}_populateOutfields(){if(!this.view)return;const{map:e}=this.view,t=this.getValidSources(),r=e=>{"group"===e.type?e.layers.forEach(e=>{$(e)&&r(e)}):t.some(t=>t.layerId===e.layerId)&&e.fields.some(e=>"assetgroup"===e.name.toLowerCase())&&(e.outFields=["assetgroup","assettype","globalid","objectid"])};for(const s of e.layers)$(s)&&r(s)}_removeGraphic(e){this._getGraphicLayer(V)?.remove(e.mapGraphic)}_createGraphicLayer(e){const{map:t}=this.view;if(!t.findLayerById(e)){const t=new m({id:e,internal:!0,listMode:"hide",title:e});T(this.view,t)}}_getGraphicLayer(e){const{map:t}=this.view;if(t){const r=t.findLayerById(e);if(r&&q(r))return r}return null}};e([c()],Q.prototype,"_activeProgress",void 0),e([c()],Q.prototype,"_flags",void 0),e([c()],Q.prototype,"traces",void 0),e([c()],Q.prototype,"defaultGraphicColor",void 0),e([c()],Q.prototype,"enableResultArea",void 0),e([c()],Q.prototype,"flags",void 0),e([c()],Q.prototype,"messages",void 0),e([c()],Q.prototype,"messagesUnits",void 0),e([c()],Q.prototype,"resultAreaProperties",null),e([c()],Q.prototype,"selectedTraces",void 0),e([c()],Q.prototype,"selectOnComplete",void 0),e([c()],Q.prototype,"showGraphicsOnComplete",void 0),e([c()],Q.prototype,"showSelectionAttributes",void 0),e([c({readOnly:!0})],Q.prototype,"state",null),e([c()],Q.prototype,"traceResults",void 0),e([c()],Q.prototype,"utilityNetwork",void 0),e([c({value:null})],Q.prototype,"view",null),Q=e([u("esri.widgets.UtilityNetworkTrace.UtilityNetworkTraceViewModel")],Q);const J=Q;export{J as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{id as t}from"../../kernel.js";import r from"../../core/Collection.js";import{deprecatedModule as s}from"../../core/deprecate.js";import i from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import l from"../../core/Logger.js";import{whenOnce as o,once as n}from"../../core/reactiveUtils.js";import{property as c,subclass as u}from"../../core/accessorSupport/decorators.js";import{ensureArray as h}from"../../core/accessorSupport/ensureType.js";import{isPoint as p,isMultipoint as d}from"../../geometry/support/jsonTypeUtils.js";import{fetchMessageBundle as g}from"../../intl/messages.js";import y from"../../layers/FeatureLayer.js";import m from"../../layers/GraphicsLayer.js";import f from"../../layers/support/CodedValueDomain.js";import{isFeatureLayer as w,isSubtypeSublayer as b,getOwningPortalUrl as _}from"../../layers/support/layerUtils.js";import A from"../../networks/UtilityNetwork.js";import{getFeaturesFromLayers as v}from"../../networks/support/utils.js";import k from"../../portal/Portal.js";import{hasUserTypeExtension as I}from"../../portal/support/utils.js";import{trace as F}from"../../rest/networks/trace.js";import G from"../../rest/networks/support/TraceLocation.js";import R from"../../rest/networks/support/TraceParameters.js";import{addUniqueLayer as T}from"../../views/draw/support/layerUtils.js";import{GeometryHandler as L}from"./support/GeometryHandler.js";import{GraphicHandler as H,barrierColor as N,startingPointColor as S}from"./support/GraphicHandler.js";import{ResultAreaHandler as P}from"./support/ResultAreaHandler.js";import{UtilityHelper as U}from"./support/UtilityHelper.js";const B=()=>g("esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace"),j=()=>g("esri/core/t9n/Units"),V=`utility-network-trace-flags-${Date.now()}`,C=`utility-network-trace-results-${Date.now()}`,E=`utility-network-trace-sketch-${Date.now()}`;function O(e){return e instanceof f}function D(e){return"feature"===e.layer.type||"subtype-group"===e.layer.type}function M(e){return"layer"in e}function x(e){return void 0!==e.layerViews}function q(e){return"graphics"===e.type}function $(e){return"feature"===e.type||"subtype-group"===e.type||"group"===e.type}async function z(e){const t=new y({url:e.networkSystemLayers.dirtyAreasLayerUrl});await t.load();const r=t.version;if(Number(r)<=11.1){const t=await _(e.layerUrl),r=new k({url:t});await r.load();const s=r?.user?.username;return!!s&&I(r,s,"utilityNetwork")}return!0}s(l.getLogger("esri.widgets.UtilityNetworkTrace.UtilityNetworkTraceViewModel"),"UtilityNetworkTraceViewModel",{replacement:"Use esri/networks/UtilityNetworkTraceAnalysis instead",version:"5.0",warnOnce:!0});let Q=class extends a{constructor(e){super(e),this._activeProgress=!1,this._clickHandler=null,this._flags=[],this._flagId=0,this._geometryHandler=null,this._highlightHandler=[],this._resultAreaHandler=null,this._sketchViewModel=null,this._traceTimeout=6e5,this._utilityHelper=new U,this._validUNLayers=[],this._watchHandler=null,this.traces=[],this.graphicHandler=null,this.defaultGraphicColor={color:[255,255,0,.6],haloOpacity:.9,fillOpacity:.2,hex:"#FFFF00"},this.enableResultArea=!1,this.flags=[],this.messages=null,this.messagesUnits=null,this.defaultResultAreaProperties={type:"convexhull",distance:10,unit:"meters",areaUnit:"square-meters",color:{color:[255,165,0,.5],haloOpacity:.9,fillOpacity:.2,hex:"#ffa500"},show:!1},this.selectedTraces=[],this.selectOnComplete=!0,this.showGraphicsOnComplete=!0,this.showSelectionAttributes=!0,this.traceResults=[],this.utilityNetwork=null}initialize(){this._geometryHandler=new L,this.graphicHandler=new H,this._resultAreaHandler=new P;(async()=>{const[e,t]=await Promise.all([B(),j()]);this.set({messages:e,messagesUnits:t})})()}destroy(){this.view=null}get resultAreaProperties(){return this.defaultResultAreaProperties}set resultAreaProperties(e){this._set("resultAreaProperties",{...this.defaultResultAreaProperties,...e}),this.graphicHandler.addCustomColor(this.resultAreaProperties.color),this.traceResults.forEach(t=>{const r=t.resultArea?.show;t.resultArea={...this.defaultResultAreaProperties,...e},this.removeResultAreaFromMap(t),this.enableResultArea&&this.createResultAreaGraphic(t).then(s=>{if(s){t.resultAreaGraphic=s;const i=e?.show??r;t.resultArea&&(t.resultArea.show=i),i&&this.addResultAreaToMap(t,s)}})})}get state(){return this.view?.ready?"ready":"loading"}get view(){return this._get("view")}set view(e){e&&"2d"!==e.type&&l.getLogger(this).error(new i("view:invalid-view","SceneView is not supported",{view:e})),this._set("view",e),this.utilityNetwork&&this.reset(),this.utilityNetwork=null,this.loadUtilityNetwork().then(e=>{e&&this.selectTracesOnLoad()})}addFlagByHit(e,t){const r=!!this.view&&this.view.popupEnabled,s=e=>{this.view?.popup&&(this.view.popupEnabled=e)};return new Promise((i,a)=>{r&&s(!1),this._clickHandler?.remove(),this._clickHandler=this._sketchViewModel.on("create",l=>{if("complete"===l.state){const o=this._getGraphicLayer(E);o&&l.graphic&&o.remove(l.graphic),this.queryFlagByHitTest(l,e,t).then(r=>{this.emit("add-flag-complete",{type:e,symbol:t}),i(r)}).catch(r=>{this.emit("add-flag-error",{type:e,symbol:t}),a(r)}).finally(()=>{r&&s(!0),this._clickHandler?.remove()})}}),this._sketchViewModel.create("point"),this.emit("add-flag",{type:e})})}addNonspatialTraceLocation(e,t){const r=this._getDisplayField(e),s=this.utilityNetwork?.getTerminalConfiguration(e),i={terminalId:null,isFilterBarrier:!1,allTerminals:s,selectedTerminals:[s?s.terminals[0].id||null:1],displayValue:r};e.attributes={...e.attributes,...i};const a=e.attributes.hasOwnProperty("GLOBALID")?e.attributes.GLOBALID:e.attributes.globalid;if(!this._flags.some(e=>e.globalId===a&&e.type===t)){const r=this._createFlagProperty(e,t,null);this._flags.push(r),this.emit("add-flag-complete",{type:t})}this.emit("add-flag",{type:t})}async addFlagsOnLoad(){if(this._flags.length>0)return[];await o(()=>null!=this.view&&!this.view.updating);return(await Promise.all(this.flags.map(async e=>{if(!e.mapPoint)return null;const{type:t}=e,r=e.mapPoint.clone(),s="barrier"===t?N:S,i={graphic:this.graphicHandler.makeGraphic(r,s),state:"complete",tool:"point",toolEventInfo:null,type:"create"};try{return await this.queryFlagByHitTest(i,e.type,null),this.emit("add-flag-complete",{type:t}),null}catch(a){return this.emit("add-flag-error",{type:t}),"barrier"===t?"barrier":"starting-point"}}))).filter(e=>!e)}async addResultAreaToMap(e,t){if(this.view)if(e.resultArea.show=!0,t)this._resultAreaHandler?.addResultAreaToMap(t,this.view.map),this.emit("add-result-area",{graphic:t});else if(e.results){const t=await this.createResultAreaGraphic(e);t&&(e.resultAreaGraphic=t,this._resultAreaHandler?.addResultAreaToMap(t,this.view.map),this.emit("add-result-area",{graphic:t}))}}async addResultGraphicToView(e,t){const{view:r}=this,{results:s}=e;if(r&&s&&this.utilityNetwork)for(const i in s.aggregatedGeometry)if("line,multipoint,polygon".includes(i)){const a=i,l=s.aggregatedGeometry[a];if(null!=l){l.spatialReference=this.utilityNetwork.spatialReference,e.graphicEnabled=!0;const s=await this._geometryHandler.projectGeometry(l,r.spatialReference),i={globalid:e.trace.globalId};if(null!==s){const e=this.graphicHandler.makeGraphic(s,t.color,i,r.spatialReference);this._getGraphicLayer(C)?.add(e)}}}}addTerminal(e,t){const r=[...this._flags];r.forEach(r=>{r.globalId===t.globalId&&(t.selectedTerminals?.includes(parseInt(e,10))||r.selectedTerminals?.push(parseInt(e,10)))}),this._flags=r}async callTrace(){const e=this.traces.filter(e=>e.selected);return!!e.length&&(this.traceResults.length>0&&this.traceResults.forEach(e=>{this.removeResultGraphicFromView(e)}),this.traceResults=[],this.removeSelection(),await Promise.all(e.map(async(e,t)=>{const r=e,s=new R({gdbVersion:this.utilityNetwork?.gdbVersion,moment:this.utilityNetwork?.historicMoment,namedTraceConfigurationGlobalId:r.globalId,outSpatialReference:null,resultTypes:null,traceType:r.traceType,traceLocations:h(G,this._flags),traceConfiguration:null});await this.executeTrace(r,this.utilityNetwork?.networkServiceUrl,s).then(async e=>{if(e.hasOwnProperty("results")){const r={...e};if(null!==r.results){r.resultArea={...this.resultAreaProperties};const e=[...r.results.elements];r.results.elements.length=0;const s=new Map;for(const t of e)s.has(t.globalId)||(s.set(t.globalId,!0),r.results.elements.push(t));const i=[...this.traceResults];if(i.splice(t,0,r),this.traceResults=i,null!==r.results&&(this.selectOnComplete&&this.mergeSelection(!0,r.trace),this.showGraphicsOnComplete&&await this.addResultGraphicToView(r,r.graphicColor),this.enableResultArea)){const e=await this.createResultAreaGraphic(r);e&&(r.resultAreaGraphic=e,r.resultArea?.show&&await this.addResultAreaToMap(r,r.resultAreaGraphic))}}else{const r=[...this.traceResults];r.splice(t,0,e),this.traceResults=r}this._activeProgress=!1}else{this._activeProgress=!1;const r=[...this.traceResults];r.splice(t,0,e),this.traceResults=r}}).catch(e=>{throw this._activeProgress=!1,e})})),!0)}cancelAddFlagByHit(){this._sketchViewModel.cancel()}changeResultAreaColor(e,t){if(!e.resultArea)return;e.resultArea.color=t;const r=this._resultAreaHandler?.changeResultAreaColor(e.trace.globalId,t,this.view.map);e.resultAreaGraphic&&(e.resultAreaGraphic.symbol=r)}changeResultGraphicColor(e,t){const r=[...this.traceResults];r.length>0&&r.forEach(r=>{r.trace.globalId===t.trace.globalId&&(r.graphicColor=e,r.graphicEnabled=!0)}),this.traceResults=r,this.removeResultGraphicFromView(t),this.addResultGraphicToView(t,e)}changeFlagSymbol(e,t){this._flags.length>0&&this._flags.forEach(r=>{r.type===e&&t&&r.mapGraphic&&(r.mapGraphic.symbol=t)})}checkCanTrace(){const e={status:!0,issues:[]},t=this.traces.filter(e=>e.selected);t.length||(e.status=!1,e.issues.push("noTracesSelected"));this._flags.some(e=>"starting-point"===e.type)||(e.status=!1,e.issues.push("noStartingPoints"));return this._flags.filter(e=>null!==e.allTerminals).some(e=>!e.selectedTerminals.length)&&(e.status=!1,e.issues.push("noTerminalSelected")),e}checkSelectionExist(){return this._highlightHandler.some(e=>e)}clearResult(e){if(!this.view)return;let t=this.traceResults;if(t.length>0){const r=t.filter(t=>t.trace.globalId===e.globalId);r.length>0&&(this.removeResultGraphicFromView(r[0]),this.removeResultAreaFromMap(r[0])),t=t.filter(t=>t.trace.globalId!==e.globalId)}this.traceResults=t,0===t.length?(this.removeAllResultAreaGraphics(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]})):this.mergeSelection(!1,e)}createResultAreaGeometries(e,t,r){if(!this.view||!this.resultAreaProperties)return;let s;if(s="convexhull"===this.resultAreaProperties?.type?1===t.length&&(p(t[0])||d(t[0])&&1===t[0].points.length)?this._resultAreaHandler?.createBuffer(t,r,e.resultArea?.unit,!0):this._resultAreaHandler?.createConvexHull(t,e.resultArea?.distance,e.resultArea?.unit):this._resultAreaHandler?.createBuffer(t,r,e.resultArea?.unit,!0),!s)return;if(Array.isArray(s)){for(const t of s){const r=this.getResultAreaAttributes(e,t),s=this._resultAreaHandler?.createResultAreaGraphic(t,r,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color);if(s)return s}return}const i=this.getResultAreaAttributes(e,s);return this._resultAreaHandler?.createResultAreaGraphic(s,i,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color)}async createResultAreaGraphic(e){if(e.results){const t=await this._createResultAreaInputGeometry(e.results);if(t.length>0){const r=Array(t.length).fill(e.resultArea?.distance),s=this.createResultAreaGeometries(e,t,r);return this.emit("create-result-area",{graphic:s}),s}}}executeTrace(e,t,r){const s=this._processFlags(r.traceLocations);return r.traceLocations=s,F(t,r,{timeout:this._traceTimeout}).then(t=>({trace:e,results:t,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:"success",date:new Date})).catch(t=>({trace:e,results:null,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:t.message,date:new Date}))}async getNonspatialTraceLocationInitialFeature(){return new Promise((e,t)=>{this._clickHandler?.remove(),this._clickHandler=this._sketchViewModel.on("create",async r=>{if("complete"!==r.state)return;const s=this._getGraphicLayer(E);s&&r.graphic&&s.remove(r.graphic);const i=this.view?.toScreen(r.graphic?.geometry);if(!i)return;const a=await(this.view?.hitTest(i));if(a?.results.length){const r=a.results.find(e=>"graphic"===e.type&&this.utilityNetwork?.isUtilityLayer(e.layer));r?e(r):t(null)}}),this._sketchViewModel.create("point")})}getResultAreaAttributes(e,r){const{messages:s}=this,i=[],a=[];this._flags.forEach(e=>{const t=e.displayValue?.field+":"+e.displayValue?.value+";"+s.attributeStrings.globalid+":"+e.globalId+";"+s.attributeStrings.terminalid+":"+e.terminalId+";"+s.attributeStrings.x+":"+e.mapPoint?.x+";"+s.attributeStrings.y+":"+e.mapPoint?.y;"starting-point"===e.type?i.push(t):a.push(t)});const l=this.utilityNetwork?.gdbVersion;return{traceId:e.trace.globalId,traceName:e.trace.title,traceDescription:e.trace.description??"",startingPoints:i.toString(),barriers:a.toString(),version:l??void 0,username:t?.credentials[0]?.userId,date:e.date,elementCount:e.results?.elements.length,functionResult:JSON.stringify(e.results?.globalFunctionResults),areaStatistic:r?this._geometryHandler.calculateArea(r,e.resultArea?.areaUnit):0}}getValidSources(){let e=[];const t=this.utilityNetwork?.dataElement?.domainNetworks??[];for(const r of t)e=e.concat(r.junctionSources),e=e.concat(r.edgeSources);return e}groupResultsByNetworkSource(e){return 0===e.length?[]:this._groupBy(e,"networkSourceId")}async loadUtilityNetwork(){const{view:e}=this;if(!e)return null;if(await e.when(),this.utilityNetwork){if(this.utilityNetwork.loaded||await this.utilityNetwork.load(),this.utilityNetwork instanceof A){try{const t=e.map;await t.loadAll()}catch(s){if("layer:unsupported-layer-type"!==s.name&&"subtype-grouplayer:missing-subtypes"!==s.name)throw s;console.error(s)}finally{this._loadUNSupportItems()}return this.utilityNetwork}return null}const t=e.map,r=t.utilityNetworks?.at(0);if(r){if(await r.load(),this.utilityNetwork=r,!await z(r))throw new i("utility-network:no-user-type-extension","User type extension not found");try{await t.loadAll()}catch(s){if("layer:unsupported-layer-type"!==s.name&&"subtype-grouplayer:missing-subtypes"!==s.name)throw s;console.error(s)}finally{this._loadUNSupportItems()}return r}return null}manageFilterBarrier(e,t){const r=[...this._flags];r.forEach(r=>{r.globalId===t.globalId&&"barrier"===t.type&&r.id===t.id&&(r.isFilterBarrier=e)}),this._flags=r}mergeSelection(e,t){let r=[];const s=[...this.traceResults],i=t.globalId;s.forEach(t=>{i===t.trace.globalId&&(t.selectionEnabled=e),t.selectionEnabled&&null!==t.results?.elements&&(r=[...r,...t.results?.elements??[]])}),this.selectResults([...new Set(r)])}async queryFeaturesById(e){const{view:t}=this;if(!t||!this.utilityNetwork)return null;const s=this.utilityNetwork.getObjectIdsFromElements(e),i={layerUrl:s[0].layerUrl,objectIds:s[0].objectIds,outFields:["*"]},a=t.map?.allTables.toArray().filter(e=>e?.parsedUrl?.path===s[0].layerUrl).filter(w)??[];this._getUniqueMapLayerViews(t).filter(({layer:e})=>e?.parsedUrl?.path===s[0].layerUrl).forEach(({layer:e})=>{"feature"!==e.type&&"subtype-group"!==e.type||a.push(e)});const l=(await Promise.all(a.map(async e=>{const s={layers:new r([e]),layerInfos:[i],returnGeometry:!0,outSpatialReference:t.spatialReference},[a]=await v(s,!1);return a}))).filter(({featureSet:e})=>e.features.length>0);return l.length>0?l:null}queryFlagByHitTest(e,t,r){return this._lookupFlagByHit(e).then(e=>{const{view:s}=this;if(!s)return!1;if(e.length>0){const s=[...this._flags],i=r;return e.forEach(e=>{const r=e.graphic,a=r.attributes.hasOwnProperty("GLOBALID")?r.attributes.GLOBALID:r.attributes.globalid;if(s.filter(e=>e.globalId===a).length<=0){const e=this.graphicHandler.getFlagGraphic(r.attributes.mapPoint,t,r,i);this._getGraphicLayer(V)?.add(e);const a=this._createFlagProperty(r,t,e);s.push(a)}else if(null!==r.attributes.percentAlong){const e=this.graphicHandler.getFlagGraphic(r.attributes.mapPoint,t,r,i);this._getGraphicLayer(V)?.add(e);const a=this._createFlagProperty(r,t,e);s.push(a)}}),this._flags=s,!0}return!1})}removeResultGraphicFromView(e){const{view:t}=this;if(!t)return;const r=this._getGraphicLayer(C)?.graphics;e.graphicEnabled=!1;const s=r?.filter(t=>t.attributes[t.attributes.hasOwnProperty("GLOBALID")?"GLOBALID":"globalid"]===e.trace.globalId);s?.forEach(e=>{this._getGraphicLayer(C)?.remove(e)})}removeFlag(e){const t=this._flags.filter(t=>{if(t.id!==e.id)return t});this._removeGraphic(e),this._flags=t}removeAllResultAreaGraphics(){this._resultAreaHandler?.removeAllResultAreaGraphics(this.view.map)}removeResultAreaFromMap(e){if(e.resultArea){e.resultArea.show=!1;const t=this._resultAreaHandler?.removeResultArea(e.trace.globalId,this.view?.map);t&&this.emit("remove-result-area",{graphic:t})}}removeSelection(){this._highlightHandler.forEach(e=>{e&&e.remove()}),this._highlightHandler=[]}removeTerminal(e,t){const r=[...this._flags];r.forEach(r=>{if(r.globalId===t.globalId&&t.selectedTerminals?.includes(parseInt(e,10))){const s=t.selectedTerminals.indexOf(parseInt(e,10));r.selectedTerminals?.splice(s,1)}}),this._flags=r}removeFlagsOnLoadWatcher(){this._watchHandler&&null!==this._watchHandler&&this._watchHandler.remove()}removeClickHandler(){this._clickHandler&&(this._sketchViewModel.cancel(),this._clickHandler.remove())}reset(){this._flags=[],this.traceResults=[];const e=[...this.traces];e.forEach(e=>{e.selected=!1}),this.traces=e,this.view&&(this._getGraphicLayer(E)?.removeAll(),this._getGraphicLayer(V)?.removeAll(),this._getGraphicLayer(C)?.removeAll(),this.removeAllResultAreaGraphics(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]}),this.emit("reset"))}selectFeaturesById(e){const{view:t}=this;if(!t||!this.utilityNetwork)return;const r=this.utilityNetwork.getObjectIdsFromElements(e);this._getUniqueMapLayerViews(t).forEach(e=>{M(e)&&e.layer?.parsedUrl?.path===r[0].layerUrl&&D(e)&&this._highlightHandler.push(e.highlight(r[0].objectIds))})}selectResults(e){if(e.length>0){this.removeSelection();const t=this.groupResultsByNetworkSource(e),r=[];for(const e in t)this.selectFeaturesById(t[e]),r.push(this.queryFeaturesById(t[e]));Promise.all(r).then(e=>{this.emit("select-features",{resultSet:e})})}else this.removeSelection(),this.emit("clear-selection",{resultSet:[]})}selectTraces(e,t){const r=[...this.traces];r.forEach(r=>{t===r.globalId&&(r.selected=e)}),this.traces=r}selectTracesOnLoad(){this.utilityNetwork?.hasOwnProperty("sharedNamedTraceConfigurations")&&(this.traces=[...this.utilityNetwork.sharedNamedTraceConfigurations],this.traces.forEach(e=>{e.selected=!1,this.selectedTraces.includes(e.globalId)&&(e.selected=!0)}))}zoomToAsset(e){this.view?.goTo(e).catch(e=>console.error(e))}async _createResultAreaInputGeometry(e){if(null!=e.aggregatedGeometry)return this._geometryHandler.mergeAggregatedToGeometries(e.aggregatedGeometry);const t=this.groupResultsByNetworkSource(e.elements),r=[];for(const s in t)r.push(this.queryFeaturesById(t[s]));try{const e=await Promise.all(r),t=[];for(const r of e)if(r)for(const e of r)for(const r of e.featureSet.features)r.geometry&&t.push(r.geometry);return t}catch{return[]}}_loadUNSupportItems(){if(!this.utilityNetwork)return;const{map:e}=this.view,{messages:t}=this;this._populateOutfields(),this._createGraphicLayer(E),this._createGraphicLayer(V),this._createGraphicLayer(C),this._resultAreaHandler?.createGraphicLayer(e,t?.alertsStrings.genericResultHeader),this._validUNLayers=this._utilityHelper.getValidUtilityNetworkLayers(e,this.utilityNetwork),this._sketchViewModel=this.graphicHandler.initializeSketch(this.view,this._getGraphicLayer(E),this._validUNLayers)}_getUniqueMapLayerViews(e){const t=[],r=e.layerViews.filter(({layer:{type:e}})=>"feature"===e||"group"===e||"subtype-group"===e).toArray(),s=e=>{for(const r of e.layerViews)x(r)?s(r):t.push(r)};return r.forEach(e=>{switch(e.layer.type){case"group":x(e)&&s(e);break;case"subtype-group":t.push(e);break;default:t.some(t=>t.layer.id===e.layer.id)||t.push(e)}}),t}_processFlags(e){const t=[];return e.forEach(e=>{if(null!==e.selectedTerminals&&e.selectedTerminals.length>0)e.selectedTerminals.forEach(r=>{const s=new G({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:r,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(s)});else{const r=new G({globalId:e.globalId,percentAlong:e.percentAlong,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(r)}}),t}_getDisplayField(e){return b(e?.sourceLayer)?this._getDisplayFieldBySublayer(e):this._getDisplayFieldByFeatureLayer(e)}_getDisplayFieldBySublayer(e){let t="",r="";const s=e.sourceLayer;t=this._checkParentForData(s,"displayField");for(const i in e.attributes){const a=i.toLowerCase();a===t?.toLowerCase()?(r=e.attributes[i],"assetgroup"===a||"assettype"===a?r=this._checkSubtype(s,s.subtypeCode):(r=this._checkDomain(s.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,s)))):(r=this._checkDomain(s.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,s)))}return{field:t,value:r?.toString()??s.title}}_getDisplayFieldByFeatureLayer(e){const t=e.sourceLayer;let r=t.displayField,s="";for(const i in e.attributes){const a=i.toLowerCase();if(a===r?.toLowerCase())if(s=e.attributes[i],"assetgroup"===a||"assettype"===a){let a=e.attributes[t.typeIdField.toUpperCase()];a||(a=e.attributes[t.typeIdField.toLowerCase()]),r=t.typeIdField,s=this._checkSubtype(t,a),""===r&&(t.templates&&t.templates.length>0?(r=t.templates[0]?.name,s=t.templates[0]?.name):(r=t.displayField,s=e.attributes[i]))}else s=this._checkDomain(t.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,t));else s=this._checkDomain(t.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,t))}return{field:r,value:s?s.toString():""}}_checkSubtype(e,t){let r=t;if("subtype-sublayer"===e.type){const s=this._checkParentForData(e,"subtypes");s?.length>0&&s.forEach(e=>{e.code===t&&(r=e.name)})}else if(null!=e.types&&e.types.length>0){const s=e.types.filter(e=>e.id===t);s.length>0&&(r=s[0].name)}return r}_checkDomain(e,t,r){let s=r;const i=e.filter(e=>e.name.toLowerCase()===t.toLowerCase());if(i.length>0&&O(i[0].domain)&&i[0].domain?.codedValues){const e=i[0].domain.codedValues.filter(({code:e})=>e===r);e.length>0&&(s=e[0].name)}return s}_checkParentForData(e,t){return e.parent?.[t]??null}_defaultDisplayField(e,t){return e.trim()?e:t.templates&&t.templates?.length>0?t.templates[0].name:t.title}get _uniqueFlagId(){return this._flagId++}_groupBy(e,t){return e.reduce((e,r)=>((e[r[t]]=e[r[t]]||[]).push(r),e),{})}async _lookupFlagByHit(e){const t=[];let r={};const s=e.graphic?.geometry,i=this.view?.toScreen(s),a=await(this.view?.hitTest(i,{include:this._validUNLayers}));if(!a?.results.length)return[];const l=a?.results.find(e=>null!==e.layer),o=l,c=o.graphic.geometry?.type,u=l?.layer,h=u.globalIdField??"globalid",p=u.objectIdField??"objectid";if(h&&!!o.graphic.attributes[h])r=o.graphic.attributes;else{const e=await(this.view?.whenLayerView(u)),t=e.createQuery();t.outFields=["assetgroup","assettype","globalid","objectid"],t.where=`${p} = ${o.graphic.attributes[p]}`,await n(()=>!e?.updating&&!e?.dataUpdating);const s=await(e?.queryFeatures(t)),i=s?.features[0],a=i?.attributes;r=a}const d=this._getDisplayField(o.graphic),g=o.mapPoint;let y={};if("point"===c||"polygon"===c){if(this.utilityNetwork){const e=this.utilityNetwork.getTerminalConfiguration(o.graphic);y={terminalId:e?e.terminals[0].id||null:1,isFilterBarrier:!1,allTerminals:e??null,selectedTerminals:[e?e.terminals[0].id||null:1],percentAlong:null,displayValue:d,mapPoint:g}}}else if("polyline"===c){const t=o.graphic,r=t.layer,s=t.getObjectId(),i=r.createQuery();i.objectIds=[s];const a=await r.queryFeatures(i),l=a?.features[0],n=l?.geometry;await this._geometryHandler.loadProjector();const c=this._geometryHandler.getPercentageAlong(n,e.graphic?.geometry,n.spatialReference);if(c[0]<0)return[];y={terminalId:null,isFilterBarrier:!1,allTerminals:null,selectedTerminals:null,percentAlong:c,displayValue:d,mapPoint:g}}return o.graphic.attributes={...r,...y},t.push(o),t}_createFlagProperty(e,t,r){const s=new G;s.terminalId=e.attributes.terminalId,s.isFilterBarrier=e.attributes.isFilterBarrier,s.percentAlong=e.attributes.percentAlong,s.globalId=e.attributes.globalid||e.attributes.GLOBALID,s.type=t;const i=s;return i.details=e,i.mapGraphic=r,i.id=this._uniqueFlagId,i.allTerminals=e.attributes.allTerminals,i.selectedTerminals=e.attributes.selectedTerminals,i.displayValue=e.attributes.displayValue,i.mapPoint=e.attributes.mapPoint,i}_populateOutfields(){if(!this.view)return;const{map:e}=this.view,t=this.getValidSources(),r=e=>{"group"===e.type?e.layers.forEach(e=>{$(e)&&r(e)}):t.some(t=>t.layerId===e.layerId)&&e.fields.some(e=>"assetgroup"===e.name.toLowerCase())&&(e.outFields=["assetgroup","assettype","globalid","objectid"])};for(const s of e.layers)$(s)&&r(s)}_removeGraphic(e){this._getGraphicLayer(V)?.remove(e.mapGraphic)}_createGraphicLayer(e){const{map:t}=this.view;if(!t.findLayerById(e)){const t=new m({id:e,internal:!0,listMode:"hide",title:e});T(this.view,t)}}_getGraphicLayer(e){const{map:t}=this.view;if(t){const r=t.findLayerById(e);if(r&&q(r))return r}return null}};e([c()],Q.prototype,"_activeProgress",void 0),e([c()],Q.prototype,"_flags",void 0),e([c()],Q.prototype,"traces",void 0),e([c()],Q.prototype,"defaultGraphicColor",void 0),e([c()],Q.prototype,"enableResultArea",void 0),e([c()],Q.prototype,"flags",void 0),e([c()],Q.prototype,"messages",void 0),e([c()],Q.prototype,"messagesUnits",void 0),e([c()],Q.prototype,"resultAreaProperties",null),e([c()],Q.prototype,"selectedTraces",void 0),e([c()],Q.prototype,"selectOnComplete",void 0),e([c()],Q.prototype,"showGraphicsOnComplete",void 0),e([c()],Q.prototype,"showSelectionAttributes",void 0),e([c({readOnly:!0})],Q.prototype,"state",null),e([c()],Q.prototype,"traceResults",void 0),e([c()],Q.prototype,"utilityNetwork",void 0),e([c({value:null})],Q.prototype,"view",null),Q=e([u("esri.widgets.UtilityNetworkTrace.UtilityNetworkTraceViewModel")],Q);const J=Q;export{J as default};
|