'use strict';

const index = require('./index-bb72bde3.js');
const Blockquote = require('./Blockquote-a4693032.js');
require('./IntersectionHelper-16aa1ea1.js');
const PrismicResponsiveImage = require('./PrismicResponsiveImage-0adc07dc.js');
const trackingService = require('./tracking-service-934c16ed.js');

const SliceNormalText = ({ slice }) => (index.h(PrismicResponsiveImage.PrismicRichText, { richText: slice.primary.content, htmlSerializer: PrismicResponsiveImage.htmlSerializer }));
const SliceRawHtml = ({ slice }) => (index.h("div", { class: "prismic-raw-html", innerHTML: slice.primary.html_content.map((c) => c.text).join('') }));
const SliceQuote = ({ slice }) => (index.h(Blockquote.Blockquote, null,
  index.h("div", null,
    index.h(PrismicResponsiveImage.PrismicRichText, { richText: slice.primary.quote })),
  slice.primary.name ? (index.h("cite", null,
    slice.primary.name,
    index.h("span", null, slice.primary.description))) : null));
const SliceFloatingImage = ({ slice }) => (index.h("figure", null,
  index.h("img", { loading: 'lazy', src: slice.primary.illustration.url, alt: slice.primary.illustration.alt })));
const SliceAd = ({ slice }) => {
  return (index.h("aside", { class: "prismic-ad" },
    index.h("a", { href: slice.primary.link.url, target: slice.primary.link.target, onClick: e => trackingService.trackClick(`${location.host}${location.pathname}`, e, 'Resource Center') },
      index.h(PrismicResponsiveImage.PrismicRichText, { richText: slice.primary.text }),
      index.h("img", { class: "prismic-ad__image", loading: 'lazy', alt: slice.primary.image.alt, height: parseInt(slice.primary.image.dimensions.height, 10) / 2, width: parseInt(slice.primary.image.dimensions.width, 10) / 2, src: slice.primary.image.url, srcset: `${slice.primary.image['1x'].url} 1x, ${slice.primary.image.url} 2x` }))));
};
const PrismicBodySlice = ({ slice, key }) => {
  switch (slice.slice_type) {
    case 'normal_text':
      return index.h(SliceNormalText, { slice: slice, key: key });
    case 'raw_html':
      return index.h(SliceRawHtml, { slice: slice, key: key });
    case 'quote':
      return index.h(SliceQuote, { slice: slice, key: key });
    case 'floating_image':
      return index.h(SliceFloatingImage, { slice: slice, key: key });
    case 'ad':
      return index.h(SliceAd, { slice: slice, key: key });
  }
  return null;
};

const PrismicContent = ({ content }) => content.map((c, i) => index.h(PrismicBodySlice, { slice: c, key: i }));

exports.PrismicBodySlice = PrismicBodySlice;
exports.PrismicContent = PrismicContent;
