@94ai/softphone 5.0.11 → 5.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/html-softphone-demo/WebrtcDiver.js +320 -0
- package/html-softphone-demo/embed-ui/index.html +77 -0
- package/html-softphone-demo/{index-embed.html → embed-ui/softphone.js} +2 -204
- package/html-softphone-demo/embed-ui/util.js +123 -0
- package/html-softphone-demo/index-channel.html +904 -0
- package/html-softphone-demo/index-local.html +3 -10
- package/html-softphone-demo/index-switch-pcm.html +613 -0
- package/html-softphone-demo/{index-other.html → index-test.html} +10 -3
- package/html-softphone-demo/index.html +34 -26
- package/html-softphone-demo/micro-call-ui/CryptoJS.js +3 -0
- package/html-softphone-demo/micro-call-ui/index.html +75 -0
- package/html-softphone-demo/micro-call-ui/microphone.js +829 -0
- package/html-softphone-demo/micro-call-ui/qiankun.js +2 -0
- package/html-softphone-demo/micro-call-ui/util.js +17 -0
- package/html-softphone-demo/micro-call-ui/wujie.js +3 -0
- package/html-softphone-demo/pcm-server/16bit-44100.pcm +0 -0
- package/html-softphone-demo/pcm-server/index.html +110 -0
- package/html-softphone-demo/pcm-server/server.js +54 -0
- package/html-softphone-demo/softphone.umd.min.js +1 -2
- package/html-softphone-demo.7z +0 -0
- package/lib/index.d.ts +1 -1
- package/lib/softphone.cjs.min.cjs +1 -1
- package/lib/softphone.esm-bundler.min.mjs +1 -1
- package/lib/softphone.umd.min.js +1 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@babel/runtime-corejs3/helpers/esm/classCallCheck";import t from"@babel/runtime-corejs3/helpers/esm/createClass";import{UserAgent as n,SessionState as i,Inviter as r,Registerer as s}from"sip.js";export{Inviter,Registerer,SessionState,URI,UserAgent}from"sip.js";export{SimpleUser}from"sip.js/lib/platform/web/index.js";import o from"on-change";export{default as onChange}from"on-change";import a from"@babel/runtime-corejs3/helpers/esm/typeof";import c from"@babel/runtime-corejs3/regenerator";import u from"@babel/runtime-corejs3/core-js/json/stringify";import f from"@babel/runtime-corejs3/core-js/object/define-property";import l from"@babel/runtime-corejs3/core-js/date/now";import h from"@babel/runtime-corejs3/core-js/instance/for-each";import d from"@babel/runtime-corejs3/core-js/set-timeout";import p from"@babel/runtime-corejs3/core-js/set-interval";import v from"@babel/runtime-corejs3/core-js/promise";import m from"@babel/runtime-corejs3/core-js/object/assign";import g from"@babel/runtime-corejs3/core-js/instance/concat";import w from"@babel/runtime-corejs3/core-js/instance/map";import b from"@babel/runtime-corejs3/core-js/instance/index-of";import k from"@babel/runtime-corejs3/core-js/instance/filter";import x from"@babel/runtime-corejs3/core-js/weak-map";import y from"@babel/runtime-corejs3/core-js/weak-set";import S from"@babel/runtime-corejs3/core-js/object/keys";import A from"@babel/runtime-corejs3/core-js/instance/pad-start";import I from"@babel/runtime-corejs3/core-js/instance/slice";import T from"crypto-js";import j from"@fingerprintjs/fingerprintjs";function C(e,t,n,i){return new(n||(n=Promise))(function(r,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,a)}c((i=i.apply(e,t||[])).next())})}function O(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function E(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}var D,R;"function"==typeof SuppressedError&&SuppressedError;var N,q,P,H,M=g(D="sip:".concat("","@")).call(D,""),U=g(R="".concat("","://")).call(R,""),z={authorizationPassword:"",authorizationUsername:"",viaHost:"",uri:n.makeURI(M),logLevel:"error",transportOptions:{server:U},contactName:""},L={connectStatus:!1,registerStatus:!1,invitatingStatus:!1,incomingStatus:!1,answerStatus:!1,reconnectStatus:!1};function X(e){return document.getElementById(e)}function F(e){if(e&&e.getTracks)try{var t=e.getTracks();h(t).call(t,function(e){try{e.stop()}catch(e){}})}catch(e){}}function G(e){return navigator.mediaDevices.getUserMedia(e).then(function(e){return e?(F(e),!0):v.reject(new Error("EmptyStreamError"))}).catch(function(e){return(!e||"NotAllowedError"!==e.name)&&v.reject(e)})}function _(){try{var e;if(-1===b(e=navigator.userAgent).call(e,"Firefox"))return G({video:!1,audio:!0}).catch(function(){return!0})}catch(e){console.log(e)}}function B(e){var t=X(e);t&&(t.currentTime=0,t.play())}function Y(e){var t=X(e);t&&(t.currentTime=0,t.pause())}function V(e){var t=X(e);t&&(t.srcObject=null,t.pause())}!function(e){e.NO="0",e.YES="1"}(N||(N={})),function(e){e.NO="0",e.YES="1"}(q||(q={})),function(e){e.MULTI_AI="1",e.MULTI_VOICE_NOTIFY="2",e.MULTI_PRETEST="3",e.LABOUR="4",e.AI="5",e.NEW_VOICE_NOTIFY="6"}(P||(P={})),function(e){e.DIRECT_ANSWER="1",e.LISTEN_FIRST_AND_THEN_ANSWER_MANUALLY="2"}(H||(H={}));var J,W,Z,K,$,Q,ee,te,ne,ie,re,se,oe,ae,ce,ue,fe,le,he,de,pe,ve,me,ge,we,be,ke,xe,ye,Se,Ae,Ie,Te,je,Ce,Oe,Ee,De,Re,Ne,qe,Pe,He,Me,Ue,ze,Le,Xe,Fe,Ge,_e,Be,Ye,Ve,Je,We,Ze,Ke,$e,Qe,et,tt,nt,it,rt,st,ot,at,ct,ut,ft,lt,ht,dt,pt,vt,mt,gt,wt,bt,kt,xt,yt,St,At,It,Tt,jt,Ct,Ot,Et,Dt,Rt,Nt,qt,Pt,Ht,Mt,Ut,zt,Lt,Xt,Ft,Gt,_t,Bt,Yt,Vt,Jt,Wt,Zt,Kt,$t,Qt,en,tn,nn,rn,sn,on,an,cn,un,fn=function(e){var t,n,i;return A(t=e.getHours().toString()).call(t,2,"0")+":"+A(n=e.getMinutes().toString()).call(n,2,"0")+":"+A(i=e.getSeconds().toString()).call(i,2,"0")},ln=function(){return new Date(new Date((new Date).toLocaleDateString()).getTime())},hn=function(e){return new Date(e.setSeconds(e.getSeconds()+1))};function dn(e){var t=ln();e(fn(t));var n=p(function(){var n=hn(t),i=fn(n);e(i)},1e3);return function(){clearInterval(n),n=null}}function pn(e,t,n){var i=window.XMLHttpRequest?new window.XMLHttpRequest:window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLHTTP"):void 0;i||t(new Error("Your Browser does not support ajax")),i.onreadystatechange=function(){if(4==i.readyState){var n=i.response||i.responseText;if(200==i.status){var r=i.getResponseHeader("Content-Type");-1!=b(r).call(r,"json")?e(JSON.parse(i.responseText)):-1!=b(r).call(r,"xml")?e(i.responseXML):e(i.responseText)}else t(n)}};var r=n.url,s=n.data,o=n.type,a=n.contentType,c=o||"POST",f=r,l=null;return s&&("GET"===c?f=f+"?"+function(e){var t=[];for(var n in e)t.push(n+"="+e[n]);return t.join("&")}(s):"POST"===c&&(l=u(s))),i.open(c,f,!0),{xhr:i,ajaxData:l,contentType:a}}var vn,mn,gn=function(){return t(function t(){var r=this,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(e(this,t),J.add(this),W.set(this,void 0),Z.set(this,void 0),K.set(this,void 0),$.set(this,void 0),Q.set(this,void 0),ee.set(this,[]),te.set(this,[]),ne.set(this,{}),ie.set(this,void 0),re.set(this,void 0),se.set(this,new MediaStream),oe.set(this,JSON.parse(u(L))),ae.set(this,0),ce.set(this,void 0),ue.set(this,void 0),fe.set(this,void 0),f(this,"token",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),le.set(this,void 0),he.set(this,48e4),de.set(this,12e6),pe.set(this,{}),ve.set(this,void 0),me.set(this,void 0),ge.set(this,void 0),we.set(this,function(e){}),be.set(this,function(e){}),ke.set(this,function(e){}),xe.set(this,function(e){}),ye.set(this,function(e){return C(r,void 0,void 0,c.mark(function t(){var n,i,r;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!O(this,ce,"f")||!O(this,ue,"f")){t.next=2;break}if(!(l()-O(this,ue,"f")>e)){t.next=2;break}return t.next=1,O(this,Ae,"f").call(this);case 1:n=t.sent,i=n.sign,r=n.timestamp,E(this,ce,null!=i?i:O(this,ce,"f"),"f"),E(this,ue,null!=r?r:O(this,ue,"f"),"f");case 2:case"end":return t.stop()}},t,this)}))}),Se.set(this,function(e){return C(r,void 0,void 0,c.mark(function t(){var n,i,r,s,o;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!O(this,le,"f")){t.next=4;break}if(!(l()-O(this,le,"f")>e)){t.next=4;break}if(!O(this,fe,"f")){t.next=2;break}return t.next=1,O(this,Ie,"f").call(this);case 1:n=t.sent,i=n.token,r=n.tokenTimestamp,E(this,fe,null!=i?i:O(this,fe,"f"),"f"),E(this,le,null!=r?r:l(),"f"),t.next=4;break;case 2:if(!this.token){t.next=4;break}return t.next=3,this.getGatewayAccessToken({corpId:O(this,Je,"f"),sid:O(this,Ke,"f"),secret:O(this,We,"f"),seatOnline:!1});case 3:s=t.sent,o=s.token,this.token=o,E(this,le,l(),"f");case 4:case"end":return t.stop()}},t,this)}))}),Ae.set(this,function(){}),Ie.set(this,function(){}),Te.set(this,function(e){}),je.set(this,function(e){}),Ce.set(this,void 0),Oe.set(this,void 0),f(this,"networkSpeed",{enumerable:!0,configurable:!0,writable:!0,value:"0.00Mb/s"}),f(this,"networkDelay",{enumerable:!0,configurable:!0,writable:!0,value:"0ms"}),f(this,"onLine",{enumerable:!0,configurable:!0,writable:!0,value:navigator.onLine}),f(this,"testspeeding",{enumerable:!0,configurable:!0,writable:!0,value:!1}),f(this,"goodNetworkSpeed",{enumerable:!0,configurable:!0,writable:!0,value:function(){return 1e3*Number(r.networkSpeed.replace("Mb/s",""))>=30}}),f(this,"goodNetworkDelay",{enumerable:!0,configurable:!0,writable:!0,value:function(){return Number(r.networkDelay.replace("ms",""))<=500&&"0ms"!==r.networkDelay}}),f(this,"authorizedMicrophonePermissions",{enumerable:!0,configurable:!0,writable:!0,value:!1}),f(this,"authorizedNotificationPermissions",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Ee.set(this,100),De.set(this,3),Re.set(this,8),Ne.set(this,3),qe.set(this,0),Pe.set(this,!1),He.set(this,void 0),Me.set(this,3),Ue.set(this,3),ze.set(this,0),Le.set(this,0),Xe.set(this,0),Fe.set(this,!1),Ge.set(this,!1),_e.set(this,!1),Be.set(this,void 0),Ye.set(this,void 0),Ve.set(this,void 0),Je.set(this,void 0),We.set(this,void 0),Ze.set(this,void 0),Ke.set(this,void 0),$e.set(this,void 0),Qe.set(this,void 0),et.set(this,void 0),tt.set(this,void 0),nt.set(this,function(e){O(r,J,"m",sn).call(r)}),it.set(this,function(){}),rt.set(this,void 0),st.set(this,void 0),ot.set(this,!1),at.set(this,4e3),ct.set(this,4e3),ut.set(this,{}),ft.set(this,!1),lt.set(this,!0),f(this,"ifAutoAnswer",{enumerable:!0,configurable:!0,writable:!0,value:function(){return String(O(r,ut,"f").autoAnswer)===N.YES}}),f(this,"notNeedSendStarDtmf",{enumerable:!0,configurable:!0,writable:!0,value:function(){return String(O(r,ut,"f").afterTransferLabour)===H.DIRECT_ANSWER}}),ht.set(this,function(){if(O(r,lt,"f")){var e;O(r,dt,"f").call(r);var t=new(window.AudioContext||window.webkitAudioContext);E(r,me,t.createScriptProcessor(2048,1,1),"f"),O(r,me,"f").onaudioprocess=function(e){for(var t=e.inputBuffer.getChannelData(0),n=0,i=0;i<t.length;++i)n+=t[i]*t[i];E(r,ae,Number(Math.sqrt(n/t.length).toFixed(2)),"f"),O(r,we,"f").call(r,O(r,ae,"f"))},E(r,ge,new MediaStream,"f"),h(e=r.getSenders()).call(e,function(e){e.track&&O(r,ge,"f").addTrack(e.track)}),E(r,ve,t.createMediaStreamSource(O(r,ge,"f")),"f"),O(r,ve,"f").connect(O(r,me,"f")),O(r,me,"f").connect(t.destination)}}),dt.set(this,function(){if(O(r,lt,"f")){if(O(r,ve,"f"))try{O(r,ve,"f").disconnect()}catch(e){console.log(e)}if(O(r,me,"f"))try{O(r,me,"f").disconnect()}catch(e){console.log(e)}if(O(r,ge,"f"))try{var e;h(e=O(r,ge,"f").getTracks()).call(e,function(e){e.stop()})}catch(e){console.log(e)}}E(r,ve,void 0,"f"),E(r,me,void 0,"f"),E(r,ge,void 0,"f"),E(r,ae,0,"f"),O(r,we,"f").call(r,O(r,ae,"f"))}),f(this,"disposeSoftphoneEnvRequirementCheck",{enumerable:!0,configurable:!0,writable:!0,value:function(){O(r,pt,"f").call(r),window.removeEventListener("offline",O(r,gt,"f")),window.removeEventListener("online",O(r,mt,"f")),window.removeEventListener("unload",r.disposeSoftphoneEnvRequirementCheck)}}),pt.set(this,function(){clearInterval(O(r,Ce,"f")),E(r,Ce,void 0,"f"),clearTimeout(O(r,Oe,"f")),E(r,Oe,void 0,"f"),r.testspeeding=!1}),f(this,"softphoneEnvCheck",{enumerable:!0,configurable:!0,writable:!0,value:function(){return C(r,void 0,void 0,c.mark(function e(){return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this.testspeeding||(O(this,vt,"f").call(this),this.oneRoundOfTesting());case 1:case"end":return e.stop()}},e,this)}))}}),vt.set(this,function(){window.addEventListener("offline",O(r,gt,"f")),window.addEventListener("online",O(r,mt,"f")),window.addEventListener("unload",r.disposeSoftphoneEnvRequirementCheck)}),f(this,"oneRoundOfTesting",{enumerable:!0,configurable:!0,writable:!0,value:function(){return C(r,void 0,void 0,c.mark(function e(){var t=this;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this.testspeeding=!0,this.detectNavigatorPermissions(),this.onLine?(O(this,wt,"f").call(this,this),E(this,Oe,d(function(){t.testspeeding=!1,t.disposeSoftphoneEnvRequirementCheck()},4e3),"f")):this.testspeeding=!1;case 1:case"end":return e.stop()}},e,this)}))}}),mt.set(this,function(){r.onLine=!0,r.oneRoundOfTesting()}),gt.set(this,function(){r.onLine=!1,r.networkSpeed="0.00Mb/s",r.networkDelay="0ms",O(r,je,"f").call(r,{networkSpeed:r.networkSpeed,networkDelay:r.networkDelay,authorizedMicrophonePermissions:r.authorizedMicrophonePermissions,authorizedNotificationPermissions:r.authorizedNotificationPermissions}),O(r,pt,"f").call(r)}),wt.set(this,function(e){return C(r,void 0,void 0,c.mark(function t(){var n,i,r=this;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=e||this,clearInterval(O(n,Ce,"f")),E(n,Ce,void 0,"f"),i=function(){return C(r,void 0,void 0,c.mark(function e(){var t;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!n.onLine){e.next=5;break}return e.prev=1,e.next=2,O(n,bt,"f").call(n);case 2:t=e.sent,n.networkSpeed=t.networkSpeed,n.networkDelay=t.networkDelay,e.next=4;break;case 3:e.prev=3,e.catch(1),n.networkSpeed="0.00Mb/s",n.networkDelay="0ms";case 4:e.next=6;break;case 5:n.networkSpeed="0.00Mb/s",n.networkDelay="0ms";case 6:O(this,je,"f").call(this,{networkSpeed:this.networkSpeed,networkDelay:this.networkDelay,authorizedMicrophonePermissions:this.authorizedMicrophonePermissions,authorizedNotificationPermissions:this.authorizedNotificationPermissions}),O(this,Oe,"f")||(this.testspeeding=!1,this.disposeSoftphoneEnvRequirementCheck());case 7:case"end":return e.stop()}},e,this,[[1,3]])}))},t.next=1,i();case 1:O(this,Oe,"f")&&E(n,Ce,p(function(){return C(this,void 0,void 0,c.mark(function e(){return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,i();case 1:case"end":return e.stop()}},e)}))},1e3),"f");case 2:case"end":return t.stop()}},t,this)}))}),bt.set(this,function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"https://seat.94ai.com/favicon.png",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:63491,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return C(r,void 0,void 0,c.mark(function i(){var r,s;return c.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:for(r=[],s=0;s<n;s++)r.push(O(this,kt,"f").call(this,e+"?d="+l()+s,t));return i.abrupt("return",v.all(r).then(function(e){var t=0,i=0;return h(e).call(e,function(e){t+=Number(e[0]),i+=Number(e[1])}),{networkDelay:(i/n).toFixed(2)+"ms",networkSpeed:(t/n).toFixed(2)+"Mb/s"}}));case 1:case"end":return i.stop()}},i,this)}))}),kt.set(this,function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"https://seat.94ai.com/favicon.png?d="+l(),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:63491;return new v(function(n,i){var r=document.createElement("img");r.start=window.performance.now(),r.onload=function(){var e=window.performance.now()-r.start;n([(1e3*t/(1048576*e)).toFixed(2),e])},r.onerror=function(e){i(e)},r.src=e}).catch(function(e){throw e})}),f(this,"openApiAjax",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return new v(function(t,n){return C(r,void 0,void 0,c.mark(function i(){var r,s,o,a,u,f,l;return c.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return r=pn(t,n,e),s=r.xhr,o=r.ajaxData,a=r.contentType,i.next=1,this.getOpenApiSign();case 1:return u=i.sent,f=u.timestamp,l=u.sign,s.setRequestHeader("appKey",O(this,Je,"f")),s.setRequestHeader("timestamp",String(f)),s.setRequestHeader("sign",l),s.setRequestHeader("Content-type",a||"application/json"),i.next=2,O(this,ke,"f").call(this,s);case 2:s.send(o);case 3:case"end":return i.stop()}},i,this)}))})}}),f(this,"requestGateway",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return r.gatewayApiAjax(m(m({},e),{url:r.getGateway()+e.url}),t)}}),f(this,"gatewayApiAjax",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return new v(function(n,i){return C(r,void 0,void 0,c.mark(function r(){var s,o,a,u,f;return c.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(s=pn(n,i,e),o=s.xhr,a=s.ajaxData,u=s.contentType,!t){r.next=2;break}return r.next=1,this.getGatewayToken();case 1:f=r.sent,o.setRequestHeader("x-token",f),o.setRequestHeader("seatsToken",f),o.setRequestHeader("x-authority-token",f);case 2:return o.setRequestHeader("x-app-code",3),o.setRequestHeader("content-type",u||"application/json"),r.next=3,O(this,xe,"f").call(this,o);case 3:o.send(a);case 4:case"end":return r.stop()}},r,this)}))})}}),f(this,"requestOpenApi",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return r.openApiAjax(m(m({},e),{url:r.getOpenApi()+e.url}))}}),f(this,"getDeviceId",{enumerable:!0,configurable:!0,writable:!0,value:function(){return C(r,void 0,void 0,c.mark(function e(){var t,n;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!O(this,tt,"f")){e.next=1;break}return e.abrupt("return",O(this,tt,"f"));case 1:return e.next=2,j.load();case 2:return t=e.sent,e.next=3,t.get();case 3:return n=e.sent,E(this,tt,n.visitorId,"f"),e.abrupt("return",O(this,tt,"f"));case 4:case"end":return e.stop()}},e,this)}))}}),Ct.set(this,function(){return C(r,void 0,void 0,c.mark(function e(){var t,i,r,s;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!O(this,J,"m",jt).call(this)||O(this,ne,"f").authorizationUsername&&O(this,ne,"f").uri&&O(this,ne,"f").authorizationPassword&&O(this,ne,"f").transportOptions.server){e.next=3;break}return e.next=1,this.getAgentInfo();case 1:if(200!=(t=e.sent).code){e.next=2;break}s=t.data,O(this,ne,"f").authorizationUsername=s.agentExtension,O(this,ne,"f").authorizationPassword=s.extensionPwd,O(this,ne,"f").contactName||(O(this,ne,"f").contactName=s.agentExtension),O(this,ne,"f").uri=n.makeURI(g(i="sip:".concat(s.agentExtension,"@")).call(i,s.wsRegisterAddress)),O(this,ne,"f").transportOptions.server=g(r="".concat(s.wsProtocol,"://")).call(r,s.wsRegisterAddress),E(this,Ke,s.agentId,"f"),E(this,Ze,s.agentTag,"f"),e.next=3;break;case 2:throw new Error(u(t));case 3:case"end":return e.stop()}},e,this)}))}),Ot.set(this,function(){return C(r,void 0,void 0,c.mark(function e(){var t;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(O(this,ne,"f").viaHost){e.next=2;break}return t="",e.next=1,this.getDeviceId();case 1:O(this,ne,"f").viaHost=g(t).call(t,e.sent,".sip");case 2:case"end":return e.stop()}},e,this)}))}),Dt.set(this,function(e){var t,n,i,s,o,a,c,u,f,l,h,d,p,v,m,g,b,k,x,y,S,A,I;O(r,ut,"f").popWindow=null===(o=e["X-Popwindow"])||void 0===o?void 0:o[0].raw,O(r,ut,"f").afterTransferLabour=null===(a=e["X-Aftertransferlabour"])||void 0===a?void 0:a[0].raw,O(r,ut,"f").callId=null===(c=e["X-94callid"])||void 0===c?void 0:c[0].raw,O(r,ut,"f").cid=null===(u=e["X-Cid"])||void 0===u?void 0:u[0].raw,O(r,ut,"f").numberId=null===(f=e["X-Numberid"])||void 0===f?void 0:f[0].raw,O(r,ut,"f").tag=(null===(l=e["X-Tag"])||void 0===l?void 0:l[0].raw)&&"null"!==(null===(h=e["X-Tag"])||void 0===h?void 0:h[0].raw)?w(t=e["X-Tag"][0].raw.split("-")).call(t,function(e){return String.fromCharCode(e)}).join(""):"",O(r,ut,"f").numberTag=(null===(d=e["X-Numbertag"])||void 0===d?void 0:d[0].raw)&&"null"!==(null===(p=e["X-Numbertag"])||void 0===p?void 0:p[0].raw)?decodeURIComponent(e["X-Numbertag"][0].raw):"",O(r,ut,"f").taskId=null===(v=e["X-Taskid"])||void 0===v?void 0:v[0].raw,O(r,ut,"f").voiceType=null===(m=e["X-Voicetype"])||void 0===m?void 0:m[0].raw,O(r,ut,"f").processTime=null===(g=e["X-Processtime"])||void 0===g?void 0:g[0].raw,O(r,ut,"f").userPhone=null===(b=e["X-Userphone"])||void 0===b?void 0:b[0].raw,O(r,ut,"f").autoAnswer=null===(k=e["X-94autoanswer"])||void 0===k?void 0:k[0].raw,O(r,ut,"f").nodeTitle=null===(x=e["X-Nodetitle"])||void 0===x?void 0:w(n=x[0].raw.split("-")).call(n,function(e){return String.fromCharCode(e)}).join(""),O(r,ut,"f").taskName=null===(y=e["X-Taskname"])||void 0===y?void 0:w(i=y[0].raw.split("-")).call(i,function(e){return String.fromCharCode(e)}).join(""),O(r,ut,"f").templateTitle=null===(S=e["X-Templatetitle"])||void 0===S?void 0:w(s=S[0].raw.split("-")).call(s,function(e){return String.fromCharCode(e)}).join(""),O(r,ut,"f").phoneNumber=(null===(A=e["X-Phonenumber"])||void 0===A?void 0:A[0].raw)||(null===(I=e.From)||void 0===I?void 0:I[0].parsed.uri.normal.user)}),Bt.set(this,function(e){switch(e){case i.Initial:case i.Establishing:break;case i.Established:O(r,J,"m",_t).call(r);break;case i.Terminating:case i.Terminated:var t=d(function(){clearTimeout(t),t=void 0,O(r,oe,"f").incomingStatus=!1,O(r,oe,"f").answerStatus=!1},10);O(r,dt,"f").call(r);break;default:throw new Error("Unknown session state.")}}),Vt.set(this,function(e,t,n){O(r,Re,"f")&&(E(r,Pe,!1,"f"),O(r,oe,"f").reconnectStatus=!1,O(r,Ge,"f")&&(E(r,Ge,!1,"f"),O(r,Zt,"f").call(r,e,t,n)))}),Jt.set(this,function(){return C(r,void 0,void 0,c.mark(function e(){return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!O(this,Re,"f")){e.next=6;break}return E(this,Pe,!0,"f"),E(this,Ge,!1,"f"),e.next=1,this.getUserAgent().transport.disconnect().catch(function(e){return console.error(e)});case 1:return console.log("sip transport disconnect"),e.prev=2,e.next=3,O(this,J,"m",Yt).call(this);case 3:e.next=5;break;case 4:e.prev=4,e.catch(2);case 5:O(this,Kt,"f").call(this),O(this,J,"m",sn).call(this);case 6:case"end":return e.stop()}},e,this,[[2,4]])}))}),Wt.set(this,function(){if(O(r,Re,"f")){var e=O(r,ne,"f").uri.clone(),t=O(r,ne,"f").uri.clone(),n=O(r,ne,"f").uri.clone();n.user=void 0,O(r,Zt,"f").call(r,n,e,t)}}),Zt.set(this,function(e,t,n){if(O(r,Re,"f")){if(O(r,Ge,"f"))return;E(r,Ge,!0,"f"),E(r,Ye,d(function(){O(r,J,"m",nn).call(r);var i=r.getUserAgent().userAgentCore,s=i.makeOutgoingRequestMessage("OPTIONS",e,t,n,{});E(r,He,i.request(s,{onAccept:function(){console.log("sip ping ok"),E(r,qe,0,"f"),E(r,He,void 0,"f"),O(r,Vt,"f").call(r,e,t,n)},onReject:function(i){var s;if(E(r,He,void 0,"f"),408===i.message.statusCode||503===i.message.statusCode)if(console.log("sip ping error with code "+i.message.statusCode),O(r,Ne,"f")>0&&O(r,qe,"f")>=O(r,Ne,"f"))console.log("sip maximum ping attempts reached"),O(r,Jt,"f").call(r);else{var o,a;if(O(r,qe,"f")>0)console.log(g(a="sip ping retry ".concat(O(r,qe,"f")," of ")).call(a,O(r,Ne,"f")," fail"));E(r,qe,(s=O(r,qe,"f"),++s),"f"),console.log(g(o="sip ping retry ".concat(O(r,qe,"f")," of ")).call(o,O(r,Ne,"f"))),O(r,Vt,"f").call(r,e,t,n)}else E(r,qe,0,"f"),O(r,Vt,"f").call(r,e,t,n)}}),"f")},1e3*O(r,Re,"f")),"f")}}),Kt.set(this,function(){if(O(r,Re,"f")){if(E(r,Ge,!1,"f"),E(r,Pe,!1,"f"),O(r,He,"f")){try{O(r,He,"f").dispose()}catch(e){}E(r,He,void 0,"f")}O(r,Ye,"f")&&O(r,J,"m",nn).call(r)}}),rn.set(this,function(){if(O(r,Me,"f")){if(O(r,_e,"f"))return;E(r,_e,!0,"f"),O(r,oe,"f").reconnectStatus=!0,E(r,Ve,d(function(){return C(r,void 0,void 0,c.mark(function e(){var t,n=this;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,O(this,J,"m",en).call(this),0===O(this,ze,"f")&&console.log("sip reconnect success then register start"),e.next=1,O(this,K,"f").register({requestDelegate:{onAccept:function(e){console.log("sip reconnect success and register ok"),E(n,ze,0,"f"),E(n,_e,!1,"f"),O(n,oe,"f").registerStatus=!0,O(n,oe,"f").reconnectStatus=!1,O(n,Wt,"f").call(n)},onReject:function(e){return C(n,void 0,void 0,c.mark(function t(){var n,i;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(console.log("sip reconnect success but register fail with code "+e.message.statusCode),E(this,_e,!1,"f"),!(O(this,Ue,"f")<=O(this,ze,"f"))){t.next=2;break}return console.log("sip maximum register attempts reached"),E(this,ze,0,"f"),t.next=1,this.getUserAgent().transport.disconnect().catch(function(e){return console.error(e)});case 1:O(this,J,"m",sn).call(this),t.next=3;break;case 2:E(this,ze,(n=O(this,ze,"f"),++n),"f"),console.log(g(i="sip reconnect success and register retry ".concat(O(this,ze,"f")," of ")).call(i,O(this,Ue,"f"))),O(this,rn,"f").call(this);case 3:case"end":return t.stop()}},t,this)}))}},requestOptions:{extraHeaders:O(this,W,"f")}});case 1:e.next=3;break;case 2:e.prev=2,t=e.catch(0),console.log("sip reconnect then registerer register error",t),E(this,ze,0,"f"),E(this,_e,!1,"f");case 3:case"end":return e.stop()}},e,this,[[0,2]])}))},1e3*O(r,Me,"f")),"f")}}),"object"!==a(s))throw new Error("userAgentOption must be plain object");O(this,J,"m",At).call(this,s),O(this,J,"m",It).call(this,s),O(this,J,"m",St).call(this,s),O(this,J,"m",Tt).call(this,s),O(this,J,"m",Nt).call(this,s),O(this,J,"m",yt).call(this,s),O(this,J,"m",xt).call(this,s),E(this,ne,O(this,J,"m",Pt).call(this,s),"f")},[{key:"volumeValue",get:function(){return O(this,ae,"f")}},{key:"businessAttribute",get:function(){return O(this,ut,"f")}},{key:"getFastOutboundCall",value:function(){return O(this,ut,"f").voiceType===P.LABOUR}},{key:"getSitOutboundCall",value:function(){return O(this,ut,"f").voiceType===P.AI}},{key:"detectNavigatorPermissions",value:function(){var e,t=this;-1===b(e=navigator.userAgent).call(e,"Firefox")?navigator.permissions.query({name:"microphone"}).then(function(e){"granted"===e.state?t.authorizedMicrophonePermissions=!0:t.authorizedMicrophonePermissions=!1}).catch(function(e){console.log("Got error :",e),t.authorizedMicrophonePermissions=!1}):navigator.mediaDevices.enumerateDevices().then(function(e){""!==k(e).call(e,function(e){return"audioinput"===e.kind})[0].label?t.authorizedMicrophonePermissions=!0:t.authorizedMicrophonePermissions=!1}),navigator.permissions.query({name:"notifications"}).then(function(e){"granted"===e.state?t.authorizedNotificationPermissions=!0:t.authorizedNotificationPermissions=!1}).catch(function(e){console.log("Got error :",e),t.authorizedNotificationPermissions=!1})}},{key:"getGateway",value:function(){return"1"===O(this,et,"f")?"https://gateway.sg.94ai.com":"https://gateway.94ai.com"}},{key:"getGatewayToken",value:function(){return C(this,void 0,void 0,c.mark(function e(){var t,n;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,O(this,Se,"f").call(this,O(this,de,"f"));case 1:if(!O(this,fe,"f")){e.next=2;break}return e.abrupt("return",O(this,fe,"f"));case 2:if(this.token){e.next=5;break}return e.next=3,O(this,Ct,"f").call(this);case 3:return e.next=4,this.getGatewayAccessToken({corpId:O(this,Je,"f"),sid:O(this,Ke,"f"),secret:O(this,We,"f"),seatOnline:!1});case 4:t=e.sent,n=t.token,this.token=n,E(this,le,l(),"f");case 5:return e.abrupt("return",this.token);case 6:case"end":return e.stop()}},e,this)}))}},{key:"getGatewayAccessToken",value:function(e){return this.requestGateway({url:"/authority/accessToken/openApi",data:e},!1)}},{key:"getCallNumberDetail",value:function(e){return this.requestGateway({url:"/task-aggre/callCenterNumber/get",data:e})}},{key:"getCallNumberChats",value:function(e){return this.requestGateway({url:"/dialogue-aggre/call-center-number/chat/list",data:e})}},{key:"getCallInfo",value:function(){return C(this,void 0,void 0,c.mark(function e(){var t,n,i,r=this;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t=m({},O(this,ut,"f")),n=function(){return C(r,void 0,void 0,c.mark(function e(){var n,i,r,s,o,a,u,f,l,h,d,p,v,m,b,k,x,y,S,A;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.numberId||!t.taskId){e.next=13;break}return n={},e.prev=1,e.next=2,this.getCallNumberDetail({id:t.numberId,taskId:t.taskId});case 2:if(200===(n=e.sent).code){e.next=3;break}return console.error(n.message),t.stop=!0,O(this,Te,"f").call(this,new Error(n.message)),e.abrupt("return");case 3:e.next=5;break;case 4:return e.prev=4,e.catch(1),s=g(i=g(r="当前会话callid:".concat(t.callId,",根据numberId:")).call(r,t.numberId,",taskId:")).call(i,t.taskId,":查询坐席接听状态异常"),console.error(s),t.stop=!0,O(this,Te,"f").call(this,new Error(n.message)),e.abrupt("return");case 5:if(o=n.data,a=o.callType,u=o.newIntentTag,f=o.intentTag,l=o.number,h=o.numberMd5,d=o.sid,p=o.config,v=o.tag,10!==o.state){e.next=6;break}return console.log("当前会话callid:".concat(t.callId,"已结束")),t.stop=!0,e.abrupt("return");case 6:if(t.callType||(t.callType=a),t.intentTag=u||f,t.number||(t.number=l),t.numberMD5||(t.numberMD5=h),t.agentId||(t.agentId=d),t.tag||(t.tag=v),t.templateId||p&&"string"==typeof p&&(m=JSON.parse(p))&&m.templateId&&(t.templateId=m.templateId),!t.callId){e.next=12;break}return k={},e.prev=7,e.next=8,this.getCallNumberChats({callId:t.callId,taskId:t.taskId});case 8:if(200===(k=e.sent).code){e.next=9;break}return console.error(k.message),t.stop=!0,O(this,Te,"f").call(this,new Error(k.message)),e.abrupt("return");case 9:e.next=11;break;case 10:return e.prev=10,e.catch(7),y=g(x="当前会话根据callId:".concat(t.callId,",taskId:")).call(x,t.taskId,":查询会话对话记录异常"),console.error(y),t.stop=!0,O(this,Te,"f").call(this,new Error(y)),e.abrupt("return");case 11:t.chats=w(b=k.data).call(b,function(e){return e.matchinfo&&(e.matchinfo=JSON.parse(e.matchinfo)),e}),O(this,pe,"f")[t.callId]=t;case 12:try{O(this,be,"f").call(this,O(this,pe,"f")[t.callId])}catch(e){console.log(e)}e.next=14;break;case 13:t.stop=!0,t.taskId||(S="当前会话callid:".concat(t.callId,"的taskId不存在,无法查询通话记录"),console.error(S),O(this,Te,"f").call(this,new Error(S))),t.numberId||(A="当前会话callid:".concat(t.callId,"的numberId不存在,无法查询通话记录"),console.error(A),O(this,Te,"f").call(this,new Error(A)));case 14:case"end":return e.stop()}},e,this,[[1,4],[7,10]])}))},e.prev=1;case 2:if(!t.stop){e.next=3;break}return e.abrupt("continue",7);case 3:return e.next=4,n();case 4:if(!t.stop){e.next=5;break}return e.abrupt("continue",7);case 5:return e.next=6,new v(function(e){var t=d(function(){return C(r,void 0,void 0,c.mark(function n(){return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:clearTimeout(t),t=void 0,e(!0);case 1:case"end":return n.stop()}},n)}))},3e3)});case 6:e.next=2;break;case 7:e.next=9;break;case 8:e.prev=8,i=e.catch(1),O(this,Te,"f").call(this,i);case 9:case"end":return e.stop()}},e,this,[[1,8]])}))}},{key:"refreshCallChatInfo",value:function(){return C(this,void 0,void 0,c.mark(function e(){return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(O(this,ut,"f").numberId&&O(this,ut,"f").callId&&O(this,ut,"f").taskId&&O(this,ft,"f"))){e.next=1;break}return e.next=1,this.getCallInfo();case 1:case"end":return e.stop()}},e,this)}))}},{key:"getOpenApi",value:function(){return O(this,$e,"f")?function(e){if(!e)return!1;var t=/^[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z]{2,}$/;return!!/^(\d{1,3}\.){3}\d{1,3}$/.test(e)||("//"===I(e).call(e,0,2)?t.test(I(e).call(e,2,e.length)):"http://"===I(e).call(e,0,7)?t.test(I(e).call(e,7,e.length)):"https://"===I(e).call(e,0,8)?t.test(I(e).call(e,8,e.length)):t.test(e))}(O(this,$e,"f"))?O(this,$e,"f"):"1"===O(this,et,"f")?"1"===O(this,Qe,"f")?"https://seatsg.94ai.com/sgopenapi":"https://seatsg.94ai.com/openapi":"1"===O(this,Qe,"f")?"https://seat.94ai.com/sgopenapi":"https://seat.94ai.com/openapi":"https://seat.94ai.com/openapi"}},{key:"getAgentInfo",value:function(){return this.requestOpenApi({url:"/v1/agent/getAgent",data:{agentTag:O(this,Ze,"f"),agentId:O(this,Ke,"f")}})}},{key:"getOpenApiSign",value:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:l(),i=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0;return C(this,void 0,void 0,c.mark(function s(){return c.wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=1,O(this,ye,"f").call(this,O(this,he,"f"));case 1:return s.abrupt("return",{sign:null!==(e=O(this,ce,"f"))&&void 0!==e?e:T.enc.Base64.stringify(T.HmacSHA1(i||O(this,Je,"f")+n,r||O(this,We,"f"))),timestamp:null!==(t=O(this,ue,"f"))&&void 0!==t?t:n});case 2:case"end":return s.stop()}},s,this)}))}},{key:"updateOpenApiAgentStatus",value:function(e){return this.requestOpenApi({url:"/v1/agent/updateAgentStatus",data:{agentTag:O(this,Ze,"f"),agentId:O(this,Ke,"f"),agentStatus:e}})}},{key:"importOpenApiAgentCustomer",value:function(e){return this.requestOpenApi({url:"/v1/task/importAgentCustomer",data:{agentTag:O(this,Ze,"f"),agentId:O(this,Ke,"f"),callType:1001,customers:[{number:e}]}})}},{key:"callNumber",value:function(e){return this.importOpenApiAgentCustomer(e)}},{key:"toggleNap",value:function(e){return e?this.updateOpenApiAgentStatus(3):this.updateOpenApiAgentStatus(1)}},{key:"refreshSign",value:function(e){E(this,ce,e,"f")}},{key:"prepareUserAgent",value:function(e,t){var n;return C(this,void 0,void 0,c.mark(function i(){var r,s,o,a,u,f,l,h,d,p,v,g;return c.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return s=(r=e||{}).refresh,o=r.registererOptions,a=r.registererRegisterOptions,u=r.extraHeaders,f=r.authorizationUsername,l=r.authorizationPassword,h=r.uri,d=r.contactName,p=r.transportOptions,i.next=1,this.dispose();case 1:return O(this,ne,"f").uri=null!=h?h:O(this,ne,"f").uri,O(this,ne,"f").authorizationUsername=null!=f?f:O(this,ne,"f").authorizationUsername,O(this,ne,"f").authorizationPassword=null!=l?l:O(this,ne,"f").authorizationPassword,O(this,ne,"f").contactName=null!==(n=null!=d?d:f)&&void 0!==n?n:O(this,ne,"f").contactName,p&&(O(this,ne,"f").transportOptions=m(m({},O(this,ne,"f").transportOptions),p)),i.prev=2,O(this,J,"m",It).call(this,e),i.next=3,O(this,Ct,"f").call(this);case 3:return i.next=4,O(this,Ot,"f").call(this);case 4:return O(this,J,"m",Rt).call(this,{refresh:s}),i.next=5,O(this,J,"m",cn).call(this);case 5:return t&&O(this,J,"m",an).call(this,t),i.next=6,O(this,J,"m",un).call(this,{registererOptions:o,registererRegisterOptions:a,extraHeaders:u},O(this,ot,"f"));case 6:return v=i.sent,i.abrupt("return",v);case 7:return i.prev=7,g=i.catch(2),i.next=8,this.dispose();case 8:throw g;case 9:case"end":return i.stop()}},i,this,[[2,7]])}))}},{key:"dispose",value:function(){return C(this,void 0,void 0,c.mark(function e(){var t;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,O(this,J,"m",Et).call(this),e.next=1,O(this,J,"m",Mt).call(this);case 1:e.next=3;break;case 2:e.prev=2,t=e.catch(0),O(this,J,"m",zt).call(this),console.log("sip dispose with error",t);case 3:case"end":return e.stop()}},e,this,[[0,2]])}))}},{key:"ignoreInvite",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return C(this,void 0,void 0,c.mark(function t(){return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return O(this,oe,"f").incomingStatus=!1,t.next=1,this.getCurrentInvitation().reject(e);case 1:case"end":return t.stop()}},t,this)}))}},{key:"acceptInvite",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return C(this,void 0,void 0,c.mark(function t(){var n,i=this;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=1,new v(function(t,n){C(i,void 0,void 0,c.mark(function i(){var r,s,o;return c.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.prev=0,r=null==e?void 0:e.onAck,s=null==e?void 0:e.onAckTimeout,null==e||delete e.onAck,null==e||delete e.onAckTimeout,i.next=1,this.getCurrentInvitation().accept(m({sessionDescriptionHandlerOptions:{constraints:{audio:!0,video:!1}},onAck:function(e){t(e),null==r||r()},onAckTimeout:function(){null==s||s(),n(new Error("接听响应超时"))}},e||{}));case 1:i.next=3;break;case 2:i.prev=2,o=i.catch(0),n(o);case 3:case"end":return i.stop()}},i,this,[[0,2]])}))});case 1:O(this,oe,"f").incomingStatus&&(O(this,oe,"f").incomingStatus=!1,O(this,oe,"f").answerStatus=!0),t.next=3;break;case 2:throw t.prev=2,n=t.catch(0),O(this,oe,"f").incomingStatus=!1,n;case 3:case"end":return t.stop()}},t,this,[[0,2]])}))}},{key:"hangUpInvite",value:function(e){return C(this,void 0,void 0,c.mark(function t(){var n,r,s,o,a,u=this;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=(n=e||{}).rejectOptions,s=n.byeOptions,o=n.extraHeaders,a=n.scoutResponse,t.abrupt("return",new v(function(e,t){return C(u,void 0,void 0,c.mark(function n(){var u,f,l,h,d,p,v,g,w,b,k;return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:n.prev=0,v=null===(u=(p=s||{}).requestDelegate)||void 0===u?void 0:u.onAccept,g=null===(f=p.requestDelegate)||void 0===f?void 0:f.onReject,null===(l=p.requestDelegate)||void 0===l||delete l.onAccept,null===(h=p.requestDelegate)||void 0===h||delete h.onReject,w=O(this,J,"m",qt).call(this,{onAccept:function(t){console.log("sip bye success"),e(t),null==v||v(t)},onReject:function(e){null==g||g(e),t(new Error("sip bye fail with code "+e.message.statusCode))}},p.requestDelegate),delete p.requestDelegate,b=null===(d=O(this,ie,"f"))||void 0===d?void 0:d.state,n.next=b===i.Initial||b===i.Establishing?1:b===i.Established?3:b===i.Terminating||b===i.Terminated?5:6;break;case 1:return n.next=2,O(this,ie,"f").reject(m({extraHeaders:o},r||{}));case 2:return e(!0),n.abrupt("continue",6);case 3:return n.next=4,O(this,ie,"f").bye(m({requestDelegate:w,requestOptions:{extraHeaders:o}},p));case 4:return a||e(!0),n.abrupt("continue",6);case 5:return e(!0),n.abrupt("continue",6);case 6:n.next=8;break;case 7:n.prev=7,k=n.catch(0),t(k);case 8:return n.prev=8,O(this,oe,"f").incomingStatus=!1,O(this,oe,"f").answerStatus=!1,n.finish(8);case 9:case"end":return n.stop()}},n,this,[[0,7,8,9]])}))}));case 1:case"end":return t.stop()}},t)}))}},{key:"sendStarDtmf",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return C(this,void 0,void 0,c.mark(function t(){var n=this;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new v(function(t,i){return C(n,void 0,void 0,c.mark(function n(){var r,s,o,a,u;return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,s=(r=e||{}).extraHeaders,o=r.requestDelegate,a=O(this,J,"m",qt).call(this,{onAccept:function(e){console.log("sip send dtmf Signal=* success"),t(e)},onReject:function(e){i(new Error("sip send dtmf Signal=* fail with code "+e.message.statusCode))}},o),delete r.requestDelegate,n.next=1,this.getCurrentInvitation().info(m({requestOptions:{body:{contentDisposition:"render",contentType:"application/dtmf-relay",content:"Signal=*\r\nDuration=100"},extraHeaders:s},requestDelegate:a},r));case 1:O(this,ht,"f").call(this),n.next=3;break;case 2:n.prev=2,u=n.catch(0),i(u);case 3:case"end":return n.stop()}},n,this,[[0,2]])}))}));case 1:case"end":return t.stop()}},t)}))}},{key:"muteRemoteAudio",value:function(){var e;h(e=O(this,Q,"f").getReceivers()).call(e,function(e){e.track.enabled=!1})}},{key:"unMuteRemoteAudio",value:function(){var e;h(e=O(this,Q,"f").getReceivers()).call(e,function(e){e.track.enabled=!0})}},{key:"muteLocalAudio",value:function(){var e;h(e=O(this,Q,"f").getSenders()).call(e,function(e){e.track.enabled=!1})}},{key:"unMuteLocalAudio",value:function(){var e;h(e=O(this,Q,"f").getSenders()).call(e,function(e){e.track.enabled=!0})}},{key:"getUserAgentStatue",value:function(){return O(this,oe,"f")}},{key:"getUserAgent",value:function(){return O(this,Z,"f")||E(this,Z,new n(O(this,ne,"f")),"f"),O(this,Z,"f")}},{key:"getSessionDescriptionHandler",value:function(){return O(this,$,"f")}},{key:"getPeerConnection",value:function(){return O(this,Q,"f")}},{key:"getSenders",value:function(){return O(this,te,"f")}},{key:"getReceivers",value:function(){return O(this,ee,"f")}},{key:"getStream",value:function(){var e,t=this;return O(this,se,"f")||E(this,se,new MediaStream,"f"),h(e=O(this,ee,"f")).call(e,function(e){e.track&&O(t,se,"f").addTrack(e.track)}),O(this,se,"f")}},{key:"getCurrentInviter",value:function(){if(!O(this,re,"f"))throw new Error("No currentInviter...");return O(this,re,"f")}},{key:"getCurrentInvitation",value:function(){return O(this,ie,"f")}},{key:"invite",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return C(this,void 0,void 0,c.mark(function i(){var s,o,a;return c.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(o=n.makeURI(e.uri?e.uri:g(s="sip:".concat(e.extension,"@")).call(s,O(this,ne,"f").transportOptions.server.split("://")[1]))){i.next=1;break}throw new Error("Failed to create target URI.");case 1:return E(this,re,new r(this.getUserAgent(),o,{sessionDescriptionHandlerOptions:{constraints:{audio:!0,video:!1}}}),"f"),a=(t||{}).extraHeaders,i.next=2,this.getCurrentInviter().invite(m({requestOptions:{extraHeaders:a}},t));case 2:return i.abrupt("return",O(this,re,"f"));case 3:case"end":return i.stop()}},i,this)}))}}])}();W=new x,Z=new x,K=new x,$=new x,Q=new x,ee=new x,te=new x,ne=new x,ie=new x,re=new x,se=new x,oe=new x,ae=new x,ce=new x,ue=new x,fe=new x,le=new x,he=new x,de=new x,pe=new x,ve=new x,me=new x,ge=new x,we=new x,be=new x,ke=new x,xe=new x,ye=new x,Se=new x,Ae=new x,Ie=new x,Te=new x,je=new x,Ce=new x,Oe=new x,Ee=new x,De=new x,Re=new x,Ne=new x,qe=new x,Pe=new x,He=new x,Me=new x,Ue=new x,ze=new x,Le=new x,Xe=new x,Fe=new x,Ge=new x,_e=new x,Be=new x,Ye=new x,Ve=new x,Je=new x,We=new x,Ze=new x,Ke=new x,$e=new x,Qe=new x,et=new x,tt=new x,nt=new x,it=new x,rt=new x,st=new x,ot=new x,at=new x,ct=new x,ut=new x,ft=new x,lt=new x,ht=new x,dt=new x,pt=new x,vt=new x,mt=new x,gt=new x,wt=new x,bt=new x,kt=new x,Ct=new x,Ot=new x,Dt=new x,Bt=new x,Vt=new x,Jt=new x,Wt=new x,Zt=new x,Kt=new x,rn=new x,J=new y,xt=function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};E(this,ke,null!==(e=n.openXhrIntercept)&&void 0!==e?e:O(this,ke,"f"),"f"),E(this,xe,null!==(t=n.gatewayXhrIntercept)&&void 0!==t?t:O(this,xe,"f"),"f")},yt=function(){var e,t,n,i,r,s,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};E(this,ft,null!==(e=o.enableChatInfoPush)&&void 0!==e?e:O(this,ft,"f"),"f"),E(this,lt,null!==(t=o.enableVolumnTrack)&&void 0!==t?t:O(this,lt,"f"),"f"),E(this,we,null!==(n=o.refreshSpeekVolumn)&&void 0!==n?n:O(this,we,"f"),"f"),E(this,je,null!==(i=o.refreshRequirementCheck)&&void 0!==i?i:O(this,je,"f"),"f"),E(this,be,null!==(r=o.refreshChat)&&void 0!==r?r:O(this,be,"f"),"f"),E(this,Te,null!==(s=o.refreshChatErrorCallback)&&void 0!==s?s:O(this,Te,"f"),"f")},St=function(){var e,t,n,i,r,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};E(this,fe,null!==(e=s.token)&&void 0!==e?e:O(this,fe,"f"),"f"),E(this,le,null!==(t=s.tokenTimestamp)&&void 0!==t?t:O(this,le,"f"),"f"),E(this,de,null!==(n=s.tokenExpirationTime)&&void 0!==n?n:O(this,de,"f"),"f"),O(this,fe,"f")&&!O(this,le,"f")&&E(this,le,l(),"f"),E(this,Se,null!==(i=s.tokenCheck)&&void 0!==i?i:O(this,Se,"f"),"f"),E(this,Ie,null!==(r=s.tokenOverdued)&&void 0!==r?r:O(this,Ie,"f"),"f")},At=function(){var e,t,n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};E(this,ot,null!==(e=i.clusterMode)&&void 0!==e?e:O(this,ot,"f"),"f"),E(this,at,null!==(t=i.reClusterRegisterTimeout)&&void 0!==t?t:O(this,at,"f"),"f"),E(this,ct,null!==(n=i.reClusterConnectTimeout)&&void 0!==n?n:O(this,ct,"f"),"f")},It=function(){var e,t,n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.agentId,s=i.agentTag,o=i.appKey,a=i.appSecret,c=i.openBaseUrl,u=i.sg,f=i.sgOpen,l=i.sign,h=i.timestamp;E(this,Ke,null!=r?r:O(this,Ke,"f"),"f"),E(this,Ze,null!=s?s:O(this,Ze,"f"),"f"),E(this,Je,null!=o?o:O(this,Je,"f"),"f"),E(this,We,null!=a?a:O(this,We,"f"),"f"),E(this,$e,null!=c?c:O(this,$e,"f"),"f"),E(this,et,null!=u?u:O(this,et,"f"),"f"),E(this,Qe,null!=f?f:O(this,Qe,"f"),"f"),E(this,ce,null!=l?l:O(this,ce,"f"),"f"),E(this,ue,null!=h?h:O(this,ue,"f"),"f"),E(this,he,null!==(e=i.signExpirationTime)&&void 0!==e?e:O(this,he,"f"),"f"),E(this,ye,null!==(t=i.signCheck)&&void 0!==t?t:O(this,ye,"f"),"f"),E(this,Ae,null!==(n=i.signOverdued)&&void 0!==n?n:O(this,Ae,"f"),"f")},Tt=function(e){e.sipHeaders&&(E(this,W,e.sipHeaders,"f"),delete e.sipHeaders)},jt=function(){return!(!O(this,Ke,"f")&&!O(this,Ze,"f")||!(O(this,Je,"f")&&O(this,We,"f")||O(this,ce,"f")&&O(this,ue,"f")))},Et=function(){O(this,J,"m",Ut).call(this),O(this,J,"m",Ft).call(this),O(this,J,"m",Gt).call(this),O(this,J,"m",Xt).call(this),O(this,J,"m",Lt).call(this),O(this,J,"m",$t).call(this),O(this,J,"m",Qt).call(this),O(this,J,"m",zt).call(this),O(this,dt,"f").call(this),E(this,ut,{},"f"),E(this,pe,{},"f")},Rt=function(e){E(this,oe,o(JSON.parse(u(L)),"function"==typeof e.refresh?e.refresh:O(this,it,"f")),"f")},Nt=function(e){var t,n,i,r,s,o,a,c,u,f,l,h,d,p,v;E(this,Ee,null!==(i=null!==(t=e.reconnectionAttempts)&&void 0!==t?t:null===(n=null==e?void 0:e.transportOptions)||void 0===n?void 0:n.maxReconnectionAttempts)&&void 0!==i?i:O(this,Ee,"f"),"f"),E(this,De,null!==(a=null!==(s=null!==(r=e.reconnectionInterval)&&void 0!==r?r:e.reconnectionDelay)&&void 0!==s?s:null===(o=null==e?void 0:e.transportOptions)||void 0===o?void 0:o.reconnectionTimeout)&&void 0!==a?a:O(this,De,"f"),"f"),E(this,Le,null!==(u=null===(c=e.transportOptions)||void 0===c?void 0:c.keepAliveInterval)&&void 0!==u?u:O(this,Le,"f"),"f"),E(this,Xe,null!==(l=null===(f=e.transportOptions)||void 0===f?void 0:f.keepAliveDebounce)&&void 0!==l?l:O(this,Xe,"f"),"f"),E(this,Me,null!==(h=e.registerInterval)&&void 0!==h?h:O(this,Me,"f"),"f"),E(this,Re,null!==(d=e.optionsPingInterval)&&void 0!==d?d:O(this,Re,"f"),"f"),E(this,Ne,null!==(p=e.optionsPingAttempts)&&void 0!==p?p:O(this,Ne,"f"),"f"),E(this,Ue,null!==(v=e.registerAttempts)&&void 0!==v?v:O(this,Ue,"f"),"f")},qt=function(e,t){var n,i=this;return t?(h(n=S(t)).call(n,function(n){if(t[n]&&"function"==typeof t[n])if(e[n]){if("function"==typeof e[n]){var r=e[n];e[n]=function(e){return C(i,void 0,void 0,c.mark(function i(){return c.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=1,t[n](e);case 1:return i.next=2,r(e);case 2:case"end":return i.stop()}},i)}))}}}else e[n]=t[n]}),e):e},Pt=function(e){var t,n=this,i={delegate:{onConnect:function(){return C(n,void 0,void 0,c.mark(function e(){return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:console.log("sip connected"),O(this,Wt,"f").call(this);case 1:case"end":return e.stop()}},e,this)}))},onInvite:function(e){O(n,Dt,"f").call(n,e.incomingInviteRequest.message.headers),n.refreshCallChatInfo(),O(n,J,"m",Ht).call(n),E(n,ie,e,"f"),O(n,oe,"f").incomingStatus=!0,e.stateChange.addListener(O(n,Bt,"f"))},onDisconnect:function(e){return C(n,void 0,void 0,c.mark(function t(){var n;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("sip disconnected"),n=!1,O(this,Re,"f")>0&&(n=O(this,Pe,"f"),O(this,Kt,"f").call(this)),t.prev=1,t.next=2,O(this,J,"m",Yt).call(this);case 2:t.next=4;break;case 3:t.prev=3,t.catch(1);case 4:(e||n)&&O(this,J,"m",sn).call(this);case 5:case"end":return t.stop()}},t,this,[[1,3]])}))}}};e.delegate?h(t=S(e.delegate)).call(t,function(t){var r=t;if(e.delegate[r]&&"function"==typeof e.delegate[r]){var s=e.delegate[r];e.delegate[r]=function(e){return C(n,void 0,void 0,c.mark(function t(){var n,o;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return null===(o=(n=i.delegate)[r])||void 0===o||o.call(n,e),t.next=1,s(e);case 1:case"end":return t.stop()}},t)}))}}}):e.delegate=i.delegate;return e.reconnectionAttempts=0,e.transportOptions=m(m({},e.transportOptions||{}),{keepAliveInterval:O(this,Le,"f"),keepAliveDebounce:O(this,Xe,"f")}),void 0===e.sessionDescriptionHandlerFactoryOptions&&(e.sessionDescriptionHandlerFactoryOptions={iceGatheringTimeout:2e3,peerConnectionConfiguration:{iceServers:[]}}),m(m({},z),e)},Ht=function(){O(this,ie,"f")&&(O(this,ie,"f").dispose(),E(this,ie,void 0,"f"))},Mt=function(){return C(this,void 0,void 0,c.mark(function e(){return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!O(this,Z,"f")){e.next=2;break}return e.next=1,O(this,Z,"f").stop();case 1:E(this,Z,void 0,"f");case 2:case"end":return e.stop()}},e,this)}))},Ut=function(){var e;O(this,se,"f")&&(h(e=O(this,se,"f").getTracks()).call(e,function(e){e.stop()}),E(this,se,void 0,"f"))},zt=function(){var e,t=this;h(e=S(L)).call(e,function(e){var n=e;O(t,oe,"f")[n]=L[n]})},Lt=function(){O(this,$,"f")&&(O(this,$,"f").close(),E(this,$,void 0,"f"))},Xt=function(){O(this,Q,"f")&&(O(this,Q,"f").close(),E(this,Q,void 0,"f"))},Ft=function(){E(this,te,[],"f")},Gt=function(){E(this,ee,[],"f")},_t=function(){var e=this.getCurrentInvitation().sessionDescriptionHandler;O(this,J,"m",Xt).call(this),O(this,J,"m",Lt).call(this),O(this,J,"m",Ft).call(this),O(this,J,"m",Gt).call(this),E(this,$,e,"f"),E(this,Q,e.peerConnection,"f"),E(this,te,O(this,Q,"f").getSenders(),"f"),E(this,ee,O(this,Q,"f").getReceivers(),"f"),(this.getFastOutboundCall()||!this.getSitOutboundCall()&&this.notNeedSendStarDtmf())&&O(this,ht,"f").call(this)},Yt=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return C(this,void 0,void 0,c.mark(function t(){var n=this;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!O(this,K,"f")){t.next=1;break}return console.log("sip due to disconnection, unregistered"),t.abrupt("return",new v(function(t,i){return C(n,void 0,void 0,c.mark(function n(){var r,s,o;return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,r=e||{},s=O(this,J,"m",qt).call(this,{onAccept:function(e){console.log("sip unregister successed"),t(e)},onReject:function(e){i(new Error("sip unregister fail with code "+e.message.statusCode))}},r.requestDelegate),delete e.requestDelegate,n.next=1,O(this,K,"f").unregister(m({requestDelegate:s},e));case 1:n.next=3;break;case 2:n.prev=2,o=n.catch(0),i(o);case 3:case"end":return n.stop()}},n,this,[[0,2]])}))}));case 1:case"end":return t.stop()}},t,this)}))},$t=function(){O(this,J,"m",en).call(this),O(this,J,"m",tn).call(this),O(this,J,"m",nn).call(this),E(this,_e,!1,"f"),E(this,Fe,!1,"f"),E(this,Ge,!1,"f")},Qt=function(){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&(clearTimeout(O(this,rt,"f")),E(this,rt,void 0,"f")),e&&(clearTimeout(O(this,st,"f")),E(this,st,void 0,"f"))},en=function(){clearTimeout(O(this,Ve,"f")),E(this,Ve,void 0,"f")},tn=function(){clearTimeout(O(this,Be,"f")),E(this,Be,void 0,"f")},nn=function(){clearTimeout(O(this,Ye,"f")),E(this,Ye,void 0,"f")},sn=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return C(this,void 0,void 0,c.mark(function n(){var i=this;return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!O(this,De,"f")){n.next=4;break}if(O(this,oe,"f").reconnectStatus=!0,!O(this,Fe,"f")){n.next=1;break}return n.abrupt("return");case 1:if(!(t>O(this,Ee,"f"))){n.next=3;break}return console.log("sip maximum reconnection attempts reached"),n.next=2,this.dispose();case 2:return n.abrupt("return");case 3:console.log("sip reconnection attempt..."),E(this,Fe,!0,"f"),E(this,Be,d(function(){O(i,J,"m",tn).call(i),i.getUserAgent().reconnect().then(function(){return C(i,void 0,void 0,c.mark(function e(){var n;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:console.log(g(n="sip reconnection attempt ".concat(t," of ")).call(n,O(this,Ee,"f")," - succeeded")),E(this,Fe,!1,"f"),O(this,rn,"f").call(this);case 1:case"end":return e.stop()}},e,this)}))}).catch(function(n){var r;console.error(n),console.log(g(r="sip reconnection attempt ".concat(t," of ")).call(r,O(i,Ee,"f")," - failed")),E(i,Fe,!1,"f"),O(i,J,"m",e).call(i,++t)})},1===t?0:1e3*O(this,De,"f")),"f");case 4:case"end":return n.stop()}},n,this)}))},on=function(e){var t,n=this;return h(t=S(e)).call(t,function(t){var i=t;if("function"==typeof(null==e?void 0:e[i])){var r=e[i];e[i]=function(e){return C(n,void 0,void 0,c.mark(function t(){var n,s;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return null===(s=(n=O(this,ne,"f").delegate)[i])||void 0===s||s.call(n,e),t.next=1,r(e);case 1:case"end":return t.stop()}},t,this)}))}}}),e},an=function(e){var t=this.getUserAgent();return t.delegate=O(this,J,"m",on).call(this,e),t},cn=function(){return C(this,void 0,void 0,c.mark(function e(){var t;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.getUserAgent(),e.next=1,t.start();case 1:if(t.isConnected()){e.next=2;break}return e.next=2,t.reconnect();case 2:if(t.isConnected()){e.next=3;break}throw new Error("链接失败,请稍后再试");case 3:return O(this,oe,"f").connectStatus=!0,e.abrupt("return",t);case 4:case"end":return e.stop()}},e,this)}))},un=function e(t){var i=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=t||{},a=o.registererOptions,u=o.registererRegisterOptions,f=o.extraHeaders;return new v(function(t,o){return C(i,void 0,void 0,c.mark(function i(){var l,h,p,v,g,w=this;return c.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return l=this.getUserAgent(),E(this,K,new s(l,m({extraHeaders:f||O(this,W,"f")},a||{})),"f"),p=u||{},v=O(this,J,"m",qt).call(this,{onAccept:function(e){h=e,O(w,J,"m",Qt).call(w),O(w,oe,"f").registerStatus=!0,t(l)},onReject:function(e){O(w,J,"m",Qt).call(w),o(new Error("sip register fail with code "+e.message.statusCode))}},p.requestDelegate),delete p.requestDelegate,r&&E(this,rt,d(function(){return C(w,void 0,void 0,c.mark(function i(){var r,g=this;return c.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(h){i.next=4;break}E(this,st,d(function(){return C(g,void 0,void 0,c.mark(function i(){var r,s;return c.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(O(this,J,"m",Qt).call(this,!1,!0),h){i.next=6;break}i.prev=1;try{O(this,K,"f").dispose()}catch(e){}return O(this,J,"m",Et).call(this),O(this,Kt,"f").call(this),E(this,qe,0,"f"),E(this,ze,0,"f"),i.next=2,O(this,Z,"f").transport.dispose();case 2:return E(this,Z,new n(O(this,ne,"f")),"f"),i.next=3,O(this,J,"m",cn).call(this);case 3:return i.next=4,O(this,J,"m",e).call(this,{registererOptions:a,registererRegisterOptions:u,extraHeaders:f});case 4:r=i.sent,t(r),i.next=6;break;case 5:i.prev=5,s=i.catch(1),o(s);case 6:case"end":return i.stop()}},i,this,[[1,5]])}))},O(this,ct,"f")),"f");try{O(this,K,"f").dispose()}catch(e){}return E(this,K,new s(l,m({extraHeaders:f||O(this,W,"f")},a||{})),"f"),O(this,J,"m",Qt).call(this,!0,!1),i.prev=1,i.next=2,O(this,K,"f").register(m({requestDelegate:v,requestOptions:{extraHeaders:f||O(this,W,"f")}},p));case 2:i.next=4;break;case 3:i.prev=3,r=i.catch(1),O(this,J,"m",Qt).call(this),o(r);case 4:case"end":return i.stop()}},i,this,[[1,3]])}))},O(this,at,"f")),"f"),i.prev=1,i.next=2,O(this,K,"f").register(m({requestDelegate:v,requestOptions:{extraHeaders:f||O(this,W,"f")}},p));case 2:i.next=4;break;case 3:i.prev=3,g=i.catch(1),O(this,J,"m",Qt).call(this),o(g);case 4:case"end":return i.stop()}},i,this,[[1,3]])}))})};var wn=function(){return t(function t(){e(this,t)},null,[{key:"getUserAgentManager",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return O(this,vn,"f",mn)||E(this,vn,new gn(e),"f",mn),O(this,vn,"f",mn)}},{key:"hasUserAgentManager",value:function(){return!!O(this,vn,"f",mn)}},{key:"newUserAgentManager",value:function(){return new gn(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}},{key:"dispose",value:function(){if(O(this,vn,"f",mn))try{O(this,vn,"f",mn).dispose()}catch(e){}finally{E(this,vn,void 0,"f",mn)}}}])}();vn=wn,mn={value:void 0};export{wn as UserAgentFactory,gn as UserAgentManager,hn as accumulateSec,dn as accumulationTimer,V as cleanupMedia,G as getDevicePermission,X as getMedia,fn as getTimes,ln as getZeorTime,Y as pauseMedia,B as playMedia,_ as requestMicroPhonePermission,F as stopStreamTracks,z as userAgentDefault,L as userAgentStatus};
|
|
1
|
+
import e from"@babel/runtime-corejs3/helpers/esm/classCallCheck";import t from"@babel/runtime-corejs3/helpers/esm/createClass";import{UserAgent as n,SessionState as i,Inviter as r,Registerer as s}from"sip.js";export{Inviter,Registerer,SessionState,URI,UserAgent}from"sip.js";export{SimpleUser}from"sip.js/lib/platform/web/index.js";import o from"on-change";export{default as onChange}from"on-change";import a from"@babel/runtime-corejs3/helpers/esm/typeof";import c from"@babel/runtime-corejs3/regenerator";import u from"@babel/runtime-corejs3/core-js/json/stringify";import f from"@babel/runtime-corejs3/core-js/object/define-property";import l from"@babel/runtime-corejs3/core-js/date/now";import h from"@babel/runtime-corejs3/core-js/instance/for-each";import d from"@babel/runtime-corejs3/core-js/set-timeout";import p from"@babel/runtime-corejs3/core-js/set-interval";import v from"@babel/runtime-corejs3/core-js/promise";import m from"@babel/runtime-corejs3/core-js/object/assign";import g from"@babel/runtime-corejs3/core-js/instance/concat";import w from"@babel/runtime-corejs3/core-js/instance/map";import b from"@babel/runtime-corejs3/core-js/instance/index-of";import k from"@babel/runtime-corejs3/core-js/instance/filter";import x from"@babel/runtime-corejs3/core-js/weak-map";import y from"@babel/runtime-corejs3/core-js/weak-set";import S from"@babel/runtime-corejs3/core-js/object/keys";import A from"@babel/runtime-corejs3/core-js/instance/pad-start";import I from"@babel/runtime-corejs3/core-js/instance/slice";import T from"crypto-js";import j from"@fingerprintjs/fingerprintjs";function C(e,t,n,i){return new(n||(n=Promise))(function(r,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,a)}c((i=i.apply(e,t||[])).next())})}function O(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function E(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}var D,R;"function"==typeof SuppressedError&&SuppressedError;var N,q,P,H,M=g(D="sip:".concat("","@")).call(D,""),U=g(R="".concat("","://")).call(R,""),z={authorizationPassword:"",authorizationUsername:"",viaHost:"",uri:n.makeURI(M),logLevel:"error",transportOptions:{server:U},contactName:""},L={connectStatus:!1,registerStatus:!1,invitatingStatus:!1,incomingStatus:!1,answerStatus:!1,reconnectStatus:!1};function X(e){return document.getElementById(e)}function F(e){if(e&&e.getTracks)try{var t=e.getTracks();h(t).call(t,function(e){try{e.stop()}catch(e){}})}catch(e){}}function G(e){return navigator.mediaDevices.getUserMedia(e).then(function(e){return e?(F(e),!0):v.reject(new Error("EmptyStreamError"))}).catch(function(e){return(!e||"NotAllowedError"!==e.name)&&v.reject(e)})}function _(){try{var e;if(-1===b(e=navigator.userAgent).call(e,"Firefox"))return G({video:!1,audio:!0}).catch(function(){return!0})}catch(e){console.log(e)}}function B(e){var t=X(e);t&&(t.currentTime=0,t.play())}function Y(e){var t=X(e);t&&(t.currentTime=0,t.pause())}function V(e){var t=X(e);t&&(t.srcObject=null,t.pause())}!function(e){e.NO="0",e.YES="1"}(N||(N={})),function(e){e.NO="0",e.YES="1"}(q||(q={})),function(e){e.MULTI_AI="1",e.MULTI_VOICE_NOTIFY="2",e.MULTI_PRETEST="3",e.LABOUR="4",e.AI="5",e.NEW_VOICE_NOTIFY="6"}(P||(P={})),function(e){e.DIRECT_ANSWER="1",e.LISTEN_FIRST_AND_THEN_ANSWER_MANUALLY="2"}(H||(H={}));var J,W,Z,K,$,Q,ee,te,ne,ie,re,se,oe,ae,ce,ue,fe,le,he,de,pe,ve,me,ge,we,be,ke,xe,ye,Se,Ae,Ie,Te,je,Ce,Oe,Ee,De,Re,Ne,qe,Pe,He,Me,Ue,ze,Le,Xe,Fe,Ge,_e,Be,Ye,Ve,Je,We,Ze,Ke,$e,Qe,et,tt,nt,it,rt,st,ot,at,ct,ut,ft,lt,ht,dt,pt,vt,mt,gt,wt,bt,kt,xt,yt,St,At,It,Tt,jt,Ct,Ot,Et,Dt,Rt,Nt,qt,Pt,Ht,Mt,Ut,zt,Lt,Xt,Ft,Gt,_t,Bt,Yt,Vt,Jt,Wt,Zt,Kt,$t,Qt,en,tn,nn,rn,sn,on,an,cn,un,fn=function(e){var t,n,i;return A(t=e.getHours().toString()).call(t,2,"0")+":"+A(n=e.getMinutes().toString()).call(n,2,"0")+":"+A(i=e.getSeconds().toString()).call(i,2,"0")},ln=function(){return new Date(new Date((new Date).toLocaleDateString()).getTime())},hn=function(e){return new Date(e.setSeconds(e.getSeconds()+1))};function dn(e){var t=ln();e(fn(t));var n=p(function(){var n=hn(t),i=fn(n);e(i)},1e3);return function(){clearInterval(n),n=null}}function pn(e,t,n){var i=window.XMLHttpRequest?new window.XMLHttpRequest:window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLHTTP"):void 0;i||t(new Error("Your Browser does not support ajax")),i.onreadystatechange=function(){if(4==i.readyState){var n=i.response||i.responseText;if(200==i.status){var r=i.getResponseHeader("Content-Type");-1!=b(r).call(r,"json")?e(JSON.parse(i.responseText)):-1!=b(r).call(r,"xml")?e(i.responseXML):e(i.responseText)}else t(n)}};var r=n.url,s=n.data,o=n.type,a=n.contentType,c=o||"POST",f=r,l=null;return s&&("GET"===c?f=f+"?"+function(e){var t=[];for(var n in e)t.push(n+"="+e[n]);return t.join("&")}(s):"POST"===c&&(l=u(s))),i.open(c,f,!0),{xhr:i,ajaxData:l,contentType:a}}var vn,mn,gn=function(){return t(function t(){var r=this,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(e(this,t),J.add(this),W.set(this,void 0),Z.set(this,void 0),K.set(this,void 0),$.set(this,void 0),Q.set(this,void 0),ee.set(this,[]),te.set(this,[]),ne.set(this,{}),ie.set(this,void 0),re.set(this,void 0),se.set(this,new MediaStream),oe.set(this,JSON.parse(u(L))),ae.set(this,0),ce.set(this,void 0),ue.set(this,void 0),fe.set(this,void 0),f(this,"token",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),le.set(this,void 0),he.set(this,48e4),de.set(this,12e6),pe.set(this,{}),ve.set(this,void 0),me.set(this,void 0),ge.set(this,void 0),we.set(this,function(e){}),be.set(this,function(e){}),ke.set(this,function(e){}),xe.set(this,function(e){}),ye.set(this,function(e){return C(r,void 0,void 0,c.mark(function t(){var n,i,r;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!O(this,ce,"f")||!O(this,ue,"f")){t.next=2;break}if(!(l()-O(this,ue,"f")>e)){t.next=2;break}return t.next=1,O(this,Ae,"f").call(this);case 1:n=t.sent,i=n.sign,r=n.timestamp,E(this,ce,null!=i?i:O(this,ce,"f"),"f"),E(this,ue,null!=r?r:O(this,ue,"f"),"f");case 2:case"end":return t.stop()}},t,this)}))}),Se.set(this,function(e){return C(r,void 0,void 0,c.mark(function t(){var n,i,r,s,o;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!O(this,le,"f")){t.next=4;break}if(!(l()-O(this,le,"f")>e)){t.next=4;break}if(!O(this,fe,"f")){t.next=2;break}return t.next=1,O(this,Ie,"f").call(this);case 1:n=t.sent,i=n.token,r=n.tokenTimestamp,E(this,fe,null!=i?i:O(this,fe,"f"),"f"),E(this,le,null!=r?r:l(),"f"),t.next=4;break;case 2:if(!this.token){t.next=4;break}return t.next=3,this.getGatewayAccessToken({corpId:O(this,Je,"f"),sid:O(this,Ke,"f"),secret:O(this,We,"f"),seatOnline:!1});case 3:s=t.sent,o=s.token,this.token=o,E(this,le,l(),"f");case 4:case"end":return t.stop()}},t,this)}))}),Ae.set(this,function(){}),Ie.set(this,function(){}),Te.set(this,function(e){}),je.set(this,function(e){}),Ce.set(this,void 0),Oe.set(this,void 0),f(this,"networkSpeed",{enumerable:!0,configurable:!0,writable:!0,value:"0.00Mb/s"}),f(this,"networkDelay",{enumerable:!0,configurable:!0,writable:!0,value:"0ms"}),f(this,"onLine",{enumerable:!0,configurable:!0,writable:!0,value:navigator.onLine}),f(this,"testspeeding",{enumerable:!0,configurable:!0,writable:!0,value:!1}),f(this,"goodNetworkSpeed",{enumerable:!0,configurable:!0,writable:!0,value:function(){return 1e3*Number(r.networkSpeed.replace("Mb/s",""))>=30}}),f(this,"goodNetworkDelay",{enumerable:!0,configurable:!0,writable:!0,value:function(){return Number(r.networkDelay.replace("ms",""))<=500&&"0ms"!==r.networkDelay}}),f(this,"authorizedMicrophonePermissions",{enumerable:!0,configurable:!0,writable:!0,value:!1}),f(this,"authorizedNotificationPermissions",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Ee.set(this,100),De.set(this,3),Re.set(this,8),Ne.set(this,3),qe.set(this,0),Pe.set(this,!1),He.set(this,void 0),Me.set(this,3),Ue.set(this,3),ze.set(this,0),Le.set(this,0),Xe.set(this,0),Fe.set(this,!1),Ge.set(this,!1),_e.set(this,!1),Be.set(this,void 0),Ye.set(this,void 0),Ve.set(this,void 0),Je.set(this,void 0),We.set(this,void 0),Ze.set(this,void 0),Ke.set(this,void 0),$e.set(this,void 0),Qe.set(this,void 0),et.set(this,void 0),tt.set(this,void 0),nt.set(this,function(e){O(r,J,"m",sn).call(r)}),it.set(this,function(){}),rt.set(this,void 0),st.set(this,void 0),ot.set(this,!1),at.set(this,4e3),ct.set(this,4e3),ut.set(this,{}),ft.set(this,!1),lt.set(this,!0),f(this,"ifAutoAnswer",{enumerable:!0,configurable:!0,writable:!0,value:function(){return String(O(r,ut,"f").autoAnswer)===N.YES}}),f(this,"notNeedSendStarDtmf",{enumerable:!0,configurable:!0,writable:!0,value:function(){return String(O(r,ut,"f").afterTransferLabour)===H.DIRECT_ANSWER}}),ht.set(this,function(){if(O(r,lt,"f")){var e;O(r,dt,"f").call(r);var t=new(window.AudioContext||window.webkitAudioContext);E(r,me,t.createScriptProcessor(2048,1,1),"f"),O(r,me,"f").onaudioprocess=function(e){for(var t=e.inputBuffer.getChannelData(0),n=0,i=0;i<t.length;++i)n+=t[i]*t[i];E(r,ae,Number(Math.sqrt(n/t.length).toFixed(2)),"f"),O(r,we,"f").call(r,O(r,ae,"f"))},E(r,ge,new MediaStream,"f"),h(e=r.getSenders()).call(e,function(e){e.track&&O(r,ge,"f").addTrack(e.track)}),E(r,ve,t.createMediaStreamSource(O(r,ge,"f")),"f"),O(r,ve,"f").connect(O(r,me,"f")),O(r,me,"f").connect(t.destination)}}),dt.set(this,function(){if(O(r,lt,"f")){if(O(r,ve,"f"))try{O(r,ve,"f").disconnect()}catch(e){console.log(e)}if(O(r,me,"f"))try{O(r,me,"f").disconnect()}catch(e){console.log(e)}if(O(r,ge,"f"))try{var e;h(e=O(r,ge,"f").getTracks()).call(e,function(e){e.stop()})}catch(e){console.log(e)}}E(r,ve,void 0,"f"),E(r,me,void 0,"f"),E(r,ge,void 0,"f"),E(r,ae,0,"f"),O(r,we,"f").call(r,O(r,ae,"f"))}),f(this,"disposeSoftphoneEnvRequirementCheck",{enumerable:!0,configurable:!0,writable:!0,value:function(){O(r,pt,"f").call(r),window.removeEventListener("offline",O(r,gt,"f")),window.removeEventListener("online",O(r,mt,"f")),window.removeEventListener("unload",r.disposeSoftphoneEnvRequirementCheck)}}),pt.set(this,function(){clearInterval(O(r,Ce,"f")),E(r,Ce,void 0,"f"),clearTimeout(O(r,Oe,"f")),E(r,Oe,void 0,"f"),r.testspeeding=!1}),f(this,"softphoneEnvCheck",{enumerable:!0,configurable:!0,writable:!0,value:function(){return C(r,void 0,void 0,c.mark(function e(){return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this.testspeeding||(O(this,vt,"f").call(this),this.oneRoundOfTesting());case 1:case"end":return e.stop()}},e,this)}))}}),vt.set(this,function(){window.addEventListener("offline",O(r,gt,"f")),window.addEventListener("online",O(r,mt,"f")),window.addEventListener("unload",r.disposeSoftphoneEnvRequirementCheck)}),f(this,"oneRoundOfTesting",{enumerable:!0,configurable:!0,writable:!0,value:function(){return C(r,void 0,void 0,c.mark(function e(){var t=this;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this.testspeeding=!0,this.detectNavigatorPermissions(),this.onLine?(O(this,wt,"f").call(this,this),E(this,Oe,d(function(){t.testspeeding=!1,t.disposeSoftphoneEnvRequirementCheck()},4e3),"f")):this.testspeeding=!1;case 1:case"end":return e.stop()}},e,this)}))}}),mt.set(this,function(){r.onLine=!0,r.oneRoundOfTesting()}),gt.set(this,function(){r.onLine=!1,r.networkSpeed="0.00Mb/s",r.networkDelay="0ms",O(r,je,"f").call(r,{networkSpeed:r.networkSpeed,networkDelay:r.networkDelay,authorizedMicrophonePermissions:r.authorizedMicrophonePermissions,authorizedNotificationPermissions:r.authorizedNotificationPermissions}),O(r,pt,"f").call(r)}),wt.set(this,function(e){return C(r,void 0,void 0,c.mark(function t(){var n,i,r=this;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=e||this,clearInterval(O(n,Ce,"f")),E(n,Ce,void 0,"f"),i=function(){return C(r,void 0,void 0,c.mark(function e(){var t;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!n.onLine){e.next=5;break}return e.prev=1,e.next=2,O(n,bt,"f").call(n);case 2:t=e.sent,n.networkSpeed=t.networkSpeed,n.networkDelay=t.networkDelay,e.next=4;break;case 3:e.prev=3,e.catch(1),n.networkSpeed="0.00Mb/s",n.networkDelay="0ms";case 4:e.next=6;break;case 5:n.networkSpeed="0.00Mb/s",n.networkDelay="0ms";case 6:O(this,je,"f").call(this,{networkSpeed:this.networkSpeed,networkDelay:this.networkDelay,authorizedMicrophonePermissions:this.authorizedMicrophonePermissions,authorizedNotificationPermissions:this.authorizedNotificationPermissions}),O(this,Oe,"f")||(this.testspeeding=!1,this.disposeSoftphoneEnvRequirementCheck());case 7:case"end":return e.stop()}},e,this,[[1,3]])}))},t.next=1,i();case 1:O(this,Oe,"f")&&E(n,Ce,p(function(){return C(this,void 0,void 0,c.mark(function e(){return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,i();case 1:case"end":return e.stop()}},e)}))},1e3),"f");case 2:case"end":return t.stop()}},t,this)}))}),bt.set(this,function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"https://seat.94ai.com/favicon.png",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:63491,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return C(r,void 0,void 0,c.mark(function i(){var r,s;return c.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:for(r=[],s=0;s<n;s++)r.push(O(this,kt,"f").call(this,e+"?d="+l()+s,t));return i.abrupt("return",v.all(r).then(function(e){var t=0,i=0;return h(e).call(e,function(e){t+=Number(e[0]),i+=Number(e[1])}),{networkDelay:(i/n).toFixed(2)+"ms",networkSpeed:(t/n).toFixed(2)+"Mb/s"}}));case 1:case"end":return i.stop()}},i,this)}))}),kt.set(this,function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"https://seat.94ai.com/favicon.png?d="+l(),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:63491;return new v(function(n,i){var r=document.createElement("img");r.start=window.performance.now(),r.onload=function(){var e=window.performance.now()-r.start;n([(1e3*t/(1048576*e)).toFixed(2),e])},r.onerror=function(e){i(e)},r.src=e}).catch(function(e){throw e})}),f(this,"openApiAjax",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return new v(function(t,n){return C(r,void 0,void 0,c.mark(function i(){var r,s,o,a,u,f,l;return c.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return r=pn(t,n,e),s=r.xhr,o=r.ajaxData,a=r.contentType,i.next=1,this.getOpenApiSign();case 1:return u=i.sent,f=u.timestamp,l=u.sign,s.setRequestHeader("appKey",O(this,Je,"f")),s.setRequestHeader("timestamp",String(f)),s.setRequestHeader("sign",l),s.setRequestHeader("Content-type",a||"application/json"),i.next=2,O(this,ke,"f").call(this,s);case 2:s.send(o);case 3:case"end":return i.stop()}},i,this)}))})}}),f(this,"requestGateway",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return r.gatewayApiAjax(m(m({},e),{url:r.getGateway()+e.url}),t)}}),f(this,"gatewayApiAjax",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return new v(function(n,i){return C(r,void 0,void 0,c.mark(function r(){var s,o,a,u,f;return c.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(s=pn(n,i,e),o=s.xhr,a=s.ajaxData,u=s.contentType,!t){r.next=2;break}return r.next=1,this.getGatewayToken();case 1:f=r.sent,o.setRequestHeader("x-token",f),o.setRequestHeader("seatsToken",f),o.setRequestHeader("x-authority-token",f);case 2:return o.setRequestHeader("x-app-code",3),o.setRequestHeader("content-type",u||"application/json"),r.next=3,O(this,xe,"f").call(this,o);case 3:o.send(a);case 4:case"end":return r.stop()}},r,this)}))})}}),f(this,"requestOpenApi",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return r.openApiAjax(m(m({},e),{url:r.getOpenApi()+e.url}))}}),f(this,"getDeviceId",{enumerable:!0,configurable:!0,writable:!0,value:function(){return C(r,void 0,void 0,c.mark(function e(){var t,n;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!O(this,tt,"f")){e.next=1;break}return e.abrupt("return",O(this,tt,"f"));case 1:return e.next=2,j.load();case 2:return t=e.sent,e.next=3,t.get();case 3:return n=e.sent,E(this,tt,n.visitorId,"f"),e.abrupt("return",O(this,tt,"f"));case 4:case"end":return e.stop()}},e,this)}))}}),Ct.set(this,function(){return C(r,void 0,void 0,c.mark(function e(){var t,i,r,s;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!O(this,J,"m",jt).call(this)||O(this,ne,"f").authorizationUsername&&O(this,ne,"f").uri&&O(this,ne,"f").authorizationPassword&&O(this,ne,"f").transportOptions.server){e.next=3;break}return e.next=1,this.getAgentInfo();case 1:if(200!=(t=e.sent).code){e.next=2;break}s=t.data,O(this,ne,"f").authorizationUsername=s.agentExtension,O(this,ne,"f").authorizationPassword=s.extensionPwd,O(this,ne,"f").contactName||(O(this,ne,"f").contactName=s.agentExtension),O(this,ne,"f").uri=n.makeURI(g(i="sip:".concat(s.agentExtension,"@")).call(i,s.wsRegisterAddress)),O(this,ne,"f").transportOptions.server=g(r="".concat(s.wsProtocol,"://")).call(r,s.wsRegisterAddress),E(this,Ke,s.agentId,"f"),E(this,Ze,s.agentTag,"f"),e.next=3;break;case 2:throw new Error(u(t));case 3:case"end":return e.stop()}},e,this)}))}),Ot.set(this,function(){return C(r,void 0,void 0,c.mark(function e(){var t;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(O(this,ne,"f").viaHost){e.next=2;break}return t="",e.next=1,this.getDeviceId();case 1:O(this,ne,"f").viaHost=g(t).call(t,e.sent,".sip");case 2:case"end":return e.stop()}},e,this)}))}),Dt.set(this,function(e){var t,n,i,s,o,a,c,u,f,l,h,d,p,v,m,g,b,k,x,y,S,A,I;O(r,ut,"f").popWindow=null===(o=e["X-Popwindow"])||void 0===o?void 0:o[0].raw,O(r,ut,"f").afterTransferLabour=null===(a=e["X-Aftertransferlabour"])||void 0===a?void 0:a[0].raw,O(r,ut,"f").callId=null===(c=e["X-94callid"])||void 0===c?void 0:c[0].raw,O(r,ut,"f").cid=null===(u=e["X-Cid"])||void 0===u?void 0:u[0].raw,O(r,ut,"f").numberId=null===(f=e["X-Numberid"])||void 0===f?void 0:f[0].raw,O(r,ut,"f").tag=(null===(l=e["X-Tag"])||void 0===l?void 0:l[0].raw)&&"null"!==(null===(h=e["X-Tag"])||void 0===h?void 0:h[0].raw)?w(t=e["X-Tag"][0].raw.split("-")).call(t,function(e){return String.fromCharCode(e)}).join(""):"",O(r,ut,"f").numberTag=(null===(d=e["X-Numbertag"])||void 0===d?void 0:d[0].raw)&&"null"!==(null===(p=e["X-Numbertag"])||void 0===p?void 0:p[0].raw)?decodeURIComponent(e["X-Numbertag"][0].raw):"",O(r,ut,"f").taskId=null===(v=e["X-Taskid"])||void 0===v?void 0:v[0].raw,O(r,ut,"f").voiceType=null===(m=e["X-Voicetype"])||void 0===m?void 0:m[0].raw,O(r,ut,"f").processTime=null===(g=e["X-Processtime"])||void 0===g?void 0:g[0].raw,O(r,ut,"f").userPhone=null===(b=e["X-Userphone"])||void 0===b?void 0:b[0].raw,O(r,ut,"f").autoAnswer=null===(k=e["X-94autoanswer"])||void 0===k?void 0:k[0].raw,O(r,ut,"f").nodeTitle=null===(x=e["X-Nodetitle"])||void 0===x?void 0:w(n=x[0].raw.split("-")).call(n,function(e){return String.fromCharCode(e)}).join(""),O(r,ut,"f").taskName=null===(y=e["X-Taskname"])||void 0===y?void 0:w(i=y[0].raw.split("-")).call(i,function(e){return String.fromCharCode(e)}).join(""),O(r,ut,"f").templateTitle=null===(S=e["X-Templatetitle"])||void 0===S?void 0:w(s=S[0].raw.split("-")).call(s,function(e){return String.fromCharCode(e)}).join(""),O(r,ut,"f").phoneNumber=(null===(A=e["X-Phonenumber"])||void 0===A?void 0:A[0].raw)||(null===(I=e.From)||void 0===I?void 0:I[0].parsed.uri.normal.user)}),Bt.set(this,function(e){switch(e){case i.Initial:case i.Establishing:break;case i.Established:O(r,J,"m",_t).call(r);break;case i.Terminating:case i.Terminated:var t=d(function(){clearTimeout(t),t=void 0,O(r,oe,"f").incomingStatus=!1,O(r,oe,"f").answerStatus=!1},10);O(r,dt,"f").call(r);break;default:throw new Error("Unknown session state.")}}),Vt.set(this,function(e,t,n){O(r,Re,"f")&&(E(r,Pe,!1,"f"),O(r,oe,"f").reconnectStatus=!1,O(r,Ge,"f")&&(E(r,Ge,!1,"f"),O(r,Zt,"f").call(r,e,t,n)))}),Jt.set(this,function(){return C(r,void 0,void 0,c.mark(function e(){return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!O(this,Re,"f")){e.next=6;break}return E(this,Pe,!0,"f"),E(this,Ge,!1,"f"),e.next=1,this.getUserAgent().transport.disconnect().catch(function(e){return console.error(e)});case 1:return console.log("sip transport disconnect"),e.prev=2,e.next=3,O(this,J,"m",Yt).call(this);case 3:e.next=5;break;case 4:e.prev=4,e.catch(2);case 5:O(this,Kt,"f").call(this),O(this,J,"m",sn).call(this);case 6:case"end":return e.stop()}},e,this,[[2,4]])}))}),Wt.set(this,function(){if(O(r,Re,"f")){var e=O(r,ne,"f").uri.clone(),t=O(r,ne,"f").uri.clone(),n=O(r,ne,"f").uri.clone();n.user=void 0,O(r,Zt,"f").call(r,n,e,t)}}),Zt.set(this,function(e,t,n){if(O(r,Re,"f")){if(O(r,Ge,"f"))return;E(r,Ge,!0,"f"),E(r,Ye,d(function(){O(r,J,"m",nn).call(r);var i=r.getUserAgent().userAgentCore,s=i.makeOutgoingRequestMessage("OPTIONS",e,t,n,{});E(r,He,i.request(s,{onAccept:function(){console.log("sip ping ok"),E(r,qe,0,"f"),E(r,He,void 0,"f"),O(r,Vt,"f").call(r,e,t,n)},onReject:function(i){var s;if(E(r,He,void 0,"f"),408===i.message.statusCode||503===i.message.statusCode)if(console.log("sip ping error with code "+i.message.statusCode),O(r,Ne,"f")>0&&O(r,qe,"f")>=O(r,Ne,"f"))console.log("sip maximum ping attempts reached"),O(r,Jt,"f").call(r);else{var o,a;if(O(r,qe,"f")>0)console.log(g(a="sip ping retry ".concat(O(r,qe,"f")," of ")).call(a,O(r,Ne,"f")," fail"));E(r,qe,(s=O(r,qe,"f"),++s),"f"),console.log(g(o="sip ping retry ".concat(O(r,qe,"f")," of ")).call(o,O(r,Ne,"f"))),O(r,Vt,"f").call(r,e,t,n)}else E(r,qe,0,"f"),O(r,Vt,"f").call(r,e,t,n)}}),"f")},1e3*O(r,Re,"f")),"f")}}),Kt.set(this,function(){if(O(r,Re,"f")){if(E(r,Ge,!1,"f"),E(r,Pe,!1,"f"),O(r,He,"f")){try{O(r,He,"f").dispose()}catch(e){}E(r,He,void 0,"f")}O(r,Ye,"f")&&O(r,J,"m",nn).call(r)}}),rn.set(this,function(){if(O(r,Me,"f")){if(O(r,_e,"f"))return;E(r,_e,!0,"f"),O(r,oe,"f").reconnectStatus=!0,E(r,Ve,d(function(){return C(r,void 0,void 0,c.mark(function e(){var t,n=this;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,O(this,J,"m",en).call(this),0===O(this,ze,"f")&&console.log("sip reconnect success then register start"),e.next=1,O(this,K,"f").register({requestDelegate:{onAccept:function(e){console.log("sip reconnect success and register ok"),E(n,ze,0,"f"),E(n,_e,!1,"f"),O(n,oe,"f").registerStatus=!0,O(n,oe,"f").reconnectStatus=!1,O(n,Wt,"f").call(n)},onReject:function(e){return C(n,void 0,void 0,c.mark(function t(){var n,i;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(console.log("sip reconnect success but register fail with code "+e.message.statusCode),E(this,_e,!1,"f"),!(O(this,Ue,"f")<=O(this,ze,"f"))){t.next=2;break}return console.log("sip maximum register attempts reached"),E(this,ze,0,"f"),t.next=1,this.getUserAgent().transport.disconnect().catch(function(e){return console.error(e)});case 1:O(this,J,"m",sn).call(this),t.next=3;break;case 2:E(this,ze,(n=O(this,ze,"f"),++n),"f"),console.log(g(i="sip reconnect success and register retry ".concat(O(this,ze,"f")," of ")).call(i,O(this,Ue,"f"))),O(this,rn,"f").call(this);case 3:case"end":return t.stop()}},t,this)}))}},requestOptions:{extraHeaders:O(this,W,"f")}});case 1:e.next=3;break;case 2:e.prev=2,t=e.catch(0),console.log("sip reconnect then registerer register error",t),E(this,ze,0,"f"),E(this,_e,!1,"f");case 3:case"end":return e.stop()}},e,this,[[0,2]])}))},1e3*O(r,Me,"f")),"f")}}),"object"!==a(s))throw new Error("userAgentOption must be plain object");O(this,J,"m",At).call(this,s),O(this,J,"m",It).call(this,s),O(this,J,"m",St).call(this,s),O(this,J,"m",Tt).call(this,s),O(this,J,"m",Nt).call(this,s),O(this,J,"m",yt).call(this,s),O(this,J,"m",xt).call(this,s),E(this,ne,O(this,J,"m",Pt).call(this,s),"f")},[{key:"volumeValue",get:function(){return O(this,ae,"f")}},{key:"businessAttribute",get:function(){return O(this,ut,"f")}},{key:"getFastOutboundCall",value:function(){return O(this,ut,"f").voiceType===P.LABOUR}},{key:"getSitOutboundCall",value:function(){return O(this,ut,"f").voiceType===P.AI}},{key:"detectNavigatorPermissions",value:function(){var e,t=this;-1===b(e=navigator.userAgent).call(e,"Firefox")?navigator.permissions.query({name:"microphone"}).then(function(e){"granted"===e.state?t.authorizedMicrophonePermissions=!0:t.authorizedMicrophonePermissions=!1}).catch(function(e){console.log("Got error :",e),t.authorizedMicrophonePermissions=!1}):navigator.mediaDevices.enumerateDevices().then(function(e){""!==k(e).call(e,function(e){return"audioinput"===e.kind})[0].label?t.authorizedMicrophonePermissions=!0:t.authorizedMicrophonePermissions=!1}),navigator.permissions.query({name:"notifications"}).then(function(e){"granted"===e.state?t.authorizedNotificationPermissions=!0:t.authorizedNotificationPermissions=!1}).catch(function(e){console.log("Got error :",e),t.authorizedNotificationPermissions=!1})}},{key:"getGateway",value:function(){return"1"===O(this,et,"f")?"https://gateway.teleai.com":"https://gateway.94ai.com"}},{key:"getGatewayToken",value:function(){return C(this,void 0,void 0,c.mark(function e(){var t,n;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,O(this,Se,"f").call(this,O(this,de,"f"));case 1:if(!O(this,fe,"f")){e.next=2;break}return e.abrupt("return",O(this,fe,"f"));case 2:if(this.token){e.next=5;break}return e.next=3,O(this,Ct,"f").call(this);case 3:return e.next=4,this.getGatewayAccessToken({corpId:O(this,Je,"f"),sid:O(this,Ke,"f"),secret:O(this,We,"f"),seatOnline:!1});case 4:t=e.sent,n=t.token,this.token=n,E(this,le,l(),"f");case 5:return e.abrupt("return",this.token);case 6:case"end":return e.stop()}},e,this)}))}},{key:"getGatewayAccessToken",value:function(e){return this.requestGateway({url:"/authority/accessToken/openApi",data:e},!1)}},{key:"getCallNumberDetail",value:function(e){return this.requestGateway({url:"/task-aggre/callCenterNumber/get",data:e})}},{key:"getCallNumberChats",value:function(e){return this.requestGateway({url:"/dialogue-aggre/call-center-number/chat/list",data:e})}},{key:"getCallInfo",value:function(){return C(this,void 0,void 0,c.mark(function e(){var t,n,i,r=this;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t=m({},O(this,ut,"f")),n=function(){return C(r,void 0,void 0,c.mark(function e(){var n,i,r,s,o,a,u,f,l,h,d,p,v,m,b,k,x,y,S,A;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.numberId||!t.taskId){e.next=13;break}return n={},e.prev=1,e.next=2,this.getCallNumberDetail({id:t.numberId,taskId:t.taskId});case 2:if(200===(n=e.sent).code){e.next=3;break}return console.error(n.message),t.stop=!0,O(this,Te,"f").call(this,new Error(n.message)),e.abrupt("return");case 3:e.next=5;break;case 4:return e.prev=4,e.catch(1),s=g(i=g(r="当前会话callid:".concat(t.callId,",根据numberId:")).call(r,t.numberId,",taskId:")).call(i,t.taskId,":查询坐席接听状态异常"),console.error(s),t.stop=!0,O(this,Te,"f").call(this,new Error(n.message)),e.abrupt("return");case 5:if(o=n.data,a=o.callType,u=o.newIntentTag,f=o.intentTag,l=o.number,h=o.numberMd5,d=o.sid,p=o.config,v=o.tag,10!==o.state){e.next=6;break}return console.log("当前会话callid:".concat(t.callId,"已结束")),t.stop=!0,e.abrupt("return");case 6:if(t.callType||(t.callType=a),t.intentTag=u||f,t.number||(t.number=l),t.numberMD5||(t.numberMD5=h),t.agentId||(t.agentId=d),t.tag||(t.tag=v),t.templateId||p&&"string"==typeof p&&(m=JSON.parse(p))&&m.templateId&&(t.templateId=m.templateId),!t.callId){e.next=12;break}return k={},e.prev=7,e.next=8,this.getCallNumberChats({callId:t.callId,taskId:t.taskId});case 8:if(200===(k=e.sent).code){e.next=9;break}return console.error(k.message),t.stop=!0,O(this,Te,"f").call(this,new Error(k.message)),e.abrupt("return");case 9:e.next=11;break;case 10:return e.prev=10,e.catch(7),y=g(x="当前会话根据callId:".concat(t.callId,",taskId:")).call(x,t.taskId,":查询会话对话记录异常"),console.error(y),t.stop=!0,O(this,Te,"f").call(this,new Error(y)),e.abrupt("return");case 11:t.chats=w(b=k.data).call(b,function(e){return e.matchinfo&&(e.matchinfo=JSON.parse(e.matchinfo)),e}),O(this,pe,"f")[t.callId]=t;case 12:try{O(this,be,"f").call(this,O(this,pe,"f")[t.callId])}catch(e){console.log(e)}e.next=14;break;case 13:t.stop=!0,t.taskId||(S="当前会话callid:".concat(t.callId,"的taskId不存在,无法查询通话记录"),console.error(S),O(this,Te,"f").call(this,new Error(S))),t.numberId||(A="当前会话callid:".concat(t.callId,"的numberId不存在,无法查询通话记录"),console.error(A),O(this,Te,"f").call(this,new Error(A)));case 14:case"end":return e.stop()}},e,this,[[1,4],[7,10]])}))},e.prev=1;case 2:if(!t.stop){e.next=3;break}return e.abrupt("continue",7);case 3:return e.next=4,n();case 4:if(!t.stop){e.next=5;break}return e.abrupt("continue",7);case 5:return e.next=6,new v(function(e){var t=d(function(){return C(r,void 0,void 0,c.mark(function n(){return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:clearTimeout(t),t=void 0,e(!0);case 1:case"end":return n.stop()}},n)}))},3e3)});case 6:e.next=2;break;case 7:e.next=9;break;case 8:e.prev=8,i=e.catch(1),O(this,Te,"f").call(this,i);case 9:case"end":return e.stop()}},e,this,[[1,8]])}))}},{key:"refreshCallChatInfo",value:function(){return C(this,void 0,void 0,c.mark(function e(){return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(O(this,ut,"f").numberId&&O(this,ut,"f").callId&&O(this,ut,"f").taskId&&O(this,ft,"f"))){e.next=1;break}return e.next=1,this.getCallInfo();case 1:case"end":return e.stop()}},e,this)}))}},{key:"getOpenApi",value:function(){return O(this,$e,"f")?function(e){if(!e)return!1;var t=/^[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z]{2,}$/;return!!/^(\d{1,3}\.){3}\d{1,3}$/.test(e)||("//"===I(e).call(e,0,2)?t.test(I(e).call(e,2,e.length)):"http://"===I(e).call(e,0,7)?t.test(I(e).call(e,7,e.length)):"https://"===I(e).call(e,0,8)?t.test(I(e).call(e,8,e.length)):t.test(e))}(O(this,$e,"f"))?O(this,$e,"f"):"1"===O(this,et,"f")?"1"===O(this,Qe,"f")?"https://seat.teleai.com/sgopenapi":"https://seat.teleai.com/openapi":"1"===O(this,Qe,"f")?"https://seat.94ai.com/sgopenapi":"https://seat.94ai.com/openapi":"https://seat.94ai.com/openapi"}},{key:"getAgentInfo",value:function(){return this.requestOpenApi({url:"/v1/agent/getAgent",data:{agentTag:O(this,Ze,"f"),agentId:O(this,Ke,"f")}})}},{key:"getOpenApiSign",value:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:l(),i=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0;return C(this,void 0,void 0,c.mark(function s(){return c.wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=1,O(this,ye,"f").call(this,O(this,he,"f"));case 1:return s.abrupt("return",{sign:null!==(e=O(this,ce,"f"))&&void 0!==e?e:T.enc.Base64.stringify(T.HmacSHA1(i||O(this,Je,"f")+n,r||O(this,We,"f"))),timestamp:null!==(t=O(this,ue,"f"))&&void 0!==t?t:n});case 2:case"end":return s.stop()}},s,this)}))}},{key:"updateOpenApiAgentStatus",value:function(e){return this.requestOpenApi({url:"/v1/agent/updateAgentStatus",data:{agentTag:O(this,Ze,"f"),agentId:O(this,Ke,"f"),agentStatus:e}})}},{key:"importOpenApiAgentCustomer",value:function(e){return this.requestOpenApi({url:"/v1/task/importAgentCustomer",data:{agentTag:O(this,Ze,"f"),agentId:O(this,Ke,"f"),callType:1001,customers:[{number:e}]}})}},{key:"callNumber",value:function(e){return this.importOpenApiAgentCustomer(e)}},{key:"toggleNap",value:function(e){return e?this.updateOpenApiAgentStatus(3):this.updateOpenApiAgentStatus(1)}},{key:"refreshSign",value:function(e){E(this,ce,e,"f")}},{key:"prepareUserAgent",value:function(e,t){var n;return C(this,void 0,void 0,c.mark(function i(){var r,s,o,a,u,f,l,h,d,p,v,g;return c.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return s=(r=e||{}).refresh,o=r.registererOptions,a=r.registererRegisterOptions,u=r.extraHeaders,f=r.authorizationUsername,l=r.authorizationPassword,h=r.uri,d=r.contactName,p=r.transportOptions,i.next=1,this.dispose();case 1:return O(this,ne,"f").uri=null!=h?h:O(this,ne,"f").uri,O(this,ne,"f").authorizationUsername=null!=f?f:O(this,ne,"f").authorizationUsername,O(this,ne,"f").authorizationPassword=null!=l?l:O(this,ne,"f").authorizationPassword,O(this,ne,"f").contactName=null!==(n=null!=d?d:f)&&void 0!==n?n:O(this,ne,"f").contactName,p&&(O(this,ne,"f").transportOptions=m(m({},O(this,ne,"f").transportOptions),p)),i.prev=2,O(this,J,"m",It).call(this,e),i.next=3,O(this,Ct,"f").call(this);case 3:return i.next=4,O(this,Ot,"f").call(this);case 4:return O(this,J,"m",Rt).call(this,{refresh:s}),i.next=5,O(this,J,"m",cn).call(this);case 5:return t&&O(this,J,"m",an).call(this,t),i.next=6,O(this,J,"m",un).call(this,{registererOptions:o,registererRegisterOptions:a,extraHeaders:u},O(this,ot,"f"));case 6:return v=i.sent,i.abrupt("return",v);case 7:return i.prev=7,g=i.catch(2),i.next=8,this.dispose();case 8:throw g;case 9:case"end":return i.stop()}},i,this,[[2,7]])}))}},{key:"dispose",value:function(){return C(this,void 0,void 0,c.mark(function e(){var t;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,O(this,J,"m",Et).call(this),e.next=1,O(this,J,"m",Mt).call(this);case 1:e.next=3;break;case 2:e.prev=2,t=e.catch(0),O(this,J,"m",zt).call(this),console.log("sip dispose with error",t);case 3:case"end":return e.stop()}},e,this,[[0,2]])}))}},{key:"ignoreInvite",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return C(this,void 0,void 0,c.mark(function t(){return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return O(this,oe,"f").incomingStatus=!1,t.next=1,this.getCurrentInvitation().reject(e);case 1:case"end":return t.stop()}},t,this)}))}},{key:"acceptInvite",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return C(this,void 0,void 0,c.mark(function t(){var n,i=this;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=1,new v(function(t,n){C(i,void 0,void 0,c.mark(function i(){var r,s,o;return c.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.prev=0,r=null==e?void 0:e.onAck,s=null==e?void 0:e.onAckTimeout,null==e||delete e.onAck,null==e||delete e.onAckTimeout,i.next=1,this.getCurrentInvitation().accept(m({sessionDescriptionHandlerOptions:{constraints:{audio:!0,video:!1}},onAck:function(e){t(e),null==r||r()},onAckTimeout:function(){null==s||s(),n(new Error("接听响应超时"))}},e||{}));case 1:i.next=3;break;case 2:i.prev=2,o=i.catch(0),n(o);case 3:case"end":return i.stop()}},i,this,[[0,2]])}))});case 1:O(this,oe,"f").incomingStatus&&(O(this,oe,"f").incomingStatus=!1,O(this,oe,"f").answerStatus=!0),t.next=3;break;case 2:throw t.prev=2,n=t.catch(0),O(this,oe,"f").incomingStatus=!1,n;case 3:case"end":return t.stop()}},t,this,[[0,2]])}))}},{key:"hangUpInvite",value:function(e){return C(this,void 0,void 0,c.mark(function t(){var n,r,s,o,a,u=this;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=(n=e||{}).rejectOptions,s=n.byeOptions,o=n.extraHeaders,a=n.scoutResponse,t.abrupt("return",new v(function(e,t){return C(u,void 0,void 0,c.mark(function n(){var u,f,l,h,d,p,v,g,w,b,k;return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:n.prev=0,v=null===(u=(p=s||{}).requestDelegate)||void 0===u?void 0:u.onAccept,g=null===(f=p.requestDelegate)||void 0===f?void 0:f.onReject,null===(l=p.requestDelegate)||void 0===l||delete l.onAccept,null===(h=p.requestDelegate)||void 0===h||delete h.onReject,w=O(this,J,"m",qt).call(this,{onAccept:function(t){console.log("sip bye success"),e(t),null==v||v(t)},onReject:function(e){null==g||g(e),t(new Error("sip bye fail with code "+e.message.statusCode))}},p.requestDelegate),delete p.requestDelegate,b=null===(d=O(this,ie,"f"))||void 0===d?void 0:d.state,n.next=b===i.Initial||b===i.Establishing?1:b===i.Established?3:b===i.Terminating||b===i.Terminated?5:6;break;case 1:return n.next=2,O(this,ie,"f").reject(m({extraHeaders:o},r||{}));case 2:return e(!0),n.abrupt("continue",6);case 3:return n.next=4,O(this,ie,"f").bye(m({requestDelegate:w,requestOptions:{extraHeaders:o}},p));case 4:return a||e(!0),n.abrupt("continue",6);case 5:return e(!0),n.abrupt("continue",6);case 6:n.next=8;break;case 7:n.prev=7,k=n.catch(0),t(k);case 8:return n.prev=8,O(this,oe,"f").incomingStatus=!1,O(this,oe,"f").answerStatus=!1,n.finish(8);case 9:case"end":return n.stop()}},n,this,[[0,7,8,9]])}))}));case 1:case"end":return t.stop()}},t)}))}},{key:"sendStarDtmf",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return C(this,void 0,void 0,c.mark(function t(){var n=this;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new v(function(t,i){return C(n,void 0,void 0,c.mark(function n(){var r,s,o,a,u;return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,s=(r=e||{}).extraHeaders,o=r.requestDelegate,a=O(this,J,"m",qt).call(this,{onAccept:function(e){console.log("sip send dtmf Signal=* success"),t(e)},onReject:function(e){i(new Error("sip send dtmf Signal=* fail with code "+e.message.statusCode))}},o),delete r.requestDelegate,n.next=1,this.getCurrentInvitation().info(m({requestOptions:{body:{contentDisposition:"render",contentType:"application/dtmf-relay",content:"Signal=*\r\nDuration=100"},extraHeaders:s},requestDelegate:a},r));case 1:O(this,ht,"f").call(this),n.next=3;break;case 2:n.prev=2,u=n.catch(0),i(u);case 3:case"end":return n.stop()}},n,this,[[0,2]])}))}));case 1:case"end":return t.stop()}},t)}))}},{key:"muteRemoteAudio",value:function(){var e;h(e=O(this,Q,"f").getReceivers()).call(e,function(e){e.track.enabled=!1})}},{key:"unMuteRemoteAudio",value:function(){var e;h(e=O(this,Q,"f").getReceivers()).call(e,function(e){e.track.enabled=!0})}},{key:"muteLocalAudio",value:function(){var e;h(e=O(this,Q,"f").getSenders()).call(e,function(e){e.track.enabled=!1})}},{key:"unMuteLocalAudio",value:function(){var e;h(e=O(this,Q,"f").getSenders()).call(e,function(e){e.track.enabled=!0})}},{key:"getUserAgentStatue",value:function(){return O(this,oe,"f")}},{key:"getUserAgent",value:function(){return O(this,Z,"f")||E(this,Z,new n(O(this,ne,"f")),"f"),O(this,Z,"f")}},{key:"getSessionDescriptionHandler",value:function(){return O(this,$,"f")}},{key:"getPeerConnection",value:function(){return O(this,Q,"f")}},{key:"getSenders",value:function(){return O(this,te,"f")}},{key:"getReceivers",value:function(){return O(this,ee,"f")}},{key:"getStream",value:function(){var e,t=this;return O(this,se,"f")||E(this,se,new MediaStream,"f"),h(e=O(this,ee,"f")).call(e,function(e){e.track&&O(t,se,"f").addTrack(e.track)}),O(this,se,"f")}},{key:"getCurrentInviter",value:function(){if(!O(this,re,"f"))throw new Error("No currentInviter...");return O(this,re,"f")}},{key:"getCurrentInvitation",value:function(){return O(this,ie,"f")}},{key:"invite",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return C(this,void 0,void 0,c.mark(function i(){var s,o,a;return c.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(o=n.makeURI(e.uri?e.uri:g(s="sip:".concat(e.extension,"@")).call(s,O(this,ne,"f").transportOptions.server.split("://")[1]))){i.next=1;break}throw new Error("Failed to create target URI.");case 1:return E(this,re,new r(this.getUserAgent(),o,{sessionDescriptionHandlerOptions:{constraints:{audio:!0,video:!1}}}),"f"),a=(t||{}).extraHeaders,i.next=2,this.getCurrentInviter().invite(m({requestOptions:{extraHeaders:a}},t));case 2:return i.abrupt("return",O(this,re,"f"));case 3:case"end":return i.stop()}},i,this)}))}}])}();W=new x,Z=new x,K=new x,$=new x,Q=new x,ee=new x,te=new x,ne=new x,ie=new x,re=new x,se=new x,oe=new x,ae=new x,ce=new x,ue=new x,fe=new x,le=new x,he=new x,de=new x,pe=new x,ve=new x,me=new x,ge=new x,we=new x,be=new x,ke=new x,xe=new x,ye=new x,Se=new x,Ae=new x,Ie=new x,Te=new x,je=new x,Ce=new x,Oe=new x,Ee=new x,De=new x,Re=new x,Ne=new x,qe=new x,Pe=new x,He=new x,Me=new x,Ue=new x,ze=new x,Le=new x,Xe=new x,Fe=new x,Ge=new x,_e=new x,Be=new x,Ye=new x,Ve=new x,Je=new x,We=new x,Ze=new x,Ke=new x,$e=new x,Qe=new x,et=new x,tt=new x,nt=new x,it=new x,rt=new x,st=new x,ot=new x,at=new x,ct=new x,ut=new x,ft=new x,lt=new x,ht=new x,dt=new x,pt=new x,vt=new x,mt=new x,gt=new x,wt=new x,bt=new x,kt=new x,Ct=new x,Ot=new x,Dt=new x,Bt=new x,Vt=new x,Jt=new x,Wt=new x,Zt=new x,Kt=new x,rn=new x,J=new y,xt=function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};E(this,ke,null!==(e=n.openXhrIntercept)&&void 0!==e?e:O(this,ke,"f"),"f"),E(this,xe,null!==(t=n.gatewayXhrIntercept)&&void 0!==t?t:O(this,xe,"f"),"f")},yt=function(){var e,t,n,i,r,s,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};E(this,ft,null!==(e=o.enableChatInfoPush)&&void 0!==e?e:O(this,ft,"f"),"f"),E(this,lt,null!==(t=o.enableVolumnTrack)&&void 0!==t?t:O(this,lt,"f"),"f"),E(this,we,null!==(n=o.refreshSpeekVolumn)&&void 0!==n?n:O(this,we,"f"),"f"),E(this,je,null!==(i=o.refreshRequirementCheck)&&void 0!==i?i:O(this,je,"f"),"f"),E(this,be,null!==(r=o.refreshChat)&&void 0!==r?r:O(this,be,"f"),"f"),E(this,Te,null!==(s=o.refreshChatErrorCallback)&&void 0!==s?s:O(this,Te,"f"),"f")},St=function(){var e,t,n,i,r,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};E(this,fe,null!==(e=s.token)&&void 0!==e?e:O(this,fe,"f"),"f"),E(this,le,null!==(t=s.tokenTimestamp)&&void 0!==t?t:O(this,le,"f"),"f"),E(this,de,null!==(n=s.tokenExpirationTime)&&void 0!==n?n:O(this,de,"f"),"f"),O(this,fe,"f")&&!O(this,le,"f")&&E(this,le,l(),"f"),E(this,Se,null!==(i=s.tokenCheck)&&void 0!==i?i:O(this,Se,"f"),"f"),E(this,Ie,null!==(r=s.tokenOverdued)&&void 0!==r?r:O(this,Ie,"f"),"f")},At=function(){var e,t,n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};E(this,ot,null!==(e=i.clusterMode)&&void 0!==e?e:O(this,ot,"f"),"f"),E(this,at,null!==(t=i.reClusterRegisterTimeout)&&void 0!==t?t:O(this,at,"f"),"f"),E(this,ct,null!==(n=i.reClusterConnectTimeout)&&void 0!==n?n:O(this,ct,"f"),"f")},It=function(){var e,t,n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.agentId,s=i.agentTag,o=i.appKey,a=i.appSecret,c=i.openBaseUrl,u=i.sg,f=i.sgOpen,l=i.sign,h=i.timestamp;E(this,Ke,null!=r?r:O(this,Ke,"f"),"f"),E(this,Ze,null!=s?s:O(this,Ze,"f"),"f"),E(this,Je,null!=o?o:O(this,Je,"f"),"f"),E(this,We,null!=a?a:O(this,We,"f"),"f"),E(this,$e,null!=c?c:O(this,$e,"f"),"f"),E(this,et,null!=u?u:O(this,et,"f"),"f"),E(this,Qe,null!=f?f:O(this,Qe,"f"),"f"),E(this,ce,null!=l?l:O(this,ce,"f"),"f"),E(this,ue,null!=h?h:O(this,ue,"f"),"f"),E(this,he,null!==(e=i.signExpirationTime)&&void 0!==e?e:O(this,he,"f"),"f"),E(this,ye,null!==(t=i.signCheck)&&void 0!==t?t:O(this,ye,"f"),"f"),E(this,Ae,null!==(n=i.signOverdued)&&void 0!==n?n:O(this,Ae,"f"),"f")},Tt=function(e){e.sipHeaders&&(E(this,W,e.sipHeaders,"f"),delete e.sipHeaders)},jt=function(){return!(!O(this,Ke,"f")&&!O(this,Ze,"f")||!(O(this,Je,"f")&&O(this,We,"f")||O(this,ce,"f")&&O(this,ue,"f")))},Et=function(){O(this,J,"m",Ut).call(this),O(this,J,"m",Ft).call(this),O(this,J,"m",Gt).call(this),O(this,J,"m",Xt).call(this),O(this,J,"m",Lt).call(this),O(this,J,"m",$t).call(this),O(this,J,"m",Qt).call(this),O(this,J,"m",zt).call(this),O(this,dt,"f").call(this),E(this,ut,{},"f"),E(this,pe,{},"f")},Rt=function(e){E(this,oe,o(JSON.parse(u(L)),"function"==typeof e.refresh?e.refresh:O(this,it,"f")),"f")},Nt=function(e){var t,n,i,r,s,o,a,c,u,f,l,h,d,p,v;E(this,Ee,null!==(i=null!==(t=e.reconnectionAttempts)&&void 0!==t?t:null===(n=null==e?void 0:e.transportOptions)||void 0===n?void 0:n.maxReconnectionAttempts)&&void 0!==i?i:O(this,Ee,"f"),"f"),E(this,De,null!==(a=null!==(s=null!==(r=e.reconnectionInterval)&&void 0!==r?r:e.reconnectionDelay)&&void 0!==s?s:null===(o=null==e?void 0:e.transportOptions)||void 0===o?void 0:o.reconnectionTimeout)&&void 0!==a?a:O(this,De,"f"),"f"),E(this,Le,null!==(u=null===(c=e.transportOptions)||void 0===c?void 0:c.keepAliveInterval)&&void 0!==u?u:O(this,Le,"f"),"f"),E(this,Xe,null!==(l=null===(f=e.transportOptions)||void 0===f?void 0:f.keepAliveDebounce)&&void 0!==l?l:O(this,Xe,"f"),"f"),E(this,Me,null!==(h=e.registerInterval)&&void 0!==h?h:O(this,Me,"f"),"f"),E(this,Re,null!==(d=e.optionsPingInterval)&&void 0!==d?d:O(this,Re,"f"),"f"),E(this,Ne,null!==(p=e.optionsPingAttempts)&&void 0!==p?p:O(this,Ne,"f"),"f"),E(this,Ue,null!==(v=e.registerAttempts)&&void 0!==v?v:O(this,Ue,"f"),"f")},qt=function(e,t){var n,i=this;return t?(h(n=S(t)).call(n,function(n){if(t[n]&&"function"==typeof t[n])if(e[n]){if("function"==typeof e[n]){var r=e[n];e[n]=function(e){return C(i,void 0,void 0,c.mark(function i(){return c.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=1,t[n](e);case 1:return i.next=2,r(e);case 2:case"end":return i.stop()}},i)}))}}}else e[n]=t[n]}),e):e},Pt=function(e){var t,n=this,i={delegate:{onConnect:function(){return C(n,void 0,void 0,c.mark(function e(){return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:console.log("sip connected"),O(this,Wt,"f").call(this);case 1:case"end":return e.stop()}},e,this)}))},onInvite:function(e){O(n,Dt,"f").call(n,e.incomingInviteRequest.message.headers),n.refreshCallChatInfo(),O(n,J,"m",Ht).call(n),E(n,ie,e,"f"),O(n,oe,"f").incomingStatus=!0,e.stateChange.addListener(O(n,Bt,"f"))},onDisconnect:function(e){return C(n,void 0,void 0,c.mark(function t(){var n;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("sip disconnected"),n=!1,O(this,Re,"f")>0&&(n=O(this,Pe,"f"),O(this,Kt,"f").call(this)),t.prev=1,t.next=2,O(this,J,"m",Yt).call(this);case 2:t.next=4;break;case 3:t.prev=3,t.catch(1);case 4:(e||n)&&O(this,J,"m",sn).call(this);case 5:case"end":return t.stop()}},t,this,[[1,3]])}))}}};e.delegate?h(t=S(e.delegate)).call(t,function(t){var r=t;if(e.delegate[r]&&"function"==typeof e.delegate[r]){var s=e.delegate[r];e.delegate[r]=function(e){return C(n,void 0,void 0,c.mark(function t(){var n,o;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return null===(o=(n=i.delegate)[r])||void 0===o||o.call(n,e),t.next=1,s(e);case 1:case"end":return t.stop()}},t)}))}}}):e.delegate=i.delegate;return e.reconnectionAttempts=0,e.transportOptions=m(m({},e.transportOptions||{}),{keepAliveInterval:O(this,Le,"f"),keepAliveDebounce:O(this,Xe,"f")}),void 0===e.sessionDescriptionHandlerFactoryOptions&&(e.sessionDescriptionHandlerFactoryOptions={iceGatheringTimeout:2e3,peerConnectionConfiguration:{iceServers:[]}}),m(m({},z),e)},Ht=function(){O(this,ie,"f")&&(O(this,ie,"f").dispose(),E(this,ie,void 0,"f"))},Mt=function(){return C(this,void 0,void 0,c.mark(function e(){return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!O(this,Z,"f")){e.next=2;break}return e.next=1,O(this,Z,"f").stop();case 1:E(this,Z,void 0,"f");case 2:case"end":return e.stop()}},e,this)}))},Ut=function(){var e;O(this,se,"f")&&(h(e=O(this,se,"f").getTracks()).call(e,function(e){e.stop()}),E(this,se,void 0,"f"))},zt=function(){var e,t=this;h(e=S(L)).call(e,function(e){var n=e;O(t,oe,"f")[n]=L[n]})},Lt=function(){O(this,$,"f")&&(O(this,$,"f").close(),E(this,$,void 0,"f"))},Xt=function(){O(this,Q,"f")&&(O(this,Q,"f").close(),E(this,Q,void 0,"f"))},Ft=function(){E(this,te,[],"f")},Gt=function(){E(this,ee,[],"f")},_t=function(){var e=this.getCurrentInvitation().sessionDescriptionHandler;O(this,J,"m",Xt).call(this),O(this,J,"m",Lt).call(this),O(this,J,"m",Ft).call(this),O(this,J,"m",Gt).call(this),E(this,$,e,"f"),E(this,Q,e.peerConnection,"f"),E(this,te,O(this,Q,"f").getSenders(),"f"),E(this,ee,O(this,Q,"f").getReceivers(),"f"),(this.getFastOutboundCall()||!this.getSitOutboundCall()&&this.notNeedSendStarDtmf())&&O(this,ht,"f").call(this)},Yt=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return C(this,void 0,void 0,c.mark(function t(){var n=this;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!O(this,K,"f")){t.next=1;break}return console.log("sip due to disconnection, unregistered"),t.abrupt("return",new v(function(t,i){return C(n,void 0,void 0,c.mark(function n(){var r,s,o;return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,r=e||{},s=O(this,J,"m",qt).call(this,{onAccept:function(e){console.log("sip unregister successed"),t(e)},onReject:function(e){i(new Error("sip unregister fail with code "+e.message.statusCode))}},r.requestDelegate),delete e.requestDelegate,n.next=1,O(this,K,"f").unregister(m({requestDelegate:s},e));case 1:n.next=3;break;case 2:n.prev=2,o=n.catch(0),i(o);case 3:case"end":return n.stop()}},n,this,[[0,2]])}))}));case 1:case"end":return t.stop()}},t,this)}))},$t=function(){O(this,J,"m",en).call(this),O(this,J,"m",tn).call(this),O(this,J,"m",nn).call(this),E(this,_e,!1,"f"),E(this,Fe,!1,"f"),E(this,Ge,!1,"f")},Qt=function(){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&(clearTimeout(O(this,rt,"f")),E(this,rt,void 0,"f")),e&&(clearTimeout(O(this,st,"f")),E(this,st,void 0,"f"))},en=function(){clearTimeout(O(this,Ve,"f")),E(this,Ve,void 0,"f")},tn=function(){clearTimeout(O(this,Be,"f")),E(this,Be,void 0,"f")},nn=function(){clearTimeout(O(this,Ye,"f")),E(this,Ye,void 0,"f")},sn=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return C(this,void 0,void 0,c.mark(function n(){var i=this;return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!O(this,De,"f")){n.next=4;break}if(O(this,oe,"f").reconnectStatus=!0,!O(this,Fe,"f")){n.next=1;break}return n.abrupt("return");case 1:if(!(t>O(this,Ee,"f"))){n.next=3;break}return console.log("sip maximum reconnection attempts reached"),n.next=2,this.dispose();case 2:return n.abrupt("return");case 3:console.log("sip reconnection attempt..."),E(this,Fe,!0,"f"),E(this,Be,d(function(){O(i,J,"m",tn).call(i),i.getUserAgent().reconnect().then(function(){return C(i,void 0,void 0,c.mark(function e(){var n;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:console.log(g(n="sip reconnection attempt ".concat(t," of ")).call(n,O(this,Ee,"f")," - succeeded")),E(this,Fe,!1,"f"),O(this,rn,"f").call(this);case 1:case"end":return e.stop()}},e,this)}))}).catch(function(n){var r;console.error(n),console.log(g(r="sip reconnection attempt ".concat(t," of ")).call(r,O(i,Ee,"f")," - failed")),E(i,Fe,!1,"f"),O(i,J,"m",e).call(i,++t)})},1===t?0:1e3*O(this,De,"f")),"f");case 4:case"end":return n.stop()}},n,this)}))},on=function(e){var t,n=this;return h(t=S(e)).call(t,function(t){var i=t;if("function"==typeof(null==e?void 0:e[i])){var r=e[i];e[i]=function(e){return C(n,void 0,void 0,c.mark(function t(){var n,s;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return null===(s=(n=O(this,ne,"f").delegate)[i])||void 0===s||s.call(n,e),t.next=1,r(e);case 1:case"end":return t.stop()}},t,this)}))}}}),e},an=function(e){var t=this.getUserAgent();return t.delegate=O(this,J,"m",on).call(this,e),t},cn=function(){return C(this,void 0,void 0,c.mark(function e(){var t;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.getUserAgent(),e.next=1,t.start();case 1:if(t.isConnected()){e.next=2;break}return e.next=2,t.reconnect();case 2:if(t.isConnected()){e.next=3;break}throw new Error("链接失败,请稍后再试");case 3:return O(this,oe,"f").connectStatus=!0,e.abrupt("return",t);case 4:case"end":return e.stop()}},e,this)}))},un=function e(t){var i=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=t||{},a=o.registererOptions,u=o.registererRegisterOptions,f=o.extraHeaders;return new v(function(t,o){return C(i,void 0,void 0,c.mark(function i(){var l,h,p,v,g,w=this;return c.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return l=this.getUserAgent(),E(this,K,new s(l,m({extraHeaders:f||O(this,W,"f")},a||{})),"f"),p=u||{},v=O(this,J,"m",qt).call(this,{onAccept:function(e){h=e,O(w,J,"m",Qt).call(w),O(w,oe,"f").registerStatus=!0,t(l)},onReject:function(e){O(w,J,"m",Qt).call(w),o(new Error("sip register fail with code "+e.message.statusCode))}},p.requestDelegate),delete p.requestDelegate,r&&E(this,rt,d(function(){return C(w,void 0,void 0,c.mark(function i(){var r,g=this;return c.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(h){i.next=4;break}E(this,st,d(function(){return C(g,void 0,void 0,c.mark(function i(){var r,s;return c.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(O(this,J,"m",Qt).call(this,!1,!0),h){i.next=6;break}i.prev=1;try{O(this,K,"f").dispose()}catch(e){}return O(this,J,"m",Et).call(this),O(this,Kt,"f").call(this),E(this,qe,0,"f"),E(this,ze,0,"f"),i.next=2,O(this,Z,"f").transport.dispose();case 2:return E(this,Z,new n(O(this,ne,"f")),"f"),i.next=3,O(this,J,"m",cn).call(this);case 3:return i.next=4,O(this,J,"m",e).call(this,{registererOptions:a,registererRegisterOptions:u,extraHeaders:f});case 4:r=i.sent,t(r),i.next=6;break;case 5:i.prev=5,s=i.catch(1),o(s);case 6:case"end":return i.stop()}},i,this,[[1,5]])}))},O(this,ct,"f")),"f");try{O(this,K,"f").dispose()}catch(e){}return E(this,K,new s(l,m({extraHeaders:f||O(this,W,"f")},a||{})),"f"),O(this,J,"m",Qt).call(this,!0,!1),i.prev=1,i.next=2,O(this,K,"f").register(m({requestDelegate:v,requestOptions:{extraHeaders:f||O(this,W,"f")}},p));case 2:i.next=4;break;case 3:i.prev=3,r=i.catch(1),O(this,J,"m",Qt).call(this),o(r);case 4:case"end":return i.stop()}},i,this,[[1,3]])}))},O(this,at,"f")),"f"),i.prev=1,i.next=2,O(this,K,"f").register(m({requestDelegate:v,requestOptions:{extraHeaders:f||O(this,W,"f")}},p));case 2:i.next=4;break;case 3:i.prev=3,g=i.catch(1),O(this,J,"m",Qt).call(this),o(g);case 4:case"end":return i.stop()}},i,this,[[1,3]])}))})};var wn=function(){return t(function t(){e(this,t)},null,[{key:"getUserAgentManager",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return O(this,vn,"f",mn)||E(this,vn,new gn(e),"f",mn),O(this,vn,"f",mn)}},{key:"hasUserAgentManager",value:function(){return!!O(this,vn,"f",mn)}},{key:"newUserAgentManager",value:function(){return new gn(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}},{key:"dispose",value:function(){if(O(this,vn,"f",mn))try{O(this,vn,"f",mn).dispose()}catch(e){}finally{E(this,vn,void 0,"f",mn)}}}])}();vn=wn,mn={value:void 0};export{wn as UserAgentFactory,gn as UserAgentManager,hn as accumulateSec,dn as accumulationTimer,V as cleanupMedia,G as getDevicePermission,X as getMedia,fn as getTimes,ln as getZeorTime,Y as pauseMedia,B as playMedia,_ as requestMicroPhonePermission,F as stopStreamTracks,z as userAgentDefault,L as userAgentStatus};
|