import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import "./index.css";

const rootElement = document.getElementById("b3-wvs-admin-root");

if (rootElement) {
  // Set CSS variable for WordPress admin theme color
  const adminColor = (window as any).b3WvsData?.admin_color || "#4f46e5";
  rootElement.style.setProperty("--b3-wvs-admin-color", adminColor);

  ReactDOM.createRoot(rootElement).render(
    <React.StrictMode>
      <App data={(window as any).b3WvsData ?? {}} />
    </React.StrictMode>,
  );
}
