{
  lib,
  config,
  ...
}: let
  inherit (lib) mkOption types;

  cfg = config.horseman.catppuccin;

  flavors = {
    mocha = {
      rosewater = {
        red = 245;
        green = 224;
        blue = 220;
      };
      flamingo = {
        red = 242;
        green = 205;
        blue = 205;
      };
      pink = {
        red = 245;
        green = 194;
        blue = 231;
      };
      mauve = {
        red = 203;
        green = 166;
        blue = 247;
      };
      red = {
        red = 243;
        green = 139;
        blue = 168;
      };
      maroon = {
        red = 235;
        green = 160;
        blue = 172;
      };
      peach = {
        red = 250;
        green = 179;
        blue = 135;
      };
      yellow = {
        red = 249;
        green = 226;
        blue = 175;
      };
      green = {
        red = 166;
        green = 227;
        blue = 161;
      };
      teal = {
        red = 148;
        green = 226;
        blue = 213;
      };
      sky = {
        red = 137;
        green = 220;
        blue = 235;
      };
      sapphire = {
        red = 116;
        green = 199;
        blue = 236;
      };
      blue = {
        red = 137;
        green = 180;
        blue = 250;
      };
      lavender = {
        red = 180;
        green = 190;
        blue = 254;
      };
      text = {
        red = 205;
        green = 214;
        blue = 244;
      };
      subtext1 = {
        red = 186;
        green = 194;
        blue = 222;
      };
      subtext0 = {
        red = 166;
        green = 173;
        blue = 200;
      };
      overlay2 = {
        red = 147;
        green = 153;
        blue = 178;
      };
      overlay1 = {
        red = 127;
        green = 132;
        blue = 156;
      };
      overlay0 = {
        red = 108;
        green = 112;
        blue = 134;
      };
      surface2 = {
        red = 88;
        green = 91;
        blue = 112;
      };
      surface1 = {
        red = 69;
        green = 71;
        blue = 90;
      };
      surface0 = {
        red = 49;
        green = 50;
        blue = 68;
      };
      base = {
        red = 30;
        green = 30;
        blue = 46;
      };
      mantle = {
        red = 24;
        green = 24;
        blue = 37;
      };
      crust = {
        red = 17;
        green = 17;
        blue = 27;
      };
    };
    macchiato = {
      rosewater = {
        red = 244;
        green = 219;
        blue = 214;
      };
      flamingo = {
        red = 240;
        green = 198;
        blue = 198;
      };
      pink = {
        red = 245;
        green = 189;
        blue = 230;
      };
      mauve = {
        red = 198;
        green = 160;
        blue = 246;
      };
      red = {
        red = 237;
        green = 135;
        blue = 150;
      };
      maroon = {
        red = 238;
        green = 153;
        blue = 160;
      };
      peach = {
        red = 245;
        green = 169;
        blue = 127;
      };
      yellow = {
        red = 238;
        green = 212;
        blue = 159;
      };
      green = {
        red = 166;
        green = 218;
        blue = 149;
      };
      teal = {
        red = 139;
        green = 213;
        blue = 202;
      };
      sky = {
        red = 145;
        green = 215;
        blue = 227;
      };
      sapphire = {
        red = 125;
        green = 196;
        blue = 228;
      };
      blue = {
        red = 138;
        green = 173;
        blue = 244;
      };
      lavender = {
        red = 183;
        green = 189;
        blue = 248;
      };
      text = {
        red = 202;
        green = 211;
        blue = 245;
      };
      subtext1 = {
        red = 184;
        green = 192;
        blue = 224;
      };
      subtext0 = {
        red = 165;
        green = 173;
        blue = 203;
      };
      overlay2 = {
        red = 147;
        green = 154;
        blue = 183;
      };
      overlay1 = {
        red = 128;
        green = 135;
        blue = 162;
      };
      overlay0 = {
        red = 110;
        green = 115;
        blue = 141;
      };
      surface2 = {
        red = 91;
        green = 96;
        blue = 120;
      };
      surface1 = {
        red = 73;
        green = 77;
        blue = 100;
      };
      surface0 = {
        red = 54;
        green = 58;
        blue = 79;
      };
      base = {
        red = 36;
        green = 39;
        blue = 58;
      };
      mantle = {
        red = 30;
        green = 32;
        blue = 48;
      };
      crust = {
        red = 24;
        green = 25;
        blue = 38;
      };
    };
    frappe = {
      rosewater = {
        red = 242;
        green = 213;
        blue = 207;
      };
      flamingo = {
        red = 238;
        green = 190;
        blue = 190;
      };
      pink = {
        red = 244;
        green = 184;
        blue = 228;
      };
      mauve = {
        red = 202;
        green = 158;
        blue = 230;
      };
      red = {
        red = 231;
        green = 130;
        blue = 132;
      };
      maroon = {
        red = 234;
        green = 153;
        blue = 156;
      };
      peach = {
        red = 239;
        green = 159;
        blue = 118;
      };
      yellow = {
        red = 229;
        green = 200;
        blue = 144;
      };
      green = {
        red = 166;
        green = 209;
        blue = 137;
      };
      teal = {
        red = 129;
        green = 200;
        blue = 190;
      };
      sky = {
        red = 153;
        green = 209;
        blue = 219;
      };
      sapphire = {
        red = 133;
        green = 193;
        blue = 220;
      };
      blue = {
        red = 140;
        green = 170;
        blue = 238;
      };
      lavender = {
        red = 186;
        green = 187;
        blue = 241;
      };
      text = {
        red = 198;
        green = 208;
        blue = 245;
      };
      subtext1 = {
        red = 181;
        green = 191;
        blue = 226;
      };
      subtext0 = {
        red = 165;
        green = 173;
        blue = 206;
      };
      overlay2 = {
        red = 148;
        green = 156;
        blue = 187;
      };
      overlay1 = {
        red = 131;
        green = 139;
        blue = 167;
      };
      overlay0 = {
        red = 115;
        green = 121;
        blue = 148;
      };
      surface2 = {
        red = 98;
        green = 104;
        blue = 128;
      };
      surface1 = {
        red = 81;
        green = 87;
        blue = 109;
      };
      surface0 = {
        red = 65;
        green = 69;
        blue = 89;
      };
      base = {
        red = 48;
        green = 52;
        blue = 70;
      };
      mantle = {
        red = 41;
        green = 44;
        blue = 60;
      };
      crust = {
        red = 35;
        green = 38;
        blue = 52;
      };
    };
    latte = {
      rosewater = {
        red = 220;
        green = 138;
        blue = 120;
      };
      flamingo = {
        red = 221;
        green = 120;
        blue = 120;
      };
      pink = {
        red = 234;
        green = 118;
        blue = 203;
      };
      mauve = {
        red = 136;
        green = 57;
        blue = 239;
      };
      red = {
        red = 210;
        green = 15;
        blue = 57;
      };
      maroon = {
        red = 230;
        green = 69;
        blue = 83;
      };
      peach = {
        red = 254;
        green = 100;
        blue = 11;
      };
      yellow = {
        red = 223;
        green = 142;
        blue = 29;
      };
      green = {
        red = 64;
        green = 160;
        blue = 43;
      };
      teal = {
        red = 23;
        green = 146;
        blue = 153;
      };
      sky = {
        red = 4;
        green = 165;
        blue = 229;
      };
      sapphire = {
        red = 32;
        green = 159;
        blue = 181;
      };
      blue = {
        red = 30;
        green = 102;
        blue = 245;
      };
      lavender = {
        red = 114;
        green = 135;
        blue = 253;
      };
      text = {
        red = 76;
        green = 79;
        blue = 105;
      };
      subtext1 = {
        red = 92;
        green = 95;
        blue = 119;
      };
      subtext0 = {
        red = 108;
        green = 111;
        blue = 133;
      };
      overlay2 = {
        red = 124;
        green = 127;
        blue = 147;
      };
      overlay1 = {
        red = 140;
        green = 143;
        blue = 161;
      };
      overlay0 = {
        red = 156;
        green = 160;
        blue = 176;
      };
      surface2 = {
        red = 172;
        green = 176;
        blue = 190;
      };
      surface1 = {
        red = 188;
        green = 192;
        blue = 204;
      };
      surface0 = {
        red = 204;
        green = 208;
        blue = 218;
      };
      base = {
        red = 239;
        green = 241;
        blue = 245;
      };
      mantle = {
        red = 230;
        green = 233;
        blue = 239;
      };
      crust = {
        red = 220;
        green = 224;
        blue = 232;
      };
    };
  };
in {
  options = {
    horseman.catppuccin = {
      flavor = mkOption {
        type = types.enum ["latte" "frappe" "mocha" "macchiato"];
        default = "mocha";
      };

      accent = mkOption {
        type = types.enum [
          "rosewater"
          "flamingo"
          "pink"
          "mauve"
          "red"
          "maroon"
          "peach"
          "yellow"
          "green"
          "teal"
          "sky"
          "sapphire"
          "blue"
          "lavender"
          "text"
          "subtext1"
          "subtext0"
          "overlay2"
          "overlay1"
          "overlay0"
          "surface2"
          "surface1"
          "surface0"
          "base"
          "mantle"
          "crust"
        ];

        default = "lavender";
      };

      colors = mkOption {
        type = types.attrsOf (types.submodule {
          options = {
            red = mkOption {
              type = types.int;
            };
            green = mkOption {
              type = types.int;
            };
            blue = mkOption {
              type = types.int;
            };
          };
        });
        readOnly = true;
      };
    };
  };

  config.horseman.catppuccin.colors = lib.mkDefault (flavors.${cfg.flavor} // {accent = flavors.${cfg.flavor}.${cfg.accent};});
}
