import{f as O,c as S}from"./CWHHmK0V.js";import{u as k}from"./Bpf-t_rp.js";import{g as b}from"./FcRkkR--.js";import{j as i,c as D,k as _,bp as U,d as $,u as F,a as B,o as V,f as T,w as J,C as j,W as R,e as h,M as W}from"./dVzHJMF1.js";import q from"./DP0doleY.js";import z from"./BAtzogEJ.js";const ne=({paginatedDataKey:c,asyncFn:s,size:y=20,optionValue:n,optionLabel:r,watch:u=()=>{},immediate:d=!0},x)=>{const p=U(),o=i([]),f=i(),m=i(),l=i(!1),v=i(!1),a=k(c,async e=>{var t;return await((t=s({...e,search:m.value??void 0}))==null?void 0:t.finally(()=>{l.value=!1,v.value=!1}))},{watch:[m],initialRows:y,immediate:d}),C=S(()=>{a.page.value=a.page.value+1},500),E=S(()=>{m.value=f.value,a.page.value=0},500),I=D(()=>a.status.value==="pending"||v.value||l.value);function L(e){const t=e.getElementsByClassName(x?"p-multiselect-list-container":"p-select-list-container")[0];t&&t.addEventListener("scroll",function(){t.scrollHeight-t.scrollTop>t.clientHeight+30||a.data.value.last||(v.value=!0,C())})}function N(){const e=document.getElementById(p);if(!e)return;const t=e.getElementsByClassName(x?"p-multiselect-list-container":"p-select-list-container")[0];t&&t.scrollTo(0,0)}function P(e,t){try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}}function H(e){return typeof n=="function"?n(e):b(n,e)}function M(e){return typeof r=="function"?r(e):b(r,e)}return O(document.body,e=>{var t;for(const g of e)if(!(g.target!==document.body||!((t=g.addedNodes)!=null&&t.length))){for(const w of g.addedNodes)if(w.id===p){L(w);break}}},{subtree:!1,childList:!0}),_(()=>a.data.value,()=>{const e=a.data.value.pageable.pageNumber===0?[]:[...o.value];o.value=[...e,...a.data.value.content]}),_(f,()=>{l.value=!0,N(),o.value=[],E()}),_(u,()=>{l.value=!0,a.page.value===0?a.execute():a.page.value=0,N(),o.value=[]}),{overlayId:p,search:f,searchLoading:l,optionsPaginated:a,listLoading:I,items:o,compareValues:P,getNestedValue:H,getNestedLabel:M}},A={class:"p-select-header"},G=$({__name:"_TemplateHeader",props:{modelValue:{},modelModifiers:{}},emits:["update:modelValue"],setup(c){const s=F(c,"modelValue");return(y,n)=>{const r=z,u=q;return V(),B("div",A,[T(u,null,{default:J(()=>[j(h("input",{"onUpdate:modelValue":n[0]||(n[0]=d=>s.value=d),class:"p-inputtext"},null,512),[[R,s.value]]),T(r,{class:"pi pi-search"})]),_:1})])}}}),re=Object.assign(G,{__name:"UiSelectServerTemplateHeader"}),K={},Q={class:"flex overflow-hidden text-ellipsis whitespace-nowrap items-center gap-2 py-1 px-3 text-sm border-t"};function X(c,s){return V(),B("div",Q,s[0]||(s[0]=[h("i",{class:"pi pi-spin pi-spinner"},null,-1),h("div",{class:"text-left"},"Buscando mais itens...",-1)]))}const oe=Object.assign(W(K,[["render",X]]),{__name:"UiSelectServerTemplateLoading"});export{re as T,ne as _,oe as a};
