import type { AuthState } from './authStoreTypes';
import { clampLibraryGridMaxColumns } from './authStoreHelpers';

type SetState = (
  partial: Partial<AuthState> | ((state: AuthState) => Partial<AuthState>),
) => void;

/**
 * Visual / chrome settings. Pure pass-through setters: tray, titlebar,
 * sidebar toggles, fullscreen lyrics rendering options, changelog
 * banner. No side effects.
 */
export function createUiAppearanceActions(set: SetState): Pick<
  AuthState,
  | 'setShowArtistImages'
  | 'setLibraryGridMaxColumns'
  | 'setShowTrayIcon'
  | 'setMinimizeToTray'
  | 'setClockFormat'
  | 'setShowOrbitTrigger'
  | 'setUseCustomTitlebar'
  | 'setWindowButtonStyle'
  | 'setShowMinimizeButton'
  | 'setPreloadMiniPlayer'
  | 'setLinuxWebkitKineticScroll'
  | 'setLinuxWaylandTextRenderProfile'
  | 'setLinuxWebkitInputForceRepaint'
  | 'setSeekbarStyle'
  | 'setQueueNowPlayingCollapsed'
  | 'setQueueDurationDisplayMode'
  | 'setQueueDisplayMode'
  | 'setSidebarLyricsStyle'
  | 'setShowChangelogOnUpdate'
  | 'setLastSeenChangelogVersion'
  | 'setLastDismissedThemeUpdateSig'
  | 'setAdvancedSettingsEnabled'
> {
  return {
    setShowArtistImages: (v) => set({ showArtistImages: v }),
    setLibraryGridMaxColumns: (v) => set({ libraryGridMaxColumns: clampLibraryGridMaxColumns(v) }),
    setShowTrayIcon: (v) => set({ showTrayIcon: v }),
    setMinimizeToTray: (v) => set({ minimizeToTray: v }),
    setClockFormat: (v) => set({ clockFormat: v }),
    setShowOrbitTrigger: (v) => set({ showOrbitTrigger: v }),
    setUseCustomTitlebar: (v) => set({ useCustomTitlebar: v }),
    setWindowButtonStyle: (v) => set({ windowButtonStyle: v }),
    setShowMinimizeButton: (v) => set({ showMinimizeButton: v }),
    setPreloadMiniPlayer: (v) => set({ preloadMiniPlayer: v }),
    setLinuxWebkitKineticScroll: (v) => set({ linuxWebkitKineticScroll: v }),
    setLinuxWaylandTextRenderProfile: (v) => set({ linuxWaylandTextRenderProfile: v }),
    setLinuxWebkitInputForceRepaint: (v) => set({ linuxWebkitInputForceRepaint: v }),
    setSeekbarStyle: (v) => set({ seekbarStyle: v }),
    setQueueNowPlayingCollapsed: (v) => set({ queueNowPlayingCollapsed: v }),
    setQueueDurationDisplayMode: (v) => set({ queueDurationDisplayMode: v }),
    setQueueDisplayMode: (v) => set({ queueDisplayMode: v }),
    setSidebarLyricsStyle: (v) => set({ sidebarLyricsStyle: v }),
    setShowChangelogOnUpdate: (v) => set({ showChangelogOnUpdate: v }),
    setLastSeenChangelogVersion: (v) => set({ lastSeenChangelogVersion: v }),
    setLastDismissedThemeUpdateSig: (v) => set({ lastDismissedThemeUpdateSig: v }),
    setAdvancedSettingsEnabled: (v) => set({ advancedSettingsEnabled: v }),
  };
}
