/*
 * 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 helperPos=require("../../rules/jet/helpers/json-propname-pos");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-property-displayname"};ruleDef.prototype.getShortDescription=function(){return"Check component properties have a display name defined"};ruleDef.prototype.getDescription=function(){return"This rule checks that any component properties and sub-properties have a display name supplied to make the user experience in Visual Builder as useful as possible"};ruleDef.prototype.register=function(context){if(context.rulePack.isRuleEnabled("oj-cca-compjson-bp-dsplyname","JET")){return false}else{return{compjson:this._doAudit,Program:this._doVComponentAudit}}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){this._checkDisplayNames(context,Utils.getComponentFullName(context.suppData.obj),context.suppData.obj)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkDisplayNames(context,componentInfo.fullName,componentInfo)}};ruleDef.prototype._checkDisplayNames=function(context,componentName,componentInfo){let issue;const propertyList=Utils.flattenComponentProperties(componentInfo,"displayName");propertyList.forEach(prop=>{if(!prop.value){issue=new context.Issue(`displayName for property '${prop.key}' should be defined`);context.reporter.addIssue(issue,context)}})};module.exports=ruleDef;