/*
 * 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 isValidAttr=require("./helpers/valid-attr");const RULE_NAME="oj-html-ojattr";const OJ_EVENT_PREFIX="on-oj-";const EVENT_PREFIX="on-";const SLOT="slot";const DATABIND="data-bind";const DATACMD="data-oj-command";const DATACONTEXT="data-oj-context";function getName(){return RULE_NAME};function getShortDescription(){return"JET component attribute must be defined"};function getDescription(){return"JET component attribute must be a defined attribute for the component"};function register(){return{"webcomp":_onWComp}};function _onWComp(ruleCtx,tag){var attrs,attr;if(attrs=ruleCtx.tagNode.attribs){for(attr in attrs){_checkAttr(ruleCtx,tag,attr)}}};function _checkAttr(ruleCtx,tag,attr){var issue,origAttr,attrPos,utils;utils=ruleCtx.utils;origAttr=attr;attr=attr.charAt(0)===":"?attr.substring(1):attr;if(attr==="\""){return}if(!isValidAttr(attr)){issue=new ruleCtx.Issue(`<${tag}> - invalid ${origAttr.charAt(0)===":"?"colon-prefixed":""} attribute '${origAttr}'`);attrPos=utils.DomUtils.getAttribPosition(ruleCtx.data,ruleCtx.tagNode,origAttr);issue.setPosition(attrPos.row,attrPos.col,attrPos.start,attrPos.end);issue.setMsgKey(RULE_NAME+"_1");ruleCtx.reporter.addIssue(issue,ruleCtx);return}utils=ruleCtx.utils;if(utils.DomUtils.isCommonAttr(attr)||utils.DomUtils.isCommonEventAttr(attr)||attr===SLOT||attr===DATABIND||attr===DATACMD||attr===DATACONTEXT||attr.startsWith(OJ_EVENT_PREFIX)||attr.startsWith(EVENT_PREFIX)){return}if(!utils.metaLib.isTagAttr(tag,attr)){if(!utils.metaLib.isTagEvent(tag,attr)){issue=new ruleCtx.Issue(`<${tag}> attribute '${attr}' is unknown`);attrPos=utils.DomUtils.getAttribPosition(ruleCtx.data,ruleCtx.tagNode,origAttr);issue.setPosition(attrPos.row,attrPos.col,attrPos.start,attrPos.end);ruleCtx.reporter.addIssue(issue,ruleCtx)}}};module.exports={getName,getDescription,getShortDescription,register};