"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.calculateSalePrice = exports.slugify = exports.toProductDetail = exports.toProductListItem = void 0;
const toProductListItem = (row) => ({
    ...row.product,
    brand: row.brand,
    productType: row.productType,
    collection: row.collection,
    frameShape: row.frameShape,
    frameColor: row.frameColor,
    ageGroup: row.ageGroup,
    size: row.size,
    primaryMedia: row.primaryMedia,
    media: row.media,
});
exports.toProductListItem = toProductListItem;
const toProductDetail = (row, relations) => ({
    ...(0, exports.toProductListItem)(row),
    ...relations,
});
exports.toProductDetail = toProductDetail;
const slugify = (value) => {
    return value
        .toLowerCase()
        .trim()
        .replace(/[^a-z0-9]+/g, "-")
        .replace(/^-+|-+$/g, "")
        .slice(0, 260);
};
exports.slugify = slugify;
const calculateSalePrice = (basePrice, discountPercent) => {
    return Math.max(0, Math.round(basePrice - (basePrice * discountPercent) / 100));
};
exports.calculateSalePrice = calculateSalePrice;
//# sourceMappingURL=productSerializers.js.map