/*
 * 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/has-slot-name");const RULE_NAME="oj-html-slot-deprecated";const DESCRIPT="The slot has been deprecated, and is subject to removal or non-active support in the future.";const SHORT="A deprecated slot has been found.";const OJ_DYNAMIC="oj-dynamic";const OJ_DYN="oj-dyn";const SLOT="slot";const TEMPLATE="template";const DOT=".";const JET_RELS=2;const SEV_BLOCKER="blocker";const MSG_ID_AGED="_aged";const MSG_ID_USER="_user";function Rule(){};Rule.prototype.getName=function(){return RULE_NAME};Rule.prototype.getShortDescription=function(){return SHORT};Rule.prototype.getDescription=function(){return DESCRIPT};Rule.prototype.register=function(regCtx){this._metaLib=regCtx.utils.metaLib;return{"<slot=>":this._onSlot}};Rule.prototype._onSlot=function(ruleCtx,slot,slotVal){if(slotVal&&!_isExpr(slotVal)&&ruleCtx.tagNode.name!==TEMPLATE){this._checkSlot(ruleCtx,slotVal)}};Rule.prototype._checkSlot=function(ruleCtx,slotName){var pnode,status;pnode=getParentNodeForSlot(ruleCtx,slotName);if(!pnode||pnode.type!=="tag"){return}let parentTag=pnode.name;if(status=this._metaLib.isTagSlotDeprecated(parentTag,slotName)){let tag=ruleCtx.tag;let since=status.since?` (since ${status.since})`:"";let descript=(status.description?` ${status.description}`:"").trimRight();if(descript&&!descript.endsWith(DOT)){descript+=DOT}let issue=new ruleCtx.Issue(`slot '${slotName}' on <${tag}> for <${parentTag}> is deprecated${since}.${descript}`);let attrPos=ruleCtx.utils.DomUtils.getAttribPosition(ruleCtx.data,ruleCtx.tagNode,SLOT);issue.setPosition(attrPos.row,attrPos.col,attrPos.start,attrPos.end);if(this._metaLib.isJetTag(parentTag)||parentTag===OJ_DYNAMIC||parentTag===OJ_DYN){if(status.since&&ruleCtx.utils.jafLib.getMajorReleaseCount(status.since)>JET_RELS){issue.setSeverity(SEV_BLOCKER);issue.setMsgKey(RULE_NAME+MSG_ID_AGED)}}else{issue.setMsgKey(RULE_NAME+MSG_ID_USER)}ruleCtx.reporter.addIssue(issue,ruleCtx)}};function _isExpr(s){return s.startsWith("[[")||s.startsWith("{{")};module.exports=Rule;