/*
 * 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-css-bp-textalign";const DESCRIPTION="Use of CSS 'text-align' is discouraged  - use the JET text-align classes.  For example: for <b>text-align:right</b> "+"use the "+"<a href='https://www.oracle.com/webfolder/technetwork/jet/jetCookbook.html?component=display&demo=textend'>text align end</a> "+"utility classes.";const SHORT_DESCRIPTION="Use of CSS 'text-align' is discouraged  - use the JET text-align classes";const DECLARATION="Declaration";const TEXT_ALIGN="text-align";const VAR="var";const COLON=":";class Rule{getName(){return RULENAME}getDescription(){return DESCRIPTION}getShortDescription(){return SHORT_DESCRIPTION}register(regCtx){this._CssUtils=regCtx.utils.CssUtils;return{"css-rule":this._onRule,"style":this._onStyle}}_onRule(ruleCtx,rule){var block,decl,issue,i;block=rule.block.children;for(i=0;i<block.length;i++){decl=block[i];if(decl.type===DECLARATION&&decl.property===TEXT_ALIGN&&!_isCssVar(decl)){issue=new ruleCtx.Issue("CSS 'text-align' - best practices: use the JET text-align classes");issue.setPosition(this._CssUtils.getPosition(ruleCtx,decl.loc));issue.setSeverity("minor");ruleCtx.reporter.addIssue(issue,ruleCtx)}}}_onStyle(ruleCtx,attr,value){var prop,issue,s,x,i;for(i=0;i<value.length;i++){s=value[i];x=s.indexOf(COLON);if(x>=0){prop=s.substring(0,x).trimEnd();if(prop===TEXT_ALIGN){issue=new ruleCtx.Issue("'text-align' property in 'style' attribute. Best practices: use the JET text-align classes");issue.setMsgKey(RULENAME+"_1");ruleCtx.reporter.addIssue(issue,ruleCtx)}}}}}function _isCssVar(decl){var c,v;c=decl.value.children;if(c){v=c[0];return v.name===VAR}return false};module.exports=Rule;