import { create } from "zustand";

export type PlayerTopBannerKind = "offline" | "network";

type PlayerTopBannerState = {
  heights: Record<PlayerTopBannerKind, number>;
  setBannerHeight: (kind: PlayerTopBannerKind, px: number) => void;
};

export const usePlayerTopBannerStore = create<PlayerTopBannerState>((set) => ({
  heights: { offline: 0, network: 0 },
  setBannerHeight: (kind, px) =>
    set((state) => ({
      heights: { ...state.heights, [kind]: Math.max(0, px) },
    })),
}));

export function selectPlayerStickyTopOffset(state: PlayerTopBannerState): number {
  return state.heights.offline + state.heights.network;
}
