import { App, Astal, Gdk, Gtk } from "astal/gtk4";
import Hyprland from "./modules/Hyprland";
import Calendar from "./modules/Calendar";
import QuickView from "./modules/QuickView";
import SystemInfo from "./modules/SystemInfo";
import { CenterBox } from "astal/gtk4/widget";

const Bar = (gdkmonitor: Gdk.Monitor) => {
    const { TOP, LEFT, RIGHT } = Astal.WindowAnchor;

    return (
        <window
            gdkmonitor={gdkmonitor}
            cssClasses={["Bar"]}
            exclusivity={Astal.Exclusivity.EXCLUSIVE}
            anchor={TOP | LEFT | RIGHT}
            visible
            application={App}
            child={
                <CenterBox
                    orientation={Gtk.Orientation.HORIZONTAL}
                    start_widget={
                        <box
                            hexpand
                            halign={Gtk.Align.START}
                            cssClasses={["BarLeft"]}
                        >
                            <Calendar.Time />
                            <SystemInfo.SystemInfo />
                            <Hyprland.Workspace />
                        </box>
                    }
                    centerWidget={<Hyprland.ActiveWindow />}
                    endWidget={
                        <box
                            hexpand
                            halign={Gtk.Align.END}
                            cssClasses={["BarRight"]}
                        >
                            <Hyprland.SysTray />
                            <QuickView.QuickView />
                        </box>
                    }
                ></CenterBox>
            }
        ></window>
    );
};

const cliHandler = (args: string[]): string => {
    return "Not implemented";
};

export default {
    Bar,
    cliHandler,
};
