import{p as e,H as t,c as i,h as s,d as a,t as l}from"./p-CHfEnK-2.js";const r=e(class extends t{constructor(e){super(),!1!==e&&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=()=>{this.el.shadowRoot.querySelector('slot[name="filter-accordion"]').assignedElements({flatten:!0}).forEach((e=>{e.querySelectorAll("ifx-list").forEach((e=>{e.resetTrigger=!e.resetTrigger}))})),this.el.shadowRoot.querySelector('slot[name="filter-search"]').assignedElements({flatten:!0}).forEach((e=>{const t=e.querySelector("ifx-filter-search").shadowRoot.querySelectorAll("ifx-search-field");t.length>0&&t.forEach((e=>{e.value=""}))})),this.selectedOptions=[],this.ifxSidebarFilterChange.emit(this.selectedOptions)};handleUpdateSidebarFilter=e=>{const{filterName:t}=e.detail,i=this.el.shadowRoot.querySelector('slot[name="filter-accordion"]');(i?i.assignedElements({flatten:!0}):[]).forEach((e=>{e.querySelectorAll("ifx-list").forEach((e=>{e.getAttribute("name")===t&&(e.resetTrigger=!e.resetTrigger)}))}));const s=this.el.shadowRoot.querySelector('slot[name="filter-search"]');(s?s.assignedNodes({flatten:!0}):[]).forEach((e=>{if(e.nodeType===Node.ELEMENT_NODE){const t=e.firstElementChild;t&&(t.setAttribute("value",""),t.dispatchEvent(new CustomEvent("ifxInput",{bubbles:!0,composed:!0,detail:""})))}}));const a=this.selectedOptions.map((e=>e.filterGroupName===t?{...e,selectedItems:[],value:""}:e));this.selectedOptions=a,this.ifxSidebarFilterChange.emit(this.selectedOptions)};handleAccordionChange=e=>{this.handleFilterChange(e)};handleSearchChange=e=>{this.handleFilterChange(e)};handleFilterChange=e=>{const t=[...this.selectedOptions];if("ifxFilterSearchChange"===e.type){const{filterName:i,filterValue:s}=e.detail,a=t.findIndex((e=>"string"!=typeof e&&e.filterGroupName===i));-1!==a?t[a].value=s:t.push({filterGroupName:i,value:s})}else if("ifxFilterAccordionChange"===e.type){const{filterGroupName:i,selectedItems:s}=e.detail,a=t.findIndex((e=>e.filterGroupName===i));-1!==a?t[a]={filterGroupName:i,selectedItems:s}:t.push({filterGroupName:i,selectedItems:s})}this.selectedOptions=t,this.ifxSidebarFilterChange.emit(this.selectedOptions)};render(){return s(a,{key:"101b341d3c60308691854e4eeed4cd7775ba104f"},s("div",{key:"bd77404a291dbb22bc236ece38c01fecf70c9c72",class:"filter-type-group"},s("slot",{key:"a266368ec138213da5c4625af5da04a55c837062",name:"filter-search"}),s("slot",{key:"462778fc06cefa2bc534893f295ccb3e226336c2",name:"filter-accordion"})))}static get style(){return":host{display:flex}.filter-type-group{width:260px;align-items:flex-start;gap:8px}.filter-type-group>::slotted(*){margin-bottom:8px}"}},[769,"ifx-filter-type-group",{selectedOptions:[32]}]),n=r,c=function(){"undefined"!=typeof customElements&&["ifx-filter-type-group"].forEach((e=>{"ifx-filter-type-group"===e&&(customElements.get(l(e))||customElements.define(l(e),r))}))};export{n as IfxFilterTypeGroup,c as defineCustomElement}