"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.restrictFileMaxSize = void 0;
const constants_1 = require("./constants");
const restrictFileMaxSize = (formatSizeToView, maxSize) => (file) => {
    if (!file.size || !maxSize) {
        return undefined;
    }
    if (file.size > maxSize) {
        const maxSizeToView = formatSizeToView?.(maxSize);
        return {
            code: constants_1.FILE_MAX_SIZE_ERROR_INFO.code,
            message: constants_1.FILE_MAX_SIZE_ERROR_INFO.message(maxSizeToView),
        };
    }
    return undefined;
};
exports.restrictFileMaxSize = restrictFileMaxSize;
