{
  config,
  lib,
  ...
}: let
  inherit (config.rose-pine) sources;

  cfg = config.programs.zellij.rose-pine;
  enable = cfg.enable && config.programs.zellij.enable;

  themeName =
    if (cfg.flavor == "main")
    then "rose-pine"
    else "rose-pine-${cfg.flavor}";
  theme = sources.zellij + "/dist/${themeName}.kdl";
in {
  options.programs.zellij.rose-pine = lib.rp.mkRosePineOpt {name = "zellij";};

  config = lib.mkIf enable {
    xdg.configFile."zellij/themes/${themeName}.kdl".source = theme;

    programs.zellij.settings = {
      theme = themeName;
    };
  };
}
