/** * Who may press the buttons that spend the site's Recomaze credits: the * roles holding the "AI with credits" capability (administrators and * editors unless the role manager says otherwise). Shared by the plugin * page and the editors, so both say the same thing to everyone else. */ export const AI_CAPABILITY = 'recomaze_seo_ai'; /** Why an AI button is greyed out. */ export const NO_AI_ACCESS = "AI actions spend the site's Recomaze credits, and your role may not start them. Ask an administrator for AI access."; /** * Whether the SEO capabilities of a user let them run AI actions. * * @param {string[] | undefined} caps - The user's SEO capabilities; unknown means a page from before the capability. * @returns {boolean} */ export const canUseAi = (caps: string[] | undefined): boolean => caps === undefined || caps.includes(AI_CAPABILITY);