import imageTwig from './paragraph.image.twig';
import imageData from './paragraph.image.yml';
import './paragraph.image.js';

import imgTwig from '@ui-base/img/_img.twig';
import { setPublishedStatus } from '.storybook/utils';

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

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

  data.paragraph = setPublishedStatus(data.paragraph_is_published);

  return imageTwig({
    ...data,
    paragraph_field_erm_image: imgTwig({
      image_src: data.paragraph_field_erm_image
    }),
  });
};
image.args = imageData;
