/* ==================================== JUCER_BINARY_RESOURCE ====================================

   This is an auto-generated file: Any edits you make may be overwritten!

*/

#include <cstring>

namespace mods
{

//================== command.lua ==================
static const unsigned char temp_binary_data_2[] =
"--- UI Commands.\n"
"-- Support library for working with Element UI commands.\n"
"-- @module el.command\n"
"\n"
"local Commands = require ('el.Commands')\n"
"local Context  = require ('el.Context')\n"
"\n"
"local M = {}\n"
"\n"
"local function instance()\n"
"    local g = Context.instance()\n"
"    return g and g:commands() or nil\n"
"end\n"
"\n"
"--- Invoke a command.\n"
"-- @int cmd Command ID\n"
"-- @bool async Invoke async or not (default false)\n"
"function M.invoke (cmd, async)\n"
"    if type(cmd) == 'number' then\n"
"        cmd = math.tointeger (cmd)\n"
"    else\n"
"        cmd = 0\n"
"    end\n"
"\n"
"    if cmd > 0 then\n"
"        local m = instance()\n"
"        assert (m ~= nil, \"nil el.Commands\")\n"
"        return m:invokeDirectly (cmd, async or false)\n"
"    end\n"
"\n"
"    return false\n"
"end\n"
"\n"
"--- Create a closure for a command.\n"
"--\n"
"-- Returns a function which invokes the command async or not. By default the\n"
"-- command is not invoked async\n"
"-- @int cmd Command ID\n"
"-- @bool async Whether to invoke async or not\n"
"-- @return function Function which invokes the command\n"
"-- @usage\n"
"-- local show_about = command.closure (command.SHOW_ABOUT, true)\n"
"-- show_about()\n"
"function M.closure (cmd, async)\n"
"    assert (type (cmd) == 'number', \"command must be a number\")\n"
"\n"
"    local c = math.tointeger (cmd)\n"
"    local a = true\n"
"    if type(async) == 'boolean' then\n"
"        a = async\n"
"    elseif type(async) == 'number' then\n"
"        a = async ~= 0.0\n"
"    elseif type(async) == 'string' then\n"
"        a = string.len (async) > 0\n"
"    elseif type(async) == 'nil' then\n"
"        a = true\n"
"    end\n"
"\n"
"    return function() return M.invoke (c, a) end\n"
"end\n"
"\n"
"-- Define standard commands as constants. \n"
"-- e.g. Commands::showAbout in C++ becomes command.SHOW_ABOUT\n"
"for _,cmd in ipairs (Commands.standard()) do\n"
"    local strings = require ('el.strings')\n"
"    local s = Commands.toString (cmd)\n"
"    if string.len(s) > 0 and strings.valid(s) then\n"
"        local k = strings.tosnake (s)\n"
"        M[string.upper (k)] = cmd\n"
"    end\n"
"end\n"
"\n"
"return M\n"
"\n"
"-- SPDX-FileCopyrightText: Copyright (C) Kushview, LLC.\n"
"-- SPDX-License-Identifier: GPL-3.0-or-later\n";

const char* command_lua = (const char*) temp_binary_data_2;
}
