/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
v4.34.7 */
import{b as u}from"./4U3PHNGQ.js";import{b as s,e as h}from"./SRDD32D4.js";import{a as c}from"./IMJMO6DB.js";import{b as a,s as p,u as l}from"./RNRMSLW5.js";export default $arcgis.t(([{when:f,watch:d}])=>{var m=class extends l{constructor(r){super(r),this.direction=h(),this.component.listen("arcgisViewClick",o=>{this._handleOpenPopup(o.detail)}),this.component.listenOn(globalThis,"unhandledrejection",o=>{if(o.reason?.name==="webgl:required"){let{name:e}=o.reason;this.webGLError={name:e}}})}hostLifecycle(){return f(()=>this.component.view.popup?.visible,()=>{this.popupRef?.visible&&(this.popupRef.visible=!1)})}openPopup(r){this.popupRef?this.popupRef.open(r):this.component.view.openPopup(r)}closePopup(){this.popupRef?this.popupRef.visible=!1:this.component.view.closePopup()}async _handleOpenPopup(r){if(this.popupRef&&!this.component.popupDisabled){r.stopPropagation();let{location:o,promises:e}=await this.popupRef?.handleViewClick(r);e?.length&&(this.component.view.closePopup(),this.popupRef?.open({location:o,promises:e}))}}_handlePopupSlotChange(r){let o=c(r.target,"arcgis-popup");!this.popupRef&&o.length?this.popupRef=o[0]:o.length||(this.popupRef=void 0)}_webGLErrorAlert(){return this.webGLError?a`<calcite-alert icon=x-octagon kind=danger open .label=${this.webGLError.name}><div slot=title>Unable to display map. WebGL2 support is required.</div><div slot=message>Ensure that your browser and hardware meet the minimum requirements.</div><calcite-link slot=link href=https://esriurl.com/webgl-faq>https://esriurl.com/webgl-faq</calcite-link></calcite-alert>`:null}render(){return u(this.direction,r=>this._handlePopupSlotChange(r),this._webGLErrorAlert())}},R=s((t,r)=>{let o=p();return r.onLifecycle(()=>d(()=>{let{map:e}=t;if(!e||e.destroyed)return[];let i=[];return e.loadError&&i.push(e),e.basemap?.loadError&&i.push(e.basemap),e.ground.loadError&&i.push(e.ground),[...e.allLayers,...e.allTables].forEach(n=>{n.loadError&&i.push(n)}),i},e=>{e.length&&(t.loadErrorSources=e,o.emit())})),o}),y=s((t,r)=>{let o=p();return r.onLifecycle(()=>d(()=>t.view?.readyState,e=>{(e==="map-content-error"||e==="rendering-error")&&o.emit()})),o});return{a:m,b:R,c:y}},"core/reactiveUtils")