local color = require("kanagawa-paper.lib.color")

local M = {}

---@param opts KanagawaConfig
---@param palette PaletteColors
---@return ThemeColors
M.get = function(opts, palette)
	return {
		modes = {
			normal = palette.canvasTeal1,
			insert = palette.canvasRed1,
			visual = palette.canvasPink1,
			replace = palette.canvasRed1,
			command = palette.canvasTeal1,
		},
		ui = {
			fg = palette.canvasGray3,
			fg_dim = palette.canvasGray2,
			fg_dimmer = palette.canvasGray1,
			fg_dark = palette.canvasAsh1,
			fg_reverse = palette.canvasWhite5,
			bg_m4 = palette.canvasGray2,
			bg_m3 = palette.canvasGray1,
			bg_m2 = palette.canvasWhite1,
			bg_m1 = palette.canvasWhite2,
			bg_dim = palette.canvasWhite3,
			bg = palette.canvasWhite4,
			bg_p1 = palette.canvasWhite5,
			bg_p2 = palette.canvasWhite6,
			bg_gutter = opts.gutter and palette.canvasWhite2 or "none",
			bg_cursorline = palette.canvasWhite3,
			bg_cursorline_alt = palette.canvasWhite4,
			bg_search = palette.canvasPink2,
			bg_visual = palette.canvasPink3,
			bg_statusline = palette.canvasWhite2,
			border = palette.canvasGray3,
			header1 = palette.canvasBlue2,
			header2 = palette.canvasOrange1,
			special = palette.canvasTeal1,
			nontext = palette.canvasGray1,
			whitespace = palette.canvasGray1,
			win_separator = palette.canvasViolet2,
			indent = palette.canvasWhite2,
			indent_scope = palette.canvasGray1,
			picker = palette.canvasRed1,
			yank = palette.canvasPink2,
			mark = palette.canvasBlue4,
			scrollbar = palette.canvasWhite1,
			tabline = {
				bg = palette.canvasWhite1,
				fg_selected = palette.canvasGray3,
				bg_selected = palette.canvasWhite4,
				fg_inactive = palette.canvasGray2,
				bg_inactive = palette.canvasWhite1,
				fg_alternate = palette.canvasPink1,
				bg_alternate = palette.canvasWhite1,
				indicator = palette.canvasTeal1,
			},
			pmenu = {
				fg = palette.canvasGray3,
				fg_sel = "none", -- This is important to make highlights pass-through
				fg_border = palette.canvasWhite3,
				bg_border = palette.canvasWhite6,
				bg = palette.canvasWhite6,
				bg_sel = palette.canvasWhite3,
				bg_sbar = palette.canvasWhite6,
				bg_thumb = palette.canvasGray1,
			},
			float = {
				fg = palette.canvasGray3,
				bg = palette.canvasWhite6,
				fg_border = palette.canvasWhite3,
				bg_border = palette.canvasWhite6,
			},
		},
		accent = {
			accent1 = palette.canvasTeal1,
			accent2 = palette.canvasOrange1,
			accent3 = palette.canvasAqua1,
			accent4 = palette.canvasGray2,
			accent5 = palette.canvasRed1,
			invert = palette.canvasWhite2,
		},
		rainbow = {
			rainbow1 = palette.canvasRed1,
			rainbow2 = palette.canvasPink1,
			rainbow3 = palette.canvasBlue1,
			rainbow4 = palette.canvasOrange2,
			rainbow5 = palette.canvasGreen1,
			rainbow6 = palette.canvasAsh1,
			rainbow7 = palette.canvasTeal1,
		},
		syn = {
			attribute = palette.canvasYellow1,
			comment = palette.canvasGray1,
			constant = palette.canvasOrange1,
			deprecated = palette.canvasGray1,
			fun = palette.canvasAqua1,
			identifier = palette.canvasTeal1,
			keyword = palette.canvasPink1,
			member = palette.canvasRed1,
			number = palette.canvasPink1,
			operator = palette.canvasRed1,
			parameter = palette.canvasGray3,
			preproc = palette.canvasRed1,
			punct = palette.canvasGray1,
			regex = palette.canvasRed1,
			statement = palette.canvasViolet1,
			string = palette.canvasGreen1,
			symbol = palette.canvasRed1,
			type = palette.canvasAqua1,
			variable = "none",
			special1 = palette.canvasTeal1,
			special2 = palette.canvasRed1,
			special3 = palette.canvasViolet1,
		},
		vcs = {
			added = palette.canvasGreen2,
			added_light = color(palette.canvasGreen2):blend(palette.canvasWhite4, 0.9):to_hex(),
			removed = palette.canvasRed1,
			removed_light = color(palette.canvasRed1):blend(palette.canvasWhite4, 0.9):to_hex(),
			changed = palette.canvasYellow1,
			changed_light = color(palette.canvasYellow1):blend(palette.canvasWhite4, 0.9):to_hex(),
		},
		diff = {
			add = palette.canvasGreen2,
			add_light = color(palette.canvasGreen2):blend(palette.canvasWhite4, 0.8):to_hex(),
			delete = palette.canvasRed1,
			delete_light = color(palette.canvasRed1):blend(palette.canvasWhite4, 0.8):to_hex(),
			change = palette.canvasYellow2,
			change_light = color(palette.canvasYellow2):blend(palette.canvasWhite4, 0.8):to_hex(),
			text = palette.canvasTeal1,
			text_light = color(palette.canvasTeal1):blend(palette.canvasWhite4, 0.8):to_hex(),
		},
		diag = {
			ok = palette.canvasGreen2,
			ok_light = color(palette.canvasGreen2):blend(palette.canvasWhite4, 0.9):to_hex(),
			error = palette.canvasRed1,
			error_light = color(palette.canvasRed1):blend(palette.canvasWhite4, 0.9):to_hex(),
			warning = palette.canvasOrange1,
			warning_light = color(palette.canvasOrange1):blend(palette.canvasWhite4, 0.9):to_hex(),
			info = palette.canvasBlue1,
			info_light = color(palette.canvasBlue1):blend(palette.canvasWhite4, 0.9):to_hex(),
			hint = palette.canvasAqua1,
			hint_light = color(palette.canvasAqua1):blend(palette.canvasWhite4, 0.9):to_hex(),
		},
		term = {
			black = palette.canvasGray2,
			red = palette.canvasRed1,
			green = palette.canvasAqua1,
			yellow = palette.canvasYellow1,
			blue = palette.canvasBlue1,
			magenta = palette.canvasPink1,
			cyan = palette.canvasTeal1,
			white = palette.canvasGray1,
			black_bright = color(palette.canvasGray2):brighten(0.1):to_hex(),
			red_bright = color(palette.canvasRed1):brighten(0.1):to_hex(),
			green_bright = color(palette.canvasAqua1):brighten(0.1):to_hex(),
			yellow_bright = color(palette.canvasYellow1):brighten(0.1):to_hex(),
			blue_bright = color(palette.canvasBlue1):brighten(0.2):to_hex(),
			magenta_bright = color(palette.canvasPink1):brighten(0.1):to_hex(),
			cyan_bright = color(palette.canvasTeal1):brighten(0.1):to_hex(),
			white_bright = color(palette.canvasGray1):brighten(0.1):to_hex(),
			indexed1 = palette.canvasOrange1,
			indexed2 = palette.canvasRed1,
		},
	}
end
return M
