import{p as e,H as t,c as i,h as s,d as n,t as r}from"./p-Bpcl2TqF.js";const c=()=>`:host{display:flex}.filter-type-group{width:260px;align-items:flex-start;gap:8px}.filter-type-group>::slotted(*){margin-bottom:8px}`;const l=e(class e extends t{constructor(e){super();if(e!==false){this.__registerHost()}this.__attachShadow();this.ifxSidebarFilterChange=i(this,"ifxSidebarFilterChange",7)}get el(){return this}selectedOptions=[];ifxSidebarFilterChange;connectedCallback(){this.el.addEventListener("ifxFilterAccordionChange",this.handleAccordionChange);this.el.addEventListener("ifxFilterSearchChange",this.handleSearchChange);window.addEventListener("ifxResetFiltersEvent",this.handleResetEvent);window.addEventListener("ifxUpdateSidebarFilter",this.handleUpdateSidebarFilter)}disconnectedCallback(){this.el.removeEventListener("ifxFilterAccordionChange",this.handleAccordionChange);this.el.removeEventListener("ifxFilterSearchChange",this.handleSearchChange);window.removeEventListener("ifxResetFiltersEvent",this.handleResetEvent)}handleResetEvent=()=>{const e=this.el.shadowRoot.querySelector('slot[name="filter-accordion"]');const t=e.assignedElements({flatten:true});t.forEach((e=>{const t=e.querySelectorAll("ifx-list");t.forEach((e=>{e.resetTrigger=!e.resetTrigger}))}));const i=this.el.shadowRoot.querySelector('slot[name="filter-search"]');const s=i.assignedElements({flatten:true});s.forEach((e=>{const t=e.querySelector("ifx-filter-search");const i=t.shadowRoot.querySelectorAll("ifx-search-field");if(i.length>0){i.forEach((e=>{e.value=""}))}}));this.selectedOptions=[];this.ifxSidebarFilterChange.emit(this.selectedOptions)};handleUpdateSidebarFilter=e=>{const{filterName:t}=e.detail;const i=this.el.shadowRoot.querySelector('slot[name="filter-accordion"]');const s=i?i.assignedElements({flatten:true}):[];s.forEach((e=>{const i=e.querySelectorAll("ifx-list");i.forEach((e=>{if(e.getAttribute("name")===t){e.resetTrigger=!e.resetTrigger}}))}));const n=this.el.shadowRoot.querySelector('slot[name="filter-search"]');const r=n?n.assignedNodes({flatten:true}):[];r.forEach((e=>{if(e.nodeType===Node.ELEMENT_NODE){const t=e;const i=t.firstElementChild;if(i){i.setAttribute("value","");i.dispatchEvent(new CustomEvent("ifxInput",{bubbles:true,composed:true,detail:""}))}}}));const c=this.selectedOptions.map((e=>{if(e.filterGroupName===t){return{...e,selectedItems:[],value:""}}return e}));this.selectedOptions=c;this.ifxSidebarFilterChange.emit(this.selectedOptions)};handleAccordionChange=e=>{this.handleFilterChange(e)};handleSearchChange=e=>{this.handleFilterChange(e)};handleFilterChange=e=>{const t=[...this.selectedOptions];if(e.type==="ifxFilterSearchChange"){const{filterName:i,filterValue:s}=e.detail;const n=t.findIndex((e=>typeof e!=="string"&&e.filterGroupName===i));if(n!==-1){t[n].value=s}else{t.push({filterGroupName:i,value:s})}}else if(e.type==="ifxFilterAccordionChange"){const{filterGroupName:i,selectedItems:s}=e.detail;const n=t.findIndex((e=>e.filterGroupName===i));if(n!==-1){t[n]={filterGroupName:i,selectedItems:s}}else{t.push({filterGroupName:i,selectedItems:s})}}this.selectedOptions=t;this.ifxSidebarFilterChange.emit(this.selectedOptions)};render(){return s(n,{key:"2bc6891c098e3d6393f3b31373a12c1ae02cdb25"},s("div",{key:"7aa34eebe2ae77b54b4f49e8bbd8b2b8e98788c4",class:"filter-type-group"},s("slot",{key:"c15c59e88dc6462fea56654250c93505fe49b7fe",name:"filter-search"}),s("slot",{key:"51326a07a20be1806503635470077824d9b76369",name:"filter-accordion"})))}static get style(){return c()}},[769,"ifx-filter-type-group",{selectedOptions:[32]}]);function a(){if(typeof customElements==="undefined"){return}const e=["ifx-filter-type-group"];e.forEach((e=>{switch(e){case"ifx-filter-type-group":if(!customElements.get(r(e))){customElements.define(r(e),l)}break}}))}const o=l;const f=a;export{o as IfxFilterTypeGroup,f as defineCustomElement};
//# sourceMappingURL=ifx-filter-type-group.js.map