Built motion from commit 00bf23f6.|2.6.16
[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 _0x07c9=['includes','condition\x20not\x20found','lodash','../../../config/logger','agi','getsecretdigits','vertices','prototype','edges','addEdge','push','numberOfEdges','size','getVertex','info','no\x20vertex\x20found','stop\x20traverse','length','condition','split','vswitch','target','default','agicommand','menu','invalid','traverseBFS','default\x20on\x20switch\x20not\x20found'];(function(_0x30a41c,_0x52bce1){var _0x219ad1=function(_0x4152f6){while(--_0x4152f6){_0x30a41c['push'](_0x30a41c['shift']());}};_0x219ad1(++_0x52bce1);}(_0x07c9,0xc6));var _0x907c=function(_0x4325e2,_0x3b34cc){_0x4325e2=_0x4325e2-0x0;var _0x4965df=_0x07c9[_0x4325e2];return _0x4965df;};'use strict';var _=require(_0x907c('0x0'));var logger=require(_0x907c('0x1'))(_0x907c('0x2'));var verticesWithRetry=['menu','getdigits',_0x907c('0x3')];var Graph=function(){this[_0x907c('0x4')]={};this['edges']={};this['numberOfEdges']=0x0;};Graph[_0x907c('0x5')]['addVertex']=function(_0x5030a6){this[_0x907c('0x4')][_0x5030a6['id']]=_0x5030a6;this[_0x907c('0x6')][_0x5030a6['id']]=[];};Graph[_0x907c('0x5')][_0x907c('0x7')]=function(_0x39843f,_0x585282,_0x3b0dd5){this[_0x907c('0x6')][_0x39843f][_0x907c('0x8')]({'target':_0x585282,'condition':_0x3b0dd5});this[_0x907c('0x9')]+=0x1;};Graph[_0x907c('0x5')][_0x907c('0xa')]=function(){return _[_0x907c('0xa')](this[_0x907c('0x4')]);};Graph[_0x907c('0x5')]['relations']=function(){return this[_0x907c('0x9')];};Graph['prototype'][_0x907c('0xb')]=function(_0x5cae34){return this[_0x907c('0x4')][_0x5cae34];};Graph['prototype']['traverseBFS']=function(_0xccceda,_0x3d2123){if(!this[_0x907c('0x4')][_0xccceda]){return logger[_0x907c('0xc')](_0x907c('0xd'));}var _0x1b4d7a=_0x3d2123(this[_0x907c('0x4')][_0xccceda]);if(!_0x1b4d7a){return logger[_0x907c('0xc')](_0x907c('0xe'));}if(this['edges'][_0xccceda][_0x907c('0xf')]===0x0){return logger['info']('no\x20edge/s\x20available');}for(var _0x1982d5=0x0,_0x51a7c1=[],_0x47aa24=![];_0x1982d5<this['edges'][_0xccceda][_0x907c('0xf')];_0x1982d5+=0x1){if(this[_0x907c('0x6')][_0xccceda][_0x1982d5]['condition']){_0x51a7c1=this[_0x907c('0x6')][_0xccceda][_0x1982d5][_0x907c('0x10')][_0x907c('0x11')](',');for(var _0x203517=0x0;_0x203517<_0x51a7c1[_0x907c('0xf')];_0x203517+=0x1){if(this[_0x907c('0x4')][_0xccceda]['agicommand']===_0x907c('0x12')&&_0x51a7c1[_0x203517]==='-'){_0x47aa24=this[_0x907c('0x6')][_0xccceda][_0x1982d5][_0x907c('0x13')];logger[_0x907c('0xc')](_0x907c('0x14'),_0x51a7c1[_0x203517],this['edges'][_0xccceda][_0x1982d5]['target']);}else if(this[_0x907c('0x4')][_0xccceda][_0x907c('0x15')]===_0x907c('0x16')&&_0x51a7c1[_0x203517]==='i'){_0x47aa24=this[_0x907c('0x6')][_0xccceda][_0x1982d5][_0x907c('0x13')];logger[_0x907c('0xc')](_0x907c('0x17'),_0x51a7c1[_0x203517],this['edges'][_0xccceda][_0x1982d5][_0x907c('0x13')]);}if(_0x51a7c1[_0x203517]===_0x1b4d7a){return this['traverseBFS'](this[_0x907c('0x6')][_0xccceda][_0x1982d5][_0x907c('0x13')],_0x3d2123);}}}else{return this[_0x907c('0x18')](this['edges'][_0xccceda][_0x1982d5]['target'],_0x3d2123);}}if(_0x51a7c1['length']){if(this['vertices'][_0xccceda][_0x907c('0x15')]===_0x907c('0x12')){if(_0x47aa24){return this[_0x907c('0x18')](_0x47aa24,_0x3d2123);}return logger[_0x907c('0xc')](_0x907c('0x19'));}else if(_[_0x907c('0x1a')](verticesWithRetry,this[_0x907c('0x4')][_0xccceda][_0x907c('0x15')])){if(_0x1b4d7a==='-'){return logger['info']('max\x20retry\x20reach');}if(_0x47aa24&&_0x1b4d7a!=='t'){return this[_0x907c('0x18')](_0x47aa24,_0x3d2123);}return this[_0x907c('0x18')](_0xccceda,_0x3d2123);}return logger[_0x907c('0xc')](_0x907c('0x1b'));}};module['exports']=Graph;