@arcgis/core 4.24.0-next.20220607 → 4.24.0-next.20220610

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 (206) hide show
  1. package/analysis/Analysis.js +1 -1
  2. package/analysis/LineOfSightAnalysis.js +1 -1
  3. package/arcade/arcadeCompiler.js +1 -1
  4. package/arcade.d.ts +4 -0
  5. package/arcade.js +1 -1
  6. package/assets/esri/core/workers/RemoteClient.js +1 -1
  7. package/assets/esri/core/workers/chunks/{4d2181bde97983ecac8b.js → 03ddf44e6fb8bf9db3ff.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{2e2d7f5952934af43fd7.js → 04034dabc8e0a489b0f8.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{d7168ff8f26ca2537080.js → 0747c28fce0b344dc89b.js} +1 -1
  10. package/assets/esri/core/workers/chunks/1e4e5d147263e98536bc.js +1 -0
  11. package/assets/esri/core/workers/chunks/{cbe98327181d8d7ad9e5.js → 262fabdc409d55831ffa.js} +1 -1
  12. package/assets/esri/core/workers/chunks/2a52c2c6edd70432f4a5.js +1 -0
  13. package/assets/esri/core/workers/chunks/{71d445d1e6812e03a1d7.js → 3ce7adaefc9de28d9c87.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{c165845a117c21246b1e.js → 42aa8ce4eb7bd851475e.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{a9a4bb1d781b1a995fb3.js → 4824926501e11d04eb4a.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{e51420d231c286b9c062.js → 540f1ed1ea9cddc739af.js} +1 -1
  17. package/assets/esri/core/workers/chunks/6196cfdeb91ceba52af3.js +1 -0
  18. package/assets/esri/core/workers/chunks/71a4618d959a09302c51.js +1 -0
  19. package/assets/esri/core/workers/chunks/76fbc8eaabba62fd4f9c.js +1 -0
  20. package/assets/esri/core/workers/chunks/{cb906a3f03dd0805c880.js → 7cc17b716b16a6684023.js} +1 -1
  21. package/assets/esri/core/workers/chunks/871681c1353026cb6d4b.js +1 -0
  22. package/assets/esri/core/workers/chunks/{13e9e6f0b4942d79b0eb.js → 88942e9f60687ac006dc.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{4c5b80ba3dbfe6f6cafb.js → acb1e649cda99d4f69a5.js} +1 -1
  24. package/assets/esri/core/workers/chunks/b71a0a8a2f446c671161.js +1 -0
  25. package/assets/esri/core/workers/chunks/b8002aaa665712299121.js +1 -0
  26. package/assets/esri/core/workers/chunks/{e4ca3f04ca7f71b46240.js → bb3480e231934b7bb34e.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{185da42e7cc8e440c0f0.js → c157b46b0724f3f0947e.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{1aba8c73c62a64e0658c.js → c6af8b0903d8d934d542.js} +1 -1
  29. package/assets/esri/core/workers/chunks/c8402e32307a7b7eaaeb.js +1 -0
  30. package/assets/esri/core/workers/chunks/c8e08a956b16034d9819.js +1 -0
  31. package/assets/esri/core/workers/chunks/d0d2566bedc493ed0a3b.js +1 -0
  32. package/assets/esri/core/workers/chunks/{8152cd26ebeae910b753.js → d3c73da9c2abb59e762a.js} +1 -1
  33. package/assets/esri/core/workers/chunks/d828a0656e7351a74fc4.js +1 -0
  34. package/assets/esri/core/workers/chunks/{172368d4eb6e6f8d2bdb.js → d8b9551df1bd196d0126.js} +1 -1
  35. package/assets/esri/core/workers/chunks/e5c8584ae764892c324d.js +1 -0
  36. package/assets/esri/core/workers/chunks/{1d893ebc6f203ff1fc3d.js → efe605ff4ba2a95c14c5.js} +1 -1
  37. package/assets/esri/core/workers/chunks/f54d5abbb9668c45bd19.js +1 -0
  38. package/assets/esri/core/workers/chunks/{bd2f4a01cb71e25837ba.js → f7ba74fc4eb541c424fc.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{1ebed6d6f561f926bd36.js → faf6e48f9f1205fb2e43.js} +1 -1
  40. package/assets/esri/geometry/support/pe-wasm.wasm +0 -0
  41. package/assets/esri/themes/base/widgets/_BasemapToggle.scss +6 -23
  42. package/assets/esri/themes/base/widgets/_Directions.scss +0 -3
  43. package/assets/esri/themes/base/widgets/_FeatureTable.scss +10 -2
  44. package/assets/esri/themes/base/widgets/_Slider.scss +8 -3
  45. package/assets/esri/themes/base/widgets/_Tooltip.scss +8 -8
  46. package/assets/esri/themes/base/widgets/_Weather.scss +5 -1
  47. package/assets/esri/themes/dark/main.css +1 -1
  48. package/assets/esri/themes/light/main.css +1 -1
  49. package/assets/esri/themes/light/view.css +1 -1
  50. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle.json +1 -1
  51. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_ar.json +1 -1
  52. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_bg.json +1 -1
  53. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_bs.json +1 -1
  54. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_ca.json +1 -1
  55. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_cs.json +1 -1
  56. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_da.json +1 -1
  57. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_de.json +1 -1
  58. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_el.json +1 -1
  59. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_en.json +1 -1
  60. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_es.json +1 -1
  61. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_et.json +1 -1
  62. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_fi.json +1 -1
  63. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_fr.json +1 -1
  64. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_he.json +1 -1
  65. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_hr.json +1 -1
  66. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_hu.json +1 -1
  67. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_id.json +1 -1
  68. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_it.json +1 -1
  69. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_ja.json +1 -1
  70. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_ko.json +1 -1
  71. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_lt.json +1 -1
  72. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_lv.json +1 -1
  73. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_nb.json +1 -1
  74. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_nl.json +1 -1
  75. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_pl.json +1 -1
  76. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_pt-BR.json +1 -1
  77. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_pt-PT.json +1 -1
  78. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_ro.json +1 -1
  79. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_ru.json +1 -1
  80. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_sk.json +1 -1
  81. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_sl.json +1 -1
  82. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_sr.json +1 -1
  83. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_sv.json +1 -1
  84. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_th.json +1 -1
  85. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_tr.json +1 -1
  86. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_uk.json +1 -1
  87. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_vi.json +1 -1
  88. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_zh-CN.json +1 -1
  89. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_zh-HK.json +1 -1
  90. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_zh-TW.json +1 -1
  91. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_en.json +1 -1
  92. package/chunks/RasterColorizer.glsl.js +22 -18
  93. package/chunks/basis_transcoder.js +1 -1
  94. package/chunks/i3s.js +1 -1
  95. package/chunks/lclayout.js +1 -1
  96. package/chunks/lerc-wasm.js +1 -1
  97. package/chunks/libtess-asm.js +1 -1
  98. package/chunks/libtess.js +1 -1
  99. package/chunks/pe-wasm.js +1 -1
  100. package/chunks/persistableUrlUtils.js +1 -1
  101. package/chunks/vxlLayer.js +1 -1
  102. package/core/quantityUtils.js +1 -1
  103. package/geometry/projection.js +1 -1
  104. package/geometry/support/geodesicUtils.js +1 -1
  105. package/geometry/support/plane.js +1 -1
  106. package/interfaces.d.ts +471 -52
  107. package/layers/LineOfSightLayer.js +1 -1
  108. package/layers/RouteLayer.js +1 -1
  109. package/layers/VectorTileLayer.js +1 -1
  110. package/layers/support/LayerContingentValuesCache.js +1 -1
  111. package/layers/support/RasterInfo.js +1 -1
  112. package/layers/support/rasterDatasets/ImageAuxRaster.js +1 -1
  113. package/layers/support/rasterDatasets/InMemoryRaster.js +1 -1
  114. package/layers/support/rasterDatasets/WCSRaster.js +1 -1
  115. package/layers/support/rasterDatasets/wcsCoverageParser.js +1 -1
  116. package/layers/support/rasterFormats/JpgPlus.js +1 -1
  117. package/layers/support/rasterFormats/RasterCodec.js +1 -1
  118. package/layers/support/rasterFormats/TiffDecoder.js +1 -1
  119. package/package.json +1 -1
  120. package/portal/support/urlUtils.js +5 -0
  121. package/renderers/support/colorRampUtils.js +1 -1
  122. package/rest/imageService/fetchRasterInfo.js +1 -1
  123. package/smartMapping/renderers/pieChart.js +1 -1
  124. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  125. package/support/arcadeUtils.js +1 -1
  126. package/support/elevationInfoUtils.js +1 -1
  127. package/support/persistableUrlUtils.js +1 -1
  128. package/support/revision.js +1 -1
  129. package/symbols/cim/cimAnalyzer.js +1 -1
  130. package/views/2d/engine/vectorTiles/shaders/VTLMaterial.js +1 -1
  131. package/views/2d/engine/webgl/Utils.js +1 -1
  132. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  133. package/views/2d/layers/graphics/GraphicStoreItem.js +1 -1
  134. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  135. package/views/3d/analysis/AnalysisViewManager3D.js +1 -1
  136. package/views/3d/analysis/Dimensioning/LengthDimensionComputation.js +1 -1
  137. package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementVisualization.js +1 -1
  138. package/views/3d/analysis/DirectLineMeasurementAnalysisView3D.js +1 -1
  139. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  140. package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
  141. package/views/3d/input/SceneInputManager.js +1 -1
  142. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  143. package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
  144. package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
  145. package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +1 -1
  146. package/views/3d/interactive/editingTools/transformGraphic/GraphicTransformTool.js +1 -1
  147. package/views/3d/layers/i3s/I3SAttributeOverrides.js +1 -1
  148. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  149. package/views/3d/support/MemoryController.js +1 -1
  150. package/views/3d/terrain/RasterColorizerTechnique.js +1 -1
  151. package/views/3d/terrain/TerrainSurface.js +1 -1
  152. package/views/3d/terrain/TileCompositor.js +1 -1
  153. package/views/3d/terrain/TileRenderer.js +1 -1
  154. package/views/3d/webgl-engine/core/shaderLibrary/output/BlendOptions.js +1 -1
  155. package/views/MapView.js +1 -1
  156. package/views/SceneView.js +1 -1
  157. package/views/View.js +1 -1
  158. package/views/draw/DrawOperation.js +1 -1
  159. package/views/draw/support/GraphicMover.js +1 -1
  160. package/views/interactive/SegmentLabels.js +1 -1
  161. package/views/interactive/editGeometry/support/editPlaneUtils.js +1 -1
  162. package/views/interactive/tooltip/TranslateTooltipInfos.js +1 -1
  163. package/views/interactive/tooltip/content/TooltipContentTranslateVertex.js +1 -1
  164. package/views/interactive/tooltip/support/measurements.js +1 -1
  165. package/views/support/areaMeasurementUtils.js +1 -1
  166. package/views/support/automaticLengthMeasurementUtils.js +5 -0
  167. package/views/support/euclideanLengthMeasurementUtils.js +5 -0
  168. package/views/support/geodesicLengthMeasurementUtils.js +5 -0
  169. package/views/support/measurementUtils.js +5 -0
  170. package/widgets/BasemapToggle/BasemapToggleViewModel.js +1 -1
  171. package/widgets/BasemapToggle.js +1 -1
  172. package/widgets/BuildingExplorer/BuildingDisciplinesTree/BuildingDisciplinesTree.js +1 -1
  173. package/widgets/BuildingExplorer/BuildingLevelPicker/BuildingLevelPicker.js +1 -1
  174. package/widgets/BuildingExplorer/BuildingPhasePicker/BuildingPhasePicker.js +1 -1
  175. package/widgets/BuildingExplorer.js +1 -1
  176. package/widgets/Daylight/DaylightViewModel.js +1 -1
  177. package/widgets/Directions/DirectionsViewModel.js +1 -1
  178. package/widgets/Directions.js +1 -1
  179. package/widgets/Feature/FeatureMedia/FeatureMediaViewModel.js +1 -1
  180. package/widgets/Feature/support/featureUtils.js +1 -1
  181. package/widgets/FeatureTable/FieldColumn.js +1 -1
  182. package/widgets/Legend/support/sizeRampUtils.js +1 -1
  183. package/widgets/Print/PrintViewModel.js +1 -1
  184. package/widgets/Sketch/SketchViewModel.js +1 -1
  185. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  186. package/widgets/UtilityNetworkTrace.js +1 -1
  187. package/widgets/Weather.js +1 -1
  188. package/widgets/Widget.js +1 -1
  189. package/widgets/support/AnalysisViewModel.js +1 -1
  190. package/widgets/support/AnchorElementViewModel.js +1 -1
  191. package/widgets/support/InteractiveAnalysisViewModel.js +1 -1
  192. package/assets/esri/core/workers/chunks/2ac6c99aacb873134f7c.js +0 -1
  193. package/assets/esri/core/workers/chunks/471beeb6924599209567.js +0 -1
  194. package/assets/esri/core/workers/chunks/5242c9badca17ba2ab25.js +0 -1
  195. package/assets/esri/core/workers/chunks/72c7d48408d1f8050026.js +0 -1
  196. package/assets/esri/core/workers/chunks/770cf0a66102100abe74.js +0 -1
  197. package/assets/esri/core/workers/chunks/96ff15d6c2bfca0c6061.js +0 -1
  198. package/assets/esri/core/workers/chunks/9c4c721d890b49697132.js +0 -1
  199. package/assets/esri/core/workers/chunks/af3766a2d27419c7766c.js +0 -1
  200. package/assets/esri/core/workers/chunks/b50bbfd75768d9a8de88.js +0 -1
  201. package/assets/esri/core/workers/chunks/b577ec80647cf2ece397.js +0 -1
  202. package/assets/esri/core/workers/chunks/c1653b6cb201ecbaabaa.js +0 -1
  203. package/assets/esri/core/workers/chunks/e99b58d07475bffce7ea.js +0 -1
  204. package/assets/esri/core/workers/chunks/f3d885aec4bca18928d4.js +0 -1
  205. package/assets/esri/core/workers/chunks/fc0da1dfeef041182ddf.js +0 -1
  206. package/views/support/lengthMeasurementUtils.js +0 -5
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
+ */
5
+ import{canProjectWithoutEngine as o}from"../../geometry/projection.js";import{getSphericalPCPF as r,SphericalECEFSpatialReference as t,WGS84ECEFSpatialReference as e}from"../../geometry/projectionEllipsoid.js";function i(i){const m=r(i),n=m===t?e:m;return o(i,n)?n:i}export{i as computeEuclideanMeasurementSR};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{typeCast as t}from"../../core/compilerUtils.js";import a from"../../core/Evented.js";import{isSome as s}from"../../core/maybe.js";import{watch as i,whenOnce as r,initial as o}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{cast as n}from"../../core/accessorSupport/decorators/cast.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{isLoaded as c,canProjectWithoutEngine as m,load as h}from"../../geometry/projection.js";import{equals as f}from"../../geometry/support/spatialReferenceUtils.js";import{esriBasemapDefinitions as u}from"../../support/basemapDefinitions.js";import{ensureType as d,destroyCache as g,findSpatialReference as v,getWellKnownBasemapId as B}from"../../support/basemapUtils.js";let b=class extends a.EventedAccessor{constructor(e){super(e),this._basemapCache={},this._loadingProjectionEngine=!1,this.nextBasemap=d("hybrid",this._basemapCache),this.view=null,this.toggle=this.toggle.bind(this)}initialize(){i((()=>this.nextBasemap),(e=>{e&&!e.loaded&&e.load().catch((()=>{}))}),o)}destroy(){this.view=null,g(this._basemapCache),this._basemapCache=null}get _nextBasemapSpatialReferenceTask(){return v(this.view,this.nextBasemap)}get activeBasemap(){return d(this.view?.map?.basemap??"topo",this._basemapCache)}castNextBasemap(e){return d(e,this._basemapCache)}get state(){return this.view?.ready?this._loadingProjectionEngine?"loading":"ready":"disabled"}async toggle(){if("disabled"===this.state)return;const{activeBasemap:e,nextBasemap:t}=this,a=!("spatialReferenceLocked"in this.view)||this.view.spatialReferenceLocked;if(!a){if(await r((()=>!this._nextBasemapSpatialReferenceTask.updating)),t!==this.nextBasemap||e!==this.activeBasemap)return;const{spatialReference:a}=this._nextBasemapSpatialReferenceTask;if(!s(a)||f(this.view.spatialReference,a)||c()||m(this.view.spatialReference,a)||(this._loadingProjectionEngine=!0,await h(),this._loadingProjectionEngine=!1),t!==this.nextBasemap||e!==this.activeBasemap)return}this.view.map.basemap=t,a||!s(this._nextBasemapSpatialReferenceTask.spatialReference)||f(this.view.spatialReference,this._nextBasemapSpatialReferenceTask.spatialReference)||(this.view.spatialReference=this._nextBasemapSpatialReferenceTask.spatialReference),this.nextBasemap=e,this.emit("toggle",{previous:e,current:t})}static getThumbnailUrl(e){if(!e)return null;const{thumbnailUrl:a}=e;if(a)return a;const s=B(e);if(s)return u[s].thumbnailUrl;const i=e.baseLayers.find((e=>!!t(e)().get("portalItem.thumbnailUrl")));return i?t(i)().get("portalItem.thumbnailUrl"):null}};e([p()],b.prototype,"_loadingProjectionEngine",void 0),e([p({readOnly:!0})],b.prototype,"_nextBasemapSpatialReferenceTask",null),e([p({readOnly:!0})],b.prototype,"activeBasemap",null),e([p()],b.prototype,"nextBasemap",void 0),e([n("nextBasemap")],b.prototype,"castNextBasemap",null),e([p({readOnly:!0})],b.prototype,"state",null),e([p()],b.prototype,"view",void 0),e([p()],b.prototype,"toggle",null),b=e([l("esri.widgets.BasemapToggle.BasemapToggleViewModel")],b);const y=b;export{y as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{typeCast as t}from"../../core/compilerUtils.js";import a from"../../core/Evented.js";import{isSome as s}from"../../core/maybe.js";import{watch as i,whenOnce as r,initial as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{cast as p}from"../../core/accessorSupport/decorators/cast.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{isLoaded as c,canProjectWithoutEngine as m,load as h}from"../../geometry/projection.js";import{equals as f}from"../../geometry/support/spatialReferenceUtils.js";import{esriBasemapDefinitions as u}from"../../support/basemapDefinitions.js";import{ensureType as d,destroyCache as g,findSpatialReference as v,getWellKnownBasemapId as b}from"../../support/basemapUtils.js";let B=class extends a.EventedAccessor{constructor(e){super(e),this._basemapCache={},this._loadingProjectionEngine=!1,this.nextBasemap=d("hybrid",this._basemapCache),this.view=null,this.toggle=this.toggle.bind(this)}initialize(){i((()=>this.nextBasemap),(e=>{e&&!e.loaded&&e.load().catch((()=>{}))}),o)}destroy(){this.view=null,g(this._basemapCache),this._basemapCache=null}get _nextBasemapSpatialReferenceTask(){return v(this.view,this.nextBasemap)}get _viewSpatialReferenceLocked(){return!("spatialReferenceLocked"in this.view)||this.view.spatialReferenceLocked}get activeBasemap(){return d(this.view?.map?.basemap??"topo",this._basemapCache)}castNextBasemap(e){return d(e,this._basemapCache)}get state(){const{view:e}=this;if(!e?.ready)return"disabled";if(this._nextBasemapSpatialReferenceTask.updating)return"disabled";const{spatialReference:t}=this._nextBasemapSpatialReferenceTask;return this._viewSpatialReferenceLocked&&s(t)&&!e.spatialReference.equals(t)?"incompatible-next-basemap":this._loadingProjectionEngine?"loading":"ready"}async toggle(){if("disabled"===this.state||"incompatible-next-basemap"===this.state)return;const{activeBasemap:e,nextBasemap:t}=this,a=this._viewSpatialReferenceLocked;if(!a){if(await r((()=>!this._nextBasemapSpatialReferenceTask.updating)),t!==this.nextBasemap||e!==this.activeBasemap)return;const{spatialReference:a}=this._nextBasemapSpatialReferenceTask;if(!s(a)||f(this.view.spatialReference,a)||c()||m(this.view.spatialReference,a)||(this._loadingProjectionEngine=!0,await h(),this._loadingProjectionEngine=!1),t!==this.nextBasemap||e!==this.activeBasemap)return}this.view.map.basemap=t,a||!s(this._nextBasemapSpatialReferenceTask.spatialReference)||f(this.view.spatialReference,this._nextBasemapSpatialReferenceTask.spatialReference)||(this.view.spatialReference=this._nextBasemapSpatialReferenceTask.spatialReference),this.nextBasemap=e,this.emit("toggle",{previous:e,current:t})}static getThumbnailUrl(e){if(!e)return null;const{thumbnailUrl:a}=e;if(a)return a;const s=b(e);if(s)return u[s].thumbnailUrl;const i=e.baseLayers.find((e=>!!t(e)().get("portalItem.thumbnailUrl")));return i?t(i)().get("portalItem.thumbnailUrl"):null}};e([n()],B.prototype,"_loadingProjectionEngine",void 0),e([n({readOnly:!0})],B.prototype,"_nextBasemapSpatialReferenceTask",null),e([n({readOnly:!0})],B.prototype,"_viewSpatialReferenceLocked",null),e([n({readOnly:!0})],B.prototype,"activeBasemap",null),e([n()],B.prototype,"nextBasemap",void 0),e([p("nextBasemap")],B.prototype,"castNextBasemap",null),e([n({readOnly:!0})],B.prototype,"state",null),e([n()],B.prototype,"view",void 0),e([n()],B.prototype,"toggle",null),B=e([l("esri.widgets.BasemapToggle.BasemapToggleViewModel")],B);const R=B;export{R as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{aliasOf as s}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as t}from"../core/accessorSupport/decorators/cast.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import{subclass as o}from"../core/accessorSupport/decorators/subclass.js";import i from"./Widget.js";import l from"./BasemapToggle/BasemapToggleViewModel.js";import{accessibleHandler as r}from"./support/decorators/accessibleHandler.js";import{messageBundle as p}from"./support/decorators/messageBundle.js";import{vmEvent as m}from"./support/decorators/vmEvent.js";import{tsx as n}from"./support/jsxFactory.js";import"./support/widgetUtils.js";const d={base:"esri-basemap-toggle esri-widget",secondaryBasemapImage:"esri-basemap-toggle__image--secondary",container:"esri-basemap-thumbnail esri-basemap-toggle__container",image:"esri-basemap-thumbnail__image esri-basemap-toggle__image",imageLoading:"esri-basemap-toggle__image--loading",overlay:"esri-basemap-thumbnail__overlay esri-basemap-toggle__image-overlay",title:"esri-basemap-thumbnail__title esri-basemap-toggle__title",disabled:"esri-disabled",loaderAnimation:"esri-widget__loader-animation"};function g(e){const s=l.getThumbnailUrl(e);return s?{backgroundImage:"url("+s+")"}:{backgroundImage:""}}const c={title:!1};let u=class extends i{constructor(e,s){super(e,s),this.activeBasemap=null,this.label=void 0,this.messages=null,this.nextBasemap=null,this.view=null,this.viewModel=new l,this.visibleElements={...c}}loadDependencies(){return import("@esri/calcite-components/dist/components/calcite-scrim.js")}castVisibleElements(e){return{...c,...e}}toggle(){return null}render(){const e=this.viewModel,s="disabled"===e.state?null:e.activeBasemap,t="disabled"===e.state?null:e.nextBasemap,a="loading"===e.state,o=t?t.title:"",i=t&&"loaded"!==t.loadStatus;let l;return this.visibleElements.title&&o&&(l=n("div",{class:d.overlay,key:"esri-basemap-toggle__overlay"},n("span",{class:d.title,title:o},o))),n("div",{class:d.base,role:"button","data-basemap-id":t?t.id:"",bind:this,onclick:this._toggle,onkeydown:this._toggle,tabIndex:0,title:this.label},n("div",{class:this.classes(d.container,d.secondaryBasemapImage)},n("div",{class:d.image,styles:g(s)})),n("div",{class:d.container},n("div",{class:this.classes(d.image,i?d.imageLoading:null),styles:g(t)},i||a?n("calcite-scrim",null,n("span",{"aria-hidden":"true",role:"presentation",class:d.loaderAnimation})):null),l))}_toggle(){this.toggle()}};e([s("viewModel.activeBasemap")],u.prototype,"activeBasemap",void 0),e([a({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],u.prototype,"label",void 0),e([a(),p("esri/widgets/BasemapToggle/t9n/BasemapToggle")],u.prototype,"messages",void 0),e([s("viewModel.nextBasemap")],u.prototype,"nextBasemap",void 0),e([s("viewModel.view")],u.prototype,"view",void 0),e([m("toggle"),a({type:l})],u.prototype,"viewModel",void 0),e([a()],u.prototype,"visibleElements",void 0),e([t("visibleElements")],u.prototype,"castVisibleElements",null),e([s("viewModel.toggle")],u.prototype,"toggle",null),e([r()],u.prototype,"_toggle",null),u=e([o("esri.widgets.BasemapToggle")],u);const b=u;export{b as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{aliasOf as s}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as t}from"../core/accessorSupport/decorators/cast.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import o from"./Widget.js";import l from"./BasemapToggle/BasemapToggleViewModel.js";import{accessibleHandler as r}from"./support/decorators/accessibleHandler.js";import{messageBundle as n}from"./support/decorators/messageBundle.js";import{vmEvent as m}from"./support/decorators/vmEvent.js";import{tsx as c}from"./support/jsxFactory.js";import"./support/widgetUtils.js";const p={base:"esri-basemap-toggle esri-widget",secondaryBasemapImage:"esri-basemap-toggle__image--secondary",container:"esri-basemap-thumbnail esri-basemap-toggle__container",image:"esri-basemap-thumbnail__image esri-basemap-toggle__image",imageLoading:"esri-basemap-toggle__image--loading",overlay:"esri-basemap-thumbnail__overlay esri-basemap-toggle__image-overlay",title:"esri-basemap-thumbnail__title esri-basemap-toggle__title",overlayScrim:"esri-basemap-thumbnail__overlay-scrim",disabled:"esri-disabled",loaderAnimation:"esri-widget__loader-animation"};function d(e){const s=l.getThumbnailUrl(e);return s?{backgroundImage:"url("+s+")"}:{backgroundImage:""}}const g={title:!1};let u=class extends o{constructor(e,s){super(e,s),this.activeBasemap=null,this.label=void 0,this.messages=null,this.nextBasemap=null,this.view=null,this.viewModel=new l,this.visibleElements={...g}}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-icon.js"),import("@esri/calcite-components/dist/components/calcite-scrim.js")])}castVisibleElements(e){return{...g,...e}}toggle(){return null}render(){const e=this.viewModel,s="disabled"===e.state?null:e.activeBasemap,t="disabled"===e.state?null:e.nextBasemap,a="loading"===e.state,i="incompatible-next-basemap"===e.state,o=t?t.title:"",l=t&&"loaded"!==t.loadStatus;let r;const n=this.visibleElements.title&&o,m=i;return(n||m)&&(r=c("div",{class:p.overlay,key:"overlay"},n?c("span",{class:p.title,title:o},o):null,m?c("calcite-scrim",{class:p.overlayScrim,title:this.messages.incompatibleSpatialReference},c("calcite-icon",{icon:"exclamation-mark-triangle"})):null)),c("div",{class:this.classes(p.base,i?p.disabled:null),role:"button","data-basemap-id":t?t.id:"",bind:this,onclick:this._toggle,onkeydown:this._toggle,tabIndex:i?-1:0,title:this.label},c("div",{class:this.classes(p.container,p.secondaryBasemapImage)},c("div",{class:p.image,styles:d(s)})),c("div",{class:p.container},c("div",{class:this.classes(p.image,l?p.imageLoading:null),styles:d(t)},l||a?c("calcite-scrim",null,c("span",{"aria-hidden":"true",role:"presentation",class:p.loaderAnimation})):null),r))}_toggle(){this.toggle()}};e([s("viewModel.activeBasemap")],u.prototype,"activeBasemap",void 0),e([a({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],u.prototype,"label",void 0),e([a(),n("esri/widgets/BasemapToggle/t9n/BasemapToggle")],u.prototype,"messages",void 0),e([s("viewModel.nextBasemap")],u.prototype,"nextBasemap",void 0),e([s("viewModel.view")],u.prototype,"view",void 0),e([m("toggle"),a({type:l})],u.prototype,"viewModel",void 0),e([a()],u.prototype,"visibleElements",void 0),e([t("visibleElements")],u.prototype,"castVisibleElements",null),e([s("viewModel.toggle")],u.prototype,"toggle",null),e([r()],u.prototype,"_toggle",null),u=e([i("esri.widgets.BasemapToggle")],u);const b=u;export{b 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.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as s}from"../../../chunks/tslib.es6.js";import{unwrapOr as e}from"../../../core/maybe.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import o from"../../Widget.js";import t from"./BuildingDisciplinesNode.js";import"../../support/widgetUtils.js";import{tsx as l}from"../../support/jsxFactory.js";const p={expand:"expand",collapse:"collapse",hideSublayer:"hideSublayer",showSublayer:"showSublayer"},a={base:`${"esri-building-disciplines-tree"}`};let c=class extends o{constructor(s){super(s),this.toggleSiblingsVisibility=!1}render(){const s=this.viewModel,i=this.toggleSiblingsVisibility,r=e(this.messages,p);return l("div",{role:"tree",class:a.base},s.root.children.toArray().reverse().map((s=>l(t,{node:s,messages:r,toggleSiblingsVisibility:i}))))}};s([i()],c.prototype,"viewModel",void 0),s([i()],c.prototype,"messages",void 0),s([i()],c.prototype,"toggleSiblingsVisibility",void 0),c=s([r("esri.widgets.BuildingExplorer.BuildingDisciplinesTree.BuildingDisciplinesTree")],c);const d=c;export{d as default};
5
+ import{_ as s}from"../../../chunks/tslib.es6.js";import{unwrapOr as e}from"../../../core/maybe.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import o from"../../Widget.js";import t from"./BuildingDisciplinesNode.js";import"../../support/widgetUtils.js";import{tsx as p}from"../../support/jsxFactory.js";const l={expand:"expand",collapse:"collapse",hideSublayer:"hideSublayer",showSublayer:"showSublayer"},a={base:`${"esri-building-disciplines-tree"}`};let c=class extends o{constructor(s){super(s),this.toggleSiblingsVisibility=!1}render(){const{vm:s}=this,i=this.toggleSiblingsVisibility,r=e(this.messages,l);return p("div",{role:"tree",class:a.base},s.root.children.toArray().reverse().map((s=>p(t,{node:s,messages:r,toggleSiblingsVisibility:i}))))}};s([i()],c.prototype,"vm",void 0),s([i()],c.prototype,"messages",void 0),s([i()],c.prototype,"toggleSiblingsVisibility",void 0),c=s([r("esri.widgets.BuildingExplorer.BuildingDisciplinesTree.BuildingDisciplinesTree")],c);const n=c;export{n as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{on as t}from"../../../core/events.js";import i from"../../../core/Handles.js";import{clamp as s}from"../../../core/mathUtils.js";import{isNone as o,isSome as l,unwrapOr as n}from"../../../core/maybe.js";import{watch as r,initial as a}from"../../../core/reactiveUtils.js";import{aliasOf as h}from"../../../core/accessorSupport/decorators/aliasOf.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{property as v}from"../../../core/accessorSupport/decorators/property.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import _ from"../../Widget.js";import{L as p,a as c,A as g,b as u,c as m,d as L,e as w,f as y,g as b,h as P,i as M}from"../../../chunks/constants.js";import{Label as f}from"./Label.js";import{LevelItem as C}from"./LevelItem.js";import{storeNode as W}from"../../support/widgetUtils.js";import{tsx as x}from"../../support/jsxFactory.js";const H={selectLevel:"selectLevel",clearLevel:"clearLevel",nextLevel:"nextLevel",previousLevel:"previousLevel",currentLevel:"{{value}}"},j="esri-building-level-picker",E={container:j,noLevel:`${j}--no-level`,animateLevel:`${j}--animate-level`,levelsContainer:`${j}__levels-container`,innerLevelsContainer:`${j}__inner-levels-container`,labelContainer:`${j}__label-container`,arrowUp:`${j}__arrow-up`,arrowDown:`${j}__arrow-down`};let T=class extends _{constructor(e,t){super(e,t),this._levelHandles=new i,this._levelEventHandles=new i,this._levelWidgets=[],this._labelWidget=new f({onClear:()=>this.viewModel.clear()}),this._hoveredLevel=null,this._expandedLevelsHeight=void 0,this._normalizedPointerPosition=0,this._hovering=!1,this._containerPosTop=null,this._levelsContainer=null,this._onPointerUp=()=>{window.getSelection().removeAllRanges(),o(this._hoveredLevel)||(this.viewModel.enabled&&this._hoveredLevel===this.viewModel.value?this.viewModel.clear():this.viewModel.select(this._hoveredLevel))},this._onPointerEnter=()=>{this._hovering||o(this._levelsContainer)||(this._hovering=!0,this._containerPosTop=this._levelsContainer.getBoundingClientRect().top??0)},this._onPointerLeave=()=>{this._hovering&&(this._normalizedPointerPosition=0,this._hoveredLevel=null,this._hovering=!1)},this._onPointerMove=e=>{if(!this._hovering)return!1;if(window.getSelection().removeAllRanges(),l(this._containerPosTop)){const t=this._containerPosTop,i=m*M,s=this._expandedLevelsMargin;let o=this._levelsHeight,l=t+i+s;const n=this._levelHeight/2;l+=n,o-=n;let r=(e.clientY-l)/o;r+=y,this._normalizedPointerPosition=r}return!1}}postInitialize(){this.own([r((()=>this._levelsContainer),(()=>this._onContainerChange()),a),r((()=>this._levels),(()=>this._createLevelWidgets()),a),r((()=>this.messages),(()=>{this._labelWidget.messages=n(this.messages,H)}),a)])}destroy(){this._levelHandles.destroy(),this._levelEventHandles.destroy(),this._levelWidgets.forEach((e=>e.destroy())),this._labelWidget.destroy()}get _levelsHeight(){return Math.round(this._levelHeight*this._numLevels)}get _expandedLevelsMargin(){return Math.round((this._expandedLevelsHeight-this._levelsHeight)/2)}get _levelWidth(){const{LEVEL_WIDTH_NOMINATOR:e,LEVEL_WIDTH_CONSTANT:t}=b,i=e/Math.sqrt(this._numLevels)+t;return Math.round(s(i,c,p))}get _levelHeight(){const e=P,t=2*e/Math.sqrt(this._numLevels);return Math.round(s(t,2,e))}get _gaussianFactor(){const e=this._numLevels;return e/Math.log(g*e)*u}get _levelClosestToPointer(){if(!this._hovering)return null;const e=this._numLevels-1,t=this._normalizedPointerPosition;return e>=0&&l(t)?this._levels[Math.round((1-t)*e)]:null}render(){const e=this._levelWidgets.length,t=e>1?this._levelWidgets.map((e=>e.render())):null,i=m*M,s=-i/M,o=this._levelsHeight,l=o+2*i;return x("div",{bind:this,key:this,class:this.classes("esri-widget",E.container,{[E.animateLevel]:!this._hovering,[E.noLevel]:e<2}),onkeydown:this._onKeyDown},this._renderLabelContainer(),x("div",{bind:this,class:E.levelsContainer,styles:{height:`${l}px`,marginTop:`${s}px`,marginBottom:`${s}px`},onfocus:this._onFocus,afterCreate:W,"data-node-ref":"_levelsContainer"},x("div",{styles:{height:`${o}px`,margin:m-this._expandedLevelsMargin+"px 0 0 0"},class:E.innerLevelsContainer},t)))}_renderLabelContainer(){const e=n(this.messages,H),t=e.previousLevel,i=e.nextLevel;return x("div",{class:E.labelContainer,tabIndex:0},x("button",{bind:this,class:E.arrowUp,disabled:!this.viewModel.hasNext,onclick:this._onArrowUpClick,"aria-label":i,title:i,type:"button"}),this._labelWidget.render(),x("button",{bind:this,class:E.arrowDown,disabled:!this.viewModel.hasPrevious,onclick:this._onArrowDownClick,"aria-label":t,title:t,type:"button"}))}_updateComponents(){const e=n(this.messages,H),t=this.viewModel.enabled?this.viewModel.value:null,i=l(this._hoveredLevel)?this._hoveredLevel:t;this._levelWidgets.forEach((i=>{const s=this.viewModel.getValueLabel(i.level);i.label=l(s)?s:e.currentLevel?.replace("{{level}}",String(i.level)),i.active=i.level===t,i.hovering=i.level===this._hoveredLevel})),this._labelWidget.level=i,this._labelWidget.active=i===t,this._labelWidget.hovering=l(this._hoveredLevel)}_createLevelWidgets(){this._levelWidgets.forEach((e=>e.destroy())),this._levelWidgets=this._levels.map((e=>new C({level:e,onSelect:()=>this._onLevelToggle(e)}))),this._levelHandles.removeAll(),this._levelHandles.add([r((()=>{const e=this.viewModel;return[this.messages,e?.value,e?.enabled,this._hoveredLevel,this._hovering]}),(()=>this._updateComponents()),a),r((()=>[this._normalizedPointerPosition,this._hovering]),(()=>this._onPointerPositionChange()),a),r((()=>this._levelWidth),(e=>this._levelWidgets.forEach((t=>t.width=e))),a)])}_onContainerChange(){const e=this._levelsContainer;o(e)||(this._levelEventHandles.removeAll(),this._levelEventHandles.add([t(e,"pointerenter",this._onPointerEnter),t(e,"pointerover",this._onPointerEnter),t(e,"pointerleave",this._onPointerLeave),t(e,"pointerup",this._onPointerUp),t(e,"pointermove",this._onPointerMove)]))}_onKeyDown(e){switch(e.key){case"ArrowDown":case"ArrowLeft":e.preventDefault(),e.stopPropagation(),this.viewModel.previous(),this._focusCurrentLevel();break;case"ArrowUp":case"ArrowRight":e.preventDefault(),e.stopPropagation(),this.viewModel.next(),this._focusCurrentLevel()}}_focusCurrentLevel(){const e=this._levelWidgets.find((e=>e.level===this.viewModel.value));e&&e.focus()}_onFocus(){this._hoveredLevel=this._levels.length>0?this._levels[0]:null}_onLevelToggle(e){this.viewModel.enabled&&this.viewModel.value===e?this.viewModel.clear():this.viewModel.select(e)}_onArrowUpClick(){this.viewModel.next()}_onArrowDownClick(){this.viewModel.previous()}_onPointerPositionChange(){let e=0;this._levelWidgets.forEach(((t,i)=>{const{width:s,height:o}=this._getLevelWidgetSize(i);t.height=o,t.width=s,e+=o})),this._hoveredLevel=this._levelClosestToPointer;const t=this._expandedLevelsHeight;(null==t||Math.abs(t-e)>30)&&(this._expandedLevelsHeight=e)}_getLevelWidgetSize(e){const t={width:this._levelWidth,height:this._levelHeight};if(this._hovering){const i=this._getGaussianFactor(e,this._normalizedPointerPosition);t.width+=L*i,t.height+=w*i}return t}_getGaussianFactor(e,t){const i=this._numLevels-1,s=(i-e)/i,o=this._gaussianFactor*(s-t);return Math.exp(-(o**2))}};e([v()],T.prototype,"viewModel",void 0),e([v()],T.prototype,"messages",void 0),e([v()],T.prototype,"_levelWidgets",void 0),e([v()],T.prototype,"_labelWidget",void 0),e([v()],T.prototype,"_hoveredLevel",void 0),e([h("viewModel.allowedValues")],T.prototype,"_levels",void 0),e([h("_levels.length")],T.prototype,"_numLevels",void 0),e([v({readOnly:!0})],T.prototype,"_levelsHeight",null),e([v()],T.prototype,"_expandedLevelsHeight",void 0),e([v({readOnly:!0})],T.prototype,"_expandedLevelsMargin",null),e([v({readOnly:!0})],T.prototype,"_levelWidth",null),e([v({readOnly:!0})],T.prototype,"_levelHeight",null),e([v({readOnly:!0})],T.prototype,"_gaussianFactor",null),e([v({readOnly:!0})],T.prototype,"_levelClosestToPointer",null),e([v({type:Number,range:{min:0,max:1}})],T.prototype,"_normalizedPointerPosition",void 0),e([v()],T.prototype,"_hovering",void 0),e([v()],T.prototype,"_containerPosTop",void 0),e([v()],T.prototype,"_levelsContainer",void 0),T=e([d("esri.widgets.BuildingExplorer.BuildingLevelPicker.BuildingLevelPicker")],T);const k=T;export{k as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{on as t}from"../../../core/events.js";import i from"../../../core/Handles.js";import{clamp as s}from"../../../core/mathUtils.js";import{isNone as o,isSome as l,unwrapOr as n}from"../../../core/maybe.js";import{watch as r,initial as a}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as v}from"../../../core/accessorSupport/decorators/subclass.js";import _ from"../../Widget.js";import{L as d,a as p,A as c,b as g,c as u,d as m,e as L,f as y,g as w,h as b,i as P}from"../../../chunks/constants.js";import{Label as f}from"./Label.js";import{LevelItem as C}from"./LevelItem.js";import{storeNode as W}from"../../support/widgetUtils.js";import{tsx as x}from"../../support/jsxFactory.js";const H={selectLevel:"selectLevel",clearLevel:"clearLevel",nextLevel:"nextLevel",previousLevel:"previousLevel",currentLevel:"{{value}}"},j="esri-building-level-picker",E={container:j,noLevel:`${j}--no-level`,animateLevel:`${j}--animate-level`,levelsContainer:`${j}__levels-container`,innerLevelsContainer:`${j}__inner-levels-container`,labelContainer:`${j}__label-container`,arrowUp:`${j}__arrow-up`,arrowDown:`${j}__arrow-down`};let M=class extends _{constructor(e,t){super(e,t),this._levelHandles=new i,this._levelEventHandles=new i,this._levelWidgets=[],this._labelWidget=new f({onClear:()=>this.vm.clear()}),this._hoveredLevel=null,this._expandedLevelsHeight=void 0,this._normalizedPointerPosition=0,this._hovering=!1,this._containerPosTop=null,this._levelsContainer=null,this._onPointerUp=()=>{if(window.getSelection().removeAllRanges(),o(this._hoveredLevel))return;const{vm:e}=this;e.enabled&&this._hoveredLevel===e.value?e.clear():e.select(this._hoveredLevel)},this._onPointerEnter=()=>{this._hovering||o(this._levelsContainer)||(this._hovering=!0,this._containerPosTop=this._levelsContainer.getBoundingClientRect().top??0)},this._onPointerLeave=()=>{this._hovering&&(this._normalizedPointerPosition=0,this._hoveredLevel=null,this._hovering=!1)},this._onPointerMove=e=>{if(!this._hovering)return!1;if(window.getSelection().removeAllRanges(),l(this._containerPosTop)){const t=this._containerPosTop,i=u*P,s=this._expandedLevelsMargin;let o=this._levelsHeight,l=t+i+s;const n=this._levelHeight/2;l+=n,o-=n;let r=(e.clientY-l)/o;r+=y,this._normalizedPointerPosition=r}return!1}}postInitialize(){this.own([r((()=>this._levelsContainer),(()=>this._onContainerChange()),a),r((()=>this._levels),(()=>this._createLevelWidgets()),a),r((()=>this.messages),(()=>{this._labelWidget.messages=n(this.messages,H)}),a)])}destroy(){this._levelHandles.destroy(),this._levelEventHandles.destroy(),this._levelWidgets.forEach((e=>e.destroy())),this._labelWidget.destroy()}get _levels(){return this.vm.allowedValues}get _numLevels(){return this._levels.length}get _levelsHeight(){return Math.round(this._levelHeight*this._numLevels)}get _expandedLevelsMargin(){return Math.round((this._expandedLevelsHeight-this._levelsHeight)/2)}get _levelWidth(){const{LEVEL_WIDTH_NOMINATOR:e,LEVEL_WIDTH_CONSTANT:t}=w,i=e/Math.sqrt(this._numLevels)+t;return Math.round(s(i,p,d))}get _levelHeight(){const e=b,t=2*e/Math.sqrt(this._numLevels);return Math.round(s(t,2,e))}get _gaussianFactor(){const e=this._numLevels;return e/Math.log(c*e)*g}get _levelClosestToPointer(){if(!this._hovering)return null;const e=this._numLevels-1,t=this._normalizedPointerPosition;return e>=0&&l(t)?this._levels[Math.round((1-t)*e)]:null}render(){const e=this._levelWidgets.length,t=e>1?this._levelWidgets.map((e=>e.render())):null,i=u*P,s=-i/P,o=this._levelsHeight,l=o+2*i;return x("div",{bind:this,key:this,class:this.classes("esri-widget",E.container,{[E.animateLevel]:!this._hovering,[E.noLevel]:e<2}),onkeydown:this._onKeyDown},this._renderLabelContainer(),x("div",{bind:this,class:E.levelsContainer,styles:{height:`${l}px`,marginTop:`${s}px`,marginBottom:`${s}px`},onfocus:this._onFocus,afterCreate:W,"data-node-ref":"_levelsContainer"},x("div",{styles:{height:`${o}px`,margin:u-this._expandedLevelsMargin+"px 0 0 0"},class:E.innerLevelsContainer},t)))}_renderLabelContainer(){const e=n(this.messages,H),t=e.previousLevel,i=e.nextLevel;return x("div",{class:E.labelContainer,tabIndex:0},x("button",{bind:this,class:E.arrowUp,disabled:!this.vm.hasNext,onclick:this._onArrowUpClick,"aria-label":i,title:i,type:"button"}),this._labelWidget.render(),x("button",{bind:this,class:E.arrowDown,disabled:!this.vm.hasPrevious,onclick:this._onArrowDownClick,"aria-label":t,title:t,type:"button"}))}_updateComponents(){const e=n(this.messages,H),t=this.vm.enabled?this.vm.value:null,i=l(this._hoveredLevel)?this._hoveredLevel:t;this._levelWidgets.forEach((i=>{const s=this.vm.getValueLabel(i.level);i.label=l(s)?s:e.currentLevel?.replace("{{level}}",String(i.level)),i.active=i.level===t,i.hovering=i.level===this._hoveredLevel})),this._labelWidget.level=i,this._labelWidget.active=i===t,this._labelWidget.hovering=l(this._hoveredLevel)}_createLevelWidgets(){this._levelWidgets.forEach((e=>e.destroy())),this._levelWidgets=this._levels.map((e=>new C({level:e,onSelect:()=>this._onLevelToggle(e)}))),this._levelHandles.removeAll(),this._levelHandles.add([r((()=>{const{vm:e}=this;return[this.messages,e?.value,e?.enabled,this._hoveredLevel,this._hovering]}),(()=>this._updateComponents()),a),r((()=>[this._normalizedPointerPosition,this._hovering]),(()=>this._onPointerPositionChange()),a),r((()=>this._levelWidth),(e=>this._levelWidgets.forEach((t=>t.width=e))),a)])}_onContainerChange(){const e=this._levelsContainer;o(e)||(this._levelEventHandles.removeAll(),this._levelEventHandles.add([t(e,"pointerenter",this._onPointerEnter),t(e,"pointerover",this._onPointerEnter),t(e,"pointerleave",this._onPointerLeave),t(e,"pointerup",this._onPointerUp),t(e,"pointermove",this._onPointerMove)]))}_onKeyDown(e){switch(e.key){case"ArrowDown":case"ArrowLeft":e.preventDefault(),e.stopPropagation(),this.vm.previous(),this._focusCurrentLevel();break;case"ArrowUp":case"ArrowRight":e.preventDefault(),e.stopPropagation(),this.vm.next(),this._focusCurrentLevel()}}_focusCurrentLevel(){const e=this._levelWidgets.find((e=>e.level===this.vm.value));e&&e.focus()}_onFocus(){this._hoveredLevel=this._levels.length>0?this._levels[0]:null}_onLevelToggle(e){const{vm:t}=this;t.enabled&&t.value===e?t.clear():t.select(e)}_onArrowUpClick(){this.vm.next()}_onArrowDownClick(){this.vm.previous()}_onPointerPositionChange(){let e=0;this._levelWidgets.forEach(((t,i)=>{const{width:s,height:o}=this._getLevelWidgetSize(i);t.height=o,t.width=s,e+=o})),this._hoveredLevel=this._levelClosestToPointer;const t=this._expandedLevelsHeight;(null==t||Math.abs(t-e)>30)&&(this._expandedLevelsHeight=e)}_getLevelWidgetSize(e){const t={width:this._levelWidth,height:this._levelHeight};if(this._hovering){const i=this._getGaussianFactor(e,this._normalizedPointerPosition);t.width+=m*i,t.height+=L*i}return t}_getGaussianFactor(e,t){const i=this._numLevels-1,s=(i-e)/i,o=this._gaussianFactor*(s-t);return Math.exp(-(o**2))}};e([h()],M.prototype,"vm",void 0),e([h()],M.prototype,"messages",void 0),e([h()],M.prototype,"_levelWidgets",void 0),e([h()],M.prototype,"_labelWidget",void 0),e([h()],M.prototype,"_hoveredLevel",void 0),e([h()],M.prototype,"_levels",null),e([h()],M.prototype,"_numLevels",null),e([h({readOnly:!0})],M.prototype,"_levelsHeight",null),e([h()],M.prototype,"_expandedLevelsHeight",void 0),e([h({readOnly:!0})],M.prototype,"_expandedLevelsMargin",null),e([h({readOnly:!0})],M.prototype,"_levelWidth",null),e([h({readOnly:!0})],M.prototype,"_levelHeight",null),e([h({readOnly:!0})],M.prototype,"_gaussianFactor",null),e([h({readOnly:!0})],M.prototype,"_levelClosestToPointer",null),e([h({type:Number,range:{min:0,max:1}})],M.prototype,"_normalizedPointerPosition",void 0),e([h()],M.prototype,"_hovering",void 0),e([h()],M.prototype,"_containerPosTop",void 0),e([h()],M.prototype,"_levelsContainer",void 0),M=e([v("esri.widgets.BuildingExplorer.BuildingLevelPicker.BuildingLevelPicker")],M);const T=M;export{T 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.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{isNone as s,unwrapOr as t,unwrap as r,isSome as o}from"../../../core/maybe.js";import{watch as i,initial as a}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import c from"../../Widget.js";import{isRTL as l}from"../../support/widgetUtils.js";import{tsx as u}from"../../support/jsxFactory.js";const p={nextPhase:"nextPhase",previousPhase:"previousPhase",currentPhase:"{{value}}"},d="esri-building-phase-picker",_={container:`${d}`,phasesContainer:`${d}__phases-container`,phase:`${d}__phase`,phaseActive:`${d}__phase--active`,phaseCurrent:`${d}__phase--current`,divider:`${d}__divider`,dividerActive:`${d}__divider--active`,arrowLeft:`${d}__arrow-left`,arrowRight:`${d}__arrow-right`};let v=class extends c{constructor(e,t){super(e,t),this._phasesContainer=null,this._shouldScrollCurrentPhaseIntoView=!0,this._shouldFocusCurrentPhase=!1,this._onKeyDown=e=>{const{viewModel:s}=this;switch(e.key){case"ArrowDown":case"ArrowLeft":e.stopPropagation(),e.preventDefault(),s.previous(),this._shouldFocusCurrentPhase=!0;break;case"ArrowUp":case"ArrowRight":e.stopPropagation(),e.preventDefault(),s.next(),this._shouldFocusCurrentPhase=!0}},this._onArrowLeftClick=()=>{this.viewModel.previous()},this._onArrowRightClick=()=>{this.viewModel.next()},this._onPhasesContainerAfterCreate=e=>{this._phasesContainer=e,requestAnimationFrame(this._scrollOrFocusPhase)},this._scrollOrFocusPhase=()=>{const e=this._phasesContainer;if(this.destroyed||s(e))return;const t=e.querySelector(`.${_.phaseCurrent}`);if(t){if(this._shouldScrollCurrentPhaseIntoView){const s=e.offsetWidth,r=t.offsetLeft,o=t.offsetWidth;e.scrollLeft=-s/2+r-o/2,this._shouldScrollCurrentPhaseIntoView=!1}this._shouldFocusCurrentPhase&&(t.focus(),this._shouldFocusCurrentPhase=!1)}}}initialize(){this.own([i((()=>[this._currentPhase,this._phasesContainer,this.container]),(()=>{this._shouldScrollCurrentPhaseIntoView=!0,requestAnimationFrame(this._scrollOrFocusPhase)}),a)])}get _phases(){return this.viewModel.allowedValues}get _currentPhase(){const{viewModel:e}=this;return e.enabled?e.value:null}render(){if(this._phases.length<2)return u("div",{key:"no-phases"});const{viewModel:e,container:s,messages:r}=this,{previousPhase:o,nextPhase:i}=t(r,p),a=l(s);return u("div",{class:this.classes("esri-widget",_.container),key:this,onkeydown:this._onKeyDown},u("button",{type:"button",class:a?_.arrowRight:_.arrowLeft,disabled:!e.hasPrevious,"aria-label":o,title:o,onclick:this._onArrowLeftClick}),u("div",{class:_.phasesContainer,afterCreate:this._onPhasesContainerAfterCreate},this._renderPhaseButtons()),u("button",{type:"button",class:a?_.arrowLeft:_.arrowRight,disabled:!e.hasNext,"aria-label":i,title:i,onclick:this._onArrowRightClick}))}_renderPhaseButtons(){const e=this._phases,s=this._currentPhase,t=[];for(let r=0;r<e.length;++r){const i=e[r],a={phase:i,active:!!o(s)&&i<=s,current:!!o(s)&&i===s};r>0&&t.push(this._renderDivider(a)),t.push(this._renderPhaseButton(a))}return t}_renderPhaseButton({phase:e,active:s,current:t}){const{viewModel:o}=this,i=r(o.getValueLabel(e));return u("button",{key:`phase-${e}`,class:this.classes(_.phase,{[_.phaseActive]:s,[_.phaseCurrent]:t}),"aria-label":i,title:i,onclick:()=>o.select(e),type:"button"},e)}_renderDivider({phase:e,active:s}){return u("div",{key:`phase-divider-${e}`,class:this.classes(_.divider,{[_.dividerActive]:s})})}};e([n({nonNullable:!0})],v.prototype,"viewModel",void 0),e([n()],v.prototype,"messages",void 0),e([n()],v.prototype,"_phases",null),e([n()],v.prototype,"_currentPhase",null),e([n()],v.prototype,"_phasesContainer",void 0),v=e([h("esri.widgets.BuildingExplorer.BuildingPhasePicker.BuildingPhasePicker")],v);const w=v;export{w as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{isNone as s,unwrapOr as t,unwrap as r,isSome as o}from"../../../core/maybe.js";import{watch as i,initial as a}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import c from"../../Widget.js";import{isRTL as l}from"../../support/widgetUtils.js";import{tsx as u}from"../../support/jsxFactory.js";const p={nextPhase:"nextPhase",previousPhase:"previousPhase",currentPhase:"{{value}}"},d="esri-building-phase-picker",_={container:`${d}`,phasesContainer:`${d}__phases-container`,phase:`${d}__phase`,phaseActive:`${d}__phase--active`,phaseCurrent:`${d}__phase--current`,divider:`${d}__divider`,dividerActive:`${d}__divider--active`,arrowLeft:`${d}__arrow-left`,arrowRight:`${d}__arrow-right`};let v=class extends c{constructor(e,t){super(e,t),this._phasesContainer=null,this._shouldScrollCurrentPhaseIntoView=!0,this._shouldFocusCurrentPhase=!1,this._onKeyDown=e=>{const{vm:s}=this;switch(e.key){case"ArrowDown":case"ArrowLeft":e.stopPropagation(),e.preventDefault(),s.previous(),this._shouldFocusCurrentPhase=!0;break;case"ArrowUp":case"ArrowRight":e.stopPropagation(),e.preventDefault(),s.next(),this._shouldFocusCurrentPhase=!0}},this._onArrowLeftClick=()=>{this.vm.previous()},this._onArrowRightClick=()=>{this.vm.next()},this._onPhasesContainerAfterCreate=e=>{this._phasesContainer=e,requestAnimationFrame(this._scrollOrFocusPhase)},this._scrollOrFocusPhase=()=>{const e=this._phasesContainer;if(this.destroyed||s(e))return;const t=e.querySelector(`.${_.phaseCurrent}`);if(t){if(this._shouldScrollCurrentPhaseIntoView){const s=e.offsetWidth,r=t.offsetLeft,o=t.offsetWidth;e.scrollLeft=-s/2+r-o/2,this._shouldScrollCurrentPhaseIntoView=!1}this._shouldFocusCurrentPhase&&(t.focus(),this._shouldFocusCurrentPhase=!1)}}}initialize(){this.own([i((()=>[this._currentPhase,this._phasesContainer,this.container]),(()=>{this._shouldScrollCurrentPhaseIntoView=!0,requestAnimationFrame(this._scrollOrFocusPhase)}),a)])}get _phases(){return this.vm.allowedValues}get _currentPhase(){const{vm:e}=this;return e.enabled?e.value:null}render(){if(this._phases.length<2)return u("div",{key:"no-phases"});const{vm:e,container:s,messages:r}=this,{previousPhase:o,nextPhase:i}=t(r,p),a=l(s);return u("div",{class:this.classes("esri-widget",_.container),key:this,onkeydown:this._onKeyDown},u("button",{type:"button",class:a?_.arrowRight:_.arrowLeft,disabled:!e.hasPrevious,"aria-label":o,title:o,onclick:this._onArrowLeftClick}),u("div",{class:_.phasesContainer,afterCreate:this._onPhasesContainerAfterCreate},this._renderPhaseButtons()),u("button",{type:"button",class:a?_.arrowLeft:_.arrowRight,disabled:!e.hasNext,"aria-label":i,title:i,onclick:this._onArrowRightClick}))}_renderPhaseButtons(){const e=this._phases,s=this._currentPhase,t=[];for(let r=0;r<e.length;++r){const i=e[r],a={phase:i,active:!!o(s)&&i<=s,current:!!o(s)&&i===s};r>0&&t.push(this._renderDivider(a)),t.push(this._renderPhaseButton(a))}return t}_renderPhaseButton({phase:e,active:s,current:t}){const{vm:o}=this,i=r(o.getValueLabel(e));return u("button",{key:`phase-${e}`,class:this.classes(_.phase,{[_.phaseActive]:s,[_.phaseCurrent]:t}),"aria-label":i,title:i,onclick:()=>o.select(e),type:"button"},e)}_renderDivider({phase:e,active:s}){return u("div",{key:`phase-divider-${e}`,class:this.classes(_.divider,{[_.dividerActive]:s})})}};e([n({nonNullable:!0})],v.prototype,"vm",void 0),e([n()],v.prototype,"messages",void 0),e([n()],v.prototype,"_phases",null),e([n()],v.prototype,"_currentPhase",null),e([n()],v.prototype,"_phasesContainer",void 0),v=e([h("esri.widgets.BuildingExplorer.BuildingPhasePicker.BuildingPhasePicker")],v);const P=v;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.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{aliasOf as i}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as s}from"../core/accessorSupport/decorators/cast.js";import{property as t}from"../core/accessorSupport/decorators/property.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import o from"./Widget.js";import l from"./BuildingExplorer/BuildingExplorerViewModel.js";import n from"./BuildingExplorer/BuildingDisciplinesTree/BuildingDisciplinesTree.js";import a from"./BuildingExplorer/BuildingLevelPicker/BuildingLevelPicker.js";import d from"./BuildingExplorer/BuildingPhasePicker/BuildingPhasePicker.js";import{Heading as p}from"./support/Heading.js";import{classes as c}from"./support/widgetUtils.js";import{messageBundle as g}from"./support/decorators/messageBundle.js";import{tsx as u}from"./support/jsxFactory.js";const h={levels:!0,phases:!0,disciplines:!0},m="esri-building-explorer",v={esriWidget:"esri-widget",esriWidgetDisabled:"esri-widget--disabled",esriIconLoadingIndicator:"esri-icon-loading-indicator",esriRotating:"esri-rotating",widgetIcon:"esri-icon-organization",base:`${m} esri-widget--panel`,panelError:`${m}__panel--error`,loadingContainer:`${m}__loading-container`,content:`${m}__content`,section:`${m}__section`,levels:`${m}__levels`,phases:`${m}__phases`,disciplines:`${m}__disciplines`};let y=class extends o{constructor(e,i){super(e,i),this._defaultViewModel=new l,this.viewModel=this._defaultViewModel,this.view=null,this.layers=null,this.visibleElements={...h},this.headingLevel=3,this.iconClass=v.widgetIcon,this.label=void 0,this.messages=null,this.messagesCommon=null,this.toggleSiblingsVisibility=!1}destroy(){this.viewModel!==this._defaultViewModel&&this._defaultViewModel.destroy()}_castVisibleElements(e){return{...h,...e}}render(){const e=this.viewModel,i="disabled"===e.state||!e.isSupported;return u("div",{key:this,class:c(v.esriWidget,v.base,{[v.esriWidgetDisabled]:i}),"aria-label":this.messages.widgetLabel},this._renderContent())}_renderContent(){const e=this.viewModel,i=this.messages;if(!e.isSupported)return u("p",{class:v.panelError},i.unsupported);if(!e.layers.length)return u("p",{class:v.panelError},i.noData);switch(e.state){case"loading":return this._renderLoadingIndicator();case"ready":return u("div",{key:"content",class:v.content},this._renderLevelPickerSection(),this._renderPhasePickerSection(),this._renderDisciplinesSection());case"failed":return u("p",{class:v.panelError},i.failed);default:return null}}_renderLoadingIndicator(){const e=this.messagesCommon.loading;return u("div",{key:"loading-container",role:"presentation",class:v.loadingContainer,"aria-label":e,title:e},u("span",{"aria-hidden":"true",class:c(v.esriIconLoadingIndicator,v.esriRotating)}))}_renderLevelPickerSection(){const e=this.viewModel.level,i="ready"===e.state,s=e.allowedValues.length>1;if(!this.visibleElements.levels||!i||!s)return null;const t=this.messages?.level;return u("div",{key:"levels",class:c(v.section,v.levels)},u(p,{level:this.headingLevel},t?.title),u(a,{viewModel:e,messages:t}))}_renderPhasePickerSection(){const e=this.viewModel.phase,i="ready"===e.state,s=e.allowedValues.length>1;if(!this.visibleElements.phases||!i||!s)return null;const t=this.messages.phase;return u("div",{key:"phases",class:c(v.section,v.phases)},u(p,{level:this.headingLevel},t.title),u(d,{viewModel:e,messages:t}))}_renderDisciplinesSection(){const e=this.viewModel.disciplines,i="ready"===e.state,s=e.root.hasChildren;if(!this.visibleElements.disciplines||!i||!s)return null;const t=this.messages?.disciplines;return u("div",{key:"disciplines",class:c(v.section,v.disciplines)},u(p,{level:this.headingLevel},t.title),u(n,{viewModel:e,messages:t,toggleSiblingsVisibility:this.toggleSiblingsVisibility}))}};e([t({type:l})],y.prototype,"viewModel",void 0),e([i("viewModel.view")],y.prototype,"view",void 0),e([i("viewModel.layers")],y.prototype,"layers",void 0),e([t()],y.prototype,"visibleElements",void 0),e([s("visibleElements")],y.prototype,"_castVisibleElements",null),e([t()],y.prototype,"headingLevel",void 0),e([t()],y.prototype,"iconClass",void 0),e([i("messages.widgetLabel",{overridable:!0})],y.prototype,"label",void 0),e([t(),g("esri/widgets/BuildingExplorer/t9n/BuildingExplorer")],y.prototype,"messages",void 0),e([t(),g("esri/t9n/common")],y.prototype,"messagesCommon",void 0),e([t({nonNullable:!0})],y.prototype,"toggleSiblingsVisibility",void 0),e([t()],y.prototype,"uiStrings",void 0),y=e([r("esri.widgets.BuildingExplorer")],y);const w=y;export{w as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{aliasOf as i}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as s}from"../core/accessorSupport/decorators/cast.js";import{property as t}from"../core/accessorSupport/decorators/property.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import o from"./Widget.js";import l from"./BuildingExplorer/BuildingExplorerViewModel.js";import n from"./BuildingExplorer/BuildingDisciplinesTree/BuildingDisciplinesTree.js";import a from"./BuildingExplorer/BuildingLevelPicker/BuildingLevelPicker.js";import d from"./BuildingExplorer/BuildingPhasePicker/BuildingPhasePicker.js";import{Heading as p}from"./support/Heading.js";import{classes as c}from"./support/widgetUtils.js";import{messageBundle as g}from"./support/decorators/messageBundle.js";import{tsx as u}from"./support/jsxFactory.js";const h={levels:!0,phases:!0,disciplines:!0},m="esri-building-explorer",v={esriWidget:"esri-widget",esriWidgetDisabled:"esri-widget--disabled",esriIconLoadingIndicator:"esri-icon-loading-indicator",esriRotating:"esri-rotating",widgetIcon:"esri-icon-organization",base:`${m} esri-widget--panel`,panelError:`${m}__panel--error`,loadingContainer:`${m}__loading-container`,content:`${m}__content`,section:`${m}__section`,levels:`${m}__levels`,phases:`${m}__phases`,disciplines:`${m}__disciplines`};let y=class extends o{constructor(e,i){super(e,i),this._defaultViewModel=new l,this.viewModel=this._defaultViewModel,this.view=null,this.layers=null,this.visibleElements={...h},this.headingLevel=3,this.iconClass=v.widgetIcon,this.label=void 0,this.messages=null,this.messagesCommon=null,this.toggleSiblingsVisibility=!1}destroy(){this.viewModel!==this._defaultViewModel&&this._defaultViewModel.destroy()}_castVisibleElements(e){return{...h,...e}}render(){const e=this.viewModel,i="disabled"===e.state||!e.isSupported;return u("div",{key:this,class:c(v.esriWidget,v.base,{[v.esriWidgetDisabled]:i}),"aria-label":this.messages.widgetLabel},this._renderContent())}_renderContent(){const e=this.viewModel,i=this.messages;if(!e.isSupported)return u("p",{class:v.panelError},i.unsupported);if(!e.layers.length)return u("p",{class:v.panelError},i.noData);switch(e.state){case"loading":return this._renderLoadingIndicator();case"ready":return u("div",{key:"content",class:v.content},this._renderLevelPickerSection(),this._renderPhasePickerSection(),this._renderDisciplinesSection());case"failed":return u("p",{class:v.panelError},i.failed);default:return null}}_renderLoadingIndicator(){const e=this.messagesCommon.loading;return u("div",{key:"loading-container",role:"presentation",class:v.loadingContainer,"aria-label":e,title:e},u("span",{"aria-hidden":"true",class:c(v.esriIconLoadingIndicator,v.esriRotating)}))}_renderLevelPickerSection(){const e=this.viewModel.level,i="ready"===e.state,s=e.allowedValues.length>1;if(!this.visibleElements.levels||!i||!s)return null;const t=this.messages?.level;return u("div",{key:"levels",class:c(v.section,v.levels)},u(p,{level:this.headingLevel},t?.title),u(a,{vm:e,messages:t}))}_renderPhasePickerSection(){const e=this.viewModel.phase,i="ready"===e.state,s=e.allowedValues.length>1;if(!this.visibleElements.phases||!i||!s)return null;const t=this.messages.phase;return u("div",{key:"phases",class:c(v.section,v.phases)},u(p,{level:this.headingLevel},t.title),u(d,{vm:e,messages:t}))}_renderDisciplinesSection(){const e=this.viewModel.disciplines,i="ready"===e.state,s=e.root.hasChildren;if(!this.visibleElements.disciplines||!i||!s)return null;const t=this.messages?.disciplines;return u("div",{key:"disciplines",class:c(v.section,v.disciplines)},u(p,{level:this.headingLevel},t.title),u(n,{vm:e,messages:t,toggleSiblingsVisibility:this.toggleSiblingsVisibility}))}};e([t({type:l})],y.prototype,"viewModel",void 0),e([i("viewModel.view")],y.prototype,"view",void 0),e([i("viewModel.layers")],y.prototype,"layers",void 0),e([t()],y.prototype,"visibleElements",void 0),e([s("visibleElements")],y.prototype,"_castVisibleElements",null),e([t()],y.prototype,"headingLevel",void 0),e([t()],y.prototype,"iconClass",void 0),e([i("messages.widgetLabel",{overridable:!0})],y.prototype,"label",void 0),e([t(),g("esri/widgets/BuildingExplorer/t9n/BuildingExplorer")],y.prototype,"messages",void 0),e([t(),g("esri/t9n/common")],y.prototype,"messagesCommon",void 0),e([t({nonNullable:!0})],y.prototype,"toggleSiblingsVisibility",void 0),e([t()],y.prototype,"uiStrings",void 0),y=e([r("esri.widgets.BuildingExplorer")],y);const b=y;export{b 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.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import{HandleOwner as i}from"../../core/HandleOwner.js";import{applySome as e,isNone as s,isSome as n,unwrapOr as a}from"../../core/maybe.js";import{when as l,initial as o,watch as r,on as h}from"../../core/reactiveUtils.js";import{schedule as g}from"../../core/scheduling.js";import{truncateLocalTime as d,resetUTCDate as p,offsetDate as u}from"../../core/timeUtils.js";import{property as y}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import m from"../../views/SceneView.js";import _ from"../../views/3d/environment/SunLighting.js";import f from"../../views/3d/environment/VirtualLighting.js";import{positionToTimezoneInfo as w}from"../../views/3d/support/earthUtils.js";import{dateTimeToSliderPos as D,sliderPosToDateTime as S,getSeasonFromDate as T,getNorthernHemisphereSeason as v,getSeasonDate as U,Hemisphere as L,calculatePlaySpeed as P}from"./support/daylightUtils.js";import{SliderWithDropdownViewModel as b}from"./support/SliderWithDropdownViewModel.js";import O from"../support/DatePickerViewModel.js";import{getSunriseAndSunsetTimes as C}from"../support/timeWidgetUtils.js";let E=class extends i{constructor(t){super(t),this.view=null,this.datePickerViewModel=new O,this.timeSliderViewModel=new b,this.lightingUpdateInterval=200,this._oldLighting=null,this.playSpeedMultiplier=1,this._cachedLightingDateUTC=new Date(0),this._cachedDisplayUTCOffset=0,this._firstInteraction=!0,this._lastLightingUpdate=0,this._nextLightingUpdate=null}initialize(){this.handles.add([l((()=>this.view),(t=>t.when((()=>this._updateLighting(null)))),o),r((()=>e(this._lighting,(t=>"sun"===t.type?t.date:null))),(t=>this._scheduleUpdateLighting(t))),h((()=>this._lighting),"timezone-will-change",(t=>this._timezoneWillChange(t)),{onListenerAdd:()=>this._timezoneWillChange(null)}),r((()=>!0===e(this.view,(t=>t.stationary))),(()=>{(this.dayPlaying||this.yearPlaying)&&this._updateSunriseAndSunset()}),o),r((()=>{const t=this.timeSliderViewModel;return{vm:t,state:t.state,sliderPosition:this.timeSliderPosition}}),(({vm:t,state:i,sliderPosition:e})=>{"ready"===i&&t.setValue(0,e)})),r((()=>this.timeSliderViewModel.currentItem?.utcOffset),(t=>this.utcOffset=t)),r((()=>this.timeSliderViewModel.isDropdownOpen),(()=>this.stopPlaying())),r((()=>this.timeSliderViewModel.values),(t=>this.timeSliderPosition=t[0])),r((()=>this.datePickerViewModel.value),(t=>{this.dayPlaying=!1,this.localDate=t})),r((()=>this.localDate),(t=>{this.datePickerViewModel.value.valueOf()!==t.getTime()&&this.datePickerViewModel.set("value",t)}))])}destroy(){this._nextLightingUpdate&&(clearTimeout(this._nextLightingUpdate),this._nextLightingUpdate=null),this.view=null}get isSupported(){return s(this.view)||"3d"===this.view.type}get utcOffset(){return this._cachedDisplayUTCOffset}set utcOffset(t){t!==this.utcOffset&&n(this._lighting)&&"sun"===this._lighting.type&&(this._lighting.displayUTCOffset=t,this._updateLighting(null))}get localDate(){return d(this._lightingDateDisplay)}set localDate(t){t.getTime()!==this.localDate.getTime()&&(this._lightingDateDisplay=p(this._lightingDateDisplay,t))}get timeSliderPosition(){return D(this._lightingDateDisplay)}set timeSliderPosition(t){Math.abs(t-this.timeSliderPosition)>1/60&&(this._lightingDateDisplay=S(this._lightingDateDisplay,t),this.stopPlaying(),this._enableDirectShadowsIfFirstInteraction())}_timezoneFromCamera(t,i){if(s(i)||!t.cameraTrackingEnabled)return 0;const e=w([i.longitude,i.latitude]);return s(e)?0:Math.round(e.hours+e.minutes/60+e.seconds/3600)}get directShadowsEnabled(){const t=e(this._lighting,(t=>t.directShadowsEnabled));return a(t,!1)}set directShadowsEnabled(t){e(this._lighting,(i=>{i.directShadowsEnabled=t}))}get sunLightingEnabled(){return"sun"===this._lightingType}set sunLightingEnabled(t){const i=this._environment;if(t===this._get("sunLightingEnabled")||s(i))return;const e=this.directShadowsEnabled,a=t?"sun":"virtual",l=this._oldLighting;let o;this._oldLighting=i.lighting,o=n(l)&&l.type===a?l:t?new _:new f,o.directShadowsEnabled=e,i.lighting=o,t||(this.timeSliderViewModel.isDropdownOpen=!1)}set playingState(t){this.playingState!==t&&this.sunLightingEnabled&&(this._set("playingState",t),"none"!==t&&(this._updateSunriseAndSunset(),this._lastTime=Date.now(),this._play(),this._enableDirectShadowsIfFirstInteraction()))}get dayPlaying(){return"day"===this.playingState}set dayPlaying(t){t?this.playingState="day":this.dayPlaying&&(this.playingState="none")}get yearPlaying(){return"year"===this.playingState}set yearPlaying(t){t?this.playingState="year":this.yearPlaying&&(this.playingState="none")}get currentSeason(){return T(this.localDate,this._currentHemisphere)}set currentSeason(t){this.stopPlaying();const i=v(t,this._currentHemisphere);this.localDate=U(this.localDate,i,L.NORTHERN)}get _currentHemisphere(){const t=e(this.view,(t=>t.camera?.position));return s(t)||t.latitude>=0?L.NORTHERN:L.SOUTHERN}get _environment(){return e(this.view,(t=>t.environment))}get _lighting(){return e(this._environment,(t=>t.lighting))}get _lightingType(){return e(this._lighting,(t=>t.type))}get _lightingDateDisplay(){return u(this._cachedLightingDateUTC,this._cachedDisplayUTCOffset,"hours")}set _lightingDateDisplay(t){const i=this._lighting;if(s(i)||!this.sunLightingEnabled||"sun"!==i.type)return;const e=u(t,-this._cachedDisplayUTCOffset,"hours");e.getTime()!==i.date.getTime()&&(i.date=e,this._updateLighting(null))}stopPlaying(){this.playingState="none"}toggleDayPlaying(){this.dayPlaying=!this.dayPlaying}toggleYearPlaying(){this.yearPlaying=!this.yearPlaying}toggleSunLightingEnabled(){this.stopPlaying(),this.sunLightingEnabled=!this.sunLightingEnabled}toggleDirectShadowsEnabled(){this.stopPlaying(),this.directShadowsEnabled=!this.directShadowsEnabled}_enableDirectShadowsIfFirstInteraction(){this._firstInteraction&&(this._firstInteraction=!1,this.directShadowsEnabled=!0)}_updateLighting(t){const i=Date.now();this._lastLightingUpdate=i;const{view:e}=this,n=this._lighting;if(s(e)||s(n)||"sun"!==n.type)return;const a=t||n.date,l=n.displayUTCOffset,o=null!==l?l:this._timezoneFromCamera(n,e.camera?.position);this._cachedLightingDateUTC.getTime()!==a.getTime()&&(this._cachedLightingDateUTC=new Date(a.getTime())),this._cachedDisplayUTCOffset!==o&&(this._cachedDisplayUTCOffset=o)}_timezoneWillChange(t){const i=this._lighting;if(s(i)||"sun"!==i.type||!i.cameraTrackingEnabled)return;let e;if(t)e=t.timezoneOffset;else{if(null!=i.displayUTCOffset)return;e=_.calculateTimezoneOffset(i.positionTimezoneInfo)}i.displayUTCOffset=e,this._scheduleUpdateLighting(null)}_scheduleUpdateLighting(t){if(this._nextLightingUpdate||s(t))return;const i=Date.now()-this._lastLightingUpdate,e=this.lightingUpdateInterval-i;e<=0?g((()=>this._updateLighting(t))):this._nextLightingUpdate=setTimeout((()=>{this._updateLighting(null),this._nextLightingUpdate=null}),e)}_play(){const t=this._lighting;if(!s(t)&&this.sunLightingEnabled&&"sun"===t.type&&(this.dayPlaying||this.yearPlaying)){const i=Date.now()-this._lastTime;if(this.dayPlaying){this._lastTime=Date.now();const e=P(this._sunrise,this._sunset,t.date)*this.playSpeedMultiplier/100*i;if(e>0){let i=new Date(t.date.getTime()+e);if(((i.getUTCHours()+t.displayUTCOffset)%24+24)%24<((t.date.getUTCHours()+t.displayUTCOffset)%24+24)%24){const s=864e5;i=new Date(t.date.getTime()+e-s)}t.date=i}}else{if(i>1e3){this._lastTime=Date.now();const i=(t.date.getUTCMonth()+1)%12,e=new Date(t.date.getTime());e.setUTCMonth(i),t.date=e}}requestAnimationFrame((()=>this._play()))}}_updateSunriseAndSunset(){const t=this._lighting;if(s(t)||"sun"!==t.type||!this.sunLightingEnabled)return;const i=e(this.view,(t=>t.camera?.position));if(s(i))return;const n=C(t.date,i.latitude,i.longitude,t.displayUTCOffset);this._sunrise=new Date(n.sunrise),this._sunset=new Date(n.sunset)}};t([y({type:m})],E.prototype,"view",void 0),t([y({type:O,nonNullable:!0})],E.prototype,"datePickerViewModel",void 0),t([y({type:b,nonNullable:!0})],E.prototype,"timeSliderViewModel",void 0),t([y()],E.prototype,"isSupported",null),t([y()],E.prototype,"lightingUpdateInterval",void 0),t([y()],E.prototype,"utcOffset",null),t([y()],E.prototype,"localDate",null),t([y()],E.prototype,"timeSliderPosition",null),t([y()],E.prototype,"directShadowsEnabled",null),t([y()],E.prototype,"sunLightingEnabled",null),t([y({type:["none","day","year"],value:"none"})],E.prototype,"playingState",null),t([y()],E.prototype,"dayPlaying",null),t([y()],E.prototype,"yearPlaying",null),t([y()],E.prototype,"playSpeedMultiplier",void 0),t([y()],E.prototype,"currentSeason",null),t([y()],E.prototype,"_lastTime",void 0),t([y()],E.prototype,"_sunrise",void 0),t([y()],E.prototype,"_sunset",void 0),t([y()],E.prototype,"_cachedLightingDateUTC",void 0),t([y()],E.prototype,"_cachedDisplayUTCOffset",void 0),t([y()],E.prototype,"_firstInteraction",void 0),t([y()],E.prototype,"_currentHemisphere",null),t([y()],E.prototype,"_environment",null),t([y()],E.prototype,"_lighting",null),t([y()],E.prototype,"_lightingType",null),t([y()],E.prototype,"_lightingDateDisplay",null),E=t([c("esri.widgets.Daylight.DaylightViewModel")],E);const M=E;export{M as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{HandleOwner as e}from"../../core/HandleOwner.js";import{applySome as i,isNone as s,isSome as n,unwrapOr as a}from"../../core/maybe.js";import{when as l,initial as o,watch as r,on as h}from"../../core/reactiveUtils.js";import{schedule as g}from"../../core/scheduling.js";import{truncateLocalTime as d,resetUTCDate as p,offsetDate as u}from"../../core/timeUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import m from"../../views/SceneView.js";import _ from"../../views/3d/environment/SunLighting.js";import f from"../../views/3d/environment/VirtualLighting.js";import{positionToTimezoneInfo as w}from"../../views/3d/support/earthUtils.js";import{dateTimeToSliderPos as D,sliderPosToDateTime as S,getSeasonFromDate as T,getNorthernHemisphereSeason as v,getSeasonDate as U,Hemisphere as L,calculatePlaySpeed as P}from"./support/daylightUtils.js";import{SliderWithDropdownViewModel as b}from"./support/SliderWithDropdownViewModel.js";import E from"../support/DatePickerViewModel.js";import{getSunriseAndSunsetTimes as O}from"../support/timeWidgetUtils.js";let C=class extends e{constructor(t){super(t),this.view=null,this.datePickerViewModel=new E,this.timeSliderViewModel=new b,this.lightingUpdateInterval=200,this._oldLighting=null,this.playSpeedMultiplier=1,this._cachedLightingDateUTC=new Date(0),this._cachedDisplayUTCOffset=0,this._firstInteraction=!0,this._lastLightingUpdate=0,this._nextLightingUpdate=null}initialize(){this.handles.add([l((()=>this.view),(t=>t.when((()=>this._updateLighting(null)))),o),r((()=>i(this._lighting,(t=>"sun"===t.type?t.date:null))),(t=>this._scheduleUpdateLighting(t))),h((()=>this._lighting),"timezone-will-change",(t=>this._timezoneWillChange(t)),{onListenerAdd:()=>this._timezoneWillChange(null)}),r((()=>!0===i(this.view,(t=>t.stationary))),(()=>{(this.dayPlaying||this.yearPlaying)&&this._updateSunriseAndSunset()}),o),r((()=>{const t=this.timeSliderViewModel;return{vm:t,state:t.state,sliderPosition:this.timeSliderPosition}}),(({vm:t,state:e,sliderPosition:i})=>{"ready"===e&&t.setValue(0,i)})),r((()=>this.timeSliderViewModel.currentItem?.utcOffset),(t=>this.utcOffset=t)),r((()=>this.timeSliderViewModel.isDropdownOpen),(()=>this.stopPlaying())),r((()=>this.timeSliderViewModel.values),(t=>this.timeSliderPosition=t[0])),r((()=>this.datePickerViewModel.value),(t=>{this.dayPlaying=!1,this.localDate=t})),r((()=>this.localDate),(t=>{this.datePickerViewModel.value.valueOf()!==t.getTime()&&this.datePickerViewModel.set("value",t)}))])}destroy(){this._nextLightingUpdate&&(clearTimeout(this._nextLightingUpdate),this._nextLightingUpdate=null),this.view=null}get isSupported(){return s(this.view)||"3d"===this.view.type}get utcOffset(){return this._cachedDisplayUTCOffset}set utcOffset(t){t!==this.utcOffset&&n(this._lighting)&&"sun"===this._lighting.type&&(this._lighting.displayUTCOffset=t,this._updateLighting(null))}get localDate(){return d(this._lightingDateDisplay)}set localDate(t){t.getTime()!==this.localDate.getTime()&&(this._lightingDateDisplay=p(this._lightingDateDisplay,t))}get timeSliderPosition(){return D(this._lightingDateDisplay)}set timeSliderPosition(t){Math.abs(t-this.timeSliderPosition)>1/60&&(this._lightingDateDisplay=S(this._lightingDateDisplay,t),this.stopPlaying(),this._enableDirectShadowsIfFirstInteraction())}_timezoneFromCamera(t,e){if(s(e)||!t.cameraTrackingEnabled)return 0;const i=w([e.longitude,e.latitude]);return s(i)?0:Math.round(i.hours+i.minutes/60+i.seconds/3600)}get directShadowsEnabled(){const t=i(this._lighting,(t=>t.directShadowsEnabled));return a(t,!1)}set directShadowsEnabled(t){i(this._lighting,(e=>{e.directShadowsEnabled=t}))}get sunLightingEnabled(){return"sun"===this._lightingType}set sunLightingEnabled(t){const e=this._environment;if(t===this._get("sunLightingEnabled")||s(e))return;const i=e.lighting,a=this._oldLighting;this._oldLighting=i;const l={directShadowsEnabled:i.directShadowsEnabled,ambientOcclusionEnabled:i.ambientOcclusionEnabled,waterReflectionEnabled:i.waterReflectionEnabled},o=t?"sun":"virtual";let r;r=n(a)&&a.type===o?a:t?new _:new f,r.set(l),e.lighting=r,t||(this.timeSliderViewModel.isDropdownOpen=!1)}set playingState(t){this.playingState!==t&&this.sunLightingEnabled&&(this._set("playingState",t),"none"!==t&&(this._updateSunriseAndSunset(),this._lastTime=Date.now(),this._play(),this._enableDirectShadowsIfFirstInteraction()))}get dayPlaying(){return"day"===this.playingState}set dayPlaying(t){t?this.playingState="day":this.dayPlaying&&(this.playingState="none")}get yearPlaying(){return"year"===this.playingState}set yearPlaying(t){t?this.playingState="year":this.yearPlaying&&(this.playingState="none")}get currentSeason(){return T(this.localDate,this._currentHemisphere)}set currentSeason(t){this.stopPlaying();const e=v(t,this._currentHemisphere);this.localDate=U(this.localDate,e,L.NORTHERN)}get _currentHemisphere(){const t=i(this.view,(t=>t.camera?.position));return s(t)||t.latitude>=0?L.NORTHERN:L.SOUTHERN}get _environment(){return i(this.view,(t=>t.environment))}get _lighting(){return i(this._environment,(t=>t.lighting))}get _lightingType(){return i(this._lighting,(t=>t.type))}get _lightingDateDisplay(){return u(this._cachedLightingDateUTC,this._cachedDisplayUTCOffset,"hours")}set _lightingDateDisplay(t){const e=this._lighting;if(s(e)||!this.sunLightingEnabled||"sun"!==e.type)return;const i=u(t,-this._cachedDisplayUTCOffset,"hours");i.getTime()!==e.date.getTime()&&(e.date=i,this._updateLighting(null))}stopPlaying(){this.playingState="none"}toggleDayPlaying(){this.dayPlaying=!this.dayPlaying}toggleYearPlaying(){this.yearPlaying=!this.yearPlaying}toggleSunLightingEnabled(){this.stopPlaying(),this.sunLightingEnabled=!this.sunLightingEnabled}toggleDirectShadowsEnabled(){this.stopPlaying(),this.directShadowsEnabled=!this.directShadowsEnabled}_enableDirectShadowsIfFirstInteraction(){this._firstInteraction&&(this._firstInteraction=!1,this.directShadowsEnabled=!0)}_updateLighting(t){const e=Date.now();this._lastLightingUpdate=e;const{view:i}=this,n=this._lighting;if(s(i)||s(n)||"sun"!==n.type)return;const a=t||n.date,l=n.displayUTCOffset,o=null!==l?l:this._timezoneFromCamera(n,i.camera?.position);this._cachedLightingDateUTC.getTime()!==a.getTime()&&(this._cachedLightingDateUTC=new Date(a.getTime())),this._cachedDisplayUTCOffset!==o&&(this._cachedDisplayUTCOffset=o)}_timezoneWillChange(t){const e=this._lighting;if(s(e)||"sun"!==e.type||!e.cameraTrackingEnabled)return;let i;if(t)i=t.timezoneOffset;else{if(null!=e.displayUTCOffset)return;i=_.calculateTimezoneOffset(e.positionTimezoneInfo)}e.displayUTCOffset=i,this._scheduleUpdateLighting(null)}_scheduleUpdateLighting(t){if(this._nextLightingUpdate||s(t))return;const e=Date.now()-this._lastLightingUpdate,i=this.lightingUpdateInterval-e;i<=0?g((()=>this._updateLighting(t))):this._nextLightingUpdate=setTimeout((()=>{this._updateLighting(null),this._nextLightingUpdate=null}),i)}_play(){const t=this._lighting;if(!s(t)&&this.sunLightingEnabled&&"sun"===t.type&&(this.dayPlaying||this.yearPlaying)){const e=Date.now()-this._lastTime;if(this.dayPlaying){this._lastTime=Date.now();const i=P(this._sunrise,this._sunset,t.date)*this.playSpeedMultiplier/100*e;if(i>0){let e=new Date(t.date.getTime()+i);if(((e.getUTCHours()+t.displayUTCOffset)%24+24)%24<((t.date.getUTCHours()+t.displayUTCOffset)%24+24)%24){const s=864e5;e=new Date(t.date.getTime()+i-s)}t.date=e}}else{if(e>1e3){this._lastTime=Date.now();const e=(t.date.getUTCMonth()+1)%12,i=new Date(t.date.getTime());i.setUTCMonth(e),t.date=i}}requestAnimationFrame((()=>this._play()))}}_updateSunriseAndSunset(){const t=this._lighting;if(s(t)||"sun"!==t.type||!this.sunLightingEnabled)return;const e=i(this.view,(t=>t.camera?.position));if(s(e))return;const n=O(t.date,e.latitude,e.longitude,t.displayUTCOffset);this._sunrise=new Date(n.sunrise),this._sunset=new Date(n.sunset)}};t([c({type:m})],C.prototype,"view",void 0),t([c({type:E,nonNullable:!0})],C.prototype,"datePickerViewModel",void 0),t([c({type:b,nonNullable:!0})],C.prototype,"timeSliderViewModel",void 0),t([c()],C.prototype,"isSupported",null),t([c()],C.prototype,"lightingUpdateInterval",void 0),t([c()],C.prototype,"utcOffset",null),t([c()],C.prototype,"localDate",null),t([c()],C.prototype,"timeSliderPosition",null),t([c()],C.prototype,"directShadowsEnabled",null),t([c()],C.prototype,"sunLightingEnabled",null),t([c({type:["none","day","year"],value:"none"})],C.prototype,"playingState",null),t([c()],C.prototype,"dayPlaying",null),t([c()],C.prototype,"yearPlaying",null),t([c()],C.prototype,"playSpeedMultiplier",void 0),t([c()],C.prototype,"currentSeason",null),t([c()],C.prototype,"_lastTime",void 0),t([c()],C.prototype,"_sunrise",void 0),t([c()],C.prototype,"_sunset",void 0),t([c()],C.prototype,"_cachedLightingDateUTC",void 0),t([c()],C.prototype,"_cachedDisplayUTCOffset",void 0),t([c()],C.prototype,"_firstInteraction",void 0),t([c()],C.prototype,"_currentHemisphere",null),t([c()],C.prototype,"_environment",null),t([c()],C.prototype,"_lighting",null),t([c()],C.prototype,"_lightingType",null),t([c()],C.prototype,"_lightingDateDisplay",null),C=t([y("esri.widgets.Daylight.DaylightViewModel")],C);const M=C;export{M 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.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Color.js";import r from"../../Graphic.js";import"../../symbols.js";import i from"../../core/Collection.js";import{deprecatedProperty as o,deprecated as s}from"../../core/deprecate.js";import l from"../../core/Error.js";import n from"../../core/Evented.js";import{HandleOwnerMixin as a}from"../../core/HandleOwner.js";import c from"../../core/Logger.js";import{isNone as h,unwrapOr as u,isSome as p,unwrap as d,applySome as m}from"../../core/maybe.js";import{isAbortError as y}from"../../core/promiseUtils.js";import{on as g,watch as v,syncAndInitial as w,initial as f}from"../../core/reactiveUtils.js";import{property as b}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{cast as _}from"../../core/accessorSupport/decorators/cast.js";import{subclass as S}from"../../core/accessorSupport/decorators/subclass.js";import{getLocale as L}from"../../intl/locale.js";import C from"../../layers/GraphicsLayer.js";import D from"../../layers/RouteLayer.js";import T from"../../layers/support/RouteStopSymbols.js";import j from"../../layers/support/RouteSymbols.js";import{fetchServiceDescription as A}from"../../rest/networkService.js";import M from"../../rest/support/RouteParameters.js";import z from"../../rest/support/Stop.js";import{GoToMixin as O}from"../support/GoTo.js";import P from"../../symbols/SimpleLineSymbol.js";import R from"../../symbols/SimpleMarkerSymbol.js";import x from"../../symbols/PictureMarkerSymbol.js";function U(e){return"esri.Graphic"===e?.declaredClass}function E(e){return Array.isArray(e)&&e.length&&U(e[0])}function I(e){return i.isCollection(e)&&e.length&&U(e.getItemAt(0))}function k(e){return"esri.rest.support.Stop"===e?.declaredClass}var H;!function(e){e[e.Active=0]="Active",e[e.Complete=1]="Complete",e[e.Failed=2]="Failed",e[e.Idle=3]="Idle",e[e.Suspended=4]="Suspended"}(H||(H={}));const G=c.getLogger("esri.widgets.Directions.DirectionsViewModel");let N=class extends(a(O(n.EventedAccessor))){constructor(e){super(e),this._highlightLayer=new C({listMode:"hide",internal:!0}),this._highlight=null,this._legacyLayer=null,this._loadPromise=null,this._loadController=null,this._routeController=null,this._serviceDescriptionStatus=H.Idle,this.apiKey=void 0,this.departureTime="now",this.lastError=null,this.lastRoute=null,this.layer=null,this.maxStops=50,this.routeParameters=new M({directionsLengthUnits:"kilometers",findBestSequence:!1,restrictUTurns:"at-dead-ends-and-intersections",returnZ:!0,startTime:null,startTimeIsUTC:!0,useHierarchy:!0,useTimeWindows:!1}),this.serviceDescription=null,this.view=null}initialize(){this.own([g((()=>m(this.layer,(e=>e.stops))),"change",(()=>{this.clearResults()})),v((()=>this.layer),((e,t)=>{if(p(e))for(;e.stops.length<2;)e.stops.add(new z);h(e)&&(this.layer=this.legacyLayer),p(t)&&t===this.legacyLayer&&this.view?.map?.remove(t)}),w),v((()=>this.view?.map),((e,t)=>{this.layer===this.legacyLayer&&(t?.remove(this.layer),e?.add(this.layer)),t?.remove(this._highlightLayer),e?.add(this._highlightLayer)}),f)])}destroy(){this.view?.map?.remove(this._highlightLayer),this.layer===this.legacyLayer&&this.view?.map?.remove(this.layer)}get _directionsLanguage(){if(h(this.serviceDescription))return;const e=this.serviceDescription.directionsSupportedLanguages;if(!e)return;const t=u(this.routeParameters.directionsLanguage,L()).slice(0,2);return e.find((e=>e.toLowerCase().slice(0,2)===t))}get impedanceAttribute(){const e=p(this.serviceDescription)?this.serviceDescription.impedance:null,t=d(this.routeParameters.travelMode)?.impedanceAttributeName??d(this.routeParameters.impedanceAttribute)??e;return this.getCostAttribute(t)}get legacyLayer(){return h(this._legacyLayer)&&(this._legacyLayer=this._getLegacyLayer()),this._legacyLayer}set routeServiceUrl(e){o(G,"routeServiceUrl",{replacement:"layer.url",version:"4.24",warnOnce:!0}),this.legacyLayer.url=e}get routeServiceUrl(){return o(G,"routeServiceUrl",{replacement:"layer.url",version:"4.24",warnOnce:!0}),this.legacyLayer.url}set routeSymbol(e){o(G,"routeSymbol",{replacement:"layer.defaultSymbols.directionLines",version:"4.24",warnOnce:!0}),this.legacyLayer.defaultSymbols.directionLines=e}get routeSymbol(){return o(G,"routeSymbol",{replacement:"layer.defaultSymbols.directionLines",version:"4.24",warnOnce:!0}),this.legacyLayer.defaultSymbols.directionLines}get selectedTravelMode(){const{serviceDescription:e}=this;if(h(e))return null;const{defaultTravelMode:t,supportedTravelModes:r=[]}=e;return r.find((e=>e.id===t))||r[0]||null}set selectedTravelMode(e){void 0!==e?this._override("selectedTravelMode",e):this._clearOverride("selectedTravelMode")}get state(){if(p(this._routeController))return"routing";if(p(this.lastError))return"error";switch(this._serviceDescriptionStatus){case H.Suspended:return"unauthenticated";case H.Idle:return"disabled";case H.Active:return"initializing";case H.Failed:return"error";default:return"ready"}}set stops(e){o(G,"stops",{replacement:"layer.stops",version:"4.24",warnOnce:!0}),this.legacyLayer.stops=e}get stops(){return o(G,"stops",{replacement:"layer.stops",version:"4.24",warnOnce:!0}),this.legacyLayer.stops}castStops(e){return E(e)||I(e)?e.map((e=>z.fromGraphic(e))):e}set stopSymbols(e){o(G,"stopSymbols",{replacement:"layer.defaultSymbols.stops",version:"4.24",warnOnce:!0}),this.legacyLayer.defaultSymbols.stops=e}get stopSymbols(){return o(G,"stopSymbols",{replacement:"layer.defaultSymbols.stops",version:"4.24",warnOnce:!0}),this.legacyLayer.defaultSymbols.stops}get timeAttribute(){const e=d(this.routeParameters.travelMode)?.timeAttributeName??d(this.routeParameters.directionsTimeAttribute)??(p(this.serviceDescription)?this.serviceDescription.directionsTimeAttribute:null);return this.getCostAttribute(e)}get travelModes(){return p(this.serviceDescription)?this.serviceDescription.supportedTravelModes:[]}async load(){if(p(this._loadPromise))return this._loadPromise;this._loadPromise=this._load(),await this._loadPromise,this._loadPromise=null}async highlight(e){this.clearHighlights();const t=await this.view.whenLayerView(this.layer);this._highlight=t.highlight(e)}highlightSegment(e){s(G,"highlightSegment",{replacement:"highlight",version:"4.24",warnOnce:!0});const{geometry:i,symbol:o}=e;if(h(this.view)||h(i)||h(o))return;this.clearHighlights();const l=o.clone();l.color=new t([0,0,0,.8]),l.width=Math.ceil(l.width/2);const n=new r({geometry:i,symbol:l});this._highlightLayer.add(n)}clearHighlights(){this._highlightLayer.removeAll(),p(this._highlight)&&(this._highlight.remove(),this._highlight=null)}centerAt(e){if(h(this.view))return;const t=k(e)||U(e)?e.geometry:e;h(t)||this.callGoTo({target:t})}clearResults(){this._set("lastRoute",null)}async getDirections(){const{apiKey:e,departureTime:t,layer:r,state:i}=this;if(h(r))throw new l("directions-view-model:missing-route-layer","A route layer must be associated with the view model.");if(r===this.legacyLayer&&s(G,"Using the Directions widget or view model without setting `layer` is deprecated.",{see:"https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#layer",version:"4.24",warnOnce:!0}),"unauthenticated"===i||"initializing"===i||"disabled"===i||this._serviceDescriptionStatus===H.Failed)throw new l("directions-view-model:not-loaded","Cannot get directions until view model loads.");this._set("lastError",null),p(this._routeController)&&(this._routeController.abort(),this._routeController=null);const o="now"===t,n="now"===t?new Date:t;if(n&&!o){const e=60*n.getTimezoneOffset()*1e3;n.setTime(n.getTime()-e)}const a=p(this.view)?this.view.spatialReference:null,c=this.routeParameters.clone();c.set({startTime:n,startTimeIsUTC:o,directionsLanguage:this._directionsLanguage,apiKey:e,outSpatialReference:a}),p(this.selectedTravelMode)&&(c.travelMode=this.selectedTravelMode);if(r.stops.filter((e=>p(e.geometry))).length<2){const e=new l("directions-view-model:not-enough-stops","Not enough stops for routing");throw this._set("lastError",e),e}this._routeController=new AbortController;const{signal:u}=this._routeController;let d=null;try{d=await r.solve(c,{signal:u}),r.update(d),this._set("lastRoute",d)}catch(m){if(!y(m)){const e=new l("directions-view-model:unable-to-route","Unable to route to these addresses",{error:m});throw this._set("lastError",e),this._set("lastRoute",null),e}}finally{this._routeController=null}return this.zoomToRoute(),d}getCostAttribute(e){return(p(this.serviceDescription)?this.serviceDescription.networkDataset.networkAttributes:[]).find((t=>t.name===e&&"cost"===t.usageType))??null}reset(){this.clearHighlights(),this.clearResults(),p(this.layer)&&(this.layer.removeAll(),this.layer.stops=new i([new z,new z]))}save(){return this.layer.save()}saveAs(e,t={}){return this.layer.saveAs(e,t)}zoomToRoute(){const{view:e,layer:{routeInfo:t}}=this;if(h(e)||h(t))return;const{geometry:r}=t;if(h(r))return;const{extent:i}=r,o=i.width>i.height,s=i.clone().expand(o?2:1);this.callGoTo({target:s})}_getLegacyLayer(){const e=new t([255,128,0]);return new D({listMode:"hide",defaultSymbols:new j({directionLines:new P({color:e,width:7,cap:"round",join:"round"}),directionPoints:null,routeInfo:null,stops:new T({break:new R({color:[255,255,255],size:10,outline:{color:[20,89,127],width:2.5}}),first:new R({color:e,size:19,outline:{color:[51,51,51],width:3}}),last:new x({width:23,height:23,url:`data:image/svg+xml;base64,${btoa(`<svg width="30" height="30" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"><g fill-rule="nonzero" fill="none"><path d="M15.15.3C6.9.3.3 6.9.3 15.15S6.9 29.7 15.15 29.7 29.7 23.1 29.7 15.15C29.7 6.9 23.25.3 15.15.3z" fill="#333"/><path d="M15 4.8C9.3 4.8 4.8 9.45 4.8 15c0 5.55 4.65 10.2 10.2 10.2 5.55 0 10.2-4.5 10.2-10.2 0-5.55-4.5-10.2-10.2-10.2z" fill="${e.toHex()}"/><path fill="#333" d="M10.5 10.5h9v9h-9z"/></g></svg>`)}`}),middle:new R({color:[51,51,51],size:12,outline:{color:e,width:3}}),unlocated:new x({height:18,width:18,url:`data:image/svg+xml;base64,${btoa(`<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="M10.1.2C4.6.2.2 4.6.2 10.1s4.4 9.7 9.9 9.7 9.7-4.4 9.7-9.7c0-5.5-4.3-9.9-9.7-9.9z" fill="#333" fill-rule="nonzero"/><path d="M10 2.7c-4.08 0-7.3 3.328-7.3 7.3s3.328 7.3 7.3 7.3 7.3-3.22 7.3-7.3c0-3.972-3.22-7.3-7.3-7.3z" fill="${e.toHex()}" fill-rule="nonzero"/><path d="M11.414 10l5.304-5.303-1.415-1.415L10 8.586 4.697 3.282 3.282 4.697 8.586 10l-5.304 5.303 1.415 1.415L10 11.414l5.303 5.304 1.415-1.415L11.414 10z" fill="#333"/></g></svg>`)}`}),waypoint:new R({color:[255,255,255],size:10,outline:{color:[20,89,127],width:2.5}})})}),stops:[{},{}]})}async _load(){if(p(this.serviceDescription)||h(this.layer))return;p(this._loadController)&&(this._loadController.abort(),this._loadController=null),this._loadController=new AbortController;const{signal:e}=this._loadController;try{this._serviceDescriptionStatus=H.Active;const t=await A(this.layer.url,this.apiKey,{signal:e});this._set("serviceDescription",t),this._serviceDescriptionStatus=H.Complete}catch(t){if(y(t))return void(this._serviceDescriptionStatus=H.Idle);if("identity-manager:user-aborted"===t.name)return void(this._serviceDescriptionStatus=H.Suspended);const e=new l("directions-view-model:service-metadata-unavailable","Cannot load route service metadata",{error:t});throw this._serviceDescriptionStatus=H.Failed,this._set("lastError",e),e}finally{this._loadController=null}}};e([b()],N.prototype,"_directionsLanguage",null),e([b()],N.prototype,"_routeController",void 0),e([b()],N.prototype,"_serviceDescriptionStatus",void 0),e([b()],N.prototype,"apiKey",void 0),e([b()],N.prototype,"departureTime",void 0),e([b({readOnly:!0})],N.prototype,"impedanceAttribute",null),e([b()],N.prototype,"lastError",void 0),e([b({readOnly:!0})],N.prototype,"lastRoute",void 0),e([b()],N.prototype,"layer",void 0),e([b({readOnly:!0})],N.prototype,"legacyLayer",null),e([b({type:Number,range:{min:2,max:50},nonNullable:!0})],N.prototype,"maxStops",void 0),e([b({type:M,nonNullable:!0})],N.prototype,"routeParameters",void 0),e([b()],N.prototype,"routeServiceUrl",null),e([b()],N.prototype,"routeSymbol",null),e([b()],N.prototype,"selectedTravelMode",null),e([b({readOnly:!0})],N.prototype,"serviceDescription",void 0),e([b({readOnly:!0})],N.prototype,"state",null),e([b()],N.prototype,"stops",null),e([_("stops")],N.prototype,"castStops",null),e([b()],N.prototype,"stopSymbols",null),e([b({readOnly:!0})],N.prototype,"timeAttribute",null),e([b()],N.prototype,"travelModes",null),e([b()],N.prototype,"view",void 0),e([b()],N.prototype,"getDirections",null),e([b()],N.prototype,"zoomToRoute",null),N=e([S("esri.widgets.Directions.DirectionsViewModel")],N);const F=N;export{F as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Color.js";import r from"../../Graphic.js";import"../../symbols.js";import i from"../../core/Collection.js";import{deprecatedProperty as o,deprecated as s}from"../../core/deprecate.js";import l from"../../core/Error.js";import n from"../../core/Evented.js";import{HandleOwnerMixin as a}from"../../core/HandleOwner.js";import c from"../../core/Logger.js";import{isNone as h,unwrapOr as u,isSome as p,unwrap as d,applySome as m}from"../../core/maybe.js";import{isAbortError as y}from"../../core/promiseUtils.js";import{on as g,watch as v,syncAndInitial as w,initial as f}from"../../core/reactiveUtils.js";import{property as b}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{cast as _}from"../../core/accessorSupport/decorators/cast.js";import{subclass as S}from"../../core/accessorSupport/decorators/subclass.js";import{getLocale as L}from"../../intl/locale.js";import C from"../../layers/GraphicsLayer.js";import D from"../../layers/RouteLayer.js";import T from"../../layers/support/RouteStopSymbols.js";import j from"../../layers/support/RouteSymbols.js";import{fetchServiceDescription as A}from"../../rest/networkService.js";import M from"../../rest/support/RouteParameters.js";import z from"../../rest/support/Stop.js";import{GoToMixin as O}from"../support/GoTo.js";import R from"../../symbols/SimpleLineSymbol.js";import P from"../../symbols/SimpleMarkerSymbol.js";import x from"../../symbols/PictureMarkerSymbol.js";function U(e){return"esri.Graphic"===e?.declaredClass}function E(e){return Array.isArray(e)&&e.length&&U(e[0])}function I(e){return i.isCollection(e)&&e.length&&U(e.getItemAt(0))}function k(e){return"esri.rest.support.Stop"===e?.declaredClass}var H;!function(e){e[e.Active=0]="Active",e[e.Complete=1]="Complete",e[e.Failed=2]="Failed",e[e.Idle=3]="Idle",e[e.Suspended=4]="Suspended"}(H||(H={}));const G=c.getLogger("esri.widgets.Directions.DirectionsViewModel");let N=class extends(a(O(n.EventedAccessor))){constructor(e){super(e),this._highlightLayer=new C({listMode:"hide",internal:!0}),this._highlight=null,this._legacyLayer=null,this._loadPromise=null,this._loadController=null,this._routeController=null,this._serviceDescriptionStatus=H.Idle,this.apiKey=void 0,this.departureTime="now",this.lastError=null,this.lastRoute=null,this.layer=null,this.maxStops=50,this.routeParameters=new M({directionsLengthUnits:"kilometers",findBestSequence:!1,restrictUTurns:"at-dead-ends-and-intersections",returnZ:!0,startTime:null,startTimeIsUTC:!0,useHierarchy:!0,useTimeWindows:!1}),this.serviceDescription=null,this.view=null}initialize(){this.own([g((()=>m(this.layer,(e=>e.stops))),"change",(()=>{this.clearResults()})),v((()=>this.layer),((e,t)=>{if(p(e))for(;e.stops.length<2;)e.stops.add(new z);h(e)&&(this.layer=this.legacyLayer),p(t)&&t===this.legacyLayer&&this.view?.map?.remove(t)}),w),v((()=>this.view?.map),((e,t)=>{this.layer===this.legacyLayer&&(t?.remove(this.layer),e?.add(this.layer)),t?.remove(this._highlightLayer),e?.add(this._highlightLayer)}),f)])}destroy(){this.view?.map?.remove(this._highlightLayer),this.layer===this.legacyLayer&&this.view?.map?.remove(this.layer)}get _directionsLanguage(){if(h(this.serviceDescription))return;const e=this.serviceDescription.directionsSupportedLanguages;if(!e)return;const t=u(this.routeParameters.directionsLanguage,L()).slice(0,2);return e.find((e=>e.toLowerCase().slice(0,2)===t))}get impedanceAttribute(){const e=p(this.serviceDescription)?this.serviceDescription.impedance:null,t=d(this.routeParameters.travelMode)?.impedanceAttributeName??d(this.routeParameters.impedanceAttribute)??e;return this.getCostAttribute(t)}get legacyLayer(){return h(this._legacyLayer)&&(this._legacyLayer=this._getLegacyLayer()),this._legacyLayer}set routeServiceUrl(e){o(G,"routeServiceUrl",{replacement:"layer.url",version:"4.24",warnOnce:!0}),this.legacyLayer.url=e}get routeServiceUrl(){return o(G,"routeServiceUrl",{replacement:"layer.url",version:"4.24",warnOnce:!0}),this.legacyLayer.url}set routeSymbol(e){o(G,"routeSymbol",{replacement:"layer.defaultSymbols.directionLines",version:"4.24",warnOnce:!0}),this.legacyLayer.defaultSymbols.directionLines=e}get routeSymbol(){return o(G,"routeSymbol",{replacement:"layer.defaultSymbols.directionLines",version:"4.24",warnOnce:!0}),this.legacyLayer.defaultSymbols.directionLines}get selectedTravelMode(){const{serviceDescription:e}=this;if(h(e))return null;const{defaultTravelMode:t,supportedTravelModes:r=[]}=e;return r.find((e=>e.id===t))||r[0]||null}set selectedTravelMode(e){void 0!==e?this._override("selectedTravelMode",e):this._clearOverride("selectedTravelMode")}get state(){if(p(this._routeController))return"routing";if(p(this.lastError))return"error";switch(this._serviceDescriptionStatus){case H.Suspended:return"unauthenticated";case H.Idle:return"disabled";case H.Active:return"initializing";case H.Failed:return"error";default:return"ready"}}set stops(e){o(G,"stops",{replacement:"layer.stops",version:"4.24",warnOnce:!0}),this.legacyLayer.stops=e}get stops(){return o(G,"stops",{replacement:"layer.stops",version:"4.24",warnOnce:!0}),this.legacyLayer.stops}castStops(e){return E(e)||I(e)?e.map((e=>z.fromGraphic(e))):e}set stopSymbols(e){o(G,"stopSymbols",{replacement:"layer.defaultSymbols.stops",version:"4.24",warnOnce:!0}),this.legacyLayer.defaultSymbols.stops=e}get stopSymbols(){return o(G,"stopSymbols",{replacement:"layer.defaultSymbols.stops",version:"4.24",warnOnce:!0}),this.legacyLayer.defaultSymbols.stops}get timeAttribute(){const e=d(this.routeParameters.travelMode)?.timeAttributeName??d(this.routeParameters.directionsTimeAttribute)??(p(this.serviceDescription)?this.serviceDescription.directionsTimeAttribute:null);return this.getCostAttribute(e)}get travelModes(){return p(this.serviceDescription)?this.serviceDescription.supportedTravelModes:[]}async load(){if(p(this._loadPromise))return this._loadPromise;this._loadPromise=this._load(),await this._loadPromise,this._loadPromise=null}async highlight(e){this.clearHighlights();const t=await this.view.whenLayerView(this.layer);this._highlight=t.highlight(e)}highlightSegment(e){s(G,"highlightSegment",{replacement:"highlight",version:"4.24",warnOnce:!0});const{geometry:i,symbol:o}=e;if(h(this.view)||h(i)||h(o))return;this.clearHighlights();const l=o.clone();l.color=new t([0,0,0,.8]),l.width=Math.ceil(l.width/2);const n=new r({geometry:i,symbol:l});this._highlightLayer.add(n)}clearHighlights(){this._highlightLayer.removeAll(),p(this._highlight)&&(this._highlight.remove(),this._highlight=null)}centerAt(e){if(h(this.view))return;const t=k(e)||U(e)?e.geometry:e;h(t)||this.callGoTo({target:t})}clearResults(){this._set("lastRoute",null),this.layer.removeResult()}async getDirections(){const{apiKey:e,departureTime:t,layer:r,state:i}=this;if(h(r))throw new l("directions-view-model:missing-route-layer","A route layer must be associated with the view model.");if(r===this.legacyLayer&&s(G,"Using the Directions widget or view model without setting `layer` is deprecated.",{see:"https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#layer",version:"4.24",warnOnce:!0}),"unauthenticated"===i||"initializing"===i||"disabled"===i||this._serviceDescriptionStatus===H.Failed)throw new l("directions-view-model:not-loaded","Cannot get directions until view model loads.");this._set("lastError",null),p(this._routeController)&&(this._routeController.abort(),this._routeController=null);const o="now"===t,n="now"===t?new Date:t;if(n&&!o){const e=60*n.getTimezoneOffset()*1e3;n.setTime(n.getTime()-e)}const a=p(this.view)?this.view.spatialReference:null,c=this.routeParameters.clone();c.set({startTime:n,startTimeIsUTC:o,directionsLanguage:this._directionsLanguage,apiKey:e,outSpatialReference:a}),p(this.selectedTravelMode)&&(c.travelMode=this.selectedTravelMode);if(r.stops.filter((e=>p(e.geometry))).length<2){const e=new l("directions-view-model:not-enough-stops","Not enough stops for routing");throw this._set("lastError",e),e}this._routeController=new AbortController;const{signal:u}=this._routeController;let d=null;try{d=await r.solve(c,{signal:u}),r.update(d),this._set("lastRoute",d)}catch(m){if(!y(m)){const e=new l("directions-view-model:unable-to-route","Unable to route to these addresses",{error:m});throw this._set("lastError",e),this._set("lastRoute",null),e}}finally{this._routeController=null}return this.zoomToRoute(),d}getCostAttribute(e){return(p(this.serviceDescription)?this.serviceDescription.networkDataset.networkAttributes:[]).find((t=>t.name===e&&"cost"===t.usageType))??null}reset(){this.clearHighlights(),this.clearResults(),p(this.layer)&&(this.layer.removeAll(),this.layer.stops=new i([new z,new z]))}save(){return this.layer.save()}saveAs(e,t={}){return this.layer.saveAs(e,t)}zoomToRoute(){const{view:e,layer:{routeInfo:t}}=this;if(h(e)||h(t))return;const{geometry:r}=t;if(h(r))return;const{extent:i}=r,o=i.width>i.height,s=i.clone().expand(o?2:1);this.callGoTo({target:s})}_getLegacyLayer(){const e=new t([255,128,0]);return new D({listMode:"hide",defaultSymbols:new j({directionLines:new R({color:e,width:7,cap:"round",join:"round"}),directionPoints:null,routeInfo:null,stops:new T({break:new P({color:[255,255,255],size:10,outline:{color:[20,89,127],width:2.5}}),first:new P({color:e,size:19,outline:{color:[51,51,51],width:3}}),last:new x({width:23,height:23,url:`data:image/svg+xml;base64,${btoa(`<svg width="30" height="30" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"><g fill-rule="nonzero" fill="none"><path d="M15.15.3C6.9.3.3 6.9.3 15.15S6.9 29.7 15.15 29.7 29.7 23.1 29.7 15.15C29.7 6.9 23.25.3 15.15.3z" fill="#333"/><path d="M15 4.8C9.3 4.8 4.8 9.45 4.8 15c0 5.55 4.65 10.2 10.2 10.2 5.55 0 10.2-4.5 10.2-10.2 0-5.55-4.5-10.2-10.2-10.2z" fill="${e.toHex()}"/><path fill="#333" d="M10.5 10.5h9v9h-9z"/></g></svg>`)}`}),middle:new P({color:[51,51,51],size:12,outline:{color:e,width:3}}),unlocated:new x({height:18,width:18,url:`data:image/svg+xml;base64,${btoa(`<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="M10.1.2C4.6.2.2 4.6.2 10.1s4.4 9.7 9.9 9.7 9.7-4.4 9.7-9.7c0-5.5-4.3-9.9-9.7-9.9z" fill="#333" fill-rule="nonzero"/><path d="M10 2.7c-4.08 0-7.3 3.328-7.3 7.3s3.328 7.3 7.3 7.3 7.3-3.22 7.3-7.3c0-3.972-3.22-7.3-7.3-7.3z" fill="${e.toHex()}" fill-rule="nonzero"/><path d="M11.414 10l5.304-5.303-1.415-1.415L10 8.586 4.697 3.282 3.282 4.697 8.586 10l-5.304 5.303 1.415 1.415L10 11.414l5.303 5.304 1.415-1.415L11.414 10z" fill="#333"/></g></svg>`)}`}),waypoint:new P({color:[255,255,255],size:10,outline:{color:[20,89,127],width:2.5}})})}),stops:[{},{}]})}async _load(){if(p(this.serviceDescription)||h(this.layer))return;p(this._loadController)&&(this._loadController.abort(),this._loadController=null),this._loadController=new AbortController;const{signal:e}=this._loadController;try{this._serviceDescriptionStatus=H.Active;const t=await A(this.layer.url,this.apiKey,{signal:e});this._set("serviceDescription",t),this._serviceDescriptionStatus=H.Complete}catch(t){if(y(t))return void(this._serviceDescriptionStatus=H.Idle);if("identity-manager:user-aborted"===t.name)return void(this._serviceDescriptionStatus=H.Suspended);const e=new l("directions-view-model:service-metadata-unavailable","Cannot load route service metadata",{error:t});throw this._serviceDescriptionStatus=H.Failed,this._set("lastError",e),e}finally{this._loadController=null}}};e([b()],N.prototype,"_directionsLanguage",null),e([b()],N.prototype,"_routeController",void 0),e([b()],N.prototype,"_serviceDescriptionStatus",void 0),e([b()],N.prototype,"apiKey",void 0),e([b()],N.prototype,"departureTime",void 0),e([b({readOnly:!0})],N.prototype,"impedanceAttribute",null),e([b()],N.prototype,"lastError",void 0),e([b({readOnly:!0})],N.prototype,"lastRoute",void 0),e([b()],N.prototype,"layer",void 0),e([b({readOnly:!0})],N.prototype,"legacyLayer",null),e([b({type:Number,range:{min:2,max:50},nonNullable:!0})],N.prototype,"maxStops",void 0),e([b({type:M,nonNullable:!0})],N.prototype,"routeParameters",void 0),e([b()],N.prototype,"routeServiceUrl",null),e([b()],N.prototype,"routeSymbol",null),e([b()],N.prototype,"selectedTravelMode",null),e([b({readOnly:!0})],N.prototype,"serviceDescription",void 0),e([b({readOnly:!0})],N.prototype,"state",null),e([b()],N.prototype,"stops",null),e([_("stops")],N.prototype,"castStops",null),e([b()],N.prototype,"stopSymbols",null),e([b({readOnly:!0})],N.prototype,"timeAttribute",null),e([b()],N.prototype,"travelModes",null),e([b()],N.prototype,"view",void 0),e([b()],N.prototype,"getDirections",null),e([b()],N.prototype,"zoomToRoute",null),N=e([S("esri.widgets.Directions.DirectionsViewModel")],N);const F=N;export{F 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.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{deprecatedProperty as t}from"../core/deprecate.js";import{on as s,pausable as o}from"../core/events.js";import i from"../core/Handles.js";import r from"../core/Logger.js";import{isNone as n,isSome as a,unwrap as l,unwrapOrValue as c}from"../core/maybe.js";import{watch as d,initial as h,when as u,on as p}from"../core/reactiveUtils.js";import{aliasOf as v}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{property as m}from"../core/accessorSupport/decorators/property.js";import{subclass as _}from"../core/accessorSupport/decorators/subclass.js";import g from"../rest/support/Stop.js";import y from"../symbols/SimpleMarkerSymbol.js";import S from"./Search.js";import w from"./Widget.js";import M from"./Directions/DirectionsViewModel.js";import{SaveLayer as f}from"./Directions/components/SaveLayer.js";import{formatDistance as b,formatTime as C,isTimeUnits as T}from"./Directions/support/directionsUtils.js";import{DepartureTime as k,CSS as I,getIconPath as D}from"./Directions/support/resources.js";import{isArcGISWorldGeocoder as L,meteredArcGISLocatorUrl as R}from"./Search/support/locatorUtils.js";import P from"./support/DatePicker.js";import{Heading as B,incrementHeadingLevel as j}from"./support/Heading.js";import x from"./support/TimePicker.js";import{accessibleHandler as A}from"./support/decorators/accessibleHandler.js";import{messageBundle as H}from"./support/decorators/messageBundle.js";import{tsx as U}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import O from"sortablejs";import{substitute as z}from"../intl/substitute.js";import{formatDate as E,convertDateFormatToIntlOptions as $}from"../intl/date.js";import{formatNumber as N}from"../intl/number.js";function F(e){const t=e.getTimezoneOffset(),s=t>0?"-":"+",o=60,i=Math.abs(Math.floor(t/o)),r=Math.abs(Math.floor(t)%o),n={minimumIntegerDigits:2};return`GMT${s}${N(i,n)}${N(r,n)}`}function V(e){return!!e.composedPath?.().find((e=>e.classList?.contains("esri-search__suggestions-list")))}const W={awaitingViewClickStop:"awaiting-view-click-stop"},q=100,K=500,Y=r.getLogger("esri.widgets.Directions");let G=class extends w{constructor(e,t){super(e,t),this._autoStopRemovalDelay=q,this._departureTime=k.NOW,this._datePicker=new P,this._handles=new i,this._newPlaceholderStop=null,this._pointerPressedSearchSuggestionStop=null,this._saveAsButtonNode=null,this._saveLayer=new f,this._sections=null,this._stopsToSearches=new Map,this._timePicker=new x,this.apiKey=null,this.goToOverride=null,this.headingLevel=2,this.iconClass=I.widgetIcon,this.label=void 0,this.lastRoute=null,this.layer=null,this.maxStops=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.searchProperties=null,this.view=null,this.viewModel=new M,this._setUpDragAndDropStops=e=>{this._sortable=O.create(e,{draggable:`.${I.validStopRow}`,ghostClass:I.stopRowGhost,handle:`.${I.stopHandle}`,onEnd:this._handleStopInputDragEnd})},this._handleDragHandlePointerDown=()=>this.viewModel.layer.stops.forEach((e=>this._acquireSearch(e).activeMenu="none")),this._handleStopInputDragEnd=({oldIndex:e,newIndex:t,target:s})=>{if(e===t)return;const{children:o}=s,i=o[t],r=o[e],n=t-e<0;s.insertBefore(i,n?r.nextElementSibling:r);const a=this.viewModel.layer.stops;a.reorder(a.getItemAt(e),t);for(const l of a)l.sequence=null;this._processStops()}}initialize(){this.own([d((()=>this.viewModel.lastRoute),(()=>{this._activeStop=null,this._activeManeuver=null,this._focusedManeuver=null,this._sections=this._getSections(),this.scheduleRender()}),h),u((()=>this.view),((e,t)=>{if(t&&(this._viewClickHandle=null,this._handles.remove(t)),e){const t=this._prepPointerDownUpClick(),o=this._prepViewClick();t.pause(),o.pause(),this._handles.add([s(e.surface,"mousedown",(()=>this._autoStopRemovalDelay=K)),s(e.surface,"mouseup",(()=>this._autoStopRemovalDelay=q)),t,o],this.view.surface),this._pointerDownUpHandle=t,this._viewClickHandle=o}}),h),u((()=>n(this.viewModel.serviceDescription)),(()=>{try{this.viewModel.load()}catch{}}),h),d((()=>this._saveLayer.state),(()=>{this.scheduleRender()}))])}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-link.js"),import("@esri/calcite-components/dist/components/calcite-popover.js")])}destroy(){this._datePicker.destroy(),this._timePicker.destroy();for(const e of this._stopsToSearches.values())e.destroy();this._sortable&&this._sortable.destroy()}set routeServiceUrl(e){t(Y,"routeServiceUrl",{replacement:"viewModel.layer.url",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.url=e}get routeServiceUrl(){return t(Y,"routeServiceUrl",{replacement:"viewModel.layer.url",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.url}set routeSymbol(e){t(Y,"routeSymbol",{replacement:"viewModel.layer.defaultSymbols.directionLines",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.defaultSymbols.directionLines=e}get routeSymbol(){return t(Y,"routeSymbol",{replacement:"viewModel.layer.defaultSymbols.directionLines",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.defaultSymbols.directionLines}set stopSymbols(e){t(Y,"stopSymbols",{replacement:"viewModel.layer.defaultSymbols.stops",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.defaultSymbols.stops=e}get stopSymbols(){return t(Y,"stopSymbols",{replacement:"viewModel.layer.defaultSymbols.stops",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.defaultSymbols.stops}getDirections(){return null}render(){return U("div",{class:this.classes(I.base,I.scroller)},this._renderPanelContent())}save(){return this.viewModel.layer.save()}saveAs(e,t={}){return this.viewModel.layer.saveAs(e,t)}zoomToRoute(){}_renderPanelContent(){const{viewModel:{serviceDescription:e,state:t}}=this,s="initializing"===t,o="error"===t&&!e,i="unauthenticated"===t,r={[I.panelContentLoading]:s,[I.panelContentError]:o,[I.panelContentSignIn]:i},n=s?"presentation":"group",a=i?this._renderSignIn():o?this._renderMessage(this._getErrorMessage()):s?this._renderLoader():this._renderReadyContent();return U("div",{class:this.classes(I.panelContent,r),role:n},a)}_renderReadyContent(){return[this._renderStopsContainer(),this._renderTravelModeOptions(),this._renderDepartureTimeControls(),this._renderSaveContainer(),this._renderSectionSplitter(),this._renderDirectionsContainer()]}_renderSignIn(){return U("div",{key:"sign-in",class:I.signInContent},U(B,{class:I.contentTitle,level:this.headingLevel},this.messages.widgetLabel),this._renderPlaceholder(),U(B,{level:j(this.headingLevel)},this.messages.signInRequired),U("button",{class:this.classes(I.button,I.buttonSecondary,I.signInButton),tabIndex:0,onclick:this._handleSignInClick,bind:this,type:"button"},this.messagesCommon.auth.signIn))}_handleSignInClick(){this.viewModel.load().catch((()=>{}))}_renderTravelModeOptions(){const{selectedTravelMode:e,travelModes:t}=this.viewModel;if(0===t.length)return null;const s=a(e)?e.name:this.messages.travelMode;return U("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(I.travelMode,this._saveLayer.opened&&I.buttonDisabled),key:"esri-directions__travel-mode-controls",role:"group"},U("select",{"aria-label":s,bind:this,class:this.classes(I.travelModeSelect,I.select),key:"esri-directions__travel-mode-options",onchange:this._handleTravelModeChange,title:s},t.map((t=>{const s=a(e)&&t.id===e.id;return U("option",{key:`esri-directions__travel-mode-${t.id}`,"data-mode":t,selected:s,value:t.id},t.name)}))))}_handleTravelModeChange(e){const t=e.currentTarget,s=t.item(t.selectedIndex);this.viewModel.selectedTravelMode=s["data-mode"],this._getDirections()}_renderStopsContainer(){return U("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(I.section,this._saveLayer.opened&&I.buttonDisabled),key:"esri-directions__stops-container",role:"group"},this._renderStops())}_renderDepartureTimeControls(){const e=this._departureTime,{messages:t}=this,s=t.departureTime;return U("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(I.departureTime,this._saveLayer.opened&&I.buttonDisabled),key:"esri-directions__departure-time-controls",role:"group"},U("select",{"aria-label":s,bind:this,class:this.classes(I.departureTimeSelect,I.select),onchange:this._handleDepartureOptionChange,title:s},U("option",{value:k.NOW,selected:e===k.NOW},t.leaveNow),U("option",{value:k.DEPART_BY,selected:e===k.DEPART_BY},t.departBy),U("option",{value:k.UNSPECIFIED,selected:e===k.UNSPECIFIED},t.timeUnspecified)),e===k.DEPART_BY?this._renderTimeControls():null)}_renderStops(){const e=this.viewModel.layer.stops;let t=0;for(const o of this._stopsToSearches.keys())e.includes(o)||this._disposeSearch(o);for(const o of e){const e=this._acquireSearch(o);"none"!==e.activeMenu&&(t+=1),a(o.name)&&(e.searchTerm=o.name)}const s=e.toArray().map(((s,o)=>{const i=e.length,r=o>1&&n(s.geometry),l={[I.stopsIcon]:o>=0&&o<i-1,[I.lastStopIcon]:o===i-1},c={[I.lastStopIconContainer]:o===i-1},d={[I.validStopRow]:!r},h=e.getItemAt(o+1),u=h&&a(h.geometry),p=o===i-1,v=o===i-2,m=2===i&&0===o||i>2&&!p&&!v||i>2&&v&&u||i>2&&p&&n(s.geometry),_=i<3,g=this._acquireSearch(s),{messages:y}=this,{removeStop:S,reverseStops:w,unlocated:M}=y,f=z(y.stopLabelTemplate,{number:o+1,label:a(s.geometry)?s.name:M}),b=`${this.id}__stop--${o}`,C=!!g.searchTerm&&!!g.selectedResult&&a(s.geometry)&&g.selectedResult.name===s.name,T={zIndex:"none"!==g.activeMenu?""+t--:""};return U("li",{"aria-label":f,afterCreate:this._handleStopFieldCreation,bind:this,class:this.classes(I.stopRow,d),id:b,key:o,"data-stop-index":o,styles:T},U("div",{class:I.stopHandle},U("span",{"aria-hidden":"true",class:this.classes(I.stopIcon,I.handleIcon,I.stopHandleIcon,I.interactiveStopIcon),onpointerdown:this._handleDragHandlePointerDown}),U("div",{bind:this,"aria-labelledby":b,class:this.classes(I.stopIconContainer,c),"data-stop-index":o,onclick:this._handleStopIconClick,onkeydown:this._handleStopIconClick,role:"button"},U("span",{class:this.classes(I.stopIcon,l),tabindex:C?"0":null}))),U("div",{class:I.stopInput},g.render()),U("div",{class:I.stopOptions,role:"group"},U("div",{"aria-label":S,class:I.removeStopButton,bind:this,"data-stop-index":o,hidden:_,onkeydown:this._handleRemoveStop,onclick:this._handleRemoveStop,role:"button",tabIndex:0,title:S},U("span",{"aria-hidden":"true",class:this.classes(I.stopIcon,I.removeStop,I.removeStopIcon,I.interactiveStopIcon)}),U("span",{class:I.screenReaderText},"removeStopTitle")),U("div",{"aria-label":w,class:I.reverseStops,bind:this,hidden:m,onkeydown:this._handleReverseStops,onclick:this._handleReverseStops,role:"button",tabIndex:0,title:w},U("span",{"aria-hidden":"true",class:this.classes(I.stopIcon,I.reverseStopIcon,I.interactiveStopIcon)}),U("span",{class:I.screenReaderText},"removeStopTitle"))))}));return U("div",null,U("ol",{class:I.stops,role:"group",afterCreate:this._setUpDragAndDropStops},s),U("div",{class:I.toolbarSection},U("div",{class:I.toolbarButtons},this._renderAddStop())))}_renderAddStop(){const e=this.viewModel.layer.stops.length>=this.maxStops;return U("calcite-button",{appearance:"outline",class:I.addStopButton,color:"neutral",disabled:e,"icon-start":"plus",key:I.addStopButton,onclick:()=>{this._addNewPlaceholder()},text:this.messages.addStop,width:"half"},this.messages.addStop)}_handleStopIconClick(e){const t=e.currentTarget["data-stop-index"],s=this.viewModel.layer.stops.getItemAt(t);s&&a(s.geometry)&&this._centerAtStop(s)}_handleClearRouteClick(){this.viewModel.reset()}_centerAtStop(e){this.viewModel.centerAt(e)}_handleStopFieldCreation(e){const t=this._newPlaceholderStop;if(!t)return;const s=e["data-stop-index"],o=this.viewModel.layer.stops.getItemAt(s);if(t===o){const e=this._acquireSearch(o);e.when((()=>{this.renderNow(),e.focus()}))}this._newPlaceholderStop=null}_handleStopInputBlur(e,t){if(this._saveLayer.opened)return;this._handles.remove(W.awaitingViewClickStop),this.view.cursor=this._previousCursor;if(!!e.selectedResult&&a(t.geometry)&&a(e.selectedResult?.feature.geometry)&&t.geometry===e.selectedResult?.feature.geometry)return void this._pointerDownUpHandle.pause();const s=n(t.geometry)&&n(e.selectedResult?.feature.geometry),o=a(t.geometry)&&a(e.selectedResult?.feature.geometry)&&t.geometry!==e.selectedResult.feature.geometry;if((s||o)&&"none"===e.activeMenu&&e.searchTerm)return e.search(),void this._pointerDownUpHandle.pause();e.searchTerm||(this._viewClickHandle.resume(),clearTimeout(this._autoStopRemovalTimeoutId),this._autoStopRemovalTimeoutId=setTimeout((()=>{this.destroyed||(this._viewClickHandle.pause(),"searching"!==e.viewModel.state?this._pointerPressedSearchSuggestionStop||(a(t.geometry)&&(t.geometry=null,this._processStops()),this.scheduleRender()):this._pointerDownUpHandle.pause())}),this._autoStopRemovalDelay))}_handleStopInputFocus(e,t){if(this._pointerDownUpHandle.resume(),this._handles.has(W.awaitingViewClickStop))return;const{view:s,view:{cursor:o}}=this;this._previousCursor=o,this._handles.add(d((()=>e.searchTerm),(t=>{e.destroyed||(s.cursor=0===t.length?"copy":o)}),h),W.awaitingViewClickStop),this._activeStop=t}_prepViewClick(){const{view:e}=this.viewModel,t=o(e,"click",this._handleViewClick.bind(this)),s=o(e.surface,"click",(()=>{clearTimeout(this._autoStopRemovalTimeoutId),s.pause()}));return{remove(){s.remove(),t.remove()},pause(){s.pause(),t.pause()},resume(){s.resume(),t.resume()}}}_prepPointerDownUpClick(){const e=o(document,"pointerdown",(e=>{this._pointerPressedSearchSuggestionStop=V(e)?this._activeStop:null})),t=o(document,"pointerup",(e=>{this._pointerDownUpHandle.pause();const t=V(e),s=this._activeStop;t||s!==this._pointerPressedSearchSuggestionStop||this._removeStop(s),this.scheduleRender(),this._pointerPressedSearchSuggestionStop=t?s:null}));return{remove(){t.remove(),e.remove()},pause(){t.pause(),e.pause()},resume(){e.resume()}}}_handleViewClick(e){const t=this._stopsToSearches.get(this._activeStop);t&&!t.searchTerm&&(t.search(e.mapPoint).then((e=>{const s=e.results[0].results[0],{feature:o,name:i}=s;this._activeStop.geometry=o.geometry,this._activeStop.name=i,t.searchTerm=i})),this.scheduleRender()),this._viewClickHandle.pause(),clearTimeout(this._autoStopRemovalTimeoutId)}_addNewPlaceholder(){if(this._pointerDownUpHandle.pause(),this._newPlaceholderStop)return;const e=new g({symbol:new y});this.viewModel.layer.stops.add(e),this._newPlaceholderStop=e}_handleReverseStops(){this._reverseStops()}_reverseStops(){this.viewModel.layer.stops.reverse();for(const e of this.viewModel.layer.stops)e.sequence=null;this._processStops()}_handleRemoveStop(e){const t=e.currentTarget["data-stop-index"],s=this.viewModel.layer.stops.getItemAt(t);this._removeStop(s),a(s.geometry)&&this._processStops()}_removeStop(e){this.viewModel.layer.stops.length<=2||(this._disposeSearch(e),this.viewModel.layer.stops.remove(e))}_handleDepartureOptionChange(e){const t=e.currentTarget,s=t.item(t.selectedIndex);s.value===k.NOW?(this._departureTime=k.NOW,this.viewModel.departureTime=k.NOW,this._handles.remove("departure-time-controls"),this._getDirections()):s.value===k.DEPART_BY?(this._departureTime=k.DEPART_BY,this._handles.add(d((()=>[this._datePicker.value,this._timePicker.value]),(()=>{this._updateDepartureTime(),this._getDirections()}),h),"departure-time-controls")):(this._departureTime=k.UNSPECIFIED,this.viewModel.departureTime=null,this._getDirections())}_updateDepartureTime(){const e=this._datePicker.value,t=this._timePicker.value;e&&t&&(this.viewModel.departureTime=new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes()))}_renderTimeControls(){return U("div",{class:I.departureTimeControls,key:"esri-directions__time-controls",role:"group"},this._datePicker.render(),this._timePicker.render())}_renderSectionSplitter(){return U("div",{class:I.sectionSplitter})}_renderSaveContainer(){return U("div",{class:I.saveSection,key:I.saveSection},U("div",{class:I.saveButtons,key:I.saveButtons},this._renderSaveButton(),this._renderSaveAsButton(),this._renderPrintButton()),this._renderRouteLayerDetailsLink())}_renderSaveButton(){const e=this.viewModel.layer.portalItem?.itemControl,t=a(this.viewModel.layer.routeInfo)&&("admin"===e||"update"===e);return U("calcite-button",{appearance:"outline",class:I.saveButton,color:"neutral",disabled:!t,"icon-start":"save",key:I.saveButton,onclick:()=>{this._handleSaveButtonClick()},text:this.messagesCommon.save,width:"full"},this.messagesCommon.save)}_renderSaveAsButton(){const e=n(this.viewModel.layer.routeInfo);return U("div",{class:I.saveAsButtonPopover,key:I.saveAsButtonPopover},U("calcite-button",{afterCreate:e=>{this._saveAsButtonNode=e},appearance:"outline",class:I.saveAsButton,color:"neutral",disabled:e,"icon-start":"duplicate",key:I.saveAsButton,onclick:()=>this._handleSaveAsButtonClick(),text:this.messagesCommon.saveAs,width:"full"},this.messagesCommon.saveAs),U("calcite-popover",{label:this._saveLayer.label,open:this._saveLayer.opened,"overlay-positioning":"fixed",referenceElement:l(this._saveAsButtonNode)},this._saveLayer.render()))}_handleSaveAsButtonClick(){this._saveLayer.opened?this._saveLayer.close():this._saveLayer.open(this.viewModel.layer)}_renderPrintButton(){return U("calcite-button",{appearance:"outline",class:I.printButton,color:"neutral","icon-start":"print",key:I.printButton,text:this.messagesCommon.print})}_renderRouteLayerDetailsLink(){const{portalItem:e}=this.viewModel.layer;if(!e)return null;const{id:t,portal:{url:s}}=e,o=`${s}/home/item.html?id=${t}`;return U("calcite-link",{class:I.layerDetailsLink,href:o,key:I.layerDetailsLink,target:"_blank"},this.messages.viewLayerDetails)}_handleSaveButtonClick(){this.viewModel.layer.save()}_renderDirectionsContainer(){return U("div",{class:this.classes(I.directionsSection,I.section),key:"esri-directions__container"},this._renderDirectionsContainerContent())}_renderLoader(){return U("div",{class:I.loader,key:"loader"})}_renderWarningCard(){return U("div",{class:I.warningCard,role:"alert"},U("div",{class:I.warningHeader},U("span",{class:I.warningIcon,"aria-hidden":"true"}),U(B,{class:I.warningHeading,level:this.headingLevel},this.messagesCommon.warning)),U("div",{class:I.warningMessage},this._getErrorMessage()))}_renderDirectionsContainerContent(){const{viewModel:{layer:e,state:t}}=this,s="routing"===t;return"error"===t?this._renderWarningCard():s?this._renderLoader():a(e.directionLines)?U("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(I.summary,this._saveLayer.opened&&I.buttonDisabled),key:"esri-directions__summary",role:"group"},this._renderCosts(),this._renderRouteActions(),this._renderManeuverSections()):U("div",{key:"esri-directions__placeholder",class:I.emptyContent},this._renderPlaceholder(),U(B,{class:I.message,level:this.headingLevel},this.messages.directionsPlaceholder))}_renderPlaceholder(){return U("svg",{class:I.emptyIllustration,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256"},U("path",{fill:"currentcolor",d:"M192 36c-15.477 0-24 6.034-24 16.99v45.822l24 24 24-24v-45.82C216 42.033 207.477 36 192 36zm20 61.155l-20 20-20-20V52.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM192 52a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zM92 140.99C92 130.035 83.477 124 68 124s-24 6.034-24 16.99v45.822l24 24 24-24zm-4 44.165l-20 20-20-20V140.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM68 140a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zm84-44h16v4h-16zm-24 80h4v12h-12v-4h8zm0-28h4v16h-4zm0-52h12v4h-8v8h-4zm0 24h4v16h-4zm-36 64h16v4H92z"}))}_renderMessage(e){return U(B,{level:this.headingLevel},e)}_renderRouteActions(){return U("div",{class:I.routeActions},U("button",{"aria-label":this.messages.clearRoute,class:this.classes(I.clearRouteButton,I.button,I.buttonTertiary),tabIndex:0,onclick:this._handleClearRouteClick,bind:this,type:"button"},this.messages.clearRoute))}_getSections(){const{directionPoints:e,directionLines:t,stops:s}=this.viewModel.layer;if(n(e)||n(t))return null;const o=[];let i=null;for(const r of e){const{objectId:e,stopId:l}=r;if(a(l)){const e=s.find((e=>e.objectId===l)),t=0===o.length;(n(i)||i.stop!==e)&&(i={stop:e,directions:[],open:t},o.push(i));continue}if(n(i))continue;const c=t.find((t=>t.directionPointId===e));n(c)||i.directions.push({directionPoint:r,directionLine:c})}return o}_renderManeuverSections(){return n(this._sections)?null:U("div",{class:I.maneuvers,role:"group"},this._sections.map(((e,t)=>{const{open:s}=e;let o;e.directions.length>0&&s&&(o=U("ol",{class:I.maneuverList},e.directions.map((e=>this._renderManeuver(e)))));const i=l(this._sections).length>2,r=t===l(this._sections).length-1,n={[I.collapsibleSection]:i},a={[I.openIcon]:!s,[I.closeIcon]:s};let c;if(i&&!r){const t=s?this.messagesCommon.open:this.messagesCommon.close;c=U("header",{class:this.classes(I.maneuverSectionHeader,I.maneuverSectionToggle),key:I.maneuverSectionHeader},U("div",{"aria-expanded":s.toString(),"aria-label":t,bind:this,class:I.maneuverSectionHeaderButton,"data-maneuver-section":e,onkeydown:this._handleSectionToggle,onclick:this._handleSectionToggle,role:"button",tabIndex:0,title:t},U(B,{class:I.maneuverSectionTitle,level:this.headingLevel},e.stop.name),U("span",{"aria-hidden":"true",class:this.classes(a)})))}else c=U("header",{class:I.maneuverSectionHeader,key:I.maneuverSectionHeader},U(B,{class:I.maneuverSectionTitle,level:this.headingLevel},e.stop.name));return U("section",{class:this.classes(I.maneuverSection,n),key:t},c,o)})))}_handleSectionToggle(e){const t=e.currentTarget["data-maneuver-section"];t.open=!t.open}_renderCosts(){const e=this._getCostSummary(),{directionPoints:t}=this.viewModel.layer;if(n(t)||n(e))return null;const s=t.getItemAt(t.length-1).arrivalTime,{primary:o,secondary:i}=e,{eta:r,etaTemplate:l,primaryCosts:c,secondaryCosts:d,zoomToRoute:h}=this.messages,u=$("short-time"),p=a(s)?`<strong>${E(s,u)}</strong>`:null,v=a(s)?`${F(s)}`:null,m=z(l,{time:p,gmt:v});return U("div",{"aria-label":h,bind:this,class:I.directionCosts,onkeydown:this._handleSummaryInteraction,onclick:this._handleSummaryInteraction,role:"button",tabIndex:0,title:h},U("div",{class:I.costsDetails,role:"group"},U("div",{class:I.primaryCosts,title:c},o),U("div",{class:I.verticalSplitter}),U("div",{class:I.secondaryCosts,title:d},i)),U("div",{innerHTML:m,title:r}))}_handleSummaryInteraction(){this._activeManeuver=null,this._focusedManeuver=null,this.viewModel.clearHighlights(),this.zoomToRoute()}_getErrorMessage(){const{messages:e,viewModel:{lastError:t}}=this;if(a(t))switch(t.name){case"directions-view-model:unable-to-route":return e.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return e.errors.unableToLoadServiceMetadata}return e.errors.unknownError}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){e.viewModel.defaultSources.forEach((e=>{e.autoNavigate=!1}))}_applyLocatorSourceOverrides({allSources:e}){for(const t of e)"url"in t&&t.url&&(t.locationType??(t.locationType="street"),L(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=R))}_acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const s=this._stopsToSearches.get(e);return s.view=t,this._overrideDefaultSources(s),s}const s=new S({view:t,resultGraphicEnabled:!1,popupEnabled:!1,...this.searchProperties});return this._normalizeSearchSources(s),this._handles.add([p((()=>s.allSources),"change",(()=>this._normalizeSearchSources(s))),s.on("select-result",(()=>{e.geometry=s.selectedResult.feature.geometry,e.name=s.selectedResult.name,this._processStops()})),s.on("search-focus",(()=>this._handleStopInputFocus(s,e))),s.on("search-blur",(()=>this._handleStopInputBlur(s,e))),s.on("search-clear",(()=>{e.geometry=null,e.name=null}))],s),this._stopsToSearches.set(e,s),s}_disposeSearch(e){this._stopsToSearches.has(e)&&(this._stopsToSearches.get(e).destroy(),this._stopsToSearches.delete(e))}_processStops(){this._getDirections()}_renderManeuver(e){const t="",{directionsLengthUnits:s}=this.viewModel.routeParameters,{directionPoint:o,directionLine:i}=e,{distance:r,duration:n}=i,{messages:l,messagesUnits:d}=this,h=b(l,d,c(r,0),{fromUnits:"meters",toUnits:s}),u=C(c(n,0),"minutes"),p=h&&u?`${h}&nbsp;&middot;&nbsp;${u}`:`${h}${u}`,v=this._getFormattedManeuverText(o),{objectId:m,directionPointType:_}=o,g=D(_),y=`esri-directions__maneuver-${m}`,S=`esri-directions__cumulative-costs-${m}`,w=`esri-directions__intermediate-costs-${m}`,M={[I.maneuverActive]:this._activeManeuver===i};return U("li",{"aria-labelledby":`${y} ${S} ${w}`,bind:this,class:this.classes(I.maneuver,M),"data-maneuver":i,key:i,onclick:this._handleManeuverClick,onkeydown:this._handleManeuverClick,onfocus:this._handleManeuverFocus,onmouseover:this._handleManeuverMouseOver,onmouseout:this._handleManeuverMouseOut,onblur:this._handleManeuverBlur,tabIndex:0},a(g)&&U("img",{alt:"",class:I.maneuverIcon,src:g}),U("div",{class:I.maneuverCostsContainer},U("span",{id:y,innerHTML:c(v,"")}),U("div",{class:I.maneuverCosts},U("div",{class:I.horizontalSplitter}),U("div",{id:S,class:I.cumulativeCost,innerHTML:t,title:l.cumulativeCosts}),U("div",{id:w,class:I.intermediateCost,innerHTML:p,title:l.intermediateCosts}))))}_handleManeuverClick(e){const t=e.currentTarget["data-maneuver"];if(this._activeManeuver===t)return this._activeManeuver=null,void this.zoomToRoute();this._activeManeuver=t;const{geometry:s}=t;this.viewModel.centerAt(s),this.viewModel.highlight(t)}_handleManeuverMouseOver(e){if(this._activeManeuver||this._focusedManeuver)return;const t=e.currentTarget["data-maneuver"];this.viewModel.highlight(t)}_handleManeuverMouseOut(){this._activeManeuver||this._focusedManeuver||this.viewModel.clearHighlights()}_handleManeuverBlur(){this._activeManeuver||(this._focusedManeuver=null,this.viewModel.clearHighlights())}_handleManeuverFocus(e){if(this._activeManeuver)return;const t=e.currentTarget["data-maneuver"];this._focusedManeuver=t,this.viewModel.highlight(t)}_getFormattedManeuverText(e){const{displayText:t,name:s,intersectingName:o}=e;if(n(t))return"";let i=t;return a(s)&&i.includes(s)&&(i=i.replace(s,`<strong>${s}</strong>`)),a(o)&&i.includes(o)&&(i=i.replace(o,`<strong>${o}</strong>`)),i}_getCostSummary(){const{viewModel:{impedanceAttribute:e,layer:{routeInfo:t},routeParameters:s}}=this;if(n(e)||n(t))return null;let{totalDuration:o,totalDistance:i}=t;const{directionsLengthUnits:r}=s;i=a(i)?i:0,o=a(o)?o:0;const l=b(this.messages,this.messagesUnits,i,{fromUnits:"meters",toUnits:r}),c=C(o,"minutes"),[d,h]=T(e.units)?[c,l]:[l,c];return{primary:d,secondary:h}}async _getDirections(){if(!(this.viewModel.layer.stops.filter((e=>a(e.geometry))).length<2))try{await this.viewModel.getDirections()}catch{}}};e([v("viewModel.apiKey")],G.prototype,"apiKey",void 0),e([v("viewModel.goToOverride")],G.prototype,"goToOverride",void 0),e([m()],G.prototype,"headingLevel",void 0),e([m()],G.prototype,"iconClass",void 0),e([m({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],G.prototype,"label",void 0),e([v("viewModel.lastRoute")],G.prototype,"lastRoute",void 0),e([v("viewModel.layer")],G.prototype,"layer",void 0),e([v("viewModel.maxStops")],G.prototype,"maxStops",void 0),e([m(),H("esri/widgets/Directions/t9n/Directions")],G.prototype,"messages",void 0),e([m(),H("esri/t9n/common")],G.prototype,"messagesCommon",void 0),e([m(),H("esri/core/t9n/Units")],G.prototype,"messagesUnits",void 0),e([m()],G.prototype,"routeServiceUrl",null),e([m()],G.prototype,"routeSymbol",null),e([m()],G.prototype,"searchProperties",void 0),e([m()],G.prototype,"stopSymbols",null),e([v("viewModel.view")],G.prototype,"view",void 0),e([m({type:M})],G.prototype,"viewModel",void 0),e([v("viewModel.getDirections")],G.prototype,"getDirections",null),e([v("viewModel.zoomToRoute")],G.prototype,"zoomToRoute",null),e([A()],G.prototype,"_handleStopIconClick",null),e([A()],G.prototype,"_handleClearRouteClick",null),e([A()],G.prototype,"_handleReverseStops",null),e([A()],G.prototype,"_handleRemoveStop",null),e([A()],G.prototype,"_handleSectionToggle",null),e([A()],G.prototype,"_handleSummaryInteraction",null),e([A()],G.prototype,"_handleManeuverClick",null),G=e([_("esri.widgets.Directions")],G);const J=G;export{J as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{deprecatedProperty as t}from"../core/deprecate.js";import{on as s,pausable as i}from"../core/events.js";import o from"../core/Handles.js";import r from"../core/Logger.js";import{isNone as n,isSome as a,unwrap as l,unwrapOrValue as c}from"../core/maybe.js";import{watch as d,initial as u,when as h,on as p}from"../core/reactiveUtils.js";import{aliasOf as v}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as m}from"../core/accessorSupport/decorators/cast.js";import{property as _}from"../core/accessorSupport/decorators/property.js";import{subclass as g}from"../core/accessorSupport/decorators/subclass.js";import y from"../rest/support/Stop.js";import S from"../symbols/SimpleMarkerSymbol.js";import w from"./Search.js";import M from"./Widget.js";import b from"./Directions/DirectionsViewModel.js";import{SaveLayer as f}from"./Directions/components/SaveLayer.js";import{formatDistance as C,formatTime as T,isTimeUnits as k}from"./Directions/support/directionsUtils.js";import{DepartureTime as D,CSS as I,getIconPath as L}from"./Directions/support/resources.js";import{isArcGISWorldGeocoder as R,meteredArcGISLocatorUrl as P}from"./Search/support/locatorUtils.js";import B from"./support/DatePicker.js";import{Heading as A,incrementHeadingLevel as j}from"./support/Heading.js";import x from"./support/TimePicker.js";import{accessibleHandler as E}from"./support/decorators/accessibleHandler.js";import{messageBundle as H}from"./support/decorators/messageBundle.js";import{tsx as U}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import O from"sortablejs";import{substitute as z}from"../intl/substitute.js";import{formatDate as $,convertDateFormatToIntlOptions as N}from"../intl/date.js";import{formatNumber as F}from"../intl/number.js";const V={departureTime:!0,layerDetails:!0,printButton:!1,saveAsButton:!0,saveButton:!0,stops:!0,traveMode:!0};function W(e){const t=e.getTimezoneOffset(),s=t>0?"-":"+",i=60,o=Math.abs(Math.floor(t/i)),r=Math.abs(Math.floor(t)%i),n={minimumIntegerDigits:2};return`GMT${s}${F(o,n)}${F(r,n)}`}function q(e){return!!e.composedPath?.().find((e=>e.classList?.contains("esri-search__suggestions-list")))}const K={awaitingViewClickStop:"awaiting-view-click-stop"},Y=100,G=500,J=r.getLogger("esri.widgets.Directions");let Q=class extends M{constructor(e,t){super(e,t),this._autoStopRemovalDelay=Y,this._departureTime=D.NOW,this._datePicker=new B,this._handles=new o,this._newPlaceholderStop=null,this._pointerPressedSearchSuggestionStop=null,this._saveAsButtonNode=null,this._saveLayer=new f,this._sections=null,this._stopsToSearches=new Map,this._timePicker=new x,this.apiKey=null,this.goToOverride=null,this.headingLevel=2,this.iconClass=I.widgetIcon,this.label=void 0,this.lastRoute=null,this.layer=null,this.maxStops=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.searchProperties=null,this.view=null,this.viewModel=new b,this.visibleElements={...V},this._setUpDragAndDropStops=e=>{this._sortable=O.create(e,{draggable:`.${I.validStopRow}`,ghostClass:I.stopRowGhost,handle:`.${I.stopHandle}`,onEnd:this._handleStopInputDragEnd})},this._handleDragHandlePointerDown=()=>this.viewModel.layer.stops.forEach((e=>this._acquireSearch(e).activeMenu="none")),this._handleStopInputDragEnd=({oldIndex:e,newIndex:t,target:s})=>{if(e===t)return;const{children:i}=s,o=i[t],r=i[e],n=t-e<0;s.insertBefore(o,n?r.nextElementSibling:r);const a=this.viewModel.layer.stops;a.reorder(a.getItemAt(e),t);for(const l of a)l.sequence=null;this._getDirections()}}initialize(){this.own([d((()=>this.viewModel.layer.routeInfo),(()=>{this._activeStop=null,this._activeManeuver=null,this._focusedManeuver=null,this._sections=this._getSections(),this.scheduleRender()}),u),h((()=>this.view),((e,t)=>{if(t&&(this._viewClickHandle=null,this._handles.remove(t)),e){const t=this._prepPointerDownUpClick(),i=this._prepViewClick();t.pause(),i.pause(),this._handles.add([s(e.surface,"mousedown",(()=>this._autoStopRemovalDelay=G)),s(e.surface,"mouseup",(()=>this._autoStopRemovalDelay=Y)),t,i],this.view.surface),this._pointerDownUpHandle=t,this._viewClickHandle=i}}),u),h((()=>n(this.viewModel.serviceDescription)),(()=>{try{this.viewModel.load()}catch{}}),u),d((()=>this._saveLayer.state),(()=>{this.scheduleRender()}))])}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-link.js"),import("@esri/calcite-components/dist/components/calcite-popover.js")])}destroy(){this._datePicker.destroy(),this._timePicker.destroy();for(const e of this._stopsToSearches.values())e.destroy();this._sortable&&this._sortable.destroy()}set routeServiceUrl(e){t(J,"routeServiceUrl",{replacement:"viewModel.layer.url",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.url=e}get routeServiceUrl(){return t(J,"routeServiceUrl",{replacement:"viewModel.layer.url",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.url}set routeSymbol(e){t(J,"routeSymbol",{replacement:"viewModel.layer.defaultSymbols.directionLines",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.defaultSymbols.directionLines=e}get routeSymbol(){return t(J,"routeSymbol",{replacement:"viewModel.layer.defaultSymbols.directionLines",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.defaultSymbols.directionLines}set stopSymbols(e){t(J,"stopSymbols",{replacement:"viewModel.layer.defaultSymbols.stops",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.defaultSymbols.stops=e}get stopSymbols(){return t(J,"stopSymbols",{replacement:"viewModel.layer.defaultSymbols.stops",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.defaultSymbols.stops}castVisibleElements(e){return{...V,...e}}getDirections(){return null}render(){return U("div",{class:this.classes(I.base,I.scroller)},this._renderPanelContent())}save(){return this.viewModel.layer.save()}saveAs(e,t={}){return this.viewModel.layer.saveAs(e,t)}zoomToRoute(){}_renderPanelContent(){const{viewModel:{serviceDescription:e,state:t}}=this,s="initializing"===t,i="error"===t&&!e,o="unauthenticated"===t,r={[I.panelContentLoading]:s,[I.panelContentError]:i,[I.panelContentSignIn]:o},n=s?"presentation":"group",a=o?this._renderSignIn():i?this._renderMessage(this._getErrorMessage()):s?this._renderLoader():this._renderReadyContent();return U("div",{class:this.classes(I.panelContent,r),role:n},a)}_renderReadyContent(){return[this._renderStopsContainer(),this._renderTravelModeOptions(),this._renderDepartureTimeControls(),this._renderSaveContainer(),this._renderSectionSplitter(),this._renderDirectionsContainer()]}_renderSignIn(){return U("div",{key:"sign-in",class:I.signInContent},U(A,{class:I.contentTitle,level:this.headingLevel},this.messages.widgetLabel),this._renderPlaceholder(),U(A,{level:j(this.headingLevel)},this.messages.signInRequired),U("button",{class:this.classes(I.button,I.buttonSecondary,I.signInButton),tabIndex:0,onclick:this._handleSignInClick,bind:this,type:"button"},this.messagesCommon.auth.signIn))}_handleSignInClick(){this.viewModel.load().catch((()=>{}))}_renderTravelModeOptions(){if(!this.visibleElements.traveMode)return null;const{selectedTravelMode:e,travelModes:t}=this.viewModel;if(0===t.length)return null;const s=a(e)?e.name:this.messages.travelMode;return U("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(I.travelMode,this._saveLayer.opened&&I.buttonDisabled),key:"esri-directions__travel-mode-controls",role:"group"},U("select",{"aria-label":s,bind:this,class:this.classes(I.travelModeSelect,I.select),key:"esri-directions__travel-mode-options",onchange:this._handleTravelModeChange,title:s},t.map((t=>{const s=a(e)&&t.id===e.id;return U("option",{key:`esri-directions__travel-mode-${t.id}`,"data-mode":t,selected:s,value:t.id},t.name)}))))}_handleTravelModeChange(e){const t=e.currentTarget,s=t.item(t.selectedIndex);this.viewModel.selectedTravelMode=s["data-mode"],this._getDirections()}_renderStopsContainer(){return this.visibleElements.stops?U("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(I.section,this._saveLayer.opened&&I.buttonDisabled),key:"esri-directions__stops-container",role:"group"},this._renderStops()):null}_renderDepartureTimeControls(){if(!this.visibleElements.departureTime)return null;const e=this._departureTime,{messages:t}=this,s=t.departureTime;return U("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(I.departureTime,this._saveLayer.opened&&I.buttonDisabled),key:"esri-directions__departure-time-controls",role:"group"},U("select",{"aria-label":s,bind:this,class:this.classes(I.departureTimeSelect,I.select),onchange:this._handleDepartureOptionChange,title:s},U("option",{value:D.NOW,selected:e===D.NOW},t.leaveNow),U("option",{value:D.DEPART_BY,selected:e===D.DEPART_BY},t.departBy),U("option",{value:D.UNSPECIFIED,selected:e===D.UNSPECIFIED},t.timeUnspecified)),e===D.DEPART_BY?this._renderTimeControls():null)}_renderStops(){const e=this.viewModel.layer.stops;let t=0;for(const i of this._stopsToSearches.keys())e.includes(i)||this._disposeSearch(i);for(const i of e){const e=this._acquireSearch(i);"none"!==e.activeMenu&&(t+=1),a(i.name)&&(e.searchTerm=i.name)}const s=e.toArray().map(((s,i)=>{const o=e.length,r=i>1&&n(s.geometry),l={[I.stopsIcon]:i>=0&&i<o-1,[I.lastStopIcon]:i===o-1},c={[I.lastStopIconContainer]:i===o-1},d={[I.validStopRow]:!r},u=e.getItemAt(i+1),h=u&&a(u.geometry),p=i===o-1,v=i===o-2,m=2===o&&0===i||o>2&&!p&&!v||o>2&&v&&h||o>2&&p&&n(s.geometry),_=o<3,g=this._acquireSearch(s),{messages:y}=this,{removeStop:S,reverseStops:w,unlocated:M}=y,b=z(y.stopLabelTemplate,{number:i+1,label:a(s.geometry)?s.name:M}),f=`${this.id}__stop--${i}`,C=!!g.searchTerm&&!!g.selectedResult&&a(s.geometry)&&g.selectedResult.name===s.name,T={zIndex:"none"!==g.activeMenu?""+t--:""};return U("li",{"aria-label":b,afterCreate:this._handleStopFieldCreation,bind:this,class:this.classes(I.stopRow,d),id:f,key:i,"data-stop-index":i,styles:T},U("div",{class:I.stopHandle},U("span",{"aria-hidden":"true",class:this.classes(I.stopIcon,I.handleIcon,I.stopHandleIcon,I.interactiveStopIcon),onpointerdown:this._handleDragHandlePointerDown}),U("div",{bind:this,"aria-labelledby":f,class:this.classes(I.stopIconContainer,c),"data-stop-index":i,onclick:this._handleStopIconClick,onkeydown:this._handleStopIconClick,role:"button"},U("span",{class:this.classes(I.stopIcon,l),tabindex:C?"0":null}))),U("div",{class:I.stopInput},g.render()),U("div",{class:I.stopOptions,role:"group"},U("div",{"aria-label":S,class:I.removeStopButton,bind:this,"data-stop-index":i,hidden:_,onkeydown:this._handleRemoveStop,onclick:this._handleRemoveStop,role:"button",tabIndex:0,title:S},U("span",{"aria-hidden":"true",class:this.classes(I.stopIcon,I.removeStop,I.removeStopIcon,I.interactiveStopIcon)}),U("span",{class:I.screenReaderText},"removeStopTitle")),U("div",{"aria-label":w,class:I.reverseStops,bind:this,hidden:m,onkeydown:this._handleReverseStops,onclick:this._handleReverseStops,role:"button",tabIndex:0,title:w},U("span",{"aria-hidden":"true",class:this.classes(I.stopIcon,I.reverseStopIcon,I.interactiveStopIcon)}),U("span",{class:I.screenReaderText},"removeStopTitle"))))}));return U("div",null,U("ol",{class:I.stops,role:"group",afterCreate:this._setUpDragAndDropStops},s),U("div",{class:I.toolbarSection},U("div",{class:I.toolbarButtons},this._renderAddStop())))}_renderAddStop(){const e=this.viewModel.layer.stops.length>=this.maxStops;return U("calcite-button",{appearance:"outline",class:I.addStopButton,color:"neutral",disabled:e,"icon-start":"plus",key:I.addStopButton,onclick:()=>{this._addNewPlaceholder()},text:this.messages.addStop,width:"half"},this.messages.addStop)}_handleStopIconClick(e){const t=e.currentTarget["data-stop-index"],s=this.viewModel.layer.stops.getItemAt(t);s&&a(s.geometry)&&this._centerAtStop(s)}_handleClearRouteClick(){this.viewModel.reset()}_centerAtStop(e){this.viewModel.centerAt(e)}_handleStopFieldCreation(e){const t=this._newPlaceholderStop;if(!t)return;const s=e["data-stop-index"],i=this.viewModel.layer.stops.getItemAt(s);if(t===i){const e=this._acquireSearch(i);e.when((()=>{this.renderNow(),e.focus()}))}this._newPlaceholderStop=null}_handleStopInputBlur(e,t){if(this._saveLayer.opened)return;this._handles.remove(K.awaitingViewClickStop),this.view.cursor=this._previousCursor;if(!!e.selectedResult&&a(t.geometry)&&a(e.selectedResult?.feature.geometry)&&t.geometry===e.selectedResult?.feature.geometry)return void this._pointerDownUpHandle.pause();const s=n(t.geometry)&&n(e.selectedResult?.feature.geometry),i=a(t.geometry)&&a(e.selectedResult?.feature.geometry)&&t.geometry!==e.selectedResult.feature.geometry;if((s||i)&&"none"===e.activeMenu&&e.searchTerm)return e.search(),void this._pointerDownUpHandle.pause();e.searchTerm||(this._viewClickHandle.resume(),clearTimeout(this._autoStopRemovalTimeoutId),this._autoStopRemovalTimeoutId=setTimeout((()=>{this.destroyed||(this._viewClickHandle.pause(),"searching"!==e.viewModel.state?this._pointerPressedSearchSuggestionStop||(a(t.geometry)&&(t.geometry=null,this._getDirections()),this.scheduleRender()):this._pointerDownUpHandle.pause())}),this._autoStopRemovalDelay))}_handleStopInputFocus(e,t){if(this._pointerDownUpHandle.resume(),this._handles.has(K.awaitingViewClickStop))return;const{view:s,view:{cursor:i}}=this;this._previousCursor=i,this._handles.add(d((()=>e.searchTerm),(t=>{e.destroyed||(s.cursor=0===t.length?"copy":i)}),u),K.awaitingViewClickStop),this._activeStop=t}_prepViewClick(){const{view:e}=this.viewModel,t=i(e,"click",this._handleViewClick.bind(this)),s=i(e.surface,"click",(()=>{clearTimeout(this._autoStopRemovalTimeoutId),s.pause()}));return{remove(){s.remove(),t.remove()},pause(){s.pause(),t.pause()},resume(){s.resume(),t.resume()}}}_prepPointerDownUpClick(){const e=i(document,"pointerdown",(e=>{this._pointerPressedSearchSuggestionStop=q(e)?this._activeStop:null})),t=i(document,"pointerup",(e=>{this._pointerDownUpHandle.pause();const t=q(e),s=this._activeStop;t||s!==this._pointerPressedSearchSuggestionStop||this._removeStop(s),this.scheduleRender(),this._pointerPressedSearchSuggestionStop=t?s:null}));return{remove(){t.remove(),e.remove()},pause(){t.pause(),e.pause()},resume(){e.resume()}}}_handleViewClick(e){const t=this._stopsToSearches.get(this._activeStop);t&&!t.searchTerm&&(t.search(e.mapPoint).then((e=>{const s=e.results[0].results[0],{feature:i,name:o}=s;this._activeStop.geometry=i.geometry,this._activeStop.name=o,t.searchTerm=o})),this.scheduleRender()),this._viewClickHandle.pause(),clearTimeout(this._autoStopRemovalTimeoutId)}_addNewPlaceholder(){if(this._pointerDownUpHandle.pause(),this._newPlaceholderStop)return;const e=new y({symbol:new S});this.viewModel.layer.stops.add(e),this._newPlaceholderStop=e}_handleReverseStops(){this._reverseStops()}_reverseStops(){this.viewModel.layer.stops.reverse();for(const e of this.viewModel.layer.stops)e.sequence=null;this._getDirections()}_handleRemoveStop(e){const t=e.currentTarget["data-stop-index"],s=this.viewModel.layer.stops.getItemAt(t);this._removeStop(s),(a(s.geometry)||n(this.viewModel.layer.routeInfo))&&this._getDirections()}_removeStop(e){this.viewModel.layer.stops.length<=2||(this._disposeSearch(e),this.viewModel.layer.stops.remove(e))}_handleDepartureOptionChange(e){const t=e.currentTarget,s=t.item(t.selectedIndex);s.value===D.NOW?(this._departureTime=D.NOW,this.viewModel.departureTime=D.NOW,this._handles.remove("departure-time-controls"),this._getDirections()):s.value===D.DEPART_BY?(this._departureTime=D.DEPART_BY,this._handles.add(d((()=>[this._datePicker.value,this._timePicker.value]),(()=>{this._updateDepartureTime(),this._getDirections()}),u),"departure-time-controls")):(this._departureTime=D.UNSPECIFIED,this.viewModel.departureTime=null,this._getDirections())}_updateDepartureTime(){const e=this._datePicker.value,t=this._timePicker.value;e&&t&&(this.viewModel.departureTime=new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes()))}_renderTimeControls(){return U("div",{class:I.departureTimeControls,key:"esri-directions__time-controls",role:"group"},this._datePicker.render(),this._timePicker.render())}_renderSectionSplitter(){return U("div",{class:I.sectionSplitter})}_renderSaveContainer(){const{saveButton:e,saveAsButton:t,printButton:s,layerDetails:i}=this.visibleElements;return e||t||s||i?U("div",{class:I.saveSection,key:I.saveSection},this._renderSaveButtons(),this._renderRouteLayerDetailsLink()):null}_renderSaveButtons(){const{saveButton:e,saveAsButton:t,printButton:s}=this.visibleElements;return e||t||s?U("div",{class:I.saveButtons,key:I.saveButtons},this._renderSaveButton(),this._renderSaveAsButton(),this._renderPrintButton()):null}_renderSaveButton(){if(!this.visibleElements.saveButton)return null;const e=this.viewModel.layer.portalItem?.itemControl,t=a(this.viewModel.layer.routeInfo)&&("admin"===e||"update"===e);return U("calcite-button",{appearance:"outline",class:I.saveButton,color:"neutral",disabled:!t,"icon-start":"save",key:I.saveButton,onclick:()=>{this._handleSaveButtonClick()},text:this.messagesCommon.save,width:"full"},this.messagesCommon.save)}_renderSaveAsButton(){if(!this.visibleElements.saveAsButton)return null;const e=n(this.viewModel.layer.routeInfo);return U("div",{class:I.saveAsButtonPopover,key:I.saveAsButtonPopover},U("calcite-button",{afterCreate:e=>{this._saveAsButtonNode=e},appearance:"outline",class:I.saveAsButton,color:"neutral",disabled:e,"icon-start":"duplicate",key:I.saveAsButton,onclick:()=>this._handleSaveAsButtonClick(),text:this.messagesCommon.saveAs,width:"full"},this.messagesCommon.saveAs),U("calcite-popover",{label:this._saveLayer.label,open:this._saveLayer.opened,"overlay-positioning":"fixed",referenceElement:l(this._saveAsButtonNode)},this._saveLayer.render()))}_handleSaveAsButtonClick(){this._saveLayer.opened?this._saveLayer.close():this._saveLayer.open(this.viewModel.layer)}_renderPrintButton(){return this.visibleElements.printButton?U("calcite-button",{appearance:"outline",class:I.printButton,color:"neutral","icon-start":"print",key:I.printButton,text:this.messagesCommon.print}):null}_renderRouteLayerDetailsLink(){if(!this.visibleElements.layerDetails)return null;const{portalItem:e}=this.viewModel.layer;if(!e)return null;const{id:t,portal:{url:s}}=e,i=`${s}/home/item.html?id=${t}`;return U("calcite-link",{class:I.layerDetailsLink,href:i,key:I.layerDetailsLink,target:"_blank"},this.messages.viewLayerDetails)}_handleSaveButtonClick(){this.viewModel.layer.save()}_renderDirectionsContainer(){return U("div",{class:this.classes(I.directionsSection,I.section),key:"esri-directions__container"},this._renderDirectionsContainerContent())}_renderLoader(){return U("div",{class:I.loader,key:"loader"})}_renderWarningCard(){return U("div",{class:I.warningCard,role:"alert"},U("div",{class:I.warningHeader},U("span",{class:I.warningIcon,"aria-hidden":"true"}),U(A,{class:I.warningHeading,level:this.headingLevel},this.messagesCommon.warning)),U("div",{class:I.warningMessage},this._getErrorMessage()))}_renderDirectionsContainerContent(){const{viewModel:{layer:e,state:t}}=this,s="routing"===t;return"error"===t?this._renderWarningCard():s?this._renderLoader():a(e.directionLines)?U("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(I.summary,this._saveLayer.opened&&I.buttonDisabled),key:"esri-directions__summary",role:"group"},this._renderCosts(),this._renderRouteActions(),this._renderManeuverSections()):U("div",{key:"esri-directions__placeholder",class:I.emptyContent},this._renderPlaceholder(),U(A,{class:I.message,level:this.headingLevel},this.messages.directionsPlaceholder))}_renderPlaceholder(){return U("svg",{class:I.emptyIllustration,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256"},U("path",{fill:"currentcolor",d:"M192 36c-15.477 0-24 6.034-24 16.99v45.822l24 24 24-24v-45.82C216 42.033 207.477 36 192 36zm20 61.155l-20 20-20-20V52.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM192 52a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zM92 140.99C92 130.035 83.477 124 68 124s-24 6.034-24 16.99v45.822l24 24 24-24zm-4 44.165l-20 20-20-20V140.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM68 140a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zm84-44h16v4h-16zm-24 80h4v12h-12v-4h8zm0-28h4v16h-4zm0-52h12v4h-8v8h-4zm0 24h4v16h-4zm-36 64h16v4H92z"}))}_renderMessage(e){return U(A,{level:this.headingLevel},e)}_renderRouteActions(){return U("div",{class:I.routeActions},U("button",{"aria-label":this.messages.clearRoute,class:this.classes(I.clearRouteButton,I.button,I.buttonTertiary),tabIndex:0,onclick:this._handleClearRouteClick,bind:this,type:"button"},this.messages.clearRoute))}_getSections(){const{directionPoints:e,directionLines:t,stops:s}=this.viewModel.layer;if(n(e)||n(t))return null;const i=[];let o=null;for(const r of e){const{objectId:e,stopId:l}=r;if(a(l)){const e=s.find((e=>e.objectId===l)),t=0===i.length;(n(o)||o.stop!==e)&&(o={stop:e,directions:[],open:t},i.push(o));continue}if(n(o))continue;const c=t.find((t=>t.directionPointId===e));n(c)||o.directions.push({directionPoint:r,directionLine:c})}return i}_renderManeuverSections(){return n(this._sections)?null:U("div",{class:I.maneuvers,role:"group"},this._sections.map(((e,t)=>{const{open:s}=e;let i;e.directions.length>0&&s&&(i=U("ol",{class:I.maneuverList},e.directions.map((e=>this._renderManeuver(e)))));const o=l(this._sections).length>2,r=t===l(this._sections).length-1,n={[I.collapsibleSection]:o},a={[I.openIcon]:!s,[I.closeIcon]:s};let c;if(o&&!r){const t=s?this.messagesCommon.open:this.messagesCommon.close;c=U("header",{class:this.classes(I.maneuverSectionHeader,I.maneuverSectionToggle),key:I.maneuverSectionHeader},U("div",{"aria-expanded":s.toString(),"aria-label":t,bind:this,class:I.maneuverSectionHeaderButton,"data-maneuver-section":e,onkeydown:this._handleSectionToggle,onclick:this._handleSectionToggle,role:"button",tabIndex:0,title:t},U(A,{class:I.maneuverSectionTitle,level:this.headingLevel},e.stop.name),U("span",{"aria-hidden":"true",class:this.classes(a)})))}else c=U("header",{class:I.maneuverSectionHeader,key:I.maneuverSectionHeader},U(A,{class:I.maneuverSectionTitle,level:this.headingLevel},e.stop.name));return U("section",{class:this.classes(I.maneuverSection,n),key:t},c,i)})))}_handleSectionToggle(e){const t=e.currentTarget["data-maneuver-section"];t.open=!t.open}_renderCosts(){const e=this._getCostSummary(),{directionPoints:t}=this.viewModel.layer;if(n(t)||n(e))return null;const s=t.getItemAt(t.length-1).arrivalTime,{primary:i,secondary:o}=e,{eta:r,etaTemplate:l,primaryCosts:c,secondaryCosts:d,zoomToRoute:u}=this.messages,h=N("short-time"),p=a(s)?`<strong>${$(s,h)}</strong>`:null,v=a(s)?`${W(s)}`:null,m=z(l,{time:p,gmt:v});return U("div",{"aria-label":u,bind:this,class:I.directionCosts,onkeydown:this._handleSummaryInteraction,onclick:this._handleSummaryInteraction,role:"button",tabIndex:0,title:u},U("div",{class:I.costsDetails,role:"group"},U("div",{class:I.primaryCosts,title:c},i),U("div",{class:I.verticalSplitter}),U("div",{class:I.secondaryCosts,title:d},o)),U("div",{innerHTML:m,title:r}))}_handleSummaryInteraction(){this._activeManeuver=null,this._focusedManeuver=null,this.viewModel.clearHighlights(),this.zoomToRoute()}_getErrorMessage(){const{messages:e,viewModel:{lastError:t}}=this;if(a(t))switch(t.name){case"directions-view-model:unable-to-route":return e.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return e.errors.unableToLoadServiceMetadata}return e.errors.unknownError}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){e.viewModel.defaultSources.forEach((e=>{e.autoNavigate=!1}))}_applyLocatorSourceOverrides({allSources:e}){for(const t of e)"url"in t&&t.url&&(t.locationType??(t.locationType="street"),R(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=P))}_acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const s=this._stopsToSearches.get(e);return s.view=t,this._overrideDefaultSources(s),s}const s=new w({view:t,resultGraphicEnabled:!1,popupEnabled:!1,...this.searchProperties});return this._normalizeSearchSources(s),this._handles.add([p((()=>s.allSources),"change",(()=>this._normalizeSearchSources(s))),s.on("select-result",(()=>{e.geometry=s.selectedResult.feature.geometry,e.name=s.selectedResult.name,this._getDirections()})),s.on("search-focus",(()=>this._handleStopInputFocus(s,e))),s.on("search-blur",(()=>this._handleStopInputBlur(s,e))),s.on("search-clear",(()=>{e.geometry=null,e.name=null,this._activeStop=e,this.viewModel.layer.removeResult()}))],s),this._stopsToSearches.set(e,s),s}_disposeSearch(e){this._stopsToSearches.has(e)&&(this._stopsToSearches.get(e).destroy(),this._stopsToSearches.delete(e))}_renderManeuver(e){const t="",{directionsLengthUnits:s}=this.viewModel.routeParameters,{directionPoint:i,directionLine:o}=e,{distance:r,duration:n}=o,{messages:l,messagesUnits:d}=this,u=C(l,d,c(r,0),{fromUnits:"meters",toUnits:s}),h=T(c(n,0),"minutes"),p=u&&h?`${u}&nbsp;&middot;&nbsp;${h}`:`${u}${h}`,v=this._getFormattedManeuverText(i),{objectId:m,directionPointType:_}=i,g=L(_),y=`esri-directions__maneuver-${m}`,S=`esri-directions__cumulative-costs-${m}`,w=`esri-directions__intermediate-costs-${m}`,M={[I.maneuverActive]:this._activeManeuver===o};return U("li",{"aria-labelledby":`${y} ${S} ${w}`,bind:this,class:this.classes(I.maneuver,M),"data-maneuver":o,key:o,onclick:this._handleManeuverClick,onkeydown:this._handleManeuverClick,onfocus:this._handleManeuverFocus,onmouseover:this._handleManeuverMouseOver,onmouseout:this._handleManeuverMouseOut,onblur:this._handleManeuverBlur,tabIndex:0},a(g)&&U("img",{alt:"",class:I.maneuverIcon,src:g}),U("div",{class:I.maneuverCostsContainer},U("span",{id:y,innerHTML:c(v,"")}),U("div",{class:I.maneuverCosts},U("div",{class:I.horizontalSplitter}),U("div",{id:S,class:I.cumulativeCost,innerHTML:t,title:l.cumulativeCosts}),U("div",{id:w,class:I.intermediateCost,innerHTML:p,title:l.intermediateCosts}))))}_handleManeuverClick(e){const t=e.currentTarget["data-maneuver"];if(this._activeManeuver===t)return this._activeManeuver=null,void this.zoomToRoute();this._activeManeuver=t;const{geometry:s}=t;this.viewModel.centerAt(s),this.viewModel.highlight(t)}_handleManeuverMouseOver(e){if(this._activeManeuver||this._focusedManeuver)return;const t=e.currentTarget["data-maneuver"];this.viewModel.highlight(t)}_handleManeuverMouseOut(){this._activeManeuver||this._focusedManeuver||this.viewModel.clearHighlights()}_handleManeuverBlur(){this._activeManeuver||(this._focusedManeuver=null,this.viewModel.clearHighlights())}_handleManeuverFocus(e){if(this._activeManeuver)return;const t=e.currentTarget["data-maneuver"];this._focusedManeuver=t,this.viewModel.highlight(t)}_getFormattedManeuverText(e){const{displayText:t,name:s,intersectingName:i}=e;if(n(t))return"";let o=t;return a(s)&&o.includes(s)&&(o=o.replace(s,`<strong>${s}</strong>`)),a(i)&&o.includes(i)&&(o=o.replace(i,`<strong>${i}</strong>`)),o}_getCostSummary(){const{viewModel:{impedanceAttribute:e,layer:{routeInfo:t},routeParameters:s}}=this;if(n(e)||n(t))return null;let{totalDuration:i,totalDistance:o}=t;const{directionsLengthUnits:r}=s;o=a(o)?o:0,i=a(i)?i:0;const l=C(this.messages,this.messagesUnits,o,{fromUnits:"meters",toUnits:r}),c=T(i,"minutes"),[d,u]=k(e.units)?[c,l]:[l,c];return{primary:d,secondary:u}}async _getDirections(){if(!(this.viewModel.layer.stops.filter((e=>a(e.geometry))).length<2))try{await this.viewModel.getDirections()}catch{}}};e([v("viewModel.apiKey")],Q.prototype,"apiKey",void 0),e([v("viewModel.goToOverride")],Q.prototype,"goToOverride",void 0),e([_()],Q.prototype,"headingLevel",void 0),e([_()],Q.prototype,"iconClass",void 0),e([_({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],Q.prototype,"label",void 0),e([v("viewModel.lastRoute")],Q.prototype,"lastRoute",void 0),e([v("viewModel.layer")],Q.prototype,"layer",void 0),e([v("viewModel.maxStops")],Q.prototype,"maxStops",void 0),e([_(),H("esri/widgets/Directions/t9n/Directions")],Q.prototype,"messages",void 0),e([_(),H("esri/t9n/common")],Q.prototype,"messagesCommon",void 0),e([_(),H("esri/core/t9n/Units")],Q.prototype,"messagesUnits",void 0),e([_()],Q.prototype,"routeServiceUrl",null),e([_()],Q.prototype,"routeSymbol",null),e([_()],Q.prototype,"searchProperties",void 0),e([_()],Q.prototype,"stopSymbols",null),e([v("viewModel.view")],Q.prototype,"view",void 0),e([_({type:b})],Q.prototype,"viewModel",void 0),e([_()],Q.prototype,"visibleElements",void 0),e([m("visibleElements")],Q.prototype,"castVisibleElements",null),e([v("viewModel.getDirections")],Q.prototype,"getDirections",null),e([v("viewModel.zoomToRoute")],Q.prototype,"zoomToRoute",null),e([E()],Q.prototype,"_handleStopIconClick",null),e([E()],Q.prototype,"_handleClearRouteClick",null),e([E()],Q.prototype,"_handleReverseStops",null),e([E()],Q.prototype,"_handleRemoveStop",null),e([E()],Q.prototype,"_handleSectionToggle",null),e([E()],Q.prototype,"_handleSummaryInteraction",null),e([E()],Q.prototype,"_handleManeuverClick",null),Q=e([g("esri.widgets.Directions")],Q);const X=Q;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.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Accessor.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{cast as o}from"../../../core/accessorSupport/decorators/cast.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import a from"../../../popup/FieldInfo.js";import s from"../../../popup/content/support/ChartMediaInfoValueSeries.js";import{substituteFieldsInLinksAndAttributes as l,fixTokens as n,substituteAttributes as p,getFixedFieldNames as d,getFixedFieldName as u,isRelatedField as f,formatValueToFieldInfo as c,getFieldInfo as m,getFieldInfoLabel as h}from"../support/featureUtils.js";import{getRelatedFieldInfo as y}from"../support/relatedFeatureUtils.js";const I={chartAnimation:!0};let b=class extends e{constructor(t){super(t),this.abilities={...I},this.activeMediaInfoIndex=0,this.attributes=null,this.description=null,this.fieldInfoMap=null,this.formattedAttributes=null,this.expressionAttributes=null,this.layer=null,this.mediaInfos=null,this.popupTemplate=null,this.relatedInfos=null,this.title=null}castAbilities(t){return{...I,...t}}get activeMediaInfo(){return this.formattedMediaInfos[this.activeMediaInfoIndex]||null}get formattedMediaInfos(){return this._formatMediaInfos()||[]}get formattedMediaInfoCount(){return this.formattedMediaInfos.length}setActiveMedia(t){this._setContentElementMedia(t)}next(){this._pageContentElementMedia(1)}previous(){this._pageContentElementMedia(-1)}_setContentElementMedia(t){const{formattedMediaInfoCount:e}=this,i=(t+e)%e;this.activeMediaInfoIndex=i}_pageContentElementMedia(t){const{activeMediaInfoIndex:e}=this,i=e+t;this._setContentElementMedia(i)}_formatMediaInfos(){const{attributes:t,mediaInfos:e,formattedAttributes:i,expressionAttributes:o,fieldInfoMap:r,layer:a}=this;return e?.map((e=>{const s=e?.clone();if(!s)return null;if(s.title=l({attributes:t,fieldInfoMap:r,globalAttributes:i,expressionAttributes:o,layer:a,text:s.title}),s.caption=l({attributes:t,fieldInfoMap:r,globalAttributes:i,expressionAttributes:o,layer:a,text:s.caption}),s.altText=l({attributes:t,fieldInfoMap:r,globalAttributes:i,expressionAttributes:o,layer:a,text:s.altText}),"image"===s.type){const{value:t}=s;return this._setImageValue({value:t,formattedAttributes:i,layer:a}),s.value.sourceURL?s:void 0}if("pie-chart"===s.type||"line-chart"===s.type||"column-chart"===s.type||"bar-chart"===s.type){const{value:e}=s;return this._setChartValue({value:e,chartType:s.type,attributes:t,formattedAttributes:i,layer:a}),s}return null})).filter(Boolean)}_setImageValue(t){const{fieldInfoMap:e}=this,{value:i,formattedAttributes:o,layer:r}=t,{linkURL:a,sourceURL:s}=i;if(s){const t=n(s,r);i.sourceURL=p({formattedAttributes:o,template:t,fieldInfoMap:e})}if(a){const t=n(a,r);i.linkURL=p({formattedAttributes:o,template:t,fieldInfoMap:e})}}_setChartValue(t){const{value:e,attributes:i,formattedAttributes:o,chartType:r,layer:a}=t,{popupTemplate:s,relatedInfos:l}=this,{fields:n,normalizeField:p}=e;e.fields=d(n,a),p&&(e.normalizeField=u(p,a));if(!n.some((t=>!!(null!=o[t]||f(t)&&l.size))))return;const c=s?.fieldInfos;n.forEach((t=>{if(f(t))return void(e.series=[...e.series,...this._getRelatedChartInfos({fieldInfos:c,fieldName:t,formattedAttributes:o,chartType:r,value:e})]);const a=this._getChartOption({value:e,attributes:i,chartType:r,formattedAttributes:o,fieldName:t,fieldInfos:c});e.series.push(a)}))}_getRelatedChartInfos(t){const{fieldInfos:e,fieldName:i,formattedAttributes:o,chartType:r,value:a}=t,s=[],l=y(i),{layerId:n,fieldName:p}=l,d=this.relatedInfos?.get(n.toString());if(!d)return s;const{relatedFeatures:u,relation:f}=d;if(!f||!u)return s;const{cardinality:c}=f;u.forEach((t=>{const{attributes:l}=t;l&&Object.keys(l).forEach((t=>{t===p&&s.push(this._getChartOption({value:a,attributes:l,formattedAttributes:o,fieldName:i,chartType:r,relatedFieldName:t,fieldInfos:e}))}))}));return"one-to-many"===c||"many-to-many"===c?s:[s[0]]}_getTooltip({label:t,value:e,chartType:i}){return"pie-chart"===i?t:`${t}: ${e}`}_getChartOption(t){const{value:e,attributes:i,formattedAttributes:o,fieldName:r,relatedFieldName:l,fieldInfos:n,chartType:p}=t,{layer:d}=this,{normalizeField:I,tooltipField:b}=e,v=I?f(I)?i[y(I).fieldName]:i[I]:null,M=l&&void 0!==i[l]?i[l]:void 0!==i[r]?i[r]:o[r],A=void 0===M?null:M&&v?M/v:M,g=new s({fieldName:r,value:A});if(f(r)){const t=y(r),e=y(b),o=e?e.fieldName:null,a=c(A,{fieldInfos:n,fieldName:l,layer:d,preventPlacesFormatting:!!v}),s=t?t.label||t.fieldName:l,u=o&&void 0!==i[o]?i[o]:s;return g.tooltip=this._getTooltip({label:u,value:a,chartType:p}),g}const _=m(n,r),x=u(r,d),T=b&&void 0!==o[b]?o[b]:h(_||new a({fieldName:x}),this.popupTemplate?.expressionInfos),C=o[x];return g.tooltip=this._getTooltip({label:T,value:C,chartType:p}),g}};t([i()],b.prototype,"abilities",void 0),t([o("abilities")],b.prototype,"castAbilities",null),t([i()],b.prototype,"activeMediaInfoIndex",void 0),t([i({readOnly:!0})],b.prototype,"activeMediaInfo",null),t([i()],b.prototype,"attributes",void 0),t([i()],b.prototype,"description",void 0),t([i()],b.prototype,"fieldInfoMap",void 0),t([i()],b.prototype,"formattedAttributes",void 0),t([i()],b.prototype,"expressionAttributes",void 0),t([i({readOnly:!0})],b.prototype,"formattedMediaInfos",null),t([i()],b.prototype,"layer",void 0),t([i({readOnly:!0})],b.prototype,"formattedMediaInfoCount",null),t([i()],b.prototype,"mediaInfos",void 0),t([i()],b.prototype,"popupTemplate",void 0),t([i()],b.prototype,"relatedInfos",void 0),t([i()],b.prototype,"title",void 0),b=t([r("esri.widgets.Feature.FeatureMedia.FeatureMediaViewModel")],b);const v=b;export{v as default};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Accessor.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{cast as i}from"../../../core/accessorSupport/decorators/cast.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import a from"../../../popup/FieldInfo.js";import s from"../../../popup/content/support/ChartMediaInfoValueSeries.js";import{substituteFieldsInLinksAndAttributes as l,fixTokens as n,substituteAttributes as p,getFixedFieldNames as d,getFixedFieldName as u,isRelatedField as f,getFieldInfo as c,getFieldInfoLabel as m}from"../support/featureUtils.js";import{getRelatedFieldInfo as h}from"../support/relatedFeatureUtils.js";const y={chartAnimation:!0};let I=class extends e{constructor(t){super(t),this.abilities={...y},this.activeMediaInfoIndex=0,this.attributes=null,this.description=null,this.fieldInfoMap=null,this.formattedAttributes=null,this.expressionAttributes=null,this.layer=null,this.mediaInfos=null,this.popupTemplate=null,this.relatedInfos=null,this.title=null}castAbilities(t){return{...y,...t}}get activeMediaInfo(){return this.formattedMediaInfos[this.activeMediaInfoIndex]||null}get formattedMediaInfos(){return this._formatMediaInfos()||[]}get formattedMediaInfoCount(){return this.formattedMediaInfos.length}setActiveMedia(t){this._setContentElementMedia(t)}next(){this._pageContentElementMedia(1)}previous(){this._pageContentElementMedia(-1)}_setContentElementMedia(t){const{formattedMediaInfoCount:e}=this,o=(t+e)%e;this.activeMediaInfoIndex=o}_pageContentElementMedia(t){const{activeMediaInfoIndex:e}=this,o=e+t;this._setContentElementMedia(o)}_formatMediaInfos(){const{attributes:t,mediaInfos:e,formattedAttributes:o,expressionAttributes:i,fieldInfoMap:r,layer:a}=this;return e?.map((e=>{const s=e?.clone();if(!s)return null;if(s.title=l({attributes:t,fieldInfoMap:r,globalAttributes:o,expressionAttributes:i,layer:a,text:s.title}),s.caption=l({attributes:t,fieldInfoMap:r,globalAttributes:o,expressionAttributes:i,layer:a,text:s.caption}),s.altText=l({attributes:t,fieldInfoMap:r,globalAttributes:o,expressionAttributes:i,layer:a,text:s.altText}),"image"===s.type){const{value:t}=s;return this._setImageValue({value:t,formattedAttributes:o,layer:a}),s.value.sourceURL?s:void 0}if("pie-chart"===s.type||"line-chart"===s.type||"column-chart"===s.type||"bar-chart"===s.type){const{value:e}=s;return this._setChartValue({value:e,chartType:s.type,attributes:t,formattedAttributes:o,layer:a}),s}return null})).filter(Boolean)}_setImageValue(t){const{fieldInfoMap:e}=this,{value:o,formattedAttributes:i,layer:r}=t,{linkURL:a,sourceURL:s}=o;if(s){const t=n(s,r);o.sourceURL=p({formattedAttributes:i,template:t,fieldInfoMap:e})}if(a){const t=n(a,r);o.linkURL=p({formattedAttributes:i,template:t,fieldInfoMap:e})}}_setChartValue(t){const{value:e,attributes:o,formattedAttributes:i,chartType:r,layer:a}=t,{popupTemplate:s,relatedInfos:l}=this,{fields:n,normalizeField:p}=e;e.fields=d(n,a),p&&(e.normalizeField=u(p,a));if(!n.some((t=>!!(null!=i[t]||f(t)&&l.size))))return;const c=s?.fieldInfos;n.forEach((t=>{if(f(t))return void(e.series=[...e.series,...this._getRelatedChartInfos({fieldInfos:c,fieldName:t,formattedAttributes:i,chartType:r,value:e})]);const a=this._getChartOption({value:e,attributes:o,chartType:r,formattedAttributes:i,fieldName:t,fieldInfos:c});e.series.push(a)}))}_getRelatedChartInfos(t){const{fieldInfos:e,fieldName:o,formattedAttributes:i,chartType:r,value:a}=t,s=[],l=h(o),{layerId:n,fieldName:p}=l,d=this.relatedInfos?.get(n.toString());if(!d)return s;const{relatedFeatures:u,relation:f}=d;if(!f||!u)return s;const{cardinality:c}=f;u.forEach((t=>{const{attributes:l}=t;l&&Object.keys(l).forEach((t=>{t===p&&s.push(this._getChartOption({value:a,attributes:l,formattedAttributes:i,fieldName:o,chartType:r,relatedFieldName:t,fieldInfos:e}))}))}));return"one-to-many"===c||"many-to-many"===c?s:[s[0]]}_getTooltip({label:t,value:e,chartType:o}){return"pie-chart"===o?`${t}`:`${t}: ${e}`}_getChartOption(t){const{value:e,attributes:o,formattedAttributes:i,fieldName:r,relatedFieldName:l,fieldInfos:n,chartType:p}=t,{layer:d,fieldInfoMap:y}=this,{normalizeField:I,tooltipField:b}=e,v=I?f(I)?o[h(I).fieldName]:o[I]:null,M=l&&void 0!==o[l]?o[l]:void 0!==o[r]?o[r]:i[r],A=new s({fieldName:r,value:void 0===M?null:M&&v?M/v:M});if(f(r)){const t=y.get(r.toLowerCase()),e=y.get(b.toLowerCase()),o=t?.fieldName??r,a=i[e?.fieldName??b]??t?.label??t?.fieldName??l,s=i[o];return A.tooltip=this._getTooltip({label:a,value:s,chartType:p}),A}const g=c(n,r),_=u(r,d),x=b&&void 0!==i[b]?i[b]:m(g||new a({fieldName:_}),this.popupTemplate?.expressionInfos),C=i[_];return A.tooltip=this._getTooltip({label:x,value:C,chartType:p}),A}};t([o()],I.prototype,"abilities",void 0),t([i("abilities")],I.prototype,"castAbilities",null),t([o()],I.prototype,"activeMediaInfoIndex",void 0),t([o({readOnly:!0})],I.prototype,"activeMediaInfo",null),t([o()],I.prototype,"attributes",void 0),t([o()],I.prototype,"description",void 0),t([o()],I.prototype,"fieldInfoMap",void 0),t([o()],I.prototype,"formattedAttributes",void 0),t([o()],I.prototype,"expressionAttributes",void 0),t([o({readOnly:!0})],I.prototype,"formattedMediaInfos",null),t([o()],I.prototype,"layer",void 0),t([o({readOnly:!0})],I.prototype,"formattedMediaInfoCount",null),t([o()],I.prototype,"mediaInfos",void 0),t([o()],I.prototype,"popupTemplate",void 0),t([o()],I.prototype,"relatedInfos",void 0),t([o()],I.prototype,"title",void 0),I=t([r("esri.widgets.Feature.FeatureMedia.FeatureMediaViewModel")],I);const b=I;export{b 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.24/esri/copyright.txt for details.
4
4
  */
5
- import"../../../intl.js";import e from"../../../core/Logger.js";import{isNone as t,isSome as r}from"../../../core/maybe.js";import{replace as n}from"../../../core/string.js";import{formatDate as i,convertDateFormatToIntlOptions as o}from"../../../intl/date.js";import{formatNumber as a,convertNumberFormatToIntlOptions as u}from"../../../intl/number.js";import{isRasterPixelValueField as l,featureHasFields as s}from"../../../layers/support/fieldUtils.js";import f from"../../../popup/support/FieldInfoFormat.js";import{loadArcade as c}from"../../../support/arcadeOnDemand.js";const d="esri.widgets.Feature.support.featureUtils",p=e.getLogger(d),m=/href=(""|'')/gi,y=/(\{([^\{\r\n]+)\})/g,g=/\'/g,h=/^\s*expression\//i,I=/(\n)/gi,b=/[\u00A0-\u9999<>\&]/gim,F=/href\s*=\s*(?:\"([^\"]+)\"|\'([^\']+)\')/gi,w=/^(?:mailto:|tel:)/,N="relationships/",E=o("short-date-short-time");function j(e){if(!t(e))return e.get("sourceLayer")||e.get("layer")}async function x(e,t){return"function"==typeof e?e.call(null,t):e}function T(e=""){if(e)return!w.test(e.trim().toLowerCase())}function C(e){return!!e&&h.test(e)}function M(e,t){if(!C(t)||!e)return null;const r=t.replace(h,"").toLowerCase();let n;return e.some((e=>e.name.toLowerCase()===r&&(n=e,!0))),n}function q(e,t){const r=M(t,e?.fieldName);return r?r.title||null:e?e.label||e.fieldName:null}function R(e,t){const r=t.get(e.toLowerCase());return`{${r&&r.fieldName||e}}`}function D(e){return e.replace(m,"")}function v(e,t){const r=U(t,e);return r?r.name:e}function L(e,t){return e&&e.map((e=>v(e,t)))}function U(e,t){return e&&"function"==typeof e.getField?e.getField(t):null}function $(e){return`${e}`.trim()}function A({attributes:e,globalAttributes:t,layer:r,text:n,expressionAttributes:i,fieldInfoMap:o}){return n?S({formattedAttributes:t,template:_(n,{...t,...i,...e},r),fieldInfoMap:o}):""}function S({formattedAttributes:e,template:t,fieldInfoMap:r}){return $(D(n(n(t,(e=>R(e,r))),e)))}function G(e,t,r=!1){const n=t[e];if("string"==typeof n){const i="%27",o=(r?encodeURIComponent(n):n).replace(g,i);t[e]=o}}function k(e,t=!1){const r={...e};return Object.keys(r).forEach((e=>G(e,r,t))),r}function O(e,t,r){const i=(t=$(t))&&"{"!==t[0];return n(e,k(r,i))}function P(e,t){return e.replace(y,((e,r,n)=>{const i=U(t,n);return i?`{${i.name}}`:r}))}function _(e,t,r){const n=P(e,r);return n?n.replace(F,((e,r,n)=>O(e,r||n,t))):n}function z(e,t){if("string"==typeof e&&t&&null==t.dateFormat&&(null!=t.places||null!=t.digitSeparator)){const t=Number(e);if(!isNaN(t))return t}return e}function H(e){return"feature"===e?.type}function Q(e){return!!e?.layer}function Z(e){return"map-image"===e?.type}function V(e,t){const r=t.fieldInfos,n=t.fieldName,i=B(r,n)?.clone(),o=t.preventPlacesFormatting,s=t.layer,c=U(s,n);if(i&&"date"===c?.type){const e=i.format||new f;e.dateFormat=e.dateFormat||"short-date-short-time",e.dateTimeFormatOptions=!Q(s)&&H(s)&&s.datesInUnknownTimezone||Q(s)&&Z(s.layer)&&s.layer.datesInUnknownTimezone?{timeZone:"UTC"}:null,i.format=e}const d=i&&i.format;return"string"==typeof e&&l(n)&&d?d.formatRasterPixelValue(e):"string"==typeof(e=z(e,d))||null==e||null==d?te(e):o?a(e,{...u(d),minimumFractionDigits:0,maximumFractionDigits:20}):d.format(e)}function B(e,t){if(!e||!e.length||!t)return;const r=t.toLowerCase();let n;return e.some((e=>!(!e.fieldName||e.fieldName.toLowerCase()!==r)&&(n=e,!0))),n}function J({fieldName:e,graphic:t,layer:r}){if(ue(e))return null;if(!r||"function"!=typeof r.getFeatureType)return null;const{typeIdField:n}=r;if(!n||e!==n)return null;const i=r.getFeatureType(t);return i?i.name:null}function K({fieldName:e,value:t,graphic:r,layer:n}){if(ue(e))return null;if(!n||"function"!=typeof n.getFieldDomain)return null;const i=n.getFieldDomain(e,{feature:r});return i&&"coded-value"===i.type?i.getName(t):null}function W(e,t){const{creatorField:r,creationDateField:n,editorField:o,editDateField:a}=e;if(!t)return;const u=t[a];if("number"==typeof u){const e=t[o];return{type:"edit",date:i(u,E),user:e}}const l=t[n];if("number"==typeof l){const e=t[r];return{type:"create",date:i(l,E),user:e}}return null}function X(e,t){const r=new Map;return e&&e.forEach((e=>{const n=v(e.fieldName,t);e.fieldName=n,r.set(n.toLowerCase(),e)})),r}function Y(e){const t=[];if(!e)return t;const{fieldInfos:r,content:n}=e;return r&&t.push(...r),n&&Array.isArray(n)?(n.forEach((e=>{if("fields"===e.type){const r=e&&e.fieldInfos;r&&t.push(...r)}})),t):t}function ee(e){return e.replace(b,(e=>`&#${e.charCodeAt(0)};`))}function te(e){return"string"==typeof e?e.replace(I,'<br class="esri-text-new-line" />'):e}function re(e){const{value:t,fieldName:r,fieldInfos:n,fieldInfoMap:o,layer:a,graphic:u}=e;if(null==t)return"";const l=K({fieldName:r,value:t,graphic:u,layer:a});if(l)return l;const s=J({fieldName:r,graphic:u,layer:a});if(s)return s;if(o.get(r.toLowerCase()))return V(t,{fieldInfos:n,fieldName:r,layer:a});const f=a&&a.fieldsIndex;return f&&f.isDateField(r)?i(t,E):te(t)}function ne({fieldInfos:e,attributes:t,layer:r,graphic:n,fieldInfoMap:i,relatedInfos:o}){const a={};return o?.forEach((t=>fe({attributes:a,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:r}))),Object.keys(t).forEach((o=>{const u=t[o];a[o]=re({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:r,value:u,graphic:n})})),a}async function ie(e,t){const{layer:r,graphic:n,outFields:i,objectIds:o,returnGeometry:a,spatialReference:u}=e,l=o[0];if("number"!=typeof l&&"string"!=typeof l){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:r,graphic:n,objectId:l,requiredFields:i};return p.warn(e,t),null}if(!r.capabilities?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:r,graphic:n,requiredFields:i,returnGeometry:a};return p.warn(e,t),null}const s=r.createQuery();s.objectIds=o,s.outFields=i?.length?i:[r.objectIdField],s.returnGeometry=!!a,s.returnZ=!!a,s.returnM=!!a,s.outSpatialReference=u;return(await r.queryFeatures(s,t)).features[0]}async function oe(e){if(!e.expressionInfos?.length)return!1;const t=await c(),{arcadeUtils:{hasGeometryFunctions:r}}=t;return r(e)}async function ae({graphic:e,popupTemplate:t,layer:r,spatialReference:n},i){if(!r||!t)return;if("function"==typeof r.load&&await r.load(i),!e.attributes)return;const o=e.attributes[r.objectIdField];if(null==o)return;const a=[o],u=await t.getRequiredFields(r.fieldsIndex),l=s(u,e),f=l?[]:u,c=t.returnGeometry||await oe(t);if(l&&!c)return;const d=await ie({layer:r,graphic:e,outFields:f,objectIds:a,returnGeometry:c,spatialReference:n},i);d&&(d.geometry&&(e.geometry=d.geometry),d.attributes&&(e.attributes={...e.attributes,...d.attributes}))}function ue(e=""){return!!e&&e.includes(N)}function le(e){return e?`${N}${e.layerId}/${e.fieldName}`:""}function se({attributes:e,graphic:t,relatedInfo:r,fieldInfos:n,fieldInfoMap:i,layer:o}){e&&t&&r&&Object.keys(t.attributes).forEach((a=>{const u=le({layerId:r.relation.id.toString(),fieldName:a}),l=t.attributes[a];e[u]=re({fieldName:u,fieldInfos:n,fieldInfoMap:i,layer:o,value:l,graphic:t})}))}function fe({attributes:e,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}){e&&t&&(t.relatedFeatures&&t.relatedFeatures&&t.relatedFeatures.forEach((o=>se({attributes:e,graphic:o,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}))),t.relatedStatsFeatures&&t.relatedStatsFeatures&&t.relatedStatsFeatures.forEach((o=>se({attributes:e,graphic:o,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}))))}const ce=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},de=({layer:e,method:t,query:n,definitionExpression:i})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const o=r(n.where)&&n.where,a=r(n.geometry)&&n.geometry;ce(i)||ce(o)||"extent"===a?.type||"tile"===n.resultType||(n.cacheHint=!0)},pe=({query:e,layer:t,method:r})=>{de({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})},me=({queryPayload:e,layer:t,method:r})=>{de({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})};export{te as applyTextFormattingHTML,X as createfieldInfoMap,P as fixTokens,ne as formatAttributes,W as formatEditInfo,V as formatValueToFieldInfo,Y as getAllFieldInfos,B as getFieldInfo,q as getFieldInfoLabel,v as getFixedFieldName,L as getFixedFieldNames,j as getSourceLayer,x as graphicCallback,ee as htmlEntities,C as isExpressionField,ue as isRelatedField,pe as preLayerQueryCallback,me as preRequestCallback,ae as queryUpdatedFeature,T as shouldOpenInNewTab,S as substituteAttributes,A as substituteFieldsInLinksAndAttributes};
5
+ import"../../../intl.js";import e from"../../../core/Logger.js";import{isNone as t,isSome as r}from"../../../core/maybe.js";import{replace as n}from"../../../core/string.js";import{formatDate as i,convertDateFormatToIntlOptions as o}from"../../../intl/date.js";import{formatNumber as a,convertNumberFormatToIntlOptions as u}from"../../../intl/number.js";import{isRasterPixelValueField as l,featureHasFields as s}from"../../../layers/support/fieldUtils.js";import f from"../../../popup/support/FieldInfoFormat.js";import{loadArcade as c}from"../../../support/arcadeOnDemand.js";const d="esri.widgets.Feature.support.featureUtils",p=e.getLogger(d),m=/href=(""|'')/gi,y=/(\{([^\{\r\n]+)\})/g,g=/\'/g,h=/^\s*expression\//i,I=/(\n)/gi,b=/[\u00A0-\u9999<>\&]/gim,F=/href\s*=\s*(?:\"([^\"]+)\"|\'([^\']+)\')/gi,w=/^(?:mailto:|tel:)/,N="relationships/",E=o("short-date-short-time");function j(e){if(!t(e))return e.get("sourceLayer")||e.get("layer")}async function x(e,t){return"function"==typeof e?e.call(null,t):e}function T(e=""){if(e)return!w.test(e.trim().toLowerCase())}function C(e){return!!e&&h.test(e)}function M(e,t){if(!C(t)||!e)return null;const r=t.replace(h,"").toLowerCase();let n;return e.some((e=>e.name.toLowerCase()===r&&(n=e,!0))),n}function q(e,t){const r=M(t,e?.fieldName);return r?r.title||null:e?e.label||e.fieldName:null}function R(e,t){const r=t.get(e.toLowerCase());return`{${r&&r.fieldName||e}}`}function v(e){return e.replace(m,"")}function D(e,t){const r=L(t,e);return r?r.name:e}function A(e,t){return e&&e.map((e=>D(e,t)))}function L(e,t){return e&&"function"==typeof e.getField?e.getField(t):null}function U(e){return`${e}`.trim()}function $({attributes:e,globalAttributes:t,layer:r,text:n,expressionAttributes:i,fieldInfoMap:o}){return n?S({formattedAttributes:t,template:_(n,{...t,...i,...e},r),fieldInfoMap:o}):""}function S({formattedAttributes:e,template:t,fieldInfoMap:r}){return U(v(n(n(t,(e=>R(e,r))),e)))}function G(e,t,r=!1){const n=t[e];if("string"==typeof n){const i="%27",o=(r?encodeURIComponent(n):n).replace(g,i);t[e]=o}}function k(e,t=!1){const r={...e};return Object.keys(r).forEach((e=>G(e,r,t))),r}function O(e,t,r){const i=(t=U(t))&&"{"!==t[0];return n(e,k(r,i))}function P(e,t){return e.replace(y,((e,r,n)=>{const i=L(t,n);return i?`{${i.name}}`:r}))}function _(e,t,r){const n=P(e,r);return n?n.replace(F,((e,r,n)=>O(e,r||n,t))):n}function z(e,t){if("string"==typeof e&&t&&null==t.dateFormat&&(null!=t.places||null!=t.digitSeparator)){const t=Number(e);if(!isNaN(t))return t}return e}function H(e){return"feature"===e?.type}function Q(e){return!!e?.layer}function Z(e){return"map-image"===e?.type}function V(e,t){const r=t.fieldInfos,n=t.fieldName,i=B(r,n)?.clone(),o=t.preventPlacesFormatting,s=t.layer,c=L(s,n);if(i&&"date"===c?.type){const e=i.format||new f;e.dateFormat=e.dateFormat||"short-date-short-time",e.dateTimeFormatOptions=!Q(s)&&H(s)&&s.datesInUnknownTimezone||Q(s)&&Z(s.layer)&&s.layer.datesInUnknownTimezone?{timeZone:"UTC"}:null,i.format=e}const d=i&&i.format;return"string"==typeof e&&l(n)&&d?d.formatRasterPixelValue(e):"string"==typeof(e=z(e,d))||null==e||null==d?te(e):o?a(e,{...u(d),minimumFractionDigits:0,maximumFractionDigits:20}):d.format(e)}function B(e,t){if(!e||!e.length||!t)return;const r=t.toLowerCase();let n;return e.some((e=>!(!e.fieldName||e.fieldName.toLowerCase()!==r)&&(n=e,!0))),n}function J({fieldName:e,graphic:t,layer:r}){if(ue(e))return null;if(!r||"function"!=typeof r.getFeatureType)return null;const{typeIdField:n}=r;if(!n||e!==n)return null;const i=r.getFeatureType(t);return i?i.name:null}function K({fieldName:e,value:t,graphic:r,layer:n}){if(ue(e))return null;if(!n||"function"!=typeof n.getFieldDomain)return null;const i=n.getFieldDomain(e,{feature:r});return i&&"coded-value"===i.type?i.getName(t):null}function W(e,t){const{creatorField:r,creationDateField:n,editorField:o,editDateField:a}=e;if(!t)return;const u=t[a];if("number"==typeof u){const e=t[o];return{type:"edit",date:i(u,E),user:e}}const l=t[n];if("number"==typeof l){const e=t[r];return{type:"create",date:i(l,E),user:e}}return null}function X(e,t){const r=new Map;return e&&e.forEach((e=>{const n=D(e.fieldName,t);e.fieldName=n,r.set(n.toLowerCase(),e)})),r}function Y(e){const t=[];if(!e)return t;const{fieldInfos:r,content:n}=e;return r&&t.push(...r),n&&Array.isArray(n)?(n.forEach((e=>{if("fields"===e.type){const r=e&&e.fieldInfos;r&&t.push(...r)}})),t):t}function ee(e){return e.replace(b,(e=>`&#${e.charCodeAt(0)};`))}function te(e){return"string"==typeof e?e.replace(I,'<br class="esri-text-new-line" />'):e}function re(e){const{value:t,fieldName:r,fieldInfos:n,fieldInfoMap:o,layer:a,graphic:u}=e;if(null==t)return"";const l=K({fieldName:r,value:t,graphic:u,layer:a});if(l)return l;const s=J({fieldName:r,graphic:u,layer:a});if(s)return s;if(o.get(r.toLowerCase()))return V(t,{fieldInfos:n||Array.from(o.values()),fieldName:r,layer:a});const f=a&&a.fieldsIndex;return f&&f.isDateField(r)?i(t,E):te(t)}function ne({fieldInfos:e,attributes:t,layer:r,graphic:n,fieldInfoMap:i,relatedInfos:o}){const a={};return o?.forEach((t=>fe({attributes:a,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:r}))),Object.keys(t).forEach((o=>{const u=t[o];a[o]=re({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:r,value:u,graphic:n})})),a}async function ie(e,t){const{layer:r,graphic:n,outFields:i,objectIds:o,returnGeometry:a,spatialReference:u}=e,l=o[0];if("number"!=typeof l&&"string"!=typeof l){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:r,graphic:n,objectId:l,requiredFields:i};return p.warn(e,t),null}if(!r.capabilities?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:r,graphic:n,requiredFields:i,returnGeometry:a};return p.warn(e,t),null}const s=r.createQuery();s.objectIds=o,s.outFields=i?.length?i:[r.objectIdField],s.returnGeometry=!!a,s.returnZ=!!a,s.returnM=!!a,s.outSpatialReference=u;return(await r.queryFeatures(s,t)).features[0]}async function oe(e){if(!e.expressionInfos?.length)return!1;const t=await c(),{arcadeUtils:{hasGeometryFunctions:r}}=t;return r(e)}async function ae({graphic:e,popupTemplate:t,layer:r,spatialReference:n},i){if(!r||!t)return;if("function"==typeof r.load&&await r.load(i),!e.attributes)return;const o=e.attributes[r.objectIdField];if(null==o)return;const a=[o],u=await t.getRequiredFields(r.fieldsIndex),l=s(u,e),f=l?[]:u,c=t.returnGeometry||await oe(t);if(l&&!c)return;const d=await ie({layer:r,graphic:e,outFields:f,objectIds:a,returnGeometry:c,spatialReference:n},i);d&&(d.geometry&&(e.geometry=d.geometry),d.attributes&&(e.attributes={...e.attributes,...d.attributes}))}function ue(e=""){return!!e&&e.includes(N)}function le(e){return e?`${N}${e.layerId}/${e.fieldName}`:""}function se({attributes:e,graphic:t,relatedInfo:r,fieldInfos:n,fieldInfoMap:i,layer:o}){e&&t&&r&&Object.keys(t.attributes).forEach((a=>{const u=le({layerId:r.relation.id.toString(),fieldName:a}),l=t.attributes[a];e[u]=re({fieldName:u,fieldInfos:n,fieldInfoMap:i,layer:o,value:l,graphic:t})}))}function fe({attributes:e,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}){e&&t&&(t.relatedFeatures&&t.relatedFeatures&&t.relatedFeatures.forEach((o=>se({attributes:e,graphic:o,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}))),t.relatedStatsFeatures&&t.relatedStatsFeatures&&t.relatedStatsFeatures.forEach((o=>se({attributes:e,graphic:o,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}))))}const ce=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},de=({layer:e,method:t,query:n,definitionExpression:i})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const o=r(n.where)&&n.where,a=r(n.geometry)&&n.geometry;ce(i)||ce(o)||"extent"===a?.type||"tile"===n.resultType||(n.cacheHint=!0)},pe=({query:e,layer:t,method:r})=>{de({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})},me=({queryPayload:e,layer:t,method:r})=>{de({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})};export{te as applyTextFormattingHTML,X as createfieldInfoMap,P as fixTokens,ne as formatAttributes,W as formatEditInfo,V as formatValueToFieldInfo,Y as getAllFieldInfos,B as getFieldInfo,q as getFieldInfoLabel,D as getFixedFieldName,A as getFixedFieldNames,j as getSourceLayer,x as graphicCallback,ee as htmlEntities,C as isExpressionField,ue as isRelatedField,pe as preLayerQueryCallback,me as preRequestCallback,ae as queryUpdatedFeature,T as shouldOpenInNewTab,S as substituteAttributes,$ as substituteFieldsInLinksAndAttributes};