// F8-10 ship-groups table — module-level filter / sort rune.
// Mirrors `table-planets-state.svelte.ts`. See that file for the
// rationale.

export type ShipGroupsSortColumn =
	| "owner"
	| "class"
	| "count"
	| "race"
	| "location"
	| "mass"
	| "speed";

export type ShipGroupsSortDirection = "asc" | "desc";

export interface ShipGroupsTableState {
	sortColumn: ShipGroupsSortColumn;
	sortDirection: ShipGroupsSortDirection;
	showOwn: boolean;
	showForeign: boolean;
	planetFilter: string;
	classFilter: string;
}

const DEFAULT_STATE: ShipGroupsTableState = {
	sortColumn: "owner",
	sortDirection: "asc",
	showOwn: true,
	showForeign: true,
	planetFilter: "",
	classFilter: "",
};

export const shipGroupsTableState: ShipGroupsTableState = $state({
	...DEFAULT_STATE,
});

export function resetShipGroupsTableState(): void {
	Object.assign(shipGroupsTableState, DEFAULT_STATE);
}
