# Config

Shared = {}
Locales = {}

Shared.locale = "en"
Shared.debug = true
Shared.acceptLegacyMessages = true
Shared.executeCommandWhenDefault = "ooc" -- nil for no default command, this will basically discard the message when no "/" provided
Shared.skipRecipientProccForAuthor = true -- If the author is inside the recipient pool, recipient-checks are skipped for him

Shared.framework = "auto"  -- Framework: qb, esx
Shared.headMessage = {
  timePerCharacter = 180,  -- ms per character to display
  minTime = 3200,         -- minimum time to display
  maxTime = 7000,
}

-- Might want to rename these if you changed the core resource name
Shared._alias = {
  ["qb-core"] = "qb",
  ["qbx_core"] = "qbx",
  ["es_extended"] = "esx"
}

Shared.UI = {}

Shared.UI.General = {
    Debug = false,

    -- Maximum message length
    MaxMessageLength = 300,
}

Shared.UI.Features = {
    -- Enable/disable emoji picker
    EmojiPicker = true,

    -- Enable/disable GIF selector with Giphy integration
    GifSelector = true,

    -- Enable/disable dice roll button
    DiceButton = true,

    -- Enable/disable try luck button
    TryButton = true,

    -- Enable/disable command suggestions
    CommandSuggestions = true,

    -- Enable/disable message length counter
    MessageLengthCounter = true,

    -- Enable/disable message history (arrow key navigation)
    MessageHistory = true,

    -- Maximum messages stored in history
    MaxHistoryMessages = 10,
}

Shared.UI.DuiHandler = {
    enabled = true, -- Enable/disable system
    duration = 8000, -- 8 seconds default duration
    maxDistance = 50.0, -- Maximum render distance
    fontSize = 0.4,
    fontId = 4,
    color = { r = 255, g = 255, b = 255, a = 255 },
    shadowColor = { r = 0, g = 0, b = 0, a = 150 },
    verticalOffset = 0.6, -- Offset above player head
    fadeDistance = 30.0, -- Distance where text starts to fade
    maxTexts = 2, -- Maximum simultaneous 3D texts
    backgroundColor = { r = 0, g = 0, b = 0, a = 80 }, -- Background overlay
    backgroundPadding = { x = 0.02, y = 0.01 },
    enableBackground = false, -- Disabled for stability
    enableShadow = false -- Disabled for stability
}
------------------------------------------------------------------------------
-- Just a reminder: Messages are proccessed in this order:
-- 1. checks (client-side) (author is allowed)
-- 2. recipients (filter player-pool) (who will receive the message)
-- 3. placeholder parsing: parse every placeholder (not message.content)
-- 4. buildText: (final step, here you can customize last details)
--
-- P.D: There is a double (check & recipient) proccess server-side
------------------------------------------------------------------------------

-- ME command
addCustomCommand({
  name = "me",
  colors = getTemplate("me"), -- Message in types.ts
  nativeCommand = {
    enabled = true,
    data = {
      help = "Perform an action in third person",
      params = {
        { name = "action", help = "The action to perform" }
      }
    }
  },
  flags = {
    headMessage = true,
  },
  checks = {},
  recipients = {
    { type = "visibility", payload = { range = 15.0 } },
  },
  buildText = function(message, args)
    return message
  end,
  ttl = nil -- nil: persistent, number: time-to-live ms
})

-- DO command
addCustomCommand({
  name = "do",
  colors = getTemplate("do"), -- Message in types.ts 
  checks = {},
  recipients = {
    { type = "visibility", payload = { range = 15.0 } },
  },
  buildText = function(message, args)
    return message
  end,
  ttl = nil -- nil: persistent, number: time-to-live ms
})

-- DICE command
addCustomCommand({
  name = "dice",
  colors = getTemplate("me"), -- Message in types.ts 
  checks = {},
  recipients = {},
  buildText = function(message, args)
    message.content_prefix.content = "{Framework:GetName}"
    message.tags[1].text = "DICE"
    message.message.content = " has rolled a dice and got " .. tostring(math.random(1, 6))
    return message
  end,
  ttl = 2000 -- nil: persistent, number: time-to-live ms
})

-- OOC command
addCustomCommand({
  name = "ooc",
  colors = getTemplate("ooc"), -- Message in types.ts 
  checks = {},
  recipients = {},
  buildText = function(message, args)
    message.content_prefix.content = GetPlayerName(PlayerId())
    return message
  end,
  ttl = nil -- nil: persistent, number: time-to-live ms
})

-- StaffChat command
addCustomCommand({
  name = "sc",
  colors = getTemplate("ooc"), -- Message in types.ts 
  checks = {},
  recipients = {
    { type = "Framework:IsAdmin", payload = {} }
  },
  buildText = function(message, args)
    message.tags[1].text = "STAFF"
    message.content_prefix.content = GetPlayerName(PlayerId())
    return message
  end,
  ttl = nil -- nil: persistent, number: time-to-live ms
})

-- Try command
addCustomCommand({
  name = "try",
  colors = getTemplate("try"), -- Message in types.ts 
  checks = {},
  recipients = {},
  nativeCommand = {
    enabled = true,
    data = {
      help = "Try to do something",
      params = {}
    }
  },
  buildText = function(message, args)
    local succ = math.random(1, 100) <= 50
    message.message.content = string.format("Tried something and ended up %s.", succ and "succeeding" or "failing")
    return message
  end,
  ttl = nil -- nil: persistent, number: time-to-live ms
})

-- Try command
addCustomCommand({
  name = "msg",
  colors = getTemplate("msg"), -- Message in types.ts 
  checks = {
    { type = "Checks:MsgCommand", payload = {} }
  },
  recipients = {
    { type = "fixed", payload = { "{Self:GetFirstArg}" } }
  },
  nativeCommand = {
    enabled = true,
    data = {
      help = "Send a message to a new player",
      params = {}
    }
  },
  buildText = function(message, args)
    message.tags[1].text = string.format(message.tags[1].text, "{Placeholder:ServerId}", table.remove(args, 1))
    message.message.content = args and table.concat(args, " ") or "empty"
    return message
  end,
  ttl = nil -- nil: persistent, number: time-to-live ms
})
----------------------------------------------------------------------------------------
-- If your messages look all the same, something in this file is messed up,
-- default template overrides unknown templates.
-- P.D: Templates added through an export should still work though, unless malformed
----------------------------------------------------------------------------------------

-- Example template
addTemplate("example", {
  decor = {
    color = "#ffff", -- Default color: theme.brand
    text = "{Placeholder:ServerId}"
  },
  tags = {
    { color = "#ffff", text = "{cmd:name}" }, -- Default color: theme.brand
  },
  content_prefix = {
    content = "",
    color = "#ffff", -- Default color: theme.brand
  },
  message = {
    color = "#fff", -- Default color: theme.secondary
    content = nil 
  }
})

-- OOC template
addTemplate("ooc", {
  tags = {
    { text = "OOC" }, -- Default color: theme.brand
  },
  content_prefix = {
    content = "Kanuu",
  },
  message = {
    content = "{Self:GetArgs}"
  }
})

-- Legacy template
addTemplate("legacy", {
  tags = {
    { text = "Legacy" }, -- Default color: theme.brand
  },
  message = {
    content = nil
  }
})

-- ME template
addTemplate("me", {
  decor = { -- ?
    text = "ID {Placeholder:ServerId}"
  },
  tags = {
    { text = "ME" }, -- Default color: theme.brand
  },
  content_prefix = {
    content = "{Framework:GetName}",
  },
  message = {
    content = "{Self:GetArgs}"
  }
})

-- DO template
addTemplate("do", {
  background = "#17191D", -- Default color: theme.brand_two
  decor = { -- ?
    text = "ID {Placeholder:ServerId}",
    color = "#DEDEDE",
  },
  tags = {
    { text = "USER", color = "#652DBC" }, -- Default color: theme.brand
  },
  content_prefix = {
    color = "#DEDEDE",
    content = "{Framework:GetName}"
  },
  message = {
    content = "{Self:GetArgs}"
  }
})

-- Try template
addTemplate("try", {
  decor = { -- ?
    text = "ID {Placeholder:ServerId}"
  },
  tags = {
    { text = "TRY" }, -- Default color: theme.brand
  },
  content_prefix = {
    content = "{Framework:GetName}",
  },
  message = {
    content = nil
  }
})

-- Try template
addTemplate("msg", {
  tags = {
    { text = "MSG %s -> %s" }, -- Default color: theme.brand
  },
  content_prefix = {
    content = "{Placeholder:CfxName}",
  },
  message = {
    content = "{Self:GetArgs}"
  }
})
Secrets = {}

Secrets.DISCORD_WEBHOOK = ""