/*
 * 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 Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-event-displayname"};ruleDef.prototype.getShortDescription=function(){return"Check component has display name defined for events"};ruleDef.prototype.getDescription=function(){return"This rule checks that events have a display name supplied to make the user experience in Visual Builder as useful as possible"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const componentType=Utils.getComponentType(meta);if(componentType==="composite"){this._checkEvents(context,meta.events)}}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkEvents(context,componentInfo.events)}};ruleDef.prototype._checkEvents=function(context,events){let issue;if(events){Object.keys(events).forEach(eventName=>{if(!events[eventName].displayName){issue=new context.Issue(`displayName for event '${eventName}' should be defined`);context.reporter.addIssue(issue,context)}})}};module.exports=ruleDef;