@arcgis/core 4.29.2 → 4.29.4

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 (51) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/686a76adc741eef369ee.js +1 -0
  3. package/assets/esri/core/workers/chunks/{b125ab84b7761e761734.js → 6ee0e9e56b80296570cb.js} +1 -1
  4. package/assets/esri/core/workers/chunks/994ca341d8711a4dd473.js +1 -0
  5. package/assets/esri/core/workers/chunks/{246cba9cd5cadba6be08.js → 9a8ab968ebb18480481d.js} +1 -1
  6. package/assets/esri/core/workers/chunks/ad9740559e8e45526796.js +1 -0
  7. package/assets/esri/core/workers/chunks/bd4cb6b02ed52b82ba56.js +1 -0
  8. package/assets/esri/core/workers/chunks/{712b5cabf4ea3dc8bf33.js → c34ec99627e7645fd218.js} +1 -1
  9. package/assets/esri/core/workers/chunks/c442480601f9a36e29b9.js +1 -0
  10. package/assets/esri/core/workers/chunks/c8ecaac448fddd120421.js +1 -0
  11. package/interfaces.d.ts +39 -51
  12. package/kernel.js +1 -1
  13. package/package.json +1 -1
  14. package/rest/knowledgeGraph/wasmInterface/wasmToFeatureFactories.js +1 -1
  15. package/rest/print.js +1 -1
  16. package/support/revision.js +1 -1
  17. package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
  18. package/views/2d/engine/webgl/FeatureTile.js +1 -1
  19. package/views/2d/engine/webgl/ReshufflePlan.js +1 -1
  20. package/views/2d/engine/webgl/cpuMapped/Buffer.js +1 -1
  21. package/views/2d/engine/webgl/cpuMapped/MappedMesh.js +1 -1
  22. package/views/2d/layers/VectorTileLayerView2D.js +1 -1
  23. package/views/2d/layers/features/FeatureContainer.js +1 -1
  24. package/views/2d/layers/features/Processor.js +1 -1
  25. package/views/2d/layers/features/ProcessorTileMessageQueue.js +5 -0
  26. package/views/2d/layers/features/RenderState.js +1 -1
  27. package/views/2d/layers/features/aggregation/GridCell.js +1 -1
  28. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  29. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  30. package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
  31. package/views/2d/layers/features/sources/strategies/AFetchLoadStrategy.js +1 -1
  32. package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
  33. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  34. package/views/2d/layers/features/support/ComputedExpression.js +1 -1
  35. package/views/2d/layers/features/support/DisplayIdGenerator.js +1 -1
  36. package/views/2d/layers/features/support/FeatureSetCache.js +5 -0
  37. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  38. package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
  39. package/widgets/BasemapLayerList.js +1 -1
  40. package/widgets/Feature/support/arcadeFeatureUtils.js +1 -1
  41. package/widgets/LayerList.js +1 -1
  42. package/widgets/Legend/LegendViewModel.js +1 -1
  43. package/widgets/Search/SearchViewModel.js +1 -1
  44. package/widgets/TableList.js +1 -1
  45. package/widgets/VersionManagement/VersionManagementViewModel.js +1 -1
  46. package/assets/esri/core/workers/chunks/7427d03e693f32a81377.js +0 -1
  47. package/assets/esri/core/workers/chunks/7a8bba91769ee18cc39f.js +0 -1
  48. package/assets/esri/core/workers/chunks/8044f34d295ec36aa3f1.js +0 -1
  49. package/assets/esri/core/workers/chunks/94d72650d556fd0eecc3.js +0 -1
  50. package/assets/esri/core/workers/chunks/ef3e6209e6ac6a56960b.js +0 -1
  51. package/assets/esri/core/workers/chunks/ff14214611e1e070235e.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import r from"../../core/Accessor.js";import i from"../../core/Collection.js";import{watch as t,initial as s,when as a}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{get as l}from"../../core/accessorSupport/get.js";import{getEffectiveFeatureReduction as y}from"../../views/2d/layers/features/layerAdapters/featureReductionUtils.js";import d from"./support/ActiveLayerInfo.js";import{onLocaleChange as h}from"../../intl/locale.js";const c={state:"state",view:"view",allLayerViews:"all-layer-views",legendProperties:"legend-properties"},L=i.ofType(d),u=new Set(["esri.layers.BuildingSceneLayer","esri.layers.CSVLayer","esri.layers.FeatureLayer","esri.layers.GeoJSONLayer","esri.layers.GeoRSSLayer","esri.layers.GroupLayer","esri.layers.HeatmapLayer","esri.layers.ImageryLayer","esri.layers.ImageryTileLayer","esri.layers.MapImageLayer","esri.layers.OGCFeatureLayer","esri.layers.OrientedImageryLayer","esri.layers.PointCloudLayer","esri.layers.StreamLayer","esri.layers.SceneLayer","esri.layers.SubtypeGroupLayer","esri.layers.TileLayer","esri.layers.VoxelLayer","esri.layers.WFSLayer","esri.layers.WMSLayer","esri.layers.WMTSLayer","esri.layers.WCSLayer","esri.layers.LinkChartLayer","esri.layers.knowledgeGraph.KnowledgeGraphSublayer"]),f="view.basemapView.baseLayerViews",p="view.groundView.layerViews",v="view.basemapView.referenceLayerViews",_=[f,p,"view.layerViews",v];let w=class extends r{constructor(e){super(e),this._layerViewByLayerId={},this._layerInfosByLayerViewId={},this._activeLayerInfosByLayerViewId={},this._activeLayerInfosWithNoParent=new i,this.activeLayerInfos=new L,this.basemapLegendVisible=!1,this.groundLegendVisible=!1,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerVisibility=!0,this.layerInfos=[],this.view=null}initialize(){this.addHandles(t((()=>this.view),(()=>this._viewHandles()),s),c.view),this.addHandles(h((()=>this._refresh())))}destroy(){this._destroyViewActiveLayerInfos(),this.view=null}get state(){return this.view?.ready?"ready":"disabled"}_viewHandles(){this.removeHandles(c.state),this.view&&this.addHandles(t((()=>this.state),(()=>this._stateHandles()),s),c.state)}_stateHandles(){this._resetAll(),"ready"===this.state&&this._watchPropertiesAndAllLayerViews()}_resetAll(){this.removeHandles([c.allLayerViews,c.legendProperties]),this._destroyViewActiveLayerInfos(),this.activeLayerInfos.removeAll()}_destroyViewActiveLayerInfos(){Object.keys(this._activeLayerInfosByLayerViewId).forEach(this._destroyViewActiveLayerInfo,this)}_destroyViewActiveLayerInfo(e){this.removeHandles(e);const r=this._activeLayerInfosByLayerViewId[e];delete this._activeLayerInfosByLayerViewId[e],r?.parent&&r.parent.children.remove(r)}_watchPropertiesAndAllLayerViews(){const{view:e}=this;if(!e)return;const{allLayerViews:r}=e;r.length&&this._refresh(),this.addHandles(r.on("change",(e=>this._allLayerViewsChangeHandle(e))),c.allLayerViews),this.addHandles(t((()=>[this.layerInfos,this.basemapLegendVisible,this.groundLegendVisible]),(()=>this._propertiesChangeHandle())),c.legendProperties)}_allLayerViewsChangeHandle(e){e.removed.forEach((e=>this._destroyViewActiveLayerInfo(e.uid))),this._refresh()}_propertiesChangeHandle(){this._destroyViewActiveLayerInfos(),this._refresh()}_refresh(){this._layerInfosByLayerViewId={},this.activeLayerInfos.removeAll(),this._generateLayerViews().filter(this._filterLayerViewsByLayerInfos,this).filter(this._isLayerViewSupported,this).forEach(this._generateActiveLayerInfo,this),this._sortActiveLayerInfos(this.activeLayerInfos)}_sortActiveLayerInfos(e){const r=this.view;if(e.length<2||!r)return;const i=[];e.forEach((r=>{if(!r.parent){const t=r.layer.parent,s=t&&"uid"in t&&this._layerViewByLayerId[t.uid],a=s&&this._activeLayerInfosByLayerViewId[s.uid];a&&e.includes(a)&&(i.push(r),r.parent=a,a.children.add(r),this._sortActiveLayerInfos(a.children))}})),e.removeMany(i);const t={};r.allLayerViews.forEach(((e,r)=>t[e.layer.uid]=r)),e.sort(((e,r)=>{const i=t[e.layer.uid]||0;return(t[r.layer.uid]||0)-i}))}_generateLayerViews(){const e=[];return _.filter(this._filterLayerViews,this).map((e=>l(this,e))).filter((e=>null!=e)).forEach(this._collectLayerViews("layerViews",e)),e}_filterLayerViews(e){const r=!this.basemapLegendVisible&&(e===f||e===v),i=!this.groundLegendVisible&&e===p;return!r&&!i}_collectLayerViews(e,r){const i=t=>(t&&t.forEach((t=>{r.push(t),i(t[e])})),r);return i}_filterLayerViewsByLayerInfos(e){const r=this.layerInfos;return!r||!r.length||r.some((r=>this._hasLayerInfo(r,e)))}_hasLayerInfo(e,r){const i=this._isLayerUIDMatching(e.layer,r.layer.uid);return i&&(this._layerInfosByLayerViewId[r.uid]=e),i}_isLayerUIDMatching(e,r){return e&&(e.uid===r||this._hasLayerUID(e.layers,r))}_hasLayerUID(e,r){return e&&e.some((e=>this._isLayerUIDMatching(e,r)))}_isLayerViewSupported(e){return!!u.has(e.layer.declaredClass)&&(this._layerViewByLayerId[e.layer.uid]=e,!0)}_generateActiveLayerInfo(e){this._isLayerActive(e)?this._buildActiveLayerInfo(e):(this.removeHandles(e.uid),this.addHandles(t((()=>[e.legendEnabled,e.layer?.legendEnabled]),(()=>this._layerActiveHandle(e))),e.uid))}_layerActiveHandle(e){this._isLayerActive(e)&&(this.removeHandles(e.uid),this._buildActiveLayerInfo(e))}_isLayerActive(e){return!this.respectLayerVisibility||e.legendEnabled&&e.layer?.legendEnabled}_buildActiveLayerInfo(e){const r=e.layer,i=e.uid,n=this._layerInfosByLayerViewId[i];let o=this._activeLayerInfosByLayerViewId[i];if(!o){const t=void 0!==n?.title&&n.layer.uid===r.uid;o=new d({layer:r,layerView:e,title:t?n.title:r.title,view:this.view,respectLayerVisibility:this.respectLayerVisibility,hideLayersNotInCurrentView:this.hideLayersNotInCurrentView,keepCacheOnDestroy:this.keepCacheOnDestroy,sublayerIds:n?.sublayerIds||[]}),this._activeLayerInfosByLayerViewId[i]=o}const l=r.parent&&"uid"in r.parent?this._layerViewByLayerId[r.parent?.uid]:null;if(o.parent=this._activeLayerInfosByLayerViewId[l?.uid],!this.hasHandles(i)){const n=[t((()=>r.title),(e=>this._titleHandle(e,o))),t((()=>[r.opacity,"renderer"in r&&r.renderer,"pointSymbol"in r&&r.pointSymbol,"lineSymbol"in r&&r.lineSymbol,"polygonSymbol"in r&&r.polygonSymbol]),(()=>this._constructLegendElements(o))),a((()=>!0===this.view?.stationary),(()=>this._scaleHandle(o)),s),t((()=>e.layer?y(e.layer,e.view):null),(()=>this._constructLegendElements(o))),t((()=>e.updating),(()=>{if(null==e.layer)return;null!=y(e.layer,e.view)&&this._constructLegendElements(o)})),t((()=>"effect"in r&&r.effect),(()=>this._constructLegendElements(o))),a((()=>this.view?.timeZone),(()=>this._constructLegendElements(o)),s)];if(this.respectLayerVisibility){const i=t((()=>e.legendEnabled),(e=>this._legendEnabledHandle(e,o))),s=t((()=>r.legendEnabled),(e=>this._legendEnabledHandle(e,o)));n.push(i,s)}this.addHandles(n,i)}o.isScaleDriven||this._constructLegendElements(o),this._addActiveLayerInfo(o)}_titleHandle(e,r){r.title=e,this._constructLegendElements(r)}_legendEnabledHandle(e,r){e?this._addActiveLayerInfo(r):this._removeActiveLayerInfo(r)}_scaleHandle(e){(e.isScaleDriven||e.hideLayersNotInCurrentView)&&this._constructLegendElements(e)}_addActiveLayerInfo(e){const{layerView:r,layer:i}=e;if(this._isLayerActive(r)&&!this.activeLayerInfos.includes(e)){const r=e.parent;if(r)r.children.includes(e)||r.children.push(e),this._sortActiveLayerInfos(r.children);else{const r=this.layerInfos?.some((e=>e.layer.uid===i.uid));i.parent&&"uid"in i.parent&&!r?this._activeLayerInfosWithNoParent.add(e):(this.activeLayerInfos.add(e),this._sortActiveLayerInfos(this.activeLayerInfos))}if(this._activeLayerInfosWithNoParent.length){const e=[];this._activeLayerInfosWithNoParent.forEach((r=>{const i=r.layer.parent,t=i&&"uid"in i?this._layerViewByLayerId[i?.uid]:null,s=this._activeLayerInfosByLayerViewId[t?.uid];s&&(e.push(r),r.parent=s)})),e.length&&(this._activeLayerInfosWithNoParent.removeMany(e),e.forEach((e=>this._addActiveLayerInfo(e))))}}}_removeActiveLayerInfo(e){const r=e.parent;r?r.children.remove(e):this.activeLayerInfos.remove(e)}_constructLegendElements(e){const r=e.layer;"featureCollections"in r&&r.featureCollections?e.buildLegendElementsForFeatureCollections(r.featureCollections):"featureReduction"in r&&r.featureReduction&&"renderer"in r.featureReduction&&("binning"===r.featureReduction.type||"cluster"===r.featureReduction.type)&&(!this.view||r.featureReduction.maxScale<=this.view.scale)?e.buildLegendElementsForFeatureReduction(r.featureReduction):"renderer"in r&&r.renderer&&!("sublayers"in r)?e.buildLegendElementsForRenderer(r.renderer):"url"in r&&r.url?e.buildLegendElementsForTools():e.children.forEach((e=>this._constructLegendElements(e)))}};e([n({type:L})],w.prototype,"activeLayerInfos",void 0),e([n()],w.prototype,"basemapLegendVisible",void 0),e([n()],w.prototype,"groundLegendVisible",void 0),e([n()],w.prototype,"hideLayersNotInCurrentView",void 0),e([n()],w.prototype,"keepCacheOnDestroy",void 0),e([n()],w.prototype,"respectLayerVisibility",void 0),e([n()],w.prototype,"layerInfos",void 0),e([n({readOnly:!0})],w.prototype,"state",null),e([n()],w.prototype,"view",void 0),w=e([o("esri.widgets.Legend.LegendViewModel")],w);const I=w;export{I as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import r from"../../core/Accessor.js";import i from"../../core/Collection.js";import{watch as t,initial as s,when as a}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{get as l}from"../../core/accessorSupport/get.js";import{getEffectiveFeatureReduction as y}from"../../views/2d/layers/features/layerAdapters/featureReductionUtils.js";import d from"./support/ActiveLayerInfo.js";import{onLocaleChange as h}from"../../intl/locale.js";const c={state:"state",view:"view",allLayerViews:"all-layer-views",legendProperties:"legend-properties"},L=i.ofType(d),u=new Set(["esri.layers.BuildingSceneLayer","esri.layers.CSVLayer","esri.layers.FeatureLayer","esri.layers.GeoJSONLayer","esri.layers.GeoRSSLayer","esri.layers.GroupLayer","esri.layers.HeatmapLayer","esri.layers.ImageryLayer","esri.layers.ImageryTileLayer","esri.layers.MapImageLayer","esri.layers.OGCFeatureLayer","esri.layers.OrientedImageryLayer","esri.layers.PointCloudLayer","esri.layers.StreamLayer","esri.layers.SceneLayer","esri.layers.SubtypeGroupLayer","esri.layers.TileLayer","esri.layers.VoxelLayer","esri.layers.WFSLayer","esri.layers.WMSLayer","esri.layers.WMTSLayer","esri.layers.WCSLayer","esri.layers.LinkChartLayer","esri.layers.knowledgeGraph.KnowledgeGraphSublayer"]),f="view.basemapView.baseLayerViews",p="view.groundView.layerViews",v="view.basemapView.referenceLayerViews",_=[f,p,"view.layerViews",v];let w=class extends r{constructor(e){super(e),this._layerViewByLayerId={},this._layerInfosByLayerViewId={},this._activeLayerInfosByLayerViewId={},this._activeLayerInfosWithNoParent=new i,this.activeLayerInfos=new L,this.basemapLegendVisible=!1,this.groundLegendVisible=!1,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerVisibility=!0,this.layerInfos=[],this.view=null}initialize(){this.addHandles(t((()=>this.view),(()=>this._viewHandles()),s),c.view),this.addHandles(h((()=>this._refresh())))}destroy(){this._destroyViewActiveLayerInfos(),this.view=null}get state(){return this.view?.ready?"ready":"disabled"}_viewHandles(){this.removeHandles(c.state),this.view&&this.addHandles(t((()=>this.state),(()=>this._stateHandles()),s),c.state)}_stateHandles(){this._resetAll(),"ready"===this.state&&this._watchPropertiesAndAllLayerViews()}_resetAll(){this.removeHandles([c.allLayerViews,c.legendProperties]),this._destroyViewActiveLayerInfos(),this.activeLayerInfos.removeAll()}_destroyViewActiveLayerInfos(){Object.keys(this._activeLayerInfosByLayerViewId).forEach(this._destroyViewActiveLayerInfo,this)}_destroyViewActiveLayerInfo(e){this.removeHandles(e);const r=this._activeLayerInfosByLayerViewId[e];delete this._activeLayerInfosByLayerViewId[e],r?.parent&&r.parent.children.remove(r)}_watchPropertiesAndAllLayerViews(){const{view:e}=this;if(!e)return;const{allLayerViews:r}=e;r.length&&this._refresh(),this.addHandles(r.on("change",(e=>this._propertiesChangeHandle())),c.allLayerViews),this.addHandles(t((()=>[this.layerInfos,this.basemapLegendVisible,this.groundLegendVisible]),(()=>this._propertiesChangeHandle())),c.legendProperties)}_propertiesChangeHandle(){this._destroyViewActiveLayerInfos(),this._refresh()}_refresh(){this._layerInfosByLayerViewId={},this.activeLayerInfos.removeAll(),this._generateLayerViews().filter(this._filterLayerViewsByLayerInfos,this).filter(this._isLayerViewSupported,this).forEach(this._generateActiveLayerInfo,this),this._sortActiveLayerInfos(this.activeLayerInfos)}_sortActiveLayerInfos(e){const r=this.view;if(e.length<2||!r)return;const i=[];e.forEach((r=>{if(!r.parent){const t=r.layer.parent,s=t&&"uid"in t&&this._layerViewByLayerId[t.uid],a=s&&this._activeLayerInfosByLayerViewId[s.uid];a&&e.includes(a)&&(i.push(r),r.parent=a,a.children.add(r),this._sortActiveLayerInfos(a.children))}})),e.removeMany(i);const t={};r.allLayerViews.forEach(((e,r)=>t[e.layer.uid]=r)),e.sort(((e,r)=>{const i=t[e.layer.uid]||0;return(t[r.layer.uid]||0)-i}))}_generateLayerViews(){const e=[];return _.filter(this._filterLayerViews,this).map((e=>l(this,e))).filter((e=>null!=e)).forEach(this._collectLayerViews("layerViews",e)),e}_filterLayerViews(e){const r=!this.basemapLegendVisible&&(e===f||e===v),i=!this.groundLegendVisible&&e===p;return!r&&!i}_collectLayerViews(e,r){const i=t=>(t&&t.forEach((t=>{r.push(t),i(t[e])})),r);return i}_filterLayerViewsByLayerInfos(e){const r=this.layerInfos;return!r||!r.length||r.some((r=>this._hasLayerInfo(r,e)))}_hasLayerInfo(e,r){const i=this._isLayerUIDMatching(e.layer,r.layer.uid);return i&&(this._layerInfosByLayerViewId[r.uid]=e),i}_isLayerUIDMatching(e,r){return e&&(e.uid===r||this._hasLayerUID(e.layers,r))}_hasLayerUID(e,r){return e&&e.some((e=>this._isLayerUIDMatching(e,r)))}_isLayerViewSupported(e){return!!u.has(e.layer.declaredClass)&&(this._layerViewByLayerId[e.layer.uid]=e,!0)}_generateActiveLayerInfo(e){this._isLayerActive(e)?this._buildActiveLayerInfo(e):(this.removeHandles(e.uid),this.addHandles(t((()=>[e.legendEnabled,e.layer?.legendEnabled]),(()=>this._layerActiveHandle(e))),e.uid))}_layerActiveHandle(e){this._isLayerActive(e)&&(this.removeHandles(e.uid),this._buildActiveLayerInfo(e))}_isLayerActive(e){return!this.respectLayerVisibility||e.legendEnabled&&e.layer?.legendEnabled}_buildActiveLayerInfo(e){const r=e.layer,i=e.uid,n=this._layerInfosByLayerViewId[i];let o=this._activeLayerInfosByLayerViewId[i];if(!o){const t=void 0!==n?.title&&n.layer.uid===r.uid;o=new d({layer:r,layerView:e,title:t?n.title:r.title,view:this.view,respectLayerVisibility:this.respectLayerVisibility,hideLayersNotInCurrentView:this.hideLayersNotInCurrentView,keepCacheOnDestroy:this.keepCacheOnDestroy,sublayerIds:n?.sublayerIds||[]}),this._activeLayerInfosByLayerViewId[i]=o}const l=r.parent&&"uid"in r.parent?this._layerViewByLayerId[r.parent?.uid]:null;if(o.parent=this._activeLayerInfosByLayerViewId[l?.uid],!this.hasHandles(i)){const n=[t((()=>r.title),(e=>this._titleHandle(e,o))),t((()=>[r.opacity,"renderer"in r&&r.renderer,"pointSymbol"in r&&r.pointSymbol,"lineSymbol"in r&&r.lineSymbol,"polygonSymbol"in r&&r.polygonSymbol]),(()=>this._constructLegendElements(o))),a((()=>!0===this.view?.stationary),(()=>this._scaleHandle(o)),s),t((()=>e.layer?y(e.layer,e.view):null),(()=>this._constructLegendElements(o))),t((()=>e.updating),(()=>{if(null==e.layer)return;null!=y(e.layer,e.view)&&this._constructLegendElements(o)})),t((()=>"effect"in r&&r.effect),(()=>this._constructLegendElements(o))),a((()=>this.view?.timeZone),(()=>this._constructLegendElements(o)),s)];if(this.respectLayerVisibility){const i=t((()=>e.legendEnabled),(e=>this._legendEnabledHandle(e,o))),s=t((()=>r.legendEnabled),(e=>this._legendEnabledHandle(e,o)));n.push(i,s)}this.addHandles(n,i)}o.isScaleDriven||this._constructLegendElements(o),this._addActiveLayerInfo(o)}_titleHandle(e,r){r.title=e,this._constructLegendElements(r)}_legendEnabledHandle(e,r){e?this._addActiveLayerInfo(r):this._removeActiveLayerInfo(r)}_scaleHandle(e){(e.isScaleDriven||e.hideLayersNotInCurrentView)&&this._constructLegendElements(e)}_addActiveLayerInfo(e){const{layerView:r,layer:i}=e;if(this._isLayerActive(r)&&!this.activeLayerInfos.includes(e)){const r=e.parent;if(r)r.children.includes(e)||r.children.push(e),this._sortActiveLayerInfos(r.children);else{const r=this.layerInfos?.some((e=>e.layer.uid===i.uid));i.parent&&"uid"in i.parent&&!r?this._activeLayerInfosWithNoParent.add(e):(this.activeLayerInfos.add(e),this._sortActiveLayerInfos(this.activeLayerInfos))}if(this._activeLayerInfosWithNoParent.length){const e=[];this._activeLayerInfosWithNoParent.forEach((r=>{const i=r.layer.parent,t=i&&"uid"in i?this._layerViewByLayerId[i?.uid]:null,s=this._activeLayerInfosByLayerViewId[t?.uid];s&&(e.push(r),r.parent=s)})),e.length&&(this._activeLayerInfosWithNoParent.removeMany(e),e.forEach((e=>this._addActiveLayerInfo(e))))}}}_removeActiveLayerInfo(e){const r=e.parent;r?r.children.remove(e):this.activeLayerInfos.remove(e)}_constructLegendElements(e){const r=e.layer;"featureCollections"in r&&r.featureCollections?e.buildLegendElementsForFeatureCollections(r.featureCollections):"featureReduction"in r&&r.featureReduction&&"renderer"in r.featureReduction&&("binning"===r.featureReduction.type||"cluster"===r.featureReduction.type)&&(!this.view||r.featureReduction.maxScale<=this.view.scale)?e.buildLegendElementsForFeatureReduction(r.featureReduction):"renderer"in r&&r.renderer&&!("sublayers"in r)?e.buildLegendElementsForRenderer(r.renderer):"url"in r&&r.url?e.buildLegendElementsForTools():e.children.forEach((e=>this._constructLegendElements(e)))}};e([n({type:L})],w.prototype,"activeLayerInfos",void 0),e([n()],w.prototype,"basemapLegendVisible",void 0),e([n()],w.prototype,"groundLegendVisible",void 0),e([n()],w.prototype,"hideLayersNotInCurrentView",void 0),e([n()],w.prototype,"keepCacheOnDestroy",void 0),e([n()],w.prototype,"respectLayerVisibility",void 0),e([n()],w.prototype,"layerInfos",void 0),e([n({readOnly:!0})],w.prototype,"state",null),e([n()],w.prototype,"view",void 0),w=e([o("esri.widgets.Legend.LegendViewModel")],w);const I=w;export{I as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{getAssetUrl as t}from"../../assets.js";import s from"../../config.js";import r from"../../Graphic.js";import o from"../../PopupTemplate.js";import"../../symbols.js";import i from"../../core/Accessor.js";import{isSome as l}from"../../core/arrayUtils.js";import a from"../../core/Collection.js";import n from"../../core/Error.js";import u from"../../core/Evented.js";import c from"../../core/Logger.js";import{mappedFind as h}from"../../core/maybe.js";import{eachAlways as p,after as g}from"../../core/promiseUtils.js";import{watch as d,whenOnce as m,initial as y}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as S}from"../../core/accessorSupport/decorators/subclass.js";import _ from"../../geometry/Point.js";import v from"../../geometry/SpatialReference.js";import{getPointFromGeometry as w,getPointWithElevation as b}from"../../geometry/support/geometryUtils.js";import{onLocaleChange as x}from"../../intl/locale.js";import{fetchMessageBundle as L}from"../../intl/messages.js";import I from"../../portal/Portal.js";import{highlightsSupported as T}from"../../views/support/layerViewUtils.js";import R from"./LayerSearchSource.js";import E from"./LocatorSearchSource.js";import F from"./SearchSource.js";import{isArcGISWorldGeocoder as j,meteredArcGISLocatorUrl as P,isProxiedArcGISWorldGeocoder as C,isMeteredArcGISWorldGeocoder as G}from"./support/locatorUtils.js";import{supported as O,getCurrentPosition as A,positionToPoint as N}from"../support/geolocationUtils.js";import{GoToMixin as D}from"../support/GoTo.js";import M from"../../symbols/PictureMarkerSymbol.js";import V from"../../symbols/SimpleLineSymbol.js";import k from"../../symbols/SimpleFillSymbol.js";import J from"../../symbols/TextSymbol.js";function H(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const U=()=>L("esri/widgets/Search/t9n/Search"),B="highlight",Q=a.ofType({key:e=>e.layer?"layer":"locator",base:F,typeMap:{layer:R,locator:E}}),Z=v.WGS84,q="esri/images/search/search-symbol-32.png",z=/<[\s\S]*?>/g,K=-1;let W=class extends(D(u.EventedMixin(i))){constructor(e){super(e),this._gotoController=null,this._searching=null,this._updatingPromise=null,this._createdFeatureLayers=[],this.autoNavigate=!0,this.autoSelect=!0,this.defaultPopupTemplate=null,this.defaultSources=new Q,this.defaultSymbols={point:new M({url:t(q),size:24,width:24,height:24}),polyline:new V({color:[130,130,130,1],width:2}),polygon:new k({color:[235,235,235,.4],outline:{color:[130,130,130,1],width:2}})},this.includeDefaultSources=!0,this.maxInputLength=128,this.maxResults=6,this.maxSuggestions=6,this.messages=null,this.minSuggestCharacters=3,this.popupEnabled=!0,this.popupTemplate=null,this.portal=I.getDefault(),this.resultCount=null,this.resultGraphicEnabled=!0,this.resultGraphic=null,this.results=null,this.selectedSuggestion=null,this.searchAllEnabled=!0,this.selectedResult=null,this.sources=new Q,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){const e=async()=>{const e=await U();this.messages=e,this.defaultPopupTemplate=new o({title:e.searchResult,content:"{Match_addr}"})};e(),this.addHandles([d((()=>[this.includeDefaultSources,this.view,this.portal]),(()=>this._update()),y),x(e)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics()}get activeSource(){return this.allSources.at(this.activeSourceIndex)??null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:K}set activeSourceIndex(e){this._overrideIfSome("activeSourceIndex",e)}get allPlaceholder(){return this.messages?.allPlaceholder}set allPlaceholder(e){this._overrideIfSome("allPlaceholder",e)}get allSources(){const{sources:e,defaultSources:t,includeDefaultSources:s}=this,r="function"==typeof s?s.call(null,{sources:e,defaultSources:t}):s?t.concat(e):e,o=this._get("allSources")||new Q;return o.removeAll(),o.addMany(r.filter(Boolean)),o}get locationEnabled(){return this._get("locationEnabled")||O()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=O();if(e&&!t){const e=new n("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});c.getLogger(this).error(e)}this._override("locationEnabled",!!e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:s}=this;if(t===K)return s??"";const r=e.at(t);return r?.placeholder??""}set searchTerm(e){this._set("searchTerm",e||""),this.clearGraphics(),this.selectedSuggestion&&this.selectedSuggestion.text!==e&&this._set("selectedSuggestion",null),""===e&&this._clear()}get searchTerm(){return this._get("searchTerm")||""}get state(){return this._searching?"searching":this.updating?"loading":0===this.allSources.length?"disabled":"ready"}get updating(){return null!=this._updatingPromise}clear(){this.searchTerm=""}clearGraphics(){this._removeHighlight(),this._closePopup();const{view:e,resultGraphic:t}=this;e&&t&&e.graphics.remove(t),this._set("resultGraphic",null)}search(e,t){this.emit("search-start"),this.clearGraphics();const s=this._createSuggestionForSearch(e),r=(async()=>{try{await this.when();const e=await this._getResultsFromSources(s,t);if(t?.signal?.aborted)return null;const r={activeSourceIndex:this.activeSourceIndex,searchTerm:s.text??"",numResults:0,numErrors:0,errors:[],results:[]};this._formatResponse(r,e,s);const o=this._getFirstResult(r.results),i=s.location&&o?o.name:s.text,l=i?.replace(z,"");return this._set("searchTerm",l),(s.key&&"number"==typeof s.sourceIndex||s.location)&&this._set("selectedSuggestion",s),this._set("results",r.results),this._set("resultCount",r.results.reduce(((e,t)=>e+(t.results?.length??0)),0)),this.emit("search-complete",r),await this._selectFirstResult(o),r}finally{this._clearSearching()}})();return this._searching=r,r}async searchNearby(e){if(!this.locationEnabled){const e=new n("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});throw c.getLogger(this).error(e),e}const t=(async()=>{try{const t=await A(),s=await N({position:t,view:this.view},e);return await this.search(s,e)}finally{this._clearSearching()}})();return this._searching=t,t}async select(e){if(this.clearGraphics(),!e){const t=new n("select:missing-parameter","Cannot select without a searchResult.",{searchResult:e});throw c.getLogger(this).error(t),t}const{view:t}=this,s=H(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=null!=s?this.allSources.at(s):null;if(!o){const e=new n("select:missing-source","Cannot select without a source.",{source:o});throw c.getLogger(this).error(e),e}const i=o instanceof R?this._getLayerSourcePopupTemplate(o):o.popupTemplate,l=o.resultSymbol||this._getDefaultSymbol(e),a=H(o,"resultGraphicEnabled")?o.resultGraphicEnabled:this.resultGraphicEnabled,u=H(o,"autoNavigate")?o.autoNavigate:this.autoNavigate,h=(H(o,"popupEnabled")?o.popupEnabled:this.popupEnabled)?i||this.popupTemplate||this.defaultPopupTemplate:null,{feature:g}=e;if(!g){const e=new n("select:missing-feature","Cannot select without a feature.",{feature:g});throw c.getLogger(this).error(e),e}const{attributes:d,geometry:m,layer:y,sourceLayer:f}=g,S=m?w(m):null,_={layerViewQuery:this._getLayerView(g),elevationQuery:t&&null!=S?b(S,t):Promise.resolve(S)},v=await p(_),x=v.layerViewQuery.value,L=v.elevationQuery.value;l instanceof J&&(l.text=e.name);const I=t&&u?e.target||e.extent:null,E=null!=I?this._goToSearchResult(I):Promise.resolve();await E;const F=x?g:new r({geometry:m,symbol:l,attributes:d,layer:y,sourceLayer:f,popupTemplate:h}),j=t?.popup,P=j&&F.getEffectivePopupTemplate(j.defaultPopupTemplateEnabled);return P&&await t.openPopup({features:[F],location:L}),x&&T(x)&&!P&&this._highlightFeature({graphic:F,layerView:x}),!x&&a&&t&&t.graphics.push(F),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",F),this.emit("select-result",{result:e,source:o,sourceIndex:s}),e}async suggest(e,t,s){const r=e||this.searchTerm;this.emit("suggest-start",{searchTerm:r}),await this._suggestTimer(t,s);const o=await this._suggestImmediate(r,s);return this._set("suggestions",o?.results),this._set("suggestionCount",o?.results.reduce(((e,t)=>e+(t.results?.length??0)),0)??null),this.emit("suggest-complete",o),o}async when(){await m((()=>!this.updating))}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const s=this._updatingPromise=p([e?.load(),t?.when()]);if(this.destroyed)return;if(await s,s!==this._updatingPromise)return}await m((()=>this.messages)),this.destroyed||this._updateDefaultSources(),this._updatingPromise=null}_clearSearching(){this._searching=null}_convertHelperServices(){const e=this.portal?.helperServices?.geocode;if(!e)return[];return e.map((e=>{if(!1===e.placefinding)return;const t=s.apiKey&&j(e.url)?{url:P}:null,r=E.fromJSON({...e,...t}),o=r.url;if(j(o)||C(o)||G(o)){const e=r.outFields??["Addr_type","Match_addr","StAddr","City"],t=(r.placeholder||this.messages?.placeholder)??"",s="number"==typeof r.defaultZoomScale?r.defaultZoomScale:2500;r.singleLineFieldName="SingleLine",r.outFields=e,r.placeholder=t,r.defaultZoomScale=s}return r.singleLineFieldName?r:void 0})).filter(l)}_destroyFeatureLayers(){this._createdFeatureLayers.forEach((e=>e?.destroy())),this._createdFeatureLayers=[]}_getLayerSources(e,t){const s=this.view?.map;return e.map((e=>{const r=s.findLayerById(e.id);if(!r)return;const o=this._getLayerJSON(e),i=R.fromJSON(o);return i.placeholder=t,this._getLayer(r,o).then((e=>{i.layer=e})),i})).filter(l).toArray()}_getTableSources(e,t){const s=this.view?.map;return e.map((e=>{if(!e.id)return;const r=s.findTableById(e.id);if(!r)return;const o=this._getLayerJSON(e),i=R.fromJSON(o);return i.placeholder=t,this._getLayer(r,o).then((e=>{i.layer=e})),i})).filter(l).toArray()}_convertApplicationProperties(){const e=this.view?.map,t=e?.applicationProperties?.viewing?.search;if(!t)return[];const{enabled:s,hintText:r,layers:o,tables:i}=t;if(!s)return[];return[...this._getLayerSources(o,r),...this._getTableSources(i,r)]}async _getSubLayer(e,t){if(await e.load(),!e.allSublayers)throw new Error;const s=e.allSublayers.find((e=>e.id===t.subLayer));if(!s)throw new Error;const r=await(s.createFeatureLayer?.());if(!r)throw new Error;return this._createdFeatureLayers.push(r),r}async _getBuildingSubLayer(e,t){await e.load();const s=e.allSublayers.find((e=>e.id===t.subLayer));if("building-component"!==s?.type)throw new Error;if(await s.load(),null==s.associatedLayer)throw new Error;return await s.associatedLayer.load(),s}async _getLayer(e,t){if("feature"===e.type||"scene"===e.type||"csv"===e.type||"geojson"===e.type||"ogc-feature"===e.type)return e;if("map-image"===e.type)try{return await this._getSubLayer(e,t)}catch(s){const t=new n("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return c.getLogger(this).error(t),null}return"building-scene"===e.type?this._getBuildingSubLayer(e,t):null}_getLayerJSON(e){return"function"==typeof e.toJSON?e.toJSON():e}_updateDefaultSources(){const{defaultSources:e,includeDefaultSources:t}=this;this._destroyFeatureLayers(),e.removeAll(),t&&e.addMany([...this._convertApplicationProperties(),...this._convertHelperServices()])}_abortGoTo(){this._gotoController&&this._gotoController.abort(),this._gotoController=null}_clear(){this._abortGoTo(),this._set("resultCount",null),this._set("results",null),this._set("suggestions",null),this._set("suggestionCount",null),this._set("selectedResult",null),this._set("selectedSuggestion",null),this.emit("search-clear")}_closePopup(){const e=this.view?.popup,{resultGraphic:t}=this;if(!e||!t)return;const s="selectedFeature"in e,r=s?e.selectedFeature:null;s&&(r&&r===t)&&e.close()}_suggestTimer(e,t){const s=null!=e?e:this.suggestionDelay;return g(s,null,t?.signal)}_createLocationForSearch(e){return e instanceof r&&e.geometry?w(e.geometry):e instanceof _?e:Array.isArray(e)&&2===e.length?new _({longitude:e[0],latitude:e[1]}):null}_createSuggestionForSearch(e){if(e&&H(e,"key")&&H(e,"text")&&H(e,"sourceIndex"))return e;const t=this._createLocationForSearch(e),s="string"==typeof e?e:this.searchTerm,{selectedSuggestion:r,selectedResult:o}=this,i=!e&&r&&o,l=i&&r.key===o.key&&r.sourceIndex===o.sourceIndex,a=i&&r.location;return l||a?r:{location:t,text:t?"":s,sourceIndex:null,key:null}}_getFirstResult(e){return h(e,(({results:e})=>e?.[0]))??null}async _selectFirstResult(e){return this.autoSelect&&e?this.select(e):null}async _suggestImmediate(e,t){await this.when();const s=await this._getSuggestionsFromSources(e,t);if(t?.signal?.aborted)return null;const r={activeSourceIndex:this.activeSourceIndex,searchTerm:e??"",numResults:0,numErrors:0,errors:[],results:[]};return this._formatResponse(r,s),r}_formatSourceResponse(e,t,s){const r=t?.value||[],o=t?.error,i=this.allSources.at(s);if(o){const t={sourceIndex:s,source:i,error:o};e.errors.push(t),c.getLogger(this).error(o),e.numErrors++}else{const t={sourceIndex:s,source:i,results:r};e.results.push(t),e.numResults+=r.length}}_formatResponse(e,t,s){if(t)if(e.activeSourceIndex===K){const r=s&&H(s,"sourceIndex")&&-1!==s.sourceIndex?s.sourceIndex:void 0;t.forEach(((t,s)=>{const o=void 0!==r?r:s;this._formatSourceResponse(e,t,o)}))}else this._formatSourceResponse(e,t[0],e.activeSourceIndex)}async _getResultsFromSources(e,t){const{allSources:s}=this,r=!e.location&&H(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!s.length){const e=new n("search:no-sources-defined","At least one source is required.",{allSources:s});throw c.getLogger(this).error(e),e}return r===K?s.forEach(((s,r)=>{o.push(this._getResultsFromSource(e,r,t))})):o.push(this._getResultsFromSource(e,r,t)),p(o)}async _getSuggestionsFromSources(e,t){const{allSources:s,activeSourceIndex:r}=this,o=[];if(!s.length){const e=new n("suggest:no-sources-defined","At least one source is required.",{allSources:s});throw c.getLogger(this).error(e),e}return r===K?s.forEach(((s,r)=>{o.push(this._getSuggestionsFromSource(e,r,t))})):o.push(this._getSuggestionsFromSource(e,r,t)),p(o)}async _getResultsFromSource(e,t,s){const r=null!=t?this.allSources.at(t):null;if(!r)return null;const{location:o=null}=e,i=this.view?.spatialReference||Z,l=H(r,"maxResults")?r.maxResults:this.maxResults,a=!!(r instanceof R&&H(r,"exactMatch"))&&r.exactMatch,{view:n}=this;return r.getResults?.({view:n,sourceIndex:t,location:o,suggestResult:e,spatialReference:i,exactMatch:a,maxResults:l},s)}async _getSuggestionsFromSource(e,t,s){const r=this.allSources.at(t);if(!r)return null;e??="";const o=H(r,"suggestionsEnabled")?r.suggestionsEnabled:this.suggestionsEnabled,i=e?.length,l=H(r,"minSuggestCharacters")?r.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||Z,i=H(r,"maxSuggestions")?r.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(r instanceof R&&H(r,"exactMatch"))&&r.exactMatch;return r.getSuggestions?.({view:l,sourceIndex:t,suggestTerm:e,spatialReference:o,maxSuggestions:i,exactMatch:a},s)}return null}_getLayerSourcePopupTemplate(e){const{layer:t}=e;if(t)return H(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){const t=this.results?.some((({results:t})=>t?.includes(e)));return t?e.sourceIndex??null:null}async _goToSearchResult(e){this._abortGoTo();const t=new AbortController;this._gotoController=t;const s={target:{target:e},options:{signal:t.signal}};e||(s.options.animate=!1),await this.callGoTo(s),this._gotoController=null}_getDefaultSymbol(e){const{defaultSymbols:t}=this,s=e.feature?.geometry;if(null==s)return null;switch(s.type){case"point":case"multipoint":return t.point;case"polyline":return t.polyline;case"extent":case"polygon":return t.polygon;default:return null}}_removeHighlight(){this.removeHandles(B)}async _getLayerView(e){const{view:t}=this;if(!e||!t||"building-component"===e.layer?.type||"subtype-sublayer"===e.layer?.type)return null;const{layer:s}=e;return s?(await t.when(),t.whenLayerView(s)):null}_highlightFeature(e){const{graphic:t,layerView:s}=e,{attributes:r,layer:o}=t,{objectIdField:i}=o,l=(i&&r?.[i])??null,a=s.highlight(l??t);this.addHandles(a,B)}_setResultFloor(e){const{view:t}=this,s=e.feature?.attributes,r=e.feature?.sourceLayer;if(r&&"floorInfo"in r&&r?.floorInfo?.floorField&&s){const e=s[r.floorInfo.floorField];t?.emit("select-result-floor",e)}}};W.ALL_INDEX=K,e([f()],W.prototype,"_searching",void 0),e([f()],W.prototype,"_updatingPromise",void 0),e([f({readOnly:!0,value:null})],W.prototype,"activeSource",null),e([f()],W.prototype,"activeSourceIndex",null),e([f()],W.prototype,"allPlaceholder",null),e([f({readOnly:!0})],W.prototype,"allSources",null),e([f()],W.prototype,"autoNavigate",void 0),e([f()],W.prototype,"autoSelect",void 0),e([f()],W.prototype,"defaultPopupTemplate",void 0),e([f({readOnly:!0})],W.prototype,"defaultSources",void 0),e([f()],W.prototype,"defaultSymbols",void 0),e([f()],W.prototype,"includeDefaultSources",void 0),e([f()],W.prototype,"locationEnabled",null),e([f()],W.prototype,"maxInputLength",void 0),e([f()],W.prototype,"maxResults",void 0),e([f()],W.prototype,"maxSuggestions",void 0),e([f()],W.prototype,"messages",void 0),e([f()],W.prototype,"minSuggestCharacters",void 0),e([f({readOnly:!0})],W.prototype,"placeholder",null),e([f()],W.prototype,"popupEnabled",void 0),e([f({type:o})],W.prototype,"popupTemplate",void 0),e([f({type:I})],W.prototype,"portal",void 0),e([f()],W.prototype,"resultCount",void 0),e([f()],W.prototype,"resultGraphicEnabled",void 0),e([f({readOnly:!0})],W.prototype,"resultGraphic",void 0),e([f({readOnly:!0})],W.prototype,"results",void 0),e([f({readOnly:!0})],W.prototype,"selectedSuggestion",void 0),e([f()],W.prototype,"searchAllEnabled",void 0),e([f({readOnly:!0})],W.prototype,"selectedResult",void 0),e([f()],W.prototype,"searchTerm",null),e([f({type:Q})],W.prototype,"sources",void 0),e([f({readOnly:!0})],W.prototype,"state",null),e([f()],W.prototype,"suggestionDelay",void 0),e([f()],W.prototype,"suggestionCount",void 0),e([f({readOnly:!0})],W.prototype,"suggestions",void 0),e([f()],W.prototype,"suggestionsEnabled",void 0),e([f({readOnly:!0})],W.prototype,"updating",null),e([f()],W.prototype,"view",void 0),e([f()],W.prototype,"clear",null),W=e([S("esri.widgets.Search.SearchViewModel")],W);const X=W;export{X as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{getAssetUrl as t}from"../../assets.js";import r from"../../config.js";import s from"../../Graphic.js";import o from"../../PopupTemplate.js";import"../../symbols.js";import i from"../../core/Accessor.js";import{isSome as l}from"../../core/arrayUtils.js";import a from"../../core/Collection.js";import n from"../../core/Error.js";import u from"../../core/Evented.js";import c from"../../core/Logger.js";import{mappedFind as h}from"../../core/maybe.js";import{eachAlways as p,after as g}from"../../core/promiseUtils.js";import{watch as d,whenOnce as m,initial as y}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as S}from"../../core/accessorSupport/decorators/subclass.js";import _ from"../../geometry/Point.js";import v from"../../geometry/SpatialReference.js";import{getPointFromGeometry as w,getPointWithElevation as b}from"../../geometry/support/geometryUtils.js";import{onLocaleChange as x}from"../../intl/locale.js";import{fetchMessageBundle as L}from"../../intl/messages.js";import I from"../../portal/Portal.js";import{highlightsSupported as T}from"../../views/support/layerViewUtils.js";import R from"./LayerSearchSource.js";import E from"./LocatorSearchSource.js";import F from"./SearchSource.js";import{isArcGISWorldGeocoder as j,meteredArcGISLocatorUrl as P,isProxiedArcGISWorldGeocoder as C,isMeteredArcGISWorldGeocoder as G}from"./support/locatorUtils.js";import{supported as O,getCurrentPosition as A,positionToPoint as N}from"../support/geolocationUtils.js";import{GoToMixin as D}from"../support/GoTo.js";import M from"../../symbols/PictureMarkerSymbol.js";import V from"../../symbols/SimpleLineSymbol.js";import k from"../../symbols/SimpleFillSymbol.js";import J from"../../symbols/TextSymbol.js";function H(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const U=()=>L("esri/widgets/Search/t9n/Search"),B="highlight",Q=a.ofType({key:e=>e.layer?"layer":"locator",base:F,typeMap:{layer:R,locator:E}}),Z=v.WGS84,q="esri/images/search/search-symbol-32.png",z=/<[\s\S]*?>/g,K=-1;let W=class extends(D(u.EventedMixin(i))){constructor(e){super(e),this._gotoController=null,this._searching=null,this._updatingPromise=null,this._createdFeatureLayers=[],this.autoNavigate=!0,this.autoSelect=!0,this.defaultPopupTemplate=null,this.defaultSources=new Q,this.defaultSymbols={point:new M({url:t(q),size:24,width:24,height:24}),polyline:new V({color:[130,130,130,1],width:2}),polygon:new k({color:[235,235,235,.4],outline:{color:[130,130,130,1],width:2}})},this.includeDefaultSources=!0,this.maxInputLength=128,this.maxResults=6,this.maxSuggestions=6,this.messages=null,this.minSuggestCharacters=3,this.popupEnabled=!0,this.popupTemplate=null,this.portal=I.getDefault(),this.resultCount=null,this.resultGraphicEnabled=!0,this.resultGraphic=null,this.results=null,this.selectedSuggestion=null,this.searchAllEnabled=!0,this.selectedResult=null,this.sources=new Q,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){const e=async()=>{const e=await U();this.messages=e,this.defaultPopupTemplate=new o({title:e.searchResult,content:"{Match_addr}"})};e(),this.addHandles([d((()=>[this.includeDefaultSources,this.view,this.portal]),(()=>this._update()),y),x(e)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics()}get activeSource(){return this.allSources.at(this.activeSourceIndex)??null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:K}set activeSourceIndex(e){this._overrideIfSome("activeSourceIndex",e)}get allPlaceholder(){return this.messages?.allPlaceholder}set allPlaceholder(e){this._overrideIfSome("allPlaceholder",e)}get allSources(){const{sources:e,defaultSources:t,includeDefaultSources:r}=this,s="function"==typeof r?r.call(null,{sources:e,defaultSources:t}):r?t.concat(e):e,o=this._get("allSources")||new Q;return o.removeAll(),o.addMany(s.filter(Boolean)),o}get locationEnabled(){return this._get("locationEnabled")||O()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=O();if(e&&!t){const e=new n("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});c.getLogger(this).error(e)}this._override("locationEnabled",!!e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:r}=this;if(t===K)return r??"";const s=e.at(t);return s?.placeholder??""}set searchTerm(e){this._set("searchTerm",e||""),this.clearGraphics(),this.selectedSuggestion&&this.selectedSuggestion.text!==e&&this._set("selectedSuggestion",null),""===e&&this._clear()}get searchTerm(){return this._get("searchTerm")||""}get state(){return this._searching?"searching":this.updating?"loading":0===this.allSources.length?"disabled":"ready"}get updating(){return null!=this._updatingPromise}clear(){this.searchTerm=""}clearGraphics(){this._removeHighlight(),this._closePopup();const{view:e,resultGraphic:t}=this;e&&t&&e.graphics.remove(t),this._set("resultGraphic",null)}search(e,t){this.emit("search-start"),this.clearGraphics();const r=this._createSuggestionForSearch(e),s=(async()=>{try{await this.when();const e=await this._getResultsFromSources(r,t);if(t?.signal?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:r.text??"",numResults:0,numErrors:0,errors:[],results:[]};this._formatResponse(s,e,r);const o=this._getFirstResult(s.results),i=r.location&&o?o.name:r.text,l=i?.replace(z,"");return this._set("searchTerm",l),(r.key&&"number"==typeof r.sourceIndex||r.location)&&this._set("selectedSuggestion",r),this._set("results",s.results),this._set("resultCount",s.results.reduce(((e,t)=>e+(t.results?.length??0)),0)),this.emit("search-complete",s),await this._selectFirstResult(o),s}finally{this._clearSearching()}})();return this._searching=s,s}async searchNearby(e){if(!this.locationEnabled){const e=new n("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});throw c.getLogger(this).error(e),e}const t=(async()=>{try{const t=await A(),r=await N({position:t,view:this.view},e);return await this.search(r,e)}finally{this._clearSearching()}})();return this._searching=t,t}async select(e){if(this.clearGraphics(),!e){const t=new n("select:missing-parameter","Cannot select without a searchResult.",{searchResult:e});throw c.getLogger(this).error(t),t}const{view:t}=this,r=H(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=null!=r?this.allSources.at(r):null;if(!o){const e=new n("select:missing-source","Cannot select without a source.",{source:o});throw c.getLogger(this).error(e),e}const i=o instanceof R?this._getLayerSourcePopupTemplate(o):o.popupTemplate,l=o.resultSymbol||this._getDefaultSymbol(e),a=H(o,"resultGraphicEnabled")?o.resultGraphicEnabled:this.resultGraphicEnabled,u=H(o,"autoNavigate")?o.autoNavigate:this.autoNavigate,h=(H(o,"popupEnabled")?o.popupEnabled:this.popupEnabled)?i||this.popupTemplate||this.defaultPopupTemplate:null,{feature:g}=e;if(!g){const e=new n("select:missing-feature","Cannot select without a feature.",{feature:g});throw c.getLogger(this).error(e),e}const{attributes:d,geometry:m,layer:y,sourceLayer:f}=g,S=m?w(m):null,_={layerViewQuery:this._getLayerView(g),elevationQuery:t&&null!=S?b(S,t):Promise.resolve(S)},v=await p(_),x=v.layerViewQuery.value,L=v.elevationQuery.value;l instanceof J&&(l.text=e.name);const I=t&&u?e.target||e.extent:null,E=null!=I?this._goToSearchResult(I):Promise.resolve();await E;const F=x?g:new s({geometry:m,symbol:l,attributes:d,layer:y,sourceLayer:f,popupTemplate:h}),j=t?.popup,P=j&&F.getEffectivePopupTemplate(j.defaultPopupTemplateEnabled);return P&&await t.openPopup({features:[F],location:L}),x&&T(x)&&!P&&this._highlightFeature({graphic:F,layerView:x}),!x&&a&&t&&t.graphics.push(F),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",F),this.emit("select-result",{result:e,source:o,sourceIndex:r}),e}async suggest(e,t,r){const s=e||this.searchTerm;this.emit("suggest-start",{searchTerm:s}),await this._suggestTimer(t,r);const o=await this._suggestImmediate(s,r);return this._set("suggestions",o?.results),this._set("suggestionCount",o?.results.reduce(((e,t)=>e+(t.results?.length??0)),0)??null),this.emit("suggest-complete",o),o}async when(){await m((()=>!this.updating))}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const r=this._updatingPromise=p([e?.load(),t?.when()]);if(this.destroyed)return;if(await r,r!==this._updatingPromise)return}await m((()=>this.messages)),this.destroyed||this._updateDefaultSources(),this._updatingPromise=null}_clearSearching(){this._searching=null}_convertHelperServices(){const e=this.portal?.helperServices?.geocode;if(!e)return[];return e.map((e=>{if(!1===e.placefinding)return;const t=r.apiKey&&j(e.url)?{url:P}:null,s=E.fromJSON({...e,...t}),o=s.url;if(j(o)||C(o)||G(o)){const e=s.outFields??["Addr_type","Match_addr","StAddr","City"],t=(s.placeholder||this.messages?.placeholder)??"",r="number"==typeof s.defaultZoomScale?s.defaultZoomScale:2500;s.singleLineFieldName="SingleLine",s.outFields=e,s.placeholder=t,s.defaultZoomScale=r}return s.singleLineFieldName?s:void 0})).filter(l)}_destroyFeatureLayers(){this._createdFeatureLayers.forEach((e=>e?.destroy())),this._createdFeatureLayers=[]}_getLayerSources(e,t){const r=this.view?.map;return e.map((e=>{const s=r.findLayerById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=R.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then((e=>{i.layer=e})),i})).filter(l).toArray()}_getTableSources(e,t){const r=this.view?.map;return e.map((e=>{if(!e.id)return;const s=r.findTableById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=R.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then((e=>{i.layer=e})),i})).filter(l).toArray()}_convertApplicationProperties(){const e=this.view?.map,t=e?.applicationProperties?.viewing?.search;if(!t)return[];const{enabled:r,hintText:s,layers:o,tables:i}=t;if(!r)return[];return[...this._getLayerSources(o,s),...this._getTableSources(i,s)]}async _getSubLayer(e,t){if(await e.load(),!e.allSublayers)throw new Error;const r=e.allSublayers.find((e=>e.id===t.subLayer));if(!r)throw new Error;const s=await(r.createFeatureLayer?.());if(!s)throw new Error;return this._createdFeatureLayers.push(s),s}async _getBuildingSubLayer(e,t){await e.load();const r=e.allSublayers.find((e=>e.id===t.subLayer));if("building-component"!==r?.type)throw new Error;if(await r.load(),null==r.associatedLayer)throw new Error;return await r.associatedLayer.load(),r}async _getLayer(e,t){if("feature"===e.type||"scene"===e.type||"csv"===e.type||"geojson"===e.type||"ogc-feature"===e.type)return e;if("map-image"===e.type)try{return await this._getSubLayer(e,t)}catch(r){const t=new n("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return c.getLogger(this).error(t),null}return"building-scene"===e.type?this._getBuildingSubLayer(e,t):null}_getLayerJSON(e){return"function"==typeof e.toJSON?e.toJSON():e}_updateDefaultSources(){const{defaultSources:e,includeDefaultSources:t}=this;this._destroyFeatureLayers(),e.removeAll(),t&&e.addMany([...this._convertApplicationProperties(),...this._convertHelperServices()])}_abortGoTo(){this._gotoController&&this._gotoController.abort(),this._gotoController=null}_clear(){this._abortGoTo(),this._set("resultCount",null),this._set("results",null),this._set("suggestions",null),this._set("suggestionCount",null),this._set("selectedResult",null),this._set("selectedSuggestion",null),this.emit("search-clear")}_closePopup(){const e=this.view?.popup,{resultGraphic:t}=this;if(!e||!t)return;const r="selectedFeature"in e,s=r?e.selectedFeature:null;r&&(s&&s===t)&&e.close()}_suggestTimer(e,t){const r=null!=e?e:this.suggestionDelay;return g(r,null,t?.signal)}_createLocationForSearch(e){return e instanceof s&&e.geometry?w(e.geometry):e instanceof _?e:Array.isArray(e)&&2===e.length?new _({longitude:e[0],latitude:e[1]}):null}_createSuggestionForSearch(e){if(e&&H(e,"key")&&H(e,"text")&&H(e,"sourceIndex"))return e;const t=this._createLocationForSearch(e),r="string"==typeof e?e:this.searchTerm,{selectedSuggestion:s,selectedResult:o}=this,i=!e&&s&&o,l=i&&s.key===o.key&&s.sourceIndex===o.sourceIndex,a=i&&s.location;return l||a?s:{location:t,text:t?"":r,sourceIndex:null,key:null}}_getFirstResult(e){return h(e,(({results:e})=>e?.[0]))??null}async _selectFirstResult(e){return this.autoSelect&&e?this.select(e):null}async _suggestImmediate(e,t){await this.when();const r=await this._getSuggestionsFromSources(e,t);if(t?.signal?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:e??"",numResults:0,numErrors:0,errors:[],results:[]};return this._formatResponse(s,r),s}_formatSourceResponse(e,t,r){const s=t?.value||[],o=t?.error,i=this.allSources.at(r);if(o){const t={sourceIndex:r,source:i,error:o};e.errors.push(t),c.getLogger(this).error(o),e.numErrors++}else{const t={sourceIndex:r,source:i,results:s};e.results.push(t),e.numResults+=s.length}}_formatResponse(e,t,r){if(t)if(e.activeSourceIndex===K){const s=r&&H(r,"sourceIndex")&&-1!==r.sourceIndex?r.sourceIndex:void 0;t.forEach(((t,r)=>{const o=void 0!==s?s:r;this._formatSourceResponse(e,t,o)}))}else this._formatSourceResponse(e,t[0],e.activeSourceIndex)}async _getResultsFromSources(e,t){const{allSources:r}=this,s=!e.location&&H(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!r.length){const e=new n("search:no-sources-defined","At least one source is required.",{allSources:r});throw c.getLogger(this).error(e),e}return s===K?r.forEach(((r,s)=>{o.push(this._getResultsFromSource(e,s,t))})):o.push(this._getResultsFromSource(e,s,t)),p(o)}async _getSuggestionsFromSources(e,t){const{allSources:r,activeSourceIndex:s}=this,o=[];if(!r.length){const e=new n("suggest:no-sources-defined","At least one source is required.",{allSources:r});throw c.getLogger(this).error(e),e}return s===K?r.forEach(((r,s)=>{o.push(this._getSuggestionsFromSource(e,s,t))})):o.push(this._getSuggestionsFromSource(e,s,t)),p(o)}async _getResultsFromSource(e,t,r){const s=null!=t?this.allSources.at(t):null;if(!s)return null;const{location:o=null}=e,i=this.view?.spatialReference||Z,l=H(s,"maxResults")?s.maxResults:this.maxResults,a=!!(s instanceof R&&H(s,"exactMatch"))&&s.exactMatch,{view:n}=this;return s.getResults?.({view:n,sourceIndex:t,location:o,suggestResult:e,spatialReference:i,exactMatch:a,maxResults:l},r)}async _getSuggestionsFromSource(e,t,r){const s=this.allSources.at(t);if(!s)return null;e??="";const o=H(s,"suggestionsEnabled")?s.suggestionsEnabled:this.suggestionsEnabled,i=e?.length,l=H(s,"minSuggestCharacters")?s.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||Z,i=H(s,"maxSuggestions")?s.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(s instanceof R&&H(s,"exactMatch"))&&s.exactMatch;return s.getSuggestions?.({view:l,sourceIndex:t,suggestTerm:e,spatialReference:o,maxSuggestions:i,exactMatch:a},r)}return null}_getLayerSourcePopupTemplate(e){const{layer:t}=e;if(t)return H(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){return h(this.results??[],(({results:t,sourceIndex:r})=>{const s=t?.includes(e);return s?r:null}))??null}async _goToSearchResult(e){this._abortGoTo();const t=new AbortController;this._gotoController=t;const r={target:{target:e},options:{signal:t.signal}};e||(r.options.animate=!1),await this.callGoTo(r),this._gotoController=null}_getDefaultSymbol(e){const{defaultSymbols:t}=this,r=e.feature?.geometry;if(null==r)return null;switch(r.type){case"point":case"multipoint":return t.point;case"polyline":return t.polyline;case"extent":case"polygon":return t.polygon;default:return null}}_removeHighlight(){this.removeHandles(B)}async _getLayerView(e){const{view:t}=this;if(!e||!t||"building-component"===e.layer?.type||"subtype-sublayer"===e.layer?.type)return null;const{layer:r}=e;return r?(await t.when(),t.whenLayerView(r)):null}_highlightFeature(e){const{graphic:t,layerView:r}=e,{attributes:s,layer:o}=t,{objectIdField:i}=o,l=(i&&s?.[i])??null,a=r.highlight(l??t);this.addHandles(a,B)}_setResultFloor(e){const{view:t}=this,r=e.feature?.attributes,s=e.feature?.sourceLayer;if(s&&"floorInfo"in s&&s?.floorInfo?.floorField&&r){const e=r[s.floorInfo.floorField];t?.emit("select-result-floor",e)}}};W.ALL_INDEX=K,e([f()],W.prototype,"_searching",void 0),e([f()],W.prototype,"_updatingPromise",void 0),e([f({readOnly:!0,value:null})],W.prototype,"activeSource",null),e([f()],W.prototype,"activeSourceIndex",null),e([f()],W.prototype,"allPlaceholder",null),e([f({readOnly:!0})],W.prototype,"allSources",null),e([f()],W.prototype,"autoNavigate",void 0),e([f()],W.prototype,"autoSelect",void 0),e([f()],W.prototype,"defaultPopupTemplate",void 0),e([f({readOnly:!0})],W.prototype,"defaultSources",void 0),e([f()],W.prototype,"defaultSymbols",void 0),e([f()],W.prototype,"includeDefaultSources",void 0),e([f()],W.prototype,"locationEnabled",null),e([f()],W.prototype,"maxInputLength",void 0),e([f()],W.prototype,"maxResults",void 0),e([f()],W.prototype,"maxSuggestions",void 0),e([f()],W.prototype,"messages",void 0),e([f()],W.prototype,"minSuggestCharacters",void 0),e([f({readOnly:!0})],W.prototype,"placeholder",null),e([f()],W.prototype,"popupEnabled",void 0),e([f({type:o})],W.prototype,"popupTemplate",void 0),e([f({type:I})],W.prototype,"portal",void 0),e([f()],W.prototype,"resultCount",void 0),e([f()],W.prototype,"resultGraphicEnabled",void 0),e([f({readOnly:!0})],W.prototype,"resultGraphic",void 0),e([f({readOnly:!0})],W.prototype,"results",void 0),e([f({readOnly:!0})],W.prototype,"selectedSuggestion",void 0),e([f()],W.prototype,"searchAllEnabled",void 0),e([f({readOnly:!0})],W.prototype,"selectedResult",void 0),e([f()],W.prototype,"searchTerm",null),e([f({type:Q})],W.prototype,"sources",void 0),e([f({readOnly:!0})],W.prototype,"state",null),e([f()],W.prototype,"suggestionDelay",void 0),e([f()],W.prototype,"suggestionCount",void 0),e([f({readOnly:!0})],W.prototype,"suggestions",void 0),e([f()],W.prototype,"suggestionsEnabled",void 0),e([f({readOnly:!0})],W.prototype,"updating",null),e([f()],W.prototype,"view",void 0),e([f()],W.prototype,"clear",null),W=e([S("esri.widgets.Search.SearchViewModel")],W);const X=W;export{X as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.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{getActionIcon as l,getActionStyles as a}from"../support/actions/actionUtils.js";import r from"./Widget.js";import{minDragEnabledItems as c,minFilterItems as d,getLayerType as m,sortableRoot as p}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as u}from"./support/componentsUtils.js";import{globalCss as h}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as g}from"./support/decorators/messageBundle.js";import{vmEvent as b}from"./support/decorators/vmEvent.js";import{tsx as f}from"./support/jsxFactory.js";import{css as _}from"./TableList/css.js";import I from"./TableList/ListItem.js";import v from"./TableList/TableListViewModel.js";import y from"./TableList/TableListVisibleElements.js";import{getItem as w,sortTablesToIds as E}from"./TableList/support/tableListUtils.js";const C=t.ofType(I),F="table";let L=class extends r{constructor(e,t){super(e,t),this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this.collapsed=!1,this.dragEnabled=!1,this.filterPlaceholder="",this.filterText="",this.headingLevel=2,this.icon=null,this.iconClass=_.widgetIcon,this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.messages=null,this.messagesCommon=null,this.minDragEnabledItems=c,this.minFilterItems=d,this.selectedItems=new C,this.selectionMode="none",this.viewModel=new v,this.visibleElements=new y,this._canMove=({dragEl:e,fromEl:t,toEl:i},o)=>{const s="pull"===o?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,n=w(e);if(!n?.sortable)return!1;const l=w(t),a=m(t),r=w(i),c=m(i),d=!!a&&!!c&&a===c,p={selected:n,from:l,to:r};return t.group&&i.group&&"function"==typeof s?s.call(null,p):d},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:o,dragEl:s,newIndex:n}=e;if(!o||!i||t?.newIndex===n&&t?.dragEl===s&&t?.toEl===i&&t?.fromEl===o)return;this._lastDragDetail=e;const l=Array.from(o.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));E(this.map?.tables,l)}}loadDependencies(){return u({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js")})}get _dragEnabled(){return this.viewModel.totalItems>=this.minDragEnabledItems&&this.dragEnabled}get _filterEnabled(){return this.viewModel.totalItems>=this.minFilterItems&&this.visibleElements.filter}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get listItemCreatedFunction(){return this.viewModel.listItemCreatedFunction}set listItemCreatedFunction(e){this.viewModel.listItemCreatedFunction=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get multipleSelectionEnabled(){return i(o.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),"multiple"===this.selectionMode}set multipleSelectionEnabled(e){i(o.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),this.selectionMode=e?"multiple":this.selectionEnabled?"single":"none"}get selectionEnabled(){return i(o.getLogger(this),"selectionEnabled",{replacement:"selectionMode, dragEnabled",version:"4.29",warnOnce:!0}),"none"!==this.selectionMode&&this.dragEnabled}set selectionEnabled(e){i(o.getLogger(this),"selectionEnabled",{replacement:"selectionMode, dragEnabled",version:"4.29",warnOnce:!0}),this.dragEnabled=e,this.selectionMode=e?this.multipleSelectionEnabled?"multiple":"single":"none"}get tableItems(){return this.viewModel.tableItems}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const e=this.viewModel?.state,t={[h.hidden]:"loading"===e,[h.disabled]:"disabled"===e},i=this.tableItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)));return f("div",{class:this.classes(_.base,h.widget,h.panel,t)},i?.length?this._renderItems(i):this._renderNoItems())}_renderNoItemsMessage(){return f("div",{slot:"message"},this.messages.noItemsToDisplay)}_renderNoItems(){return f("div",{class:_.itemMessage,key:"esri-layer-list__no-items"},f("calcite-notice",{icon:"information",kind:"info",open:!0,scale:"m",width:"full"},this._renderNoItemsMessage()))}_renderPanelFlowItems(e){return e?.toArray().filter((({panel:e})=>e?.open&&!e.disabled&&e.flowEnabled)).map((({title:e,panel:t})=>{const i=()=>this._handlePanelFlowItemBack(t);return f("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:e,heading:t.title,headingLevel:this.headingLevel,key:`flow-panel-${t.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),i()}},t.render(),f("calcite-button",{appearance:"transparent",onclick:i,slot:"footer-actions",width:"full"},this.messagesCommon.back))}))}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderItems(e){const{visible:t,collapsed:i,visibleElements:{closeButton:o,collapseButton:s,heading:n,flow:l},_dragEnabled:a,_filterEnabled:r,selectionMode:c,messages:d,filterPlaceholder:m,filterText:u}=this,h=[f("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:o,closed:!t,collapsed:i,collapsible:s,heading:n?d.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",onCalciteFlowItemClose:()=>this.visible=!1},f("calcite-list",{canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-layer-type":F,dragEnabled:a,filterEnabled:r,filterPlaceholder:m,filterText:u,group:p,key:"root-list",label:d.widgetLabel,selectionAppearance:"border",selectionMode:c,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this.filterText=e.target?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},e?.toArray().map((e=>this._renderItem(e))),e?.length&&r?f("div",{class:_.filterNoResults,slot:"filter-no-results"},f("calcite-notice",{kind:"info",open:!0,scale:"m",width:"full"},this._renderNoItemsMessage())):null)),this._renderPanelFlowItems(e)];return t?l?f("calcite-flow",{key:"root-flow"},h):h:null}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:o}=e;t.insertBefore(i,t.children[o])}_renderItemMessage(e){return e.error?f("div",{class:_.itemMessage,key:"esri-layer-list__error",slot:"content-bottom"},f("calcite-notice",{icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",width:"full"},f("div",{slot:"message"},this.messages.tableError))):null}_renderItem(e){const{_selectedDragItemLayerUid:t,selectionMode:i,selectedItems:o,messages:s}=this,n=e.title||s.untitledTable,l=this._filterActions(e.actionsSections),a=this._countActions(l);return f("calcite-list-item",{afterCreate:t=>this._focusSelectedDragEl(t,e),afterUpdate:t=>this._focusSelectedDragEl(t,e),class:_.item,"data-item":e,dragDisabled:!e.sortable,dragSelected:e.layer.uid===t,id:e.layer?.uid,key:`list-item-${e.layer.uid}`,label:n,metadata:{title:n},selected:"none"!==i&&o.includes(e),title:n,value:e.layer?.uid,onCalciteListItemDragHandleChange:t=>this._handleCalciteListItemDragHandleChange(t,e)},f("div",{class:_.itemContent,slot:"content"},n),this._renderItemStatus(e),this._renderItemTemporaryIcon(e),this._renderItemMessage(e),this._renderPanel(e.panel),this._renderPanelAction(e.panel),a>1?this._renderActionsSections(e,l):1===a?this._renderAction({item:e,action:this._getSingleActionButton(l),textEnabled:!1}):null)}_renderItemTemporaryIcon(e){return this.visibleElements.temporaryTableIndicators&&!e.layer.persistenceEnabled?f("calcite-icon",{class:_.itemTemporaryIcon,icon:"temporary",key:"temporary-icon",scale:"s",slot:"actions-start",title:this.messages.temporary}):null}_renderItemStatus(e){const{visibleElements:t}=this;if(!t.statusIndicators)return null;const{publishing:i}=e;return f("calcite-icon",{class:this.classes({[_.statusIndicator]:!0,[_.publishing]:i}),icon:"stop-square",key:"layer-item-status",scale:"s",slot:"actions-end"})}_renderPanel(e){return!e?.open||e.disabled||e.flowEnabled?null:f("div",{class:_.itemContentBottom,key:`content-panel-${e.uid}`,slot:"content-bottom"},e.render())}_renderPanelAction(e){if(!e?.visible)return null;const{open:t,title:i,disabled:o}=e;return f("calcite-action",{active:t,appearance:"transparent",disabled:o,icon:l(e),key:`action-${e.uid}`,onclick:()=>this._togglePanel(e),scale:"s",slot:"actions-end",text:i??"",title:i??void 0},this._renderFallbackIcon(e))}_renderActionsSections(e,t){return f("calcite-action-menu",{appearance:"transparent",key:"item-action-menu",label:this.messagesCommon.menu,open:e.actionsOpen,overlayPositioning:"fixed",placement:"bottom-end",scale:"s",slot:"actions-end",onCalciteActionMenuOpen:t=>e.actionsOpen=t.target.open},f("calcite-action",{appearance:"transparent",icon:"ellipsis",scale:"s",slot:"trigger",text:this.messagesCommon.options,title:this.messagesCommon.options}),t.toArray().map(((t,i)=>this._renderActionSection(e,t,i))))}_renderActionSection(e,t,i){return f("calcite-action-group",{key:`action-section-${i}`},t.toArray().map((t=>this._renderAction({item:e,action:t,textEnabled:!0}))))}_renderFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o="image"in e?e.image:void 0,s={[_.itemActionIcon]:!!t,[_.itemActionImage]:!!o};return t&&(s[t]=!0),o||t?f("span",{"aria-hidden":"true",class:this.classes(_.itemActionIcon,s),key:"icon",styles:a(o)}):null}_renderAction(e){const{item:t,action:i,textEnabled:o}=e,{active:s,disabled:n,title:a,type:r,indicator:c}=i;return f("calcite-action",{active:"toggle"===r&&i.value,appearance:"transparent",disabled:n,icon:l(i),indicator:c,key:`action-${i.uid}`,loading:s,onclick:()=>this._triggerAction(t,i),scale:"s",slot:o?void 0:"actions-end",text:a??"",textEnabled:o,title:a??void 0},this._renderFallbackIcon(i))}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_getSingleActionButton(e){return e.reduce((e=>e)).filter((e=>e&&"button"===e.type)).at(0)}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_focusSelectedDragEl(e,t){this._selectedDragItemLayerUid===t.layer.uid&&requestAnimationFrame((()=>e?.setFocus()))}_handleCalciteListItemDragHandleChange(e,t){e.stopPropagation();const i=e.target.dragSelected;this._selectedDragItemLayerUid=i?t.layer.uid:null}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const o=e.target.selectedItems.map((e=>w(e))).filter(Boolean);i.removeAll(),i.addMany(o)}_togglePanel(e){e.open=!e.open,e.open&&(this._focusPanelFlowItem=!0)}_triggerAction(e,t){t&&e&&("toggle"===t.type&&(t.value=!t.value),this.triggerAction(t,e))}};e([s()],L.prototype,"_focusRootFlowItem",void 0),e([s()],L.prototype,"_focusPanelFlowItem",void 0),e([s()],L.prototype,"_dragEnabled",null),e([s()],L.prototype,"_filterEnabled",null),e([s()],L.prototype,"collapsed",void 0),e([s()],L.prototype,"dragEnabled",void 0),e([s()],L.prototype,"filterPlaceholder",void 0),e([s()],L.prototype,"filterText",void 0),e([s()],L.prototype,"headingLevel",void 0),e([s()],L.prototype,"icon",void 0),e([s()],L.prototype,"iconClass",void 0),e([s()],L.prototype,"label",null),e([s()],L.prototype,"listItemCanGiveFunction",void 0),e([s()],L.prototype,"listItemCanReceiveFunction",void 0),e([s()],L.prototype,"listItemCreatedFunction",null),e([s()],L.prototype,"map",null),e([s(),g("esri/widgets/TableList/t9n/TableList")],L.prototype,"messages",void 0),e([s(),g("esri/t9n/common")],L.prototype,"messagesCommon",void 0),e([s()],L.prototype,"minDragEnabledItems",void 0),e([s()],L.prototype,"minFilterItems",void 0),e([s()],L.prototype,"multipleSelectionEnabled",null),e([s()],L.prototype,"selectionEnabled",null),e([s()],L.prototype,"selectedItems",void 0),e([s()],L.prototype,"selectionMode",void 0),e([s({readOnly:!0})],L.prototype,"tableItems",null),e([b("trigger-action"),s({type:v})],L.prototype,"viewModel",void 0),e([s({type:y,nonNullable:!0})],L.prototype,"visibleElements",void 0),L=e([n("esri.widgets.TableList")],L);const M=L;export{M as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.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{getActionIcon as l,getActionStyles as a}from"../support/actions/actionUtils.js";import r from"./Widget.js";import{minDragEnabledItems as c,minFilterItems as d,getLayerType as m,sortableRoot as p}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as u}from"./support/componentsUtils.js";import{globalCss as h}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as g}from"./support/decorators/messageBundle.js";import{vmEvent as b}from"./support/decorators/vmEvent.js";import{tsx as f}from"./support/jsxFactory.js";import{css as _}from"./TableList/css.js";import I from"./TableList/ListItem.js";import v from"./TableList/TableListViewModel.js";import y from"./TableList/TableListVisibleElements.js";import{getItem as w,sortTablesToIds as E}from"./TableList/support/tableListUtils.js";const C=t.ofType(I),F="table";let L=class extends r{constructor(e,t){super(e,t),this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this.collapsed=!1,this.dragEnabled=!1,this.filterPlaceholder="",this.filterText="",this.headingLevel=2,this.icon=null,this.iconClass=_.widgetIcon,this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.messages=null,this.messagesCommon=null,this.minDragEnabledItems=c,this.minFilterItems=d,this.selectedItems=new C,this.selectionMode="none",this.viewModel=new v,this.visibleElements=new y,this._canMove=({dragEl:e,fromEl:t,toEl:i},o)=>{const s="pull"===o?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,n=w(e);if(!n?.sortable)return!1;const l=w(t),a=m(t),r=w(i),c=m(i),d=!!a&&!!c&&a===c,p={selected:n,from:l,to:r};return t.group&&i.group&&"function"==typeof s?s.call(null,p):d},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:o,dragEl:s,newIndex:n}=e;if(!o||!i||t?.newIndex===n&&t?.dragEl===s&&t?.toEl===i&&t?.fromEl===o)return;this._lastDragDetail=e;const l=Array.from(o.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));E(this.map?.tables,l)}}loadDependencies(){return u({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js")})}get _dragEnabled(){return this.viewModel.totalItems>=this.minDragEnabledItems&&this.dragEnabled}get _filterEnabled(){return this.viewModel.totalItems>=this.minFilterItems&&this.visibleElements.filter}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get listItemCreatedFunction(){return this.viewModel.listItemCreatedFunction}set listItemCreatedFunction(e){this.viewModel.listItemCreatedFunction=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get multipleSelectionEnabled(){return i(o.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),"multiple"===this.selectionMode}set multipleSelectionEnabled(e){i(o.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),this.selectionMode=e?"multiple":this.selectionEnabled?"single":"none"}get selectionEnabled(){return i(o.getLogger(this),"selectionEnabled",{replacement:"selectionMode, dragEnabled",version:"4.29",warnOnce:!0}),"none"!==this.selectionMode&&this.dragEnabled}set selectionEnabled(e){i(o.getLogger(this),"selectionEnabled",{replacement:"selectionMode, dragEnabled",version:"4.29",warnOnce:!0}),this.dragEnabled=e,this.selectionMode=e?this.multipleSelectionEnabled?"multiple":"single":"none"}get tableItems(){return this.viewModel.tableItems}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const e=this.viewModel?.state,t={[h.hidden]:"loading"===e,[h.disabled]:"disabled"===e},i=this.tableItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)));return f("div",{class:this.classes(_.base,h.widget,h.panel,t)},i?.length?this._renderItems(i):this._renderNoItems())}_renderNoItemsMessage(){return f("div",{slot:"message"},this.messages.noItemsToDisplay)}_renderNoItems(){return f("div",{class:_.itemMessage,key:"esri-layer-list__no-items"},f("calcite-notice",{icon:"information",kind:"info",open:!0,scale:"m",width:"full"},this._renderNoItemsMessage()))}_renderPanelFlowItems(e){return e?.toArray().filter((({panel:e})=>e?.open&&!e.disabled&&e.flowEnabled)).map((({title:e,panel:t})=>{const i=()=>this._handlePanelFlowItemBack(t);return f("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:e,heading:t.title,headingLevel:this.headingLevel,key:`flow-panel-${t.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),i()}},t.render(),f("calcite-button",{appearance:"transparent",onclick:i,slot:"footer-actions",width:"full"},this.messagesCommon.back))}))}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderItems(e){const{visible:t,collapsed:i,visibleElements:{closeButton:o,collapseButton:s,heading:n,flow:l},_dragEnabled:a,_filterEnabled:r,selectionMode:c,messages:d,filterPlaceholder:m,filterText:u}=this,h=[f("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:o,closed:!t,collapsed:i,collapsible:s,heading:n?d.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",onCalciteFlowItemClose:()=>this.visible=!1},f("calcite-list",{canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-layer-type":F,dragEnabled:a,filterEnabled:r,filterPlaceholder:m,filterText:r?u:"",group:p,key:"root-list",label:d.widgetLabel,selectionAppearance:"border",selectionMode:c,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this.filterText=e.target?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},e?.toArray().map((e=>this._renderItem(e))),e?.length&&r?f("div",{class:_.filterNoResults,slot:"filter-no-results"},f("calcite-notice",{kind:"info",open:!0,scale:"m",width:"full"},this._renderNoItemsMessage())):null)),this._renderPanelFlowItems(e)];return t?l?f("calcite-flow",{key:"root-flow"},h):h:null}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:o}=e;t.insertBefore(i,t.children[o])}_renderItemMessage(e){return e.error?f("div",{class:_.itemMessage,key:"esri-layer-list__error",slot:"content-bottom"},f("calcite-notice",{icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",width:"full"},f("div",{slot:"message"},this.messages.tableError))):null}_renderItem(e){const{_selectedDragItemLayerUid:t,selectionMode:i,selectedItems:o,messages:s}=this,n=e.title||s.untitledTable,l=this._filterActions(e.actionsSections),a=this._countActions(l);return f("calcite-list-item",{afterCreate:t=>this._focusSelectedDragEl(t,e),afterUpdate:t=>this._focusSelectedDragEl(t,e),class:_.item,"data-item":e,dragDisabled:!e.sortable,dragSelected:e.layer.uid===t,id:e.layer?.uid,key:`list-item-${e.layer.uid}`,label:n,metadata:{title:n},selected:"none"!==i&&o.includes(e),title:n,value:e.layer?.uid,onCalciteListItemDragHandleChange:t=>this._handleCalciteListItemDragHandleChange(t,e)},f("div",{class:_.itemContent,slot:"content"},n),this._renderItemStatus(e),this._renderItemTemporaryIcon(e),this._renderItemMessage(e),this._renderPanel(e.panel),this._renderPanelAction(e.panel),a>1?this._renderActionsSections(e,l):1===a?this._renderAction({item:e,action:this._getSingleActionButton(l),textEnabled:!1}):null)}_renderItemTemporaryIcon(e){return this.visibleElements.temporaryTableIndicators&&!e.layer.persistenceEnabled?f("calcite-icon",{class:_.itemTemporaryIcon,icon:"temporary",key:"temporary-icon",scale:"s",slot:"actions-start",title:this.messages.temporary}):null}_renderItemStatus(e){const{visibleElements:t}=this;if(!t.statusIndicators)return null;const{publishing:i}=e;return f("calcite-icon",{class:this.classes({[_.statusIndicator]:!0,[_.publishing]:i}),icon:"stop-square",key:"layer-item-status",scale:"s",slot:"actions-end"})}_renderPanel(e){return!e?.open||e.disabled||e.flowEnabled?null:f("div",{class:_.itemContentBottom,key:`content-panel-${e.uid}`,slot:"content-bottom"},e.render())}_renderPanelAction(e){if(!e?.visible)return null;const{open:t,title:i,disabled:o}=e;return f("calcite-action",{active:t,appearance:"transparent",disabled:o,icon:l(e),key:`action-${e.uid}`,onclick:()=>this._togglePanel(e),scale:"s",slot:"actions-end",text:i??"",title:i??void 0},this._renderFallbackIcon(e))}_renderActionsSections(e,t){return f("calcite-action-menu",{appearance:"transparent",key:"item-action-menu",label:this.messagesCommon.menu,open:e.actionsOpen,overlayPositioning:"fixed",placement:"bottom-end",scale:"s",slot:"actions-end",onCalciteActionMenuOpen:t=>e.actionsOpen=t.target.open},f("calcite-action",{appearance:"transparent",icon:"ellipsis",scale:"s",slot:"trigger",text:this.messagesCommon.options,title:this.messagesCommon.options}),t.toArray().map(((t,i)=>this._renderActionSection(e,t,i))))}_renderActionSection(e,t,i){return f("calcite-action-group",{key:`action-section-${i}`},t.toArray().map((t=>this._renderAction({item:e,action:t,textEnabled:!0}))))}_renderFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o="image"in e?e.image:void 0,s={[_.itemActionIcon]:!!t,[_.itemActionImage]:!!o};return t&&(s[t]=!0),o||t?f("span",{"aria-hidden":"true",class:this.classes(_.itemActionIcon,s),key:"icon",styles:a(o)}):null}_renderAction(e){const{item:t,action:i,textEnabled:o}=e,{active:s,disabled:n,title:a,type:r,indicator:c}=i;return f("calcite-action",{active:"toggle"===r&&i.value,appearance:"transparent",disabled:n,icon:l(i),indicator:c,key:`action-${i.uid}`,loading:s,onclick:()=>this._triggerAction(t,i),scale:"s",slot:o?void 0:"actions-end",text:a??"",textEnabled:o,title:a??void 0},this._renderFallbackIcon(i))}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_getSingleActionButton(e){return e.reduce((e=>e)).filter((e=>e&&"button"===e.type)).at(0)}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_focusSelectedDragEl(e,t){this._selectedDragItemLayerUid===t.layer.uid&&requestAnimationFrame((()=>e?.setFocus()))}_handleCalciteListItemDragHandleChange(e,t){e.stopPropagation();const i=e.target.dragSelected;this._selectedDragItemLayerUid=i?t.layer.uid:null}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const o=e.target.selectedItems.map((e=>w(e))).filter(Boolean);i.removeAll(),i.addMany(o)}_togglePanel(e){e.open=!e.open,e.open&&(this._focusPanelFlowItem=!0)}_triggerAction(e,t){t&&e&&("toggle"===t.type&&(t.value=!t.value),this.triggerAction(t,e))}};e([s()],L.prototype,"_focusRootFlowItem",void 0),e([s()],L.prototype,"_focusPanelFlowItem",void 0),e([s()],L.prototype,"_dragEnabled",null),e([s()],L.prototype,"_filterEnabled",null),e([s()],L.prototype,"collapsed",void 0),e([s()],L.prototype,"dragEnabled",void 0),e([s()],L.prototype,"filterPlaceholder",void 0),e([s()],L.prototype,"filterText",void 0),e([s()],L.prototype,"headingLevel",void 0),e([s()],L.prototype,"icon",void 0),e([s()],L.prototype,"iconClass",void 0),e([s()],L.prototype,"label",null),e([s()],L.prototype,"listItemCanGiveFunction",void 0),e([s()],L.prototype,"listItemCanReceiveFunction",void 0),e([s()],L.prototype,"listItemCreatedFunction",null),e([s()],L.prototype,"map",null),e([s(),g("esri/widgets/TableList/t9n/TableList")],L.prototype,"messages",void 0),e([s(),g("esri/t9n/common")],L.prototype,"messagesCommon",void 0),e([s()],L.prototype,"minDragEnabledItems",void 0),e([s()],L.prototype,"minFilterItems",void 0),e([s()],L.prototype,"multipleSelectionEnabled",null),e([s()],L.prototype,"selectionEnabled",null),e([s()],L.prototype,"selectedItems",void 0),e([s()],L.prototype,"selectionMode",void 0),e([s({readOnly:!0})],L.prototype,"tableItems",null),e([b("trigger-action"),s({type:v})],L.prototype,"viewModel",void 0),e([s({type:y,nonNullable:!0})],L.prototype,"visibleElements",void 0),L=e([n("esri.widgets.TableList")],L);const M=L;export{M as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../core/Accessor.js";import i from"../../core/Error.js";import t from"../../core/Logger.js";import{watch as o,initial as s}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../core/support/UpdatingHandles.js";import c from"../../portal/Portal.js";import{hasUserTypeExtension as l}from"../../portal/support/utils.js";import{createFeatureServices as h}from"../../rest/featureService/utils.js";import u from"../../versionManagement/VersionManagementService.js";let g=class extends r{constructor(e){super(e),this._currentVersionIdentifiers=new Map,this._initialValidationsFinished=!1,this._portals=new Map,this._updatingHandles=new d,this._validConstructProperties=!0,this.advancedEditingUserTypeExtensionForUrl=new Map,this.executionError=void 0,this.featureServices=new Map,this.layers=null,this.loadError=void 0,this.serverVersionForUrl=new Map,this.serviceNames=new Map,this.userForUrl=new Map,this.versionInfos=new Map,this.versionManagementServices=new Map}initialize(){this.addHandles([o((()=>this.layers?.toArray()),(async()=>{await this._onLayersChange()}),s)])}destroy(){this._updatingHandles.destroy()}get state(){return this.loadError||!this._validConstructProperties?"disabled":this.executionError?"failed":this._updatingHandles.updating?"executing":this._initialValidationsFinished?"ready":"loading"}async alterVersion(e){"disabled"!==this.state?await this._updatingHandles.addPromise((async()=>{this._setExecutionError();const r=this.versionManagementServices.get(e.featureServerUrl);if(!r)return void this._logNoVersionManagementServiceFoundError();if(!this.serverVersionForUrl.has(e.featureServerUrl)||this.serverVersionForUrl.get(e.featureServerUrl)<=11.1)return void this._logError("execution-error","no-valid-enterprise-version");if(!this.advancedEditingUserTypeExtensionForUrl.get(e.featureServerUrl))return void this._logError("execution-error","no-advanced-editing-user-type-extension");const{featureServerUrl:i,versionIdentifier:t,...o}=e;await r.alterVersion(t,o).catch((async e=>{await this.getVersionInfos(i,!0),this._logExecutionError(e)}))})()):this._logError("load-error",this.loadError)}async changeVersion(e,r,i){"disabled"!==this.state?await this._updatingHandles.addPromise((async()=>{this._setExecutionError();const t=this.versionManagementServices.get(e);if(!t)return void this._logNoVersionManagementServiceFoundError();const o=this._currentVersionIdentifiers.get(e)??{name:t.defaultVersionIdentifier.name,guid:t.defaultVersionIdentifier.guid},s={name:r,guid:i};await t.changeVersion(this.featureServices.get(e)?.layers,o,s).catch((e=>{this._logExecutionError(e)}))&&this._currentVersionIdentifiers.set(e,s)})()):this._logError("load-error",this.loadError)}async createVersion(e){"disabled"!==this.state?await this._updatingHandles.addPromise((async()=>{this._setExecutionError();const r=e.featureServerUrl,i=this.versionManagementServices.get(r);if(!i)return void this._logNoVersionManagementServiceFoundError();const t=this.advancedEditingUserTypeExtensionForUrl.get(e.featureServerUrl),o=this.userForUrl.get(r).toUpperCase(),s=this._isEmptyString(e.ownerName)?o:e.ownerName?.trim().toUpperCase();if(s!==o){if(this.serverVersionForUrl.get(r)<=11.1)return void this._logError("execution-error","versioning-api-error");if(!t)return void this._logError("execution-error","no-advanced-editing-user-type-extension")}const n=s===o?e.versionName:e.versionName+"_tmp";if("SDE"===s?.toUpperCase()&&"DEFAULT"===e.versionName.toUpperCase()||this.versionInfos.get(r)?.find((r=>r.versionIdentifier.name.toUpperCase()===(s+"."+e.versionName).toUpperCase())))return void this._logError("execution-error","no-valid-version-name");const a=await i.createVersion({versionName:n,access:e.access,description:e.description}).catch((e=>{this._logExecutionError(e)}));if(this.executionError&&s!==o){const{guid:i,name:t}=a.versionIdentifier;let o={featureServerUrl:r,versionIdentifier:{guid:i,name:t},ownerName:s};await this.alterVersion(o).catch((e=>{this._logExecutionError(e),this.deleteVersion(r,a.versionIdentifier.name,a.versionIdentifier.guid)})),o={featureServerUrl:r,versionIdentifier:{guid:a.versionIdentifier.guid,name:a.versionIdentifier.name},versionName:e.versionName},await this.alterVersion(o).catch((async e=>{await this.deleteVersion(r,a.versionIdentifier.name,a.versionIdentifier.guid),await this.getVersionInfos(r,!0),this._logExecutionError(e)}))}})()):this._logError("load-error",this.loadError)}async deleteVersion(e,r,i){"disabled"!==this.state?await this._updatingHandles.addPromise((async()=>{this._setExecutionError();const t=this.versionManagementServices.get(e);if(!t)return void this._logNoVersionManagementServiceFoundError();if(this.serverVersionForUrl.get(e)<=11.1)return void this._logError("execution-error","versioning-api-error");if(!this.advancedEditingUserTypeExtensionForUrl.get(e))return void this._logError("execution-error","no-advanced-editing-user-type-extension");const o={name:r,guid:i};await t.deleteVersion(o).catch((e=>{this._logExecutionError(e)}))&&await this.getVersionInfos(e,!0).catch((e=>{this._logExecutionError(e)}))})()):this._logError("load-error",this.loadError)}async getVersionInfos(e,r){if("disabled"!==this.state)return await this._updatingHandles.addPromise((async()=>{this._setExecutionError();const i=this.featureServices.get(e)?.featureService;if(!i)return void this._logError("execution-error","no-feature-service-found");if(!i.loaded){await i.load().catch((e=>{this._logExecutionError(e)}));const r=i.url;this.serverVersionForUrl.set(r,i.sourceJSON?.currentVersion??0),this.serverVersionForUrl.get(r)<=11.1&&this.advancedEditingUserTypeExtensionForUrl.set(r,!1);const t=this.userForUrl.get(e);this._portals.get(e)&&t?this.advancedEditingUserTypeExtensionForUrl.set(r,await l(this._portals.get(e),t,"advediting")):this.advancedEditingUserTypeExtensionForUrl.set(r,!1)}i.versionManagementServiceUrl&&this.versionManagementServices.set(i.url,new u({url:i.versionManagementServiceUrl}));const t=this.versionManagementServices.get(e);if(t){if(t.loaded||await t.load().catch((e=>{this._logExecutionError(e)})),!this.versionInfos.get(e)||r){const r=await t.getVersionInfos().catch((e=>{this._logExecutionError(e)}));this.versionInfos.set(e,r),this._currentVersionIdentifiers.set(e,t.defaultVersionIdentifier)}}else this._logNoVersionManagementServiceFoundError()})()),this.versionInfos.get(e);this._logError("load-error",this.loadError)}_isEmptyString(e){return!e||0===e.trim().length}_logError(e,r){switch(e){case"load-error":this._setLoadError(r),t.getLogger(this).error(new i(e,r));break;case"execution-error":this._setExecutionError(r),t.getLogger(this).error(new i(e,r))}}_logExecutionError(e){this._logError("execution-error",e.message)}_logNoVersionManagementServiceFoundError(){this._logError("execution-error","no-version-management-service-found")}async _onLayersChange(){if(this._initialValidationsFinished=!1,this._setLoadError(),this._validConstructProperties=!0,!this.layers)return this._logError("load-error","no-layers-property"),void(this._validConstructProperties=!1);if(this.featureServices=h(this.layers),!this.featureServices.size)return this._logError("load-error","no-feature-services"),void(this._validConstructProperties=!1);for(const e of this.featureServices.keys())if(!this.serviceNames.has(e)){this.serviceNames.set(e,e.split("/").at(-2));const r=new c({authMode:"immediate",url:new URL(e).origin+"/portal"});await r.load(),this._portals.set(e,r);const i=r?.user?.username;i&&this.userForUrl.set(e,i)}this._initialValidationsFinished=!0}_setExecutionError(e){this._set("executionError",e)}_setLoadError(e){this._set("loadError",e)}};e([n()],g.prototype,"_initialValidationsFinished",void 0),e([n({readOnly:!0})],g.prototype,"advancedEditingUserTypeExtensionForUrl",void 0),e([n({readOnly:!0})],g.prototype,"executionError",void 0),e([n()],g.prototype,"featureServices",void 0),e([n()],g.prototype,"layers",void 0),e([n({readOnly:!0})],g.prototype,"loadError",void 0),e([n({readOnly:!0})],g.prototype,"serverVersionForUrl",void 0),e([n()],g.prototype,"serviceNames",void 0),e([n({readOnly:!0})],g.prototype,"state",null),e([n({readOnly:!0})],g.prototype,"userForUrl",void 0),e([n()],g.prototype,"versionInfos",void 0),e([n()],g.prototype,"versionManagementServices",void 0),g=e([a("esri.widgets.VersionManagement.VersionManagementViewModel")],g);const v=g;export{v as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../core/Accessor.js";import i from"../../core/Error.js";import t from"../../core/Logger.js";import{watch as o,initial as s}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../core/support/UpdatingHandles.js";import c from"../../portal/Portal.js";import{hasUserTypeExtension as l}from"../../portal/support/utils.js";import{createFeatureServices as h}from"../../rest/featureService/utils.js";import u from"../../versionManagement/VersionManagementService.js";let g=class extends r{constructor(e){super(e),this._currentVersionIdentifiers=new Map,this._initialValidationsFinished=!1,this._portals=new Map,this._updatingHandles=new d,this._validConstructProperties=!0,this.advancedEditingUserTypeExtensionForUrl=new Map,this.executionError=void 0,this.featureServices=new Map,this.layers=null,this.loadError=void 0,this.serverVersionForUrl=new Map,this.serviceNames=new Map,this.userForUrl=new Map,this.versionInfos=new Map,this.versionManagementServices=new Map}initialize(){this.addHandles([o((()=>this.layers?.toArray()),(async()=>{await this._onLayersChange()}),s)])}destroy(){this._updatingHandles.destroy()}get state(){return this.loadError||!this._validConstructProperties?"disabled":this.executionError?"failed":this._updatingHandles.updating?"executing":this._initialValidationsFinished?"ready":"loading"}async alterVersion(e){"disabled"!==this.state?await this._updatingHandles.addPromise((async()=>{this._setExecutionError();const r=this.versionManagementServices.get(e.featureServerUrl);if(!r)return void this._logNoVersionManagementServiceFoundError();if(!this.serverVersionForUrl.has(e.featureServerUrl)||this.serverVersionForUrl.get(e.featureServerUrl)<=11.1)return void this._logError("execution-error","no-valid-enterprise-version");if(!this.advancedEditingUserTypeExtensionForUrl.get(e.featureServerUrl))return void this._logError("execution-error","no-advanced-editing-user-type-extension");const{featureServerUrl:i,versionIdentifier:t,...o}=e;await r.alterVersion(t,o).catch((async e=>{await this.getVersionInfos(i,!0),this._logExecutionError(e)}))})()):this._logError("load-error",this.loadError)}async changeVersion(e,r,i){"disabled"!==this.state?await this._updatingHandles.addPromise((async()=>{this._setExecutionError();const t=this.versionManagementServices.get(e);if(!t)return void this._logNoVersionManagementServiceFoundError();const o=this._currentVersionIdentifiers.get(e)??{name:t.defaultVersionIdentifier.name,guid:t.defaultVersionIdentifier.guid},s={name:r,guid:i};await t.changeVersion(this.featureServices.get(e)?.layers,o,s).catch((e=>{this._logExecutionError(e)}))&&this._currentVersionIdentifiers.set(e,s)})()):this._logError("load-error",this.loadError)}async createVersion(e){"disabled"!==this.state?await this._updatingHandles.addPromise((async()=>{this._setExecutionError();const r=e.featureServerUrl,i=this.versionManagementServices.get(r);if(!i)return void this._logNoVersionManagementServiceFoundError();const t=this.advancedEditingUserTypeExtensionForUrl.get(e.featureServerUrl),o=this.userForUrl.get(r).toUpperCase(),s=this._isEmptyString(e.ownerName)?o:e.ownerName?.trim().toUpperCase();if(s!==o){if(this.serverVersionForUrl.get(r)<=11.1)return void this._logError("execution-error","versioning-api-error");if(!t)return void this._logError("execution-error","no-advanced-editing-user-type-extension")}if("SDE"===s?.toUpperCase()&&"DEFAULT"===e.versionName.toUpperCase()||this.versionInfos.get(r)?.find((r=>r.versionIdentifier.name.toUpperCase()===(s+"."+e.versionName).toUpperCase()||r.versionIdentifier.name.toUpperCase()===(o+"."+e.versionName).toUpperCase())))return void this._logError("execution-error","no-valid-version-name");const n=await i.createVersion({versionName:e.versionName,access:s!==o?"public":e.access,description:e.description}).catch((e=>{this._logExecutionError(e)}));if(!this.executionError&&s!==o){const{guid:i,name:t}=n.versionIdentifier,a={featureServerUrl:r,versionIdentifier:{guid:i,name:t},access:e.access,ownerName:s};await this.alterVersion(a),this.executionError&&this.deleteVersion(r,o+"."+e.versionName,n.versionIdentifier.guid)}await this.getVersionInfos(r,!0)})()):this._logError("load-error",this.loadError)}async deleteVersion(e,r,i){"disabled"!==this.state?await this._updatingHandles.addPromise((async()=>{this._setExecutionError();const t=this.versionManagementServices.get(e);if(!t)return void this._logNoVersionManagementServiceFoundError();if(this.serverVersionForUrl.get(e)<=11.1)return void this._logError("execution-error","versioning-api-error");if(!this.advancedEditingUserTypeExtensionForUrl.get(e))return void this._logError("execution-error","no-advanced-editing-user-type-extension");const o={name:r,guid:i};await t.deleteVersion(o).catch((e=>{this._logExecutionError(e)}))&&await this.getVersionInfos(e,!0).catch((e=>{this._logExecutionError(e)}))})()):this._logError("load-error",this.loadError)}async getVersionInfos(e,r){if("disabled"!==this.state)return await this._updatingHandles.addPromise((async()=>{this._setExecutionError();const i=this.featureServices.get(e)?.featureService;if(!i)return void this._logError("execution-error","no-feature-service-found");if(!i.loaded){await i.load().catch((e=>{this._logExecutionError(e)}));const r=i.url;this.serverVersionForUrl.set(r,i.sourceJSON?.currentVersion??0),this.serverVersionForUrl.get(r)<=11.1&&this.advancedEditingUserTypeExtensionForUrl.set(r,!1);const t=this.userForUrl.get(e);this._portals.get(e)&&t?this.advancedEditingUserTypeExtensionForUrl.set(r,await l(this._portals.get(e),t,"advediting")):this.advancedEditingUserTypeExtensionForUrl.set(r,!1)}i.versionManagementServiceUrl&&this.versionManagementServices.set(i.url,new u({url:i.versionManagementServiceUrl}));const t=this.versionManagementServices.get(e);if(t){if(t.loaded||await t.load().catch((e=>{this._logExecutionError(e)})),!this.versionInfos.get(e)||r){const r=await t.getVersionInfos().catch((e=>{this._logExecutionError(e)}));this.versionInfos.set(e,r),this._currentVersionIdentifiers.set(e,t.defaultVersionIdentifier)}}else this._logNoVersionManagementServiceFoundError()})()),this.versionInfos.get(e);this._logError("load-error",this.loadError)}_isEmptyString(e){return!e||0===e.trim().length}_logError(e,r){switch(e){case"load-error":this._setLoadError(r),t.getLogger(this).error(new i(e,r));break;case"execution-error":this._setExecutionError(r),t.getLogger(this).error(new i(e,r))}}_logExecutionError(e){this._logError("execution-error",e.message)}_logNoVersionManagementServiceFoundError(){this._logError("execution-error","no-version-management-service-found")}async _onLayersChange(){if(this._initialValidationsFinished=!1,this._setLoadError(),this._validConstructProperties=!0,!this.layers)return this._logError("load-error","no-layers-property"),void(this._validConstructProperties=!1);if(this.featureServices=h(this.layers),!this.featureServices.size)return this._logError("load-error","no-feature-services"),void(this._validConstructProperties=!1);for(const e of this.featureServices.keys())if(!this.serviceNames.has(e)){this.serviceNames.set(e,e.split("/").at(-2));const r=new c({authMode:"immediate",url:new URL(e).origin+"/portal"});await r.load(),this._portals.set(e,r);const i=r?.user?.username;i&&this.userForUrl.set(e,i)}this._initialValidationsFinished=!0}_setExecutionError(e){this._set("executionError",e)}_setLoadError(e){this._set("loadError",e)}};e([n()],g.prototype,"_initialValidationsFinished",void 0),e([n({readOnly:!0})],g.prototype,"advancedEditingUserTypeExtensionForUrl",void 0),e([n({readOnly:!0})],g.prototype,"executionError",void 0),e([n()],g.prototype,"featureServices",void 0),e([n()],g.prototype,"layers",void 0),e([n({readOnly:!0})],g.prototype,"loadError",void 0),e([n({readOnly:!0})],g.prototype,"serverVersionForUrl",void 0),e([n()],g.prototype,"serviceNames",void 0),e([n({readOnly:!0})],g.prototype,"state",null),e([n({readOnly:!0})],g.prototype,"userForUrl",void 0),e([n()],g.prototype,"versionInfos",void 0),e([n()],g.prototype,"versionManagementServices",void 0),g=e([a("esri.widgets.VersionManagement.VersionManagementViewModel")],g);const v=g;export{v as default};