@arcgis/core 4.32.0-next.20241219 → 4.32.0-next.20241221
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/WebLinkChart.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{0da2aaca3f0b4fe910e3.js → 015285436ca965f94e17.js} +1 -1
- package/assets/esri/core/workers/chunks/127c82cdb229434883b6.js +1 -0
- package/assets/esri/core/workers/chunks/16530347bd78dc6c2fcd.js +1 -0
- package/assets/esri/core/workers/chunks/{5119811063bfc97fb725.js → 1a713cc601c6fcd97d2f.js} +1 -1
- package/assets/esri/core/workers/chunks/{48f6eb3b63fec1d3312d.js → 2d908c115ea18e813b95.js} +1 -1
- package/assets/esri/core/workers/chunks/{11052103efe3d53a784e.js → 31d9f0a37a5d0a1c450b.js} +1 -1
- package/assets/esri/core/workers/chunks/{e7c3199813070ff30a3d.js → 3bb94da29dac3367ecc6.js} +1 -1
- package/assets/esri/core/workers/chunks/3ed7c8138231de3a3b96.js +1 -0
- package/assets/esri/core/workers/chunks/{9cc9bac6e02ab241e852.js → 4746b7afa90ea3641e60.js} +1 -1
- package/assets/esri/core/workers/chunks/{ce33d2b5f22a5c566661.js → 4b5dbdcad438cb2dd4bf.js} +1 -1
- package/assets/esri/core/workers/chunks/5a0eb9dfe668cf290462.js +1 -0
- package/assets/esri/core/workers/chunks/{ee1ddf56549bb169509c.js → 6332da54159d72a6ce66.js} +1 -1
- package/assets/esri/core/workers/chunks/648d7d8fa19a2e772c89.js +1 -0
- package/assets/esri/core/workers/chunks/66b411119b8ffb99b9dc.js +1 -0
- package/assets/esri/core/workers/chunks/69efc716991a407c3d23.js +1 -0
- package/assets/esri/core/workers/chunks/88c68881cbdf4e911832.js +1 -0
- package/assets/esri/core/workers/chunks/8e60de347b209a753c73.js +1 -0
- package/assets/esri/core/workers/chunks/{fb43c44a7d6b61f31e75.js → 94432e04de01ee7adc0e.js} +1 -1
- package/assets/esri/core/workers/chunks/{80ac74da0b0e45e74beb.js → 9a498f2c007f4d78d4dd.js} +1 -1
- package/assets/esri/core/workers/chunks/{770d233254419b741616.js → 9ad7d095e614e7e8d7f5.js} +1 -1
- package/assets/esri/core/workers/chunks/9dd167db3f2e68b71cea.js +1 -0
- package/assets/esri/core/workers/chunks/{b15894bff153e0793ef4.js → 9f495ad57cdbfa90c5b8.js} +1 -1
- package/assets/esri/core/workers/chunks/{d7b76bc7bff34abc2253.js → a0b3d70a1b0360084593.js} +1 -1
- package/assets/esri/core/workers/chunks/a90611cdc86190799560.js +1 -0
- package/assets/esri/core/workers/chunks/{e213f4a1c95a33f80cdc.js → aedff36d3fec86abb9fb.js} +1 -1
- package/assets/esri/core/workers/chunks/{194013d377e7dd00845f.js → b611f46835edcd6eefcc.js} +1 -1
- package/assets/esri/core/workers/chunks/{eddab4dc706e75c6637f.js → bff74200a0df0950cf08.js} +1 -1
- package/assets/esri/core/workers/chunks/{8f2ffb6944c9028d3bea.js → c08cb75c3eef6c45f604.js} +1 -1
- package/assets/esri/core/workers/chunks/c1c216b0aebe86311fae.js +1 -0
- package/assets/esri/core/workers/chunks/{f2b195d04414417682d4.js → cbf57abb537e86c1dd7f.js} +1 -1
- package/assets/esri/core/workers/chunks/dce55e7f76adecc055c3.js +1 -0
- package/assets/esri/core/workers/chunks/f2cdb7be3fd65f65c30b.js +1 -0
- package/assets/esri/core/workers/chunks/f9af0473878d960a02f2.js +1 -0
- package/assets/esri/core/workers/chunks/fa1c68f2ffcdff7986b6.js +1 -0
- package/assets/esri/core/workers/chunks/{0f1a7aeec18db5323365.js → fdd8a5eb07466541f1f9.js} +1 -1
- package/assets/esri/themes/base/widgets/_FeatureTable.scss +3 -3
- 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/OperatorProject.js +1 -1
- package/chunks/QuadraticBezier.js +1 -1
- package/form/elements/GroupElement.js +1 -1
- package/form/elements/UtilityNetworkAssociationsElement.d.ts +4 -0
- package/form/elements/{UtilityNetworkAssociationElement.js → UtilityNetworkAssociationsElement.js} +1 -1
- package/form/elements.js +1 -1
- package/form/support/formUtils.js +1 -1
- package/geometry/operators/affineTransformOperator.js +1 -1
- package/geometry/operators/alphaShapeOperator.js +1 -1
- package/geometry/operators/areaOperator.js +1 -1
- package/geometry/operators/autoCompleteOperator.js +1 -1
- package/geometry/operators/boundaryOperator.js +1 -1
- package/geometry/operators/bufferOperator.js +1 -1
- package/geometry/operators/centroidOperator.js +1 -1
- package/geometry/operators/clipOperator.js +1 -1
- package/geometry/operators/containsOperator.js +1 -1
- package/geometry/operators/convexHullOperator.js +1 -1
- package/geometry/operators/crossesOperator.js +1 -1
- package/geometry/operators/cutOperator.js +1 -1
- package/geometry/operators/densifyOperator.js +1 -1
- package/geometry/operators/differenceOperator.js +1 -1
- package/geometry/operators/disjointOperator.js +1 -1
- package/geometry/operators/distanceOperator.js +1 -1
- package/geometry/operators/equalsOperator.js +1 -1
- package/geometry/operators/extendOperator.js +1 -1
- package/geometry/operators/generalizeOperator.js +1 -1
- package/geometry/operators/geodesicBufferOperator.js +1 -1
- package/geometry/operators/geodesicProximityOperator.js +1 -1
- package/geometry/operators/geodeticAreaOperator.js +1 -1
- package/geometry/operators/geodeticDensifyOperator.js +1 -1
- package/geometry/operators/geodeticDistanceOperator.js +1 -1
- package/geometry/operators/geodeticLengthOperator.js +1 -1
- package/geometry/operators/graphicBufferOperator.js +1 -1
- package/geometry/operators/integrateOperator.js +1 -1
- package/geometry/operators/intersectionOperator.js +1 -1
- package/geometry/operators/intersectsOperator.js +1 -1
- package/geometry/operators/isNearOperator.js +1 -1
- package/geometry/operators/labelPointOperator.js +1 -1
- package/geometry/operators/lengthOperator.js +1 -1
- package/geometry/operators/linesToPolygonsOperator.js +1 -1
- package/geometry/operators/locateBetweenOperator.js +1 -1
- package/geometry/operators/minimumBoundingCircleOperator.js +1 -1
- package/geometry/operators/multiPartToSinglePartOperator.js +1 -1
- package/geometry/operators/offsetOperator.js +1 -1
- package/geometry/operators/overlapsOperator.js +1 -1
- package/geometry/operators/polygonOverlayOperator.js +1 -1
- package/geometry/operators/polygonSlicerOperator.js +1 -1
- package/geometry/operators/projectOperator.js +1 -1
- package/geometry/operators/proximityOperator.js +1 -1
- package/geometry/operators/relateOperator.js +1 -1
- package/geometry/operators/reshapeOperator.js +1 -1
- package/geometry/operators/simplifyOperator.js +1 -1
- package/geometry/operators/singlePartToMultiPartOperator.js +1 -1
- package/geometry/operators/symmetricDifferenceOperator.js +1 -1
- package/geometry/operators/touchesOperator.js +1 -1
- package/geometry/operators/unionOperator.js +1 -1
- package/geometry/operators/withinOperator.js +1 -1
- package/interfaces.d.ts +231 -71
- package/layers/LinkChartLayer.js +1 -1
- package/layers/graphics/OptimizedFeature.js +1 -1
- package/layers/graphics/sources/geojson/geojson.js +1 -1
- package/layers/knowledgeGraph/supportUtils.js +1 -1
- package/layers/support/Sublayer.js +1 -1
- package/layers/support/VideoElement.js +1 -1
- package/layers/support/domainUtils.js +1 -1
- package/layers/support/fieldUtils.js +1 -1
- package/linkChart/OrganicLayoutSettings.js +1 -1
- package/package.json +1 -1
- package/portal/schemas/definitions.js +1 -1
- package/rest/knowledgeGraphService.js +1 -1
- package/rest/query/operations/pbfOptimizedFeatureSet.js +1 -1
- package/rest/support/fileFormat.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/mesh/factories/ResourceProxy.js +1 -1
- package/views/2d/input/MapViewInputManager.js +1 -1
- package/views/2d/input/handlers/KeyRotate.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/features/FeatureContainer.js +1 -1
- package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
- package/views/2d/layers/features/Processor.js +1 -1
- package/views/2d/layers/features/processor/AProcessorStrategy.js +1 -1
- package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
- package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
- package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/2d/layers/features/sources/strategies/ALoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/ASourceChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +5 -0
- package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderJSON.js +1 -1
- package/views/2d/layers/support/DebouncedFeatureOverride.js +5 -0
- package/views/2d/layers/support/FeatureCommandQueue.js +1 -1
- package/views/3d/input/SceneInputManager.js +1 -1
- package/views/3d/input/handlers/KeyboardNavigation.js +1 -1
- package/views/3d/terrain/TileTexture.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/RenderSubmitSystem.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
- package/views/3d/webgl-engine/lib/TextureCompressionWorker.js +1 -1
- package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/layers/FeatureLayerView.js +1 -1
- package/views/support/TextureCompressionHelper.js +1 -1
- package/views/webgl/Texture.js +1 -1
- package/webscene/Slide.js +1 -1
- package/webscene/SlideLegend.d.ts +4 -0
- package/webscene/SlideLegend.js +5 -0
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/FeatureTable/FieldColumn.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/Features.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/DigitizationAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageOverlays.js +1 -1
- package/widgets/OrientedImageryViewer/digitizationUtils.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/Popup.js +1 -1
- package/widgets/Print/PrintViewModel.js +1 -1
- package/widgets/Print/TemplateOptions.js +1 -1
- package/widgets/Print.js +1 -1
- package/widgets/ShadowCast.js +1 -1
- package/widgets/support/forms/formUtils.js +1 -1
- package/assets/esri/core/workers/chunks/0e9bd990a8d0691fb9c8.js +0 -1
- package/assets/esri/core/workers/chunks/27933d6ffeebb5c13ab7.js +0 -1
- package/assets/esri/core/workers/chunks/3ef5002b21b1a5b97e11.js +0 -1
- package/assets/esri/core/workers/chunks/48266c87363e7dcaefb3.js +0 -1
- package/assets/esri/core/workers/chunks/5786b190ad3e2d933245.js +0 -1
- package/assets/esri/core/workers/chunks/668679baf519ada9ae28.js +0 -1
- package/assets/esri/core/workers/chunks/737f381f2cfeddb96d15.js +0 -1
- package/assets/esri/core/workers/chunks/84d26c6c805f5855ffd3.js +0 -1
- package/assets/esri/core/workers/chunks/8f2f2d497b875e2b4139.js +0 -1
- package/assets/esri/core/workers/chunks/a4c8b773283ea8f0e256.js +0 -1
- package/assets/esri/core/workers/chunks/a68068b3151a14c4a0ad.js +0 -1
- package/assets/esri/core/workers/chunks/ad99308fb9678cdce917.js +0 -1
- package/assets/esri/core/workers/chunks/cc427e8f1b17744b6ea4.js +0 -1
- package/assets/esri/core/workers/chunks/dd4bd96dfb7f9921b774.js +0 -1
- package/assets/esri/core/workers/chunks/e1a03231e24293e66418.js +0 -1
- package/assets/esri/core/workers/chunks/fce1158755f959730602.js +0 -1
- package/views/2d/layers/features/sources/strategies/chunks/OverrideChunk.js +0 -5
- package/views/3d/input/handlers/SingleKey.js +0 -5
- package/views/3d/input/handlers/SingleKeyResetHeading.js +0 -5
- package/views/3d/input/handlers/SingleKeyResetTilt.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import"../../symbols.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import r from"../../core/Logger.js";import{debounce as o,isAbortError as a}from"../../core/promiseUtils.js";import n from"../../core/ReactiveSet.js";import{watch as l,when as u,sync as h}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{initializeProjection as p,project as g}from"../../geometry/projection.js";import{getPointFromGeometry as m}from"../../geometry/support/geometryUtils.js";import{geographicToWebMercator as f}from"../../geometry/support/webMercatorUtils.js";import y from"../../layers/Layer.js";import{fallbackObjectIDAttribute as w}from"../../layers/LayerConstants.js";import{getDisplayedSymbol as F}from"../../symbols/support/symbolUtils.js";import{system as v}from"../../time/timeZoneUtils.js";import{highlightsSupported as _}from"../../views/support/layerViewUtils.js";import b from"../Feature/FeatureViewModel.js";import{ActionsCollection as C,zoomToFeature as P,zoomToClusteredFeatures as E,browseClusteredFeatures as M}from"../Popup/actions.js";import{triggerAction as j,isClusterFeature as A,removeClusteredFeaturesForBrowsing as L,displayClusterExtent as V,browseAggregateFeatures as I,getSelectedTarget as T}from"../Popup/actionUtils.js";import S from"../support/AnchorElementViewModel.js";import O from"../support/GoTo.js";import R from"../../symbols/SimpleFillSymbol.js";import x from"../../geometry/Point.js";const H="location-scale-handle",B=()=>[P.clone()],U=()=>[E.clone(),M.clone()];let G=null;function Z(e,t){return"building-scene"===e||"2d"===t&&("map-image"===e||"tile"===e||"imagery"===e||"imagery-tile"===e)}let z=class extends(O(S)){constructor(e){super(e),this._pendingPromises=new n,this._fetchFeaturesController=null,this._highlightSelectedFeaturePromise=null,this._highlightActiveFeaturePromise=null,this._selectedClusterFeature=null,this.actions=new C,this.activeFeature=null,this.autoCloseEnabled=!1,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureMenuTitle=null,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.selectedClusterBoundaryFeature=new t({symbol:new R({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=o((async e=>{const{spatialReference:t}=this,i=this.selectedFeature?.geometry?.type,s=this.location??e;if(i&&"mesh"!==i&&t&&s&&this.selectedFeature)if("point"!==i)try{const e=this.selectedFeature;let i=e.geometry;const r=this._getHighlightLayer(e),o=e.getObjectId();if(!r||!this.view)return;if(o){const e=this.view?.allLayerViews.find((e=>e.layer.uid===r.uid));if(!e||!("queryFeatures"in e))return;const s=e.createQuery();s.outSpatialReference=t,s.objectIds=[o],s.returnGeometry=!0;const{features:a}=await e.queryFeatures(s);i=a[0]?.geometry}if(!i||"mesh"===i.type)return;if(i=g(i,t),G||(G=await import("../../geometry/geometryEngineAsync.js")),!await G.intersects(i,s)){const t=(await G.nearestCoordinate(i,s)).coordinate??s;this.selectedFeature===e&&(this.location=t)}}catch(o){a(o)||r.getLogger(this).error(o)}else this.location=m(this.selectedFeature.geometry)??s}))}initialize(){this.addHandles([this.on("view-change",(()=>this._autoClose())),l((()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view]),(()=>this._highlightSelectedFeature())),l((()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view]),(()=>this._highlightActiveFeature())),l((()=>this.view?.animation?.state),(e=>this._animationStateChange(e))),l((()=>this.location),(e=>this._locationChange(e))),l((()=>this.selectedFeature),(e=>this._selectedFeatureChange(e))),l((()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage]),(()=>this._selectedFeatureIndexChange())),l((()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels]),(()=>this._setGraphicOnFeatureViewModels())),l((()=>this.featureViewModels),(()=>this._featureViewModelsChange())),this.on("trigger-action",(e=>j({event:e,viewModel:this,view:this.view}))),u((()=>!this.waitingForResult),(()=>this._waitingForResultChange()),h),l((()=>[this.features,this.map,this.spatialReference,this.timeZone]),(()=>this._updateFeatureVMs())),l((()=>this.view?.scale),(()=>this._viewScaleChange())),u((()=>!this.visible),(()=>this.browseClusterEnabled=!1)),l((()=>this.browseClusterEnabled),(e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing()))])}destroy(){this._cancelFetchingFeatures(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new C;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,a=r?i.concat(t):t,n=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=n?.actions,u=n?.overwriteActions?l:l?.concat(a)??a;return u?.filter(Boolean).forEach((t=>e.add(t))),e}get defaultActions(){const e=this._get("defaultActions")||new C;return e.removeAll(),e.addMany(A(this.selectedFeature)?U():B()),e}get featureCount(){return this.features.length}set features(e){const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1)}set location(e){let t=e;const i=this.spatialReference?.isWebMercator,s=e?.spatialReference?.isWGS84;s&&i&&(t=f(e)),this._set("location",t)}get map(){return this.view?.map??null}set map(e){this._override("map",e)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice()).forEach((e=>this._pendingPromises.add(e))),e.reduce(((e,t)=>e.finally((()=>t.then((e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)})).finally((()=>this._pendingPromises.delete(t))).catch((()=>{}))))),Promise.resolve())):this._set("promises",[])}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;e=isNaN(e)||e<-1||!t?-1:(e+t)%t,this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){const{view:e,map:t}=this;return e?e.ready?"ready":"disabled":t?"ready":"disabled"}get timeZone(){return this.view?.timeZone??v}set timeZone(e){this._overrideIfSome("timeZone",e)}get waitingForContents(){return this.featureViewModels.some((e=>e.waitingForContent))}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=T(this);return t&&e?this.callGoTo({target:{target:t,scale:e.scale}}):Promise.reject(new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeatures(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location);const s=["actionsMenuOpen","collapsed"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex++,this}previous(){return this.selectedFeatureIndex--,this}disableClusterBrowsing(){L(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?A(t)?(await V(this),await I(this)):r.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):r.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}handleViewClick(e){this._fetchFeaturesAndOpen(e)}_animationStateChange(e){this.zoomToLocation||(P.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(A(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i,view:s}=this;s&&i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>1?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>1?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null===i)return;const o=((i-1)*s+t)%t,a=o+s;r.slice(o,a).forEach(((t,i)=>{t&&(t.graphic??=e[o+i])}))}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:s}=this;if(!e||!s)return;if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),A(e))return;return e.symbol=await F(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}const r=e.sourceLayer?.type;if("map-image"!==r&&"imagery"!==r&&"imagery-tile"!==r||(e.symbol=await F(e)),!i&&t||!e.geometry){if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}else this.location=m(e.geometry)}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:s,spatialReference:r,map:o,timeZone:a,location:n}=this;if(A(e)||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const l=i.slice(),u=[];t.forEach(((t,i)=>{if(!t)return;let h=null;if(l.some(((e,i)=>(e&&e.graphic===t&&(h=e,l.splice(i,1)),!!h))),h)u[i]=h;else{const l=new b({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:r,graphic:t===e?t:null,location:n,map:o,view:s,timeZone:a});u[i]=l}})),l.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",u)}async _getScreenPoint(e,t){const{spatialReference:i,view:s}=this;if(!s)return null;await(s?.when());const r=e?.spatialReference;return r&&i?(await p(r,i,null,t),s.toScreen(e)):null}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:s}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:s}),{signal:s,event:i})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const s=new AbortController,{signal:r}=s;this._fetchFeaturesController=s;const o=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:r,event:i});return o.catch((()=>{})).then((()=>{this._fetchFeaturesController=null})),o}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e,{view:s}=this;this.removeHandles(H),this.addHandles([l((()=>this.view?.scale),(()=>this._debouncedLocationUpdate(t).catch((e=>{a(e)||r.getLogger(this).error(e)})))),u((()=>!this.visible),(()=>{this.removeHandles(H)}),{once:!0})],H);const{pendingFeatures:o}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});s?.popup&&"open"in s.popup&&s.popup.open({location:t??void 0,promises:o})}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t}_getHighlightTarget(e,t,i){if(Z(t.type,i))return e;const s=e.getObjectId();if(null!=s)return s;const r="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||w:null,o=e.attributes;return o&&r&&o[r]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightActiveFeature(){const e="highlight-active-feature";this.removeHandles(e);const{highlightEnabled:t,view:i,activeFeature:s,visible:r}=this;if(!(s&&i&&t&&r))return;const o=this._getHighlightLayer(s);if(!(o&&o instanceof y&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(i,o);this._highlightActiveFeaturePromise=a;const n=await a;if(!(n&&_(n)&&this._highlightActiveFeaturePromise===a&&this.activeFeature&&this.highlightEnabled))return;const l=n.highlight(this._getHighlightTarget(s,o,i.type));this.addHandles(l,e)}async _highlightSelectedFeature(){const e="highlight-selected-feature";this.removeHandles(e);const{selectedFeature:t,highlightEnabled:i,view:s,visible:r}=this;if(!(t&&s&&i&&r))return;const o=this._getHighlightLayer(t);if(!(o&&o instanceof y&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(s,o);this._highlightSelectedFeaturePromise=a;const n=await a;if(!(n&&_(n)&&this._highlightSelectedFeaturePromise===a&&this.selectedFeature&&this.highlightEnabled&&this.visible))return;const l=n.highlight(this._getHighlightTarget(t,o,s.type));this.addHandles(l,e)}_updateFeatures(e){const{features:t}=this,i=e.filter((e=>!t.includes(e)));i?.length&&(this.features=t.concat(i))}};e([c()],z.prototype,"_fetchFeaturesController",void 0),e([c({type:C})],z.prototype,"actions",void 0),e([c({readOnly:!0})],z.prototype,"active",null),e([c()],z.prototype,"activeFeature",void 0),e([c({readOnly:!0})],z.prototype,"allActions",null),e([c()],z.prototype,"autoCloseEnabled",void 0),e([c()],z.prototype,"browseClusterEnabled",void 0),e([c()],z.prototype,"content",void 0),e([c({type:C,readOnly:!0})],z.prototype,"defaultActions",null),e([c({type:Boolean})],z.prototype,"defaultPopupTemplateEnabled",void 0),e([c({readOnly:!0})],z.prototype,"featureCount",null),e([c()],z.prototype,"featurePage",void 0),e([c({value:[]})],z.prototype,"features",null),e([c()],z.prototype,"featuresPerPage",void 0),e([c()],z.prototype,"featureMenuOpen",void 0),e([c()],z.prototype,"featureMenuTitle",void 0),e([c()],z.prototype,"featureViewModelAbilities",void 0),e([c({readOnly:!0})],z.prototype,"featureViewModels",void 0),e([c()],z.prototype,"highlightEnabled",void 0),e([c()],z.prototype,"includeDefaultActions",void 0),e([c({type:x})],z.prototype,"location",null),e([c()],z.prototype,"map",null),e([c({readOnly:!0})],z.prototype,"pendingPromisesCount",null),e([c({readOnly:!0})],z.prototype,"promiseCount",null),e([c()],z.prototype,"promises",null),e([c({readOnly:!0})],z.prototype,"selectedClusterBoundaryFeature",void 0),e([c({value:null,readOnly:!0})],z.prototype,"selectedFeature",null),e([c({value:-1})],z.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],z.prototype,"selectedFeatureViewModel",null),e([c({readOnly:!0})],z.prototype,"state",null),e([c()],z.prototype,"timeZone",null),e([c()],z.prototype,"title",void 0),e([c()],z.prototype,"updateLocationEnabled",void 0),e([c()],z.prototype,"view",void 0),e([c()],z.prototype,"visible",void 0),e([c({readOnly:!0})],z.prototype,"waitingForContents",null),e([c({readOnly:!0})],z.prototype,"waitingForResult",null),e([c()],z.prototype,"zoomFactor",void 0),e([c()],z.prototype,"zoomToLocation",void 0),e([c()],z.prototype,"centerAtLocation",null),z=e([d("esri.widgets.Features.FeaturesViewModel")],z);const W=z;export{W as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import"../../symbols.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import r from"../../core/Logger.js";import{debounce as o,isAbortError as a}from"../../core/promiseUtils.js";import n from"../../core/ReactiveSet.js";import{watch as l,when as u,sync as h}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{initializeProjection as p,project as g}from"../../geometry/projection.js";import{getPointFromGeometry as m}from"../../geometry/support/geometryUtils.js";import{geographicToWebMercator as f}from"../../geometry/support/webMercatorUtils.js";import y from"../../layers/Layer.js";import{fallbackObjectIDAttribute as w}from"../../layers/LayerConstants.js";import{getDisplayedSymbol as F}from"../../symbols/support/symbolUtils.js";import{system as v}from"../../time/timeZoneUtils.js";import{highlightsSupported as _}from"../../views/support/layerViewUtils.js";import b from"../Feature/FeatureViewModel.js";import{ActionsCollection as C,zoomToFeature as P,zoomToClusteredFeatures as E,browseClusteredFeatures as M}from"../Popup/actions.js";import{triggerAction as j,isClusterFeature as A,removeClusteredFeaturesForBrowsing as L,displayClusterExtent as V,browseAggregateFeatures as I,getSelectedTarget as T}from"../Popup/actionUtils.js";import S from"../support/AnchorElementViewModel.js";import O from"../support/GoTo.js";import R from"../../symbols/SimpleFillSymbol.js";import x from"../../geometry/Point.js";const H="location-scale-handle",B=()=>[P.clone()],U=()=>[E.clone(),M.clone()];let G=null;function Z(e,t){return"building-scene"===e||"2d"===t&&("map-image"===e||"tile"===e||"imagery"===e||"imagery-tile"===e)}let z=class extends(O(S)){constructor(e){super(e),this._pendingPromises=new n,this._fetchFeaturesController=null,this._highlightSelectedFeaturePromise=null,this._highlightActiveFeaturePromise=null,this._selectedClusterFeature=null,this.actions=new C,this.activeFeature=null,this.autoCloseEnabled=!1,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureMenuTitle=null,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.selectedClusterBoundaryFeature=new t({symbol:new R({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=o((async e=>{const{spatialReference:t}=this,i=this.selectedFeature?.geometry?.type,s=this.location??e;if(i&&"mesh"!==i&&t&&s&&this.selectedFeature)if("point"!==i)try{const e=this.selectedFeature;let i=e.geometry;const r=this._getHighlightLayer(e),o=e.getObjectId();if(!r||!this.view)return;if(o){const e=this.view?.allLayerViews.find((e=>e.layer.uid===r.uid));if(!e||!("queryFeatures"in e))return;const s=e.createQuery();s.outSpatialReference=t,s.objectIds=[o],s.returnGeometry=!0;const{features:a}=await e.queryFeatures(s);i=a[0]?.geometry}if(!i||"mesh"===i.type)return;if(i=g(i,t),G||(G=await import("../../geometry/geometryEngineAsync.js")),!await G.intersects(i,s)){const t=(await G.nearestCoordinate(i,s)).coordinate??s;this.selectedFeature===e&&(this.location=t)}}catch(o){a(o)||r.getLogger(this).error(o)}else this.location=m(this.selectedFeature.geometry)??s}))}initialize(){this.addHandles([this.on("view-change",(()=>this._autoClose())),l((()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view]),(()=>this._highlightSelectedFeature())),l((()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view]),(()=>this._highlightActiveFeature())),l((()=>this.view?.animation?.state),(e=>this._animationStateChange(e))),l((()=>this.location),(e=>this._locationChange(e))),l((()=>this.selectedFeature),(e=>this._selectedFeatureChange(e))),l((()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage]),(()=>this._selectedFeatureIndexChange())),l((()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels]),(()=>this._setGraphicOnFeatureViewModels())),l((()=>this.featureViewModels),(()=>this._featureViewModelsChange())),this.on("trigger-action",(e=>j({event:e,viewModel:this,view:this.view}))),u((()=>!this.waitingForResult),(()=>this._waitingForResultChange()),h),l((()=>[this.features,this.map,this.spatialReference,this.timeZone]),(()=>this._updateFeatureVMs())),l((()=>this.view?.scale),(()=>this._viewScaleChange())),u((()=>!this.visible),(()=>this.browseClusterEnabled=!1)),l((()=>this.browseClusterEnabled),(e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing()))])}destroy(){this._cancelFetchingFeatures(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new C;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,a=r?i.concat(t):t,n=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=n?.actions,u=n?.overwriteActions?l:l?.concat(a)??a;return u?.filter(Boolean).forEach((t=>e.add(t))),e}get defaultActions(){const e=this._get("defaultActions")||new C;return e.removeAll(),e.addMany(A(this.selectedFeature)?U():B()),e}get featureCount(){return this.features.length}set features(e){const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1)}set location(e){let t=e;const i=this.spatialReference?.isWebMercator,s=e?.spatialReference?.isWGS84;s&&i&&(t=f(e)),this._set("location",t)}get map(){return this.view?.map??null}set map(e){this._override("map",e)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice()).forEach((e=>this._pendingPromises.add(e))),e.reduce(((e,t)=>e.finally((()=>t.then((e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)})).finally((()=>this._pendingPromises.delete(t))).catch((()=>{}))))),Promise.resolve())):this._set("promises",[])}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;e=isNaN(e)||e<-1||!t?-1:(e+t)%t,this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){const{view:e,map:t}=this;return e?e.ready?"ready":"disabled":t?"ready":"disabled"}get timeZone(){return this.view?.timeZone??v}set timeZone(e){this._overrideIfSome("timeZone",e)}get waitingForContents(){return this.featureViewModels.some((e=>e.waitingForContent))}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=T(this);return t&&e?this.callGoTo({target:{target:t,scale:e.scale}}):Promise.reject(new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeatures(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location);const s=["actionsMenuOpen","collapsed"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex++,this}previous(){return this.selectedFeatureIndex--,this}disableClusterBrowsing(){L(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?A(t)?(await V(this),await I(this)):r.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):r.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}handleViewClick(e){this._fetchFeaturesAndOpen(e)}_animationStateChange(e){this.zoomToLocation||(P.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(A(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i,view:s}=this;s&&i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>1?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>1?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null===i)return;const o=((i-1)*s+t)%t,a=o+s;r.slice(o,a).forEach(((t,i)=>{t&&(t.graphic??=e[o+i])}))}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:s}=this;if(!e||!s)return;if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),A(e))return;return e.symbol=await F(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}const r=e.sourceLayer?.type;if("map-image"!==r&&"imagery"!==r&&"imagery-tile"!==r||(e.symbol=await F(e)),!i&&t||!e.geometry){if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}else this.location=m(e.geometry)}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:s,spatialReference:r,map:o,timeZone:a,location:n}=this;if(A(e)||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const l=i.slice(),u=[];t.forEach(((t,i)=>{if(!t)return;let h=null;if(l.some(((e,i)=>(e&&e.graphic===t&&(h=e,l.splice(i,1)),!!h))),h)u[i]=h;else{const l=new b({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:r,graphic:t===e?t:null,location:n,map:o,view:s,timeZone:a});u[i]=l}})),l.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",u)}async _getScreenPoint(e,t){const{spatialReference:i,view:s}=this;if(!s)return null;await(s?.when());const r=e?.spatialReference;return r&&i?(await p(r,i,null,t),s.toScreen(e)):null}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:s}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:s}),{signal:s,event:i})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const s=new AbortController,{signal:r}=s;this._fetchFeaturesController=s;const o=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:r,event:i});return o.catch((()=>{})).then((()=>{this._fetchFeaturesController=null})),o}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e,{view:s}=this;this.removeHandles(H),this.addHandles([l((()=>this.view?.scale),(()=>this._debouncedLocationUpdate(t).catch((e=>{a(e)||r.getLogger(this).error(e)})))),u((()=>!this.visible),(()=>{this.removeHandles(H)}),{once:!0})],H);const{pendingFeatures:o}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});s?.popup&&"open"in s.popup&&s.popup.open({location:t??void 0,promises:o})}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t}_getHighlightTarget(e,t,i){if(Z(t.type,i))return e;const s=e.getObjectId();if(null!=s)return s;const r="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||w:null,o=e.attributes;return o&&r&&o[r]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightActiveFeature(){const e="highlight-active-feature";this.removeHandles(e);const{highlightEnabled:t,view:i,activeFeature:s,visible:r}=this;if(!(s&&i&&t&&r))return;const o=this._getHighlightLayer(s);if(!(o&&o instanceof y&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(i,o);this._highlightActiveFeaturePromise=a;const n=await a;if(!(n&&_(n)&&this._highlightActiveFeaturePromise===a&&this.activeFeature&&this.highlightEnabled))return;const l=n.highlight(this._getHighlightTarget(s,o,i.type));this.addHandles(l,e)}async _highlightSelectedFeature(){const e="highlight-selected-feature";this.removeHandles(e);const{selectedFeature:t,highlightEnabled:i,view:s,visible:r}=this;if(!(t&&s&&i&&r))return;const o=this._getHighlightLayer(t);if(!(o&&o instanceof y&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(s,o);this._highlightSelectedFeaturePromise=a;const n=await a;if(!(n&&_(n)&&this._highlightSelectedFeaturePromise===a&&this.selectedFeature&&this.highlightEnabled&&this.visible))return;const l=n.highlight(this._getHighlightTarget(t,o,s.type));this.addHandles(l,e)}_updateFeatures(e){const{features:t}=this,i=e.filter((e=>!t.includes(e)));i?.length&&(this.features=t.concat(i))}};e([c()],z.prototype,"_fetchFeaturesController",void 0),e([c({type:C})],z.prototype,"actions",void 0),e([c({readOnly:!0})],z.prototype,"active",null),e([c()],z.prototype,"activeFeature",void 0),e([c({readOnly:!0})],z.prototype,"allActions",null),e([c()],z.prototype,"autoCloseEnabled",void 0),e([c()],z.prototype,"browseClusterEnabled",void 0),e([c()],z.prototype,"content",void 0),e([c({type:C,readOnly:!0})],z.prototype,"defaultActions",null),e([c({type:Boolean})],z.prototype,"defaultPopupTemplateEnabled",void 0),e([c({readOnly:!0})],z.prototype,"featureCount",null),e([c()],z.prototype,"featurePage",void 0),e([c({value:[]})],z.prototype,"features",null),e([c()],z.prototype,"featuresPerPage",void 0),e([c()],z.prototype,"featureMenuOpen",void 0),e([c()],z.prototype,"featureMenuTitle",void 0),e([c()],z.prototype,"featureViewModelAbilities",void 0),e([c({readOnly:!0})],z.prototype,"featureViewModels",void 0),e([c()],z.prototype,"highlightEnabled",void 0),e([c()],z.prototype,"includeDefaultActions",void 0),e([c({type:x})],z.prototype,"location",null),e([c()],z.prototype,"map",null),e([c({readOnly:!0})],z.prototype,"pendingPromisesCount",null),e([c({readOnly:!0})],z.prototype,"promiseCount",null),e([c()],z.prototype,"promises",null),e([c({readOnly:!0})],z.prototype,"selectedClusterBoundaryFeature",void 0),e([c({value:null,readOnly:!0})],z.prototype,"selectedFeature",null),e([c({value:-1})],z.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],z.prototype,"selectedFeatureViewModel",null),e([c()],z.prototype,"spatialReference",null),e([c({readOnly:!0})],z.prototype,"state",null),e([c()],z.prototype,"timeZone",null),e([c()],z.prototype,"title",void 0),e([c()],z.prototype,"updateLocationEnabled",void 0),e([c()],z.prototype,"view",void 0),e([c()],z.prototype,"visible",void 0),e([c({readOnly:!0})],z.prototype,"waitingForContents",null),e([c({readOnly:!0})],z.prototype,"waitingForResult",null),e([c()],z.prototype,"zoomFactor",void 0),e([c()],z.prototype,"zoomToLocation",void 0),e([c()],z.prototype,"centerAtLocation",null),z=e([d("esri.widgets.Features.FeaturesViewModel")],z);const W=z;export{W as default};
|
package/widgets/Features.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import i from"../core/Logger.js";import{ignoreAbortErrors as o}from"../core/promiseUtils.js";import{watch as s,when as n}from"../core/reactiveUtils.js";import{waitAnimationFrame as r}from"../core/scheduling.js";import{throttle as l}from"../core/throttle.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import{getPointFromGeometry as c}from"../geometry/support/geometryUtils.js";import{substituteActionImage as u,getActionStyles as h}from"../support/actions/actionUtils.js";import p from"./Feature.js";import m from"./Spinner.js";import v from"./Widget.js";import{css as g}from"./Feature/resources.js";import{FeatureContentMixin as w}from"./Feature/support/FeatureContentMixin.js";import{css as _}from"./Features/css.js";import f from"./Features/FeaturesDrillIn.js";import M from"./Features/FeaturesViewModel.js";import F from"./Features/FeaturesVisibleElements.js";import{ActionsCollection as b}from"./Popup/actions.js";import{zoomToLocation as y}from"./Popup/actionUtils.js";import{loadCalciteComponents as I}from"./support/componentsUtils.js";import{globalCss as C}from"./support/globalCss.js";import{Heading as A}from"./support/Heading.js";import{setFocus as x}from"./support/widgetUtils.js";import{messageBundle as N}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as O}from"./support/jsxFactory.js";import{substitute as k}from"../intl/substitute.js";import{formatNumber as E}from"../intl/number.js";const j="selected-index",L=0,W="features-spinner";function S(e){return e?.declaredClass.startsWith("esri.layers.")??!1}let B=class extends(w(v)){constructor(e,i){super(e,i),this._featureMenuIntersectionObserverCallback=([e])=>{e?.isIntersecting&&null!=this.viewModel.featurePage&&this.viewModel.featurePage++},this._featureMenuIntersectionObserver=new IntersectionObserver(this._featureMenuIntersectionObserverCallback,{root:window.document}),this._featureMenuIntersectionObserverNode=null,this._spinner=null,this._feature=null,this._focusAbortController=null,this._drillInFlowItems=new t,this._drillInWidget=new f({flowItems:this._drillInFlowItems}),this._rootFlowItemNode=null,this._featureMenuViewportNode=null,this._actionBarMenuNode=null,this.collapsed=!1,this.featureNavigationTop=!1,this.headerActions=new b,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.responsiveActionsEnabled=!1,this.viewModel=new M,this.visibleElements=new F,this._renderAction=(e,t)=>{const i=this._getActionTitle(e),{type:o,active:s,uid:n,disabled:r,indicator:l}=e;return e.visible?O("calcite-action",{active:"toggle"===o&&e.value,appearance:"solid",bind:this,"data-action-id":e.id,"data-action-uid":n,disabled:r,icon:this._getActionIcon(e),indicator:l,key:`action-${t}`,loading:s,onclick:this._triggerAction,scale:"s",text:i,textEnabled:!this._hideActionText,title:this._hideActionText?i:void 0},this._getFallbackIcon(e)):null},this._openFeatureMenu=()=>{this.featureMenuOpen=!0,this._focusFlowItemNode("menu-flow-item")},this._previousFeature=()=>{this.viewModel.selectedFeatureIndex--},this._nextFeature=()=>{this.viewModel.selectedFeatureIndex++},this._handleFeatureMenuBack=()=>{this.featureMenuOpen&&(this._focusFlowItemNode("root-flow-item"),this.featureMenuOpen=!1)},this._displaySpinnerThrottled=l((()=>this._displaySpinner()),L),this._addSelectedFeatureIndexHandle(),this.addHandles([this._displaySpinnerThrottled,s((()=>this.viewModel?.active),(()=>this._toggleScreenLocationEnabled())),s((()=>this.viewModel?.active),(e=>this._drillInWidget.closed=!e)),s((()=>this.visibleElements?.closeButton),(e=>this._drillInWidget.closable=e)),s((()=>this.visibleElements?.spinner),(e=>this._spinnerEnabledChange(e))),s((()=>this.viewModel?.view),((e,t)=>this._viewChange(e,t))),s((()=>this.viewModel?.view?.ready),((e,t)=>this._viewReadyChange(e??!1,t??!1))),s((()=>[this.viewModel?.waitingForResult,this.viewModel?.location]),(()=>{this._hideSpinner(),this._displaySpinnerThrottled()})),s((()=>this.viewModel?.screenLocation),(()=>this._closeOpenActionMenu())),s((()=>this.selectedFeatureWidget),(()=>this._destroyDrillInFlowItemWidgets())),s((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]}),(()=>this._setTitleFromFeatureWidget())),s((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]}),(()=>this._setContentFromFeatureWidget())),s((()=>this.viewModel?.featureViewModels),(()=>this._featureMenuViewportScrollTop())),this._drillInWidget.on("close",(()=>this.close())),this._drillInWidget.on("exit",(()=>this._destroyDrillInFlowItemWidgets())),this._drillInWidget.on("open-feature",(({feature:e})=>this._openRelatedFeature(e))),this._drillInWidget.on("zoom-to-feature",(({featureWidget:e})=>y(this.viewModel,e)))])}loadDependencies(){return I({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})}destroy(){this._destroyDrillInFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver?.disconnect(),this._drillInWidget?.destroy(),this._focusAbortController?.abort()}get _hideActionText(){if(!this.responsiveActionsEnabled)return!1;const e=this.view?.widthBreakpoint;return"xsmall"===e||"small"===e||"medium"===e}get _featureNavigationVisible(){return this.viewModel.active&&this.viewModel.featureCount>1&&this.visibleElements.featureNavigation}get _isCollapsed(){return this._collapseEnabled&&this.collapsed}get _collapseEnabled(){return this.visibleElements.collapseButton&&!!this.title&&!!this.content}get active(){return this.viewModel.active}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get icon(){return null}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get featureMenuTitle(){return this.viewModel.featureMenuTitle}set featureMenuTitle(e){this.viewModel.featureMenuTitle=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedDrillInFeature(){const e=Array.from(this._drillInFlowItems).at(-1);if(!e)return null;const{flowType:t}=e;return"feature-association"===t||"feature-relationship"===t?e.graphic??null:null}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_drillInFlowItems:i,timeZone:o,spatialReference:s,map:n}=this,{selectedFeatureViewModel:r}=this.viewModel,l={title:!1};return r?(e?(e.viewModel=r,e.visibleElements=l):this._feature=new p({flowItems:i,headingLevel:t+1,timeZone:o,spatialReference:s,map:n,viewModel:r,visibleElements:l}),this._feature):null}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e?this._rootFlowItemNode?.blur():i.getLogger(this).warn("Features can only be blurred when currently active.")}clear(){return this.viewModel.clear()}close(){this.viewModel.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e?this._focusFlowItemNode(this.featureMenuOpen?"menu-flow-item":"root-flow-item"):i.getLogger(this).warn("Features can only be focused when currently active.")}next(){return this.viewModel.next()}open(e){this.removeHandles(j);const t={collapsed:e?.collapsed??!1};this.set(t),this.viewModel.open(e),this.addHandles(n((()=>!this.viewModel.waitingForResult),(()=>this._addSelectedFeatureIndexHandle()),{once:!0}))}previous(){return this.viewModel.previous()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return O("div",{bind:this,class:this.classes(_.base,C.widget,C.panel),onkeydown:this._onMainKeydown},this._renderHeader(),this._renderContentContainer())}_renderFeatureNavigation(){return[this._renderPagination(),this._renderFeatureMenuButton()]}_renderHeader(){return!this.featureMenuOpen&&this.featureNavigationTop&&this._featureNavigationVisible?O("div",{class:_.header,key:"header-actions"},this._renderFeatureNavigation()):null}_renderFooter(){return this.featureMenuOpen||this.featureNavigationTop||!this._featureNavigationVisible?null:O("div",{class:_.footer,key:"footer-actions",slot:"footer"},this._renderFeatureNavigation())}_renderFeatureMenuButton(){const{messages:e,viewModel:t}=this,{featureCount:i,selectedFeatureIndex:o,pendingPromisesCount:s}=t;return O("calcite-action",{appearance:"solid",bind:this,icon:"list",key:"feature-menu-button",label:e.selectFeature,loading:s>0,onclick:this._openFeatureMenu,scale:"s",text:k(e.pageText,{index:E(o+1),total:E(i)}),textEnabled:!0,title:e.selectFeature})}_renderPagination(){const{previous:e,next:t}=this.messagesCommon.pagination;return O("calcite-action-bar",{class:_.paginationActionBar,expandDisabled:!0,key:"pagination-action-bar",layout:"horizontal",overflowActionsDisabled:!0,scale:"s"},O("calcite-action-group",{scale:"s"},O("calcite-action",{appearance:"solid",class:_.paginationPrevious,icon:"chevron-left",iconFlipRtl:!0,label:e,onclick:this._previousFeature,scale:"s",text:e,title:e}),O("calcite-action",{appearance:"solid",icon:"chevron-right",iconFlipRtl:!0,label:t,onclick:this._nextFeature,scale:"s",text:t,title:t})))}_renderFeatureMenuItem(e){const{selectedFeatureViewModel:t,featureViewModels:i}=this.viewModel,o=e===t,s=i.indexOf(e);return O("calcite-list-item",{bind:this,"data-feature-index":s,key:`feature-menu-item-${e.uid}`,onblur:this._removeActiveFeature,onfocus:this._setActiveFeature,onmouseleave:this._removeActiveFeature,onmouseover:this._setActiveFeature,selected:o,onCalciteListItemSelect:this._selectFeature},O("span",{innerHTML:e.title||this.messagesCommon.untitled,slot:"content"}))}_groupResultsByLayer(){const{featureViewModels:e}=this.viewModel,t=new Map;return e.forEach((e=>{const i=e?.graphic;if(!i)return;const{layer:o,sourceLayer:s}=i,n=(S(o)?o:null)||(S(s)?s:null),r=t.get(n)??[];t.set(n,[...r,e])})),t}_renderFeatureMenu(){const{messages:e,viewModel:t}=this,i=this._groupResultsByLayer();return t.featureViewModels.length?O("calcite-list",{displayMode:"flat",label:e?.featuresList,selectionAppearance:"icon",selectionMode:"single"},Array.from(i.keys(),(e=>{const t=i.get(e)?.map((e=>this._renderFeatureMenuItem(e))),o=e?e.title??this.messagesCommon.untitled:null;return this.visibleElements.featureListLayerTitle&&null!==o?O("calcite-list-item-group",{heading:o,key:e?.uid||"map-graphics"},t):t}))):null}_renderHeaderAction(e,t){const i=e.title||"";return e.visible?O("calcite-action",{active:"toggle"===e.type&&e.value,appearance:"solid",bind:this,"data-action-id":e.id,"data-action-uid":e.uid,disabled:e.disabled,icon:e.icon??void 0,indicator:e.indicator,key:`header-action-${t}`,loading:e.active,onclick:this._triggerHeaderAction,slot:"header-actions-end",text:i,title:i}):null}_renderHeaderActions(){return this.headerActions.map(((e,t)=>this._renderHeaderAction(e,t))).toArray()}_renderContentFeature(){const{headingLevel:e,visibleElements:t,_isCollapsed:i,_collapseEnabled:o,_drillInFlowItems:s,featureNavigationTop:n,featureMenuOpen:r}=this,{title:l,active:a}=this.viewModel,d=t.heading&&l?l:"";return O("calcite-flow-item",{afterCreate:this._storeRootFlowItemNode,bind:this,class:this.classes({[_.contentFeature]:!0,[_.flowItemCollapsed]:i}),closable:t.closeButton,closed:!a,collapsed:i,collapseDirection:n?"down":"up",collapsible:o,headingLevel:e,key:"root-flow-item",selected:!r&&0===s.length,onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},d?O(A,{class:this.classes(_.featuresHeading,C.heading),innerHTML:d,key:"header-content",level:this.headingLevel,slot:"header-content"}):null,this._renderHeaderActions(),this._renderActionBar(),i?null:O("div",{class:this.classes(_.container,_.contentContainer)},this._renderContent()),this._renderFooter())}_renderFeatureMenuContainer(){const{viewModel:e,featureMenuOpen:t,featureMenuTitle:i,messages:o,messagesCommon:s}=this,{active:n,featureViewModels:r,pendingPromisesCount:l}=e,a=i??o.selectFeature;return t?O("calcite-flow-item",{afterCreate:this._storeFeatureMenuFlowItemNode,bind:this,closable:!1,closed:!n,description:k(o.total,{total:r.length}),heading:a,key:"feature-menu",loading:e.waitingForContents,selected:t,onCalciteFlowItemBack:e=>{e.preventDefault(),this._handleFeatureMenuBack()}},l>0?O("calcite-loader",{class:_.loader,inline:!0,key:"feature-menu-loader",label:s.loading,slot:"header-actions-end"}):null,O("div",{class:_.container},this._renderFeatureMenu()),O("div",{afterCreate:this._featureMenuIntersectionObserverCreated,bind:this,class:_.featureMenuObserver}),O("calcite-button",{appearance:"transparent",onclick:this._handleFeatureMenuBack,slot:"footer-actions",width:"full"},s.back)):null}_renderContentContainer(){const e=[this._renderContentFeature(),this._renderFeatureMenuContainer(),this._drillInWidget.render()];return this.visibleElements.flow?O("calcite-flow",{key:"content-container"},e):e}_getFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o=u({action:e,feature:this.selectedFeature}),s={[_.icon]:!!t,[_.actionImage]:!!o};return t&&(s[t]=!0),o||t?O("span",{"aria-hidden":"true",class:this.classes(_.icon,s),key:"icon",styles:h(o)}):null}_renderActionBar(){return!this._isCollapsed&&this.visibleElements.actionBar&&this.viewModel.allActions?.length?O("calcite-action-bar",{expandDisabled:!0,expanded:!this._hideActionText,key:"header-action-bar",scale:"s",slot:"action-bar"},O("calcite-action-group",{afterCreate:e=>this._actionBarMenuNode=e,overlayPositioning:"fixed",scale:"s"},this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map(this._renderAction)}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?O("div",{class:g.contentNode,innerHTML:e,key:e}):this.renderNodeContent(e):null}_handleCollapseToggle(){this.collapsed=!this.collapsed}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;if(null==i||null==t)return;this._destroyDrillInFlowItemWidgets(),await this.viewModel.zoomTo({target:i});const o=c(i);this.open({features:[t],location:null!=o?o:void 0})}async _focusFlowItemNode(e){this._focusAbortController?.abort(),this._focusAbortController=new AbortController;const t=this._focusAbortController.signal;await o(r(t));const i="menu-flow-item"===e?this._featureMenuViewportNode:this._rootFlowItemNode;x(i)}_storeRootFlowItemNode(e){this._rootFlowItemNode=e}_storeFeatureMenuFlowItemNode(e){this._featureMenuViewportNode=e}_setActiveFeature(e){const{viewModel:t}=this,i=e.currentTarget["data-feature-index"];t.activeFeature=t.features?.[i]||null}_removeActiveFeature(){this.viewModel.activeFeature=null}_selectFeature(e){const t=e.currentTarget["data-feature-index"];isNaN(t)||(this.viewModel.selectedFeatureIndex=t),this._handleFeatureMenuBack()}_unobserveFeatureMenuObserver(){this._featureMenuIntersectionObserverNode&&this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode)}_featureMenuIntersectionObserverCreated(e){this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver.observe(e),this._featureMenuIntersectionObserverNode=e}_getActionIcon(e){return e.icon?e.icon:e.image||e.className?void 0:"question"}_getActionTitle(e){const{messages:t,selectedFeature:i,messagesCommon:o}=this,{id:s}=e,n=i?.attributes,r=e.title??"",l="zoom-to-feature"===s?k(r,{messages:t}):"remove-selected-feature"===s?k(r,{messages:o}):"zoom-to-clustered-features"===s||"browse-clustered-features"===s?k(r,{messages:t}):e.title;return l&&n?k(l,n):l??""}_onMainKeydown(e){const{key:t}=e;"ArrowLeft"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.previous()),"ArrowRight"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.next())}_featureMenuViewportScrollTop(){this._featureMenuViewportNode&&this._featureMenuViewportNode.scrollContentTo({top:0})}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_addSelectedFeatureIndexHandle(){const e=s((()=>this.viewModel?.selectedFeatureIndex),((e,t)=>this._selectedFeatureIndexUpdated(e,t)));this.addHandles(e,j)}_selectedFeatureIndexUpdated(e,t){const{featureCount:i}=this.viewModel;i&&e!==t&&-1!==e&&(this._destroyDrillInFlowItemWidgets(),this._rootFlowItemNode&&this._rootFlowItemNode.scrollContentTo({top:0}))}_triggerHeaderAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,o=this.headerActions.find((({uid:e})=>e===i));o&&!o.disabled&&("toggle"===o?.type&&(o.value=!o.value),this.emit("trigger-header-action",{action:o}))}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:o}=this.viewModel,s=o.findIndex((e=>e.uid===i)),n=o.at(s);n&&"toggle"===n.type&&(n.value=!n.value),this.viewModel.triggerAction(s)}_createSpinner(e){e&&(this._spinner=new m({view:e}),e.ui.add(this._spinner,{key:W,position:"manual",internal:!0}))}_wireUpView(e){this._destroySpinner(),e&&this.visibleElements?.spinner&&this._createSpinner(e)}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_closeOpenActionMenu(){const{_actionBarMenuNode:e}=this;e&&(e.menuOpen=!1)}_destroyDrillInFlowItemWidgets(){this._drillInFlowItems.drain((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}))}_toggleScreenLocationEnabled(){const{viewModel:e}=this;e&&(e.screenLocationEnabled=e.active)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_destroySpinner(){const{_spinner:e,view:t}=this;e&&(t?.ui?.remove(e,W),e.destroy(),this._spinner=null)}_spinnerEnabledChange(e){this._destroySpinner(),e&&this._createSpinner(this.viewModel?.view)}};e([a()],B.prototype,"_drillInFlowItems",void 0),e([a()],B.prototype,"_hideActionText",null),e([a()],B.prototype,"_featureNavigationVisible",null),e([a()],B.prototype,"_isCollapsed",null),e([a()],B.prototype,"_collapseEnabled",null),e([a({readOnly:!0})],B.prototype,"active",null),e([a()],B.prototype,"collapsed",void 0),e([a()],B.prototype,"content",null),e([a()],B.prototype,"icon",null),e([a()],B.prototype,"featureMenuOpen",null),e([a()],B.prototype,"featureMenuTitle",null),e([a()],B.prototype,"featureNavigationTop",void 0),e([a()],B.prototype,"features",null),e([a()],B.prototype,"goToOverride",null),e([a({type:b})],B.prototype,"headerActions",void 0),e([a()],B.prototype,"headingLevel",void 0),e([a()],B.prototype,"location",null),e([a()],B.prototype,"label",null),e([a()],B.prototype,"map",null),e([a(),N("esri/widgets/Features/t9n/Features")],B.prototype,"messages",void 0),e([a(),N("esri/t9n/common")],B.prototype,"messagesCommon",void 0),e([a()],B.prototype,"promises",null),e([a()],B.prototype,"responsiveActionsEnabled",void 0),e([a({readOnly:!0})],B.prototype,"selectedFeature",null),e([a({readOnly:!0})],B.prototype,"selectedDrillInFeature",null),e([a()],B.prototype,"selectedFeatureIndex",null),e([a({readOnly:!0})],B.prototype,"selectedFeatureWidget",null),e([a()],B.prototype,"spatialReference",null),e([a()],B.prototype,"title",null),e([a()],B.prototype,"timeZone",null),e([a()],B.prototype,"updateLocationEnabled",null),e([a()],B.prototype,"view",null),e([a({type:M}),T(["triggerAction","trigger-action"])],B.prototype,"viewModel",void 0),e([a({type:F,nonNullable:!0})],B.prototype,"visibleElements",void 0),e([a()],B.prototype,"visible",null),B=e([d("esri.widgets.Features")],B);const R=B;export{R as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import i from"../core/Logger.js";import{ignoreAbortErrors as o}from"../core/promiseUtils.js";import{watch as s,when as n}from"../core/reactiveUtils.js";import{waitAnimationFrame as r}from"../core/scheduling.js";import{throttle as l}from"../core/throttle.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import{getPointFromGeometry as c}from"../geometry/support/geometryUtils.js";import{substituteActionImage as u,getActionStyles as h}from"../support/actions/actionUtils.js";import p from"./Feature.js";import m from"./Spinner.js";import v from"./Widget.js";import{css as g}from"./Feature/resources.js";import{FeatureContentMixin as w}from"./Feature/support/FeatureContentMixin.js";import{css as _}from"./Features/css.js";import f from"./Features/FeaturesDrillIn.js";import M from"./Features/FeaturesViewModel.js";import F from"./Features/FeaturesVisibleElements.js";import{ActionsCollection as b}from"./Popup/actions.js";import{zoomToLocation as y}from"./Popup/actionUtils.js";import{loadCalciteComponents as I}from"./support/componentsUtils.js";import{globalCss as C}from"./support/globalCss.js";import{Heading as A}from"./support/Heading.js";import{setFocus as x}from"./support/widgetUtils.js";import{messageBundle as N}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as O}from"./support/jsxFactory.js";import{substitute as k}from"../intl/substitute.js";import{formatNumber as E}from"../intl/number.js";const j="selected-index",L=0,W="features-spinner";function S(e){return e?.declaredClass.startsWith("esri.layers.")??!1}let B=class extends(w(v)){constructor(e,i){super(e,i),this._featureMenuIntersectionObserverCallback=([e])=>{e?.isIntersecting&&null!=this.viewModel.featurePage&&this.viewModel.featurePage++},this._featureMenuIntersectionObserver=new IntersectionObserver(this._featureMenuIntersectionObserverCallback,{root:window.document}),this._featureMenuIntersectionObserverNode=null,this._spinner=null,this._feature=null,this._focusAbortController=null,this._drillInFlowItems=new t,this._drillInWidget=new f({flowItems:this._drillInFlowItems}),this._rootFlowItemNode=null,this._featureMenuViewportNode=null,this._actionBarMenuNode=null,this.collapsed=!1,this.featureNavigationTop=!1,this.headerActions=new b,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.responsiveActionsEnabled=!1,this.viewModel=new M,this.visibleElements=new F,this._renderAction=(e,t)=>{const i=this._getActionTitle(e),{type:o,active:s,uid:n,disabled:r,indicator:l}=e;return e.visible?O("calcite-action",{active:"toggle"===o&&e.value,appearance:"solid",bind:this,"data-action-id":e.id,"data-action-uid":n,disabled:r,icon:this._getActionIcon(e),indicator:l,key:`action-${t}`,loading:s,onclick:this._triggerAction,scale:"s",text:i,textEnabled:!this._hideActionText,title:this._hideActionText?i:void 0},this._getFallbackIcon(e)):null},this._openFeatureMenu=()=>{this.featureMenuOpen=!0,this._focusFlowItemNode("menu-flow-item")},this._previousFeature=()=>{this.viewModel.selectedFeatureIndex--},this._nextFeature=()=>{this.viewModel.selectedFeatureIndex++},this._handleFeatureMenuBack=()=>{this.featureMenuOpen&&(this._focusFlowItemNode("root-flow-item"),this.featureMenuOpen=!1)},this._displaySpinnerThrottled=l((()=>this._displaySpinner()),L),this._addSelectedFeatureIndexHandle(),this.addHandles([this._displaySpinnerThrottled,s((()=>this.viewModel?.active),(()=>this._toggleScreenLocationEnabled())),s((()=>this.viewModel?.active),(e=>this._drillInWidget.closed=!e)),s((()=>this.visibleElements?.closeButton),(e=>this._drillInWidget.closable=e)),s((()=>this.visibleElements?.spinner),(e=>this._spinnerEnabledChange(e))),s((()=>this.viewModel?.view),((e,t)=>this._viewChange(e,t))),s((()=>this.viewModel?.view?.ready),((e,t)=>this._viewReadyChange(e??!1,t??!1))),s((()=>[this.viewModel?.waitingForResult,this.viewModel?.location]),(()=>{this._hideSpinner(),this._displaySpinnerThrottled()})),s((()=>this.viewModel?.screenLocation),(()=>this._closeOpenActionMenu())),s((()=>this.selectedFeatureWidget),(()=>this._destroyDrillInFlowItemWidgets())),s((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]}),(()=>this._setTitleFromFeatureWidget())),s((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]}),(()=>this._setContentFromFeatureWidget())),s((()=>this.viewModel?.featureViewModels),(()=>this._featureMenuViewportScrollTop())),this._drillInWidget.on("close",(()=>this.close())),this._drillInWidget.on("exit",(()=>this._destroyDrillInFlowItemWidgets())),this._drillInWidget.on("open-feature",(({feature:e})=>this._openRelatedFeature(e))),this._drillInWidget.on("zoom-to-feature",(({featureWidget:e})=>y(this.viewModel,e)))])}loadDependencies(){return I({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})}destroy(){this._destroyDrillInFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver?.disconnect(),this._drillInWidget?.destroy(),this._focusAbortController?.abort()}get _hideActionText(){if(!this.responsiveActionsEnabled)return!1;const e=this.view?.widthBreakpoint;return"xsmall"===e||"small"===e||"medium"===e}get _featureNavigationVisible(){return this.viewModel.active&&this.viewModel.featureCount>1&&this.visibleElements.featureNavigation}get _isCollapsed(){return this._collapseEnabled&&this.collapsed}get _collapseEnabled(){return this.visibleElements.collapseButton&&!!this.title&&!!this.content}get active(){return this.viewModel.active}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get icon(){return null}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get featureMenuTitle(){return this.viewModel.featureMenuTitle}set featureMenuTitle(e){this.viewModel.featureMenuTitle=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedDrillInFeature(){const e=Array.from(this._drillInFlowItems).at(-1);if(!e)return null;const{flowType:t}=e;return"feature-association"===t||"feature-relationship"===t?e.graphic??null:null}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_drillInFlowItems:i,timeZone:o,spatialReference:s,map:n}=this,{selectedFeatureViewModel:r}=this.viewModel,l={title:!1};return r?(e?(e.viewModel=r,e.visibleElements=l):this._feature=new p({flowItems:i,headingLevel:t+1,timeZone:o,spatialReference:s,map:n,viewModel:r,visibleElements:l}),this._feature):null}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e?this._rootFlowItemNode?.blur():i.getLogger(this).warn("Features can only be blurred when currently active.")}clear(){return this.viewModel.clear()}close(){this.viewModel.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e?this._focusFlowItemNode(this.featureMenuOpen?"menu-flow-item":"root-flow-item"):i.getLogger(this).warn("Features can only be focused when currently active.")}next(){return this.viewModel.next()}open(e){this.removeHandles(j);const t={collapsed:e?.collapsed??!1};this.set(t),this.viewModel.open(e),this.addHandles(n((()=>!this.viewModel.waitingForResult),(()=>this._addSelectedFeatureIndexHandle()),{once:!0}))}previous(){return this.viewModel.previous()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return O("div",{bind:this,class:this.classes(_.base,C.widget,C.panel),onkeydown:this._onMainKeydown},this._renderHeader(),this._renderContentContainer())}_renderFeatureNavigation(){return[this._renderPagination(),this._renderFeatureMenuButton()]}_renderHeader(){return!this.featureMenuOpen&&this.featureNavigationTop&&this._featureNavigationVisible?O("div",{class:_.header,key:"header-actions"},this._renderFeatureNavigation()):null}_renderFooter(){return this.featureMenuOpen||this.featureNavigationTop||!this._featureNavigationVisible?null:O("div",{class:_.footer,key:"footer-actions",slot:"footer"},this._renderFeatureNavigation())}_renderFeatureMenuButton(){const{messages:e,viewModel:t}=this,{featureCount:i,selectedFeatureIndex:o,pendingPromisesCount:s}=t;return O("calcite-action",{appearance:"solid",bind:this,icon:"list",key:"feature-menu-button",label:e.selectFeature,loading:s>0,onclick:this._openFeatureMenu,scale:"s",text:k(e.pageText,{index:E(o+1),total:E(i)}),textEnabled:!0,title:e.selectFeature})}_renderPagination(){const{previous:e,next:t}=this.messagesCommon.pagination;return O("calcite-action-bar",{class:_.paginationActionBar,expandDisabled:!0,key:"pagination-action-bar",layout:"horizontal",overflowActionsDisabled:!0,scale:"s"},O("calcite-action-group",{scale:"s"},O("calcite-action",{appearance:"solid",class:_.paginationPrevious,icon:"chevron-left",iconFlipRtl:!0,label:e,onclick:this._previousFeature,scale:"s",text:e,title:e}),O("calcite-action",{appearance:"solid",icon:"chevron-right",iconFlipRtl:!0,label:t,onclick:this._nextFeature,scale:"s",text:t,title:t})))}_renderFeatureMenuItem(e){const{selectedFeatureViewModel:t,featureViewModels:i}=this.viewModel,o=e===t,s=i.indexOf(e);return O("calcite-list-item",{bind:this,"data-feature-index":s,key:`feature-menu-item-${e.uid}`,onblur:this._removeActiveFeature,onfocus:this._setActiveFeature,onmouseleave:this._removeActiveFeature,onmouseover:this._setActiveFeature,selected:o,onCalciteListItemSelect:this._selectFeature},O("span",{innerHTML:e.title||this.messagesCommon.untitled,slot:"content"}))}_groupResultsByLayer(){const{featureViewModels:e}=this.viewModel,t=new Map;return e.forEach((e=>{const i=e?.graphic;if(!i)return;const{layer:o,sourceLayer:s}=i,n=(S(o)?o:null)||(S(s)?s:null),r=t.get(n)??[];t.set(n,[...r,e])})),t}_renderFeatureMenu(){const{messages:e,viewModel:t}=this,i=this._groupResultsByLayer();return t.featureViewModels.length?O("calcite-list",{displayMode:"flat",label:e?.featuresList,selectionAppearance:"icon",selectionMode:"single"},Array.from(i.keys(),(e=>{const t=i.get(e)?.map((e=>this._renderFeatureMenuItem(e))),o=e?e.title??this.messagesCommon.untitled:null;return this.visibleElements.featureListLayerTitle&&null!==o?O("calcite-list-item-group",{heading:o,key:e?.uid||"map-graphics"},t):t}))):null}_renderHeaderAction(e,t){const i=e.title||"";return e.visible?O("calcite-action",{active:"toggle"===e.type&&e.value,appearance:"solid",bind:this,"data-action-id":e.id,"data-action-uid":e.uid,disabled:e.disabled,icon:e.icon??void 0,indicator:e.indicator,key:`header-action-${t}`,loading:e.active,onclick:this._triggerHeaderAction,slot:"header-actions-end",text:i,title:i}):null}_renderHeaderActions(){return this.headerActions.map(((e,t)=>this._renderHeaderAction(e,t))).toArray()}_renderContentFeature(){const{headingLevel:e,visibleElements:t,_isCollapsed:i,_collapseEnabled:o,_drillInFlowItems:s,featureNavigationTop:n,featureMenuOpen:r}=this,{title:l,active:a}=this.viewModel,d=t.heading&&l?l:"";return O("calcite-flow-item",{afterCreate:this._storeRootFlowItemNode,bind:this,class:this.classes({[_.contentFeature]:!0,[_.flowItemCollapsed]:i}),closable:t.closeButton,closed:!a,collapsed:i,collapseDirection:n?"down":"up",collapsible:o,headingLevel:e,key:"root-flow-item",selected:!r&&0===s.length,onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},d?O(A,{class:this.classes(_.featuresHeading,C.heading),innerHTML:d,key:"header-content",level:this.headingLevel,slot:"header-content"}):null,this._renderHeaderActions(),this._renderActionBar(),i?null:O("div",{class:this.classes(_.container,_.contentContainer)},this._renderContent()),this._renderFooter())}_renderFeatureMenuContainer(){const{viewModel:e,featureMenuOpen:t,featureMenuTitle:i,messages:o,messagesCommon:s}=this,{active:n,featureViewModels:r,pendingPromisesCount:l}=e,a=i??o.selectFeature;return t?O("calcite-flow-item",{afterCreate:this._storeFeatureMenuFlowItemNode,bind:this,closable:!1,closed:!n,description:k(o.total,{total:r.length}),heading:a,key:"feature-menu",loading:e.waitingForContents,selected:t,onCalciteFlowItemBack:e=>{e.preventDefault(),this._handleFeatureMenuBack()}},l>0?O("calcite-loader",{class:_.loader,inline:!0,key:"feature-menu-loader",label:s.loading,slot:"header-actions-end"}):null,O("div",{class:_.container},this._renderFeatureMenu()),O("div",{afterCreate:this._featureMenuIntersectionObserverCreated,bind:this,class:_.featureMenuObserver}),O("calcite-button",{appearance:"transparent",onclick:this._handleFeatureMenuBack,slot:"footer-actions",width:"full"},s.back)):null}_renderContentContainer(){const e=[this._renderContentFeature(),this._renderFeatureMenuContainer(),this._drillInWidget.render()];return this.visibleElements.flow?O("calcite-flow",{key:"content-container"},e):e}_getFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o=u({action:e,feature:this.selectedFeature}),s={[_.icon]:!!t,[_.actionImage]:!!o};return t&&(s[t]=!0),o||t?O("span",{"aria-hidden":"true",class:this.classes(_.icon,s),key:"icon",styles:h(o)}):null}_renderActionBar(){return!this._isCollapsed&&this.visibleElements.actionBar&&this.viewModel.allActions?.length?O("calcite-action-bar",{expandDisabled:!0,expanded:!this._hideActionText,key:"header-action-bar",scale:"s",slot:"action-bar"},O("calcite-action-group",{afterCreate:e=>this._actionBarMenuNode=e,overlayPositioning:"fixed",scale:"s"},this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map(this._renderAction)}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?O("div",{class:g.contentNode,innerHTML:e,key:e}):this.renderNodeContent(e):null}_handleCollapseToggle(){this.collapsed=!this.collapsed}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;if(null==i||null==t)return;this._destroyDrillInFlowItemWidgets(),await this.viewModel.zoomTo({target:i});const o=c(i);this.open({features:[t],location:null!=o?o:void 0})}async _focusFlowItemNode(e){this._focusAbortController?.abort(),this._focusAbortController=new AbortController;const t=this._focusAbortController.signal;await o(r(t));const i="menu-flow-item"===e?this._featureMenuViewportNode:this._rootFlowItemNode;x(i)}_storeRootFlowItemNode(e){this._rootFlowItemNode=e}_storeFeatureMenuFlowItemNode(e){this._featureMenuViewportNode=e}_setActiveFeature(e){const{viewModel:t}=this,i=e.currentTarget["data-feature-index"];t.activeFeature=t.features?.[i]||null}_removeActiveFeature(){this.viewModel.activeFeature=null}_selectFeature(e){const t=e.currentTarget["data-feature-index"];isNaN(t)||(this.viewModel.selectedFeatureIndex=t),this._handleFeatureMenuBack()}_unobserveFeatureMenuObserver(){this._featureMenuIntersectionObserverNode&&this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode)}_featureMenuIntersectionObserverCreated(e){this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver.observe(e),this._featureMenuIntersectionObserverNode=e}_getActionIcon(e){return e.icon?e.icon:e.image||e.className?void 0:"question"}_getActionTitle(e){const{messages:t,selectedFeature:i,messagesCommon:o}=this,{id:s}=e,n=i?.attributes,r=e.title??"",l="zoom-to-feature"===s?k(r,{messages:t}):"remove-selected-feature"===s?k(r,{messages:o}):"zoom-to-clustered-features"===s||"browse-clustered-features"===s?k(r,{messages:t}):e.title;return l&&n?k(l,n):l??""}_onMainKeydown(e){const{key:t}=e;"ArrowLeft"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.previous()),"ArrowRight"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.next())}_featureMenuViewportScrollTop(){this._featureMenuViewportNode&&this._featureMenuViewportNode.scrollContentTo({top:0})}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_addSelectedFeatureIndexHandle(){const e=s((()=>this.viewModel?.selectedFeatureIndex),((e,t)=>this._selectedFeatureIndexUpdated(e,t)));this.addHandles(e,j)}_selectedFeatureIndexUpdated(e,t){const{featureCount:i}=this.viewModel;i&&e!==t&&-1!==e&&(this._destroyDrillInFlowItemWidgets(),this._rootFlowItemNode&&this._rootFlowItemNode.scrollContentTo({top:0}))}_triggerHeaderAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,o=this.headerActions.find((({uid:e})=>e===i));o&&!o.disabled&&("toggle"===o?.type&&(o.value=!o.value),this.emit("trigger-header-action",{action:o}))}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:o}=this.viewModel,s=o.findIndex((e=>e.uid===i)),n=o.at(s);n&&"toggle"===n.type&&(n.value=!n.value),this.viewModel.triggerAction(s)}_createSpinner(e){e&&(this._spinner=new m({view:e}),e.ui.add(this._spinner,{key:W,position:"manual",internal:!0}))}_wireUpView(e){this._destroySpinner(),e&&this.visibleElements?.spinner&&this._createSpinner(e)}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_closeOpenActionMenu(){const{_actionBarMenuNode:e}=this;e&&(e.menuOpen=!1)}_destroyDrillInFlowItemWidgets(){this._drillInFlowItems.drain((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}))}_toggleScreenLocationEnabled(){const{viewModel:e}=this;e&&(e.screenLocationEnabled=e.active)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_destroySpinner(){const{_spinner:e}=this;e&&(e.view?.ui?.remove(e,W),e.destroy(),this._spinner=null)}_spinnerEnabledChange(e){this._destroySpinner(),e&&this._createSpinner(this.viewModel?.view)}};e([a()],B.prototype,"_drillInFlowItems",void 0),e([a()],B.prototype,"_hideActionText",null),e([a()],B.prototype,"_featureNavigationVisible",null),e([a()],B.prototype,"_isCollapsed",null),e([a()],B.prototype,"_collapseEnabled",null),e([a({readOnly:!0})],B.prototype,"active",null),e([a()],B.prototype,"collapsed",void 0),e([a()],B.prototype,"content",null),e([a()],B.prototype,"icon",null),e([a()],B.prototype,"featureMenuOpen",null),e([a()],B.prototype,"featureMenuTitle",null),e([a()],B.prototype,"featureNavigationTop",void 0),e([a()],B.prototype,"features",null),e([a()],B.prototype,"goToOverride",null),e([a({type:b})],B.prototype,"headerActions",void 0),e([a()],B.prototype,"headingLevel",void 0),e([a()],B.prototype,"location",null),e([a()],B.prototype,"label",null),e([a()],B.prototype,"map",null),e([a(),N("esri/widgets/Features/t9n/Features")],B.prototype,"messages",void 0),e([a(),N("esri/t9n/common")],B.prototype,"messagesCommon",void 0),e([a()],B.prototype,"promises",null),e([a()],B.prototype,"responsiveActionsEnabled",void 0),e([a({readOnly:!0})],B.prototype,"selectedFeature",null),e([a({readOnly:!0})],B.prototype,"selectedDrillInFeature",null),e([a()],B.prototype,"selectedFeatureIndex",null),e([a({readOnly:!0})],B.prototype,"selectedFeatureWidget",null),e([a()],B.prototype,"spatialReference",null),e([a()],B.prototype,"title",null),e([a()],B.prototype,"timeZone",null),e([a()],B.prototype,"updateLocationEnabled",null),e([a()],B.prototype,"view",null),e([a({type:M}),T(["triggerAction","trigger-action"])],B.prototype,"viewModel",void 0),e([a({type:F,nonNullable:!0})],B.prototype,"visibleElements",void 0),e([a()],B.prototype,"visible",null),B=e([d("esri.widgets.Features")],B);const R=B;export{R as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import"../../symbols.js";import{isSome as i,equals as r}from"../../core/arrayUtils.js";import{createTask as a}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import l from"../../core/Evented.js";import c from"../../core/JSONSupport.js";import{equalsShallow as h}from"../../core/lang.js";import p from"../../core/Logger.js";import{clamp as u}from"../../core/mathUtils.js";import{abortMaybe as d,destroyMaybe as m}from"../../core/maybe.js";import g from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as f,waitTick as v}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{on as b,watch as F,syncAndInitial as _,initial as P}from"../../core/reactiveUtils.js";import{sqlAnd as I}from"../../core/sql.js";import{getMetersPerUnitForSR as S}from"../../core/unitUtils.js";import{property as C}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as V}from"../../core/support/UpdatingHandles.js";import{union as A}from"../../geometry/geometryEngineAsync.js";import{projectWithZConversion as M}from"../../geometry/projection.js";import{isClockwise as R}from"../../geometry/support/coordsUtils.js";import{geographicToWebMercator as j}from"../../geometry/support/webMercatorUtils.js";import O from"../../layers/GraphicsLayer.js";import{searchImages as L}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as B}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as G,computePolygonForInspection as H,resizePolygon as x,checkIfPolygonContainsSelectedPoint as E}from"../../layers/orientedImagery/core/coverageUtils.js";import{isConstantElevation as z,isElevationSource as T}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{imageToWorld as D,imageToWorldPanoramic as U}from"../../layers/orientedImagery/transformations/imageToWorld.js";import N from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as W}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{getInitialAngle as q,convertPixelToHeadingPitch as $,getImageToWorldProperties as J,getUpdateElevationProps as K,isElevationSampler as Q,pointToArray as Z,getImageToWorldPanoramicProperties as X,getWorldToImageProperties as Y,convertHeadingPitchToSphereVertex as ee,or as te}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as ie,worldToImage as re}from"../../layers/orientedImagery/transformations/worldToImage.js";import{getFloorFilterClause as ae}from"../../layers/support/floorFilterUtils.js";import se from"../../rest/support/AttachmentQuery.js";import{scale as oe}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as ne}from"../../views/input/InputManager.js";import le from"../PanoramicViewer.js";import{invalidCameraHeading as ce,sectorsInOrder as he,sectorsRadii as pe}from"./constants.js";import{crossSymbol as ue,crossSymbol3D as de,measurementPolygonSymbol as me,measurementPolylineSymbol as ge,sourcePointSymbol as ye,diamondSymbol as fe,diamondSymbol3D as ve,activeSourcePointSymbol as we}from"./symbols.js";import{isNoAttachmentError as be,getContentType as Fe,isTifOrMrf as _e,filterOILLayerView as Pe,isSceneView as Ie,isGraphic as Se,calculateSegment as Ce,calculateDirection as ke}from"./utils.js";import Ve from"./components/ImageViewer.js";import Ae from"../../geometry/Point.js";import Me from"../../geometry/SpatialReference.js";import Re from"../../symbols/SimpleLineSymbol.js";import je from"../../geometry/Multipoint.js";import Oe from"../../geometry/Polyline.js";import Le from"../../geometry/Polygon.js";const Be={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles",sketchHandles:"sketch-handles"},Ge=new Set(["JPG","JPEG"]),He=/\.(\w+)$/,xe=e=>"FA"===e,Ee=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let ze=class extends(l.EventedMixin(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.conversionProps=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.determineWorkflowForFeature=async(e,t,i)=>{const{currentBestFeature:r,selectedPoint:a,view:s}=this;if(s?.closePopup(),r&&a){this._initialCurrentCoverageUpdate=!0;try{await this._updatePointsAndPolygons(i),await this._loadImage(i)}catch(o){y(o)||(this.loadImageError(o),p.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.displayNewAreaMeasurementButton=!0,this.distanceMeasurementResult=0,this.digitizationLayer=null,this.features=new s,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.navigatorCurrentBestFeature=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new w,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.sketchAdapter=null,this.updateFootprint=async(e,t)=>{"image-loaded"===this.state&&await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new Ve,this._initialCurrentCoverageUpdate=!0,this._overlays=new O({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new le,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._updatingHandles=new V,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDigitizationAdapter=async e=>{const{sketchAdapter:t}=this;if("digitization"===t?.type)return t;const i=import("./adapters/sketch/DigitizationAdapter.js");this._updatingHandles.addPromise(i);const{default:r}=await i;return f(e),this.sketchAdapter=new r({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.loadImageViewer=e=>{this._imageViewer.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.startDigitization=e=>{},this.stopDigitization=e=>{},this.toggleImageAttributes=()=>{d(this._openPopupTask),this._openPopupTask=a((async e=>{const{currentBestFeature:i,popupEnabled:r,layer:a,view:s}=this;if(s?.closePopup(),!(s&&i&&r&&a))return;const{attributes:o,geometry:n}=i,l=new t({geometry:n,attributes:o.toJSON(),layer:a});f(e),await s.openPopup({features:[l],location:o.location.clone()})}))},this._createViewClickHandle=()=>{if(this.removeHandles(Be.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,ne.WIDGET),Be.click)},this._createImageClickHandle=()=>{this.removeHandles(Be.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:i,currentBestFeature:r,footprintExtent:s}=this,o=i?.imageSize;if(!(e&&"none"!==t&&o&&s&&r))return;i.clickAction="pixel-location";let n=null;const l=b((()=>i),"pixel-location",(e=>{this.plotReferencePointOnImage(e),n?.abort(),n=a((async i=>{if(!e)return;const a=await this.getMapPoint(e,{feature:r,imageSize:o,mode:t}).then((e=>{const t=this.view?.spatialReference;return te(!t,e.spatialReference.equals(t))?e:M(e,t)}));f(i),this.plotReferencePointOnGround(a)}))}));this.addHandles(l,Be.imageClick)},this._getImageSourceFromAttachment=async(e,t,i)=>{const r=new se({objectIds:[t]}),a=await e.queryAttachments(r,i),s=a[`${t}`]?.[0],o=s?.url;if(!o)throw new n("NoAttachmentError","no attachments found",{[e.objectIdField]:t,layer:e});return{datasetFormat:s.contentType.split("/")[1].toUpperCase(),url:o}},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:r}=this;if(this.clearGraphics(),!i||!t||"none"===r)return;const{attributes:a}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:l,cameraPitch:c,objectId:h,cameraOrientation:u,location:d}=a,m=(l??0)+(o??0),g=d.spatialReference.isWGS84&&4!==u?.type?j(d):new Ae(d);let v=s;if(xe(s))try{v=await this._getImageSourceFromAttachment(i,h,e)}catch(w){if(y(w))return;return be(w)?(p.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${i.objectIdField}: ${h}`)):(p.getLogger(this).error(w,{[i.objectIdField]:h,layer:i}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${i.objectIdField} ${h}`))}try{await this.loadImageFromSource(v,{imageRotation:m,options:e,pitch:c,yaw:n,mode:r,cameraLocation:g}),f(e),await this.transformAndPlotSelectedLocation(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:i,imageRotation:r,options:a}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:l}=new URL(o);let c=s?n.match(He)?.[1]:e.datasetFormat;if(!c){const e=await Fe(o,{...t.options});c=e?.split("/")[1]??"UNKNOWN FORMAT"}switch(i){case"default":this._imageViewer.imageSource={datasetFormat:c.toUpperCase(),url:o.split("?")[0]},this._imageViewer.customParameters=Object.fromEntries(l),this._imageViewer.imageRotation=r??0,await this._imageViewer.loadImage(a);break;case"panoramic":if(Ge.has(c.toUpperCase())){const{selectedPoint:e}=this,{pitch:i,yaw:r,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=o;let l=r??0;"number"==typeof n?l=n-l:s&&e&&(l=await q(s,e)-l),this._panoramicViewer.pitch=i??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(a)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:c});break}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");f(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");f(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=a((async t=>{const{pointerType:i,button:r,mapPoint:a}=e;if(("mouse"!==i||0===r)&&a)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(a,{signal:t}))}))},this.plotSelectedPointOnImage=async(e,i)=>{if(await v(i),!e)return;const r=new Ae({...c.isSerializable(e)?e.toJSON():e});if("default"===this.mode)r.x-=.5,r.y=.5-r.y,r.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:r,symbol:ue}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:i}=this._panoramicViewer;if(!i)return;const[r,a]=i,{heading:s,pitch:o}=$(e,r,a),n=ee(s,o);this._crossSymbol=new t({geometry:new Ae(n,Me.WebMercator),symbol:de}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this.selectBestFeature=this.selectBestFeature.bind(this)}initialize(){this.addHandles([F((()=>this.view),(()=>{this.load()}),_),F((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),P),F((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),P),F((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{this._createViewClickHandle(),this._createImageClickHandle()}),_),F((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),_),F((()=>this.currentBestFeature),(async(e,t)=>{d(this._featureChangedTask),this._featureChangedTask=a((async i=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:i}]))),await this._featureChangedTask.promise}),{sync:!0}),F((()=>this.mode),(e=>{switch(this.removeHandles(Be.interactionHandles),e){case"default":this.addHandles(F((()=>this._imageViewer.imagePointsInView),(e=>{e&&(d(this._updateFootprintTask),this._updateFootprintTask=a((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>r(e,t,h)}),Be.interactionHandles);break;case"panoramic":this.addHandles(F((()=>{const{currentBestFeature:e,state:t}=this,{imageSize:i,vfov:r,hfov:a,pitch:s,yaw:o}=this._panoramicViewer;return e&&i&&"image-loading"!==t?[r,a,o,s]:null}),(e=>{if(!e||"image-loading"===this.state)return;const[t,i,r,s]=e;d(this._updateFootprintTask),this._updateFootprintTask=a((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:r,pitch:s},{signal:e})}))}),{..._,equals:(e,t)=>r(e,t,h)}),Be.interactionHandles)}}),_),F((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:i,mode:r,sharpness:a}=this;"default"===r&&(e.brightness=t,e.contrast=i,e.sharpness=a)}),_),F((()=>this.activeViewer?.imageRenderer),(()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}))])}destroy(){this._updateFootprintTask=d(this._updateFootprintTask),this._clickTask=d(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=m(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._crossSymbol=m(this._crossSymbol),this._referencePointOnGround=m(this._referencePointOnGround),this._referencePointOnImage=m(this._referencePointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this._panoramicViewer.destroy()}get activeLayer(){return o(p.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(p.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:i}=this;switch(i){case"default":return e;case"panoramic":return t;default:return null}}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",u(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",u(e,-10,10))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){return _e(this.currentBestFeature?.attributes.imagePath.trim())}get imageLoaded(){return o(p.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===ce}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(Pe(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ae(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:i}=e;return 360===t||i?"panoramic":"default"}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?he.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",u(e,0,1))}get sketchGraphicsLayer(){return this.sketch?.layer}get state(){const{mode:e,disabled:t}=this;if(t)return"disabled";if(!this.isFulfilled())return"loading";if(this.isRejected())return"error";if(this._updatingHandles.updating)return"image-loading";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:i,imageRotation:r}})=>{const a=e.trim();return _e(a)?{url:a,objectId:t,rotation:(i??0)+(r??0)}:null})).filter(i)):null}set view(e){this._set("view",e)}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}digitizeCreate(e,t){const{sketch:i}=this;return i?i.create(e,t):Promise.reject(Ee())}async digitizeDelete(){if(!this.sketch)throw Ee();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw Ee();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw Ee();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw Ee();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw Ee();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw Ee();return this.sketch.update(e,t)}filterByFootprints(e,t){const i=[],r=[],a=[];return e.forEach((e=>{const{layer:{coveragePercent:s},attributes:o}=e;let n;const l=S(e.geometry.spatialReference);o.cameraHeight/=l,o.farDistance/=l,o.nearDistance/=l,z(o.elevationSource)&&(o.elevationSource.constantElevation/=l);const{polygon:c,frustum:h}=G(o);if(n=c.clone(),o.isInspection&&(n=H(o)),s&&(n=x(n,s)),E(n,t)){a.push(e);const{geometry:t,objectId:s,cameraHeight:n,cameraHeading:l}=o,p=t.clone();p.z=n,p.imageID=s,this.pointSources.push(p),l!==ce&&(i.push(c),h&&r.push(h))}})),{features:a,polygons:i,frustums:r}}getMeasurementProperties(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:i,attributes:r}=e,{elevationSource:a,cameraHeight:s}=r,o=J(r,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?M(n,Me.WebMercator):Promise.resolve(n)).then((e=>(n=e,K((n.z??0)-s,{elevationSample:i,elevationSource:a,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&Q(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}handleDigitizeDelete(){}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[he[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:i}=e;if(isNaN(i))return;const r=this._sectorData?.[t];r?.length&&this._updateCurrentBestFeature(r.at(i))}async load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch((e=>{if(!y(e))throw e}))),this}async loadBestImage(e,t){return this.view?.closePopup(),this.displayMessage=null,this.selectedPoint=e.spatialReference.isGeographic?j(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),this._fetchFeaturesWithController(e,t)}loadImageError(e){p.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js");this._updatingHandles.addPromise(t);const{default:i}=await t;f(e),this.sketch=new i({layer:new O,view:this.activeViewer?.imageRenderer})}return this.sketch}async loadSketchAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js");this._updatingHandles.addPromise(t);const{default:i}=await t;if(f(e),this.sketchAdapter=new i({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}if(this.sketch&&this.sketchAdapter){const e=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;e&&this.sketch&&(this.sketch.polygonSymbol=me(e),this.sketch.polylineSymbol=ge(e))}return this.sketchAdapter}async overlayCameraLocations(e){const{activeViewer:i,currentBestFeature:r,overlayedCameraLocations:a,layer:s,mode:o,state:n}=this,l=i?.imageSize;if(!l||!r||!s||"none"===o||n.includes("loading"))return;const{polygon:c}=G(r.attributes);if(i.removeManyGraphics(a.toArray()),a.removeAll(),e){const{features:e}=await s.queryFeatures({where:`${s.objectIdField} <> ${r.attributes.objectId}`,geometry:c,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map((async e=>{const{attributes:i,geometry:a}=e,s=await this.getPixels(a,{feature:r,imageSize:l,mode:o}),n=ye.clone();return n.outline=new Re({color:[0,0,0],width:1}),new t({attributes:i,symbol:n,geometry:s})})));a.addMany(n),i.addManyGraphics(a.toArray())}}overlayGraphicsOnImage(e,t){this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,r=!1){const{activeViewer:a,currentBestFeature:o,mode:n,state:l}=this,c=a?.imageSize;if(!c||!o||"none"===n||l.includes("loading"))return;const{polygon:h}=G(o.attributes),{features:p}=await e.queryFeatures({geometry:h,returnGeometry:!0,outFields:[e.objectIdField]}),u=new s((await Promise.all(p.map((async i=>{const{attributes:a,geometry:s}=i,l=i.symbol?.clone()??e.renderer?.getSymbol(i)?.clone();switch(s?.type){case"point":{const i=await this.getPixels(s,{feature:o,imageSize:c,mode:n});return new t({attributes:a,layer:e,symbol:l,geometry:i,visible:e.visible&&r})}case"polygon":{const{rings:i,spatialReference:h}=s,p=i.map((e=>e.map((([e,t,i])=>new Ae({x:e,y:t,z:i,spatialReference:h}))))),u=await Promise.all(p.map((async e=>this.getPixels(e,{feature:o,imageSize:c,mode:n}).then((e=>e.map(Z))))));return new t({attributes:a,layer:e,symbol:l,geometry:new Le({rings:u,spatialReference:Me.WebMercator}),visible:e.visible&&r})}case"polyline":{const{paths:i,spatialReference:h}=s,p=i.map((e=>e.map((([e,t,i])=>new Ae({x:e,y:t,z:i,spatialReference:h}))))),u=await Promise.all(p.map((async e=>this.getPixels(e,{feature:o,imageSize:c,mode:n}).then((e=>e.map(Z))))));return new t({attributes:a,layer:e,symbol:l,geometry:new Oe({paths:u,spatialReference:Me.WebMercator}),visible:e.visible&&r})}case"multipoint":{const{points:i,spatialReference:h}=s,p=i.map((([e,t,i])=>new Ae({x:e,y:t,z:i,spatialReference:h}))),u=await this.getPixels(p,{feature:o,imageSize:c,mode:n}).then((e=>e.map(Z)));return new t({attributes:a,layer:e,symbol:l,geometry:new je({points:u,spatialReference:Me.WebMercator}),visible:e.visible&&r})}}return null})))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,u)}async getPixels(e,t){const{imageSize:i,mode:r}=t,a=(await this.worldToImage(Array.isArray(e)?e:[e])).map((e=>{if("default"===r)return new Ae({x:e.x-.5,y:.5-e.y,spatialReference:Me.WebMercator});const[t,a]=i,{heading:s,pitch:o}=$(e,t,a),n=ee(s,o);return new Ae(n,Me.WebMercator)}));return Array.isArray(e)?a:a[0]}async getMapPoint(e,t){const{feature:i,mode:r,imageSize:a}=t,{elevationSample:s,attributes:o}=i,{elevationSource:n,location:l,elevation:c,cameraHeight:h}=o;let p=l.clone();p.spatialReference.isGeographic&&(p=await M(p,Me.WebMercator));const u=await K(c??(l.z??0)-h,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let d;if("elevationSample"in u&&Q(u.elevationSample)&&(i.elevationSample=u.elevationSample),"default"===r){const t=J(o,a[0],a[1]);d=await D(Array.isArray(e)?e:[e],{...t,cameraLocation:p},u)}else{const t=X(o,a[0],a[1]);d=await U(Array.isArray(e)?e:[e],{...t,cameraLocation:p},u)}return Array.isArray(e)?d:d[0]}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new Ae({...e.toJSON()}),symbol:fe}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const i=c.isSerializable(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,this._referencePointOnImage=new t({geometry:new Ae({spatialReference:this._imageViewer.imageRenderer.spatialReference.clone(),...i}),symbol:fe}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:i}=this._panoramicViewer;if(!i)return;const[r,a]=i,{heading:s,pitch:o}=$(e,r,a),n=ee(s,o);this._referencePointOnImage=new t({geometry:new Ae(n,Me.WebMercator),symbol:ve}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach((e=>{this._imageViewer.removeManyGraphics(e.toArray())})),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=d(this._clickTask)}async searchBestImage(e,t){try{const i=await L(e,t);i&&await this._processFeatureResponse(i,e.point,{signal:t?.signal})}catch(i){y(i)||(this.setMessage("imageLoadError","error",i.message),p.getLogger(this).error("error occurred while finding best image",i))}}selectBestFeature(e){this.currentBestFeature=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach((t=>{this._toggleVisiblity(t,e)}))}toggleOverlayMapFeatures(e,t){const i=this.overlayedMapFeatures.get(e);i&&this._toggleVisiblity(i,t)}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:i}=e;let r=!1,a=!1;const s=this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=t.spatialReference.equals(s.spatialReference)?t:await M(t,s.spatialReference);r=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await M(t,s.spatialReference);a=s.extent.contains(e);break}}if(!r&&!a)return void this.clearReferencePointOnImage();const o=await this.worldToImage(t,i);if(o)return f(i),this.plotReferencePointOnImage(o),{x:o.x,y:o.y};this.clearReferencePointOnImage()}updateSuitabilities(e){e.sort(((e,t)=>e.suitability-t.suitability)),this._suitabilities=e;const t=this._suitabilities.map((({feature:e})=>e));this._initialCurrentCoverageUpdate=!0,this._updateFeatures(t),this._groupFeaturesBySectors()}async _fetchFeatures(e,t){if(!this.view)return;const i=this.layer;if(i){const r={include:i},a=this.view.toScreen(e);if(!a)return;const s=await this.view.hitTest(a,r);return this._processHitTestResults(i,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(i){if(y(i))return;this.setMessage("imageLoadError","error"),p.getLogger(this).error("error occurred while fetching features",i)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:i,features:r,invalidCameraHeading:a}=this;if(!e||!t||!i||!r||a)return void(this._sectorData=null);this._sectorData={};for(const c of he)this._sectorData[c]=new s;const o=e.map(((e,t)=>({...e,featureIndex:t})));o.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const n=o.map((({distance:e})=>e)),l=Math.max(...n);o.forEach((e=>{const{distance:t,angle:i,featureIndex:a}=e,s=t/l*pe[2],o=Ce(t,l),n=ke(i);if(!this._sectorData)return;const c=pe[3]+s*Math.sin(i*Math.PI/180),h=pe[3]+s*Math.cos(i*Math.PI/180);let p;const u=r.at(a),d=u===this.currentBestFeature,m=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(d&&m)p=-90;else{const e=c-pe[3],t=h-pe[3],i=t/Math.sqrt(e**2+t**2);let r=180*Math.acos(i)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(r*=-1),p=r}const g=""===o?n:`${o}_${n}`;d&&(p===this.bestFeatureAngle?this.previousFeatureAngle=p:this.bestFeatureAngle=p,this.navigatorCurrentBestFeature=m?null:{x:c,y:h,direction:n});const y=this._sectorData[g];y.add({angle:i,featureIndex:a,x:c,y:h,objectID:u.attributes.objectId,sector:g,featureIndexInSector:y.length})}))}async _processFeatureResponse(e,t,i){const{features:r}=e;if(!r?.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll();const{features:a,polygons:s,frustums:o}=this.filterByFootprints(r,t);if(!a.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);let n;if(this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o),s[0]){let e=new Le({spatialReference:s[0].spatialReference});for(const i of s)e=await A(e,i);const t=[];for(const{geometry:i}of a)e.contains(i)||t.push([i.x,i.y]);if(t.sort(((e,t)=>+R([e,t]))),e.addRing(t),this.footprintExtent=oe(e.extent,2,2),this.view?.supportsGround)try{n=await this.view.map.ground.createElevationSampler(this.footprintExtent,i)}catch(l){y(l)||p.getLogger(this).error(l)}}if((n||a[0].attributes.elevationSource)&&this.footprintExtent){const e=a[0].attributes.elevationSource;T(e)&&!n&&(n=await W({extent:this.footprintExtent,lod:e.lod,url:e.url,rasterFunction:e.rasterFunction}));const i=await K((a[0].attributes.location.z??0)-a[0].attributes.cameraHeight,{elevationSample:n,elevationSource:e,extent:this.footprintExtent}),[r,...s]=await N([t,...a.map((e=>e.attributes.geometry.clone()))],i);a[0].elevationSample=n??i.elevationSample,t.elevation=r.z,a.forEach(((e,t)=>{e.attributes.elevation=s[t].z}))}a[0].elevationSample&&a.forEach((e=>{e.elevationSample=a[0].elevationSample})),this._suitabilities=B({features:a,selectedPoint:t,camera:Ie(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities)}async _processHitTestResults(e,t,i){const{screenPoint:r,results:[a]}=t,s="graphic"===a?.type&&this.shouldShowSelectedImage,o=a?.mapPoint??this.view?.toMap(r);if(!o)return;const{layerFloorFilterClause:n}=this,l=e.spatialReference.equals(o.spatialReference)?o:await M(o,e.spatialReference),c=I("1=1",I(e.definitionExpression,n)),h=l.spatialReference.isGeographic?1:S(l.spatialReference),p={layerInstanceOrURL:e,point:l,queryParams:{where:c,maximumDistance:e.maximumDistance?e.maximumDistance/h:void 0,objectIds:s?[a.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(p,i)}_toggleVisiblity(e,t){e.forEach((e=>{e.visible=t}))}_updateFeatures(e){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this.currentBestFeature=e[0]}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:r,currentCoverageVisible:a,isAdditionalPointSourcesVisible:s}=this;if(r&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),f(e);for(const e of i)e.imageID===r.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e,symbol:we,visible:a}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e,symbol:ye,visible:s}))}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let i;if(t)i=-90;else{const t=e.x-pe[3],r=e.y-pe[3],a=r/Math.sqrt(t**2+r**2);let s=180*Math.acos(a)/Math.PI;(t<0&&r<0||t<0&&r>0)&&(s*=-1),i=s}i===this.bestFeatureAngle?this.previousFeatureAngle=i:this.bestFeatureAngle=i,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=m(this._referencePointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,i,r){this.displayMessage={key:e,type:t,data:i,map:r}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:i,selectedPoint:r,state:a}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=m(this._crossSymbol)),!r||!t||"image-loaded"!==a||i)return;let s;try{s=await this.worldToImage(r,e),f(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||p.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:r,feature:t})}}async worldToImage(e,t){const{footprintExtent:i}=this,{imageSize:r}=this.activeViewer;if("none"===this.mode||!this.currentBestFeature||!r||!i)return;const{attributes:{location:a,elevationSource:s,cameraHeading:o,elevation:n,cameraHeight:l},elevationSample:c}=this.currentBestFeature;let h=a.clone();const p=await K(n??(a.z??0)-l,{elevationSample:c,elevationSource:s});this.currentBestFeature.elevationSample=p.elevationSample;const u=Array.isArray(e)?e:[e];let d,m=await Promise.all(u.map((e=>new Promise((t=>{if(!e.hasZ)return t(N(e,p));t(e)})))));if(a.spatialReference.isGeographic&&(h=await M(h,Me.WebMercator,t)),m=await Promise.all(m.map((async e=>h.spatialReference.equals(e.spatialReference)?e:await M(e,h.spatialReference,t)))),f(t),"panoramic"===this.mode)d=ie(m,{imageHeight:r[1],imageWidth:r[0],cameraHeading:o,cameraLocation:h});else{const e=Y(this.currentBestFeature.attributes,r[0],r[1]);d=re(m,{...e,cameraLocation:h})}return Array.isArray(e)?d:d[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:r,currentBestFeature:a,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c}=this,{attributes:{objectId:h},elevationSample:p}=a;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),l){const e=[...i,...r,this.bestFeatureCurrentFootprint,s].filter(Se);l.supportsGround&&p&&c?.updateGroundElevation&&c.updateGroundElevation(e,p),n&&e.push(new t({geometry:n.clone(),symbol:ue.clone(),attributes:{imageID:h}})),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,l?.supportsGround&&p&&c?.updateGroundElevation&&c.updateGroundElevation([e],p),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([C()],ze.prototype,"activeLayer",null),e([C({readOnly:!0})],ze.prototype,"activeViewer",null),e([C()],ze.prototype,"additionalFeatures",void 0),e([C({type:s.ofType(t)})],ze.prototype,"additionalCameraLocations",void 0),e([C({type:s.ofType(t)})],ze.prototype,"additionalFootprints",void 0),e([C()],ze.prototype,"areaMeasurementResult",void 0),e([C()],ze.prototype,"bestFeatureAngle",void 0),e([C()],ze.prototype,"bestFeatureCurrentFootprint",void 0),e([C({type:t})],ze.prototype,"bestFeatureFootprint",void 0),e([C({type:Number})],ze.prototype,"brightness",null),e([C({type:Number})],ze.prototype,"contrast",null),e([C()],ze.prototype,"conversionProps",void 0),e([C()],ze.prototype,"coverageFrustums",void 0),e([C()],ze.prototype,"coveragePolygons",void 0),e([C()],ze.prototype,"currentBestFeature",void 0),e([C()],ze.prototype,"currentBestFeatureLocation",void 0),e([C()],ze.prototype,"currentCoverageVisible",void 0),e([C({json:{write:!1}})],ze.prototype,"determineWorkflowForFeature",void 0),e([C()],ze.prototype,"disabled",void 0),e([C()],ze.prototype,"displayMessage",void 0),e([C()],ze.prototype,"displayNewMeasurementButton",void 0),e([C()],ze.prototype,"displayNewAreaMeasurementButton",void 0),e([C()],ze.prototype,"distanceMeasurementResult",void 0),e([C()],ze.prototype,"digitizationLayer",void 0),e([C({readOnly:!0})],ze.prototype,"featureCount",null),e([C()],ze.prototype,"features",void 0),e([C({readOnly:!0})],ze.prototype,"imageGalleryEnabled",null),e([C({readOnly:!0})],ze.prototype,"imageLoaded",null),e([C({readOnly:!0})],ze.prototype,"invalidCameraHeading",null),e([C()],ze.prototype,"imagePointsInView",null),e([C()],ze.prototype,"isAdditionalCoverageVisible",void 0),e([C()],ze.prototype,"isAdditionalPointSourcesVisible",void 0),e([C()],ze.prototype,"layer",void 0),e([C()],ze.prototype,"layerView",null),e([C({readOnly:!0})],ze.prototype,"layerFloorFilterClause",null),e([C({type:Number})],ze.prototype,"localPort",void 0),e([C()],ze.prototype,"mapImageConversionToolState",void 0),e([C({readOnly:!0,value:"none"})],ze.prototype,"mode",null),e([C()],ze.prototype,"navigatorCurrentBestFeature",void 0),e([C({type:s.ofType(t)})],ze.prototype,"overlayedCameraLocations",void 0),e([C()],ze.prototype,"overlayedMapFeatures",void 0),e([C()],ze.prototype,"pointSources",void 0),e([C({readOnly:!0})],ze.prototype,"popupEnabled",null),e([C()],ze.prototype,"previousFeatureAngle",void 0),e([C()],ze.prototype,"referencePoint",null),e([C({readOnly:!0})],ze.prototype,"sectorData",null),e([C()],ze.prototype,"selectedPoint",void 0),e([C({type:Number})],ze.prototype,"sharpness",null),e([C()],ze.prototype,"shouldShowSelectedImage",void 0),e([C()],ze.prototype,"sketch",void 0),e([C()],ze.prototype,"sketchAdapter",void 0),e([C({readOnly:!0})],ze.prototype,"sketchGraphicsLayer",null),e([C({readOnly:!0})],ze.prototype,"state",null),e([C({readOnly:!0})],ze.prototype,"thumbnails",null),e([C()],ze.prototype,"updateFootprint",void 0),e([C()],ze.prototype,"updateFootprintPanorama",void 0),e([C({value:null})],ze.prototype,"view",null),e([C()],ze.prototype,"_adapter",void 0),e([C()],ze.prototype,"_highlightedFeatureHandle",void 0),e([C()],ze.prototype,"_imageViewer",void 0),e([C()],ze.prototype,"_initialCurrentCoverageUpdate",void 0),e([C()],ze.prototype,"_overlays",void 0),e([C({readOnly:!0})],ze.prototype,"_overlaysView",null),e([C()],ze.prototype,"_panoramicViewer",void 0),e([C()],ze.prototype,"_referencePointOnGround",void 0),e([C()],ze.prototype,"_referencePointOnImage",void 0),e([C()],ze.prototype,"_sectorData",void 0),e([C({readOnly:!0})],ze.prototype,"_updatingHandles",void 0),e([C()],ze.prototype,"footprintExtent",void 0),ze=e([k("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],ze);const Te=ze;export{Te as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import"../../symbols.js";import{isSome as i,equals as r}from"../../core/arrayUtils.js";import{createTask as a}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import l from"../../core/Evented.js";import c from"../../core/JSONSupport.js";import{equalsShallow as h}from"../../core/lang.js";import p from"../../core/Logger.js";import{clamp as u}from"../../core/mathUtils.js";import{abortMaybe as d,destroyMaybe as m}from"../../core/maybe.js";import g from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as f,waitTick as v}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{on as b,watch as F,syncAndInitial as _,initial as P}from"../../core/reactiveUtils.js";import{sqlAnd as I}from"../../core/sql.js";import{getMetersPerUnitForSR as S}from"../../core/unitUtils.js";import{property as C}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as V}from"../../core/support/UpdatingHandles.js";import{union as A}from"../../geometry/geometryEngineAsync.js";import{projectWithZConversion as M}from"../../geometry/projection.js";import{isClockwise as R}from"../../geometry/support/coordsUtils.js";import{geographicToWebMercator as O}from"../../geometry/support/webMercatorUtils.js";import j from"../../layers/GraphicsLayer.js";import{searchImages as L}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as z}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as B,computePolygonForInspection as G,resizePolygon as x,checkIfPolygonContainsSelectedPoint as E}from"../../layers/orientedImagery/core/coverageUtils.js";import{isConstantElevation as H,isElevationSource as T}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{imageToWorld as D,imageToWorldPanoramic as U}from"../../layers/orientedImagery/transformations/imageToWorld.js";import N from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as W}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{getInitialAngle as q,convertPixelToHeadingPitch as $,getImageToWorldProperties as J,getUpdateElevationProps as Z,isElevationSampler as K,pointToArray as Q,getImageToWorldPanoramicProperties as X,getWorldToImageProperties as Y,convertHeadingPitchToSphereVertex as ee,or as te}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as ie,worldToImage as re}from"../../layers/orientedImagery/transformations/worldToImage.js";import{getFloorFilterClause as ae}from"../../layers/support/floorFilterUtils.js";import se from"../../rest/support/AttachmentQuery.js";import{scale as oe}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as ne}from"../../views/input/InputManager.js";import le from"../PanoramicViewer.js";import{invalidCameraHeading as ce,sectorsInOrder as he,sectorsRadii as pe}from"./constants.js";import{crossSymbol as ue,crossSymbol3D as de,measurementPolygonSymbol as me,measurementPolylineSymbol as ge,sourcePointSymbol as ye,diamondSymbol as fe,diamondSymbol3D as ve,activeSourcePointSymbol as we}from"./symbols.js";import{isNoAttachmentError as be,getContentType as Fe,isTifOrMrf as _e,filterOILLayerView as Pe,isSceneView as Ie,isGraphic as Se,calculateSegment as Ce,calculateDirection as ke}from"./utils.js";import Ve from"./components/ImageViewer.js";import Ae from"../../geometry/Point.js";import Me from"../../geometry/SpatialReference.js";import Re from"../../symbols/SimpleLineSymbol.js";import Oe from"../../geometry/Multipoint.js";import je from"../../geometry/Polyline.js";import Le from"../../geometry/Polygon.js";const ze={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles",sketchHandles:"sketch-handles"},Be=new Set(["JPG","JPEG"]),Ge=/\.(\w+)$/,xe=e=>"FA"===e,Ee=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let He=class extends(l.EventedMixin(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.conversionProps=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.determineWorkflowForFeature=async(e,t,i)=>{const{currentBestFeature:r,selectedPoint:a,view:s}=this;if(s?.closePopup(),r&&a){this._initialCurrentCoverageUpdate=!0;try{await this._updatePointsAndPolygons(i),await this._loadImage(i)}catch(o){y(o)||(this.loadImageError(o),p.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.displayNewAreaMeasurementButton=!0,this.distanceMeasurementResult=0,this.digitizationLayer=null,this.features=new s,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.navigatorCurrentBestFeature=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new w,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.sketchAdapter=null,this.updateFootprint=async(e,t)=>{"image-loaded"===this.state&&await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new Ve,this._initialCurrentCoverageUpdate=!0,this._overlays=new j({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new le,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._updatingHandles=new V,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDigitizationAdapter=async e=>{const{sketchAdapter:t}=this;if(await this.loadSketch(e),"digitization"===t?.type)return t;const i=import("./adapters/sketch/DigitizationAdapter.js");this._updatingHandles.addPromise(i);const{default:r}=await i;return f(e),this.sketchAdapter=new r({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.loadImageViewer=e=>{this._imageViewer.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.startDigitization=e=>{},this.stopDigitization=e=>{},this.toggleImageAttributes=()=>{d(this._openPopupTask),this._openPopupTask=a((async e=>{const{currentBestFeature:i,popupEnabled:r,layer:a,view:s}=this;if(s?.closePopup(),!(s&&i&&r&&a))return;const{attributes:o,geometry:n}=i,l=new t({geometry:n,attributes:o.toJSON(),layer:a});f(e),await s.openPopup({features:[l],location:o.location.clone()})}))},this._createViewClickHandle=()=>{if(this.removeHandles(ze.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,ne.WIDGET),ze.click)},this._createImageClickHandle=()=>{this.removeHandles(ze.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:i,currentBestFeature:r,footprintExtent:s}=this,o=i?.imageSize;if(!(e&&"none"!==t&&o&&s&&r))return;i.clickAction="pixel-location";let n=null;const l=b((()=>i),"pixel-location",(e=>{this.plotReferencePointOnImage(e),n?.abort(),n=a((async i=>{if(!e)return;const a=await this.getMapPoint(e,{feature:r,imageSize:o,mode:t}).then((e=>{const t=this.view?.spatialReference;return te(!t,e.spatialReference.equals(t))?e:M(e,t)}));f(i),this.plotReferencePointOnGround(a)}))}));this.addHandles(l,ze.imageClick)},this._getImageSourceFromAttachment=async(e,t,i)=>{const r=new se({objectIds:[t]}),a=await e.queryAttachments(r,i),s=a[`${t}`]?.[0],o=s?.url;if(!o)throw new n("NoAttachmentError","no attachments found",{[e.objectIdField]:t,layer:e});return{datasetFormat:s.contentType.split("/")[1].toUpperCase(),url:o}},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:r}=this;if(this.clearGraphics(),!i||!t||"none"===r)return;const{attributes:a}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:l,cameraPitch:c,objectId:h,cameraOrientation:u,location:d}=a,m=(l??0)+(o??0),g=d.spatialReference.isWGS84&&4!==u?.type?O(d):new Ae(d);let v=s;if(xe(s))try{v=await this._getImageSourceFromAttachment(i,h,e)}catch(w){if(y(w))return;return be(w)?(p.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${i.objectIdField}: ${h}`)):(p.getLogger(this).error(w,{[i.objectIdField]:h,layer:i}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${i.objectIdField} ${h}`))}try{await this.loadImageFromSource(v,{imageRotation:m,options:e,pitch:c,yaw:n,mode:r,cameraLocation:g}),f(e),await this.transformAndPlotSelectedLocation(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:i,imageRotation:r,options:a}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:l}=new URL(o);let c=s?n.match(Ge)?.[1]:e.datasetFormat;if(!c){const e=await Fe(o,{...t.options});c=e?.split("/")[1]??"UNKNOWN FORMAT"}switch(i){case"default":this._imageViewer.imageSource={datasetFormat:c.toUpperCase(),url:o.split("?")[0]},this._imageViewer.customParameters=Object.fromEntries(l),this._imageViewer.imageRotation=r??0,await this._imageViewer.loadImage(a);break;case"panoramic":if(Be.has(c.toUpperCase())){const{selectedPoint:e}=this,{pitch:i,yaw:r,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=o;let l=r??0;"number"==typeof n?l=n-l:s&&e&&(l=await q(s,e)-l),this._panoramicViewer.pitch=i??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(a)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:c});break}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");f(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");f(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=a((async t=>{const{pointerType:i,button:r,mapPoint:a}=e;if(("mouse"!==i||0===r)&&a)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(a,{signal:t}))}))},this.plotSelectedPointOnImage=async(e,i)=>{if(await v(i),!e)return;const r=new Ae({...c.isSerializable(e)?e.toJSON():e});if("default"===this.mode)r.x-=.5,r.y=.5-r.y,r.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:r,symbol:ue}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:i}=this._panoramicViewer;if(!i)return;const[r,a]=i,{heading:s,pitch:o}=$(e,r,a),n=ee(s,o);this._crossSymbol=new t({geometry:new Ae(n,Me.WebMercator),symbol:de}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this.selectBestFeature=this.selectBestFeature.bind(this)}initialize(){this.addHandles([F((()=>this.view),(()=>{this.load()}),_),F((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),P),F((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),P),F((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{this._createViewClickHandle(),this._createImageClickHandle()}),_),F((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),_),F((()=>this.currentBestFeature),(async(e,t)=>{d(this._featureChangedTask),this._featureChangedTask=a((async i=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:i}]))),await this._featureChangedTask.promise}),{sync:!0}),F((()=>this.mode),(e=>{switch(this.removeHandles(ze.interactionHandles),e){case"default":this.addHandles(F((()=>this._imageViewer.imagePointsInView),(e=>{e&&(d(this._updateFootprintTask),this._updateFootprintTask=a((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>r(e,t,h)}),ze.interactionHandles);break;case"panoramic":this.addHandles(F((()=>{const{currentBestFeature:e,state:t}=this,{imageSize:i,vfov:r,hfov:a,pitch:s,yaw:o}=this._panoramicViewer;return e&&i&&"image-loading"!==t?[r,a,o,s]:null}),(e=>{if(!e||"image-loading"===this.state)return;const[t,i,r,s]=e;d(this._updateFootprintTask),this._updateFootprintTask=a((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:r,pitch:s},{signal:e})}))}),{..._,equals:(e,t)=>r(e,t,h)}),ze.interactionHandles)}}),_),F((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:i,mode:r,sharpness:a}=this;"default"===r&&(e.brightness=t,e.contrast=i,e.sharpness=a)}),_),F((()=>this.activeViewer?.imageRenderer),(()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}))])}destroy(){this._updateFootprintTask=d(this._updateFootprintTask),this._clickTask=d(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=m(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._crossSymbol=m(this._crossSymbol),this._referencePointOnGround=m(this._referencePointOnGround),this._referencePointOnImage=m(this._referencePointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this._panoramicViewer.destroy()}get activeLayer(){return o(p.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(p.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:i}=this;switch(i){case"default":return e;case"panoramic":return t;default:return null}}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",u(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",u(e,-10,10))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){return _e(this.currentBestFeature?.attributes.imagePath.trim())}get imageLoaded(){return o(p.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===ce}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(Pe(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ae(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:i}=e;return 360===t||i?"panoramic":"default"}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?he.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",u(e,0,1))}get sketchGraphicsLayer(){return this.sketch?.layer}get state(){const{mode:e,disabled:t}=this;if(t)return"disabled";if(!this.isFulfilled())return"loading";if(this.isRejected())return"error";if(this._updatingHandles.updating)return"image-loading";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:i,imageRotation:r}})=>{const a=e.trim();return _e(a)?{url:a,objectId:t,rotation:(i??0)+(r??0)}:null})).filter(i)):null}set view(e){this._set("view",e)}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}digitizeCreate(e,t){const{sketch:i}=this;return i?i.create(e,t):Promise.reject(Ee())}async digitizeDelete(){if(!this.sketch)throw Ee();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw Ee();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw Ee();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw Ee();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw Ee();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw Ee();return this.sketch.update(e,t)}filterByFootprints(e,t){const i=[],r=[],a=[];return e.forEach((e=>{const{layer:{coveragePercent:s},attributes:o}=e;let n;const l=S(e.geometry.spatialReference);o.cameraHeight/=l,o.farDistance/=l,o.nearDistance/=l,H(o.elevationSource)&&(o.elevationSource.constantElevation/=l);const{polygon:c,frustum:h}=B(o);if(n=c.clone(),o.isInspection&&(n=G(o)),s&&(n=x(n,s)),E(n,t)){a.push(e);const{geometry:t,objectId:s,cameraHeight:n,cameraHeading:l}=o,p=t.clone();p.z=n,p.imageID=s,this.pointSources.push(p),l!==ce&&(i.push(c),h&&r.push(h))}})),{features:a,polygons:i,frustums:r}}getMeasurementProperties(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:i,attributes:r}=e,{elevationSource:a,cameraHeight:s}=r,o=J(r,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?M(n,Me.WebMercator):Promise.resolve(n)).then((e=>(n=e,Z((n.z??0)-s,{elevationSample:i,elevationSource:a,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&K(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}async deleteDigitizedFeatures(e){const{digitizationLayer:t}=this;if(!t)throw new n("Digitization layer is not available");return t.queryFeatures({objectIds:e}).then((({features:e})=>t.applyEdits({deleteFeatures:e})))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[he[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:i}=e;if(isNaN(i))return;const r=this._sectorData?.[t];r?.length&&this._updateCurrentBestFeature(r.at(i))}async load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch((e=>{if(!y(e))throw e}))),this}async loadBestImage(e,t){return this.view?.closePopup(),this.displayMessage=null,this.selectedPoint=e.spatialReference.isGeographic?O(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),this._fetchFeaturesWithController(e,t)}loadImageError(e){p.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js");this._updatingHandles.addPromise(t);const{default:i}=await t;f(e),this.sketch=new i({layer:new j,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadSketchAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js");this._updatingHandles.addPromise(t);const{default:i}=await t;if(f(e),this.sketchAdapter=new i({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}if(this.sketch&&this.sketchAdapter){const e=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;e&&this.sketch&&(this.sketch.polygonSymbol=me(e),this.sketch.polylineSymbol=ge(e))}return this.sketchAdapter}async overlayCameraLocations(e){const{activeViewer:i,currentBestFeature:r,overlayedCameraLocations:a,layer:s,mode:o,state:n}=this,l=i?.imageSize;if(!l||!r||!s||"none"===o||n.includes("loading"))return;const{polygon:c}=B(r.attributes);if(i.removeManyGraphics(a.toArray()),a.removeAll(),e){const{features:e}=await s.queryFeatures({where:`${s.objectIdField} <> ${r.attributes.objectId}`,geometry:c,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map((async e=>{const{attributes:i,geometry:a}=e,s=await this.getPixels(a,{feature:r,imageSize:l,mode:o}),n=ye.clone();return n.outline=new Re({color:[0,0,0],width:1}),new t({attributes:i,symbol:n,geometry:s})})));a.addMany(n),i.addManyGraphics(a.toArray())}}overlayGraphicsOnImage(e,t){this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,r=!1){const{activeViewer:a,currentBestFeature:o,mode:n,state:l}=this,c=a?.imageSize;if(!c||!o||"none"===n||l.includes("loading"))return;const{polygon:h}=B(o.attributes),{features:p}=await e.queryFeatures({geometry:h,returnGeometry:!0,outFields:[e.objectIdField]}),u=new s((await Promise.all(p.map((async i=>{const{attributes:a,geometry:s}=i,l=i.symbol?.clone()??e.renderer?.getSymbol(i)?.clone();switch(s?.type){case"point":{const i=await this.getPixels(s,{feature:o,imageSize:c,mode:n});return new t({attributes:a,layer:e,symbol:l,geometry:i,visible:e.visible&&r})}case"polygon":{const{rings:i,spatialReference:h}=s,p=i.map((e=>e.map((([e,t,i])=>new Ae({x:e,y:t,z:i,spatialReference:h}))))),u=await Promise.all(p.map((async e=>this.getPixels(e,{feature:o,imageSize:c,mode:n}).then((e=>e.map(Q))))));return new t({attributes:a,layer:e,symbol:l,geometry:new Le({rings:u,spatialReference:Me.WebMercator}),visible:e.visible&&r})}case"polyline":{const{paths:i,spatialReference:h}=s,p=i.map((e=>e.map((([e,t,i])=>new Ae({x:e,y:t,z:i,spatialReference:h}))))),u=await Promise.all(p.map((async e=>this.getPixels(e,{feature:o,imageSize:c,mode:n}).then((e=>e.map(Q))))));return new t({attributes:a,layer:e,symbol:l,geometry:new je({paths:u,spatialReference:Me.WebMercator}),visible:e.visible&&r})}case"multipoint":{const{points:i,spatialReference:h}=s,p=i.map((([e,t,i])=>new Ae({x:e,y:t,z:i,spatialReference:h}))),u=await this.getPixels(p,{feature:o,imageSize:c,mode:n}).then((e=>e.map(Q)));return new t({attributes:a,layer:e,symbol:l,geometry:new Oe({points:u,spatialReference:Me.WebMercator}),visible:e.visible&&r})}}return null})))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,u)}async getPixels(e,t){const{imageSize:i,mode:r}=t,a=(await this.worldToImage(Array.isArray(e)?e:[e])).map((e=>{if("default"===r)return new Ae({x:e.x-.5,y:.5-e.y,spatialReference:Me.WebMercator});const[t,a]=i,{heading:s,pitch:o}=$(e,t,a),n=ee(s,o);return new Ae(n,Me.WebMercator)}));return Array.isArray(e)?a:a[0]}async getMapPoint(e,t){const{feature:i,mode:r,imageSize:a}=t,{elevationSample:s,attributes:o}=i,{elevationSource:n,location:l,elevation:c,cameraHeight:h}=o;let p=l.clone();p.spatialReference.isGeographic&&(p=await M(p,Me.WebMercator));const u=await Z(c??(l.z??0)-h,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let d;if("elevationSample"in u&&K(u.elevationSample)&&(i.elevationSample=u.elevationSample),"default"===r){const t=J(o,a[0],a[1]);d=await D(Array.isArray(e)?e:[e],{...t,cameraLocation:p},u)}else{const t=X(o,a[0],a[1]);d=await U(Array.isArray(e)?e:[e],{...t,cameraLocation:p},u)}return Array.isArray(e)?d:d[0]}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new Ae({...e.toJSON()}),symbol:fe}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const i=c.isSerializable(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,this._referencePointOnImage=new t({geometry:new Ae({spatialReference:this._imageViewer.imageRenderer.spatialReference.clone(),...i}),symbol:fe}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:i}=this._panoramicViewer;if(!i)return;const[r,a]=i,{heading:s,pitch:o}=$(e,r,a),n=ee(s,o);this._referencePointOnImage=new t({geometry:new Ae(n,Me.WebMercator),symbol:ve}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach((e=>{this._imageViewer.removeManyGraphics(e.toArray())})),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=d(this._clickTask)}async saveDigitizedFeatures(e){const{activeViewer:t,currentBestFeature:r,digitizationLayer:a,mode:s}=this,o=t?.imageSize;if(!o||!r||!s)throw new n("Image size, current best feature and mode are required to save digitized features");if(!a)throw new n("Digitization layer is not available");const l=await Promise.all(e.map((async e=>{const t=e.clone(),{geometry:i}=t;if(i)if(i.type===a.geometryType)switch(i.type){case"point":return t.geometry=await this.getMapPoint({x:i.x+.5,y:.5-i.y},{feature:r,imageSize:o,mode:s}),t;case"polygon":{const e=await Promise.all(i.rings.map((async e=>this.getMapPoint(e.map((([e,t])=>({x:e+.5,y:.5-t}))),{feature:r,imageSize:o,mode:s}))));return t.geometry=new Le({spatialReference:e[0][0].spatialReference,hasZ:!0,rings:e.map((e=>e.map(Q)))}),t}case"polyline":{const e=await Promise.all(i.paths.map((async e=>this.getMapPoint(e.map((([e,t])=>({x:e+.5,y:.5-t}))),{feature:r,imageSize:o,mode:s}))));return t.geometry=new je({spatialReference:e[0][0].spatialReference,hasZ:!0,paths:e.map((e=>e.map(Q)))}),t}case"mesh":case"multipoint":return void p.getLogger(this).warn("saveDigitizedFeatures:unsupported geometry type",{message:"only point, polygon, polyline are supported for digitization",geometryType:i.type,graphic:t})}else p.getLogger(this).warn("saveDigitizedFeatures:geometry type mismatch",{expected:a.geometryType,actual:i.type,graphic:t})}))),c=l.filter(i);return a.applyEdits({addFeatures:c}).then((e=>{const{addFeatureResults:t}=e;let i=0;const r=l.map((e=>{const r=t[i++];return e?r:{error:new n("Error in saving digitized features"),objectId:null,globalId:null}}));return{...e,addFeatureResults:r}}))}async searchBestImage(e,t){try{const i=await L(e,t);i&&await this._processFeatureResponse(i,e.point,{signal:t?.signal})}catch(i){y(i)||(this.setMessage("imageLoadError","error",i.message),p.getLogger(this).error("error occurred while finding best image",i))}}selectBestFeature(e){this.currentBestFeature=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach((t=>{this._toggleVisiblity(t,e)}))}toggleOverlayMapFeatures(e,t){const i=this.overlayedMapFeatures.get(e);i&&this._toggleVisiblity(i,t)}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:i}=e;let r=!1,a=!1;const s=this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=t.spatialReference.equals(s.spatialReference)?t:await M(t,s.spatialReference);r=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await M(t,s.spatialReference);a=s.extent.contains(e);break}}if(!r&&!a)return void this.clearReferencePointOnImage();const o=await this.worldToImage(t,i);if(o)return f(i),this.plotReferencePointOnImage(o),{x:o.x,y:o.y};this.clearReferencePointOnImage()}updateSuitabilities(e){e.sort(((e,t)=>e.suitability-t.suitability)),this._suitabilities=e;const t=this._suitabilities.map((({feature:e})=>e));this._initialCurrentCoverageUpdate=!0,this._updateFeatures(t),this._groupFeaturesBySectors()}async _fetchFeatures(e,t){if(!this.view)return;const i=this.layer;if(i){const r={include:i},a=this.view.toScreen(e);if(!a)return;const s=await this.view.hitTest(a,r);return this._processHitTestResults(i,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(i){if(y(i))return;this.setMessage("imageLoadError","error"),p.getLogger(this).error("error occurred while fetching features",i)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:i,features:r,invalidCameraHeading:a}=this;if(!e||!t||!i||!r||a)return void(this._sectorData=null);this._sectorData={};for(const c of he)this._sectorData[c]=new s;const o=e.map(((e,t)=>({...e,featureIndex:t})));o.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const n=o.map((({distance:e})=>e)),l=Math.max(...n);o.forEach((e=>{const{distance:t,angle:i,featureIndex:a}=e,s=t/l*pe[2],o=Ce(t,l),n=ke(i);if(!this._sectorData)return;const c=pe[3]+s*Math.sin(i*Math.PI/180),h=pe[3]+s*Math.cos(i*Math.PI/180);let p;const u=r.at(a),d=u===this.currentBestFeature,m=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(d&&m)p=-90;else{const e=c-pe[3],t=h-pe[3],i=t/Math.sqrt(e**2+t**2);let r=180*Math.acos(i)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(r*=-1),p=r}const g=""===o?n:`${o}_${n}`;d&&(p===this.bestFeatureAngle?this.previousFeatureAngle=p:this.bestFeatureAngle=p,this.navigatorCurrentBestFeature=m?null:{x:c,y:h,direction:n});const y=this._sectorData[g];y.add({angle:i,featureIndex:a,x:c,y:h,objectID:u.attributes.objectId,sector:g,featureIndexInSector:y.length})}))}async _processFeatureResponse(e,t,i){const{features:r}=e;if(!r?.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll();const{features:a,polygons:s,frustums:o}=this.filterByFootprints(r,t);if(!a.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);let n;if(this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o),s[0]){let e=new Le({spatialReference:s[0].spatialReference});for(const i of s)e=await A(e,i);const t=[];for(const{geometry:i}of a)e.contains(i)||t.push([i.x,i.y]);if(t.sort(((e,t)=>+R([e,t]))),e.addRing(t),this.footprintExtent=oe(e.extent,2,2),this.view?.supportsGround)try{n=await this.view.map.ground.createElevationSampler(this.footprintExtent,i)}catch(l){y(l)||p.getLogger(this).error(l)}}if((n||a[0].attributes.elevationSource)&&this.footprintExtent){const e=a[0].attributes.elevationSource;T(e)&&!n&&(n=await W({extent:this.footprintExtent,lod:e.lod,url:e.url,rasterFunction:e.rasterFunction}));const i=await Z((a[0].attributes.location.z??0)-a[0].attributes.cameraHeight,{elevationSample:n,elevationSource:e,extent:this.footprintExtent}),[r,...s]=await N([t,...a.map((e=>e.attributes.geometry.clone()))],i);a[0].elevationSample=n??i.elevationSample,t.elevation=r.z,a.forEach(((e,t)=>{e.attributes.elevation=s[t].z}))}a[0].elevationSample&&a.forEach((e=>{e.elevationSample=a[0].elevationSample})),this._suitabilities=z({features:a,selectedPoint:t,camera:Ie(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities)}async _processHitTestResults(e,t,i){const{screenPoint:r,results:[a]}=t,s="graphic"===a?.type&&this.shouldShowSelectedImage,o=a?.mapPoint??this.view?.toMap(r);if(!o)return;const{layerFloorFilterClause:n}=this,l=e.spatialReference.equals(o.spatialReference)?o:await M(o,e.spatialReference),c=I("1=1",I(e.definitionExpression,n)),h=l.spatialReference.isGeographic?1:S(l.spatialReference),p={layerInstanceOrURL:e,point:l,queryParams:{where:c,maximumDistance:e.maximumDistance?e.maximumDistance/h:void 0,objectIds:s?[a.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(p,i)}_toggleVisiblity(e,t){e.forEach((e=>{e.visible=t}))}_updateFeatures(e){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this.currentBestFeature=e[0]}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:r,currentCoverageVisible:a,isAdditionalPointSourcesVisible:s}=this;if(r&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),f(e);for(const e of i)e.imageID===r.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e,symbol:we,visible:a}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e,symbol:ye,visible:s}))}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let i;if(t)i=-90;else{const t=e.x-pe[3],r=e.y-pe[3],a=r/Math.sqrt(t**2+r**2);let s=180*Math.acos(a)/Math.PI;(t<0&&r<0||t<0&&r>0)&&(s*=-1),i=s}i===this.bestFeatureAngle?this.previousFeatureAngle=i:this.bestFeatureAngle=i,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=m(this._referencePointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,i,r){this.displayMessage={key:e,type:t,data:i,map:r}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:i,selectedPoint:r,state:a}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=m(this._crossSymbol)),!r||!t||"image-loaded"!==a||i)return;let s;try{s=await this.worldToImage(r,e),f(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||p.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:r,feature:t})}}async worldToImage(e,t){const{footprintExtent:i}=this,{imageSize:r}=this.activeViewer;if("none"===this.mode||!this.currentBestFeature||!r||!i)return;const{attributes:{location:a,elevationSource:s,cameraHeading:o,elevation:n,cameraHeight:l},elevationSample:c}=this.currentBestFeature;let h=a.clone();const p=await Z(n??(a.z??0)-l,{elevationSample:c,elevationSource:s});this.currentBestFeature.elevationSample=p.elevationSample;const u=Array.isArray(e)?e:[e];let d,m=await Promise.all(u.map((e=>new Promise((t=>{if(!e.hasZ)return t(N(e,p));t(e)})))));if(a.spatialReference.isGeographic&&(h=await M(h,Me.WebMercator,t)),m=await Promise.all(m.map((async e=>h.spatialReference.equals(e.spatialReference)?e:await M(e,h.spatialReference,t)))),f(t),"panoramic"===this.mode)d=ie(m,{imageHeight:r[1],imageWidth:r[0],cameraHeading:o,cameraLocation:h});else{const e=Y(this.currentBestFeature.attributes,r[0],r[1]);d=re(m,{...e,cameraLocation:h})}return Array.isArray(e)?d:d[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:r,currentBestFeature:a,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c}=this,{attributes:{objectId:h},elevationSample:p}=a;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),l){const e=[...i,...r,this.bestFeatureCurrentFootprint,s].filter(Se);l.supportsGround&&p&&c?.updateGroundElevation&&c.updateGroundElevation(e,p),n&&e.push(new t({geometry:n.clone(),symbol:ue.clone(),attributes:{imageID:h}})),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,l?.supportsGround&&p&&c?.updateGroundElevation&&c.updateGroundElevation([e],p),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([C()],He.prototype,"activeLayer",null),e([C({readOnly:!0})],He.prototype,"activeViewer",null),e([C()],He.prototype,"additionalFeatures",void 0),e([C({type:s.ofType(t)})],He.prototype,"additionalCameraLocations",void 0),e([C({type:s.ofType(t)})],He.prototype,"additionalFootprints",void 0),e([C()],He.prototype,"areaMeasurementResult",void 0),e([C()],He.prototype,"bestFeatureAngle",void 0),e([C()],He.prototype,"bestFeatureCurrentFootprint",void 0),e([C({type:t})],He.prototype,"bestFeatureFootprint",void 0),e([C({type:Number})],He.prototype,"brightness",null),e([C({type:Number})],He.prototype,"contrast",null),e([C()],He.prototype,"conversionProps",void 0),e([C()],He.prototype,"coverageFrustums",void 0),e([C()],He.prototype,"coveragePolygons",void 0),e([C()],He.prototype,"currentBestFeature",void 0),e([C()],He.prototype,"currentBestFeatureLocation",void 0),e([C()],He.prototype,"currentCoverageVisible",void 0),e([C({json:{write:!1}})],He.prototype,"determineWorkflowForFeature",void 0),e([C()],He.prototype,"disabled",void 0),e([C()],He.prototype,"displayMessage",void 0),e([C()],He.prototype,"displayNewMeasurementButton",void 0),e([C()],He.prototype,"displayNewAreaMeasurementButton",void 0),e([C()],He.prototype,"distanceMeasurementResult",void 0),e([C()],He.prototype,"digitizationLayer",void 0),e([C({readOnly:!0})],He.prototype,"featureCount",null),e([C()],He.prototype,"features",void 0),e([C({readOnly:!0})],He.prototype,"imageGalleryEnabled",null),e([C({readOnly:!0})],He.prototype,"imageLoaded",null),e([C({readOnly:!0})],He.prototype,"invalidCameraHeading",null),e([C()],He.prototype,"imagePointsInView",null),e([C()],He.prototype,"isAdditionalCoverageVisible",void 0),e([C()],He.prototype,"isAdditionalPointSourcesVisible",void 0),e([C()],He.prototype,"layer",void 0),e([C()],He.prototype,"layerView",null),e([C({readOnly:!0})],He.prototype,"layerFloorFilterClause",null),e([C({type:Number})],He.prototype,"localPort",void 0),e([C()],He.prototype,"mapImageConversionToolState",void 0),e([C({readOnly:!0,value:"none"})],He.prototype,"mode",null),e([C()],He.prototype,"navigatorCurrentBestFeature",void 0),e([C({type:s.ofType(t)})],He.prototype,"overlayedCameraLocations",void 0),e([C()],He.prototype,"overlayedMapFeatures",void 0),e([C()],He.prototype,"pointSources",void 0),e([C({readOnly:!0})],He.prototype,"popupEnabled",null),e([C()],He.prototype,"previousFeatureAngle",void 0),e([C()],He.prototype,"referencePoint",null),e([C({readOnly:!0})],He.prototype,"sectorData",null),e([C()],He.prototype,"selectedPoint",void 0),e([C({type:Number})],He.prototype,"sharpness",null),e([C()],He.prototype,"shouldShowSelectedImage",void 0),e([C()],He.prototype,"sketch",void 0),e([C()],He.prototype,"sketchAdapter",void 0),e([C({readOnly:!0})],He.prototype,"sketchGraphicsLayer",null),e([C({readOnly:!0})],He.prototype,"state",null),e([C({readOnly:!0})],He.prototype,"thumbnails",null),e([C()],He.prototype,"updateFootprint",void 0),e([C()],He.prototype,"updateFootprintPanorama",void 0),e([C({value:null})],He.prototype,"view",null),e([C()],He.prototype,"_adapter",void 0),e([C()],He.prototype,"_highlightedFeatureHandle",void 0),e([C()],He.prototype,"_imageViewer",void 0),e([C()],He.prototype,"_initialCurrentCoverageUpdate",void 0),e([C()],He.prototype,"_overlays",void 0),e([C({readOnly:!0})],He.prototype,"_overlaysView",null),e([C()],He.prototype,"_panoramicViewer",void 0),e([C()],He.prototype,"_referencePointOnGround",void 0),e([C()],He.prototype,"_referencePointOnImage",void 0),e([C()],He.prototype,"_sectorData",void 0),e([C({readOnly:!0})],He.prototype,"_updatingHandles",void 0),e([C()],He.prototype,"footprintExtent",void 0),He=e([k("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],He);const Te=He;export{Te as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import i from"../../../../core/Collection.js";import s from"../../../../core/ReactiveMap.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import{checkImageGeometryField as a}from"../../digitizationUtils.js";import{SketchHandlerMixin as d}from"../../mixins/SketchHandlerMixin.js";let n=class extends(d(t)){constructor(e){super(e),this.savedGraphics=new i,this.type="digitization",this.pendingGraphics=new s}handleCreate(e){const{state:t,graphic:s,tool:r}=e,{digitizationLayer:o}=this.viewModel,{pendingGraphics:d}=this,n=o?.fields.find((({name:e,alias:t,type:i})=>a(e,t,i)));if("complete"===t&&n&&o){if(s?.geometry){s.sourceLayer=o,s.attributes=s.attributes??{[n.name]:btoa(JSON.stringify(s.geometry.toJSON()))},d.has(o.id)||d.set(o.id,new i);d.get(o.id).add(s)}this.viewModel.sketch?.create(r)}}handleDelete(e){const{digitizationLayer:t}=this.viewModel;if(!t)return;const{graphics:i}=e;this.pendingGraphics.get(t.id)?.removeMany(i),this.savedGraphics.removeMany(i),this.viewModel.deleteDigitizedFeatures(i.map((({attributes:e,layer:t})=>{const i=t?.objectIdField;return i?e[i]:null})).filter(Boolean))}handleDestroy(){this.savedGraphics.destroy(),this.pendingGraphics=null}handleDuplicate(e){const{graphics:t}=e,{digitizationLayer:i}=this.viewModel;i&&this.pendingGraphics.get(i.id)?.addMany(t)}handleUpdate(e){const{toolEventInfo:t,graphics:i}=e,s=i.filter((({sourceLayer:e})=>e===this.viewModel.digitizationLayer));s.length===i.length?t&&this.viewModel.sketch?.undo():this.viewModel.sketch?.update(s)}async save(){const{digitizationLayer:e}=this.viewModel;if(!e)return;const t=this.pendingGraphics.get(e.id),i=t?.toArray()??[],{addFeatureResults:s}=await this.viewModel.saveDigitizedFeatures(i),r=s.reduce(((e,{objectId:t,globalId:s,error:r},o)=>{const a=i[o],{attributes:d}=a;return r?e.error.push(a):(t&&(d[t]=t),s&&(d[s]=s),e.success.push(a)),e}),{success:[],error:[]});this.savedGraphics.addMany(r.success),t?.removeAll(),t?.addMany(r.error)}};e([r()],n.prototype,"savedGraphics",void 0),e([r()],n.prototype,"type",void 0),e([r()],n.prototype,"pendingGraphics",void 0),n=e([o("esri.widgets.OrientedImageryViewer.adapters.sketch.DigitizationAdapter")],n);const c=n;export{c as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Identifiable.js";import{watch as s,syncAndInitial as i}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import r from"../../Widget.js";import{css as
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Identifiable.js";import{watch as s,syncAndInitial as i}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import r from"../../Widget.js";import{css as c}from"../css.js";import l from"./OverlayLayersList.js";import{loadCalciteComponents as n}from"../../support/componentsUtils.js";import{globalCss as p}from"../../support/globalCss.js";import"../../support/widgetUtils.js";import{tsx as h}from"../../support/jsxFactory.js";let m=class extends(t.IdentifiableMixin(r)){constructor(){super(...arguments),this.closed=!1,this.layerList=new l({selectionMode:"multiple"}),this.listItemCreatedFunction=null,this.messages=null,this.showCameraLocations=!1,this.showMapFeatures=!1,this.viewModel=null}initialize(){this.addHandles([s((()=>({view:this.view,layerList:this.layerList})),(({view:e,layerList:t})=>{t.view=e}),i),s((()=>({layerList:this.layerList,listItemCreatedFunction:this.listItemCreatedFunction})),(({layerList:e,listItemCreatedFunction:t})=>{e.listItemCreatedFunction=t}),i)])}loadDependencies(){return n({list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),action:()=>import("@esri/calcite-components/dist/components/calcite-action")})}get view(){return this.viewModel?.view??null}_onCalcitePanelClose(e){e.stopPropagation(),this.closed=!0}_renderCameraLocationsSwitch(e){return h("calcite-list-item",{bind:this,label:this.messages?.overlayCameraLocations,onclick:this._toggleShowCameraLocations},h("calcite-switch",{bind:this,checked:e,class:c.overlaysSwitch,onchange:this._toggleShowCameraLocations,scale:"s",slot:"actions-end"}))}_renderOverlayMapFeatures(e){return h("calcite-list-item",{bind:this,label:this.messages?.overlayMapFeatures,onclick:this._toggleShowMapFeatures},h("calcite-switch",{bind:this,checked:e,class:c.overlaysSwitch,onchange:this._toggleShowMapFeatures,scale:"s",slot:"actions-end"}))}_renderList(e){return e?h("div",{class:c.imageOverlaysLayerList},this.layerList.render()):null}_renderPanel(){const{closed:e,messages:t,showCameraLocations:s,showMapFeatures:i}=this;return h("calcite-panel",{bind:this,closable:!0,closed:e,heading:t?.imageOverlays,onCalcitePanelClose:this._onCalcitePanelClose},h("calcite-action",{bind:this,icon:"cursor",label:t.selectFeature,onclick:e=>{const t=e.target;t.active=!t.active,this.emit("select-digitized",t.active)},scale:"s",slot:"header-actions-end",text:t.selectFeature}),h("calcite-action",{bind:this,icon:"save",label:"save",onclick:()=>{this.emit("save")},scale:"s",slot:"header-actions-end",text:"save"}),h("calcite-action",{bind:this,icon:"trash",label:"delete",onclick:()=>{this.emit("delete-digitized")},scale:"s",slot:"header-actions-end",text:t.deleteFeature}),h("calcite-list",{label:t?.imageOverlays},this._renderCameraLocationsSwitch(s),this._renderOverlayMapFeatures(i)),this._renderList(i))}_toggleShowCameraLocations(e){e.stopPropagation(),this.showCameraLocations=!this.showCameraLocations}_toggleShowMapFeatures(e){e.stopPropagation(),this.showMapFeatures=!this.showMapFeatures}render(){const e=this.layerList.operationalItems.items.length,t=this.showMapFeatures&&0===e,s=this.showMapFeatures&&e>0,i={[p.widget]:!0,[c.imageOverlaysNoResult]:t,[c.imageOverlaysIncreasedHeight]:s,[c.imageOverlays]:!t&&!s};return h("div",{class:this.classes(i)},this._renderPanel())}};e([o()],m.prototype,"closed",void 0),e([o()],m.prototype,"layerList",void 0),e([o()],m.prototype,"listItemCreatedFunction",void 0),e([o()],m.prototype,"messages",void 0),e([o()],m.prototype,"showCameraLocations",void 0),e([o()],m.prototype,"showMapFeatures",void 0),e([o()],m.prototype,"view",null),e([o()],m.prototype,"viewModel",void 0),m=e([a("esri.widgets.OrientedImageryViewer.components.ImageOverlays")],m);const d=m;export{d as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{or as e}from"../../layers/orientedImagery/transformations/utils.js";import{isEditableLayer as
|
|
5
|
+
import{or as e}from"../../layers/orientedImagery/transformations/utils.js";import{isEditableLayer as t}from"../../layers/support/editableLayers.js";const o="oiobjectid",r="imagegeometry";function n(e,t){return s(o,e,t)}function i(e,t,o){return s(r,e,t)&&"blob"===o}function s(t,o,r){return e(o.toLowerCase()===t,r?.toLowerCase()===t)}function a(e){return"point"===e||"polygon"===e||"polyline"===e}function l(e){return t(e)&&a(e.geometryType)&&2===e.fields.filter((({name:e,type:t,alias:o})=>i(e,o,t)||n(e,o))).length}export{i as checkImageGeometryField,n as checkOiObjectIdField,l as isValidDigitizationLayer};
|