/*
 * Copyright (c) 2018, 2026, Oracle and/or its affiliates.
 * Licensed under The Universal Permissive License (UPL), Version 1.0
 * as shown at https://oss.oracle.com/licenses/upl/
 */
const RULENAME="oj-tsx-acc-button-label";const DESCRIPTION="For button accessibility, the 'label' attribute should be applied to the following button components: "+"<oj-c-button>, <oj-c-menu-button> and <oj-c-split-menu-button>.";const SHORT_DESCRIPTION="Button components should use the 'label' attribute to make them accessible.";const LABEL="label";class Rule{getName(){return RULENAME}getDescription(){return DESCRIPTION}getShortDescription(){return SHORT_DESCRIPTION}register(regCtx){this._tsxUtils=regCtx.utils.tsxUtils;this._metaLib=regCtx.utils.metaLib;return{"Tsx<oj-c-button>":this._onBtn,"Tsx<oj-c-menu-button>":this._onBtn,"Tsx<oj-c-split-menu-button>":this._onBtn,"Tsx<oj-c-toggle-button>":this._onBtn,"startaudit":this._onPreAudit}}_onBtn(ruleCtx,tsxComp){if(!this._tsxUtils.getProperty(tsxComp,LABEL)){if(this._canEmit(ruleCtx,tsxComp.name)){let issue=new ruleCtx.Issue(`<${tsxComp.name}> should use the 'label' attribute to be accessible.`);ruleCtx.reporter.addIssue(issue,ruleCtx)}}}_canEmit(ruleCtx,tag){var req,ret=true,i;if((req=this._metaLib.getRequiredAttrs(tag))&&req.length){for(i=0;i<req.length;i++){if(req[i]===LABEL){ret=!this._isAttrReqRule;break}}}return ret}_onPreAudit(ctx){this._isAttrReqRule=ctx.rulePack.isRuleEnabled("oj-tsx-attr-req")}}module.exports=Rule;