@94ai/softphone
Advanced tools
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" | ||
| content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" /> | ||
| <title>softphone</title> | ||
| <style> | ||
| .nf-transparent { | ||
| visibility: hidden; | ||
| } | ||
| .nf-softphone-text { | ||
| text-align: center; | ||
| line-height: 32px; | ||
| margin-top: -32px; | ||
| } | ||
| .nf-softphone-container { | ||
| margin-left: 10px; | ||
| height: 32px; | ||
| min-width: 600px; | ||
| } | ||
| .nf-softphone-iframe-container { | ||
| height: 32px; | ||
| width: 100%; | ||
| overflow: visible; | ||
| } | ||
| .nf-softphone-iframe { | ||
| width: 100vw; | ||
| height: 100vh; | ||
| top: 0; | ||
| left: 0; | ||
| } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <div id='softpone-context1' style='overflow: hidden'> | ||
| <div style="display: flex;height: 32px;"> | ||
| <div style="min-width: 600px;width: 600px;" id='softphone1'></div> | ||
| </div> | ||
| </div> | ||
| <script> | ||
| function generateUUID() { // Public Domain/MIT | ||
| let d = Date.now(); | ||
| if (typeof performance !== 'undefined' && typeof performance.now === 'function'){ | ||
| d += performance.now(); //use high-precision timer if available | ||
| } | ||
| return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { | ||
| const r = (d + Math.random() * 16) % 16 | 0; | ||
| d = Math.floor(d / 16); | ||
| return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16); | ||
| }); | ||
| } | ||
| function debounce(func, wait, immediate) { | ||
| let timeout, args, context, timestamp, result | ||
| const later = function() { | ||
| // 据上一次触发时间间隔 | ||
| const last = +new Date() - timestamp | ||
| // 上次被包装函数被调用时间间隔last小于设定时间间隔wait | ||
| if (last < wait && last > 0) { | ||
| timeout = setTimeout(later, wait - last) | ||
| } else { | ||
| timeout = null | ||
| // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用 | ||
| if (!immediate) { | ||
| result = func.apply(context, args) | ||
| if (!timeout) context = args = null | ||
| } | ||
| } | ||
| } | ||
| return function(...args) { | ||
| // @ts-ignore | ||
| context = this | ||
| timestamp = +new Date() | ||
| const callNow = immediate && !timeout | ||
| // 如果延时不存在,重新设定延时 | ||
| if (!timeout) timeout = setTimeout(later, wait) | ||
| if (callNow) { | ||
| result = func.apply(context, args) | ||
| // @ts-ignore | ||
| context = args = null | ||
| } | ||
| return result | ||
| } | ||
| } | ||
| // 用于存储传入 nextTick 的回调函数 | ||
| const callbacks = []; | ||
| // 标记是否已经安排了回调函数的执行 | ||
| let pending = false; | ||
| // 执行队列中的所有回调函数 | ||
| function flushCallbacks() { | ||
| pending = false; | ||
| // 复制一份当前的回调队列,避免在执行过程中添加新的回调影响循环 | ||
| const copies = callbacks.slice(0); | ||
| callbacks.length = 0; | ||
| // 依次执行每个回调函数,并处理可能出现的异常 | ||
| for (let i = 0; i < copies.length; i++) { | ||
| try { | ||
| copies[i](); | ||
| } catch (e) { | ||
| console.error('Error in nextTick callback:', e); | ||
| } | ||
| } | ||
| } | ||
| // 根据浏览器支持情况选择合适的异步执行方式 | ||
| let timerFunc; | ||
| if (typeof Promise !== 'undefined') { | ||
| // 如果支持 Promise,使用 Promise 的 then 方法创建微任务 | ||
| const p = Promise.resolve(); | ||
| timerFunc = () => { | ||
| p.then(flushCallbacks); | ||
| }; | ||
| } else if (typeof MutationObserver !== 'undefined') { | ||
| // 如果支持 MutationObserver,使用它创建微任务 | ||
| let counter = 1; | ||
| const observer = new MutationObserver(flushCallbacks); | ||
| const textNode = document.createTextNode(String(counter)); | ||
| observer.observe(textNode, { | ||
| characterData: true | ||
| }); | ||
| timerFunc = () => { | ||
| counter = (counter + 1) % 2; | ||
| textNode.data = String(counter); | ||
| }; | ||
| } else if (typeof setImmediate !== 'undefined') { | ||
| // 如果支持 setImmediate,使用它创建宏任务 | ||
| timerFunc = () => { | ||
| setImmediate(flushCallbacks); | ||
| }; | ||
| } else { | ||
| // 最后使用 setTimeout 作为兜底方案创建宏任务 | ||
| timerFunc = () => { | ||
| setTimeout(flushCallbacks, 0); | ||
| }; | ||
| } | ||
| // 实现 nextTick 函数,支持传入回调函数或返回 Promise | ||
| async function nextTick(cb) { | ||
| return new Promise((resolve) => { | ||
| // 将回调函数和 resolve 函数封装成一个新的回调 | ||
| callbacks.push(() => { | ||
| if (cb) { | ||
| try { | ||
| cb(); | ||
| } catch (e) { | ||
| console.error('Error in nextTick callback:', e); | ||
| } | ||
| } | ||
| // 当回调执行完毕后,resolve Promise | ||
| resolve(true); | ||
| }); | ||
| // 如果当前没有正在执行的回调安排,安排一次新的执行 | ||
| if (!pending) { | ||
| pending = true; | ||
| timerFunc(); | ||
| } | ||
| }); | ||
| } | ||
| class SoftphoneManager { | ||
| id | ||
| timer | ||
| constructor() { | ||
| /** | ||
| * 隔离链接实例 | ||
| */ | ||
| this.id = generateUUID() | ||
| } | ||
| option = { | ||
| origin: 'ai-softphone', | ||
| ancestorOrigin: 'nf-softphone', | ||
| destinationOrigin: '*', | ||
| scrollview: undefined, | ||
| scrollingText: '正在滚动中...', | ||
| envMap: { | ||
| test: 'http://softphone.test.k8s.com', | ||
| dev: 'http://softphone.dev.k8s.com', | ||
| sg: 'https://seatsg.94ai.com', | ||
| gray: 'http://softphone.gray.94ai.com', | ||
| prod: 'https://seat.94ai.com', | ||
| }, | ||
| env: 'prod', | ||
| selector: undefined, | ||
| el: undefined, | ||
| agentId: undefined, | ||
| agentTag: undefined, | ||
| appKey: undefined, | ||
| appSecret: undefined, | ||
| sgGateway: undefined, | ||
| sgBase: undefined, | ||
| sgOpen: undefined, | ||
| sgDomain: undefined, | ||
| timestamp: undefined, | ||
| sign: undefined, | ||
| extStatus: '0', | ||
| callShow: '1', | ||
| transferToLaborShow: '1', | ||
| restShow: '1', | ||
| networkDetectShow: '1', | ||
| muteShow: '1', | ||
| logShow: '1', | ||
| timingShow: '1', | ||
| signShow: '1', | ||
| instanceMap: {}, | ||
| softphoneConnectCallBack: () => {console.log('softphone-connect')}, | ||
| softphoneCallRefreshCallBack: () => {console.log('softphone-call-refresh')}, | ||
| softphoneSeatStatusChangeCallBack: () => {console.log('softphone-seats-status-change')}, | ||
| softphoneAcceptCallBack: () => {console.log('softphone-accept')}, | ||
| softphoneIgnoreCallBack: () => {console.log('softphone-ignore')}, | ||
| softphoneHangupCallBack: () => {console.log('softphone-hangup')}, | ||
| softphoneSessionStateChangeCallBack: () => {console.log('softphone-session-state-change')}, | ||
| softphoneIncomingCallBack: () => {console.log('softphone-incoming')}, | ||
| softphoneSendDtmfCallBack: () => {console.log('softphone-send-dtmf')}, | ||
| softphoneConnectRegisteredCallBack: () => {console.log('softphone-connect-registered')}, | ||
| softphoneSignOverduedCallBack: (done) => { | ||
| done({ | ||
| timestamp: undefined, | ||
| sign: undefined | ||
| }) | ||
| }, | ||
| } | ||
| loadCssCode = (code) => { | ||
| const styleId = 'nf-softphone' | ||
| if (!document.getElementById(styleId)) { | ||
| const style = document.createElement('style'); | ||
| style.id = styleId | ||
| style.type = 'text/css'; | ||
| // @ts-ignore | ||
| style.rel = 'stylesheet'; | ||
| //for Chrome Firefox Opera Safari | ||
| style.appendChild(document.createTextNode(code)); | ||
| //for IE | ||
| //style.styleSheet.cssText = code; | ||
| const head = document.getElementsByTagName('head')[0]; | ||
| head.appendChild(style); | ||
| } | ||
| } | ||
| removeCssCode = () => { | ||
| const styleId = 'nf-softphone' | ||
| const css = document.getElementById(styleId) | ||
| if (css) { | ||
| if (css.parentNode) { | ||
| css.parentNode.removeChild(css); | ||
| } | ||
| } | ||
| } | ||
| /** | ||
| * 隔离软电话容器 | ||
| */ | ||
| getContextDomElement = (el) => { | ||
| return (this.option.selector ? (document.querySelector(this.option.selector) ?? document) : document).querySelector(el) | ||
| } | ||
| /** | ||
| * 隔离软电话容器内容 | ||
| */ | ||
| getSoftphoneDomElement = (el) => { | ||
| return this.getContextDomElement(this.option.el).querySelector(el) || this.getContextDomElement(el) || document.querySelector(el) | ||
| } | ||
| signOverdued = (data) => { | ||
| const iframe = this.getSoftphoneDomElement('.nf-softphone-iframe') | ||
| iframe?.contentWindow?.postMessage(JSON.stringify({ | ||
| origin: 'nf-softphone', | ||
| ancestorOrigin: this.option.ancestorOrigin, | ||
| destinationOrigin: 'ai-softphone', | ||
| type: 'softphone-sign-overdued', | ||
| data | ||
| }), '*') | ||
| } | ||
| handlingCommunication = (e) => { | ||
| const iframe = this.getSoftphoneDomElement('.nf-softphone-iframe') | ||
| if (iframe) { | ||
| let data = {} | ||
| try { | ||
| data = JSON.parse(e.data) | ||
| } catch (e) {} | ||
| if ((data.ancestorOrigin === this.option.ancestorOrigin && data.origin !== this.option.ancestorOrigin) || | ||
| (data.ancestorOrigin === this.option.origin && data.origin === this.option.origin)) { | ||
| if (data.destinationOrigin === '*' || data.destinationOrigin === this.option.destinationOrigin) { | ||
| if (data.type === 'softphone-expand') { | ||
| if (data.data === 'expand') { | ||
| iframe.setAttribute('style', 'position: fixed;z-index:999;'); | ||
| } else if (data.data === 'shrink') { | ||
| iframe.removeAttribute('style'); | ||
| } | ||
| return | ||
| } | ||
| if (data.type === 'softphone-connect') { | ||
| this.option.softphoneConnectCallBack?.(data) | ||
| } else if (data.type === 'softphone-call-refresh') { | ||
| this.option.softphoneCallRefreshCallBack?.(data) | ||
| } else if (data.type === 'softphone-seats-status-change') { | ||
| this.option.softphoneSeatStatusChangeCallBack?.(data) | ||
| } else if (data.type === 'softphone-accept') { | ||
| this.option.softphoneAcceptCallBack?.(data) | ||
| } else if (data.type === 'softphone-ignore') { | ||
| this.option.softphoneIgnoreCallBack?.(data) | ||
| } else if (data.type === 'softphone-hangup') { | ||
| this.option.softphoneHangupCallBack?.(data) | ||
| } else if (data.type === 'softphone-session-state-change') { | ||
| this.option.softphoneSessionStateChangeCallBack?.(data) | ||
| } else if (data.type === 'softphone-incoming') { | ||
| this.option.softphoneIncomingCallBack?.(data) | ||
| } else if (data.type === 'softphone-send-dtmf') { | ||
| this.option.softphoneSendDtmfCallBack?.(data) | ||
| } else if (data.type === 'softphone-connect-registered') { | ||
| this.option.softphoneConnectRegisteredCallBack?.(data) | ||
| } else if (data.type === 'softphone-sign-overdued') { | ||
| const done = (data) => { | ||
| const { | ||
| sign, | ||
| timestamp | ||
| } = data | ||
| this.signOverdued({ | ||
| sign, | ||
| timestamp | ||
| }) | ||
| } | ||
| this.option.softphoneSignOverduedCallBack?.(done) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| handlingScroll = debounce(async () => { | ||
| const { | ||
| top, | ||
| left, | ||
| } = (await this.refreshStyle() || {}) | ||
| if (top && left) { | ||
| (this.getSoftphoneDomElement('.nf-softphone-iframe')).contentWindow.postMessage(JSON.stringify({ | ||
| type: 'softphone-scroll', | ||
| origin: this.option.origin, | ||
| ancestorOrigin: this.option.ancestorOrigin, | ||
| destinationOrigin: this.option.destinationOrigin, | ||
| data: { | ||
| paddingTop: top + 'px', | ||
| } | ||
| }), '*') | ||
| } | ||
| }, 500, false) | ||
| handlerInteractive = () => { | ||
| /** | ||
| * 实时处理层级 | ||
| */ | ||
| window.addEventListener('message', this.handlingCommunication, false); | ||
| if (this.option.scrollview) { | ||
| document.querySelector(this.option.scrollview)?.addEventListener('scroll', this.handlingScroll) | ||
| document.querySelector(this.option.scrollview)?.addEventListener('scroll', this.handlingScrollTransparent) | ||
| } | ||
| this.loadCssCode(` | ||
| .nf-transparent { | ||
| visibility: hidden; | ||
| } | ||
| .nf-softphone-text { | ||
| text-align: center; | ||
| line-height: 32px; | ||
| margin-top: -32px; | ||
| } | ||
| .nf-softphone-container { | ||
| margin-left: 10px; | ||
| height: 32px; | ||
| min-width: 600px; | ||
| } | ||
| .nf-softphone-iframe-container { | ||
| height: 32px; | ||
| width: 100%; | ||
| overflow: visible; | ||
| } | ||
| .nf-softphone-iframe { | ||
| width: 100vw; | ||
| height: 100vh; | ||
| top: 0; | ||
| left: 0; | ||
| } | ||
| `); | ||
| } | ||
| handlerDomRemove = () => { | ||
| Object.keys(this.option.instanceMap).forEach(key => { | ||
| const el = document.getElementById(key) | ||
| if (el && el.parentNode) { | ||
| el.parentNode.removeChild(el) | ||
| } | ||
| }) | ||
| } | ||
| _containerScrolling | ||
| get containerScrolling() { | ||
| return this._containerScrolling | ||
| } | ||
| set containerScrolling(value) { | ||
| if (this.containerScrolling !== value) { | ||
| this._containerScrolling = value | ||
| const nfSoftphoneContainer = this.getSoftphoneDomElement('.nf-softphone-container') | ||
| const nfSoftphoneText = this.getSoftphoneDomElement('.nf-softphone-text') | ||
| nfSoftphoneContainer?.setAttribute('class', `nf-softphone-container ${value === true ? 'nf-transparent' : ''}`) | ||
| nfSoftphoneText?.setAttribute('style', `display: ${value === true ? 'block' : 'none'}`) | ||
| } | ||
| } | ||
| handlingScrollTransparent = () => { | ||
| this.containerScrolling = true | ||
| } | ||
| refreshStyle = async () => { | ||
| clearTimeout(this.timer) | ||
| this.timer = undefined | ||
| const nfSoftphoneContainer = this.getSoftphoneDomElement('.nf-softphone-container') | ||
| const nfSoftphoneIframeContainer = this.getSoftphoneDomElement('.nf-softphone-iframe-container') | ||
| if (nfSoftphoneContainer && nfSoftphoneIframeContainer) { | ||
| const containerStyle = nfSoftphoneContainer.getAttribute('style') | ||
| const iframeContainerStyle = nfSoftphoneIframeContainer.getAttribute('style') | ||
| nfSoftphoneContainer.removeAttribute('style') | ||
| nfSoftphoneIframeContainer.removeAttribute('style') | ||
| const leftMargin = getComputedStyle(nfSoftphoneContainer).marginLeft | ||
| const top = nfSoftphoneContainer.getBoundingClientRect().top | ||
| if (top <= 0) { | ||
| nfSoftphoneContainer.setAttribute('style', containerStyle) | ||
| nfSoftphoneIframeContainer.setAttribute('style', iframeContainerStyle) | ||
| return { | ||
| top: 0, | ||
| left: 0, | ||
| leftMargin | ||
| } | ||
| } | ||
| const left = nfSoftphoneContainer.getBoundingClientRect().left | ||
| if (left <= 0) { | ||
| nfSoftphoneContainer.setAttribute('style', containerStyle) | ||
| nfSoftphoneIframeContainer.setAttribute('style', iframeContainerStyle) | ||
| return { | ||
| top: 0, | ||
| left: 0, | ||
| leftMargin | ||
| } | ||
| } | ||
| nfSoftphoneContainer.setAttribute('style', `margin-top:${top}px;margin-left:${leftMargin};margin-bottom:${top}px;`) | ||
| nfSoftphoneIframeContainer.setAttribute('style', `margin-top:-${2 * top}px;margin-left:-${left}px;`) | ||
| this.timer = setTimeout(() => { | ||
| clearTimeout(this.timer) | ||
| this.timer = undefined | ||
| this.containerScrolling = false | ||
| }, 100) | ||
| return { | ||
| leftMargin, | ||
| top, | ||
| left | ||
| } | ||
| } | ||
| return { | ||
| leftMargin: 0, | ||
| top: 0, | ||
| left: 0 | ||
| } | ||
| } | ||
| handlerDomGenerater = async () => { | ||
| const nfSoftphone = document.createElement('div'); | ||
| const nfSoftphoneText = document.createElement('div'); | ||
| nfSoftphoneText.innerText = this.option.scrollingText || '正在滚动中...' | ||
| const nfSoftphoneContainer = document.createElement('div'); | ||
| const iframeContainer = document.createElement('div'); | ||
| const iframe = document.createElement('iframe'); | ||
| const uuid = this.id + '-container' | ||
| this.option.instanceMap[uuid] = nfSoftphone | ||
| nfSoftphone.setAttribute('id', uuid) | ||
| nfSoftphone.setAttribute('class', 'nf-softphone') | ||
| nfSoftphoneText.setAttribute('class', 'nf-softphone-text') | ||
| nfSoftphoneText.setAttribute('style', "display: none;") | ||
| nfSoftphoneContainer.setAttribute('class', "nf-softphone-container") | ||
| iframeContainer.setAttribute('class', "nf-softphone-iframe-container") | ||
| iframe.setAttribute('class', "nf-softphone-iframe") | ||
| iframe.setAttribute('src', "") | ||
| iframe.setAttribute('frameborder', "0") | ||
| iframe.setAttribute('scrolling', "no") | ||
| iframe.setAttribute('allow', "camera *; microphone *") | ||
| iframeContainer.appendChild(iframe) | ||
| nfSoftphoneContainer.appendChild(iframeContainer) | ||
| nfSoftphone.appendChild(nfSoftphoneContainer) | ||
| nfSoftphone.appendChild(nfSoftphoneText) | ||
| const destination = (this.option.el ? this.getSoftphoneDomElement(this.option.el) ?? document.body : document.body) | ||
| destination.appendChild(nfSoftphone) | ||
| await nextTick() | ||
| const { | ||
| top, | ||
| left, | ||
| } = await this.refreshStyle() | ||
| const { | ||
| envMap, | ||
| env, | ||
| agentTag, | ||
| agentId, | ||
| appSecret, | ||
| extStatus, | ||
| appKey, | ||
| ancestorOrigin, | ||
| destinationOrigin, | ||
| callShow, | ||
| transferToLaborShow, | ||
| restShow, | ||
| networkDetectShow, | ||
| muteShow, | ||
| logShow, | ||
| timingShow, | ||
| signShow, | ||
| sign, | ||
| timestamp, | ||
| sgGateway, | ||
| sgBase, | ||
| sgOpen, | ||
| sgDomain, | ||
| } = this.option | ||
| let url = `${ envMap?.[env] ?? env }/#/?cross=1&open=1` | ||
| url += agentTag ? `&agentTag=${agentTag}` : '' | ||
| url += agentId ? `&agentId=${agentId}` : '' | ||
| url += appSecret ? `&appSecret=${appSecret}` : '' | ||
| url += sign ? `&sign=${sign}` : '' | ||
| url += timestamp ? `×tamp=${timestamp}` : '' | ||
| url += sgGateway ? `&sgGateway=${sgGateway}` : '' | ||
| url += sgBase ? `&sgBase=${sgBase}` : '' | ||
| url += sgOpen ? `&sgOpen=${sgOpen}` : '' | ||
| url += sgDomain ? `&sgDomain=${sgDomain}` : '' | ||
| url += `&appKey=${appKey}&extStatus=${extStatus}&paddingTop=${top}px&paddingLeft=${left}px&ancestorOrigin=${ancestorOrigin}&destinationOrigin=${destinationOrigin}` | ||
| url += `&callShow=${callShow}` | ||
| url += `&transferToLaborShow=${transferToLaborShow}` | ||
| url += `&restShow=${restShow}` | ||
| url += `&networkDetectShow=${networkDetectShow}` | ||
| url += `&muteShow=${muteShow}` | ||
| url += `&logShow=${logShow}` | ||
| url += `&timingShow=${timingShow}` | ||
| url += `&signShow=${signShow}` | ||
| iframe.src = url | ||
| } | ||
| initSoftphone = (option) => { | ||
| this.option = option ? { ...this.option, ...option } :this.option | ||
| this.handlerInteractive() | ||
| this.handlerDomGenerater() | ||
| return this | ||
| } | ||
| postMessageCommunicate = (type, status) => { | ||
| const iframe = this.getSoftphoneDomElement('.nf-softphone-iframe') | ||
| if (iframe) { | ||
| iframe.contentWindow.postMessage(JSON.stringify({ | ||
| origin: 'nf-softphone', | ||
| ancestorOrigin: this.option.ancestorOrigin, | ||
| destinationOrigin: this.option.destinationOrigin, | ||
| type, | ||
| data: { | ||
| status, | ||
| type: 'manual' | ||
| } | ||
| }), '*') | ||
| } | ||
| } | ||
| connect = () => { | ||
| this.postMessageCommunicate('softphone-connect', true) | ||
| } | ||
| disconnect = () => { | ||
| this.postMessageCommunicate('softphone-connect', false) | ||
| } | ||
| seatsStatusChange = (status) => { | ||
| this.postMessageCommunicate('softphone-seats-status-change', status) | ||
| } | ||
| accept = () => { | ||
| this.postMessageCommunicate('softphone-accept') | ||
| } | ||
| ignore = () => { | ||
| this.postMessageCommunicate('softphone-ignore') | ||
| } | ||
| hangup = () => { | ||
| this.postMessageCommunicate('softphone-hangup') | ||
| } | ||
| sendDtmf = () => { | ||
| this.postMessageCommunicate('softphone-send-dtmf') | ||
| } | ||
| removeTimer = () => { | ||
| clearTimeout(this.timer) | ||
| this.timer = undefined | ||
| } | ||
| destroy = () => { | ||
| window.removeEventListener('message', this.handlingCommunication, false); | ||
| if (this.option.scrollview) { | ||
| document.querySelector(this.option.scrollview)?.removeEventListener('scroll', this.handlingScroll) | ||
| document.querySelector(this.option.scrollview)?.removeEventListener('scroll', this.handlingScrollTransparent) | ||
| } | ||
| this.removeCssCode() | ||
| this.handlerDomRemove() | ||
| this.removeTimer() | ||
| } | ||
| } | ||
| const softphoneManager = new SoftphoneManager() | ||
| const agentTag1 = 'zoujh-test' | ||
| const appKey1 = '032d44009bff1752' | ||
| const appSecret1 = '4c7304c94c5e8725613516d4d6db679b' | ||
| /** | ||
| 👈 拿到实例后可以手动触发软电话实例的各种动作,如签入,签出,接听,忽略,挂断等等,注意这个实例不是软电话实例,是链接软电话通讯的实例 | ||
| */ | ||
| const nfSoftPhone1 = (new SoftphoneManager()).initSoftphone({ // 👈 当多实例时使用类创建新实例 | ||
| el: '#softphone1', // 👈 软电话容器 | ||
| selector: '#softpone-context1', // 👈 软电话容器查询上下文,用于多实例隔离软电话dom的查询环境 | ||
| ancestorOrigin: 'nf-softphone1', // origin,ancestorOrigin,destinationOrigin具体含义参见下文,如果是单实例,可以写死origin=ai-softphone&destinationOrigin=nf-softphone&ancestorOrigin=nf-softphone | ||
| destinationOrigin: 'nf-softphone1', | ||
| agentTag: agentTag1, // 👈 坐席唯一标志 | ||
| appKey: appKey1, // 👈 企业appKey | ||
| appSecret: appSecret1, | ||
| extStatus: '1', // 👈 初始化是否处于小休状态, 非1 小休 1 在线 | ||
| softphoneConnectCallBack: (data) => { | ||
| console.log('softphone-connect') | ||
| }, // 👈 签入签出回调 | ||
| softphoneCallRefreshCallBack: (data) => {console.log('softphone-call-refresh')}, // 👈 来电刷新来电记录列表回调 | ||
| softphoneSeatStatusChangeCallBack: (data) => {console.log('softphone-seats-status-change')},// 👈 小休和在线切换回调 | ||
| softphoneAcceptCallBack: (data) => {console.log('softphone-accept')},// 👈 接听回调 | ||
| softphoneIgnoreCallBack: (data) => {console.log('softphone-ignore')},// 👈 忽略回调 | ||
| softphoneHangupCallBack: (data) => {console.log('softphone-hangup')},// 👈 挂断回调 | ||
| softphoneSessionStateChangeCallBack: (data) => {console.log('softphone-session-state-change')},// 👈 会话状态改变回调 | ||
| softphoneIncomingCallBack: (data) => {console.log('softphone-incoming')},// 👈 来电回调 | ||
| softphoneSendDtmfCallBack: (data) => {console.log('softphone-send-dtmf')},// 👈 转人工回调 | ||
| softphoneConnectRegisteredCallBack: (data) => {console.log('softphone-connect-registered')},// 👈 动态绑定动作完成回调(在这之后才能执行动作类总线通讯) | ||
| }); | ||
| </script> | ||
| </body> | ||
| </html> |
@@ -826,3 +826,14 @@ <!DOCTYPE html> | ||
| const callPhone = async () => { | ||
| const callInfo = await userAgentManager.callNumber(call.value) // 👈 一键 | ||
| // const callInfo = await userAgentManager.callNumber(call.value) // 👈 一键 | ||
| const callInfo = await userAgentManager.requestOpenApi({ // 主动外呼 | ||
| url: '/v1/task/importAgentCustomer', | ||
| data: { | ||
| agentTag: '15018707394', | ||
| callType: 1001, | ||
| customers: [{ | ||
| tag: '测试tag', | ||
| number: 18617381945 | ||
| }] | ||
| } | ||
| }) | ||
| if (callInfo.code === 200) { // 正确响应 | ||
@@ -829,0 +840,0 @@ alert('呼叫成功') |
@@ -1,1 +0,1 @@ | ||
| "use strict";var e,t,n=require("@babel/runtime-corejs3/helpers/esm/classCallCheck"),i=require("@babel/runtime-corejs3/helpers/esm/createClass"),r=require("sip.js"),s=require("sip.js/lib/platform/web/index.js"),a=require("on-change"),o=require("@babel/runtime-corejs3/helpers/esm/typeof"),c=require("@babel/runtime-corejs3/regenerator"),u=require("@babel/runtime-corejs3/core-js/json/stringify"),l=require("@babel/runtime-corejs3/core-js/object/define-property"),f=require("@babel/runtime-corejs3/core-js/date/now"),h=require("@babel/runtime-corejs3/core-js/instance/for-each"),d=require("@babel/runtime-corejs3/core-js/set-timeout"),p=require("@babel/runtime-corejs3/core-js/set-interval"),v=require("@babel/runtime-corejs3/core-js/promise"),g=require("@babel/runtime-corejs3/core-js/object/assign"),m=require("@babel/runtime-corejs3/core-js/instance/concat"),w=require("@babel/runtime-corejs3/core-js/instance/map"),b=require("@babel/runtime-corejs3/core-js/instance/index-of"),k=require("@babel/runtime-corejs3/core-js/instance/filter"),x=require("@babel/runtime-corejs3/core-js/weak-map"),y=require("@babel/runtime-corejs3/core-js/weak-set"),S=require("@babel/runtime-corejs3/core-js/object/keys"),A=require("@babel/runtime-corejs3/core-js/instance/pad-start"),I=require("@babel/runtime-corejs3/core-js/instance/slice"),T=require("crypto-js"),j=require("@fingerprintjs/fingerprintjs");function O(e,t,n,i){return new(n||(n=Promise))(function(r,s){function a(e){try{c(i.next(e))}catch(e){s(e)}}function o(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(a,o)}c((i=i.apply(e,t||[])).next())})}function C(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 q(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}"function"==typeof SuppressedError&&SuppressedError;var D,E,R,N,P=m(e="sip:".concat("","@")).call(e,""),M=m(t="".concat("","://")).call(t,""),U={authorizationPassword:"",authorizationUsername:"",viaHost:"",uri:r.UserAgent.makeURI(P),logLevel:"error",transportOptions:{server:M},contactName:""},H={connectStatus:!1,registerStatus:!1,invitatingStatus:!1,incomingStatus:!1,answerStatus:!1,reconnectStatus:!1};function z(e){return document.getElementById(e)}function L(e){if(e&&e.getTracks)try{var t=e.getTracks();h(t).call(t,function(e){try{e.stop()}catch(e){}})}catch(e){}}function X(e){return navigator.mediaDevices.getUserMedia(e).then(function(e){return e?(L(e),!0):v.reject(new Error("EmptyStreamError"))}).catch(function(e){return(!e||"NotAllowedError"!==e.name)&&v.reject(e)})}!function(e){e.NO="0",e.YES="1"}(D||(D={})),function(e){e.NO="0",e.YES="1"}(E||(E={})),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"}(R||(R={})),function(e){e.DIRECT_ANSWER="1",e.LISTEN_FIRST_AND_THEN_ANSWER_MANUALLY="2"}(N||(N={}));var F,G,_,B,Y,V,J,W,Z,K,$,Q,ee,te,ne,ie,re,se,ae,oe,ce,ue,le,fe,he,de,pe,ve,ge,me,we,be,ke,xe,ye,Se,Ae,Ie,Te,je,Oe,Ce,qe,De,Ee,Re,Ne,Pe,Me,Ue,He,ze,Le,Xe,Fe,Ge,_e,Be,Ye,Ve,Je,We,Ze,Ke,$e,Qe,et,tt,nt,it,rt,st,at,ot,ct,ut,lt,ft,ht,dt,pt,vt,gt,mt,wt,bt,kt,xt,yt,St,At,It,Tt,jt,Ot,Ct,qt,Dt,Et,Rt,Nt,Pt,Mt,Ut,Ht,zt,Lt,Xt,Ft,Gt,_t,Bt,Yt,Vt,Jt,Wt,Zt,Kt,$t,Qt,en,tn,nn,rn=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")},sn=function(){return new Date(new Date((new Date).toLocaleDateString()).getTime())},an=function(e){return new Date(e.setSeconds(e.getSeconds()+1))};function on(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,a=n.type,o=n.contentType,c=a||"POST",l=r,f=null;return s&&("GET"===c?l=l+"?"+function(e){var t=[];for(var n in e)t.push(n+"="+e[n]);return t.join("&")}(s):"POST"===c&&(f=u(s))),i.open(c,l,!0),{xhr:i,ajaxData:f,contentType:o}}var cn,un,ln=function(){return i(function e(){var t=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(n(this,e),F.add(this),G.set(this,void 0),_.set(this,void 0),B.set(this,void 0),Y.set(this,void 0),V.set(this,void 0),J.set(this,[]),W.set(this,[]),Z.set(this,{}),K.set(this,void 0),$.set(this,void 0),Q.set(this,new MediaStream),ee.set(this,JSON.parse(u(H))),te.set(this,0),ne.set(this,void 0),ie.set(this,void 0),re.set(this,void 0),l(this,"token",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),se.set(this,void 0),ae.set(this,48e4),oe.set(this,12e6),ce.set(this,{}),ue.set(this,void 0),le.set(this,void 0),fe.set(this,void 0),he.set(this,function(e){}),de.set(this,function(e){}),pe.set(this,function(e){}),ve.set(this,function(e){}),ge.set(this,function(e){return O(t,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(!C(this,ne,"f")||!C(this,ie,"f")){t.next=2;break}if(!(f()-C(this,ie,"f")>e)){t.next=2;break}return t.next=1,C(this,we,"f").call(this);case 1:n=t.sent,i=n.sign,r=n.timestamp,q(this,ne,null!=i?i:C(this,ne,"f"),"f"),q(this,ie,null!=r?r:C(this,ie,"f"),"f");case 2:case"end":return t.stop()}},t,this)}))}),me.set(this,function(e){return O(t,void 0,void 0,c.mark(function t(){var n,i,r,s,a;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!C(this,se,"f")){t.next=4;break}if(!(f()-C(this,se,"f")>e)){t.next=4;break}if(!C(this,re,"f")){t.next=2;break}return t.next=1,C(this,be,"f").call(this);case 1:n=t.sent,i=n.token,r=n.tokenTimestamp,q(this,re,null!=i?i:C(this,re,"f"),"f"),q(this,se,null!=r?r:f(),"f"),t.next=4;break;case 2:if(!this.token){t.next=4;break}return t.next=3,this.getGatewayAccessToken({corpId:C(this,Fe,"f"),sid:C(this,Be,"f"),secret:C(this,Ge,"f"),seatOnline:!1});case 3:s=t.sent,a=s.token,this.token=a,q(this,se,f(),"f");case 4:case"end":return t.stop()}},t,this)}))}),we.set(this,function(){}),be.set(this,function(){}),ke.set(this,function(e){}),xe.set(this,function(e){}),ye.set(this,void 0),Se.set(this,void 0),l(this,"networkSpeed",{enumerable:!0,configurable:!0,writable:!0,value:"0.00Mb/s"}),l(this,"networkDelay",{enumerable:!0,configurable:!0,writable:!0,value:"0ms"}),l(this,"onLine",{enumerable:!0,configurable:!0,writable:!0,value:navigator.onLine}),l(this,"testspeeding",{enumerable:!0,configurable:!0,writable:!0,value:!1}),l(this,"goodNetworkSpeed",{enumerable:!0,configurable:!0,writable:!0,value:function(){return 1e3*Number(t.networkSpeed.replace("Mb/s",""))>=30}}),l(this,"goodNetworkDelay",{enumerable:!0,configurable:!0,writable:!0,value:function(){return Number(t.networkDelay.replace("ms",""))<=500&&"0ms"!==t.networkDelay}}),l(this,"authorizedMicrophonePermissions",{enumerable:!0,configurable:!0,writable:!0,value:!1}),l(this,"authorizedNotificationPermissions",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Ae.set(this,100),Ie.set(this,3),Te.set(this,8),je.set(this,3),Oe.set(this,0),Ce.set(this,!1),qe.set(this,void 0),De.set(this,3),Ee.set(this,3),Re.set(this,0),Ne.set(this,0),Pe.set(this,0),Me.set(this,!1),Ue.set(this,!1),He.set(this,!1),ze.set(this,void 0),Le.set(this,void 0),Xe.set(this,void 0),Fe.set(this,void 0),Ge.set(this,void 0),_e.set(this,void 0),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,function(e){C(t,F,"m",$t).call(t)}),Ke.set(this,function(){}),$e.set(this,void 0),Qe.set(this,void 0),et.set(this,!1),tt.set(this,4e3),nt.set(this,4e3),it.set(this,{}),rt.set(this,!1),st.set(this,!0),l(this,"ifAutoAnswer",{enumerable:!0,configurable:!0,writable:!0,value:function(){return String(C(t,it,"f").autoAnswer)===D.YES}}),l(this,"notNeedSendStarDtmf",{enumerable:!0,configurable:!0,writable:!0,value:function(){return String(C(t,it,"f").afterTransferLabour)===N.DIRECT_ANSWER}}),at.set(this,function(){if(C(t,st,"f")){var e;C(t,ot,"f").call(t);var n=new(window.AudioContext||window.webkitAudioContext);q(t,le,n.createScriptProcessor(2048,1,1),"f"),C(t,le,"f").onaudioprocess=function(e){for(var n=e.inputBuffer.getChannelData(0),i=0,r=0;r<n.length;++r)i+=n[r]*n[r];q(t,te,Number(Math.sqrt(i/n.length).toFixed(2)),"f"),C(t,he,"f").call(t,C(t,te,"f"))},q(t,fe,new MediaStream,"f"),h(e=t.getSenders()).call(e,function(e){e.track&&C(t,fe,"f").addTrack(e.track)}),q(t,ue,n.createMediaStreamSource(C(t,fe,"f")),"f"),C(t,ue,"f").connect(C(t,le,"f")),C(t,le,"f").connect(n.destination)}}),ot.set(this,function(){if(C(t,st,"f")){if(C(t,ue,"f"))try{C(t,ue,"f").disconnect()}catch(e){console.log(e)}if(C(t,le,"f"))try{C(t,le,"f").disconnect()}catch(e){console.log(e)}if(C(t,fe,"f"))try{var e;h(e=C(t,fe,"f").getTracks()).call(e,function(e){e.stop()})}catch(e){console.log(e)}}q(t,ue,void 0,"f"),q(t,le,void 0,"f"),q(t,fe,void 0,"f"),q(t,te,0,"f"),C(t,he,"f").call(t,C(t,te,"f"))}),l(this,"disposeSoftphoneEnvRequirementCheck",{enumerable:!0,configurable:!0,writable:!0,value:function(){C(t,ct,"f").call(t),window.removeEventListener("offline",C(t,ft,"f")),window.removeEventListener("online",C(t,lt,"f")),window.removeEventListener("unload",t.disposeSoftphoneEnvRequirementCheck)}}),ct.set(this,function(){clearInterval(C(t,ye,"f")),q(t,ye,void 0,"f"),clearTimeout(C(t,Se,"f")),q(t,Se,void 0,"f"),t.testspeeding=!1}),l(this,"softphoneEnvCheck",{enumerable:!0,configurable:!0,writable:!0,value:function(){return O(t,void 0,void 0,c.mark(function e(){return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this.testspeeding||(C(this,ut,"f").call(this),this.oneRoundOfTesting());case 1:case"end":return e.stop()}},e,this)}))}}),ut.set(this,function(){window.addEventListener("offline",C(t,ft,"f")),window.addEventListener("online",C(t,lt,"f")),window.addEventListener("unload",t.disposeSoftphoneEnvRequirementCheck)}),l(this,"oneRoundOfTesting",{enumerable:!0,configurable:!0,writable:!0,value:function(){return O(t,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?(C(this,ht,"f").call(this,this),q(this,Se,d(function(){t.testspeeding=!1,t.disposeSoftphoneEnvRequirementCheck()},4e3),"f")):this.testspeeding=!1;case 1:case"end":return e.stop()}},e,this)}))}}),lt.set(this,function(){t.onLine=!0,t.oneRoundOfTesting()}),ft.set(this,function(){t.onLine=!1,t.networkSpeed="0.00Mb/s",t.networkDelay="0ms",C(t,xe,"f").call(t,{networkSpeed:t.networkSpeed,networkDelay:t.networkDelay,authorizedMicrophonePermissions:t.authorizedMicrophonePermissions,authorizedNotificationPermissions:t.authorizedNotificationPermissions}),C(t,ct,"f").call(t)}),ht.set(this,function(e){return O(t,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(C(n,ye,"f")),q(n,ye,void 0,"f"),i=function(){return O(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,C(n,dt,"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:C(this,xe,"f").call(this,{networkSpeed:this.networkSpeed,networkDelay:this.networkDelay,authorizedMicrophonePermissions:this.authorizedMicrophonePermissions,authorizedNotificationPermissions:this.authorizedNotificationPermissions}),C(this,Se,"f")||(this.testspeeding=!1,this.disposeSoftphoneEnvRequirementCheck());case 7:case"end":return e.stop()}},e,this,[[1,3]])}))},t.next=1,i();case 1:C(this,Se,"f")&&q(n,ye,p(function(){return O(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)}))}),dt.set(this,function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"https://seat.94ai.com/favicon.png",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:63491,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return O(t,void 0,void 0,c.mark(function t(){var r,s;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:for(r=[],s=0;s<i;s++)r.push(C(this,pt,"f").call(this,e+"?d="+f()+s,n));return t.abrupt("return",v.all(r).then(function(e){var t=0,n=0;return h(e).call(e,function(e){t+=Number(e[0]),n+=Number(e[1])}),{networkDelay:(n/i).toFixed(2)+"ms",networkSpeed:(t/i).toFixed(2)+"Mb/s"}}));case 1:case"end":return t.stop()}},t,this)}))}),pt.set(this,function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"https://seat.94ai.com/favicon.png?d="+f(),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})}),l(this,"openApiAjax",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return new v(function(n,i){return O(t,void 0,void 0,c.mark(function t(){var r,s,a,o,u,l,f;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=on(n,i,e),s=r.xhr,a=r.ajaxData,o=r.contentType,t.next=1,this.getOpenApiSign();case 1:return u=t.sent,l=u.timestamp,f=u.sign,s.setRequestHeader("appKey",C(this,Fe,"f")),s.setRequestHeader("timestamp",String(l)),s.setRequestHeader("sign",f),s.setRequestHeader("Content-type",o||"application/json"),t.next=2,C(this,pe,"f").call(this,s);case 2:s.send(a);case 3:case"end":return t.stop()}},t,this)}))})}}),l(this,"requestGateway",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t.gatewayApiAjax(g(g({},e),{url:t.getGateway()+e.url}),n)}}),l(this,"gatewayApiAjax",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return new v(function(i,r){return O(t,void 0,void 0,c.mark(function t(){var s,a,o,u,l;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(s=on(i,r,e),a=s.xhr,o=s.ajaxData,u=s.contentType,!n){t.next=2;break}return t.next=1,this.getGatewayToken();case 1:l=t.sent,a.setRequestHeader("x-token",l),a.setRequestHeader("seatsToken",l),a.setRequestHeader("x-authority-token",l);case 2:return a.setRequestHeader("x-app-code",3),a.setRequestHeader("content-type",u||"application/json"),t.next=3,C(this,ve,"f").call(this,a);case 3:a.send(o);case 4:case"end":return t.stop()}},t,this)}))})}}),l(this,"requestOpenApi",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return t.openApiAjax(g(g({},e),{url:t.getOpenApi()+e.url}))}}),l(this,"getDeviceId",{enumerable:!0,configurable:!0,writable:!0,value:function(){return O(t,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(!C(this,We,"f")){e.next=1;break}return e.abrupt("return",C(this,We,"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,q(this,We,n.visitorId,"f"),e.abrupt("return",C(this,We,"f"));case 4:case"end":return e.stop()}},e,this)}))}}),yt.set(this,function(){return O(t,void 0,void 0,c.mark(function e(){var t,n,i,s;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!C(this,F,"m",xt).call(this)||C(this,Z,"f").authorizationUsername&&C(this,Z,"f").uri&&C(this,Z,"f").authorizationPassword&&C(this,Z,"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,C(this,Z,"f").authorizationUsername=s.agentExtension,C(this,Z,"f").authorizationPassword=s.extensionPwd,C(this,Z,"f").contactName||(C(this,Z,"f").contactName=s.agentExtension),C(this,Z,"f").uri=r.UserAgent.makeURI(m(n="sip:".concat(s.agentExtension,"@")).call(n,s.wsRegisterAddress)),C(this,Z,"f").transportOptions.server=m(i="".concat(s.wsProtocol,"://")).call(i,s.wsRegisterAddress),q(this,Be,s.agentId,"f"),q(this,_e,s.agentTag,"f"),e.next=3;break;case 2:throw new Error(u(t));case 3:case"end":return e.stop()}},e,this)}))}),St.set(this,function(){return O(t,void 0,void 0,c.mark(function e(){var t;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(C(this,Z,"f").viaHost){e.next=2;break}return t="",e.next=1,this.getDeviceId();case 1:C(this,Z,"f").viaHost=m(t).call(t,e.sent,".sip");case 2:case"end":return e.stop()}},e,this)}))}),It.set(this,function(e){var n,i,r,s,a,o,c,u,l,f,h,d,p,v,g,m,b,k,x,y,S;C(t,it,"f").popWindow=null===(a=e["X-Popwindow"])||void 0===a?void 0:a[0].raw,C(t,it,"f").afterTransferLabour=null===(o=e["X-Aftertransferlabour"])||void 0===o?void 0:o[0].raw,C(t,it,"f").callId=null===(c=e["X-94callid"])||void 0===c?void 0:c[0].raw,C(t,it,"f").cid=null===(u=e["X-Cid"])||void 0===u?void 0:u[0].raw,C(t,it,"f").numberId=null===(l=e["X-Numberid"])||void 0===l?void 0:l[0].raw,C(t,it,"f").tag=(null===(f=e["X-Tag"])||void 0===f?void 0:f[0].raw)&&"null"!==(null===(h=e["X-Tag"])||void 0===h?void 0:h[0].raw)?w(n=e["X-Tag"][0].raw.split("-")).call(n,function(e){return String.fromCharCode(e)}).join(""):"",C(t,it,"f").taskId=null===(d=e["X-Taskid"])||void 0===d?void 0:d[0].raw,C(t,it,"f").voiceType=null===(p=e["X-Voicetype"])||void 0===p?void 0:p[0].raw,C(t,it,"f").processTime=null===(v=e["X-Processtime"])||void 0===v?void 0:v[0].raw,C(t,it,"f").userPhone=null===(g=e["X-Userphone"])||void 0===g?void 0:g[0].raw,C(t,it,"f").autoAnswer=null===(m=e["X-94autoanswer"])||void 0===m?void 0:m[0].raw,C(t,it,"f").nodeTitle=null===(b=e["X-Nodetitle"])||void 0===b?void 0:w(i=b[0].raw.split("-")).call(i,function(e){return String.fromCharCode(e)}).join(""),C(t,it,"f").taskName=null===(k=e["X-Taskname"])||void 0===k?void 0:w(r=k[0].raw.split("-")).call(r,function(e){return String.fromCharCode(e)}).join(""),C(t,it,"f").templateTitle=null===(x=e["X-Templatetitle"])||void 0===x?void 0:w(s=x[0].raw.split("-")).call(s,function(e){return String.fromCharCode(e)}).join(""),C(t,it,"f").phoneNumber=(null===(y=e["X-Phonenumber"])||void 0===y?void 0:y[0].raw)||(null===(S=e.From)||void 0===S?void 0:S[0].parsed.uri.normal.user)}),zt.set(this,function(e){switch(e){case r.SessionState.Initial:case r.SessionState.Establishing:break;case r.SessionState.Established:C(t,F,"m",Ht).call(t);break;case r.SessionState.Terminating:case r.SessionState.Terminated:var n=d(function(){clearTimeout(n),n=void 0,C(t,ee,"f").incomingStatus=!1,C(t,ee,"f").answerStatus=!1},10);C(t,ot,"f").call(t);break;default:throw new Error("Unknown session state.")}}),Xt.set(this,function(e,n,i){C(t,Te,"f")&&(q(t,Ce,!1,"f"),C(t,ee,"f").reconnectStatus=!1,C(t,Ue,"f")&&(q(t,Ue,!1,"f"),C(t,_t,"f").call(t,e,n,i)))}),Ft.set(this,function(){return O(t,void 0,void 0,c.mark(function e(){return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!C(this,Te,"f")){e.next=6;break}return q(this,Ce,!0,"f"),q(this,Ue,!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,C(this,F,"m",Lt).call(this);case 3:e.next=5;break;case 4:e.prev=4,e.catch(2);case 5:C(this,Bt,"f").call(this),C(this,F,"m",$t).call(this);case 6:case"end":return e.stop()}},e,this,[[2,4]])}))}),Gt.set(this,function(){if(C(t,Te,"f")){var e=C(t,Z,"f").uri.clone(),n=C(t,Z,"f").uri.clone(),i=C(t,Z,"f").uri.clone();i.user=void 0,C(t,_t,"f").call(t,i,e,n)}}),_t.set(this,function(e,n,i){if(C(t,Te,"f")){if(C(t,Ue,"f"))return;q(t,Ue,!0,"f"),q(t,Le,d(function(){C(t,F,"m",Zt).call(t);var r=t.getUserAgent().userAgentCore,s=r.makeOutgoingRequestMessage("OPTIONS",e,n,i,{});q(t,qe,r.request(s,{onAccept:function(){console.log("sip ping ok"),q(t,Oe,0,"f"),q(t,qe,void 0,"f"),C(t,Xt,"f").call(t,e,n,i)},onReject:function(r){var s;if(q(t,qe,void 0,"f"),408===r.message.statusCode||503===r.message.statusCode)if(console.log("sip ping error with code "+r.message.statusCode),C(t,je,"f")>0&&C(t,Oe,"f")>=C(t,je,"f"))console.log("sip maximum ping attempts reached"),C(t,Ft,"f").call(t);else{var a,o;if(C(t,Oe,"f")>0)console.log(m(o="sip ping retry ".concat(C(t,Oe,"f")," of ")).call(o,C(t,je,"f")," fail"));q(t,Oe,(s=C(t,Oe,"f"),++s),"f"),console.log(m(a="sip ping retry ".concat(C(t,Oe,"f")," of ")).call(a,C(t,je,"f"))),C(t,Xt,"f").call(t,e,n,i)}else q(t,Oe,0,"f"),C(t,Xt,"f").call(t,e,n,i)}}),"f")},1e3*C(t,Te,"f")),"f")}}),Bt.set(this,function(){if(C(t,Te,"f")){if(q(t,Ue,!1,"f"),q(t,Ce,!1,"f"),C(t,qe,"f")){try{C(t,qe,"f").dispose()}catch(e){}q(t,qe,void 0,"f")}C(t,Le,"f")&&C(t,F,"m",Zt).call(t)}}),Kt.set(this,function(){if(C(t,De,"f")){if(C(t,He,"f"))return;q(t,He,!0,"f"),C(t,ee,"f").reconnectStatus=!0,q(t,Xe,d(function(){return O(t,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,C(this,F,"m",Jt).call(this),0===C(this,Re,"f")&&console.log("sip reconnect success then register start"),e.next=1,C(this,B,"f").register({requestDelegate:{onAccept:function(e){console.log("sip reconnect success and register ok"),q(n,Re,0,"f"),q(n,He,!1,"f"),C(n,ee,"f").registerStatus=!0,C(n,ee,"f").reconnectStatus=!1,C(n,Gt,"f").call(n)},onReject:function(e){return O(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),q(this,He,!1,"f"),!(C(this,Ee,"f")<=C(this,Re,"f"))){t.next=2;break}return console.log("sip maximum register attempts reached"),q(this,Re,0,"f"),t.next=1,this.getUserAgent().transport.disconnect().catch(function(e){return console.error(e)});case 1:C(this,F,"m",$t).call(this),t.next=3;break;case 2:q(this,Re,(n=C(this,Re,"f"),++n),"f"),console.log(m(i="sip reconnect success and register retry ".concat(C(this,Re,"f")," of ")).call(i,C(this,Ee,"f"))),C(this,Kt,"f").call(this);case 3:case"end":return t.stop()}},t,this)}))}},requestOptions:{extraHeaders:C(this,G,"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),q(this,Re,0,"f"),q(this,He,!1,"f");case 3:case"end":return e.stop()}},e,this,[[0,2]])}))},1e3*C(t,De,"f")),"f")}}),"object"!==o(i))throw new Error("userAgentOption must be plain object");C(this,F,"m",wt).call(this,i),C(this,F,"m",bt).call(this,i),C(this,F,"m",mt).call(this,i),C(this,F,"m",kt).call(this,i),C(this,F,"m",jt).call(this,i),C(this,F,"m",gt).call(this,i),C(this,F,"m",vt).call(this,i),q(this,Z,C(this,F,"m",Ct).call(this,i),"f")},[{key:"volumeValue",get:function(){return C(this,te,"f")}},{key:"businessAttribute",get:function(){return C(this,it,"f")}},{key:"getFastOutboundCall",value:function(){return C(this,it,"f").voiceType===R.LABOUR}},{key:"getSitOutboundCall",value:function(){return C(this,it,"f").voiceType===R.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"===C(this,Je,"f")?"https://gateway.sg.94ai.com":"https://gateway.94ai.com"}},{key:"getGatewayToken",value:function(){return O(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,C(this,me,"f").call(this,C(this,oe,"f"));case 1:if(!C(this,re,"f")){e.next=2;break}return e.abrupt("return",C(this,re,"f"));case 2:if(this.token){e.next=5;break}return e.next=3,C(this,yt,"f").call(this);case 3:return e.next=4,this.getGatewayAccessToken({corpId:C(this,Fe,"f"),sid:C(this,Be,"f"),secret:C(this,Ge,"f"),seatOnline:!1});case 4:t=e.sent,n=t.token,this.token=n,q(this,se,f(),"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 O(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=g({},C(this,it,"f")),n=function(){return O(r,void 0,void 0,c.mark(function e(){var n,i,r,s,a,o,u,l,f,h,d,p,v,g,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,C(this,ke,"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=m(i=m(r="当前会话callid:".concat(t.callId,",根据numberId:")).call(r,t.numberId,",taskId:")).call(i,t.taskId,":查询坐席接听状态异常"),console.error(s),t.stop=!0,C(this,ke,"f").call(this,new Error(n.message)),e.abrupt("return");case 5:if(a=n.data,o=a.callType,u=a.newIntentTag,l=a.intentTag,f=a.number,h=a.numberMd5,d=a.sid,p=a.config,v=a.tag,10!==a.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=o),t.intentTag=u||l,t.number||(t.number=f),t.numberMD5||(t.numberMD5=h),t.agentId||(t.agentId=d),t.tag||(t.tag=v),t.templateId||p&&"string"==typeof p&&(g=JSON.parse(p))&&g.templateId&&(t.templateId=g.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,C(this,ke,"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=m(x="当前会话根据callId:".concat(t.callId,",taskId:")).call(x,t.taskId,":查询会话对话记录异常"),console.error(y),t.stop=!0,C(this,ke,"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}),C(this,ce,"f")[t.callId]=t;case 12:try{C(this,de,"f").call(this,C(this,ce,"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),C(this,ke,"f").call(this,new Error(S))),t.numberId||(A="当前会话callid:".concat(t.callId,"的numberId不存在,无法查询通话记录"),console.error(A),C(this,ke,"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 O(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),C(this,ke,"f").call(this,i);case 9:case"end":return e.stop()}},e,this,[[1,8]])}))}},{key:"refreshCallChatInfo",value:function(){return O(this,void 0,void 0,c.mark(function e(){return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(C(this,it,"f").numberId&&C(this,it,"f").callId&&C(this,it,"f").taskId&&C(this,rt,"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 C(this,Ye,"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))}(C(this,Ye,"f"))?C(this,Ye,"f"):"1"===C(this,Je,"f")?"1"===C(this,Ve,"f")?"https://seatsg.94ai.com/sgopenapi":"https://seatsg.94ai.com/openapi":"1"===C(this,Ve,"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:C(this,_e,"f"),agentId:C(this,Be,"f")}})}},{key:"getOpenApiSign",value:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:f(),i=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0;return O(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,C(this,ge,"f").call(this,C(this,ae,"f"));case 1:return s.abrupt("return",{sign:null!==(e=C(this,ne,"f"))&&void 0!==e?e:T.enc.Base64.stringify(T.HmacSHA1(i||C(this,Fe,"f")+n,r||C(this,Ge,"f"))),timestamp:null!==(t=C(this,ie,"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:C(this,_e,"f"),agentId:C(this,Be,"f"),agentStatus:e}})}},{key:"importOpenApiAgentCustomer",value:function(e){return this.requestOpenApi({url:"/v1/task/importAgentCustomer",data:{agentTag:C(this,_e,"f"),agentId:C(this,Be,"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){q(this,ne,e,"f")}},{key:"prepareUserAgent",value:function(e,t){var n;return O(this,void 0,void 0,c.mark(function i(){var r,s,a,o,u,l,f,h,d,p,v,m;return c.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return s=(r=e||{}).refresh,a=r.registererOptions,o=r.registererRegisterOptions,u=r.extraHeaders,l=r.authorizationUsername,f=r.authorizationPassword,h=r.uri,d=r.contactName,p=r.transportOptions,i.next=1,this.dispose();case 1:return C(this,Z,"f").uri=null!=h?h:C(this,Z,"f").uri,C(this,Z,"f").authorizationUsername=null!=l?l:C(this,Z,"f").authorizationUsername,C(this,Z,"f").authorizationPassword=null!=f?f:C(this,Z,"f").authorizationPassword,C(this,Z,"f").contactName=null!==(n=null!=d?d:l)&&void 0!==n?n:C(this,Z,"f").contactName,p&&(C(this,Z,"f").transportOptions=g(g({},C(this,Z,"f").transportOptions),p)),i.prev=2,C(this,F,"m",bt).call(this,e),i.next=3,C(this,yt,"f").call(this);case 3:return i.next=4,C(this,St,"f").call(this);case 4:return C(this,F,"m",Tt).call(this,{refresh:s}),i.next=5,C(this,F,"m",tn).call(this);case 5:return t&&C(this,F,"m",en).call(this,t),i.next=6,C(this,F,"m",nn).call(this,{registererOptions:a,registererRegisterOptions:o,extraHeaders:u},C(this,et,"f"));case 6:return v=i.sent,i.abrupt("return",v);case 7:return i.prev=7,m=i.catch(2),i.next=8,this.dispose();case 8:throw m;case 9:case"end":return i.stop()}},i,this,[[2,7]])}))}},{key:"dispose",value:function(){return O(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,C(this,F,"m",At).call(this),e.next=1,C(this,F,"m",Dt).call(this);case 1:e.next=3;break;case 2:e.prev=2,t=e.catch(0),C(this,F,"m",Rt).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 O(this,void 0,void 0,c.mark(function t(){return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return C(this,ee,"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 O(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){O(i,void 0,void 0,c.mark(function i(){var r,s,a;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(g({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,a=i.catch(0),n(a);case 3:case"end":return i.stop()}},i,this,[[0,2]])}))});case 1:C(this,ee,"f").incomingStatus&&(C(this,ee,"f").incomingStatus=!1,C(this,ee,"f").answerStatus=!0),t.next=3;break;case 2:throw t.prev=2,n=t.catch(0),C(this,ee,"f").incomingStatus=!1,n;case 3:case"end":return t.stop()}},t,this,[[0,2]])}))}},{key:"hangUpInvite",value:function(e){return O(this,void 0,void 0,c.mark(function t(){var n,i,s,a,o,u=this;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return i=(n=e||{}).rejectOptions,s=n.byeOptions,a=n.extraHeaders,o=n.scoutResponse,t.abrupt("return",new v(function(e,t){return O(u,void 0,void 0,c.mark(function n(){var u,l,f,h,d,p,v,m,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,m=null===(l=p.requestDelegate)||void 0===l?void 0:l.onReject,null===(f=p.requestDelegate)||void 0===f||delete f.onAccept,null===(h=p.requestDelegate)||void 0===h||delete h.onReject,w=C(this,F,"m",Ot).call(this,{onAccept:function(t){console.log("sip bye success"),e(t),null==v||v(t)},onReject:function(e){null==m||m(e),t(new Error("sip bye fail with code "+e.message.statusCode))}},p.requestDelegate),delete p.requestDelegate,b=null===(d=C(this,K,"f"))||void 0===d?void 0:d.state,n.next=b===r.SessionState.Initial||b===r.SessionState.Establishing?1:b===r.SessionState.Established?3:b===r.SessionState.Terminating||b===r.SessionState.Terminated?5:6;break;case 1:return n.next=2,C(this,K,"f").reject(g({extraHeaders:a},i||{}));case 2:return e(!0),n.abrupt("continue",6);case 3:return n.next=4,C(this,K,"f").bye(g({requestDelegate:w,requestOptions:{extraHeaders:a}},p));case 4:return o||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,C(this,ee,"f").incomingStatus=!1,C(this,ee,"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 O(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 O(n,void 0,void 0,c.mark(function n(){var r,s,a,o,u;return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,s=(r=e||{}).extraHeaders,a=r.requestDelegate,o=C(this,F,"m",Ot).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))}},a),delete r.requestDelegate,n.next=1,this.getCurrentInvitation().info(g({requestOptions:{body:{contentDisposition:"render",contentType:"application/dtmf-relay",content:"Signal=*\r\nDuration=100"},extraHeaders:s},requestDelegate:o},r));case 1:C(this,at,"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=C(this,V,"f").getReceivers()).call(e,function(e){e.track.enabled=!1})}},{key:"unMuteRemoteAudio",value:function(){var e;h(e=C(this,V,"f").getReceivers()).call(e,function(e){e.track.enabled=!0})}},{key:"muteLocalAudio",value:function(){var e;h(e=C(this,V,"f").getSenders()).call(e,function(e){e.track.enabled=!1})}},{key:"unMuteLocalAudio",value:function(){var e;h(e=C(this,V,"f").getSenders()).call(e,function(e){e.track.enabled=!0})}},{key:"getUserAgentStatue",value:function(){return C(this,ee,"f")}},{key:"getUserAgent",value:function(){return C(this,_,"f")||q(this,_,new r.UserAgent(C(this,Z,"f")),"f"),C(this,_,"f")}},{key:"getSessionDescriptionHandler",value:function(){return C(this,Y,"f")}},{key:"getPeerConnection",value:function(){return C(this,V,"f")}},{key:"getSenders",value:function(){return C(this,W,"f")}},{key:"getReceivers",value:function(){return C(this,J,"f")}},{key:"getStream",value:function(){var e,t=this;return C(this,Q,"f")||q(this,Q,new MediaStream,"f"),h(e=C(this,J,"f")).call(e,function(e){e.track&&C(t,Q,"f").addTrack(e.track)}),C(this,Q,"f")}},{key:"getCurrentInviter",value:function(){if(!C(this,$,"f"))throw new Error("No currentInviter...");return C(this,$,"f")}},{key:"getCurrentInvitation",value:function(){return C(this,K,"f")}},{key:"invite",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return O(this,void 0,void 0,c.mark(function n(){var i,s,a;return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(s=r.UserAgent.makeURI(e.uri?e.uri:m(i="sip:".concat(e.extension,"@")).call(i,C(this,Z,"f").transportOptions.server.split("://")[1]))){n.next=1;break}throw new Error("Failed to create target URI.");case 1:return q(this,$,new r.Inviter(this.getUserAgent(),s,{sessionDescriptionHandlerOptions:{constraints:{audio:!0,video:!1}}}),"f"),a=(t||{}).extraHeaders,n.next=2,this.getCurrentInviter().invite(g({requestOptions:{extraHeaders:a}},t));case 2:return n.abrupt("return",C(this,$,"f"));case 3:case"end":return n.stop()}},n,this)}))}}])}();G=new x,_=new x,B=new x,Y=new x,V=new x,J=new x,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,ae=new x,oe=new x,ce=new x,ue=new x,le=new x,fe=new x,he=new x,de=new x,pe=new x,ve=new x,ge=new x,me=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,Oe=new x,Ce=new x,qe=new x,De=new x,Ee=new x,Re=new x,Ne=new x,Pe=new x,Me=new x,Ue=new x,He=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,at=new x,ot=new x,ct=new x,ut=new x,lt=new x,ft=new x,ht=new x,dt=new x,pt=new x,yt=new x,St=new x,It=new x,zt=new x,Xt=new x,Ft=new x,Gt=new x,_t=new x,Bt=new x,Kt=new x,F=new y,vt=function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};q(this,pe,null!==(e=n.openXhrIntercept)&&void 0!==e?e:C(this,pe,"f"),"f"),q(this,ve,null!==(t=n.gatewayXhrIntercept)&&void 0!==t?t:C(this,ve,"f"),"f")},gt=function(){var e,t,n,i,r,s,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};q(this,rt,null!==(e=a.enableChatInfoPush)&&void 0!==e?e:C(this,rt,"f"),"f"),q(this,st,null!==(t=a.enableVolumnTrack)&&void 0!==t?t:C(this,st,"f"),"f"),q(this,he,null!==(n=a.refreshSpeekVolumn)&&void 0!==n?n:C(this,he,"f"),"f"),q(this,xe,null!==(i=a.refreshRequirementCheck)&&void 0!==i?i:C(this,xe,"f"),"f"),q(this,de,null!==(r=a.refreshChat)&&void 0!==r?r:C(this,de,"f"),"f"),q(this,ke,null!==(s=a.refreshChatErrorCallback)&&void 0!==s?s:C(this,ke,"f"),"f")},mt=function(){var e,t,n,i,r,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};q(this,re,null!==(e=s.token)&&void 0!==e?e:C(this,re,"f"),"f"),q(this,se,null!==(t=s.tokenTimestamp)&&void 0!==t?t:C(this,se,"f"),"f"),q(this,oe,null!==(n=s.tokenExpirationTime)&&void 0!==n?n:C(this,oe,"f"),"f"),C(this,re,"f")&&!C(this,se,"f")&&q(this,se,f(),"f"),q(this,me,null!==(i=s.tokenCheck)&&void 0!==i?i:C(this,me,"f"),"f"),q(this,be,null!==(r=s.tokenOverdued)&&void 0!==r?r:C(this,be,"f"),"f")},wt=function(){var e,t,n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};q(this,et,null!==(e=i.clusterMode)&&void 0!==e?e:C(this,et,"f"),"f"),q(this,tt,null!==(t=i.reClusterRegisterTimeout)&&void 0!==t?t:C(this,tt,"f"),"f"),q(this,nt,null!==(n=i.reClusterConnectTimeout)&&void 0!==n?n:C(this,nt,"f"),"f")},bt=function(){var e,t,n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.agentId,s=i.agentTag,a=i.appKey,o=i.appSecret,c=i.openBaseUrl,u=i.sg,l=i.sgOpen,f=i.sign,h=i.timestamp;q(this,Be,null!=r?r:C(this,Be,"f"),"f"),q(this,_e,null!=s?s:C(this,_e,"f"),"f"),q(this,Fe,null!=a?a:C(this,Fe,"f"),"f"),q(this,Ge,null!=o?o:C(this,Ge,"f"),"f"),q(this,Ye,null!=c?c:C(this,Ye,"f"),"f"),q(this,Je,null!=u?u:C(this,Je,"f"),"f"),q(this,Ve,null!=l?l:C(this,Ve,"f"),"f"),q(this,ne,null!=f?f:C(this,ne,"f"),"f"),q(this,ie,null!=h?h:C(this,ie,"f"),"f"),q(this,ae,null!==(e=i.signExpirationTime)&&void 0!==e?e:C(this,ae,"f"),"f"),q(this,ge,null!==(t=i.signCheck)&&void 0!==t?t:C(this,ge,"f"),"f"),q(this,we,null!==(n=i.signOverdued)&&void 0!==n?n:C(this,we,"f"),"f")},kt=function(e){e.sipHeaders&&(q(this,G,e.sipHeaders,"f"),delete e.sipHeaders)},xt=function(){return!(!C(this,Be,"f")&&!C(this,_e,"f")||!(C(this,Fe,"f")&&C(this,Ge,"f")||C(this,ne,"f")&&C(this,ie,"f")))},At=function(){C(this,F,"m",Et).call(this),C(this,F,"m",Mt).call(this),C(this,F,"m",Ut).call(this),C(this,F,"m",Pt).call(this),C(this,F,"m",Nt).call(this),C(this,F,"m",Yt).call(this),C(this,F,"m",Vt).call(this),C(this,F,"m",Rt).call(this),C(this,ot,"f").call(this),q(this,it,{},"f"),q(this,ce,{},"f")},Tt=function(e){q(this,ee,a(JSON.parse(u(H)),"function"==typeof e.refresh?e.refresh:C(this,Ke,"f")),"f")},jt=function(e){var t,n,i,r,s,a,o,c,u,l,f,h,d,p,v;q(this,Ae,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:C(this,Ae,"f"),"f"),q(this,Ie,null!==(o=null!==(s=null!==(r=e.reconnectionInterval)&&void 0!==r?r:e.reconnectionDelay)&&void 0!==s?s:null===(a=null==e?void 0:e.transportOptions)||void 0===a?void 0:a.reconnectionTimeout)&&void 0!==o?o:C(this,Ie,"f"),"f"),q(this,Ne,null!==(u=null===(c=e.transportOptions)||void 0===c?void 0:c.keepAliveInterval)&&void 0!==u?u:C(this,Ne,"f"),"f"),q(this,Pe,null!==(f=null===(l=e.transportOptions)||void 0===l?void 0:l.keepAliveDebounce)&&void 0!==f?f:C(this,Pe,"f"),"f"),q(this,De,null!==(h=e.registerInterval)&&void 0!==h?h:C(this,De,"f"),"f"),q(this,Te,null!==(d=e.optionsPingInterval)&&void 0!==d?d:C(this,Te,"f"),"f"),q(this,je,null!==(p=e.optionsPingAttempts)&&void 0!==p?p:C(this,je,"f"),"f"),q(this,Ee,null!==(v=e.registerAttempts)&&void 0!==v?v:C(this,Ee,"f"),"f")},Ot=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 O(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},Ct=function(e){var t,n=this,i={delegate:{onConnect:function(){return O(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"),C(this,Gt,"f").call(this);case 1:case"end":return e.stop()}},e,this)}))},onInvite:function(e){C(n,It,"f").call(n,e.incomingInviteRequest.message.headers),n.refreshCallChatInfo(),C(n,F,"m",qt).call(n),q(n,K,e,"f"),C(n,ee,"f").incomingStatus=!0,e.stateChange.addListener(C(n,zt,"f"))},onDisconnect:function(e){return O(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,C(this,Te,"f")>0&&(n=C(this,Ce,"f"),C(this,Bt,"f").call(this)),t.prev=1,t.next=2,C(this,F,"m",Lt).call(this);case 2:t.next=4;break;case 3:t.prev=3,t.catch(1);case 4:(e||n)&&C(this,F,"m",$t).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 O(n,void 0,void 0,c.mark(function t(){var n,a;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return null===(a=(n=i.delegate)[r])||void 0===a||a.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=g(g({},e.transportOptions||{}),{keepAliveInterval:C(this,Ne,"f"),keepAliveDebounce:C(this,Pe,"f")}),void 0===e.sessionDescriptionHandlerFactoryOptions&&(e.sessionDescriptionHandlerFactoryOptions={iceGatheringTimeout:2e3,peerConnectionConfiguration:{iceServers:[]}}),g(g({},U),e)},qt=function(){C(this,K,"f")&&(C(this,K,"f").dispose(),q(this,K,void 0,"f"))},Dt=function(){return O(this,void 0,void 0,c.mark(function e(){return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!C(this,_,"f")){e.next=2;break}return e.next=1,C(this,_,"f").stop();case 1:q(this,_,void 0,"f");case 2:case"end":return e.stop()}},e,this)}))},Et=function(){var e;C(this,Q,"f")&&(h(e=C(this,Q,"f").getTracks()).call(e,function(e){e.stop()}),q(this,Q,void 0,"f"))},Rt=function(){var e,t=this;h(e=S(H)).call(e,function(e){var n=e;C(t,ee,"f")[n]=H[n]})},Nt=function(){C(this,Y,"f")&&(C(this,Y,"f").close(),q(this,Y,void 0,"f"))},Pt=function(){C(this,V,"f")&&(C(this,V,"f").close(),q(this,V,void 0,"f"))},Mt=function(){q(this,W,[],"f")},Ut=function(){q(this,J,[],"f")},Ht=function(){var e=this.getCurrentInvitation().sessionDescriptionHandler;C(this,F,"m",Pt).call(this),C(this,F,"m",Nt).call(this),C(this,F,"m",Mt).call(this),C(this,F,"m",Ut).call(this),q(this,Y,e,"f"),q(this,V,e.peerConnection,"f"),q(this,W,C(this,V,"f").getSenders(),"f"),q(this,J,C(this,V,"f").getReceivers(),"f"),(this.getFastOutboundCall()||!this.getSitOutboundCall()&&this.notNeedSendStarDtmf())&&C(this,at,"f").call(this)},Lt=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return O(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(!C(this,B,"f")){t.next=1;break}return console.log("sip due to disconnection, unregistered"),t.abrupt("return",new v(function(t,i){return O(n,void 0,void 0,c.mark(function n(){var r,s,a;return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,r=e||{},s=C(this,F,"m",Ot).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,C(this,B,"f").unregister(g({requestDelegate:s},e));case 1:n.next=3;break;case 2:n.prev=2,a=n.catch(0),i(a);case 3:case"end":return n.stop()}},n,this,[[0,2]])}))}));case 1:case"end":return t.stop()}},t,this)}))},Yt=function(){C(this,F,"m",Jt).call(this),C(this,F,"m",Wt).call(this),C(this,F,"m",Zt).call(this),q(this,He,!1,"f"),q(this,Me,!1,"f"),q(this,Ue,!1,"f")},Vt=function(){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&(clearTimeout(C(this,$e,"f")),q(this,$e,void 0,"f")),e&&(clearTimeout(C(this,Qe,"f")),q(this,Qe,void 0,"f"))},Jt=function(){clearTimeout(C(this,Xe,"f")),q(this,Xe,void 0,"f")},Wt=function(){clearTimeout(C(this,ze,"f")),q(this,ze,void 0,"f")},Zt=function(){clearTimeout(C(this,Le,"f")),q(this,Le,void 0,"f")},$t=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return O(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(!C(this,Ie,"f")){n.next=4;break}if(C(this,ee,"f").reconnectStatus=!0,!C(this,Me,"f")){n.next=1;break}return n.abrupt("return");case 1:if(!(t>C(this,Ae,"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..."),q(this,Me,!0,"f"),q(this,ze,d(function(){C(i,F,"m",Wt).call(i),i.getUserAgent().reconnect().then(function(){return O(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(m(n="sip reconnection attempt ".concat(t," of ")).call(n,C(this,Ae,"f")," - succeeded")),q(this,Me,!1,"f"),C(this,Kt,"f").call(this);case 1:case"end":return e.stop()}},e,this)}))}).catch(function(n){var r;console.error(n),console.log(m(r="sip reconnection attempt ".concat(t," of ")).call(r,C(i,Ae,"f")," - failed")),q(i,Me,!1,"f"),C(i,F,"m",e).call(i,++t)})},1===t?0:1e3*C(this,Ie,"f")),"f");case 4:case"end":return n.stop()}},n,this)}))},Qt=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 O(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=C(this,Z,"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},en=function(e){var t=this.getUserAgent();return t.delegate=C(this,F,"m",Qt).call(this,e),t},tn=function(){return O(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 C(this,ee,"f").connectStatus=!0,e.abrupt("return",t);case 4:case"end":return e.stop()}},e,this)}))},nn=function e(t){var n=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],s=t||{},a=s.registererOptions,o=s.registererRegisterOptions,u=s.extraHeaders;return new v(function(t,s){return O(n,void 0,void 0,c.mark(function n(){var l,f,h,p,v,m=this;return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return l=this.getUserAgent(),q(this,B,new r.Registerer(l,g({extraHeaders:u||C(this,G,"f")},a||{})),"f"),h=o||{},p=C(this,F,"m",Ot).call(this,{onAccept:function(e){f=e,C(m,F,"m",Vt).call(m),C(m,ee,"f").registerStatus=!0,t(l)},onReject:function(e){C(m,F,"m",Vt).call(m),s(new Error("sip register fail with code "+e.message.statusCode))}},h.requestDelegate),delete h.requestDelegate,i&&q(this,$e,d(function(){return O(m,void 0,void 0,c.mark(function n(){var i,v=this;return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(f){n.next=4;break}q(this,Qe,d(function(){return O(v,void 0,void 0,c.mark(function n(){var i,l;return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(C(this,F,"m",Vt).call(this,!1,!0),f){n.next=6;break}n.prev=1;try{C(this,B,"f").dispose()}catch(e){}return C(this,F,"m",At).call(this),C(this,Bt,"f").call(this),q(this,Oe,0,"f"),q(this,Re,0,"f"),n.next=2,C(this,_,"f").transport.dispose();case 2:return q(this,_,new r.UserAgent(C(this,Z,"f")),"f"),n.next=3,C(this,F,"m",tn).call(this);case 3:return n.next=4,C(this,F,"m",e).call(this,{registererOptions:a,registererRegisterOptions:o,extraHeaders:u});case 4:i=n.sent,t(i),n.next=6;break;case 5:n.prev=5,l=n.catch(1),s(l);case 6:case"end":return n.stop()}},n,this,[[1,5]])}))},C(this,nt,"f")),"f");try{C(this,B,"f").dispose()}catch(e){}return q(this,B,new r.Registerer(l,g({extraHeaders:u||C(this,G,"f")},a||{})),"f"),C(this,F,"m",Vt).call(this,!0,!1),n.prev=1,n.next=2,C(this,B,"f").register(g({requestDelegate:p,requestOptions:{extraHeaders:u||C(this,G,"f")}},h));case 2:n.next=4;break;case 3:n.prev=3,i=n.catch(1),C(this,F,"m",Vt).call(this),s(i);case 4:case"end":return n.stop()}},n,this,[[1,3]])}))},C(this,tt,"f")),"f"),n.prev=1,n.next=2,C(this,B,"f").register(g({requestDelegate:p,requestOptions:{extraHeaders:u||C(this,G,"f")}},h));case 2:n.next=4;break;case 3:n.prev=3,v=n.catch(1),C(this,F,"m",Vt).call(this),s(v);case 4:case"end":return n.stop()}},n,this,[[1,3]])}))})};var fn=function(){return i(function e(){n(this,e)},null,[{key:"getUserAgentManager",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return C(this,cn,"f",un)||q(this,cn,new ln(e),"f",un),C(this,cn,"f",un)}},{key:"hasUserAgentManager",value:function(){return!!C(this,cn,"f",un)}},{key:"newUserAgentManager",value:function(){return new ln(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}},{key:"dispose",value:function(){if(C(this,cn,"f",un))try{C(this,cn,"f",un).dispose()}catch(e){}finally{q(this,cn,void 0,"f",un)}}}])}();cn=fn,un={value:void 0},Object.defineProperty(exports,"Inviter",{enumerable:!0,get:function(){return r.Inviter}}),Object.defineProperty(exports,"Registerer",{enumerable:!0,get:function(){return r.Registerer}}),Object.defineProperty(exports,"SessionState",{enumerable:!0,get:function(){return r.SessionState}}),Object.defineProperty(exports,"URI",{enumerable:!0,get:function(){return r.URI}}),Object.defineProperty(exports,"UserAgent",{enumerable:!0,get:function(){return r.UserAgent}}),Object.defineProperty(exports,"SimpleUser",{enumerable:!0,get:function(){return s.SimpleUser}}),exports.onChange=a,exports.UserAgentFactory=fn,exports.UserAgentManager=ln,exports.accumulateSec=an,exports.accumulationTimer=function(e){var t=sn();e(rn(t));var n=p(function(){var n=an(t),i=rn(n);e(i)},1e3);return function(){clearInterval(n),n=null}},exports.cleanupMedia=function(e){var t=z(e);t&&(t.srcObject=null,t.pause())},exports.getDevicePermission=X,exports.getMedia=z,exports.getTimes=rn,exports.getZeorTime=sn,exports.pauseMedia=function(e){var t=z(e);t&&(t.currentTime=0,t.pause())},exports.playMedia=function(e){var t=z(e);t&&(t.currentTime=0,t.play())},exports.requestMicroPhonePermission=function(){try{var e;if(-1===b(e=navigator.userAgent).call(e,"Firefox"))return X({video:!1,audio:!0}).catch(function(){return!0})}catch(e){console.log(e)}},exports.stopStreamTracks=L,exports.userAgentDefault=U,exports.userAgentStatus=H; | ||
| "use strict";var e,t,n=require("@babel/runtime-corejs3/helpers/esm/classCallCheck"),i=require("@babel/runtime-corejs3/helpers/esm/createClass"),r=require("sip.js"),s=require("sip.js/lib/platform/web/index.js"),a=require("on-change"),o=require("@babel/runtime-corejs3/helpers/esm/typeof"),c=require("@babel/runtime-corejs3/regenerator"),u=require("@babel/runtime-corejs3/core-js/json/stringify"),l=require("@babel/runtime-corejs3/core-js/object/define-property"),f=require("@babel/runtime-corejs3/core-js/date/now"),h=require("@babel/runtime-corejs3/core-js/instance/for-each"),d=require("@babel/runtime-corejs3/core-js/set-timeout"),p=require("@babel/runtime-corejs3/core-js/set-interval"),v=require("@babel/runtime-corejs3/core-js/promise"),g=require("@babel/runtime-corejs3/core-js/object/assign"),m=require("@babel/runtime-corejs3/core-js/instance/concat"),w=require("@babel/runtime-corejs3/core-js/instance/map"),b=require("@babel/runtime-corejs3/core-js/instance/index-of"),k=require("@babel/runtime-corejs3/core-js/instance/filter"),x=require("@babel/runtime-corejs3/core-js/weak-map"),y=require("@babel/runtime-corejs3/core-js/weak-set"),S=require("@babel/runtime-corejs3/core-js/object/keys"),A=require("@babel/runtime-corejs3/core-js/instance/pad-start"),I=require("@babel/runtime-corejs3/core-js/instance/slice"),T=require("crypto-js"),j=require("@fingerprintjs/fingerprintjs");function O(e,t,n,i){return new(n||(n=Promise))(function(r,s){function a(e){try{c(i.next(e))}catch(e){s(e)}}function o(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(a,o)}c((i=i.apply(e,t||[])).next())})}function C(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 q(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}"function"==typeof SuppressedError&&SuppressedError;var D,E,R,N,P=m(e="sip:".concat("","@")).call(e,""),U=m(t="".concat("","://")).call(t,""),M={authorizationPassword:"",authorizationUsername:"",viaHost:"",uri:r.UserAgent.makeURI(P),logLevel:"error",transportOptions:{server:U},contactName:""},H={connectStatus:!1,registerStatus:!1,invitatingStatus:!1,incomingStatus:!1,answerStatus:!1,reconnectStatus:!1};function z(e){return document.getElementById(e)}function L(e){if(e&&e.getTracks)try{var t=e.getTracks();h(t).call(t,function(e){try{e.stop()}catch(e){}})}catch(e){}}function X(e){return navigator.mediaDevices.getUserMedia(e).then(function(e){return e?(L(e),!0):v.reject(new Error("EmptyStreamError"))}).catch(function(e){return(!e||"NotAllowedError"!==e.name)&&v.reject(e)})}!function(e){e.NO="0",e.YES="1"}(D||(D={})),function(e){e.NO="0",e.YES="1"}(E||(E={})),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"}(R||(R={})),function(e){e.DIRECT_ANSWER="1",e.LISTEN_FIRST_AND_THEN_ANSWER_MANUALLY="2"}(N||(N={}));var F,G,_,B,Y,V,J,W,Z,K,$,Q,ee,te,ne,ie,re,se,ae,oe,ce,ue,le,fe,he,de,pe,ve,ge,me,we,be,ke,xe,ye,Se,Ae,Ie,Te,je,Oe,Ce,qe,De,Ee,Re,Ne,Pe,Ue,Me,He,ze,Le,Xe,Fe,Ge,_e,Be,Ye,Ve,Je,We,Ze,Ke,$e,Qe,et,tt,nt,it,rt,st,at,ot,ct,ut,lt,ft,ht,dt,pt,vt,gt,mt,wt,bt,kt,xt,yt,St,At,It,Tt,jt,Ot,Ct,qt,Dt,Et,Rt,Nt,Pt,Ut,Mt,Ht,zt,Lt,Xt,Ft,Gt,_t,Bt,Yt,Vt,Jt,Wt,Zt,Kt,$t,Qt,en,tn,nn,rn=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")},sn=function(){return new Date(new Date((new Date).toLocaleDateString()).getTime())},an=function(e){return new Date(e.setSeconds(e.getSeconds()+1))};function on(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,a=n.type,o=n.contentType,c=a||"POST",l=r,f=null;return s&&("GET"===c?l=l+"?"+function(e){var t=[];for(var n in e)t.push(n+"="+e[n]);return t.join("&")}(s):"POST"===c&&(f=u(s))),i.open(c,l,!0),{xhr:i,ajaxData:f,contentType:o}}var cn,un,ln=function(){return i(function e(){var t=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(n(this,e),F.add(this),G.set(this,void 0),_.set(this,void 0),B.set(this,void 0),Y.set(this,void 0),V.set(this,void 0),J.set(this,[]),W.set(this,[]),Z.set(this,{}),K.set(this,void 0),$.set(this,void 0),Q.set(this,new MediaStream),ee.set(this,JSON.parse(u(H))),te.set(this,0),ne.set(this,void 0),ie.set(this,void 0),re.set(this,void 0),l(this,"token",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),se.set(this,void 0),ae.set(this,48e4),oe.set(this,12e6),ce.set(this,{}),ue.set(this,void 0),le.set(this,void 0),fe.set(this,void 0),he.set(this,function(e){}),de.set(this,function(e){}),pe.set(this,function(e){}),ve.set(this,function(e){}),ge.set(this,function(e){return O(t,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(!C(this,ne,"f")||!C(this,ie,"f")){t.next=2;break}if(!(f()-C(this,ie,"f")>e)){t.next=2;break}return t.next=1,C(this,we,"f").call(this);case 1:n=t.sent,i=n.sign,r=n.timestamp,q(this,ne,null!=i?i:C(this,ne,"f"),"f"),q(this,ie,null!=r?r:C(this,ie,"f"),"f");case 2:case"end":return t.stop()}},t,this)}))}),me.set(this,function(e){return O(t,void 0,void 0,c.mark(function t(){var n,i,r,s,a;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!C(this,se,"f")){t.next=4;break}if(!(f()-C(this,se,"f")>e)){t.next=4;break}if(!C(this,re,"f")){t.next=2;break}return t.next=1,C(this,be,"f").call(this);case 1:n=t.sent,i=n.token,r=n.tokenTimestamp,q(this,re,null!=i?i:C(this,re,"f"),"f"),q(this,se,null!=r?r:f(),"f"),t.next=4;break;case 2:if(!this.token){t.next=4;break}return t.next=3,this.getGatewayAccessToken({corpId:C(this,Fe,"f"),sid:C(this,Be,"f"),secret:C(this,Ge,"f"),seatOnline:!1});case 3:s=t.sent,a=s.token,this.token=a,q(this,se,f(),"f");case 4:case"end":return t.stop()}},t,this)}))}),we.set(this,function(){}),be.set(this,function(){}),ke.set(this,function(e){}),xe.set(this,function(e){}),ye.set(this,void 0),Se.set(this,void 0),l(this,"networkSpeed",{enumerable:!0,configurable:!0,writable:!0,value:"0.00Mb/s"}),l(this,"networkDelay",{enumerable:!0,configurable:!0,writable:!0,value:"0ms"}),l(this,"onLine",{enumerable:!0,configurable:!0,writable:!0,value:navigator.onLine}),l(this,"testspeeding",{enumerable:!0,configurable:!0,writable:!0,value:!1}),l(this,"goodNetworkSpeed",{enumerable:!0,configurable:!0,writable:!0,value:function(){return 1e3*Number(t.networkSpeed.replace("Mb/s",""))>=30}}),l(this,"goodNetworkDelay",{enumerable:!0,configurable:!0,writable:!0,value:function(){return Number(t.networkDelay.replace("ms",""))<=500&&"0ms"!==t.networkDelay}}),l(this,"authorizedMicrophonePermissions",{enumerable:!0,configurable:!0,writable:!0,value:!1}),l(this,"authorizedNotificationPermissions",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Ae.set(this,100),Ie.set(this,3),Te.set(this,8),je.set(this,3),Oe.set(this,0),Ce.set(this,!1),qe.set(this,void 0),De.set(this,3),Ee.set(this,3),Re.set(this,0),Ne.set(this,0),Pe.set(this,0),Ue.set(this,!1),Me.set(this,!1),He.set(this,!1),ze.set(this,void 0),Le.set(this,void 0),Xe.set(this,void 0),Fe.set(this,void 0),Ge.set(this,void 0),_e.set(this,void 0),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,function(e){C(t,F,"m",$t).call(t)}),Ke.set(this,function(){}),$e.set(this,void 0),Qe.set(this,void 0),et.set(this,!1),tt.set(this,4e3),nt.set(this,4e3),it.set(this,{}),rt.set(this,!1),st.set(this,!0),l(this,"ifAutoAnswer",{enumerable:!0,configurable:!0,writable:!0,value:function(){return String(C(t,it,"f").autoAnswer)===D.YES}}),l(this,"notNeedSendStarDtmf",{enumerable:!0,configurable:!0,writable:!0,value:function(){return String(C(t,it,"f").afterTransferLabour)===N.DIRECT_ANSWER}}),at.set(this,function(){if(C(t,st,"f")){var e;C(t,ot,"f").call(t);var n=new(window.AudioContext||window.webkitAudioContext);q(t,le,n.createScriptProcessor(2048,1,1),"f"),C(t,le,"f").onaudioprocess=function(e){for(var n=e.inputBuffer.getChannelData(0),i=0,r=0;r<n.length;++r)i+=n[r]*n[r];q(t,te,Number(Math.sqrt(i/n.length).toFixed(2)),"f"),C(t,he,"f").call(t,C(t,te,"f"))},q(t,fe,new MediaStream,"f"),h(e=t.getSenders()).call(e,function(e){e.track&&C(t,fe,"f").addTrack(e.track)}),q(t,ue,n.createMediaStreamSource(C(t,fe,"f")),"f"),C(t,ue,"f").connect(C(t,le,"f")),C(t,le,"f").connect(n.destination)}}),ot.set(this,function(){if(C(t,st,"f")){if(C(t,ue,"f"))try{C(t,ue,"f").disconnect()}catch(e){console.log(e)}if(C(t,le,"f"))try{C(t,le,"f").disconnect()}catch(e){console.log(e)}if(C(t,fe,"f"))try{var e;h(e=C(t,fe,"f").getTracks()).call(e,function(e){e.stop()})}catch(e){console.log(e)}}q(t,ue,void 0,"f"),q(t,le,void 0,"f"),q(t,fe,void 0,"f"),q(t,te,0,"f"),C(t,he,"f").call(t,C(t,te,"f"))}),l(this,"disposeSoftphoneEnvRequirementCheck",{enumerable:!0,configurable:!0,writable:!0,value:function(){C(t,ct,"f").call(t),window.removeEventListener("offline",C(t,ft,"f")),window.removeEventListener("online",C(t,lt,"f")),window.removeEventListener("unload",t.disposeSoftphoneEnvRequirementCheck)}}),ct.set(this,function(){clearInterval(C(t,ye,"f")),q(t,ye,void 0,"f"),clearTimeout(C(t,Se,"f")),q(t,Se,void 0,"f"),t.testspeeding=!1}),l(this,"softphoneEnvCheck",{enumerable:!0,configurable:!0,writable:!0,value:function(){return O(t,void 0,void 0,c.mark(function e(){return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this.testspeeding||(C(this,ut,"f").call(this),this.oneRoundOfTesting());case 1:case"end":return e.stop()}},e,this)}))}}),ut.set(this,function(){window.addEventListener("offline",C(t,ft,"f")),window.addEventListener("online",C(t,lt,"f")),window.addEventListener("unload",t.disposeSoftphoneEnvRequirementCheck)}),l(this,"oneRoundOfTesting",{enumerable:!0,configurable:!0,writable:!0,value:function(){return O(t,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?(C(this,ht,"f").call(this,this),q(this,Se,d(function(){t.testspeeding=!1,t.disposeSoftphoneEnvRequirementCheck()},4e3),"f")):this.testspeeding=!1;case 1:case"end":return e.stop()}},e,this)}))}}),lt.set(this,function(){t.onLine=!0,t.oneRoundOfTesting()}),ft.set(this,function(){t.onLine=!1,t.networkSpeed="0.00Mb/s",t.networkDelay="0ms",C(t,xe,"f").call(t,{networkSpeed:t.networkSpeed,networkDelay:t.networkDelay,authorizedMicrophonePermissions:t.authorizedMicrophonePermissions,authorizedNotificationPermissions:t.authorizedNotificationPermissions}),C(t,ct,"f").call(t)}),ht.set(this,function(e){return O(t,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(C(n,ye,"f")),q(n,ye,void 0,"f"),i=function(){return O(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,C(n,dt,"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:C(this,xe,"f").call(this,{networkSpeed:this.networkSpeed,networkDelay:this.networkDelay,authorizedMicrophonePermissions:this.authorizedMicrophonePermissions,authorizedNotificationPermissions:this.authorizedNotificationPermissions}),C(this,Se,"f")||(this.testspeeding=!1,this.disposeSoftphoneEnvRequirementCheck());case 7:case"end":return e.stop()}},e,this,[[1,3]])}))},t.next=1,i();case 1:C(this,Se,"f")&&q(n,ye,p(function(){return O(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)}))}),dt.set(this,function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"https://seat.94ai.com/favicon.png",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:63491,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return O(t,void 0,void 0,c.mark(function t(){var r,s;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:for(r=[],s=0;s<i;s++)r.push(C(this,pt,"f").call(this,e+"?d="+f()+s,n));return t.abrupt("return",v.all(r).then(function(e){var t=0,n=0;return h(e).call(e,function(e){t+=Number(e[0]),n+=Number(e[1])}),{networkDelay:(n/i).toFixed(2)+"ms",networkSpeed:(t/i).toFixed(2)+"Mb/s"}}));case 1:case"end":return t.stop()}},t,this)}))}),pt.set(this,function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"https://seat.94ai.com/favicon.png?d="+f(),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})}),l(this,"openApiAjax",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return new v(function(n,i){return O(t,void 0,void 0,c.mark(function t(){var r,s,a,o,u,l,f;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=on(n,i,e),s=r.xhr,a=r.ajaxData,o=r.contentType,t.next=1,this.getOpenApiSign();case 1:return u=t.sent,l=u.timestamp,f=u.sign,s.setRequestHeader("appKey",C(this,Fe,"f")),s.setRequestHeader("timestamp",String(l)),s.setRequestHeader("sign",f),s.setRequestHeader("Content-type",o||"application/json"),t.next=2,C(this,pe,"f").call(this,s);case 2:s.send(a);case 3:case"end":return t.stop()}},t,this)}))})}}),l(this,"requestGateway",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t.gatewayApiAjax(g(g({},e),{url:t.getGateway()+e.url}),n)}}),l(this,"gatewayApiAjax",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return new v(function(i,r){return O(t,void 0,void 0,c.mark(function t(){var s,a,o,u,l;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(s=on(i,r,e),a=s.xhr,o=s.ajaxData,u=s.contentType,!n){t.next=2;break}return t.next=1,this.getGatewayToken();case 1:l=t.sent,a.setRequestHeader("x-token",l),a.setRequestHeader("seatsToken",l),a.setRequestHeader("x-authority-token",l);case 2:return a.setRequestHeader("x-app-code",3),a.setRequestHeader("content-type",u||"application/json"),t.next=3,C(this,ve,"f").call(this,a);case 3:a.send(o);case 4:case"end":return t.stop()}},t,this)}))})}}),l(this,"requestOpenApi",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return t.openApiAjax(g(g({},e),{url:t.getOpenApi()+e.url}))}}),l(this,"getDeviceId",{enumerable:!0,configurable:!0,writable:!0,value:function(){return O(t,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(!C(this,We,"f")){e.next=1;break}return e.abrupt("return",C(this,We,"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,q(this,We,n.visitorId,"f"),e.abrupt("return",C(this,We,"f"));case 4:case"end":return e.stop()}},e,this)}))}}),yt.set(this,function(){return O(t,void 0,void 0,c.mark(function e(){var t,n,i,s;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!C(this,F,"m",xt).call(this)||C(this,Z,"f").authorizationUsername&&C(this,Z,"f").uri&&C(this,Z,"f").authorizationPassword&&C(this,Z,"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,C(this,Z,"f").authorizationUsername=s.agentExtension,C(this,Z,"f").authorizationPassword=s.extensionPwd,C(this,Z,"f").contactName||(C(this,Z,"f").contactName=s.agentExtension),C(this,Z,"f").uri=r.UserAgent.makeURI(m(n="sip:".concat(s.agentExtension,"@")).call(n,s.wsRegisterAddress)),C(this,Z,"f").transportOptions.server=m(i="".concat(s.wsProtocol,"://")).call(i,s.wsRegisterAddress),q(this,Be,s.agentId,"f"),q(this,_e,s.agentTag,"f"),e.next=3;break;case 2:throw new Error(u(t));case 3:case"end":return e.stop()}},e,this)}))}),St.set(this,function(){return O(t,void 0,void 0,c.mark(function e(){var t;return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(C(this,Z,"f").viaHost){e.next=2;break}return t="",e.next=1,this.getDeviceId();case 1:C(this,Z,"f").viaHost=m(t).call(t,e.sent,".sip");case 2:case"end":return e.stop()}},e,this)}))}),It.set(this,function(e){var n,i,r,s,a,o,c,u,l,f,h,d,p,v,g,m,b,k,x,y,S,A,I;C(t,it,"f").popWindow=null===(a=e["X-Popwindow"])||void 0===a?void 0:a[0].raw,C(t,it,"f").afterTransferLabour=null===(o=e["X-Aftertransferlabour"])||void 0===o?void 0:o[0].raw,C(t,it,"f").callId=null===(c=e["X-94callid"])||void 0===c?void 0:c[0].raw,C(t,it,"f").cid=null===(u=e["X-Cid"])||void 0===u?void 0:u[0].raw,C(t,it,"f").numberId=null===(l=e["X-Numberid"])||void 0===l?void 0:l[0].raw,C(t,it,"f").tag=(null===(f=e["X-Tag"])||void 0===f?void 0:f[0].raw)&&"null"!==(null===(h=e["X-Tag"])||void 0===h?void 0:h[0].raw)?w(n=e["X-Tag"][0].raw.split("-")).call(n,function(e){return String.fromCharCode(e)}).join(""):"",C(t,it,"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):"",C(t,it,"f").taskId=null===(v=e["X-Taskid"])||void 0===v?void 0:v[0].raw,C(t,it,"f").voiceType=null===(g=e["X-Voicetype"])||void 0===g?void 0:g[0].raw,C(t,it,"f").processTime=null===(m=e["X-Processtime"])||void 0===m?void 0:m[0].raw,C(t,it,"f").userPhone=null===(b=e["X-Userphone"])||void 0===b?void 0:b[0].raw,C(t,it,"f").autoAnswer=null===(k=e["X-94autoanswer"])||void 0===k?void 0:k[0].raw,C(t,it,"f").nodeTitle=null===(x=e["X-Nodetitle"])||void 0===x?void 0:w(i=x[0].raw.split("-")).call(i,function(e){return String.fromCharCode(e)}).join(""),C(t,it,"f").taskName=null===(y=e["X-Taskname"])||void 0===y?void 0:w(r=y[0].raw.split("-")).call(r,function(e){return String.fromCharCode(e)}).join(""),C(t,it,"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(""),C(t,it,"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)}),zt.set(this,function(e){switch(e){case r.SessionState.Initial:case r.SessionState.Establishing:break;case r.SessionState.Established:C(t,F,"m",Ht).call(t);break;case r.SessionState.Terminating:case r.SessionState.Terminated:var n=d(function(){clearTimeout(n),n=void 0,C(t,ee,"f").incomingStatus=!1,C(t,ee,"f").answerStatus=!1},10);C(t,ot,"f").call(t);break;default:throw new Error("Unknown session state.")}}),Xt.set(this,function(e,n,i){C(t,Te,"f")&&(q(t,Ce,!1,"f"),C(t,ee,"f").reconnectStatus=!1,C(t,Me,"f")&&(q(t,Me,!1,"f"),C(t,_t,"f").call(t,e,n,i)))}),Ft.set(this,function(){return O(t,void 0,void 0,c.mark(function e(){return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!C(this,Te,"f")){e.next=6;break}return q(this,Ce,!0,"f"),q(this,Me,!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,C(this,F,"m",Lt).call(this);case 3:e.next=5;break;case 4:e.prev=4,e.catch(2);case 5:C(this,Bt,"f").call(this),C(this,F,"m",$t).call(this);case 6:case"end":return e.stop()}},e,this,[[2,4]])}))}),Gt.set(this,function(){if(C(t,Te,"f")){var e=C(t,Z,"f").uri.clone(),n=C(t,Z,"f").uri.clone(),i=C(t,Z,"f").uri.clone();i.user=void 0,C(t,_t,"f").call(t,i,e,n)}}),_t.set(this,function(e,n,i){if(C(t,Te,"f")){if(C(t,Me,"f"))return;q(t,Me,!0,"f"),q(t,Le,d(function(){C(t,F,"m",Zt).call(t);var r=t.getUserAgent().userAgentCore,s=r.makeOutgoingRequestMessage("OPTIONS",e,n,i,{});q(t,qe,r.request(s,{onAccept:function(){console.log("sip ping ok"),q(t,Oe,0,"f"),q(t,qe,void 0,"f"),C(t,Xt,"f").call(t,e,n,i)},onReject:function(r){var s;if(q(t,qe,void 0,"f"),408===r.message.statusCode||503===r.message.statusCode)if(console.log("sip ping error with code "+r.message.statusCode),C(t,je,"f")>0&&C(t,Oe,"f")>=C(t,je,"f"))console.log("sip maximum ping attempts reached"),C(t,Ft,"f").call(t);else{var a,o;if(C(t,Oe,"f")>0)console.log(m(o="sip ping retry ".concat(C(t,Oe,"f")," of ")).call(o,C(t,je,"f")," fail"));q(t,Oe,(s=C(t,Oe,"f"),++s),"f"),console.log(m(a="sip ping retry ".concat(C(t,Oe,"f")," of ")).call(a,C(t,je,"f"))),C(t,Xt,"f").call(t,e,n,i)}else q(t,Oe,0,"f"),C(t,Xt,"f").call(t,e,n,i)}}),"f")},1e3*C(t,Te,"f")),"f")}}),Bt.set(this,function(){if(C(t,Te,"f")){if(q(t,Me,!1,"f"),q(t,Ce,!1,"f"),C(t,qe,"f")){try{C(t,qe,"f").dispose()}catch(e){}q(t,qe,void 0,"f")}C(t,Le,"f")&&C(t,F,"m",Zt).call(t)}}),Kt.set(this,function(){if(C(t,De,"f")){if(C(t,He,"f"))return;q(t,He,!0,"f"),C(t,ee,"f").reconnectStatus=!0,q(t,Xe,d(function(){return O(t,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,C(this,F,"m",Jt).call(this),0===C(this,Re,"f")&&console.log("sip reconnect success then register start"),e.next=1,C(this,B,"f").register({requestDelegate:{onAccept:function(e){console.log("sip reconnect success and register ok"),q(n,Re,0,"f"),q(n,He,!1,"f"),C(n,ee,"f").registerStatus=!0,C(n,ee,"f").reconnectStatus=!1,C(n,Gt,"f").call(n)},onReject:function(e){return O(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),q(this,He,!1,"f"),!(C(this,Ee,"f")<=C(this,Re,"f"))){t.next=2;break}return console.log("sip maximum register attempts reached"),q(this,Re,0,"f"),t.next=1,this.getUserAgent().transport.disconnect().catch(function(e){return console.error(e)});case 1:C(this,F,"m",$t).call(this),t.next=3;break;case 2:q(this,Re,(n=C(this,Re,"f"),++n),"f"),console.log(m(i="sip reconnect success and register retry ".concat(C(this,Re,"f")," of ")).call(i,C(this,Ee,"f"))),C(this,Kt,"f").call(this);case 3:case"end":return t.stop()}},t,this)}))}},requestOptions:{extraHeaders:C(this,G,"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),q(this,Re,0,"f"),q(this,He,!1,"f");case 3:case"end":return e.stop()}},e,this,[[0,2]])}))},1e3*C(t,De,"f")),"f")}}),"object"!==o(i))throw new Error("userAgentOption must be plain object");C(this,F,"m",wt).call(this,i),C(this,F,"m",bt).call(this,i),C(this,F,"m",mt).call(this,i),C(this,F,"m",kt).call(this,i),C(this,F,"m",jt).call(this,i),C(this,F,"m",gt).call(this,i),C(this,F,"m",vt).call(this,i),q(this,Z,C(this,F,"m",Ct).call(this,i),"f")},[{key:"volumeValue",get:function(){return C(this,te,"f")}},{key:"businessAttribute",get:function(){return C(this,it,"f")}},{key:"getFastOutboundCall",value:function(){return C(this,it,"f").voiceType===R.LABOUR}},{key:"getSitOutboundCall",value:function(){return C(this,it,"f").voiceType===R.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"===C(this,Je,"f")?"https://gateway.sg.94ai.com":"https://gateway.94ai.com"}},{key:"getGatewayToken",value:function(){return O(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,C(this,me,"f").call(this,C(this,oe,"f"));case 1:if(!C(this,re,"f")){e.next=2;break}return e.abrupt("return",C(this,re,"f"));case 2:if(this.token){e.next=5;break}return e.next=3,C(this,yt,"f").call(this);case 3:return e.next=4,this.getGatewayAccessToken({corpId:C(this,Fe,"f"),sid:C(this,Be,"f"),secret:C(this,Ge,"f"),seatOnline:!1});case 4:t=e.sent,n=t.token,this.token=n,q(this,se,f(),"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 O(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=g({},C(this,it,"f")),n=function(){return O(r,void 0,void 0,c.mark(function e(){var n,i,r,s,a,o,u,l,f,h,d,p,v,g,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,C(this,ke,"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=m(i=m(r="当前会话callid:".concat(t.callId,",根据numberId:")).call(r,t.numberId,",taskId:")).call(i,t.taskId,":查询坐席接听状态异常"),console.error(s),t.stop=!0,C(this,ke,"f").call(this,new Error(n.message)),e.abrupt("return");case 5:if(a=n.data,o=a.callType,u=a.newIntentTag,l=a.intentTag,f=a.number,h=a.numberMd5,d=a.sid,p=a.config,v=a.tag,10!==a.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=o),t.intentTag=u||l,t.number||(t.number=f),t.numberMD5||(t.numberMD5=h),t.agentId||(t.agentId=d),t.tag||(t.tag=v),t.templateId||p&&"string"==typeof p&&(g=JSON.parse(p))&&g.templateId&&(t.templateId=g.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,C(this,ke,"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=m(x="当前会话根据callId:".concat(t.callId,",taskId:")).call(x,t.taskId,":查询会话对话记录异常"),console.error(y),t.stop=!0,C(this,ke,"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}),C(this,ce,"f")[t.callId]=t;case 12:try{C(this,de,"f").call(this,C(this,ce,"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),C(this,ke,"f").call(this,new Error(S))),t.numberId||(A="当前会话callid:".concat(t.callId,"的numberId不存在,无法查询通话记录"),console.error(A),C(this,ke,"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 O(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),C(this,ke,"f").call(this,i);case 9:case"end":return e.stop()}},e,this,[[1,8]])}))}},{key:"refreshCallChatInfo",value:function(){return O(this,void 0,void 0,c.mark(function e(){return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(C(this,it,"f").numberId&&C(this,it,"f").callId&&C(this,it,"f").taskId&&C(this,rt,"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 C(this,Ye,"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))}(C(this,Ye,"f"))?C(this,Ye,"f"):"1"===C(this,Je,"f")?"1"===C(this,Ve,"f")?"https://seatsg.94ai.com/sgopenapi":"https://seatsg.94ai.com/openapi":"1"===C(this,Ve,"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:C(this,_e,"f"),agentId:C(this,Be,"f")}})}},{key:"getOpenApiSign",value:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:f(),i=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0;return O(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,C(this,ge,"f").call(this,C(this,ae,"f"));case 1:return s.abrupt("return",{sign:null!==(e=C(this,ne,"f"))&&void 0!==e?e:T.enc.Base64.stringify(T.HmacSHA1(i||C(this,Fe,"f")+n,r||C(this,Ge,"f"))),timestamp:null!==(t=C(this,ie,"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:C(this,_e,"f"),agentId:C(this,Be,"f"),agentStatus:e}})}},{key:"importOpenApiAgentCustomer",value:function(e){return this.requestOpenApi({url:"/v1/task/importAgentCustomer",data:{agentTag:C(this,_e,"f"),agentId:C(this,Be,"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){q(this,ne,e,"f")}},{key:"prepareUserAgent",value:function(e,t){var n;return O(this,void 0,void 0,c.mark(function i(){var r,s,a,o,u,l,f,h,d,p,v,m;return c.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return s=(r=e||{}).refresh,a=r.registererOptions,o=r.registererRegisterOptions,u=r.extraHeaders,l=r.authorizationUsername,f=r.authorizationPassword,h=r.uri,d=r.contactName,p=r.transportOptions,i.next=1,this.dispose();case 1:return C(this,Z,"f").uri=null!=h?h:C(this,Z,"f").uri,C(this,Z,"f").authorizationUsername=null!=l?l:C(this,Z,"f").authorizationUsername,C(this,Z,"f").authorizationPassword=null!=f?f:C(this,Z,"f").authorizationPassword,C(this,Z,"f").contactName=null!==(n=null!=d?d:l)&&void 0!==n?n:C(this,Z,"f").contactName,p&&(C(this,Z,"f").transportOptions=g(g({},C(this,Z,"f").transportOptions),p)),i.prev=2,C(this,F,"m",bt).call(this,e),i.next=3,C(this,yt,"f").call(this);case 3:return i.next=4,C(this,St,"f").call(this);case 4:return C(this,F,"m",Tt).call(this,{refresh:s}),i.next=5,C(this,F,"m",tn).call(this);case 5:return t&&C(this,F,"m",en).call(this,t),i.next=6,C(this,F,"m",nn).call(this,{registererOptions:a,registererRegisterOptions:o,extraHeaders:u},C(this,et,"f"));case 6:return v=i.sent,i.abrupt("return",v);case 7:return i.prev=7,m=i.catch(2),i.next=8,this.dispose();case 8:throw m;case 9:case"end":return i.stop()}},i,this,[[2,7]])}))}},{key:"dispose",value:function(){return O(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,C(this,F,"m",At).call(this),e.next=1,C(this,F,"m",Dt).call(this);case 1:e.next=3;break;case 2:e.prev=2,t=e.catch(0),C(this,F,"m",Rt).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 O(this,void 0,void 0,c.mark(function t(){return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return C(this,ee,"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 O(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){O(i,void 0,void 0,c.mark(function i(){var r,s,a;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(g({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,a=i.catch(0),n(a);case 3:case"end":return i.stop()}},i,this,[[0,2]])}))});case 1:C(this,ee,"f").incomingStatus&&(C(this,ee,"f").incomingStatus=!1,C(this,ee,"f").answerStatus=!0),t.next=3;break;case 2:throw t.prev=2,n=t.catch(0),C(this,ee,"f").incomingStatus=!1,n;case 3:case"end":return t.stop()}},t,this,[[0,2]])}))}},{key:"hangUpInvite",value:function(e){return O(this,void 0,void 0,c.mark(function t(){var n,i,s,a,o,u=this;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return i=(n=e||{}).rejectOptions,s=n.byeOptions,a=n.extraHeaders,o=n.scoutResponse,t.abrupt("return",new v(function(e,t){return O(u,void 0,void 0,c.mark(function n(){var u,l,f,h,d,p,v,m,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,m=null===(l=p.requestDelegate)||void 0===l?void 0:l.onReject,null===(f=p.requestDelegate)||void 0===f||delete f.onAccept,null===(h=p.requestDelegate)||void 0===h||delete h.onReject,w=C(this,F,"m",Ot).call(this,{onAccept:function(t){console.log("sip bye success"),e(t),null==v||v(t)},onReject:function(e){null==m||m(e),t(new Error("sip bye fail with code "+e.message.statusCode))}},p.requestDelegate),delete p.requestDelegate,b=null===(d=C(this,K,"f"))||void 0===d?void 0:d.state,n.next=b===r.SessionState.Initial||b===r.SessionState.Establishing?1:b===r.SessionState.Established?3:b===r.SessionState.Terminating||b===r.SessionState.Terminated?5:6;break;case 1:return n.next=2,C(this,K,"f").reject(g({extraHeaders:a},i||{}));case 2:return e(!0),n.abrupt("continue",6);case 3:return n.next=4,C(this,K,"f").bye(g({requestDelegate:w,requestOptions:{extraHeaders:a}},p));case 4:return o||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,C(this,ee,"f").incomingStatus=!1,C(this,ee,"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 O(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 O(n,void 0,void 0,c.mark(function n(){var r,s,a,o,u;return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,s=(r=e||{}).extraHeaders,a=r.requestDelegate,o=C(this,F,"m",Ot).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))}},a),delete r.requestDelegate,n.next=1,this.getCurrentInvitation().info(g({requestOptions:{body:{contentDisposition:"render",contentType:"application/dtmf-relay",content:"Signal=*\r\nDuration=100"},extraHeaders:s},requestDelegate:o},r));case 1:C(this,at,"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=C(this,V,"f").getReceivers()).call(e,function(e){e.track.enabled=!1})}},{key:"unMuteRemoteAudio",value:function(){var e;h(e=C(this,V,"f").getReceivers()).call(e,function(e){e.track.enabled=!0})}},{key:"muteLocalAudio",value:function(){var e;h(e=C(this,V,"f").getSenders()).call(e,function(e){e.track.enabled=!1})}},{key:"unMuteLocalAudio",value:function(){var e;h(e=C(this,V,"f").getSenders()).call(e,function(e){e.track.enabled=!0})}},{key:"getUserAgentStatue",value:function(){return C(this,ee,"f")}},{key:"getUserAgent",value:function(){return C(this,_,"f")||q(this,_,new r.UserAgent(C(this,Z,"f")),"f"),C(this,_,"f")}},{key:"getSessionDescriptionHandler",value:function(){return C(this,Y,"f")}},{key:"getPeerConnection",value:function(){return C(this,V,"f")}},{key:"getSenders",value:function(){return C(this,W,"f")}},{key:"getReceivers",value:function(){return C(this,J,"f")}},{key:"getStream",value:function(){var e,t=this;return C(this,Q,"f")||q(this,Q,new MediaStream,"f"),h(e=C(this,J,"f")).call(e,function(e){e.track&&C(t,Q,"f").addTrack(e.track)}),C(this,Q,"f")}},{key:"getCurrentInviter",value:function(){if(!C(this,$,"f"))throw new Error("No currentInviter...");return C(this,$,"f")}},{key:"getCurrentInvitation",value:function(){return C(this,K,"f")}},{key:"invite",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return O(this,void 0,void 0,c.mark(function n(){var i,s,a;return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(s=r.UserAgent.makeURI(e.uri?e.uri:m(i="sip:".concat(e.extension,"@")).call(i,C(this,Z,"f").transportOptions.server.split("://")[1]))){n.next=1;break}throw new Error("Failed to create target URI.");case 1:return q(this,$,new r.Inviter(this.getUserAgent(),s,{sessionDescriptionHandlerOptions:{constraints:{audio:!0,video:!1}}}),"f"),a=(t||{}).extraHeaders,n.next=2,this.getCurrentInviter().invite(g({requestOptions:{extraHeaders:a}},t));case 2:return n.abrupt("return",C(this,$,"f"));case 3:case"end":return n.stop()}},n,this)}))}}])}();G=new x,_=new x,B=new x,Y=new x,V=new x,J=new x,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,ae=new x,oe=new x,ce=new x,ue=new x,le=new x,fe=new x,he=new x,de=new x,pe=new x,ve=new x,ge=new x,me=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,Oe=new x,Ce=new x,qe=new x,De=new x,Ee=new x,Re=new x,Ne=new x,Pe=new x,Ue=new x,Me=new x,He=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,at=new x,ot=new x,ct=new x,ut=new x,lt=new x,ft=new x,ht=new x,dt=new x,pt=new x,yt=new x,St=new x,It=new x,zt=new x,Xt=new x,Ft=new x,Gt=new x,_t=new x,Bt=new x,Kt=new x,F=new y,vt=function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};q(this,pe,null!==(e=n.openXhrIntercept)&&void 0!==e?e:C(this,pe,"f"),"f"),q(this,ve,null!==(t=n.gatewayXhrIntercept)&&void 0!==t?t:C(this,ve,"f"),"f")},gt=function(){var e,t,n,i,r,s,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};q(this,rt,null!==(e=a.enableChatInfoPush)&&void 0!==e?e:C(this,rt,"f"),"f"),q(this,st,null!==(t=a.enableVolumnTrack)&&void 0!==t?t:C(this,st,"f"),"f"),q(this,he,null!==(n=a.refreshSpeekVolumn)&&void 0!==n?n:C(this,he,"f"),"f"),q(this,xe,null!==(i=a.refreshRequirementCheck)&&void 0!==i?i:C(this,xe,"f"),"f"),q(this,de,null!==(r=a.refreshChat)&&void 0!==r?r:C(this,de,"f"),"f"),q(this,ke,null!==(s=a.refreshChatErrorCallback)&&void 0!==s?s:C(this,ke,"f"),"f")},mt=function(){var e,t,n,i,r,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};q(this,re,null!==(e=s.token)&&void 0!==e?e:C(this,re,"f"),"f"),q(this,se,null!==(t=s.tokenTimestamp)&&void 0!==t?t:C(this,se,"f"),"f"),q(this,oe,null!==(n=s.tokenExpirationTime)&&void 0!==n?n:C(this,oe,"f"),"f"),C(this,re,"f")&&!C(this,se,"f")&&q(this,se,f(),"f"),q(this,me,null!==(i=s.tokenCheck)&&void 0!==i?i:C(this,me,"f"),"f"),q(this,be,null!==(r=s.tokenOverdued)&&void 0!==r?r:C(this,be,"f"),"f")},wt=function(){var e,t,n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};q(this,et,null!==(e=i.clusterMode)&&void 0!==e?e:C(this,et,"f"),"f"),q(this,tt,null!==(t=i.reClusterRegisterTimeout)&&void 0!==t?t:C(this,tt,"f"),"f"),q(this,nt,null!==(n=i.reClusterConnectTimeout)&&void 0!==n?n:C(this,nt,"f"),"f")},bt=function(){var e,t,n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.agentId,s=i.agentTag,a=i.appKey,o=i.appSecret,c=i.openBaseUrl,u=i.sg,l=i.sgOpen,f=i.sign,h=i.timestamp;q(this,Be,null!=r?r:C(this,Be,"f"),"f"),q(this,_e,null!=s?s:C(this,_e,"f"),"f"),q(this,Fe,null!=a?a:C(this,Fe,"f"),"f"),q(this,Ge,null!=o?o:C(this,Ge,"f"),"f"),q(this,Ye,null!=c?c:C(this,Ye,"f"),"f"),q(this,Je,null!=u?u:C(this,Je,"f"),"f"),q(this,Ve,null!=l?l:C(this,Ve,"f"),"f"),q(this,ne,null!=f?f:C(this,ne,"f"),"f"),q(this,ie,null!=h?h:C(this,ie,"f"),"f"),q(this,ae,null!==(e=i.signExpirationTime)&&void 0!==e?e:C(this,ae,"f"),"f"),q(this,ge,null!==(t=i.signCheck)&&void 0!==t?t:C(this,ge,"f"),"f"),q(this,we,null!==(n=i.signOverdued)&&void 0!==n?n:C(this,we,"f"),"f")},kt=function(e){e.sipHeaders&&(q(this,G,e.sipHeaders,"f"),delete e.sipHeaders)},xt=function(){return!(!C(this,Be,"f")&&!C(this,_e,"f")||!(C(this,Fe,"f")&&C(this,Ge,"f")||C(this,ne,"f")&&C(this,ie,"f")))},At=function(){C(this,F,"m",Et).call(this),C(this,F,"m",Ut).call(this),C(this,F,"m",Mt).call(this),C(this,F,"m",Pt).call(this),C(this,F,"m",Nt).call(this),C(this,F,"m",Yt).call(this),C(this,F,"m",Vt).call(this),C(this,F,"m",Rt).call(this),C(this,ot,"f").call(this),q(this,it,{},"f"),q(this,ce,{},"f")},Tt=function(e){q(this,ee,a(JSON.parse(u(H)),"function"==typeof e.refresh?e.refresh:C(this,Ke,"f")),"f")},jt=function(e){var t,n,i,r,s,a,o,c,u,l,f,h,d,p,v;q(this,Ae,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:C(this,Ae,"f"),"f"),q(this,Ie,null!==(o=null!==(s=null!==(r=e.reconnectionInterval)&&void 0!==r?r:e.reconnectionDelay)&&void 0!==s?s:null===(a=null==e?void 0:e.transportOptions)||void 0===a?void 0:a.reconnectionTimeout)&&void 0!==o?o:C(this,Ie,"f"),"f"),q(this,Ne,null!==(u=null===(c=e.transportOptions)||void 0===c?void 0:c.keepAliveInterval)&&void 0!==u?u:C(this,Ne,"f"),"f"),q(this,Pe,null!==(f=null===(l=e.transportOptions)||void 0===l?void 0:l.keepAliveDebounce)&&void 0!==f?f:C(this,Pe,"f"),"f"),q(this,De,null!==(h=e.registerInterval)&&void 0!==h?h:C(this,De,"f"),"f"),q(this,Te,null!==(d=e.optionsPingInterval)&&void 0!==d?d:C(this,Te,"f"),"f"),q(this,je,null!==(p=e.optionsPingAttempts)&&void 0!==p?p:C(this,je,"f"),"f"),q(this,Ee,null!==(v=e.registerAttempts)&&void 0!==v?v:C(this,Ee,"f"),"f")},Ot=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 O(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},Ct=function(e){var t,n=this,i={delegate:{onConnect:function(){return O(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"),C(this,Gt,"f").call(this);case 1:case"end":return e.stop()}},e,this)}))},onInvite:function(e){C(n,It,"f").call(n,e.incomingInviteRequest.message.headers),n.refreshCallChatInfo(),C(n,F,"m",qt).call(n),q(n,K,e,"f"),C(n,ee,"f").incomingStatus=!0,e.stateChange.addListener(C(n,zt,"f"))},onDisconnect:function(e){return O(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,C(this,Te,"f")>0&&(n=C(this,Ce,"f"),C(this,Bt,"f").call(this)),t.prev=1,t.next=2,C(this,F,"m",Lt).call(this);case 2:t.next=4;break;case 3:t.prev=3,t.catch(1);case 4:(e||n)&&C(this,F,"m",$t).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 O(n,void 0,void 0,c.mark(function t(){var n,a;return c.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return null===(a=(n=i.delegate)[r])||void 0===a||a.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=g(g({},e.transportOptions||{}),{keepAliveInterval:C(this,Ne,"f"),keepAliveDebounce:C(this,Pe,"f")}),void 0===e.sessionDescriptionHandlerFactoryOptions&&(e.sessionDescriptionHandlerFactoryOptions={iceGatheringTimeout:2e3,peerConnectionConfiguration:{iceServers:[]}}),g(g({},M),e)},qt=function(){C(this,K,"f")&&(C(this,K,"f").dispose(),q(this,K,void 0,"f"))},Dt=function(){return O(this,void 0,void 0,c.mark(function e(){return c.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!C(this,_,"f")){e.next=2;break}return e.next=1,C(this,_,"f").stop();case 1:q(this,_,void 0,"f");case 2:case"end":return e.stop()}},e,this)}))},Et=function(){var e;C(this,Q,"f")&&(h(e=C(this,Q,"f").getTracks()).call(e,function(e){e.stop()}),q(this,Q,void 0,"f"))},Rt=function(){var e,t=this;h(e=S(H)).call(e,function(e){var n=e;C(t,ee,"f")[n]=H[n]})},Nt=function(){C(this,Y,"f")&&(C(this,Y,"f").close(),q(this,Y,void 0,"f"))},Pt=function(){C(this,V,"f")&&(C(this,V,"f").close(),q(this,V,void 0,"f"))},Ut=function(){q(this,W,[],"f")},Mt=function(){q(this,J,[],"f")},Ht=function(){var e=this.getCurrentInvitation().sessionDescriptionHandler;C(this,F,"m",Pt).call(this),C(this,F,"m",Nt).call(this),C(this,F,"m",Ut).call(this),C(this,F,"m",Mt).call(this),q(this,Y,e,"f"),q(this,V,e.peerConnection,"f"),q(this,W,C(this,V,"f").getSenders(),"f"),q(this,J,C(this,V,"f").getReceivers(),"f"),(this.getFastOutboundCall()||!this.getSitOutboundCall()&&this.notNeedSendStarDtmf())&&C(this,at,"f").call(this)},Lt=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return O(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(!C(this,B,"f")){t.next=1;break}return console.log("sip due to disconnection, unregistered"),t.abrupt("return",new v(function(t,i){return O(n,void 0,void 0,c.mark(function n(){var r,s,a;return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,r=e||{},s=C(this,F,"m",Ot).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,C(this,B,"f").unregister(g({requestDelegate:s},e));case 1:n.next=3;break;case 2:n.prev=2,a=n.catch(0),i(a);case 3:case"end":return n.stop()}},n,this,[[0,2]])}))}));case 1:case"end":return t.stop()}},t,this)}))},Yt=function(){C(this,F,"m",Jt).call(this),C(this,F,"m",Wt).call(this),C(this,F,"m",Zt).call(this),q(this,He,!1,"f"),q(this,Ue,!1,"f"),q(this,Me,!1,"f")},Vt=function(){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&(clearTimeout(C(this,$e,"f")),q(this,$e,void 0,"f")),e&&(clearTimeout(C(this,Qe,"f")),q(this,Qe,void 0,"f"))},Jt=function(){clearTimeout(C(this,Xe,"f")),q(this,Xe,void 0,"f")},Wt=function(){clearTimeout(C(this,ze,"f")),q(this,ze,void 0,"f")},Zt=function(){clearTimeout(C(this,Le,"f")),q(this,Le,void 0,"f")},$t=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return O(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(!C(this,Ie,"f")){n.next=4;break}if(C(this,ee,"f").reconnectStatus=!0,!C(this,Ue,"f")){n.next=1;break}return n.abrupt("return");case 1:if(!(t>C(this,Ae,"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..."),q(this,Ue,!0,"f"),q(this,ze,d(function(){C(i,F,"m",Wt).call(i),i.getUserAgent().reconnect().then(function(){return O(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(m(n="sip reconnection attempt ".concat(t," of ")).call(n,C(this,Ae,"f")," - succeeded")),q(this,Ue,!1,"f"),C(this,Kt,"f").call(this);case 1:case"end":return e.stop()}},e,this)}))}).catch(function(n){var r;console.error(n),console.log(m(r="sip reconnection attempt ".concat(t," of ")).call(r,C(i,Ae,"f")," - failed")),q(i,Ue,!1,"f"),C(i,F,"m",e).call(i,++t)})},1===t?0:1e3*C(this,Ie,"f")),"f");case 4:case"end":return n.stop()}},n,this)}))},Qt=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 O(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=C(this,Z,"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},en=function(e){var t=this.getUserAgent();return t.delegate=C(this,F,"m",Qt).call(this,e),t},tn=function(){return O(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 C(this,ee,"f").connectStatus=!0,e.abrupt("return",t);case 4:case"end":return e.stop()}},e,this)}))},nn=function e(t){var n=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],s=t||{},a=s.registererOptions,o=s.registererRegisterOptions,u=s.extraHeaders;return new v(function(t,s){return O(n,void 0,void 0,c.mark(function n(){var l,f,h,p,v,m=this;return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return l=this.getUserAgent(),q(this,B,new r.Registerer(l,g({extraHeaders:u||C(this,G,"f")},a||{})),"f"),h=o||{},p=C(this,F,"m",Ot).call(this,{onAccept:function(e){f=e,C(m,F,"m",Vt).call(m),C(m,ee,"f").registerStatus=!0,t(l)},onReject:function(e){C(m,F,"m",Vt).call(m),s(new Error("sip register fail with code "+e.message.statusCode))}},h.requestDelegate),delete h.requestDelegate,i&&q(this,$e,d(function(){return O(m,void 0,void 0,c.mark(function n(){var i,v=this;return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(f){n.next=4;break}q(this,Qe,d(function(){return O(v,void 0,void 0,c.mark(function n(){var i,l;return c.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(C(this,F,"m",Vt).call(this,!1,!0),f){n.next=6;break}n.prev=1;try{C(this,B,"f").dispose()}catch(e){}return C(this,F,"m",At).call(this),C(this,Bt,"f").call(this),q(this,Oe,0,"f"),q(this,Re,0,"f"),n.next=2,C(this,_,"f").transport.dispose();case 2:return q(this,_,new r.UserAgent(C(this,Z,"f")),"f"),n.next=3,C(this,F,"m",tn).call(this);case 3:return n.next=4,C(this,F,"m",e).call(this,{registererOptions:a,registererRegisterOptions:o,extraHeaders:u});case 4:i=n.sent,t(i),n.next=6;break;case 5:n.prev=5,l=n.catch(1),s(l);case 6:case"end":return n.stop()}},n,this,[[1,5]])}))},C(this,nt,"f")),"f");try{C(this,B,"f").dispose()}catch(e){}return q(this,B,new r.Registerer(l,g({extraHeaders:u||C(this,G,"f")},a||{})),"f"),C(this,F,"m",Vt).call(this,!0,!1),n.prev=1,n.next=2,C(this,B,"f").register(g({requestDelegate:p,requestOptions:{extraHeaders:u||C(this,G,"f")}},h));case 2:n.next=4;break;case 3:n.prev=3,i=n.catch(1),C(this,F,"m",Vt).call(this),s(i);case 4:case"end":return n.stop()}},n,this,[[1,3]])}))},C(this,tt,"f")),"f"),n.prev=1,n.next=2,C(this,B,"f").register(g({requestDelegate:p,requestOptions:{extraHeaders:u||C(this,G,"f")}},h));case 2:n.next=4;break;case 3:n.prev=3,v=n.catch(1),C(this,F,"m",Vt).call(this),s(v);case 4:case"end":return n.stop()}},n,this,[[1,3]])}))})};var fn=function(){return i(function e(){n(this,e)},null,[{key:"getUserAgentManager",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return C(this,cn,"f",un)||q(this,cn,new ln(e),"f",un),C(this,cn,"f",un)}},{key:"hasUserAgentManager",value:function(){return!!C(this,cn,"f",un)}},{key:"newUserAgentManager",value:function(){return new ln(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}},{key:"dispose",value:function(){if(C(this,cn,"f",un))try{C(this,cn,"f",un).dispose()}catch(e){}finally{q(this,cn,void 0,"f",un)}}}])}();cn=fn,un={value:void 0},Object.defineProperty(exports,"Inviter",{enumerable:!0,get:function(){return r.Inviter}}),Object.defineProperty(exports,"Registerer",{enumerable:!0,get:function(){return r.Registerer}}),Object.defineProperty(exports,"SessionState",{enumerable:!0,get:function(){return r.SessionState}}),Object.defineProperty(exports,"URI",{enumerable:!0,get:function(){return r.URI}}),Object.defineProperty(exports,"UserAgent",{enumerable:!0,get:function(){return r.UserAgent}}),Object.defineProperty(exports,"SimpleUser",{enumerable:!0,get:function(){return s.SimpleUser}}),exports.onChange=a,exports.UserAgentFactory=fn,exports.UserAgentManager=ln,exports.accumulateSec=an,exports.accumulationTimer=function(e){var t=sn();e(rn(t));var n=p(function(){var n=an(t),i=rn(n);e(i)},1e3);return function(){clearInterval(n),n=null}},exports.cleanupMedia=function(e){var t=z(e);t&&(t.srcObject=null,t.pause())},exports.getDevicePermission=X,exports.getMedia=z,exports.getTimes=rn,exports.getZeorTime=sn,exports.pauseMedia=function(e){var t=z(e);t&&(t.currentTime=0,t.pause())},exports.playMedia=function(e){var t=z(e);t&&(t.currentTime=0,t.play())},exports.requestMicroPhonePermission=function(){try{var e;if(-1===b(e=navigator.userAgent).call(e,"Firefox"))return X({video:!1,audio:!0}).catch(function(){return!0})}catch(e){console.log(e)}},exports.stopStreamTracks=L,exports.userAgentDefault=M,exports.userAgentStatus=H; |
@@ -1,1 +0,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 k from"@babel/runtime-corejs3/core-js/instance/index-of";import b 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===k(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,ke,be,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,kt,bt,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!=k(r).call(r,"json")?e(JSON.parse(i.responseText)):-1!=k(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){}),ke.set(this,function(e){}),be.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,kt,"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)}))}),kt.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,bt,"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)}))}),bt.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,be,"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,k,b,x,y,S;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").taskId=null===(d=e["X-Taskid"])||void 0===d?void 0:d[0].raw,O(r,ut,"f").voiceType=null===(p=e["X-Voicetype"])||void 0===p?void 0:p[0].raw,O(r,ut,"f").processTime=null===(v=e["X-Processtime"])||void 0===v?void 0:v[0].raw,O(r,ut,"f").userPhone=null===(m=e["X-Userphone"])||void 0===m?void 0:m[0].raw,O(r,ut,"f").autoAnswer=null===(g=e["X-94autoanswer"])||void 0===g?void 0:g[0].raw,O(r,ut,"f").nodeTitle=null===(k=e["X-Nodetitle"])||void 0===k?void 0:w(n=k[0].raw.split("-")).call(n,function(e){return String.fromCharCode(e)}).join(""),O(r,ut,"f").taskName=null===(b=e["X-Taskname"])||void 0===b?void 0:w(i=b[0].raw.split("-")).call(i,function(e){return String.fromCharCode(e)}).join(""),O(r,ut,"f").templateTitle=null===(x=e["X-Templatetitle"])||void 0===x?void 0:w(s=x[0].raw.split("-")).call(s,function(e){return String.fromCharCode(e)}).join(""),O(r,ut,"f").phoneNumber=(null===(y=e["X-Phonenumber"])||void 0===y?void 0:y[0].raw)||(null===(S=e.From)||void 0===S?void 0:S[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===k(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){""!==b(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,k,b,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 b={},e.prev=7,e.next=8,this.getCallNumberChats({callId:t.callId,taskId:t.taskId});case 8:if(200===(b=e.sent).code){e.next=9;break}return console.error(b.message),t.stop=!0,O(this,Te,"f").call(this,new Error(b.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(k=b.data).call(k,function(e){return e.matchinfo&&(e.matchinfo=JSON.parse(e.matchinfo)),e}),O(this,pe,"f")[t.callId]=t;case 12:try{O(this,ke,"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,k,b;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,k=null===(d=O(this,ie,"f"))||void 0===d?void 0:d.state,n.next=k===i.Initial||k===i.Establishing?1:k===i.Established?3:k===i.Terminating||k===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,b=n.catch(0),t(b);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,ke=new x,be=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,kt=new x,bt=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,be,null!==(e=n.openXhrIntercept)&&void 0!==e?e:O(this,be,"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,ke,null!==(r=o.refreshChat)&&void 0!==r?r:O(this,ke,"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}; | ||
| 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
-1
| { | ||
| "name": "@94ai/softphone", | ||
| "version": "5.0.10", | ||
| "version": "5.0.11", | ||
| "description": "94 Intelligent Technology Co., Ltd softphone SDK", | ||
@@ -5,0 +5,0 @@ "main": "lib/softphone.cjs.min.cjs", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
1958711
1.22%30
3.45%3828
0.1%