/*
 * 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 helperPos=require("./helpers/json-propname-pos");const helperProp=require("./helpers/bp-checkPropType");const RULE_NAME="oj-cca-compjson-bp-obj";function getName(){return RULE_NAME};function getShortDescription(){return"Web component component.json metadata should follow best practices and avoid 'object' type properties"};function getDescription(){return"For best practices, web components should avoid use of the property type 'object' without sub-properties, and provide a more complete definition of the API either using sub-properties or using a closure type definition"};function register(){return{"compjson-composite":_handle}};function _handle(ruleCtx,obj){var json,props,prop,issue,msg,pos,i;json=obj.obj;if(json.properties){props=helperProp(json.properties,"o");if(props){for(i=0;i<props.length;i++){prop=props[i];if(_hasSub_properties(json.properties,prop)){continue}msg="property '"+prop+"': type 'object' has no sub-properties. Provide a more complete API definition using sub-properties or a closure type definition";issue=new ruleCtx.Issue(msg);pos=helperPos(ruleCtx,prop);issue.setPosition(pos.row,pos.col,pos.index,pos.index?pos.index+6:0);ruleCtx.reporter.addIssue(issue,ruleCtx)}}}};function _hasSub_properties(props,prop){var subprop,a,i;if(!prop.includes(".")){return!!props[prop].properties}a=prop.split(".");for(i=0;i<a.length;i++){subprop=props[a[i]];if(subprop&&subprop.properties){if(a.length-1===i){return true}props=subprop.properties;continue}break}return false};module.exports={getName,getDescription,getShortDescription,register};