@arcgis/core 4.28.0-rc.2 → 4.28.0-rc.3
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/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{0e354096ad8817971eed.js → 02d235849ba93541d7ad.js} +1 -1
- package/assets/esri/core/workers/chunks/0422c5160491fbcf01dc.js +1 -0
- package/assets/esri/core/workers/chunks/224e79f6c172da444e0a.js +1 -0
- package/assets/esri/core/workers/chunks/{ca3d5803cdf035d7389d.js → 30776102fbab294bfe7b.js} +1 -1
- package/assets/esri/core/workers/chunks/{61dec8399919b278b636.js → 3ac9001b19a90faf5573.js} +1 -1
- package/assets/esri/core/workers/chunks/41081c921037e543a22f.js +1 -0
- package/assets/esri/core/workers/chunks/4564a7885d045a850887.js +1 -0
- package/assets/esri/core/workers/chunks/4adf3a8c6b49c381a633.js +1 -0
- package/assets/esri/core/workers/chunks/{2721aa6b6941b28b9758.js → 63c8bf00120a4e67f5b0.js} +1 -1
- package/assets/esri/core/workers/chunks/74951370a341f02d3714.js +1 -0
- package/assets/esri/core/workers/chunks/{fa6103e3d4e857b0035b.js → 78e2fa121760383b08ec.js} +9 -6
- package/assets/esri/core/workers/chunks/7b8377b3a9f78f9d3613.js +1 -0
- package/assets/esri/core/workers/chunks/{fd28400141a6751327ae.js → 7cf7f2b991a7cbdad2ce.js} +1 -1
- package/assets/esri/core/workers/chunks/{1a723bb4a341f645e5fe.js → 83b8141f0c80e3448012.js} +1 -1
- package/assets/esri/core/workers/chunks/934c32c49bb9e21482fd.js +1 -0
- package/assets/esri/core/workers/chunks/969a82b674eda9f8720f.js +1 -0
- package/assets/esri/core/workers/chunks/a1e16c33f1843dbdce26.js +1 -0
- package/assets/esri/core/workers/chunks/{d07235ce2765a25b9be4.js → a50ec5b647a160199cb2.js} +1 -1
- package/assets/esri/core/workers/chunks/{77923afde29ae1ff10ca.js → b6e86e179f99b5cf8dff.js} +1 -1
- package/assets/esri/core/workers/chunks/c3ddf5dbc34f118002df.js +1 -0
- package/assets/esri/core/workers/chunks/{7b3d5f044c96e2c2af11.js → d191267d91a53db42956.js} +1 -1
- package/assets/esri/core/workers/chunks/ffa330a19a09679212fb.js +1 -0
- package/assets/esri/themes/base/widgets/_BasemapGallery.scss +3 -9
- package/assets/esri/themes/base/widgets/_Legend.scss +1 -1
- package/assets/esri/themes/base/widgets/_TimeZoneLabel.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/geometry/support/meshUtils/georeference.js +1 -1
- package/interfaces.d.ts +1254 -262
- package/kernel.js +1 -1
- package/layers/GroupLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/data/queryValidationUtils.js +1 -1
- package/layers/mixins/ArcGISMapService.js +1 -1
- package/layers/save/groupLayerUtils.js +1 -1
- package/layers/save/utils.js +1 -1
- package/layers/support/ImageElement.js +1 -1
- package/layers/support/Sublayer.js +1 -1
- package/layers/support/Subtype.d.ts +4 -0
- package/layers/support/Subtype.js +1 -1
- package/layers/support/imageryRendererUtils.js +1 -1
- package/networks/Network.js +1 -1
- package/package.json +1 -1
- package/portal/support/jsonContext.js +1 -1
- package/portal/support/layersLoader.js +1 -1
- package/rest/featureService/FeatureService.d.ts +4 -0
- package/rest/featureService/FeatureService.js +1 -1
- package/rest/featureService/utils.d.ts +4 -0
- package/rest/query/operations/query.js +1 -1
- package/support/basemapUtils.js +1 -1
- package/support/revision.js +1 -1
- package/versionManagement/VersionManagementService.d.ts +4 -0
- package/versionManagement/VersionManagementService.js +1 -1
- package/views/2d/engine/vectorTiles/VTLPainter3D.js +1 -1
- package/views/2d/engine/webgl/Overlay.js +1 -1
- package/views/2d/input/handlers/KeyPan.js +1 -1
- package/views/2d/interactive/editingTools/manipulations/DragManipulation.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +1 -1
- package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/MediaLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerWorker.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/defaultSymbolComplexity.js +1 -1
- package/views/3d/layers/graphics/elevationAlignPointsInFeatures.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/support/MemoryController.js +1 -1
- package/views/3d/support/PBFDecoder.js +1 -1
- package/views/3d/support/ResourceController.js +1 -1
- package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/core/FBOPool.js +5 -0
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js +9 -6
- package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
- package/views/3d/webgl-engine/lib/Camera.js +1 -1
- package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/Texture.js +1 -1
- package/views/3d/webgl-engine/lib/textureUtils.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
- package/views/interactive/snapping/featureSources/FeatureCollectionSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
- package/views/interactive/snapping/featureSources/snappingCandidateElevationAlignment.js +1 -1
- package/widgets/BasemapGallery.js +1 -1
- package/widgets/DirectionalPad.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/Features.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/TimeSlider.js +1 -1
- package/widgets/TimeZoneLabel.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/assets/esri/core/workers/chunks/00da3c16741a9bc47f3a.js +0 -1
- package/assets/esri/core/workers/chunks/0e4646d14fa0775bf463.js +0 -1
- package/assets/esri/core/workers/chunks/4e0bf30da4281070e453.js +0 -1
- package/assets/esri/core/workers/chunks/51b8913dff24e693bd25.js +0 -1
- package/assets/esri/core/workers/chunks/5e907ec0ee1565b5fbbc.js +0 -1
- package/assets/esri/core/workers/chunks/7388fd97e7b1a2142744.js +0 -1
- package/assets/esri/core/workers/chunks/92d8f75e616afa5c761e.js +0 -1
- package/assets/esri/core/workers/chunks/a877a4826cd6a46ec99b.js +0 -1
- package/assets/esri/core/workers/chunks/b251d8a856dc8b9406e0.js +0 -1
- package/assets/esri/core/workers/chunks/d8c696da42f8f8919b83.js +0 -1
- package/assets/esri/core/workers/chunks/fac3e57784d7f37053af.js +0 -1
- package/assets/esri/core/workers/chunks/fc95b1a36ed68b851400.js +0 -1
- package/widgets/DirectionalPad/DirectionalPadViewModel.d.ts +0 -4
- package/widgets/DirectionalPad.d.ts +0 -4
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/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{isSome as r}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import s from"../../core/Evented.js";import{isSerializable as o}from"../../core/JSONSupport.js";import a from"../../core/Logger.js";import{clamp as n}from"../../core/mathUtils.js";import{destroyMaybe as l}from"../../core/maybe.js";import{once as h,on as c,watch as g,initial as u}from"../../core/reactiveUtils.js";import{createScreenPoint as m}from"../../core/screenUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import{ensureType as p}from"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import _ from"../../geometry/Extent.js";import{geographicToWebMercator as v}from"../../geometry/support/webMercatorUtils.js";import f from"../../layers/GraphicsLayer.js";import P from"../../layers/ImageryTileLayer.js";import{searchImages as C}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as I}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as b,computePolygonForInspection as w,resizePolygon as F,checkIfPolygonContainsSelectedPoint as M}from"../../layers/orientedImagery/core/coverageUtils.js";import{updateElevation as S,transformPoints as x}from"../../layers/orientedImagery/transformations/groundToImageUtils.js";import{transformPoints as V}from"../../layers/orientedImagery/transformations/imageToGroundUtils.js";import j from"../../layers/support/RasterFunction.js";import{convolutionKernel as A}from"../../layers/support/rasterFunctionConstants.js";import O from"../../layers/support/rasterDatasets/RasterFactory.js";import G from"../../rest/support/AttachmentQuery.js";import D from"../../views/MapView.js";import{getResolutionToScaleFactor as R}from"../../views/2d/viewpointUtils.js";import{projectWithEngineOrService as L}from"../../views/support/projectionUtils.js";import{sectorsInOrder as E,sectorsRadii as U}from"./constants.js";import{activePolygonSymbol as T,polygonSymbol as N,activeSourcePointSymbol as k,sourcePointSymbol as H,crossSymbol as J,diamondSymbol as z}from"./symbols.js";import{isTifOrMrf as $,isSceneView as q,isGraphic as B}from"./utils.js";import W from"../../geometry/Polygon.js";import Z from"../../geometry/SpatialReference.js";import Q from"../../geometry/Point.js";const K={click:"view-click",view:"view",viewLayers:"view-layers",mapLayers:"map-layers",layerViews:"layer-views",layerListMode:"layer-list-mode",children:"children",registerLayerSelection:"register-layer-selection",plotPointOnGround:"plot-point-on-ground"},X=e=>/^https?:/i.test(e),Y=e=>"FA"===e;let ee=class extends s.EventedAccessor{constructor(e){super(e),this.activeLayer=null,this.shouldShowSelectedImage=!1,this.coverageFrustums=new i,this.coveragePolygons=new i,this.currentCoverageVisible=!0,this.disabled=!1,this.displayMessage=null,this.pointSources=new i,this.previousFeatureAngle=0,this.selectedFeature=null,this.selectedFeatureAngle=0,this.selectedPoint=null,this.features=new i,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.localPort=null,this.mapImageConversionToolState=!1,this.navigatorSelectedFeature=null,this._additionalCoveragePolygons=new i,this._additionalFeatureGraphics=new i,this._currentCoveragePolygon=null,this._currentImage=null,this._fetchFeaturesController=null,this._imageViewer=null,this._initialCurrentCoveragePolygon=null,this._initialCurrentCoverageUpdate=!0,this._overlays=null,this._plotPolygons=!1,this._initialPreviousCoveragePolygon=null,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._crossSymbol=null,this._panConstraint=null,this._scaleConstraint=null,this._suitabilities=null,this._transformController=new AbortController,this._updateCoverageController=null,this.handleSectorClick=this.handleSectorClick.bind(this),this.loadViewer=this.loadViewer.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this)}initialize(){h((()=>this.view?.ready)).then((()=>{this._overlays=new f({listMode:"hide"}),this.view.map.layers.add(this._overlays)})),this.addHandles([c((()=>this.view),"click",(e=>{if(this.view.ready&&!this.disabled&&this.active&&(e.stopPropagation(),e.preventDefault(),"mouse"!==e.pointerType||0===e.button))if(this.mapImageConversionToolState)this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.selectedFeature,selectedLocation:e.mapPoint,options:{signal:this._transformController?.signal}});else{const{mapPoint:t}=e;this.displayMessage=null,this.selectedPoint=t.spatialReference.isGeographic?v(t):t.clone(),this.features.removeAll(),this._additionalCoveragePolygons.removeAll(),this._additionalFeatureGraphics.removeAll(),this._currentCoveragePolygon=l(this._currentCoveragePolygon),this._overlays?.removeAll(),this.selectedFeature=null,this._fetchFeaturesWithController(e)}})),g((()=>this.view?.map?.allLayers?.length),(e=>{e&&this._overlays&&this.view.map.layers.reorder(this._overlays,e-1)}),{initial:!0}),g((()=>this.activeLayer?.visible??!1),(e=>{this._overlays&&(this._overlays.visible=e)}))],K.view)}destroy(){this._cancelCurrentCoverageUpdate(),this._cancelFetchingFeatures(),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this._additionalCoveragePolygons.destroy(),this._additionalFeatureGraphics.destroy(),this._currentImage=l(this._currentImage),this._imageViewer=l(this._imageViewer),this._initialCurrentCoveragePolygon=l(this._initialCurrentCoveragePolygon),this._currentCoveragePolygon=l(this._currentCoveragePolygon),this._crossSymbol=l(this._crossSymbol),this._referencePointOnGround=l(this._referencePointOnGround),this._referencePointOnImage=l(this._referencePointOnImage),this._overlays&&this.view?.map.remove(this._overlays),this._overlays=l(this._overlays)}get active(){return!0===this.view?.map?.allLayers.some((e=>"oriented-imagery"===e.type&&e.loaded))}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",n(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",n(e,-10,10))}get currentImageView(){return this._imageViewer?.allLayerViews.find((e=>e.layer===this._currentImage))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){return $(this.selectedFeature?.attributes.imagePath.trim())}get imageLoaded(){return this._currentImage?.loaded??!1}get updating(){return"loading"===this._currentImage?.loadStatus||!!this._fetchFeaturesController}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",n(e,0,1))}get sectorData(){const{_sectorData:e}=this;if(e)return E.map((t=>e[t]))}get state(){const{active:e,activeLayer:t}=this;return e||t?this._currentImage?.loadStatus?`image-${this._currentImage.loadStatus}`:"ready":"disabled"}get thumbnails(){const{features:e}=this;return e?new i(e.map((({attributes:{imagePath:e,objectId:t}})=>{const r=e.trim();return $(r)?{url:r,objectId:t}:null})).filter(r)):null}set view(e){this._set("view",e)}getCurrentCoveragePolygon(){return this._currentCoveragePolygon}getSelectedFeature(){return this.selectedFeature}getSelectedFeaturePolygon(){return this._initialCurrentCoveragePolygon}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[E[e]];t?.length&&this._updateSelectedFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:r}=e;if(isNaN(r))return;const i=this._sectorData?.[t];i?.length&&this._updateSelectedFeature(i.at(r))}loadViewer(e){const t=new Map,r={wkid:0};this._imageViewer=new D({container:e,map:t,spatialReferance:r,constraints:{snapToZoom:!1,rotationEnabled:!1},ui:{components:["zoom"]}}),h((()=>!0===this._imageViewer?.stationary)).then((()=>{this.setMessage("onLoadMessage","info")})),this._imageViewer.addHandles([this._imageViewer.on("click",(async e=>{if(0===e.button&&this._currentImage&&this.mapImageConversionToolState&&this._currentImage?.fullExtent){const{xmin:t,xmax:r,ymin:i,ymax:s}=this._currentImage.fullExtent,{x:o,y:a}=e.mapPoint;if(t>o||r<o||s<a||i>a)return;this.plotReferencePointOnImage(e.mapPoint);const n=this.getSelectedFeature();if(n){const t=(await V([e.mapPoint.toJSON()],{feature:n,currentCoveragePolygon:this.getSelectedFeaturePolygon(),imageProperties:this._currentImage.rasterInfo,options:{signal:this._transformController?.signal}}))[0];t&&this.plotReferencePointOnGround(t)}}})),g((()=>[this._imageViewer?.viewpoint,this._initialCurrentCoveragePolygon]),((e,t)=>{e?.[1]!==t?.[1]&&(this._initialPreviousCoveragePolygon=this._plotPolygons?null:t?.[1]),this._imageViewer?.viewpoint&&this._initialCurrentCoveragePolygon&&(this._cancelCurrentCoverageUpdate(),this.updateCoverage())})),g((()=>this.selectedFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),u),g((()=>this.selectedFeature),(async()=>{const{selectedFeature:e,selectedPoint:t}=this;if(!e&&this._currentImage&&(this._imageViewer?.map.layers.remove(this._currentImage),this._currentImage=l(this._currentImage)),e&&t){this._initialCurrentCoverageUpdate=!0,this._updatePointsAndPolygons(),this._fetchFeaturesController??=new AbortController;const{signal:t}=this._fetchFeaturesController;await this.loadImage(e,{signal:t}).finally((()=>{this._fetchFeaturesController=null}))}}))])}resetImage(){this._currentImage=l(this._currentImage),this.setMessage("onLoadMessage","info"),this._cancelCurrentCoverageUpdate(),this._cancelFetchingFeatures()}async searchBestImage(e,t){try{const r=await C(e,t);r&&await this._processFeatureResponse(r,{signal:t?.signal})}catch(r){const e=a.getLogger(this);this.setMessage("imageLoadError","error"),e.error("error occurred while finding best image",r)}}setAdditionalCameraLocationsVisibility(e){this._additionalFeatureGraphics.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this._additionalCoveragePolygons.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this._currentCoveragePolygon&&(this._currentCoveragePolygon.visible=e),this._selectedFeatureGraphic&&(this._selectedFeatureGraphic.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}_cancelFetchingFeatures(e){const t=this._fetchFeaturesController;t&&t.abort(e),this._fetchFeaturesController=null}_cancelCurrentCoverageUpdate(){const e=this._updateCoverageController;e&&e.abort("Multiple Coverage Updates: Aborting Current Coverage Update to sync image and coverage"),this._updateCoverageController=null}async _fetchFeatures(e,t){const{screenPoint:r}=e,i=this.activeLayer;if(i){const e={include:i},s=await this.view.hitTest(r,e);this._processHitTestResults(i,s,t)}}async _fetchFeaturesWithController(e){this._cancelFetchingFeatures();const t=new AbortController,{signal:r}=t;this._fetchFeaturesController=t;try{await this._fetchFeatures(e,{signal:r}).finally((()=>{this._fetchFeaturesController=null}))}catch(i){const e=a.getLogger(this);this.setMessage("imageLoadError","error"),e.error("error occurred while fetching features",i)}}_groupFeaturesBySectors(){const{_suitabilities:e,features:t}=this;if(!e||!t)return void(this._sectorData=null);this._sectorData={};for(const a of E)this._sectorData[a]=new i;const r=e.map(((e,t)=>({...e,featureIndex:t})));r.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const s=r.map((({distance:e})=>e)),o=Math.max(...s);r.forEach((e=>{const{distance:r,angle:i,featureIndex:s}=e;let a="FAR";const n=r/o*U[2];n<=U[0]?a="NEAR":n<=U[1]&&(a="");let l="NORTH";if(Math.abs(i)>=135?l="WEST":i<-45&&i>-135?l="SOUTH":i<=45&&(l="EAST"),!this._sectorData)return;const h=U[3]+n*Math.sin(i*Math.PI/180),c=U[3]+n*Math.cos(i*Math.PI/180);let g;const u=t.at(s),m=u===this.selectedFeature,d=this.selectedFeature?.attributes.cameraPitch&&this.selectedFeature?.attributes.cameraPitch<5;if(m&&d)g=-90;else{const e=h-U[3],t=c-U[3],r=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(r)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),g=i}const p=""===a?l:`${a}_${l}`;m&&(g===this.selectedFeatureAngle?this.previousFeatureAngle=g:this.selectedFeatureAngle=g,this.navigatorSelectedFeature=d?null:{x:h,y:c,direction:l});const y=this._sectorData[p];y.add({angle:i,featureIndex:s,x:h,y:c,objectID:u.attributes.objectId,sector:p,featureIndexInSector:y.length})}))}async _processFeatureResponse(e,t){const{selectedPoint:r}=this;if(!r)return;if(!e)return;const i=e;if(!i)return;const{features:s}=i;if(!s.length)return this.setMessage("noImageError","error"),void(this.selectedFeature=null);const a=new Array;this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll(),s.forEach((e=>{let t;const{polygon:i,frustum:s}=b(e);if(t=i,e.attributes.isInspection&&(t=w(e.attributes)),e.layer.coveragePercent&&(t=F(t,e.layer.coveragePercent)),M(t,r)){a.push(e);const r=t.toJSON(),i=s?.toJSON(),{attributes:n}=e,{cameraHeight:l,cameraHeading:h,location:c,objectId:g}=n,u=o(c)?c.toJSON():c;r.imageID=u.imageID=g,i&&(i.imageID=g),u.z=l,this.pointSources?.push(u),this.coveragePolygons?.push(h>0?r:void 0),this.coverageFrustums?.push(h>0?i:void 0)}}));const n=this.coveragePolygons?.getItemAt(0);if(!a.length)return void this.setMessage("noImageError","error");if(a[0].attributes.elevationSource&&!r.z&&n){const e=await S([r],{feature:a[0],currentCoveragePolygon:new W(n),options:t});if(e[0]){const t=e[0];r.elevation=t.z}}this._suitabilities=I({features:a,selectedPoint:r,camera:q(this.view)?this.view.camera:null,currentImage:this.selectedFeature}),this._suitabilities?.sort(((e,t)=>e.suitability-t.suitability));const l=this._suitabilities?.map((e=>e.feature)),h=l[0];this._updateFeatures(l),this.selectedFeature=h,this._groupFeaturesBySectors(),this._initialCurrentCoverageUpdate=!0,this._plotPolygons=!0}async _processHitTestResults(e,t,r){const{screenPoint:i,results:s}=t,o=this.view.toMap(i),a=s[0],n={layerInstanceOrURL:e,point:o,queryParams:{maximumDistance:e.maximumDistance,objectIds:this.shouldShowSelectedImage?[a.graphic.attributes.id]:void 0},queryFeatures:null};await this.searchBestImage(n,r)}_updateFeatures(e){e.length&&(this.features.removeAll(),this.features.addMany(e))}_updatePointsAndPolygons(){const{coveragePolygons:e,pointSources:r,selectedFeature:i,currentCoverageVisible:s,isAdditionalCoverageVisible:o,isAdditionalPointSourcesVisible:a}=this;if(e&&r&&i){this._additionalCoveragePolygons.removeAll(),this._additionalFeatureGraphics.removeAll(),this._currentCoveragePolygon&&(this._currentCoveragePolygon.destroy(),this._currentCoveragePolygon=null,this._initialCurrentCoveragePolygon=null);for(const r of e)r?.imageID===i?.attributes.objectId?this._initialCurrentCoveragePolygon=new t({attributes:{imageID:r?.imageID},geometry:{type:"polygon",...r},symbol:T,visible:!1}):this._additionalCoveragePolygons.push(new t({attributes:{imageID:r?.imageID},geometry:{type:"polygon",...r},symbol:N,visible:o}));for(const e of r)e.imageID===i?.attributes.objectId?this._selectedFeatureGraphic=new t({attributes:{imageID:e.imageID},geometry:{type:"point",...e},symbol:k,visible:s}):this._additionalFeatureGraphics?.push(new t({attributes:{imageID:e.imageID},geometry:{type:"point",...e},symbol:H,visible:a}))}}_updateSelectedFeature(e){if(!e)return;this.selectedFeature=this.features?.at(e.featureIndex);const t=this.selectedFeature?.attributes.cameraPitch&&this.selectedFeature?.attributes.cameraPitch<5;let r;if(t)r=-90;else{const t=e.x-U[3],i=e.y-U[3],s=i/Math.sqrt(t**2+i**2);let o=180*Math.acos(s)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(o*=-1),r=o}r===this.selectedFeatureAngle?this.previousFeatureAngle=r:this.selectedFeatureAngle=r,this.navigatorSelectedFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}updateCurrentCoveragePolygon(e){if(this._initialCurrentCoverageUpdate)if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,e&&(this._currentCoveragePolygon&&this._currentCoveragePolygon.destroy(),e.visible=this.currentCoverageVisible,this._currentCoveragePolygon=e),this.view){this._plotPolygons=!1;const e=this.selectedPoint?new t({geometry:this.selectedPoint.clone(),symbol:J,attributes:{imageID:this.selectedFeature?.attributes.objectId}}):null;this._overlays?.graphics.addMany([...this._additionalCoveragePolygons,...this._additionalFeatureGraphics,this._currentCoveragePolygon,this._selectedFeatureGraphic,e].filter(B))}else if(this._plotPolygons){this._plotPolygons=!1;const e={points:this.pointSources?.filter((e=>e?.imageID!==this.selectedFeature?.attributes.objectId)),frustums:this.coverageFrustums?.filter((e=>e?.imageID!==this.selectedFeature?.attributes.objectId)),polygons:this._additionalCoveragePolygons?.map((e=>e.geometry?.toJSON())),currentPoint:this.pointSources.find((e=>e?.imageID===this.selectedFeature?.attributes.objectId)),currentPolygon:this._currentCoveragePolygon,currentFrustum:this.coverageFrustums?.find((e=>e?.imageID===this.selectedFeature?.attributes.objectId))};this.emit("plot-polygons",{data:e})}else{const e={currentPoint:this.pointSources.find((e=>e?.imageID===this.selectedFeature?.attributes.objectId)),additionalPoint:this.pointSources.find((e=>e?.imageID===this._initialPreviousCoveragePolygon?.attributes.imageID)),currentPolygon:this._currentCoveragePolygon,additionalPolygon:this._initialPreviousCoveragePolygon};this.emit("update-selected-feature",{data:e})}else if(this.view){const t=this._currentCoveragePolygon&&this._overlays?this._overlays.graphics.indexOf(this._currentCoveragePolygon):-1;e&&(this._currentCoveragePolygon&&(this._overlays?.remove(this._currentCoveragePolygon),this._currentCoveragePolygon.destroy()),e.visible=this.currentCoverageVisible,this._currentCoveragePolygon=e,this._overlays?.graphics.add(this._currentCoveragePolygon,t>=0?t:void 0))}else e&&(this._currentCoveragePolygon=e,this.emit("update-current-coverage",{graphic:e.toJSON()}))}async loadImage(e,t){if(!this._imageViewer)return;if(this._imageViewer.graphics.removeAll(),this._currentImage&&this._imageViewer?.map.layers.includes(this._currentImage)&&(this._currentImage?.removeHandles("image-handles"),this._imageViewer?.map.layers.remove(this._currentImage),this._currentImage?.destroy(),this._currentImage=null),!e)return void this.setMessage("noImageError","error");const{horizontalFieldOfView:r,isSpherical:i}=e.attributes;if(360===r||i)return void this.setMessage("unsupportedPanaromicImageryError","error");let s,o,n=e.attributes.imagePath;if(!X(n)&&!Y(n)){if(!this.localPort)return this.setMessage("noLocalPort","error"),void a.getLogger(this).error("oriented-imagery-viewer:missing-local-port","A value for local port is not set. Local port is needed to load local images.");n=`http://127.0.0.1:${this.localPort}/${n}`}this._referencePointOnGround&&(this._imageViewer?.graphics.remove(this._referencePointOnGround),this._referencePointOnGround.destroy());const l={skipExtensions:["aux.xml","jgw"]};if(Y(n)){const r=new G({objectIds:[e.attributes.objectId]}),i=(await e.layer.queryAttachments(r,t))[`${e.attributes.objectId}`];if(!i[0]?.url)return void this.setMessage("noAttachment","error");if(s=i[0].contentType.split("/")[1]?.toUpperCase(),n=i[0]?.url,o=await O.open({ioConfig:l,url:n,datasetFormat:s,...t}).catch((e=>(this.setMessage("imageLoadError","error",e.message),null))),!o)return}this._currentImage=new P({ioConfig:l,url:n,raster:o,options:t}),this._imageViewer.map.layers.add(this._currentImage);try{const r=await this._currentImage.when();this._imageViewer.extent=r.fullExtent,r.raster.rasterInfo.isPseudoSpatialReference&&(this._imageViewer.rotation=(e.attributes.cameraRoll??0)+(e.attributes.imageRotation??0)),this._panConstraint&&this._imageViewer.constraints.customConstraints.remove(this._panConstraint),this._scaleConstraint&&this._imageViewer.constraints.customConstraints.remove(this._scaleConstraint),this._panConstraint={constrain:(e,t)=>{if(!this._currentImage||!this._imageViewer||!e.targetGeometry)return e;const{xmin:r,xmax:i,ymin:s,ymax:o}=this._currentImage.fullExtent,{extent:a,rotation:n}=this._imageViewer,l=n*Math.PI/180,h=Math.abs(Math.cos(l)*a.width+Math.sin(l)*a.height),c=Math.abs(Math.cos(l)*a.height+Math.sin(l)*a.width),{rasterInfo:g}=this._currentImage;return e.targetGeometry.x=Math.min(Math.max(r+Math.min(g.width,h)/2,e.targetGeometry.x),i-Math.min(g.width,h)/2),e.targetGeometry.y=Math.min(Math.max(s+Math.min(g.height,c)/2,e.targetGeometry.y),o-Math.min(g.height,c)/2),e},applyPanConstraint:e=>{if(!this._currentImage||!this._imageViewer||!e.targetGeometry)return e;const{xmin:t,xmax:r,ymin:i,ymax:s}=this._currentImage.fullExtent,{extent:o,rotation:a}=this._imageViewer,n=a*Math.PI/180,l=Math.abs(Math.cos(n)*o.width+Math.sin(n)*o.height),h=Math.abs(Math.cos(n)*o.height+Math.sin(n)*o.width),{rasterInfo:c}=this._currentImage;return e.targetGeometry.x=Math.min(Math.max(t+Math.min(c.width,l)/2,e.targetGeometry.x),r-Math.min(c.width,l)/2),e.targetGeometry.y=Math.min(Math.max(i+Math.min(c.height,h)/2,e.targetGeometry.y),s-Math.min(c.height,h)/2),e}},this._scaleConstraint={constrain:(e,t)=>{if(this._imageViewer&&this._currentImage){const{width:t,height:r}=this._currentImage.rasterInfo,{width:i,height:s,rotation:o,zoom:a}=this._imageViewer,n=o*Math.PI/180,l=Math.abs(Math.cos(n)*t+Math.sin(n)*r),h=Math.abs(Math.cos(n)*r+Math.sin(n)*t);a<1&&(e.scale=Math.max(e.scale,R(this._imageViewer.spatialReference)*Math.max(l/i,h/s)/2**a))}return e}},this._imageViewer.constraints.customConstraints.addMany([this._panConstraint,this._scaleConstraint]),r.addHandles(g((()=>[this.brightness,this.contrast,this.sharpness]),(([e,t,i])=>{r.loaded&&(r.effect=`contrast(${10*(t+10)}%) brightness(${10*(e+10)}%)`,this.sharpenImage(r,i))}),u)),await this.transformAndPlotSelectedLocation(t)}catch(h){a.getLogger(this).error("oriented-imagery-viewer:load-image",h),this.setMessage("imageLoadError","error",h.message)}}sharpenImage(e,t){const r=[0,-1*t,0,-1*t,5,-1*t,0,-1*t,0],i=new j({functionName:"Convolution",functionArguments:{type:A.userDefined,cols:3,rows:3,kernel:r,convolutionType:A.userDefined}});e.renderer=null,e.rasterFunction=i}async transformAndPlotSelectedLocation(e){const{_currentImage:r,selectedFeature:i,selectedPoint:s}=this;if(!s||!i||!r?.loaded)return;const{pixelSize:o}=r.rasterInfo,a=await x([s],{feature:i,imageProperties:r.rasterInfo,currentCoveragePolygon:this.getSelectedFeaturePolygon(),options:e});if(!a.length)return;const n=a[0];if(!n)return;const l=p(_,await L(r.fullExtent,p(Z,this._imageViewer?.spatialReference),null,e?.signal));n.x=n.x*o.x+l.xmin,n.y=l.ymax-n.y*o.y,n.spatialReference=l.spatialReference,this._crossSymbol&&(this._imageViewer?.graphics.remove(this._crossSymbol),this._crossSymbol.destroy()),this._crossSymbol=new t({geometry:Q.fromJSON(n),symbol:J}),this._imageViewer?.graphics.add(this._crossSymbol)}async transformAndPlotReferencePointOnImage(e){if(!this._imageViewer)return;const t=this._currentImage;if(!t)return;const{feature:r,selectedLocation:i,options:s}=e,{pixelSize:o,isPseudoSpatialReference:a,transform:n}=t.rasterInfo,l=await x([i],{feature:r,imageProperties:t.rasterInfo,currentCoveragePolygon:this.getSelectedFeaturePolygon(),options:s});if(!l.length)return;let h=l[0];const c=await L(t.fullExtent,this._imageViewer.spatialReference,null,s?.signal);a?(h.x=h.x*o.x+c.xmin,h.y=c.ymax-h.y*o.y,h.spatialReference=c.spatialReference):h=n.forwardTransform(new Q(h)),this.plotReferencePointOnImage(h)}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),this._referencePointOnGround=new t({geometry:{type:"point",...e.toJSON()},symbol:z}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}})}plotReferencePointOnImage(e){this._imageViewer&&(this._referencePointOnImage&&(this._imageViewer.graphics.remove(this._referencePointOnImage),this._referencePointOnImage.destroy()),this._referencePointOnImage=new t({geometry:{type:"point",...o(e)?e.toJSON():e},symbol:z}),this._imageViewer.graphics.add(this._referencePointOnImage))}setMessage(e,t,r){this.displayMessage={key:e,type:t,data:r}}async updateCoverage(){const e=new AbortController,{signal:r}=e;this._updateCoverageController=e;const{_imageViewer:i}=this;if(this._currentImage?.loaded&&i){const{width:e,height:s}=this._currentImage.rasterInfo,{xmin:o,xmax:a,ymin:n,ymax:l}=this._currentImage.fullExtent,h=[[0,0],[Math.min(i.width,e),0],[Math.min(i.width,e),Math.min(i.height,s)],[0,Math.min(i.height,s)]].map((e=>i.toMap(m(e[0],e[1]))));h.forEach((e=>{e.x=o<=e.x&&e.x<=a?e.x:Math.abs(o-e.x)>Math.abs(a-e.x)?a:o,e.y=n<=e.y&&e.y<=l?e.y:Math.abs(n-e.y)>Math.abs(l-e.y)?l:n}));const c=await V(h,{feature:this.getSelectedFeature(),currentCoveragePolygon:this.getSelectedFeaturePolygon(),imageProperties:this._currentImage.rasterInfo,options:{signal:r}});if(c&&!r.aborted){const e=[c.map((e=>[e.x,e.y,1]))];e[0].push(e[0][0]);const r=new W({hasZ:!0,rings:e,spatialReference:c[0].spatialReference});this.updateCurrentCoveragePolygon(new t({attributes:{imageID:this.selectedFeature?.attributes.objectId},geometry:r,symbol:T,visible:this.currentCoverageVisible}))}}}};e([d()],ee.prototype,"active",null),e([d()],ee.prototype,"activeLayer",void 0),e([d()],ee.prototype,"shouldShowSelectedImage",void 0),e([d({type:Number})],ee.prototype,"brightness",null),e([d({type:Number})],ee.prototype,"contrast",null),e([d()],ee.prototype,"coverageFrustums",void 0),e([d()],ee.prototype,"coveragePolygons",void 0),e([d()],ee.prototype,"currentCoverageVisible",void 0),e([d()],ee.prototype,"currentImageView",null),e([d()],ee.prototype,"disabled",void 0),e([d()],ee.prototype,"displayMessage",void 0),e([d()],ee.prototype,"pointSources",void 0),e([d()],ee.prototype,"previousFeatureAngle",void 0),e([d()],ee.prototype,"selectedFeature",void 0),e([d()],ee.prototype,"selectedFeatureAngle",void 0),e([d()],ee.prototype,"selectedPoint",void 0),e([d({readOnly:!0})],ee.prototype,"featureCount",null),e([d()],ee.prototype,"features",void 0),e([d()],ee.prototype,"imageGalleryEnabled",null),e([d()],ee.prototype,"imageLoaded",null),e([d()],ee.prototype,"isAdditionalCoverageVisible",void 0),e([d()],ee.prototype,"isAdditionalPointSourcesVisible",void 0),e([d({type:Number})],ee.prototype,"localPort",void 0),e([d()],ee.prototype,"mapImageConversionToolState",void 0),e([d()],ee.prototype,"navigatorSelectedFeature",void 0),e([d()],ee.prototype,"updating",null),e([d({type:Number})],ee.prototype,"sharpness",null),e([d()],ee.prototype,"sectorData",null),e([d()],ee.prototype,"state",null),e([d()],ee.prototype,"thumbnails",null),e([d()],ee.prototype,"view",null),e([d()],ee.prototype,"_additionalCoveragePolygons",void 0),e([d()],ee.prototype,"_additionalFeatureGraphics",void 0),e([d()],ee.prototype,"_currentCoveragePolygon",void 0),e([d()],ee.prototype,"_currentImage",void 0),e([d()],ee.prototype,"_fetchFeaturesController",void 0),e([d()],ee.prototype,"_imageViewer",void 0),e([d()],ee.prototype,"_initialCurrentCoveragePolygon",void 0),e([d()],ee.prototype,"_initialCurrentCoverageUpdate",void 0),e([d()],ee.prototype,"_overlays",void 0),e([d()],ee.prototype,"_plotPolygons",void 0),e([d()],ee.prototype,"_initialPreviousCoveragePolygon",void 0),e([d()],ee.prototype,"_referencePointOnGround",void 0),e([d()],ee.prototype,"_referencePointOnImage",void 0),e([d()],ee.prototype,"_selectedFeatureGraphic",void 0),e([d()],ee.prototype,"_sectorData",void 0),ee=e([y("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],ee);const te=ee;export{te as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{isSome as r}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import s from"../../core/Evented.js";import{isSerializable as a}from"../../core/JSONSupport.js";import n from"../../core/Logger.js";import{clamp as l}from"../../core/mathUtils.js";import{destroyMaybe as h}from"../../core/maybe.js";import{watch as c,once as g,initial as u}from"../../core/reactiveUtils.js";import{createScreenPoint as m}from"../../core/screenUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import{ensureType as p}from"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import _ from"../../geometry/Extent.js";import{geographicToWebMercator as v}from"../../geometry/support/webMercatorUtils.js";import f from"../../layers/GraphicsLayer.js";import P from"../../layers/ImageryTileLayer.js";import{searchImages as C}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as I}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as b,computePolygonForInspection as w,resizePolygon as F,checkIfPolygonContainsSelectedPoint as M}from"../../layers/orientedImagery/core/coverageUtils.js";import{updateElevation as S,transformPoints as x}from"../../layers/orientedImagery/transformations/groundToImageUtils.js";import{transformPoints as V}from"../../layers/orientedImagery/transformations/imageToGroundUtils.js";import j from"../../layers/support/RasterFunction.js";import{convolutionKernel as O}from"../../layers/support/rasterFunctionConstants.js";import A from"../../layers/support/rasterDatasets/RasterFactory.js";import G from"../../rest/support/AttachmentQuery.js";import D from"../../views/MapView.js";import{getResolutionToScaleFactor as R}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as L}from"../../views/input/InputManager.js";import{projectWithEngineOrService as E}from"../../views/support/projectionUtils.js";import{sectorsInOrder as T,sectorsRadii as U}from"./constants.js";import{activePolygonSymbol as k,polygonSymbol as N,activeSourcePointSymbol as H,sourcePointSymbol as J,crossSymbol as z,diamondSymbol as B}from"./symbols.js";import{isTifOrMrf as $,isSceneView as q,isGraphic as W}from"./utils.js";import Z from"../../geometry/Polygon.js";import Q from"../../geometry/SpatialReference.js";import K from"../../geometry/Point.js";const X={click:"view-click",imageClick:"image-click"},Y=e=>/^https?:/i.test(e),ee=e=>"FA"===e;let te=class extends s.EventedAccessor{constructor(e){super(e),this.layer=null,this.shouldShowSelectedImage=!1,this.coverageFrustums=new i,this.coveragePolygons=new i,this.currentCoverageVisible=!0,this.disabled=!1,this.displayMessage=null,this.pointSources=new i,this.previousFeatureAngle=0,this.selectedFeature=null,this.selectedFeatureAngle=0,this.selectedPoint=null,this.features=new i,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.localPort=null,this.mapImageConversionToolState=!1,this.navigatorSelectedFeature=null,this._additionalCoveragePolygons=new i,this._additionalFeatureGraphics=new i,this._currentCoveragePolygon=null,this._currentImage=null,this._fetchFeaturesController=null,this._imageViewer=null,this._initialCurrentCoveragePolygon=null,this._initialCurrentCoverageUpdate=!0,this._overlays=new f({listMode:"hide",internal:!0}),this._plotPolygons=!1,this._initialPreviousCoveragePolygon=null,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._crossSymbol=null,this._panConstraint=null,this._scaleConstraint=null,this._suitabilities=null,this._transformController=new AbortController,this._updateCoverageController=null,this._imageClickHandler=async e=>{if(0===e.button&&this._currentImage&&this._currentImage?.fullExtent){const{xmin:t,xmax:r,ymin:i,ymax:o}=this._currentImage.fullExtent,{x:s,y:a}=e.mapPoint;if(t>s||r<s||o<a||i>a)return;this.plotReferencePointOnImage(e.mapPoint);const n=this.getSelectedFeature();if(n){const t=(await V([e.mapPoint.toJSON()],{feature:n,currentCoveragePolygon:this.getSelectedFeaturePolygon(),imageProperties:this._currentImage.rasterInfo,options:{signal:this._transformController?.signal}}))[0];t&&this.plotReferencePointOnGround(t)}}},this._viewClickHandler=e=>{"mouse"===e.pointerType&&0!==e.button||(e.stopPropagation(),e.preventDefault(),this.loadBestImage(e.mapPoint))},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),this.plotMapPoint(e.mapPoint)},this.handleSectorClick=this.handleSectorClick.bind(this),this.loadViewer=this.loadViewer.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this)}initialize(){this.addHandles([c((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),u),c((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),u),c((()=>this.layer?.visible??!1),(e=>{this._overlays.visible=e}),u),c((()=>[this.state,this.mapImageConversionToolState]),(()=>{if(this.removeHandles(X.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,L.WIDGET),X.click)}),u),c((()=>this.mapImageConversionToolState),(()=>{this.removeHandles(X.imageClick),this.imageLoaded&&this.mapImageConversionToolState&&this.addHandles(this._imageViewer.on("click",this._imageClickHandler),X.imageClick)}))])}destroy(){this._cancelCurrentCoverageUpdate(),this._cancelFetchingFeatures(),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this._additionalCoveragePolygons.destroy(),this._additionalFeatureGraphics.destroy(),this._currentImage=h(this._currentImage),this._imageViewer=h(this._imageViewer),this._initialCurrentCoveragePolygon=h(this._initialCurrentCoveragePolygon),this._currentCoveragePolygon=h(this._currentCoveragePolygon),this._crossSymbol=h(this._crossSymbol),this._referencePointOnGround=h(this._referencePointOnGround),this._referencePointOnImage=h(this._referencePointOnImage),this._overlays&&this.view?.map.remove(this._overlays),this._overlays.destroy()}get activeLayer(){return o(n.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(n.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",l(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",l(e,-10,10))}get currentImageView(){return this._imageViewer?.allLayerViews.find((e=>e.layer===this._currentImage))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){return $(this.selectedFeature?.attributes.imagePath.trim())}get imageLoaded(){return this._currentImage?.loaded??!1}get updating(){return"loading"===this._currentImage?.loadStatus||!!this._fetchFeaturesController}get referencePoint(){return this._referencePointOnGround?.geometry}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",l(e,0,1))}get sectorData(){const{_sectorData:e}=this;if(e)return T.map((t=>e[t]))}get state(){const{layer:e,view:t,_currentImage:r}=this;return this.disabled||!e||t&&!t.ready?"disabled":r?.loadStatus?`image-${r.loadStatus}`:"ready"}get thumbnails(){const{features:e}=this;return e?new i(e.map((({attributes:{imagePath:e,objectId:t}})=>{const r=e.trim();return $(r)?{url:r,objectId:t}:null})).filter(r)):null}set view(e){this._set("view",e)}getCurrentCoveragePolygon(){return this._currentCoveragePolygon}getSelectedFeature(){return this.selectedFeature}getSelectedFeaturePolygon(){return this._initialCurrentCoveragePolygon}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[T[e]];t?.length&&this._updateSelectedFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:r}=e;if(isNaN(r))return;const i=this._sectorData?.[t];i?.length&&this._updateSelectedFeature(i.at(r))}async loadBestImage(e){this.displayMessage=null,this.selectedPoint=e.spatialReference.isGeographic?v(e):e.clone(),this.features.removeAll(),this._additionalCoveragePolygons.removeAll(),this._additionalFeatureGraphics.removeAll(),this._currentCoveragePolygon=h(this._currentCoveragePolygon),this._overlays?.removeAll(),this.selectedFeature=null,await this._fetchFeaturesWithController(e)}loadViewer(e){const t=new Map,r={wkid:0};this._imageViewer=new D({container:e,map:t,spatialReferance:r,constraints:{snapToZoom:!1,rotationEnabled:!1},ui:{components:["zoom"]}}),g((()=>!0===this._imageViewer?.stationary)).then((()=>{this.setMessage("onLoadMessage","info")})),this._imageViewer.addHandles([c((()=>[this._imageViewer?.viewpoint,this._initialCurrentCoveragePolygon]),((e,t)=>{e?.[1]!==t?.[1]&&(this._initialPreviousCoveragePolygon=this._plotPolygons?null:t?.[1]),this._imageViewer?.viewpoint&&this._initialCurrentCoveragePolygon&&(this._cancelCurrentCoverageUpdate(),this.updateCoverage())})),c((()=>this.selectedFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),u),c((()=>this.selectedFeature),(async()=>{const{selectedFeature:e,selectedPoint:t}=this;if(!e&&this._currentImage&&(this._imageViewer?.map.layers.remove(this._currentImage),this._currentImage=h(this._currentImage)),e&&t){this._initialCurrentCoverageUpdate=!0,this._updatePointsAndPolygons(),this._fetchFeaturesController??=new AbortController;const{signal:t}=this._fetchFeaturesController;await this.loadImage(e,{signal:t}).finally((()=>{this._fetchFeaturesController=null}))}}))])}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.selectedFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}resetImage(){this._currentImage=h(this._currentImage),this.setMessage("onLoadMessage","info"),this._cancelCurrentCoverageUpdate(),this._cancelFetchingFeatures()}async searchBestImage(e,t){try{const r=await C(e,t);r&&await this._processFeatureResponse(r,{signal:t?.signal})}catch(r){const e=n.getLogger(this);this.setMessage("imageLoadError","error"),e.error("error occurred while finding best image",r)}}setAdditionalCameraLocationsVisibility(e){this._additionalFeatureGraphics.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this._additionalCoveragePolygons.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this._currentCoveragePolygon&&(this._currentCoveragePolygon.visible=e),this._selectedFeatureGraphic&&(this._selectedFeatureGraphic.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}_cancelFetchingFeatures(e){const t=this._fetchFeaturesController;t&&t.abort(e),this._fetchFeaturesController=null}_cancelCurrentCoverageUpdate(){const e=this._updateCoverageController;e&&e.abort("Multiple Coverage Updates: Aborting Current Coverage Update to sync image and coverage"),this._updateCoverageController=null}async _fetchFeatures(e,t){if(!this.view)return;const r=this.layer;if(r){const i={include:r},o=this.view.toScreen(e);if(!o)return;const s=await this.view.hitTest(o,i);this._processHitTestResults(r,s,t)}}async _fetchFeaturesWithController(e){this._cancelFetchingFeatures();const t=new AbortController,{signal:r}=t;this._fetchFeaturesController=t;try{await this._fetchFeatures(e,{signal:r}).finally((()=>{this._fetchFeaturesController=null}))}catch(i){const e=n.getLogger(this);this.setMessage("imageLoadError","error"),e.error("error occurred while fetching features",i)}}_groupFeaturesBySectors(){const{_suitabilities:e,features:t}=this;if(!e||!t)return void(this._sectorData=null);this._sectorData={};for(const a of T)this._sectorData[a]=new i;const r=e.map(((e,t)=>({...e,featureIndex:t})));r.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const o=r.map((({distance:e})=>e)),s=Math.max(...o);r.forEach((e=>{const{distance:r,angle:i,featureIndex:o}=e;let a="FAR";const n=r/s*U[2];n<=U[0]?a="NEAR":n<=U[1]&&(a="");let l="NORTH";if(Math.abs(i)>=135?l="WEST":i<-45&&i>-135?l="SOUTH":i<=45&&(l="EAST"),!this._sectorData)return;const h=U[3]+n*Math.sin(i*Math.PI/180),c=U[3]+n*Math.cos(i*Math.PI/180);let g;const u=t.at(o),m=u===this.selectedFeature,d=this.selectedFeature?.attributes.cameraPitch&&this.selectedFeature?.attributes.cameraPitch<5;if(m&&d)g=-90;else{const e=h-U[3],t=c-U[3],r=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(r)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),g=i}const p=""===a?l:`${a}_${l}`;m&&(g===this.selectedFeatureAngle?this.previousFeatureAngle=g:this.selectedFeatureAngle=g,this.navigatorSelectedFeature=d?null:{x:h,y:c,direction:l});const y=this._sectorData[p];y.add({angle:i,featureIndex:o,x:h,y:c,objectID:u.attributes.objectId,sector:p,featureIndexInSector:y.length})}))}async _processFeatureResponse(e,t){const{selectedPoint:r}=this;if(!r)return;if(!e)return;const i=e;if(!i)return;const{features:o}=i;if(!o.length)return this.setMessage("noImageError","error"),void(this.selectedFeature=null);const s=new Array;this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll(),o.forEach((e=>{let t;const{polygon:i,frustum:o}=b(e);if(t=i,e.attributes.isInspection&&(t=w(e.attributes)),e.layer.coveragePercent&&(t=F(t,e.layer.coveragePercent)),M(t,r)){s.push(e);const r=t.toJSON(),i=o?.toJSON(),{attributes:n}=e,{cameraHeight:l,cameraHeading:h,location:c,objectId:g}=n,u=a(c)?c.toJSON():c;r.imageID=u.imageID=g,i&&(i.imageID=g),u.z=l,this.pointSources?.push(u),this.coveragePolygons?.push(h>0?r:void 0),this.coverageFrustums?.push(h>0?i:void 0)}}));const n=this.coveragePolygons?.getItemAt(0);if(!s.length)return void this.setMessage("noImageError","error");if(s[0].attributes.elevationSource&&!r.z&&n){const e=await S([r],{feature:s[0],currentCoveragePolygon:new Z(n),options:t});if(e[0]){const t=e[0];r.elevation=t.z}}this._suitabilities=I({features:s,selectedPoint:r,camera:q(this.view)?this.view.camera:null,currentImage:this.selectedFeature}),this._suitabilities?.sort(((e,t)=>e.suitability-t.suitability));const l=this._suitabilities?.map((e=>e.feature)),h=l[0];this._updateFeatures(l),this.selectedFeature=h,this._groupFeaturesBySectors(),this._initialCurrentCoverageUpdate=!0,this._plotPolygons=!0}async _processHitTestResults(e,t,r){const{screenPoint:i,results:[o]}=t,s="graphic"===o?.type&&this.shouldShowSelectedImage,a={layerInstanceOrURL:e,point:o?.mapPoint??this.view?.toMap(i),queryParams:{maximumDistance:e.maximumDistance,objectIds:s?[o.graphic.getAttribute(e.objectIdField)]:void 0},queryFeatures:null};await this.searchBestImage(a,r)}_updateFeatures(e){e.length&&(this.features.removeAll(),this.features.addMany(e))}_updatePointsAndPolygons(){const{coveragePolygons:e,pointSources:r,selectedFeature:i,currentCoverageVisible:o,isAdditionalCoverageVisible:s,isAdditionalPointSourcesVisible:a}=this;if(e&&r&&i){this._additionalCoveragePolygons.removeAll(),this._additionalFeatureGraphics.removeAll(),this._currentCoveragePolygon&&(this._currentCoveragePolygon.destroy(),this._currentCoveragePolygon=null,this._initialCurrentCoveragePolygon=null);for(const r of e)r?.imageID===i?.attributes.objectId?this._initialCurrentCoveragePolygon=new t({attributes:{imageID:r?.imageID},geometry:{type:"polygon",...r},symbol:k,visible:!1}):this._additionalCoveragePolygons.push(new t({attributes:{imageID:r?.imageID},geometry:{type:"polygon",...r},symbol:N,visible:s}));for(const e of r)e.imageID===i?.attributes.objectId?this._selectedFeatureGraphic=new t({attributes:{imageID:e.imageID},geometry:{type:"point",...e},symbol:H,visible:o}):this._additionalFeatureGraphics?.push(new t({attributes:{imageID:e.imageID},geometry:{type:"point",...e},symbol:J,visible:a}))}}_updateSelectedFeature(e){if(!e)return;this.selectedFeature=this.features?.at(e.featureIndex);const t=this.selectedFeature?.attributes.cameraPitch&&this.selectedFeature?.attributes.cameraPitch<5;let r;if(t)r=-90;else{const t=e.x-U[3],i=e.y-U[3],o=i/Math.sqrt(t**2+i**2);let s=180*Math.acos(o)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(s*=-1),r=s}r===this.selectedFeatureAngle?this.previousFeatureAngle=r:this.selectedFeatureAngle=r,this.navigatorSelectedFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}updateCurrentCoveragePolygon(e){if(this._initialCurrentCoverageUpdate)if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,e&&(this._currentCoveragePolygon&&this._currentCoveragePolygon.destroy(),e.visible=this.currentCoverageVisible,this._currentCoveragePolygon=e),this.view){this._plotPolygons=!1;const e=this.selectedPoint?new t({geometry:this.selectedPoint.clone(),symbol:z,attributes:{imageID:this.selectedFeature?.attributes.objectId}}):null;this._overlays?.graphics.addMany([...this._additionalCoveragePolygons,...this._additionalFeatureGraphics,this._currentCoveragePolygon,this._selectedFeatureGraphic,e].filter(W))}else if(this._plotPolygons){this._plotPolygons=!1;const e={points:this.pointSources?.filter((e=>e?.imageID!==this.selectedFeature?.attributes.objectId)),frustums:this.coverageFrustums?.filter((e=>e?.imageID!==this.selectedFeature?.attributes.objectId)),polygons:this._additionalCoveragePolygons?.map((e=>e.geometry?.toJSON())),currentPoint:this.pointSources.find((e=>e?.imageID===this.selectedFeature?.attributes.objectId)),currentPolygon:this._currentCoveragePolygon,currentFrustum:this.coverageFrustums?.find((e=>e?.imageID===this.selectedFeature?.attributes.objectId))};this.emit("plot-polygons",{data:e})}else{const e={currentPoint:this.pointSources.find((e=>e?.imageID===this.selectedFeature?.attributes.objectId)),additionalPoint:this.pointSources.find((e=>e?.imageID===this._initialPreviousCoveragePolygon?.attributes.imageID)),currentPolygon:this._currentCoveragePolygon,additionalPolygon:this._initialPreviousCoveragePolygon};this.emit("update-selected-feature",{data:e})}else if(this.view){const t=this._currentCoveragePolygon&&this._overlays?this._overlays.graphics.indexOf(this._currentCoveragePolygon):-1;e&&(this._currentCoveragePolygon&&(this._overlays?.remove(this._currentCoveragePolygon),this._currentCoveragePolygon.destroy()),e.visible=this.currentCoverageVisible,this._currentCoveragePolygon=e,this._overlays?.graphics.add(this._currentCoveragePolygon,t>=0?t:void 0))}else e&&(this._currentCoveragePolygon=e,this.emit("update-current-coverage",{graphic:e.toJSON()}))}async loadImage(e,t){if(!this._imageViewer)return;if(this._imageViewer.graphics.removeAll(),this._currentImage&&this._imageViewer?.map.layers.includes(this._currentImage)&&(this._currentImage?.removeHandles("image-handles"),this._imageViewer?.map.layers.remove(this._currentImage),this._currentImage?.destroy(),this._currentImage=null),!e)return void this.setMessage("noImageError","error");const{horizontalFieldOfView:r,isSpherical:i}=e.attributes;if(360===r||i)return void this.setMessage("unsupportedPanaromicImageryError","error");let o,s,a=e.attributes.imagePath;if(!Y(a)&&!ee(a)){if(!this.localPort)return this.setMessage("noLocalPort","error"),void n.getLogger(this).error("oriented-imagery-viewer:missing-local-port","A value for local port is not set. Local port is needed to load local images.");a=`http://127.0.0.1:${this.localPort}/${a}`}this._referencePointOnGround&&(this._imageViewer?.graphics.remove(this._referencePointOnGround),this._referencePointOnGround.destroy());const l={skipExtensions:["aux.xml","jgw"]};if(ee(a)){const r=new G({objectIds:[e.attributes.objectId]}),i=(await e.layer.queryAttachments(r,t))[`${e.attributes.objectId}`];if(!i[0]?.url)return void this.setMessage("noAttachment","error");if(o=i[0].contentType.split("/")[1]?.toUpperCase(),a=i[0]?.url,s=await A.open({ioConfig:l,url:a,datasetFormat:o,...t}).catch((e=>(this.setMessage("imageLoadError","error",e.message),null))),!s)return}this._currentImage=new P({ioConfig:l,url:a,raster:s,options:t}),this._imageViewer.map.layers.add(this._currentImage);try{const r=await this._currentImage.when();this._imageViewer.extent=r.fullExtent,r.raster.rasterInfo.isPseudoSpatialReference&&(this._imageViewer.rotation=(e.attributes.cameraRoll??0)+(e.attributes.imageRotation??0)),this._panConstraint&&this._imageViewer.constraints.customConstraints.remove(this._panConstraint),this._scaleConstraint&&this._imageViewer.constraints.customConstraints.remove(this._scaleConstraint),this._panConstraint={constrain:(e,t)=>{if(!this._currentImage||!this._imageViewer||!e.targetGeometry)return e;const{xmin:r,xmax:i,ymin:o,ymax:s}=this._currentImage.fullExtent,{extent:a,rotation:n}=this._imageViewer,l=n*Math.PI/180,h=Math.abs(Math.cos(l)*a.width+Math.sin(l)*a.height),c=Math.abs(Math.cos(l)*a.height+Math.sin(l)*a.width),{rasterInfo:g}=this._currentImage;return e.targetGeometry.x=Math.min(Math.max(r+Math.min(g.width,h)/2,e.targetGeometry.x),i-Math.min(g.width,h)/2),e.targetGeometry.y=Math.min(Math.max(o+Math.min(g.height,c)/2,e.targetGeometry.y),s-Math.min(g.height,c)/2),e},applyPanConstraint:e=>{if(!this._currentImage||!this._imageViewer||!e.targetGeometry)return e;const{xmin:t,xmax:r,ymin:i,ymax:o}=this._currentImage.fullExtent,{extent:s,rotation:a}=this._imageViewer,n=a*Math.PI/180,l=Math.abs(Math.cos(n)*s.width+Math.sin(n)*s.height),h=Math.abs(Math.cos(n)*s.height+Math.sin(n)*s.width),{rasterInfo:c}=this._currentImage;return e.targetGeometry.x=Math.min(Math.max(t+Math.min(c.width,l)/2,e.targetGeometry.x),r-Math.min(c.width,l)/2),e.targetGeometry.y=Math.min(Math.max(i+Math.min(c.height,h)/2,e.targetGeometry.y),o-Math.min(c.height,h)/2),e}},this._scaleConstraint={constrain:(e,t)=>{if(this._imageViewer&&this._currentImage){const{width:t,height:r}=this._currentImage.rasterInfo,{width:i,height:o,rotation:s,zoom:a}=this._imageViewer,n=s*Math.PI/180,l=Math.abs(Math.cos(n)*t+Math.sin(n)*r),h=Math.abs(Math.cos(n)*r+Math.sin(n)*t);a<1&&(e.scale=Math.max(e.scale,R(this._imageViewer.spatialReference)*Math.max(l/i,h/o)/2**a))}return e}},this._imageViewer.constraints.customConstraints.addMany([this._panConstraint,this._scaleConstraint]),r.addHandles(c((()=>[this.brightness,this.contrast,this.sharpness]),(([e,t,i])=>{r.loaded&&(r.effect=`contrast(${10*(t+10)}%) brightness(${10*(e+10)}%)`,this.sharpenImage(r,i))}),u)),await this.transformAndPlotSelectedLocation(t)}catch(h){n.getLogger(this).error("oriented-imagery-viewer:load-image",h),this.setMessage("imageLoadError","error",h.message)}}sharpenImage(e,t){const r=[0,-1*t,0,-1*t,5,-1*t,0,-1*t,0],i=new j({functionName:"Convolution",functionArguments:{type:O.userDefined,cols:3,rows:3,kernel:r,convolutionType:O.userDefined}});e.renderer=null,e.rasterFunction=i}async transformAndPlotSelectedLocation(e){const{_currentImage:r,selectedFeature:i,selectedPoint:o}=this;if(!o||!i||!r?.loaded)return;const{pixelSize:s}=r.rasterInfo,a=await x([o],{feature:i,imageProperties:r.rasterInfo,currentCoveragePolygon:this.getSelectedFeaturePolygon(),options:e});if(!a.length)return;const n=a[0];if(!n)return;const l=p(_,await E(r.fullExtent,p(Q,this._imageViewer?.spatialReference),null,e?.signal));n.x=n.x*s.x+l.xmin,n.y=l.ymax-n.y*s.y,n.spatialReference=l.spatialReference,this._crossSymbol&&(this._imageViewer?.graphics.remove(this._crossSymbol),this._crossSymbol.destroy()),this._crossSymbol=new t({geometry:K.fromJSON(n),symbol:z}),this._imageViewer?.graphics.add(this._crossSymbol)}async transformAndPlotReferencePointOnImage(e){if(!this._imageViewer)return;const t=this._currentImage;if(!t)return;const{feature:r,selectedLocation:i,options:o}=e,{pixelSize:s,isPseudoSpatialReference:a,transform:n}=t.rasterInfo,l=await x([i],{feature:r,imageProperties:t.rasterInfo,currentCoveragePolygon:this.getSelectedFeaturePolygon(),options:o});if(!l.length)return;let h=l[0];const c=await E(t.fullExtent,this._imageViewer.spatialReference,null,o?.signal);return a?(h.x=h.x*s.x+c.xmin,h.y=c.ymax-h.y*s.y,h.spatialReference=c.spatialReference):h=n.forwardTransform(new K(h)),this.plotReferencePointOnImage(h),{x:h.x,y:h.y}}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),this._referencePointOnGround=new t({geometry:{type:"point",...e.toJSON()},symbol:B}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}})}plotReferencePointOnImage(e){this._imageViewer&&(this._referencePointOnImage&&(this._imageViewer.graphics.remove(this._referencePointOnImage),this._referencePointOnImage.destroy()),this._referencePointOnImage=new t({geometry:{type:"point",...a(e)?e.toJSON():e},symbol:B}),this._imageViewer.graphics.add(this._referencePointOnImage))}setMessage(e,t,r){this.displayMessage={key:e,type:t,data:r}}async updateCoverage(){const e=new AbortController,{signal:r}=e;this._updateCoverageController=e;const{_imageViewer:i}=this;if(this._currentImage?.loaded&&i){const{width:e,height:o}=this._currentImage.rasterInfo,{xmin:s,xmax:a,ymin:n,ymax:l}=this._currentImage.fullExtent,h=[[0,0],[Math.min(i.width,e),0],[Math.min(i.width,e),Math.min(i.height,o)],[0,Math.min(i.height,o)]].map((e=>i.toMap(m(e[0],e[1]))));h.forEach((e=>{e.x=s<=e.x&&e.x<=a?e.x:Math.abs(s-e.x)>Math.abs(a-e.x)?a:s,e.y=n<=e.y&&e.y<=l?e.y:Math.abs(n-e.y)>Math.abs(l-e.y)?l:n}));const c=await V(h,{feature:this.getSelectedFeature(),currentCoveragePolygon:this.getSelectedFeaturePolygon(),imageProperties:this._currentImage.rasterInfo,options:{signal:r}});if(c&&!r.aborted){const e=[c.map((e=>[e.x,e.y,1]))];e[0].push(e[0][0]);const r=new Z({hasZ:!0,rings:e,spatialReference:c[0].spatialReference});this.updateCurrentCoveragePolygon(new t({attributes:{imageID:this.selectedFeature?.attributes.objectId},geometry:r,symbol:k,visible:this.currentCoverageVisible}))}}}};e([d()],te.prototype,"activeLayer",null),e([d()],te.prototype,"layer",void 0),e([d()],te.prototype,"shouldShowSelectedImage",void 0),e([d({type:Number})],te.prototype,"brightness",null),e([d({type:Number})],te.prototype,"contrast",null),e([d()],te.prototype,"coverageFrustums",void 0),e([d()],te.prototype,"coveragePolygons",void 0),e([d()],te.prototype,"currentCoverageVisible",void 0),e([d({readOnly:!0})],te.prototype,"currentImageView",null),e([d()],te.prototype,"disabled",void 0),e([d()],te.prototype,"displayMessage",void 0),e([d()],te.prototype,"pointSources",void 0),e([d()],te.prototype,"previousFeatureAngle",void 0),e([d()],te.prototype,"selectedFeature",void 0),e([d()],te.prototype,"selectedFeatureAngle",void 0),e([d()],te.prototype,"selectedPoint",void 0),e([d({readOnly:!0})],te.prototype,"featureCount",null),e([d()],te.prototype,"features",void 0),e([d({readOnly:!0})],te.prototype,"imageGalleryEnabled",null),e([d({readOnly:!0})],te.prototype,"imageLoaded",null),e([d()],te.prototype,"isAdditionalCoverageVisible",void 0),e([d()],te.prototype,"isAdditionalPointSourcesVisible",void 0),e([d({type:Number})],te.prototype,"localPort",void 0),e([d()],te.prototype,"mapImageConversionToolState",void 0),e([d()],te.prototype,"navigatorSelectedFeature",void 0),e([d({readOnly:!0})],te.prototype,"updating",null),e([d()],te.prototype,"referencePoint",null),e([d({type:Number})],te.prototype,"sharpness",null),e([d({readOnly:!0})],te.prototype,"sectorData",null),e([d({readOnly:!0})],te.prototype,"state",null),e([d({readOnly:!0})],te.prototype,"thumbnails",null),e([d({value:null})],te.prototype,"view",null),e([d()],te.prototype,"_additionalCoveragePolygons",void 0),e([d()],te.prototype,"_additionalFeatureGraphics",void 0),e([d()],te.prototype,"_currentCoveragePolygon",void 0),e([d()],te.prototype,"_currentImage",void 0),e([d()],te.prototype,"_fetchFeaturesController",void 0),e([d()],te.prototype,"_imageViewer",void 0),e([d()],te.prototype,"_initialCurrentCoveragePolygon",void 0),e([d()],te.prototype,"_initialCurrentCoverageUpdate",void 0),e([d()],te.prototype,"_overlays",void 0),e([d()],te.prototype,"_plotPolygons",void 0),e([d()],te.prototype,"_initialPreviousCoveragePolygon",void 0),e([d()],te.prototype,"_referencePointOnGround",void 0),e([d()],te.prototype,"_referencePointOnImage",void 0),e([d()],te.prototype,"_selectedFeatureGraphic",void 0),e([d()],te.prototype,"_sectorData",void 0),te=e([y("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],te);const re=te;export{re 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.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import{prefersReducedMotion as t}from"../core/a11yUtils.js";import i from"../core/Logger.js";import{watch as s,initial as a}from"../core/reactiveUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import{cast as r}from"../core/accessorSupport/decorators/cast.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import l from"../layers/support/rasterDatasets/RasterFactory.js";import c from"./Widget.js";import{getAllArcPath as d}from"./OrientedImageryViewer/arcUtils.js";import{defaultVisibleElements as h,css as g,navigationToolRotationFrom as m,navigationToolRotationTo as v,base as p,root as u,segmentArcs as b,sectorsRadii as y,featureCircleRadius as _,navigation as C,navigationToolDimensionLength as w}from"./OrientedImageryViewer/constants.js";import I from"./OrientedImageryViewer/OrientedImageryViewerViewModel.js";import{loadCalciteComponents as T}from"./support/componentsUtils.js";import"./support/widgetUtils.js";import{messageBundle as f}from"./support/decorators/messageBundle.js";import{tsx as M}from"./support/jsxFactory.js";let A=class extends c{constructor(e,t){super(e,t),this.isDocked=!1,this.galleryOpened=!1,this.imageEnhancementToolActive=!1,this.navigationToolActive=!1,this.viewModel=new I,this.messagesCommon=null,this.visibleElements={...h},this._navigationTool=null,this._actionItems=new Map,this._galleryController=new AbortController,this._galleryObserver=new IntersectionObserver(this._lazyLoadImage.bind(this)),this._loadImageFromGallery=this._loadImageFromGallery.bind(this),this._registerGalleryItem=this._registerGalleryItem.bind(this),this._unregisterGalleryItem=this._unregisterGalleryItem.bind(this),this._renderViewerContainer=this._renderViewerContainer.bind(this),this._renderViewer=this._renderViewer.bind(this)}initialize(){this.addHandles([s((()=>[this.viewModel?.selectedFeatureAngle,this._navigationTool]),(([e,t])=>{!this.viewModel.updating&&t&&this._updateNavigationTool(t)}),a),s((()=>this.currentCoverageVisible),(e=>this._onCurrentCoverageVisibilityChange(e))),s((()=>this.isAdditionalCoverageVisible),(e=>this._onAdditionalCoverageVisibilityChange(e))),s((()=>this.isAdditionalPointSourcesVisible),(e=>this._onAdditionalCameraLocationsVisibility(e)))])}loadDependencies(){return T({tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js"),action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel.js"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider.js")})}destroy(){this._galleryController.abort(),this._galleryObserver.disconnect()}get activeLayer(){return this.viewModel.activeLayer}set activeLayer(e){this.viewModel.activeLayer=e}get currentCoverageVisible(){return this.viewModel.currentCoverageVisible}set currentCoverageVisible(e){this.viewModel.currentCoverageVisible=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get imageGalleryEnabled(){return this.viewModel.imageGalleryEnabled}get isAdditionalCoverageVisible(){return this.viewModel.isAdditionalCoverageVisible}set isAdditionalCoverageVisible(e){this.viewModel.isAdditionalCoverageVisible=e}get isAdditionalPointSourcesVisible(){return this.viewModel.isAdditionalPointSourcesVisible}set isAdditionalPointSourcesVisible(e){this.viewModel.isAdditionalPointSourcesVisible=e}get mapImageConversionToolState(){return this.viewModel.mapImageConversionToolState}set mapImageConversionToolState(e){this.viewModel.mapImageConversionToolState=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...h,...e}}async _getThumbnailPixelBlockInternal(e,t){const{level:s,offset:a,size:o}=this._getMaxLevelRasterParameters(e);try{const{pixelBlock:i}=await e.fetchRawPixels(s,a,o,t);return i}catch(r){i.getLogger(this).warn("failed to create canvas with pixeldata",r)}return null}_getMaxLevelRasterParameters(e){const{storageInfo:t,width:i,height:s}=e.rasterInfo,{maximumPyramidLevel:a,pyramidScalingFactor:o}=t,r=o??2;return{level:a,offset:{x:0,y:0},size:{width:Math.ceil(i/r**a),height:Math.ceil(s/r**a)}}}async _getThumbnailPixelBlock(e){const{signal:t}=this._galleryController;try{const i=await l.open({url:e,signal:t});return i?await this._getThumbnailPixelBlockInternal(i,{signal:t}):null}catch(s){i.getLogger(this).error("failed to create thumbnail",s)}return null}_handleBrightnessChange(e){this.viewModel.brightness=e.target.value??0}_handleContrastChange(e){this.viewModel.contrast=e.target.value??0}_handleSharpnessChange(e){this.viewModel.sharpness=e.target.value??0}_lazyLoadImage(e,t){e.forEach((async e=>{if(e.isIntersecting){const i=e.target,s=i.getAttribute("data-src");if(!s)return;const a=await this._getThumbnailPixelBlock(s);if(!a)return;i.width=a.width,i.height=a.height;const o=i.getContext("2d");if(!o)return;const r=o.createImageData(i.width,i.height);r.data.set(a.getAsRGBA()),o.putImageData(r,0,0),t.unobserve(i)}}))}_loadImageFromGallery(e){const{target:t}=e;if(!t)return;const i=t.getAttribute("data-objectid");i&&this.viewModel.selectedFeature?.attributes.objectId!==Number(i)&&(this.viewModel.selectedFeature=this.viewModel.features?.find((({attributes:e})=>e.objectId===Number(i))))}_onAdditionalCoverageVisibilityChange(e){this.viewModel.setAdditionalCoverageVisibility(e)}_onAdditionalCameraLocationsVisibility(e){this.viewModel.setAdditionalCameraLocationsVisibility(e)}_onCurrentCoverageVisibilityChange(e){this.viewModel.setCurrentCoverageVisibility(e)}_registerGalleryItem(e){this._galleryObserver.observe(e)}_resetImageTools(){this.viewModel.sharpness=this.viewModel.brightness=this.viewModel.contrast=0}_resizeNavigationTool(){this._navigationTool?.parentElement?.classList.toggle(g.navigationZoomed)}_storeActionElement(e){this._actionItems.set(e.text,e)}_storeNavigationToolReference(e){this._navigationTool=e}_toggleAdditionalCameraLocations(){this.isAdditionalPointSourcesVisible=!this.isAdditionalPointSourcesVisible}_toggleAdditionalCoverage(){this.isAdditionalCoverageVisible=!this.isAdditionalCoverageVisible}_toggleCurrentCoverage(){this.currentCoverageVisible=!this.currentCoverageVisible}_toggleImageEnhancementToolState(e){e.stopPropagation(),this.imageEnhancementToolActive=!this.imageEnhancementToolActive,this.imageEnhancementToolActive&&(this.galleryOpened&&(this.galleryOpened=!1),this.navigationToolActive&&(this.navigationToolActive=!1))}_toggleImageGallery(e){e.stopPropagation(),this.galleryOpened=!!this.imageGalleryEnabled&&!this.galleryOpened,this.galleryOpened&&(this.imageEnhancementToolActive&&(this.imageEnhancementToolActive=!1),this.navigationToolActive&&(this.navigationToolActive=!1))}_toggleNavigationTool(){this.navigationToolActive=!this.navigationToolActive,this.navigationToolActive&&(this.galleryOpened&&(this.galleryOpened=!1),this.imageEnhancementToolActive&&(this.imageEnhancementToolActive=!1))}_toggleMapImageConversionToolState(){this.mapImageConversionToolState=!this.mapImageConversionToolState}_unregisterGalleryItem(e){this._galleryObserver.unobserve(e)}_updateNavigationTool(e){const{previousFeatureAngle:t,selectedFeatureAngle:i}=this.viewModel,s=(i-t+540)%360-180;e.style.setProperty(m,`${t}deg`),e.style.setProperty(v,`${t+s}deg`)}resetImage(){this.viewModel.resetImage()}render(){const{isDocked:e,viewModel:{updating:t}}=this;return M("div",{class:this.classes(p,u)},M("calcite-panel",{bind:this,class:e?g.dock:g.float,heading:this.visibleElements.title?this.messages.title:void 0,loading:t},this.visibleElements.coverageMenu?this._renderMenuBarContainer():null,this._renderBody()))}_renderActionTooltips(){return[...this._actionItems].map((([e,t])=>M("calcite-tooltip",{key:e,referenceElement:t},M("span",null,e))))}_renderBody(){return M("div",{class:g.body},this._renderViewerContainer(),this._renderImageGallery(),this._renderImageEnhancementTools(),this._renderNavigation())}_renderImageEnhancementTools(){const{imageEnhancementToolActive:e,viewModel:{brightness:t,contrast:i,sharpness:s}}=this;return e&&M("calcite-panel",{bind:this,class:g.imageEnhancementWrapper,closable:!0,closed:!e,heading:this.messages.imageEnhancement,key:this.messages.imageEnhancement,onCalcitePanelClose:this._toggleImageEnhancementToolState},M("div",{class:g.imageEnhancementTools},M("div",{class:g.imageEnhancementToolContainer},M("calcite-label",null,this.messages.brightness,M("calcite-slider",{bind:this,labelTicks:!0,max:10,min:-10,ticks:5,value:t,onCalciteSliderInput:this._handleBrightnessChange}))),M("div",{class:g.imageEnhancementToolContainer},M("calcite-label",null,this.messages.contrast,M("calcite-slider",{bind:this,labelTicks:!0,max:10,min:-10,ticks:5,value:i,onCalciteSliderInput:this._handleContrastChange}))),M("div",{class:g.imageEnhancementToolContainer},M("calcite-label",null,this.messages.sharpness,M("calcite-slider",{bind:this,labelTicks:!0,max:1,min:0,step:.1,ticks:.5,value:s,onCalciteSliderInput:this._handleSharpnessChange})))),M("calcite-action",{bind:this,icon:"reset",onclick:this._resetImageTools,slot:"header-actions-end",text:this.messagesCommon.reset}))}_renderImageGallery(){const{container:e,galleryOpened:t,imageGalleryEnabled:i,viewModel:{thumbnails:s}}=this;return i&&t&&(e&&s)?M("calcite-panel",{bind:this,class:g.carousel,closable:!0,closed:!t,heading:this.messages.imageGallery,key:this.messages.imageGallery,onCalcitePanelClose:this._toggleImageGallery},M("div",{class:g.carouselContainer},this._renderThumbnails(s))):null}_renderMapImageConversionTool(){const{mapImageConversionToolState:e,viewModel:{state:t}}=this;return M("calcite-action",{active:e,afterCreate:this._storeActionElement,bind:this,disabled:"image-loaded"!==t,icon:"image-pin",onclick:this._toggleMapImageConversionToolState,text:this.messages.mapImageConversionTool})}_renderNavigation(){const{viewModel:{sectorData:e,features:i,selectedFeature:s,updating:a,navigatorSelectedFeature:o}}=this;if(!i.length||!this.container||!s)return null;let r,n,l,c,h;if(o){const{x:e,y:t,direction:i}=o,[s,a,d,g]=b[i];r=`M ${e} ${t} L ${s} ${a} A ${y[2]} ${y[2]} 0 0 1 ${d} ${g} Z`,n=e,c=t,l=b[i][4],h=b[i][5]}const m=e=>{const t=e.target.dataset?.sector;t&&this.viewModel.handleSectorClick(+t)},v=e=>{const t=e.target.dataset;if(!t)return;const{featureIndexInSector:i,sector:s}=t;i&&s&&this.viewModel.handleFeatureClick({sector:s,featureIndexInSector:+i})},p=e=>{e.removeEventListener("click",v)},u=e?.map((e=>e?.items)).filter(Boolean).flatMap((e=>e?.map((({x:e,y:t,objectID:i,featureIndexInSector:a,sector:o})=>M("circle",{afterRemoved:p,class:this.classes(g.feature,{selected:s.attributes.objectId===i}),cx:e,cy:t,"data-featureIndexInSector":a,"data-sector":o,key:`${g.feature}-${i}`,onclick:v,r:_}))))),I=e=>{e.removeEventListener("click",m)};return this.navigationToolActive&&!a?M("div",{bind:this,class:g.navigationWrapper,key:this.messages.navigationTool},M("svg",{afterCreate:this._storeNavigationToolReference.bind(this),class:t()?C:g.rotateWithAnimation,focusable:"false",height:w,role:"img",width:w,xmlns:"http://www.w3.org/2000/svg"},M("defs",null,M("linearGradient",{gradientUnits:"userSpaceOnUse",id:`${this.id}-coverage-fill`,x1:n,x2:l,y1:c,y2:h},M("stop",{class:g.navigationPathOffset0,offset:0}),M("stop",{class:g.navigationPathOffset1,offset:1}))),M("g",null,M("circle",{class:this.classes(g.sector,g.outerSector),cx:y[3],cy:y[3],onclick:this._resizeNavigationTool.bind(this),r:y[3]}),M("circle",{class:g.sector,cx:y[3],cy:y[3],r:y[2]}),M("circle",{class:g.sector,cx:y[3],cy:y[3],r:y[1]}),M("circle",{class:g.sector,cx:y[3],cy:y[3],r:y[0]}),M("path",{class:g.pointer,d:"M 56.5 6.06217782649107 L 60 0 L 63.5 6.06217782649107 Z",key:`${g.pointer}-west`}),M("path",{class:this.classes(g.pointer,g.north),d:"M 113.93782217350893 56.5 L 120 60 L 113.93782217350893 63.5 Z",key:`${g.pointer}-north`}),M("path",{class:g.pointer,d:"M 56.5 113.93782217350893 L 60 120 L 63.5 113.93782217350893 Z",key:`${g.pointer}-east`}),M("path",{class:g.pointer,d:"M 6.06217782649107 56.5 L 0 60 L 6.06217782649107 63.5 Z",key:`${g.pointer}-south`}),M("path",{class:this.classes(g.sector,g.sectorSeparator),d:"M 23.937554159486076 23.937554159486076 L 96.06244584051393 96.06244584051393 M 23.937554159486076 96.06244584051393 L 96.06244584051393 23.937554159486076",key:g.sectorSeparator}),d([y[2],y[1],y[0]],y[3],y[3]).map(((t,i)=>M("path",{afterRemoved:I,class:this.classes(g.sector,e?.[i]?.length?g.sectorEnabled:g.sectorDisabled),d:t,"data-sector":`${i}`,key:`${g.sector}-${i}`,onclick:m}))),M("path",{class:this.classes(g.sector,g.sectorCross),d:"M 56.4 56.4 L 63.53 63.53 M 63.53 56.4 L 56.4 63.53",key:g.sectorCross}),u,s.attributes.cameraPitch>=5&&r?M("path",{class:g.selectedFeaturePath,d:r,fill:`url(#${this.id}-coverage-fill)`,key:g.selectedFeaturePath}):null))):null}_renderNavigationTool(){const{state:e}=this.viewModel;return M("calcite-action",{active:this.navigationToolActive,afterCreate:this._storeActionElement,bind:this,disabled:"image-loaded"!==e,icon:"explore",onclick:this._toggleNavigationTool,text:this.messages.navigationTool})}_renderImageEnhancementTool(){const{state:e}=this.viewModel;return M("calcite-action",{active:this.imageEnhancementToolActive,afterCreate:this._storeActionElement,bind:this,disabled:"image-loaded"!==e,icon:"sliders-horizontal",onclick:this._toggleImageEnhancementToolState,text:this.messages.imageEnhancement})}_renderMenuBarContainer(){const{currentCoverageVisible:e,isAdditionalCoverageVisible:t,isAdditionalPointSourcesVisible:i,imageGalleryEnabled:s}=this;return M("calcite-action-bar",{expandDisabled:!0,layout:"horizontal",slot:"action-bar"},M("calcite-action-group",{expanded:!0},M("calcite-action",{active:e,afterCreate:this._storeActionElement,bind:this,class:g.currentCoverage,icon:"trapezoid-area",onclick:this._toggleCurrentCoverage,text:this.messages.currentFootprint}),M("calcite-action",{active:t,afterCreate:this._storeActionElement,bind:this,class:g.addCoverage,icon:"trapezoid-area",onclick:this._toggleAdditionalCoverage,text:this.messages.additionalFootprints}),M("calcite-action",{active:i,afterCreate:this._storeActionElement,bind:this,class:g.addExpPoints,icon:"circle-area",onclick:this._toggleAdditionalCameraLocations,text:this.messages.additionalCameraLocations})),M("calcite-action-group",{layout:"horizontal"},this.visibleElements.mapImageConversionTool?this._renderMapImageConversionTool():null,this.visibleElements.navigationTool?this._renderNavigationTool():null,this.visibleElements.imageEnhancement?this._renderImageEnhancementTool():null),M("calcite-action-group",null,M("calcite-action",{active:this.galleryOpened,afterCreate:this._storeActionElement,bind:this,disabled:!s,icon:"images",onclick:this._toggleImageGallery,text:this.messages.imageGallery,textEnabled:!0})),this._renderActionTooltips())}_renderMessageBox(){const{displayMessage:e}=this.viewModel;return e?M("span",{class:g.messageBox},this.messages[e.key],e?.data):null}_renderThumbnails(e){const{selectedFeature:t}=this.viewModel;return t?M("div",{class:g.carouselContent},e.items.map((({url:e,objectId:i},s)=>M("div",{class:`${g.carouselItemWrapper}${t.attributes.objectId===i?"--selected":""}`,key:`${g.carouselItemWrapper}-${s}`},M("canvas",{afterCreate:this._registerGalleryItem,afterRemoved:this._unregisterGalleryItem,alt:`thumbnail-${i}`,class:g.carouselItem,"data-objectid":`${i}`,"data-src":e,onclick:this._loadImageFromGallery}))))):null}_renderViewerContainer(){return M("div",{class:g.viewerContainer},this._renderViewer(),this._renderMessageBox())}_renderViewer(){const{displayMessage:e}=this.viewModel;return M("div",{afterCreate:this.viewModel.loadViewer,bind:this,class:`${g.viewer}${e?"--hide":""}`})}};e([o()],A.prototype,"activeLayer",null),e([o()],A.prototype,"currentCoverageVisible",null),e([o()],A.prototype,"disabled",null),e([o()],A.prototype,"isDocked",void 0),e([o()],A.prototype,"galleryOpened",void 0),e([o()],A.prototype,"imageEnhancementToolActive",void 0),e([o()],A.prototype,"imageGalleryEnabled",null),e([o()],A.prototype,"isAdditionalCoverageVisible",null),e([o()],A.prototype,"isAdditionalPointSourcesVisible",null),e([o()],A.prototype,"mapImageConversionToolState",null),e([o()],A.prototype,"navigationToolActive",void 0),e([o({type:I})],A.prototype,"viewModel",void 0),e([o(),f("esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer")],A.prototype,"messages",void 0),e([o(),f("esri/t9n/common")],A.prototype,"messagesCommon",void 0),e([o()],A.prototype,"view",null),e([o()],A.prototype,"visibleElements",void 0),e([r("visibleElements")],A.prototype,"castVisibleElements",null),e([o()],A.prototype,"_navigationTool",void 0),A=e([n("esri.widgets.OrientedImageryViewer")],A);const E=A;export{E as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import{prefersReducedMotion as t}from"../core/a11yUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import s from"../core/Logger.js";import{watch as a,initial as o}from"../core/reactiveUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import{cast as n}from"../core/accessorSupport/decorators/cast.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import c from"../layers/support/rasterDatasets/RasterFactory.js";import d from"./Widget.js";import{getAllArcPath as h}from"./OrientedImageryViewer/arcUtils.js";import{defaultVisibleElements as g,css as m,navigationToolRotationFrom as v,navigationToolRotationTo as p,base as u,root as b,segmentArcs as y,sectorsRadii as _,featureCircleRadius as C,navigation as w,navigationToolDimensionLength as I}from"./OrientedImageryViewer/constants.js";import f from"./OrientedImageryViewer/OrientedImageryViewerViewModel.js";import{loadCalciteComponents as M}from"./support/componentsUtils.js";import"./support/widgetUtils.js";import{messageBundle as T}from"./support/decorators/messageBundle.js";import{tsx as A}from"./support/jsxFactory.js";let E=class extends d{constructor(e,t){super(e,t),this.dockEnabled=!1,this.galleryOpened=!1,this.imageEnhancementToolActive=!1,this.navigationToolActive=!1,this.viewModel=new f,this.messagesCommon=null,this.visibleElements={...g},this._navigationTool=null,this._actionItems=new Map,this._galleryController=new AbortController,this._galleryObserver=new IntersectionObserver(this._lazyLoadImage.bind(this)),this._loadImageFromGallery=this._loadImageFromGallery.bind(this),this._registerGalleryItem=this._registerGalleryItem.bind(this),this._unregisterGalleryItem=this._unregisterGalleryItem.bind(this),this._renderViewerContainer=this._renderViewerContainer.bind(this),this._renderViewer=this._renderViewer.bind(this)}initialize(){this.addHandles([a((()=>[this.viewModel?.selectedFeatureAngle,this._navigationTool]),(([e,t])=>{!this.viewModel.updating&&t&&this._updateNavigationTool(t)}),o),a((()=>this.currentCoverageVisible),(e=>this._onCurrentCoverageVisibilityChange(e))),a((()=>this.isAdditionalCoverageVisible),(e=>this._onAdditionalCoverageVisibilityChange(e))),a((()=>this.isAdditionalPointSourcesVisible),(e=>this._onAdditionalCameraLocationsVisibility(e)))])}loadDependencies(){return M({tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js"),action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel.js"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider.js")})}destroy(){this._galleryController.abort(),this._galleryObserver.disconnect()}get activeLayer(){return i(s.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){i(s.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get currentCoverageVisible(){return this.viewModel.currentCoverageVisible}set currentCoverageVisible(e){this.viewModel.currentCoverageVisible=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get isDocked(){return i(s.getLogger(this),"isDocked",{replacement:"dockEnabled"}),this.dockEnabled}set isDocked(e){i(s.getLogger(this),"isDocked",{replacement:"dockEnabled"}),this.dockEnabled=e}get imageGalleryEnabled(){return this.viewModel.imageGalleryEnabled}get isAdditionalCoverageVisible(){return this.viewModel.isAdditionalCoverageVisible}set isAdditionalCoverageVisible(e){this.viewModel.isAdditionalCoverageVisible=e}get isAdditionalPointSourcesVisible(){return this.viewModel.isAdditionalPointSourcesVisible}set isAdditionalPointSourcesVisible(e){this.viewModel.isAdditionalPointSourcesVisible=e}get mapImageConversionToolState(){return this.viewModel.mapImageConversionToolState}set mapImageConversionToolState(e){this.viewModel.mapImageConversionToolState=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get referencePoint(){return this.viewModel.referencePoint??null}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...g,...e}}async _getThumbnailPixelBlockInternal(e,t){const{level:i,offset:a,size:o}=this._getMaxLevelRasterParameters(e);try{const{pixelBlock:s}=await e.fetchRawPixels(i,a,o,t);return s}catch(r){s.getLogger(this).warn("failed to create canvas with pixeldata",r)}return null}_getMaxLevelRasterParameters(e){const{storageInfo:t,width:i,height:s}=e.rasterInfo,{maximumPyramidLevel:a,pyramidScalingFactor:o}=t,r=o??2;return{level:a,offset:{x:0,y:0},size:{width:Math.ceil(i/r**a),height:Math.ceil(s/r**a)}}}async _getThumbnailPixelBlock(e){const{signal:t}=this._galleryController;try{const i=await c.open({url:e,signal:t});return i?await this._getThumbnailPixelBlockInternal(i,{signal:t}):null}catch(i){s.getLogger(this).error("failed to create thumbnail",i)}return null}_handleBrightnessChange(e){this.viewModel.brightness=e.target.value??0}_handleContrastChange(e){this.viewModel.contrast=e.target.value??0}_handleSharpnessChange(e){this.viewModel.sharpness=e.target.value??0}_lazyLoadImage(e,t){e.forEach((async e=>{if(e.isIntersecting){const i=e.target,s=i.getAttribute("data-src");if(!s)return;const a=await this._getThumbnailPixelBlock(s);if(!a)return;i.width=a.width,i.height=a.height;const o=i.getContext("2d");if(!o)return;const r=o.createImageData(i.width,i.height);r.data.set(a.getAsRGBA()),o.putImageData(r,0,0),t.unobserve(i)}}))}_loadImageFromGallery(e){const{target:t}=e;if(!t)return;const i=t.getAttribute("data-objectid");i&&this.viewModel.selectedFeature?.attributes.objectId!==Number(i)&&(this.viewModel.selectedFeature=this.viewModel.features?.find((({attributes:e})=>e.objectId===Number(i))))}_onAdditionalCoverageVisibilityChange(e){this.viewModel.setAdditionalCoverageVisibility(e)}_onAdditionalCameraLocationsVisibility(e){this.viewModel.setAdditionalCameraLocationsVisibility(e)}_onCurrentCoverageVisibilityChange(e){this.viewModel.setCurrentCoverageVisibility(e)}_registerGalleryItem(e){this._galleryObserver.observe(e)}_resetImageTools(){this.viewModel.sharpness=this.viewModel.brightness=this.viewModel.contrast=0}_resizeNavigationTool(){this._navigationTool?.parentElement?.classList.toggle(m.navigationZoomed)}_storeActionElement(e){this._actionItems.set(e.text,e)}_storeNavigationToolReference(e){this._navigationTool=e}_toggleAdditionalCameraLocations(){this.isAdditionalPointSourcesVisible=!this.isAdditionalPointSourcesVisible}_toggleAdditionalCoverage(){this.isAdditionalCoverageVisible=!this.isAdditionalCoverageVisible}_toggleCurrentCoverage(){this.currentCoverageVisible=!this.currentCoverageVisible}_toggleImageEnhancementToolState(e){e.stopPropagation(),this.imageEnhancementToolActive=!this.imageEnhancementToolActive,this.imageEnhancementToolActive&&(this.galleryOpened&&(this.galleryOpened=!1),this.navigationToolActive&&(this.navigationToolActive=!1))}_toggleImageGallery(e){e.stopPropagation(),this.galleryOpened=!!this.imageGalleryEnabled&&!this.galleryOpened,this.galleryOpened&&(this.imageEnhancementToolActive&&(this.imageEnhancementToolActive=!1),this.navigationToolActive&&(this.navigationToolActive=!1))}_toggleNavigationTool(){this.navigationToolActive=!this.navigationToolActive,this.navigationToolActive&&(this.galleryOpened&&(this.galleryOpened=!1),this.imageEnhancementToolActive&&(this.imageEnhancementToolActive=!1))}_toggleMapImageConversionToolState(){this.mapImageConversionToolState=!this.mapImageConversionToolState}_unregisterGalleryItem(e){this._galleryObserver.unobserve(e)}_updateNavigationTool(e){const{previousFeatureAngle:t,selectedFeatureAngle:i}=this.viewModel,s=(i-t+540)%360-180;e.style.setProperty(v,`${t}deg`),e.style.setProperty(p,`${t+s}deg`)}loadBestImage(e){this.viewModel.loadBestImage(e)}async plotMapPoint(e){return this.viewModel.plotMapPoint(e)}resetImage(){this.viewModel.resetImage()}render(){const{dockEnabled:e,viewModel:{updating:t}}=this;return A("div",{class:this.classes(u,b)},A("calcite-panel",{bind:this,class:e?m.dock:m.float,heading:this.visibleElements.title?this.messages.title:void 0,loading:t},this.visibleElements.coverageMenu?this._renderMenuBarContainer():null,this._renderBody()))}_renderActionTooltips(){return[...this._actionItems].map((([e,t])=>A("calcite-tooltip",{key:e,referenceElement:t},A("span",null,e))))}_renderBody(){return A("div",{class:m.body},this._renderViewerContainer(),this._renderImageGallery(),this._renderImageEnhancementTools(),this._renderNavigation())}_renderImageEnhancementTools(){const{imageEnhancementToolActive:e,viewModel:{brightness:t,contrast:i,sharpness:s}}=this;return e&&A("calcite-panel",{bind:this,class:m.imageEnhancementWrapper,closable:!0,closed:!e,heading:this.messages.imageEnhancement,key:this.messages.imageEnhancement,onCalcitePanelClose:this._toggleImageEnhancementToolState},A("div",{class:m.imageEnhancementTools},A("div",{class:m.imageEnhancementToolContainer},A("calcite-label",null,this.messages.brightness,A("calcite-slider",{bind:this,labelTicks:!0,max:10,min:-10,ticks:5,value:t,onCalciteSliderInput:this._handleBrightnessChange}))),A("div",{class:m.imageEnhancementToolContainer},A("calcite-label",null,this.messages.contrast,A("calcite-slider",{bind:this,labelTicks:!0,max:10,min:-10,ticks:5,value:i,onCalciteSliderInput:this._handleContrastChange}))),A("div",{class:m.imageEnhancementToolContainer},A("calcite-label",null,this.messages.sharpness,A("calcite-slider",{bind:this,labelTicks:!0,max:1,min:0,step:.1,ticks:.5,value:s,onCalciteSliderInput:this._handleSharpnessChange})))),A("calcite-action",{bind:this,icon:"reset",onclick:this._resetImageTools,slot:"header-actions-end",text:this.messagesCommon.reset}))}_renderImageGallery(){const{container:e,galleryOpened:t,imageGalleryEnabled:i,viewModel:{thumbnails:s}}=this;return i&&t&&(e&&s)?A("calcite-panel",{bind:this,class:m.carousel,closable:!0,closed:!t,heading:this.messages.imageGallery,key:this.messages.imageGallery,onCalcitePanelClose:this._toggleImageGallery},A("div",{class:m.carouselContainer},this._renderThumbnails(s))):null}_renderMapImageConversionTool(){const{mapImageConversionToolState:e,viewModel:{imageLoaded:t}}=this;return A("calcite-action",{active:e,afterCreate:this._storeActionElement,bind:this,disabled:!t,icon:"image-pin",onclick:this._toggleMapImageConversionToolState,text:this.messages.mapImageConversionTool})}_renderNavigation(){const{viewModel:{sectorData:e,features:i,selectedFeature:s,updating:a,navigatorSelectedFeature:o}}=this;if(!i.length||!this.container||!s)return null;let r,n,l,c,d;if(o){const{x:e,y:t,direction:i}=o,[s,a,h,g]=y[i];r=`M ${e} ${t} L ${s} ${a} A ${_[2]} ${_[2]} 0 0 1 ${h} ${g} Z`,n=e,c=t,l=y[i][4],d=y[i][5]}const g=e=>{const t=e.target.dataset?.sector;t&&this.viewModel.handleSectorClick(+t)},v=e=>{const t=e.target.dataset;if(!t)return;const{featureIndexInSector:i,sector:s}=t;i&&s&&this.viewModel.handleFeatureClick({sector:s,featureIndexInSector:+i})},p=e=>{e.removeEventListener("click",v)},u=e?.map((e=>e?.items)).filter(Boolean).flatMap((e=>e?.map((({x:e,y:t,objectID:i,featureIndexInSector:a,sector:o})=>A("circle",{afterRemoved:p,class:this.classes(m.feature,{selected:s.attributes.objectId===i}),cx:e,cy:t,"data-featureIndexInSector":a,"data-sector":o,key:`${m.feature}-${i}`,onclick:v,r:C}))))),b=e=>{e.removeEventListener("click",g)};return this.navigationToolActive&&!a?A("div",{bind:this,class:m.navigationWrapper,key:this.messages.navigationTool},A("svg",{afterCreate:this._storeNavigationToolReference.bind(this),class:t()?w:m.rotateWithAnimation,focusable:"false",height:I,role:"img",width:I,xmlns:"http://www.w3.org/2000/svg"},A("defs",null,A("linearGradient",{gradientUnits:"userSpaceOnUse",id:`${this.id}-coverage-fill`,x1:n,x2:l,y1:c,y2:d},A("stop",{class:m.navigationPathOffset0,offset:0}),A("stop",{class:m.navigationPathOffset1,offset:1}))),A("g",null,A("circle",{class:this.classes(m.sector,m.outerSector),cx:_[3],cy:_[3],onclick:this._resizeNavigationTool.bind(this),r:_[3]}),A("circle",{class:m.sector,cx:_[3],cy:_[3],r:_[2]}),A("circle",{class:m.sector,cx:_[3],cy:_[3],r:_[1]}),A("circle",{class:m.sector,cx:_[3],cy:_[3],r:_[0]}),A("path",{class:m.pointer,d:"M 56.5 6.06217782649107 L 60 0 L 63.5 6.06217782649107 Z",key:`${m.pointer}-west`}),A("path",{class:this.classes(m.pointer,m.north),d:"M 113.93782217350893 56.5 L 120 60 L 113.93782217350893 63.5 Z",key:`${m.pointer}-north`}),A("path",{class:m.pointer,d:"M 56.5 113.93782217350893 L 60 120 L 63.5 113.93782217350893 Z",key:`${m.pointer}-east`}),A("path",{class:m.pointer,d:"M 6.06217782649107 56.5 L 0 60 L 6.06217782649107 63.5 Z",key:`${m.pointer}-south`}),A("path",{class:this.classes(m.sector,m.sectorSeparator),d:"M 23.937554159486076 23.937554159486076 L 96.06244584051393 96.06244584051393 M 23.937554159486076 96.06244584051393 L 96.06244584051393 23.937554159486076",key:m.sectorSeparator}),h([_[2],_[1],_[0]],_[3],_[3]).map(((t,i)=>A("path",{afterRemoved:b,class:this.classes(m.sector,e?.[i]?.length?m.sectorEnabled:m.sectorDisabled),d:t,"data-sector":`${i}`,key:`${m.sector}-${i}`,onclick:g}))),A("path",{class:this.classes(m.sector,m.sectorCross),d:"M 56.4 56.4 L 63.53 63.53 M 63.53 56.4 L 56.4 63.53",key:m.sectorCross}),u,s.attributes.cameraPitch>=5&&r?A("path",{class:m.selectedFeaturePath,d:r,fill:`url(#${this.id}-coverage-fill)`,key:m.selectedFeaturePath}):null))):null}_renderNavigationTool(){const{imageLoaded:e}=this.viewModel;return A("calcite-action",{active:this.navigationToolActive,afterCreate:this._storeActionElement,bind:this,disabled:!e,icon:"explore",onclick:this._toggleNavigationTool,text:this.messages.navigationTool})}_renderImageEnhancementTool(){const{imageLoaded:e}=this.viewModel;return A("calcite-action",{active:this.imageEnhancementToolActive,afterCreate:this._storeActionElement,bind:this,disabled:!e,icon:"sliders-horizontal",onclick:this._toggleImageEnhancementToolState,text:this.messages.imageEnhancement})}_renderMenuBarContainer(){const{currentCoverageVisible:e,isAdditionalCoverageVisible:t,isAdditionalPointSourcesVisible:i,imageGalleryEnabled:s}=this;return A("calcite-action-bar",{expandDisabled:!0,layout:"horizontal",slot:"action-bar"},A("calcite-action-group",{expanded:!0},A("calcite-action",{active:e,afterCreate:this._storeActionElement,bind:this,class:m.currentCoverage,icon:"trapezoid-area",onclick:this._toggleCurrentCoverage,text:this.messages.currentFootprint}),A("calcite-action",{active:t,afterCreate:this._storeActionElement,bind:this,class:m.addCoverage,icon:"trapezoid-area",onclick:this._toggleAdditionalCoverage,text:this.messages.additionalFootprints}),A("calcite-action",{active:i,afterCreate:this._storeActionElement,bind:this,class:m.addExpPoints,icon:"circle-area",onclick:this._toggleAdditionalCameraLocations,text:this.messages.additionalCameraLocations})),A("calcite-action-group",{layout:"horizontal"},this.visibleElements.mapImageConversionTool?this._renderMapImageConversionTool():null,this.visibleElements.navigationTool?this._renderNavigationTool():null,this.visibleElements.imageEnhancement?this._renderImageEnhancementTool():null),A("calcite-action-group",null,A("calcite-action",{active:this.galleryOpened,afterCreate:this._storeActionElement,bind:this,disabled:!s,icon:"images",onclick:this._toggleImageGallery,text:this.messages.imageGallery,textEnabled:!0})),this._renderActionTooltips())}_renderMessageBox(){const{displayMessage:e}=this.viewModel;return e?A("span",{class:m.messageBox},this.messages[e.key],e?.data):null}_renderThumbnails(e){const{selectedFeature:t}=this.viewModel;return t?A("div",{class:m.carouselContent},e.items.map((({url:e,objectId:i},s)=>A("div",{class:`${m.carouselItemWrapper}${t.attributes.objectId===i?"--selected":""}`,key:`${m.carouselItemWrapper}-${s}`},A("canvas",{afterCreate:this._registerGalleryItem,afterRemoved:this._unregisterGalleryItem,alt:`thumbnail-${i}`,class:m.carouselItem,"data-objectid":`${i}`,"data-src":e,onclick:this._loadImageFromGallery}))))):null}_renderViewerContainer(){return A("div",{class:m.viewerContainer},this._renderViewer(),this._renderMessageBox())}_renderViewer(){const{displayMessage:e}=this.viewModel;return A("div",{afterCreate:this.viewModel.loadViewer,bind:this,class:`${m.viewer}${e?"--hide":""}`})}};e([r()],E.prototype,"activeLayer",null),e([r()],E.prototype,"currentCoverageVisible",null),e([r()],E.prototype,"disabled",null),e([r()],E.prototype,"dockEnabled",void 0),e([r()],E.prototype,"isDocked",null),e([r()],E.prototype,"galleryOpened",void 0),e([r()],E.prototype,"imageEnhancementToolActive",void 0),e([r({readOnly:!0})],E.prototype,"imageGalleryEnabled",null),e([r()],E.prototype,"isAdditionalCoverageVisible",null),e([r()],E.prototype,"isAdditionalPointSourcesVisible",null),e([r()],E.prototype,"mapImageConversionToolState",null),e([r()],E.prototype,"layer",null),e([r()],E.prototype,"navigationToolActive",void 0),e([r({type:f})],E.prototype,"viewModel",void 0),e([r(),T("esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer")],E.prototype,"messages",void 0),e([r(),T("esri/t9n/common")],E.prototype,"messagesCommon",void 0),e([r()],E.prototype,"referencePoint",null),e([r()],E.prototype,"view",null),e([r()],E.prototype,"visibleElements",void 0),e([n("visibleElements")],E.prototype,"castVisibleElements",null),e([r()],E.prototype,"_navigationTool",void 0),E=e([l("esri.widgets.OrientedImageryViewer")],E);const k=E;export{k as default};
|
package/widgets/TimeSlider.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.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../chunks/tslib.es6.js";import e from"../TimeInterval.js";import{equals as i}from"../core/arrayUtils.js";import{neverReached as s}from"../core/compilerUtils.js";import{watch as o,initial as a}from"../core/reactiveUtils.js";import{truncateDate as n,offsetDate as r}from"../core/timeUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import{formatDate as u,convertDateFormatToIntlOptions as d}from"../intl/date.js";import{unknown as c,system as p}from"../time/timeZoneUtils.js";import v from"./Slider.js";import h from"./Widget.js";import{loadCalciteComponents as f}from"./support/componentsUtils.js";import{globalCss as y}from"./support/globalCss.js";import{legacyIcon as g}from"./support/legacyIcon.js";import{accessibleHandler as b}from"./support/decorators/accessibleHandler.js";import{messageBundle as x}from"./support/decorators/messageBundle.js";import{vmEvent as w}from"./support/decorators/vmEvent.js";import{tsx as k}from"./support/jsxFactory.js";import{onResize as j}from"./support/widgetUtils.js";import{getCalciteThemeClass as T}from"../support/themeUtils.js";import{css as _}from"./TimeSlider/css.js";import E from"./TimeSlider/TimeSliderViewModel.js";const M=3,S=858,F=[{minor:{value:100,unit:"milliseconds"},major:{value:1,unit:"seconds"},format:{second:"numeric"}},{minor:{value:500,unit:"milliseconds"},major:{value:5,unit:"seconds"},format:{second:"numeric"}},{minor:{value:1,unit:"seconds"},major:{value:20,unit:"seconds"},format:{minute:"numeric",second:"numeric"}},{minor:{value:2,unit:"seconds"},major:{value:30,unit:"seconds"},format:{minute:"numeric",second:"numeric"}},{minor:{value:10,unit:"seconds"},major:{value:1,unit:"minutes"},format:{minute:"numeric"}},{minor:{value:15,unit:"seconds"},major:{value:5,unit:"minutes"},format:{hour:"numeric",minute:"numeric"}},{minor:{value:1,unit:"minutes"},major:{value:20,unit:"minutes"},format:{hour:"numeric",minute:"numeric"}},{minor:{value:5,unit:"minutes"},major:{value:2,unit:"hours"},format:{hour:"numeric",minute:"numeric"}},{minor:{value:15,unit:"minutes"},major:{value:6,unit:"hours"},format:{hour:"numeric",minute:"numeric"}},{minor:{value:1,unit:"hours"},major:{value:1,unit:"days"},format:{day:"numeric",month:"short"}},{minor:{value:6,unit:"hours"},major:{value:1,unit:"weeks"},format:{day:"numeric",month:"short"}},{minor:{value:1,unit:"days"},major:{value:1,unit:"months"},format:{month:"long"}},{minor:{value:2,unit:"days"},major:{value:1,unit:"months"},format:{month:"short"}},{minor:{value:3,unit:"days"},major:{value:1,unit:"months"},format:{month:"short"}},{minor:{value:4,unit:"days"},major:{value:3,unit:"months"},format:{month:"short",year:"numeric"}},{minor:{value:1,unit:"weeks"},major:{value:1,unit:"years"},format:{year:"numeric"}},{minor:{value:1,unit:"months"},major:{value:1,unit:"years"},format:{year:"numeric"}},{minor:{value:2,unit:"months"},major:{value:2,unit:"years"},format:{year:"numeric"}},{minor:{value:1,unit:"years"},major:{value:1,unit:"decades"},format:{year:"numeric"}},{minor:{value:2,unit:"years"},major:{value:5,unit:"decades"},format:{year:"numeric"}},{minor:{value:5,unit:"decades"},major:{value:10,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:1,unit:"centuries"},major:{value:10,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:2,unit:"centuries"},major:{value:20,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:5,unit:"centuries"},major:{value:50,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:10,unit:"centuries"},major:{value:100,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:20,unit:"centuries"},major:{value:200,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:50,unit:"centuries"},major:{value:500,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:100,unit:"centuries"},major:{value:1e3,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:200,unit:"centuries"},major:{value:1e3,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:500,unit:"centuries"},major:{value:5e3,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:1e3,unit:"centuries"},major:{value:1e4,unit:"centuries"},format:{era:"short",year:"numeric"}}];let C=class extends h{constructor(t,e){super(t,e),this._ignoreNextSliderUpdate=!1,this._slider=new v({precision:0,visibleElements:{rangeLabels:!1},rangeLabelInputsEnabled:!1,thumbsConstrained:!1}),this._tickFormat=null,this.disabled=!1,this.iconClass=_.widgetIcon,this.icon=null,this.labelFormatFunction=null,this.messages=null,this.messagesCommon=null,this.tickConfigs=null,this.timeVisible=!1,this.viewModel=new E}initialize(){this.addHandles([o((()=>this._slider.values),(t=>{if(this._ignoreNextSliderUpdate)return void(this._ignoreNextSliderUpdate=!1);const e=this.viewModel.valuesToTimeExtent(t);null!=this.timeExtent?null!=e?this.timeExtent.equals(e)||(this.timeExtent=e):this.timeExtent=null:null!=e&&(this.timeExtent=e)})),o((()=>this.effectiveStops),(()=>this._updateSliderSteps()),a)])}loadDependencies(){return f({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu.js")})}destroy(){this._slider.destroy(),this._tickFormat=null}get _dateFormat(){return this._getIntlOptions("short-date")}get _timeFormat(){return this._getIntlOptions("long-time")}get actions(){return this.viewModel.actions}set actions(t){this.viewModel.actions=t}get effectiveStops(){return this.viewModel.effectiveStops}get fullTimeExtent(){return this.viewModel.fullTimeExtent}set fullTimeExtent(t){this.viewModel.fullTimeExtent=t}get interactive(){return!(this.disabled||"disabled"===this.viewModel.state||this.viewModel.view?.timeZone===c)}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}set layout(t){["auto","compact","wide"].includes(t)||(t="auto"),this._set("layout",t)}get loop(){return this.viewModel.loop}set loop(t){this.viewModel.loop=t}get mode(){return this.viewModel.mode}set mode(t){this.viewModel.mode=t}get playRate(){return this.viewModel.playRate}set playRate(t){this.viewModel.playRate=t}get stops(){return this.viewModel.stops}set stops(t){this.viewModel.stops=t}get tickFormats(){const{timeZone:t}=this;return F.map((({minor:i,major:s,format:o})=>({minor:new e(i),major:new e(s),format:{...o,timeZone:t}})))}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(t){this.viewModel.timeExtent=t}get timeZone(){return this.viewModel.view?.timeZone??p}set timeZone(t){this._overrideIfSome("timeZone",t)}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}static async getPropertiesFromWebMap(t,e){return E.getPropertiesFromWebMap(t,e)}next(){return this.viewModel.next()}play(){return this.viewModel.play()}previous(){return this.viewModel.previous()}stop(){return this.viewModel.stop()}render(){const{_slider:t,actions:e,domNode:s,effectiveStops:o,fullTimeExtent:a,interactive:n,messages:r,messagesCommon:l,mode:m,tickConfigs:d,timeExtent:c,timeVisible:p,viewModel:{state:v,timeExtentValues:h}}=this;if(null!=a){const{start:e,end:i}=a;if(null!=e&&null!=i){const s=e.getTime(),o=i.getTime(),a=t.min!==s||t.max!==o;if(a&&(t.min=s,t.max=o),null!=d)t.tickConfigs!==d&&(t.tickConfigs=d);else{const e=(o-s)/(t.trackElement?.offsetWidth||400),i=this.tickFormats.find((t=>t.minor.toMilliseconds()>M*e))??this.tickFormats.at(-1),n=this._tickFormat!==i&&null!=i;if(n&&(this._tickFormat=i),a||n){const e={mode:"position",values:this._getTickPositions(i.minor),labelsVisible:!1,tickCreatedFunction:(t,e)=>{e?.classList.add(_.sliderMinorTick)}},s={mode:"position",values:this._getTickPositions(i.major),labelsVisible:!0,tickCreatedFunction:(t,e)=>{e?.classList.add(_.sliderMajorTick)},labelFormatFunction:t=>u(t,i.format)};t.tickConfigs=[e,s]}}}}const f=null==this.fullTimeExtent?.start||null==this.fullTimeExtent.end||null==this.timeExtent||this.timeExtent.isAllTime||this.timeExtent.isEmpty||null!=this.timeExtent.start&&(this.timeExtent.start<this.fullTimeExtent.start||this.timeExtent.start>this.fullTimeExtent.end)||null!=this.timeExtent.end&&(this.timeExtent.end>this.fullTimeExtent.end||this.timeExtent.end<this.fullTimeExtent.start);if(f)switch(this._ignoreNextSliderUpdate=!0,m){case"time-window":t.values=[t.min,t.max];break;case"instant":case"cumulative-from-end":t.values=[t.min];break;case"cumulative-from-start":t.values=[t.max]}else null!=h?i(t.values,h)||(t.values=h):t.values=null;t.disabled=!n;const b="ready"===v,x="playing"===v,w=f||!n||null==o||0===o.length,E="auto"===this.layout?s.clientWidth<S?"compact":"wide":this.layout,F=k("div",{class:_.animation},k("button",{"aria-disabled":w?"true":"false","aria-label":x?l.control.stop:l.control.play,bind:this,class:this.classes(y.widgetButton,_.animationButton,w&&y.buttonDisabled),disabled:w,onclick:this._playOrStopClick,title:x?l.control.stop:l.control.play,type:"button"},k("div",{class:this.classes((b||w)&&g.play,x&&g.pause)}))),C=null!=this.labelFormatFunction?k("div",{afterCreate:this._createLabel,afterUpdate:this._createLabel,bind:this,class:_.timeExtentDate,"data-date":c?[c.start,c.end]:null,"data-layout":E,"data-type":"extent",key:"extent"}):null==c||null!=c&&c.isAllTime?[k("div",{class:this.classes(_.warning,g.noticeTriangle)}),k("div",{class:_.warningText,key:"warning-text"},r.noTimeExtent)]:c.isEmpty?[k("div",{class:this.classes(_.warning,g.noticeTriangle)}),k("div",{class:_.warningText,key:"warning-text"},r.emptyTimeExtent)]:[null!=c.start&&k("div",{class:_.timeExtentGroup,key:"start-date-group"},k("div",{class:_.timeExtentDate,key:"start-date"},this._formatDate(c.start)),p?k("div",{class:_.timeExtentTime,key:"start-time"},this._formatTime(c.start)):null),null!=c.start&&null!=c.end&&c.start.getTime()!==c.end.getTime()&&k("div",{class:_.timeExtentSeparator,key:"separator"},"–"),null!=c.end&&(null==c.start||c.start.getTime()!==c.end.getTime())&&k("div",{class:_.timeExtentGroup,key:"end-date-group"},k("div",{class:_.timeExtentDate,key:"end-date"},this._formatDate(c.end)),p?k("div",{class:_.timeExtentTime,key:"end-time"},this._formatTime(c.end)):null)],D=k("div",{class:this.classes(_.timeExtent,!n&&y.buttonDisabled)},[C]),U=null!=this.labelFormatFunction?k("div",{afterCreate:this._createLabel,afterUpdate:this._createLabel,bind:this,class:_.minDate,"data-date":a?.start,"data-layout":E,"data-type":"min",key:"min-date"}):null!=a?.start&&[k("div",{class:_.minDate,key:"min-date"},this._formatDate(a.start)),p&&k("div",{class:_.minTime,key:"min-time"},this._formatTime(a.start))],L=k("div",{class:this.classes(_.min,!n&&y.buttonDisabled)},[U]),Z=k("div",{class:_.slider},t.render()),R=null!=this.labelFormatFunction?k("div",{afterCreate:this._createLabel,afterUpdate:this._createLabel,bind:this,class:_.maxDate,"data-date":a?.end,"data-layout":E,"data-type":"max",key:"max-date"}):null!=a?.end&&[k("div",{class:_.maxDate,key:"max-date"},this._formatDate(a.end)),p&&k("div",{class:_.maxTime,key:"max-time"},this._formatTime(a.end))],B=k("div",{class:this.classes(_.max,!n&&y.buttonDisabled)},[R]),I=k("div",{class:_.previous},k("button",{"aria-disabled":w?"true":"false","aria-label":l.pagination.previous,bind:this,class:this.classes(y.widgetButton,_.previousButton,(x||w)&&y.buttonDisabled),disabled:w,onclick:this._previousClick,title:l.pagination.previous,type:"button"},k("div",{class:g.reverse}))),O=k("div",{class:_.next},k("button",{"aria-disabled":w?"true":"false","aria-label":l.pagination.next,bind:this,class:this.classes(y.widgetButton,_.nextButton,(x||w)&&y.buttonDisabled),disabled:w,onclick:this._nextClick,title:l.pagination.next,type:"button"},k("div",{class:g.forward}))),A=e?.length>0,V=A&&k("div",{class:_.actions,title:l.options},k("calcite-action-menu",{class:_.actionsButton,label:l.options},e.toArray().map((t=>k("calcite-action",{bind:this,icon:t.icon,id:t.id,onclick:()=>this.viewModel.triggerAction(t),text:t.title,textEnabled:!0})))));return k("div",{afterCreate:t=>{this.addHandles(j(t,(()=>this.scheduleRender())))},"aria-label":r.widgetLabel,class:this.classes(_.timeSlider,y.widget,`${_.timeSliderMode}${m}`,`${_.timeSliderLayout}${E}`,!n&&y.disabled,f&&_.timeSliderOutOfBounds,A&&_.hasActions,T())},"wide"===E&&k("div",{class:_.timeSliderRow},k("div",{class:_.playbackControls},[F,D,L,Z,B,I,O]),V),"compact"===E&&[k("div",{class:_.timeSliderRow,key:"time-slider-row-1"},[D,V]),k("div",{class:_.timeSliderRow,key:"time-slider-row-2"},[Z]),k("div",{class:_.timeSliderRow,key:"time-slider-row-3"},[L,I,F,O,B])])}updateWebDocument(t){this.viewModel?.updateWebDocument(t)}_createLabel(t){if(null==this.labelFormatFunction)return;const e=t.getAttribute("data-type"),i=t.getAttribute("data-layout"),s=t["data-date"];this.labelFormatFunction(s,e,t,i)}_formatDate(t){return u(t,this._dateFormat)}_formatTime(t){return u(t,this._timeFormat)}_getIntlOptions(t){const{timeZone:e}=this;return{...d(t),timeZone:e}}_getTickPositions(t){const{fullTimeExtent:e}=this;if(null==e?.start||null==e.end)return[];const{start:i,end:s}=e,o=[],{value:a,unit:l}=t;let m=n(i,l,this.timeZone);for(;m.getTime()<=s.getTime();)m.getTime()>=i.getTime()&&o.push(m.getTime()),m=r(m,a,l,this.timeZone);return o}_updateSliderSteps(){this._slider.steps=null!=this.effectiveStops&&this.effectiveStops.length>0?this.effectiveStops.map((t=>t.getTime())):null}_playOrStopClick(){switch(this.viewModel.state){case"ready":this.viewModel.play();break;case"playing":this.viewModel.stop();break;case"disabled":break;default:s(this.viewModel.state)}}_previousClick(){this.viewModel.previous()}_nextClick(){this.viewModel.next()}};t([l()],C.prototype,"_dateFormat",null),t([l()],C.prototype,"_timeFormat",null),t([l()],C.prototype,"actions",null),t([l()],C.prototype,"disabled",void 0),t([l()],C.prototype,"effectiveStops",null),t([l()],C.prototype,"fullTimeExtent",null),t([l()],C.prototype,"iconClass",void 0),t([l()],C.prototype,"icon",void 0),t([l({readOnly:!0})],C.prototype,"interactive",null),t([l()],C.prototype,"label",null),t([l()],C.prototype,"labelFormatFunction",void 0),t([l({value:"auto"})],C.prototype,"layout",null),t([l()],C.prototype,"loop",null),t([l(),x("esri/widgets/TimeSlider/t9n/TimeSlider")],C.prototype,"messages",void 0),t([l(),x("esri/t9n/common")],C.prototype,"messagesCommon",void 0),t([l()],C.prototype,"mode",null),t([l()],C.prototype,"playRate",null),t([l()],C.prototype,"stops",null),t([l()],C.prototype,"tickConfigs",void 0),t([l()],C.prototype,"tickFormats",null),t([l()],C.prototype,"timeExtent",null),t([l({nonNullable:!0})],C.prototype,"timeVisible",void 0),t([l()],C.prototype,"timeZone",null),t([l()],C.prototype,"view",null),t([l({type:E}),w("trigger-action")],C.prototype,"viewModel",void 0),t([b()],C.prototype,"_playOrStopClick",null),t([b()],C.prototype,"_previousClick",null),t([b()],C.prototype,"_nextClick",null),C=t([m("esri.widgets.TimeSlider")],C);const D=C;export{D as default};
|
|
5
|
+
import{_ as t}from"../chunks/tslib.es6.js";import e from"../TimeInterval.js";import{equals as i}from"../core/arrayUtils.js";import{neverReached as s}from"../core/compilerUtils.js";import{watch as o,initial as a}from"../core/reactiveUtils.js";import{truncateDate as n,offsetDate as r}from"../core/timeUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import{formatDate as u,convertDateFormatToIntlOptions as d}from"../intl/date.js";import{unknown as c,system as p}from"../time/timeZoneUtils.js";import h from"./Slider.js";import v from"./Widget.js";import{loadCalciteComponents as f}from"./support/componentsUtils.js";import{globalCss as y}from"./support/globalCss.js";import{legacyIcon as g}from"./support/legacyIcon.js";import{accessibleHandler as b}from"./support/decorators/accessibleHandler.js";import{messageBundle as x}from"./support/decorators/messageBundle.js";import{vmEvent as w}from"./support/decorators/vmEvent.js";import{tsx as k}from"./support/jsxFactory.js";import{onResize as j}from"./support/widgetUtils.js";import{getCalciteThemeClass as T}from"../support/themeUtils.js";import{css as _}from"./TimeSlider/css.js";import E from"./TimeSlider/TimeSliderViewModel.js";const M=3,S=858,F=[{minor:{value:100,unit:"milliseconds"},major:{value:1,unit:"seconds"},format:{second:"numeric"}},{minor:{value:500,unit:"milliseconds"},major:{value:5,unit:"seconds"},format:{second:"numeric"}},{minor:{value:1,unit:"seconds"},major:{value:20,unit:"seconds"},format:{minute:"numeric",second:"numeric"}},{minor:{value:2,unit:"seconds"},major:{value:30,unit:"seconds"},format:{minute:"numeric",second:"numeric"}},{minor:{value:10,unit:"seconds"},major:{value:1,unit:"minutes"},format:{minute:"numeric"}},{minor:{value:15,unit:"seconds"},major:{value:5,unit:"minutes"},format:{hour:"numeric",minute:"numeric"}},{minor:{value:1,unit:"minutes"},major:{value:20,unit:"minutes"},format:{hour:"numeric",minute:"numeric"}},{minor:{value:5,unit:"minutes"},major:{value:2,unit:"hours"},format:{hour:"numeric",minute:"numeric"}},{minor:{value:15,unit:"minutes"},major:{value:6,unit:"hours"},format:{hour:"numeric",minute:"numeric"}},{minor:{value:1,unit:"hours"},major:{value:1,unit:"days"},format:{day:"numeric",month:"short"}},{minor:{value:6,unit:"hours"},major:{value:1,unit:"weeks"},format:{day:"numeric",month:"short"}},{minor:{value:1,unit:"days"},major:{value:1,unit:"months"},format:{month:"long"}},{minor:{value:2,unit:"days"},major:{value:1,unit:"months"},format:{month:"short"}},{minor:{value:3,unit:"days"},major:{value:1,unit:"months"},format:{month:"short"}},{minor:{value:4,unit:"days"},major:{value:3,unit:"months"},format:{month:"short",year:"numeric"}},{minor:{value:1,unit:"weeks"},major:{value:1,unit:"years"},format:{year:"numeric"}},{minor:{value:1,unit:"months"},major:{value:1,unit:"years"},format:{year:"numeric"}},{minor:{value:2,unit:"months"},major:{value:2,unit:"years"},format:{year:"numeric"}},{minor:{value:1,unit:"years"},major:{value:1,unit:"decades"},format:{year:"numeric"}},{minor:{value:2,unit:"years"},major:{value:5,unit:"decades"},format:{year:"numeric"}},{minor:{value:5,unit:"decades"},major:{value:10,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:1,unit:"centuries"},major:{value:10,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:2,unit:"centuries"},major:{value:20,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:5,unit:"centuries"},major:{value:50,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:10,unit:"centuries"},major:{value:100,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:20,unit:"centuries"},major:{value:200,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:50,unit:"centuries"},major:{value:500,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:100,unit:"centuries"},major:{value:1e3,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:200,unit:"centuries"},major:{value:1e3,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:500,unit:"centuries"},major:{value:5e3,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:1e3,unit:"centuries"},major:{value:1e4,unit:"centuries"},format:{era:"short",year:"numeric"}}];let C=class extends v{constructor(t,e){super(t,e),this._ignoreNextSliderUpdate=!1,this._slider=new h({precision:0,visibleElements:{rangeLabels:!1},rangeLabelInputsEnabled:!1,thumbsConstrained:!1}),this._tickFormat=null,this.disabled=!1,this.iconClass=_.widgetIcon,this.icon=null,this.labelFormatFunction=null,this.messages=null,this.messagesCommon=null,this.tickConfigs=null,this.timeVisible=!1,this.viewModel=new E}initialize(){this.addHandles([o((()=>this._slider.values),(t=>{if(this._ignoreNextSliderUpdate)return void(this._ignoreNextSliderUpdate=!1);const e=this.viewModel.valuesToTimeExtent(t);null!=this.timeExtent?null!=e?this.timeExtent.equals(e)||(this.timeExtent=e):this.timeExtent=null:null!=e&&(this.timeExtent=e)})),o((()=>this.effectiveStops),(()=>this._updateSliderSteps()),a)])}loadDependencies(){return f({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu.js")})}destroy(){this._slider.destroy(),this._tickFormat=null}get _dateFormat(){return this._getIntlOptions("short-date")}get _timeFormat(){return this._getIntlOptions("long-time")}get actions(){return this.viewModel.actions}set actions(t){this.viewModel.actions=t}get effectiveStops(){return this.viewModel.effectiveStops}get fullTimeExtent(){return this.viewModel.fullTimeExtent}set fullTimeExtent(t){this.viewModel.fullTimeExtent=t}get interactive(){return!(this.disabled||"disabled"===this.viewModel.state||this.timeZone===c)}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}set layout(t){["auto","compact","wide"].includes(t)||(t="auto"),this._set("layout",t)}get loop(){return this.viewModel.loop}set loop(t){this.viewModel.loop=t}get mode(){return this.viewModel.mode}set mode(t){this.viewModel.mode=t}get playRate(){return this.viewModel.playRate}set playRate(t){this.viewModel.playRate=t}get stops(){return this.viewModel.stops}set stops(t){this.viewModel.stops=t}get tickFormats(){const{timeZone:t}=this;return F.map((({minor:i,major:s,format:o})=>({minor:new e(i),major:new e(s),format:{...o,timeZone:t}})))}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(t){this.viewModel.timeExtent=t}get timeZone(){return this.viewModel.view?.timeZone??p}set timeZone(t){this._overrideIfSome("timeZone",t)}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}static async getPropertiesFromWebMap(t,e){return E.getPropertiesFromWebMap(t,e)}next(){return this.viewModel.next()}play(){return this.viewModel.play()}previous(){return this.viewModel.previous()}stop(){return this.viewModel.stop()}render(){const{_slider:t,actions:e,domNode:s,effectiveStops:o,fullTimeExtent:a,interactive:n,messages:r,messagesCommon:l,mode:m,tickConfigs:d,timeExtent:c,timeVisible:p,viewModel:{state:h,timeExtentValues:v}}=this;if(null!=a){const{start:e,end:i}=a;if(null!=e&&null!=i){const s=e.getTime(),o=i.getTime(),a=t.min!==s||t.max!==o;if(a&&(t.min=s,t.max=o),null!=d)t.tickConfigs!==d&&(t.tickConfigs=d);else{const e=(o-s)/(t.trackElement?.offsetWidth||400),i=this.tickFormats.find((t=>t.minor.toMilliseconds()>M*e))??this.tickFormats.at(-1),n=this._tickFormat!==i&&null!=i;if(n&&(this._tickFormat=i),a||n){const e={mode:"position",values:this._getTickPositions(i.minor),labelsVisible:!1,tickCreatedFunction:(t,e)=>{e?.classList.add(_.sliderMinorTick)}},s={mode:"position",values:this._getTickPositions(i.major),labelsVisible:!0,tickCreatedFunction:(t,e)=>{e?.classList.add(_.sliderMajorTick)},labelFormatFunction:t=>u(t,i.format)};t.tickConfigs=[e,s]}}}}const f=null==this.fullTimeExtent?.start||null==this.fullTimeExtent.end||null==this.timeExtent||this.timeExtent.isAllTime||this.timeExtent.isEmpty||null!=this.timeExtent.start&&(this.timeExtent.start<this.fullTimeExtent.start||this.timeExtent.start>this.fullTimeExtent.end)||null!=this.timeExtent.end&&(this.timeExtent.end>this.fullTimeExtent.end||this.timeExtent.end<this.fullTimeExtent.start);if(f)switch(this._ignoreNextSliderUpdate=!0,m){case"time-window":t.values=[t.min,t.max];break;case"instant":case"cumulative-from-end":t.values=[t.min];break;case"cumulative-from-start":t.values=[t.max]}else null!=v?i(t.values,v)||(t.values=v):t.values=null;t.disabled=!n;const b="ready"===h,x="playing"===h,w=f||!n||null==o||0===o.length,E="auto"===this.layout?s.clientWidth<S?"compact":"wide":this.layout,F=k("div",{class:_.animation},k("button",{"aria-disabled":w?"true":"false","aria-label":x?l.control.stop:l.control.play,bind:this,class:this.classes(y.widgetButton,_.animationButton,w&&y.buttonDisabled),disabled:w,onclick:this._playOrStopClick,title:x?l.control.stop:l.control.play,type:"button"},k("div",{class:this.classes((b||w)&&g.play,x&&g.pause)}))),C=null!=this.labelFormatFunction?k("div",{afterCreate:this._createLabel,afterUpdate:this._createLabel,bind:this,class:_.timeExtentDate,"data-date":c?[c.start,c.end]:null,"data-layout":E,"data-type":"extent",key:"extent"}):null==c||null!=c&&c.isAllTime?[k("div",{class:this.classes(_.warning,g.noticeTriangle)}),k("div",{class:_.warningText,key:"warning-text"},r.noTimeExtent)]:c.isEmpty?[k("div",{class:this.classes(_.warning,g.noticeTriangle)}),k("div",{class:_.warningText,key:"warning-text"},r.emptyTimeExtent)]:[null!=c.start&&k("div",{class:_.timeExtentGroup,key:"start-date-group"},k("div",{class:_.timeExtentDate,key:"start-date"},this._formatDate(c.start)),p?k("div",{class:_.timeExtentTime,key:"start-time"},this._formatTime(c.start)):null),null!=c.start&&null!=c.end&&c.start.getTime()!==c.end.getTime()&&k("div",{class:_.timeExtentSeparator,key:"separator"},"–"),null!=c.end&&(null==c.start||c.start.getTime()!==c.end.getTime())&&k("div",{class:_.timeExtentGroup,key:"end-date-group"},k("div",{class:_.timeExtentDate,key:"end-date"},this._formatDate(c.end)),p?k("div",{class:_.timeExtentTime,key:"end-time"},this._formatTime(c.end)):null)],D=k("div",{class:this.classes(_.timeExtent,!n&&y.buttonDisabled)},[C]),U=null!=this.labelFormatFunction?k("div",{afterCreate:this._createLabel,afterUpdate:this._createLabel,bind:this,class:_.minDate,"data-date":a?.start,"data-layout":E,"data-type":"min",key:"min-date"}):null!=a?.start&&[k("div",{class:_.minDate,key:"min-date"},this._formatDate(a.start)),p&&k("div",{class:_.minTime,key:"min-time"},this._formatTime(a.start))],L=k("div",{class:this.classes(_.min,!n&&y.buttonDisabled)},[U]),Z=k("div",{class:_.slider},t.render()),R=null!=this.labelFormatFunction?k("div",{afterCreate:this._createLabel,afterUpdate:this._createLabel,bind:this,class:_.maxDate,"data-date":a?.end,"data-layout":E,"data-type":"max",key:"max-date"}):null!=a?.end&&[k("div",{class:_.maxDate,key:"max-date"},this._formatDate(a.end)),p&&k("div",{class:_.maxTime,key:"max-time"},this._formatTime(a.end))],B=k("div",{class:this.classes(_.max,!n&&y.buttonDisabled)},[R]),I=k("div",{class:_.previous},k("button",{"aria-disabled":w?"true":"false","aria-label":l.pagination.previous,bind:this,class:this.classes(y.widgetButton,_.previousButton,(x||w)&&y.buttonDisabled),disabled:w,onclick:this._previousClick,title:l.pagination.previous,type:"button"},k("div",{class:g.reverse}))),O=k("div",{class:_.next},k("button",{"aria-disabled":w?"true":"false","aria-label":l.pagination.next,bind:this,class:this.classes(y.widgetButton,_.nextButton,(x||w)&&y.buttonDisabled),disabled:w,onclick:this._nextClick,title:l.pagination.next,type:"button"},k("div",{class:g.forward}))),A=e?.length>0,V=A&&k("div",{class:_.actions,title:l.options},k("calcite-action-menu",{class:_.actionsButton,label:l.options},e.toArray().map((t=>k("calcite-action",{bind:this,icon:t.icon,id:t.id,onclick:()=>this.viewModel.triggerAction(t),text:t.title,textEnabled:!0})))));return k("div",{afterCreate:t=>{this.addHandles(j(t,(()=>this.scheduleRender())))},"aria-label":r.widgetLabel,class:this.classes(_.timeSlider,y.widget,`${_.timeSliderMode}${m}`,`${_.timeSliderLayout}${E}`,!n&&y.disabled,f&&_.timeSliderOutOfBounds,A&&_.hasActions,T())},"wide"===E&&k("div",{class:_.timeSliderRow},k("div",{class:_.playbackControls},[F,D,L,Z,B,I,O]),V),"compact"===E&&[k("div",{class:_.timeSliderRow,key:"time-slider-row-1"},[D,V]),k("div",{class:_.timeSliderRow,key:"time-slider-row-2"},[Z]),k("div",{class:_.timeSliderRow,key:"time-slider-row-3"},[L,I,F,O,B])])}updateWebDocument(t){this.viewModel?.updateWebDocument(t)}_createLabel(t){if(null==this.labelFormatFunction)return;const e=t.getAttribute("data-type"),i=t.getAttribute("data-layout"),s=t["data-date"];this.labelFormatFunction(s,e,t,i)}_formatDate(t){return u(t,this._dateFormat)}_formatTime(t){return u(t,this._timeFormat)}_getIntlOptions(t){const{timeZone:e}=this;return{...d(t),timeZone:e}}_getTickPositions(t){const{fullTimeExtent:e}=this;if(null==e?.start||null==e.end)return[];const{start:i,end:s}=e,o=[],{value:a,unit:l}=t;let m=n(i,l,this.timeZone);for(;m.getTime()<=s.getTime();)m.getTime()>=i.getTime()&&o.push(m.getTime()),m=r(m,a,l,this.timeZone);return o}_updateSliderSteps(){this._slider.steps=null!=this.effectiveStops&&this.effectiveStops.length>0?this.effectiveStops.map((t=>t.getTime())):null}_playOrStopClick(){switch(this.viewModel.state){case"ready":this.viewModel.play();break;case"playing":this.viewModel.stop();break;case"disabled":break;default:s(this.viewModel.state)}}_previousClick(){this.viewModel.previous()}_nextClick(){this.viewModel.next()}};t([l()],C.prototype,"_dateFormat",null),t([l()],C.prototype,"_timeFormat",null),t([l()],C.prototype,"actions",null),t([l()],C.prototype,"disabled",void 0),t([l()],C.prototype,"effectiveStops",null),t([l()],C.prototype,"fullTimeExtent",null),t([l()],C.prototype,"iconClass",void 0),t([l()],C.prototype,"icon",void 0),t([l({readOnly:!0})],C.prototype,"interactive",null),t([l()],C.prototype,"label",null),t([l()],C.prototype,"labelFormatFunction",void 0),t([l({value:"auto"})],C.prototype,"layout",null),t([l()],C.prototype,"loop",null),t([l(),x("esri/widgets/TimeSlider/t9n/TimeSlider")],C.prototype,"messages",void 0),t([l(),x("esri/t9n/common")],C.prototype,"messagesCommon",void 0),t([l()],C.prototype,"mode",null),t([l()],C.prototype,"playRate",null),t([l()],C.prototype,"stops",null),t([l()],C.prototype,"tickConfigs",void 0),t([l()],C.prototype,"tickFormats",null),t([l()],C.prototype,"timeExtent",null),t([l({nonNullable:!0})],C.prototype,"timeVisible",void 0),t([l()],C.prototype,"timeZone",null),t([l()],C.prototype,"view",null),t([l({type:E}),w("trigger-action")],C.prototype,"viewModel",void 0),t([b()],C.prototype,"_playOrStopClick",null),t([b()],C.prototype,"_previousClick",null),t([b()],C.prototype,"_nextClick",null),C=t([m("esri.widgets.TimeSlider")],C);const D=C;export{D as default};
|
package/widgets/TimeZoneLabel.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.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import{getAssetPath as t}from"@esri/calcite-components/dist/components/index.js";import"../intl.js";import s from"../request.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as o}from"../core/accessorSupport/decorators/subclass.js";import{getShortOffsetTimeZoneSuffix as r}from"../intl/date.js";import{unknown as n}from"../time/timeZoneUtils.js";import a from"./Widget.js";import{loadCalciteComponents as
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import{getAssetPath as t}from"@esri/calcite-components/dist/components/index.js";import"../intl.js";import s from"../request.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as o}from"../core/accessorSupport/decorators/subclass.js";import{getShortOffsetTimeZoneSuffix as r}from"../intl/date.js";import{unknown as n}from"../time/timeZoneUtils.js";import a from"./Widget.js";import{loadCalciteComponents as c}from"./support/componentsUtils.js";import{globalCss as d}from"./support/globalCss.js";import{isRTL as l}from"./support/widgetUtils.js";import{messageBundle as p}from"./support/decorators/messageBundle.js";import{tsx as m}from"./support/jsxFactory.js";import{css as u}from"./TimeZoneLabel/css.js";import h from"./TimeZoneLabel/TimeZoneLabelViewModel.js";import{onLocaleChange as g,getLocale as b}from"../intl/locale.js";import{substitute as v}from"../intl/substitute.js";import{normalizeMessageBundleLocale as f}from"../intl/messages.js";let j=class extends a{constructor(e,t){super(e,t),this.disabled=!1,this.expanded=!1,this.icon=null,this.inputTimeZoneMessages=null,this.messages=null,this.viewModel=new h,this._onExpanderClick=()=>{this.expanded=!this.expanded}}initialize(){this.addHandles(g((()=>this._updateMessageBundle()))),this._updateMessageBundle()}loadDependencies(){return c({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js")})}get expandDirection(){if(!this.view||!this.container)return"end";const e=l();switch(this.view.ui.getPosition(this.container)){case"top-right":case"bottom-right":case"top-trailing":case"bottom-trailing":return e?"end":"start";case"top-left":case"bottom-left":case"top-leading":case"bottom-leading":return e?"start":"end";default:return"end"}}set expandDirection(e){this._overrideIfSome("expandDirection",e)}get formattedTimeZone(){const{timeZoneComponents:e}=this.viewModel;if(!e)return"";const{timeZone:t}=e;if("area"in e){const{area:s,location:i}=e;if("etc"===s.toLowerCase())return r(t)??t;const o=this.messages.area[s.toLowerCase()]??s,n=this.inputTimeZoneMessages??{},a=Object.entries(n).find((([e])=>e.toLowerCase()===t.toLowerCase()))?.[1]??i;return v(this.messages.locationArea,{area:o,location:a})}return t===n?this.messages.noAdjustment:t}get interactive(){return!(this.disabled||"disabled"===this.viewModel.state)}get label(){return this.messages.widgetLabel}set label(e){this._overrideIfSome("label",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){const{expandDirection:e,interactive:t,label:s}=this,i=this.classes(u.base,d.widget,!t&&d.disabled),o=[this._renderExpander(),this._renderName(),this._renderBadge()];return"start"===e&&o.reverse(),m("div",{"aria-label":s,class:i},o)}_getIcon(){const{expanded:e,expandDirection:t}=this;return e?l()?"start"===t?"chevrons-left":"chevrons-right":"start"===t?"chevrons-right":"chevrons-left":"time-zone"}_renderExpander(){const{interactive:e,label:t}=this,s=this._getIcon();return m("calcite-action",{active:!1,class:u.expander,disabled:!e,icon:s,key:u.expander,onclick:this._onExpanderClick,scale:"s",text:t,textEnabled:!1,title:t})}_renderBadge(){const{expanded:e,interactive:t}=this;return m("div",{class:this.classes(u.badge,!e&&u.badgeHidden,!t&&u.badgeDisabled)},m("calcite-icon",{class:u.badgeIcon,icon:"time-zone",scale:"s"}))}_renderName(){const{expanded:e,formattedTimeZone:t,interactive:s}=this;return m("span",{class:this.classes(u.name,!e&&u.nameHidden,!s&&u.nameDisabled),key:u.name},t)}async _updateMessageBundle(){const e=t("assets/input-time-zone/t9n/messages"),i=b(),o=`${e}_${f(i)}.json`,r=await s(o,{responseType:"text"}).catch((()=>{}));this.inputTimeZoneMessages=JSON.parse(r?.data??{})}};e([i()],j.prototype,"disabled",void 0),e([i()],j.prototype,"expandDirection",null),e([i()],j.prototype,"expanded",void 0),e([i({readOnly:!0})],j.prototype,"formattedTimeZone",null),e([i()],j.prototype,"icon",void 0),e([i()],j.prototype,"inputTimeZoneMessages",void 0),e([i({readOnly:!0})],j.prototype,"interactive",null),e([i()],j.prototype,"label",null),e([i(),p("esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel")],j.prototype,"messages",void 0),e([i()],j.prototype,"view",null),e([i()],j.prototype,"viewModel",void 0),j=e([o("esri.widgets.TimeZoneLabel")],j);const w=j;export{w 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.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{id as t}from"../../kernel.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import i from"../../core/Evented.js";import a from"../../core/Logger.js";import{when as l}from"../../core/reactiveUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import c from"../../geometry/Point.js";import{fetchMessageBundle as h}from"../../intl/messages.js";import u from"../../layers/FeatureLayer.js";import p from"../../layers/GraphicsLayer.js";import d from"../../layers/support/CodedValueDomain.js";import{isFeatureLayer as g}from"../../layers/support/layerUtils.js";import m from"../../networks/UtilityNetwork.js";import{getObjectIdsFromElements as y,getFeaturesFromLayers as f}from"../../networks/support/utils.js";import w from"../../portal/Portal.js";import{hasUserTypeExtension as _}from"../../portal/support/utils.js";import{trace as b}from"../../rest/networks/trace.js";import A from"../../rest/networks/support/TraceLocation.js";import v from"../../rest/networks/support/TraceParameters.js";import{GeometryHandler as R}from"./support/GeometryHandler.js";import{GraphicHandler as I}from"./support/GraphicHandler.js";import{ResultAreaHandler as k}from"./support/ResultAreaHandler.js";import{UtilityHelper as F}from"./support/UtilityHelper.js";const S=()=>h("esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace"),T=()=>h("esri/core/t9n/Units"),G=`utility-network-trace-flags-${Date.now()}`,L=`utility-network-trace-results-${Date.now()}`;function H(e){return e instanceof d}function P(e){return"feature"===e.layer.type||"subtype-group"===e.layer.type}function U(e){return"layer"in e}function N(e){return void 0!==e.layerViews}function C(e){return"graphics"===e.type}async function E(e){const t=new u({url:e.networkSystemLayers.dirtyAreasLayerUrl});await t.load();const r=t.version;if(Number(r)<=11.1){const t=new w({url:new URL(e.layerUrl).origin+"/portal"});await t.load();const r=t?.user?.username;return!!r&&_(t,r,"utilityNetwork")}return!0}let B=class extends i.EventedAccessor{constructor(e){super(e),this._activeProgress=!1,this._clickHandler=null,this._flags=[],this._geometryHandler=null,this._highlightHandler=[],this._resultAreaHandler=null,this._utilityHelper=new F,this._traces=[],this._watchHandler=null,this._validUNLayers=[],this._traceTimeout=6e5,this.graphicHandler=null,this.defaultGraphicColor={color:[255,255,0,.6],haloOpacity:.9,fillOpacity:.2,hex:"#FFFF00"},this.enableResultArea=!1,this.flags=[],this.gdbVersion="sde.DEFAULT",this.messages=null,this.messagesUnits=null,this.defaultResultAreaProperties={type:"convexhull",distance:10,unit:"meters",areaUnit:"square-meters",color:{color:[255,165,0,.5],haloOpacity:.9,fillOpacity:.2,hex:"#ffa500"},show:!1},this.selectedTraces=[],this.selectOnComplete=!0,this.showGraphicsOnComplete=!0,this.showSelectionAttributes=!0,this.traceResults=[],this.utilityNetwork=null}initialize(){this._geometryHandler=new R,this.graphicHandler=new I,this._resultAreaHandler=new k;(async()=>{const[e,t]=await Promise.all([S(),T()]);this.set({messages:e,messagesUnits:t})})()}destroy(){this.view=null}get resultAreaProperties(){return this.defaultResultAreaProperties}set resultAreaProperties(e){this._set("resultAreaProperties",{...this.defaultResultAreaProperties,...e}),this.graphicHandler.addCustomColor(this.resultAreaProperties.color),this.traceResults.forEach((t=>{t.resultArea={...this.defaultResultAreaProperties,...e};const r=t.resultArea.show;this.removeResultAreaFromMap(t),r&&this.enableResultArea&&this.addResultAreaToMap(t)}))}get state(){return this.view?.ready?"ready":"loading"}get view(){return this._get("view")}set view(e){e&&"2d"!==e.type&&a.getLogger(this).error(new s("view:invalid-view","SceneView is not supported",{view:e})),this._set("view",e)}addFlagByHit(e,t){const r=e=>{this.view?.popup&&(this.view.popupEnabled=e)};return new Promise(((s,i)=>{r(!1),this._clickHandler?.remove(),this.emit("add-flag",{type:e}),this._clickHandler=this.view?.on("click",(a=>{this.queryFlagByHitTest(a,e,t).then((i=>{r(!0),this._clickHandler?.remove(),this.emit("add-flag-complete",{type:e,symbol:t}),s(i)})).catch((s=>{r(!0),this._clickHandler?.remove(),this.emit("add-flag-error",{type:e,symbol:t}),i(s)}))}))}))}async addFlagsOnLoad(){return new Promise((e=>{const t=[];this._watchHandler=l((()=>null!=this.view&&!this.view.updating),(async()=>{if(this._flags.length>0)e(t);else{const r=this.flags.map((async e=>{if(e.mapPoint){const r=new c({x:e.mapPoint.x,y:e.mapPoint.y,spatialReference:e.mapPoint.spatialReference.wkid}),s={screenPoint:this.view.toScreen(r),mapPoint:r};await this.queryFlagByHitTest(s,e.type)||("barrier"===e.type?t.push("barrier"):t.push("starting-point"))}}));await Promise.all(r),e(t)}}),{initial:!0})}))}addResultAreaToMap(e){if(e.resultArea.show=!0,null!==e.results?.aggregatedGeometry){const t=this._geometryHandler.mergeAggregatedToGeometries(e.results?.aggregatedGeometry);if(t.length>0){const r=Array(t.length).fill(e.resultArea?.distance);this.createResultAreaGeometries(e,t,r)}}else{const t=this._groupResultsByNetworkSource(e.results.elements),r=[];for(const e in t)r.push(this.queryFeaturesById(t[e]));Promise.all(r).then((t=>{const r=[];for(const e of t)for(const t of e)for(const e of t.featureSet.features)r.push(e.geometry);const s=Array(r.length).fill(e.resultArea?.distance);this.createResultAreaGeometries(e,r,s)})).catch((e=>{console.log(e)}))}}async addResultGraphicToView(e,t){const{view:r}=this,{results:s}=e;if(r&&s)for(const i in s.aggregatedGeometry)if("line,multipoint,polygon".includes(i)){const a=i,l=s.aggregatedGeometry[a];if(null!=l){l.spatialReference=this.utilityNetwork.spatialReference,e.graphicEnabled=!0;const s=await this._geometryHandler.projectGeometry(l,r.spatialReference),i={globalid:e.trace.globalId};if(null!==s){const e=this.graphicHandler.makeGraphic(s,t.color,i,r.spatialReference);this._getGraphicLayer(L)?.add(e)}}}}addTerminal(e,t){const r=[...this._flags];r.forEach((r=>{r.globalId===t.globalId&&(t.selectedTerminals?.includes(parseInt(e,10))||r.selectedTerminals?.push(parseInt(e,10)))})),this._flags=r}async callTrace(){const e=this._traces.filter((e=>e.selected));return e.length>0&&(this.traceResults.length>0&&this.traceResults.forEach((e=>{this.removeResultGraphicFromView(e)})),this.traceResults=[],this.removeSelection(),await Promise.all(e.map((async(e,t)=>{const r=e,s=new v({gdbVersion:this.gdbVersion,moment:null,traceType:r.traceType,traceLocations:this._flags,namedTraceConfigurationGlobalId:r.globalId,traceConfiguration:null,outSpatialReference:null,resultTypes:null});await this.executeTrace(r,this.utilityNetwork.networkServiceUrl,s).then((e=>{if(e.hasOwnProperty("results")){const r={...e};if(null!==r.results){r.resultArea={...this.resultAreaProperties};const e=[...r.results.elements];r.results.elements.length=0;const s=new Map;for(const t of e)s.has(t.globalId)||(s.set(t.globalId,!0),r.results.elements.push(t));const i=[...this.traceResults];i.splice(t,0,r),this.traceResults=i,null!==r.results&&(this.selectOnComplete&&this.mergeSelection(!0,r.trace),this.showGraphicsOnComplete&&this.addResultGraphicToView(r,r.graphicColor),this.enableResultArea&&r.resultArea.show&&this.addResultAreaToMap(r))}else{const r=[...this.traceResults];r.splice(t,0,e),this.traceResults=r}this._activeProgress=!1}else{this._activeProgress=!1;const r=[...this.traceResults];r.splice(t,0,e),this.traceResults=r}})).catch((e=>{throw this._activeProgress=!1,e}))}))),!0)}changeResultAreaColor(e,t){e.resultArea&&(e.resultArea.color=t,this._resultAreaHandler?.changeResultAreaColor(e.trace.globalId,t,this.view.map))}changeResultGraphicColor(e,t){const r=[...this.traceResults];r.length>0&&r.forEach((r=>{r.trace.globalId===t.trace.globalId&&(r.graphicColor=e,r.graphicEnabled=!0)})),this.traceResults=r,this.removeResultGraphicFromView(t),this.addResultGraphicToView(t,e)}changeFlagSymbol(e,t){this._flags.length>0&&this._flags.forEach((r=>{r.type===e&&t&&r.mapGraphic&&(r.mapGraphic.symbol=t)}))}checkCanTrace(){const e={status:!0,issues:[]};let t=!1;const r=this._flags.some((e=>"starting-point"===e.type)),s=this._flags.filter((e=>null!==e.allTerminals));s.length>0&&(t=s.some((e=>e.selectedTerminals.length<=0)));let i=[];return r?(i=this._traces.filter((e=>e.selected)),i.length<=0?(e.status=!1,e.issues=["noTrace"],t&&(e.status=!1,e.issues=["noTrace","noTerminalSelected"])):t&&(e.status=!1,e.issues=["noTerminalSelected"])):(i=this._traces.filter((e=>!0===e.selected)),i.length>0?(e.status=!1,e.issues=["noStart"],t&&(e.status=!1,e.issues=["noStart","noTerminalSelected"])):(e.status=!1,e.issues=["noStart","noTrace"],t&&(e.status=!1,e.issues=["noStart","noTrace","noTerminalSelected"]))),e}checkSelectionExist(){let e=!1;return this._highlightHandler.some((t=>{t&&(e=!0)})),e}clearResult(e){if(!this.view)return;let t=this.traceResults;if(t.length>0){const r=t.filter((t=>t.trace.globalId===e.globalId));r.length>0&&(this.removeResultGraphicFromView(r[0]),this.removeResultAreaFromMap(r[0])),t=t.filter((t=>t.trace.globalId!==e.globalId))}this.traceResults=t,0===t.length?(this.removeAllResultAreaGraphics(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]})):this.mergeSelection(!1,e)}createResultAreaGeometries(e,t,r){if(!this.view||!this.resultAreaProperties)return;let s;if("convexhull"===this.resultAreaProperties?.type?s=this._resultAreaHandler?.createConvexHull(t,e.resultArea?.distance,e.resultArea?.unit):t&&(s=this._resultAreaHandler?.createBuffer(t,r,e.resultArea?.unit,!0)),s&&Array.isArray(s)){if(s.length>0)for(const i of s){const t=this.getResultAreaAttributes(e,i),r=this._resultAreaHandler?.createResultAreaGraphic(i,t,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color);r&&(this._resultAreaHandler?.addResultAreaToMap(r,this.view.map),this.emit("add-result-area",{graphic:r}))}}else{const t=this.getResultAreaAttributes(e,s),r=this._resultAreaHandler?.createResultAreaGraphic(s,t,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color);r&&(this._resultAreaHandler?.addResultAreaToMap(r,this.view.map),this.emit("add-result-area",{graphic:r}))}}executeTrace(e,t,r){const s=this._processFlags(r.traceLocations);return r.traceLocations=s,b(t,r,{timeout:this._traceTimeout}).then((t=>({trace:e,results:t,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:"success",date:new Date}))).catch((t=>({trace:e,results:null,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:t.message,date:new Date})))}getResultAreaAttributes(e,r){const{messages:s}=this,i=[],a=[];this._flags.forEach((e=>{const t=e.displayValue?.field+":"+e.displayValue?.value+";"+s.attributeStrings.globalid+":"+e.globalId+";"+s.attributeStrings.terminalid+":"+e.terminalId+";"+s.attributeStrings.x+":"+e.mapPoint?.x+";"+s.attributeStrings.y+":"+e.mapPoint?.y;"starting-point"===e.type?i.push(t):a.push(t)}));return{traceId:e.trace.globalId,traceName:e.trace.title,traceDescription:e.trace.description??"",startingPoints:i.toString(),barriers:a.toString(),version:this.gdbVersion,username:t.credentials[0].userId,date:e.date,elementCount:e.results?.elements.length,functionResult:JSON.stringify(e.results?.globalFunctionResults),areaStatistic:this._geometryHandler.calculateArea(r,e.resultArea?.areaUnit)}}getValidSources(){let e=[];const t=this.utilityNetwork.dataElement?.domainNetworks??[];for(const r of t)e=e.concat(r.junctionSources),e=e.concat(r.edgeSources);return e}async loadUtilityNetwork(){const{view:e}=this;if(!e)return null;if(await e.when(),this.utilityNetwork){if(this.utilityNetwork.loaded||await this.utilityNetwork.load(),this.utilityNetwork instanceof m){try{const t=e.map;await t.loadAll(),this._loadUNSupportItems()}catch(i){this._loadUNSupportItems()}return this.utilityNetwork}return null}const t=e.map,r=t.utilityNetworks?.at(0);if(r){if(await r.load(),this.utilityNetwork=r,!await E(r))throw new s("utility-network:no-user-type-extension","User type extension not found");try{await t.loadAll(),this._loadUNSupportItems()}catch(i){}finally{this._loadUNSupportItems()}return r}return null}manageFilterBarrier(e,t){const r=[...this._flags];r.forEach((r=>{r.globalId===t.globalId&&"barrier"===t.type&&r.id===t.id&&(r.isFilterBarrier=e)})),this._flags=r}mergeSelection(e,t){let r=[];const s=[...this.traceResults],i=t.globalId;s.forEach((t=>{i===t.trace.globalId&&(t.selectionEnabled=e),t.selectionEnabled&&null!==t.results?.elements&&(r=[...r,...t.results?.elements??[]])})),this.selectResults([...new Set(r)])}async queryFeaturesById(e){const{view:t}=this;if(!t)return null;const s=y(this.utilityNetwork,e),i={layerUrl:s[0].layerUrl,objectIds:s[0].objectIds,outFields:["*"]},a=t.map?.allTables.toArray().filter((e=>e?.parsedUrl?.path===s[0].layerUrl)).filter(g)??[];this._getUniqueMapLayerViews(t).filter((({layer:e})=>e?.parsedUrl?.path===s[0].layerUrl)).forEach((({layer:e})=>{"feature"!==e.type&&"subtype-group"!==e.type||a.push(e)}));const l=(await Promise.all(a.map((async e=>{const s={layers:new r([e]),layerInfos:[i],returnGeometry:!0,outSpatialReference:t.spatialReference},[a]=await f(s,!1);return a})))).filter((({featureSet:e})=>e.features.length>0));return l.length>0?l:null}queryFlagByHitTest(e,t,r){return this._lookupFlagByHit(e).then((e=>{const{view:s}=this;if(!s)return!1;if(e.length>0){const s=[...this._flags],i=r;return e.forEach((e=>{const r=e.graphic,a=r.attributes.hasOwnProperty("GLOBALID")?r.attributes.GLOBALID:r.attributes.globalid;if(s.filter((e=>e.globalId===a)).length<=0){const e=this.graphicHandler.getFlagGraphic(r.mapPoint,t,r,i);this._getGraphicLayer(G)?.add(e),s.push({...r,type:t,globalId:r.attributes.globalid||r.attributes.GLOBALID,details:r,mapGraphic:e,id:s.length+1})}else if(null!==r.percentAlong){const e=this.graphicHandler.getFlagGraphic(r.mapPoint,t,r,i);this._getGraphicLayer(G)?.add(e),s.push({...r,type:t,globalId:r.attributes.globalid||r.attributes.GLOBALID,details:r,mapGraphic:e,id:s.length+1})}})),this._flags=s,!0}return!1}))}removeResultGraphicFromView(e){const{view:t}=this;if(!t)return;const r=this._getGraphicLayer(L)?.graphics;e.graphicEnabled=!1;const s=r?.filter((t=>t.attributes[t.attributes.hasOwnProperty("GLOBALID")?"GLOBALID":"globalid"]===e.trace.globalId));s?.forEach((e=>{this._getGraphicLayer(L)?.remove(e)}))}removeFlag(e){const t=this._flags.filter((t=>{if(t.id!==e.id)return t}));this._removeGraphic(e),this._flags=t}removeAllResultAreaGraphics(){this._resultAreaHandler?.removeAllResultAreaGraphics(this.view.map)}removeResultAreaFromMap(e){e.resultArea.show=!1;const t=this._resultAreaHandler?.removeResultArea(e.trace.globalId,this.view?.map);t&&this.emit("remove-result-area",{graphic:t})}removeSelection(){this._highlightHandler.forEach((e=>{e&&e.remove()})),this._highlightHandler=[]}removeTerminal(e,t){const r=[...this._flags];r.forEach((r=>{if(r.globalId===t.globalId&&t.selectedTerminals?.includes(parseInt(e,10))){const s=t.selectedTerminals.indexOf(parseInt(e,10));r.selectedTerminals?.splice(s,1)}})),this._flags=r}removeFlagsOnLoadWatcher(){this._watchHandler&&null!==this._watchHandler&&this._watchHandler.remove()}reset(){this._flags=[],this.traceResults=[];const e=[...this._traces];e.forEach((e=>{e.selected=!1})),this._traces=e,this.view&&(this._getGraphicLayer(L)?.removeAll(),this._getGraphicLayer(G)?.removeAll(),this.removeAllResultAreaGraphics(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]}))}selectFeaturesById(e){const{view:t}=this;if(!t)return;const r=y(this.utilityNetwork,e);this._getUniqueMapLayerViews(t).forEach((e=>{U(e)&&e.layer?.parsedUrl?.path===r[0].layerUrl&&P(e)&&this._highlightHandler.push(e.highlight(r[0].objectIds))}))}selectResults(e){if(e.length>0){this.removeSelection();const t=this._groupResultsByNetworkSource(e),r=[];for(const e in t)this.selectFeaturesById(t[e]),r.push(this.queryFeaturesById(t[e]));Promise.all(r).then((e=>{this.emit("select-features",{resultSet:e})}))}else this.removeSelection(),this.emit("clear-selection",{resultSet:[]})}selectTraces(e,t){const r=[...this._traces];r.forEach((r=>{t===r.globalId&&(r.selected=e)})),this._traces=r}selectTracesOnLoad(){this.utilityNetwork.hasOwnProperty("sharedNamedTraceConfigurations")&&(this._traces=[...this.utilityNetwork.sharedNamedTraceConfigurations],this._traces.forEach((e=>{e.selected=!1,this.selectedTraces.includes(e.globalId)&&(e.selected=!0)})))}zoomToAsset(e){this.view?.goTo(e).catch((e=>console.error(e)))}_loadUNSupportItems(){const{map:e}=this.view,{messages:t}=this;this._populateOutfields(),this._createGraphicLayer(G),this._createGraphicLayer(L),this._resultAreaHandler?.createGraphicLayer(e,t?.alertsStrings.genericResultHeader),this._validUNLayers=this._utilityHelper.getValidUtilityNetworkLayers(e,this.utilityNetwork)}_getUniqueMapLayerViews(e){const t=[];return e.layerViews.filter((({layer:{type:e}})=>"feature"===e||"group"===e||"subtype-group"===e)).toArray().forEach((e=>{switch(e.layer.type){case"group":if(N(e))for(const r of e.layerViews)t.push(r);break;case"subtype-group":t.push(e);break;default:t.some((t=>t.layer.id===e.layer.id))||t.push(e)}})),t}_processFlags(e){const t=[];return e.forEach((e=>{if(null!==e.selectedTerminals&&e.selectedTerminals.length>0)e.selectedTerminals.forEach((r=>{const s=new A({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:r,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(s)}));else{const r=new A({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:null,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(r)}})),t}_getDisplayField(e){return"subtype-sublayer"===e?.layer?.type?this._getDisplayFieldBySublayer(e):this._getDisplayFieldByFeatureLayer(e)}_getDisplayFieldBySublayer(e){let t="",r="";const s=e.layer;t=this._checkParentForData(s,"displayField");for(const i in e.attributes){const a=i.toLowerCase();a===t?.toLowerCase()?(r=e.attributes[i],"assetgroup"===a||"assettype"===a?r=this._checkSubtype(s,s.subtypeCode):(r=this._checkDomain(s.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,s)))):(r=this._checkDomain(s.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,s)))}return{field:t,value:r.toString()}}_getDisplayFieldByFeatureLayer(e){const t=e.layer;let r=t.displayField,s="";for(const i in e.attributes){const a=i.toLowerCase();if(a===r?.toLowerCase())if(s=e.attributes[i],"assetgroup"===a||"assettype"===a){let a=e.attributes[t.typeIdField.toUpperCase()];a||(a=e.attributes[t.typeIdField.toLowerCase()]),r=t.typeIdField,s=this._checkSubtype(t,a),""===r&&(t.templates&&t.templates.length>0?(r=t.templates[0]?.name,s=t.templates[0]?.name):(r=t.displayField,s=e.attributes[i]))}else s=this._checkDomain(t.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,t));else s=this._checkDomain(t.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,t))}return{field:r,value:s?s.toString():""}}_checkSubtype(e,t){let r=t;if("subtype-sublayer"===e.type){const s=this._checkParentForData(e,"subtypes");s?.length>0&&s.forEach((e=>{e.code===t&&(r=e.name)}))}else if(null!=e.types&&e.types.length>0){const s=e.types.filter((e=>e.id===t));s.length>0&&(r=s[0].name)}return r}_checkDomain(e,t,r){let s=r;const i=e.filter((e=>e.name.toLowerCase()===t.toLowerCase()));if(i.length>0&&H(i[0].domain)&&i[0].domain?.codedValues){const e=i[0].domain.codedValues.filter((({code:e})=>e===r));e.length>0&&(s=e[0].name)}return s}_checkParentForData(e,t){return e.parent?.[t]??null}_defaultDisplayField(e,t){return e.trim()?e:t.templates&&t.templates?.length>0?t.templates[0].name:t.title}_groupBy(e,t){return e.reduce(((e,r)=>((e[r[t]]=e[r[t]]||[]).push(r),e)),{})}_groupResultsByNetworkSource(e){if(e.length>0){return this._groupBy(e,"networkSourceId")}return[]}_lookupFlagByHit(e){return this.view.hitTest(e.screenPoint,{include:this._validUNLayers}).then((t=>{const r=[];if(t.results.length>0){const s=t.results.find((e=>null!==e.layer));if(null!=s.graphic?.geometry)if("polyline"===s.graphic.geometry.type){const t=this._geometryHandler.getPercentageAlong(s.graphic.geometry,e.mapPoint,s.graphic.geometry.spatialReference),i=this._getDisplayField(s.graphic);s.graphic.terminalId=null,s.graphic.isFilterBarrier=!1,s.graphic.allTerminals=null,s.graphic.selectedTerminals=null,s.graphic.percentAlong=t,s.graphic.displayValue=i,s.graphic.mapPoint=s.mapPoint,r.push(s)}else if(("point"===s.graphic.geometry.type||"polygon"===s.graphic.geometry.type)&&null!==this.utilityNetwork){const e=this.utilityNetwork.getTerminalConfiguration(s.graphic),t=this._getDisplayField(s.graphic);s.graphic.terminalId=e?e.terminals[0].id||null:1,s.graphic.isFilterBarrier=!1,s.graphic.allTerminals=e??null,s.graphic.selectedTerminals=[e?e.terminals[0].id||null:1],s.graphic.percentAlong=null,s.graphic.displayValue=t,s.graphic.mapPoint=s.mapPoint,r.push(s)}}return r}))}async _populateOutfields(){const e=this.view?.map,t=this.getValidSources();e?.layers.forEach((e=>{"group"===e.type?e.layers.forEach((e=>{t.some((t=>t.layerId===e.layerId))&&e.fields.some((e=>"assetgroup"===e.name.toLowerCase()))&&(e.outFields=["assetgroup","assettype","globalid","objectid"])})):t.some((t=>t.layerId===e.layerId))&&e.fields.some((e=>"assetgroup"===e.name.toLowerCase()))&&(e.outFields=["assetgroup","assettype","globalid","objectid"])}))}_removeGraphic(e){this._getGraphicLayer(G)?.remove(e.mapGraphic)}_createGraphicLayer(e){const{map:t}=this.view;if(!t.findLayerById(e)){const r=new p({title:e,listMode:"hide",id:e});t.add(r)}}_getGraphicLayer(e){const{map:t}=this.view;if(t){const r=t.findLayerById(e);if(r&&C(r))return r}return null}};e([o()],B.prototype,"_activeProgress",void 0),e([o()],B.prototype,"_flags",void 0),e([o()],B.prototype,"_traces",void 0),e([o()],B.prototype,"defaultGraphicColor",void 0),e([o()],B.prototype,"enableResultArea",void 0),e([o()],B.prototype,"flags",void 0),e([o()],B.prototype,"gdbVersion",void 0),e([o()],B.prototype,"messages",void 0),e([o()],B.prototype,"messagesUnits",void 0),e([o()],B.prototype,"resultAreaProperties",null),e([o()],B.prototype,"selectedTraces",void 0),e([o()],B.prototype,"selectOnComplete",void 0),e([o()],B.prototype,"showGraphicsOnComplete",void 0),e([o()],B.prototype,"showSelectionAttributes",void 0),e([o({readOnly:!0})],B.prototype,"state",null),e([o()],B.prototype,"traceResults",void 0),e([o()],B.prototype,"utilityNetwork",void 0),e([o({value:null})],B.prototype,"view",null),B=e([n("esri.widgets.UtilityNetworkTrace.UtilityNetworkTraceViewModel")],B);const j=B;export{j as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{id as t}from"../../kernel.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import i from"../../core/Evented.js";import a from"../../core/Logger.js";import{when as l}from"../../core/reactiveUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import c from"../../geometry/Point.js";import{fetchMessageBundle as h}from"../../intl/messages.js";import u from"../../layers/FeatureLayer.js";import p from"../../layers/GraphicsLayer.js";import d from"../../layers/support/CodedValueDomain.js";import{isFeatureLayer as g}from"../../layers/support/layerUtils.js";import m from"../../networks/UtilityNetwork.js";import{getObjectIdsFromElements as y,getFeaturesFromLayers as f}from"../../networks/support/utils.js";import w from"../../portal/Portal.js";import{hasUserTypeExtension as _}from"../../portal/support/utils.js";import{trace as b}from"../../rest/networks/trace.js";import A from"../../rest/networks/support/TraceLocation.js";import v from"../../rest/networks/support/TraceParameters.js";import{GeometryHandler as R}from"./support/GeometryHandler.js";import{GraphicHandler as I}from"./support/GraphicHandler.js";import{ResultAreaHandler as k}from"./support/ResultAreaHandler.js";import{UtilityHelper as F}from"./support/UtilityHelper.js";const S=()=>h("esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace"),T=()=>h("esri/core/t9n/Units"),G=`utility-network-trace-flags-${Date.now()}`,L=`utility-network-trace-results-${Date.now()}`;function H(e){return e instanceof d}function P(e){return"feature"===e.layer.type||"subtype-group"===e.layer.type}function U(e){return"layer"in e}function N(e){return void 0!==e.layerViews}function C(e){return"graphics"===e.type}async function E(e){const t=new u({url:e.networkSystemLayers.dirtyAreasLayerUrl});await t.load();const r=t.version;if(Number(r)<=11.1){const t=new w({url:new URL(e.layerUrl).origin+"/portal"});await t.load();const r=t?.user?.username;return!!r&&_(t,r,"utilityNetwork")}return!0}let B=class extends i.EventedAccessor{constructor(e){super(e),this._activeProgress=!1,this._clickHandler=null,this._flags=[],this._geometryHandler=null,this._highlightHandler=[],this._resultAreaHandler=null,this._utilityHelper=new F,this._traces=[],this._watchHandler=null,this._validUNLayers=[],this._traceTimeout=6e5,this.graphicHandler=null,this.defaultGraphicColor={color:[255,255,0,.6],haloOpacity:.9,fillOpacity:.2,hex:"#FFFF00"},this.enableResultArea=!1,this.flags=[],this.gdbVersion="sde.DEFAULT",this.messages=null,this.messagesUnits=null,this.defaultResultAreaProperties={type:"convexhull",distance:10,unit:"meters",areaUnit:"square-meters",color:{color:[255,165,0,.5],haloOpacity:.9,fillOpacity:.2,hex:"#ffa500"},show:!1},this.selectedTraces=[],this.selectOnComplete=!0,this.showGraphicsOnComplete=!0,this.showSelectionAttributes=!0,this.traceResults=[],this.utilityNetwork=null}initialize(){this._geometryHandler=new R,this.graphicHandler=new I,this._resultAreaHandler=new k;(async()=>{const[e,t]=await Promise.all([S(),T()]);this.set({messages:e,messagesUnits:t})})()}destroy(){this.view=null}get resultAreaProperties(){return this.defaultResultAreaProperties}set resultAreaProperties(e){this._set("resultAreaProperties",{...this.defaultResultAreaProperties,...e}),this.graphicHandler.addCustomColor(this.resultAreaProperties.color),this.traceResults.forEach((t=>{t.resultArea={...this.defaultResultAreaProperties,...e};const r=t.resultArea.show;this.removeResultAreaFromMap(t),r&&this.enableResultArea&&this.addResultAreaToMap(t)}))}get state(){return this.view?.ready?"ready":"loading"}get view(){return this._get("view")}set view(e){e&&"2d"!==e.type&&a.getLogger(this).error(new s("view:invalid-view","SceneView is not supported",{view:e})),this._set("view",e)}addFlagByHit(e,t){const r=e=>{this.view?.popup&&(this.view.popupEnabled=e)};return new Promise(((s,i)=>{r(!1),this._clickHandler?.remove(),this.emit("add-flag",{type:e}),this._clickHandler=this.view?.on("click",(a=>{this.queryFlagByHitTest(a,e,t).then((i=>{r(!0),this._clickHandler?.remove(),this.emit("add-flag-complete",{type:e,symbol:t}),s(i)})).catch((s=>{r(!0),this._clickHandler?.remove(),this.emit("add-flag-error",{type:e,symbol:t}),i(s)}))}))}))}async addFlagsOnLoad(){return new Promise((e=>{const t=[];this._watchHandler=l((()=>null!=this.view&&!this.view.updating),(async()=>{if(this._flags.length>0)e(t);else{const r=this.flags.map((async e=>{if(e.mapPoint){const r=new c({x:e.mapPoint.x,y:e.mapPoint.y,spatialReference:e.mapPoint.spatialReference.wkid}),s={screenPoint:this.view.toScreen(r),mapPoint:r};await this.queryFlagByHitTest(s,e.type)||("barrier"===e.type?t.push("barrier"):t.push("starting-point"))}}));await Promise.all(r),e(t)}}),{initial:!0})}))}addResultAreaToMap(e){if(e.resultArea.show=!0,null!==e.results?.aggregatedGeometry){const t=this._geometryHandler.mergeAggregatedToGeometries(e.results?.aggregatedGeometry);if(t.length>0){const r=Array(t.length).fill(e.resultArea?.distance);this.createResultAreaGeometries(e,t,r)}}else{const t=this._groupResultsByNetworkSource(e.results.elements),r=[];for(const e in t)r.push(this.queryFeaturesById(t[e]));Promise.all(r).then((t=>{const r=[];for(const e of t)for(const t of e)for(const e of t.featureSet.features)r.push(e.geometry);const s=Array(r.length).fill(e.resultArea?.distance);this.createResultAreaGeometries(e,r,s)})).catch((e=>{console.log(e)}))}}async addResultGraphicToView(e,t){const{view:r}=this,{results:s}=e;if(r&&s)for(const i in s.aggregatedGeometry)if("line,multipoint,polygon".includes(i)){const a=i,l=s.aggregatedGeometry[a];if(null!=l){l.spatialReference=this.utilityNetwork.spatialReference,e.graphicEnabled=!0;const s=await this._geometryHandler.projectGeometry(l,r.spatialReference),i={globalid:e.trace.globalId};if(null!==s){const e=this.graphicHandler.makeGraphic(s,t.color,i,r.spatialReference);this._getGraphicLayer(L)?.add(e)}}}}addTerminal(e,t){const r=[...this._flags];r.forEach((r=>{r.globalId===t.globalId&&(t.selectedTerminals?.includes(parseInt(e,10))||r.selectedTerminals?.push(parseInt(e,10)))})),this._flags=r}async callTrace(){const e=this._traces.filter((e=>e.selected));return e.length>0&&(this.traceResults.length>0&&this.traceResults.forEach((e=>{this.removeResultGraphicFromView(e)})),this.traceResults=[],this.removeSelection(),await Promise.all(e.map((async(e,t)=>{const r=e,s=new v({gdbVersion:this.gdbVersion,moment:null,traceType:r.traceType,traceLocations:this._flags,namedTraceConfigurationGlobalId:r.globalId,traceConfiguration:null,outSpatialReference:null,resultTypes:null});await this.executeTrace(r,this.utilityNetwork.networkServiceUrl,s).then((e=>{if(e.hasOwnProperty("results")){const r={...e};if(null!==r.results){r.resultArea={...this.resultAreaProperties};const e=[...r.results.elements];r.results.elements.length=0;const s=new Map;for(const t of e)s.has(t.globalId)||(s.set(t.globalId,!0),r.results.elements.push(t));const i=[...this.traceResults];i.splice(t,0,r),this.traceResults=i,null!==r.results&&(this.selectOnComplete&&this.mergeSelection(!0,r.trace),this.showGraphicsOnComplete&&this.addResultGraphicToView(r,r.graphicColor),this.enableResultArea&&r.resultArea.show&&this.addResultAreaToMap(r))}else{const r=[...this.traceResults];r.splice(t,0,e),this.traceResults=r}this._activeProgress=!1}else{this._activeProgress=!1;const r=[...this.traceResults];r.splice(t,0,e),this.traceResults=r}})).catch((e=>{throw this._activeProgress=!1,e}))}))),!0)}changeResultAreaColor(e,t){e.resultArea&&(e.resultArea.color=t,this._resultAreaHandler?.changeResultAreaColor(e.trace.globalId,t,this.view.map))}changeResultGraphicColor(e,t){const r=[...this.traceResults];r.length>0&&r.forEach((r=>{r.trace.globalId===t.trace.globalId&&(r.graphicColor=e,r.graphicEnabled=!0)})),this.traceResults=r,this.removeResultGraphicFromView(t),this.addResultGraphicToView(t,e)}changeFlagSymbol(e,t){this._flags.length>0&&this._flags.forEach((r=>{r.type===e&&t&&r.mapGraphic&&(r.mapGraphic.symbol=t)}))}checkCanTrace(){const e={status:!0,issues:[]};let t=!1;const r=this._flags.some((e=>"starting-point"===e.type)),s=this._flags.filter((e=>null!==e.allTerminals));s.length>0&&(t=s.some((e=>e.selectedTerminals.length<=0)));let i=[];return r?(i=this._traces.filter((e=>e.selected)),i.length<=0?(e.status=!1,e.issues=["noTrace"],t&&(e.status=!1,e.issues=["noTrace","noTerminalSelected"])):t&&(e.status=!1,e.issues=["noTerminalSelected"])):(i=this._traces.filter((e=>!0===e.selected)),i.length>0?(e.status=!1,e.issues=["noStart"],t&&(e.status=!1,e.issues=["noStart","noTerminalSelected"])):(e.status=!1,e.issues=["noStart","noTrace"],t&&(e.status=!1,e.issues=["noStart","noTrace","noTerminalSelected"]))),e}checkSelectionExist(){let e=!1;return this._highlightHandler.some((t=>{t&&(e=!0)})),e}clearResult(e){if(!this.view)return;let t=this.traceResults;if(t.length>0){const r=t.filter((t=>t.trace.globalId===e.globalId));r.length>0&&(this.removeResultGraphicFromView(r[0]),this.removeResultAreaFromMap(r[0])),t=t.filter((t=>t.trace.globalId!==e.globalId))}this.traceResults=t,0===t.length?(this.removeAllResultAreaGraphics(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]})):this.mergeSelection(!1,e)}createResultAreaGeometries(e,t,r){if(!this.view||!this.resultAreaProperties)return;let s;if("convexhull"===this.resultAreaProperties?.type?s=this._resultAreaHandler?.createConvexHull(t,e.resultArea?.distance,e.resultArea?.unit):t&&(s=this._resultAreaHandler?.createBuffer(t,r,e.resultArea?.unit,!0)),s&&Array.isArray(s)){if(s.length>0)for(const i of s){const t=this.getResultAreaAttributes(e,i),r=this._resultAreaHandler?.createResultAreaGraphic(i,t,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color);r&&(this._resultAreaHandler?.addResultAreaToMap(r,this.view.map),this.emit("add-result-area",{graphic:r}))}}else{const t=this.getResultAreaAttributes(e,s),r=this._resultAreaHandler?.createResultAreaGraphic(s,t,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color);r&&(this._resultAreaHandler?.addResultAreaToMap(r,this.view.map),this.emit("add-result-area",{graphic:r}))}}executeTrace(e,t,r){const s=this._processFlags(r.traceLocations);return r.traceLocations=s,b(t,r,{timeout:this._traceTimeout}).then((t=>({trace:e,results:t,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:"success",date:new Date}))).catch((t=>({trace:e,results:null,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:t.message,date:new Date})))}getResultAreaAttributes(e,r){const{messages:s}=this,i=[],a=[];this._flags.forEach((e=>{const t=e.displayValue?.field+":"+e.displayValue?.value+";"+s.attributeStrings.globalid+":"+e.globalId+";"+s.attributeStrings.terminalid+":"+e.terminalId+";"+s.attributeStrings.x+":"+e.mapPoint?.x+";"+s.attributeStrings.y+":"+e.mapPoint?.y;"starting-point"===e.type?i.push(t):a.push(t)}));return{traceId:e.trace.globalId,traceName:e.trace.title,traceDescription:e.trace.description??"",startingPoints:i.toString(),barriers:a.toString(),version:this.gdbVersion,username:t.credentials[0].userId,date:e.date,elementCount:e.results?.elements.length,functionResult:JSON.stringify(e.results?.globalFunctionResults),areaStatistic:r?this._geometryHandler.calculateArea(r,e.resultArea?.areaUnit):0}}getValidSources(){let e=[];const t=this.utilityNetwork.dataElement?.domainNetworks??[];for(const r of t)e=e.concat(r.junctionSources),e=e.concat(r.edgeSources);return e}async loadUtilityNetwork(){const{view:e}=this;if(!e)return null;if(await e.when(),this.utilityNetwork){if(this.utilityNetwork.loaded||await this.utilityNetwork.load(),this.utilityNetwork instanceof m){try{const t=e.map;await t.loadAll(),this._loadUNSupportItems()}catch(i){this._loadUNSupportItems()}return this.utilityNetwork}return null}const t=e.map,r=t.utilityNetworks?.at(0);if(r){if(await r.load(),this.utilityNetwork=r,!await E(r))throw new s("utility-network:no-user-type-extension","User type extension not found");try{await t.loadAll(),this._loadUNSupportItems()}catch(i){}finally{this._loadUNSupportItems()}return r}return null}manageFilterBarrier(e,t){const r=[...this._flags];r.forEach((r=>{r.globalId===t.globalId&&"barrier"===t.type&&r.id===t.id&&(r.isFilterBarrier=e)})),this._flags=r}mergeSelection(e,t){let r=[];const s=[...this.traceResults],i=t.globalId;s.forEach((t=>{i===t.trace.globalId&&(t.selectionEnabled=e),t.selectionEnabled&&null!==t.results?.elements&&(r=[...r,...t.results?.elements??[]])})),this.selectResults([...new Set(r)])}async queryFeaturesById(e){const{view:t}=this;if(!t)return null;const s=y(this.utilityNetwork,e),i={layerUrl:s[0].layerUrl,objectIds:s[0].objectIds,outFields:["*"]},a=t.map?.allTables.toArray().filter((e=>e?.parsedUrl?.path===s[0].layerUrl)).filter(g)??[];this._getUniqueMapLayerViews(t).filter((({layer:e})=>e?.parsedUrl?.path===s[0].layerUrl)).forEach((({layer:e})=>{"feature"!==e.type&&"subtype-group"!==e.type||a.push(e)}));const l=(await Promise.all(a.map((async e=>{const s={layers:new r([e]),layerInfos:[i],returnGeometry:!0,outSpatialReference:t.spatialReference},[a]=await f(s,!1);return a})))).filter((({featureSet:e})=>e.features.length>0));return l.length>0?l:null}queryFlagByHitTest(e,t,r){return this._lookupFlagByHit(e).then((e=>{const{view:s}=this;if(!s)return!1;if(e.length>0){const s=[...this._flags],i=r;return e.forEach((e=>{const r=e.graphic,a=r.attributes.hasOwnProperty("GLOBALID")?r.attributes.GLOBALID:r.attributes.globalid;if(s.filter((e=>e.globalId===a)).length<=0){const e=this.graphicHandler.getFlagGraphic(r.mapPoint,t,r,i);this._getGraphicLayer(G)?.add(e),s.push({...r,type:t,globalId:r.attributes.globalid||r.attributes.GLOBALID,details:r,mapGraphic:e,id:s.length+1})}else if(null!==r.percentAlong){const e=this.graphicHandler.getFlagGraphic(r.mapPoint,t,r,i);this._getGraphicLayer(G)?.add(e),s.push({...r,type:t,globalId:r.attributes.globalid||r.attributes.GLOBALID,details:r,mapGraphic:e,id:s.length+1})}})),this._flags=s,!0}return!1}))}removeResultGraphicFromView(e){const{view:t}=this;if(!t)return;const r=this._getGraphicLayer(L)?.graphics;e.graphicEnabled=!1;const s=r?.filter((t=>t.attributes[t.attributes.hasOwnProperty("GLOBALID")?"GLOBALID":"globalid"]===e.trace.globalId));s?.forEach((e=>{this._getGraphicLayer(L)?.remove(e)}))}removeFlag(e){const t=this._flags.filter((t=>{if(t.id!==e.id)return t}));this._removeGraphic(e),this._flags=t}removeAllResultAreaGraphics(){this._resultAreaHandler?.removeAllResultAreaGraphics(this.view.map)}removeResultAreaFromMap(e){e.resultArea.show=!1;const t=this._resultAreaHandler?.removeResultArea(e.trace.globalId,this.view?.map);t&&this.emit("remove-result-area",{graphic:t})}removeSelection(){this._highlightHandler.forEach((e=>{e&&e.remove()})),this._highlightHandler=[]}removeTerminal(e,t){const r=[...this._flags];r.forEach((r=>{if(r.globalId===t.globalId&&t.selectedTerminals?.includes(parseInt(e,10))){const s=t.selectedTerminals.indexOf(parseInt(e,10));r.selectedTerminals?.splice(s,1)}})),this._flags=r}removeFlagsOnLoadWatcher(){this._watchHandler&&null!==this._watchHandler&&this._watchHandler.remove()}reset(){this._flags=[],this.traceResults=[];const e=[...this._traces];e.forEach((e=>{e.selected=!1})),this._traces=e,this.view&&(this._getGraphicLayer(L)?.removeAll(),this._getGraphicLayer(G)?.removeAll(),this.removeAllResultAreaGraphics(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]}))}selectFeaturesById(e){const{view:t}=this;if(!t)return;const r=y(this.utilityNetwork,e);this._getUniqueMapLayerViews(t).forEach((e=>{U(e)&&e.layer?.parsedUrl?.path===r[0].layerUrl&&P(e)&&this._highlightHandler.push(e.highlight(r[0].objectIds))}))}selectResults(e){if(e.length>0){this.removeSelection();const t=this._groupResultsByNetworkSource(e),r=[];for(const e in t)this.selectFeaturesById(t[e]),r.push(this.queryFeaturesById(t[e]));Promise.all(r).then((e=>{this.emit("select-features",{resultSet:e})}))}else this.removeSelection(),this.emit("clear-selection",{resultSet:[]})}selectTraces(e,t){const r=[...this._traces];r.forEach((r=>{t===r.globalId&&(r.selected=e)})),this._traces=r}selectTracesOnLoad(){this.utilityNetwork.hasOwnProperty("sharedNamedTraceConfigurations")&&(this._traces=[...this.utilityNetwork.sharedNamedTraceConfigurations],this._traces.forEach((e=>{e.selected=!1,this.selectedTraces.includes(e.globalId)&&(e.selected=!0)})))}zoomToAsset(e){this.view?.goTo(e).catch((e=>console.error(e)))}_loadUNSupportItems(){const{map:e}=this.view,{messages:t}=this;this._populateOutfields(),this._createGraphicLayer(G),this._createGraphicLayer(L),this._resultAreaHandler?.createGraphicLayer(e,t?.alertsStrings.genericResultHeader),this._validUNLayers=this._utilityHelper.getValidUtilityNetworkLayers(e,this.utilityNetwork)}_getUniqueMapLayerViews(e){const t=[];return e.layerViews.filter((({layer:{type:e}})=>"feature"===e||"group"===e||"subtype-group"===e)).toArray().forEach((e=>{switch(e.layer.type){case"group":if(N(e))for(const r of e.layerViews)t.push(r);break;case"subtype-group":t.push(e);break;default:t.some((t=>t.layer.id===e.layer.id))||t.push(e)}})),t}_processFlags(e){const t=[];return e.forEach((e=>{if(null!==e.selectedTerminals&&e.selectedTerminals.length>0)e.selectedTerminals.forEach((r=>{const s=new A({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:r,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(s)}));else{const r=new A({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:null,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(r)}})),t}_getDisplayField(e){return"subtype-sublayer"===e?.layer?.type?this._getDisplayFieldBySublayer(e):this._getDisplayFieldByFeatureLayer(e)}_getDisplayFieldBySublayer(e){let t="",r="";const s=e.layer;t=this._checkParentForData(s,"displayField");for(const i in e.attributes){const a=i.toLowerCase();a===t?.toLowerCase()?(r=e.attributes[i],"assetgroup"===a||"assettype"===a?r=this._checkSubtype(s,s.subtypeCode):(r=this._checkDomain(s.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,s)))):(r=this._checkDomain(s.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,s)))}return{field:t,value:r.toString()}}_getDisplayFieldByFeatureLayer(e){const t=e.layer;let r=t.displayField,s="";for(const i in e.attributes){const a=i.toLowerCase();if(a===r?.toLowerCase())if(s=e.attributes[i],"assetgroup"===a||"assettype"===a){let a=e.attributes[t.typeIdField.toUpperCase()];a||(a=e.attributes[t.typeIdField.toLowerCase()]),r=t.typeIdField,s=this._checkSubtype(t,a),""===r&&(t.templates&&t.templates.length>0?(r=t.templates[0]?.name,s=t.templates[0]?.name):(r=t.displayField,s=e.attributes[i]))}else s=this._checkDomain(t.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,t));else s=this._checkDomain(t.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,t))}return{field:r,value:s?s.toString():""}}_checkSubtype(e,t){let r=t;if("subtype-sublayer"===e.type){const s=this._checkParentForData(e,"subtypes");s?.length>0&&s.forEach((e=>{e.code===t&&(r=e.name)}))}else if(null!=e.types&&e.types.length>0){const s=e.types.filter((e=>e.id===t));s.length>0&&(r=s[0].name)}return r}_checkDomain(e,t,r){let s=r;const i=e.filter((e=>e.name.toLowerCase()===t.toLowerCase()));if(i.length>0&&H(i[0].domain)&&i[0].domain?.codedValues){const e=i[0].domain.codedValues.filter((({code:e})=>e===r));e.length>0&&(s=e[0].name)}return s}_checkParentForData(e,t){return e.parent?.[t]??null}_defaultDisplayField(e,t){return e.trim()?e:t.templates&&t.templates?.length>0?t.templates[0].name:t.title}_groupBy(e,t){return e.reduce(((e,r)=>((e[r[t]]=e[r[t]]||[]).push(r),e)),{})}_groupResultsByNetworkSource(e){if(e.length>0){return this._groupBy(e,"networkSourceId")}return[]}_lookupFlagByHit(e){return this.view.hitTest(e.screenPoint,{include:this._validUNLayers}).then((t=>{const r=[];if(t.results.length>0){const s=t.results.find((e=>null!==e.layer));if(null!=s.graphic?.geometry)if("polyline"===s.graphic.geometry.type){const t=this._geometryHandler.getPercentageAlong(s.graphic.geometry,e.mapPoint,s.graphic.geometry.spatialReference),i=this._getDisplayField(s.graphic);s.graphic.terminalId=null,s.graphic.isFilterBarrier=!1,s.graphic.allTerminals=null,s.graphic.selectedTerminals=null,s.graphic.percentAlong=t,s.graphic.displayValue=i,s.graphic.mapPoint=s.mapPoint,r.push(s)}else if(("point"===s.graphic.geometry.type||"polygon"===s.graphic.geometry.type)&&null!==this.utilityNetwork){const e=this.utilityNetwork.getTerminalConfiguration(s.graphic),t=this._getDisplayField(s.graphic);s.graphic.terminalId=e?e.terminals[0].id||null:1,s.graphic.isFilterBarrier=!1,s.graphic.allTerminals=e??null,s.graphic.selectedTerminals=[e?e.terminals[0].id||null:1],s.graphic.percentAlong=null,s.graphic.displayValue=t,s.graphic.mapPoint=s.mapPoint,r.push(s)}}return r}))}async _populateOutfields(){const e=this.view?.map,t=this.getValidSources();e?.layers.forEach((e=>{"group"===e.type?e.layers.forEach((e=>{t.some((t=>t.layerId===e.layerId))&&e.fields.some((e=>"assetgroup"===e.name.toLowerCase()))&&(e.outFields=["assetgroup","assettype","globalid","objectid"])})):t.some((t=>t.layerId===e.layerId))&&e.fields.some((e=>"assetgroup"===e.name.toLowerCase()))&&(e.outFields=["assetgroup","assettype","globalid","objectid"])}))}_removeGraphic(e){this._getGraphicLayer(G)?.remove(e.mapGraphic)}_createGraphicLayer(e){const{map:t}=this.view;if(!t.findLayerById(e)){const r=new p({title:e,listMode:"hide",id:e});t.add(r)}}_getGraphicLayer(e){const{map:t}=this.view;if(t){const r=t.findLayerById(e);if(r&&C(r))return r}return null}};e([o()],B.prototype,"_activeProgress",void 0),e([o()],B.prototype,"_flags",void 0),e([o()],B.prototype,"_traces",void 0),e([o()],B.prototype,"defaultGraphicColor",void 0),e([o()],B.prototype,"enableResultArea",void 0),e([o()],B.prototype,"flags",void 0),e([o()],B.prototype,"gdbVersion",void 0),e([o()],B.prototype,"messages",void 0),e([o()],B.prototype,"messagesUnits",void 0),e([o()],B.prototype,"resultAreaProperties",null),e([o()],B.prototype,"selectedTraces",void 0),e([o()],B.prototype,"selectOnComplete",void 0),e([o()],B.prototype,"showGraphicsOnComplete",void 0),e([o()],B.prototype,"showSelectionAttributes",void 0),e([o({readOnly:!0})],B.prototype,"state",null),e([o()],B.prototype,"traceResults",void 0),e([o()],B.prototype,"utilityNetwork",void 0),e([o({value:null})],B.prototype,"view",null),B=e([n("esri.widgets.UtilityNetworkTrace.UtilityNetworkTraceViewModel")],B);const j=B;export{j as default};
|