1 var _0x5503=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x62\x6C\x75\x65\x62\x69\x72\x64","\x6D\x6F\x6D\x65\x6E\x74","\x75\x74\x69\x6C","\x6C\x6F\x64\x61\x73\x68","\x70\x61\x74\x68","\x2E\x2E\x2F\x2E\x2E\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x65\x78\x65\x63","\x63\x68\x69\x6C\x64\x2D\x70\x72\x6F\x63\x65\x73\x73\x2D\x70\x72\x6F\x6D\x69\x73\x65","\x66\x61\x78","\x2E\x2E\x2F\x2E\x2E\x2F\x6C\x6F\x67\x67\x65\x72\x2E\x6A\x73","\x46\x61\x78\x4D\x65\x73\x73\x61\x67\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x46\x61\x78\x52\x6F\x6F\x6D","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74","\x46\x61\x78\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74","\x43\x6F\x6E\x74\x61\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x5B\x46\x61\x78\x5D\x20\x4E\x65\x77\x20\x6D\x65\x73\x73\x61\x67\x65\x20\x66\x72\x6F\x6D\x20\x25\x73","\x63\x61\x6C\x6C\x65\x72\x69\x64\x6E\x75\x6D","\x66\x6F\x72\x6D\x61\x74","\x69\x6E\x66\x6F","\x63\x6C\x6F\x6E\x65","\x5B\x46\x61\x78\x5D\x20\x45\x72\x72\x6F\x72\x20\x72\x65\x63\x65\x69\x76\x69\x6E\x67\x20\x6D\x65\x73\x73\x61\x67\x65\x3A","\x65\x72\x72\x6F\x72","\x5B\x46\x61\x78\x5D\x20\x4D\x65\x73\x73\x61\x67\x65\x3A","\x6D\x65\x73\x73\x61\x67\x65","\x5B\x46\x61\x78\x5D\x20\x53\x74\x61\x63\x6B\x3A","\x73\x74\x61\x63\x6B","\x63\x61\x74\x63\x68","\x70\x61\x67\x65\x73\x74\x72\x61\x6E\x73\x66\x65\x72\x72\x65\x64","\x5B\x46\x61\x78\x5D\x20\x46\x69\x6C\x65\x20\x63\x6F\x72\x72\x65\x63\x74\x6C\x79\x20\x63\x6F\x6E\x76\x65\x72\x74\x65\x64","\x64\x65\x62\x75\x67","\x5B\x46\x61\x78\x5D\x20\x4D\x65\x73\x73\x61\x67\x65\x20\x63\x6F\x72\x72\x65\x63\x74\x6C\x79\x20\x72\x65\x63\x65\x69\x76\x65\x64\x2C\x20\x69\x6E\x69\x74\x69\x61\x74\x69\x6E\x67\x20\x72\x6F\x75\x74\x69\x6E\x67\x2E\x2E\x2E","\x69\x6E\x69\x74\x46\x61\x78\x52\x6F\x75\x74\x69\x6E\x67","\x73\x65\x6E\x64","\x67\x65\x74","\x74\x68\x65\x6E","\x5B\x46\x61\x78\x5D\x20\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x20\x6E\x6F\x74\x20\x63\x72\x65\x61\x74\x65\x64","\x5B\x46\x61\x78\x5D\x20\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x3A","\x69\x64","\x74\x69\x66\x66\x32\x70\x64\x66\x20\x2D\x6F\x20","\x20","\x66\x69\x6C\x65\x6E\x61\x6D\x65","\x5B\x46\x61\x78\x5D\x20\x4D\x65\x73\x73\x61\x67\x65\x20\x6E\x6F\x74\x20\x63\x72\x65\x61\x74\x65\x64","\x6E\x61\x6D\x65","\x70\x61\x72\x73\x65","\x2E\x70\x64\x66","\x72\x6F\x6F\x74","\x73\x65\x72\x76\x65\x72","\x66\x69\x6C\x65\x73","\x69\x6E\x62\x6F\x75\x6E\x64","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64","\x6A\x6F\x69\x6E","\x63\x72\x65\x61\x74\x65","\x5B\x46\x61\x78\x5D\x20\x54\x72\x61\x6E\x73\x66\x65\x72\x72\x65\x64\x20\x66\x69\x6C\x65\x20\x69\x73\x20\x65\x6D\x70\x74\x79\x20\x28\x70\x61\x67\x65\x73\x74\x72\x61\x6E\x73\x66\x65\x72\x72\x65\x64\x3A\x25\x73\x29","\x5B\x46\x61\x78\x5D\x20\x52\x6F\x6F\x6D\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64\x2F\x63\x72\x65\x61\x74\x65\x64","\x5B\x46\x61\x78\x5D\x20\x52\x6F\x6F\x6D\x3A","\x46\x61\x78\x52\x6F\x6F\x6D\x49\x64","\x73\x74\x61\x74\x75\x73","\x52\x45\x43\x45\x49\x56\x45\x44","\x66\x72\x6F\x6D","\x74\x6F","\x6C\x6F\x63\x61\x6C\x73\x74\x61\x74\x69\x6F\x6E\x69\x64","","\x54\x72\x61\x6E\x73\x66\x65\x72\x72\x65\x64\x20\x66\x69\x6C\x65\x20\x69\x73\x20\x65\x6D\x70\x74\x79","\x6C\x65\x6E\x67\x74\x68","\x66\x69\x72\x73\x74","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x4F\x50\x45\x4E","\x73\x79\x73\x74\x65\x6D","\x66\x61\x78\x49\x6E","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x4E\x45\x57","\x43\x4C\x4F\x53\x45\x44","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x44\x45\x53\x43","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x70\x72\x65\x61\x64","\x5B\x46\x61\x78\x5D\x20\x41\x63\x63\x6F\x75\x6E\x74\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x5B\x46\x61\x78\x5D\x20\x41\x63\x63\x6F\x75\x6E\x74\x20\x66\x6F\x75\x6E\x64\x3A","\x4C\x69\x73\x74\x49\x64","\x66\x69\x6E\x64\x4F\x72\x43\x72\x65\x61\x74\x65","\x66\x69\x6E\x64\x4F\x6E\x65","\x5B\x46\x61\x78\x5D\x20\x45\x72\x72\x6F\x72\x20\x75\x70\x64\x61\x74\x69\x6E\x67\x20\x73\x65\x6E\x64\x69\x6E\x67\x20\x6D\x65\x73\x73\x61\x67\x65\x3A","\x5B\x46\x61\x78\x5D\x20\x52\x6F\x6F\x6D\x20\x75\x70\x64\x61\x74\x65\x20\x66\x6F\x72\x20\x53\x65\x6E\x64\x46\x61\x78\x20\x65\x76\x65\x6E\x74","\x5B\x46\x61\x78\x5D\x20\x52\x6F\x6F\x6D\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x53\x45\x4E\x54","\x5B\x46\x61\x78\x5D\x20\x4D\x65\x73\x73\x61\x67\x65\x20\x75\x70\x64\x61\x74\x65\x20\x66\x6F\x72\x20\x53\x65\x6E\x64\x46\x61\x78\x20\x65\x76\x65\x6E\x74","\x67\x65\x74\x46\x61\x78\x52\x6F\x6F\x6D","\x5B\x46\x61\x78\x5D\x20\x4D\x65\x73\x73\x61\x67\x65\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x30","\x46\x41\x49\x4C\x45\x44","\x72\x65\x6D\x6F\x74\x65\x73\x74\x61\x74\x69\x6F\x6E\x69\x64","\x72\x65\x73\x6F\x6C\x75\x74\x69\x6F\x6E","\x74\x72\x61\x6E\x73\x66\x65\x72\x72\x61\x74\x65","\x76\x61\x72\x69\x61\x62\x6C\x65","\x72\x65\x73\x6F\x6C\x76\x65","\x5B\x46\x61\x78\x5D\x20\x45\x72\x72\x6F\x72\x20\x75\x70\x64\x61\x74\x69\x6E\x67\x20\x6D\x65\x73\x73\x61\x67\x65\x3A","\x63\x68\x61\x6E\x6E\x65\x6C","\x63\x68\x61\x6E\x6E\x65\x6C\x73\x74\x61\x74\x65","\x63\x68\x61\x6E\x6E\x65\x6C\x73\x74\x61\x74\x65\x64\x65\x73\x63","\x63\x61\x6C\x6C\x65\x72\x69\x64\x6E\x61\x6D\x65","\x63\x6F\x6E\x6E\x65\x63\x74\x65\x64\x6C\x69\x6E\x65\x6E\x75\x6D","\x63\x6F\x6E\x6E\x65\x63\x74\x65\x64\x6C\x69\x6E\x65\x6E\x61\x6D\x65","\x61\x63\x63\x6F\x75\x6E\x74\x63\x6F\x64\x65","\x63\x6F\x6E\x74\x65\x78\x74","\x65\x78\x74\x65\x6E","\x70\x72\x69\x6F\x72\x69\x74\x79","\x75\x6E\x69\x71\x75\x65\x69\x64","\x6C\x69\x6E\x6B\x65\x64\x69\x64","\x66\x61\x78\x65\x72\x72\x6F\x72","\x68\x61\x73\x4F\x77\x6E\x50\x72\x6F\x70\x65\x72\x74\x79","\x76\x61\x6C\x75\x65","\x5B\x46\x61\x78\x5D\x20\x45\x72\x72\x6F\x72\x20\x75\x70\x64\x61\x74\x69\x6E\x67\x20\x65\x72\x72\x6F\x72\x3A"];_0x5503[0];var BPromise=require(_0x5503[1]);var moment=require(_0x5503[2]);var util=require(_0x5503[3]);var _=require(_0x5503[4]);var path=require(_0x5503[5]);var config=require(_0x5503[6]);var exec=require(_0x5503[8])[_0x5503[7]];var logger=require(_0x5503[10])(_0x5503[9]);var FaxMessage=require(_0x5503[12])[_0x5503[11]];var FaxRoom=require(_0x5503[12])[_0x5503[13]];var FaxAccount=require(_0x5503[12])[_0x5503[14]];var FaxAttachment=require(_0x5503[12])[_0x5503[15]];var Contact=require(_0x5503[12])[_0x5503[16]];module[_0x5503[17]]= function(){return {receivefax:function(_0xfc9fxe){return function(_0xfc9fxf){logger[_0x5503[21]](util[_0x5503[20]](_0x5503[18],_0xfc9fxe[_0x5503[19]]));var _0xfc9fx10=_[_0x5503[22]](_0xfc9fxe);var _0xfc9fx11;var _0xfc9fx12,_0xfc9fx13;return FaxAccount[_0x5503[83]]({where:{localstationid:_0xfc9fxe[_0x5503[63]]}})[_0x5503[37]](function(_0xfc9fx1c){if(!_0xfc9fx1c){throw new Error(_0x5503[79])};logger[_0x5503[32]](_0x5503[80],_0xfc9fxe[_0x5503[63]]);_0xfc9fx11= _0xfc9fx1c;if(_0xfc9fx11[_0x5503[81]]){return Contact[_0x5503[82]]({where:{ListId:_0xfc9fx11[_0x5503[81]],$or:[{phone:_0xfc9fxe[_0x5503[19]]},{fax:_0xfc9fxe[_0x5503[19]]}]},defaults:{phone:_0xfc9fxe[_0x5503[19]],fax:_0xfc9fxe[_0x5503[19]],firstName:_0xfc9fxe[_0x5503[19]],ListId:_0xfc9fx11[_0x5503[81]]}})}else {return []}})[_0x5503[78]](function(_0xfc9fx1a,_0xfc9fx1b){if(_0xfc9fx1b!== undefined&& !_0xfc9fx1b){return _0xfc9fx1a[_0x5503[72]]({fax:_0xfc9fxe[_0x5503[19]]})};return})[_0x5503[37]](function(){return FaxRoom[_0x5503[77]]({limit:1,where:{contact:_0xfc9fx10[_0x5503[19]],FaxAccountId:_0xfc9fx11[_0x5503[40]],status:{$ne:_0x5503[74]}},order:[[_0x5503[75],_0x5503[76]]]})})[_0x5503[37]](function(_0xfc9fx19){if(_0xfc9fx19[_0x5503[66]]){_0xfc9fx19= _[_0x5503[67]](_0xfc9fx19);return _0xfc9fx19[_0x5503[72]]({lastEvent:_0x5503[60],lastEventAt:moment()[_0x5503[20]](_0x5503[68]),status:_0x5503[69],openReason:_0x5503[70],faxIn:++_0xfc9fx19[_0x5503[71]]})}else {return FaxRoom[_0x5503[54]]({contact:_0xfc9fx10[_0x5503[19]],account:_0xfc9fx11[_0x5503[45]],status:_0x5503[73],lastEvent:_0x5503[60],lastEventAt:moment()[_0x5503[20]](_0x5503[68]),FaxAccountId:_0xfc9fx11[_0x5503[40]],faxIn:1})}})[_0x5503[37]](function(_0xfc9fx19){if(!_0xfc9fx19){throw new Error(_0x5503[56])};logger[_0x5503[32]](_0x5503[57],_0xfc9fx19[_0x5503[40]]);_0xfc9fx13= _0xfc9fx19;_0xfc9fx10[_0x5503[58]]= _0xfc9fx19[_0x5503[40]];_0xfc9fx10[_0x5503[59]]= _0x5503[60];_0xfc9fx10[_0x5503[61]]= _0xfc9fx10[_0x5503[19]];_0xfc9fx10[_0x5503[62]]= _0xfc9fx10[_0x5503[63]];_0xfc9fx10[_0x5503[24]]= parseInt(_0xfc9fx10[_0x5503[30]])> 0?_0x5503[64]:_0x5503[65];return FaxMessage[_0x5503[54]](_0xfc9fx10)})[_0x5503[37]](function(_0xfc9fx16){if(!_0xfc9fx16){throw new Error(_0x5503[44])};_0xfc9fx12= _0xfc9fx16;logger[_0x5503[32]](_0x5503[25],_0xfc9fx16[_0x5503[40]]);if(parseInt(_0xfc9fxe[_0x5503[30]])> 0){var _0xfc9fx17=path[_0x5503[46]](_0xfc9fxe[_0x5503[43]])[_0x5503[45]];var _0xfc9fx18=_0xfc9fx17+ _0x5503[47];return FaxAttachment[_0x5503[54]]({path:path[_0x5503[53]](config[_0x5503[48]],_0x5503[49],_0x5503[50],_0x5503[9],_0x5503[51],_0x5503[52],_0xfc9fx18),basename:_0xfc9fx18,name:_0xfc9fx17,FaxMessageId:_0xfc9fx16[_0x5503[40]]})};logger[_0x5503[24]](util[_0x5503[20]](_0x5503[55],_0xfc9fxe[_0x5503[30]]));return})[_0x5503[37]](function(_0xfc9fx15){if(!_0xfc9fx15){logger[_0x5503[24]](_0x5503[38]);return};logger[_0x5503[32]](_0x5503[39],_0xfc9fx15[_0x5503[40]]);return exec(_0x5503[41]+ _0xfc9fx15[_0x5503[5]]+ _0x5503[42]+ _0xfc9fxe[_0x5503[43]])})[_0x5503[37]](function(){if(parseInt(_0xfc9fxe[_0x5503[30]])> 0){logger[_0x5503[32]](_0x5503[31]);logger[_0x5503[21]](_0x5503[33]);process[_0x5503[35]]({message:_0x5503[34],doc:{message:_0xfc9fx12,account:_0xfc9fx11}});return _0xfc9fx12[_0x5503[36]]({plain:true})}})[_0x5503[29]](function(_0xfc9fx14){logger[_0x5503[24]](_0x5503[23],_0xfc9fx14);logger[_0x5503[24]](_0x5503[25],_0xfc9fx14[_0x5503[26]]);logger[_0x5503[24]](_0x5503[27],_0xfc9fx14[_0x5503[28]])})}},sendfax:function(_0xfc9fxe){return function(_0xfc9fxf){var _0xfc9fx12;return FaxMessage[_0x5503[83]]({where:{filename:_0xfc9fxe[_0x5503[43]],localstationid:_0xfc9fxe[_0x5503[63]]}})[_0x5503[37]](function(_0xfc9fx1e){if(!_0xfc9fx1e){throw new Error(_0x5503[90])};_0xfc9fx12= _0xfc9fx1e;var _0xfc9fx1f=_0x5503[87];if(_0xfc9fxe[_0x5503[30]]=== _0x5503[91]){_0xfc9fx1f= _0x5503[92]};return _0xfc9fx12[_0x5503[72]]({remotestationid:_0xfc9fxe[_0x5503[93]],pagestransferred:_0xfc9fxe[_0x5503[30]],resolution:_0xfc9fxe[_0x5503[94]],transferrate:_0xfc9fxe[_0x5503[95]],status:_0xfc9fx1f})})[_0x5503[37]](function(_0xfc9fx16){logger[_0x5503[32]](_0x5503[88],_0xfc9fx16[_0x5503[40]]);return _0xfc9fx12[_0x5503[89]]()})[_0x5503[37]](function(_0xfc9fx1d){if(!_0xfc9fx1d){throw new Error(_0x5503[86])};return _0xfc9fx1d[_0x5503[72]]({lastEvent:_0x5503[87]},{individualHooks:true})})[_0x5503[37]](function(_0xfc9fx19){logger[_0x5503[32]](_0x5503[85],_0xfc9fx19[_0x5503[40]])})[_0x5503[29]](function(_0xfc9fx14){logger[_0x5503[24]](_0x5503[84],_0xfc9fx14);logger[_0x5503[24]](_0x5503[25],_0xfc9fx14[_0x5503[26]]);logger[_0x5503[24]](_0x5503[27],_0xfc9fx14[_0x5503[28]])})}},faxstatus:function(_0xfc9fxe){return function(_0xfc9fxf){if(_0xfc9fxe[_0x5503[96]]!== _0x5503[35]){return BPromise[_0x5503[97]]()};return FaxMessage[_0x5503[83]]({where:{filename:_0xfc9fxe[_0x5503[43]],localstationid:_0xfc9fxe[_0x5503[63]]}})[_0x5503[37]](function(_0xfc9fx1e){if(!_0xfc9fx1e){throw new Error(_0x5503[90])};return _0xfc9fx1e[_0x5503[72]]({channel:_0xfc9fxe[_0x5503[99]],channelstate:_0xfc9fxe[_0x5503[100]],channelstatedesc:_0xfc9fxe[_0x5503[101]],calleridnum:_0xfc9fxe[_0x5503[19]],calleridname:_0xfc9fxe[_0x5503[102]],connectedlinenum:_0xfc9fxe[_0x5503[103]],connectedlinename:_0xfc9fxe[_0x5503[104]],accountcode:_0xfc9fxe[_0x5503[105]],context:_0xfc9fxe[_0x5503[106]],exten:_0xfc9fxe[_0x5503[107]],priority:_0xfc9fxe[_0x5503[108]],uniqueid:_0xfc9fxe[_0x5503[109]],linkedid:_0xfc9fxe[_0x5503[110]],lastStatus:_0xfc9fxe[_0x5503[59]]})})[_0x5503[29]](function(_0xfc9fx14){logger[_0x5503[24]](_0x5503[98],_0xfc9fx14);logger[_0x5503[24]](_0x5503[25],_0xfc9fx14[_0x5503[26]]);logger[_0x5503[24]](_0x5503[27],_0xfc9fx14[_0x5503[28]])})}},faxerror:function(_0xfc9fxe){return function(_0xfc9fxf){if(!_0xfc9fxe[_0x5503[96]][_0x5503[112]](_0x5503[111])|| !_0xfc9fxe[_0x5503[113]]){return BPromise[_0x5503[97]]()};return FaxMessage[_0x5503[83]]({where:{channel:_0xfc9fxe[_0x5503[99]]}})[_0x5503[37]](function(_0xfc9fx1e){if(_0xfc9fx1e){return _0xfc9fx1e[_0x5503[72]]({error:_0xfc9fxe[_0x5503[113]]})};return})[_0x5503[29]](function(_0xfc9fx14){logger[_0x5503[24]](_0x5503[114],_0xfc9fx14)})}}}}