import{dG as S,dY as v,cO as x,cX as m,e4 as C,e5 as I,e6 as A,cU as k,du as _,cV as $}from"./BC4hLSsA.js";const B=(t,l,e)=>{if(t==null||l==null)return-1;if(!l.length)return 0;t=t.toString().toLocaleLowerCase(),l=l.toString().toLocaleLowerCase();const r=[];let n=t.indexOf(l);for(;~n;)r.push([n,n+l.length]),n=t.indexOf(l,n+l.length);return r.length?r:-1};function w(t,l){if(!(t==null||typeof t=="boolean"||t===-1))return typeof t=="number"?[[t,t+l.length]]:Array.isArray(t[0])?t:[t]}const R=S({customFilter:Function,customKeyFilter:Object,filterKeys:[Array,String],filterMode:{type:String,default:"intersection"},noFilter:Boolean},"filter");function E(t,l,e){var c;const r=[],n=(e==null?void 0:e.default)??B,i=e!=null&&e.filterKeys?I(e.filterKeys):!1,a=Object.keys((e==null?void 0:e.customKeyFilter)??{}).length;if(!(t!=null&&t.length))return r;let u=null;e:for(let d=0;d0)&&!(e!=null&&e.noFilter)){let K=!1;if(typeof f=="object"){if(f.type==="divider"||f.type==="subheader"){(u==null?void 0:u.type)==="divider"&&f.type==="subheader"&&r.push(u),u={index:d,matches:{},type:f.type};continue}const L=i||Object.keys(M);K=L.length===a;for(const b of L){const j=A(M,b),O=(c=e==null?void 0:e.customKeyFilter)==null?void 0:c[b];if(s=O?O(j,l,f):n(j,l,f),s!==-1&&s!==!1)O?h[b]=w(s,l):g[b]=w(s,l);else if((e==null?void 0:e.filterMode)==="every")continue e}}else s=n(f,l,f),s!==-1&&s!==!1&&(g.title=w(s,l));const F=Object.keys(g).length,y=Object.keys(h).length;if(!F&&!y||(e==null?void 0:e.filterMode)==="union"&&y!==a&&!F||(e==null?void 0:e.filterMode)==="intersection"&&(y!==a||!F&&a>0&&!K))continue}u&&(r.push(u),u=null),r.push({index:d,matches:{...g,...h}})}return r}function V(t,l,e,r){const n=v([]),i=v(new Map),a=x(()=>r!=null&&r.transform?m(l).map(c=>[c,r.transform(c)]):m(l));C(()=>{const c=typeof e=="function"?e():m(e),d=typeof c!="string"&&typeof c!="number"?"":String(c),f=E(a.value,d,{customKeyFilter:{...t.customKeyFilter,...m(r==null?void 0:r.customKeyFilter)},default:t.customFilter,filterKeys:t.filterKeys,filterMode:t.filterMode,noFilter:t.noFilter}),M=m(l),h=[],g=new Map;f.forEach(s=>{let{index:K,matches:F}=s;const y=M[K];h.push(y),g.set(y.value,F)}),n.value=h,i.value=g});function u(c){return i.value.get(c.value)}return{filteredItems:n,filteredMatches:i,getMatches:u}}function z(t,l,e){return e==null||!e.length?l:e.map((r,n)=>{const i=n===0?0:e[n-1][1],a=[k("span",{class:_(`${t}__unmask`)},[l.slice(i,r[0])]),k("span",{class:_(`${t}__mask`)},[l.slice(r[0],r[1])])];return n===e.length-1&&a.push(k("span",{class:_(`${t}__unmask`)},[l.slice(r[1])])),k($,null,[a])})}export{z as h,R as m,V as u};