/*! * (C) Ionic http://ionicframework.com - MIT License */ import{r as t,h as i,f as s,i as e,d as o}from"./p-9ad82dba.js";import{a}from"./p-3cc276f4.js";import"./p-b51e4004.js";const n=class{constructor(i){t(this,i),this.loaded=!1,this.active=!1,this.delegate=void 0,this.tab=void 0,this.component=void 0}async componentWillLoad(){this.active&&await this.setActive()}async setActive(){await this.prepareLazyLoaded(),this.active=!0}changeActive(t){t&&this.prepareLazyLoaded()}prepareLazyLoaded(){if(!this.loaded&&null!=this.component){this.loaded=!0;try{return a(this.delegate,this.el,this.component,["ion-page"])}catch(t){console.error(t)}}return Promise.resolve(void 0)}render(){const{tab:t,active:e,component:o}=this;return i(s,{key:"1a58c58f3d721e840fc2bb09a4f93c47ff0ce1dc",role:"tabpanel","aria-hidden":e?null:"true","aria-labelledby":`tab-button-${t}`,class:{"ion-page":void 0===o,"tab-hidden":!e}},i("slot",{key:"0189bc368d456b93c376c363216d6535f45a8822"}))}get el(){return e(this)}static get watchers(){return{active:["changeActive"]}}};n.style=":host(.tab-hidden){display:none !important}";const h=class{constructor(i){t(this,i),this.ionNavWillLoad=o(this,"ionNavWillLoad",7),this.ionTabsWillChange=o(this,"ionTabsWillChange",3),this.ionTabsDidChange=o(this,"ionTabsDidChange",3),this.transitioning=!1,this.onTabClicked=t=>{const{href:i,tab:s}=t.detail;if(this.useRouter&&void 0!==i){const t=document.querySelector("ion-router");t&&t.push(i)}else this.select(s)},this.selectedTab=void 0,this.useRouter=!1}async componentWillLoad(){if(this.useRouter||(this.useRouter=!!document.querySelector("ion-router")&&!this.el.closest("[no-router]")),!this.useRouter){const t=this.tabs;t.length>0&&await this.select(t[0])}this.ionNavWillLoad.emit()}componentWillRender(){const t=this.el.querySelector("ion-tab-bar");t&&(t.selectedTab=this.selectedTab?this.selectedTab.tab:void 0)}async select(t){const i=r(this.tabs,t);return!!this.shouldSwitch(i)&&(await this.setActive(i),await this.notifyRouter(),this.tabSwitch(),!0)}async getTab(t){return r(this.tabs,t)}getSelected(){return Promise.resolve(this.selectedTab?this.selectedTab.tab:void 0)}async setRouteId(t){const i=r(this.tabs,t);return this.shouldSwitch(i)?(await this.setActive(i),{changed:!0,element:this.selectedTab,markVisible:()=>this.tabSwitch()}):{changed:!1,element:this.selectedTab}}async getRouteId(){var t;const i=null===(t=this.selectedTab)||void 0===t?void 0:t.tab;return void 0!==i?{id:i,element:this.selectedTab}:void 0}setActive(t){return this.transitioning?Promise.reject("transitioning already happening"):(this.transitioning=!0,this.leavingTab=this.selectedTab,this.selectedTab=t,this.ionTabsWillChange.emit({tab:t.tab}),t.active=!0,Promise.resolve())}tabSwitch(){const t=this.selectedTab,i=this.leavingTab;this.leavingTab=void 0,this.transitioning=!1,t&&i!==t&&(i&&(i.active=!1),this.ionTabsDidChange.emit({tab:t.tab}))}notifyRouter(){if(this.useRouter){const t=document.querySelector("ion-router");if(t)return t.navChanged("forward")}return Promise.resolve(!1)}shouldSwitch(t){return void 0!==t&&t!==this.selectedTab&&!this.transitioning}get tabs(){return Array.from(this.el.querySelectorAll("ion-tab"))}render(){return i(s,{key:"05f1607d092d5bef9f1f42dd46d4bec6caa58f15",onIonTabButtonClick:this.onTabClicked},i("slot",{key:"8e175dbf3afeb76c0b3a794b3064a2191b1b5fbc",name:"top"}),i("div",{key:"d7120d2f0dc58cca23c0854e042a4d4b8fde4db6",class:"tabs-inner"},i("slot",{key:"a3651076ad9ab1c6cf56a7b82172ff59930d1963"})),i("slot",{key:"a719a23f813740dc2c03d21af0c2fe28f1b4f8bb",name:"bottom"}))}get el(){return e(this)}},r=(t,i)=>{const s="string"==typeof i?t.find((t=>t.tab===i)):i;return s||console.error(`tab with id: "${s}" does not exist`),s};h.style=":host{left:0;right:0;top:0;bottom:0;display:-ms-flexbox;display:flex;position:absolute;-ms-flex-direction:column;flex-direction:column;width:100%;height:100%;contain:layout size style;z-index:0}.tabs-inner{position:relative;-ms-flex:1;flex:1;contain:layout size style}";export{n as ion_tab,h as ion_tabs}