text: const { getCLSDiff } = require('./get-diff');
  
  function getCLSDiffMessage({
    baseBranchMetrics,
    currentBranchMetrics,
    baseBranchName,
    currentBranchName,
  }) {
    const {
      currentTotalValue,
      previousTotalValue,
      totalValueDiff,
      presetsWithDiff,
    } = getCLSDiff(baseBranchMetrics, currentBranchMetrics);
  
    if (!totalValueDiff) {
      return `**Cumulative Layout Shift** total value is **${currentTotalValue}** and it has not changed between the branches.`;
    }
  
    const before = `${baseBranchName}: **${previousTotalValue}**`;
    const after = `${currentBranchName}: **${currentTotalValue}**`;
  
    let message = `**Cumulative Layout Shift** has changed (${before} ---> ${after}) for the following presets:`;
  
    presetsWithDiff.forEach(({ presetName, lang, valueBefore, valueAfter }) => {
      if (typeof valueBefore === 'undefined') {
        message += `\n* [NEW PRESET] ${presetName}/${lang}: **${valueAfter}**`;
        return;
      }
  
      message += `\n* ${presetName}/${lang}: **${valueBefore}** ---> **${valueAfter}**`;
    });
  
    return message;
  }
  
  module.exports = { getCLSDiffMessage };
  