Built motion from commit (unavailable).|2.5.4
[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 _0x2f68=['agicommand','target','default','traverseBFS','default\x20on\x20switch\x20not\x20found','includes','max\x20retry\x20reach','condition\x20not\x20found','exports','../../../config/logger','agi','menu','getdigits','vertices','numberOfEdges','prototype','addEdge','edges','push','size','relations','getVertex','info','no\x20vertex\x20found','stop\x20traverse','length','no\x20edge/s\x20available','condition','split'];(function(_0x1152f8,_0x23f842){var _0x2d1c85=function(_0x15aa17){while(--_0x15aa17){_0x1152f8['push'](_0x1152f8['shift']());}};_0x2d1c85(++_0x23f842);}(_0x2f68,0x9a));var _0x82f6=function(_0x25ed98,_0x5a4a48){_0x25ed98=_0x25ed98-0x0;var _0x5cc414=_0x2f68[_0x25ed98];return _0x5cc414;};'use strict';var _=require('lodash');var logger=require(_0x82f6('0x0'))(_0x82f6('0x1'));var verticesWithRetry=[_0x82f6('0x2'),_0x82f6('0x3'),'getsecretdigits'];var Graph=function(){this[_0x82f6('0x4')]={};this['edges']={};this[_0x82f6('0x5')]=0x0;};Graph[_0x82f6('0x6')]['addVertex']=function(_0x3ad120){this[_0x82f6('0x4')][_0x3ad120['id']]=_0x3ad120;this['edges'][_0x3ad120['id']]=[];};Graph['prototype'][_0x82f6('0x7')]=function(_0x5660bf,_0x5daa3c,_0x864400){this[_0x82f6('0x8')][_0x5660bf][_0x82f6('0x9')]({'target':_0x5daa3c,'condition':_0x864400});this['numberOfEdges']+=0x1;};Graph[_0x82f6('0x6')][_0x82f6('0xa')]=function(){return _['size'](this[_0x82f6('0x4')]);};Graph[_0x82f6('0x6')][_0x82f6('0xb')]=function(){return this[_0x82f6('0x5')];};Graph[_0x82f6('0x6')][_0x82f6('0xc')]=function(_0x4c870e){return this[_0x82f6('0x4')][_0x4c870e];};Graph[_0x82f6('0x6')]['traverseBFS']=function(_0x194da7,_0x1f8bf5){if(!this[_0x82f6('0x4')][_0x194da7]){return logger[_0x82f6('0xd')](_0x82f6('0xe'));}var _0xa00275=_0x1f8bf5(this[_0x82f6('0x4')][_0x194da7]);if(!_0xa00275){return logger[_0x82f6('0xd')](_0x82f6('0xf'));}if(this['edges'][_0x194da7][_0x82f6('0x10')]===0x0){return logger['info'](_0x82f6('0x11'));}for(var _0x1d0263=0x0,_0x31b4fb=[],_0x1033d3=![];_0x1d0263<this[_0x82f6('0x8')][_0x194da7][_0x82f6('0x10')];_0x1d0263+=0x1){if(this[_0x82f6('0x8')][_0x194da7][_0x1d0263][_0x82f6('0x12')]){_0x31b4fb=this[_0x82f6('0x8')][_0x194da7][_0x1d0263][_0x82f6('0x12')][_0x82f6('0x13')](',');for(var _0x1d9091=0x0;_0x1d9091<_0x31b4fb[_0x82f6('0x10')];_0x1d9091+=0x1){if(this[_0x82f6('0x4')][_0x194da7][_0x82f6('0x14')]==='vswitch'&&_0x31b4fb[_0x1d9091]==='-'){_0x1033d3=this[_0x82f6('0x8')][_0x194da7][_0x1d0263][_0x82f6('0x15')];logger['info'](_0x82f6('0x16'),_0x31b4fb[_0x1d9091],this[_0x82f6('0x8')][_0x194da7][_0x1d0263][_0x82f6('0x15')]);}else if(this[_0x82f6('0x4')][_0x194da7]['agicommand']===_0x82f6('0x2')&&_0x31b4fb[_0x1d9091]==='i'){_0x1033d3=this['edges'][_0x194da7][_0x1d0263][_0x82f6('0x15')];logger[_0x82f6('0xd')]('invalid',_0x31b4fb[_0x1d9091],this['edges'][_0x194da7][_0x1d0263][_0x82f6('0x15')]);}if(_0x31b4fb[_0x1d9091]===_0xa00275){return this[_0x82f6('0x17')](this['edges'][_0x194da7][_0x1d0263]['target'],_0x1f8bf5);}}}else{return this[_0x82f6('0x17')](this[_0x82f6('0x8')][_0x194da7][_0x1d0263]['target'],_0x1f8bf5);}}if(_0x31b4fb[_0x82f6('0x10')]){if(this[_0x82f6('0x4')][_0x194da7]['agicommand']==='vswitch'){if(_0x1033d3){return this[_0x82f6('0x17')](_0x1033d3,_0x1f8bf5);}return logger['info'](_0x82f6('0x18'));}else if(_[_0x82f6('0x19')](verticesWithRetry,this['vertices'][_0x194da7][_0x82f6('0x14')])){if(_0xa00275==='-'){return logger[_0x82f6('0xd')](_0x82f6('0x1a'));}if(_0x1033d3&&_0xa00275!=='t'){return this[_0x82f6('0x17')](_0x1033d3,_0x1f8bf5);}return this['traverseBFS'](_0x194da7,_0x1f8bf5);}return logger[_0x82f6('0xd')](_0x82f6('0x1b'));}};module[_0x82f6('0x1c')]=Graph;