import{$ as c}from"./iframe-DSGyX7_4.js";import{c as o}from"./FormElementComponent-C16iBOay.js";import{c as p}from"./helpers-DDTkKuvc.js";class a{constructor(e){this.wrapper=e.addClass("initiated"),this.label=e.find("label.acc"),this.toggle=this.label.find("a"),this.checkbox=this.label.prev('input[type="checkbox"]'),this.subs=e.find(".checkbox-wrapper"),this.initToggle(),this.initChangeListener()}initChangeListener(){this.checkbox.on("change",e=>{const t=c(e.currentTarget).removeClass("half-checked").prop("checked");this.subs.find('input[type="checkbox"]').prop("checked",t)}),this.subs.find('input[type="checkbox"]').on("change",()=>{this.checkSelection()}),this.checkSelection()}initToggle(){this.toggle.on("click",e=>{e.preventDefault(),e.stopPropagation(),this.label.toggleClass("open"),this.subs.stop().slideToggle(300,"swing")})}checkSelection(){const e=this.subs.find('input[type="checkbox"]:checked').length,t=this.subs.find('input[type="checkbox"]:not(:checked)').length;e===0?this.checkbox.prop("checked",!1).removeClass("half-checked"):t===0?this.checkbox.prop("checked",!0).removeClass("half-checked"):this.checkbox.prop("checked",!1).addClass("half-checked")}}c("body").on("ihk-init dynamic-component-loaded gfi-dynamic-init",function(){c(".checkbox-group:not(.initiated)").each(()=>{new a(c(this))})});const u=({wrapperClass:s="ev-filter-wrapper",title:e="Branchen",items:t=["Dienstleistungen","Handel","Industrie","Verkehr"],namespace:n="branchen"})=>{const i=o({inputType:"checkbox",label:'<a role="button" href="#">'+e+"</a>",wrapperClasses:"checkbox-group "+s,name:n}),h=p("div",["ev-filter","checkbox-wrapper"],null,i);return h.ariaHidden=!0,i.querySelector("label").classList.add("acc"),t.map((l,r)=>{h.appendChild(o({inputType:"checkbox",label:l,name:n,id:n+"-"+r}))}),c(document).ready(()=>{new a(c(i))}),i};export{u as c};
