-- Copyright © 2024 @Groick (Twitch). All rights reserved.
local function L(key, ...) return EasyOptions:Localize(key, ...) end
function EasyOptions:CreateOptionShowMinimapIcon(parent, positionInfo, optionItem)
  optionItem.Text = optionItem.Text or L("Show Minimap Icon")
  optionItem.TooltipText = optionItem.TooltipText or L("Indicates whether the minimap icon for this addon is visible.")
  local onOptionValueChangedHandlerCustom = optionItem.OnOptionValueChangedHandler
  optionItem.OnOptionValueChangedHandler = function(self)
    local optionItem = self
    optionItem:UpdateMinimapIconVisibleState()
    if (onOptionValueChangedHandlerCustom ~= nil) then
      onOptionValueChangedHandlerCustom(self)
    end
  end
  
  local control, controlRegionWidth, controlRegionHeight = EasyOptions:CreateOptionCheckBox(parent, positionInfo, optionItem)
  
  local value = optionItem:GetOptionValue()
  local minimapIconTooltipTitleText = optionItem.MinimapIconTooltipTitleText or optionItem.MinimapIconText
  optionItem.MinimapDataObjectName, optionItem.MinimapDataObject, optionItem.MinimapButton = EasyOptions:AddMinimapIcon(optionItem.AddonName, optionItem.Name, optionItem.MinimapIconText, minimapIconTooltipTitleText, optionItem.MinimapIconTooltipText, optionItem.MinimapIconFilePath, value, optionItem.OnMinimapIconClickHandler)
  
  optionItem.UpdateMinimapIconVisibleState = function(self)
    local optionItem = self
    local value = optionItem:GetOptionValue()
    optionItem.MinimapDataObject:SetVisible(value)
  end

  return control, controlRegionWidth, controlRegionHeight
end
function EasyOptions:GetDefaultMinimapIconTooltipText(addonName)
  local color = EasyOptionsDB["TooltipAlternateTextColor"]
  local prefix_LeftClick = EasyOptions:ConvertTextToColoredText(L("Left-Click:"), color)
  local prefix_RightClick = EasyOptions:ConvertTextToColoredText(L("Right-Click:"), color)
  return L("{1} Show options for {2}.\n{3} Manage in EasyOptions.", prefix_LeftClick, addonName, prefix_RightClick)
end
