import statisticGroupTwig from './paragraph.statistic-group.twig';
import statisticGroupData from './paragraph.statistic-group.yml';
import './paragraph.statistic-group.js';

import {statistic} from '@ui-paragraph/statistic/component/paragraph.statistic.stories.js';

import { setPublishedStatus } from '.storybook/utils';

/**
 * Storybook Definition.
 */
export default {
  title: 'Layout Components/Statistic Group',
};

export const statisticGroup = (args) => {
  // Create deep copy of data and merge args.
  let data = JSON.parse(JSON.stringify(statisticGroupData ?? {}));
  data = Object.assign(data, args);

  data.paragraph = setPublishedStatus(data.paragraph_is_published);

  return statisticGroupTwig({
    ...data,
    paragraph_field_erp_statistics: [
      statistic(),
      statistic({
        paragraph_field_stat_number: 100
      }),
      statistic({
        paragraph_field_stat_prefix: '',
        paragraph_field_stat_suffix: '',
        paragraph_field_stat_number: '8.2:3'
      }),
      statistic(),
    ].join('')
  });
}
statisticGroup.args = statisticGroupData;
