import { h } from './index-0861cb0b.js';
import { B as Blockquote } from './Blockquote-43e585d2.js';
import './IntersectionHelper-215713b2.js';
import { h as htmlSerializer, P as PrismicRichText } from './PrismicResponsiveImage-4bbd855d.js';
import { t as trackClick } from './tracking-service-bdb1e857.js';

const SliceNormalText = ({ slice }) => (h(PrismicRichText, { richText: slice.primary.content, htmlSerializer: htmlSerializer }));
const SliceRawHtml = ({ slice }) => (h("div", { class: "prismic-raw-html", innerHTML: slice.primary.html_content.map((c) => c.text).join('') }));
const SliceQuote = ({ slice }) => (h(Blockquote, null,
  h("div", null,
    h(PrismicRichText, { richText: slice.primary.quote })),
  slice.primary.name ? (h("cite", null,
    slice.primary.name,
    h("span", null, slice.primary.description))) : null));
const SliceFloatingImage = ({ slice }) => {
  // console.log(slice);
  return (h("figure", { class: `prismic-floating-image ${slice.primary.side.toLowerCase()}` },
    h("img", { loading: 'lazy', src: slice.primary.illustration.url, alt: slice.primary.illustration.alt }),
    slice.primary.caption.length != 0 ?
      h("figcaption", null, slice.primary.caption[0].text) : ''));
};
const SliceAd = ({ slice }) => {
  return (h("aside", { class: "prismic-ad" },
    h("a", { href: slice.primary.link.url, target: slice.primary.link.target, onClick: e => trackClick(`${location.host}${location.pathname}`, e, 'Resource Center') },
      h(PrismicRichText, { richText: slice.primary.text }),
      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 SliceYoutube = ({ slice }) => {
  // console.log('in youtube', slice);
  return (h("div", { class: 'prismic-youtube-container' },
    h("iframe", { src: `https://www.youtube.com/embed/${slice.primary.vid}`, frameborder: '0', allowFullScreen: true })));
};
const PrismicBodySlice = ({ slice, key }) => {
  console.log(slice);
  switch (slice.slice_type) {
    case 'normal_text':
      return h(SliceNormalText, { slice: slice, key: key });
    case 'raw_html':
      return h(SliceRawHtml, { slice: slice, key: key });
    case 'quote':
      return h(SliceQuote, { slice: slice, key: key });
    case 'floating_image':
      return h(SliceFloatingImage, { slice: slice, key: key });
    case 'ad':
      return h(SliceAd, { slice: slice, key: key });
    case 'youtube':
      return h(SliceYoutube, { slice: slice, key: key });
  }
  return null;
};

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

export { PrismicContent as P, PrismicBodySlice as a };
