import React from 'react';
import PropTypes from 'prop-types';
import { Provider } from 'react-redux';
import headComponents from './src/head';
import { createStore } from './src/redux/createStore';
import layoutSelector from './utils/gatsby/layoutSelector';
const store = createStore();
export const wrapRootElement = ({ element }) => {
  return {element};
};
wrapRootElement.propTypes = {
  element: PropTypes.any
};
// TODO: put these in a common utils file.
const mathJaxCdn = {
  address:
    'https://cdnjs.cloudflare.com/ajax/libs/mathjax/' +
    '2.7.4/MathJax.js?config=TeX-AMS_HTML',
  id: 'mathjax',
  key: 'mathjax',
  type: 'text/javascript'
};
const stripeScript = {
  address: 'https://js.stripe.com/v3/',
  id: 'stripe-js',
  key: 'stripe-js',
  type: 'text/javascript'
};
const challengeRE = new RegExp('/learn/[^/]+/[^/]+/[^/]+/?$');
const donateRE = new RegExp('/donate/?$');
export const wrapPageElement = layoutSelector;
export const onRenderBody = ({
  pathname,
  setHeadComponents,
  setPostBodyComponents
}) => {
  setHeadComponents([...headComponents]);
  const scripts = [
    ,
    
  ];
  if (pathname.includes('/learn/coding-interview-prep/rosetta-code')) {
    scripts.push(
      
    );
  }
  if (challengeRE.test(pathname) || donateRE.test(pathname)) {
    scripts.push(
      
    );
  }
  setPostBodyComponents(scripts.filter(Boolean));
};