import{r as e,c as t,a as i,h as s,d as r}from"./p-Cby2wKoI.js";const a=()=>`:host{display:flex}.filter-type-group{width:260px;align-items:flex-start;gap:8px}.filter-type-group>::slotted(*){margin-bottom:8px}`;const n=class{constructor(i){e(this,i);this.ifxSidebarFilterChange=t(this,"ifxSidebarFilterChange",7)}get el(){return i(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 r=this.el.shadowRoot.querySelector('slot[name="filter-search"]');const a=r?r.assignedNodes({flatten:true}):[];a.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 n=this.selectedOptions.map((e=>{if(e.filterGroupName===t){return{...e,selectedItems:[],value:""}}return e}));this.selectedOptions=n;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 r=t.findIndex((e=>typeof e!=="string"&&e.filterGroupName===i));if(r!==-1){t[r].value=s}else{t.push({filterGroupName:i,value:s})}}else if(e.type==="ifxFilterAccordionChange"){const{filterGroupName:i,selectedItems:s}=e.detail;const r=t.findIndex((e=>e.filterGroupName===i));if(r!==-1){t[r]={filterGroupName:i,selectedItems:s}}else{t.push({filterGroupName:i,selectedItems:s})}}this.selectedOptions=t;this.ifxSidebarFilterChange.emit(this.selectedOptions)};render(){return s(r,{key:"2bc6891c098e3d6393f3b31373a12c1ae02cdb25"},s("div",{key:"7aa34eebe2ae77b54b4f49e8bbd8b2b8e98788c4",class:"filter-type-group"},s("slot",{key:"c15c59e88dc6462fea56654250c93505fe49b7fe",name:"filter-search"}),s("slot",{key:"51326a07a20be1806503635470077824d9b76369",name:"filter-accordion"})))}};n.style=a();export{n as ifx_filter_type_group};
//# sourceMappingURL=p-3d294537.entry.js.map