/*
 * 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/
 */
function load(inFile,nd,fnError,allowComments,utils){var o=loadEx(inFile,nd,fnError,allowComments,utils);return o?o.obj:null};function loadEx(inFile,nd,fnError,allowComments,utils){var o,obj=null,jsonRaw,json;try{if(nd.fs.existsSync(inFile)){jsonRaw=json=nd.fs.readFileSync(inFile,"utf8");if(allowComments){json=nd.decomment(jsonRaw)}o=JSON.parse(json);obj={json:jsonRaw,obj:o}}else{if(fnError){fnError(`file not found "${inFile}"`)}}}catch(e){if(fnError){let msg=_convertJsonPosToRowCol(e.message,nd.fs.readFileSync(inFile,"utf8"),utils);fnError(msg?`${msg} : ${inFile}`:`${e.message}`)}}return obj};function _convertJsonPosToRowCol(msg,data,utils){var x,y,n,rc;x=msg.indexOf("position");if(x<0){return null}y=msg.indexOf("token");if(y>=0){y+=6;msg=msg.substring(0,y)+"'"+msg.substring(y,y+1)+"'"+msg.substring(y+1)}x=msg.indexOf("position");n=parseInt(msg.substr(x+8).trim());rc=utils.getRowColFromIndex(data,n);return msg.substring(0,x)+"line "+rc.row+", col "+rc.col};module.exports.load=load;module.exports.loadEx=loadEx;