
-- XXT main path
XXT_HOME_PATH = "<XXT_HOME_PATH>"

-- XXT executable file root path
XXT_SYSTEM_PATH = "<XXT_SYSTEM_PATH>"

-- XXT service program path
XXT_EXE_PATH = XXT_SYSTEM_PATH .. "/<XXT_EXE_NAME>"

-- XXT resource path
XXT_RES_PATH = XXT_HOME_PATH .. "/res"

-- XXT Lua module path
XXT_LUA_PATH = XXT_HOME_PATH .. "/lua"

-- XXT script path
XXT_SCRIPTS_PATH = XXT_HOME_PATH .. "/lua/scripts"

-- XXT C library path
XXT_LIB_PATH = XXT_LUA_PATH .. "/lib"

-- XXT log path
XXT_LOG_PATH = XXT_HOME_PATH .. "/log"

-- XXT additional daemon script path
XXT_DAEMONS_PATH = XXT_HOME_PATH .. "/daemons"

-- XXT Tesseract language data path
XXT_TESSDATA_PATH = XXT_HOME_PATH.."/tessdata"

-- XXT model data path
XXT_MODELS_PATH = XXT_HOME_PATH.."/models"

-- Is XXT a TrollStore version?
IS_TROLLSTORE_EDITION = "<IS_TROLLSTORE_EDITION>"

--- Output logs to development tools
--- @param argA any
--- @param argB any
---
---[Documentation](https://xxtouch.app/en/docs/handbook/develop-helper/nLog)
---
function nLog(argA, argB, ...) end

--------------------------------------------------------------------------------
-- Develop auxiliary modules
--------------------------------------------------------------------------------

--- Get the number of milliseconds that the current script has been executed
---@return integer elapsedMs Number of milliseconds executed
---
---[Documentation](https://xxtouch.app/en/docs/handbook/develop-helper/get_elapsed_ms)
---
function get_elapsed_ms() end

--- Get the jailbreak root path corresponding to the system root path
---@param systemPath? string System root path
---@return string jailbreakPath Jailbreak root path
---
---[Documentation](https://xxtouch.app/en/docs/handbook/develop-helper/jbroot)
---
function jbroot(systemPath) end

--- Get the system root path corresponding to the jailbreak root path
---@param jailbreakPath? string Jailbreak root path
---@return string systemPath System root path
---
---[Documentation](https://xxtouch.app/en/docs/handbook/develop-helper/rootfs)
---
function rootfs(jailbreakPath) end

---@class print*
---@field out fun():string buffer contents
print = {}

--- Print content to buffer
---@param ... any Variable parameters
---
---[Documentation](https://xxtouch.app/en/docs/handbook/develop-helper/print)
---
function print(...) end

--- Extract the contents of the print buffer
---@return string buffer buffer contents
---
---[Documentation](https://xxtouch.app/en/docs/handbook/develop-helper/print.out)
---
function print.out() end

--- Create a process to execute Lua code and block the current thread
---@param luacode string Lua code that needs to be executed. There is no thread module available in this environment.
---@param timeout_ms? integer Timeout in milliseconds, default 0 means there is no limit to running
---@return string? Standard output content
---@return boolean? Whether the execution is successful (end status is 0)
---@return string? End status text description
---@return integer? end status code
---@return string? Standard error content
function fork_dostring(luacode, timeout_ms) end

--------------------------------------------------------------------------------
-- control flow module
--------------------------------------------------------------------------------

--- Register a callback to be executed when the script exits
--- Using the same `name` will overwrite the registered callback; passing nil in `callback` means unregistering
--- This function is available since version 2025-07-05
---@param name string callback identifier
---@param callback? function Function executed when the script exits
---@return function? originalCallback A previously registered callback with the same name
---
---[Documentation](https://xxtouch.app/en/docs/handbook/control-flow/register_atexit)
---
function register_atexit(name, callback) end

os = os or {}

--- Restart the current script or jump to the specified script file
--- An error may be returned when the script path is passed in; if the call is successful, the function will not return
---@param scriptPath? string Script file path
---@return boolean? ok The success or failure of the operation (returned only on failure or if a path is passed in)
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/control-flow/os.restart)
---
function os.restart(scriptPath) end

--------------------------------------------------------------------------------
-- Analog accelerometer module
--------------------------------------------------------------------------------

---@class accelerometer*
accelerometer = {}

--- Simulate a shake
function accelerometer.shake() end

--- gravity direction upward
function accelerometer.rotate_home_on_top() end

--- Gravity direction to the left
function accelerometer.rotate_home_on_left() end

--- gravity direction downwards
function accelerometer.rotate_home_on_bottom() end

--- Gravity direction to the right
function accelerometer.rotate_home_on_right() end


--------------------------------------------------------------------------------
-- application module
--------------------------------------------------------------------------------

---@class app*
app = {}

---@alias app_permission_operation "get"|"set"|"reset"

---@class app_notification_permissions_info*
---@field allowsNotifications? boolean Whether notifications are allowed
---@field showsInNotificationCenter? boolean Whether to show in Notification Center
---@field showsInLockScreen? boolean Whether to show on the lock screen
---@field showsOnExternalDevices? boolean Whether to show on external devices
---@field showsMessagePreview? boolean Whether to show message previews
---@field alertType? integer Alert style
---@field pushSettings? integer Push settings
---@field authorizationStatus? integer Authorization status
---@field displayName? string Display name
---@field appName? string App name

---@class app_local_network_permissions_info*
---@field bundleIdentifier? string App identifier
---@field allowsLocalNetwork? boolean Whether local network access is allowed
---@field authorizationStatus? integer Authorization status, 0 undecided, 1 denied, 2 allowed
---@field denyMulticast? boolean Whether local network access is denied
---@field multicastPreferenceSet? boolean Whether the user preference has been set
---@field wifiBehavior? integer Wi-Fi behavior
---@field cellularBehavior? integer Cellular behavior

--- Get the app's bundle path
---@param appID string identifier
---@return string? bundle path
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.bundle_path)
---
function app.bundle_path(appID) end

--- Get the data container path of the App
---@param appID string identifier
---@return string? Data container path
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.data_path)
---
function app.data_path(appID) end

--- Get group information of App
---@param appID string identifier
---@return table Grouping information is a key-value pair in the form {group_id = data_path,...}
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.group_info)
---
function app.group_info(appID) end

--- Get App plug-in information
---@param appID string identifier
---@return table Plug-in information is a list in the form {{bid = "xxx", bundle_path= "xxx", data_path = "xxx"},...}
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.plugin_info)
---
function app.plugin_info(appID) end

--- Get the TEAM ID of the App
---@param appID string identifier
---@return string? TEAM ID
function app.team_id(appID) end

--- Set App’s TCC permissions
---@param appID string identifier
---@param service string Service ID
---@param state integer status value
---@return boolean operationSucceed Operation success or failure
---@return integer originalState original state value
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.set_tcc)
---
function app.set_tcc(appID, service, state) end

--- Get, set, or reset the app's notification permission information
--- This function is available in versions after 20260529 and requires iOS 14 or above
---@param appID string identifier
---@param operation? app_permission_operation Operation type, defaults to "get"
---@param info? app_notification_permissions_info* Permission information, only used for "set"
---@return app_notification_permissions_info*? info "get" operation returns permission information or nil; "set" / "reset" return no values
function app.notification_permissions(appID, operation, info) end

--- Get, set, or reset the app's local network permission information
--- This function is available in versions after 20260529 and requires iOS 14 or above
---@param appID string identifier
---@param operation? app_permission_operation Operation type, defaults to "get"
---@param value? boolean|integer|app_local_network_permissions_info* Whether to allow local network access or permission information, only used for "set"
---@return app_local_network_permissions_info*|boolean|nil result "get" operation returns permission information or nil; "set" / "reset" return whether the operation succeeded
function app.local_network_permissions(appID, operation, value) end

--- An app notification pops up
---@param appID string identifier
---@param title string Notification title
---@param content string Notification content
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.pop_banner)
---
function app.pop_banner(appID, title, content) end

--- Run App
---@param appID string identifier
---@return integer Running status
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.run)
---
function app.run(appID) end

--- Close App
---@param appID string|integer identifier or process number
---@return integer closed state
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.close)
---
function app.close(appID) end

--- Simulate swiping up to exit the app
---@param appID string identifier
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.quit)
---
function app.quit(appID) end

--- Check if the app is running
---@param appID string identifier
---@return boolean Running status
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.is_running)
---
function app.is_running(appID) end

--- Get the file descriptor and socket information opened by the App
---@param identifier string | integer identifier or process number
---@return table? fileInfo Open file list
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.lsof)
---
function app.lsof(identifier) end

--- Get the localized name of the App
---@param appID string identifier
---@return string? localized name
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.localized_name)
---
function app.localized_name(appID) end

--- Get app icon data
---@param appID string identifier
---@return string? PNG Image data
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.png_data_for_bid)
---
function app.png_data_for_bid(appID) end

--- Get the process ID of the running App
---@param appID string identifier
---@return integer process number
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.pid_for_bid)
---
function app.pid_for_bid(appID) end

--- Get the current memory consumption of the app
---@param appID string|integer identifier or process number
---@return number Memory usage
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.used_memory)
---
function app.used_memory(appID) end

--- Get the identifier of the front-end App
---@return string? identifier
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.front_bid)
---
function app.front_bid() end

--- Get the process number of the foreground App
---@return integer process number
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.front_pid)
---
function app.front_pid() end

--- Open a URL in the frontend
---@param URL string URL
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.open_url)
---
function app.open_url(URL) end

--- Open a URL using the frontend of an app
---@param bid string App identifier
---@param URL string URL
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.open_url)
---
function app.open_url(bid, URL) end

--- Get a list of App identifiers
---@return table identifier array
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.bundles)
---
function app.bundles() end

--- Get process list
---@return table process list
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.all_procs)
---
function app.all_procs() end

--- Install IPA
---@param ipaPath string file path
---@return boolean operationSucceed Operation success or failure
---@return string? failureReason Reason for failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.install)
---
function app.install(ipaPath) end

--- Uninstall an app
---@param appID string identifier
---@return boolean operationSucceed Operation success or failure
---@return string? failureReason Reason for failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/app/app.uninstall)
---
function app.uninstall(appID) end

--- Enter text into the front-end App. This function has been deprecated because it needs to be injected into the App process.
---@param text string text content
function app.input_text(text) end

--------------------------------------------------------------------------------
-- Cleanup module
--------------------------------------------------------------------------------

---@class clear*
clear = {}

--- Clean up a certain keychain information or a group of keychain information
---@param teamid string App Team ID
---
---[Documentation](https://xxtouch.app/en/docs/handbook/clear/clear.keychain)
---
function clear.keychain(teamid) end

--- Clear keychain information for all apps
---
---[Documentation](https://xxtouch.app/en/docs/handbook/clear/clear.all_keychain)
---
function clear.all_keychain() end

--- clear clipboard
function clear.pasteboard() end

--- Clear browser cookies
---
---[Documentation](https://xxtouch.app/en/docs/handbook/clear/clear.cookies)
---
function clear.cookies() end

--- Clear system cache
---
---[Documentation](https://xxtouch.app/en/docs/handbook/clear/clear.caches)
---
function clear.caches() end

--- Clear all local photos from the album
---
---[Documentation](https://xxtouch.app/en/docs/handbook/clear/clear.all_photos)
---
function clear.all_photos() end

--- Clean up archive data of an application
---@param appID string identifier
---@return boolean Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/clear/clear.app_data)
---
function clear.app_data(appID) end

--- Clean IDFA/V
---@param newIDFAs? string|table New IDFA or IDFAV list
---@return boolean operationSucceed Operation success or failure
---@return table? oldTab Old IDFAV table
---
---[Documentation](https://xxtouch.app/en/docs/handbook/clear/clear.idfav)
---
function clear.idfav(newIDFAs) end


--------------------------------------------------------------------------------
-- device module
--------------------------------------------------------------------------------

---@class device*
device = {}

--- Reset automatic lock screen countdown
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.reset_idle)
---
function device.reset_idle() end

--- Set automatic screen lock minutes
---@param minutes integer Number of minutes, 0 means never lock the screen
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.set_autolock_time)
---
function device.set_autolock_time(minutes) end

--- lock screen
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.lock_screen)
---
function device.lock_screen() end

--- Unlock screen
---@param password? string Lock screen password, no longer supported on iOS 8 or above
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.unlock_screen)
---
function device.unlock_screen(password) end

--- Get screen lock status
---@return boolean Whether to lock screen
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.is_screen_locked)
---
function device.is_screen_locked() end

--- Get the screen orientation of the foreground application
---@return integer rotation state
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.front_orien)
---
function device.front_orien() end

--- Lock screen rotation
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.lock_orien)
---
function device.lock_orien() end

--- Unlock screen rotation
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.unlock_orien)
---
function device.unlock_orien() end

--- Get screen rotation lock status
---@return boolean Whether to lock
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.is_orien_locked)
---
function device.is_orien_locked() end

--- Vibration equipment
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.vibrator)
---
function device.vibrator() end

--- Turn on AssistiveTouch
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.assistive_touch_on)
---
function device.assistive_touch_on() end

--- Turn off AssistiveTouch
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.assistive_touch_off)
---
function device.assistive_touch_off() end

--- Get AssistiveTouch switch status
---@return boolean switch status
function device.is_assistive_touch_on() end

--- Play sound in the background
---@param soundPath string sound file path
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.play_sound)
---
function device.play_sound(soundPath) end

--- Set device volume
---@param volume number Volume (0.0~1.0)
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.set_volume)
---
function device.set_volume(volume) end

--- Get device type
---@return string Device type
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.type)
---
function device.type() end

--- Get device name
---@return string Device name
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.name)
---
function device.name() end

--- Set device name
---@param name string Device name
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.set_name)
---
function device.set_name(name) end

--- Get device UDID
---@return string UDID
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.udid)
---
function device.udid() end

--- Get the serial number of the device
---@return string serial number
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.serial_number)
---
function device.serial_number() end

--- Get the device's Wi-Fi MAC address
---@return string Crooked Mike
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.wifi_mac)
---
function device.wifi_mac() end

--- Get the Bluetooth MAC address of the device
---@return string Brutimac
function device.bluetooth_mac() end

--- Get all interface IPs of the device
---@return table Interface information array
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.ifaddrs)
---
function device.ifaddrs() end

--- Get the remaining battery power of the current device
---@return number Power
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.battery_level)
---
function device.battery_level() end

--- Get the current device charging status
---@return string charging status
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.battery_state)
---
function device.battery_state() end

--- Get the backlight brightness value
---@return number Brightness value (0.0~1.0)
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.brightness)
---
function device.brightness() end

--- Set backlight brightness value
---@param value number Brightness value (0.0~1.0)
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.set_brightness)
---
function device.set_brightness(value) end

--- Turn on reduce dynamic effects
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.reduce_motion_on)
---
function device.reduce_motion_on() end

--- Turn off reduced dynamic effects
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.reduce_motion_off)
---
function device.reduce_motion_off() end

--- Get the switch status of reducing dynamic effects
--- @return boolean Get the switch status
function device.is_reduce_motion_on() end

--- Turn on the fade crossfade transition effect
function device.reduce_motion_slide_on() end

--- Turn off the fade crossfade transition effect
function device.reduce_motion_slide_off() end

--- Get the on/off status of the weakened crossfade transition effect
--- @return boolean Get the switch status
function device.is_reduce_motion_slide_on() end

--- Turn on Wi-Fi
function device.wifi_on() end

--- Turn off Wi-Fi
function device.wifi_off() end

--- Get Wi-Fi switch status
---@return boolean switch status
function device.is_wifi_on() end

--- Turn on device Wi-Fi
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.turn_on_wifi)
---
function device.turn_on_wifi() end

--- Turn off device Wi-Fi
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.turn_off_wifi)
---
function device.turn_off_wifi() end

--- Get current Wi-Fi information
---@return table? wifiInfo Wi-Fi information
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.wifi_info)
---
function device.wifi_info() end

--- Turn on cellular data
function device.data_on() end

--- Turn off cellular data
function device.data_off() end

--- Get cellular data switch status
---@return boolean switch status
function device.is_data_on() end

--- Turn on device cellular data
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.turn_on_data)
---
function device.turn_on_data() end

--- Turn off device cellular data
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.turn_off_data)
---
function device.turn_off_data() end

--- Turn on Bluetooth
function device.bluetooth_on() end

--- Turn off Bluetooth
function device.bluetooth_off() end

--- Get Bluetooth switch status
---@return boolean switch status
function device.is_bluetooth_on() end

--- Turn on device Bluetooth
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.turn_on_bluetooth)
---
function device.turn_on_bluetooth() end

--- Turn off device Bluetooth
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.turn_off_bluetooth)
---
function device.turn_off_bluetooth() end

--- Turn on airplane mode
function device.airplane_on() end

--- Turn off airplane mode
function device.airplane_off() end

--- Get airplane mode switch status
---@return boolean switch status
function device.is_airplane_on() end

--- Turn on device airplane mode
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.turn_on_airplane)
---
function device.turn_on_airplane() end

--- Turn off device airplane mode
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.turn_off_airplane)
---
function device.turn_off_airplane() end

--- Connect to currently selected VPN
function device.vpn_on() end

--- Disconnect the currently connected VPN
function device.vpn_off() end

--- Get VPN switch status
---@return boolean switch status
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.is_vpn_on)
---
function device.is_vpn_on() end

--- Open currently selected VPN
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.turn_on_vpn)
---
function device.turn_on_vpn() end

--- Disconnect the currently connected VPN
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.turn_off_vpn)
---
function device.turn_off_vpn() end

--- Turn on flash
---@return boolean Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.flash_on)
---
function device.flash_on() end

--- Turn off flash
---@return boolean Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.flash_off)
---
function device.flash_off() end

--- Get flash switch status
---@return boolean Whether to turn on
function device.is_flash_on() end

--- Join a wireless access point
---@param SSID string SSID
---@param password? string Password, the valid password length must be greater than or equal to 8
---@param timeout_ms? integer Timeout in milliseconds
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.join_wifi)
---
function device.join_wifi(SSID, password, timeout_ms) end

--- Forgot wireless access point
---@param SSID string SSID
---
---[Documentation](https://xxtouch.app/en/docs/handbook/device/device.forget_wifi)
---
function device.forget_wifi(SSID) end


--------------------------------------------------------------------------------
-- Dialog module
--------------------------------------------------------------------------------

---@class dialog*
dialog = {}

---@class Dialog*
Dialog = {}

--- Create a dialog box with no parameters
---@return Dialog* dialog box
---
---[Documentation](https://xxtouch.app/en/docs/handbook/dialog/new)
---
function dialog() end

--- Pop up a pop-up window prompt with only one OK button
---@param text? string content
---@param timeout_s? number timeout seconds
function dialog(text, timeout_s) end

--- Settings dialog box to configure partitions
---@param configName? string Configure partitions
---@return Dialog* dialog box
---
---[Documentation](https://xxtouch.app/en/docs/handbook/dialog/dialogm_set_config)
---
function Dialog:set_config(configName) end

--- Configure the automatic disappearing time of the dialog box
---@param timeout number timeout seconds
---@param shouldSubmit? boolean Submit or not
---@return Dialog* dialog box
---
---[Documentation](https://xxtouch.app/en/docs/handbook/dialog/dialogm_set_timeout)
---
function Dialog:set_timeout(timeout, shouldSubmit) end

--- Configure the title of the dialog box
---@param title string title text
---@return Dialog* dialog box
---
---[Documentation](https://xxtouch.app/en/docs/handbook/dialog/dialogm_set_title)
---
function Dialog:set_title(title) end

--- Configure the title of the dialog box close button
---@param title string title text
---@return Dialog* dialog box
function Dialog:set_close_title(title) end

--- Configure the title of the dialog submit button
---@param title string title text
---@return Dialog* dialog box
function Dialog:set_submit_title(title) end

--- Configure the size of the dialog box
--- Only valid for dialog of webview engine
---@param width integer Width
---@param height integer height
---@return Dialog* dialog box
---
---[Documentation](https://xxtouch.app/en/docs/handbook/dialog/dialogm_set_size)
---
function Dialog:set_size(width, height) end

--- Configure the position and size of the dialog box
--- Only valid for dialog of webview engine
---@param x integer Upper left abscissa
---@param y integer Upper left vertical coordinate
---@param width integer Width
---@param height integer height
---@return Dialog* dialog box
---
---[Documentation](https://xxtouch.app/en/docs/handbook/dialog/dialogm_set_frame)
---
function Dialog:set_frame(x, y, width, height) end

--- Configure the corner radius of the dialog box
--- Only valid for dialog of webview engine
---@param radius integer corner radius
---@return Dialog* dialog box
---
---[Documentation](https://xxtouch.app/en/docs/handbook/dialog/dialogm_set_corner_radius)
---
function Dialog:set_corner_radius(radius) end

--- Add a group to the dialog box
--- Only valid for XUI engine dialog
---@param groupName string Group name
---@return Dialog* dialog box
function Dialog:add_group(groupName) end

--- Add a label to the dialog box
---@param labelText string label text
---@param alignment? string Alignment
---@return Dialog* dialog box
---
---[Documentation](https://xxtouch.app/en/docs/handbook/dialog/dialogm_add_label)
---
function Dialog:add_label(labelText, alignment) end

--- Add a text box to the dialog box
---@param labelText string Title
---@param placeholder? string placeholder
---@return Dialog* dialog box
---
---[Documentation](https://xxtouch.app/en/docs/handbook/dialog/dialogm_add_input)
---
function Dialog:add_input(labelText, placeholder) end

--- Add a switch to the dialog box
---@param labelText string switch title
---@param defaultValue? boolean Default value
---@return Dialog* dialog box
---
---[Documentation](https://xxtouch.app/en/docs/handbook/dialog/dialogm_add_switch)
---
function Dialog:add_switch(labelText, defaultValue) end

--- Add a slider to the dialog box
---@param labelText string slider title
---@param opts table Option list {min, max, step}
---@param defaultValue? number Default value
---@return Dialog* dialog box
---
---[Documentation](https://xxtouch.app/en/docs/handbook/dialog/dialogm_add_range)
---
function Dialog:add_range(labelText, opts, defaultValue) end

--- Add a single-item selector to the dialog box
---@param labelText string Title
---@param optionList table Options list
---@param defaultValue? string Default value
---@return Dialog* dialog box
---
---[Documentation](https://xxtouch.app/en/docs/handbook/dialog/dialogm_add_picker)
---
function Dialog:add_picker(labelText, optionList, defaultValue) end

--- Add a radio group to the dialog box
---@param labelText string Title
---@param optionList table Options list
---@param defaultValue? string Default value
---@return Dialog* dialog box
---
---[Documentation](https://xxtouch.app/en/docs/handbook/dialog/dialogm_add_radio)
---
function Dialog:add_radio(labelText, optionList, defaultValue) end

--- Add a multi-select group to the dialog box
---@param labelText string Title
---@param optionList table Options list
---@param defaultList? table Default value list
---@return Dialog* dialog box
---
---[Documentation](https://xxtouch.app/en/docs/handbook/dialog/dialogm_add_checkbox)
---
function Dialog:add_checkbox(labelText, optionList, defaultList) end

--- Add a picture to the dialog box
---@param image ImageObject* pictures
---@return Dialog* dialog box
---
---[Documentation](https://xxtouch.app/en/docs/handbook/dialog/dialogm_add_image)
---
function Dialog:add_image(image) end

--- trigger callback function
--- Only valid for XUI engine dialog
---@param labelText string Title
---@param callbackFunc? function callback function
---@return Dialog* dialog box
function Dialog:add_button(labelText, callbackFunc) end

--- Pop up the dialog box and return the user's choices
---@return boolean didSubmit Submit or not
---@return table optionTab option association table
---
---[Documentation](https://xxtouch.app/en/docs/handbook/dialog/dialogm_show)
---
function Dialog:show() end

--- Get dialog configuration without popping up the dialog box
---@return boolean didSubmit Submit or not
---@return table optionTab option association table
---
---[Documentation](https://xxtouch.app/en/docs/handbook/dialog/dialogm_load)
---
function Dialog:load() end


--------------------------------------------------------------------------------
-- extended string module
--------------------------------------------------------------------------------

---@class string*
string = {}

--- Convert to hexadecimal text
---@param data string Data content
---@return string hexadecimal text
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.to_hex)
---
function string.to_hex(data) end

--- Convert back from hexadecimal text
---@param hexStr string hexadecimal text
---@return string Data content
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.from_hex)
---
function string.from_hex(hexStr) end

--- Convert GBK encoded text to UTF-8 encoded text
---@param encStr string GBK encoded string
---@return string? Text that can be used directly
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.from_gbk)
---
function string.from_gbk(encStr) end

--- Calculate MD5
---@param data string Data content
---@return string hexHash
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.md5)
---
function string.md5(data) end

--- Calculate SHA-1
---@param data string Data content
---@return string hexHash
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.sha1)
---
function string.sha1(data) end

--- Calculate SHA-256
---@param data string Data content
---@return string hexHash
function string.sha256(data) end

--- Calculate HMAC-SHA1
---@param data string Data content
---@param key string key
---@return string hexHash
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.hmac_sha1)
---
function string.hmac_sha1(data, key) end

--- Calculate HMAC-SHA256
---@param data string Data content
---@param key string key
---@return string hexHash
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.hmac_sha256)
---
function string.hmac_sha256(data, key) end

--- Calculate SHA-512
---@param data string Data content
---@return string hexHash
function string.sha512(data) end

--- encoding
---@param data string Data content
---@return string b64 text
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.base64_encode)
---
function string.base64_encode(data) end

--- Decode
---@param encStr string b64 text
---@return string Data content
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.base64_decode)
---
function string.base64_decode(encStr) end

--- Encryption
---@param data string Data content
---@param secret string key
---@return string Encrypted data
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.aes128_encrypt)
---
function string.aes128_encrypt(data, secret) end

--- Decrypt
---@param encData string Encrypted data
---@param secret string key
---@return string Data content
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.aes128_decrypt)
---
function string.aes128_decrypt(encData, secret) end

--- Encode URI string
---@param uri string Original URI
---@return string encoded Encoded URI
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.encode_uri)
---
function string.encode_uri(uri) end

--- Encode URI components
---@param component string original text
---@return string encoded Encoded text
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.encode_uri_component)
---
function string.encode_uri_component(component) end

--- Decode URI string
---@param encodedUri string Encoded URI
---@return string uri Decoded URI
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.decode_uri)
---
function string.decode_uri(encodedUri) end

--- Decode URI components
---@param encodedComponent string encoded text
---@return string component decoded text
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.decode_uri_component)
---
function string.decode_uri_component(encodedComponent) end

--- Split a text using delimiter rules
---@param haystack string Text to be split
---@param sep string delimiter
---@param maxCnt? integer Maximum number of returns
---@return table Split text array
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.split)
---
function string.split(haystack, sep, maxCnt) end

--- Determine whether the text begins with the specified prefix
---@param text string Detected text
---@param prefix string prefix
---@param position? integer Detect starting position
---@return boolean Does it match
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.starts_with)
---
function string.starts_with(text, prefix, position) end

--- Determine whether the text ends with the specified suffix
---@param text string Detected text
---@param suffix string suffix
---@param length? integer Detection length
---@return boolean Does it match
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.ends_with)
---
function string.ends_with(text, suffix, length) end

--- Remove whitespace characters on the left side of text
---@param text string preprocessing text
---@return string Processed text
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.ltrim)
---
function string.ltrim(text) end

--- Remove whitespace characters on the right side of text
---@param text string preprocessing text
---@return string Processed text
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.rtrim)
---
function string.rtrim(text) end

--- Remove whitespace characters from both sides of text
---@param text string preprocessing text
---@return string Processed text
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.trim)
---
function string.trim(text) end

--- Remove all whitespace characters from text
---@param text string preprocessing text
---@return string Processed text
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.atrim)
---
function string.atrim(text) end

--- left fill (alias)
---@param text string original text
---@param length integer target length
---@param padText? string Fill text
---@return string Completed text
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.lpad)
---
function string.lpad(text, length, padText) end

--- fill left
---@param text string preprocessing text
---@param padLen integer Complement the length
---@param padText? string Complete text
---@return string Processed text
function string.pad_start(text, padLen, padText) end

--- Right fill (alias)
---@param text string original text
---@param length integer target length
---@param padText? string Fill text
---@return string Completed text
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.rpad)
---
function string.rpad(text, length, padText) end

--- right fill
---@param text string preprocessing text
---@param padLen integer Complement the length
---@param padText? string Complete text
---@return string Processed text
function string.pad_end(text, padLen, padText) end

--- Remove UTF8-BOM before text
---@param text string preprocessing text
---@return string Processed text
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.strip_utf8_bom)
---
function string.strip_utf8_bom(text) end

--- Generate random text
---@param charPool string character pool
---@param charCnt integer Number of generated characters
---@return string random text
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.random)
---
function string.random(charPool, charCnt) end

--- Compare two version numbers
---@param verA string Version number 1
---@param verB string Version number 2
---@return integer Compare results
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-string/string.compare_version)
---
function string.compare_version(verA, verB) end


--------------------------------------------------------------------------------
-- Extended table module
--------------------------------------------------------------------------------

---@class table*
table = {}

--- Deep copy a table
---@param inTab table Incoming table
---@return table Pass in a copy of the table
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-table/table.deep_copy)
---
function table.deep_copy(inTab) end

--- Output to standard output
---@param inTab table association table
---@return string table text
function table.deep_print(inTab) end

--- Does not output to standard output, only returns a string
---@param inTab table association table
---@return string table text
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-table/table.deep_dump)
---
function table.deep_dump(inTab) end

--- Load a table from a string
---@param tabStr string table text
---@return table? association table
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ext-table/table.load_string)
---
function table.load_string(tabStr) end


--------------------------------------------------------------------------------
-- File operation module
--------------------------------------------------------------------------------

---@class file*
file = {}

---@class file.path*
file.path = {}

--- Determine whether a file or directory exists
---@param path string File or directory path
---@return boolean existence information
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.exists)
---
function file.exists(path) end

--- List all file names in the directory
---@param path string directory path
---@param deep_and_full? boolean Whether to list recursively and return the full path
---@return table? file list
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.list)
---
function file.list(path, deep_and_full) end

--- Get file attributes
---@param path string File or directory path
---@param fields? table | string Request fields
---@return table? attrs attribute table
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.attrs)
---
function file.attrs(path, fields) end

--- Get symbolic link properties
---@param path string File or directory path
---@param fields? table | string Request fields
---@return table? attrs attribute table
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.lattrs)
---
function file.lattrs(path, fields) end

--- Change current working directory
---@param path string directory path
---@return boolean ok Operation success or failure
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.chdir)
---
function file.chdir(path) end

--- Get the current working directory
---@return string? cwd current working directory
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.currentdir)
---
function file.currentdir() end

--- Get file size
---@param path string file path
---@return integer File size
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.size)
---
function file.size(path) end

--- Calculate MD5 value of file
---@param path string file path
---@return string? hash MD5 value
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.md5)
---
function file.md5(path) end

--- Calculate the SHA-1 value of a file
---@param path string file path
---@return string? hash SHA-1 value
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.sha1)
---
function file.sha1(path) end

--- Read data from file
---@param path string file path
---@return string? File content
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.reads)
---
function file.reads(path) end

--- Write data to file
---@param path string file path
---@param content string Content to be written
---@return boolean Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.writes)
---
function file.writes(path, content) end

--- Append data to the end of the file
---@param path string file path
---@param content string Content to be added
---@return boolean Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.appends)
---
function file.appends(path, content) end

--- Count the total number of lines in a text file
---@param path string file path
---@return integer Number of lines
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.line_count)
---
function file.line_count(path) end

--- Get the contents of the specified line of the text file
---@param path string file path
---@param lineNum integer Line number
---@return string? row content
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.get_line)
---
function file.get_line(path, lineNum) end

--- Set the content of the specified line of the text file
---@param path string file path
---@param lineNum integer Line number
---@param content string Content to be written
---@return boolean Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.set_line)
---
function file.set_line(path, lineNum, content) end

--- Insert content before the specified line in the text file
---@param path string file path
---@param lineNum integer Line number
---@param content string Content to be inserted
---@return boolean Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.insert_line)
---
function file.insert_line(path, lineNum, content) end

--- Remove specified lines from text file
---@param path string file path
---@param lineNum integer Line number
---@return boolean operationSucceed Operation success or failure
---@return string? deletedLine The contents of the deleted row
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.remove_line)
---
function file.remove_line(path, lineNum) end

--- Get all lines of a text file
---@param path string file path
---@return table row array
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.get_lines)
---
function file.get_lines(path) end

--- Write a sequential table transformation to a file line by line
---@param path string file path
---@param lineArr table row array
---@return boolean Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.set_lines)
---
function file.set_lines(path, lineArr) end

--- Insert a sequence table transformation line by line before the specified line in the file
---@param path string file path
---@param lineNum integer Line number
---@param lineArr table row array
---@return boolean Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.insert_lines)
---
function file.insert_lines(path, lineNum, lineArr) end

--- Delete a file or directory
---@param path string File or directory path
---@return boolean ok Operation success or failure
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.remove)
---
function file.remove(path) end

--- Copy a file or directory
---@param srcPath string source path
---@param dstPath string target path
---@param mode? "overwrite" | "o" | "merge" | "o" | "overwrite-merge" | "om" | "mo" Overwrite merge mode
---@return boolean ok Operation success or failure
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.copy)
---
function file.copy(srcPath, dstPath, mode) end

--- Move a file or directory
---@param srcPath string source path
---@param dstPath string target path
---@param mode? "overwrite" | "o" | "merge" | "o" | "overwrite-merge" | "om" | "mo" Overwrite merge mode
---@return boolean ok Operation success or failure
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.move)
---
function file.move(srcPath, dstPath, mode) end

--- Create a hard or symbolic link
---@param srcPath string Source file path
---@param dstPath string target file path
---@param symbolic? boolean Whether to create symbolic links
---@return boolean ok Operation success or failure
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.link)
---
function file.link(srcPath, dstPath, symbolic) end

--- Create directories recursively
---@param path string directory path
---@param uid? integer User ID
---@param gid? integer User group ID
---@param perm? integer | string Permissions
---@return boolean ok Operation success or failure
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.mkdir_p)
---
function file.mkdir_p(path, uid, gid, perm) end

--- Update file access and modification times
---@param path string file path
---@param accessTime? integer access timestamp
---@param modifyTime? integer Modify timestamp
---@return boolean ok Operation success or failure
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.touch)
---
function file.touch(path, accessTime, modifyTime) end

--- Pack a file or directory using ZIP
---@param zipPath string Output zip path
---@param entries table | string File list or directory path
---@param password? string Password
---@return boolean ok Operation success or failure
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.zip)
---
function file.zip(zipPath, entries, password) end

--- Unzip the ZIP file
---@param zipPath string zip file path
---@param targetPath string Decompression target path
---@param password? string Password
---@return boolean ok Operation success or failure
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.unzip)
---
function file.unzip(zipPath, targetPath, password) end

--- Search the file system for a file or directory
---@param pattern string | table Search mode
-- - **string (Glob mode)**:
-- - Use Unix shell-style glob patterns for matching. Paths are separated by `/`.
-- - Supported wildcards:
-- - `*`: matches zero or more of any characters in the current path component (does not match `/`).
-- - `?`: matches any character in the current path component (does not match `/`).
-- - `[...]`: Matches any single character specified within square brackets. Support:
-- - Character list: `[abc]` matches 'a', 'b', or 'c'.
-- - Character range: `[a-z]` matches any lowercase letter.
-- - Negation: `[!abc]` matches any character except 'a', 'b', 'c'.
-- - Special characters: To match `]`, `-`, `!` or `^` itself, you can put them at the beginning (except `]`, which can come after `!`) or escape them with `\` (although escaping may not be supported in this implementation, it is recommended to put them in a safe place).
-- - `\`: used to escape special characters (may have limited support in this implementation, use the above method in preference).
-- - The path separator `/` is used to separate path components, wildcards will not match across `/`.
-- - A `/` at the beginning of the path indicates an absolute path search.
-- - The `/` at the end of the path means that the last item matched must be a directory.
-- - Example:
-- - `"/var/log/*.log"`: Find all files ending with `.log` in the `/var/log/` directory.
-- - `"/Users/*/Documents/report?.doc"`: Find files named `report` plus an arbitrary character plus `.doc` in the `Documents` directory of all users.
-- - `"/etc/[a-c]*.conf"`: Search for files starting with 'a', 'b', or 'c' and ending with `.conf` in the `/etc/` directory.
-- - `"/usr/local/bin/"`: Looks for the `/usr/local/bin` directory itself (if it exists).
--
-- - **table (exact component mode)**:
-- - Provide a Lua array (table) where each element represents a level (component) of the path.
-- - Component type:
-- - `string`: Match the string exactly as a directory or file name.
-- - If the string starts with `/` (first component only), it represents an absolute path.
-- - If the string ends with `/`, it means that this level must match a directory.
-- - `table` (like `{ "lua_pattern" }`): Matches directory or file names using the provided Lua pattern string. The pattern automatically adds `^` and `$` to ensure an exact match of the entire component name.
-- - `function`: Provide a custom matching function `func(name)`. The function receives the directory or file name `name` as a parameter and needs to return `true` to indicate successful matching and `false` to indicate failure.
-- - Components are matched sequentially. The previous component must successfully match a directory (unless it is the last component) before it can continue to match the next component.
-- - Example:
-- - `{"/var/log/", {"^apache.*%.log$"}}`: Find all files starting with `apache` and ending with `.log` in the `/var/log/` directory.
-- - `{ "/Users/", function(name) return name:sub(1,1) ~= "." end, "Documents/" }`: Find the `Documents` directory under all non-hidden user directories.
-- - `{ "/", "tmp" }`: Find the `tmp` file or directory in the root directory.
--
---@return table An array (table) containing the full path strings of all matched files or directories. If no match is found, an empty list `{}` is returned
---
---[Documentation](https://xxtouch.app/en/docs/handbook/file/file.find)
---
function file.find(pattern) end

--- Break a path string into its component parts.
---@param path string The path string to be decomposed.
---@return table An array (table) containing the components of a path, or (nil, "Invalid path") if the path is invalid.
---@usage local components = file.path.components("/usr/local/bin") -- Return {"/", "usr", "local", "bin"}
function file.path.components(path) end

--- Returns the last component of a path string.
---@param path string Path string.
---@return string The last component of the path, or (nil, "Invalid path") if the path is invalid.
---@usage local last = file.path.last_component("/usr/local/bin") -- Return "bin"
---@usage local last = file.path.last_component("/") -- Return "/"
function file.path.last_component(path) end

--- Returns a new path string generated by removing the last path component.
---@param path string Original path string.
---@return string The new path string with the last component removed, or (nil, "Invalid path") if the path is invalid.
---@usage local parent = file.path.remove_last_component("/usr/local/bin") -- Return "/usr/local"
---@usage local parent = file.path.remove_last_component("/usr") -- Return "/"
---@usage local parent = file.path.remove_last_component("/") -- Return "/"
function file.path.remove_last_component(path) end

--- Returns a new path string generated by appending the specified path components to the recipient.
-- This function automatically handles path separators ('/') as needed.
---@param path string Base path string.
---@param component string The path components to append.
---@return string The new path string with the components appended, or (nil, "Invalid path") if any path or component is invalid.
---@usage local full_path = file.path.add_component("/usr/local", "bin") -- Return "/usr/local/bin"
---@usage local full_path = file.path.add_component("/", "tmp") -- Return "/tmp"
function file.path.add_component(path, component) end

--- Returns the file extension of the path string, if present.
-- The extension is the part of the last path component after the last period.
---@param path string Path string.
---@return string File extension (without '.'), or an empty string or (nil, "Invalid path") if the path is invalid or has no extension.
---@usage local ext = file.path.extension("/path/to/file.txt") -- Return "txt"
---@usage local ext = file.path.extension("/path/to/archive.tar.gz") -- Return "gz"
---@usage local ext = file.path.extension("/path/to/file") -- Return ""
function file.path.extension(path) end

--- Returns a new path string generated by removing the file extension if present.
---@param path string Original path string.
---@return string The new path string with the extension removed, or (nil, "Invalid path") if the path is invalid.
---@usage local base = file.path.remove_extension("/path/to/file.txt") -- Return "/path/to/file"
---@usage local base = file.path.remove_extension("/path/to/archive.tar.gz") -- Return "/path/to/archive.tar"
---@usage local base = file.path.remove_extension("/path/to/file") -- Return "/path/to/file"
function file.path.remove_extension(path) end

--- Returns a new path string generated by appending the specified file extension to the recipient.
-- If the original path already has an extension, the new extension will be appended to the existing extension (for example, file.txt -> file.txt.bak).
---@param path string Base path string.
---@param extension string The file extension to append (may or may not contain the leading '.').
---@return string A new path string with the extension appended, or (nil, "Invalid path" or "Invalid extension") if the path or extension is invalid.
---@usage local new_path = file.path.add_extension("/path/to/file", "txt") -- Return "/path/to/file.txt"
---@usage local new_path = file.path.add_extension("/path/to/file.tar", "gz") -- Return "/path/to/file.tar.gz"
function file.path.add_extension(path, extension) end

--- Returns a new path string generated by normalizing the path.
-- The normalization process involves parsing the "." and ".." components of the path, removing extraneous slashes, and trying to resolve symbolic links (but this function does not resolve them).
---@param path string Original path string.
---@return string Normalized path string, or (nil, "Invalid path") if the path is invalid.
---@usage local std_path = file.path.normalize("/usr/local/../bin/./script") -- Return "/usr/bin/script"
---@usage local std_path = file.path.normalize("//tmp///file/") -- Return "/tmp/file"
function file.path.normalize(path) end

--- Returns a new path string generated by resolving symbolic links in the path and normalizing the path.
-- This function fully resolves all symbolic links in the path until the final real path is obtained.
---@param path string The original path string containing the symbolic link.
---@return string The path string after parsing the symbolic link and normalizing it, returning (nil, "Invalid path") if the path is invalid or the parsing fails.
---@usage local real_path = file.path.resolve_symlinks("/tmp") -- May return "/var/tmp"
function file.path.resolve_symlinks(path) end


--------------------------------------------------------------------------------
-- FTP module
--------------------------------------------------------------------------------

---@class ftp*
ftp = {}

--- FTP file download
---@param remoteURL string URL
---@param localPath string local file path
---@param timeout? integer Connection timeout seconds
---@param shouldContinue? boolean Breakpoint resume mode
---@param blockCallback? function Chunked callback function
---@param bufSiz? integer buffer size
---@return boolean downloadSucceed Download success or failure
---@return table downloadDetail Download information
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ftp/ftp.download)
---
function ftp.download(remoteURL, localPath, timeout, shouldContinue, blockCallback, bufSiz) end

--- FTP file upload
---@param localPath string local file path
---@param remoteURL string URL
---@param timeout? integer Connection timeout seconds
---@param shouldContinue? boolean Breakpoint resume mode
---@param blockCallback? function Chunked callback function
---@param bufSiz? integer buffer size
---@return boolean uploadSucceed Upload success or failure
---@return table uploadDetail Upload information
---
---[Documentation](https://xxtouch.app/en/docs/handbook/ftp/ftp.upload)
---
function ftp.upload(localPath, remoteURL, timeout, shouldContinue, blockCallback, bufSiz) end


--------------------------------------------------------------------------------
-- HTTP module
--------------------------------------------------------------------------------

---@class http*
http = {}

--- Make a GET request
---@param optionsOrURL string|{url:string,timeout?:integer,headers?:table,params?:table,download_file?:string} URL or option
---@param timeout? integer timeout seconds
---@param headers? table Request header
---@return integer statusCode HTTP status code
---@return string headerJSON Return header JSON text
---@return string bodyData return body
---
---[Documentation](https://xxtouch.app/en/docs/handbook/http/http.get)
---
function http.get(optionsOrURL, timeout, headers) end

--- Make a POST request
---@param optionsOrURL string|{url:string,timeout?:integer,headers?:table,params?:table,multipart?:table,data?:string|table,json?:table,upload_file?:string,download_file?:string} URL or option
---@param timeout? integer timeout seconds
---@param headers? table Request header
---@param body? string Request body
---@return integer statusCode HTTP status code
---@return string headerJSON Return header JSON text
---@return string bodyData return body
---
---[Documentation](https://xxtouch.app/en/docs/handbook/http/http.post)
---
function http.post(optionsOrURL, timeout, headers, body) end

--- HTTP file download
---@param remoteURL string URL
---@param localPath string local file path
---@param timeout? integer Connection timeout seconds
---@param shouldContinue? boolean Breakpoint resume mode
---@param blockCallback? function Chunked callback function
---@param bufSize? integer buffer size
---@return boolean downloadSucceed Download success or failure
---@return table downloadDetail Download information
---
---[Documentation](https://xxtouch.app/en/docs/handbook/http/http.download)
---
function http.download(remoteURL, localPath, timeout, shouldContinue, blockCallback, bufSize) end

--- Make a HEAD request
---@param optionsOrURL string|{url:string,timeout?:integer,headers?:table,params?:table,download_file?:string} URL or option
---@param timeout? integer timeout seconds
---@param headers? table Request header
---@return integer statusCode HTTP status code
---@return string headerJSON Return header JSON text
---
---[Documentation](https://xxtouch.app/en/docs/handbook/http/http.head)
---
function http.head(optionsOrURL, timeout, headers) end

--- Make a DELETE request
---@param optionsOrURL string|{url:string,timeout?:integer,headers?:table,params?:table,multipart?:table,data?:string|table,json?:table,upload_file?:string,download_file?:string} URL or option
---@param timeout? integer timeout seconds
---@param headers? table Request header
---@return integer statusCode HTTP status code
---@return string headerJSON Return header JSON text
---@return string bodyData return body
---
---[Documentation](https://xxtouch.app/en/docs/handbook/http/http.delete)
---
function http.delete(optionsOrURL, timeout, headers) end

--- Encode the table as application/x-www-form-urlencoded
---@param formTable table Tables that need to be coded
---@return string formText Encoded form text
---
---[Documentation](https://xxtouch.app/en/docs/handbook/http/http.table_to_form_urlencoded)
---
function http.table_to_form_urlencoded(formTable) end

--- Decode application/x-www-form-urlencoded form text into a table
---@param formText string Need to decode form text
---@return table? formTable decoded table
function http.form_urlencoded_to_table(formText) end

--- Initiate a PUT request
---@param optionsOrURL string|{url:string,timeout?:integer,headers?:table,params?:table,multipart?:table,data?:string|table,json?:table,upload_file?:string,download_file?:string} URL or option
---@param timeout? integer timeout seconds
---@param headers? table Request header
---@param body? string Request body
---@return integer statusCode HTTP status code
---@return string headerJSON Return header JSON text
---@return string bodyData return body
---
---[Documentation](https://xxtouch.app/en/docs/handbook/http/http.put)
---
function http.put(optionsOrURL, timeout, headers, body) end

--- Make a MOVE request
---@param optionsOrURL string|{url:string,timeout?:integer,headers?:table,params?:table,multipart?:table,data?:string|table,json?:table,upload_file?:string,download_file?:string} URL or option
---@param timeout? integer timeout seconds
---@param headers? table Request header
---@param body? string Request body
---@return integer statusCode HTTP status code
---@return string headerJSON Return header JSON text
---@return string bodyData return body
function http.move(optionsOrURL, timeout, headers, body) end

--- Initiate LOCK request
---@param optionsOrURL string|{url:string,timeout?:integer,headers?:table,params?:table,multipart?:table,data?:string|table,json?:table,upload_file?:string,download_file?:string} URL or option
---@param timeout? integer timeout seconds
---@param headers? table Request header
---@param body? string Request body
---@return integer statusCode HTTP status code
---@return string headerJSON Return header JSON text
---@return string bodyData return body
function http.lock(optionsOrURL, timeout, headers, body) end

--- Make an UNLOCK request
---@param optionsOrURL string|{url:string,timeout?:integer,headers?:table,params?:table,multipart?:table,data?:string|table,json?:table,upload_file?:string,download_file?:string} URL or option
---@param timeout? integer timeout seconds
---@param headers? table Request header
---@param body? string Request body
---@return integer statusCode HTTP status code
---@return string headerJSON Return header JSON text
---@return string bodyData return body
function http.unlock(optionsOrURL, timeout, headers, body) end

--- Make a PROPPATCH request
---@param optionsOrURL string|{url:string,timeout?:integer,headers?:table,params?:table,multipart?:table,data?:string|table,json?:table,upload_file?:string,download_file?:string} URL or option
---@param timeout? integer timeout seconds
---@param headers? table Request header
---@param body? string Request body
---@return integer statusCode HTTP status code
---@return string headerJSON Return header JSON text
---@return string bodyData return body
function http.proppatch(optionsOrURL, timeout, headers, body) end

--- Make a COPY request
---@param optionsOrURL string|{url:string,timeout?:integer,headers?:table,params?:table,multipart?:table,data?:string|table,json?:table,upload_file?:string,download_file?:string} URL or option
---@param timeout? integer timeout seconds
---@param headers? table Request header
---@param body? string Request body
---@return integer statusCode HTTP status code
---@return string headerJSON Return header JSON text
---@return string bodyData return body
function http.copy(optionsOrURL, timeout, headers, body) end

--- Make MKCOL request
---@param optionsOrURL string|{url:string,timeout?:integer,headers?:table,params?:table,multipart?:table,data?:string|table,json?:table,upload_file?:string,download_file?:string} URL or option
---@param timeout? integer timeout seconds
---@param headers? table Request header
---@param body? string Request body
---@return integer statusCode HTTP status code
---@return string headerJSON Return header JSON text
---@return string bodyData return body
function http.mkcol(optionsOrURL, timeout, headers, body) end

--- Make a PATCH request
---@param optionsOrURL string|{url:string,timeout?:integer,headers?:table,params?:table,multipart?:table,data?:string|table,json?:table,upload_file?:string,download_file?:string} URL or option
---@param timeout? integer timeout seconds
---@param headers? table Request header
---@param body? string Request body
---@return integer statusCode HTTP status code
---@return string headerJSON Return header JSON text
---@return string bodyData return body
function http.patch(optionsOrURL, timeout, headers, body) end

--- Make a PROPFIND request
---@param optionsOrURL string|{url:string,timeout?:integer,headers?:table,params?:table,multipart?:table,data?:string|table,json?:table,upload_file?:string,download_file?:string} URL or option
---@param timeout? integer timeout seconds
---@param headers? table Request header
---@param body? string Request body
---@return integer statusCode HTTP status code
---@return string headerJSON Return header JSON text
---@return string bodyData return body
function http.propfind(optionsOrURL, timeout, headers, body) end

--- Make a TRACE request
---@param optionsOrURL string|{url:string,timeout?:integer,headers?:table,params?:table,multipart?:table,data?:string|table,json?:table,upload_file?:string,download_file?:string} URL or option
---@param timeout? integer timeout seconds
---@param headers? table Request header
---@param body? string Request body
---@return integer statusCode HTTP status code
---@return string headerJSON Return header JSON text
---@return string bodyData return body
function http.trace(optionsOrURL, timeout, headers, body) end


--------------------------------------------------------------------------------
-- CoreML module
--------------------------------------------------------------------------------

---@class coreml*
coreml = {}

--- Compile CoreML models natively
---@param modelPath string Model file path
---@return string? compiledPath Compiled model path
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.compile_model)
---
function coreml.compile_model(modelPath) end

--- Create a CoreML visual reasoner
---@param compiledModelPath string Compiled model path
---@return coreml_vision_request_object*? request visual reasoner object
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.new_vision_request)
---
function coreml.new_vision_request(compiledModelPath) end

---@class coreml_model_request_options*
---@field compiled_model_path string Compiled model path
---@field uses_cpu_only? boolean Whether to use CPU only

--- Create a CoreML model request object
---@param options coreml_model_request_options*|string Model request options or compiled model paths
---@return coreml_model_request_object* request model request object
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.new_model_request)
---
function coreml.new_model_request(options) end

--- Create a CoreML model request object
---@param options coreml_model_request_options*|string Model request options or compiled model paths
---@return coreml_model_request_object* request model request object
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.new_model_request)
---
function coreml.model_request(options) end

--- Create a CoreML model request object
---@param options coreml_model_request_options*|string Model request options or compiled model paths
---@return coreml_model_request_object* request model request object
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.new_model_request)
---
function coreml.session(options) end

--- Create a CoreML decoder
---@param schema table|string decode schema
---@return coreml_decoder* decoder decoder
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.multi_array_module)
---
function coreml.create_decoder(schema) end

--- Create CoreML/ONNX compatible tensors from images
---@param imageObj ImageObject* Picture object
---@param options? table Options
---@return coreml_multi_array*|onnxruntime_tensor* tensor Tensor
---@return onnxruntime_image_tensor_meta* meta Preprocessing meta information
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.multi_array_module)
---
function coreml.tensor_from_image(imageObj, options) end

--- Create CoreML/ONNX compatible batch tensor from image array
---@param images ImageObject*[] Image object array
---@param options? table Options
---@return coreml_multi_array*|onnxruntime_tensor* tensor Tensor
---@return onnxruntime_image_tensor_meta[] metas Preprocessing meta information
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.multi_array_module)
---
function coreml.tensor_from_images(images, options) end

---@param matrix coreml_multi_array*|onnxruntime_tensor* candidate matrix
---@param schema table|string decode schema
---@param options? table Options
---@return table candidates Candidate results
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.multi_array_module)
---
function coreml.decode_matrix_candidates(matrix, schema, options) end

---@param boxes coreml_multi_array*|onnxruntime_tensor* boxes
---@param scores coreml_multi_array*|onnxruntime_tensor* scores
---@param classIds coreml_multi_array*|onnxruntime_tensor* class ids
---@param keepIndices? coreml_multi_array*|onnxruntime_tensor* keep indices
---@return onnxruntime_box_record[] records Test records
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.multi_array_module)
---
function coreml.records_from_boxes(boxes, scores, classIds, keepIndices) end

---@param prototypes coreml_multi_array*|onnxruntime_tensor* prototypes
---@param coefficients coreml_multi_array*|onnxruntime_tensor* coefficients
---@param boxes coreml_multi_array*|onnxruntime_tensor* boxes
---@param width integer Image width
---@param height integer Image height
---@param options? table Options
---@return onnxruntime_mask_bitmap[] masks Mask list
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.multi_array_module)
---
function coreml.proto_masks(prototypes, coefficients, boxes, width, height, options) end

---@param lhs onnxruntime_mask_bitmap*|coreml_multi_array*|onnxruntime_tensor* left mask
---@param rhs onnxruntime_mask_bitmap*|coreml_multi_array*|onnxruntime_tensor* right mask
---@param options? table Options
---@return number iou Mask IoU
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.multi_array_module)
---
function coreml.mask_iou(lhs, rhs, options) end

---@param opts? table Options
---@return coreml_tracker* tracker tracker
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.multi_array_module)
---
function coreml.tracker(opts) end

---@class coreml_vision_request_object*
coreml_vision_request_object = {}

--- Reasoning about images using CoreML
---@param imageObj ImageObject* Pictures that require reasoning
---@return table result Inference results
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml_vision_request_objectm_predict)
---
function coreml_vision_request_object:predict(imageObj) end

---@return boolean ok Is it closed
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml_vision_request_objectm_predict)
---
function coreml_vision_request_object:close() end

---@return string[] names Enter name
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml_vision_request_objectm_predict)
---
function coreml_vision_request_object:input_names() end

---@return string[] names output name
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml_vision_request_objectm_predict)
---
function coreml_vision_request_object:output_names() end

---@class coreml_model_request_object*
coreml_model_request_object = {}

--- Reasoning with CoreML
---@param inputs table|string|ImageObject* input
---@param outputsOrOptions? string[]|table output name or option
---@param options? table Options
---@return table result Inference results
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml_model_request_object_methods)
---
function coreml_model_request_object:predict(inputs, outputsOrOptions, options) end

--- Reasoning with CoreML
---@param inputs table|string|ImageObject* input
---@param outputsOrOptions? string[]|table output name or option
---@param options? table Options
---@return table result Inference results
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml_model_request_object_methods)
---
function coreml_model_request_object:run(inputs, outputsOrOptions, options) end

---@param inputs table[] batch input
---@param outputsOrOptions? string[]|table output name or option
---@param options? table Options
---@return table result Inference results
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml_model_request_object_methods)
---
function coreml_model_request_object:predict_batch(inputs, outputsOrOptions, options) end

---@return boolean done Whether to complete the asynchronous request
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml_model_request_object_methods)
---
function coreml_model_request_object:is_done() end

---@return table result asynchronous results
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml_model_request_object_methods)
---
function coreml_model_request_object:results() end

---@return boolean ok Is it closed
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml_model_request_object_methods)
---
function coreml_model_request_object:close() end

---@return table metadata Model metadata
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml_model_request_object_methods)
---
function coreml_model_request_object:metadata() end

---@return boolean usesCpuOnly Whether to use CPU only
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml_model_request_object_methods)
---
function coreml_model_request_object:uses_cpu_only() end

---@return string computeUnits computing unit
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml_model_request_object_methods)
---
function coreml_model_request_object:compute_units() end

---@return string[] names Enter name
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml_model_request_object_methods)
---
function coreml_model_request_object:input_names() end

---@return string[] names output name
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml_model_request_object_methods)
---
function coreml_model_request_object:output_names() end

---@return table[] features Input features
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml_model_request_object_methods)
---
function coreml_model_request_object:input_features() end

---@return table[] features Output features
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml_model_request_object_methods)
---
function coreml_model_request_object:output_features() end

---@return table info Enter information
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml_model_request_object_methods)
---
function coreml_model_request_object:input_info() end

---@return table info Output information
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml_model_request_object_methods)
---
function coreml_model_request_object:output_info() end

---@return string[] labels Category label
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml_model_request_object_methods)
---
function coreml_model_request_object:class_labels() end

---@class coreml_decoder*
coreml_decoder = {}

---@param outputs table Model output
---@param options? table Options
---@return any result Decoding result
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.multi_array_module)
---
function coreml_decoder:decode(outputs, options) end

---@return string task Task name
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.multi_array_module)
---
function coreml_decoder:task() end

---@return table schema decode schema
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.multi_array_module)
---
function coreml_decoder:schema() end

---@class coreml_tracker*
coreml_tracker = {}

---@param detections table[] Test results
---@param options? table Options
---@return onnxruntime_track[] tracks Track results
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.multi_array_module)
---
function coreml_tracker:update(detections, options) end

---@return boolean ok Is it successful?
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.multi_array_module)
---
function coreml_tracker:reset() end

---@return onnxruntime_track[] tracks tracking status
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.multi_array_module)
---
function coreml_tracker:state() end

---@return boolean ok Is it successful?
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.multi_array_module)
---
function coreml_tracker:close() end

---@class coreml_multi_array*
coreml_multi_array = {}

---@return integer[] shape shape
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.multi_array_module)
---
function coreml_multi_array:shape() end

---@return string dataType data type
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.multi_array_module)
---
function coreml_multi_array:data_type() end

---@return integer count Number of elements
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.multi_array_module)
---
function coreml_multi_array:count() end

---@return integer[] strides step length
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.multi_array_module)
---
function coreml_multi_array:strides() end

---@return table data data sheet
---
---[Documentation](https://xxtouch.app/en/docs/handbook/coreml/coreml.multi_array_module)
---
function coreml_multi_array:to_table() end


--------------------------------------------------------------------------------
-- Image module
--------------------------------------------------------------------------------

---@class image*
image = {}

---@class ImageObject*
ImageObject = {}

--- Determine whether a value is an image object
---@param value any The value to be judged
---@return boolean Whether it is a picture object
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/image.is)
---
function image.is(value) end

--- Create a blank image object of specified size
---@param width integer wide
---@param height integer high
---@return ImageObject* image
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/image.new)
---
function image.new(width, height) end

--- Create a new text image object
---@param text string text
---@param opts? table Options table {font = font, size = font size, color = font color, alpha = font opacity, back_color = background color, back_alpha = background opacity}
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/image.new_text_image)
---
function image.new_text_image(text, opts) end

--- Create a picture object from a file
---@param imgPath string file path
---@return ImageObject* image
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/image.load_file)
---
function image.load_file(imgPath) end

--- Create a picture object from data
---@param imgData string image data
---@return ImageObject* image
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/image.load_data)
---
function image.load_data(imgData) end

--- Image stitching
---@param imageNameList table Image file name array
---@param outputPath string Output path
---@param direction? integer Splicing direction
---@param quality? number Build quality
---@return boolean Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/image.oper_merge)
---
function image.oper_merge(imageNameList, outputPath, direction, quality) end

--- Import an image file into the photo album
---@param imagePath string Image file path
function image.image_to_album(imagePath) end

--- Import a video file into the photo album
---@param videoPath string Video file path
function image.video_to_album(videoPath) end

--- Get the size of the image object
---@return integer width wide
---@return integer height high
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_size)
---
function ImageObject:size() end

--- Create a copy of the picture object from the picture object
---@return ImageObject* Image 2
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_copy)
---
function ImageObject:copy() end

--- Cut off part of the area to create a new image object
---@param left? integer left
---@param top? integer on
---@param right? integer right
---@param bottom? integer down
---@return ImageObject* Image 2
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_crop)
---
function ImageObject:crop(left, top, right, bottom) end

--- Destroy an image object
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_destroy)
---
function ImageObject:destroy() end

--- Save image object to photo album
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_save_to_album)
---
function ImageObject:save_to_album() end

--- Export image objects to PNG files or data
---@param imagePath string file path
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_save_to_png_file)
---
function ImageObject:save_to_png_file(imagePath) end

--- Export image objects to PNG files or data
---@return string PNG data
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_png_data)
---
function ImageObject:png_data() end

--- Export picture objects to JPEG files or data
---@param imagePath string file path
---@param quality? number Image quality
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_save_to_jpeg_file)
---
function ImageObject:save_to_jpeg_file(imagePath, quality) end

--- Export picture objects to JPEG files or data
---@param quality? number Image quality
---@return string JPEG data
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_jpeg_data)
---
function ImageObject:jpeg_data(quality) end

--- Rotate 90 degrees counterclockwise ⤴️
---@return ImageObject* image
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_turn_left)
---
function ImageObject:turn_left() end

--- Rotate 90 degrees clockwise ⤵️
---@return ImageObject* image
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_turn_right)
---
function ImageObject:turn_right() end

--- flip up and down
---@return ImageObject* image
function ImageObject:turn_upondown() end

--- Zoom picture object
---@param newWidth integer wide
---@param newHeight integer high
---@return ImageObject* image
function ImageObject:resize(newWidth, newHeight) end

--- OpenCV scaling image object
---@param newWidth integer wide
---@param newHeight integer high
---@return ImageObject* image
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_cv_resize)
---
function ImageObject:cv_resize(newWidth, newHeight) end

--- Get the color of a certain point in the picture object
---@param coordX integer abscissa
---@param coordY integer vertical coordinate
---@return integer color Color
---@return integer alpha opacity
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_get_color)
---
function ImageObject:get_color(coordX, coordY) end

--- Set the color of a certain point in the picture object
---@param coordX integer abscissa
---@param coordY integer vertical coordinate
---@param color integer Color
---@return ImageObject* image
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_set_color)
---
function ImageObject:set_color(coordX, coordY, color) end

--- color replacement
---@param origColor integer primary color
---@param replColor integer replacement color
---@param similarity integer primary color similarity
---@return ImageObject* image
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_replace_color)
---
function ImageObject:replace_color(origColor, replColor, similarity) end

--- Picture in picture
---@param smallImg ImageObject* small image
---@param opts? table Option table {left = upper left abscissa, top = upper left ordinate, alpha = opacity, background = {{color*, color shift*}, {color*, color shift*},...}}
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_draw_image)
---
function ImageObject:draw_image(smallImg, opts) end

--- OpenCV automatic binarization
---@param threshold? integer Binarization threshold
---@return ImageObject* image
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_cv_binaryzation)
---
function ImageObject:cv_binaryzation(threshold) end

--- Color cast binarization
---@param opts? table | string { [white_background = boolean], [csim_mode = boolean], [csim_algorithm = 0|1|2], { Color*, color cast*},... } or color cast string
---@return ImageObject* image
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_binaryzation)
---
function ImageObject:binaryzation(opts) end

--- Compare the difference area of another image using OpenCV
---@param other ImageObject* another picture object
---@param opts? table Ratio configuration {should_visualize = whether to visualize, approx_epsilon = contour approximation perimeter percentage}
---@return table diffShapes difference shape collection
---@return ImageObject*? visualizeImage Visualization images
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_cv_compare_image)
---
function ImageObject:cv_compare_image(other, opts) end

--- Convert an image into a collection of shape outlines
---@param opts? table Contour configuration {should_visualize = whether to visualize, closed = whether to close, blur_size = blur kernel, canny_threshold1 = edge minimum threshold, canny_threshold2 = edge maximum threshold, approx_epsilon = contour approximation perimeter percentage}
---@return table shapeList shape collection
---@return ImageObject*? visualizeImage Visualization images
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_cv_to_shapes)
---
function ImageObject:cv_to_shapes(opts) end

--- Find a given collection of shapes in a picture
---@param shapes table target shape collection
---@param opts? table Configuration {should_visualize = whether to visualize, closed = whether to close, min_area = minimum area, max_area = maximum area, blur_size = blur kernel, canny_threshold1 = edge minimum threshold, canny_threshold2 = edge maximum threshold, diff_threshold = difference threshold, approx_epsilon = contour approximation perimeter percentage}
---@return table matches Matched shape information
---@return ImageObject*? visualizeImage Visualization images
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_cv_find_shapes)
---
function ImageObject:cv_find_shapes(shapes, opts) end

--- Use OpenCV feature point matching to detect templates
---@param templates table Template collection, where the sequence element is a picture object and the field is configuration {should_visualize = whether to visualize, detector = feature detector, score_thresh = matching score threshold}
---@return table results Template detection results
---@return ImageObject*? visualizeImage Visualization images
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_cv_detect_templates)
---
function ImageObject:cv_detect_templates(templates) end

--- Use OpenCV to find images in images
---@param smallImg ImageObject* small image
---@return integer coordX abscissa
---@return integer coordY vertical coordinate
---@return number similarity match similarity
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_cv_find_image)
---
function ImageObject:cv_find_image(smallImg) end

--- Decode the QR code in the current picture
---@return string? text Recognize text
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_qr_decode)
---
function ImageObject:qr_decode() end

--- Picture multi-point color matching
---@param colors table Matching table {{abscissa*, ordinate*, color*}, {abscissa*, ordinate*, color*},...}
---@param similarity? integer Similarity
---@return boolean Is it an exact match?
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_is_colors)
---
function ImageObject:is_colors(colors, similarity) end

--- Find colors in pictures (multi-point similarity mode)
---@param opts table Match table {[find_order = search order], [find_all = whether to search multiple results], [max_results = maximum number of results], [max_miss = maximum number of misses allowed], {abscissa coordinate of starting point, ordinate of starting point, color of starting point[, similarity of starting point]}, {abscissa coordinate of offset point*, ordinate of offset point*, color of offset point*[, similarity of offset point*]}, {abscissa coordinate of offset point*, Offset point ordinate*, offset point color*[, offset point similarity*]},...}
---@param similarity? integer global similarity
---@param left? integer Search area upper left abscissa
---@param top? integer Search area upper left vertical coordinate
---@param right? integer Search area lower right abscissa
---@param bottom? integer Search area lower right vertical coordinate
---@return integer coordX abscissa
---@return integer coordY vertical coordinate
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_find_color)
---
function ImageObject:find_color(opts, similarity, left, top, right, bottom) end

--- Find the color in the picture (multi-point color cast mode)
---@param opts table Matching table {[find_order = search order], [find_all = whether to search multiple results], [max_results = maximum number of results], [max_miss = maximum number of misses allowed], {abscissa of starting point, ordinate of starting point, {color of starting point[, color deviation of starting point]}}, {abscissa of offset point*, ordinate of offset point*, {color of offset point*, color deviation of offset point*}}, {abscissa of offset point*, Offset point ordinate*, {offset point color*, offset point color shift*}},...}
---@param left? integer Search area upper left abscissa
---@param top? integer Search area upper left vertical coordinate
---@param right? integer Search area lower right abscissa
---@param bottom? integer Search area lower right vertical coordinate
---@return integer coordX abscissa
---@return integer coordY vertical coordinate
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_find_color)
---
function ImageObject:find_color(opts, left, top, right, bottom) end

--- Find a picture within a picture
---@param smallImg ImageObject* | string subimage or subimage path
---@param confidence_threshold? number | {find_all? : boolean, confidence_threshold? : number, mask? : ImageObject*, downscale? : number, should_visualize? : boolean} similarity or options
---@param left? integer Search area left boundary
---@param top? integer Search area upper boundary
---@param right? integer Search area right boundary
---@param bottom? integer Search area lower boundary
---@return integer | table coordX abscissa
---@return integer coordY vertical coordinate
---@return integer resultSimilarity Result similarity
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_find_image)
---
function ImageObject:find_image(smallImg, confidence_threshold, left, top, right, bottom) end

--- Optical character recognition of images
---@param lang_opt? string | table Language options
---@param bin_opt? table | string | boolean Binarization options
---@return string Recognition result string list
---@return table Details of the recognition results, including the coordinates of the recognized area
---
---[Documentation](https://xxtouch.app/en/docs/handbook/image/imagem_ocr_text)
---
function ImageObject:ocr_text(lang_opt, bin_opt) end

--- Use a bitmap font to perform OCR on the image and return the recognized text and character information.
---@param md MatrixDict* font object
---@param opts? number | table similarity or option list
--- The options table supports fields:
--- * `sim` number similarity threshold, ranging from 0 to 100, default 98.
--- * `nms` boolean whether to enable non-maximum suppression, the default is true.
--- * `nms_threshold` number Non-maximum suppression threshold, default 0.2, automatically set to 0 when `nms` is false.
---@return string text Recognition results separated by newline
---@return table boxes Recognized character array, each item is {word:string, x:integer, y:integer, w:integer, h:integer}
--- Among them, x=rect.top, y=rect.left, w/h are rect.bottom-rect.top, rect.right-rect.left respectively; the score field is not included.
function ImageObject:dm_ocr(md, opts) end

--- Search the specified string in the image and return the target starting coordinates and matching character information.
---@param md MatrixDict* font object
---@param sim_or_opts? number | string | table When it is number, it represents similarity; when it is string, it represents target text; when it is table, it represents options.
---@param keyword? string When `sim_or_opts` is number, this parameter is the string to be searched, and can be ignored in other cases.
--- The options table supports fields:
--- * `sim` number similarity threshold, ranging from 0 to 100, default 98.
--- * `nms` boolean whether to enable non-maximum suppression, the default is true.
--- * `nms_threshold` number Non-maximum suppression threshold, default 0.2.
--- * `find` string | table specifies one or more target strings.
---@return integer coordX The abscissa of the target found (returns -1 if not found)
---@return integer coordY The ordinate of the found target (returns -1 if not found)
---@return table boxes Hit character table, the format of each item is the same as `ImageObject:dm_ocr`.
--- When the parameter is illegal, -1, -1 and an empty list are also returned.
function ImageObject:dm_find_str(md, sim_or_opts, keyword) end


--------------------------------------------------------------------------------
-- Matrix font module
--------------------------------------------------------------------------------

---@class matrix_dict*
matrix_dict = {}

---@class MatrixDict*
MatrixDict = {}

--- Create a new empty bitmap font library
---@return MatrixDict* dict font object
function matrix_dict.new() end

--- Load dot matrix information from file to create font library
---@param filename string File path, the content is dot matrix information, one per line
---@return MatrixDict*|nil dict font object
---@return string? errMsg Error description when opening fails
function matrix_dict.load_file(filename) end

--- Load dot matrix information from string to create font library
---@param matrixStr string Dot matrix information string, which can contain multiple lines
---@return MatrixDict* dict font object
function matrix_dict.load_string(matrixStr) end

--- Copy current font
---@return MatrixDict* newDict New font
function MatrixDict:copy() end

--- Append string dot matrix information to the font library
---@param matrixStr string Dot matrix information string, which can contain multiple lines
---@return integer addedCount Number of new entries (duplicate keys will not be counted)
function MatrixDict:add_with_string(matrixStr) end

--- Append the dot matrix information in the file to the font library
---@param filename string File path, the content is dot matrix information
---@return integer addedCount Number of new entries (duplicate keys will not be counted)
function MatrixDict:add_with_file(filename) end

--- Append the contents of another font to the current font
---@param other MatrixDict* another font object
---@return integer addedCount Number of new entries (duplicate keys will not be counted)
function MatrixDict:add_with_dict(other) end

--- Get the number of entries in the current font
---@return integer count Number of entries
function MatrixDict:size() end

--- Export all original bitmap strings of the current font (spliced according to newlines)
---@return string matrices One row per lattice (traversal order is hash iteration, non-sorting)
function MatrixDict:dump() end

--- Delete a dot matrix from the font library
---@param matrixStr string Original dot matrix information (matching key)
---@return boolean removed Is deletion successful?
function MatrixDict:remove(matrixStr) end


--------------------------------------------------------------------------------
-- JSON module
--------------------------------------------------------------------------------

---@class json*
json = {}

--- NULL constant in JSON
json.null = nil

--- Dump Lua values as JSON text
---@param value any value
---@return string JSON text
---
---[Documentation](https://xxtouch.app/en/docs/handbook/json/json.encode)
---
function json.encode(value) end

--- Load JSON text as Lua value
---@param jsonStr string JSON text
---@return any | nil value
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/json/json.decode)
---
function json.decode(jsonStr) end


--------------------------------------------------------------------------------
-- Analog button module
--------------------------------------------------------------------------------

---@class key*
key = {}

--- Simulate pressing a physical button
---@param keyCode integer Key code
---
---[Documentation](https://xxtouch.app/en/docs/handbook/key/key.press)
---
function key.press(keyCode) end

--- Simulate pressing a physical button
---@param keyCode integer Key code
---
---[Documentation](https://xxtouch.app/en/docs/handbook/key/key.down)
---
function key.down(keyCode) end

--- Release a pressed physical button
---@param keyCode integer Key code
---
---[Documentation](https://xxtouch.app/en/docs/handbook/key/key.up)
---
function key.up(keyCode) end

--- Simulate typing text
---@param text string text
---@param delay? integer Delay per key
---@param shift_delay? integer Used to enter uppercase letters or special symbols. You need to hold down the Shift key to enter text. Press Shift to delay the pop-up.
---
---[Documentation](https://xxtouch.app/en/docs/handbook/key/key.send_text)
---
function key.send_text(text, delay, shift_delay) end


--------------------------------------------------------------------------------
-- Clipboard module
--------------------------------------------------------------------------------

---@alias pasteboard_item table<string, string>
---@alias pasteboard_items pasteboard_item|pasteboard_item[]

---@class pasteboard_write_options*
---@field local_only? boolean Only saved locally, supported by iOS 10 and above
---@field expiration_date? number Unix Timestamp in seconds, supported by iOS 10 and above

---@class pasteboard*
pasteboard = {}

--- Get data from clipboard
---@param utiType? string Generic type identifier
---@return string data
---
---[Documentation](https://xxtouch.app/en/docs/handbook/pasteboard/pasteboard.read)
---
function pasteboard.read(utiType) end

--- Write content to clipboard
--- When passing in a clipboard item or a list of clipboard items, multiple format representations can be provided for the same clipboard item
---@param data string|pasteboard_items Data, clipboard item, or list of clipboard items
---@param utiTypeOrOptions? string|pasteboard_write_options* Generic type identifier or option
---@return boolean ok Is it successful?
---
---[Documentation](https://xxtouch.app/en/docs/handbook/pasteboard/pasteboard.write)
---
function pasteboard.write(data, utiTypeOrOptions) end

--- Write clipboard items
--- This function can only be used in versions after 20260428
---@param itemOrItems pasteboard_items Clipboard item or list of clipboard items
---@param options? pasteboard_write_options* Options
---@return boolean ok Is it successful?
---
---[Documentation](https://xxtouch.app/en/docs/handbook/pasteboard/pasteboard.write_items)
---
function pasteboard.write_items(itemOrItems, options) end

--- Get information about all data items in the clipboard
---@return table dataItems Data item information in the clipboard
function pasteboard.dump() end

--- Get all data types in the clipboard
---@return table types List of data types
function pasteboard.types() end

--- Clear the clipboard and return the original content
---@return table dataItems Data in clipboard
---
---[Documentation](https://xxtouch.app/en/docs/handbook/pasteboard/pasteboard.clear)
---
function pasteboard.clear() end


--------------------------------------------------------------------------------
-- Property sheet module
--------------------------------------------------------------------------------

---@class plist*
plist = {}

--- Read attribute table file
---@param path string file path
---@return table? table
---
---[Documentation](https://xxtouch.app/en/docs/handbook/plist/plist.read)
---
function plist.read(path) end

--- Write property table file
---@param path string file path
---@param tab table table
---@param fmt? "xml" | "binary" | "openstep" Property table data format, default "xml"
---@return boolean Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/plist/plist.write)
---
function plist.write(path, tab, fmt) end

--- Load attribute table data as Lua table
---@param data string attribute table data
---@return table? table
---
---[Documentation](https://xxtouch.app/en/docs/handbook/plist/plist.load)
---
function plist.load(data) end

--- Dump Lua table to property table data
---@param tab table table
---@param fmt "xml" | "binary" | "openstep" Data format, default "xml"
---@return string attribute table data
---
---[Documentation](https://xxtouch.app/en/docs/handbook/plist/plist.dump)
---
function plist.dump(tab, fmt) end

--- Attribute table data format conversion
---@param data string attribute table data
---@param fmt? "xml" | "binary" | "openstep" Property table data format, default "xml"
---@return string? convertedData Converted attribute table data
---
---[Documentation](https://xxtouch.app/en/docs/handbook/plist/plist.data_convert)
---
function plist.data_convert(data, fmt) end


--------------------------------------------------------------------------------
-- process dictionary module
--------------------------------------------------------------------------------

--- Store values in process dictionary
---@param key string Key name
---@param value string value
---@return string Returns the old value at this key position, or an empty string if there is none
---
---[Documentation](https://xxtouch.app/en/docs/handbook/proc/proc_put)
---
function proc_put(key, value) end

--- View the values stored in the process dictionary
---@param key string Key name
---@return string Returns the value stored at the key position, or an empty string if there is no value at the key position.
---
---[Documentation](https://xxtouch.app/en/docs/handbook/proc/proc_get)
---
function proc_get(key) end

--- Execute process dictionary transaction code
---@param code string Transaction Lua code
---@return string? result Return content
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/proc/proc_dict_run)
---
function proc_dict_run(code) end

--- Push a value to the end of the process queue dictionary
---@param key string Key name
---@param value string value
---@return integer Current queue length
---
---[Documentation](https://xxtouch.app/en/docs/handbook/proc/proc_queue_push)
---
function proc_queue_push(key, value) end

--- Pop a value from the end of the process queue dictionary
---@param key string Key name
---@return string Returns the popped value, or an empty string if the queue does not exist or is empty
---
---[Documentation](https://xxtouch.app/en/docs/handbook/proc/proc_queue_pop)
---
function proc_queue_pop(key) end

--- Push a value to the end of the process queue dictionary
---@param key string Key name
---@param value string value
---@return integer Current queue length
---
---[Documentation](https://xxtouch.app/en/docs/handbook/proc/proc_queue_push_back)
---
function proc_queue_push_back(key, value) end

--- Push a value to the head of the process queue dictionary
---@param key string Key name
---@param value string value
---@return integer Current queue length
---
---[Documentation](https://xxtouch.app/en/docs/handbook/proc/proc_queue_push_front)
---
function proc_queue_push_front(key, value) end

--- Pop a value from the end of the process queue dictionary
---@param key string Key name
---@return string Returns the popped value, or an empty string if the queue does not exist or is empty
---
---[Documentation](https://xxtouch.app/en/docs/handbook/proc/proc_queue_pop_back)
---
function proc_queue_pop_back(key) end

--- Pop a value from the head of the process queue dictionary
---@param key string Key name
---@return string Returns the popped value, or an empty string if the queue does not exist or is empty
---
---[Documentation](https://xxtouch.app/en/docs/handbook/proc/proc_queue_pop_front)
---
function proc_queue_pop_front(key) end

--- Read all values in the process queue dictionary
---@param key string Key name
---@return table values value set
---
---[Documentation](https://xxtouch.app/en/docs/handbook/proc/proc_queue_read)
---
function proc_queue_read(key) end

--- Pop all specified values from the process queue dictionary
---@param key string Key name
---@param value string Specify value
---@return integer count Number of pop-ups
---
---[Documentation](https://xxtouch.app/en/docs/handbook/proc/proc_queue_pop_value)
---
function proc_queue_pop_value(key, value) end

--- Count the number of specific values in the process queue dictionary
---@param key string Key name
---@param value string Specify value
---@return integer count number
---
---[Documentation](https://xxtouch.app/en/docs/handbook/proc/proc_queue_count_value)
---
function proc_queue_count_value(key, value) end

--- Pop all values from process queue dictionary
---@param key string Key name
---@return table Returns a list of popped values, or an empty list if the queue does not exist or is empty
---
---[Documentation](https://xxtouch.app/en/docs/handbook/proc/proc_queue_clear)
---
function proc_queue_clear(key) end

--- Get the size of the process queue dictionary
---@param key string Key name
---@return integer Current queue length
---
---[Documentation](https://xxtouch.app/en/docs/handbook/proc/proc_queue_size)
---
function proc_queue_size(key) end

--------------------------------------------------------------------------------
-- screen module
--------------------------------------------------------------------------------

---@class screen*
screen = {}

--- Initialize the rotating coordinate system
---@param coordinate integer coordinate system
---@return integer Original coordinate system
---
---[Documentation](https://xxtouch.app/en/docs/handbook/screen/screen.init)
---
function screen.init(coordinate) end

--- Initialize the rotating coordinate system (Home below)
---@return integer Original coordinate system
---
---[Documentation](https://xxtouch.app/en/docs/handbook/screen/screen.init)
---
function screen.init_home_on_bottom() end

--- Initialize the rotating coordinate system (Home is on the right)
---@return integer Original coordinate system
---
---[Documentation](https://xxtouch.app/en/docs/handbook/screen/screen.init)
---
function screen.init_home_on_right() end

--- Initialize the rotating coordinate system (Home is on the left)
---@return integer Original coordinate system
---
---[Documentation](https://xxtouch.app/en/docs/handbook/screen/screen.init)
---
function screen.init_home_on_left() end

--- Initialize the rotating coordinate system (Home is on top)
---@return integer Original coordinate system
---
---[Documentation](https://xxtouch.app/en/docs/handbook/screen/screen.init)
---
function screen.init_home_on_top() end

--- Coordinate rotation conversion
---@param coordX integer abscissa
---@param coordY integer vertical coordinate
---@param direction integer direction of rotation
---@return integer newCoordX The horizontal coordinate after rotation
---@return integer newCoordY Rotated vertical coordinate
---
---[Documentation](https://xxtouch.app/en/docs/handbook/screen/screen.rotate_xy)
---
function screen.rotate_xy(coordX, coordY, direction) end

--- Reverse coordinate rotation transformation
---@param coordX integer original abscissa
---@param coordY integer Original vertical coordinate
---@param direction integer Original coordinate rotation direction
---@return integer portraitX Corresponding vertical screen horizontal coordinates
---@return integer portraitY The corresponding vertical coordinate of the vertical screen
---
---[Documentation](https://xxtouch.app/en/docs/handbook/screen/screen.unrotate_xy)
---
function screen.unrotate_xy(coordX, coordY, direction) end

--- Get screen zoom factor
---@return number scaleFactor screen scaling factor
---
---[Documentation](https://xxtouch.app/en/docs/handbook/screen/screen.scale_factor)
---
function screen.scale_factor() end

--- Get screen size
---@return integer screenWidth screen width
---@return integer screenHeight screen height
---
---[Documentation](https://xxtouch.app/en/docs/handbook/screen/screen.size)
---
function screen.size() end

--- keep screen
---@return integer Get screen content count
---
---[Documentation](https://xxtouch.app/en/docs/handbook/screen/screen.keep)
---
function screen.keep() end

--- Exit screen hold state
---@return integer Get screen content count
---
---[Documentation](https://xxtouch.app/en/docs/handbook/screen/screen.unkeep)
---
function screen.unkeep() end

--- Get the color of a certain point on the screen
---@param coordX integer abscissa
---@param coordY integer vertical coordinate
---@return integer color value
---
---[Documentation](https://xxtouch.app/en/docs/handbook/screen/screen.get_color)
---
function screen.get_color(coordX, coordY) end

--- Get the color RGB of a certain point on the screen
---@param coordX integer abscissa
---@param coordY integer vertical coordinate
---@return integer red red
---@return integer green green
---@return integer blue blue
---
---[Documentation](https://xxtouch.app/en/docs/handbook/screen/screen.get_color_rgb)
---
function screen.get_color_rgb(coordX, coordY) end

--- Screen multi-point color matching
---@param colors table Color table {{abscissa*, ordinate*, color*}, {abscissa*, ordinate*, color*},...}
---@param similarity? integer Similarity
---@return boolean Is it an exact match?
---
---[Documentation](https://xxtouch.app/en/docs/handbook/screen/screen.is_colors)
---
function screen.is_colors(colors, similarity) end

--- Multi-point similarity mode color finding
---@param opts table Matching table {[find_all = whether to search multiple results], [max_results = maximum number of results], [max_miss = maximum number of misses allowed], {abscissa coordinate of starting point, ordinate of starting point, color of starting point[, similarity of starting point]}, {abscissa coordinate of offset point*, ordinate of offset point*, color of offset point*[, similarity of offset point*]}, {abscissa coordinate of offset point*, ordinate of offset point*, Offset point color*[, offset point similarity*]},...}
---@param similarity? integer global similarity
---@param left? integer Search area left boundary
---@param top? integer Search area upper boundary
---@param right? integer Search area right boundary
---@param bottom? integer Search area lower boundary
---@return integer coordX abscissa
---@return integer coordY vertical coordinate
---
---[Documentation](https://xxtouch.app/en/docs/handbook/screen/screen.find_color-co)
---
function screen.find_color(opts, similarity, left, top, right, bottom) end

--- Multi-point color cast mode to find colors
---@param opts table Matching table {[find_all = whether to search multiple results], [max_results = maximum number of results], [max_miss = maximum number of misses allowed], {abscissa coordinate of starting point, ordinate of starting point, {color of starting point[, color deviation of starting point]}}, {abscissa coordinate of offset point*, ordinate of offset point*, {color of offset point*, color deviation of offset point*}}, {abscissa coordinate of offset point*, ordinate of offset point*, {Offset point color*, Offset point color shift*}},...}
---@param left? integer Search area left boundary
---@param top? integer Search area upper boundary
---@param right? integer Search area right boundary
---@param bottom? integer Search area lower boundary
---@return integer coordX abscissa
---@return integer coordY vertical coordinate
---
---[Documentation](https://xxtouch.app/en/docs/handbook/screen/screen.find_color-cs)
---
function screen.find_color(opts, left, top, right, bottom) end

--- Get screen content
---@param left? integer left
---@param top? integer on
---@param right? integer right
---@param bottom? integer down
---@return ImageObject* screen content
---
---[Documentation](https://xxtouch.app/en/docs/handbook/screen/screen.image)
---
function screen.image(left, top, right, bottom) end

--- Screen image search
---@param smallImg ImageObject* | string subimage or subimage path
---@param confidence_threshold? number | {find_all? : boolean, confidence_threshold? : number, mask? : ImageObject*, downscale? : number, should_visualize? : boolean} similarity or options
---@param left? integer Search area left boundary
---@param top? integer Search area upper boundary
---@param right? integer Search area right boundary
---@param bottom? integer Search area lower boundary
---@return integer | table coordX abscissa
---@return integer coordY vertical coordinate
---@return integer resultSimilarity Result similarity
---
---[Documentation](https://xxtouch.app/en/docs/handbook/screen/screen.find_image)
---
function screen.find_image(smallImg, confidence_threshold, left, top, right, bottom) end

--- Screen area optical character recognition
---@param left? integer abscissa left boundary
---@param top? integer Upper boundary of ordinate
---@param right? integer abscissa right boundary
---@param bottom? integer ordinate lower boundary
---@param lang_opt? string | table Language options
---@param bin_opt? table | string | boolean Binarization options
---@return string Recognize result string
---@return table Details of the recognition results, including the coordinates of the recognized area
---
---[Documentation](https://xxtouch.app/en/docs/handbook/screen/screen.ocr_text)
---
function screen.ocr_text(left, top, right, bottom, lang_opt, bin_opt) end

--------------------------------------------------------------------------------
-- system module
--------------------------------------------------------------------------------

---@class sys*
sys = {}

--- Show prompt text
---@param text string Text content
---@param orien? integer | {allow_screenshot? : boolean, orien?: integer} Rotation direction or option allow_screenshot allows toast to be screenshotted
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.toast)
---
function sys.toast(text, orien) end

--- System prompt pops up
---@param content string Text content
---@param autoDismissalInSeconds? integer Automatically disappear seconds
---@param title? string Title
---@param btnA? string Button 0 title
---@param btnB? string Button 1 title
---@param btnC? string Button 2 title
---@return integer Choose
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.alert)
---
function sys.alert(content, autoDismissalInSeconds, title, btnA, btnB, btnC) end

--- Pop up input prompt
---@param title string Title
---@param message? string Description content
---@param shadowOpts? string|table Shadow prompt content or shadow prompt table {"Text box 1 shadow prompt", "Text box 2 shadow prompt"}
---@param defaultTexts? string|table Default text content or default text table {"Default text of text box 1", "Default text of text box 2"}
---@param btnA? string Button 0 title
---@param btnB? string Button 1 title
---@param btnC? string Button 2 title
---@param autoDismissalInSeconds? integer Automatically disappear seconds
---@return string enteredTextA Input text line A
---@return string? enteredTextB Input text line B
---@return integer? selectedButtonIndex Selected button index
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.input_box)
---
function sys.input_box(title, message, shadowOpts, defaultTexts, btnA, btnB, btnC, autoDismissalInSeconds) end

--- Pop up input prompt
---@param title string Title
---@param message? string Description content
---@param shadowOpts? string|table Shadow prompt content or shadow prompt table {"Text box 1 shadow prompt", "Text box 2 shadow prompt"}
---@param defaultTexts? string|table Default text content or default text table {"Default text of text box 1", "Default text of text box 2"}
---@param autoDismissalInSeconds? integer Automatically disappear seconds
---@return string enteredTextA Input text line A
---@return string? enteredTextB Input text line B
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.input_box)
---
function sys.input_box(title, message, shadowOpts, defaultTexts, autoDismissalInSeconds) end

--- Enter text
---@param text string Text content
---@param shouldPressEnter? boolean Press Enter when input is complete
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.input_text)
---
function sys.input_text(text, shouldPressEnter) end

--- Millisecond latency
---@param delayInMilliseconds integer milliseconds
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.msleep)
---
function sys.msleep(delayInMilliseconds) end

--- Get the current millisecond timestamp
---@return integer Millisecond level UNIX timestamp
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.mtime)
---
function sys.mtime() end

--- Get network time
---@return integer timestamp UNIX timestamp in seconds
---@return boolean isSynchronized Has it been synchronized?
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.net_time)
---
function sys.net_time() end

--- generate a random number
---@return integer random numbers
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.rnd)
---
function sys.rnd() end

--- Get the current available memory value of the device
---@return number available memory
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.available_memory)
---
function sys.available_memory() end

--- Get the current memory status information of the device
---@return table memoryInfo memory status
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.memory_info)
---
function sys.memory_info() end

--- Get the currently unused storage space value of the device
---@param mountPoint? string mount point
---@return number freeSize Remaining space (MB)
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.free_disk_space)
---
function sys.free_disk_space(mountPoint) end

--- Output standard system log
---@param ... any
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.log)
---
function sys.log(...) end

--- Ask the system a question
---@param question string Question name
---@return string? System reply
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.mgcopyanswer)
---
function sys.mgcopyanswer(question) end

--- Read the specified sysctl key value
---@param keyName string sysctl The full key name, such as "kern.boottime"
---@return string? data Raw byte data, returns nil when reading fails
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.ctlbyname)
---
function sys.ctlbyname(keyName) end

--- Get system version
---@return string System version
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.version)
---
function sys.version() end

--- Get CoreFoundation version
---@return number cfVersion CoreFoundation version number
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.cfversion)
---
function sys.cfversion() end

--- Get XXTouch version
---@return string version number
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.xtversion)
---
function sys.xtversion() end

--- Get Allow Apps to Request to Track switch state
--- This function is available in versions after 20260529
---@return boolean? allow Whether apps are allowed to request tracking; returns nil when reading fails
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.user_tracking)
---
function sys.user_tracking() end

--- Set Allow Apps to Request to Track switch state
--- This function is available in versions after 20260529
---@param allow boolean Whether apps are allowed to request tracking
---@return boolean success Whether the setting was applied successfully
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.user_tracking)
---
function sys.set_user_tracking(allow) end

--- Get Personalized Ads switch state
--- This function is available in versions after 20260529
---@return boolean? allow Whether personalized ads are allowed; returns nil when reading fails
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.personalized_advertising)
---
function sys.personalized_advertising() end

--- Set Personalized Ads switch state
--- This function is available in versions after 20260529
---@param allow boolean Whether personalized ads are allowed
---@return boolean success Whether the setting was applied successfully
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.personalized_advertising)
---
function sys.set_personalized_advertising(allow) end

--- Get Location Services main switch state
--- This function is available in versions after 20260529
---@return boolean? enabled Whether Location Services are enabled; returns nil when reading fails
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.location_services)
---
function sys.location_services() end

--- Set Location Services main switch state
--- This function is available in versions after 20260529
---@param enabled boolean Whether Location Services are enabled
---@return boolean success Whether the setting was applied successfully
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.location_services)
---
function sys.set_location_services(enabled) end

--- Get the port number of XXTouch OpenAPI
---@return integer port number
function sys.port() end

--- Send a signal to the specified process
---@param pid integer process number
---@param signal integer signal number
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.kill)
---
function sys.kill(pid, signal) end

--- Sends a signal to the process with the specified name
---@param signal integer signal number
---@param ... string Process name list
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.killall)
---
function sys.killall(signal, ...) end

--- Restart
function sys.reboot() end

--- Shut down
function sys.halt() end

--- Modify file owner recursively
---@param path string File or directory path
---@param uid integer User ID
---@param gid integer User group ID
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.lchown_r)
---
function sys.lchown_r(path, uid, gid) end

--- Modify file permissions recursively
---@param path string File or directory path
---@param perm integer | string Permissions
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.lchmod_r)
---
function sys.lchmod_r(path, perm) end

--- Recursively modify file owners and permissions
---@param path string File or directory path
---@param uid integer User ID
---@param gid integer User group ID
---@param perm integer | string Permissions
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.lchownmod_r)
---
function sys.lchownmod_r(path, uid, gid, perm) end

--- Create directories recursively
---@param path string directory path
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.mkdir_p)
---
function sys.mkdir_p(path) end

---@class sys_task_pipe_object*
sys_task_pipe_object = {}

--- Read prepared data from the pipe
---@param bytes? integer Number of bytes read
---@return string data Data content
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_pipe_object:read(bytes) end

--- Write data to the pipe
---@param data string Data content
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_pipe_object:write(data) end

--- Close the write end of the pipe
---@return boolean ok Operation success or failure
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_pipe_object:wclose() end

--- Close the read end of the pipe
---@return boolean ok Operation success or failure
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_pipe_object:rclose() end

---@class sys_task_object*
sys_task_object = {}

--- Start task
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_object:launch() end

--- Synchronously wait for the task to end
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_object:wait_until_exit() end

--- Set task input flow
---@param input sys_task_pipe_object* | "/dev/null" | "/dev/zero" input stream
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_object:set_stdin(input) end

--- Get task input stream
---@return sys_task_pipe_object* input input stream
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_object:stdin() end

--- Set task output stream
---@param output sys_task_pipe_object* | "/dev/null" output stream
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_object:set_stdout(output) end

--- Get task output stream
---@return sys_task_pipe_object* output output stream
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_object:stdout() end

--- Set task error flow
---@param output sys_task_pipe_object* | "/dev/null" error stream
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_object:set_stderr(output) end

--- Get task error stream
---@return sys_task_pipe_object* output error stream
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_object:stderr() end

--- Set the working directory of the task
---@param workDir string working directory
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_object:set_work_dir(workDir) end

--- Get the working directory of the task
---@return string workDir working directory
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_object:work_dir() end

--- Set task environment variables
---@param env table Environment variable dictionary
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_object:set_env(env) end

--- Get task environment variables
---@return table env Environment variable dictionary
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_object:env() end

--- Get task process ID
---@return integer pid process number
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_object:pid() end

--- Determine whether the task is running
---@return boolean running Is it running?
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_object:is_running() end

--- Send SIGINT to task
---@return boolean ok Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_object:interrupt() end

--- Send SIGTERM to task
---@return boolean ok Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_object:terminate() end

--- Send SIGKILL to the task
---@return boolean ok Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_object:kill() end

--- Get task termination status
---@return integer | nil status terminal state
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_object:termination_status() end

--- Get task termination reason
---@return string | nil reason Reason for termination
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys_task_object:termination_reason() end

--- Create an execution task
---@param executablePath string Executable file path
---@param ... string parameters
---@return sys_task_object* task Task object
---
---[Documentation](https://xxtouch.app/en/docs/handbook/sys/sys.task)
---
function sys.task(executablePath, ...) end


--------------------------------------------------------------------------------
-- Thread module
--------------------------------------------------------------------------------

---@class thread*
thread = {}

--- dispatch a task
---@param taskClousure function Task function
---@param errorCallback? function error callback
---@return integer Task ID
---
---[Documentation](https://xxtouch.app/en/docs/handbook/thread/thread.dispatch)
---
function thread.dispatch(taskClousure, errorCallback) end

--- Get the ID of the current task
---@return integer Task ID
---
---[Documentation](https://xxtouch.app/en/docs/handbook/thread/thread.current_id)
---
function thread.current_id() end

--- Remove a task from the queue
---@param taskID integer Task ID
---
---[Documentation](https://xxtouch.app/en/docs/handbook/thread/thread.kill)
---
function thread.kill(taskID) end

--- Blocks waiting for a task to complete
---@param taskID integer Task ID
---@param timeout? integer timeout seconds
---
---[Documentation](https://xxtouch.app/en/docs/handbook/thread/thread.wait)
---
function thread.wait(taskID, timeout) end

--- Register to listen for an event
---@param eventName string event name
---@param eventCallback function event callback
---@param errorCallback? function error callback
---@return integer Event listening ID
---
---[Documentation](https://xxtouch.app/en/docs/handbook/thread/thread.register_event)
---
function thread.register_event(eventName, eventCallback, errorCallback) end

--- Unregister to listen for an event
---@param eventName string event name
---@param eventID integer Event listening ID
---@return integer Event listening ID
---
---[Documentation](https://xxtouch.app/en/docs/handbook/thread/thread.unregister_event)
---
function thread.unregister_event(eventName, eventID) end


--------------------------------------------------------------------------------
-- Analog touch module
--------------------------------------------------------------------------------

---@class touch*
touch = {}

---@class TouchObject*
TouchObject = {}

--- Set touch event visualization display
---@param shouldShow boolean Whether to display
function touch.show_pose(shouldShow) end

--- Simulate a finger touch on the screen
---@param coordX integer abscissa
---@param coordY integer vertical coordinate
---@param delayBetweenDownAndUpInMs? integer Delay in milliseconds
---@param delayAfterUpInMs? integer Wait milliseconds after operation
---
---[Documentation](https://xxtouch.app/en/docs/handbook/touch/touch.tap)
---
function touch.tap(coordX, coordY, delayBetweenDownAndUpInMs, delayAfterUpInMs) end

--- Simulate finger touching the screen
---@param coordX integer abscissa
---@param coordY integer vertical coordinate
---@return TouchObject* touch event
---
---[Documentation](https://xxtouch.app/en/docs/handbook/touch/touch.on)
---
function touch.on(coordX, coordY) end

--- Simulate a finger leaving the screen
---@param coordX? integer abscissa
---@param coordY? integer vertical coordinate
---
---[Documentation](https://xxtouch.app/en/docs/handbook/touch/touchm_off)
---
function TouchObject:off(coordX, coordY) end

--- Simulate finger movement on screen
---@param coordX integer abscissa
---@param coordY integer vertical coordinate
---@param pressure? integer pressure
---@param twist? integer angle
---@param flags? integer option flag
---@return TouchObject* touch event
---
---[Documentation](https://xxtouch.app/en/docs/handbook/touch/touchm_move)
---
function TouchObject:move(coordX, coordY, pressure, twist, flags) end

--- Set the delay for each step of the touch event object movement
---@param stepDelayMs integer Delay in milliseconds per step
---@return TouchObject* touch event
---
---[Documentation](https://xxtouch.app/en/docs/handbook/touch/touchm_step_delay)
---
function TouchObject:step_delay(stepDelayMs) end

--- Set the touch event object movement step size
---@param stepLength integer step length
---@return TouchObject* touch event
---
---[Documentation](https://xxtouch.app/en/docs/handbook/touch/touchm_step_len)
---
function TouchObject:step_len(stepLength) end

--- Millisecond latency
---@param delayInMs integer milliseconds
---@return TouchObject* touch event
---
---[Documentation](https://xxtouch.app/en/docs/handbook/touch/touchm_msleep)
---
function TouchObject:msleep(delayInMs) end

--- Millisecond latency
---@param delayInMs integer milliseconds
---@return TouchObject* touch event
---
---[Documentation](https://xxtouch.app/en/docs/handbook/touch/touchm_msleep)
---
function TouchObject:delay(delayInMs) end

--- Simulate finger pressure on screen
---@param pressure? integer pressure
---@param twist? integer angle
---@return TouchObject* touch event
---
---[Documentation](https://xxtouch.app/en/docs/handbook/touch/touchm_press)
---
function TouchObject:press(pressure, twist) end

--- Simulate finger touching the screen
---@param finger_id integer Finger ID
---@param coordX integer abscissa
---@param coordY integer vertical coordinate
---@return integer Touch finger ID
---
---[Documentation](https://xxtouch.app/en/docs/handbook/touch/touch.on)
---
function touch.on(finger_id, coordX, coordY) end

--- Simulate finger movement on screen
---@param finger_id integer Finger ID
---@param coordX? integer abscissa
---@param coordY? integer vertical coordinate
---@return integer Touch finger ID
---
---[Documentation](https://xxtouch.app/en/docs/handbook/touch/touchm_move)
---
function touch.move(finger_id, coordX, coordY) end

--- Simulate a finger leaving the screen
---@param finger_id integer Finger ID
---@param coordX? integer abscissa
---@param coordY? integer vertical coordinate
---@return integer Touch finger ID
---
---[Documentation](https://xxtouch.app/en/docs/handbook/touch/touchm_off)
---
function touch.off(finger_id, coordX, coordY) end


--------------------------------------------------------------------------------
-- Gadget module
--------------------------------------------------------------------------------

---@class utils*
utils = {}

--- Convert timestamp to formatted time text
---@param format string time format
---@param timestamp number Timestamp
---@param opts? table Options {tz = time zone, locale = localization}
---@return string formattedText Format time
---
---[Documentation](https://xxtouch.app/en/docs/handbook/utils/utils.date_to_format)
---
function utils.date_to_format(format, timestamp, opts) end

--- Convert formatted time text to timestamp
---@param format string time format
---@param dateText string time text
---@param opts? table Options {tz = time zone, locale = localization}
---@return number timestamp Timestamp
---
---[Documentation](https://xxtouch.app/en/docs/handbook/utils/utils.date_from_format)
---
function utils.date_from_format(format, dateText, opts) end

--- Timestamp converted to RFC 1123 text
---@param timestamp number Timestamp
---@return string rfc1123 RFC1123 text
---
---[Documentation](https://xxtouch.app/en/docs/handbook/utils/utils.date_to_rfc1123)
---
function utils.date_to_rfc1123(timestamp) end

--- RFC 1123 text to timestamp
---@param rfc1123 string RFC1123 text
---@return number timestamp Timestamp
---
---[Documentation](https://xxtouch.app/en/docs/handbook/utils/utils.date_from_rfc1123)
---
function utils.date_from_rfc1123(rfc1123) end

--- Timestamp converted to RFC 3339 text
---@param timestamp number Timestamp
---@return string rfc3339 RFC3339 text
---
---[Documentation](https://xxtouch.app/en/docs/handbook/utils/utils.date_to_rfc3339)
---
function utils.date_to_rfc3339(timestamp) end

--- RFC 3339 text to timestamp conversion
---@param rfc3339 string RFC3339 text
---@return number timestamp Timestamp
---
---[Documentation](https://xxtouch.app/en/docs/handbook/utils/utils.date_from_rfc3339)
---
function utils.date_from_rfc3339(rfc3339) end

--- Generate a UUID
---@return string uuid UUID
---
---[Documentation](https://xxtouch.app/en/docs/handbook/utils/utils.gen_uuid)
---
function utils.gen_uuid() end

--- Generate a time-based one-time password
--- This function is available in versions after 20260107
---@param timestamp integer Unix timestamp in seconds. Pass -1 to use the current time.
---@param url string TOTP URL in the otpauth://totp/... format
---@param secret? string Base32 secret
---@return string? code Generated one-time password
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/utils/utils.totp_next)
---
function utils.totp_next(timestamp, url, secret) end

--- Generate a one-time password by counter
--- This function is available in versions after 20260107
---@param counter integer HOTP counter
---@param url string HOTP URL in the otpauth://hotp/... format
---@param secret? string Base32 secret
---@return string? code Generated one-time password
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/utils/utils.hotp_counter)
---
function utils.hotp_counter(counter, url, secret) end

--- Generate the next counter-based one-time password
--- This function is available in versions after 20260107
---@param url string HOTP URL in the otpauth://hotp/... format
---@param secret? string Base32 secret
---@return string? code Generated one-time password
---@return string? errMsg error message
---
---[Documentation](https://xxtouch.app/en/docs/handbook/utils/utils.hotp_next)
---
function utils.hotp_next(url, secret) end

--- Encode text into QR code image
---@param text string text content
---@param opts? table Options {size = size, fill_color = fill color, shadow_color = shadow color}
---@return ImageObject* image Picture object
---
---[Documentation](https://xxtouch.app/en/docs/handbook/utils/utils.qr_encode)
---
function utils.qr_encode(text, opts) end

--- Import a video file into the photo album
---@param videoPath string Video file path
---
---[Documentation](https://xxtouch.app/en/docs/handbook/utils/utils.video_to_album)
---
function utils.video_to_album(videoPath) end

--- Add one or more contacts to your address book
---@param contacts table Contact list
---{
---  {
--- firstName = "Last Name 1",
--- lastName = "Name 1",
---    phoneNumbers = {
--- "Contact 1 number 1",
--- "Contact 1 Number 2",
---    },
---    emails = {
--- "Contact 1 Email 1",
--- "Contact 1 Email 2",
---    },
---  },
---  {
--- firstName = "Last name 2",
--- lastName = "Name 2",
---    phoneNumbers = {
--- "Contact 2 number 1",
--- "Contact 2 number 2",
---    },
---    emails = {
--- "Contact 2 Email 1",
--- "Contact 2 Email 2",
---    },
---  },
---  ...
---}
---@return boolean Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/utils/utils.add_contacts)
---
function utils.add_contacts(contacts) end

--- Delete all contacts from address book
---@return boolean Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/utils/utils.remove_all_contacts)
---
function utils.remove_all_contacts() end

--- Get the startup parameters of the current script
---@return table Startup parameter association table
---
---[Documentation](https://xxtouch.app/en/docs/handbook/utils/utils.launch_args)
---
function utils.launch_args() end

--- Determine whether the current script is started from within the app
---@return boolean Whether to start from within the App
---
---[Documentation](https://xxtouch.app/en/docs/handbook/utils/utils.is_launch_via_app)
---
function utils.is_launch_via_app() end


--------------------------------------------------------------------------------
-- VPN configuration module
--------------------------------------------------------------------------------

---@class vpnconf*
vpnconf = {}

--- Create a VPN configuration
---@param configTab table configuration table
---@return boolean Create success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/vpnconf/vpnconf.create)
---
function vpnconf.create(configTab) end

--- Get the list of current system VPNs
---@return table VPN list
---
---[Documentation](https://xxtouch.app/en/docs/handbook/vpnconf/vpnconf.list)
---
function vpnconf.list() end

--- Choose a VPN configuration
---@param displayID string Display name or VPNID
---@return boolean Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/vpnconf/vpnconf.select)
---
function vpnconf.select(displayID) end

--- Delete a VPN configuration
---@param displayID string Display name or VPNID
---@return boolean Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/vpnconf/vpnconf.delete)
---
function vpnconf.delete(displayID) end

--- Establish a connection with the currently selected VPN
---@return boolean Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/vpnconf/vpnconf.connect)
---
function vpnconf.connect() end

--- Disconnect current VPN connection
---@return boolean Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/vpnconf/vpnconf.disconnect)
---
function vpnconf.disconnect() end

--- Get the status of the currently selected VPN
---@return table Status description table
---
---[Documentation](https://xxtouch.app/en/docs/handbook/vpnconf/vpnconf.status)
---
function vpnconf.status() end


--------------------------------------------------------------------------------
-- script package module
--------------------------------------------------------------------------------

---@class xpp*
xpp = {}

--- Get meta-information about the current script package
---@return table info Meta information
---
---[Documentation](https://xxtouch.app/en/docs/handbook/xpp/xpp.info)
---
function xpp.info() end

--- Get the package path of the current script package
---@return string path package path
---
---[Documentation](https://xxtouch.app/en/docs/handbook/xpp/xpp.bundle_path)
---
function xpp.bundle_path() end

--- Get the resource path in the current script package
---@param resourceName string Resource file name
---@return string? path Resource path
---
---[Documentation](https://xxtouch.app/en/docs/handbook/xpp/xpp.resource_path)
---
function xpp.resource_path(resourceName) end


--------------------------------------------------------------------------------
-- Web view module
--------------------------------------------------------------------------------

---@class webview*
webview = {}

--- Present a web view
---@param opts table Option table {id = view ID, html = HTML content, x = origin abscissa, y = origin ordinate, width = width, height = height, corner_radius = corner radius, alpha = opacity, animation_duration = animation time, rotate = rotation angle, level = form level, opaque = range opaque, ignores_hit = whether to ignore touch events, can_drag = whether it can be dragged}
---
---[Documentation](https://xxtouch.app/en/docs/handbook/webview/webview.show)
---
function webview.show(opts) end

--- Hide a web view
---@param viewID integer View ID
---
---[Documentation](https://xxtouch.app/en/docs/handbook/webview/webview.hide)
---
function webview.hide(viewID) end

--- Execute a piece of JavaScript on a web view
---@param jsContent string JS text
---@param viewID integer View ID
---@return string Execution result text
---
---[Documentation](https://xxtouch.app/en/docs/handbook/webview/webview.eval)
---
function webview.eval(jsContent, viewID) end

--- Get the area and level information of a web view
---@param viewID integer View ID
---@return table? Region and level information table
---
---[Documentation](https://xxtouch.app/en/docs/handbook/webview/webview.frame)
---
function webview.frame(viewID) end

--- Destroy a web view
---@param viewID integer View ID
---
---[Documentation](https://xxtouch.app/en/docs/handbook/webview/webview.destroy)
---
function webview.destroy(viewID) end


--------------------------------------------------------------------------------
-- Configure interface module
--------------------------------------------------------------------------------

---@class xui*
xui = {}

--- Show a configuration interface
---@param fileName string Configuration interface file name
---
---[Documentation](https://xxtouch.app/en/docs/handbook/xui/xui.show)
---
function xui.show(fileName) end

--- Collapse the displayed configuration interface
---
---[Documentation](https://xxtouch.app/en/docs/handbook/xui/xui.dismiss)
---
function xui.dismiss() end

--- Reload the currently displayed configuration interface
---
---[Documentation](https://xxtouch.app/en/docs/handbook/xui/xui.reload)
---
function xui.reload() end

--- Verify and initialize configuration interface configuration
---@param fileName string Configuration interface file name
---
---[Documentation](https://xxtouch.app/en/docs/handbook/xui/xui.setup)
---
function xui.setup(fileName) end

--- Clear all configurations of a configuration partition
---@param defaults string Configure partitions
---@return boolean ok Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/xui/xui.clear)
---
function xui.clear(defaults) end

--- Get a certain configuration value on the configuration interface
---@param defaults string Configure partitions
---@param key string configuration key
---@return any value configuration value
---
---[Documentation](https://xxtouch.app/en/docs/handbook/xui/xui.get)
---
function xui.get(defaults, key) end

--- Set a certain configuration value on the configuration interface
---@param defaults string Configure partitions
---@param key string configuration key
---@param value any configuration value
---@return boolean ok Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/xui/xui.set)
---
function xui.set(defaults, key, value) end

--- Read all configurations of a configuration partition
---@param defaults string Configure partitions
---@return table config configuration table
---
---[Documentation](https://xxtouch.app/en/docs/handbook/xui/xui.read)
---
function xui.read(defaults) end

--- Overwrite the configuration written to the configuration partition
---@param defaults string Configure partitions
---@param config table configuration table
---@return boolean ok Operation success or failure
---
---[Documentation](https://xxtouch.app/en/docs/handbook/xui/xui.write)
---
function xui.write(defaults, config) end
