/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import b from"./J4OTW75Q.js";import a from"./DXIOCBFP.js";export default $arcgis.t(([,m,p,{isZoomScreenSize:h},{c:d},{d:l}])=>{var n=new m({icon:"magnifying-glass-plus",id:"zoom-to-feature",title:"{messages.zoom}"}),b=new m({icon:"trash",id:"remove-selected-feature",title:"{messages.remove}"}),s=new m({icon:"magnifying-glass-plus",id:"zoom-to-clustered-features",title:"{messages.zoom}"}),y=new p({icon:"table",id:"browse-clustered-features",title:"{messages.browseClusteredFeatures}",value:!1});function O(e){if(e.icon)return e.icon;if(!("image"in e&&e.image)&&!e.className)return"question"}function Q(e){return e?{backgroundImage:`url(${e})`}:{}}function z(e){let{selectedFeature:t,location:i,view:r}=e;return r?t??i??null:null}async function E(e,t){let{location:i,selectedFeature:r,view:o,zoomFactor:a}=e;await t?.viewModel?.updateGeometry();let c=t?.graphic,g=c?.geometry?c:z(e);if(!o||!g)throw new Error("Cannot zoom to location without a target and view.");let f=o.scale/a,u=c?.geometry??e.selectedFeature?.geometry??i,w=u?.type==="point"&&await h(c??r,o);n.active=!0,n.disabled=!0;try{await e.zoomTo({target:{target:g,scale:w?f:void 0}})}catch(v){if(d(v))return;throw new Error("Could not zoom to the location of the graphic.")}finally{n.active=!1,n.disabled=!1,w&&e.location!==u&&(e.location=u)}}function C(e){return!!e&&e.isAggregate&&l(e)?.featureReduction?.type==="cluster"}async function F(e,t){let i=await e.whenLayerView(l(t)),r=i.createQuery(),o=t.getObjectId();return r.aggregateIds=o!=null?[o]:[],[i,r]}async function T(e){let{selectedFeature:t,view:i}=e;if(i?.type!=="2d")throw new Error("zoomToCluster:invalid-view: View must be 2d MapView.");if(!t||!C(t))throw new Error("zoomToCluster:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.");let[r,o]=await F(i,t);s.active=!0,s.disabled=!0;let{extent:a}=await r.queryExtent(o);a&&await e.zoomTo({target:a}),s.active=!1,s.disabled=!1}var Z=async(e,t)=>{if(!e)throw new Error("trigger-action:missing-arguments: Event has no action");let{disabled:i,id:r}=e;if(!r)throw new Error("trigger-action:invalid-action: action.id is missing");if(i)throw new Error("trigger-action:invalid-action: Action is disabled");if(r===n.id)return await E(t).catch(o=>{if(!d(o))throw o});if(r===s.id)return await T(t);if(r===y.id){t.browseClusterEnabled=!t.browseClusterEnabled,t.featureMenuOpen=t.browseClusterEnabled;return}if(r===b.id){t.visible=!1;let{selectedFeature:o}=t;if(!o)throw new Error("trigger-action:missing-selected-feature: Cannot remove selected feature without a selected feature.");let a=l(o);a?a.remove(o):t.view?.graphics.remove(o)}};return{a:n,b:O,c:Q,d:E,e:Z}},"intl","support/actions/ActionButton","support/actions/ActionToggle","applications/Components/actionUtils",a,b)