5aeedbf29b28720245ecf7b08a8018b03b5ed86f
[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 _0x63ca=['../../../config/logger','agi','menu','getdigits','getsecretdigits','edges','numberOfEdges','prototype','addVertex','vertices','addEdge','push','size','relations','getVertex','info','no\x20vertex\x20found','stop\x20traverse','length','condition','agicommand','vswitch','target','invalid','traverseBFS','default\x20on\x20switch\x20not\x20found','max\x20retry\x20reach','exports','lodash'];(function(_0x173c98,_0x38dc60){var _0x1303dc=function(_0x47b54f){while(--_0x47b54f){_0x173c98['push'](_0x173c98['shift']());}};_0x1303dc(++_0x38dc60);}(_0x63ca,0xca));var _0xa63c=function(_0x11765d,_0x46113b){_0x11765d=_0x11765d-0x0;var _0x389e72=_0x63ca[_0x11765d];return _0x389e72;};'use strict';var _=require(_0xa63c('0x0'));var logger=require(_0xa63c('0x1'))(_0xa63c('0x2'));var verticesWithRetry=[_0xa63c('0x3'),_0xa63c('0x4'),_0xa63c('0x5')];var Graph=function(){this['vertices']={};this[_0xa63c('0x6')]={};this[_0xa63c('0x7')]=0x0;};Graph[_0xa63c('0x8')][_0xa63c('0x9')]=function(_0x18de75){this[_0xa63c('0xa')][_0x18de75['id']]=_0x18de75;this[_0xa63c('0x6')][_0x18de75['id']]=[];};Graph[_0xa63c('0x8')][_0xa63c('0xb')]=function(_0x5a825a,_0x1a3aa3,_0x39b586){this[_0xa63c('0x6')][_0x5a825a][_0xa63c('0xc')]({'target':_0x1a3aa3,'condition':_0x39b586});this[_0xa63c('0x7')]+=0x1;};Graph[_0xa63c('0x8')][_0xa63c('0xd')]=function(){return _['size'](this['vertices']);};Graph[_0xa63c('0x8')][_0xa63c('0xe')]=function(){return this['numberOfEdges'];};Graph['prototype'][_0xa63c('0xf')]=function(_0x35535e){return this[_0xa63c('0xa')][_0x35535e];};Graph['prototype']['traverseBFS']=function(_0x34407d,_0x11b32a){if(!this['vertices'][_0x34407d]){return logger[_0xa63c('0x10')](_0xa63c('0x11'));}var _0x137225=_0x11b32a(this['vertices'][_0x34407d]);if(!_0x137225){return logger[_0xa63c('0x10')](_0xa63c('0x12'));}if(this['edges'][_0x34407d][_0xa63c('0x13')]===0x0){return logger[_0xa63c('0x10')]('no\x20edge/s\x20available');}for(var _0x3902bf=0x0,_0x3c15dd=[],_0x16bca9=![];_0x3902bf<this['edges'][_0x34407d]['length'];_0x3902bf+=0x1){if(this[_0xa63c('0x6')][_0x34407d][_0x3902bf]['condition']){_0x3c15dd=this[_0xa63c('0x6')][_0x34407d][_0x3902bf][_0xa63c('0x14')]['split'](',');for(var _0x488d94=0x0;_0x488d94<_0x3c15dd[_0xa63c('0x13')];_0x488d94+=0x1){if(this['vertices'][_0x34407d][_0xa63c('0x15')]===_0xa63c('0x16')&&_0x3c15dd[_0x488d94]==='-'){_0x16bca9=this[_0xa63c('0x6')][_0x34407d][_0x3902bf][_0xa63c('0x17')];logger[_0xa63c('0x10')]('default',_0x3c15dd[_0x488d94],this[_0xa63c('0x6')][_0x34407d][_0x3902bf]['target']);}else if(this[_0xa63c('0xa')][_0x34407d]['agicommand']==='menu'&&_0x3c15dd[_0x488d94]==='i'){_0x16bca9=this[_0xa63c('0x6')][_0x34407d][_0x3902bf][_0xa63c('0x17')];logger[_0xa63c('0x10')](_0xa63c('0x18'),_0x3c15dd[_0x488d94],this[_0xa63c('0x6')][_0x34407d][_0x3902bf][_0xa63c('0x17')]);}if(_0x3c15dd[_0x488d94]===_0x137225){return this[_0xa63c('0x19')](this['edges'][_0x34407d][_0x3902bf][_0xa63c('0x17')],_0x11b32a);}}}else{return this[_0xa63c('0x19')](this[_0xa63c('0x6')][_0x34407d][_0x3902bf]['target'],_0x11b32a);}}if(_0x3c15dd['length']){if(this[_0xa63c('0xa')][_0x34407d][_0xa63c('0x15')]===_0xa63c('0x16')){if(_0x16bca9){return this[_0xa63c('0x19')](_0x16bca9,_0x11b32a);}return logger[_0xa63c('0x10')](_0xa63c('0x1a'));}else if(_['includes'](verticesWithRetry,this['vertices'][_0x34407d][_0xa63c('0x15')])){if(_0x137225==='-'){return logger[_0xa63c('0x10')](_0xa63c('0x1b'));}if(_0x16bca9&&_0x137225!=='t'){return this[_0xa63c('0x19')](_0x16bca9,_0x11b32a);}return this['traverseBFS'](_0x34407d,_0x11b32a);}return logger[_0xa63c('0x10')]('condition\x20not\x20found');}};module[_0xa63c('0x1c')]=Graph;