63ec959edab3182428febc6a5de9bebf0a45ed98
[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 _0xd081=['agicommand','vswitch','target','traverseBFS','default\x20on\x20switch\x20not\x20found','includes','max\x20retry\x20reach','condition\x20not\x20found','exports','lodash','../../../config/logger','agi','menu','getdigits','getsecretdigits','vertices','numberOfEdges','prototype','addEdge','edges','push','size','relations','getVertex','info','no\x20vertex\x20found','stop\x20traverse','split'];(function(_0x515b6c,_0x3cb7e7){var _0x42ba30=function(_0x1f9aed){while(--_0x1f9aed){_0x515b6c['push'](_0x515b6c['shift']());}};_0x42ba30(++_0x3cb7e7);}(_0xd081,0x13d));var _0x1d08=function(_0x2ad33f,_0x1c4260){_0x2ad33f=_0x2ad33f-0x0;var _0x4b83e9=_0xd081[_0x2ad33f];return _0x4b83e9;};'use strict';var _=require(_0x1d08('0x0'));var logger=require(_0x1d08('0x1'))(_0x1d08('0x2'));var verticesWithRetry=[_0x1d08('0x3'),_0x1d08('0x4'),_0x1d08('0x5')];var Graph=function(){this[_0x1d08('0x6')]={};this['edges']={};this[_0x1d08('0x7')]=0x0;};Graph[_0x1d08('0x8')]['addVertex']=function(_0x5057cb){this[_0x1d08('0x6')][_0x5057cb['id']]=_0x5057cb;this['edges'][_0x5057cb['id']]=[];};Graph[_0x1d08('0x8')][_0x1d08('0x9')]=function(_0x3b9d20,_0x7cdf7e,_0x4258c4){this[_0x1d08('0xa')][_0x3b9d20][_0x1d08('0xb')]({'target':_0x7cdf7e,'condition':_0x4258c4});this[_0x1d08('0x7')]+=0x1;};Graph[_0x1d08('0x8')]['size']=function(){return _[_0x1d08('0xc')](this['vertices']);};Graph[_0x1d08('0x8')][_0x1d08('0xd')]=function(){return this[_0x1d08('0x7')];};Graph[_0x1d08('0x8')][_0x1d08('0xe')]=function(_0x4aac26){return this[_0x1d08('0x6')][_0x4aac26];};Graph[_0x1d08('0x8')]['traverseBFS']=function(_0x3aaed5,_0x4ae457){if(!this[_0x1d08('0x6')][_0x3aaed5]){return logger[_0x1d08('0xf')](_0x1d08('0x10'));}var _0x33f0c6=_0x4ae457(this[_0x1d08('0x6')][_0x3aaed5]);if(!_0x33f0c6){return logger['info'](_0x1d08('0x11'));}if(this[_0x1d08('0xa')][_0x3aaed5]['length']===0x0){return logger['info']('no\x20edge/s\x20available');}for(var _0x780ed4=0x0,_0x390a6e=[],_0xf10cdf=![];_0x780ed4<this[_0x1d08('0xa')][_0x3aaed5]['length'];_0x780ed4+=0x1){if(this[_0x1d08('0xa')][_0x3aaed5][_0x780ed4]['condition']){_0x390a6e=this[_0x1d08('0xa')][_0x3aaed5][_0x780ed4]['condition'][_0x1d08('0x12')](',');for(var _0x56b781=0x0;_0x56b781<_0x390a6e['length'];_0x56b781+=0x1){if(this['vertices'][_0x3aaed5][_0x1d08('0x13')]===_0x1d08('0x14')&&_0x390a6e[_0x56b781]==='-'){_0xf10cdf=this[_0x1d08('0xa')][_0x3aaed5][_0x780ed4][_0x1d08('0x15')];logger[_0x1d08('0xf')]('default',_0x390a6e[_0x56b781],this[_0x1d08('0xa')][_0x3aaed5][_0x780ed4][_0x1d08('0x15')]);}else if(this[_0x1d08('0x6')][_0x3aaed5][_0x1d08('0x13')]===_0x1d08('0x3')&&_0x390a6e[_0x56b781]==='i'){_0xf10cdf=this['edges'][_0x3aaed5][_0x780ed4]['target'];logger['info']('invalid',_0x390a6e[_0x56b781],this[_0x1d08('0xa')][_0x3aaed5][_0x780ed4][_0x1d08('0x15')]);}if(_0x390a6e[_0x56b781]===_0x33f0c6){return this[_0x1d08('0x16')](this[_0x1d08('0xa')][_0x3aaed5][_0x780ed4][_0x1d08('0x15')],_0x4ae457);}}}else{return this[_0x1d08('0x16')](this[_0x1d08('0xa')][_0x3aaed5][_0x780ed4][_0x1d08('0x15')],_0x4ae457);}}if(_0x390a6e['length']){if(this[_0x1d08('0x6')][_0x3aaed5][_0x1d08('0x13')]==='vswitch'){if(_0xf10cdf){return this['traverseBFS'](_0xf10cdf,_0x4ae457);}return logger[_0x1d08('0xf')](_0x1d08('0x17'));}else if(_[_0x1d08('0x18')](verticesWithRetry,this['vertices'][_0x3aaed5][_0x1d08('0x13')])){if(_0x33f0c6==='-'){return logger['info'](_0x1d08('0x19'));}if(_0xf10cdf&&_0x33f0c6!=='t'){return this[_0x1d08('0x16')](_0xf10cdf,_0x4ae457);}return this['traverseBFS'](_0x3aaed5,_0x4ae457);}return logger[_0x1d08('0xf')](_0x1d08('0x1a'));}};module[_0x1d08('0x1b')]=Graph;