hs-cti.es5.umd.prod.js 82 KB

12345678910111213
  1. /*!
  2. - Name HS_CTI
  3. - FileName hs-cti
  4. - Version 1.0.9
  5. - JS Standard es5
  6. - Author platformfe
  7. - Built on 2024/11/27 10:37:38
  8. - GitHub
  9. - Branch main
  10. - CommitID 987d86cd91cde7d1c235ad106d79fc92c305b8ff
  11. - CommitMessage fix: 修改socket地址
  12. */
  13. !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("sip.js"),require("socket.io-client")):"function"==typeof define&&define.amd?define(["exports","sip.js","socket.io-client"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).HS_CTI={},e.SIP,e.io)}(this,(function(e,t,n){"use strict";var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)};function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var o=function(){return o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},o.apply(this,arguments)};function s(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s}function a(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}function c(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function l(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var u=function(){function e(n,r){void 0===r&&(r={});var i=this;Object.defineProperty(this,"delegate",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"managedSessions",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"userAgent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"optionsPingFailure",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"optionsPingRequest",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"optionsPingRunning",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"optionsPingTimeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"registrationAttemptTimeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"registerer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"registererOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"registererRegisterOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shouldBeConnected",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"shouldBeRegistered",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"attemptingReconnection",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this.delegate=r.delegate,this.options=o({aor:"",autoStop:!0,delegate:{},iceStopWaitingOnServerReflexive:!1,managedSessionFactory:this.managedSessionFactory,maxSimultaneousSessions:2,media:{},optionsPingInterval:-1,optionsPingRequestURI:"",reconnectionAttempts:3,reconnectionDelay:3,registrationRetry:!1,registrationRetryInterval:3,registerGuard:null,registererOptions:{},registererRegisterOptions:{},sendDTMFUsingSessionDescriptionHandler:!1,userAgentOptions:{}},e.stripUndefinedProperties(r));var s=o({},r.userAgentOptions);if(s.transportConstructor||(s.transportConstructor=t.Web.Transport),s.transportOptions||(s.transportOptions={server:n}),!s.uri&&r.aor){var l=t.UserAgent.makeURI(r.aor);if(!l)throw new Error("Failed to create valid URI from ".concat(r.aor));s.uri=l}if(this.userAgent=new t.UserAgent(s),this.userAgent.delegate={onConnect:function(){i.logger.log("Connected"),i.delegate&&i.delegate.onServerConnect&&i.delegate.onServerConnect(),i.shouldBeRegistered&&i.register(),i.options.optionsPingInterval>0&&i.optionsPingStart()},onDisconnect:function(e){return a(i,void 0,void 0,(function(){var t,n,r,i,o,s=this;return c(this,(function(l){return this.logger.log("Disconnected"),t=!1,this.options.optionsPingInterval>0&&(t=this.optionsPingFailure,this.optionsPingFailure=!1,this.optionsPingStop()),e||t?(this.registerer&&(this.logger.log("Disposing of registerer..."),this.registerer.dispose().catch((function(e){s.logger.debug("Error occurred disposing of registerer after connection with server was lost."),s.logger.debug(e.toString())})),this.registerer=void 0),this.managedSessions.slice().map((function(e){return e.session})).forEach((function(e){return a(s,void 0,void 0,(function(){var t=this;return c(this,(function(n){return this.logger.log("Disposing of session..."),e.dispose().catch((function(e){t.logger.debug("Error occurred disposing of a session after connection with server was lost."),t.logger.debug(e.toString())})),[2]}))}))})),this.shouldBeConnected&&(null===(r=null===(n=this.delegate)||void 0===n?void 0:n.onReconnectStart)||void 0===r||r.call(n),this.attemptReconnection())):null===(o=null===(i=this.delegate)||void 0===i?void 0:i.onServerDisconnect)||void 0===o||o.call(i,e),[2]}))}))},onInvite:function(e){i.logger.log("[".concat(e.id,"] Received INVITE"));var t=i.options.maxSimultaneousSessions;if(0!==t&&i.managedSessions.length>t)return i.logger.warn("[".concat(e.id,"] Session already in progress, rejecting INVITE...")),void e.reject().then((function(){i.logger.log("[".concat(e.id,"] Rejected INVITE"))})).catch((function(t){i.logger.error("[".concat(e.id,"] Failed to reject INVITE")),i.logger.error(t.toString())}));var n={sessionDescriptionHandlerOptions:{constraints:i.constraints}};i.initSession(e,n),i.delegate&&i.delegate.onCallReceived?i.delegate.onCallReceived(e):(i.logger.warn("[".concat(e.id,"] No handler available, rejecting INVITE...")),e.reject().then((function(){i.logger.log("[".concat(e.id,"] Rejected INVITE"))})).catch((function(t){i.logger.error("[".concat(e.id,"] Failed to reject INVITE")),i.logger.error(t.toString())})))},onMessage:function(e){e.accept().then((function(){i.delegate&&i.delegate.onMessageReceived&&i.delegate.onMessageReceived(e)}))},onNotify:function(e){e.accept().then((function(){i.delegate&&i.delegate.onNotificationReceived&&i.delegate.onNotificationReceived(e)}))}},this.registererOptions=o({},r.registererOptions),this.registererRegisterOptions=o({},r.registererRegisterOptions),this.options.registrationRetry){this.registererRegisterOptions.requestDelegate=this.registererRegisterOptions.requestDelegate||{};var u=this.registererRegisterOptions.requestDelegate.onReject;this.registererRegisterOptions.requestDelegate.onReject=function(e){u&&u(e),i.attemptRegistration()}}this.logger=this.userAgent.getLogger("sip.SessionManager"),window.addEventListener("online",(function(){i.logger.log("Online"),i.shouldBeConnected&&i.connect()})),this.options.autoStop&&window.addEventListener("beforeunload",(function(){return a(i,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return this.shouldBeConnected=!1,this.shouldBeRegistered=!1,this.userAgent.state===t.UserAgentState.Stopped?[3,2]:[4,this.userAgent.stop()];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))}))}return Object.defineProperty(e,"stripUndefinedProperties",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return Object.keys(e).reduce((function(t,n){return void 0!==e[n]&&(t[n]=e[n]),t}),{})}}),Object.defineProperty(e.prototype,"getLocalMediaStream",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=e.sessionDescriptionHandler;if(n){if(!(n instanceof t.Web.SessionDescriptionHandler))throw new Error("Session description handler not instance of web SessionDescriptionHandler");return n.localMediaStream}}}),Object.defineProperty(e.prototype,"getRemoteMediaStream",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=e.sessionDescriptionHandler;if(n){if(!(n instanceof t.Web.SessionDescriptionHandler))throw new Error("Session description handler not instance of web SessionDescriptionHandler");return n.remoteMediaStream}}}),Object.defineProperty(e.prototype,"getLocalAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;return null===(t=this.getLocalMediaStream(e))||void 0===t?void 0:t.getTracks().find((function(e){return"audio"===e.kind}))}}),Object.defineProperty(e.prototype,"getLocalVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;return null===(t=this.getLocalMediaStream(e))||void 0===t?void 0:t.getTracks().find((function(e){return"video"===e.kind}))}}),Object.defineProperty(e.prototype,"getRemoteAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;return null===(t=this.getRemoteMediaStream(e))||void 0===t?void 0:t.getTracks().find((function(e){return"audio"===e.kind}))}}),Object.defineProperty(e.prototype,"getRemoteVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;return null===(t=this.getRemoteMediaStream(e))||void 0===t?void 0:t.getTracks().find((function(e){return"video"===e.kind}))}}),Object.defineProperty(e.prototype,"connect",{enumerable:!1,configurable:!0,writable:!0,value:function(){return a(this,void 0,void 0,(function(){return c(this,(function(e){return this.logger.log("Connecting UserAgent..."),this.shouldBeConnected=!0,this.userAgent.state!==t.UserAgentState.Started?[2,this.userAgent.start()]:[2,this.userAgent.reconnect()]}))}))}}),Object.defineProperty(e.prototype,"disconnect",{enumerable:!1,configurable:!0,writable:!0,value:function(){return a(this,void 0,void 0,(function(){return c(this,(function(e){return this.logger.log("Disconnecting UserAgent..."),this.userAgent.state===t.UserAgentState.Stopped?[2,Promise.resolve()]:(this.shouldBeConnected=!1,this.shouldBeRegistered=!1,this.registerer=void 0,[2,this.userAgent.stop()])}))}))}}),Object.defineProperty(e.prototype,"isConnected",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.userAgent.isConnected()}}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return a(this,void 0,void 0,(function(){var n=this;return c(this,(function(r){return this.logger.log("Registering UserAgent..."),this.shouldBeRegistered=!0,void 0!==e&&(this.registererRegisterOptions=o({},e)),this.registerer||(this.registerer=new t.Registerer(this.userAgent,this.registererOptions),this.registerer.stateChange.addListener((function(e){switch(e){case t.RegistererState.Initial:break;case t.RegistererState.Registered:n.delegate&&n.delegate.onRegistered&&n.delegate.onRegistered();break;case t.RegistererState.Unregistered:n.delegate&&n.delegate.onUnregistered&&n.delegate.onUnregistered(),n.shouldBeRegistered&&n.attemptRegistration();break;case t.RegistererState.Terminated:break;default:throw new Error("Unknown registerer state.")}}))),[2,this.attemptRegistration(!0)]}))}))}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return a(this,void 0,void 0,(function(){return c(this,(function(t){return this.logger.log("Unregistering UserAgent..."),this.shouldBeRegistered=!1,this.registerer?[2,this.registerer.unregister(e).then((function(){}))]:(this.logger.warn("No registerer to unregister."),[2,Promise.resolve()])}))}))}}),Object.defineProperty(e.prototype,"call",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n,r){return a(this,void 0,void 0,(function(){var i,o,s,a,l=this;return c(this,(function(c){return this.logger.log("Beginning Session..."),0!==(i=this.options.maxSimultaneousSessions)&&this.managedSessions.length>i?[2,Promise.reject(new Error("Maximum number of sessions already exists."))]:(o=t.UserAgent.makeURI(e))?(n||(n={}),n.sessionDescriptionHandlerOptions||(n.sessionDescriptionHandlerOptions={}),n.sessionDescriptionHandlerOptions.constraints||(n.sessionDescriptionHandlerOptions.constraints=this.constraints),n.earlyMedia&&((r=r||{}).requestDelegate=r.requestDelegate||{},s=r.requestDelegate.onProgress,r.requestDelegate.onProgress=function(e){183===e.message.statusCode&&l.setupRemoteMedia(a),s&&s(e)}),this.options.iceStopWaitingOnServerReflexive&&(n.delegate=n.delegate||{},n.delegate.onSessionDescriptionHandler=function(e){if(!(e instanceof t.Web.SessionDescriptionHandler))throw new Error("Session description handler not instance of SessionDescriptionHandler");e.peerConnectionDelegate={onicecandidate:function(t){var n;"srflx"===(null===(n=t.candidate)||void 0===n?void 0:n.type)&&(l.logger.log("[".concat(a.id,"] Found srflx ICE candidate, stop waiting...")),e.iceGatheringComplete())}}}),a=new t.Inviter(this.userAgent,o,n),[2,this.sendInvite(a,n,r).then((function(){return a}))]):[2,Promise.reject(new Error('Failed to create a valid URI from "'.concat(e,'"')))]}))}))}}),Object.defineProperty(e.prototype,"hangup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return a(this,void 0,void 0,(function(){return c(this,(function(t){return this.logger.log("[".concat(e.id,"] Hangup...")),this.sessionExists(e)?[2,this.terminate(e)]:[2,Promise.reject(new Error("Session does not exist."))]}))}))}}),Object.defineProperty(e.prototype,"answer",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){return this.logger.log("[".concat(e.id,"] Accepting Invitation...")),this.sessionExists(e)?e instanceof t.Invitation?(n||(n={}),n.sessionDescriptionHandlerOptions||(n.sessionDescriptionHandlerOptions={}),n.sessionDescriptionHandlerOptions.constraints||(n.sessionDescriptionHandlerOptions.constraints=this.constraints),[2,e.accept(n)]):[2,Promise.reject(new Error("Session not instance of Invitation."))]:[2,Promise.reject(new Error("Session does not exist."))]}))}))}}),Object.defineProperty(e.prototype,"decline",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return a(this,void 0,void 0,(function(){return c(this,(function(n){return this.logger.log("[".concat(e.id,"] Rejecting Invitation...")),this.sessionExists(e)?e instanceof t.Invitation?[2,e.reject()]:[2,Promise.reject(new Error("Session not instance of Invitation."))]:[2,Promise.reject(new Error("Session does not exist."))]}))}))}}),Object.defineProperty(e.prototype,"hold",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return a(this,void 0,void 0,(function(){return c(this,(function(t){return this.logger.log("[".concat(e.id,"] Holding session...")),[2,this.setHold(e,!0)]}))}))}}),Object.defineProperty(e.prototype,"unhold",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return a(this,void 0,void 0,(function(){return c(this,(function(t){return this.logger.log("[".concat(e.id,"] Unholding session...")),[2,this.setHold(e,!1)]}))}))}}),Object.defineProperty(e.prototype,"isHeld",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.sessionManaged(e);return!!t&&t.held}}),Object.defineProperty(e.prototype,"mute",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.logger.log("[".concat(e.id,"] Disabling media tracks...")),this.setMute(e,!0)}}),Object.defineProperty(e.prototype,"unmute",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.logger.log("[".concat(e.id,"] Enabling media tracks...")),this.setMute(e,!1)}}),Object.defineProperty(e.prototype,"isMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.sessionManaged(e);return!!t&&t.muted}}),Object.defineProperty(e.prototype,"sendDTMF",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return a(this,void 0,void 0,(function(){var n;return c(this,(function(r){return this.logger.log("[".concat(e.id,"] Sending DTMF...")),/^[0-9A-D#*,]$/.exec(t)?this.sessionExists(e)?(this.logger.log("[".concat(e.id,"] Sending DTMF tone: ").concat(t)),this.options.sendDTMFUsingSessionDescriptionHandler?e.sessionDescriptionHandler?e.sessionDescriptionHandler.sendDtmf(t)?[2,Promise.resolve()]:[2,Promise.reject(new Error("Failed to send DTMF"))]:[2,Promise.reject(new Error("Session desciption handler undefined."))]:(n={body:{contentDisposition:"render",contentType:"application/dtmf-relay",content:"Signal="+t+"\r\nDuration=2000"}},[2,e.info({requestOptions:n}).then((function(){}))])):[2,Promise.reject(new Error("Session does not exist."))]:[2,Promise.reject(new Error("Invalid DTMF tone."))]}))}))}}),Object.defineProperty(e.prototype,"transfer",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n,r){return a(this,void 0,void 0,(function(){var i;return c(this,(function(o){return this.logger.log("[".concat(e.id,"] Referring session...")),n instanceof t.Session?[2,e.refer(n,r).then((function(){}))]:(i=t.UserAgent.makeURI(n))?[2,e.refer(i,r).then((function(){}))]:[2,Promise.reject(new Error('Failed to create a valid URI from "'.concat(n,'"')))]}))}))}}),Object.defineProperty(e.prototype,"message",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n){return a(this,void 0,void 0,(function(){var r;return c(this,(function(i){return this.logger.log("Sending message..."),(r=t.UserAgent.makeURI(e))?[2,new t.Messager(this.userAgent,r,n).message()]:[2,Promise.reject(new Error('Failed to create a valid URI from "'.concat(e,'"')))]}))}))}}),Object.defineProperty(e.prototype,"constraints",{get:function(){var e={audio:!0,video:!1};return this.options.media.constraints&&(e=o({},this.options.media.constraints)),e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"attemptReconnection",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,n,r=this;void 0===e&&(e=1);var i=this.options.reconnectionAttempts,o=this.options.reconnectionDelay;if(this.shouldBeConnected){if(this.attemptingReconnection&&this.logger.log("Reconnection attempt already in progress"),e>i)return this.logger.log("Reconnection maximum attempts reached"),void(null===(n=null===(t=this.delegate)||void 0===t?void 0:t.onReconnectFailed)||void 0===n||n.call(t));1===e?this.logger.log("Reconnection attempt ".concat(e," of ").concat(i," - trying")):this.logger.log("Reconnection attempt ".concat(e," of ").concat(i," - trying in ").concat(o," seconds")),this.attemptingReconnection=!0,setTimeout((function(){if(!r.shouldBeConnected)return r.logger.log("Reconnection attempt ".concat(e," of ").concat(i," - aborted")),void(r.attemptingReconnection=!1);r.userAgent.reconnect().then((function(){r.logger.log("Reconnection attempt ".concat(e," of ").concat(i," - succeeded")),r.attemptingReconnection=!1})).catch((function(t){r.logger.log("Reconnection attempt ".concat(e," of ").concat(i," - failed")),r.logger.error(t.message),r.attemptingReconnection=!1,r.attemptReconnection(++e)}))}),1===e?0:1e3*o)}else this.logger.log("Should not be connected currently")}}),Object.defineProperty(e.prototype,"attemptRegistration",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=this;if(void 0===e&&(e=!1),this.logger.log("Registration attempt ".concat(e?"without delay":"")),!this.shouldBeRegistered)return this.logger.log("Should not be registered currently"),Promise.resolve();if(void 0!==this.registrationAttemptTimeout)return this.logger.log("Registration attempt already in progress"),Promise.resolve();return new Promise((function(r,i){var o,s;n.registrationAttemptTimeout=setTimeout((function(){(n.registerer?n.isConnected()?n.userAgent.state===t.UserAgentState.Stopped?(n.logger.log("User agent stopped"),Promise.resolve()):n.options.registerGuard?n.options.registerGuard().catch((function(e){throw n.logger.log("Register guard rejected will making registration attempt"),e})).then((function(e){return e||!n.registerer?Promise.resolve():n.registerer.register(n.registererRegisterOptions).then((function(){}))})):n.registerer.register(n.registererRegisterOptions).then((function(){})):(n.logger.log("User agent not connected"),Promise.resolve()):(n.logger.log("Registerer undefined"),Promise.resolve())).then((function(){n.registrationAttemptTimeout=void 0,r()})).catch((function(e){n.registrationAttemptTimeout=void 0,e instanceof t.RequestPendingError?r():i(e)}))}),e?0:(o=n.options.registrationRetryInterval,s=2*o,1e3*(Math.random()*(s-o)+o)))}))}}),Object.defineProperty(e.prototype,"cleanupMedia",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.sessionManaged(e);if(!t)throw new Error("Managed session does not exist.");t.mediaLocal&&t.mediaLocal.video&&(t.mediaLocal.video.srcObject=null,t.mediaLocal.video.pause()),t.mediaRemote&&(t.mediaRemote.audio&&(t.mediaRemote.audio.srcObject=null,t.mediaRemote.audio.pause()),t.mediaRemote.video&&(t.mediaRemote.video.srcObject=null,t.mediaRemote.video.pause()))}}),Object.defineProperty(e.prototype,"enableReceiverTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n){if(!this.sessionExists(e))throw new Error("Session does not exist.");var r=e.sessionDescriptionHandler;if(!(r instanceof t.Web.SessionDescriptionHandler))throw new Error("Session's session description handler not instance of SessionDescriptionHandler.");r.enableReceiverTracks(n)}}),Object.defineProperty(e.prototype,"enableSenderTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n){if(!this.sessionExists(e))throw new Error("Session does not exist.");var r=e.sessionDescriptionHandler;if(!(r instanceof t.Web.SessionDescriptionHandler))throw new Error("Session's session description handler not instance of SessionDescriptionHandler.");r.enableSenderTracks(n)}}),Object.defineProperty(e.prototype,"initSession",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n){var r=this;this.sessionAdd(e),this.delegate&&this.delegate.onCallCreated&&this.delegate.onCallCreated(e),e.stateChange.addListener((function(n){switch(r.logger.log("[".concat(e.id,"] Session state changed to ").concat(n)),n){case t.SessionState.Initial:case t.SessionState.Establishing:break;case t.SessionState.Established:r.setupLocalMedia(e),r.setupRemoteMedia(e),r.delegate&&r.delegate.onCallAnswered&&r.delegate.onCallAnswered(e);break;case t.SessionState.Terminating:case t.SessionState.Terminated:r.sessionExists(e)&&(r.cleanupMedia(e),r.sessionRemove(e),r.delegate&&r.delegate.onCallHangup&&r.delegate.onCallHangup(e));break;default:throw new Error("Unknown session state.")}})),e.delegate=e.delegate||{},e.delegate.onInfo=function(t){var n;if(void 0!==(null===(n=r.delegate)||void 0===n?void 0:n.onCallDTMFReceived)){var i=t.request.getHeader("content-type");if(i&&/^application\/dtmf-relay/i.exec(i)){var o=t.request.body.split("\r\n",2);if(2===o.length){var s,a=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/;if(void 0!==o[0]&&a.test(o[0])&&(s=o[0].replace(a,"$2")),s){var c,l=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;void 0!==o[1]&&l.test(o[1])&&(c=parseInt(o[1].replace(l,"$2"),10)),c?t.accept().then((function(){if(r.delegate&&r.delegate.onCallDTMFReceived){if(!s||!c)throw new Error("Tone or duration undefined.");r.delegate.onCallDTMFReceived(e,s,c)}})).catch((function(e){r.logger.error(e.message)})):t.reject()}else t.reject()}else t.reject()}else t.reject()}else t.reject()},e.delegate.onRefer=function(e){e.accept().then((function(){return r.sendInvite(e.makeInviter(n),n)})).catch((function(e){r.logger.error(e.message)}))}}}),Object.defineProperty(e.prototype,"optionsPingRun",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){var r=this;if(this.options.optionsPingInterval<1)throw new Error("Invalid options ping interval.");this.optionsPingRunning||(this.optionsPingRunning=!0,this.optionsPingTimeout=setTimeout((function(){r.optionsPingTimeout=void 0;var i=function(){r.optionsPingFailure=!1,r.optionsPingRunning&&(r.optionsPingRunning=!1,r.optionsPingRun(e,t,n))},o=r.userAgent.userAgentCore,s=o.makeOutgoingRequestMessage("OPTIONS",e,t,n,{});r.optionsPingRequest=o.request(s,{onAccept:function(){r.optionsPingRequest=void 0,i()},onReject:function(e){r.optionsPingRequest=void 0,408===e.message.statusCode||503===e.message.statusCode?(r.logger.error("OPTIONS ping failed"),r.optionsPingFailure=!0,r.optionsPingRunning=!1,r.userAgent.transport.disconnect().catch((function(e){return r.logger.error(e)}))):i()}})}),1e3*this.options.optionsPingInterval))}}),Object.defineProperty(e.prototype,"optionsPingStart",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,n,r;if(this.logger.log("OPTIONS pings started"),this.options.optionsPingRequestURI){if(!(e=t.UserAgent.makeURI(this.options.optionsPingRequestURI)))throw new Error("Failed to create Request URI.");n=this.userAgent.contact.uri.clone(),r=this.userAgent.contact.uri.clone()}else{if(!this.options.aor)return void this.logger.error("You have enabled sending OPTIONS pings and as such you must provide either a) an AOR to register, or b) an RURI to use for the target of the OPTIONS ping requests. ");var i=t.UserAgent.makeURI(this.options.aor);if(!i)throw new Error("Failed to create URI.");(e=i.clone()).user=void 0,n=i.clone(),r=i.clone()}this.optionsPingRun(e,n,r)}}),Object.defineProperty(e.prototype,"optionsPingStop",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.logger.log("OPTIONS pings stopped"),this.optionsPingRunning=!1,this.optionsPingFailure=!1,this.optionsPingRequest&&(this.optionsPingRequest.dispose(),this.optionsPingRequest=void 0),this.optionsPingTimeout&&(clearTimeout(this.optionsPingTimeout),this.optionsPingTimeout=void 0)}}),Object.defineProperty(e.prototype,"sendInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){return a(this,void 0,void 0,(function(){var r=this;return c(this,(function(i){return this.initSession(e,t),[2,e.invite(n).then((function(){r.logger.log("[".concat(e.id,"] Sent INVITE"))}))]}))}))}}),Object.defineProperty(e.prototype,"managedSessionFactory",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return{session:t,held:!1,muted:!1}}}),Object.defineProperty(e.prototype,"sessionAdd",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.managedSessionFactory(this,e);this.managedSessions.push(t)}}),Object.defineProperty(e.prototype,"sessionExists",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return void 0!==this.sessionManaged(e)}}),Object.defineProperty(e.prototype,"sessionManaged",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.managedSessions.find((function(t){return t.session.id===e.id}))}}),Object.defineProperty(e.prototype,"sessionRemove",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.managedSessions=this.managedSessions.filter((function(t){return t.session.id!==e.id}))}}),Object.defineProperty(e.prototype,"setHold",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n){return a(this,void 0,void 0,(function(){var r,i,o,s=this;return c(this,(function(a){if(!this.sessionExists(e))return[2,Promise.reject(new Error("Session does not exist."))];if(this.isHeld(e)===n)return[2,Promise.resolve()];if(!(e.sessionDescriptionHandler instanceof t.Web.SessionDescriptionHandler))throw new Error("Session's session description handler not instance of SessionDescriptionHandler.");if(r={requestDelegate:{onAccept:function(){var t=s.sessionManaged(e);void 0!==t&&(t.held=n,s.enableReceiverTracks(e,!t.held),s.enableSenderTracks(e,!t.held&&!t.muted),s.delegate&&s.delegate.onCallHold&&s.delegate.onCallHold(e,t.held))},onReject:function(){s.logger.warn("[".concat(e.id,"] Re-invite request was rejected"));var t=s.sessionManaged(e);void 0!==t&&(t.held=!n,s.enableReceiverTracks(e,!t.held),s.enableSenderTracks(e,!t.held&&!t.muted),s.delegate&&s.delegate.onCallHold&&s.delegate.onCallHold(e,t.held))}}},(i=e.sessionDescriptionHandlerOptionsReInvite).hold=n,e.sessionDescriptionHandlerOptionsReInvite=i,!(o=this.sessionManaged(e)))throw new Error("Managed session is undefiend.");return o.held=n,[2,e.invite(r).then((function(){var t=s.sessionManaged(e);void 0!==t&&(s.enableReceiverTracks(e,!t.held),s.enableSenderTracks(e,!t.held&&!t.muted))})).catch((function(r){throw o.held=!n,r instanceof t.RequestPendingError&&s.logger.error("[".concat(e.id,"] A hold request is already in progress.")),r}))]}))}))}}),Object.defineProperty(e.prototype,"setMute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n){if(this.sessionExists(e))if(e.state===t.SessionState.Established){var r=this.sessionManaged(e);void 0!==r&&(r.muted=n,this.enableSenderTracks(e,!r.held&&!r.muted))}else this.logger.warn("[".concat(e.id,"] An established session is required to enable/disable media tracks"));else this.logger.warn("[".concat(e.id,"] A session is required to enabled/disable media tracks"))}}),Object.defineProperty(e.prototype,"setupLocalMedia",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,n=this.sessionManaged(e);if(!n)throw new Error("Managed session does not exist.");var r="function"==typeof this.options.media.local?this.options.media.local(e):this.options.media.local;n.mediaLocal=r;var i=null==r?void 0:r.video;if(i){var o=this.getLocalMediaStream(e);if(!o)throw new Error("Local media stream undefiend.");i.srcObject=o,i.volume=0,i.play().catch((function(n){t.logger.error("[".concat(e.id,"] Failed to play local media")),t.logger.error(n.message)}))}}}),Object.defineProperty(e.prototype,"setupRemoteMedia",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,n=this.sessionManaged(e);if(!n)throw new Error("Managed session does not exist.");var r="function"==typeof this.options.media.remote?this.options.media.remote(e):this.options.media.remote;n.mediaRemote=r;var i=(null==r?void 0:r.video)||(null==r?void 0:r.audio);if(i){var o=this.getRemoteMediaStream(e);if(!o)throw new Error("Remote media stream undefiend.");i.autoplay=!0,i.srcObject=o,i.play().catch((function(n){t.logger.error("[".concat(e.id,"] Failed to play remote media")),t.logger.error(n.message)})),o.onaddtrack=function(){t.logger.log("Remote media onaddtrack"),i.load(),i.play().catch((function(n){t.logger.error("[".concat(e.id,"] Failed to play remote media")),t.logger.error(n.message)}))}}}}),Object.defineProperty(e.prototype,"terminate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return a(this,void 0,void 0,(function(){var n=this;return c(this,(function(r){switch(this.logger.log("[".concat(e.id,"] Terminating...")),e.state){case t.SessionState.Initial:if(e instanceof t.Inviter)return[2,e.cancel().then((function(){n.logger.log("[".concat(e.id,"] Inviter never sent INVITE (canceled)"))}))];if(e instanceof t.Invitation)return[2,e.reject().then((function(){n.logger.log("[".concat(e.id,"] Invitation rejected (sent 480)"))}))];throw new Error("Unknown session type.");case t.SessionState.Establishing:if(e instanceof t.Inviter)return[2,e.cancel().then((function(){n.logger.log("[".concat(e.id,"] Inviter canceled (sent CANCEL)"))}))];if(e instanceof t.Invitation)return[2,e.reject().then((function(){n.logger.log("[".concat(e.id,"] Invitation rejected (sent 480)"))}))];throw new Error("Unknown session type.");case t.SessionState.Established:return[2,e.bye().then((function(){n.logger.log("[".concat(e.id,"] Session ended (sent BYE)"))}))];case t.SessionState.Terminating:case t.SessionState.Terminated:break;default:throw new Error("Unknown state")}return this.logger.log("[".concat(e.id,"] Terminating in state ").concat(e.state,", no action taken")),[2,Promise.resolve()]}))}))}}),e}(),d=function(){function e(e,t){void 0===t&&(t={});var n=this;Object.defineProperty(this,"delegate",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sessionManager",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.delegate=t.delegate,this.options=o({},t);var r={aor:this.options.aor,delegate:{onCallAnswered:function(){var e,t;return null===(t=null===(e=n.delegate)||void 0===e?void 0:e.onCallAnswered)||void 0===t?void 0:t.call(e)},onCallCreated:function(e){var t,r,i,o;n.session=e,null===(r=null===(t=n.delegate)||void 0===t?void 0:t.onCallBegin)||void 0===r||r.call(t,e),null===(o=null===(i=n.delegate)||void 0===i?void 0:i.onCallCreated)||void 0===o||o.call(i)},onCallReceived:function(e){var t,r,i,o;null===(r=null===(t=n.delegate)||void 0===t?void 0:t.onCallReceived)||void 0===r||r.call(t),null===(o=null===(i=n.delegate)||void 0===i?void 0:i.onInvite)||void 0===o||o.call(i,e)},onCallHangup:function(){var e,t;n.session=void 0,(null===(e=n.delegate)||void 0===e?void 0:e.onCallHangup)&&(null===(t=n.delegate)||void 0===t||t.onCallHangup())},onCallHold:function(e,t){var r,i;return null===(i=null===(r=n.delegate)||void 0===r?void 0:r.onCallHold)||void 0===i?void 0:i.call(r,t)},onCallDTMFReceived:function(e,t,r){var i,o;return null===(o=null===(i=n.delegate)||void 0===i?void 0:i.onCallDTMFReceived)||void 0===o?void 0:o.call(i,t,r)},onMessageReceived:function(e){var t,r;return null===(r=null===(t=n.delegate)||void 0===t?void 0:t.onMessageReceived)||void 0===r?void 0:r.call(t,e.request.body)},onRegistered:function(){var e,t;return null===(t=null===(e=n.delegate)||void 0===e?void 0:e.onRegistered)||void 0===t?void 0:t.call(e)},onUnregistered:function(){var e,t;return null===(t=null===(e=n.delegate)||void 0===e?void 0:e.onUnregistered)||void 0===t?void 0:t.call(e)},onServerConnect:function(){var e,t;return null===(t=null===(e=n.delegate)||void 0===e?void 0:e.onServerConnect)||void 0===t?void 0:t.call(e)},onServerDisconnect:function(){var e,t;return null===(t=null===(e=n.delegate)||void 0===e?void 0:e.onServerDisconnect)||void 0===t?void 0:t.call(e)},onReconnectFailed:function(){var e,t;return null===(t=null===(e=n.delegate)||void 0===e?void 0:e.onReconnectFailed)||void 0===t?void 0:t.call(e)},onReconnectStart:function(){var e,t;return null===(t=null===(e=n.delegate)||void 0===e?void 0:e.onReconnectStart)||void 0===t?void 0:t.call(e)}},maxSimultaneousSessions:1,media:this.options.media,optionsPingInterval:this.options.optionsPingInterval,optionsPingRequestURI:this.options.aor,reconnectionAttempts:this.options.reconnectionAttempts,reconnectionDelay:this.options.reconnectionDelay,registererOptions:this.options.registererOptions,sendDTMFUsingSessionDescriptionHandler:this.options.sendDTMFUsingSessionDescriptionHandler,userAgentOptions:this.options.userAgentOptions};this.sessionManager=new u(e,r),this.sessionManager.userAgent.stateChange.addListener((function(e){var t,r;null===(r=null===(t=n.delegate)||void 0===t?void 0:t.onUserAgentStateChange)||void 0===r||r.call(t,e)})),this.logger=this.sessionManager.userAgent.getLogger("sip.SimpleUser")}return Object.defineProperty(e.prototype,"id",{get:function(){return this.options.userAgentOptions&&this.options.userAgentOptions.displayName||"Anonymous"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localMediaStream",{get:function(){return this.session&&this.sessionManager.getLocalMediaStream(this.session)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"remoteMediaStream",{get:function(){return this.session&&this.sessionManager.getRemoteMediaStream(this.session)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localAudioTrack",{get:function(){return this.session&&this.sessionManager.getLocalAudioTrack(this.session)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localVideoTrack",{get:function(){return this.session&&this.sessionManager.getLocalVideoTrack(this.session)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"remoteAudioTrack",{get:function(){return this.session&&this.sessionManager.getRemoteAudioTrack(this.session)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"remoteVideoTrack",{get:function(){return this.session&&this.sessionManager.getRemoteVideoTrack(this.session)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connect",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.logger.log("[".concat(this.id,"] Connecting UserAgent...")),this.sessionManager.connect()}}),Object.defineProperty(e.prototype,"disconnect",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.logger.log("[".concat(this.id,"] Disconnecting UserAgent...")),this.sessionManager.disconnect()}}),Object.defineProperty(e.prototype,"isConnected",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.sessionManager.isConnected()}}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.logger.log("[".concat(this.id,"] Registering UserAgent...")),this.sessionManager.register(e)}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.logger.log("[".concat(this.id,"] Unregistering UserAgent...")),this.sessionManager.unregister(e)}}),Object.defineProperty(e.prototype,"call",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){return this.logger.log("[".concat(this.id,"] Beginning Session...")),this.session?Promise.reject(new Error("Session already exists.")):this.sessionManager.call(e,t,n).then((function(){}))}}),Object.defineProperty(e.prototype,"hangup",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;return this.logger.log("[".concat(this.id,"] Hangup...")),this.session?this.sessionManager.hangup(this.session).then((function(){e.session=void 0})):Promise.reject(new Error("Session does not exist."))}}),Object.defineProperty(e.prototype,"answer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.logger.log("[".concat(this.id,"] Accepting Invitation...")),this.session?this.sessionManager.answer(this.session,e):Promise.reject(new Error("Session does not exist."))}}),Object.defineProperty(e.prototype,"decline",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.logger.log("[".concat(this.id,"] rejecting Invitation...")),this.session?this.sessionManager.decline(this.session):Promise.reject(new Error("Session does not exist."))}}),Object.defineProperty(e.prototype,"hold",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.logger.log("[".concat(this.id,"] holding session...")),this.session?this.sessionManager.hold(this.session):Promise.reject(new Error("Session does not exist."))}}),Object.defineProperty(e.prototype,"unhold",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.logger.log("[".concat(this.id,"] unholding session...")),this.session?this.sessionManager.unhold(this.session):Promise.reject(new Error("Session does not exist."))}}),Object.defineProperty(e.prototype,"isHeld",{enumerable:!1,configurable:!0,writable:!0,value:function(){return!!this.session&&this.sessionManager.isHeld(this.session)}}),Object.defineProperty(e.prototype,"mute",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.logger.log("[".concat(this.id,"] disabling media tracks...")),this.session&&this.sessionManager.mute(this.session)}}),Object.defineProperty(e.prototype,"unmute",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.logger.log("[".concat(this.id,"] enabling media tracks...")),this.session&&this.sessionManager.unmute(this.session)}}),Object.defineProperty(e.prototype,"isMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(){return!!this.session&&this.sessionManager.isMuted(this.session)}}),Object.defineProperty(e.prototype,"sendDTMF",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.logger.log("[".concat(this.id,"] sending DTMF...")),this.session?this.sessionManager.sendDTMF(this.session,e):Promise.reject(new Error("Session does not exist."))}}),Object.defineProperty(e.prototype,"message",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this.logger.log("[".concat(this.id,"] sending message...")),this.sessionManager.message(e,t)}}),e}();let g=Object.prototype.hasOwnProperty,p="~";function f(){}function h(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function b(e,t,n,r,i){if("function"!=typeof n)throw new TypeError("The listener must be a function");const o=new h(n,r||e,i),s=p?p+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],o]:e._events[s].push(o):(e._events[s]=o,e._eventsCount++),e}function v(e,t){0==--e._eventsCount?e._events=new f:delete e._events[t]}function m(){this._events=new f,this._eventsCount=0}Object.create&&(f.prototype=Object.create(null),(new f).__proto__||(p=!1)),m.prototype.eventNames=function(){let e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)g.call(e,t)&&n.push(p?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},m.prototype.listeners=function(e){const t=p?p+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,i=n.length,o=new Array(i);r<i;r++)o[r]=n[r].fn;return o},m.prototype.listenerCount=function(e){const t=p?p+e:e,n=this._events[t];return n?n.fn?1:n.length:0},m.prototype.emit=function(e,t,n,r,i,o){const s=p?p+e:e;if(!this._events[s])return!1;let a,c,l=this._events[s],u=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),u){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,r),!0;case 5:return l.fn.call(l.context,t,n,r,i),!0;case 6:return l.fn.call(l.context,t,n,r,i,o),!0}for(c=1,a=new Array(u-1);c<u;c++)a[c-1]=arguments[c];l.fn.apply(l.context,a)}else{let i,o=l.length;for(c=0;c<o;c++)switch(l[c].once&&this.removeListener(e,l[c].fn,void 0,!0),u){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,t);break;case 3:l[c].fn.call(l[c].context,t,n);break;case 4:l[c].fn.call(l[c].context,t,n,r);break;default:if(!a)for(i=1,a=new Array(u-1);i<u;i++)a[i-1]=arguments[i];l[c].fn.apply(l[c].context,a)}}return!0},m.prototype.on=function(e,t,n){return b(this,e,t,n,!1)},m.prototype.once=function(e,t,n){return b(this,e,t,n,!0)},m.prototype.removeListener=function(e,t,n,r){const i=p?p+e:e;if(!this._events[i])return this;if(!t)return v(this,i),this;const o=this._events[i];if(o.fn)o.fn!==t||r&&!o.once||n&&o.context!==n||v(this,i);else{for(var s=0,a=[],c=o.length;s<c;s++)(o[s].fn!==t||r&&!o[s].once||n&&o[s].context!==n)&&a.push(o[s]);a.length?this._events[i]=1===a.length?a[0]:a:v(this,i)}return this},m.prototype.removeAllListeners=function(e){let t;return e?(t=p?p+e:e,this._events[t]&&v(this,t)):(this._events=new f,this._eventsCount=0),this},m.prototype.off=m.prototype.removeListener,m.prototype.addListener=m.prototype.on,m.prefixed=p,m.EventEmitter=m,"undefined"!=typeof module&&(module.exports=m);var S;e.LoggerLevels=void 0,(S=e.LoggerLevels||(e.LoggerLevels={}))[S.error=0]="error",S[S.warn=1]="warn",S[S.log=2]="log",S[S.debug=3]="debug";var y,w,P,O,T,k,I,C,_,R,j,E,A=function(){function t(e,t,n){Object.defineProperty(this,"_level",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"category",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"label",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._level=e,this.category=t,this.label=n}return Object.defineProperty(t.prototype,"error",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.genericLog(e.LoggerLevels.error,t)}}),Object.defineProperty(t.prototype,"warn",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.genericLog(e.LoggerLevels.warn,t)}}),Object.defineProperty(t.prototype,"log",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.genericLog(e.LoggerLevels.log,t)}}),Object.defineProperty(t.prototype,"debug",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.genericLog(e.LoggerLevels.debug,t)}}),Object.defineProperty(t.prototype,"genericLog",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._level>=e&&this.print(e,this.category,this.label,t)}}),Object.defineProperty(t.prototype,"print",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,r,i){if("string"==typeof i){var o=[(s=Date.now(),a=new Date(s),c=a.getFullYear(),l=String(a.getMonth()+1).padStart(2,"0"),u=String(a.getDate()).padStart(2,"0"),d=String(a.getHours()).padStart(2,"0"),g=String(a.getMinutes()).padStart(2,"0"),p=String(a.getSeconds()).padStart(2,"0"),f=String(a.getMilliseconds()).padStart(3,"0"),"".concat(c,"-").concat(l,"-").concat(u," ").concat(d,":").concat(g,":").concat(p,".").concat(f))];r&&o.push(r),i=o.concat(i).join(" | ")}var s,a,c,l,u,d,g,p,f;switch(t){case e.LoggerLevels.error:console.error("%c".concat(n),"color: blue;",i);break;case e.LoggerLevels.warn:console.warn("%c".concat(n),"color: blue;",i);break;case e.LoggerLevels.log:console.log("%c".concat(n),"color: blue;",i);break;case e.LoggerLevels.debug:console.debug("%c".concat(n),"color: blue;",i)}}}),Object.defineProperty(t.prototype,"level",{get:function(){return this._level},set:function(t){t>=0&&t<=3?this._level=t:t>3?this._level=3:e.LoggerLevels.hasOwnProperty(t)?this._level=t:this.error("invalid 'level' parameter value: "+JSON.stringify(t))},enumerable:!1,configurable:!0}),t}();e.Scene=void 0,(y=e.Scene||(e.Scene={})).Manual="manual",y.Robot="robot",y.Monitor="monitor",y.Predictive="predictive",y.Wechat="wechat",e.MonitorScene=void 0,(w=e.MonitorScene||(e.MonitorScene={})).All="all",w.Manual="manual",w.Robot="robot",w.Predictive="predictive",e.SocketStatus=void 0,(P=e.SocketStatus||(e.SocketStatus={})).Initial="Initial",P.Connecting="Connecting",P.Connected="Connected",P.Ready="Ready",P.ReTry="ReTry",P.Terminated="Terminated",e.SIPStatus=void 0,(O=e.SIPStatus||(e.SIPStatus={})).Initial="Initial",O.Started="Started",O.Connecting="Connecting",O.Connected="Connected",O.Ready="Ready",O.ReTry="ReTry",O.Terminated="Terminated",e.CTIStatus=void 0,(T=e.CTIStatus||(e.CTIStatus={})).Initial="Initial",T.Ready="Ready",T.ReTry="ReTry",T.Terminated="Terminated",e.CallStatus=void 0,(k=e.CallStatus||(e.CallStatus={})).Started="Started",k.Stopped="Stopped",e.SessionStatus=void 0,(I=e.SessionStatus||(e.SessionStatus={})).Initial="Initial",I.Establishing="Establishing",I.Established="Established",I.Terminating="Terminating",I.Terminated="Terminated",e.CTIErrorType=void 0,(C=e.CTIErrorType||(e.CTIErrorType={})).SdkTerminated="SdkTerminated",C.SdkError="SdkError",C.ServerTerminated="ServerTerminated",C.ServerError="ServerError",e.HskTerminatedCode=void 0,(_=e.HskTerminatedCode||(e.HskTerminatedCode={})).CTITerminated="100001",_.GetUserMedia="100002",_.GetInitConfig="100003",_.SocketOnError="110001",_.SocketOnConnectError="110002",_.SocketOnDisconnect="110003",_.SocketRepeatLogin="110004",_.SocketOnReconnectFailed="110007",_.SIPInitUserAgent="120001",_.SIPInitRegister="120002",_.SIPUserAgentStateStopped="120003",_.SIPTransportStateDisconnected="120004",_.SIPRegistererStateTerminated="120005",_.SIPOnDisconnect="120006",_.SIPInitTransport="120007",_.SipHeartBeatErr="120008",_.SIPUnRegistered="120009",e.SdkErrorCode=void 0,(R=e.SdkErrorCode||(e.SdkErrorCode={})).Answer="200001",R.Bye="200002",R.InvitationCancel="200003",R.AssignStream="200004",R.FetchError="200005",e.CTIEvent=void 0,(j=e.CTIEvent||(e.CTIEvent={})).OnCtiError="OnCtiError",j.OnSessionStatusChange="OnSessionStatusChange",j.OnInitalSuccess="OnInitalSuccess",j.OnAgentWorkReport="OnAgentWorkReport",j.OnRingStart="OnRingStart",j.OnRingEnd="OnRingEnd",j.OnDetectedTone="OnDetectedTone",j.OnAgentReport="OnAgentReport",j.OnCallReportInfo="OnCallReportInfo",j.OnCallRing="OnCallRing",j.OnCallEnd="OnCallEnd",j.OnCallAnswer="OnCallAnswer",j.OnAgentGroupQuery="OnAgentGroupQuery",j.OnMethodResponseEvent="OnMethodResponseEvent",j.OnEventPrompt="OnEventPrompt",j.OnPrompt="OnPrompt",function(e){e.TrackParams="trackParams",e.ENV="env",e.LoggerLevel="loggerLevel"}(E||(E={}));var M=[[E.TrackParams,{}],[E.ENV,"test"],[E.LoggerLevel,e.LoggerLevels.debug]],L=new Map,D=function(){M.forEach((function(e,t){return L.set(e,t)}))};D();var x,H,U,F,N=function(e,t,n){void 0===n&&(n=!1),n||"object"!=typeof t?L.set(e,t):L.set(e,o(o({},L.get(e)),t))},B=function(){return window.HS_CTI_CLIENT_ID||(window.HS_CTI_CLIENT_ID="xxxxxxxxxxxx4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})).replace(/-/g,"")),window.HS_CTI_CLIENT_ID};!function(e){e.RingAudio="_ringAudio",e.WaitAudio="_waitAudio",e.ByeAudio="_byeAudio"}(x||(x={})),function(e){e.FeSocket="fe-socket",e.FeSIP="fe-sip",e.FeMethod="fe-method",e.FeAPI="fe-api",e.FeAPIError="fe-api-error",e.FeIMDown="fe-im-down",e.FeIMCmd="fe-im-cmd",e.FeMedia="fe-media",e.FeStatus="fe-status",e.FeEmit="fe-emit"}(H||(H={})),function(e){e.SetSocketStatus="SetSocketStatus",e.SocketDownEvent="SocketDownEvent"}(U||(U={})),function(e){e.CommonNetworkErrorMsg="对不起,网络状况暂时不佳,请刷新后重试。",e.CustomNetworkErrorMsg="对不起,连接失败,请刷新后重试。如果问题持续出现,请联系我们的技术人员。感谢您的理解和支持。",e.ManualCallAnswerErrorMsg="当前电话未接通,通话已结束,请重试。",e.RobotOrWeChatAnswerErrorMsg="对不起,由于用户挂机等原因,当前电话未接通,请等待下一通电话。",e.SipByeErrorMsg="请稍等,正在挂断。",e.CTIRepeatLoginMsg="当前坐席已被其他终端替代。"}(F||(F={}));var q,W={checkIn:F.CommonNetworkErrorMsg,checkOut:F.CommonNetworkErrorMsg,setIdle:F.CustomNetworkErrorMsg,setBusy:F.CommonNetworkErrorMsg,makeCall:F.CommonNetworkErrorMsg,answer:F.CommonNetworkErrorMsg,bye:F.CommonNetworkErrorMsg,loadAgentGroupData:F.CommonNetworkErrorMsg,listen:F.CommonNetworkErrorMsg,setActiveService:F.CustomNetworkErrorMsg},J=["agent_id","saas_id","env","scene"],V=l(l([],J,!0),["monitorScene"],!0),G=function(t){function r(e){var n=t.call(this)||this;return Object.defineProperty(n,"logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"socket",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"socketOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"heartBeatDelay",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"closeHeartBeatDelay",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"heartBeatTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"closeHeartBeatTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"imRetryCount",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"sessionId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),window.addEventListener("onunload",n.closeSocket),n.logger=new A(e.loggerLevel,"HsSocket"),n.socket=void 0,n.heartBeatTimer=null,n.closeHeartBeatTimer=null,n.sessionId="",n.socketOptions=e,n.heartBeatDelay=1e3*e.imHeartTime||3e3,n.closeHeartBeatDelay=1e3*e.imHeartTime||3e3,n.imRetryCount=e.imRetryCount||10,n}return i(r,t),Object.defineProperty(r.prototype,"initSocket",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this;this.closeSocket(),this.emit(U.SetSocketStatus,{status:e.SocketStatus.Connecting}),this.socket=n(this.socketOptions.imWsServer,{transports:["websocket"],reconnectionAttempts:this.imRetryCount,reconnectionDelay:this.heartBeatDelay,reconnectionDelayMax:this.heartBeatDelay+1e3,timeout:this.heartBeatDelay,reconnection:!0}),this.socket.on("error",(function(e){t.logger.error("socket_error | ".concat(JSON.stringify(e)))})),this.socket.on("connect_error",(function(e){var n="socket_connect_error | ".concat(JSON.stringify(e));t.logger.warn(n)})),this.socket.on("reconnecting",(function(n){t.logger.error("socket_warn | socket_reconnecting | ".concat(n)),t.emit(U.SetSocketStatus,{status:e.SocketStatus.ReTry})})),this.socket.on("reconnect",(function(n){t.logger.error("socket_warn | socket_reconnect | ".concat(n)),t.emit(U.SetSocketStatus,{status:e.SocketStatus.Ready})})),this.socket.on("reconnect_failed",(function(n){t.logger.error("socket_warn | socket_reconnect_failed | ".concat(n)),t.emit(U.SetSocketStatus,{status:e.SocketStatus.Terminated,code:e.HskTerminatedCode.SocketOnReconnectFailed,error:"".concat(n)})})),this.socket.on("connect",(function(){t.emit(U.SetSocketStatus,{status:e.SocketStatus.Connected}),t.socketLogin()})),this.socket.on("disconnect",(function(e){var n="socket_disconnect | ".concat(e);t.logger.warn(n)})),this.socket.on("common_down_data",(function(e){console.log(e,3434343434),e&&JSON.parse(e)&&JSON.parse(e).data&&t.emit(U.SocketDownEvent,{eventData:JSON.parse(JSON.parse(e).data)})})),this.socket.on("common_down_cmd",(function(n){var r=JSON.parse(n).clientSessionId;console.log("dsdsdsdsdsds",r),r===t.sessionId&&(t.logger.error("socket status | ".concat(e.SocketStatus.Terminated," | 坐席在其他页面重新初始化,本页面被踢出")),t.emit(U.SetSocketStatus,{status:e.SocketStatus.Terminated,code:e.HskTerminatedCode.SocketRepeatLogin,error:"您已在其他页面签入,当前页面连接已断开"}))}))}}),Object.defineProperty(r.prototype,"socketLogin",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this,n={userId:this.socketOptions.agent_id};this.socket&&this.socket.emit("login",n,(function(n){console.log(n,"测试一下"),t.emit(U.SetSocketStatus,{status:e.SocketStatus.Ready}),N(E.TrackParams,{socket_session_id:n}),t.sessionId=n,t.startHeartbeat()}))}}),Object.defineProperty(r.prototype,"closeSocket",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.socket&&(this.socket.io.opts.reconnection=!1,this.socket.close(),this.socket.removeAllListeners()),this.socket=void 0,this.sessionId="",this.heartBeatTimer&&(window.clearTimeout(this.heartBeatTimer),this.heartBeatTimer=null),this.closeHeartBeatTimer&&(window.clearTimeout(this.closeHeartBeatTimer),this.closeHeartBeatTimer=null)}}),Object.defineProperty(r.prototype,"startHeartbeat",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.heartBeatTimer&&(window.clearTimeout(this.heartBeatTimer),this.heartBeatTimer=null),this.closeHeartBeatTimer&&(window.clearTimeout(this.closeHeartBeatTimer),this.closeHeartBeatTimer=null),this.socket&&this.heartbeatEvent()}}),Object.defineProperty(r.prototype,"heartbeatEvent",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this.heartBeatTimer=setTimeout((function(){e.socket&&e.sendHeartbeat(),e.closeHeartBeatTimer=setTimeout((function(){e.logger.warn("socket_heart_beat | 心跳超时,即将重新连接"),e.initSocket()}),e.closeHeartBeatDelay)}),this.heartBeatDelay)}}),Object.defineProperty(r.prototype,"sendHeartbeat",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this.socket&&this.socket.emit("heartbeat",JSON.stringify(o({},this.socketOptions)),(function(){e.startHeartbeat()}))}}),r}(m),$=new A(window.ctiLoggerLevel||(q=E.LoggerLevel,L.get(q)),"HsApi"),Y=function(){return(65536|65536*Math.random()).toString(16).substr(1)};function Q(e){var t=e.baseUrl,n=e.url,r=e.data;return a(this,void 0,void 0,(function(){var e,i;return c(this,(function(o){switch(o.label){case 0:return e=Y()+Y()+Y()+Y(),[4,fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json","X-B3-TraceId":e,"X-B3-SpanId":e},body:JSON.stringify(r)})];case 1:return(i=o.sent()).ok||$.error("api response | ".concat(n," | Request failed with status ").concat(i.status)),[2,i.json()]}}))}))}var X=function(e){var t=e.baseUrl,n=e.url,r=void 0===n?"":n,i=e.data;return new Promise((function(e,n){return a(void 0,void 0,void 0,(function(){var o,s,a,l;return c(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),[4,Q({baseUrl:t,url:r,data:i})];case 1:return o=c.sent(),s=o.code,a=o.msg,console.log(a),0===s?$.log("api response | ".concat(r," | ").concat(JSON.stringify(o))):$.error("api response | ".concat(r," | ").concat(JSON.stringify(o))),e(o),[3,3];case 2:return l=c.sent(),$.error("api response | ".concat(r," | ").concat(JSON.stringify(l))),n(l),[3,3];case 3:return[2]}}))}))}))},z="http://192.168.100.159:8090",Z=function(e){return X({baseUrl:z,url:"/open/agent/get-init-config",data:e})},K=function(e){return X({baseUrl:z,url:"/open/agent/manual-call",data:e})},ee=function(e){return X({baseUrl:z,url:"/open/num/generate",data:e})};function te(t){return function(n,r,i){var o=i.value;return i.value=function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];if(this.logger.log("sdk method | ".concat(r," | ").concat(t)),this.getCTIStatus!==e.CTIStatus.Ready){var s={type:e.CTIErrorType.SdkTerminated,code:e.HskTerminatedCode.CTITerminated,msg:W[r],method:r,terminated_source:this._terminatedStatusList};return this.eventEmitAndTrack(e.CTIEvent.OnCtiError,s),Promise.reject(s)}return o.apply(this,n)},i}}function ne(){return function(t,n,r){var i=r.value;return r.value=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return a(this,void 0,void 0,(function(){var r,o,s,a,l,u;return c(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),[4,i.apply(this,t)];case 1:return r=c.sent(),o=r.code,s=r.msg,0!==o?(a=function(t){return t>=300001&&t<=399999?e.CTIErrorType.ServerTerminated:e.CTIErrorType.ServerError}(o),u={type:a,code:o,msg:s,method:n},this.eventEmitAndTrack(e.CTIEvent.OnCtiError,u),a===e.CTIErrorType.ServerTerminated&&this.setCTIStatus(e.CTIStatus.Terminated),[2,Promise.reject(u)]):[2,Promise.resolve(r)];case 2:return l=c.sent(),u={type:"fetch_error",code:e.SdkErrorCode.FetchError,msg:JSON.stringify(l),method:n},this.eventEmitAndTrack(e.CTIEvent.OnCtiError,u),[2,Promise.reject(u)];case 3:return[2]}}))}))},r}}var re={_ringAudio:"http://static.fuxicarbon.com/hs-cti/ring.wav",_waitAudio:"http://static.fuxicarbon.com/hs-cti/manual.wav",_byeAudio:"http://static.fuxicarbon.com/hs-cti/bye.wav"},ie=function(n){function r(t){var r=this,i=t.saas_id,s=t.agent_id,a=t.scene,c=t.env,l=t.loggerLevel;r=n.call(this)||this,Object.defineProperty(r,"logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"loggerLevel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"scene",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"agent_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"saas_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_initOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_socket",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_sipUserAgent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_ctiFlowIdList",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_baseParams",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_waitAudio",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_ringAudio",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_byeAudio",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_remoteAudio",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_ctiStatus",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_ctiStatusList",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_sipStatus",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_sipStatusList",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_socketStatus",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_socketStatusList",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_callStatus",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_terminatedStatusList",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),r.loggerLevel=window.ctiLoggerLevel||l||e.LoggerLevels.log,r.logger=new A(r.loggerLevel,"HsCTI"),r._waitAudio=new Audio,r._ringAudio=new Audio,r._byeAudio=new Audio,r._remoteAudio=new Audio,r.saas_id=i,r.agent_id=s,r.scene=a,r._callId="",N(E.ENV,c),N(E.LoggerLevel,r.loggerLevel),r._baseParams={agent_id:s,saas_id:i,scene:a};var u={agent_id:s,vcc_id:i,scene:a};if(a===e.Scene.Monitor){var d=t.monitorScene;r._baseParams=o(o({},r._baseParams),{monitorScene:d}),N(E.TrackParams,o(o({},u),{monitor_scene:d}),!0)}else N(E.TrackParams,u,!0);return r.initInstanceOptions(),r.setCTIStatus(e.CTIStatus.Initial),r._callStatus=e.CallStatus.Stopped,r._terminatedStatusList=[],r}return i(r,n),Object.defineProperty(r.prototype,"getCTIStatus",{get:function(){return this._ctiStatus},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"getSocketStatus",{get:function(){return this._socketStatus},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"getSIPStatus",{get:function(){return this._sipStatus},enumerable:!1,configurable:!0}),Object.defineProperty(r,"getInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return r.instance||(r.instance=new r(e)),N(E.TrackParams,{clientId:B()}),r.instance}}),Object.defineProperty(r.prototype,"initInstanceOptions",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._ctiFlowIdList=[],this._ctiStatusList=[],this._sipStatusList=[],this._socketStatusList=[],r.instance=void 0,this._initOptions=void 0,D()}}),Object.defineProperty(r.prototype,"clearSocketAndSip",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,t,n;null===(e=this._socket)||void 0===e||e.closeSocket(),null===(t=this._sipUserAgent)||void 0===t||t.unregister(),null===(n=this._sipUserAgent)||void 0===n||n.disconnect(),this._sipUserAgent=void 0}}),Object.defineProperty(r.prototype,"setAudioSrc",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this.logger.debug("media | 设置等待音 src: ".concat(re[e])),this[e].src=re[e],this[e].currentTime=0,this[e].autoplay=!1,this[e].loop=t}}),Object.defineProperty(r.prototype,"playAudio",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.logger.debug("media | 播放音频:".concat(e)),this[e].play()}}),Object.defineProperty(r.prototype,"stopLocalAudio",{enumerable:!1,configurable:!0,writable:!0,value:function(){switch(this.scene){case e.Scene.Robot:case e.Scene.Monitor:this.stopAudio(x.RingAudio,!0);break;case e.Scene.Manual:this.stopAudio(x.WaitAudio,!0)}}}),Object.defineProperty(r.prototype,"stopAudio",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this;this.logger.debug("media | 停止音频播放:".concat(e)),this[e].src="",setTimeout((function(){n.setAudioSrc(e,t)}),1e3)}}),Object.defineProperty(r.prototype,"init",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this._ctiStatusList.slice(-1)[0]===e.CTIStatus.Initial){switch(this.setAudioSrc(x.ByeAudio,!1),this.scene){case e.Scene.Robot:case e.Scene.Monitor:this.setAudioSrc(x.RingAudio,!0);break;case e.Scene.Manual:this.setAudioSrc(x.WaitAudio,!0)}this.getInitConfig()}}}),Object.defineProperty(r.prototype,"getInitConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(){return a(this,void 0,void 0,(function(){var t,n,r,i,s;return c(this,(function(a){switch(a.label){case 0:return[4,Z(this._baseParams)];case 1:return t=a.sent(),n=t.code,r=t.data,i=t.msg,s=o(o({},s=r),{imHeartTime:3,imRetryCount:3,fsHeartTime:60,fsRetryCount:3,fsRetryTime:60,fsRegisterExpireTime:84e3,ctiSessionId:"id-"+Date.now()+"-"+Math.floor(1e4*Math.random()),imWsServer:"ws://192.168.100.159:8091/ws/cs-im",imWsPath:"ws/cs-im"}),0===n&&s?(N(E.TrackParams,{sip_server:s.sipServer,cti_session_id:s.ctiSessionId}),this._initOptions=s,this.initSocket(s),this.initSip(s)):this.eventEmitAndTrack(e.CTIEvent.OnCtiError,{type:e.CTIErrorType.ServerTerminated,code:e.HskTerminatedCode.GetInitConfig,msg:0!==n||s?i:"未查到坐席",method:"getInitConfig",res_code:n}),[2]}}))}))}}),Object.defineProperty(r.prototype,"initSocket",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this;this.setSocketStatus({status:e.SocketStatus.Initial}),this._socket=new G({agent_id:this.agent_id,saas_id:this.saas_id,imWsServer:t.imWsServer,imWsPath:t.imWsPath,imHeartTime:t.imHeartTime,imRetryCount:t.imRetryCount,ctiSessionId:t.ctiSessionId,loggerLevel:this.loggerLevel}),this._socket.on(U.SocketDownEvent,(function(e){var t=e.eventData,r=t.eventName,i=t.ext;n.logger.log("socket server down | ".concat(r," | ").concat(JSON.stringify(i))),n.handleSocketDownEvent({eventName:r,ext:i})})),this._socket.on(U.SetSocketStatus,(function(e){console.log("set socket statussdsdsdsdsdsdds | ".concat(JSON.stringify(e))),n.setSocketStatus(e)})),this._socket.initSocket()}}),Object.defineProperty(r.prototype,"handleSocketDownEvent",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=t.eventName,r=t.ext,i=this._baseParams.ctiFlowId,o=r.ctiFlowId;[e.Scene.Manual,e.Scene.Monitor].includes(this.scene)&&i&&o&&i!==o?this.logger.error("cti_flow_id | 不一致! fe: ".concat(i,", server: ").concat(o,", eventName: ").concat(n)):this.serverEventEmit({eventName:n,ext:r})}}),Object.defineProperty(r.prototype,"serverEventEmit",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=t.eventName,r=t.ext,i=[e.CTIEvent.OnRingStart,e.CTIEvent.OnDetectedTone,e.CTIEvent.OnRingEnd];switch(n){case e.CTIEvent.OnRingStart:case e.CTIEvent.OnDetectedTone:this.stopLocalAudio();break;case e.CTIEvent.OnAgentWorkReport:break;case e.CTIEvent.OnCallEnd:this._callStatus=e.CallStatus.Stopped,N(E.TrackParams,{call_id:""});case e.CTIEvent.OnRingEnd:}i.includes(n)||this.eventEmitAndTrack(n,r)}}),Object.defineProperty(r.prototype,"initSip",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this;this.setSipStatus({status:e.SIPStatus.Initial});var r=t.wss_server,i={aor:t.sip_server,reconnectionAttempts:t.fsRetryCount,reconnectionDelay:t.fsRetryTime,optionsPingInterval:t.fsHeartTime,media:{remote:{audio:this._remoteAudio}},userAgentOptions:{gracefulShutdown:!0,authorizationPassword:t.phone_pwd,sessionDescriptionHandlerFactoryOptions:{constraints:{audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0},video:!1},peerConnectionConfiguration:{iceServers:[{urls:t.ice_server}]}}}};i.delegate=this.sipDelegate(),this._sipUserAgent=new d(r,i),this._sipUserAgent.connect().catch((function(t){var r="SIP UserAgent 启动失败:".concat(JSON.stringify(t));n.logger.error(r),n.setSipStatus({status:e.SIPStatus.Terminated,code:e.HskTerminatedCode.SIPInitUserAgent,error:r,method:"initSIPJS"})}))}}),Object.defineProperty(r.prototype,"sipDelegate",{enumerable:!1,configurable:!0,writable:!0,value:function(){var n=this;return{onServerConnect:function(){n._sipUserAgent.register()},onServerDisconnect:function(){n.setSipStatus({status:e.SIPStatus.Terminated})},onReconnectStart:function(){n.setSipStatus({status:e.SIPStatus.ReTry})},onReconnectFailed:function(){n.setSipStatus({status:e.SIPStatus.Terminated,code:e.HskTerminatedCode.SIPOnDisconnect,error:"超过重连次数,终止重连",method:"onReconnectFailed"}),n.setSipStatus({status:e.SIPStatus.Terminated})},onRegistered:function(){n.setSipStatus({status:e.SIPStatus.Ready})},onUserAgentStateChange:function(r){switch(r){case t.UserAgentState.Started:n.setSipStatus({status:e.SIPStatus.Started});break;case t.UserAgentState.Stopped:n.setSipStatus({status:e.SIPStatus.Terminated,code:n._sipStatusList.includes(e.SIPStatus.Started)?e.HskTerminatedCode.SIPUserAgentStateStopped:e.HskTerminatedCode.SIPInitUserAgent,error:"SIP UserAgentState 状态停止",method:"onUserAgentStateChange"})}},onInvite:function(r){var i=r.request.getHeader("P-LIBRA-CallId")||"";console.log(i,2888888888),n._callId=i,console.log(i,1888888888),N(E.TrackParams,{call_id:i}),n.sessionStateChangeAndTrack(r.state),[e.Scene.Robot,e.Scene.Monitor].includes(n.scene)&&(n.playAudio(x.RingAudio),console.log("playAudio",1888888888)),[e.Scene.Manual].includes(n.scene)&&(n.answer(),console.log("answer",1888888888)),r.delegate={onCancel:function(t){var r="sip_invitation_on_cancel | ".concat(JSON.stringify(t));n.logger.error(r),n.eventEmitAndTrack(e.CTIEvent.OnCtiError,{type:e.CTIErrorType.SdkError,code:e.SdkErrorCode.InvitationCancel,msg:"当前通话已结束",method:"sipDelegate"},r)}},r.stateChange.addListener((function(r){switch(n.sessionStateChangeAndTrack(r),r){case t.SessionState.Initial:case t.SessionState.Establishing:break;case t.SessionState.Established:[e.Scene.Robot,e.Scene.Monitor].includes(n.scene)&&n.stopLocalAudio();break;case t.SessionState.Terminating:break;case t.SessionState.Terminated:n.playAudio(x.ByeAudio),setTimeout((function(){n.stopAudio(x.ByeAudio,!1)}),1e3),n.stopLocalAudio(),n._callStatus=e.CallStatus.Stopped,N(E.TrackParams,{call_id:""})}}))}}}}),Object.defineProperty(r.prototype,"sessionStateChangeAndTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.eventEmitAndTrack(e.CTIEvent.OnSessionStatusChange,{status:t});var n="sip_session_state_".concat(t.replace(/\s/g,"").replace(/([A-Z])/g,"_$1").toLowerCase().replace(/^_/,"").replace(/_$/,""));this.logger.log(n)}}),Object.defineProperty(r.prototype,"setCTIStatus",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(t!==this.getCTIStatus){this._ctiStatus=t,this._ctiStatusList.push(t);var n="cti status | ".concat(t," | ").concat(this._ctiStatusList);t===e.CTIStatus.Terminated?(this.setSocketStatus({status:e.SocketStatus.Terminated}),this.setSipStatus({status:e.SIPStatus.Terminated}),this.stopLocalAudio(),this.logger.warn(n)):this.logger.debug(n),t===e.CTIStatus.Ready&&(this.setSocketStatus({status:e.SocketStatus.Ready}),this.setSipStatus({status:e.SIPStatus.Ready}),this._terminatedStatusList=[],this._ctiStatusList.includes(e.CTIStatus.ReTry)||this.checkIn())}}}),Object.defineProperty(r.prototype,"setSocketStatus",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=t.status,r=t.code,i=t.error;if(n!==this.getSocketStatus){this._socketStatus=n,this._socketStatusList.push(n);var o="socket status | ".concat(n," | ").concat(this._socketStatusList);n===e.SocketStatus.Terminated?this.logger.warn(o):this.logger.debug(o),this.socketOrSipStatusChange(n,this.getSIPStatus),i&&(this._terminatedStatusList.push(r),this.eventEmitAndTrack(e.CTIEvent.OnCtiError,{type:e.CTIErrorType.SdkTerminated,code:r,msg:r===e.HskTerminatedCode.SocketRepeatLogin?F.CTIRepeatLoginMsg:F.CommonNetworkErrorMsg,method:"setSocketStatus"},{error_msg:i,socket_status_list:this._socketStatusList,sip_status_list:this._sipStatusList,cti_status_list:this._ctiStatusList}),this.clearSocketAndSip())}}}),Object.defineProperty(r.prototype,"setSipStatus",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=t.status,r=t.code,i=t.error,o=t.method;if(n!==this.getSIPStatus){this._sipStatus=n,this._sipStatusList.push(n);var s="sip status | ".concat(n," | ").concat(this._sipStatusList);n===e.SIPStatus.Terminated?this.logger.warn(s):this.logger.debug(s),this.socketOrSipStatusChange(this.getSocketStatus,n),i&&(this._terminatedStatusList.push(r),this.eventEmitAndTrack(e.CTIEvent.OnCtiError,{type:e.CTIErrorType.SdkTerminated,code:r,msg:F.CommonNetworkErrorMsg,method:o||"setSipStatus"},{error_msg:i,socket_status_list:this._socketStatusList,sip_status_list:this._sipStatusList,cti_status_list:this._ctiStatusList}),this.clearSocketAndSip())}}}),Object.defineProperty(r.prototype,"socketOrSipStatusChange",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){t===e.SocketStatus.Ready&&n===e.SIPStatus.Ready&&this.setCTIStatus(e.CTIStatus.Ready),t!==e.SocketStatus.ReTry&&n!==e.SIPStatus.ReTry||this.setCTIStatus(e.CTIStatus.ReTry),t!==e.SocketStatus.Terminated&&n!==e.SIPStatus.Terminated||this.setCTIStatus(e.CTIStatus.Terminated)}}),Object.defineProperty(r.prototype,"eventEmitAndTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,r){this.logger.debug("sdk emit | ".concat(t," | ").concat(JSON.stringify(n))),t===e.CTIEvent.OnCtiError&&(this._callStatus=e.CallStatus.Stopped);try{this.emit(t,n),console.log(r)}catch(r){this.logger.error("业务监听 ".concat(t," 事件,处理回调时报错: ").concat(r))}}}),Object.defineProperty(r.prototype,"checkIn",{enumerable:!1,configurable:!0,writable:!0,value:function(){return a(this,void 0,void 0,(function(){var t;return c(this,(function(n){switch(n.label){case 0:return[4,(r=this._baseParams,X({baseUrl:z,url:"/open/agent/check-in",data:r}))];case 1:return 0===(t=n.sent()).code&&this.eventEmitAndTrack(e.CTIEvent.OnInitalSuccess,{saas_id:this.saas_id,agent_id:this.agent_id,scene:this.scene,phoneNum:this._initOptions.phone_num,sipServer:this._initOptions.sip_server}),[2,t]}var r}))}))}}),Object.defineProperty(r.prototype,"checkOut",{enumerable:!1,configurable:!0,writable:!0,value:function(){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,(t=this._baseParams,X({baseUrl:z,url:"/open/agent/check-out",data:t}))];case 1:return[2,e.sent()]}var t}))}))}}),Object.defineProperty(r.prototype,"getCtiFlowId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return a(this,void 0,void 0,(function(){var e,t,n;return c(this,(function(r){switch(r.label){case 0:return[4,ee(this._baseParams)];case 1:return e=r.sent(),t=e.code,n=e.data,0===t&&(this._baseParams.ctiFlowId=n,this._ctiFlowIdList.push(n),N(E.TrackParams,{cti_flow_id:n,cti_flow_id_list:JSON.stringify(this._ctiFlowIdList)})),[2,e]}}))}))}}),Object.defineProperty(r.prototype,"setIdle",{enumerable:!1,configurable:!0,writable:!0,value:function(){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,(t=this._baseParams,X({baseUrl:z,url:"/open/agent/idle",data:t}))];case 1:return[2,e.sent()]}var t}))}))}}),Object.defineProperty(r.prototype,"setBusy",{enumerable:!1,configurable:!0,writable:!0,value:function(){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,(t=this._baseParams,X({baseUrl:z,url:"/open/agent/busy",data:t}))];case 1:return[2,e.sent()]}var t}))}))}}),Object.defineProperty(r.prototype,"makeCall",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return this._callStatus===e.CallStatus.Started?[2]:(this._callStatus=e.CallStatus.Started,[4,this.getCtiFlowId()]);case 1:return n.sent(),this.playAudio(x.WaitAudio),[4,this.serverCall(t)];case 2:return[2,n.sent()]}}))}))}}),Object.defineProperty(r.prototype,"serverCall",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=t.called,r=t.caller,i=t.ext;return a(this,void 0,void 0,(function(){var t,s,a,l;return c(this,(function(c){switch(c.label){case 0:return t=o(o(o({},this._baseParams),{called:n,caller:r}),i),[4,K(t)];case 1:return s=c.sent(),a=s.code,l=s.data,0===a?""===this._callId&&l&&(this._callId=l,N(E.TrackParams,{call_id:l})):(this._callStatus=e.CallStatus.Stopped,this.stopLocalAudio()),[2,s]}}))}))}}),Object.defineProperty(r.prototype,"answer",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this;return new Promise((function(n,r){var i;null===(i=t._sipUserAgent)||void 0===i||i.answer({sessionDescriptionHandlerOptions:{constraints:{audio:!0,video:!1}}}).then((function(){n({code:0,data:"answer",msg:"SIP 接起电话成功"}),t.logger.debug("sip_accept_success")})).catch((function(n){var i={type:e.CTIErrorType.SdkError,code:e.SdkErrorCode.Answer,msg:t.scene===e.Scene.Manual?F.ManualCallAnswerErrorMsg:F.RobotOrWeChatAnswerErrorMsg,method:"answer"};r(i),t.eventEmitAndTrack(e.CTIEvent.OnCtiError,i,"".concat(n)),t.logger.error("".concat(e.CTIEvent.OnCtiError," | ").concat(n))}))}))}}),Object.defineProperty(r.prototype,"bye",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this;return new Promise((function(n,r){var i;null===(i=t._sipUserAgent)||void 0===i||i.hangup().then((function(){n({code:0,data:"bye",msg:"SIP 挂断电话成功"}),t.logger.debug("sip_bye_success")})).catch((function(n){var i={type:e.CTIErrorType.SdkError,code:e.SdkErrorCode.Bye,msg:F.SipByeErrorMsg,method:"bye"};r(i),"Session does not exist."!==n.message&&t.eventEmitAndTrack(e.CTIEvent.OnCtiError,i,"".concat(n)),t.logger.error("".concat(e.CTIEvent.OnCtiError," | ").concat(n))}))}))}}),Object.defineProperty(r.prototype,"serverBye",{enumerable:!1,configurable:!0,writable:!0,value:function(){return a(this,void 0,void 0,(function(){var t,n;return c(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.bye(),this._baseParams.ctiFlowId||this.scene!==e.Scene.Manual?[4,this.turnHang()]:[2];case 1:return t=r.sent(),[2,Promise.resolve(t)];case 2:return n=r.sent(),[2,Promise.reject(n)];case 3:return[2]}}))}))}}),Object.defineProperty(r.prototype,"turnHang",{enumerable:!1,configurable:!0,writable:!0,value:function(){return a(this,void 0,void 0,(function(){var e;return c(this,(function(t){switch(t.label){case 0:return[4,(n=o(o({},this._baseParams),{callId:this._callId}),X({baseUrl:z,url:"/open/agent/manual-hang",data:n}))];case 1:return e=t.sent(),this._callId="",[2,e]}var n}))}))}}),Object.defineProperty(r.prototype,"getAgentStatus",{enumerable:!1,configurable:!0,writable:!0,value:function(){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,(t=this._baseParams,X({baseUrl:z,url:"/open/agent/agent-state",data:t}))];case 1:return[2,e.sent()]}var t}))}))}}),Object.defineProperty(r.prototype,"loadAgentGroupData",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return a(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,(n=o(o({},this._baseParams),{monitorIds:e}),X({baseUrl:z,url:"/open/monitor/load-agent-group-data",data:n}))];case 1:return[2,t.sent()]}var n}))}))}}),Object.defineProperty(r.prototype,"listen",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return a(this,void 0,void 0,(function(){var t;return c(this,(function(n){switch(n.label){case 0:return[4,this.getCtiFlowId()];case 1:return(t=n.sent())&&0!==t.code?[2,t]:[4,(r=o(o({},this._baseParams),{agent_id:e,leaderAgentId:this.agent_id}),X({baseUrl:z,url:"/open/agent/listen",data:r}))];case 2:return[2,n.sent()]}var r}))}))}}),Object.defineProperty(r.prototype,"setActiveService",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return a(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,(n=o(o({},this._baseParams),{serviceId:e}),X({baseUrl:z,url:"/open/human-service/member-active",data:n}))];case 1:return[2,t.sent()]}var n}))}))}}),Object.defineProperty(r.prototype,"unInit",{enumerable:!1,configurable:!0,writable:!0,value:function(){return a(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this.checkOut()];case 1:return t.sent(),this.setCTIStatus(e.CTIStatus.Terminated),this.initInstanceOptions(),this.clearSocketAndSip(),this._callId="",[2]}}))}))}}),s([function(t,n,r){var i=r.value;return r.value=function(){for(var t=this,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];navigator&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia?navigator.mediaDevices.getUserMedia({audio:!0,video:!1}).then((function(){return t.logger.debug("media | getUserMedia | 获取浏览器媒体权限成功"),i.apply(t,n)})).catch((function(n){t.logger.error("media | getUserMedia | ".concat(n)),t.eventEmitAndTrack(e.CTIEvent.OnCtiError,{type:e.CTIErrorType.SdkTerminated,code:e.HskTerminatedCode.GetUserMedia,msg:"NotAllowedError"===n.name?"用户拒绝了获取麦克风权限!":"获取麦克风权限失败",method:"getUserMedia"},{source:H.FeMedia,event_name:"get_user_media_error",error:n.name})})):(this.logger.error("media | getUserMedia | 浏览器版本过低,不支持获取媒体权限"),this.eventEmitAndTrack(e.CTIEvent.OnCtiError,{type:e.CTIErrorType.SdkTerminated,code:e.HskTerminatedCode.GetUserMedia,msg:"浏览器版本过低,不支持获取媒体权限",method:"getUserMedia"},{source:H.FeMedia,event_name:"get_user_media_not_support"}))},r}],r.prototype,"init",null),s([te("签入"),ne()],r.prototype,"checkIn",null),s([te("签出"),ne()],r.prototype,"checkOut",null),s([ne()],r.prototype,"getCtiFlowId",null),s([te("置闲"),ne()],r.prototype,"setIdle",null),s([te("置忙"),ne()],r.prototype,"setBusy",null),s([te("人工外呼")],r.prototype,"makeCall",null),s([ne()],r.prototype,"serverCall",null),s([te("接起")],r.prototype,"answer",null),s([te("挂断")],r.prototype,"bye",null),s([ne()],r.prototype,"turnHang",null),s([ne()],r.prototype,"getAgentStatus",null),s([te("获取监听组成员"),ne()],r.prototype,"loadAgentGroupData",null),s([te("坐席监听"),ne()],r.prototype,"listen",null),s([te("签入人工组"),ne()],r.prototype,"setActiveService",null),s([function(t,n,r){var i=r.value;return r.value=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t[0];return(r.scene===e.Scene.Monitor?V:J).forEach((function(e){if(!r[e])throw"参数[".concat(e,"]为必填参数")})),i.apply(this,t)},r}],r,"getInstance",null),r}(m);e.Logger=A,e.getInstance=function(e){return ie.getInstance(e)}}));