'use strict';function m(...n){for(let r in n)if(typeof n[r]=="boolean")return n[r];return  false}function f(n){return !!(n==null||typeof n=="undefined"||typeof n=="string"&&n===""||Array.isArray(n)&&!n.length)}function S(n){return !!(n&&typeof n=="string")}function y(n){return typeof n=="number"&&!isNaN(n)}function O(n,r,t={}){if(!Array.isArray(n))return [];if(n.length<=1)return n;t=Object.assign({},t),t.direction=S(t.direction)&&["asc","desc"].includes(t.direction)?t.direction:"asc",t.chunkSize=y(t.chunkSize)&&t.chunkSize>0?t.chunkSize:1e4,t.ignoreCase=m(t.ignoreCase,true);let{direction:e,chunkSize:i,ignoreCase:o}=t;return n.length>i?g(n,r,e,o):n.sort((s,c)=>T(r(s),r(c),e,o))}function g(n,r,t,e){if(n.length<=1)return n;let i=Math.floor(n.length/2),o=n.slice(0,i),s=n.slice(i);return b(g(o,r,t,e),g(s,r,t,e),r,t,e)}function T(n,r,t,e){var s,c;if(f(n)&&f(r))return 0;if(f(n)&&!f(r))return t==="asc"?-1:1;if(f(r)&&!f(n))return t==="asc"?1:-1;if(typeof n=="number"&&typeof r=="number")return t==="asc"?n-r:r-n;if(n instanceof Date&&r instanceof Date)return t==="asc"?n.getTime()-r.getTime():r.getTime()-n.getTime();n instanceof RegExp&&r instanceof RegExp&&(n=n.toString(),r=r.toString()),["boolean","number","string"].includes(typeof n)&&(n=String(n)),["boolean","number","string"].includes(typeof r)&&(r=String(r));let i=(s=n==null?void 0:n.toString())!=null?s:String(n),o=(c=r==null?void 0:r.toString())!=null?c:String(r);return e&&(i=i.toLowerCase(),o=o.toLowerCase()),u(i,o,t)}function u(n,r,t){if(!n&&r)return t==="asc"?-1:1;if(n&&!r)return t==="asc"?1:-1;if(!n&&!r)return 0;let e=n.localeCompare(r),i=e<0?-1:e>0?1:0;return t==="asc"?i:-i}function b(n,r,t,e,i){let o=[],s=0,c=0;for(;s<n.length&&c<r.length;)T(t(n[s]),t(r[c]),e,i)<=0?(o.push(n[s]),s++):(o.push(r[c]),c++);return o.concat(n.slice(s)).concat(r.slice(c))}exports.sortBy=O;