/*
 * 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 RULE_NAME="oj-html-attr-$unique";const $UNIQUE="$unique";const ID="id";const DATABIND="data-bind";const ATTR="attr";const MSG="Use $uniqueid instead of $unique in Knockout and web component syntax";const EXPLAIN="When generating or referencing element IDs in web components, $uniqueId should be used in preference to $unique to guarantee stable UI's for testing.";function getName(){return RULE_NAME}function getShortDescription(){return MSG}function getDescription(){return EXPLAIN}function register(){return{"notglob":_onComp}};function _onComp(ruleCtx){var attrs,attr,val;if(!(attrs=ruleCtx.tagNode.attribs)){return}for(attr in attrs){val=attrs[attr];_onAttr(ruleCtx,attr,val)}}function _onAttr(ruleCtx,attrName,attrValue){if(attrName===DATABIND&&attrValue.startsWith(ATTR)){if(_is$Unique(attrValue)){let issue=new ruleCtx.Issue(`<${ruleCtx.tag}> data-bind attribute uses $unique. ${EXPLAIN}`);issue.setMsgKey(RULE_NAME+"_1");_addIssue(ruleCtx,issue,attrName)}return}if(_is$Unique(attrValue)){let issue=new ruleCtx.Issue(`<${ruleCtx.tag}> - found use of $unique. ${EXPLAIN}`);issue.setMsgKey(RULE_NAME+"_2");_addIssue(ruleCtx,issue,attrName)}};function _addIssue(ruleCtx,issue,attrName){let attrPos=ruleCtx.utils.DomUtils.getAttribPosition(ruleCtx.data,ruleCtx.node,attrName);issue.setPosition(attrPos.row,attrPos.col,attrPos.start,attrPos.end);ruleCtx.reporter.addIssue(issue,ruleCtx)};function _is$Unique(s){var x,end,isIssue=false;x=s.indexOf($UNIQUE);if(x>=0){if(s.length>=x+$UNIQUE.length+ID.length){end=s.substr(x+$UNIQUE.length,2).toLowerCase();if(end!==ID){isIssue=true}}else{isIssue=true}}return isIssue};module.exports={getName,getDescription,getShortDescription,register};