/*
 * Copyright (c) 2018, 2025, 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-html-redwood-bp-btn-avatar";const DESCRIPTION="Buttons should not contain avatars, they may not correctly align within the button";const SHORT_DESCRIPTION=DESCRIPTION;class Rule{getName(){return RULENAME}getDescription(){return DESCRIPTION}getShortDescription(){return SHORT_DESCRIPTION}register(){return{"<oj-button>":this._onBtn,"<oj-c-button>":this._onBtn,"<oj-menu-button>":this._onBtn,"<oj-c-menu-button>":this._onBtn,"<oj-c-progress-button>":this._onBtn,"<oj-c-toggle-button>":this._onBtn}}_onBtn(ruleCtx,tagName){var childs;if(childs=ruleCtx.tagNode.children){for(let i=0;i<childs.length;i++){if(this._check(ruleCtx,childs[i],tagName)){return}};}}_check(ruleCtx,child,tagName){var childs;if(!child||!child.name||child.type!=="tag"){return false}if(_isAvatar(child.name)){this._emitIssue(ruleCtx,child,tagName);return true}else if(child.name==="span"||child.name.startsWith("oj-bind")){childs=child.children;for(let i=0;i<childs.length;i++){if(this._check(ruleCtx,childs[i],tagName)){return true};}}return false}_emitIssue(ruleCtx,avatar,btnName){let issue=new ruleCtx.Issue(`An avatar should not be used inside <${btnName}> in Redwood theme`);issue.setPosition(null,null,avatar.startIndex,avatar.startIndex+avatar.name.length+1);ruleCtx.reporter.addIssue(issue,ruleCtx)}}function _isAvatar(tagName){return tagName==="oj-avatar"||tagName==="oj-c-avatar"};module.exports=Rule;