resolveEnabledCategories = (categories, excludedCategories) => {
    const {
        _allCategoryNames,
        _acceptedCategories,
        _readOnlyCategories,
        _preferencesModalExists,
        _enabledServices,
        _defaultEnabledCategories,
        _allDefinedServices
    } = globalObj._state;

    /**
     * @type {string[]}
     */
    let enabledCategories = [];

    if (!categories) {
        enabledCategories = [..._acceptedCategories, ..._defaultEnabledCategories];
        //{{START: GUI}}
        if (_preferencesModalExists) {
            enabledCategories = retrieveCategoriesFromModal();
        }
        //{{END: GUI}}
    } else {
        if (isArray(categories)) {
            enabledCategories.push(...categories);
        } else if (isString(categories)) {
            enabledCategories = categories === 'all'
                ? _allCategoryNames
                : [categories];
        }

        /**
         * If there are services, turn them all on or off
         */
        for (const categoryName of _allCategoryNames) {
            _enabledServices[categoryName] = elContains(enabledCategories, categoryName)
                ? getKeys(_allDefinedServices[categoryName])
                : [];
        }
    }

    // Remove invalid and excluded categories
    enabledCategories = enabledCategories.filter(category =>
        !elContains(_allCategoryNames, category) ||
        !elContains(excludedCategories, category)
    );

    // Add back all the categories set as "readonly/required"
    enabledCategories.push(..._readOnlyCategories);

    setAcceptedCategories(enabledCategories);
}
@param {string[]|string} categories - Categories to accept
@param {string[]} [excludedCategories]