import React from 'react';
import ReactDOM from 'react-dom';
import { AuthProvider } from "react-oidc-context";

import App from './app';

//TODO remove debugging
if (process.env.NODE_ENV !== 'production') {
    console.log('development mode');
}

//since react 18
import { createRoot } from 'react-dom/client';

//create root container
const root = createRoot(document.getElementById("root"));

//open id connect config
const oidcConfig = {
    authority: "https://kc.swingbe.de/realms/vbn",
    client_id: "data.vbn.de",
    redirect_uri: "http://localhost:8080",
    onSigninCallback: () => {
	window.history.replaceState(
	    {},
	    document.title,
	    window.location.pathname
	)
    }
}

//render root app
root.render(
  <AuthProvider {...oidcConfig}>
    <React.StrictMode>
      <App />
    </React.StrictMode>
  </AuthProvider>
);
