/*
 * 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 RULENAME="oj-html-form-bindif";const DESCRIPTION="<oj-form-layout> is meant to have static content only. The use of a 'bind' tag - <oj-bind-for-each>, <oj-bind-if>,"+"or <oj-if> - is not supported.<p>"+"The problem with using a 'bind' tag inside a form layout, is that the layout will not be refreshed if "+"its child DOM changes after instantiation (unless the refresh() method on the layout is called). This can result in the "+"layout not managing multiple columns correctly and is therefore not supported.<p>"+"If the 'bind' tag evaluation is fully resolved and will not change before the form is rendered, there will be no problem. "+"Similarly, if the  form has only one column of fields, there is unlikely to be any visible issue. "+"If there is the possibility that the expression used to control the bind-if is going to change, then the solution is to put "+"the <oj-form-layout> inside the 'bind' tag' (i.e. split the form layout into multiple layouts and control each as a unit).";const SHORT_DESCRIPTION="The use of <oj-bind-for-each>, <oj-bind-if>, or <oj-if> inside <oj-form-layout> is not supported";const OJ_IF="oj-if";const OJ_BIND_IF="oj-bind-if";const OJ_BIND_FOR_EACH="oj-bind-for-each";class Rule{getName(){return RULENAME}getDescription(){return DESCRIPTION}getShortDescription(){return SHORT_DESCRIPTION}register(){return{"<oj-form-layout>":this._onForm,"<oj-c-form-layout>":this._onForm}}_onForm(ruleCtx){let node=ruleCtx.tagNode;let attribs=node.attribs;if(this._attrVal(attribs,"direction")!=="column"){let maxcol=this._attrVal(attribs,"max-columns");if(isNaN(maxcol)||maxcol>1){this._walkDomChildren(ruleCtx,node)}}}_emit(ruleCtx,node){let issue=new ruleCtx.Issue(`<oj-form-layout> is meant to have static content only. The use of <${node.name}> is not supported`);issue.setPosition(null,null,node.startIndex+1,node.startIndex+node.name.length);ruleCtx.reporter.addIssue(issue,ruleCtx)}_walkDomChildren(ruleCtx,node){var ch,n,i,ok=true;;ch=node.children;if(ch){for(i=0;i<ch.length;i++){n=ch[i];if(n.type==="tag"){let name=n.name;if(name===OJ_BIND_FOR_EACH){ok=false;this._emit(ruleCtx,n)}else if(name===OJ_BIND_IF||name===OJ_IF){if(n.children&&n.children.length>1){ok=false;this._emit(ruleCtx,n)}}}}}return ok}_attrVal(attribs,attr){var v=attribs[attr];return attr==="max-columns"?parseInt(v):v}}module.exports=Rule;