import React from "react";
import ReactDOM from "react-dom/client";
import { App } from "./App";
import { ViewMode } from "./routes/ViewMode";

const renderResistants = (defaultViewMode: ViewMode) => {
  ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
    <React.StrictMode>
      <App defaultViewMode={defaultViewMode} />
    </React.StrictMode>
  );
};

// @ts-ignore
window.Squarespace.onInitialize(Y, function () {
  const defaultViewMode: ViewMode = location.href.includes("resistants")
    ? "photos"
    : "map";

  renderResistants(defaultViewMode);
});
