'use strict';

/**
 * Return the start date of the week in the broadcast calendar.
 *
 * @since 9.4.0
 */
function startOfBroadcastWeek(date, dateLib) {
    const firstOfMonth = dateLib.startOfMonth(date);
    const dayOfWeek = firstOfMonth.getDay();
    if (dayOfWeek === 1) {
        return firstOfMonth;
    }
    else if (dayOfWeek === 0) {
        return dateLib.addDays(firstOfMonth, -1 * 6);
    }
    else {
        return dateLib.addDays(firstOfMonth, -1 * (dayOfWeek - 1));
    }
}

exports.startOfBroadcastWeek = startOfBroadcastWeek;
//# sourceMappingURL=startOfBroadcastWeek.cjs.map
