ion-widget-phone
Version:
Enhance Your Business Communication Productivity and Efficiency with Our Softphone and PBX Service
8 lines (7 loc) • 42.1 kB
JavaScript
(function(A,T){typeof exports=="object"&&typeof module<"u"?module.exports=T():typeof define=="function"&&define.amd?define(T):(A=typeof globalThis<"u"?globalThis:A||self,A["ion-phone"]=T())})(this,function(){"use strict";var gn=Object.defineProperty;var wn=(A,T,C)=>T in A?gn(A,T,{enumerable:!0,configurable:!0,writable:!0,value:C}):A[T]=C;var R=(A,T,C)=>(wn(A,typeof T!="symbol"?T+"":T,C),C);function A(t,e){return function(){return t.apply(e,arguments)}}const{toString:T}=Object.prototype,{getPrototypeOf:C}=Object,W=(t=>e=>{const r=T.call(e);return t[r]||(t[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),P=t=>(t=t.toLowerCase(),e=>W(e)===t),z=t=>e=>typeof e===t,{isArray:U}=Array,q=z("undefined");function Xe(t){return t!==null&&!q(t)&&t.constructor!==null&&!q(t.constructor)&&N(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const he=P("ArrayBuffer");function Ge(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&he(t.buffer),e}const Qe=z("string"),N=z("function"),pe=z("number"),J=t=>t!==null&&typeof t=="object",Ye=t=>t===!0||t===!1,V=t=>{if(W(t)!=="object")return!1;const e=C(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},Ze=P("Date"),et=P("File"),tt=P("Blob"),nt=P("FileList"),rt=t=>J(t)&&N(t.pipe),st=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||N(t.append)&&((e=W(t))==="formdata"||e==="object"&&N(t.toString)&&t.toString()==="[object FormData]"))},ot=P("URLSearchParams"),[it,at,ct,lt]=["ReadableStream","Request","Response","Headers"].map(P),ut=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function H(t,e,{allOwnKeys:r=!1}={}){if(t===null||typeof t>"u")return;let n,s;if(typeof t!="object"&&(t=[t]),U(t))for(n=0,s=t.length;n<s;n++)e.call(null,t[n],n,t);else{const o=r?Object.getOwnPropertyNames(t):Object.keys(t),i=o.length;let c;for(n=0;n<i;n++)c=o[n],e.call(null,t[c],c,t)}}function me(t,e){e=e.toLowerCase();const r=Object.keys(t);let n=r.length,s;for(;n-- >0;)if(s=r[n],e===s.toLowerCase())return s;return null}const ye=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ge=t=>!q(t)&&t!==ye;function Y(){const{caseless:t}=ge(this)&&this||{},e={},r=(n,s)=>{const o=t&&me(e,s)||s;V(e[o])&&V(n)?e[o]=Y(e[o],n):V(n)?e[o]=Y({},n):U(n)?e[o]=n.slice():e[o]=n};for(let n=0,s=arguments.length;n<s;n++)arguments[n]&&H(arguments[n],r);return e}const ft=(t,e,r,{allOwnKeys:n}={})=>(H(e,(s,o)=>{r&&N(s)?t[o]=A(s,r):t[o]=s},{allOwnKeys:n}),t),dt=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),ht=(t,e,r,n)=>{t.prototype=Object.create(e.prototype,n),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),r&&Object.assign(t.prototype,r)},pt=(t,e,r,n)=>{let s,o,i;const c={};if(e=e||{},t==null)return e;do{for(s=Object.getOwnPropertyNames(t),o=s.length;o-- >0;)i=s[o],(!n||n(i,t,e))&&!c[i]&&(e[i]=t[i],c[i]=!0);t=r!==!1&&C(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},mt=(t,e,r)=>{t=String(t),(r===void 0||r>t.length)&&(r=t.length),r-=e.length;const n=t.indexOf(e,r);return n!==-1&&n===r},yt=t=>{if(!t)return null;if(U(t))return t;let e=t.length;if(!pe(e))return null;const r=new Array(e);for(;e-- >0;)r[e]=t[e];return r},gt=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&C(Uint8Array)),wt=(t,e)=>{const n=(t&&t[Symbol.iterator]).call(t);let s;for(;(s=n.next())&&!s.done;){const o=s.value;e.call(t,o[0],o[1])}},bt=(t,e)=>{let r;const n=[];for(;(r=t.exec(e))!==null;)n.push(r);return n},Et=P("HTMLFormElement"),St=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,s){return n.toUpperCase()+s}),we=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),Rt=P("RegExp"),be=(t,e)=>{const r=Object.getOwnPropertyDescriptors(t),n={};H(r,(s,o)=>{let i;(i=e(s,o,t))!==!1&&(n[o]=i||s)}),Object.defineProperties(t,n)},Ot=t=>{be(t,(e,r)=>{if(N(t)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=t[r];if(N(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},Tt=(t,e)=>{const r={},n=s=>{s.forEach(o=>{r[o]=!0})};return U(t)?n(t):n(String(t).split(e)),r},At=()=>{},Nt=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e,Z="abcdefghijklmnopqrstuvwxyz",Ee="0123456789",Se={DIGIT:Ee,ALPHA:Z,ALPHA_DIGIT:Z+Z.toUpperCase()+Ee},Pt=(t=16,e=Se.ALPHA_DIGIT)=>{let r="";const{length:n}=e;for(;t--;)r+=e[Math.random()*n|0];return r};function xt(t){return!!(t&&N(t.append)&&t[Symbol.toStringTag]==="FormData"&&t[Symbol.iterator])}const Ct=t=>{const e=new Array(10),r=(n,s)=>{if(J(n)){if(e.indexOf(n)>=0)return;if(!("toJSON"in n)){e[s]=n;const o=U(n)?[]:{};return H(n,(i,c)=>{const f=r(i,s+1);!q(f)&&(o[c]=f)}),e[s]=void 0,o}}return n};return r(t,0)},Lt=P("AsyncFunction"),a={isArray:U,isArrayBuffer:he,isBuffer:Xe,isFormData:st,isArrayBufferView:Ge,isString:Qe,isNumber:pe,isBoolean:Ye,isObject:J,isPlainObject:V,isReadableStream:it,isRequest:at,isResponse:ct,isHeaders:lt,isUndefined:q,isDate:Ze,isFile:et,isBlob:tt,isRegExp:Rt,isFunction:N,isStream:rt,isURLSearchParams:ot,isTypedArray:gt,isFileList:nt,forEach:H,merge:Y,extend:ft,trim:ut,stripBOM:dt,inherits:ht,toFlatObject:pt,kindOf:W,kindOfTest:P,endsWith:mt,toArray:yt,forEachEntry:wt,matchAll:bt,isHTMLForm:Et,hasOwnProperty:we,hasOwnProp:we,reduceDescriptors:be,freezeMethods:Ot,toObjectSet:Tt,toCamelCase:St,noop:At,toFiniteNumber:Nt,findKey:me,global:ye,isContextDefined:ge,ALPHABET:Se,generateString:Pt,isSpecCompliantForm:xt,toJSONObject:Ct,isAsyncFn:Lt,isThenable:t=>t&&(J(t)||N(t))&&N(t.then)&&N(t.catch)};function p(t,e,r,n,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),r&&(this.config=r),n&&(this.request=n),s&&(this.response=s)}a.inherits(p,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Re=p.prototype,Oe={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{Oe[t]={value:t}}),Object.defineProperties(p,Oe),Object.defineProperty(Re,"isAxiosError",{value:!0}),p.from=(t,e,r,n,s,o)=>{const i=Object.create(Re);return a.toFlatObject(t,i,function(f){return f!==Error.prototype},c=>c!=="isAxiosError"),p.call(i,t.message,e,r,n,s),i.cause=t,i.name=t.name,o&&Object.assign(i,o),i};const Dt=null;function ee(t){return a.isPlainObject(t)||a.isArray(t)}function Te(t){return a.endsWith(t,"[]")?t.slice(0,-2):t}function Ae(t,e,r){return t?t.concat(e).map(function(s,o){return s=Te(s),!r&&o?"["+s+"]":s}).join(r?".":""):e}function Ft(t){return a.isArray(t)&&!t.some(ee)}const _t=a.toFlatObject(a,{},null,function(e){return/^is[A-Z]/.test(e)});function v(t,e,r){if(!a.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,r=a.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,E){return!a.isUndefined(E[m])});const n=r.metaTokens,s=r.visitor||l,o=r.dots,i=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(e);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function u(h){if(h===null)return"";if(a.isDate(h))return h.toISOString();if(!f&&a.isBlob(h))throw new p("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(h)||a.isTypedArray(h)?f&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function l(h,m,E){let S=h;if(h&&!E&&typeof h=="object"){if(a.endsWith(m,"{}"))m=n?m:m.slice(0,-2),h=JSON.stringify(h);else if(a.isArray(h)&&Ft(h)||(a.isFileList(h)||a.endsWith(m,"[]"))&&(S=a.toArray(h)))return m=Te(m),S.forEach(function(w,$){!(a.isUndefined(w)||w===null)&&e.append(i===!0?Ae([m],$,o):i===null?m:m+"[]",u(w))}),!1}return ee(h)?!0:(e.append(Ae(E,m,o),u(h)),!1)}const d=[],g=Object.assign(_t,{defaultVisitor:l,convertValue:u,isVisitable:ee});function y(h,m){if(!a.isUndefined(h)){if(d.indexOf(h)!==-1)throw Error("Circular reference detected in "+m.join("."));d.push(h),a.forEach(h,function(S,L){(!(a.isUndefined(S)||S===null)&&s.call(e,S,a.isString(L)?L.trim():L,m,g))===!0&&y(S,m?m.concat(L):[L])}),d.pop()}}if(!a.isObject(t))throw new TypeError("data must be an object");return y(t),e}function Ne(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function te(t,e){this._pairs=[],t&&v(t,this,e)}const Pe=te.prototype;Pe.append=function(e,r){this._pairs.push([e,r])},Pe.toString=function(e){const r=e?function(n){return e.call(this,n,Ne)}:Ne;return this._pairs.map(function(s){return r(s[0])+"="+r(s[1])},"").join("&")};function Bt(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function xe(t,e,r){if(!e)return t;const n=r&&r.encode||Bt,s=r&&r.serialize;let o;if(s?o=s(e,r):o=a.isURLSearchParams(e)?e.toString():new te(e,r).toString(n),o){const i=t.indexOf("#");i!==-1&&(t=t.slice(0,i)),t+=(t.indexOf("?")===-1?"?":"&")+o}return t}class Ce{constructor(){this.handlers=[]}use(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){a.forEach(this.handlers,function(n){n!==null&&e(n)})}}const Le={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Ut={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:te,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},ne=typeof window<"u"&&typeof document<"u",kt=(t=>ne&&["ReactNative","NativeScript","NS"].indexOf(t)<0)(typeof navigator<"u"&&navigator.product),It=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",qt=ne&&window.location.href||"http://localhost",x={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ne,hasStandardBrowserEnv:kt,hasStandardBrowserWebWorkerEnv:It,origin:qt},Symbol.toStringTag,{value:"Module"})),...Ut};function Ht(t,e){return v(t,new x.classes.URLSearchParams,Object.assign({visitor:function(r,n,s,o){return x.isNode&&a.isBuffer(r)?(this.append(n,r.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},e))}function jt(t){return a.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function Mt(t){const e={},r=Object.keys(t);let n;const s=r.length;let o;for(n=0;n<s;n++)o=r[n],e[o]=t[o];return e}function De(t){function e(r,n,s,o){let i=r[o++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),f=o>=r.length;return i=!i&&a.isArray(s)?s.length:i,f?(a.hasOwnProp(s,i)?s[i]=[s[i],n]:s[i]=n,!c):((!s[i]||!a.isObject(s[i]))&&(s[i]=[]),e(r,n,s[i],o)&&a.isArray(s[i])&&(s[i]=Mt(s[i])),!c)}if(a.isFormData(t)&&a.isFunction(t.entries)){const r={};return a.forEachEntry(t,(n,s)=>{e(jt(n),s,r,0)}),r}return null}function $t(t,e,r){if(a.isString(t))try{return(e||JSON.parse)(t),a.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}const j={transitional:Le,adapter:["xhr","http","fetch"],transformRequest:[function(e,r){const n=r.getContentType()||"",s=n.indexOf("application/json")>-1,o=a.isObject(e);if(o&&a.isHTMLForm(e)&&(e=new FormData(e)),a.isFormData(e))return s?JSON.stringify(De(e)):e;if(a.isArrayBuffer(e)||a.isBuffer(e)||a.isStream(e)||a.isFile(e)||a.isBlob(e)||a.isReadableStream(e))return e;if(a.isArrayBufferView(e))return e.buffer;if(a.isURLSearchParams(e))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let c;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Ht(e,this.formSerializer).toString();if((c=a.isFileList(e))||n.indexOf("multipart/form-data")>-1){const f=this.env&&this.env.FormData;return v(c?{"files[]":e}:e,f&&new f,this.formSerializer)}}return o||s?(r.setContentType("application/json",!1),$t(e)):e}],transformResponse:[function(e){const r=this.transitional||j.transitional,n=r&&r.forcedJSONParsing,s=this.responseType==="json";if(a.isResponse(e)||a.isReadableStream(e))return e;if(e&&a.isString(e)&&(n&&!this.responseType||s)){const i=!(r&&r.silentJSONParsing)&&s;try{return JSON.parse(e)}catch(c){if(i)throw c.name==="SyntaxError"?p.from(c,p.ERR_BAD_RESPONSE,this,null,this.response):c}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:x.classes.FormData,Blob:x.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],t=>{j.headers[t]={}});const Wt=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),zt=t=>{const e={};let r,n,s;return t&&t.split(`
`).forEach(function(i){s=i.indexOf(":"),r=i.substring(0,s).trim().toLowerCase(),n=i.substring(s+1).trim(),!(!r||e[r]&&Wt[r])&&(r==="set-cookie"?e[r]?e[r].push(n):e[r]=[n]:e[r]=e[r]?e[r]+", "+n:n)}),e},Fe=Symbol("internals");function M(t){return t&&String(t).trim().toLowerCase()}function K(t){return t===!1||t==null?t:a.isArray(t)?t.map(K):String(t)}function Jt(t){const e=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(t);)e[n[1]]=n[2];return e}const Vt=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function re(t,e,r,n,s){if(a.isFunction(n))return n.call(this,e,r);if(s&&(e=r),!!a.isString(e)){if(a.isString(n))return e.indexOf(n)!==-1;if(a.isRegExp(n))return n.test(e)}}function vt(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,r,n)=>r.toUpperCase()+n)}function Kt(t,e){const r=a.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(t,n+r,{value:function(s,o,i){return this[n].call(this,e,s,o,i)},configurable:!0})})}class O{constructor(e){e&&this.set(e)}set(e,r,n){const s=this;function o(c,f,u){const l=M(f);if(!l)throw new Error("header name must be a non-empty string");const d=a.findKey(s,l);(!d||s[d]===void 0||u===!0||u===void 0&&s[d]!==!1)&&(s[d||f]=K(c))}const i=(c,f)=>a.forEach(c,(u,l)=>o(u,l,f));if(a.isPlainObject(e)||e instanceof this.constructor)i(e,r);else if(a.isString(e)&&(e=e.trim())&&!Vt(e))i(zt(e),r);else if(a.isHeaders(e))for(const[c,f]of e.entries())o(f,c,n);else e!=null&&o(r,e,n);return this}get(e,r){if(e=M(e),e){const n=a.findKey(this,e);if(n){const s=this[n];if(!r)return s;if(r===!0)return Jt(s);if(a.isFunction(r))return r.call(this,s,n);if(a.isRegExp(r))return r.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,r){if(e=M(e),e){const n=a.findKey(this,e);return!!(n&&this[n]!==void 0&&(!r||re(this,this[n],n,r)))}return!1}delete(e,r){const n=this;let s=!1;function o(i){if(i=M(i),i){const c=a.findKey(n,i);c&&(!r||re(n,n[c],c,r))&&(delete n[c],s=!0)}}return a.isArray(e)?e.forEach(o):o(e),s}clear(e){const r=Object.keys(this);let n=r.length,s=!1;for(;n--;){const o=r[n];(!e||re(this,this[o],o,e,!0))&&(delete this[o],s=!0)}return s}normalize(e){const r=this,n={};return a.forEach(this,(s,o)=>{const i=a.findKey(n,o);if(i){r[i]=K(s),delete r[o];return}const c=e?vt(o):String(o).trim();c!==o&&delete r[o],r[c]=K(s),n[c]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const r=Object.create(null);return a.forEach(this,(n,s)=>{n!=null&&n!==!1&&(r[s]=e&&a.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,r])=>e+": "+r).join(`
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...r){const n=new this(e);return r.forEach(s=>n.set(s)),n}static accessor(e){const n=(this[Fe]=this[Fe]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=M(i);n[c]||(Kt(s,i),n[c]=!0)}return a.isArray(e)?e.forEach(o):o(e),this}}O.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),a.reduceDescriptors(O.prototype,({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(n){this[r]=n}}}),a.freezeMethods(O);function se(t,e){const r=this||j,n=e||r,s=O.from(n.headers);let o=n.data;return a.forEach(t,function(c){o=c.call(r,o,s.normalize(),e?e.status:void 0)}),s.normalize(),o}function _e(t){return!!(t&&t.__CANCEL__)}function k(t,e,r){p.call(this,t??"canceled",p.ERR_CANCELED,e,r),this.name="CanceledError"}a.inherits(k,p,{__CANCEL__:!0});function Be(t,e,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?t(r):e(new p("Request failed with status code "+r.status,[p.ERR_BAD_REQUEST,p.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Xt(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function Gt(t,e){t=t||10;const r=new Array(t),n=new Array(t);let s=0,o=0,i;return e=e!==void 0?e:1e3,function(f){const u=Date.now(),l=n[o];i||(i=u),r[s]=f,n[s]=u;let d=o,g=0;for(;d!==s;)g+=r[d++],d=d%t;if(s=(s+1)%t,s===o&&(o=(o+1)%t),u-i<e)return;const y=l&&u-l;return y?Math.round(g*1e3/y):void 0}}function Qt(t,e){let r=0;const n=1e3/e;let s=null;return function(){const i=this===!0,c=Date.now();if(i||c-r>n)return s&&(clearTimeout(s),s=null),r=c,t.apply(null,arguments);s||(s=setTimeout(()=>(s=null,r=Date.now(),t.apply(null,arguments)),n-(c-r)))}}const X=(t,e,r=3)=>{let n=0;const s=Gt(50,250);return Qt(o=>{const i=o.loaded,c=o.lengthComputable?o.total:void 0,f=i-n,u=s(f),l=i<=c;n=i;const d={loaded:i,total:c,progress:c?i/c:void 0,bytes:f,rate:u||void 0,estimated:u&&c&&l?(c-i)/u:void 0,event:o,lengthComputable:c!=null};d[e?"download":"upload"]=!0,t(d)},r)},Yt=x.hasStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");let n;function s(o){let i=o;return e&&(r.setAttribute("href",i),i=r.href),r.setAttribute("href",i),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=s(window.location.href),function(i){const c=a.isString(i)?s(i):i;return c.protocol===n.protocol&&c.host===n.host}}():function(){return function(){return!0}}(),Zt=x.hasStandardBrowserEnv?{write(t,e,r,n,s,o){const i=[t+"="+encodeURIComponent(e)];a.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),a.isString(n)&&i.push("path="+n),a.isString(s)&&i.push("domain="+s),o===!0&&i.push("secure"),document.cookie=i.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function en(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function tn(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function Ue(t,e){return t&&!en(e)?tn(t,e):e}const ke=t=>t instanceof O?{...t}:t;function _(t,e){e=e||{};const r={};function n(u,l,d){return a.isPlainObject(u)&&a.isPlainObject(l)?a.merge.call({caseless:d},u,l):a.isPlainObject(l)?a.merge({},l):a.isArray(l)?l.slice():l}function s(u,l,d){if(a.isUndefined(l)){if(!a.isUndefined(u))return n(void 0,u,d)}else return n(u,l,d)}function o(u,l){if(!a.isUndefined(l))return n(void 0,l)}function i(u,l){if(a.isUndefined(l)){if(!a.isUndefined(u))return n(void 0,u)}else return n(void 0,l)}function c(u,l,d){if(d in e)return n(u,l);if(d in t)return n(void 0,u)}const f={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(u,l)=>s(ke(u),ke(l),!0)};return a.forEach(Object.keys(Object.assign({},t,e)),function(l){const d=f[l]||s,g=d(t[l],e[l],l);a.isUndefined(g)&&d!==c||(r[l]=g)}),r}const Ie=t=>{const e=_({},t);let{data:r,withXSRFToken:n,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:c}=e;e.headers=i=O.from(i),e.url=xe(Ue(e.baseURL,e.url),t.params,t.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let f;if(a.isFormData(r)){if(x.hasStandardBrowserEnv||x.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if((f=i.getContentType())!==!1){const[u,...l]=f?f.split(";").map(d=>d.trim()).filter(Boolean):[];i.setContentType([u||"multipart/form-data",...l].join("; "))}}if(x.hasStandardBrowserEnv&&(n&&a.isFunction(n)&&(n=n(e)),n||n!==!1&&Yt(e.url))){const u=s&&o&&Zt.read(o);u&&i.set(s,u)}return e},nn=typeof XMLHttpRequest<"u"&&function(t){return new Promise(function(r,n){const s=Ie(t);let o=s.data;const i=O.from(s.headers).normalize();let{responseType:c}=s,f;function u(){s.cancelToken&&s.cancelToken.unsubscribe(f),s.signal&&s.signal.removeEventListener("abort",f)}let l=new XMLHttpRequest;l.open(s.method.toUpperCase(),s.url,!0),l.timeout=s.timeout;function d(){if(!l)return;const y=O.from("getAllResponseHeaders"in l&&l.getAllResponseHeaders()),m={data:!c||c==="text"||c==="json"?l.responseText:l.response,status:l.status,statusText:l.statusText,headers:y,config:t,request:l};Be(function(S){r(S),u()},function(S){n(S),u()},m),l=null}"onloadend"in l?l.onloadend=d:l.onreadystatechange=function(){!l||l.readyState!==4||l.status===0&&!(l.responseURL&&l.responseURL.indexOf("file:")===0)||setTimeout(d)},l.onabort=function(){l&&(n(new p("Request aborted",p.ECONNABORTED,s,l)),l=null)},l.onerror=function(){n(new p("Network Error",p.ERR_NETWORK,s,l)),l=null},l.ontimeout=function(){let h=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const m=s.transitional||Le;s.timeoutErrorMessage&&(h=s.timeoutErrorMessage),n(new p(h,m.clarifyTimeoutError?p.ETIMEDOUT:p.ECONNABORTED,s,l)),l=null},o===void 0&&i.setContentType(null),"setRequestHeader"in l&&a.forEach(i.toJSON(),function(h,m){l.setRequestHeader(m,h)}),a.isUndefined(s.withCredentials)||(l.withCredentials=!!s.withCredentials),c&&c!=="json"&&(l.responseType=s.responseType),typeof s.onDownloadProgress=="function"&&l.addEventListener("progress",X(s.onDownloadProgress,!0)),typeof s.onUploadProgress=="function"&&l.upload&&l.upload.addEventListener("progress",X(s.onUploadProgress)),(s.cancelToken||s.signal)&&(f=y=>{l&&(n(!y||y.type?new k(null,t,l):y),l.abort(),l=null)},s.cancelToken&&s.cancelToken.subscribe(f),s.signal&&(s.signal.aborted?f():s.signal.addEventListener("abort",f)));const g=Xt(s.url);if(g&&x.protocols.indexOf(g)===-1){n(new p("Unsupported protocol "+g+":",p.ERR_BAD_REQUEST,t));return}l.send(o||null)})},rn=(t,e)=>{let r=new AbortController,n;const s=function(f){if(!n){n=!0,i();const u=f instanceof Error?f:this.reason;r.abort(u instanceof p?u:new k(u instanceof Error?u.message:u))}};let o=e&&setTimeout(()=>{s(new p(`timeout ${e} of ms exceeded`,p.ETIMEDOUT))},e);const i=()=>{t&&(o&&clearTimeout(o),o=null,t.forEach(f=>{f&&(f.removeEventListener?f.removeEventListener("abort",s):f.unsubscribe(s))}),t=null)};t.forEach(f=>f&&f.addEventListener&&f.addEventListener("abort",s));const{signal:c}=r;return c.unsubscribe=i,[c,()=>{o&&clearTimeout(o),o=null}]},sn=function*(t,e){let r=t.byteLength;if(!e||r<e){yield t;return}let n=0,s;for(;n<r;)s=n+e,yield t.slice(n,s),n=s},on=async function*(t,e,r){for await(const n of t)yield*sn(ArrayBuffer.isView(n)?n:await r(String(n)),e)},qe=(t,e,r,n,s)=>{const o=on(t,e,s);let i=0;return new ReadableStream({type:"bytes",async pull(c){const{done:f,value:u}=await o.next();if(f){c.close(),n();return}let l=u.byteLength;r&&r(i+=l),c.enqueue(new Uint8Array(u))},cancel(c){return n(c),o.return()}},{highWaterMark:2})},He=(t,e)=>{const r=t!=null;return n=>setTimeout(()=>e({lengthComputable:r,total:t,loaded:n}))},G=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",je=G&&typeof ReadableStream=="function",oe=G&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),an=je&&(()=>{let t=!1;const e=new Request(x.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e})(),Me=64*1024,ie=je&&!!(()=>{try{return a.isReadableStream(new Response("").body)}catch{}})(),Q={stream:ie&&(t=>t.body)};G&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!Q[e]&&(Q[e]=a.isFunction(t[e])?r=>r[e]():(r,n)=>{throw new p(`Response type '${e}' is not supported`,p.ERR_NOT_SUPPORT,n)})})})(new Response);const cn=async t=>{if(t==null)return 0;if(a.isBlob(t))return t.size;if(a.isSpecCompliantForm(t))return(await new Request(t).arrayBuffer()).byteLength;if(a.isArrayBufferView(t))return t.byteLength;if(a.isURLSearchParams(t)&&(t=t+""),a.isString(t))return(await oe(t)).byteLength},ln=async(t,e)=>{const r=a.toFiniteNumber(t.getContentLength());return r??cn(e)},ae={http:Dt,xhr:nn,fetch:G&&(async t=>{let{url:e,method:r,data:n,signal:s,cancelToken:o,timeout:i,onDownloadProgress:c,onUploadProgress:f,responseType:u,headers:l,withCredentials:d="same-origin",fetchOptions:g}=Ie(t);u=u?(u+"").toLowerCase():"text";let[y,h]=s||o||i?rn([s,o],i):[],m,E;const S=()=>{!m&&setTimeout(()=>{y&&y.unsubscribe()}),m=!0};let L;try{if(f&&an&&r!=="get"&&r!=="head"&&(L=await ln(l,n))!==0){let F=new Request(e,{method:"POST",body:n,duplex:"half"}),I;a.isFormData(n)&&(I=F.headers.get("content-type"))&&l.setContentType(I),F.body&&(n=qe(F.body,Me,He(L,X(f)),null,oe))}a.isString(d)||(d=d?"cors":"omit"),E=new Request(e,{...g,signal:y,method:r.toUpperCase(),headers:l.normalize().toJSON(),body:n,duplex:"half",withCredentials:d});let w=await fetch(E);const $=ie&&(u==="stream"||u==="response");if(ie&&(c||$)){const F={};["status","statusText","headers"].forEach(Ke=>{F[Ke]=w[Ke]});const I=a.toFiniteNumber(w.headers.get("content-length"));w=new Response(qe(w.body,Me,c&&He(I,X(c,!0)),$&&S,oe),F)}u=u||"text";let yn=await Q[a.findKey(Q,u)||"text"](w,t);return!$&&S(),h&&h(),await new Promise((F,I)=>{Be(F,I,{data:yn,headers:O.from(w.headers),status:w.status,statusText:w.statusText,config:t,request:E})})}catch(w){throw S(),w&&w.name==="TypeError"&&/fetch/i.test(w.message)?Object.assign(new p("Network Error",p.ERR_NETWORK,t,E),{cause:w.cause||w}):p.from(w,w&&w.code,t,E)}})};a.forEach(ae,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const $e=t=>`- ${t}`,un=t=>a.isFunction(t)||t===null||t===!1,We={getAdapter:t=>{t=a.isArray(t)?t:[t];const{length:e}=t;let r,n;const s={};for(let o=0;o<e;o++){r=t[o];let i;if(n=r,!un(r)&&(n=ae[(i=String(r)).toLowerCase()],n===void 0))throw new p(`Unknown adapter '${i}'`);if(n)break;s[i||"#"+o]=n}if(!n){const o=Object.entries(s).map(([c,f])=>`adapter ${c} `+(f===!1?"is not supported by the environment":"is not available in the build"));let i=e?o.length>1?`since :
`+o.map($e).join(`
`):" "+$e(o[0]):"as no adapter specified";throw new p("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return n},adapters:ae};function ce(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new k(null,t)}function ze(t){return ce(t),t.headers=O.from(t.headers),t.data=se.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),We.getAdapter(t.adapter||j.adapter)(t).then(function(n){return ce(t),n.data=se.call(t,t.transformResponse,n),n.headers=O.from(n.headers),n},function(n){return _e(n)||(ce(t),n&&n.response&&(n.response.data=se.call(t,t.transformResponse,n.response),n.response.headers=O.from(n.response.headers))),Promise.reject(n)})}const Je="1.7.2",le={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{le[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});const Ve={};le.transitional=function(e,r,n){function s(o,i){return"[Axios v"+Je+"] Transitional option '"+o+"'"+i+(n?". "+n:"")}return(o,i,c)=>{if(e===!1)throw new p(s(i," has been removed"+(r?" in "+r:"")),p.ERR_DEPRECATED);return r&&!Ve[i]&&(Ve[i]=!0,console.warn(s(i," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(o,i,c):!0}};function fn(t,e,r){if(typeof t!="object")throw new p("options must be an object",p.ERR_BAD_OPTION_VALUE);const n=Object.keys(t);let s=n.length;for(;s-- >0;){const o=n[s],i=e[o];if(i){const c=t[o],f=c===void 0||i(c,o,t);if(f!==!0)throw new p("option "+o+" must be "+f,p.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new p("Unknown option "+o,p.ERR_BAD_OPTION)}}const ue={assertOptions:fn,validators:le},D=ue.validators;class B{constructor(e){this.defaults=e,this.interceptors={request:new Ce,response:new Ce}}async request(e,r){try{return await this._request(e,r)}catch(n){if(n instanceof Error){let s;Error.captureStackTrace?Error.captureStackTrace(s={}):s=new Error;const o=s.stack?s.stack.replace(/^.+\n/,""):"";try{n.stack?o&&!String(n.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(n.stack+=`
`+o):n.stack=o}catch{}}throw n}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=_(this.defaults,r);const{transitional:n,paramsSerializer:s,headers:o}=r;n!==void 0&&ue.assertOptions(n,{silentJSONParsing:D.transitional(D.boolean),forcedJSONParsing:D.transitional(D.boolean),clarifyTimeoutError:D.transitional(D.boolean)},!1),s!=null&&(a.isFunction(s)?r.paramsSerializer={serialize:s}:ue.assertOptions(s,{encode:D.function,serialize:D.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=o&&a.merge(o.common,o[r.method]);o&&a.forEach(["delete","get","head","post","put","patch","common"],h=>{delete o[h]}),r.headers=O.concat(i,o);const c=[];let f=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(r)===!1||(f=f&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const u=[];this.interceptors.response.forEach(function(m){u.push(m.fulfilled,m.rejected)});let l,d=0,g;if(!f){const h=[ze.bind(this),void 0];for(h.unshift.apply(h,c),h.push.apply(h,u),g=h.length,l=Promise.resolve(r);d<g;)l=l.then(h[d++],h[d++]);return l}g=c.length;let y=r;for(d=0;d<g;){const h=c[d++],m=c[d++];try{y=h(y)}catch(E){m.call(this,E);break}}try{l=ze.call(this,y)}catch(h){return Promise.reject(h)}for(d=0,g=u.length;d<g;)l=l.then(u[d++],u[d++]);return l}getUri(e){e=_(this.defaults,e);const r=Ue(e.baseURL,e.url);return xe(r,e.params,e.paramsSerializer)}}a.forEach(["delete","get","head","options"],function(e){B.prototype[e]=function(r,n){return this.request(_(n||{},{method:e,url:r,data:(n||{}).data}))}}),a.forEach(["post","put","patch"],function(e){function r(n){return function(o,i,c){return this.request(_(c||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}B.prototype[e]=r(),B.prototype[e+"Form"]=r(!0)});class fe{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(o){r=o});const n=this;this.promise.then(s=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](s);n._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{n.subscribe(c),o=c}).then(s);return i.cancel=function(){n.unsubscribe(o)},i},e(function(o,i,c){n.reason||(n.reason=new k(o,i,c),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}static source(){let e;return{token:new fe(function(s){e=s}),cancel:e}}}function dn(t){return function(r){return t.apply(null,r)}}function hn(t){return a.isObject(t)&&t.isAxiosError===!0}const de={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(de).forEach(([t,e])=>{de[e]=t});function ve(t){const e=new B(t),r=A(B.prototype.request,e);return a.extend(r,B.prototype,e,{allOwnKeys:!0}),a.extend(r,e,null,{allOwnKeys:!0}),r.create=function(s){return ve(_(t,s))},r}const b=ve(j);b.Axios=B,b.CanceledError=k,b.CancelToken=fe,b.isCancel=_e,b.VERSION=Je,b.toFormData=v,b.AxiosError=p,b.Cancel=b.CanceledError,b.all=function(e){return Promise.all(e)},b.spread=dn,b.isAxiosError=hn,b.mergeConfig=_,b.AxiosHeaders=O,b.formToJSON=t=>De(a.isHTMLForm(t)?new FormData(t):t),b.getAdapter=We.getAdapter,b.HttpStatusCode=de,b.default=b;async function pn(t){let e=(t==null?void 0:t.url)||null,r=(t==null?void 0:t.method)||"get",n=(t==null?void 0:t.data)||null,s=(t==null?void 0:t.auth)||null,o={method:r,url:e,timeout:1e3*60*3,headers:{"Content-type":"application/json",Authorization:`Bearer ${s}`}};return n&&(o.data=JSON.stringify(n)),t!=null&&t.headers&&(o.headers={...o.headers,...t.headers}),await b(o).then(function(c){return c.data}).catch(function(c){return c})}class mn{constructor(e){R(this,"pos1",0);R(this,"pos2",0);R(this,"pos3",0);R(this,"pos4",0);R(this,"host",null);R(this,"apikey",null);R(this,"userkey",null);R(this,"position","right");R(this,"width",250);R(this,"height",245);R(this,"widgetTitle",'<i class="icon-phone-outline"></i> ION Phone');R(this,"colorHeader",null);R(this,"settingDom",{embed:null,fit:!0});R(this,"callback",{"connection-status":e=>e,"registration-status":e=>e,"call-listen":e=>e,"call-status":e=>e,"dial-established":e=>e,unregistered:e=>e,"auto-dial":e=>e,info:e=>e,queue:e=>e});var r,n,s,o,i,c,f,u,l,d,g;this.host=e.credential.host||null,this.apikey=e.credential.token||null,this.userkey=e.credential.userkey||null,this.position=((r=e==null?void 0:e.setting)==null?void 0:r.position)||"right",this.width=((n=e==null?void 0:e.setting)==null?void 0:n.width)||250,this.height=((s=e==null?void 0:e.setting)==null?void 0:s.height)||245,this.widgetTitle=((i=(o=e==null?void 0:e.setting)==null?void 0:o.header)==null?void 0:i.title)||'<i class="icon-phone-outline"></i> ION Phone',this.colorHeader=((f=(c=e==null?void 0:e.setting)==null?void 0:c.header)==null?void 0:f.color)||null,this.settingDom.embed=((l=(u=e==null?void 0:e.setting)==null?void 0:u.dom)==null?void 0:l.embed)||null,this.settingDom.fit=((g=(d=e==null?void 0:e.setting)==null?void 0:d.dom)==null?void 0:g.fit)||!0}async init(){try{const e=await pn({url:`${this.host}/api/config`,method:"POST",auth:this.apikey,data:{userkey:this.userkey}}),r=e.result.token||null,n=e.result.webphone||null;this.generateFrame(r,n),window.addEventListener("message",this.receiveMessage.bind(this),!1)}catch{this.generateFrame()}if(this.colorHeader){const e=this.colorHeader.substring(0,1)=="#"?this.colorHeader.padEnd(7,"0"):`#${this.colorHeader.padEnd(7,"0")}`,r=document.querySelector(".IONPhone-header");r.style.background=`linear-gradient(#ffffffcc, ${e}cc, ${e})`,r.style.border=`1px solid ${e}`}}receiveMessage(e){var r,n,s,o,i,c;try{const f=(r=e==null?void 0:e.data)==null?void 0:r.message;if(f){const u=f.toString().toLowerCase().replace(/_/g,"-");this.callback[u]&&this.callback[u](((n=e==null?void 0:e.data)==null?void 0:n.payload)||null)}if(f=="CALL_STATUS"){const u=((o=(s=e==null?void 0:e.data)==null?void 0:s.payload)==null?void 0:o.status)||null;if(this.collapseWidget(!0),u==="FINISH")this.headerUpdate(null);else{const l=`<i class="IONPhone-flash IONPhone-animated icon-dot-circled"></i> Call ${u}`;this.headerUpdate(l)}}if(f=="CALL_LISTEN"){const u=((c=(i=e==null?void 0:e.data)==null?void 0:i.payload)==null?void 0:c.status)||null;this.collapseWidget(!0);const l=`<i class="IONPhone-flash IONPhone-animated icon-dot-circled"></i> Incoming Call - ${u}`;this.headerUpdate(l)}}catch{}}headerUpdate(e){try{const r=document.querySelector(".IONPhonetitle");e?r.innerHTML=e:r.innerHTML=this.widgetTitle}catch{}}generateFrame(e,r){let n='<div class="IONPhone-header">';n+=`<div class="IONPhonetitle">${this.widgetTitle}</div>`,n+='<div class="IONPhoneoptions">',n+='<a class="IONPhone-hideBtn">',n+='<i class="icon-up-open"></i>',n+="</a>",n+="</div>",n+='<br clear="all"/>',n+="</div>",n+='<div class="IONPhonecontent IONPhone-responsive">',n+='<div class="IONPhone-loader">',n+=`${r?"Loading Softphone":"System Error"}`,n+="</div>",r&&(n+=`<form class="ion-form-plugin" action="${r}" method="post" target="ion-iframe-dialer">`,n+='<input type="hidden" name="token" value="">',n+="</form>",n+=`<iframe name="ion-iframe-dialer" id="ion-iframe-dialer" src="${r}" allow="microphone"></iframe>`),n+="</div>",n+="</div>";let s=this.width>=250?this.width:250,o=this.height>=245?this.height:245;if(!document.querySelector("#IONPhone")){let d=document.createElement("div");if(d.setAttribute("id","IONPhone"),d.className="IONPhone",d.innerHTML=n,this.settingDom.embed instanceof HTMLElement){if(this.settingDom.embed.appendChild(d),this.settingDom.fit){const y=this.settingDom.embed.offsetWidth,h=this.settingDom.embed.offsetHeight;d.style.resize="none",s=y>=235?y:250,o=h>=230?h:245}const g=document.querySelector(".IONPhoneoptions");g.style.display="none"}else document.body.appendChild(d)}const c=["left","right"].indexOf(this.position)>=0?this.position:"right",f=document.querySelector(".IONPhone");if(f.style.width=`${s}px`,f.style.height=`${o}px`,f.dataset.height=`${o}px`,this.settingDom.embed||(f.style[c]="0px"),r){document.querySelector("#ion-iframe-dialer").addEventListener("onload",()=>{const y=document.querySelector(".IONPhone-loader");y.style.display="none"}),new Promise(async(y,h)=>{const m=document.querySelector('form.ion-form-plugin > [name="token"]');m&&e&&(m.value=e),e?y():h()}).then(()=>{const y=document.querySelector(".ion-form-plugin");y&&y.submit()}).catch(()=>{});const g=document.querySelector(".IONPhone-loader");g.style.display="none"}const u=document.querySelector(".IONPhone-header"),l=document.querySelector(".IONPhone-hideBtn");this.settingDom.embed?u.style.cursor="default":(u.addEventListener("mousedown",this.dragMouseDown.bind(this)),l.addEventListener("click",this.collapseWidget.bind(this,!1)))}collapseWidget(e=!1){const r=document.querySelector(".IONPhone"),n=document.querySelector(".IONPhonecontent"),s=document.querySelector(".IONPhoneoptions");try{r&&n&&(n.style.display=="none"||e?(n.style.display="block",s.style.transform="rotate(0deg)",r.dataset.height&&(r.style.height=`${r.dataset.height}px`)):(r.dataset.height=r.offsetHeight.toString(),setTimeout(()=>n.style.display="none",150),s.style.transform="rotate(180deg)",r.style.height="35px"))}catch{}}dragMouseDown(){const e=window==null?void 0:window.event;e.preventDefault(),this.pos3=e.clientX,this.pos4=e.clientY,document.onmousemove=this.elementDrag.bind(this),document.onmouseup=this.closeDragElement}elementDrag(){const e=window==null?void 0:window.event;e==null||e.preventDefault(),this.pos1=this.pos3-e.clientX,this.pos2=this.pos4-e.clientY,this.pos3=e.clientX,this.pos4=e==null?void 0:e.clientY;let r=window.innerWidth,n=window.innerHeight;const s=document.querySelector(".IONPhone"),o=r-s.offsetWidth,i=n-s.offsetHeight,c=s.offsetTop-this.pos2,f=s.offsetLeft-this.pos1;c>=0&&c<=i&&(s.style.top=c+"px"),f>=0&&f<=o&&(s.style.left=f+"px")}closeDragElement(){document.onmouseup=null,document.onmousemove=null}setNumber(e,r=null){try{let n={message:"SET_NUM",payload:{call_id:e,alias:r}};const s=document.querySelector("#ion-iframe-dialer");s.contentWindow&&(s.contentWindow.postMessage(n,"*"),this.collapseWidget(!0))}catch(n){console.trace(n)}}setDial(e,r=null){try{let n={message:"DIAL",payload:{call_id:e,alias:r}};const s=document.querySelector("#ion-iframe-dialer");s.contentWindow&&(s.contentWindow.postMessage(n,"*"),this.collapseWidget(!0))}catch(n){console.trace(n)}}setHangup(){try{let e={message:"HANGUP",payload:{}};const r=document.querySelector("#ion-iframe-dialer");r.contentWindow&&(r.contentWindow.postMessage(e,"*"),this.collapseWidget(!0))}catch(e){console.trace(e)}}setQueue(e,r=null){try{let n={message:"SET_QUEUE",payload:{isPaused:e,reason:r}};const s=document.querySelector("#ion-iframe-dialer");s.contentWindow&&(s.contentWindow.postMessage(n,"*"),this.collapseWidget(!0))}catch(n){console.trace(n)}}on(e,r){try{this.callback[e]&&(this.callback[e]=r)}catch(n){console.trace(n)}}}return mn});
//# sourceMappingURL=ion-phone.umd.cjs.map