ysyt-agent-sdk 1.0.47 → 1.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/src/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AgentDataType, AgentItemType, AgentStateDataType, DeviceType, InitInfoType, RequestBodyType, StateType } from './types';
|
|
2
|
-
import { Events } from '@/store/event-center';
|
|
1
|
+
import type { AgentDataType, AgentItemType, AgentStateDataType, DeviceType, InitInfoType, RequestBodyType, StateType } from './types';
|
|
2
|
+
import type { Events } from '@/store/event-center';
|
|
3
3
|
export type * from './types';
|
|
4
4
|
export * from './types/Enum';
|
|
5
5
|
declare class YSYTAgentSdk {
|
|
@@ -16,7 +16,7 @@ declare class YSYTAgentSdk {
|
|
|
16
16
|
* @param enableBrowserAlert 是否开启浏览器通知
|
|
17
17
|
*/
|
|
18
18
|
init({ actionNodeParams, url, appKey, appSecret, agentNo, enableBrowserAlert }: InitInfoType): Promise<void>;
|
|
19
|
-
on<K extends keyof Events>(event: K,
|
|
19
|
+
on<K extends keyof Events>(event: K, handler: (data: Events[K]) => void): this;
|
|
20
20
|
off<K extends keyof Events>(event: K, listener: (msg: Events[K]) => void): void;
|
|
21
21
|
offAll(): void;
|
|
22
22
|
destroyRtc(): Promise<void>;
|
|
@@ -14,7 +14,7 @@ const Re=globalThis,Ue=Re.trustedTypes,ke=Ue?Ue.createPolicy("lit-html",{createH
|
|
|
14
14
|
* @license
|
|
15
15
|
* Copyright 2017 Google LLC
|
|
16
16
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
17
|
-
*/},gt=globalThis;class dt extends De{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const A=super.createRenderRoot();return this.renderOptions.renderBefore??=A.firstChild,A}update(A){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(A),this._$Do=qt(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Xe}}dt._$litElement$=!0,dt.finalized=!0,gt.litElementHydrateSupport?.({LitElement:dt});const pt=gt.litElementPolyfillSupport;pt?.({LitElement:dt}),(gt.litElementVersions??=[]).push("4.2.1");const ut={statusColor:{[exports.AgentStatus.IDLE]:"#1D92E9",[exports.AgentStatus.BUSY]:"#F5212D",[exports.AgentStatus.OFFLINE]:"#8c8c8c",[exports.AgentStatus.RINGING]:"#e9b91d"}},Ct=["call_number"],mt=[],Et=["hangup"],It=["hold","hangup","unhold","mute","unmute","transfer","consult","satisfaction","dtmf"],Mt=["consult_transfer","conference","consult_retrieve"],wt=["hangup"],Bt=["hangup"],Qt=["answer","reject"],ft=["hangup","consult","transfer","hold","unhold","mute","unmute","satisfaction","dtmf"],St={agentInfo:{},isRtcReconnecting:!1,sessionId:"",enableBrowserAlert:!1,autoStateTimer:null},yt={isCalling:!1,direction:null,outCallIsAnswer:!1,incomingIsAnswer:!1,isMeeting:!1,isHold:!1,displayText:"",isMuted:!1,consultIsAnswer:!1,actionConfigs:[],answerDevice:1};const Tt=new class extends $A{updateIsCalling(A){this.setState({isCalling:A})}updateDirection(A){this.setState({direction:A})}updateOutCallIsAnswer(A){this.setState({outCallIsAnswer:A})}updateIsHold(A){this.getState().isHold=A}updateDisplayText(A){this.setState({displayText:A})}updateActionConfigs(A){this.setState({actionConfigs:A}),ae.emit(exports.EventName.PHONE_BAR_OPERATION,A)}updateConsultIsAnswer(A){this.setState({consultIsAnswer:A})}updateIsMuted(A){this.setState({isMuted:A})}updateIncomingIsAnswer(A){this.setState({incomingIsAnswer:A})}updateAnswerDevice(A){this.setState({answerDevice:A}),1!==A?(this.setState({actionConfigs:[]}),ae.emit(exports.EventName.PHONE_BAR_OPERATION,[])):St.stateObject.state===exports.AgentStatus.IDLE?(this.setState({actionConfigs:Ct}),ae.emit(exports.EventName.PHONE_BAR_OPERATION,Ct)):St.stateObject.state===exports.AgentStatus.BUSY&&(this.setState({actionConfigs:mt}),ae.emit(exports.EventName.PHONE_BAR_OPERATION,mt)),ae.emit(exports.EventName.UPDATE_ANSWER_DEVICE,A)}updateIsMeeting(A){this.setState({isMeeting:A})}reset(){this.setState({...yt})}getCallInfo(){return this.getState()}get(A){return this.getState()[A]}}(yt);class Dt extends Error{response;request;options;constructor(A,e,t){const s=`${A.status||0===A.status?A.status:""} ${A.statusText||""}`.trim();super(`Request failed with ${s?`status code ${s}`:"an unknown error"}: ${e.method} ${e.url}`),this.name="HTTPError",this.response=A,this.request=e,this.options=t}}class Rt extends Error{request;constructor(A){super(`Request timed out: ${A.method} ${A.url}`),this.name="TimeoutError",this.request=A}}const Ut=(()=>{let A=!1,e=!1;const t="function"==typeof globalThis.ReadableStream,s="function"==typeof globalThis.Request;if(t&&s)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return A=!0,"half"}}).headers.has("Content-Type")}catch(A){if(A instanceof Error&&"unsupported BodyInit type"===A.message)return!1;throw A}return A&&!e})(),kt="function"==typeof globalThis.AbortController,Gt="function"==typeof globalThis.AbortSignal&&"function"==typeof globalThis.AbortSignal.any,Yt="function"==typeof globalThis.ReadableStream,Ft="function"==typeof globalThis.FormData,xt=["get","post","put","patch","head","delete"],Zt={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},vt=2147483647,Kt=(new TextEncoder).encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Ot=Symbol("stop"),bt={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},Nt={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},Jt=(A,e)=>{const t=(A=>{if(!A)return 0;if(A instanceof FormData){let e=0;for(const[t,s]of A)e+=Kt,e+=(new TextEncoder).encode(`Content-Disposition: form-data; name="${t}"`).length,e+="string"==typeof s?(new TextEncoder).encode(s).length:s.size;return e}if(A instanceof Blob)return A.size;if(A instanceof ArrayBuffer)return A.byteLength;if("string"==typeof A)return(new TextEncoder).encode(A).length;if(A instanceof URLSearchParams)return(new TextEncoder).encode(A.toString()).length;if("byteLength"in A)return A.byteLength;if("object"==typeof A&&null!==A)try{const e=JSON.stringify(A);return(new TextEncoder).encode(e).length}catch{return 0}return 0})(A.body);let s=0;return new Request(A,{duplex:"half",body:new ReadableStream({async start(i){const r=A.body instanceof ReadableStream?A.body.getReader():new Response("").body.getReader();await async function A(){const{done:o,value:n}=await r.read();if(o)return e&&e({percent:1,transferredBytes:s,totalBytes:Math.max(t,s)},new Uint8Array),void i.close();s+=n.byteLength;let a=0===t?0:s/t;(t<s||1===a)&&(a=.99),e&&e({percent:Number(a.toFixed(2)),transferredBytes:s,totalBytes:t},n),i.enqueue(n),await A()}()}})})},Ht=A=>null!==A&&"object"==typeof A,jt=(...A)=>{for(const e of A)if((!Ht(e)||Array.isArray(e))&&void 0!==e)throw new TypeError("The `options` argument must be an object");return zt({},...A)},Lt=(A={},e={})=>{const t=new globalThis.Headers(A),s=e instanceof globalThis.Headers,i=new globalThis.Headers(e);for(const[A,e]of i.entries())s&&"undefined"===e||void 0===e?t.delete(A):t.set(A,e);return t};function Wt(A,e,t){return Object.hasOwn(e,t)&&void 0===e[t]?[]:zt(A[t]??[],e[t]??[])}const Pt=(A={},e={})=>({beforeRequest:Wt(A,e,"beforeRequest"),beforeRetry:Wt(A,e,"beforeRetry"),afterResponse:Wt(A,e,"afterResponse"),beforeError:Wt(A,e,"beforeError")}),zt=(...A)=>{let e={},t={},s={};for(const i of A)if(Array.isArray(i))Array.isArray(e)||(e=[]),e=[...e,...i];else if(Ht(i)){for(let[A,t]of Object.entries(i))Ht(t)&&A in e&&(t=zt(e[A],t)),e={...e,[A]:t};Ht(i.hooks)&&(s=Pt(s,i.hooks),e.hooks=s),Ht(i.headers)&&(t=Lt(t,i.headers),e.headers=t)}return e},Xt=A=>xt.includes(A)?A.toUpperCase():A,_t={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:A=>.3*2**(A-1)*1e3},$t=(A={})=>{if("number"==typeof A)return{..._t,limit:A};if(A.methods&&!Array.isArray(A.methods))throw new Error("retry.methods must be an array");if(A.statusCodes&&!Array.isArray(A.statusCodes))throw new Error("retry.statusCodes must be an array");return{..._t,...A}};class As{static create(A,e){const t=new As(A,e),s=async()=>{if("number"==typeof t._options.timeout&&t._options.timeout>vt)throw new RangeError("The `timeout` option cannot be greater than 2147483647");await Promise.resolve();let A=await t._fetch();for(const e of t._options.hooks.afterResponse){const s=await e(t.request,t._options,t._decorateResponse(A.clone()));s instanceof globalThis.Response&&(A=s)}if(t._decorateResponse(A),!A.ok&&t._options.throwHttpErrors){let e=new Dt(A,t.request,t._options);for(const A of t._options.hooks.beforeError)e=await A(e);throw e}if(t._options.onDownloadProgress){if("function"!=typeof t._options.onDownloadProgress)throw new TypeError("The `onDownloadProgress` option must be a function");if(!Yt)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return((A,e)=>{const t=Number(A.headers.get("content-length"))||0;let s=0;return 204===A.status?(e&&e({percent:1,totalBytes:t,transferredBytes:s},new Uint8Array),new Response(null,{status:A.status,statusText:A.statusText,headers:A.headers})):new Response(new ReadableStream({async start(i){const r=A.body.getReader();e&&e({percent:0,transferredBytes:0,totalBytes:t},new Uint8Array),await async function A(){const{done:o,value:n}=await r.read();o?i.close():(e&&(s+=n.byteLength,e({percent:0===t?0:s/t,transferredBytes:s,totalBytes:t},n)),i.enqueue(n),await A())}()}}),{status:A.status,statusText:A.statusText,headers:A.headers})})(A.clone(),t._options.onDownloadProgress)}return A},i=(t._options.retry.methods.includes(t.request.method.toLowerCase())?t._retry(s):s()).finally(async()=>{t.request.bodyUsed||await(t.request.body?.cancel())});for(const[A,s]of Object.entries(Zt))i[A]=async()=>{t.request.headers.set("accept",t.request.headers.get("accept")||s);const r=await i;if("json"===A){if(204===r.status)return"";if(0===(await r.clone().arrayBuffer()).byteLength)return"";if(e.parseJson)return e.parseJson(await r.text())}return r[A]()};return i}request;abortController;_retryCount=0;_input;_options;constructor(A,e={}){if(this._input=A,this._options={...e,headers:Lt(this._input.headers,e.headers),hooks:Pt({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},e.hooks),method:Xt(e.method??this._input.method??"GET"),prefixUrl:String(e.prefixUrl||""),retry:$t(e.retry),throwHttpErrors:!1!==e.throwHttpErrors,timeout:e.timeout??1e4,fetch:e.fetch??globalThis.fetch.bind(globalThis)},"string"!=typeof this._input&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&"string"==typeof this._input){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(kt&&Gt){const A=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=A?AbortSignal.any([A,this.abortController.signal]):this.abortController.signal}if(Ut&&(this._options.duplex="half"),void 0!==this._options.json&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const A="?"+("string"==typeof this._options.searchParams?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),e=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,A);!(Ft&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)||this._options.headers&&this._options.headers["content-type"]||this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(e,{...this.request}),this._options)}if(this._options.onUploadProgress){if("function"!=typeof this._options.onUploadProgress)throw new TypeError("The `onUploadProgress` option must be a function");if(!Ut)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=Jt(this.request,this._options.onUploadProgress))}}_calculateRetryDelay(A){if(this._retryCount++,this._retryCount>this._options.retry.limit||A instanceof Rt)throw A;if(A instanceof Dt){if(!this._options.retry.statusCodes.includes(A.response.status))throw A;const e=A.response.headers.get("Retry-After")??A.response.headers.get("RateLimit-Reset")??A.response.headers.get("X-RateLimit-Reset")??A.response.headers.get("X-Rate-Limit-Reset");if(e&&this._options.retry.afterStatusCodes.includes(A.response.status)){let A=1e3*Number(e);Number.isNaN(A)?A=Date.parse(e)-Date.now():A>=Date.parse("2024-01-01")&&(A-=Date.now());const t=this._options.retry.maxRetryAfter??A;return A<t?A:t}if(413===A.response.status)throw A}const e=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,e)}_decorateResponse(A){return this._options.parseJson&&(A.json=async()=>this._options.parseJson(await A.text())),A}async _retry(A){try{return await A()}catch(e){const t=Math.min(this._calculateRetryDelay(e),vt);if(this._retryCount<1)throw e;await async function(A,{signal:e}){return new Promise((t,s)=>{function i(){clearTimeout(r),s(e.reason)}e&&(e.throwIfAborted(),e.addEventListener("abort",i,{once:!0}));const r=setTimeout(()=>{e?.removeEventListener("abort",i),t()},A)})}(t,{signal:this._options.signal});for(const A of this._options.hooks.beforeRetry){if(await A({request:this.request,options:this._options,error:e,retryCount:this._retryCount})===Ot)return}return this._retry(A)}}async _fetch(){for(const A of this._options.hooks.beforeRequest){const e=await A(this.request,this._options);if(e instanceof Request){this.request=e;break}if(e instanceof Response)return e}const A=((A,e)=>{const t={};for(const s in e)s in Nt||s in bt||s in A||(t[s]=e[s]);return t})(this.request,this._options),e=this.request;return this.request=e.clone(),!1===this._options.timeout?this._options.fetch(e,A):async function(A,e,t,s){return new Promise((i,r)=>{const o=setTimeout(()=>{t&&t.abort(),r(new Rt(A))},s.timeout);s.fetch(A,e).then(i).catch(r).then(()=>{clearTimeout(o)})})}(e,A,this.abortController,this._options)}}
|
|
17
|
+
*/},gt=globalThis;class dt extends De{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const A=super.createRenderRoot();return this.renderOptions.renderBefore??=A.firstChild,A}update(A){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(A),this._$Do=qt(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Xe}}dt._$litElement$=!0,dt.finalized=!0,gt.litElementHydrateSupport?.({LitElement:dt});const pt=gt.litElementPolyfillSupport;pt?.({LitElement:dt}),(gt.litElementVersions??=[]).push("4.2.1");const ut={statusColor:{[exports.AgentStatus.IDLE]:"#1D92E9",[exports.AgentStatus.BUSY]:"#F5212D",[exports.AgentStatus.OFFLINE]:"#8c8c8c",[exports.AgentStatus.RINGING]:"#e9b91d"}},Ct=["call_number"],mt=[],Et=["hangup"],It=["hold","hangup","unhold","mute","unmute","transfer","consult","satisfaction","dtmf"],Mt=["consult_transfer","conference","consult_retrieve"],wt=["hangup"],Bt=["hangup"],Qt=["answer","reject"],ft=["hangup","consult","transfer","hold","unhold","mute","unmute","satisfaction","dtmf"],St={agentInfo:{},isRtcReconnecting:!1,sessionId:"",enableBrowserAlert:!1,autoStateTimer:null},yt={isCalling:!1,direction:null,outCallIsAnswer:!1,incomingIsAnswer:!1,isMeeting:!1,isHold:!1,displayText:"",isMuted:!1,consultIsAnswer:!1,actionConfigs:[],answerDevice:1};const Tt=new class extends $A{updateIsCalling(A){this.setState({isCalling:A})}updateDirection(A){this.setState({direction:A})}updateOutCallIsAnswer(A){this.setState({outCallIsAnswer:A})}updateIsHold(A){this.getState().isHold=A}updateDisplayText(A){this.setState({displayText:A})}updateActionConfigs(A){this.setState({actionConfigs:A}),ae.emit(exports.EventName.PHONE_BAR_OPERATION,A)}updateConsultIsAnswer(A){this.setState({consultIsAnswer:A})}updateIsMuted(A){this.setState({isMuted:A})}updateIncomingIsAnswer(A){this.setState({incomingIsAnswer:A})}updateAnswerDevice(A){this.setState({answerDevice:A}),1!==A?this.updateActionConfigs([]):St.stateObject.state===exports.AgentStatus.IDLE?this.updateActionConfigs(Ct):St.stateObject.state===exports.AgentStatus.BUSY&&this.updateActionConfigs(mt),ae.emit(exports.EventName.UPDATE_ANSWER_DEVICE,A)}updateIsMeeting(A){this.setState({isMeeting:A})}reset(){this.setState({...yt})}getCallInfo(){return this.getState()}get(A){return this.getState()[A]}}(yt);class Dt extends Error{response;request;options;constructor(A,e,t){const s=`${A.status||0===A.status?A.status:""} ${A.statusText||""}`.trim();super(`Request failed with ${s?`status code ${s}`:"an unknown error"}: ${e.method} ${e.url}`),this.name="HTTPError",this.response=A,this.request=e,this.options=t}}class Rt extends Error{request;constructor(A){super(`Request timed out: ${A.method} ${A.url}`),this.name="TimeoutError",this.request=A}}const Ut=(()=>{let A=!1,e=!1;const t="function"==typeof globalThis.ReadableStream,s="function"==typeof globalThis.Request;if(t&&s)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return A=!0,"half"}}).headers.has("Content-Type")}catch(A){if(A instanceof Error&&"unsupported BodyInit type"===A.message)return!1;throw A}return A&&!e})(),kt="function"==typeof globalThis.AbortController,Gt="function"==typeof globalThis.AbortSignal&&"function"==typeof globalThis.AbortSignal.any,Yt="function"==typeof globalThis.ReadableStream,Ft="function"==typeof globalThis.FormData,xt=["get","post","put","patch","head","delete"],Zt={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},vt=2147483647,Kt=(new TextEncoder).encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Ot=Symbol("stop"),bt={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},Nt={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},Jt=(A,e)=>{const t=(A=>{if(!A)return 0;if(A instanceof FormData){let e=0;for(const[t,s]of A)e+=Kt,e+=(new TextEncoder).encode(`Content-Disposition: form-data; name="${t}"`).length,e+="string"==typeof s?(new TextEncoder).encode(s).length:s.size;return e}if(A instanceof Blob)return A.size;if(A instanceof ArrayBuffer)return A.byteLength;if("string"==typeof A)return(new TextEncoder).encode(A).length;if(A instanceof URLSearchParams)return(new TextEncoder).encode(A.toString()).length;if("byteLength"in A)return A.byteLength;if("object"==typeof A&&null!==A)try{const e=JSON.stringify(A);return(new TextEncoder).encode(e).length}catch{return 0}return 0})(A.body);let s=0;return new Request(A,{duplex:"half",body:new ReadableStream({async start(i){const r=A.body instanceof ReadableStream?A.body.getReader():new Response("").body.getReader();await async function A(){const{done:o,value:n}=await r.read();if(o)return e&&e({percent:1,transferredBytes:s,totalBytes:Math.max(t,s)},new Uint8Array),void i.close();s+=n.byteLength;let a=0===t?0:s/t;(t<s||1===a)&&(a=.99),e&&e({percent:Number(a.toFixed(2)),transferredBytes:s,totalBytes:t},n),i.enqueue(n),await A()}()}})})},Ht=A=>null!==A&&"object"==typeof A,jt=(...A)=>{for(const e of A)if((!Ht(e)||Array.isArray(e))&&void 0!==e)throw new TypeError("The `options` argument must be an object");return zt({},...A)},Lt=(A={},e={})=>{const t=new globalThis.Headers(A),s=e instanceof globalThis.Headers,i=new globalThis.Headers(e);for(const[A,e]of i.entries())s&&"undefined"===e||void 0===e?t.delete(A):t.set(A,e);return t};function Wt(A,e,t){return Object.hasOwn(e,t)&&void 0===e[t]?[]:zt(A[t]??[],e[t]??[])}const Pt=(A={},e={})=>({beforeRequest:Wt(A,e,"beforeRequest"),beforeRetry:Wt(A,e,"beforeRetry"),afterResponse:Wt(A,e,"afterResponse"),beforeError:Wt(A,e,"beforeError")}),zt=(...A)=>{let e={},t={},s={};for(const i of A)if(Array.isArray(i))Array.isArray(e)||(e=[]),e=[...e,...i];else if(Ht(i)){for(let[A,t]of Object.entries(i))Ht(t)&&A in e&&(t=zt(e[A],t)),e={...e,[A]:t};Ht(i.hooks)&&(s=Pt(s,i.hooks),e.hooks=s),Ht(i.headers)&&(t=Lt(t,i.headers),e.headers=t)}return e},Xt=A=>xt.includes(A)?A.toUpperCase():A,_t={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:A=>.3*2**(A-1)*1e3},$t=(A={})=>{if("number"==typeof A)return{..._t,limit:A};if(A.methods&&!Array.isArray(A.methods))throw new Error("retry.methods must be an array");if(A.statusCodes&&!Array.isArray(A.statusCodes))throw new Error("retry.statusCodes must be an array");return{..._t,...A}};class As{static create(A,e){const t=new As(A,e),s=async()=>{if("number"==typeof t._options.timeout&&t._options.timeout>vt)throw new RangeError("The `timeout` option cannot be greater than 2147483647");await Promise.resolve();let A=await t._fetch();for(const e of t._options.hooks.afterResponse){const s=await e(t.request,t._options,t._decorateResponse(A.clone()));s instanceof globalThis.Response&&(A=s)}if(t._decorateResponse(A),!A.ok&&t._options.throwHttpErrors){let e=new Dt(A,t.request,t._options);for(const A of t._options.hooks.beforeError)e=await A(e);throw e}if(t._options.onDownloadProgress){if("function"!=typeof t._options.onDownloadProgress)throw new TypeError("The `onDownloadProgress` option must be a function");if(!Yt)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return((A,e)=>{const t=Number(A.headers.get("content-length"))||0;let s=0;return 204===A.status?(e&&e({percent:1,totalBytes:t,transferredBytes:s},new Uint8Array),new Response(null,{status:A.status,statusText:A.statusText,headers:A.headers})):new Response(new ReadableStream({async start(i){const r=A.body.getReader();e&&e({percent:0,transferredBytes:0,totalBytes:t},new Uint8Array),await async function A(){const{done:o,value:n}=await r.read();o?i.close():(e&&(s+=n.byteLength,e({percent:0===t?0:s/t,transferredBytes:s,totalBytes:t},n)),i.enqueue(n),await A())}()}}),{status:A.status,statusText:A.statusText,headers:A.headers})})(A.clone(),t._options.onDownloadProgress)}return A},i=(t._options.retry.methods.includes(t.request.method.toLowerCase())?t._retry(s):s()).finally(async()=>{t.request.bodyUsed||await(t.request.body?.cancel())});for(const[A,s]of Object.entries(Zt))i[A]=async()=>{t.request.headers.set("accept",t.request.headers.get("accept")||s);const r=await i;if("json"===A){if(204===r.status)return"";if(0===(await r.clone().arrayBuffer()).byteLength)return"";if(e.parseJson)return e.parseJson(await r.text())}return r[A]()};return i}request;abortController;_retryCount=0;_input;_options;constructor(A,e={}){if(this._input=A,this._options={...e,headers:Lt(this._input.headers,e.headers),hooks:Pt({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},e.hooks),method:Xt(e.method??this._input.method??"GET"),prefixUrl:String(e.prefixUrl||""),retry:$t(e.retry),throwHttpErrors:!1!==e.throwHttpErrors,timeout:e.timeout??1e4,fetch:e.fetch??globalThis.fetch.bind(globalThis)},"string"!=typeof this._input&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&"string"==typeof this._input){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(kt&&Gt){const A=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=A?AbortSignal.any([A,this.abortController.signal]):this.abortController.signal}if(Ut&&(this._options.duplex="half"),void 0!==this._options.json&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const A="?"+("string"==typeof this._options.searchParams?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),e=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,A);!(Ft&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)||this._options.headers&&this._options.headers["content-type"]||this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(e,{...this.request}),this._options)}if(this._options.onUploadProgress){if("function"!=typeof this._options.onUploadProgress)throw new TypeError("The `onUploadProgress` option must be a function");if(!Ut)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=Jt(this.request,this._options.onUploadProgress))}}_calculateRetryDelay(A){if(this._retryCount++,this._retryCount>this._options.retry.limit||A instanceof Rt)throw A;if(A instanceof Dt){if(!this._options.retry.statusCodes.includes(A.response.status))throw A;const e=A.response.headers.get("Retry-After")??A.response.headers.get("RateLimit-Reset")??A.response.headers.get("X-RateLimit-Reset")??A.response.headers.get("X-Rate-Limit-Reset");if(e&&this._options.retry.afterStatusCodes.includes(A.response.status)){let A=1e3*Number(e);Number.isNaN(A)?A=Date.parse(e)-Date.now():A>=Date.parse("2024-01-01")&&(A-=Date.now());const t=this._options.retry.maxRetryAfter??A;return A<t?A:t}if(413===A.response.status)throw A}const e=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,e)}_decorateResponse(A){return this._options.parseJson&&(A.json=async()=>this._options.parseJson(await A.text())),A}async _retry(A){try{return await A()}catch(e){const t=Math.min(this._calculateRetryDelay(e),vt);if(this._retryCount<1)throw e;await async function(A,{signal:e}){return new Promise((t,s)=>{function i(){clearTimeout(r),s(e.reason)}e&&(e.throwIfAborted(),e.addEventListener("abort",i,{once:!0}));const r=setTimeout(()=>{e?.removeEventListener("abort",i),t()},A)})}(t,{signal:this._options.signal});for(const A of this._options.hooks.beforeRetry){if(await A({request:this.request,options:this._options,error:e,retryCount:this._retryCount})===Ot)return}return this._retry(A)}}async _fetch(){for(const A of this._options.hooks.beforeRequest){const e=await A(this.request,this._options);if(e instanceof Request){this.request=e;break}if(e instanceof Response)return e}const A=((A,e)=>{const t={};for(const s in e)s in Nt||s in bt||s in A||(t[s]=e[s]);return t})(this.request,this._options),e=this.request;return this.request=e.clone(),!1===this._options.timeout?this._options.fetch(e,A):async function(A,e,t,s){return new Promise((i,r)=>{const o=setTimeout(()=>{t&&t.abort(),r(new Rt(A))},s.timeout);s.fetch(A,e).then(i).catch(r).then(()=>{clearTimeout(o)})})}(e,A,this.abortController,this._options)}}
|
|
18
18
|
/*! MIT License © Sindre Sorhus */const es=A=>{const e=(e,t)=>As.create(e,jt(A,t));for(const t of xt)e[t]=(e,s)=>As.create(e,jt(A,s,{method:t}));return e.create=A=>es(jt(A)),e.extend=e=>("function"==typeof e&&(e=e(A??{})),es(jt(A,e))),e.stop=Ot,e};var ts,ss=es(),is="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},rs={exports:{}};
|
|
19
19
|
/**
|
|
20
20
|
* [js-md5]{@link https://github.com/emn178/js-md5}
|
|
@@ -14,7 +14,7 @@ const Re=globalThis,Ue=Re.trustedTypes,ke=Ue?Ue.createPolicy("lit-html",{createH
|
|
|
14
14
|
* @license
|
|
15
15
|
* Copyright 2017 Google LLC
|
|
16
16
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
17
|
-
*/},gt=globalThis;class dt extends Te{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const A=super.createRenderRoot();return this.renderOptions.renderBefore??=A.firstChild,A}update(A){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(A),this._$Do=qt(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Xe}}dt._$litElement$=!0,dt.finalized=!0,gt.litElementHydrateSupport?.({LitElement:dt});const ut=gt.litElementPolyfillSupport;ut?.({LitElement:dt}),(gt.litElementVersions??=[]).push("4.2.1");const pt={statusColor:{[Ae.IDLE]:"#1D92E9",[Ae.BUSY]:"#F5212D",[Ae.OFFLINE]:"#8c8c8c",[Ae.RINGING]:"#e9b91d"}},mt=["call_number"],Ct=[],Et=["hangup"],It=["hold","hangup","unhold","mute","unmute","transfer","consult","satisfaction","dtmf"],Mt=["consult_transfer","conference","consult_retrieve"],wt=["hangup"],Bt=["hangup"],Qt=["answer","reject"],ft=["hangup","consult","transfer","hold","unhold","mute","unmute","satisfaction","dtmf"],St={agentInfo:{},isRtcReconnecting:!1,sessionId:"",enableBrowserAlert:!1,autoStateTimer:null},yt={isCalling:!1,direction:null,outCallIsAnswer:!1,incomingIsAnswer:!1,isMeeting:!1,isHold:!1,displayText:"",isMuted:!1,consultIsAnswer:!1,actionConfigs:[],answerDevice:1};const Dt=new class extends $A{updateIsCalling(A){this.setState({isCalling:A})}updateDirection(A){this.setState({direction:A})}updateOutCallIsAnswer(A){this.setState({outCallIsAnswer:A})}updateIsHold(A){this.getState().isHold=A}updateDisplayText(A){this.setState({displayText:A})}updateActionConfigs(A){this.setState({actionConfigs:A}),ae.emit(re.PHONE_BAR_OPERATION,A)}updateConsultIsAnswer(A){this.setState({consultIsAnswer:A})}updateIsMuted(A){this.setState({isMuted:A})}updateIncomingIsAnswer(A){this.setState({incomingIsAnswer:A})}updateAnswerDevice(A){this.setState({answerDevice:A}),1!==A?(this.setState({actionConfigs:[]}),ae.emit(re.PHONE_BAR_OPERATION,[])):St.stateObject.state===Ae.IDLE?(this.setState({actionConfigs:mt}),ae.emit(re.PHONE_BAR_OPERATION,mt)):St.stateObject.state===Ae.BUSY&&(this.setState({actionConfigs:Ct}),ae.emit(re.PHONE_BAR_OPERATION,Ct)),ae.emit(re.UPDATE_ANSWER_DEVICE,A)}updateIsMeeting(A){this.setState({isMeeting:A})}reset(){this.setState({...yt})}getCallInfo(){return this.getState()}get(A){return this.getState()[A]}}(yt);class Tt extends Error{response;request;options;constructor(A,e,t){const s=`${A.status||0===A.status?A.status:""} ${A.statusText||""}`.trim();super(`Request failed with ${s?`status code ${s}`:"an unknown error"}: ${e.method} ${e.url}`),this.name="HTTPError",this.response=A,this.request=e,this.options=t}}class Rt extends Error{request;constructor(A){super(`Request timed out: ${A.method} ${A.url}`),this.name="TimeoutError",this.request=A}}const Ut=(()=>{let A=!1,e=!1;const t="function"==typeof globalThis.ReadableStream,s="function"==typeof globalThis.Request;if(t&&s)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return A=!0,"half"}}).headers.has("Content-Type")}catch(A){if(A instanceof Error&&"unsupported BodyInit type"===A.message)return!1;throw A}return A&&!e})(),kt="function"==typeof globalThis.AbortController,Gt="function"==typeof globalThis.AbortSignal&&"function"==typeof globalThis.AbortSignal.any,Yt="function"==typeof globalThis.ReadableStream,Ft="function"==typeof globalThis.FormData,Zt=["get","post","put","patch","head","delete"],vt={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},xt=2147483647,Kt=(new TextEncoder).encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Ot=Symbol("stop"),bt={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},Nt={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},Jt=(A,e)=>{const t=(A=>{if(!A)return 0;if(A instanceof FormData){let e=0;for(const[t,s]of A)e+=Kt,e+=(new TextEncoder).encode(`Content-Disposition: form-data; name="${t}"`).length,e+="string"==typeof s?(new TextEncoder).encode(s).length:s.size;return e}if(A instanceof Blob)return A.size;if(A instanceof ArrayBuffer)return A.byteLength;if("string"==typeof A)return(new TextEncoder).encode(A).length;if(A instanceof URLSearchParams)return(new TextEncoder).encode(A.toString()).length;if("byteLength"in A)return A.byteLength;if("object"==typeof A&&null!==A)try{const e=JSON.stringify(A);return(new TextEncoder).encode(e).length}catch{return 0}return 0})(A.body);let s=0;return new Request(A,{duplex:"half",body:new ReadableStream({async start(i){const r=A.body instanceof ReadableStream?A.body.getReader():new Response("").body.getReader();await async function A(){const{done:o,value:n}=await r.read();if(o)return e&&e({percent:1,transferredBytes:s,totalBytes:Math.max(t,s)},new Uint8Array),void i.close();s+=n.byteLength;let a=0===t?0:s/t;(t<s||1===a)&&(a=.99),e&&e({percent:Number(a.toFixed(2)),transferredBytes:s,totalBytes:t},n),i.enqueue(n),await A()}()}})})},Ht=A=>null!==A&&"object"==typeof A,jt=(...A)=>{for(const e of A)if((!Ht(e)||Array.isArray(e))&&void 0!==e)throw new TypeError("The `options` argument must be an object");return zt({},...A)},Lt=(A={},e={})=>{const t=new globalThis.Headers(A),s=e instanceof globalThis.Headers,i=new globalThis.Headers(e);for(const[A,e]of i.entries())s&&"undefined"===e||void 0===e?t.delete(A):t.set(A,e);return t};function Wt(A,e,t){return Object.hasOwn(e,t)&&void 0===e[t]?[]:zt(A[t]??[],e[t]??[])}const Pt=(A={},e={})=>({beforeRequest:Wt(A,e,"beforeRequest"),beforeRetry:Wt(A,e,"beforeRetry"),afterResponse:Wt(A,e,"afterResponse"),beforeError:Wt(A,e,"beforeError")}),zt=(...A)=>{let e={},t={},s={};for(const i of A)if(Array.isArray(i))Array.isArray(e)||(e=[]),e=[...e,...i];else if(Ht(i)){for(let[A,t]of Object.entries(i))Ht(t)&&A in e&&(t=zt(e[A],t)),e={...e,[A]:t};Ht(i.hooks)&&(s=Pt(s,i.hooks),e.hooks=s),Ht(i.headers)&&(t=Lt(t,i.headers),e.headers=t)}return e},Xt=A=>Zt.includes(A)?A.toUpperCase():A,_t={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:A=>.3*2**(A-1)*1e3},$t=(A={})=>{if("number"==typeof A)return{..._t,limit:A};if(A.methods&&!Array.isArray(A.methods))throw new Error("retry.methods must be an array");if(A.statusCodes&&!Array.isArray(A.statusCodes))throw new Error("retry.statusCodes must be an array");return{..._t,...A}};class As{static create(A,e){const t=new As(A,e),s=async()=>{if("number"==typeof t._options.timeout&&t._options.timeout>xt)throw new RangeError("The `timeout` option cannot be greater than 2147483647");await Promise.resolve();let A=await t._fetch();for(const e of t._options.hooks.afterResponse){const s=await e(t.request,t._options,t._decorateResponse(A.clone()));s instanceof globalThis.Response&&(A=s)}if(t._decorateResponse(A),!A.ok&&t._options.throwHttpErrors){let e=new Tt(A,t.request,t._options);for(const A of t._options.hooks.beforeError)e=await A(e);throw e}if(t._options.onDownloadProgress){if("function"!=typeof t._options.onDownloadProgress)throw new TypeError("The `onDownloadProgress` option must be a function");if(!Yt)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return((A,e)=>{const t=Number(A.headers.get("content-length"))||0;let s=0;return 204===A.status?(e&&e({percent:1,totalBytes:t,transferredBytes:s},new Uint8Array),new Response(null,{status:A.status,statusText:A.statusText,headers:A.headers})):new Response(new ReadableStream({async start(i){const r=A.body.getReader();e&&e({percent:0,transferredBytes:0,totalBytes:t},new Uint8Array),await async function A(){const{done:o,value:n}=await r.read();o?i.close():(e&&(s+=n.byteLength,e({percent:0===t?0:s/t,transferredBytes:s,totalBytes:t},n)),i.enqueue(n),await A())}()}}),{status:A.status,statusText:A.statusText,headers:A.headers})})(A.clone(),t._options.onDownloadProgress)}return A},i=(t._options.retry.methods.includes(t.request.method.toLowerCase())?t._retry(s):s()).finally(async()=>{t.request.bodyUsed||await(t.request.body?.cancel())});for(const[A,s]of Object.entries(vt))i[A]=async()=>{t.request.headers.set("accept",t.request.headers.get("accept")||s);const r=await i;if("json"===A){if(204===r.status)return"";if(0===(await r.clone().arrayBuffer()).byteLength)return"";if(e.parseJson)return e.parseJson(await r.text())}return r[A]()};return i}request;abortController;_retryCount=0;_input;_options;constructor(A,e={}){if(this._input=A,this._options={...e,headers:Lt(this._input.headers,e.headers),hooks:Pt({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},e.hooks),method:Xt(e.method??this._input.method??"GET"),prefixUrl:String(e.prefixUrl||""),retry:$t(e.retry),throwHttpErrors:!1!==e.throwHttpErrors,timeout:e.timeout??1e4,fetch:e.fetch??globalThis.fetch.bind(globalThis)},"string"!=typeof this._input&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&"string"==typeof this._input){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(kt&&Gt){const A=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=A?AbortSignal.any([A,this.abortController.signal]):this.abortController.signal}if(Ut&&(this._options.duplex="half"),void 0!==this._options.json&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const A="?"+("string"==typeof this._options.searchParams?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),e=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,A);!(Ft&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)||this._options.headers&&this._options.headers["content-type"]||this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(e,{...this.request}),this._options)}if(this._options.onUploadProgress){if("function"!=typeof this._options.onUploadProgress)throw new TypeError("The `onUploadProgress` option must be a function");if(!Ut)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=Jt(this.request,this._options.onUploadProgress))}}_calculateRetryDelay(A){if(this._retryCount++,this._retryCount>this._options.retry.limit||A instanceof Rt)throw A;if(A instanceof Tt){if(!this._options.retry.statusCodes.includes(A.response.status))throw A;const e=A.response.headers.get("Retry-After")??A.response.headers.get("RateLimit-Reset")??A.response.headers.get("X-RateLimit-Reset")??A.response.headers.get("X-Rate-Limit-Reset");if(e&&this._options.retry.afterStatusCodes.includes(A.response.status)){let A=1e3*Number(e);Number.isNaN(A)?A=Date.parse(e)-Date.now():A>=Date.parse("2024-01-01")&&(A-=Date.now());const t=this._options.retry.maxRetryAfter??A;return A<t?A:t}if(413===A.response.status)throw A}const e=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,e)}_decorateResponse(A){return this._options.parseJson&&(A.json=async()=>this._options.parseJson(await A.text())),A}async _retry(A){try{return await A()}catch(e){const t=Math.min(this._calculateRetryDelay(e),xt);if(this._retryCount<1)throw e;await async function(A,{signal:e}){return new Promise((t,s)=>{function i(){clearTimeout(r),s(e.reason)}e&&(e.throwIfAborted(),e.addEventListener("abort",i,{once:!0}));const r=setTimeout(()=>{e?.removeEventListener("abort",i),t()},A)})}(t,{signal:this._options.signal});for(const A of this._options.hooks.beforeRetry){if(await A({request:this.request,options:this._options,error:e,retryCount:this._retryCount})===Ot)return}return this._retry(A)}}async _fetch(){for(const A of this._options.hooks.beforeRequest){const e=await A(this.request,this._options);if(e instanceof Request){this.request=e;break}if(e instanceof Response)return e}const A=((A,e)=>{const t={};for(const s in e)s in Nt||s in bt||s in A||(t[s]=e[s]);return t})(this.request,this._options),e=this.request;return this.request=e.clone(),!1===this._options.timeout?this._options.fetch(e,A):async function(A,e,t,s){return new Promise((i,r)=>{const o=setTimeout(()=>{t&&t.abort(),r(new Rt(A))},s.timeout);s.fetch(A,e).then(i).catch(r).then(()=>{clearTimeout(o)})})}(e,A,this.abortController,this._options)}}
|
|
17
|
+
*/},gt=globalThis;class dt extends Te{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const A=super.createRenderRoot();return this.renderOptions.renderBefore??=A.firstChild,A}update(A){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(A),this._$Do=qt(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Xe}}dt._$litElement$=!0,dt.finalized=!0,gt.litElementHydrateSupport?.({LitElement:dt});const ut=gt.litElementPolyfillSupport;ut?.({LitElement:dt}),(gt.litElementVersions??=[]).push("4.2.1");const pt={statusColor:{[Ae.IDLE]:"#1D92E9",[Ae.BUSY]:"#F5212D",[Ae.OFFLINE]:"#8c8c8c",[Ae.RINGING]:"#e9b91d"}},mt=["call_number"],Ct=[],Et=["hangup"],It=["hold","hangup","unhold","mute","unmute","transfer","consult","satisfaction","dtmf"],Mt=["consult_transfer","conference","consult_retrieve"],wt=["hangup"],Bt=["hangup"],Qt=["answer","reject"],ft=["hangup","consult","transfer","hold","unhold","mute","unmute","satisfaction","dtmf"],St={agentInfo:{},isRtcReconnecting:!1,sessionId:"",enableBrowserAlert:!1,autoStateTimer:null},yt={isCalling:!1,direction:null,outCallIsAnswer:!1,incomingIsAnswer:!1,isMeeting:!1,isHold:!1,displayText:"",isMuted:!1,consultIsAnswer:!1,actionConfigs:[],answerDevice:1};const Dt=new class extends $A{updateIsCalling(A){this.setState({isCalling:A})}updateDirection(A){this.setState({direction:A})}updateOutCallIsAnswer(A){this.setState({outCallIsAnswer:A})}updateIsHold(A){this.getState().isHold=A}updateDisplayText(A){this.setState({displayText:A})}updateActionConfigs(A){this.setState({actionConfigs:A}),ae.emit(re.PHONE_BAR_OPERATION,A)}updateConsultIsAnswer(A){this.setState({consultIsAnswer:A})}updateIsMuted(A){this.setState({isMuted:A})}updateIncomingIsAnswer(A){this.setState({incomingIsAnswer:A})}updateAnswerDevice(A){this.setState({answerDevice:A}),1!==A?this.updateActionConfigs([]):St.stateObject.state===Ae.IDLE?this.updateActionConfigs(mt):St.stateObject.state===Ae.BUSY&&this.updateActionConfigs(Ct),ae.emit(re.UPDATE_ANSWER_DEVICE,A)}updateIsMeeting(A){this.setState({isMeeting:A})}reset(){this.setState({...yt})}getCallInfo(){return this.getState()}get(A){return this.getState()[A]}}(yt);class Tt extends Error{response;request;options;constructor(A,e,t){const s=`${A.status||0===A.status?A.status:""} ${A.statusText||""}`.trim();super(`Request failed with ${s?`status code ${s}`:"an unknown error"}: ${e.method} ${e.url}`),this.name="HTTPError",this.response=A,this.request=e,this.options=t}}class Rt extends Error{request;constructor(A){super(`Request timed out: ${A.method} ${A.url}`),this.name="TimeoutError",this.request=A}}const Ut=(()=>{let A=!1,e=!1;const t="function"==typeof globalThis.ReadableStream,s="function"==typeof globalThis.Request;if(t&&s)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return A=!0,"half"}}).headers.has("Content-Type")}catch(A){if(A instanceof Error&&"unsupported BodyInit type"===A.message)return!1;throw A}return A&&!e})(),kt="function"==typeof globalThis.AbortController,Gt="function"==typeof globalThis.AbortSignal&&"function"==typeof globalThis.AbortSignal.any,Yt="function"==typeof globalThis.ReadableStream,Ft="function"==typeof globalThis.FormData,Zt=["get","post","put","patch","head","delete"],vt={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},xt=2147483647,Kt=(new TextEncoder).encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Ot=Symbol("stop"),bt={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},Nt={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},Jt=(A,e)=>{const t=(A=>{if(!A)return 0;if(A instanceof FormData){let e=0;for(const[t,s]of A)e+=Kt,e+=(new TextEncoder).encode(`Content-Disposition: form-data; name="${t}"`).length,e+="string"==typeof s?(new TextEncoder).encode(s).length:s.size;return e}if(A instanceof Blob)return A.size;if(A instanceof ArrayBuffer)return A.byteLength;if("string"==typeof A)return(new TextEncoder).encode(A).length;if(A instanceof URLSearchParams)return(new TextEncoder).encode(A.toString()).length;if("byteLength"in A)return A.byteLength;if("object"==typeof A&&null!==A)try{const e=JSON.stringify(A);return(new TextEncoder).encode(e).length}catch{return 0}return 0})(A.body);let s=0;return new Request(A,{duplex:"half",body:new ReadableStream({async start(i){const r=A.body instanceof ReadableStream?A.body.getReader():new Response("").body.getReader();await async function A(){const{done:o,value:n}=await r.read();if(o)return e&&e({percent:1,transferredBytes:s,totalBytes:Math.max(t,s)},new Uint8Array),void i.close();s+=n.byteLength;let a=0===t?0:s/t;(t<s||1===a)&&(a=.99),e&&e({percent:Number(a.toFixed(2)),transferredBytes:s,totalBytes:t},n),i.enqueue(n),await A()}()}})})},Ht=A=>null!==A&&"object"==typeof A,jt=(...A)=>{for(const e of A)if((!Ht(e)||Array.isArray(e))&&void 0!==e)throw new TypeError("The `options` argument must be an object");return zt({},...A)},Lt=(A={},e={})=>{const t=new globalThis.Headers(A),s=e instanceof globalThis.Headers,i=new globalThis.Headers(e);for(const[A,e]of i.entries())s&&"undefined"===e||void 0===e?t.delete(A):t.set(A,e);return t};function Wt(A,e,t){return Object.hasOwn(e,t)&&void 0===e[t]?[]:zt(A[t]??[],e[t]??[])}const Pt=(A={},e={})=>({beforeRequest:Wt(A,e,"beforeRequest"),beforeRetry:Wt(A,e,"beforeRetry"),afterResponse:Wt(A,e,"afterResponse"),beforeError:Wt(A,e,"beforeError")}),zt=(...A)=>{let e={},t={},s={};for(const i of A)if(Array.isArray(i))Array.isArray(e)||(e=[]),e=[...e,...i];else if(Ht(i)){for(let[A,t]of Object.entries(i))Ht(t)&&A in e&&(t=zt(e[A],t)),e={...e,[A]:t};Ht(i.hooks)&&(s=Pt(s,i.hooks),e.hooks=s),Ht(i.headers)&&(t=Lt(t,i.headers),e.headers=t)}return e},Xt=A=>Zt.includes(A)?A.toUpperCase():A,_t={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:A=>.3*2**(A-1)*1e3},$t=(A={})=>{if("number"==typeof A)return{..._t,limit:A};if(A.methods&&!Array.isArray(A.methods))throw new Error("retry.methods must be an array");if(A.statusCodes&&!Array.isArray(A.statusCodes))throw new Error("retry.statusCodes must be an array");return{..._t,...A}};class As{static create(A,e){const t=new As(A,e),s=async()=>{if("number"==typeof t._options.timeout&&t._options.timeout>xt)throw new RangeError("The `timeout` option cannot be greater than 2147483647");await Promise.resolve();let A=await t._fetch();for(const e of t._options.hooks.afterResponse){const s=await e(t.request,t._options,t._decorateResponse(A.clone()));s instanceof globalThis.Response&&(A=s)}if(t._decorateResponse(A),!A.ok&&t._options.throwHttpErrors){let e=new Tt(A,t.request,t._options);for(const A of t._options.hooks.beforeError)e=await A(e);throw e}if(t._options.onDownloadProgress){if("function"!=typeof t._options.onDownloadProgress)throw new TypeError("The `onDownloadProgress` option must be a function");if(!Yt)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return((A,e)=>{const t=Number(A.headers.get("content-length"))||0;let s=0;return 204===A.status?(e&&e({percent:1,totalBytes:t,transferredBytes:s},new Uint8Array),new Response(null,{status:A.status,statusText:A.statusText,headers:A.headers})):new Response(new ReadableStream({async start(i){const r=A.body.getReader();e&&e({percent:0,transferredBytes:0,totalBytes:t},new Uint8Array),await async function A(){const{done:o,value:n}=await r.read();o?i.close():(e&&(s+=n.byteLength,e({percent:0===t?0:s/t,transferredBytes:s,totalBytes:t},n)),i.enqueue(n),await A())}()}}),{status:A.status,statusText:A.statusText,headers:A.headers})})(A.clone(),t._options.onDownloadProgress)}return A},i=(t._options.retry.methods.includes(t.request.method.toLowerCase())?t._retry(s):s()).finally(async()=>{t.request.bodyUsed||await(t.request.body?.cancel())});for(const[A,s]of Object.entries(vt))i[A]=async()=>{t.request.headers.set("accept",t.request.headers.get("accept")||s);const r=await i;if("json"===A){if(204===r.status)return"";if(0===(await r.clone().arrayBuffer()).byteLength)return"";if(e.parseJson)return e.parseJson(await r.text())}return r[A]()};return i}request;abortController;_retryCount=0;_input;_options;constructor(A,e={}){if(this._input=A,this._options={...e,headers:Lt(this._input.headers,e.headers),hooks:Pt({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},e.hooks),method:Xt(e.method??this._input.method??"GET"),prefixUrl:String(e.prefixUrl||""),retry:$t(e.retry),throwHttpErrors:!1!==e.throwHttpErrors,timeout:e.timeout??1e4,fetch:e.fetch??globalThis.fetch.bind(globalThis)},"string"!=typeof this._input&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&"string"==typeof this._input){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(kt&&Gt){const A=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=A?AbortSignal.any([A,this.abortController.signal]):this.abortController.signal}if(Ut&&(this._options.duplex="half"),void 0!==this._options.json&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const A="?"+("string"==typeof this._options.searchParams?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),e=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,A);!(Ft&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)||this._options.headers&&this._options.headers["content-type"]||this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(e,{...this.request}),this._options)}if(this._options.onUploadProgress){if("function"!=typeof this._options.onUploadProgress)throw new TypeError("The `onUploadProgress` option must be a function");if(!Ut)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=Jt(this.request,this._options.onUploadProgress))}}_calculateRetryDelay(A){if(this._retryCount++,this._retryCount>this._options.retry.limit||A instanceof Rt)throw A;if(A instanceof Tt){if(!this._options.retry.statusCodes.includes(A.response.status))throw A;const e=A.response.headers.get("Retry-After")??A.response.headers.get("RateLimit-Reset")??A.response.headers.get("X-RateLimit-Reset")??A.response.headers.get("X-Rate-Limit-Reset");if(e&&this._options.retry.afterStatusCodes.includes(A.response.status)){let A=1e3*Number(e);Number.isNaN(A)?A=Date.parse(e)-Date.now():A>=Date.parse("2024-01-01")&&(A-=Date.now());const t=this._options.retry.maxRetryAfter??A;return A<t?A:t}if(413===A.response.status)throw A}const e=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,e)}_decorateResponse(A){return this._options.parseJson&&(A.json=async()=>this._options.parseJson(await A.text())),A}async _retry(A){try{return await A()}catch(e){const t=Math.min(this._calculateRetryDelay(e),xt);if(this._retryCount<1)throw e;await async function(A,{signal:e}){return new Promise((t,s)=>{function i(){clearTimeout(r),s(e.reason)}e&&(e.throwIfAborted(),e.addEventListener("abort",i,{once:!0}));const r=setTimeout(()=>{e?.removeEventListener("abort",i),t()},A)})}(t,{signal:this._options.signal});for(const A of this._options.hooks.beforeRetry){if(await A({request:this.request,options:this._options,error:e,retryCount:this._retryCount})===Ot)return}return this._retry(A)}}async _fetch(){for(const A of this._options.hooks.beforeRequest){const e=await A(this.request,this._options);if(e instanceof Request){this.request=e;break}if(e instanceof Response)return e}const A=((A,e)=>{const t={};for(const s in e)s in Nt||s in bt||s in A||(t[s]=e[s]);return t})(this.request,this._options),e=this.request;return this.request=e.clone(),!1===this._options.timeout?this._options.fetch(e,A):async function(A,e,t,s){return new Promise((i,r)=>{const o=setTimeout(()=>{t&&t.abort(),r(new Rt(A))},s.timeout);s.fetch(A,e).then(i).catch(r).then(()=>{clearTimeout(o)})})}(e,A,this.abortController,this._options)}}
|
|
18
18
|
/*! MIT License © Sindre Sorhus */const es=A=>{const e=(e,t)=>As.create(e,jt(A,t));for(const t of Zt)e[t]=(e,s)=>As.create(e,jt(A,s,{method:t}));return e.create=A=>es(jt(A)),e.extend=e=>("function"==typeof e&&(e=e(A??{})),es(jt(A,e))),e.stop=Ot,e};var ts,ss=es(),is="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},rs={exports:{}};
|
|
19
19
|
/**
|
|
20
20
|
* [js-md5]{@link https://github.com/emn178/js-md5}
|
|
@@ -14,7 +14,7 @@ const Ue=globalThis,ke=Ue.trustedTypes,Ge=ke?ke.createPolicy("lit-html",{createH
|
|
|
14
14
|
* @license
|
|
15
15
|
* Copyright 2017 Google LLC
|
|
16
16
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
17
|
-
*/},dt=globalThis;class ut extends Re{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const A=super.createRenderRoot();return this.renderOptions.renderBefore??=A.firstChild,A}update(A){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(A),this._$Do=gt(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return _e}}ut._$litElement$=!0,ut.finalized=!0,dt.litElementHydrateSupport?.({LitElement:ut});const pt=dt.litElementPolyfillSupport;pt?.({LitElement:ut}),(dt.litElementVersions??=[]).push("4.2.1");const Ct={statusColor:{[A.AgentStatus.IDLE]:"#1D92E9",[A.AgentStatus.BUSY]:"#F5212D",[A.AgentStatus.OFFLINE]:"#8c8c8c",[A.AgentStatus.RINGING]:"#e9b91d"}},mt=["call_number"],Et=[],It=["hangup"],Mt=["hold","hangup","unhold","mute","unmute","transfer","consult","satisfaction","dtmf"],wt=["consult_transfer","conference","consult_retrieve"],Bt=["hangup"],Qt=["hangup"],ft=["answer","reject"],St=["hangup","consult","transfer","hold","unhold","mute","unmute","satisfaction","dtmf"],yt={agentInfo:{},isRtcReconnecting:!1,sessionId:"",enableBrowserAlert:!1,autoStateTimer:null},Tt={isCalling:!1,direction:null,outCallIsAnswer:!1,incomingIsAnswer:!1,isMeeting:!1,isHold:!1,displayText:"",isMuted:!1,consultIsAnswer:!1,actionConfigs:[],answerDevice:1};const Dt=new class extends Ae{updateIsCalling(A){this.setState({isCalling:A})}updateDirection(A){this.setState({direction:A})}updateOutCallIsAnswer(A){this.setState({outCallIsAnswer:A})}updateIsHold(A){this.getState().isHold=A}updateDisplayText(A){this.setState({displayText:A})}updateActionConfigs(e){this.setState({actionConfigs:e}),Ve.emit(A.EventName.PHONE_BAR_OPERATION,e)}updateConsultIsAnswer(A){this.setState({consultIsAnswer:A})}updateIsMuted(A){this.setState({isMuted:A})}updateIncomingIsAnswer(A){this.setState({incomingIsAnswer:A})}updateAnswerDevice(e){this.setState({answerDevice:e}),1!==e?(this.setState({actionConfigs:[]}),Ve.emit(A.EventName.PHONE_BAR_OPERATION,[])):yt.stateObject.state===A.AgentStatus.IDLE?(this.setState({actionConfigs:mt}),Ve.emit(A.EventName.PHONE_BAR_OPERATION,mt)):yt.stateObject.state===A.AgentStatus.BUSY&&(this.setState({actionConfigs:Et}),Ve.emit(A.EventName.PHONE_BAR_OPERATION,Et)),Ve.emit(A.EventName.UPDATE_ANSWER_DEVICE,e)}updateIsMeeting(A){this.setState({isMeeting:A})}reset(){this.setState({...Tt})}getCallInfo(){return this.getState()}get(A){return this.getState()[A]}}(Tt);class Rt extends Error{response;request;options;constructor(A,e,t){const s=`${A.status||0===A.status?A.status:""} ${A.statusText||""}`.trim();super(`Request failed with ${s?`status code ${s}`:"an unknown error"}: ${e.method} ${e.url}`),this.name="HTTPError",this.response=A,this.request=e,this.options=t}}class Ut extends Error{request;constructor(A){super(`Request timed out: ${A.method} ${A.url}`),this.name="TimeoutError",this.request=A}}const kt=(()=>{let A=!1,e=!1;const t="function"==typeof globalThis.ReadableStream,s="function"==typeof globalThis.Request;if(t&&s)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return A=!0,"half"}}).headers.has("Content-Type")}catch(A){if(A instanceof Error&&"unsupported BodyInit type"===A.message)return!1;throw A}return A&&!e})(),Gt="function"==typeof globalThis.AbortController,Yt="function"==typeof globalThis.AbortSignal&&"function"==typeof globalThis.AbortSignal.any,Ft="function"==typeof globalThis.ReadableStream,Zt="function"==typeof globalThis.FormData,vt=["get","post","put","patch","head","delete"],xt={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},Kt=2147483647,Ot=(new TextEncoder).encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,bt=Symbol("stop"),Nt={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},Jt={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},Ht=(A,e)=>{const t=(A=>{if(!A)return 0;if(A instanceof FormData){let e=0;for(const[t,s]of A)e+=Ot,e+=(new TextEncoder).encode(`Content-Disposition: form-data; name="${t}"`).length,e+="string"==typeof s?(new TextEncoder).encode(s).length:s.size;return e}if(A instanceof Blob)return A.size;if(A instanceof ArrayBuffer)return A.byteLength;if("string"==typeof A)return(new TextEncoder).encode(A).length;if(A instanceof URLSearchParams)return(new TextEncoder).encode(A.toString()).length;if("byteLength"in A)return A.byteLength;if("object"==typeof A&&null!==A)try{const e=JSON.stringify(A);return(new TextEncoder).encode(e).length}catch{return 0}return 0})(A.body);let s=0;return new Request(A,{duplex:"half",body:new ReadableStream({async start(i){const r=A.body instanceof ReadableStream?A.body.getReader():new Response("").body.getReader();await async function A(){const{done:o,value:n}=await r.read();if(o)return e&&e({percent:1,transferredBytes:s,totalBytes:Math.max(t,s)},new Uint8Array),void i.close();s+=n.byteLength;let a=0===t?0:s/t;(t<s||1===a)&&(a=.99),e&&e({percent:Number(a.toFixed(2)),transferredBytes:s,totalBytes:t},n),i.enqueue(n),await A()}()}})})},jt=A=>null!==A&&"object"==typeof A,Lt=(...A)=>{for(const e of A)if((!jt(e)||Array.isArray(e))&&void 0!==e)throw new TypeError("The `options` argument must be an object");return Xt({},...A)},Wt=(A={},e={})=>{const t=new globalThis.Headers(A),s=e instanceof globalThis.Headers,i=new globalThis.Headers(e);for(const[A,e]of i.entries())s&&"undefined"===e||void 0===e?t.delete(A):t.set(A,e);return t};function Pt(A,e,t){return Object.hasOwn(e,t)&&void 0===e[t]?[]:Xt(A[t]??[],e[t]??[])}const zt=(A={},e={})=>({beforeRequest:Pt(A,e,"beforeRequest"),beforeRetry:Pt(A,e,"beforeRetry"),afterResponse:Pt(A,e,"afterResponse"),beforeError:Pt(A,e,"beforeError")}),Xt=(...A)=>{let e={},t={},s={};for(const i of A)if(Array.isArray(i))Array.isArray(e)||(e=[]),e=[...e,...i];else if(jt(i)){for(let[A,t]of Object.entries(i))jt(t)&&A in e&&(t=Xt(e[A],t)),e={...e,[A]:t};jt(i.hooks)&&(s=zt(s,i.hooks),e.hooks=s),jt(i.headers)&&(t=Wt(t,i.headers),e.headers=t)}return e},_t=A=>vt.includes(A)?A.toUpperCase():A,$t={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:A=>.3*2**(A-1)*1e3},As=(A={})=>{if("number"==typeof A)return{...$t,limit:A};if(A.methods&&!Array.isArray(A.methods))throw new Error("retry.methods must be an array");if(A.statusCodes&&!Array.isArray(A.statusCodes))throw new Error("retry.statusCodes must be an array");return{...$t,...A}};class es{static create(A,e){const t=new es(A,e),s=async()=>{if("number"==typeof t._options.timeout&&t._options.timeout>Kt)throw new RangeError("The `timeout` option cannot be greater than 2147483647");await Promise.resolve();let A=await t._fetch();for(const e of t._options.hooks.afterResponse){const s=await e(t.request,t._options,t._decorateResponse(A.clone()));s instanceof globalThis.Response&&(A=s)}if(t._decorateResponse(A),!A.ok&&t._options.throwHttpErrors){let e=new Rt(A,t.request,t._options);for(const A of t._options.hooks.beforeError)e=await A(e);throw e}if(t._options.onDownloadProgress){if("function"!=typeof t._options.onDownloadProgress)throw new TypeError("The `onDownloadProgress` option must be a function");if(!Ft)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return((A,e)=>{const t=Number(A.headers.get("content-length"))||0;let s=0;return 204===A.status?(e&&e({percent:1,totalBytes:t,transferredBytes:s},new Uint8Array),new Response(null,{status:A.status,statusText:A.statusText,headers:A.headers})):new Response(new ReadableStream({async start(i){const r=A.body.getReader();e&&e({percent:0,transferredBytes:0,totalBytes:t},new Uint8Array),await async function A(){const{done:o,value:n}=await r.read();o?i.close():(e&&(s+=n.byteLength,e({percent:0===t?0:s/t,transferredBytes:s,totalBytes:t},n)),i.enqueue(n),await A())}()}}),{status:A.status,statusText:A.statusText,headers:A.headers})})(A.clone(),t._options.onDownloadProgress)}return A},i=(t._options.retry.methods.includes(t.request.method.toLowerCase())?t._retry(s):s()).finally(async()=>{t.request.bodyUsed||await(t.request.body?.cancel())});for(const[A,s]of Object.entries(xt))i[A]=async()=>{t.request.headers.set("accept",t.request.headers.get("accept")||s);const r=await i;if("json"===A){if(204===r.status)return"";if(0===(await r.clone().arrayBuffer()).byteLength)return"";if(e.parseJson)return e.parseJson(await r.text())}return r[A]()};return i}request;abortController;_retryCount=0;_input;_options;constructor(A,e={}){if(this._input=A,this._options={...e,headers:Wt(this._input.headers,e.headers),hooks:zt({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},e.hooks),method:_t(e.method??this._input.method??"GET"),prefixUrl:String(e.prefixUrl||""),retry:As(e.retry),throwHttpErrors:!1!==e.throwHttpErrors,timeout:e.timeout??1e4,fetch:e.fetch??globalThis.fetch.bind(globalThis)},"string"!=typeof this._input&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&"string"==typeof this._input){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(Gt&&Yt){const A=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=A?AbortSignal.any([A,this.abortController.signal]):this.abortController.signal}if(kt&&(this._options.duplex="half"),void 0!==this._options.json&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const A="?"+("string"==typeof this._options.searchParams?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),e=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,A);!(Zt&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)||this._options.headers&&this._options.headers["content-type"]||this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(e,{...this.request}),this._options)}if(this._options.onUploadProgress){if("function"!=typeof this._options.onUploadProgress)throw new TypeError("The `onUploadProgress` option must be a function");if(!kt)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=Ht(this.request,this._options.onUploadProgress))}}_calculateRetryDelay(A){if(this._retryCount++,this._retryCount>this._options.retry.limit||A instanceof Ut)throw A;if(A instanceof Rt){if(!this._options.retry.statusCodes.includes(A.response.status))throw A;const e=A.response.headers.get("Retry-After")??A.response.headers.get("RateLimit-Reset")??A.response.headers.get("X-RateLimit-Reset")??A.response.headers.get("X-Rate-Limit-Reset");if(e&&this._options.retry.afterStatusCodes.includes(A.response.status)){let A=1e3*Number(e);Number.isNaN(A)?A=Date.parse(e)-Date.now():A>=Date.parse("2024-01-01")&&(A-=Date.now());const t=this._options.retry.maxRetryAfter??A;return A<t?A:t}if(413===A.response.status)throw A}const e=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,e)}_decorateResponse(A){return this._options.parseJson&&(A.json=async()=>this._options.parseJson(await A.text())),A}async _retry(A){try{return await A()}catch(e){const t=Math.min(this._calculateRetryDelay(e),Kt);if(this._retryCount<1)throw e;await async function(A,{signal:e}){return new Promise((t,s)=>{function i(){clearTimeout(r),s(e.reason)}e&&(e.throwIfAborted(),e.addEventListener("abort",i,{once:!0}));const r=setTimeout(()=>{e?.removeEventListener("abort",i),t()},A)})}(t,{signal:this._options.signal});for(const A of this._options.hooks.beforeRetry){if(await A({request:this.request,options:this._options,error:e,retryCount:this._retryCount})===bt)return}return this._retry(A)}}async _fetch(){for(const A of this._options.hooks.beforeRequest){const e=await A(this.request,this._options);if(e instanceof Request){this.request=e;break}if(e instanceof Response)return e}const A=((A,e)=>{const t={};for(const s in e)s in Jt||s in Nt||s in A||(t[s]=e[s]);return t})(this.request,this._options),e=this.request;return this.request=e.clone(),!1===this._options.timeout?this._options.fetch(e,A):async function(A,e,t,s){return new Promise((i,r)=>{const o=setTimeout(()=>{t&&t.abort(),r(new Ut(A))},s.timeout);s.fetch(A,e).then(i).catch(r).then(()=>{clearTimeout(o)})})}(e,A,this.abortController,this._options)}}
|
|
17
|
+
*/},dt=globalThis;class ut extends Re{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const A=super.createRenderRoot();return this.renderOptions.renderBefore??=A.firstChild,A}update(A){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(A),this._$Do=gt(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return _e}}ut._$litElement$=!0,ut.finalized=!0,dt.litElementHydrateSupport?.({LitElement:ut});const pt=dt.litElementPolyfillSupport;pt?.({LitElement:ut}),(dt.litElementVersions??=[]).push("4.2.1");const Ct={statusColor:{[A.AgentStatus.IDLE]:"#1D92E9",[A.AgentStatus.BUSY]:"#F5212D",[A.AgentStatus.OFFLINE]:"#8c8c8c",[A.AgentStatus.RINGING]:"#e9b91d"}},mt=["call_number"],Et=[],It=["hangup"],Mt=["hold","hangup","unhold","mute","unmute","transfer","consult","satisfaction","dtmf"],wt=["consult_transfer","conference","consult_retrieve"],Bt=["hangup"],Qt=["hangup"],ft=["answer","reject"],St=["hangup","consult","transfer","hold","unhold","mute","unmute","satisfaction","dtmf"],yt={agentInfo:{},isRtcReconnecting:!1,sessionId:"",enableBrowserAlert:!1,autoStateTimer:null},Tt={isCalling:!1,direction:null,outCallIsAnswer:!1,incomingIsAnswer:!1,isMeeting:!1,isHold:!1,displayText:"",isMuted:!1,consultIsAnswer:!1,actionConfigs:[],answerDevice:1};const Dt=new class extends Ae{updateIsCalling(A){this.setState({isCalling:A})}updateDirection(A){this.setState({direction:A})}updateOutCallIsAnswer(A){this.setState({outCallIsAnswer:A})}updateIsHold(A){this.getState().isHold=A}updateDisplayText(A){this.setState({displayText:A})}updateActionConfigs(e){this.setState({actionConfigs:e}),Ve.emit(A.EventName.PHONE_BAR_OPERATION,e)}updateConsultIsAnswer(A){this.setState({consultIsAnswer:A})}updateIsMuted(A){this.setState({isMuted:A})}updateIncomingIsAnswer(A){this.setState({incomingIsAnswer:A})}updateAnswerDevice(e){this.setState({answerDevice:e}),1!==e?this.updateActionConfigs([]):yt.stateObject.state===A.AgentStatus.IDLE?this.updateActionConfigs(mt):yt.stateObject.state===A.AgentStatus.BUSY&&this.updateActionConfigs(Et),Ve.emit(A.EventName.UPDATE_ANSWER_DEVICE,e)}updateIsMeeting(A){this.setState({isMeeting:A})}reset(){this.setState({...Tt})}getCallInfo(){return this.getState()}get(A){return this.getState()[A]}}(Tt);class Rt extends Error{response;request;options;constructor(A,e,t){const s=`${A.status||0===A.status?A.status:""} ${A.statusText||""}`.trim();super(`Request failed with ${s?`status code ${s}`:"an unknown error"}: ${e.method} ${e.url}`),this.name="HTTPError",this.response=A,this.request=e,this.options=t}}class Ut extends Error{request;constructor(A){super(`Request timed out: ${A.method} ${A.url}`),this.name="TimeoutError",this.request=A}}const kt=(()=>{let A=!1,e=!1;const t="function"==typeof globalThis.ReadableStream,s="function"==typeof globalThis.Request;if(t&&s)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return A=!0,"half"}}).headers.has("Content-Type")}catch(A){if(A instanceof Error&&"unsupported BodyInit type"===A.message)return!1;throw A}return A&&!e})(),Gt="function"==typeof globalThis.AbortController,Yt="function"==typeof globalThis.AbortSignal&&"function"==typeof globalThis.AbortSignal.any,Ft="function"==typeof globalThis.ReadableStream,Zt="function"==typeof globalThis.FormData,vt=["get","post","put","patch","head","delete"],xt={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},Kt=2147483647,Ot=(new TextEncoder).encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,bt=Symbol("stop"),Nt={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},Jt={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},Ht=(A,e)=>{const t=(A=>{if(!A)return 0;if(A instanceof FormData){let e=0;for(const[t,s]of A)e+=Ot,e+=(new TextEncoder).encode(`Content-Disposition: form-data; name="${t}"`).length,e+="string"==typeof s?(new TextEncoder).encode(s).length:s.size;return e}if(A instanceof Blob)return A.size;if(A instanceof ArrayBuffer)return A.byteLength;if("string"==typeof A)return(new TextEncoder).encode(A).length;if(A instanceof URLSearchParams)return(new TextEncoder).encode(A.toString()).length;if("byteLength"in A)return A.byteLength;if("object"==typeof A&&null!==A)try{const e=JSON.stringify(A);return(new TextEncoder).encode(e).length}catch{return 0}return 0})(A.body);let s=0;return new Request(A,{duplex:"half",body:new ReadableStream({async start(i){const r=A.body instanceof ReadableStream?A.body.getReader():new Response("").body.getReader();await async function A(){const{done:o,value:n}=await r.read();if(o)return e&&e({percent:1,transferredBytes:s,totalBytes:Math.max(t,s)},new Uint8Array),void i.close();s+=n.byteLength;let a=0===t?0:s/t;(t<s||1===a)&&(a=.99),e&&e({percent:Number(a.toFixed(2)),transferredBytes:s,totalBytes:t},n),i.enqueue(n),await A()}()}})})},jt=A=>null!==A&&"object"==typeof A,Lt=(...A)=>{for(const e of A)if((!jt(e)||Array.isArray(e))&&void 0!==e)throw new TypeError("The `options` argument must be an object");return Xt({},...A)},Wt=(A={},e={})=>{const t=new globalThis.Headers(A),s=e instanceof globalThis.Headers,i=new globalThis.Headers(e);for(const[A,e]of i.entries())s&&"undefined"===e||void 0===e?t.delete(A):t.set(A,e);return t};function Pt(A,e,t){return Object.hasOwn(e,t)&&void 0===e[t]?[]:Xt(A[t]??[],e[t]??[])}const zt=(A={},e={})=>({beforeRequest:Pt(A,e,"beforeRequest"),beforeRetry:Pt(A,e,"beforeRetry"),afterResponse:Pt(A,e,"afterResponse"),beforeError:Pt(A,e,"beforeError")}),Xt=(...A)=>{let e={},t={},s={};for(const i of A)if(Array.isArray(i))Array.isArray(e)||(e=[]),e=[...e,...i];else if(jt(i)){for(let[A,t]of Object.entries(i))jt(t)&&A in e&&(t=Xt(e[A],t)),e={...e,[A]:t};jt(i.hooks)&&(s=zt(s,i.hooks),e.hooks=s),jt(i.headers)&&(t=Wt(t,i.headers),e.headers=t)}return e},_t=A=>vt.includes(A)?A.toUpperCase():A,$t={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:A=>.3*2**(A-1)*1e3},As=(A={})=>{if("number"==typeof A)return{...$t,limit:A};if(A.methods&&!Array.isArray(A.methods))throw new Error("retry.methods must be an array");if(A.statusCodes&&!Array.isArray(A.statusCodes))throw new Error("retry.statusCodes must be an array");return{...$t,...A}};class es{static create(A,e){const t=new es(A,e),s=async()=>{if("number"==typeof t._options.timeout&&t._options.timeout>Kt)throw new RangeError("The `timeout` option cannot be greater than 2147483647");await Promise.resolve();let A=await t._fetch();for(const e of t._options.hooks.afterResponse){const s=await e(t.request,t._options,t._decorateResponse(A.clone()));s instanceof globalThis.Response&&(A=s)}if(t._decorateResponse(A),!A.ok&&t._options.throwHttpErrors){let e=new Rt(A,t.request,t._options);for(const A of t._options.hooks.beforeError)e=await A(e);throw e}if(t._options.onDownloadProgress){if("function"!=typeof t._options.onDownloadProgress)throw new TypeError("The `onDownloadProgress` option must be a function");if(!Ft)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return((A,e)=>{const t=Number(A.headers.get("content-length"))||0;let s=0;return 204===A.status?(e&&e({percent:1,totalBytes:t,transferredBytes:s},new Uint8Array),new Response(null,{status:A.status,statusText:A.statusText,headers:A.headers})):new Response(new ReadableStream({async start(i){const r=A.body.getReader();e&&e({percent:0,transferredBytes:0,totalBytes:t},new Uint8Array),await async function A(){const{done:o,value:n}=await r.read();o?i.close():(e&&(s+=n.byteLength,e({percent:0===t?0:s/t,transferredBytes:s,totalBytes:t},n)),i.enqueue(n),await A())}()}}),{status:A.status,statusText:A.statusText,headers:A.headers})})(A.clone(),t._options.onDownloadProgress)}return A},i=(t._options.retry.methods.includes(t.request.method.toLowerCase())?t._retry(s):s()).finally(async()=>{t.request.bodyUsed||await(t.request.body?.cancel())});for(const[A,s]of Object.entries(xt))i[A]=async()=>{t.request.headers.set("accept",t.request.headers.get("accept")||s);const r=await i;if("json"===A){if(204===r.status)return"";if(0===(await r.clone().arrayBuffer()).byteLength)return"";if(e.parseJson)return e.parseJson(await r.text())}return r[A]()};return i}request;abortController;_retryCount=0;_input;_options;constructor(A,e={}){if(this._input=A,this._options={...e,headers:Wt(this._input.headers,e.headers),hooks:zt({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},e.hooks),method:_t(e.method??this._input.method??"GET"),prefixUrl:String(e.prefixUrl||""),retry:As(e.retry),throwHttpErrors:!1!==e.throwHttpErrors,timeout:e.timeout??1e4,fetch:e.fetch??globalThis.fetch.bind(globalThis)},"string"!=typeof this._input&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&"string"==typeof this._input){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(Gt&&Yt){const A=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=A?AbortSignal.any([A,this.abortController.signal]):this.abortController.signal}if(kt&&(this._options.duplex="half"),void 0!==this._options.json&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const A="?"+("string"==typeof this._options.searchParams?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),e=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,A);!(Zt&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)||this._options.headers&&this._options.headers["content-type"]||this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(e,{...this.request}),this._options)}if(this._options.onUploadProgress){if("function"!=typeof this._options.onUploadProgress)throw new TypeError("The `onUploadProgress` option must be a function");if(!kt)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=Ht(this.request,this._options.onUploadProgress))}}_calculateRetryDelay(A){if(this._retryCount++,this._retryCount>this._options.retry.limit||A instanceof Ut)throw A;if(A instanceof Rt){if(!this._options.retry.statusCodes.includes(A.response.status))throw A;const e=A.response.headers.get("Retry-After")??A.response.headers.get("RateLimit-Reset")??A.response.headers.get("X-RateLimit-Reset")??A.response.headers.get("X-Rate-Limit-Reset");if(e&&this._options.retry.afterStatusCodes.includes(A.response.status)){let A=1e3*Number(e);Number.isNaN(A)?A=Date.parse(e)-Date.now():A>=Date.parse("2024-01-01")&&(A-=Date.now());const t=this._options.retry.maxRetryAfter??A;return A<t?A:t}if(413===A.response.status)throw A}const e=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,e)}_decorateResponse(A){return this._options.parseJson&&(A.json=async()=>this._options.parseJson(await A.text())),A}async _retry(A){try{return await A()}catch(e){const t=Math.min(this._calculateRetryDelay(e),Kt);if(this._retryCount<1)throw e;await async function(A,{signal:e}){return new Promise((t,s)=>{function i(){clearTimeout(r),s(e.reason)}e&&(e.throwIfAborted(),e.addEventListener("abort",i,{once:!0}));const r=setTimeout(()=>{e?.removeEventListener("abort",i),t()},A)})}(t,{signal:this._options.signal});for(const A of this._options.hooks.beforeRetry){if(await A({request:this.request,options:this._options,error:e,retryCount:this._retryCount})===bt)return}return this._retry(A)}}async _fetch(){for(const A of this._options.hooks.beforeRequest){const e=await A(this.request,this._options);if(e instanceof Request){this.request=e;break}if(e instanceof Response)return e}const A=((A,e)=>{const t={};for(const s in e)s in Jt||s in Nt||s in A||(t[s]=e[s]);return t})(this.request,this._options),e=this.request;return this.request=e.clone(),!1===this._options.timeout?this._options.fetch(e,A):async function(A,e,t,s){return new Promise((i,r)=>{const o=setTimeout(()=>{t&&t.abort(),r(new Ut(A))},s.timeout);s.fetch(A,e).then(i).catch(r).then(()=>{clearTimeout(o)})})}(e,A,this.abortController,this._options)}}
|
|
18
18
|
/*! MIT License © Sindre Sorhus */const ts=A=>{const e=(e,t)=>es.create(e,Lt(A,t));for(const t of vt)e[t]=(e,s)=>es.create(e,Lt(A,s,{method:t}));return e.create=A=>ts(Lt(A)),e.extend=e=>("function"==typeof e&&(e=e(A??{})),ts(Lt(A,e))),e.stop=bt,e};var ss=ts(),is="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},rs={exports:{}};
|
|
19
19
|
/**
|
|
20
20
|
* [js-md5]{@link https://github.com/emn178/js-md5}
|