"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNumericPlanLimit = getNumericPlanLimit;
exports.startOfCurrentMonth = startOfCurrentMonth;
exports.startOfCurrentWeek = startOfCurrentWeek;
function getNumericPlanLimit(limits, key) {
    if (!limits || typeof limits !== 'object' || Array.isArray(limits)) {
        return null;
    }
    const value = limits[key];
    if (value === null || value === undefined) {
        return null;
    }
    const numberValue = Number(value);
    return Number.isFinite(numberValue) ? numberValue : null;
}
function startOfCurrentMonth(now = new Date()) {
    return new Date(now.getFullYear(), now.getMonth(), 1);
}
function startOfCurrentWeek(now = new Date()) {
    const date = new Date(now);
    const day = date.getDay();
    const diff = date.getDate() - day + (day === 0 ? -6 : 1);
    return new Date(date.getFullYear(), date.getMonth(), diff);
}
//# sourceMappingURL=plan-limits.js.map