/*
 * 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/
 */
var Jaf=function(){this._audit=require("./src/JafCore");this._api=require("./lib/api");this._nd={fs:require("fs"),path:require("path"),glob:require("glob"),process:process,os:require("os"),decomment:require("strip-json-comments"),decache:require("decache"),Config:require("./lib/Config"),metaLoader:require("./lib/metaLoader"),ruleLoader:require("./lib/ruleLoader"),msgidLoader:require("./lib/msgidLoader"),jsonLoader:require("./lib/JsonLoader"),Components:require("./lib/Components"),ComponentSvcs:require("./lib/ComponentSvcs"),schema:require("./lib/schema"),builtinpacks:null,extends:require("./lib/extends"),tsparse:require("@typescript-eslint/typescript-estree"),fsUtils:require("./lib/FsUtils"),zipUtils:require("./lib/ZipUtils"),tsUtils:require("./lib/TsUtils"),jetver:require("./lib/jetver"),exportRules:require("./lib/exportRules"),spinner:require("./lib/spinnernoop")};this._audit=new this._audit(this._nd,"api");this._api=new this._api(this._nd,this._audit);this._error=1};Jaf.prototype.initSync=function(config,cbIssue,cbMsg,cbSummary){this._error=this._api.startSync({config:config,cbIssue:cbIssue,cbMsg:cbMsg,cbSummary:cbSummary});return this._error};Jaf.prototype.init=function(config){this._error=0;return this._api.start({config:config})};Jaf.prototype.auditSync=function(filespec){var i,rc=this._error;if(!this._error){if(this._audit._regListenerTypesSet){return rc}if(Array.isArray(filespec)&&filespec.length){for(i=0;i<filespec.length;i++){rc=this._api.auditSync(filespec[i])}}else{rc=this._api.auditSync(filespec)}}return rc};Jaf.prototype.audit=function(filespec){var _self=this;return new Promise((resolve,reject)=>{if(!_self._error){_self._api.audit(filespec).then(rc=>{if(_self.getMarker()){console.log(`jafapi audit.then(${_self.getMarker()}) rc = ${rc}`)}rc?resolve(rc):reject(1)}).catch(e=>{if(_self.getMarker()){console.log(`jafapi catch(${_self.getMarker()}) ${e}`)}reject(e)})}else{reject(_self._error)}})};Jaf.prototype.on=function(evName,fn,extra){this._api.on(evName,fn,extra);return this};Jaf.prototype.removeAllListeners=function(evName){this._api.removeAllListeners(evName);return this};Jaf.prototype.removeListener=function(evName,fn){this._api.removeListener(evName,fn);return this};Jaf.prototype.plugins=function(ar){this._api.plugins(ar);return this};Jaf.prototype.getDescription=function(issue,short){return this._api.getDescription(issue,short)};Jaf.prototype.getActiveRulesetInfo=function(fmt){fmt=fmt!=="json"&&fmt!=="prose"&&fmt!=="sonar"?"json":fmt;return this._api.getRulesetInfo(fmt,true)};Jaf.prototype.setCallbacks=function(fnIssue,fnMsg,fnSummary){this._audit.setApiCallbacks(fnIssue,fnMsg,fnSummary)};Jaf.prototype.enableMsgId=function(msgid,state){return this._api.enableMsgId(msgid,state)};Jaf.prototype.getConfig=function(){return this._api.getConfig()};Jaf.prototype.getSevLib=function(){return this._api.getSevLib()};Jaf.prototype.enableRule=function(ruleName,state){return this._api.enableRule(ruleName,state)};Jaf.prototype.getInfo=function(){return this._api.getInfo()};Jaf.prototype.getMarker=function(){return this._api.getMarker()};Jaf.prototype.setMarker=function(mark){return this._api.setMarker(mark)};Jaf.prototype.setVsCodeExtHint=function(isVsCodeExt){isVsCodeExt=isVsCodeExt!==undefined?!!isVsCodeExt:true;return this._api.setVsCodeExtHint(isVsCodeExt)};module.exports=Jaf;