{
  inputs,
  config,
  lib,
  pkgs,
  ...
}:

let
  cfg = config.programs.bitwarden;

  inherit (lib) mkEnableOption mkIf;
in
{
  options.programs.bitwarden = {
    enable = mkEnableOption "Bitwarden password manager integration";
  };

  config = mkIf cfg.enable {
    home.packages = [
      pkgs.bitwarden-menu
      pkgs.bitwarden-cli
    ];

    programs.librewolf = mkIf config.programs.librewolf.enable {
      profiles.default.extensions.packages =
        with inputs.nur.legacyPackages."${pkgs.stdenv.hostPlatform.system}".repos.rycee.firefox-addons; [
          bitwarden
        ];
    };
  };
}
