"use strict";function search(e,t){const{query:r,fields:s,fuzzy:l=!0,limit:n}=t;if(!r.trim())return void 0!==n?e.slice(0,n):e;const o=l?r.toLowerCase():r,u=e.filter(e=>s&&s.length>0?s.some(t=>{const r=getNestedValue(e,t);return null!=r&&matchesQuery(String(r),o,l)}):searchAllFields(e,o,l));return void 0!==n?u.slice(0,n):u}function getNestedValue(e,t){const r=t.split(".");let s=e;for(const e of r){if(null==s)return null;if("object"!=typeof s)return null;s=s[e]}return s}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)))}Object.defineProperty(exports,"__esModule",{value:!0}),exports.search=search;