@arcgis/core 4.34.0-next.60 → 4.34.0-next.62

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 (176) hide show
  1. package/applications/Components/actionUtils.d.ts +3 -0
  2. package/applications/Components/actionUtils.js +5 -0
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/0264905da9fa56166538.js +1 -0
  5. package/assets/esri/core/workers/chunks/{007721d1d99233046420.js → 188feb2bcbf8e48e3163.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{0ff8b28a34b1825c227d.js → 220c8d6338f236298720.js} +1 -1
  7. package/assets/esri/core/workers/chunks/226833d408eb1225e168.js +1 -0
  8. package/assets/esri/core/workers/chunks/33718ea851645d9078d1.js +1 -0
  9. package/assets/esri/core/workers/chunks/{54b43876ae6fb078eb38.js → 77e27f318b5863dd0f5c.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{2d74af2b383187bd59c3.js → 8005ae652361f506bc5f.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{0468266dfe15ec41d60a.js → a35a439f053d1fe0541b.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{4e21a1116be0d6340163.js → bdc18ef9cdc8242f014e.js} +1 -1
  13. package/assets/esri/core/workers/chunks/d6f5297f7b323c340727.js +1 -0
  14. package/assets/esri/core/workers/chunks/f4167fc895d4009df1c7.js +1 -0
  15. package/assets/esri/core/workers/chunks/f542bdc994a5ea3aa9d1.js +1 -0
  16. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ar.json +1 -1
  17. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_bg.json +1 -1
  18. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_bs.json +1 -1
  19. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ca.json +1 -1
  20. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_cs.json +1 -1
  21. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_da.json +1 -1
  22. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_de.json +1 -1
  23. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_el.json +1 -1
  24. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_es.json +1 -1
  25. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_et.json +1 -1
  26. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_fi.json +1 -1
  27. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_fr.json +1 -1
  28. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_he.json +1 -1
  29. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_hr.json +1 -1
  30. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_hu.json +1 -1
  31. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_id.json +1 -1
  32. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_it.json +1 -1
  33. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ja.json +1 -1
  34. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ko.json +1 -1
  35. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_lt.json +1 -1
  36. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_lv.json +1 -1
  37. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_nl.json +1 -1
  38. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_no.json +1 -1
  39. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_pl.json +1 -1
  40. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_pt-BR.json +1 -1
  41. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_pt-PT.json +1 -1
  42. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ro.json +1 -1
  43. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ru.json +1 -1
  44. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sk.json +1 -1
  45. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sl.json +1 -1
  46. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sr.json +1 -1
  47. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sv.json +1 -1
  48. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_th.json +1 -1
  49. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_tr.json +1 -1
  50. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_uk.json +1 -1
  51. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_vi.json +1 -1
  52. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_zh-CN.json +1 -1
  53. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_zh-HK.json +1 -1
  54. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_zh-TW.json +1 -1
  55. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_ar.json +1 -1
  56. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_bg.json +1 -1
  57. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_bs.json +1 -1
  58. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_ca.json +1 -1
  59. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_cs.json +1 -1
  60. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_da.json +1 -1
  61. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_de.json +1 -1
  62. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_el.json +1 -1
  63. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_es.json +1 -1
  64. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_et.json +1 -1
  65. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_fi.json +1 -1
  66. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_fr.json +1 -1
  67. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_he.json +1 -1
  68. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_hr.json +1 -1
  69. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_hu.json +1 -1
  70. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_id.json +1 -1
  71. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_it.json +1 -1
  72. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_ja.json +1 -1
  73. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_ko.json +1 -1
  74. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_lt.json +1 -1
  75. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_lv.json +1 -1
  76. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_nl.json +1 -1
  77. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_no.json +1 -1
  78. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_pl.json +1 -1
  79. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_pt-BR.json +1 -1
  80. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_pt-PT.json +1 -1
  81. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_ro.json +1 -1
  82. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_ru.json +1 -1
  83. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_sk.json +1 -1
  84. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_sl.json +1 -1
  85. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_sr.json +1 -1
  86. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_sv.json +1 -1
  87. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_th.json +1 -1
  88. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_tr.json +1 -1
  89. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_uk.json +1 -1
  90. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_vi.json +1 -1
  91. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_zh-CN.json +1 -1
  92. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_zh-HK.json +1 -1
  93. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_zh-TW.json +1 -1
  94. package/chunks/BloomComposition.glsl.js +6 -5
  95. package/chunks/Fog.glsl.js +20 -13
  96. package/config.js +1 -1
  97. package/core/Collection.js +1 -1
  98. package/core/has.js +1 -1
  99. package/interfaces.d.ts +189 -55
  100. package/kernel.js +1 -1
  101. package/layers/OGCFeatureLayer.js +1 -1
  102. package/layers/SceneLayer.js +1 -1
  103. package/layers/VoxelLayer.js +1 -1
  104. package/layers/VoxelWasmPerSceneView.js +1 -1
  105. package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
  106. package/layers/graphics/data/QueryEngineResult.js +1 -1
  107. package/layers/video/VideoController.js +1 -1
  108. package/package.json +2 -2
  109. package/support/revision.js +1 -1
  110. package/symbols/IconSymbol3DLayer.js +1 -1
  111. package/symbols/TextSymbol3DLayer.js +1 -1
  112. package/symbols/support/IconSymbol3DLayerResource.js +1 -1
  113. package/symbols/support/OccludedVisibility.js +5 -0
  114. package/symbols/support/Symbol3DAnchorPosition2D.js +1 -1
  115. package/symbols/support/Symbol3DIconOutline.js +1 -1
  116. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  117. package/views/2d/layers/features/FeatureContainer.js +1 -1
  118. package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
  119. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  120. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  121. package/views/2d/layers/support/UpdateTracking2D.js +1 -1
  122. package/views/2d/navigation/actions/Pan.js +1 -1
  123. package/views/3d/analysis/ElevationProfile/ElevationProfileInputVisualization.js +1 -1
  124. package/views/3d/analysis/ElevationProfileAnalysisView3D.js +1 -1
  125. package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
  126. package/views/3d/environment/Fog.glsl.js +1 -1
  127. package/views/3d/environment/Fog.js +1 -1
  128. package/views/3d/environment/FogTechniqueConfiguration.js +5 -0
  129. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  130. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  131. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  132. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  133. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  134. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  135. package/views/3d/layers/graphics/Graphics3DSymbol.js +1 -1
  136. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  137. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  138. package/views/3d/layers/graphics/Graphics3DWebStyleSymbol.js +1 -1
  139. package/views/3d/layers/graphics/GraphicsDeconflictor.js +1 -1
  140. package/views/3d/layers/graphics/Labeler.js +1 -1
  141. package/views/3d/layers/support/StageLayerElevationProvider.js +1 -1
  142. package/views/3d/state/ViewState.js +1 -1
  143. package/views/3d/state/controllers/CameraController.js +1 -1
  144. package/views/3d/support/MemoryController.js +1 -1
  145. package/views/3d/webgl-engine/effects/blit/Blit.js +1 -1
  146. package/views/3d/webgl-engine/effects/bloom/BloomComposition.glsl.js +1 -1
  147. package/views/3d/webgl-engine/effects/bloom/BloomCompositionTechnique.js +1 -1
  148. package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +1 -1
  149. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  150. package/views/3d/webgl-engine/lib/CutFillDepth.js +1 -1
  151. package/views/3d/webgl-engine/lib/GPUPointOcclusionQuery.js +1 -1
  152. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  153. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  154. package/views/GroundView.js +1 -1
  155. package/views/SceneView.js +1 -1
  156. package/views/analysis/ElevationProfile/ElevationProfileController.js +1 -1
  157. package/views/analysis/ElevationProfile/ElevationProfileInputLineComputation.js +1 -1
  158. package/views/analysis/ElevationProfile/ElevationProfileResult.js +1 -1
  159. package/views/analysis/ElevationProfile/ElevationProfileTool.js +5 -0
  160. package/views/analysis/ElevationProfile/elevationProfileGeometryUtils.js +1 -1
  161. package/views/input/IViewEvents.js +5 -0
  162. package/views/interactive/Tooltip.js +1 -1
  163. package/views/support/LayerViewManager.js +1 -1
  164. package/webscene/SunLighting.js +1 -1
  165. package/webscene/VirtualLighting.js +1 -1
  166. package/widgets/CoordinateConversion/support/Format.js +1 -1
  167. package/widgets/Popup/actionUtils.js +1 -1
  168. package/widgets/Print/PrintViewModel.js +1 -1
  169. package/widgets/Search/SearchViewModel.js +1 -1
  170. package/widgets/UtilityNetworkTrace.js +1 -1
  171. package/assets/esri/core/workers/chunks/18f878ec695617650a96.js +0 -1
  172. package/assets/esri/core/workers/chunks/232c76f122b1f519e099.js +0 -1
  173. package/assets/esri/core/workers/chunks/5e1afea05b624b315d9f.js +0 -1
  174. package/assets/esri/core/workers/chunks/63f3e46bfa820436161c.js +0 -1
  175. package/assets/esri/core/workers/chunks/981275b6f008431c983a.js +0 -1
  176. package/assets/esri/core/workers/chunks/e36d538915261ee0373f.js +0 -1
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
+ */
5
+ import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import i from"../../../core/Accessor.js";import{isSome as s}from"../../../core/arrayUtils.js";import{createTask as a}from"../../../core/asyncUtils.js";import"../../../core/has.js";import{makeHandle as r,handlesGroup as o}from"../../../core/handleUtils.js";import{ignoreAbortErrors as n,isAborted as c,createResolver as p,throwIfAborted as l,createAbortError as h,onAbort as m}from"../../../core/promiseUtils.js";import{watch as y,syncAndInitial as d}from"../../../core/reactiveUtils.js";import{property as u}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import k from"../../../layers/GraphicsLayer.js";import f from"../../../symbols/CIMSymbol.js";import g from"../../../symbols/SimpleLineSymbol.js";import{isPolylineGraphic as v,isPolyline as w,isValidInputGraphic as b}from"./elevationProfileGeometryUtils.js";import{ViewEventPriorities as G}from"../../input/InputManager.js";import{isCancelEvent as O}from"../../interactive/interactiveToolUtils.js";import S from"../../../widgets/Sketch/SketchViewModel.js";const I=Symbol("main"),V=Symbol("interactive-operation");let j=class extends i{constructor(e){super(e),this._activeOperationInfo=null}initialize(){const{view:e}=this;this._graphicsLayer=new k({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height",offset:null},title:"Elevation profile graphics layer"}),this._sketchViewModel=new S({layer:this._graphicsLayer,view:e,defaultCreateOptions:{mode:"click",hasZ:!0},updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{shapeOperation:"none"},enableRotation:!1,enableScaling:!1,enableMoveAllGraphics:!1,enableZ:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"reshape"},polylineSymbol:this._lineSymbol,activeLineSymbol:this._lineSymbol}),this.addHandles(y(()=>({map:e.map,internalGraphicsLayer:this._graphicsLayer,state:this.state}),({map:e,internalGraphicsLayer:t,state:i})=>{switch(L(e,t),i){case"idle":case"selected":this._stopOperation();break;case"picking":case"awaiting-sketch":case"sketching":break;case"reshaping":this._startReshape();break;case"reshaping-disabled":this._stopOperation(),this._graphicsLayer.visible=!1,this._ensureUpdatedSketchGraphic()}},d),I)}destroy(){this._sketchViewModel.destroy();const e=this._graphicsLayer;e&&this.view.map?.remove(e),e.destroy()}get sketchGraphic(){return this._get("sketchGraphic")}set sketchGraphic(e){e!==this._get("sketchGraphic")&&(this._set("sketchGraphic",e),D(this._graphicsLayer,e),this._updateInputFromSketchGraphic())}get state(){const{analysis:e,visible:t,interactive:i}=this.analysisViewData;if(!t)return"idle";switch(this._activeOperationInfo?.type){case"place":return this._sketchViewModel.createGraphic===this.sketchGraphic?"sketching":"awaiting-sketch";case"pick-graphic":return"picking";default:{const{input:t}=e;return t?v(t)?"selected":i?"reshaping":"reshaping-disabled":"idle"}}}get updating(){return this._sketchViewModel.updating}get _lineSymbol(){return M(this.view.type)}place(e){return this._startOperation("place",e,(t,i)=>{const s=this.analysisViewData.analysis.clone(),a=this._sketchViewModel.on("create",e=>{switch(e.state){case"complete":this._updateInputFromSketchGraphic(),this._stopOperation();break;case"cancel":this._stopOperation();break;case"active":this._updateInputFromSketchGraphic();break;case"start":this.sketchGraphic=e.graphic}});return n(this._sketchViewModel.create("polyline")),r(()=>(a.remove(),this._sketchViewModel.cancel(),this._updateInputFromSketchGraphic(),this.analysisViewData.analysis.valid?c(e)||s.equals(this.analysisViewData.analysis)?i():void t():(this._clearInput(),i())))})}async pickGraphic(e){return this._startOperation("pick-graphic",e,(e,t)=>{const{view:i}=this;i.closePopup();let s=null;const n=r=>{r.defer(async()=>{s?.abort(),s=a(async s=>{const{results:a}=await i.hitTest(r);l(s);const o=a.filter(e=>"graphic"===e.type).map(e=>e.graphic).find(b);o?(r.preventDefault(),r.stopPropagation(),this.sketchGraphic=null,this.analysisViewData.analysis.input=o,e(),this._stopOperation()):t()}),await s.promise})},c=e=>{O(e)&&(t(),this._stopOperation())};return i.focus(),o([i.on("immediate-click",n,G.TOOL),i.on("key-down",c,G.TOOL),i.acquireCursor("crosshair","high"),r(()=>{s?.abort(),t()})])})}_startReshape(){this._stopOperation();const e=this._sketchViewModel.on("update",e=>{this._updateInputFromSketchGraphic(),"complete"===e.state&&this._stopOperation()});this._replaceHandles(r(()=>{e.remove(),this._sketchViewModel.cancel()}),V);const t=this._ensureUpdatedSketchGraphic();t&&(this._graphicsLayer.visible=!0,n(this._sketchViewModel.update(t,{tool:"reshape"})))}async _startOperation(e,t,i){const s=this._activeOperationInfo,a=p(),r={type:e,promise:a.promise};if(this._activeOperationInfo=r,s){const e=s.promise.catch(()=>{});this._stopOperation(),await e,l(t)}this.analysisViewData.interactive=!0;const o=i(()=>a.resolve({}),()=>a.reject(h()));this._replaceHandles([o,m(t,()=>this._stopOperation())],V);try{return await a.promise}finally{this._activeOperationInfo===r&&(this._activeOperationInfo=null)}}_stopOperation(){this.removeHandles(V)}_ensureUpdatedSketchGraphic(){const{input:e}=this.analysisViewData.analysis;return w(e)?(this.sketchGraphic??=new t({symbol:this._lineSymbol,geometry:e}),this.sketchGraphic.geometry=e,this.sketchGraphic):(this.sketchGraphic=null,null)}_clearInput(){this.sketchGraphic=null,this.analysisViewData.analysis.input=null}_updateInputFromSketchGraphic(){const e=this.sketchGraphic,{analysis:t}=this.analysisViewData;t.input=v(e)?e.geometry:null}_replaceHandles(e,t){this.removeHandles(t),this.addHandles((Array.isArray(e)?e:[e]).filter(s),t)}};function M(e){if("2d"===e){const e={type:"CIMSolidStroke",enable:!0,capStyle:"Butt",joinStyle:"Round",width:1.5};return new f({data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{...e,effects:[{type:"CIMGeometricEffectDashes",dashTemplate:[5,4],lineDashEnding:"FullGap",controlPointEnding:"NoConstraint"}],color:[0,0,0,255]},{...e,color:[255,255,255,255]}]}}})}return new g({color:[0,0,0,0]})}function L(e,t){t&&(t.parent&&"remove"in t.parent&&t.parent.remove(t),e?.add(t))}function D({graphics:e},t){t?(e.includes(t)||e.add(t),1!==e.length&&e.removeMany(e.filter(e=>e!==t))):e.removeAll()}e([u({constructOnly:!0})],j.prototype,"analysisViewData",void 0),e([u({constructOnly:!0})],j.prototype,"view",void 0),e([u()],j.prototype,"sketchGraphic",null),e([u({nonNullable:!0})],j.prototype,"state",null),e([u()],j.prototype,"updating",null),e([u()],j.prototype,"_activeOperationInfo",void 0),e([u()],j.prototype,"_lineSymbol",null),j=e([_("esri.views.analysis.ElevationProfile.ElevationProfileTool")],j);export{j as ElevationProfileTool};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{floatEqualUlp as e,lerp as t}from"../../../core/mathUtils.js";import{throwIfAborted as n}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as r}from"../../../core/unitUtils.js";import{distance as o,lerp as s}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{m as i}from"../../../chunks/vec32.js";import a from"../../../geometry/Polyline.js";import{initializeProjection as c,project as u}from"../../../geometry/projectionUtils.js";import l from"../../../geometry/SpatialReference.js";import{geodesicLengths as f,isSupported as p,inverseGeodeticSolver as h,directGeodeticSolver as m}from"../../../geometry/support/geodesicUtils.js";import{getElevationOffset as d}from"../../../support/elevationInfoUtils.js";import{ElevationProfileGenerationError as g}from"./ElevationProfileGenerationError.js";async function y(e,t,o,s,i,a,p){let h,m,d;const y=e.spatialReference,j=y.isGeographic||y.isWebMercator;let v=0;if(!j){const{execute:t}=await import("../../../geometry/operators/lengthOperator.js");n(p),v=t(e,{unit:"meters"}),n(p)}const P=1/r(s);if(j){await c([{source:y,dest:s},{source:y,dest:l.WGS84}],p);const n=O(e);h=f([n],"meters")[0];const r=w(h,i);if(B(e,h,r)>a)throw new g("too-complex");const j=R(n,t,o);({densifiedPath:m,distances:d}=G(j,r,P)),m=u(m,s)}else{await c([{source:y,dest:s}],p),h=v;const r=w(h,i);if(B(e,h,r)>a)throw new g("too-complex");const l=R(e,t,o);({densifiedPath:m,distances:d}=z(l,r,P)),n(p),m=u(m,s)}return{densifiedPath:m,pathLength:h*P,distances:d}}function w(e,t){const n=e/t.densificationMaxSamples;return Math.max(t.samplingDistance,n)}function R(e,t,n){if(null==t)return P(e);const r=e.spatialReference,o=t.mode,s=d(t,r);let i=null;switch(n.type){case"2d":i=j(e,o,s);break;case"3d":i=v(e,o,s,n)}return null==i?P(e):new a({hasZ:!0,hasM:!1,spatialReference:r,paths:Z(e.paths,i)})}function j({hasZ:e},t,n){return"absolute-height"===t?e?([e,t,r])=>[e,t,r+n]:([e,t])=>[e,t,n]:null}function v({spatialReference:e,hasZ:t},n,r,{elevationProvider:o}){const s=(t,n,r,s)=>o?.getElevation(t,n,r,e,s)??0;switch(n){case"on-the-ground":return([e,t])=>[e,t,s(e,t,0,"ground")];case"absolute-height":return t?([e,t,n])=>[e,t,n+r]:([e,t])=>[e,t,r];case"relative-to-ground":return t?([e,t,n])=>[e,t,n+s(e,t,n,"ground")+r]:([e,t])=>[e,t,s(e,t,0,"ground")+r];case"relative-to-scene":return t?([e,t,n])=>[e,t,n+s(e,t,n,"scene")+r]:([e,t])=>[e,t,s(e,t,0,"scene")+r];default:return null}}function P(e){return e.hasZ?new a({hasZ:!1,hasM:!1,spatialReference:e.spatialReference,paths:Z(e.paths,([e,t])=>[e,t])}):e}function Z(e,t){const n=e.length,r=new Array(n);for(let o=0;o<n;++o){const n=e[o],s=n.length,i=new Array(n.length);r[o]=i;for(let e=0;e<s;++e)i[e]=t(n[e])}return r}function x(e){return null!=e&&"polyline"===e.type&&e.paths.length>0&&e.paths.every(e=>e.length>=2)}function M(e){return null!=e?.geometry&&"polyline"===e.geometry.type}function S(e){return b(e)?e:null}function U(e){return b(e)?e.geometry:e}function b(e){return null!=e&&"geometry"in e}function A(t,n,o,s,i){const{spatialReference:c,hasZ:u}=t,l={from:null,to:null,distance:0,azimuth:0,reverseAzimuth:0,spatialReference:c,metersPerSR:r(c)},f=[],p=[];let h=0;for(let r=0;r<t.paths.length;++r){const a=t.paths[r],c=new Array,u=new Array;let m=0;for(let t=1;t<a.length;++t){const r=a[t-1],f=a[t],p=s(l,r,f);let d;for(d=m;d<p.distance&&!e(d,p.distance);d+=n)c.push(i(p,d)),u.push((h+d)*o);m=d-p.distance,h+=p.distance,c.push(f),u.push(h*o)}f[r]=c,p[r]=u}return{densifiedPath:new a({spatialReference:c,hasZ:u,paths:f}),distances:p}}function z(e,t,n){const{hasZ:r}=e;return A(e,t,n,W,r?L:I)}function G(e,t,n){const{hasZ:r}=e;return A(e,t,n,E,r?D:k)}function E(e,t,n){return e.distance=0,h(e,t,n,e.spatialReference),e.from=t,e.to=n,e}function W(e,t,n){return e.from=t,e.to=n,e.distance=o(n,t)*e.metersPerSR,e}function k({from:e,azimuth:t,spatialReference:n},r){return m([0,0],e,t,r,n)}function D({from:e,to:n,azimuth:r,distance:o,spatialReference:s},i){const a=i/o,c=[0,0,t(e[2],n[2],a)];return m(c,e,r,i,s),c}function I({from:e,to:t,distance:n},r){return s([0,0],e,t,r/n)}function L({from:e,to:t,distance:n},r){return i([0,0,0],e,t,r/n)}function O(e){return p(e.spatialReference)?e:u(e,l.WGS84)}function q(e){return e.paths.reduce((e,t)=>e+t.length,0)}function B(e,t,n){return q(e)+Math.floor(t/n)+Math.max(0,e.paths.reduce(e=>1+e,0)-1)}export{q as countPoints,y as densifyPath,U as getInputGeometry,S as getInputGraphic,M as isPolylineGraphic,x as isValidInputPath,R as toAbsoluteHeightElevation};
5
+ import{floatEqualUlp as e,lerp as t}from"../../../core/mathUtils.js";import{throwIfAborted as n}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as r}from"../../../core/unitUtils.js";import{distance as o,lerp as s}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{m as i}from"../../../chunks/vec32.js";import a from"../../../geometry/Polyline.js";import{initializeProjection as c,project as u}from"../../../geometry/projectionUtils.js";import l from"../../../geometry/SpatialReference.js";import{geodesicLengths as f,isSupported as p,inverseGeodeticSolver as h,directGeodeticSolver as m}from"../../../geometry/support/geodesicUtils.js";import{getElevationOffset as d}from"../../../support/elevationInfoUtils.js";import{ElevationProfileGenerationError as g}from"./ElevationProfileGenerationError.js";async function y(e,t,o,s,i,a,p){let h,m,d;const y=e.spatialReference,j=y.isGeographic||y.isWebMercator;let v=0;if(!j){const{execute:t}=await import("../../../geometry/operators/lengthOperator.js");n(p),v=t(e,{unit:"meters"}),n(p)}const P=1/r(s);if(j){await c([{source:y,dest:s},{source:y,dest:l.WGS84}],p);const n=B(e);h=f([n],"meters")[0];const r=w(h,i);if(F(e,h,r)>a)throw new g("too-complex");const j=R(n,t,o);({densifiedPath:m,distances:d}=W(j,r,P)),m=u(m,s)}else{await c([{source:y,dest:s}],p),h=v;const r=w(h,i);if(F(e,h,r)>a)throw new g("too-complex");const l=R(e,t,o);({densifiedPath:m,distances:d}=E(l,r,P)),n(p),m=u(m,s)}return{densifiedPath:m,pathLength:h*P,distances:d}}function w(e,t){const n=e/t.densificationMaxSamples;return Math.max(t.samplingDistance,n)}function R(e,t,n){if(null==t)return P(e);const r=e.spatialReference,o=t.mode,s=d(t,r);let i=null;switch(n.type){case"2d":i=j(e,o,s);break;case"3d":i=v(e,o,s,n)}return null==i?P(e):new a({hasZ:!0,hasM:!1,spatialReference:r,paths:Z(e.paths,i)})}function j({hasZ:e},t,n){return"absolute-height"===t?e?([e,t,r])=>[e,t,r+n]:([e,t])=>[e,t,n]:null}function v({spatialReference:e,hasZ:t},n,r,{elevationProvider:o}){const s=(t,n,r,s)=>o?.getElevation(t,n,r,e,s)??0;switch(n){case"on-the-ground":return([e,t])=>[e,t,s(e,t,0,"ground")];case"absolute-height":return t?([e,t,n])=>[e,t,n+r]:([e,t])=>[e,t,r];case"relative-to-ground":return t?([e,t,n])=>[e,t,n+s(e,t,n,"ground")+r]:([e,t])=>[e,t,s(e,t,0,"ground")+r];case"relative-to-scene":return t?([e,t,n])=>[e,t,n+s(e,t,n,"scene")+r]:([e,t])=>[e,t,s(e,t,0,"scene")+r];default:return null}}function P(e){return e.hasZ?new a({hasZ:!1,hasM:!1,spatialReference:e.spatialReference,paths:Z(e.paths,([e,t])=>[e,t])}):e}function Z(e,t){const n=e.length,r=new Array(n);for(let o=0;o<n;++o){const n=e[o],s=n.length,i=new Array(n.length);r[o]=i;for(let e=0;e<s;++e)i[e]=t(n[e])}return r}function x(e){return null!=e&&"polyline"===e.type&&e.paths.length>0&&e.paths.every(e=>e.length>=2)}function M(e){return S(e)&&x(e.geometry)}function S(e){return z(e)&&U(e?.geometry)}function U(e){return!z(e)&&null!=e&&"polyline"===e.type}function b(e){return z(e)?e:null}function A(e){return z(e)?e.geometry:e}function z(e){return null!=e&&"geometry"in e}function G(t,n,o,s,i){const{spatialReference:c,hasZ:u}=t,l={from:null,to:null,distance:0,azimuth:0,reverseAzimuth:0,spatialReference:c,metersPerSR:r(c)},f=[],p=[];let h=0;for(let r=0;r<t.paths.length;++r){const a=t.paths[r],c=new Array,u=new Array;let m=0;for(let t=1;t<a.length;++t){const r=a[t-1],f=a[t],p=s(l,r,f);let d;for(d=m;d<p.distance&&!e(d,p.distance);d+=n)c.push(i(p,d)),u.push((h+d)*o);m=d-p.distance,h+=p.distance,c.push(f),u.push(h*o)}f[r]=c,p[r]=u}return{densifiedPath:new a({spatialReference:c,hasZ:u,paths:f}),distances:p}}function E(e,t,n){const{hasZ:r}=e;return G(e,t,n,D,r?q:O)}function W(e,t,n){const{hasZ:r}=e;return G(e,t,n,k,r?L:I)}function k(e,t,n){return e.distance=0,h(e,t,n,e.spatialReference),e.from=t,e.to=n,e}function D(e,t,n){return e.from=t,e.to=n,e.distance=o(n,t)*e.metersPerSR,e}function I({from:e,azimuth:t,spatialReference:n},r){return m([0,0],e,t,r,n)}function L({from:e,to:n,azimuth:r,distance:o,spatialReference:s},i){const a=i/o,c=[0,0,t(e[2],n[2],a)];return m(c,e,r,i,s),c}function O({from:e,to:t,distance:n},r){return s([0,0],e,t,r/n)}function q({from:e,to:t,distance:n},r){return i([0,0,0],e,t,r/n)}function B(e){return p(e.spatialReference)?e:u(e,l.WGS84)}function C(e){return e.paths.reduce((e,t)=>e+t.length,0)}function F(e,t,n){return C(e)+Math.floor(t/n)+Math.max(0,e.paths.reduce(e=>1+e,0)-1)}export{C as countPoints,y as densifyPath,A as getInputGeometry,b as getInputGraphic,z as isGraphic,U as isPolyline,S as isPolylineGraphic,M as isValidInputGraphic,x as isValidInputPath,R as toAbsoluteHeightElevation};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
+ */
5
+ const d={Left:0,Middle:1,Right:2,Back:3,Forward:4,Undefined:-1};export{d as MouseButton};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import{EventedAccessor as e}from"../../core/Evented.js";import{on as o}from"../../core/events.js";import{destroyMaybe as n}from"../../core/maybe.js";import{watch as i,when as s,syncAndInitial as r,initial as l,sync as a}from"../../core/reactiveUtils.js";import{cloneScreenPoint as c,createScreenPoint as p}from"../../core/screenUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../core/support/UpdatingHandles.js";import{setCalciteModeClass as f}from"../../support/modeUtils.js";import{base as m}from"./tooltip/css.js";import{tooltipContentFactory as g}from"./tooltip/content/tooltipContentFactory.js";import{isRTL as y}from"../../widgets/support/widgetUtils.js";const v={base:`${m}`,ltr:`${m}--ltr`,rtl:`${m}--rtl`,debug:`${m}--debug`},_=20,C=16,b="bottom-end";let P=class extends e{constructor(t){super(t),this.info=null,this.options=null,this.position=null,this.content=null,this._focused=!1,this.outerContainer=document.createElement("div"),this.debug=!1,this._updatingHandles=new h,this._lastPosition=null,this._rtl=!1,this._prevXY=[0,0]}initialize(){const{outerContainer:t}=this;this.addHandles([i(()=>this.view.overlay?.surface,e=>{t.remove(),e?.appendChild(t),this._rtl=y(e)},r),i(()=>this.info,(e,o)=>{if(null!=this.content&&null!=e&&null!=o&&e.type===o.type)this.content.info=e;else{n(this.content);const o=g(this,e);o?(this.content=o,o.container&&t.appendChild(o.container),this.exitInputMode()):this.content=null}},r),i(()=>({container:this.outerContainer,style:this._outerContainerStyle}),({container:t,style:e})=>{Object.assign(t.style,e)},l),i(()=>({outerContainer:this.outerContainer,placement:this.effectivePlacement,effectiveOffset:this._effectiveOffset,rtl:this._rtl,debug:this.debug}),({outerContainer:t,placement:e,effectiveOffset:o,rtl:n,debug:i})=>{const{classList:s}=t;s.add(v.base),s.toggle(v.rtl,n),s.toggle(v.ltr,!n),s.toggle(v.debug,i),this.outerContainer.style.setProperty("--offset",`${o}px`),f(t),x(t,e)},l),s(()=>"feedback"===this.mode,()=>{this.position=null,this._clearOverride("effectivePlacement")},a),o(this.outerContainer,"paste",t=>{this.emit("paste",t)}),o(this.outerContainer,["focusin","focusout"],()=>{this._focused=this.content?.container?.contains(document.activeElement)??!1})])}destroy(){this.info=null,this.content=n(this.content),this.outerContainer.remove()}get mode(){return this.content?.mode??"feedback"}get focused(){return this._focused}get visible(){return"none"!==this._outerContainerStyle.display}get contentContainer(){return this.content?.container}get effectivePlacement(){const t=this.options?.placement;return"auto"===t?"bottom-end":t??b}get updating(){return this._updatingHandles.updating}get _screenPoint(){const{inputManager:t}=this.view;return t?.multiTouchActive?null:t?.latestPointerInfo?.location}get _effectiveOffset(){return this.options?.offset??_}get _outerContainerStyle(){const t=this.position??this._screenPoint;if(this._lastPosition=c(t),null!=t&&null!=this.content){return{display:"block",transform:`translate(${Math.round(t.x)}px, ${Math.round(t.y)}px)`}}return{display:"none",transform:"none"}}clear(){this.info=null}async enterInputMode(t){const e=this.position??this._lastPosition??this._screenPoint,o=this.position=c(e),{effectivePlacement:n}=this;this._override("effectivePlacement",n);const i=()=>{o&&(this.position=j(this.contentContainer,o,this._effectiveOffset,this.view),Object.assign(this.outerContainer.style,this._outerContainerStyle))};await this._updatingHandles.addPromise(this.content?.enterInputMode(t,i))}async exitInputMode(t){await this._updatingHandles.addPromise(this.content?.exitInputMode(t))}onDragStart(t,e){this._prevXY=[t,e]}onDrag(t,e){const o=t-this._prevXY[0],n=e-this._prevXY[1];this._prevXY=[t,e];const{position:i}=this;if(i){const{view:s}=this,r=t-s.position[0],l=e-s.position[1];if(r<0||r>s.width||l<0||l>s.height-C)return;this.position=p(i.x+o,i.y+n)}}onDragEnd(){this._prevXY=[0,0]}};function j(t,e,o,n){if(!t||!n.container)return e;const i=t.getBoundingClientRect(),{left:s,top:r}=n.container.getBoundingClientRect();let{x:l,y:a}=e;const c=i.left-s-o;c<0&&(l-=c);const u=i.right-s+o-n.width;u>0&&(l-=u);const d=i.top-r-o;d<0&&(a-=d);const h=i.bottom-r+o-n.height;return h>0&&(a-=h),p(l,a)}t([u({nonNullable:!0})],P.prototype,"view",void 0),t([u()],P.prototype,"info",void 0),t([u()],P.prototype,"options",void 0),t([u()],P.prototype,"position",void 0),t([u()],P.prototype,"content",void 0),t([u({readOnly:!0})],P.prototype,"mode",null),t([u()],P.prototype,"_focused",void 0),t([u({readOnly:!0})],P.prototype,"focused",null),t([u({readOnly:!0})],P.prototype,"outerContainer",void 0),t([u({readOnly:!0})],P.prototype,"contentContainer",null),t([u({readOnly:!0})],P.prototype,"effectivePlacement",null),t([u()],P.prototype,"debug",void 0),t([u()],P.prototype,"updating",null),t([u()],P.prototype,"_lastPosition",void 0),t([u()],P.prototype,"_screenPoint",null),t([u()],P.prototype,"_rtl",void 0),t([u()],P.prototype,"_effectiveOffset",null),t([u()],P.prototype,"_outerContainerStyle",null),P=t([d("esri.views.interactive.Tooltip")],P);const O=["top","bottom","leading","trailing"].flatMap(t=>[w(`${t}-start`),w(t),w(`${t}-end`)]);function w(t){return`${v.base}--${t}`}function x({classList:t},e){O.forEach(e=>t.remove(e)),t.add(w(e))}const $=P;export{$ as default};
5
+ import{__decorate as t}from"tslib";import{EventedAccessor as e}from"../../core/Evented.js";import{on as o}from"../../core/events.js";import{destroyMaybe as n}from"../../core/maybe.js";import{watch as i,when as s,syncAndInitial as r,initial as l,sync as a}from"../../core/reactiveUtils.js";import{cloneScreenPoint as c,createScreenPoint as p}from"../../core/screenUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../core/support/UpdatingHandles.js";import{setCalciteModeClass as f}from"../../support/modeUtils.js";import{base as m}from"./tooltip/css.js";import{tooltipContentFactory as g}from"./tooltip/content/tooltipContentFactory.js";import{isRTL as y}from"../../widgets/support/widgetUtils.js";const v={base:`${m}`,ltr:`${m}--ltr`,rtl:`${m}--rtl`,debug:`${m}--debug`},_=20,C=16,b="bottom-end";let P=class extends e{constructor(t){super(t),this.info=null,this.options=null,this.position=null,this.content=null,this._focused=!1,this.outerContainer=document.createElement("div"),this.debug=!1,this._updatingHandles=new h,this._lastPosition=null,this._rtl=!1,this._prevXY=[0,0]}initialize(){const{outerContainer:t}=this;this.addHandles([i(()=>this.view.overlay?.surface,e=>{t.remove(),e?.appendChild(t),this._rtl=y(e)},r),i(()=>this.info,(e,o)=>{if(null!=this.content&&null!=e&&null!=o&&e.type===o.type)this.content.info=e;else{n(this.content);const o=g(this,e);o?(this.content=o,o.container&&t.appendChild(o.container),this.exitInputMode()):this.content=null}},r),i(()=>({container:this.outerContainer,style:this._outerContainerStyle}),({container:t,style:e})=>{Object.assign(t.style,e)},l),i(()=>({outerContainer:this.outerContainer,placement:this.effectivePlacement,effectiveOffset:this._effectiveOffset,rtl:this._rtl,debug:this.debug}),({outerContainer:t,placement:e,effectiveOffset:o,rtl:n,debug:i})=>{const{classList:s}=t;s.add(v.base),s.toggle(v.rtl,n),s.toggle(v.ltr,!n),s.toggle(v.debug,i),this.outerContainer.style.setProperty("--offset",`${o}px`),f(t),x(t,e)},l),s(()=>"feedback"===this.mode,()=>{this.position=null,this._clearOverride("effectivePlacement")},a),o(this.outerContainer,"paste",t=>{this.emit("paste",t)}),o(this.outerContainer,["focusin","focusout"],()=>{this._focused=this.content?.container?.contains(document.activeElement)??!1})])}destroy(){this.info=null,this.content=n(this.content),this.outerContainer.remove(),this._updatingHandles.destroy()}get mode(){return this.content?.mode??"feedback"}get focused(){return this._focused}get visible(){return"none"!==this._outerContainerStyle.display}get contentContainer(){return this.content?.container}get effectivePlacement(){const t=this.options?.placement;return"auto"===t?"bottom-end":t??b}get updating(){return this._updatingHandles.updating}get _screenPoint(){const{inputManager:t}=this.view;return t?.multiTouchActive?null:t?.latestPointerInfo?.location}get _effectiveOffset(){return this.options?.offset??_}get _outerContainerStyle(){const t=this.position??this._screenPoint;if(this._lastPosition=c(t),null!=t&&null!=this.content){return{display:"block",transform:`translate(${Math.round(t.x)}px, ${Math.round(t.y)}px)`}}return{display:"none",transform:"none"}}clear(){this.info=null}async enterInputMode(t){const e=this.position??this._lastPosition??this._screenPoint,o=this.position=c(e),{effectivePlacement:n}=this;this._override("effectivePlacement",n);const i=()=>{o&&(this.position=j(this.contentContainer,o,this._effectiveOffset,this.view),Object.assign(this.outerContainer.style,this._outerContainerStyle))};await this._updatingHandles.addPromise(this.content?.enterInputMode(t,i))}async exitInputMode(t){await this._updatingHandles.addPromise(this.content?.exitInputMode(t))}onDragStart(t,e){this._prevXY=[t,e]}onDrag(t,e){const o=t-this._prevXY[0],n=e-this._prevXY[1];this._prevXY=[t,e];const{position:i}=this;if(i){const{view:s}=this,r=t-s.position[0],l=e-s.position[1];if(r<0||r>s.width||l<0||l>s.height-C)return;this.position=p(i.x+o,i.y+n)}}onDragEnd(){this._prevXY=[0,0]}};function j(t,e,o,n){if(!t||!n.container)return e;const i=t.getBoundingClientRect(),{left:s,top:r}=n.container.getBoundingClientRect();let{x:l,y:a}=e;const c=i.left-s-o;c<0&&(l-=c);const u=i.right-s+o-n.width;u>0&&(l-=u);const d=i.top-r-o;d<0&&(a-=d);const h=i.bottom-r+o-n.height;return h>0&&(a-=h),p(l,a)}t([u({nonNullable:!0})],P.prototype,"view",void 0),t([u()],P.prototype,"info",void 0),t([u()],P.prototype,"options",void 0),t([u()],P.prototype,"position",void 0),t([u()],P.prototype,"content",void 0),t([u({readOnly:!0})],P.prototype,"mode",null),t([u()],P.prototype,"_focused",void 0),t([u({readOnly:!0})],P.prototype,"focused",null),t([u({readOnly:!0})],P.prototype,"outerContainer",void 0),t([u({readOnly:!0})],P.prototype,"contentContainer",null),t([u({readOnly:!0})],P.prototype,"effectivePlacement",null),t([u()],P.prototype,"debug",void 0),t([u()],P.prototype,"updating",null),t([u()],P.prototype,"_lastPosition",void 0),t([u()],P.prototype,"_screenPoint",null),t([u()],P.prototype,"_rtl",void 0),t([u()],P.prototype,"_effectiveOffset",null),t([u()],P.prototype,"_outerContainerStyle",null),P=t([d("esri.views.interactive.Tooltip")],P);const O=["top","bottom","leading","trailing"].flatMap(t=>[w(`${t}-start`),w(t),w(`${t}-end`)]);function w(t){return`${v.base}--${t}`}function x({classList:t},e){O.forEach(e=>t.remove(e)),t.add(w(e))}const $=P;export{$ as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import r from"../../core/Accessor.js";import i from"../../core/Error.js";import t from"../../core/Logger.js";import{someMap as s}from"../../core/MapUtils.js";import{createResolver as o,createAbortError as a,isAbortError as n}from"../../core/promiseUtils.js";import{on as l,watch as y,syncAndInitial as h}from"../../core/reactiveUtils.js";import{schedule as p}from"../../core/scheduling.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{get as w}from"../../core/accessorSupport/get.js";import{UpdatingHandles as m}from"../../core/support/UpdatingHandles.js";import{destroyMap as u}from"../../support/collectionUtils.js";import{LayerLayerViewInfo as f}from"./LayerLayerViewInfo.js";function g(e){return null!=e&&"object"==typeof e&&"layerViews"in e}let _=class extends r{constructor(e){super(e),this._layerLayerViewInfoMap=new Map,this._recyclingInfoMap=new Map,this._watchUpdatingTracking=new m,this.supportsGround=!0,this._preloadLayerViewModules=()=>{const e=this.view.map?.allLayers;if(e)for(const r of e)!1!==this.layerViewFilter?.(r)&&this.layerViewImporter.hasLayerViewModule(r)&&this.layerViewImporter.importLayerView(r)},this._reschedule=()=>this.destroyed?Promise.reject():(null==this._workPromise&&(this._workPromise=o(),this._workPromise.promise.catch(()=>{})),this.removeHandles("reschedule"),this.addHandles(p(this._doWork),"reschedule"),this._workPromise.promise),this._doWork=()=>{if(this.destroyed)return;const{map:e}=this.view;if(!e)return void this.clear();if(this._map!==e&&(this.clear(),this._map=e),null==this._workPromise)return void this.notifyChange("updating");this.removeHandles("reschedule"),this.removeHandles("collection-change");const r=new Set,i=[],t=this.view.ready,s=e=>{if(null!=e)for(const o of e)if(o){if(!1===this.layerViewFilter?.(o))continue;r.add(o);const e=this._layerLayerViewInfoMap.get(o);e&&t?e.start():e||this._recyclingInfoMap.has(o)||i.push(o),"layers"in o&&o.layers&&s(o.layers)}};for(const n of this._rootCollectionNames)s(w(this,n));const o=new Array,a=e=>{const r=e.tryRecycle(i);r?(this._recyclingInfoMap.set(e.layer,e),this.notifyChange("updating"),r.then(()=>{this._recyclingInfoMap.delete(e.layer),this._layerLayerViewInfoMap.set(e.layer,e),this._reschedule(),this.notifyChange("updating")}).catch(r=>{n(r)||(this._recyclingInfoMap.delete(e.layer),e.destroy(),this._reschedule(),this.notifyChange("updating"))})):o.push(e)};for(const n of this._layerLayerViewInfoMap.values())r.has(n.layer)||(this._layerLayerViewInfoMap.delete(n.layer),a(n));for(const n of this._recyclingInfoMap.values())r.has(n.layer)||(this._recyclingInfoMap.delete(n.layer),a(n));for(const n of i)this._createLayerView(n);this._refreshCollections(),o.forEach(e=>e.destroy());const l=[e?.ground?.layers,e?.basemap?.baseLayers,e?.basemap?.groundLayers,e?.basemap?.referenceLayers,e?.layers].filter(e=>!!e);r.forEach(e=>"layers"in e&&l.push(e.layers)),this.addHandles(l.map(e=>this._watchUpdatingTracking.addOnCollectionChange(()=>e,this._reschedule)),"collection-change"),this._workPromise.resolve(),this._workPromise=null}}initialize(){this.addHandles([l(()=>this.view?.map?.allLayers,"change",this._preloadLayerViewModules,{onListenerAdd:this._preloadLayerViewModules}),y(()=>{const e=this.view,r=e?.map;return[r?.basemap,r?.ground,r?.layers,e?.ready]},()=>this._reschedule(),h)]),this._preloadLayerViewModules(),this._reschedule()}clearHandles(){this._watchUpdatingTracking.removeAll()}destroy(){this.clear(),u(this._recyclingInfoMap),u(this._layerLayerViewInfoMap),this._watchUpdatingTracking.destroy(),this._map=null,null!=this._workPromise&&(this._workPromise.reject(a()),this._workPromise=null)}get _layersToLayerViews(){const e=[["view.map.basemap.baseLayers","view.basemapView.baseLayerViews"],["view.map.basemap.groundLayers","view.basemapView.groundLayerViews"],["view.map.layers","view.layerViews"],["view.map.basemap.referenceLayers","view.basemapView.referenceLayerViews"]];return this.supportsGround&&e.push(["view.map.ground.layers","view.groundView.layerViews"]),new Map(e)}get _rootCollectionNames(){return Array.from(this._layersToLayerViews.keys())}get updating(){return null!=this._workPromise||this._watchUpdatingTracking.updating||s(this._layerLayerViewInfoMap,e=>!e.done)||this._recyclingInfoMap.size>0}get updatingRemaining(){let e=0;for(const r of this._layerLayerViewInfoMap.values())r.done||++e;return e}clear(){this.destroyed||(this._clearCollections(),u(this._layerLayerViewInfoMap))}async whenLayerView(e){await this._reschedule();const r=this._layerLayerViewInfoMap.get(e)?.promise;if(!r){const r=this._recyclingInfoMap.get(e)?.promise;if(!r)throw new i("view:no-layerview-for-layer","No layerview has been found for the layer",{layer:e});return r}return r}isCreatingLayerViewsForLayer(e,r){this.commitProperty("updatingRemaining");const i=this._layerLayerViewInfoMap.get(e);if(!i?.done)return!0;const t=i.layerView;return!(!t||!r||t.parent===r)||!!(i.done&&t&&"layers"in e&&e.layers?.length)&&e.layers.some(e=>this.isCreatingLayerViewsForLayer(e,t))}_refreshCollections(){for(const[e,r]of this._layersToLayerViews)this._populateLayerViewsOwners(w(this,e),w(this,r),this.view);this.notifyChange("updating"),this.notifyChange("updatingRemaining")}_clearCollections(){for(const e of this._layersToLayerViews.values())w(this,e)?.removeAll()}_populateLayerViewsOwners(e,r,i){if(!e||!r)return void r?.removeAll();let t=0;for(const s of e){const e=this._layerLayerViewInfoMap.get(s);if(!e?.layerView)continue;const o=e.layerView;o.layer=s,o.parent=i,r.at(t)!==o&&r.splice(t,0,o),"layers"in s&&g(o)&&this._populateLayerViewsOwners(s.layers,o.layerViews,o),t+=1}t<r.length&&r.splice(t)}_createLayerView(e){e.load().catch(r=>{t.getLogger("LayerViewManager").error(`Error loading layer "${e.title}"`,r)}),this.layerViewImporter.hasLayerViewModule(e)&&this.layerViewImporter.importLayerView(e);const r=new f(e,this.view,this.layerViewImporter);r.promise?.then(()=>this._refreshCollections(),r=>{r&&(n(r)||"cancelled:layerview-create"===r.name)||t.getLogger(this).error(`Failed to create layerview for layer title:'${e.title??"no title"}', id:'${e.id??"no id"}' of type '${e.type}'.`,{layer:e,error:r}),this._refreshCollections()}),this._layerLayerViewInfoMap.set(e,r),this.view.ready&&r.start(),this.notifyChange("updating"),this.notifyChange("updatingRemaining")}};e([c()],_.prototype,"_workPromise",void 0),e([c({readOnly:!0})],_.prototype,"_watchUpdatingTracking",void 0),e([c({readOnly:!0})],_.prototype,"_layersToLayerViews",null),e([c({readOnly:!0})],_.prototype,"_rootCollectionNames",null),e([c({constructOnly:!0})],_.prototype,"layerViewFilter",void 0),e([c()],_.prototype,"layerViewImporter",void 0),e([c()],_.prototype,"supportsGround",void 0),e([c({readOnly:!0})],_.prototype,"updating",null),e([c({readOnly:!0})],_.prototype,"updatingRemaining",null),e([c({constructOnly:!0})],_.prototype,"view",void 0),_=e([d("esri.views.support.LayerViewManager")],_);const V=_;export{V as default};
5
+ import{__decorate as e}from"tslib";import r from"../../core/Accessor.js";import i from"../../core/Error.js";import t from"../../core/Logger.js";import{someMap as s}from"../../core/MapUtils.js";import{createResolver as o,createAbortError as a,isAbortError as n}from"../../core/promiseUtils.js";import{on as l,watch as y,syncAndInitial as h}from"../../core/reactiveUtils.js";import{schedule as p}from"../../core/scheduling.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{get as w}from"../../core/accessorSupport/get.js";import{UpdatingHandles as m}from"../../core/support/UpdatingHandles.js";import{destroyMap as u}from"../../support/collectionUtils.js";import{LayerLayerViewInfo as f}from"./LayerLayerViewInfo.js";function g(e){return null!=e&&"object"==typeof e&&"layerViews"in e}let _=class extends r{constructor(e){super(e),this._layerLayerViewInfoMap=new Map,this._recyclingInfoMap=new Map,this._watchUpdatingTracking=new m,this.supportsGround=!0,this._preloadLayerViewModules=()=>{const e=this.view.map?.allLayers;if(e)for(const r of e)!1!==this.layerViewFilter?.(r)&&this.layerViewImporter.hasLayerViewModule(r)&&this.layerViewImporter.importLayerView(r)},this._reschedule=()=>this.destroyed?Promise.reject():(null==this._workPromise&&(this._workPromise=o(),this._workPromise.promise.catch(()=>{})),this.removeHandles("reschedule"),this.addHandles(p(this._doWork),"reschedule"),this._workPromise.promise),this._doWork=()=>{if(this.destroyed)return;const{map:e}=this.view;if(!e)return void this.clear();if(this._map!==e&&(this.clear(),this._map=e),null==this._workPromise)return void this.notifyChange("updating");this.removeHandles("reschedule"),this.removeHandles("collection-change");const r=new Set,i=[],t=this.view.ready,s=e=>{if(null!=e)for(const o of e)if(o){if(!1===this.layerViewFilter?.(o))continue;r.add(o);const e=this._layerLayerViewInfoMap.get(o);e&&t?e.start():e||this._recyclingInfoMap.has(o)||i.push(o),"layers"in o&&o.layers&&s(o.layers)}};for(const n of this._rootCollectionNames)s(w(this,n));const o=new Array,a=e=>{const r=e.tryRecycle(i);r?(this._recyclingInfoMap.set(e.layer,e),this.notifyChange("updating"),r.then(()=>{this._recyclingInfoMap.delete(e.layer),this._layerLayerViewInfoMap.set(e.layer,e),this._reschedule(),this.notifyChange("updating")}).catch(r=>{n(r)||(this._recyclingInfoMap.delete(e.layer),e.destroy(),this._reschedule(),this.notifyChange("updating"))})):o.push(e)};for(const n of this._layerLayerViewInfoMap.values())r.has(n.layer)||(this._layerLayerViewInfoMap.delete(n.layer),a(n));for(const n of this._recyclingInfoMap.values())r.has(n.layer)||(this._recyclingInfoMap.delete(n.layer),a(n));for(const n of i)this._createLayerView(n);this._refreshCollections(),o.forEach(e=>e.destroy());const l=[e?.ground?.layers,e?.basemap?.baseLayers,e?.basemap?.groundLayers,e?.basemap?.referenceLayers,e?.layers].filter(e=>!!e);r.forEach(e=>"layers"in e&&l.push(e.layers)),this.addHandles(l.map(e=>this._watchUpdatingTracking.addOnCollectionChange(()=>e,this._reschedule)),"collection-change"),this._workPromise.resolve(),this._workPromise=null}}initialize(){this.addHandles([l(()=>this.view?.map?.allLayers,"change",this._preloadLayerViewModules,{onListenerAdd:this._preloadLayerViewModules}),y(()=>{const e=this.view,r=e?.map;return[r?.basemap,r?.ground,r?.layers,e?.ready]},()=>this._reschedule(),h)]),this._preloadLayerViewModules(),this._reschedule()}clearHandles(){this._watchUpdatingTracking.removeAll()}destroy(){this.clear(),u(this._recyclingInfoMap),u(this._layerLayerViewInfoMap),this._watchUpdatingTracking.destroy(),this._map=null,null!=this._workPromise&&(this._workPromise.reject(a()),this._workPromise=null)}get _layersToLayerViews(){const e=[["view.map.basemap.baseLayers","view.basemapView.baseLayerViews"],["view.map.basemap.groundLayers","view.basemapView.groundLayerViews"],["view.map.layers","view.layerViews"],["view.map.basemap.referenceLayers","view.basemapView.referenceLayerViews"]];return this.supportsGround&&e.push(["view.map.ground.layers","view.groundView.layerViews"]),new Map(e)}get _rootCollectionNames(){return Array.from(this._layersToLayerViews.keys())}get updating(){return null!=this._workPromise||this._watchUpdatingTracking.updating||s(this._layerLayerViewInfoMap,e=>!e.done)||this._recyclingInfoMap.size>0}get updatingRemaining(){let e=0;for(const r of this._layerLayerViewInfoMap.values())r.done||++e;return e}clear(){this.destroyed||(this._clearCollections(),u(this._layerLayerViewInfoMap))}async whenLayerView(e){await this._reschedule();const r=this._layerLayerViewInfoMap.get(e)?.promise;if(!r){const r=this._recyclingInfoMap.get(e)?.promise;if(!r)throw new i("view:no-layerview-for-layer","No layerview has been found for the layer",{layer:e});return r}return r}isCreatingLayerViewsForLayer(e,r){this.commitProperty("updatingRemaining");const i=this._layerLayerViewInfoMap.get(e);if(!i?.done)return!0;const t=i.layerView;return!(!t||!r||t.parent===r)||!!(i.done&&t&&"layers"in e&&e.layers?.length)&&e.layers.some(e=>this.isCreatingLayerViewsForLayer(e,t))}_refreshCollections(){for(const[e,r]of this._layersToLayerViews)this._populateLayerViewsOwners(w(this,e),w(this,r),this.view);this.notifyChange("updating"),this.notifyChange("updatingRemaining")}_clearCollections(){for(const e of this._layersToLayerViews.values())w(this,e)?.removeAll()}_populateLayerViewsOwners(e,r,i){if(!e||!r)return void r?.removeAll();let t=0;for(const s of e){const e=this._layerLayerViewInfoMap.get(s);if(!e?.layerView)continue;const o=e.layerView;o.layer=s,o.parent=i,r.at(t)!==o&&r.splice(t,0,o),"layers"in s&&g(o)&&this._populateLayerViewsOwners(s.layers,o.layerViews,o),t+=1}t<r.length&&r.splice(t)}_createLayerView(e){e.load().catch(r=>{t.getLogger("LayerViewManager").error(`Error loading layer "${e.title}"`,r)}),this.layerViewImporter.hasLayerViewModule(e)&&this.layerViewImporter.importLayerView(e);const r=new f(e,this.view,this.layerViewImporter);r.promise?.then(()=>this._refreshCollections(),r=>{r&&(n(r)||"cancelled:layerview-create"===r.name)||t.getLogger(this).error(`Failed to create layerview for layer title:'${e.title??"no title"}', id:'${e.id??"no id"}' of type '${e.type}'.`,{layer:e,error:r}),this.destroyed||this._refreshCollections()}),this._layerLayerViewInfoMap.set(e,r),this.view.ready&&r.start(),this.notifyChange("updating"),this.notifyChange("updatingRemaining")}};e([c()],_.prototype,"_workPromise",void 0),e([c({readOnly:!0})],_.prototype,"_watchUpdatingTracking",void 0),e([c({readOnly:!0})],_.prototype,"_layersToLayerViews",null),e([c({readOnly:!0})],_.prototype,"_rootCollectionNames",null),e([c({constructOnly:!0})],_.prototype,"layerViewFilter",void 0),e([c()],_.prototype,"layerViewImporter",void 0),e([c()],_.prototype,"supportsGround",void 0),e([c({readOnly:!0})],_.prototype,"updating",null),e([c({readOnly:!0})],_.prototype,"updatingRemaining",null),e([c({constructOnly:!0})],_.prototype,"view",void 0),_=e([d("esri.views.support.LayerViewManager")],_);const V=_;export{V 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{JSONSupport as t}from"../core/JSONSupport.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{reader as o}from"../core/accessorSupport/decorators/reader.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import{writer as a}from"../core/accessorSupport/decorators/writer.js";var d;let i=class extends t{static{d=this}constructor(...e){super(...e),this.type="sun",this.date=null,this.directShadowsEnabled=!1,this.displayUTCOffset=null}readDate(e,t){return null!=t.datetime&&new Date(t.datetime)||null}writeDate(e,t,r){t[r]=e.getTime()}readDirectShadowsEnabled(e,t){return!!t.directShadows}writedirectShadowsEnabled(e,t,r){e&&(t[r]=e)}writeDisplayUTCOffset(e,t){null!=e&&(t.displayUTCOffset=e)}clone(){return new d(this.cloneConstructProperties())}cloneConstructProperties(){const e={directShadowsEnabled:this.directShadowsEnabled,displayUTCOffset:null!=this.displayUTCOffset?this.displayUTCOffset:null};return null!=this.date&&(e.date=new Date(this.date)),e}};e([r({readOnly:!0,type:["sun"],json:{write:!0}})],i.prototype,"type",void 0),e([r({type:Date,json:{type:Number,write:{target:"datetime"}}})],i.prototype,"date",void 0),e([o("date",["datetime"])],i.prototype,"readDate",null),e([a("date")],i.prototype,"writeDate",null),e([r({type:Boolean,json:{default:!1,write:{target:"directShadows"}}})],i.prototype,"directShadowsEnabled",void 0),e([o("directShadowsEnabled",["directShadows"])],i.prototype,"readDirectShadowsEnabled",null),e([a("directShadowsEnabled")],i.prototype,"writedirectShadowsEnabled",null),e([r({type:Number,json:{write:!0}})],i.prototype,"displayUTCOffset",void 0),e([a("displayUTCOffset")],i.prototype,"writeDisplayUTCOffset",null),i=d=e([s("esri.webscene.SunLighting")],i);const p=i;export{p as default};
5
+ import{__decorate as e}from"tslib";import{JSONSupport as t}from"../core/JSONSupport.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{reader as o}from"../core/accessorSupport/decorators/reader.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import{writer as a}from"../core/accessorSupport/decorators/writer.js";var d;let i=class extends t{static{d=this}constructor(e){super(e),this.type="sun",this.date=null,this.directShadowsEnabled=!1,this.displayUTCOffset=null}readDate(e,t){return null!=t.datetime&&new Date(t.datetime)||null}writeDate(e,t,r){t[r]=e.getTime()}readDirectShadowsEnabled(e,t){return!!t.directShadows}writedirectShadowsEnabled(e,t,r){e&&(t[r]=e)}writeDisplayUTCOffset(e,t){null!=e&&(t.displayUTCOffset=e)}clone(){return new d(this.cloneConstructProperties())}cloneConstructProperties(){const e={directShadowsEnabled:this.directShadowsEnabled,displayUTCOffset:null!=this.displayUTCOffset?this.displayUTCOffset:null};return null!=this.date&&(e.date=new Date(this.date)),e}};e([r({readOnly:!0,type:["sun"],json:{write:!0}})],i.prototype,"type",void 0),e([r({type:Date,json:{type:Number,write:{target:"datetime"}}})],i.prototype,"date",void 0),e([o("date",["datetime"])],i.prototype,"readDate",null),e([a("date")],i.prototype,"writeDate",null),e([r({type:Boolean,json:{default:!1,write:{target:"directShadows"}}})],i.prototype,"directShadowsEnabled",void 0),e([o("directShadowsEnabled",["directShadows"])],i.prototype,"readDirectShadowsEnabled",null),e([a("directShadowsEnabled")],i.prototype,"writedirectShadowsEnabled",null),e([r({type:Number,json:{write:!0}})],i.prototype,"displayUTCOffset",void 0),e([a("displayUTCOffset")],i.prototype,"writeDisplayUTCOffset",null),i=d=e([s("esri.webscene.SunLighting")],i);const p=i;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.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as r}from"tslib";import{JSONSupport as t}from"../core/JSONSupport.js";import{property as e}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as o}from"../core/accessorSupport/decorators/subclass.js";var s;let i=class extends t{static{s=this}constructor(...r){super(...r),this.type="virtual",this.directShadowsEnabled=!1}clone(){return new s(this.cloneConstructProperties())}cloneConstructProperties(){return{directShadowsEnabled:this.directShadowsEnabled}}};r([e({readOnly:!0,type:["virtual"],json:{write:{isRequired:!0}}})],i.prototype,"type",void 0),r([e({type:Boolean,json:{default:!1,name:"directShadows",write:!0}})],i.prototype,"directShadowsEnabled",void 0),i=s=r([o("esri.webscene.VirtualLighting")],i);const c=i;export{c as default};
5
+ import{__decorate as r}from"tslib";import{JSONSupport as t}from"../core/JSONSupport.js";import{property as e}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as o}from"../core/accessorSupport/decorators/subclass.js";var s;let i=class extends t{static{s=this}constructor(r){super(r),this.type="virtual",this.directShadowsEnabled=!1}clone(){return new s(this.cloneConstructProperties())}cloneConstructProperties(){return{directShadowsEnabled:this.directShadowsEnabled}}};r([e({readOnly:!0,type:["virtual"],json:{write:{isRequired:!0}}})],i.prototype,"type",void 0),r([e({type:Boolean,json:{default:!1,name:"directShadows",write:!0}})],i.prototype,"directShadowsEnabled",void 0),i=s=r([o("esri.webscene.VirtualLighting")],i);const c=i;export{c as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import r from"../../../core/Error.js";import"../../../core/has.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{fromUsng as i,fromUtm as s,fromMgrs as a,fromLatitudeLongitude as l,toUtm as c,toUsng as p,toMgrs as u,toLatitudeLongitude as m}from"../../../geometry/coordinateFormatter.js";import{isLoaded as d,project as h}from"../../../geometry/projectionUtils.js";import f from"../../../geometry/SpatialReference.js";import{equals as v}from"../../../geometry/support/spatialReferenceUtils.js";import{project as g}from"../../../geometry/support/webMercatorUtils.js";import{isValidPoint as y,fromXY as w,pointToCoordinate as b,getDegreePrecision as S}from"./coordinateConversionUtils.js";let _=class extends t{constructor(e){super(e),this.conversionInfo=null,this.coordinateSegments=null,this._currentPattern=void 0,this.defaultPattern=null,this.name=null,this.viewModel=null}get currentPattern(){return(this._currentPattern||this.defaultPattern)??""}set currentPattern(e){this._currentPattern=e}get label(){return this.name??""}set label(e){this._overrideIfSome("label",e)}get hasDisplayProperties(){return!(!this.defaultPattern||!this.coordinateSegments)}get spatialReference(){return"basemap"===this.name?this._viewSpatialReference:this.conversionInfo?.spatialReference??f.WGS84}set spatialReference(e){this._overrideIfSome("spatialReference",e)}get _viewSpatialReference(){return this.viewModel?.view?.spatialReference??f.WGS84}get _additionalCharactersPattern(){const e=this.coordinateSegments;if(!e)return null;const t=e.map(e=>e.alias),r=this.currentPattern.replaceAll(new RegExp(`["nsew${t.join()}]`,"gi"),"").replaceAll(" ","");return new RegExp(`[${r}]`,"g")}get test(){}async convert(e){if(!y(e))throw new r("format:invalid-point","Could not convert invalid point.",{point:e});const t=this.conversionInfo?.convert;if(t)return Promise.resolve().then(()=>t(e));const n=this._project(e,this.spatialReference);return{location:n,coordinate:this._getCoordinate(n)}}getConversionStrategy(){const e=this._viewSpatialReference;return this.conversionInfo?.convert||this.viewModel?.formatterAvailable||"xy"===this.name&&(e.isWebMercator||e.isWGS84)||"basemap"===this.name?"client":"server"}getDisplayCoordinate(e){if(!e)return null;if(!this.coordinateSegments||!this.currentPattern)return e;let t=this.currentPattern;const r=this._getSegmentMatches(e,!1);for(let n=this.coordinateSegments.length-1;n>=0;n--){const e=this.coordinateSegments[n];t=t.replace(e.alias,r[n])}return t}_parseUserInput(e){const{defaultPattern:t,_additionalCharactersPattern:r,coordinateSegments:n}=this;if(!t||!r)return"";let o=t.replace(r,"");e=e.replace(r,"");const i=this._getSegmentMatches(e,!0);if(n)for(let s=n.length-1;s>=0;s--){const e=n[s];o=o.replace(e.alias,i[s])}return o}_getSegmentMatches(e,t){const r=new Array,{coordinateSegments:n}=this;if(!n)return r;for(let o=0;o<n.length;o++){const i=n[o],s=e.match(i.searchPattern);if(!s){r.push("");continue}let a=s[0];if(e=e.replace(a,"").trim(),i.substitution){const e=t?i.substitution.input(a):i.substitution.output(a);e&&(a=`${e}`)}r.push(a)}return r}async reverseConvert(e){const t=this._parseUserInput(e),n=this.conversionInfo?.reverseConvert;let o;if(n)o=n(t);else if("xy"===this.name||"basemap"===this.name)o=w(t,this.spatialReference);else if(this.viewModel?.formatterAvailable)switch(this.name){case"dd":case"ddm":case"dms":o=l(t,this.spatialReference);break;case"mgrs":{const e="automatic";o=a(t,this.spatialReference,e);break}case"utm":{const e="latitude-band-indicators";o=s(t,this.spatialReference,e);break}case"usng":o=i(t,this.spatialReference);break;default:o=null}if(!o)throw new r("format:invalid-input","Could not parse input into point.",{userInput:e});return this._project(o,this._viewSpatialReference)}_getCoordinate(e){const t=this.viewModel?.view?.scale??0;if(!y(e))throw new r("format:invalid-point","Could not transform invalid point into coordinate.",{point:e});if(this.viewModel?.formatterAvailable||"basemap"===this.name||"xy"===this.name)switch(this.name){case"dd":case"ddm":case"dms":{const r=S(t);return m(e,this.name,r)}case"mgrs":return u(e,"automatic",5,!1);case"usng":return p(e,5,!1);case"utm":return c(e,"latitude-band-indicators",!0);default:return b(e,t)}return b(e,t)}_project(e,t){if(v(e.spatialReference,t)||!t)return e;if(this.viewModel?.formatterAvailable&&d())return h(e,t);if(!this.viewModel?.formatterAvailable){const r=g(e,t);if(null!=r)return r}return null}};e([n()],_.prototype,"conversionInfo",void 0),e([n()],_.prototype,"coordinateSegments",void 0),e([n()],_.prototype,"currentPattern",null),e([n()],_.prototype,"_currentPattern",void 0),e([n()],_.prototype,"label",null),e([n()],_.prototype,"defaultPattern",void 0),e([n({readOnly:!0})],_.prototype,"hasDisplayProperties",null),e([n()],_.prototype,"name",void 0),e([n({type:f})],_.prototype,"spatialReference",null),e([n()],_.prototype,"viewModel",void 0),e([n({readOnly:!0})],_.prototype,"_viewSpatialReference",null),e([n({readOnly:!0})],_.prototype,"_additionalCharactersPattern",null),_=e([o("esri.widgets.CoordinateConversion.support.Format")],_);const R=_;export{R as default};
5
+ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import r from"../../../core/Error.js";import"../../../core/has.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{fromUsng as i,fromUtm as s,fromMgrs as a,fromLatitudeLongitude as l,toUtm as c,toUsng as p,toMgrs as u,toLatitudeLongitude as m}from"../../../geometry/coordinateFormatter.js";import{isLoaded as d,project as h}from"../../../geometry/projectionUtils.js";import f from"../../../geometry/SpatialReference.js";import{equals as v}from"../../../geometry/support/spatialReferenceUtils.js";import{project as g}from"../../../geometry/support/webMercatorUtils.js";import{isValidPoint as y,fromXY as w,pointToCoordinate as b,getDegreePrecision as S}from"./coordinateConversionUtils.js";let _=class extends t{constructor(e){super(e),this.conversionInfo=null,this.coordinateSegments=null,this._currentPattern=void 0,this.defaultPattern=null,this.name=null,this.viewModel=null}get currentPattern(){return(this._currentPattern||this.defaultPattern)??""}set currentPattern(e){this._currentPattern=e}get label(){return this.name??""}set label(e){this._overrideIfSome("label",e)}get hasDisplayProperties(){return!(!this.defaultPattern||!this.coordinateSegments)}get spatialReference(){return"basemap"===this.name?this._viewSpatialReference:this.conversionInfo?.spatialReference??f.WGS84}set spatialReference(e){this._overrideIfSome("spatialReference",e)}get _viewSpatialReference(){return this.viewModel?.view?.spatialReference??f.WGS84}get _additionalCharactersPattern(){const e=this.coordinateSegments;if(!e)return null;const t=e.map(e=>e.alias),r=this.currentPattern.replaceAll(new RegExp(`["nsew${t.join()}]`,"gi"),"").replaceAll(" ","");return new RegExp(`[${r}]`,"g")}get test(){}async convert(e){if(!y(e))throw new r("format:invalid-point","Could not convert invalid point.",{point:e});const t=this.conversionInfo?.convert;if(t)return Promise.resolve().then(()=>t(e));const n=this._project(e,this.spatialReference);return{location:n,coordinate:this._getCoordinate(n)}}getConversionStrategy(){const e=this._viewSpatialReference;return this.conversionInfo?.convert||this.viewModel?.formatterAvailable||"xy"===this.name&&(e.isWebMercator||e.isWGS84)||"basemap"===this.name?"client":"server"}getDisplayCoordinate(e){if(!e)return null;if(!this.coordinateSegments||!this.currentPattern)return e;let t=this.currentPattern;const r=this._getSegmentMatches(e,!1);for(let n=this.coordinateSegments.length-1;n>=0;n--){const e=this.coordinateSegments[n];t=t.replace(e.alias,r[n])}return t}_parseUserInput(e){const{defaultPattern:t,_additionalCharactersPattern:r,coordinateSegments:n}=this;if(!t||!r)return"";let o=t.replace(r,"");e=e.replace(r,"");const i=this._getSegmentMatches(e,!0);if(n)for(let s=n.length-1;s>=0;s--){const e=n[s];o=o.replace(e.alias,i[s])}return o}_getSegmentMatches(e,t){const r=new Array,{coordinateSegments:n}=this;if(!n)return r;for(let o=0;o<n.length;o++){const i=n[o],s=e.match(i.searchPattern);if(!s){r.push("");continue}let a=s[0];if(e=e.replace(a,"").trim(),i.substitution){const e=t?i.substitution.input(a):i.substitution.output(a);e&&(a=`${e}`)}r.push(a)}return r}async reverseConvert(e){const t=this._parseUserInput(e),n=this.conversionInfo?.reverseConvert;let o;if(n)o=n(t);else if("xy"===this.name||"basemap"===this.name)o=w(t,this.spatialReference);else if(this.viewModel?.formatterAvailable)switch(this.name){case"dd":case"ddm":case"dms":o=l(t,this.spatialReference);break;case"mgrs":{const e="automatic";o=a(t,this.spatialReference,e);break}case"utm":{const e="latitude-band-indicators";o=s(t,this.spatialReference,e);break}case"usng":o=i(t,this.spatialReference);break;default:o=null}if(!o)throw new r("format:invalid-input","Could not parse input into point.",{coordinate:e});return this._project(o,this._viewSpatialReference)}_getCoordinate(e){const t=this.viewModel?.view?.scale??0;if(!y(e))throw new r("format:invalid-point","Could not transform invalid point into coordinate.",{point:e});if(this.viewModel?.formatterAvailable||"basemap"===this.name||"xy"===this.name)switch(this.name){case"dd":case"ddm":case"dms":{const r=S(t);return m(e,this.name,r)}case"mgrs":return u(e,"automatic",5,!1);case"usng":return p(e,5,!1);case"utm":return c(e,"latitude-band-indicators",!0);default:return b(e,t)}return b(e,t)}_project(e,t){if(v(e.spatialReference,t)||!t)return e;if(this.viewModel?.formatterAvailable&&d())return h(e,t);if(!this.viewModel?.formatterAvailable){const r=g(e,t);if(null!=r)return r}return null}};e([n()],_.prototype,"conversionInfo",void 0),e([n()],_.prototype,"coordinateSegments",void 0),e([n()],_.prototype,"currentPattern",null),e([n()],_.prototype,"_currentPattern",void 0),e([n()],_.prototype,"label",null),e([n()],_.prototype,"defaultPattern",void 0),e([n({readOnly:!0})],_.prototype,"hasDisplayProperties",null),e([n()],_.prototype,"name",void 0),e([n({type:f})],_.prototype,"spatialReference",null),e([n()],_.prototype,"viewModel",void 0),e([n({readOnly:!0})],_.prototype,"_viewSpatialReference",null),e([n({readOnly:!0})],_.prototype,"_additionalCharactersPattern",null),_=e([o("esri.widgets.CoordinateConversion.support.Format")],_);const R=_;export{R as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../core/Error.js";import t from"../../core/Logger.js";import{isAbortError as r,throwIfNotAbortError as o}from"../../core/promiseUtils.js";import{zoomToFeature as i,zoomToClusteredFeatures as n,browseClusteredFeatures as a,removeSelectedFeature as s}from"./actions.js";const c="esri.widgets.Popup.PopupViewModel",u=()=>t.getLogger(c),l=t=>{const{event:r,view:c,viewModel:u}=t,{action:l}=r;if(!l)return Promise.reject(new e("trigger-action:missing-arguments","Event has no action"));const{disabled:d,id:g}=l;if(!g)return Promise.reject(new e("trigger-action:invalid-action","action.id is missing"));if(d)return Promise.reject(new e("trigger-action:invalid-action","Action is disabled"));if(g===i.id)return f(u).catch(o);if(g===n.id)return m(u);if(g===a.id)return u.browseClusterEnabled=!u.browseClusterEnabled,u.featureMenuOpen=u.browseClusterEnabled,Promise.resolve();if(g===s.id){u.visible=!1;const{selectedFeature:t}=u;if(!t)return Promise.reject(new e(`trigger-action:${s.id}`,"selectedFeature is required",{selectedFeature:t}));const{sourceLayer:r}=t;return r?r.remove(t):c?.graphics.remove(t),Promise.resolve()}return Promise.resolve()};function d(e){const{selectedFeature:t,location:r,view:o}=e;return o?t??r??null:null}function g(e){return!!e&&e.isAggregate&&"cluster"===e.sourceLayer?.featureReduction?.type}async function w(e,t){if("3d"!==t?.type||!e||"esri.Graphic"!==e.declaredClass)return!0;const r=t.getViewForGraphic(e);if(r&&"whenGraphicBounds"in r){let t=null;try{t=await r.whenGraphicBounds(e,{useViewElevation:!0})}catch(o){}return!t||!t.boundingBox||t.boundingBox[0]===t.boundingBox[3]&&t.boundingBox[1]===t.boundingBox[4]&&t.boundingBox[2]===t.boundingBox[5]}return!0}async function f(t,o){const{location:n,selectedFeature:a,view:s,zoomFactor:c}=t;await(o?.viewModel?.updateGeometry());const l=o?.graphic,g=l?.geometry?l:d(t);if(!s||!g){const t=new e("zoom-to:invalid-target-or-view","Cannot zoom to location without a target and view.",{target:g,view:s});throw u().error(t),t}const f=s.scale/c,m=l?.geometry??t.selectedFeature?.geometry??n,v=null!=m&&"point"===m.type&&await w(l??a,s);i.active=!0,i.disabled=!0;try{await t.zoomTo({target:{target:g,scale:v?f:void 0}})}catch(p){if(r(p))return;const t=new e("zoom-to:invalid-graphic","Could not zoom to the location of the graphic.",{graphic:l??a});u().error(t)}finally{i.active=!1,i.disabled=!1,t.zoomToLocation=null,v&&(t.location=m)}}async function m(t){const{selectedFeature:r,view:o}=t;if("2d"!==o?.type){const t=new e("zoomToCluster:invalid-view","View must be 2d MapView.",{view:o});throw u().error(t),t}if(!r||!g(r)){const t=new e("zoomToCluster:invalid-selectedFeature","Selected feature must represent an aggregate/cluster graphic.",{selectedFeature:r});throw u().error(t),t}const[i,a]=await y(o,r);n.active=!0,n.disabled=!0;const{extent:s}=await i.queryExtent(a);s&&await t.zoomTo({target:s}),n.active=!1,n.disabled=!1}async function v(e){const{view:t,selectedFeature:r}=e;if(!t||!r)return;const[o,i]=await y(t,r),{extent:n}=await o.queryExtent(i);e.selectedClusterBoundaryFeature.geometry=n,t.graphics.add(e.selectedClusterBoundaryFeature)}async function p(e){const{selectedFeature:t,view:r}=e;if(!r||!t)return;const[o,i]=await y(r,t);a.active=!0,a.disabled=!0;const{features:n}=await o.queryFeatures(i);a.active=!1,a.disabled=!1,a.value=!0;const s={features:[t].concat(n)};"feature"===e?.initialDisplayMode&&(s.featureMenuOpen=!0),e?.open(s)}async function y(e,t){const r=await e.whenLayerView(t.sourceLayer),o=r.createQuery(),i=t.getObjectId();return o.aggregateIds=null!=i?[i]:[],[r,o]}function h(e){a.value=!1;const t=e.features.filter(e=>g(e));t.length&&(e.features=t)}export{p as browseAggregateFeatures,v as displayClusterExtent,d as getSelectedTarget,g as isClusterFeature,h as removeClusteredFeaturesForBrowsing,l as triggerAction,m as zoomToClusterExtent,f as zoomToLocation};
5
+ import e from"../../core/Error.js";import t from"../../core/Logger.js";import{isAbortError as r,throwIfNotAbortError as o}from"../../core/promiseUtils.js";import{zoomToFeature as i,zoomToClusteredFeatures as n,browseClusteredFeatures as a,removeSelectedFeature as s}from"./actions.js";const c="esri.widgets.Popup.PopupViewModel",u=()=>t.getLogger(c),l=t=>{const{event:r,view:c,viewModel:u}=t,{action:l}=r;if(!l)return Promise.reject(new e("trigger-action:missing-arguments","Event has no action"));const{disabled:d,id:g}=l;if(!g)return Promise.reject(new e("trigger-action:invalid-action","action.id is missing"));if(d)return Promise.reject(new e("trigger-action:invalid-action","Action is disabled"));if(g===i.id)return f(u).catch(o);if(g===n.id)return m(u);if(g===a.id)return u.browseClusterEnabled=!u.browseClusterEnabled,u.featureMenuOpen=u.browseClusterEnabled,Promise.resolve();if(g===s.id){u.visible=!1;const{selectedFeature:t}=u;if(!t)return Promise.reject(new e(`trigger-action:${s.id}`,"selectedFeature is required",{selectedFeature:t}));const{sourceLayer:r}=t;return r?r.remove(t):c?.graphics.remove(t),Promise.resolve()}return Promise.resolve()};function d(e){const{selectedFeature:t,location:r,view:o}=e;return o?t??r??null:null}function g(e){return!!e&&e.isAggregate&&"cluster"===e.sourceLayer?.featureReduction?.type}async function w(e,t){if("3d"!==t?.type||!e||"esri.Graphic"!==e.declaredClass)return!0;const r=t.getViewForGraphic(e);if(r&&"whenGraphicBounds"in r){let t=null;try{t=await r.whenGraphicBounds(e,{useViewElevation:!0})}catch(o){}return!t||!t.boundingBox||t.boundingBox[0]===t.boundingBox[3]&&t.boundingBox[1]===t.boundingBox[4]&&t.boundingBox[2]===t.boundingBox[5]}return!0}async function f(t,o){const{location:n,selectedFeature:a,view:s,zoomFactor:c}=t;await(o?.viewModel?.updateGeometry());const l=o?.graphic,g=l?.geometry?l:d(t);if(!s||!g){const t=new e("zoom-to:invalid-target-or-view","Cannot zoom to location without a target and view.",{target:g,view:s});throw u().error(t),t}const f=s.scale/c,m=l?.geometry??t.selectedFeature?.geometry??n,v=null!=m&&"point"===m.type&&await w(l??a,s);i.active=!0,i.disabled=!0;try{await t.zoomTo({target:{target:g,scale:v?f:void 0}})}catch(p){if(r(p))return;const t=new e("zoom-to:invalid-graphic","Could not zoom to the location of the graphic.",{graphic:l??a});u().error(t)}finally{i.active=!1,i.disabled=!1,t.zoomToLocation=null,v&&(t.location=m)}}async function m(t){const{selectedFeature:r,view:o}=t;if("2d"!==o?.type){const t=new e("zoomToCluster:invalid-view","View must be 2d MapView.",{view:o});throw u().error(t),t}if(!r||!g(r)){const t=new e("zoomToCluster:invalid-selectedFeature","Selected feature must represent an aggregate/cluster graphic.",{selectedFeature:r});throw u().error(t),t}const[i,a]=await y(o,r);n.active=!0,n.disabled=!0;const{extent:s}=await i.queryExtent(a);s&&await t.zoomTo({target:s}),n.active=!1,n.disabled=!1}async function v(e){const{view:t,selectedFeature:r}=e;if(!t||!r)return;const[o,i]=await y(t,r),{extent:n}=await o.queryExtent(i);e.selectedClusterBoundaryFeature.geometry=n,t.graphics.add(e.selectedClusterBoundaryFeature)}async function p(e){const{selectedFeature:t,view:r}=e;if(!r||!t)return;const[o,i]=await y(r,t);a.active=!0,a.disabled=!0;const{features:n}=await o.queryFeatures(i);a.active=!1,a.disabled=!1,a.value=!0;const s={features:[t].concat(n)};"feature"===e?.initialDisplayMode&&(s.featureMenuOpen=!0),e?.open(s)}async function y(e,t){const r=await e.whenLayerView(t.sourceLayer),o=r.createQuery(),i=t.getObjectId();return o.aggregateIds=null!=i?[i]:[],[r,o]}function h(e){a.value=!1;const t=e.features.filter(e=>g(e));t.length&&(e.features=t)}export{p as browseAggregateFeatures,v as displayClusterExtent,d as getSelectedTarget,g as isClusterFeature,w as isZoomScreenSize,h as removeClusteredFeaturesForBrowsing,l as triggerAction,m as zoomToClusterExtent,f as zoomToLocation};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import{isSome as e}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import i from"../../core/Error.js";import{EventedAccessor as o}from"../../core/Evented.js";import{clone as a}from"../../core/lang.js";import{LoadableMixin as r}from"../../core/Loadable.js";import{EsriPromiseMixin as l}from"../../core/Promise.js";import n from"../../core/ReactiveMap.js";import{watch as p,initial as m}from"../../core/reactiveUtils.js";import{createScreenPoint as h}from"../../core/screenUtils.js";import{unitType as d,convertUnit as u,getMetersPerUnitForSR as c,inchesPerMeter as f}from"../../core/unitUtils.js";import{property as y}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as T}from"../../core/accessorSupport/decorators/subclass.js";import v from"../../geometry/Extent.js";import w from"../../geometry/SpatialReference.js";import{formatDate as _,convertDateFormatToIntlOptions as I}from"../../intl/date.js";import{getLocaleLanguage as g}from"../../intl/locale.js";import x from"../../portal/Portal.js";import O from"../../portal/PortalQueryParams.js";import{reArcGISOnlineDomain as b}from"../../portal/support/urlUtils.js";import{execute as E,getTaskInfo as P}from"../../rest/print.js";import{formatJsonMap as L}from"../../rest/support/fileFormat.js";import{fromJSON as S}from"../../rest/support/layoutTemplate.js";import U from"../../rest/support/PrintParameters.js";import k from"../../rest/support/PrintTemplate.js";import{getExtent as C}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as j}from"../../views/input/InputManager.js";import F from"../../views/overlay/BoxOverlayItem.js";import H from"./CustomTemplate.js";import M from"./FileLink.js";import D from"./TemplateOptions.js";import{fetchLayoutTemplateInfos as A,valueUnitKebabDict as W}from"./utils.js";const R=[30,144,255,255],N=[237,211,23,255],z=[216,48,32,255],V=new Set(["GISProfessionalStdUT","GISProfessionalAdvUT"]),B=/(\/GPServer\/).+/i,G=96,q=s.ofType(H),$=s.ofType(M);function J(t){t.layoutOptions??={},t.layoutOptions.customTextElements??=[];const e="date";if(!t.layoutOptions.customTextElements.find(t=>e in t)){const{customTextElements:e}=t.layoutOptions;let s=_(Date.now(),I("short-date"));"ar"===g()&&(s="‏"+s),e.push({date:s})}}function Q(t,e,s){if(!e)return;!(e.visible===s)&&t.layoutOptions&&(t.layoutOptions.elementOverrides?t.layoutOptions.elementOverrides[e.name]={visible:s}:t.layoutOptions.elementOverrides={[e.name]:{visible:s}})}let K=class extends(r(l(o))){constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._templateIdToCustomTemplate=new n,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this._asyncPrintTaskUrl=null,this._layoutInfoTaskUrl=null,this._portalLayoutInfoTaskUrl=null,this._customLayoutOptions=null,this._exportedFileNameMap={},this._layoutTemplateInfosCache=new Map,this._tasksInfoCache=new Map,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new q,this.defaultTemplates=new q,this.error=null,this.exportedLinks=new $,this.extraParameters=null,this.includeDefaultTemplates=!0,this.outSpatialReference=null,this.portal=x.getDefault(),this.portalTemplateIds=[],this.printServiceTemplates=new q,this.defaultTemplate=null,this.showPrintAreaEnabled=!1,this.printServiceUrl=null,this.printTimeout=12e4,this.saveExportEnabled=!1,this.templatesInfo=null,this.updateDelay=1e3,this.view=null,this.templateCustomTextElements=null,this.templateOptions=new D}initialize(){this.addHandles([p(()=>[this.showPrintAreaEnabled,this.view],()=>{this.showPrintAreaEnabled?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))}),p(()=>[this.templateOptions.layout,this.templateOptions.layoutItem],()=>{this.loaded&&this._processTemplateOptions()}),p(()=>[this.allowedFormats,this.allowedLayouts],()=>{this.loaded&&this._loadTemplateInfos()}),p(()=>this.exportedLinks,()=>{for(const{name:t,extension:e}of this.exportedLinks)t&&e&&this._updateExportedFileNameMap(`${t}${e}`)},m)])}destroy(){this.removeHandles("overlay-handler"),this.view&&(this._overlayItem&&(this.view.overlay?.removeItem(this._overlayItem),this._overlayItem.destroy(),this._overlayItem=null),this.view=null)}get effectivePrintServiceUrl(){return this.printServiceUrl??null}get effectiveTemplateCustomTextElements(){if(!this._serviceTemplateCustomTextElements)return{};const t=a(this._serviceTemplateCustomTextElements);return this.templateCustomTextElements&&Object.keys(this.templateCustomTextElements).forEach(e=>{const s=t[e];if(s){const t=this.templateCustomTextElements?.[e];s.forEach(e=>{const[s]=Object.entries(e)[0];t?.forEach(t=>{const[i,o]=Object.entries(t)[0];s===i&&(e[s]=o)})})}}),Object.freeze(t)}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}async load(t){return this.addResolvingPromise(this._loadResources(t).catch(t=>this.error=t)),this}async print(t){const{view:e,extraParameters:s,updateDelay:o,outSpatialReference:a}=this;if(!e)throw new i("print:view-required","view is not set");J(t);const r=this._getOverlayItem(),l=t.scalePreserved||!this.showPrintAreaEnabled?void 0:C(new v,e.viewpoint,"map-only"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[r.boxWidth,r.boxHeight]),n=new U({view:e,template:t,extent:l,extraParameters:s,updateDelay:o,outSpatialReference:a});try{const e=!!t.layoutItem?.id&&(this.portalTemplateIds.includes(t.layoutItem.id)||this.browseTemplates.some(e=>e.layoutItem?.id===t.layoutItem?.id));return await E(e&&this._asyncPrintTaskUrl?this._asyncPrintTaskUrl:this.effectivePrintServiceUrl,n,{timeout:this.printTimeout})}catch(p){throw new i("print:export-error","An error occurred while exporting the web map.",{error:p})}}toPrintTemplate({attributionEnabled:t,author:e,copyright:s,customTextElements:o,dpi:a,forceFeatureAttributes:r,format:l,height:n,id:p,includeTables:m,layout:h,layoutItem:d,legendEnabled:u,northArrowEnabled:c,scale:f,scaleBarEnabled:y,scaleEnabled:T,title:v,width:w}){if(!h&&!d)throw new i("print:layout-required","layout is not set");const _=new k({attributionVisible:t,forceFeatureAttributes:r,format:l,includeTables:m,layout:h,layoutItem:d,layoutOptions:{authorText:e||"",copyrightText:s||"",customTextElements:o,titleText:v||""},outScale:f??0,scalePreserved:T});if(w&&(_.exportOptions.width=w),n&&(_.exportOptions.height=n),a&&(_.exportOptions.dpi=a),_.layoutOptions){u||(_.layoutOptions.legendLayers=[]);const t=this.getLayoutTemplateById(p)?.mapSurroundInfoOptions;if(t){const e=t.northArrow;for(const t of e)Q(_,t,c);const s=t.scaleBar;for(const t of s)Q(_,t,y);const i=t.legend;for(const t of i)Q(_,t,u)}}return _}getLayoutTemplateById(t){return t?this._templateIdToCustomTemplate.get(t):null}async addPortalTemplate(t){if(!this.portal||!t?.id)return;try{t.loaded||await t.load()}catch{return void this.applyTemplate(this.defaultTemplate)}const e=new H({type:"browse-template",layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl,label:t.title,layoutItem:t});this._templateIdToCustomTemplate.set(e.id,e),this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem&&this.templateOptions.id===t.layoutItem.id&&(this.defaultTemplate?this.applyTemplate(this.defaultTemplate):this.templateOptions.reset()),this.browseTemplates.remove(t),this._templateIdToCustomTemplate.delete(t.id)}async applyTemplate(t){if(t&&t===this.getLayoutTemplateById(this.templateOptions.id))return;if(this.templateOptions.reset(),!t)return;if("map-only"===t)return void(this.templateOptions.layout="map-only");!t.layout||!this.templatesInfo||this.templatesInfo.layout.choiceList.includes(t.layout)||(this.defaultTemplate?t=this.defaultTemplate:this.templateOptions.reset());const e=t.layout||t.layoutItem?.id,s=e?this.templateCustomTextElements?.[e]:void 0;if(await this.templateOptions.applyTemplate(t,{customTextElements:s,customLayoutOptions:this._customLayoutOptions}),e&&this._serviceTemplateCustomTextElements&&!this._serviceTemplateCustomTextElements[e]&&t.layoutTemplateInfo?.layoutOptions?.customTextElements){const s=a(this._serviceTemplateCustomTextElements);s[e]=t.layoutTemplateInfo.layoutOptions.customTextElements,this._serviceTemplateCustomTextElements=Object.freeze(s)}}createExportedFileLink(t){const e=this.toPrintTemplate(this.templateOptions).format.toLowerCase(),s=e.includes("png")?"png":e,i=t+s;return this._updateExportedFileNameMap(i),new M({name:t,extension:s,count:this._exportedFileNameMap[i]})}export(t){const e=this.createExportedFileLink(t);this.exportedLinks.add(e);const s=this.print(this.toPrintTemplate(this.templateOptions)).then(t=>e.set({url:t?.url,state:"ready"})).catch(t=>e.set({error:t,state:"error"}));return this.emit("submit",{link:e,saveExportEnabled:this.saveExportEnabled}),s.then(t=>this.emit("complete",{link:t,saveExportEnabled:this.saveExportEnabled})),{link:e,promise:s}}async _loadResources(t){this.destroyed||(await this._loadUrls(t),await this._loadTemplateInfos(t),this._updateOverLayItem())}async _loadTemplateInfos(t){const e=[...this.defaultTemplates,...this.printServiceTemplates];for(const{id:o}of e)this._templateIdToCustomTemplate.delete(o);this.defaultTemplates.removeAll(),this.printServiceTemplates.removeAll();const[s,i]=await Promise.all([this._getLayoutToLayoutTemplateInfos(t),this._getPrintServiceTemplatesInfo(t)]);await this._loadAllTemplates(s,i,t),this._processPrintServiceTemplatesInfo(i),await this._processTemplateOptions()}_updateExportedFileNameMap(t){void 0!==this._exportedFileNameMap[t]?this._exportedFileNameMap[t]++:this._exportedFileNameMap[t]=0}async _processTemplateOptions(){const{layout:t,layoutItem:e}=this.templateOptions;if("map-only"!==t)if(this._customLayoutOptions={legend:this.templateOptions.legendEnabled,northArrow:this.templateOptions.northArrowEnabled,scaleBar:this.templateOptions.scaleBarEnabled},e?.id){try{e.loaded||await e.load()}catch{return void this.applyTemplate(this.defaultTemplate)}let t=this._templateIdToCustomTemplate.get(e.id);t||(t=new H({label:e.title,layoutItem:e,layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl}),this._templateIdToCustomTemplate.set(t.id,t)),await this.applyTemplate(t)}else if(t){const t=this.defaultTemplates.find(t=>t.layout===this.templateOptions.layout)??this.printServiceTemplates.find(t=>t.layout===this.templateOptions.layout);await this.applyTemplate(t??this.defaultTemplate)}}async _loadPortal(t){try{await this.portal.load(t)}catch(e){throw new i("print:could-not-load-portal","Cannot load print resource information from portal",{error:e,url:this.effectivePrintServiceUrl})}}async _loadUrls(t){if(this.printServiceUrl)this._set("effectivePrintServiceUrl",this.printServiceUrl),this._layoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(this.effectivePrintServiceUrl,t);else{await this._loadPortal(t);const{printTask:e,asyncPrintTask:s,layoutInfoTask:i}=this.portal?.helperServices??{};this._set("effectivePrintServiceUrl",e?.url),this._asyncPrintTaskUrl=s?.url,this._layoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(this.effectivePrintServiceUrl,t),i?.url&&this.effectivePrintServiceUrl!==i.url?this._portalLayoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(i.url,t):this._portalLayoutInfoTaskUrl=this._layoutInfoTaskUrl}const e=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!e?.includes("gpserver"))throw new i("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl})}async _getLayoutInfoTaskUrl(t,e){if(!t)return null;const s=await P(t,"GetLayoutTemplatesInfo",e);return s?t.replace(B,`$1${encodeURI(s.displayName)}`):null}_getPortalDefaultTemplates(t,e){return this.portal?.helperServices?.printTask?.templates?.filter(t=>"map_only"!==t.layout.toLowerCase()&&(!e||e.includes(S(t.layout))))?.map(e=>{const s=H.fromJSON(e);if(s.type="default-template",s.layoutInfoTaskUrl=this._layoutInfoTaskUrl,s.layout){const e=t.get(s.layout);e&&s.setLayoutTemplateInfo(e)}return s})??[]}async _getPortalCustomTemplates(t){if(this.printServiceUrl||!this.portal)return[];const{layoutGroupQuery:e,user:s}=this.portal,i=b.test(this.portal.url),o=s?.userLicenseTypeId,a=o&&V.has(o);if(!e||i&&!a)return[];const r=new O({query:e,disableExtraQuery:!0}),l=await this.portal.queryGroups(r,t);if(!l.total)return[];const n=l.results[0],p=new O({num:100,query:"type:Layout",sortField:n.sortField,sortOrder:n.sortOrder??void 0}),m=(await n.queryItems(p,t)).results;if(!m.length)return[];return m.map(t=>(this.portalTemplateIds.push(t.id),new H({type:"default-template",label:t.title,layoutItem:t,layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl})))}async _loadAllTemplates(t,e,s){let i=!1;const o=e?.layout?.choiceList;if(this.includeDefaultTemplates&&this.portal&&!this.printServiceUrl){const e=this._getPortalDefaultTemplates(t,o);i=!!e.length,this.defaultTemplates.addMany(e);const a=await this._getPortalCustomTemplates(s);this.defaultTemplates.addMany(a);for(const t of this.defaultTemplates)this._templateIdToCustomTemplate.set(t.id,t)}i||t.forEach((t,e)=>{if(!o||o.includes(e)){const s=new H({type:"print-service-template",layout:e,layoutInfoTaskUrl:this._layoutInfoTaskUrl});s.setLayoutTemplateInfo(t),this.printServiceTemplates.add(s),this._templateIdToCustomTemplate.set(s.id,s)}})}_processPrintServiceTemplatesInfo(t){this._set("templatesInfo",t);const e=t?.layout?.defaultValue;if(e&&"map-only"!==e){const t=this.defaultTemplates.find(t=>t.layout===e)??this.printServiceTemplates.find(t=>t.layout===e)??this.defaultTemplates.at(0)??this.printServiceTemplates.at(0);this._set("defaultTemplate",t)}}async _getLayoutToLayoutTemplateInfos(t){const e=this._layoutInfoTaskUrl,s=e?this._layoutTemplateInfosCache.get(e):void 0,i=s??await A(e,void 0,t);s||this._layoutTemplateInfosCache.set(e,i);const o=new Map,a={};for(const r of i){const t=S(r.layoutTemplate);o.set(t,r),a[t]=r.layoutOptions.customTextElements}return this._serviceTemplateCustomTextElements=Object.freeze(a),o}async _getPrintServiceTemplatesInfo(t){const e=this.effectivePrintServiceUrl?this._tasksInfoCache.get(this.effectivePrintServiceUrl):void 0,s=e??await P(this.effectivePrintServiceUrl,"ExportWebMap",t);if(!s)throw new i("print:unavailable-service-info","Can't fetch templates info from service");e||this._tasksInfoCache.set(this.effectivePrintServiceUrl,s);const{parameters:o}=s,a=o.find(({name:t})=>"Format"===t),r=o.find(({name:t})=>"Layout_Template"===t);return{format:this._getFormat(a),layout:this._getLayout(r)}}_getFormat(t){const s="all"===this.allowedFormats?t.choiceList:t.choiceList.filter(t=>"string"!=typeof this.allowedFormats&&this.allowedFormats.some(e=>new RegExp(`\\b${e}\\b`,"i").test(t))),i=(s.length?s:t.choiceList).map(t=>L.fromJSON(t)).filter(e),o=L.fromJSON(t.defaultValue),a=i.some(t=>new RegExp(`\\b${o}\\b`,"i").test(t))?o:i[0];return{choiceList:i,defaultValue:a}}_getLayout(t){const s=t.choiceList.filter(t=>"map_only"!==t.toLowerCase()),i="all"===this.allowedLayouts?s:s.filter(t=>this.allowedLayouts.includes(S(t))),o=(i.length?i:s).map(S).filter(e),a=S(t.defaultValue),r=o.includes(a)?a:o.find(t=>/(?=.*letter)(?=.*landscape)/i.test(t))??o.find(t=>/(?=.*a4)(?=.*landscape)/i.test(t))??o[0];return{choiceList:o,defaultValue:r}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new F({strokeDash:[5],strokeWidth:2,strokeColor:[30,144,255,255]})),this._overlayItem}_enablePrintPreview(){if(!this.view?.overlay)return;const t=this.templateOptions,e=this._getOverlayItem();this.addHandles([p(()=>[t.width,t.height,t.scaleEnabled,t.scale,t.layout,t.layoutItem,t.id,t.state,t.dpi,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding,this.loaded],()=>this._updateOverLayItem(),m),this.view?.on("drag",["Shift"],t=>this._handleDrag(t),j.WIDGET),this.view?.on("key-down",["Escape"],()=>this._resetDrag(),j.WIDGET)],"overlay-handler"),this.view.overlay.addItem(e)}_updateOverLayItem(){if(!this.view)return;const t=this.templateOptions,e=this._getOverlayItem(),s=t.layoutItem?.id??t.layout,i=this.view,o=i.spatialReference,[a,r]=i.state.paddedViewState.size,l=i.state.padding;let n=0,p=0;if("map-only"===s)null!=t.width&&null!=t.height&&(n=t.width,p=t.height);else if(s){const e=t.id?this._templateIdToCustomTemplate.get(t.id):null,{webMapFrameSize:s,pageUnits:i}=e?.layoutTemplateInfo??{};let l=!1;if(s&&i)if(this._isFreeHand){const t=s[0]/s[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=W.fromJSON(i.toLowerCase()),e=o.unit;d(t)===d(e)?(n=u(s[0],t,e),p=u(s[1],t,e)):(l=!0,n=s[0],p=s[1])}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const e=l?Math.min(a/n,r/p):c(o)*f*t.dpi;n*=e,p*=e}else if(0===n||0===p)n=a,p=r;else{const t=(a-.1*a)/n,e=(r-.1*r)/p,s=Math.min(t,e);n*=s,p*=s}}const{scaleEnabled:m,scale:h}=t,y=m&&h?h/this.view.scale:1,T=m&&h?G/t.dpi:1;if(e.boxWidth=n*y*T||a,e.boxHeight=p*y*T||r,l&&(e.padding=l),e.backgroundWidth=a??0,e.backgroundHeight=r??0,"loading"===this.loadStatus)e.strokeColor=N;else if("loaded"===this.loadStatus)switch(this.templateOptions.state){case"pending":e.strokeColor=N;break;case"ready":e.strokeColor=R;break;case"error":e.strokeColor=z}}_resetDrag(){this._isFreeHand=!1,this._updateOverLayItem()}_handleDrag(t){switch(t.action){case"start":this._start();break;case"update":this._update(t);break;case"end":this._end()}t.stopPropagation()}_start(){this._isFreeHand=!0}_update(t){const e=this._getOverlayItem(),{x:s,y:i}=t,{x:o,y:a}=t.origin;s>o?(e.x=o,e.boxWidth=s-o):(e.x=s,e.boxWidth=o-s),i>a?(e.y=a,e.boxHeight=i-a):(e.y=i,e.boxHeight=a-i)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,s=e.toMap(h(t.x+.5*t.boxWidth,t.y+.5*t.boxHeight));t.x=null,t.y=null,e.goTo({center:s}),this._freeHandWidth=t.boxWidth,this._freehandHeight=t.boxHeight,"map-only"===this.templateOptions.layout&&(this.templateOptions.width=this._freeHandWidth,this.templateOptions.height=this._freehandHeight),this.templateOptions.scale=this.view.scale,this._updateOverLayItem()}};t([y()],K.prototype,"_serviceTemplateCustomTextElements",void 0),t([y()],K.prototype,"_templateIdToCustomTemplate",void 0),t([y()],K.prototype,"allowedFormats",void 0),t([y()],K.prototype,"allowedLayouts",void 0),t([y({type:q})],K.prototype,"browseTemplates",void 0),t([y({type:q})],K.prototype,"defaultTemplates",void 0),t([y()],K.prototype,"error",void 0),t([y({type:$})],K.prototype,"exportedLinks",void 0),t([y()],K.prototype,"extraParameters",void 0),t([y()],K.prototype,"includeDefaultTemplates",void 0),t([y({readOnly:!0})],K.prototype,"effectivePrintServiceUrl",null),t([y()],K.prototype,"effectiveTemplateCustomTextElements",null),t([y({type:w})],K.prototype,"outSpatialReference",void 0),t([y({type:x})],K.prototype,"portal",void 0),t([y()],K.prototype,"portalTemplateIds",void 0),t([y({type:q})],K.prototype,"printServiceTemplates",void 0),t([y({readOnly:!0})],K.prototype,"defaultTemplate",void 0),t([y()],K.prototype,"showPrintAreaEnabled",void 0),t([y()],K.prototype,"printServiceUrl",void 0),t([y()],K.prototype,"printTimeout",void 0),t([y()],K.prototype,"saveExportEnabled",void 0),t([y({readOnly:!0})],K.prototype,"state",null),t([y({readOnly:!0})],K.prototype,"templatesInfo",void 0),t([y()],K.prototype,"updateDelay",void 0),t([y()],K.prototype,"view",void 0),t([y()],K.prototype,"templateCustomTextElements",void 0),t([y({type:D})],K.prototype,"templateOptions",void 0),K=t([T("esri.widgets.Print.PrintViewModel")],K);const X=K;export{X as default};
5
+ import{__decorate as t}from"tslib";import{isSome as e}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import i from"../../core/Error.js";import{EventedAccessor as o}from"../../core/Evented.js";import{clone as a}from"../../core/lang.js";import{LoadableMixin as r}from"../../core/Loadable.js";import{EsriPromiseMixin as l}from"../../core/Promise.js";import n from"../../core/ReactiveMap.js";import{watch as p,initial as m}from"../../core/reactiveUtils.js";import{createScreenPoint as h}from"../../core/screenUtils.js";import{unitType as d,convertUnit as u,getMetersPerUnitForSR as c,inchesPerMeter as f}from"../../core/unitUtils.js";import{property as y}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as T}from"../../core/accessorSupport/decorators/subclass.js";import v from"../../geometry/Extent.js";import w from"../../geometry/SpatialReference.js";import{formatDate as _,convertDateFormatToIntlOptions as I}from"../../intl/date.js";import{getLocaleLanguage as g}from"../../intl/locale.js";import x from"../../portal/Portal.js";import O from"../../portal/PortalQueryParams.js";import{reArcGISOnlineDomain as b}from"../../portal/support/urlUtils.js";import{execute as E,getTaskInfo as P}from"../../rest/print.js";import{formatJsonMap as L}from"../../rest/support/fileFormat.js";import{fromJSON as S}from"../../rest/support/layoutTemplate.js";import U from"../../rest/support/PrintParameters.js";import k from"../../rest/support/PrintTemplate.js";import{getExtent as C}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as j}from"../../views/input/InputManager.js";import F from"../../views/overlay/BoxOverlayItem.js";import H from"./CustomTemplate.js";import M from"./FileLink.js";import D from"./TemplateOptions.js";import{fetchLayoutTemplateInfos as A,valueUnitKebabDict as W}from"./utils.js";const R=[30,144,255,255],N=[237,211,23,255],z=[216,48,32,255],V=new Set(["GISProfessionalStdUT","GISProfessionalAdvUT"]),B=/(\/GPServer\/).+/i,G=96,q=s.ofType(H),$=s.ofType(M);function J(t){t.layoutOptions??={},t.layoutOptions.customTextElements??=[];const e="date";if(!t.layoutOptions.customTextElements.find(t=>e in t)){const{customTextElements:e}=t.layoutOptions;let s=_(Date.now(),I("short-date"));"ar"===g()&&(s="‏"+s),e.push({date:s})}}function Q(t,e,s){if(!e)return;!(e.visible===s)&&t.layoutOptions&&(t.layoutOptions.elementOverrides?t.layoutOptions.elementOverrides[e.name]={visible:s}:t.layoutOptions.elementOverrides={[e.name]:{visible:s}})}let K=class extends(r(l(o))){constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._templateIdToCustomTemplate=new n,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this._asyncPrintTaskUrl=null,this._layoutInfoTaskUrl=null,this._portalLayoutInfoTaskUrl=null,this._customLayoutOptions=null,this._exportedFileNameMap={},this._layoutTemplateInfosCache=new Map,this._tasksInfoCache=new Map,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new q,this.defaultTemplates=new q,this.error=null,this.exportedLinks=new $,this.extraParameters=null,this.includeDefaultTemplates=!0,this.outSpatialReference=null,this.portal=x.getDefault(),this.portalTemplateIds=[],this.printServiceTemplates=new q,this.defaultTemplate=null,this.showPrintAreaEnabled=!1,this.printServiceUrl=null,this.printTimeout=12e4,this.saveExportEnabled=!1,this.templatesInfo=null,this.updateDelay=1e3,this.view=null,this.templateCustomTextElements=null,this.templateOptions=new D}initialize(){this.addHandles([p(()=>[this.showPrintAreaEnabled,this.view],()=>{this.showPrintAreaEnabled?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))}),p(()=>[this.templateOptions.layout,this.templateOptions.layoutItem],()=>{this.loaded&&this._processTemplateOptions()}),p(()=>[this.allowedFormats,this.allowedLayouts],()=>{this.loaded&&this._loadTemplateInfos()}),p(()=>this.exportedLinks,()=>{for(const{name:t,extension:e}of this.exportedLinks)t&&e&&this._updateExportedFileNameMap(`${t}${e}`)},m)])}destroy(){this.removeHandles("overlay-handler"),this.view&&(this._overlayItem&&(this.view.overlay?.removeItem(this._overlayItem),this._overlayItem.destroy(),this._overlayItem=null),this.view=null)}get effectivePrintServiceUrl(){return this.printServiceUrl??null}get effectiveTemplateCustomTextElements(){if(!this._serviceTemplateCustomTextElements)return{};const t=a(this._serviceTemplateCustomTextElements);return this.templateCustomTextElements&&Object.keys(this.templateCustomTextElements).forEach(e=>{const s=t[e];if(s){const t=this.templateCustomTextElements?.[e];s.forEach(e=>{const[s]=Object.entries(e)[0];t?.forEach(t=>{const[i,o]=Object.entries(t)[0];s===i&&(e[s]=o)})})}}),Object.freeze(t)}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}async print(t){const{view:e,extraParameters:s,updateDelay:o,outSpatialReference:a}=this;if(!e)throw new i("print:view-required","view is not set");J(t);const r=this._getOverlayItem(),l=t.scalePreserved||!this.showPrintAreaEnabled?void 0:C(new v,e.viewpoint,"map-only"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[r.boxWidth,r.boxHeight]),n=new U({view:e,template:t,extent:l,extraParameters:s,updateDelay:o,outSpatialReference:a});try{const e=!!t.layoutItem?.id&&(this.portalTemplateIds.includes(t.layoutItem.id)||this.browseTemplates.some(e=>e.layoutItem?.id===t.layoutItem?.id));return await E(e&&this._asyncPrintTaskUrl?this._asyncPrintTaskUrl:this.effectivePrintServiceUrl,n,{timeout:this.printTimeout})}catch(p){throw new i("print:export-error","An error occurred while exporting the web map.",{error:p})}}async load(t){return this.addResolvingPromise(this._loadResources(t).catch(t=>this.error=t)),this}toPrintTemplate({attributionEnabled:t,author:e,copyright:s,customTextElements:o,dpi:a,forceFeatureAttributes:r,format:l,height:n,id:p,includeTables:m,layout:h,layoutItem:d,legendEnabled:u,northArrowEnabled:c,scale:f,scaleBarEnabled:y,scaleEnabled:T,title:v,width:w}){if(!h&&!d)throw new i("print:layout-required","layout is not set");const _=new k({attributionVisible:t,forceFeatureAttributes:r,format:l,includeTables:m,layout:h,layoutItem:d,layoutOptions:{authorText:e||"",copyrightText:s||"",customTextElements:o,titleText:v||""},outScale:f??0,scalePreserved:T});if(w&&(_.exportOptions.width=w),n&&(_.exportOptions.height=n),a&&(_.exportOptions.dpi=a),_.layoutOptions){u||(_.layoutOptions.legendLayers=[]);const t=this.getLayoutTemplateById(p)?.mapSurroundInfoOptions;if(t){const e=t.northArrow;for(const t of e)Q(_,t,c);const s=t.scaleBar;for(const t of s)Q(_,t,y);const i=t.legend;for(const t of i)Q(_,t,u)}}return _}getLayoutTemplateById(t){return t?this._templateIdToCustomTemplate.get(t):null}async addPortalTemplate(t){if(!this.portal||!t?.id)return;try{t.loaded||await t.load()}catch{return void this.applyTemplate(this.defaultTemplate)}const e=new H({type:"browse-template",layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl,label:t.title,layoutItem:t});this._templateIdToCustomTemplate.set(e.id,e),this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem&&this.templateOptions.id===t.layoutItem.id&&(this.defaultTemplate?this.applyTemplate(this.defaultTemplate):this.templateOptions.reset()),this.browseTemplates.remove(t),this._templateIdToCustomTemplate.delete(t.id)}async applyTemplate(t){if(t&&t===this.getLayoutTemplateById(this.templateOptions.id))return;if(this.templateOptions.reset(),!t)return;if("map-only"===t)return void(this.templateOptions.layout="map-only");!t.layout||!this.templatesInfo||this.templatesInfo.layout.choiceList.includes(t.layout)||(this.defaultTemplate?t=this.defaultTemplate:this.templateOptions.reset());const e=t.layout||t.layoutItem?.id,s=e?this.templateCustomTextElements?.[e]:void 0;if(await this.templateOptions.applyTemplate(t,{customTextElements:s,customLayoutOptions:this._customLayoutOptions}),e&&this._serviceTemplateCustomTextElements&&!this._serviceTemplateCustomTextElements[e]&&t.layoutTemplateInfo?.layoutOptions?.customTextElements){const s=a(this._serviceTemplateCustomTextElements);s[e]=t.layoutTemplateInfo.layoutOptions.customTextElements,this._serviceTemplateCustomTextElements=Object.freeze(s)}}createExportedFileLink(t){const e=this.toPrintTemplate(this.templateOptions).format.toLowerCase(),s=e.includes("png")?"png":e,i=t+s;return this._updateExportedFileNameMap(i),new M({name:t,extension:s,count:this._exportedFileNameMap[i]})}export(t){const e=this.createExportedFileLink(t);this.exportedLinks.add(e);const s=this.print(this.toPrintTemplate(this.templateOptions)).then(t=>e.set({url:t?.url,state:"ready"})).catch(t=>e.set({error:t,state:"error"}));return this.emit("submit",{link:e,saveExportEnabled:this.saveExportEnabled}),s.then(t=>this.emit("complete",{link:t,saveExportEnabled:this.saveExportEnabled})),{link:e,promise:s}}async _loadResources(t){this.destroyed||(await this._loadUrls(t),await this._loadTemplateInfos(t),this._updateOverLayItem())}async _loadTemplateInfos(t){const e=[...this.defaultTemplates,...this.printServiceTemplates];for(const{id:o}of e)this._templateIdToCustomTemplate.delete(o);this.defaultTemplates.removeAll(),this.printServiceTemplates.removeAll();const[s,i]=await Promise.all([this._getLayoutToLayoutTemplateInfos(t),this._getPrintServiceTemplatesInfo(t)]);await this._loadAllTemplates(s,i,t),this._processPrintServiceTemplatesInfo(i),await this._processTemplateOptions()}_updateExportedFileNameMap(t){void 0!==this._exportedFileNameMap[t]?this._exportedFileNameMap[t]++:this._exportedFileNameMap[t]=0}async _processTemplateOptions(){const{layout:t,layoutItem:e}=this.templateOptions;if("map-only"!==t)if(this._customLayoutOptions={legend:this.templateOptions.legendEnabled,northArrow:this.templateOptions.northArrowEnabled,scaleBar:this.templateOptions.scaleBarEnabled},e?.id){try{e.loaded||await e.load()}catch{return void this.applyTemplate(this.defaultTemplate)}let t=this._templateIdToCustomTemplate.get(e.id);t||(t=new H({label:e.title,layoutItem:e,layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl}),this._templateIdToCustomTemplate.set(t.id,t)),await this.applyTemplate(t)}else if(t){const t=this.defaultTemplates.find(t=>t.layout===this.templateOptions.layout)??this.printServiceTemplates.find(t=>t.layout===this.templateOptions.layout);await this.applyTemplate(t??this.defaultTemplate)}}async _loadPortal(t){try{await this.portal.load(t)}catch(e){throw new i("print:could-not-load-portal","Cannot load print resource information from portal",{error:e,url:this.effectivePrintServiceUrl})}}async _loadUrls(t){if(this.printServiceUrl)this._set("effectivePrintServiceUrl",this.printServiceUrl),this._layoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(this.effectivePrintServiceUrl,t);else{await this._loadPortal(t);const{printTask:e,asyncPrintTask:s,layoutInfoTask:i}=this.portal?.helperServices??{};this._set("effectivePrintServiceUrl",e?.url),this._asyncPrintTaskUrl=s?.url,this._layoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(this.effectivePrintServiceUrl,t),i?.url&&this.effectivePrintServiceUrl!==i.url?this._portalLayoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(i.url,t):this._portalLayoutInfoTaskUrl=this._layoutInfoTaskUrl}const e=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!e?.includes("gpserver"))throw new i("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl})}async _getLayoutInfoTaskUrl(t,e){if(!t)return null;const s=await P(t,"GetLayoutTemplatesInfo",e);return s?t.replace(B,`$1${encodeURI(s.displayName)}`):null}_getPortalDefaultTemplates(t,e){return this.portal?.helperServices?.printTask?.templates?.filter(t=>"map_only"!==t.layout.toLowerCase()&&(!e||e.includes(S(t.layout))))?.map(e=>{const s=H.fromJSON(e);if(s.type="default-template",s.layoutInfoTaskUrl=this._layoutInfoTaskUrl,s.layout){const e=t.get(s.layout);e&&s.setLayoutTemplateInfo(e)}return s})??[]}async _getPortalCustomTemplates(t){if(this.printServiceUrl||!this.portal)return[];const{layoutGroupQuery:e,user:s}=this.portal,i=b.test(this.portal.url),o=s?.userLicenseTypeId,a=o&&V.has(o);if(!e||i&&!a)return[];const r=new O({query:e,disableExtraQuery:!0}),l=await this.portal.queryGroups(r,t);if(!l.total)return[];const n=l.results[0],p=new O({num:100,query:"type:Layout",sortField:n.sortField,sortOrder:n.sortOrder??void 0}),m=(await n.queryItems(p,t)).results;if(!m.length)return[];return m.map(t=>(this.portalTemplateIds.push(t.id),new H({type:"default-template",label:t.title,layoutItem:t,layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl})))}async _loadAllTemplates(t,e,s){let i=!1;const o=e?.layout?.choiceList;if(this.includeDefaultTemplates&&this.portal&&!this.printServiceUrl){const e=this._getPortalDefaultTemplates(t,o);i=!!e.length,this.defaultTemplates.addMany(e);const a=await this._getPortalCustomTemplates(s);this.defaultTemplates.addMany(a);for(const t of this.defaultTemplates)this._templateIdToCustomTemplate.set(t.id,t)}i||t.forEach((t,e)=>{if(!o||o.includes(e)){const s=new H({type:"print-service-template",layout:e,layoutInfoTaskUrl:this._layoutInfoTaskUrl});s.setLayoutTemplateInfo(t),this.printServiceTemplates.add(s),this._templateIdToCustomTemplate.set(s.id,s)}})}_processPrintServiceTemplatesInfo(t){this._set("templatesInfo",t);const e=t?.layout?.defaultValue;if(e&&"map-only"!==e){const t=this.defaultTemplates.find(t=>t.layout===e)??this.printServiceTemplates.find(t=>t.layout===e)??this.defaultTemplates.at(0)??this.printServiceTemplates.at(0);this._set("defaultTemplate",t)}}async _getLayoutToLayoutTemplateInfos(t){const e=this._layoutInfoTaskUrl,s=e?this._layoutTemplateInfosCache.get(e):void 0,i=s??await A(e,void 0,t);s||this._layoutTemplateInfosCache.set(e,i);const o=new Map,a={};for(const r of i){const t=S(r.layoutTemplate);o.set(t,r),a[t]=r.layoutOptions.customTextElements}return this._serviceTemplateCustomTextElements=Object.freeze(a),o}async _getPrintServiceTemplatesInfo(t){const e=this.effectivePrintServiceUrl?this._tasksInfoCache.get(this.effectivePrintServiceUrl):void 0,s=e??await P(this.effectivePrintServiceUrl,"ExportWebMap",t);if(!s)throw new i("print:unavailable-service-info","Can't fetch templates info from service");e||this._tasksInfoCache.set(this.effectivePrintServiceUrl,s);const{parameters:o}=s,a=o.find(({name:t})=>"Format"===t),r=o.find(({name:t})=>"Layout_Template"===t);return{format:this._getFormat(a),layout:this._getLayout(r)}}_getFormat(t){const s="all"===this.allowedFormats?t.choiceList:t.choiceList.filter(t=>"string"!=typeof this.allowedFormats&&this.allowedFormats.some(e=>new RegExp(`\\b${e}\\b`,"i").test(t))),i=(s.length?s:t.choiceList).map(t=>L.fromJSON(t)).filter(e),o=L.fromJSON(t.defaultValue),a=i.some(t=>new RegExp(`\\b${o}\\b`,"i").test(t))?o:i[0];return{choiceList:i,defaultValue:a}}_getLayout(t){const s=t.choiceList.filter(t=>"map_only"!==t.toLowerCase()),i="all"===this.allowedLayouts?s:s.filter(t=>this.allowedLayouts.includes(S(t))),o=(i.length?i:s).map(S).filter(e),a=S(t.defaultValue),r=o.includes(a)?a:o.find(t=>/(?=.*letter)(?=.*landscape)/i.test(t))??o.find(t=>/(?=.*a4)(?=.*landscape)/i.test(t))??o[0];return{choiceList:o,defaultValue:r}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new F({strokeDash:[5],strokeWidth:2,strokeColor:[30,144,255,255]})),this._overlayItem}_enablePrintPreview(){if(!this.view?.overlay)return;const t=this.templateOptions,e=this._getOverlayItem();this.addHandles([p(()=>[t.width,t.height,t.scaleEnabled,t.scale,t.layout,t.layoutItem,t.id,t.state,t.dpi,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding,this.loaded],()=>this._updateOverLayItem(),m),this.view?.on("drag",["Shift"],t=>this._handleDrag(t),j.WIDGET),this.view?.on("key-down",["Escape"],()=>this._resetDrag(),j.WIDGET)],"overlay-handler"),this.view.overlay.addItem(e)}_updateOverLayItem(){if(!this.view)return;const t=this.templateOptions,e=this._getOverlayItem(),s=t.layoutItem?.id??t.layout,i=this.view,o=i.spatialReference,[a,r]=i.state.paddedViewState.size,l=i.state.padding;let n=0,p=0;if("map-only"===s)null!=t.width&&null!=t.height&&(n=t.width,p=t.height);else if(s){const e=t.id?this._templateIdToCustomTemplate.get(t.id):null,{webMapFrameSize:s,pageUnits:i}=e?.layoutTemplateInfo??{};let l=!1;if(s&&i)if(this._isFreeHand){const t=s[0]/s[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=W.fromJSON(i.toLowerCase()),e=o.unit;d(t)===d(e)?(n=u(s[0],t,e),p=u(s[1],t,e)):(l=!0,n=s[0],p=s[1])}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const e=l?Math.min(a/n,r/p):c(o)*f*t.dpi;n*=e,p*=e}else if(0===n||0===p)n=a,p=r;else{const t=(a-.1*a)/n,e=(r-.1*r)/p,s=Math.min(t,e);n*=s,p*=s}}const{scaleEnabled:m,scale:h}=t,y=m&&h?h/this.view.scale:1,T=m&&h?G/t.dpi:1;if(e.boxWidth=n*y*T||a,e.boxHeight=p*y*T||r,l&&(e.padding=l),e.backgroundWidth=a??0,e.backgroundHeight=r??0,"loading"===this.loadStatus)e.strokeColor=N;else if("loaded"===this.loadStatus)switch(this.templateOptions.state){case"pending":e.strokeColor=N;break;case"ready":e.strokeColor=R;break;case"error":e.strokeColor=z}}_resetDrag(){this._isFreeHand=!1,this._updateOverLayItem()}_handleDrag(t){switch(t.action){case"start":this._start();break;case"update":this._update(t);break;case"end":this._end()}t.stopPropagation()}_start(){this._isFreeHand=!0}_update(t){const e=this._getOverlayItem(),{x:s,y:i}=t,{x:o,y:a}=t.origin;s>o?(e.x=o,e.boxWidth=s-o):(e.x=s,e.boxWidth=o-s),i>a?(e.y=a,e.boxHeight=i-a):(e.y=i,e.boxHeight=a-i)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,s=e.toMap(h(t.x+.5*t.boxWidth,t.y+.5*t.boxHeight));t.x=null,t.y=null,e.goTo({center:s}),this._freeHandWidth=t.boxWidth,this._freehandHeight=t.boxHeight,"map-only"===this.templateOptions.layout&&(this.templateOptions.width=this._freeHandWidth,this.templateOptions.height=this._freehandHeight),this.templateOptions.scale=this.view.scale,this._updateOverLayItem()}};t([y()],K.prototype,"_serviceTemplateCustomTextElements",void 0),t([y()],K.prototype,"_templateIdToCustomTemplate",void 0),t([y()],K.prototype,"allowedFormats",void 0),t([y()],K.prototype,"allowedLayouts",void 0),t([y({type:q})],K.prototype,"browseTemplates",void 0),t([y({type:q})],K.prototype,"defaultTemplates",void 0),t([y()],K.prototype,"error",void 0),t([y({type:$})],K.prototype,"exportedLinks",void 0),t([y()],K.prototype,"extraParameters",void 0),t([y()],K.prototype,"includeDefaultTemplates",void 0),t([y({readOnly:!0})],K.prototype,"effectivePrintServiceUrl",null),t([y()],K.prototype,"effectiveTemplateCustomTextElements",null),t([y({type:w})],K.prototype,"outSpatialReference",void 0),t([y({type:x})],K.prototype,"portal",void 0),t([y()],K.prototype,"portalTemplateIds",void 0),t([y({type:q})],K.prototype,"printServiceTemplates",void 0),t([y({readOnly:!0})],K.prototype,"defaultTemplate",void 0),t([y()],K.prototype,"showPrintAreaEnabled",void 0),t([y()],K.prototype,"printServiceUrl",void 0),t([y()],K.prototype,"printTimeout",void 0),t([y()],K.prototype,"saveExportEnabled",void 0),t([y({readOnly:!0})],K.prototype,"state",null),t([y({readOnly:!0})],K.prototype,"templatesInfo",void 0),t([y()],K.prototype,"updateDelay",void 0),t([y()],K.prototype,"view",void 0),t([y()],K.prototype,"templateCustomTextElements",void 0),t([y({type:D})],K.prototype,"templateOptions",void 0),K=t([T("esri.widgets.Print.PrintViewModel")],K);const X=K;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.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{getAssetUrl as t}from"../../assets.js";import r from"../../Graphic.js";import s from"../../PopupTemplate.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import l from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import n from"../../core/Logger.js";import{mappedFind as u}from"../../core/maybe.js";import{eachAlways as c,after as h}from"../../core/promiseUtils.js";import{watch as p,initial as g,whenOnce as d}from"../../core/reactiveUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import f from"../../geometry/Point.js";import S from"../../geometry/SpatialReference.js";import{getPointFromGeometry as _,getPointWithElevation as v}from"../../geometry/support/geometryUtils.js";import{onLocaleChange as w}from"../../intl/locale.js";import{fetchMessageBundle as b}from"../../intl/messages.js";import x from"../../portal/Portal.js";import{isApiKeyApplicable as L}from"../../support/apiKeyUtils.js";import I from"../../symbols/PictureMarkerSymbol.js";import T from"../../symbols/SimpleFillSymbol.js";import R from"../../symbols/SimpleLineSymbol.js";import E from"../../symbols/TextSymbol.js";import{highlightsSupported as F}from"../../views/support/layerViewUtils.js";import P from"./LayerSearchSource.js";import j from"./LocatorSearchSource.js";import C from"./SearchSource.js";import{isArcGISWorldGeocoder as G,meteredArcGISLocatorUrl as O,isProxiedArcGISWorldGeocoder as A,isMeteredArcGISWorldGeocoder as N}from"./support/locatorUtils.js";import{supported as D,getCurrentPosition as M,positionToPoint as V}from"../support/geolocationUtils.js";import{GoTo as J}from"../support/GoTo.js";function U(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const k=()=>b("esri/widgets/Search/t9n/Search"),H="highlight",B=i.ofType({key:e=>e.layer?"layer":"locator",base:C,typeMap:{layer:P,locator:j}}),Q=S.WGS84,Z="esri/images/search/search-symbol-32.png",q=/<[\s\S]*?>/g,z=-1;let K=class extends(J(a)){constructor(e){super(e),this._gotoController=null,this._searching=null,this._updatingPromise=null,this._createdFeatureLayers=[],this.autoNavigate=!0,this.autoSelect=!0,this.defaultPopupTemplate=null,this.defaultSources=new B,this.defaultSymbols={point:new I({url:t(Z),size:24,width:24,height:24}),polyline:new R({color:[130,130,130,1],width:2}),polygon:new T({color:[235,235,235,.4],outline:{color:[130,130,130,1],width:2}})},this.includeDefaultSources=!0,this.maxInputLength=128,this.maxResults=6,this.maxSuggestions=6,this.messages=null,this.minSuggestCharacters=3,this.popupEnabled=!0,this.popupTemplate=null,this.portal=x.getDefault(),this.resultCount=null,this.resultGraphicEnabled=!0,this.resultGraphic=null,this.results=null,this.selectedSuggestion=null,this.searchAllEnabled=!0,this.selectedResult=null,this.sources=new B,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){const e=async()=>{const e=await k();this.messages=e,this.defaultPopupTemplate=new s({title:e.searchResult,content:"{Match_addr}"})};e(),this.addHandles([p(()=>[this.includeDefaultSources,this.view,this.portal],()=>this._update(),g),w(e)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics()}static{this.ALL_INDEX=z}get activeSource(){return this.allSources.at(this.activeSourceIndex)??null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:z}set activeSourceIndex(e){this._overrideIfSome("activeSourceIndex",e)}get allPlaceholder(){return this.messages?.allPlaceholder}set allPlaceholder(e){this._overrideIfSome("allPlaceholder",e)}get allSources(){const{sources:e,defaultSources:t,includeDefaultSources:r}=this,s="function"==typeof r?r.call(null,{sources:e,defaultSources:t}):r?t.concat(e):e,o=this._get("allSources")||new B;return o.removeAll(),o.addMany(s.filter(Boolean)),o}get locationEnabled(){return this._get("locationEnabled")||D()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=D();if(e&&!t){const e=new l("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});n.getLogger(this).error(e)}this._override("locationEnabled",!!e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:r}=this;if(t===z)return r??"";const s=e.at(t);return s?.placeholder??""}set searchTerm(e){this._set("searchTerm",e||""),this.clearGraphics(),this.selectedSuggestion&&this.selectedSuggestion.text!==e&&this._set("selectedSuggestion",null),""===e&&this._clear()}get searchTerm(){return this._get("searchTerm")||""}get state(){return this._searching?"searching":this.updating?"loading":0===this.allSources.length?"disabled":"ready"}get updating(){return null!=this._updatingPromise}clear(){this.searchTerm=""}clearGraphics(){this._removeHighlight(),this._closePopup();const{view:e,resultGraphic:t}=this;e&&t&&e.graphics.remove(t),this._set("resultGraphic",null)}search(e,t){this.emit("search-start"),this.clearGraphics();const r=this._createSuggestionForSearch(e),s=(async()=>{try{await this.when();const e=await this._getResultsFromSources(r,t);if(t?.signal?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:r.text??"",numResults:0,numErrors:0,errors:[],results:[]};this._formatResponse(s,e,r);const o=this._getFirstResult(s.results),i=r.location&&o?o.name:r.text,l=i?.replace(q,"");return this._set("searchTerm",l),(r.key&&"number"==typeof r.sourceIndex||r.location)&&this._set("selectedSuggestion",r),this._set("results",s.results),this._set("resultCount",s.results.reduce((e,t)=>e+(t.results?.length??0),0)),this.emit("search-complete",s),await this._selectFirstResult(o),s}finally{this._clearSearching()}})();return this._searching=s,s}async searchNearby(e){if(!this.locationEnabled){const e=new l("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});throw n.getLogger(this).error(e),e}const t=(async()=>{try{const t=await M(),r=await V({position:t,view:this.view},e);return await this.search(r,e)}finally{this._clearSearching()}})();return this._searching=t,t}async select(e){if(this.clearGraphics(),!e){const t=new l("select:missing-parameter","Cannot select without a searchResult.",{searchResult:e});throw n.getLogger(this).error(t),t}const{view:t}=this,s=U(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=null!=s?this.allSources.at(s):null;if(!o){const e=new l("select:missing-source","Cannot select without a source.",{source:o});throw n.getLogger(this).error(e),e}const i=o instanceof P?this._getLayerSourcePopupTemplate(o):o.popupTemplate,a=o.resultSymbol||this._getDefaultSymbol(e),u=U(o,"resultGraphicEnabled")?o.resultGraphicEnabled:this.resultGraphicEnabled,h=U(o,"autoNavigate")?o.autoNavigate:this.autoNavigate,p=U(o,"popupEnabled")?o.popupEnabled:this.popupEnabled,g=p?i||this.popupTemplate||this.defaultPopupTemplate:null,{feature:d}=e;if(!d){const e=new l("select:missing-feature","Cannot select without a feature.",{feature:d});throw n.getLogger(this).error(e),e}const{attributes:m,geometry:y,layer:f,sourceLayer:S}=d,w=y?_(y):null,b={layerViewQuery:this._getLayerView(d),elevationQuery:t&&null!=w?v(w,t):Promise.resolve(w)},x=await c(b),L=x.layerViewQuery.value,I=x.elevationQuery.value;a instanceof E&&(a.text=e.name);const T=t&&h?e.target||e.extent:null,R=null!=T?this._goToSearchResult(T):Promise.resolve();await R;const j=L?d:new r({geometry:y,symbol:a,attributes:m,layer:f,sourceLayer:S,popupTemplate:g}),C=t?.popup,G=C&&p&&j.getEffectivePopupTemplate(C.defaultPopupTemplateEnabled);return G&&await t.openPopup({features:[j],location:I}),L&&F(L)&&!G&&this._highlightFeature({graphic:j,layerView:L}),!L&&u&&t&&t.graphics.push(j),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",j),this.emit("select-result",{result:e,source:o,sourceIndex:s}),e}async suggest(e,t,r){const s=e||this.searchTerm;this.emit("suggest-start",{searchTerm:s}),await this._suggestTimer(t,r);const o=await this._suggestImmediate(s,r);return this._set("suggestions",o?.results),this._set("suggestionCount",o?.results.reduce((e,t)=>e+(t.results?.length??0),0)??null),this.emit("suggest-complete",o),o}async when(){await d(()=>!this.updating)}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const r=this._updatingPromise=c([e?.load(),t?.when()]);if(this.destroyed)return;if(await r,r!==this._updatingPromise)return}await d(()=>this.messages),this.destroyed||this._updateDefaultSources(),this._updatingPromise=null}_clearSearching(){this._searching=null}_convertHelperServices(){const e=this.portal?.helperServices?.geocode;if(!e)return[];return e.map(e=>{if(!1===e.placefinding)return;const t=G(e.url)&&L(e.url)?{url:O}:null,r=j.fromJSON({...e,...t}),s=r.url;if(G(s)||A(s)||N(s)){const e=r.outFields??["Addr_type","Match_addr","StAddr","City"],t=(r.placeholder||this.messages?.placeholder)??"",s="number"==typeof r.defaultZoomScale?r.defaultZoomScale:2500;r.singleLineFieldName="SingleLine",r.outFields=e,r.placeholder=t,r.defaultZoomScale=s}return r.singleLineFieldName?r:void 0}).filter(o)}_destroyFeatureLayers(){this._createdFeatureLayers.forEach(e=>e?.destroy()),this._createdFeatureLayers=[]}_getLayerSources(e,t){const r=this.view?.map;return e.map(e=>{const s=r.findLayerById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=P.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then(e=>{i.layer=e}),i}).filter(o).toArray()}_getTableSources(e,t){const r=this.view?.map;return e.map(e=>{if(!e.id)return;const s=r.findTableById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=P.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then(e=>{i.layer=e}),i}).filter(o).toArray()}_convertApplicationProperties(){const e=this.view?.map,t=e?.applicationProperties?.viewing?.search;if(!t)return[];const{enabled:r,hintText:s,layers:o,tables:i}=t;if(!r)return[];return[...this._getLayerSources(o,s),...this._getTableSources(i,s)]}async _getSubLayer(e,t){if(await e.load(),!e.allSublayers)throw new Error;const r=e.allSublayers.find(e=>e.id===t.subLayer);if(!r)throw new Error;const s=await(r.createFeatureLayer?.());if(!s)throw new Error;return this._createdFeatureLayers.push(s),s}async _getBuildingSubLayer(e,t){await e.load();const r=e.allSublayers.find(e=>e.id===t.subLayer);if("building-component"!==r?.type)throw new Error;if(await r.load(),null==r.associatedLayer)throw new Error;return await r.associatedLayer.load(),r}async _getLayer(e,t){if("feature"===e.type||"scene"===e.type||"csv"===e.type||"geojson"===e.type||"ogc-feature"===e.type)return e;if("map-image"===e.type)try{return await this._getSubLayer(e,t)}catch(r){const t=new l("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return n.getLogger(this).error(t),null}return"building-scene"===e.type?this._getBuildingSubLayer(e,t):null}_getLayerJSON(e){return"function"==typeof e.toJSON?e.toJSON():e}_updateDefaultSources(){const{defaultSources:e,includeDefaultSources:t}=this;this._destroyFeatureLayers(),e.removeAll(),t&&e.addMany([...this._convertApplicationProperties(),...this._convertHelperServices()])}_abortGoTo(){this._gotoController&&this._gotoController.abort(),this._gotoController=null}_clear(){this._abortGoTo(),this._set("resultCount",null),this._set("results",null),this._set("suggestions",null),this._set("suggestionCount",null),this._set("selectedResult",null),this._set("selectedSuggestion",null),this.emit("search-clear")}_closePopup(){const e=this.view?.popup,{resultGraphic:t}=this;if(!e||!t)return;const r="selectedFeature"in e,s=r?e.selectedFeature:null;r&&(s&&s===t)&&e.close()}_suggestTimer(e,t){const r=null!=e?e:this.suggestionDelay;return h(r,null,t?.signal)}_createLocationForSearch(e){return e instanceof r&&e.geometry?_(e.geometry):e instanceof f?e:Array.isArray(e)&&2===e.length?new f({longitude:e[0],latitude:e[1]}):null}_createSuggestionForSearch(e){if(e&&U(e,"key")&&U(e,"text")&&U(e,"sourceIndex"))return e;const t=this._createLocationForSearch(e),r="string"==typeof e?e:this.searchTerm,{selectedSuggestion:s,selectedResult:o}=this,i=!e&&s&&o,l=i&&s.key===o.key&&s.sourceIndex===o.sourceIndex,a=i&&s.location;return l||a?s:{location:t,text:t?"":r,sourceIndex:null,key:null}}_getFirstResult(e){return u(e,({results:e})=>e?.[0])??null}async _selectFirstResult(e){return this.autoSelect&&e?this.select(e):null}async _suggestImmediate(e,t){await this.when();const r=await this._getSuggestionsFromSources(e,t);if(t?.signal?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:e??"",numResults:0,numErrors:0,errors:[],results:[]};return this._formatResponse(s,r),s}_formatSourceResponse(e,t,r){const s=t?.value||[],o=t?.error,i=this.allSources.at(r);if(o){const t={sourceIndex:r,source:i,error:o};e.errors.push(t),n.getLogger(this).error(o),e.numErrors++}else{const t={sourceIndex:r,source:i,results:s};e.results.push(t),e.numResults+=s.length}}_formatResponse(e,t,r){if(t)if(e.activeSourceIndex===z){const s=r&&U(r,"sourceIndex")&&-1!==r.sourceIndex?r.sourceIndex:void 0;t.forEach((t,r)=>{const o=void 0!==s?s:r;this._formatSourceResponse(e,t,o)})}else this._formatSourceResponse(e,t[0],e.activeSourceIndex)}async _getResultsFromSources(e,t){const{allSources:r}=this,s=!e.location&&U(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!r.length){const e=new l("search:no-sources-defined","At least one source is required.",{allSources:r});throw n.getLogger(this).error(e),e}return s===z?r.forEach((r,s)=>{o.push(this._getResultsFromSource(e,s,t))}):o.push(this._getResultsFromSource(e,s,t)),c(o)}async _getSuggestionsFromSources(e,t){const{allSources:r,activeSourceIndex:s}=this,o=[];if(!r.length){const e=new l("suggest:no-sources-defined","At least one source is required.",{allSources:r});throw n.getLogger(this).error(e),e}return s===z?r.forEach((r,s)=>{o.push(this._getSuggestionsFromSource(e,s,t))}):o.push(this._getSuggestionsFromSource(e,s,t)),c(o)}async _getResultsFromSource(e,t,r){const s=null!=t?this.allSources.at(t):null;if(!s)return null;const{location:o=null}=e,i=this.view?.spatialReference??Q,l=U(s,"maxResults")?s.maxResults:this.maxResults,a=!!(s instanceof P&&U(s,"exactMatch"))&&s.exactMatch,{view:n}=this;return s.getResults?.({exactMatch:a,location:o,maxResults:l,sourceIndex:t,spatialReference:i,suggestResult:e,view:n},r)}async _getSuggestionsFromSource(e,t,r){const s=this.allSources.at(t);if(!s)return null;e??="";const o=U(s,"suggestionsEnabled")?s.suggestionsEnabled:this.suggestionsEnabled,i=e?.length,l=U(s,"minSuggestCharacters")?s.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||Q,i=U(s,"maxSuggestions")?s.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(s instanceof P&&U(s,"exactMatch"))&&s.exactMatch;return s.getSuggestions?.({view:l,sourceIndex:t,suggestTerm:e,spatialReference:o,maxSuggestions:i,exactMatch:a},r)}return null}_getLayerSourcePopupTemplate(e){const{layer:t}=e;if(t)return U(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){return u(this.results??[],({results:t,sourceIndex:r})=>{const s=t?.includes(e);return s?r:null})??null}async _goToSearchResult(e){this._abortGoTo();const t=new AbortController;this._gotoController=t;const r={target:{target:e},options:{signal:t.signal}};e||(r.options.animate=!1),await this.callGoTo(r),this._gotoController=null}_getDefaultSymbol(e){const{defaultSymbols:t}=this,r=e.feature?.geometry;if(null==r)return null;switch(r.type){case"point":case"multipoint":return t.point;case"polyline":return t.polyline;case"extent":case"polygon":return t.polygon;default:return null}}_removeHighlight(){this.removeHandles(H)}async _getLayerView(e){const{view:t}=this;if(!e||!t)return null;const{layer:r,sourceLayer:s}=e,o=r??s;return o&&"building-component"!==o.type&&"subtype-sublayer"!==o.type?(await t.when(),t.whenLayerView(o)):null}_highlightFeature(e){const{graphic:t,layerView:r}=e,{attributes:s,layer:o,sourceLayer:i}=t,l=o??i,{objectIdField:a}=l,n=(a&&s?.[a])??null,u=r.highlight(n??t);this.addHandles(u,H)}_setResultFloor(e){const{view:t}=this,r=e.feature?.attributes,s=e.feature?.sourceLayer;if(s&&"floorInfo"in s&&s?.floorInfo?.floorField&&r){const e=r[s.floorInfo.floorField];t?.emit("select-result-floor",e)}}};e([m()],K.prototype,"_searching",void 0),e([m()],K.prototype,"_updatingPromise",void 0),e([m({readOnly:!0,value:null})],K.prototype,"activeSource",null),e([m()],K.prototype,"activeSourceIndex",null),e([m()],K.prototype,"allPlaceholder",null),e([m({readOnly:!0})],K.prototype,"allSources",null),e([m()],K.prototype,"autoNavigate",void 0),e([m()],K.prototype,"autoSelect",void 0),e([m({type:s})],K.prototype,"defaultPopupTemplate",void 0),e([m({readOnly:!0})],K.prototype,"defaultSources",void 0),e([m()],K.prototype,"defaultSymbols",void 0),e([m()],K.prototype,"includeDefaultSources",void 0),e([m()],K.prototype,"locationEnabled",null),e([m()],K.prototype,"maxInputLength",void 0),e([m()],K.prototype,"maxResults",void 0),e([m()],K.prototype,"maxSuggestions",void 0),e([m()],K.prototype,"messages",void 0),e([m()],K.prototype,"minSuggestCharacters",void 0),e([m({readOnly:!0})],K.prototype,"placeholder",null),e([m()],K.prototype,"popupEnabled",void 0),e([m({type:s})],K.prototype,"popupTemplate",void 0),e([m({type:x})],K.prototype,"portal",void 0),e([m()],K.prototype,"resultCount",void 0),e([m()],K.prototype,"resultGraphicEnabled",void 0),e([m({readOnly:!0})],K.prototype,"resultGraphic",void 0),e([m({readOnly:!0})],K.prototype,"results",void 0),e([m({readOnly:!0})],K.prototype,"selectedSuggestion",void 0),e([m()],K.prototype,"searchAllEnabled",void 0),e([m({readOnly:!0})],K.prototype,"selectedResult",void 0),e([m()],K.prototype,"searchTerm",null),e([m({type:B})],K.prototype,"sources",void 0),e([m({readOnly:!0})],K.prototype,"state",null),e([m()],K.prototype,"suggestionDelay",void 0),e([m()],K.prototype,"suggestionCount",void 0),e([m({readOnly:!0})],K.prototype,"suggestions",void 0),e([m()],K.prototype,"suggestionsEnabled",void 0),e([m({readOnly:!0})],K.prototype,"updating",null),e([m()],K.prototype,"view",void 0),e([m()],K.prototype,"clear",null),K=e([y("esri.widgets.Search.SearchViewModel")],K);const W=K;export{W as default};
5
+ import{__decorate as e}from"tslib";import{getAssetUrl as t}from"../../assets.js";import r from"../../Graphic.js";import s from"../../PopupTemplate.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import l from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import n from"../../core/Logger.js";import{mappedFind as u}from"../../core/maybe.js";import{eachAlways as c,after as h}from"../../core/promiseUtils.js";import{watch as p,initial as g,whenOnce as d}from"../../core/reactiveUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import f from"../../geometry/Point.js";import S from"../../geometry/SpatialReference.js";import{getPointFromGeometry as _,getPointWithElevation as v}from"../../geometry/support/geometryUtils.js";import{onLocaleChange as w}from"../../intl/locale.js";import{fetchMessageBundle as b}from"../../intl/messages.js";import x from"../../portal/Portal.js";import{isApiKeyApplicable as L}from"../../support/apiKeyUtils.js";import I from"../../symbols/PictureMarkerSymbol.js";import T from"../../symbols/SimpleFillSymbol.js";import R from"../../symbols/SimpleLineSymbol.js";import E from"../../symbols/TextSymbol.js";import{highlightsSupported as F}from"../../views/support/layerViewUtils.js";import P from"./LayerSearchSource.js";import j from"./LocatorSearchSource.js";import C from"./SearchSource.js";import{isArcGISWorldGeocoder as G,meteredArcGISLocatorUrl as O,isProxiedArcGISWorldGeocoder as A,isMeteredArcGISWorldGeocoder as N}from"./support/locatorUtils.js";import{supported as D,getCurrentPosition as M,positionToPoint as V}from"../support/geolocationUtils.js";import{GoTo as J}from"../support/GoTo.js";function U(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const k=()=>b("esri/widgets/Search/t9n/Search"),H="highlight",B=i.ofType({key:e=>e.layer?"layer":"locator",base:C,typeMap:{layer:P,locator:j}}),Q=S.WGS84,Z="esri/images/search/search-symbol-32.png",q=/<[\s\S]*?>/g,z=-1;let K=class extends(J(a)){constructor(e){super(e),this._gotoController=null,this._searching=null,this._updatingPromise=null,this._createdFeatureLayers=[],this.autoNavigate=!0,this.autoSelect=!0,this.defaultPopupTemplate=null,this.defaultSources=new B,this.defaultSymbols={point:new I({url:t(Z),size:24,width:24,height:24}),polyline:new R({color:[130,130,130,1],width:2}),polygon:new T({color:[235,235,235,.4],outline:{color:[130,130,130,1],width:2}})},this.includeDefaultSources=!0,this.maxInputLength=128,this.maxResults=6,this.maxSuggestions=6,this.messages=null,this.minSuggestCharacters=3,this.popupEnabled=!0,this.popupTemplate=null,this.portal=x.getDefault(),this.resultCount=null,this.resultGraphicEnabled=!0,this.resultGraphic=null,this.results=null,this.selectedSuggestion=null,this.searchAllEnabled=!0,this.selectedResult=null,this.sources=new B,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){const e=async()=>{const e=await k();this.messages=e,this.defaultPopupTemplate=new s({title:e.searchResult,content:"{Match_addr}"})};e(),this.addHandles([p(()=>[this.includeDefaultSources,this.view,this.portal],()=>this._update(),g),w(e)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics()}static{this.ALL_INDEX=z}get activeSource(){return this.allSources.at(this.activeSourceIndex)??null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:z}set activeSourceIndex(e){this._overrideIfSome("activeSourceIndex",e)}get allPlaceholder(){return this.messages?.allPlaceholder}set allPlaceholder(e){this._overrideIfSome("allPlaceholder",e)}get allSources(){const{sources:e,defaultSources:t,includeDefaultSources:r}=this,s="function"==typeof r?r.call(null,{sources:e,defaultSources:t}):r?t.concat(e):e,o=this._get("allSources")||new B;return o.removeAll(),o.addMany(s.filter(Boolean)),o}get locationEnabled(){return this._get("locationEnabled")||D()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=D();if(e&&!t){const e=new l("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});n.getLogger(this).error(e)}this._override("locationEnabled",!!e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:r}=this;if(t===z)return r??"";const s=e.at(t);return s?.placeholder??""}set searchTerm(e){this._set("searchTerm",e||""),this.clearGraphics(),this.selectedSuggestion&&this.selectedSuggestion.text!==e&&this._set("selectedSuggestion",null),""===e&&this._clear()}get searchTerm(){return this._get("searchTerm")||""}get state(){return this._searching?"searching":this.updating?"loading":0===this.allSources.length?"disabled":"ready"}get updating(){return null!=this._updatingPromise}clear(){this.searchTerm=""}clearGraphics(){this._removeHighlight(),this._closePopup();const{view:e,resultGraphic:t}=this;e&&t&&e.graphics.remove(t),this._set("resultGraphic",null)}search(e,t){this.emit("search-start"),this.clearGraphics();const r=this._createSuggestionForSearch(e),s=(async()=>{try{await this.when();const e=await this._getResultsFromSources(r,t);if(t?.signal?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:r.text??"",numResults:0,numErrors:0,errors:[],results:[]};this._formatResponse(s,e,r);const o=this._getFirstResult(s.results),i=r.location&&o?o.name:r.text,l=i?.replace(q,"");return this._set("searchTerm",l),(r.key&&"number"==typeof r.sourceIndex||r.location)&&this._set("selectedSuggestion",r),this._set("results",s.results),this._set("resultCount",s.results.reduce((e,t)=>e+(t.results?.length??0),0)),this.emit("search-complete",s),await this._selectFirstResult(o),s}finally{this._clearSearching()}})();return this._searching=s,s}async searchNearby(e){if(!this.locationEnabled){const e=new l("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});throw n.getLogger(this).error(e),e}const t=(async()=>{try{const t=await M(),r=await V({position:t,view:this.view},e);return await this.search(r,e)}finally{this._clearSearching()}})();return this._searching=t,t}async select(e){if(this.clearGraphics(),!e){const t=new l("select:missing-parameter","Cannot select without a searchResult.",{value:e});throw n.getLogger(this).error(t),t}const{view:t}=this,s=U(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=null!=s?this.allSources.at(s):null;if(!o){const e=new l("select:missing-source","Cannot select without a source.",{source:o});throw n.getLogger(this).error(e),e}const i=o instanceof P?this._getLayerSourcePopupTemplate(o):o.popupTemplate,a=o.resultSymbol||this._getDefaultSymbol(e),u=U(o,"resultGraphicEnabled")?o.resultGraphicEnabled:this.resultGraphicEnabled,h=U(o,"autoNavigate")?o.autoNavigate:this.autoNavigate,p=U(o,"popupEnabled")?o.popupEnabled:this.popupEnabled,g=p?i||this.popupTemplate||this.defaultPopupTemplate:null,{feature:d}=e;if(!d){const e=new l("select:missing-feature","Cannot select without a feature.",{feature:d});throw n.getLogger(this).error(e),e}const{attributes:m,geometry:y,layer:f,sourceLayer:S}=d,w=y?_(y):null,b={layerViewQuery:this._getLayerView(d),elevationQuery:t&&null!=w?v(w,t):Promise.resolve(w)},x=await c(b),L=x.layerViewQuery.value,I=x.elevationQuery.value;a instanceof E&&(a.text=e.name);const T=t&&h?e.target||e.extent:null,R=null!=T?this._goToSearchResult(T):Promise.resolve();await R;const j=L?d:new r({geometry:y,symbol:a,attributes:m,layer:f,sourceLayer:S,popupTemplate:g}),C=t?.popup,G=C&&p&&j.getEffectivePopupTemplate(C.defaultPopupTemplateEnabled);return G&&await t.openPopup({features:[j],location:I}),L&&F(L)&&!G&&this._highlightFeature({graphic:j,layerView:L}),!L&&u&&t&&t.graphics.push(j),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",j),this.emit("select-result",{result:e,source:o,sourceIndex:s}),e}async suggest(e,t,r){const s=e||this.searchTerm;this.emit("suggest-start",{searchTerm:s}),await this._suggestTimer(t,r);const o=await this._suggestImmediate(s,r);return this._set("suggestions",o?.results),this._set("suggestionCount",o?.results.reduce((e,t)=>e+(t.results?.length??0),0)??null),this.emit("suggest-complete",o),o}async when(){await d(()=>!this.updating)}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const r=this._updatingPromise=c([e?.load(),t?.when()]);if(this.destroyed)return;if(await r,r!==this._updatingPromise)return}await d(()=>this.messages),this.destroyed||this._updateDefaultSources(),this._updatingPromise=null}_clearSearching(){this._searching=null}_convertHelperServices(){const e=this.portal?.helperServices?.geocode;if(!e)return[];return e.map(e=>{if(!1===e.placefinding)return;const t=G(e.url)&&L(e.url)?{url:O}:null,r=j.fromJSON({...e,...t}),s=r.url;if(G(s)||A(s)||N(s)){const e=r.outFields??["Addr_type","Match_addr","StAddr","City"],t=(r.placeholder||this.messages?.placeholder)??"",s="number"==typeof r.defaultZoomScale?r.defaultZoomScale:2500;r.singleLineFieldName="SingleLine",r.outFields=e,r.placeholder=t,r.defaultZoomScale=s}return r.singleLineFieldName?r:void 0}).filter(o)}_destroyFeatureLayers(){this._createdFeatureLayers.forEach(e=>e?.destroy()),this._createdFeatureLayers=[]}_getLayerSources(e,t){const r=this.view?.map;return e.map(e=>{const s=r.findLayerById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=P.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then(e=>{i.layer=e}),i}).filter(o).toArray()}_getTableSources(e,t){const r=this.view?.map;return e.map(e=>{if(!e.id)return;const s=r.findTableById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=P.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then(e=>{i.layer=e}),i}).filter(o).toArray()}_convertApplicationProperties(){const e=this.view?.map,t=e?.applicationProperties?.viewing?.search;if(!t)return[];const{enabled:r,hintText:s,layers:o,tables:i}=t;if(!r)return[];return[...this._getLayerSources(o,s),...this._getTableSources(i,s)]}async _getSubLayer(e,t){if(await e.load(),!e.allSublayers)throw new Error;const r=e.allSublayers.find(e=>e.id===t.subLayer);if(!r)throw new Error;const s=await(r.createFeatureLayer?.());if(!s)throw new Error;return this._createdFeatureLayers.push(s),s}async _getBuildingSubLayer(e,t){await e.load();const r=e.allSublayers.find(e=>e.id===t.subLayer);if("building-component"!==r?.type)throw new Error;if(await r.load(),null==r.associatedLayer)throw new Error;return await r.associatedLayer.load(),r}async _getLayer(e,t){if("feature"===e.type||"scene"===e.type||"csv"===e.type||"geojson"===e.type||"ogc-feature"===e.type)return e;if("map-image"===e.type)try{return await this._getSubLayer(e,t)}catch(r){const t=new l("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return n.getLogger(this).error(t),null}return"building-scene"===e.type?this._getBuildingSubLayer(e,t):null}_getLayerJSON(e){return"function"==typeof e.toJSON?e.toJSON():e}_updateDefaultSources(){const{defaultSources:e,includeDefaultSources:t}=this;this._destroyFeatureLayers(),e.removeAll(),t&&e.addMany([...this._convertApplicationProperties(),...this._convertHelperServices()])}_abortGoTo(){this._gotoController&&this._gotoController.abort(),this._gotoController=null}_clear(){this._abortGoTo(),this._set("resultCount",null),this._set("results",null),this._set("suggestions",null),this._set("suggestionCount",null),this._set("selectedResult",null),this._set("selectedSuggestion",null),this.emit("search-clear")}_closePopup(){const e=this.view?.popup,{resultGraphic:t}=this;if(!e||!t)return;const r="selectedFeature"in e,s=r?e.selectedFeature:null;r&&(s&&s===t)&&e.close()}_suggestTimer(e,t){const r=null!=e?e:this.suggestionDelay;return h(r,null,t?.signal)}_createLocationForSearch(e){return e instanceof r&&e.geometry?_(e.geometry):e instanceof f?e:Array.isArray(e)&&2===e.length?new f({longitude:e[0],latitude:e[1]}):null}_createSuggestionForSearch(e){if(e&&U(e,"key")&&U(e,"text")&&U(e,"sourceIndex"))return e;const t=this._createLocationForSearch(e),r="string"==typeof e?e:this.searchTerm,{selectedSuggestion:s,selectedResult:o}=this,i=!e&&s&&o,l=i&&s.key===o.key&&s.sourceIndex===o.sourceIndex,a=i&&s.location;return l||a?s:{location:t,text:t?"":r,sourceIndex:null,key:null}}_getFirstResult(e){return u(e,({results:e})=>e?.[0])??null}async _selectFirstResult(e){return this.autoSelect&&e?this.select(e):null}async _suggestImmediate(e,t){await this.when();const r=await this._getSuggestionsFromSources(e,t);if(t?.signal?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:e??"",numResults:0,numErrors:0,errors:[],results:[]};return this._formatResponse(s,r),s}_formatSourceResponse(e,t,r){const s=t?.value||[],o=t?.error,i=this.allSources.at(r);if(o){const t={sourceIndex:r,source:i,error:o};e.errors.push(t),n.getLogger(this).error(o),e.numErrors++}else{const t={sourceIndex:r,source:i,results:s};e.results.push(t),e.numResults+=s.length}}_formatResponse(e,t,r){if(t)if(e.activeSourceIndex===z){const s=r&&U(r,"sourceIndex")&&-1!==r.sourceIndex?r.sourceIndex:void 0;t.forEach((t,r)=>{const o=void 0!==s?s:r;this._formatSourceResponse(e,t,o)})}else this._formatSourceResponse(e,t[0],e.activeSourceIndex)}async _getResultsFromSources(e,t){const{allSources:r}=this,s=!e.location&&U(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!r.length){const e=new l("search:no-sources-defined","At least one source is required.",{allSources:r});throw n.getLogger(this).error(e),e}return s===z?r.forEach((r,s)=>{o.push(this._getResultsFromSource(e,s,t))}):o.push(this._getResultsFromSource(e,s,t)),c(o)}async _getSuggestionsFromSources(e,t){const{allSources:r,activeSourceIndex:s}=this,o=[];if(!r.length){const e=new l("suggest:no-sources-defined","At least one source is required.",{allSources:r});throw n.getLogger(this).error(e),e}return s===z?r.forEach((r,s)=>{o.push(this._getSuggestionsFromSource(e,s,t))}):o.push(this._getSuggestionsFromSource(e,s,t)),c(o)}async _getResultsFromSource(e,t,r){const s=null!=t?this.allSources.at(t):null;if(!s)return null;const{location:o=null}=e,i=this.view?.spatialReference??Q,l=U(s,"maxResults")?s.maxResults:this.maxResults,a=!!(s instanceof P&&U(s,"exactMatch"))&&s.exactMatch,{view:n}=this;return s.getResults?.({exactMatch:a,location:o,maxResults:l,sourceIndex:t,spatialReference:i,suggestResult:e,view:n},r)}async _getSuggestionsFromSource(e,t,r){const s=this.allSources.at(t);if(!s)return null;e??="";const o=U(s,"suggestionsEnabled")?s.suggestionsEnabled:this.suggestionsEnabled,i=e?.length,l=U(s,"minSuggestCharacters")?s.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||Q,i=U(s,"maxSuggestions")?s.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(s instanceof P&&U(s,"exactMatch"))&&s.exactMatch;return s.getSuggestions?.({view:l,sourceIndex:t,suggestTerm:e,spatialReference:o,maxSuggestions:i,exactMatch:a},r)}return null}_getLayerSourcePopupTemplate(e){const{layer:t}=e;if(t)return U(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){return u(this.results??[],({results:t,sourceIndex:r})=>{const s=t?.includes(e);return s?r:null})??null}async _goToSearchResult(e){this._abortGoTo();const t=new AbortController;this._gotoController=t;const r={target:{target:e},options:{signal:t.signal}};e||(r.options.animate=!1),await this.callGoTo(r),this._gotoController=null}_getDefaultSymbol(e){const{defaultSymbols:t}=this,r=e.feature?.geometry;if(null==r)return null;switch(r.type){case"point":case"multipoint":return t.point;case"polyline":return t.polyline;case"extent":case"polygon":return t.polygon;default:return null}}_removeHighlight(){this.removeHandles(H)}async _getLayerView(e){const{view:t}=this;if(!e||!t)return null;const{layer:r,sourceLayer:s}=e,o=r??s;return o&&"building-component"!==o.type&&"subtype-sublayer"!==o.type?(await t.when(),t.whenLayerView(o)):null}_highlightFeature(e){const{graphic:t,layerView:r}=e,{attributes:s,layer:o,sourceLayer:i}=t,l=o??i,{objectIdField:a}=l,n=(a&&s?.[a])??null,u=r.highlight(n??t);this.addHandles(u,H)}_setResultFloor(e){const{view:t}=this,r=e.feature?.attributes,s=e.feature?.sourceLayer;if(s&&"floorInfo"in s&&s?.floorInfo?.floorField&&r){const e=r[s.floorInfo.floorField];t?.emit("select-result-floor",e)}}};e([m()],K.prototype,"_searching",void 0),e([m()],K.prototype,"_updatingPromise",void 0),e([m({readOnly:!0,value:null})],K.prototype,"activeSource",null),e([m()],K.prototype,"activeSourceIndex",null),e([m()],K.prototype,"allPlaceholder",null),e([m({readOnly:!0})],K.prototype,"allSources",null),e([m()],K.prototype,"autoNavigate",void 0),e([m()],K.prototype,"autoSelect",void 0),e([m({type:s})],K.prototype,"defaultPopupTemplate",void 0),e([m({readOnly:!0})],K.prototype,"defaultSources",void 0),e([m()],K.prototype,"defaultSymbols",void 0),e([m()],K.prototype,"includeDefaultSources",void 0),e([m()],K.prototype,"locationEnabled",null),e([m()],K.prototype,"maxInputLength",void 0),e([m()],K.prototype,"maxResults",void 0),e([m()],K.prototype,"maxSuggestions",void 0),e([m()],K.prototype,"messages",void 0),e([m()],K.prototype,"minSuggestCharacters",void 0),e([m({readOnly:!0})],K.prototype,"placeholder",null),e([m()],K.prototype,"popupEnabled",void 0),e([m({type:s})],K.prototype,"popupTemplate",void 0),e([m({type:x})],K.prototype,"portal",void 0),e([m()],K.prototype,"resultCount",void 0),e([m()],K.prototype,"resultGraphicEnabled",void 0),e([m({readOnly:!0})],K.prototype,"resultGraphic",void 0),e([m({readOnly:!0})],K.prototype,"results",void 0),e([m({readOnly:!0})],K.prototype,"selectedSuggestion",void 0),e([m()],K.prototype,"searchAllEnabled",void 0),e([m({readOnly:!0})],K.prototype,"selectedResult",void 0),e([m()],K.prototype,"searchTerm",null),e([m({type:B})],K.prototype,"sources",void 0),e([m({readOnly:!0})],K.prototype,"state",null),e([m()],K.prototype,"suggestionDelay",void 0),e([m()],K.prototype,"suggestionCount",void 0),e([m({readOnly:!0})],K.prototype,"suggestions",void 0),e([m()],K.prototype,"suggestionsEnabled",void 0),e([m({readOnly:!0})],K.prototype,"updating",null),e([m()],K.prototype,"view",void 0),e([m()],K.prototype,"clear",null),K=e([y("esri.widgets.Search.SearchViewModel")],K);const W=K;export{W as default};