/*
 * 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 RULE_NAME="oj-tsx-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 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._tsxUtils=regCtx.utils.tsxUtils;this._metaLib=regCtx.utils.metaLib;return{"Tsx<slot=>":this._onSlot}};Rule.prototype._onSlot=function(ruleCtx,tsxProp){var slotName;if(slotName=_getSlotName(tsxProp)){if(tsxProp.parent.name!==TEMPLATE){this._checkSlot(ruleCtx,tsxProp,slotName)}}};Rule.prototype._checkSlot=function(ruleCtx,tsxProp,slotName){var tsxParent;if(!(tsxParent=this._tsxUtils.getSlotParent(ruleCtx,tsxProp,slotName))){return}let parentTag=tsxParent.name;let status;if(status=this._metaLib.isTagSlotDeprecated(parentTag,slotName)){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 <${tsxProp.parent.name}> for <${parentTag}> is deprecated${since}.${descript}`);this._tsxUtils.setIssuePosition(issue,tsxProp);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 _getSlotName(tsxProp){return tsxProp.node.value.type==="Literal"?tsxProp.node.value.value:null};module.exports=Rule;