@arcgis/core 4.32.0-next.20250220 → 4.32.0

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 (112) hide show
  1. package/arcade/featureSetUtils.js +1 -1
  2. package/arcade/functions/featuresetbase.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/37323e58dbec303f5054.js +1 -0
  5. package/assets/esri/core/workers/chunks/{7b07410fe98015b80c74.js → 5341b86c2fb5347393c5.js} +1 -1
  6. package/assets/esri/core/workers/chunks/60d5cbfa9e1c6b3c98df.js +1 -0
  7. package/assets/esri/core/workers/chunks/{a5acbdb8347a809a26c0.js → 610c3249fe81e370af8c.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{d98c78e89d70ad0b8628.js → 6ab476f696290d190c6c.js} +1 -1
  9. package/assets/esri/core/workers/chunks/7292bb19b73f601d891b.js +1 -0
  10. package/assets/esri/core/workers/chunks/78c066e8fe167d4ab817.js +1 -0
  11. package/assets/esri/core/workers/chunks/80744ad7f7656ef918db.js +1 -0
  12. package/assets/esri/core/workers/chunks/8bbe8df40df2b8e54562.js +1 -0
  13. package/assets/esri/core/workers/chunks/caf410ed75c40b3703eb.js +1 -0
  14. package/assets/esri/core/workers/chunks/df506c4f81affce248c4.js +1 -0
  15. package/assets/esri/core/workers/chunks/{4be39bc2d2edd94bdb75.js → e481e7d508274bc83c70.js} +1 -1
  16. package/assets/esri/core/workers/chunks/eefa1dfeb63ce965bb40.js +1 -0
  17. package/assets/esri/core/workers/chunks/fd8790291348fb7ead55.js +1 -0
  18. package/assets/esri/themes/base/widgets/_ItemList.scss +14 -0
  19. package/assets/esri/themes/dark/main.css +1 -1
  20. package/assets/esri/themes/light/main.css +1 -1
  21. package/assets/esri/themes/light/view.css +1 -1
  22. package/config.js +1 -1
  23. package/core/sql/AggregateFunctions.js +1 -1
  24. package/core/sql/DateOnly.js +1 -1
  25. package/core/sql/SqlInterval.js +1 -1
  26. package/core/sql/SqlTimestampOffset.js +1 -1
  27. package/core/sql/TimeOnly.js +1 -1
  28. package/core/sql/WhereClause.js +1 -1
  29. package/core/sql/WhereGrammar.js +1 -1
  30. package/core/sql/sqlCompareUtils.js +1 -1
  31. package/core/sql/sqlDateParsingUtils.js +1 -1
  32. package/editing/sharedTemplates/SharedTemplate.js +1 -1
  33. package/editing/sharedTemplates/SharedTemplateMetadata.js +1 -1
  34. package/editing/sharedTemplates/SharedTemplateProvider.js +1 -1
  35. package/editing/sharedTemplates/executor/support/createServiceEdit.js +1 -1
  36. package/editing/sharedTemplates/support/sharedTemplateErrors.js +1 -1
  37. package/editing/sharedTemplates/templateDefinitions/FeatureTemplateDefinition.js +1 -1
  38. package/editing/sharedTemplates/templateDefinitions/GroupTemplateDefinition.js +1 -1
  39. package/editing/sharedTemplates/templateDefinitions/PresetTemplateDefinition.js +1 -1
  40. package/editing/sharedTemplates/templateDefinitions/TemplateDefinitionBase.js +1 -1
  41. package/editing/sharedTemplates/templateDefinitions/parts/FeatureTemplateRelationshipPart.js +1 -1
  42. package/editing/sharedTemplates/templateDefinitions/parts/GroupTemplatePart.js +1 -1
  43. package/editing/sharedTemplates/templateDefinitions/parts/TemplatePartBase.js +1 -1
  44. package/interfaces.d.ts +448 -63
  45. package/kernel.js +1 -1
  46. package/layers/RouteLayer.js +1 -1
  47. package/layers/orientedImagery/core/coverageUtils.js +1 -1
  48. package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
  49. package/layers/orientedImagery/transformations/rectifyMapPoint.js +1 -1
  50. package/layers/orientedImagery/transformations/utils.js +1 -1
  51. package/layers/orientedImagery/transformations/worldToImage.js +1 -1
  52. package/layers/support/Relationship.js +1 -1
  53. package/networks/RulesTable.js +1 -1
  54. package/package.json +1 -1
  55. package/rest/support/PointBarrier.js +1 -1
  56. package/support/revision.js +1 -1
  57. package/symbols/cim/fitVectorMarker.js +1 -1
  58. package/undoredo/support/Services.js +1 -1
  59. package/views/2d/AnimationManager.js +1 -1
  60. package/views/2d/layers/RouteLayerView2D.js +1 -1
  61. package/views/2d/layers/features/sources/FeatureCache.js +1 -1
  62. package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
  63. package/views/2d/layers/features/sources/strategies/support/snapshotUtils.js +5 -0
  64. package/views/2d/layers/features/support/whereUtils.js +1 -1
  65. package/views/View.js +1 -1
  66. package/views/animation/easing.js +1 -1
  67. package/widgets/Directions.js +1 -1
  68. package/widgets/Editor/AddAssociationWorkflow.js +1 -1
  69. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  70. package/widgets/Editor/CreateFeaturesWorkflowData.js +1 -1
  71. package/widgets/Editor/Edits.js +1 -1
  72. package/widgets/Editor/UpdateWorkflow.js +1 -1
  73. package/widgets/Editor/components/PendingFeatureList.js +1 -1
  74. package/widgets/Editor/workflowUtils.js +1 -1
  75. package/widgets/Editor.js +1 -1
  76. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/AssociationDetails.js +1 -1
  77. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
  78. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
  79. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js +1 -1
  80. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/VisibleElements.js +5 -0
  81. package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
  82. package/widgets/FeatureForm/UtilityNetworkAssociationInput.js +1 -1
  83. package/widgets/FeatureForm/VisibleElements.js +5 -0
  84. package/widgets/FeatureForm/featureFormUtils.js +1 -1
  85. package/widgets/FeatureForm.js +1 -1
  86. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  87. package/widgets/OrientedImageryViewer/adapters/sketch/DataCaptureAdapter.js +5 -0
  88. package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
  89. package/widgets/OrientedImageryViewer/components/ImageOverlays.js +1 -1
  90. package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
  91. package/widgets/OrientedImageryViewer/components/OverlayLayersListViewModel.js +1 -1
  92. package/widgets/OrientedImageryViewer/constants.js +1 -1
  93. package/widgets/OrientedImageryViewer/dataCaptureUtils.js +5 -0
  94. package/widgets/OrientedImageryViewer/symbols.js +1 -1
  95. package/widgets/OrientedImageryViewer.js +1 -1
  96. package/widgets/support/FilterCondition.js +1 -1
  97. package/widgets/support/GoTo.js +1 -1
  98. package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +1 -1
  99. package/widgets/support/goToUtils.js +1 -1
  100. package/widgets/support/symbolPreviewUtils.js +1 -1
  101. package/assets/esri/core/workers/chunks/10ca2107c99fab6bcc3b.js +0 -1
  102. package/assets/esri/core/workers/chunks/122ed10cac9f192e1eec.js +0 -1
  103. package/assets/esri/core/workers/chunks/1b3a52ce3e8e5be4d196.js +0 -1
  104. package/assets/esri/core/workers/chunks/35e4af82a08b4eadbfab.js +0 -1
  105. package/assets/esri/core/workers/chunks/6f007703662e714b2f0a.js +0 -1
  106. package/assets/esri/core/workers/chunks/8232a2c4bdc3011bb9e3.js +0 -1
  107. package/assets/esri/core/workers/chunks/8b8579d81728cb35bb29.js +0 -1
  108. package/assets/esri/core/workers/chunks/934857de20f6f5c15188.js +0 -1
  109. package/assets/esri/core/workers/chunks/b8fae500c69ca2cff62a.js +0 -1
  110. package/assets/esri/core/workers/chunks/ebe832bd57a316364ca1.js +0 -1
  111. package/widgets/OrientedImageryViewer/adapters/sketch/DigitizationAdapter.js +0 -5
  112. package/widgets/OrientedImageryViewer/digitizationUtils.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../../core/has.js";import{debounce as t}from"../../../../../core/promiseUtils.js";import{FeatureSnapshotSourceChunk as e}from"./strategies/chunks/FeatureSnapshotSourceChunk.js";class s{constructor(s,h,i,o){this.store=s,this.queryInfo=h,this._options=i,this._fetch=o,this._nextBatch=new Set,this._fetchFeatures=t((async()=>{if(0===this._nextBatch.size||this._options.signal?.aborted)return;const t=Array.from(this._nextBatch);this._nextBatch.clear();try{const s=this.queryInfo.createQuery({objectIds:t,outFields:["*"],cacheHint:!0}),h="cache."+t.join(","),i=await this._fetch(s,this._options,{chunkId:h}),o=new e(i,s.inner.toJSON(),0,!1);o.chunkId=h,this.store.insert(o)}catch(s){}}))}prepareCacheUpdate(t,e){if(e)for(const s of e)this._nextBatch.delete(s);for(const s of t)this._nextBatch.add(s)}applyCacheUpdate(){return 0===this._nextBatch.size||this._options.signal?.aborted?null:this._fetchFeatures().catch((()=>{}))}}export{s as FeatureCache};
5
+ import t from"../../../../../core/Error.js";import"../../../../../core/has.js";import e from"../../../../../core/Logger.js";import{debounce as r}from"../../../../../core/promiseUtils.js";import{generateUUID as s}from"../../../../../core/uuid.js";import{fetchPages as i}from"./strategies/support/snapshotUtils.js";const o=8e3;class h{constructor(h,a,c,n){this.store=h,this.queryInfo=a,this._options=c,this._fetch=n,this._nextBatch=new Set,this._fetchFeatures=r((async()=>{if(0===this._nextBatch.size||this._options.signal?.aborted)return;const r=Array.from(this._nextBatch);this._nextBatch.clear(),r.length>o&&e.getLogger("esri.views.2d.layers.FeatureLayerView2D").warn(new t("highlight-too-many-features",`highlight is limited to ${o} features on large layers configured with a display filter to avoid performance issues`));const h=this.queryInfo.objectIdsQueryPageSize,a=Math.ceil(o/h),c=Math.min(a,Math.ceil(r.length/h)),n=Array.from({length:c},((t,e)=>{const s=e*h,i=Math.min(s+h,r.length);return{num:e,query:this.queryInfo.createObjectIdsQuery(r.slice(s,i))}}));try{await i({chunkPrefix:"cache."+s(),fetch:this._fetch},this.store,n,this._options)}catch(f){}}))}prepareCacheUpdate(t,e){if(e)for(const r of e)this._nextBatch.delete(r);for(const r of t)this._nextBatch.add(r)}applyCacheUpdate(){return 0===this._nextBatch.size||this._options.signal?.aborted?null:this._fetchFeatures().catch((()=>{}))}}export{h as FeatureCache};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../../core/has.js";import{sqlAnd as e}from"../../../../../core/sql.js";import t from"../../../../../geometry/SpatialReference.js";import{isHostedAgolService as r}from"../../../../../layers/support/arcgisLayerUrl.js";import{getClauseForScaleRange as a}from"../../../../../layers/support/displayFilterUtils.js";import i from"../../../../../rest/support/Query.js";import s from"../../../../../time/TimeExtent.js";const o=4;function n(e,a,i){const o=e.orderByFields??i.objectIdField+" ASC",n=e.source,l={returnCentroid:!(null!==n&&"object"==typeof n&&"path"in n&&r(n.path))&&"esriGeometryPolygon"===i.serviceGeometryType,returnGeometry:!0,timeReferenceUnknownClient:i.timeReferenceUnknownClient??void 0,outSpatialReference:t.fromJSON(e.outSpatialReference),orderByFields:"memory"===e.type?[]:[o],where:a.mutable.dataFilter.definitionExpression??"1=1",outFields:a.mutable.availableFields,multipatchOption:"esriGeometryMultiPatch"===i.serviceGeometryType?"xyFootprint":null};if("feature"===a.type){const{gdbVersion:e,historicMoment:t,timeExtent:r}=a.mutable.dataFilter;return{...l,gdbVersion:e,historicMoment:t?new Date(t):null,timeExtent:r?s.fromJSON(r):null,outFields:a.mutable.availableFields}}return l}class l{static fromSchema(e,t,r){const a="feature"===t.type?t.mutable.dataFilter.queryScaleRanges:[],i=t.mutable.displayFilterInfo;return new l(n(e,t,r),i,a,r.subtypeField,t.mutable.dataFilter.customParameters,r.geometryType,e.queryMetadata)}constructor(e,t,r,a,i,s,o){this._queryParams=e,this._displayFilter=t,this._queryScaleRanges=r,this._subtypeField=a,this._customParameters=i,this._geometryType=s,this._queryMetadata=o}get pageSize(){if(null==this._queryMetadata)throw new Error("InternalError: Service does not support paged queries");const e=this._queryMetadata.supportsMaxRecordCountFactor?o:null,t=(this._queryMetadata.maxRecordCount??8e3)*(e??1);return Math.min(8e3,t)}updateHistoricMoment(e){this._queryParams.historicMoment=e}updateFields(e){this._queryParams.outFields=e}createPatchFieldsQuery(e,t,r){if(!t.getSize())return null;const a=e.clone();if("*"===this._queryParams.outFields[0]){if("*"===(a.outFields??[])[0])return null;a.outFields=this._queryParams.outFields}else{const e=new Set(this._queryParams.outFields),r=[];for(const a of e)t.hasField(a)||r.push(a);if(0===r.length)return null;a.outFields=r}a.returnGeometry=!1,a.returnCentroid=!1,a.quantizationParameters=null,a.cacheHint=!0;const i={inner:a,customParameters:this._customParameters};if(has("esri-tiles-debug")&&null!=r){const e=r.chunkId.toString().replaceAll("/",".");i.customParameters=i.customParameters?{...i.customParameters,chunkId:e}:{chunkId:e}}return i}createQuery(e={}){if(!this._queryParams)throw new Error("InternalError: queryInfo should be defined");return{inner:new i({...this._queryParams,...e}),customParameters:this._customParameters}}createTileQuery(t,r){if(null==this._queryMetadata)throw new Error("InternalError: Service does not support tile queries");const i=this.createQuery(r),s=i.inner;if(this._queryScaleRanges.length){const r=this._queryScaleRanges.filter((e=>(!e.minScale||e.minScale>=t.maxScale)&&(!e.maxScale||e.maxScale<=t.minScale))).map((e=>e.subtypeCode));if(r.length){const t=`${this._subtypeField} IN (${r})`;s.where=e(s.where,t)}}if(this._displayFilter&&(s.where=e(s.where,a(this._displayFilter,t.minScale,t.maxScale))),s.quantizationParameters=r.quantizationParameters??t.getQuantizationParameters(),s.resultType="tile",s.geometry=t.extent,this._queryMetadata.supportsQuantization?"esriGeometryPolyline"===this._geometryType&&(s.maxAllowableOffset=t.resolution*has("feature-polyline-generalization-factor")):"esriGeometryPolyline"!==this._geometryType&&"esriGeometryPolygon"!==this._geometryType||(s.maxAllowableOffset=t.resolution,"esriGeometryPolyline"===this._geometryType&&(s.maxAllowableOffset*=has("feature-polyline-generalization-factor"))),s.defaultSpatialReferenceEnabled=this._queryMetadata.supportsDefaultSpatialReference,s.compactGeometryEnabled=this._queryMetadata.supportsCompactGeometry,this._queryMetadata.supportsMaxRecordCountFactor&&(s.maxRecordCountFactor=o),has("esri-tiles-debug")){const e=t.id.replaceAll("/",".");i.customParameters=i.customParameters?{...i.customParameters,tileId:e}:{tileId:e}}return i}createPagedTileQuery(e,t){const r=this.pageSize;return this.createTileQuery(e,{start:r*t,num:r,returnExceededLimitFeatures:!0})}createPagedQuery(e){const t=this.pageSize;return this.createQuery({start:t*e,num:t,returnExceededLimitFeatures:!0,maxRecordCountFactor:o,cacheHint:!0})}}export{l as FeatureSourceQueryInfo};
5
+ import has from"../../../../../core/has.js";import{sqlAnd as e}from"../../../../../core/sql.js";import t from"../../../../../geometry/SpatialReference.js";import{isHostedAgolService as r}from"../../../../../layers/support/arcgisLayerUrl.js";import{getClauseForScaleRange as a}from"../../../../../layers/support/displayFilterUtils.js";import i from"../../../../../rest/support/Query.js";import s from"../../../../../time/TimeExtent.js";const o=4;function n(e,a,i){const o=e.orderByFields??i.objectIdField+" ASC",n=e.source,u={returnCentroid:!(null!==n&&"object"==typeof n&&"path"in n&&r(n.path))&&"esriGeometryPolygon"===i.serviceGeometryType,returnGeometry:!0,timeReferenceUnknownClient:i.timeReferenceUnknownClient??void 0,outSpatialReference:t.fromJSON(e.outSpatialReference),orderByFields:"memory"===e.type?[]:[o],where:a.mutable.dataFilter.definitionExpression??"1=1",outFields:a.mutable.availableFields,multipatchOption:"esriGeometryMultiPatch"===i.serviceGeometryType?"xyFootprint":null};if("feature"===a.type){const{gdbVersion:e,historicMoment:t,timeExtent:r}=a.mutable.dataFilter;return{...u,gdbVersion:e,historicMoment:t?new Date(t):null,timeExtent:r?s.fromJSON(r):null,outFields:a.mutable.availableFields}}return u}class u{static fromSchema(e,t,r){const a="feature"===t.type?t.mutable.dataFilter.queryScaleRanges:[],i=t.mutable.displayFilterInfo;return new u(n(e,t,r),i,a,r.subtypeField,t.mutable.dataFilter.customParameters,r.geometryType,e.queryMetadata)}constructor(e,t,r,a,i,s,o){this._queryParams=e,this._displayFilter=t,this._queryScaleRanges=r,this._subtypeField=a,this._customParameters=i,this._geometryType=s,this._queryMetadata=o}get pageSize(){if(null==this._queryMetadata)throw new Error("InternalError: Service does not support paged queries");const e=this._queryMetadata.supportsMaxRecordCountFactor?o:null,t=(this._queryMetadata.maxRecordCount??8e3)*(e??1);return Math.min(8e3,t)}get objectIdsQueryPageSize(){return this._queryMetadata?.maxRecordCount??2e3}updateHistoricMoment(e){this._queryParams.historicMoment=e}updateFields(e){this._queryParams.outFields=e}createPatchFieldsQuery(e,t,r){if(!t.getSize())return null;const a=e.clone();if("*"===this._queryParams.outFields[0]){if("*"===(a.outFields??[])[0])return null;a.outFields=this._queryParams.outFields}else{const e=new Set(this._queryParams.outFields),r=[];for(const a of e)t.hasField(a)||r.push(a);if(0===r.length)return null;a.outFields=r}a.returnGeometry=!1,a.returnCentroid=!1,a.quantizationParameters=null,a.cacheHint=!0;const i={inner:a,customParameters:this._customParameters};if(has("esri-tiles-debug")&&null!=r){const e=r.chunkId.toString().replaceAll("/",".");i.customParameters=i.customParameters?{...i.customParameters,chunkId:e}:{chunkId:e}}return i}createQuery(e={}){if(!this._queryParams)throw new Error("InternalError: queryInfo should be defined");return{inner:new i({...this._queryParams,...e}),customParameters:this._customParameters}}createTileQuery(t,r){if(null==this._queryMetadata)throw new Error("InternalError: Service does not support tile queries");const i=this.createQuery(r),s=i.inner;if(this._queryScaleRanges.length){const r=this._queryScaleRanges.filter((e=>(!e.minScale||e.minScale>=t.maxScale)&&(!e.maxScale||e.maxScale<=t.minScale))).map((e=>e.subtypeCode));if(r.length){const t=`${this._subtypeField} IN (${r})`;s.where=e(s.where,t)}}if(this._displayFilter&&(s.where=e(s.where,a(this._displayFilter,t.minScale,t.maxScale))),s.quantizationParameters=r.quantizationParameters??t.getQuantizationParameters(),s.resultType="tile",s.geometry=t.extent,this._queryMetadata.supportsQuantization?"esriGeometryPolyline"===this._geometryType&&(s.maxAllowableOffset=t.resolution*has("feature-polyline-generalization-factor")):"esriGeometryPolyline"!==this._geometryType&&"esriGeometryPolygon"!==this._geometryType||(s.maxAllowableOffset=t.resolution,"esriGeometryPolyline"===this._geometryType&&(s.maxAllowableOffset*=has("feature-polyline-generalization-factor"))),s.defaultSpatialReferenceEnabled=this._queryMetadata.supportsDefaultSpatialReference,s.compactGeometryEnabled=this._queryMetadata.supportsCompactGeometry,this._queryMetadata.supportsMaxRecordCountFactor&&(s.maxRecordCountFactor=o),has("esri-tiles-debug")){const e=t.id.replaceAll("/",".");i.customParameters=i.customParameters?{...i.customParameters,tileId:e}:{tileId:e}}return i}createPagedTileQuery(e,t){const r=this.pageSize;return this.createTileQuery(e,{start:r*t,num:r,returnExceededLimitFeatures:!0})}createPagedQuery(e){const t=this.pageSize;return this.createQuery({start:t*e,num:t,returnExceededLimitFeatures:!0,maxRecordCountFactor:o,cacheHint:!0})}createObjectIdsQuery(e){return this.createQuery({objectIds:e,outFields:["*"]})}}export{u as FeatureSourceQueryInfo};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
+ */
5
+ import r from"../../../../../../../core/Error.js";import{throwIfAborted as e}from"../../../../../../../core/promiseUtils.js";import{FeatureSnapshotSourceChunk as n}from"../chunks/FeatureSnapshotSourceChunk.js";async function o(e,n,o,a={}){const s=(await Promise.allSettled(o.map((r=>t(e,n,r,a))))).filter((r=>"rejected"===r.status)).map((r=>r.reason));if(s.length)throw new r("featurelayer-query","Encountered errors when downloading data",{errors:s})}async function t(r,o,t,a={}){const s=`${r.chunkPrefix??""}${t.num}`,u=await r.fetch(t.query,a,{chunkId:s}),i=new n(u,t.query.inner.toJSON(),t.num,!1);i.chunkId=i.normalizedChunkId=s,e(a),o.insert(i)}export{o as fetchPages};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../core/Error.js";import r from"../../../../../core/Logger.js";import{parseWhereClause as t}from"../../../../../core/sql.js";const a=()=>r.getLogger("esri.views.2d.layers.features.support.whereUtils"),n={getAttribute:(e,r)=>e.readAttribute(r)};async function s(r,s){try{const o=await t(r,s);if(!o.isStandardized){const r=new e("mapview - bad input","Unable to apply filter's definition expression, as expression is not standardized.",o);a().error(r)}return(e,t)=>{const s=e.readArcadeFeature();try{return o.testFeature(s,n,t.currentUser)}catch(i){return a().warn("mapview-bad-where-clause","Encountered an error when evaluating where clause",r),!0}}}catch(o){return a().warn("mapview-bad-where-clause","Encountered an error when evaluating where clause",r),e=>!0}}export{s as createWhereClause};
5
+ import r from"../../../../../core/Error.js";import e from"../../../../../core/Logger.js";import{parseWhereClause as t}from"../../../../../core/sql.js";const n=()=>e.getLogger("esri.views.2d.layers.FeatureLayerView2D"),o={getAttribute:(r,e)=>r.readAttribute(e)};async function a(e,a){try{const s=await t(e,a);return s.isStandardized||n().error(new r("sql-parse-error","expression is not standardized",{where:e})),(t,a)=>{const i=t.readArcadeFeature();try{return s.testFeatureCompiled(i,o,a.currentUser)}catch(u){return n().warn(new r("sql-runtime-error","Encountered an error when evaluating where clause",{where:e,error:u})),!0}}}catch(s){return n().warn(new r("sql-runtime-error","Encountered an error when evaluating where clause",{where:e,error:s})),r=>!0}}export{a as createWhereClause};
package/views/View.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.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../Map.js";import i from"../core/Accessor.js";import{createTask as r}from"../core/asyncUtils.js";import a from"../core/Collection.js";import s from"../core/CollectionFlattener.js";import o from"../core/Error.js";import n from"../core/Evented.js";import l from"../core/Handles.js";import has from"../core/has.js";import p from"../core/Loadable.js";import d from"../core/Logger.js";import{destroyMaybe as h,abortMaybe as y}from"../core/maybe.js";import u from"../core/Promise.js";import{after as m}from"../core/promiseUtils.js";import{watch as c,whenOnce as g,when as f,sync as w,syncAndInitial as v}from"../core/reactiveUtils.js";import{property as M}from"../core/accessorSupport/decorators/property.js";import"../core/RandomLCG.js";import{subclass as _}from"../core/accessorSupport/decorators/subclass.js";import{owningCollectionProperty as V}from"../core/support/OwningCollection.js";import{UpdatingHandles as R}from"../core/support/UpdatingHandles.js";import S from"../geometry/Extent.js";import j from"../geometry/HeightModelInfo.js";import T from"../geometry/SpatialReference.js";import{equals as E}from"../geometry/support/spatialReferenceUtils.js";import{AnalysesCollection as F}from"../support/AnalysesCollection.js";import{GraphicsCollection as k}from"../support/GraphicsCollection.js";import x from"../time/TimeExtent.js";import{system as b,isTimeZoneValid as O}from"../time/timeZoneUtils.js";import L from"./BasemapView.js";import C from"./LayerViewManager.js";import Z from"./Magnifier.js";import I from"./SelectionManager.js";import H from"./Theme.js";import{ToolViewManager as W}from"./ToolViewManager.js";import{makeDefaultHighlightOptions as D}from"./3d/support/DefaultHighlights.js";import q from"./input/Input.js";import{ViewEvents as P}from"./input/ViewEvents.js";import A from"./navigation/Navigation.js";import{DefaultsFromMap as U}from"./support/DefaultsFromMap.js";import z from"./support/HighlightOptions.js";import G from"./support/RequiredFieldsOptions.js";var N;let $=N=class extends(n.EventedMixin(u.EsriPromiseMixin(i))){constructor(e){super(e),this._userSpatialReference=null,this._cursor=null,this.handles=new l,this.updatingHandles=new R,this.highlights=D(),this.allLayerViews=new s({getCollections:()=>[this.basemapView?.baseLayerViews,this.groundView?.layerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:K}),this.groundView=null,this.basemapView=null,this.displayFilterEnabled=!0,this.fatalError=null,this.graphics=new k,this.analyses=new F,this.typeSpecificPreconditionsReady=!0,this.layerViews=new a,this.magnifier=new Z,this.padding={left:0,top:0,right:0,bottom:0},this.ready=!1,this._readyStateWaitingTask=null,this.supportsGround=!0,this.type=null,this.scale=null,this.updating=!1,this.initialExtentRequired=!0,this.input=new q,this.navigation=new A,this.layerViewManager=null,this.analysisViewManager=null,this.isHeightModelInfoRequired=!1,this.width=null,this.height=null,this.resizing=!1,this.suspended=!1,this.viewEvents=new P(this),this.persistableViewModels=new a,this.requiredFieldsOptions=new G,this._isValid=!1,this._readyCycleForced=!1,this._lockedSpatialReference=null,this._userTimeZone=null,this._lockedTimeZone=null,this._userTimeExtent=null,this._lockedTimeExtent=null,this.theme=null,this.handles.add(c((()=>this.preconditionsReady),(e=>{const t=this.ready;if(e?(this._lockedSpatialReference=this.spatialReference,this._lockedTimeZone=this.timeZone,this._lockedTimeExtent=this.timeExtent,N.views.add(this)):(this._lockedSpatialReference=null,N.views.remove(this)),this.notifyChange("spatialReference"),!e&&t)this.toolViewManager?.detach(),null!=this.analysisViewManager&&this.analysisViewManager.detach(),this.layerViewManager?.clear(),this._teardown();else if(e&&!t){try{this._startup()}catch(i){return void queueMicrotask((()=>{this.fatalError=new o("startup-error",null,i)}))}null!=this.analysisViewManager&&this.analysisViewManager.attach(),this.toolViewManager.attach()}}),w))}initialize(){this.addResolvingPromise(Promise.all([this.loadAsyncDependencies(),this.validate()]).then((()=>(this._isValid=!0,g((()=>this.ready)))))),this.basemapView=new L({view:this}),this.layerViewManager=new C({view:this,layerViewImporter:{importLayerView:e=>this.importLayerView(e),hasLayerViewModule:e=>this.hasLayerViewModule(e)},supportsGround:this.supportsGround}),this.toolViewManager=new W({view:this}),this.selectionManager=new I({view:this}),this.addHandles([f((()=>"map-content-error"===this.readyState&&!this.spatialReference),(()=>{d.getLogger(this).warn("#spatialReference","no spatial reference could be derived from the currently added map layers")})),c((()=>this.initialExtentRequired),(e=>this.defaultsFromMap.required={...this.defaultsFromMap.required,extent:e}),v),c((()=>this.ready),(e=>{this.defaultsFromMap&&(this.defaultsFromMap.suspended=e,this.defaultsFromMap.userSpatialReference=e?this.spatialReference:this._userSpatialReference)}),w),c((()=>this._userSpatialReference),(e=>{this.defaultsFromMap&&(this.defaultsFromMap.userSpatialReference=e)}),v)])}destroy(){this.destroyed||(N.views.remove(this),this.viewEvents.destroy(),this.allLayerViews.destroy(),this.navigation&&(this.navigation.destroy(),this._set("navigation",null)),this.graphics=h(this.graphics),this.analyses=h(this.analyses),this.defaultsFromMap.destroy(),this._set("defaultsFromMap",null),h(this.analysisViewManager),this.toolViewManager=h(this.toolViewManager),this.layerViewManager=h(this.layerViewManager),this.selectionManager=h(this.selectionManager),this.basemapView=h(this.basemapView),this.groundView?.destroy(),this.layerViews?.forEach((e=>e.destroy())),this.layerViews.length=0,this.invalidate(),this._emitter.clear(),this.handles.destroy(),this.map=h(this.map),this.updatingHandles.destroy())}_startup(){this._set("ready",!0)}_teardown(){this._set("ready",!1)}whenReady(){return Promise.resolve(this)}toMap(){return d.getLogger(this).error("#toMap()","Not implemented on this instance of View"),null}get activeTool(){return this.toolViewManager?.activeTool}set activeTool(e){this.toolViewManager&&(this.toolViewManager.activeTool=e)}get animation(){return this._get("animation")}set animation(e){this._set("animation",e)}get center(){return null}get defaultsFromMapSettings(){return{}}get defaultsFromMap(){return new U({required:{tileInfo:!1,heightModelInfo:!1,extent:!1},map:()=>this.map,getSpatialReferenceSupport:(e,t)=>this.getSpatialReferenceSupport(e,t),...this.defaultsFromMapSettings})}get extent(){return this._get("extent")}set extent(e){this._set("extent",e)}get heightModelInfo(){return this.getDefaultHeightModelInfo()}get interacting(){return this.navigating}get navigating(){return!1}get preconditionsReady(){return!(this.fatalError||!this._isValid||this._readyCycleForced||!this.map||p.isLoadable(this.map)&&!this.map.loaded||0===this.width||0===this.height||!this.spatialReference||!this._validateSpatialReference(this.spatialReference)||!this._lockedSpatialReference&&!this.defaultsFromMap?.ready||!this.typeSpecificPreconditionsReady)}get resolution(){return 0}set map(e){e!==this._get("map")&&(e?.destroyed&&(d.getLogger(this).warn("#map","The provided map is already destroyed",{map:e}),e=null),p.isLoadable(e)&&e.load().catch((()=>{})),this.constructed&&!this.destroyed&&(this.forceReadyCycle(),this._lockedSpatialReference=null),this._set("map",e))}get readyState(){if(this.destroyed)return this._get("readyState");if(!this.map)return"missing-map";if("container"in this&&!this.container)return"missing-container";if(this.fatalError)return"rendering-error";if((this.defaultsFromMap?.ready??!1)&&!this.spatialReference){const e=!("loaded"in this.map)||this.map.loaded,t=this.map.ground.loaded,i=this.map.basemap?.loaded??!0;return e&&i&&t&&!this.map?.allLayers.length?"empty-map":(this._readyStateWaitingTask||(this._readyStateWaitingTask=r((e=>m(has("view-readyState-waiting-delay"),null,e))),this.addHandles(this._readyStateWaitingTask),this.addHandles(this._readyStateWaitingTask,"ready-state-task")),this._readyStateWaitingTask?.finished?"map-content-error":"loading")}return this._readyStateWaitingTask=y(this._readyStateWaitingTask),this.removeHandles("ready-state-task"),this.ready?"ready":"loading"}get spatialReference(){const e=this._userSpatialReference||this._lockedSpatialReference||this.getDefaultSpatialReference()||null;if(e&&this.defaultsFromMap?.required?.heightModelInfo){const t=e.clone();return t.vcsWkid=this.defaultsFromMap.vcsWkid,t.latestVcsWkid=this.defaultsFromMap.latestVcsWkid,t}return e}set spatialReference(e){const t=!E(e,this._get("spatialReference"));this._set("_userSpatialReference",e),t&&(this._set("spatialReference",e),this._spatialReferenceChanged(e))}_spatialReferenceChanged(e){}get stationary(){return!this.animation&&!this.navigating&&!this.resizing}get timeExtent(){return this._userTimeExtent??this._lockedTimeExtent??this.getDefaultTimeExtent()??null}set timeExtent(e){this._userTimeExtent=e}get timeZone(){return this._userTimeZone??this._lockedTimeZone??this.getDefaultTimeZone()??b}set timeZone(e){this._userTimeZone=e,O(e)||d.getLogger(this).warn("#timeZone",`the parsed value '${e}' may not be a valid IANA time zone`)}get tools(){return this.toolViewManager?.tools}get initialExtent(){return this.defaultsFromMap?.extent}get cursor(){return this.toolViewManager?.cursor??this._cursor??"default"}set cursor(e){this._cursor=e,this.notifyChange("cursor")}get size(){return[this.width,this.height]}get effectiveTheme(){return this.theme??new H}whenLayerView(e){return this.layerViewManager?.whenLayerView(e)??Promise.reject()}getDefaultSpatialReference(){return this.defaultsFromMap?.spatialReference}getDefaultHeightModelInfo(){return(this.map&&"heightModelInfo"in this.map?this.map.heightModelInfo:void 0)??this.defaultsFromMap?.heightModelInfo??null}getDefaultTimeZone(){return null}getDefaultTimeExtent(){return null}importLayerView(e){throw new o("importLayerView() not implemented")}hasLayerViewModule(e){return!1}async validate(){}async loadAsyncDependencies(){}invalidate(){this._isValid=!1}getSpatialReferenceSupport(){return{constraints:null}}_validateSpatialReference(e){return null!=this.getSpatialReferenceSupport(e)}when(e,t){return this.isResolved()&&!this.ready&&d.getLogger(this).warn("#when()","Calling view.when() while the view is no longer ready but was already resolved once will resolve immediately. Use reactiveUtils.whenOnce(() => view.ready).then(...) instead."),super.when(e,t)}forceReadyCycle(){this.ready&&(f((()=>this.destroyed||!1===this.preconditionsReady),(()=>this._readyCycleForced=!1),{once:!0}),this._readyCycleForced=!0)}addAndActivateTool(e){this.toolViewManager.tools.add(e),this.activeTool=e}tryFatalErrorRecovery(){this.fatalError=null}};$.views=new a,e([M()],$.prototype,"_userSpatialReference",void 0),e([M({type:a.ofType(z)})],$.prototype,"highlights",void 0),e([M()],$.prototype,"activeTool",null),e([M({readOnly:!0})],$.prototype,"allLayerViews",void 0),e([M()],$.prototype,"groundView",void 0),e([M()],$.prototype,"animation",null),e([M()],$.prototype,"basemapView",void 0),e([M()],$.prototype,"center",null),e([M()],$.prototype,"defaultsFromMapSettings",null),e([M()],$.prototype,"defaultsFromMap",null),e([M()],$.prototype,"displayFilterEnabled",void 0),e([M()],$.prototype,"fatalError",void 0),e([M({type:S})],$.prototype,"extent",null),e([M(V(k,"graphics"))],$.prototype,"graphics",void 0),e([M(V(F,"analyses"))],$.prototype,"analyses",void 0),e([M({readOnly:!0,type:j})],$.prototype,"heightModelInfo",null),e([M({readOnly:!0})],$.prototype,"interacting",null),e([M({readOnly:!0})],$.prototype,"navigating",null),e([M({readOnly:!0,dependsOn:["fatalError","_isValid","_readyCycleForced","map","map.loaded?","width","height","spatialReference","_lockedSpatialReference","defaultsFromMap.ready","typeSpecificPreconditionsReady"]})],$.prototype,"preconditionsReady",null),e([M({readOnly:!0})],$.prototype,"typeSpecificPreconditionsReady",void 0),e([M({type:a,readOnly:!0})],$.prototype,"layerViews",void 0),e([M()],$.prototype,"resolution",null),e([M({type:Z})],$.prototype,"magnifier",void 0),e([M({value:null,type:t})],$.prototype,"map",null),e([M()],$.prototype,"padding",void 0),e([M({readOnly:!0})],$.prototype,"ready",void 0),e([M()],$.prototype,"_readyStateWaitingTask",void 0),e([M({readOnly:!0})],$.prototype,"readyState",null),e([M({type:T})],$.prototype,"spatialReference",null),e([M()],$.prototype,"stationary",null),e([M({readOnly:!0})],$.prototype,"supportsGround",void 0),e([M({type:x})],$.prototype,"timeExtent",null),e([M({type:String,nonNullable:!0})],$.prototype,"timeZone",null),e([M()],$.prototype,"tools",null),e([M()],$.prototype,"toolViewManager",void 0),e([M({readOnly:!0})],$.prototype,"type",void 0),e([M({type:Number})],$.prototype,"scale",void 0),e([M({readOnly:!0})],$.prototype,"updating",void 0),e([M({readOnly:!0})],$.prototype,"initialExtentRequired",void 0),e([M({readOnly:!0})],$.prototype,"initialExtent",null),e([M()],$.prototype,"cursor",null),e([M({readOnly:!0})],$.prototype,"input",void 0),e([M({type:A,nonNullable:!0})],$.prototype,"navigation",void 0),e([M()],$.prototype,"layerViewManager",void 0),e([M()],$.prototype,"analysisViewManager",void 0),e([M()],$.prototype,"selectionManager",void 0),e([M()],$.prototype,"width",void 0),e([M()],$.prototype,"height",void 0),e([M({readOnly:!0})],$.prototype,"resizing",void 0),e([M({value:null,readOnly:!0})],$.prototype,"size",null),e([M({readOnly:!0})],$.prototype,"suspended",void 0),e([M({readOnly:!0})],$.prototype,"viewEvents",void 0),e([M({readOnly:!0})],$.prototype,"persistableViewModels",void 0),e([M()],$.prototype,"_isValid",void 0),e([M()],$.prototype,"_readyCycleForced",void 0),e([M()],$.prototype,"_lockedSpatialReference",void 0),e([M()],$.prototype,"_userTimeZone",void 0),e([M()],$.prototype,"_lockedTimeZone",void 0),e([M()],$.prototype,"_userTimeExtent",void 0),e([M()],$.prototype,"_lockedTimeExtent",void 0),e([M({type:H})],$.prototype,"theme",void 0),e([M({readOnly:!0,type:H})],$.prototype,"effectiveTheme",null),$=N=e([_("esri.views.View")],$);const B=globalThis.$arcgis;B&&!B.views&&Object.defineProperty(B,"views",{configurable:!1,enumerable:!0,writable:!1,value:$.views});const J=$;function K(e){return e.layerViews}export{J as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../Map.js";import i from"../core/Accessor.js";import{createTask as r}from"../core/asyncUtils.js";import a from"../core/Collection.js";import s from"../core/CollectionFlattener.js";import{referenceSetter as o}from"../core/collectionUtils.js";import n from"../core/Error.js";import l from"../core/Evented.js";import p from"../core/Handles.js";import has from"../core/has.js";import h from"../core/Loadable.js";import d from"../core/Logger.js";import{destroyMaybe as y,abortMaybe as u}from"../core/maybe.js";import m from"../core/Promise.js";import{after as c}from"../core/promiseUtils.js";import{watch as g,whenOnce as f,when as w,sync as v,syncAndInitial as _}from"../core/reactiveUtils.js";import{property as M}from"../core/accessorSupport/decorators/property.js";import"../core/RandomLCG.js";import{subclass as V}from"../core/accessorSupport/decorators/subclass.js";import{owningCollectionProperty as R}from"../core/support/OwningCollection.js";import{UpdatingHandles as S}from"../core/support/UpdatingHandles.js";import j from"../geometry/Extent.js";import T from"../geometry/HeightModelInfo.js";import E from"../geometry/SpatialReference.js";import{equals as F}from"../geometry/support/spatialReferenceUtils.js";import{AnalysesCollection as k}from"../support/AnalysesCollection.js";import{GraphicsCollection as x}from"../support/GraphicsCollection.js";import b from"../time/TimeExtent.js";import{system as O,isTimeZoneValid as L}from"../time/timeZoneUtils.js";import C from"./BasemapView.js";import Z from"./LayerViewManager.js";import I from"./Magnifier.js";import H from"./SelectionManager.js";import W from"./Theme.js";import{ToolViewManager as D}from"./ToolViewManager.js";import{makeDefaultHighlightOptions as q}from"./3d/support/DefaultHighlights.js";import P from"./input/Input.js";import{ViewEvents as U}from"./input/ViewEvents.js";import A from"./navigation/Navigation.js";import{DefaultsFromMap as z}from"./support/DefaultsFromMap.js";import G from"./support/HighlightOptions.js";import N from"./support/RequiredFieldsOptions.js";var $;let B=$=class extends(l.EventedMixin(m.EsriPromiseMixin(i))){constructor(e){super(e),this._userSpatialReference=null,this._cursor=null,this.handles=new p,this.updatingHandles=new S,this.allLayerViews=new s({getCollections:()=>[this.basemapView?.baseLayerViews,this.groundView?.layerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:Q}),this.groundView=null,this.basemapView=null,this.displayFilterEnabled=!0,this.fatalError=null,this.graphics=new x,this.analyses=new k,this.typeSpecificPreconditionsReady=!0,this.layerViews=new a,this.magnifier=new I,this.padding={left:0,top:0,right:0,bottom:0},this.ready=!1,this._readyStateWaitingTask=null,this.supportsGround=!0,this.type=null,this.scale=null,this.updating=!1,this.initialExtentRequired=!0,this.input=new P,this.navigation=new A,this.layerViewManager=null,this.analysisViewManager=null,this.isHeightModelInfoRequired=!1,this.width=null,this.height=null,this.resizing=!1,this.suspended=!1,this.viewEvents=new U(this),this.persistableViewModels=new a,this.requiredFieldsOptions=new N,this._isValid=!1,this._readyCycleForced=!1,this._lockedSpatialReference=null,this._userTimeZone=null,this._lockedTimeZone=null,this._userTimeExtent=null,this._lockedTimeExtent=null,this.theme=null,this.handles.add(g((()=>this.preconditionsReady),(e=>{const t=this.ready;if(e?(this._lockedSpatialReference=this.spatialReference,this._lockedTimeZone=this.timeZone,this._lockedTimeExtent=this.timeExtent,$.views.add(this)):(this._lockedSpatialReference=null,$.views.remove(this)),this.notifyChange("spatialReference"),!e&&t)this.toolViewManager?.detach(),null!=this.analysisViewManager&&this.analysisViewManager.detach(),this.layerViewManager?.clear(),this._teardown();else if(e&&!t){try{this._startup()}catch(i){return void queueMicrotask((()=>{this.fatalError=new n("startup-error",null,i)}))}null!=this.analysisViewManager&&this.analysisViewManager.attach(),this.toolViewManager.attach()}}),v))}initialize(){this.addResolvingPromise(Promise.all([this.loadAsyncDependencies(),this.validate()]).then((()=>(this._isValid=!0,f((()=>this.ready)))))),this.basemapView=new C({view:this}),this.layerViewManager=new Z({view:this,layerViewImporter:{importLayerView:e=>this.importLayerView(e),hasLayerViewModule:e=>this.hasLayerViewModule(e)},supportsGround:this.supportsGround}),this.toolViewManager=new D({view:this}),this.selectionManager=new H({view:this}),this.addHandles([w((()=>"map-content-error"===this.readyState&&!this.spatialReference),(()=>{d.getLogger(this).warn("#spatialReference","no spatial reference could be derived from the currently added map layers")})),g((()=>this.initialExtentRequired),(e=>this.defaultsFromMap.required={...this.defaultsFromMap.required,extent:e}),_),g((()=>this.ready),(e=>{this.defaultsFromMap&&(this.defaultsFromMap.suspended=e,this.defaultsFromMap.userSpatialReference=e?this.spatialReference:this._userSpatialReference)}),v),g((()=>this._userSpatialReference),(e=>{this.defaultsFromMap&&(this.defaultsFromMap.userSpatialReference=e)}),_)])}destroy(){this.destroyed||($.views.remove(this),this.viewEvents.destroy(),this.allLayerViews.destroy(),this.navigation&&(this.navigation.destroy(),this._set("navigation",null)),this.graphics=y(this.graphics),this.analyses=y(this.analyses),this.defaultsFromMap.destroy(),this._set("defaultsFromMap",null),y(this.analysisViewManager),this.toolViewManager=y(this.toolViewManager),this.layerViewManager=y(this.layerViewManager),this.selectionManager=y(this.selectionManager),this.basemapView=y(this.basemapView),this.groundView?.destroy(),this.layerViews?.forEach((e=>e.destroy())),this.layerViews.length=0,this.invalidate(),this._emitter.clear(),this.handles.destroy(),this.map=y(this.map),this.updatingHandles.destroy())}_startup(){this._set("ready",!0)}_teardown(){this._set("ready",!1)}whenReady(){return Promise.resolve(this)}toMap(){return d.getLogger(this).error("#toMap()","Not implemented on this instance of View"),null}get highlights(){return this._get("highlights")??q()}set highlights(e){this._set("highlights",o(e,this._get("highlights")))}get activeTool(){return this.toolViewManager?.activeTool}set activeTool(e){this.toolViewManager&&(this.toolViewManager.activeTool=e)}get animation(){return this._get("animation")}set animation(e){this._set("animation",e)}get center(){return null}get defaultsFromMapSettings(){return{}}get defaultsFromMap(){return new z({required:{tileInfo:!1,heightModelInfo:!1,extent:!1},map:()=>this.map,getSpatialReferenceSupport:(e,t)=>this.getSpatialReferenceSupport(e,t),...this.defaultsFromMapSettings})}get extent(){return this._get("extent")}set extent(e){this._set("extent",e)}get heightModelInfo(){return this.getDefaultHeightModelInfo()}get interacting(){return this.navigating}get navigating(){return!1}get preconditionsReady(){return!(this.fatalError||!this._isValid||this._readyCycleForced||!this.map||h.isLoadable(this.map)&&!this.map.loaded||0===this.width||0===this.height||!this.spatialReference||!this._validateSpatialReference(this.spatialReference)||!this._lockedSpatialReference&&!this.defaultsFromMap?.ready||!this.typeSpecificPreconditionsReady)}get resolution(){return 0}set map(e){e!==this._get("map")&&(e?.destroyed&&(d.getLogger(this).warn("#map","The provided map is already destroyed",{map:e}),e=null),h.isLoadable(e)&&e.load().catch((()=>{})),this.constructed&&!this.destroyed&&(this.forceReadyCycle(),this._lockedSpatialReference=null),this._set("map",e))}get readyState(){if(this.destroyed)return this._get("readyState");if(!this.map)return"missing-map";if("container"in this&&!this.container)return"missing-container";if(this.fatalError)return"rendering-error";if((this.defaultsFromMap?.ready??!1)&&!this.spatialReference){const e=!("loaded"in this.map)||this.map.loaded,t=this.map.ground.loaded,i=this.map.basemap?.loaded??!0;return e&&i&&t&&!this.map?.allLayers.length?"empty-map":(this._readyStateWaitingTask||(this._readyStateWaitingTask=r((e=>c(has("view-readyState-waiting-delay"),null,e))),this.addHandles(this._readyStateWaitingTask),this.addHandles(this._readyStateWaitingTask,"ready-state-task")),this._readyStateWaitingTask?.finished?"map-content-error":"loading")}return this._readyStateWaitingTask=u(this._readyStateWaitingTask),this.removeHandles("ready-state-task"),this.ready?"ready":"loading"}get spatialReference(){const e=this._userSpatialReference||this._lockedSpatialReference||this.getDefaultSpatialReference()||null;if(e&&this.defaultsFromMap?.required?.heightModelInfo){const t=e.clone();return t.vcsWkid=this.defaultsFromMap.vcsWkid,t.latestVcsWkid=this.defaultsFromMap.latestVcsWkid,t}return e}set spatialReference(e){const t=!F(e,this._get("spatialReference"));this._set("_userSpatialReference",e),t&&(this._set("spatialReference",e),this._spatialReferenceChanged(e))}_spatialReferenceChanged(e){}get stationary(){return!this.animation&&!this.navigating&&!this.resizing}get timeExtent(){return this._userTimeExtent??this._lockedTimeExtent??this.getDefaultTimeExtent()??null}set timeExtent(e){this._userTimeExtent=e}get timeZone(){return this._userTimeZone??this._lockedTimeZone??this.getDefaultTimeZone()??O}set timeZone(e){this._userTimeZone=e,L(e)||d.getLogger(this).warn("#timeZone",`the parsed value '${e}' may not be a valid IANA time zone`)}get tools(){return this.toolViewManager?.tools}get initialExtent(){return this.defaultsFromMap?.extent}get cursor(){return this.toolViewManager?.cursor??this._cursor??"default"}set cursor(e){this._cursor=e,this.notifyChange("cursor")}get size(){return[this.width,this.height]}get effectiveTheme(){return this.theme??new W}whenLayerView(e){return this.layerViewManager?.whenLayerView(e)??Promise.reject()}getDefaultSpatialReference(){return this.defaultsFromMap?.spatialReference}getDefaultHeightModelInfo(){return(this.map&&"heightModelInfo"in this.map?this.map.heightModelInfo:void 0)??this.defaultsFromMap?.heightModelInfo??null}getDefaultTimeZone(){return null}getDefaultTimeExtent(){return null}importLayerView(e){throw new n("importLayerView() not implemented")}hasLayerViewModule(e){return!1}async validate(){}async loadAsyncDependencies(){}invalidate(){this._isValid=!1}getSpatialReferenceSupport(){return{constraints:null}}_validateSpatialReference(e){return null!=this.getSpatialReferenceSupport(e)}when(e,t){return this.isResolved()&&!this.ready&&d.getLogger(this).warn("#when()","Calling view.when() while the view is no longer ready but was already resolved once will resolve immediately. Use reactiveUtils.whenOnce(() => view.ready).then(...) instead."),super.when(e,t)}forceReadyCycle(){this.ready&&(w((()=>this.destroyed||!1===this.preconditionsReady),(()=>this._readyCycleForced=!1),{once:!0}),this._readyCycleForced=!0)}addAndActivateTool(e){this.toolViewManager.tools.add(e),this.activeTool=e}tryFatalErrorRecovery(){this.fatalError=null}};B.views=new a,e([M()],B.prototype,"_userSpatialReference",void 0),e([M({type:a.ofType(G)})],B.prototype,"highlights",null),e([M()],B.prototype,"activeTool",null),e([M({readOnly:!0})],B.prototype,"allLayerViews",void 0),e([M()],B.prototype,"groundView",void 0),e([M()],B.prototype,"animation",null),e([M()],B.prototype,"basemapView",void 0),e([M()],B.prototype,"center",null),e([M()],B.prototype,"defaultsFromMapSettings",null),e([M()],B.prototype,"defaultsFromMap",null),e([M()],B.prototype,"displayFilterEnabled",void 0),e([M()],B.prototype,"fatalError",void 0),e([M({type:j})],B.prototype,"extent",null),e([M(R(x,"graphics"))],B.prototype,"graphics",void 0),e([M(R(k,"analyses"))],B.prototype,"analyses",void 0),e([M({readOnly:!0,type:T})],B.prototype,"heightModelInfo",null),e([M({readOnly:!0})],B.prototype,"interacting",null),e([M({readOnly:!0})],B.prototype,"navigating",null),e([M({readOnly:!0,dependsOn:["fatalError","_isValid","_readyCycleForced","map","map.loaded?","width","height","spatialReference","_lockedSpatialReference","defaultsFromMap.ready","typeSpecificPreconditionsReady"]})],B.prototype,"preconditionsReady",null),e([M({readOnly:!0})],B.prototype,"typeSpecificPreconditionsReady",void 0),e([M({type:a,readOnly:!0})],B.prototype,"layerViews",void 0),e([M()],B.prototype,"resolution",null),e([M({type:I})],B.prototype,"magnifier",void 0),e([M({value:null,type:t})],B.prototype,"map",null),e([M()],B.prototype,"padding",void 0),e([M({readOnly:!0})],B.prototype,"ready",void 0),e([M()],B.prototype,"_readyStateWaitingTask",void 0),e([M({readOnly:!0})],B.prototype,"readyState",null),e([M({type:E})],B.prototype,"spatialReference",null),e([M()],B.prototype,"stationary",null),e([M({readOnly:!0})],B.prototype,"supportsGround",void 0),e([M({type:b})],B.prototype,"timeExtent",null),e([M({type:String,nonNullable:!0})],B.prototype,"timeZone",null),e([M()],B.prototype,"tools",null),e([M()],B.prototype,"toolViewManager",void 0),e([M({readOnly:!0})],B.prototype,"type",void 0),e([M({type:Number})],B.prototype,"scale",void 0),e([M({readOnly:!0})],B.prototype,"updating",void 0),e([M({readOnly:!0})],B.prototype,"initialExtentRequired",void 0),e([M({readOnly:!0})],B.prototype,"initialExtent",null),e([M()],B.prototype,"cursor",null),e([M({readOnly:!0})],B.prototype,"input",void 0),e([M({type:A,nonNullable:!0})],B.prototype,"navigation",void 0),e([M()],B.prototype,"layerViewManager",void 0),e([M()],B.prototype,"analysisViewManager",void 0),e([M()],B.prototype,"selectionManager",void 0),e([M()],B.prototype,"width",void 0),e([M()],B.prototype,"height",void 0),e([M({readOnly:!0})],B.prototype,"resizing",void 0),e([M({value:null,readOnly:!0})],B.prototype,"size",null),e([M({readOnly:!0})],B.prototype,"suspended",void 0),e([M({readOnly:!0})],B.prototype,"viewEvents",void 0),e([M({readOnly:!0})],B.prototype,"persistableViewModels",void 0),e([M()],B.prototype,"_isValid",void 0),e([M()],B.prototype,"_readyCycleForced",void 0),e([M()],B.prototype,"_lockedSpatialReference",void 0),e([M()],B.prototype,"_userTimeZone",void 0),e([M()],B.prototype,"_lockedTimeZone",void 0),e([M()],B.prototype,"_userTimeExtent",void 0),e([M()],B.prototype,"_lockedTimeExtent",void 0),e([M({type:W})],B.prototype,"theme",void 0),e([M({readOnly:!0,type:W})],B.prototype,"effectiveTheme",null),B=$=e([V("esri.views.View")],B);const J=globalThis.$arcgis;J&&!J.views&&Object.defineProperty(J,"views",{configurable:!1,enumerable:!0,writable:!1,value:B.views});const K=B;function Q(e){return e.layerViews}export{K 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.32/esri/copyright.txt for details.
4
4
  */
5
- const t=t=>t,u=t=>t*t,o=t=>1-u(1-t),i=t=>t<.5?u(2*t)/2:(o(2*(t-.5))+1)/2,n=t=>t*t*t,c=t=>1-n(1-t),a=t=>t<.5?n(2*t)/2:(c(2*(t-.5))+1)/2,s=t=>t*t*t*t,q=t=>1-s(1-t),r=t=>t<.5?s(2*t)/2:(q(2*(t-.5))+1)/2,e=t=>t*t*t*t*t,b=t=>1-e(1-t),d=t=>t<.5?e(2*t)/2:(b(2*(t-.5))+1)/2,h=t=>1-Math.cos(t*Math.PI/2),p=t=>1-h(1-t),x=t=>t<.5?h(2*t)/2:(p(2*(t-.5))+1)/2,M=t=>2**(10*(t-1)),f=t=>1-M(1-t),l=t=>t<.5?M(2*t)/2:(f(2*(t-.5))+1)/2,I=t=>-(Math.sqrt(1-t*t)-1),P=t=>1-I(1-t),g=t=>t<.5?I(2*t)/2:(P(2*(t-.5))+1)/2;function j(t){const u=2*(t-Math.sqrt((t-1)*t)),o=u/2/t;return i=>i<o?t*i*i:u*i-u+1}function k(t,u){return(o,i)=>o<u?u*t(o/u,i):1-t((1-o)/(1-u),i)*(1-u)}const m=k(j(1),1),v=k(j(1),0),w=k(j(1),.5),y=k(j(2),1),z=k(j(2),0),A=k(j(2),.5),B=k(j(3),1),C=k(j(3),0),D=k(j(3),.5),E=k(j(4),1),F=k(j(4),0),G=k(j(4),.5),H={linear:t,"in-quad":u,"out-quad":o,"in-out-quad":i,"in-coast-quad":m,"out-coast-quad":v,"in-out-coast-quad":w,"in-cubic":n,"out-cubic":c,"in-out-cubic":a,"in-coast-cubic":y,"out-coast-cubic":z,"in-out-coast-cubic":A,"in-quart":s,"out-quart":q,"in-out-quart":r,"in-coast-quart":B,"out-coast-quart":C,"in-out-coast-quart":D,"in-quint":e,"out-quint":b,"in-out-quint":d,"in-coast-quint":E,"out-coast-quint":F,"in-out-coast-quint":G,"in-sine":h,"out-sine":p,"in-out-sine":x,"in-expo":M,"out-expo":f,"in-out-expo":l,"in-circ":I,"out-circ":P,"in-out-circ":g};export{H as EasingFunctions,I as inCirc,y as inCoastCubic,m as inCoastQuad,B as inCoastQuart,E as inCoastQuint,n as inCubic,M as inExpo,g as inOutCirc,A as inOutCoastCubic,w as inOutCoastQuad,D as inOutCoastQuart,G as inOutCoastQuint,a as inOutCubic,l as inOutExpo,i as inOutQuad,r as inOutQuart,d as inOutQuint,x as inOutSine,u as inQuad,s as inQuart,e as inQuint,h as inSine,t as linear,P as outCirc,z as outCoastCubic,v as outCoastQuad,C as outCoastQuart,F as outCoastQuint,c as outCubic,f as outExpo,o as outQuad,q as outQuart,b as outQuint,p as outSine};
5
+ import{easingFunctions as t}from"../2d/unitBezier.js";const u=t=>t,i=t=>t*t,o=t=>1-i(1-t),n=t=>t<.5?i(2*t)/2:(o(2*(t-.5))+1)/2,a=t=>t*t*t,c=t=>1-a(1-t),s=t=>t<.5?a(2*t)/2:(c(2*(t-.5))+1)/2,e=t=>t*t*t*t,q=t=>1-e(1-t),r=t=>t<.5?e(2*t)/2:(q(2*(t-.5))+1)/2,d=t=>t*t*t*t*t,b=t=>1-d(1-t),p=t=>t<.5?d(2*t)/2:(b(2*(t-.5))+1)/2,h=t=>1-Math.cos(t*Math.PI/2),x=t=>1-h(1-t),M=t=>t<.5?h(2*t)/2:(x(2*(t-.5))+1)/2,f=t=>2**(10*(t-1)),I=t=>1-f(1-t),m=t=>t<.5?f(2*t)/2:(I(2*(t-.5))+1)/2,O=t=>-(Math.sqrt(1-t*t)-1),j=t=>1-O(1-t),l=t=>t<.5?O(2*t)/2:(j(2*(t-.5))+1)/2;function z(t){const u=2*(t-Math.sqrt((t-1)*t)),i=u/2/t;return o=>o<i?t*o*o:u*o-u+1}function B(t,u){return(i,o)=>i<u?u*t(i/u,o):1-t((1-i)/(1-u),o)*(1-u)}const P=B(z(1),1),g=B(z(1),0),k=B(z(1),.5),v=B(z(2),1),w=B(z(2),0),y=B(z(2),.5),A=B(z(3),1),C=B(z(3),0),D=B(z(3),.5),E=B(z(4),1),F=B(z(4),0),G=B(z(4),.5),H={linear:u,"in-quad":i,"out-quad":o,"in-out-quad":n,"in-coast-quad":P,"out-coast-quad":g,"in-out-coast-quad":k,"in-cubic":a,"out-cubic":c,"in-out-cubic":s,"in-coast-cubic":v,"out-coast-cubic":w,"in-out-coast-cubic":y,"in-quart":e,"out-quart":q,"in-out-quart":r,"in-coast-quart":A,"out-coast-quart":C,"in-out-coast-quart":D,"in-quint":d,"out-quint":b,"in-out-quint":p,"in-coast-quint":E,"out-coast-quint":F,"in-out-coast-quint":G,"in-sine":h,"out-sine":x,"in-out-sine":M,"in-expo":f,"out-expo":I,"in-out-expo":m,"in-circ":O,"out-circ":j,"in-out-circ":l,ease:u=>t.ease(u),"ease-in":u=>t.easeIn(u),"ease-out":u=>t.easeOut(u),"ease-in-out":u=>t.easeInOut(u)};export{H as EasingFunctions,O as inCirc,v as inCoastCubic,P as inCoastQuad,A as inCoastQuart,E as inCoastQuint,a as inCubic,f as inExpo,l as inOutCirc,y as inOutCoastCubic,k as inOutCoastQuad,D as inOutCoastQuart,G as inOutCoastQuint,s as inOutCubic,m as inOutExpo,n as inOutQuad,r as inOutQuart,p as inOutQuint,M as inOutSine,i as inQuad,e as inQuart,d as inQuint,h as inSine,u as linear,j as outCirc,w as outCoastCubic,g as outCoastQuad,C as outCoastQuart,F as outCoastQuint,c as outCubic,I as outExpo,o as outQuad,q as outQuart,b as outQuint,x as outSine};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{isSome as t}from"../core/arrayUtils.js";import i from"../core/Collection.js";import{makeHandle as s}from"../core/handleUtils.js";import{debounce as o,isAbortError as r}from"../core/promiseUtils.js";import{watch as a,initial as n,on as l}from"../core/reactiveUtils.js";import{escapeRegExpString as c}from"../core/string.js";import{property as d}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import p from"../portal/Portal.js";import{defaultUnitPropertyMetadata as h}from"../properties/defaultUnit.js";import u from"../rest/support/Stop.js";import v from"../symbols/SimpleMarkerSymbol.js";import _ from"./Search.js";import g from"./Widget.js";import{DirectionsSearchTool as w}from"./Directions/DirectionsSearchTool.js";import y from"./Directions/DirectionsViewModel.js";import b from"./Directions/DirectionsVisibleElements.js";import{formatDistance as f,formatDuration as S,DepartureTimeOption as M,getIconName as k}from"./Directions/support/directionsUtils.js";import{isArcGISWorldGeocoder as I,meteredArcGISLocatorUrl as F}from"./Search/support/locatorUtils.js";import{loadCalciteComponents as T}from"./support/componentsUtils.js";import{globalCss as D}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as x}from"./support/decorators/messageBundle.js";import{tsx as C}from"./support/jsxFactory.js";function E(e){const{branchName:i,displayText:s,exitName:o,intersectingName:r,name:a,towardName:n}=e;if(null==s)return null;const l=[i,o,r,a,n].filter(t).sort(((e,t)=>t.length-e.length)).map((e=>c(e)));if(!l.length)return s;const d=new RegExp(l.join("|"),"g"),m=s.matchAll(d);let p=0;const h=[];for(const{0:t,index:c}of m)h.push(s.slice(p,c),C("span",{class:A.labelEmphasize,key:`maneuver-${c}`},t)),p=c+t.length;return h.push(s.slice(p)),C("span",null,h)}function $(e){if(!e)return;const t=new Date(e);return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())}const L="esri-directions",A={base:L,accordion:`${L}__accordion`,actionContainer:`${L}__action-container`,addStopButton:`${L}__add-stop-button`,departureTime:`${L}__departure-time`,departureTimeOptions:`${L}__departure-time-options`,directionsHeader:`${L}__directions-header`,directionsHeaderStopName:`${L}__directions-header-stop-name`,editFooter:`${L}__edit-footer`,editToolbar:`${L}__edit-toolbar`,editToolbarContainer:`${L}__edit-toolbar-container`,flexColumn:`${L}__flex-column`,flexRow:`${L}__flex-row`,headerStops:`${L}__header-stops`,labelEmphasize:`${L}__label-emphasize`,labelNoBottomMargin:`${L}__label-no-bottom-margin`,marginInlineMedium:`${L}__margin-inline-medium`,optimizeSection:`${L}__optimize-section`,optimizeSwitches:`${L}__optimize-switches`,paddingMedium:`${L}__padding-medium`,primaryFlowItem:`${L}__primary-flow-item`,primaryFooter:`${L}__primary-footer`,primaryFooterCentered:`${L}__primary-footer-centered`,primaryFooterLoader:`${L}__primary-footer-loader`,routeItem:`${L}__route-item`,routeItemButton:`${L}__route-item-button`,routeItemButtonContent:`${L}__route-item-button-content`,routeItemLabel:`${L}__route-item-label`,routeItemDescription:`${L}__route-item-description`,saveError:`${L}__save-error`,saveErrorIcon:`${L}__save-error-icon`,saveErrorLabel:`${L}__save-error-label`,saveProcessLoader:`${L}__save-process-loader`,selectedFeatureContainer:`${L}__selected-feature-container`,separator:`${L}__separator`,solveRoute:`${L}__solve-route`,stopContainer:`${L}__stop-container`,stopList:`${L}__stop-list`,stopItem:`${L}__stop-item`};let R=class extends g{constructor(e,t){super(e,t),this._activeManeuver=null,this._placeholderStops=new i([new u,new u]),this._portalFolderCombobox=null,this._portalFolders=null,this._portalItemNameInput=null,this._portalUserName=null,this._sections=null,this._stopsToSearches=new Map,this._currentFlowItem="primary",this._parentFlowItem="primary",this._saveState="initialized",this._searchTool=null,this.headingLevel=2,this.messages=null,this.messagesUnits=null,this.searchProperties=null,this.viewModel=new y,this.visibleElements=new b,this._solveRouteDebounced=o((()=>this._solveRoute()))}initialize(){this.addHandles([a((()=>this.viewModel.layer),(()=>{try{this.viewModel.load()}catch{}}),n),a((()=>this.viewModel.layer?.routeInfo),(()=>{this._sections=this._getStopSections()}),n),a((()=>this.viewModel.layer?.stops.toArray()),(e=>{e&&this.view?.activeTool&&this._searchTool&&this.view.activeTool===this._searchTool&&!e.includes(this._searchTool.stop)&&(this.view.tools.remove(this._searchTool),this._searchTool=null)}))])}loadDependencies(){return T({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"block-section":()=>import("@esri/calcite-components/dist/components/calcite-block-section"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch")})}get apiKey(){return this.viewModel.apiKey}set apiKey(e){this.viewModel.apiKey=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"right"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get lastRoute(){return this.viewModel.lastRoute}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get maxStops(){return this.viewModel.maxStops}set maxStops(e){this.viewModel.maxStops=e}get unit(){return this.defaultUnit}set unit(e){this._overrideIfSome("unit",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e);return i.view=t,this._overrideDefaultSources(i),i}const i=new _({icon:!1,popupEnabled:!1,resultGraphicEnabled:!1,view:t,...this.searchProperties});return this._normalizeSearchSources(i),this.addHandles([l((()=>i.allSources),"change",(()=>this._normalizeSearchSources(i))),i.on("search-clear",(()=>{e.geometry=null,e.name=null,this.viewModel.layer?.removeResult()})),i.on("select-result",(()=>{const t=i.selectedResult;e.geometry=t?.feature.geometry,e.name=t?.name,this._solveRouteDebounced()})),a((()=>i.searchTerm),(t=>{e.name=t}))],i),this._stopsToSearches.set(e,i),i}getDirections(){return this.viewModel.getDirections()}render(){return C("div",{class:this.classes(A.base,D.widget,D.panel)},C("calcite-flow",null,this._renderPrimaryFlowItem(),this._renderDirectionsFlowItem(),this._renderEditFlowItem(),this._renderSaveFlowItem()))}save(){return this.viewModel.save()}saveAs(e,t={}){return this.viewModel.saveAs(e,t)}zoomToRoute(){return this.viewModel.zoomToRoute()}_applyLocatorSourceOverrides({allSources:e}){for(const t of e)"url"in t&&t.url&&(t.locationType??="street",I(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=F))}_disposeSearch(e){if(!e||!this._stopsToSearches.has(e))return;const t=this._stopsToSearches.get(e);this.removeHandles(t),t.destroy(),this._stopsToSearches.delete(e)}_getEffectiveStops(){return this.viewModel.layer?.stops??this._placeholderStops}_getErrorDescription(){switch(this.viewModel.lastError?.name){case"directions-view-model:unable-to-route":return this.messages.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return this.messages.errors.unableToLoadServiceMetadata;default:return this.messages.errors.unknownError}}_getNetworkFeatureName(e){switch(e.type){case"stop":switch(e.locationType){case"stop":default:return this.messages.networkFeatures.stops.stop;case"waypoint":return this.messages.networkFeatures.stops.waypoint;case"break":return this.messages.networkFeatures.stops.break}case"point-barrier":return this.messages.networkFeatures.pointBarrier;case"polyline-barrier":return this.messages.networkFeatures.polylineBarrier;case"polygon-barrier":return this.messages.networkFeatures.polygonBarrier}}_getRouteCostSummary(){const e=this.viewModel.layer?.routeInfo;if(!e)return null;const t=e.totalDistance??0,i=e.totalDuration??0,{messagesUnits:s,unit:o}=this;return{distance:f(s,t,o),duration:S(i)}}_getStopSections(){if(!this.viewModel.layer)return null;const{directionPoints:e,directionLines:t,stops:i}=this.viewModel.layer;if(!e||!t)return null;const s=[];let o=null;for(const r of e){const{objectId:e,stopId:a}=r;if(null!=a){const e=i.find((({objectId:e})=>e===a));o&&o.stop===e||(o={stop:e,directions:[]},s.push(o));continue}if(null==o)continue;const n=t.find((({directionPointId:t})=>t===e));null!=n&&o.directions.push({directionPoint:r,directionLine:n})}return s}_handleLocateStopAction(e){const{view:t}=this;if(!t)return;const i="directions-search-tool";this.removeHandles(i),this._searchTool=new w({stop:e,view:t}),this.addHandles([this._searchTool.on("click",(async t=>{if(t.mapPoint&&this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e),s=await i.search(t.mapPoint),o=s?.results?.[0].results?.[0];if(o){const{feature:t,name:s}=o;i.searchTerm=s,e.geometry=t.geometry}}this.removeHandles(i)})),s((()=>{this._searchTool&&(this.view?.tools.remove(this._searchTool),this._searchTool=null)}))],i),t.addAndActivateTool(this._searchTool)}_handleEditingDoneClick(){this.viewModel.stopEditing(),this._currentFlowItem="primary"}async _handleSaveLayerAsAction(){const e=p.getDefault();try{await e.signIn()}catch(t){if(r(t)||"identity-manager:user-aborted"===t.name)return;return this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",void(this._saveState="connect-to-portal-error")}this._saveState="fetch-portal-information",this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",this._portalUserName=e.user?.username;try{this._portalFolders=await(e.user?.fetchFolders())}catch{return void(this._saveState="fetch-portal-information-error")}this._saveState="save-layer"}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){for(const t of e.viewModel.defaultSources)t.autoNavigate=!1}_renderClearRouteAction(e){return C("calcite-action",{icon:"trash",key:"clear-route",onclick:()=>{this._currentFlowItem="primary",this.viewModel.reset()},...e,text:this.messages.common.clear,textEnabled:!0})}_renderDeleteStopAction(e){const t=this._getEffectiveStops();return C("calcite-action",{icon:"trash",onclick:()=>{t.remove(e),this._disposeSearch(e),this._solveRouteDebounced()},scale:"s",slot:"actions-end",text:this.messages.deleteStop,title:this.messages.deleteStop})}_renderDepartureTime(){const{DEPART_AT:e,NOW:t,UNSPECIFIED:i}=M;return C("calcite-label",{class:A.departureTime,key:"departure-time"},this.messages.departureTime,C("calcite-combobox",{clearDisabled:!0,label:this.messages.departureTime,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{const{selectedItems:t}=e;t.length&&(this.viewModel.departureOption=t[0].value,this._solveRouteDebounced())}},C("calcite-combobox-item",{heading:this.messages.leaveNow,key:t,label:this.messages.leaveNow,selected:this.viewModel.departureOption===t,value:t}),C("calcite-combobox-item",{heading:this.messages.departAt,key:e,label:this.messages.departAt,selected:this.viewModel.departureOption===e,value:e}),C("calcite-combobox-item",{heading:this.messages.timeUnspecified,key:i,label:this.messages.timeUnspecified,selected:this.viewModel.departureOption===i,value:i})))}_renderDepartureTimeOptions(){return this.viewModel.departureOption!==M.DEPART_AT?null:C("div",{class:A.departureTimeOptions},C("calcite-input-date-picker",{scale:"s",valueAsDate:$(this.viewModel.departureIsoDate),onCalciteInputDatePickerChange:({currentTarget:{value:e}})=>{Array.isArray(e)||(this.viewModel.departureIsoDate=e,this._solveRouteDebounced())}}),C("calcite-input-time-picker",{scale:"s",value:this.viewModel.departureIsoTime,onCalciteInputTimePickerClose:({currentTarget:{value:e}})=>{this.viewModel.departureIsoTime=e,this._solveRouteDebounced()}}))}_renderDirectionsFlowItem(){if("directions"!==this._currentFlowItem)return null;const e=this._getRouteCostSummary();if(!this._sections||!e)return null;const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel,o=this._sections.at(0)?.stop.name??"",r=this._sections.at(-1)?.stop.name??"";return C("calcite-flow-item",{key:"directions-flow-item",overlayPositioning:"fixed",selected:"directions"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this._currentFlowItem="primary"}},C("div",{class:A.directionsHeader,slot:"header-content"},C("div",{class:A.headerStops},C("span",null,this.messages.from)," ",C("span",{class:A.directionsHeaderStopName},o),C("span",null,this.messages.to)," ",C("span",{class:A.directionsHeaderStopName},r)),C("div",{class:A.flexColumn},C("span",null,`${i} (${t})`),s?C("span",null,s):null)),this._renderRouteLayerActions({slot:"header-menu-actions"}),C("calcite-accordion",{class:A.accordion,iconPosition:"start",selectionMode:"single"},this._sections.map(((e,t)=>{const{stop:i,directions:s}=e,{name:o}=i;return C("calcite-accordion-item",{expanded:0===t,heading:o??"",key:`stop-${t}`},C("calcite-action",{icon:"zoom-to-object",onclick:()=>{this.viewModel.centerAt(i)},slot:"actions-end",text:this.messages.panToStop}),this._renderDirectionTurns(s))}))))}_renderDirectionTurns(e){return C("calcite-list",{label:this.messages.drivingDirections,selectionMode:"none"},e.map(((e,t)=>{const{directionPoint:i,directionLine:s}=e,{distance:o,duration:r}=s,a=f(this.messagesUnits,o??0,this.unit),n=S(r??0),l=a&&n?`${a} | ${n}`:`${a||n}`,c=E(i),d=k(i.directionPointType);return C("calcite-list-item",{class:A.labelNoBottomMargin,key:`driving-direction-${t}`,onpointerenter:()=>{this.viewModel.highlight(s)},onpointerleave:()=>{this.viewModel.clearHighlights()},onCalciteListItemSelect:()=>{this._activeManeuver===s?this.zoomToRoute():(this._activeManeuver=s,this.viewModel.centerAt(s.geometry))}},C("calcite-icon",{icon:d,slot:"content-start"}),C("div",{slot:"content"},C("calcite-label",{layout:"inline",scale:"s"},c),C("calcite-label",{layout:"inline",scale:"s"},l)))})))}_renderEditFlowItem(){return"edit"!==this._currentFlowItem?null:C("calcite-flow-item",{heading:this.messages.editRoute,headingLevel:this.headingLevel,key:"edit-flow-item",loading:"routing"===this.viewModel.state,selected:"edit"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem="primary"}},C("div",{class:A.flexColumn,key:"edit-container"},C("div",{class:A.editToolbarContainer},C("calcite-label",{layout:"inline",scale:"s"},this.messages.automaticallySolve,C("calcite-switch",{checked:this.viewModel.autoSolve,scale:"s",onCalciteSwitchChange:e=>{this.viewModel.autoSolve=e.target.checked}})),C("div",{class:A.editToolbar},C("calcite-action",{icon:"flag",onclick:()=>{this.viewModel.create("stop")},scale:"s",text:this.messages.networkFeatures.stops.stop,textEnabled:!0}),C("calcite-action",{icon:"line",onclick:()=>{this.viewModel.create("polyline-barrier")},scale:"s",text:this.messages.barrier,textEnabled:!0}),C("calcite-action",{class:A.solveRoute,disabled:this.viewModel.autoSolve,icon:"refresh",onclick:()=>{this._solveRouteDebounced()},scale:"s",text:this.messages.solve,textEnabled:!0}))),C("div",{class:A.selectedFeatureContainer},C("calcite-list",{label:this.messages.selectedNetworkFeatures,scale:"s",selectionMode:"none"},this.viewModel.selectedNetworkFeatures?.toArray().map(((e,t)=>C("calcite-list-item",{description:this._getNetworkFeatureName(e),key:`network-feature-${t}`,label:e.name??e.objectId?.toString()??this.messages.unnamed},C("calcite-action",{icon:"trash",onclick:()=>{this.viewModel.remove(e)},scale:"s",slot:"actions-end",text:this.messages.common.delete})))))),C("div",{class:A.editFooter},this._renderEditFooterContent())))}_renderEditFooterContent(){return this.viewModel.lastError?this._renderErrorNotice():C("calcite-button",{appearance:"outline-fill",bind:this,onclick:this._handleEditingDoneClick,width:"full"},this.messages.common.done)}_renderErrorNotice(){return C("calcite-notice",{icon:"exclamation-mark-circle",kind:"danger",open:!0},C("calcite-label",{class:A.labelNoBottomMargin,slot:"message"},this._getErrorDescription()))}_renderFooter(){if(!this.viewModel.layer)return C("div",{class:A.primaryFooter,key:"footer-missing-layer"},C("calcite-notice",{icon:"information",open:!0},C("calcite-label",{class:A.labelNoBottomMargin,slot:"message"},this.messages.missingLayer)));if("unauthenticated"===this.viewModel.state)return C("div",{class:A.primaryFooterCentered,key:"footer-sign-in"},C("calcite-label",null,this.messages.signInRequired),C("calcite-button",{onclick:()=>{this.viewModel.load().catch((()=>{}))}},this.messages.common.auth.signIn));if("routing"===this.viewModel.state)return C("div",{class:this.classes(A.primaryFooter,A.primaryFooterLoader),key:"footer-routing"},C("calcite-loader",{label:this.messages.solve,scale:"s"}));if("error"===this.viewModel.state)return C("div",{class:A.primaryFooter,key:"footer-service-error"},this._renderErrorNotice());if(!this.viewModel.layer?.routeInfo)return C("div",{class:A.primaryFooter,key:"footer-unsolved-route"},C("calcite-notice",{icon:"information",open:!0},C("calcite-label",{class:A.labelNoBottomMargin,slot:"message"},this.messages.directionsPlaceholder)));const e=this._getRouteCostSummary();if(!e||!this.viewModel.layer?.directionPoints)return C("div",{class:A.primaryFooter,key:"footer-invalid-route"},C("calcite-notice",{icon:"exclamation-mark-triangle",kind:"danger",open:!0},C("calcite-label",{class:A.labelNoBottomMargin,slot:"message"},this.messages.invalidRoute)));const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel;return C("div",{class:A.routeItem,key:"footer-directions-summary"},C("button",{"aria-busy":"false","aria-label":this.messages.viewDrivingDirections,"aria-live":"polite",class:A.routeItemButton,onclick:()=>{this._currentFlowItem="directions"},type:"button"},C("div",{class:A.routeItemButtonContent},C("span",{class:A.routeItemLabel},`${i} (${t})`),C("span",{class:A.routeItemDescription},s)),C("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s"})),C("calcite-dropdown",null,C("calcite-action",{icon:"ellipsis",slot:"trigger",text:"Route actions"}),this._renderRouteLayerActions()))}_renderInteractiveRouteActions(){return C("div",{class:A.actionContainer,key:"interactive-route-action-container"},C("calcite-button",{appearance:"outline",class:A.addStopButton,disabled:this._getEffectiveStops().length>=this.maxStops,iconStart:"plus",kind:"neutral",label:this.messages.addStop,onclick:()=>{const e=new v;this.viewModel.layer?.stops.add(new u({symbol:e}))},width:"half"},this.messages.addStop),C("calcite-button",{appearance:"outline",disabled:"2d"!==this.viewModel.view?.type,iconStart:"pencil",kind:"neutral",label:this.messages.editRoute,onclick:()=>{this._currentFlowItem="edit",this.viewModel.startEditing()},width:"half"},this.messages.editRoute))}_renderLocateStopAction(e){if(null!=e.name||null!=e.geometry)return null;const t=this._getEffectiveStops().indexOf(e),i=!!this.view?.activeTool&&this.view.activeTool===this._searchTool&&this._searchTool.stop===e;return C("calcite-action",{active:i,icon:"crosshair",key:`stop-location-action-${t}`,onclick:()=>this._handleLocateStopAction(e),scale:"s",slot:"actions-end",text:this.messages.pickALocationOnTheMap,title:this.messages.pickALocationOnTheMap})}_renderOptimizeStopOrder(){const{routeParameters:e}=this.viewModel,{findBestSequence:t,preserveFirstStop:i,preserveLastStop:s}=e;return C("calcite-block-section",{class:A.optimizeSection,text:this.messages.optimizeOrder,toggleDisplay:"switch",onCalciteBlockSectionToggle:({target:t})=>{e.findBestSequence=t.open,t.open||this._resetStopSequence(),this._solveRouteDebounced()}},t?[C("calcite-label",{class:A.optimizeSwitches,key:"preserve-first-stop",layout:"inline-space-between"},this.messages.preserveFirstStop,C("calcite-switch",{checked:i,scale:"s",onCalciteSwitchChange:({target:{checked:t}})=>{e.preserveFirstStop=t,this._resetStopSequence(),this._solveRouteDebounced()}})),C("calcite-label",{class:A.optimizeSwitches,key:"preserve-last-stop",layout:"inline-space-between"},this.messages.preserveLastStop,C("calcite-switch",{checked:s,scale:"s",onCalciteSwitchChange:({target:{checked:t}})=>{e.preserveLastStop=t,this._resetStopSequence(),this._solveRouteDebounced()}}))]:null)}_renderPrimaryFlowItem(){return C("calcite-flow-item",{key:"primary-flow-item",loading:"initializing"===this.viewModel.state,selected:"primary"===this._currentFlowItem},C("calcite-panel",{class:A.primaryFlowItem,disabled:!this.viewModel.layer||"unauthenticated"===this.viewModel.state||"error"===this.viewModel.state&&!this.viewModel.serviceDescription},this._renderStops(),this._renderInteractiveRouteActions(),this._renderSeparator(),this._renderRouteSolveOptions()),this._renderFooter())}_renderRouteLayerActions(e){return[this._renderClearRouteAction(e),this._renderSaveLayerAction(e),this._renderSaveLayerAsAction(e),this._renderViewItemDetailsAction(e)]}_renderRouteSolveOptions(){return C("div",{class:A.marginInlineMedium,key:"route-solve-options"},this._renderTravelModes(),this._renderDepartureTime(),this._renderDepartureTimeOptions(),this._renderOptimizeStopOrder())}_renderSaveContent(){switch(this._saveState){case"initialized":return this._renderSaveInitialized();case"connect-to-portal":return this._renderSaveProcessing(this.messages.identity.lblSigning);case"connect-to-portal-error":return this._renderSaveError(this.messages.errors.authenticating);case"fetch-portal-information":return this._renderSaveProcessing(this.messages.processing.fetching);case"fetch-portal-information-error":return this._renderSaveError(this.messages.errors.fetching);case"save-layer":return this._renderSaveLayerSettings();case"saving":return this._renderSaveProcessing(this.messages.processing.saving);case"saving-error":return this._renderSaveError(this.messages.errors.saving)}}_renderSaveError(e){return C("calcite-panel",{class:A.paddingMedium,key:"save-layer-error"},C("div",{class:A.saveError},C("calcite-icon",{class:A.saveErrorIcon,icon:"exclamation-mark-triangle",scale:"l",textLabel:this.messages.common.errorMessage}),C("calcite-label",{class:A.saveErrorLabel},e)),C("calcite-button",{appearance:"outline",onclick:()=>{this._currentFlowItem=this._parentFlowItem},slot:"footer-actions",width:"full"},this.messages.common.close))}_renderSaveInitialized(){return C("calcite-panel",{class:A.paddingMedium,key:"save-layer-initialized"})}_renderSaveFlowItem(){return"save"!==this._currentFlowItem?null:C("calcite-flow-item",{heading:this.messages.saveLayer,headingLevel:this.headingLevel,key:"save-layer-flow-item",selected:"save"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this._currentFlowItem=this._parentFlowItem}},this._renderSaveContent())}_renderSaveLayerAction(e){if(!this.visibleElements.saveButton)return null;const t=this.viewModel.layer,i=t?.routeInfo,s=t?.portalItem?.itemControl;return C("calcite-action",{disabled:!(!!i&&("admin"===s||"update"===s)),icon:"save",key:"save-route",onclick:()=>{this.viewModel.layer?.save()},...e,text:this.messages.common.save,textEnabled:!0})}_renderSaveLayerAsAction(e){if(!this.visibleElements.saveAsButton)return null;const t=!this.viewModel.layer?.routeInfo;return C("calcite-action",{disabled:t,icon:"save-as",key:"save-as-route",onclick:()=>{this._handleSaveLayerAsAction()},...e,text:this.messages.common.saveAs,textEnabled:!0})}_renderSaveLayerSettings(){if(null==this.layer||null==this._portalFolders||null==this._portalUserName)return this._renderSaveInitialized();const{stops:e}=this.layer,t=`${e.at(0).name} - ${e.at(-1).name}`,i=this._portalFolders.map((e=>C("calcite-combobox-item",{heading:e.title??"",key:`${L}-folder-${e.id}`,value:e.id})));return i.unshift(C("calcite-combobox-item",{heading:`${this._portalUserName} (${this.messages.common.home})`,key:`${L}-folder-home`,selected:!0,value:null})),C("calcite-panel",{key:"save-layer-panel"},C("div",{class:A.paddingMedium},C("calcite-label",null,this.messages.laverName,C("calcite-input",{afterCreate:e=>{this._portalItemNameInput=e},label:this.messages.laverName,value:t})),C("calcite-label",null,this.messages.saveInFolder,C("calcite-combobox",{afterCreate:e=>{this._portalFolderCombobox=e},label:this.messages.saveInFolder,overlayPositioning:"fixed",selectionMode:"single"},i))),C("calcite-button",{onclick:()=>{if(this._saveState="saving",null==this.layer||null==this._portalFolders)return;const e=this._portalItemNameInput?.value,t=this._portalFolderCombobox?.value,i=this._portalFolders.find((({id:e})=>e===t));this.layer.saveAs({title:e},{folder:i}).then((()=>{this._currentFlowItem=this._parentFlowItem})).catch((()=>{this._saveState="saving-error"}))},slot:"footer-actions",width:"full"},this.messages.common.save),C("calcite-button",{appearance:"outline",onclick:()=>{this._currentFlowItem=this._parentFlowItem},slot:"footer-actions",width:"full"},this.messages.common.cancel))}_renderSaveProcessing(e){return C("calcite-panel",{class:A.marginInlineMedium,key:"save-layer-processing"},C("calcite-loader",{class:A.saveProcessLoader,label:e,text:e}))}_renderSeparator(){return C("div",{class:A.separator})}_renderStop(e){const t=this.acquireSearch(e);null!=e.name&&(t.searchTerm=e.name);const i=this._getEffectiveStops(),s=this._renderLocateStopAction(e),o=i.length>2&&this._renderDeleteStopAction(e);return C("calcite-list-item",{key:e,value:e},s,o,C("div",{class:A.stopItem,slot:"content"},t.render()))}_renderStops(){const e=this._getEffectiveStops();for(const t of this._stopsToSearches.keys())e.includes(t)||this._disposeSearch(t);return C("div",{class:A.stopContainer,key:A.stopContainer},C("calcite-list",{class:A.stopList,dragEnabled:!0,label:this.messages.widgetLabel,scale:"s",onCalciteListOrderChange:({detail:t})=>{e.reorder(t.dragEl.value,t.newIndex),this._resetStopSequence(),this._solveRouteDebounced()}},e.toArray().map((e=>this._renderStop(e)))),2===e.length&&C("calcite-action",{icon:"arrow-up-down",onclick:()=>{e.reverse(),this._resetStopSequence(),this._solveRouteDebounced()},scale:"s",text:this.messages.reverseStops}))}_renderTravelModes(){return this.viewModel.travelModes.length?C("calcite-label",{key:"travel-modes"},this.messages.mode,C("calcite-combobox",{clearDisabled:!0,label:this.messages.mode,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{const{selectedItems:t}=e;t.length&&(this.viewModel.selectedTravelMode=t[0].value,this._solveRouteDebounced())}},this.viewModel.travelModes.map((e=>C("calcite-combobox-item",{heading:e.name,key:e.id,label:e.name,selected:this.viewModel.selectedTravelMode?.id===e.id,value:e}))))):null}_renderViewItemDetailsAction(e){if(!this.visibleElements.layerDetails)return null;const t=this.viewModel.layer?.portalItem;return C("calcite-action",{disabled:!t,icon:"launch",key:"open-route-details-link",onclick:()=>{t&&window.open(`${t.portal.url}/home/item.html?id=${t.id}`,"_blank")},...e,text:this.messages.viewLayerDetails,textEnabled:!0})}_resetStopSequence(){this.viewModel.layer?.stops.forEach((e=>{e.sequence=null}))}async _solveRoute(){this.viewModel.updateDepartureTime();if(!((this.viewModel.layer?.stops.filter((({geometry:e})=>!!e)).length??0)<2))try{await this.viewModel.getDirections()}catch{}}};e([d()],R.prototype,"_currentFlowItem",void 0),e([d()],R.prototype,"_saveState",void 0),e([d()],R.prototype,"_searchTool",void 0),e([d()],R.prototype,"apiKey",null),e([d(h)],R.prototype,"defaultUnit",void 0),e([d()],R.prototype,"goToOverride",null),e([d()],R.prototype,"headingLevel",void 0),e([d()],R.prototype,"icon",null),e([d()],R.prototype,"label",null),e([d({readOnly:!0})],R.prototype,"lastRoute",null),e([d()],R.prototype,"layer",null),e([d()],R.prototype,"maxStops",null),e([d(),x("esri/widgets/Directions/t9n/Directions")],R.prototype,"messages",void 0),e([d(),x("esri/core/t9n/Units")],R.prototype,"messagesUnits",void 0),e([d()],R.prototype,"searchProperties",void 0),e([d()],R.prototype,"unit",null),e([d()],R.prototype,"view",null),e([d({type:y})],R.prototype,"viewModel",void 0),e([d({type:b,nonNullable:!0})],R.prototype,"visibleElements",void 0),R=e([m("esri.widgets.Directions")],R);const N=R;export{N as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{isSome as t}from"../core/arrayUtils.js";import i from"../core/Collection.js";import{makeHandle as s}from"../core/handleUtils.js";import{debounce as o,isAbortError as r}from"../core/promiseUtils.js";import{watch as a,initial as n,on as l}from"../core/reactiveUtils.js";import{escapeRegExpString as c}from"../core/string.js";import{property as d}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import p from"../portal/Portal.js";import{defaultUnitPropertyMetadata as h}from"../properties/defaultUnit.js";import u from"../rest/support/Stop.js";import v from"../symbols/SimpleMarkerSymbol.js";import _ from"./Search.js";import g from"./Widget.js";import{DirectionsSearchTool as w}from"./Directions/DirectionsSearchTool.js";import y from"./Directions/DirectionsViewModel.js";import b from"./Directions/DirectionsVisibleElements.js";import{formatDistance as f,formatDuration as S,DepartureTimeOption as M,getIconName as k}from"./Directions/support/directionsUtils.js";import{isArcGISWorldGeocoder as I,meteredArcGISLocatorUrl as F}from"./Search/support/locatorUtils.js";import{loadCalciteComponents as T}from"./support/componentsUtils.js";import{globalCss as x}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as D}from"./support/decorators/messageBundle.js";import{tsx as E}from"./support/jsxFactory.js";function $(e){const{branchName:i,displayText:s,exitName:o,intersectingName:r,name:a,towardName:n}=e;if(null==s)return null;const l=[i,o,r,a,n].filter(t).sort(((e,t)=>t.length-e.length)).map((e=>c(e)));if(!l.length)return s;const d=new RegExp(l.join("|"),"g"),m=s.matchAll(d);let p=0;const h=[];for(const{0:t,index:c}of m)h.push(s.slice(p,c),E("span",{class:L.labelEmphasize,key:`maneuver-${c}`},t)),p=c+t.length;return h.push(s.slice(p)),E("span",null,h)}const C="esri-directions",L={base:C,accordion:`${C}__accordion`,actionContainer:`${C}__action-container`,addStopButton:`${C}__add-stop-button`,departureTime:`${C}__departure-time`,departureTimeOptions:`${C}__departure-time-options`,directionsHeader:`${C}__directions-header`,directionsHeaderStopName:`${C}__directions-header-stop-name`,editFooter:`${C}__edit-footer`,editToolbar:`${C}__edit-toolbar`,editToolbarContainer:`${C}__edit-toolbar-container`,flexColumn:`${C}__flex-column`,flexRow:`${C}__flex-row`,headerStops:`${C}__header-stops`,labelEmphasize:`${C}__label-emphasize`,labelNoBottomMargin:`${C}__label-no-bottom-margin`,marginInlineMedium:`${C}__margin-inline-medium`,optimizeSection:`${C}__optimize-section`,optimizeSwitches:`${C}__optimize-switches`,paddingMedium:`${C}__padding-medium`,primaryFlowItem:`${C}__primary-flow-item`,primaryFooter:`${C}__primary-footer`,primaryFooterCentered:`${C}__primary-footer-centered`,primaryFooterLoader:`${C}__primary-footer-loader`,routeItem:`${C}__route-item`,routeItemButton:`${C}__route-item-button`,routeItemButtonContent:`${C}__route-item-button-content`,routeItemLabel:`${C}__route-item-label`,routeItemDescription:`${C}__route-item-description`,saveError:`${C}__save-error`,saveErrorIcon:`${C}__save-error-icon`,saveErrorLabel:`${C}__save-error-label`,saveProcessLoader:`${C}__save-process-loader`,selectedFeatureContainer:`${C}__selected-feature-container`,separator:`${C}__separator`,solveRoute:`${C}__solve-route`,stopContainer:`${C}__stop-container`,stopList:`${C}__stop-list`,stopItem:`${C}__stop-item`};let R=class extends g{constructor(e,t){super(e,t),this._activeManeuver=null,this._placeholderStops=new i([new u,new u]),this._portalFolderCombobox=null,this._portalFolders=null,this._portalItemNameInput=null,this._portalUserName=null,this._sections=null,this._stopsToSearches=new Map,this._currentFlowItem="primary",this._parentFlowItem="primary",this._saveState="initialized",this._searchTool=null,this.headingLevel=2,this.messages=null,this.messagesUnits=null,this.searchProperties=null,this.viewModel=new y,this.visibleElements=new b,this._solveRouteDebounced=o((()=>this._solveRoute()))}initialize(){this.addHandles([a((()=>this.viewModel.layer),(()=>{try{this.viewModel.load()}catch{}}),n),a((()=>this.viewModel.layer?.routeInfo),(()=>{this._sections=this._getStopSections()}),n),a((()=>this.viewModel.layer?.stops.toArray()),(e=>{e&&this.view?.activeTool&&this._searchTool&&this.view.activeTool===this._searchTool&&!e.includes(this._searchTool.stop)&&(this.view.tools.remove(this._searchTool),this._searchTool=null)}))])}loadDependencies(){return T({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"block-section":()=>import("@esri/calcite-components/dist/components/calcite-block-section"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch")})}get apiKey(){return this.viewModel.apiKey}set apiKey(e){this.viewModel.apiKey=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"right"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get lastRoute(){return this.viewModel.lastRoute}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get maxStops(){return this.viewModel.maxStops}set maxStops(e){this.viewModel.maxStops=e}get unit(){return this.defaultUnit}set unit(e){this._overrideIfSome("unit",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e);return i.view=t,this._overrideDefaultSources(i),i}const i=new _({icon:!1,popupEnabled:!1,resultGraphicEnabled:!1,view:t,...this.searchProperties});return this._normalizeSearchSources(i),this.addHandles([l((()=>i.allSources),"change",(()=>this._normalizeSearchSources(i))),i.on("search-clear",(()=>{e.geometry=null,e.name=null,this.viewModel.layer?.removeResult()})),i.on("select-result",(()=>{const t=i.selectedResult;e.geometry=t?.feature.geometry,e.name=t?.name,this._solveRouteDebounced()})),a((()=>i.searchTerm),(t=>{e.name=t}))],i),this._stopsToSearches.set(e,i),i}getDirections(){return this.viewModel.getDirections()}render(){return E("div",{class:this.classes(L.base,x.widget,x.panel)},E("calcite-flow",null,this._renderPrimaryFlowItem(),this._renderDirectionsFlowItem(),this._renderEditFlowItem(),this._renderSaveFlowItem()))}save(){return this.viewModel.save()}saveAs(e,t={}){return this.viewModel.saveAs(e,t)}zoomToRoute(){return this.viewModel.zoomToRoute()}_applyLocatorSourceOverrides({allSources:e}){for(const t of e)"url"in t&&t.url&&(t.locationType??="street",I(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=F))}_disposeSearch(e){if(!e||!this._stopsToSearches.has(e))return;const t=this._stopsToSearches.get(e);this.removeHandles(t),t.destroy(),this._stopsToSearches.delete(e)}_getEffectiveStops(){return this.viewModel.layer?.stops??this._placeholderStops}_getErrorDescription(){switch(this.viewModel.lastError?.name){case"directions-view-model:unable-to-route":return this.messages.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return this.messages.errors.unableToLoadServiceMetadata;default:return this.messages.errors.unknownError}}_getNetworkFeatureName(e){switch(e.type){case"stop":switch(e.locationType){case"stop":default:return this.messages.networkFeatures.stops.stop;case"waypoint":return this.messages.networkFeatures.stops.waypoint;case"break":return this.messages.networkFeatures.stops.break}case"point-barrier":return this.messages.networkFeatures.pointBarrier;case"polyline-barrier":return this.messages.networkFeatures.polylineBarrier;case"polygon-barrier":return this.messages.networkFeatures.polygonBarrier}}_getRouteCostSummary(){const e=this.viewModel.layer?.routeInfo;if(!e)return null;const t=e.totalDistance??0,i=e.totalDuration??0,{messagesUnits:s,unit:o}=this;return{distance:f(s,t,o),duration:S(i)}}_getStopSections(){if(!this.viewModel.layer)return null;const{directionPoints:e,directionLines:t,stops:i}=this.viewModel.layer;if(!e||!t)return null;const s=[];let o=null;for(const r of e){const{objectId:e,stopId:a}=r;if(null!=a){const e=i.find((({objectId:e})=>e===a));o&&o.stop===e||(o={stop:e,directions:[]},s.push(o));continue}if(null==o)continue;const n=t.find((({directionPointId:t})=>t===e));null!=n&&o.directions.push({directionPoint:r,directionLine:n})}return s}_handleLocateStopAction(e){const{view:t}=this;if(!t)return;const i="directions-search-tool";this.removeHandles(i),this._searchTool=new w({stop:e,view:t}),this.addHandles([this._searchTool.on("click",(async t=>{if(t.mapPoint&&this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e),s=await i.search(t.mapPoint),o=s?.results?.[0].results?.[0];if(o){const{feature:t,name:s}=o;i.searchTerm=s,e.geometry=t.geometry}}this.removeHandles(i)})),s((()=>{this._searchTool&&(this.view?.tools.remove(this._searchTool),this._searchTool=null)}))],i),t.addAndActivateTool(this._searchTool)}_handleEditingDoneClick(){this.viewModel.stopEditing(),this._currentFlowItem="primary"}async _handleSaveLayerAsAction(){const e=p.getDefault();try{await e.signIn()}catch(t){if(r(t)||"identity-manager:user-aborted"===t.name)return;return this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",void(this._saveState="connect-to-portal-error")}this._saveState="fetch-portal-information",this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",this._portalUserName=e.user?.username;try{this._portalFolders=await(e.user?.fetchFolders())}catch{return void(this._saveState="fetch-portal-information-error")}this._saveState="save-layer"}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){for(const t of e.viewModel.defaultSources)t.autoNavigate=!1}_renderClearRouteAction(e){return E("calcite-action",{icon:"trash",key:"clear-route",onclick:()=>{this._currentFlowItem="primary",this.viewModel.reset()},...e,text:this.messages.common.clear,textEnabled:!0})}_renderDeleteStopAction(e){const t=this._getEffectiveStops();return E("calcite-action",{icon:"trash",onclick:()=>{t.remove(e),this._disposeSearch(e),this._solveRouteDebounced()},scale:"s",slot:"actions-end",text:this.messages.deleteStop,title:this.messages.deleteStop})}_renderDepartureTime(){const{DEPART_AT:e,NOW:t,UNSPECIFIED:i}=M;return E("calcite-label",{class:L.departureTime,key:"departure-time"},this.messages.departureTime,E("calcite-combobox",{clearDisabled:!0,label:this.messages.departureTime,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{const{selectedItems:t}=e;t.length&&(this.viewModel.departureOption=t[0].value,this._solveRouteDebounced())}},E("calcite-combobox-item",{heading:this.messages.leaveNow,key:t,label:this.messages.leaveNow,selected:this.viewModel.departureOption===t,value:t}),E("calcite-combobox-item",{heading:this.messages.departAt,key:e,label:this.messages.departAt,selected:this.viewModel.departureOption===e,value:e}),E("calcite-combobox-item",{heading:this.messages.timeUnspecified,key:i,label:this.messages.timeUnspecified,selected:this.viewModel.departureOption===i,value:i})))}_renderDepartureTimeOptions(){return this.viewModel.departureOption!==M.DEPART_AT?null:E("div",{class:L.departureTimeOptions},E("calcite-input-date-picker",{scale:"s",value:this.viewModel.departureIsoDate,onCalciteInputDatePickerChange:({currentTarget:{value:e}})=>{Array.isArray(e)||(this.viewModel.departureIsoDate=e,this._solveRouteDebounced())}}),E("calcite-input-time-picker",{scale:"s",value:this.viewModel.departureIsoTime,onCalciteInputTimePickerClose:({currentTarget:{value:e}})=>{this.viewModel.departureIsoTime=e,this._solveRouteDebounced()}}))}_renderDirectionsFlowItem(){if("directions"!==this._currentFlowItem)return null;const e=this._getRouteCostSummary();if(!this._sections||!e)return null;const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel,o=this._sections.at(0)?.stop.name??"",r=this._sections.at(-1)?.stop.name??"";return E("calcite-flow-item",{key:"directions-flow-item",overlayPositioning:"fixed",selected:"directions"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this._currentFlowItem="primary"}},E("div",{class:L.directionsHeader,slot:"header-content"},E("div",{class:L.headerStops},E("span",null,this.messages.from)," ",E("span",{class:L.directionsHeaderStopName},o),E("span",null,this.messages.to)," ",E("span",{class:L.directionsHeaderStopName},r)),E("div",{class:L.flexColumn},E("span",null,`${i} (${t})`),s?E("span",null,s):null)),this._renderRouteLayerActions({slot:"header-menu-actions"}),E("calcite-accordion",{class:L.accordion,iconPosition:"start",selectionMode:"single"},this._sections.map(((e,t)=>{const{stop:i,directions:s}=e,{name:o}=i;return E("calcite-accordion-item",{expanded:0===t,heading:o??"",key:`stop-${t}`},E("calcite-action",{icon:"zoom-to-object",onclick:()=>{this.viewModel.centerAt(i)},slot:"actions-end",text:this.messages.panToStop}),this._renderDirectionTurns(s))}))))}_renderDirectionTurns(e){return E("calcite-list",{label:this.messages.drivingDirections,selectionMode:"none"},e.map(((e,t)=>{const{directionPoint:i,directionLine:s}=e,{distance:o,duration:r}=s,a=f(this.messagesUnits,o??0,this.unit),n=S(r??0),l=a&&n?`${a} | ${n}`:`${a||n}`,c=$(i),d=k(i.directionPointType);return E("calcite-list-item",{class:L.labelNoBottomMargin,key:`driving-direction-${t}`,onpointerenter:()=>{this.viewModel.highlight(s)},onpointerleave:()=>{this.viewModel.clearHighlights()},onCalciteListItemSelect:()=>{this._activeManeuver===s?this.zoomToRoute():(this._activeManeuver=s,this.viewModel.centerAt(s.geometry))}},E("calcite-icon",{icon:d,slot:"content-start"}),E("div",{slot:"content"},E("calcite-label",{layout:"inline",scale:"s"},c),E("calcite-label",{layout:"inline",scale:"s"},l)))})))}_renderEditFlowItem(){return"edit"!==this._currentFlowItem?null:E("calcite-flow-item",{heading:this.messages.editRoute,headingLevel:this.headingLevel,key:"edit-flow-item",loading:"routing"===this.viewModel.state,selected:"edit"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem="primary"}},E("div",{class:L.flexColumn,key:"edit-container"},E("div",{class:L.editToolbarContainer},E("calcite-label",{layout:"inline",scale:"s"},this.messages.automaticallySolve,E("calcite-switch",{checked:this.viewModel.autoSolve,scale:"s",onCalciteSwitchChange:e=>{this.viewModel.autoSolve=e.target.checked}})),E("div",{class:L.editToolbar},E("calcite-action",{icon:"flag",onclick:()=>{this.viewModel.create("stop")},scale:"s",text:this.messages.networkFeatures.stops.stop,textEnabled:!0}),E("calcite-action",{icon:"line",onclick:()=>{this.viewModel.create("polyline-barrier")},scale:"s",text:this.messages.barrier,textEnabled:!0}),E("calcite-action",{class:L.solveRoute,disabled:this.viewModel.autoSolve,icon:"refresh",onclick:()=>{this._solveRouteDebounced()},scale:"s",text:this.messages.solve,textEnabled:!0}))),E("div",{class:L.selectedFeatureContainer},E("calcite-list",{label:this.messages.selectedNetworkFeatures,scale:"s",selectionMode:"none"},this.viewModel.selectedNetworkFeatures?.toArray().map(((e,t)=>E("calcite-list-item",{description:this._getNetworkFeatureName(e),key:`network-feature-${t}`,label:e.name??e.objectId?.toString()??this.messages.unnamed},E("calcite-action",{icon:"trash",onclick:()=>{this.viewModel.remove(e)},scale:"s",slot:"actions-end",text:this.messages.common.delete})))))),E("div",{class:L.editFooter},this._renderEditFooterContent())))}_renderEditFooterContent(){return this.viewModel.lastError?this._renderErrorNotice():E("calcite-button",{appearance:"outline-fill",bind:this,onclick:this._handleEditingDoneClick,width:"full"},this.messages.common.done)}_renderErrorNotice(){return E("calcite-notice",{icon:"exclamation-mark-circle",kind:"danger",open:!0},E("calcite-label",{class:L.labelNoBottomMargin,slot:"message"},this._getErrorDescription()))}_renderFooter(){if(!this.viewModel.layer)return E("div",{class:L.primaryFooter,key:"footer-missing-layer"},E("calcite-notice",{icon:"information",open:!0},E("calcite-label",{class:L.labelNoBottomMargin,slot:"message"},this.messages.missingLayer)));if("unauthenticated"===this.viewModel.state)return E("div",{class:L.primaryFooterCentered,key:"footer-sign-in"},E("calcite-label",null,this.messages.signInRequired),E("calcite-button",{onclick:()=>{this.viewModel.load().catch((()=>{}))}},this.messages.common.auth.signIn));if("routing"===this.viewModel.state)return E("div",{class:this.classes(L.primaryFooter,L.primaryFooterLoader),key:"footer-routing"},E("calcite-loader",{label:this.messages.solve,scale:"s"}));if("error"===this.viewModel.state)return E("div",{class:L.primaryFooter,key:"footer-service-error"},this._renderErrorNotice());if(!this.viewModel.layer?.routeInfo)return E("div",{class:L.primaryFooter,key:"footer-unsolved-route"},E("calcite-notice",{icon:"information",open:!0},E("calcite-label",{class:L.labelNoBottomMargin,slot:"message"},this.messages.directionsPlaceholder)));const e=this._getRouteCostSummary();if(!e||!this.viewModel.layer?.directionPoints)return E("div",{class:L.primaryFooter,key:"footer-invalid-route"},E("calcite-notice",{icon:"exclamation-mark-triangle",kind:"danger",open:!0},E("calcite-label",{class:L.labelNoBottomMargin,slot:"message"},this.messages.invalidRoute)));const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel;return E("div",{class:L.routeItem,key:"footer-directions-summary"},E("button",{"aria-busy":"false","aria-label":this.messages.viewDrivingDirections,"aria-live":"polite",class:L.routeItemButton,onclick:()=>{this._currentFlowItem="directions"},type:"button"},E("div",{class:L.routeItemButtonContent},E("span",{class:L.routeItemLabel},`${i} (${t})`),E("span",{class:L.routeItemDescription},s)),E("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s"})),E("calcite-dropdown",null,E("calcite-action",{icon:"ellipsis",slot:"trigger",text:"Route actions"}),this._renderRouteLayerActions()))}_renderInteractiveRouteActions(){return E("div",{class:L.actionContainer,key:"interactive-route-action-container"},E("calcite-button",{appearance:"outline",class:L.addStopButton,disabled:this._getEffectiveStops().length>=this.maxStops,iconStart:"plus",kind:"neutral",label:this.messages.addStop,onclick:()=>{const e=new v;this.viewModel.layer?.stops.add(new u({symbol:e}))},width:"half"},this.messages.addStop),E("calcite-button",{appearance:"outline",disabled:"2d"!==this.viewModel.view?.type,iconStart:"pencil",kind:"neutral",label:this.messages.editRoute,onclick:()=>{this._currentFlowItem="edit",this.viewModel.startEditing()},width:"half"},this.messages.editRoute))}_renderLocateStopAction(e){if(null!=e.name||null!=e.geometry)return null;const t=this._getEffectiveStops().indexOf(e),i=!!this.view?.activeTool&&this.view.activeTool===this._searchTool&&this._searchTool.stop===e;return E("calcite-action",{active:i,icon:"crosshair",key:`stop-location-action-${t}`,onclick:()=>this._handleLocateStopAction(e),scale:"s",slot:"actions-end",text:this.messages.pickALocationOnTheMap,title:this.messages.pickALocationOnTheMap})}_renderOptimizeStopOrder(){const{routeParameters:e}=this.viewModel,{findBestSequence:t,preserveFirstStop:i,preserveLastStop:s}=e;return E("calcite-block-section",{class:L.optimizeSection,text:this.messages.optimizeOrder,toggleDisplay:"switch",onCalciteBlockSectionToggle:({target:t})=>{e.findBestSequence=t.open,t.open||this._resetStopSequence(),this._solveRouteDebounced()}},t?[E("calcite-label",{class:L.optimizeSwitches,key:"preserve-first-stop",layout:"inline-space-between"},this.messages.preserveFirstStop,E("calcite-switch",{checked:i,scale:"s",onCalciteSwitchChange:({target:{checked:t}})=>{e.preserveFirstStop=t,this._resetStopSequence(),this._solveRouteDebounced()}})),E("calcite-label",{class:L.optimizeSwitches,key:"preserve-last-stop",layout:"inline-space-between"},this.messages.preserveLastStop,E("calcite-switch",{checked:s,scale:"s",onCalciteSwitchChange:({target:{checked:t}})=>{e.preserveLastStop=t,this._resetStopSequence(),this._solveRouteDebounced()}}))]:null)}_renderPrimaryFlowItem(){return E("calcite-flow-item",{key:"primary-flow-item",loading:"initializing"===this.viewModel.state,selected:"primary"===this._currentFlowItem},E("calcite-panel",{class:L.primaryFlowItem,disabled:!this.viewModel.layer||"unauthenticated"===this.viewModel.state||"error"===this.viewModel.state&&!this.viewModel.serviceDescription},this._renderStops(),this._renderInteractiveRouteActions(),this._renderSeparator(),this._renderRouteSolveOptions()),this._renderFooter())}_renderRouteLayerActions(e){return[this._renderClearRouteAction(e),this._renderSaveLayerAction(e),this._renderSaveLayerAsAction(e),this._renderViewItemDetailsAction(e)]}_renderRouteSolveOptions(){return E("div",{class:L.marginInlineMedium,key:"route-solve-options"},this._renderTravelModes(),this._renderDepartureTime(),this._renderDepartureTimeOptions(),this._renderOptimizeStopOrder())}_renderSaveContent(){switch(this._saveState){case"initialized":return this._renderSaveInitialized();case"connect-to-portal":return this._renderSaveProcessing(this.messages.identity.lblSigning);case"connect-to-portal-error":return this._renderSaveError(this.messages.errors.authenticating);case"fetch-portal-information":return this._renderSaveProcessing(this.messages.processing.fetching);case"fetch-portal-information-error":return this._renderSaveError(this.messages.errors.fetching);case"save-layer":return this._renderSaveLayerSettings();case"saving":return this._renderSaveProcessing(this.messages.processing.saving);case"saving-error":return this._renderSaveError(this.messages.errors.saving)}}_renderSaveError(e){return E("calcite-panel",{class:L.paddingMedium,key:"save-layer-error"},E("div",{class:L.saveError},E("calcite-icon",{class:L.saveErrorIcon,icon:"exclamation-mark-triangle",scale:"l",textLabel:this.messages.common.errorMessage}),E("calcite-label",{class:L.saveErrorLabel},e)),E("calcite-button",{appearance:"outline",onclick:()=>{this._currentFlowItem=this._parentFlowItem},slot:"footer-actions",width:"full"},this.messages.common.close))}_renderSaveInitialized(){return E("calcite-panel",{class:L.paddingMedium,key:"save-layer-initialized"})}_renderSaveFlowItem(){return"save"!==this._currentFlowItem?null:E("calcite-flow-item",{heading:this.messages.saveLayer,headingLevel:this.headingLevel,key:"save-layer-flow-item",selected:"save"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this._currentFlowItem=this._parentFlowItem}},this._renderSaveContent())}_renderSaveLayerAction(e){if(!this.visibleElements.saveButton)return null;const t=this.viewModel.layer,i=t?.routeInfo,s=t?.portalItem?.itemControl;return E("calcite-action",{disabled:!(!!i&&("admin"===s||"update"===s)),icon:"save",key:"save-route",onclick:()=>{this.viewModel.layer?.save()},...e,text:this.messages.common.save,textEnabled:!0})}_renderSaveLayerAsAction(e){if(!this.visibleElements.saveAsButton)return null;const t=!this.viewModel.layer?.routeInfo;return E("calcite-action",{disabled:t,icon:"save-as",key:"save-as-route",onclick:()=>{this._handleSaveLayerAsAction()},...e,text:this.messages.common.saveAs,textEnabled:!0})}_renderSaveLayerSettings(){if(null==this.layer||null==this._portalFolders||null==this._portalUserName)return this._renderSaveInitialized();const{stops:e}=this.layer,t=`${e.at(0).name} - ${e.at(-1).name}`,i=[E("calcite-combobox-item",{heading:`${this._portalUserName} (${this.messages.common.home})`,key:`${C}-folder-home`,selected:!0,value:`${C}-folder-home`}),...this._portalFolders.map((e=>E("calcite-combobox-item",{heading:e.title??"",key:`${C}-folder-${e.id}`,value:e.id})))];return E("calcite-panel",{key:"save-layer-panel"},E("div",{class:L.paddingMedium},E("calcite-label",null,this.messages.laverName,E("calcite-input",{afterCreate:e=>{this._portalItemNameInput=e},label:this.messages.laverName,value:t})),E("calcite-label",null,this.messages.saveInFolder,E("calcite-combobox",{afterCreate:e=>{this._portalFolderCombobox=e},clearDisabled:!0,label:this.messages.saveInFolder,overlayPositioning:"fixed",selectionMode:"single"},i))),E("calcite-button",{onclick:()=>{if(this._saveState="saving",null==this.layer||null==this._portalFolders)return;const e=this._portalItemNameInput?.value,t=this._portalFolderCombobox?.value,i=this._portalFolders.find((({id:e})=>e===t));this.layer.saveAs({title:e},{folder:i}).then((()=>{this._currentFlowItem=this._parentFlowItem})).catch((()=>{this._saveState="saving-error"}))},slot:"footer-actions",width:"full"},this.messages.common.save),E("calcite-button",{appearance:"outline",onclick:()=>{this._currentFlowItem=this._parentFlowItem},slot:"footer-actions",width:"full"},this.messages.common.cancel))}_renderSaveProcessing(e){return E("calcite-panel",{class:L.marginInlineMedium,key:"save-layer-processing"},E("calcite-loader",{class:L.saveProcessLoader,label:e,text:e}))}_renderSeparator(){return E("div",{class:L.separator})}_renderStop(e){const t=this.acquireSearch(e);null!=e.name&&(t.searchTerm=e.name);const i=this._getEffectiveStops(),s=this._renderLocateStopAction(e),o=i.length>2&&this._renderDeleteStopAction(e);return E("calcite-list-item",{key:e,value:e},s,o,E("div",{class:L.stopItem,slot:"content"},t.render()))}_renderStops(){const e=this._getEffectiveStops();for(const t of this._stopsToSearches.keys())e.includes(t)||this._disposeSearch(t);return E("div",{class:L.stopContainer,key:L.stopContainer},E("calcite-list",{class:L.stopList,dragEnabled:!0,label:this.messages.widgetLabel,scale:"s",onCalciteListOrderChange:({detail:t})=>{e.reorder(t.dragEl.value,t.newIndex),this._resetStopSequence(),this._solveRouteDebounced()}},e.toArray().map((e=>this._renderStop(e)))),2===e.length&&E("calcite-action",{icon:"arrow-up-down",onclick:()=>{e.reverse(),this._resetStopSequence(),this._solveRouteDebounced()},scale:"s",text:this.messages.reverseStops}))}_renderTravelModes(){return this.viewModel.travelModes.length?E("calcite-label",{key:"travel-modes"},this.messages.mode,E("calcite-combobox",{clearDisabled:!0,label:this.messages.mode,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{const{selectedItems:t}=e;t.length&&(this.viewModel.selectedTravelMode=t[0].value,this._solveRouteDebounced())}},this.viewModel.travelModes.map((e=>E("calcite-combobox-item",{heading:e.name,key:e.id,label:e.name,selected:this.viewModel.selectedTravelMode?.id===e.id,value:e}))))):null}_renderViewItemDetailsAction(e){if(!this.visibleElements.layerDetails)return null;const t=this.viewModel.layer?.portalItem;return E("calcite-action",{disabled:!t,icon:"launch",key:"open-route-details-link",onclick:()=>{t&&window.open(`${t.portal.url}/home/item.html?id=${t.id}`,"_blank")},...e,text:this.messages.viewLayerDetails,textEnabled:!0})}_resetStopSequence(){this.viewModel.layer?.stops.forEach((e=>{e.sequence=null}))}async _solveRoute(){this.viewModel.updateDepartureTime();if(!((this.viewModel.layer?.stops.filter((({geometry:e})=>!!e)).length??0)<2))try{await this.viewModel.getDirections()}catch{}}};e([d()],R.prototype,"_currentFlowItem",void 0),e([d()],R.prototype,"_saveState",void 0),e([d()],R.prototype,"_searchTool",void 0),e([d()],R.prototype,"apiKey",null),e([d(h)],R.prototype,"defaultUnit",void 0),e([d()],R.prototype,"goToOverride",null),e([d()],R.prototype,"headingLevel",void 0),e([d()],R.prototype,"icon",null),e([d()],R.prototype,"label",null),e([d({readOnly:!0})],R.prototype,"lastRoute",null),e([d()],R.prototype,"layer",null),e([d()],R.prototype,"maxStops",null),e([d(),D("esri/widgets/Directions/t9n/Directions")],R.prototype,"messages",void 0),e([d(),D("esri/core/t9n/Units")],R.prototype,"messagesUnits",void 0),e([d()],R.prototype,"searchProperties",void 0),e([d()],R.prototype,"unit",null),e([d()],R.prototype,"view",null),e([d({type:y})],R.prototype,"viewModel",void 0),e([d({type:b,nonNullable:!0})],R.prototype,"visibleElements",void 0),R=e([m("esri.widgets.Directions")],R);const A=R;export{A 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.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{makeHandle as i,abortHandle as o}from"../../core/handleUtils.js";import{isAborted as s}from"../../core/promiseUtils.js";import{watch as r}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{isSubtypeSublayer as n}from"../../layers/support/layerUtils.js";import{createFeatureServices as d}from"../../rest/featureService/utils.js";import c from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as p}from"../../views/support/HighlightDefaults.js";import u from"./AddAssociationWorkflowData.js";import w from"./Workflow.js";import{fetchFullFeature as m}from"./workflowUtils.js";import h from"../FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js";var y;const f={exit:Symbol()};let A=y=class extends w{constructor(e){super(e),this._utilityNetworkAssociationAddAssociationViewModel=new h,this._highlightHelper=null,this.fullFeature=null,this.type="add-association"}initialize(){const{data:e}=this,{feature:r}=e,{view:a}=e.viewModel;a&&(this._highlightHelper=new c({view:a,highlightName:p}),this.addHandles(i((()=>this._highlightHelper?.removeAll()))));const l=new AbortController;this.addHandles(o(l)),this._updatingHandles.addPromise(m(r,e.viewModel.view.spatialReference,l.signal).then((e=>{s(l)||(this.fullFeature=e,this._initializeUtilityNetworkAssociationAddAssociationViewModel())}),(e=>this.cancel({force:!0,error:new t("editor:failed-to-fetch-full-feature","Failed to retrieve all information for this feature. The update cannot proceed.",{detail:{error:e}})}))))}get editorItem(){return this.data.editorItem}get featureFormViewModel(){return this._featureFormViewModel}get utilityNetworkAssociationAddAssociationViewModel(){return this._utilityNetworkAssociationAddAssociationViewModel}get hasPendingEdits(){return!!this._utilityNetworkAssociationAddAssociationViewModel.selectedFeature}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get reliesOnOwnerAdminPrivileges(){return this.editorItem.capabilities.create.reliesOnOwnerAdminPrivileges}async enter(){this._initializeUtilityNetworkAssociationAddAssociationViewModel()}exit(){this.removeHandles(f.exit)}async start(){return await super.start(),null}_initializeUtilityNetworkAssociationAddAssociationViewModel(){const{viewModel:{view:e},utilityNetwork:t,associationType:i}=this.data,o=this._utilityNetworkAssociationAddAssociationViewModel;o.graphic=this.fullFeature,o.map=e?.map,o.utilityNetwork=t,o.layer=this.layer,o.associationType=i,this.addHandles([r((()=>o.selectedLayer),(e=>{e&&this.go("add-association-select-feature")})),r((()=>o.selectedFeature),(e=>{e&&this.go("add-association-create-association")}))],f.exit)}static async create(e){const t=new y({data:await u.create(e),onCommit:this._onCommitFactory(e.applyEditsFeatureService)});return t._set("steps",this._createWorkflowSteps(t)),t}static _createWorkflowSteps(e){return[{id:"add-association-select-layer",async setUp(){const{utilityNetworkAssociationAddAssociationViewModel:t}=e.data.viewModel;t&&(t.filterOptionsVisible?t.filterOptionsVisible=!1:t.selectedLayer=null)},async tearDown(){}},{id:"add-association-select-feature",async setUp(){const{utilityNetworkAssociationAddAssociationViewModel:t}=e.data.viewModel;t&&(t.selectedFeature=null)},async tearDown(){}},{id:"add-association-create-association",async setUp(){},async tearDown(){}}]}};A._onCommitFactory=e=>async i=>{const{feature:o,utilityNetwork:s,associationInput:r}=i,{utilityNetworkAssociationAddAssociationViewModel:a}=i.viewModel,{association:l}=a,c=s?.generateAddAssociations([l]);if(!c)throw new t("editor:failed-to-add-association","Could not create payload needed to add association");const p=o.sourceLayer,u=n(p)&&p.parent?p.parent:p,w=d([u]),m=w.values().next().value?.featureService;if(!m)throw new t("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(m?.load());const h=s?.gdbVersion??void 0;await e(m,[c],{gdbVersion:h}),await r.refresh()},e([a()],A.prototype,"_utilityNetworkAssociationAddAssociationViewModel",void 0),e([a()],A.prototype,"_featureFormViewModel",void 0),e([a()],A.prototype,"editorItem",null),e([a()],A.prototype,"featureFormViewModel",null),e([a()],A.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([a()],A.prototype,"fullFeature",void 0),e([a()],A.prototype,"hasPendingEdits",null),e([a()],A.prototype,"layer",null),e([a()],A.prototype,"parent",null),e([a()],A.prototype,"parentLayer",null),e([a()],A.prototype,"reliesOnOwnerAdminPrivileges",null),A=y=e([l("esri.widgets.Editor.AddAssociationWorkflow")],A);export{A as AddAssociationWorkflow};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{makeHandle as i,abortHandle as o}from"../../core/handleUtils.js";import{isAborted as s}from"../../core/promiseUtils.js";import{watch as r}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{isSubtypeSublayer as l}from"../../layers/support/layerUtils.js";import{createFeatureServices as d}from"../../rest/featureService/utils.js";import c from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as u}from"../../views/support/HighlightDefaults.js";import p from"./AddAssociationWorkflowData.js";import w from"./Workflow.js";import{fetchFullFeature as m}from"./workflowUtils.js";import y from"../FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js";import{getFeatureTitle as h}from"../support/UtilityNetworkAssociations/utilityNetworkUtils.js";var A;const f={exit:Symbol()};let g=A=class extends w{constructor(e){super(e),this._utilityNetworkAssociationAddAssociationViewModel=new y,this._highlightHelper=null,this.sourceFeatureItem=null,this.type="add-association"}initialize(){const{data:e}=this,{view:t}=e.viewModel;t&&(this._highlightHelper=new c({view:t,highlightName:u}),this.addHandles(i((()=>this._highlightHelper?.removeAll()))));const s=new AbortController;this.addHandles(o(s)),this._updatingHandles.addPromise(this._setup(s))}get editorItem(){return this.data.editorItem}get featureFormViewModel(){return this._featureFormViewModel}get utilityNetworkAssociationAddAssociationViewModel(){return this._utilityNetworkAssociationAddAssociationViewModel}get hasPendingEdits(){return!!this._utilityNetworkAssociationAddAssociationViewModel.selectedFeature}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get reliesOnOwnerAdminPrivileges(){return this.editorItem.capabilities.create.reliesOnOwnerAdminPrivileges}async enter(){this._initializeUtilityNetworkAssociationAddAssociationViewModel()}exit(){this.removeHandles(f.exit)}async start(){return await super.start(),null}async _setup(e){const{data:i}=this,{feature:o}=i;try{const t=await m(o,i.viewModel.view.spatialReference,e.signal);if(s(e))return;const r=t.sourceLayer&&"getFeatureTitle"in t.sourceLayer?await t.sourceLayer.getFeatureTitle(t):h(t);if(s(e))return;this.sourceFeatureItem={feature:o,label:r},this._initializeUtilityNetworkAssociationAddAssociationViewModel()}catch(r){this.cancel({force:!0,error:new t("editor:failed-to-fetch-full-feature","Failed to retrieve all information for this feature. The update cannot proceed.",{detail:{error:r}})})}}_initializeUtilityNetworkAssociationAddAssociationViewModel(){const{viewModel:{view:e},utilityNetwork:t,associationType:i}=this.data,o=this._utilityNetworkAssociationAddAssociationViewModel;o.graphic=this.sourceFeatureItem.feature,o.map=e?.map,o.utilityNetwork=t,o.layer=this.layer,o.associationType=i,this.addHandles([r((()=>o.selectedLayer),(e=>{e&&this.go("add-association-select-feature")})),r((()=>o.selectedFeature),(e=>{e&&this.go("add-association-create-association")}))],f.exit)}static async create(e){const t=new A({data:await p.create(e),onCommit:this._onCommitFactory(e.applyEditsFeatureService)});return t._set("steps",this._createWorkflowSteps(t)),t}static _createWorkflowSteps(e){return[{id:"add-association-select-layer",async setUp(){const{utilityNetworkAssociationAddAssociationViewModel:t}=e.data.viewModel;t&&(t.selectedLayer=null,t.selectedFeature=null,t.association=null)},async tearDown(){}},{id:"add-association-select-feature",async setUp(){const{utilityNetworkAssociationAddAssociationViewModel:t}=e.data.viewModel;t&&(t.selectedFeature=null,t.association=null)},async tearDown(){}},{id:"add-association-create-association",async setUp(){},async tearDown(){}}]}};g._onCommitFactory=e=>async i=>{const{feature:o,utilityNetwork:s,associationInput:r}=i,{utilityNetworkAssociationAddAssociationViewModel:a}=i.viewModel,{association:n}=a,c=s?.generateAddAssociations([n]);if(!c)throw new t("editor:failed-to-add-association","Could not create payload needed to add association");const u=o.sourceLayer,p=l(u)&&u.parent?u.parent:u,w=d([p]),m=w.values().next().value?.featureService;if(!m)throw new t("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(m?.load());const y=s?.gdbVersion??void 0;await e(m,[c],{gdbVersion:y}),await r.refresh()},e([a()],g.prototype,"_utilityNetworkAssociationAddAssociationViewModel",void 0),e([a()],g.prototype,"_featureFormViewModel",void 0),e([a()],g.prototype,"editorItem",null),e([a()],g.prototype,"featureFormViewModel",null),e([a()],g.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([a()],g.prototype,"sourceFeatureItem",void 0),e([a()],g.prototype,"hasPendingEdits",null),e([a()],g.prototype,"layer",null),e([a()],g.prototype,"parent",null),e([a()],g.prototype,"parentLayer",null),e([a()],g.prototype,"reliesOnOwnerAdminPrivileges",null),g=A=e([n("esri.widgets.Editor.AddAssociationWorkflow")],g);export{g as AddAssociationWorkflow};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import{removeMaybe as o,destroyMaybe as n}from"../../core/maybe.js";import{isPromiseLike as l,debounce as d}from"../../core/promiseUtils.js";import{watch as c,when as u,initial as h,whenOnce as p,syncAndInitial as m}from"../../core/reactiveUtils.js";import{generateBracedUUID as f}from"../../core/uuid.js";import{property as w}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as g}from"../../core/accessorSupport/decorators/subclass.js";import{isSharedTemplate as y,isSharedTemplateOrMetadata as v}from"../../editing/templateUtils.js";import{createTemplateExecutor as F}from"../../editing/sharedTemplates/executor/createTemplateExecutor.js";import _ from"../../layers/GraphicsLayer.js";import{isTable as b}from"../../layers/support/layerUtils.js";import{getDisplayedSymbol as M}from"../../symbols/support/symbolUtils.js";import{getDrawHelpMessage as V}from"../../views/draw/support/helpMessageUtils.js";import I from"../../views/draw/support/HighlightHelper.js";import k from"../../views/interactive/sketch/SketchOptions.js";import S from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as C}from"../../views/support/HighlightDefaults.js";import P from"./CreateFeaturesWorkflowData.js";import{isModelUpload as A,handleModelUpload as H}from"./modelUploadUtils.js";import E from"./Workflow.js";import{startCreatingNewFeature as T,findLayerInfo as j,updateGraphicSymbolWhenRequired as U,isTerminalUpdateEventType as L,getVisualVariableAttributes as x,startUpdatingFeatureGeometry as O,createWorkflowSteps as R,avoidFeatureTemplateSelectionWithOnlyOneItem as W,getCreationAttributes as D,getFullTemplateForCreationInfo as N,getServiceLayersById as G,prepareAttachmentsForCreateFeaturesWorkflow as z,showProgressCursor as Z,setUpSketchCreateWatchers as q,setVisualVariablesAndElevationInfoForUpdate as B,visualVariableInteractiveUpdate as K}from"./workflowUtils.js";import J from"../FeatureForm/FeatureFormViewModel.js";import Q from"../Sketch/SketchViewModel.js";var X;const Y=Symbol(),$=Symbol(),ee=Symbol(),te=Symbol(),ae={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let ie=X=class extends E{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._featureFormViewModel=new J,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){if(this.pendingFeatures.some((e=>!!this.data.getEditsForPendingFeature(e)?.modified)))return!0;const{creationInfo:e,upload:t}=this.data,a=this._sketchViewModel,{activeComponent:i}=a,r=a.createGraphic?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==i?.type&&"draw-3d"!==i?.type)&&i.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=this._sketchViewModel.createGraphic;if("mesh"===a){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then((e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage}));const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(i,e):void 0}const r=this._sketchViewModel.activeCreateToolDrawMode,s=this._sketchViewModel.activeTool;return V("rectangle"===s?"rectangle":"circle"===s?"circle":a,i?.geometry,r)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;return e?this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures||"2d"!==t?.type&&"multipoint"===e?[]:[...ae[e]]:[]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&this._setUpCreatingFeaturesStep()}exit(){this._isActive=!1,this.removeHandles([ee])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),b(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(){const{featureFormViewModel:e}=this;if(e.pendingSubtypeChoice)return;e.submit(),this._stashValidationState();const t=this.data.selectedPendingFeature,a=this._hasValidationErrors(t)?t:this.data.pendingFeatures.find((e=>this._hasValidationErrors(e)));return a?(await this._startUpdating({feature:a}),void e?.submit()):super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||A(this.data.creationInfo)||this._attachmentsActive?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||A(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.removePendingFeature(e),this.sketchViewModel.layer.graphics.remove(e)}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,applyEditsFeatureServiceCallback:i,isNested:r,creationInfo:s,parent:o,snappingManager:n,startAt:l,viewModel:d}=e,c=e.sketchOptions??new k,u=s?.layer,h=u?d.findEditorItemForLayer(u):void 0,p=new X({data:new P({creationInfo:s,editorItem:h,parent:o,sketchOptions:c,snappingManager:n,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;p._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:o}=r,n=o.capabilities?.editing.supportsGlobalId&&"globalIdField"in o,l=p._attachmentFileInfos,{fullTemplate:d,templateExecutorInfo:c}=e,u=d&&y(d)&&c?.completionResult;if(n){if(ne(s),u){const e=de(c.completionResult.edits,l);await i(d.featureService,e,{globalIdUsed:!0,gdbVersion:d.layer.gdbVersion??void 0})}else{const e=le(s,l);await a(o,e,{globalIdUsed:!0})}return}const h=u?await i(d.featureService,c.completionResult.edits,{gdbVersion:d.layer.gdbVersion??void 0}):[await a(o,{addFeatures:s})];h&&l.size>0&&await Promise.all(h.map((e=>{if(e?.addFeatureResults)return t(o,oe(s,e.addFeatureResults,o,l))})))}});return p._set("steps",this._createWorkflowSteps(p,l)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,i((()=>e.opacity=t))}async _startCreating(){this.removeHandles($);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new";const a=await T(this._sketchViewModel,e,this._webStyleCache);this.addHandles(a,$)}async _clearSelectedFeature(){const e=this._featureFormViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=o(this._featureFormHandle),this._featureFormViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||this.data.viewModel.activeWorkflow?.previous()}_stashValidationState(){const e=this._featureFormViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._featureFormViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_featureFormViewModel:n,_sketchViewModel:l}=this,{creationInfo:d,viewModel:u}=a,{attachmentsViewModel:h,layerInfos:p,view:m}=u;if(!m||!d)return;o(this._featureFormHandle);const f=e.sourceLayer,w=j(p,f),g=w?.formTemplate,y=m.spatialReference;n.set({arcadeEditType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:m.map}),"add"!==h.mode&&"edit"!==h.mode||u.activeWorkflow?.previous(),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>h.addFile(e,t))),await U(e,s,"2d"===m.type?m.scale:null);const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([n.on("value-change",(async()=>{v?.updateAttributes(n.getValues()),await U(e,s,"2d"===m.type?m.scale:null)})),l.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&L(e.toolEventInfo.type))&&n.notifyFeatureGeometryChanged()})),c((()=>n.feature?.sourceLayer),(t=>e.sourceLayer=t)),c((()=>[n.feature,n.submittable]),(()=>this._stashValidationState()))]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchViewModel:a,data:i}=this,{creationInfo:r,viewModel:s}=i,{view:o}=s;if(!o||!r)return;const n=e.sourceLayer??r.layer;return b(n)?void 0:(this._visualVariableAttributes=x(e),O({graphic:e,sketchViewModel:a,sourceLayer:n,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=R(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(A(t)?e.addHandles(await H({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),e.addHandles(i.featureTemplatesViewModel.on("select",(({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())})),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([ee,Y,$,te]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return W(a,i)}static _configureSketchViewModel(e){const{data:t}=e,a=e._webStyleCache,{creationInfo:s,viewModel:o}=t,{view:n}=o,l=e._sketchViewModel,h=[];if(!n)return i();if("2d"===n.type){s&&h.push(e._fadeExistingFeatures(s.layer));const t=d(((e,t)=>Promise.all(e.map((e=>U(e,a,t))))));h.push(c((()=>n.scale),(e=>t(l.layer.graphics,e))))}const p=D(t.fullTemplate,s?.attributeOverrides),m=async i=>{if("start"!==i.state||e.hasHandles($)||e.addHandles(await q({creationAttributes:p,data:t,sketchViewModel:l,view:n,webStyleCache:a}),$),"cancel"!==i.state&&"complete"!==i.state||e.removeHandles($),"cancel"===i.state&&null!==n.activeTool&&n.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===i.state&&i.graphic){const t=await e._processEdits(i.graphic,{scale:"2d"===n.type?n.scale:null,useSourceLayer:!0,webStyleCache:e._webStyleCache});t&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:t}))}},f=async a=>{const{attachmentsViewModel:i}=o,{_featureFormViewModel:r}=e;if(a.graphics.length>1)return void await e._clearSelectedFeature();const d=a.graphics[0];if("complete"===a.state){const{submittable:t}=r;if(e.numPendingFeatures!==s?.maxFeatures&&t||r.submit(),await e._clearSelectedFeature(),"add"!==i.mode&&"edit"!==i.mode||o.activeWorkflow?.previous(),!a.aborted&&n.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===a.state)return d.sourceLayer??=t.creationInfo?.layer,await B({sketchViewModel:l,graphic:d,visualVariables:e._visualVariableAttributes,webStyleCache:e._webStyleCache,sourceLayer:d.sourceLayer}),e._selectFeatureForUpdate({feature:d});if("active"===a.state){await e.updatePendingFeature(d);const t=e._visualVariableAttributes;await K(n,d,a,t,e._webStyleCache);const i=d.attributes,{rotation:s,size:o}=t;if(null!=s){const{field:e}=s;r.setValue(e,i[e])}if(null!=o){const{field:e}=o;r.setValue(e,i[e])}}}},w=async a=>{if(a.graphics.forEach((e=>{t.removePendingFeature(e)})),!A(t.creationInfo))return e._startCreating()},g=async()=>{if(A(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};h.push(l.on("create",(t=>e._updatingHandles.addPromise(m(t)))),l.on("update",(t=>e._updatingHandles.addPromise(f(t)))),l.on("delete",(t=>e._updatingHandles.addPromise(w(t)))),u((()=>!e.numPendingFeatures),(()=>e._updatingHandles.addPromise(g()))),i((()=>{l.cancel()})),re(l,t),...se(t));const y=r(h);return l.addHandles(y),y}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new _({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new Q({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:t});this._sketchViewModel=r,t?.map.add(a),this.addHandles([i((()=>{t?.destroyed||t?.map.remove(a),a.destroy()})),c((()=>this.numPendingFeatures>0),(e=>this._sketchViewModel.updateOnGraphicClick=e),h)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._featureFormViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a}=this,{layerInfos:i,view:r}=a.viewModel,s=this._featureFormViewModel,{templateExecutorInfo:o}=a;if(!o){const t=e.clone();return t.geometry=null,a.addPendingFeature(e,t),e}const n=this.sketchViewModel.layer;n.remove(e);const{executor:d}=o,c=d(e.geometry,"completion"),u=l(c)?await c:c;o.completionResult=u,s.arcadeEditType="INSERT",s.map=r?.map,s.spatialReference=r?.spatialReference;for(const l of u.edits){let e=null;if(l.addFeatures)for(const r of l.addFeatures){const o=r.clone();o.geometry=null,r.symbol=await M(r,t),n.add(r);const l=a.addPendingFeature(r,o);r.sourceLayer!==e?.layer&&(e=j(i,r.sourceLayer)),s.feature=r,s.formTemplate=e?.formTemplate,await p((()=>!s.updating)),l.submittable=s.submittable}}s.feature=null,await p((()=>!s.updating));return u.edits.reduce(((e,t)=>e+(t.addFeatures?.length??0)),0)>1?null:u.primary?.graphic}async _setUpCreatingFeaturesStep(){if(this.hasHandles(ee))return;const{data:e,sketchViewModel:s}=this,{creationInfo:n,viewModel:l}=e,{attachmentsViewModel:d,view:u}=l;if(!u||!n?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:p,layer:m}=n,f=[];if(this._featureFormHandle=o(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=l.findEditorItemForLayer(n.layer),null===e.fullTemplate&&n.template){const t=await N(n,u);e.fullTemplate=t,t&&y(t)&&(e.templateExecutorInfo={completionResult:null,executor:await F(t),serviceLayersById:await G(n.layer,u)})}z(d),f.push(c((()=>d.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const w=Z(u);f.push(w);const g=b(n.layer);try{if(g){const{template:e}=n;if(e&&v(e))throw new a("Shared templates are not yet supported");const i=p??new t({attributes:{...e?.prototype.attributes,...n.attributeOverrides},sourceLayer:m});await this._startUpdating({feature:i})}else f.push(X._configureSketchViewModel(this)),p?(s.layer.add(p),await this._startUpdating({feature:p})):await this._startCreating()}finally{w.remove()}const _=i((()=>{for(const t of e.pendingFeatures)s.layer.remove(t),e.removePendingFeature(t)})),M=c((()=>u?.timeZone),(e=>this._featureFormViewModel.timeZone=e),h),V=i((()=>{A(n)&&l.cancelWorkflow({warnIfNoWorkflow:!1})}));this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles([i((()=>d.fileInfos.removeAll())),r(f),V,_,M],ee)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),te),await p((()=>null==e?.activeTool),t.signal),t.abort()}};function re(e,t){let a=null;const s=()=>e.snappingOptions.featureSources,o=()=>(a=new S({layer:e.layer}),s().add(a),a),l=()=>{null!=a&&(s().remove(a),a=n(a))};return r([c((()=>{const e=t.creationInfo?.layer,a=s().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return l();a??=o(),a.enabled=t}),m),i(l)])}function se(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new I({view:t});a.push(c((()=>e.selectedPendingFeature),((e,t)=>{r.remove(e),r.add(t)})),i((()=>r.destroy())))}const r=new I({view:t,highlightName:C});return a.push(c((()=>e.temporaryHighlightFeature),(e=>{r.removeAll(),r.add(e)})),i((()=>r.destroy()))),a}function oe(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach((({form:e})=>r.push({feature:o,attachment:e})))}})),r}function ne(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=f())}}function le(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:f(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function de(e,t){return e.map((e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:f(),data:t}})}return i.length?{...e,addAttachments:i}:e}))}e([w()],ie.prototype,"createFeatureState",void 0),e([w()],ie.prototype,"data",void 0),e([w({constructOnly:!0})],ie.prototype,"isNested",void 0),e([w()],ie.prototype,"featureFormViewModel",null),e([w()],ie.prototype,"hasPendingEdits",null),e([w()],ie.prototype,"hasPreviousStep",null),e([w()],ie.prototype,"_getDrawMeshHelpMessage",void 0),e([w()],ie.prototype,"helpMessage",null),e([w()],ie.prototype,"layer",null),e([w()],ie.prototype,"parent",null),e([w()],ie.prototype,"parentLayer",null),e([w()],ie.prototype,"keyboardCancellationEnabled",null),e([w()],ie.prototype,"reliesOnOwnerAdminPrivileges",null),e([w()],ie.prototype,"shouldShowAttachments",null),e([w()],ie.prototype,"shouldAllowAttachmentEditing",null),e([w()],ie.prototype,"sketchViewModel",null),e([w()],ie.prototype,"availableCreateTools",null),e([w()],ie.prototype,"_attachmentsActive",null),ie=X=e([g("esri.widgets.Editor.CreateFeaturesWorkflow")],ie);const ce=ie;export{ce as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import o from"../../core/Logger.js";import{removeMaybe as n,destroyMaybe as l}from"../../core/maybe.js";import{isPromiseLike as d,debounce as c}from"../../core/promiseUtils.js";import{watch as u,when as h,initial as p,whenOnce as m,syncAndInitial as f}from"../../core/reactiveUtils.js";import{generateBracedUUID as w}from"../../core/uuid.js";import{property as g}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{isSharedTemplateOrMetadata as v,isSharedTemplate as F}from"../../editing/templateUtils.js";import{createTemplateExecutor as _}from"../../editing/sharedTemplates/executor/createTemplateExecutor.js";import b from"../../layers/GraphicsLayer.js";import{isTable as M}from"../../layers/support/layerUtils.js";import{getDisplayedSymbol as V}from"../../symbols/support/symbolUtils.js";import{getDrawHelpMessage as I}from"../../views/draw/support/helpMessageUtils.js";import k from"../../views/draw/support/HighlightHelper.js";import S from"../../views/interactive/sketch/SketchOptions.js";import C from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as P}from"../../views/support/HighlightDefaults.js";import A from"./CreateFeaturesWorkflowData.js";import{isModelUpload as H,handleModelUpload as E}from"./modelUploadUtils.js";import T from"./Workflow.js";import{createToolFromGeometryType as j,setRelationshipFields as U,startCreatingNewFeature as L,findLayerInfo as x,updateGraphicSymbolWhenRequired as O,isTerminalUpdateEventType as R,getVisualVariableAttributes as W,startUpdatingFeatureGeometry as D,createWorkflowSteps as N,avoidFeatureTemplateSelectionWithOnlyOneItem as G,getCreationAttributes as z,getFullTemplateForCreationInfo as Z,getServiceLayersById as K,prepareAttachmentsForCreateFeaturesWorkflow as q,showProgressCursor as B,setUpSketchCreateWatchers as J,setVisualVariablesAndElevationInfoForUpdate as Q,visualVariableInteractiveUpdate as X}from"./workflowUtils.js";import Y from"../FeatureForm/FeatureFormViewModel.js";import $ from"../Sketch/SketchViewModel.js";var ee;const te=Symbol(),ae=Symbol(),ie=Symbol(),re=Symbol(),se={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let oe=ee=class extends T{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._featureFormViewModel=new Y,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){if(this.pendingFeatures.some((e=>!!this.data.getEditsForPendingFeature(e)?.modified)))return!0;const{creationInfo:e,upload:t}=this.data,a=this._sketchViewModel,{activeComponent:i}=a,r=a.createGraphic?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==i?.type&&"draw-3d"!==i?.type)&&i.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature&&!this.parent&&!H(this.data.creationInfo)}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=this._sketchViewModel.createGraphic;if("mesh"===a){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then((e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage}));const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(i,e):void 0}const r=this._sketchViewModel.activeCreateToolDrawMode,s=this._sketchViewModel.activeTool;return I("rectangle"===s?"rectangle":"circle"===s?"circle":a,i?.geometry,r)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e)return[];if(this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(v(this.data.fullTemplate)){const{tool:t}=j(e,this.data.fullTemplate);return[t]}return"2d"!==t?.type&&"multipoint"===e?[]:[...se[e]]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&this._setUpCreatingFeaturesStep()}exit(){this._isActive=!1,this.removeHandles([ie])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),M(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(){const{featureFormViewModel:e}=this;if(e.pendingSubtypeChoice)return;e.submit(),this._stashValidationState();const t=this.data.selectedPendingFeature,a=this._hasValidationErrors(t)?t:this.data.pendingFeatures.find((e=>this._hasValidationErrors(e)));return a?(await this._startUpdating({feature:a}),void e?.submit()):super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||H(this.data.creationInfo)||this._attachmentsActive||this.parent?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||H(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.isSharedTemplateWorkflow?o.getLogger(this).warn("Cannot cancel individual features created by shared templates."):(this.data.removePendingFeature(e),this.sketchViewModel.layer.graphics.remove(e))}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,applyEditsFeatureServiceCallback:i,isNested:r,creationInfo:s,parent:o,snappingManager:n,startAt:l,viewModel:d}=e,c=e.sketchOptions??new S,u=s?.layer,h=u?d.findEditorItemForLayer(u):void 0,p=new ee({data:new A({creationInfo:s,editorItem:h,parent:o,sketchOptions:c,snappingManager:n,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;p._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:o}=r,n=o.capabilities?.editing.supportsGlobalId&&"globalIdField"in o,l=p._attachmentFileInfos,{fullTemplate:d,templateExecutorInfo:c}=e;c?.completionResult&&U(c.completionResult.relationships);const u=d&&F(d)&&c?.completionResult;if(n){if(ce(s),u){const e=he(c.completionResult.edits,l);await i(d.featureService,e,{globalIdUsed:!0,gdbVersion:d.layer.gdbVersion??void 0})}else{const e=ue(s,l);await a(o,e,{globalIdUsed:!0})}return}const h=u?await i(d.featureService,c.completionResult.edits,{gdbVersion:d.layer.gdbVersion??void 0}):[await a(o,{addFeatures:s})];h&&l.size>0&&await Promise.all(h.map((e=>{if(e?.addFeatureResults)return t(o,de(s,e.addFeatureResults,o,l))})))}});return p._set("steps",this._createWorkflowSteps(p,l)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,i((()=>e.opacity=t))}async _startCreating(){this.removeHandles(ae);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new";const a=await L(this._sketchViewModel,e,this._webStyleCache);this.addHandles(a,ae)}async _clearSelectedFeature(){const e=this._featureFormViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=n(this._featureFormHandle),this._featureFormViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||this.data.viewModel.activeWorkflow?.previous()}_stashValidationState(){const e=this._featureFormViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._featureFormViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_featureFormViewModel:o,_sketchViewModel:l}=this,{creationInfo:d,viewModel:c}=a,{attachmentsViewModel:h,layerInfos:p,view:m}=c;if(!m||!d)return;n(this._featureFormHandle);const f=e.sourceLayer,w=x(p,f),g=w?.formTemplate,y=m.spatialReference;o.set({arcadeEditType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:m.map}),"add"!==h.mode&&"edit"!==h.mode||c.activeWorkflow?.previous(),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>h.addFile(e,t))),await O(e,s,"2d"===m.type?m.scale:null);const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([o.on("value-change",(async()=>{v?.updateAttributes(o.getValues()),await O(e,s,"2d"===m.type?m.scale:null)})),l.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&R(e.toolEventInfo.type))&&o.notifyFeatureGeometryChanged()})),u((()=>o.feature?.sourceLayer),(t=>e.sourceLayer=t)),u((()=>[o.feature,o.submittable]),(()=>this._stashValidationState()))]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchViewModel:a,data:i}=this,{creationInfo:r,viewModel:s}=i,{view:o}=s;if(!o||!r)return;const n=e.sourceLayer??r.layer;return M(n)?void 0:(this._visualVariableAttributes=W(e),D({graphic:e,sketchViewModel:a,sourceLayer:n,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=N(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(H(t)?e.addHandles(await E({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),e.addHandles(i.featureTemplatesViewModel.on("select",(({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())})),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([ie,te,ae,re]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return G(a,i)}static _configureSketchViewModel(e){const{data:t}=e,a=e._webStyleCache,{creationInfo:s,viewModel:o}=t,{view:n}=o,l=e._sketchViewModel,d=[];if(!n)return i();if("2d"===n.type){s&&d.push(e._fadeExistingFeatures(s.layer));const t=c(((e,t)=>Promise.all(e.map((e=>O(e,a,t))))));d.push(u((()=>n.scale),(e=>t(l.layer.graphics,e))))}const p=z(t.fullTemplate,s?.attributeOverrides),m=async i=>{if("start"!==i.state||e.hasHandles(ae)||e.addHandles(await J({creationAttributes:p,data:t,sketchViewModel:l,view:n,webStyleCache:a}),ae),"cancel"!==i.state&&"complete"!==i.state||e.removeHandles(ae),"cancel"===i.state&&null!==n.activeTool&&n.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===i.state&&i.graphic){const t=await e._processEdits(i.graphic,{scale:"2d"===n.type?n.scale:null,useSourceLayer:!0,webStyleCache:e._webStyleCache});t&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:t}))}},f=async a=>{const{attachmentsViewModel:i}=o,{_featureFormViewModel:r}=e;if(a.graphics.length>1)return void await e._clearSelectedFeature();const d=a.graphics[0];if("complete"===a.state){const{submittable:t}=r;if(e.numPendingFeatures!==s?.maxFeatures&&t||r.submit(),await e._clearSelectedFeature(),"add"!==i.mode&&"edit"!==i.mode||o.activeWorkflow?.previous(),!a.aborted&&n.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===a.state)return d.sourceLayer??=t.creationInfo?.layer,await Q({sketchViewModel:l,graphic:d,visualVariables:e._visualVariableAttributes,webStyleCache:e._webStyleCache,sourceLayer:d.sourceLayer}),e._selectFeatureForUpdate({feature:d});if("active"===a.state){await e.updatePendingFeature(d);const t=e._visualVariableAttributes;await X(n,d,a,t,e._webStyleCache);const i=d.attributes,{rotation:s,size:o}=t;if(null!=s){const{field:e}=s;r.setValue(e,i[e])}if(null!=o){const{field:e}=o;r.setValue(e,i[e])}}}},w=async a=>{if(a.graphics.forEach((e=>{t.removePendingFeature(e)})),!H(t.creationInfo))return e._startCreating()},g=async()=>{if(H(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};d.push(l.on("create",(t=>e._updatingHandles.addPromise(m(t)))),l.on("update",(t=>e._updatingHandles.addPromise(f(t)))),l.on("delete",(t=>e._updatingHandles.addPromise(w(t)))),h((()=>!e.numPendingFeatures),(()=>e._updatingHandles.addPromise(g()))),i((()=>{l.cancel()})),ne(l,t),...le(t));const y=r(d);return l.addHandles(y),y}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new b({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new $({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:t});this._sketchViewModel=r,t?.map.add(a),this.addHandles([i((()=>{t?.destroyed||t?.map.remove(a),a.destroy()})),u((()=>this.numPendingFeatures>0),(e=>this._sketchViewModel.updateOnGraphicClick=e),p)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._featureFormViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a}=this,{layerInfos:i,view:r}=a.viewModel,s=this._featureFormViewModel,{templateExecutorInfo:o}=a;if(!o){const t=e.clone();return t.geometry=null,a.addPendingFeature(e,t),e}const n=this.sketchViewModel.layer;n.remove(e);const{executor:l}=o,c=l(e.geometry,"completion"),u=d(c)?await c:c;o.completionResult=u,U(u.relationships),s.arcadeEditType="INSERT",s.map=r?.map,s.spatialReference=r?.spatialReference;for(const d of u.edits){let e=null;if(d.addFeatures)for(const r of d.addFeatures){const o=r.clone();o.geometry=null,r.symbol=await V(r,t),n.add(r);const l=a.addPendingFeature(r,o);r.sourceLayer!==e?.layer&&(e=x(i,r.sourceLayer)),s.feature=r,s.formTemplate=e?.formTemplate,await m((()=>!s.updating)),l.submittable=s.submittable}}s.feature=null,await m((()=>!s.updating));return u.edits.reduce(((e,t)=>e+(t.addFeatures?.length??0)),0)>1?null:u.primary?.graphic}async _setUpCreatingFeaturesStep(){if(this.hasHandles(ie))return;const{data:e,sketchViewModel:s}=this,{creationInfo:o,viewModel:l}=e,{attachmentsViewModel:d,view:c}=l;if(!c||!o?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:h,layer:m}=o,f=[];if(this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=l.findEditorItemForLayer(o.layer),null===e.fullTemplate&&o.template){const t=await Z(o,c);e.fullTemplate=t,t&&F(t)&&(e.templateExecutorInfo={completionResult:null,executor:await _(t),serviceLayersById:await K(o.layer,c)})}s.allowDeleteKey=!e.isSharedTemplateWorkflow,q(d),f.push(u((()=>d.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const w=B(c);f.push(w);const g=M(o.layer);try{if(g){const{template:e}=o;if(e&&v(e))throw new a("Shared templates are not yet supported");const i=h??new t({attributes:{...e?.prototype.attributes,...o.attributeOverrides},sourceLayer:m});await this._startUpdating({feature:i})}else f.push(ee._configureSketchViewModel(this)),h?(s.layer.add(h),await this._startUpdating({feature:h})):await this._startCreating()}finally{w.remove()}const y=i((()=>{for(const t of e.pendingFeatures)s.layer.remove(t),e.removePendingFeature(t)})),b=u((()=>c?.timeZone),(e=>{this._featureFormViewModel.timeZone=e,this.data.timeZone=e}),p),V=i((()=>{H(o)&&l.cancelWorkflow({warnIfNoWorkflow:!1})}));this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles([i((()=>d.fileInfos.removeAll())),r(f),V,y,b],ie)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),re),await m((()=>null==e?.activeTool),t.signal),t.abort()}};function ne(e,t){let a=null;const s=()=>e.snappingOptions.featureSources,o=()=>(a=new C({layer:e.layer}),s().add(a),a),n=()=>{null!=a&&(s().remove(a),a=l(a))};return r([u((()=>{const e=t.creationInfo?.layer,a=s().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return n();a??=o(),a.enabled=t}),f),i(n)])}function le(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new k({view:t});a.push(u((()=>e.selectedPendingFeature),((e,t)=>{r.remove(e),r.add(t)})),i((()=>r.destroy())))}const r=new k({view:t,highlightName:P});return a.push(u((()=>e.temporaryHighlightFeature),(e=>{r.removeAll(),r.add(e)})),i((()=>r.destroy()))),a}function de(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach((({form:e})=>r.push({feature:o,attachment:e})))}})),r}function ce(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=w())}}function ue(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:w(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function he(e,t){return e.map((e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:w(),data:t}})}return i.length?{...e,addAttachments:i}:e}))}e([g()],oe.prototype,"createFeatureState",void 0),e([g()],oe.prototype,"data",void 0),e([g({constructOnly:!0})],oe.prototype,"isNested",void 0),e([g()],oe.prototype,"featureFormViewModel",null),e([g()],oe.prototype,"hasPendingEdits",null),e([g()],oe.prototype,"hasPreviousStep",null),e([g()],oe.prototype,"_getDrawMeshHelpMessage",void 0),e([g()],oe.prototype,"helpMessage",null),e([g()],oe.prototype,"layer",null),e([g()],oe.prototype,"parent",null),e([g()],oe.prototype,"parentLayer",null),e([g()],oe.prototype,"keyboardCancellationEnabled",null),e([g()],oe.prototype,"reliesOnOwnerAdminPrivileges",null),e([g()],oe.prototype,"shouldShowAttachments",null),e([g()],oe.prototype,"shouldAllowAttachmentEditing",null),e([g()],oe.prototype,"sketchViewModel",null),e([g()],oe.prototype,"availableCreateTools",null),e([g()],oe.prototype,"_attachmentsActive",null),oe=ee=e([y("esri.widgets.Editor.CreateFeaturesWorkflow")],oe);const pe=oe;export{pe as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import r from"../../core/Collection.js";import o from"../../core/Logger.js";import s from"../../core/ReactiveMap.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import a from"./Edits.js";const p=()=>o.getLogger("esri.widgets.Editor.CreateFeaturesWorkflowData");let l=class extends t{constructor(e){super(e),this.creationInfo=null,this.editorItem=null,this.fullTemplate=null,this.parent=null,this.temporaryHighlightFeature=null,this.sketchOptions=null,this.snappingManager=null,this.templateExecutorInfo=null,this.viewModel=null,this.upload=null,this._pendingEdits=new s}get pendingFeatures(){return new r([...this._pendingEdits.keys()])}set selectedPendingFeature(e){this._set("selectedPendingFeature",e),this.temporaryHighlightFeature=null}isSubmittable(e){return!!this._pendingEdits.get(e)?.submittable}addPendingFeature(e,t=e){this.temporaryHighlightFeature=null;const{_pendingEdits:r}=this;if(r.has(e))return r.get(e);e.sourceLayer||p().warn("source-layer-not-set","A feature added to `pendingFeatures` did not have `sourceLayer` set. This may cause problems throughout `CreateFeaturesWorkflow`.");const o=new a({feature:e});return o.trackChanges(t),r.set(e,o),o}getEditsForPendingFeature(e){return this._pendingEdits.get(e)}removePendingFeature(e){this.temporaryHighlightFeature=null;const{_pendingEdits:t}=this,r=t.get(e);r&&(r.destroy(),t.delete(e)),this.selectedPendingFeature===e&&(this.selectedPendingFeature=null)}};e([i()],l.prototype,"creationInfo",void 0),e([i()],l.prototype,"editorItem",void 0),e([i()],l.prototype,"fullTemplate",void 0),e([i()],l.prototype,"parent",void 0),e([i()],l.prototype,"pendingFeatures",null),e([i()],l.prototype,"selectedPendingFeature",null),e([i()],l.prototype,"temporaryHighlightFeature",void 0),e([i({constructOnly:!0})],l.prototype,"sketchOptions",void 0),e([i()],l.prototype,"snappingManager",void 0),e([i()],l.prototype,"templateExecutorInfo",void 0),e([i()],l.prototype,"viewModel",void 0),e([i()],l.prototype,"upload",void 0),l=e([n("esri.widgets.Editor.CreateFeaturesWorkflowData")],l);const d=l;export{d as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import r from"../../core/Collection.js";import o from"../../core/Logger.js";import i from"../../core/ReactiveMap.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{isSharedTemplateOrMetadata as l}from"../../editing/templateUtils.js";import a from"./Edits.js";const p=()=>o.getLogger("esri.widgets.Editor.CreateFeaturesWorkflowData");let d=class extends t{constructor(e){super(e),this.creationInfo=null,this.editorItem=null,this.fullTemplate=null,this.parent=null,this.temporaryHighlightFeature=null,this.sketchOptions=null,this.snappingManager=null,this.templateExecutorInfo=null,this.viewModel=null,this.upload=null,this._pendingEdits=new i}get isSharedTemplateWorkflow(){return!!this.fullTemplate&&l(this.fullTemplate)}get pendingFeatures(){return new r([...this._pendingEdits.keys()])}set selectedPendingFeature(e){this._set("selectedPendingFeature",e),this.temporaryHighlightFeature=null}set timeZone(e){this._set("timeZone",e),this._pendingEdits.forEach((t=>{t.timeZone=e}))}isSubmittable(e){return!!this._pendingEdits.get(e)?.submittable}addPendingFeature(e,t=e){this.temporaryHighlightFeature=null;const{_pendingEdits:r}=this;if(r.has(e))return r.get(e);e.sourceLayer||p().warn("source-layer-not-set","A feature added to `pendingFeatures` did not have `sourceLayer` set. This may cause problems throughout `CreateFeaturesWorkflow`.");const o=new a({feature:e});return o.trackChanges(t),r.set(e,o),o}getEditsForPendingFeature(e){return this._pendingEdits.get(e)}removePendingFeature(e){this.temporaryHighlightFeature=null;const{_pendingEdits:t}=this,r=t.get(e);r&&(r.destroy(),t.delete(e)),this.selectedPendingFeature===e&&(this.selectedPendingFeature=null)}getFeatureTitle(e){return this._pendingEdits.get(e)?.displayTitle}};e([s()],d.prototype,"creationInfo",void 0),e([s()],d.prototype,"editorItem",void 0),e([s()],d.prototype,"fullTemplate",void 0),e([s()],d.prototype,"isSharedTemplateWorkflow",null),e([s()],d.prototype,"parent",void 0),e([s()],d.prototype,"pendingFeatures",null),e([s()],d.prototype,"selectedPendingFeature",null),e([s()],d.prototype,"temporaryHighlightFeature",void 0),e([s({constructOnly:!0})],d.prototype,"sketchOptions",void 0),e([s()],d.prototype,"snappingManager",void 0),e([s()],d.prototype,"templateExecutorInfo",void 0),e([s()],d.prototype,"viewModel",void 0),e([s()],d.prototype,"upload",void 0),e([s()],d.prototype,"timeZone",null),d=e([n("esri.widgets.Editor.CreateFeaturesWorkflowData")],d);const u=d;export{u 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.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{attributesAreEquivalent as o}from"./support/editsUtils.js";function s(t){return null==t?null:JSON.stringify(t)}let a=class extends e{constructor(t){super(t),this._stagedForDelete=!1,this.feature=null,this.initialFeature=null,this.submittable=!1}get attributesModified(){return!o(this.initialFeature?.attributes,this.feature?.attributes)}get geometryModified(){return this._stringifyGeometry(this.feature)!==this._stringifyGeometry(this.initialFeature)}get stagedForDelete(){return this._stagedForDelete}get modified(){return this.attributesModified||this.geometryModified||this._stagedForDelete}stageDelete(){this._stagedForDelete=!0}unstageDelete(){this._stagedForDelete=!1}trackChanges(t=this.feature){this.initialFeature=t?.clone()}updateAttributes(t){const{feature:e}=this;e&&(e.attributes=t,this.notifyChange("attributesModified"))}updateGeometry(t){const{feature:e}=this;e&&(e.geometry=t,this.notifyChange("geometryModified"))}_stringifyGeometry(t){const e=t?.geometry;return s("mesh"===e?.type?{transform:e.transform,vertexSpace:e.vertexSpace}:e)}};t([r()],a.prototype,"_stagedForDelete",void 0),t([r()],a.prototype,"attributesModified",null),t([r()],a.prototype,"feature",void 0),t([r()],a.prototype,"geometryModified",null),t([r()],a.prototype,"initialFeature",void 0),t([r()],a.prototype,"modified",null),t([r()],a.prototype,"submittable",void 0),a=t([i("esri.widgets.Editor.Edits")],a);const u=a;export{u as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{debounce as i}from"../../core/promiseUtils.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{attributesAreEquivalent as o}from"./support/editsUtils.js";function a(e){return null==e?null:JSON.stringify(e)}let l=class extends t{constructor(e){super(e),this._stagedForDelete=!1,this.feature=null,this.initialFeature=null,this.submittable=!1,this.displayTitle=null,this._debouncedRefreshDisplayTitle=i(this._refreshDisplayTitle.bind(this),100)}get attributesModified(){return!o(this.initialFeature?.attributes,this.feature?.attributes)}get geometryModified(){return this._stringifyGeometry(this.feature)!==this._stringifyGeometry(this.initialFeature)}get stagedForDelete(){return this._stagedForDelete}get modified(){return this.attributesModified||this.geometryModified||this._stagedForDelete}set timeZone(e){this._set("timeZone",e),this._debouncedRefreshDisplayTitle()}stageDelete(){this._stagedForDelete=!0}unstageDelete(){this._stagedForDelete=!1}trackChanges(e=this.feature){this.initialFeature=e?.clone(),this._debouncedRefreshDisplayTitle()}updateAttributes(e){const{feature:t}=this;t&&(t.attributes=e,this.notifyChange("attributesModified")),this._debouncedRefreshDisplayTitle()}updateGeometry(e){const{feature:t}=this;t&&(t.geometry=e,this.notifyChange("geometryModified"))}_stringifyGeometry(e){const t=e?.geometry;return a("mesh"===t?.type?{transform:t.transform,vertexSpace:t.vertexSpace}:t)}async _refreshDisplayTitle(e){const t=this.feature,i=t?.sourceLayer;if(!i||!("getFeatureTitle"in i))return;const r=await i.getFeatureTitle(t,{fetchMissingFields:!1,timeZone:this.timeZone});e.aborted||(this.displayTitle=""===r?null:r)}};e([r()],l.prototype,"_stagedForDelete",void 0),e([r()],l.prototype,"attributesModified",null),e([r()],l.prototype,"feature",void 0),e([r()],l.prototype,"geometryModified",null),e([r()],l.prototype,"initialFeature",void 0),e([r()],l.prototype,"modified",null),e([r()],l.prototype,"submittable",void 0),e([r()],l.prototype,"displayTitle",void 0),e([r()],l.prototype,"timeZone",null),l=e([s("esri.widgets.Editor.Edits")],l);const n=l;export{n as default};