cf9a6f2ccafa3531fd89d7a9b061c9b21563b07d
[motion2.git] / server / services / routing / server / applications / gotoif.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 _0x4b44=['lodash','html-to-text','../../../../config/logger','routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','consequence','replace','error','[%s][GOTOIF]\x20%s','map','message','join','stop','condition','priorityTrue','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','next','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s','stringify','validate'];(function(_0x2f8341,_0x38fba0){var _0xd50073=function(_0xe19184){while(--_0xe19184){_0x2f8341['push'](_0x2f8341['shift']());}};_0xd50073(++_0x38fba0);}(_0x4b44,0x13e));var _0x44b4=function(_0x5799a8,_0x23f759){_0x5799a8=_0x5799a8-0x0;var _0x98f5f0=_0x4b44[_0x5799a8];return _0x98f5f0;};'use strict';var schema=require(_0x44b4('0x0'));var _=require(_0x44b4('0x1'));var htmlToText=require(_0x44b4('0x2'));var utils=require('./utils');var logger=require(_0x44b4('0x3'))(_0x44b4('0x4'));var gotoif=schema({'condition':{'type':_0x44b4('0x5'),'required':!![],'message':_0x44b4('0x6')},'priorityTrue':{'type':_0x44b4('0x7'),'message':_0x44b4('0x8')},'priorityFalse':{'type':_0x44b4('0x7'),'message':_0x44b4('0x9')}});exports[_0x44b4('0xa')]=function(_0x1ba022,_0x8b57e3){return function(_0x18f4bb){try{var _0x5d3d26={'condition':htmlToText['fromString'](utils['getMustacheRender'](_0x8b57e3[0x0],this),{'wordwrap':![]})[_0x44b4('0xb')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x8b57e3[0x1],'priorityFalse':_0x8b57e3[0x2]};var _0x4a2d79=gotoif[_0x44b4('0x0')](_0x5d3d26,{'typecast':!![]});if(_0x4a2d79['length']){logger[_0x44b4('0xc')](_0x44b4('0xd'),_0x1ba022,_[_0x44b4('0xe')](_0x4a2d79,_0x44b4('0xf'))[_0x44b4('0x10')](',\x20'));_0x18f4bb[_0x44b4('0x11')]();}else{try{var _0x225326=eval('('+_0x5d3d26[_0x44b4('0x12')]+')');var _0xf11ba2=_0x225326?_0x5d3d26[_0x44b4('0x13')]:_0x5d3d26['priorityFalse'];logger[_0x44b4('0x14')](_0x44b4('0x15'),_0x1ba022,_0x5d3d26[_0x44b4('0x12')],_0x225326,_0xf11ba2||'next');if(_0xf11ba2){var _0x2588ce=_[_0x44b4('0x16')](_0x18f4bb[_0x44b4('0x17')](),{'p':_0xf11ba2});if(_0x2588ce>=0x0){logger[_0x44b4('0x14')](_0x44b4('0x18'),_0x1ba022,_0xf11ba2||'next',_0x2588ce);_0x18f4bb[_0x44b4('0x19')](_0x2588ce);}else{logger[_0x44b4('0x14')](_0x44b4('0x1a'),_0x1ba022,_0xf11ba2||_0x44b4('0x19'));_0x18f4bb[_0x44b4('0x11')]();}}else{_0x18f4bb[_0x44b4('0x19')]();}}catch(_0x50887c){logger[_0x44b4('0xc')](_0x44b4('0x1b'),_0x1ba022,_0x50887c[_0x44b4('0xf')]);_0x18f4bb[_0x44b4('0x11')]();}}}catch(_0x555086){logger[_0x44b4('0xc')]('[%s][GOTOIF]\x20%s',_0x1ba022,JSON[_0x44b4('0x1c')](_0x555086));_0x18f4bb[_0x44b4('0x11')]();}};};