ebecc3c4246f7cb84679a406cbfaa38edb0ab390
[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 _0x3add=['no\x20edge/s\x20available','condition','split','agicommand','vswitch','target','default','invalid','max\x20retry\x20reach','lodash','../../../config/logger','agi','menu','getdigits','edges','numberOfEdges','prototype','addVertex','addEdge','push','size','vertices','relations','getVertex','traverseBFS','info','no\x20vertex\x20found','stop\x20traverse','length'];(function(_0x2b6a8f,_0x294599){var _0x2d2036=function(_0x1ea077){while(--_0x1ea077){_0x2b6a8f['push'](_0x2b6a8f['shift']());}};_0x2d2036(++_0x294599);}(_0x3add,0x10e));var _0xd3ad=function(_0x1b2ff7,_0x12a034){_0x1b2ff7=_0x1b2ff7-0x0;var _0x31656a=_0x3add[_0x1b2ff7];return _0x31656a;};'use strict';var _=require(_0xd3ad('0x0'));var logger=require(_0xd3ad('0x1'))(_0xd3ad('0x2'));var verticesWithRetry=[_0xd3ad('0x3'),_0xd3ad('0x4'),'getsecretdigits'];var Graph=function(){this['vertices']={};this[_0xd3ad('0x5')]={};this[_0xd3ad('0x6')]=0x0;};Graph[_0xd3ad('0x7')][_0xd3ad('0x8')]=function(_0x50574c){this['vertices'][_0x50574c['id']]=_0x50574c;this['edges'][_0x50574c['id']]=[];};Graph[_0xd3ad('0x7')][_0xd3ad('0x9')]=function(_0x4b4579,_0x33a722,_0x4ca709){this[_0xd3ad('0x5')][_0x4b4579][_0xd3ad('0xa')]({'target':_0x33a722,'condition':_0x4ca709});this['numberOfEdges']+=0x1;};Graph['prototype'][_0xd3ad('0xb')]=function(){return _[_0xd3ad('0xb')](this[_0xd3ad('0xc')]);};Graph['prototype'][_0xd3ad('0xd')]=function(){return this[_0xd3ad('0x6')];};Graph[_0xd3ad('0x7')][_0xd3ad('0xe')]=function(_0x2461d8){return this[_0xd3ad('0xc')][_0x2461d8];};Graph[_0xd3ad('0x7')][_0xd3ad('0xf')]=function(_0x5bc90d,_0x3b52a8){if(!this[_0xd3ad('0xc')][_0x5bc90d]){return logger[_0xd3ad('0x10')](_0xd3ad('0x11'));}var _0x4a461d=_0x3b52a8(this['vertices'][_0x5bc90d]);if(!_0x4a461d){return logger[_0xd3ad('0x10')](_0xd3ad('0x12'));}if(this[_0xd3ad('0x5')][_0x5bc90d][_0xd3ad('0x13')]===0x0){return logger[_0xd3ad('0x10')](_0xd3ad('0x14'));}for(var _0x351235=0x0,_0x37d502=[],_0x15a59f=![];_0x351235<this[_0xd3ad('0x5')][_0x5bc90d][_0xd3ad('0x13')];_0x351235+=0x1){if(this[_0xd3ad('0x5')][_0x5bc90d][_0x351235]['condition']){_0x37d502=this['edges'][_0x5bc90d][_0x351235][_0xd3ad('0x15')][_0xd3ad('0x16')](',');for(var _0x189932=0x0;_0x189932<_0x37d502[_0xd3ad('0x13')];_0x189932+=0x1){if(this[_0xd3ad('0xc')][_0x5bc90d][_0xd3ad('0x17')]===_0xd3ad('0x18')&&_0x37d502[_0x189932]==='-'){_0x15a59f=this[_0xd3ad('0x5')][_0x5bc90d][_0x351235][_0xd3ad('0x19')];logger[_0xd3ad('0x10')](_0xd3ad('0x1a'),_0x37d502[_0x189932],this[_0xd3ad('0x5')][_0x5bc90d][_0x351235][_0xd3ad('0x19')]);}else if(this[_0xd3ad('0xc')][_0x5bc90d][_0xd3ad('0x17')]===_0xd3ad('0x3')&&_0x37d502[_0x189932]==='i'){_0x15a59f=this[_0xd3ad('0x5')][_0x5bc90d][_0x351235]['target'];logger[_0xd3ad('0x10')](_0xd3ad('0x1b'),_0x37d502[_0x189932],this[_0xd3ad('0x5')][_0x5bc90d][_0x351235][_0xd3ad('0x19')]);}if(_0x37d502[_0x189932]===_0x4a461d){return this[_0xd3ad('0xf')](this['edges'][_0x5bc90d][_0x351235]['target'],_0x3b52a8);}}}else{return this[_0xd3ad('0xf')](this[_0xd3ad('0x5')][_0x5bc90d][_0x351235][_0xd3ad('0x19')],_0x3b52a8);}}if(_0x37d502[_0xd3ad('0x13')]){if(this[_0xd3ad('0xc')][_0x5bc90d][_0xd3ad('0x17')]==='vswitch'){if(_0x15a59f){return this[_0xd3ad('0xf')](_0x15a59f,_0x3b52a8);}return logger[_0xd3ad('0x10')]('default\x20on\x20switch\x20not\x20found');}else if(_['includes'](verticesWithRetry,this[_0xd3ad('0xc')][_0x5bc90d]['agicommand'])){if(_0x4a461d==='-'){return logger[_0xd3ad('0x10')](_0xd3ad('0x1c'));}if(_0x15a59f&&_0x4a461d!=='t'){return this[_0xd3ad('0xf')](_0x15a59f,_0x3b52a8);}return this[_0xd3ad('0xf')](_0x5bc90d,_0x3b52a8);}return logger[_0xd3ad('0x10')]('condition\x20not\x20found');}};module['exports']=Graph;