/**
 * Minified by jsDelivr using Terser v5.48.0.
 * Original file: /npm/yekonga-server@4.4.18/src/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
const EventEmitter=require("events").EventEmitter;EventEmitter.defaultMaxListeners=0;const emitter=new EventEmitter;process.setMaxListeners(0),process.env.NODE_TLS_REJECT_UNAUTHORIZED=0,emitter.setMaxListeners(0),require("./global");const{YekongaServer:YekongaServer}=require("./core/init");Yekonga.setConfig=function(e,t){serverLibrary.__dirname=process.cwd(),serverLibrary.__src=__dirname,new YekongaServer(e,t)},Yekonga.updateConfig=function(e,t){var i=null,r=e.split(".");r.reverse();for(const e of r){var s={};s[e]=i||t,i=Yekonga.Helper.copyJson(s)}if(i.logoUrl){var o=Array.isArray(Yekonga.Config.public)?Yekonga.Config.public[0]:Yekonga.Config.public;i.logoUrl="uploads/"+Yekonga.Helper.saveFile(i.logoUrl,`${o}/uploads`)}Yekonga.Helper.mergeJSON(Yekonga.Config,i);const a=JSON.stringify(Yekonga.Config,null,4);Yekonga.Helper.writeFile("config.json",a,!0)},Yekonga.Storage=new class{constructor(){this.hasRedis=!1,this.client=null,this.localState={}}async connect(){try{var e={};Yekonga.Config.ports.redis&&(e.url=`redis://localhost:${Yekonga.Config.ports.redis}`),e.url&&(this.client=global.serverLibrary.createClient(e),this.client.on("error",e=>{console.error("Redis Client Error",e),this.hasRedis=!1}),await this.client.connect(),this.hasRedis=!0)}catch(e){console.error("Redis Connection",e),this.hasRedis=!1}}async acquireLock(e){var t=Math.floor(1e3*Math.random())+5;if(await new Promise(e=>setTimeout(e,t)),this.hasRedis){const t=6e5;return"OK"===await this.client.set(e,"locked",{NX:!0,PX:t})}return this.localState[e]=!0,!1}async releaseLock(e){this.hasRedis?await this.client.del(e):delete this.localState[e]}async set(e,t){this.hasRedis?await this.client.set(e,JSON.stringify(t)):this.localState[e]=t}async get(e,t){var i=null;try{i=this.hasRedis?JSON.parse(await this.client.get(e)):this.localState[e]}catch(e){console.error("Yekonga.Storage",e)}return void 0===i?t:i}async setObject(e,t){this.hasRedis?await this.client.hSet(e,t):this.localState[e]=t}async getObject(e,t){var i=null;return void 0===(i=this.hasRedis?await this.client.hGet(e):this.localState[e])?t||null:i}};let logo=serverLibrary.fs.readFileSync(serverLibrary.path.join(__dirname,"assets/logo-sm.text"),{encoding:"utf8"});Yekonga.Helper.printLog(null,logo,"yellow"),module.exports=()=>{console.info("Setup is ready")};
//# sourceMappingURL=/sm/f7749956cbbddee008d41b612c49038f820c009b8de53d594fc812a23ddf374b.map