import _ from 'lodash';
import types from 'pg-types';
export const mapToObject = (map) => _.fromPairs([...map.entries()]);
export const subpathsObject = (paths, field, getter, setter) => _.map(_.filter(paths, (path) => _.startsWith(getter(path), field + '.')), (path) => setter(path, _.replace(getter(path), field + '.', '')));
export const subpaths = (paths, field) => subpathsObject(paths, field, (a) => a, (_, newPath) => newPath);
export const firstOrderPaths = (paths, getter = (a) => a) => _(paths)
    .map(getter)
    .filter((v) => !v.includes('.'))
    .value();
export const firstOrderProperties = (o, removeNulls = true) => _.omitBy(o, (v) => _.isObject(v) || _.isArray(v) || (removeNulls && _.isNull(v)));
const OID_ARRAY_TEXT = 1009;
export const lucidColumnJSONArrayConsume = types.getTypeParser(OID_ARRAY_TEXT);
export const areSameDay = (date1, date2) => {
    const d1 = new Date(date1);
    const d2 = new Date(date2);
    const year1 = d1.getFullYear();
    const month1 = d1.getMonth();
    const day1 = d1.getDate();
    const year2 = d2.getFullYear();
    const month2 = d2.getMonth();
    const day2 = d2.getDate();
    return year1 === year2 && month1 === month2 && day1 === day2;
};
export const sanitizeFilename = (input) => input
    .normalize('NFD')
    .replace(/[\u0300-\u036f]/g, '')
    .replace(/[^A-Za-z0-9\-_\/!.\s]/g, '')
    .trim();
export const isFunction = (func) => {
    return !func.prototype || Object.getOwnPropertyNames(func.prototype).length == 1;
};
//# sourceMappingURL=utils.js.map