@arcgis/core 4.31.0-next.20240620 → 4.31.0-next.20240621

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{3a74d3fc690177a703f5.js → 019ce38b02e3bf517125.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{222807cfaa2e17d0efea.js → 6745cedf6f82c8917904.js} +1 -1
  4. package/assets/esri/core/workers/chunks/7b6cd976367a0dd297d6.js +1 -0
  5. package/assets/esri/core/workers/chunks/{8a948d46d0377a6adb86.js → 9d677af08238d9e09e72.js} +2 -2
  6. package/assets/esri/core/workers/chunks/bedf60888f07b78b314d.js +1 -0
  7. package/assets/esri/core/workers/chunks/c39237c00c1d588dc107.js +1 -0
  8. package/assets/esri/core/workers/chunks/de7fa31d86a65ccdffc1.js +1 -0
  9. package/assets/esri/core/workers/chunks/{8ee8f3c54b2cce217845.js → f13fb6b712e364bbf48c.js} +1 -1
  10. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_ar.json +1 -1
  11. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_bg.json +1 -1
  12. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_bs.json +1 -1
  13. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_ca.json +1 -1
  14. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_cs.json +1 -1
  15. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_da.json +1 -1
  16. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_de.json +1 -1
  17. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_el.json +1 -1
  18. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_es.json +1 -1
  19. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_et.json +1 -1
  20. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_fi.json +1 -1
  21. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_fr.json +1 -1
  22. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_he.json +1 -1
  23. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_hr.json +1 -1
  24. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_hu.json +1 -1
  25. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_id.json +1 -1
  26. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_it.json +1 -1
  27. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_ja.json +1 -1
  28. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_ko.json +1 -1
  29. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_lt.json +1 -1
  30. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_lv.json +1 -1
  31. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_nb.json +1 -1
  32. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_nl.json +1 -1
  33. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_pl.json +1 -1
  34. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_pt-BR.json +1 -1
  35. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_pt-PT.json +1 -1
  36. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_ro.json +1 -1
  37. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_ru.json +1 -1
  38. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_sk.json +1 -1
  39. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_sl.json +1 -1
  40. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_sr.json +1 -1
  41. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_sv.json +1 -1
  42. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_th.json +1 -1
  43. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_tr.json +1 -1
  44. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_uk.json +1 -1
  45. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_vi.json +1 -1
  46. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_zh-CN.json +1 -1
  47. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_zh-HK.json +1 -1
  48. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_zh-TW.json +1 -1
  49. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ar.json +1 -1
  50. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_bg.json +1 -1
  51. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_bs.json +1 -1
  52. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ca.json +1 -1
  53. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_cs.json +1 -1
  54. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_da.json +1 -1
  55. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_de.json +1 -1
  56. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_el.json +1 -1
  57. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_es.json +1 -1
  58. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_et.json +1 -1
  59. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_fi.json +1 -1
  60. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_fr.json +1 -1
  61. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_he.json +1 -1
  62. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_hr.json +1 -1
  63. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_hu.json +1 -1
  64. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_id.json +1 -1
  65. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_it.json +1 -1
  66. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ja.json +1 -1
  67. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ko.json +1 -1
  68. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_lt.json +1 -1
  69. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_lv.json +1 -1
  70. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_nb.json +1 -1
  71. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_nl.json +1 -1
  72. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pl.json +1 -1
  73. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pt-BR.json +1 -1
  74. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pt-PT.json +1 -1
  75. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ro.json +1 -1
  76. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ru.json +1 -1
  77. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sk.json +1 -1
  78. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sl.json +1 -1
  79. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sr.json +1 -1
  80. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sv.json +1 -1
  81. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_th.json +1 -1
  82. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_tr.json +1 -1
  83. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_uk.json +1 -1
  84. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_vi.json +1 -1
  85. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-CN.json +1 -1
  86. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-HK.json +1 -1
  87. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-TW.json +1 -1
  88. package/chunks/CheckerBoard.glsl.js +9 -6
  89. package/chunks/ComponentShader.glsl.js +4 -4
  90. package/chunks/ImageMaterial.glsl.js +1 -2
  91. package/interfaces.d.ts +50 -14
  92. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  93. package/layers/mixins/EditBusLayer.js +1 -1
  94. package/layers/mixins/FeatureLayerBase.js +1 -1
  95. package/layers/orientedImagery/core/ExposurePoint.js +1 -1
  96. package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
  97. package/layers/support/featureLayerUtils.js +1 -1
  98. package/package.json +1 -1
  99. package/portal/schemas/definitions.js +1 -1
  100. package/rest/knowledgeGraph/wasmInterface/WasmDataModelWrapperInterfaces.js +1 -1
  101. package/support/revision.js +1 -1
  102. package/views/2d/layers/support/ExportStrategy.js +1 -1
  103. package/views/3d/layers/I3SMeshView3D.js +1 -1
  104. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  105. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  106. package/views/3d/layers/graphics/Graphics3DObject3DGraphicLayer.js +1 -1
  107. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  108. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  109. package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentData.glsl.js +1 -2
  110. package/views/3d/webgl-engine/effects/RenderPlugin.js +1 -1
  111. package/views/3d/webgl-engine/lib/Material.js +1 -1
  112. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  113. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  114. package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
  115. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  116. package/views/3d/webgl-engine/lib/edgeRendering/interfaces.js +1 -1
  117. package/views/3d/webgl-engine/lib/edgeRendering/util.js +1 -1
  118. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  119. package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
  120. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  121. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  122. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  123. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  124. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  125. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  126. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  127. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  128. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  129. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  130. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  131. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  132. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  133. package/views/3d/webgl-engine/shaders/CheckerBoard.glsl.js +1 -1
  134. package/views/SelectionManager.js +1 -1
  135. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  136. package/widgets/OrientedImageryViewer/adapters/OrientedImageryViewerViewModelAdapter2D.js +1 -1
  137. package/widgets/OrientedImageryViewer/utils.js +1 -1
  138. package/widgets/OrientedImageryViewer.js +1 -1
  139. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  140. package/widgets/PanoramicViewer/constants.js +1 -1
  141. package/widgets/PanoramicViewer/utils.js +1 -1
  142. package/widgets/Print.js +1 -1
  143. package/assets/esri/core/workers/chunks/4f2be9fd4ff5b3ad3110.js +0 -1
  144. package/assets/esri/core/workers/chunks/88c7d84a1fde246ca71f.js +0 -1
  145. package/assets/esri/core/workers/chunks/986520dd0de64105dbff.js +0 -1
  146. package/assets/esri/core/workers/chunks/ad0a87dba95785ad6171.js +0 -1
@@ -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 D from"../PanoramicViewer.js";import{sectorsInOrder as H,sectorsRadii as U}from"./constants.js";import{crossSymbol as N,crossSymbol3D as z,diamondSymbol as W,diamondSymbol3D as q,activeSourcePointSymbol as J,sourcePointSymbol as $}from"./symbols.js";import{getContentType as K,isNoAttachmentError as Q,isTifOrMrf as X,isSceneView as Y,isGraphic as Z,calculateSegment as ee,calculateDirection as te}from"./utils.js";import ie from"./components/ImageViewer.js";import re from"../../geometry/Point.js";import oe from"../../geometry/SpatialReference.js";const se={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles"},ae=new Set(["JPG","JPEG"]),ne=/\.(\w+)$/,le=e=>"FA"===e;let he=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 ie,this.bestFeatureFootprint=null,this._initialCurrentCoverageUpdate=!0,this._loading=!1,this._overlays=new C({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new D,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;let n=s?e.match(ne)?.[1]??"":e.datasetFormat;if(!n){const e=await K(a,{...t.options});e&&(n=e.split("/")[1]),n??="UNKNOWN FORMAT"}switch(i){case"default":{this._imageViewer.imageSource={datasetFormat:n.toUpperCase(),url:a};const e=new URL(a);this._imageViewer.customParameters=Object.fromEntries(e.searchParams),this._imageViewer.imageRotation=r??0,await this._imageViewer.loadImage(o);break}case"panoramic":if(ae.has(n.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,await this._panoramicViewer.loadImage(o)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:n});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 re(d);let F=s;if(le(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 re({...h(e)?e.toJSON():e,spatialReference:oe.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 re(n,oe.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(se.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),se.click),this.removeHandles(se.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)}})),se.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)}})),se.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(se.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)}),se.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)}),se.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?H.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),t>0&&(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?.[H[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 re({...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 re({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 re(n,oe.WebMercator),symbol:q}),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 H)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=ee(t,n),l=te(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=s.find((e=>e.imageID===o[0].attributes.objectId)).clone();n&&!n.contains(o[0].geometry)&&n.addRing([o[0].geometry]);const l=n.extent;let h;if(this.footprintExtent=l,this.view?.supportsGround)try{h=await this.view.map.ground.createElevationSampler(l,i)}catch(p){g(p)||u.getLogger(this).error(p)}if(o[0].elevationSample=h,(h||o[0].attributes.elevationSource)&&l){const e=await k([t],{feature:o[0],footprintExtent:l,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:Y(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities);const c=this._suitabilities.map((e=>e.feature));this.currentBestFeature=c[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:J,visible:o}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e,symbol:$,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(Z);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:void 0))}}};e([_()],he.prototype,"activeLayer",null),e([_({readOnly:!0})],he.prototype,"activeViewer",null),e([_()],he.prototype,"additionalFeatures",void 0),e([_()],he.prototype,"bestFeatureAngle",void 0),e([_({type:Number})],he.prototype,"brightness",null),e([_({type:Number})],he.prototype,"contrast",null),e([_()],he.prototype,"coverageFrustums",void 0),e([_()],he.prototype,"coveragePolygons",void 0),e([_()],he.prototype,"currentBestFeature",void 0),e([_()],he.prototype,"currentCoverageVisible",void 0),e([_({json:{write:!1}})],he.prototype,"determineWorkflowForFeature",void 0),e([_()],he.prototype,"disabled",void 0),e([_()],he.prototype,"displayMessage",void 0),e([_()],he.prototype,"drawFootprint",void 0),e([_({readOnly:!0})],he.prototype,"featureCount",null),e([_()],he.prototype,"features",void 0),e([_({readOnly:!0})],he.prototype,"imageGalleryEnabled",null),e([_({readOnly:!0})],he.prototype,"imageLoaded",null),e([_()],he.prototype,"imagePointsInView",null),e([_()],he.prototype,"isAdditionalCoverageVisible",void 0),e([_()],he.prototype,"isAdditionalPointSourcesVisible",void 0),e([_()],he.prototype,"layer",void 0),e([_({type:Number})],he.prototype,"localPort",void 0),e([_()],he.prototype,"mapImageConversionToolState",void 0),e([_({readOnly:!0,value:"none"})],he.prototype,"mode",null),e([_()],he.prototype,"navigatorCurrentBestFeature",void 0),e([_()],he.prototype,"pointSources",void 0),e([_({readOnly:!0})],he.prototype,"popupEnabled",null),e([_()],he.prototype,"previousFeatureAngle",void 0),e([_()],he.prototype,"referencePoint",null),e([_({readOnly:!0})],he.prototype,"sectorData",null),e([_()],he.prototype,"selectedPoint",void 0),e([_({type:Number})],he.prototype,"sharpness",null),e([_()],he.prototype,"shouldShowSelectedImage",void 0),e([_({readOnly:!0})],he.prototype,"state",null),e([_({readOnly:!0})],he.prototype,"thumbnails",null),e([_()],he.prototype,"updateFootprint",void 0),e([_()],he.prototype,"updateFootprintPanorama",void 0),e([_({value:null})],he.prototype,"view",null),e([_()],he.prototype,"_adapter",void 0),e([_({type:s.ofType(t)})],he.prototype,"additionalFootprints",void 0),e([_({type:s.ofType(t)})],he.prototype,"additionalCameraLocations",void 0),e([_()],he.prototype,"bestFeatureCurrentFootprint",void 0),e([_()],he.prototype,"_fetchFeaturesController",void 0),e([_()],he.prototype,"_highlightedFeatureHandle",void 0),e([_()],he.prototype,"_imageViewer",void 0),e([_({type:t})],he.prototype,"bestFeatureFootprint",void 0),e([_()],he.prototype,"_initialCurrentCoverageUpdate",void 0),e([_()],he.prototype,"_loading",void 0),e([_()],he.prototype,"_overlays",void 0),e([_({readOnly:!0})],he.prototype,"_overlaysView",null),e([_()],he.prototype,"_panoramicViewer",void 0),e([_()],he.prototype,"_referencePointOnGround",void 0),e([_()],he.prototype,"_referencePointOnImage",void 0),e([_()],he.prototype,"currentBestFeatureLocation",void 0),e([_()],he.prototype,"_sectorData",void 0),e([_()],he.prototype,"footprintExtent",void 0),he=e([b("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],he);const ce=he;export{ce as default};
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 q,activeSourcePointSymbol as J,sourcePointSymbol as $}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;let n=s?e.match(he)?.[1]??"":e.datasetFormat;if(!n){const e=await K(a,{...t.options});e&&(n=e.split("/")[1]),n??="UNKNOWN FORMAT"}switch(i){case"default":{this._imageViewer.imageSource={datasetFormat:n.toUpperCase(),url:a};const e=new URL(a);this._imageViewer.customParameters=Object.fromEntries(e.searchParams),this._imageViewer.imageRotation=r??0,await this._imageViewer.loadImage(o);break}case"panoramic":this._loading=!0;if(le.has(n.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:n});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:q}),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:J,visible:o}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e,symbol:$,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};
@@ -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"../../../geometry.js";import e from"../../../Graphic.js";import{isSome as t}from"../../../core/arrayUtils.js";import i from"../../../core/Logger.js";import{waitTick as o,throwIfAborted as r,isAbortError as s}from"../../../core/promiseUtils.js";import{transformPoints as a}from"../../../layers/orientedImagery/transformations/imageToGroundUtils.js";import{convertOrientationToPixelLocation as n}from"../../../layers/orientedImagery/transformations/utils.js";import{activePolygonSymbol as l,polygonSymbol as m}from"../symbols.js";import c from"../../../geometry/Polygon.js";class p{constructor(p){this.viewModel=p,this.createFootprints=async t=>{await o(t);const{coveragePolygons:i,currentBestFeature:r,isAdditionalCoverageVisible:s}=this.viewModel;for(const o of i)o?.imageID===r.attributes.objectId?this.viewModel.bestFeatureFootprint=new e({attributes:{imageID:o?.imageID},geometry:o,symbol:l,visible:!1}):this.viewModel.additionalFootprints.push(new e({attributes:{imageID:o?.imageID},geometry:o,symbol:m.clone(),visible:s}))},this.updateFootprint=async(o,n)=>{const{activeViewer:m,currentBestFeature:p,currentCoverageVisible:g,footprintExtent:u}=this.viewModel,f=m?.imageSize;if(p&&f&&u)try{const i=await a(o,{feature:p,imageProperties:{width:f[0],height:f[1]},options:n,footprintExtent:u});r(n);const s=i.filter(t);if(!s.length)return;const m=[s.map((({x:e,y:t})=>[e,t,1]))];m[0].push(m[0][0]);const d=new c({rings:m,spatialReference:s[0].spatialReference});this.viewModel.updateCurrentCoveragePolygon(new e({geometry:d,attributes:{imageID:p.attributes.objectId},symbol:l,visible:g}))}catch(d){s(d)||i.getLogger(this.viewModel).error("update-footprint",d)}},this.updateFootprintPanorama=async(t,i)=>{const{horizontalFieldOfView:o,pitch:s,verticalFieldOfView:m,yaw:p}=t,{activeViewer:g,currentBestFeature:u,currentCoverageVisible:f,footprintExtent:d}=this.viewModel,h=g?.imageSize;if(!u||!h||!d)return;const{cameraPitch:y,objectId:w}=u.attributes;if(s+y-m/2>180)return void this.viewModel.updateCurrentCoveragePolygon(null);let v=[];if(s+y+m/2<180){v=[[-o/2,m/2],[o/2,m/2],...s-m/2<0?[[-o/2,-m/2],[o/2,-m/2]]:[[o/2,-m/2],[-o/2,-m/2]]]}else if(s+y-m/2<180&&s+y+m/2>180){v=[[-o/2,-m/2]];const e=o/6,t=o/e;for(let i=0;i<=e;i++)v.push([i*t-o/2,90-s]);v.push([o/2,-m/2])}const b=v.map((([e,t])=>n(p+e,s+t,h[0],h[1]))),j=await a(b,{feature:u,imageProperties:{width:h[0],height:h[1]},options:i,footprintExtent:d});r(i);const I=[j.map((({x:e,y:t})=>[e,t,1]))];I[0].push(I[0][0]);const F=new c({rings:I,spatialReference:j[0].spatialReference});this.viewModel.updateCurrentCoveragePolygon(new e({geometry:F,attributes:{imageID:w},symbol:l.clone(),visible:f}))}}}export{p as default};
5
+ import"../../../geometry.js";import e from"../../../Graphic.js";import{isSome as t}from"../../../core/arrayUtils.js";import i from"../../../core/Logger.js";import{waitTick as o,throwIfAborted as r,isAbortError as s}from"../../../core/promiseUtils.js";import{transformPoints as a}from"../../../layers/orientedImagery/transformations/imageToGroundUtils.js";import{convertOrientationToPixelLocation as n}from"../../../layers/orientedImagery/transformations/utils.js";import{activePolygonSymbol as l,polygonSymbol as m}from"../symbols.js";import c from"../../../geometry/Polygon.js";class p{constructor(p){this.viewModel=p,this.createFootprints=async t=>{await o(t);const{coveragePolygons:i,currentBestFeature:r,isAdditionalCoverageVisible:s}=this.viewModel;for(const o of i)o?.imageID===r.attributes.objectId?this.viewModel.bestFeatureFootprint=new e({attributes:{imageID:o?.imageID},geometry:o,symbol:l,visible:!1}):this.viewModel.additionalFootprints.push(new e({attributes:{imageID:o?.imageID},geometry:o,symbol:m.clone(),visible:s}))},this.updateFootprint=async(o,n)=>{const{activeViewer:m,currentBestFeature:p,currentCoverageVisible:g,footprintExtent:u}=this.viewModel,f=m?.imageSize;if(p&&f&&u)try{const i=await a(o,{feature:p,imageProperties:{width:f[0],height:f[1]},options:n,footprintExtent:u});r(n);const s=i.filter(t);if(!s.length)return;const m=[s.map((({x:e,y:t})=>[e,t,1]))];m[0].push(m[0][0]);const d=new c({rings:m,spatialReference:s[0].spatialReference});this.viewModel.updateCurrentCoveragePolygon(new e({geometry:d,attributes:{imageID:p.attributes.objectId},symbol:l,visible:g}))}catch(d){s(d)||i.getLogger(this.viewModel).error("update-footprint",d)}},this.updateFootprintPanorama=async(t,i)=>{const{horizontalFieldOfView:o,pitch:s,verticalFieldOfView:m,yaw:p}=t,{activeViewer:g,currentBestFeature:u,currentCoverageVisible:f,footprintExtent:d}=this.viewModel,h=g?.imageSize;if(!u||!h||!d)return;const{cameraPitch:y,objectId:w}=u.attributes;if(s+y-m/2>180)return void this.viewModel.updateCurrentCoveragePolygon(null);let v=[];if(s+y+m/2<180){v=[[-o/2,m/2],[o/2,m/2],...s-m/2<0?[[-o/2,-m/2],[o/2,-m/2]]:[[o/2,-m/2],[-o/2,-m/2]]]}else if(s+y-m/2<180&&s+y+m/2>180){v=[[-o/2,-m/2]];const e=Math.floor(o/6),t=o/e;for(let i=0;i<=e;i++)v.push([i*t-o/2,90-s]);v.push([o/2,-m/2])}const b=v.map((([e,t])=>n(p+e,s+t,h[0],h[1]))),j=await a(b,{feature:u,imageProperties:{width:h[0],height:h[1]},options:i,footprintExtent:d});r(i);const I=[j.map((({x:e,y:t})=>[e,t,1]))];I[0].push(I[0][0]);const F=new c({rings:I,spatialReference:j[0].spatialReference});this.viewModel.updateCurrentCoveragePolygon(new e({geometry:F,attributes:{imageID:w},symbol:l.clone(),visible:f}))}}}export{p 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 r from"../../request.js";import t from"../../core/Logger.js";import{sectorsRadii as e}from"./constants.js";function n(r){return"3d"===r?.type}function o(r){return"esri.Graphic"===r?.declaredClass}function i(r){return/.*\.(tif|mrf)$/i.test(r??"")}function s(r){return Math.abs(r)>=135?"WEST":r<-45&&r>-135?"SOUTH":r<=45?"EAST":"NORTH"}function u(r,t){const n=r/t*e[2];return n<=e[0]?"NEAR":n<=e[1]?"":"FAR"}function a(r){return r&&r.url&&r.datasetFormat?r:null}function c(r){return"string"==typeof r&&r.length?r:a(r)}function g(r){return"NoAttachmentError"===r?.name}const f=r=>`${r}:missing-property`,m=(r,t)=>`Property ${t} is missing in ${r}`,d=(r="esri.widgets.OrientedImageryViewer",e)=>{throw t.getLogger(r).error(e),e},p=async(e,n)=>{try{const t=await r(e,{...n,method:"head"});return t?.getHeader?.("Content-Type")}catch(o){return t.getLogger("esri.widgets.OrientedImagery").error("failed to fetch Content-Type",o),null}};export{s as calculateDirection,u as calculateSegment,c as castImageSource,a as castURLWithDatasetFormat,p as getContentType,m as getMissingPropertyErrorMessage,f as getMissingPropertyErrorName,o as isGraphic,g as isNoAttachmentError,n as isSceneView,i as isTifOrMrf,d as logAndThrow};
5
+ import t from"../../request.js";import r from"../../core/Logger.js";import{sectorsRadii as e}from"./constants.js";function n(t){return"3d"===t?.type}function o(t){return"esri.Graphic"===t?.declaredClass}function i(t){return/.*\.(tif|mrf)$/i.test(t??"")}function s(t){return Math.abs(t)>=135?"WEST":t<-45&&t>-135?"SOUTH":t<=45?"EAST":"NORTH"}function u(t,r){const n=t/r*e[2];return n<=e[0]?"NEAR":n<=e[1]?"":"FAR"}function a(t){return t&&t.url&&t.datasetFormat?t:null}function c(t){return"string"==typeof t&&t.length?t:a(t)}function m(t){return"NoAttachmentError"===t?.name}const f=t=>`${t}:missing-property`,g=(t,r)=>`Property ${r} is missing in ${t}`,d=(t="esri.widgets.OrientedImageryViewer",e)=>{throw r.getLogger(t).error(e),e},p=async(e,n)=>{try{const r=await t(e,{...n,method:"head"});return r?.getHeader?.("Content-Type")}catch(o){return r.getLogger("esri.widgets.OrientedImagery").error("failed to fetch Content-Type",o),null}};function y(t,r){0!==r&&(t.xmin/=r,t.xmax*=r,t.ymin/=r,t.ymax*=r)}export{s as calculateDirection,u as calculateSegment,c as castImageSource,a as castURLWithDatasetFormat,p as getContentType,g as getMissingPropertyErrorMessage,f as getMissingPropertyErrorName,o as isGraphic,m as isNoAttachmentError,n as isSceneView,i as isTifOrMrf,d as logAndThrow,y as scaleExtent};
@@ -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{prefersReducedMotion as t}from"../core/a11yUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import{deg2rad as a}from"../core/mathUtils.js";import{watch as s,initial as r}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{rotatePixel as c}from"../layers/orientedImagery/transformations/utils.js";import d from"../layers/support/rasterDatasets/RasterFactory.js";import h from"./Widget.js";import{getAllArcPath as g}from"./OrientedImageryViewer/arcUtils.js";import{css as m,segmentArcs as p,sectorsRadii as u,featureCircleRadius as v,navigation as b,navigationToolDimensionLength as y,navigationToolRotationFrom as w,navigationToolRotationTo as _,root as C}from"./OrientedImageryViewer/constants.js";import f from"./OrientedImageryViewer/OrientedImageryViewerViewModel.js";import M from"./OrientedImageryViewer/OrientedImageryViewerVisibleElements.js";import{loadCalciteComponents as I}from"./support/componentsUtils.js";import{globalCss as T}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as A}from"./support/decorators/messageBundle.js";import{tsx as E}from"./support/jsxFactory.js";import{substitute as k}from"../intl/substitute.js";let V=class extends h{constructor(e,t){super(e,t),this.dockEnabled=!1,this.galleryOpened=!1,this.imageEnhancementToolActive=!1,this.navigationToolActive=!1,this.viewModel=new f,this.messagesCommon=null,this.visibleElements=new M,this._navigationToolExpanded=!1,this._navigationTool=null,this._actionItems=new Map,this._galleryController=new AbortController,this._galleryObserver=new IntersectionObserver(this._lazyLoadImage.bind(this)),this._highlight=e=>{const t=e.target?.dataset.objectid;t&&this.viewModel.highlight(t)},this._removeHighlight=()=>this.viewModel.removeHighlight(),this._scaleNavigationTool=()=>{this._navigationToolExpanded=!this._navigationToolExpanded},this._toggleImageAttributes=()=>{this.viewModel.toggleImageAttributes()},this._loadImageFromGallery=this._loadImageFromGallery.bind(this),this._registerGalleryItem=this._registerGalleryItem.bind(this),this._unregisterGalleryItem=this._unregisterGalleryItem.bind(this),this._renderViewerContainer=this._renderViewerContainer.bind(this),this.loadImageFromSource=this.loadImageFromSource.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this)}initialize(){this.addHandles([s((()=>[this.viewModel?.bestFeatureAngle,this._navigationTool]),(([e,t])=>{t&&this._updateNavigationTool(t)}),r),s((()=>this.currentCoverageVisible),(e=>this._onCurrentCoverageVisibilityChange(e))),s((()=>this.isAdditionalCoverageVisible),(e=>this._onAdditionalCoverageVisibilityChange(e))),s((()=>this.isAdditionalPointSourcesVisible),(e=>this._onAdditionalCameraLocationsVisibility(e)))])}loadDependencies(){return I({tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js"),action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel.js"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider.js")})}destroy(){this._galleryController.abort(),this._galleryObserver.disconnect()}get activeLayer(){return i(o.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){i(o.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get currentBestFeature(){return this.viewModel.currentBestFeature}set currentBestFeature(e){this.viewModel.currentBestFeature=e}get currentCoverageVisible(){return this.viewModel.currentCoverageVisible}set currentCoverageVisible(e){this.viewModel.currentCoverageVisible=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get displayMessage(){return this.viewModel.displayMessage}set drawFootprint(e){this.viewModel.drawFootprint=e}get drawFootprint(){return this.viewModel.drawFootprint}get features(){return this.viewModel.features}get imagePointsInView(){return this.viewModel.imagePointsInView}get isDocked(){return i(o.getLogger(this),"isDocked",{replacement:"dockEnabled"}),this.dockEnabled}set isDocked(e){i(o.getLogger(this),"isDocked",{replacement:"dockEnabled"}),this.dockEnabled=e}get icon(){return"oriented-imagery-widget"}set icon(e){this._overrideIfSome("icon",e)}get imageGalleryEnabled(){return this.viewModel.imageGalleryEnabled}get isAdditionalCoverageVisible(){return this.viewModel.isAdditionalCoverageVisible}set isAdditionalCoverageVisible(e){this.viewModel.isAdditionalCoverageVisible=e}get isAdditionalPointSourcesVisible(){return this.viewModel.isAdditionalPointSourcesVisible}set isAdditionalPointSourcesVisible(e){this.viewModel.isAdditionalPointSourcesVisible=e}get mapImageConversionToolState(){return this.viewModel.mapImageConversionToolState}set mapImageConversionToolState(e){this.viewModel.mapImageConversionToolState=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get popupEnabled(){return this.viewModel.popupEnabled}get referencePoint(){return this.viewModel.referencePoint??null}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set determineWorkflowForFeature(e){this.viewModel.determineWorkflowForFeature=e}get determineWorkflowForFeature(){return this.viewModel.determineWorkflowForFeature}set updateFootprint(e){this.viewModel.updateFootprint=e}get updateFootprint(){return this.viewModel.updateFootprint}async _getThumbnailPixelBlockInternal(e,t){const{level:i,offset:a,size:s}=this._getMaxLevelRasterParameters(e);try{const{pixelBlock:o}=await e.fetchRawPixels(i,a,s,t);return o}catch(r){o.getLogger(this).warn("failed to create canvas with pixel data",r)}return null}_getMaxLevelRasterParameters(e){const{storageInfo:t,width:i,height:o}=e.rasterInfo,{maximumPyramidLevel:a,pyramidScalingFactor:s}=t,r=s??2;return{level:a,offset:{x:0,y:0},size:{width:Math.ceil(i/r**a),height:Math.ceil(o/r**a)}}}async _getThumbnailPixelBlock(e){const{signal:t}=this._galleryController;try{const i=await d.open({url:e,signal:t});return i?await this._getThumbnailPixelBlockInternal(i,{signal:t}):null}catch(i){o.getLogger(this).error("failed to create thumbnail",i)}return null}_handleBrightnessChange(e){this.viewModel.brightness=e.target.value??0}_handleContrastChange(e){this.viewModel.contrast=e.target.value??0}_handleSharpnessChange(e){this.viewModel.sharpness=e.target.value??0}_lazyLoadImage(e,t){e.forEach((async e=>{if(e.isIntersecting){const i=e.target,s=i.getAttribute("data-src"),r=i.getAttribute("data-rotation"),n=r?parseFloat(r)%360:null;if(!s)return;const l=await this._getThumbnailPixelBlock(s);if(!l)return;i.width=l.width,i.height=l.height;const d=i.getContext("2d");if(!d)return;const h=d.createImageData(i.width,i.height);if(h.data.set(l.getAsRGBA()),"number"==typeof n&&0!==n){const e=a(n),s=document.createElement("canvas"),r=s.getContext("2d");if(r){s.width=h.width,s.height=h.height,r.putImageData(h,0,0);const o=c(0,0,e),a=c(h.width,0,e),n=c(h.width,h.height,e),l=c(0,h.height,e),g=Math.max(o[0],a[0],n[0],l[0])-Math.min(o[0],a[0],n[0],l[0]),m=Math.max(o[1],a[1],n[1],l[1])-Math.min(o[1],a[1],n[1],l[1]),p=Math.min(i.width/g,i.height/m);return d.save(),d.clearRect(0,0,i.width,i.height),d.translate(i.width/2,i.height/2),d.rotate(e),d.scale(p,p),d.drawImage(s,-h.width/2,-h.height/2,h.width,h.height),d.restore(),t.unobserve(i)}o.getLogger(this).warn("oriented-imagery-viewer:image-gallery","failed to apply rotation on thumbnail")}d.putImageData(h,0,0),t.unobserve(i)}}))}_loadImageFromGallery(e){const{target:t}=e;if(!t)return;const i=t.getAttribute("data-objectid");i&&this.viewModel.currentBestFeature?.attributes.objectId!==Number(i)&&this.viewModel.selectBestFeature(i)}_onAdditionalCoverageVisibilityChange(e){this.viewModel.setAdditionalCoverageVisibility(e)}_onAdditionalCameraLocationsVisibility(e){this.viewModel.setAdditionalCameraLocationsVisibility(e)}_onCurrentCoverageVisibilityChange(e){this.viewModel.setCurrentCoverageVisibility(e)}_registerGalleryItem(e){this._galleryObserver.observe(e)}_renderActionTooltips(){return[...this._actionItems].map((([e,t])=>E("calcite-tooltip",{key:e,referenceElement:t},E("span",null,e))))}_renderBody(){return E("div",{class:m.body},this._renderViewerContainer(),this._renderImageGallery(),this._renderImageEnhancementTools(),this._renderNavigation())}_renderImageEnhancementTools(){const{imageEnhancementToolActive:e,viewModel:{brightness:t,contrast:i,sharpness:o}}=this;return e&&E("calcite-panel",{bind:this,class:m.imageEnhancementWrapper,closable:!0,closed:!e,heading:this.messages.imageEnhancement,key:this.messages.imageEnhancement,onCalcitePanelClose:this._toggleImageEnhancementToolState},E("div",{class:m.imageEnhancementTools},E("div",{class:m.imageEnhancementToolContainer},E("calcite-label",null,this.messages.brightness,E("calcite-slider",{bind:this,labelTicks:!0,max:10,min:-10,ticks:5,value:t,onCalciteSliderInput:this._handleBrightnessChange}))),E("div",{class:m.imageEnhancementToolContainer},E("calcite-label",null,this.messages.contrast,E("calcite-slider",{bind:this,labelTicks:!0,max:10,min:-10,ticks:5,value:i,onCalciteSliderInput:this._handleContrastChange}))),E("div",{class:m.imageEnhancementToolContainer},E("calcite-label",null,this.messages.sharpness,E("calcite-slider",{bind:this,labelTicks:!0,max:1,min:0,step:.1,ticks:.5,value:o,onCalciteSliderInput:this._handleSharpnessChange})))),E("calcite-action",{bind:this,icon:"reset",onclick:this._resetImageTools,slot:"header-actions-end",text:this.messagesCommon.reset}))}_renderImageGallery(){const{container:e,galleryOpened:t,imageGalleryEnabled:i,viewModel:{thumbnails:o}}=this;return i&&t&&(e&&o)?E("calcite-panel",{bind:this,class:m.carousel,closable:!0,closed:!t,heading:this.messages.imageGallery,key:this.messages.imageGallery,onCalcitePanelClose:this._toggleImageGallery},E("div",{class:m.carouselContainer},this._renderThumbnails(o))):null}_renderMapImageConversionTool(){const{mapImageConversionToolState:e,viewModel:{state:t}}=this;return E("calcite-action",{active:e,afterCreate:this._storeActionElement,bind:this,disabled:"image-loaded"!==t,icon:"image-pin",onclick:this._toggleMapImageConversionToolState,text:this.messages.mapImageConversionTool})}_renderNavigation(){const{viewModel:{sectorData:e,navigatorCurrentBestFeature:i,currentBestFeature:o,state:a}}=this;if(!this.container||!o)return null;let s,r,n,l,c;if(i){const{x:e,y:t,direction:o}=i,[a,d,h,g]=p[o];s=`M ${e} ${t} L ${a} ${d} A ${u[2]} ${u[2]} 0 0 1 ${h} ${g} Z`,r=e,l=t,n=p[o][4],c=p[o][5]}const d=e=>{const t=e.target.dataset?.sector;t&&this.viewModel.handleSectorClick(+t)},h=e=>{const t=e.target.dataset;if(!t)return;const{featureIndexInSector:i,sector:o}=t;i&&o&&this.viewModel.handleFeatureClick({sector:o,featureIndexInSector:+i})},w=e=>{e.removeEventListener("click",h)},_=o.attributes.objectId,C=e?.map((e=>e?.items)).filter(Boolean).flatMap((e=>e?.map((({x:e,y:t,objectID:i,featureIndexInSector:o,sector:a})=>E("circle",{afterRemoved:w,class:this.classes(m.feature,{selected:_===i}),cx:e,cy:t,"data-feature-index-in-sector":o,"data-sector":a,key:`${m.feature}-${i}`,onclick:h,r:v}))))),f=e=>{e.removeEventListener("click",d)},M=this.classes({[m.navigationWrapper]:!0,[m.navigationZoomed]:this._navigationToolExpanded});return this.navigationToolActive&&"image-loaded"===a?E("div",{bind:this,class:M,key:this.messages.navigationTool},E("svg",{afterCreate:e=>this._storeNavigationToolReference(e),class:t()?b:m.rotateWithAnimation,focusable:"false",height:y,role:"img",width:y,xmlns:"http://www.w3.org/2000/svg"},E("defs",null,E("linearGradient",{gradientUnits:"userSpaceOnUse",id:`${this.id}-coverage-fill`,x1:r,x2:n,y1:l,y2:c},E("stop",{class:m.navigationPathOffset0,offset:0}),E("stop",{class:m.navigationPathOffset1,offset:1}))),E("g",null,E("circle",{class:this.classes(m.sector,m.outerSector),cx:u[3],cy:u[3],onclick:this._scaleNavigationTool,r:u[3]}),E("circle",{class:m.sector,cx:u[3],cy:u[3],r:u[2]}),E("circle",{class:m.sector,cx:u[3],cy:u[3],r:u[1]}),E("circle",{class:m.sector,cx:u[3],cy:u[3],r:u[0]}),E("path",{class:m.pointer,d:"M 56.5 6.06217782649107 L 60 0 L 63.5 6.06217782649107 Z",key:`${m.pointer}-west`}),E("path",{class:this.classes(m.pointer,m.north),d:"M 113.93782217350893 56.5 L 120 60 L 113.93782217350893 63.5 Z",key:`${m.pointer}-north`}),E("path",{class:m.pointer,d:"M 56.5 113.93782217350893 L 60 120 L 63.5 113.93782217350893 Z",key:`${m.pointer}-east`}),E("path",{class:m.pointer,d:"M 6.06217782649107 56.5 L 0 60 L 6.06217782649107 63.5 Z",key:`${m.pointer}-south`}),E("path",{class:this.classes(m.sector,m.sectorSeparator),d:"M 23.937554159486076 23.937554159486076 L 96.06244584051393 96.06244584051393 M 23.937554159486076 96.06244584051393 L 96.06244584051393 23.937554159486076",key:m.sectorSeparator}),g([u[2],u[1],u[0]],u[3],u[3]).map(((t,i)=>E("path",{afterRemoved:f,class:this.classes(m.sector,e?.[i]?.length?m.sectorEnabled:m.sectorDisabled),d:t,"data-sector":`${i}`,key:`${m.sector}-${i}`,onclick:d}))),E("path",{class:this.classes(m.sector,m.sectorCross),d:"M 56.4 56.4 L 63.53 63.53 M 63.53 56.4 L 56.4 63.53",key:m.sectorCross}),C,o.attributes.cameraPitch>=5&&s?E("path",{class:m.selectedFeaturePath,d:s,fill:`url(#${this.id}-coverage-fill)`,key:m.selectedFeaturePath}):null))):null}_renderNavigationTool(){const{state:e}=this.viewModel;return E("calcite-action",{active:this.navigationToolActive,afterCreate:this._storeActionElement,bind:this,disabled:"image-loaded"!==e,icon:"explore",onclick:this._toggleNavigationTool,text:this.messages.navigationTool})}_renderImageEnhancementTool(){const{state:e,mode:t}=this.viewModel;return E("calcite-action",{active:this.imageEnhancementToolActive,afterCreate:this._storeActionElement,bind:this,disabled:"default"!==t||"image-loaded"!==e,icon:"sliders-horizontal",onclick:this._toggleImageEnhancementToolState,text:this.messages.imageEnhancement})}_renderMenuBarContainer(){const{currentCoverageVisible:e,isAdditionalCoverageVisible:t,isAdditionalPointSourcesVisible:i,imageGalleryEnabled:o}=this;return E("calcite-action-bar",{expandDisabled:!0,layout:"horizontal",slot:"action-bar"},E("calcite-action-group",{expanded:!0},E("calcite-action",{active:e,afterCreate:this._storeActionElement,bind:this,class:m.currentCoverage,icon:"trapezoid-area",onclick:this._toggleCurrentCoverage,text:this.messages.currentFootprint}),E("calcite-action",{active:t,afterCreate:this._storeActionElement,bind:this,class:m.addCoverage,icon:"trapezoid-area",onclick:this._toggleAdditionalCoverage,text:this.messages.additionalFootprints}),E("calcite-action",{active:i,afterCreate:this._storeActionElement,bind:this,class:m.addExpPoints,icon:"circle-area",onclick:this._toggleAdditionalCameraLocations,text:this.messages.additionalCameraLocations})),E("calcite-action-group",{layout:"horizontal"},this.visibleElements.mapImageConversionTool?this._renderMapImageConversionTool():null,this.visibleElements.navigationTool?this._renderNavigationTool():null,this.visibleElements.imageEnhancement?this._renderImageEnhancementTool():null),E("calcite-action-group",null,E("calcite-action",{active:this.galleryOpened,afterCreate:this._storeActionElement,bind:this,disabled:!o,icon:"images",onclick:this._toggleImageGallery,text:this.messages.imageGallery,textEnabled:!0}),this.visibleElements.showPopupsAction?this._renderPopupAction():null),this._renderActionTooltips())}_renderMessageBox(){const{messages:e,viewModel:{displayMessage:t}}=this;if(!t)return null;const{data:i,key:o,map:a}=t,s=`${a?k(e[o],a):e[o]}`;return E("span",{class:m.messageBox},i?`${s} ${i}`:s)}_renderPopupAction(){return E("calcite-action",{afterCreate:this._storeActionElement,bind:this,disabled:!this.popupEnabled,icon:"popup",onclick:this._toggleImageAttributes,text:this.messages.showPopups,textEnabled:!0})}_renderThumbnails(e){const{currentBestFeature:t}=this.viewModel;return t?E("div",{class:m.carouselContent},e.items.map((({url:e,objectId:i,rotation:o},a)=>E("div",{class:`${m.carouselItemWrapper}${t.attributes.objectId===i?"--selected":""}`,key:`${m.carouselItemWrapper}-${a}`},E("canvas",{afterCreate:this._registerGalleryItem,afterRemoved:this._unregisterGalleryItem,alt:`thumbnail-${i}`,class:m.carouselItem,"data-objectid":`${i}`,"data-rotation":`${o}`,"data-src":e,onclick:this._loadImageFromGallery,onmouseenter:this._highlight,onmouseleave:this._removeHighlight}))))):null}_renderViewerContainer(){return E("div",{class:m.viewerContainer},this._renderImageViewer(),this._renderPanoramicViewer(),this._renderMessageBox())}_renderImageViewer(){const{displayMessage:e,loadImageViewer:t,mode:i}=this.viewModel,o=`${m.viewer}${e||"default"!==i?"--hide":""}`;return E("calcite-panel",{afterCreate:t,bind:this,class:o})}_renderPanoramicViewer(){const{displayMessage:e,loadPanoramicViewer:t,mode:i}=this.viewModel,o=`${m.viewer}${e||"panoramic"!==i?"--hide":""}`;return E("calcite-panel",{afterCreate:t,bind:this,class:o})}_resetImageTools(){this.viewModel.sharpness=this.viewModel.brightness=this.viewModel.contrast=0}_storeActionElement(e){this._actionItems.set(e.text,e)}_storeNavigationToolReference(e){this._navigationTool=e}_toggleAdditionalCameraLocations(){this.isAdditionalPointSourcesVisible=!this.isAdditionalPointSourcesVisible}_toggleAdditionalCoverage(){this.isAdditionalCoverageVisible=!this.isAdditionalCoverageVisible}_toggleCurrentCoverage(){this.currentCoverageVisible=!this.currentCoverageVisible}_toggleImageEnhancementToolState(e){e.stopPropagation(),this.imageEnhancementToolActive=!this.imageEnhancementToolActive,this.imageEnhancementToolActive&&(this.galleryOpened&&(this.galleryOpened=!1),this.navigationToolActive&&(this.navigationToolActive=!1))}_toggleImageGallery(e){e.stopPropagation(),this.galleryOpened=!!this.imageGalleryEnabled&&!this.galleryOpened,this.galleryOpened&&(this.imageEnhancementToolActive&&(this.imageEnhancementToolActive=!1),this.navigationToolActive&&(this.navigationToolActive=!1))}_toggleNavigationTool(){this.navigationToolActive=!this.navigationToolActive,this.navigationToolActive&&(this.galleryOpened&&(this.galleryOpened=!1),this.imageEnhancementToolActive&&(this.imageEnhancementToolActive=!1))}_toggleMapImageConversionToolState(){this.mapImageConversionToolState=!this.mapImageConversionToolState}_unregisterGalleryItem(e){this._galleryObserver.unobserve(e)}_updateNavigationTool(e){const{previousFeatureAngle:t,bestFeatureAngle:i}=this.viewModel,o=(i-t+540)%360-180;e.style.setProperty(w,`${t}deg`),e.style.setProperty(_,`${t+o}deg`)}loadBestImage(e){this.viewModel.loadBestImage(e)}loadImageFromSource(e,t){return this.viewModel.loadImageFromSource(e,t)}async plotMapPoint(e){return this.viewModel.plotMapPoint(e)}plotReferencePointOnGround(e){this.viewModel.plotReferencePointOnGround(e)}plotReferencePointOnImage(e){this.viewModel.plotReferencePointOnImage(e)}resetImage(){this.viewModel.resetImage()}render(){const{dockEnabled:e,viewModel:{state:t}}=this;return E("div",{class:this.classes(T.widget,C)},E("calcite-panel",{bind:this,class:e?m.dock:m.float,heading:this.visibleElements.title?this.messages.title:void 0,loading:"image-loading"===t},this.visibleElements.coverageMenu?this._renderMenuBarContainer():null,this._renderBody()))}updateSuitabilities(e){this.viewModel.updateSuitabilities(e)}};e([n()],V.prototype,"activeLayer",null),e([n()],V.prototype,"currentBestFeature",null),e([n()],V.prototype,"currentCoverageVisible",null),e([n()],V.prototype,"disabled",null),e([n()],V.prototype,"dockEnabled",void 0),e([n()],V.prototype,"drawFootprint",null),e([n()],V.prototype,"features",null),e([n()],V.prototype,"imagePointsInView",null),e([n()],V.prototype,"isDocked",null),e([n()],V.prototype,"galleryOpened",void 0),e([n()],V.prototype,"icon",null),e([n()],V.prototype,"imageEnhancementToolActive",void 0),e([n({readOnly:!0})],V.prototype,"imageGalleryEnabled",null),e([n()],V.prototype,"isAdditionalCoverageVisible",null),e([n()],V.prototype,"isAdditionalPointSourcesVisible",null),e([n()],V.prototype,"mapImageConversionToolState",null),e([n()],V.prototype,"layer",null),e([n()],V.prototype,"navigationToolActive",void 0),e([n({type:f})],V.prototype,"viewModel",void 0),e([n(),A("esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer")],V.prototype,"messages",void 0),e([n(),A("esri/t9n/common")],V.prototype,"messagesCommon",void 0),e([n({readOnly:!0})],V.prototype,"popupEnabled",null),e([n()],V.prototype,"referencePoint",null),e([n()],V.prototype,"view",null),e([n({type:M,nonNullable:!0})],V.prototype,"visibleElements",void 0),e([n()],V.prototype,"determineWorkflowForFeature",null),e([n()],V.prototype,"updateFootprint",null),e([n()],V.prototype,"_navigationToolExpanded",void 0),e([n()],V.prototype,"_navigationTool",void 0),V=e([l("esri.widgets.OrientedImageryViewer")],V);const x=V;export{x as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{prefersReducedMotion as t}from"../core/a11yUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import{deg2rad as a}from"../core/mathUtils.js";import{watch as s,initial as r}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{rotatePixel as c}from"../layers/orientedImagery/transformations/utils.js";import d from"../layers/support/rasterDatasets/RasterFactory.js";import h from"./Widget.js";import{getAllArcPath as g}from"./OrientedImageryViewer/arcUtils.js";import{css as m,segmentArcs as p,sectorsRadii as u,featureCircleRadius as v,navigation as b,navigationToolDimensionLength as y,navigationToolRotationFrom as w,navigationToolRotationTo as _,root as C}from"./OrientedImageryViewer/constants.js";import f from"./OrientedImageryViewer/OrientedImageryViewerViewModel.js";import M from"./OrientedImageryViewer/OrientedImageryViewerVisibleElements.js";import{loadCalciteComponents as I}from"./support/componentsUtils.js";import{globalCss as T}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as A}from"./support/decorators/messageBundle.js";import{tsx as E}from"./support/jsxFactory.js";import{substitute as k}from"../intl/substitute.js";let V=class extends h{constructor(e,t){super(e,t),this.dockEnabled=!1,this.galleryOpened=!1,this.imageEnhancementToolActive=!1,this.navigationToolActive=!1,this.viewModel=new f,this.messagesCommon=null,this.visibleElements=new M,this._navigationToolExpanded=!1,this._navigationTool=null,this._actionItems=new Map,this._galleryController=new AbortController,this._galleryObserver=new IntersectionObserver(this._lazyLoadImage.bind(this)),this._highlight=e=>{const t=e.target?.dataset.objectid;t&&this.viewModel.highlight(t)},this._removeHighlight=()=>this.viewModel.removeHighlight(),this._scaleNavigationTool=()=>{this._navigationToolExpanded=!this._navigationToolExpanded},this._toggleImageAttributes=()=>{this.viewModel.toggleImageAttributes()},this._loadImageFromGallery=this._loadImageFromGallery.bind(this),this._registerGalleryItem=this._registerGalleryItem.bind(this),this._unregisterGalleryItem=this._unregisterGalleryItem.bind(this),this._renderViewerContainer=this._renderViewerContainer.bind(this),this.loadImageFromSource=this.loadImageFromSource.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this)}initialize(){this.addHandles([s((()=>[this.viewModel?.bestFeatureAngle,this._navigationTool]),(([e,t])=>{t&&this._updateNavigationTool(t)}),r),s((()=>this.currentCoverageVisible),(e=>this._onCurrentCoverageVisibilityChange(e))),s((()=>this.isAdditionalCoverageVisible),(e=>this._onAdditionalCoverageVisibilityChange(e))),s((()=>this.isAdditionalPointSourcesVisible),(e=>this._onAdditionalCameraLocationsVisibility(e)))])}loadDependencies(){return I({tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js"),action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel.js"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider.js")})}destroy(){this._galleryController.abort(),this._galleryObserver.disconnect()}get activeLayer(){return i(o.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){i(o.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get currentBestFeature(){return this.viewModel.currentBestFeature}set currentBestFeature(e){this.viewModel.currentBestFeature=e}get currentCoverageVisible(){return this.viewModel.currentCoverageVisible}set currentCoverageVisible(e){this.viewModel.currentCoverageVisible=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get displayMessage(){return this.viewModel.displayMessage}set drawFootprint(e){this.viewModel.drawFootprint=e}get drawFootprint(){return this.viewModel.drawFootprint}get features(){return this.viewModel.features}get imagePointsInView(){return this.viewModel.imagePointsInView}get isDocked(){return i(o.getLogger(this),"isDocked",{replacement:"dockEnabled"}),this.dockEnabled}set isDocked(e){i(o.getLogger(this),"isDocked",{replacement:"dockEnabled"}),this.dockEnabled=e}get icon(){return"oriented-imagery-widget"}set icon(e){this._overrideIfSome("icon",e)}get imageGalleryEnabled(){return this.viewModel.imageGalleryEnabled}get isAdditionalCoverageVisible(){return this.viewModel.isAdditionalCoverageVisible}set isAdditionalCoverageVisible(e){this.viewModel.isAdditionalCoverageVisible=e}get isAdditionalPointSourcesVisible(){return this.viewModel.isAdditionalPointSourcesVisible}set isAdditionalPointSourcesVisible(e){this.viewModel.isAdditionalPointSourcesVisible=e}get mapImageConversionToolState(){return this.viewModel.mapImageConversionToolState}set mapImageConversionToolState(e){this.viewModel.mapImageConversionToolState=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get popupEnabled(){const{popupEnabled:e,state:t}=this.viewModel;return"image-loaded"===t&&e}get referencePoint(){return this.viewModel.referencePoint??null}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set determineWorkflowForFeature(e){this.viewModel.determineWorkflowForFeature=e}get determineWorkflowForFeature(){return this.viewModel.determineWorkflowForFeature}set updateFootprint(e){this.viewModel.updateFootprint=e}get updateFootprint(){return this.viewModel.updateFootprint}async _getThumbnailPixelBlockInternal(e,t){const{level:i,offset:a,size:s}=this._getMaxLevelRasterParameters(e);try{const{pixelBlock:o}=await e.fetchRawPixels(i,a,s,t);return o}catch(r){o.getLogger(this).warn("failed to create canvas with pixel data",r)}return null}_getMaxLevelRasterParameters(e){const{storageInfo:t,width:i,height:o}=e.rasterInfo,{maximumPyramidLevel:a,pyramidScalingFactor:s}=t,r=s??2;return{level:a,offset:{x:0,y:0},size:{width:Math.ceil(i/r**a),height:Math.ceil(o/r**a)}}}async _getThumbnailPixelBlock(e){const{signal:t}=this._galleryController;try{const i=await d.open({url:e,signal:t});return i?await this._getThumbnailPixelBlockInternal(i,{signal:t}):null}catch(i){o.getLogger(this).error("failed to create thumbnail",i)}return null}_handleBrightnessChange(e){this.viewModel.brightness=e.target.value??0}_handleContrastChange(e){this.viewModel.contrast=e.target.value??0}_handleSharpnessChange(e){this.viewModel.sharpness=e.target.value??0}_lazyLoadImage(e,t){e.forEach((async e=>{if(e.isIntersecting){const i=e.target,s=i.getAttribute("data-src"),r=i.getAttribute("data-rotation"),n=r?parseFloat(r)%360:null;if(!s)return;const l=await this._getThumbnailPixelBlock(s);if(!l)return;i.width=l.width,i.height=l.height;const d=i.getContext("2d");if(!d)return;const h=d.createImageData(i.width,i.height);if(h.data.set(l.getAsRGBA()),"number"==typeof n&&0!==n){const e=a(n),s=document.createElement("canvas"),r=s.getContext("2d");if(r){s.width=h.width,s.height=h.height,r.putImageData(h,0,0);const o=c(0,0,e),a=c(h.width,0,e),n=c(h.width,h.height,e),l=c(0,h.height,e),g=Math.max(o[0],a[0],n[0],l[0])-Math.min(o[0],a[0],n[0],l[0]),m=Math.max(o[1],a[1],n[1],l[1])-Math.min(o[1],a[1],n[1],l[1]),p=Math.min(i.width/g,i.height/m);return d.save(),d.clearRect(0,0,i.width,i.height),d.translate(i.width/2,i.height/2),d.rotate(e),d.scale(p,p),d.drawImage(s,-h.width/2,-h.height/2,h.width,h.height),d.restore(),t.unobserve(i)}o.getLogger(this).warn("oriented-imagery-viewer:image-gallery","failed to apply rotation on thumbnail")}d.putImageData(h,0,0),t.unobserve(i)}}))}_loadImageFromGallery(e){const{target:t}=e;if(!t)return;const i=t.getAttribute("data-objectid");i&&this.viewModel.currentBestFeature?.attributes.objectId!==Number(i)&&this.viewModel.selectBestFeature(i)}_onAdditionalCoverageVisibilityChange(e){this.viewModel.setAdditionalCoverageVisibility(e)}_onAdditionalCameraLocationsVisibility(e){this.viewModel.setAdditionalCameraLocationsVisibility(e)}_onCurrentCoverageVisibilityChange(e){this.viewModel.setCurrentCoverageVisibility(e)}_registerGalleryItem(e){this._galleryObserver.observe(e)}_renderActionTooltips(){return[...this._actionItems].map((([e,t])=>E("calcite-tooltip",{key:e,referenceElement:t},E("span",null,e))))}_renderBody(){return E("div",{class:m.body},this._renderViewerContainer(),this._renderImageGallery(),this._renderImageEnhancementTools(),this._renderNavigation())}_renderImageEnhancementTools(){const{imageEnhancementToolActive:e,viewModel:{brightness:t,contrast:i,sharpness:o}}=this;return e&&E("calcite-panel",{bind:this,class:m.imageEnhancementWrapper,closable:!0,closed:!e,heading:this.messages.imageEnhancement,key:this.messages.imageEnhancement,onCalcitePanelClose:this._toggleImageEnhancementToolState},E("div",{class:m.imageEnhancementTools},E("div",{class:m.imageEnhancementToolContainer},E("calcite-label",null,this.messages.brightness,E("calcite-slider",{bind:this,labelTicks:!0,max:10,min:-10,ticks:5,value:t,onCalciteSliderInput:this._handleBrightnessChange}))),E("div",{class:m.imageEnhancementToolContainer},E("calcite-label",null,this.messages.contrast,E("calcite-slider",{bind:this,labelTicks:!0,max:10,min:-10,ticks:5,value:i,onCalciteSliderInput:this._handleContrastChange}))),E("div",{class:m.imageEnhancementToolContainer},E("calcite-label",null,this.messages.sharpness,E("calcite-slider",{bind:this,labelTicks:!0,max:1,min:0,step:.1,ticks:.5,value:o,onCalciteSliderInput:this._handleSharpnessChange})))),E("calcite-action",{bind:this,icon:"reset",onclick:this._resetImageTools,slot:"header-actions-end",text:this.messagesCommon.reset}))}_renderImageGallery(){const{container:e,galleryOpened:t,imageGalleryEnabled:i,viewModel:{thumbnails:o}}=this;return i&&t&&(e&&o)?E("calcite-panel",{bind:this,class:m.carousel,closable:!0,closed:!t,heading:this.messages.imageGallery,key:this.messages.imageGallery,onCalcitePanelClose:this._toggleImageGallery},E("div",{class:m.carouselContainer},this._renderThumbnails(o))):null}_renderMapImageConversionTool(){const{mapImageConversionToolState:e,viewModel:{state:t}}=this;return E("calcite-action",{active:e,afterCreate:this._storeActionElement,bind:this,disabled:"image-loaded"!==t,icon:"image-pin",onclick:this._toggleMapImageConversionToolState,text:this.messages.mapImageConversionTool})}_renderNavigation(){const{viewModel:{sectorData:e,navigatorCurrentBestFeature:i,currentBestFeature:o,state:a}}=this;if(!this.container||!o)return null;let s,r,n,l,c;if(i){const{x:e,y:t,direction:o}=i,[a,d,h,g]=p[o];s=`M ${e} ${t} L ${a} ${d} A ${u[2]} ${u[2]} 0 0 1 ${h} ${g} Z`,r=e,l=t,n=p[o][4],c=p[o][5]}const d=e=>{const t=e.target.dataset?.sector;t&&this.viewModel.handleSectorClick(+t)},h=e=>{const t=e.target.dataset;if(!t)return;const{featureIndexInSector:i,sector:o}=t;i&&o&&this.viewModel.handleFeatureClick({sector:o,featureIndexInSector:+i})},w=e=>{e.removeEventListener("click",h)},_=o.attributes.objectId,C=e?.map((e=>e?.items)).filter(Boolean).flatMap((e=>e?.map((({x:e,y:t,objectID:i,featureIndexInSector:o,sector:a})=>E("circle",{afterRemoved:w,class:this.classes(m.feature,{selected:_===i}),cx:e,cy:t,"data-feature-index-in-sector":o,"data-sector":a,key:`${m.feature}-${i}`,onclick:h,r:v}))))),f=e=>{e.removeEventListener("click",d)},M=this.classes({[m.navigationWrapper]:!0,[m.navigationZoomed]:this._navigationToolExpanded});return this.navigationToolActive&&"image-loaded"===a?E("div",{bind:this,class:M,key:this.messages.navigationTool},E("svg",{afterCreate:e=>this._storeNavigationToolReference(e),class:t()?b:m.rotateWithAnimation,focusable:"false",height:y,role:"img",width:y,xmlns:"http://www.w3.org/2000/svg"},E("defs",null,E("linearGradient",{gradientUnits:"userSpaceOnUse",id:`${this.id}-coverage-fill`,x1:r,x2:n,y1:l,y2:c},E("stop",{class:m.navigationPathOffset0,offset:0}),E("stop",{class:m.navigationPathOffset1,offset:1}))),E("g",null,E("circle",{class:this.classes(m.sector,m.outerSector),cx:u[3],cy:u[3],onclick:this._scaleNavigationTool,r:u[3]}),E("circle",{class:m.sector,cx:u[3],cy:u[3],r:u[2]}),E("circle",{class:m.sector,cx:u[3],cy:u[3],r:u[1]}),E("circle",{class:m.sector,cx:u[3],cy:u[3],r:u[0]}),E("path",{class:m.pointer,d:"M 56.5 6.06217782649107 L 60 0 L 63.5 6.06217782649107 Z",key:`${m.pointer}-west`}),E("path",{class:this.classes(m.pointer,m.north),d:"M 113.93782217350893 56.5 L 120 60 L 113.93782217350893 63.5 Z",key:`${m.pointer}-north`}),E("path",{class:m.pointer,d:"M 56.5 113.93782217350893 L 60 120 L 63.5 113.93782217350893 Z",key:`${m.pointer}-east`}),E("path",{class:m.pointer,d:"M 6.06217782649107 56.5 L 0 60 L 6.06217782649107 63.5 Z",key:`${m.pointer}-south`}),E("path",{class:this.classes(m.sector,m.sectorSeparator),d:"M 23.937554159486076 23.937554159486076 L 96.06244584051393 96.06244584051393 M 23.937554159486076 96.06244584051393 L 96.06244584051393 23.937554159486076",key:m.sectorSeparator}),g([u[2],u[1],u[0]],u[3],u[3]).map(((t,i)=>E("path",{afterRemoved:f,class:this.classes(m.sector,e?.[i]?.length?m.sectorEnabled:m.sectorDisabled),d:t,"data-sector":`${i}`,key:`${m.sector}-${i}`,onclick:d}))),E("path",{class:this.classes(m.sector,m.sectorCross),d:"M 56.4 56.4 L 63.53 63.53 M 63.53 56.4 L 56.4 63.53",key:m.sectorCross}),C,o.attributes.cameraPitch>=5&&s?E("path",{class:m.selectedFeaturePath,d:s,fill:`url(#${this.id}-coverage-fill)`,key:m.selectedFeaturePath}):null))):null}_renderNavigationTool(){const{state:e}=this.viewModel;return E("calcite-action",{active:this.navigationToolActive,afterCreate:this._storeActionElement,bind:this,disabled:"image-loaded"!==e,icon:"explore",onclick:this._toggleNavigationTool,text:this.messages.navigationTool})}_renderImageEnhancementTool(){const{state:e,mode:t}=this.viewModel;return E("calcite-action",{active:this.imageEnhancementToolActive,afterCreate:this._storeActionElement,bind:this,disabled:"default"!==t||"image-loaded"!==e,icon:"sliders-horizontal",onclick:this._toggleImageEnhancementToolState,text:this.messages.imageEnhancement})}_renderMenuBarContainer(){const{currentCoverageVisible:e,isAdditionalCoverageVisible:t,isAdditionalPointSourcesVisible:i,imageGalleryEnabled:o}=this;return E("calcite-action-bar",{expandDisabled:!0,layout:"horizontal",slot:"action-bar"},E("calcite-action-group",{expanded:!0},E("calcite-action",{active:e,afterCreate:this._storeActionElement,bind:this,class:m.currentCoverage,icon:"trapezoid-area",onclick:this._toggleCurrentCoverage,text:this.messages.currentFootprint}),E("calcite-action",{active:t,afterCreate:this._storeActionElement,bind:this,class:m.addCoverage,icon:"trapezoid-area",onclick:this._toggleAdditionalCoverage,text:this.messages.additionalFootprints}),E("calcite-action",{active:i,afterCreate:this._storeActionElement,bind:this,class:m.addExpPoints,icon:"circle-area",onclick:this._toggleAdditionalCameraLocations,text:this.messages.additionalCameraLocations})),E("calcite-action-group",{layout:"horizontal"},this.visibleElements.mapImageConversionTool?this._renderMapImageConversionTool():null,this.visibleElements.navigationTool?this._renderNavigationTool():null,this.visibleElements.imageEnhancement?this._renderImageEnhancementTool():null),E("calcite-action-group",null,E("calcite-action",{active:this.galleryOpened,afterCreate:this._storeActionElement,bind:this,disabled:!o,icon:"images",onclick:this._toggleImageGallery,text:this.messages.imageGallery,textEnabled:!0}),this.visibleElements.showPopupsAction?this._renderPopupAction():null),this._renderActionTooltips())}_renderMessageBox(){const{messages:e,viewModel:{displayMessage:t}}=this;if(!t)return null;const{data:i,key:o,map:a}=t,s=`${a?k(e[o],a):e[o]}`;return E("span",{class:m.messageBox},i?`${s} ${i}`:s)}_renderPopupAction(){return E("calcite-action",{afterCreate:this._storeActionElement,bind:this,disabled:!this.popupEnabled,icon:"popup",onclick:this._toggleImageAttributes,text:this.messages.showPopups,textEnabled:!0})}_renderThumbnails(e){const{currentBestFeature:t}=this.viewModel;return t?E("div",{class:m.carouselContent},e.items.map((({url:e,objectId:i,rotation:o},a)=>E("div",{class:`${m.carouselItemWrapper}${t.attributes.objectId===i?"--selected":""}`,key:`${m.carouselItemWrapper}-${a}`},E("canvas",{afterCreate:this._registerGalleryItem,afterRemoved:this._unregisterGalleryItem,alt:`thumbnail-${i}`,class:m.carouselItem,"data-objectid":`${i}`,"data-rotation":`${o}`,"data-src":e,onclick:this._loadImageFromGallery,onmouseenter:this._highlight,onmouseleave:this._removeHighlight}))))):null}_renderViewerContainer(){return E("div",{class:m.viewerContainer},this._renderImageViewer(),this._renderPanoramicViewer(),this._renderMessageBox())}_renderImageViewer(){const{displayMessage:e,loadImageViewer:t,mode:i}=this.viewModel,o=`${m.viewer}${e||"default"!==i?"--hide":""}`;return E("calcite-panel",{afterCreate:t,bind:this,class:o})}_renderPanoramicViewer(){const{displayMessage:e,loadPanoramicViewer:t,mode:i}=this.viewModel,o=`${m.viewer}${e||"panoramic"!==i?"--hide":""}`;return E("calcite-panel",{afterCreate:t,bind:this,class:o})}_resetImageTools(){this.viewModel.sharpness=this.viewModel.brightness=this.viewModel.contrast=0}_storeActionElement(e){this._actionItems.set(e.text,e)}_storeNavigationToolReference(e){this._navigationTool=e}_toggleAdditionalCameraLocations(){this.isAdditionalPointSourcesVisible=!this.isAdditionalPointSourcesVisible}_toggleAdditionalCoverage(){this.isAdditionalCoverageVisible=!this.isAdditionalCoverageVisible}_toggleCurrentCoverage(){this.currentCoverageVisible=!this.currentCoverageVisible}_toggleImageEnhancementToolState(e){e.stopPropagation(),this.imageEnhancementToolActive=!this.imageEnhancementToolActive,this.imageEnhancementToolActive&&(this.galleryOpened&&(this.galleryOpened=!1),this.navigationToolActive&&(this.navigationToolActive=!1))}_toggleImageGallery(e){e.stopPropagation(),this.galleryOpened=!!this.imageGalleryEnabled&&!this.galleryOpened,this.galleryOpened&&(this.imageEnhancementToolActive&&(this.imageEnhancementToolActive=!1),this.navigationToolActive&&(this.navigationToolActive=!1))}_toggleNavigationTool(){this.navigationToolActive=!this.navigationToolActive,this.navigationToolActive&&(this.galleryOpened&&(this.galleryOpened=!1),this.imageEnhancementToolActive&&(this.imageEnhancementToolActive=!1))}_toggleMapImageConversionToolState(){this.mapImageConversionToolState=!this.mapImageConversionToolState}_unregisterGalleryItem(e){this._galleryObserver.unobserve(e)}_updateNavigationTool(e){const{previousFeatureAngle:t,bestFeatureAngle:i}=this.viewModel,o=(i-t+540)%360-180;e.style.setProperty(w,`${t}deg`),e.style.setProperty(_,`${t+o}deg`)}loadBestImage(e){this.viewModel.loadBestImage(e)}loadImageFromSource(e,t){return this.viewModel.loadImageFromSource(e,t)}async plotMapPoint(e){return this.viewModel.plotMapPoint(e)}plotReferencePointOnGround(e){this.viewModel.plotReferencePointOnGround(e)}plotReferencePointOnImage(e){this.viewModel.plotReferencePointOnImage(e)}resetImage(){this.viewModel.resetImage()}render(){const{dockEnabled:e,viewModel:{state:t}}=this;return E("div",{class:this.classes(T.widget,C)},E("calcite-panel",{bind:this,class:e?m.dock:m.float,heading:this.visibleElements.title?this.messages.title:void 0,loading:"image-loading"===t},this.visibleElements.coverageMenu?this._renderMenuBarContainer():null,this._renderBody()))}updateSuitabilities(e){this.viewModel.updateSuitabilities(e)}};e([n()],V.prototype,"activeLayer",null),e([n()],V.prototype,"currentBestFeature",null),e([n()],V.prototype,"currentCoverageVisible",null),e([n()],V.prototype,"disabled",null),e([n()],V.prototype,"dockEnabled",void 0),e([n()],V.prototype,"drawFootprint",null),e([n()],V.prototype,"features",null),e([n()],V.prototype,"imagePointsInView",null),e([n()],V.prototype,"isDocked",null),e([n()],V.prototype,"galleryOpened",void 0),e([n()],V.prototype,"icon",null),e([n()],V.prototype,"imageEnhancementToolActive",void 0),e([n({readOnly:!0})],V.prototype,"imageGalleryEnabled",null),e([n()],V.prototype,"isAdditionalCoverageVisible",null),e([n()],V.prototype,"isAdditionalPointSourcesVisible",null),e([n()],V.prototype,"mapImageConversionToolState",null),e([n()],V.prototype,"layer",null),e([n()],V.prototype,"navigationToolActive",void 0),e([n({type:f})],V.prototype,"viewModel",void 0),e([n(),A("esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer")],V.prototype,"messages",void 0),e([n(),A("esri/t9n/common")],V.prototype,"messagesCommon",void 0),e([n({readOnly:!0})],V.prototype,"popupEnabled",null),e([n()],V.prototype,"referencePoint",null),e([n()],V.prototype,"view",null),e([n({type:M,nonNullable:!0})],V.prototype,"visibleElements",void 0),e([n()],V.prototype,"determineWorkflowForFeature",null),e([n()],V.prototype,"updateFootprint",null),e([n()],V.prototype,"_navigationToolExpanded",void 0),e([n()],V.prototype,"_navigationTool",void 0),V=e([l("esri.widgets.OrientedImageryViewer")],V);const x=V;export{x 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 V}from"../../layers/orientedImagery/transformations/utils.js";import C from"../../views/SceneView.js";import M from"../Zoom.js";import{logAndThrow as j,getMissingPropertyErrorName as z,getMissingPropertyErrorMessage as R}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as P}from"./constants.js";import H from"./PanoramicZoomConditions.js";import b from"./PanoramicZoomViewModel.js";import{meshToGraphic as S,createImageSphere as O}from"./utils.js";import x from"../../geometry/SpatialReference.js";const k={autoLoad:"auto-load",default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let I=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.maxHFOV=120,this.minHFOV=50,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(k.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()}))],k.navigation)},this._addHFOVHandles=()=>{this.removeHandles(k.fovConstraint),this.addHandles(g((()=>[this.maxHFOV,this.minHFOV]),(()=>{this._zoomViewModel&&(this._zoomViewModel.panoramicZoomConditions=new H({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))}),u),k.fovConstraint)},this._addZoomHandles=()=>{this._zoomViewModel=new b({view:this.imageRenderer,panoramicZoomConditions:new H({maxFOV:this.maxHFOV,minFOV:this.minHFOV})});const e=new M({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=V(e.mapPoint,this.imageSize[0],this.imageSize[1]);this.emit("pixel-location",{...t,spatialReference:x.WebMercator,meshVertex:e.mapPoint});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 C({map:this._map,viewingMode:"local",camera:{position:P},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:x.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(k.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))}),u)],k.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 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){return await p(t),this._imageGraphic=S(O(e)),this._graphics.add(this._imageGraphic),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):j(this.declaredClass,new s(z("panoramic-viewer"),R("PanoramicViewerViewModel","imageSource")))}};e([y()],I.prototype,"_graphics",void 0),e([y()],I.prototype,"_imageGraphic",void 0),e([y()],I.prototype,"_imageRenderer",void 0),e([y()],I.prototype,"_loadController",void 0),e([y()],I.prototype,"_map",void 0),e([y()],I.prototype,"_zoomViewModel",void 0),e([y({type:Boolean})],I.prototype,"autoLoad",void 0),e([y({type:t})],I.prototype,"camera",null),e([v(new h({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],I.prototype,"clickAction",void 0),e([y({type:Number})],I.prototype,"fov",null),e([y({readOnly:!0})],I.prototype,"hfov",null),e([y({type:Number})],I.prototype,"maxHFOV",void 0),e([y({type:Number})],I.prototype,"minHFOV",void 0),e([y()],I.prototype,"imageSize",void 0),e([y()],I.prototype,"imageSource",void 0),e([y({type:Number})],I.prototype,"pitch",void 0),e([y({readOnly:!0})],I.prototype,"imageRenderer",null),e([y()],I.prototype,"state",void 0),e([y({readOnly:!0})],I.prototype,"vfov",null),e([y({type:Number})],I.prototype,"yaw",void 0),I=e([f("esri.widgets.PanoramicViewer.PanoramicViewerViewModel")],I);const F=I;export{F as default};
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 V}from"../../layers/orientedImagery/transformations/utils.js";import z from"../../views/SceneView.js";import R 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 x from"./PanoramicZoomViewModel.js";import{findDiagonalFOV as k,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 x({view:this.imageRenderer,panoramicZoomConditions:new b({maxFOV:this.maxHFOV,minFOV:this.minHFOV})});const e=new R({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=V(e.mapPoint,this.imageSize[0],this.imageSize[1]);this.emit("pixel-location",{...t,spatialReference:G.WebMercator,meshVertex:e.mapPoint});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 z({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 k(H,e/t)}get minHFOV(){const{size:[e,t]}=this.imageRenderer;return k(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=k(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"../../geometry.js";import e from"../../geometry/Point.js";import r from"../../geometry/SpatialReference.js";const o=new e({x:0,y:0,z:0,spatialReference:r.WebMercator}),t=1e3;export{o as defaultImageSphereCenter,t as defaultImageSphereSize};
5
+ import"../../geometry.js";import e from"../../geometry/Point.js";import r from"../../geometry/SpatialReference.js";const o=new e({x:0,y:0,z:0,spatialReference:r.WebMercator}),t=1e3,m=114,i=120,p=50;export{o as defaultImageSphereCenter,t as defaultImageSphereSize,m as humanBinocularHFOV,i as maxPanoramicViewerHFOV,p as minPanoramicViewerHFOV};
@@ -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"../../Graphic.js";import"../../symbols.js";import t from"../../core/Collection.js";import r from"../../geometry/Mesh.js";import o from"../../geometry/support/MeshMaterial.js";import s from"../../geometry/support/MeshTexture.js";import{defaultImageSphereSize as m,defaultImageSphereCenter as i}from"./constants.js";import n from"../../symbols/MeshSymbol3D.js";import u from"../../symbols/FillSymbol3DLayer.js";function c(e,t=i,n=m){const u=t.clone();u.z=-m/2;const c=r.createSphere(u,{size:n,densificationFactor:2,vertexSpace:"georeferenced",material:new o({colorTexture:new s({data:e})})});if(c.components[0].trustSourceNormals=!0,c.vertexAttributes.uv){const e=c.vertexAttributes.uv.length??0;for(let t=0;t<e;t++)c.vertexAttributes.uv[2*t+0]=1-c.vertexAttributes.uv[2*t+0],c.vertexAttributes.uv[2*t+1]=c.vertexAttributes.uv[2*t+1]}return c.centerAt(u),c}function l(r){return new e({geometry:r,symbol:new n({symbolLayers:new t([new u])})})}export{c as createImageSphere,l as meshToGraphic};
5
+ import t from"../../Graphic.js";import"../../symbols.js";import e from"../../core/Collection.js";import{rad2deg as r,deg2rad as o}from"../../core/mathUtils.js";import s from"../../geometry/Mesh.js";import m from"../../geometry/support/MeshMaterial.js";import n from"../../geometry/support/MeshTexture.js";import{defaultImageSphereSize as i,defaultImageSphereCenter as u}from"./constants.js";import a from"../../symbols/MeshSymbol3D.js";import c from"../../symbols/FillSymbol3DLayer.js";function l(t,e=u,r=i){const o=e.clone();o.z=-i/2;const a=s.createSphere(o,{size:r,densificationFactor:2,vertexSpace:"georeferenced",material:new m({colorTexture:new n({data:t})})});if(a.components[0].trustSourceNormals=!0,a.vertexAttributes.uv){const t=a.vertexAttributes.uv.length??0;for(let e=0;e<t;e++)a.vertexAttributes.uv[2*e+0]=1-a.vertexAttributes.uv[2*e+0],a.vertexAttributes.uv[2*e+1]=a.vertexAttributes.uv[2*e+1]}return a.centerAt(o),a}function p(r){return new t({geometry:r,symbol:new a({symbolLayers:new e([new c])})})}function f(t,e){return 2*r(Math.atan(Math.tan(o(t/2))*Math.sqrt(e**2+1)))}export{l as createImageSphere,f as findDiagonalFOV,p as meshToGraphic};
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 a}from"../core/lang.js";import{watch as i}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 x}from"./support/jsxFactory.js";import{formatNumber as C}from"../intl/number.js";const O=t.ofType(h),k="MAP_ONLY";var I;!function(e){e.layout="layoutTab",e.mapOnly="mapOnlyTab",e.export="exportTab"}(I||(I={}));const $="esri-print",L=`${$}__advanced-options-button`,S={base:$,headerTitle:`${$}__header-title`,layoutTabList:`${$}__layout-tab-list`,layoutTab:`${$}__layout-tab`,layoutSection:`${$}__layout-section`,mapOnlySection:`${$}__map-only-section`,panelItemsCentered:`${$}__panel-items--centered`,loader:`${$}__loader`,advancedOptionsButton:L,advancedOptionsButtonContainer:`${L}-container`,advancedOptionsButtonTitle:`${L}-title`,advancedOptionsButtonIconOpened:`${L}-icon--opened`,advancedOptionsButtonIconClosed:`${L}-icon--closed`,advancedOptionsButtonIconClosed_RTL:`${L}-icon--closed-rtl`,swapButton:`${$}__swap-button`,printButton:`${$}__export-button`,templateSelectContainer:`${$}__template-select-container`,templateSelectBlock:`${$}__template-select-block`,templateSelectIcon:`${$}__template-select-icon`,formSectionContainer:`${$}__form-section-container`,formCheckboxLabel:`${$}__form-checkbox-label`,advancedOptionsSection:`${$}__advanced-options-section`,advancedOptionsContainer:`${$}__advanced-options-container`,browseTemplateButtonContainer:`${$}__browse-template-button-container`,exportedFilesContainer:`${$}__export-panel-container`,exportedFilesTitle:`${$}__export-title`,exportedFile:`${$}__exported-file`,exportedFileLink:`${$}__exported-file-link`,exportedFileLinkTitle:`${$}__exported-file-link-title`,exportedFilesEmpty:`${$}__exported-files-empty`,printWidgetContainer:`${$}__container`,content:`${$}__content`,panelContainer:`${$}__panel-container`,scaleInfoContainer:`${$}__scale-info-container`,scaleInputContainer:`${$}__scale-input-container`,scaleInput:`${$}__scale-input`,sizeContainer:`${$}__size-container`,panelError:`${$}__panel--error`,exportedFileError:`${$}__exported-file--error`,exportedFileLoader:`${$}__exported-file--loader`,exportSection:`${$}__export-section`,exportSectionCentered:`${$}__export-section--centered`,templateButtonContainer:`${$}__template-button-container`,templateDoneButton:`${$}__template-done-button`,templateSelectFlowItemContainer:`${$}__template-select-flow-item-container`,templateSelectFlowItemContent:`${$}__template-select-flow-item-content`,templateSelectFlowItemListHeading:`${$}__template-select-flow-item-list-heading`};function M(e,t,l,a){const i=l/t,o=a/t;return{width:Math.round(e*i),height:Math.round(e*o)}}function E(e){return!isNaN(e)&&e>0}function F(e){return e?.toUpperCase()===k}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=I.layout,this._pendingExportScroll=!1,this._rootNode=null,this._selectedLayout=null,this._abortController=null,this._showTemplates=!1,this.browseTemplateButtonOnClick=null,this.exportedLinks=new O,this.headingLevel=3,this.messagesCommon=null,this.messagesUnits=null,this.viewModel=new b,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 l=d(this.viewModel.effectivePrintServiceUrl),a=t.url,i=document.createElement("a");if(i.target="_blank",i.href=a,i.rel="noreferrer",i.download=t.formattedName??"",!l)return i.click(),void e.stopPropagation();e.preventDefault();const o=new URL(a);o.searchParams.set("token",l),i.href=o.href,i.click(),i.href=a},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 l=this.viewModel.templatesInfo.format.choiceList.find((t=>t.toUpperCase().includes(`(${e.toUpperCase()})`)));this.templateOptions.format=l??t})),i((()=>[this.templateOptions.layout,this.viewModel.templatesInfo?.layout.defaultValue]),(async([e,t])=>{if(this._selectedTab=F(e)?I.mapOnly:I.layout,this._selectedTab!==I.layout)return;const{includeDefaultTemplates:l,viewModel:i,_selectedLayout:o}=this,{portalTemplateIds:n,browseTemplates:s,templatesInfo:r}=i,c=i.defaultTemplates.filter((({layoutItem:e})=>n.includes(e?.id))),p=i.defaultTemplates.filter((({layoutItem:e})=>!n.includes(e?.id))),d=l&&p.length;if(e){(d?P(p,e):r?.layout.choiceList.includes(e))||P(c,e)||P(s,e)||(this.templateOptions.layout=null,this.templateOptions.layoutItem=null)}else{o&&((d?P(p,o):r?.layout.choiceList.includes(o))||P(c,o)||P(s,o))?await this._applyTemplate(o):(this.templateOptions.layout=null,this.templateOptions.layoutItem=null),this.templateOptions.layout||d||!t||await this._applyTemplate(t)}this._selectedLayout=this.templateOptions.layout;const u=!!this.templateOptions.layout&&this.viewModel.effectiveTemplateCustomTextElements[this.templateOptions.layout];this.templateOptions.customTextElements=u?a(u):null})),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)}))]);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:a}=this,{attributionEnabled:i,author:o,copyright:n,dpi:s,format:r,height:c,layout:p,legendEnabled:d,northArrowEnabled:m,scaleEnabled:h,scale:b,width:y}=t,w="ready"!==l.state||this._awaitingServerResponse||!p,T=this._renderTitleOrFileNameSection(),C=x("div",{class:S.formSectionContainer},x("calcite-label",null,e.fileFormatTitle,x("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}},l.templatesInfo?.format?.choiceList.sort().map(((e,t)=>x("calcite-combobox-item",{key:`file-format-${t}`,selected:e===this.templateOptions.format,textLabel:u(e),value:e})))))),O=x("calcite-label",{layout:"inline"},x("calcite-switch",{checked:this.showPrintAreaEnabled,onCalciteSwitchChange:e=>{this.showPrintAreaEnabled=!!e.target.checked}}),e.printPreview),k=x("div",null,x("div",{class:S.formSectionContainer},x("calcite-label",null,e.template,x("div",{class:S.templateSelectContainer,onclick:()=>{this._showTemplates=!0}},x("calcite-block",{class:S.templateSelectBlock,description:this._getPageSizeLabel(p),heading:this._getTemplateLabel()}),x("calcite-icon",{class:S.templateSelectIcon,icon:v()?"chevron-left":"chevron-right",scale:"s"})))),O),$=x("div",{class:S.formSectionContainer},x("calcite-label",null,e.dpi,x("calcite-input",{bind:this,"data-input-name":"dpi",min:1,onchange:this._handleDPIChange,tabIndex:0,type:"number",value:`${s}`}))),L=x("div",{class:this.classes(S.scaleInfoContainer,S.formSectionContainer)},x("calcite-label",{layout:"inline"},x("calcite-checkbox",{bind:this,checked:h,"data-option-name":"scaleEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.scale),x("div",{class:S.scaleInputContainer},x("calcite-input",{"aria-label":e.scaleLabel,"aria-valuenow":`${b}`,bind:this,class:S.scaleInput,"data-input-name":"scale",disabled:!h,onchange:this._updateInputValue,tabIndex:0,type:"number",value:`${b}`}),x("calcite-button",{appearance:"outline","aria-label":e.reset,bind:this,disabled:!h,iconStart:"refresh",kind:"neutral",onclick:this._resetToCurrentScale,tabIndex:0}))),M=x("div",{"aria-labelledby":`${this.id}__advancedOptionsForLayout`,class:S.advancedOptionsContainer,key:"advanced-section-for-layout"},L,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasAuthorText??1?x("div",{class:S.formSectionContainer,key:"author-info"},x("calcite-label",null,e.author,x("calcite-input",{bind:this,"data-input-name":"author",onchange:this._updateInputValue,tabIndex:0,value:o??""}))):null,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasCopyrightText??1?x("div",{class:S.formSectionContainer,key:"copyright-text"},x("calcite-label",null,e.copyright,x("calcite-input",{bind:this,"data-input-name":"copyright",onchange:this._updateInputValue,tabIndex:0,value:n??""}))):null,$,this._renderCustomTextElementSection(),this.viewModel.layoutTemplateInfo?.layoutOptions?.hasLegend??1?x("div",{class:S.formSectionContainer,key:"legend-info"},x("calcite-label",{layout:"inline"},x("calcite-checkbox",{bind:this,checked:d,"data-option-name":"legendEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.legend)):null,this.viewModel.layoutTemplateNorthArrowInfo??1?x("div",{class:S.formSectionContainer,key:"north-arrow"},x("calcite-label",{layout:"inline"},x("calcite-checkbox",{bind:this,checked:m,"data-option-name":"northArrowEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.northArrow)):null),E=x("div",{"aria-labelledby":`${this.id}__advancedOptionsForMapOnly`,class:S.advancedOptionsContainer},L,$,x("div",{class:S.formSectionContainer},x("calcite-label",{layout:"inline"},x("calcite-checkbox",{bind:this,checked:i,"data-option-name":"attributionEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.attribution)),this._renderCustomTextElementSection()),F=this.exportedLinks.toArray(),j=this._renderExportedLink(F),P={[S.exportSectionCentered]:!F.length},A=this._selectedTab===I.layout?x("section",{"aria-labelledby":`${this.id}__layoutTab`,class:S.layoutSection,id:`${this.id}__layoutContent`,key:"esri-print__layoutContent",role:"tabpanel"},x("div",{class:S.panelContainer},this.viewModel.layoutTemplateInfo?.layoutOptions?.hasTitleText??1?T:null,k,this._selectedTab===I.layout?C:null,x("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(S.panelContainer,S.advancedOptionsSection),collapsible:!0,disabled:!p,heading:e.advancedOptions,id:"advancedOptionsForLayout",key:"advanced-options-for-layout"},M))):this._selectedTab===I.mapOnly?x("section",{"aria-labelledby":`${this.id}__mapOnlyTab`,class:S.mapOnlySection,id:`${this.id}__mapOnlyContent`,key:"esri-print__mapOnlyContent",role:"tabpanel"},x("div",{class:S.panelContainer},T,C,x("div",null,x("div",{class:this.classes(S.sizeContainer,S.formSectionContainer)},x("calcite-label",null,e.width,x("calcite-input",{bind:this,"data-input-name":"width",onchange:this._updateInputValue,tabIndex:0,type:"number",value:`${y}`})),x("calcite-label",null,e.height,x("calcite-input",{bind:this,"data-input-name":"height",onchange:this._updateInputValue,tabIndex:0,type:"number",value:`${c}`})),x("button",{"aria-label":e.swap,bind:this,class:this.classes(_.widgetButton,S.swapButton,g.swap),onclick:this._switchInput,tabIndex:0,type:"button"})),O),x("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"},E))):x("section",{"aria-labelledby":`${this.id}__exportTab`,class:this.classes(S.exportSection,P),id:`${this.id}__exportContent`,key:"esri-print__exportContent",role:"tabpanel"},x("div",{class:S.panelContainer},x("div",{afterUpdate:this._scrollExportIntoView,bind:this,class:S.exportedFilesContainer},0===F.length?x("div",{class:S.exportedFilesEmpty},x("calcite-icon",{icon:"file",scale:"l"}),x("div",null,x(f,{class:S.exportedFilesTitle,level:this.headingLevel},e.noExportedFiles),x("div",null,e.exportHint))):j))),B={[_.buttonDisabled]:w||!p&&!r},D=!a||"2d"!==a.type,U=x("div",{class:S.panelError},D?e.sceneViewError:e.serviceError),N=F.some((({state:e})=>"pending"===e)),V=x("div",{class:S.content,key:"panel"},x("div",null,x("ul",{bind:this,class:S.layoutTabList,onclick:this._toggleLayoutPanel,onkeydown:this._handleLayoutPanelKeyDown,role:"tablist"},x("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===I.layout}`,class:S.layoutTab,"data-tab-id":I.layout,id:`${this.id}__layoutTab`,role:"tab",tabIndex:0},e.layoutTab),x("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===I.mapOnly}`,class:S.layoutTab,"data-tab-id":I.mapOnly,id:`${this.id}__mapOnlyTab`,role:"tab",tabIndex:0},e.mapOnlyTab),x("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===I.export}`,class:S.layoutTab,"data-tab-id":I.export,id:`${this.id}__exportedFilesTab`,role:"tab",tabIndex:0},N?x("calcite-loader",{inline:!0,label:"loading",scale:"s"}):null,e.exportsTab)),A),this._selectedTab!==I.export?x("button",{"aria-label":e.exportDescription,bind:this,class:this.classes(S.printButton,_.button,B),disabled:w,onclick:this._handlePrintMap,tabIndex:0,type:"button"},e.export):null),R=x("calcite-flow",{key:"root-flow"},x("calcite-flow-item",{bind:this,key:"root-flow-item"},x("div",{class:S.printWidgetContainer},x("header",{class:S.headerTitle},e.export),this.error||D||!a?U:V)),this._renderChooseTemplateFlowItem()),z="initializing"===l.state,H=z?this._renderLoader():R,W={[S.panelItemsCentered]:z};return x("div",{bind:this,class:this.classes(S.base,_.widget,_.panel,W)},H)}_getPageSizeLabel(e){if(!e)return;const t=this.viewModel.getLayoutTemplateInfo(e);if(!t)return;const l=A.fromJSON(t.pageUnits.toLowerCase());return`${C(t.pageSize[0])} x ${C(t.pageSize[1])} ${o(this.messagesUnits,l,"abbr")}`}_getTemplateLabel(){const{messages:e,includeDefaultTemplates:t,templateOptions:l,viewModel:a}=this,{layout:i}=l,o=i?(t?a.defaultTemplates.find((({layoutItem:e,layout:t})=>i===e?.id||i===t)):null)??a.browseTemplates.find((({layoutItem:e})=>i===e?.id)):null;return o?.label?.replaceAll("_"," ")??e[i]??i?.replaceAll("_"," ")??e.selectTemplate}_renderChooseTemplateFlowItem(){if(!this._showTemplates)return null;const{includeDefaultTemplates:e,messages:t,viewModel:l}=this,{defaultTemplates:a,templatesInfo:i,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,a)=>{const i=e.layoutItem?.id??e.layout,o=this._getPageSizeLabel(i),n=i===this.templateOptions.layout;return x("calcite-list-item",{description:o,key:`browse-template-${a}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:n,title:e.description??"",value:i},!o&&n&&e.layoutItem?.id?x("calcite-loader",{inline:!0,key:`browse-template-loader-${a}`,label:"loading",scale:"s",slot:"content-end"}):null,x("calcite-action",{icon:"trash",onclick:()=>l.removePortalTemplate(e),slot:"actions-end",text:"delete"}))})):null,c=a.length&&e?a.toArray().filter((({label:e,layoutItem:t})=>!F(e)&&n.includes(t?.id))).map(((e,l)=>{const a=e.layoutItem?.id??e.layout,i=this._getPageSizeLabel(a),o=a===this.templateOptions.layout;return x("calcite-list-item",{description:i,key:`portal-template-${a}-${o}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:o,title:e.description??"",value:a},!i&&o&&e.layoutItem?.id?x("calcite-loader",{inline:!0,key:`portal-template-loader-${l}`,label:"loading",scale:"s",slot:"content-end"}):null)})):null,d=a.length&&e?a.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 a=e.layoutItem?.id??e.layout,i=this._getPageSizeLabel(a),o=a===this.templateOptions.layout;return x("calcite-list-item",{description:i,key:`default-template-${l}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:o,title:e.description??"",value:a},!i&&o&&e.layoutItem?.id?x("calcite-loader",{inline:!0,key:`default-template-loader-${l}`,label:"loading",scale:"s",slot:"content-end"}):null)})):null,u=!i?.layout?.choiceList.length||e&&d?.length?null:i.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)=>x("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 x("calcite-flow-item",{bind:this,closable:!1,heading:t.chooseTemplate,key:"template-flow-item",onCalciteFlowItemBack:e=>{e.preventDefault(),this._showTemplates=!1}},x("div",{class:S.templateSelectFlowItemContainer},x("div",{class:S.templateSelectFlowItemContent},this.browseTemplateButtonOnClick?x("calcite-button",{appearance:"outline",class:S.browseTemplateButtonContainer,key:"browse-template-button",onclick:this.browseTemplateButtonOnClick},"Browse Templates"):null,x("calcite-list",{filterEnabled:m,key:"template-list",selectionMode:"single-persist",onCalciteListChange:({target:e})=>this._applyTemplate(e.selectedItems[0].value)},r?.length?x("div",{key:"my-templates"},x("div",{class:S.templateSelectFlowItemListHeading},t.myTemplates,x("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:t.beta},t.beta)),r):null,c?.length?x("div",{key:"org-templates"},x("div",{class:S.templateSelectFlowItemListHeading},t.organizationTemplates,s?x("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:t.beta},t.beta):null),c):null,r?.length||c?.length?d?.length?x("div",{key:"default-templates"},x("div",{class:S.templateSelectFlowItemListHeading},t.defaultTemplates),d):null:d,r?.length||c?.length?u?.length?x("div",{key:"service-templates"},x("div",{class:S.templateSelectFlowItemListHeading},t.defaultTemplates),u):null:u)),x("div",{class:S.templateButtonContainer},x("calcite-button",{class:S.templateDoneButton,onclick:()=>this._showTemplates=!1},this.messagesCommon.done))))}_renderCustomTextElementSection(){const{customTextElements:e}=this.templateOptions;return e?x("div",{class:S.formSectionContainer,key:"custom-text-elements"},e.map((e=>{const[t,l]=Object.entries(e)[0];return"date"===t?null:x("calcite-label",null,t,x("calcite-input",{bind:this,"data-input-custom":!0,"data-input-name":t,value:l??"",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{format:l,layoutItem:i}=t,o=i?.id??t.layout??this.templateOptions.layout;if(this.templateOptions.layout=o,!t.layoutOptions)try{this._abortController=new AbortController,await this.viewModel.fetchLayoutTemplateInfo(t,{signal:this._abortController.signal})}catch(p){return}finally{this._abortController=null}const n=t.layoutOptions?.legend??this.templateOptions.legendEnabled,s=t.layoutOptions?.northArrow??this.templateOptions.northArrowEnabled,r=o?this.viewModel.effectiveTemplateCustomTextElements[o]:null,c=r?a(r):null;this.templateOptions.set({customTextElements:c,format:l,layout:o,layoutItem:i,legendEnabled:n,northArrowEnabled:s})}_renderTitleOrFileNameSection(){const{title:e,fileName:t,titlePlaceHolder:l,fileNamePlaceHolder:a}=this.messages,i=this._selectedTab===I.layout?e:t,o=this._selectedTab===I.layout?l:a,n=this._selectedTab===I.layout?this.templateOptions.title:this.templateOptions.fileName;return x("div",{class:S.formSectionContainer,key:i},x("calcite-label",null,i,x("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={[S.loader]:this._awaitingServerResponse};return x("div",{class:this.classes(e),key:"loader"})}_createFileLink(e,t){const l=t||this.messages.untitled,a=e.format.toLowerCase(),i=a.includes("png")?"png":a,o=l+i;return void 0!==this._exportedFileNameMap[o]?this._exportedFileNameMap[o]++:this._exportedFileNameMap[o]=0,new h({name:l,extension:i,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"),a=!!t["data-input-custom"],{templateOptions:i}=this;if(a)return void this._updateCustomTextElementValue(i.customTextElements,l,t.value);let o;if("number"===t.type){if(!E(t.valueAsNumber)){const e=i[l];return void(t.value=`${e}`)}o=t.valueAsNumber}else o=t.value;i[l]=o}_handleDPIChange(e){const{templateOptions:t}=this,l=t.dpi;this._updateInputValue(e);const a=e.currentTarget.valueAsNumber,{height:i,width:o}=M(a,l,t.width,t.height);t.height=i,t.width=o}_handlePrintMap(){this._pendingExportScroll=!0;const{templateOptions:e}=this,t=this.viewModel.toPrintTemplate(e),l=this._selectedTab===I.layout?t.layoutOptions?.titleText:e.fileName,a=this._createFileLink(t,l);this.exportedLinks.add(a),this.emit("submit",{link:a}),this._selectedTab=I.export,this.viewModel.print(t).then((e=>{a.set({url:e&&e.url,state:"ready"})})).catch((e=>{a.set({error:e,state:"error"})})).then((()=>{this.emit("complete",{link:a}),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,a=l-t;a>0&&(e.scrollTop=a)}_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:a,state:i}=e,o=e.formattedName??"",r="error"===i,c="pending"===i,p="ready"===i;let d=a||null;d&&(d=n(d));const u=s(a,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 x("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?x("calcite-loader",{class:S.exportedFileLoader,inline:!0,key:`${o}-loader`,label:t.generatingExport,scale:"m",slot:"content-start"}):x("calcite-icon",{icon:j(e),key:`${o}-start-icon`,scale:"s",slot:"content-start"}),p?x("calcite-icon",{"aria-label":`${o}. ${t.linkReady}`,icon:u?"download-to":"launch",key:`${o}-end-icon`,scale:"s",slot:"content-end"}):null,c?null:x("calcite-action",{"aria-label":`${h}`,"data-item":e,icon:"x",key:`${o}-action`,onclick:this._removeLink,slot:"actions-end",text:`${h}`}))}));return x("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===I.mapOnly)this.templateOptions.layout=k,this.templateOptions.layoutItem=null,this.templateOptions.customTextElements=null;else if(this._selectedTab===I.layout){const e=this._selectedLayout??(this.includeDefaultTemplates&&this.viewModel.defaultTemplates.length?null:this.viewModel.templatesInfo?.layout?.defaultValue);e?this._applyTemplate(e):(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 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([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:O})],B.prototype,"exportedLinks",void 0),e([r()],B.prototype,"extraParameters",null),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 D=B;export{D as default};
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 x}from"./support/jsxFactory.js";import{formatNumber as C}from"../intl/number.js";const O=t.ofType(h),I="MAP_ONLY";var k;!function(e){e.layout="layoutTab",e.mapOnly="mapOnlyTab",e.export="exportTab"}(k||(k={}));const $="esri-print",L=`${$}__advanced-options-button`,S={base:$,headerTitle:`${$}__header-title`,layoutTabList:`${$}__layout-tab-list`,layoutTab:`${$}__layout-tab`,layoutSection:`${$}__layout-section`,mapOnlySection:`${$}__map-only-section`,panelItemsCentered:`${$}__panel-items--centered`,loader:`${$}__loader`,advancedOptionsButton:L,advancedOptionsButtonContainer:`${L}-container`,advancedOptionsButtonTitle:`${L}-title`,advancedOptionsButtonIconOpened:`${L}-icon--opened`,advancedOptionsButtonIconClosed:`${L}-icon--closed`,advancedOptionsButtonIconClosed_RTL:`${L}-icon--closed-rtl`,swapButton:`${$}__swap-button`,printButton:`${$}__export-button`,templateSelectContainer:`${$}__template-select-container`,templateSelectBlock:`${$}__template-select-block`,templateSelectIcon:`${$}__template-select-icon`,formSectionContainer:`${$}__form-section-container`,formCheckboxLabel:`${$}__form-checkbox-label`,advancedOptionsSection:`${$}__advanced-options-section`,advancedOptionsContainer:`${$}__advanced-options-container`,browseTemplateButtonContainer:`${$}__browse-template-button-container`,exportedFilesContainer:`${$}__export-panel-container`,exportedFilesTitle:`${$}__export-title`,exportedFile:`${$}__exported-file`,exportedFileLink:`${$}__exported-file-link`,exportedFileLinkTitle:`${$}__exported-file-link-title`,exportedFilesEmpty:`${$}__exported-files-empty`,printWidgetContainer:`${$}__container`,content:`${$}__content`,panelContainer:`${$}__panel-container`,scaleInfoContainer:`${$}__scale-info-container`,scaleInputContainer:`${$}__scale-input-container`,scaleInput:`${$}__scale-input`,sizeContainer:`${$}__size-container`,panelError:`${$}__panel--error`,exportedFileError:`${$}__exported-file--error`,exportedFileLoader:`${$}__exported-file--loader`,exportSection:`${$}__export-section`,exportSectionCentered:`${$}__export-section--centered`,templateButtonContainer:`${$}__template-button-container`,templateDoneButton:`${$}__template-done-button`,templateSelectFlowItemContainer:`${$}__template-select-flow-item-container`,templateSelectFlowItemContent:`${$}__template-select-flow-item-content`,templateSelectFlowItemListHeading:`${$}__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?.toUpperCase()===I}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._abortController=null,this._showTemplates=!1,this.browseTemplateButtonOnClick=null,this.exportedLinks=new O,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.viewModel.templatesInfo?.layout.defaultValue]),(async([e,t])=>{if(this._selectedTab=F(e)?k.mapOnly:k.layout,this._selectedTab!==k.layout)return;const{includeDefaultTemplates:l,viewModel:a,_selectedLayout:o}=this,{portalTemplateIds:n,browseTemplates:s,templatesInfo:r}=a,c=a.defaultTemplates.filter((({layoutItem:e})=>n.includes(e?.id))),p=a.defaultTemplates.filter((({layoutItem:e})=>!n.includes(e?.id))),d=l&&p.length;if(e){(d?P(p,e):r?.layout.choiceList.includes(e))||P(c,e)||P(s,e)||(this.templateOptions.layout=null,this.templateOptions.layoutItem=null)}else{o&&((d?P(p,o):r?.layout.choiceList.includes(o))||P(c,o)||P(s,o))?await this._applyTemplate(o):(this.templateOptions.layout=null,this.templateOptions.layoutItem=null),this.templateOptions.layout||d||!t||await this._applyTemplate(t)}this._selectedLayout=this.templateOptions.layout;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,legendEnabled:d,northArrowEnabled:m,scaleEnabled:h,scale:b,width:y}=t,w="ready"!==l.state||this._awaitingServerResponse||!p,T=this._renderTitleOrFileNameSection(),C=x("div",{class:S.formSectionContainer},x("calcite-label",null,e.fileFormatTitle,x("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}},l.templatesInfo?.format?.choiceList.sort().map(((e,t)=>x("calcite-combobox-item",{key:`file-format-${t}`,selected:e===this.templateOptions.format,textLabel:u(e),value:e})))))),O=x("calcite-label",{layout:"inline"},x("calcite-switch",{checked:this.showPrintAreaEnabled,onCalciteSwitchChange:e=>{this.showPrintAreaEnabled=!!e.target.checked}}),e.printPreview),I=x("div",null,x("div",{class:S.formSectionContainer},x("calcite-label",null,e.template,x("div",{class:S.templateSelectContainer,onclick:()=>{this._showTemplates=!0}},x("calcite-block",{class:S.templateSelectBlock,description:this._getPageSizeLabel(p),heading:this._getTemplateLabel()}),x("calcite-icon",{class:S.templateSelectIcon,icon:v()?"chevron-left":"chevron-right",scale:"s"})))),O),$=x("div",{class:S.formSectionContainer},x("calcite-label",null,e.dpi,x("calcite-input",{bind:this,"data-input-name":"dpi",min:1,tabIndex:0,type:"number",value:`${s}`,onCalciteInputInput:this._handleDPIChange}))),L=x("div",{class:this.classes(S.scaleInfoContainer,S.formSectionContainer)},x("calcite-label",{layout:"inline"},x("calcite-checkbox",{bind:this,checked:h,"data-option-name":"scaleEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.scale),x("div",{class:S.scaleInputContainer},x("calcite-input",{"aria-label":e.scaleLabel,"aria-valuenow":`${b}`,bind:this,class:S.scaleInput,"data-input-name":"scale",disabled:!h,tabIndex:0,type:"number",value:`${b}`,onCalciteInputInput:this._updateInputValue}),x("calcite-button",{appearance:"outline","aria-label":e.reset,bind:this,disabled:!h,iconStart:"refresh",kind:"neutral",onclick:this._resetToCurrentScale,tabIndex:0}))),M=x("div",{"aria-labelledby":`${this.id}__advancedOptionsForLayout`,class:S.advancedOptionsContainer,key:"advanced-section-for-layout"},L,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasAuthorText??1?x("div",{class:S.formSectionContainer,key:"author-info"},x("calcite-label",null,e.author,x("calcite-input",{bind:this,"data-input-name":"author",tabIndex:0,value:o??"",onCalciteInputInput:this._updateInputValue}))):null,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasCopyrightText??1?x("div",{class:S.formSectionContainer,key:"copyright-text"},x("calcite-label",null,e.copyright,x("calcite-input",{bind:this,"data-input-name":"copyright",tabIndex:0,value:n??"",onCalciteInputInput:this._updateInputValue}))):null,$,this._renderCustomTextElementSection(),this.viewModel.layoutTemplateInfo?.layoutOptions?.hasLegend??1?x("div",{class:S.formSectionContainer,key:"legend-info"},x("calcite-label",{layout:"inline"},x("calcite-checkbox",{bind:this,checked:d,"data-option-name":"legendEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.legend)):null,this.viewModel.layoutTemplateNorthArrowInfo??1?x("div",{class:S.formSectionContainer,key:"north-arrow"},x("calcite-label",{layout:"inline"},x("calcite-checkbox",{bind:this,checked:m,"data-option-name":"northArrowEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.northArrow)):null),E=x("div",{"aria-labelledby":`${this.id}__advancedOptionsForMapOnly`,class:S.advancedOptionsContainer},L,$,x("div",{class:S.formSectionContainer},x("calcite-label",{layout:"inline"},x("calcite-checkbox",{bind:this,checked:a,"data-option-name":"attributionEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.attribution)),this._renderCustomTextElementSection()),F=this.exportedLinks.toArray(),j=this._renderExportedLink(F),P={[S.exportSectionCentered]:!F.length},A=this._selectedTab===k.layout?x("section",{"aria-labelledby":`${this.id}__layoutTab`,class:S.layoutSection,id:`${this.id}__layoutContent`,key:"esri-print__layoutContent",role:"tabpanel"},x("div",{class:S.panelContainer},this.viewModel.layoutTemplateInfo?.layoutOptions?.hasTitleText??1?T:null,I,this._selectedTab===k.layout?C:null,x("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(S.panelContainer,S.advancedOptionsSection),collapsible:!0,disabled:!p,heading:e.advancedOptions,id:"advancedOptionsForLayout",key:"advanced-options-for-layout"},M))):this._selectedTab===k.mapOnly?x("section",{"aria-labelledby":`${this.id}__mapOnlyTab`,class:S.mapOnlySection,id:`${this.id}__mapOnlyContent`,key:"esri-print__mapOnlyContent",role:"tabpanel"},x("div",{class:S.panelContainer},T,C,x("div",null,x("div",{class:this.classes(S.sizeContainer,S.formSectionContainer)},x("calcite-label",null,e.width,x("calcite-input",{bind:this,"data-input-name":"width",tabIndex:0,type:"number",value:`${y}`,onCalciteInputInput:this._updateInputValue})),x("calcite-label",null,e.height,x("calcite-input",{bind:this,"data-input-name":"height",tabIndex:0,type:"number",value:`${c}`,onCalciteInputInput:this._updateInputValue})),x("button",{"aria-label":e.swap,bind:this,class:this.classes(_.widgetButton,S.swapButton,g.swap),onclick:this._switchInput,tabIndex:0,type:"button"})),O),x("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"},E))):x("section",{"aria-labelledby":`${this.id}__exportTab`,class:this.classes(S.exportSection,P),id:`${this.id}__exportContent`,key:"esri-print__exportContent",role:"tabpanel"},x("div",{class:S.panelContainer},x("div",{afterUpdate:this._scrollExportIntoView,bind:this,class:S.exportedFilesContainer},0===F.length?x("div",{class:S.exportedFilesEmpty},x("calcite-icon",{icon:"file",scale:"l"}),x("div",null,x(f,{class:S.exportedFilesTitle,level:this.headingLevel},e.noExportedFiles),x("div",null,e.exportHint))):j))),B={[_.buttonDisabled]:w||!p&&!r},D=!i||"2d"!==i.type,U=x("div",{class:S.panelError},D?e.sceneViewError:e.serviceError),N=F.some((({state:e})=>"pending"===e)),V=x("div",{class:S.content,key:"panel"},x("div",null,x("ul",{bind:this,class:S.layoutTabList,onclick:this._toggleLayoutPanel,onkeydown:this._handleLayoutPanelKeyDown,role:"tablist"},x("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),x("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),x("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?x("calcite-loader",{inline:!0,label:"loading",scale:"s"}):null,e.exportsTab)),A),this._selectedTab!==k.export?x("button",{"aria-label":e.exportDescription,bind:this,class:this.classes(S.printButton,_.button,B),disabled:w,onclick:this._handlePrintMap,tabIndex:0,type:"button"},e.export):null),R=x("calcite-flow",{key:"root-flow"},x("calcite-flow-item",{bind:this,key:"root-flow-item"},x("div",{class:S.printWidgetContainer},x("header",{class:S.headerTitle},e.export),this.error||D||!i?U:V)),this._renderChooseTemplateFlowItem()),z="initializing"===l.state,H=z?this._renderLoader():R,W={[S.panelItemsCentered]:z};return x("div",{bind:this,class:this.classes(S.base,_.widget,_.panel,W)},H)}_getPageSizeLabel(e){if(!e)return;const t=this.viewModel.getLayoutTemplateInfo(e);if(!t)return;const l=A.fromJSON(t.pageUnits.toLowerCase());return`${C(t.pageSize[0])} x ${C(t.pageSize[1])} ${o(this.messagesUnits,l,"abbr")}`}_getTemplateLabel(){const{messages:e,includeDefaultTemplates:t,templateOptions:l,viewModel:i}=this,{layout:a}=l,o=a?(t?i.defaultTemplates.find((({layoutItem:e,layout:t})=>a===e?.id||a===t)):null)??i.browseTemplates.find((({layoutItem:e})=>a===e?.id)):null;return o?.label?.replaceAll("_"," ")??e[a]??a?.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=a===this.templateOptions.layout;return x("calcite-list-item",{description:o,key:`browse-template-${i}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:n,title:e.description??"",value:a},!o&&n&&e.layoutItem?.id?x("calcite-loader",{inline:!0,key:`browse-template-loader-${i}`,label:"loading",scale:"s",slot:"content-end"}):null,x("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=i===this.templateOptions.layout;return x("calcite-list-item",{description:a,key:`portal-template-${i}-${o}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:o,title:e.description??"",value:i},!a&&o&&e.layoutItem?.id?x("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=i===this.templateOptions.layout;return x("calcite-list-item",{description:a,key:`default-template-${l}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:o,title:e.description??"",value:i},!a&&o&&e.layoutItem?.id?x("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)=>x("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 x("calcite-flow-item",{bind:this,closable:!1,heading:t.chooseTemplate,key:"template-flow-item",onCalciteFlowItemBack:e=>{e.preventDefault(),this._showTemplates=!1}},x("div",{class:S.templateSelectFlowItemContainer},x("div",{class:S.templateSelectFlowItemContent},this.browseTemplateButtonOnClick?x("calcite-button",{appearance:"outline",class:S.browseTemplateButtonContainer,key:"browse-template-button",onclick:this.browseTemplateButtonOnClick},"Browse Templates"):null,x("calcite-list",{filterEnabled:m,key:"template-list",selectionMode:"single-persist",onCalciteListChange:({target:e})=>this._applyTemplate(e.selectedItems[0].value)},r?.length?x("div",{key:"my-templates"},x("div",{class:S.templateSelectFlowItemListHeading},t.myTemplates,x("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:t.beta},t.beta)),r):null,c?.length?x("div",{key:"org-templates"},x("div",{class:S.templateSelectFlowItemListHeading},t.organizationTemplates,s?x("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:t.beta},t.beta):null),c):null,r?.length||c?.length?d?.length?x("div",{key:"default-templates"},x("div",{class:S.templateSelectFlowItemListHeading},t.defaultTemplates),d):null:d,r?.length||c?.length?u?.length?x("div",{key:"service-templates"},x("div",{class:S.templateSelectFlowItemListHeading},t.defaultTemplates),u):null:u)),x("div",{class:S.templateButtonContainer},x("calcite-button",{class:S.templateDoneButton,onclick:()=>this._showTemplates=!1},this.messagesCommon.done))))}_renderCustomTextElementSection(){const{customTextElements:e}=this.templateOptions;return e?x("div",{class:S.formSectionContainer,key:"custom-text-elements"},e.map(((e,t)=>{const[l,i]=Object.entries(e)[0];return"date"===l?null:x("calcite-label",{key:`custom-text-elements-${l}-${t}`},l,x("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{format:l,layoutItem:a}=t,o=a?.id??t.layout??this.templateOptions.layout;if(this.templateOptions.layout=o,!t.layoutOptions)try{this._abortController=new AbortController,await this.viewModel.fetchLayoutTemplateInfo(t,{signal:this._abortController.signal})}catch(p){return}finally{this._abortController=null}const n=t.layoutOptions?.legend??this.templateOptions.legendEnabled,s=t.layoutOptions?.northArrow??this.templateOptions.northArrowEnabled,r=o?this.viewModel.effectiveTemplateCustomTextElements[o]:null,c=r?i(r):null;this.templateOptions.set({customTextElements:c,format:l,layout:o,layoutItem:a,legendEnabled:n,northArrowEnabled:s})}_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 x("div",{class:S.formSectionContainer,key:a},x("calcite-label",null,a,x("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 x("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 x("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?x("calcite-loader",{class:S.exportedFileLoader,inline:!0,key:`${o}-loader`,label:t.generatingExport,scale:"m",slot:"content-start"}):x("calcite-icon",{icon:j(e),key:`${o}-start-icon`,scale:"s",slot:"content-start"}),p?x("calcite-icon",{"aria-label":`${o}. ${t.linkReady}`,icon:u?"download-to":"launch",key:`${o}-end-icon`,scale:"s",slot:"content-end"}):null,c?null:x("calcite-action",{"aria-label":`${h}`,"data-item":e,icon:"x",key:`${o}-action`,onclick:this._removeLink,slot:"actions-end",text:`${h}`}))}));return x("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=I,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);e?this._applyTemplate(e):(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,"_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:O})],B.prototype,"exportedLinks",void 0),e([r()],B.prototype,"extraParameters",null),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 D=B;export{D as default};