
function strip_ansi(str)
  -- Remove ANSI escape sequences
  str = str:gsub('\27%[[%d;?]*[ -/]*[@-~]', '') -- CSI sequences
  str = str:gsub('\27%][^%a]*%a', '')           -- OSC sequences (simplified)
  str = str:gsub('\27%]%d+;.-\7', '')           -- OSC terminated by BEL
  str = str:gsub('\27%]%d+;.-\27\\', '')        -- OSC terminated by ST (ESC\)
  str = str:gsub('\27[PX^_].-\27\\', '')        -- DCS, SOS, PM, APC sequences
  return str
end



local function hex_to_rgb(hex)
	local r, g, b = hex:match("#?(%x%x)(%x%x)(%x%x)")
	return tonumber(r, 16), tonumber(g, 16), tonumber(b, 16)
end

function fg(hex)
	local r, g, b = hex_to_rgb(hex)
	return ("\27[38;2;%d;%d;%dm"):format(r, g, b)
end

function bg(hex)
	local r, g, b = hex_to_rgb(hex)
	return ("\27[48;2;%d;%d;%dm"):format(r, g, b)
end

function reset()
	return "\27[0m"
end

function fg_rgb(r, g, b)
	return ("\27[38;2;%d;%d;%dm"):format(r, g, b)
end

function bg_rgb(r,g,b)
	return ("\27[48;2;%d;%d;%dm"):format(r, g, b)
end

function invert_colors_of_text(text)
	return "\27[7m" .. text .. "\27[0m"
end



styles = {
  selectedStyle = {
    fg = "#008000",
    bold = true
  },

  unselectedStyle = {
    fg = "#808080" -- was "8"
  },

  hyperlink = {
    fg = "#FFFFFF",
    bg = "#0000FF"
  },

  selfPrefix = {
    fg = "#00FF00" -- was "10"
  },

  selfBody = {
    fg = "#7FFF7F"
  },

  topbarStyke = {
    fg = "#FFFFFF", -- was "15"
    bg = "#808080", -- was "8"
    bold = true
  },

  bottombarStyle = {
    fg = "#FFFFFF", -- was "15"
    bg = "#808080" -- was "8"
  },

  replyHighlight = {
    fg = "#000000",
    bg = "#FFFFFF"
  },

  errorBarStyle = {
    fg = "#FFFFFF",
    bg = "#FF0000"
  }
}--
