import{u as F}from"./useOrderFormDropdown-BujpLpDg.js";import{t as N}from"./widget-BUAABBRb.js";import{u as M}from"./translationsStore-DBJu9sBR.js";import{a as A,C as L,k as O,b as w,o as W,m as u,g as i,p as l,u as o,q as p,F as y,H as x,L as q,D as v}from"./convert-case-to-camel-case.utils-DDUpNI96.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";const E={class:"ccb-dropdown multi-select"},H={key:0,class:"anchor ccb-heading-5 ccb-light-3 ccb-selected"},P=["onClick"],R={key:1,class:"anchor ccb-heading-5 ccb-light ccb-selected"},$={key:2,class:"anchor ccb-heading-5 ccb-light-3"},j={class:"ccb-order-dropdown__list"},z={class:"ccb-default-checkbox"},G=["for"],J=["id","name","checked","value","onChange"],K={class:"ccb-checkbox-label"},te=A({__name:"MultiSelectDropDown",props:{field:{}},emits:["toggle"],setup(V,{emit:C}){const T=C,_=V,{field:e}=L(_),b=O(null),{toggleBody:m}=F(_,T,b),g=M(),S=n=>{var r;const s=((r=e.value.selectedIdx)==null?void 0:r.filter(t=>t!==n))||[];e.value.selectedIdx=s},a=w(()=>e.value.selectedIdx||[]),D=n=>{var h,f,k;let s=e.value.selectedIdx||[];a.value.includes(n)?s=((h=e.value.selectedIdx)==null?void 0:h.filter(d=>d!==n))||[]:s.push(n);let r=[];const t=((k=(f=e.value)==null?void 0:f.attributes)==null?void 0:k.options)||[];for(let d=0;d<t.length;d++){const B=t[d];s.includes(d)&&r.push(B.optionText||"")}const{updateValue:c}=N();e.value.value=r,c(e.value.id,e.value.value,s)},I=w(()=>Math.random().toString(36).substring(2,15));return W(()=>{var n;Array.isArray((n=e.value)==null?void 0:n.value)&&(e.value.value=e.value.value[0])}),(n,s)=>{var r;return i(),u("div",{class:"ccb-field__input-wrapper",ref_key:"dropdownWrapper",ref:b},[l("div",E,[l("div",{class:"ccb-order-dropdown__input",onClick:s[0]||(s[0]=(...t)=>o(m)&&o(m)(...t))},[s[1]||(s[1]=l("i",{class:"ccb-icon-Path-3485 ccb-select-arrow"},null,-1)),o(e).attributes&&o(e).attributes.options&&a.value.length>0?(i(),u("span",H,[a.value.length&&a.value.length<3?(i(!0),u(y,{key:0},x(a.value,(t,c)=>(i(),u("span",{class:"selected",key:c},[q(v(o(e).attributes.options[t].optionText)+" ",1),l("i",{class:"ccb-icon-close",onClick:h=>S(t)},null,8,P)]))),128)):p("",!0)])):p("",!0),a.value.length>=3?(i(),u("span",R,v(a.value.length)+" "+v(o(g).getTranslations.optionsSelected),1)):p("",!0),a.value.length===0?(i(),u("span",$,v(o(g).getTranslations.selectValues),1)):p("",!0)]),l("div",j,[l("ul",null,[(r=o(e).attributes)!=null&&r.options?(i(!0),u(y,{key:0},x(o(e).attributes.options,(t,c)=>(i(),u("li",{key:c},[l("div",z,[l("label",{for:o(e).id+"order_dropdown_checkbox_"+c},[l("input",{type:"checkbox",id:o(e).id+"order_dropdown_checkbox_"+c,name:I.value,checked:a.value.includes(c),value:t.optionText,onChange:()=>D(c)},null,40,J),l("span",K,v(t.optionText),1)],8,G)])]))),128)):p("",!0)])])])],512)}}});export{te as default};
//# sourceMappingURL=MultiSelectDropDown-B6Q_6VE_.js.map
