/*
 * 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 getParentNodeForSlot=require("./helpers/tsx/has-slot-name");const hasProp=require("./helpers/tsx/has-prop-value");const RULENAME="oj-tsx-button-size-chroming";const DESCRIPTION="The Redwood input designs require the use of small buttons. Please update the "+"button properties in the 'start' or 'end' slot:<br>"+"&nbsp;1) For <oj-button>, use class=\"oj-button-sm\"<br>"+"&nbsp;2) For <oj-c-button>, set size=\"sm\" and chroming=\"ghost\"";const SHORT_DESCRIPTION="Redwood input design spec -small buttons required.";const OJ_INPUT_TEXT="oj-input-text";const OJ_C_INPUT_TEXT="oj-c-input-text";const OJ_BUTTON="oj-button";const OJ_C_BUTTON="oj-c-button";const START="start";const END="end";class Rule{getName(){return RULENAME}getDescription(){return DESCRIPTION}getShortDescription(){return SHORT_DESCRIPTION}register(regCtx){this._tsxUtils=regCtx.utils.tsxUtils;return{"Tsx<oj-button slot=>":this._onBtn,"Tsx<oj-c-button slot=>":this._onBtn}}_onBtn(ruleCtx,tsxProp){var slotName;if(!(slotName=this._tsxUtils.getPropertyStringValue(tsxProp))){return}if(slotName!==START&&slotName!==END){return}let tsxComp,tagName,parentName,node;tsxComp=tsxProp.parent;if(!(node=getParentNodeForSlot(ruleCtx,tsxComp,slotName))){return}parentName=node.name;tagName=tsxComp.name;if(tagName!==OJ_BUTTON&&tagName!==OJ_C_BUTTON||parentName!==OJ_INPUT_TEXT&&parentName!==OJ_C_INPUT_TEXT){return}if(tagName===OJ_BUTTON){if(!hasProp(tsxComp,"class","oj-button-sm")){this._emitIssue(ruleCtx,true)}}else{if(!hasProp(tsxComp,"chroming","ghost")||!hasProp(tsxComp,"size","sm")){this._emitIssue(ruleCtx,false)}}}_emitIssue(ruleCtx,legacy){var msg=legacy?"<oj-button> in the 'start' or 'end' slot should use class=\"oj-button-sm\"":"<oj-c-button> in the 'start' or 'end' slot should use chroming=\"ghost\" and size=\"sm\"";var issue=new ruleCtx.Issue("Redwood input specs: "+msg);if(!legacy){issue.setMsgKey(RULENAME+"_1")}ruleCtx.reporter.addIssue(issue,ruleCtx)}}module.exports=Rule;