import{p as e,H as t,c as i,h as s,d as l,t as a}from"./p-Bpcl2TqF.js";import{d as r}from"./p-DtIGLtyC.js";import{d as n}from"./p-KvSIaMXJ.js";const o=()=>`:host{display:block;width:100%}.search-container{display:flex;width:calc(100% - 48px);padding-left:24px;padding-right:24px;flex-direction:row;align-items:flex-start;margin-bottom:16px}.components-container{display:flex;width:calc(100% - 48px);padding-left:24px;padding-right:24px;flex-direction:row;align-items:flex-end;align-content:flex-end;flex-wrap:wrap;gap:16px}.filter-slot-wrapper{flex-grow:1;flex-basis:100%;max-width:100%}@media (max-width: 1024px){.more-filters-wrapper{order:3;width:100%;display:flex;justify-content:center;padding-top:16px;}}@media (min-width: 720px) and (max-width: 1024px){.filter-slot-wrapper{flex-basis:calc((100% - 16px) / 2);max-width:calc((100% - 16px) / 2)}}@media (min-width: 1025px){.filter-slot-wrapper{flex-basis:auto;max-width:200px}::slotted([slot=filter-search]){max-width:828px}}::slotted([slot=filter-search]){flex-grow:1;flex-basis:100%;width:100%}`;const f=e(class e extends t{constructor(e){super();if(e!==false){this.__registerHost()}this.__attachShadow();this.ifxTopbarFilterChange=i(this,"ifxTopbarFilterChange",7)}get el(){return this}selectedOptions=[];ifxTopbarFilterChange;showAllFilters=false;maxShownFilters=4;visibleSlots;showMoreFiltersButton=true;connectedCallback(){this.el.addEventListener("ifxFilterSelect",this.handleTopbarFilterChange);this.el.addEventListener("ifxFilterSearchChange",this.handleSearchChange);window.addEventListener("ifxResetFiltersEvent",this.handleResetEvent)}disconnectedCallback(){this.el.removeEventListener("ifxFilterSelect",this.handleTopbarFilterChange);this.el.removeEventListener("ifxFilterSearchChange",this.handleSearchChange);window.removeEventListener("ifxResetFiltersEvent",this.handleResetEvent)}componentWillLoad(){this.updateVisibleSlots()}updateVisibleSlots(){this.visibleSlots=this.showAllFilters?Number.MAX_SAFE_INTEGER:this.maxShownFilters}handleMoreFiltersClick=()=>{this.showAllFilters=true;this.updateVisibleSlots()};handleResetEvent=()=>{const e=this.el.shadowRoot?.querySelector('slot[name="filter-search"]');if(e instanceof HTMLSlotElement){const t=e.assignedElements({flatten:true});t.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.ifxTopbarFilterChange.emit(this.selectedOptions)};handleSearchChange=e=>{this.handleTopbarFilterChange(e)};handleTopbarFilterChange=e=>{const t=[...this.selectedOptions];if(e.type==="ifxFilterSearchChange"){const{filterName:i,filterValue:s}=e.detail;const l=t.findIndex((e=>e.filterName===i));if(l!==-1){t[l].filterValues=[s]}else{t.push({filterName:i,filterValues:[s],type:"text"})}}else if(e.type==="ifxFilterSelect"){const{filterName:i,filterValues:s,type:l}=e.detail;const a=t.findIndex((e=>e.filterName===i));if(a!==-1){t[a].filterValues=s;t[a].type=l}else{t.push({filterName:i,filterValues:s,type:l})}}this.selectedOptions=t;this.ifxTopbarFilterChange.emit(this.selectedOptions)};render(){const e=Math.max(0,this.visibleSlots);const t=this.el.querySelectorAll("ifx-set-filter").length;const i=Math.min(e,t,Number.MAX_SAFE_INTEGER);const a=Array.from({length:i},((e,t)=>s("div",{class:"filter-slot-wrapper"},s("slot",{name:`filter-component-${t+1}`}))));return s(l,{key:"60f59cd921c6b9ef7e2c0940d9af4a831db25e3f"},s("div",{key:"180858e8ca59a4b59fc82e94da8469413af81d07",class:"search-container"},s("slot",{key:"0faf70261e9626dd292125b0c0ecde676f5a80c8",name:"filter-search"})," "),s("div",{key:"f257b7a6704b44b580357e7d552a2d3c8f9d033c",class:"components-container"},a.length>0?a:s("slot",{name:"filter-component"}),this.showMoreFiltersButton&&!this.showAllFilters&&s("div",{key:"ca9fbecb493ab564c4c0f807769869d80a0edd6c",class:"more-filters-wrapper",onClick:this.handleMoreFiltersClick},s("ifx-button",{key:"82945c7339ded3d56de43e32ad96ea65785a0bff",type:"button",disabled:false,variant:"tertiary",size:"m",target:"_blank",theme:"default","full-width":"false"},s("ifx-icon",{key:"06e16472e9093226f95ccae72566251e6b1d252d",icon:"filter-16"}),"More filters"))))}static get style(){return o()}},[769,"ifx-filter-bar",{maxShownFilters:[2,"max-shown-filters"],showMoreFiltersButton:[4,"show-more-filters-button"],selectedOptions:[32],showAllFilters:[32],visibleSlots:[32]}]);function c(){if(typeof customElements==="undefined"){return}const e=["ifx-filter-bar","ifx-button","ifx-icon"];e.forEach((e=>{switch(e){case"ifx-filter-bar":if(!customElements.get(a(e))){customElements.define(a(e),f)}break;case"ifx-button":if(!customElements.get(a(e))){r()}break;case"ifx-icon":if(!customElements.get(a(e))){n()}break}}))}const d=f;const h=c;export{d as IfxFilterBar,h as defineCustomElement};
//# sourceMappingURL=ifx-filter-bar.js.map