dee1d707dc749c9a38587f7b4cea31acbf13e6d9
[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 _0xadf3=['numberOfEdges','prototype','addEdge','push','size','relations','getVertex','traverseBFS','info','no\x20vertex\x20found','stop\x20traverse','length','no\x20edge/s\x20available','condition','split','agicommand','vswitch','target','default','invalid','default\x20on\x20switch\x20not\x20found','includes','max\x20retry\x20reach','condition\x20not\x20found','exports','agi','menu','vertices','edges'];(function(_0xc69ded,_0x26a593){var _0x359ecf=function(_0x3c6dbb){while(--_0x3c6dbb){_0xc69ded['push'](_0xc69ded['shift']());}};_0x359ecf(++_0x26a593);}(_0xadf3,0x13b));var _0x3adf=function(_0x39a8d4,_0x3c7767){_0x39a8d4=_0x39a8d4-0x0;var _0x4d3e7e=_0xadf3[_0x39a8d4];return _0x4d3e7e;};'use strict';var _=require('lodash');var logger=require('../../../config/logger')(_0x3adf('0x0'));var verticesWithRetry=[_0x3adf('0x1'),'getdigits','getsecretdigits'];var Graph=function(){this[_0x3adf('0x2')]={};this[_0x3adf('0x3')]={};this[_0x3adf('0x4')]=0x0;};Graph[_0x3adf('0x5')]['addVertex']=function(_0xb668cc){this[_0x3adf('0x2')][_0xb668cc['id']]=_0xb668cc;this[_0x3adf('0x3')][_0xb668cc['id']]=[];};Graph[_0x3adf('0x5')][_0x3adf('0x6')]=function(_0x3a8d74,_0x53abcb,_0x502e3b){this[_0x3adf('0x3')][_0x3a8d74][_0x3adf('0x7')]({'target':_0x53abcb,'condition':_0x502e3b});this[_0x3adf('0x4')]+=0x1;};Graph[_0x3adf('0x5')][_0x3adf('0x8')]=function(){return _['size'](this['vertices']);};Graph[_0x3adf('0x5')][_0x3adf('0x9')]=function(){return this['numberOfEdges'];};Graph[_0x3adf('0x5')][_0x3adf('0xa')]=function(_0x324083){return this['vertices'][_0x324083];};Graph[_0x3adf('0x5')][_0x3adf('0xb')]=function(_0x1d1442,_0x320e48){if(!this[_0x3adf('0x2')][_0x1d1442]){return logger[_0x3adf('0xc')](_0x3adf('0xd'));}var _0x1bd359=_0x320e48(this[_0x3adf('0x2')][_0x1d1442]);if(!_0x1bd359){return logger[_0x3adf('0xc')](_0x3adf('0xe'));}if(this[_0x3adf('0x3')][_0x1d1442][_0x3adf('0xf')]===0x0){return logger['info'](_0x3adf('0x10'));}for(var _0x415a18=0x0,_0x4caebd=[],_0x245495=![];_0x415a18<this['edges'][_0x1d1442][_0x3adf('0xf')];_0x415a18+=0x1){if(this[_0x3adf('0x3')][_0x1d1442][_0x415a18][_0x3adf('0x11')]){_0x4caebd=this[_0x3adf('0x3')][_0x1d1442][_0x415a18]['condition'][_0x3adf('0x12')](',');for(var _0x5964d0=0x0;_0x5964d0<_0x4caebd[_0x3adf('0xf')];_0x5964d0+=0x1){if(this[_0x3adf('0x2')][_0x1d1442][_0x3adf('0x13')]===_0x3adf('0x14')&&_0x4caebd[_0x5964d0]==='-'){_0x245495=this[_0x3adf('0x3')][_0x1d1442][_0x415a18][_0x3adf('0x15')];logger[_0x3adf('0xc')](_0x3adf('0x16'),_0x4caebd[_0x5964d0],this[_0x3adf('0x3')][_0x1d1442][_0x415a18][_0x3adf('0x15')]);}else if(this[_0x3adf('0x2')][_0x1d1442]['agicommand']===_0x3adf('0x1')&&_0x4caebd[_0x5964d0]==='i'){_0x245495=this[_0x3adf('0x3')][_0x1d1442][_0x415a18][_0x3adf('0x15')];logger[_0x3adf('0xc')](_0x3adf('0x17'),_0x4caebd[_0x5964d0],this[_0x3adf('0x3')][_0x1d1442][_0x415a18][_0x3adf('0x15')]);}if(_0x4caebd[_0x5964d0]===_0x1bd359){return this[_0x3adf('0xb')](this[_0x3adf('0x3')][_0x1d1442][_0x415a18]['target'],_0x320e48);}}}else{return this['traverseBFS'](this[_0x3adf('0x3')][_0x1d1442][_0x415a18]['target'],_0x320e48);}}if(_0x4caebd[_0x3adf('0xf')]){if(this[_0x3adf('0x2')][_0x1d1442]['agicommand']===_0x3adf('0x14')){if(_0x245495){return this[_0x3adf('0xb')](_0x245495,_0x320e48);}return logger[_0x3adf('0xc')](_0x3adf('0x18'));}else if(_[_0x3adf('0x19')](verticesWithRetry,this[_0x3adf('0x2')][_0x1d1442]['agicommand'])){if(_0x1bd359==='-'){return logger[_0x3adf('0xc')](_0x3adf('0x1a'));}if(_0x245495&&_0x1bd359!=='t'){return this[_0x3adf('0xb')](_0x245495,_0x320e48);}return this[_0x3adf('0xb')](_0x1d1442,_0x320e48);}return logger['info'](_0x3adf('0x1b'));}};module[_0x3adf('0x1c')]=Graph;