/*
 * 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 getStyles=require("./helpers/extractStylesFromClass");const RULE_NAME="oj-html-ojstyle";const SHORT="JET component 'class' attribute styles must be valid";const LONG="JET web component 'class' attribute styles prefixed with 'oj-' must be JET defined styles, or defined in a styleset.";function Rule(){this._checkList=null;this._isAccept=false};Rule.prototype.getName=function(){return RULE_NAME};Rule.prototype.getShortDescription=function(){return SHORT};Rule.prototype.getDescription=function(){return LONG};Rule.prototype.register=function(regCtx){var customOpts,i;if(regCtx.rulePack.isRuleEnabled("oj-html-stylesel")){return false}if(customOpts=regCtx.ruleOpts.customOpts){if(this._ignore=customOpts.ignore){for(i=0;i<this._ignore.length;i++){this._ignore[i]=new RegExp(this._ignore[i])}}}return{"class":this._onClass}};Rule.prototype._onClass=function(ruleCtx,attrName,attrValue){var tagName,i,j,issue,classes,style,metaLib;metaLib=ruleCtx.utils.metaLib;tagName=ruleCtx.tag;if(!ruleCtx.ojTag||!metaLib.isJetTag(tagName)){return}classes=getStyles(attrValue);for(i=0;i<classes.length;i++){style=classes[i];if(this._ignore){for(j=0;j<this._ignore.length;j++){if(this._ignore[j].test(style)){break}}if(j<this._ignore.length){continue}}if(!metaLib.isStyle(style)){issue=new ruleCtx.Issue("<"+tagName+"> - unknown JET class style '"+style+"'");ruleCtx.reporter.addIssue(issue,ruleCtx)}}};module.exports=Rule;