'use strict';

/* eslint-disable no-unused-vars */
/* eslint-disable no-undef */

import * as React from 'react';
import ReactDOM from 'react-dom';
import CookieConsent from 'react-cookie-consent'

const e = React.createElement;

function Consent() {
  let domain = 'localhost';
  let hostname = window.location.hostname.split('.');
  switch (hostname.length) {
    case 1:
      domain = 'localhost';
      break;
    case 2:
    case 3:
      domain = '.datacite.org';
      break;
    case 4:
      domain = '.stage.datacite.org';
  }

  const cookieStyle = { fontSize: '16px', height: '95px', flexWrap: 'nowrap !important' }
  const linkStyle = { color: '#fecd23' }
  const myContentStyle = {}

  return (
    <CookieConsent
      style={cookieStyle}
      location="bottom"
      buttonText="Accept"
      declineButtonText="Reject"
      sameSite="strict"
      cookieName="_consent"
      extraCookieOptions={{ domain: domain }}
      overlay={true}
      enableDeclineButton
      buttonWrapperClasses="MY_BUTTON_WRAPPER_CLASS"
      containerClasses="CookieConsent MY_CONTAINER_CLASS"
      contentClasses="MY_CONTENT_CLASS"
      contentStyle={myContentStyle}
      declineButtonClasses="MY_DECLINE_BUTTON_CLASS"
    >
      We use cookies on our website. Some are technically necessary, others help
      us improve your user experience. You can decline non-essential cookies by
      selecting “Reject”. Please see our{' '}
      <a
        href="https://datacite.org/privacy.html"
        style={linkStyle}
        target="_blank"
        rel="noreferrer"
      >
        Privacy Policy
      </a>{' '}
      for further information about our privacy practices and use of cookies.{' '}
    </CookieConsent>
  )
}

const domContainer = document.querySelector('#consent');
ReactDOM.render(e(Consent), domContainer);

@@ -1,9 +1,9 @@
-'
+%22
 use stri
@@ -4,17 +4,17 @@
 e strict
-'
+%22
 ;%0A%0A/* es
@@ -102,15 +102,15 @@
 rom 
-'
+%22
 react
-'
+%22
 ;%0Aim
@@ -124,25 +124,25 @@
 actDOM from 
-'
+%22
 react-dom';%0A
@@ -138,17 +138,17 @@
 eact-dom
-'
+%22
 ;%0Aimport
@@ -167,17 +167,17 @@
 nt from 
-'
+%22
 react-co
@@ -188,17 +188,18 @@
 -consent
-'
+%22;
 %0A%0Aconst 
@@ -252,33 +252,33 @@
 %0A  let domain = 
-'
+%22
 localhost';%0A  le
@@ -274,28 +274,17 @@
 host
-'
+%22
 ;%0A  
-let hostname = 
+if (
 wind
@@ -308,132 +308,257 @@
 ame.
-split('.');%0A  switch (hostname.length) %7B%0A    case 1:%0A      domain = 'localhost';%0A      break;%0A    case 2:%0A    case 3:%0A 
+endsWith(%22.stage.datacite.org%22)) %7B%0A    domain = %22.stage.datacite.org%22;%0A  %7D else if (window.location.hostname.endsWith(%22.test.datacite.org%22)) %7B%0A    domain = %22.test.datacite.org%22;%0A  %7D else if (window.location.hostname.endsWith(%22.datacite.org%22)) %7B%0A
     
- 
 doma
@@ -562,17 +562,17 @@
 omain = 
-'
+%22
 .datacit
@@ -580,72 +580,102 @@
 .org
-'
+%22
 ;%0A  
- 
-   break;%0A    case 4:%0A      domain = '.stage.datacite.org'
+%7D else if (window.location.hostname.endsWith(%22.vercel.app%22)) %7B%0A    domain = %22.vercel.app%22
 ;%0A  
@@ -700,16 +700,20 @@
 tyle = %7B
+%0A   
  fontSiz
@@ -719,15 +719,19 @@
 ze: 
-'
+%22
 16px
-',
+%22,%0A   
  hei
@@ -739,15 +739,19 @@
 ht: 
-'
+%22
 95px
-',
+%22,%0A   
  fle
@@ -757,17 +757,17 @@
 exWrap: 
-'
+%22
 nowrap !
@@ -775,19 +775,23 @@
 mportant
-'
+%22,%0A 
  %7D
+;
 %0A  const
@@ -816,19 +816,20 @@
 or: 
-'
+%22
 #fecd23
-'
+%22
  %7D
+;
 %0A  c
@@ -852,16 +852,17 @@
 yle = %7B%7D
+;
 %0A%0A  retu
@@ -1587,19 +1587,19 @@
 see our%7B
-' '
+%22 %22
 %7D%0A      
@@ -1767,19 +1767,19 @@
    %3C/a%3E%7B
-' '
+%22 %22
 %7D%0A      
@@ -1854,11 +1854,11 @@
 es.%7B
-' '
+%22 %22
 %7D%0A  
@@ -1879,16 +1879,17 @@
 ent%3E%0A  )
+;
 %0A%7D%0A%0Acons
@@ -1932,17 +1932,17 @@
 tor(
-'
+%22
 #consent
 ');%0A
@@ -1941,9 +1941,9 @@
 sent
-'
+%22
 );%0AR

support vercel.app hostname for cookie