52dfc25f5ed9327f8a24dca5cb7accbe9a39ab5b
[motion2.git] / server / services / agi / graph / index.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xc072=['includes','max\x20retry\x20reach','condition\x20not\x20found','exports','agi','menu','getdigits','vertices','edges','prototype','addVertex','addEdge','push','numberOfEdges','size','relations','traverseBFS','no\x20vertex\x20found','info','stop\x20traverse','length','no\x20edge/s\x20available','condition','split','agicommand','vswitch','target','default','invalid','default\x20on\x20switch\x20not\x20found'];(function(_0x5a6ac3,_0x4a57b6){var _0x54f5fe=function(_0x59dd89){while(--_0x59dd89){_0x5a6ac3['push'](_0x5a6ac3['shift']());}};_0x54f5fe(++_0x4a57b6);}(_0xc072,0x14e));var _0x2c07=function(_0x4865f0,_0x5431c7){_0x4865f0=_0x4865f0-0x0;var _0x22363f=_0xc072[_0x4865f0];return _0x22363f;};'use strict';var _=require('lodash');var logger=require('../../../config/logger')(_0x2c07('0x0'));var verticesWithRetry=[_0x2c07('0x1'),_0x2c07('0x2'),'getsecretdigits'];var Graph=function(){this[_0x2c07('0x3')]={};this[_0x2c07('0x4')]={};this['numberOfEdges']=0x0;};Graph[_0x2c07('0x5')][_0x2c07('0x6')]=function(_0x3bc164){this['vertices'][_0x3bc164['id']]=_0x3bc164;this[_0x2c07('0x4')][_0x3bc164['id']]=[];};Graph['prototype'][_0x2c07('0x7')]=function(_0x2266fc,_0x5c6e92,_0x21f74f){this['edges'][_0x2266fc][_0x2c07('0x8')]({'target':_0x5c6e92,'condition':_0x21f74f});this[_0x2c07('0x9')]+=0x1;};Graph[_0x2c07('0x5')][_0x2c07('0xa')]=function(){return _[_0x2c07('0xa')](this[_0x2c07('0x3')]);};Graph['prototype'][_0x2c07('0xb')]=function(){return this['numberOfEdges'];};Graph['prototype']['getVertex']=function(_0x12210e){return this[_0x2c07('0x3')][_0x12210e];};Graph['prototype'][_0x2c07('0xc')]=function(_0x2a9a8a,_0x59b262){if(!this['vertices'][_0x2a9a8a]){return logger['info'](_0x2c07('0xd'));}var _0x48b5ca=_0x59b262(this[_0x2c07('0x3')][_0x2a9a8a]);if(!_0x48b5ca){return logger[_0x2c07('0xe')](_0x2c07('0xf'));}if(this[_0x2c07('0x4')][_0x2a9a8a][_0x2c07('0x10')]===0x0){return logger[_0x2c07('0xe')](_0x2c07('0x11'));}for(var _0x2dd72b=0x0,_0x43165f=[],_0x374b20=![];_0x2dd72b<this[_0x2c07('0x4')][_0x2a9a8a][_0x2c07('0x10')];_0x2dd72b+=0x1){if(this[_0x2c07('0x4')][_0x2a9a8a][_0x2dd72b][_0x2c07('0x12')]){_0x43165f=this[_0x2c07('0x4')][_0x2a9a8a][_0x2dd72b]['condition'][_0x2c07('0x13')](',');for(var _0x387e5f=0x0;_0x387e5f<_0x43165f[_0x2c07('0x10')];_0x387e5f+=0x1){if(this[_0x2c07('0x3')][_0x2a9a8a][_0x2c07('0x14')]===_0x2c07('0x15')&&_0x43165f[_0x387e5f]==='-'){_0x374b20=this[_0x2c07('0x4')][_0x2a9a8a][_0x2dd72b][_0x2c07('0x16')];logger[_0x2c07('0xe')](_0x2c07('0x17'),_0x43165f[_0x387e5f],this[_0x2c07('0x4')][_0x2a9a8a][_0x2dd72b][_0x2c07('0x16')]);}else if(this[_0x2c07('0x3')][_0x2a9a8a][_0x2c07('0x14')]===_0x2c07('0x1')&&_0x43165f[_0x387e5f]==='i'){_0x374b20=this[_0x2c07('0x4')][_0x2a9a8a][_0x2dd72b][_0x2c07('0x16')];logger[_0x2c07('0xe')](_0x2c07('0x18'),_0x43165f[_0x387e5f],this[_0x2c07('0x4')][_0x2a9a8a][_0x2dd72b]['target']);}if(_0x43165f[_0x387e5f]===_0x48b5ca){return this['traverseBFS'](this['edges'][_0x2a9a8a][_0x2dd72b][_0x2c07('0x16')],_0x59b262);}}}else{return this[_0x2c07('0xc')](this[_0x2c07('0x4')][_0x2a9a8a][_0x2dd72b][_0x2c07('0x16')],_0x59b262);}}if(_0x43165f[_0x2c07('0x10')]){if(this[_0x2c07('0x3')][_0x2a9a8a][_0x2c07('0x14')]===_0x2c07('0x15')){if(_0x374b20){return this[_0x2c07('0xc')](_0x374b20,_0x59b262);}return logger['info'](_0x2c07('0x19'));}else if(_[_0x2c07('0x1a')](verticesWithRetry,this['vertices'][_0x2a9a8a][_0x2c07('0x14')])){if(_0x48b5ca==='-'){return logger[_0x2c07('0xe')](_0x2c07('0x1b'));}if(_0x374b20&&_0x48b5ca!=='t'){return this['traverseBFS'](_0x374b20,_0x59b262);}return this[_0x2c07('0xc')](_0x2a9a8a,_0x59b262);}return logger[_0x2c07('0xe')](_0x2c07('0x1c'));}};module[_0x2c07('0x1d')]=Graph;