export function search(e,t){const{query:r,fields:l,fuzzy:n=!0,limit:s}=t;if(!r.trim())return void 0!==s?e.slice(0,s):e;const o=n?r.toLowerCase():r,u=e.filter(e=>l&&l.length>0?l.some(t=>{const r=getNestedValue(e,t);return null!=r&&matchesQuery(String(r),o,n)}):searchAllFields(e,o,n));return void 0!==s?u.slice(0,s):u}function getNestedValue(e,t){const r=t.split(".");let l=e;for(const e of r){if(null==l)return null;if("object"!=typeof l)return null;l=l[e]}return l}function matchesQuery(e,t,r){return r?e.toLowerCase().includes(t):e.includes(t)}function searchAllFields(e,t,r){return null!=e&&("string"==typeof e?matchesQuery(e,t,r):"number"==typeof e||"boolean"==typeof e?matchesQuery(String(e),t,r):Array.isArray(e)?e.some(e=>searchAllFields(e,t,r)):"object"==typeof e&&Object.values(e).some(e=>searchAllFields(e,t,r)))}