'use strict';

var Template = require('dw/util/Template');
var HashMap = require('dw/util/HashMap');
var ImageTransformation = require('*/cartridge/experience/utilities/ImageTransformation.js');


/**
 * Render logic for storefront.imageAndText component.
 * @param {dw.experience.ComponentScriptContext} context The Component script context object.
 * @param {dw.util.Map} [modelIn] Additional model values created by another cartridge. This will not be passed in by Commcerce Cloud Plattform.
 *
 * @returns {string} The markup to be displayed
 */
module.exports.render = function (context, modelIn) {
    var model = modelIn || new HashMap();
    var content = context.content;

    model.heading = content.heading ? content.heading : null;
    model.ITCText = content.ITCText ? content.ITCText : null;
    model.image = content.image ? ImageTransformation.getScaledImage(content.image) : null;
    model.link = content.ITCLink ? content.ITCLink : '#';
    model.alt = content.alt ? content.alt : null;

    return new Template('experience/components/commerce_assets/productListTile').render(model).text;
};
