import { useState, useCallback } from "react";

export type RecordingMode = "video" | "audio";

const KEY = "llink:recording-mode";

export function useRecordingMode(): [RecordingMode, (mode: RecordingMode) => void] {
  const [mode, setModeState] = useState<RecordingMode>(() => {
    const stored = localStorage.getItem(KEY);
    return stored === "audio" ? "audio" : "video";
  });

  const setMode = useCallback((m: RecordingMode) => {
    localStorage.setItem(KEY, m);
    setModeState(m);
  }, []);

  return [mode, setMode];
}
