import{w as u,T as J}from"./vendor-vue-runtime-dom-B2rky8vu.js";import{A as K,_}from"./settings.consts-BmuAyinH.js";import{u as P}from"./admin-8MB3iCV_.js";import{d as Q,e as r,w as U,f as o,i as a,F as p,t as m,x as n,j as f,k as W,r as V,m as X}from"./vendor-vue-runtime-core-DwK6Ry68.js";import{t as Y,r as T,u as v}from"./vendor-vue-reactivity-CheHbvBM.js";import{a as g,t as B}from"./vendor-vue-shared-DrzsEcag.js";const Z={key:0,class:"ccb-total-multiselect__required"},ee={key:0},te={class:"ccb-total-multiselect-chip__text"},le=["onClick"],se=["checked","onChange"],ae={class:"ccb-total-multiselect-option__box"},oe={key:0,class:"ccb-total-multiselect-option__checkmark"},ne={class:"ccb-total-multiselect-option__label"},pe=Q({__name:"MultiSelect",props:{modelValue:{},label:{},items:{},name:{},required:{type:Boolean},placeholder:{},className:{},maxItemsShown:{}},emits:["update:modelValue","change"],setup(A,{emit:I}){const M=A,h=I,{items:d,modelValue:N,label:w,required:$,placeholder:z,name:q,className:D,maxItemsShown:x}=Y(M),F=P(),c=T(!1),l=T([]),L=r(()=>typeof x.value>"u"?(d.value||[]).length:x.value),O=r(()=>(d.value||[]).map(t=>({label:t.title||t.label||"",value:t.alias||t.value}))),b=t=>K(t,F.getTranslations),j=r(()=>b(w.value||"")),y=t=>t.alias||t.value,E=r(()=>`${l.value.length} ${b("option(s) selected")}`),R=r(()=>{const t=new Set(l.value);return(d.value||[]).filter(e=>t.has(y(e)))}),C=()=>{h("update:modelValue",[...l.value]),h("change",q.value||"",[...l.value])},G=t=>{l.value=l.value.filter(e=>String(e)!==String(t)),C()},S=()=>{c.value=!c.value},k=t=>l.value.some(e=>e===t),H=(t,e)=>{t.target.checked?k(e)||(l.value=[...l.value,e]):l.value=l.value.filter(i=>i!==e),C()};return U(()=>N.value,t=>{const e=Array.isArray(t)?t:[],s=new Set((d.value||[]).map(i=>i.alias||i.value));l.value=e.filter(i=>s.has(i))},{immediate:!0,deep:!0}),(t,e)=>(a(),o(p,null,[c.value?(a(),o("div",{key:0,class:"multiselect-overlay",onClick:e[0]||(e[0]=s=>c.value=!1)})):m("",!0),n("div",{class:g(["ccb-total-multiselect",{[v(D)||""]:!0,"ccb-multiselect-active":c.value}])},[v(w)?(a(),o("div",{key:0,class:"ccb-total-multiselect__label",onClick:S},[f(_,{text:j.value,size:"s",weight:"regular"},null,8,["text"]),v($)?(a(),o("span",Z,"*")):m("",!0)])):m("",!0),n("div",{class:"ccb-total-multiselect-input",onClick:S},[n("div",{class:g(["ccb-total-multiselect-input__chips",{"is-empty":l.value.length===0}])},[l.value.length?(a(),o(p,{key:0},[l.value.length>L.value?(a(),o("div",ee,[f(_,{text:E.value,size:"m",weight:"medium"},null,8,["text"])])):(a(!0),o(p,{key:1},V(R.value,s=>(a(),o("div",{key:s.alias,class:"ccb-total-multiselect-chip",onClick:e[1]||(e[1]=u(()=>{},["stop"]))},[e[8]||(e[8]=n("i",{class:"ccb-icon-ic_calculator"},null,-1)),n("span",te,B(s.title||s.label||""),1),n("button",{type:"button",class:"ccb-total-multiselect-chip__remove",onClick:i=>G(y(s))}," × ",8,le)]))),128))],64)):(a(),W(_,{key:1,text:v(z)||"",size:"m",weight:"medium"},null,8,["text"]))],2),n("span",{class:g(["ccb-total-multiselect-input__icon",{"is-open":c.value}])},e[9]||(e[9]=[n("i",{class:"ccb-icon-ic_caret_down"},null,-1)]),2),f(J,{name:"dropdown"},{default:X(()=>[c.value?(a(),o("div",{key:0,class:"ccb-total-multiselect-options",onClick:e[6]||(e[6]=u(()=>{},["stop"])),onMousedown:e[7]||(e[7]=u(()=>{},["stop"]))},[n("div",{class:"ccb-total-multiselect-options__list",onClick:e[4]||(e[4]=u(()=>{},["stop"])),onMousedown:e[5]||(e[5]=u(()=>{},["stop"]))},[(a(!0),o(p,null,V(O.value,s=>(a(),o("label",{key:String(s.value),class:"ccb-total-multiselect-option",onClick:e[2]||(e[2]=u(()=>{},["stop"])),onMousedown:e[3]||(e[3]=u(()=>{},["stop"]))},[n("input",{type:"checkbox",class:"ccb-total-multiselect-option__input",checked:k(s.value),onChange:i=>H(i,s.value)},null,40,se),n("span",ae,[k(s.value)?(a(),o("span",oe)):m("",!0)]),n("span",ne,B(b(s.label)),1)],32))),128))],32)],32)):m("",!0)]),_:1})])],2)],64))}});export{pe as _};
//# sourceMappingURL=MultiSelect.vue_vue_type_script_setup_true_lang-DYhaIBB7.js.map
