/*
 * 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 RULENAME="oj-tsx-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";const COLUMN="column";const MAX_COLUMNS="max-columns";const DIRECTION="direction";class Rule{getName(){return RULENAME}getDescription(){return DESCRIPTION}getShortDescription(){return SHORT_DESCRIPTION}register(){return{"Tsx<oj-form-layout>":this._onForm,"Tsx<oj-c-form-layout>":this._onForm}}_onForm(ruleCtx,tsxComp){let tsxUtils=ruleCtx.utils.tsxUtils;let val;if(val=tsxUtils.getPropertyRawValue(tsxComp,DIRECTION,true)){if(val!==COLUMN){let maxcol=tsxUtils.getPropertyRawValue(tsxComp,MAX_COLUMNS,true);if(!maxcol||isNaN(maxcol)||maxcol>1){this._walkDomChildren(ruleCtx,tsxComp)}}}}_emit(ruleCtx,tsxComp){let issue=new ruleCtx.Issue(`<oj-form-layout> is meant to have static content only. The use of <${tsxComp.name}> is not supported`);ruleCtx.utils.tsxUtils.setIssuePosition(issue,tsxComp);ruleCtx.reporter.addIssue(issue,ruleCtx)}_walkDomChildren(ruleCtx,comp){var ch,tsxComp,i,ok=true;;if(ch=comp.children){for(i=0;i<ch.length;i++){let name;tsxComp=ch[i];name=tsxComp.name;if(name===OJ_BIND_FOR_EACH){ok=false;this._emit(ruleCtx,tsxComp)}else if(name===OJ_BIND_IF||name===OJ_IF){if(tsxComp.children&&tsxComp.children.length>1){ok=false;this._emit(ruleCtx,tsxComp)}}}}return ok}}module.exports=Rule;