/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import{b as p}from"./HVT2WBVC.js";import{G as a,h as i,i as n,t as r}from"./FFF5HUPM.js";import"./EXBEKVP5.js";var h=i`@layer{:host{display:block}}`,e=class extends a{constructor(){super(...arguments),this.inTour=!1,this.instantAppsPopovers=new Map,this.beforeOpen=async()=>await Promise.resolve()}static{this.properties={inTour:7,currentId:3,instantAppsPopovers:0,beforeOpen:0}}static{this.styles=h}static{this.shadowRootOptions=r}async beginTour(){this.inTour=!0,this.handlePopoverProps({pagination:!0,disableAction:!0});let s=Array.from(this.instantAppsPopovers.keys());await this.open(s[0])}async close(s){let t=this.instantAppsPopovers.get(s)?.firstElementChild;t&&(t.open=!1)}async endTour(){await this.close(this.currentId),this.inTour=!1,this.handlePopoverProps({pagination:!1,disableAction:!1})}async open(s){await this.beforeOpen();let t=this.instantAppsPopovers.get(s)?.firstElementChild;t.open=!0}async next(){let s=Array.from(this.instantAppsPopovers.keys()),t=s.indexOf(this.currentId)+1,o=s[t];await this.close(this.currentId),await this.open(o)}async previous(){let s=Array.from(this.instantAppsPopovers.keys()),t=s.indexOf(this.currentId)-1,o=s[t];await this.close(this.currentId),await this.open(o)}async done(){await this.endTour()}load(){let s=this.el.querySelector("[slot='popovers']");(s?Array.from(s.children):[]).forEach((t,o)=>{let c=t.getAttribute("ref-id");t.parent=this,t.index=o,this.instantAppsPopovers.set(c,t)}),this.listen("calcitePopoverOpen",t=>{let o=t.target.getAttribute("ref-id")??"";this.currentId=o})}handlePopoverProps(s){Array.from(this.el.querySelector("[slot='popovers']")?.children??[]).forEach(t=>{t.disableAction=s.disableAction,t.pagination=s.pagination})}render(){return n`<slot name=popovers></slot>`}};p("instant-apps-popovers",e);export{e as InstantAppsPopovers};
