---@meta alerthelper

--------------------------------------------------------------------------------
-- alerthelper system pop-up processing rule module
--------------------------------------------------------------------------------

---@alias alerthelper_pattern string
---@alias alerthelper_button_match string|integer|string[]
---@alias alerthelper_text_field_match string|integer|string[]
---@alias alerthelper_text_field_values string|string[]|table<string, string>
---@alias alerthelper_condition_callback fun(alert:alerthelper_alert):boolean?
---@alias alerthelper_action_callback fun(alert:alerthelper_alert):any
---@alias alerthelper_log_callback fun(alert:alerthelper_alert)

---@class alerthelper_text_field*
---@field placeholder? string text box placeholder
---@field text? string Text box current text

---@class alerthelper_alert*
---@field title? string Pop-up window title
---@field message? string Pop-up content
---@field cancelButton? string Cancel button title
---@field preferredButton? string Preferred button title
---@field buttons? string[] Button title list
---@field textFields? alerthelper_text_field[]|alerthelper_text_field_values Text box list; fill value can be set when writing
---@field processName? string process name
---@field bundleIdentifier? string Application package name
---@field className? string Pop-up window class name
---@field parentClassName? string Parent object class name
---@field pointer? any Pop-up window object pointer
---@field parent? any parent object pointer
---@field source? string Pop-up source
local alert = {}

--- Click the button that assigns a title or sequence number.
---@param button string|integer Button title or serial number
function alert:clickButton(button) end

--- Click the Cancel button.
function alert:clickCancel() end

--- Click the Preferred button.
function alert:clickPreferred() end

---@class alerthelper_conditions*
---@field bundleIdentifier? alerthelper_pattern Apply package name pattern
---@field processName? alerthelper_pattern process name pattern
---@field parentClassName? alerthelper_pattern Parent object class name pattern
---@field className? alerthelper_pattern Pop-up window class name pattern
---@field source? alerthelper_pattern Pop-up source mode
---@field title? alerthelper_pattern title mode
---@field message? alerthelper_pattern content mode
---@field cancelButton? alerthelper_pattern Cancel button title mode
---@field preferredButton? alerthelper_pattern Preferred button title mode
---@field buttons? alerthelper_button_match Button matching; a string indicates that any button matches, a number indicates the number of buttons, and an array indicates that both quantity and order match.
---@field textFields? alerthelper_text_field_match Text box matching; the string indicates any placeholder match, the number indicates the number of text boxes, and the array indicates that both quantity and order match.

---@class alerthelper_actions*
---@field textFields? alerthelper_text_field_values Fill text box
---@field clickButton? string|integer Click to specify the button title or serial number
---@field clickCancel? boolean Click the cancel button
---@field clickPreferred? boolean Click the Preferred button
---@field log? boolean|alerthelper_log_callback Output log; true uses default logging function

---@class alerthelper_rule*
---@field name? string Rule name
---@field conditions? alerthelper_conditions*|alerthelper_condition_callback|false Match condition; unconditional match when omitted
---@field actions? alerthelper_actions*|alerthelper_action_callback Action after matching
---@field continue? boolean Whether to continue matching subsequent rules after matching
---@field wait? integer Number of milliseconds to delay action execution after matching

---@class alerthelper*
---@field _VERSION string module version
---@type alerthelper*
local M = {}

M._VERSION = "0.8.4"

--- Set the system pop-up processing rule list.
---
--- This module does not work properly in safe mode. Returns to the previous cache rule when the setting is successful.
---@param rules alerthelper_rule[] Rule list
---@return alerthelper_rule[]? last_rules Previous cache rule; nil when the tweak directory cannot be located
function M.setRules(rules) end

--- Read the previous cache rule.
---@return alerthelper_rule[]? rules Cache rule; nil if not present
function M.getRules() end

--- Clear system pop-up window handling rules.
function M.clearRules() end

--- Convert a string into a Lua pattern where every character matches normal text.
---@param str string raw string
---@return string pattern Escaped Lua pattern
function M.plainPattern(str) end

--- Generate a Lua pattern for exact equality matching.
---@param str string raw string
---@return string pattern Exactly matching Lua pattern
function M.equalPattern(str) end

return M
