1import{C as c}from"./app-BXezEdO3.js";var p=(o=>(o.CHANGE="filter-group:change",o))(p||{}),h=(o=>(o.CHANGE="filter-item:change",o))(h||{});class s extends c{static SELECTORS={select:"select",radio:'input[type="radio"]',checkbox:'input[type="checkbox"]',input:'input[type="text"]',option:".filter-item__option",showAll:".filter-item__option--show-all"};static CLASSES={optionHidden:"filter-item__option--hidden"};selects;radios;inputs;checkboxes;options;showAll;preventChangeDispatch=!1;parent;parentId;run(){this.bind(),this.setListeners()}reset(){this.preventChangeDispatch=!0,this.resetSelects(),this.resetRadiosAndCheckboxes(),this.resetInputs(),this.preventChangeDispatch=!1}resetSelects(){this.selects?.forEach(e=>{e.value=""})}resetRadiosAndCheckboxes(){[...this.radios||[],...this.checkboxes||[]].forEach(e=>{e.checked=!1})}resetInputs(){this.inputs?.forEach(e=>{e.value=""})}bind(){this.parent=this.element.dataset.parent||"",this.parentId=this.element.dataset.parentId||"",this.selects=Array.from(this.element.querySelectorAll(s.SELECTORS.select))||[],this.radios=Array.from(this.element.querySelectorAll(s.SELECTORS.radio))||[],this.checkboxes=Array.from(this.element.querySelectorAll(s.SELECTORS.checkbox))||[],this.inputs=Array.from(this.element.querySelectorAll(s.SELECTORS.input))||[],this.options=Array.from(this.element.querySelectorAll(s.SELECTORS.option))||[],this.showAll=this.element.querySelector(s.SELECTORS.showAll)}setListeners(){[...this.selects,...this.radios,...this.checkboxes].forEach(e=>{e.addEventListener("change",t=>{t.stopPropagation(),this.preventChangeDispatch||this.dispatch(h.CHANGE,{name:e.name,value:e.value,key:e.dataset.key})})}),this.radios.forEach(e=>{e.parentElement.querySelector("label")?.addEventListener("click",t=>{e.checked&&(t.preventDefault(),e.checked=!1,this.dispatch(h.CHANGE,{name:e.name,value:"",key:e.dataset.key}))})}),this.showAll?.addEventListener("click",()=>{this.options.forEach(e=>{const t=e.matches(s.SELECTORS.showAll);e.classList.toggle(s.CLASSES.optionHidden,t)})})}}class d extends c{static SELECTORS={item:".filter-item"};get key(){return this.element.dataset.key}itemElements=[];items=[];run(){this.bind(),this.setListeners()}bind(){this.itemElements=Array.from(this.element.querySelectorAll(d.SELECTORS.item)),this.items=this.itemElements.map(e=>{const t=new s(e);return e.app=e.app||{},e.app["filter-item"]=t,t.run(),t})}setListeners(){this.element.addEventListener(h.CHANGE,()=>{this.dispatch(p.CHANGE,{key:this.element.dataset.key})})}reset(){this.items.forEach(e=>e.reset())}}class r extends c{static SELECTORS={group:".filter-group",item:".filter-item",reset:".filter__reset",form:"form"};static CLASSES={resetOtherGroups:"filter--reset-other-groups"};resetButton;form;get resetOtherGroups(){return this.element.classList.contains(r.CLASSES.resetOtherGroups)}groupElements=[];groups=[];run(){this.bind(),this.setListeners(),this.initialCheckConditions()}bind(){this.resetButton=this.element.querySelector(r.SELECTORS.reset),this.form=this.element.querySelector(r.SELECTORS.form),this.groupElements=Array.from(this.element.querySelectorAll(r.SELECTORS.group)),this.groups=this.groupElements.map(e=>{const t=new d(e);return e.app=e.app||{},e.app["filter-group"]=t,t.run(),t})}
1setListeners(){this.element.addEventListener(p.CHANGE,this.onGroupChange.bind(this)),this.element.addEventListener(h.CHANGE,this.onItemChange.bind(this)),this.resetButton?.addEventListener("click",this.onResetClick.bind(this))}onGroupChange(e){this.groups.forEach(t=>{t.key!==e.detail.key&&this.resetOtherGroups&&t.reset()})}onItemChange(e){this.checkConditions(e.detail.key,e.detail.value)}initialCheckConditions(){Array.from(this.element.querySelectorAll("select")).forEach(n=>{this.checkConditions(n.dataset.key,n.value)}),Array.from(this.element.querySelectorAll('input[type="radio"], input[type="checkbox"]')).forEach(n=>{n.checked&&this.checkConditions(n.dataset.key,n.value)})}checkConditions(e,t){Array.from(this.element.querySelectorAll(`${r.SELECTORS.item}[data-parent], ${r.SELECTORS.item} option[data-parent]`)).forEach(i=>{const a=i.dataset.parent,l=a&&a===e;if(!l)return;const u=i.dataset.parentId,m=u&&u===t,E=!t&&i.dataset.hideOnAll!=="true"||l&&m;i.dataset.parentActive=E?"true":"false",!E&&i.tagName!=="OPTION"&&i.closest(".filter-item").app?.["filter-item"]?.reset()}),Array.from(this.element.querySelectorAll(`${r.SELECTORS.item} select:has(option[data-parent])`)).forEach(i=>{if(i.value){const a=i.querySelector("option:checked");if(a.dataset.parentActive===void 0)return;!a.dataset.parent||a.dataset.parentActive==="true"||a.closest(".filter-item").app?.["filter-item"]?.reset()}})}onResetClick(e){e.preventDefault(),e.stopPropagation(),this.groups.forEach(t=>t.reset()),this.form?.submit()}}export{r as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.