import{E as n,f as h,S as c,d as L,B as C,g as I}from"./dom.min.js?5.3.0";const v="tab",D="bs.tab",l=`.${D}`,S=`hide${l}`,R=`hidden${l}`,$=`show${l}`,y=`shown${l}`,x=`click${l}`,k=`keydown${l}`,P=`load${l}`,W="ArrowLeft",O="ArrowRight",H="ArrowUp",T="ArrowDown",A="Home",p="End",d="active",w="fade",g="show",J="dropdown",N=".dropdown-toggle",K=".dropdown-menu",b=`:not(${N})`,V='.list-group, .nav, [role="tablist"]',G=".nav-item, .list-group-item",M=`.nav-link${b}, .list-group-item${b}, [role="tab"]${b}`,m='[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]',f=`${M}, ${m}`,Y=`.${d}[data-bs-toggle="tab"], .${d}[data-bs-toggle="pill"], .${d}[data-bs-toggle="list"]`;class a extends C{constructor(t){super(t),this._parent=this._element.closest(V),this._parent&&(this._setInitialAttributes(this._parent,this._getChildren()),n.on(this._element,k,e=>this._keydown(e)))}static get NAME(){return v}show(){const t=this._element;if(this._elemIsActive(t))return;const e=this._getActiveElem(),s=e?n.trigger(e,S,{relatedTarget:t}):null;n.trigger(t,$,{relatedTarget:e}).defaultPrevented||s&&s.defaultPrevented||(this._deactivate(e,t),this._activate(t,e))}_activate(t,e){if(!t)return;t.classList.add(d),this._activate(c.getElementFromSelector(t));const s=()=>{if(t.getAttribute("role")!=="tab"){t.classList.add(g);return}t.removeAttribute("tabindex"),t.setAttribute("aria-selected",!0),this._toggleDropDown(t,!0),n.trigger(t,y,{relatedTarget:e})};this._queueCallback(s,t,t.classList.contains(w))}_deactivate(t,e){if(!t)return;t.classList.remove(d),t.blur(),this._deactivate(c.getElementFromSelector(t));const s=()=>{if(t.getAttribute("role")!=="tab"){t.classList.remove(g);return}t.setAttribute("aria-selected",!1),t.setAttribute("tabindex","-1"),this._toggleDropDown(t,!1),n.trigger(t,R,{relatedTarget:e})};this._queueCallback(s,t,t.classList.contains(w))}_keydown(t){if(![W,O,H,T,A,p].includes(t.key))return;t.stopPropagation(),t.preventDefault();const e=this._getChildren().filter(i=>!h(i));let s;if([A,p].includes(t.key))s=e[t.key===A?0:e.length-1];else{const i=[O,T].includes(t.key);s=I(e,t.target,i,!0)}s&&(s.focus({preventScroll:!0}),a.getOrCreateInstance(s).show())}_getChildren(){return c.find(f,this._parent)}_getActiveElem(){return this._getChildren().find(t=>this._elemIsActive(t))||null}_setInitialAttributes(t,e){this._setAttributeIfNotExists(t,"role","tablist");for(const s of e)this._setInitialAttributesOnChild(s)}_setInitialAttributesOnChild(t){t=this._getInnerElement(t);const e=this._elemIsActive(t),s=this._getOuterElement(t);t.setAttribute("aria-selected",e),s!==t&&this._setAttributeIfNotExists(s,"role","presentation"),e||t.setAttribute("tabindex","-1"),this._setAttributeIfNotExists(t,"role","tab"),this._setInitialAttributesOnTargetPanel(t)}_setInitialAttributesOnTargetPanel(t){const e=c.getElementFromSelector(t);e&&(this._setAttributeIfNotExists(e,"role","tabpanel"),t.id&&this._setAttributeIfNotExists(e,"aria-labelledby",`${t.id}`))}_toggleDropDown(t,e){const s=this._getOuterElement(t);if(!s.classList.contains(J))return;const i=(_,u)=>{const r=c.findOne(_,s);r&&r.classList.toggle(u,e)};i(N,d),i(K,g),s.setAttribute("aria-expanded",e)}_setAttributeIfNotExists(t,e,s){t.hasAttribute(e)||t.setAttribute(e,s)}_elemIsActive(t){return t.classList.contains(d)}_getInnerElement(t){return t.matches(f)?t:c.findOne(f,t)}_getOuterElement(t){return t.closest(G)||t}static jQueryInterface(t){return this.each(function(){const e=a.getOrCreateInstance(this);if(typeof t=="string"){if(e[t]===void 0||t.startsWith("_")||t==="constructor")throw new TypeError(`No method named "${t}"`);e[t]()}})}}if(n.on(document,x,m,function(o){["A","AREA"].includes(this.tagName)&&o.preventDefault(),!h(this)&&a.getOrCreateInstance(this).show()}),n.on(window,P,()=>{for(const o of c.find(Y))a.getOrCreateInstance(o)}),L(a),window.Joomla=window.Joomla||{},window.bootstrap=window.bootstrap||{},window.bootstrap.Tab=a,Joomla.initialiseTabs=(o,t)=>{if(!(o instanceof Element)&&t.isJoomla){const e=document.querySelector(`${o}Content`);if(e){const s=Array.from(e.children);s.length&&s.forEach(i=>{if(!i.classList.contains("tab-pane"))return;const _=i.dataset.active!=="",u=document.querySelector(`${o}Tabs`);if(u){const r=document.createElement("a");r.href=`#${i.dataset.id}`,r.classList.add("nav-link"),_&&r.classList.add("active"),r.dataset.bsToggle="tab",r.setAttribute("role","tab"),r.setAttribute("aria-controls",i.dataset.id),r.setAttribute("aria-selected",i.dataset.id),r.innerHTML=Joomla.sanitizeHtml(i.dataset.title);const E=document.createElement("li");E.classList.add("nav-item"),E.setAttribute("role","presentation"),E.appendChild(r),u.appendChild(E),new window.bootstrap.Tab(E)}})}}else Array.from(document.querySelectorAll(`${o} a`)).map(e=>new window.bootstrap.Tab(e,t))},Joomla&&Joomla.getOptions){const o=Joomla.getOptions("bootstrap.tabs");typeof o=="object"&&o!==null&&Object.keys(o).map(t=>Joomla.initialiseTabs(t,o[t]))}export{a as T};
