@arcgis/core 4.24.0-next.20220331 → 4.24.0-next.20220401

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 (124) hide show
  1. package/WebScene.js +1 -1
  2. package/analysis/LineOfSightAnalysisObserver.js +1 -1
  3. package/analysis/LineOfSightAnalysisTarget.js +1 -1
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/0eb9c9477d36cd212f8b.js +1 -0
  6. package/assets/esri/core/workers/chunks/10779a256841c37f2429.js +1 -0
  7. package/assets/esri/core/workers/chunks/125b14c2ccd96d7c20c2.js +1 -0
  8. package/assets/esri/core/workers/chunks/{19cb7315d403a4cd4f59.js → 2530e8ccf6e12787ce76.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{302c68c5b91d1ab4fd47.js → 560234694f3e53802aff.js} +1 -1
  10. package/assets/esri/core/workers/chunks/5633710daeb3bbb79bcf.js +1 -0
  11. package/assets/esri/core/workers/chunks/6f7917da7166e8c6854b.js +1 -0
  12. package/assets/esri/core/workers/chunks/7388824eac8da01ea03d.js +1 -0
  13. package/assets/esri/core/workers/chunks/794b47764ebb0257ed41.js +1 -0
  14. package/assets/esri/core/workers/chunks/81e9d860a044acec74ce.js +1 -0
  15. package/assets/esri/core/workers/chunks/{9a32f129f0d67547e44c.js → 831dc0187f71e658550c.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{d162d1b7b97a58e97d8c.js → 8958cd555f4887526e8b.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{e57b71ba70f088a3a052.js → 90dcd86cdef90099abfa.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{a5b54e134ae59629d6d1.js → 93067e27eea5844edc6c.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{0b63c9d5d9c004923a97.js → b26bd8fde2fc65bb67fb.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{b81e1df3a47b61421295.js → b34ba22c7a5adce8a7a2.js} +1 -1
  21. package/assets/esri/core/workers/chunks/c28f7ae4756ad1ba94bd.js +1 -0
  22. package/assets/esri/core/workers/chunks/{e1408ff1b8343674e6ef.js → c59b0b58e24e6a60cf3e.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{f4e79769297ad9c1d508.js → c7cee13a962396b23a5e.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{cb38754110b7a0e901f6.js → cd3679fa86129ebabfdf.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{224c0e64160bdc170051.js → d076627bb7dadea89e89.js} +1 -1
  26. package/assets/esri/core/workers/chunks/e06ad3a3d71154fed654.js +1 -0
  27. package/assets/esri/core/workers/chunks/{7a77d4cd27c30f1a5cae.js → ee3387a43dfbb3df23e1.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{fbb7a121a45f8ca7d89c.js → f4fc165420d449e442b8.js} +1 -1
  29. package/assets/esri/themes/base/widgets/_Widget.scss +2 -2
  30. package/assets/esri/themes/dark/main.css +1 -1
  31. package/assets/esri/themes/dark-blue/main.css +1 -1
  32. package/assets/esri/themes/dark-green/main.css +1 -1
  33. package/assets/esri/themes/dark-purple/main.css +1 -1
  34. package/assets/esri/themes/dark-red/main.css +1 -1
  35. package/assets/esri/themes/light/main.css +1 -1
  36. package/assets/esri/themes/light/view.css +1 -1
  37. package/assets/esri/themes/light-blue/main.css +1 -1
  38. package/assets/esri/themes/light-green/main.css +1 -1
  39. package/assets/esri/themes/light-purple/main.css +1 -1
  40. package/assets/esri/themes/light-red/main.css +1 -1
  41. package/core/AsyncUpdate.js +1 -1
  42. package/exports/csv.js +1 -1
  43. package/geometry/support/meshUtils/exporters/gltf/geometry.js +1 -1
  44. package/geometry/support/normalizeUtils.js +1 -1
  45. package/interfaces.d.ts +120 -0
  46. package/layers/MapImageLayer.js +1 -1
  47. package/layers/RouteLayer.js +1 -1
  48. package/layers/VectorTileLayer.js +1 -1
  49. package/layers/graphics/editingSupport.js +1 -1
  50. package/layers/mixins/ArcGISImageService.js +1 -1
  51. package/layers/support/RasterJobHandler.js +1 -1
  52. package/layers/support/SpriteSource.js +1 -1
  53. package/layers/support/Sublayer.js +1 -1
  54. package/layers/support/TilemapCache.js +1 -1
  55. package/layers/support/vectorTileLayerLoader.js +1 -1
  56. package/libs/i3s/I3SModule.js +1 -1
  57. package/libs/vxl/VxlModule.js +1 -1
  58. package/package.json +1 -1
  59. package/portal/support/layersLoader.js +1 -1
  60. package/portal/support/portalLayers.js +1 -1
  61. package/renderers/support/DictionaryLoader.js +1 -1
  62. package/rest/query/operations/query.js +1 -1
  63. package/rest/query/operations/queryTopFeatures.js +1 -1
  64. package/rest/support/DirectionLine.js +1 -1
  65. package/rest/support/DirectionPoint.js +1 -1
  66. package/rest/support/PointBarrier.js +1 -1
  67. package/rest/support/PolygonBarrier.js +1 -1
  68. package/rest/support/PolylineBarrier.js +1 -1
  69. package/rest/support/RouteInfo.js +1 -1
  70. package/rest/support/Stop.js +1 -1
  71. package/smartMapping/labels/clusters.js +1 -1
  72. package/smartMapping/renderers/color.js +1 -1
  73. package/smartMapping/support/adapters/SceneLayerAdapter.js +1 -1
  74. package/support/elevationInfoUtils.js +1 -1
  75. package/support/revision.js +1 -1
  76. package/symbols/support/previewSymbol3D.js +1 -1
  77. package/symbols/support/symbolLayerUtils.js +1 -1
  78. package/views/2d/engine/vectorTiles/TileParser.js +1 -1
  79. package/views/2d/engine/webgl/util/Lock.js +1 -1
  80. package/views/2d/layers/RouteLayerView2D.js +1 -1
  81. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  82. package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
  83. package/views/2d/layers/support/webStyleUtils.js +1 -1
  84. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  85. package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
  86. package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
  87. package/views/3d/interactive/analysisTools/lineOfSight/LineOfSightTool.js +1 -1
  88. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  89. package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
  90. package/views/3d/layers/ImageryLayerView3D.js +1 -1
  91. package/views/3d/layers/RouteLayerView3D.js +1 -1
  92. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  93. package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
  94. package/views/3d/layers/support/PopupSceneLayerView.js +1 -1
  95. package/views/3d/support/debugFlags.js +1 -1
  96. package/views/3d/terrain/TerrainSurface.js +1 -1
  97. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  98. package/views/SceneView.js +1 -1
  99. package/views/layers/ImageryTileLayerView.js +1 -1
  100. package/views/layers/MapImageLayerView.js +1 -1
  101. package/views/layers/TileLayerView.js +1 -1
  102. package/views/support/DefaultsFromMap.js +1 -1
  103. package/widgets/Bookmarks/BookmarksViewModel.js +1 -1
  104. package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
  105. package/widgets/Directions/DirectionsViewModel.js +1 -1
  106. package/widgets/Directions.js +1 -1
  107. package/widgets/Editor.js +1 -1
  108. package/widgets/Feature/support/featureUtils.js +1 -1
  109. package/widgets/FeatureForm/InputField.js +1 -1
  110. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  111. package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
  112. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  113. package/widgets/Popup/actionUtils.js +1 -1
  114. package/widgets/Search/SearchViewModel.js +1 -1
  115. package/assets/esri/core/workers/chunks/113362697da1b69deaed.js +0 -1
  116. package/assets/esri/core/workers/chunks/1e590d63187ada4f5ff7.js +0 -1
  117. package/assets/esri/core/workers/chunks/391a330182c616cfffaf.js +0 -1
  118. package/assets/esri/core/workers/chunks/3a85312fd7d0cda9ce93.js +0 -1
  119. package/assets/esri/core/workers/chunks/3c00e38d3b16f4a53a4f.js +0 -1
  120. package/assets/esri/core/workers/chunks/4a82a6a473b3d540d0be.js +0 -1
  121. package/assets/esri/core/workers/chunks/5b4d9786c010d265346c.js +0 -1
  122. package/assets/esri/core/workers/chunks/bbfc98e33d4630eb9e5c.js +0 -1
  123. package/assets/esri/core/workers/chunks/bd725783b85f308e2c89.js +0 -1
  124. package/assets/esri/core/workers/chunks/d343f05a3366f95e0494.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../core/Error.js";import{isSome as t}from"../../core/maybe.js";import{eachAlways as o}from"../../core/promiseUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{combinedViewLayerTimeExtentProperty as i}from"../../layers/support/commonProperties.js";import{ExportImageParameters as p}from"../../layers/support/ExportImageParameters.js";import{calculateTolerance as l}from"../../renderers/support/clickToleranceUtils.js";import{loadArcade as m}from"../../support/arcadeOnDemand.js";import{getRequiredFields as n,getFetchPopupTemplate as c}from"./support/popupUtils.js";import{getLayerFloorFilterClause as u}from"../support/floorFilterUtils.js";const y=y=>{let d=class extends y{initialize(){this.exportImageParameters=new p({layer:this.layer})}destroy(){this.exportImageParameters.destroy(),this.exportImageParameters=null}get exportImageVersion(){var e;return null==(e=this.exportImageParameters)||e.commitProperty("version"),this.commitProperty("timeExtent"),(this._get("exportImageVersion")||0)+1}async fetchPopupFeatures(e,s){const{layer:a}=this;if(!e)return Promise.reject(new r("mapimagelayerview:fetchPopupFeatures","Nothing to fetch without area",{layer:a}));const i=this.get("view.scale"),p=[],m=async e=>{const r=0===e.minScale||i<=e.minScale,o=0===e.maxScale||i>=e.maxScale;if(e.visible&&r&&o)if(e.sublayers)e.sublayers.forEach(m);else if(e.popupEnabled){const r=c(e,{...s,defaultPopupTemplateEnabled:!1});t(r)&&p.unshift({sublayer:e,popupTemplate:r})}},y=a.sublayers.toArray().reverse().map(m);await Promise.all(y);const d=p.map((async({sublayer:r,popupTemplate:o})=>{await r.load().catch((()=>{}));const a=r.createQuery(),i=t(s)?s.event:null,p=l({renderer:r.renderer,event:i}),m=this.createFetchPopupFeaturesQueryGeometry(e,p);if(a.geometry=m,a.outFields=await n(r,o),"floors"in this.view){var c,y;const e=null==(c=this.view)||null==(y=c.floors)?void 0:y.clone(),o=u(e,r);t(o)&&(a.where=a.where?`(${a.where}) AND (${o})`:o)}const d=await this._loadArcadeModules(o);d&&d.arcadeUtils.hasGeometryOperations(o)||(a.maxAllowableOffset=m.width/p);return(await r.queryFeatures(a)).features}));return(await o(d)).reduce(((e,r)=>r.value?[...e,...r.value]:e),[]).filter((e=>null!=e))}canResume(){var e;return!!super.canResume()&&(null==(e=this.timeExtent)||!e.isEmpty)}_loadArcadeModules(e){if(e.get("expressionInfos.length")||Array.isArray(e.content)&&e.content.some((e=>"expression"===e.type)))return m()}};return e([s()],d.prototype,"exportImageParameters",void 0),e([s({readOnly:!0})],d.prototype,"exportImageVersion",null),e([s()],d.prototype,"layer",void 0),e([s()],d.prototype,"suspended",void 0),e([s(i)],d.prototype,"timeExtent",void 0),d=e([a("esri.views.layers.MapImageLayerView")],d),d};export{y as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../core/Error.js";import{isSome as t}from"../../core/maybe.js";import{eachAlways as o}from"../../core/promiseUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{combinedViewLayerTimeExtentProperty as i}from"../../layers/support/commonProperties.js";import{ExportImageParameters as p}from"../../layers/support/ExportImageParameters.js";import{calculateTolerance as l}from"../../renderers/support/clickToleranceUtils.js";import{loadArcade as m}from"../../support/arcadeOnDemand.js";import{getRequiredFields as n,getFetchPopupTemplate as c}from"./support/popupUtils.js";import{getLayerFloorFilterClause as u}from"../support/floorFilterUtils.js";const y=y=>{let d=class extends y{initialize(){this.exportImageParameters=new p({layer:this.layer})}destroy(){this.exportImageParameters.destroy(),this.exportImageParameters=null}get exportImageVersion(){var e;return null==(e=this.exportImageParameters)||e.commitProperty("version"),this.commitProperty("timeExtent"),(this._get("exportImageVersion")||0)+1}async fetchPopupFeatures(e,s){const{layer:a}=this;if(!e)throw new r("mapimagelayerview:fetchPopupFeatures","Nothing to fetch without area",{layer:a});const i=this.get("view.scale"),p=[],m=async e=>{const r=0===e.minScale||i<=e.minScale,o=0===e.maxScale||i>=e.maxScale;if(e.visible&&r&&o)if(e.sublayers)e.sublayers.forEach(m);else if(e.popupEnabled){const r=c(e,{...s,defaultPopupTemplateEnabled:!1});t(r)&&p.unshift({sublayer:e,popupTemplate:r})}},y=a.sublayers.toArray().reverse().map(m);await Promise.all(y);const d=p.map((async({sublayer:r,popupTemplate:o})=>{await r.load().catch((()=>{}));const a=r.createQuery(),i=t(s)?s.event:null,p=l({renderer:r.renderer,event:i}),m=this.createFetchPopupFeaturesQueryGeometry(e,p);if(a.geometry=m,a.outFields=await n(r,o),"floors"in this.view){var c,y;const e=null==(c=this.view)||null==(y=c.floors)?void 0:y.clone(),o=u(e,r);t(o)&&(a.where=a.where?`(${a.where}) AND (${o})`:o)}const d=await this._loadArcadeModules(o);d&&d.arcadeUtils.hasGeometryOperations(o)||(a.maxAllowableOffset=m.width/p);return(await r.queryFeatures(a)).features}));return(await o(d)).reduce(((e,r)=>r.value?[...e,...r.value]:e),[]).filter((e=>null!=e))}canResume(){var e;return!!super.canResume()&&(null==(e=this.timeExtent)||!e.isEmpty)}_loadArcadeModules(e){if(e.get("expressionInfos.length")||Array.isArray(e.content)&&e.content.some((e=>"expression"===e.type)))return m()}};return e([s()],d.prototype,"exportImageParameters",void 0),e([s({readOnly:!0})],d.prototype,"exportImageVersion",null),e([s()],d.prototype,"layer",void 0),e([s()],d.prototype,"suspended",void 0),e([s(i)],d.prototype,"timeExtent",void 0),d=e([a("esri.views.layers.MapImageLayerView")],d),d};export{y as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../core/Error.js";import{isSome as t}from"../../core/maybe.js";import{eachAlways as o}from"../../core/promiseUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{calculateTolerance as p}from"../../renderers/support/clickToleranceUtils.js";const i=i=>{let c=class extends i{async fetchPopupFeatures(e,s){const{layer:a}=this;if(!e)return Promise.reject(new r("tilelayerview:fetchPopupFeatures","Nothing to fetch without area",{layer:a}));if("tile"!==a.type)return Promise.reject(new r("tilelayerview:fetchPopupFeatures","Layer type should be 'tile'",{type:a.type}));const i=this.get("view.scale"),c=a.allSublayers.toArray().filter((e=>{const r=0===e.minScale||i<=e.minScale,t=0===e.maxScale||i>=e.maxScale;return e.popupTemplate&&e.popupEnabled&&e.visible&&r&&t}));return o(c.map((async r=>{const o=r.createQuery(),a=t(s)?s.event:null,i=p({renderer:r.renderer,event:a});o.geometry=this.createFetchPopupFeaturesQueryGeometry(e,i),o.outFields=await r.popupTemplate.getRequiredFields();return(await r.queryFeatures(o)).features}))).then((e=>[].concat(...e.map((e=>e.value)).filter(Boolean))))}};return e([s()],c.prototype,"layer",void 0),c=e([a("esri.layers.mixins.TileLayerView")],c),c};export{i as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../core/Error.js";import{isSome as t}from"../../core/maybe.js";import{eachAlways as o}from"../../core/promiseUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{calculateTolerance as p}from"../../renderers/support/clickToleranceUtils.js";const i=i=>{let c=class extends i{async fetchPopupFeatures(e,s){const{layer:a}=this;if(!e)throw new r("tilelayerview:fetchPopupFeatures","Nothing to fetch without area",{layer:a});if("tile"!==a.type)throw new r("tilelayerview:fetchPopupFeatures","Layer type should be 'tile'",{type:a.type});const i=this.get("view.scale"),c=a.allSublayers.toArray().filter((e=>{const r=0===e.minScale||i<=e.minScale,t=0===e.maxScale||i>=e.maxScale;return e.popupTemplate&&e.popupEnabled&&e.visible&&r&&t}));return o(c.map((async r=>{const o=r.createQuery(),a=t(s)?s.event:null,i=p({renderer:r.renderer,event:a});o.geometry=this.createFetchPopupFeaturesQueryGeometry(e,i),o.outFields=await r.popupTemplate.getRequiredFields();return(await r.queryFeatures(o)).features}))).then((e=>[].concat(...e.map((e=>e.value)).filter(Boolean))))}};return e([s()],c.prototype,"layer",void 0),c=e([a("esri.layers.mixins.TileLayerView")],c),c};export{i 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"../../core/Accessor.js";import a from"../../core/Logger.js";import{abortMaybe as i,isSome as n,unwrap as s,isNone as l}from"../../core/maybe.js";import{createTask as r,isAborted as o}from"../../core/promiseUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{supportsHeightModelInfo as u,deriveHeightModelInfoFromLayer as c}from"../../geometry/support/heightModelInfoUtils.js";import{stringFromViewingMode as f,ViewingMode as h}from"../ViewingMode.js";import{projectWithEngineOrService as g}from"./projectionUtils.js";const y=a.getLogger("esri.views.support.DefaultsFromMap");y.level="info";let _=class extends t{constructor(e){super(e),this.required={tileInfo:!1,heightModelInfo:!1,extent:!1},this.defaultSpatialReference=null,this.userSpatialReference=null,this.sourcePreloadCount=10,this.priorityCollection=null,this.logDebugInformation=!1,this.requiresExtentInSpatialReference=!0,this.suspended=!1,this._projectExtentTask={task:null,input:null,output:null,spatialReference:null}}destroy(){this._projectExtentTask.task&&(this._debug("Aborting project extent task"),this._projectExtentTask.task=i(this._projectExtentTask.task)),this._set("map",null)}get ready(){return!this._spatialReferenceTask.updating&&!this._tileInfoTask.updating&&!this._extentTask.updating}get heightModelInfoReady(){return!this._heightModelInfoTask.updating}get spatialReference(){return n(this.userSpatialReference)?this.userSpatialReference:s(this._spatialReferenceTask.spatialReference)}get extent(){return s(this._extentTask.extent)}get heightModelInfo(){return s(this._heightModelInfoTask.heightModelInfo)}get vcsWkid(){return s(this._heightModelInfoTask.vcsWkid)}get latestVcsWkid(){return s(this._heightModelInfoTask.latestVcsWkid)}get viewingMode(){return l(this.userSpatialReference)||this.userSpatialReference.equals(s(this._spatialReferenceTask.spatialReference))?s(this._spatialReferenceTask.viewingMode):null}get tileInfo(){return s(this._tileInfoTask.tileInfo)}get mapCollections(){var e,t,a,i;const s=null==(e=this.map)?void 0:e.call(this),l=[];return n(this.priorityCollection)&&l.push(this.priorityCollection),l.push({parent:null==s?void 0:s.basemap,layers:null==s||null==(t=s.basemap)?void 0:t.baseLayers},{layers:null==s?void 0:s.layers},{parent:null==s?void 0:s.ground,layers:null==s||null==(a=s.ground)?void 0:a.layers},{parent:null==s?void 0:s.basemap,layers:null==s||null==(i=s.basemap)?void 0:i.referenceLayers}),l}get _allLayers(){var e,t;const a=this._collectLayers(this.mapCollections);return this._debug("Collected",null!=(e=null==(t=a.layers)?void 0:t.length)?e:0,"layers, updating",a.updating),a}get _spatialReferenceTask(){var e;if(this.suspended)return null!=(e=this._get("_spatialReferenceTask"))?e:{updating:!1};const{layers:t,updating:a}=this._allLayers,i={candidates:null};for(const l of t)if(this._processSpatialReferenceCandidates(l,i),n(i.candidates)&&1===i.candidates.length)break;if(a&&(l(i.candidates)||1!==i.candidates.length))return{updating:!0};const s=this._pickSpatialReferenceCandidate(i.candidates);return this._debug("Finished spatial reference",n(s)?`${s.spatialReference.wkid}:${n(s.viewingMode)?f(s.viewingMode):"global/local"}`:"none available"),{spatialReference:n(s)?s.spatialReference:null,viewingMode:n(s)?s.viewingMode:null,updating:!1}}get _tileInfoTask(){var e,t,a,i,n,s,l,r;if(!this.required.tileInfo)return null!=(r=this._get("_tileInfoTask"))?r:{updating:!1};if(!this.spatialReference)return{updating:this._spatialReferenceTask.updating};const{layers:o,updating:p}=this._collectLayers([{parent:null==(e=this.map)||null==(t=e.call(this))?void 0:t.basemap,layers:null==(a=this.map)||null==(i=a.call(this))||null==(n=i.basemap)?void 0:n.baseLayers},{layers:null==(s=this.map)||null==(l=s.call(this))?void 0:l.layers}]);if(o&&o.length>0&&"tileInfo"in o[0]){const e=o[0].tileInfo;return{tileInfo:e&&e.spatialReference.equals(this.spatialReference)?e:null,updating:!1}}return{updating:p}}get _heightModelInfoTask(){var e,t;if(!this.required.heightModelInfo||this.suspended&&null!=(e=this._get("_heightModelInfoTask"))&&e.heightModelInfo)return null!=(t=this._get("_heightModelInfoTask"))?t:{updating:!1};const{layers:a,updating:i}=this._allLayers;for(const o of a){var n,s;if(this._debug("Considering",null!=(n=null!=(s=o.title)?s:o.id)?n:o.declaredClass,"for height model info"),u(o)){const e=c(o);var l,r;if(e)return this._debug("Derived height model info",e),{heightModelInfo:e,vcsWkid:null==(l=o.spatialReference)?void 0:l.vcsWkid,latestVcsWkid:null==(r=o.spatialReference)?void 0:r.latestVcsWkid,updating:!1}}this._debug("Layer does not support height models")}return this._debug("No height model info found,","updating",i),{updating:i}}get _extentCandidatesTask(){var e;if(this.suspended||!this.required.extent)return null!=(e=this._get("_extentCandidatesTask"))?e:{updating:!1};if(!this.spatialReference)return{updating:this._spatialReferenceTask.updating};const t=this._allLayers,a=t.updating,i=[];for(const l of t.layers){var s;const e="fullExtents"in l&&l.fullExtents||(n(l.fullExtent)?[l.fullExtent]:[]),t=this.requiresExtentInSpatialReference?null:e[0],a=null!=(s=e.find((e=>e.spatialReference.equals(this.spatialReference))))?s:t;if(a)return{candidates:[{extent:a,layer:l}],updating:!1};if(this._getSupportedSpatialReferences(l).length>0)for(const n of e)i.push({extent:n,layer:l})}return{candidates:i,updating:a}}get _extentTask(){const{candidates:e,updating:t}=this._extentCandidatesTask;if(t)return{updating:t};if(l(e)||0===e.length)return{updating:!1};if(!this.spatialReference)return{updating:this._spatialReferenceTask.updating};const a=this._pickExtentCandidate(e),s=this.spatialReference;return a.extent.equals(this._projectExtentTask.input)&&s.equals(this._projectExtentTask.spatialReference)?{extent:this._projectExtentTask.output,updating:n(this._projectExtentTask.task)&&!this._projectExtentTask.task.finished}:(n(this._projectExtentTask.task)&&(this._debug("Aborting project extent task"),this._projectExtentTask.task=i(this._projectExtentTask.task)),this._debug("Starting project extent task for",a.extent),this._projectExtentTask={input:a.extent.clone(),output:null,spatialReference:s.clone(),task:r((async e=>{try{const t=await g(a.extent,s,a.layer.portalItem,e);this._debug("Project extent task finished",t),this._projectExtentTask={...this._projectExtentTask,task:null,output:t}}catch(t){if(o(e))return;this._projectExtentTask={...this._projectExtentTask,task:null}}}))},{updating:!0})}_processSpatialReferenceCandidates(e,t){var a;const i=this._getSupportedSpatialReferences(e);if(0!==i.length)if(this._debug("Spatial reference candidates from",null!=(a=e.title)?a:e.id,":",i.map((e=>`${e.spatialReference.wkid}:${n(e.viewingMode)?f(e.viewingMode):"global/local"}`)).join(", ")),l(t.candidates))t.candidates=i;else{const e=[],a=(e,t)=>n(e)?n(t)?e===t&&e:e:t;for(const n of t.candidates)for(const t of i){if(!n.spatialReference.equals(t.spatialReference))continue;const i=a(n.viewingMode,t.viewingMode);if(!1!==i){e.push({spatialReference:n.spatialReference,viewingMode:i});break}}e.length>0&&(t.candidates=e)}}_pickSpatialReferenceCandidate(e){const t=this.defaultSpatialReference;return l(e)||e.length<1?n(t)?{spatialReference:t,viewingMode:null}:null:(n(t)&&e.length>1&&e.some((({spatialReference:e})=>e.equals(t)))&&(e=e.filter((({spatialReference:e})=>e.equals(t)))),e.length>1&&e.some((({viewingMode:e})=>e!==h.Local))&&(e=e.filter((({viewingMode:e})=>e!==h.Local))),e[0])}_getSupportedSpatialReferences(e){const t="supportedSpatialReferences"in e&&e.supportedSpatialReferences||(e.spatialReference?[e.spatialReference]:[]);if(0===t.length)return[];const a=[];for(const i of t){const t=this.getSpatialReferenceSupport({spatialReference:i,layer:e});if(n(t)){const e=n(t.constraints)?t.constraints:[{spatialReference:i,viewingMode:null}];for(const{spatialReference:t,viewingMode:i}of e)(!this.requiresExtentInSpatialReference||l(this.userSpatialReference)||t.equals(this.userSpatialReference))&&a.push({spatialReference:t,viewingMode:i})}}return a}_pickExtentCandidate(e){const t=this.spatialReference;return e.find((({extent:e})=>t.equals(e.spatialReference)))||e[0]}_collectLayers(e){var t;if("loaded"!==this._loadMaybe(null==(t=this.map)?void 0:t.call(this)))return{layers:[],updating:!0};const a={layers:[],preloading:-1,updating:!1};for(const i of e)if(this._collectCollection(i,a),a.preloading===this.sourcePreloadCount)break;return{layers:a.layers,updating:a.updating}}_collectCollection(e,t){if(e.layers){switch(this._loadMaybe(e.parent)){case"loading":return t.updating=!0,void++t.preloading;case"failed":return}for(const n of e.layers){switch(this._loadMaybe(n)){case"failed":continue;case"loading":t.updating=!0,++t.preloading;break;case"loaded":var a,i;if(!t.updating)this._debug("Considering layer",null!=(a=null!=(i=n.title)?i:n.id)?a:n.declaredClass),t.layers.push(n);"layers"in n&&this._collectCollection({layers:n.layers},t)}if(t.preloading===this.sourcePreloadCount)break}}}_loadMaybe(e){return e&&"loadStatus"in e?"not-loaded"===e.loadStatus?(this._debug("Triggering load",null!=(t=null!=(a=e.title)?a:e.id)?t:e.declaredClass),e.load(),"loading"):e.loadStatus:"loaded";var t,a}_debug(...e){this.logDebugInformation&&y.info(...e)}};e([p()],_.prototype,"required",void 0),e([p({constructOnly:!0})],_.prototype,"map",void 0),e([p({constructOnly:!0})],_.prototype,"getSpatialReferenceSupport",void 0),e([p()],_.prototype,"defaultSpatialReference",void 0),e([p()],_.prototype,"userSpatialReference",void 0),e([p()],_.prototype,"sourcePreloadCount",void 0),e([p()],_.prototype,"priorityCollection",void 0),e([p()],_.prototype,"logDebugInformation",void 0),e([p()],_.prototype,"requiresExtentInSpatialReference",void 0),e([p()],_.prototype,"suspended",void 0),e([p({readOnly:!0})],_.prototype,"ready",null),e([p({readOnly:!0})],_.prototype,"heightModelInfoReady",null),e([p({readOnly:!0})],_.prototype,"spatialReference",null),e([p({readOnly:!0})],_.prototype,"extent",null),e([p({readOnly:!0})],_.prototype,"heightModelInfo",null),e([p({readOnly:!0})],_.prototype,"vcsWkid",null),e([p({readOnly:!0})],_.prototype,"latestVcsWkid",null),e([p({readOnly:!0})],_.prototype,"viewingMode",null),e([p({readOnly:!0})],_.prototype,"tileInfo",null),e([p({readOnly:!0})],_.prototype,"mapCollections",null),e([p({readOnly:!0})],_.prototype,"_allLayers",null),e([p({readOnly:!0})],_.prototype,"_spatialReferenceTask",null),e([p({readOnly:!0})],_.prototype,"_tileInfoTask",null),e([p({readOnly:!0})],_.prototype,"_heightModelInfoTask",null),e([p({readOnly:!0})],_.prototype,"_extentCandidatesTask",null),e([p()],_.prototype,"_extentTask",null),e([p()],_.prototype,"_projectExtentTask",void 0),_=e([d("esri.views.support.DefaultsFromMap")],_);export{_ as DefaultsFromMap};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{abortMaybe as a,isSome as n,unwrap as i,isNone as s}from"../../core/maybe.js";import{createTask as l,isAborted as r}from"../../core/promiseUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import{supportsHeightModelInfo as u,deriveHeightModelInfoFromLayer as c}from"../../geometry/support/heightModelInfoUtils.js";import{ViewingMode as d}from"../ViewingMode.js";import{projectWithEngineOrService as f}from"./projectionUtils.js";let h=class extends t{constructor(e){super(e),this.required={tileInfo:!1,heightModelInfo:!1,extent:!1},this.defaultSpatialReference=null,this.userSpatialReference=null,this.sourcePreloadCount=10,this.priorityCollection=null,this.requiresExtentInSpatialReference=!0,this.suspended=!1,this._projectExtentTask={task:null,input:null,output:null,spatialReference:null}}destroy(){this._projectExtentTask.task&&(this._projectExtentTask.task=a(this._projectExtentTask.task)),this._set("map",null)}get ready(){return!this._spatialReferenceTask.updating&&!this._tileInfoTask.updating&&!this._extentTask.updating}get heightModelInfoReady(){return!this._heightModelInfoTask.updating}get spatialReference(){return n(this.userSpatialReference)?this.userSpatialReference:i(this._spatialReferenceTask.spatialReference)}get extent(){return i(this._extentTask.extent)}get heightModelInfo(){return i(this._heightModelInfoTask.heightModelInfo)}get vcsWkid(){return i(this._heightModelInfoTask.vcsWkid)}get latestVcsWkid(){return i(this._heightModelInfoTask.latestVcsWkid)}get viewingMode(){return s(this.userSpatialReference)||this.userSpatialReference.equals(i(this._spatialReferenceTask.spatialReference))?i(this._spatialReferenceTask.viewingMode):null}get tileInfo(){return i(this._tileInfoTask.tileInfo)}get mapCollections(){var e,t,a,i;const s=null==(e=this.map)?void 0:e.call(this),l=[];return n(this.priorityCollection)&&l.push(this.priorityCollection),l.push({parent:null==s?void 0:s.basemap,layers:null==s||null==(t=s.basemap)?void 0:t.baseLayers},{layers:null==s?void 0:s.layers},{parent:null==s?void 0:s.ground,layers:null==s||null==(a=s.ground)?void 0:a.layers},{parent:null==s?void 0:s.basemap,layers:null==s||null==(i=s.basemap)?void 0:i.referenceLayers}),l}get _allLayers(){return this._collectLayers(this.mapCollections)}get _spatialReferenceTask(){var e;if(this.suspended)return null!=(e=this._get("_spatialReferenceTask"))?e:{updating:!1};const{layers:t,updating:a}=this._allLayers;let i=null;for(const s of t){const e=this._getSupportedSpatialReferences(s);if(e.length>0){const t=this._narrowDownSpatialReferenceCandidates(i,e);n(t)&&(i=t)}if(n(i)&&1===i.length)break}if(a&&(s(i)||1!==i.length))return{updating:!0};const l=this._pickSpatialReferenceCandidate(i);return{spatialReference:n(l)?l.spatialReference:null,viewingMode:n(l)?l.viewingMode:null,updating:!1}}get _tileInfoTask(){var e,t,a,n,i,s,l,r;if(!this.required.tileInfo)return null!=(r=this._get("_tileInfoTask"))?r:{updating:!1};if(!this.spatialReference)return{updating:this._spatialReferenceTask.updating};const{layers:o,updating:p}=this._collectLayers([{parent:null==(e=this.map)||null==(t=e.call(this))?void 0:t.basemap,layers:null==(a=this.map)||null==(n=a.call(this))||null==(i=n.basemap)?void 0:i.baseLayers},{layers:null==(s=this.map)||null==(l=s.call(this))?void 0:l.layers}]);if(o&&o.length>0&&"tileInfo"in o[0]){const e=o[0].tileInfo;return{tileInfo:e&&e.spatialReference.equals(this.spatialReference)?e:null,updating:!1}}return{updating:p}}get _heightModelInfoTask(){var e,t;if(!this.required.heightModelInfo||this.suspended&&null!=(e=this._get("_heightModelInfoTask"))&&e.heightModelInfo)return null!=(t=this._get("_heightModelInfoTask"))?t:{updating:!1};const{layers:a,updating:n}=this._allLayers;for(const l of a)if(u(l)){const e=c(l);var i,s;if(e)return{heightModelInfo:e,vcsWkid:null==(i=l.spatialReference)?void 0:i.vcsWkid,latestVcsWkid:null==(s=l.spatialReference)?void 0:s.latestVcsWkid,updating:!1}}return{updating:n}}get _extentCandidatesTask(){var e;if(this.suspended||!this.required.extent)return null!=(e=this._get("_extentCandidatesTask"))?e:{updating:!1};if(!this.spatialReference)return{updating:this._spatialReferenceTask.updating};const t=this._allLayers,a=t.updating,i=[];for(const l of t.layers){var s;const e="fullExtents"in l&&l.fullExtents||(n(l.fullExtent)?[l.fullExtent]:[]),t=this.requiresExtentInSpatialReference?null:e[0],a=null!=(s=e.find((e=>e.spatialReference.equals(this.spatialReference))))?s:t;if(a)return{candidates:[{extent:a,layer:l}],updating:!1};if(this._getSupportedSpatialReferences(l).length>0)for(const n of e)i.push({extent:n,layer:l})}return{candidates:i,updating:a}}get _extentTask(){const{candidates:e,updating:t}=this._extentCandidatesTask;if(t)return{updating:t};if(s(e)||0===e.length)return{updating:!1};if(!this.spatialReference)return{updating:this._spatialReferenceTask.updating};const i=this._pickExtentCandidate(e),o=this.spatialReference;return i.extent.equals(this._projectExtentTask.input)&&o.equals(this._projectExtentTask.spatialReference)?{extent:this._projectExtentTask.output,updating:n(this._projectExtentTask.task)&&!this._projectExtentTask.task.finished}:(n(this._projectExtentTask.task)&&(this._projectExtentTask.task=a(this._projectExtentTask.task)),this._projectExtentTask={input:i.extent.clone(),output:null,spatialReference:o.clone(),task:l((async e=>{try{const t=await f(i.extent,o,i.layer.portalItem,e);this._projectExtentTask={...this._projectExtentTask,task:null,output:t}}catch(t){if(r(e))return;this._projectExtentTask={...this._projectExtentTask,task:null}}}))},{updating:!0})}_narrowDownSpatialReferenceCandidates(e,t){if(s(e))return t;const a=[],i=(e,t)=>n(e)?n(t)?e===t&&e:e:t;for(const n of e)for(const e of t){if(!n.spatialReference.equals(e.spatialReference))continue;const t=i(n.viewingMode,e.viewingMode);if(!1!==t){a.push({spatialReference:n.spatialReference,viewingMode:t});break}}return a.length>0?a:null}_pickSpatialReferenceCandidate(e){const t=this.defaultSpatialReference;return s(e)||e.length<1?n(t)?{spatialReference:t,viewingMode:null}:null:(n(t)&&e.length>1&&e.some((({spatialReference:e})=>e.equals(t)))&&(e=e.filter((({spatialReference:e})=>e.equals(t)))),e.length>1&&e.some((({viewingMode:e})=>e!==d.Local))&&(e=e.filter((({viewingMode:e})=>e!==d.Local))),e[0])}_getSupportedSpatialReferences(e){const t="supportedSpatialReferences"in e&&e.supportedSpatialReferences||(e.spatialReference?[e.spatialReference]:[]);if(0===t.length)return[];const a=[];for(const i of t){const t=this.getSpatialReferenceSupport({spatialReference:i,layer:e});if(n(t)){const e=n(t.constraints)?t.constraints:[{spatialReference:i,viewingMode:null}];for(const{spatialReference:t,viewingMode:n}of e)(!this.requiresExtentInSpatialReference||s(this.userSpatialReference)||t.equals(this.userSpatialReference))&&a.push({spatialReference:t,viewingMode:n})}}return a}_pickExtentCandidate(e){const t=this.spatialReference;return e.find((({extent:e})=>t.equals(e.spatialReference)))||e[0]}_collectLayers(e){var t;if("loaded"!==this._loadMaybe(null==(t=this.map)?void 0:t.call(this)))return{layers:[],updating:!0};const a={layers:[],preloading:-1,updating:!1};for(const n of e)if(this._collectCollection(n,a),a.preloading===this.sourcePreloadCount)break;return{layers:a.layers,updating:a.updating}}_collectCollection(e,t){if(e.layers){switch(this._loadMaybe(e.parent)){case"loading":return t.updating=!0,void++t.preloading;case"failed":return}for(const a of e.layers){switch(this._loadMaybe(a)){case"failed":continue;case"loading":t.updating=!0,++t.preloading;break;case"loaded":t.updating||t.layers.push(a),"layers"in a&&this._collectCollection({layers:a.layers},t)}if(t.preloading===this.sourcePreloadCount)break}}}_loadMaybe(e){return e&&"loadStatus"in e?"not-loaded"===e.loadStatus?(e.title,e.load(),"loading"):e.loadStatus:"loaded"}};e([o()],h.prototype,"required",void 0),e([o({constructOnly:!0})],h.prototype,"map",void 0),e([o({constructOnly:!0})],h.prototype,"getSpatialReferenceSupport",void 0),e([o()],h.prototype,"defaultSpatialReference",void 0),e([o()],h.prototype,"userSpatialReference",void 0),e([o()],h.prototype,"sourcePreloadCount",void 0),e([o()],h.prototype,"priorityCollection",void 0),e([o()],h.prototype,"requiresExtentInSpatialReference",void 0),e([o()],h.prototype,"suspended",void 0),e([o({readOnly:!0})],h.prototype,"ready",null),e([o({readOnly:!0})],h.prototype,"heightModelInfoReady",null),e([o({readOnly:!0})],h.prototype,"spatialReference",null),e([o({readOnly:!0})],h.prototype,"extent",null),e([o({readOnly:!0})],h.prototype,"heightModelInfo",null),e([o({readOnly:!0})],h.prototype,"vcsWkid",null),e([o({readOnly:!0})],h.prototype,"latestVcsWkid",null),e([o({readOnly:!0})],h.prototype,"viewingMode",null),e([o({readOnly:!0})],h.prototype,"tileInfo",null),e([o({readOnly:!0})],h.prototype,"mapCollections",null),e([o({readOnly:!0})],h.prototype,"_allLayers",null),e([o({readOnly:!0})],h.prototype,"_spatialReferenceTask",null),e([o({readOnly:!0})],h.prototype,"_tileInfoTask",null),e([o({readOnly:!0})],h.prototype,"_heightModelInfoTask",null),e([o({readOnly:!0})],h.prototype,"_extentCandidatesTask",null),e([o()],h.prototype,"_extentTask",null),e([o()],h.prototype,"_projectExtentTask",void 0),h=e([p("esri.views.support.DefaultsFromMap")],h);export{h as DefaultsFromMap};
@@ -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"../../Viewpoint.js";import o from"../../core/Collection.js";import i from"../../core/Error.js";import r from"../../core/Evented.js";import a from"../../core/Logger.js";import{isSome as s}from"../../core/maybe.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{cast as c}from"../../core/accessorSupport/decorators/cast.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{SlideThumbnail as p}from"../../webdoc/support/SlideThumbnail.js";import m from"../../webmap/Bookmark.js";import{GoToMixin as u}from"../support/GoTo.js";const k="esri.widgets.Bookmarks.BookmarksViewModel",d=a.getLogger(k),v=o.ofType(m),w={width:128,height:128,format:"png"},h={takeScreenshot:!0,captureViewpoint:!0,captureRotation:!0,captureScale:!0,captureTimeExtent:!0},b={time:!0};let f=class extends(u(r.EventedAccessor)){constructor(t){super(t),this.abilities={...b},this.activeBookmark=null}destroy(){this.view=null,this._set("activeBookmark",null)}castAbilities(t){return{...b,...t}}set bookmarks(t){void 0!==t?this._override("bookmarks",t):this._clearOverride("bookmarks")}get bookmarks(){return this.get("view.map.bookmarks")||new v}set defaultCreateOptions(t){this._set("defaultCreateOptions",{...h,...t})}get defaultCreateOptions(){return h}set defaultEditOptions(t){this._set("defaultEditOptions",{...h,...t})}get defaultEditOptions(){return h}get state(){const t=this.get("view");return t&&!t.ready?"loading":"ready"}get view(){return this._get("view")}set view(t){t&&"2d"!==t.type&&d.error(new i("view:invalid-view","SceneView is not supported",{view:t})),this._set("view",t)}async createBookmark(t){const{view:e,defaultCreateOptions:o,abilities:r}=this;if(!e){const t=new i("create-bookmark:invalid-view","Cannot create a bookmark without a view.");return d.error(t),Promise.reject(t)}const{takeScreenshot:a,screenshotSettings:n,captureViewpoint:c,captureRotation:l,captureScale:p,captureTimeExtent:u}={...o,...t},k=a?await this._createThumbnail(n):void 0,v=r.time&&u&&s(e.timeExtent)?e.timeExtent.clone():void 0;return new m({...k&&{thumbnail:k},...u&&{timeExtent:v},...c&&{viewpoint:this._createViewpoint({view:e,captureScale:p,captureRotation:l})}})}async editBookmark(t,e){const{view:o,defaultEditOptions:r}=this;if(!o){const t=new i("edit-bookmark:invalid-view","Cannot edit a bookmark without a view.");return d.error(t),Promise.reject(t)}const{takeScreenshot:a,screenshotSettings:n,captureViewpoint:c,captureRotation:l,captureScale:p,captureTimeExtent:m}={...r,...e},u=a?await this._createThumbnail(n):void 0;return u&&(t.thumbnail=u),c&&(t.viewpoint=this._createViewpoint({view:o,captureScale:p,captureRotation:l})),m&&s(o.timeExtent)&&(t.timeExtent=o.timeExtent.clone()),this.emit("bookmark-edit",{bookmark:t}),t}goTo(t){const{abilities:e,view:o}=this;if(!o){const t=new i("go-to:invalid-view","Cannot go to a bookmark without a view");return d.error(t),Promise.reject(t)}const r=null==t?void 0:t.viewpoint;if(!r){const e=new i("go-to:invalid-bookmark","Cannot go to a bookmark that does not contain a 'viewpoint'.",{bookmark:t});return d.error(e),Promise.reject(e)}this._set("activeBookmark",t);const a={target:r},s=this.callGoTo(a),n=null==t?void 0:t.timeExtent;return e.time&&n&&(o.timeExtent=n),this.emit("bookmark-select",{bookmark:t}),s.catch((()=>{})).then((()=>this._set("activeBookmark",null))),s}async _createThumbnail(t){const e=await this.view.takeScreenshot({...w,...t});return new p({url:e.dataUrl})}_createViewpoint({view:t,captureRotation:o,captureScale:i}){var r,a;const s=null==(r=t.viewpoint)?void 0:r.clone();return new e({targetGeometry:null==(a=t.extent)?void 0:a.clone(),rotation:o&&(null==s?void 0:s.rotation)||0,scale:i&&(null==s?void 0:s.scale)||0})}};t([n()],f.prototype,"abilities",void 0),t([c("abilities")],f.prototype,"castAbilities",null),t([n({readOnly:!0})],f.prototype,"activeBookmark",void 0),t([n({type:v})],f.prototype,"bookmarks",null),t([n()],f.prototype,"defaultCreateOptions",null),t([n()],f.prototype,"defaultEditOptions",null),t([n({readOnly:!0})],f.prototype,"state",null),t([n({value:null})],f.prototype,"view",null),f=t([l(k)],f);const g=f;export{g as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../Viewpoint.js";import o from"../../core/Collection.js";import i from"../../core/Error.js";import r from"../../core/Evented.js";import a from"../../core/Logger.js";import{isSome as s}from"../../core/maybe.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{cast as c}from"../../core/accessorSupport/decorators/cast.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{SlideThumbnail as p}from"../../webdoc/support/SlideThumbnail.js";import m from"../../webmap/Bookmark.js";import{GoToMixin as u}from"../support/GoTo.js";const k="esri.widgets.Bookmarks.BookmarksViewModel",d=a.getLogger(k),w=o.ofType(m),v={width:128,height:128,format:"png"},h={takeScreenshot:!0,captureViewpoint:!0,captureRotation:!0,captureScale:!0,captureTimeExtent:!0},b={time:!0};let f=class extends(u(r.EventedAccessor)){constructor(t){super(t),this.abilities={...b},this.activeBookmark=null}destroy(){this.view=null,this._set("activeBookmark",null)}castAbilities(t){return{...b,...t}}set bookmarks(t){void 0!==t?this._override("bookmarks",t):this._clearOverride("bookmarks")}get bookmarks(){return this.get("view.map.bookmarks")||new w}set defaultCreateOptions(t){this._set("defaultCreateOptions",{...h,...t})}get defaultCreateOptions(){return h}set defaultEditOptions(t){this._set("defaultEditOptions",{...h,...t})}get defaultEditOptions(){return h}get state(){const t=this.get("view");return t&&!t.ready?"loading":"ready"}get view(){return this._get("view")}set view(t){t&&"2d"!==t.type&&d.error(new i("view:invalid-view","SceneView is not supported",{view:t})),this._set("view",t)}async createBookmark(t){const{view:e,defaultCreateOptions:o,abilities:r}=this;if(!e){const t=new i("create-bookmark:invalid-view","Cannot create a bookmark without a view.");throw d.error(t),t}const{takeScreenshot:a,screenshotSettings:n,captureViewpoint:c,captureRotation:l,captureScale:p,captureTimeExtent:u}={...o,...t},k=a?await this._createThumbnail(n):void 0,w=r.time&&u&&s(e.timeExtent)?e.timeExtent.clone():void 0;return new m({...k&&{thumbnail:k},...u&&{timeExtent:w},...c&&{viewpoint:this._createViewpoint({view:e,captureScale:p,captureRotation:l})}})}async editBookmark(t,e){const{view:o,defaultEditOptions:r}=this;if(!o){const t=new i("edit-bookmark:invalid-view","Cannot edit a bookmark without a view.");throw d.error(t),t}const{takeScreenshot:a,screenshotSettings:n,captureViewpoint:c,captureRotation:l,captureScale:p,captureTimeExtent:m}={...r,...e},u=a?await this._createThumbnail(n):void 0;return u&&(t.thumbnail=u),c&&(t.viewpoint=this._createViewpoint({view:o,captureScale:p,captureRotation:l})),m&&s(o.timeExtent)&&(t.timeExtent=o.timeExtent.clone()),this.emit("bookmark-edit",{bookmark:t}),t}goTo(t){const{abilities:e,view:o}=this;if(!o){const t=new i("go-to:invalid-view","Cannot go to a bookmark without a view");return d.error(t),Promise.reject(t)}const r=null==t?void 0:t.viewpoint;if(!r){const e=new i("go-to:invalid-bookmark","Cannot go to a bookmark that does not contain a 'viewpoint'.",{bookmark:t});return d.error(e),Promise.reject(e)}this._set("activeBookmark",t);const a={target:r},s=this.callGoTo(a),n=null==t?void 0:t.timeExtent;return e.time&&n&&(o.timeExtent=n),this.emit("bookmark-select",{bookmark:t}),s.catch((()=>{})).then((()=>this._set("activeBookmark",null))),s}async _createThumbnail(t){const e=await this.view.takeScreenshot({...v,...t});return new p({url:e.dataUrl})}_createViewpoint({view:t,captureRotation:o,captureScale:i}){var r,a;const s=null==(r=t.viewpoint)?void 0:r.clone();return new e({targetGeometry:null==(a=t.extent)?void 0:a.clone(),rotation:o&&(null==s?void 0:s.rotation)||0,scale:i&&(null==s?void 0:s.scale)||0})}};t([n()],f.prototype,"abilities",void 0),t([c("abilities")],f.prototype,"castAbilities",null),t([n({readOnly:!0})],f.prototype,"activeBookmark",void 0),t([n({type:w})],f.prototype,"bookmarks",null),t([n()],f.prototype,"defaultCreateOptions",null),t([n()],f.prototype,"defaultEditOptions",null),t([n({readOnly:!0})],f.prototype,"state",null),t([n({value:null})],f.prototype,"view",null),f=t([l(k)],f);const g=f;export{g 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{getAssetUrl as e}from"../../assets.js";import o from"../../Graphic.js";import"../../intl.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import r from"../../core/Evented.js";import n from"../../core/Handles.js";import a from"../../core/Logger.js";import{init as h,whenOnce as c}from"../../core/watchUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import m from"../../geometry/Point.js";import{load as p}from"../../geometry/projection.js";import v from"../../symbols/PictureMarkerSymbol.js";import u from"./support/Conversion.js";import{isValidPoint as g,isSupportedNotation as _}from"./support/coordinateConversionUtils.js";import{generateDefaultFormats as w,setDefaultPatterns as f}from"./support/formatUtils.js";import{GoToMixin as C}from"../support/GoTo.js";import{onLocaleChange as y,getLocale as b}from"../../intl/locale.js";import{fetchMessageBundle as P}from"../../intl/messages.js";const j={default:"default",crosshair:"crosshair"},M=new m([0,0,500]),L="xy",S=["mgrs","utm","usng","dd","dms","ddm"],F="esri__coordinateConversionWidgetState",A=a.getLogger("esri.widgets.CoordinateConversion.CoordinateConversionViewModel"),E={conversions:"conversions",formats:"formats",view:"view",viewChange:"view-change"},x="esri/images/search/search-symbol-32.png";let G=class extends(C(r.EventedAccessor)){constructor(t){super(t),this._conversionPromise=null,this._handles=new n,this._locationGraphic=null,this._pointerCount=0,this.conversions=new i,this.formats=new i,this.formatterAvailable=!1,this.messages=null,this.filteredFormats=new i,this.locationSymbol=new v({url:e(x),width:24,height:24}),this.storageEnabled=!0,this.storageType="session",this.view=null,this._saveWidgetState=this._saveWidgetState.bind(this),this._handleFormatChange=this._handleFormatChange.bind(this),this._handleConversionChange=this._handleConversionChange.bind(this),this._handleViewChange=this._handleViewChange.bind(this),this._onClick=this._onClick.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this)}initialize(){const t=async()=>this.messages=await P("esri/widgets/CoordinateConversion/t9n/CoordinateConversion");t().then((()=>{if(!this.destroyed&&(this.formats.addMany(w(this.messages)),this.storageEnabled&&this._loadWidgetState(),this.formats.forEach((t=>{t.viewModel=this,this._handles.add(t.watch("currentPattern",this._saveWidgetState),t.name)})),this._handles.add(this.conversions.on("change",this._handleConversionChange),E.conversions),this._handles.add(this.formats.on("change",this._handleFormatChange),E.formats),this._handles.add(y((()=>{t().then((()=>{f(this.messages,this.formats)}))}))),p().then((()=>{this.formatterAvailable=!0})).catch((t=>{A.error(new s("coordinate-conversion:projection-load-failed","Failed to load the projection module.",{error:t})),this.formatterAvailable=!1,this._filterFormatsAndConversions()})).then((()=>this._handles.add(h(this,"view",this._handleViewChange),E.viewChange))),0===this.conversions.length)){const t=this.formats.find((t=>t.name===L))||this.formats.getItemAt(0);this.conversions.add(new u({format:t}))}}))}destroy(){this._handles.removeAll(),this._cleanUpView(this.view),this.view=null}set currentLocation(t){this._set("currentLocation",t),this._updateConversions()}get currentLocation(){return this._get("currentLocation")||null}set mode(t){switch(t){case"capture":this.currentLocation=null,this._startCaptureMode(),this._set("mode",t);break;case"live":this._startLiveMode(),this._set("mode",t)}}get mode(){return this._get("mode")||"live"}get state(){const{messages:t,view:e}=this,o=null==e?void 0:e.ready;return t?o?"ready":e?"loading":"disabled":"disabled"}get storage(){const{storageType:t}=this;return"session"===t?sessionStorage:localStorage}get waitingForConversions(){return null!=this._conversionPromise}setLocation(t){if(this.view.graphics.remove(this._locationGraphic),t){const e=t.clone();e.hasZ&&(e.z=void 0),this._locationGraphic=new o({geometry:e,symbol:this.get("locationSymbol")}),this.view.graphics.add(this._locationGraphic)}}convert(t,e){return g(e)?Promise.resolve().then((()=>t.convert(e))):Promise.reject(new s("coordinate-conversion:invalid-point","Invalid point cannot be converted.",{point:e}))}goToLocation(t){if(this.get("view.clippingArea")||this.get("view.map.basemap.baseLayers.length")>0){const e=this.get("view.clippingArea")||this.view.map.basemap.baseLayers.getItemAt(0).fullExtent;return e?e.contains(t)?this.callGoTo({target:t}):Promise.reject(new s("coordinate-conversion:go-to-failed","Point outside basemap extent.",{point:t})):this.callGoTo({target:t})}return this.callGoTo({target:t})}pause(){this.currentLocation=null,this._handles.remove(E.view),this.view&&(this.view.cursor=j.default,this.view.graphics.remove(this._locationGraphic))}previewConversion(t,e=this.currentLocation||M){return this._convertMany([t],e).then((()=>t.displayCoordinate))}resume(){"capture"===this.mode?this._startCaptureMode():this._startLiveMode()}reverseConvert(t,e){return e.reverseConvert(t)}async updateConversions(t,e){return e&&e.type&&"point"===e.type?this._convertMany(t,e):(this._clearConversions(this.conversions),Promise.reject(new s("coordinate-conversion:invalid-input-point","Point is invalid, conversions cannot be updated.",{point:e})))}_cleanUpView(t){t&&(t.graphics.remove(this._locationGraphic),this._handles.remove(E.view),t.cursor=j.default)}_clearConversions(t){t.forEach((t=>{t.position={location:null,coordinate:null}}))}_convertMany(t,e){return Promise.all(t.map((t=>t.format.convert(e).then((e=>(t.position=e,t))).catch((()=>{t.position=null}))))).then((()=>t))}_handleConversionChange(t){t.added.forEach((t=>{const e=t.format;e.viewModel=this,this.currentLocation&&(this._set("waitingForConversions",!0),this.convert(e,this.currentLocation).then((e=>{t.position=e,this._set("waitingForConversions",!1)})))})),this._saveWidgetState()}_handleFormatChange(t){t.added.forEach((t=>{this._handles.add(t.watch("currentPattern",this._saveWidgetState),t.name),t.viewModel=this})),t.removed.forEach((t=>{t.viewModel=null,this._handles.remove(t.name)}))}_loadWidgetState(){try{const t=JSON.parse(this.storage.getItem(F));t&&this._setWidgetState(t)}catch(t){A.error(new s("coordinate-conversion:invalid-session-storage-json","Could not read from storage.",{error:t}))}}_startCaptureMode(){this._handles.remove(E.view),this.view&&(this.view.cursor=j.crosshair,this.currentLocation&&this.setLocation(this.currentLocation),this._handles.add(this.view.on("click",this._onClick),E.view))}_startLiveMode(){this._pointerCount=0,this._handles.remove(E.view),this.view&&(this.view.cursor=j.default,this.view.graphics.remove(this._locationGraphic),this._handles.add([this.view.on("pointer-down",this._onPointerDown),this.view.on("pointer-up",this._onPointerUp),this.view.on("pointer-move",this._onPointerMove)],E.view))}_handleViewChange(t,e){e&&e!==t&&this._cleanUpView(e),t&&("capture"===this.mode&&this._startCaptureMode(),this._startLiveMode(),e&&this._filterFormatsAndConversions())}_onClick(t){if(0===t.button){const e=this.view.toMap(t),o=e&&e.normalize();this.setLocation(o),this.currentLocation=o}}_onPointerDown(t){const{pointerType:e}=t;if(this._pointerCount++,("touch"===e||"pen"===e)&&1===this._pointerCount){const e=this.view.toMap(t);this.currentLocation=e&&e.normalize()}}_onPointerMove(t){const{pointerType:e}=t;if("mouse"===e||1===this._pointerCount){const e=this.view.toMap(t);this.currentLocation=e&&e.normalize()}}_onPointerUp(){this._pointerCount--}_setWidgetState(t){try{t.formats.forEach((e=>{const o=this.formats.find((t=>t.name===e.name));o&&t.locale===b()&&e.currentPattern&&(o.currentPattern=e.currentPattern),o&&e.index>=0&&this.conversions.add(new u({format:o}))}))}catch(e){A.warn(new s("coordinate-conversion:session-storage-read-error","Could not get widget state from stored JSON.",{error:e}))}}_saveWidgetState(){if(!this.storageEnabled)return;const t=this._toJSON();try{this.storage.setItem(F,JSON.stringify({formats:t,locale:b()}))}catch(e){A.error(new s("coordinate-conversion:local-storage-write-error","Could not write to localStorage.",{error:e}))}}async _updateConversions(){try{await this.updateConversions(this.conversions.toArray(),this.currentLocation)}catch{}}_toJSON(){return this.formats.filter((t=>{const e=t.name;return"xy"===e||"basemap"===e||_(e)})).map((t=>({name:t.name,currentPattern:t.currentPattern,defaultPattern:t.defaultPattern,index:this.conversions.findIndex((e=>e.format===t))}))).sort(((t,e)=>t.index-e.index)).toArray()}_filterFormatsAndConversions(){const{formatterAvailable:t,conversions:e,formats:o}=this;t||this._handles.add(c(this,"view.spatialReference",(t=>{const i=t.isWebMercator||t.isWGS84,s=o.filter((t=>{const{name:e}=t;return!!S.includes(e)||"xy"===e&&!i})),r=this.filteredFormats.filter((t=>"xy"===t.name&&i&&!this.formats.includes(t))),n=e.filter((t=>s.includes(t.format)));o.removeMany(s),e.removeMany(n),this.filteredFormats.addMany(s.filter((t=>!this.filteredFormats.includes(t)))),o.addMany(r)})),E.view)}};t([d()],G.prototype,"conversions",void 0),t([d({type:m})],G.prototype,"currentLocation",null),t([d()],G.prototype,"formats",void 0),t([d()],G.prototype,"messages",void 0),t([d()],G.prototype,"mode",null),t([d()],G.prototype,"filteredFormats",void 0),t([d({readOnly:!0})],G.prototype,"state",null),t([d()],G.prototype,"locationSymbol",void 0),t([d({readOnly:!0,dependsOn:["storageType"]})],G.prototype,"storage",null),t([d()],G.prototype,"storageEnabled",void 0),t([d()],G.prototype,"storageType",void 0),t([d({readOnly:!0})],G.prototype,"waitingForConversions",null),t([d()],G.prototype,"view",void 0),G=t([l("esri.widgets.CoordinateConversion.CoordinateConversionViewModel")],G);const W=G;export{W as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{getAssetUrl as e}from"../../assets.js";import o from"../../Graphic.js";import"../../intl.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import r from"../../core/Evented.js";import n from"../../core/Handles.js";import a from"../../core/Logger.js";import{init as h,whenOnce as c}from"../../core/watchUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import m from"../../geometry/Point.js";import{load as p}from"../../geometry/projection.js";import v from"../../symbols/PictureMarkerSymbol.js";import u from"./support/Conversion.js";import{isValidPoint as g,isSupportedNotation as _}from"./support/coordinateConversionUtils.js";import{generateDefaultFormats as w,setDefaultPatterns as f}from"./support/formatUtils.js";import{GoToMixin as C}from"../support/GoTo.js";import{onLocaleChange as y,getLocale as b}from"../../intl/locale.js";import{fetchMessageBundle as M}from"../../intl/messages.js";const P={default:"default",crosshair:"crosshair"},j=new m([0,0,500]),L="xy",S=["mgrs","utm","usng","dd","dms","ddm"],F="esri__coordinateConversionWidgetState",A=a.getLogger("esri.widgets.CoordinateConversion.CoordinateConversionViewModel"),E={conversions:"conversions",formats:"formats",view:"view",viewChange:"view-change"},x="esri/images/search/search-symbol-32.png";let G=class extends(C(r.EventedAccessor)){constructor(t){super(t),this._conversionPromise=null,this._handles=new n,this._locationGraphic=null,this._pointerCount=0,this.conversions=new i,this.formats=new i,this.formatterAvailable=!1,this.messages=null,this.filteredFormats=new i,this.locationSymbol=new v({url:e(x),width:24,height:24}),this.storageEnabled=!0,this.storageType="session",this.view=null,this._saveWidgetState=this._saveWidgetState.bind(this),this._handleFormatChange=this._handleFormatChange.bind(this),this._handleConversionChange=this._handleConversionChange.bind(this),this._handleViewChange=this._handleViewChange.bind(this),this._onClick=this._onClick.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this)}initialize(){const t=async()=>this.messages=await M("esri/widgets/CoordinateConversion/t9n/CoordinateConversion");t().then((()=>{if(!this.destroyed&&(this.formats.addMany(w(this.messages)),this.storageEnabled&&this._loadWidgetState(),this.formats.forEach((t=>{t.viewModel=this,this._handles.add(t.watch("currentPattern",this._saveWidgetState),t.name)})),this._handles.add(this.conversions.on("change",this._handleConversionChange),E.conversions),this._handles.add(this.formats.on("change",this._handleFormatChange),E.formats),this._handles.add(y((()=>{t().then((()=>{f(this.messages,this.formats)}))}))),p().then((()=>{this.formatterAvailable=!0})).catch((t=>{A.error(new s("coordinate-conversion:projection-load-failed","Failed to load the projection module.",{error:t})),this.formatterAvailable=!1,this._filterFormatsAndConversions()})).then((()=>this._handles.add(h(this,"view",this._handleViewChange),E.viewChange))),0===this.conversions.length)){const t=this.formats.find((t=>t.name===L))||this.formats.getItemAt(0);this.conversions.add(new u({format:t}))}}))}destroy(){this._handles.removeAll(),this._cleanUpView(this.view),this.view=null}set currentLocation(t){this._set("currentLocation",t),this._updateConversions()}get currentLocation(){return this._get("currentLocation")||null}set mode(t){switch(t){case"capture":this.currentLocation=null,this._startCaptureMode(),this._set("mode",t);break;case"live":this._startLiveMode(),this._set("mode",t)}}get mode(){return this._get("mode")||"live"}get state(){const{messages:t,view:e}=this,o=null==e?void 0:e.ready;return t?o?"ready":e?"loading":"disabled":"disabled"}get storage(){const{storageType:t}=this;return"session"===t?sessionStorage:localStorage}get waitingForConversions(){return null!=this._conversionPromise}setLocation(t){if(this.view.graphics.remove(this._locationGraphic),t){const e=t.clone();e.hasZ&&(e.z=void 0),this._locationGraphic=new o({geometry:e,symbol:this.get("locationSymbol")}),this.view.graphics.add(this._locationGraphic)}}convert(t,e){return g(e)?Promise.resolve().then((()=>t.convert(e))):Promise.reject(new s("coordinate-conversion:invalid-point","Invalid point cannot be converted.",{point:e}))}goToLocation(t){if(this.get("view.clippingArea")||this.get("view.map.basemap.baseLayers.length")>0){const e=this.get("view.clippingArea")||this.view.map.basemap.baseLayers.getItemAt(0).fullExtent;return e?e.contains(t)?this.callGoTo({target:t}):Promise.reject(new s("coordinate-conversion:go-to-failed","Point outside basemap extent.",{point:t})):this.callGoTo({target:t})}return this.callGoTo({target:t})}pause(){this.currentLocation=null,this._handles.remove(E.view),this.view&&(this.view.cursor=P.default,this.view.graphics.remove(this._locationGraphic))}previewConversion(t,e=this.currentLocation||j){return this._convertMany([t],e).then((()=>t.displayCoordinate))}resume(){"capture"===this.mode?this._startCaptureMode():this._startLiveMode()}reverseConvert(t,e){return e.reverseConvert(t)}async updateConversions(t,e){if(!e||!e.type||"point"!==e.type)throw this._clearConversions(this.conversions),new s("coordinate-conversion:invalid-input-point","Point is invalid, conversions cannot be updated.",{point:e});return this._convertMany(t,e)}_cleanUpView(t){t&&(t.graphics.remove(this._locationGraphic),this._handles.remove(E.view),t.cursor=P.default)}_clearConversions(t){t.forEach((t=>{t.position={location:null,coordinate:null}}))}_convertMany(t,e){return Promise.all(t.map((t=>t.format.convert(e).then((e=>(t.position=e,t))).catch((()=>{t.position=null}))))).then((()=>t))}_handleConversionChange(t){t.added.forEach((t=>{const e=t.format;e.viewModel=this,this.currentLocation&&(this._set("waitingForConversions",!0),this.convert(e,this.currentLocation).then((e=>{t.position=e,this._set("waitingForConversions",!1)})))})),this._saveWidgetState()}_handleFormatChange(t){t.added.forEach((t=>{this._handles.add(t.watch("currentPattern",this._saveWidgetState),t.name),t.viewModel=this})),t.removed.forEach((t=>{t.viewModel=null,this._handles.remove(t.name)}))}_loadWidgetState(){try{const t=JSON.parse(this.storage.getItem(F));t&&this._setWidgetState(t)}catch(t){A.error(new s("coordinate-conversion:invalid-session-storage-json","Could not read from storage.",{error:t}))}}_startCaptureMode(){this._handles.remove(E.view),this.view&&(this.view.cursor=P.crosshair,this.currentLocation&&this.setLocation(this.currentLocation),this._handles.add(this.view.on("click",this._onClick),E.view))}_startLiveMode(){this._pointerCount=0,this._handles.remove(E.view),this.view&&(this.view.cursor=P.default,this.view.graphics.remove(this._locationGraphic),this._handles.add([this.view.on("pointer-down",this._onPointerDown),this.view.on("pointer-up",this._onPointerUp),this.view.on("pointer-move",this._onPointerMove)],E.view))}_handleViewChange(t,e){e&&e!==t&&this._cleanUpView(e),t&&("capture"===this.mode&&this._startCaptureMode(),this._startLiveMode(),e&&this._filterFormatsAndConversions())}_onClick(t){if(0===t.button){const e=this.view.toMap(t),o=e&&e.normalize();this.setLocation(o),this.currentLocation=o}}_onPointerDown(t){const{pointerType:e}=t;if(this._pointerCount++,("touch"===e||"pen"===e)&&1===this._pointerCount){const e=this.view.toMap(t);this.currentLocation=e&&e.normalize()}}_onPointerMove(t){const{pointerType:e}=t;if("mouse"===e||1===this._pointerCount){const e=this.view.toMap(t);this.currentLocation=e&&e.normalize()}}_onPointerUp(){this._pointerCount--}_setWidgetState(t){try{t.formats.forEach((e=>{const o=this.formats.find((t=>t.name===e.name));o&&t.locale===b()&&e.currentPattern&&(o.currentPattern=e.currentPattern),o&&e.index>=0&&this.conversions.add(new u({format:o}))}))}catch(e){A.warn(new s("coordinate-conversion:session-storage-read-error","Could not get widget state from stored JSON.",{error:e}))}}_saveWidgetState(){if(!this.storageEnabled)return;const t=this._toJSON();try{this.storage.setItem(F,JSON.stringify({formats:t,locale:b()}))}catch(e){A.error(new s("coordinate-conversion:local-storage-write-error","Could not write to localStorage.",{error:e}))}}async _updateConversions(){try{await this.updateConversions(this.conversions.toArray(),this.currentLocation)}catch{}}_toJSON(){return this.formats.filter((t=>{const e=t.name;return"xy"===e||"basemap"===e||_(e)})).map((t=>({name:t.name,currentPattern:t.currentPattern,defaultPattern:t.defaultPattern,index:this.conversions.findIndex((e=>e.format===t))}))).sort(((t,e)=>t.index-e.index)).toArray()}_filterFormatsAndConversions(){const{formatterAvailable:t,conversions:e,formats:o}=this;t||this._handles.add(c(this,"view.spatialReference",(t=>{const i=t.isWebMercator||t.isWGS84,s=o.filter((t=>{const{name:e}=t;return!!S.includes(e)||"xy"===e&&!i})),r=this.filteredFormats.filter((t=>"xy"===t.name&&i&&!this.formats.includes(t))),n=e.filter((t=>s.includes(t.format)));o.removeMany(s),e.removeMany(n),this.filteredFormats.addMany(s.filter((t=>!this.filteredFormats.includes(t)))),o.addMany(r)})),E.view)}};t([d()],G.prototype,"conversions",void 0),t([d({type:m})],G.prototype,"currentLocation",null),t([d()],G.prototype,"formats",void 0),t([d()],G.prototype,"messages",void 0),t([d()],G.prototype,"mode",null),t([d()],G.prototype,"filteredFormats",void 0),t([d({readOnly:!0})],G.prototype,"state",null),t([d()],G.prototype,"locationSymbol",void 0),t([d({readOnly:!0,dependsOn:["storageType"]})],G.prototype,"storage",null),t([d()],G.prototype,"storageEnabled",void 0),t([d()],G.prototype,"storageType",void 0),t([d({readOnly:!0})],G.prototype,"waitingForConversions",null),t([d()],G.prototype,"view",void 0),G=t([l("esri.widgets.CoordinateConversion.CoordinateConversionViewModel")],G);const W=G;export{W as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.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"../../config.js";import o from"../../Graphic.js";import"../../symbols.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import l from"../../core/Evented.js";import{HandleOwnerMixin as n}from"../../core/HandleOwner.js";import{isNone as a,isSome as u,unwrap as c}from"../../core/maybe.js";import{isAbortError as d}from"../../core/promiseUtils.js";import{on as p,watch as h,initial as m,syncAndInitial as v}from"../../core/reactiveUtils.js";import{aliasOf as y}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{cast as g}from"../../core/accessorSupport/decorators/cast.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import{subclass as w}from"../../core/accessorSupport/decorators/subclass.js";import{getLocale as _}from"../../intl/locale.js";import S from"../../layers/GraphicsLayer.js";import b from"../../layers/RouteLayer.js";import C from"../../layers/support/DefaultSymbols.js";import{fetchServiceDescription as D}from"../../rest/networkService.js";import T from"../../rest/support/RouteParameters.js";import j from"../../rest/support/Stop.js";import{GoToMixin as L}from"../support/GoTo.js";import M from"../../symbols/SimpleLineSymbol.js";import A from"../../symbols/SimpleMarkerSymbol.js";import P from"../../symbols/PictureMarkerSymbol.js";function z(e){return Array.isArray(e)&&e.length>0&&e[0]instanceof o}function U(e){return i.isCollection(e)&&e.length>0&&e.getItemAt(0)instanceof o}function R(e){return"esri.rest.support.Stop"===(null==e?void 0:e.declaredClass)}const x=[105,220,255],O=new M({color:x,width:7,cap:"round",join:"round"}),I={first:new A({color:x,size:19,outline:{color:[51,51,51],width:3}}),middle:new A({color:[51,51,51],size:12,outline:{color:x,width:3}}),last:new P({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="#69DCFF"/><path fill="#333" d="M10.5 10.5h9v9h-9z"/></g></svg>')}`}),unlocated:new P({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="#69DCFF" 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 A({color:[255,255,255],size:10,outline:{color:[20,89,127],width:2.5}})};var F;!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"}(F||(F={}));let k=class extends(n(L(l.EventedAccessor))){constructor(e){super(e),this._highlightLayer=new S({listMode:"hide"}),this._loadPromise=null,this._loadController=null,this._routeLayer=new b({listMode:"hide",defaultSymbols:new C({directionLines:O,directionPoints:new A({size:0}),routeInfo:new M({width:0}),firstStop:I.first,middleStop:I.middle,lastStop:I.last,invalidStop:I.unlocated,waypointStop:I.waypoint,breakStop:I.waypoint}),stops:[{},{}],url:this.routeServiceUrl}),this._routeController=null,this._serviceDescriptionStatus=F.Idle,this.apiKey=void 0,this.departureTime="now",this.lastRoute=null,this.routeParameters=new T({directionsLengthUnits:"kilometers",findBestSequence:!1,restrictUTurns:"at-dead-ends-and-intersections",returnZ:!0,startTime:null,startTimeIsUTC:!0,useHierarchy:!0,useTimeWindows:!1}),this.routeSymbol=O,this.serviceDescription=null,this.error=null,this.stops=null,this.view=null}initialize(){this.handles.add([p((()=>this.stops),"change",(()=>{this.clearResults()})),h((()=>{var e;return null==(e=this.view)?void 0:e.map}),((e,t)=>{const r=[this._routeLayer,this._highlightLayer];t&&t.removeMany(r),e&&e.addMany(r)}),m),h((()=>this.routeServiceUrl),(e=>{if(this._routeLayer.url=e,u(this._loadController))return this._loadController.abort(),this._loadController=null,this._loadPromise=null,this._set("serviceDescription",null),void this.load();this._set("serviceDescription",null)}),v)])}destroy(){var e;null==(e=this.view)||e.map.removeMany([this._routeLayer,this._highlightLayer])}get _directionsLanguage(){var e;if(a(this.serviceDescription))return;const t=this.serviceDescription.directionsSupportedLanguages;if(!t)return;const r=(null!=(e=this.routeParameters.directionsLanguage)?e:_()).slice(0,2);return t.find((e=>e.toLowerCase().slice(0,2)===r))}get impedanceAttribute(){var e,t,r;const o=u(this.serviceDescription)?this.serviceDescription.impedance:null,i=null!=(e=null!=(t=null==(r=this.routeParameters.travelMode)?void 0:r.impedanceAttributeName)?t:this.routeParameters.impedanceAttribute)?e:o;return this.getCostAttribute(i)}set maxStops(e){const t=50,r=2;e=e<=r?r:e>t?t:e,this._set("maxStops",e)}get routeLayer(){return this._routeLayer}get routeServiceUrl(){return r.routeServiceUrl}set routeServiceUrl(e){null!=e?this._override("routeServiceUrl",e):this._clearOverride("routeServiceUrl")}get selectedTravelMode(){const{serviceDescription:e}=this;if(a(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(u(this._routeController))return"routing";if(u(this.error))return"error";switch(this._serviceDescriptionStatus){case F.Suspended:return"unauthenticated";case F.Idle:return"disabled";case F.Active:return"initializing";case F.Failed:return"error";default:return"ready"}}castStops(e){return z(e)||U(e)?e.map((e=>j.fromPortalJSON(e.toJSON()))):e}set stopSymbols(e){const t={...I,...e};this._set("stopSymbols",t)}get timeAttribute(){var e,t,r;const o=null!=(e=null!=(t=null==(r=this.routeParameters.travelMode)?void 0:r.timeAttributeName)?t:this.routeParameters.directionsTimeAttribute)?e:u(this.serviceDescription)?this.serviceDescription.directionsTimeAttribute:null;return this.getCostAttribute(o)}get travelModes(){return u(this.serviceDescription)?this.serviceDescription.supportedTravelModes:[]}async load(){if(u(this._loadPromise))return this._loadPromise;this._loadPromise=this._load(),await this._loadPromise,this._loadPromise=null}highlightSegment(e){const{geometry:r,symbol:i}=e;if(a(this.view)||a(r)||a(i))return;this.clearHighlights();const s=i.clone();s.color=new t([0,0,0,.8]),s.width=Math.ceil(s.width/2);const l=new o({geometry:r,symbol:s});this._highlightLayer.add(l)}clearHighlights(){this._highlightLayer.removeAll()}centerAt(e){if(a(this.view))return;const t=R(e)?c(e.geometry):e;this.callGoTo({target:t})}clearResults(){this._set("lastRoute",null)}async getDirections(){const{state:e}=this;if("unauthenticated"===e||"initializing"===e||"disabled"===e||this._serviceDescriptionStatus===F.Failed)return Promise.reject(new s("directions-view-model:not-loaded","Cannot get directions until view model loads."));this._set("error",null),u(this._routeController)&&(this._routeController.abort(),this._routeController=null);const{apiKey:t,departureTime:r}=this,o="now"===r,i="now"===r?new Date:r;if(i&&!o){const e=60*i.getTimezoneOffset()*1e3;i.setTime(i.getTime()-e)}const l=u(this.view)?this.view.spatialReference:null,n=this.routeParameters.clone();n.set({startTime:i,startTimeIsUTC:o,directionsLanguage:this._directionsLanguage,apiKey:t,outSpatialReference:l}),u(this.selectedTravelMode)&&(n.travelMode=this.selectedTravelMode);if(this.stops.filter((e=>u(e.geometry))).length<2){const e=new s("directions-view-model:not-enough-stops","Not enough stops for routing");return this._set("error",e),Promise.reject(e)}this._routeController=new AbortController;const{signal:a}=this._routeController;let c=null;try{c=await this._routeLayer.solve(n,{signal:a}),this._routeLayer.update(c),this._set("lastRoute",c)}catch(p){if(!d(p)){const e=new s("directions-view-model:unable-to-route","Unable to route to these addresses",{error:p});throw this._set("error",e),this._set("lastRoute",null),e}}finally{this._routeController=null}return this.zoomToRoute(),c}getCostAttribute(e){const t=(u(this.serviceDescription)?this.serviceDescription.networkDataset.networkAttributes:[]).find((t=>t.name===e&&"esriNAUTCost"===t.usageType));return null!=t?t:null}reset(){this.clearHighlights(),this.clearResults(),this._routeLayer.removeAll(),this._routeLayer.stops.addMany([new j,new j])}zoomToRoute(){const{view:e,lastRoute:t}=this;if(a(e)||a(t))return;const{routeInfo:r}=t;if(a(r))return;const{geometry:o}=r;if(a(o))return;const{extent:i}=o,s=i.width>i.height,l=i.clone().expand(s?2:1);this.callGoTo({target:l})}async _load(){if(u(this.serviceDescription))return;u(this._loadController)&&(this._loadController.abort(),this._loadController=null),this._loadController=new AbortController;const{signal:e}=this._loadController;try{this._serviceDescriptionStatus=F.Active;const t=await D(this.routeServiceUrl,this.apiKey,{signal:e});this._set("serviceDescription",t),this._serviceDescriptionStatus=F.Complete}catch(t){if(d(t))return void(this._serviceDescriptionStatus=F.Idle);if("identity-manager:user-aborted"===t.name)return void(this._serviceDescriptionStatus=F.Suspended);const e=new s("directions-view-model:service-metadata-unavailable","Cannot load route service metadata",{error:t});throw this._serviceDescriptionStatus=F.Failed,this._set("error",e),e}finally{this._loadController=null}}};e([f()],k.prototype,"_directionsLanguage",null),e([f()],k.prototype,"_routeController",void 0),e([f()],k.prototype,"_serviceDescriptionStatus",void 0),e([f()],k.prototype,"apiKey",void 0),e([f()],k.prototype,"departureTime",void 0),e([f({readOnly:!0})],k.prototype,"impedanceAttribute",null),e([f({readOnly:!0})],k.prototype,"lastRoute",void 0),e([f({value:50})],k.prototype,"maxStops",null),e([f()],k.prototype,"routeLayer",null),e([f({type:T,nonNullable:!0})],k.prototype,"routeParameters",void 0),e([f()],k.prototype,"routeServiceUrl",null),e([f()],k.prototype,"routeSymbol",void 0),e([f()],k.prototype,"selectedTravelMode",null),e([f({readOnly:!0})],k.prototype,"serviceDescription",void 0),e([f({readOnly:!0})],k.prototype,"state",null),e([f()],k.prototype,"error",void 0),e([y("routeLayer.stops")],k.prototype,"stops",void 0),e([g("stops")],k.prototype,"castStops",null),e([f({value:I})],k.prototype,"stopSymbols",null),e([f({readOnly:!0})],k.prototype,"timeAttribute",null),e([f()],k.prototype,"travelModes",null),e([f()],k.prototype,"view",void 0),e([f()],k.prototype,"getDirections",null),e([f()],k.prototype,"zoomToRoute",null),k=e([w("esri.widgets.Directions.DirectionsViewModel")],k);const N=k;export{N as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Color.js";import r from"../../config.js";import o from"../../Graphic.js";import"../../symbols.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import l from"../../core/Evented.js";import{HandleOwnerMixin as n}from"../../core/HandleOwner.js";import{isNone as a,isSome as u,unwrap as c}from"../../core/maybe.js";import{isAbortError as d}from"../../core/promiseUtils.js";import{on as p,watch as h,initial as m,syncAndInitial as v}from"../../core/reactiveUtils.js";import{aliasOf as y}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{cast as g}from"../../core/accessorSupport/decorators/cast.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import{subclass as w}from"../../core/accessorSupport/decorators/subclass.js";import{getLocale as _}from"../../intl/locale.js";import S from"../../layers/GraphicsLayer.js";import b from"../../layers/RouteLayer.js";import C from"../../layers/support/DefaultSymbols.js";import{fetchServiceDescription as D}from"../../rest/networkService.js";import T from"../../rest/support/RouteParameters.js";import L from"../../rest/support/Stop.js";import{GoToMixin as M}from"../support/GoTo.js";import j from"../../symbols/SimpleLineSymbol.js";import A from"../../symbols/SimpleMarkerSymbol.js";import z from"../../symbols/PictureMarkerSymbol.js";function P(e){return Array.isArray(e)&&e.length>0&&e[0]instanceof o}function U(e){return i.isCollection(e)&&e.length>0&&e.getItemAt(0)instanceof o}function R(e){return"esri.rest.support.Stop"===(null==e?void 0:e.declaredClass)}const x=[105,220,255],I=new j({color:x,width:7,cap:"round",join:"round"}),O={first:new A({color:x,size:19,outline:{color:[51,51,51],width:3}}),middle:new A({color:[51,51,51],size:12,outline:{color:x,width:3}}),last:new z({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="#69DCFF"/><path fill="#333" d="M10.5 10.5h9v9h-9z"/></g></svg>')}`}),unlocated:new z({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="#69DCFF" 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 A({color:[255,255,255],size:10,outline:{color:[20,89,127],width:2.5}})};var F;!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"}(F||(F={}));let k=class extends(n(M(l.EventedAccessor))){constructor(e){super(e),this._highlightLayer=new S({listMode:"hide"}),this._loadPromise=null,this._loadController=null,this._routeLayer=new b({listMode:"hide",defaultSymbols:new C({directionLines:I,directionPoints:new A({size:0}),routeInfo:new j({width:0}),firstStop:O.first,middleStop:O.middle,lastStop:O.last,invalidStop:O.unlocated,waypointStop:O.waypoint,breakStop:O.waypoint}),stops:[{},{}],url:this.routeServiceUrl}),this._routeController=null,this._serviceDescriptionStatus=F.Idle,this.apiKey=void 0,this.departureTime="now",this.lastRoute=null,this.routeParameters=new T({directionsLengthUnits:"kilometers",findBestSequence:!1,restrictUTurns:"at-dead-ends-and-intersections",returnZ:!0,startTime:null,startTimeIsUTC:!0,useHierarchy:!0,useTimeWindows:!1}),this.routeSymbol=I,this.serviceDescription=null,this.error=null,this.stops=null,this.view=null}initialize(){this.handles.add([p((()=>this.stops),"change",(()=>{this.clearResults()})),h((()=>{var e;return null==(e=this.view)?void 0:e.map}),((e,t)=>{const r=[this._routeLayer,this._highlightLayer];t&&t.removeMany(r),e&&e.addMany(r)}),m),h((()=>this.routeServiceUrl),(e=>{if(this._routeLayer.url=e,u(this._loadController))return this._loadController.abort(),this._loadController=null,this._loadPromise=null,this._set("serviceDescription",null),void this.load();this._set("serviceDescription",null)}),v)])}destroy(){var e;null==(e=this.view)||e.map.removeMany([this._routeLayer,this._highlightLayer])}get _directionsLanguage(){var e;if(a(this.serviceDescription))return;const t=this.serviceDescription.directionsSupportedLanguages;if(!t)return;const r=(null!=(e=this.routeParameters.directionsLanguage)?e:_()).slice(0,2);return t.find((e=>e.toLowerCase().slice(0,2)===r))}get impedanceAttribute(){var e,t,r;const o=u(this.serviceDescription)?this.serviceDescription.impedance:null,i=null!=(e=null!=(t=null==(r=this.routeParameters.travelMode)?void 0:r.impedanceAttributeName)?t:this.routeParameters.impedanceAttribute)?e:o;return this.getCostAttribute(i)}set maxStops(e){const t=50,r=2;e=e<=r?r:e>t?t:e,this._set("maxStops",e)}get routeLayer(){return this._routeLayer}get routeServiceUrl(){return r.routeServiceUrl}set routeServiceUrl(e){null!=e?this._override("routeServiceUrl",e):this._clearOverride("routeServiceUrl")}get selectedTravelMode(){const{serviceDescription:e}=this;if(a(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(u(this._routeController))return"routing";if(u(this.error))return"error";switch(this._serviceDescriptionStatus){case F.Suspended:return"unauthenticated";case F.Idle:return"disabled";case F.Active:return"initializing";case F.Failed:return"error";default:return"ready"}}castStops(e){return P(e)||U(e)?e.map((e=>L.fromGraphic(e))):e}set stopSymbols(e){const t={...O,...e};this._set("stopSymbols",t)}get timeAttribute(){var e,t,r;const o=null!=(e=null!=(t=null==(r=this.routeParameters.travelMode)?void 0:r.timeAttributeName)?t:this.routeParameters.directionsTimeAttribute)?e:u(this.serviceDescription)?this.serviceDescription.directionsTimeAttribute:null;return this.getCostAttribute(o)}get travelModes(){return u(this.serviceDescription)?this.serviceDescription.supportedTravelModes:[]}async load(){if(u(this._loadPromise))return this._loadPromise;this._loadPromise=this._load(),await this._loadPromise,this._loadPromise=null}highlightSegment(e){const{geometry:r,symbol:i}=e;if(a(this.view)||a(r)||a(i))return;this.clearHighlights();const s=i.clone();s.color=new t([0,0,0,.8]),s.width=Math.ceil(s.width/2);const l=new o({geometry:r,symbol:s});this._highlightLayer.add(l)}clearHighlights(){this._highlightLayer.removeAll()}centerAt(e){if(a(this.view))return;const t=R(e)?c(e.geometry):e;this.callGoTo({target:t})}clearResults(){this._set("lastRoute",null)}async getDirections(){const{state:e}=this;if("unauthenticated"===e||"initializing"===e||"disabled"===e||this._serviceDescriptionStatus===F.Failed)throw new s("directions-view-model:not-loaded","Cannot get directions until view model loads.");this._set("error",null),u(this._routeController)&&(this._routeController.abort(),this._routeController=null);const{apiKey:t,departureTime:r}=this,o="now"===r,i="now"===r?new Date:r;if(i&&!o){const e=60*i.getTimezoneOffset()*1e3;i.setTime(i.getTime()-e)}const l=u(this.view)?this.view.spatialReference:null,n=this.routeParameters.clone();n.set({startTime:i,startTimeIsUTC:o,directionsLanguage:this._directionsLanguage,apiKey:t,outSpatialReference:l}),u(this.selectedTravelMode)&&(n.travelMode=this.selectedTravelMode);if(this.stops.filter((e=>u(e.geometry))).length<2){const e=new s("directions-view-model:not-enough-stops","Not enough stops for routing");throw this._set("error",e),e}this._routeController=new AbortController;const{signal:a}=this._routeController;let c=null;try{c=await this._routeLayer.solve(n,{signal:a}),this._routeLayer.update(c),this._set("lastRoute",c)}catch(p){if(!d(p)){const e=new s("directions-view-model:unable-to-route","Unable to route to these addresses",{error:p});throw this._set("error",e),this._set("lastRoute",null),e}}finally{this._routeController=null}return this.zoomToRoute(),c}getCostAttribute(e){const t=(u(this.serviceDescription)?this.serviceDescription.networkDataset.networkAttributes:[]).find((t=>t.name===e&&"esriNAUTCost"===t.usageType));return null!=t?t:null}reset(){this.clearHighlights(),this.clearResults(),this._routeLayer.removeAll(),this._routeLayer.stops.addMany([new L,new L])}zoomToRoute(){const{view:e,lastRoute:t}=this;if(a(e)||a(t))return;const{routeInfo:r}=t;if(a(r))return;const{geometry:o}=r;if(a(o))return;const{extent:i}=o,s=i.width>i.height,l=i.clone().expand(s?2:1);this.callGoTo({target:l})}async _load(){if(u(this.serviceDescription))return;u(this._loadController)&&(this._loadController.abort(),this._loadController=null),this._loadController=new AbortController;const{signal:e}=this._loadController;try{this._serviceDescriptionStatus=F.Active;const t=await D(this.routeServiceUrl,this.apiKey,{signal:e});this._set("serviceDescription",t),this._serviceDescriptionStatus=F.Complete}catch(t){if(d(t))return void(this._serviceDescriptionStatus=F.Idle);if("identity-manager:user-aborted"===t.name)return void(this._serviceDescriptionStatus=F.Suspended);const e=new s("directions-view-model:service-metadata-unavailable","Cannot load route service metadata",{error:t});throw this._serviceDescriptionStatus=F.Failed,this._set("error",e),e}finally{this._loadController=null}}};e([f()],k.prototype,"_directionsLanguage",null),e([f()],k.prototype,"_routeController",void 0),e([f()],k.prototype,"_serviceDescriptionStatus",void 0),e([f()],k.prototype,"apiKey",void 0),e([f()],k.prototype,"departureTime",void 0),e([f({readOnly:!0})],k.prototype,"impedanceAttribute",null),e([f({readOnly:!0})],k.prototype,"lastRoute",void 0),e([f({value:50})],k.prototype,"maxStops",null),e([f()],k.prototype,"routeLayer",null),e([f({type:T,nonNullable:!0})],k.prototype,"routeParameters",void 0),e([f()],k.prototype,"routeServiceUrl",null),e([f()],k.prototype,"routeSymbol",void 0),e([f()],k.prototype,"selectedTravelMode",null),e([f({readOnly:!0})],k.prototype,"serviceDescription",void 0),e([f({readOnly:!0})],k.prototype,"state",null),e([f()],k.prototype,"error",void 0),e([y("routeLayer.stops")],k.prototype,"stops",void 0),e([g("stops")],k.prototype,"castStops",null),e([f({value:O})],k.prototype,"stopSymbols",null),e([f({readOnly:!0})],k.prototype,"timeAttribute",null),e([f()],k.prototype,"travelModes",null),e([f()],k.prototype,"view",void 0),e([f()],k.prototype,"getDirections",null),e([f()],k.prototype,"zoomToRoute",null),k=e([w("esri.widgets.Directions.DirectionsViewModel")],k);const G=k;export{G 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"../Graphic.js";import"../intl.js";import{on as s,pausable as o}from"../core/events.js";import i from"../core/Handles.js";import{isSome as r,isNone as n,unwrap as a,unwrapOrValue as l}from"../core/maybe.js";import{watch as c,initial as d,when as h,on as u}from"../core/reactiveUtils.js";import{aliasOf as p}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 v}from"../core/accessorSupport/decorators/subclass.js";import _ from"../rest/support/Stop.js";import g from"../symbols/SimpleMarkerSymbol.js";import S from"./Search.js";import w from"./Widget.js";import y from"./Directions/DirectionsViewModel.js";import{formatDistance as M,formatTime as f,isTimeUnits as T}from"./Directions/support/directionsUtils.js";import{DepartureTime as b,CSS as C,getIconPath as I}from"./Directions/support/resources.js";import{isArcGISWorldGeocoder as k,meteredArcGISLocatorUrl as R}from"./Search/support/locatorUtils.js";import D from"./support/DatePicker.js";import{Heading as P,incrementHeadingLevel as j}from"./support/Heading.js";import x from"./support/TimePicker.js";import{accessibleHandler as H}from"./support/decorators/accessibleHandler.js";import{messageBundle as U}from"./support/decorators/messageBundle.js";import"../core/Logger.js";import{tsx as L}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import z from"sortablejs";import{substitute as A}from"../intl/substitute.js";import{formatDate as E,convertDateFormatToIntlOptions as O}from"../intl/date.js";import{formatNumber as $}from"../intl/number.js";function B(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}${$(i,n)}${$(r,n)}`}function F(e){return!(null==e.composedPath||!e.composedPath().find((e=>{var t;return null==(t=e.classList)?void 0:t.contains("esri-search__suggestions-list")})))}const N={awaitingViewClickStop:"awaiting-view-click-stop"},V=100,q=500;let W=class extends w{constructor(e,t){super(e,t),this._autoStopRemovalDelay=V,this._departureTime=b.NOW,this._datePicker=new D,this._handles=new i,this._newPlaceholderStop=null,this._pointerPressedSearchSuggestionStop=null,this._sections=null,this._stopsToSearches=new Map,this._timePicker=new x,this.apiKey=null,this.goToOverride=null,this.headingLevel=2,this.iconClass=C.widgetIcon,this.label=void 0,this.lastRoute=null,this.maxStops=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.routeServiceUrl=void 0,this.routeSymbol=null,this.searchProperties=null,this.stopSymbols=null,this.view=null,this.viewModel=new y,this._setUpDragAndDropStops=e=>{this._sortable=z.create(e,{draggable:`.${C.validStopRow}`,ghostClass:C.stopRowGhost,handle:`.${C.stopHandle}`,onEnd:this._handleStopInputDragEnd})},this._handleDragHandlePointerDown=()=>this.viewModel.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.stops;a.reorder(a.getItemAt(e),t);for(const l of a)l.sequence=null;this._processStops()}}initialize(){this.own([c((()=>this.viewModel.lastRoute),(()=>{if(r(this.viewModel.lastRoute)){for(const e of this._stopsToSearches.values())e.destroy();this._stopsToSearches.clear();for(const e of this.viewModel.lastRoute.stops){this._acquireSearch(e).searchTerm=r(e.name)?e.name:""}}this._activeStop=null,this._activeManeuver=null,this._focusedManeuver=null,this._sections=this._getSections(),this.scheduleRender()}),d),c((()=>[this.viewModel.selectedTravelMode,this.viewModel.departureTime]),(async()=>{this.viewModel.stops.filter((e=>r(e.geometry))).length>1&&(await this.viewModel.load(),this.getDirections())}),d),h((()=>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=q)),s(e.surface,"mouseup",(()=>this._autoStopRemovalDelay=V)),t,o],this.view.surface),this._pointerDownUpHandle=t,this._viewClickHandle=o}}),d),h((()=>n(this.viewModel.serviceDescription)),(()=>{this.viewModel.load()}),d)])}destroy(){this._datePicker.destroy(),this._timePicker.destroy(),this._stopsToSearches.forEach((e=>e.destroy())),this._sortable&&this._sortable.destroy()}getDirections(){return null}zoomToRoute(){}render(){return L("div",{class:this.classes(C.base,C.scroller)},this._renderPanelContent())}_renderPanelContent(){const{viewModel:{state:e}}=this,t="initializing"===e,s="error"===e&&!this.viewModel.serviceDescription,o="unauthenticated"===e,i={[C.panelContentLoading]:t,[C.panelContentError]:s,[C.panelContentSignIn]:o},r=t?"presentation":"group",n=o?this._renderSignIn():s?this._renderMessage(this._getErrorMessage()):t?this._renderLoader():this._renderReadyContent();return L("div",{class:this.classes(C.panelContent,i),role:r},n)}_renderReadyContent(){return[this._renderStopsContainer(),this._renderTravelModeOptions(),this._renderDepartureTimeControls(),this._renderSectionSplitter(),this._renderDirectionsContainer()]}_renderSignIn(){return L("div",{key:"sign-in",class:C.signInContent},L(P,{class:C.contentTitle,level:this.headingLevel},this.messages.widgetLabel),this._renderPlaceholder(),L(P,{level:j(this.headingLevel)},this.messages.signInRequired),L("button",{class:this.classes(C.button,C.buttonSecondary,C.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=r(e)?e.name:this.messages.travelMode;return L("select",{"aria-label":s,bind:this,class:this.classes(C.travelModeSelect,C.select),key:"esri-directions__travel-mode-options",onchange:this._handleTravelModeChange,title:s},t.map((t=>{const s=r(e)&&t.id===e.id;return L("option",{key:t,"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"]}_renderStopsContainer(){return L("div",{class:C.section,key:"esri-directions__stops-container",role:"group"},this._renderStops())}_renderDepartureTimeControls(){const e=this._departureTime,{messages:t}=this,s=t.departureTime;return L("div",{class:C.departureTime,key:"esri-directions__departure-time-controls",role:"group"},L("select",{"aria-label":s,bind:this,class:this.classes(C.departureTimeSelect,C.select),onchange:this._handleDepartureOptionChange,title:s},L("option",{value:b.NOW,selected:e===b.NOW},t.leaveNow),L("option",{value:b.DEPART_BY,selected:e===b.DEPART_BY},t.departBy),L("option",{value:b.UNSPECIFIED,selected:e===b.UNSPECIFIED},t.timeUnspecified)),e===b.DEPART_BY?this._renderTimeControls():null)}_renderStops(){const e=this.viewModel.stops;let t=0;e.forEach((e=>{"none"!==this._acquireSearch(e).activeMenu&&(t+=1)}));const s=e.toArray().map(((s,o)=>{const i=e.length,a=o>1&&n(s.geometry),l={[C.stopsIcon]:o>=0&&o<i-1,[C.lastStopIcon]:o===i-1},c={[C.lastStopIconContainer]:o===i-1},d={[C.validStopRow]:!a},h=e.getItemAt(i-1),u=h&&r(h.geometry),p=e.getItemAt(o+1),m=p&&r(p.geometry),v=o===i-1,_=o===i-2,g=2===i&&0===o||i>2&&!v&&!_||i>2&&_&&m||i>2&&v&&n(s.geometry),S=2===i||3===i&&!u||a,w=this._acquireSearch(s),{messages:y}=this,{removeStop:M,reverseStops:f,unlocated:T}=y,b=A(y.stopLabelTemplate,{number:o+1,label:r(s.geometry)?s.name:T}),I=`${this.id}__stop--${o}`,k=!!w.searchTerm&&!!w.selectedResult&&r(s.geometry)&&w.selectedResult.name===s.name,R={zIndex:"none"!==w.activeMenu?""+t--:""};return L("li",{"aria-label":b,afterCreate:this._handleStopFieldCreation,bind:this,class:this.classes(C.stopRow,d),id:I,key:o,"data-stop-index":o,styles:R},L("div",{class:C.stopHandle},L("span",{"aria-hidden":"true",class:this.classes(C.stopIcon,C.handleIcon,C.stopHandleIcon,C.interactiveStopIcon),onpointerdown:this._handleDragHandlePointerDown}),L("div",{bind:this,"aria-labelledby":I,class:this.classes(C.stopIconContainer,c),"data-stop-index":o,onclick:this._handleStopIconClick,onkeydown:this._handleStopIconClick,role:"button"},L("span",{class:this.classes(C.stopIcon,l),tabindex:k?"0":null}))),L("div",{class:C.stopInput},w.render()),L("div",{class:C.stopOptions,role:"group"},L("div",{"aria-label":M,class:C.removeStopButton,bind:this,"data-stop-index":o,hidden:S,onkeydown:this._handleRemoveStop,onclick:this._handleRemoveStop,role:"button",tabIndex:0,title:M},L("span",{"aria-hidden":"true",class:this.classes(C.stopIcon,C.removeStop,C.removeStopIcon,C.interactiveStopIcon)}),L("span",{class:C.screenReaderText},"removeStopTitle")),L("div",{"aria-label":f,class:C.reverseStops,bind:this,hidden:g,onkeydown:this._handleReverseStops,onclick:this._handleReverseStops,role:"button",tabIndex:0,title:f},L("span",{"aria-hidden":"true",class:this.classes(C.stopIcon,C.reverseStopIcon,C.interactiveStopIcon)}),L("span",{class:C.screenReaderText},"removeStopTitle"))))})),o=e.every((e=>r(e.geometry))),i=e.length>=this.maxStops,a=this.messages.addStop,l=e.length>=2&&o&&!i?L("div",{"aria-label":a,bind:this,class:C.addStop,key:"esri-directions__add-stop",onfocus:this._handleAddStopFocus,tabIndex:0},L("span",{"aria-hidden":"true",class:this.classes(C.addStopIcon,C.stopIcon,C.interactiveStopIcon)}),L("div",{"aria-hidden":"true",class:C.addStopText},a)):null;return L("div",null,L("ol",{class:C.stops,role:"group",afterCreate:this._setUpDragAndDropStops},s),l)}_handleStopIconClick(e){const t=e.currentTarget["data-stop-index"],s=this.viewModel.stops.getItemAt(t);s&&r(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.stops.getItemAt(s);if(t===o){const e=this._acquireSearch(o);e.when((()=>{this.renderNow(),e.focus()}))}this._newPlaceholderStop=null}_handleStopInputBlur(e,t){this._handles.remove(N.awaitingViewClickStop),this.view.cursor=this._previousCursor;if(!e.selectedResult||!r(t.geometry)||!r(e.selectedResult.feature.geometry)||t.geometry!==e.selectedResult.feature.geometry)return"none"===e.activeMenu&&e.searchTerm&&(n(e.selectedResult.feature.geometry)&&n(t.geometry)||r(t.geometry)&&r(e.selectedResult.feature.geometry)&&t.geometry!==e.selectedResult.feature.geometry)?(e.search(),void this._pointerDownUpHandle.pause()):void(e.searchTerm||(this._viewClickHandle.resume(),clearTimeout(this._autoStopRemovalTimeoutId),this._autoStopRemovalTimeoutId=setTimeout((()=>{this.destroyed||(this._viewClickHandle.pause(),"searching"!==e.viewModel.state?this._pointerPressedSearchSuggestionStop||(r(t.geometry)&&(t.geometry=null,this._processStops()),this.scheduleRender()):this._pointerDownUpHandle.pause())}),this._autoStopRemovalDelay)));this._pointerDownUpHandle.pause()}_handleStopInputFocus(e,t){if(this._pointerDownUpHandle.resume(),this._handles.has(N.awaitingViewClickStop))return;const{view:s,view:{cursor:o}}=this;this._previousCursor=o,this._handles.add(c((()=>e.searchTerm),(t=>{e.destroyed||(s.cursor=0===t.length?"copy":o)}),d),N.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=F(e)?this._activeStop:null})),t=o(document,"pointerup",(e=>{this._pointerDownUpHandle.pause();const t=F(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)}_handleAddStopFocus(){this._addNewPlaceholder()}_addNewPlaceholder(){if(this._pointerDownUpHandle.pause(),this._newPlaceholderStop)return;const e=new _({symbol:new g});this.viewModel.stops.add(e),this._newPlaceholderStop=e}_handleReverseStops(){this._reverseStops()}_reverseStops(){this.viewModel.stops.reverse();for(const e of this.viewModel.stops)e.sequence=null;this._processStops()}_handleRemoveStop(e){const t=e.currentTarget["data-stop-index"];this._removeStop(this.viewModel.stops.getItemAt(t)),this._processStops()}_removeStop(e){this.viewModel.stops.length<=2||(this._disposeSearch(e),this.viewModel.stops.remove(e))}_handleDepartureOptionChange(e){const t=e.currentTarget,s=t.item(t.selectedIndex);s.value===b.NOW?(this._departureTime=b.NOW,this.viewModel.departureTime=b.NOW,this._handles.remove("departure-time-controls")):s.value===b.DEPART_BY?(this._departureTime=b.DEPART_BY,this._handles.add([c((()=>this._datePicker.value),(()=>this._updateDepartureTime()),d),c((()=>this._timePicker.value),(()=>this._updateDepartureTime()),d)],"departure-time-controls")):(this._departureTime=b.UNSPECIFIED,this.viewModel.departureTime=null)}_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 L("div",{class:C.departureTimeControls,key:"esri-directions__time-controls",role:"group"},this._datePicker.render(),this._timePicker.render())}_renderSectionSplitter(){return L("div",{class:C.sectionSplitter})}_renderDirectionsContainer(){return L("div",{class:this.classes(C.directionsSection,C.section),key:"esri-directions__container"},this._renderDirectionsContainerContent())}_renderLoader(){return L("div",{class:C.loader,key:"loader"})}_renderWarningCard(){return L("div",{class:C.warningCard,role:"alert"},L("div",{class:C.warningHeader},L("span",{class:C.warningIcon,"aria-hidden":"true"}),L(P,{class:C.warningHeading,level:this.headingLevel},this.messagesCommon.warning)),L("div",{class:C.warningMessage},this._getErrorMessage()))}_renderDirectionsContainerContent(){const{lastRoute:e,viewModel:{state:t}}=this,s="routing"===t;return"error"===t?this._renderWarningCard():s?this._renderLoader():r(e)&&r(e.directionLines)?L("div",{class:C.summary,key:"esri-directions__summary",role:"group"},this._renderCosts(),this._renderRouteActions(),this._renderManeuverSections()):L("div",{key:"esri-directions__placeholder",class:C.emptyContent},this._renderPlaceholder(),L(P,{class:C.message,level:this.headingLevel},this.messages.directionsPlaceholder))}_renderPlaceholder(){return L("svg",{class:C.emptyIllustration,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256"},L("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 L(P,{level:this.headingLevel},e)}_renderRouteActions(){return L("div",{class:C.routeActions},L("button",{"aria-label":this.messages.clearRoute,class:this.classes(C.clearRouteButton,C.button,C.buttonTertiary),tabIndex:0,onclick:this._handleClearRouteClick,bind:this,type:"button"},this.messages.clearRoute))}_getSections(){if(n(this.lastRoute))return null;const{directionPoints:e,directionLines:t,stops:s}=this.lastRoute;if(n(e)||n(t))return null;const o=[];let i=null;for(const a of e){const{objectId:e,stopId:l}=a;if(r(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:a,directionLine:c})}return o}_renderManeuverSections(){return n(this._sections)?null:L("div",{class:C.maneuvers,role:"group"},this._sections.map(((e,t)=>{const{open:s}=e;let o;e.directions.length>0&&s&&(o=L("ol",{class:C.maneuverList},e.directions.map((e=>this._renderManeuver(e)))));const i=a(this._sections).length>2,r=t===a(this._sections).length-1,n={[C.collapsibleSection]:i},l={[C.openIcon]:!s,[C.closeIcon]:s};let c;if(i&&!r){const t=s?this.messagesCommon.open:this.messagesCommon.close;c=L("header",{class:this.classes(C.maneuverSectionHeader,C.maneuverSectionToggle),key:"esri-directions__maneuver-section-header"},L("div",{"aria-expanded":s.toString(),"aria-label":t,bind:this,class:C.maneuverSectionHeaderButton,"data-maneuver-section":e,onkeydown:this._handleSectionToggle,onclick:this._handleSectionToggle,role:"button",tabIndex:0,title:t},L(P,{class:C.maneuverSectionTitle,level:this.headingLevel},e.stop.name),L("span",{"aria-hidden":"true",class:this.classes(l)})))}else c=L("header",{class:C.maneuverSectionHeader,key:"esri-directions__maneuver-section-header"},L(P,{class:C.maneuverSectionTitle,level:this.headingLevel},e.stop.name));return L("section",{class:this.classes(C.maneuverSection,n),key:t},c,o)})))}_handleSectionToggle(e){const t=e.currentTarget["data-maneuver-section"];t.open=!t.open}_renderCosts(){const{lastRoute:e}=this;if(n(e))return null;const t=this._getCostSummary(),{directionPoints:s}=e;if(n(s)||n(t))return null;const o=s.getItemAt(s.length-1).arrivalTime,{primary:i,secondary:a}=t,{eta:l,etaTemplate:c,primaryCosts:d,secondaryCosts:h,zoomToRoute:u}=this.messages,p=O("short-time"),m=r(o)?`<strong>${E(o,p)}</strong>`:null,v=r(o)?`${B(o)}`:null,_=A(c,{time:m,gmt:v});return L("div",{"aria-label":u,bind:this,class:C.directionCosts,onkeydown:this._handleSummaryInteraction,onclick:this._handleSummaryInteraction,role:"button",tabIndex:0,title:u},L("div",{class:C.costsDetails,role:"group"},L("div",{"aria-label":d,class:C.primaryCosts,title:d},i),L("div",{class:C.verticalSplitter}),L("div",{"aria-label":h,class:C.secondaryCosts,title:h},a)),L("div",{"aria-label":l,innerHTML:_,title:l}))}_handleSummaryInteraction(){this._activeManeuver=null,this._focusedManeuver=null,this.viewModel.clearHighlights(),this.zoomToRoute()}_getErrorMessage(){const{messages:e,viewModel:{error:t}}=this;if(r(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){if("url"in t&&t.url)null!=t.locationType||(t.locationType="street"),k(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([u((()=>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),this._stopsToSearches.set(e,s),s}_disposeSearch(e){this._stopsToSearches.get(e).destroy(),this._stopsToSearches.delete(e)}_processStops(){const e=this.viewModel.stops.filter((e=>r(e.geometry)));this.viewModel.stops=e,e.length>1&&this.getDirections()}_renderManeuver(e){const t="",{directionsLengthUnits:s}=this.viewModel.routeParameters,{directionPoint:o,directionLine:i}=e,{distance:n,duration:a}=i,{messages:c,messagesUnits:d}=this,h=M(c,d,l(n,0),{fromUnits:"meters",toUnits:s}),u=f(l(a,0),"minutes"),p=h&&u?`${h}&nbsp;&middot;&nbsp;${u}`:`${h}${u}`,m=this._getFormattedManeuverText(o),{objectId:v,directionPointType:_}=o,g=I(_),S=`esri-directions__maneuver-${v}`,w=`esri-directions__cumulative-costs-${v}`,y=`esri-directions__intermediate-costs-${v}`,T={[C.maneuverActive]:this._activeManeuver===i};return L("li",{"aria-labelledby":`${S} ${w} ${y}`,bind:this,class:this.classes(C.maneuver,T),"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},r(g)&&L("img",{alt:"",class:C.maneuverIcon,src:g}),L("div",{class:C.maneuverCostsContainer},L("span",{id:S,innerHTML:l(m,"")}),L("div",{class:C.maneuverCosts},L("div",{class:C.horizontalSplitter}),L("div",{id:w,"aria-label":c.cumulativeCosts,class:C.cumulativeCost,innerHTML:t,title:c.cumulativeCosts}),L("div",{id:y,"aria-label":c.intermediateCosts,class:C.intermediateCost,innerHTML:p,title:c.intermediateCosts}))))}_handleManeuverClick(e){const s=e.currentTarget["data-maneuver"];if(this._activeManeuver===s)return this._activeManeuver=null,void this.zoomToRoute();this._activeManeuver=s;const{geometry:o,symbol:i}=s,r=new t({geometry:o,symbol:i});this.viewModel.centerAt(r),this.viewModel.highlightSegment(r)}_handleManeuverMouseOver(e){if(this._activeManeuver||this._focusedManeuver)return;const s=e.currentTarget["data-maneuver"],{geometry:o,symbol:i}=s,r=new t({geometry:o,symbol:i});this.viewModel.highlightSegment(r)}_handleManeuverMouseOut(){this._activeManeuver||this._focusedManeuver||this.viewModel.clearHighlights()}_handleManeuverBlur(){this._activeManeuver||(this._focusedManeuver=null,this.viewModel.clearHighlights())}_handleManeuverFocus(e){if(this._activeManeuver)return;const s=e.currentTarget["data-maneuver"];this._focusedManeuver=s;const{geometry:o,symbol:i}=s,r=new t({geometry:o,symbol:i});this.viewModel.highlightSegment(r)}_getFormattedManeuverText(e){const{displayText:t,name:s,intersectingName:o}=e;if(n(t))return"";let i=t;return r(s)&&i.includes(s)&&(i=i.replace(s,`<strong>${s}</strong>`)),r(o)&&i.includes(o)&&(i=i.replace(o,`<strong>${o}</strong>`)),i}_getCostSummary(){const{viewModel:{impedanceAttribute:e,routeParameters:t},lastRoute:s}=this;if(n(e)||n(s))return null;const{routeInfo:o}=s;let{totalDuration:i,totalDistance:a}=o;const{directionsLengthUnits:l}=t;a=r(a)?a:0,i=r(i)?i:0;const c=M(this.messages,this.messagesUnits,a,{fromUnits:"meters",toUnits:l}),d=f(i,"minutes"),[h,u]=T(e.units)?[d,c]:[c,d];return{primary:h,secondary:u}}};e([p("viewModel.apiKey")],W.prototype,"apiKey",void 0),e([p("viewModel.goToOverride")],W.prototype,"goToOverride",void 0),e([m()],W.prototype,"headingLevel",void 0),e([m()],W.prototype,"iconClass",void 0),e([m({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],W.prototype,"label",void 0),e([p("viewModel.lastRoute")],W.prototype,"lastRoute",void 0),e([p("viewModel.maxStops")],W.prototype,"maxStops",void 0),e([m(),U("esri/widgets/Directions/t9n/Directions")],W.prototype,"messages",void 0),e([m(),U("esri/t9n/common")],W.prototype,"messagesCommon",void 0),e([m(),U("esri/core/t9n/Units")],W.prototype,"messagesUnits",void 0),e([p("viewModel.routeServiceUrl")],W.prototype,"routeServiceUrl",void 0),e([p("viewModel.routeSymbol")],W.prototype,"routeSymbol",void 0),e([m()],W.prototype,"searchProperties",void 0),e([p("viewModel.stopSymbols")],W.prototype,"stopSymbols",void 0),e([p("viewModel.view")],W.prototype,"view",void 0),e([m({type:y})],W.prototype,"viewModel",void 0),e([p("viewModel.getDirections")],W.prototype,"getDirections",null),e([p("viewModel.zoomToRoute")],W.prototype,"zoomToRoute",null),e([H()],W.prototype,"_handleStopIconClick",null),e([H()],W.prototype,"_handleClearRouteClick",null),e([H()],W.prototype,"_handleReverseStops",null),e([H()],W.prototype,"_handleRemoveStop",null),e([H()],W.prototype,"_handleSectionToggle",null),e([H()],W.prototype,"_handleSummaryInteraction",null),e([H()],W.prototype,"_handleManeuverClick",null),W=e([v("esri.widgets.Directions")],W);const K=W;export{K as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.js";import"../intl.js";import{on as s,pausable as o}from"../core/events.js";import i from"../core/Handles.js";import{isSome as r,isNone as n,unwrap as a,unwrapOrValue as l}from"../core/maybe.js";import{watch as c,initial as d,when as h,on as u}from"../core/reactiveUtils.js";import{aliasOf as p}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 v}from"../core/accessorSupport/decorators/subclass.js";import _ from"../rest/support/Stop.js";import g from"../symbols/SimpleMarkerSymbol.js";import S from"./Search.js";import w from"./Widget.js";import y from"./Directions/DirectionsViewModel.js";import{formatDistance as M,formatTime as f,isTimeUnits as T}from"./Directions/support/directionsUtils.js";import{DepartureTime as b,CSS as C,getIconPath as I}from"./Directions/support/resources.js";import{isArcGISWorldGeocoder as k,meteredArcGISLocatorUrl as R}from"./Search/support/locatorUtils.js";import D from"./support/DatePicker.js";import{Heading as P,incrementHeadingLevel as j}from"./support/Heading.js";import x from"./support/TimePicker.js";import{accessibleHandler as H}from"./support/decorators/accessibleHandler.js";import{messageBundle as U}from"./support/decorators/messageBundle.js";import"../core/Logger.js";import{tsx as L}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import z from"sortablejs";import{substitute as A}from"../intl/substitute.js";import{formatDate as E,convertDateFormatToIntlOptions as O}from"../intl/date.js";import{formatNumber as $}from"../intl/number.js";function B(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}${$(i,n)}${$(r,n)}`}function F(e){return!(null==e.composedPath||!e.composedPath().find((e=>{var t;return null==(t=e.classList)?void 0:t.contains("esri-search__suggestions-list")})))}const N={awaitingViewClickStop:"awaiting-view-click-stop"},V=100,q=500;let W=class extends w{constructor(e,t){super(e,t),this._autoStopRemovalDelay=V,this._departureTime=b.NOW,this._datePicker=new D,this._handles=new i,this._newPlaceholderStop=null,this._pointerPressedSearchSuggestionStop=null,this._sections=null,this._stopsToSearches=new Map,this._timePicker=new x,this.apiKey=null,this.goToOverride=null,this.headingLevel=2,this.iconClass=C.widgetIcon,this.label=void 0,this.lastRoute=null,this.maxStops=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.routeServiceUrl=void 0,this.routeSymbol=null,this.searchProperties=null,this.stopSymbols=null,this.view=null,this.viewModel=new y,this._setUpDragAndDropStops=e=>{this._sortable=z.create(e,{draggable:`.${C.validStopRow}`,ghostClass:C.stopRowGhost,handle:`.${C.stopHandle}`,onEnd:this._handleStopInputDragEnd})},this._handleDragHandlePointerDown=()=>this.viewModel.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.stops;a.reorder(a.getItemAt(e),t);for(const l of a)l.sequence=null;this._processStops()}}initialize(){this.own([c((()=>this.viewModel.lastRoute),(()=>{if(r(this.viewModel.lastRoute)){for(const e of this._stopsToSearches.values())e.destroy();this._stopsToSearches.clear();for(const e of this.viewModel.lastRoute.stops){this._acquireSearch(e).searchTerm=r(e.name)?e.name:""}}this._activeStop=null,this._activeManeuver=null,this._focusedManeuver=null,this._sections=this._getSections(),this.scheduleRender()}),d),c((()=>[this.viewModel.selectedTravelMode,this.viewModel.departureTime]),(async()=>{this.viewModel.stops.filter((e=>r(e.geometry))).length>1&&(await this.viewModel.load(),this._getDirections())}),d),h((()=>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=q)),s(e.surface,"mouseup",(()=>this._autoStopRemovalDelay=V)),t,o],this.view.surface),this._pointerDownUpHandle=t,this._viewClickHandle=o}}),d),h((()=>n(this.viewModel.serviceDescription)),(()=>{this.viewModel.load()}),d)])}destroy(){this._datePicker.destroy(),this._timePicker.destroy(),this._stopsToSearches.forEach((e=>e.destroy())),this._sortable&&this._sortable.destroy()}getDirections(){return null}zoomToRoute(){}render(){return L("div",{class:this.classes(C.base,C.scroller)},this._renderPanelContent())}_renderPanelContent(){const{viewModel:{serviceDescription:e,state:t}}=this,s="initializing"===t,o="error"===t&&!e,i="unauthenticated"===t,r={[C.panelContentLoading]:s,[C.panelContentError]:o,[C.panelContentSignIn]:i},n=s?"presentation":"group",a=i?this._renderSignIn():o?this._renderMessage(this._getErrorMessage()):s?this._renderLoader():this._renderReadyContent();return L("div",{class:this.classes(C.panelContent,r),role:n},a)}_renderReadyContent(){return[this._renderStopsContainer(),this._renderTravelModeOptions(),this._renderDepartureTimeControls(),this._renderSectionSplitter(),this._renderDirectionsContainer()]}_renderSignIn(){return L("div",{key:"sign-in",class:C.signInContent},L(P,{class:C.contentTitle,level:this.headingLevel},this.messages.widgetLabel),this._renderPlaceholder(),L(P,{level:j(this.headingLevel)},this.messages.signInRequired),L("button",{class:this.classes(C.button,C.buttonSecondary,C.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=r(e)?e.name:this.messages.travelMode;return L("select",{"aria-label":s,bind:this,class:this.classes(C.travelModeSelect,C.select),key:"esri-directions__travel-mode-options",onchange:this._handleTravelModeChange,title:s},t.map((t=>{const s=r(e)&&t.id===e.id;return L("option",{key:t,"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"]}_renderStopsContainer(){return L("div",{class:C.section,key:"esri-directions__stops-container",role:"group"},this._renderStops())}_renderDepartureTimeControls(){const e=this._departureTime,{messages:t}=this,s=t.departureTime;return L("div",{class:C.departureTime,key:"esri-directions__departure-time-controls",role:"group"},L("select",{"aria-label":s,bind:this,class:this.classes(C.departureTimeSelect,C.select),onchange:this._handleDepartureOptionChange,title:s},L("option",{value:b.NOW,selected:e===b.NOW},t.leaveNow),L("option",{value:b.DEPART_BY,selected:e===b.DEPART_BY},t.departBy),L("option",{value:b.UNSPECIFIED,selected:e===b.UNSPECIFIED},t.timeUnspecified)),e===b.DEPART_BY?this._renderTimeControls():null)}_renderStops(){const e=this.viewModel.stops;let t=0;e.forEach((e=>{"none"!==this._acquireSearch(e).activeMenu&&(t+=1)}));const s=e.toArray().map(((s,o)=>{const i=e.length,a=o>1&&n(s.geometry),l={[C.stopsIcon]:o>=0&&o<i-1,[C.lastStopIcon]:o===i-1},c={[C.lastStopIconContainer]:o===i-1},d={[C.validStopRow]:!a},h=e.getItemAt(i-1),u=h&&r(h.geometry),p=e.getItemAt(o+1),m=p&&r(p.geometry),v=o===i-1,_=o===i-2,g=2===i&&0===o||i>2&&!v&&!_||i>2&&_&&m||i>2&&v&&n(s.geometry),S=2===i||3===i&&!u||a,w=this._acquireSearch(s),{messages:y}=this,{removeStop:M,reverseStops:f,unlocated:T}=y,b=A(y.stopLabelTemplate,{number:o+1,label:r(s.geometry)?s.name:T}),I=`${this.id}__stop--${o}`,k=!!w.searchTerm&&!!w.selectedResult&&r(s.geometry)&&w.selectedResult.name===s.name,R={zIndex:"none"!==w.activeMenu?""+t--:""};return L("li",{"aria-label":b,afterCreate:this._handleStopFieldCreation,bind:this,class:this.classes(C.stopRow,d),id:I,key:o,"data-stop-index":o,styles:R},L("div",{class:C.stopHandle},L("span",{"aria-hidden":"true",class:this.classes(C.stopIcon,C.handleIcon,C.stopHandleIcon,C.interactiveStopIcon),onpointerdown:this._handleDragHandlePointerDown}),L("div",{bind:this,"aria-labelledby":I,class:this.classes(C.stopIconContainer,c),"data-stop-index":o,onclick:this._handleStopIconClick,onkeydown:this._handleStopIconClick,role:"button"},L("span",{class:this.classes(C.stopIcon,l),tabindex:k?"0":null}))),L("div",{class:C.stopInput},w.render()),L("div",{class:C.stopOptions,role:"group"},L("div",{"aria-label":M,class:C.removeStopButton,bind:this,"data-stop-index":o,hidden:S,onkeydown:this._handleRemoveStop,onclick:this._handleRemoveStop,role:"button",tabIndex:0,title:M},L("span",{"aria-hidden":"true",class:this.classes(C.stopIcon,C.removeStop,C.removeStopIcon,C.interactiveStopIcon)}),L("span",{class:C.screenReaderText},"removeStopTitle")),L("div",{"aria-label":f,class:C.reverseStops,bind:this,hidden:g,onkeydown:this._handleReverseStops,onclick:this._handleReverseStops,role:"button",tabIndex:0,title:f},L("span",{"aria-hidden":"true",class:this.classes(C.stopIcon,C.reverseStopIcon,C.interactiveStopIcon)}),L("span",{class:C.screenReaderText},"removeStopTitle"))))})),o=e.every((e=>r(e.geometry))),i=e.length>=this.maxStops,a=this.messages.addStop,l=e.length>=2&&o&&!i?L("div",{"aria-label":a,bind:this,class:C.addStop,key:"esri-directions__add-stop",onfocus:this._handleAddStopFocus,tabIndex:0},L("span",{"aria-hidden":"true",class:this.classes(C.addStopIcon,C.stopIcon,C.interactiveStopIcon)}),L("div",{"aria-hidden":"true",class:C.addStopText},a)):null;return L("div",null,L("ol",{class:C.stops,role:"group",afterCreate:this._setUpDragAndDropStops},s),l)}_handleStopIconClick(e){const t=e.currentTarget["data-stop-index"],s=this.viewModel.stops.getItemAt(t);s&&r(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.stops.getItemAt(s);if(t===o){const e=this._acquireSearch(o);e.when((()=>{this.renderNow(),e.focus()}))}this._newPlaceholderStop=null}_handleStopInputBlur(e,t){this._handles.remove(N.awaitingViewClickStop),this.view.cursor=this._previousCursor;if(!e.selectedResult||!r(t.geometry)||!r(e.selectedResult.feature.geometry)||t.geometry!==e.selectedResult.feature.geometry)return"none"===e.activeMenu&&e.searchTerm&&(n(e.selectedResult.feature.geometry)&&n(t.geometry)||r(t.geometry)&&r(e.selectedResult.feature.geometry)&&t.geometry!==e.selectedResult.feature.geometry)?(e.search(),void this._pointerDownUpHandle.pause()):void(e.searchTerm||(this._viewClickHandle.resume(),clearTimeout(this._autoStopRemovalTimeoutId),this._autoStopRemovalTimeoutId=setTimeout((()=>{this.destroyed||(this._viewClickHandle.pause(),"searching"!==e.viewModel.state?this._pointerPressedSearchSuggestionStop||(r(t.geometry)&&(t.geometry=null,this._processStops()),this.scheduleRender()):this._pointerDownUpHandle.pause())}),this._autoStopRemovalDelay)));this._pointerDownUpHandle.pause()}_handleStopInputFocus(e,t){if(this._pointerDownUpHandle.resume(),this._handles.has(N.awaitingViewClickStop))return;const{view:s,view:{cursor:o}}=this;this._previousCursor=o,this._handles.add(c((()=>e.searchTerm),(t=>{e.destroyed||(s.cursor=0===t.length?"copy":o)}),d),N.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=F(e)?this._activeStop:null})),t=o(document,"pointerup",(e=>{this._pointerDownUpHandle.pause();const t=F(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)}_handleAddStopFocus(){this._addNewPlaceholder()}_addNewPlaceholder(){if(this._pointerDownUpHandle.pause(),this._newPlaceholderStop)return;const e=new _({symbol:new g});this.viewModel.stops.add(e),this._newPlaceholderStop=e}_handleReverseStops(){this._reverseStops()}_reverseStops(){this.viewModel.stops.reverse();for(const e of this.viewModel.stops)e.sequence=null;this._processStops()}_handleRemoveStop(e){const t=e.currentTarget["data-stop-index"];this._removeStop(this.viewModel.stops.getItemAt(t)),this._processStops()}_removeStop(e){this.viewModel.stops.length<=2||(this._disposeSearch(e),this.viewModel.stops.remove(e))}_handleDepartureOptionChange(e){const t=e.currentTarget,s=t.item(t.selectedIndex);s.value===b.NOW?(this._departureTime=b.NOW,this.viewModel.departureTime=b.NOW,this._handles.remove("departure-time-controls")):s.value===b.DEPART_BY?(this._departureTime=b.DEPART_BY,this._handles.add([c((()=>this._datePicker.value),(()=>this._updateDepartureTime()),d),c((()=>this._timePicker.value),(()=>this._updateDepartureTime()),d)],"departure-time-controls")):(this._departureTime=b.UNSPECIFIED,this.viewModel.departureTime=null)}_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 L("div",{class:C.departureTimeControls,key:"esri-directions__time-controls",role:"group"},this._datePicker.render(),this._timePicker.render())}_renderSectionSplitter(){return L("div",{class:C.sectionSplitter})}_renderDirectionsContainer(){return L("div",{class:this.classes(C.directionsSection,C.section),key:"esri-directions__container"},this._renderDirectionsContainerContent())}_renderLoader(){return L("div",{class:C.loader,key:"loader"})}_renderWarningCard(){return L("div",{class:C.warningCard,role:"alert"},L("div",{class:C.warningHeader},L("span",{class:C.warningIcon,"aria-hidden":"true"}),L(P,{class:C.warningHeading,level:this.headingLevel},this.messagesCommon.warning)),L("div",{class:C.warningMessage},this._getErrorMessage()))}_renderDirectionsContainerContent(){const{lastRoute:e,viewModel:{state:t}}=this,s="routing"===t;return"error"===t?this._renderWarningCard():s?this._renderLoader():r(e)&&r(e.directionLines)?L("div",{class:C.summary,key:"esri-directions__summary",role:"group"},this._renderCosts(),this._renderRouteActions(),this._renderManeuverSections()):L("div",{key:"esri-directions__placeholder",class:C.emptyContent},this._renderPlaceholder(),L(P,{class:C.message,level:this.headingLevel},this.messages.directionsPlaceholder))}_renderPlaceholder(){return L("svg",{class:C.emptyIllustration,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256"},L("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 L(P,{level:this.headingLevel},e)}_renderRouteActions(){return L("div",{class:C.routeActions},L("button",{"aria-label":this.messages.clearRoute,class:this.classes(C.clearRouteButton,C.button,C.buttonTertiary),tabIndex:0,onclick:this._handleClearRouteClick,bind:this,type:"button"},this.messages.clearRoute))}_getSections(){if(n(this.lastRoute))return null;const{directionPoints:e,directionLines:t,stops:s}=this.lastRoute;if(n(e)||n(t))return null;const o=[];let i=null;for(const a of e){const{objectId:e,stopId:l}=a;if(r(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:a,directionLine:c})}return o}_renderManeuverSections(){return n(this._sections)?null:L("div",{class:C.maneuvers,role:"group"},this._sections.map(((e,t)=>{const{open:s}=e;let o;e.directions.length>0&&s&&(o=L("ol",{class:C.maneuverList},e.directions.map((e=>this._renderManeuver(e)))));const i=a(this._sections).length>2,r=t===a(this._sections).length-1,n={[C.collapsibleSection]:i},l={[C.openIcon]:!s,[C.closeIcon]:s};let c;if(i&&!r){const t=s?this.messagesCommon.open:this.messagesCommon.close;c=L("header",{class:this.classes(C.maneuverSectionHeader,C.maneuverSectionToggle),key:"esri-directions__maneuver-section-header"},L("div",{"aria-expanded":s.toString(),"aria-label":t,bind:this,class:C.maneuverSectionHeaderButton,"data-maneuver-section":e,onkeydown:this._handleSectionToggle,onclick:this._handleSectionToggle,role:"button",tabIndex:0,title:t},L(P,{class:C.maneuverSectionTitle,level:this.headingLevel},e.stop.name),L("span",{"aria-hidden":"true",class:this.classes(l)})))}else c=L("header",{class:C.maneuverSectionHeader,key:"esri-directions__maneuver-section-header"},L(P,{class:C.maneuverSectionTitle,level:this.headingLevel},e.stop.name));return L("section",{class:this.classes(C.maneuverSection,n),key:t},c,o)})))}_handleSectionToggle(e){const t=e.currentTarget["data-maneuver-section"];t.open=!t.open}_renderCosts(){const{lastRoute:e}=this;if(n(e))return null;const t=this._getCostSummary(),{directionPoints:s}=e;if(n(s)||n(t))return null;const o=s.getItemAt(s.length-1).arrivalTime,{primary:i,secondary:a}=t,{eta:l,etaTemplate:c,primaryCosts:d,secondaryCosts:h,zoomToRoute:u}=this.messages,p=O("short-time"),m=r(o)?`<strong>${E(o,p)}</strong>`:null,v=r(o)?`${B(o)}`:null,_=A(c,{time:m,gmt:v});return L("div",{"aria-label":u,bind:this,class:C.directionCosts,onkeydown:this._handleSummaryInteraction,onclick:this._handleSummaryInteraction,role:"button",tabIndex:0,title:u},L("div",{class:C.costsDetails,role:"group"},L("div",{"aria-label":d,class:C.primaryCosts,title:d},i),L("div",{class:C.verticalSplitter}),L("div",{"aria-label":h,class:C.secondaryCosts,title:h},a)),L("div",{"aria-label":l,innerHTML:_,title:l}))}_handleSummaryInteraction(){this._activeManeuver=null,this._focusedManeuver=null,this.viewModel.clearHighlights(),this.zoomToRoute()}_getErrorMessage(){const{messages:e,viewModel:{error:t}}=this;if(r(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){if("url"in t&&t.url)null!=t.locationType||(t.locationType="street"),k(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([u((()=>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),this._stopsToSearches.set(e,s),s}_disposeSearch(e){this._stopsToSearches.get(e).destroy(),this._stopsToSearches.delete(e)}_processStops(){const e=this.viewModel.stops.filter((e=>r(e.geometry)));this.viewModel.stops=e,e.length>1&&this._getDirections()}_renderManeuver(e){const t="",{directionsLengthUnits:s}=this.viewModel.routeParameters,{directionPoint:o,directionLine:i}=e,{distance:n,duration:a}=i,{messages:c,messagesUnits:d}=this,h=M(c,d,l(n,0),{fromUnits:"meters",toUnits:s}),u=f(l(a,0),"minutes"),p=h&&u?`${h}&nbsp;&middot;&nbsp;${u}`:`${h}${u}`,m=this._getFormattedManeuverText(o),{objectId:v,directionPointType:_}=o,g=I(_),S=`esri-directions__maneuver-${v}`,w=`esri-directions__cumulative-costs-${v}`,y=`esri-directions__intermediate-costs-${v}`,T={[C.maneuverActive]:this._activeManeuver===i};return L("li",{"aria-labelledby":`${S} ${w} ${y}`,bind:this,class:this.classes(C.maneuver,T),"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},r(g)&&L("img",{alt:"",class:C.maneuverIcon,src:g}),L("div",{class:C.maneuverCostsContainer},L("span",{id:S,innerHTML:l(m,"")}),L("div",{class:C.maneuverCosts},L("div",{class:C.horizontalSplitter}),L("div",{id:w,"aria-label":c.cumulativeCosts,class:C.cumulativeCost,innerHTML:t,title:c.cumulativeCosts}),L("div",{id:y,"aria-label":c.intermediateCosts,class:C.intermediateCost,innerHTML:p,title:c.intermediateCosts}))))}_handleManeuverClick(e){const s=e.currentTarget["data-maneuver"];if(this._activeManeuver===s)return this._activeManeuver=null,void this.zoomToRoute();this._activeManeuver=s;const{geometry:o,symbol:i}=s,r=new t({geometry:o,symbol:i});this.viewModel.centerAt(r),this.viewModel.highlightSegment(r)}_handleManeuverMouseOver(e){if(this._activeManeuver||this._focusedManeuver)return;const s=e.currentTarget["data-maneuver"],{geometry:o,symbol:i}=s,r=new t({geometry:o,symbol:i});this.viewModel.highlightSegment(r)}_handleManeuverMouseOut(){this._activeManeuver||this._focusedManeuver||this.viewModel.clearHighlights()}_handleManeuverBlur(){this._activeManeuver||(this._focusedManeuver=null,this.viewModel.clearHighlights())}_handleManeuverFocus(e){if(this._activeManeuver)return;const s=e.currentTarget["data-maneuver"];this._focusedManeuver=s;const{geometry:o,symbol:i}=s,r=new t({geometry:o,symbol:i});this.viewModel.highlightSegment(r)}_getFormattedManeuverText(e){const{displayText:t,name:s,intersectingName:o}=e;if(n(t))return"";let i=t;return r(s)&&i.includes(s)&&(i=i.replace(s,`<strong>${s}</strong>`)),r(o)&&i.includes(o)&&(i=i.replace(o,`<strong>${o}</strong>`)),i}_getCostSummary(){const{viewModel:{impedanceAttribute:e,routeParameters:t},lastRoute:s}=this;if(n(e)||n(s))return null;const{routeInfo:o}=s;let{totalDuration:i,totalDistance:a}=o;const{directionsLengthUnits:l}=t;a=r(a)?a:0,i=r(i)?i:0;const c=M(this.messages,this.messagesUnits,a,{fromUnits:"meters",toUnits:l}),d=f(i,"minutes"),[h,u]=T(e.units)?[d,c]:[c,d];return{primary:h,secondary:u}}async _getDirections(){try{await this.viewModel.getDirections()}catch{}}};e([p("viewModel.apiKey")],W.prototype,"apiKey",void 0),e([p("viewModel.goToOverride")],W.prototype,"goToOverride",void 0),e([m()],W.prototype,"headingLevel",void 0),e([m()],W.prototype,"iconClass",void 0),e([m({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],W.prototype,"label",void 0),e([p("viewModel.lastRoute")],W.prototype,"lastRoute",void 0),e([p("viewModel.maxStops")],W.prototype,"maxStops",void 0),e([m(),U("esri/widgets/Directions/t9n/Directions")],W.prototype,"messages",void 0),e([m(),U("esri/t9n/common")],W.prototype,"messagesCommon",void 0),e([m(),U("esri/core/t9n/Units")],W.prototype,"messagesUnits",void 0),e([p("viewModel.routeServiceUrl")],W.prototype,"routeServiceUrl",void 0),e([p("viewModel.routeSymbol")],W.prototype,"routeSymbol",void 0),e([m()],W.prototype,"searchProperties",void 0),e([p("viewModel.stopSymbols")],W.prototype,"stopSymbols",void 0),e([p("viewModel.view")],W.prototype,"view",void 0),e([m({type:y})],W.prototype,"viewModel",void 0),e([p("viewModel.getDirections")],W.prototype,"getDirections",null),e([p("viewModel.zoomToRoute")],W.prototype,"zoomToRoute",null),e([H()],W.prototype,"_handleStopIconClick",null),e([H()],W.prototype,"_handleClearRouteClick",null),e([H()],W.prototype,"_handleReverseStops",null),e([H()],W.prototype,"_handleRemoveStop",null),e([H()],W.prototype,"_handleSectionToggle",null),e([H()],W.prototype,"_handleSummaryInteraction",null),e([H()],W.prototype,"_handleManeuverClick",null),W=e([v("esri.widgets.Directions")],W);const K=W;export{K as default};
package/widgets/Editor.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{HandleOwnerMixin as t}from"../core/HandleOwner.js";import s from"../core/Logger.js";import{isSome as i}from"../core/maybe.js";import{watch as a}from"../core/reactiveUtils.js";import{init as r,on as o,watch as n,whenNot as l}from"../core/watchUtils.js";import{aliasOf as d}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as c}from"../core/accessorSupport/decorators/cast.js";import{property as p}from"../core/accessorSupport/decorators/property.js";import{subclass as h}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as m}from"../layers/support/fieldUtils.js";import u from"../views/interactive/snapping/SnappingOptions.js";import g from"./Attachments.js";import v from"./FeatureForm.js";import _ from"./FeatureTemplates.js";import w from"./Spinner.js";import f from"./Widget.js";import{workflowDeprecation as k}from"./Editor/deprecationUtils.js";import y from"./Editor/EditorViewModel.js";import{ItemList as b}from"./FeatureTemplates/ItemList.js";import{Heading as C,incrementHeadingLevel as M}from"./support/Heading.js";import F from"./support/SnappingControls.js";import{accessibleHandler as A}from"./support/decorators/accessibleHandler.js";import{messageBundle as W}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as S}from"./support/jsxFactory.js";import{classes as E}from"./support/widgetUtils.js";import{substitute as B}from"../intl/substitute.js";const P={base:"esri-editor esri-widget esri-widget--panel",scroller:"esri-editor__scroller",content:"esri-editor__content",contentGroup:"esri-editor__content-group",message:"esri-editor__message",controls:"esri-editor__controls",progressBar:"esri-editor__progress-bar",promptContainer:"esri-editor__prompt",promptHeader:"esri-editor__prompt__header",promptHeading:"esri-editor__prompt__header__heading",promptMessage:"esri-editor__prompt__message",promptDivider:"esri-editor__prompt__divider",promptActions:"esri-editor__prompt__actions",promptOption:"esri-editor__prompt__option",promptOptionPrimary:"esri-editor__prompt__option--primary",promptOptionNegative:"esri-editor__prompt__option--negative",promptOptionPositive:"esri-editor__prompt__option--positive",controlButton:"esri-editor__control-button",overlay:"esri-editor__overlay",warningIcon:"esri-icon-notice-triangle",widgetIcon:"esri-icon-edit",button:"esri-button",buttonDisabled:"esri-button--disabled",buttonSecondary:"esri-button--secondary",buttonTertiary:"esri-button--tertiary",input:"esri-input",interactive:"esri-interactive",select:"esri-select",panelToolbar:"esri-editor__panel-toolbar",panelToolbarSnappingButton:"esri-editor__panel-toolbar__snapping-button",panelContent:"esri-editor__panel-content",panelContentSection:"esri-editor__panel-content--section",updateFeaturesActionButtons:"esri-editor__update-features-action-buttons",updateFeaturesActionButtonsButton:"esri-editor__update-features-action-buttons--button",featureTemplatesContainer:"esri-editor__feature-templates-container",snappingControlsPopover:"esri-editor__snapping-controls-popover",scrimOverlay:"esri-editor__scrim-overlay"},j={undoRedoButtons:!1};function L(e){e.focus()}const U="esri.widgets.Editor",V=s.getLogger(U);let x=class extends(t(f)){constructor(e,t){super(e,t),this._candidateCommitted=!1,this._featureForm=new v,this._stateStack=[],this._attachments=new g({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new _({enableListScroll:!1}),this._filterText="",this._prompt=null,this._spinner=new w,this._snappingPopover=null,this.activeWorkflow=null,this.allowedWorkflows=null,this.useDeprecatedCreateWorkflow=!1,this.headingLevel=4,this.iconClass=P.widgetIcon,this.label=void 0,this.layerInfos=null,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.snappingOptions=new u,this.supportingWidgetDefaults=null,this.view=null,this.viewModel=new y,this.visibleElements={...j},this._setCandidateFeature=(e,t=!1)=>{if(this._candidateCommitted)return;const s=this._assertActiveUpdateWorkflow();s.data.edits.feature=e,t&&(s.next(),this._candidateCommitted=!0)},this._handleSave=this._handleSave.bind(this),this._handleBack=this._handleBack.bind(this),this._handleDone=this._handleDone.bind(this),this._handleDelete=this._handleDelete.bind(this),this._handleAdd=this._handleAdd.bind(this),this._handleEdit=this._handleEdit.bind(this),this._handleAttachmentAdd=this._handleAttachmentAdd.bind(this),this._handleAttachmentUpdate=this._handleAttachmentUpdate.bind(this),this._handleAttachmentDelete=this._handleAttachmentDelete.bind(this),this.EditorPanel=this.EditorPanel.bind(this)}initialize(){const{view:e,snappingOptions:t}=this;this._snappingControls=new F({snappingOptions:t,view:e,visibleElements:{header:!1}}),this.own([r(this,"headingLevel",(e=>{this._featureForm.headingLevel=M(e),this._featureTemplates.headingLevel=M(e)})),this.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(e):this.startCreateFeaturesWorkflowAtFeatureCreation(e))),a((()=>this.viewModel.state),((e,t)=>{const s=this._stateStack.indexOf(e);-1===s?this._stateStack.push(t):this._stateStack.splice(s)})),r(this,"viewModel",(e=>{this._featureForm.viewModel=e?e.featureFormViewModel:null,this._attachments.viewModel=e?e.attachmentsViewModel:null,this._featureTemplates.viewModel=e?e.featureTemplatesViewModel:null,this._spinner.viewModel=e?e.spinnerViewModel:null})),r(this,"view",((e,t)=>{const s=`editor-${this.id}-spinner`;t&&t.ui.remove(this._spinner,s),e&&e.ui.add(this._spinner,{key:s,position:"manual"})})),o(this,"viewModel.sketchViewModel","create",(()=>{this.scheduleRender()})),o(this,"viewModel.activeWorkflow","cancel-request",(({controller:e})=>{const{messages:t,messagesCommon:s}=this;this._prompt={title:t.cancelRequestTitle,message:t.cancelRequestWarningMessage,context:"danger",actions:{primary:{label:s.form.yes,action:()=>{e.allow(),this._prompt=null}},secondary:{label:s.form.no,action:()=>(e.deny(),this._prompt=null)}}},this.scheduleRender()})),r(this,"supportingWidgetDefaults",(e=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch))})),n(this,"_attachments.error",(e=>{if(!e)return;const{messages:t,messagesCommon:s}=this;this._prompt={title:t.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:s.form.ok,action:()=>{this._prompt=null}}}}})),n(this,"viewModel.failures",(e=>{if(!e)return;const{messages:t}=this,[{error:s,retry:i,cancel:a}]=e;this._prompt={title:t.errorWarningTitle,message:B(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{i(),this._prompt=null}},secondary:{label:t.ignore,action:()=>(a(),this._prompt=null)}}}})),n(this,"viewModel.state",(e=>{"awaiting-feature-to-update"===e&&(this._filterText=""),"awaiting-update-feature-candidate"===e&&(this._candidateCommitted=!1)})),n(this,["_attachments.selectedFile","_attachments.submitting"],(()=>this.scheduleRender())),l(this,"viewModel.activeWorkflow",(()=>this._featureTemplates.filterText=""))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._snappingControls.destroy()}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-action.js"),import("@esri/calcite-components/dist/components/calcite-action-menu.js"),import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-flow.js"),import("@esri/calcite-components/dist/components/calcite-icon.js"),import("@esri/calcite-components/dist/components/calcite-loader.js"),import("@esri/calcite-components/dist/components/calcite-panel.js"),import("@esri/calcite-components/dist/components/calcite-popover.js"),import("@esri/calcite-components/dist/components/calcite-popover-manager.js"),import("@esri/calcite-components/dist/components/calcite-scrim.js"),import("@esri/calcite-components/dist/components/calcite-tooltip-manager.js")])}castVisibleElements(e){return{...j,...e}}startCreateWorkflowAtFeatureTypeSelection(){return k(V,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return k(V,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return k(V,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{_attachments:e,_prompt:t,viewModel:s}=this;if(!s)return S("div",{class:P.base});const{state:a}=s,r=i(t)?S("calcite-scrim",null,this.renderPrompt(t)):null;return S("div",{class:P.base},s.syncing||e.submitting?this.renderProgressBar():null,S("calcite-flow",null,this._stateStack.map((e=>this.renderState(e))),this.renderState(a)),r)}renderState(e){switch(e){case"disabled":break;case"ready":return this.renderLanding(e);case"awaiting-feature-creation-info":return this.renderTemplates(e);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this.renderAttributeEditing(e);case"awaiting-feature-to-update":return this.renderFeatureUpdating(e);case"awaiting-update-feature-candidate":return this.renderFeatureList(e);case"awaiting-feature-to-create":return this.renderFeatureCreation(e);case"adding-attachment":return this.renderAttachmentAdding(e);case"editing-attachment":return this.renderAttachmentEditing(e)}return S("div",null)}isPanelActive(e){return this.viewModel.state===e}renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:i,messagesCommon:a,_handleBack:r,_snappingControls:o,viewModel:{sketchViewModel:n}}=this;return S(t,{active:this.isPanelActive(e),key:"templates-panel",handleBack:r,heading:i.selectTemplate,headingLevel:s,messages:i,messagesCommon:a,sketchViewModel:n,snappingControls:o},this._featureTemplates.render())}renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:i,messagesCommon:a,headingLevel:r,_handleBack:o,_snappingControls:n,viewModel:l}=this,{sketchViewModel:d}=l,c=l.featureFormViewModel;if("create-features"===t.type&&t.pendingFeatures.length<1)return this.renderFeatureCreation(e);const p="update"===t.type&&!t.data.edits.modified||l.syncing||c.inputFields.length>0&&!c.submittable,h="update"===t.type?i.editFeature:i.createFeatures,m="update"===t.type?a.update:a.create,u="create-features"===t.type&&"create-new"===t.createFeatureState,g=[{label:"create-features"===t.type&&t.numPendingFeatures>1?B(i.createFeaturesTemplate,{numFeatures:t.numPendingFeatures}):m,type:"primary",disabled:p,clickHandler:this._handleSave}];let v=!1;return"update"===t.type&&(t.data.editableItem.hasAttachments&&(v=!0),t.data.editableItem.supports.includes("delete")&&g.push({label:a.delete,type:"tertiary",clickHandler:this._handleDelete})),S(s,{active:this.isPanelActive(e),key:"attribute-editing-panel",heading:h,headingLevel:r,showContentScrim:u,handleBack:o,messages:i,messagesCommon:a,sketchViewModel:d,snappingControls:n},S("div",{class:P.panelContentSection},S("div",{class:P.contentGroup},c.inputFields.length>0?this._featureForm.render():this.renderMessage(B(i.clickToFinishTemplate,{button:m})),v?S("div",{key:"attachments"},S("div",null,i.attachments),this._attachments.render()):null)),S("div",{class:this._prompt?"":P.scrimOverlay},this.renderControls(g)))}renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_handleBack:i,headingLevel:a,messages:r,messagesCommon:o,_snappingControls:n,viewModel:{sketchViewModel:l}}=this,d=[{label:t.submitting?o.cancel:o.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentAdd}];return S(s,{active:this.isPanelActive(e),key:"attachment-adding-panel",heading:r.addAttachment,headingLevel:a,handleBack:i,messages:r,messagesCommon:o,sketchViewModel:l,snappingControls:n},S("div",{class:this.classes(P.content,P.scroller)},t.render()),this.renderControls(d))}renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_handleBack:i,headingLevel:a,messages:r,messagesCommon:o,_snappingControls:n,viewModel:{sketchViewModel:l}}=this,d=[{label:o.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentUpdate},{label:o.delete,disabled:t.submitting,type:"tertiary",clickHandler:this._handleAttachmentDelete}];return S(s,{active:this.isPanelActive(e),key:"attachment-editing-panel",heading:r.editAttachment,headingLevel:a,handleBack:i,messages:r,messagesCommon:o,sketchViewModel:l,snappingControls:n},S("div",{class:this.classes(P.content,P.scroller)},t.render()),this.renderControls(d))}renderFeatureUpdating(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,_snappingControls:o,viewModel:{sketchViewModel:n}}=this;return S(t,{active:this.isPanelActive(e),key:"feature-updating-panel",heading:a.selectFeature,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:n,snappingControls:o},S("div",{class:this.classes(P.content,P.scroller)},this.renderMessage(a.selectFeatureToEdit)))}renderMessage(e){return S("div",{class:P.message},e)}renderFeatureCreation(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,_snappingControls:o,viewModel:n}=this,{sketchViewModel:l}=n,d=n.sketchViewModel,c=this._assertActiveCreateWorkflow().data.creationInfo.layer,p=d.canUndo()&&d.createGraphic?d.createGraphic:null,h=this._getSketchingTip(c.geometryType,p);return S(t,{active:this.isPanelActive(e),key:"feature-creation-panel",heading:a.placeFeature,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:l,snappingControls:o},S("div",{class:this.classes(P.content,P.scroller)},this.renderMessage(h)))}renderControls(e){return S("div",{class:P.controls,key:"controls"},e.map((({disabled:e=!1,label:t,type:s,clickHandler:i},a)=>this.renderButton({label:t,class:this.classes(P.controlButton,P.button,"secondary"===s?P.buttonSecondary:"tertiary"===s?P.buttonTertiary:null,e?P.buttonDisabled:null),disabled:e,clickHandler:i,key:a}))))}renderPrompt({title:e,message:t,context:s,actions:i}){const a=!!i.secondary,r=S("calcite-button",{appearance:"solid",color:"danger"===s?"red":"blue",width:a?"half":"full",onclick:i.primary.action,key:"prompt-primary-button",afterCreate:L},i.primary.label),o=a?S("calcite-button",{appearance:"clear",color:"danger"===s?"red":"blue",width:"half",onclick:i.secondary.action,key:"prompt-secondary-button"},i.secondary.label):null;return S("div",{class:`${P.promptContainer}--${s}`},S("div",{class:P.promptHeader},S("calcite-icon",{icon:"exclamation-mark-triangle"}),S(C,{class:P.promptHeading,level:this.headingLevel},e)),S("div",{class:P.promptMessage},t),S("div",{class:P.promptDivider}),S("div",{class:P.promptActions},o,r))}renderProgressBar(){return S("div",{class:this.classes(P.progressBar),key:"progress-bar"})}renderButton(e){return S("button",{class:e.class,disabled:e.disabled,key:e.key,onclick:e.clickHandler,type:"button"},e.label)}renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:i,messagesCommon:a,_snappingControls:r,viewModel:{sketchViewModel:o}}=this;return S(t,{active:this.isPanelActive(e),key:"landing-panel",heading:i.widgetLabel,headingLevel:s,showBackButton:!1,messages:i,messagesCommon:a,sketchViewModel:o,snappingControls:r},S("div",{key:"edit-actions",class:P.panelContentSection},this.renderUpdateActions()),S("div",{key:"create-actions",class:P.panelContentSection},this.renderCreateActions()))}renderUpdateActions(){const{messages:e,messagesCommon:t}=this;return S("div",null,S(C,{level:M(this.headingLevel)},e.editFeatures),S("div",{class:P.updateFeaturesActionButtons},S("calcite-action",{text:t.select,textEnabled:!0,icon:"cursor",alignment:"start",class:P.updateFeaturesActionButtonsButton,onclick:this._handleEdit})))}renderCreateActions(){const{messages:e}=this;return S("div",null,S(C,{level:M(this.headingLevel)},e.createFeatures),S("div",{key:"templates",class:P.featureTemplatesContainer},this._featureTemplates.render()))}renderFeatureList(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,messagesTemplates:o,_snappingControls:n,viewModel:{editableItems:l,sketchViewModel:d}}=this,c=this._assertActiveUpdateWorkflow().data.candidates,p=B(a.multipleFeaturesTemplate,{total:c.length}),h=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,i=this._filterText.toLowerCase(),{title:a}=s.layer,r=this.viewModel.editableItems.find((e=>e.layer===s.layer));return r.supports.includes("update")&&(!i||t.toLowerCase().includes(i)||a.toLowerCase().includes(i))})).forEach((e=>{m++;const t=e.data.layer;h.has(t)?h.get(t).items.push(e):h.set(t,{id:`${t.id}`,label:t.title,items:[e]})}));const u=l.filter((({layer:e})=>h.has(e))).map((({layer:e})=>h.get(e))).toArray(),g=m>10||this._filterText.length>0;return S(t,{active:this.isPanelActive(e),key:"feature-list",heading:p,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:d,snappingControls:n},b({id:this.id,enableListScroll:!1,filterEnabled:g,filterText:this._filterText,items:u,messages:{filterPlaceholder:o.filterPlaceholder,noItems:o.noItems,noMatches:o.noMatches},onItemMouseEnter:({data:e})=>this._setCandidateFeature(e),onItemMouseLeave:()=>this._setCandidateFeature(null),onItemSelect:({data:e})=>this._setCandidateFeature(e,!0),onFilterChange:e=>this._filterText=e}))}EditorPanel(e,...t){const{active:s,handleBack:i,heading:a,headingLevel:r,key:o,messages:n,messagesCommon:l,showBackButton:d,showContentScrim:c,sketchViewModel:p,snappingControls:h}=e;return S("calcite-panel",{bind:this,key:o,heading:a,headingLevel:r,showBackButton:null==d||d,beforeBack:null!=i?i:null,onCalcitePanelScroll:this._onSnappingPopoverPanelScroll},S("calcite-popover-manager",{autoClose:s,class:P.panelToolbar},S("calcite-popover",{afterCreate:this._afterSnappingPopoverCreated,afterUpdate:this._afterSnappingPopoverUpdated,bind:this,label:n.snappingSettings,heading:n.snappingSettings,"reference-element":`${o}__snappingButton`,"overlay-positioning":"fixed"},S("div",{class:P.snappingControlsPopover},h.render())),S("calcite-button",{id:`${o}__snappingButton`,text:n.snapping,appearance:"transparent",color:"neutral",alignment:"icon-end-space-between","icon-start":"vertex-gps","icon-end":"caret-down",width:"full",class:P.panelToolbarSnappingButton},n.snapping),this.visibleElements.undoRedoButtons?[S("calcite-button",{key:"undo-button",text:l.undo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"undo",scale:"l",disabled:!p.canUndo(),onclick:p.undo.bind(p)}),S("calcite-button",{key:"redo-button",text:l.redo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"redo",scale:"l",disabled:!p.canRedo(),onclick:p.redo.bind(p)})]:null),S("div",{class:E(P.panelContent,P.scroller)},t,c?S("calcite-scrim",null):null))}_onSnappingPopoverPanelScroll(){var e;null!=(e=this._snappingPopover)&&e.open&&this._snappingPopover.toggle()}_afterSnappingPopoverCreated(e){this._snappingPopover=e}_afterSnappingPopoverUpdated(e){this._snappingPopover=e}_getSketchingTip(e,t){const{messages:s}=this;if("point"===e)return s.tips.clickToAddPoint;if("polygon"===e||"polyline"===e){if(!t)return s.tips.clickToStart;const i=t.geometry,a="polygon"===e?"rings":"paths",[r]=i[a];return"polygon"===e&&r<4?s.tips.clickToContinue:s.tips.clickToContinueThenDoubleClickToEnd}return s.tips.clickToAddFeature}_getLabel(e){const t=e.layer;if(!t)return null;const{objectIdField:s}=t,{attributes:i}=e,a=m(t);return a&&i[a]&&`${i[a]}`||B(this.messages.untitledFeatureTemplate,{id:i[s]})}_handleDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.viewModel.deleteFeatureFromWorkflow(),this._prompt=null}},secondary:{label:e.keepFeature,action:()=>this._prompt=null}}}}_handleSave(){this.viewModel.featureFormViewModel.validateContingencyConstraints(this.viewModel.featureFormViewModel.getValues(),{includeIncompleteViolations:!0}).length>0||this.viewModel.activeWorkflow.commit()}_handleAttachmentAdd(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.addAttachment().then((()=>t.previous()))}_handleAttachmentUpdate(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.updateAttachment().then((()=>t.previous()))}_handleAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.deleteAttachment(e.viewModel.activeAttachmentInfo).then((()=>{t.previous(),this._prompt=null}))}},secondary:{label:e.keepAttachment,action:()=>this._prompt=null}}}}_handleAdd(){this.viewModel.canCreate}_handleEdit(){this.viewModel.canUpdate&&this.viewModel.startUpdateWorkflowAtFeatureSelection()}_handleDone(){this.viewModel.cancelWorkflow({force:!0})}async _handleBack(){const{messages:e}=this,t=this.activeWorkflow,s=()=>{t.hasPreviousStep?t.previous({cancelCurrentStep:!0}):this.viewModel.cancelWorkflow({force:!0})};if("create"===t.type||"create-features"===t.type&&t.numPendingFeatures>0||"update"===t.type&&t.data.edits.modified){const{type:i}=t,a="create"===i?e.cancelAddWarningMessage:e.cancelEditWarningMessage,r="create"===i?e.cancelAddTitle:e.cancelEditTitle,o="create"===i?e.continueAdding:e.continueEditing,n="create"===i?e.discardFeature:e.discardEdits;return this._prompt={title:r,message:a,context:"danger",actions:{primary:{label:n,action:()=>{s(),this._prompt=null}},secondary:{label:o,action:()=>this._prompt=null}}},this.scheduleRender(),Promise.reject()}s()}_assertActiveCreateWorkflow(){const{type:e}=this.viewModel.activeWorkflow;if("create"===e||"create-features"===e)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be instance of CreateWorkflow or CreateFeaturesWorkflow")}_assertActiveUpdateWorkflow(){if("update"===this.viewModel.activeWorkflow.type)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be an UpdateWorkflow")}};e([p()],x.prototype,"_attachments",void 0),e([d("viewModel.activeWorkflow")],x.prototype,"activeWorkflow",void 0),e([d("viewModel.allowedWorkflows")],x.prototype,"allowedWorkflows",void 0),e([p()],x.prototype,"useDeprecatedCreateWorkflow",void 0),e([p()],x.prototype,"headingLevel",void 0),e([p()],x.prototype,"iconClass",void 0),e([p({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],x.prototype,"label",void 0),e([d("viewModel.layerInfos")],x.prototype,"layerInfos",void 0),e([p(),W("esri/widgets/Editor/t9n/Editor")],x.prototype,"messages",void 0),e([p(),W("esri/t9n/common")],x.prototype,"messagesCommon",void 0),e([p(),W("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],x.prototype,"messagesTemplates",void 0),e([d("viewModel.snappingOptions")],x.prototype,"snappingOptions",void 0),e([p()],x.prototype,"supportingWidgetDefaults",void 0),e([d("viewModel.view")],x.prototype,"view",void 0),e([p(),T(["workflow-cancel","workflow-commit"])],x.prototype,"viewModel",void 0),e([p()],x.prototype,"visibleElements",void 0),e([c("visibleElements")],x.prototype,"castVisibleElements",null),e([A()],x.prototype,"_handleDelete",null),e([A()],x.prototype,"_handleAttachmentAdd",null),e([A()],x.prototype,"_handleAttachmentUpdate",null),e([A()],x.prototype,"_handleAttachmentDelete",null),e([A()],x.prototype,"_handleAdd",null),e([A()],x.prototype,"_handleEdit",null),e([A()],x.prototype,"_handleDone",null),x=e([h(U)],x);const D=x;export{D as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{HandleOwnerMixin as t}from"../core/HandleOwner.js";import s from"../core/Logger.js";import{isSome as i}from"../core/maybe.js";import{watch as a}from"../core/reactiveUtils.js";import{init as r,on as o,watch as n,whenNot as l}from"../core/watchUtils.js";import{aliasOf as d}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as c}from"../core/accessorSupport/decorators/cast.js";import{property as p}from"../core/accessorSupport/decorators/property.js";import{subclass as h}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as m}from"../layers/support/fieldUtils.js";import u from"../views/interactive/snapping/SnappingOptions.js";import g from"./Attachments.js";import v from"./FeatureForm.js";import _ from"./FeatureTemplates.js";import w from"./Spinner.js";import f from"./Widget.js";import{workflowDeprecation as k}from"./Editor/deprecationUtils.js";import y from"./Editor/EditorViewModel.js";import{ItemList as b}from"./FeatureTemplates/ItemList.js";import{Heading as C,incrementHeadingLevel as M}from"./support/Heading.js";import A from"./support/SnappingControls.js";import{accessibleHandler as F}from"./support/decorators/accessibleHandler.js";import{messageBundle as W}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as S}from"./support/jsxFactory.js";import{classes as E}from"./support/widgetUtils.js";import{substitute as B}from"../intl/substitute.js";const P={base:"esri-editor esri-widget esri-widget--panel",scroller:"esri-editor__scroller",content:"esri-editor__content",contentGroup:"esri-editor__content-group",message:"esri-editor__message",controls:"esri-editor__controls",progressBar:"esri-editor__progress-bar",promptContainer:"esri-editor__prompt",promptHeader:"esri-editor__prompt__header",promptHeading:"esri-editor__prompt__header__heading",promptMessage:"esri-editor__prompt__message",promptDivider:"esri-editor__prompt__divider",promptActions:"esri-editor__prompt__actions",promptOption:"esri-editor__prompt__option",promptOptionPrimary:"esri-editor__prompt__option--primary",promptOptionNegative:"esri-editor__prompt__option--negative",promptOptionPositive:"esri-editor__prompt__option--positive",controlButton:"esri-editor__control-button",overlay:"esri-editor__overlay",warningIcon:"esri-icon-notice-triangle",widgetIcon:"esri-icon-edit",button:"esri-button",buttonDisabled:"esri-button--disabled",buttonSecondary:"esri-button--secondary",buttonTertiary:"esri-button--tertiary",input:"esri-input",interactive:"esri-interactive",select:"esri-select",panelToolbar:"esri-editor__panel-toolbar",panelToolbarSnappingButton:"esri-editor__panel-toolbar__snapping-button",panelContent:"esri-editor__panel-content",panelContentSection:"esri-editor__panel-content--section",updateFeaturesActionButtons:"esri-editor__update-features-action-buttons",updateFeaturesActionButtonsButton:"esri-editor__update-features-action-buttons--button",featureTemplatesContainer:"esri-editor__feature-templates-container",snappingControlsPopover:"esri-editor__snapping-controls-popover",scrimOverlay:"esri-editor__scrim-overlay"},j={undoRedoButtons:!1};function L(e){e.focus()}const U="esri.widgets.Editor",V=s.getLogger(U);let x=class extends(t(f)){constructor(e,t){super(e,t),this._candidateCommitted=!1,this._featureForm=new v,this._stateStack=[],this._attachments=new g({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new _({enableListScroll:!1}),this._filterText="",this._prompt=null,this._spinner=new w,this._snappingPopover=null,this.activeWorkflow=null,this.allowedWorkflows=null,this.useDeprecatedCreateWorkflow=!1,this.headingLevel=4,this.iconClass=P.widgetIcon,this.label=void 0,this.layerInfos=null,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.snappingOptions=new u,this.supportingWidgetDefaults=null,this.view=null,this.viewModel=new y,this.visibleElements={...j},this._setCandidateFeature=(e,t=!1)=>{if(this._candidateCommitted)return;const s=this._assertActiveUpdateWorkflow();s.data.edits.feature=e,t&&(s.next(),this._candidateCommitted=!0)},this._handleSave=this._handleSave.bind(this),this._handleBack=this._handleBack.bind(this),this._handleDone=this._handleDone.bind(this),this._handleDelete=this._handleDelete.bind(this),this._handleAdd=this._handleAdd.bind(this),this._handleEdit=this._handleEdit.bind(this),this._handleAttachmentAdd=this._handleAttachmentAdd.bind(this),this._handleAttachmentUpdate=this._handleAttachmentUpdate.bind(this),this._handleAttachmentDelete=this._handleAttachmentDelete.bind(this),this.EditorPanel=this.EditorPanel.bind(this)}initialize(){const{view:e,snappingOptions:t}=this;this._snappingControls=new A({snappingOptions:t,view:e,visibleElements:{header:!1}}),this.own([r(this,"headingLevel",(e=>{this._featureForm.headingLevel=M(e),this._featureTemplates.headingLevel=M(e)})),this.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(e):this.startCreateFeaturesWorkflowAtFeatureCreation(e))),a((()=>this.viewModel.state),((e,t)=>{const s=this._stateStack.indexOf(e);-1===s?this._stateStack.push(t):this._stateStack.splice(s)})),r(this,"viewModel",(e=>{this._featureForm.viewModel=e?e.featureFormViewModel:null,this._attachments.viewModel=e?e.attachmentsViewModel:null,this._featureTemplates.viewModel=e?e.featureTemplatesViewModel:null,this._spinner.viewModel=e?e.spinnerViewModel:null})),r(this,"view",((e,t)=>{const s=`editor-${this.id}-spinner`;t&&t.ui.remove(this._spinner,s),e&&e.ui.add(this._spinner,{key:s,position:"manual"})})),o(this,"viewModel.sketchViewModel","create",(()=>{this.scheduleRender()})),o(this,"viewModel.activeWorkflow","cancel-request",(({controller:e})=>{const{messages:t,messagesCommon:s}=this;this._prompt={title:t.cancelRequestTitle,message:t.cancelRequestWarningMessage,context:"danger",actions:{primary:{label:s.form.yes,action:()=>{e.allow(),this._prompt=null}},secondary:{label:s.form.no,action:()=>(e.deny(),this._prompt=null)}}},this.scheduleRender()})),r(this,"supportingWidgetDefaults",(e=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch))})),n(this,"_attachments.error",(e=>{if(!e)return;const{messages:t,messagesCommon:s}=this;this._prompt={title:t.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:s.form.ok,action:()=>{this._prompt=null}}}}})),n(this,"viewModel.failures",(e=>{if(!e)return;const{messages:t}=this,[{error:s,retry:i,cancel:a}]=e;this._prompt={title:t.errorWarningTitle,message:B(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{i(),this._prompt=null}},secondary:{label:t.ignore,action:()=>(a(),this._prompt=null)}}}})),n(this,"viewModel.state",(e=>{"awaiting-feature-to-update"===e&&(this._filterText=""),"awaiting-update-feature-candidate"===e&&(this._candidateCommitted=!1)})),n(this,["_attachments.selectedFile","_attachments.submitting"],(()=>this.scheduleRender())),l(this,"viewModel.activeWorkflow",(()=>this._featureTemplates.filterText=""))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._snappingControls.destroy()}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-action.js"),import("@esri/calcite-components/dist/components/calcite-action-menu.js"),import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-flow.js"),import("@esri/calcite-components/dist/components/calcite-icon.js"),import("@esri/calcite-components/dist/components/calcite-loader.js"),import("@esri/calcite-components/dist/components/calcite-panel.js"),import("@esri/calcite-components/dist/components/calcite-popover.js"),import("@esri/calcite-components/dist/components/calcite-popover-manager.js"),import("@esri/calcite-components/dist/components/calcite-scrim.js"),import("@esri/calcite-components/dist/components/calcite-tooltip-manager.js")])}castVisibleElements(e){return{...j,...e}}startCreateWorkflowAtFeatureTypeSelection(){return k(V,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return k(V,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return k(V,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{_attachments:e,_prompt:t,viewModel:s}=this;if(!s)return S("div",{class:P.base});const{state:a}=s,r=i(t)?S("calcite-scrim",null,this.renderPrompt(t)):null;return S("div",{class:P.base},s.syncing||e.submitting?this.renderProgressBar():null,S("calcite-flow",null,this._stateStack.map((e=>this.renderState(e))),this.renderState(a)),r)}renderState(e){switch(e){case"disabled":break;case"ready":return this.renderLanding(e);case"awaiting-feature-creation-info":return this.renderTemplates(e);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this.renderAttributeEditing(e);case"awaiting-feature-to-update":return this.renderFeatureUpdating(e);case"awaiting-update-feature-candidate":return this.renderFeatureList(e);case"awaiting-feature-to-create":return this.renderFeatureCreation(e);case"adding-attachment":return this.renderAttachmentAdding(e);case"editing-attachment":return this.renderAttachmentEditing(e)}return S("div",null)}isPanelActive(e){return this.viewModel.state===e}renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:i,messagesCommon:a,_handleBack:r,_snappingControls:o,viewModel:{sketchViewModel:n}}=this;return S(t,{active:this.isPanelActive(e),key:"templates-panel",handleBack:r,heading:i.selectTemplate,headingLevel:s,messages:i,messagesCommon:a,sketchViewModel:n,snappingControls:o},this._featureTemplates.render())}renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:i,messagesCommon:a,headingLevel:r,_handleBack:o,_snappingControls:n,viewModel:l}=this,{sketchViewModel:d}=l,c=l.featureFormViewModel;if("create-features"===t.type&&t.pendingFeatures.length<1)return this.renderFeatureCreation(e);const p="update"===t.type&&!t.data.edits.modified||l.syncing,h="update"===t.type?i.editFeature:i.createFeatures,m="update"===t.type?a.update:a.create,u="create-features"===t.type&&"create-new"===t.createFeatureState,g=[{label:"create-features"===t.type&&t.numPendingFeatures>1?B(i.createFeaturesTemplate,{numFeatures:t.numPendingFeatures}):m,type:"primary",disabled:p,clickHandler:this._handleSave}];let v=!1;return"update"===t.type&&(t.data.editableItem.hasAttachments&&(v=!0),t.data.editableItem.supports.includes("delete")&&g.push({label:a.delete,type:"tertiary",clickHandler:this._handleDelete})),S(s,{active:this.isPanelActive(e),key:"attribute-editing-panel",heading:h,headingLevel:r,showContentScrim:u,handleBack:o,messages:i,messagesCommon:a,sketchViewModel:d,snappingControls:n},S("div",{class:P.panelContentSection},S("div",{class:P.contentGroup},c.inputFields.length>0?this._featureForm.render():this.renderMessage(B(i.clickToFinishTemplate,{button:m})),v?S("div",{key:"attachments"},S("div",null,i.attachments),this._attachments.render()):null)),S("div",{class:this._prompt?"":P.scrimOverlay},this.renderControls(g)))}renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_handleBack:i,headingLevel:a,messages:r,messagesCommon:o,_snappingControls:n,viewModel:{sketchViewModel:l}}=this,d=[{label:t.submitting?o.cancel:o.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentAdd}];return S(s,{active:this.isPanelActive(e),key:"attachment-adding-panel",heading:r.addAttachment,headingLevel:a,handleBack:i,messages:r,messagesCommon:o,sketchViewModel:l,snappingControls:n},S("div",{class:this.classes(P.content,P.scroller)},t.render()),this.renderControls(d))}renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_handleBack:i,headingLevel:a,messages:r,messagesCommon:o,_snappingControls:n,viewModel:{sketchViewModel:l}}=this,d=[{label:o.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentUpdate},{label:o.delete,disabled:t.submitting,type:"tertiary",clickHandler:this._handleAttachmentDelete}];return S(s,{active:this.isPanelActive(e),key:"attachment-editing-panel",heading:r.editAttachment,headingLevel:a,handleBack:i,messages:r,messagesCommon:o,sketchViewModel:l,snappingControls:n},S("div",{class:this.classes(P.content,P.scroller)},t.render()),this.renderControls(d))}renderFeatureUpdating(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,_snappingControls:o,viewModel:{sketchViewModel:n}}=this;return S(t,{active:this.isPanelActive(e),key:"feature-updating-panel",heading:a.selectFeature,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:n,snappingControls:o},S("div",{class:this.classes(P.content,P.scroller)},this.renderMessage(a.selectFeatureToEdit)))}renderMessage(e){return S("div",{class:P.message},e)}renderFeatureCreation(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,_snappingControls:o,viewModel:n}=this,{sketchViewModel:l}=n,d=n.sketchViewModel,c=this._assertActiveCreateWorkflow().data.creationInfo.layer,p=d.canUndo()&&d.createGraphic?d.createGraphic:null,h=this._getSketchingTip(c.geometryType,p);return S(t,{active:this.isPanelActive(e),key:"feature-creation-panel",heading:a.placeFeature,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:l,snappingControls:o},S("div",{class:this.classes(P.content,P.scroller)},this.renderMessage(h)))}renderControls(e){return S("div",{class:P.controls,key:"controls"},e.map((({disabled:e=!1,label:t,type:s,clickHandler:i},a)=>this.renderButton({label:t,class:this.classes(P.controlButton,P.button,"secondary"===s?P.buttonSecondary:"tertiary"===s?P.buttonTertiary:null,e?P.buttonDisabled:null),disabled:e,clickHandler:i,key:a}))))}renderPrompt({title:e,message:t,context:s,actions:i}){const a=!!i.secondary,r=S("calcite-button",{appearance:"solid",color:"danger"===s?"red":"blue",width:a?"half":"full",onclick:i.primary.action,key:"prompt-primary-button",afterCreate:L},i.primary.label),o=a?S("calcite-button",{appearance:"clear",color:"danger"===s?"red":"blue",width:"half",onclick:i.secondary.action,key:"prompt-secondary-button"},i.secondary.label):null;return S("div",{class:`${P.promptContainer}--${s}`},S("div",{class:P.promptHeader},S("calcite-icon",{icon:"exclamation-mark-triangle"}),S(C,{class:P.promptHeading,level:this.headingLevel},e)),S("div",{class:P.promptMessage},t),S("div",{class:P.promptDivider}),S("div",{class:P.promptActions},o,r))}renderProgressBar(){return S("div",{class:this.classes(P.progressBar),key:"progress-bar"})}renderButton(e){return S("button",{class:e.class,disabled:e.disabled,key:e.key,onclick:e.clickHandler,type:"button"},e.label)}renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:i,messagesCommon:a,_snappingControls:r,viewModel:{sketchViewModel:o}}=this;return S(t,{active:this.isPanelActive(e),key:"landing-panel",heading:i.widgetLabel,headingLevel:s,showBackButton:!1,messages:i,messagesCommon:a,sketchViewModel:o,snappingControls:r},S("div",{key:"edit-actions",class:P.panelContentSection},this.renderUpdateActions()),S("div",{key:"create-actions",class:P.panelContentSection},this.renderCreateActions()))}renderUpdateActions(){const{messages:e,messagesCommon:t}=this;return S("div",null,S(C,{level:M(this.headingLevel)},e.editFeatures),S("div",{class:P.updateFeaturesActionButtons},S("calcite-action",{text:t.select,textEnabled:!0,icon:"cursor",alignment:"start",class:P.updateFeaturesActionButtonsButton,onclick:this._handleEdit})))}renderCreateActions(){const{messages:e}=this;return S("div",null,S(C,{level:M(this.headingLevel)},e.createFeatures),S("div",{key:"templates",class:P.featureTemplatesContainer},this._featureTemplates.render()))}renderFeatureList(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,messagesTemplates:o,_snappingControls:n,viewModel:{editableItems:l,sketchViewModel:d}}=this,c=this._assertActiveUpdateWorkflow().data.candidates,p=B(a.multipleFeaturesTemplate,{total:c.length}),h=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,i=this._filterText.toLowerCase(),{title:a}=s.layer,r=this.viewModel.editableItems.find((e=>e.layer===s.layer));return r.supports.includes("update")&&(!i||t.toLowerCase().includes(i)||a.toLowerCase().includes(i))})).forEach((e=>{m++;const t=e.data.layer;h.has(t)?h.get(t).items.push(e):h.set(t,{id:`${t.id}`,label:t.title,items:[e]})}));const u=l.filter((({layer:e})=>h.has(e))).map((({layer:e})=>h.get(e))).toArray(),g=m>10||this._filterText.length>0;return S(t,{active:this.isPanelActive(e),key:"feature-list",heading:p,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:d,snappingControls:n},b({id:this.id,enableListScroll:!1,filterEnabled:g,filterText:this._filterText,items:u,messages:{filterPlaceholder:o.filterPlaceholder,noItems:o.noItems,noMatches:o.noMatches},onItemMouseEnter:({data:e})=>this._setCandidateFeature(e),onItemMouseLeave:()=>this._setCandidateFeature(null),onItemSelect:({data:e})=>this._setCandidateFeature(e,!0),onFilterChange:e=>this._filterText=e}))}EditorPanel(e,...t){const{active:s,handleBack:i,heading:a,headingLevel:r,key:o,messages:n,messagesCommon:l,showBackButton:d,showContentScrim:c,sketchViewModel:p,snappingControls:h}=e;return S("calcite-panel",{bind:this,key:o,heading:a,headingLevel:r,showBackButton:null==d||d,beforeBack:null!=i?i:null,onCalcitePanelScroll:this._onSnappingPopoverPanelScroll},S("calcite-popover-manager",{autoClose:s,class:P.panelToolbar},S("calcite-popover",{afterCreate:this._afterSnappingPopoverCreated,afterUpdate:this._afterSnappingPopoverUpdated,bind:this,label:n.snappingSettings,heading:n.snappingSettings,"reference-element":`${o}__snappingButton`,"overlay-positioning":"fixed"},S("div",{class:P.snappingControlsPopover},h.render())),S("calcite-button",{id:`${o}__snappingButton`,text:n.snapping,appearance:"transparent",color:"neutral",alignment:"icon-end-space-between","icon-start":"vertex-gps","icon-end":"caret-down",width:"full",class:P.panelToolbarSnappingButton},n.snapping),this.visibleElements.undoRedoButtons?[S("calcite-button",{key:"undo-button",text:l.undo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"undo",scale:"l",disabled:!p.canUndo(),onclick:p.undo.bind(p)}),S("calcite-button",{key:"redo-button",text:l.redo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"redo",scale:"l",disabled:!p.canRedo(),onclick:p.redo.bind(p)})]:null),S("div",{class:E(P.panelContent,P.scroller)},t,c?S("calcite-scrim",null):null))}_onSnappingPopoverPanelScroll(){var e;null!=(e=this._snappingPopover)&&e.open&&this._snappingPopover.toggle()}_afterSnappingPopoverCreated(e){this._snappingPopover=e}_afterSnappingPopoverUpdated(e){this._snappingPopover=e}_getSketchingTip(e,t){const{messages:s}=this;if("point"===e)return s.tips.clickToAddPoint;if("polygon"===e||"polyline"===e){if(!t)return s.tips.clickToStart;const i=t.geometry,a="polygon"===e?"rings":"paths",[r]=i[a];return"polygon"===e&&r<4?s.tips.clickToContinue:s.tips.clickToContinueThenDoubleClickToEnd}return s.tips.clickToAddFeature}_getLabel(e){const t=e.layer;if(!t)return null;const{objectIdField:s}=t,{attributes:i}=e,a=m(t);return a&&i[a]&&`${i[a]}`||B(this.messages.untitledFeatureTemplate,{id:i[s]})}_handleDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.viewModel.deleteFeatureFromWorkflow(),this._prompt=null}},secondary:{label:e.keepFeature,action:()=>this._prompt=null}}}}_handleSave(){const{featureFormViewModel:e}=this.viewModel;e.submit(),!e.submittable||e.validateContingencyConstraints(e.getValues(),{includeIncompleteViolations:!0}).length>0||this.viewModel.activeWorkflow.commit()}_handleAttachmentAdd(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.addAttachment().then((()=>t.previous()))}_handleAttachmentUpdate(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.updateAttachment().then((()=>t.previous()))}_handleAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.deleteAttachment(e.viewModel.activeAttachmentInfo).then((()=>{t.previous(),this._prompt=null}))}},secondary:{label:e.keepAttachment,action:()=>this._prompt=null}}}}_handleAdd(){this.viewModel.canCreate}_handleEdit(){this.viewModel.canUpdate&&this.viewModel.startUpdateWorkflowAtFeatureSelection()}_handleDone(){this.viewModel.cancelWorkflow({force:!0})}async _handleBack(){const{messages:e}=this,t=this.activeWorkflow,s=()=>{t.hasPreviousStep?t.previous({cancelCurrentStep:!0}):this.viewModel.cancelWorkflow({force:!0})};if("create"===t.type||"create-features"===t.type&&t.numPendingFeatures>0||"update"===t.type&&t.data.edits.modified){const{type:i}=t,a="create"===i?e.cancelAddWarningMessage:e.cancelEditWarningMessage,r="create"===i?e.cancelAddTitle:e.cancelEditTitle,o="create"===i?e.continueAdding:e.continueEditing,n="create"===i?e.discardFeature:e.discardEdits;throw this._prompt={title:r,message:a,context:"danger",actions:{primary:{label:n,action:()=>{s(),this._prompt=null}},secondary:{label:o,action:()=>this._prompt=null}}},this.scheduleRender(),new Error}s()}_assertActiveCreateWorkflow(){const{type:e}=this.viewModel.activeWorkflow;if("create"===e||"create-features"===e)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be instance of CreateWorkflow or CreateFeaturesWorkflow")}_assertActiveUpdateWorkflow(){if("update"===this.viewModel.activeWorkflow.type)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be an UpdateWorkflow")}};e([p()],x.prototype,"_attachments",void 0),e([d("viewModel.activeWorkflow")],x.prototype,"activeWorkflow",void 0),e([d("viewModel.allowedWorkflows")],x.prototype,"allowedWorkflows",void 0),e([p()],x.prototype,"useDeprecatedCreateWorkflow",void 0),e([p()],x.prototype,"headingLevel",void 0),e([p()],x.prototype,"iconClass",void 0),e([p({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],x.prototype,"label",void 0),e([d("viewModel.layerInfos")],x.prototype,"layerInfos",void 0),e([p(),W("esri/widgets/Editor/t9n/Editor")],x.prototype,"messages",void 0),e([p(),W("esri/t9n/common")],x.prototype,"messagesCommon",void 0),e([p(),W("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],x.prototype,"messagesTemplates",void 0),e([d("viewModel.snappingOptions")],x.prototype,"snappingOptions",void 0),e([p()],x.prototype,"supportingWidgetDefaults",void 0),e([d("viewModel.view")],x.prototype,"view",void 0),e([p(),T(["workflow-cancel","workflow-commit"])],x.prototype,"viewModel",void 0),e([p()],x.prototype,"visibleElements",void 0),e([c("visibleElements")],x.prototype,"castVisibleElements",null),e([F()],x.prototype,"_handleDelete",null),e([F()],x.prototype,"_handleAttachmentAdd",null),e([F()],x.prototype,"_handleAttachmentUpdate",null),e([F()],x.prototype,"_handleAttachmentDelete",null),e([F()],x.prototype,"_handleAdd",null),e([F()],x.prototype,"_handleEdit",null),e([F()],x.prototype,"_handleDone",null),x=e([h(U)],x);const D=x;export{D 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{featureHasFields as l}from"../../../layers/support/fieldUtils.js";import s from"../../../popup/support/FieldInfoFormat.js";import{loadArcade as f}from"../../../support/arcadeOnDemand.js";const c="esri.widgets.Feature.support.featureUtils",d=e.getLogger(c),p=/href=(""|'')/gi,m=/(\{([^\{\r\n]+)\})/g,y=/\'/g,g=/^\s*expression\//i,h=/(\n)/gi,b=/[\u00A0-\u9999<>\&]/gim,F=/href\s*=\s*(?:\"([^\"]+)\"|\'([^\']+)\')/gi,I=/^(?:mailto:|tel:)/,w="relationships/",N=o("short-date-short-time");function E(e){if(!t(e))return e.get("sourceLayer")||e.get("layer")}async function v(e,t){return"function"==typeof e?e.call(null,t):e}function j(e=""){if(e)return!I.test(e.trim().toLowerCase())}function T(e){return!!e&&g.test(e)}function x(e,t){if(!T(t)||!e)return null;const r=t.replace(g,"").toLowerCase();let n;return e.some((e=>e.name.toLowerCase()===r&&(n=e,!0))),n}function C(e,t){const r=x(t,null==e?void 0:e.fieldName);return r?r.title||null:e?e.label||e.fieldName:null}function q(e,t){const r=t.get(e.toLowerCase());return`{${r&&r.fieldName||e}}`}function D(e){return e.replace(p,"")}function R(e,t){const r=M(t,e);return r?r.name:e}function L(e,t){return e&&e.map((e=>R(e,t)))}function M(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?A({formattedAttributes:t,template:P(n,{...t,...i,...e},r),fieldInfoMap:o}):""}function A({formattedAttributes:e,template:t,fieldInfoMap:r}){return U(D(n(n(t,(e=>q(e,r))),e)))}function S(e,t,r=!1){const n=t[e];if("string"==typeof n){const i="%27",o=(r?encodeURIComponent(n):n).replace(y,i);t[e]=o}}function G(e,t=!1){const r={...e};return Object.keys(r).forEach((e=>S(e,r,t))),r}function k(e,t,r){const i=(t=U(t))&&"{"!==t[0];return n(e,G(r,i))}function O(e,t){return e.replace(m,((e,r,n)=>{const i=M(t,n);return i?`{${i.name}}`:r}))}function P(e,t,r){const n=O(e,r);return n?n.replace(F,((e,r,n)=>k(e,r||n,t))):n}function _(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 z(e){return"feature"===(null==e?void 0:e.type)}function H(e){return!(null==e||!e.layer)}function Q(e){return"map-image"===(null==e?void 0:e.type)}function Z(e,t){const r=t.fieldInfos,n=t.fieldName,i=B(r,n),o=null==i?void 0:i.clone(),l=t.preventPlacesFormatting,f=t.layer,c=M(f,n);if(o&&"date"===(null==c?void 0:c.type)){const e=o.format||new s;e.dateFormat=e.dateFormat||"short-date-short-time",e.dateTimeFormatOptions=!H(f)&&z(f)&&f.datesInUnknownTimezone||H(f)&&Q(f.layer)&&f.layer.datesInUnknownTimezone?{timeZone:"UTC"}:null,o.format=e}const d=o&&o.format;return"string"==typeof(e=_(e,d))||null==e||null==d?ee(e):l?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(ae(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(ae(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 V(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,N),user:e}}const l=t[n];if("number"==typeof l){const e=t[r];return{type:"create",date:i(l,N),user:e}}return null}function W(e,t){const r=new Map;return e&&e.forEach((e=>{const n=R(e.fieldName,t);e.fieldName=n,r.set(n.toLowerCase(),e)})),r}function X(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 Y(e){return e.replace(b,(e=>`&#${e.charCodeAt(0)};`))}function ee(e){return"string"==typeof e?e.replace(h,'<br class="esri-text-new-line" />'):e}function te(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 Z(t,{fieldInfos:n,fieldName:r,layer:a});const f=a&&a.fieldsIndex;return f&&f.isDateField(r)?i(t,N):ee(t)}function re({fieldInfos:e,attributes:t,layer:r,graphic:n,fieldInfoMap:i,relatedInfos:o}){const a={};return null==o||o.forEach((e=>se(a,e))),Object.keys(t).forEach((o=>{const u=t[o];a[o]=te({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:r,value:u,graphic:n})})),a}async function ne(e,t){var r,n;const{layer:i,graphic:o,outFields:a,objectIds:u,returnGeometry:l,spatialReference:s}=e,f=u[0];if("number"!=typeof f&&"string"!=typeof f){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:i,graphic:o,objectId:f,requiredFields:a};return d.warn(e,t),null}if(null==(r=i.capabilities)||null==(n=r.operations)||!n.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:i,graphic:o,requiredFields:a,returnGeometry:l};return d.warn(e,t),null}const c=i.createQuery();c.objectIds=u,c.outFields=null!=a&&a.length?a:[i.objectIdField],c.returnGeometry=!!l,c.returnZ=!!l,c.returnM=!!l,c.outSpatialReference=s;return(await i.queryFeatures(c,t)).features[0]}async function ie(e){var t;if(null==(t=e.expressionInfos)||!t.length)return!1;const r=await f(),{arcadeUtils:{hasGeometryFunctions:n}}=r;return n(e)}async function oe({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),s=l(u,e),f=s?[]:u,c=t.returnGeometry||await ie(t);if(s&&!c)return;const d=await ne({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 ae(e=""){return!!e&&e.includes(w)}function ue(e){return e?`${w}${e.layerId}/${e.fieldName}`:""}function le({attributes:e,graphic:t,relatedInfo:r}){e&&t&&r&&Object.keys(t.attributes).forEach((n=>{const i=ue({layerId:r.relation.id.toString(),fieldName:n});e[i]=t.attributes[n]}))}function se(e,t){e&&t&&(t.relatedFeatures&&t.relatedFeatures&&t.relatedFeatures.forEach((r=>le({attributes:e,graphic:r,relatedInfo:t}))),t.relatedStatsFeatures&&t.relatedStatsFeatures&&t.relatedStatsFeatures.forEach((r=>le({attributes:e,graphic:r,relatedInfo:t}))))}const fe=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},ce=({layer:e,method:t,query:n,definitionExpression:i})=>{var o,a;if(null==(o=e.capabilities)||null==(a=o.query)||!a.supportsCacheHint||"attachments"===t)return;const u=r(n.where)&&n.where,l=r(n.geometry)&&n.geometry;fe(i)||fe(u)||"extent"===(null==l?void 0:l.type)||"tile"===n.resultType||(n.cacheHint=!0)},de=({query:e,layer:t,method:r})=>{ce({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})},pe=({queryPayload:e,layer:t,method:r})=>{ce({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})};export{ee as applyTextFormattingHTML,W as createfieldInfoMap,O as fixTokens,re as formatAttributes,V as formatEditInfo,Z as formatValueToFieldInfo,X as getAllFieldInfos,B as getFieldInfo,C as getFieldInfoLabel,R as getFixedFieldName,L as getFixedFieldNames,E as getSourceLayer,v as graphicCallback,Y as htmlEntities,T as isExpressionField,ae as isRelatedField,de as preLayerQueryCallback,pe as preRequestCallback,oe as queryUpdatedFeature,j as shouldOpenInNewTab,A as substituteAttributes,$ 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 l}from"../../../intl/number.js";import{featureHasFields as u}from"../../../layers/support/fieldUtils.js";import s from"../../../popup/support/FieldInfoFormat.js";import{loadArcade as f}from"../../../support/arcadeOnDemand.js";const c="esri.widgets.Feature.support.featureUtils",d=e.getLogger(c),p=/href=(""|'')/gi,m=/(\{([^\{\r\n]+)\})/g,y=/\'/g,g=/^\s*expression\//i,h=/(\n)/gi,I=/[\u00A0-\u9999<>\&]/gim,b=/href\s*=\s*(?:\"([^\"]+)\"|\'([^\']+)\')/gi,F=/^(?:mailto:|tel:)/,w="relationships/",N=o("short-date-short-time");function E(e){if(!t(e))return e.get("sourceLayer")||e.get("layer")}async function v(e,t){return"function"==typeof e?e.call(null,t):e}function j(e=""){if(e)return!F.test(e.trim().toLowerCase())}function T(e){return!!e&&g.test(e)}function x(e,t){if(!T(t)||!e)return null;const r=t.replace(g,"").toLowerCase();let n;return e.some((e=>e.name.toLowerCase()===r&&(n=e,!0))),n}function C(e,t){const r=x(t,null==e?void 0:e.fieldName);return r?r.title||null:e?e.label||e.fieldName:null}function M(e,t){const r=t.get(e.toLowerCase());return`{${r&&r.fieldName||e}}`}function q(e){return e.replace(p,"")}function D(e,t){const r=L(t,e);return r?r.name:e}function R(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?A({formattedAttributes:t,template:P(n,{...t,...i,...e},r),fieldInfoMap:o}):""}function A({formattedAttributes:e,template:t,fieldInfoMap:r}){return U(q(n(n(t,(e=>M(e,r))),e)))}function S(e,t,r=!1){const n=t[e];if("string"==typeof n){const i="%27",o=(r?encodeURIComponent(n):n).replace(y,i);t[e]=o}}function G(e,t=!1){const r={...e};return Object.keys(r).forEach((e=>S(e,r,t))),r}function k(e,t,r){const i=(t=U(t))&&"{"!==t[0];return n(e,G(r,i))}function O(e,t){return e.replace(m,((e,r,n)=>{const i=L(t,n);return i?`{${i.name}}`:r}))}function P(e,t,r){const n=O(e,r);return n?n.replace(b,((e,r,n)=>k(e,r||n,t))):n}function _(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 z(e){return"feature"===(null==e?void 0:e.type)}function H(e){return!(null==e||!e.layer)}function Q(e){return"map-image"===(null==e?void 0:e.type)}function Z(e,t){const r=t.fieldInfos,n=t.fieldName,i=B(r,n),o=null==i?void 0:i.clone(),u=t.preventPlacesFormatting,f=t.layer,c=L(f,n);if(o&&"date"===(null==c?void 0:c.type)){const e=o.format||new s;e.dateFormat=e.dateFormat||"short-date-short-time",e.dateTimeFormatOptions=!H(f)&&z(f)&&f.datesInUnknownTimezone||H(f)&&Q(f.layer)&&f.layer.datesInUnknownTimezone?{timeZone:"UTC"}:null,o.format=e}const d=o&&o.format;return"string"==typeof(e=_(e,d))||null==e||null==d?ee(e):u?a(e,{...l(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(ae(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(ae(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 V(e,t){const{creatorField:r,creationDateField:n,editorField:o,editDateField:a}=e;if(!t)return;const l=t[a];if("number"==typeof l){const e=t[o];return{type:"edit",date:i(l,N),user:e}}const u=t[n];if("number"==typeof u){const e=t[r];return{type:"create",date:i(u,N),user:e}}return null}function W(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 X(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 Y(e){return e.replace(I,(e=>`&#${e.charCodeAt(0)};`))}function ee(e){return"string"==typeof e?e.replace(h,'<br class="esri-text-new-line" />'):e}function te(e){const{value:t,fieldName:r,fieldInfos:n,fieldInfoMap:o,layer:a,graphic:l}=e;if(null==t)return"";const u=K({fieldName:r,value:t,graphic:l,layer:a});if(u)return u;const s=J({fieldName:r,graphic:l,layer:a});if(s)return s;if(o.get(r.toLowerCase()))return Z(t,{fieldInfos:n,fieldName:r,layer:a});const f=a&&a.fieldsIndex;return f&&f.isDateField(r)?i(t,N):ee(t)}function re({fieldInfos:e,attributes:t,layer:r,graphic:n,fieldInfoMap:i,relatedInfos:o}){const a={};return null==o||o.forEach((t=>se({attributes:a,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:r}))),Object.keys(t).forEach((o=>{const l=t[o];a[o]=te({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:r,value:l,graphic:n})})),a}async function ne(e,t){var r,n;const{layer:i,graphic:o,outFields:a,objectIds:l,returnGeometry:u,spatialReference:s}=e,f=l[0];if("number"!=typeof f&&"string"!=typeof f){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:i,graphic:o,objectId:f,requiredFields:a};return d.warn(e,t),null}if(null==(r=i.capabilities)||null==(n=r.operations)||!n.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:i,graphic:o,requiredFields:a,returnGeometry:u};return d.warn(e,t),null}const c=i.createQuery();c.objectIds=l,c.outFields=null!=a&&a.length?a:[i.objectIdField],c.returnGeometry=!!u,c.returnZ=!!u,c.returnM=!!u,c.outSpatialReference=s;return(await i.queryFeatures(c,t)).features[0]}async function ie(e){var t;if(null==(t=e.expressionInfos)||!t.length)return!1;const r=await f(),{arcadeUtils:{hasGeometryFunctions:n}}=r;return n(e)}async function oe({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],l=await t.getRequiredFields(r.fieldsIndex),s=u(l,e),f=s?[]:l,c=t.returnGeometry||await ie(t);if(s&&!c)return;const d=await ne({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 ae(e=""){return!!e&&e.includes(w)}function le(e){return e?`${w}${e.layerId}/${e.fieldName}`:""}function ue({attributes:e,graphic:t,relatedInfo:r,fieldInfos:n,fieldInfoMap:i,layer:o}){e&&t&&r&&Object.keys(t.attributes).forEach((a=>{const l=le({layerId:r.relation.id.toString(),fieldName:a}),u=t.attributes[a];e[l]=te({fieldName:l,fieldInfos:n,fieldInfoMap:i,layer:o,value:u,graphic:t})}))}function se({attributes:e,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}){e&&t&&(t.relatedFeatures&&t.relatedFeatures&&t.relatedFeatures.forEach((o=>ue({attributes:e,graphic:o,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}))),t.relatedStatsFeatures&&t.relatedStatsFeatures&&t.relatedStatsFeatures.forEach((o=>ue({attributes:e,graphic:o,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}))))}const fe=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},ce=({layer:e,method:t,query:n,definitionExpression:i})=>{var o,a;if(null==(o=e.capabilities)||null==(a=o.query)||!a.supportsCacheHint||"attachments"===t)return;const l=r(n.where)&&n.where,u=r(n.geometry)&&n.geometry;fe(i)||fe(l)||"extent"===(null==u?void 0:u.type)||"tile"===n.resultType||(n.cacheHint=!0)},de=({query:e,layer:t,method:r})=>{ce({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})},pe=({queryPayload:e,layer:t,method:r})=>{ce({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})};export{ee as applyTextFormattingHTML,W as createfieldInfoMap,O as fixTokens,re as formatAttributes,V as formatEditInfo,Z as formatValueToFieldInfo,X as getAllFieldInfos,B as getFieldInfo,C as getFieldInfoLabel,D as getFixedFieldName,R as getFixedFieldNames,E as getSourceLayer,v as graphicCallback,Y as htmlEntities,T as isExpressionField,ae as isRelatedField,de as preLayerQueryCallback,pe as preRequestCallback,oe as queryUpdatedFeature,j as shouldOpenInNewTab,A as substituteAttributes,$ as substituteFieldsInLinksAndAttributes};