/*
 * 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-html-bp-button-xs-chroming";const DESCRIPTION="For components <oj-button> and <oj-c-button>, property size=\"xs\" is only supported using "+"ghost chroming and icon display mode. For size=\"xs\":<br>"+"&nbsp; 1) chroming=\"ghost\" is required, and:<br>"+"&nbsp; 2) display=\"icons\" is required.<br>";const SHORT_DESCRIPTION="For <oj-button> and <oj-c-button> property size=\"xs\" is only supported using "+"ghost chroming and icon display mode.<br>";const CLASS="class";const XS="xs";const DISPLAY="display";const CHROMING="chroming";const GHOST="ghost";const ICONS="icons";class Rule{getName(){return RULENAME}getDescription(){return DESCRIPTION}getShortDescription(){return SHORT_DESCRIPTION}register(){return{"<oj-c-button size=>":this._onBtn,"<oj-c-menu-button size=>":this._onBtn}}_onBtn(ruleCtx,attr,attrVal){if(attrVal===XS){let msgType=0;if(this._hasAttr(ruleCtx,CHROMING,GHOST)){if(this._hasAttr(ruleCtx,DISPLAY,ICONS)){return}msgType=2}else{msgType=1}if(msgType){this._emitIssue(ruleCtx,msgType)}}}_emitIssue(ruleCtx,msgType){var msg,tag;tag=ruleCtx.tagNode.name;if(msgType===1){msg=`<${tag} size="xs"> requires chroming="ghost".`}else if(msgType===2){msg=`<${tag} size="xs" chroming="ghost"> requires 'display="icons".`}if(msg){let issue=new ruleCtx.Issue(msg);let attrPos=ruleCtx.position;issue.setPosition(attrPos.row,attrPos.col,attrPos.start,attrPos.end);ruleCtx.reporter.addIssue(issue,ruleCtx)}}_hasAttr(ruleCtx,attr,attrVal){var attribs,attrib,ret=false;if(attr&&(attribs=ruleCtx.tagNode.attribs)){if(attrib=attribs[attr]){if(arguments.length===2){return true}if(attr===CLASS){let clsName,i;let a=attrib.split(" ");for(i=0;i<a.length;i++){if(clsName=a[i]){if(clsName===attrVal){ret=true;break}}}}else if(attrib===attrVal){ret=true}}}return ret}}module.exports=Rule;