@arcgis/core 4.23.0-next.20211230 → 4.23.0-next.20220106

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.
package/rest/utils.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as e}from"../core/maybe.js";import{urlToObject as t}from"../core/urlUtils.js";import{getScale as i}from"../geometry/support/scaleUtils.js";import{getLayerFloorFilterClause as n,combineFloorsDefinitionExpression as r}from"../views/support/floorFilterUtils.js";function s(e,t){return t?{...t,query:{...e,...t.query}}:{query:e}}function o(e){return"string"==typeof e?t(e):e}function l(e,t,i){const n={};for(const r in e){if("declaredClass"===r)continue;const s=e[r];if(null!=s&&"function"!=typeof s)if(Array.isArray(s)){n[r]=[];for(let e=0;e<s.length;e++)n[r][e]=l(s[e])}else if("object"==typeof s)if(s.toJSON){const e=s.toJSON(i&&i[r]);n[r]=t?e:JSON.stringify(e)}else n[r]=t?s:JSON.stringify(s);else n[r]=s}return n}function f({mapExtent:e,floors:t,width:r,sublayers:s,layerIds:o}){const l={},f={extent:e,width:r,spatialReference:null==e?void 0:e.spatialReference};let c=s;o&&o.length&&s&&(c=s.filter((e=>o.includes(e.id))));const u=i(f),y=[],p=e=>{const t=0===u,i=0===e.minScale||u<=e.minScale,n=0===e.maxScale||u>=e.maxScale;e.visible&&(t||i&&n)&&(e.sublayers?e.sublayers.forEach(p):y.unshift(e))};if(c&&c.forEach(p),c&&c.length){const e=y.map((e=>{const i=n(t,e);return e.toExportImageJSON(i)})),i=e.some((e=>"mapLayer"===e.source.type?e.source.mapLayerId!==e.id:"dataLayer"===e.source.type));if(i){let t=JSON.stringify(e);"[]"===t&&(t="[{}]"),l.dynamicLayers=t}else if(!i){if(o&&o.length)l.layerIds=o;else{const e=c.map((({id:e})=>e));e.length&&(l.layerIds=e)}const e=a({floors:t,visibleSublayers:y});if(e&&e.length){const t=e.reduce(((e,t)=>(t.definitionExpression&&(e[t.id]=t.definitionExpression),e)),{});Object.keys(t).length&&(l.layerDefs=JSON.stringify(t))}}}return l}function a({floors:t,visibleSublayers:i}){const s=!(null==t||!t.length),o=i.filter((e=>null!=e.definitionExpression||s&&null!=e.floorInfo));if(!o.length)return null;return o.map((i=>{const s=n(t,i),o=e(s)?r(s,i):i.definitionExpression,l={id:i.id,definitionExpression:null};return o&&(l.definitionExpression=o),l}))}export{s as asValidOptions,l as encode,o as parseUrl,f as toDynamicLayersJSON};
5
+ import{isSome as e}from"../core/maybe.js";import{urlToObject as n}from"../core/urlUtils.js";import{getScale as t}from"../geometry/support/scaleUtils.js";import{getLayerFloorFilterClause as i,combineFloorsDefinitionExpression as r}from"../views/support/floorFilterUtils.js";function s(e,n){return n?{...n,query:{...e,...n.query}}:{query:e}}function o(e){return"string"==typeof e?n(e):e}function l(e,n,t){const i={};for(const r in e){if("declaredClass"===r)continue;const s=e[r];if(null!=s&&"function"!=typeof s)if(Array.isArray(s)){i[r]=[];for(let e=0;e<s.length;e++)i[r][e]=l(s[e])}else if("object"==typeof s)if(s.toJSON){const e=s.toJSON(t&&t[r]);i[r]=n?e:JSON.stringify(e)}else i[r]=n?s:JSON.stringify(s);else i[r]=s}return i}function f({mapExtent:e,floors:n,width:r,sublayers:s,layerIds:o}){const l={},f={extent:e,width:r,spatialReference:null==e?void 0:e.spatialReference};let u=s;null!=o&&o.length&&s&&(u=s.filter((e=>o.includes(e.id))));const c=t(f),y=[],p=e=>{const n=0===c,t=0===e.minScale||c<=e.minScale,i=0===e.maxScale||c>=e.maxScale;e.visible&&(n||t&&i)&&(e.sublayers?e.sublayers.forEach(p):y.unshift(e))};if(u&&u.forEach(p),u&&u.length){const e=y.map((e=>{const t=i(n,e);return e.toExportImageJSON(t)})),t=e.some((e=>"mapLayer"===e.source.type?e.source.mapLayerId!==e.id:"dataLayer"===e.source.type));if(t){let n=JSON.stringify(e);"[]"===n&&(n="[{}]"),l.dynamicLayers=n}else if(!t){if(null!=o&&o.length)l.layerIds=o;else{const e=u.map((({id:e})=>e));e.length&&(l.layerIds=e)}const e=a({floors:n,visibleSublayers:y});if(e&&e.length){const n=e.reduce(((e,n)=>(n.definitionExpression&&(e[n.id]=n.definitionExpression),e)),{});Object.keys(n).length&&(l.layerDefs=JSON.stringify(n))}}}else null!=o&&o.length&&(l.layerIds=o);return l}function a({floors:n,visibleSublayers:t}){const s=!(null==n||!n.length),o=t.filter((e=>null!=e.definitionExpression||s&&null!=e.floorInfo));if(!o.length)return null;return o.map((t=>{const s=i(n,t),o=e(s)?r(s,t):t.definitionExpression,l={id:t.id,definitionExpression:null};return o&&(l.definitionExpression=o),l}))}export{s as asValidOptions,l as encode,o as parseUrl,f as toDynamicLayersJSON};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Error.js";import{isSome as r}from"../../../core/maybe.js";import{formatNumber as a}from"../../../intl/number.js";import{createClassBreaksRenderer as t,getField as s}from"../../../renderers/support/rasterRendererHelper.js";import{processRasterRendererParameters as n}from"../support/utils.js";async function o(a){const t=(a=await n(a)).layer,{rasterInfo:o}=t;if(o.bandCount>1)throw new e("raster-class-breaks-renderer:not-supported","Multiband raster is not supported");a.field||(a.field=r(o.attributeTable)?s(o.attributeTable,"value").name:"value");const i=r(o.attributeTable),l=i&&o.attributeTable.fields.find((e=>"count"===e.name.toLowerCase())),u=i&&o.attributeTable.fields.find((e=>e.name.toLowerCase()===a.field.toLowerCase()));if(!(l&&u||r(o.histograms)||(await t.updateRasterInfoWithEstimatedStats({renderingRule:a.renderingRule,signal:a.signal}),r(o.histograms))))throw new e("raster-class-breaks-renderer:not-supported","Histograms or raster attribute table is required on the source raster. Unable to estimate histograms");const{colors:m,numClasses:c}=a;if(m&&c&&m.length!==c)throw new e("raster-class-breaks-renderer:not-supported","The size of the `colors` parameter does not match 'numClasses'");return a.classificationMethod||(a.classificationMethod="natural-breaks"),a}async function i(a){a=await o(a);const s=t(a.layer.rasterInfo,a);if(!r(s))throw new e("raster-class-breaks-renderer:not-supported","Class breaks renderer is not supported on this data");const n={minValue:s.minValue,maxValue:s.classBreakInfos[s.classBreakInfos.length-1].maxValue,normalizationTotal:null,classBreakInfos:s.classBreakInfos.map((e=>{const r=l(e.minValue,e.maxValue);return e.label=r,{minValue:e.minValue,maxValue:e.maxValue,label:r}}))};return{renderer:s,classBreaksResult:n}}function l(e,r){return a(e,{maximumFractionDigits:3})+" - "+a(r,{maximumFractionDigits:3})}export{i as createRenderer};
5
+ import e from"../../../core/Error.js";import{isSome as r}from"../../../core/maybe.js";import{formatNumber as a}from"../../../intl/number.js";import{createClassBreaksRenderer as t,getField as s}from"../../../renderers/support/rasterRendererHelper.js";import{processRasterRendererParameters as n}from"../support/utils.js";async function o(a){const t=(a=await n(a)).layer,{rasterInfo:o}=t;if(o.bandCount>1)throw new e("raster-class-breaks-renderer:not-supported","Multiband raster is not supported");a.field||(a.field=r(o.attributeTable)?s(o.attributeTable,"value").name:"value");if(!(r(o.attributeTable)&&o.attributeTable.fields.find((e=>e.name.toLowerCase()===a.field.toLowerCase())))&&!r(o.histograms)&&(await t.updateRasterInfoWithEstimatedStats({renderingRule:a.renderingRule,signal:a.signal}),!r(o.histograms)))throw new e("raster-class-breaks-renderer:not-supported","Histograms or raster attribute table is required on the source raster. Unable to estimate histograms");const{colors:i,numClasses:l}=a;if(i&&l&&i.length!==l)throw new e("raster-class-breaks-renderer:not-supported","The size of the `colors` parameter does not match 'numClasses'");return a.classificationMethod||(a.classificationMethod="natural-breaks"),a}async function i(a){a=await o(a);const s=t(a.layer.rasterInfo,a);if(!r(s))throw new e("raster-class-breaks-renderer:not-supported","Class breaks renderer is not supported on this data");const n={minValue:s.minValue,maxValue:s.classBreakInfos[s.classBreakInfos.length-1].maxValue,normalizationTotal:null,classBreakInfos:s.classBreakInfos.map((e=>{const r=l(e.minValue,e.maxValue);return e.label=r,{minValue:e.minValue,maxValue:e.maxValue,label:r}}))};return{renderer:s,classBreaksResult:n}}function l(e,r){return a(e,{maximumFractionDigits:3})+" - "+a(r,{maximumFractionDigits:3})}export{i as createRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- const e="20211230",a="031184be9af0675d8af42e28a660b33eadfe73b6";export{e as buildDate,a as commitHash};
5
+ const e="20220106",b="eb98e31e62d44360a0ec873c5b9ecd3190b2b4aa";export{e as buildDate,b as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{loadImagery as o}from"./dataUtils.js";import i from"./FlowContainer.js";import a from"./FlowStrategy.js";import n from"./FlowStyle.js";let l=class extends t{constructor(){super(...arguments),this._loadImagery=(e,t,r,s)=>o(this.layer,e,t,r,s),this._createStreamlinesMesh=(e,t,r)=>this.layer.createStreamlinesMesh({flowData:t,rendererSettings:e},{signal:r}),this.container=null,this.layer=null,this.type="rasterAnimatedFlow",this.redrawOrRefetch=async()=>{this._rendererChanged()}}get updating(){return!this._strategy||this._strategy.updating}update(e){e.stationary?this._strategy.update(e):this.layerView.requestUpdate()}install(e){this.container=new i,e.addChild(this.container),this._strategy=new a({flowContainer:this.container}),this._rendererChanged()}uninstall(){this._strategy.destroy(),this.container.removeAllChildren(),this.container.remove()}moveEnd(){}async doRefresh(){}attach(){}_rendererChanged(){if("animated-flow"!==this.layer.renderer.type)return;const e=new n(this._loadImagery,this._createStreamlinesMesh,this.layer.renderer);this.container.flowStyle=e,this.layerView.requestUpdate()}};e([r()],l.prototype,"_strategy",void 0),e([r()],l.prototype,"container",void 0),e([r()],l.prototype,"layer",void 0),e([r()],l.prototype,"layerView",void 0),e([r()],l.prototype,"type",void 0),e([r()],l.prototype,"updating",null),l=e([s("esri.views.2d.engine.flow.AnimatedFlowView2D")],l);const p=l;export{p as default};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../Graphic.js";import r from"../../../../core/Accessor.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import{loadImagery as i}from"./dataUtils.js";import a from"./FlowContainer.js";import n from"./FlowStrategy.js";import l from"./FlowStyle.js";let p=class extends r{constructor(){super(...arguments),this._loadImagery=(e,t,r,s)=>i(this.layer,e,t,r,s),this._createStreamlinesMesh=(e,t,r)=>this.layer.createStreamlinesMesh({flowData:t,rendererSettings:e},{signal:r}),this.container=null,this.layer=null,this.type="rasterAnimatedFlow",this.redrawOrRefetch=async()=>{this._rendererChanged()}}get updating(){return!this._strategy||this._strategy.updating}update(e){e.stationary?this._strategy.update(e):this.layerView.requestUpdate()}hitTest(e){return new t({attributes:{},geometry:e.clone(),layer:this.layer})}install(e){this.container=new a,e.addChild(this.container),this._strategy=new n({flowContainer:this.container}),this._rendererChanged()}uninstall(){this._strategy.destroy(),this.container.removeAllChildren(),this.container.remove()}moveEnd(){}async doRefresh(){}attach(){}_rendererChanged(){if("animated-flow"!==this.layer.renderer.type)return;const e=new l(this._loadImagery,this._createStreamlinesMesh,this.layer.renderer);this.container.flowStyle=e,this.layerView.requestUpdate()}};e([s()],p.prototype,"_strategy",void 0),e([s()],p.prototype,"container",void 0),e([s()],p.prototype,"layer",void 0),e([s()],p.prototype,"layerView",void 0),e([s()],p.prototype,"type",void 0),e([s()],p.prototype,"updating",null),p=e([o("esri.views.2d.engine.flow.AnimatedFlowView2D")],p);const h=p;export{h 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.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{init as t,watch as i}from"../../../core/watchUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import a from"../engine/flow/AnimatedFlowView2D.js";import{LayerView2DMixin as h}from"./LayerView2D.js";import o from"./imagery/ImageryGraphicsView2D.js";import n from"./imagery/ImageryView2D.js";import{ImageryLayerView as l}from"../../layers/ImageryLayerView.js";import u from"../../layers/LayerView.js";import{RefreshableLayerView as w}from"../../layers/RefreshableLayerView.js";let p=class extends(l(w(h(u)))){constructor(){super(...arguments),this._exportImageVersion=-1}initialize(){this.handles.add([t(this,["layer.blendMode","layer.effects"],(e=>{this.subview&&(this.subview.container.blendMode=e)}),!0),t(this,"layer.effect",(e=>{this.subview&&(this.subview.container.effect=e)}),!0)])}get pixelData(){return this.updating?null:"getPixelData"in this.subview?this.subview.getPixelData():null}get updating(){return!!(!this.subview||"updating"in this.subview&&this.subview.updating)}async hitTest(e,t){return this.subview?"hitTest"in this.subview?[this.subview.hitTest(e)]:[]:null}update(e){var t;null==(t=this.subview)||t.update(e)}attach(){this.layer.increaseRasterJobHandlerUsage(),this._setSubView(),this.handles.add([t(this,"layer.exportImageServiceParameters.version",(e=>{this._exportImageVersion!==e&&(this._exportImageVersion=e,this.requestUpdate())})),this.watch("timeExtent",(()=>{"timeExtent"in this.subview&&(this.subview.timeExtent=this.timeExtent),this.requestUpdate()})),this.layer.on("redraw",(()=>{"redraw"in this.subview?this.subview.redraw():this.subview.redrawOrRefetch()})),i(this.layer,"renderer",(()=>this._setSubView()))],"imagerylayerview-update")}detach(){this.layer.decreaseRasterJobHandlerUsage(),this.subview.destroy(),this.handles.remove("imagerylayerview-update"),this._exportImageVersion=-1}moveStart(){}viewChange(){}moveEnd(){this.requestUpdate()}async doRefresh(){this.requestUpdate()}isUpdating(){return!this.subview||!this.suspended&&this.subview.updating}_setSubView(){var e,t;let i="Imagery";"vector-field"===(null==(e=this.layer.renderer)?void 0:e.type)&&"lerc"===this.layer.format&&(i="Graphics");var s,r;("animated-flow"===(null==(t=this.layer.renderer)?void 0:t.type)&&(i="Flow"),this.subview&&this.subview.type===i)||(null==(s=this.subview)||s.uninstall(this.container),null==(r=this.subview)||r.destroy(),this.subview="Imagery"===i?new n({layer:this.layer,view:this.view,timeExtent:this.timeExtent}):"Graphics"===i?new o({layer:this.layer,view:this.view,timeExtent:this.timeExtent}):new a({layer:this.layer,layerView:this}),this.subview.attach(),this.subview.install(this.container),this.subview.container.blendMode=this.layer.blendMode,this.subview.container.effect=this.layer.effect);this.requestUpdate()}};e([s()],p.prototype,"pixelData",null),e([s({readOnly:!0})],p.prototype,"updating",null),e([s()],p.prototype,"subview",void 0),p=e([r("esri.views.2d.layers.ImageryLayerView2D")],p);const d=p;export{d as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import i from"../../../Graphic.js";import t from"../../../core/Collection.js";import{init as s,watch as r}from"../../../core/watchUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{GraphicsCollection as o}from"../../../support/GraphicsCollection.js";import n from"../engine/flow/AnimatedFlowView2D.js";import{LayerView2DMixin as l}from"./LayerView2D.js";import p from"./graphics/GraphicsView2D.js";import u from"./graphics/HighlightGraphicContainer.js";import c from"./imagery/ImageryGraphicsView2D.js";import w from"./imagery/ImageryView2D.js";import{ImageryLayerView as d}from"../../layers/ImageryLayerView.js";import m from"../../layers/LayerView.js";import{RefreshableLayerView as y}from"../../layers/RefreshableLayerView.js";let g=class extends(d(y(l(m)))){constructor(){super(...arguments),this._exportImageVersion=-1}initialize(){this.handles.add([s(this,["layer.blendMode","layer.effects"],(e=>{this.subview&&(this.subview.container.blendMode=e)}),!0),s(this,"layer.effect",(e=>{this.subview&&(this.subview.container.effect=e)}),!0)])}get pixelData(){return this.updating?null:"getPixelData"in this.subview?this.subview.getPixelData():null}get updating(){return!!(!this.subview||"updating"in this.subview&&this.subview.updating)}async hitTest(e,i){return this.subview?[this.subview.hitTest(e)]:null}update(e){var i;null==(i=this.subview)||i.update(e)}attach(){this.layer.increaseRasterJobHandlerUsage(),this._setSubView(),this.handles.add([s(this,"layer.exportImageServiceParameters.version",(e=>{this._exportImageVersion!==e&&(this._exportImageVersion=e,this.requestUpdate())})),this.watch("timeExtent",(()=>{"timeExtent"in this.subview&&(this.subview.timeExtent=this.timeExtent),this.requestUpdate()})),this.layer.on("redraw",(()=>{"redraw"in this.subview?this.subview.redraw():this.subview.redrawOrRefetch()})),r(this.layer,"renderer",(()=>this._setSubView()))],"imagerylayerview-update")}detach(){var e,i;this.layer.decreaseRasterJobHandlerUsage(),this.subview.destroy(),null==(e=this._highlightGraphics)||e.destroy(),null==(i=this._highlightView)||i.destroy(),this.handles.remove("imagerylayerview-update"),this._exportImageVersion=-1}moveStart(){}viewChange(){}moveEnd(){this.requestUpdate()}highlight(e,s){if(!((Array.isArray(e)?e[0]:t.isCollection(e)?e.getItemAt(0):e)instanceof i))return{remove:()=>{}};let r=[];return Array.isArray(e)||t.isCollection(e)?r=e.map((e=>e.clone())):e instanceof i&&(r=[e.clone()]),this._highlightGraphics.addMany(r),{remove:()=>{this._highlightGraphics.removeMany(r)}}}async doRefresh(){this.requestUpdate()}isUpdating(){return!this.subview||!this.suspended&&this.subview.updating}_setSubView(){var e,i;let t="Imagery";"vector-field"===(null==(e=this.layer.renderer)?void 0:e.type)&&"lerc"===this.layer.format&&(t="Graphics");var s,r,a;("animated-flow"===(null==(i=this.layer.renderer)?void 0:i.type)&&(t="Flow"),this.subview&&this.subview.type===t)||(null==(s=this.subview)||s.uninstall(this.container),null==(r=this.subview)||r.destroy(),null==(a=this._highlightGraphics)||a.destroy(),this._highlightView&&(this._highlightView.destroy(),this.container.removeChild(this._highlightView.container)),this.subview="Imagery"===t?new w({layer:this.layer,view:this.view,timeExtent:this.timeExtent}):"Graphics"===t?new c({layer:this.layer,view:this.view,timeExtent:this.timeExtent}):new n({layer:this.layer,layerView:this}),this.subview.attach(),this.subview.install(this.container),this.subview.container.blendMode=this.layer.blendMode,this.subview.container.effect=this.layer.effect);this._highlightGraphics=new o,this._highlightView=new p({view:this.view,graphics:this._highlightGraphics,requestUpdateCallback:()=>this.requestUpdate(),container:new u(this.view.featuresTilingScheme)}),this.container.addChild(this._highlightView.container),this.requestUpdate()}};e([a()],g.prototype,"pixelData",null),e([a({readOnly:!0})],g.prototype,"updating",null),e([a()],g.prototype,"subview",void 0),g=e([h("esri.views.2d.layers.ImageryLayerView2D")],g);const v=g;export{v as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import"../../symbols.js";import s from"../../core/Collection.js";import i from"../../core/Error.js";import o from"../../core/Handles.js";import r from"../../core/Logger.js";import{unwrap as n,isNone as a}from"../../core/maybe.js";import{init as l,watch as u,whenFalse as h}from"../../core/watchUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import{geographicToWebMercator as d}from"../../geometry/support/webMercatorUtils.js";import g from"../../layers/Layer.js";import f from"../../support/actions/ActionBase.js";import m from"../../support/actions/ActionButton.js";import y from"../../support/actions/ActionToggle.js";import{getDisplayedSymbol as w}from"../../symbols/support/symbolUtils.js";import{ViewEventPriorities as F}from"../../views/input/InputManager.js";import{highlightsSupported as v}from"../../views/support/layerViewUtils.js";import _ from"../Feature/FeatureViewModel.js";import{zoomToClusteredFeatures as b,browseClusteredFeatures as C,zoomToFeature as P}from"./actions.js";import{triggerAction as E,getSelectedTarget as A,removeClusteredFeaturesForBrowsing as M,displayClusterExtent as j,browseAggregateFeatures as V}from"./actionUtils.js";import O from"../support/AnchorElementViewModel.js";import{GoToMixin as x}from"../support/GoTo.js";import I from"../../symbols/SimpleFillSymbol.js";import L from"../../geometry/Point.js";const T=s.ofType({key:"type",defaultKeyValue:"button",base:f,typeMap:{button:m,toggle:y}}),S=()=>[P.clone()],B=()=>[b.clone(),C.clone()],R="esri.widgets.Popup.PopupViewModel",G=r.getLogger(R);let z=class extends(x(O)){constructor(e){super(e),this._handles=new o,this._pendingPromises=new Set,this._fetchFeaturesController=null,this._selectedClusterFeature=null,this.featurePage=null,this.actions=new T,this.defaultPopupTemplateEnabled=!1,this.autoCloseEnabled=!1,this.autoOpenEnabled=!0,this.browseClusterEnabled=!1,this.content=null,this.featuresPerPage=20,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.selectedClusterBoundaryFeature=new t({symbol:new I({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null}get isLoadingFeature(){return this.featureViewModels.some((e=>e.waitingForContent))}initialize(){this._handles.add([l(this,["autoOpenEnabled","view"],(()=>this._autoOpenEnabledChange())),this.on("view-change",(()=>this._autoClose())),u(this,["highlightEnabled","selectedFeature","visible","view"],(()=>this._highlightFeature())),u(this,"view.animation.state",(e=>this._animationStateChange(e))),u(this,"location",(e=>this._locationChange(e))),u(this,"selectedFeature",(e=>this._selectedFeatureChange(e))),u(this,["selectedFeatureIndex","featureCount","featuresPerPage"],(()=>this._selectedFeatureIndexChange())),u(this,["featurePage","selectedFeatureIndex","featureCount","featuresPerPage, featureViewModels"],(()=>this._setGraphicOnFeatureViewModels())),u(this,"featureViewModels",(()=>this._featureViewModelsChange())),this.on("trigger-action",(e=>E({event:e,view:this.view}))),h(this,"waitingForResult",(()=>this._waitingForResultChange()),!0),u(this,["features","view","view.map","view.spatialReference"],(()=>this._updateFeatureVMs())),u(this,["view.scale"],this._viewScaleChange),h(this,"visible",(()=>this.browseClusterEnabled=!1)),u(this,"browseClusterEnabled",(e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing()))])}destroy(){this._cancelFetchingFeatures(),this._handles.destroy(),this._handles=null,this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new T;e.removeAll();const{actions:t,defaultActions:s,defaultPopupTemplateEnabled:i,includeDefaultActions:o,selectedFeature:r}=this,n=o?s.concat(t):t,a=r&&("function"==typeof r.getEffectivePopupTemplate&&r.getEffectivePopupTemplate(i)||r.popupTemplate),l=a&&a.actions,u=a&&a.overwriteActions?l:l?l.concat(n):n;return u&&u.filter(Boolean).forEach((t=>e.add(t))),e}get defaultActions(){var e;const t=this._get("defaultActions")||new T;return t.removeAll(),t.addMany(null!=(e=this.selectedFeature)&&e.isAggregate?B():S()),t}get featureCount(){return this.features.length}get features(){return this._get("features")||[]}set features(e){const t=e||[];this._set("features",t);const{pendingPromisesCount:s,promiseCount:i,selectedFeatureIndex:o}=this,r=i&&t.length;r&&s&&-1===o?this.selectedFeatureIndex=0:r&&-1!==o||(this.selectedFeatureIndex=t.length?0:-1)}get location(){return this._get("location")||null}set location(e){const t=this.get("view.spatialReference.isWebMercator");e&&e.get("spatialReference.isWGS84")&&t&&(e=d(e)),this._set("location",e)}get pendingPromisesCount(){return this._pendingPromises.size}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){if(this._pendingPromises.clear(),this.features=[],!Array.isArray(e)||!e.length)return this._set("promises",[]),void this.notifyChange("pendingPromisesCount");this._set("promises",e),(e=e.slice(0)).forEach((e=>{this._pendingPromises.add(e);const t=t=>{this._pendingPromises.has(e)&&this._updateFeatures(t),this._updatePendingPromises(e)},s=()=>this._updatePendingPromises(e);e.then(t,s)})),this.notifyChange("pendingPromisesCount")}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;e=isNaN(e)||e<-1||!t?-1:(e+t)%t,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get state(){return this.get("view.ready")?"ready":"disabled"}centerAtLocation(){const{view:e}=this,t=A(this);if(!t){const s=new i("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e});return G.error(s),Promise.reject(s)}return this.callGoTo({target:{target:t,scale:e.scale}})}clear(){this.set({promises:[],features:[],content:null,title:null,location:null})}fetchFeatures(e,t){const{view:s}=this;if(!s||!e){const t=new i("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:s});return G.error(t),Promise.reject(t)}return s.fetchPopupFeatures(e,{event:t&&t.event,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t&&t.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:s}=t;delete t.fetchFeatures,s&&this._setFetchFeaturesPromises(t.location);const i=["actionsMenuOpen","collapsed","featureMenuOpen"];for(const o of i)delete t[o];this.set(t)}triggerAction(e){const t=this.allActions.getItemAt(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex=this.selectedFeatureIndex+1,this}previous(){return this.selectedFeatureIndex=this.selectedFeatureIndex-1,this}disableClusterBrowsing(){M(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){await j(this),await V(this)}_animationStateChange(e){this.zoomToLocation||(P.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){var e;const t=null==(e=this.view)?void 0:e.graphics;t&&(t.remove(this.selectedClusterBoundaryFeature),t.remove(this._selectedClusterFeature)),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){var e;(null!=(e=this.selectedFeature)&&e.isAggregate||this.browseClusterEnabled)&&(this.browseClusterEnabled=!1,this.visible=!1)}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:s}=this;s&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>1?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>1?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:s,featuresPerPage:i,featureViewModels:o}=this;if(null===s)return;const r=((s-1)*i+t)%t,n=r+i;o.slice(r,n).forEach(((t,s)=>{t&&!t.graphic&&(t.graphic=e[r+s])}))}async _selectedFeatureChange(e){if(!e)return;const{location:t,updateLocationEnabled:s,view:i}=this;if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(i.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),e.isAggregate)return;return e.symbol=await w(e),this._selectedClusterFeature=e,void i.graphics.add(this._selectedClusterFeature)}!s&&t||!e.geometry?s&&!e.geometry&&this.centerAtLocation().then((()=>{this.location=i.center.clone()})):this.location=n(this._getPointFromGeometry(e.geometry))}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}_setFetchFeaturesPromises(e){return this._fetchFeaturesWithController(this._getScreenPoint(e||this.location)).then((e=>{const{clientOnlyGraphics:t,promisesPerLayerView:s}=e,i=Promise.resolve(t),o=s.map((e=>e.promise));this.promises=[i,...o]}))}_destroyFeatureVMs(){this.featureViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:s}=this;if(null!=e&&e.isAggregate||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t||!t.length)return;const i=s.slice(0),o=[];t.forEach(((t,s)=>{if(!t)return;let r=null;if(i.some(((e,s)=>(e&&e.graphic===t&&(r=e,i.splice(s,1)),!!r))),r)o[s]=r;else{var n,a;const i=new _({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:null==(n=this.view)?void 0:n.spatialReference,graphic:t===e?t:null,map:null==(a=this.view)?void 0:a.map,view:this.view});o[s]=i}})),i.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",o)}_getScreenPoint(e){const{view:t}=this;return t&&e&&"function"==typeof t.toScreen?t.toScreen(e):null}_autoOpenEnabledChange(){const e="auto-fetch-features",{_handles:t,autoOpenEnabled:s}=this;if(t.remove(e),s&&this.view){const s=this.view.on("click",(e=>{"mouse"===e.pointerType&&0!==e.button||this._fetchFeaturesAndOpen(e)}),F.WIDGET);t.add(s,e)}}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null,this.notifyChange("waitingForResult")}_fetchFeaturesWithController(e,t){this._cancelFetchingFeatures();const s=new AbortController,{signal:i}=s;this._fetchFeaturesController=s,this.notifyChange("waitingForResult");const o=this.fetchFeatures(e,{signal:i,event:t});return o.catch((()=>{})).then((()=>{this._fetchFeaturesController=null,this.notifyChange("waitingForResult")})),o}_fetchFeaturesAndOpen(e){const{screenPoint:t,mapPoint:s}=e,{view:i}=this;this._fetchFeaturesWithController(t,e).then((e=>{const{clientOnlyGraphics:t,promisesPerLayerView:o,location:r}=e,n=[Promise.resolve(t),...o.map((e=>e.promise))];return i.popup.open({location:r||s,promises:n}),e}))}_updatePendingPromises(e){e&&this._pendingPromises.has(e)&&(this._pendingPromises.delete(e),this.notifyChange("pendingPromisesCount"))}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}_getPointFromGeometry(e){return a(e)?null:"point"===e.type?e:"extent"===e.type?e.center:"polygon"===e.type?e.centroid:"multipoint"===e.type||"polyline"===e.type?e.extent.center:null}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}async _highlightFeature(){const e="highlight";this._handles.remove(e);const{selectedFeature:t,highlightEnabled:s,view:i,visible:o}=this;if(!(t&&i&&s&&o))return;let{layer:r,sourceLayer:n}=t;if("map-notes"!==(null==n?void 0:n.type)&&"subtype-group"!==(null==n?void 0:n.type)||(r=n),!(r&&r instanceof g))return;const a=this._getLayerView(i,r);this._highlightPromise=a;const l=await a;if(!(l&&v(l)&&this._highlightPromise===a&&this.selectedFeature&&this.highlightEnabled&&this.visible))return;const u="objectIdField"in r&&r.objectIdField,h=t.attributes,c=h&&u&&h[u],p=l.highlight(c||t);this._handles.add(p,e)}_updateFeatures(e){const{features:t}=this;if(!e||!e.length)return;if(!t.length)return void(this.features=e);const s=e.filter((e=>-1===t.indexOf(e)));this.features=t.concat(s)}};e([c()],z.prototype,"featurePage",void 0),e([c()],z.prototype,"isLoadingFeature",null),e([c({type:T})],z.prototype,"actions",void 0),e([c({readOnly:!0})],z.prototype,"active",null),e([c({readOnly:!0})],z.prototype,"allActions",null),e([c({type:Boolean})],z.prototype,"defaultPopupTemplateEnabled",void 0),e([c()],z.prototype,"autoCloseEnabled",void 0),e([c()],z.prototype,"autoOpenEnabled",void 0),e([c()],z.prototype,"browseClusterEnabled",void 0),e([c()],z.prototype,"content",void 0),e([c({type:T,readOnly:!0})],z.prototype,"defaultActions",null),e([c({readOnly:!0})],z.prototype,"featureCount",null),e([c()],z.prototype,"features",null),e([c()],z.prototype,"featuresPerPage",void 0),e([c()],z.prototype,"featureViewModelAbilities",void 0),e([c({readOnly:!0})],z.prototype,"featureViewModels",void 0),e([c()],z.prototype,"highlightEnabled",void 0),e([c()],z.prototype,"includeDefaultActions",void 0),e([c({type:L})],z.prototype,"location",null),e([c({readOnly:!0})],z.prototype,"pendingPromisesCount",null),e([c({readOnly:!0})],z.prototype,"selectedClusterBoundaryFeature",void 0),e([c({readOnly:!0})],z.prototype,"waitingForResult",null),e([c({readOnly:!0})],z.prototype,"promiseCount",null),e([c()],z.prototype,"promises",null),e([c({value:null,readOnly:!0})],z.prototype,"selectedFeature",null),e([c({value:-1})],z.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],z.prototype,"selectedFeatureViewModel",null),e([c({readOnly:!0})],z.prototype,"state",null),e([c()],z.prototype,"title",void 0),e([c()],z.prototype,"updateLocationEnabled",void 0),e([c()],z.prototype,"view",void 0),e([c()],z.prototype,"visible",void 0),e([c()],z.prototype,"zoomFactor",void 0),e([c()],z.prototype,"zoomToLocation",void 0),e([c()],z.prototype,"centerAtLocation",null),z=e([p(R)],z);const U=z;export{U as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import"../../symbols.js";import s from"../../core/Collection.js";import i from"../../core/Error.js";import o from"../../core/Handles.js";import r from"../../core/Logger.js";import{unwrap as n,isNone as a}from"../../core/maybe.js";import{init as l,watch as u,whenFalse as h}from"../../core/watchUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import{geographicToWebMercator as d}from"../../geometry/support/webMercatorUtils.js";import g from"../../layers/Layer.js";import f from"../../support/actions/ActionBase.js";import m from"../../support/actions/ActionButton.js";import y from"../../support/actions/ActionToggle.js";import{getDisplayedSymbol as w}from"../../symbols/support/symbolUtils.js";import{ViewEventPriorities as v}from"../../views/input/InputManager.js";import{highlightsSupported as F}from"../../views/support/layerViewUtils.js";import _ from"../Feature/FeatureViewModel.js";import{zoomToClusteredFeatures as b,browseClusteredFeatures as C,zoomToFeature as P}from"./actions.js";import{triggerAction as E,getSelectedTarget as A,removeClusteredFeaturesForBrowsing as M,displayClusterExtent as j,browseAggregateFeatures as V}from"./actionUtils.js";import O from"../support/AnchorElementViewModel.js";import{GoToMixin as x}from"../support/GoTo.js";import I from"../../symbols/SimpleFillSymbol.js";import L from"../../geometry/Point.js";const T=s.ofType({key:"type",defaultKeyValue:"button",base:f,typeMap:{button:m,toggle:y}}),S=()=>[P.clone()],B=()=>[b.clone(),C.clone()],R="esri.widgets.Popup.PopupViewModel",G=r.getLogger(R);let z=class extends(x(O)){constructor(e){super(e),this._handles=new o,this._pendingPromises=new Set,this._fetchFeaturesController=null,this._selectedClusterFeature=null,this.featurePage=null,this.actions=new T,this.defaultPopupTemplateEnabled=!1,this.autoCloseEnabled=!1,this.autoOpenEnabled=!0,this.browseClusterEnabled=!1,this.content=null,this.featuresPerPage=20,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.selectedClusterBoundaryFeature=new t({symbol:new I({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null}get isLoadingFeature(){return this.featureViewModels.some((e=>e.waitingForContent))}initialize(){this._handles.add([l(this,["autoOpenEnabled","view"],(()=>this._autoOpenEnabledChange())),this.on("view-change",(()=>this._autoClose())),u(this,["highlightEnabled","selectedFeature","visible","view"],(()=>this._highlightFeature())),u(this,"view.animation.state",(e=>this._animationStateChange(e))),u(this,"location",(e=>this._locationChange(e))),u(this,"selectedFeature",(e=>this._selectedFeatureChange(e))),u(this,["selectedFeatureIndex","featureCount","featuresPerPage"],(()=>this._selectedFeatureIndexChange())),u(this,["featurePage","selectedFeatureIndex","featureCount","featuresPerPage, featureViewModels"],(()=>this._setGraphicOnFeatureViewModels())),u(this,"featureViewModels",(()=>this._featureViewModelsChange())),this.on("trigger-action",(e=>E({event:e,view:this.view}))),h(this,"waitingForResult",(()=>this._waitingForResultChange()),!0),u(this,["features","view","view.map","view.spatialReference"],(()=>this._updateFeatureVMs())),u(this,["view.scale"],this._viewScaleChange),h(this,"visible",(()=>this.browseClusterEnabled=!1)),u(this,"browseClusterEnabled",(e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing()))])}destroy(){this._cancelFetchingFeatures(),this._handles.destroy(),this._handles=null,this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new T;e.removeAll();const{actions:t,defaultActions:s,defaultPopupTemplateEnabled:i,includeDefaultActions:o,selectedFeature:r}=this,n=o?s.concat(t):t,a=r&&("function"==typeof r.getEffectivePopupTemplate&&r.getEffectivePopupTemplate(i)||r.popupTemplate),l=a&&a.actions,u=a&&a.overwriteActions?l:l?l.concat(n):n;return u&&u.filter(Boolean).forEach((t=>e.add(t))),e}get defaultActions(){var e;const t=this._get("defaultActions")||new T;return t.removeAll(),t.addMany(null!=(e=this.selectedFeature)&&e.isAggregate?B():S()),t}get featureCount(){return this.features.length}get features(){return this._get("features")||[]}set features(e){const t=e||[];this._set("features",t);const{pendingPromisesCount:s,promiseCount:i,selectedFeatureIndex:o}=this,r=i&&t.length;r&&s&&-1===o?this.selectedFeatureIndex=0:r&&-1!==o||(this.selectedFeatureIndex=t.length?0:-1)}get location(){return this._get("location")||null}set location(e){const t=this.get("view.spatialReference.isWebMercator");e&&e.get("spatialReference.isWGS84")&&t&&(e=d(e)),this._set("location",e)}get pendingPromisesCount(){return this._pendingPromises.size}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){if(this._pendingPromises.clear(),this.features=[],!Array.isArray(e)||!e.length)return this._set("promises",[]),void this.notifyChange("pendingPromisesCount");this._set("promises",e),(e=e.slice(0)).forEach((e=>{this._pendingPromises.add(e);const t=t=>{this._pendingPromises.has(e)&&this._updateFeatures(t),this._updatePendingPromises(e)},s=()=>this._updatePendingPromises(e);e.then(t,s)})),this.notifyChange("pendingPromisesCount")}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;e=isNaN(e)||e<-1||!t?-1:(e+t)%t,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get state(){return this.get("view.ready")?"ready":"disabled"}centerAtLocation(){const{view:e}=this,t=A(this);if(!t){const s=new i("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e});return G.error(s),Promise.reject(s)}return this.callGoTo({target:{target:t,scale:e.scale}})}clear(){this.set({promises:[],features:[],content:null,title:null,location:null})}fetchFeatures(e,t){const{view:s}=this;if(!s||!e){const t=new i("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:s});return G.error(t),Promise.reject(t)}return s.fetchPopupFeatures(e,{event:t&&t.event,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t&&t.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:s}=t;delete t.fetchFeatures,s&&this._setFetchFeaturesPromises(t.location);const i=["actionsMenuOpen","collapsed","featureMenuOpen"];for(const o of i)delete t[o];this.set(t)}triggerAction(e){const t=this.allActions.getItemAt(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex=this.selectedFeatureIndex+1,this}previous(){return this.selectedFeatureIndex=this.selectedFeatureIndex-1,this}disableClusterBrowsing(){M(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){await j(this),await V(this)}_animationStateChange(e){this.zoomToLocation||(P.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){var e;const t=null==(e=this.view)?void 0:e.graphics;t&&(t.remove(this.selectedClusterBoundaryFeature),t.remove(this._selectedClusterFeature)),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){var e;(null!=(e=this.selectedFeature)&&e.isAggregate||this.browseClusterEnabled)&&(this.browseClusterEnabled=!1,this.visible=!1)}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:s}=this;s&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>1?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>1?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:s,featuresPerPage:i,featureViewModels:o}=this;if(null===s)return;const r=((s-1)*i+t)%t,n=r+i;o.slice(r,n).forEach(((t,s)=>{t&&!t.graphic&&(t.graphic=e[r+s])}))}async _selectedFeatureChange(e){if(!e)return;const{location:t,updateLocationEnabled:s,view:i}=this;if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(i.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),e.isAggregate)return;return e.symbol=await w(e),this._selectedClusterFeature=e,void i.graphics.add(this._selectedClusterFeature)}!s&&t||!e.geometry?s&&!e.geometry&&this.centerAtLocation().then((()=>{this.location=i.center.clone()})):this.location=n(this._getPointFromGeometry(e.geometry))}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}_setFetchFeaturesPromises(e){return this._fetchFeaturesWithController(this._getScreenPoint(e||this.location)).then((e=>{const{clientOnlyGraphics:t,promisesPerLayerView:s}=e,i=Promise.resolve(t),o=s.map((e=>e.promise));this.promises=[i,...o]}))}_destroyFeatureVMs(){this.featureViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:s}=this;if(null!=e&&e.isAggregate||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t||!t.length)return;const i=s.slice(0),o=[];t.forEach(((t,s)=>{if(!t)return;let r=null;if(i.some(((e,s)=>(e&&e.graphic===t&&(r=e,i.splice(s,1)),!!r))),r)o[s]=r;else{var n,a;const i=new _({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:null==(n=this.view)?void 0:n.spatialReference,graphic:t===e?t:null,map:null==(a=this.view)?void 0:a.map,view:this.view});o[s]=i}})),i.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",o)}_getScreenPoint(e){const{view:t}=this;return t&&e&&"function"==typeof t.toScreen?t.toScreen(e):null}_autoOpenEnabledChange(){const e="auto-fetch-features",{_handles:t,autoOpenEnabled:s}=this;if(t.remove(e),s&&this.view){const s=this.view.on("click",(e=>{"mouse"===e.pointerType&&0!==e.button||this._fetchFeaturesAndOpen(e)}),v.WIDGET);t.add(s,e)}}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null,this.notifyChange("waitingForResult")}_fetchFeaturesWithController(e,t){this._cancelFetchingFeatures();const s=new AbortController,{signal:i}=s;this._fetchFeaturesController=s,this.notifyChange("waitingForResult");const o=this.fetchFeatures(e,{signal:i,event:t});return o.catch((()=>{})).then((()=>{this._fetchFeaturesController=null,this.notifyChange("waitingForResult")})),o}_fetchFeaturesAndOpen(e){const{screenPoint:t,mapPoint:s}=e,{view:i}=this;this._fetchFeaturesWithController(t,e).then((e=>{const{clientOnlyGraphics:t,promisesPerLayerView:o,location:r}=e,n=[Promise.resolve(t),...o.map((e=>e.promise))];return i.popup.open({location:r||s,promises:n}),e}))}_updatePendingPromises(e){e&&this._pendingPromises.has(e)&&(this._pendingPromises.delete(e),this.notifyChange("pendingPromisesCount"))}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}_getPointFromGeometry(e){return a(e)?null:"point"===e.type?e:"extent"===e.type?e.center:"polygon"===e.type?e.centroid:"multipoint"===e.type||"polyline"===e.type?e.extent.center:null}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}async _highlightFeature(){const e="highlight";this._handles.remove(e);const{selectedFeature:t,highlightEnabled:s,view:i,visible:o}=this;if(!(t&&i&&s&&o))return;let{layer:r,sourceLayer:n}=t;if("map-notes"!==(null==n?void 0:n.type)&&"subtype-group"!==(null==n?void 0:n.type)||(r=n),!(r&&r instanceof g))return;const a=this._getLayerView(i,r);this._highlightPromise=a;const l=await a;if(!(l&&F(l)&&this._highlightPromise===a&&this.selectedFeature&&this.highlightEnabled&&this.visible))return;const u="imagery"===r.type?void 0:"objectIdField"in r&&r.objectIdField,h=t.attributes,c=h&&u&&h[u],p=l.highlight(c||t);this._handles.add(p,e)}_updateFeatures(e){const{features:t}=this;if(!e||!e.length)return;if(!t.length)return void(this.features=e);const s=e.filter((e=>-1===t.indexOf(e)));this.features=t.concat(s)}};e([c()],z.prototype,"featurePage",void 0),e([c()],z.prototype,"isLoadingFeature",null),e([c({type:T})],z.prototype,"actions",void 0),e([c({readOnly:!0})],z.prototype,"active",null),e([c({readOnly:!0})],z.prototype,"allActions",null),e([c({type:Boolean})],z.prototype,"defaultPopupTemplateEnabled",void 0),e([c()],z.prototype,"autoCloseEnabled",void 0),e([c()],z.prototype,"autoOpenEnabled",void 0),e([c()],z.prototype,"browseClusterEnabled",void 0),e([c()],z.prototype,"content",void 0),e([c({type:T,readOnly:!0})],z.prototype,"defaultActions",null),e([c({readOnly:!0})],z.prototype,"featureCount",null),e([c()],z.prototype,"features",null),e([c()],z.prototype,"featuresPerPage",void 0),e([c()],z.prototype,"featureViewModelAbilities",void 0),e([c({readOnly:!0})],z.prototype,"featureViewModels",void 0),e([c()],z.prototype,"highlightEnabled",void 0),e([c()],z.prototype,"includeDefaultActions",void 0),e([c({type:L})],z.prototype,"location",null),e([c({readOnly:!0})],z.prototype,"pendingPromisesCount",null),e([c({readOnly:!0})],z.prototype,"selectedClusterBoundaryFeature",void 0),e([c({readOnly:!0})],z.prototype,"waitingForResult",null),e([c({readOnly:!0})],z.prototype,"promiseCount",null),e([c()],z.prototype,"promises",null),e([c({value:null,readOnly:!0})],z.prototype,"selectedFeature",null),e([c({value:-1})],z.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],z.prototype,"selectedFeatureViewModel",null),e([c({readOnly:!0})],z.prototype,"state",null),e([c()],z.prototype,"title",void 0),e([c()],z.prototype,"updateLocationEnabled",void 0),e([c()],z.prototype,"view",void 0),e([c()],z.prototype,"visible",void 0),e([c()],z.prototype,"zoomFactor",void 0),e([c()],z.prototype,"zoomToLocation",void 0),e([c()],z.prototype,"centerAtLocation",null),z=e([p(R)],z);const U=z;export{U as default};