local M = {}
local util = require("cyberdream.util")

--- Get extension configuration
--- @param opts cyberdream.Config
--- @param t cyberdream.Palette
function M.get(opts, t)
    opts = opts or {}
    local p = {
        -- redifined for further customization
        bg = t.bg,
        white = t.fg,
        grey = t.grey,
        cyan = t.cyan,
        blue = t.blue,
        pink = t.pink,
        orange = t.orange,
        yellow = t.yellow,
        purple = t.purple,
        magenta = t.magenta,
        bg_solid = t.bg_solid,
        -- blended colors
        red = util.blend(t.bg_solid, t.red, 0.20),
        green = util.blend(t.bg_solid, t.green, 0.20),
        bg_red = util.blend(t.bg_solid, t.red, 0.65),
        bg_green = util.blend(t.bg_solid, t.green, 0.65),
        diffbg_red = util.blend(t.bg_solid, t.red, 0.85),
        diffbg_green = util.blend(t.bg_solid, t.green, 0.85),
        bg_cyan = util.blend(t.bg_solid, t.cyan, 0.20),
        bg_blue = util.blend(t.bg_solid, t.blue, 0.20),
        bg_magenta = util.blend(t.bg_solid, t.magenta, 0.20),
        bg_alt = util.blend(t.bg_solid, t.bg_highlight, 0.02),
        -- styles
        bold = true,
        italic = true,
        underline = true,
    }
    local highlights = {
        NeogitGraphAuthor = { fg = p.orange },
        NeogitGraphRed = { fg = p.red },
        NeogitGraphWhite = { fg = p.white },
        NeogitGraphYellow = { fg = p.yellow },
        NeogitGraphGreen = { fg = p.green },
        NeogitGraphCyan = { fg = p.cyan },
        NeogitGraphBlue = { fg = p.blue },
        NeogitGraphPurple = { fg = p.purple },
        NeogitGraphGray = { fg = p.grey },
        NeogitGraphOrange = { fg = p.orange },
        NeogitGraphBoldOrange = { fg = p.orange, bold = p.bold },
        NeogitGraphBoldRed = { fg = p.red, bold = p.bold },
        NeogitGraphBoldWhite = { fg = p.white, bold = p.bold },
        NeogitGraphBoldYellow = { fg = p.yellow, bold = p.bold },
        NeogitGraphBoldGreen = { fg = p.green, bold = p.bold },
        NeogitGraphBoldCyan = { fg = p.cyan, bold = p.bold },
        NeogitGraphBoldBlue = { fg = p.blue, bold = p.bold },
        NeogitGraphBoldPurple = { fg = p.purple, bold = p.bold },
        NeogitGraphBoldGray = { fg = p.grey, bold = p.bold },
        NeogitHunkMergeHeader = { fg = p.bg_alt, bg = p.grey, bold = p.bold },
        NeogitHunkMergeHeaderHighlight = { fg = p.bg, bg = p.bg_cyan, bold = p.bold },
        NeogitHunkMergeHeaderCursor = { fg = p.bg, bg = p.bg_cyan, bold = p.bold },
        NeogitHunkHeader = { fg = p.bg, bg = p.grey, bold = p.bold },
        NeogitHunkHeaderHighlight = { fg = p.bg, bg = p.bg_magenta, bold = p.bold },
        NeogitHunkHeaderCursor = { fg = p.bg, bg = p.bg_magenta, bold = p.bold },
        NeogitDiffContext = { bg = p.bg_alt },
        NeogitDiffContextHighlight = { bg = p.bg_alt },
        NeogitDiffContextCursor = { bg = p.bg_alt },
        NeogitDiffAdditions = { fg = p.bg_green },
        NeogitDiffAdd = { bg = p.diffbg_green, fg = p.bg_green },
        NeogitDiffAddHighlight = { bg = p.diffbg_green, fg = p.green },
        NeogitDiffAddCursor = { bg = p.bg_alt, fg = p.green },
        NeogitDiffDeletions = { fg = p.bg_red },
        NeogitDiffDelete = { bg = p.diffbg_red, fg = p.bg_red },
        NeogitDiffDeleteHighlight = { bg = p.diffbg_red, fg = p.red },
        NeogitDiffDeleteCursor = { bg = p.bg_alt, fg = p.red },
        NeogitPopupSectionTitle = { fg = p.blue },
        NeogitPopupBranchName = { fg = p.cyan },
        NeogitPopupBold = { bold = p.bold },
        NeogitPopupSwitchKey = { fg = p.magenta },
        NeogitPopupSwitchEnabled = { link = "NeogitPopupSwitchKey" },
        NeogitPopupOptionKey = { link = "NeogitPopupSwitchKey" },
        NeogitPopupConfigKey = { link = "NeogitPopupSwitchKey" },
        NeogitPopupActionKey = { link = "NeogitPopupSwitchKey" },
        NeogitFilePath = { fg = p.blue, italic = p.italic },
        NeogitCommitViewHeader = { bg = p.bg_cyan, fg = p.bg_solid },
        NeogitDiffHeader = { bg = p.bg_alt, fg = p.blue, bold = p.bold },
        NeogitDiffHeaderHighlight = { bg = p.bg_alt, fg = p.orange, bold = p.bold },
        NeogitBranch = { fg = p.cyan, bold = p.bold },
        NeogitBranchHead = { fg = p.blue, bold = p.bold, underline = p.underline },
        NeogitRemote = { fg = p.blue, bold = p.bold },
        NeogitUnmergedInto = { fg = p.pink, bold = p.bold },
        NeogitUnpushedTo = { fg = p.pink, bold = p.bold },
        NeogitUnpulledFrom = { fg = p.pink, bold = p.bold },
        NeogitChangeModified = { fg = p.blue, bold = p.bold, italic = p.italic },
        NeogitChangeAdded = { fg = p.green, bold = p.bold, italic = p.italic },
        NeogitChangeDeleted = { fg = p.red, bold = p.bold, italic = p.italic },
        NeogitChangeRenamed = { fg = p.purple, bold = p.bold, italic = p.italic },
        NeogitChangeUpdated = { fg = p.orange, bold = p.bold, italic = p.italic },
        NeogitChangeCopied = { fg = p.cyan, bold = p.bold, italic = p.italic },
        NeogitChangeUnmerged = { fg = p.yellow, bold = p.bold, italic = p.italic },
        NeogitChangeNewFile = { fg = p.green, bold = p.bold, italic = p.italic },
        NeogitSectionHeader = { fg = p.green, bold = p.bold },
        NeogitTagName = { fg = p.yellow },
        NeogitTagDistance = { fg = p.cyan },
        NeogitFloatHeader = { bg = p.bg, bold = p.bold },
        NeogitFloatHeaderHighlight = { bg = p.bg_alt, fg = p.cyan, bold = p.bold },
        NeogitActiveItem = { bg = p.orange, fg = p.bg_solid, bold = p.bold },
    }

    return highlights
end

return M
