import{_ as U}from"./CbtPaznW.js";import $ from"./Dc_YXEFz.js";import{_ as P,T,a as N}from"./DmwTwIPt.js";import V from"./DPeK_S5k.js";import{d as x,L as H,u as S,k as b,v as z,b as F,w as g,o as M,f as _,E as D,W as G,g as i,l as K,e as A,t as W,G as O,K as E}from"./JQJBiNWj.js";const R=x({__name:"PaginatedMulti",props:H({paginatedDataKey:{},asyncFn:{},placeholder:{default:"Selecione..."},filter:{type:Boolean,default:!0},size:{},name:{},watch:{},showClear:{type:Boolean},disabled:{type:Boolean},showToggleAll:{type:Boolean,default:!0},optionValue:{type:[String,Function],default:"value"},optionLabel:{type:[String,Function],default:"label"},immediate:{type:Boolean,default:!0},clearOnWatch:{type:Boolean},defaultOption:{},autoSelectFirst:{type:Boolean},classInput:{},modelValue:{},defaultValue:{},options:{},optionDisabled:{},optionGroupLabel:{},optionGroupChildren:{},scrollHeight:{},filterPlaceholder:{},filterLocale:{},filterMatchMode:{},filterFields:{},editable:{type:Boolean},invalid:{type:Boolean},variant:{},dataKey:{},fluid:{type:Boolean},inputId:{},inputStyle:{},inputClass:{},labelId:{},labelStyle:{},labelClass:{},panelStyle:{},panelClass:{},overlayStyle:{},overlayClass:{},appendTo:{},loading:{type:Boolean},clearIcon:{},dropdownIcon:{},filterIcon:{},loadingIcon:{},resetFilterOnHide:{type:Boolean},resetFilterOnClear:{type:Boolean},virtualScrollerOptions:{},autoOptionFocus:{type:Boolean},autoFilterFocus:{type:Boolean},selectOnFocus:{type:Boolean},focusOnHover:{type:Boolean},highlightOnSelect:{type:Boolean},checkmark:{type:Boolean},filterMessage:{},selectionMessage:{},emptySelectionMessage:{},emptyFilterMessage:{},emptyMessage:{},tabindex:{},ariaLabel:{},ariaLabelledby:{},formControl:{},dt:{},pt:{},ptOptions:{},unstyled:{type:Boolean}},{modelValue:{},modelModifiers:{},object:{},objectModifiers:{}}),emits:["update:modelValue","update:object"],setup(y){const r=y,{items:m,overlayId:C,search:h,searchLoading:L,optionsPaginated:k,listLoading:f,compareValues:c,getNestedValue:d,getNestedLabel:I}=P(r,!0),a=S(y,"modelValue"),n=S(y,"object"),j=e=>{var t,o;const l=a.value||e;if(!(l!=null&&l.length))return r.placeholder;if(l.length>1)return`${l.length} itens selecionados`;if(!((t=n.value)!=null&&t.length))return"Um item selecionado";if((o=n.value)!=null&&o[0])return I(n.value[0])??"Um item selecionado"};return b(a,e=>{var l,t;if(!(e!=null&&e.length)){n.value=void 0;return}if(!((l=n.value)!=null&&l.length)){n.value=m.value.filter(o=>e.some(s=>c(d(o),s)));return}if(!c(e,n.value.map(o=>d(o)))){const o=(t=a.value)==null?void 0:t.map(s=>m.value.find(u=>c(d(u),s))).filter(s=>s);n.value=o}}),b(n,e=>{var l;if(e!=null&&e.length&&!e.some(t=>{const o=d(t);return o==null})){if(!((l=a.value)!=null&&l.length)){a.value=e.map(t=>d(t));return}c(a.value,e.map(t=>d(t)))||(a.value=e.map(t=>d(t)))}}),b(m,e=>{var l,t,o;if(!(!((l=a.value)!=null&&l.length)||!(e!=null&&e.length))&&(!((t=n.value)!=null&&t.length)||!c(n.value.map(s=>d(s)),a.value))){const s=(o=a.value)==null?void 0:o.map(u=>e.find(v=>c(d(v),u))).filter(u=>u);n.value=s.length?s:void 0}},{immediate:!0}),z(()=>{a.value||!n.value||(a.value=n.value.map(e=>d(e)))}),(e,l)=>{const t=U,o=$;return M(),F(o,{name:e.name},{default:g(s=>{var u,v,B;return[_(i(V),{modelValue:a.value,"onUpdate:modelValue":l[1]||(l[1]=p=>a.value=p),options:i(m),"option-label":r.optionLabel,"option-value":r.optionValue,loading:i(f),placeholder:i(f)?"Buscando...":e.placeholder,pt:{overlay:{id:i(C)}},"overlay-class":`${i(f)&&"page-loading"} ${i(L)&&e.$style.hide_container} ${e.$style.multi_select}`,"virtual-scroller-options":i(m).length>100?{itemSize:38}:void 0,"show-toggle-all":r.showToggleAll===!1?!1:((B=(v=(u=i(k))==null?void 0:u.data)==null?void 0:v.value)==null?void 0:B.last)||!1,"max-selected-labels":1,name:r.name,"show-clear":r.showClear,disabled:r.disabled,class:O(r.classInput)},G({value:g(({value:p})=>[A("span",{class:O(p&&"p-select-label")},W(j(p)),3)]),_:2},[r.filter?{name:"header",fn:g(()=>[_(T,{modelValue:i(h),"onUpdate:modelValue":l[0]||(l[0]=p=>K(h)?h.value=p:null)},null,8,["modelValue"])]),key:"0"}:void 0,i(f)?{name:"footer",fn:g(()=>[_(N)]),key:"1"}:void 0]),1032,["modelValue","options","option-label","option-value","loading","placeholder","pt","overlay-class","virtual-scroller-options","show-toggle-all","name","show-clear","disabled","class"]),s.props?(M(),F(t,{key:0,modelValue:a.value,"onUpdate:modelValue":l[2]||(l[2]=p=>a.value=p),field:s},null,8,["modelValue","field"])):D("",!0)]}),_:1},8,["name"])}}}),q="_hide_container_1klla_2",J="_multi_select_1klla_8",Q={hide_container:q,multi_select:J},X={$style:Q},te=Object.assign(E(R,[["__cssModules",X]]),{__name:"UiSelectServerPaginatedMulti"});export{te as _};
