local M = {}

function M.create(palette, zitch_pattern, config)
	local bg = config.transparent_bg and "NONE" or palette.black
	local groups = {
		-- from old
		CursorLine = { bg = config.transparent_bg and "NONE" or palette.charcoal },
		Cursor = { bg = palette.magenta },
		lCursor = { bg = palette.magenta },
		CursorIM = { bg = palette.magenta },
		Directory = zitch_pattern.GreenBold,
		DiffAdd = { fg = palette.green, bg = palette.pine },
		DiffChange = { fg = palette.blue, bg = palette.indigo },
		DiffDelete = { fg = palette.red, bg = palette.maroon },
		DiffText = { fg = palette.orange, bg = palette.clay },
		EndOfBuffer = { fg = bg },
		ErrorMsg = { fg = palette.red, bg = bg, gui = "bold" },
		VertSplit = { fg = bg, bg = bg },
		Folded = { fg = palette.gray, gui = "italic" },
		FoldColumn = { fg = palette.gray, bg = bg },
		SignColumn = { bg = bg },
		IncSearch = { fg = palette.orange, bg = bg, gui = "inverse" },
		Substitute = { fg = bg, bg = palette.white },
		LineNr = zitch_pattern.PurpleFaded,
		CursorLineNr = { bg = config.transparent_bg and "NONE" or palette.charcoal, fg = palette.lilac },
		MatchParen = { bg = bg, gui = "bold" },
		Normal = { fg = palette.white, bg = bg },
		Pmenu = { fg = palette.magenta, bg = bg },
		PmenuSel = { fg = palette.magenta, bg = palette.mulberry, gui = "bold" },
		PmenuSbar = { bg = bg },
		PmenuThumb = { bg = palette.magenta },
		Search = { fg = bg, bg = palette.yellow },
		SpecialKey = zitch_pattern.Foreground,
		SpellBad = zitch_pattern.RedUnderline,
		SpellCap = zitch_pattern.OrangeUnderline,
		SpellLocal = zitch_pattern.BlueUnderline,
		SpellRare = zitch_pattern.PurpleUnderline,
		TabLine = { fg = palette.gray, bg = bg },
		TabLineFill = { fg = bg, bg = bg },
		TabLineSel = { fg = palette.green, bg = bg, gui = "inverse" },
		Title = zitch_pattern.GreenBold,
		VisualNOS = { bg = palette.mauve, gui = "inverse" },
		WarningMsg = { fg = palette.orange, bg = bg, gui = "bold" },
		NormalFloat = { bg = palette.darkblack },
		WinBarNC = { bg = palette.darkblack },
		WinBar = { bg = palette.darkblack },
		CurSearch = { fg = palette.cyan, bg = palette.teal },

		Comment = { fg = palette.gray, gui = config.italic_comments and "italic" or "NONE" },
		Constant = zitch_pattern.Purple,
		String = zitch_pattern.Green,
		Character = zitch_pattern.GreenBold,
		Number = zitch_pattern.Green,
		Boolean = zitch_pattern.Green,
		["@variable"] = palette.white,

		Identifier = zitch_pattern.Purple,
		Function = zitch_pattern.Orange,

		Statement = zitch_pattern.Purple,
		Conditional = zitch_pattern.Purple,
		Repeat = zitch_pattern.Purple,
		Label = zitch_pattern.Purple,
		Exception = zitch_pattern.Purple,
		Operator = zitch_pattern.Purple,
		Keyword = zitch_pattern.Purple,

		Include = zitch_pattern.Purple,
		Define = zitch_pattern.Purple,
		Macro = zitch_pattern.Purple,
		PreProc = zitch_pattern.Foreground,
		PreCondit = zitch_pattern.Purple,

		Type = zitch_pattern.Blue,
		StorageClass = zitch_pattern.Purple,
		Structure = zitch_pattern.Purple,
		Typedef = zitch_pattern.Purple,

		Special = zitch_pattern.Purple,
		SpecialChar = zitch_pattern.Purple,
		Tag = zitch_pattern.Foreground,
		SpecialComment = zitch_pattern.Gray,
		Debug = zitch_pattern.RedBold,
		Delimiter = zitch_pattern.PinkBold,

		Ignore = {},
		Bold = { gui = "bold" },
		Underlined = { gui = "underline" },
		Italic = { gui = "italic" },
		Error = { fg = palette.red, gui = "bold,underline" },
		Todo = { fg = palette.green, gui = "bold,italic" },

		cmpnormal = { bg = bg, fg = palette.magenta },
		CmpBorder = { bg = bg, fg = palette.magenta },
		CmpCursorLine = {
			bg = config.transparent_bg and "NONE" or palette.lightblack,
			fg = palette.magenta,
			bold = true,
		},
		CmpItemKindText = { bg = "NONE", fg = palette.magenta },
		CmpItemKind = { bg = "NONE", fg = palette.magenta },
		CmpItemAbbr = { bg = "NONE", fg = palette.magenta },
		CmpItemAbbrMatch = { bg = "NONE", fg = palette.green, bold = true },
		CmpItemAbbrMatchFuzzy = { bg = "NONE", fg = palette.orange },

		-- Core UI
		BlinkCmpMenu = { fg = palette.magenta, bg = bg },
		BlinkCmpMenuBorder = { bg = bg, fg = palette.magenta },
		BlinkCmpMenuSelection = { bg = palette.mulberry, gui = "bold" },
		BlinkCmpScrollBarThumb = { bg = palette.magenta },
		BlinkCmpScrollBarGutter = { bg = bg },
		-- Label text
		BlinkCmpLabel = { bg = "NONE", fg = palette.magenta },
		BlinkCmpLabelDeprecated = { bg = "NONE", fg = palette.magenta, strikethrough = true },
		BlinkCmpLabelMatch = { bg = "NONE", fg = palette.green, bold = true },
		BlinkCmpLabelDetail = { bg = "NONE", fg = palette.magenta },
		BlinkCmpLabelDescription = { bg = "NONE", fg = palette.magenta },
		-- Kind icon text (left side of completion)
		BlinkCmpKind = { bg = "NONE", fg = palette.magenta },
		BlinkCmpKindFunction = { bg = "NONE", fg = palette.cyan },
		BlinkCmpKindMethod = { bg = "NONE", fg = palette.cyan },
		BlinkCmpKindVariable = { bg = "NONE", fg = palette.yellow },
		BlinkCmpKindClass = { bg = "NONE", fg = palette.magenta },
		BlinkCmpKindModule = { bg = "NONE", fg = palette.blue },
		BlinkCmpKindKeyword = { bg = "NONE", fg = palette.orange },
		BlinkCmpKindField = { bg = "NONE", fg = palette.orange },
		BlinkCmpKindProperty = { bg = "NONE", fg = palette.yellow },
		BlinkCmpKindInterface = { bg = "NONE", fg = palette.magenta },
		BlinkCmpSource = { bg = "NONE", fg = palette.lilac },
		-- Source label (right side)
		-- BlinkCmpGhostText = {}, -- Ghost text preview
		-- Docs popup
		BlinkCmpDoc = { fg = palette.white, bg = bg },
		BlinkCmpDocBorder = { bg = bg, fg = palette.magenta },
		BlinkCmpDocSeparator = { bg = "NONE", fg = palette.gray },
		-- BlinkCmpDocCursorLine = {},
		-- Signature help
		BlinkCmpSignatureHelp = { fg = palette.white, bg = bg },
		BlinkCmpSignatureHelpBorder = { bg = bg, fg = palette.magenta },
		-- BlinkCmpSignatureHelpActiveParameter = {},

		-- Custom Flash Hi Grps
		MyFlashBackdrop = { fg = palette.mulberry, bg = "NONE", italic = false }, -- backdrop
		MyFlashMatch = { bg = palette.magenta, fg = palette.ebony }, -- search matches
		MyFlashCurrent = { bg = palette.yellow, fg = palette.ebony }, -- current match
		MyFlashLabel = { bg = palette.red, fg = palette.ebony }, -- jump label

		TelescopePromptBorder = { fg = palette.magenta },
		TelescopePromptNormal = { fg = palette.magenta, bg = config.transparent_bg and "NONE" or palette.charcoal },
		TelescopePromptTitle = { fg = palette.magenta, bg = palette.mulberry, bold = true },
		TelescopePromptCounter = { fg = palette.graphite },
		TelescopePromptPrefix = { fg = palette.magenta },
		TelescopeResultsBorder = { fg = palette.magenta },
		TelescopeResultsNormal = { fg = palette.magenta, bg = config.transparent_bg and "NONE" or palette.charcoal },
		TelescopeResultsTitle = { fg = palette.magenta, bg = palette.mulberry, bold = true },
		TelescopePreviewBorder = { fg = palette.magenta },
		TelescopePreviewNormal = { fg = palette.white, bg = config.transparent_bg and "NONE" or palette.charcoal },
		TelescopePreviewTitle = { fg = palette.magenta, bg = palette.mulberry, bold = true },
		TelescopeMatching = { fg = palette.green, bg = palette.pine },
		TelescopeNormal = { bg = palette.magenta, fg = palette.red },
		TelescopePrompt = { fg = palette.cyan },
		TelescopeResults = { fg = palette.magenta },
		TelescopeSelection = { fg = palette.magenta, bg = palette.aubergine, bold = true },
		TelescopeSelectionCaret = { fg = palette.coral, bg = palette.aubergine },

		NeoTreeDirectoryIcon = { bg = "NONE", fg = palette.yellow },
		NeoTreeDirectoryName = { bg = "NONE", fg = palette.yellow },
		NeoTreeFileName = { bg = "NONE", fg = palette.magenta },
		NeoTreeTitleBar = { bg = "NONE", fg = palette.magenta },
		NeoTreeCursorLine = { bg = config.transparent_bg and "NONE" or "#21202b" },
		NeoTreeFloatBorder = { bg = config.transparent_bg and "NONE" or palette.charcoal, fg = palette.magenta },
		NeoTreeFloatNormal = { bg = config.transparent_bg and "NONE" or palette.charcoal, fg = palette.magenta },
		NeoTreeFloatTitle = { bg = palette.mulberry, fg = palette.magenta },
		NeoTreeIndentMarker = { bg = "NONE", fg = "#4f3e29" },

		LazyNormal = { bg = config.transparent_bg and "NONE" or palette.charcoal },
		FloatBorder = { fg = palette.magenta },
		FloatTitle = { fg = palette.magenta },
		Float = { fg = palette.magenta },

		Visual = { bg = config.transparent_bg and "NONE" or "#21202b" },
		WinSeparator = { fg = "#0f0f14", bg = "NONE" },
		StatusLine = { fg = "NONE", bg = "NONE" },
		StatusLineNC = { fg = "NONE", bg = "NONE" },

		DiagnosticError = { bg = "NONE", fg = palette.red },
		DiagnosticFloatingError = { bg = "NONE", fg = palette.red },
		DiagnosticSignError = { bg = "NONE", fg = palette.red },
		DiagnosticUndelineError = { bg = "NONE", fg = palette.red },
		DiagnosticVirtualTextError = { bg = palette.maroon, fg = palette.red },

		DiagnosticInfo = { bg = "NONE", fg = palette.cyan },
		DiagnosticFloatingInfo = { bg = "NONE", fg = palette.cyan },
		DiagnosticSignInfo = { bg = "NONE", fg = palette.cyan },
		DiagnosticUndelineInfo = { bg = "NONE", fg = palette.cyan },
		DiagnosticVirtualTextInfo = { bg = palette.teal, fg = palette.cyan },

		DiagnosticOk = { bg = "NONE", fg = palette.green },
		DiagnosticFloatingOk = { bg = "NONE", fg = palette.green },
		DiagnosticSignOk = { bg = "NONE", fg = palette.green },
		DiagnosticUndelineOk = { bg = "NONE", fg = palette.green },
		DiagnosticVirtualTextOk = { bg = palette.pine, fg = palette.green },

		DiagnosticHint = { bg = "NONE", fg = palette.blue },
		DiagnosticFloatingHint = { bg = "NONE", fg = palette.blue },
		DiagnosticSignHint = { bg = "NONE", fg = palette.blue },
		DiagnosticUndelineHint = { bg = "NONE", fg = palette.blue },
		DiagnosticVirtualTextHint = { bg = palette.indigo, fg = palette.blue },

		DiagnosticWarn = { bg = "NONE", fg = palette.orange },
		DiagnosticFloatingWarn = { bg = "NONE", fg = palette.orange },
		DiagnosticSignWarn = { bg = "NONE", fg = palette.orange },
		DiagnosticUndelineWarn = { bg = "NONE", fg = palette.orange },
		DiagnosticVirtualTextWarn = { bg = palette.clay, fg = palette.orange },

		NoiceCmdlinePopupBorder = { fg = palette.green, bg = "NONE" },
		NoiceCmdlineIcon = { fg = palette.green, bg = "NONE" },
		NoiceCmdlinePopupBorderCalculator = { fg = palette.green, bg = "NONE" },
		NoiceCmdlineIconCalculator = { fg = palette.green, bg = "NONE" },
		NoiceCmdlinePopupBorderCmdline = { fg = palette.green, bg = "NONE" },
		NoiceCmdlineIconCmdline = { fg = palette.green, bg = "NONE" },
		NoiceCmdlinePopupBorderFilter = { fg = palette.green, bg = "NONE" },
		NoiceCmdlineIconFilter = { fg = palette.green, bg = "NONE" },
		NoiceCmdlinePopupBorderHelp = { fg = palette.yellow, bg = "NONE" },
		NoiceCmdlineIconHelp = { fg = palette.yellow, bg = "NONE" },
		NoiceCmdlinePopupBorderIncRename = { fg = palette.blue, bg = "NONE" },
		NoiceCmdlineIconIncRename = { fg = palette.blue, bg = "NONE" },
		NoiceCmdlinePopupBorderInput = { fg = palette.green, bg = "NONE" },
		NoiceCmdlineIconInput = { fg = palette.green, bg = "NONE" },
		NoiceCmdlinePopupBorderLua = { fg = palette.green, bg = "NONE" },
		NoiceCmdlineIconLua = { fg = palette.green, bg = "NONE" },
		NoiceCmdlinePopupBorderSearch = { fg = palette.orange, bg = "NONE" },
		NoiceCmdlineIconSearch = { fg = palette.orange, bg = "NONE" },

		NotifyINFOBody = { fg = palette.blue, bg = "NONE" },
		NotifyDEBUGBody = { fg = palette.yellow, bg = "NONE" },
		NotifyERRORBody = { fg = palette.red, bg = "NONE" },
		NotifyTRACEBody = { fg = palette.purple, bg = "NONE" },
		NotifyWARNBody = { fg = palette.orange, bg = "NONE" },

		AlphaHeader = { fg = palette.purple, bg = "NONE" },
		AlphaButtonText = { fg = palette.mulberry, bg = "NONE", bold = true },
		AlphaButtonShortcut = { fg = palette.amethyst, bg = "NONE", italic = false },
		AlphaFooter = { fg = palette.mulberry, bg = "NONE", italic = false },

		lualine_a_normal = { fg = palette.blue, bg = palette.lightblack },
		lualine_b_normal = { fg = palette.slate, bg = palette.darkblack },
		lualine_b_fancy_branch_normal = { fg = palette.slate, bg = palette.darkblack },
		lualine_c_normal = { fg = palette.slate, bg = palette.darkblack },
		lualine_x_normal = { fg = palette.slate, bg = palette.darkblack },
		lualine_y_normal = { fg = palette.slate, bg = palette.darkblack },
		lualine_z_normal = { fg = palette.slate, bg = palette.darkblack },
		lualine_a_inactive = { fg = palette.graphite, bg = palette.magenta },
		lualine_b_inactive = { fg = palette.graphite, bg = palette.magenta },
		lualine_b_fancy_branch_inactive = { fg = palette.graphite, bg = palette.magenta },
		lualine_c_inactive = { fg = palette.graphite },
		lualine_a_command = { fg = palette.orange, bg = "#4b2424" },
		lualine_z_command = { fg = palette.slate, bg = palette.darkblack },
		lualine_a_insert = { fg = palette.green, bg = "#123127" },
		lualine_z_insert = { fg = palette.slate, bg = palette.darkblack },
		lualine_a_replace = { fg = palette.red, bg = "#652929" },
		lualine_z_replace = { fg = palette.slate, bg = palette.darkblack },
		lualine_a_visual = { fg = palette.yellow, bg = "#4b3b27" },
		lualine_z_visual = { fg = palette.slate, bg = palette.darkblack },
		lualine_a_fancy_branch_terminal = { fg = palette.green, bg = "#123127" },

		CopilotSuggestion = { bg = "NONE", fg = palette.mulberry },
		CopilotAnnotation = { bg = "NONE", fg = palette.slate, bold = true },

		RenderMarkdownCode = { bg = palette.darkblack },
		RenderMarkdownCodeInline = { bg = palette.darkblack },
		RenderMarkdownBullet = { fg = palette.orange },
		RenderMarkdownDash = { fg = palette.orange },
		RenderMarkdownTableHead = { fg = palette.red },
		RenderMarkdownTableRow = { fg = palette.orange },

		-- Highlight Groups setting all Available Colors as Foregrounds
		ZitchPurple = { fg = palette.purple },
		ZitchGreen = { fg = palette.green },
		ZitchOrange = { fg = palette.orange },
		ZitchCoral = { fg = palette.coral },
		ZitchCyan = { fg = palette.cyan },
		ZitchRed = { fg = palette.red },
		ZitchPink = { fg = palette.pink },
		ZitchWhite = { fg = palette.white },
		ZitchGray = { fg = palette.gray },
		ZitchAsh = { fg = palette.ash },
		ZitchBlack = { fg = palette.black },
		ZitchDarkBlack = { fg = palette.darkblack },
		ZitchMagenta = { fg = palette.magenta },
		ZitchYellow = { fg = palette.yellow },
		ZitchMauve = { fg = palette.mauve },
		ZitchBlue = { fg = palette.blue },
		ZitchCharcoal = { fg = palette.charcoal },
		ZitchSlate = { fg = palette.slate },
		ZitchGraphite = { fg = palette.graphite },
		ZitchLilac = { fg = palette.lilac },
		ZitchAmethyst = { fg = palette.amethyst },
		ZitchAubergine = { fg = palette.aubergine },
		ZitchEbony = { fg = palette.ebony },
		ZitchMaroon = { fg = palette.maroon },
		ZitchPine = { fg = palette.pine },
		ZitchIndigo = { fg = palette.indigo },
		ZitchUmber = { fg = palette.umber },
		ZitchClay = { fg = palette.clay },
		ZitchMulberry = { fg = palette.mulberry },
		ZitchTeal = { fg = palette.teal },
		ZitchLightBlack = { fg = palette.lightblack },

		-- from new
		ColorColumn = { bg = palette.mauve },
		PmenuThumb = { bg = palette.amethyst },
		PmenuSbar = { bg = palette.amethyst },
		WildMenu = { fg = palette.purple, bg = palette.graphite },
		Visual = { bg = palette.graphite },
		Question = { fg = palette.purple },
		ModeMsg = { fg = palette.white, style = "bold" },
		MoreMsg = { fg = palette.white, style = "bold" },
		TabLineFill = { bg = palette.amethyst },
		StatusLine = { fg = palette.white, bg = palette.amethyst },
		StatusLineNC = { fg = palette.gray, bg = palette.amethyst },
		WinSeparator = { fg = palette.amethyst },
		Whitespace = { fg = palette.gray },
		NonText = { fg = palette.gray },
		Conceal = { fg = palette.gray },
		SpellBad = { undercurl = true, sp = palette.red },
		SpellCap = { undercurl = true, sp = palette.orange },
		SpellRare = { undercurl = true, sp = palette.purple },
		SpellLocal = { undercurl = true, sp = palette.cyan },
		Error = { fg = palette.red },
	}
	return groups
end

return M
