{
  config,
  inputs,
  lib,
  system,
  pkgs,
  fetchFromGitHub,
  ...
}:
let
  cfg = config.modules.zen-browser;
in
{
  imports = [
    # inputs.zen-browser.homeModules.beta
    # inputs.zen-browser.homeModules.twilight
    inputs.zen-browser.homeModules.twilight-official
  ];
  options.modules.zen-browser = {
    enable = lib.mkEnableOption "zen";
  };
  config = lib.mkIf cfg.enable {
    programs.zen-browser = {
      enable = true;
      policies = {
        AutofillAddressEnabled = true;
        AutofillCreditCardEnabled = false;
        DisableAppUpdate = true;
        DisableFeedbackCommands = true;
        DisableFirefoxStudies = true;
        DisablePocket = true;
        DisableTelemetry = true;
        DontCheckDefaultBrowser = true;
        NoDefaultBookmarks = true;
        OfferToSaveLogins = false;
        EnableTrackingProtection = {
          Value = true;
          Locked = true;
          Cryptomining = true;
          Fingerprinting = true;
        };
      };
    };
    xdg.mimeApps =
      let
        value =
          let
            zen-browser = inputs.zen-browser.packages.${system}.twilight-official; # or twilight
          in
          zen-browser.meta.desktopFileName;

        associations = builtins.listToAttrs (
          map
            (name: {
              inherit name value;
            })
            [
              "application/x-extension-shtml"
              "application/x-extension-xhtml"
              "application/x-extension-html"
              "application/x-extension-xht"
              "application/x-extension-htm"
              "x-scheme-handler/unknown"
              "x-scheme-handler/mailto"
              "x-scheme-handler/chrome"
              "x-scheme-handler/about"
              "x-scheme-handler/https"
              "x-scheme-handler/http"
              "application/xhtml+xml"
              "application/json"
              "text/plain"
              "text/html"
            ]
        );
      in
      {
        associations.added = associations;
        defaultApplications = associations;
      };
  };
}
