import statisticTwig from './paragraph.statistic.twig';
import statisticData from './paragraph.statistic.yml';
import './paragraph.statistic.js';

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

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

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

  data.paragraph = setPublishedStatus(data.paragraph_is_published);

  return `
    <script>Drupal.behaviors.statistic.attach(document);</script>
    ${statisticTwig({
      ...data,
    })}`;
}
statistic.args = statisticData;
