@arcgis/core 4.31.0-next.20240821 → 4.31.0-next.20240822
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/{9443b9ec03f25c723c2c.js → 06d328c8aad32c52de97.js} +1 -1
- package/assets/esri/core/workers/chunks/203afe6dd0461d4bd774.js +278 -0
- package/assets/esri/core/workers/chunks/{cd9f48dcee2a1fc261ed.js → c5214a47690c594903d1.js} +25 -25
- package/assets/esri/themes/base/widgets/_Grid.scss +0 -8
- package/assets/esri/themes/base/widgets/_Print.scss +13 -15
- 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/assets/esri/widgets/Print/t9n/Print.json +1 -1
- package/assets/esri/widgets/Print/t9n/Print_en.json +1 -1
- package/chunks/ComponentShader.glsl.js +29 -29
- package/chunks/DefaultMaterial.glsl.js +1 -1
- package/chunks/Path.glsl.js +22 -17
- package/exports/csv.js +1 -1
- package/interfaces.d.ts +37 -9
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/support/highlightGroupUtils.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js +3 -3
- package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/OutputColorHighlightOID.glsl.js +8 -8
- package/views/3d/webgl-engine/shaders/Path.glsl.js +1 -1
- package/widgets/Feature/FeatureMedia.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/Grid/Column.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/Print/CustomTemplate.js +1 -1
- package/widgets/Print/PrintViewModel.js +1 -1
- package/widgets/Print/TemplateOptions.js +1 -1
- package/widgets/Print/utils.js +5 -0
- package/widgets/Print.js +1 -1
- package/widgets/support/exportUtils.js +1 -1
- package/assets/esri/core/workers/chunks/e5474bcde5b8fa037b56.js +0 -278
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/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 i,equals as r}from"../../core/arrayUtils.js";import{createTask as o}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as a}from"../../core/deprecate.js";import n from"../../core/Error.js";import l from"../../core/Evented.js";import{isSerializable as h}from"../../core/JSONSupport.js";import{equalsShallow as c}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as p}from"../../core/mathUtils.js";import{abortMaybe as d,destroyMaybe as m}from"../../core/maybe.js";import{isAbortError as g,throwIfAborted as y,waitTick as f}from"../../core/promiseUtils.js";import{watch as F,syncAndInitial as v,initial as w}from"../../core/reactiveUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as b}from"../../core/accessorSupport/decorators/subclass.js";import{isPolygon as P}from"../../geometry/support/jsonUtils.js";import{geographicToWebMercator as I}from"../../geometry/support/webMercatorUtils.js";import C from"../../layers/GraphicsLayer.js";import{searchImages as V}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as S}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as O,computePolygonForInspection as j,resizePolygon as A,checkIfPolygonContainsSelectedPoint as B}from"../../layers/orientedImagery/core/coverageUtils.js";import{updateElevation as k,transformPoints as L}from"../../layers/orientedImagery/transformations/groundToImageUtils.js";import{transformPoints as G}from"../../layers/orientedImagery/transformations/imageToGroundUtils.js";import{getInitialAngle as M,convertPixelToHeadingPitch as E,convertHeadingPitchToSphereVertex as R}from"../../layers/orientedImagery/transformations/utils.js";import x from"../../rest/support/AttachmentQuery.js";import{ViewEventPriorities as T}from"../../views/input/InputManager.js";import H from"../PanoramicViewer.js";import{sectorsInOrder as D,sectorsRadii as U}from"./constants.js";import{crossSymbol as N,crossSymbol3D as z,diamondSymbol as W,diamondSymbol3D as $,activeSourcePointSymbol as q,sourcePointSymbol as J}from"./symbols.js";import{getContentType as K,isNoAttachmentError as Q,isTifOrMrf as X,scaleExtent as Y,isSceneView as Z,isGraphic as ee,calculateSegment as te,calculateDirection as ie}from"./utils.js";import re from"./components/ImageViewer.js";import oe from"../../geometry/Point.js";import se from"../../geometry/SpatialReference.js";import ae from"../../geometry/Polygon.js";const ne={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles"},le=new Set(["JPG","JPEG"]),he=/\.(\w+)$/,ce=e=>"FA"===e;let ue=class extends l.EventedAccessor{constructor(e){super(e),this.additionalFeatures=new s,this.bestFeatureAngle=0,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentCoverageVisible=!0,this.determineWorkflowForFeature=()=>{d(this._featureChangedTask),this._featureChangedTask=o((async e=>{const{currentBestFeature:t,selectedPoint:i,view:r}=this;if(r?.closePopup(),t&&i){this._initialCurrentCoverageUpdate=!0;try{await this._updatePointsAndPolygons({signal:e}),await this._loadImage({signal:e})}catch(o){g(o)||(this.loadImageError(o),u.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}}))},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.drawFootprint=()=>{this.bestFeatureFootprint&&this.updateCurrentCoveragePolygon(this.bestFeatureFootprint)},this.features=new s,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.navigatorCurrentBestFeature=null,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.updateFootprint=async(e,t)=>{"image-loaded"===this.state&&await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this._adapter=null,this.additionalFootprints=new s,this.additionalCameraLocations=new s,this.bestFeatureCurrentFootprint=null,this._fetchFeaturesController=null,this._highlightedFeatureHandle=null,this._imageViewer=new re,this.bestFeatureFootprint=null,this._initialCurrentCoverageUpdate=!0,this._loading=!1,this._overlays=new C({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new H,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadImageFromSource=async(e,t)=>{const{mode:i,imageRotation:r,options:o}=t,s="string"==typeof e,a=s?e:e.url,{origin:n,pathname:l,searchParams:h}=new URL(a);let c=s?l.match(he)?.[1]??"":e.datasetFormat;if(!c){const e=await K(a,{...t.options});e&&(c=e.split("/")[1]),c??="UNKNOWN FORMAT"}switch(i){case"default":this._imageViewer.imageSource={datasetFormat:c.toUpperCase(),url:`${n}${l}`},this._imageViewer.customParameters=Object.fromEntries(h),this._imageViewer.imageRotation=r??0,await this._imageViewer.loadImage(o);break;case"panoramic":this._loading=!0;if(le.has(c.toUpperCase())){const{selectedPoint:e}=this,{pitch:i,yaw:r,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=a;let l=r??0;"number"==typeof n?l=n-l:s&&e&&(l=await M(s,e)-l),this._panoramicViewer.pitch=i??0,this._panoramicViewer.yaw=l,this._loading=!1,await this._panoramicViewer.loadImage(o)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:c});break}},this.loadImageViewer=e=>{this._imageViewer.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.toggleImageAttributes=()=>{d(this._openPopupTask),this._openPopupTask=o((async e=>{const{currentBestFeature:i,popupEnabled:r,layer:o,view:s}=this;if(s?.closePopup(),!(s&&i&&r&&o))return;const{attributes:a,geometry:n}=i,l=new t({geometry:n,attributes:a.toJSON(),popupTemplate:o.popupTemplate});y(e),await s.openPopup({features:[l],location:a.location.clone()})}))},this._getImageSourceFromAttachment=async(e,t,i)=>{const r=new x({objectIds:[t]}),o=await e.queryAttachments(r,i),s=o[`${t}`]?.[0],a=s?.url;if(!a)throw new n("NoAttachmentError","no attachments found",{[e.objectIdField]:t,layer:e});return{datasetFormat:s.contentType.split("/")[1].toUpperCase(),url:a}},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:r}=this;if(this.clearGraphics(),!i||!t||"none"===r)return;const{attributes:o}=t,{imagePath:s,imageRotation:a,cameraHeading:n,cameraRoll:l,cameraPitch:h,objectId:c,cameraOrientation:p,location:d}=o,m=(l??0)+(a??0),f=d.spatialReference.isWGS84&&4!==p?.type?I(d):new oe(d);let F=s;if(ce(s))try{F=await this._getImageSourceFromAttachment(i,c,e)}catch(v){if(g(v))return;return Q(v)?(u.getLogger(this).error(v),void this.setMessage("noAttachment","error",`${i.objectIdField}: ${c}`)):(u.getLogger(this).error(v,{[i.objectIdField]:c,layer:i}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${i.objectIdField} ${c}`))}try{await this.loadImageFromSource(F,{imageRotation:m,options:e,pitch:h,yaw:n,mode:r,cameraLocation:f}),y(e),await this.transformAndPlotSelectedLocation(e)}catch(v){g(v)||this.loadImageError(v)}},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._viewClickHandler=e=>{"mouse"===e.pointerType&&0!==e.button||(e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.loadBestImage(e.mapPoint))},this.plotSelectedPointOnImage=async(e,i)=>{if(await f(i),!e)return;const r=new oe({...h(e)?e.toJSON():e,spatialReference:se.WebMercator});if("default"===this.mode)r.x-=.5,r.y=.5-r.y,this._crossSymbol=new t({geometry:r,symbol:N}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:i}=this._panoramicViewer;if(!i)return;const[r,o]=i,{heading:s,pitch:a}=E(e,r,o),n=R(s,a);this._crossSymbol=new t({geometry:new oe(n,se.WebMercator),symbol:z}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this.determineWorkflowForFeature=this.determineWorkflowForFeature.bind(this),this.selectBestFeature=this.selectBestFeature.bind(this),this.drawFootprint=this.drawFootprint.bind(this)}initialize(){this.addHandles([F((()=>this.view),(async e=>{if(e){switch(this._loading=!0,e.type){case"2d":{const{default:e}=await import("./adapters/OrientedImageryViewerViewModelAdapter2D.js");this._adapter=new e(this);break}case"3d":{const{default:e}=await import("./adapters/OrientedImageryViewerViewModelAdapter3D.js");this._adapter=new e(this);break}}this._loading=!1}else this._adapter=null}),v),F((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),w),F((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),w),F((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{if(this.removeHandles(ne.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,T.WIDGET),ne.click),this.removeHandles(ne.imageClick);const{mapImageConversionToolState:t,mode:i}=this;if(t&&"none"!==i)switch(i){case"default":this._imageViewer.clickAction="pixel-location",this.addHandles(this._imageViewer.on("pixel-location",(async e=>{this.plotReferencePointOnImage(e);const t=this.currentBestFeature;if(t){const i=(await G([e.toJSON()],{feature:t,imageProperties:{width:this._imageViewer.imageSize[0],height:this._imageViewer.imageSize[1]},options:{signal:this._transformController?.signal},footprintExtent:this.footprintExtent}))[0];i&&this.plotReferencePointOnGround(i)}})),ne.imageClick);break;case"panoramic":this._panoramicViewer.clickAction="pixel-location",this.addHandles(this._panoramicViewer.on("pixel-location",(async e=>{this.plotReferencePointOnImage(e);const t=this.currentBestFeature,{imageSize:i}=this._panoramicViewer;if(t&&e&&i){const r=(await G([e],{feature:t,imageProperties:{width:i[0],height:i[1]},options:{signal:this._transformController?.signal},footprintExtent:this.footprintExtent}))[0];r&&this.plotReferencePointOnGround(r)}})),ne.imageClick)}}),v),F((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),v),F((()=>this.currentBestFeature),((e,t)=>{this.determineWorkflowForFeature(e,t)}),{sync:!0}),F((()=>this.mode),(e=>{switch(this.removeHandles(ne.interactionHandles),e){case"default":this.addHandles(F((()=>this._imageViewer.imagePointsInView),(e=>{e&&(d(this._updateFootprintTask),this._updateFootprintTask=o((async t=>{await this.updateFootprint(e,{signal:t})})))}),{...v,equals:(e,t)=>r(e,t,c)}),ne.interactionHandles);break;case"panoramic":this.addHandles(F((()=>{const{currentBestFeature:e}=this,{imageSize:t,vfov:i,hfov:r,pitch:o,yaw:s}=this._panoramicViewer;return e&&t?[i,r,s,o]:null}),(e=>{if(!e||"image-loading"===this.state)return;const[t,i,r,s]=e;d(this._updateFootprintTask),this._updateFootprintTask=o((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:r,pitch:s},{signal:e})}))}),{...v,equals:(e,t)=>r(e,t,c)}),ne.interactionHandles)}}),v),F((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:i,mode:r,sharpness:o}=this;"default"===r&&(e.brightness=t,e.contrast=i,e.sharpness=o)}),v)])}destroy(){this._updateFootprintTask=d(this._updateFootprintTask),this._cancelFetchingFeatures(),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=m(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._crossSymbol=m(this._crossSymbol),this._referencePointOnGround=m(this._referencePointOnGround),this._referencePointOnImage=m(this._referencePointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy()}get activeLayer(){return a(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){a(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:i}=this;switch(i){case"default":return e;case"panoramic":return t;default:return null}}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",e>10?10:e<-10?-10:e)}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",p(e,-10,10))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){return X(this.currentBestFeature?.attributes.imagePath.trim())}get imageLoaded(){return a(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:i}=e;return 360===t||i?"panoramic":"default"}get popupEnabled(){return null!==this.layer&&this.layer.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?D.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",p(e,0,1))}get state(){const{mode:e,disabled:t}=this;if(t)return"disabled";if(this._loading)return"image-loading";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:i,imageRotation:r}})=>{const o=e.trim();return X(o)?{url:o,objectId:t,rotation:(i??0)+(r??0)}:null})).filter(i)):null}set view(e){this._set("view",e)}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}filterByFootprints(e,t){const i=[],r=[],o=[];return e.forEach((e=>{const{layer:{coveragePercent:s},attributes:a}=e;let n;const{polygon:l,frustum:h}=O(a);if(n=l.clone(),a.isInspection&&(n=j(a)),s&&(n=A(n,s)),B(n,t)){o.push(e);const{cameraHeading:t,geometry:s,objectId:n,cameraHeight:c}=a,u=s.clone();u.z=c,u.imageID=n,this.pointSources.push(u),-999!==t&&(i.push(l),h&&r.push(h))}})),{features:o,polygons:i,frustums:r}}getCurrentCoveragePolygon(){return this.bestFeatureCurrentFootprint}getCurrentBestFeaturePolygon(){return this.bestFeatureFootprint}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[D[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:i}=e;if(isNaN(i))return;const r=this._sectorData?.[t];r?.length&&this._updateCurrentBestFeature(r.at(i))}async loadBestImage(e){this._loading=!0,this.view?.closePopup(),this.displayMessage=null,this.selectedPoint=e.spatialReference.isGeographic?I(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),await this._fetchFeaturesWithController(e)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new oe({...e.toJSON()}),symbol:W}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage.destroy()),this.mode){case"default":{const i=h(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,this._referencePointOnImage=new t({geometry:new oe({spatialReference:this._imageViewer.imageRenderer.spatialReference,...i}),symbol:W}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:i}=this._panoramicViewer;if(!i)return;const[r,o]=i,{heading:s,pitch:a}=E(e,r,o),n=R(s,a);this._referencePointOnImage=new t({geometry:new oe(n,se.WebMercator),symbol:$}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._cancelFetchingFeatures()}async searchBestImage(e,t){try{const i=await V(e,t);i&&await this._processFeatureResponse(i,e.point,{signal:t?.signal})}catch(i){g(i)||(this.setMessage("imageLoadError","error",i.message),u.getLogger(this).error("error occurred while finding best image",i))}}selectBestFeature(e){this.currentBestFeature=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:i}=e,r=this.bestFeatureFootprint?.geometry,o=P(r)&&r.contains(t),s="mesh"===r?.type&&r?.extent.contains(t);if(!o&&!s)return;const a=await this.transformPoint(t,i);return a?(this.plotReferencePointOnImage(a),{x:a.x,y:a.y}):void 0}updateSuitabilities(e){this._suitabilities=e.sort(((e,t)=>e.suitability-t.suitability));const t=this._suitabilities.map((e=>e.feature));this._updateFeatures(t),this._groupFeaturesBySectors(),this._initialCurrentCoverageUpdate=!0}_cancelFetchingFeatures(e){const t=this._fetchFeaturesController;t&&t.abort(e),this._fetchFeaturesController=null}async _fetchFeatures(e,t){if(!this.view)return;const i=this.layer;if(i){const r={include:i},o=this.view.toScreen(e);if(!o)return;const s=await this.view.hitTest(o,r);this._processHitTestResults(i,s,t)}}async _fetchFeaturesWithController(e){this._cancelFetchingFeatures();const t=new AbortController,{signal:i}=t;this._fetchFeaturesController=t;try{await this._fetchFeatures(e,{signal:i}).finally((()=>{this._fetchFeaturesController=null}))}catch(r){this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",r)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:i,features:r}=this;if(!(e&&t&&i&&r))return void(this._sectorData=null);this._sectorData={};for(const l of D)this._sectorData[l]=new s;const o=e.map(((e,t)=>({...e,featureIndex:t})));o.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const a=o.map((({distance:e})=>e)),n=Math.max(...a);o.forEach((e=>{const{distance:t,angle:i,featureIndex:o}=e,s=t/n*U[2],a=te(t,n),l=ie(i);if(!this._sectorData)return;const h=U[3]+s*Math.sin(i*Math.PI/180),c=U[3]+s*Math.cos(i*Math.PI/180);let u;const p=r.at(o),d=p===this.currentBestFeature,m=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(d&&m)u=-90;else{const e=h-U[3],t=c-U[3],i=t/Math.sqrt(e**2+t**2);let r=180*Math.acos(i)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(r*=-1),u=r}const g=""===a?l:`${a}_${l}`;d&&(u===this.bestFeatureAngle?this.previousFeatureAngle=u:this.bestFeatureAngle=u,this.navigatorCurrentBestFeature=m?null:{x:h,y:c,direction:l});const y=this._sectorData[g];y.add({angle:i,featureIndex:o,x:h,y:c,objectID:p.attributes.objectId,sector:g,featureIndexInSector:y.length})}))}async _processFeatureResponse(e,t,i){const{features:r}=e;if(!r?.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll();const{features:o,polygons:s,frustums:a}=this.filterByFootprints(r,t);if(!o.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(a);const n=new ae({spatialReference:s[0].spatialReference});for(const{rings:u}of s)n.addRing(u[0]);const l=[];for(const{geometry:u}of o)n.contains(u)||l.push(u);n.addRing(l);const h=n.extent;let c;if(Y(h,2),this.footprintExtent=h,this.view?.supportsGround)try{c=await this.view.map.ground.createElevationSampler(h,i)}catch(d){g(d)||u.getLogger(this).error(d)}if(o[0].elevationSample=c,(c||o[0].attributes.elevationSource)&&h){const e=await k([t],{feature:o[0],footprintExtent:h,options:i});if(e[0]){const i=e[0];t.elevation=i.z}}o[0].elevationSample&&o.forEach((e=>{e.elevationSample=o[0].elevationSample})),this._suitabilities=S({features:o,selectedPoint:t,camera:Z(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities);const p=this._suitabilities.map((e=>e.feature));this.currentBestFeature=p[0],this._loading=!1}async _processHitTestResults(e,t,i){const{screenPoint:r,results:[o]}=t,s="graphic"===o?.type&&this.shouldShowSelectedImage,a=o?.mapPoint??this.view?.toMap(r);if(!a)return;const n={layerInstanceOrURL:e,point:a,queryParams:{where:e.definitionExpression??"1=1",maximumDistance:e.maximumDistance,objectIds:s?[o.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(n,i)}_updateFeatures(e){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.currentBestFeature=e[0],e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll()}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:r,currentCoverageVisible:o,isAdditionalPointSourcesVisible:s}=this;if(r){this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),await(this._adapter?.createFootprints(e)),y(e);for(const e of i)e.imageID===r.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e,symbol:q,visible:o}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e,symbol:J,visible:s}))}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let i;if(t)i=-90;else{const t=e.x-U[3],r=e.y-U[3],o=r/Math.sqrt(t**2+r**2);let s=180*Math.acos(o)/Math.PI;(t<0&&r<0||t<0&&r>0)&&(s*=-1),i=s}i===this.bestFeatureAngle?this.previousFeatureAngle=i:this.bestFeatureAngle=i,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics()}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,i,r){this._loading=!1,this.displayMessage={key:e,type:t,data:i,map:r}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,selectedPoint:i,state:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=m(this._crossSymbol)),!i||!t||"image-loaded"!==r)return;let o;try{o=await this.transformPoint(i,e),y(e),await this.plotSelectedPointOnImage(o,e)}catch(s){g(s)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:s,selectedPoint:i,feature:t})}}async transformPoint(e,t){if("none"===this.mode)return;const i=this.currentBestFeature,r=await L([e],{feature:i,imageProperties:"default"===this.mode?this._imageViewer.viewModel.image.serviceRasterInfo:{width:this._panoramicViewer.imageSize?.[0],height:this._panoramicViewer.imageSize?.[1]},options:t},"3d"===this.view?.type);if(!r.length)return;return r[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:r,currentBestFeature:o,currentBestFeatureLocation:s,currentCoverageVisible:a,selectedPoint:n,view:l,_adapter:h}=this,{attributes:{objectId:c},elevationSample:u}=o;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),e&&(e.visible=a,this.bestFeatureCurrentFootprint=e),l){const e=[...i,...r,this.bestFeatureCurrentFootprint,s].filter(ee);l.supportsGround&&u&&h?.updateGroundElevation&&h.updateGroundElevation(e,u),n&&e.push(new t({geometry:n.clone(),symbol:N.clone(),attributes:{imageID:c}})),this._overlays.graphics.addMany(e)}}else if(l){this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,l?.supportsGround&&u&&h?.updateGroundElevation&&h.updateGroundElevation([e],u),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([_()],ue.prototype,"activeLayer",null),e([_({readOnly:!0})],ue.prototype,"activeViewer",null),e([_()],ue.prototype,"additionalFeatures",void 0),e([_()],ue.prototype,"bestFeatureAngle",void 0),e([_({type:Number})],ue.prototype,"brightness",null),e([_({type:Number})],ue.prototype,"contrast",null),e([_()],ue.prototype,"coverageFrustums",void 0),e([_()],ue.prototype,"coveragePolygons",void 0),e([_()],ue.prototype,"currentBestFeature",void 0),e([_()],ue.prototype,"currentCoverageVisible",void 0),e([_({json:{write:!1}})],ue.prototype,"determineWorkflowForFeature",void 0),e([_()],ue.prototype,"disabled",void 0),e([_()],ue.prototype,"displayMessage",void 0),e([_()],ue.prototype,"drawFootprint",void 0),e([_({readOnly:!0})],ue.prototype,"featureCount",null),e([_()],ue.prototype,"features",void 0),e([_({readOnly:!0})],ue.prototype,"imageGalleryEnabled",null),e([_({readOnly:!0})],ue.prototype,"imageLoaded",null),e([_()],ue.prototype,"imagePointsInView",null),e([_()],ue.prototype,"isAdditionalCoverageVisible",void 0),e([_()],ue.prototype,"isAdditionalPointSourcesVisible",void 0),e([_()],ue.prototype,"layer",void 0),e([_({type:Number})],ue.prototype,"localPort",void 0),e([_()],ue.prototype,"mapImageConversionToolState",void 0),e([_({readOnly:!0,value:"none"})],ue.prototype,"mode",null),e([_()],ue.prototype,"navigatorCurrentBestFeature",void 0),e([_()],ue.prototype,"pointSources",void 0),e([_({readOnly:!0})],ue.prototype,"popupEnabled",null),e([_()],ue.prototype,"previousFeatureAngle",void 0),e([_()],ue.prototype,"referencePoint",null),e([_({readOnly:!0})],ue.prototype,"sectorData",null),e([_()],ue.prototype,"selectedPoint",void 0),e([_({type:Number})],ue.prototype,"sharpness",null),e([_()],ue.prototype,"shouldShowSelectedImage",void 0),e([_({readOnly:!0})],ue.prototype,"state",null),e([_({readOnly:!0})],ue.prototype,"thumbnails",null),e([_()],ue.prototype,"updateFootprint",void 0),e([_()],ue.prototype,"updateFootprintPanorama",void 0),e([_({value:null})],ue.prototype,"view",null),e([_()],ue.prototype,"_adapter",void 0),e([_({type:s.ofType(t)})],ue.prototype,"additionalFootprints",void 0),e([_({type:s.ofType(t)})],ue.prototype,"additionalCameraLocations",void 0),e([_()],ue.prototype,"bestFeatureCurrentFootprint",void 0),e([_()],ue.prototype,"_fetchFeaturesController",void 0),e([_()],ue.prototype,"_highlightedFeatureHandle",void 0),e([_()],ue.prototype,"_imageViewer",void 0),e([_({type:t})],ue.prototype,"bestFeatureFootprint",void 0),e([_()],ue.prototype,"_initialCurrentCoverageUpdate",void 0),e([_()],ue.prototype,"_loading",void 0),e([_()],ue.prototype,"_overlays",void 0),e([_({readOnly:!0})],ue.prototype,"_overlaysView",null),e([_()],ue.prototype,"_panoramicViewer",void 0),e([_()],ue.prototype,"_referencePointOnGround",void 0),e([_()],ue.prototype,"_referencePointOnImage",void 0),e([_()],ue.prototype,"currentBestFeatureLocation",void 0),e([_()],ue.prototype,"_sectorData",void 0),e([_()],ue.prototype,"footprintExtent",void 0),ue=e([b("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],ue);const pe=ue;export{pe as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{isSome as r,equals as i}from"../../core/arrayUtils.js";import{createTask as o}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as a}from"../../core/deprecate.js";import n from"../../core/Error.js";import l from"../../core/Evented.js";import{isSerializable as h}from"../../core/JSONSupport.js";import{equalsShallow as c}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as p}from"../../core/mathUtils.js";import{abortMaybe as d,destroyMaybe as m}from"../../core/maybe.js";import{EsriPromise as g}from"../../core/Promise.js";import{throwIfAborted as y,isAbortError as f,waitTick as v}from"../../core/promiseUtils.js";import{on as w,watch as F,syncAndInitial as _,initial as b}from"../../core/reactiveUtils.js";import{property as P}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as I}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as C}from"../../core/support/UpdatingHandles.js";import{isPolygon as S}from"../../geometry/support/jsonUtils.js";import{geographicToWebMercator as V}from"../../geometry/support/webMercatorUtils.js";import O from"../../layers/GraphicsLayer.js";import{searchImages as k}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as j}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as A,computePolygonForInspection as B,resizePolygon as L,checkIfPolygonContainsSelectedPoint as M}from"../../layers/orientedImagery/core/coverageUtils.js";import{updateElevation as G,transformPoints as T}from"../../layers/orientedImagery/transformations/groundToImageUtils.js";import{transformPoints as R}from"../../layers/orientedImagery/transformations/imageToGroundUtils.js";import{getInitialAngle as E,convertPixelToHeadingPitch as H,convertHeadingPitchToSphereVertex as x}from"../../layers/orientedImagery/transformations/utils.js";import D from"../../rest/support/AttachmentQuery.js";import{ViewEventPriorities as U}from"../../views/input/InputManager.js";import N from"../PanoramicViewer.js";import{sectorsInOrder as W,sectorsRadii as z}from"./constants.js";import{crossSymbol as $,crossSymbol3D as q,diamondSymbol as J,diamondSymbol3D as K,activeSourcePointSymbol as Q,sourcePointSymbol as X}from"./symbols.js";import{isNoAttachmentError as Y,getContentType as Z,isTifOrMrf as ee,scaleExtent as te,isSceneView as re,isGraphic as ie,calculateSegment as oe,calculateDirection as se}from"./utils.js";import ae from"./components/ImageViewer.js";import ne from"../../geometry/Point.js";import le from"../../geometry/SpatialReference.js";import he from"../../geometry/Polygon.js";const ce={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles"},ue=new Set(["JPG","JPEG"]),pe=/\.(\w+)$/,de=e=>"FA"===e;let me=class extends(l.EventedMixin(g)){constructor(e){super(e),this.additionalFeatures=new s,this.bestFeatureAngle=0,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentCoverageVisible=!0,this.determineWorkflowForFeature=()=>{d(this._featureChangedTask),this._featureChangedTask=o((async e=>{const{currentBestFeature:t,selectedPoint:r,view:i}=this;if(i?.closePopup(),t&&r){this._initialCurrentCoverageUpdate=!0;try{await this._updatePointsAndPolygons({signal:e}),await this._loadImage({signal:e})}catch(o){f(o)||(this.loadImageError(o),u.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}}))},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.drawFootprint=()=>{this.bestFeatureFootprint&&this.updateCurrentCoveragePolygon(this.bestFeatureFootprint)},this.features=new s,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.navigatorCurrentBestFeature=null,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.updateFootprint=async(e,t)=>{"image-loaded"===this.state&&await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this._adapter=null,this.additionalFootprints=new s,this.additionalCameraLocations=new s,this.bestFeatureCurrentFootprint=null,this._highlightedFeatureHandle=null,this._imageViewer=new ae,this.bestFeatureFootprint=null,this._initialCurrentCoverageUpdate=!0,this._overlays=new O({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new N,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._updatingHandles=new C,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.loadImageViewer=e=>{this._imageViewer.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.toggleImageAttributes=()=>{d(this._openPopupTask),this._openPopupTask=o((async e=>{const{currentBestFeature:r,popupEnabled:i,layer:o,view:s}=this;if(s?.closePopup(),!(s&&r&&i&&o))return;const{attributes:a,geometry:n}=r,l=new t({geometry:n,attributes:a.toJSON(),popupTemplate:o.popupTemplate});y(e),await s.openPopup({features:[l],location:a.location.clone()})}))},this._createViewClickHandle=()=>{if(this.removeHandles(ce.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,U.WIDGET),ce.click)},this._createImageClickHandle=()=>{this.removeHandles(ce.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:r}=this;if(!e||"none"===t||!r)return;r.clickAction="pixel-location";let i=null;const s=w((()=>r),"pixel-location",(e=>{this.plotReferencePointOnImage(e),i?.abort(),i=o((async t=>{const{currentBestFeature:i,footprintExtent:o}=this,{imageSize:s}=r;if(!(i&&e&&s&&o))return;const[a]=await R([e],{feature:i,footprintExtent:o,imageProperties:{width:s[0],height:s[1]},options:{signal:t}});y(t),a&&this.plotReferencePointOnGround(a)}))}));this.addHandles(s,ce.imageClick)},this._getImageSourceFromAttachment=async(e,t,r)=>{const i=new D({objectIds:[t]}),o=await e.queryAttachments(i,r),s=o[`${t}`]?.[0],a=s?.url;if(!a)throw new n("NoAttachmentError","no attachments found",{[e.objectIdField]:t,layer:e});return{datasetFormat:s.contentType.split("/")[1].toUpperCase(),url:a}},this._loadAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/OrientedImageryViewerViewModelAdapter2D.js");y(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/OrientedImageryViewerViewModelAdapter3D.js");y(e),this._adapter=new t(this);break}}else this._adapter=null},this._loadImage=async e=>{const{currentBestFeature:t,layer:r,mode:i}=this;if(this.clearGraphics(),!r||!t||"none"===i)return;const{attributes:o}=t,{imagePath:s,imageRotation:a,cameraHeading:n,cameraRoll:l,cameraPitch:h,objectId:c,cameraOrientation:p,location:d}=o,m=(l??0)+(a??0),g=d.spatialReference.isWGS84&&4!==p?.type?V(d):new ne(d);let v=s;if(de(s))try{v=await this._getImageSourceFromAttachment(r,c,e)}catch(w){if(f(w))return;return Y(w)?(u.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${r.objectIdField}: ${c}`)):(u.getLogger(this).error(w,{[r.objectIdField]:c,layer:r}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${r.objectIdField} ${c}`))}try{await this.loadImageFromSource(v,{imageRotation:m,options:e,pitch:h,yaw:n,mode:i,cameraLocation:g}),y(e),await this.transformAndPlotSelectedLocation(e)}catch(w){f(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:r,imageRotation:i,options:o}=t,s="string"==typeof e,a=s?e:e.url,{origin:n,pathname:l,searchParams:h}=new URL(a);let c=s?l.match(pe)?.[1]??"":e.datasetFormat;if(!c){const e=await Z(a,{...t.options});e&&(c=e.split("/")[1]),c??="UNKNOWN FORMAT"}switch(r){case"default":this._imageViewer.imageSource={datasetFormat:c.toUpperCase(),url:`${n}${l}`},this._imageViewer.customParameters=Object.fromEntries(h),this._imageViewer.imageRotation=i??0,await this._imageViewer.loadImage(o);break;case"panoramic":if(ue.has(c.toUpperCase())){const{selectedPoint:e}=this,{pitch:r,yaw:i,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=a;let l=i??0;"number"==typeof n?l=n-l:s&&e&&(l=await E(s,e)-l),this._panoramicViewer.pitch=r??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(o)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:c});break}},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=o((async t=>{const{pointerType:r,button:i,mapPoint:o}=e;if(("mouse"!==r||0===i)&&o)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(o,{signal:t}))}))},this.plotSelectedPointOnImage=async(e,r)=>{if(await v(r),!e)return;const i=new ne({...h(e)?e.toJSON():e,spatialReference:le.WebMercator});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,this._crossSymbol=new t({geometry:i,symbol:$}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:r}=this._panoramicViewer;if(!r)return;const[i,o]=r,{heading:s,pitch:a}=H(e,i,o),n=x(s,a);this._crossSymbol=new t({geometry:new ne(n,le.WebMercator),symbol:q}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this.determineWorkflowForFeature=this.determineWorkflowForFeature.bind(this),this.selectBestFeature=this.selectBestFeature.bind(this),this.drawFootprint=this.drawFootprint.bind(this)}initialize(){this.addHandles([F((()=>this.view),(()=>{this.load()}),_),F((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),b),F((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),b),F((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{this._createViewClickHandle(),this._createImageClickHandle()}),_),F((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),_),F((()=>this.currentBestFeature),((e,t)=>{this.determineWorkflowForFeature(e,t)}),{sync:!0}),F((()=>this.mode),(e=>{switch(this.removeHandles(ce.interactionHandles),e){case"default":this.addHandles(F((()=>this._imageViewer.imagePointsInView),(e=>{e&&(d(this._updateFootprintTask),this._updateFootprintTask=o((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>i(e,t,c)}),ce.interactionHandles);break;case"panoramic":this.addHandles(F((()=>{const{currentBestFeature:e,state:t}=this,{imageSize:r,vfov:i,hfov:o,pitch:s,yaw:a}=this._panoramicViewer;return e&&r&&"image-loading"!==t?[i,o,a,s]:null}),(e=>{if(!e||"image-loading"===this.state)return;const[t,r,i,s]=e;d(this._updateFootprintTask),this._updateFootprintTask=o((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:r,yaw:i,pitch:s},{signal:e})}))}),{..._,equals:(e,t)=>i(e,t,c)}),ce.interactionHandles)}}),_),F((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:r,mode:i,sharpness:o}=this;"default"===i&&(e.brightness=t,e.contrast=r,e.sharpness=o)}),_)])}destroy(){this._updateFootprintTask=d(this._updateFootprintTask),this._clickTask=d(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=m(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._crossSymbol=m(this._crossSymbol),this._referencePointOnGround=m(this._referencePointOnGround),this._referencePointOnImage=m(this._referencePointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy()}get activeLayer(){return a(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){a(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:r}=this;switch(r){case"default":return e;case"panoramic":return t;default:return null}}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",p(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",p(e,-10,10))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){return ee(this.currentBestFeature?.attributes.imagePath.trim())}get imageLoaded(){return a(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:r}=e;return 360===t||r?"panoramic":"default"}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?W.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",p(e,0,1))}get state(){const{mode:e,disabled:t}=this;if(t)return"disabled";if(!this.isFulfilled())return"loading";if(this.isRejected())return"error";if(this._updatingHandles.updating)return"image-loading";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:r,imageRotation:i}})=>{const o=e.trim();return ee(o)?{url:o,objectId:t,rotation:(r??0)+(i??0)}:null})).filter(r)):null}set view(e){this._set("view",e)}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}filterByFootprints(e,t){const r=[],i=[],o=[];return e.forEach((e=>{const{layer:{coveragePercent:s},attributes:a}=e;let n;const{polygon:l,frustum:h}=A(a);if(n=l.clone(),a.isInspection&&(n=B(a)),s&&(n=L(n,s)),M(n,t)){o.push(e);const{cameraHeading:t,geometry:s,objectId:n,cameraHeight:c}=a,u=s.clone();u.z=c,u.imageID=n,this.pointSources.push(u),-999!==t&&(r.push(l),h&&i.push(h))}})),{features:o,polygons:r,frustums:i}}getCurrentCoveragePolygon(){return this.bestFeatureCurrentFootprint}getCurrentBestFeaturePolygon(){return this.bestFeatureFootprint}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[W[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:r}=e;if(isNaN(r))return;const i=this._sectorData?.[t];i?.length&&this._updateCurrentBestFeature(i.at(r))}async load(e){return this.addResolvingPromise(this._loadAdapter(e).catch((e=>{if(!f(e))throw e}))),this}async loadBestImage(e,t){return this.view?.closePopup(),this.displayMessage=null,this.selectedPoint=e.spatialReference.isGeographic?V(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),this._fetchFeaturesWithController(e,t)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new ne({...e.toJSON()}),symbol:J}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage.destroy()),this.mode){case"default":{const r=h(e)?e.toJSON():e;r.x-=.5,r.y=.5-r.y,this._referencePointOnImage=new t({geometry:new ne({spatialReference:this._imageViewer.imageRenderer.spatialReference,...r}),symbol:J}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:r}=this._panoramicViewer;if(!r)return;const[i,o]=r,{heading:s,pitch:a}=H(e,i,o),n=x(s,a);this._referencePointOnImage=new t({geometry:new ne(n,le.WebMercator),symbol:K}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=d(this._clickTask)}async searchBestImage(e,t){try{const r=await k(e,t);r&&await this._processFeatureResponse(r,e.point,{signal:t?.signal})}catch(r){f(r)||(this.setMessage("imageLoadError","error",r.message),u.getLogger(this).error("error occurred while finding best image",r))}}selectBestFeature(e){this.currentBestFeature=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:r}=e,i=this.bestFeatureFootprint?.geometry,o=S(i)&&i.contains(t),s="mesh"===i?.type&&i?.extent.contains(t);if(!o&&!s)return;const a=await this.transformPoint(t,r);return a?(this.plotReferencePointOnImage(a),{x:a.x,y:a.y}):void 0}updateSuitabilities(e){this._suitabilities=e.sort(((e,t)=>e.suitability-t.suitability));const t=this._suitabilities.map((e=>e.feature));this._initialCurrentCoverageUpdate=!0,this._groupFeaturesBySectors(),this._updateFeatures(t)}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);return this._processHitTestResults(r,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(r){if(f(r))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",r)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:r,features:i}=this;if(!(e&&t&&r&&i))return void(this._sectorData=null);this._sectorData={};for(const l of W)this._sectorData[l]=new s;const o=e.map(((e,t)=>({...e,featureIndex:t})));o.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const a=o.map((({distance:e})=>e)),n=Math.max(...a);o.forEach((e=>{const{distance:t,angle:r,featureIndex:o}=e,s=t/n*z[2],a=oe(t,n),l=se(r);if(!this._sectorData)return;const h=z[3]+s*Math.sin(r*Math.PI/180),c=z[3]+s*Math.cos(r*Math.PI/180);let u;const p=i.at(o),d=p===this.currentBestFeature,m=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(d&&m)u=-90;else{const e=h-z[3],t=c-z[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),u=i}const g=""===a?l:`${a}_${l}`;d&&(u===this.bestFeatureAngle?this.previousFeatureAngle=u:this.bestFeatureAngle=u,this.navigatorCurrentBestFeature=m?null:{x:h,y:c,direction:l});const y=this._sectorData[g];y.add({angle:r,featureIndex:o,x:h,y:c,objectID:p.attributes.objectId,sector:g,featureIndexInSector:y.length})}))}async _processFeatureResponse(e,t,r){const{features:i}=e;if(!i?.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll();const{features:o,polygons:s,frustums:a}=this.filterByFootprints(i,t);if(!o.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(a);const n=new he({spatialReference:s[0].spatialReference});for(const{rings:u}of s)n.addRing(u[0]);const l=[];for(const{geometry:u}of o)n.contains(u)||l.push(u);n.addRing(l);const h=n.extent;let c;if(te(h,2),this.footprintExtent=h,this.view?.supportsGround)try{c=await this.view.map.ground.createElevationSampler(h,r)}catch(p){f(p)||u.getLogger(this).error(p)}if(o[0].elevationSample=c,(c||o[0].attributes.elevationSource)&&h){const e=await G([t],{feature:o[0],footprintExtent:h,options:r});if(e[0]){const r=e[0];t.elevation=r.z}}o[0].elevationSample&&o.forEach((e=>{e.elevationSample=o[0].elevationSample})),this._suitabilities=j({features:o,selectedPoint:t,camera:re(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities)}async _processHitTestResults(e,t,r){const{screenPoint:i,results:[o]}=t,s="graphic"===o?.type&&this.shouldShowSelectedImage,a=o?.mapPoint??this.view?.toMap(i);if(!a)return;const n={layerInstanceOrURL:e,point:a,queryParams:{where:e.definitionExpression??"1=1",maximumDistance:e.maximumDistance,objectIds:s?[o.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(n,r)}_updateFeatures(e){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this.currentBestFeature=e[0]}async _updatePointsAndPolygons(e){const{pointSources:r,currentBestFeature:i,currentCoverageVisible:o,isAdditionalPointSourcesVisible:s}=this;if(i){this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),await(this._adapter?.createFootprints(e)),y(e);for(const e of r)e.imageID===i.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e,symbol:Q,visible:o}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e,symbol:X,visible:s}))}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let r;if(t)r=-90;else{const t=e.x-z[3],i=e.y-z[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.bestFeatureAngle?this.previousFeatureAngle=r:this.bestFeatureAngle=r,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics()}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,r,i){this.displayMessage={key:e,type:t,data:r,map:i}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,selectedPoint:r,state:i}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=m(this._crossSymbol)),!r||!t||"image-loaded"!==i)return;let o;try{o=await this.transformPoint(r,e),y(e),await this.plotSelectedPointOnImage(o,e)}catch(s){f(s)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:s,selectedPoint:r,feature:t})}}async transformPoint(e,t){if("none"===this.mode)return;const r=this.currentBestFeature,i=await T([e],{feature:r,imageProperties:"default"===this.mode?this._imageViewer.viewModel.image.serviceRasterInfo:{width:this._panoramicViewer.imageSize?.[0],height:this._panoramicViewer.imageSize?.[1]},options:t},"3d"===this.view?.type);if(!i.length)return;return i[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:r,additionalCameraLocations:i,currentBestFeature:o,currentBestFeatureLocation:s,currentCoverageVisible:a,selectedPoint:n,view:l,_adapter:h}=this,{attributes:{objectId:c},elevationSample:u}=o;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),e&&(e.visible=a,this.bestFeatureCurrentFootprint=e),l){const e=[...r,...i,this.bestFeatureCurrentFootprint,s].filter(ie);l.supportsGround&&u&&h?.updateGroundElevation&&h.updateGroundElevation(e,u),n&&e.push(new t({geometry:n.clone(),symbol:$.clone(),attributes:{imageID:c}})),this._overlays.graphics.addMany(e)}}else if(l){this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,l?.supportsGround&&u&&h?.updateGroundElevation&&h.updateGroundElevation([e],u),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([P()],me.prototype,"activeLayer",null),e([P({readOnly:!0})],me.prototype,"activeViewer",null),e([P()],me.prototype,"additionalFeatures",void 0),e([P()],me.prototype,"bestFeatureAngle",void 0),e([P({type:Number})],me.prototype,"brightness",null),e([P({type:Number})],me.prototype,"contrast",null),e([P()],me.prototype,"coverageFrustums",void 0),e([P()],me.prototype,"coveragePolygons",void 0),e([P()],me.prototype,"currentBestFeature",void 0),e([P()],me.prototype,"currentCoverageVisible",void 0),e([P({json:{write:!1}})],me.prototype,"determineWorkflowForFeature",void 0),e([P()],me.prototype,"disabled",void 0),e([P()],me.prototype,"displayMessage",void 0),e([P()],me.prototype,"drawFootprint",void 0),e([P({readOnly:!0})],me.prototype,"featureCount",null),e([P()],me.prototype,"features",void 0),e([P({readOnly:!0})],me.prototype,"imageGalleryEnabled",null),e([P({readOnly:!0})],me.prototype,"imageLoaded",null),e([P()],me.prototype,"imagePointsInView",null),e([P()],me.prototype,"isAdditionalCoverageVisible",void 0),e([P()],me.prototype,"isAdditionalPointSourcesVisible",void 0),e([P()],me.prototype,"layer",void 0),e([P({type:Number})],me.prototype,"localPort",void 0),e([P()],me.prototype,"mapImageConversionToolState",void 0),e([P({readOnly:!0,value:"none"})],me.prototype,"mode",null),e([P()],me.prototype,"navigatorCurrentBestFeature",void 0),e([P()],me.prototype,"pointSources",void 0),e([P({readOnly:!0})],me.prototype,"popupEnabled",null),e([P()],me.prototype,"previousFeatureAngle",void 0),e([P()],me.prototype,"referencePoint",null),e([P({readOnly:!0})],me.prototype,"sectorData",null),e([P()],me.prototype,"selectedPoint",void 0),e([P({type:Number})],me.prototype,"sharpness",null),e([P()],me.prototype,"shouldShowSelectedImage",void 0),e([P({readOnly:!0})],me.prototype,"state",null),e([P({readOnly:!0})],me.prototype,"thumbnails",null),e([P()],me.prototype,"updateFootprint",void 0),e([P()],me.prototype,"updateFootprintPanorama",void 0),e([P({value:null})],me.prototype,"view",null),e([P()],me.prototype,"_adapter",void 0),e([P({type:s.ofType(t)})],me.prototype,"additionalFootprints",void 0),e([P({type:s.ofType(t)})],me.prototype,"additionalCameraLocations",void 0),e([P()],me.prototype,"bestFeatureCurrentFootprint",void 0),e([P()],me.prototype,"_highlightedFeatureHandle",void 0),e([P()],me.prototype,"_imageViewer",void 0),e([P({type:t})],me.prototype,"bestFeatureFootprint",void 0),e([P()],me.prototype,"_initialCurrentCoverageUpdate",void 0),e([P()],me.prototype,"_overlays",void 0),e([P({readOnly:!0})],me.prototype,"_overlaysView",null),e([P()],me.prototype,"_panoramicViewer",void 0),e([P()],me.prototype,"_referencePointOnGround",void 0),e([P()],me.prototype,"_referencePointOnImage",void 0),e([P()],me.prototype,"currentBestFeatureLocation",void 0),e([P()],me.prototype,"_sectorData",void 0),e([P({readOnly:!0})],me.prototype,"_updatingHandles",void 0),e([P()],me.prototype,"footprintExtent",void 0),me=e([I("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],me);const ge=me;export{ge 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.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Camera.js";import"../../geometry.js";import i from"../../Ground.js";import o from"../../Map.js";import a from"../../request.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import n from"../../core/Evented.js";import{JSONMap as h}from"../../core/jsonMap.js";import{rad2deg as m,deg2rad as l}from"../../core/mathUtils.js";import{destroyMaybe as d}from"../../core/maybe.js";import{isAbortError as c,waitTick as p}from"../../core/promiseUtils.js";import{watch as g,when as _,syncAndInitial as u}from"../../core/reactiveUtils.js";import{property as y}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{enumeration as v}from"../../core/accessorSupport/decorators/enumeration.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import w from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Camera.js";import"../../geometry.js";import i from"../../Ground.js";import o from"../../Map.js";import a from"../../request.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import n from"../../core/Evented.js";import{JSONMap as h}from"../../core/jsonMap.js";import{rad2deg as m,deg2rad as l}from"../../core/mathUtils.js";import{destroyMaybe as d}from"../../core/maybe.js";import{isAbortError as c,waitTick as p}from"../../core/promiseUtils.js";import{watch as g,when as _,syncAndInitial as u}from"../../core/reactiveUtils.js";import{property as y}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{enumeration as v}from"../../core/accessorSupport/decorators/enumeration.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import w from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as z}from"../../layers/orientedImagery/transformations/utils.js";import R from"../../views/SceneView.js";import V from"../Zoom.js";import{logAndThrow as C,getMissingPropertyErrorName as M,getMissingPropertyErrorMessage as j}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as P,maxPanoramicViewerHFOV as H,minPanoramicViewerHFOV as O,humanBinocularHFOV as S}from"./constants.js";import b from"./PanoramicZoomConditions.js";import k from"./PanoramicZoomViewModel.js";import{findDiagonalFOV as x,meshToGraphic as I,createImageSphere as F}from"./utils.js";import G from"../../geometry/SpatialReference.js";const A={autoLoad:"auto-load",default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let L=class extends n.EventedAccessor{constructor(e){super(e),this._startPosition=null,this._targetPosition=null,this._graphics=new w({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this._loadController=null,this._map=new o({ground:new i({opacity:0,navigationConstraint:null}),layers:new r([this._graphics])}),this._zoomViewModel=null,this.autoLoad=!1,this.clickAction="none",this.imageSize=null,this.imageSource=null,this.pitch=90,this.state="ready",this.yaw=0,this._addNavigationHandles=()=>{this.imageRenderer.basemapTerrain.suspended=!0,this.imageRenderer.constraints.tilt.max=180,this.removeHandles(A.navigation),this.addHandles([this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("double-click",this._handleDoubleClick),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",(e=>{const t=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],i=e.key;t.includes(i)&&e.stopPropagation()}))],A.navigation)},this._addHFOVHandles=()=>{this.removeHandles(A.fovConstraint),this.addHandles(g((()=>[this.maxHFOV,this.minHFOV]),(()=>{this._zoomViewModel&&(this._zoomViewModel.panoramicZoomConditions=new b({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))}),u),A.fovConstraint)},this._addZoomHandles=()=>{this._zoomViewModel=new k({view:this.imageRenderer,panoramicZoomConditions:new b({maxFOV:this.maxHFOV,minFOV:this.minHFOV})});const e=new V({viewModel:this._zoomViewModel});this.imageRenderer.ui.add(e,"top-left"),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:t,x:i,y:o}=e;switch(t){case"start":this._startPosition=this._targetPosition={x:i,y:o};break;case"update":this._targetPosition={x:i,y:o},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.async((async()=>{const t=await this.imageRenderer.hitTest(e.screenPoint,{include:this._graphics});this.emit("hittest-response",t)}));break;case"pixel-location":{if(e.stopPropagation(),!this.imageSize||!e.mapPoint)return void this.emit("pixel-location",null);const t=z(e.mapPoint,this.imageSize[0],this.imageSize[1]);this.emit("pixel-location",{...t,spatialReference:G.WebMercator});break}}},this._handleWheel=e=>{const t=e.deltaX??e.native.deltaX;e.stopPropagation(),t>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadWithController=()=>{this._cancelLoadWithController(),this._loadController=new AbortController,this.loadImage(this._loadController)},this._zoomIn=()=>this._zoomViewModel?.zoomIn(),this._zoomOut=()=>this._zoomViewModel?.zoomOut(),this.addGraphic=(e,t)=>"image-loaded"===this.state&&!this._graphics.graphics.includes(e)&&(this._graphics.graphics.add(e,t),!0),this.addManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter((e=>!this._graphics.graphics.includes(e)));return this._graphics.graphics.addMany(t),!0},this.clearGraphics=()=>{this._graphics.graphics.removeAll()},this.clearImage=()=>{this.imageSize=null,this._removeImageSphere()},this.removeGraphic=e=>!("image-loaded"!==this.state||!this._graphics.graphics.includes(e))&&(this._graphics.remove(e),!0),this.removeManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter((e=>this._graphics.graphics.includes(e)));return this._graphics.removeMany(t),!0},this._imageRenderer=new R({map:this._map,viewingMode:"local",camera:{position:P},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:G.WebMercator,ui:{components:["attribution"]}})}initialize(){this.state="initialized",this.addHandles([g((()=>this.imageSource),(()=>{this.imageSource&&this.autoLoad&&this._loadWithController()}),u),g((()=>this.fov),(()=>{this._reloadCamera()}),u),g((()=>this.yaw),(e=>{this.camera.heading=e,this._reloadCamera()}),u),g((()=>this.pitch),(e=>{this.camera.tilt=e,this._reloadCamera()}),u),_((()=>this.imageRenderer.ready),(()=>{this._addNavigationHandles(),this._addZoomHandles()}),u),g((()=>this.clickAction),(e=>{this.removeHandles(A.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))}),u)],A.default)}get camera(){return this.imageRenderer.camera}set camera(e){e&&(this.imageRenderer.camera=e.clone())}get fov(){return this.camera.fov}set fov(e){Number.isFinite(e)&&this._zoomViewModel?.zoomTo(e)}get hfov(){const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*m(Math.atan(Math.tan(l(e/2))*Math.sin(a)))}get imageRenderer(){return this._imageRenderer}get maxHFOV(){const{size:[e,t]}=this.imageRenderer;return x(H,e/t)}get minHFOV(){const{size:[e,t]}=this.imageRenderer;return x(O,e/t)}get vfov(){const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*m(Math.atan(Math.tan(l(e/2))*Math.cos(a)))}async _loadImageInternal(e,t){let i;this.state="image-loading";try{i=(await a(e,{responseType:"image",...t})).data}catch(o){throw c(o)?this.state="image-load-aborted":this.state="image-load-error",o}return this._updateImageSphere(i,t)}_reloadCamera(){this.camera=this.camera.clone()}_removeImageSphere(){this._imageGraphic&&(this._graphics.remove(this._imageGraphic),this._imageGraphic=d(this._imageGraphic)),this.state="ready",this.imageSize=null}_updateCameraHeadingAndTilt(){if(!this._startPosition||!this._targetPosition)return;const e=this.camera.heading+(this._startPosition.x-this._targetPosition.x)/this.imageRenderer.width*this.camera.fov;this.yaw=(e+360)%360;const t=this.camera.tilt-(this._startPosition.y-this._targetPosition.y)/this.imageRenderer.height*this.imageRenderer.camera.tilt;this.pitch=Math.min(179.5,Math.max(.5,t)),this._startPosition=this._targetPosition}async _updateImageSphere(e,t){await p(t);const{size:[i,o]}=this.imageRenderer;return this._imageGraphic=I(F(e)),this._graphics.add(this._imageGraphic),this.fov=x(S,i/o),this.state="image-loaded",this.imageSize=[e.width,e.height],this._imageGraphic.geometry}async loadImage(e){return this._removeImageSphere(),this.imageSource?this._loadImageInternal(this.imageSource,e):C(this.declaredClass,new s(M("panoramic-viewer"),j("PanoramicViewerViewModel","imageSource")))}};e([y()],L.prototype,"_graphics",void 0),e([y()],L.prototype,"_imageGraphic",void 0),e([y()],L.prototype,"_imageRenderer",void 0),e([y()],L.prototype,"_loadController",void 0),e([y()],L.prototype,"_map",void 0),e([y()],L.prototype,"_zoomViewModel",void 0),e([y({type:Boolean})],L.prototype,"autoLoad",void 0),e([y({type:t})],L.prototype,"camera",null),e([v(new h({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],L.prototype,"clickAction",void 0),e([y({type:Number})],L.prototype,"fov",null),e([y({readOnly:!0})],L.prototype,"hfov",null),e([y({readOnly:!0})],L.prototype,"imageRenderer",null),e([y()],L.prototype,"imageSize",void 0),e([y()],L.prototype,"imageSource",void 0),e([y({readOnly:!0})],L.prototype,"maxHFOV",null),e([y({readOnly:!0})],L.prototype,"minHFOV",null),e([y({type:Number})],L.prototype,"pitch",void 0),e([y()],L.prototype,"state",void 0),e([y({readOnly:!0})],L.prototype,"vfov",null),e([y({type:Number})],L.prototype,"yaw",void 0),L=e([f("esri.widgets.PanoramicViewer.PanoramicViewerViewModel")],L);const W=L;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.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import{id as o}from"../../kernel.js";import e from"../../core/Error.js";import{JSONSupport as r}from"../../core/JSONSupport.js";import{createMD5Hash as s}from"../../core/MD5.js";import{isAbortError as a}from"../../core/promiseUtils.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import n from"../../portal/PortalItem.js";import{fromJSON as p}from"../../rest/support/fileFormat.js";import{fromJSON as u}from"../../rest/support/layoutTemplate.js";import{fetchLayoutTemplateInfos as m}from"./utils.js";let d=class extends r{constructor(t){super(t),this.description=null,this.format=null,this.state="not-loaded",this.label=null,this.layoutInfoTaskUrl=null,this.layout=null,this.layoutItem=null,this.layoutOptions=null,this.layoutTemplateInfo=null,this.type=null}get id(){return this.layoutItem?.id??`${this.layout}-${s(JSON.stringify(this.toJSON()))}`}get mapSurroundInfoOptions(){const t=this.layoutTemplateInfo?.layoutOptions?.mapSurroundInfos;if(!t)return null;const o={northArrow:[],scaleBar:[],legend:[]};for(const e of t)switch(e.type){case"CIMMarkerNorthArrow":o.northArrow.push(e);break;case"CIMScaleLine":o.scaleBar.push(e);break;case"CIMGroupElement":e.elements?.some((t=>"CIMScaleLine"===t.type))&&o.scaleBar.push(e);break;case"CIMLegend":o.legend.push(e)}return o}async fetchLayoutItemTemplateInfo(t){const{layoutItem:r}=this;if(r?.id&&!this.layoutTemplateInfo&&"loaded"!==this.state)try{this._set("state","loading");const s=this.layoutInfoTaskUrl;if(!s)throw new e("print:invalid-layout-info-task-url","Can't fetch layout template info",{url:s});"public"!==r.access&&o&&await o.getCredential(s);const a={Layout_Item_ID:JSON.stringify({id:r.id})},i=(await m(s,a,t))[0];this._set("layoutTemplateInfo",i);const{hasLegend:l}=i.layoutOptions,n=this.mapSurroundInfoOptions?.northArrow.some((({visible:t})=>t))??!1,p=this.mapSurroundInfoOptions?.scaleBar.some((({visible:t})=>t))??!1;this._set("layoutOptions",{legend:l,northArrow:n,scaleBar:p}),this._set("state","loaded")}catch(s){this._set("state",a(s)?"not-loaded":"error")}}setLayoutTemplateInfo(t){this._set("layoutTemplateInfo",t),this._set("state","loaded")}};t([i({json:{write:!0}})],d.prototype,"description",void 0),t([i({json:{read:p,write:!0}})],d.prototype,"format",void 0),t([i({readOnly:!0})],d.prototype,"id",null),t([i({readOnly:!0})],d.prototype,"state",void 0),t([i({json:{write:!0}})],d.prototype,"label",void 0),t([i()],d.prototype,"layoutInfoTaskUrl",void 0),t([i({json:{read:u,write:!0}})],d.prototype,"layout",void 0),t([i({type:n,json:{write:!0}})],d.prototype,"layoutItem",void 0),t([i({readOnly:!0,json:{write:!0}})],d.prototype,"layoutOptions",void 0),t([i({readOnly:!0})],d.prototype,"layoutTemplateInfo",void 0),t([i({readOnly:!0})],d.prototype,"mapSurroundInfoOptions",null),t([i()],d.prototype,"type",void 0),d=t([l("esri.widgets.Print.CustomTemplate")],d);const y=d;export{y 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.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{id as e}from"../../kernel.js";import o from"../../request.js";import{isSome as i}from"../../core/arrayUtils.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import{JSONMap as a}from"../../core/jsonMap.js";import{clone as l}from"../../core/lang.js";import n from"../../core/Loadable.js";import{isAbortError as p}from"../../core/promiseUtils.js";import m from"../../core/ReactiveMap.js";import{watch as u,initial as h}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{unitType as d,convertUnit as y,getMetersPerUnitForSR as f,inchesPerMeter as v}from"../../core/unitUtils.js";import{property as w}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as T}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as I,convertDateFormatToIntlOptions as _}from"../../intl/date.js";import{getLanguage as g}from"../../intl/locale.js";import O from"../../portal/Portal.js";import b from"../../portal/PortalQueryParams.js";import{reArcGISOnlineDomain as x}from"../../portal/support/urlUtils.js";import{execute as P,getTasks as S,getMode as j}from"../../rest/print.js";import{execute as L}from"../../rest/geoprocessor/execute.js";import{submitJob as E}from"../../rest/geoprocessor/submitJob.js";import{fromJSON as U}from"../../rest/support/fileFormat.js";import{fromJSON as k}from"../../rest/support/layoutTemplate.js";import C from"../../rest/support/PrintParameters.js";import H from"../../rest/support/PrintTemplate.js";import{getExtent as F}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as D}from"../../views/input/InputManager.js";import A from"../../views/overlay/BoxOverlayItem.js";import M from"./CustomTemplate.js";import W from"./TemplateOptions.js";import N from"../../geometry/Extent.js";const z=new Set(["GISProfessionalStdUT","GISProfessionalAdvUT"]),V=/(\/GPServer\/).+/i,q=new a({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),G=r.ofType(M);function R(t){t.layoutOptions??={},t.layoutOptions.customTextElements??=[];const e="date";if(!t.layoutOptions.customTextElements.find((t=>e in t))){const{customTextElements:e}=t.layoutOptions;let o=I(Date.now(),_("short-date"));"ar"===g()&&(o=""+o),e.push({date:o})}}let J=class extends n{constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._layoutToTemplateInfo=new m,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this._asyncPrintTaskUrl=null,this._layoutInfoTaskUrl=null,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new G,this.defaultTemplates=new G,this.error=null,this.extraParameters=null,this.includeDefaultTemplates=!0,this.portal=O.getDefault(),this.portalTemplateIds=[],this.showPrintAreaEnabled=!1,this.printServiceUrl=null,this.printTimeout=12e4,this.templatesInfo=null,this.updateDelay=1e3,this.view=null,this.templateCustomTextElements=null,this.templateOptions=new W}initialize(){this.addHandles(u((()=>this.showPrintAreaEnabled),(t=>{t?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))})))}destroy(){this.removeHandles("overlay-handler"),this.view&&(this._overlayItem&&(this.view.overlay?.removeItem(this._overlayItem),this._overlayItem.destroy(),this._overlayItem=null),this.view=null)}get effectivePrintServiceUrl(){return this.printServiceUrl??null}get effectiveTemplateCustomTextElements(){if(!this._serviceTemplateCustomTextElements)return{};const t=l(this._serviceTemplateCustomTextElements);return this.templateCustomTextElements&&Object.keys(this.templateCustomTextElements).forEach((e=>{const o=t[e];if(o){const t=this.templateCustomTextElements?.[e];o.forEach((e=>{const[o]=Object.entries(e)[0];t?.forEach((t=>{const[i,r]=Object.entries(t)[0];o===i&&(e[o]=r)}))}))}})),Object.freeze(t)}get layoutTemplateInfo(){const t=this.templateOptions.layoutItem?.id??this.templateOptions.layout;return t?this._layoutToTemplateInfo.get(t):null}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}get layoutTemplateNorthArrowInfo(){return this.layoutTemplateInfo?.layoutOptions?.mapSurroundInfos?this.layoutTemplateInfo.layoutOptions.mapSurroundInfos.find((t=>"CIMMarkerNorthArrow"===t.type)):null}async load(t){return this.addResolvingPromise(this._loadResources(t).catch((t=>this.error=t))),this}async print(t){const{view:e,extraParameters:o,updateDelay:i}=this;if(!e)throw new s("print:view-required","view is not set");R(t);const r=this._getOverlayItem(),a=t.scalePreserved||!this.showPrintAreaEnabled?void 0:F(new N,e.viewpoint,"map-only"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[r.boxWidth,r.boxHeight]),l=new C({view:e,template:t,extent:a,extraParameters:o,updateDelay:i});try{const e=!!t.layoutItem?.id&&(this.portalTemplateIds.includes(t.layoutItem.id)||this.browseTemplates.some((e=>e.layoutItem?.id===t.layoutItem?.id)));return await P(e&&this._asyncPrintTaskUrl?this._asyncPrintTaskUrl:this.effectivePrintServiceUrl,l,{timeout:this.printTimeout})}catch(n){throw new s("print:export-error","An error occurred while exporting the web map.",{error:n})}}toPrintTemplate({attributionEnabled:t,author:e,copyright:o,customTextElements:i,dpi:r,forceFeatureAttributes:a,format:l,height:n,includeTables:p,layout:m,layoutItem:u,legendEnabled:h,northArrowEnabled:c,scale:d,scaleEnabled:y,title:f,width:v}){if(!m&&!u)throw new s("print:layout-required","layout is not set");const w=new H({attributionVisible:t,forceFeatureAttributes:a,format:l,includeTables:p,layout:m,layoutItem:u,layoutOptions:{authorText:e||"",copyrightText:o||"",customTextElements:i,titleText:f||""},outScale:d??0,scalePreserved:y});v&&(w.exportOptions.width=v),n&&(w.exportOptions.height=n),r&&(w.exportOptions.dpi=r),!h&&w.layoutOptions&&(w.layoutOptions.legendLayers=[]);const T=this.layoutTemplateNorthArrowInfo;if(T){!(T.visible===c)&&w.layoutOptions&&(w.layoutOptions.elementOverrides={[T.name]:{visible:c}})}return w}async fetchLayoutTemplateInfo(t,e){if(!t.layoutItem?.id)return;const o=await this._fetchPortalLayoutTemplateInfo(t.layoutItem,e);this._layoutToTemplateInfo.set(t.layoutItem.id,o),t.layoutTemplateInfo=o;const{hasLegend:i,mapSurroundInfos:r,customTextElements:s}=o.layoutOptions,a=r.some((({type:t,visible:e})=>"CIMMarkerNorthArrow"===t&&e));t.layoutOptions={legend:i,northArrow:a};const n=l(this._serviceTemplateCustomTextElements)??{};n[t.layoutItem.id]=s,this._serviceTemplateCustomTextElements=Object.freeze(n)}getLayoutTemplateInfo(t){return this._layoutToTemplateInfo.get(t)}async addPortalTemplate(t){const e=new M({label:t.title,layoutItem:t});this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem?.id&&this.templateOptions.layoutItem?.id===t.layoutItem.id&&(this.templateOptions.layout=this.defaultTemplates.length||this.browseTemplates.length?null:this.templatesInfo?.layout?.defaultValue,this.templateOptions.layoutItem=null),this._layoutToTemplateInfo.delete(t.layoutItem.id),this.browseTemplates.remove(t)}async _loadResources(t){let e=[];if(this.printServiceUrl)this._set("effectivePrintServiceUrl",this.printServiceUrl),await this._updateLayoutInfoTaskUrl(this.effectivePrintServiceUrl);else{if(this.destroyed)return;try{await this.portal.load(t)}catch(l){throw new s("print:could-not-load-portal","Cannot load print resource information from portal",{error:l,url:this.effectivePrintServiceUrl})}if(this.portal.helperServices){const{asyncPrintTask:t,layoutInfoTask:o,printTask:i}=this.portal.helperServices;i&&(this._set("effectivePrintServiceUrl",i.url),e=i.templates?.map((t=>M.fromJSON(t)))??[]),this._asyncPrintTaskUrl=t?.url,await this._updateLayoutInfoTaskUrl(o?.url||this.effectivePrintServiceUrl)}}this.defaultTemplates.addMany(e);const o=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!o?.includes("gpserver"))throw new s("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl});const[i,r,a]=await Promise.all([this._getPrintServiceLayouts(t),this._getPrintServiceTemplates(t),this._getPortalCustomTemplates(t)]);if(this._processPrintServiceLayouts(i),this._processPrintServiceTemplates(r),this._processPortalTemplates(a),this.templateOptions.layoutItem?.id){const e=this.templateOptions.layoutItem.id;let o=this.defaultTemplates.find((t=>t.layoutItem?.id===e));o||(o=new M({label:this.templateOptions.layoutItem.title,layoutItem:this.templateOptions.layoutItem})),await this.fetchLayoutTemplateInfo(o,t),this.templateOptions.layout=null,this.templateOptions.layoutItem=o.layoutItem}this._updateOverLayItem()}async _updateLayoutInfoTaskUrl(t,e){if(!t)return;const o=(await S(t,e)).find((t=>t.includes("Get Layout Templates Info")));o&&(this._layoutInfoTaskUrl=t.replace(V,`$1${encodeURI(o)}`))}async _getPortalCustomTemplates(t){if(this.printServiceUrl||!this.portal)return[];const{layoutGroupQuery:e,user:o}=this.portal,i=x.test(this.portal.url),r=o?.userLicenseTypeId,s=r&&z.has(r);if(!e||i&&!s)return[];const a=new b({query:e,disableExtraQuery:!0}),l=await this.portal.queryGroups(a,t);if(!l.total)return[];const n=l.results[0],p=new b({num:100,query:"type:Layout",sortField:n.sortField,sortOrder:n.sortOrder??void 0}),m=(await n.queryItems(p,t)).results;return m.length?m.map((t=>new M({label:t.title,layoutItem:t}))):[]}async _fetchPortalLayoutTemplateInfo(t,o){const{id:i}=t,r=this._layoutInfoTaskUrl;if(!r)throw new s("print:invalid-layout-info-task-url","Can't fetch layout template info",{url:r});"public"!==t.access&&e&&await e.getCredential(r);const a={Layout_Item_ID:JSON.stringify({id:i})};return(await this._fetchLayoutTemplateInfos(a,o))[0]}async _fetchLayoutTemplateInfos(t,e){const o=this._layoutInfoTaskUrl;if(!o)throw new s("print:invalid-layout-info-task-url","Can't fetch layout template info",{url:o});if("async"===await j(o)){const i=await E(o,t,void 0,e||void 0);await i.waitForJobCompletion({interval:1e3});return(await i.fetchResultData("Output_JSON")).value}return(await L(o,t,null,e)).results[0].value}_processPortalTemplates(t){if(t){this.defaultTemplates.addMany(t);for(const e of t)e.layoutItem?.id&&this.portalTemplateIds.push(e.layoutItem.id)}}_processPrintServiceTemplates(t){this._set("templatesInfo",t)}async _getPrintServiceLayouts(t){let e=[];try{e=await this._fetchLayoutTemplateInfos(void 0,t)}catch{}return e}_processPrintServiceLayouts(t){const e={};for(const o of t){const{layoutTemplate:t,layoutOptions:i}=o,r=k(t);this._layoutToTemplateInfo.set(r,o),e[r]=i.customTextElements}this._serviceTemplateCustomTextElements=Object.freeze(e)}async _getPrintServiceTemplates(t){let e;try{({data:e}=await o(this.effectivePrintServiceUrl,{...t,query:{f:"json"},timeout:this.printTimeout}))}catch(l){throw p(l)?l:new s("print:unavailable-service-info","Can't fetch templates info from service",{error:l})}const{parameters:i}=e,r=i.find((({name:t})=>"Format"===t)),a=i.find((({name:t})=>"Layout_Template"===t));return{format:this._getFormat(r),layout:this._getLayout(a)}}_getFormat(t){const e="all"===this.allowedFormats?t.choiceList:t.choiceList.filter((t=>this.allowedFormats.includes(U(t)))),o=(e.length?e:t.choiceList).map(U).filter(i),r=U(t.defaultValue),s=o.includes(r)?r:o[0];return{choiceList:o,defaultValue:s}}_getLayout(t){const e=t.choiceList.filter((t=>"map_only"!==t.toLowerCase())),o="all"===this.allowedLayouts?e:e.filter((t=>this.allowedLayouts.includes(k(t)))),r=(o.length?o:e).map(k).filter(i),s=k(t.defaultValue),a=r.includes(s)?s:r.find((t=>/(?=.*letter)(?=.*landscape)/i.test(t)))??r.find((t=>/(?=.*a4)(?=.*landscape)/i.test(t)))??r[0];return{choiceList:r,defaultValue:a}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new A({strokeDash:[5],strokeWidth:2,strokeColor:[30,144,255,255]})),this._overlayItem}_enablePrintPreview(){if(!this.view?.overlay)return;const t=this.templateOptions,e=this._getOverlayItem();this.addHandles([u((()=>[t.width,t.height,t.scaleEnabled,t.scale,t.layout,t.layoutItem,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding]),(()=>this._updateOverLayItem()),h),this.view?.on("drag",["Shift"],(t=>this._handleDrag(t)),D.WIDGET),this.view?.on("key-down",["Escape"],(()=>this._resetDrag()),D.WIDGET)],"overlay-handler"),this.view.overlay.addItem(e)}_updateOverLayItem(){if(!this.view)return;const t=this.templateOptions,e=this._getOverlayItem(),o=t.layoutItem?.id??t.layout,i=this.view,r=i.spatialReference,[s,a]=i.state.paddedViewState.size,l=i.state.padding;let n=0,p=0;if("map-only"===o)null!=t.width&&null!=t.height&&(n=t.width,p=t.height);else if(o){const{webMapFrameSize:e,pageUnits:i}=this._layoutToTemplateInfo.get(o)??{};let l=!1;if(e&&i)if(this._isFreeHand){const t=e[0]/e[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=q.fromJSON(i.toLowerCase()),o=r.unit;d(t)===d(o)?(n=y(e[0],t,o),p=y(e[1],t,o)):(l=!0,n=e[0],p=e[1])}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const e=l?Math.min(s/n,a/p):f(r)*v*t.dpi;n*=e,p*=e}else if(0===n||0===p)n=s,p=a;else{const t=(s-.1*s)/n,e=(a-.1*a)/p,o=Math.min(t,e);n*=o,p*=o}}const{scaleEnabled:m,scale:u}=t,h=m&&u?u/this.view.scale:1;e.boxWidth=n*h||s,e.boxHeight=p*h||a,l&&(e.padding=l),e.backgroundWidth=s??0,e.backgroundHeight=a??0}_resetDrag(){this._isFreeHand=!1,this._updateOverLayItem()}_handleDrag(t){switch(t.action){case"start":this._start();break;case"update":this._update(t);break;case"end":this._end()}t.stopPropagation()}_start(){this._isFreeHand=!0}_update(t){const e=this._getOverlayItem(),{x:o,y:i}=t,{x:r,y:s}=t.origin;o>r?(e.x=r,e.boxWidth=o-r):(e.x=o,e.boxWidth=r-o),i>s?(e.y=s,e.boxHeight=i-s):(e.y=i,e.boxHeight=s-i)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,o=e.toMap(c(t.x+.5*t.boxWidth,t.y+.5*t.boxHeight));t.x=null,t.y=null,e.goTo({center:o}),this._freeHandWidth=t.boxWidth,this._freehandHeight=t.boxHeight,"map-only"===this.templateOptions.layout&&(this.templateOptions.width=this._freeHandWidth,this.templateOptions.height=this._freehandHeight),this.templateOptions.scale=this.view.scale,this._updateOverLayItem()}};t([w()],J.prototype,"_serviceTemplateCustomTextElements",void 0),t([w()],J.prototype,"_layoutToTemplateInfo",void 0),t([w()],J.prototype,"allowedFormats",void 0),t([w()],J.prototype,"allowedLayouts",void 0),t([w({type:G})],J.prototype,"browseTemplates",void 0),t([w({type:G})],J.prototype,"defaultTemplates",void 0),t([w()],J.prototype,"error",void 0),t([w()],J.prototype,"extraParameters",void 0),t([w()],J.prototype,"includeDefaultTemplates",void 0),t([w({readOnly:!0})],J.prototype,"effectivePrintServiceUrl",null),t([w()],J.prototype,"effectiveTemplateCustomTextElements",null),t([w()],J.prototype,"layoutTemplateInfo",null),t([w({type:O})],J.prototype,"portal",void 0),t([w()],J.prototype,"portalTemplateIds",void 0),t([w()],J.prototype,"showPrintAreaEnabled",void 0),t([w()],J.prototype,"printServiceUrl",void 0),t([w()],J.prototype,"printTimeout",void 0),t([w({readOnly:!0})],J.prototype,"state",null),t([w({readOnly:!0})],J.prototype,"templatesInfo",void 0),t([w()],J.prototype,"updateDelay",void 0),t([w()],J.prototype,"view",void 0),t([w()],J.prototype,"templateCustomTextElements",void 0),t([w({type:W})],J.prototype,"templateOptions",void 0),t([w()],J.prototype,"layoutTemplateNorthArrowInfo",null),J=t([T("esri.widgets.Print.PrintViewModel")],J);const Q=J;export{Q as default};
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import"../../geometry.js";import e from"../../request.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import o from"../../core/Error.js";import{JSONMap as a}from"../../core/jsonMap.js";import{clone as r}from"../../core/lang.js";import l from"../../core/Loadable.js";import{isAbortError as n}from"../../core/promiseUtils.js";import p from"../../core/ReactiveMap.js";import{watch as m,initial as h}from"../../core/reactiveUtils.js";import{createScreenPoint as u}from"../../core/screenUtils.js";import{unitType as d,convertUnit as c,getMetersPerUnitForSR as y,inchesPerMeter as f}from"../../core/unitUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as T}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as w,convertDateFormatToIntlOptions as _}from"../../intl/date.js";import{getLanguage as I}from"../../intl/locale.js";import g from"../../portal/Portal.js";import O from"../../portal/PortalQueryParams.js";import{reArcGISOnlineDomain as b}from"../../portal/support/urlUtils.js";import{execute as x,getTasks as P}from"../../rest/print.js";import{fromJSON as S}from"../../rest/support/fileFormat.js";import{fromJSON as U}from"../../rest/support/layoutTemplate.js";import j from"../../rest/support/PrintParameters.js";import k from"../../rest/support/PrintTemplate.js";import{getExtent as E}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as L}from"../../views/input/InputManager.js";import C from"../../views/overlay/BoxOverlayItem.js";import H from"./CustomTemplate.js";import D from"./TemplateOptions.js";import{fetchLayoutTemplateInfos as F}from"./utils.js";import W from"../../geometry/Extent.js";import A from"../../geometry/SpatialReference.js";const R=[30,144,255,255],M=[237,211,23,255],V=[216,48,32,255],q=new Set(["GISProfessionalStdUT","GISProfessionalAdvUT"]),z=/(\/GPServer\/).+/i,G=new a({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),B=s.ofType(H);function J(t){t.layoutOptions??={},t.layoutOptions.customTextElements??=[];const e="date";if(!t.layoutOptions.customTextElements.find((t=>e in t))){const{customTextElements:e}=t.layoutOptions;let i=w(Date.now(),_("short-date"));"ar"===I()&&(i=""+i),e.push({date:i})}}function N(t,e,i){if(!e)return;!(e.visible===i)&&t.layoutOptions&&(t.layoutOptions.elementOverrides?t.layoutOptions.elementOverrides[e.name]={visible:i}:t.layoutOptions.elementOverrides={[e.name]:{visible:i}})}let Q=class extends l{constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._templateIdToCustomTemplate=new p,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this._asyncPrintTaskUrl=null,this._layoutInfoTaskUrl=null,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new B,this.defaultTemplates=new B,this.error=null,this.extraParameters=null,this.includeDefaultTemplates=!0,this.outSpatialReference=null,this.portal=g.getDefault(),this.portalTemplateIds=[],this.printServiceTemplates=new B,this.defaultTemplate=null,this.showPrintAreaEnabled=!1,this.printServiceUrl=null,this.printTimeout=12e4,this.templatesInfo=null,this.updateDelay=1e3,this.view=null,this.templateCustomTextElements=null,this.templateOptions=new D}initialize(){this.addHandles([m((()=>this.showPrintAreaEnabled),(t=>{t?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))})),m((()=>[this.templateOptions.layout,this.templateOptions.layoutItem]),(()=>{this.loaded&&this._processTemplateOptions()}))])}destroy(){this.removeHandles("overlay-handler"),this.view&&(this._overlayItem&&(this.view.overlay?.removeItem(this._overlayItem),this._overlayItem.destroy(),this._overlayItem=null),this.view=null)}get effectivePrintServiceUrl(){return this.printServiceUrl??null}get effectiveTemplateCustomTextElements(){if(!this._serviceTemplateCustomTextElements)return{};const t=r(this._serviceTemplateCustomTextElements);return this.templateCustomTextElements&&Object.keys(this.templateCustomTextElements).forEach((e=>{const i=t[e];if(i){const t=this.templateCustomTextElements?.[e];i.forEach((e=>{const[i]=Object.entries(e)[0];t?.forEach((t=>{const[s,o]=Object.entries(t)[0];i===s&&(e[i]=o)}))}))}})),Object.freeze(t)}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}async load(t){return this.addResolvingPromise(this._loadResources(t).catch((t=>this.error=t))),this}async print(t){const{view:e,extraParameters:i,updateDelay:s,outSpatialReference:a}=this;if(!e)throw new o("print:view-required","view is not set");J(t);const r=this._getOverlayItem(),l=t.scalePreserved||!this.showPrintAreaEnabled?void 0:E(new W,e.viewpoint,"map-only"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[r.boxWidth,r.boxHeight]),n=new j({view:e,template:t,extent:l,extraParameters:i,updateDelay:s,outSpatialReference:a});try{const e=!!t.layoutItem?.id&&(this.portalTemplateIds.includes(t.layoutItem.id)||this.browseTemplates.some((e=>e.layoutItem?.id===t.layoutItem?.id)));return await x(e&&this._asyncPrintTaskUrl?this._asyncPrintTaskUrl:this.effectivePrintServiceUrl,n,{timeout:this.printTimeout})}catch(p){throw new o("print:export-error","An error occurred while exporting the web map.",{error:p})}}toPrintTemplate({attributionEnabled:t,author:e,copyright:i,customTextElements:s,dpi:a,forceFeatureAttributes:r,format:l,height:n,id:p,includeTables:m,layout:h,layoutItem:u,legendEnabled:d,northArrowEnabled:c,scale:y,scaleEnabled:f,title:v,width:T}){if(!h&&!u)throw new o("print:layout-required","layout is not set");const w=new k({attributionVisible:t,forceFeatureAttributes:r,format:l,includeTables:m,layout:h,layoutItem:u,layoutOptions:{authorText:e||"",copyrightText:i||"",customTextElements:s,titleText:v||""},outScale:y??0,scalePreserved:f});if(T&&(w.exportOptions.width=T),n&&(w.exportOptions.height=n),a&&(w.exportOptions.dpi=a),w.layoutOptions){d||(w.layoutOptions.legendLayers=[]);const t=this.getLayoutTemplateById(p)?.mapSurroundInfoOptions;if(t){N(w,t.northArrow[0],c);const e=t.scaleBar;for(const t of e)N(w,t,f)}}return w}getLayoutTemplateById(t){return t?this._templateIdToCustomTemplate.get(t):null}async addPortalTemplate(t){if(!this.portal||!t?.id||this._templateIdToCustomTemplate.has(t.id))return;const e=new H({type:"browse-template",layoutInfoTaskUrl:this._layoutInfoTaskUrl,label:t.title,layoutItem:t});this._templateIdToCustomTemplate.set(e.id,e),this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem&&this.templateOptions.id===t.layoutItem.id&&(this.defaultTemplate?this.applyTemplate(this.defaultTemplate):this.templateOptions.reset()),this.browseTemplates.remove(t),this._templateIdToCustomTemplate.delete(t.id)}async applyTemplate(t){if(!t)return void this.templateOptions.reset();!t.layout||!this.templatesInfo||this.templatesInfo.layout.choiceList.includes(t.layout)||(this.defaultTemplate?t=this.defaultTemplate:this.templateOptions.reset());const e=t.layout?this.effectiveTemplateCustomTextElements[t.layout]:null;await this.templateOptions.applyTemplate(t,e)}async _loadResources(t){if(this.destroyed)return;await this._loadUrls(t);const[e,i]=await Promise.all([this._getLayoutToLayoutTemplateInfos(t),this._getPrintServiceTemplatesInfo(t)]);await this._loadAllTemplates(e,t),this._processPrintServiceTemplatesInfo(i),await this._processTemplateOptions(),this._updateOverLayItem()}async _processTemplateOptions(){const{layout:t,layoutItem:e}=this.templateOptions;if("map-only"!==t&&!this.templateOptions.id)if(e?.id){let t=this._templateIdToCustomTemplate.get(e.id);t||(t=new H({label:e.title,layoutItem:e,layoutInfoTaskUrl:this._layoutInfoTaskUrl}),this._templateIdToCustomTemplate.set(t.id,t)),await this.applyTemplate(t)}else if(t){const t=this.defaultTemplates.find((t=>t.layout===this.templateOptions.layout))??this.printServiceTemplates.find((t=>t.layout===this.templateOptions.layout));await this.applyTemplate(t??this.defaultTemplate)}}async _loadPortal(t){try{await this.portal.load(t)}catch(e){throw new o("print:could-not-load-portal","Cannot load print resource information from portal",{error:e,url:this.effectivePrintServiceUrl})}}async _loadUrls(t){if(this.printServiceUrl)this._set("effectivePrintServiceUrl",this.printServiceUrl),await this._updateLayoutInfoTaskUrl(this.effectivePrintServiceUrl);else{await this._loadPortal(t);const{printTask:e,asyncPrintTask:i,layoutInfoTask:s}=this.portal?.helperServices??{};this._set("effectivePrintServiceUrl",e?.url),this._asyncPrintTaskUrl=i?.url,await this._updateLayoutInfoTaskUrl(s?.url||this.effectivePrintServiceUrl)}const e=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!e?.includes("gpserver"))throw new o("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl})}async _updateLayoutInfoTaskUrl(t,e){if(!t)return;const i=(await P(t,e)).find((t=>t.includes("Get Layout Templates Info")));i&&(this._layoutInfoTaskUrl=t.replace(z,`$1${encodeURI(i)}`))}_getPortalDefaultTemplates(t){return this.portal?.helperServices?.printTask?.templates?.map((e=>{const i=H.fromJSON(e);if(i.type="default-template",i.layoutInfoTaskUrl=this._layoutInfoTaskUrl,i.layout){const e=t.get(i.layout);e&&i.setLayoutTemplateInfo(e)}return i}))??[]}async _getPortalCustomTemplates(t){if(this.printServiceUrl||!this.portal)return[];const{layoutGroupQuery:e,user:i}=this.portal,s=b.test(this.portal.url),o=i?.userLicenseTypeId,a=o&&q.has(o);if(!e||s&&!a)return[];const r=new O({query:e,disableExtraQuery:!0}),l=await this.portal.queryGroups(r,t);if(!l.total)return[];const n=l.results[0],p=new O({num:100,query:"type:Layout",sortField:n.sortField,sortOrder:n.sortOrder??void 0}),m=(await n.queryItems(p,t)).results;if(!m.length)return[];return m.map((t=>(this.portalTemplateIds.push(t.id),new H({type:"default-template",label:t.title,layoutItem:t,layoutInfoTaskUrl:this._layoutInfoTaskUrl}))))}async _loadAllTemplates(t,e){if(this.includeDefaultTemplates&&this.portal&&!this.printServiceUrl){const i=this._getPortalDefaultTemplates(t);this.defaultTemplates.addMany(i);const s=await this._getPortalCustomTemplates(e);this.defaultTemplates.addMany(s);for(const t of this.defaultTemplates)this._templateIdToCustomTemplate.set(t.id,t)}this.defaultTemplates.length||t.forEach(((t,e)=>{const i=new H({type:"print-service-template",layout:e,layoutInfoTaskUrl:this._layoutInfoTaskUrl});i.setLayoutTemplateInfo(t),this.printServiceTemplates.add(i),this._templateIdToCustomTemplate.set(i.id,i)}))}_processPrintServiceTemplatesInfo(t){this._set("templatesInfo",t);const e=t?.layout?.defaultValue;e&&"map-only"!==e&&this._set("defaultTemplate",this.defaultTemplates.find((t=>t.layout===e))??this.printServiceTemplates.find((t=>t.layout===e)))}async _getLayoutToLayoutTemplateInfos(t){const e=await F(this._layoutInfoTaskUrl,void 0,t),i=new Map,s={};for(const o of e){const t=U(o.layoutTemplate);i.set(t,o),s[t]=o.layoutOptions.customTextElements}return this._serviceTemplateCustomTextElements=Object.freeze(s),i}async _getPrintServiceTemplatesInfo(t){let i;try{({data:i}=await e(this.effectivePrintServiceUrl,{...t,query:{f:"json"},timeout:this.printTimeout}))}catch(l){throw n(l)?l:new o("print:unavailable-service-info","Can't fetch templates info from service",{error:l})}const{parameters:s}=i,a=s.find((({name:t})=>"Format"===t)),r=s.find((({name:t})=>"Layout_Template"===t));return{format:this._getFormat(a),layout:this._getLayout(r)}}_getFormat(t){const e="all"===this.allowedFormats?t.choiceList:t.choiceList.filter((t=>this.allowedFormats.includes(S(t)))),s=(e.length?e:t.choiceList).map(S).filter(i),o=S(t.defaultValue),a=s.includes(o)?o:s[0];return{choiceList:s,defaultValue:a}}_getLayout(t){const e=t.choiceList.filter((t=>"map_only"!==t.toLowerCase())),s="all"===this.allowedLayouts?e:e.filter((t=>this.allowedLayouts.includes(U(t)))),o=(s.length?s:e).map(U).filter(i),a=U(t.defaultValue),r=o.includes(a)?a:o.find((t=>/(?=.*letter)(?=.*landscape)/i.test(t)))??o.find((t=>/(?=.*a4)(?=.*landscape)/i.test(t)))??o[0];return{choiceList:o,defaultValue:r}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new C({strokeDash:[5],strokeWidth:2,strokeColor:[30,144,255,255]})),this._overlayItem}_enablePrintPreview(){if(!this.view?.overlay)return;const t=this.templateOptions,e=this._getOverlayItem();this.addHandles([m((()=>[t.width,t.height,t.scaleEnabled,t.scale,t.layout,t.layoutItem,t.id,t.state,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding,this.loaded]),(()=>this._updateOverLayItem()),h),this.view?.on("drag",["Shift"],(t=>this._handleDrag(t)),L.WIDGET),this.view?.on("key-down",["Escape"],(()=>this._resetDrag()),L.WIDGET)],"overlay-handler"),this.view.overlay.addItem(e)}_updateOverLayItem(){if(!this.view)return;const t=this.templateOptions,e=this._getOverlayItem(),i=t.layoutItem?.id??t.layout,s=this.view,o=s.spatialReference,[a,r]=s.state.paddedViewState.size,l=s.state.padding;let n=0,p=0;if("map-only"===i)null!=t.width&&null!=t.height&&(n=t.width,p=t.height);else if(i){const e=t.id?this._templateIdToCustomTemplate.get(t.id):null,{webMapFrameSize:i,pageUnits:s}=e?.layoutTemplateInfo??{};let l=!1;if(i&&s)if(this._isFreeHand){const t=i[0]/i[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=G.fromJSON(s.toLowerCase()),e=o.unit;d(t)===d(e)?(n=c(i[0],t,e),p=c(i[1],t,e)):(l=!0,n=i[0],p=i[1])}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const e=l?Math.min(a/n,r/p):y(o)*f*t.dpi;n*=e,p*=e}else if(0===n||0===p)n=a,p=r;else{const t=(a-.1*a)/n,e=(r-.1*r)/p,i=Math.min(t,e);n*=i,p*=i}}const{scaleEnabled:m,scale:h}=t,u=m&&h?h/this.view.scale:1;if(e.boxWidth=n*u||a,e.boxHeight=p*u||r,l&&(e.padding=l),e.backgroundWidth=a??0,e.backgroundHeight=r??0,"loading"===this.loadStatus)e.strokeColor=M;else if("loaded"===this.loadStatus)switch(this.templateOptions.state){case"pending":e.strokeColor=M;break;case"ready":e.strokeColor=R;break;case"error":e.strokeColor=V}}_resetDrag(){this._isFreeHand=!1,this._updateOverLayItem()}_handleDrag(t){switch(t.action){case"start":this._start();break;case"update":this._update(t);break;case"end":this._end()}t.stopPropagation()}_start(){this._isFreeHand=!0}_update(t){const e=this._getOverlayItem(),{x:i,y:s}=t,{x:o,y:a}=t.origin;i>o?(e.x=o,e.boxWidth=i-o):(e.x=i,e.boxWidth=o-i),s>a?(e.y=a,e.boxHeight=s-a):(e.y=s,e.boxHeight=a-s)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,i=e.toMap(u(t.x+.5*t.boxWidth,t.y+.5*t.boxHeight));t.x=null,t.y=null,e.goTo({center:i}),this._freeHandWidth=t.boxWidth,this._freehandHeight=t.boxHeight,"map-only"===this.templateOptions.layout&&(this.templateOptions.width=this._freeHandWidth,this.templateOptions.height=this._freehandHeight),this.templateOptions.scale=this.view.scale,this._updateOverLayItem()}};t([v()],Q.prototype,"_serviceTemplateCustomTextElements",void 0),t([v()],Q.prototype,"_templateIdToCustomTemplate",void 0),t([v()],Q.prototype,"allowedFormats",void 0),t([v()],Q.prototype,"allowedLayouts",void 0),t([v({type:B})],Q.prototype,"browseTemplates",void 0),t([v({type:B})],Q.prototype,"defaultTemplates",void 0),t([v()],Q.prototype,"error",void 0),t([v()],Q.prototype,"extraParameters",void 0),t([v()],Q.prototype,"includeDefaultTemplates",void 0),t([v({readOnly:!0})],Q.prototype,"effectivePrintServiceUrl",null),t([v()],Q.prototype,"effectiveTemplateCustomTextElements",null),t([v({type:A})],Q.prototype,"outSpatialReference",void 0),t([v({type:g})],Q.prototype,"portal",void 0),t([v()],Q.prototype,"portalTemplateIds",void 0),t([v({type:B})],Q.prototype,"printServiceTemplates",void 0),t([v({readOnly:!0})],Q.prototype,"defaultTemplate",void 0),t([v()],Q.prototype,"showPrintAreaEnabled",void 0),t([v()],Q.prototype,"printServiceUrl",void 0),t([v()],Q.prototype,"printTimeout",void 0),t([v({readOnly:!0})],Q.prototype,"state",null),t([v({readOnly:!0})],Q.prototype,"templatesInfo",void 0),t([v()],Q.prototype,"updateDelay",void 0),t([v()],Q.prototype,"view",void 0),t([v()],Q.prototype,"templateCustomTextElements",void 0),t([v({type:D})],Q.prototype,"templateOptions",void 0),Q=t([T("esri.widgets.Print.PrintViewModel")],Q);const $=Q;export{$ 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.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import o from"../../core/Accessor.js";import{
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import o from"../../core/Accessor.js";import{clone as e}from"../../core/lang.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import l from"../../portal/PortalItem.js";let i=class extends o{constructor(t){super(t),this._abortController=null,this.attributionEnabled=!0,this.author=null,this.copyright=null,this.customTextElements=null,this.dpi=96,this.fileName=null,this.forceFeatureAttributes=!1,this.format="pdf",this.height=null,this.includeTables=!0,this.id=null,this.state="ready",this.layout="letter-ansi-a-landscape",this.layoutItem=null,this.legendEnabled=!0,this.northArrowEnabled=!1,this.scale=null,this.scaleBarEnabled=!1,this.scaleEnabled=!1,this.title=null,this.width=null}async applyTemplate(t,o){if((t?.id!==this.id||"error"===t?.state)&&(this._abortController&&(this._abortController.abort(),this._abortController=null),t)){if(this._set("state","pending"),this._resetMapSurroundInfoOptions(),this._set("id",t.id),this.set({layout:t.layout,layoutItem:t.layoutItem}),!t.layoutOptions&&t.layoutItem){const o=new AbortController;if(this._abortController=o,await t.fetchLayoutItemTemplateInfo({signal:this._abortController.signal}),"loaded"!==t.state){if("error"===t.state&&this._set("state","error"),this._abortController!==o)return;return void(this._abortController=null)}this._abortController=null}this.set({customTextElements:o?e(o):this.customTextElements,format:this.format??t.format,legendEnabled:t.layoutOptions?.legend??this.legendEnabled,northArrowEnabled:t.layoutOptions?.northArrow??this.northArrowEnabled,scaleBarEnabled:t.layoutOptions?.scaleBar??this.scaleBarEnabled}),this._set("state","ready")}}reset(){this._set("id",null),this._set("state","ready"),this.set({layout:null,layoutItem:null,customTextElements:null}),this._resetMapSurroundInfoOptions()}_resetMapSurroundInfoOptions(){this.set({legendEnabled:!0,northArrowEnabled:!1,scaleBarEnabled:!1})}};t([r()],i.prototype,"attributionEnabled",void 0),t([r()],i.prototype,"author",void 0),t([r()],i.prototype,"copyright",void 0),t([r()],i.prototype,"customTextElements",void 0),t([r()],i.prototype,"dpi",void 0),t([r()],i.prototype,"fileName",void 0),t([r()],i.prototype,"forceFeatureAttributes",void 0),t([r()],i.prototype,"format",void 0),t([r()],i.prototype,"height",void 0),t([r()],i.prototype,"includeTables",void 0),t([r({readOnly:!0})],i.prototype,"id",void 0),t([r({readOnly:!0})],i.prototype,"state",void 0),t([r()],i.prototype,"layout",void 0),t([r({type:l})],i.prototype,"layoutItem",void 0),t([r()],i.prototype,"legendEnabled",void 0),t([r()],i.prototype,"northArrowEnabled",void 0),t([r()],i.prototype,"scale",void 0),t([r()],i.prototype,"scaleBarEnabled",void 0),t([r()],i.prototype,"scaleEnabled",void 0),t([r()],i.prototype,"title",void 0),t([r()],i.prototype,"width",void 0),i=t([s("esri.widgets.Print.TemplateOptions")],i);const a=i;export{a as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import t from"../../core/Error.js";import{getMode as o}from"../../rest/print.js";import{execute as r}from"../../rest/geoprocessor/execute.js";import{submitJob as e}from"../../rest/geoprocessor/submitJob.js";async function a(a,i,s){if(!a)throw new t("print:invalid-layout-info-task-url","Can't fetch layout template info",{url:a});if("async"===await o(a)){const t=await e(a,i,void 0,s||void 0);await t.waitForJobCompletion();return(await t.fetchResultData("Output_JSON")).value}return(await r(a,i,null,s)).results[0].value}export{a as fetchLayoutTemplateInfos};
|
package/widgets/Print.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.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{JSONMap as l}from"../core/jsonMap.js";import{clone as i}from"../core/lang.js";import{watch as a}from"../core/reactiveUtils.js";import{unitName as o}from"../core/unitFormatUtils.js";import{addProxy as n,hasSameOrigin as s}from"../core/urlUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{reArcGISOnlineDomain as p}from"../portal/support/urlUtils.js";import{getToken as d}from"../rest/utils.js";import{toJSON as u}from"../rest/support/fileFormat.js";import m from"./Widget.js";import h from"./Print/FileLink.js";import b from"./Print/PrintViewModel.js";import{loadCalciteComponents as y}from"./support/componentsUtils.js";import{globalCss as _}from"./support/globalCss.js";import{Heading as f}from"./support/Heading.js";import{legacyIcon as g}from"./support/legacyIcon.js";import{isRTL as v,isActivationKey as w}from"./support/widgetUtils.js";import{messageBundle as T}from"./support/decorators/messageBundle.js";import{tsx as I}from"./support/jsxFactory.js";import{formatNumber as x}from"../intl/number.js";const C=t.ofType(h),O="map-only";var k;!function(e){e.layout="layoutTab",e.mapOnly="mapOnlyTab",e.export="exportTab"}(k||(k={}));const L="esri-print",$=`${L}__advanced-options-button`,S={base:L,headerTitle:`${L}__header-title`,layoutTabList:`${L}__layout-tab-list`,layoutTab:`${L}__layout-tab`,layoutSection:`${L}__layout-section`,mapOnlySection:`${L}__map-only-section`,panelItemsCentered:`${L}__panel-items--centered`,loader:`${L}__loader`,advancedOptionsButton:$,advancedOptionsButtonContainer:`${$}-container`,advancedOptionsButtonTitle:`${$}-title`,advancedOptionsButtonIconOpened:`${$}-icon--opened`,advancedOptionsButtonIconClosed:`${$}-icon--closed`,advancedOptionsButtonIconClosed_RTL:`${$}-icon--closed-rtl`,swapButton:`${L}__swap-button`,printButton:`${L}__export-button`,templateSelectContainer:`${L}__template-select-container`,templateSelectBlock:`${L}__template-select-block`,templateSelectIcon:`${L}__template-select-icon`,formSectionContainer:`${L}__form-section-container`,formCheckboxLabel:`${L}__form-checkbox-label`,advancedOptionsSection:`${L}__advanced-options-section`,advancedOptionsContainer:`${L}__advanced-options-container`,browseTemplateButtonContainer:`${L}__browse-template-button-container`,exportedFilesContainer:`${L}__export-panel-container`,exportedFilesTitle:`${L}__export-title`,exportedFile:`${L}__exported-file`,exportedFileLink:`${L}__exported-file-link`,exportedFileLinkTitle:`${L}__exported-file-link-title`,exportedFilesEmpty:`${L}__exported-files-empty`,printWidgetContainer:`${L}__container`,content:`${L}__content`,panelContainer:`${L}__panel-container`,scaleInfoContainer:`${L}__scale-info-container`,scaleInputContainer:`${L}__scale-input-container`,scaleInput:`${L}__scale-input`,sizeContainer:`${L}__size-container`,panelError:`${L}__panel--error`,exportedFileError:`${L}__exported-file--error`,exportedFileLoader:`${L}__exported-file--loader`,exportSection:`${L}__export-section`,exportSectionCentered:`${L}__export-section--centered`,templateButtonContainer:`${L}__template-button-container`,templateDoneButton:`${L}__template-done-button`,templateSelectFlowItemContainer:`${L}__template-select-flow-item-container`,templateSelectFlowItemContent:`${L}__template-select-flow-item-content`,templateSelectFlowItemListHeading:`${L}__template-select-flow-item-list-heading`};function M(e,t,l,i){const a=l/t,o=i/t;return{width:Math.round(e*a),height:Math.round(e*o)}}function E(e){return!isNaN(e)&&e>0}function F(e){return e?.toLowerCase()===O}function j(e){const{state:t,extension:l}=e;switch(t){case"pending":return"spinner";case"error":return"exclamation-mark-circle";default:return l?.toLowerCase()?.includes("pdf")?"file-pdf":"file"}}function P(e,t){return!!t&&e.some((e=>e.layoutItem?.id===t||e.layout===t))}const A=new l({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"});let B=class extends m{constructor(e,t){super(e,t),this._activeTabFocusRequested=!1,this._awaitingServerResponse=!1,this._exportedFileNameMap={},this._selectedTab=k.layout,this._pendingExportScroll=!1,this._rootNode=null,this._selectedLayout=null,this._selectedLayoutItem=null,this._abortController=null,this._fetchingLayoutItemId=null,this._showTemplates=!1,this.browseTemplateButtonOnClick=null,this.exportedLinks=new C,this.headerVisible=!0,this.headingLevel=3,this.messagesCommon=null,this.messagesUnits=null,this.viewModel=new b,this._onInput=e=>{this._selectedTab===k.layout?this.templateOptions.title=e.target.value:this._selectedTab===k.mapOnly&&(this.templateOptions.fileName=e.target.value)},this._removeLink=e=>{const t=e.currentTarget["data-item"];t&&this.exportedLinks.remove(t)},this._handleLinkClick=e=>{const t=e.currentTarget["data-item"];if(!t||"ready"!==t.state||!t.url)return;const l=d(this.viewModel.effectivePrintServiceUrl),i=t.url,a=document.createElement("a");if(a.target="_blank",a.href=i,a.rel="noreferrer",a.download=t.formattedName??"",!l)return a.click(),void e.stopPropagation();e.preventDefault();const o=new URL(i);o.searchParams.set("token",l),a.href=o.href,a.click(),a.href=i},this._focusOnTabChange=this._focusOnTabChange.bind(this)}initialize(){this.addHandles([a((()=>[this.templateOptions.format,this.viewModel.templatesInfo?.format.defaultValue]),(([e,t])=>{if(t&&!e)return void(this.templateOptions.format=t);if(!e||!t||!this.viewModel.templatesInfo)return;if(this.viewModel.templatesInfo.format.choiceList.includes(e))return;const l=this.viewModel.templatesInfo.format.choiceList.find((t=>t.toUpperCase().includes(`(${e.toUpperCase()})`)));this.templateOptions.format=l??t})),a((()=>[this.templateOptions.layout,this.templateOptions.layoutItem,this._fetchingLayoutItemId,this.viewModel.templatesInfo?.layout.defaultValue]),(async()=>{const{layout:e,layoutItem:t}=this.templateOptions,l=this.viewModel.templatesInfo?.layout?.defaultValue;if(this._selectedTab=F(e)?k.mapOnly:k.layout,this._selectedTab!==k.layout)return;const{includeDefaultTemplates:a,viewModel:o}=this,{portalTemplateIds:n,browseTemplates:s,templatesInfo:r}=o,c=o.defaultTemplates.filter((({layoutItem:e})=>n.includes(e?.id))),p=o.defaultTemplates.filter((({layoutItem:e})=>!n.includes(e?.id))),d=a&&p.length;if(e||t){const l=!!e&&(d?P(p,e):r?.layout.choiceList.includes(e)),i=t?.id,a=!!i&&(P(c,i)||P(s,i));l||a||(this.templateOptions.layout=null,this.templateOptions.layoutItem=null)}else{const{_selectedLayout:e,_selectedLayoutItem:t}=this,i=!!e&&(d?P(p,e):r?.layout.choiceList.includes(e)),a=t?.id,o=!!a&&(P(c,a)||P(s,a));i||o?await this._applyTemplate(e??a):(this.templateOptions.layout=null,this.templateOptions.layoutItem=null),this.templateOptions.layout||this.templateOptions.layoutItem||d||!l||await this._applyTemplate(l)}this._selectedLayout=this.templateOptions.layout,this._selectedLayoutItem=this.templateOptions.layoutItem;const u=!!this.templateOptions.layout&&this.viewModel.effectiveTemplateCustomTextElements[this.templateOptions.layout];this.templateOptions.customTextElements=u?i(u):null})),a((()=>this.templateOptions.dpi),(e=>{e<=0&&(this.templateOptions.dpi=1)})),a((()=>this.viewModel.view?.scale),(e=>{!e||this.templateOptions.scaleEnabled&&this.templateOptions.scale||(this.templateOptions.scale=e)}))]);const{height:e,width:t}=this.templateOptions;this.templateOptions.width=t||800,this.templateOptions.height=e||1100;const l=setTimeout((()=>{this._awaitingServerResponse=!0,this.scheduleRender()}),500);this.viewModel.load().then((()=>{clearTimeout(l),this._awaitingServerResponse=!1}))}loadDependencies(){return y({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip.js")})}destroy(){this.viewModel.destroy()}get allowedFormats(){return this.viewModel.allowedFormats}set allowedFormats(e){this.viewModel.allowedFormats=e}get allowedLayouts(){return this.viewModel.allowedLayouts}set allowedLayouts(e){this.viewModel.allowedLayouts=e}get error(){return this.viewModel.error}get extraParameters(){return this.viewModel.extraParameters}set extraParameters(e){this.viewModel.extraParameters=e}get icon(){return"print"}set icon(e){this._overrideIfSome("icon",e)}get includeDefaultTemplates(){return this.viewModel.includeDefaultTemplates}set includeDefaultTemplates(e){this.viewModel.includeDefaultTemplates=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get portal(){return this.viewModel.portal}set portal(e){this.viewModel.portal=e}get showPrintAreaEnabled(){return this.viewModel.showPrintAreaEnabled}set showPrintAreaEnabled(e){this.viewModel.showPrintAreaEnabled=e}get printServiceUrl(){return this.viewModel.printServiceUrl}set printServiceUrl(e){this.viewModel.printServiceUrl=e}get templateCustomTextElements(){return this.viewModel.templateCustomTextElements}set templateCustomTextElements(e){this.viewModel.templateCustomTextElements=e}get templateOptions(){return this.viewModel.templateOptions}set templateOptions(e){this.viewModel.templateOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){const{messages:e,templateOptions:t,viewModel:l,view:i}=this,{attributionEnabled:a,author:o,copyright:n,dpi:s,format:r,height:c,layout:p,layoutItem:d,legendEnabled:m,northArrowEnabled:h,scaleEnabled:b,scale:y,width:w}=t,T="ready"!==l.state||this._awaitingServerResponse||!(p||d),x=this._renderTitleOrFileNameSection(),C=I("div",{class:S.formSectionContainer},I("calcite-label",null,e.fileFormatTitle,I("calcite-combobox",{clearDisabled:!0,label:e.formatDefaultOption,maxItems:6,placeholder:e.formatDefaultOption,selectionMode:"single-persist",onCalciteComboboxChange:({target:e})=>{this.templateOptions.format=e.selectedItems[0]?.value??"pdf"}},l.templatesInfo?.format?.choiceList.sort().map(((e,t)=>I("calcite-combobox-item",{key:`file-format-${t}`,selected:e===this.templateOptions.format,textLabel:u(e),value:e})))))),O=I("calcite-label",{layout:"inline"},I("calcite-switch",{checked:this.showPrintAreaEnabled,onCalciteSwitchChange:e=>{this.showPrintAreaEnabled=!!e.target.checked}}),e.printPreview),L=I("div",null,I("div",{class:S.formSectionContainer},I("calcite-label",null,e.template,I("div",{class:S.templateSelectContainer,onclick:()=>{this._showTemplates=!0}},I("calcite-block",{class:S.templateSelectBlock,description:this._getPageSizeLabel(p??d?.id),heading:this._getTemplateLabel()}),I("calcite-icon",{class:S.templateSelectIcon,icon:v()?"chevron-left":"chevron-right",scale:"s"})))),O),$=I("div",{class:S.formSectionContainer},I("calcite-label",null,e.dpi,I("calcite-input",{bind:this,"data-input-name":"dpi",min:1,tabIndex:0,type:"number",value:`${s}`,onCalciteInputInput:this._handleDPIChange}))),M=I("div",{class:this.classes(S.scaleInfoContainer,S.formSectionContainer)},I("calcite-label",{layout:"inline"},I("calcite-checkbox",{bind:this,checked:b,"data-option-name":"scaleEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.scale),I("div",{class:S.scaleInputContainer},I("calcite-input",{"aria-label":e.scaleLabel,"aria-valuenow":`${y}`,bind:this,class:S.scaleInput,"data-input-name":"scale",disabled:!b,tabIndex:0,type:"number",value:`${y}`,onCalciteInputInput:this._updateInputValue}),I("calcite-button",{appearance:"outline","aria-label":e.reset,bind:this,disabled:!b,iconStart:"refresh",kind:"neutral",onclick:this._resetToCurrentScale,tabIndex:0}))),E=I("div",{"aria-labelledby":`${this.id}__advancedOptionsForLayout`,class:S.advancedOptionsContainer,key:"advanced-section-for-layout"},M,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasAuthorText??1?I("div",{class:S.formSectionContainer,key:"author-info"},I("calcite-label",null,e.author,I("calcite-input",{bind:this,"data-input-name":"author",tabIndex:0,value:o??"",onCalciteInputInput:this._updateInputValue}))):null,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasCopyrightText??1?I("div",{class:S.formSectionContainer,key:"copyright-text"},I("calcite-label",null,e.copyright,I("calcite-input",{bind:this,"data-input-name":"copyright",tabIndex:0,value:n??"",onCalciteInputInput:this._updateInputValue}))):null,$,this._renderCustomTextElementSection(),this.viewModel.layoutTemplateInfo?.layoutOptions?.hasLegend??1?I("div",{class:S.formSectionContainer,key:"legend-info"},I("calcite-label",{layout:"inline"},I("calcite-checkbox",{bind:this,checked:m,"data-option-name":"legendEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.legend)):null,this.viewModel.layoutTemplateNorthArrowInfo?I("div",{class:S.formSectionContainer,key:"north-arrow"},I("calcite-label",{layout:"inline"},I("calcite-checkbox",{bind:this,checked:h,"data-option-name":"northArrowEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.northArrow)):null),F=I("div",{"aria-labelledby":`${this.id}__advancedOptionsForMapOnly`,class:S.advancedOptionsContainer},M,$,I("div",{class:S.formSectionContainer},I("calcite-label",{layout:"inline"},I("calcite-checkbox",{bind:this,checked:a,"data-option-name":"attributionEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.attribution)),this._renderCustomTextElementSection()),j=this.exportedLinks.toArray(),P=this._renderExportedLink(j),A={[S.exportSectionCentered]:!j.length},B=this._selectedTab===k.layout?I("section",{"aria-labelledby":`${this.id}__layoutTab`,class:S.layoutSection,id:`${this.id}__layoutContent`,key:"esri-print__layoutContent",role:"tabpanel"},I("div",{class:S.panelContainer},this.viewModel.layoutTemplateInfo?.layoutOptions?.hasTitleText??1?x:null,L,this._selectedTab===k.layout?C:null,I("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(S.panelContainer,S.advancedOptionsSection),collapsible:!0,disabled:!(p||d?.id),heading:e.advancedOptions,id:"advancedOptionsForLayout",key:"advanced-options-for-layout"},E))):this._selectedTab===k.mapOnly?I("section",{"aria-labelledby":`${this.id}__mapOnlyTab`,class:S.mapOnlySection,id:`${this.id}__mapOnlyContent`,key:"esri-print__mapOnlyContent",role:"tabpanel"},I("div",{class:S.panelContainer},x,C,I("div",null,I("div",{class:this.classes(S.sizeContainer,S.formSectionContainer)},I("calcite-label",null,e.width,I("calcite-input",{bind:this,"data-input-name":"width",tabIndex:0,type:"number",value:`${w}`,onCalciteInputInput:this._updateInputValue})),I("calcite-label",null,e.height,I("calcite-input",{bind:this,"data-input-name":"height",tabIndex:0,type:"number",value:`${c}`,onCalciteInputInput:this._updateInputValue})),I("button",{"aria-label":e.swap,bind:this,class:this.classes(_.widgetButton,S.swapButton,g.swap),onclick:this._switchInput,tabIndex:0,type:"button"})),O),I("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(S.panelContainer,S.advancedOptionsSection),collapsible:!0,heading:e.advancedOptions,id:"advancedOptionsForMapOnly",key:"advanced-options-for-map-only"},F))):I("section",{"aria-labelledby":`${this.id}__exportTab`,class:this.classes(S.exportSection,A),id:`${this.id}__exportContent`,key:"esri-print__exportContent",role:"tabpanel"},I("div",{class:S.panelContainer},I("div",{afterUpdate:this._scrollExportIntoView,bind:this,class:S.exportedFilesContainer},0===j.length?I("div",{class:S.exportedFilesEmpty},I("calcite-icon",{icon:"file",scale:"l"}),I("div",null,I(f,{class:S.exportedFilesTitle,level:this.headingLevel},e.noExportedFiles),I("div",null,e.exportHint))):P))),V={[_.buttonDisabled]:T||!(p||d?.id)&&!r},D=!i||"2d"!==i.type,U=I("div",{class:S.panelError},D?e.sceneViewError:e.serviceError),N=j.some((({state:e})=>"pending"===e)),R=I("div",{class:S.content,key:"panel"},I("div",null,I("ul",{bind:this,class:S.layoutTabList,onclick:this._toggleLayoutPanel,onkeydown:this._handleLayoutPanelKeyDown,role:"tablist"},I("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===k.layout}`,class:S.layoutTab,"data-tab-id":k.layout,id:`${this.id}__layoutTab`,role:"tab",tabIndex:0},e.layoutTab),I("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===k.mapOnly}`,class:S.layoutTab,"data-tab-id":k.mapOnly,id:`${this.id}__mapOnlyTab`,role:"tab",tabIndex:0},e.mapOnlyTab),I("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===k.export}`,class:S.layoutTab,"data-tab-id":k.export,id:`${this.id}__exportedFilesTab`,role:"tab",tabIndex:0},N?I("calcite-loader",{inline:!0,label:"loading",scale:"s"}):null,e.exportsTab)),B),this._selectedTab!==k.export?I("button",{"aria-label":e.exportDescription,bind:this,class:this.classes(S.printButton,_.button,V),disabled:T,onclick:this._handlePrintMap,tabIndex:0,type:"button"},e.export):null),z=I("calcite-flow",{key:"root-flow"},I("calcite-flow-item",{bind:this,key:"root-flow-item"},I("div",{class:S.printWidgetContainer},this.headerVisible?I("header",{class:S.headerTitle},e.export):null,this.error||D||!i?U:R)),this._renderChooseTemplateFlowItem()),H="initializing"===l.state,W=H?this._renderLoader():z,q={[S.panelItemsCentered]:H};return I("div",{bind:this,class:this.classes(S.base,_.widget,_.panel,q)},W)}_getPageSizeLabel(e){if(!e)return;const t=this.viewModel.getLayoutTemplateInfo(e);if(!t)return;const l=A.fromJSON(t.pageUnits.toLowerCase());return`${x(t.pageSize[0])} x ${x(t.pageSize[1])} ${o(this.messagesUnits,l,"abbr")}`}_getTemplateLabel(){const{messages:e,includeDefaultTemplates:t,templateOptions:l,viewModel:i}=this,{layout:a,layoutItem:o}=l,n=o?.id,s=(t?i.defaultTemplates.find((({layoutItem:e,layout:t})=>a?a===t:n===e?.id)):null)??i.browseTemplates.find((({layoutItem:e})=>n===e?.id));return s?.label?.replaceAll("_"," ")??e[a]??a?.replaceAll("_"," ")??n?.replaceAll("_"," ")??e.selectTemplate}_renderChooseTemplateFlowItem(){if(!this._showTemplates)return null;const{includeDefaultTemplates:e,messages:t,viewModel:l}=this,{defaultTemplates:i,templatesInfo:a,browseTemplates:o,portalTemplateIds:n}=l,s=p.test(this.portal?.url),r=o.length?o.toArray().sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)).map(((e,i)=>{const a=e.layoutItem?.id??e.layout,o=this._getPageSizeLabel(a),n=e.layout?e.layout===this.templateOptions.layout:e.layoutItem?.id===this.templateOptions.layoutItem?.id;return I("calcite-list-item",{description:o,key:`browse-template-${i}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:n,title:e.description??"",value:a},this._fetchingLayoutItemId===e.layoutItem?.id?I("calcite-loader",{inline:!0,key:`browse-template-loader-${i}`,label:"loading",scale:"s",slot:"content-end"}):null,I("calcite-action",{icon:"trash",onclick:()=>l.removePortalTemplate(e),slot:"actions-end",text:"delete"}))})):null,c=i.length&&e?i.toArray().filter((({label:e,layoutItem:t})=>!F(e)&&n.includes(t?.id))).map(((e,l)=>{const i=e.layoutItem?.id??e.layout,a=this._getPageSizeLabel(i),o=e.layout?e.layout===this.templateOptions.layout:e.layoutItem?.id===this.templateOptions.layoutItem?.id;return I("calcite-list-item",{description:a,key:`portal-template-${i}-${o}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:o,title:e.description??"",value:i},this._fetchingLayoutItemId===e.layoutItem?.id?I("calcite-loader",{inline:!0,key:`portal-template-loader-${l}`,label:"loading",scale:"s",slot:"content-end"}):null)})):null,d=i.length&&e?i.toArray().filter((({label:e,layoutItem:t})=>!F(e)&&!n.includes(t?.id))).sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)).map(((e,l)=>{const i=e.layoutItem?.id??e.layout,a=this._getPageSizeLabel(i),o=e.layout?e.layout===this.templateOptions.layout:e.layoutItem?.id===this.templateOptions.layoutItem?.id;return I("calcite-list-item",{description:a,key:`default-template-${l}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:o,title:e.description??"",value:i},this._fetchingLayoutItemId===e.layoutItem?.id?I("calcite-loader",{inline:!0,key:`default-template-loader-${l}`,label:"loading",scale:"s",slot:"content-end"}):null)})):null,u=!a?.layout?.choiceList.length||e&&d?.length?null:a.layout.choiceList.map((e=>({label:t[e]??e.replaceAll("_"," "),value:e}))).sort(((e,t)=>e.label>t.label?1:0)).map((({label:e,value:t},l)=>I("calcite-list-item",{description:this._getPageSizeLabel(t),key:`service-template-${l}`,label:e,selected:t===this.templateOptions.layout,value:t}))),m=(r?.length??0)+(c?.length??0)+(d?.length??0)+(u?.length??0)>15;return I("calcite-flow-item",{bind:this,closable:!1,heading:t.chooseTemplate,key:"template-flow-item",onCalciteFlowItemBack:e=>{e.preventDefault(),this._showTemplates=!1}},I("div",{class:S.templateSelectFlowItemContainer},I("div",{class:S.templateSelectFlowItemContent},this.browseTemplateButtonOnClick?I("calcite-button",{appearance:"outline",class:S.browseTemplateButtonContainer,key:"browse-template-button",onclick:this.browseTemplateButtonOnClick},"Browse Templates"):null,I("calcite-list",{filterEnabled:m,key:"template-list",selectionMode:"single-persist",onCalciteListChange:({target:e})=>this._applyTemplate(e.selectedItems[0]?.value)},r?.length?I("div",{key:"my-templates"},I("div",{class:S.templateSelectFlowItemListHeading},t.myTemplates,I("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:t.beta},t.beta)),r):null,c?.length?I("div",{key:"org-templates"},I("div",{class:S.templateSelectFlowItemListHeading},t.organizationTemplates,s?I("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:t.beta},t.beta):null),c):null,r?.length||c?.length?d?.length?I("div",{key:"default-templates"},I("div",{class:S.templateSelectFlowItemListHeading},t.defaultTemplates),d):null:d,r?.length||c?.length?u?.length?I("div",{key:"service-templates"},I("div",{class:S.templateSelectFlowItemListHeading},t.defaultTemplates),u):null:u)),I("div",{class:S.templateButtonContainer},I("calcite-button",{class:S.templateDoneButton,onclick:()=>this._showTemplates=!1},this.messagesCommon.done))))}_renderCustomTextElementSection(){const{customTextElements:e}=this.templateOptions;return e?I("div",{class:S.formSectionContainer,key:"custom-text-elements"},e.map(((e,t)=>{const[l,i]=Object.entries(e)[0];return"date"===l?null:I("calcite-label",{key:`custom-text-elements-${l}-${t}`},l,I("calcite-input",{bind:this,"data-input-custom":!0,"data-input-name":l,value:i??"",onCalciteInputInput:this._updateInputValue}))}))):null}async _applyTemplate(e){if(this._abortController&&(this._abortController.abort(),this._abortController=null),!e)return;const t=this.viewModel.defaultTemplates.find((({layoutItem:t})=>e===t?.id))??this.viewModel.browseTemplates.find((({layoutItem:t})=>e===t?.id));if(!t)return this.templateOptions.layout=e,void(this.templateOptions.layoutItem=null);const{layoutItem:l}=t,a=t.format??this.templateOptions.format;if(!t.layoutOptions)try{this._abortController=new AbortController,this._fetchingLayoutItemId=l?.id,await this.viewModel.fetchLayoutTemplateInfo(t,{signal:this._abortController.signal})}catch(c){return}finally{this._abortController=null,this._fetchingLayoutItemId=null}const o=t.layoutOptions?.legend??this.templateOptions.legendEnabled,n=t.layoutOptions?.northArrow??this.templateOptions.northArrowEnabled,s=e?this.viewModel.effectiveTemplateCustomTextElements[e]:null,r=s?i(s):null;this.templateOptions.set({customTextElements:r,format:a,layout:null,layoutItem:l,legendEnabled:o,northArrowEnabled:n})}_renderTitleOrFileNameSection(){const{title:e,fileName:t,titlePlaceHolder:l,fileNamePlaceHolder:i}=this.messages,a=this._selectedTab===k.layout?e:t,o=this._selectedTab===k.layout?l:i,n=this._selectedTab===k.layout?this.templateOptions.title:this.templateOptions.fileName;return I("div",{class:S.formSectionContainer,key:a},I("calcite-label",null,a,I("calcite-input",{placeholder:o,value:n??"",onCalciteInputInput:this._onInput})))}_focusOnTabChange(e){if(!this._activeTabFocusRequested)return;const t=e.getAttribute("data-tab-id");("layoutTab"===t&&this._selectedTab===k.layout||"mapOnlyTab"===t&&this._selectedTab===k.mapOnly||"exportTab"===t&&this._selectedTab===k.export)&&(e.focus(),this._activeTabFocusRequested=!1)}_renderLoader(){const e={[S.loader]:this._awaitingServerResponse};return I("div",{class:this.classes(e),key:"loader"})}_createFileLink(e,t){const l=t||this.messages.untitled,i=e.format.toLowerCase(),a=i.includes("png")?"png":i,o=l+a;return void 0!==this._exportedFileNameMap[o]?this._exportedFileNameMap[o]++:this._exportedFileNameMap[o]=0,new h({name:l,extension:a,count:this._exportedFileNameMap[o]})}_resetToCurrentScale(){this.templateOptions.scale=this.viewModel.view?.scale}_updateCustomTextElementValue(e,t,l){e.find((e=>{const[l]=Object.entries(e)[0];return l===t}))[t]=l}_updateInputValue(e){const t=e.target,l=t.getAttribute("data-input-name"),i=!!t["data-input-custom"],{templateOptions:a}=this;if(i)return void this._updateCustomTextElementValue(a.customTextElements,l,t.value);let o;if("number"===t.type){const e=Number(t.value);if(!E(e)){const e=a[l];return void(t.value=`${e}`)}o=e}else o=t.value;a[l]=o}_handleDPIChange(e){const{templateOptions:t}=this,l=t.dpi;this._updateInputValue(e);const i=t.dpi,{height:a,width:o}=M(i,l,t.width,t.height);t.height=a,t.width=o}_handlePrintMap(){this._pendingExportScroll=!0;const{templateOptions:e}=this,t=this.viewModel.toPrintTemplate(e),l=this._selectedTab===k.layout?t.layoutOptions?.titleText:e.fileName,i=this._createFileLink(t,l);this.exportedLinks.add(i),this.emit("submit",{link:i}),this._selectedTab=k.export,this.viewModel.print(t).then((e=>{i.set({url:e&&e.url,state:"ready"})})).catch((e=>{i.set({error:e,state:"error"})})).then((()=>{this.emit("complete",{link:i}),this.scheduleRender()}))}_switchInput(){[this.templateOptions.width,this.templateOptions.height]=[this.templateOptions.height,this.templateOptions.width]}_scrollExportIntoView(){if(!this._pendingExportScroll)return;this._pendingExportScroll=!1;const e=this._rootNode;if(!e)return;const{clientHeight:t,scrollHeight:l}=e,i=l-t;i>0&&(e.scrollTop=i)}_toggleInputValue(e){const t=e.target,l=t.getAttribute("data-option-name");this.templateOptions[l]=t.checked,"scaleEnabled"===l&&this._resetToCurrentScale()}_renderExportedLink(e){const t=this.messages,l=e.map((e=>{const{error:l,url:i,state:a}=e,o=e.formattedName??"",r="error"===a,c="pending"===a,p="ready"===a;let d=i||null;d&&(d=n(d));const u=s(i,location.href);let m;m=c?t.pending:p?t.ready:t.errorMessage;const h=r?"print-task:cim-symbol-unsupported"===l?.name?t.exportWebMapCIMError:t.exportWebMapError:"";return I("calcite-list-item",{"aria-label":m,class:S.exportedFile,"data-item":e,description:c?t.generatingExport:h||(u?t.ready:t.linkReady),key:o,label:o,title:h,onCalciteListItemSelect:this._handleLinkClick},c?I("calcite-loader",{class:S.exportedFileLoader,inline:!0,key:`${o}-loader`,label:t.generatingExport,scale:"m",slot:"content-start"}):I("calcite-icon",{icon:j(e),key:`${o}-start-icon`,scale:"s",slot:"content-start"}),p?I("calcite-icon",{"aria-label":`${o}. ${t.linkReady}`,icon:u?"download-to":"launch",key:`${o}-end-icon`,scale:"s",slot:"content-end"}):null,c?null:I("calcite-action",{"aria-label":`${h}`,"data-item":e,icon:"x",key:`${o}-action`,onclick:this._removeLink,slot:"actions-end",text:`${h}`}))}));return I("calcite-list",{filterEnabled:e?.length>10},l)}_toggleLayoutPanel(e){const t=e.target;this._toggleTab(t.getAttribute("data-tab-id"))}_toggleTab(e,t=!0){if(this._selectedTab=e,this._selectedTab===k.mapOnly)this.templateOptions.layout=O,this.templateOptions.layoutItem=null,this.templateOptions.customTextElements=null;else if(this._selectedTab===k.layout){const e=this._selectedLayout??(this.includeDefaultTemplates&&this.viewModel.defaultTemplates.length?null:this.viewModel.templatesInfo?.layout?.defaultValue),t=this._selectedLayoutItem?.id;e||t?this._applyTemplate(e??t):(this.templateOptions.layout=null,this.templateOptions.layoutItem=null,this.templateOptions.customTextElements=null)}t&&(this._activeTabFocusRequested=!0)}_handleLayoutPanelKeyDown(e){const{key:t}=e,l=e.target.getAttribute("data-tab-id");if(w(t))return this._toggleTab(l),e.preventDefault(),void e.stopPropagation();if("ArrowLeft"===t||"ArrowRight"===t){switch(l){case k.layout:this._toggleTab("ArrowLeft"===t?k.export:k.mapOnly);break;case k.mapOnly:this._toggleTab("ArrowLeft"===t?k.layout:k.export);break;case k.export:this._toggleTab("ArrowLeft"===t?k.mapOnly:k.layout)}e.preventDefault(),e.stopPropagation()}}};e([r()],B.prototype,"_fetchingLayoutItemId",void 0),e([r()],B.prototype,"_showTemplates",void 0),e([r()],B.prototype,"allowedFormats",null),e([r()],B.prototype,"allowedLayouts",null),e([r()],B.prototype,"browseTemplateButtonOnClick",void 0),e([r()],B.prototype,"error",null),e([r({type:C})],B.prototype,"exportedLinks",void 0),e([r()],B.prototype,"extraParameters",null),e([r()],B.prototype,"headerVisible",void 0),e([r()],B.prototype,"headingLevel",void 0),e([r()],B.prototype,"icon",null),e([r()],B.prototype,"includeDefaultTemplates",null),e([r()],B.prototype,"label",null),e([r(),T("esri/widgets/Print/t9n/Print")],B.prototype,"messages",void 0),e([r(),T("esri/t9n/common")],B.prototype,"messagesCommon",void 0),e([r(),T("esri/core/t9n/Units")],B.prototype,"messagesUnits",void 0),e([r()],B.prototype,"portal",null),e([r()],B.prototype,"showPrintAreaEnabled",null),e([r()],B.prototype,"printServiceUrl",null),e([r()],B.prototype,"templateCustomTextElements",null),e([r()],B.prototype,"templateOptions",null),e([r()],B.prototype,"view",null),e([r({type:b})],B.prototype,"viewModel",void 0),B=e([c("esri.widgets.Print")],B);const V=B;export{V as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../geometry.js";import"../intl.js";import t from"../core/Collection.js";import{JSONMap as a}from"../core/jsonMap.js";import{watch as i}from"../core/reactiveUtils.js";import{unitName as l}from"../core/unitFormatUtils.js";import{addProxy as o,hasSameOrigin as n}from"../core/urlUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{reArcGISOnlineDomain as c}from"../portal/support/urlUtils.js";import{getToken as p}from"../rest/utils.js";import{toJSON as d}from"../rest/support/fileFormat.js";import m from"./Widget.js";import u from"./Print/FileLink.js";import h from"./Print/PrintViewModel.js";import{loadCalciteComponents as b}from"./support/componentsUtils.js";import{globalCss as _}from"./support/globalCss.js";import{Heading as y}from"./support/Heading.js";import{legacyIcon as g}from"./support/legacyIcon.js";import{isRTL as f,isActivationKey as v}from"./support/widgetUtils.js";import{messageBundle as w}from"./support/decorators/messageBundle.js";import{tsx as T}from"./support/jsxFactory.js";import x from"../geometry/SpatialReference.js";import{formatNumber as C}from"../intl/number.js";const k=t.ofType(u),O="map-only";var I;!function(e){e.layout="layoutTab",e.mapOnly="mapOnlyTab",e.export="exportTab"}(I||(I={}));const S="esri-print",$=`${S}__advanced-options-button`,L={base:S,headerTitle:`${S}__header-title`,layoutTabList:`${S}__layout-tab-list`,layoutTab:`${S}__layout-tab`,layoutSection:`${S}__layout-section`,mapOnlySection:`${S}__map-only-section`,panelItemsCentered:`${S}__panel-items--centered`,loader:`${S}__loader`,advancedOptionsButton:$,advancedOptionsButtonContainer:`${$}-container`,advancedOptionsButtonTitle:`${$}-title`,advancedOptionsButtonIconOpened:`${$}-icon--opened`,advancedOptionsButtonIconClosed:`${$}-icon--closed`,advancedOptionsButtonIconClosed_RTL:`${$}-icon--closed-rtl`,swapButton:`${S}__swap-button`,printButton:`${S}__export-button`,templateSelectContainer:`${S}__template-select-container`,templateSelectBlock:`${S}__template-select-block`,templateSelectIcon:`${S}__template-select-icon`,templateSelectError:`${S}__template-select-error`,templateSelectArrow:`${S}__template-select-arrow`,formSectionContainer:`${S}__form-section-container`,formCheckboxLabel:`${S}__form-checkbox-label`,advancedOptionsSection:`${S}__advanced-options-section`,advancedOptionsContainer:`${S}__advanced-options-container`,browseTemplateButtonContainer:`${S}__browse-template-button-container`,browseTemplateButtonContainerFilter:`${S}__browse-template-button-container-filter`,exportedFilesContainer:`${S}__export-panel-container`,exportedFilesTitle:`${S}__export-title`,exportedFile:`${S}__exported-file`,exportedFileLink:`${S}__exported-file-link`,exportedFileLinkTitle:`${S}__exported-file-link-title`,exportedFilesEmpty:`${S}__exported-files-empty`,printWidgetContainer:`${S}__container`,content:`${S}__content`,panelContainer:`${S}__panel-container`,scaleInfoContainer:`${S}__scale-info-container`,scaleInputContainer:`${S}__scale-input-container`,scaleInput:`${S}__scale-input`,sizeContainer:`${S}__size-container`,panelError:`${S}__panel--error`,exportedFileError:`${S}__exported-file--error`,exportedFileLoader:`${S}__exported-file--loader`,exportSection:`${S}__export-section`,exportSectionCentered:`${S}__export-section--centered`,templateButtonContainer:`${S}__template-button-container`,templateDoneButton:`${S}__template-done-button`,templateSelectFlowItemContainer:`${S}__template-select-flow-item-container`,templateSelectFlowItemContent:`${S}__template-select-flow-item-content`,templateSelectFlowItemListHeading:`${S}__template-select-flow-item-list-heading`};function M(e,t,a,i){const l=a/t,o=i/t;return{width:Math.round(e*l),height:Math.round(e*o)}}function E(e){return!isNaN(e)&&e>0}function F(e){return e?.toLowerCase()===O}function j(e){const{state:t,extension:a}=e;switch(t){case"pending":return"spinner";case"error":return"exclamation-mark-circle";default:return a?.toLowerCase()?.includes("pdf")?"file-pdf":"file"}}const P=new a({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),B=new Map([["a3-landscape","a3-landscape"],["a3-portrait","a3-portrait"],["a4-landscape","a4-landscape"],["a4-portrait","a4-portrait"],["letter-ansi-a-landscape","ansi-a-landscape"],["letter-ansi-a-portrait","ansi-a-portrait"],["tabloid-ansi-b-landscape","ansi-b-landscape"],["tabloid-ansi-b-portrait","ansi-b-portrait"]]);let A=class extends m{constructor(e,t){super(e,t),this._activeTabFocusRequested=!1,this._awaitingServerResponse=!1,this._exportedFileNameMap={},this._selectedTab=I.layout,this._pendingExportScroll=!1,this._rootNode=null,this._selectedTemplate=null,this._showTemplates=!1,this.browseTemplateButtonOnClick=null,this.exportedLinks=new k,this.headerVisible=!0,this.headingLevel=3,this.messagesCommon=null,this.messagesUnits=null,this.viewModel=new h,this._onInput=e=>{this._selectedTab===I.layout?this.templateOptions.title=e.target.value:this._selectedTab===I.mapOnly&&(this.templateOptions.fileName=e.target.value)},this._removeLink=e=>{const t=e.currentTarget["data-item"];t&&this.exportedLinks.remove(t)},this._handleLinkClick=e=>{const t=e.currentTarget["data-item"];if(!t||"ready"!==t.state||!t.url)return;const a=p(this.viewModel.effectivePrintServiceUrl),i=t.url,l=document.createElement("a");if(l.target="_blank",l.href=i,l.rel="noreferrer",l.download=t.formattedName??"",!a)return l.click(),void e.stopPropagation();e.preventDefault();const o=new URL(i);o.searchParams.set("token",a),l.href=o.href,l.click(),l.href=i},this._focusOnTabChange=this._focusOnTabChange.bind(this)}initialize(){this.addHandles([i((()=>[this.templateOptions.format,this.viewModel.templatesInfo?.format.defaultValue]),(([e,t])=>{if(t&&!e)return void(this.templateOptions.format=t);if(!e||!t||!this.viewModel.templatesInfo)return;if(this.viewModel.templatesInfo.format.choiceList.includes(e))return;const a=this.viewModel.templatesInfo.format.choiceList.find((t=>t.toUpperCase().includes(`(${e.toUpperCase()})`)));this.templateOptions.format=a??t})),i((()=>[this.templateOptions.id,this.viewModel.loaded]),(async()=>{const{layout:e}=this.templateOptions;this._selectedTab=F(e)?I.mapOnly:I.layout,this._selectedTab===I.layout&&this.viewModel.loaded&&(this._selectedTemplate=this.viewModel.getLayoutTemplateById(this.templateOptions.id))})),i((()=>this.templateOptions.dpi),(e=>{e<=0&&(this.templateOptions.dpi=1)})),i((()=>this.viewModel.view?.scale),(e=>{!e||this.templateOptions.scaleEnabled&&this.templateOptions.scale||(this.templateOptions.scale=e)}))]);for(const{name:i,extension:l}of this.exportedLinks)i&&l&&this._updateExportedFileNameMap(`${i}${l}`);const{height:e,width:t}=this.templateOptions;this.templateOptions.width=t||800,this.templateOptions.height=e||1100;const a=setTimeout((()=>{this._awaitingServerResponse=!0,this.scheduleRender()}),500);this.viewModel.load().then((()=>{clearTimeout(a),this._awaitingServerResponse=!1}))}loadDependencies(){return b({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip.js")})}destroy(){this.viewModel.destroy()}get allowedFormats(){return this.viewModel.allowedFormats}set allowedFormats(e){this.viewModel.allowedFormats=e}get allowedLayouts(){return this.viewModel.allowedLayouts}set allowedLayouts(e){this.viewModel.allowedLayouts=e}get error(){return this.viewModel.error}get extraParameters(){return this.viewModel.extraParameters}set extraParameters(e){this.viewModel.extraParameters=e}get icon(){return"print"}set icon(e){this._overrideIfSome("icon",e)}get includeDefaultTemplates(){return this.viewModel.includeDefaultTemplates}set includeDefaultTemplates(e){this.viewModel.includeDefaultTemplates=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get outSpatialReference(){return this.viewModel.outSpatialReference}set outSpatialReference(e){this.viewModel.outSpatialReference=e}get portal(){return this.viewModel.portal}set portal(e){this.viewModel.portal=e}get showPrintAreaEnabled(){return this.viewModel.showPrintAreaEnabled}set showPrintAreaEnabled(e){this.viewModel.showPrintAreaEnabled=e}get printServiceUrl(){return this.viewModel.printServiceUrl}set printServiceUrl(e){this.viewModel.printServiceUrl=e}get templateCustomTextElements(){return this.viewModel.templateCustomTextElements}set templateCustomTextElements(e){this.viewModel.templateCustomTextElements=e}get templateOptions(){return this.viewModel.templateOptions}set templateOptions(e){this.viewModel.templateOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){const{messages:e,templateOptions:t,viewModel:a,view:i}=this,{attributionEnabled:l,author:o,copyright:n,dpi:s,format:r,height:c,layout:p,layoutItem:m,legendEnabled:u,northArrowEnabled:h,scaleBarEnabled:b,scaleEnabled:v,scale:w,width:C}=t,k="ready"!==a.state||this._awaitingServerResponse||!(p||m),O=this._renderTitleOrFileNameSection(),S=T("div",{class:L.formSectionContainer},T("calcite-label",null,e.fileFormatTitle,T("calcite-combobox",{clearDisabled:!0,label:e.formatDefaultOption,maxItems:6,placeholder:e.formatDefaultOption,selectionMode:"single-persist",onCalciteComboboxChange:({target:e})=>{this.templateOptions.format=e.selectedItems[0]?.value??"pdf"}},a.templatesInfo?.format?.choiceList.sort().map(((e,t)=>T("calcite-combobox-item",{key:`file-format-${t}`,selected:e===this.templateOptions.format,textLabel:d(e),value:e})))))),$=T("calcite-label",{layout:"inline"},T("calcite-switch",{checked:this.showPrintAreaEnabled,onCalciteSwitchChange:e=>{this.showPrintAreaEnabled=!!e.target.checked}}),e.printPreview),M=T("div",null,T("div",{class:L.formSectionContainer},T("calcite-label",null,e.template,T("calcite-block",{class:L.templateSelectContainer,collapsible:!1,description:this._getPageSizeLabel(this._selectedTemplate),heading:this._getTemplateLabel(this._selectedTemplate,!0),key:"template-select-block",loading:"loading"===this._selectedTemplate?.state,onclick:()=>{this._showTemplates=!0}},T("calcite-icon",{class:L.templateSelectIcon,icon:(this._selectedTemplate?.layout?B.get(this._selectedTemplate.layout):null)||"custom-print",key:"template-select-icon",scale:"l",slot:"content-start"}),"error"===this._selectedTemplate?.state?T("calcite-icon",{class:L.templateSelectError,icon:"exclamation-mark-circle",key:"template-select-error",scale:"s",slot:"actions-end"}):null,T("calcite-icon",{class:L.templateSelectArrow,icon:f()?"chevron-left":"chevron-right",key:"template-select-arrow",scale:"s",slot:"actions-end"})))),$),E=T("div",{class:L.formSectionContainer},T("calcite-label",null,e.dpi,T("calcite-input",{bind:this,"data-input-name":"dpi",min:1,tabIndex:0,type:"number",value:`${s}`,onCalciteInputInput:this._handleDPIChange}))),F=T("div",{class:L.formSectionContainer},T("calcite-label",null,e.outSpatialReference,T("calcite-input",{bind:this,"data-input-name":"outSpatialReference",tabIndex:0,type:"number",value:a.outSpatialReference?.wkid?.toString()??"",onCalciteInputInput:({target:e})=>{const t=Number(e.value);a.outSpatialReference=Number.isNaN(t)?new x({wkid:t}):null}}))),j=T("div",{class:this.classes(L.scaleInfoContainer,L.formSectionContainer)},T("calcite-label",{layout:"inline"},T("calcite-checkbox",{bind:this,checked:v,"data-option-name":"scaleEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.scale),T("div",{class:L.scaleInputContainer},T("calcite-input",{"aria-label":e.scaleLabel,"aria-valuenow":`${w}`,bind:this,class:L.scaleInput,"data-input-name":"scale",disabled:!v,tabIndex:0,type:"number",value:`${w}`,onCalciteInputInput:this._updateInputValue}),T("calcite-button",{appearance:"outline","aria-label":e.reset,bind:this,disabled:!v,iconStart:"refresh",kind:"neutral",onclick:this._resetToCurrentScale,tabIndex:0}))),P=T("div",{"aria-labelledby":`${this.id}__advancedOptionsForLayout`,class:L.advancedOptionsContainer,key:"advanced-section-for-layout"},j,this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasAuthorText??1?T("div",{class:L.formSectionContainer,key:"author-info"},T("calcite-label",null,e.author,T("calcite-input",{bind:this,"data-input-name":"author",tabIndex:0,value:o??"",onCalciteInputInput:this._updateInputValue}))):null,this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasCopyrightText??1?T("div",{class:L.formSectionContainer,key:"copyright-text"},T("calcite-label",null,e.copyright,T("calcite-input",{bind:this,"data-input-name":"copyright",tabIndex:0,value:n??"",onCalciteInputInput:this._updateInputValue}))):null,E,F,this._renderCustomTextElementSection(),this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasLegend??1?T("div",{class:L.formSectionContainer,key:"legend-info"},T("calcite-label",{layout:"inline"},T("calcite-checkbox",{bind:this,checked:u,"data-option-name":"legendEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.legend)):null,this._selectedTemplate?.mapSurroundInfoOptions?.northArrow.length?T("div",{class:L.formSectionContainer,key:"north-arrow"},T("calcite-label",{layout:"inline"},T("calcite-checkbox",{bind:this,checked:h,"data-option-name":"northArrowEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.northArrow)):null,this._selectedTemplate?.mapSurroundInfoOptions?.scaleBar.length?T("div",{class:L.formSectionContainer,key:"scale-bar"},T("calcite-label",{layout:"inline"},T("calcite-checkbox",{bind:this,checked:b,"data-option-name":"scaleBarEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.scaleBar)):null),A=T("div",{"aria-labelledby":`${this.id}__advancedOptionsForMapOnly`,class:L.advancedOptionsContainer},j,E,F,T("div",{class:L.formSectionContainer},T("calcite-label",{layout:"inline"},T("calcite-checkbox",{bind:this,checked:l,"data-option-name":"attributionEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.attribution)),this._renderCustomTextElementSection()),N=this.exportedLinks.toArray(),R=this._renderExportedLink(N),D={[L.exportSectionCentered]:!N.length},U=this._selectedTab===I.layout?T("section",{"aria-labelledby":`${this.id}__layoutTab`,class:L.layoutSection,id:`${this.id}__layoutContent`,key:"esri-print__layoutContent",role:"tabpanel"},T("div",{class:L.panelContainer},this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasTitleText??1?O:null,M,this._selectedTab===I.layout?S:null,T("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(L.panelContainer,L.advancedOptionsSection),collapsible:!0,disabled:!(p||m?.id),heading:e.advancedOptions,id:"advancedOptionsForLayout",key:"advanced-options-for-layout"},P))):this._selectedTab===I.mapOnly?T("section",{"aria-labelledby":`${this.id}__mapOnlyTab`,class:L.mapOnlySection,id:`${this.id}__mapOnlyContent`,key:"esri-print__mapOnlyContent",role:"tabpanel"},T("div",{class:L.panelContainer},O,S,T("div",null,T("div",{class:this.classes(L.sizeContainer,L.formSectionContainer)},T("calcite-label",null,e.width,T("calcite-input",{bind:this,"data-input-name":"width",tabIndex:0,type:"number",value:`${C}`,onCalciteInputInput:this._updateInputValue})),T("calcite-label",null,e.height,T("calcite-input",{bind:this,"data-input-name":"height",tabIndex:0,type:"number",value:`${c}`,onCalciteInputInput:this._updateInputValue})),T("button",{"aria-label":e.swap,bind:this,class:this.classes(_.widgetButton,L.swapButton,g.swap),onclick:this._switchInput,tabIndex:0,type:"button"})),$),T("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(L.panelContainer,L.advancedOptionsSection),collapsible:!0,heading:e.advancedOptions,id:"advancedOptionsForMapOnly",key:"advanced-options-for-map-only"},A))):T("section",{"aria-labelledby":`${this.id}__exportTab`,class:this.classes(L.exportSection,D),id:`${this.id}__exportContent`,key:"esri-print__exportContent",role:"tabpanel"},T("div",{class:L.panelContainer},T("div",{afterUpdate:this._scrollExportIntoView,bind:this,class:L.exportedFilesContainer},0===N.length?T("div",{class:L.exportedFilesEmpty},T("calcite-icon",{icon:"file",scale:"l"}),T("div",null,T(y,{class:L.exportedFilesTitle,level:this.headingLevel},e.noExportedFiles),T("div",null,e.exportHint))):R))),V={[_.buttonDisabled]:k||!(p||m?.id)&&!r},H=!i||"2d"!==i.type,z=T("div",{class:L.panelError},H?e.sceneViewError:e.serviceError),W=N.some((({state:e})=>"pending"===e)),q=T("div",{class:L.content,key:"panel"},T("div",null,T("ul",{bind:this,class:L.layoutTabList,onclick:this._toggleLayoutPanel,onkeydown:this._handleLayoutPanelKeyDown,role:"tablist"},T("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===I.layout}`,class:L.layoutTab,"data-tab-id":I.layout,id:`${this.id}__layoutTab`,role:"tab",tabIndex:0},e.layoutTab),T("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===I.mapOnly}`,class:L.layoutTab,"data-tab-id":I.mapOnly,id:`${this.id}__mapOnlyTab`,role:"tab",tabIndex:0},e.mapOnlyTab),T("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===I.export}`,class:L.layoutTab,"data-tab-id":I.export,id:`${this.id}__exportedFilesTab`,role:"tab",tabIndex:0},W?T("calcite-loader",{inline:!0,label:"loading",scale:"s"}):null,e.exportsTab)),U),this._selectedTab!==I.export?T("button",{"aria-label":e.exportDescription,bind:this,class:this.classes(L.printButton,_.button,V),disabled:k,onclick:this._handlePrintMap,tabIndex:0,type:"button"},e.export):null),K=T("calcite-flow",{key:"root-flow"},T("calcite-flow-item",{bind:this,key:"root-flow-item"},T("div",{class:L.printWidgetContainer},this.headerVisible?T("header",{class:L.headerTitle},e.export):null,this.error||H||!i?z:q)),this._renderChooseTemplateFlowItem()),G="initializing"===a.state,J=G?this._renderLoader():K,Q={[L.panelItemsCentered]:G};return T("div",{bind:this,class:this.classes(L.base,_.widget,_.panel,Q)},J)}_getPageSizeLabel(e){if(!e)return;const t=e.layoutTemplateInfo;if(!t)return;const a=P.fromJSON(t.pageUnits.toLowerCase());return`${C(t.pageSize[0])} x ${C(t.pageSize[1])} ${l(this.messagesUnits,a,"abbr")}`}_getTemplateLabel(e,t=!1){if(!e)return t?this.messages.selectTemplate:this.messages.untitled;const{label:a,layout:i,layoutItem:l,type:o}=e;if("print-service-template"===o)return this.messages[i];const n=a??i??l?.id;return n?.replaceAll("_"," ")??this.messages.untitled}_getPortalTemplates(){const{portalTemplateIds:e}=this.viewModel;return this.includeDefaultTemplates?this.viewModel.defaultTemplates.toArray().filter((({layout:t,layoutItem:a})=>!F(t)&&!!a?.id&&e.includes(a.id))):[]}_getDefaultTemplates(){const{portalTemplateIds:e}=this.viewModel;return this.includeDefaultTemplates?this.viewModel.defaultTemplates.toArray().filter((({layout:t,layoutItem:a})=>!(F(t)||a?.id&&e.includes(a.id)))):[]}_getPrintServiceTemplates(){return this.includeDefaultTemplates&&this.viewModel.defaultTemplates.length?[]:this.viewModel.printServiceTemplates.toArray().filter((({layout:e})=>!F(e)))}_renderLayoutTemplates(e,t=!1,a=!1){return t&&e.sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)),e.map((e=>T("calcite-list-item",{description:this._getPageSizeLabel(e),key:`template-${e.id}-${e.id===this.templateOptions.id}`,label:this._getTemplateLabel(e),selected:e.id===this.templateOptions.id,title:e.description??"",value:e},T("calcite-icon",{icon:(e.layout?B.get(e.layout):null)||"custom-print",slot:"content-start"}),"loading"===e.state?T("calcite-loader",{inline:!0,key:`template-loader-${e.id}`,label:"loading",scale:"s",slot:"content-end"}):null,"error"===e?.state?T("calcite-icon",{class:L.templateSelectError,icon:"exclamation-mark-circle",key:`template-error-${e.id}`,scale:"s",slot:"content-end"}):null,a?T("calcite-action",{icon:"trash",onclick:()=>this.viewModel.removePortalTemplate(e),slot:"actions-end",text:"delete"}):null)))}_renderChooseTemplateFlowItem(){if(!this._showTemplates)return null;const{messages:e}=this,t=c.test(this.portal?.url),a=this.viewModel.browseTemplates.toArray(),i=this._getPortalTemplates(),l=this._getDefaultTemplates(),o=this._getPrintServiceTemplates(),n=a.length+i.length+l.length+o.length>15,s=this.browseTemplateButtonOnClick?T("calcite-button",{appearance:"outline",class:n?L.browseTemplateButtonContainerFilter:L.browseTemplateButtonContainer,iconStart:"folder",key:"browse-template-button",onclick:this.browseTemplateButtonOnClick,slot:n?"filter-actions-end":"default"},n?null:e.browseTemplates):null;return T("calcite-flow-item",{bind:this,closable:!1,heading:e.chooseTemplate,key:"template-flow-item",onCalciteFlowItemBack:e=>{e.preventDefault(),this._showTemplates=!1}},T("div",{class:L.templateSelectFlowItemContainer},T("div",{class:L.templateSelectFlowItemContent},n?null:s,T("calcite-list",{filterEnabled:n,filterProps:["label"],key:"template-list",selectionMode:"single-persist",onCalciteListChange:({target:e})=>this.viewModel.applyTemplate(e.selectedItems[0]?.value)},n?s:null,a.length?T("div",{key:"my-templates"},T("div",{class:L.templateSelectFlowItemListHeading},e.myTemplates,T("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:e.beta},e.beta)),this._renderLayoutTemplates(a,!0,!0)):null,i.length?T("div",{key:"org-templates"},T("div",{class:L.templateSelectFlowItemListHeading},e.organizationTemplates,t?T("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:e.beta},e.beta):null),this._renderLayoutTemplates(i)):null,a.length||i.length?l.length?T("div",{key:"default-templates"},T("div",{class:L.templateSelectFlowItemListHeading},e.defaultTemplates),this._renderLayoutTemplates(l,!0)):null:this._renderLayoutTemplates(l,!0),a.length||i.length?o.length?T("div",{key:"service-templates"},T("div",{class:L.templateSelectFlowItemListHeading},e.defaultTemplates),this._renderLayoutTemplates(o,!0)):null:this._renderLayoutTemplates(o,!0))),T("div",{class:L.templateButtonContainer},T("calcite-button",{class:L.templateDoneButton,onclick:()=>this._showTemplates=!1},this.messagesCommon.done))))}_renderCustomTextElementSection(){const{customTextElements:e}=this.templateOptions;return e?T("div",{class:L.formSectionContainer,key:"custom-text-elements"},e.map(((e,t)=>{const[a,i]=Object.entries(e)[0];return"date"===a?null:T("calcite-label",{key:`custom-text-elements-${a}-${t}`},a,T("calcite-input",{bind:this,"data-input-custom":!0,"data-input-name":a,value:i??"",onCalciteInputInput:this._updateInputValue}))}))):null}_renderTitleOrFileNameSection(){const{title:e,fileName:t,titlePlaceHolder:a,fileNamePlaceHolder:i}=this.messages,l=this._selectedTab===I.layout?e:t,o=this._selectedTab===I.layout?a:i,n=this._selectedTab===I.layout?this.templateOptions.title:this.templateOptions.fileName;return T("div",{class:L.formSectionContainer,key:l},T("calcite-label",null,l,T("calcite-input",{placeholder:o,value:n??"",onCalciteInputInput:this._onInput})))}_focusOnTabChange(e){if(!this._activeTabFocusRequested)return;const t=e.getAttribute("data-tab-id");("layoutTab"===t&&this._selectedTab===I.layout||"mapOnlyTab"===t&&this._selectedTab===I.mapOnly||"exportTab"===t&&this._selectedTab===I.export)&&(e.focus(),this._activeTabFocusRequested=!1)}_renderLoader(){const e={[L.loader]:this._awaitingServerResponse};return T("div",{class:this.classes(e),key:"loader"})}_updateExportedFileNameMap(e){void 0!==this._exportedFileNameMap[e]?this._exportedFileNameMap[e]++:this._exportedFileNameMap[e]=0}_createFileLink(e,t){const a=t||this.messages.untitled,i=e.format.toLowerCase(),l=i.includes("png")?"png":i,o=a+l;return this._updateExportedFileNameMap(o),new u({name:a,extension:l,count:this._exportedFileNameMap[o]})}_resetToCurrentScale(){this.templateOptions.scale=this.viewModel.view?.scale}_updateCustomTextElementValue(e,t,a){e.find((e=>{const[a]=Object.entries(e)[0];return a===t}))[t]=a}_updateInputValue(e){const t=e.target,a=t.getAttribute("data-input-name"),i=!!t["data-input-custom"],{templateOptions:l}=this;if(i)return void this._updateCustomTextElementValue(l.customTextElements,a,t.value);let o;if("number"===t.type){const e=Number(t.value);if(!E(e)){const e=l[a];return void(t.value=`${e}`)}o=e}else o=t.value;l[a]=o}_handleDPIChange(e){const{templateOptions:t}=this,a=t.dpi;this._updateInputValue(e);const i=t.dpi,{height:l,width:o}=M(i,a,t.width,t.height);t.height=l,t.width=o}_handlePrintMap(){this._pendingExportScroll=!0;const{templateOptions:e}=this,t=this.viewModel.toPrintTemplate(e),a=this._selectedTab===I.layout?t.layoutOptions?.titleText:e.fileName,i=this._createFileLink(t,a);this.exportedLinks.add(i),this.emit("submit",{link:i}),this._selectedTab=I.export,this.viewModel.print(t).then((e=>{i.set({url:e&&e.url,state:"ready"})})).catch((e=>{i.set({error:e,state:"error"})})).then((()=>{this.emit("complete",{link:i}),this.scheduleRender()}))}_switchInput(){[this.templateOptions.width,this.templateOptions.height]=[this.templateOptions.height,this.templateOptions.width]}_scrollExportIntoView(){if(!this._pendingExportScroll)return;this._pendingExportScroll=!1;const e=this._rootNode;if(!e)return;const{clientHeight:t,scrollHeight:a}=e,i=a-t;i>0&&(e.scrollTop=i)}_toggleInputValue(e){const t=e.target,a=t.getAttribute("data-option-name");this.templateOptions[a]=t.checked,"scaleEnabled"===a&&this._resetToCurrentScale()}_renderExportedLink(e){const t=this.messages,a=e.map((e=>{const{error:a,url:i,state:l}=e,s=e.formattedName??"",r="error"===l,c="pending"===l,p="ready"===l;let d=i||null;d&&(d=o(d));const m=n(i,location.href);let u;u=c?t.pending:p?t.ready:t.errorMessage;const h=r?"print-task:cim-symbol-unsupported"===a?.name?t.exportWebMapCIMError:t.exportWebMapError:"";return T("calcite-list-item",{"aria-label":u,class:L.exportedFile,"data-item":e,description:c?t.generatingExport:h||(m?t.ready:t.linkReady),key:s,label:s,title:h,onCalciteListItemSelect:this._handleLinkClick},c?T("calcite-loader",{class:L.exportedFileLoader,inline:!0,key:`${s}-loader`,label:t.generatingExport,scale:"m",slot:"content-start"}):T("calcite-icon",{icon:j(e),key:`${s}-start-icon`,scale:"s",slot:"content-start"}),p?T("calcite-icon",{"aria-label":`${s}. ${t.linkReady}`,icon:m?"download-to":"launch",key:`${s}-end-icon`,scale:"s",slot:"content-end"}):null,c?null:T("calcite-action",{"aria-label":`${h}`,"data-item":e,icon:"x",key:`${s}-action`,onclick:this._removeLink,slot:"actions-end",text:`${h}`}))}));return T("calcite-list",{filterEnabled:e?.length>10},a)}_toggleLayoutPanel(e){const t=e.target;this._toggleTab(t.getAttribute("data-tab-id"))}_toggleTab(e,t=!0){if(this._selectedTab=e,this._selectedTab===I.mapOnly)this.templateOptions.reset(),this.templateOptions.layout=O;else if(this._selectedTab===I.layout){const e=this._selectedTemplate??this.viewModel.defaultTemplate;e?this.viewModel.applyTemplate(e):this.templateOptions.reset()}t&&(this._activeTabFocusRequested=!0)}_handleLayoutPanelKeyDown(e){const{key:t}=e,a=e.target.getAttribute("data-tab-id");if(v(t))return this._toggleTab(a),e.preventDefault(),void e.stopPropagation();if("ArrowLeft"===t||"ArrowRight"===t){switch(a){case I.layout:this._toggleTab("ArrowLeft"===t?I.export:I.mapOnly);break;case I.mapOnly:this._toggleTab("ArrowLeft"===t?I.layout:I.export);break;case I.export:this._toggleTab("ArrowLeft"===t?I.mapOnly:I.layout)}e.preventDefault(),e.stopPropagation()}}};e([s()],A.prototype,"_showTemplates",void 0),e([s()],A.prototype,"allowedFormats",null),e([s()],A.prototype,"allowedLayouts",null),e([s()],A.prototype,"browseTemplateButtonOnClick",void 0),e([s()],A.prototype,"error",null),e([s({type:k})],A.prototype,"exportedLinks",void 0),e([s()],A.prototype,"extraParameters",null),e([s()],A.prototype,"headerVisible",void 0),e([s()],A.prototype,"headingLevel",void 0),e([s()],A.prototype,"icon",null),e([s()],A.prototype,"includeDefaultTemplates",null),e([s()],A.prototype,"label",null),e([s(),w("esri/widgets/Print/t9n/Print")],A.prototype,"messages",void 0),e([s(),w("esri/t9n/common")],A.prototype,"messagesCommon",void 0),e([s(),w("esri/core/t9n/Units")],A.prototype,"messagesUnits",void 0),e([s({type:x})],A.prototype,"outSpatialReference",null),e([s()],A.prototype,"portal",null),e([s()],A.prototype,"showPrintAreaEnabled",null),e([s()],A.prototype,"printServiceUrl",null),e([s()],A.prototype,"templateCustomTextElements",null),e([s()],A.prototype,"templateOptions",null),e([s()],A.prototype,"view",null),e([s({type:h})],A.prototype,"viewModel",void 0),A=e([r("esri.widgets.Print")],A);const N=A;export{N 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.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Error.js";import{convertFeaturesToCSV as t}from"../../exports/csv.js";import{renderingSanitizer as o}from"./widgetUtils.js";function r(){return"showSaveFilePicker"in window&&(()=>{try{return window.self===window.top}catch{return!1}})()}async function i(i){const{layer:c,
|
|
5
|
+
import e from"../../core/Error.js";import{convertFeaturesToCSV as t}from"../../exports/csv.js";import{renderingSanitizer as o}from"./widgetUtils.js";function r(){return"showSaveFilePicker"in window&&(()=>{try{return window.self===window.top}catch{return!1}})()}async function i(i){const{layer:c,includeGeometry:s,objectIds:a,outFields:n}=i,l=n??c.outFields??["*"],d=c.createQuery();d.objectIds=a,d.outFields=l;const w=await c.queryFeatures(d),u=await t(w,{includeGeometry:!c.isTable&&(s||"point"===w.geometryType),outFields:l});if(!u)throw new e("export-csv:no-output","Unable to generate a valid export string");const p=new Blob([u],{type:"text/csv"}),m=o.sanitize(c.title);if(r())try{const e=await showSaveFilePicker({suggestedName:m,types:[{accept:{"text/csv":[".csv"]}}]}),t=await e.createWritable();await t.write(p),await t.close()}catch(y){if(y instanceof e&&"AbortError"!==y.name)throw y}else{const e=URL.createObjectURL(p),t=document.createElement("a");t.href=e,t.download=`${m}.csv`,t.style.display="none",document.body.append(t),t.click(),setTimeout((()=>{URL.revokeObjectURL(e),t.remove()}),1e3)}}export{i as exportToCSV,r as supportsFileSystemAccess};
|