@ujet/websdk-headless 3.0.3
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/README.md +757 -0
- package/dist/index.cjs +563 -0
- package/dist/index.d.ts +409 -0
- package/dist/index.js +41274 -0
- package/package.json +24 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
"use strict";var l1=Object.defineProperty;var f1=(e,r,t)=>r in e?l1(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var bt=(e,r,t)=>(f1(e,typeof r!="symbol"?r+"":r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ou=require("uuid"),d1="qa",bw="3.0.3",Um="https://main.api.ujetqa.co",Or={companyId:"",tenant:"",trackerId:"",deviceId:"",application:"websdk",version:bw};function p1(e){return(e==null?void 0:e.constructor)===Object}async function Bm(e,r=3){let t=0,n;for(;t<=r;){t+=1;try{return await e()}catch(i){n=i,console.error(i),await h1(1e3*Math.pow(2,t))}}throw n}function h1(e){return new Promise(r=>{setTimeout(()=>{r(0)},e)})}const qm=[];class ts{constructor(r){bt(this,"channel");this.channel=r}static addHandler(r){qm.push(r)}debug(...r){this._log("debug",...r)}info(...r){this._log("info",...r)}warn(...r){this._log("warn",...r)}error(...r){this._log("error",...r)}_log(r,...t){qm.forEach(n=>{n(this.channel,r,...t)})}}const v1=(e,r,...t)=>{console[r](`[${r}][${e}]`,...t)};function m1(e){return function(r,t,...n){const i="https://log-api.newrelic.com/log/v1",a=_w(r,t,...n);return fetch(i,{method:"POST",body:JSON.stringify(a),headers:{"api-key":e,"content-type":"application/json"}})}}function _w(e,r,...t){let n=t.pop();typeof n=="string"&&(t.push(n),n={});const i=t.join(" "),a={loglevel:r,channel:e,timestamp:new Date().toISOString(),application:Or.application,version:Or.version,device:Or.deviceId,tenant:Or.tenant,company_id:Or.companyId,location_url:location.href,data:b1(n),message:Bh(i)};return Or.trackerId&&(a.tracker_id=Or.trackerId),a}const g1=["user","phone","phone_number","phoneNumber","email"],y1=[/(?:3[47]\d|(?:4\d|5[1-5]|65)\d{2}|6011)\d{12}/g,/(?!(000|666|9))\d{3}-(?!00)\d{2}-(?!0000)\d{4}/g,/^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)+$/g];function Bh(e){return typeof e=="string"?y1.forEach(r=>{e=e.replace(r,"__MASKED__")}):e&&p1(e)&&(e={...e},Object.keys(e).forEach(r=>{g1.indexOf(r)!==-1?e[r]="__MASKED__":Bh(e[r])})),e}function b1(e){if(e.error){const r=e.error;return{error:{name:r.name,message:r.message,stack:r.stack}}}return Bh(e.data)}const Cf=new ts("communicator");class _1{constructor(r,t){bt(this,"events");bt(this,"options");bt(this,"channel");bt(this,"authenticate");bt(this,"channelReady",!1);bt(this,"pending",[]);bt(this,"promises",{});bt(this,"user");this.authenticate=r.authenticate,this.events=t,this.options=S1(r),this.channel=new MessageChannel,this.refreshToken(),this.useConnect(this.options)}useConnect(r){const t=document.createElement("iframe");t.id="ujet-bridge",t.src=r.bridge,t.setAttribute("style","display:none");let n="*";/^https\:/.test(r.bridge)&&(n=new URL(r.bridge).origin),t.addEventListener("load",()=>{if(Cf.debug("iframe bridge ready for",n),!this.channelReady){const i={type:"_init",data:r};t.contentWindow.postMessage(i,n,[this.channel.port2])}}),this.channel.port1.onmessage=i=>{this.receiveMessage(i)},document.body.appendChild(t)}receiveMessage(r){const t=r.data;if(t)if(Cf.debug("receiveMessage",t),t.type==="ready")this.channelReady=!0,Or.deviceId=t.result.deviceId,this.runPending(),this.events.triggerEvent("ready");else if(t.type==="callback"&&t.callbackId){const[n,i]=this.promises[t.callbackId];t.error?i(t.error):(n(t.result),t.request==="_auth"&&this.events.triggerEvent("authenticated")),delete this.promises[t.callbackId]}else t.type==="refreshToken"&&this.refreshToken()}postMessage(r){this.channelReady?(Cf.debug("postMessage",r),this.channel.port1.postMessage(r)):this.pending.push(r)}runPending(){for(;this.pending.length;){const r=this.pending.shift();this.postMessage(r)}}postPromise(r,t){return new Promise((n,i)=>{const a=Math.random().toString(36).slice(2)+"_"+Date.now();this.promises[a]=[n,i];const s={type:r,callbackId:a,data:t};this.postMessage(s)})}async refreshToken(){const r=await this.authenticate(),t=["twilio_chat","nexmo_chat"];this.options.cobrowse&&t.push("cobrowse");const i={type:"_auth",data:{modules:t,user:{token:r.token,company_id:this.options.companyId}}};this.postMessage(i);const a=JSON.parse(atob(r.token.split(".")[1]));this.user={identity:a.identity,name:a.name,email:a.email}}request(r,t){const n={url:r,options:t};return this.postPromise("request",n)}}function S1(e){var i;let r=e.host;r||(e.tenant?r=Um.replace("main.api",e.tenant+".api"):r=Um);const t=e.lang||"en",n=!!((i=e.cobrowse)!=null&&i.enabled);return{host:r,lang:t,cobrowse:n,companyId:e.companyId,location:location.href,bridge:e.bridge||"https://websdk.ujetqa.co/v3/bridge.html"}}const Gm=new ts("MediaStore"),w1=window.indexedDB||window.webkitIndexedDB||window.mozIndexedDB||window.OIndexedDB||window.msIndexedDB,T1="chat-media",zm=1,Yc="file";class Sw{constructor(){bt(this,"db")}store(){return new Promise((r,t)=>{if(this.db)return r(Wm(this.db));const n=w1.open(T1,zm);n.onerror=()=>{t(new Error("indexedDB open failed"))},n.onsuccess=()=>{const i=n.result;this.db=i,r(Wm(i))},n.onupgradeneeded=i=>{const a=n.result;i.oldVersion>0&&i.oldVersion<zm&&(Gm.info("deprecating media store"),a.deleteObjectStore(Yc)),Gm.info("creating media store"),a.createObjectStore(Yc)}})}async save(r,t){(await this.store()).put({index:r,file:t},r)}async getAll(){const r=await this.store();return await new Promise((t,n)=>{const i=r.getAll();i.onerror=()=>{n(new Error("indexedDB getAll failed"))},i.onsuccess=()=>{t(i.result)}})}async getAllFiles(){const r={};return(await this.getAll()).forEach(n=>{r[n.index]=n.file}),r}async clear(){(await this.store()).clear()}}function Wm(e){return e.transaction(Yc,"readwrite").objectStore(Yc)}class qh{constructor(){bt(this,"handlers",{})}addEventListener(r,t){this.handlers[r]||(this.handlers[r]=[]),this.handlers[r].push(t)}triggerEvent(r,t){const n=this.handlers[r];n&&n.forEach(i=>{i(t)})}removeEventListener(r,t){if(this.handlers[r]){const n=this.handlers[r].indexOf(t);this.handlers[r].splice(n,1)}}destroy(){this.handlers={}}}const C1=new ts("chat-provider");class Gh{constructor(r,t){bt(this,"audio");bt(this,"issueChatToken");bt(this,"identity");bt(this,"channelId");bt(this,"region");bt(this,"events");this.events=new qh,this.region=r.region,this.issueChatToken=t}ping(){this.audio||(this.audio=new window.Audio("https://websdk.ujetqa.co/v3/ping.mp3"));try{this.audio.play()}catch(r){C1.warn("Chat audio play failed",{error:r})}}on(r,t){this.events.addEventListener(r,t)}off(r,t){this.events.removeEventListener(r,t)}}bt(Gh,"type","base");const ww={};function zh(e){ww[e.type]=e}function E1(e){return ww[e]}const k1=["assigned","va_assigned"],Tw=["dismissed","va_dismissed"],R1=["queued",...k1,...Tw],$1=["timeout","canceled","failed","finished"],Vm=new ts("Chat");class O1{constructor(r,t){bt(this,"provider");bt(this,"state");bt(this,"store");bt(this,"globalEvents");bt(this,"connected",!1);bt(this,"allowSkipVirtualAgent",!1);this.state=r,this.store=new Sw;const n=E1(this.state.provider_type);this.provider=new n(r,t)}_setGlobalEvents(r){this.globalEvents=r,this.on("message",t=>{r.triggerEvent("chat.message",t),this.registerMessageEvents(t)}),this.on("memberJoined",t=>{r.triggerEvent("chat.memberJoined",t)}),this.on("memberLeft",t=>{r.triggerEvent("chat.memberLeft",t)}),this.on("typingStarted",t=>{r.triggerEvent("chat.typingStarted",t)}),this.on("typingEnded",t=>{r.triggerEvent("chat.typingEnded",t)})}get id(){return this.state.id}get menuId(){return this.state.menus[this.state.menus.length-1].id}get channelId(){return this.state.provider_channel_id}get lang(){return this.state.lang}get userIdentity(){return this.provider.identity}get status(){return this.state.status}get statusText(){return this.state.status_text}get cobrowsable(){return this.state.features.indexOf("cobrowse")!==-1}get ongoing(){return R1.indexOf(this.state.status)!=-1}get dismissed(){return Tw.indexOf(this.state.status)!=-1}get ended(){return $1.indexOf(this.state.status)!=-1}get transcriptCount(){return this.state.transcript_requested_count}get createdAt(){return this.state.created_at}get feedbackType(){var r;return this.state.survey_enabled?"survey":(r=this.state.csat_settings)!=null&&r.enabled?"rate":"none"}update(r){r.id==this.state.id&&(this.state=r,this.triggerEvent("updated",this))}on(r,t){this.provider.events.addEventListener(r,t)}off(r,t){this.provider.events.removeEventListener(r,t)}async connect(){try{return await Bm(()=>this.provider.create(),3),await Bm(()=>this.provider.join(this.state.provider_channel_id),3),this.connected=!0,this.triggerEvent("connected"),Vm.info("connected with provider",this.state.provider_type),!0}catch{return!1}}async disconnect(){this.connected=!1,this.triggerEvent("disconnected"),this.provider.events.destroy(),await this.provider.destroy(),Vm.info("disconnect with provider",this.state.provider_type)}async sendMessage(r,t){const n=await this.provider.sendMessage(r);return t&&this.store.save(n,t),n}preview(r){return this.provider.preview(r)}async fetchMessages(){const r=await this.store.getAllFiles();return this.provider.fetchMessages(r)}startTyping(){return this.provider.startTyping()}stopTyping(){return this.provider.stopTyping()}async destroy(){this.provider&&(await this.clearMediaStore(),this.triggerEvent("destroyed"),this.provider=null),this.state=null}async clearMediaStore(){await this.store.clear()}triggerEvent(r,t){this.provider.events.triggerEvent(r,t),this.globalEvents&&this.globalEvents.triggerEvent("chat."+r,t)}registerMessageEvents(r){r.event==="cobrowseRequestedFromAgent"?this.provider.events.triggerEvent("_requestCobrowse","agent"):r.event==="cobrowseRequestedFromEndUser"?this.provider.events.triggerEvent("_requestCobrowse","end_user"):r.event==="chatDismissed"?(this.state.status="dismissed",this.triggerEvent("dismissed")):r.event==="chatEnded"&&(this.disconnect(),r.timeout?(this.state.status="timeout",this.triggerEvent("timeout")):(this.state.status="finished",this.triggerEvent("ended")))}}function I1(e,r,t,n){const i=new FormData;Object.keys(t).forEach(s=>{i.append(s,t[s])}),i.append("file",e);const a=new XMLHttpRequest;return a.open("POST",r,!0),n&&(a.onprogress=s=>{n(s.loaded)}),new Promise((s,c)=>{a.onreadystatechange=function(){if(a.readyState===a.DONE){if(a.status>=500){const o=new Error(`xhr:${a.status}:server_error`);return c(o)}if(a.status>=200&&a.status<300){const o=P1(a.responseText);s(o)}else if(a.status>=400){let o="unknown";const u=new Error(`xhr:${a.status}:${o}`);c(u)}}},a.ontimeout=function(){const o=new Error("xhr:ontimeout");c(o),a.abort()},a.onerror=function(){const o=new Error("xhr:onerror");c(o)},a.send(i)})}function P1(e){return new window.DOMParser().parseFromString(e,"text/xml").getElementsByTagName("Key")[0].childNodes[0].nodeValue}function A1(e="none"){return/^image/.test(e)?"photo":/^video/.test(e)?"video":"file"}function Cw(e){return e.map(M1).filter(r=>r.enabled)}function M1(e){const r={id:e.id,enabled:!0,channels:[]};if(e.hidden||!e.name||!e.name.trim())return r.enabled=!1,r;r.name=e.name.trim();const t=x1(e);if(t&&(r.redirection=e.redirection),e.children&&e.children.length){const n=Cw(e.children);return r.enabled=n.length>0||t,r.children=n,r}if(!e.channels)r.enabled=t;else{const{channels:n,deflection:i}=N1(e.channels);r.deflection=i,t||(r.channels=n),r.enabled=n.length>0||t}return r}function x1(e){let r=!1;const t=e.redirection;return t&&(t.option==="message"||t.option==="url")&&(r=!!t.data),r}function N1(e){const r=L1(e);D1(e).forEach(a=>{r.push(a)});let n=null;const i=e.chat;return i&&i.deflected&&(n={enabled:!0,type:i.deflected_reason}),{channels:r,deflection:n}}function L1(e){const r=[],t=e.chat;return t&&(t.enabled||t.virtual_agent_available)&&r.push({...e.chat,type:"chat"}),e.voice_call&&e.voice_call.instant_enabled&&r.push({...e.voice_call,type:"instant_call"}),e.voice_call&&e.voice_call.schedule_enabled&&r.push({...e.voice_call,type:"scheduled_call",deflection_type:e.voice_call.schedule_deflection_type}),e.email&&e.email.enabled&&r.push({...e.email,type:"email"}),t&&t.deflected&&t.deflected_reason==="over_capacity"&&t.keep_waiting&&r.push({...t,enabled:!0,type:"keep_waiting",deflection_type:t.deflected_reason}),r}function D1(e){const r=[];return e.external_deflection_link&&e.external_deflection_link.enabled&&e.external_deflection_link.links.forEach(n=>{n.enabled&&r.push({...n,type:"external_link"})}),r}const j1={en:"English (US)","en-CA":"English (Canada)","en-GB":"English (UK)",es:"Español (España)","es-MX":"Español (México)",fr:"Français (France)","fr-CA":"Français (Canada)",de:"Deutsch",ja:"日本語",ko:"한국어",it:"Italiano",zh:"中文 (简体)","zh-Hant":"中文 (繁體)",sv:"Svenska",pt:"Português (Portugal)","pt-BR":"Português (Brasil)",fi:"Suomi",nb:"Norsk",da:"Dansk",nl:"Nederlands",tr:"Türk",vi:"Tiếng Việt",th:"คนไทย",ar:"اَلْعَرَبِيَّةُ"};function F1(e){return{languages:e.languages.filter(t=>t.enabled).map(t=>({lang:t.lang,name:t.name,localeName:j1[t.lang]})),name:e.display_name,subdomain:e.subdomain,support_email:e.support_email,action_tracking:e.action_tracking_enabled,email_transcripts:e.chat_settings.email_transcripts,message_preview:e.chat_settings.message_preview,email_enhancement:e.email_enhancement_enabled}}class U1{constructor(r){bt(this,"request");this.request=r}get(r,t){if(t){let n=[];Object.keys(t).forEach(i=>{const a=t[i];a!==void 0&&n.push(`${encodeURIComponent(i)}=${encodeURIComponent(a)}`)}),r+="?"+n.join("&")}return this.request(r,{method:"GET"})}post(r,t){const n={method:"POST"};return n.body=JSON.stringify(t),this.request(r,n)}patch(r,t){const n={method:"PATCH"};return n.body=JSON.stringify(t),this.request(r,n)}put(r,t){const n={method:"PUT"};return n.body=JSON.stringify(t),this.request(r,n)}async getTriggers(r){const t={"UJET-Company-Id":r};return(await this.request("proactive_chat_triggers",{method:"GET",headers:t})).data}async getCompany(){const r=await this.get("company");return F1(r.data)}async getMenus(r,t){const n={type:"web_menu",lang:r,direct_access_key:t},i=await this.get("menus",n),a={key:!!t,user:!1},s=i.headers["ujet-direct-access"];return s&&s!="false"&&(a.user=!0),{menus:Cw(i.data),direct:a}}async getAfterHourMessage(r){return(await this.get(`audible_messages/${r}`)).data["after_hours.message"].text}async getTimeSlots(r,t="en"){return(await this.get(`menus/${r}/time_slots`,{type:"web_menu",lang:t})).data}async getWaitTimes(r,t="en"){return(await this.get(`menus/${r}/wait_times`,{type:"web_menu",lang:t})).data}async finishChat(r){return(await this.patch(`chats/${r}`,{status:"finished"})).data}getChatDeflection(r){return this.get(`chats/${r}/deflections`)}sendChatCustomData(r,t){let n;return typeof t=="string"?n={signed:!0,signed_data:t}:n={signed:!1,data:t},this.post(`chats/${r}/custom_data`,n)}sendChatTranscript(r,t){return this.post(`chats/${r}/transcripts`,{emails:t.join(",")})}escalateChat(r,t){return this.post(`chats/${r}/escalations`,t)}trackEscalation(r,t,n){return this.put(`chats/${r}/escalations/${t}`,{escalation_id:t,deflection_channel:n})}requestChatCobrowse(r,t){return this.post(`chats/${r}/cobrowse`,t)}rateChat(r,t){return this.patch(`chats/${r}/rating`,t)}async getChatSurvey(r){return(await this.get(`chats/${r}/survey`)).data}sendChatSurvey(r,t){const n={chat_id:r,answers:t};return this.put(`chats/${r}/survey`,n)}async createChat(r,t,n,i){const a={chat:{menu_id:r,lang:t,email:n.email,greeting:n.greeting,trigger_id:n.trigger_id,ticket_id:n.ticket_id},cobrowsable:n.cobrowsable},c=(await this.post("chats",a)).data;return this.wrapChat(c,i)}async loadChat(r,t){const n=await this.getChat(r);return this.wrapChat(n,t)}async resumeChat(r,t){const n=await this.patch(`chats/${r}`,{status:"queued"});return this.wrapChat(n.data,t)}async uploadChatFile(r,t,n){const i=A1(t.type),a=t.name.replace(/\.[^.]+$/i,""),s=await this.post(`chats/${r}/${i}s/upload`,{filename:a}),c=await I1(t,s.data.url,s.data.fields,n),u=(await this.post(`chats/${r}/${i}s`,{chat_id:r,[i]:{s3_path:c,photo_type:i}})).data;return u.type=i,u}async getChat(r){return(await this.get(`chats/${r}`)).data}wrapChat(r,t){const n=async()=>(await this.post(`chats/${r.id}/tokens`,{provider_type:r.provider_type,device_id:t})).data,i=new O1(r,n),a=async()=>{if(i.status==="va_assigned"){const c=(await this.get(`menus/${i.menuId}/virtual_agent_settings`,{lang:i.lang})).data.allow_skip_virtual_agent;i.allowSkipVirtualAgent=c}};if(i.channelId)i.connect(),a();else{const s=setInterval(async()=>{const c=await this.getChat(i.id);c.provider_channel_id&&(i.update(c),i.connect(),a(),clearInterval(s))},1500)}return i}async createCall(r,t,n){let i="recording_permission_not_asked";n.recording_permission===!0?i="recording_permission_granted":i="recording_permission_denied";const a={type:n.scheduled_at?"web_scheduled_call":"web_instant_call",menu_id:r,lang:t,email:n.email,ticket_id:n.ticket_id,recording_permission:i,scheduled_at:n.scheduled_at,end_user:{phone_number:n.phone_number}},c=(await this.post("calls",{call:a,cobrowsable:!1})).data;return c.menu_id=c.selected_menu.id,c}async fetchCall(r){const n=(await this.get(`calls/${r}`)).data;return n.menu_id=n.selected_menu.id,n}async cancelCall(r){const n=(await this.patch(`calls/${r}`,{status:"failed",fail_reason:"canceled"})).data;return n.menu_id=n.selected_menu.id,n}async listFileTypes(){return(await this.get("email_prohibited_file_types")).data}createEmail(r,t,n){const i={end_user_email:n.email,email_body:n.content,menu_id:r.toString(),lang:t};return n.name&&(i.end_user_name=n.name),n.recaptcha&&(i.recaptcha_response=n.recaptcha),n.files&&(i["email_attachments[]"]=[...n.files]),this.request("emails",{form:i})}}const Ef="ujet:",Dr={set(e,r){return localStorage.setItem(Ef+e,r)},get(e){return localStorage.getItem(Ef+e)},del(e){return localStorage.removeItem(Ef+e)}},Ew={href:window.location.href,interval:24*60*60};function B1(e,r){if(!Array.isArray(e)||!e.length)return null;const t=V1(),n=t===0,i=t+1;return H1(i),e.filter(s=>{const c=q1(s,Ew.href),o=G1(s.visitor_type,n),u=z1(s.messages,r),l=i>=s.page_visit_count,f=!W1(s.id);return c&&o&&u&&l&&f}).sort((s,c)=>s.stay_time-c.stay_time)[0]||null}function q1(e,r){const t=e.keywords_included||[],n=e.keywords_excluded||[];if(!t.length&&!n.length)return!0;const i=t.filter(s=>r.indexOf(s)!==-1).length,a=n.filter(s=>r.indexOf(s)===-1).length;return!!i||!!a}function G1(e,r){return e==="visitor_type_new"?r:e==="visitor_type_returning"?!r:!0}function z1(e,r){return e.filter(n=>n.lang===r).length>0}function W1(e){try{const r=parseInt(Dr.get(`trigger:${e}`),10);return Date.now()/1e3-r<Ew.interval}catch{return!1}}function V1(){try{const e=Dr.get("visits");return e?parseInt(e,10):0}catch{return 0}}function H1(e){try{Dr.set("visits",e.toString())}catch{}}class Wh{constructor(r,t,n){bt(this,"lang");bt(this,"messages");bt(this,"_cobrowse");bt(this,"_started",!1);this._cobrowse=r,this.messages=t,this.lang=n}static async create(r){const t=await K1();t.license=r.license;const n=r.trustedOrigins||[];return n.push(location.origin),t.trustedOrigins=n,["api","capabilities","registration","redactedViews","unredactedViews"].forEach(a=>{r[a]!==void 0&&(t[a]=r[a])}),new Wh(t,r.messages,r.lang)}setCustomData(r){this._cobrowse.customData=r}on(r,t){this._cobrowse.on(r,t)}async start(){this._started||(await this._cobrowse.client(),await this._cobrowse.start(),this._started=!0,Y1(this._cobrowse,this.messages,this.lang),X1(this._cobrowse,this.messages.endSessionText,this.lang))}async stop(){await this._cobrowse.stop(),this._started=!1}async endSession(){this._cobrowse.currentSession&&await this._cobrowse.currentSession.end()}async createSessionCode(){return this._cobrowse.currentSession?this._cobrowse.currentSession.code():await this._cobrowse.createSessionCode()}}function K1(){return window.CobrowseIO?window.CobrowseIO:new Promise(e=>{const r=document.createElement("script");r.src="https://js.cobrowse.io/CobrowseIO.js",r.async=!0;const t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(r,t),r.onload=function(){e(window.CobrowseIO)}})}const J1=`<dialog open class="cobrowse-dialog">
|
|
2
|
+
<h1>$title</h1>
|
|
3
|
+
<div class="cobrowse-dialog_content">$content</div>
|
|
4
|
+
<div class="cobrowse-dialog_footer">
|
|
5
|
+
<button class="cobrowse-dialog_allow js-cobrowse-allow">$allow</button>
|
|
6
|
+
<button class="cobrowse-dialog_deny js-cobrowse-deny">$deny</button>
|
|
7
|
+
</div>
|
|
8
|
+
</dialog>`;function Y1(e,r,t){const n=(i,a)=>{const s=document.createElement("div");s.className="cobrowse-wrapper",s.lang=t;const c=document.querySelector(".cobrowse-template");let o;c?o=c.textContent:o=J1,o=o.replace(/\$title/g,i).replace(/\$content/g,a),o=o.replace(/\$allow/g,r.allowText).replace(/\$deny/g,r.denyText),s.innerHTML=o;const u=()=>{s.parentNode&&s.parentNode.removeChild(s)};return new Promise(l=>{document.body&&document.body.appendChild(s);const f=s.querySelector(".js-cobrowse-allow");f==null||f.addEventListener("click",()=>{l(!0),u()});const d=s.querySelector(".js-cobrowse-deny");d==null||d.addEventListener("click",()=>{l(!1),u()})})};e.confirmSession=function(){return n(r.confirmSessionTitle,r.confirmSessionContent)},e.confirmRemoteControl=function(){return n(r.confirmRemoteControlTitle,r.confirmRemoteControlContent)},e.confirmFullDevice=function(){return n(r.confirmFullDeviceTitle,r.confirmFullDeviceContent)}}function X1(e,r,t){const n=()=>{e.currentSession&&e.currentSession.end()};e.showSessionControls=function(){let i=document.querySelector("#cobrowse-end-button");i||(i=document.createElement("button"),i.id="cobrowse-end-button",i.setAttribute("lang",t),i.textContent=r,i.addEventListener("click",n)),document.body.appendChild(i)},e.hideSessionControls=function(){let i=document.querySelector("#cobrowse-end-button");i&&i.parentNode&&(i.removeEventListener("click",n),i.parentNode.removeChild(i))}}const Q1={confirmSessionTitle:"Co-browse Session Request",confirmSessionContent:"Do you want to share your current screen with the agent?",endSessionText:"End Co-browse Session",confirmRemoteControlTitle:"Remote Access Request",confirmRemoteControlContent:"The agent would like to have access to your currently shared screen to further assist you. Do you want to allow this?",confirmFullDeviceTitle:"Screen Share Request",confirmFullDeviceContent:"Do you want to share your full screen with the agent? The agent will not be able to control anything on the screen.",allowText:"Allow",denyText:"Deny"},Z1={confirmSessionTitle:"Solicitud de sesión de conavegación",confirmSessionContent:"¿Desea compartir su pantalla actual con el agente?",endSessionText:"Fin de la sesión de conavegación",confirmRemoteControlTitle:"Solicitud de acceso remoto",confirmRemoteControlContent:"El agente desea tener acceso a su pantalla actual compartida para seguir asistiéndole. ¿Desea permitirlo?",confirmFullDeviceTitle:"Solicitud de compartir pantalla",confirmFullDeviceContent:"¿Desea compartir su pantalla completa con el agente? El agente no podrá controlar nada de la pantalla.",allowText:"Permitir",denyText:"Denegar"},e$={confirmSessionTitle:"Demande de session de co-navigation",confirmSessionContent:"Voulez-vous partager votre écran actuel avec l'agent ?",endSessionText:"Terminer la session de co-navigation",confirmRemoteControlTitle:"Demande d'accès à distance",confirmRemoteControlContent:"L'agent souhaite avoir accès à l'écran que vous partagez actuellement pour mieux vous aider. Voulez-vous l'y autoriser ?",confirmFullDeviceTitle:"Demande de partage d'écran",confirmFullDeviceContent:"Voulez-vous partager votre écran complet avec l'agent ? L'agent ne sera pas en mesure de contrôler quoi que ce soit sur l'écran.",allowText:"Autoriser",denyText:"Refuser"},t$={confirmSessionTitle:"Co-Browsing-Sitzungsanfrage",confirmSessionContent:"Möchten Sie Ihren aktuellen Bildschirm für den Agenten freigeben?",endSessionText:"Co-Browsing-Sitzung beenden",confirmRemoteControlTitle:"Fernzugriff-Anfrage",confirmRemoteControlContent:"Der Agent möchte Zugriff auf Ihren aktuell freigegebenen Bildschirm erhalten, um Ihnen weiterhelfen zu können. Möchten Sie dies erlauben?",confirmFullDeviceTitle:"Bildschirmfreigabe",confirmFullDeviceContent:"Möchten Sie Ihren gesamten Bildschirm für den Agenten freigeben? Der Agent ist dadurch nicht in der Lage, Elemente auf Ihrem Bildschirm zu steuern.",allowText:"Erlauben",denyText:"Verweigern"},r$={confirmSessionTitle:"共同ブラウジングセッションリクエスト",confirmSessionContent:"現在の画面を担当者と共有したいですか。",endSessionText:"共同ブラウジングセッションを終了",confirmRemoteControlTitle:"リモートアクセスリクエスト",confirmRemoteControlContent:"担当者は、お客様をさらにお手伝いするために、現在共有中の画面へのアクセスを希望しています。許可しますか。",confirmFullDeviceTitle:"画面共有リクエスト",confirmFullDeviceContent:"画面全体を担当者と共有したいですか。担当者は画面上で一切の操作ができません。",allowText:"許可",denyText:"拒否"},n$={confirmSessionTitle:"코브라우징 세션 요청",confirmSessionContent:"현재 화면을 상담원과 공유하시겠습니까?",endSessionText:"코브라우징 세션 종료",confirmRemoteControlTitle:"원격 액세스 요청",confirmRemoteControlContent:"상담원이 추가 지원을 위해 현재 공유된 화면에 액세스할 수 있기를 원합니다. 허용하시겠습니까?",confirmFullDeviceTitle:"화면 공유 요청",confirmFullDeviceContent:"상담원과 전체 화면을 공유하시겠습니까? 상담원은 화면의 어떤 부분도 제어할 수 없습니다.",allowText:"허용",denyText:"거절"},i$={confirmSessionTitle:"Richiesta di sessione di co-browsing",confirmSessionContent:"Vuoi condividere la tua schermata attuale con l'operatore?",endSessionText:"Termina sessione di co-browsing",confirmRemoteControlTitle:"Richiesta di accesso remoto",confirmRemoteControlContent:"L'operatore vorrebbe accedere alla tua schermata attualmente condivisa per assisterti al meglio. Acconsenti?",confirmFullDeviceTitle:"Richiesta di condivisione schermo",confirmFullDeviceContent:"Vuoi condividere il tuo intero schermo con l'operatore? L'operatore non potrà controllare nessun elemento sullo schermo.",allowText:"Consenti",denyText:"Rifiuta"},a$={confirmSessionTitle:"同步浏览会话请求",confirmSessionContent:"您是否要向该客服代表共享当前的屏幕?",endSessionText:"结束同步浏览会话",confirmRemoteControlTitle:"远程访问请求",confirmRemoteControlContent:"为了进一步协助您,客服代表想访问您当前的共享屏幕。您是否允许这样做?",confirmFullDeviceTitle:"屏幕共享请求",confirmFullDeviceContent:"您是否要向该客服代表共享全屏?客服代表将不能控制屏幕上的任何东西。",allowText:"允许",denyText:"拒绝"},s$={confirmSessionTitle:"Samwebbläsningssession har begärts",confirmSessionContent:"Vill du dela din aktuella skärm med vår medarbetare?",endSessionText:"Avsluta samwebbläsningssession",confirmRemoteControlTitle:"Begäran om fjärråtkomst",confirmRemoteControlContent:"Vår medarbetare skulle vilja få åtkomst till skärmen som du delar just nu för att kunna hjälpa dig vidare. Vill du tillåta detta?",confirmFullDeviceTitle:"Begäran om skärmdelning",confirmFullDeviceContent:"Vill du dela hela skärmen med medarbetaren? Medarbetaren kommer inte kunna kontrollera något på skärmen.",allowText:"Tillåt",denyText:"Neka"},o$={confirmSessionTitle:"Solicitação de Sessão de Co-navegação",confirmSessionContent:"Deseja partilhar o seu ecrã atual com o agente?",endSessionText:"Terminar Sessão de Co-navegação",confirmRemoteControlTitle:"Solicitação de Acesso Remoto",confirmRemoteControlContent:"O agente gostaria de ter acesso ao seu ecrã partilhado atualmente para ajudá-lo ainda mais. Quer permitir isto?",confirmFullDeviceTitle:"Solicitação de Partilha de Ecrã",confirmFullDeviceContent:"Deseja partilhar o seu ecrã inteiro com o agente? O agente não poderá controlar nada no ecrã.",allowText:"Permitir",denyText:"Negar"},u$={confirmSessionTitle:"Pyyntö yhteisselausistunnosta",confirmSessionContent:"Haluatko jakaa nykyisen näyttösi edustajan kanssa?",endSessionText:"Lopeta yhteisselausistunto",confirmRemoteControlTitle:"Etäkäyttöpyyntö",confirmRemoteControlContent:"Edustaja haluaisi saada käyttää tällä hetkellä jakamaasi näyttöä voidakseen auttaa sinua enemmän. Haluatko antaa siihen luvan?",confirmFullDeviceTitle:"Näytön jakamispyyntö",confirmFullDeviceContent:"Haluatko jakaa koko näyttösi edustajan kanssa? Edustaja ei pysty käyttämään mitään näytöllä olevaa.",allowText:"Salli",denyText:"Estä"},c$={confirmSessionTitle:"Samlesingsøkten er startet",confirmSessionContent:"Vil du dele skjermen din med agenten?",endSessionText:"Avslutt samlesingsøkt",confirmRemoteControlTitle:"Forespørsel om fjerntilgang",confirmRemoteControlContent:"Agenten vil ha tilgang til skjermen din for å kunne hjelpe deg videre. Vil du tillate dette?",confirmFullDeviceTitle:"Forespørsel om skjermdeling",confirmFullDeviceContent:"Vil du dele hele skjermen din med agenten? Agenten kan ikke kontrollere noe på skjermen.",allowText:"Tillat",denyText:"Avvis"},l$={confirmSessionTitle:"Forespørgsel om sambrowsingsession",confirmSessionContent:"Vil du dele din nuværende skærm med agenten",endSessionText:"Afslut sambrowsingsession",confirmRemoteControlTitle:"Anmodning om fjernadgang",confirmRemoteControlContent:"Agenten vil gerne have adgang til din nuværende delte skærm for at kunne hjælpe dig yderligere. Ønsker du at tillade dette?",confirmFullDeviceTitle:"Forespørgsel om skærmdeling",confirmFullDeviceContent:"Vil du dele din fulde skærm med agenten? Agenten vil ikke kunne styre noget på skærmen",allowText:"Tillad",denyText:"Afvis"},f$={confirmSessionTitle:"Verzoek om cobrowse-sessie",confirmSessionContent:"Wilt u uw huidige scherm delen met de agent?",endSessionText:"Cobrowse-sessie beëindigen",confirmRemoteControlTitle:"Verzoek om toegang op afstand",confirmRemoteControlContent:"De agent wil graag toegang hebben tot uw momenteel gedeelde scherm om u verder te helpen. Wilt u dit toestaan?",confirmFullDeviceTitle:"Verzoek om scherm te delen",confirmFullDeviceContent:"Wilt u uw volledige scherm delen met de agent? De agent kan niets op het scherm bedienen.",allowText:"Toestaan",denyText:"Weigeren"},d$={confirmSessionTitle:"Oturum İsteğini Eş Zamanlı Tara",confirmSessionContent:"Mevcut ekranınızı temsilciyle paylaşmak ister misiniz?",endSessionText:"Eş zamanlı Oturum Taramayı Sonlandır",confirmRemoteControlTitle:"Uzaktan Erişim İsteği",confirmRemoteControlContent:"Temsilci şu anda paylaşılan ekranınıza size daha fazla yardımcı olabilmek için erişim sağlamak istiyor. Buna izin vermek istiyor musunuz?",confirmFullDeviceTitle:"Ekran Paylaşım İsteği",confirmFullDeviceContent:"Temsilciyle tam ekranınızı paylaşmak istiyor musunuz? Temsilci ekrandaki hiçbir şeyi kontrol edemez.",allowText:"İzin Ver",denyText:"Reddet"},p$={confirmSessionTitle:"Yêu cầu phiên cùng duyệt",confirmSessionContent:"Bạn có muốn chia sẻ màn hình hiện tại của mình với chuyên viên không?",endSessionText:"Kết thúc phiên cùng duyệt",confirmRemoteControlTitle:"Yêu cầu truy cập từ xa",confirmRemoteControlContent:"Chuyên viên muốn được cấp quyền truy cập vào màn hình bạn đang chia sẻ để hỗ trợ bạn nhiều hơn. Bạn có muốn cho phép không?",confirmFullDeviceTitle:"Yêu cầu chia sẻ màn hình",confirmFullDeviceContent:"Bạn có muốn chia sẻ toàn bộ màn hình của mình với chuyên viên không? Chuyên viên sẽ không thể điều khiển bất cứ phần nào trên màn hình.",allowText:"Cho phép",denyText:"Từ chối"},h$={confirmSessionTitle:"ขอเซสชันเรียกดูร่วม",confirmSessionContent:"คุณต้องการแชร์หน้าจอปัจจุบันกับตัวแทนหรือไม่",endSessionText:"สิ้นสุดเซสชันเรียกดูร่วม",confirmRemoteControlTitle:"ขอการเข้าถึงระยะไกล",confirmRemoteControlContent:"ตัวแทนต้องการเข้าถึงหน้าจอของคุณที่แชร์อยู่ในปัจจุบันเพื่อให้ความช่วยเหลือคุณต่อไป คุณจะอนุญาตหรือไม่",confirmFullDeviceTitle:"ขอแชร์หน้าจอ",confirmFullDeviceContent:"คุณต้องการแชร์ทั้งหน้าของคุณกับตัวแทนหรือไม่ ตัวแทนจะไม่สามารถควบคุมอะไรบนหน้าจอ",allowText:"ยินยอม",denyText:"ปฏิเสธ"},v$={confirmSessionTitle:"طلب جلسة تصفح مشترك",confirmSessionContent:"هل تريد مشاركة شاشتك الحالية مع الموظف؟",endSessionText:"إنهاء جلسة التصفح المشترك",confirmRemoteControlTitle:"طلب التحكم عن بعد",confirmRemoteControlContent:"يرغب مسئول الدعم في رؤية شاشتك المشاركة حالياً لمساعدتك بشكلٍ أكبر. هل تسمح بذلك؟",confirmFullDeviceTitle:"طلب مشاركة الشاشة",confirmFullDeviceContent:"هل تريد مشاركة شاشتك الكاملة مع مسئول الدعم؟ لن يتمكن المسئول من التحكم في أي شيء على الشاشة.",allowText:"السماح",denyText:"الرفض"},m$={en:Q1,"en-CA":{confirmSessionTitle:"Co-browse Session Request",confirmSessionContent:"Do you want to share your current screen with the agent?",endSessionText:"End Co-browse Session",confirmRemoteControlTitle:"Remote Access Request",confirmRemoteControlContent:"The agent would like to have access to your currently shared screen to further assist you. Do you want to allow this?",confirmFullDeviceTitle:"Screen Share Request",confirmFullDeviceContent:"Do you want to share your full screen with the agent? The agent will not be able to control anything on the screen.",allowText:"Allow",denyText:"Deny"},"en-GB":{confirmSessionTitle:"Co-browse Session Request",confirmSessionContent:"Do you want to share your current screen with the agent?",endSessionText:"End Co-browse Session",confirmRemoteControlTitle:"Remote Access Request",confirmRemoteControlContent:"The agent would like to have access to your currently shared screen to further assist you. Do you want to allow this?",confirmFullDeviceTitle:"Screen Share Request",confirmFullDeviceContent:"Do you want to share your full screen with the agent? The agent will not be able to control anything on the screen.",allowText:"Allow",denyText:"Deny"},es:Z1,"es-MX":{confirmSessionTitle:"Solicitud de Sesión de Co-navegación",confirmSessionContent:"¿Quiere compartir su pantalla actual con el agente?",endSessionText:"Fin de la sesión de co-navegación",confirmRemoteControlTitle:"Solicitud de acceso remoto",confirmRemoteControlContent:"El agente desea tener acceso a su pantalla actualmente compartida para poder ayudarlo. ¿Quiere permitirlo?",confirmFullDeviceTitle:"Petición de pantalla compartida",confirmFullDeviceContent:"¿Quiere compartir su pantalla completa con el agente? El agente no podrá controlar nada en la pantalla.",allowText:"Permitir",denyText:"Denegar"},fr:e$,"fr-CA":{confirmSessionTitle:"Demande de session co-navigation",confirmSessionContent:"Voulez-vous partager votre écran actuel avec l'agent?",endSessionText:"Fin de la session de co-navigation",confirmRemoteControlTitle:"Demande d'accès à distance",confirmRemoteControlContent:"L'agent souhaiterait avoir accès à votre écran actuellement partagé pour mieux vous aider. Voulez-vous l'autoriser?",confirmFullDeviceTitle:"Demande de partage d'écran",confirmFullDeviceContent:"Voulez-vous partager votre écran complet avec l'agent? L'agent ne sera pas en mesure de contrôler quoi que ce soit sur l'écran.",allowText:"Autoriser",denyText:"Refuser"},de:t$,ja:r$,ko:n$,it:i$,zh:a$,"zh-Hant":{confirmSessionTitle:"共同瀏覽工作階段要求",confirmSessionContent:"要與專員分享您目前的畫面嗎?",endSessionText:"結束共同瀏覽工作階段",confirmRemoteControlTitle:"遠端存取要求",confirmRemoteControlContent:"專員想要存取您目前分享的螢幕畫面以進一步協助您。要允許嗎?",confirmFullDeviceTitle:"螢幕畫面分享要求",confirmFullDeviceContent:"要與專員分享全螢幕嗎?專員將無法控制畫面上的任何項目。",allowText:"允許",denyText:"拒絕"},sv:s$,pt:o$,"pt-BR":{confirmSessionTitle:"Solicitação de Sessão de Co-navegação",confirmSessionContent:"Você deseja compartilhar sua tela atual com o agente?",endSessionText:"Encerrar Sessão de Co-navegação",confirmRemoteControlTitle:"Solicitação de Acesso Remoto",confirmRemoteControlContent:"O agente gostaria de acessar sua tela atualmente compartilhada para melhor ajudá-lo. Você deseja permitir isso?",confirmFullDeviceTitle:"Solicitação de Compartilhamento de Tela",confirmFullDeviceContent:"Você deseja compartilhar sua tela inteira com o agente? O agente não poderá controlar nada na tela.",allowText:"Permitir",denyText:"Negar"},fi:u$,nb:c$,da:l$,nl:f$,tr:d$,vi:p$,th:h$,ar:v$};let g$=class{constructor(r){bt(this,"options");bt(this,"communicator");bt(this,"methods");bt(this,"events",new qh);bt(this,"request");bt(this,"chat");bt(this,"cobrowse");this.options=r,this.communicator=new _1(r,this.events);const t=this.communicator.request.bind(this.communicator);this.methods=new U1(t),this.request=t,Or.companyId=r.companyId,r.tenant&&(Or.tenant=r.tenant)}get deviceId(){return Or.deviceId}get user(){return this.communicator.user}get lang(){return this.options.lang?this.options.lang:Dr.get("lang")||"en"}set lang(r){this.options.lang||Dr.set("lang",r)}on(r,t){this.events.addEventListener(r,t)}off(r,t){this.events.removeEventListener(r,t)}async getCompany(){const r=await this.methods.getCompany();return Or.tenant=r.subdomain,r}async getTrigger(r){const t=await this.methods.getTriggers(this.options.companyId);return B1(t,r||this.lang)}getMenus(r,t){return this.methods.getMenus(t||this.lang,r)}getTimeSlots(r,t){return this.methods.getTimeSlots(r,t||this.lang)}createCall(r,t){var n;return!t.email&&((n=this.user)!=null&&n.email)&&(t.email=this.user.email),this.methods.createCall(Number(r),t.lang||this.lang,t)}loadCall(r){return this.methods.fetchCall(r)}cancelCall(r){return this.methods.cancelCall(r)}createEmail(r,t){return this.methods.createEmail(r,t.lang||this.lang,t)}async createChat(r,t={},n){var a,s;if(this.chat&&this.chat.ongoing)throw new Error("There is an ongoing chat.");!t.email&&((a=this.user)!=null&&a.email)&&(t.email=this.user.email),t.cobrowsable===void 0&&(t.cobrowsable=!!((s=this.options.cobrowse)!=null&&s.enabled));const i=await this.methods.createChat(Number(r),t.lang||this.lang,t,this.deviceId);return this.registerOngoingChat(i),await i.clearMediaStore(),n&&this.methods.sendChatCustomData(i.id,n),i}async loadChat(r){const t=await this.methods.loadChat(r,this.deviceId);return t.ongoing?this.registerOngoingChat(t):(Dr.del("chat"),Dr.del("cobrowse")),t}async resumeChat(r){const t=await this.methods.resumeChat(r,this.deviceId);return this.registerOngoingChat(t),t}async loadOngoingChat(){const r=Dr.get("chat");if(r){const t=await this.loadChat(r);if(t.ongoing)return t}}async finishChat(){if(this.chat){await this.chat.disconnect();const r=await this.methods.finishChat(this.chat.id);this.chat.update(r),this.events.triggerEvent("chat.ended")}}async destroyChat(){this.chat&&(this.chat.ongoing&&await this.finishChat(),await this.chat.destroy(),this.chat=null,Or.trackerId="")}sendChatTranscript(r){return this.methods.sendChatTranscript(this.chat.id,r)}getChatSurvey(){return this.methods.getChatSurvey(this.chat.id)}sendChatSurvey(r){if(this.chat.feedbackType!=="survey")throw new Error("Chat feedback type is: "+this.chat.feedbackType);return this.methods.sendChatSurvey(this.chat.id,r)}sendChatRate(r){if(this.chat.feedbackType!=="rate")throw new Error("Chat feedback type is: "+this.chat.feedbackType);return this.methods.rateChat(this.chat.id,r)}escalateChat(r){return this.methods.escalateChat(this.chat.id,r)}async sendFileMessage(r,t){const n=await this.methods.uploadChatFile(this.chat.id,r,t);return this.chat.sendMessage(n,r)}async sendTextMessage(r){const t={type:"text",content:r};return this.chat.sendMessage(t)}async createCobrowseCode(r,t){await this.initializeCobrowse(r||this.lang);let n=Dr.get("cobrowse");n||(n=Date.now().toString(),Dr.set("cobrowse",n));const i={device_id:this.deviceId,device_name:`${Or.application} / ${Or.version}`,nonce:n,...t};return this.user.name&&(i.user_name=this.user.name),this.cobrowse.setCustomData(i),this.cobrowse.createSessionCode()}async startCobrowse(r="end_user"){if(!this.chat.cobrowsable)throw new Error(`Chat ${this.chat.id} does not support cobrowse.`);const t={chatId:`chat_${this.chat.id}`},n=await this.createCobrowseCode(this.chat.lang,t);if(n){const i=Dr.get("cobrowse");await this.methods.requestChatCobrowse(this.chat.id,{code:n,from:r,nonce:i})}}async initializeCobrowse(r){if(!this.cobrowse){const t=this.options.cobrowse.messages||m$[r],n={...this.options.cobrowse,messages:t,lang:r};this.cobrowse=await Wh.create(n),this.cobrowse.start(),["loaded","updated","ended"].forEach(a=>{this.cobrowse.on(`session.${a}`,s=>{this.events.triggerEvent(`cobrowse.${a}`,s)})})}}registerOngoingChat(r){r._setGlobalEvents(this.events),r.on("_requestCobrowse",t=>{t==="agent"?this.startCobrowse(t):this.initializeCobrowse(r.lang),this.events.triggerEvent("cobrowse.request",{from:t})}),r.on("disconnected",()=>{Dr.del("chat"),Dr.del("cobrowse")}),this.chat=r,Or.trackerId=`chat_${r.id}`,Dr.set("chat",r.id.toString()),r.cobrowsable&&Dr.get("cobrowse")&&this.initializeCobrowse(r.lang)}};var ze=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Vh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function kw(e){if(e.__esModule)return e;var r=e.default;if(typeof r=="function"){var t=function n(){if(this instanceof n){var i=[null];i.push.apply(i,arguments);var a=Function.bind.apply(r,i);return new a}return r.apply(this,arguments)};t.prototype=r.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}),t}var Rw={},Uu=function(e){return e&&e.Math==Math&&e},Rt=Uu(typeof globalThis=="object"&&globalThis)||Uu(typeof window=="object"&&window)||Uu(typeof self=="object"&&self)||Uu(typeof ze=="object"&&ze)||function(){return this}()||ze||Function("return this")(),ii={},mt=function(e){try{return!!e()}catch{return!0}},y$=mt,Yt=!y$(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),b$=mt,uu=!b$(function(){var e=function(){}.bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),_$=uu,Bu=Function.prototype.call,qt=_$?Bu.bind(Bu):function(){return Bu.apply(Bu,arguments)},cu={},$w={}.propertyIsEnumerable,Ow=Object.getOwnPropertyDescriptor,S$=Ow&&!$w.call({1:2},1);cu.f=S$?function(r){var t=Ow(this,r);return!!t&&t.enumerable}:$w;var rs=function(e,r){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:r}},Iw=uu,Pw=Function.prototype,cp=Pw.call,w$=Iw&&Pw.bind.bind(cp,cp),_t=Iw?w$:function(e){return function(){return cp.apply(e,arguments)}},Aw=_t,T$=Aw({}.toString),C$=Aw("".slice),ai=function(e){return C$(T$(e),8,-1)},E$=_t,k$=mt,R$=ai,kf=Object,$$=E$("".split),lu=k$(function(){return!kf("z").propertyIsEnumerable(0)})?function(e){return R$(e)=="String"?$$(e,""):kf(e)}:kf,si=function(e){return e==null},O$=si,I$=TypeError,oi=function(e){if(O$(e))throw I$("Can't call method on "+e);return e},P$=lu,A$=oi,ln=function(e){return P$(A$(e))},lp=typeof document=="object"&&document.all,M$=typeof lp>"u"&&lp!==void 0,Mw={all:lp,IS_HTMLDDA:M$},xw=Mw,x$=xw.all,Bt=xw.IS_HTMLDDA?function(e){return typeof e=="function"||e===x$}:function(e){return typeof e=="function"},Hm=Bt,Nw=Mw,N$=Nw.all,tr=Nw.IS_HTMLDDA?function(e){return typeof e=="object"?e!==null:Hm(e)||e===N$}:function(e){return typeof e=="object"?e!==null:Hm(e)},Rf=Rt,L$=Bt,D$=function(e){return L$(e)?e:void 0},zn=function(e,r){return arguments.length<2?D$(Rf[e]):Rf[e]&&Rf[e][r]},j$=_t,Di=j$({}.isPrototypeOf),ns=typeof navigator<"u"&&String(navigator.userAgent)||"",Lw=Rt,$f=ns,Km=Lw.process,Jm=Lw.Deno,Ym=Km&&Km.versions||Jm&&Jm.version,Xm=Ym&&Ym.v8,jn,Xc;Xm&&(jn=Xm.split("."),Xc=jn[0]>0&&jn[0]<4?1:+(jn[0]+jn[1]));!Xc&&$f&&(jn=$f.match(/Edge\/(\d+)/),(!jn||jn[1]>=74)&&(jn=$f.match(/Chrome\/(\d+)/),jn&&(Xc=+jn[1])));var no=Xc,Qm=no,F$=mt,U$=Rt,B$=U$.String,io=!!Object.getOwnPropertySymbols&&!F$(function(){var e=Symbol();return!B$(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&Qm&&Qm<41}),q$=io,Dw=q$&&!Symbol.sham&&typeof Symbol.iterator=="symbol",G$=zn,z$=Bt,W$=Di,V$=Dw,H$=Object,ao=V$?function(e){return typeof e=="symbol"}:function(e){var r=G$("Symbol");return z$(r)&&W$(r.prototype,H$(e))},K$=String,is=function(e){try{return K$(e)}catch{return"Object"}},J$=Bt,Y$=is,X$=TypeError,En=function(e){if(J$(e))return e;throw X$(Y$(e)+" is not a function")},Q$=En,Z$=si,as=function(e,r){var t=e[r];return Z$(t)?void 0:Q$(t)},Of=qt,If=Bt,Pf=tr,eO=TypeError,tO=function(e,r){var t,n;if(r==="string"&&If(t=e.toString)&&!Pf(n=Of(t,e))||If(t=e.valueOf)&&!Pf(n=Of(t,e))||r!=="string"&&If(t=e.toString)&&!Pf(n=Of(t,e)))return n;throw eO("Can't convert object to primitive value")},jw={exports:{}},Fw=!1,Zm=Rt,rO=Object.defineProperty,Hh=function(e,r){try{rO(Zm,e,{value:r,configurable:!0,writable:!0})}catch{Zm[e]=r}return r},nO=Rt,iO=Hh,eg="__core-js_shared__",aO=nO[eg]||iO(eg,{}),Kh=aO,tg=Kh;(jw.exports=function(e,r){return tg[e]||(tg[e]=r!==void 0?r:{})})("versions",[]).push({version:"3.30.2",mode:"global",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.30.2/LICENSE",source:"https://github.com/zloirock/core-js"});var so=jw.exports,sO=oi,oO=Object,xr=function(e){return oO(sO(e))},uO=_t,cO=xr,lO=uO({}.hasOwnProperty),rr=Object.hasOwn||function(r,t){return lO(cO(r),t)},fO=_t,dO=0,pO=Math.random(),hO=fO(1 .toString),fu=function(e){return"Symbol("+(e===void 0?"":e)+")_"+hO(++dO+pO,36)},vO=Rt,mO=so,rg=rr,gO=fu,yO=io,bO=Dw,Ps=vO.Symbol,Af=mO("wks"),_O=bO?Ps.for||Ps:Ps&&Ps.withoutSetter||gO,Gt=function(e){return rg(Af,e)||(Af[e]=yO&&rg(Ps,e)?Ps[e]:_O("Symbol."+e)),Af[e]},SO=qt,ng=tr,ig=ao,wO=as,TO=tO,CO=Gt,EO=TypeError,kO=CO("toPrimitive"),Jh=function(e,r){if(!ng(e)||ig(e))return e;var t=wO(e,kO),n;if(t){if(r===void 0&&(r="default"),n=SO(t,e,r),!ng(n)||ig(n))return n;throw EO("Can't convert object to primitive value")}return r===void 0&&(r="number"),TO(e,r)},RO=Jh,$O=ao,du=function(e){var r=RO(e,"string");return $O(r)?r:r+""},OO=Rt,ag=tr,fp=OO.document,IO=ag(fp)&&ag(fp.createElement),_l=function(e){return IO?fp.createElement(e):{}},PO=Yt,AO=mt,MO=_l,Uw=!PO&&!AO(function(){return Object.defineProperty(MO("div"),"a",{get:function(){return 7}}).a!=7}),xO=Yt,NO=qt,LO=cu,DO=rs,jO=ln,FO=du,UO=rr,BO=Uw,sg=Object.getOwnPropertyDescriptor;ii.f=xO?sg:function(r,t){if(r=jO(r),t=FO(t),BO)try{return sg(r,t)}catch{}if(UO(r,t))return DO(!NO(LO.f,r,t),r[t])};var qr={},qO=Yt,GO=mt,Bw=qO&&GO(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),zO=tr,WO=String,VO=TypeError,sr=function(e){if(zO(e))return e;throw VO(WO(e)+" is not an object")},HO=Yt,KO=Uw,JO=Bw,qu=sr,og=du,YO=TypeError,Mf=Object.defineProperty,XO=Object.getOwnPropertyDescriptor,xf="enumerable",Nf="configurable",Lf="writable";qr.f=HO?JO?function(r,t,n){if(qu(r),t=og(t),qu(n),typeof r=="function"&&t==="prototype"&&"value"in n&&Lf in n&&!n[Lf]){var i=XO(r,t);i&&i[Lf]&&(r[t]=n.value,n={configurable:Nf in n?n[Nf]:i[Nf],enumerable:xf in n?n[xf]:i[xf],writable:!1})}return Mf(r,t,n)}:Mf:function(r,t,n){if(qu(r),t=og(t),qu(n),KO)try{return Mf(r,t,n)}catch{}if("get"in n||"set"in n)throw YO("Accessors not supported");return"value"in n&&(r[t]=n.value),r};var QO=Yt,ZO=qr,eI=rs,ji=QO?function(e,r,t){return ZO.f(e,r,eI(1,t))}:function(e,r,t){return e[r]=t,e},qw={exports:{}},dp=Yt,tI=rr,Gw=Function.prototype,rI=dp&&Object.getOwnPropertyDescriptor,Yh=tI(Gw,"name"),nI=Yh&&function(){}.name==="something",iI=Yh&&(!dp||dp&&rI(Gw,"name").configurable),pu={EXISTS:Yh,PROPER:nI,CONFIGURABLE:iI},aI=_t,sI=Bt,pp=Kh,oI=aI(Function.toString);sI(pp.inspectSource)||(pp.inspectSource=function(e){return oI(e)});var Xh=pp.inspectSource,uI=Rt,cI=Bt,ug=uI.WeakMap,lI=cI(ug)&&/native code/.test(String(ug)),fI=so,dI=fu,cg=fI("keys"),Sl=function(e){return cg[e]||(cg[e]=dI(e))},hu={},pI=lI,zw=Rt,hI=tr,vI=ji,Df=rr,jf=Kh,mI=Sl,gI=hu,lg="Object already initialized",hp=zw.TypeError,yI=zw.WeakMap,Qc,Qo,Zc,bI=function(e){return Zc(e)?Qo(e):Qc(e,{})},_I=function(e){return function(r){var t;if(!hI(r)||(t=Qo(r)).type!==e)throw hp("Incompatible receiver, "+e+" required");return t}};if(pI||jf.state){var Yn=jf.state||(jf.state=new yI);Yn.get=Yn.get,Yn.has=Yn.has,Yn.set=Yn.set,Qc=function(e,r){if(Yn.has(e))throw hp(lg);return r.facade=e,Yn.set(e,r),r},Qo=function(e){return Yn.get(e)||{}},Zc=function(e){return Yn.has(e)}}else{var ms=mI("state");gI[ms]=!0,Qc=function(e,r){if(Df(e,ms))throw hp(lg);return r.facade=e,vI(e,ms,r),r},Qo=function(e){return Df(e,ms)?e[ms]:{}},Zc=function(e){return Df(e,ms)}}var kn={set:Qc,get:Qo,has:Zc,enforce:bI,getterFor:_I},Qh=_t,SI=mt,wI=Bt,Gu=rr,vp=Yt,TI=pu.CONFIGURABLE,CI=Xh,Ww=kn,EI=Ww.enforce,kI=Ww.get,fg=String,jc=Object.defineProperty,RI=Qh("".slice),$I=Qh("".replace),OI=Qh([].join),II=vp&&!SI(function(){return jc(function(){},"length",{value:8}).length!==8}),PI=String(String).split("String"),AI=qw.exports=function(e,r,t){RI(fg(r),0,7)==="Symbol("&&(r="["+$I(fg(r),/^Symbol\(([^)]*)\)/,"$1")+"]"),t&&t.getter&&(r="get "+r),t&&t.setter&&(r="set "+r),(!Gu(e,"name")||TI&&e.name!==r)&&(vp?jc(e,"name",{value:r,configurable:!0}):e.name=r),II&&t&&Gu(t,"arity")&&e.length!==t.arity&&jc(e,"length",{value:t.arity});try{t&&Gu(t,"constructor")&&t.constructor?vp&&jc(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch{}var n=EI(e);return Gu(n,"source")||(n.source=OI(PI,typeof r=="string"?r:"")),e};Function.prototype.toString=AI(function(){return wI(this)&&kI(this).source||CI(this)},"toString");var Vw=qw.exports,MI=Bt,xI=qr,NI=Vw,LI=Hh,Gr=function(e,r,t,n){n||(n={});var i=n.enumerable,a=n.name!==void 0?n.name:r;if(MI(t)&&NI(t,a,n),n.global)i?e[r]=t:LI(r,t);else{try{n.unsafe?e[r]&&(i=!0):delete e[r]}catch{}i?e[r]=t:xI.f(e,r,{value:t,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return e},ba={},DI=Math.ceil,jI=Math.floor,FI=Math.trunc||function(r){var t=+r;return(t>0?jI:DI)(t)},UI=FI,ui=function(e){var r=+e;return r!==r||r===0?0:UI(r)},BI=ui,qI=Math.max,GI=Math.min,ss=function(e,r){var t=BI(e);return t<0?qI(t+r,0):GI(t,r)},zI=ui,WI=Math.min,Fi=function(e){return e>0?WI(zI(e),9007199254740991):0},VI=Fi,Ir=function(e){return VI(e.length)},HI=ln,KI=ss,JI=Ir,dg=function(e){return function(r,t,n){var i=HI(r),a=JI(i),s=KI(n,a),c;if(e&&t!=t){for(;a>s;)if(c=i[s++],c!=c)return!0}else for(;a>s;s++)if((e||s in i)&&i[s]===t)return e||s||0;return!e&&-1}},wl={includes:dg(!0),indexOf:dg(!1)},YI=_t,Ff=rr,XI=ln,QI=wl.indexOf,ZI=hu,pg=YI([].push),Hw=function(e,r){var t=XI(e),n=0,i=[],a;for(a in t)!Ff(ZI,a)&&Ff(t,a)&&pg(i,a);for(;r.length>n;)Ff(t,a=r[n++])&&(~QI(i,a)||pg(i,a));return i},Zh=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],eP=Hw,tP=Zh,rP=tP.concat("length","prototype");ba.f=Object.getOwnPropertyNames||function(r){return eP(r,rP)};var vu={};vu.f=Object.getOwnPropertySymbols;var nP=zn,iP=_t,aP=ba,sP=vu,oP=sr,uP=iP([].concat),Kw=nP("Reflect","ownKeys")||function(r){var t=aP.f(oP(r)),n=sP.f;return n?uP(t,n(r)):t},hg=rr,cP=Kw,lP=ii,fP=qr,Jw=function(e,r,t){for(var n=cP(r),i=fP.f,a=lP.f,s=0;s<n.length;s++){var c=n[s];!hg(e,c)&&!(t&&hg(t,c))&&i(e,c,a(r,c))}},dP=mt,pP=Bt,hP=/#|\.prototype\./,mu=function(e,r){var t=mP[vP(e)];return t==yP?!0:t==gP?!1:pP(r)?dP(r):!!r},vP=mu.normalize=function(e){return String(e).replace(hP,".").toLowerCase()},mP=mu.data={},gP=mu.NATIVE="N",yP=mu.POLYFILL="P",Tl=mu,Uf=Rt,bP=ii.f,_P=ji,SP=Gr,wP=Hh,TP=Jw,CP=Tl,St=function(e,r){var t=e.target,n=e.global,i=e.stat,a,s,c,o,u,l;if(n?s=Uf:i?s=Uf[t]||wP(t,{}):s=(Uf[t]||{}).prototype,s)for(c in r){if(u=r[c],e.dontCallGetSet?(l=bP(s,c),o=l&&l.value):o=s[c],a=CP(n?c:t+(i?".":"#")+c,e.forced),!a&&o!==void 0){if(typeof u==typeof o)continue;TP(u,o)}(e.sham||o&&o.sham)&&_P(u,"sham",!0),SP(s,c,u,e)}},EP=qr.f,kP=rr,RP=Gt,vg=RP("toStringTag"),Ui=function(e,r,t){e&&!t&&(e=e.prototype),e&&!kP(e,vg)&&EP(e,vg,{configurable:!0,value:r})},$P=St,OP=Rt,IP=Ui;$P({global:!0},{Reflect:{}});IP(OP.Reflect,"Reflect",!0);var PP=uu,Yw=Function.prototype,mg=Yw.apply,gg=Yw.call,_a=typeof Reflect=="object"&&Reflect.apply||(PP?gg.bind(mg):function(){return gg.apply(mg,arguments)}),AP=_t,oo=AP([].slice),Xw=_t,MP=En,xP=tr,NP=rr,yg=oo,LP=uu,Qw=Function,DP=Xw([].concat),jP=Xw([].join),Bf={},FP=function(e,r,t){if(!NP(Bf,r)){for(var n=[],i=0;i<r;i++)n[i]="a["+i+"]";Bf[r]=Qw("C,a","return new C("+jP(n,",")+")")}return Bf[r](e,t)},UP=LP?Qw.bind:function(r){var t=MP(this),n=t.prototype,i=yg(arguments,1),a=function(){var c=DP(i,yg(arguments));return this instanceof a?FP(t,c.length,c):t.apply(r,c)};return xP(n)&&(a.prototype=n),a},BP=Gt,qP=BP("toStringTag"),Zw={};Zw[qP]="z";var ev=String(Zw)==="[object z]",GP=ev,zP=Bt,Fc=ai,WP=Gt,VP=WP("toStringTag"),HP=Object,KP=Fc(function(){return arguments}())=="Arguments",JP=function(e,r){try{return e[r]}catch{}},Bi=GP?Fc:function(e){var r,t,n;return e===void 0?"Undefined":e===null?"Null":typeof(t=JP(r=HP(e),VP))=="string"?t:KP?Fc(r):(n=Fc(r))=="Object"&&zP(r.callee)?"Arguments":n},YP=_t,XP=mt,eT=Bt,QP=Bi,ZP=zn,eA=Xh,tT=function(){},tA=[],rT=ZP("Reflect","construct"),tv=/^\s*(?:class|function)\b/,rA=YP(tv.exec),nA=!tv.exec(tT),wo=function(r){if(!eT(r))return!1;try{return rT(tT,tA,r),!0}catch{return!1}},nT=function(r){if(!eT(r))return!1;switch(QP(r)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return nA||!!rA(tv,eA(r))}catch{return!0}};nT.sham=!0;var Cl=!rT||XP(function(){var e;return wo(wo.call)||!wo(Object)||!wo(function(){e=!0})||e})?nT:wo,iA=Cl,aA=is,sA=TypeError,rv=function(e){if(iA(e))return e;throw sA(aA(e)+" is not a constructor")},nv={},oA=Hw,uA=Zh,gu=Object.keys||function(r){return oA(r,uA)},cA=Yt,lA=Bw,fA=qr,dA=sr,pA=ln,hA=gu;nv.f=cA&&!lA?Object.defineProperties:function(r,t){dA(r);for(var n=pA(t),i=hA(t),a=i.length,s=0,c;a>s;)fA.f(r,c=i[s++],n[c]);return r};var vA=zn,iT=vA("document","documentElement"),mA=sr,gA=nv,bg=Zh,yA=hu,bA=iT,_A=_l,SA=Sl,_g=">",Sg="<",mp="prototype",gp="script",aT=SA("IE_PROTO"),qf=function(){},sT=function(e){return Sg+gp+_g+e+Sg+"/"+gp+_g},wg=function(e){e.write(sT("")),e.close();var r=e.parentWindow.Object;return e=null,r},wA=function(){var e=_A("iframe"),r="java"+gp+":",t;return e.style.display="none",bA.appendChild(e),e.src=String(r),t=e.contentWindow.document,t.open(),t.write(sT("document.F=Object")),t.close(),t.F},zu,Uc=function(){try{zu=new ActiveXObject("htmlfile")}catch{}Uc=typeof document<"u"?document.domain&&zu?wg(zu):wA():wg(zu);for(var e=bg.length;e--;)delete Uc[mp][bg[e]];return Uc()};yA[aT]=!0;var Sa=Object.create||function(r,t){var n;return r!==null?(qf[mp]=mA(r),n=new qf,qf[mp]=null,n[aT]=r):n=Uc(),t===void 0?n:gA.f(n,t)},TA=St,CA=zn,Gf=_a,EA=UP,Tg=rv,kA=sr,Cg=tr,RA=Sa,oT=mt,iv=CA("Reflect","construct"),$A=Object.prototype,OA=[].push,uT=oT(function(){function e(){}return!(iv(function(){},[],e)instanceof e)}),cT=!oT(function(){iv(function(){})}),Eg=uT||cT;TA({target:"Reflect",stat:!0,forced:Eg,sham:Eg},{construct:function(r,t){Tg(r),kA(t);var n=arguments.length<3?r:Tg(arguments[2]);if(cT&&!uT)return iv(r,t,n);if(r==n){switch(t.length){case 0:return new r;case 1:return new r(t[0]);case 2:return new r(t[0],t[1]);case 3:return new r(t[0],t[1],t[2]);case 4:return new r(t[0],t[1],t[2],t[3])}var i=[null];return Gf(OA,i,t),new(Gf(EA,r,i))}var a=n.prototype,s=RA(Cg(a)?a:$A),c=Gf(r,s,t);return Cg(c)?c:s}});var IA=St,PA=xr,lT=gu,AA=mt,MA=AA(function(){lT(1)});IA({target:"Object",stat:!0,forced:MA},{keys:function(r){return lT(PA(r))}});var xA=Bi,NA=String,br=function(e){if(xA(e)==="Symbol")throw TypeError("Cannot convert a Symbol value to a string");return NA(e)},av={},LA=du,DA=qr,jA=rs,uo=function(e,r,t){var n=LA(r);n in e?DA.f(e,n,jA(0,t)):e[n]=t},kg=ss,FA=Ir,UA=uo,BA=Array,qA=Math.max,yu=function(e,r,t){for(var n=FA(e),i=kg(r,n),a=kg(t===void 0?n:t,n),s=BA(qA(a-i,0)),c=0;i<a;i++,c++)UA(s,c,e[i]);return s.length=c,s},GA=ai,zA=ln,fT=ba.f,WA=yu,dT=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],VA=function(e){try{return fT(e)}catch{return WA(dT)}};av.f=function(r){return dT&&GA(r)=="Window"?VA(r):fT(zA(r))};var Rg=Vw,HA=qr,ci=function(e,r,t){return t.get&&Rg(t.get,r,{getter:!0}),t.set&&Rg(t.set,r,{setter:!0}),HA.f(e,r,t)},sv={},KA=Gt;sv.f=KA;var JA=Rt,pT=JA,$g=pT,YA=rr,XA=sv,QA=qr.f,hT=function(e){var r=$g.Symbol||($g.Symbol={});YA(r,e)||QA(r,e,{value:XA.f(e)})},ZA=qt,eM=zn,tM=Gt,rM=Gr,nM=function(){var e=eM("Symbol"),r=e&&e.prototype,t=r&&r.valueOf,n=tM("toPrimitive");r&&!r[n]&&rM(r,n,function(i){return ZA(t,this)},{arity:1})},iM=ai,aM=_t,El=function(e){if(iM(e)==="Function")return aM(e)},Og=El,sM=En,oM=uu,uM=Og(Og.bind),qi=function(e,r){return sM(e),r===void 0?e:oM?uM(e,r):function(){return e.apply(r,arguments)}},cM=ai,bu=Array.isArray||function(r){return cM(r)=="Array"},Ig=bu,lM=Cl,fM=tr,dM=Gt,pM=dM("species"),Pg=Array,hM=function(e){var r;return Ig(e)&&(r=e.constructor,lM(r)&&(r===Pg||Ig(r.prototype))?r=void 0:fM(r)&&(r=r[pM],r===null&&(r=void 0))),r===void 0?Pg:r},vM=hM,ov=function(e,r){return new(vM(e))(r===0?0:r)},mM=qi,gM=_t,yM=lu,bM=xr,_M=Ir,SM=ov,Ag=gM([].push),ra=function(e){var r=e==1,t=e==2,n=e==3,i=e==4,a=e==6,s=e==7,c=e==5||a;return function(o,u,l,f){for(var d=bM(o),p=yM(d),h=mM(u,l),E=_M(p),M=0,I=f||SM,x=r?I(o,E):t||s?I(o,0):void 0,j,z;E>M;M++)if((c||M in p)&&(j=p[M],z=h(j,M,d),e))if(r)x[M]=z;else if(z)switch(e){case 3:return!0;case 5:return j;case 6:return M;case 2:Ag(x,j)}else switch(e){case 4:return!1;case 7:Ag(x,j)}return a?-1:n||i?i:x}},fn={forEach:ra(0),map:ra(1),filter:ra(2),some:ra(3),every:ra(4),find:ra(5),findIndex:ra(6),filterReject:ra(7)},kl=St,uv=Rt,cv=qt,wM=_t,Hs=Yt,Ks=io,TM=mt,wr=rr,CM=Di,yp=sr,Rl=ln,lv=du,EM=br,bp=rs,Zo=Sa,vT=gu,kM=ba,mT=av,RM=vu,gT=ii,yT=qr,$M=nv,bT=cu,zf=Gr,OM=ci,fv=so,IM=Sl,_T=hu,Mg=fu,PM=Gt,AM=sv,MM=hT,xM=nM,NM=Ui,ST=kn,$l=fn.forEach,Qr=IM("hidden"),Ol="Symbol",eu="prototype",LM=ST.set,xg=ST.getterFor(Ol),Tn=Object[eu],Ka=uv.Symbol,Do=Ka&&Ka[eu],DM=uv.TypeError,Wf=uv.QObject,wT=gT.f,Wa=yT.f,TT=mT.f,jM=bT.f,CT=wM([].push),Ai=fv("symbols"),_u=fv("op-symbols"),FM=fv("wks"),_p=!Wf||!Wf[eu]||!Wf[eu].findChild,Sp=Hs&&TM(function(){return Zo(Wa({},"a",{get:function(){return Wa(this,"a",{value:7}).a}})).a!=7})?function(e,r,t){var n=wT(Tn,r);n&&delete Tn[r],Wa(e,r,t),n&&e!==Tn&&Wa(Tn,r,n)}:Wa,Vf=function(e,r){var t=Ai[e]=Zo(Do);return LM(t,{type:Ol,tag:e,description:r}),Hs||(t.description=r),t},Il=function(r,t,n){r===Tn&&Il(_u,t,n),yp(r);var i=lv(t);return yp(n),wr(Ai,i)?(n.enumerable?(wr(r,Qr)&&r[Qr][i]&&(r[Qr][i]=!1),n=Zo(n,{enumerable:bp(0,!1)})):(wr(r,Qr)||Wa(r,Qr,bp(1,{})),r[Qr][i]=!0),Sp(r,i,n)):Wa(r,i,n)},dv=function(r,t){yp(r);var n=Rl(t),i=vT(n).concat(RT(n));return $l(i,function(a){(!Hs||cv(wp,n,a))&&Il(r,a,n[a])}),r},UM=function(r,t){return t===void 0?Zo(r):dv(Zo(r),t)},wp=function(r){var t=lv(r),n=cv(jM,this,t);return this===Tn&&wr(Ai,t)&&!wr(_u,t)?!1:n||!wr(this,t)||!wr(Ai,t)||wr(this,Qr)&&this[Qr][t]?n:!0},ET=function(r,t){var n=Rl(r),i=lv(t);if(!(n===Tn&&wr(Ai,i)&&!wr(_u,i))){var a=wT(n,i);return a&&wr(Ai,i)&&!(wr(n,Qr)&&n[Qr][i])&&(a.enumerable=!0),a}},kT=function(r){var t=TT(Rl(r)),n=[];return $l(t,function(i){!wr(Ai,i)&&!wr(_T,i)&&CT(n,i)}),n},RT=function(e){var r=e===Tn,t=TT(r?_u:Rl(e)),n=[];return $l(t,function(i){wr(Ai,i)&&(!r||wr(Tn,i))&&CT(n,Ai[i])}),n};Ks||(Ka=function(){if(CM(Do,this))throw DM("Symbol is not a constructor");var r=!arguments.length||arguments[0]===void 0?void 0:EM(arguments[0]),t=Mg(r),n=function(i){this===Tn&&cv(n,_u,i),wr(this,Qr)&&wr(this[Qr],t)&&(this[Qr][t]=!1),Sp(this,t,bp(1,i))};return Hs&&_p&&Sp(Tn,t,{configurable:!0,set:n}),Vf(t,r)},Do=Ka[eu],zf(Do,"toString",function(){return xg(this).tag}),zf(Ka,"withoutSetter",function(e){return Vf(Mg(e),e)}),bT.f=wp,yT.f=Il,$M.f=dv,gT.f=ET,kM.f=mT.f=kT,RM.f=RT,AM.f=function(e){return Vf(PM(e),e)},Hs&&(OM(Do,"description",{configurable:!0,get:function(){return xg(this).description}}),zf(Tn,"propertyIsEnumerable",wp,{unsafe:!0})));kl({global:!0,constructor:!0,wrap:!0,forced:!Ks,sham:!Ks},{Symbol:Ka});$l(vT(FM),function(e){MM(e)});kl({target:Ol,stat:!0,forced:!Ks},{useSetter:function(){_p=!0},useSimple:function(){_p=!1}});kl({target:"Object",stat:!0,forced:!Ks,sham:!Hs},{create:UM,defineProperty:Il,defineProperties:dv,getOwnPropertyDescriptor:ET});kl({target:"Object",stat:!0,forced:!Ks},{getOwnPropertyNames:kT});xM();NM(Ka,Ol);_T[Qr]=!0;var BM=io,$T=BM&&!!Symbol.for&&!!Symbol.keyFor,qM=St,GM=zn,zM=rr,WM=br,OT=so,VM=$T,Hf=OT("string-to-symbol-registry"),HM=OT("symbol-to-string-registry");qM({target:"Symbol",stat:!0,forced:!VM},{for:function(e){var r=WM(e);if(zM(Hf,r))return Hf[r];var t=GM("Symbol")(r);return Hf[r]=t,HM[t]=r,t}});var KM=St,JM=rr,YM=ao,XM=is,QM=so,ZM=$T,Ng=QM("symbol-to-string-registry");KM({target:"Symbol",stat:!0,forced:!ZM},{keyFor:function(r){if(!YM(r))throw TypeError(XM(r)+" is not a symbol");if(JM(Ng,r))return Ng[r]}});var ex=_t,Lg=bu,tx=Bt,Dg=ai,rx=br,jg=ex([].push),nx=function(e){if(tx(e))return e;if(Lg(e)){for(var r=e.length,t=[],n=0;n<r;n++){var i=e[n];typeof i=="string"?jg(t,i):(typeof i=="number"||Dg(i)=="Number"||Dg(i)=="String")&&jg(t,rx(i))}var a=t.length,s=!0;return function(c,o){if(s)return s=!1,o;if(Lg(this))return o;for(var u=0;u<a;u++)if(t[u]===c)return o}}},ix=St,IT=zn,PT=_a,ax=qt,Su=_t,AT=mt,Fg=Bt,Ug=ao,MT=oo,sx=nx,ox=io,ux=String,da=IT("JSON","stringify"),Wu=Su(/./.exec),Bg=Su("".charAt),cx=Su("".charCodeAt),lx=Su("".replace),fx=Su(1 .toString),dx=/[\uD800-\uDFFF]/g,qg=/^[\uD800-\uDBFF]$/,Gg=/^[\uDC00-\uDFFF]$/,zg=!ox||AT(function(){var e=IT("Symbol")();return da([e])!="[null]"||da({a:e})!="{}"||da(Object(e))!="{}"}),Wg=AT(function(){return da("\uDF06\uD834")!=='"\\udf06\\ud834"'||da("\uDEAD")!=='"\\udead"'}),px=function(e,r){var t=MT(arguments),n=sx(r);if(!(!Fg(n)&&(e===void 0||Ug(e))))return t[1]=function(i,a){if(Fg(n)&&(a=ax(n,this,ux(i),a)),!Ug(a))return a},PT(da,null,t)},hx=function(e,r,t){var n=Bg(t,r-1),i=Bg(t,r+1);return Wu(qg,e)&&!Wu(Gg,i)||Wu(Gg,e)&&!Wu(qg,n)?"\\u"+fx(cx(e,0),16):e};da&&ix({target:"JSON",stat:!0,arity:3,forced:zg||Wg},{stringify:function(r,t,n){var i=MT(arguments),a=PT(zg?px:da,null,i);return Wg&&typeof a=="string"?lx(a,dx,hx):a}});var vx=St,mx=io,gx=mt,xT=vu,yx=xr,bx=!mx||gx(function(){xT.f(1)});vx({target:"Object",stat:!0,forced:bx},{getOwnPropertySymbols:function(r){var t=xT.f;return t?t(yx(r)):[]}});var _x=mt,Sx=Gt,wx=no,Tx=Sx("species"),wu=function(e){return wx>=51||!_x(function(){var r=[],t=r.constructor={};return t[Tx]=function(){return{foo:1}},r[e](Boolean).foo!==1})},Cx=St,Ex=fn.filter,kx=wu,Rx=kx("filter");Cx({target:"Array",proto:!0,forced:!Rx},{filter:function(r){return Ex(this,r,arguments.length>1?arguments[1]:void 0)}});var $x=St,Ox=mt,Ix=ln,NT=ii.f,LT=Yt,Px=!LT||Ox(function(){NT(1)});$x({target:"Object",stat:!0,forced:Px,sham:!LT},{getOwnPropertyDescriptor:function(r,t){return NT(Ix(r),t)}});var Ax=St,Mx=Yt,xx=Kw,Nx=ln,Lx=ii,Dx=uo;Ax({target:"Object",stat:!0,sham:!Mx},{getOwnPropertyDescriptors:function(r){for(var t=Nx(r),n=Lx.f,i=xx(t),a={},s=0,c,o;i.length>s;)o=n(t,c=i[s++]),o!==void 0&&Dx(a,c,o);return a}});var DT={exports:{}};(function(e){function r(n,i,a,s,c,o,u){try{var l=n[o](u),f=l.value}catch(d){a(d);return}l.done?i(f):Promise.resolve(f).then(s,c)}function t(n){return function(){var i=this,a=arguments;return new Promise(function(s,c){var o=n.apply(i,a);function u(f){r(o,s,c,u,l,"next",f)}function l(f){r(o,s,c,u,l,"throw",f)}u(void 0)})}}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(DT);var Tu=DT.exports,jT={exports:{}};(function(e){function r(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(jT);var os=jT.exports,FT={exports:{}},UT={exports:{}};(function(e){function r(t,n){return e.exports=r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,s){return a.__proto__=s,a},e.exports.__esModule=!0,e.exports.default=e.exports,r(t,n)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(UT);var pv=UT.exports;(function(e){var r=pv;function t(n,i){if(typeof i!="function"&&i!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(i&&i.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),i&&r(n,i)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(FT);var li=FT.exports,BT={exports:{}},qT={exports:{}};(function(e){function r(t){"@babel/helpers - typeof";return e.exports=r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},e.exports.__esModule=!0,e.exports.default=e.exports,r(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(qT);var Rn=qT.exports;(function(e){var r=Rn.default,t=os;function n(i,a){if(a&&(r(a)==="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return t(i)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports})(BT);var fi=BT.exports,GT={exports:{}};(function(e){function r(t){return e.exports=r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},e.exports.__esModule=!0,e.exports.default=e.exports,r(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(GT);var $n=GT.exports,zT={exports:{}},WT={exports:{}},VT={exports:{}};(function(e){var r=Rn.default;function t(n,i){if(r(n)!=="object"||n===null)return n;var a=n[Symbol.toPrimitive];if(a!==void 0){var s=a.call(n,i||"default");if(r(s)!=="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(VT);var jx=VT.exports;(function(e){var r=Rn.default,t=jx;function n(i){var a=t(i,"string");return r(a)==="symbol"?a:String(a)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports})(WT);var HT=WT.exports;(function(e){var r=HT;function t(n,i,a){return i=r(i),i in n?Object.defineProperty(n,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[i]=a,n}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(zT);var us=zT.exports,KT={exports:{}};(function(e){var r=HT;function t(i,a){for(var s=0;s<a.length;s++){var c=a[s];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(i,r(c.key),c)}}function n(i,a,s){return a&&t(i.prototype,a),s&&t(i,s),Object.defineProperty(i,"prototype",{writable:!1}),i}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports})(KT);var wa=KT.exports,JT={exports:{}};(function(e){function r(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(JT);var di=JT.exports,Fx=ev,Ux=Bi,Bx=Fx?{}.toString:function(){return"[object "+Ux(this)+"]"},qx=ev,Gx=Gr,zx=Bx;qx||Gx(Object.prototype,"toString",zx,{unsafe:!0});var Wx=ai,Pl=typeof process<"u"&&Wx(process)=="process",Vx=_t,Hx=En,Kx=function(e,r,t){try{return Vx(Hx(Object.getOwnPropertyDescriptor(e,r)[t]))}catch{}},Jx=Bt,Yx=String,Xx=TypeError,Qx=function(e){if(typeof e=="object"||Jx(e))return e;throw Xx("Can't set "+Yx(e)+" as a prototype")},Zx=Kx,eN=sr,tN=Qx,co=Object.setPrototypeOf||("__proto__"in{}?function(){var e=!1,r={},t;try{t=Zx(Object.prototype,"__proto__","set"),t(r,[]),e=r instanceof Array}catch{}return function(i,a){return eN(i),tN(a),e?t(i,a):i.__proto__=a,i}}():void 0),rN=zn,nN=ci,iN=Gt,aN=Yt,Vg=iN("species"),Al=function(e){var r=rN(e);aN&&r&&!r[Vg]&&nN(r,Vg,{configurable:!0,get:function(){return this}})},sN=Di,oN=TypeError,cs=function(e,r){if(sN(r,e))return e;throw oN("Incorrect invocation")},Hg=sr,uN=rv,cN=si,lN=Gt,fN=lN("species"),hv=function(e,r){var t=Hg(e).constructor,n;return t===void 0||cN(n=Hg(t)[fN])?r:uN(n)},dN=TypeError,vv=function(e,r){if(e<r)throw dN("Not enough arguments");return e},pN=ns,YT=/(?:ipad|iphone|ipod).*applewebkit/i.test(pN),cn=Rt,hN=_a,vN=qi,Kg=Bt,mN=rr,XT=mt,Jg=iT,gN=oo,Yg=_l,yN=vv,bN=YT,_N=Pl,Tp=cn.setImmediate,Cp=cn.clearImmediate,SN=cn.process,Kf=cn.Dispatch,wN=cn.Function,Xg=cn.MessageChannel,TN=cn.String,Jf=0,Vo={},Qg="onreadystatechange",tu,Da,Yf,Xf;XT(function(){tu=cn.location});var mv=function(e){if(mN(Vo,e)){var r=Vo[e];delete Vo[e],r()}},Qf=function(e){return function(){mv(e)}},Zg=function(e){mv(e.data)},ey=function(e){cn.postMessage(TN(e),tu.protocol+"//"+tu.host)};(!Tp||!Cp)&&(Tp=function(r){yN(arguments.length,1);var t=Kg(r)?r:wN(r),n=gN(arguments,1);return Vo[++Jf]=function(){hN(t,void 0,n)},Da(Jf),Jf},Cp=function(r){delete Vo[r]},_N?Da=function(e){SN.nextTick(Qf(e))}:Kf&&Kf.now?Da=function(e){Kf.now(Qf(e))}:Xg&&!bN?(Yf=new Xg,Xf=Yf.port2,Yf.port1.onmessage=Zg,Da=vN(Xf.postMessage,Xf)):cn.addEventListener&&Kg(cn.postMessage)&&!cn.importScripts&&tu&&tu.protocol!=="file:"&&!XT(ey)?(Da=ey,cn.addEventListener("message",Zg,!1)):Qg in Yg("script")?Da=function(e){Jg.appendChild(Yg("script"))[Qg]=function(){Jg.removeChild(this),mv(e)}}:Da=function(e){setTimeout(Qf(e),0)});var QT={set:Tp,clear:Cp},ZT=function(){this.head=null,this.tail=null};ZT.prototype={add:function(e){var r={item:e,next:null},t=this.tail;t?t.next=r:this.head=r,this.tail=r},get:function(){var e=this.head;if(e){var r=this.head=e.next;return r===null&&(this.tail=null),e.item}}};var eC=ZT,CN=ns,EN=/ipad|iphone|ipod/i.test(CN)&&typeof Pebble<"u",kN=ns,RN=/web0s(?!.*chrome)/i.test(kN),Ya=Rt,ty=qi,$N=ii.f,Zf=QT.set,ON=eC,IN=YT,PN=EN,AN=RN,ed=Pl,ry=Ya.MutationObserver||Ya.WebKitMutationObserver,ny=Ya.document,iy=Ya.process,Vu=Ya.Promise,ay=$N(Ya,"queueMicrotask"),Ep=ay&&ay.value,gs,td,rd,Hu,sy;if(!Ep){var Ku=new ON,Ju=function(){var e,r;for(ed&&(e=iy.domain)&&e.exit();r=Ku.get();)try{r()}catch(t){throw Ku.head&&gs(),t}e&&e.enter()};!IN&&!ed&&!AN&&ry&&ny?(td=!0,rd=ny.createTextNode(""),new ry(Ju).observe(rd,{characterData:!0}),gs=function(){rd.data=td=!td}):!PN&&Vu&&Vu.resolve?(Hu=Vu.resolve(void 0),Hu.constructor=Vu,sy=ty(Hu.then,Hu),gs=function(){sy(Ju)}):ed?gs=function(){iy.nextTick(Ju)}:(Zf=ty(Zf,Ya),gs=function(){Zf(Ju)}),Ep=function(e){Ku.head||gs(),Ku.add(e)}}var MN=Ep,xN=function(e,r){try{arguments.length==1?console.error(e):console.error(e,r)}catch{}},gv=function(e){try{return{error:!1,value:e()}}catch(r){return{error:!0,value:r}}},NN=Rt,Ml=NN.Promise,tC=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",LN=tC,DN=Pl,jN=!LN&&!DN&&typeof window=="object"&&typeof document=="object",FN=Rt,Ho=Ml,UN=Bt,BN=Tl,qN=Xh,GN=Gt,zN=jN,WN=tC,nd=no;Ho&&Ho.prototype;var VN=GN("species"),kp=!1,rC=UN(FN.PromiseRejectionEvent),HN=BN("Promise",function(){var e=qN(Ho),r=e!==String(Ho);if(!r&&nd===66)return!0;if(!nd||nd<51||!/native code/.test(e)){var t=new Ho(function(a){a(1)}),n=function(a){a(function(){},function(){})},i=t.constructor={};if(i[VN]=n,kp=t.then(function(){})instanceof n,!kp)return!0}return!r&&(zN||WN)&&!rC}),Cu={CONSTRUCTOR:HN,REJECTION_EVENT:rC,SUBCLASSING:kp},lo={},oy=En,KN=TypeError,JN=function(e){var r,t;this.promise=new e(function(n,i){if(r!==void 0||t!==void 0)throw KN("Bad Promise constructor");r=n,t=i}),this.resolve=oy(r),this.reject=oy(t)};lo.f=function(e){return new JN(e)};var YN=St,el=Pl,ma=Rt,Js=qt,uy=Gr,cy=co,XN=Ui,QN=Al,ZN=En,Bc=Bt,eL=tr,tL=cs,rL=hv,nC=QT.set,yv=MN,nL=xN,iL=gv,aL=eC,iC=kn,tl=Ml,bv=Cu,aC=lo,xl="Promise",sC=bv.CONSTRUCTOR,sL=bv.REJECTION_EVENT,oL=bv.SUBCLASSING,id=iC.getterFor(xl),uL=iC.set,Rs=tl&&tl.prototype,Va=tl,Yu=Rs,oC=ma.TypeError,Rp=ma.document,_v=ma.process,$p=aC.f,cL=$p,lL=!!(Rp&&Rp.createEvent&&ma.dispatchEvent),uC="unhandledrejection",fL="rejectionhandled",ly=0,cC=1,dL=2,Sv=1,lC=2,Xu,fy,pL,dy,fC=function(e){var r;return eL(e)&&Bc(r=e.then)?r:!1},dC=function(e,r){var t=r.value,n=r.state==cC,i=n?e.ok:e.fail,a=e.resolve,s=e.reject,c=e.domain,o,u,l;try{i?(n||(r.rejection===lC&&vL(r),r.rejection=Sv),i===!0?o=t:(c&&c.enter(),o=i(t),c&&(c.exit(),l=!0)),o===e.promise?s(oC("Promise-chain cycle")):(u=fC(o))?Js(u,o,a,s):a(o)):s(t)}catch(f){c&&!l&&c.exit(),s(f)}},pC=function(e,r){e.notified||(e.notified=!0,yv(function(){for(var t=e.reactions,n;n=t.get();)dC(n,e);e.notified=!1,r&&!e.rejection&&hL(e)}))},hC=function(e,r,t){var n,i;lL?(n=Rp.createEvent("Event"),n.promise=r,n.reason=t,n.initEvent(e,!1,!0),ma.dispatchEvent(n)):n={promise:r,reason:t},!sL&&(i=ma["on"+e])?i(n):e===uC&&nL("Unhandled promise rejection",t)},hL=function(e){Js(nC,ma,function(){var r=e.facade,t=e.value,n=py(e),i;if(n&&(i=iL(function(){el?_v.emit("unhandledRejection",t,r):hC(uC,r,t)}),e.rejection=el||py(e)?lC:Sv,i.error))throw i.value})},py=function(e){return e.rejection!==Sv&&!e.parent},vL=function(e){Js(nC,ma,function(){var r=e.facade;el?_v.emit("rejectionHandled",r):hC(fL,r,e.value)})},As=function(e,r,t){return function(n){e(r,n,t)}},Ls=function(e,r,t){e.done||(e.done=!0,t&&(e=t),e.value=r,e.state=dL,pC(e,!0))},Op=function(e,r,t){if(!e.done){e.done=!0,t&&(e=t);try{if(e.facade===r)throw oC("Promise can't be resolved itself");var n=fC(r);n?yv(function(){var i={done:!1};try{Js(n,r,As(Op,i,e),As(Ls,i,e))}catch(a){Ls(i,a,e)}}):(e.value=r,e.state=cC,pC(e,!1))}catch(i){Ls({done:!1},i,e)}}};if(sC&&(Va=function(r){tL(this,Yu),ZN(r),Js(Xu,this);var t=id(this);try{r(As(Op,t),As(Ls,t))}catch(n){Ls(t,n)}},Yu=Va.prototype,Xu=function(r){uL(this,{type:xl,done:!1,notified:!1,parent:!1,reactions:new aL,rejection:!1,state:ly,value:void 0})},Xu.prototype=uy(Yu,"then",function(r,t){var n=id(this),i=$p(rL(this,Va));return n.parent=!0,i.ok=Bc(r)?r:!0,i.fail=Bc(t)&&t,i.domain=el?_v.domain:void 0,n.state==ly?n.reactions.add(i):yv(function(){dC(i,n)}),i.promise}),fy=function(){var e=new Xu,r=id(e);this.promise=e,this.resolve=As(Op,r),this.reject=As(Ls,r)},aC.f=$p=function(e){return e===Va||e===pL?new fy(e):cL(e)},Bc(tl)&&Rs!==Object.prototype)){dy=Rs.then,oL||uy(Rs,"then",function(r,t){var n=this;return new Va(function(i,a){Js(dy,n,i,a)}).then(r,t)},{unsafe:!0});try{delete Rs.constructor}catch{}cy&&cy(Rs,Yu)}YN({global:!0,constructor:!0,wrap:!0,forced:sC},{Promise:Va});XN(Va,xl,!1);QN(xl);var Eu={},mL=Gt,gL=Eu,yL=mL("iterator"),bL=Array.prototype,wv=function(e){return e!==void 0&&(gL.Array===e||bL[yL]===e)},_L=Bi,hy=as,SL=si,wL=Eu,TL=Gt,CL=TL("iterator"),ku=function(e){if(!SL(e))return hy(e,CL)||hy(e,"@@iterator")||wL[_L(e)]},EL=qt,kL=En,RL=sr,$L=is,OL=ku,IL=TypeError,Nl=function(e,r){var t=arguments.length<2?OL(e):r;if(kL(t))return RL(EL(t,e));throw IL($L(e)+" is not iterable")},PL=qt,vy=sr,AL=as,vC=function(e,r,t){var n,i;vy(e);try{if(n=AL(e,"return"),!n){if(r==="throw")throw t;return t}n=PL(n,e)}catch(a){i=!0,n=a}if(r==="throw")throw t;if(i)throw n;return vy(n),t},ML=qi,xL=qt,NL=sr,LL=is,DL=wv,jL=Ir,my=Di,FL=Nl,UL=ku,gy=vC,BL=TypeError,qc=function(e,r){this.stopped=e,this.result=r},yy=qc.prototype,Ll=function(e,r,t){var n=t&&t.that,i=!!(t&&t.AS_ENTRIES),a=!!(t&&t.IS_RECORD),s=!!(t&&t.IS_ITERATOR),c=!!(t&&t.INTERRUPTED),o=ML(r,n),u,l,f,d,p,h,E,M=function(x){return u&&gy(u,"normal",x),new qc(!0,x)},I=function(x){return i?(NL(x),c?o(x[0],x[1],M):o(x[0],x[1])):c?o(x,M):o(x)};if(a)u=e.iterator;else if(s)u=e;else{if(l=UL(e),!l)throw BL(LL(e)+" is not iterable");if(DL(l)){for(f=0,d=jL(e);d>f;f++)if(p=I(e[f]),p&&my(yy,p))return p;return new qc(!1)}u=FL(e,l)}for(h=a?e.next:u.next;!(E=xL(h,u)).done;){try{p=I(E.value)}catch(x){gy(u,"throw",x)}if(typeof p=="object"&&p&&my(yy,p))return p}return new qc(!1)},qL=Gt,mC=qL("iterator"),gC=!1;try{var GL=0,by={next:function(){return{done:!!GL++}},return:function(){gC=!0}};by[mC]=function(){return this},Array.from(by,function(){throw 2})}catch{}var Dl=function(e,r){if(!r&&!gC)return!1;var t=!1;try{var n={};n[mC]=function(){return{next:function(){return{done:t=!0}}}},e(n)}catch{}return t},zL=Ml,WL=Dl,VL=Cu.CONSTRUCTOR,yC=VL||!WL(function(e){zL.all(e).then(void 0,function(){})}),HL=St,KL=qt,JL=En,YL=lo,XL=gv,QL=Ll,ZL=yC;HL({target:"Promise",stat:!0,forced:ZL},{all:function(r){var t=this,n=YL.f(t),i=n.resolve,a=n.reject,s=XL(function(){var c=JL(t.resolve),o=[],u=0,l=1;QL(r,function(f){var d=u++,p=!1;l++,KL(c,t,f).then(function(h){p||(p=!0,o[d]=h,--l||i(o))},a)}),--l||i(o)});return s.error&&a(s.value),n.promise}});var eD=St,tD=Cu.CONSTRUCTOR,Ip=Ml,rD=zn,nD=Bt,iD=Gr,_y=Ip&&Ip.prototype;eD({target:"Promise",proto:!0,forced:tD,real:!0},{catch:function(e){return this.then(void 0,e)}});if(nD(Ip)){var Sy=rD("Promise").prototype.catch;_y.catch!==Sy&&iD(_y,"catch",Sy,{unsafe:!0})}var aD=St,sD=qt,oD=En,uD=lo,cD=gv,lD=Ll,fD=yC;aD({target:"Promise",stat:!0,forced:fD},{race:function(r){var t=this,n=uD.f(t),i=n.reject,a=cD(function(){var s=oD(t.resolve);lD(r,function(c){sD(s,t,c).then(n.resolve,i)})});return a.error&&i(a.value),n.promise}});var dD=St,pD=qt,hD=lo,vD=Cu.CONSTRUCTOR;dD({target:"Promise",stat:!0,forced:vD},{reject:function(r){var t=hD.f(this);return pD(t.reject,void 0,r),t.promise}});var mD=sr,gD=tr,yD=lo,bD=function(e,r){if(mD(e),gD(r)&&r.constructor===e)return r;var t=yD.f(e),n=t.resolve;return n(r),t.promise},_D=St,SD=zn,wD=Cu.CONSTRUCTOR,TD=bD;SD("Promise");_D({target:"Promise",stat:!0,forced:wD},{resolve:function(r){return TD(this,r)}});var CD=St,ED=fn.map,kD=wu,RD=kD("map");CD({target:"Array",proto:!0,forced:!RD},{map:function(r){return ED(this,r,arguments.length>1?arguments[1]:void 0)}});var bC={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},$D=_l,ad=$D("span").classList,wy=ad&&ad.constructor&&ad.constructor.prototype,_C=wy===Object.prototype?void 0:wy,OD=mt,jl=function(e,r){var t=[][e];return!!t&&OD(function(){t.call(null,r||function(){return 1},1)})},ID=fn.forEach,PD=jl,AD=PD("forEach"),MD=AD?[].forEach:function(r){return ID(this,r,arguments.length>1?arguments[1]:void 0)},Ty=Rt,Cy=bC,xD=_C,sd=MD,ND=ji,SC=function(e){if(e&&e.forEach!==sd)try{ND(e,"forEach",sd)}catch{e.forEach=sd}};for(var od in Cy)Cy[od]&&SC(Ty[od]&&Ty[od].prototype);SC(xD);var wC={exports:{}};(function(e){var r=Rn.default;function t(){e.exports=t=function(){return n},e.exports.__esModule=!0,e.exports.default=e.exports;var n={},i=Object.prototype,a=i.hasOwnProperty,s=Object.defineProperty||function(be,Te,we){be[Te]=we.value},c=typeof Symbol=="function"?Symbol:{},o=c.iterator||"@@iterator",u=c.asyncIterator||"@@asyncIterator",l=c.toStringTag||"@@toStringTag";function f(be,Te,we){return Object.defineProperty(be,Te,{value:we,enumerable:!0,configurable:!0,writable:!0}),be[Te]}try{f({},"")}catch{f=function(we,ge,$e){return we[ge]=$e}}function d(be,Te,we,ge){var $e=Te&&Te.prototype instanceof E?Te:E,De=Object.create($e.prototype),G=new Re(ge||[]);return s(De,"_invoke",{value:L(be,we,G)}),De}function p(be,Te,we){try{return{type:"normal",arg:be.call(Te,we)}}catch(ge){return{type:"throw",arg:ge}}}n.wrap=d;var h={};function E(){}function M(){}function I(){}var x={};f(x,o,function(){return this});var j=Object.getPrototypeOf,z=j&&j(j(ae([])));z&&z!==i&&a.call(z,o)&&(x=z);var ie=I.prototype=E.prototype=Object.create(x);function oe(be){["next","throw","return"].forEach(function(Te){f(be,Te,function(we){return this._invoke(Te,we)})})}function J(be,Te){function we($e,De,G,Qe){var Et=p(be[$e],be,De);if(Et.type!=="throw"){var ut=Et.arg,je=ut.value;return je&&r(je)=="object"&&a.call(je,"__await")?Te.resolve(je.__await).then(function(te){we("next",te,G,Qe)},function(te){we("throw",te,G,Qe)}):Te.resolve(je).then(function(te){ut.value=te,G(ut)},function(te){return we("throw",te,G,Qe)})}Qe(Et.arg)}var ge;s(this,"_invoke",{value:function(De,G){function Qe(){return new Te(function(Et,ut){we(De,G,Et,ut)})}return ge=ge?ge.then(Qe,Qe):Qe()}})}function L(be,Te,we){var ge="suspendedStart";return function($e,De){if(ge==="executing")throw new Error("Generator is already running");if(ge==="completed"){if($e==="throw")throw De;return Ve()}for(we.method=$e,we.arg=De;;){var G=we.delegate;if(G){var Qe=Y(G,we);if(Qe){if(Qe===h)continue;return Qe}}if(we.method==="next")we.sent=we._sent=we.arg;else if(we.method==="throw"){if(ge==="suspendedStart")throw ge="completed",we.arg;we.dispatchException(we.arg)}else we.method==="return"&&we.abrupt("return",we.arg);ge="executing";var Et=p(be,Te,we);if(Et.type==="normal"){if(ge=we.done?"completed":"suspendedYield",Et.arg===h)continue;return{value:Et.arg,done:we.done}}Et.type==="throw"&&(ge="completed",we.method="throw",we.arg=Et.arg)}}}function Y(be,Te){var we=Te.method,ge=be.iterator[we];if(ge===void 0)return Te.delegate=null,we==="throw"&&be.iterator.return&&(Te.method="return",Te.arg=void 0,Y(be,Te),Te.method==="throw")||we!=="return"&&(Te.method="throw",Te.arg=new TypeError("The iterator does not provide a '"+we+"' method")),h;var $e=p(ge,be.iterator,Te.arg);if($e.type==="throw")return Te.method="throw",Te.arg=$e.arg,Te.delegate=null,h;var De=$e.arg;return De?De.done?(Te[be.resultName]=De.value,Te.next=be.nextLoc,Te.method!=="return"&&(Te.method="next",Te.arg=void 0),Te.delegate=null,h):De:(Te.method="throw",Te.arg=new TypeError("iterator result is not an object"),Te.delegate=null,h)}function Z(be){var Te={tryLoc:be[0]};1 in be&&(Te.catchLoc=be[1]),2 in be&&(Te.finallyLoc=be[2],Te.afterLoc=be[3]),this.tryEntries.push(Te)}function ye(be){var Te=be.completion||{};Te.type="normal",delete Te.arg,be.completion=Te}function Re(be){this.tryEntries=[{tryLoc:"root"}],be.forEach(Z,this),this.reset(!0)}function ae(be){if(be){var Te=be[o];if(Te)return Te.call(be);if(typeof be.next=="function")return be;if(!isNaN(be.length)){var we=-1,ge=function $e(){for(;++we<be.length;)if(a.call(be,we))return $e.value=be[we],$e.done=!1,$e;return $e.value=void 0,$e.done=!0,$e};return ge.next=ge}}return{next:Ve}}function Ve(){return{value:void 0,done:!0}}return M.prototype=I,s(ie,"constructor",{value:I,configurable:!0}),s(I,"constructor",{value:M,configurable:!0}),M.displayName=f(I,l,"GeneratorFunction"),n.isGeneratorFunction=function(be){var Te=typeof be=="function"&&be.constructor;return!!Te&&(Te===M||(Te.displayName||Te.name)==="GeneratorFunction")},n.mark=function(be){return Object.setPrototypeOf?Object.setPrototypeOf(be,I):(be.__proto__=I,f(be,l,"GeneratorFunction")),be.prototype=Object.create(ie),be},n.awrap=function(be){return{__await:be}},oe(J.prototype),f(J.prototype,u,function(){return this}),n.AsyncIterator=J,n.async=function(be,Te,we,ge,$e){$e===void 0&&($e=Promise);var De=new J(d(be,Te,we,ge),$e);return n.isGeneratorFunction(Te)?De:De.next().then(function(G){return G.done?G.value:De.next()})},oe(ie),f(ie,l,"Generator"),f(ie,o,function(){return this}),f(ie,"toString",function(){return"[object Generator]"}),n.keys=function(be){var Te=Object(be),we=[];for(var ge in Te)we.push(ge);return we.reverse(),function $e(){for(;we.length;){var De=we.pop();if(De in Te)return $e.value=De,$e.done=!1,$e}return $e.done=!0,$e}},n.values=ae,Re.prototype={constructor:Re,reset:function(Te){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(ye),!Te)for(var we in this)we.charAt(0)==="t"&&a.call(this,we)&&!isNaN(+we.slice(1))&&(this[we]=void 0)},stop:function(){this.done=!0;var Te=this.tryEntries[0].completion;if(Te.type==="throw")throw Te.arg;return this.rval},dispatchException:function(Te){if(this.done)throw Te;var we=this;function ge(ut,je){return G.type="throw",G.arg=Te,we.next=ut,je&&(we.method="next",we.arg=void 0),!!je}for(var $e=this.tryEntries.length-1;$e>=0;--$e){var De=this.tryEntries[$e],G=De.completion;if(De.tryLoc==="root")return ge("end");if(De.tryLoc<=this.prev){var Qe=a.call(De,"catchLoc"),Et=a.call(De,"finallyLoc");if(Qe&&Et){if(this.prev<De.catchLoc)return ge(De.catchLoc,!0);if(this.prev<De.finallyLoc)return ge(De.finallyLoc)}else if(Qe){if(this.prev<De.catchLoc)return ge(De.catchLoc,!0)}else{if(!Et)throw new Error("try statement without catch or finally");if(this.prev<De.finallyLoc)return ge(De.finallyLoc)}}}},abrupt:function(Te,we){for(var ge=this.tryEntries.length-1;ge>=0;--ge){var $e=this.tryEntries[ge];if($e.tryLoc<=this.prev&&a.call($e,"finallyLoc")&&this.prev<$e.finallyLoc){var De=$e;break}}De&&(Te==="break"||Te==="continue")&&De.tryLoc<=we&&we<=De.finallyLoc&&(De=null);var G=De?De.completion:{};return G.type=Te,G.arg=we,De?(this.method="next",this.next=De.finallyLoc,h):this.complete(G)},complete:function(Te,we){if(Te.type==="throw")throw Te.arg;return Te.type==="break"||Te.type==="continue"?this.next=Te.arg:Te.type==="return"?(this.rval=this.arg=Te.arg,this.method="return",this.next="end"):Te.type==="normal"&&we&&(this.next=we),h},finish:function(Te){for(var we=this.tryEntries.length-1;we>=0;--we){var ge=this.tryEntries[we];if(ge.finallyLoc===Te)return this.complete(ge.completion,ge.afterLoc),ye(ge),h}},catch:function(Te){for(var we=this.tryEntries.length-1;we>=0;--we){var ge=this.tryEntries[we];if(ge.tryLoc===Te){var $e=ge.completion;if($e.type==="throw"){var De=$e.arg;ye(ge)}return De}}throw new Error("illegal catch attempt")},delegateYield:function(Te,we,ge){return this.delegate={iterator:ae(Te),resultName:we,nextLoc:ge},this.method==="next"&&(this.arg=void 0),h}},n}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(wC);var LD=wC.exports,Gc=LD(),Ru=Gc;try{regeneratorRuntime=Gc}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=Gc:Function("r","regeneratorRuntime = r")(Gc)}var DD=TypeError,jD=9007199254740991,TC=function(e){if(e>jD)throw DD("Maximum allowed index exceeded");return e},FD=St,UD=mt,BD=bu,qD=tr,GD=xr,zD=Ir,Ey=TC,ky=uo,WD=ov,VD=wu,HD=Gt,KD=no,CC=HD("isConcatSpreadable"),JD=KD>=51||!UD(function(){var e=[];return e[CC]=!1,e.concat()[0]!==e}),YD=function(e){if(!qD(e))return!1;var r=e[CC];return r!==void 0?!!r:BD(e)},XD=!JD||!VD("concat");FD({target:"Array",proto:!0,arity:1,forced:XD},{concat:function(r){var t=GD(this),n=WD(t,0),i=0,a,s,c,o,u;for(a=-1,c=arguments.length;a<c;a++)if(u=a===-1?t:arguments[a],YD(u))for(o=zD(u),Ey(i+o),s=0;s<o;s++,i++)s in u&&ky(n,i,u[s]);else Ey(i+1),ky(n,i++,u);return n.length=i,n}});var QD=sr,ZD=vC,ej=function(e,r,t,n){try{return n?r(QD(t)[0],t[1]):r(t)}catch(i){ZD(e,"throw",i)}},tj=qi,rj=qt,nj=xr,ij=ej,aj=wv,sj=Cl,oj=Ir,Ry=uo,uj=Nl,cj=ku,$y=Array,EC=function(r){var t=nj(r),n=sj(this),i=arguments.length,a=i>1?arguments[1]:void 0,s=a!==void 0;s&&(a=tj(a,i>2?arguments[2]:void 0));var c=cj(t),o=0,u,l,f,d,p,h;if(c&&!(this===$y&&aj(c)))for(d=uj(t,c),p=d.next,l=n?new this:[];!(f=rj(p,d)).done;o++)h=s?ij(d,a,[f.value,o],!0):f.value,Ry(l,o,h);else for(u=oj(t),l=n?new this(u):$y(u);u>o;o++)h=s?a(t[o],o):t[o],Ry(l,o,h);return l.length=o,l},lj=St,fj=EC,dj=Dl,pj=!dj(function(e){Array.from(e)});lj({target:"Array",stat:!0,forced:pj},{from:fj});var Tv=_t,hj=ui,vj=br,mj=oi,gj=Tv("".charAt),Oy=Tv("".charCodeAt),yj=Tv("".slice),Iy=function(e){return function(r,t){var n=vj(mj(r)),i=hj(t),a=n.length,s,c;return i<0||i>=a?e?"":void 0:(s=Oy(n,i),s<55296||s>56319||i+1===a||(c=Oy(n,i+1))<56320||c>57343?e?gj(n,i):s:e?yj(n,i,i+2):(s-55296<<10)+(c-56320)+65536)}},Cv={codeAt:Iy(!1),charAt:Iy(!0)},bj=mt,_j=!bj(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),Sj=rr,wj=Bt,Tj=xr,Cj=Sl,Ej=_j,Py=Cj("IE_PROTO"),Pp=Object,kj=Pp.prototype,Fl=Ej?Pp.getPrototypeOf:function(e){var r=Tj(e);if(Sj(r,Py))return r[Py];var t=r.constructor;return wj(t)&&r instanceof t?t.prototype:r instanceof Pp?kj:null},Rj=mt,$j=Bt,Oj=tr,Ay=Fl,Ij=Gr,Pj=Gt,Ap=Pj("iterator"),kC=!1,Xa,ud,cd;[].keys&&(cd=[].keys(),"next"in cd?(ud=Ay(Ay(cd)),ud!==Object.prototype&&(Xa=ud)):kC=!0);var Aj=!Oj(Xa)||Rj(function(){var e={};return Xa[Ap].call(e)!==e});Aj&&(Xa={});$j(Xa[Ap])||Ij(Xa,Ap,function(){return this});var RC={IteratorPrototype:Xa,BUGGY_SAFARI_ITERATORS:kC},Mj=RC.IteratorPrototype,xj=Sa,Nj=rs,Lj=Ui,Dj=Eu,jj=function(){return this},$C=function(e,r,t,n){var i=r+" Iterator";return e.prototype=xj(Mj,{next:Nj(+!n,t)}),Lj(e,i,!1),Dj[i]=jj,e},Fj=St,Uj=qt,OC=pu,Bj=Bt,qj=$C,My=Fl,xy=co,Gj=Ui,zj=ji,ld=Gr,Wj=Gt,Vj=Eu,IC=RC,Hj=OC.PROPER,Kj=OC.CONFIGURABLE,Ny=IC.IteratorPrototype,Qu=IC.BUGGY_SAFARI_ITERATORS,To=Wj("iterator"),Ly="keys",Co="values",Dy="entries",Jj=function(){return this},Ev=function(e,r,t,n,i,a,s){qj(t,r,n);var c=function(I){if(I===i&&d)return d;if(!Qu&&I in l)return l[I];switch(I){case Ly:return function(){return new t(this,I)};case Co:return function(){return new t(this,I)};case Dy:return function(){return new t(this,I)}}return function(){return new t(this)}},o=r+" Iterator",u=!1,l=e.prototype,f=l[To]||l["@@iterator"]||i&&l[i],d=!Qu&&f||c(i),p=r=="Array"&&l.entries||f,h,E,M;if(p&&(h=My(p.call(new e)),h!==Object.prototype&&h.next&&(My(h)!==Ny&&(xy?xy(h,Ny):Bj(h[To])||ld(h,To,Jj)),Gj(h,o,!0))),Hj&&i==Co&&f&&f.name!==Co&&(Kj?zj(l,"name",Co):(u=!0,d=function(){return Uj(f,this)})),i)if(E={values:c(Co),keys:a?d:c(Ly),entries:c(Dy)},s)for(M in E)(Qu||u||!(M in l))&&ld(l,M,E[M]);else Fj({target:r,proto:!0,forced:Qu||u},E);return l[To]!==d&&ld(l,To,d,{name:i}),Vj[r]=d,E},kv=function(e,r){return{value:e,done:r}},Yj=Cv.charAt,Xj=br,PC=kn,Qj=Ev,jy=kv,AC="String Iterator",Zj=PC.set,e2=PC.getterFor(AC);Qj(String,"String",function(e){Zj(this,{type:AC,string:Xj(e),index:0})},function(){var r=e2(this),t=r.string,n=r.index,i;return n>=t.length?jy(void 0,!0):(i=Yj(t,n),r.index+=i.length,jy(i,!1))});var MC={exports:{}};(function(e){(function(r,t){e.exports?e.exports=t():r.log=t()})(ze,function(){var r=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"];function a(E,M){var I=E[M];if(typeof I.bind=="function")return I.bind(E);try{return Function.prototype.bind.call(I,E)}catch{return function(){return Function.prototype.apply.apply(I,[E,arguments])}}}function s(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(E){return E==="debug"&&(E="log"),typeof console===t?!1:E==="trace"&&n?s:console[E]!==void 0?a(console,E):console.log!==void 0?a(console,"log"):r}function o(E,M){for(var I=0;I<i.length;I++){var x=i[I];this[x]=I<E?r:this.methodFactory(x,E,M)}this.log=this.debug}function u(E,M,I){return function(){typeof console!==t&&(o.call(this,M,I),this[E].apply(this,arguments))}}function l(E,M,I){return c(E)||u.apply(this,arguments)}function f(E,M,I){var x=this,j;M=M??"WARN";var z="loglevel";typeof E=="string"?z+=":"+E:typeof E=="symbol"&&(z=void 0);function ie(Y){var Z=(i[Y]||"silent").toUpperCase();if(!(typeof window===t||!z)){try{window.localStorage[z]=Z;return}catch{}try{window.document.cookie=encodeURIComponent(z)+"="+Z+";"}catch{}}}function oe(){var Y;if(!(typeof window===t||!z)){try{Y=window.localStorage[z]}catch{}if(typeof Y===t)try{var Z=window.document.cookie,ye=Z.indexOf(encodeURIComponent(z)+"=");ye!==-1&&(Y=/^([^;]+)/.exec(Z.slice(ye))[1])}catch{}return x.levels[Y]===void 0&&(Y=void 0),Y}}function J(){if(!(typeof window===t||!z)){try{window.localStorage.removeItem(z);return}catch{}try{window.document.cookie=encodeURIComponent(z)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}x.name=E,x.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},x.methodFactory=I||l,x.getLevel=function(){return j},x.setLevel=function(Y,Z){if(typeof Y=="string"&&x.levels[Y.toUpperCase()]!==void 0&&(Y=x.levels[Y.toUpperCase()]),typeof Y=="number"&&Y>=0&&Y<=x.levels.SILENT){if(j=Y,Z!==!1&&ie(Y),o.call(x,Y,E),typeof console===t&&Y<x.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+Y},x.setDefaultLevel=function(Y){M=Y,oe()||x.setLevel(Y,!1)},x.resetLevel=function(){x.setLevel(M,!1),J()},x.enableAll=function(Y){x.setLevel(x.levels.TRACE,Y)},x.disableAll=function(Y){x.setLevel(x.levels.SILENT,Y)};var L=oe();L==null&&(L=M),x.setLevel(L,!1)}var d=new f,p={};d.getLogger=function(M){if(typeof M!="symbol"&&typeof M!="string"||M==="")throw new TypeError("You must supply a name when creating a logger.");var I=p[M];return I||(I=p[M]=new f(M,d.getLevel(),d.methodFactory)),I};var h=typeof window!==t?window.log:void 0;return d.noConflict=function(){return typeof window!==t&&window.log===d&&(window.log=h),d},d.getLoggers=function(){return p},d.default=d,d})})(MC);var pr=MC.exports;const Ja="\\d+(?:[\\.,]\\d+)?",t2=`(${Ja}W)`,r2=`(${Ja}Y)?(${Ja}M)?(${Ja}D)?`,n2=`T(${Ja}H)?(${Ja}M)?(${Ja}S)?`,i2=`P(?:${t2}|${r2}(?:${n2})?)`,a2=["weeks","years","months","days","hours","minutes","seconds"],Rv=new RegExp(i2),xC=e=>e.match(Rv).slice(1).reduce((r,t,n)=>(r[a2[n]]=parseFloat(t)||0,r),{}),$v=(e,r)=>{const t=r?r.getTime():Date.now(),n=new Date(t);return n.setFullYear(n.getFullYear()+e.years),n.setMonth(n.getMonth()+e.months),n.setDate(n.getDate()+e.days),n.setHours(n.getHours()+e.hours),n.setMinutes(n.getMinutes()+e.minutes),n.setMilliseconds(n.getMilliseconds()+e.seconds*1e3),n.setDate(n.getDate()+e.weeks*7),n},NC=(e,r)=>{const t=r?r.getTime():Date.now(),n=new Date(t);return($v(e,n).getTime()-n.getTime())/1e3},s2={end:$v,toSeconds:NC,pattern:Rv,parse:xC},o2=Object.freeze(Object.defineProperty({__proto__:null,default:s2,end:$v,parse:xC,pattern:Rv,toSeconds:NC},Symbol.toStringTag,{value:"Module"})),u2=kw(o2);var c2=Gt,l2=Sa,f2=qr.f,Mp=c2("unscopables"),xp=Array.prototype;xp[Mp]==null&&f2(xp,Mp,{configurable:!0,value:l2(null)});var Ov=function(e){xp[Mp][e]=!0},d2=ln,Iv=Ov,Fy=Eu,LC=kn,p2=qr.f,h2=Ev,Zu=kv,v2=Yt,DC="Array Iterator",m2=LC.set,g2=LC.getterFor(DC),jC=h2(Array,"Array",function(e,r){m2(this,{type:DC,target:d2(e),index:0,kind:r})},function(){var e=g2(this),r=e.target,t=e.kind,n=e.index++;return!r||n>=r.length?(e.target=void 0,Zu(void 0,!0)):t=="keys"?Zu(n,!1):t=="values"?Zu(r[n],!1):Zu([n,r[n]],!1)},"values"),Uy=Fy.Arguments=Fy.Array;Iv("keys");Iv("values");Iv("entries");if(v2&&Uy.name!=="values")try{p2(Uy,"name",{value:"values"})}catch{}var By=Rt,FC=bC,y2=_C,jo=jC,fd=ji,UC=Gt,dd=UC("iterator"),qy=UC("toStringTag"),pd=jo.values,BC=function(e,r){if(e){if(e[dd]!==pd)try{fd(e,dd,pd)}catch{e[dd]=pd}if(e[qy]||fd(e,qy,r),FC[r]){for(var t in jo)if(e[t]!==jo[t])try{fd(e,t,jo[t])}catch{e[t]=jo[t]}}}};for(var hd in FC)BC(By[hd]&&By[hd].prototype,hd);BC(y2,"DOMTokenList");var b2=Bt,_2=tr,Gy=co,Pv=function(e,r,t){var n,i;return Gy&&b2(n=r.constructor)&&n!==t&&_2(i=n.prototype)&&i!==t.prototype&&Gy(e,i),e},S2=_t,w2=S2(1 .valueOf),T2=`
|
|
9
|
+
\v\f\r \u2028\u2029\uFEFF`,C2=_t,E2=oi,k2=br,Np=T2,zy=C2("".replace),R2=RegExp("^["+Np+"]+"),$2=RegExp("(^|[^"+Np+"])["+Np+"]+$"),vd=function(e){return function(r){var t=k2(E2(r));return e&1&&(t=zy(t,R2,"")),e&2&&(t=zy(t,$2,"$1")),t}},O2={start:vd(1),end:vd(2),trim:vd(3)},I2=St,qC=Fw,P2=Yt,GC=Rt,zC=pT,WC=_t,A2=Tl,Wy=rr,M2=Pv,x2=Di,N2=ao,VC=Jh,L2=mt,D2=ba.f,j2=ii.f,F2=qr.f,U2=w2,B2=O2.trim,Ul="Number",Ds=GC[Ul];zC[Ul];var Av=Ds.prototype,q2=GC.TypeError,G2=WC("".slice),ec=WC("".charCodeAt),z2=function(e){var r=VC(e,"number");return typeof r=="bigint"?r:W2(r)},W2=function(e){var r=VC(e,"number"),t,n,i,a,s,c,o,u;if(N2(r))throw q2("Cannot convert a Symbol value to a number");if(typeof r=="string"&&r.length>2){if(r=B2(r),t=ec(r,0),t===43||t===45){if(n=ec(r,2),n===88||n===120)return NaN}else if(t===48){switch(ec(r,1)){case 66:case 98:i=2,a=49;break;case 79:case 111:i=8,a=55;break;default:return+r}for(s=G2(r,2),c=s.length,o=0;o<c;o++)if(u=ec(s,o),u<48||u>a)return NaN;return parseInt(s,i)}}return+r},Mv=A2(Ul,!Ds(" 0o1")||!Ds("0b1")||Ds("+0x1")),V2=function(e){return x2(Av,e)&&L2(function(){U2(e)})},Bl=function(r){var t=arguments.length<1?0:Ds(z2(r));return V2(this)?M2(Object(t),this,Bl):t};Bl.prototype=Av;Mv&&!qC&&(Av.constructor=Bl);I2({global:!0,constructor:!0,wrap:!0,forced:Mv},{Number:Bl});var H2=function(e,r){for(var t=P2?D2(r):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),n=0,i;t.length>n;n++)Wy(r,i=t[n])&&!Wy(e,i)&&F2(e,i,j2(r,i))};(Mv||qC)&&H2(zC[Ul],Ds);var K2=sr,HC=function(){var e=K2(this),r="";return e.hasIndices&&(r+="d"),e.global&&(r+="g"),e.ignoreCase&&(r+="i"),e.multiline&&(r+="m"),e.dotAll&&(r+="s"),e.unicode&&(r+="u"),e.unicodeSets&&(r+="v"),e.sticky&&(r+="y"),r},xv=mt,J2=Rt,Nv=J2.RegExp,Lv=xv(function(){var e=Nv("a","y");return e.lastIndex=2,e.exec("abcd")!=null}),Y2=Lv||xv(function(){return!Nv("a","y").sticky}),X2=Lv||xv(function(){var e=Nv("^r","gy");return e.lastIndex=2,e.exec("str")!=null}),KC={BROKEN_CARET:X2,MISSED_STICKY:Y2,UNSUPPORTED_Y:Lv},Q2=mt,Z2=Rt,eF=Z2.RegExp,tF=Q2(function(){var e=eF(".","s");return!(e.dotAll&&e.exec(`
|
|
10
|
+
`)&&e.flags==="s")}),rF=mt,nF=Rt,iF=nF.RegExp,aF=rF(function(){var e=iF("(?<a>b)","g");return e.exec("b").groups.a!=="b"||"b".replace(e,"$<a>c")!=="bc"}),Ms=qt,ql=_t,sF=br,oF=HC,uF=KC,cF=so,lF=Sa,fF=kn.get,dF=tF,pF=aF,hF=cF("native-string-replace",String.prototype.replace),rl=RegExp.prototype.exec,Lp=rl,vF=ql("".charAt),mF=ql("".indexOf),gF=ql("".replace),md=ql("".slice),Dp=function(){var e=/a/,r=/b*/g;return Ms(rl,e,"a"),Ms(rl,r,"a"),e.lastIndex!==0||r.lastIndex!==0}(),JC=uF.BROKEN_CARET,jp=/()??/.exec("")[1]!==void 0,yF=Dp||jp||JC||dF||pF;yF&&(Lp=function(r){var t=this,n=fF(t),i=sF(r),a=n.raw,s,c,o,u,l,f,d;if(a)return a.lastIndex=t.lastIndex,s=Ms(Lp,a,i),t.lastIndex=a.lastIndex,s;var p=n.groups,h=JC&&t.sticky,E=Ms(oF,t),M=t.source,I=0,x=i;if(h&&(E=gF(E,"y",""),mF(E,"g")===-1&&(E+="g"),x=md(i,t.lastIndex),t.lastIndex>0&&(!t.multiline||t.multiline&&vF(i,t.lastIndex-1)!==`
|
|
11
|
+
`)&&(M="(?: "+M+")",x=" "+x,I++),c=new RegExp("^(?:"+M+")",E)),jp&&(c=new RegExp("^"+M+"$(?!\\s)",E)),Dp&&(o=t.lastIndex),u=Ms(rl,h?c:t,x),h?u?(u.input=md(u.input,I),u[0]=md(u[0],I),u.index=t.lastIndex,t.lastIndex+=u[0].length):t.lastIndex=0:Dp&&u&&(t.lastIndex=t.global?u.index+u[0].length:o),jp&&u&&u.length>1&&Ms(hF,u[0],c,function(){for(l=1;l<arguments.length-2;l++)arguments[l]===void 0&&(u[l]=void 0)}),u&&p)for(u.groups=f=lF(null),l=0;l<p.length;l++)d=p[l],f[d[0]]=u[d[1]];return u});var Gl=Lp,bF=St,Vy=Gl;bF({target:"RegExp",proto:!0,forced:/./.exec!==Vy},{exec:Vy});var Hy=El,Ky=Gr,_F=Gl,Jy=mt,YC=Gt,SF=ji,wF=YC("species"),gd=RegExp.prototype,zl=function(e,r,t,n){var i=YC(e),a=!Jy(function(){var u={};return u[i]=function(){return 7},""[e](u)!=7}),s=a&&!Jy(function(){var u=!1,l=/a/;return e==="split"&&(l={},l.constructor={},l.constructor[wF]=function(){return l},l.flags="",l[i]=/./[i]),l.exec=function(){return u=!0,null},l[i](""),!u});if(!a||!s||t){var c=Hy(/./[i]),o=r(i,""[e],function(u,l,f,d,p){var h=Hy(u),E=l.exec;return E===_F||E===gd.exec?a&&!p?{done:!0,value:c(l,f,d)}:{done:!0,value:h(f,l,d)}:{done:!1}});Ky(String.prototype,e,o[0]),Ky(gd,i,o[1])}n&&SF(gd[i],"sham",!0)},TF=Cv.charAt,Dv=function(e,r,t){return r+(t?TF(e,r).length:1)},jv=_t,CF=xr,EF=Math.floor,yd=jv("".charAt),kF=jv("".replace),bd=jv("".slice),RF=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,$F=/\$([$&'`]|\d{1,2})/g,OF=function(e,r,t,n,i,a){var s=t+e.length,c=n.length,o=$F;return i!==void 0&&(i=CF(i),o=RF),kF(a,o,function(u,l){var f;switch(yd(l,0)){case"$":return"$";case"&":return e;case"`":return bd(r,0,t);case"'":return bd(r,s);case"<":f=i[bd(l,1,-1)];break;default:var d=+l;if(d===0)return u;if(d>c){var p=EF(d/10);return p===0?u:p<=c?n[p-1]===void 0?yd(l,1):n[p-1]+yd(l,1):u}f=n[d-1]}return f===void 0?"":f})},Yy=qt,IF=sr,PF=Bt,AF=ai,MF=Gl,xF=TypeError,Wl=function(e,r){var t=e.exec;if(PF(t)){var n=Yy(t,e,r);return n!==null&&IF(n),n}if(AF(e)==="RegExp")return Yy(MF,e,r);throw xF("RegExp#exec called on incompatible receiver")},NF=_a,Xy=qt,Vl=_t,LF=zl,DF=mt,jF=sr,FF=Bt,UF=si,BF=ui,qF=Fi,ys=br,GF=oi,zF=Dv,WF=as,VF=OF,HF=Wl,KF=Gt,Fp=KF("replace"),JF=Math.max,YF=Math.min,XF=Vl([].concat),_d=Vl([].push),Qy=Vl("".indexOf),Zy=Vl("".slice),QF=function(e){return e===void 0?e:String(e)},ZF=function(){return"a".replace(/./,"$0")==="$0"}(),eb=function(){return/./[Fp]?/./[Fp]("a","$0")==="":!1}(),eU=!DF(function(){var e=/./;return e.exec=function(){var r=[];return r.groups={a:"7"},r},"".replace(e,"$<a>")!=="7"});LF("replace",function(e,r,t){var n=eb?"$":"$0";return[function(a,s){var c=GF(this),o=UF(a)?void 0:WF(a,Fp);return o?Xy(o,a,c,s):Xy(r,ys(c),a,s)},function(i,a){var s=jF(this),c=ys(i);if(typeof a=="string"&&Qy(a,n)===-1&&Qy(a,"$<")===-1){var o=t(r,s,c,a);if(o.done)return o.value}var u=FF(a);u||(a=ys(a));var l=s.global;if(l){var f=s.unicode;s.lastIndex=0}for(var d=[];;){var p=HF(s,c);if(p===null||(_d(d,p),!l))break;var h=ys(p[0]);h===""&&(s.lastIndex=zF(c,qF(s.lastIndex),f))}for(var E="",M=0,I=0;I<d.length;I++){p=d[I];for(var x=ys(p[0]),j=JF(YF(BF(p.index),c.length),0),z=[],ie=1;ie<p.length;ie++)_d(z,QF(p[ie]));var oe=p.groups;if(u){var J=XF([x],z,j,c);oe!==void 0&&_d(J,oe);var L=ys(NF(a,void 0,J))}else L=VF(x,c,j,z,oe,a);j>=M&&(E+=Zy(c,M,j)+L,M=j+x.length)}return E+Zy(c,M)}]},!eU||!ZF||eb);var tU=St,rU=_t,nU=lu,iU=ln,aU=jl,sU=rU([].join),oU=nU!=Object,uU=oU||!aU("join",",");tU({target:"Array",proto:!0,forced:uU},{join:function(r){return sU(iU(this),r===void 0?",":r)}});var Tr={},cU=St,tb=bu,lU=Cl,fU=tr,rb=ss,dU=Ir,pU=ln,hU=uo,vU=Gt,mU=wu,gU=oo,yU=mU("slice"),bU=vU("species"),Sd=Array,_U=Math.max;cU({target:"Array",proto:!0,forced:!yU},{slice:function(r,t){var n=pU(this),i=dU(n),a=rb(r,i),s=rb(t===void 0?i:t,i),c,o,u;if(tb(n)&&(c=n.constructor,lU(c)&&(c===Sd||tb(c.prototype))?c=void 0:fU(c)&&(c=c[bU],c===null&&(c=void 0)),c===Sd||c===void 0))return gU(n,a,s);for(o=new(c===void 0?Sd:c)(_U(s-a,0)),u=0;a<s;a++,u++)a in n&&hU(o,u,n[a]);return o.length=u,o}});var SU=St,nb=qt,wU=Bt,ib=sr,TU=br,CU=function(){var e=!1,r=/[ac]/;return r.exec=function(){return e=!0,/./.exec.apply(this,arguments)},r.test("abc")===!0&&e}(),EU=/./.test;SU({target:"RegExp",proto:!0,forced:!CU},{test:function(e){var r=ib(this),t=TU(e),n=r.exec;if(!wU(n))return nb(EU,r,t);var i=nb(n,r,t);return i===null?!1:(ib(i),!0)}});var kU=St,RU=Yt,$U=Rt,tc=_t,OU=rr,IU=Bt,PU=Di,AU=br,MU=ci,xU=Jw,Ci=$U.Symbol,ja=Ci&&Ci.prototype;if(RU&&IU(Ci)&&(!("description"in ja)||Ci().description!==void 0)){var ab={},rc=function(){var r=arguments.length<1||arguments[0]===void 0?void 0:AU(arguments[0]),t=PU(ja,this)?new Ci(r):r===void 0?Ci():Ci(r);return r===""&&(ab[t]=!0),t};xU(rc,Ci),rc.prototype=ja,ja.constructor=rc;var NU=String(Ci("test"))=="Symbol(test)",LU=tc(ja.valueOf),DU=tc(ja.toString),jU=/^Symbol\((.*)\)[^)]+$/,FU=tc("".replace),UU=tc("".slice);MU(ja,"description",{configurable:!0,get:function(){var r=LU(this);if(OU(ab,r))return"";var t=DU(r),n=NU?UU(t,7,-1):FU(t,jU,"$1");return n===""?void 0:n}}),kU({global:!0,constructor:!0,forced:!0},{Symbol:rc})}var BU=hT;BU("iterator");var qU=Yt,GU=pu.EXISTS,XC=_t,zU=ci,QC=Function.prototype,WU=XC(QC.toString),ZC=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,VU=XC(ZC.exec),HU="name";qU&&!GU&&zU(QC,HU,{configurable:!0,get:function(){try{return VU(ZC,WU(this))[1]}catch{return""}}});var e0={exports:{}},t0={exports:{}};(function(e){function r(t){if(Array.isArray(t))return t}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(t0);var KU=t0.exports,r0={exports:{}};(function(e){function r(t,n){var i=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(i!=null){var a,s,c,o,u=[],l=!0,f=!1;try{if(c=(i=i.call(t)).next,n===0){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=c.call(i)).done)&&(u.push(a.value),u.length!==n);l=!0);}catch(d){f=!0,s=d}finally{try{if(!l&&i.return!=null&&(o=i.return(),Object(o)!==o))return}finally{if(f)throw s}}return u}}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(r0);var JU=r0.exports,n0={exports:{}},i0={exports:{}};(function(e){function r(t,n){(n==null||n>t.length)&&(n=t.length);for(var i=0,a=new Array(n);i<n;i++)a[i]=t[i];return a}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(i0);var a0=i0.exports;(function(e){var r=a0;function t(n,i){if(n){if(typeof n=="string")return r(n,i);var a=Object.prototype.toString.call(n).slice(8,-1);if(a==="Object"&&n.constructor&&(a=n.constructor.name),a==="Map"||a==="Set")return Array.from(n);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return r(n,i)}}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(n0);var s0=n0.exports,o0={exports:{}};(function(e){function r(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
12
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(o0);var YU=o0.exports;(function(e){var r=KU,t=JU,n=s0,i=YU;function a(s,c){return r(s)||t(s,c)||n(s,c)||i()}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports})(e0);var fo=e0.exports,u0={exports:{}},c0={exports:{}};(function(e){var r=a0;function t(n){if(Array.isArray(n))return r(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(c0);var XU=c0.exports,l0={exports:{}};(function(e){function r(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(l0);var QU=l0.exports,f0={exports:{}};(function(e){function r(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
13
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(f0);var ZU=f0.exports;(function(e){var r=XU,t=QU,n=s0,i=ZU;function a(s){return r(s)||t(s)||n(s)||i()}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports})(u0);var po=u0.exports,eB=St,tB=wl.includes,rB=mt,nB=Ov,iB=rB(function(){return!Array(1).includes()});eB({target:"Array",proto:!0,forced:iB},{includes:function(r){return tB(this,r,arguments.length>1?arguments[1]:void 0)}});nB("includes");var aB=tr,sB=Math.floor,d0=Number.isInteger||function(r){return!aB(r)&&isFinite(r)&&sB(r)===r},oB=St,uB=d0;oB({target:"Number",stat:!0},{isInteger:uB});var cB=Yt,p0=_t,lB=gu,fB=ln,dB=cu.f,pB=p0(dB),hB=p0([].push),sb=function(e){return function(r){for(var t=fB(r),n=lB(t),i=n.length,a=0,s=[],c;i>a;)c=n[a++],(!cB||pB(t,c))&&hB(s,e?[c,t[c]]:t[c]);return s}},vB={entries:sb(!0),values:sb(!1)},mB=St,gB=vB.entries;mB({target:"Object",stat:!0},{entries:function(r){return gB(r)}});/*
|
|
14
|
+
@license
|
|
15
|
+
Copyright (c) 2021 Twilio Inc.
|
|
16
|
+
|
|
17
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
*/Object.defineProperty(Tr,"__esModule",{value:!0});var yB=Rn,bB=fo,_B=po,SB=wa,wB=di,TB=li,CB=fi,EB=$n;function Ta(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var js=Ta(yB),Mi=Ta(bB),wd=Ta(_B),kB=Ta(SB),RB=Ta(wB),$B=Ta(TB),OB=Ta(CB),ob=Ta(EB),Gi=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return{checks:t}};function IB(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=PB(e))||r&&e&&typeof e.length=="number"){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
25
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,c;return{s:function(){t=t.call(e)},n:function(){var u=t.next();return a=u.done,u},e:function(u){s=!0,c=u},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw c}}}}function PB(e,r){if(e){if(typeof e=="string")return ub(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return ub(e,r)}}function ub(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var h0=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return Gi(function(i){var a=!1,s=[],c=IB(t),o;try{for(c.s();!(o=c.n()).done;){var u=o.value;if(typeof u=="string"){a=a||js.default(i)===u,s.push("of type ".concat(u));continue}a=a||i instanceof u,s.push("an instance of ".concat(u.name))}}catch(l){c.e(l)}finally{c.f()}return[a,s]})};function AB(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=MB(e))||r&&e&&typeof e.length=="number"){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
26
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,c;return{s:function(){t=t.call(e)},n:function(){var u=t.next();return a=u.done,u},e:function(u){s=!0,c=u},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw c}}}}function MB(e,r){if(e){if(typeof e=="string")return cb(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return cb(e,r)}}function cb(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var xB=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return Gi(function(i){var a=!1,s=[],c=AB(t),o;try{for(c.s();!(o=c.n()).done;){var u=o.value;a=a||i===u,s.push(typeof u=="string"?'"'.concat(u,'"'):"".concat(u))}}catch(l){c.e(l)}finally{c.f()}return[a,s]})};function NB(e){var r=LB();return function(){var n=ob.default(e),i;if(r){var a=ob.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return OB.default(this,i)}}function LB(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ru(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=DB(e))||r&&e&&typeof e.length=="number"){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
27
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,c;return{s:function(){t=t.call(e)},n:function(){var u=t.next();return a=u.done,u},e:function(u){s=!0,c=u},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw c}}}}function DB(e,r){if(e){if(typeof e=="string")return lb(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return lb(e,r)}}function lb(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var Hl=function(r,t){if(t.length>r.length)throw new Error("Expected at most ".concat(r.length," argument(s), but got ").concat(t.length));for(;t.length<r.length;)t.push(void 0);var n=ru(t.entries()),i;try{for(n.s();!(i=n.n()).done;){var a=Mi.default(i.value,2),s=a[0],c=a[1],o=Jl(r[s],c),u=Mi.default(o,4),l=u[0],f=u[1],d=u[2],p=u[3];if(!l){var h=s+1;throw new Error("Argument ".concat(h," is expected to be ").concat(d).concat(p," but got ").concat(f))}}}catch(E){n.e(E)}finally{n.f()}},v0=function(r){var t,n,i=["undefined","boolean","number","bigint","string"];if(i.includes(js.default(r))&&(n=typeof r=="string"?'"'.concat(r,'"'):"".concat(r)),js.default(r)==="object"&&(r==null||(t=r.constructor)===null||t===void 0?void 0:t.name)!=="Object"){var a;n=r===null?"null":"instance of ".concat(r==null||(a=r.constructor)===null||a===void 0?void 0:a.name)}return n||(n=js.default(r)),n},jB=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=Fv(t);return function(a){return function(s){$B.default(o,s);var c=NB(o);function o(){RB.default(this,o);for(var u=arguments.length,l=new Array(u),f=0;f<u;f++)l[f]=arguments[f];return Hl(i,l),c.call.apply(c,[this].concat(l))}return kB.default(o)}(a)}},FB=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=Fv(t);return function(a,s,c){if(typeof c.value!="function")throw new Error("The validateTypes decorator can only be applied to methods");var o=c.value;c.value=function(){for(var u=arguments.length,l=new Array(u),f=0;f<u;f++)l[f]=arguments[f];return Hl(i,l),o.apply(this,l)}}},UB=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=Fv(t);return function(a,s,c){if(typeof c.value!="function")throw new Error("The validateTypesAsync decorator can only be applied to methods");var o=c.value;c.value=function(){for(var u=arguments.length,l=new Array(u),f=0;f<u;f++)l[f]=arguments[f];try{Hl(i,l)}catch(d){return Promise.reject(d)}return o.apply(this,l)}}},Fv=function(r){var t=[],n=ru(r),i;try{for(n.s();!(i=n.n()).done;){var a=i.value;t.push(Kl(a))}}catch(s){n.e(s)}finally{n.f()}return t},Kl=function(r){var t=[],n=Array.isArray(r)?r:[r],i=ru(n),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;if(typeof s=="string"||typeof s=="function"){t.push(h0(s));continue}t.push(s)}}catch(c){i.e(c)}finally{i.f()}return t},Jl=function(r,t){var n=[],i,a=!1,s=ru(r),c;try{for(s.s();!(c=s.n()).done;){var o=c.value,u=ru(o.checks),l;try{for(u.s();!(l=u.n()).done;){var f=l.value,d=f(t),p=Mi.default(d,3),h=p[0],E=p[1],M=p[2];a=a||h,!i&&M&&(i=M),E&&(n=typeof E=="string"?[].concat(wd.default(n),[E]):[].concat(wd.default(n),wd.default(E)))}}catch(z){u.e(z)}finally{u.f()}}}catch(z){s.e(z)}finally{s.f()}if(a)return[!0];var I=i||v0(t),x=n.length-1,j=x>0?"".concat(n.slice(0,x).join(", ")," or ").concat(n[x]):n.join(", ");return[!1,I,j,x>1?";":","]};function BB(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=qB(e))||r&&e&&typeof e.length=="number"){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
28
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,c;return{s:function(){t=t.call(e)},n:function(){var u=t.next();return a=u.done,u},e:function(u){s=!0,c=u},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw c}}}}function qB(e,r){if(e){if(typeof e=="string")return fb(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return fb(e,r)}}function fb(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var GB=function(r,t){return Gi(function(n){if(!Array.isArray(n)||n.length<1)return[!1,"a non-empty array of ".concat(r)];var i=BB(n.entries()),a;try{for(i.s();!(a=i.n()).done;){var s=Mi.default(a.value,2),c=s[0],o=s[1],u=Jl(Kl(t),o),l=Mi.default(u,3),f=l[0],d=l[1],p=l[2];if(!f)return[!1,"a valid non-empty array of ".concat(r," (index ").concat(c," should be ").concat(p,")"),"malformed array of ".concat(r," (index ").concat(c," is ").concat(d,")")]}}catch(h){i.e(h)}finally{i.f()}return[!0]})},zB=Gi(function(e){return[typeof e=="string"&&e.length>0,"a non-empty string"]}),WB=Gi(function(e){return[typeof e=="number"&&Number.isInteger(e)&&e>=0,"a non-negative integer"]}),VB=Gi(function(e){return[js.default(e)==="object"&&e!==null&&!Array.isArray(e),"a pure object (non-null and non-array)"]}),HB=function(r,t){return Gi(function(n){if(js.default(n)!=="object"||n===null||Array.isArray(n))return[!1,"valid ".concat(r," (should be a pure object)")];for(var i=0,a=Object.entries(t);i<a.length;i++){var s=Mi.default(a[i],2),c=s[0],o=s[1],u=Jl(Kl(o),n[c]),l=Mi.default(u,3),f=l[0],d=l[1],p=l[2];if(!f)return[!1,"valid ".concat(r,' (key "').concat(c,'" should be ').concat(p,")"),"malformed ".concat(r,' (key "').concat(c,'" is ').concat(d,")")]}return[!0]})};function KB(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=JB(e))||r&&e&&typeof e.length=="number"){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
29
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,c;return{s:function(){t=t.call(e)},n:function(){var u=t.next();return a=u.done,u},e:function(u){s=!0,c=u},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw c}}}}function JB(e,r){if(e){if(typeof e=="string")return db(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return db(e,r)}}function db(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var YB=function(r,t){return Gi(function(n){if(!Array.isArray(n))return[!1,"an array of ".concat(r)];var i=KB(n.entries()),a;try{for(i.s();!(a=i.n()).done;){var s=Mi.default(a.value,2),c=s[0],o=s[1],u=Jl(Kl(t),o),l=Mi.default(u,3),f=l[0],d=l[1],p=l[2];if(!f)return[!1,"a valid array of ".concat(r," (index ").concat(c," should be ").concat(p,")"),"malformed array of ".concat(r," (index ").concat(c," is ").concat(d,")")]}}catch(h){i.e(h)}finally{i.f()}return[!0]})};Tr.array=YB;Tr.custom=Gi;Tr.literal=xB;Tr.nonEmptyArray=GB;Tr.nonEmptyString=zB;Tr.nonNegativeInteger=WB;Tr.objectSchema=HB;Tr.pureObject=VB;Tr.runtimeTypeValidation=Hl;Tr.stringifyReceivedType=v0;Tr.type=h0;Tr.validateConstructorTypes=jB;Tr.validateTypes=FB;Tr.validateTypesAsync=UB;var Uv={},m0={exports:{}},g0={exports:{}};(function(e){var r=$n;function t(n,i){for(;!Object.prototype.hasOwnProperty.call(n,i)&&(n=r(n),n!==null););return n}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(g0);var XB=g0.exports;(function(e){var r=XB;function t(){return typeof Reflect<"u"&&Reflect.get?(e.exports=t=Reflect.get.bind(),e.exports.__esModule=!0,e.exports.default=e.exports):(e.exports=t=function(i,a,s){var c=r(i,a);if(c){var o=Object.getOwnPropertyDescriptor(c,a);return o.get?o.get.call(arguments.length<3?i:s):o.value}},e.exports.__esModule=!0,e.exports.default=e.exports),t.apply(this,arguments)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(m0);var Bv=m0.exports;/*
|
|
30
|
+
@license
|
|
31
|
+
Copyright (c) 2021 Twilio Inc.
|
|
32
|
+
|
|
33
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
34
|
+
|
|
35
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
36
|
+
|
|
37
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
38
|
+
|
|
39
|
+
*/Object.defineProperty(Uv,"__esModule",{value:!0});var QB=po,ZB=di,e3=wa,t3=os,r3=Bv,n3=li,i3=fi,a3=$n,s3=us;function zi(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var pb=zi(QB),o3=zi(ZB),u3=zi(e3),c3=zi(t3),Fa=zi(r3),l3=zi(n3),f3=zi(i3),Ei=zi(a3),d3=zi(s3),p3;function pa(){}pa.prototype=Object.create(null);function Vt(){Vt.init.call(this)}Vt.EventEmitter=Vt;Vt.usingDomains=!1;Vt.prototype.domain=void 0;Vt.prototype._events=void 0;Vt.prototype._maxListeners=void 0;Vt.defaultMaxListeners=10;Vt.init=function(){this.domain=null,Vt.usingDomains&&p3.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new pa,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Vt.prototype.setMaxListeners=function(r){if(typeof r!="number"||r<0||isNaN(r))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=r,this};function y0(e){return e._maxListeners===void 0?Vt.defaultMaxListeners:e._maxListeners}Vt.prototype.getMaxListeners=function(){return y0(this)};function h3(e,r,t){if(r)e.call(t);else for(var n=e.length,i=$u(e,n),a=0;a<n;++a)i[a].call(t)}function v3(e,r,t,n){if(r)e.call(t,n);else for(var i=e.length,a=$u(e,i),s=0;s<i;++s)a[s].call(t,n)}function m3(e,r,t,n,i){if(r)e.call(t,n,i);else for(var a=e.length,s=$u(e,a),c=0;c<a;++c)s[c].call(t,n,i)}function g3(e,r,t,n,i,a){if(r)e.call(t,n,i,a);else for(var s=e.length,c=$u(e,s),o=0;o<s;++o)c[o].call(t,n,i,a)}function y3(e,r,t,n){if(r)e.apply(t,n);else for(var i=e.length,a=$u(e,i),s=0;s<i;++s)a[s].apply(t,n)}Vt.prototype.emit=function(r){var t,n,i,a,s,c,o,u=r==="error";if(c=this._events,c)u=u&&c.error==null;else if(!u)return!1;if(o=this.domain,u){if(t=arguments[1],o)t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=o,t.domainThrown=!1,o.emit("error",t);else{if(t instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}return!1}if(n=c[r],!n)return!1;var f=typeof n=="function";switch(i=arguments.length,i){case 1:h3(n,f,this);break;case 2:v3(n,f,this,arguments[1]);break;case 3:m3(n,f,this,arguments[1],arguments[2]);break;case 4:g3(n,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(a=new Array(i-1),s=1;s<i;s++)a[s-1]=arguments[s];y3(n,f,this,a)}return!0};function b0(e,r,t,n){var i,a,s;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(a=e._events,a?(a.newListener&&(e.emit("newListener",r,t.listener?t.listener:t),a=e._events),s=a[r]):(a=e._events=new pa,e._eventsCount=0),!s)s=a[r]=t,++e._eventsCount;else if(typeof s=="function"?s=a[r]=n?[t,s]:[s,t]:n?s.unshift(t):s.push(t),!s.warned&&(i=y0(e),i&&i>0&&s.length>i)){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+r+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=r,c.count=s.length,b3(c)}return e}function b3(e){typeof console.warn=="function"?console.warn(e):console.log(e)}Vt.prototype.addListener=function(r,t){return b0(this,r,t,!1)};Vt.prototype.on=Vt.prototype.addListener;Vt.prototype.prependListener=function(r,t){return b0(this,r,t,!0)};function _0(e,r,t){var n=!1;function i(){e.removeListener(r,i),n||(n=!0,t.apply(e,arguments))}return i.listener=t,i}Vt.prototype.once=function(r,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.on(r,_0(this,r,t)),this};Vt.prototype.prependOnceListener=function(r,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(r,_0(this,r,t)),this};Vt.prototype.removeListener=function(r,t){var n,i,a,s,c;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[r],!n)return this;if(n===t||n.listener&&n.listener===t)--this._eventsCount===0?this._events=new pa:(delete i[r],i.removeListener&&this.emit("removeListener",r,n.listener||t));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===t||n[s].listener&&n[s].listener===t){c=n[s].listener,a=s;break}if(a<0)return this;if(n.length===1){if(n[0]=void 0,--this._eventsCount===0)return this._events=new pa,this;delete i[r]}else _3(n,a);i.removeListener&&this.emit("removeListener",r,c||t)}return this};Vt.prototype.off=function(e,r){return this.removeListener(e,r)};Vt.prototype.removeAllListeners=function(r){var t,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new pa,this._eventsCount=0):n[r]&&(--this._eventsCount===0?this._events=new pa:delete n[r]),this;if(arguments.length===0){for(var i=Object.keys(n),a=0,s;a<i.length;++a)s=i[a],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=new pa,this._eventsCount=0,this}if(t=n[r],typeof t=="function")this.removeListener(r,t);else if(t)do this.removeListener(r,t[t.length-1]);while(t[0]);return this};Vt.prototype.listeners=function(r){var t,n,i=this._events;return i?(t=i[r],t?typeof t=="function"?n=[t.listener||t]:n=S3(t):n=[]):n=[],n};Vt.listenerCount=function(e,r){return typeof e.listenerCount=="function"?e.listenerCount(r):S0.call(e,r)};Vt.prototype.listenerCount=S0;function S0(e){var r=this._events;if(r){var t=r[e];if(typeof t=="function")return 1;if(t)return t.length}return 0}Vt.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function _3(e,r){for(var t=r,n=t+1,i=e.length;n<i;t+=1,n+=1)e[t]=e[n];e.pop()}function $u(e,r){for(var t=new Array(r);r--;)t[r]=e[r];return t}function S3(e){for(var r=new Array(e.length),t=0;t<r.length;++t)r[t]=e[t].listener||e[t];return r}function w3(e){var r=T3();return function(){var n=Ei.default(e),i;if(r){var a=Ei.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return f3.default(this,i)}}function T3(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var C3=function(e){l3.default(t,e);var r=w3(t);function t(){var n;return o3.default(this,t),n=r.call(this),d3.default(c3.default(n),"eventHistory",new Map),n}return u3.default(t,[{key:"on",value:function(i,a){return Fa.default(Ei.default(t.prototype),"on",this).call(this,i,a)}},{key:"once",value:function(i,a){return Fa.default(Ei.default(t.prototype),"once",this).call(this,i,a)}},{key:"off",value:function(i,a){return Fa.default(Ei.default(t.prototype),"off",this).call(this,i,a)}},{key:"emit",value:function(i){for(var a,s=arguments.length,c=new Array(s>1?s-1:0),o=1;o<s;o++)c[o-1]=arguments[o];return this.eventHistory.set(i,c),(a=Fa.default(Ei.default(t.prototype),"emit",this)).call.apply(a,[this,i].concat(c))}},{key:"addListener",value:function(i,a){return Fa.default(Ei.default(t.prototype),"addListener",this).call(this,i,a)}},{key:"removeListener",value:function(i,a){return Fa.default(Ei.default(t.prototype),"removeListener",this).call(this,i,a)}},{key:"addListenerWithReplay",value:function(i,a){var s=this.eventHistory.get(i);return s!==void 0&&a.apply(void 0,pb.default(s)),this.addListener(i,a)}},{key:"onWithReplay",value:function(i,a){return this.addListenerWithReplay(i,a)}},{key:"onceWithReplay",value:function(i,a){var s=this.eventHistory.get(i);return s!==void 0?(a.apply(void 0,pb.default(s)),this):Fa.default(Ei.default(t.prototype),"once",this).call(this,i,a)}}]),t}(Vt);Uv.ReplayEventEmitter=C3;var nl={exports:{}};nl.exports;(function(e,r){var t=200,n="__lodash_hash_undefined__",i=1,a=2,s=9007199254740991,c="[object Arguments]",o="[object Array]",u="[object AsyncFunction]",l="[object Boolean]",f="[object Date]",d="[object Error]",p="[object Function]",h="[object GeneratorFunction]",E="[object Map]",M="[object Number]",I="[object Null]",x="[object Object]",j="[object Promise]",z="[object Proxy]",ie="[object RegExp]",oe="[object Set]",J="[object String]",L="[object Symbol]",Y="[object Undefined]",Z="[object WeakMap]",ye="[object ArrayBuffer]",Re="[object DataView]",ae="[object Float32Array]",Ve="[object Float64Array]",be="[object Int8Array]",Te="[object Int16Array]",we="[object Int32Array]",ge="[object Uint8Array]",$e="[object Uint8ClampedArray]",De="[object Uint16Array]",G="[object Uint32Array]",Qe=/[\\^$.*+?()[\]{}|]/g,Et=/^\[object .+?Constructor\]$/,ut=/^(?:0|[1-9]\d*)$/,je={};je[ae]=je[Ve]=je[be]=je[Te]=je[we]=je[ge]=je[$e]=je[De]=je[G]=!0,je[c]=je[o]=je[ye]=je[l]=je[Re]=je[f]=je[d]=je[p]=je[E]=je[M]=je[x]=je[ie]=je[oe]=je[J]=je[Z]=!1;var te=typeof ze=="object"&&ze&&ze.Object===Object&&ze,ur=typeof self=="object"&&self&&self.Object===Object&&self,Me=te||ur||Function("return this")(),fe=r&&!r.nodeType&&r,Pt=fe&&!0&&e&&!e.nodeType&&e,We=Pt&&Pt.exports===fe,Kt=We&&te.process,gt=function(){try{return Kt&&Kt.binding&&Kt.binding("util")}catch{}}(),xe=gt&>.isTypedArray;function ft(B,w){for(var k=-1,S=B==null?0:B.length,m=0,v=[];++k<S;){var _=B[k];w(_,k,B)&&(v[m++]=_)}return v}function Tt(B,w){for(var k=-1,S=w.length,m=B.length;++k<S;)B[m+k]=w[k];return B}function Le(B,w){for(var k=-1,S=B==null?0:B.length;++k<S;)if(w(B[k],k,B))return!0;return!1}function Jt(B,w){for(var k=-1,S=Array(B);++k<B;)S[k]=w(k);return S}function vt(B){return function(w){return B(w)}}function zt(B,w){return B.has(w)}function nr(B,w){return B==null?void 0:B[w]}function He(B){var w=-1,k=Array(B.size);return B.forEach(function(S,m){k[++w]=[m,S]}),k}function Pr(B,w){return function(k){return B(w(k))}}function Cr(B){var w=-1,k=Array(B.size);return B.forEach(function(S){k[++w]=S}),k}var Ct=Array.prototype,kt=Function.prototype,yt=Object.prototype,st=Me["__core-js_shared__"],Lt=kt.toString,Xt=yt.hasOwnProperty,hr=function(){var B=/[^.]+$/.exec(st&&st.keys&&st.keys.IE_PROTO||"");return B?"Symbol(src)_1."+B:""}(),hn=yt.toString,Pn=RegExp("^"+Lt.call(Xt).replace(Qe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),_r=We?Me.Buffer:void 0,Wt=Me.Symbol,Nr=Me.Uint8Array,_e=yt.propertyIsEnumerable,Ce=Ct.splice,ce=Wt?Wt.toStringTag:void 0,de=Object.getOwnPropertySymbols,le=_r?_r.isBuffer:void 0,ke=Pr(Object.keys,Object),Ie=Zt(Me,"DataView"),ee=Zt(Me,"Map"),ve=Zt(Me,"Promise"),Q=Zt(Me,"Set"),se=Zt(Me,"WeakMap"),X=Zt(Object,"create"),Ue=O(Ie),Oe=O(ee),Ze=O(ve),Ke=O(Q),Je=O(se),rt=Wt?Wt.prototype:void 0,nt=rt?rt.valueOf:void 0;function Ye(B){var w=-1,k=B==null?0:B.length;for(this.clear();++w<k;){var S=B[w];this.set(S[0],S[1])}}function tt(){this.__data__=X?X(null):{},this.size=0}function it(B){var w=this.has(B)&&delete this.__data__[B];return this.size-=w?1:0,w}function ct(B){var w=this.__data__;if(X){var k=w[B];return k===n?void 0:k}return Xt.call(w,B)?w[B]:void 0}function Sr(B){var w=this.__data__;return X?w[B]!==void 0:Xt.call(w,B)}function cr(B,w){var k=this.__data__;return this.size+=this.has(B)?0:1,k[B]=X&&w===void 0?n:w,this}Ye.prototype.clear=tt,Ye.prototype.delete=it,Ye.prototype.get=ct,Ye.prototype.has=Sr,Ye.prototype.set=cr;function ot(B){var w=-1,k=B==null?0:B.length;for(this.clear();++w<k;){var S=B[w];this.set(S[0],S[1])}}function Hr(){this.__data__=[],this.size=0}function ir(B){var w=this.__data__,k=Hn(w,B);if(k<0)return!1;var S=w.length-1;return k==S?w.pop():Ce.call(w,k,1),--this.size,!0}function Wn(B){var w=this.__data__,k=Hn(w,B);return k<0?void 0:w[k][1]}function hi(B){return Hn(this.__data__,B)>-1}function $a(B,w){var k=this.__data__,S=Hn(k,B);return S<0?(++this.size,k.push([B,w])):k[S][1]=w,this}ot.prototype.clear=Hr,ot.prototype.delete=ir,ot.prototype.get=Wn,ot.prototype.has=hi,ot.prototype.set=$a;function Kr(B){var w=-1,k=B==null?0:B.length;for(this.clear();++w<k;){var S=B[w];this.set(S[0],S[1])}}function Yi(){this.size=0,this.__data__={hash:new Ye,map:new(ee||ot),string:new Ye}}function Oa(B){var w=An(this,B).delete(B);return this.size-=w?1:0,w}function Vn(B){return An(this,B).get(B)}function Er(B){return An(this,B).has(B)}function Ia(B,w){var k=An(this,B),S=k.size;return k.set(B,w),this.size+=k.size==S?0:1,this}Kr.prototype.clear=Yi,Kr.prototype.delete=Oa,Kr.prototype.get=Vn,Kr.prototype.has=Er,Kr.prototype.set=Ia;function rn(B){var w=-1,k=B==null?0:B.length;for(this.__data__=new Kr;++w<k;)this.add(B[w])}function ar(B){return this.__data__.set(B,n),this}function vi(B){return this.__data__.has(B)}rn.prototype.add=rn.prototype.push=ar,rn.prototype.has=vi;function Jr(B){var w=this.__data__=new ot(B);this.size=w.size}function Xi(){this.__data__=new ot,this.size=0}function Pa(B){var w=this.__data__,k=w.delete(B);return this.size=w.size,k}function Aa(B){return this.__data__.get(B)}function Ar(B){return this.__data__.has(B)}function At(B,w){var k=this.__data__;if(k instanceof ot){var S=k.__data__;if(!ee||S.length<t-1)return S.push([B,w]),this.size=++k.size,this;k=this.__data__=new Kr(S)}return k.set(B,w),this.size=k.size,this}Jr.prototype.clear=Xi,Jr.prototype.delete=Pa,Jr.prototype.get=Aa,Jr.prototype.has=Ar,Jr.prototype.set=At;function mi(B,w){var k=N(B),S=!k&&U(B),m=!k&&!S&&pe(B),v=!k&&!S&&!m&&lr(B),_=k||S||m||v,g=_?Jt(B.length,String):[],y=g.length;for(var b in B)(w||Xt.call(B,b))&&!(_&&(b=="length"||m&&(b=="offset"||b=="parent")||v&&(b=="buffer"||b=="byteLength"||b=="byteOffset")||nn(b,y)))&&g.push(b);return g}function Hn(B,w){for(var k=B.length;k--;)if(R(B[k][0],w))return k;return-1}function Ma(B,w,k){var S=w(B);return N(B)?S:Tt(S,k(B))}function Yr(B){return B==null?B===void 0?Y:I:ce&&ce in Object(B)?Kn(B):P(B)}function gi(B){return Lr(B)&&Yr(B)==c}function yi(B,w,k,S,m){return B===w?!0:B==null||w==null||!Lr(B)&&!Lr(w)?B!==B&&w!==w:xa(B,w,k,S,yi,m)}function xa(B,w,k,S,m,v){var _=N(B),g=N(w),y=_?o:kr(B),b=g?o:kr(w);y=y==c?x:y,b=b==c?x:b;var T=y==x,$=b==x,H=y==b;if(H&&pe(B)){if(!pe(w))return!1;_=!0,T=!1}if(H&&!T)return v||(v=new Jr),_||lr(B)?Zi(B,w,k,S,m,v):bi(B,w,y,k,S,m,v);if(!(k&i)){var K=T&&Xt.call(B,"__wrapped__"),re=$&&Xt.call(w,"__wrapped__");if(K||re){var ue=K?B.value():B,Xe=re?w.value():w;return v||(v=new Jr),m(ue,Xe,k,S,v)}}return H?(v||(v=new Jr),ea(B,w,k,S,m,v)):!1}function Na(B){if(!dt(B)||F(B))return!1;var w=qe(B)?Pn:Et;return w.test(O(B))}function vr(B){return Lr(B)&&at(B.length)&&!!je[Yr(B)]}function Qi(B){if(!q(B))return ke(B);var w=[];for(var k in Object(B))Xt.call(B,k)&&k!="constructor"&&w.push(k);return w}function Zi(B,w,k,S,m,v){var _=k&i,g=B.length,y=w.length;if(g!=y&&!(_&&y>g))return!1;var b=v.get(B);if(b&&v.get(w))return b==w;var T=-1,$=!0,H=k&a?new rn:void 0;for(v.set(B,w),v.set(w,B);++T<g;){var K=B[T],re=w[T];if(S)var ue=_?S(re,K,T,w,B,v):S(K,re,T,B,w,v);if(ue!==void 0){if(ue)continue;$=!1;break}if(H){if(!Le(w,function(Xe,lt){if(!zt(H,lt)&&(K===Xe||m(K,Xe,k,S,v)))return H.push(lt)})){$=!1;break}}else if(!(K===re||m(K,re,k,S,v))){$=!1;break}}return v.delete(B),v.delete(w),$}function bi(B,w,k,S,m,v,_){switch(k){case Re:if(B.byteLength!=w.byteLength||B.byteOffset!=w.byteOffset)return!1;B=B.buffer,w=w.buffer;case ye:return!(B.byteLength!=w.byteLength||!v(new Nr(B),new Nr(w)));case l:case f:case M:return R(+B,+w);case d:return B.name==w.name&&B.message==w.message;case ie:case J:return B==w+"";case E:var g=He;case oe:var y=S&i;if(g||(g=Cr),B.size!=w.size&&!y)return!1;var b=_.get(B);if(b)return b==w;S|=a,_.set(B,w);var T=Zi(g(B),g(w),S,m,v,_);return _.delete(B),T;case L:if(nt)return nt.call(B)==nt.call(w)}return!1}function ea(B,w,k,S,m,v){var _=k&i,g=vn(B),y=g.length,b=vn(w),T=b.length;if(y!=T&&!_)return!1;for(var $=y;$--;){var H=g[$];if(!(_?H in w:Xt.call(w,H)))return!1}var K=v.get(B);if(K&&v.get(w))return K==w;var re=!0;v.set(B,w),v.set(w,B);for(var ue=_;++$<y;){H=g[$];var Xe=B[H],lt=w[H];if(S)var C=_?S(lt,Xe,H,w,B,v):S(Xe,lt,H,B,w,v);if(!(C===void 0?Xe===lt||m(Xe,lt,k,S,v):C)){re=!1;break}ue||(ue=H=="constructor")}if(re&&!ue){var A=B.constructor,D=w.constructor;A!=D&&"constructor"in B&&"constructor"in w&&!(typeof A=="function"&&A instanceof A&&typeof D=="function"&&D instanceof D)&&(re=!1)}return v.delete(B),v.delete(w),re}function vn(B){return Ma(B,an,Jn)}function An(B,w){var k=B.__data__;return ta(w)?k[typeof w=="string"?"string":"hash"]:k.map}function Zt(B,w){var k=nr(B,w);return Na(k)?k:void 0}function Kn(B){var w=Xt.call(B,ce),k=B[ce];try{B[ce]=void 0;var S=!0}catch{}var m=hn.call(B);return S&&(w?B[ce]=k:delete B[ce]),m}var Jn=de?function(B){return B==null?[]:(B=Object(B),ft(de(B),function(w){return _e.call(B,w)}))}:_o,kr=Yr;(Ie&&kr(new Ie(new ArrayBuffer(1)))!=Re||ee&&kr(new ee)!=E||ve&&kr(ve.resolve())!=j||Q&&kr(new Q)!=oe||se&&kr(new se)!=Z)&&(kr=function(B){var w=Yr(B),k=w==x?B.constructor:void 0,S=k?O(k):"";if(S)switch(S){case Ue:return Re;case Oe:return E;case Ze:return j;case Ke:return oe;case Je:return Z}return w});function nn(B,w){return w=w??s,!!w&&(typeof B=="number"||ut.test(B))&&B>-1&&B%1==0&&B<w}function ta(B){var w=typeof B;return w=="string"||w=="number"||w=="symbol"||w=="boolean"?B!=="__proto__":B===null}function F(B){return!!hr&&hr in B}function q(B){var w=B&&B.constructor,k=typeof w=="function"&&w.prototype||yt;return B===k}function P(B){return hn.call(B)}function O(B){if(B!=null){try{return Lt.call(B)}catch{}try{return B+""}catch{}}return""}function R(B,w){return B===w||B!==B&&w!==w}var U=gi(function(){return arguments}())?gi:function(B){return Lr(B)&&Xt.call(B,"callee")&&!_e.call(B,"callee")},N=Array.isArray;function me(B){return B!=null&&at(B.length)&&!qe(B)}var pe=le||Qt;function Ae(B,w){return yi(B,w)}function qe(B){if(!dt(B))return!1;var w=Yr(B);return w==p||w==h||w==u||w==z}function at(B){return typeof B=="number"&&B>-1&&B%1==0&&B<=s}function dt(B){var w=typeof B;return B!=null&&(w=="object"||w=="function")}function Lr(B){return B!=null&&typeof B=="object"}var lr=xe?vt(xe):vr;function an(B){return me(B)?mi(B):Qi(B)}function _o(){return[]}function Qt(){return!1}e.exports=Ae})(nl,nl.exports);var E3=nl.exports,w0={exports:{}},k3=mt,R3=k3(function(){if(typeof ArrayBuffer=="function"){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}}),$3=mt,O3=tr,I3=ai,hb=R3,zc=Object.isExtensible,P3=$3(function(){zc(1)}),A3=P3||hb?function(r){return!O3(r)||hb&&I3(r)=="ArrayBuffer"?!1:zc?zc(r):!0}:zc,M3=mt,T0=!M3(function(){return Object.isExtensible(Object.preventExtensions({}))}),x3=St,N3=_t,L3=hu,D3=tr,qv=rr,j3=qr.f,vb=ba,F3=av,Gv=A3,U3=fu,B3=T0,C0=!1,xi=U3("meta"),q3=0,zv=function(e){j3(e,xi,{value:{objectID:"O"+q3++,weakData:{}}})},G3=function(e,r){if(!D3(e))return typeof e=="symbol"?e:(typeof e=="string"?"S":"P")+e;if(!qv(e,xi)){if(!Gv(e))return"F";if(!r)return"E";zv(e)}return e[xi].objectID},z3=function(e,r){if(!qv(e,xi)){if(!Gv(e))return!0;if(!r)return!1;zv(e)}return e[xi].weakData},W3=function(e){return B3&&C0&&Gv(e)&&!qv(e,xi)&&zv(e),e},V3=function(){H3.enable=function(){},C0=!0;var e=vb.f,r=N3([].splice),t={};t[xi]=1,e(t).length&&(vb.f=function(n){for(var i=e(n),a=0,s=i.length;a<s;a++)if(i[a]===xi){r(i,a,1);break}return i},x3({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:F3.f}))},H3=w0.exports={enable:V3,fastKey:G3,getWeakData:z3,onFreeze:W3};L3[xi]=!0;var Wv=w0.exports,K3=St,J3=Rt,Y3=_t,mb=Tl,X3=Gr,Q3=Wv,Z3=Ll,e4=cs,t4=Bt,r4=si,Td=tr,Cd=mt,n4=Dl,i4=Ui,a4=Pv,E0=function(e,r,t){var n=e.indexOf("Map")!==-1,i=e.indexOf("Weak")!==-1,a=n?"set":"add",s=J3[e],c=s&&s.prototype,o=s,u={},l=function(I){var x=Y3(c[I]);X3(c,I,I=="add"?function(z){return x(this,z===0?0:z),this}:I=="delete"?function(j){return i&&!Td(j)?!1:x(this,j===0?0:j)}:I=="get"?function(z){return i&&!Td(z)?void 0:x(this,z===0?0:z)}:I=="has"?function(z){return i&&!Td(z)?!1:x(this,z===0?0:z)}:function(z,ie){return x(this,z===0?0:z,ie),this})},f=mb(e,!t4(s)||!(i||c.forEach&&!Cd(function(){new s().entries().next()})));if(f)o=t.getConstructor(r,e,n,a),Q3.enable();else if(mb(e,!0)){var d=new o,p=d[a](i?{}:-0,1)!=d,h=Cd(function(){d.has(1)}),E=n4(function(I){new s(I)}),M=!i&&Cd(function(){for(var I=new s,x=5;x--;)I[a](x,x);return!I.has(-0)});E||(o=r(function(I,x){e4(I,c);var j=a4(new s,I,o);return r4(x)||Z3(x,j[a],{that:j,AS_ENTRIES:n}),j}),o.prototype=c,c.constructor=o),(h||M)&&(l("delete"),l("has"),n&&l("get")),(M||p)&&l(a),i&&c.clear&&delete c.clear}return u[e]=o,K3({global:!0,constructor:!0,forced:o!=s},u),i4(o,e),i||t.setStrong(o,e,n),o},s4=Gr,Vv=function(e,r,t){for(var n in r)s4(e,n,r[n],t);return e},o4=Sa,u4=ci,gb=Vv,c4=qi,l4=cs,f4=si,d4=Ll,p4=Ev,nc=kv,h4=Al,Eo=Yt,yb=Wv.fastKey,k0=kn,bb=k0.set,Ed=k0.getterFor,R0={getConstructor:function(e,r,t,n){var i=e(function(u,l){l4(u,a),bb(u,{type:r,index:o4(null),first:void 0,last:void 0,size:0}),Eo||(u.size=0),f4(l)||d4(l,u[n],{that:u,AS_ENTRIES:t})}),a=i.prototype,s=Ed(r),c=function(u,l,f){var d=s(u),p=o(u,l),h,E;return p?p.value=f:(d.last=p={index:E=yb(l,!0),key:l,value:f,previous:h=d.last,next:void 0,removed:!1},d.first||(d.first=p),h&&(h.next=p),Eo?d.size++:u.size++,E!=="F"&&(d.index[E]=p)),u},o=function(u,l){var f=s(u),d=yb(l),p;if(d!=="F")return f.index[d];for(p=f.first;p;p=p.next)if(p.key==l)return p};return gb(a,{clear:function(){for(var l=this,f=s(l),d=f.index,p=f.first;p;)p.removed=!0,p.previous&&(p.previous=p.previous.next=void 0),delete d[p.index],p=p.next;f.first=f.last=void 0,Eo?f.size=0:l.size=0},delete:function(u){var l=this,f=s(l),d=o(l,u);if(d){var p=d.next,h=d.previous;delete f.index[d.index],d.removed=!0,h&&(h.next=p),p&&(p.previous=h),f.first==d&&(f.first=p),f.last==d&&(f.last=h),Eo?f.size--:l.size--}return!!d},forEach:function(l){for(var f=s(this),d=c4(l,arguments.length>1?arguments[1]:void 0),p;p=p?p.next:f.first;)for(d(p.value,p.key,this);p&&p.removed;)p=p.previous},has:function(l){return!!o(this,l)}}),gb(a,t?{get:function(l){var f=o(this,l);return f&&f.value},set:function(l,f){return c(this,l===0?0:l,f)}}:{add:function(l){return c(this,l=l===0?0:l,l)}}),Eo&&u4(a,"size",{configurable:!0,get:function(){return s(this).size}}),i},setStrong:function(e,r,t){var n=r+" Iterator",i=Ed(r),a=Ed(n);p4(e,r,function(s,c){bb(this,{type:n,target:s,state:i(s),kind:c,last:void 0})},function(){for(var s=a(this),c=s.kind,o=s.last;o&&o.removed;)o=o.previous;return!s.target||!(s.last=o=o?o.next:s.state.first)?(s.target=void 0,nc(void 0,!0)):c=="keys"?nc(o.key,!1):c=="values"?nc(o.value,!1):nc([o.key,o.value],!1)},t?"entries":"values",!t,!0),h4(r)}},v4=E0,m4=R0;v4("Map",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},m4);var Wi={};/*
|
|
40
|
+
@license
|
|
41
|
+
Copyright (c) 2016, Twilio, Inc.
|
|
42
|
+
|
|
43
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
44
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
45
|
+
copyright notice and this permission notice appear in all copies.
|
|
46
|
+
|
|
47
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
48
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
49
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
50
|
+
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
51
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
52
|
+
OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
53
|
+
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
54
|
+
|
|
55
|
+
*/Object.defineProperty(Wi,"__esModule",{value:!0});var g4=di,y4=wa,b4=os,_4=li,S4=fi,w4=$n,T4=us;function ls(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Hv=ls(g4),Kv=ls(y4),Ri=ls(b4),Jv=ls(_4),$0=ls(S4),il=ls(w4),$i=ls(T4),C4;function ha(){}ha.prototype=Object.create(null);function Ft(){Ft.init.call(this)}Ft.EventEmitter=Ft;Ft.usingDomains=!1;Ft.prototype.domain=void 0;Ft.prototype._events=void 0;Ft.prototype._maxListeners=void 0;Ft.defaultMaxListeners=10;Ft.init=function(){this.domain=null,Ft.usingDomains&&C4.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new ha,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Ft.prototype.setMaxListeners=function(r){if(typeof r!="number"||r<0||isNaN(r))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=r,this};function O0(e){return e._maxListeners===void 0?Ft.defaultMaxListeners:e._maxListeners}Ft.prototype.getMaxListeners=function(){return O0(this)};function E4(e,r,t){if(r)e.call(t);else for(var n=e.length,i=Ou(e,n),a=0;a<n;++a)i[a].call(t)}function k4(e,r,t,n){if(r)e.call(t,n);else for(var i=e.length,a=Ou(e,i),s=0;s<i;++s)a[s].call(t,n)}function R4(e,r,t,n,i){if(r)e.call(t,n,i);else for(var a=e.length,s=Ou(e,a),c=0;c<a;++c)s[c].call(t,n,i)}function $4(e,r,t,n,i,a){if(r)e.call(t,n,i,a);else for(var s=e.length,c=Ou(e,s),o=0;o<s;++o)c[o].call(t,n,i,a)}function O4(e,r,t,n){if(r)e.apply(t,n);else for(var i=e.length,a=Ou(e,i),s=0;s<i;++s)a[s].apply(t,n)}Ft.prototype.emit=function(r){var t,n,i,a,s,c,o,u=r==="error";if(c=this._events,c)u=u&&c.error==null;else if(!u)return!1;if(o=this.domain,u){if(t=arguments[1],o)t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=o,t.domainThrown=!1,o.emit("error",t);else{if(t instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}return!1}if(n=c[r],!n)return!1;var f=typeof n=="function";switch(i=arguments.length,i){case 1:E4(n,f,this);break;case 2:k4(n,f,this,arguments[1]);break;case 3:R4(n,f,this,arguments[1],arguments[2]);break;case 4:$4(n,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(a=new Array(i-1),s=1;s<i;s++)a[s-1]=arguments[s];O4(n,f,this,a)}return!0};function I0(e,r,t,n){var i,a,s;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(a=e._events,a?(a.newListener&&(e.emit("newListener",r,t.listener?t.listener:t),a=e._events),s=a[r]):(a=e._events=new ha,e._eventsCount=0),!s)s=a[r]=t,++e._eventsCount;else if(typeof s=="function"?s=a[r]=n?[t,s]:[s,t]:n?s.unshift(t):s.push(t),!s.warned&&(i=O0(e),i&&i>0&&s.length>i)){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+r+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=r,c.count=s.length,I4(c)}return e}function I4(e){typeof console.warn=="function"?console.warn(e):console.log(e)}Ft.prototype.addListener=function(r,t){return I0(this,r,t,!1)};Ft.prototype.on=Ft.prototype.addListener;Ft.prototype.prependListener=function(r,t){return I0(this,r,t,!0)};function P0(e,r,t){var n=!1;function i(){e.removeListener(r,i),n||(n=!0,t.apply(e,arguments))}return i.listener=t,i}Ft.prototype.once=function(r,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.on(r,P0(this,r,t)),this};Ft.prototype.prependOnceListener=function(r,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(r,P0(this,r,t)),this};Ft.prototype.removeListener=function(r,t){var n,i,a,s,c;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[r],!n)return this;if(n===t||n.listener&&n.listener===t)--this._eventsCount===0?this._events=new ha:(delete i[r],i.removeListener&&this.emit("removeListener",r,n.listener||t));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===t||n[s].listener&&n[s].listener===t){c=n[s].listener,a=s;break}if(a<0)return this;if(n.length===1){if(n[0]=void 0,--this._eventsCount===0)return this._events=new ha,this;delete i[r]}else P4(n,a);i.removeListener&&this.emit("removeListener",r,c||t)}return this};Ft.prototype.off=function(e,r){return this.removeListener(e,r)};Ft.prototype.removeAllListeners=function(r){var t,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new ha,this._eventsCount=0):n[r]&&(--this._eventsCount===0?this._events=new ha:delete n[r]),this;if(arguments.length===0){for(var i=Object.keys(n),a=0,s;a<i.length;++a)s=i[a],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=new ha,this._eventsCount=0,this}if(t=n[r],typeof t=="function")this.removeListener(r,t);else if(t)do this.removeListener(r,t[t.length-1]);while(t[0]);return this};Ft.prototype.listeners=function(r){var t,n,i=this._events;return i?(t=i[r],t?typeof t=="function"?n=[t.listener||t]:n=A4(t):n=[]):n=[],n};Ft.listenerCount=function(e,r){return typeof e.listenerCount=="function"?e.listenerCount(r):A0.call(e,r)};Ft.prototype.listenerCount=A0;function A0(e){var r=this._events;if(r){var t=r[e];if(typeof t=="function")return 1;if(t)return t.length}return 0}Ft.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function P4(e,r){for(var t=r,n=t+1,i=e.length;n<i;t+=1,n+=1)e[t]=e[n];e.pop()}function Ou(e,r){for(var t=new Array(r);r--;)t[r]=e[r];return t}function A4(e){for(var r=new Array(e.length),t=0;t<r.length;++t)r[t]=e[t].listener||e[t];return r}function M0(e){var r=M4();return function(){var n=il.default(e),i;if(r){var a=il.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return $0.default(this,i)}}function M4(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var x0=function(e){Jv.default(t,e);var r=M0(t);function t(n){var i;return Hv.default(this,t),i=r.call(this),$i.default(Ri.default(i),"timeout",null),$i.default(Ri.default(i),"startTimestamp",-1),i.minDelay=n.min,i.maxDelay=n.max,i.initialDelay=n.initial||0,i.maxAttemptsCount=n.maxAttemptsCount||0,i.maxAttemptsTime=n.maxAttemptsTime||0,i.randomness=n.randomness||0,i.inProgress=!1,i.attemptNum=0,i.prevDelay=0,i.currDelay=0,i}return Kv.default(t,[{key:"attempt",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.attemptNum++,this.emit("attempt",this)}},{key:"nextDelay",value:function(i){if(typeof i=="number")return this.prevDelay=0,this.currDelay=i,i;if(this.attemptNum==0)return this.initialDelay;if(this.attemptNum==1)return this.currDelay=this.minDelay,this.currDelay;this.prevDelay=this.currDelay;var a=this.currDelay+this.prevDelay;return this.maxDelay&&a>this.maxDelay&&(this.currDelay=this.maxDelay,a=this.maxDelay),this.currDelay=a,a}},{key:"randomize",value:function(i){var a=i*this.randomness,s=Math.round(Math.random()*a*2-a);return Math.max(0,i+s)}},{key:"scheduleAttempt",value:function(i){var a=this;if(this.maxAttemptsCount&&this.attemptNum>=this.maxAttemptsCount){this.cleanup(),this.emit("failed",new Error("Maximum attempt count limit reached"));return}var s=this.nextDelay(i);if(s=this.randomize(s),this.maxAttemptsTime&&this.startTimestamp+this.maxAttemptsTime<Date.now()+s){this.cleanup(),this.emit("failed",new Error("Maximum attempt time limit reached"));return}this.timeout=setTimeout(function(){return a.attempt()},s)}},{key:"cleanup",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.inProgress=!1,this.attemptNum=0,this.prevDelay=0,this.currDelay=0}},{key:"start",value:function(){if(this.inProgress)throw new Error("Retrier is already in progress");this.inProgress=!0,this.startTimestamp=Date.now(),this.scheduleAttempt(this.initialDelay)}},{key:"cancel",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null,this.inProgress=!1,this.emit("cancelled"))}},{key:"succeeded",value:function(i){this.emit("succeeded",i)}},{key:"failed",value:function(i,a){if(this.timeout)throw new Error("Retrier attempt is already in progress");this.scheduleAttempt(a)}}]),t}(Ft),x4=function(e){Jv.default(t,e);var r=M0(t);function t(n){var i;return Hv.default(this,t),i=r.call(this),$i.default(Ri.default(i),"resolve",function(){}),$i.default(Ri.default(i),"reject",function(){}),i.retrier=new x0(n),i}return Kv.default(t,[{key:"run",value:function(i){var a=this;return this.retrier.on("attempt",function(){i().then(function(s){return a.retrier.succeeded(s)}).catch(function(s){return a.retrier.failed(s)})}),this.retrier.on("succeeded",function(s){return a.resolve(s)}),this.retrier.on("cancelled",function(){return a.reject(new Error("Cancelled"))}),this.retrier.on("failed",function(s){return a.reject(s)}),new Promise(function(s,c){a.resolve=s,a.reject=c,a.retrier.start()})}},{key:"cancel",value:function(){this.retrier.cancel()}}]),t}(Ft);function N4(e){var r=L4();return function(){var n=il.default(e),i;if(r){var a=il.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return $0.default(this,i)}}function L4(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ic(e){return e!=null}var D4=function(e){Jv.default(t,e);var r=N4(t);function t(n){var i;Hv.default(this,t),i=r.call(this),$i.default(Ri.default(i),"backoffDelay",0),$i.default(Ri.default(i),"nextBackoffDelay",0),$i.default(Ri.default(i),"backoffNumber",0),$i.default(Ri.default(i),"timeoutID",null),$i.default(Ri.default(i),"maxNumberOfRetry",-1),n=n||{};var a=n,s=a.initialDelay,c=a.maxDelay,o=a.randomisationFactor,u=a.factor;if(ic(s)&&s<1)throw new Error("The initial timeout must be equal to or greater than 1.");if(ic(c)&&c<=1)throw new Error("The maximal timeout must be greater than 1.");if(ic(o)&&(o<0||o>1))throw new Error("The randomisation factor must be between 0 and 1.");if(ic(u)&&u<=1)throw new Error("Exponential factor should be greater than 1.");if(i.initialDelay=s||100,i.maxDelay=c||1e4,i.maxDelay<=i.initialDelay)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");return i.randomisationFactor=o||0,i.factor=u||2,i.reset(),i}return Kv.default(t,[{key:"backoff",value:function(i){this.timeoutID==null&&(this.backoffNumber===this.maxNumberOfRetry?(this.emit("fail",i),this.reset()):(this.backoffDelay=this.next(),this.timeoutID=setTimeout(this.onBackoff.bind(this),this.backoffDelay),this.emit("backoff",this.backoffNumber,this.backoffDelay,i)))}},{key:"reset",value:function(){this.backoffDelay=0,this.nextBackoffDelay=this.initialDelay,this.backoffNumber=0,this.timeoutID&&clearTimeout(this.timeoutID),this.timeoutID=null}},{key:"failAfter",value:function(i){if(i<=0)throw new Error("Expected a maximum number of retry greater than 0 but got ".concat(i));this.maxNumberOfRetry=i}},{key:"next",value:function(){this.backoffDelay=Math.min(this.nextBackoffDelay,this.maxDelay),this.nextBackoffDelay=this.backoffDelay*this.factor;var i=1+Math.random()*this.randomisationFactor;return Math.min(this.maxDelay,Math.round(this.backoffDelay*i))}},{key:"onBackoff",value:function(){this.timeoutID=null,this.emit("ready",this.backoffNumber,this.backoffDelay),this.backoffNumber++}}],[{key:"exponential",value:function(i){return new t(i)}}]),t}(Ft);Wi.AsyncRetrier=x4;Wi.Backoff=D4;Wi.Retrier=x0;var Yl={},j4=qt,F4=rr,U4=Di,B4=HC,_b=RegExp.prototype,q4=function(e){var r=e.flags;return r===void 0&&!("flags"in _b)&&!F4(e,"flags")&&U4(_b,e)?j4(B4,e):r},G4=pu.PROPER,z4=Gr,W4=sr,Sb=br,V4=mt,H4=q4,Yv="toString",K4=RegExp.prototype,N0=K4[Yv],J4=V4(function(){return N0.call({source:"a",flags:"b"})!="/a/b"}),Y4=G4&&N0.name!=Yv;(J4||Y4)&&z4(RegExp.prototype,Yv,function(){var r=W4(this),t=Sb(r.source),n=Sb(H4(r));return"/"+t+"/"+n},{unsafe:!0});var zr={};/*
|
|
56
|
+
@license
|
|
57
|
+
Copyright (c) 2021 Twilio Inc.
|
|
58
|
+
|
|
59
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
60
|
+
|
|
61
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
62
|
+
|
|
63
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
*/Object.defineProperty(zr,"__esModule",{value:!0});var X4=Rn,Q4=fo,Z4=po,eq=di,tq=li,rq=fi,nq=$n;function fs(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Fs=fs(X4),Qa=fs(Q4),kd=fs(Z4),iq=fs(eq),aq=fs(tq),sq=fs(rq),wb=fs(nq),Ca=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return{checks:t}};function oq(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=uq(e))||r&&e&&typeof e.length=="number"){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
67
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,c;return{s:function(){t=t.call(e)},n:function(){var u=t.next();return a=u.done,u},e:function(u){s=!0,c=u},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw c}}}}function uq(e,r){if(e){if(typeof e=="string")return Tb(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Tb(e,r)}}function Tb(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var L0=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return Ca(function(i){var a=!1,s=[],c=oq(t),o;try{for(c.s();!(o=c.n()).done;){var u=o.value;if(typeof u=="string"){a=a||Fs.default(i)===u,s.push("of type ".concat(u));continue}a=a||i instanceof u,s.push("an instance of ".concat(u.name))}}catch(l){c.e(l)}finally{c.f()}return[a,s]})};function cq(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=lq(e))||r&&e&&typeof e.length=="number"){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
68
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,c;return{s:function(){t=t.call(e)},n:function(){var u=t.next();return a=u.done,u},e:function(u){s=!0,c=u},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw c}}}}function lq(e,r){if(e){if(typeof e=="string")return Cb(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Cb(e,r)}}function Cb(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var fq=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return Ca(function(i){var a=!1,s=[],c=cq(t),o;try{for(c.s();!(o=c.n()).done;){var u=o.value;a=a||i===u,s.push(typeof u=="string"?'"'.concat(u,'"'):"".concat(u))}}catch(l){c.e(l)}finally{c.f()}return[a,s]})},dq=Ca(function(e){return[typeof e=="string"&&e.length>0,"a non-empty string"]}),pq=Ca(function(e){return[typeof e=="number"&&Number.isInteger(e)&&e>=0,"a non-negative integer"]}),hq=Ca(function(e){return[Fs.default(e)==="object"&&e!==null&&!Array.isArray(e),"a pure object (non-null and non-array)"]});function vq(e){var r=mq();return function(){var n=wb.default(e),i;if(r){var a=wb.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return sq.default(this,i)}}function mq(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function nu(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=gq(e))||r&&e&&typeof e.length=="number"){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
69
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,c;return{s:function(){t=t.call(e)},n:function(){var u=t.next();return a=u.done,u},e:function(u){s=!0,c=u},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw c}}}}function gq(e,r){if(e){if(typeof e=="string")return Eb(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Eb(e,r)}}function Eb(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var Xl=function(r,t){if(t.length>r.length)throw new Error("Expected at most ".concat(r.length," argument(s), but got ").concat(t.length));for(;t.length<r.length;)t.push(void 0);var n=nu(t.entries()),i;try{for(n.s();!(i=n.n()).done;){var a=Qa.default(i.value,2),s=a[0],c=a[1],o=Zv(r[s],c),u=Qa.default(o,4),l=u[0],f=u[1],d=u[2],p=u[3];if(!l){var h=s+1;throw new Error("Argument ".concat(h," is expected to be ").concat(d).concat(p," but got ").concat(f))}}}catch(E){n.e(E)}finally{n.f()}},D0=function(r){var t,n,i=["undefined","boolean","number","bigint","string"];if(i.includes(Fs.default(r))&&(n=typeof r=="string"?'"'.concat(r,'"'):"".concat(r)),Fs.default(r)==="object"&&(r==null||(t=r.constructor)===null||t===void 0?void 0:t.name)!=="Object"){var a;n=r===null?"null":"instance of ".concat(r==null||(a=r.constructor)===null||a===void 0?void 0:a.name)}return n||(n=Fs.default(r)),n},yq=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=Xv(t);return function(a){return function(s){aq.default(o,s);var c=vq(o);function o(){iq.default(this,o);for(var u=arguments.length,l=new Array(u),f=0;f<u;f++)l[f]=arguments[f];return Xl(i,l),c.call.apply(c,[this].concat(l))}return o}(a)}},bq=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=Xv(t);return function(a,s,c){if(typeof c.value!="function")throw new Error("The validateTypes decorator can only be applied to methods");var o=c.value;c.value=function(){for(var u=arguments.length,l=new Array(u),f=0;f<u;f++)l[f]=arguments[f];return Xl(i,l),o.apply(this,l)}}},_q=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=Xv(t);return function(a,s,c){if(typeof c.value!="function")throw new Error("The validateTypesAsync decorator can only be applied to methods");var o=c.value;c.value=function(){for(var u=arguments.length,l=new Array(u),f=0;f<u;f++)l[f]=arguments[f];try{Xl(i,l)}catch(d){return Promise.reject(d)}return o.apply(this,l)}}},Xv=function(r){var t=[],n=nu(r),i;try{for(n.s();!(i=n.n()).done;){var a=i.value;t.push(Qv(a))}}catch(s){n.e(s)}finally{n.f()}return t},Qv=function(r){var t=[],n=Array.isArray(r)?r:[r],i=nu(n),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;if(typeof s=="string"||typeof s=="function"){t.push(L0(s));continue}t.push(s)}}catch(c){i.e(c)}finally{i.f()}return t},Zv=function(r,t){var n=[],i,a=!1,s=nu(r),c;try{for(s.s();!(c=s.n()).done;){var o=c.value,u=nu(o.checks),l;try{for(u.s();!(l=u.n()).done;){var f=l.value,d=f(t),p=Qa.default(d,3),h=p[0],E=p[1],M=p[2];a=a||h,!i&&M&&(i=M),E&&(n=typeof E=="string"?[].concat(kd.default(n),[E]):[].concat(kd.default(n),kd.default(E)))}}catch(z){u.e(z)}finally{u.f()}}}catch(z){s.e(z)}finally{s.f()}if(a)return[!0];var I=i||D0(t),x=n.length-1,j=x>0?"".concat(n.slice(0,x).join(", ")," or ").concat(n[x]):n.join(", ");return[!1,I,j,x>1?";":","]},Sq=function(r,t){return Ca(function(n){if(Fs.default(n)!=="object"||n===null||Array.isArray(n))return[!1,"valid ".concat(r," (should be a pure object)")];for(var i=0,a=Object.entries(t);i<a.length;i++){var s=Qa.default(a[i],2),c=s[0],o=s[1],u=Zv(Qv(o),n[c]),l=Qa.default(u,3),f=l[0],d=l[1],p=l[2];if(!f)return[!1,"valid ".concat(r,' (key "').concat(c,'" should be ').concat(p,")"),"malformed ".concat(r,' (key "').concat(c,'" is ').concat(d,")")]}return[!0]})};function wq(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=Tq(e))||r&&e&&typeof e.length=="number"){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
70
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,c;return{s:function(){t=t.call(e)},n:function(){var u=t.next();return a=u.done,u},e:function(u){s=!0,c=u},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw c}}}}function Tq(e,r){if(e){if(typeof e=="string")return kb(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return kb(e,r)}}function kb(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var Cq=function(r,t){return Ca(function(n){if(!Array.isArray(n))return[!1,"an array of ".concat(r)];var i=wq(n.entries()),a;try{for(i.s();!(a=i.n()).done;){var s=Qa.default(a.value,2),c=s[0],o=s[1],u=Zv(Qv(t),o),l=Qa.default(u,3),f=l[0],d=l[1],p=l[2];if(!f)return[!1,"a valid array of ".concat(r," (index ").concat(c," should be ").concat(p,")"),"malformed array of ".concat(r," (index ").concat(c," is ").concat(d,")")]}}catch(h){i.e(h)}finally{i.f()}return[!0]})};zr.array=Cq;zr.custom=Ca;zr.literal=fq;zr.nonEmptyString=dq;zr.nonNegativeInteger=pq;zr.objectSchema=Sq;zr.pureObject=hq;zr.runtimeTypeValidation=Xl;zr.stringifyReceivedType=D0;zr.type=L0;zr.validateConstructorTypes=yq;zr.validateTypes=bq;zr.validateTypesAsync=_q;var Eq=E0,kq=R0;Eq("Set",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},kq);var j0={exports:{}};(function(e,r){(function(n,i){e.exports=i()})(ze,function(){return function(t){var n={};function i(a){if(n[a])return n[a].exports;var s=n[a]={i:a,l:!1,exports:{}};return t[a].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=n,i.i=function(a){return a},i.d=function(a,s,c){i.o(a,s)||Object.defineProperty(a,s,{configurable:!1,enumerable:!0,get:c})},i.n=function(a){var s=a&&a.__esModule?function(){return a.default}:function(){return a};return i.d(s,"a",s),s},i.o=function(a,s){return Object.prototype.hasOwnProperty.call(a,s)},i.p="",i(i.s=5)}([function(t,n,i){t.exports=function(a,s){var c,o,u;for(c=1;c<arguments.length;c++){o=arguments[c];for(u in o)o.hasOwnProperty(u)&&(a[u]=o[u])}return a}},function(t,n,i){var a=i(0);t.exports={build:function(s,c){var o,u,l,f=c.plugins;for(o=0,u=f.length;o<u;o++)l=f[o],l.methods&&a(s,l.methods),l.properties&&Object.defineProperties(s,l.properties)},hook:function(s,c,o){var u,l,f,d,p=s.config.plugins,h=[s.context];for(o&&(h=h.concat(o)),u=0,l=p.length;u<l;u++)d=p[u],f=p[u][c],f&&f.apply(d,h)}}},function(t,n,i){function a(s){if(s.length===0)return s;var c,o,u=s.split(/[_-]/);if(u.length===1&&u[0][0].toLowerCase()===u[0][0])return s;for(o=u[0].toLowerCase(),c=1;c<u.length;c++)o=o+u[c].charAt(0).toUpperCase()+u[c].substring(1).toLowerCase();return o}a.prepended=function(s,c){return c=a(c),s+c[0].toUpperCase()+c.substring(1)},t.exports=a},function(t,n,i){var a=i(0),s=i(2);function c(o,u){o=o||{},this.options=o,this.defaults=u.defaults,this.states=[],this.transitions=[],this.map={},this.lifecycle=this.configureLifecycle(),this.init=this.configureInitTransition(o.init),this.data=this.configureData(o.data),this.methods=this.configureMethods(o.methods),this.map[this.defaults.wildcard]={},this.configureTransitions(o.transitions||[]),this.plugins=this.configurePlugins(o.plugins,u.plugin)}a(c.prototype,{addState:function(o){this.map[o]||(this.states.push(o),this.addStateLifecycleNames(o),this.map[o]={})},addStateLifecycleNames:function(o){this.lifecycle.onEnter[o]=s.prepended("onEnter",o),this.lifecycle.onLeave[o]=s.prepended("onLeave",o),this.lifecycle.on[o]=s.prepended("on",o)},addTransition:function(o){this.transitions.indexOf(o)<0&&(this.transitions.push(o),this.addTransitionLifecycleNames(o))},addTransitionLifecycleNames:function(o){this.lifecycle.onBefore[o]=s.prepended("onBefore",o),this.lifecycle.onAfter[o]=s.prepended("onAfter",o),this.lifecycle.on[o]=s.prepended("on",o)},mapTransition:function(o){var u=o.name,l=o.from,f=o.to;return this.addState(l),typeof f!="function"&&this.addState(f),this.addTransition(u),this.map[l][u]=o,o},configureLifecycle:function(){return{onBefore:{transition:"onBeforeTransition"},onAfter:{transition:"onAfterTransition"},onEnter:{state:"onEnterState"},onLeave:{state:"onLeaveState"},on:{transition:"onTransition"}}},configureInitTransition:function(o){return typeof o=="string"?this.mapTransition(a({},this.defaults.init,{to:o,active:!0})):typeof o=="object"?this.mapTransition(a({},this.defaults.init,o,{active:!0})):(this.addState(this.defaults.init.from),this.defaults.init)},configureData:function(o){return typeof o=="function"?o:typeof o=="object"?function(){return o}:function(){return{}}},configureMethods:function(o){return o||{}},configurePlugins:function(o,u){o=o||[];var l,f,d;for(l=0,f=o.length;l<f;l++)d=o[l],typeof d=="function"&&(o[l]=d=d()),d.configure&&d.configure(this);return o},configureTransitions:function(o){var u,l,f,d,p,h=this.defaults.wildcard;for(l=0;l<o.length;l++)for(f=o[l],d=Array.isArray(f.from)?f.from:[f.from||h],p=f.to||h,u=0;u<d.length;u++)this.mapTransition({name:f.name,from:d[u],to:p})},transitionFor:function(o,u){var l=this.defaults.wildcard;return this.map[o][u]||this.map[l][u]},transitionsFor:function(o){var u=this.defaults.wildcard;return Object.keys(this.map[o]).concat(Object.keys(this.map[u]))},allStates:function(){return this.states},allTransitions:function(){return this.transitions}}),t.exports=c},function(t,n,i){var a=i(0),s=i(6),c=i(1),o=[null,[]];function u(l,f){this.context=l,this.config=f,this.state=f.init.from,this.observers=[l]}a(u.prototype,{init:function(l){if(a(this.context,this.config.data.apply(this.context,l)),c.hook(this,"init"),this.config.init.active)return this.fire(this.config.init.name,[])},is:function(l){return Array.isArray(l)?l.indexOf(this.state)>=0:this.state===l},isPending:function(){return this.pending},can:function(l){return!this.isPending()&&!!this.seek(l)},cannot:function(l){return!this.can(l)},allStates:function(){return this.config.allStates()},allTransitions:function(){return this.config.allTransitions()},transitions:function(){return this.config.transitionsFor(this.state)},seek:function(l,f){var d=this.config.defaults.wildcard,p=this.config.transitionFor(this.state,l),h=p&&p.to;return typeof h=="function"?h.apply(this.context,f):h===d?this.state:h},fire:function(l,f){return this.transit(l,this.state,this.seek(l,f),f)},transit:function(l,f,d,p){var h=this.config.lifecycle,E=this.config.options.observeUnchangedState||f!==d;return d?this.isPending()?this.context.onPendingTransition(l,f,d):(this.config.addState(d),this.beginTransit(),p.unshift({transition:l,from:f,to:d,fsm:this.context}),this.observeEvents([this.observersForEvent(h.onBefore.transition),this.observersForEvent(h.onBefore[l]),E?this.observersForEvent(h.onLeave.state):o,E?this.observersForEvent(h.onLeave[f]):o,this.observersForEvent(h.on.transition),E?["doTransit",[this]]:o,E?this.observersForEvent(h.onEnter.state):o,E?this.observersForEvent(h.onEnter[d]):o,E?this.observersForEvent(h.on[d]):o,this.observersForEvent(h.onAfter.transition),this.observersForEvent(h.onAfter[l]),this.observersForEvent(h.on[l])],p)):this.context.onInvalidTransition(l,f,d)},beginTransit:function(){this.pending=!0},endTransit:function(l){return this.pending=!1,l},failTransit:function(l){throw this.pending=!1,l},doTransit:function(l){this.state=l.to},observe:function(l){if(l.length===2){var f={};f[l[0]]=l[1],this.observers.push(f)}else this.observers.push(l[0])},observersForEvent:function(l){for(var f=0,d=this.observers.length,p,h=[];f<d;f++)p=this.observers[f],p[l]&&h.push(p);return[l,h,!0]},observeEvents:function(l,f,d,p){if(l.length===0)return this.endTransit(p===void 0?!0:p);var h=l[0][0],E=l[0][1],M=l[0][2];if(f[0].event=h,h&&M&&h!==d&&c.hook(this,"lifecycle",f),E.length===0)return l.shift(),this.observeEvents(l,f,h,p);var I=E.shift(),x=I[h].apply(I,f);return x&&typeof x.then=="function"?x.then(this.observeEvents.bind(this,l,f,h)).catch(this.failTransit.bind(this)):x===!1?this.endTransit(!1):this.observeEvents(l,f,h,x)},onInvalidTransition:function(l,f,d){throw new s("transition is invalid in current state",l,f,d,this.state)},onPendingTransition:function(l,f,d){throw new s("transition is invalid while previous transition is still in progress",l,f,d,this.state)}}),t.exports=u},function(t,n,i){var a=i(0),s=i(2),c=i(1),o=i(3),u=i(4),l={is:function(M){return this._fsm.is(M)},can:function(M){return this._fsm.can(M)},cannot:function(M){return this._fsm.cannot(M)},observe:function(){return this._fsm.observe(arguments)},transitions:function(){return this._fsm.transitions()},allTransitions:function(){return this._fsm.allTransitions()},allStates:function(){return this._fsm.allStates()},onInvalidTransition:function(M,I,x){return this._fsm.onInvalidTransition(M,I,x)},onPendingTransition:function(M,I,x){return this._fsm.onPendingTransition(M,I,x)}},f={state:{configurable:!1,enumerable:!0,get:function(){return this._fsm.state},set:function(M){throw Error("use transitions to change state")}}};function d(M){return h(this||{},M)}function p(){var M,I;typeof arguments[0]=="function"?(M=arguments[0],I=arguments[1]||{}):(M=function(){this._fsm.apply(this,arguments)},I=arguments[0]||{});var x=new o(I,d);return E(M.prototype,x),M.prototype._fsm.config=x,M}function h(M,I){var x=new o(I,d);return E(M,x),M._fsm(),M}function E(M,I){if(typeof M!="object"||Array.isArray(M))throw Error("StateMachine can only be applied to objects");c.build(M,I),Object.defineProperties(M,f),a(M,l),a(M,I.methods),I.allTransitions().forEach(function(x){M[s(x)]=function(){return this._fsm.fire(x,[].slice.call(arguments))}}),M._fsm=function(){this._fsm=new u(this,I),this._fsm.init(arguments)}}d.version="3.0.1",d.factory=p,d.apply=h,d.defaults={wildcard:"*",init:{name:"init",from:"none"}},t.exports=d},function(t,n,i){t.exports=function(a,s,c,o,u){this.message=a,this.transition=s,this.from=c,this.to=o,this.current=u}}])})})(j0);var Rq=j0.exports,Up={exports:{}},F0=typeof ArrayBuffer<"u"&&typeof DataView<"u",$q=F0,em=Yt,Br=Rt,U0=Bt,Ql=tr,ga=rr,tm=Bi,Oq=is,Iq=ji,Bp=Gr,Pq=ci,Aq=Di,Zl=Fl,ho=co,Mq=Gt,xq=fu,B0=kn,q0=B0.enforce,Nq=B0.get,al=Br.Int8Array,qp=al&&al.prototype,Rb=Br.Uint8ClampedArray,$b=Rb&&Rb.prototype,ei=al&&Zl(al),Un=qp&&Zl(qp),Lq=Object.prototype,rm=Br.TypeError,Ob=Mq("toStringTag"),Gp=xq("TYPED_ARRAY_TAG"),sl="TypedArrayConstructor",Ni=$q&&!!ho&&tm(Br.opera)!=="Opera",G0=!1,Zr,oa,Us,Li={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},nm={BigInt64Array:8,BigUint64Array:8},Dq=function(r){if(!Ql(r))return!1;var t=tm(r);return t==="DataView"||ga(Li,t)||ga(nm,t)},z0=function(e){var r=Zl(e);if(Ql(r)){var t=Nq(r);return t&&ga(t,sl)?t[sl]:z0(r)}},W0=function(e){if(!Ql(e))return!1;var r=tm(e);return ga(Li,r)||ga(nm,r)},jq=function(e){if(W0(e))return e;throw rm("Target is not a typed array")},Fq=function(e){if(U0(e)&&(!ho||Aq(ei,e)))return e;throw rm(Oq(e)+" is not a typed array constructor")},Uq=function(e,r,t,n){if(em){if(t)for(var i in Li){var a=Br[i];if(a&&ga(a.prototype,e))try{delete a.prototype[e]}catch{try{a.prototype[e]=r}catch{}}}(!Un[e]||t)&&Bp(Un,e,t?r:Ni&&qp[e]||r,n)}},Bq=function(e,r,t){var n,i;if(em){if(ho){if(t){for(n in Li)if(i=Br[n],i&&ga(i,e))try{delete i[e]}catch{}}if(!ei[e]||t)try{return Bp(ei,e,t?r:Ni&&ei[e]||r)}catch{}else return}for(n in Li)i=Br[n],i&&(!i[e]||t)&&Bp(i,e,r)}};for(Zr in Li)oa=Br[Zr],Us=oa&&oa.prototype,Us?q0(Us)[sl]=oa:Ni=!1;for(Zr in nm)oa=Br[Zr],Us=oa&&oa.prototype,Us&&(q0(Us)[sl]=oa);if((!Ni||!U0(ei)||ei===Function.prototype)&&(ei=function(){throw rm("Incorrect invocation")},Ni))for(Zr in Li)Br[Zr]&&ho(Br[Zr],ei);if((!Ni||!Un||Un===Lq)&&(Un=ei.prototype,Ni))for(Zr in Li)Br[Zr]&&ho(Br[Zr].prototype,Un);Ni&&Zl($b)!==Un&&ho($b,Un);if(em&&!ga(Un,Ob)){G0=!0,Pq(Un,Ob,{configurable:!0,get:function(){return Ql(this)?this[Gp]:void 0}});for(Zr in Li)Br[Zr]&&Iq(Br[Zr],Gp,Zr)}var Ht={NATIVE_ARRAY_BUFFER_VIEWS:Ni,TYPED_ARRAY_TAG:G0&&Gp,aTypedArray:jq,aTypedArrayConstructor:Fq,exportTypedArrayMethod:Uq,exportTypedArrayStaticMethod:Bq,getTypedArrayConstructor:z0,isView:Dq,isTypedArray:W0,TypedArray:ei,TypedArrayPrototype:Un},V0=Rt,Rd=mt,qq=Dl,Gq=Ht.NATIVE_ARRAY_BUFFER_VIEWS,zq=V0.ArrayBuffer,Ua=V0.Int8Array,Wq=!Gq||!Rd(function(){Ua(1)})||!Rd(function(){new Ua(-1)})||!qq(function(e){new Ua,new Ua(null),new Ua(1.5),new Ua(e)},!0)||Rd(function(){return new Ua(new zq(2),1,void 0).length!==1}),Vq=ui,Hq=Fi,Kq=RangeError,H0=function(e){if(e===void 0)return 0;var r=Vq(e),t=Hq(r);if(r!==t)throw Kq("Wrong length or index");return t},Jq=Array,Yq=Math.abs,ki=Math.pow,Xq=Math.floor,Qq=Math.log,Zq=Math.LN2,e6=function(e,r,t){var n=Jq(t),i=t*8-r-1,a=(1<<i)-1,s=a>>1,c=r===23?ki(2,-24)-ki(2,-77):0,o=e<0||e===0&&1/e<0?1:0,u=0,l,f,d;for(e=Yq(e),e!=e||e===1/0?(f=e!=e?1:0,l=a):(l=Xq(Qq(e)/Zq),d=ki(2,-l),e*d<1&&(l--,d*=2),l+s>=1?e+=c/d:e+=c*ki(2,1-s),e*d>=2&&(l++,d/=2),l+s>=a?(f=0,l=a):l+s>=1?(f=(e*d-1)*ki(2,r),l=l+s):(f=e*ki(2,s-1)*ki(2,r),l=0));r>=8;)n[u++]=f&255,f/=256,r-=8;for(l=l<<r|f,i+=r;i>0;)n[u++]=l&255,l/=256,i-=8;return n[--u]|=o*128,n},t6=function(e,r){var t=e.length,n=t*8-r-1,i=(1<<n)-1,a=i>>1,s=n-7,c=t-1,o=e[c--],u=o&127,l;for(o>>=7;s>0;)u=u*256+e[c--],s-=8;for(l=u&(1<<-s)-1,u>>=-s,s+=r;s>0;)l=l*256+e[c--],s-=8;if(u===0)u=1-a;else{if(u===i)return l?NaN:o?-1/0:1/0;l=l+ki(2,r),u=u-a}return(o?-1:1)*l*ki(2,u-r)},r6={pack:e6,unpack:t6},n6=xr,Ib=ss,i6=Ir,K0=function(r){for(var t=n6(this),n=i6(t),i=arguments.length,a=Ib(i>1?arguments[1]:void 0,n),s=i>2?arguments[2]:void 0,c=s===void 0?n:Ib(s,n);c>a;)t[a++]=r;return t},ef=Rt,im=_t,$d=Yt,a6=F0,J0=pu,Pb=ji,s6=ci,Ab=Vv,Od=mt,ac=cs,o6=ui,u6=Fi,ol=H0,Y0=r6,c6=Fl,Mb=co,l6=ba.f,f6=K0,d6=yu,X0=Ui,am=kn,p6=J0.PROPER,xb=J0.CONFIGURABLE,Bs="ArrayBuffer",tf="DataView",qs="prototype",h6="Wrong length",Q0="Wrong index",Nb=am.getterFor(Bs),Ko=am.getterFor(tf),Lb=am.set,bn=ef[Bs],on=bn,bs=on&&on[qs],Qn=ef[tf],Ba=Qn&&Qn[qs],Db=Object.prototype,v6=ef.Array,ul=ef.RangeError,m6=im(f6),g6=im([].reverse),Z0=Y0.pack,jb=Y0.unpack,Fb=function(e){return[e&255]},Ub=function(e){return[e&255,e>>8&255]},Bb=function(e){return[e&255,e>>8&255,e>>16&255,e>>24&255]},qb=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},y6=function(e){return Z0(e,23,4)},b6=function(e){return Z0(e,52,8)},sc=function(e,r,t){s6(e[qs],r,{configurable:!0,get:function(){return t(this)[r]}})},na=function(e,r,t,n){var i=ol(t),a=Ko(e);if(i+r>a.byteLength)throw ul(Q0);var s=a.bytes,c=i+a.byteOffset,o=d6(s,c,c+r);return n?o:g6(o)},ia=function(e,r,t,n,i,a){var s=ol(t),c=Ko(e);if(s+r>c.byteLength)throw ul(Q0);for(var o=c.bytes,u=s+c.byteOffset,l=n(+i),f=0;f<r;f++)o[u+f]=l[a?f:r-f-1]};if(!a6)on=function(r){ac(this,bs);var t=ol(r);Lb(this,{type:Bs,bytes:m6(v6(t),0),byteLength:t}),$d||(this.byteLength=t,this.detached=!1)},bs=on[qs],Qn=function(r,t,n){ac(this,Ba),ac(r,bs);var i=Nb(r),a=i.byteLength,s=o6(t);if(s<0||s>a)throw ul("Wrong offset");if(n=n===void 0?a-s:u6(n),s+n>a)throw ul(h6);Lb(this,{type:tf,buffer:r,byteLength:n,byteOffset:s,bytes:i.bytes}),$d||(this.buffer=r,this.byteLength=n,this.byteOffset=s)},Ba=Qn[qs],$d&&(sc(on,"byteLength",Nb),sc(Qn,"buffer",Ko),sc(Qn,"byteLength",Ko),sc(Qn,"byteOffset",Ko)),Ab(Ba,{getInt8:function(r){return na(this,1,r)[0]<<24>>24},getUint8:function(r){return na(this,1,r)[0]},getInt16:function(r){var t=na(this,2,r,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(r){var t=na(this,2,r,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(r){return qb(na(this,4,r,arguments.length>1?arguments[1]:void 0))},getUint32:function(r){return qb(na(this,4,r,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(r){return jb(na(this,4,r,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(r){return jb(na(this,8,r,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(r,t){ia(this,1,r,Fb,t)},setUint8:function(r,t){ia(this,1,r,Fb,t)},setInt16:function(r,t){ia(this,2,r,Ub,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(r,t){ia(this,2,r,Ub,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(r,t){ia(this,4,r,Bb,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(r,t){ia(this,4,r,Bb,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(r,t){ia(this,4,r,y6,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(r,t){ia(this,8,r,b6,t,arguments.length>2?arguments[2]:void 0)}});else{var Gb=p6&&bn.name!==Bs;if(!Od(function(){bn(1)})||!Od(function(){new bn(-1)})||Od(function(){return new bn,new bn(1.5),new bn(NaN),bn.length!=1||Gb&&!xb})){on=function(r){return ac(this,bs),new bn(ol(r))},on[qs]=bs;for(var zb=l6(bn),Wb=0,Id;zb.length>Wb;)(Id=zb[Wb++])in on||Pb(on,Id,bn[Id]);bs.constructor=on}else Gb&&xb&&Pb(bn,"name",Bs);Mb&&c6(Ba)!==Db&&Mb(Ba,Db);var oc=new Qn(new on(2)),Vb=im(Ba.setInt8);oc.setInt8(0,2147483648),oc.setInt8(1,2147483649),(oc.getInt8(0)||!oc.getInt8(1))&&Ab(Ba,{setInt8:function(r,t){Vb(this,r,t<<24>>24)},setUint8:function(r,t){Vb(this,r,t<<24>>24)}},{unsafe:!0})}X0(on,Bs);X0(Qn,tf);var eE={ArrayBuffer:on,DataView:Qn},_6=ui,S6=RangeError,w6=function(e){var r=_6(e);if(r<0)throw S6("The argument can't be less than 0");return r},T6=w6,C6=RangeError,tE=function(e,r){var t=T6(e);if(t%r)throw C6("Wrong offset");return t},E6=Bi,k6=function(e){var r=E6(e);return r=="BigInt64Array"||r=="BigUint64Array"},R6=Jh,$6=TypeError,rE=function(e){var r=R6(e,"number");if(typeof r=="number")throw $6("Can't convert number to bigint");return BigInt(r)},O6=qi,I6=qt,P6=rv,A6=xr,M6=Ir,x6=Nl,N6=ku,L6=wv,D6=k6,j6=Ht.aTypedArrayConstructor,F6=rE,U6=function(r){var t=P6(this),n=A6(r),i=arguments.length,a=i>1?arguments[1]:void 0,s=a!==void 0,c=N6(n),o,u,l,f,d,p,h,E;if(c&&!L6(c))for(h=x6(n,c),E=h.next,n=[];!(p=I6(E,h)).done;)n.push(p.value);for(s&&i>2&&(a=O6(a,arguments[2])),u=M6(n),l=new(j6(t))(u),f=D6(l),o=0;u>o;o++)d=s?a(n[o],o):n[o],l[o]=f?F6(d):+d;return l},Hb=St,nE=Rt,Kb=qt,B6=Yt,q6=Wq,vo=Ht,iE=eE,Jb=cs,G6=rs,ko=ji,z6=d0,W6=Fi,Yb=H0,Pd=tE,aE=du,Ro=rr,V6=Bi,zp=tr,H6=ao,K6=Sa,J6=Di,uc=co,Y6=ba.f,Xb=U6,X6=fn.forEach,Q6=Al,Z6=ci,sE=qr,oE=ii,sm=kn,e5=Pv,Wp=sm.get,t5=sm.set,r5=sm.enforce,uE=sE.f,n5=oE.f,i5=Math.round,Ad=nE.RangeError,cE=iE.ArrayBuffer,a5=cE.prototype,s5=iE.DataView,cc=vo.NATIVE_ARRAY_BUFFER_VIEWS,Qb=vo.TYPED_ARRAY_TAG,Zb=vo.TypedArray,$o=vo.TypedArrayPrototype,o5=vo.aTypedArrayConstructor,Vp=vo.isTypedArray,lc="BYTES_PER_ELEMENT",Md="Wrong length",e_=function(e,r){o5(e);for(var t=0,n=r.length,i=new e(n);n>t;)i[t]=r[t++];return i},fc=function(e,r){Z6(e,r,{configurable:!0,get:function(){return Wp(this)[r]}})},t_=function(e){var r;return J6(a5,e)||(r=V6(e))=="ArrayBuffer"||r=="SharedArrayBuffer"},lE=function(e,r){return Vp(e)&&!H6(r)&&r in e&&z6(+r)&&r>=0},r_=function(r,t){return t=aE(t),lE(r,t)?G6(2,r[t]):n5(r,t)},n_=function(r,t,n){return t=aE(t),lE(r,t)&&zp(n)&&Ro(n,"value")&&!Ro(n,"get")&&!Ro(n,"set")&&!n.configurable&&(!Ro(n,"writable")||n.writable)&&(!Ro(n,"enumerable")||n.enumerable)?(r[t]=n.value,r):uE(r,t,n)};B6?(cc||(oE.f=r_,sE.f=n_,fc($o,"buffer"),fc($o,"byteOffset"),fc($o,"byteLength"),fc($o,"length")),Hb({target:"Object",stat:!0,forced:!cc},{getOwnPropertyDescriptor:r_,defineProperty:n_}),Up.exports=function(e,r,t){var n=e.match(/\d+/)[0]/8,i=e+(t?"Clamped":"")+"Array",a="get"+e,s="set"+e,c=nE[i],o=c,u=o&&o.prototype,l={},f=function(E,M){var I=Wp(E);return I.view[a](M*n+I.byteOffset,!0)},d=function(E,M,I){var x=Wp(E);t&&(I=(I=i5(I))<0?0:I>255?255:I&255),x.view[s](M*n+x.byteOffset,I,!0)},p=function(E,M){uE(E,M,{get:function(){return f(this,M)},set:function(I){return d(this,M,I)},enumerable:!0})};cc?q6&&(o=r(function(E,M,I,x){return Jb(E,u),e5(function(){return zp(M)?t_(M)?x!==void 0?new c(M,Pd(I,n),x):I!==void 0?new c(M,Pd(I,n)):new c(M):Vp(M)?e_(o,M):Kb(Xb,o,M):new c(Yb(M))}(),E,o)}),uc&&uc(o,Zb),X6(Y6(c),function(E){E in o||ko(o,E,c[E])}),o.prototype=u):(o=r(function(E,M,I,x){Jb(E,u);var j=0,z=0,ie,oe,J;if(!zp(M))J=Yb(M),oe=J*n,ie=new cE(oe);else if(t_(M)){ie=M,z=Pd(I,n);var L=M.byteLength;if(x===void 0){if(L%n||(oe=L-z,oe<0))throw Ad(Md)}else if(oe=W6(x)*n,oe+z>L)throw Ad(Md);J=oe/n}else return Vp(M)?e_(o,M):Kb(Xb,o,M);for(t5(E,{buffer:ie,byteOffset:z,byteLength:oe,length:J,view:new s5(ie)});j<J;)p(E,j++)}),uc&&uc(o,Zb),u=o.prototype=K6($o)),u.constructor!==o&&ko(u,"constructor",o),r5(u).TypedArrayConstructor=o,Qb&&ko(u,Qb,i);var h=o!=c;l[i]=o,Hb({global:!0,constructor:!0,forced:h,sham:!cc},l),lc in o||ko(o,lc,n),lc in u||ko(u,lc,n),Q6(i)}):Up.exports=function(){};var u5=Up.exports,c5=u5;c5("Uint8",function(e){return function(t,n,i){return e(this,t,n,i)}});var i_=is,l5=TypeError,om=function(e,r){if(!delete e[r])throw l5("Cannot delete property "+i_(r)+" of "+i_(e))},f5=xr,xd=ss,d5=Ir,p5=om,h5=Math.min,v5=[].copyWithin||function(r,t){var n=f5(this),i=d5(n),a=xd(r,i),s=xd(t,i),c=arguments.length>2?arguments[2]:void 0,o=h5((c===void 0?i:xd(c,i))-s,i-a),u=1;for(s<a&&a<s+o&&(u=-1,s+=o-1,a+=o-1);o-- >0;)s in n?n[a]=n[s]:p5(n,a),a+=u,s+=u;return n},m5=_t,fE=Ht,g5=v5,y5=m5(g5),b5=fE.aTypedArray,_5=fE.exportTypedArrayMethod;_5("copyWithin",function(r,t){return y5(b5(this),r,t,arguments.length>2?arguments[2]:void 0)});var dE=Ht,S5=fn.every,w5=dE.aTypedArray,T5=dE.exportTypedArrayMethod;T5("every",function(r){return S5(w5(this),r,arguments.length>1?arguments[1]:void 0)});var pE=Ht,C5=K0,E5=rE,k5=Bi,R5=qt,$5=_t,O5=mt,I5=pE.aTypedArray,P5=pE.exportTypedArrayMethod,A5=$5("".slice),M5=O5(function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),e!==1});P5("fill",function(r){var t=arguments.length;I5(this);var n=A5(k5(this),0,3)==="Big"?E5(r):+r;return R5(C5,this,n,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)},M5);var x5=Ir,N5=function(e,r){for(var t=0,n=x5(r),i=new e(n);n>t;)i[t]=r[t++];return i},hE=Ht,L5=hv,D5=hE.aTypedArrayConstructor,j5=hE.getTypedArrayConstructor,rf=function(e){return D5(L5(e,j5(e)))},F5=N5,U5=rf,B5=function(e,r){return F5(U5(e),r)},vE=Ht,q5=fn.filter,G5=B5,z5=vE.aTypedArray,W5=vE.exportTypedArrayMethod;W5("filter",function(r){var t=q5(z5(this),r,arguments.length>1?arguments[1]:void 0);return G5(this,t)});var mE=Ht,V5=fn.find,H5=mE.aTypedArray,K5=mE.exportTypedArrayMethod;K5("find",function(r){return V5(H5(this),r,arguments.length>1?arguments[1]:void 0)});var gE=Ht,J5=fn.findIndex,Y5=gE.aTypedArray,X5=gE.exportTypedArrayMethod;X5("findIndex",function(r){return J5(Y5(this),r,arguments.length>1?arguments[1]:void 0)});var yE=Ht,Q5=fn.forEach,Z5=yE.aTypedArray,eG=yE.exportTypedArrayMethod;eG("forEach",function(r){Q5(Z5(this),r,arguments.length>1?arguments[1]:void 0)});var bE=Ht,tG=wl.includes,rG=bE.aTypedArray,nG=bE.exportTypedArrayMethod;nG("includes",function(r){return tG(rG(this),r,arguments.length>1?arguments[1]:void 0)});var _E=Ht,iG=wl.indexOf,aG=_E.aTypedArray,sG=_E.exportTypedArrayMethod;sG("indexOf",function(r){return iG(aG(this),r,arguments.length>1?arguments[1]:void 0)});var oG=Rt,uG=mt,um=_t,SE=Ht,cm=jC,cG=Gt,lm=cG("iterator"),a_=oG.Uint8Array,lG=um(cm.values),fG=um(cm.keys),dG=um(cm.entries),fm=SE.aTypedArray,nf=SE.exportTypedArrayMethod,$s=a_&&a_.prototype,af=!uG(function(){$s[lm].call([1])}),wE=!!$s&&$s.values&&$s[lm]===$s.values&&$s.values.name==="values",TE=function(){return lG(fm(this))};nf("entries",function(){return dG(fm(this))},af);nf("keys",function(){return fG(fm(this))},af);nf("values",TE,af||!wE,{name:"values"});nf(lm,TE,af||!wE,{name:"values"});var CE=Ht,pG=_t,hG=CE.aTypedArray,vG=CE.exportTypedArrayMethod,mG=pG([].join);vG("join",function(r){return mG(hG(this),r)});var gG=_a,yG=ln,bG=ui,_G=Ir,SG=jl,wG=Math.min,Hp=[].lastIndexOf,EE=!!Hp&&1/[1].lastIndexOf(1,-0)<0,TG=SG("lastIndexOf"),CG=EE||!TG,EG=CG?function(r){if(EE)return gG(Hp,this,arguments)||0;var t=yG(this),n=_G(t),i=n-1;for(arguments.length>1&&(i=wG(i,bG(arguments[1]))),i<0&&(i=n+i);i>=0;i--)if(i in t&&t[i]===r)return i||0;return-1}:Hp,kE=Ht,kG=_a,RG=EG,$G=kE.aTypedArray,OG=kE.exportTypedArrayMethod;OG("lastIndexOf",function(r){var t=arguments.length;return kG(RG,$G(this),t>1?[r,arguments[1]]:[r])});var RE=Ht,IG=fn.map,PG=rf,AG=RE.aTypedArray,MG=RE.exportTypedArrayMethod;MG("map",function(r){return IG(AG(this),r,arguments.length>1?arguments[1]:void 0,function(t,n){return new(PG(t))(n)})});var xG=En,NG=xr,LG=lu,DG=Ir,jG=TypeError,s_=function(e){return function(r,t,n,i){xG(t);var a=NG(r),s=LG(a),c=DG(a),o=e?c-1:0,u=e?-1:1;if(n<2)for(;;){if(o in s){i=s[o],o+=u;break}if(o+=u,e?o<0:c<=o)throw jG("Reduce of empty array with no initial value")}for(;e?o>=0:c>o;o+=u)o in s&&(i=t(i,s[o],o,a));return i}},$E={left:s_(!1),right:s_(!0)},OE=Ht,FG=$E.left,UG=OE.aTypedArray,BG=OE.exportTypedArrayMethod;BG("reduce",function(r){var t=arguments.length;return FG(UG(this),r,t,t>1?arguments[1]:void 0)});var IE=Ht,qG=$E.right,GG=IE.aTypedArray,zG=IE.exportTypedArrayMethod;zG("reduceRight",function(r){var t=arguments.length;return qG(GG(this),r,t,t>1?arguments[1]:void 0)});var PE=Ht,WG=PE.aTypedArray,VG=PE.exportTypedArrayMethod,HG=Math.floor;VG("reverse",function(){for(var r=this,t=WG(r).length,n=HG(t/2),i=0,a;i<n;)a=r[i],r[i++]=r[--t],r[t]=a;return r});var AE=Rt,ME=qt,dm=Ht,KG=Ir,JG=tE,YG=xr,xE=mt,XG=AE.RangeError,Kp=AE.Int8Array,o_=Kp&&Kp.prototype,NE=o_&&o_.set,QG=dm.aTypedArray,ZG=dm.exportTypedArrayMethod,Jp=!xE(function(){var e=new Uint8ClampedArray(2);return ME(NE,e,{length:1,0:3},1),e[1]!==3}),ez=Jp&&dm.NATIVE_ARRAY_BUFFER_VIEWS&&xE(function(){var e=new Kp(2);return e.set(1),e.set("2",1),e[0]!==0||e[1]!==2});ZG("set",function(r){QG(this);var t=JG(arguments.length>1?arguments[1]:void 0,1),n=YG(r);if(Jp)return ME(NE,this,n,t);var i=this.length,a=KG(n),s=0;if(a+t>i)throw XG("Wrong length");for(;s<a;)this[t+s]=n[s++]},!Jp||ez);var LE=Ht,tz=rf,rz=mt,nz=oo,iz=LE.aTypedArray,az=LE.exportTypedArrayMethod,sz=rz(function(){new Int8Array(1).slice()});az("slice",function(r,t){for(var n=nz(iz(this),r,t),i=tz(this),a=0,s=n.length,c=new i(s);s>a;)c[a]=n[a++];return c},sz);var DE=Ht,oz=fn.some,uz=DE.aTypedArray,cz=DE.exportTypedArrayMethod;cz("some",function(r){return oz(uz(this),r,arguments.length>1?arguments[1]:void 0)});var u_=yu,lz=Math.floor,Yp=function(e,r){var t=e.length,n=lz(t/2);return t<8?fz(e,r):dz(e,Yp(u_(e,0,n),r),Yp(u_(e,n),r),r)},fz=function(e,r){for(var t=e.length,n=1,i,a;n<t;){for(a=n,i=e[n];a&&r(e[a-1],i)>0;)e[a]=e[--a];a!==n++&&(e[a]=i)}return e},dz=function(e,r,t,n){for(var i=r.length,a=t.length,s=0,c=0;s<i||c<a;)e[s+c]=s<i&&c<a?n(r[s],t[c])<=0?r[s++]:t[c++]:s<i?r[s++]:t[c++];return e},pm=Yp,pz=ns,c_=pz.match(/firefox\/(\d+)/i),jE=!!c_&&+c_[1],hz=ns,FE=/MSIE|Trident/.test(hz),vz=ns,l_=vz.match(/AppleWebKit\/(\d+)\./),UE=!!l_&&+l_[1],mz=Rt,gz=El,Xp=mt,yz=En,bz=pm,BE=Ht,f_=jE,_z=FE,d_=no,p_=UE,Sz=BE.aTypedArray,wz=BE.exportTypedArrayMethod,iu=mz.Uint16Array,Gs=iu&&gz(iu.prototype.sort),Tz=!!Gs&&!(Xp(function(){Gs(new iu(2),null)})&&Xp(function(){Gs(new iu(2),{})})),h_=!!Gs&&!Xp(function(){if(d_)return d_<74;if(f_)return f_<67;if(_z)return!0;if(p_)return p_<602;var e=new iu(516),r=Array(516),t,n;for(t=0;t<516;t++)n=t%4,e[t]=515-t,r[t]=t-2*n+3;for(Gs(e,function(i,a){return(i/4|0)-(a/4|0)}),t=0;t<516;t++)if(e[t]!==r[t])return!0}),Cz=function(e){return function(r,t){return e!==void 0?+e(r,t)||0:t!==t?-1:r!==r?1:r===0&&t===0?1/r>0&&1/t<0?1:-1:r>t}};wz("sort",function(r){return r!==void 0&&yz(r),h_?Gs(this,r):bz(Sz(this),Cz(r))},!h_||Tz);var qE=Ht,Ez=Fi,v_=ss,kz=rf,Rz=qE.aTypedArray,$z=qE.exportTypedArrayMethod;$z("subarray",function(r,t){var n=Rz(this),i=n.length,a=v_(r,i),s=kz(n);return new s(n.buffer,n.byteOffset+a*n.BYTES_PER_ELEMENT,Ez((t===void 0?i:v_(t,i))-a))});var Oz=Rt,Iz=_a,GE=Ht,Qp=mt,m_=oo,cl=Oz.Int8Array,g_=GE.aTypedArray,Pz=GE.exportTypedArrayMethod,zE=[].toLocaleString,Az=!!cl&&Qp(function(){zE.call(new cl(1))}),Mz=Qp(function(){return[1,2].toLocaleString()!=new cl([1,2]).toLocaleString()})||!Qp(function(){cl.prototype.toLocaleString.call([1,2])});Pz("toLocaleString",function(){return Iz(zE,Az?m_(g_(this)):g_(this),m_(arguments))},Mz);var xz=Ht.exportTypedArrayMethod,Nz=mt,Lz=Rt,Dz=_t,y_=Lz.Uint8Array,jz=y_&&y_.prototype||{},ll=[].toString,Fz=Dz([].join);Nz(function(){ll.call({})})&&(ll=function(){return Fz(this)});var Uz=jz.toString!=ll;xz("toString",ll,Uz);var Bz=tr,qz=ai,Gz=Gt,zz=Gz("match"),WE=function(e){var r;return Bz(e)&&((r=e[zz])!==void 0?!!r:qz(e)=="RegExp")},Wz=_a,Oo=qt,hm=_t,Vz=zl,Hz=sr,Kz=si,Jz=WE,b_=oi,Yz=hv,Xz=Dv,Qz=Fi,Nd=br,Zz=as,__=yu,S_=Wl,eW=Gl,tW=KC,rW=mt,_s=tW.UNSUPPORTED_Y,w_=4294967295,nW=Math.min,VE=[].push,iW=hm(/./.exec),Ss=hm(VE),Io=hm("".slice),aW=!rW(function(){var e=/(?:)/,r=e.exec;e.exec=function(){return r.apply(this,arguments)};var t="ab".split(e);return t.length!==2||t[0]!=="a"||t[1]!=="b"});Vz("split",function(e,r,t){var n;return"abbc".split(/(b)*/)[1]=="c"||"test".split(/(?:)/,-1).length!=4||"ab".split(/(?:ab)*/).length!=2||".".split(/(.?)(.?)/).length!=4||".".split(/()()/).length>1||"".split(/.?/).length?n=function(i,a){var s=Nd(b_(this)),c=a===void 0?w_:a>>>0;if(c===0)return[];if(i===void 0)return[s];if(!Jz(i))return Oo(r,s,i,c);for(var o=[],u=(i.ignoreCase?"i":"")+(i.multiline?"m":"")+(i.unicode?"u":"")+(i.sticky?"y":""),l=0,f=new RegExp(i.source,u+"g"),d,p,h;(d=Oo(eW,f,s))&&(p=f.lastIndex,!(p>l&&(Ss(o,Io(s,l,d.index)),d.length>1&&d.index<s.length&&Wz(VE,o,__(d,1)),h=d[0].length,l=p,o.length>=c)));)f.lastIndex===d.index&&f.lastIndex++;return l===s.length?(h||!iW(f,""))&&Ss(o,""):Ss(o,Io(s,l)),o.length>c?__(o,0,c):o}:"0".split(void 0,0).length?n=function(i,a){return i===void 0&&a===0?[]:Oo(r,this,i,a)}:n=r,[function(a,s){var c=b_(this),o=Kz(a)?void 0:Zz(a,e);return o?Oo(o,a,c,s):Oo(n,Nd(c),a,s)},function(i,a){var s=Hz(this),c=Nd(i),o=t(n,s,c,a,n!==r);if(o.done)return o.value;var u=Yz(s,RegExp),l=s.unicode,f=(s.ignoreCase?"i":"")+(s.multiline?"m":"")+(s.unicode?"u":"")+(_s?"g":"y"),d=new u(_s?"^(?:"+s.source+")":s,f),p=a===void 0?w_:a>>>0;if(p===0)return[];if(c.length===0)return S_(d,c)===null?[c]:[];for(var h=0,E=0,M=[];E<c.length;){d.lastIndex=_s?0:E;var I=S_(d,_s?Io(c,E):c),x;if(I===null||(x=nW(Qz(d.lastIndex+(_s?E:0)),c.length))===h)E=Xz(c,E,l);else{if(Ss(M,Io(c,h,E)),M.length===p)return M;for(var j=1;j<=I.length-1;j++)if(Ss(M,I[j]),M.length===p)return M;E=h=x}}return Ss(M,Io(c,h)),M}]},!aW,_s);var HE={exports:{}},KE={exports:{}};(function(e){function r(t){return Function.toString.call(t).indexOf("[native code]")!==-1}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(KE);var sW=KE.exports,JE={exports:{}},YE={exports:{}};(function(e){function r(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(YE);var oW=YE.exports;(function(e){var r=pv,t=oW;function n(i,a,s){return t()?(e.exports=n=Reflect.construct.bind(),e.exports.__esModule=!0,e.exports.default=e.exports):(e.exports=n=function(o,u,l){var f=[null];f.push.apply(f,u);var d=Function.bind.apply(o,f),p=new d;return l&&r(p,l.prototype),p},e.exports.__esModule=!0,e.exports.default=e.exports),n.apply(null,arguments)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports})(JE);var uW=JE.exports;(function(e){var r=$n,t=pv,n=sW,i=uW;function a(s){var c=typeof Map=="function"?new Map:void 0;return e.exports=a=function(u){if(u===null||!n(u))return u;if(typeof u!="function")throw new TypeError("Super expression must either be null or a function");if(typeof c<"u"){if(c.has(u))return c.get(u);c.set(u,l)}function l(){return i(u,arguments,r(this).constructor)}return l.prototype=Object.create(u.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}),t(l,u)},e.exports.__esModule=!0,e.exports.default=e.exports,a(s)}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports})(HE);var sf=HE.exports,fl={exports:{}};/*!
|
|
71
|
+
* Platform.js v1.3.6
|
|
72
|
+
* Copyright 2014-2020 Benjamin Tan
|
|
73
|
+
* Copyright 2011-2013 John-David Dalton
|
|
74
|
+
* Available under MIT license
|
|
75
|
+
*/fl.exports;(function(e,r){(function(){var t={function:!0,object:!0},n=t[typeof window]&&window||this,i=r,a=e&&!e.nodeType&&e,s=i&&a&&typeof ze=="object"&&ze;s&&(s.global===s||s.window===s||s.self===s)&&(n=s);var c=Math.pow(2,53)-1,o=/\bOpera/,u=Object.prototype,l=u.hasOwnProperty,f=u.toString;function d(L){return L=String(L),L.charAt(0).toUpperCase()+L.slice(1)}function p(L,Y,Z){var ye={"10.0":"10","6.4":"10 Technical Preview","6.3":"8.1","6.2":"8","6.1":"Server 2008 R2 / 7","6.0":"Server 2008 / Vista","5.2":"Server 2003 / XP 64-bit","5.1":"XP","5.01":"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return Y&&Z&&/^Win/i.test(L)&&!/^Windows Phone /i.test(L)&&(ye=ye[/[\d.]+$/.exec(L)])&&(L="Windows "+ye),L=String(L),Y&&Z&&(L=L.replace(RegExp(Y,"i"),Z)),L=E(L.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0]),L}function h(L,Y){var Z=-1,ye=L?L.length:0;if(typeof ye=="number"&&ye>-1&&ye<=c)for(;++Z<ye;)Y(L[Z],Z,L);else M(L,Y)}function E(L){return L=ie(L),/^(?:webOS|i(?:OS|P))/.test(L)?L:d(L)}function M(L,Y){for(var Z in L)l.call(L,Z)&&Y(L[Z],Z,L)}function I(L){return L==null?d(L):f.call(L).slice(8,-1)}function x(L,Y){var Z=L!=null?typeof L[Y]:"number";return!/^(?:boolean|number|string|undefined)$/.test(Z)&&(Z=="object"?!!L[Y]:!0)}function j(L){return String(L).replace(/([ -])(?!$)/g,"$1?")}function z(L,Y){var Z=null;return h(L,function(ye,Re){Z=Y(Z,ye,Re,L)}),Z}function ie(L){return String(L).replace(/^ +| +$/g,"")}function oe(L){var Y=n,Z=L&&typeof L=="object"&&I(L)!="String";Z&&(Y=L,L=null);var ye=Y.navigator||{},Re=ye.userAgent||"";L||(L=Re);var ae=Z?!!ye.likeChrome:/\bChrome\b/.test(L)&&!/internal|\n/i.test(f.toString()),Ve="Object",be=Z?Ve:"ScriptBridgingProxyObject",Te=Z?Ve:"Environment",we=Z&&Y.java?"JavaPackage":I(Y.java),ge=Z?Ve:"RuntimeObject",$e=/\bJava/.test(we)&&Y.java,De=$e&&I(Y.environment)==Te,G=$e?"a":"α",Qe=$e?"b":"β",Et=Y.document||{},ut=Y.operamini||Y.opera,je=o.test(je=Z&&ut?ut["[[Class]]"]:I(ut))?je:ut=null,te,ur=L,Me=[],fe=null,Pt=L==Re,We=Pt&&ut&&typeof ut.version=="function"&&ut.version(),Kt,gt=Jt([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"]),xe=zt(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"(?:Edge|Edg|EdgA|EdgiOS)"},"Midori","Nook Browser","PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Vivaldi","Waterfox","WebPositive",{label:"Yandex Browser",pattern:"YaBrowser"},{label:"UC Browser",pattern:"UCBrowser"},"Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chromium","Chrome",{label:"Chrome",pattern:"(?:HeadlessChrome)"},{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"]),ft=He([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad","iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),Tt=vt({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}}),Le=nr(["Windows Phone","KaiOS","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian",{label:"DragonFly BSD",pattern:"DragonFly"},"Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac","Windows 98;","Windows "]);function Jt(kt){return z(kt,function(yt,st){return yt||RegExp("\\b"+(st.pattern||j(st))+"\\b","i").exec(L)&&(st.label||st)})}function vt(kt){return z(kt,function(yt,st,Lt){return yt||(st[ft]||st[/^[a-z]+(?: +[a-z]+\b)*/i.exec(ft)]||RegExp("\\b"+j(Lt)+"(?:\\b|\\w*\\d)","i").exec(L))&&Lt})}function zt(kt){return z(kt,function(yt,st){return yt||RegExp("\\b"+(st.pattern||j(st))+"\\b","i").exec(L)&&(st.label||st)})}function nr(kt){return z(kt,function(yt,st){var Lt=st.pattern||j(st);return!yt&&(yt=RegExp("\\b"+Lt+"(?:/[\\d.]+|[ \\w.]*)","i").exec(L))&&(yt=p(yt,Lt,st.label||st)),yt})}function He(kt){return z(kt,function(yt,st){var Lt=st.pattern||j(st);return!yt&&(yt=RegExp("\\b"+Lt+" *\\d+[.\\w_]*","i").exec(L)||RegExp("\\b"+Lt+" *\\w+-[\\w]*","i").exec(L)||RegExp("\\b"+Lt+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(L))&&((yt=String(st.label&&!RegExp(Lt,"i").test(st.label)?st.label:yt).split("/"))[1]&&!/[\d.]+/.test(yt[0])&&(yt[0]+=" "+yt[1]),st=st.label||st,yt=E(yt[0].replace(RegExp(Lt,"i"),st).replace(RegExp("; *(?:"+st+"[_-])?","i")," ").replace(RegExp("("+st+")[-_.]?(\\w)","i"),"$1 $2"))),yt})}function Pr(kt){return z(kt,function(yt,st){return yt||(RegExp(st+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(L)||0)[1]||null})}function Cr(){return this.description||""}if(gt&&(gt=[gt]),/\bAndroid\b/.test(Le)&&!ft&&(te=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(L))&&(ft=ie(te[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),Tt&&!ft?ft=He([Tt]):Tt&&ft&&(ft=ft.replace(RegExp("^("+j(Tt)+")[-_.\\s]","i"),Tt+" ").replace(RegExp("^("+j(Tt)+")[-_.]?(\\w)","i"),Tt+" $2")),(te=/\bGoogle TV\b/.exec(ft))&&(ft=te[0]),/\bSimulator\b/i.test(L)&&(ft=(ft?ft+" ":"")+"Simulator"),xe=="Opera Mini"&&/\bOPiOS\b/.test(L)&&Me.push("running in Turbo/Uncompressed mode"),xe=="IE"&&/\blike iPhone OS\b/.test(L)?(te=oe(L.replace(/like iPhone OS/,"")),Tt=te.manufacturer,ft=te.product):/^iP/.test(ft)?(xe||(xe="Safari"),Le="iOS"+((te=/ OS ([\d_]+)/i.exec(L))?" "+te[1].replace(/_/g,"."):"")):xe=="Konqueror"&&/^Linux\b/i.test(Le)?Le="Kubuntu":Tt&&Tt!="Google"&&(/Chrome/.test(xe)&&!/\bMobile Safari\b/i.test(L)||/\bVita\b/.test(ft))||/\bAndroid\b/.test(Le)&&/^Chrome/.test(xe)&&/\bVersion\//i.test(L)?(xe="Android Browser",Le=/\bAndroid\b/.test(Le)?Le:"Android"):xe=="Silk"?(/\bMobi/i.test(L)||(Le="Android",Me.unshift("desktop mode")),/Accelerated *= *true/i.test(L)&&Me.unshift("accelerated")):xe=="UC Browser"&&/\bUCWEB\b/.test(L)?Me.push("speed mode"):xe=="PaleMoon"&&(te=/\bFirefox\/([\d.]+)\b/.exec(L))?Me.push("identifying as Firefox "+te[1]):xe=="Firefox"&&(te=/\b(Mobile|Tablet|TV)\b/i.exec(L))?(Le||(Le="Firefox OS"),ft||(ft=te[1])):!xe||(te=!/\bMinefield\b/i.test(L)&&/\b(?:Firefox|Safari)\b/.exec(xe))?(xe&&!ft&&/[\/,]|^[^(]+?\)/.test(L.slice(L.indexOf(te+"/")+8))&&(xe=null),(te=ft||Tt||Le)&&(ft||Tt||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(Le))&&(xe=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(Le)?Le:te)+" Browser")):xe=="Electron"&&(te=(/\bChrome\/([\d.]+)\b/.exec(L)||0)[1])&&Me.push("Chromium "+te),We||(We=Pr(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",j(xe),"(?:Firefox|Minefield|NetFront)"])),(te=gt=="iCab"&&parseFloat(We)>3&&"WebKit"||/\bOpera\b/.test(xe)&&(/\bOPR\b/.test(L)?"Blink":"Presto")||/\b(?:Midori|Nook|Safari)\b/i.test(L)&&!/^(?:Trident|EdgeHTML)$/.test(gt)&&"WebKit"||!gt&&/\bMSIE\b/i.test(L)&&(Le=="Mac OS"?"Tasman":"Trident")||gt=="WebKit"&&/\bPlayStation\b(?! Vita\b)/i.test(xe)&&"NetFront")&&(gt=[te]),xe=="IE"&&(te=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(L)||0)[1])?(xe+=" Mobile",Le="Windows Phone "+(/\+$/.test(te)?te:te+".x"),Me.unshift("desktop mode")):/\bWPDesktop\b/i.test(L)?(xe="IE Mobile",Le="Windows Phone 8.x",Me.unshift("desktop mode"),We||(We=(/\brv:([\d.]+)/.exec(L)||0)[1])):xe!="IE"&>=="Trident"&&(te=/\brv:([\d.]+)/.exec(L))&&(xe&&Me.push("identifying as "+xe+(We?" "+We:"")),xe="IE",We=te[1]),Pt){if(x(Y,"global"))if($e&&(te=$e.lang.System,ur=te.getProperty("os.arch"),Le=Le||te.getProperty("os.name")+" "+te.getProperty("os.version")),De){try{We=Y.require("ringo/engine").version.join("."),xe="RingoJS"}catch{(te=Y.system)&&te.global.system==Y.system&&(xe="Narwhal",Le||(Le=te[0].os||null))}xe||(xe="Rhino")}else typeof Y.process=="object"&&!Y.process.browser&&(te=Y.process)&&(typeof te.versions=="object"&&(typeof te.versions.electron=="string"?(Me.push("Node "+te.versions.node),xe="Electron",We=te.versions.electron):typeof te.versions.nw=="string"&&(Me.push("Chromium "+We,"Node "+te.versions.node),xe="NW.js",We=te.versions.nw)),xe||(xe="Node.js",ur=te.arch,Le=te.platform,We=/[\d.]+/.exec(te.version),We=We?We[0]:null));else I(te=Y.runtime)==be?(xe="Adobe AIR",Le=te.flash.system.Capabilities.os):I(te=Y.phantom)==ge?(xe="PhantomJS",We=(te=te.version||null)&&te.major+"."+te.minor+"."+te.patch):typeof Et.documentMode=="number"&&(te=/\bTrident\/(\d+)/i.exec(L))?(We=[We,Et.documentMode],(te=+te[1]+4)!=We[1]&&(Me.push("IE "+We[1]+" mode"),gt&&(gt[1]=""),We[1]=te),We=xe=="IE"?String(We[1].toFixed(1)):We[0]):typeof Et.documentMode=="number"&&/^(?:Chrome|Firefox)\b/.test(xe)&&(Me.push("masking as "+xe+" "+We),xe="IE",We="11.0",gt=["Trident"],Le="Windows");Le=Le&&E(Le)}if(We&&(te=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(We)||/(?:alpha|beta)(?: ?\d)?/i.exec(L+";"+(Pt&&ye.appMinorVersion))||/\bMinefield\b/i.test(L)&&"a")&&(fe=/b/i.test(te)?"beta":"alpha",We=We.replace(RegExp(te+"\\+?$"),"")+(fe=="beta"?Qe:G)+(/\d+\+?/.exec(te)||"")),xe=="Fennec"||xe=="Firefox"&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(Le))xe="Firefox Mobile";else if(xe=="Maxthon"&&We)We=We.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(ft))ft=="Xbox 360"&&(Le=null),ft=="Xbox 360"&&/\bIEMobile\b/.test(L)&&Me.unshift("mobile mode");else if((/^(?:Chrome|IE|Opera)$/.test(xe)||xe&&!ft&&!/Browser|Mobi/.test(xe))&&(Le=="Windows CE"||/Mobi/i.test(L)))xe+=" Mobile";else if(xe=="IE"&&Pt)try{Y.external===null&&Me.unshift("platform preview")}catch{Me.unshift("embedded")}else(/\bBlackBerry\b/.test(ft)||/\bBB10\b/.test(L))&&(te=(RegExp(ft.replace(/ +/g," *")+"/([.\\d]+)","i").exec(L)||0)[1]||We)?(te=[te,/BB10/.test(L)],Le=(te[1]?(ft=null,Tt="BlackBerry"):"Device Software")+" "+te[0],We=null):this!=M&&ft!="Wii"&&(Pt&&ut||/Opera/.test(xe)&&/\b(?:MSIE|Firefox)\b/i.test(L)||xe=="Firefox"&&/\bOS X (?:\d+\.){2,}/.test(Le)||xe=="IE"&&(Le&&!/^Win/.test(Le)&&We>5.5||/\bWindows XP\b/.test(Le)&&We>8||We==8&&!/\bTrident\b/.test(L)))&&!o.test(te=oe.call(M,L.replace(o,"")+";"))&&te.name&&(te="ing as "+te.name+((te=te.version)?" "+te:""),o.test(xe)?(/\bIE\b/.test(te)&&Le=="Mac OS"&&(Le=null),te="identify"+te):(te="mask"+te,je?xe=E(je.replace(/([a-z])([A-Z])/g,"$1 $2")):xe="Opera",/\bIE\b/.test(te)&&(Le=null),Pt||(We=null)),gt=["Presto"],Me.push(te));(te=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(L)||0)[1])&&(te=[parseFloat(te.replace(/\.(\d)$/,".0$1")),te],xe=="Safari"&&te[1].slice(-1)=="+"?(xe="WebKit Nightly",fe="alpha",We=te[1].slice(0,-1)):(We==te[1]||We==(te[2]=(/\bSafari\/([\d.]+\+?)/i.exec(L)||0)[1]))&&(We=null),te[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(L)||0)[1],te[0]==537.36&&te[2]==537.36&&parseFloat(te[1])>=28&>=="WebKit"&&(gt=["Blink"]),!Pt||!ae&&!te[1]?(gt&&(gt[1]="like Safari"),te=(te=te[0],te<400?1:te<500?2:te<526?3:te<533?4:te<534?"4+":te<535?5:te<537?6:te<538?7:te<601?8:te<602?9:te<604?10:te<606?11:te<608?12:"12")):(gt&&(gt[1]="like Chrome"),te=te[1]||(te=te[0],te<530?1:te<532?2:te<532.05?3:te<533?4:te<534.03?5:te<534.07?6:te<534.1?7:te<534.13?8:te<534.16?9:te<534.24?10:te<534.3?11:te<535.01?12:te<535.02?"13+":te<535.07?15:te<535.11?16:te<535.19?17:te<536.05?18:te<536.1?19:te<537.01?20:te<537.11?"21+":te<537.13?23:te<537.18?24:te<537.24?25:te<537.36?26:gt!="Blink"?"27":"28")),gt&&(gt[1]+=" "+(te+=typeof te=="number"?".x":/[.+]/.test(te)?"":"+")),xe=="Safari"&&(!We||parseInt(We)>45)?We=te:xe=="Chrome"&&/\bHeadlessChrome/i.test(L)&&Me.unshift("headless")),xe=="Opera"&&(te=/\bzbov|zvav$/.exec(Le))?(xe+=" ",Me.unshift("desktop mode"),te=="zvav"?(xe+="Mini",We=null):xe+="Mobile",Le=Le.replace(RegExp(" *"+te+"$"),"")):xe=="Safari"&&/\bChrome\b/.exec(gt&>[1])?(Me.unshift("desktop mode"),xe="Chrome Mobile",We=null,/\bOS X\b/.test(Le)?(Tt="Apple",Le="iOS 4.3+"):Le=null):/\bSRWare Iron\b/.test(xe)&&!We&&(We=Pr("Chrome")),We&&We.indexOf(te=/[\d.]+$/.exec(Le))==0&&L.indexOf("/"+te+"-")>-1&&(Le=ie(Le.replace(te,""))),Le&&Le.indexOf(xe)!=-1&&!RegExp(xe+" OS").test(Le)&&(Le=Le.replace(RegExp(" *"+j(xe)+" *"),"")),gt&&!/\b(?:Avant|Nook)\b/.test(xe)&&(/Browser|Lunascape|Maxthon/.test(xe)||xe!="Safari"&&/^iOS/.test(Le)&&/\bSafari\b/.test(gt[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(xe)&>[1])&&(te=gt[gt.length-1])&&Me.push(te),Me.length&&(Me=["("+Me.join("; ")+")"]),Tt&&ft&&ft.indexOf(Tt)<0&&Me.push("on "+Tt),ft&&Me.push((/^on /.test(Me[Me.length-1])?"":"on ")+ft),Le&&(te=/ ([\d.+]+)$/.exec(Le),Kt=te&&Le.charAt(Le.length-te[0].length-1)=="/",Le={architecture:32,family:te&&!Kt?Le.replace(te[0],""):Le,version:te?te[1]:null,toString:function(){var kt=this.version;return this.family+(kt&&!Kt?" "+kt:"")+(this.architecture==64?" 64-bit":"")}}),(te=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(ur))&&!/\bi686\b/i.test(ur)?(Le&&(Le.architecture=64,Le.family=Le.family.replace(RegExp(" *"+te),"")),xe&&(/\bWOW64\b/i.test(L)||Pt&&/\w(?:86|32)$/.test(ye.cpuClass||ye.platform)&&!/\bWin64; x64\b/i.test(L))&&Me.unshift("32-bit")):Le&&/^OS X/.test(Le.family)&&xe=="Chrome"&&parseFloat(We)>=39&&(Le.architecture=64),L||(L=null);var Ct={};return Ct.description=L,Ct.layout=gt&>[0],Ct.manufacturer=Tt,Ct.name=xe,Ct.prerelease=fe,Ct.product=ft,Ct.ua=L,Ct.version=xe&&We,Ct.os=Le||{architecture:null,family:null,version:null,toString:function(){return"null"}},Ct.parse=oe,Ct.toString=Cr,Ct.version&&Me.unshift(We),Ct.name&&Me.unshift(xe),Le&&xe&&!(Le==String(Le).split(" ")[0]&&(Le==xe.split(" ")[0]||ft))&&Me.push(ft?"("+Le+")":"on "+Le),Me.length&&(Ct.description=Me.join(" ")),Ct}var J=oe();i&&a?M(J,function(L,Y){i[Y]=L}):n.platform=J}).call(ze)})(fl,fl.exports);var XE=fl.exports,cW=qt,lW=zl,fW=sr,dW=si,pW=Fi,Ld=br,hW=oi,vW=as,mW=Dv,T_=Wl;lW("match",function(e,r,t){return[function(i){var a=hW(this),s=dW(i)?void 0:vW(i,e);return s?cW(s,i,a):new RegExp(i)[e](Ld(a))},function(n){var i=fW(this),a=Ld(n),s=t(r,i,a);if(s.done)return s.value;if(!i.global)return T_(i,a);var c=i.unicode;i.lastIndex=0;for(var o=[],u=0,l;(l=T_(i,a))!==null;){var f=Ld(l[0]);o[u]=f,f===""&&(i.lastIndex=mW(a,pW(i.lastIndex),c)),u++}return u===0?null:o}]});var gW=Object.is||function(r,t){return r===t?r!==0||1/r===1/t:r!=r&&t!=t},yW=qt,bW=zl,_W=sr,SW=si,wW=oi,C_=gW,E_=br,TW=as,CW=Wl;bW("search",function(e,r,t){return[function(i){var a=wW(this),s=SW(i)?void 0:TW(i,e);return s?yW(s,i,a):new RegExp(i)[e](E_(a))},function(n){var i=_W(this),a=E_(n),s=t(r,i,a);if(s.done)return s.value;var c=i.lastIndex;C_(c,0)||(i.lastIndex=0);var o=CW(i,a);return C_(i.lastIndex,c)||(i.lastIndex=c),o===null?-1:o.index}]});var EW=Yt,kW=bu,RW=TypeError,$W=Object.getOwnPropertyDescriptor,OW=EW&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}(),IW=OW?function(e,r){if(kW(e)&&!$W(e,"length").writable)throw RW("Cannot set read only .length");return e.length=r}:function(e,r){return e.length=r},PW=St,AW=xr,MW=ss,xW=ui,NW=Ir,LW=IW,DW=TC,jW=ov,FW=uo,Dd=om,UW=wu,BW=UW("splice"),qW=Math.max,GW=Math.min;PW({target:"Array",proto:!0,forced:!BW},{splice:function(r,t){var n=AW(this),i=NW(n),a=MW(r,i),s=arguments.length,c,o,u,l,f,d;for(s===0?c=o=0:s===1?(c=0,o=i-a):(c=s-2,o=GW(qW(xW(t),0),i-a)),DW(i+c-o),u=jW(n,o),l=0;l<o;l++)f=a+l,f in n&&FW(u,l,n[f]);if(u.length=o,c<o){for(l=a;l<i-o;l++)f=l+o,d=l+c,f in n?n[d]=n[f]:Dd(n,d);for(l=i;l>i-o+c;l--)Dd(n,l-1)}else if(c>o)for(l=i-o;l>a;l--)f=l+o-1,d=l+c-1,f in n?n[d]=n[f]:Dd(n,d);for(l=0;l<c;l++)n[l+a]=arguments[l+2];return LW(n,i-o+c),u}});/*
|
|
76
|
+
@license
|
|
77
|
+
The following license applies to all parts of this software except as
|
|
78
|
+
documented below.
|
|
79
|
+
|
|
80
|
+
Copyright (c) 2016, Twilio, inc.
|
|
81
|
+
All rights reserved.
|
|
82
|
+
|
|
83
|
+
Redistribution and use in source and binary forms, with or without
|
|
84
|
+
modification, are permitted provided that the following conditions are
|
|
85
|
+
met:
|
|
86
|
+
|
|
87
|
+
1. Redistributions of source code must retain the above copyright
|
|
88
|
+
notice, this list of conditions and the following disclaimer.
|
|
89
|
+
|
|
90
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
91
|
+
notice, this list of conditions and the following disclaimer in
|
|
92
|
+
the documentation and/or other materials provided with the
|
|
93
|
+
distribution.
|
|
94
|
+
|
|
95
|
+
3. Neither the name of Twilio nor the names of its contributors may
|
|
96
|
+
be used to endorse or promote products derived from this software
|
|
97
|
+
without specific prior written permission.
|
|
98
|
+
|
|
99
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
100
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
101
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
102
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
103
|
+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
104
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
105
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
106
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
107
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
108
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
109
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
110
|
+
|
|
111
|
+
This software includes javascript-state-machine under the following license.
|
|
112
|
+
|
|
113
|
+
Copyright (c) 2012, 2013, 2014, 2015, Jake Gordon and contributors
|
|
114
|
+
|
|
115
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
116
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
117
|
+
in the Software without restriction, including without limitation the rights
|
|
118
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
119
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
120
|
+
furnished to do so, subject to the following conditions:
|
|
121
|
+
|
|
122
|
+
The above copyright notice and this permission notice shall be included in all
|
|
123
|
+
copies or substantial portions of the Software.
|
|
124
|
+
|
|
125
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
126
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
127
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
128
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
129
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
130
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
131
|
+
|
|
132
|
+
This software includes loglevel under the following license.
|
|
133
|
+
|
|
134
|
+
Copyright (c) 2013 Tim Perry
|
|
135
|
+
|
|
136
|
+
Permission is hereby granted, free of charge, to any person
|
|
137
|
+
obtaining a copy of this software and associated documentation
|
|
138
|
+
files (the "Software"), to deal in the Software without
|
|
139
|
+
restriction, including without limitation the rights to use,
|
|
140
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
141
|
+
copies of the Software, and to permit persons to whom the
|
|
142
|
+
Software is furnished to do so, subject to the following
|
|
143
|
+
conditions:
|
|
144
|
+
|
|
145
|
+
The above copyright notice and this permission notice shall be
|
|
146
|
+
included in all copies or substantial portions of the Software.
|
|
147
|
+
|
|
148
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
149
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
150
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
151
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
152
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
153
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
154
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
155
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
*/(function(e){var r=typeof r<"u"?r:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(e,"__esModule",{value:!0});var t=Tu,n=wa,i=os,a=Bv,s=li,c=fi,o=$n,u=di,l=us,f=Ru,d=Rn,p=zr,h=pr,E=Rq,M=ou,I=sf,x=Wi,j=XE;function z(F){return F&&typeof F=="object"&&"default"in F?F:{default:F}}function ie(F){if(F&&F.__esModule)return F;var q=Object.create(null);return F&&Object.keys(F).forEach(function(P){if(P!=="default"){var O=Object.getOwnPropertyDescriptor(F,P);Object.defineProperty(q,P,O.get?O:{enumerable:!0,get:function(){return F[P]}})}}),q.default=F,Object.freeze(q)}var oe=z(t),J=z(n),L=z(i),Y=z(a),Z=z(s),ye=z(c),Re=z(o),ae=z(u),Ve=z(l),be=z(f),Te=z(d),we=ie(h),ge=ie(E),$e=z(I),De=ie(j);function G(F,q,P,O){var R=arguments.length,U=R<3?q:O===null?O=Object.getOwnPropertyDescriptor(q,P):O,N;if((typeof Reflect>"u"?"undefined":Te.default(Reflect))==="object"&&typeof Reflect.decorate=="function")U=Reflect.decorate(F,q,P,O);else for(var me=F.length-1;me>=0;me--)(N=F[me])&&(U=(R<3?N(U):R>3?N(q,P,U):N(q,P))||U);return R>3&&U&&Object.defineProperty(q,P,U),U}function Qe(F,q){if((typeof Reflect>"u"?"undefined":Te.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(F,q)}var Et;function ut(){}ut.prototype=Object.create(null);function je(){je.init.call(this)}je.EventEmitter=je,je.usingDomains=!1,je.prototype.domain=void 0,je.prototype._events=void 0,je.prototype._maxListeners=void 0,je.defaultMaxListeners=10,je.init=function(){this.domain=null,je.usingDomains&&Et.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new ut,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},je.prototype.setMaxListeners=function(q){if(typeof q!="number"||q<0||isNaN(q))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=q,this};function te(F){return F._maxListeners===void 0?je.defaultMaxListeners:F._maxListeners}je.prototype.getMaxListeners=function(){return te(this)};function ur(F,q,P){if(q)F.call(P);else for(var O=F.length,R=Le(F,O),U=0;U<O;++U)R[U].call(P)}function Me(F,q,P,O){if(q)F.call(P,O);else for(var R=F.length,U=Le(F,R),N=0;N<R;++N)U[N].call(P,O)}function fe(F,q,P,O,R){if(q)F.call(P,O,R);else for(var U=F.length,N=Le(F,U),me=0;me<U;++me)N[me].call(P,O,R)}function Pt(F,q,P,O,R,U){if(q)F.call(P,O,R,U);else for(var N=F.length,me=Le(F,N),pe=0;pe<N;++pe)me[pe].call(P,O,R,U)}function We(F,q,P,O){if(q)F.apply(P,O);else for(var R=F.length,U=Le(F,R),N=0;N<R;++N)U[N].apply(P,O)}je.prototype.emit=function(q){var P,O,R,U,N,me,pe,Ae=q==="error";if(me=this._events,me)Ae=Ae&&me.error==null;else if(!Ae)return!1;if(pe=this.domain,Ae){if(P=arguments[1],pe)P||(P=new Error('Uncaught, unspecified "error" event')),P.domainEmitter=this,P.domain=pe,P.domainThrown=!1,pe.emit("error",P);else{if(P instanceof Error)throw P;var qe=new Error('Uncaught, unspecified "error" event. ('+P+")");throw qe.context=P,qe}return!1}if(O=me[q],!O)return!1;var at=typeof O=="function";switch(R=arguments.length,R){case 1:ur(O,at,this);break;case 2:Me(O,at,this,arguments[1]);break;case 3:fe(O,at,this,arguments[1],arguments[2]);break;case 4:Pt(O,at,this,arguments[1],arguments[2],arguments[3]);break;default:for(U=new Array(R-1),N=1;N<R;N++)U[N-1]=arguments[N];We(O,at,this,U)}return!0};function Kt(F,q,P,O){var R,U,N;if(typeof P!="function")throw new TypeError('"listener" argument must be a function');if(U=F._events,U?(U.newListener&&(F.emit("newListener",q,P.listener?P.listener:P),U=F._events),N=U[q]):(U=F._events=new ut,F._eventsCount=0),!N)N=U[q]=P,++F._eventsCount;else if(typeof N=="function"?N=U[q]=O?[P,N]:[N,P]:O?N.unshift(P):N.push(P),!N.warned&&(R=te(F),R&&R>0&&N.length>R)){N.warned=!0;var me=new Error("Possible EventEmitter memory leak detected. "+N.length+" "+q+" listeners added. Use emitter.setMaxListeners() to increase limit");me.name="MaxListenersExceededWarning",me.emitter=F,me.type=q,me.count=N.length,gt(me)}return F}function gt(F){typeof console.warn=="function"?console.warn(F):console.log(F)}je.prototype.addListener=function(q,P){return Kt(this,q,P,!1)},je.prototype.on=je.prototype.addListener,je.prototype.prependListener=function(q,P){return Kt(this,q,P,!0)};function xe(F,q,P){var O=!1;function R(){F.removeListener(q,R),O||(O=!0,P.apply(F,arguments))}return R.listener=P,R}je.prototype.once=function(q,P){if(typeof P!="function")throw new TypeError('"listener" argument must be a function');return this.on(q,xe(this,q,P)),this},je.prototype.prependOnceListener=function(q,P){if(typeof P!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(q,xe(this,q,P)),this},je.prototype.removeListener=function(q,P){var O,R,U,N,me;if(typeof P!="function")throw new TypeError('"listener" argument must be a function');if(R=this._events,!R)return this;if(O=R[q],!O)return this;if(O===P||O.listener&&O.listener===P)--this._eventsCount===0?this._events=new ut:(delete R[q],R.removeListener&&this.emit("removeListener",q,O.listener||P));else if(typeof O!="function"){for(U=-1,N=O.length;N-- >0;)if(O[N]===P||O[N].listener&&O[N].listener===P){me=O[N].listener,U=N;break}if(U<0)return this;if(O.length===1){if(O[0]=void 0,--this._eventsCount===0)return this._events=new ut,this;delete R[q]}else Tt(O,U);R.removeListener&&this.emit("removeListener",q,me||P)}return this},je.prototype.off=function(F,q){return this.removeListener(F,q)},je.prototype.removeAllListeners=function(q){var P,O;if(O=this._events,!O)return this;if(!O.removeListener)return arguments.length===0?(this._events=new ut,this._eventsCount=0):O[q]&&(--this._eventsCount===0?this._events=new ut:delete O[q]),this;if(arguments.length===0){for(var R=Object.keys(O),U=0,N;U<R.length;++U)N=R[U],N!=="removeListener"&&this.removeAllListeners(N);return this.removeAllListeners("removeListener"),this._events=new ut,this._eventsCount=0,this}if(P=O[q],typeof P=="function")this.removeListener(q,P);else if(P)do this.removeListener(q,P[P.length-1]);while(P[0]);return this},je.prototype.listeners=function(q){var P,O,R=this._events;return R?(P=R[q],P?typeof P=="function"?O=[P.listener||P]:O=Jt(P):O=[]):O=[],O},je.listenerCount=function(F,q){return typeof F.listenerCount=="function"?F.listenerCount(q):ft.call(F,q)},je.prototype.listenerCount=ft;function ft(F){var q=this._events;if(q){var P=q[F];if(typeof P=="function")return 1;if(P)return P.length}return 0}je.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function Tt(F,q){for(var P=q,O=P+1,R=F.length;O<R;P+=1,O+=1)F[P]=F[O];F.pop()}function Le(F,q){for(var P=new Array(q);q--;)P[q]=F[q];return P}function Jt(F){for(var q=new Array(F.length),P=0;P<q.length;++P)q[P]=F[P].listener||F[P];return q}var vt=we.getLogger("twilsock");function zt(F,q){return["".concat(new Date().toISOString()," Twilsock ").concat(F,":")].concat(Array.from(q))}var nr=function(){function F(q){ae.default(this,F),Ve.default(this,"prefix",""),this.prefix=q!=null&&q.length>0?" "+q+":":""}return J.default(F,[{key:"setLevel",value:function(P){vt.setLevel(P)}},{key:"trace",value:function(){for(var P=arguments.length,O=new Array(P),R=0;R<P;R++)O[R]=arguments[R];vt.trace.apply(null,zt("T",O))}},{key:"debug",value:function(){for(var P=arguments.length,O=new Array(P),R=0;R<P;R++)O[R]=arguments[R];vt.debug.apply(null,zt("D",O))}},{key:"info",value:function(){for(var P=arguments.length,O=new Array(P),R=0;R<P;R++)O[R]=arguments[R];vt.info.apply(null,zt("I",O))}},{key:"warn",value:function(){for(var P=arguments.length,O=new Array(P),R=0;R<P;R++)O[R]=arguments[R];vt.warn.apply(null,zt("W",O))}},{key:"error",value:function(){for(var P=arguments.length,O=new Array(P),R=0;R<P;R++)O[R]=arguments[R];vt.error.apply(null,zt("E",O))}}],[{key:"setLevel",value:function(P){vt.setLevel(P)}},{key:"trace",value:function(){for(var P=arguments.length,O=new Array(P),R=0;R<P;R++)O[R]=arguments[R];vt.trace.apply(null,zt("T",O))}},{key:"debug",value:function(){for(var P=arguments.length,O=new Array(P),R=0;R<P;R++)O[R]=arguments[R];vt.debug.apply(null,zt("D",O))}},{key:"info",value:function(){for(var P=arguments.length,O=new Array(P),R=0;R<P;R++)O[R]=arguments[R];vt.info.apply(null,zt("I",O))}},{key:"warn",value:function(){for(var P=arguments.length,O=new Array(P),R=0;R<P;R++)O[R]=arguments[R];vt.warn.apply(null,zt("W",O))}},{key:"error",value:function(){for(var P=arguments.length,O=new Array(P),R=0;R<P;R++)O[R]=arguments[R];vt.error.apply(null,zt("E",O))}}]),F}(),He=new nr(""),Pr="0.12.2",Cr=function(){function F(q,P,O){ae.default(this,F),Ve.default(this,"confirmedCapabilities",new Set),this.activeGrant=P,this._token=q;var R=O.region||"us1",U="wss://tsock.".concat(R,".twilio.com/v3/wsconnect"),N=O.twilsock||O.Twilsock||{};this.url=N.uri||U,this._continuationToken=O.continuationToken?O.continuationToken:null,this.logLevel=O.logLevel?O.logLevel:"error",this.retryPolicy=O.retryPolicy?O.retryPolicy:{min:1*1e3,max:2*60*1e3,randomness:.2},this.clientMetadata=O.clientMetadata?O.clientMetadata:{},this.clientMetadata.ver=Pr,this.initRegistrations=O.initRegistrations?O.initRegistrations:null,this.tweaks=O.tweaks?O.tweaks:null}return J.default(F,[{key:"token",get:function(){return this._token}},{key:"continuationToken",get:function(){return this._continuationToken}},{key:"updateToken",value:function(P){this._token=P}},{key:"updateContinuationToken",value:function(P){this._continuationToken=P}}]),F}(),Ct=function F(q){ae.default(this,F),this.id=q||"TM".concat(M.v4())};function kt(F){var q=yt();return function(){var O=Re.default(F),R;if(q){var U=Re.default(this).constructor;R=Reflect.construct(O,arguments,U)}else R=O.apply(this,arguments);return ye.default(this,R)}}function yt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var st=function(F){Z.default(P,F);var q=kt(P);function P(O,R,U,N,me){var pe;return ae.default(this,P),pe=q.call(this),Ve.default(L.default(pe),"method","init"),pe.token=O,pe.continuation_token=R,pe.metadata=U,pe.registrations=N,pe.tweaks=me,pe.capabilities=["client_update","offline_storage","telemetry.v1"],pe}return P}(Ct);function Lt(F){var q=Xt();return function(){var O=Re.default(F),R;if(q){var U=Re.default(this).constructor;R=Reflect.construct(O,arguments,U)}else R=O.apply(this,arguments);return ye.default(this,R)}}function Xt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var hr=function(F){Z.default(P,F);var q=Lt(P);function P(O,R,U,N,me,pe,Ae){var qe;return ae.default(this,P),qe=q.call(this,O),qe.continuationToken=R,qe.continuationTokenStatus=N,qe.offlineStorage=me,qe.initRegistrations=pe,qe.debugInfo=Ae,qe.confirmedCapabilities=U,qe}return P}(Ct);function hn(F){var q=Pn();return function(){var O=Re.default(F),R;if(q){var U=Re.default(this).constructor;R=Reflect.construct(O,arguments,U)}else R=O.apply(this,arguments);return ye.default(this,R)}}function Pn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var _r=function(F){Z.default(P,F);var q=hn(P);function P(O){var R;return ae.default(this,P),R=q.call(this),Ve.default(L.default(R),"method","update"),R.token=O,R}return P}(Ct);function Wt(F){var q=Nr();return function(){var O=Re.default(F),R;if(q){var U=Re.default(this).constructor;R=Reflect.construct(O,arguments,U)}else R=O.apply(this,arguments);return ye.default(this,R)}}function Nr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var _e=function(F){Z.default(P,F);var q=Wt(P);function P(O,R,U){var N;return ae.default(this,P),N=q.call(this),Ve.default(L.default(N),"method","message"),N.active_grant=O,N.payload_type=R,N.http_request=U,N}return P}(Ct);function Ce(F){var q=ce();return function(){var O=Re.default(F),R;if(q){var U=Re.default(this).constructor;R=Reflect.construct(O,arguments,U)}else R=O.apply(this,arguments);return ye.default(this,R)}}function ce(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var de=function(F){Z.default(P,F);var q=Ce(P);function P(O){var R;return ae.default(this,P),R=q.call(this,O),Ve.default(L.default(R),"method","reply"),Ve.default(L.default(R),"payload_type","application/json"),Ve.default(L.default(R),"status",{code:200,status:"OK"}),R}return P}(Ct);function le(F){var q=ke();return function(){var O=Re.default(F),R;if(q){var U=Re.default(this).constructor;R=Reflect.construct(O,arguments,U)}else R=O.apply(this,arguments);return ye.default(this,R)}}function ke(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ie=function(F){Z.default(P,F);var q=le(P);function P(){var O;return ae.default(this,P),O=q.call(this),Ve.default(L.default(O),"method","close"),O}return P}(Ct);function ee(F){var q=ve();return function(){var O=Re.default(F),R;if(q){var U=Re.default(this).constructor;R=Reflect.construct(O,arguments,U)}else R=O.apply(this,arguments);return ye.default(this,R)}}function ve(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Q=function F(q,P,O,R,U,N){ae.default(this,F),this.start=q,this.end=P,this.title=O,this.details=R,this.id=U,this.type=N},se=function(F){Z.default(P,F);var q=ee(P);function P(O){var R;return ae.default(this,P),R=q.call(this),Ve.default(L.default(R),"method","telemetry.v1"),R.events=O,R}return P}(Ct);function X(F){var q=encodeURIComponent(F),P=q.replace(/%([0-9A-F]{2})/g,function(O,R){return String.fromCharCode(+("0x"+R))});return P.length}function Ue(F){var q=encodeURIComponent(F),P=q.replace(/%([0-9A-F]{2})/g,function(R,U){return String.fromCharCode(+("0x"+U))}),O=new Uint8Array(P.length);return Array.prototype.forEach.call(P,function(R,U){O[U]=R.charCodeAt(0)}),O}function Oe(F){var q=Array.prototype.map.call(F,function(O){return String.fromCharCode(O)}).join(""),P=q.replace(/(.)/g,function(O,R){var U=R.charCodeAt(0).toString(16).toUpperCase();return U.length<2&&(U="0"+U),"%"+U});return decodeURIComponent(P)}function Ze(F){return JSON.parse(Oe(F))}function Ke(F){for(var q="",P=0;P<F.length;++P){var O=String.fromCharCode(F[P]);if(q+=O,O==="\r"){P+=2;break}}var R=q.split(" ");return{size:P,protocol:R[0],version:R[1],headerSize:Number(R[2])}}var Je=function(){function F(){ae.default(this,F)}return J.default(F,null,[{key:"parse",value:function(P){var O=2,R=new Uint8Array(P),U=Ke(R);if(U.protocol!=="TWILSOCK"||U.version!=="V3.0")return He.error("unsupported protocol: ".concat(U.protocol," ver ").concat(U.version)),null;var N;try{N=Ze(R.subarray(U.size,U.size+U.headerSize))}catch(qe){return He.error("failed to parse message header",qe,P),null}He.debug("message received: ",N.method),He.trace("message received: ",N);var me;if(N.payload_size>0){var pe=O+U.size+U.headerSize,Ae=N.payload_size;if(!N.hasOwnProperty("payload_type")||N.payload_type.indexOf("application/json")===0)try{me=Ze(R.subarray(pe,pe+Ae))}catch(qe){return He.error("failed to parse message body",qe,P),null}else N.payload_type.indexOf("text/plain")===0&&(me=Oe(R.subarray(pe,pe+Ae)))}return{method:N.method,header:N,payload:me}}},{key:"createPacket",value:function(P){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";P.payload_size=X(O);var R=JSON.stringify(P),U="TWILSOCK V3.0 "+X(R);He.debug("send request:",U+R+O);var N=Ue(U+`\r
|
|
159
|
+
`+R+`\r
|
|
160
|
+
`+O);return N.buffer}}]),F}();function rt(F){var q=nt();return function(){var O=Re.default(F),R;if(q){var U=Re.default(this).constructor;R=Reflect.construct(O,arguments,U)}else R=O.apply(this,arguments);return ye.default(this,R)}}function nt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ye=function(F){Z.default(P,F);var q=rt(P);function P(O){return ae.default(this,P),q.call(this,O)}return P}($e.default(Error));function tt(F){var q=it();return function(){var O=Re.default(F),R;if(q){var U=Re.default(this).constructor;R=Reflect.construct(O,arguments,U)}else R=O.apply(this,arguments);return ye.default(this,R)}}function it(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ct=function(F){Z.default(P,F);var q=tt(P);function P(O,R){var U;return ae.default(this,P),U=q.call(this,O),U.reply=R,U}return P}(Ye);function Sr(F,q){var P=Object.keys(F);if(Object.getOwnPropertySymbols){var O=Object.getOwnPropertySymbols(F);q&&(O=O.filter(function(R){return Object.getOwnPropertyDescriptor(F,R).enumerable})),P.push.apply(P,O)}return P}function cr(F){for(var q=1;q<arguments.length;q++){var P=arguments[q]!=null?arguments[q]:{};q%2?Sr(Object(P),!0).forEach(function(O){Ve.default(F,O,P[O])}):Object.getOwnPropertyDescriptors?Object.defineProperties(F,Object.getOwnPropertyDescriptors(P)):Sr(Object(P)).forEach(function(O){Object.defineProperty(F,O,Object.getOwnPropertyDescriptor(P,O))})}return F}function ot(F){var q=Hr();return function(){var O=Re.default(F),R;if(q){var U=Re.default(this).constructor;R=Reflect.construct(O,arguments,U)}else R=O.apply(this,arguments);return ye.default(this,R)}}function Hr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ir=function(F){Z.default(P,F);var q=ot(P);function P(O){var R;return ae.default(this,P),R=q.call(this),Ve.default(L.default(R),"newBackoff",null),Ve.default(L.default(R),"usedBackoff",null),Ve.default(L.default(R),"retrier",null),R.options=O?cr({},O):{},R}return J.default(P,[{key:"inProgress",get:function(){return!!this.retrier}},{key:"start",value:function(){if(this.inProgress)throw new Error("Already waiting for next attempt, call finishAttempt(success : boolean) to finish it");this.createRetrier()}},{key:"stop",value:function(){this.cleanRetrier(),this.newBackoff=null,this.usedBackoff=null}},{key:"modifyBackoff",value:function(R){this.newBackoff=R}},{key:"attemptFailed",value:function(){if(!this.inProgress)throw new Error("No attempt is in progress");if(this.newBackoff){var R=!this.usedBackoff||this.usedBackoff<this.newBackoff;if(R)this.createRetrier();else{var U;(U=this.retrier)===null||U===void 0||U.failed(new Error)}}else{var N;(N=this.retrier)===null||N===void 0||N.failed(new Error)}}},{key:"cancel",value:function(){var R;(R=this.retrier)===null||R===void 0||R.cancel()}},{key:"cleanRetrier",value:function(){var R,U;(R=this.retrier)===null||R===void 0||R.removeAllListeners(),(U=this.retrier)===null||U===void 0||U.cancel(),this.retrier=null}},{key:"getRetryPolicy",value:function(){var R=cr({},this.options);return this.newBackoff&&(R.min=this.newBackoff,R.max=this.options.max&&this.options.max>this.newBackoff?this.options.max:this.newBackoff),R.maxAttemptsCount=this.options.maxAttemptsCount?this.options.maxAttemptsCount+1:void 0,R}},{key:"createRetrier",value:function(){var R=this;this.cleanRetrier();var U=this.getRetryPolicy();this.retrier=new x.Retrier(U),this.retrier.once("attempt",function(){var N,me;(N=R.retrier)===null||N===void 0||N.on("attempt",function(){return R.emit("attempt")}),(me=R.retrier)===null||me===void 0||me.failed(new Error("Skipping first attempt"))}),this.retrier.on("failed",function(N){return R.emit("failed",N)}),this.usedBackoff=this.newBackoff,this.newBackoff=null,this.retrier.start()}}]),P}(je);function Wn(F){var q=hi();return function(){var O=Re.default(F),R;if(q){var U=Re.default(this).constructor;R=Reflect.construct(O,arguments,U)}else R=O.apply(this,arguments);return ye.default(this,R)}}function hi(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var $a=3e3;function Kr(F){setTimeout(F,0)}var Yi=function(F){Z.default(P,F);var q=Wn(P);function P(O,R,U){var N;ae.default(this,P),N=q.call(this),Ve.default(L.default(N),"disconnectingTimer",null),Ve.default(L.default(N),"disconnectedPromiseResolve",null),Ve.default(L.default(N),"terminalStates",["disconnected","rejected"]),Ve.default(L.default(N),"tokenExpiredSasCode",20104),Ve.default(L.default(N),"terminationReason","Connection is not initialized"),N.websocket=O,N.websocket.on("connected",function(){return N.fsm.socketConnected()}),N.websocket.on("disconnected",function(){return N.fsm.socketClosed()}),N.websocket.on("message",function(pe){return N.onIncomingMessage(pe)}),N.websocket.on("socketError",function(pe){return N.emit("connectionError",{terminal:!1,message:"Socket error: ".concat(pe.message),httpStatusCode:null,errorCode:null})}),N.transport=R,N.config=U,N.retrier=new ir(U.retryPolicy),N.retrier.on("attempt",function(){return N.retry()}),N.retrier.on("failed",function(pe){He.warn("Retrying failed: ".concat(pe.message)),N.disconnect()}),typeof window<"u"&&typeof window.addEventListener<"u"&&(window.addEventListener("online",function(){He.debug("Browser reported connectivity state: online"),N.resetBackoff(),N.fsm.systemOnline()}),window.addEventListener("offline",function(){He.debug("Browser reported connectivity state: offline"),N.websocket.close(),N.fsm.socketClosed()}));var me=ge.factory({init:"disconnected",transitions:[{name:"userConnect",from:["disconnected","rejected"],to:"connecting"},{name:"userConnect",from:["connecting","connected"]},{name:"userDisconnect",from:["connecting","initialising","connected","updating","retrying","rejected","waitSocketClosed","waitOffloadSocketClosed"],to:"disconnecting"},{name:"userRetry",from:["retrying"],to:"connecting"},{name:"socketConnected",from:["connecting"],to:"initialising"},{name:"socketClosed",from:["connecting","initialising","connected","updating","error","waitOffloadSocketClosed"],to:"retrying"},{name:"socketClosed",from:["disconnecting"],to:"disconnected"},{name:"socketClosed",from:["waitSocketClosed"],to:"disconnected"},{name:"socketClosed",from:["rejected"],to:"rejected"},{name:"initSuccess",from:["initialising"],to:"connected"},{name:"initError",from:["initialising"],to:"error"},{name:"tokenRejected",from:["initialising","updating"],to:"rejected"},{name:"protocolError",from:["initialising","connected","updating"],to:"error"},{name:"receiveClose",from:["initialising","connected","updating"],to:"waitSocketClosed"},{name:"receiveOffload",from:["initialising","connected","updating"],to:"waitOffloadSocketClosed"},{name:"unsupportedProtocol",from:["initialising","connected","updating"],to:"unsupported"},{name:"receiveFatalClose",from:["initialising","connected","updating"],to:"unsupported"},{name:"userUpdateToken",from:["disconnected","rejected","connecting","retrying"],to:"connecting"},{name:"userUpdateToken",from:["connected"],to:"updating"},{name:"updateSuccess",from:["updating"],to:"connected"},{name:"updateError",from:["updating"],to:"error"},{name:"userSend",from:["connected"],to:"connected"},{name:"systemOnline",from:["retrying"],to:"connecting"}],methods:{onConnecting:function(){N.setupSocket(),N.emit("connecting")},onEnterInitialising:function(){N.sendInit()},onLeaveInitialising:function(){N.cancelInit()},onEnterUpdating:function(){N.sendUpdate()},onLeaveUpdating:function(){N.cancelUpdate()},onEnterRetrying:function(){N.initRetry(),N.emit("connecting")},onEnterConnected:function(){N.resetBackoff(),N.onConnected()},onUserUpdateToken:function(){N.resetBackoff()},onTokenRejected:function(){N.resetBackoff(),N.closeSocket(!0),N.finalizeSocket()},onUserDisconnect:function(){N.closeSocket(!0)},onEnterDisconnecting:function(){N.startDisconnectTimer()},onLeaveDisconnecting:function(){N.cancelDisconnectTimer()},onEnterWaitSocketClosed:function(){N.startDisconnectTimer()},onLeaveWaitSocketClosed:function(){N.cancelDisconnectTimer()},onEnterWaitOffloadSocketClosed:function(){N.startDisconnectTimer()},onLeaveWaitOffloadSocketClosed:function(){N.cancelDisconnectTimer()},onDisconnected:function(){N.resetBackoff(),N.finalizeSocket()},onReceiveClose:function(){N.onCloseReceived()},onReceiveOffload:function(Ae,qe){He.debug("onreceiveoffload: ",qe),N.modifyBackoff(qe.body),N.onCloseReceived()},onUnsupported:function(){N.closeSocket(!0),N.finalizeSocket()},onError:function(Ae,qe){N.closeSocket(qe),N.finalizeSocket()},onEnterState:function(Ae){Ae.from!=="none"&&N.changeState(Ae)},onInvalidTransition:function(Ae,qe,at){He.warn("FSM: unexpected transition",qe,at)}}});return N.fsm=new me,N}return J.default(P,[{key:"changeState",value:function(R){He.debug("FSM: ".concat(R.transition,": ").concat(R.from," --> ").concat(R.to)),this.lastEmittedState!==this.state&&(this.lastEmittedState=this.state,this.emit("stateChanged",this.state))}},{key:"resetBackoff",value:function(){He.trace("resetBackoff"),this.retrier.stop()}},{key:"modifyBackoff",value:function(R){He.trace("modifyBackoff",R);var U=R?R.backoff_policy:null;U&&typeof U.reconnect_min_ms=="number"&&this.retrier.modifyBackoff(U.reconnect_min_ms)}},{key:"startDisconnectTimer",value:function(){var R=this;He.trace("startDisconnectTimer"),this.disconnectingTimer&&(clearTimeout(this.disconnectingTimer),this.disconnectingTimer=null),this.disconnectingTimer=setTimeout(function(){He.debug("disconnecting is timed out"),R.closeSocket(!0)},$a)}},{key:"cancelDisconnectTimer",value:function(){He.trace("cancelDisconnectTimer"),this.disconnectingTimer&&(clearTimeout(this.disconnectingTimer),this.disconnectingTimer=null)}},{key:"isConnected",get:function(){return this.state==="connected"&&this.websocket.isConnected}},{key:"state",get:function(){switch(this.fsm.state){case"connecting":case"initialising":case"retrying":case"error":return"connecting";case"updating":case"connected":return"connected";case"rejected":return"denied";case"disconnecting":case"waitSocketClosed":case"waitOffloadSocketClosed":return"disconnecting";case"disconnected":default:return"disconnected"}}},{key:"initRetry",value:function(){He.debug("initRetry"),this.retrier.inProgress?this.retrier.attemptFailed():this.retrier.start()}},{key:"retry",value:function(){this.fsm.state!="connecting"?(He.trace("retry"),this.websocket.close(),this.fsm.userRetry()):He.trace("can retry as already connecting")}},{key:"onConnected",value:function(){this.emit("connected")}},{key:"finalizeSocket",value:function(){He.trace("finalizeSocket"),this.websocket.close(),this.emit("disconnected"),this.disconnectedPromiseResolve&&(this.disconnectedPromiseResolve(),this.disconnectedPromiseResolve=null)}},{key:"setupSocket",value:function(){He.trace("setupSocket:",this.config.token),this.emit("beforeConnect"),this.websocket.connect()}},{key:"onIncomingMessage",value:function(R){var U=Je.parse(R);if(U){var N=U.method,me=U.header,pe=U.payload;if(N!=="reply"&&this.confirmReceiving(me),N==="notification")this.emit("message",me.message_type,pe);else if(me.method==="reply")this.transport.processReply({id:me.id,status:me.status,header:me,body:pe});else if(me.method==="client_update")me.client_update_type==="token_about_to_expire"&&this.emit("tokenAboutToExpire");else if(me.method==="close")if(me.status.code===308)He.debug("Connection has been offloaded"),this.fsm.receiveOffload({status:me.status.status,body:pe});else if(me.status.code===406){var Ae="Server closed connection because can't parse protocol: ".concat(JSON.stringify(me.status));this.emitReplyConnectionError(Ae,me,!0),He.error(Ae),this.fsm.receiveFatalClose()}else me.status.code===417?(He.error("Server closed connection because can't parse client reply: ".concat(JSON.stringify(me.status))),this.fsm.receiveFatalClose(me.status.status)):me.status.code===410?(He.warn("Server closed connection: ".concat(JSON.stringify(me.status))),this.fsm.receiveClose(me.status.status),this.emit("tokenExpired")):me.status.code===401?(He.error("Server closed connection: ".concat(JSON.stringify(me.status))),this.fsm.receiveClose(me.status.status)):(He.warn("unexpected message: ",me.status),this.fsm.receiveOffload({status:me.status.status,body:null}))}}},{key:"sendInit",value:function(){var O=oe.default(be.default.mark(function U(){var N,me;return be.default.wrap(function(Ae){for(;;)switch(Ae.prev=Ae.next){case 0:return He.trace("sendInit"),Ae.prev=1,this.emit("beforeSendInit"),Ae.next=5,this.transport.sendInit();case 5:N=Ae.sent,this.config.updateContinuationToken(N.continuationToken),this.config.confirmedCapabilities=N.confirmedCapabilities,this.fsm.initSuccess(N),this.emit("initialized",N),this.emit("tokenUpdated"),Ae.next=17;break;case 13:Ae.prev=13,Ae.t0=Ae.catch(1),Ae.t0 instanceof ct?(me=!1,He.warn("Init rejected by server: ".concat(JSON.stringify(Ae.t0.reply.status))),this.emit("sendInitFailed"),Ae.t0.reply.status.code===401||Ae.t0.reply.status.code===403?(me=!0,this.fsm.tokenRejected(Ae.t0.reply.status),Ae.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):Ae.t0.reply.status.code===429?(this.modifyBackoff(Ae.t0.reply.body),this.fsm.initError(!0)):Ae.t0.reply.status.code===500?this.fsm.initError(!1):this.fsm.initError(!0),this.emitReplyConnectionError(Ae.t0.message,Ae.t0.reply,me)):(this.terminationReason=Ae.t0.message,this.emit("connectionError",{terminal:!0,message:"Unknown error during connection initialisation: ".concat(Ae.t0.message,`
|
|
161
|
+
`).concat(JSON.stringify(Ae.t0,null,2)),httpStatusCode:null,errorCode:null}),this.fsm.initError(!0)),this.emit("tokenUpdated",Ae.t0);case 17:case"end":return Ae.stop()}},U,this,[[1,13]])}));function R(){return O.apply(this,arguments)}return R}()},{key:"sendUpdate",value:function(){var O=oe.default(be.default.mark(function U(){var N,me,pe;return be.default.wrap(function(qe){for(;;)switch(qe.prev=qe.next){case 0:return He.trace("sendUpdate"),N=new _r(this.config.token),qe.prev=2,qe.next=5,this.transport.sendWithReply(N);case 5:me=qe.sent,this.fsm.updateSuccess(me.body),this.emit("tokenUpdated"),qe.next=14;break;case 10:qe.prev=10,qe.t0=qe.catch(2),qe.t0 instanceof ct?(pe=!1,He.warn("Token update rejected by server: ".concat(JSON.stringify(qe.t0.reply.status))),qe.t0.reply.status.code===401||qe.t0.reply.status.code===403?(pe=!0,this.fsm.tokenRejected(qe.t0.reply.status),qe.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):qe.t0.reply.status.code===429?(this.modifyBackoff(qe.t0.reply.body),this.fsm.updateError(qe.t0.reply.status)):this.fsm.updateError(qe.t0.reply.status),this.emitReplyConnectionError(qe.t0.message,qe.t0.reply,pe)):(this.emit("error",!1,qe.t0.message,null,null),this.fsm.updateError(qe.t0)),this.emit("tokenUpdated",qe.t0);case 14:case"end":return qe.stop()}},U,this,[[2,10]])}));function R(){return O.apply(this,arguments)}return R}()},{key:"emitReplyConnectionError",value:function(R,U,N){var me=U.status&&U.status.description?U.status.description:R,pe=U.status.code,Ae=U.status&&U.status.errorCode?U.status.errorCode:null;N&&(this.terminationReason=me),this.emit("connectionError",{terminal:N,message:"Connection error: ".concat(me),httpStatusCode:pe,errorCode:Ae})}},{key:"cancelInit",value:function(){He.trace("cancelInit")}},{key:"cancelUpdate",value:function(){He.trace("cancelUpdate")}},{key:"confirmReceiving",value:function(R){He.trace("confirmReceiving");try{this.transport.send(new de(R.id))}catch(U){He.debug("failed to confirm packet receiving",U)}}},{key:"closeSocket",value:function(R){var U=this;He.trace("closeSocket (graceful: ".concat(R,")")),R&&this.transport.isConnected&&this.transport.sendClose(),this.websocket.close(),Kr(function(){return U.fsm.socketClosed()})}},{key:"connect",value:function(){He.trace("connect"),this.fsm.userConnect()}},{key:"disconnect",value:function(){var R=this;return He.trace("disconnect"),this.fsm.is("disconnected")?Promise.resolve():new Promise(function(U){R.disconnectedPromiseResolve=U,R.fsm.userDisconnect()})}},{key:"updateToken",value:function(R){var U=this;return He.trace("updateToken:",R),new Promise(function(N,me){U.once("tokenUpdated",function(pe){pe?me(pe):N()}),U.fsm.userUpdateToken()})}},{key:"isTerminalState",get:function(){return this.terminalStates.indexOf(this.fsm.state)!==-1}},{key:"getTerminationReason",get:function(){return this.terminationReason}},{key:"onCloseReceived",value:function(){this.websocket.close()}}]),P}(je),Oa=function(){function F(){ae.default(this,F)}return J.default(F,null,[{key:"getMetadata",value:function(P){var O,R,U,N,me,pe,Ae,qe,at=P&&P.clientMetadata?P.clientMetadata:{},dt=["ver","env","envv","os","osv","osa","type","sdk","sdkv","dev","devv","devt","app","appv"],Lr={env:(O=De.name)!==null&&O!==void 0?O:"unknown",envv:(R=De.version)!==null&&R!==void 0?R:"unknown",os:(U=(N=De.os)===null||N===void 0?void 0:N.family)!==null&&U!==void 0?U:"unknown",osv:(me=(pe=De.os)===null||pe===void 0?void 0:pe.version)!==null&&me!==void 0?me:"unknown",osa:(Ae=(qe=De.os)===null||qe===void 0?void 0:qe.architecture)!==null&&Ae!==void 0?Ae:"unknown",sdk:"js-default"},lr={};return dt.filter(function(an){return an in at||an in Lr}).forEach(function(an){return lr[an]=an in at?at[an]:Lr[an]}),lr}}]),F}(),Vn=3e4;function Er(F){return F>=200&&F<300}function Ia(F){switch(Te.default(F)){case"undefined":return"";case"object":return JSON.stringify(F);default:return F}}var rn=function(){function F(q,P){var O=this;ae.default(this,F),this.config=P,this.activeRequests=new Map,this.channel=q,this.channel.on("reply",function(R){return O.processReply(R)}),this.channel.on("disconnected",function(){O.activeRequests.forEach(function(R){clearTimeout(R.timeout),R.reject(new Ye("disconnected"))}),O.activeRequests.clear()})}return J.default(F,[{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"processReply",value:function(P){var O=this.activeRequests.get(P.id);O&&(clearTimeout(O.timeout),this.activeRequests.delete(P.id),Er(P.status.code)?O.resolve(P):(O.reject(new ct("Transport failure: "+P.status.status,P)),He.trace("message rejected")))}},{key:"storeRequest",value:function(P,O,R){var U={resolve:O,reject:R,timeout:setTimeout(function(){He.trace("request",P,"is timed out"),R(new Ye("Twilsock: request timeout: "+P))},Vn)};this.activeRequests.set(P,U)}},{key:"shutdown",value:function(){this.activeRequests.forEach(function(P){clearTimeout(P.timeout),P.reject(new Ye("Twilsock: request cancelled by user"))}),this.activeRequests.clear()}},{key:"sendInit",value:function(){var q=oe.default(be.default.mark(function O(){var R,U,N;return be.default.wrap(function(pe){for(;;)switch(pe.prev=pe.next){case 0:return He.trace("sendInit"),R=Oa.getMetadata(this.config),U=new st(this.config.token,this.config.continuationToken,R,this.config.initRegistrations,this.config.tweaks),pe.next=5,this.sendWithReply(U);case 5:return N=pe.sent,pe.abrupt("return",new hr(N.id,N.header.continuation_token,new Set(N.header.capabilities),N.header.continuation_token_status,N.header.offline_storage,N.header.init_registrations,N.header.debug_info));case 7:case"end":return pe.stop()}},O,this)}));function P(){return q.apply(this,arguments)}return P}()},{key:"sendClose",value:function(){var P=new Ie;this.send(P)}},{key:"sendWithReply",value:function(P,O){var R=this;return new Promise(function(U,N){var me=R.send(P,O);R.storeRequest(me,U,N)})}},{key:"send",value:function(P,O){P.id=P.id||"TM".concat(M.v4());var R=Je.createPacket(P,Ia(O));try{return this.channel.send(R),P.id}catch(U){throw He.debug("failed to send ",P,U),He.trace(U.stack),U}}}]),F}();function ar(F){var q=vi();return function(){var O=Re.default(F),R;if(q){var U=Re.default(this).constructor;R=Reflect.construct(O,arguments,U)}else R=O.apply(this,arguments);return ye.default(this,R)}}function vi(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Jr=function(F){Z.default(P,F);var q=ar(P);function P(O){var R;return ae.default(this,P),R=q.call(this),Ve.default(L.default(R),"socket",null),R.url=O,R.url=O,R.WebSocket=r.WebSocket||r.MozWebSocket||{},R}return J.default(P,[{key:"isConnected",get:function(){return!!this.socket&&this.socket.readyState===1}},{key:"connect",value:function(){var R=this;He.trace("connecting to socket");var U;try{U=new this.WebSocket(this.url)}catch(N){He.debug("Socket error: ".concat(this.url)),this.emit("socketError",N);return}U.binaryType="arraybuffer",U.onopen=function(){He.debug("socket opened ".concat(R.url)),R.emit("connected")},U.onclose=function(N){He.debug("socket closed",N),R.emit("disconnected",N)},U.onerror=function(N){He.debug("Socket error:",N),R.emit("socketError",N)},U.onmessage=function(N){R.emit("message",N.data)},this.socket=U}},{key:"send",value:function(R){return this.socket&&this.socket.send(R)}},{key:"close",value:function(){if(He.trace("closing socket"),this.socket){this.socket.onopen=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.onmessage=null;try{this.socket.close()}finally{}}}}]),P}(je);function Xi(F){var q=Pa();return function(){var O=Re.default(F),R;if(q){var U=Re.default(this).constructor;R=Reflect.construct(O,arguments,U)}else R=O.apply(this,arguments);return ye.default(this,R)}}function Pa(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Aa=function(F){Z.default(P,F);var q=Xi(P);function P(O){var R;return ae.default(this,P),R=q.call(this),R.transport=O,R.registrations=new Map,R.registrationsInProgress=new Map,R}return J.default(P,[{key:"putNotificationContext",value:function(){var O=oe.default(be.default.mark(function U(N,me){var pe;return be.default.wrap(function(qe){for(;;)switch(qe.prev=qe.next){case 0:return pe={method:"put_notification_ctx",notification_ctx_id:N},qe.next=3,this.transport.sendWithReply(pe,me);case 3:case"end":return qe.stop()}},U,this)}));function R(U,N){return O.apply(this,arguments)}return R}()},{key:"deleteNotificationContext",value:function(){var O=oe.default(be.default.mark(function U(N){var me;return be.default.wrap(function(Ae){for(;;)switch(Ae.prev=Ae.next){case 0:return me={method:"delete_notification_ctx",notification_ctx_id:N},Ae.next=3,this.transport.sendWithReply(me);case 3:case"end":return Ae.stop()}},U,this)}));function R(U){return O.apply(this,arguments)}return R}()},{key:"updateRegistration",value:function(){var O=oe.default(be.default.mark(function U(N,me){var pe,Ae;return be.default.wrap(function(at){for(;;)switch(at.prev=at.next){case 0:return He.debug("update registration for context",N),pe=this.registrationsInProgress.get(N),pe||(pe=new Set,this.registrationsInProgress.set(N,pe)),Ae=M.v4(),pe.add(Ae),at.prev=5,at.next=8,this.putNotificationContext(N,me);case 8:He.debug("registration attempt succeeded for context",me),pe.delete(Ae),pe.size===0&&(this.registrationsInProgress.delete(N),this.emit("registered",N)),at.next=19;break;case 13:at.prev=13,at.t0=at.catch(5),He.warn("registration attempt failed for context",me),He.debug(at.t0),pe.delete(Ae),pe.size===0&&(this.registrationsInProgress.delete(N),this.emit("registrationFailed",N,at.t0));case 19:case"end":return at.stop()}},U,this,[[5,13]])}));function R(U,N){return O.apply(this,arguments)}return R}()},{key:"updateRegistrations",value:function(){var O=oe.default(be.default.mark(function U(){var N=this,me;return be.default.wrap(function(Ae){for(;;)switch(Ae.prev=Ae.next){case 0:return He.trace("refreshing ".concat(this.registrations.size," registrations")),me=[],this.registrations.forEach(function(qe,at){me.push(N.updateRegistration(at,qe))}),Ae.next=5,Promise.all(me);case 5:case"end":return Ae.stop()}},U,this)}));function R(){return O.apply(this,arguments)}return R}()},{key:"setNotificationsContext",value:function(){var O=oe.default(be.default.mark(function U(N,me){return be.default.wrap(function(Ae){for(;;)switch(Ae.prev=Ae.next){case 0:if(!(!N||!me)){Ae.next=2;break}throw new Ye("Invalid arguments provided");case 2:return this.registrations.set(N,me),Ae.next=5,this.updateRegistration(N,me);case 5:return Ae.abrupt("return",Ae.sent);case 6:case"end":return Ae.stop()}},U,this)}));function R(U,N){return O.apply(this,arguments)}return R}()},{key:"removeNotificationsContext",value:function(){var O=oe.default(be.default.mark(function U(N){return be.default.wrap(function(pe){for(;;)switch(pe.prev=pe.next){case 0:if(this.registrations.has(N)){pe.next=2;break}return pe.abrupt("return");case 2:return pe.next=4,this.deleteNotificationContext(N);case 4:this.transport.isConnected&&this.registrations.delete(N);case 5:case"end":return pe.stop()}},U,this)}));function R(U){return O.apply(this,arguments)}return R}()}]),P}(je);function Ar(F){var q=At();return function(){var O=Re.default(F),R;if(q){var U=Re.default(this).constructor;R=Reflect.construct(O,arguments,U)}else R=O.apply(this,arguments);return ye.default(this,R)}}function At(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var mi=function(F){Z.default(P,F);var q=Ar(P);function P(O,R,U){var N;return ae.default(this,P),N=q.call(this,R),N.status=O,N.description=R,N.body=U,N}return P}(Ye);function Hn(F){var q=Ma();return function(){var O=Re.default(F),R;if(q){var U=Re.default(this).constructor;R=Reflect.construct(O,arguments,U)}else R=O.apply(this,arguments);return ye.default(this,R)}}function Ma(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Yr=function(F){Z.default(P,F);var q=Hn(P);function P(O){return ae.default(this,P),q.call(this,O)}return P}(Ye),gi=2e4;function yi(F){return F>=200&&F<300}function xa(F){return F&&F.header&&F.header.http_status}function Na(F){var q=F.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)(\/[^?#]*)(\?[^#]*|)(#.*|)$/);if(q){var P={protocol:q[1],host:q[2],hostname:q[3],port:q[4],pathname:q[5],search:q[6],hash:q[7],params:{}};if(P.search.length>0){var O=P.search.substring(1);P.params=O.split("&").map(function(R){return R.split("=")}).reduce(function(R,U){return R.hasOwnProperty(U[0])?Array.isArray(R[U[0]])?R[U[0]].push(U[1]):R[U[0]]=[R[U[0]],U[1]]:R[U[0]]=U[1],R},{})}return P}throw new Ye("Incorrect URI: "+F)}function vr(F,q){var P=Na(q),O={method:F,host:P.host,path:P.pathname};return P.params&&(O.params=P.params),O}function Qi(F,q,P,O,R){return{to:vr(F,q),headers:P,body:O,grant:R}}var Zi=function(){function F(q,P,O){ae.default(this,F),this.config=O,this.transport=q,this.pendingMessages=[],this.twilsock=P}return J.default(F,[{key:"saveMessage",value:function(P){var O=this;return new Promise(function(R,U){var N={message:P,resolve:R,reject:U,alreadyRejected:!1,timeout:setTimeout(function(){He.debug("request is timed out"),U(new Ye("request '".concat(P.to.method,"' to '").concat(P.to.host,"' timed out"))),N.alreadyRejected=!0},gi)};O.pendingMessages.push(N)})}},{key:"sendPendingMessages",value:function(){for(var P=this,O=function(){var N=P.pendingMessages[0];if(!N.alreadyRejected)try{var me=N.message;P.actualSend(me).then(function(pe){return N.resolve(pe)}).catch(function(pe){return N.reject(pe)}),clearTimeout(N.timeout)}catch(pe){return He.debug("Failed to send pending message",pe),"break"}P.pendingMessages.splice(0,1)};this.pendingMessages.length>0;){var R=O();if(R==="break")break}}},{key:"rejectPendingMessages",value:function(){var P=this;this.pendingMessages.forEach(function(O){O.reject(new Yr("Unable to connect: "+P.twilsock.getTerminationReason)),O.alreadyRejected=!0,clearTimeout(O.timeout)}),this.pendingMessages.splice(0,this.pendingMessages.length)}},{key:"actualSend",value:function(){var q=oe.default(be.default.mark(function O(R){var U,N,me,pe,Ae,qe,at,dt;return be.default.wrap(function(lr){for(;;)switch(lr.prev=lr.next){case 0:return N=R.to,me=R.headers,pe=R.body,Ae=(U=R.grant)!==null&&U!==void 0?U:this.config.activeGrant,qe={host:N.host,path:N.path,method:N.method,params:N.params,headers:me},at=new _e(Ae,me["Content-Type"]||"application/json",qe),He.trace("Sending upstream message",at),lr.next=9,this.transport.sendWithReply(at,pe);case 9:if(dt=lr.sent,He.trace("Received upstream message response",dt),!(xa(dt)&&!yi(dt.header.http_status.code))){lr.next=13;break}throw new mi(dt.header.http_status.code,dt.header.http_status.status,dt.body);case 13:return lr.abrupt("return",{status:dt.header.http_status,headers:dt.header.http_headers,body:dt.body});case 14:case"end":return lr.stop()}},O,this)}));function P(O){return q.apply(this,arguments)}return P}()},{key:"send",value:function(P,O){var R=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},U=arguments.length>3?arguments[3]:void 0,N=arguments.length>4?arguments[4]:void 0;if(this.twilsock.isTerminalState)return Promise.reject(new Yr("Unable to connect: "+this.twilsock.getTerminationReason));var me=Qi(P,O,R,U,N);return this.twilsock.isConnected?this.actualSend(me):this.saveMessage(me)}}]),F}(),bi=function(){function F(){var q=this;ae.default(this,F),this._promise=new Promise(function(P,O){q._resolve=P,q._reject=O})}return J.default(F,[{key:"promise",get:function(){return this._promise}},{key:"update",value:function(P){this._resolve(P)}},{key:"set",value:function(P){this._resolve(P)}},{key:"fail",value:function(P){this._reject(P)}}]),F}(),ea=function(){function F(q){ae.default(this,F),this.id=q}return J.default(F,null,[{key:"create",value:function(P){if(P instanceof Object&&"storage_id"in P)return new F(P.storage_id);throw new Ye('Field "storage_id" is missing')}}]),F}(),vn=function(){function F(){return ae.default(this,F),Ve.default(this,"initializedFlag","twilio_twilsock_token_storage"),Ve.default(this,"tokenStoragePrefix","twilio_continuation_token_"),F._instance||(this.initialize(),F._instance=this),F._instance}return J.default(F,[{key:"sessionStorage",value:function(){try{return r.sessionStorage}catch{return null}}},{key:"window",value:function(){try{return r.window}catch{return null}}},{key:"storeToken",value:function(P,O){this.canStore()&&this.sessionStorage.setItem(this.getKeyName(O),P)}},{key:"getStoredToken",value:function(P){return this.canStore()?this.sessionStorage.getItem(this.getKeyName(P)):null}},{key:"initialize",value:function(){var P=this;if(this.canStore()){var O=this.sessionStorage.getItem(this.initializedFlag);O&&this.clear(),this.sessionStorage.setItem(this.initializedFlag,"true");var R=this.sessionStorage.removeItem;this.window.addEventListener("unload",function(){R(P.initializedFlag)})}}},{key:"clear",value:function(){if(this.canStore()){for(var P=[],O=0;O<this.sessionStorage.length;O++){var R=this.sessionStorage.key(O);R&&R.indexOf(this.tokenStoragePrefix)===0&&P.push(R)}var U=this.sessionStorage.removeItem;P.forEach(function(N){return U(N)}),U(this.initializedFlag)}}},{key:"getKeyName",value:function(P){return"".concat(this.tokenStoragePrefix).concat(P)}},{key:"canStore",value:function(){return!!(this.sessionStorage&&this.sessionStorage.length&&this.window)}}]),F}();Ve.default(vn,"_instance",null);var An=new vn,Zt=function(){function F(q,P,O,R,U,N){ae.default(this,F),this.title=q,this.details=P,this.start=O,this.type=U,this.id=N,this.end=R}return J.default(F,[{key:"toTelemetryEvent",value:function(){var P=new Date,O=this.start,R=this.end?this.end:P;if(R<O){var U=R;R=O,O=U}var N=O.getTime()-P.getTime(),me=R.getTime()-P.getTime(),pe=new Q(N,me,this.title,this.details,this.id,this.type);return pe}}]),F}();e.TelemetryPoint=void 0,function(F){F[F.Start=0]="Start",F[F.End=1]="End"}(e.TelemetryPoint||(e.TelemetryPoint={})),e.EventSendingLimitation=void 0,function(F){F[F.MinEventsPortion=0]="MinEventsPortion",F[F.AnyEvents=1]="AnyEvents",F[F.AnyEventsIncludingUnfinished=2]="AnyEventsIncludingUnfinished"}(e.EventSendingLimitation||(e.EventSendingLimitation={}));var Kn=function(){function F(q,P){ae.default(this,F),Ve.default(this,"minEventsPortionToSend",50),Ve.default(this,"maxEventsPortionToSend",100),Ve.default(this,"pendingEvents",new Map),Ve.default(this,"readyEvents",[]),Ve.default(this,"hasInitializationFinished",!1),Ve.default(this,"_canSendTelemetry",!1),this.config=q,this.packetInterface=P}return J.default(F,[{key:"isTelemetryEnabled",get:function(){return this.config.confirmedCapabilities.has("telemetry.v1")}},{key:"canSendTelemetry",get:function(){return this._canSendTelemetry&&this.isTelemetryEnabled},set:function(P){He.debug("TelemetryTracker.canSendTelemetry: ".concat(P," TelemetryTracker.isTelemetryEnabled: ").concat(this.isTelemetryEnabled)),this._canSendTelemetry&&!P&&(this.pendingEvents.clear(),this.readyEvents=[]),this._canSendTelemetry=P,P&&this.sendTelemetry(e.EventSendingLimitation.AnyEvents),P&&!this.hasInitializationFinished&&(this.hasInitializationFinished=!0)}},{key:"addTelemetryEvent",value:function(P){!this.canSendTelemetry&&this.hasInitializationFinished||this.readyEvents.push(P)}},{key:"addPartialEvent",value:function(P,O,R){He.debug("Adding ".concat(R===e.TelemetryPoint.Start?"starting":"ending"," timepoint for '").concat(O,"' event"));var U=this.pendingEvents.has(O);if(R===e.TelemetryPoint.Start)U&&He.debug("Overwriting starting point for '".concat(O,"' event")),this.pendingEvents.set(O,P);else{if(!U){He.info("Could not find started event for '".concat(O,"' event"));return}this.addTelemetryEvent(this.merge(this.pendingEvents.get(O),P)),this.pendingEvents.delete(O)}}},{key:"getTelemetryToSend",value:function(P){return!this.canSendTelemetry||this.readyEvents.length==0?[]:P==e.EventSendingLimitation.MinEventsPortion&&this.readyEvents.length<this.minEventsPortionToSend?[]:this.getTelemetryPortion(P==e.EventSendingLimitation.AnyEventsIncludingUnfinished)}},{key:"getTelemetryPortion",value:function(P){var O=this,R=Math.min(this.readyEvents.length,this.maxEventsPortionToSend),U=this.readyEvents.splice(0,R);return P&&U.length<this.maxEventsPortionToSend&&this.pendingEvents.forEach(function(N,me){if(!(U.length>=O.maxEventsPortionToSend)){var pe=O.pendingEvents.get(me);O.pendingEvents.delete(me),U.push(new Zt("[UNFINISHED] ".concat(pe.title),pe.details,pe.start,null,pe.type,pe.id))}}),U}},{key:"merge",value:function(P,O){return new Zt(O.title?O.title:P.title,O.details?O.details:P.details,P.start,O.end,O.type?O.type:P.type,O.id?O.id:P.id)}},{key:"sendTelemetryIfMinimalPortionCollected",value:function(){this.sendTelemetry(e.EventSendingLimitation.MinEventsPortion)}},{key:"sendTelemetry",value:function(P){var O=this.getTelemetryToSend(P);if(O.length!==0)try{this.packetInterface.send(new se(O.map(function(R){return R.toTelemetryEvent()})))}catch(R){He.debug("Error while sending ".concat(O.length," telemetry events due to ").concat(R,"; they will be resubmitted")),this.readyEvents=this.readyEvents.concat(O)}}}]),F}();function Jn(F){var q=kr();return function(){var O=Re.default(F),R;if(q){var U=Re.default(this).constructor;R=Reflect.construct(O,arguments,U)}else R=O.apply(this,arguments);return ye.default(this,R)}}function kr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var nn=function F(){ae.default(this,F)};Ve.default(nn,"TWILSOCK_CONNECT","twilsock.sdk.connect"),Ve.default(nn,"TWILSOCK_INIT","twilsock.sdk.init"),e.TwilsockClient=function(F){Z.default(P,F);var q=Jn(P);function P(O,R,U){var N;ae.default(this,P),N=q.call(this),Ve.default(L.default(N),"version",Pr),Ve.default(L.default(N),"offlineStorageDeferred",new bi),U.continuationToken=U.continuationToken?U.continuationToken:An.getStoredToken(R);var me=N.config=new Cr(O,R,U);He.setLevel(me.logLevel);var pe=new Jr(me.url),Ae=new rn(pe,me);return N.channel=new Yi(pe,Ae,me),N.registrations=new Aa(Ae),N.upstream=new Zi(Ae,N.channel,me),N.telemetryTracker=new Kn(me,Ae),N.channel.on("initialized",function(){return N.telemetryTracker.canSendTelemetry=!0}),pe.on("disconnected",function(){return N.telemetryTracker.canSendTelemetry=!1}),N.registrations.on("registered",function(qe){return N.emit("registered",qe)}),N.channel.on("message",function(qe,at){return setTimeout(function(){return N.emit("message",qe,at)},0)}),N.channel.on("stateChanged",function(qe){return setTimeout(function(){return N.emit("stateChanged",qe)},0)}),N.channel.on("connectionError",function(qe){return setTimeout(function(){return N.emit("connectionError",qe)},0)}),N.channel.on("tokenAboutToExpire",function(){return setTimeout(function(){return N.emit("tokenAboutToExpire")},0)}),N.channel.on("tokenExpired",function(){return setTimeout(function(){return N.emit("tokenExpired")},0)}),N.channel.on("connected",function(){return N.registrations.updateRegistrations()}),N.channel.on("connected",function(){return N.upstream.sendPendingMessages()}),N.channel.on("connected",function(){return setTimeout(function(){return N.emit("connected")},0)}),N.channel.on("beforeConnect",function(){return N.telemetryTracker.addPartialEvent(new Zt("Establish WebSocket connection","",new Date),nn.TWILSOCK_CONNECT,e.TelemetryPoint.Start)}),N.channel.on("connected",function(){return N.telemetryTracker.addPartialEvent(new Zt("Establish WebSocket connection","",new Date,new Date),nn.TWILSOCK_CONNECT,e.TelemetryPoint.End)}),N.channel.on("beforeSendInit",function(){return N.telemetryTracker.addPartialEvent(new Zt("Send Twilsock init","",new Date),nn.TWILSOCK_INIT,e.TelemetryPoint.Start)}),N.channel.on("initialized",function(){return N.telemetryTracker.addPartialEvent(new Zt("Send Twilsock init","Succeeded",new Date,new Date),nn.TWILSOCK_INIT,e.TelemetryPoint.End)}),N.channel.on("sendInitFailed",function(){return N.telemetryTracker.addPartialEvent(new Zt("Send Twilsock init","Failed",new Date,new Date),nn.TWILSOCK_INIT,e.TelemetryPoint.End)}),N.channel.on("initialized",function(qe){N.handleStorageId(R,qe),An.storeToken(qe.continuationToken,R),setTimeout(function(){return N.emit("initialized",qe)},0)}),N.channel.on("disconnected",function(){return setTimeout(function(){return N.emit("disconnected")},0)}),N.channel.on("disconnected",function(){return N.upstream.rejectPendingMessages()}),N.channel.on("disconnected",function(){return N.offlineStorageDeferred.fail(new Ye("Client disconnected"))}),N.offlineStorageDeferred.promise.catch(function(){}),N}return J.default(P,[{key:"emit",value:function(R){for(var U,N=arguments.length,me=new Array(N>1?N-1:0),pe=1;pe<N;pe++)me[pe-1]=arguments[pe];return He.debug("Emitting ".concat(R.toString(),"(").concat(me.map(function(Ae){return JSON.stringify(Ae)}).join(", "),")")),(U=Y.default(Re.default(P.prototype),"emit",this)).call.apply(U,[this,R].concat(me))}},{key:"handleStorageId",value:function(R,U){if(!U.offlineStorage)this.offlineStorageDeferred.fail(new Ye("No offline storage id"));else if(U.offlineStorage.hasOwnProperty(R))try{this.offlineStorageDeferred.set(ea.create(U.offlineStorage[R])),He.debug("Offline storage for '".concat(R,"' product: ").concat(JSON.stringify(U.offlineStorage[R]),"."))}catch(N){this.offlineStorageDeferred.fail(new Ye("Failed to parse offline storage for ".concat(R," ").concat(JSON.stringify(U.offlineStorage[R]),". ").concat(N,".")))}else this.offlineStorageDeferred.fail(new Ye("No offline storage id for '".concat(R,"' product: ").concat(JSON.stringify(U.offlineStorage))))}},{key:"storageId",value:function(){return this.offlineStorageDeferred.promise}},{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"state",get:function(){return this.channel.state}},{key:"updateToken",value:function(){var O=oe.default(be.default.mark(function U(N){return be.default.wrap(function(pe){for(;;)switch(pe.prev=pe.next){case 0:if(He.trace("updating token '".concat(N,"'")),this.config.token!==N){pe.next=3;break}return pe.abrupt("return");case 3:return this.config.updateToken(N),pe.next=6,this.channel.updateToken(N);case 6:return pe.abrupt("return",pe.sent);case 7:case"end":return pe.stop()}},U,this)}));function R(U){return O.apply(this,arguments)}return R}()},{key:"setNotificationsContext",value:function(){var O=oe.default(be.default.mark(function U(N,me){return be.default.wrap(function(Ae){for(;;)switch(Ae.prev=Ae.next){case 0:return Ae.next=2,this.registrations.setNotificationsContext(N,me);case 2:case"end":return Ae.stop()}},U,this)}));function R(U,N){return O.apply(this,arguments)}return R}()},{key:"removeNotificationsContext",value:function(){var O=oe.default(be.default.mark(function U(N){return be.default.wrap(function(pe){for(;;)switch(pe.prev=pe.next){case 0:return pe.next=2,this.registrations.removeNotificationsContext(N);case 2:case"end":return pe.stop()}},U,this)}));function R(U){return O.apply(this,arguments)}return R}()},{key:"connect",value:function(){return this.channel.connect()}},{key:"disconnect",value:function(){var O=oe.default(be.default.mark(function U(){return be.default.wrap(function(me){for(;;)switch(me.prev=me.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEventsIncludingUnfinished),me.next=3,this.channel.disconnect();case 3:return me.abrupt("return",me.sent);case 4:case"end":return me.stop()}},U,this)}));function R(){return O.apply(this,arguments)}return R}()},{key:"get",value:function(){var O=oe.default(be.default.mark(function U(N,me,pe){return be.default.wrap(function(qe){for(;;)switch(qe.prev=qe.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEvents),qe.next=3,this.upstream.send("GET",N,me,void 0,pe);case 3:return qe.abrupt("return",qe.sent);case 4:case"end":return qe.stop()}},U,this)}));function R(U,N,me){return O.apply(this,arguments)}return R}()},{key:"post",value:function(){var O=oe.default(be.default.mark(function U(N,me,pe,Ae){return be.default.wrap(function(at){for(;;)switch(at.prev=at.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEvents),at.next=3,this.upstream.send("POST",N,me,pe,Ae);case 3:return at.abrupt("return",at.sent);case 4:case"end":return at.stop()}},U,this)}));function R(U,N,me,pe){return O.apply(this,arguments)}return R}()},{key:"put",value:function(){var O=oe.default(be.default.mark(function U(N,me,pe,Ae){return be.default.wrap(function(at){for(;;)switch(at.prev=at.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEvents),at.next=3,this.upstream.send("PUT",N,me,pe,Ae);case 3:return at.abrupt("return",at.sent);case 4:case"end":return at.stop()}},U,this)}));function R(U,N,me,pe){return O.apply(this,arguments)}return R}()},{key:"delete",value:function(){var O=oe.default(be.default.mark(function U(N,me,pe,Ae){return be.default.wrap(function(at){for(;;)switch(at.prev=at.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEvents),at.next=3,this.upstream.send("DELETE",N,me,pe,Ae);case 3:return at.abrupt("return",at.sent);case 4:case"end":return at.stop()}},U,this)}));function R(U,N,me,pe){return O.apply(this,arguments)}return R}()},{key:"addTelemetryEvent",value:function(R){this.telemetryTracker.addTelemetryEvent(R),this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}},{key:"addPartialTelemetryEvent",value:function(R,U,N){this.telemetryTracker.addPartialEvent(R,U,N),N===e.TelemetryPoint.End&&this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}}]),P}(je),e.TwilsockClient=G([p.validateConstructorTypes(p.nonEmptyString,p.nonEmptyString,[p.pureObject,"undefined",p.literal(null)]),Qe("design:paramtypes",[String,String,Object])],e.TwilsockClient);var ta=function(){function F(q){ae.default(this,F),this.product=q,this.type="ers",this.notification_protocol_version=0,this.message_types=[]}return J.default(F,[{key:"populateInitRegistrations",value:function(P){var O=new Set(this.message_types);for(var R in P)O.add(P[R]);this.message_types=Array.from(O)}}]),F}();e.InitRegistration=ta,e.TelemetryEventDescription=Zt,e.TelemetryTracker=Kn,e.TransportUnavailableError=Yr,e.Twilsock=e.TwilsockClient,e.TwilsockError=Ye})(Yl);var QE={},k_=Yt,zW=_t,WW=qt,VW=mt,jd=gu,HW=vu,KW=cu,JW=xr,YW=lu,ws=Object.assign,R_=Object.defineProperty,XW=zW([].concat),ZE=!ws||VW(function(){if(k_&&ws({b:1},ws(R_({},"a",{enumerable:!0,get:function(){R_(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var e={},r={},t=Symbol(),n="abcdefghijklmnopqrst";return e[t]=7,n.split("").forEach(function(i){r[i]=i}),ws({},e)[t]!=7||jd(ws({},r)).join("")!=n})?function(r,t){for(var n=JW(r),i=arguments.length,a=1,s=HW.f,c=KW.f;i>a;)for(var o=YW(arguments[a++]),u=s?XW(jd(o),s(o)):jd(o),l=u.length,f=0,d;l>f;)d=u[f++],(!k_||WW(c,o,d))&&(n[d]=o[d]);return n}:ws,QW=St,$_=ZE;QW({target:"Object",stat:!0,arity:2,forced:Object.assign!==$_},{assign:$_});/*
|
|
162
|
+
@license
|
|
163
|
+
The MIT License (MIT)
|
|
164
|
+
|
|
165
|
+
Copyright (c) 2016 Twilio Inc.
|
|
166
|
+
|
|
167
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
168
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
169
|
+
in the Software without restriction, including without limitation the rights
|
|
170
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
171
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
172
|
+
furnished to do so, subject to the following conditions:
|
|
173
|
+
|
|
174
|
+
The above copyright notice and this permission notice shall be included in all
|
|
175
|
+
copies or substantial portions of the Software.
|
|
176
|
+
|
|
177
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
178
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
179
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
180
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
181
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
182
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
183
|
+
SOFTWARE.
|
|
184
|
+
|
|
185
|
+
*/(function(e){Object.defineProperty(e,"__esModule",{value:!0});var r=Tu,t=di,n=wa,i=li,a=fi,s=$n,c=Ru,o=Rn,u=Yl,l=os,f=us,d=Wi,p=fo,h=po,E=pr,M=ou,I=Tr;function x(_e){return _e&&typeof _e=="object"&&"default"in _e?_e:{default:_e}}function j(_e){if(_e&&_e.__esModule)return _e;var Ce=Object.create(null);return _e&&Object.keys(_e).forEach(function(ce){if(ce!=="default"){var de=Object.getOwnPropertyDescriptor(_e,ce);Object.defineProperty(Ce,ce,de.get?de:{enumerable:!0,get:function(){return _e[ce]}})}}),Ce.default=_e,Object.freeze(Ce)}var z=x(r),ie=x(t),oe=x(n),J=x(i),L=x(a),Y=x(s),Z=x(c),ye=x(o),Re=x(l),ae=x(f),Ve=x(p),be=x(h),Te=j(E),we=j(M);function ge(_e,Ce,ce,de){var le=arguments.length,ke=le<3?Ce:de===null?de=Object.getOwnPropertyDescriptor(Ce,ce):de,Ie;if((typeof Reflect>"u"?"undefined":ye.default(Reflect))==="object"&&typeof Reflect.decorate=="function")ke=Reflect.decorate(_e,Ce,ce,de);else for(var ee=_e.length-1;ee>=0;ee--)(Ie=_e[ee])&&(ke=(le<3?Ie(ke):le>3?Ie(Ce,ce,ke):Ie(Ce,ce))||ke);return le>3&&ke&&Object.defineProperty(Ce,ce,ke),ke}function $e(_e,Ce){if((typeof Reflect>"u"?"undefined":ye.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(_e,Ce)}var De;function G(){}G.prototype=Object.create(null);function Qe(){Qe.init.call(this)}Qe.EventEmitter=Qe,Qe.usingDomains=!1,Qe.prototype.domain=void 0,Qe.prototype._events=void 0,Qe.prototype._maxListeners=void 0,Qe.defaultMaxListeners=10,Qe.init=function(){this.domain=null,Qe.usingDomains&&De.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new G,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Qe.prototype.setMaxListeners=function(Ce){if(typeof Ce!="number"||Ce<0||isNaN(Ce))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=Ce,this};function Et(_e){return _e._maxListeners===void 0?Qe.defaultMaxListeners:_e._maxListeners}Qe.prototype.getMaxListeners=function(){return Et(this)};function ut(_e,Ce,ce){if(Ce)_e.call(ce);else for(var de=_e.length,le=xe(_e,de),ke=0;ke<de;++ke)le[ke].call(ce)}function je(_e,Ce,ce,de){if(Ce)_e.call(ce,de);else for(var le=_e.length,ke=xe(_e,le),Ie=0;Ie<le;++Ie)ke[Ie].call(ce,de)}function te(_e,Ce,ce,de,le){if(Ce)_e.call(ce,de,le);else for(var ke=_e.length,Ie=xe(_e,ke),ee=0;ee<ke;++ee)Ie[ee].call(ce,de,le)}function ur(_e,Ce,ce,de,le,ke){if(Ce)_e.call(ce,de,le,ke);else for(var Ie=_e.length,ee=xe(_e,Ie),ve=0;ve<Ie;++ve)ee[ve].call(ce,de,le,ke)}function Me(_e,Ce,ce,de){if(Ce)_e.apply(ce,de);else for(var le=_e.length,ke=xe(_e,le),Ie=0;Ie<le;++Ie)ke[Ie].apply(ce,de)}Qe.prototype.emit=function(Ce){var ce,de,le,ke,Ie,ee,ve,Q=Ce==="error";if(ee=this._events,ee)Q=Q&&ee.error==null;else if(!Q)return!1;if(ve=this.domain,Q){if(ce=arguments[1],ve)ce||(ce=new Error('Uncaught, unspecified "error" event')),ce.domainEmitter=this,ce.domain=ve,ce.domainThrown=!1,ve.emit("error",ce);else{if(ce instanceof Error)throw ce;var se=new Error('Uncaught, unspecified "error" event. ('+ce+")");throw se.context=ce,se}return!1}if(de=ee[Ce],!de)return!1;var X=typeof de=="function";switch(le=arguments.length,le){case 1:ut(de,X,this);break;case 2:je(de,X,this,arguments[1]);break;case 3:te(de,X,this,arguments[1],arguments[2]);break;case 4:ur(de,X,this,arguments[1],arguments[2],arguments[3]);break;default:for(ke=new Array(le-1),Ie=1;Ie<le;Ie++)ke[Ie-1]=arguments[Ie];Me(de,X,this,ke)}return!0};function fe(_e,Ce,ce,de){var le,ke,Ie;if(typeof ce!="function")throw new TypeError('"listener" argument must be a function');if(ke=_e._events,ke?(ke.newListener&&(_e.emit("newListener",Ce,ce.listener?ce.listener:ce),ke=_e._events),Ie=ke[Ce]):(ke=_e._events=new G,_e._eventsCount=0),!Ie)Ie=ke[Ce]=ce,++_e._eventsCount;else if(typeof Ie=="function"?Ie=ke[Ce]=de?[ce,Ie]:[Ie,ce]:de?Ie.unshift(ce):Ie.push(ce),!Ie.warned&&(le=Et(_e),le&&le>0&&Ie.length>le)){Ie.warned=!0;var ee=new Error("Possible EventEmitter memory leak detected. "+Ie.length+" "+Ce+" listeners added. Use emitter.setMaxListeners() to increase limit");ee.name="MaxListenersExceededWarning",ee.emitter=_e,ee.type=Ce,ee.count=Ie.length,Pt(ee)}return _e}function Pt(_e){typeof console.warn=="function"?console.warn(_e):console.log(_e)}Qe.prototype.addListener=function(Ce,ce){return fe(this,Ce,ce,!1)},Qe.prototype.on=Qe.prototype.addListener,Qe.prototype.prependListener=function(Ce,ce){return fe(this,Ce,ce,!0)};function We(_e,Ce,ce){var de=!1;function le(){_e.removeListener(Ce,le),de||(de=!0,ce.apply(_e,arguments))}return le.listener=ce,le}Qe.prototype.once=function(Ce,ce){if(typeof ce!="function")throw new TypeError('"listener" argument must be a function');return this.on(Ce,We(this,Ce,ce)),this},Qe.prototype.prependOnceListener=function(Ce,ce){if(typeof ce!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(Ce,We(this,Ce,ce)),this},Qe.prototype.removeListener=function(Ce,ce){var de,le,ke,Ie,ee;if(typeof ce!="function")throw new TypeError('"listener" argument must be a function');if(le=this._events,!le)return this;if(de=le[Ce],!de)return this;if(de===ce||de.listener&&de.listener===ce)--this._eventsCount===0?this._events=new G:(delete le[Ce],le.removeListener&&this.emit("removeListener",Ce,de.listener||ce));else if(typeof de!="function"){for(ke=-1,Ie=de.length;Ie-- >0;)if(de[Ie]===ce||de[Ie].listener&&de[Ie].listener===ce){ee=de[Ie].listener,ke=Ie;break}if(ke<0)return this;if(de.length===1){if(de[0]=void 0,--this._eventsCount===0)return this._events=new G,this;delete le[Ce]}else gt(de,ke);le.removeListener&&this.emit("removeListener",Ce,ee||ce)}return this},Qe.prototype.off=function(_e,Ce){return this.removeListener(_e,Ce)},Qe.prototype.removeAllListeners=function(Ce){var ce,de;if(de=this._events,!de)return this;if(!de.removeListener)return arguments.length===0?(this._events=new G,this._eventsCount=0):de[Ce]&&(--this._eventsCount===0?this._events=new G:delete de[Ce]),this;if(arguments.length===0){for(var le=Object.keys(de),ke=0,Ie;ke<le.length;++ke)Ie=le[ke],Ie!=="removeListener"&&this.removeAllListeners(Ie);return this.removeAllListeners("removeListener"),this._events=new G,this._eventsCount=0,this}if(ce=de[Ce],typeof ce=="function")this.removeListener(Ce,ce);else if(ce)do this.removeListener(Ce,ce[ce.length-1]);while(ce[0]);return this},Qe.prototype.listeners=function(Ce){var ce,de,le=this._events;return le?(ce=le[Ce],ce?typeof ce=="function"?de=[ce.listener||ce]:de=ft(ce):de=[]):de=[],de},Qe.listenerCount=function(_e,Ce){return typeof _e.listenerCount=="function"?_e.listenerCount(Ce):Kt.call(_e,Ce)},Qe.prototype.listenerCount=Kt;function Kt(_e){var Ce=this._events;if(Ce){var ce=Ce[_e];if(typeof ce=="function")return 1;if(ce)return ce.length}return 0}Qe.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function gt(_e,Ce){for(var ce=Ce,de=ce+1,le=_e.length;de<le;ce+=1,de+=1)_e[ce]=_e[de];_e.pop()}function xe(_e,Ce){for(var ce=new Array(Ce);Ce--;)ce[Ce]=_e[Ce];return ce}function ft(_e){for(var Ce=new Array(_e.length),ce=0;ce<Ce.length;++ce)Ce[ce]=_e[ce].listener||_e[ce];return Ce}var Tt=Te.getLogger("twilio-notificatiions");function Le(_e,Ce){return["".concat(new Date().toISOString()," Twilio.Notifications ").concat(_e,":")].concat(Array.from(Ce))}var Jt=function(){function _e(){ie.default(this,_e)}return oe.default(_e,[{key:"setLevel",value:function(ce){Tt.setLevel(ce)}},{key:"trace",value:function(){for(var ce=arguments.length,de=new Array(ce),le=0;le<ce;le++)de[le]=arguments[le];Tt.trace.apply(null,Le("T",de))}},{key:"debug",value:function(){for(var ce=arguments.length,de=new Array(ce),le=0;le<ce;le++)de[le]=arguments[le];Tt.debug.apply(null,Le("D",de))}},{key:"info",value:function(){for(var ce=arguments.length,de=new Array(ce),le=0;le<ce;le++)de[le]=arguments[le];Tt.info.apply(null,Le("I",de))}},{key:"warn",value:function(){for(var ce=arguments.length,de=new Array(ce),le=0;le<ce;le++)de[le]=arguments[le];Tt.warn.apply(null,Le("W",de))}},{key:"error",value:function(){for(var ce=arguments.length,de=new Array(ce),le=0;le<ce;le++)de[le]=arguments[le];Tt.error.apply(null,Le("E",de))}}]),_e}(),vt=new Jt;function zt(_e){var Ce=nr();return function(){var de=Y.default(_e),le;if(Ce){var ke=Y.default(this).constructor;le=Reflect.construct(de,arguments,ke)}else le=de.apply(this,arguments);return L.default(this,le)}}function nr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var He=oe.default(function _e(){var Ce=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",ce=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",de=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;ie.default(this,_e),this.token=Ce,this.notificationId=ce,this.messageTypes=de});function Pr(_e,Ce){return[].concat(be.default(be.default(_e).filter(function(ce){return!Ce.has(ce)})),be.default(be.default(Ce).filter(function(ce){return!_e.has(ce)})))}function Cr(_e,Ce){var ce=new Set;return _e.notificationId!==Ce.notificationId&&ce.add("notificationId"),_e.token!==Ce.token&&ce.add("token"),Pr(_e.messageTypes,Ce.messageTypes).length>0&&ce.add("messageType"),[ce.size>0,ce]}var Ct=function(_e){J.default(ce,_e);var Ce=zt(ce);function ce(de){var le;return ie.default(this,ce),le=Ce.call(this),ae.default(Re.default(le),"desiredState",new He),ae.default(Re.default(le),"currentState",new He),ae.default(Re.default(le),"_hasActiveAttempt",!1),le.channelType=de,le}return oe.default(ce,[{key:"setNotificationId",value:function(le){this.desiredState.notificationId=le}},{key:"isActive",value:function(){return this.desiredState.notificationId!==""}},{key:"subscribe",value:function(le){if(this.desiredState.messageTypes.has(le)){vt.debug("message type '".concat(le,"' for channel ").concat(this.channelType," is already registered"));return}this.desiredState.messageTypes.add(le)}},{key:"unsubscribe",value:function(le){this.desiredState.messageTypes.has(le)&&this.desiredState.messageTypes.delete(le)}},{key:"updateToken",value:function(le){this.desiredState.token=le}},{key:"commitChanges",value:function(){var de=z.default(Z.default.mark(function ke(){var Ie,ee,ve,Q,se,X;return Z.default.wrap(function(Oe){for(;;)switch(Oe.prev=Oe.next){case 0:if(!this._hasActiveAttempt){Oe.next=3;break}throw vt.error("One registration attempt is already in progress"),new Error("One registration attempt is already in progress");case 3:if(Ie=Cr(this.desiredState,this.currentState),ee=Ve.default(Ie,2),ve=ee[0],Q=ee[1],ve){Oe.next=6;break}return Oe.abrupt("return");case 6:if(this.currentState.notificationId||Q.delete("notificationId"),vt.trace("Persisting ".concat(this.channelType," registration"),Q,this.desiredState),Oe.prev=8,this._hasActiveAttempt=!0,se=new He,se.token=this.desiredState.token,se.notificationId=this.desiredState.notificationId,se.messageTypes=new Set(this.desiredState.messageTypes),!(se.messageTypes.size>0)){Oe.next=24;break}return Oe.next=17,this.updateRegistration(se,Q);case 17:X=Oe.sent,this.currentState.token=X.token,this.currentState.notificationId=X.notificationId,this.currentState.messageTypes=new Set(X.messageTypes),this.emit("stateChanged",this.channelType,"registered",this.currentState),Oe.next=30;break;case 24:return Oe.next=26,this.removeRegistration();case 26:this.currentState.token=se.token,this.currentState.notificationId=se.notificationId,this.currentState.messageTypes.clear(),this.emit("stateChanged",this.channelType,"unregistered",this.currentState);case 30:Oe.next=35;break;case 32:throw Oe.prev=32,Oe.t0=Oe.catch(8),Oe.t0;case 35:return Oe.prev=35,this._hasActiveAttempt=!1,Oe.finish(35);case 38:case"end":return Oe.stop()}},ke,this,[[8,32,35,38]])}));function le(){return de.apply(this,arguments)}return le}()}]),ce}(Qe);function kt(_e){var Ce=yt();return function(){var de=Y.default(_e),le;if(Ce){var ke=Y.default(this).constructor;le=Reflect.construct(de,arguments,ke)}else le=de.apply(this,arguments);return L.default(this,le)}}function yt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var st={min:2e3,max:12e4,randomness:.2},Lt=function(_e){J.default(ce,_e);var Ce=kt(ce);function ce(de,le,ke,Ie){var ee;return ie.default(this,ce),ee=Ce.call(this,de),ae.default(Re.default(ee),"registrationId",null),ee.context=le,ee.twilsock=ke,ee.registrarUrl=Ie,ee}return oe.default(ce,[{key:"updateRegistration",value:function(){var de=z.default(Z.default.mark(function ke(Ie,ee){var ve=this,Q,se,X,Ue,Oe;return Z.default.wrap(function(Ke){for(;;)switch(Ke.prev=Ke.next){case 0:if(!ee.has("notificationId")){Ke.next=3;break}return Ke.next=3,this.removeRegistration();case 3:if(!(!Ie.notificationId||!Ie.notificationId.length)){Ke.next=6;break}throw vt.error("No push notification ID for registration"),new Error("No push notification ID for registration");case 6:return vt.trace("Registering",this.channelType,Ie),Q={endpoint_platform:this.context.platform,channel_type:this.channelType,version:this.context.protocolVersion.toString(),message_types:Array.from(Ie.messageTypes),data:{registration_id:Ie.notificationId}},se=this.context.productId,X="".concat(this.registrarUrl,"?productId=").concat(se),Ue={"Content-Type":"application/json"},vt.trace("Creating registration for channel ".concat(this.channelType)),Ke.prev=12,Ke.next=15,new d.AsyncRetrier(st).run(function(){return ve.twilsock.post(X,Ue,Q,se)});case 15:Oe=Ke.sent,this.registrationId=Oe.body.id,vt.debug("Registration created: ",Oe),Ke.next=24;break;case 20:throw Ke.prev=20,Ke.t0=Ke.catch(12),vt.error("Registration failed: ",Ke.t0),Ke.t0;case 24:return Ke.abrupt("return",Ie);case 25:case"end":return Ke.stop()}},ke,this,[[12,20]])}));function le(ke,Ie){return de.apply(this,arguments)}return le}()},{key:"removeRegistration",value:function(){var de=z.default(Z.default.mark(function ke(){var Ie=this,ee,ve,Q;return Z.default.wrap(function(X){for(;;)switch(X.prev=X.next){case 0:if(this.registrationId){X.next=2;break}return X.abrupt("return");case 2:return ee=this.context.productId,ve="".concat(this.registrarUrl,"/").concat(this.registrationId,"?productId=").concat(ee),Q={"Content-Type":"application/json"},vt.trace("Removing registration for ".concat(this.channelType)),X.prev=6,X.next=9,new d.AsyncRetrier(Object.assign(st,{maxAttemptsCount:3})).run(function(){return Ie.twilsock.delete(ve,Q,{},ee)});case 9:this.registrationId=null,this.currentState.notificationId="",vt.debug("Registration removed for ".concat(this.channelType)),X.next=18;break;case 14:throw X.prev=14,X.t0=X.catch(6),vt.error("Failed to remove registration ",this.channelType,X.t0),X.t0;case 18:case"end":return X.stop()}},ke,this,[[6,14]])}));function le(){return de.apply(this,arguments)}return le}()},{key:"sendDeviceRemoveRequest",value:function(){var de=z.default(Z.default.mark(function ke(Ie){var ee=this,ve,Q,se,X;return Z.default.wrap(function(Oe){for(;;)switch(Oe.prev=Oe.next){case 0:if(Ie!==""){Oe.next=2;break}throw new Error("Empty registration ID");case 2:return ve=this.context.productId,Q="".concat(this.registrarUrl,"?productId=").concat(ve),se={"Content-Type":"application/json"},X={binding_type:this.channelType,address:Ie},Oe.prev=6,vt.trace("Removing old registrations for ".concat(this.channelType)),Oe.next=10,new d.AsyncRetrier(Object.assign(st,{maxAttemptsCount:3})).run(function(){return ee.twilsock.delete(Q,se,X,ve)});case 10:this.registrationId=null,this.currentState.notificationId="",vt.debug("Registration removed for ".concat(this.channelType)),Oe.next=19;break;case 15:throw Oe.prev=15,Oe.t0=Oe.catch(6),vt.error("Failed to remove registration ",this.channelType,Oe.t0),Oe.t0;case 19:case"end":return Oe.stop()}},ke,this,[[6,15]])}));function le(ke){return de.apply(this,arguments)}return le}()}]),ce}(Ct);function Xt(_e){var Ce=hr();return function(){var de=Y.default(_e),le;if(Ce){var ke=Y.default(this).constructor;le=Reflect.construct(de,arguments,ke)}else le=de.apply(this,arguments);return L.default(this,le)}}function hr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var hn=function(_e){J.default(ce,_e);var Ce=Xt(ce);function ce(de,le,ke){var Ie;return ie.default(this,ce),Ie=Ce.call(this,"twilsock"),ae.default(Re.default(Ie),"contextId",we.v4()),Ie.productId=de,Ie.platform=le,Ie.twilsock=ke,Ie}return oe.default(ce,[{key:"updateRegistration",value:function(){var de=z.default(Z.default.mark(function ke(Ie,ee){var ve,Q;return Z.default.wrap(function(X){for(;;)switch(X.prev=X.next){case 0:if(ee.has("messageType")){X.next=2;break}return X.abrupt("return",Ie);case 2:return ve=Array.from(Ie.messageTypes),Q={product_id:this.productId,notification_protocol_version:4,endpoint_platform:this.platform,message_types:ve},X.prev=4,X.next=7,this.twilsock.setNotificationsContext(this.contextId,Q);case 7:X.next=13;break;case 9:throw X.prev=9,X.t0=X.catch(4),vt.error("Failed to update twilsock notification context: ".concat(X.t0)),X.t0;case 13:return X.abrupt("return",Ie);case 14:case"end":return X.stop()}},ke,this,[[4,9]])}));function le(ke,Ie){return de.apply(this,arguments)}return le}()},{key:"removeRegistration",value:function(){var de=z.default(Z.default.mark(function ke(){return Z.default.wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:return ee.prev=0,ee.next=3,this.twilsock.removeNotificationsContext(this.contextId);case 3:ee.next=9;break;case 5:throw ee.prev=5,ee.t0=ee.catch(0),vt.error("Failed to remove twilsock notification context: ".concat(ee.t0)),ee.t0;case 9:case"end":return ee.stop()}},ke,this,[[0,5]])}));function le(){return de.apply(this,arguments)}return le}()},{key:"sendDeviceRemoveRequest",value:function(){var de=z.default(Z.default.mark(function ke(Ie){return Z.default.wrap(function(ve){for(;;)switch(ve.prev=ve.next){case 0:case"end":return ve.stop()}},ke)}));function le(ke){return de.apply(this,arguments)}return le}()}]),ce}(Ct);function Pn(_e){var Ce=_r();return function(){var de=Y.default(_e),le;if(Ce){var ke=Y.default(this).constructor;le=Reflect.construct(de,arguments,ke)}else le=de.apply(this,arguments);return L.default(this,le)}}function _r(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Wt,Nr=I.literal("apn","fcm","twilsock");e.Notifications=Wt=function(_e){J.default(ce,_e);var Ce=Pn(ce);function ce(de){var le,ke,Ie,ee,ve,Q,se,X=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};ie.default(this,ce),se=Ce.call(this),X.logLevel=(le=X.logLevel)!==null&&le!==void 0?le:"error",vt.setLevel(X.logLevel);var Ue=(ke=X.productId)!==null&&ke!==void 0?ke:"notifications",Oe=!X.twilsockClient,Ze=X.twilsockClient=(Ie=X.twilsockClient)!==null&&Ie!==void 0?Ie:new u.TwilsockClient(de,Ue,X),Ke=(ee=X.notifications)!==null&&ee!==void 0?ee:{},Je=(ve=(Q=Ke.region)!==null&&Q!==void 0?Q:X.region)!==null&&ve!==void 0?ve:"us1",rt="https://ers.".concat(Je,".twilio.com/v1/registrations"),nt=Ke.ersUrl||rt;se.connectors=new Map;var Ye=Wt._detectPlatform();return se.connectors.set("apn",new Lt("apn",{protocolVersion:4,productId:Ue,platform:Ye},Ze,nt)),se.connectors.set("fcm",new Lt("fcm",{protocolVersion:3,productId:Ue,platform:Ye},Ze,nt)),se.connectors.set("twilsock",new hn(Ue,Ye,Ze)),Ze.on("stateChanged",function(tt){return se.emit("transportState",tt)}),se._connector("twilsock").on("stateChanged",function(tt,it,ct){return se.emit("stateChanged",tt,it,ct)}),se._connector("apn").on("stateChanged",function(tt,it,ct){return se.emit("stateChanged",tt,it,ct)}),se._connector("fcm").on("stateChanged",function(tt,it,ct){return se.emit("stateChanged",tt,it,ct)}),Ze.on("message",function(tt,it){return se._routeMessage(tt,it)}),se.updateToken(de),Oe&&(Ze.connect(),se.twilsock=Ze),se}return oe.default(ce,[{key:"shutdown",value:function(){var de=z.default(Z.default.mark(function ke(){return Z.default.wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:if(this.connectors.clear(),!this.twilsock){ee.next=4;break}return ee.next=4,this.twilsock.disconnect();case 4:case"end":return ee.stop()}},ke,this)}));function le(){return de.apply(this,arguments)}return le}()},{key:"setPushRegistrationId",value:function(le,ke){vt.debug("Set ".concat(le," push registration id '").concat(ke,"'")),this._connector(le).setNotificationId(ke)}},{key:"subscribe",value:function(le,ke){vt.debug("Add ".concat(le," subscriptions for message type ").concat(ke)),this._connector(le).subscribe(ke)}},{key:"unsubscribe",value:function(le,ke){vt.debug("Remove ".concat(le," subscriptions for message type ").concat(ke)),this._connector(le).unsubscribe(ke)}},{key:"updateToken",value:function(le){this.connectors.forEach(function(ke){return ke.updateToken(le)})}},{key:"commitChanges",value:function(){var de=z.default(Z.default.mark(function ke(){var Ie;return Z.default.wrap(function(ve){for(;;)switch(ve.prev=ve.next){case 0:return Ie=[],this.connectors.forEach(function(Q){Q.isActive()&&Ie.push(Q.commitChanges())}),ve.next=4,Promise.all(Ie);case 4:case"end":return ve.stop()}},ke,this)}));function le(){return de.apply(this,arguments)}return le}()},{key:"removeRegistrations",value:function(){var de=z.default(Z.default.mark(function ke(Ie,ee){return Z.default.wrap(function(Q){for(;;)switch(Q.prev=Q.next){case 0:return Q.next=2,this._connector(Ie).sendDeviceRemoveRequest(ee);case 2:case"end":return Q.stop()}},ke,this)}));function le(ke,Ie){return de.apply(this,arguments)}return le}()},{key:"handlePushNotification",value:function(le){return{messageType:le.twi_message_type,payload:le.payload}}},{key:"_routeMessage",value:function(le,ke){vt.debug("Notification message arrived: ",le,ke),this.emit("message",le,ke)}},{key:"_connector",value:function(le){var ke=this.connectors.get(le);if(!ke)throw new Error("Unknown channel type: ".concat(le));return ke}}],[{key:"_detectPlatform",value:function(){var le="";return typeof navigator<"u"?(le="unknown",typeof navigator.product<"u"&&(le=navigator.product),typeof navigator.userAgent<"u"&&(le=navigator.userAgent)):le="web",le.substring(0,128)}}]),ce}(Qe),ge([I.validateTypes(Nr,I.nonEmptyString),$e("design:type",Function),$e("design:paramtypes",[String,String]),$e("design:returntype",void 0)],e.Notifications.prototype,"setPushRegistrationId",null),ge([I.validateTypes(Nr,I.nonEmptyString),$e("design:type",Function),$e("design:paramtypes",[String,String]),$e("design:returntype",void 0)],e.Notifications.prototype,"subscribe",null),ge([I.validateTypes(Nr,I.nonEmptyString),$e("design:type",Function),$e("design:paramtypes",[String,String]),$e("design:returntype",void 0)],e.Notifications.prototype,"unsubscribe",null),ge([I.validateTypes(I.nonEmptyString),$e("design:type",Function),$e("design:paramtypes",[String]),$e("design:returntype",void 0)],e.Notifications.prototype,"updateToken",null),ge([I.validateTypesAsync(Nr,I.nonEmptyString),$e("design:type",Function),$e("design:paramtypes",[String,String]),$e("design:returntype",Promise)],e.Notifications.prototype,"removeRegistrations",null),e.Notifications=Wt=ge([I.validateConstructorTypes(I.nonEmptyString,[I.pureObject,"undefined",I.literal(null)]),$e("design:paramtypes",[String,Object])],e.Notifications)})(QE);var tn={},Wr={};/*
|
|
186
|
+
@license
|
|
187
|
+
Copyright (c) 2021 Twilio Inc.
|
|
188
|
+
|
|
189
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
190
|
+
|
|
191
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
192
|
+
|
|
193
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
*/Object.defineProperty(Wr,"__esModule",{value:!0});var ZW=Rn,eV=fo,tV=po,rV=di,nV=li,iV=fi,aV=$n;function ds(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var zs=ds(ZW),Za=ds(eV),Fd=ds(tV),sV=ds(rV),oV=ds(nV),uV=ds(iV),O_=ds(aV),Ea=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return{checks:t}};function cV(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=lV(e))||r&&e&&typeof e.length=="number"){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
197
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,c;return{s:function(){t=t.call(e)},n:function(){var u=t.next();return a=u.done,u},e:function(u){s=!0,c=u},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw c}}}}function lV(e,r){if(e){if(typeof e=="string")return I_(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return I_(e,r)}}function I_(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var ek=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return Ea(function(i){var a=!1,s=[],c=cV(t),o;try{for(c.s();!(o=c.n()).done;){var u=o.value;if(typeof u=="string"){a=a||zs.default(i)===u,s.push("of type ".concat(u));continue}a=a||i instanceof u,s.push("an instance of ".concat(u.name))}}catch(l){c.e(l)}finally{c.f()}return[a,s]})};function fV(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=dV(e))||r&&e&&typeof e.length=="number"){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
198
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,c;return{s:function(){t=t.call(e)},n:function(){var u=t.next();return a=u.done,u},e:function(u){s=!0,c=u},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw c}}}}function dV(e,r){if(e){if(typeof e=="string")return P_(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return P_(e,r)}}function P_(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var pV=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return Ea(function(i){var a=!1,s=[],c=fV(t),o;try{for(c.s();!(o=c.n()).done;){var u=o.value;a=a||i===u,s.push(typeof u=="string"?'"'.concat(u,'"'):"".concat(u))}}catch(l){c.e(l)}finally{c.f()}return[a,s]})},hV=Ea(function(e){return[typeof e=="string"&&e.length>0,"a non-empty string"]}),vV=Ea(function(e){return[typeof e=="number"&&Number.isInteger(e)&&e>=0,"a non-negative integer"]}),mV=Ea(function(e){return[zs.default(e)==="object"&&e!==null&&!Array.isArray(e),"a pure object (non-null and non-array)"]});function gV(e){var r=yV();return function(){var n=O_.default(e),i;if(r){var a=O_.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return uV.default(this,i)}}function yV(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function au(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=bV(e))||r&&e&&typeof e.length=="number"){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
199
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,c;return{s:function(){t=t.call(e)},n:function(){var u=t.next();return a=u.done,u},e:function(u){s=!0,c=u},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw c}}}}function bV(e,r){if(e){if(typeof e=="string")return A_(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return A_(e,r)}}function A_(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var of=function(r,t){if(t.length>r.length)throw new Error("Expected at most ".concat(r.length," argument(s), but got ").concat(t.length));for(;t.length<r.length;)t.push(void 0);var n=au(t.entries()),i;try{for(n.s();!(i=n.n()).done;){var a=Za.default(i.value,2),s=a[0],c=a[1],o=gm(r[s],c),u=Za.default(o,4),l=u[0],f=u[1],d=u[2],p=u[3];if(!l){var h=s+1;throw new Error("Argument ".concat(h," is expected to be ").concat(d).concat(p," but got ").concat(f))}}}catch(E){n.e(E)}finally{n.f()}},tk=function(r){var t,n,i=["undefined","boolean","number","bigint","string"];if(i.includes(zs.default(r))&&(n=typeof r=="string"?'"'.concat(r,'"'):"".concat(r)),zs.default(r)==="object"&&(r==null||(t=r.constructor)===null||t===void 0?void 0:t.name)!=="Object"){var a;n=r===null?"null":"instance of ".concat(r==null||(a=r.constructor)===null||a===void 0?void 0:a.name)}return n||(n=zs.default(r)),n},_V=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=vm(t);return function(a){return function(s){oV.default(o,s);var c=gV(o);function o(){sV.default(this,o);for(var u=arguments.length,l=new Array(u),f=0;f<u;f++)l[f]=arguments[f];return of(i,l),c.call.apply(c,[this].concat(l))}return o}(a)}},SV=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=vm(t);return function(a,s,c){if(typeof c.value!="function")throw new Error("The validateTypes decorator can only be applied to methods");var o=c.value;c.value=function(){for(var u=arguments.length,l=new Array(u),f=0;f<u;f++)l[f]=arguments[f];return of(i,l),o.apply(this,l)}}},wV=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=vm(t);return function(a,s,c){if(typeof c.value!="function")throw new Error("The validateTypesAsync decorator can only be applied to methods");var o=c.value;c.value=function(){for(var u=arguments.length,l=new Array(u),f=0;f<u;f++)l[f]=arguments[f];try{of(i,l)}catch(d){return Promise.reject(d)}return o.apply(this,l)}}},vm=function(r){var t=[],n=au(r),i;try{for(n.s();!(i=n.n()).done;){var a=i.value;t.push(mm(a))}}catch(s){n.e(s)}finally{n.f()}return t},mm=function(r){var t=[],n=Array.isArray(r)?r:[r],i=au(n),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;if(typeof s=="string"||typeof s=="function"){t.push(ek(s));continue}t.push(s)}}catch(c){i.e(c)}finally{i.f()}return t},gm=function(r,t){var n=[],i,a=!1,s=au(r),c;try{for(s.s();!(c=s.n()).done;){var o=c.value,u=au(o.checks),l;try{for(u.s();!(l=u.n()).done;){var f=l.value,d=f(t),p=Za.default(d,3),h=p[0],E=p[1],M=p[2];a=a||h,!i&&M&&(i=M),E&&(n=typeof E=="string"?[].concat(Fd.default(n),[E]):[].concat(Fd.default(n),Fd.default(E)))}}catch(z){u.e(z)}finally{u.f()}}}catch(z){s.e(z)}finally{s.f()}if(a)return[!0];var I=i||tk(t),x=n.length-1,j=x>0?"".concat(n.slice(0,x).join(", ")," or ").concat(n[x]):n.join(", ");return[!1,I,j,x>1?";":","]},TV=function(r,t){return Ea(function(n){if(zs.default(n)!=="object"||n===null||Array.isArray(n))return[!1,"valid ".concat(r," (should be a pure object)")];for(var i=0,a=Object.entries(t);i<a.length;i++){var s=Za.default(a[i],2),c=s[0],o=s[1],u=gm(mm(o),n[c]),l=Za.default(u,3),f=l[0],d=l[1],p=l[2];if(!f)return[!1,"valid ".concat(r,' (key "').concat(c,'" should be ').concat(p,")"),"malformed ".concat(r,' (key "').concat(c,'" is ').concat(d,")")]}return[!0]})};function CV(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=EV(e))||r&&e&&typeof e.length=="number"){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
200
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,c;return{s:function(){t=t.call(e)},n:function(){var u=t.next();return a=u.done,u},e:function(u){s=!0,c=u},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw c}}}}function EV(e,r){if(e){if(typeof e=="string")return M_(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return M_(e,r)}}function M_(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var kV=function(r,t){return Ea(function(n){if(!Array.isArray(n))return[!1,"an array of ".concat(r)];var i=CV(n.entries()),a;try{for(i.s();!(a=i.n()).done;){var s=Za.default(a.value,2),c=s[0],o=s[1],u=gm(mm(t),o),l=Za.default(u,3),f=l[0],d=l[1],p=l[2];if(!f)return[!1,"a valid array of ".concat(r," (index ").concat(c," should be ").concat(p,")"),"malformed array of ".concat(r," (index ").concat(c," is ").concat(d,")")]}}catch(h){i.e(h)}finally{i.f()}return[!0]})};Wr.array=kV;Wr.custom=Ea;Wr.literal=pV;Wr.nonEmptyString=hV;Wr.nonNegativeInteger=vV;Wr.objectSchema=TV;Wr.pureObject=mV;Wr.runtimeTypeValidation=of;Wr.stringifyReceivedType=tk;Wr.type=ek;Wr.validateConstructorTypes=_V;Wr.validateTypes=SV;Wr.validateTypesAsync=wV;/*
|
|
201
|
+
@license
|
|
202
|
+
The following license applies to all parts of this software except as
|
|
203
|
+
documented below.
|
|
204
|
+
|
|
205
|
+
Copyright (c) 2016, Twilio, inc.
|
|
206
|
+
All rights reserved.
|
|
207
|
+
|
|
208
|
+
Redistribution and use in source and binary forms, with or without
|
|
209
|
+
modification, are permitted provided that the following conditions are
|
|
210
|
+
met:
|
|
211
|
+
|
|
212
|
+
1. Redistributions of source code must retain the above copyright
|
|
213
|
+
notice, this list of conditions and the following disclaimer.
|
|
214
|
+
|
|
215
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
216
|
+
notice, this list of conditions and the following disclaimer in
|
|
217
|
+
the documentation and/or other materials provided with the
|
|
218
|
+
distribution.
|
|
219
|
+
|
|
220
|
+
3. Neither the name of Twilio nor the names of its contributors may
|
|
221
|
+
be used to endorse or promote products derived from this software
|
|
222
|
+
without specific prior written permission.
|
|
223
|
+
|
|
224
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
225
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
226
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
227
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
228
|
+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
229
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
230
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
231
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
232
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
233
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
234
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
235
|
+
|
|
236
|
+
This software includes loglevel under the following license.
|
|
237
|
+
|
|
238
|
+
Copyright (c) 2013 Tim Perry
|
|
239
|
+
|
|
240
|
+
Permission is hereby granted, free of charge, to any person
|
|
241
|
+
obtaining a copy of this software and associated documentation
|
|
242
|
+
files (the "Software"), to deal in the Software without
|
|
243
|
+
restriction, including without limitation the rights to use,
|
|
244
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
245
|
+
copies of the Software, and to permit persons to whom the
|
|
246
|
+
Software is furnished to do so, subject to the following
|
|
247
|
+
conditions:
|
|
248
|
+
|
|
249
|
+
The above copyright notice and this permission notice shall be
|
|
250
|
+
included in all copies or substantial portions of the Software.
|
|
251
|
+
|
|
252
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
253
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
254
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
255
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
256
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
257
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
258
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
259
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
260
|
+
|
|
261
|
+
This software includes Backoff library under the following license
|
|
262
|
+
|
|
263
|
+
Copyright (C) 2012 Mathieu Turcotte
|
|
264
|
+
|
|
265
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
266
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
267
|
+
the Software without restriction, including without limitation the rights to
|
|
268
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
269
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
270
|
+
so, subject to the following conditions:
|
|
271
|
+
|
|
272
|
+
The above copyright notice and this permission notice shall be included in all
|
|
273
|
+
copies or substantial portions of the Software.
|
|
274
|
+
|
|
275
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
276
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
277
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
278
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
279
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
280
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
281
|
+
SOFTWARE.
|
|
282
|
+
|
|
283
|
+
This software includes Event-to-Promise library under the following license
|
|
284
|
+
|
|
285
|
+
Copyright (c) 2014, Julien Fontanet <julien.fontanet@isonoe.net>.
|
|
286
|
+
|
|
287
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
288
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
289
|
+
and this permission notice appear in all copies.
|
|
290
|
+
|
|
291
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
292
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
293
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
294
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
295
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
296
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
297
|
+
THIS SOFTWARE.
|
|
298
|
+
|
|
299
|
+
*/Object.defineProperty(tn,"__esModule",{value:!0});var RV=Tu,$V=di,OV=wa,IV=os,PV=li,AV=fi,MV=$n,xV=us,NV=Ru,LV=Rn,Pe=Wr,dl=Yl,DV=sf,jV=pr,FV=fo,rk=Wi,nk=ou,UV=Bv,BV=XE;function dn(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function ym(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach(function(t){if(t!=="default"){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),r.default=e,Object.freeze(r)}var Be=dn(RV),Ot=dn($V),Nt=dn(OV),ti=dn(IV),Vr=dn(PV),ka=dn(AV),or=dn(MV),jt=dn(xV),ne=dn(NV),ik=dn(LV),qV=dn(DV),GV=ym(jV),ak=dn(FV),zV=ym(nk),Iu=dn(UV),dc=ym(BV);function It(e,r,t,n){var i=arguments.length,a=i<3?r:n===null?n=Object.getOwnPropertyDescriptor(r,t):n,s;if((typeof Reflect>"u"?"undefined":ik.default(Reflect))==="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(e,r,t,n);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(a=(i<3?s(a):i>3?s(r,t,a):s(r,t))||a);return i>3&&a&&Object.defineProperty(r,t,a),a}function Ne(e,r){if((typeof Reflect>"u"?"undefined":ik.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,r)}var WV;function va(){}va.prototype=Object.create(null);function Ut(){Ut.init.call(this)}Ut.EventEmitter=Ut;Ut.usingDomains=!1;Ut.prototype.domain=void 0;Ut.prototype._events=void 0;Ut.prototype._maxListeners=void 0;Ut.defaultMaxListeners=10;Ut.init=function(){this.domain=null,Ut.usingDomains&&WV.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new va,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Ut.prototype.setMaxListeners=function(r){if(typeof r!="number"||r<0||isNaN(r))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=r,this};function sk(e){return e._maxListeners===void 0?Ut.defaultMaxListeners:e._maxListeners}Ut.prototype.getMaxListeners=function(){return sk(this)};function VV(e,r,t){if(r)e.call(t);else for(var n=e.length,i=Pu(e,n),a=0;a<n;++a)i[a].call(t)}function HV(e,r,t,n){if(r)e.call(t,n);else for(var i=e.length,a=Pu(e,i),s=0;s<i;++s)a[s].call(t,n)}function KV(e,r,t,n,i){if(r)e.call(t,n,i);else for(var a=e.length,s=Pu(e,a),c=0;c<a;++c)s[c].call(t,n,i)}function JV(e,r,t,n,i,a){if(r)e.call(t,n,i,a);else for(var s=e.length,c=Pu(e,s),o=0;o<s;++o)c[o].call(t,n,i,a)}function YV(e,r,t,n){if(r)e.apply(t,n);else for(var i=e.length,a=Pu(e,i),s=0;s<i;++s)a[s].apply(t,n)}Ut.prototype.emit=function(r){var t,n,i,a,s,c,o,u=r==="error";if(c=this._events,c)u=u&&c.error==null;else if(!u)return!1;if(o=this.domain,u){if(t=arguments[1],o)t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=o,t.domainThrown=!1,o.emit("error",t);else{if(t instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}return!1}if(n=c[r],!n)return!1;var f=typeof n=="function";switch(i=arguments.length,i){case 1:VV(n,f,this);break;case 2:HV(n,f,this,arguments[1]);break;case 3:KV(n,f,this,arguments[1],arguments[2]);break;case 4:JV(n,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(a=new Array(i-1),s=1;s<i;s++)a[s-1]=arguments[s];YV(n,f,this,a)}return!0};function ok(e,r,t,n){var i,a,s;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(a=e._events,a?(a.newListener&&(e.emit("newListener",r,t.listener?t.listener:t),a=e._events),s=a[r]):(a=e._events=new va,e._eventsCount=0),!s)s=a[r]=t,++e._eventsCount;else if(typeof s=="function"?s=a[r]=n?[t,s]:[s,t]:n?s.unshift(t):s.push(t),!s.warned&&(i=sk(e),i&&i>0&&s.length>i)){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+r+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=r,c.count=s.length,XV(c)}return e}function XV(e){typeof console.warn=="function"?console.warn(e):console.log(e)}Ut.prototype.addListener=function(r,t){return ok(this,r,t,!1)};Ut.prototype.on=Ut.prototype.addListener;Ut.prototype.prependListener=function(r,t){return ok(this,r,t,!0)};function uk(e,r,t){var n=!1;function i(){e.removeListener(r,i),n||(n=!0,t.apply(e,arguments))}return i.listener=t,i}Ut.prototype.once=function(r,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.on(r,uk(this,r,t)),this};Ut.prototype.prependOnceListener=function(r,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(r,uk(this,r,t)),this};Ut.prototype.removeListener=function(r,t){var n,i,a,s,c;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[r],!n)return this;if(n===t||n.listener&&n.listener===t)--this._eventsCount===0?this._events=new va:(delete i[r],i.removeListener&&this.emit("removeListener",r,n.listener||t));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===t||n[s].listener&&n[s].listener===t){c=n[s].listener,a=s;break}if(a<0)return this;if(n.length===1){if(n[0]=void 0,--this._eventsCount===0)return this._events=new va,this;delete i[r]}else QV(n,a);i.removeListener&&this.emit("removeListener",r,c||t)}return this};Ut.prototype.off=function(e,r){return this.removeListener(e,r)};Ut.prototype.removeAllListeners=function(r){var t,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new va,this._eventsCount=0):n[r]&&(--this._eventsCount===0?this._events=new va:delete n[r]),this;if(arguments.length===0){for(var i=Object.keys(n),a=0,s;a<i.length;++a)s=i[a],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=new va,this._eventsCount=0,this}if(t=n[r],typeof t=="function")this.removeListener(r,t);else if(t)do this.removeListener(r,t[t.length-1]);while(t[0]);return this};Ut.prototype.listeners=function(r){var t,n,i=this._events;return i?(t=i[r],t?typeof t=="function"?n=[t.listener||t]:n=ZV(t):n=[]):n=[],n};Ut.listenerCount=function(e,r){return typeof e.listenerCount=="function"?e.listenerCount(r):ck.call(e,r)};Ut.prototype.listenerCount=ck;function ck(e){var r=this._events;if(r){var t=r[e];if(typeof t=="function")return 1;if(t)return t.length}return 0}Ut.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function QV(e,r){for(var t=r,n=t+1,i=e.length;n<i;t+=1,n+=1)e[t]=e[n];e.pop()}function Pu(e,r){for(var t=new Array(r);r--;)t[r]=e[r];return t}function ZV(e){for(var r=new Array(e.length),t=0;t<r.length;++t)r[t]=e[t].listener||e[t];return r}var Ys=function(){function e(r){Ot.default(this,e),this.base=r,this.args=new Array,this.paths=new Array}return Nt.default(e,[{key:"pathSegment",value:function(t){return this.paths.push(encodeURIComponent(t)),this}},{key:"queryParam",value:function(t,n){return typeof n<"u"&&this.args.push(encodeURIComponent(t)+"="+encodeURIComponent(n)),this}},{key:"build",value:function(){var t=this.base;return this.paths.length&&(t+="/"+this.paths.join("/")),this.args.length&&(t+="?"+this.args.join("&")),t}}]),e}();function lk(e){var r=eH();return function(){var n=or.default(e),i;if(r){var a=or.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return ka.default(this,i)}}function eH(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var en=function(e){Vr.default(t,e);var r=lk(t);function t(n){var i,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;return Ot.default(this,t),i=r.call(this),i.name=i.constructor.name,i.message="".concat(n," (status: ").concat(a,", code: ").concat(s,")"),i.status=a,i.code=s,i}return t}(qV.default(Error)),tH=function(e){Vr.default(t,e);var r=lk(t);function t(n){var i,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,c=arguments.length>3?arguments[3]:void 0;return Ot.default(this,t),i=r.call(this,n,a,s),i.body=c,i}return t}(en);function Bn(e){return JSON.parse(JSON.stringify(e))}function fk(e){var r=e===void 0||bm(e);if(!r)throw new en("Invalid pageSize parameter. Expected a positive integer, was '".concat(e,"'."),400,20007)}function rH(e){return!isNaN(parseInt(e))&&isFinite(e)}function bm(e){return rH(e)&&e>0}var Ts=GV.getLogger("twilio-sync");function Po(e,r){return["".concat(new Date().toISOString()," Sync ").concat(e,":")].concat(Array.from(r))}var Mt={setLevel:function(r){Ts.setLevel(r)},trace:function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];Ts.trace.apply(null,Po("T",t))},debug:function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];Ts.debug.apply(null,Po("D",t))},info:function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];Ts.info.apply(null,Po("I",t))},warn:function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];Ts.warn.apply(null,Po("W",t))},error:function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];Ts.error.apply(null,Po("E",t))}},nH="/v4/Subscriptions",iH="/v3/Maps",aH="/v3/Lists",sH="/v3/Documents",oH="/v3/Streams",uH="/v3/Insights";function cH(e,r,t){return e&&typeof e[r]<"u"?e[r]:t}var lH=function(){function e(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ot.default(this,e);var t=r.region||"us1",n="https://cds.".concat(t,".twilio.com"),i=r.cdsUri||n;this.settings={subscriptionsUri:i+nH,documentsUri:i+sH,listsUri:i+aH,mapsUri:i+iH,streamsUri:i+oH,insightsUri:i+uH,sessionStorageEnabled:cH(r.Sync,"enableSessionStorage",!0),productId:r.productId}}return Nt.default(e,[{key:"subscriptionsUri",get:function(){return this.settings.subscriptionsUri}},{key:"documentsUri",get:function(){return this.settings.documentsUri}},{key:"listsUri",get:function(){return this.settings.listsUri}},{key:"mapsUri",get:function(){return this.settings.mapsUri}},{key:"streamsUri",get:function(){return this.settings.streamsUri}},{key:"insightsUri",get:function(){return this.settings.insightsUri}},{key:"backoffConfig",get:function(){return this.settings.backoffConfig||{}}},{key:"sessionStorageEnabled",get:function(){return this.settings.sessionStorageEnabled}},{key:"productId",get:function(){return this.settings.productId}}]),e}();function Ao(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=fH(e))||r&&e&&typeof e.length=="number"){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
300
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,c;return{s:function(){t=t.call(e)},n:function(){var u=t.next();return a=u.done,u},e:function(u){s=!0,c=u},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw c}}}}function fH(e,r){if(e){if(typeof e=="string")return x_(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return x_(e,r)}}function x_(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var dH=function(){function e(r){Ot.default(this,e),this.localObject=r,this.pendingCorrelationId=null,this.pendingAction=null,this.established=!1,this.retryCount=0}return Nt.default(e,[{key:"sid",get:function(){return this.localObject.sid}},{key:"type",get:function(){return this.localObject.type}},{key:"lastEventId",get:function(){return this.localObject.lastEventId}},{key:"indexName",get:function(){return this.localObject.indexName}},{key:"queryString",get:function(){return this.localObject.queryString}},{key:"isEstablished",get:function(){return this.established}},{key:"update",value:function(t,n){this.localObject._update(t,n)}},{key:"updatePending",value:function(t,n){this.pendingAction=t,this.pendingCorrelationId=n}},{key:"reset",value:function(){this.updatePending(null,null),this.retryCount=0,this.established=!1,this.setSubscriptionState("none")}},{key:"markAsFailed",value:function(t){this.rejectedWithError=t.error,this.updatePending(null,null),this.localObject.reportFailure(new en("Failed to subscribe on service events: ".concat(t.error.message),t.error.status,t.error.code))}},{key:"complete",value:function(t){this.updatePending(null,null),this.established=!0,this.localObject._advanceLastEventId(t)}},{key:"setSubscriptionState",value:function(t){this.localObject._setSubscriptionState(t)}}]),e}(),pH=function(){function e(r){var t=this;Ot.default(this,e),jt.default(this,"isConnected",!1),jt.default(this,"maxBatchSize",100),jt.default(this,"subscriptionTtlTimer",null),jt.default(this,"pendingPokeReason",null),this.services=r,this.subscriptions=new Map,this.persisted=new Map,this.latestPokeResponseArrivalTimestampByCorrelationId=new Map;var n={randomisationFactor:.2,initialDelay:100,maxDelay:2*60*1e3};this.backoff=rk.Backoff.exponential(Object.assign(n,this.services.config.backoffConfig)),this.backoff.on("ready",function(){var i=t.getSubscriptionUpdateBatch(),a=i.action,s=i.subscriptions;a?t.applyNewSubscriptionUpdateBatch(a,s):(t.backoff.reset(),Mt.debug("All subscriptions resolved."))})}return Nt.default(e,[{key:"getSubscriptionUpdateBatch",value:function(){function t(a,s,c,o){var u=[],l=Ao(a),f;try{for(l.s();!(f=l.n()).done;){var d=ak.default(f.value,2),p=d[0],h=d[1],E=s.get(p);if(!E&&c!==h.pendingAction&&!h.rejectedWithError&&(u.push(h),o&&u.length>=o))break}}catch(M){l.e(M)}finally{l.f()}return u}var n=t(this.subscriptions,this.persisted,"establish",this.maxBatchSize);if(n.length>0)return{action:"establish",subscriptions:n};var i=t(this.persisted,this.subscriptions,"cancel",this.maxBatchSize);return i.length>0?{action:"cancel",subscriptions:i}:{action:null,subscriptions:null}}},{key:"persist",value:function(){this.backoff.backoff()}},{key:"applyNewSubscriptionUpdateBatch",value:function(){var r=Be.default(ne.default.mark(function n(i,a){var s=this,c,o,u,l,f,d,p,h,E,M,I,x,j,z,ie,oe;return ne.default.wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(this.isConnected){L.next=4;break}return Mt.debug("Twilsock connection (required for subscription) not ready; waiting…"),this.backoff.reset(),L.abrupt("return");case 4:a=this.processLocalActions(i,a),c=new Date().getTime(),o=Ao(a);try{for(o.s();!(u=o.n()).done;)l=u.value,this.recordActionAttemptOn(l,i,c)}catch(Y){o.e(Y)}finally{o.f()}return f=this.pendingPokeReason,this.pendingPokeReason=null,L.prev=10,L.next=13,this.request(i,c,f,a);case 13:d=L.sent,p=d.body.max_batch_size,!isNaN(parseInt(p))&&isFinite(p)&&p>0&&(this.maxBatchSize=p),this.subscriptionTtlTimer||(h=d.body.ttl_in_s,E=!isNaN(parseFloat(h))&&isFinite(h),M=E&&h>0,M&&(this.subscriptionTtlTimer=setTimeout(function(){return s.onSubscriptionTtlElapsed()},h*1e3))),i==="establish"&&(I=d.body.estimated_delivery_in_ms,x=!isNaN(parseFloat(I))&&isFinite(I),j=x&&I>0,j?setTimeout(function(){return s.verifyPokeDelivery(c,I,a)},I):Mt.error("Invalid timeout: ".concat(I)),a.filter(function(Y){return Y.pendingCorrelationId===c}).forEach(function(Y){return Y.setSubscriptionState("response_in_flight")})),this.backoff.reset(),L.next=26;break;case 21:L.prev=21,L.t0=L.catch(10),z=Ao(a);try{for(z.s();!(ie=z.n()).done;)oe=ie.value,this.recordActionFailureOn(oe,i)}catch(Y){z.e(Y)}finally{z.f()}L.t0 instanceof dl.TransportUnavailableError?(Mt.debug("Twilsock connection (required for subscription) not ready (c:".concat(c,"); waiting…")),this.backoff.reset()):(Mt.debug("Failed an attempt to ".concat(i," subscriptions (c:").concat(c,"); retrying"),L.t0),this.persist());case 26:case"end":return L.stop()}},n,this,[[10,21]])}));function t(n,i){return r.apply(this,arguments)}return t}()},{key:"verifyPokeDelivery",value:function(t,n,i){var a=this,s=this.latestPokeResponseArrivalTimestampByCorrelationId.get(t),c=s?new Date().getTime()-s:n;if(c>=n)i.filter(function(u){return u.pendingCorrelationId===t}).forEach(function(u){u.updatePending(null,null),u.retryCount++,a.persisted.delete(u.sid)}),this.persist(),this.latestPokeResponseArrivalTimestampByCorrelationId.delete(t);else{var o=n-c;setTimeout(function(){return a.verifyPokeDelivery(t,n,i)},o)}}},{key:"processLocalActions",value:function(t,n){return t==="cancel"?n.filter(function(i){return!i.rejectedWithError}):n}},{key:"recordActionAttemptOn",value:function(t,n,i){if(t.setSubscriptionState("request_in_flight"),n==="establish")this.persisted.set(t.sid,t),t.updatePending(n,i);else{var a=this.persisted.get(t.sid);a&&a.updatePending(n,i)}}},{key:"recordActionFailureOn",value:function(t,n){t.setSubscriptionState("none"),t.updatePending(null,null),n==="establish"&&this.persisted.delete(t.sid)}},{key:"request",value:function(t,n,i,a){var s=a.map(function(u){return{object_sid:u.sid,object_type:u.type,last_event_id:t==="establish"?u.lastEventId:void 0,index_name:t==="establish"?u.indexName:void 0,query_string:t==="establish"?u.queryString:void 0}}),c=a.filter(function(u){return u.retryCount>0}).length;Mt.debug("Attempting '".concat(t,"' request (c:").concat(n,"):"),s);var o={event_protocol_version:4,action:t,correlation_id:n,retried_requests:c,ttl_in_s:-1,requests:s};return i==="ttl"&&(o.reason=i),this.services.network.post(this.services.config.subscriptionsUri,o)}},{key:"add",value:function(t,n){Mt.debug("Establishing intent to subscribe to ".concat(t));var i=this.subscriptions.get(t);i&&n&&i.lastEventId===n.lastEventId||(this.persisted.delete(t),this.subscriptions.set(t,new dH(n)),this.persist())}},{key:"remove",value:function(t){Mt.debug("Establishing intent to unsubscribe from ".concat(t));var n=this.subscriptions.delete(t);n&&this.persist()}},{key:"acceptMessage",value:function(t,n){Mt.trace("Subscriptions received",t);var i=t.event_type,a=typeof t.events<"u"?t.events:[t.event],s=t.correlation_id;s&&this.latestPokeResponseArrivalTimestampByCorrelationId.set(s,new Date().getTime());var c=Ao(a),o;try{for(c.s();!(o=c.n()).done;){var u=o.value,l=void 0;switch(t.event_type){case"subscription_established":this.applySubscriptionEstablishedMessage(u,s);break;case"subscription_canceled":this.applySubscriptionCancelledMessage(u,s);break;case"subscription_failed":this.applySubscriptionFailedMessage(u,s);break;case(l=i.match(/^(?:map|list|document|stream|live_query)_/)||{}).input:{var f=void 0;switch(l[0]){case"map_":f=u.map_sid;break;case"list_":f=u.list_sid;break;case"document_":f=u.document_sid;break;case"stream_":f=u.stream_sid;break;case"live_query_":f=u.query_id,n=!1,t.strictly_ordered===!0&&(n=!0);break;default:f=void 0}this.applyEventToSubscribedEntity(f,u,i,n);break}default:Mt.debug("Dropping unknown message type ".concat(i));break}}}catch(d){c.e(d)}finally{c.f()}}},{key:"applySubscriptionEstablishedMessage",value:function(t,n){var i=t.object_sid,a=this.persisted.get(t.object_sid);a&&a.pendingCorrelationId===n?t.replay_status==="interrupted"?(Mt.debug("Event Replay for subscription to ".concat(i," (c:").concat(n,") interrupted; continuing eagerly.")),a.updatePending(null,null),this.persisted.delete(a.sid),this.backoff.reset()):t.replay_status==="completed"&&(Mt.debug("Event Replay for subscription to ".concat(i," (c:").concat(n,") completed. Subscription is ready.")),a.complete(t.last_event_id),this.persisted.set(t.object_sid,a),a.setSubscriptionState("established"),this.backoff.reset()):Mt.debug("Late message for ".concat(t.object_sid," (c:").concat(n,") dropped.")),this.persist()}},{key:"applySubscriptionCancelledMessage",value:function(t,n){var i=this.persisted.get(t.object_sid);i&&i.pendingCorrelationId===n?(i.updatePending(null,null),i.setSubscriptionState("none"),this.persisted.delete(t.object_sid)):Mt.debug("Late message for ".concat(t.object_sid," (c:").concat(n,") dropped.")),this.persist()}},{key:"applySubscriptionFailedMessage",value:function(t,n){var i=t.object_sid,a=this.subscriptions.get(i),s=this.persisted.get(i);a&&s?s.pendingCorrelationId===n&&(Mt.error("Failed to subscribe on ".concat(s.sid),t.error),s.markAsFailed(t),s.setSubscriptionState("none")):!a&&s&&(this.persisted.delete(i),s.setSubscriptionState("none")),this.persist()}},{key:"applyEventToSubscribedEntity",value:function(t,n,i,a){var s=this;if(t){a=a||function(){var o=s.persisted.get(t);return o&&o.isEstablished}();var c=this.subscriptions.get(t);c?(n.type=i,c.update(n,a)):Mt.debug("Message dropped for SID '".concat(t,"', for which there is no subscription."))}}},{key:"onConnectionStateChanged",value:function(t){this.isConnected=t,t&&this.poke("reconnect")}},{key:"onSubscriptionTtlElapsed",value:function(){this.isConnected&&this.poke("ttl")}},{key:"poke",value:function(t){Mt.debug("Triggering event replay for all subscriptions, reason=".concat(t)),this.pendingPokeReason=t,this.subscriptionTtlTimer&&(clearTimeout(this.subscriptionTtlTimer),this.subscriptionTtlTimer=null);var n=[],i=Ao(this.persisted.values()),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;s.reset(),s.rejectedWithError&&n.push(s)}}catch(l){i.e(l)}finally{i.f()}this.persisted.clear();for(var c=0,o=n;c<o.length;c++){var u=o[c];this.persisted.set(u.sid,u)}this.persist()}},{key:"shutdown",value:function(){this.backoff.reset(),this.subscriptions.clear()}}]),e}(),hH=4e3,vH=6e4,mH=9e4,gH=.2;function N_(e){if(e.body&&e.body.message)return e.body.message;switch(e.status){case 429:return"Throttled by server";case 404:return"Not found from server";default:return"Error from server"}}function L_(e){return e.body?e.body.code:0}function Mo(e){return e.status===409?new tH(N_(e),e.status,L_(e),e.body):e.status?new en(N_(e),e.status,L_(e)):e instanceof dl.TransportUnavailableError?e:new en(e.message,0,0)}var yH=function(){function e(r,t,n){Ot.default(this,e),this.clientInfo=r,this.config=t,this.transport=n}return Nt.default(e,[{key:"createHeaders",value:function(){return{"Content-Type":"application/json","Twilio-Sync-Client-Info":JSON.stringify(this.clientInfo),"Twilio-Request-Id":"RQ"+zV.v4().replace(/-/g,"")}}},{key:"backoffConfig",value:function(){return Object.assign({min:hH,max:vH,maxAttemptsTime:mH,randomness:gH},this.config.backoffConfig)}},{key:"executeWithRetry",value:function(t){var n=this,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return new Promise(function(a,s){var c=[502,503,504];i&&c.push(429);var o=new rk.Retrier(n.backoffConfig());o.on("attempt",function(){t().then(function(u){return o.succeeded(u)}).catch(function(u){if(c.includes(u.status)){var l=parseInt(u.headers?u.headers["Retry-After"]:null);o.failed(Mo(u),isNaN(l)?null:l*1e3)}else u.message==="Twilsock disconnected"?o.failed(Mo(u)):(o.removeAllListeners(),o.cancel(),s(Mo(u)))})}),o.on("succeeded",function(u){a(u)}),o.on("cancelled",function(u){return s(Mo(u))}),o.on("failed",function(u){return s(Mo(u))}),o.start()})}},{key:"get",value:function(t){var n=this,i=this.createHeaders();return Mt.debug("GET",t,"ID:",i["Twilio-Request-Id"]),this.executeWithRetry(function(){return n.transport.get(t,i,n.config.productId)},!0)}},{key:"post",value:function(t,n,i){var a=this,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,c=this.createHeaders();return typeof i<"u"&&i!==null&&(c["If-Match"]=i),Mt.debug("POST",t,"ID:",c["Twilio-Request-Id"]),this.executeWithRetry(function(){return a.transport.post(t,c,n,a.config.productId)},s)}},{key:"put",value:function(t,n,i){var a=this,s=this.createHeaders();return typeof i<"u"&&i!==null&&(s["If-Match"]=i),Mt.debug("PUT",t,"ID:",s["Twilio-Request-Id"]),this.executeWithRetry(function(){return a.transport.put(t,s,n,a.config.productId)},!1)}},{key:"delete",value:function(t){var n=this,i=this.createHeaders();return Mt.debug("DELETE",t,"ID:",i["Twilio-Request-Id"]),this.executeWithRetry(function(){return n.transport.delete(t,i,n.config.productId)},!1)}}]),e}(),bH=function(){function e(r,t){Ot.default(this,e),this.config=r,this.storageId=null;try{this.storage=t||sessionStorage}catch{}}return Nt.default(e,[{key:"storageKey",value:function(t,n){return"".concat(this.storageId,"::").concat(t,"::").concat(n)}},{key:"isReady",get:function(){return this.config.sessionStorageEnabled&&!!this.storageId}},{key:"updateStorageId",value:function(t){this.storageId=t}},{key:"store",value:function(t,n,i){return this.isReady?this._store(this.storageKey(t,n),i):null}},{key:"read",value:function(t,n){return this.isReady?this._read(this.storageKey(t,n)):null}},{key:"remove",value:function(t,n,i){if(!this.isReady)return null;try{this.storage.removeItem(this.storageKey(t,n)),i&&this.storage.removeItem(this.storageKey(t,i))}catch{}}},{key:"update",value:function(t,n,i,a){if(!this.isReady)return null;this._apply(this.storageKey(t,n),a),i&&this._apply(this.storageKey(t,i),a)}},{key:"_store",value:function(t,n){try{this.storage.setItem(t,JSON.stringify(n))}catch{}}},{key:"_read",value:function(t){try{var n=this.storage.getItem(t);if(n)return JSON.parse(n)}catch{}return null}},{key:"_apply",value:function(t,n){var i=this._read(t);if(!i)return!1;this._store(t,Object.assign(i,n))}}]),e}();function _H(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=SH(e))||r&&e&&typeof e.length=="number"){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
301
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,c;return{s:function(){t=t.call(e)},n:function(){var u=t.next();return a=u.done,u},e:function(u){s=!0,c=u},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw c}}}}function SH(e,r){if(e){if(typeof e=="string")return D_(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return D_(e,r)}}function D_(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var Au=function(){function e(r,t){Ot.default(this,e),this.services=r,this.removalHandler=t,this.subscriptionState="none",this._attachedListeners=new Map}return Nt.default(e,[{key:"_advanceLastEventId",value:function(t,n){}},{key:"reportFailure",value:function(t){t.status===404?this.onRemoved(!1):this.broadcastEventToListeners("failure",t)}},{key:"_subscribe",value:function(){this.services.router._subscribe(this.sid,this)}},{key:"_unsubscribe",value:function(){this.services.router._unsubscribe(this.sid)}},{key:"_setSubscriptionState",value:function(t){this.subscriptionState=t,this.broadcastEventToListeners("_subscriptionStateChanged",t)}},{key:"close",value:function(){this._unsubscribe(),this.removalHandler!=null&&this.removalHandler(this.type,this.sid,this.uniqueName)}},{key:"attach",value:function(t){var n=t.listenerUuid,i=this._attachedListeners.get(n);i||(this._attachedListeners.size||this._subscribe(),this._attachedListeners.set(n,t))}},{key:"detach",value:function(t){this._attachedListeners.delete(t),this._attachedListeners.size||this.close()}},{key:"broadcastEventToListeners",value:function(t,n){var i=_H(this._attachedListeners.values()),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;s.emit(t,n)}}catch(c){i.e(c)}finally{i.f()}}}]),e}(),dk=function(){function e(r){Ot.default(this,e),jt.default(this,"queuedRequests",[]),jt.default(this,"isRequestInFlight",!1),this.inputMergingFunction=r}return Nt.default(e,[{key:"add",value:function(t,n){var i=this,a=new Promise(function(s,c){return i.queuedRequests.push({input:t,requestFunction:n,resolve:s,reject:c})});return this.wakeupQueue(),a}},{key:"squashAndAdd",value:function(t,n){var i=this.queuedRequests;this.queuedRequests=[];var a;i.length>0?(a=i.map(function(c){return c.input}).reduce(this.inputMergingFunction),a=this.inputMergingFunction(a,t)):a=t;var s=this.add(a,n);return i.forEach(function(c){return s.then(c.resolve,c.reject)}),s}},{key:"isEmpty",value:function(){return this.queuedRequests.length===0&&!this.isRequestInFlight}},{key:"wakeupQueue",value:function(){var t=this;if(!(this.queuedRequests.length===0||this.isRequestInFlight)){var n=this.queuedRequests.shift();this.isRequestInFlight=!0,n.requestFunction(n.input).then(n.resolve,n.reject).then(function(i){t.isRequestInFlight=!1,t.wakeupQueue()})}}}]),e}(),pk=function(){function e(r){Ot.default(this,e),jt.default(this,"queueByNamespaceKey",new Map),this.inputReducer=r}return Nt.default(e,[{key:"add",value:function(){var r=Be.default(ne.default.mark(function n(i,a,s){return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.abrupt("return",this.invokeQueueMethod(i,function(u){return u.add(a,s)}));case 1:case"end":return o.stop()}},n,this)}));function t(n,i,a){return r.apply(this,arguments)}return t}()},{key:"squashAndAdd",value:function(){var r=Be.default(ne.default.mark(function n(i,a,s){return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.abrupt("return",this.invokeQueueMethod(i,function(u){return u.squashAndAdd(a,s)}));case 1:case"end":return o.stop()}},n,this)}));function t(n,i,a){return r.apply(this,arguments)}return t}()},{key:"invokeQueueMethod",value:function(){var r=Be.default(ne.default.mark(function n(i,a){var s,c;return ne.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.queueByNamespaceKey.has(i)||this.queueByNamespaceKey.set(i,new dk(this.inputReducer)),s=this.queueByNamespaceKey.get(i),c=a(s),this.queueByNamespaceKey.get(i).isEmpty()&&this.queueByNamespaceKey.delete(i),u.abrupt("return",c);case 5:case"end":return u.stop()}},n,this)}));function t(n,i){return r.apply(this,arguments)}return t}()}]),e}();function wH(e){var r=TH();return function(){var n=or.default(e),i;if(r){var a=or.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return ka.default(this,i)}}function TH(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Mu=function(e){Vr.default(t,e);var r=wH(t);function t(){var n;return Ot.default(this,t),n=r.call(this),n.closed=!1,n.uuid=nk.v4(),n}return Nt.default(t,[{key:"listenerUuid",get:function(){return this.uuid}},{key:"close",value:function(){this.removeAllListeners(),this.closed=!0}},{key:"ensureNotClosed",value:function(){if(this.closed)throw new Error("Invalid operation on closed object")}}]),t}(Ut);function hk(e){var r=CH();return function(){var n=or.default(e),i;if(r){var a=or.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return ka.default(this,i)}}function CH(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Zp=function(e){Vr.default(t,e);var r=hk(t);function t(n,i,a){var s;Ot.default(this,t),s=r.call(this,n,a),jt.default(ti.default(s),"isDeleted",!1);var c=function(u,l){return typeof l.ttl=="number"?{ttl:l.ttl}:u};return s.updateMergingQueue=new dk(c),s.descriptor=i,s.descriptor.data=s.descriptor.data||{},s.descriptor.date_updated=new Date(s.descriptor.date_updated),s}return Nt.default(t,[{key:"uri",get:function(){return this.descriptor.url}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"document"}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"data",get:function(){return this.descriptor.data}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"_update",value:function(i){switch(i.date_created=new Date(i.date_created),i.type){case"document_updated":if(i.id<=this.lastEventId){Mt.trace("Document update skipped, current:",this.lastEventId,", remote:",i.id);break}var a=this.descriptor.data!==void 0?Bn(this.descriptor.data):null;this.descriptor.last_event_id=i.id,this.descriptor.revision=i.document_revision,this.descriptor.date_updated=i.date_created,this.descriptor.data=i.document_data,this.broadcastEventToListeners("updated",{data:i.document_data,isLocal:!1,previousData:a}),this.services.storage.update(this.type,this.sid,this.uniqueName,{last_event_id:i.id,revision:i.document_revision,date_updated:i.date_created,data:i.document_data});break;case"document_removed":this.onRemoved(!1);break}}},{key:"set",value:function(){var n=Be.default(ne.default.mark(function a(s,c){var o=this,u;return ne.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return u=c||{},f.abrupt("return",this.updateMergingQueue.squashAndAdd(u,function(d){return o._setUnconditionally(s,d.ttl)}));case 2:case"end":return f.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=Be.default(ne.default.mark(function a(s,c){var o=this,u;return ne.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return u=c||{},f.abrupt("return",this.updateMergingQueue.add(u,function(d){return o._setWithIfMatch(s,d.ttl)}));case 2:case"end":return f.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=Be.default(ne.default.mark(function a(s,c){return ne.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.mutate(function(l){return Object.assign(l,s)},c));case 1:case"end":return u.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=Be.default(ne.default.mark(function a(s){var c;return ne.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,this._postUpdateToServer({ttl:s});case 2:c=u.sent,this.descriptor.date_expires=c.date_expires;case 4:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_setUnconditionally",value:function(){var n=Be.default(ne.default.mark(function a(s,c){var o;return ne.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.next=2,this._postUpdateToServer({data:s,revision:void 0,ttl:c});case 2:return o=l.sent,this._handleSuccessfulUpdateResult(o),l.abrupt("return",this.descriptor.data);case 5:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"_setWithIfMatch",value:function(){var n=Be.default(ne.default.mark(function a(s,c){var o,u,l;return ne.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(o=s(Bn(this.descriptor.data)),!o){d.next=22;break}return u=this.revision,d.prev=3,d.next=6,this._postUpdateToServer({data:o,revision:u,ttl:c});case 6:return l=d.sent,this._handleSuccessfulUpdateResult(l),d.abrupt("return",this.descriptor.data);case 11:if(d.prev=11,d.t0=d.catch(3),d.t0.status!==412){d.next=19;break}return d.next=16,this._softSync();case 16:return d.abrupt("return",this._setWithIfMatch(s));case 19:throw d.t0;case 20:d.next=23;break;case 22:return d.abrupt("return",this.descriptor.data);case 23:case"end":return d.stop()}},a,this,[[3,11]])}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"_handleSuccessfulUpdateResult",value:function(i){if(!(i.last_event_id<=this.descriptor.last_event_id)){var a=this.descriptor.data!==void 0?Bn(this.descriptor.data):null;this.descriptor.revision=i.revision,this.descriptor.data=i.data,this.descriptor.last_event_id=i.last_event_id,this.descriptor.date_expires=i.date_expires,this.descriptor.date_updated=new Date(i.date_updated),this.services.storage.update(this.type,this.sid,this.uniqueName,{last_event_id:i.last_event_id,revision:i.revision,date_updated:i.date_updated,data:i.data}),this.broadcastEventToListeners("updated",{data:this.descriptor.data,isLocal:!0,previousData:a})}}},{key:"_postUpdateToServer",value:function(){var n=Be.default(ne.default.mark(function a(s){var c,o,u;return ne.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(this.isDeleted){f.next=17;break}return c={data:s.data},s.ttl!==void 0&&(c.ttl=s.ttl),o=s.revision,f.prev=4,f.next=7,this.services.network.post(this.uri,c,o);case 7:return u=f.sent,f.abrupt("return",{revision:u.body.revision,data:s.data,last_event_id:u.body.last_event_id,date_updated:u.body.date_updated,date_expires:u.body.date_expires});case 11:throw f.prev=11,f.t0=f.catch(4),f.t0.status===404&&this.onRemoved(!1),f.t0;case 15:f.next=18;break;case 17:return f.abrupt("return",Promise.reject(new en("The Document has been removed",404,54100)));case 18:case"end":return f.stop()}},a,this,[[4,11]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_softSync",value:function(){var n=Be.default(ne.default.mark(function a(){var s=this;return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.abrupt("return",this.services.network.get(this.uri).then(function(u){var l={type:"document_updated",id:u.body.last_event_id,document_revision:u.body.revision,document_data:u.body.data,date_created:u.body.date_updated};return s._update(l),s}).catch(function(u){u.status===404?s.onRemoved(!1):Mt.error("Can't get updates for ".concat(s.sid,":"),u)}));case 1:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"onRemoved",value:function(i){if(!this.isDeleted){var a=this.descriptor.data!==void 0?Bn(this.descriptor.data):null;this.isDeleted=!0,this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:i,previousData:a})}}},{key:"removeDocument",value:function(){var n=Be.default(ne.default.mark(function a(){return ne.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(this.isDeleted){c.next=6;break}return c.next=3,this.services.network.delete(this.uri);case 3:this.onRemoved(!0),c.next=7;break;case 6:return c.abrupt("return",Promise.reject(new en("The Document has been removed",404,54100)));case 7:case"end":return c.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()}],[{key:"type",get:function(){return"document"}}]),t}(Au),wn=function(e){Vr.default(t,e);var r=hk(t);function t(n){var i;return Ot.default(this,t),i=r.call(this),i.syncDocumentImpl=n,i.syncDocumentImpl.attach(ti.default(i)),i}return Nt.default(t,[{key:"uri",get:function(){return this.syncDocumentImpl.uri}},{key:"revision",get:function(){return this.syncDocumentImpl.revision}},{key:"lastEventId",get:function(){return this.syncDocumentImpl.lastEventId}},{key:"dateExpires",get:function(){return this.syncDocumentImpl.dateExpires}},{key:"type",get:function(){return Zp.type}},{key:"sid",get:function(){return this.syncDocumentImpl.sid}},{key:"data",get:function(){return this.syncDocumentImpl.data}},{key:"dateUpdated",get:function(){return this.syncDocumentImpl.dateUpdated}},{key:"uniqueName",get:function(){return this.syncDocumentImpl.uniqueName}},{key:"set",value:function(){var n=Be.default(ne.default.mark(function a(s,c){return ne.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncDocumentImpl.set(s,c));case 2:case"end":return u.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=Be.default(ne.default.mark(function a(s,c){return ne.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncDocumentImpl.mutate(s,c));case 2:case"end":return u.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=Be.default(ne.default.mark(function a(s,c){return ne.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncDocumentImpl.update(s,c));case 2:case"end":return u.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=Be.default(ne.default.mark(function a(s){return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncDocumentImpl.setTtl(s));case 2:case"end":return o.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"removeDocument",value:function(){var n=Be.default(ne.default.mark(function a(){return ne.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncDocumentImpl.removeDocument());case 2:case"end":return c.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"close",value:function(){Iu.default(or.default(t.prototype),"close",this).call(this),this.syncDocumentImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return Zp.type}}]),t}(Mu);jt.default(wn,"removed","removed");jt.default(wn,"updated","updated");It([Pe.validateTypesAsync(Pe.pureObject,["undefined",Pe.objectSchema("document metadata",{ttl:[Pe.nonNegativeInteger,"undefined"]})]),Ne("design:type",Function),Ne("design:paramtypes",[Object,Object]),Ne("design:returntype",Promise)],wn.prototype,"set",null);It([Pe.validateTypesAsync("function",["undefined",Pe.objectSchema("document metadata",{ttl:[Pe.nonNegativeInteger,"undefined"]})]),Ne("design:type",Function),Ne("design:paramtypes",[Function,Object]),Ne("design:returntype",Promise)],wn.prototype,"mutate",null);It([Pe.validateTypesAsync(Pe.pureObject,["undefined",Pe.objectSchema("document metadata",{ttl:[Pe.nonNegativeInteger,"undefined"]})]),Ne("design:type",Function),Ne("design:paramtypes",[Object,Object]),Ne("design:returntype",Promise)],wn.prototype,"update",null);It([Pe.validateTypesAsync(Pe.nonNegativeInteger),Ne("design:type",Function),Ne("design:paramtypes",[Number]),Ne("design:returntype",Promise)],wn.prototype,"setTtl",null);var eh=function(){function e(r){Ot.default(this,e),this.descriptor=r}return Nt.default(e,[{key:"uri",get:function(){return this.descriptor.uri}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.lastEventId}},{key:"dateUpdated",get:function(){return this.descriptor.dateUpdated}},{key:"dateExpires",get:function(){return this.descriptor.dateExpires}},{key:"index",get:function(){return this.descriptor.index}},{key:"data",get:function(){return this.descriptor.data}},{key:"update",value:function(t,n,i,a){return this.descriptor.lastEventId=t,this.descriptor.revision=n,this.descriptor.data=i,this.descriptor.dateUpdated=a,this}},{key:"updateDateExpires",value:function(t){this.descriptor.dateExpires=t}}]),e}(),_m=function(){function e(r,t,n,i){Ot.default(this,e),this.prevToken=n,this.nextToken=i,this.items=r,this.source=t}return Nt.default(e,[{key:"hasNextPage",get:function(){return!!this.nextToken}},{key:"hasPrevPage",get:function(){return!!this.prevToken}},{key:"nextPage",value:function(){var r=Be.default(ne.default.mark(function n(){return ne.default.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.hasNextPage){a.next=2;break}throw new Error("No next page");case 2:return a.abrupt("return",this.source(this.nextToken));case 3:case"end":return a.stop()}},n,this)}));function t(){return r.apply(this,arguments)}return t}()},{key:"prevPage",value:function(){var r=Be.default(ne.default.mark(function n(){return ne.default.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.hasPrevPage){a.next=2;break}throw new Error("No previous page");case 2:return a.abrupt("return",this.source(this.prevToken));case 3:case"end":return a.stop()}},n,this)}));function t(){return r.apply(this,arguments)}return t}()}]),e}();function EH(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=kH(e))||r&&e&&typeof e.length=="number"){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
302
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,c;return{s:function(){t=t.call(e)},n:function(){var u=t.next();return a=u.done,u},e:function(u){s=!0,c=u},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw c}}}}function kH(e,r){if(e){if(typeof e=="string")return j_(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return j_(e,r)}}function j_(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var RH=function(){function e(r,t){Ot.default(this,e),this.balanceFactor=0,this.key=r,this.value=t,this.parent=null,this.left=null,this.right=null}return Nt.default(e,[{key:"isRoot",get:function(){return this.parent===null}},{key:"isLeaf",get:function(){return this.left===null&&this.right===null}},{key:"isLeftChild",get:function(){return this.parent.left===this}},{key:"update",value:function(t){this.value=t}},{key:"replace",value:function(t,n){t&&(this.left===n?this.left=n:this.right===n&&(this.right=n))}}]),e}(),$H=function(){function e(r,t){Ot.default(this,e),this.isLessThan=r||function(n,i){return n<i},this.isEqual=t||function(n,i){return n===i},this.root=null,this.count=null}return Nt.default(e,[{key:"size",get:function(){return this.count}},{key:"clear",value:function(){this.root=null,this.count=0}},{key:"set",value:function(t,n){var i=this.getNode(t);i?i.update(n):this.insert(t,n)}},{key:"insert",value:function(t,n){var i=new RH(t,n);if(this.count++,!this.root){this.root=i;return}for(var a=this.root;;)if(this.isLessThan(t,a.key))if(a.left)a=a.left;else{a.left=i;break}else if(a.right)a=a.right;else{a.right=i;break}for(i.parent=a,a=i;a.parent;){var s=a.parent,c=s.balanceFactor;if(a.isLeftChild?s.balanceFactor++:s.balanceFactor--,Math.abs(s.balanceFactor)<Math.abs(c))break;if(s.balanceFactor<-1||s.balanceFactor>1){this.rebalance(s);break}a=s}}},{key:"get",value:function(t){for(var n=this.root;n;){if(this.isEqual(t,n.key))return n.value;this.isLessThan(t,n.key)?n=n.left:n=n.right}return null}},{key:"delete",value:function(t){var n=this.getNode(t);if(!n||n.key!==t)return null;var i=n.parent,a=n.left,s=n.right;if(!!a!=!!s){var c=a||s;!i&&!c?this.root=null:i&&!c?this.root=c:(i.replace(n,null),this.rebalance(i))}else{for(var o=n.left;o.right;)o=o.right;if(n.left===o)n.isRoot?(this.root=o,o.parent=null):(n.isLeftChild?n.parent.left=o:n.parent.right=o,o.parent=n.parent),o.right=n.right,o.right.parent=o,o.balanceFactor=n.balanceFactor,n={parent:o,isLeftChild:!0};else{var u=o.parent,l=o.left;u.right=l,l&&(l.parent=u),n.isRoot?(this.root=o,o.parent=null):(n.isLeftChild?n.parent.left=o:n.parent.right=o,o.parent=n.parent),o.right=n.right,o.right.parent=o,o.left=n.left,o.left.parent=o,o.balanceFactor=n.balanceFactor,n={parent:u,isLeftChild:!1}}}for(this.count--;n.parent;){var f=n.parent,d=f.balanceFactor;if(n.isLeftChild?f.balanceFactor-=1:f.balanceFactor+=1,Math.abs(f.balanceFactor)>Math.abs(d))if(f.balanceFactor<-1||f.balanceFactor>1)if(this.rebalance(f),f.parent.balanceFactor===0)n=f.parent;else break;else break;else n=f}return null}},{key:"getNode",value:function(t){for(var n=this.root;n;){if(this.isEqual(t,n.key))return n;this.isLessThan(t,n.key)?n=n.left:n=n.right}return null}},{key:"rebalance",value:function(t){t.balanceFactor<0?t.right.balanceFactor>0?(this.rotateRight(t.right),this.rotateLeft(t)):this.rotateLeft(t):t.balanceFactor>0&&(t.left.balanceFactor<0?(this.rotateLeft(t.left),this.rotateRight(t)):this.rotateRight(t))}},{key:"rotateLeft",value:function(t){var n=t.right;t.right=n.left,n.left!==null&&(n.left.parent=t),n.parent=t.parent,n.parent===null?this.root=n:t.isLeftChild?n.parent.left=n:n.parent.right=n,n.left=t,t.parent=n,t.balanceFactor=t.balanceFactor+1-Math.min(n.balanceFactor,0),n.balanceFactor=n.balanceFactor+1-Math.max(t.balanceFactor,0)}},{key:"rotateRight",value:function(t){var n=t.left;t.left=n.right,n.right!==null&&(n.right.parent=t),n.parent=t.parent,n.parent===null?this.root=n:t.isLeftChild?n.parent.left=n:n.parent.right=n,n.right=t,t.parent=n,t.balanceFactor=t.balanceFactor-1-Math.min(n.balanceFactor,0),n.balanceFactor=n.balanceFactor-1-Math.max(t.balanceFactor,0)}},{key:Symbol.iterator,value:ne.default.mark(function r(){var t,n,i;return ne.default.wrap(function(s){for(;;)switch(s.prev=s.next){case 0:t=EH(this.getIterator()),s.prev=1,t.s();case 3:if((n=t.n()).done){s.next=9;break}return i=n.value,s.next=7,i;case 7:s.next=3;break;case 9:s.next=14;break;case 11:s.prev=11,s.t0=s.catch(1),t.e(s.t0);case 14:return s.prev=14,t.f(),s.finish(14);case 17:case"end":return s.stop()}},r,this,[[1,11,14,17]])})},{key:"getIterator",value:ne.default.mark(function r(){var t,n,i,a=arguments;return ne.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:t=a.length>0&&a[0]!==void 0?a[0]:null,n=this.root;case 2:if(!n){c.next=8;break}if(!(this.isEqual(t,n.key)||t===null&&!n.left)){c.next=5;break}return c.abrupt("break",8);case 5:this.isLessThan(t,n.key)||t===null?n=n.left:n=n.right,c.next=2;break;case 8:if(n){c.next=10;break}return c.abrupt("return",null);case 10:i=!0;case 11:if(!i){c.next=29;break}return c.next=14,[n.key,n.value];case 14:if(i=!1,!n.right){c.next=21;break}for(n=n.right;n.left;)n=n.left;i=!0,c.next=27;break;case 21:if(!n.parent){c.next=26;break}i=n.parent.left===n,n=n.parent,c.next=27;break;case 26:return c.abrupt("break",37);case 27:c.next=35;break;case 29:if(!n.parent){c.next=34;break}i=n.parent.left===n,n=n.parent,c.next=35;break;case 34:return c.abrupt("break",37);case 35:c.next=11;break;case 37:return c.abrupt("return",null);case 38:case"end":return c.stop()}},r,this)})},{key:"getReverseIterator",value:ne.default.mark(function r(){var t,n,i,a=arguments;return ne.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:t=a.length>0&&a[0]!==void 0?a[0]:null,n=this.root;case 2:if(!n){c.next=8;break}if(!(this.isEqual(t,n.key)||t===null&&!n.right)){c.next=5;break}return c.abrupt("break",8);case 5:!this.isLessThan(t,n.key)||t===null?n=n.right:n=n.left,c.next=2;break;case 8:if(n){c.next=10;break}return c.abrupt("return",null);case 10:i=!0;case 11:if(!i){c.next=29;break}return c.next=14,[n.key,n.value];case 14:if(i=!1,!n.left){c.next=21;break}for(n=n.left;n.right;)n=n.right;i=!0,c.next=27;break;case 21:if(!n.parent){c.next=26;break}i=n.parent.right===n,n=n.parent,c.next=27;break;case 26:return c.abrupt("break",37);case 27:c.next=35;break;case 29:if(!n.parent){c.next=34;break}i=n.parent.right===n,n=n.parent,c.next=35;break;case 34:return c.abrupt("break",37);case 35:c.next=11;break;case 37:return c.abrupt("return",null);case 38:case"end":return c.stop()}},r,this)})}]),e}();function OH(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=IH(e))||r&&e&&typeof e.length=="number"){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
303
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,c;return{s:function(){t=t.call(e)},n:function(){var u=t.next();return a=u.done,u},e:function(u){s=!0,c=u},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw c}}}}function IH(e,r){if(e){if(typeof e=="string")return F_(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return F_(e,r)}}function F_(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var PH=function(){function e(r,t){Ot.default(this,e),this.value=r,this.revision=t||0}return Nt.default(e,[{key:"isValid",get:function(){return!0}}]),e}(),AH=function(){function e(r){Ot.default(this,e),this.revision=r}return Nt.default(e,[{key:"isValid",get:function(){return!1}}]),e}(),Sm=function(){function e(){Ot.default(this,e),this.items=new $H}return Nt.default(e,[{key:"store",value:function(t,n,i){var a=this.items.get(t);return a&&a.revision>i?a.isValid?a.value:null:(this.items.set(t,new PH(n,i)),n)}},{key:"delete",value:function(t,n){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,a=this.items.get(t);(!a||a.revision<n||a&&i===!0)&&this.items.set(t,new AH(n))}},{key:"isKnown",value:function(t,n){var i=this.items.get(t);return i&&i.revision>=n}},{key:"get",value:function(t){var n=this.items.get(t);return n&&n.isValid?n.value:null}},{key:"has",value:function(t){var n=this.items.get(t);return n&&n.isValid}},{key:"forEach",value:function(t){if(this.items){var n=OH(this.items),i;try{for(n.s();!(i=n.n()).done;){var a=ak.default(i.value,2),s=a[0],c=a[1];c.isValid&&t(s,c.value)}}catch(o){n.e(o)}finally{n.f()}}}}]),e}();function vk(e){var r=MH();return function(){var n=or.default(e),i;if(r){var a=or.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return ka.default(this,i)}}function MH(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var th=function(e){Vr.default(t,e);var r=vk(t);function t(n,i,a){var s;Ot.default(this,t),s=r.call(this,n,a);var c=function(u,l){return typeof l.ttl=="number"?{ttl:l.ttl}:u};return s.updateMergingQueue=new pk(c),s.cache=new Sm,s.descriptor=i,s.descriptor.date_updated=new Date(s.descriptor.date_updated),s}return Nt.default(t,[{key:"uri",get:function(){return this.descriptor.url}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"links",get:function(){return this.descriptor.links}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"list"}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"_addOrUpdateItemOnServer",value:function(){var n=Be.default(ne.default.mark(function a(s,c,o,u){var l,f;return ne.default.wrap(function(p){for(;;)switch(p.prev=p.next){case 0:return l={data:c},u!==void 0&&(l.ttl=u),p.next=4,this.services.network.post(s,l,o);case 4:return f=p.sent,f.body.data=c,f.body.date_updated=new Date(f.body.date_updated),p.abrupt("return",f.body);case 8:case"end":return p.stop()}},a,this)}));function i(a,s,c,o){return n.apply(this,arguments)}return i}()},{key:"push",value:function(){var n=Be.default(ne.default.mark(function a(s,c){var o,u,l;return ne.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return o=(c||{}).ttl,d.next=3,this._addOrUpdateItemOnServer(this.links.items,s,void 0,o);case 3:return u=d.sent,l=Number(u.index),this._handleItemMutated(l,u.url,u.last_event_id,u.revision,s,u.date_updated,u.date_expires,!0,!1),d.abrupt("return",this.cache.get(l));case 7:case"end":return d.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"set",value:function(){var n=Be.default(ne.default.mark(function a(s,c,o){var u=this,l;return ne.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return l=o||{},d.abrupt("return",this.updateMergingQueue.squashAndAdd(s,l,function(p){return u._updateItemUnconditionally(s,c,p.ttl)}));case 2:case"end":return d.stop()}},a,this)}));function i(a,s,c){return n.apply(this,arguments)}return i}()},{key:"_updateItemUnconditionally",value:function(){var n=Be.default(ne.default.mark(function a(s,c,o){var u,l;return ne.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return d.next=2,this.get(s);case 2:return u=d.sent,d.next=5,this._addOrUpdateItemOnServer(u.uri,c,void 0,o);case 5:return l=d.sent,this._handleItemMutated(s,l.url,l.last_event_id,l.revision,l.data,l.date_updated,l.date_expires,!1,!1),d.abrupt("return",this.cache.get(s));case 8:case"end":return d.stop()}},a,this)}));function i(a,s,c){return n.apply(this,arguments)}return i}()},{key:"_updateItemWithIfMatch",value:function(){var n=Be.default(ne.default.mark(function a(s,c,o){var u,l,f,d;return ne.default.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,this.get(s);case 2:if(u=h.sent,l=c(Bn(u.data)),!l){h.next=25;break}return f=u.revision,h.prev=6,h.next=9,this._addOrUpdateItemOnServer(u.uri,l,f,o);case 9:return d=h.sent,this._handleItemMutated(s,d.url,d.last_event_id,d.revision,d.data,d.date_updated,d.date_expires,!1,!1),h.abrupt("return",this.cache.get(s));case 14:if(h.prev=14,h.t0=h.catch(6),h.t0.status!==412){h.next=22;break}return h.next=19,this._getItemFromServer(s);case 19:return h.abrupt("return",this._updateItemWithIfMatch(s,c,o));case 22:throw h.t0;case 23:h.next=26;break;case 25:return h.abrupt("return",u);case 26:case"end":return h.stop()}},a,this,[[6,14]])}));function i(a,s,c){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=Be.default(ne.default.mark(function a(s,c,o){var u=this,l;return ne.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return l=o||{},d.abrupt("return",this.updateMergingQueue.add(s,l,function(p){return u._updateItemWithIfMatch(s,c,p.ttl)}));case 2:case"end":return d.stop()}},a,this)}));function i(a,s,c){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=Be.default(ne.default.mark(function a(s,c,o){return ne.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.abrupt("return",this.mutate(s,function(f){return Object.assign(f,c)},o));case 1:case"end":return l.stop()}},a,this)}));function i(a,s,c){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=Be.default(ne.default.mark(function a(s){var c,o,u;return ne.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,this.get(s);case 2:return c=f.sent,o=Bn(c.data),f.next=6,this.services.network.delete(c.uri);case 6:u=f.sent,this._handleItemRemoved(s,u.body.last_event_id,o,new Date(u.body.date_updated),!1);case 8:case"end":return f.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=Be.default(ne.default.mark(function a(s){var c;return ne.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(c=this.cache.get(s),!c){u.next=5;break}return u.abrupt("return",c);case 5:return u.abrupt("return",this._getItemFromServer(s));case 6:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_getItemFromServer",value:function(){var n=Be.default(ne.default.mark(function a(s){var c;return ne.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,this.queryItems({index:s});case 2:if(c=u.sent,!(c.items.length<1)){u.next=7;break}throw new en("No item with index ".concat(s," found"),404,54151);case 7:return u.abrupt("return",c.items[0]);case 8:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"queryItems",value:function(){var n=Be.default(ne.default.mark(function a(s){var c=this,o,u,l,f;return ne.default.wrap(function(p){for(;;)switch(p.prev=p.next){case 0:return s=s||{},o=new Ys(this.links.items).queryParam("From",s.from).queryParam("PageSize",s.limit).queryParam("Index",s.index).queryParam("PageToken",s.pageToken).queryParam("Order",s.order).build(),p.next=4,this.services.network.get(o);case 4:return u=p.sent,l=u.body.items.map(function(h){h.date_updated=new Date(h.date_updated);var E=c.cache.get(h.index);return E?c._handleItemMutated(h.index,h.url,h.last_event_id,h.revision,h.data,h.date_updated,h.date_expires,!1,!0):c.cache.store(Number(h.index),new eh({index:Number(h.index),uri:h.url,revision:h.revision,lastEventId:h.last_event_id,dateUpdated:h.date_updated,dateExpires:h.date_expires,data:h.data}),h.last_event_id),c.cache.get(h.index)}),f=u.body.meta,p.abrupt("return",new _m(l,function(h){return c.queryItems({pageToken:h})},f.previous_token,f.next_token));case 8:case"end":return p.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"getItems",value:function(){var n=Be.default(ne.default.mark(function a(s){return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return s=s||{},fk(s.pageSize),s.limit=s.pageSize||s.limit||50,s.order=s.order||"asc",o.abrupt("return",this.queryItems(s));case 5:case"end":return o.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"getContext",value:function(){var n=Be.default(ne.default.mark(function a(){var s;return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(this.context){o.next=5;break}return o.next=3,this.services.network.get(this.links.context);case 3:s=o.sent,this._updateContextIfRequired(s.body.data,s.body.last_event_id);case 5:return o.abrupt("return",this.context);case 6:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=Be.default(ne.default.mark(function a(s){var c,o;return ne.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.prev=0,c={ttl:s},l.next=4,this.services.network.post(this.uri,c);case 4:o=l.sent,this.descriptor.date_expires=o.body.date_expires,l.next=12;break;case 8:throw l.prev=8,l.t0=l.catch(0),l.t0.status===404&&this.onRemoved(!1),l.t0;case 12:case"end":return l.stop()}},a,this,[[0,8]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setItemTtl",value:function(){var n=Be.default(ne.default.mark(function a(s,c){var o,u,l;return ne.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return d.next=2,this.get(s);case 2:return o=d.sent,u={ttl:c},d.next=6,this.services.network.post(o.uri,u);case 6:l=d.sent,o.updateDateExpires(l.body.date_expires);case 8:case"end":return d.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeList",value:function(){var n=Be.default(ne.default.mark(function a(){return ne.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return c.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"onRemoved",value:function(i){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:i})}},{key:"shouldIgnoreEvent",value:function(i,a){return this.cache.isKnown(i,a)}},{key:"_update",value:function(i,a){var s=Number(i.item_index);switch(i.date_created=new Date(i.date_created),i.type){case"list_item_added":case"list_item_updated":this._handleItemMutated(s,i.item_url,i.id,i.item_revision,i.item_data,i.date_created,void 0,i.type==="list_item_added",!0);break;case"list_item_removed":this._handleItemRemoved(s,i.id,i.item_data,i.date_created,!0);break;case"list_context_updated":this._handleContextUpdate(i.context_data,i.id,i.date_created);break;case"list_removed":this.onRemoved(!1);break}a&&this._advanceLastEventId(i.id,i.list_revision)}},{key:"_advanceLastEventId",value:function(i,a){this.lastEventId<i&&(this.descriptor.last_event_id=i,a&&(this.descriptor.revision=a))}},{key:"_updateRootDateUpdated",value:function(i){(!this.descriptor.date_updated||i.getTime()>this.descriptor.date_updated.getTime())&&(this.descriptor.date_updated=i,this.services.storage.update(this.type,this.sid,this.uniqueName,{date_updated:i}))}},{key:"_handleItemMutated",value:function(i,a,s,c,o,u,l,f,d){if(this.shouldIgnoreEvent(i,s)){Mt.trace("Item ".concat(i," update skipped, current: ").concat(this.lastEventId,", remote: ").concat(s));return}this._updateRootDateUpdated(u);var p=this.cache.get(i);if(!p){var h=new eh({index:i,uri:a,lastEventId:s,revision:c,data:o,dateUpdated:u,dateExpires:l});this.cache.store(i,h,s),this.emitItemMutationEvent(h,d,f);return}var E=Bn(p.data);p.update(s,c,o,u),this.cache.store(i,p,s),l!==void 0&&p.updateDateExpires(l),this.emitItemMutationEvent(p,d,!1,E)}},{key:"emitItemMutationEvent",value:function(i,a,s){var c=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,o=s?"itemAdded":"itemUpdated",u={item:i,isLocal:!a};s||(u.previousItemData=c),this.broadcastEventToListeners(o,u)}},{key:"_handleItemRemoved",value:function(i,a,s,c,o){this._updateRootDateUpdated(c),this.cache.delete(i,a),this.broadcastEventToListeners("itemRemoved",{index:i,isLocal:!o,previousItemData:s})}},{key:"_handleContextUpdate",value:function(i,a,s){this._updateRootDateUpdated(s),this._updateContextIfRequired(i,a)&&this.broadcastEventToListeners("contextUpdated",{context:i,isLocal:!1})}},{key:"_updateContextIfRequired",value:function(i,a){return!this.contextEventId||a>this.contextEventId?(this.context=i,this.contextEventId=a,!0):(Mt.trace("Context update skipped, current:",this.lastEventId,", remote:",a),!1)}}],[{key:"type",get:function(){return"list"}}]),t}(Au),dr=function(e){Vr.default(t,e);var r=vk(t);function t(n){var i;return Ot.default(this,t),i=r.call(this),i.syncListImpl=n,i.syncListImpl.attach(ti.default(i)),i}return Nt.default(t,[{key:"uri",get:function(){return this.syncListImpl.uri}},{key:"revision",get:function(){return this.syncListImpl.revision}},{key:"lastEventId",get:function(){return this.syncListImpl.lastEventId}},{key:"links",get:function(){return this.syncListImpl.links}},{key:"dateExpires",get:function(){return this.syncListImpl.dateExpires}},{key:"type",get:function(){return th.type}},{key:"sid",get:function(){return this.syncListImpl.sid}},{key:"uniqueName",get:function(){return this.syncListImpl.uniqueName}},{key:"dateUpdated",get:function(){return this.syncListImpl.dateUpdated}},{key:"push",value:function(){var n=Be.default(ne.default.mark(function a(s,c){return ne.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncListImpl.push(s,c));case 2:case"end":return u.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"set",value:function(){var n=Be.default(ne.default.mark(function a(s,c,o){return ne.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncListImpl.set(s,c,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s,c){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=Be.default(ne.default.mark(function a(s,c,o){return ne.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncListImpl.mutate(s,c,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s,c){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=Be.default(ne.default.mark(function a(s,c,o){return ne.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncListImpl.update(s,c,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s,c){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=Be.default(ne.default.mark(function a(s){return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncListImpl.remove(s));case 2:case"end":return o.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=Be.default(ne.default.mark(function a(s){return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncListImpl.get(s));case 2:case"end":return o.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"getContext",value:function(){var n=Be.default(ne.default.mark(function a(){return ne.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncListImpl.getContext());case 2:case"end":return c.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"getItems",value:function(){var n=Be.default(ne.default.mark(function a(s){return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncListImpl.getItems(s));case 2:case"end":return o.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=Be.default(ne.default.mark(function a(s){return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncListImpl.setTtl(s));case 2:case"end":return o.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setItemTtl",value:function(){var n=Be.default(ne.default.mark(function a(s,c){return ne.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncListImpl.setItemTtl(s,c));case 2:case"end":return u.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeList",value:function(){var n=Be.default(ne.default.mark(function a(){return ne.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncListImpl.removeList());case 2:case"end":return c.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"close",value:function(){Iu.default(or.default(t.prototype),"close",this).call(this),this.syncListImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return th.type}}]),t}(Mu);jt.default(dr,"itemAdded","itemAdded");jt.default(dr,"itemUpdated","itemUpdated");jt.default(dr,"itemRemoved","itemRemoved");jt.default(dr,"removed","removed");It([Pe.validateTypesAsync(Pe.pureObject,["undefined",Pe.objectSchema("item metadata",{ttl:[Pe.nonNegativeInteger,"undefined"]})]),Ne("design:type",Function),Ne("design:paramtypes",[Object,Object]),Ne("design:returntype",Promise)],dr.prototype,"push",null);It([Pe.validateTypesAsync(Pe.nonNegativeInteger,Pe.pureObject,["undefined",Pe.objectSchema("item metadata",{ttl:[Pe.nonNegativeInteger,"undefined"]})]),Ne("design:type",Function),Ne("design:paramtypes",[Number,Object,Object]),Ne("design:returntype",Promise)],dr.prototype,"set",null);It([Pe.validateTypesAsync(Pe.nonNegativeInteger,"function",["undefined",Pe.objectSchema("item metadata",{ttl:[Pe.nonNegativeInteger,"undefined"]})]),Ne("design:type",Function),Ne("design:paramtypes",[Number,Function,Object]),Ne("design:returntype",Promise)],dr.prototype,"mutate",null);It([Pe.validateTypesAsync(Pe.nonNegativeInteger,Pe.pureObject,["undefined",Pe.objectSchema("item metadata",{ttl:[Pe.nonNegativeInteger,"undefined"]})]),Ne("design:type",Function),Ne("design:paramtypes",[Number,Object,Object]),Ne("design:returntype",Promise)],dr.prototype,"update",null);It([Pe.validateTypesAsync(Pe.nonNegativeInteger),Ne("design:type",Function),Ne("design:paramtypes",[Number]),Ne("design:returntype",Promise)],dr.prototype,"remove",null);It([Pe.validateTypesAsync(Pe.nonNegativeInteger),Ne("design:type",Function),Ne("design:paramtypes",[Number]),Ne("design:returntype",Promise)],dr.prototype,"get",null);It([Pe.validateTypesAsync(["undefined",Pe.objectSchema("query options",{from:[Pe.nonNegativeInteger,"undefined"],pageSize:[Pe.custom(function(e){return[bm(e),"a positive integer"]}),"undefined"]})]),Ne("design:type",Function),Ne("design:paramtypes",[Object]),Ne("design:returntype",Promise)],dr.prototype,"getItems",null);It([Pe.validateTypesAsync(Pe.nonNegativeInteger),Ne("design:type",Function),Ne("design:paramtypes",[Number]),Ne("design:returntype",Promise)],dr.prototype,"setTtl",null);It([Pe.validateTypesAsync(Pe.nonNegativeInteger,Pe.nonNegativeInteger),Ne("design:type",Function),Ne("design:paramtypes",[Number,Number]),Ne("design:returntype",Promise)],dr.prototype,"setItemTtl",null);var Fo=function(){function e(r){Ot.default(this,e),this.descriptor=r}return Nt.default(e,[{key:"uri",get:function(){return this.descriptor.url}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"key",get:function(){return this.descriptor.key}},{key:"data",get:function(){return this.descriptor.data}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"update",value:function(t,n,i,a){return this.descriptor.last_event_id=t,this.descriptor.revision=n,this.descriptor.data=i,this.descriptor.date_updated=a,this}},{key:"updateDateExpires",value:function(t){this.descriptor.date_expires=t}}]),e}();function mk(e){var r=xH();return function(){var n=or.default(e),i;if(r){var a=or.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return ka.default(this,i)}}function xH(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var rh=function(e){Vr.default(t,e);var r=mk(t);function t(n,i,a){var s;Ot.default(this,t),s=r.call(this,n,a);var c=function(u,l){return typeof l.ttl=="number"?{ttl:l.ttl}:u};return s.updateMergingQueue=new pk(c),s.cache=new Sm,s.descriptor=i,s.descriptor.date_updated=new Date(s.descriptor.date_updated),i.items&&i.items.forEach(function(o){o.date_updated=new Date(o.date_updated),s.cache.store(o.key,new Fo(o),o.last_event_id)}),s}return Nt.default(t,[{key:"uri",get:function(){return this.descriptor.url}},{key:"links",get:function(){return this.descriptor.links}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"map"}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"set",value:function(){var n=Be.default(ne.default.mark(function a(s,c,o){var u=this,l;return ne.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return l=o||{},d.abrupt("return",this.updateMergingQueue.squashAndAdd(s,l,function(p){return u._putItemUnconditionally(s,c,p.ttl)}));case 2:case"end":return d.stop()}},a,this)}));function i(a,s,c){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=Be.default(ne.default.mark(function a(s){return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(s!=null){o.next=2;break}throw new en("SyncMapItem key may not be empty",400,54209);case 2:if(!this.cache.has(s)){o.next=6;break}return o.abrupt("return",this.cache.get(s));case 6:return o.abrupt("return",this._getItemFromServer(s));case 7:case"end":return o.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_getItemFromServer",value:function(){var n=Be.default(ne.default.mark(function a(s){var c;return ne.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,this.queryItems({key:s});case 2:if(c=u.sent,!(c.items.length<1)){u.next=7;break}throw new en("The specified Map Item does not exist",404,54201);case 7:return u.abrupt("return",c.items[0]);case 8:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=Be.default(ne.default.mark(function a(s,c,o){var u=this,l;return ne.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return l=o||{},d.abrupt("return",this.updateMergingQueue.add(s,l,function(p){return u._putItemWithIfMatch(s,c,p.ttl)}));case 2:case"end":return d.stop()}},a,this)}));function i(a,s,c){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=Be.default(ne.default.mark(function a(s,c,o){return ne.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.abrupt("return",this.mutate(s,function(f){return Object.assign(f,c)},o));case 1:case"end":return l.stop()}},a,this)}));function i(a,s,c){return n.apply(this,arguments)}return i}()},{key:"_putItemUnconditionally",value:function(){var n=Be.default(ne.default.mark(function a(s,c,o){var u,l;return ne.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return d.next=2,this._putItemToServer(s,c,void 0,o);case 2:return u=d.sent,l=u.item,this._handleItemMutated(l.key,l.url,l.last_event_id,l.revision,l.data,l.date_updated,l.date_expires,u.added,!1),d.abrupt("return",this.cache.get(l.key));case 6:case"end":return d.stop()}},a,this)}));function i(a,s,c){return n.apply(this,arguments)}return i}()},{key:"_putItemWithIfMatch",value:function(){var n=Be.default(ne.default.mark(function a(s,c,o){var u,l,f,d,p;return ne.default.wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return E.next=2,this.get(s).catch(function(M){if(M.status===404)return new Fo({key:s,data:{},last_event_id:-1,revision:"-1",url:null,date_updated:null,date_expires:null});throw M});case 2:if(u=E.sent,l=c(Bn(u.data)),!l){E.next=26;break}return f=u.revision,E.prev=6,E.next=9,this._putItemToServer(s,l,f,o);case 9:return d=E.sent,p=d.item,this._handleItemMutated(p.key,p.url,p.last_event_id,p.revision,p.data,p.date_updated,p.date_expires,d.added,!1),E.abrupt("return",this.cache.get(p.key));case 15:if(E.prev=15,E.t0=E.catch(6),E.t0.status!==412){E.next=23;break}return E.next=20,this._getItemFromServer(s);case 20:return E.abrupt("return",this._putItemWithIfMatch(s,c,o));case 23:throw E.t0;case 24:E.next=27;break;case 26:return E.abrupt("return",u);case 27:case"end":return E.stop()}},a,this,[[6,15]])}));function i(a,s,c){return n.apply(this,arguments)}return i}()},{key:"_putItemToServer",value:function(){var n=Be.default(ne.default.mark(function a(s,c,o,u){var l,f,d,p,h;return ne.default.wrap(function(M){for(;;)switch(M.prev=M.next){case 0:return l=new Ys(this.links.items).pathSegment(s).build(),f={data:c},u!==void 0&&(f.ttl=u),M.prev=3,M.next=6,this.services.network.put(l,f,o);case 6:return d=M.sent,p=d.body,p.data=c,p.date_updated=new Date(p.date_updated),h=d.status.code===201,M.abrupt("return",{added:h,item:p});case 14:throw M.prev=14,M.t0=M.catch(3),M.t0.status===404&&this.onRemoved(!1),M.t0;case 18:case"end":return M.stop()}},a,this,[[3,14]])}));function i(a,s,c,o){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=Be.default(ne.default.mark(function a(s){var c,o,u;return ne.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,this.get(s);case 2:return c=f.sent,o=Bn(c.data),f.next=6,this.services.network.delete(c.uri);case 6:u=f.sent,this._handleItemRemoved(s,u.body.last_event_id,o,new Date(u.body.date_updated),!1);case 8:case"end":return f.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"queryItems",value:function(){var n=Be.default(ne.default.mark(function a(s){var c=this,o,u,l,f;return ne.default.wrap(function(p){for(;;)switch(p.prev=p.next){case 0:return s=s||{},o=new Ys(this.links.items).queryParam("From",s.from).queryParam("PageSize",s.limit).queryParam("Key",s.key).queryParam("PageToken",s.pageToken).queryParam("Order",s.order).build(),p.next=4,this.services.network.get(o);case 4:return u=p.sent,l=u.body.items.map(function(h){h.date_updated=new Date(h.date_updated);var E=c.cache.get(h.key);return E?c._handleItemMutated(h.key,h.url,h.last_event_id,h.revision,h.data,h.date_updated,h.date_expires,!1,!0):c.cache.store(h.key,new Fo(h),h.last_event_id),c.cache.get(h.key)}),f=u.body.meta,p.abrupt("return",new _m(l,function(h){return c.queryItems({pageToken:h})},f.previous_token,f.next_token));case 8:case"end":return p.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"getItems",value:function(){var n=Be.default(ne.default.mark(function a(s){return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return s=s||{},fk(s.pageSize),s.limit=s.pageSize||s.limit||50,s.order=s.order||"asc",o.abrupt("return",this.queryItems(s));case 5:case"end":return o.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"shouldIgnoreEvent",value:function(i,a){return this.cache.isKnown(i,a)}},{key:"_update",value:function(i,a){switch(i.date_created=new Date(i.date_created),i.type){case"map_item_added":case"map_item_updated":this._handleItemMutated(i.item_key,i.item_url,i.id,i.item_revision,i.item_data,i.date_created,void 0,i.type==="map_item_added",!0);break;case"map_item_removed":this._handleItemRemoved(i.item_key,i.id,i.item_data,i.date_created,!0);break;case"map_removed":this.onRemoved(!1);break}a&&this._advanceLastEventId(i.id,i.map_revision)}},{key:"_advanceLastEventId",value:function(i,a){this.lastEventId<i&&(this.descriptor.last_event_id=i,a&&(this.descriptor.revision=a))}},{key:"_updateRootDateUpdated",value:function(i){(!this.descriptor.date_updated||i.getTime()>this.descriptor.date_updated.getTime())&&(this.descriptor.date_updated=i,this.services.storage.update(this.type,this.sid,this.uniqueName,{date_updated:i}))}},{key:"_handleItemMutated",value:function(i,a,s,c,o,u,l,f,d){if(this.shouldIgnoreEvent(i,s)){Mt.trace("SyncMapItem ",i," update skipped, current:",this.lastEventId,", remote:",s);return}this._updateRootDateUpdated(u);var p=this.cache.get(i);if(!p){var h=new Fo({key:i,url:a,last_event_id:s,revision:c,data:o,date_updated:u,date_expires:l});this.cache.store(i,h,s),this.emitItemMutationEvent(h,d,f);return}var E=Bn(p.data);p.update(s,c,o,u),this.cache.store(i,p,s),l!==void 0&&p.updateDateExpires(l),this.emitItemMutationEvent(p,d,!1,E)}},{key:"emitItemMutationEvent",value:function(i,a,s){var c=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,o=s?"itemAdded":"itemUpdated",u={item:i,isLocal:!a};s||(u.previousItemData=c),this.broadcastEventToListeners(o,u)}},{key:"_handleItemRemoved",value:function(i,a,s,c,o){this._updateRootDateUpdated(c),this.cache.delete(i,a),this.broadcastEventToListeners("itemRemoved",{key:i,isLocal:!o,previousItemData:s})}},{key:"onRemoved",value:function(i){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:i})}},{key:"setTtl",value:function(){var n=Be.default(ne.default.mark(function a(s){var c,o;return ne.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.prev=0,c={ttl:s},l.next=4,this.services.network.post(this.uri,c);case 4:o=l.sent,this.descriptor.date_expires=o.body.date_expires,l.next=12;break;case 8:throw l.prev=8,l.t0=l.catch(0),l.t0.status===404&&this.onRemoved(!1),l.t0;case 12:case"end":return l.stop()}},a,this,[[0,8]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setItemTtl",value:function(){var n=Be.default(ne.default.mark(function a(s,c){var o,u,l;return ne.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return d.next=2,this.get(s);case 2:return o=d.sent,u={ttl:c},d.next=6,this.services.network.post(o.uri,u);case 6:l=d.sent,o.updateDateExpires(l.body.date_expires);case 8:case"end":return d.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeMap",value:function(){var n=Be.default(ne.default.mark(function a(){return ne.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return c.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()}],[{key:"type",get:function(){return"map"}}]),t}(Au),yr=function(e){Vr.default(t,e);var r=mk(t);function t(n){var i;return Ot.default(this,t),i=r.call(this),i.syncMapImpl=n,i.syncMapImpl.attach(ti.default(i)),i}return Nt.default(t,[{key:"uri",get:function(){return this.syncMapImpl.uri}},{key:"links",get:function(){return this.syncMapImpl.links}},{key:"revision",get:function(){return this.syncMapImpl.revision}},{key:"lastEventId",get:function(){return this.syncMapImpl.lastEventId}},{key:"dateExpires",get:function(){return this.syncMapImpl.dateExpires}},{key:"type",get:function(){return rh.type}},{key:"sid",get:function(){return this.syncMapImpl.sid}},{key:"uniqueName",get:function(){return this.syncMapImpl.uniqueName}},{key:"dateUpdated",get:function(){return this.syncMapImpl.dateUpdated}},{key:"set",value:function(){var n=Be.default(ne.default.mark(function a(s,c,o){return ne.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncMapImpl.set(s,c,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s,c){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=Be.default(ne.default.mark(function a(s){return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncMapImpl.get(s));case 2:case"end":return o.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=Be.default(ne.default.mark(function a(s,c,o){return ne.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncMapImpl.mutate(s,c,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s,c){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=Be.default(ne.default.mark(function a(s,c,o){return ne.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncMapImpl.update(s,c,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s,c){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=Be.default(ne.default.mark(function a(s){return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncMapImpl.remove(s));case 2:case"end":return o.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"getItems",value:function(){var n=Be.default(ne.default.mark(function a(s){return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncMapImpl.getItems(s));case 2:case"end":return o.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=Be.default(ne.default.mark(function a(s){return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncMapImpl.setTtl(s));case 2:case"end":return o.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setItemTtl",value:function(){var n=Be.default(ne.default.mark(function a(s,c){return ne.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncMapImpl.setItemTtl(s,c));case 2:case"end":return u.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeMap",value:function(){var n=Be.default(ne.default.mark(function a(){return ne.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.next=3,this.syncMapImpl.removeMap();case 3:case"end":return c.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"close",value:function(){Iu.default(or.default(t.prototype),"close",this).call(this),this.syncMapImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return rh.type}}]),t}(Mu);jt.default(yr,"itemAdded","itemAdded");jt.default(yr,"itemUpdated","itemUpdated");jt.default(yr,"itemRemoved","itemRemoved");jt.default(yr,"removed","removed");It([Pe.validateTypesAsync("string",Pe.pureObject,["undefined",Pe.objectSchema("item metadata",{ttl:[Pe.nonNegativeInteger,"undefined"]})]),Ne("design:type",Function),Ne("design:paramtypes",[String,Object,Object]),Ne("design:returntype",Promise)],yr.prototype,"set",null);It([Pe.validateTypesAsync("string"),Ne("design:type",Function),Ne("design:paramtypes",[String]),Ne("design:returntype",Promise)],yr.prototype,"get",null);It([Pe.validateTypesAsync("string","function",["undefined",Pe.objectSchema("item metadata",{ttl:[Pe.nonNegativeInteger,"undefined"]})]),Ne("design:type",Function),Ne("design:paramtypes",[String,Function,Object]),Ne("design:returntype",Promise)],yr.prototype,"mutate",null);It([Pe.validateTypesAsync("string",Pe.pureObject,["undefined",Pe.objectSchema("item metadata",{ttl:[Pe.nonNegativeInteger,"undefined"]})]),Ne("design:type",Function),Ne("design:paramtypes",[String,Object,Object]),Ne("design:returntype",Promise)],yr.prototype,"update",null);It([Pe.validateTypesAsync("string"),Ne("design:type",Function),Ne("design:paramtypes",[String]),Ne("design:returntype",Promise)],yr.prototype,"remove",null);It([Pe.validateTypesAsync(["undefined",Pe.objectSchema("query options",{from:["string","undefined"],pageSize:[Pe.custom(function(e){return[bm(e),"a positive integer"]}),"undefined"]})]),Ne("design:type",Function),Ne("design:paramtypes",[Object]),Ne("design:returntype",Promise)],yr.prototype,"getItems",null);It([Pe.validateTypesAsync(Pe.nonNegativeInteger),Ne("design:type",Function),Ne("design:paramtypes",[Number]),Ne("design:returntype",Promise)],yr.prototype,"setTtl",null);It([Pe.validateTypesAsync("string",Pe.nonNegativeInteger),Ne("design:type",Function),Ne("design:paramtypes",[String,Number]),Ne("design:returntype",Promise)],yr.prototype,"setItemTtl",null);function gk(e){var r=NH();return function(){var n=or.default(e),i;if(r){var a=or.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return ka.default(this,i)}}function NH(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var su=function(e){Vr.default(t,e);var r=gk(t);function t(n,i,a){var s;return Ot.default(this,t),s=r.call(this,n,a),s.descriptor=i,s}return Nt.default(t,[{key:"uri",get:function(){return this.descriptor.url}},{key:"links",get:function(){return this.descriptor.links}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"stream"}},{key:"lastEventId",get:function(){return null}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"publishMessage",value:function(){var n=Be.default(ne.default.mark(function a(s){var c,o,u,l;return ne.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return c={data:s},d.next=3,this.services.network.post(this.links.messages,c);case 3:return o=d.sent,u=o.body,l=this._handleMessagePublished(u.sid,s,!1),d.abrupt("return",l);case 7:case"end":return d.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=Be.default(ne.default.mark(function a(s){var c,o;return ne.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.prev=0,c={ttl:s},l.next=4,this.services.network.post(this.uri,c);case 4:o=l.sent,this.descriptor.date_expires=o.body.date_expires,l.next=12;break;case 8:throw l.prev=8,l.t0=l.catch(0),l.t0.status===404&&this.onRemoved(!1),l.t0;case 12:case"end":return l.stop()}},a,this,[[0,8]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"removeStream",value:function(){var n=Be.default(ne.default.mark(function a(){return ne.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return c.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"_update",value:function(i){switch(i.type){case"stream_message_published":{this._handleMessagePublished(i.message_sid,i.message_data,!0);break}case"stream_removed":{this.onRemoved(!1);break}}}},{key:"_handleMessagePublished",value:function(i,a,s){var c={sid:i,data:a};return this.broadcastEventToListeners("messagePublished",{message:c,isLocal:!s}),c}},{key:"onRemoved",value:function(i){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:i})}}],[{key:"type",get:function(){return"stream"}}]),t}(Au);It([Pe.validateTypesAsync(Pe.pureObject),Ne("design:type",Function),Ne("design:paramtypes",[Object]),Ne("design:returntype",Promise)],su.prototype,"publishMessage",null);It([Pe.validateTypesAsync(Pe.nonNegativeInteger),Ne("design:type",Function),Ne("design:paramtypes",[Number]),Ne("design:returntype",Promise)],su.prototype,"setTtl",null);var Zn=function(e){Vr.default(t,e);var r=gk(t);function t(n){var i;return Ot.default(this,t),i=r.call(this),i.syncStreamImpl=n,i.syncStreamImpl.attach(ti.default(i)),i}return Nt.default(t,[{key:"uri",get:function(){return this.syncStreamImpl.uri}},{key:"links",get:function(){return this.syncStreamImpl.links}},{key:"dateExpires",get:function(){return this.syncStreamImpl.dateExpires}},{key:"type",get:function(){return su.type}},{key:"lastEventId",get:function(){return null}},{key:"sid",get:function(){return this.syncStreamImpl.sid}},{key:"uniqueName",get:function(){return this.syncStreamImpl.uniqueName}},{key:"publishMessage",value:function(){var n=Be.default(ne.default.mark(function a(s){return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncStreamImpl.publishMessage(s));case 2:case"end":return o.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=Be.default(ne.default.mark(function a(s){return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncStreamImpl.setTtl(s));case 2:case"end":return o.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"removeStream",value:function(){var n=Be.default(ne.default.mark(function a(){return ne.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncStreamImpl.removeStream());case 2:case"end":return c.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"close",value:function(){Iu.default(or.default(t.prototype),"close",this).call(this),this.syncStreamImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return su.type}}]),t}(Mu);jt.default(Zn,"messagePublished","messagePublished");jt.default(Zn,"removed","removed");It([Pe.validateTypesAsync(Pe.pureObject),Ne("design:type",Function),Ne("design:paramtypes",[Object]),Ne("design:returntype",Promise)],Zn.prototype,"publishMessage",null);It([Pe.validateTypesAsync(Pe.nonNegativeInteger),Ne("design:type",Function),Ne("design:paramtypes",[Number]),Ne("design:returntype",Promise)],Zn.prototype,"setTtl",null);var LH=function e(r){Ot.default(this,e),this.sdk="js",this.sdkVer=r,this.os=dc.os.family,this.osVer=dc.os.version,this.pl=dc.name,this.plVer=dc.version},DH=function(){function e(){Ot.default(this,e),this.names=new Map,this.entities=new Map}return Nt.default(e,[{key:"store",value:function(t){var n=this.entities.get(t.sid);return n||(this.entities.set(t.sid,t),t.uniqueName&&this.names.set(t.type+"::"+t.uniqueName,t.sid),t)}},{key:"getResolved",value:function(t,n){var i=this.names.get(n+"::"+t);return i?this.entities.get(i):null}},{key:"get",value:function(t,n){return this.entities.get(t)||this.getResolved(t,n)||null}},{key:"remove",value:function(t){var n=this.entities.get(t);n&&(this.entities.delete(t),n.uniqueName&&this.names.delete(n.type+"::"+n.uniqueName))}}]),e}();function wm(e){var r=jH();return function(){var n=or.default(e),i;if(r){var a=or.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return ka.default(this,i)}}function jH(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var FH=function e(){Ot.default(this,e)},nh=function(e){Vr.default(t,e);var r=wm(t);function t(n,i,a,s){var c;return Ot.default(this,t),c=r.call(this,i,a),c.descriptor=n,c.cache=new Sm,s&&s.forEach(function(o){c.cache.store(o.key,{key:o.key,value:o.data},o.revision)}),c}return Nt.default(t,[{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return null}},{key:"type",get:function(){return t.type}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"indexName",get:function(){return this.descriptor.indexName}},{key:"queryString",get:function(){return this.descriptor.queryExpression}},{key:"queryUri",get:function(){return this.descriptor.queryUri}},{key:"liveQueryDescriptor",get:function(){return this.descriptor}},{key:"onRemoved",value:function(){}},{key:"getItems",value:function(){var i={};return this.cache.forEach(function(a,s){i[a]=s.value}),i}},{key:"_update",value:function(i,a){switch(i.type){case"live_query_item_updated":this.handleItemMutated(i.item_key,i.item_data,i.item_revision);break;case"live_query_item_removed":this.handleItemRemoved(i.item_key,i.item_revision);break;case"live_query_updated":this.handleBatchUpdate(i.items);break}a&&this._advanceLastEventId(i.last_event_id)}},{key:"handleItemMutated",value:function(i,a,s){if(this.shouldIgnoreEvent(i,s))Mt.trace("Item ".concat(i," update skipped, revision: ").concat(s));else{var c={key:i,value:a};this.cache.store(i,c,s),this.broadcastEventToListeners("itemUpdated",c)}}},{key:"handleItemRemoved",value:function(i,a){var s=a===null;this.shouldIgnoreEvent(i,a)?Mt.trace("Item ".concat(i," delete skipped, revision: ").concat(a)):(this.cache.delete(i,a,s),this.broadcastEventToListeners("itemRemoved",{key:i}))}},{key:"handleBatchUpdate",value:function(i){var a=this,s={};i!=null&&i.forEach(function(o){s[o.key]={data:o.data,revision:o.revision}}),this.cache.forEach(function(o,u){var l=s[o];l!=null?a.handleItemMutated(o,l.data,l.revision):a.handleItemRemoved(o,null),delete s[o]});for(var c in s)this.handleItemMutated(c,s[c].data,s[c].revision)}},{key:"shouldIgnoreEvent",value:function(i,a){return i!=null&&a!=null&&this.cache.isKnown(i,a)}},{key:"_advanceLastEventId",value:function(i,a){this.lastEventId<i&&(this.descriptor.last_event_id=i)}}],[{key:"type",get:function(){return"live_query"}}]),t}(Au);function yk(e){return ih.apply(this,arguments)}function ih(){return ih=Be.default(ne.default.mark(function e(r){var t,n,i,a,s,c;return ne.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(t=r.network,n=r.queryString,i=r.uri,a=r.type,n!=null){u.next=3;break}throw new en("Invalid query",400,54507);case 3:return s={query_string:n},a===Oi.type&&(s.type=a),u.next=7,t.post(i,s,void 0,!0);case 7:return c=u.sent,u.abrupt("return",c.body);case 9:case"end":return u.stop()}},e)})),ih.apply(this,arguments)}var Oi=function(e){Vr.default(t,e);var r=wm(t);function t(n){var i;return Ot.default(this,t),i=r.call(this),i.liveQueryImpl=n,i.liveQueryImpl.attach(ti.default(i)),i}return Nt.default(t,[{key:"type",get:function(){return nh.type}},{key:"lastEventId",get:function(){return this.liveQueryImpl.lastEventId}},{key:"sid",get:function(){return this.liveQueryImpl.sid}},{key:"close",value:function(){Iu.default(or.default(t.prototype),"close",this).call(this),this.liveQueryImpl.detach(this.listenerUuid)}},{key:"getItems",value:function(){return this.ensureNotClosed(),this.liveQueryImpl.getItems()}}],[{key:"type",get:function(){return nh.type}}]),t}(Mu);jt.default(Oi,"itemUpdated","itemUpdated");jt.default(Oi,"itemRemoved","itemRemoved");var xu=function(e){Vr.default(t,e);var r=wm(t);function t(n){var i;return Ot.default(this,t),i=r.call(this),jt.default(ti.default(i),"queryExpression",null),jt.default(ti.default(i),"items",{}),Object.assign(ti.default(i),n),i.updateIndexName(n.indexName),i}return Nt.default(t,[{key:"type",get:function(){return t.type}},{key:"search",value:function(){var n=Be.default(ne.default.mark(function a(s){var c=this;return ne.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.items={},u.abrupt("return",yk({network:this.network,uri:this.queryUri,queryString:s}).then(function(l){c.queryExpression=s,l.items&&l.items.forEach(function(f){c.items[f.key]=f.data}),c.emit("searchResult",c.getItems())}).catch(function(l){throw Mt.error("Error '".concat(l.message,"' while executing query '").concat(s,"'")),c.queryExpression=null,l}));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"subscribe",value:function(){var n=Be.default(ne.default.mark(function a(){return ne.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(this.queryExpression!=null){c.next=2;break}return c.abrupt("return",Promise.reject(new en("Invalid query",400,54507)));case 2:return c.abrupt("return",this.liveQueryCreator(this.indexName,this.queryExpression));case 3:case"end":return c.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"getItems",value:function(){return this.items}},{key:"updateIndexName",value:function(i){this.indexName=i,this.queryUri=this.generateQueryUri(this.indexName)}},{key:"generateQueryUri",value:function(i){return new Ys(this.insightsUri).pathSegment(i).pathSegment("Items").build()}}],[{key:"type",get:function(){return"instant_query"}}]),t}(Ut);jt.default(xu,"searchResult","searchResult");It([Pe.validateTypesAsync("string"),Ne("design:type",Function),Ne("design:paramtypes",[String]),Ne("design:returntype",Promise)],xu.prototype,"search",null);It([Pe.validateTypes(Pe.nonEmptyString),Ne("design:type",Function),Ne("design:paramtypes",[String]),Ne("design:returntype",void 0)],xu.prototype,"updateIndexName",null);var UH="3.1.0";function BH(e){var r=qH();return function(){var n=or.default(e),i;if(r){var a=or.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return ka.default(this,i)}}function qH(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function U_(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),t.push.apply(t,n)}return t}function B_(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?U_(Object(t),!0).forEach(function(n){jt.default(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):U_(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}var GH="data_sync",Ud=UH;function pc(e){if(e){if(typeof e=="string")return{id:e,mode:"open_or_create"};var r=e.mode||(e.id?"open_or_create":"create_new");return B_(B_({},e),{},{mode:r})}else return{mode:"create_new"}}var q_="com.twilio.rtd.cds.document",G_="com.twilio.rtd.cds.list",z_="com.twilio.rtd.cds.map",W_="twilio.sync.event",pn=function(e){Vr.default(t,e);var r=BH(t);function t(n){var i,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(Ot.default(this,t),i=r.call(this),!n)throw new Error("Sync library needs a valid Twilio token to be passed");a.hasOwnProperty("logLevel")?Mt.setLevel(a.logLevel):Mt.setLevel("silent");var s=a.productId=a.productId||GH;a.clientMetadata=a.clientMetadata||{},a.clientMetadata.hasOwnProperty("type")||(a.clientMetadata.type="sync"),a.clientMetadata.hasOwnProperty("sdk")||(a.clientMetadata.sdk="JS",a.clientMetadata.sdkv=Ud);var c=!a.twilsockClient;if(!a.initRegistrations){var o=new dl.InitRegistration(s);t.populateInitRegistrations(o),a.initRegistrations=[o]}var u=a.twilsockClient=a.twilsockClient||new dl.Twilsock(n,s,a);u.on("tokenAboutToExpire",function(p){return i.emit("tokenAboutToExpire",p)}),u.on("tokenExpired",function(){return i.emit("tokenExpired")}),u.on("connectionError",function(p){return i.emit("connectionError",p)}),u.on("stateChanged",function(p){i.emit("connectionStateChanged",p),i.services.subscriptions.onConnectionStateChanged(p==="connected")}),u.on("message",function(p,h){return i._routeMessage(p,h)});var l=new lH(a),f=new yH(new LH(Ud),l,u),d=new bH(l);return i.services={config:l,twilsock:u,network:f,storage:d,router:ti.default(i),subscriptions:null},i.services.subscriptions=new pH(i.services),i.entities=new DH,c&&u.connect(),i}return Nt.default(t,[{key:"_routeMessage",value:function(i,a){switch(Mt.trace("Notification type:",i,"content:",a),i){case q_:case G_:case z_:this.services.subscriptions.acceptMessage(a,!1);break;case W_:this.services.subscriptions.acceptMessage(a,!0);break}}},{key:"_subscribe",value:function(i,a){this.services.subscriptions.add(i,a)}},{key:"_unsubscribe",value:function(i){this.services.subscriptions.remove(i)}},{key:"connectionState",get:function(){return this.services.twilsock.state}},{key:"ensureReady",value:function(){var n=Be.default(ne.default.mark(function a(){var s;return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(this.services.config.sessionStorageEnabled){o.next=2;break}return o.abrupt("return");case 2:return o.prev=2,o.next=5,this.services.twilsock.storageId();case 5:s=o.sent,this.services.storage.updateStorageId(s.id),o.next=12;break;case 9:o.prev=9,o.t0=o.catch(2),Mt.warn("Failed to initialize storage",o.t0);case 12:case"end":return o.stop()}},a,this,[[2,9]])}));function i(){return n.apply(this,arguments)}return i}()},{key:"storeRootInSessionCache",value:function(i,a,s){if(!(!this.services.config.sessionStorageEnabled||!a)){var c=Bn(s);(i===dr.type||i===yr.type)&&(c.last_event_id=null,delete c.items),this.services.storage.store(i,a,c)}}},{key:"readRootFromSessionCache",value:function(i,a){return!this.services.config.sessionStorageEnabled||!a?null:this.services.storage.read(i,a)}},{key:"_get",value:function(){var n=Be.default(ne.default.mark(function a(s,c){var o,u,l,f=arguments;return ne.default.wrap(function(p){for(;;)switch(p.prev=p.next){case 0:if(o=f.length>2&&f[2]!==void 0?f[2]:!1,c){p.next=3;break}throw new en("Cannot get entity without id",404);case 3:return u=new Ys(s).pathSegment(c).queryParam("Include",o?"items":void 0).build(),p.next=6,this.services.network.get(u);case 6:return l=p.sent,p.abrupt("return",l.body);case 8:case"end":return p.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"_createDocument",value:function(i,a,s){var c={unique_name:i,data:a||{}};return s!==void 0&&(c.ttl=s),this.services.network.post(this.services.config.documentsUri,c).then(function(o){return o.body.data=c.data,o.body})}},{key:"_getDocument",value:function(){var n=Be.default(ne.default.mark(function a(s){return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.abrupt("return",this.readRootFromSessionCache(wn.type,s)||this._get(this.services.config.documentsUri,s));case 1:case"end":return o.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_createList",value:function(i,a,s,c){var o={unique_name:i,purpose:a,context:s};return c!==void 0&&(o.ttl=c),this.services.network.post(this.services.config.listsUri,o).then(function(u){return u.body})}},{key:"_getList",value:function(){var n=Be.default(ne.default.mark(function a(s){return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.abrupt("return",this.readRootFromSessionCache(dr.type,s)||this._get(this.services.config.listsUri,s));case 1:case"end":return o.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_createMap",value:function(i,a){var s={unique_name:i};return a!==void 0&&(s.ttl=a),this.services.network.post(this.services.config.mapsUri,s).then(function(c){return c.body})}},{key:"_getMap",value:function(){var n=Be.default(ne.default.mark(function a(s){var c,o=arguments;return ne.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return c=o.length>1&&o[1]!==void 0?o[1]:!1,l.abrupt("return",this.readRootFromSessionCache(yr.type,s)||this._get(this.services.config.mapsUri,s,c));case 2:case"end":return l.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_getStream",value:function(){var n=Be.default(ne.default.mark(function a(s){return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.abrupt("return",this.readRootFromSessionCache(Zn.type,s)||this._get(this.services.config.streamsUri,s,!1));case 1:case"end":return o.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_createStream",value:function(){var n=Be.default(ne.default.mark(function a(s,c){var o,u;return ne.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return o={unique_name:s},c!==void 0&&(o.ttl=c),f.next=4,this.services.network.post(this.services.config.streamsUri,o);case 4:return u=f.sent,f.abrupt("return",u.body);case 6:case"end":return f.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"_getLiveQuery",value:function(i){return this.readRootFromSessionCache(Oi.type,i)}},{key:"getCached",value:function(i,a){return i&&this.entities.get(i,a)||null}},{key:"removeFromCacheAndSession",value:function(i,a,s){this.entities.remove(a),this.services.config.sessionStorageEnabled&&this.services.storage.remove(i,a,s)}},{key:"document",value:function(){var n=Be.default(ne.default.mark(function a(s){var c=this,o,u,l,f;return ne.default.wrap(function(p){for(;;)switch(p.prev=p.next){case 0:return p.next=2,this.ensureReady();case 2:if(o=pc(s),o.mode!=="create_new"){p.next=9;break}return p.next=6,this._createDocument(o.id,o.data,o.ttl);case 6:u=p.sent,p.next=39;break;case 9:if(l=this.getCached(o.id,wn.type),!l){p.next=14;break}return p.abrupt("return",new wn(l));case 14:return p.prev=14,p.next=17,this._getDocument(o.id);case 17:u=p.sent,p.next=39;break;case 20:if(p.prev=20,p.t0=p.catch(14),!(p.t0.status!==404||o.mode==="open_existing")){p.next=26;break}throw p.t0;case 26:return p.prev=26,p.next=29,this._createDocument(o.id,o.data,o.ttl);case 29:u=p.sent,p.next=39;break;case 32:if(p.prev=32,p.t1=p.catch(26),p.t1.status!==409){p.next=38;break}return p.abrupt("return",this.document(s));case 38:throw p.t1;case 39:return this.storeRootInSessionCache(wn.type,o.id,u),f=new Zp(this.services,u,function(h,E,M){return c.removeFromCacheAndSession(h,E,M)}),f=this.entities.store(f),p.abrupt("return",new wn(f));case 43:case"end":return p.stop()}},a,this,[[14,20],[26,32]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"map",value:function(){var n=Be.default(ne.default.mark(function a(s){var c=this,o,u,l,f;return ne.default.wrap(function(p){for(;;)switch(p.prev=p.next){case 0:return p.next=2,this.ensureReady();case 2:if(o=pc(s),o.mode!=="create_new"){p.next=9;break}return p.next=6,this._createMap(o.id,o.ttl);case 6:u=p.sent,p.next=39;break;case 9:if(l=this.getCached(o.id,yr.type),!l){p.next=14;break}return p.abrupt("return",new yr(l));case 14:return p.prev=14,p.next=17,this._getMap(o.id,o.includeItems);case 17:u=p.sent,p.next=39;break;case 20:if(p.prev=20,p.t0=p.catch(14),!(p.t0.status!==404||o.mode==="open_existing")){p.next=26;break}throw p.t0;case 26:return p.prev=26,p.next=29,this._createMap(o.id,o.ttl);case 29:u=p.sent,p.next=39;break;case 32:if(p.prev=32,p.t1=p.catch(26),p.t1.status!==409){p.next=38;break}return p.abrupt("return",this.map(s));case 38:throw p.t1;case 39:return this.storeRootInSessionCache(yr.type,o.id,u),f=new rh(this.services,u,function(h,E,M){return c.removeFromCacheAndSession(h,E,M)}),f=this.entities.store(f),p.abrupt("return",new yr(f));case 43:case"end":return p.stop()}},a,this,[[14,20],[26,32]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"list",value:function(){var n=Be.default(ne.default.mark(function a(s){var c=this,o,u,l,f;return ne.default.wrap(function(p){for(;;)switch(p.prev=p.next){case 0:return p.next=2,this.ensureReady();case 2:if(o=pc(s),o.mode!=="create_new"){p.next=9;break}return p.next=6,this._createList(o.id,o.purpose,o.context,o.ttl);case 6:u=p.sent,p.next=39;break;case 9:if(l=this.getCached(o.id,dr.type),!l){p.next=14;break}return p.abrupt("return",new dr(l));case 14:return p.prev=14,p.next=17,this._getList(o.id);case 17:u=p.sent,p.next=39;break;case 20:if(p.prev=20,p.t0=p.catch(14),!(p.t0.status!==404||o.mode==="open_existing")){p.next=26;break}throw p.t0;case 26:return p.prev=26,p.next=29,this._createList(o.id,o.purpose,o.context,o.ttl);case 29:u=p.sent,p.next=39;break;case 32:if(p.prev=32,p.t1=p.catch(26),p.t1.status!==409){p.next=38;break}return p.abrupt("return",this.list(s));case 38:throw p.t1;case 39:return this.storeRootInSessionCache(dr.type,o.id,u),f=new th(this.services,u,function(h,E,M){return c.removeFromCacheAndSession(h,E,M)}),f=this.entities.store(f),p.abrupt("return",new dr(f));case 43:case"end":return p.stop()}},a,this,[[14,20],[26,32]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"stream",value:function(){var n=Be.default(ne.default.mark(function a(s){var c=this,o,u,l,f,d;return ne.default.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,this.ensureReady();case 2:if(o=pc(s),o.mode!=="create_new"){h.next=9;break}return h.next=6,this._createStream(o.id,o.ttl);case 6:u=h.sent,h.next=39;break;case 9:if(l=this.getCached(o.id,Zn.type),!l){h.next=14;break}return h.abrupt("return",new Zn(l));case 14:return h.prev=14,h.next=17,this._getStream(o.id);case 17:u=h.sent,h.next=39;break;case 20:if(h.prev=20,h.t0=h.catch(14),!(h.t0.status!==404||o.mode==="open_existing")){h.next=26;break}throw h.t0;case 26:return h.prev=26,h.next=29,this._createStream(o.id,o.ttl);case 29:u=h.sent,h.next=39;break;case 32:if(h.prev=32,h.t1=h.catch(26),h.t1.status!==409){h.next=38;break}return h.abrupt("return",this.stream(s));case 38:throw h.t1;case 39:return this.storeRootInSessionCache(Zn.type,o.id,u),f=function(M,I,x){return c.removeFromCacheAndSession(M,I,x)},d=new su(this.services,u,f),d=this.entities.store(d),h.abrupt("return",new Zn(d));case 44:case"end":return h.stop()}},a,this,[[14,20],[26,32]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"shutdown",value:function(){var n=Be.default(ne.default.mark(function a(){return ne.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this.services.subscriptions.shutdown();case 2:return c.next=4,this.services.twilsock.disconnect();case 4:case"end":return c.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"updateToken",value:function(){var n=Be.default(ne.default.mark(function a(s){return ne.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.abrupt("return",this.services.twilsock.updateToken(s).catch(function(u){var l,f=u==null||(l=u.reply)===null||l===void 0?void 0:l.status;throw(f==null?void 0:f.code)===401&&(f==null?void 0:f.status)==="UNAUTHORIZED"?new en("Updated token was rejected by server",400,51130):u}));case 1:case"end":return o.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"liveQuery",value:function(){var n=Be.default(ne.default.mark(function a(s,c){var o=this,u,l,f,d,p;return ne.default.wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return E.next=2,this.ensureReady();case 2:return u=new Ys(this.services.config.insightsUri).pathSegment(s).pathSegment("Items").build(),E.next=5,yk({network:this.services.network,uri:u,queryString:c,type:Oi.type});case 5:return l=E.sent,f=this.getCached(l.query_id,Oi.type),f||(d=this._getLiveQuery(l.query_id),d||(d={indexName:s,queryExpression:c,sid:l.query_id,queryUri:u,last_event_id:l.last_event_id}),p=function(I,x,j){return o.removeFromCacheAndSession(I,x,j)},f=new nh(d,this.services,p,l.items)),this.storeRootInSessionCache(Oi.type,l.query_id,f.liveQueryDescriptor),f=this.entities.store(f),E.abrupt("return",new Oi(f));case 11:case"end":return E.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"instantQuery",value:function(){var n=Be.default(ne.default.mark(function a(s){var c=this,o;return ne.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.next=2,this.ensureReady();case 2:return o=function(d,p){return c.liveQuery(d,p)},l.abrupt("return",new xu({indexName:s,network:this.services.network,insightsUri:this.services.config.insightsUri,liveQueryCreator:o}));case 4:case"end":return l.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()}],[{key:"populateInitRegistrations",value:function(i){i.populateInitRegistrations([W_,q_,G_,z_])}},{key:"version",get:function(){return Ud}}]),t}(Ut);jt.default(pn,"connectionStateChanged","connectionStateChanged");jt.default(pn,"connectionError","connectionError");jt.default(pn,"tokenAboutToExpire","tokenAboutToExpire");jt.default(pn,"tokenExpired","tokenExpired");It([Pe.validateTypesAsync(["undefined","string",Pe.objectSchema("open document options",{id:["string","undefined"],mode:[Pe.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Pe.nonNegativeInteger,"undefined"],data:[Pe.pureObject,"undefined",Pe.literal(null)]})]),Ne("design:type",Function),Ne("design:paramtypes",[Object]),Ne("design:returntype",Promise)],pn.prototype,"document",null);It([Pe.validateTypesAsync(["undefined","string",Pe.objectSchema("open map options",{id:["string","undefined"],mode:[Pe.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Pe.nonNegativeInteger,"undefined"],data:[Pe.pureObject,"undefined",Pe.literal(null)],includeItems:["boolean","undefined"]})]),Ne("design:type",Function),Ne("design:paramtypes",[Object]),Ne("design:returntype",Promise)],pn.prototype,"map",null);It([Pe.validateTypesAsync(["undefined","string",Pe.objectSchema("open list options",{id:["string","undefined"],mode:[Pe.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Pe.nonNegativeInteger,"undefined"],data:[Pe.pureObject,"undefined",Pe.literal(null)],purpose:["string","undefined"],context:[Pe.pureObject,"undefined"],includeItems:["boolean","undefined"]})]),Ne("design:type",Function),Ne("design:paramtypes",[Object]),Ne("design:returntype",Promise)],pn.prototype,"list",null);It([Pe.validateTypesAsync(["undefined","string",Pe.objectSchema("open stream options",{id:["string","undefined"],mode:[Pe.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Pe.nonNegativeInteger,"undefined"],data:[Pe.pureObject,"undefined",Pe.literal(null)]})]),Ne("design:type",Function),Ne("design:paramtypes",[Object]),Ne("design:returntype",Promise)],pn.prototype,"stream",null);It([Pe.validateTypesAsync(Pe.nonEmptyString),Ne("design:type",Function),Ne("design:paramtypes",[String]),Ne("design:returntype",Promise)],pn.prototype,"updateToken",null);It([Pe.validateTypesAsync(Pe.nonEmptyString,"string"),Ne("design:type",Function),Ne("design:paramtypes",[String,String]),Ne("design:returntype",Promise)],pn.prototype,"liveQuery",null);It([Pe.validateTypesAsync(Pe.nonEmptyString),Ne("design:type",Function),Ne("design:paramtypes",[String]),Ne("design:returntype",Promise)],pn.prototype,"instantQuery",null);tn.Client=pn;tn.InsightsItem=FH;tn.InstantQuery=xu;tn.LiveQuery=Oi;tn.Paginator=_m;tn.SyncClient=pn;tn.SyncDocument=wn;tn.SyncList=dr;tn.SyncListItem=eh;tn.SyncMap=yr;tn.SyncMapItem=Fo;tn.SyncStream=Zn;var bk={},zH=WE,WH=TypeError,_k=function(e){if(zH(e))throw WH("The method doesn't accept regular expressions");return e},VH=Gt,HH=VH("match"),Sk=function(e){var r=/./;try{"/./"[e](r)}catch{try{return r[HH]=!1,"/./"[e](r)}catch{}}return!1},KH=St,wk=El,JH=ii.f,YH=Fi,V_=br,XH=_k,QH=oi,ZH=Sk,H_=wk("".startsWith),e8=wk("".slice),t8=Math.min,Tk=ZH("startsWith"),r8=!Tk&&!!function(){var e=JH(String.prototype,"startsWith");return e&&!e.writable}();KH({target:"String",proto:!0,forced:!r8&&!Tk},{startsWith:function(r){var t=V_(QH(this));XH(r);var n=YH(t8(arguments.length>1?arguments[1]:void 0,t.length)),i=V_(r);return H_?H_(t,i,n):e8(t,n,n+i.length)===i}});var n8=mt,i8=Gt,a8=Yt,K_=Fw,s8=i8("iterator"),Ck=!n8(function(){var e=new URL("b?a=1&b=2&c=3","http://a"),r=e.searchParams,t="";return e.pathname="c%20d",r.forEach(function(n,i){r.delete("b"),t+=i+n}),K_&&!e.toJSON||!r.size&&(K_||!a8)||!r.sort||e.href!=="http://a/c%20d?a=1&c=3"||r.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!r[s8]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("http://тест").host!=="xn--e1aybc"||new URL("http://a#б").hash!=="#%D0%B1"||t!=="a1c3"||new URL("http://x",void 0).host!=="x"}),ps=_t,Bd=2147483647,Jo=36,Ek=1,ah=26,o8=38,u8=700,c8=72,l8=128,f8="-",d8=/[^\0-\u007E]/,kk=/[.\u3002\uFF0E\uFF61]/g,J_="Overflow: input needs wider integers to process",qd=Jo-Ek,Y_=RangeError,p8=ps(kk.exec),xs=Math.floor,Gd=String.fromCharCode,X_=ps("".charCodeAt),Rk=ps([].join),ua=ps([].push),h8=ps("".replace),v8=ps("".split),m8=ps("".toLowerCase),g8=function(e){for(var r=[],t=0,n=e.length;t<n;){var i=X_(e,t++);if(i>=55296&&i<=56319&&t<n){var a=X_(e,t++);(a&64512)==56320?ua(r,((i&1023)<<10)+(a&1023)+65536):(ua(r,i),t--)}else ua(r,i)}return r},Q_=function(e){return e+22+75*(e<26)},y8=function(e,r,t){var n=0;for(e=t?xs(e/u8):e>>1,e+=xs(e/r);e>qd*ah>>1;)e=xs(e/qd),n+=Jo;return xs(n+(qd+1)*e/(e+o8))},b8=function(e){var r=[];e=g8(e);var t=e.length,n=l8,i=0,a=c8,s,c;for(s=0;s<e.length;s++)c=e[s],c<128&&ua(r,Gd(c));var o=r.length,u=o;for(o&&ua(r,f8);u<t;){var l=Bd;for(s=0;s<e.length;s++)c=e[s],c>=n&&c<l&&(l=c);var f=u+1;if(l-n>xs((Bd-i)/f))throw Y_(J_);for(i+=(l-n)*f,n=l,s=0;s<e.length;s++){if(c=e[s],c<n&&++i>Bd)throw Y_(J_);if(c==n){for(var d=i,p=Jo;;){var h=p<=a?Ek:p>=a+ah?ah:p-a;if(d<h)break;var E=d-h,M=Jo-h;ua(r,Gd(Q_(h+E%M))),d=xs(E/M),p+=Jo}ua(r,Gd(Q_(d))),a=y8(i,f,u==o),i=0,u++}}i++,n++}return Rk(r,"")},_8=function(e){var r=[],t=v8(h8(m8(e),kk,"."),"."),n,i;for(n=0;n<t.length;n++)i=t[n],ua(r,p8(d8,i)?"xn--"+b8(i):i);return Rk(r,".")},sh=St,Xs=Rt,hc=qt,ri=_t,Ws=Yt,$k=Ck,Ok=Gr,S8=ci,w8=Vv,T8=Ui,C8=$C,Tm=kn,Ik=cs,zd=Bt,E8=rr,k8=qi,R8=Bi,$8=sr,Pk=tr,un=br,O8=Sa,Z_=rs,oh=Nl,I8=ku,Cs=vv,P8=Gt,A8=pm,M8=P8("iterator"),Nu="URLSearchParams",Ak=Nu+"Iterator",Mk=Tm.set,_n=Tm.getterFor(Nu),x8=Tm.getterFor(Ak),N8=Object.getOwnPropertyDescriptor,Cm=function(e){if(!Ws)return Xs[e];var r=N8(Xs,e);return r&&r.value},eS=Cm("fetch"),pl=Cm("Request"),Yo=Cm("Headers"),Wd=pl&&pl.prototype,tS=Yo&&Yo.prototype,L8=Xs.RegExp,D8=Xs.TypeError,xk=Xs.decodeURIComponent,j8=Xs.encodeURIComponent,F8=ri("".charAt),rS=ri([].join),Ha=ri([].push),uh=ri("".replace),U8=ri([].shift),nS=ri([].splice),iS=ri("".split),B8=ri("".slice),q8=/\+/g,aS=Array(4),G8=function(e){return aS[e-1]||(aS[e-1]=L8("((?:%[\\da-f]{2}){"+e+"})","gi"))},z8=function(e){try{return xk(e)}catch{return e}},sS=function(e){var r=uh(e,q8," "),t=4;try{return xk(r)}catch{for(;t;)r=uh(r,G8(t--),z8);return r}},W8=/[!'()~]|%20/g,V8={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},H8=function(e){return V8[e]},oS=function(e){return uh(j8(e),W8,H8)},Vd=C8(function(r,t){Mk(this,{type:Ak,iterator:oh(_n(r).entries),kind:t})},"Iterator",function(){var r=x8(this),t=r.kind,n=r.iterator.next(),i=n.value;return n.done||(n.value=t==="keys"?i.key:t==="values"?i.value:[i.key,i.value]),n},!0),Nk=function(e){this.entries=[],this.url=null,e!==void 0&&(Pk(e)?this.parseObject(e):this.parseQuery(typeof e=="string"?F8(e,0)==="?"?B8(e,1):e:un(e)))};Nk.prototype={type:Nu,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var r=I8(e),t,n,i,a,s,c,o;if(r)for(t=oh(e,r),n=t.next;!(i=hc(n,t)).done;){if(a=oh($8(i.value)),s=a.next,(c=hc(s,a)).done||(o=hc(s,a)).done||!hc(s,a).done)throw D8("Expected sequence with length 2");Ha(this.entries,{key:un(c.value),value:un(o.value)})}else for(var u in e)E8(e,u)&&Ha(this.entries,{key:u,value:un(e[u])})},parseQuery:function(e){if(e)for(var r=iS(e,"&"),t=0,n,i;t<r.length;)n=r[t++],n.length&&(i=iS(n,"="),Ha(this.entries,{key:sS(U8(i)),value:sS(rS(i,"="))}))},serialize:function(){for(var e=this.entries,r=[],t=0,n;t<e.length;)n=e[t++],Ha(r,oS(n.key)+"="+oS(n.value));return rS(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var uf=function(){Ik(this,Qs);var r=arguments.length>0?arguments[0]:void 0,t=Mk(this,new Nk(r));Ws||(this.length=t.entries.length)},Qs=uf.prototype;w8(Qs,{append:function(r,t){Cs(arguments.length,2);var n=_n(this);Ha(n.entries,{key:un(r),value:un(t)}),Ws||this.length++,n.updateURL()},delete:function(e){Cs(arguments.length,1);for(var r=_n(this),t=r.entries,n=un(e),i=0;i<t.length;)t[i].key===n?nS(t,i,1):i++;Ws||(this.length=t.length),r.updateURL()},get:function(r){Cs(arguments.length,1);for(var t=_n(this).entries,n=un(r),i=0;i<t.length;i++)if(t[i].key===n)return t[i].value;return null},getAll:function(r){Cs(arguments.length,1);for(var t=_n(this).entries,n=un(r),i=[],a=0;a<t.length;a++)t[a].key===n&&Ha(i,t[a].value);return i},has:function(r){Cs(arguments.length,1);for(var t=_n(this).entries,n=un(r),i=0;i<t.length;)if(t[i++].key===n)return!0;return!1},set:function(r,t){Cs(arguments.length,1);for(var n=_n(this),i=n.entries,a=!1,s=un(r),c=un(t),o=0,u;o<i.length;o++)u=i[o],u.key===s&&(a?nS(i,o--,1):(a=!0,u.value=c));a||Ha(i,{key:s,value:c}),Ws||(this.length=i.length),n.updateURL()},sort:function(){var r=_n(this);A8(r.entries,function(t,n){return t.key>n.key?1:-1}),r.updateURL()},forEach:function(r){for(var t=_n(this).entries,n=k8(r,arguments.length>1?arguments[1]:void 0),i=0,a;i<t.length;)a=t[i++],n(a.value,a.key,this)},keys:function(){return new Vd(this,"keys")},values:function(){return new Vd(this,"values")},entries:function(){return new Vd(this,"entries")}},{enumerable:!0});Ok(Qs,M8,Qs.entries,{name:"entries"});Ok(Qs,"toString",function(){return _n(this).serialize()},{enumerable:!0});Ws&&S8(Qs,"size",{get:function(){return _n(this).entries.length},configurable:!0,enumerable:!0});T8(uf,Nu);sh({global:!0,constructor:!0,forced:!$k},{URLSearchParams:uf});if(!$k&&zd(Yo)){var K8=ri(tS.has),J8=ri(tS.set),uS=function(e){if(Pk(e)){var r=e.body,t;if(R8(r)===Nu)return t=e.headers?new Yo(e.headers):new Yo,K8(t,"content-type")||J8(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),O8(e,{body:Z_(0,un(r)),headers:Z_(0,t)})}return e};if(zd(eS)&&sh({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(r){return eS(r,arguments.length>1?uS(arguments[1]):{})}}),zd(pl)){var Hd=function(r){return Ik(this,Wd),new pl(r,arguments.length>1?uS(arguments[1]):{})};Wd.constructor=Hd,Hd.prototype=Wd,sh({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Hd})}}var Y8={URLSearchParams:uf,getState:_n},X8=St,Em=Yt,Q8=Ck,km=Rt,cS=qi,On=_t,hl=Gr,mn=ci,Z8=cs,ch=rr,Rm=ZE,Es=EC,xn=yu,e9=Cv.codeAt,t9=_8,wi=br,r9=Ui,n9=vv,Lk=Y8,Dk=kn,i9=Dk.set,vl=Dk.getterFor("URL"),a9=Lk.URLSearchParams,s9=Lk.getState,xo=km.URL,lh=km.TypeError,ml=km.parseInt,o9=Math.floor,lS=Math.pow,Sn=On("".charAt),Fn=On(/./.exec),Uo=On([].join),u9=On(1 .toString),c9=On([].pop),Os=On([].push),Kd=On("".replace),l9=On([].shift),f9=On("".split),Xo=On("".slice),gl=On("".toLowerCase),d9=On([].unshift),p9="Invalid authority",Jd="Invalid scheme",qa="Invalid host",fS="Invalid port",jk=/[a-z]/i,h9=/[\d+-.a-z]/i,fh=/\d/,v9=/^0x/i,m9=/^[0-7]+$/,g9=/^\d+$/,Fk=/^[\da-f]+$/i,y9=/[\0\t\n\r #%/:<>?@[\\\]^|]/,b9=/[\0\t\n\r #/:<>?@[\\\]^|]/,_9=/^[\u0000-\u0020]+/,S9=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,w9=/[\t\n\r]/g,gn,T9=function(e){var r=f9(e,"."),t,n,i,a,s,c,o;if(r.length&&r[r.length-1]==""&&r.length--,t=r.length,t>4)return e;for(n=[],i=0;i<t;i++){if(a=r[i],a=="")return e;if(s=10,a.length>1&&Sn(a,0)=="0"&&(s=Fn(v9,a)?16:8,a=Xo(a,s==8?1:2)),a==="")c=0;else{if(!Fn(s==10?g9:s==8?m9:Fk,a))return e;c=ml(a,s)}Os(n,c)}for(i=0;i<t;i++)if(c=n[i],i==t-1){if(c>=lS(256,5-t))return null}else if(c>255)return null;for(o=c9(n),i=0;i<n.length;i++)o+=n[i]*lS(256,3-i);return o},C9=function(e){var r=[0,0,0,0,0,0,0,0],t=0,n=null,i=0,a,s,c,o,u,l,f,d=function(){return Sn(e,i)};if(d()==":"){if(Sn(e,1)!=":")return;i+=2,t++,n=t}for(;d();){if(t==8)return;if(d()==":"){if(n!==null)return;i++,t++,n=t;continue}for(a=s=0;s<4&&Fn(Fk,d());)a=a*16+ml(d(),16),i++,s++;if(d()=="."){if(s==0||(i-=s,t>6))return;for(c=0;d();){if(o=null,c>0)if(d()=="."&&c<4)i++;else return;if(!Fn(fh,d()))return;for(;Fn(fh,d());){if(u=ml(d(),10),o===null)o=u;else{if(o==0)return;o=o*10+u}if(o>255)return;i++}r[t]=r[t]*256+o,c++,(c==2||c==4)&&t++}if(c!=4)return;break}else if(d()==":"){if(i++,!d())return}else if(d())return;r[t++]=a}if(n!==null)for(l=t-n,t=7;t!=0&&l>0;)f=r[t],r[t--]=r[n+l-1],r[n+--l]=f;else if(t!=8)return;return r},E9=function(e){for(var r=null,t=1,n=null,i=0,a=0;a<8;a++)e[a]!==0?(i>t&&(r=n,t=i),n=null,i=0):(n===null&&(n=a),++i);return i>t&&(r=n,t=i),r},No=function(e){var r,t,n,i;if(typeof e=="number"){for(r=[],t=0;t<4;t++)d9(r,e%256),e=o9(e/256);return Uo(r,".")}else if(typeof e=="object"){for(r="",n=E9(e),t=0;t<8;t++)i&&e[t]===0||(i&&(i=!1),n===t?(r+=t?":":"::",i=!0):(r+=u9(e[t],16),t<7&&(r+=":")));return"["+r+"]"}return e},Wc={},Uk=Rm({},Wc,{" ":1,'"':1,"<":1,">":1,"`":1}),Bk=Rm({},Uk,{"#":1,"?":1,"{":1,"}":1}),Yd=Rm({},Bk,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),aa=function(e,r){var t=e9(e,0);return t>32&&t<127&&!ch(r,e)?e:encodeURIComponent(e)},vc={ftp:21,file:null,http:80,https:443,ws:80,wss:443},Bo=function(e,r){var t;return e.length==2&&Fn(jk,Sn(e,0))&&((t=Sn(e,1))==":"||!r&&t=="|")},dS=function(e){var r;return e.length>1&&Bo(Xo(e,0,2))&&(e.length==2||(r=Sn(e,2))==="/"||r==="\\"||r==="?"||r==="#")},k9=function(e){return e==="."||gl(e)==="%2e"},R9=function(e){return e=gl(e),e===".."||e==="%2e."||e===".%2e"||e==="%2e%2e"},Xd={},pS={},Qd={},hS={},vS={},Zd={},mS={},gS={},mc={},gc={},ep={},tp={},rp={},np={},yS={},ip={},ks={},Xn={},bS={},Ga={},_i={},$m=function(e,r,t){var n=wi(e),i,a,s;if(r){if(a=this.parse(n),a)throw lh(a);this.searchParams=null}else{if(t!==void 0&&(i=new $m(t,!0)),a=this.parse(n,null,i),a)throw lh(a);s=s9(new a9),s.bindURL(this),this.searchParams=s}};$m.prototype={type:"URL",parse:function(e,r,t){var n=this,i=r||Xd,a=0,s="",c=!1,o=!1,u=!1,l,f,d,p;for(e=wi(e),r||(n.scheme="",n.username="",n.password="",n.host=null,n.port=null,n.path=[],n.query=null,n.fragment=null,n.cannotBeABaseURL=!1,e=Kd(e,_9,""),e=Kd(e,S9,"$1")),e=Kd(e,w9,""),l=Es(e);a<=l.length;){switch(f=l[a],i){case Xd:if(f&&Fn(jk,f))s+=gl(f),i=pS;else{if(r)return Jd;i=Qd;continue}break;case pS:if(f&&(Fn(h9,f)||f=="+"||f=="-"||f=="."))s+=gl(f);else if(f==":"){if(r&&(n.isSpecial()!=ch(vc,s)||s=="file"&&(n.includesCredentials()||n.port!==null)||n.scheme=="file"&&!n.host))return;if(n.scheme=s,r){n.isSpecial()&&vc[n.scheme]==n.port&&(n.port=null);return}s="",n.scheme=="file"?i=np:n.isSpecial()&&t&&t.scheme==n.scheme?i=hS:n.isSpecial()?i=gS:l[a+1]=="/"?(i=vS,a++):(n.cannotBeABaseURL=!0,Os(n.path,""),i=bS)}else{if(r)return Jd;s="",i=Qd,a=0;continue}break;case Qd:if(!t||t.cannotBeABaseURL&&f!="#")return Jd;if(t.cannotBeABaseURL&&f=="#"){n.scheme=t.scheme,n.path=xn(t.path),n.query=t.query,n.fragment="",n.cannotBeABaseURL=!0,i=_i;break}i=t.scheme=="file"?np:Zd;continue;case hS:if(f=="/"&&l[a+1]=="/")i=mc,a++;else{i=Zd;continue}break;case vS:if(f=="/"){i=gc;break}else{i=Xn;continue}case Zd:if(n.scheme=t.scheme,f==gn)n.username=t.username,n.password=t.password,n.host=t.host,n.port=t.port,n.path=xn(t.path),n.query=t.query;else if(f=="/"||f=="\\"&&n.isSpecial())i=mS;else if(f=="?")n.username=t.username,n.password=t.password,n.host=t.host,n.port=t.port,n.path=xn(t.path),n.query="",i=Ga;else if(f=="#")n.username=t.username,n.password=t.password,n.host=t.host,n.port=t.port,n.path=xn(t.path),n.query=t.query,n.fragment="",i=_i;else{n.username=t.username,n.password=t.password,n.host=t.host,n.port=t.port,n.path=xn(t.path),n.path.length--,i=Xn;continue}break;case mS:if(n.isSpecial()&&(f=="/"||f=="\\"))i=mc;else if(f=="/")i=gc;else{n.username=t.username,n.password=t.password,n.host=t.host,n.port=t.port,i=Xn;continue}break;case gS:if(i=mc,f!="/"||Sn(s,a+1)!="/")continue;a++;break;case mc:if(f!="/"&&f!="\\"){i=gc;continue}break;case gc:if(f=="@"){c&&(s="%40"+s),c=!0,d=Es(s);for(var h=0;h<d.length;h++){var E=d[h];if(E==":"&&!u){u=!0;continue}var M=aa(E,Yd);u?n.password+=M:n.username+=M}s=""}else if(f==gn||f=="/"||f=="?"||f=="#"||f=="\\"&&n.isSpecial()){if(c&&s=="")return p9;a-=Es(s).length+1,s="",i=ep}else s+=f;break;case ep:case tp:if(r&&n.scheme=="file"){i=ip;continue}else if(f==":"&&!o){if(s=="")return qa;if(p=n.parseHost(s),p)return p;if(s="",i=rp,r==tp)return}else if(f==gn||f=="/"||f=="?"||f=="#"||f=="\\"&&n.isSpecial()){if(n.isSpecial()&&s=="")return qa;if(r&&s==""&&(n.includesCredentials()||n.port!==null))return;if(p=n.parseHost(s),p)return p;if(s="",i=ks,r)return;continue}else f=="["?o=!0:f=="]"&&(o=!1),s+=f;break;case rp:if(Fn(fh,f))s+=f;else if(f==gn||f=="/"||f=="?"||f=="#"||f=="\\"&&n.isSpecial()||r){if(s!=""){var I=ml(s,10);if(I>65535)return fS;n.port=n.isSpecial()&&I===vc[n.scheme]?null:I,s=""}if(r)return;i=ks;continue}else return fS;break;case np:if(n.scheme="file",f=="/"||f=="\\")i=yS;else if(t&&t.scheme=="file")if(f==gn)n.host=t.host,n.path=xn(t.path),n.query=t.query;else if(f=="?")n.host=t.host,n.path=xn(t.path),n.query="",i=Ga;else if(f=="#")n.host=t.host,n.path=xn(t.path),n.query=t.query,n.fragment="",i=_i;else{dS(Uo(xn(l,a),""))||(n.host=t.host,n.path=xn(t.path),n.shortenPath()),i=Xn;continue}else{i=Xn;continue}break;case yS:if(f=="/"||f=="\\"){i=ip;break}t&&t.scheme=="file"&&!dS(Uo(xn(l,a),""))&&(Bo(t.path[0],!0)?Os(n.path,t.path[0]):n.host=t.host),i=Xn;continue;case ip:if(f==gn||f=="/"||f=="\\"||f=="?"||f=="#"){if(!r&&Bo(s))i=Xn;else if(s==""){if(n.host="",r)return;i=ks}else{if(p=n.parseHost(s),p)return p;if(n.host=="localhost"&&(n.host=""),r)return;s="",i=ks}continue}else s+=f;break;case ks:if(n.isSpecial()){if(i=Xn,f!="/"&&f!="\\")continue}else if(!r&&f=="?")n.query="",i=Ga;else if(!r&&f=="#")n.fragment="",i=_i;else if(f!=gn&&(i=Xn,f!="/"))continue;break;case Xn:if(f==gn||f=="/"||f=="\\"&&n.isSpecial()||!r&&(f=="?"||f=="#")){if(R9(s)?(n.shortenPath(),f!="/"&&!(f=="\\"&&n.isSpecial())&&Os(n.path,"")):k9(s)?f!="/"&&!(f=="\\"&&n.isSpecial())&&Os(n.path,""):(n.scheme=="file"&&!n.path.length&&Bo(s)&&(n.host&&(n.host=""),s=Sn(s,0)+":"),Os(n.path,s)),s="",n.scheme=="file"&&(f==gn||f=="?"||f=="#"))for(;n.path.length>1&&n.path[0]==="";)l9(n.path);f=="?"?(n.query="",i=Ga):f=="#"&&(n.fragment="",i=_i)}else s+=aa(f,Bk);break;case bS:f=="?"?(n.query="",i=Ga):f=="#"?(n.fragment="",i=_i):f!=gn&&(n.path[0]+=aa(f,Wc));break;case Ga:!r&&f=="#"?(n.fragment="",i=_i):f!=gn&&(f=="'"&&n.isSpecial()?n.query+="%27":f=="#"?n.query+="%23":n.query+=aa(f,Wc));break;case _i:f!=gn&&(n.fragment+=aa(f,Uk));break}a++}},parseHost:function(e){var r,t,n;if(Sn(e,0)=="["){if(Sn(e,e.length-1)!="]"||(r=C9(Xo(e,1,-1)),!r))return qa;this.host=r}else if(this.isSpecial()){if(e=t9(e),Fn(y9,e)||(r=T9(e),r===null))return qa;this.host=r}else{if(Fn(b9,e))return qa;for(r="",t=Es(e),n=0;n<t.length;n++)r+=aa(t[n],Wc);this.host=r}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||this.scheme=="file"},includesCredentials:function(){return this.username!=""||this.password!=""},isSpecial:function(){return ch(vc,this.scheme)},shortenPath:function(){var e=this.path,r=e.length;r&&(this.scheme!="file"||r!=1||!Bo(e[0],!0))&&e.length--},serialize:function(){var e=this,r=e.scheme,t=e.username,n=e.password,i=e.host,a=e.port,s=e.path,c=e.query,o=e.fragment,u=r+":";return i!==null?(u+="//",e.includesCredentials()&&(u+=t+(n?":"+n:"")+"@"),u+=No(i),a!==null&&(u+=":"+a)):r=="file"&&(u+="//"),u+=e.cannotBeABaseURL?s[0]:s.length?"/"+Uo(s,"/"):"",c!==null&&(u+="?"+c),o!==null&&(u+="#"+o),u},setHref:function(e){var r=this.parse(e);if(r)throw lh(r);this.searchParams.update()},getOrigin:function(){var e=this.scheme,r=this.port;if(e=="blob")try{return new Zs(e.path[0]).origin}catch{return"null"}return e=="file"||!this.isSpecial()?"null":e+"://"+No(this.host)+(r!==null?":"+r:"")},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(wi(e)+":",Xd)},getUsername:function(){return this.username},setUsername:function(e){var r=Es(wi(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var t=0;t<r.length;t++)this.username+=aa(r[t],Yd)}},getPassword:function(){return this.password},setPassword:function(e){var r=Es(wi(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var t=0;t<r.length;t++)this.password+=aa(r[t],Yd)}},getHost:function(){var e=this.host,r=this.port;return e===null?"":r===null?No(e):No(e)+":"+r},setHost:function(e){this.cannotBeABaseURL||this.parse(e,ep)},getHostname:function(){var e=this.host;return e===null?"":No(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,tp)},getPort:function(){var e=this.port;return e===null?"":wi(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(e=wi(e),e==""?this.port=null:this.parse(e,rp))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+Uo(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,ks))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){e=wi(e),e==""?this.query=null:(Sn(e,0)=="?"&&(e=Xo(e,1)),this.query="",this.parse(e,Ga)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){if(e=wi(e),e==""){this.fragment=null;return}Sn(e,0)=="#"&&(e=Xo(e,1)),this.fragment="",this.parse(e,_i)},update:function(){this.query=this.searchParams.serialize()||null}};var Zs=function(r){var t=Z8(this,jr),n=n9(arguments.length,1)>1?arguments[1]:void 0,i=i9(t,new $m(r,!1,n));Em||(t.href=i.serialize(),t.origin=i.getOrigin(),t.protocol=i.getProtocol(),t.username=i.getUsername(),t.password=i.getPassword(),t.host=i.getHost(),t.hostname=i.getHostname(),t.port=i.getPort(),t.pathname=i.getPathname(),t.search=i.getSearch(),t.searchParams=i.getSearchParams(),t.hash=i.getHash())},jr=Zs.prototype,yn=function(e,r){return{get:function(){return vl(this)[e]()},set:r&&function(t){return vl(this)[r](t)},configurable:!0,enumerable:!0}};Em&&(mn(jr,"href",yn("serialize","setHref")),mn(jr,"origin",yn("getOrigin")),mn(jr,"protocol",yn("getProtocol","setProtocol")),mn(jr,"username",yn("getUsername","setUsername")),mn(jr,"password",yn("getPassword","setPassword")),mn(jr,"host",yn("getHost","setHost")),mn(jr,"hostname",yn("getHostname","setHostname")),mn(jr,"port",yn("getPort","setPort")),mn(jr,"pathname",yn("getPathname","setPathname")),mn(jr,"search",yn("getSearch","setSearch")),mn(jr,"searchParams",yn("getSearchParams")),mn(jr,"hash",yn("getHash","setHash")));hl(jr,"toJSON",function(){return vl(this).serialize()},{enumerable:!0});hl(jr,"toString",function(){return vl(this).serialize()},{enumerable:!0});if(xo){var _S=xo.createObjectURL,SS=xo.revokeObjectURL;_S&&hl(Zs,"createObjectURL",cS(_S,xo)),SS&&hl(Zs,"revokeObjectURL",cS(SS,xo))}r9(Zs,"URL");X8({global:!0,constructor:!0,forced:!Q8,sham:!Em},{URL:Zs});/*
|
|
304
|
+
@license
|
|
305
|
+
Copyright (c) 2018, Twilio, Inc.
|
|
306
|
+
|
|
307
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
308
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
309
|
+
copyright notice and this permission notice appear in all copies.
|
|
310
|
+
|
|
311
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
312
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
313
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
314
|
+
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
315
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
316
|
+
OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
317
|
+
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
318
|
+
|
|
319
|
+
*/(function(e){var r=typeof r<"u"?r:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(e,"__esModule",{value:!0});var t=di,n=wa,i=li,a=fi,s=$n,c=sf,o=us,u=Tu,l=Ru,f=Rn,d=pr,p=Wi,h=Tr;function E(ee){return ee&&typeof ee=="object"&&"default"in ee?ee:{default:ee}}function M(ee){if(ee&&ee.__esModule)return ee;var ve=Object.create(null);return ee&&Object.keys(ee).forEach(function(Q){if(Q!=="default"){var se=Object.getOwnPropertyDescriptor(ee,Q);Object.defineProperty(ve,Q,se.get?se:{enumerable:!0,get:function(){return ee[Q]}})}}),ve.default=ee,Object.freeze(ve)}var I=E(t),x=E(n),j=E(i),z=E(a),ie=E(s),oe=E(c),J=E(o),L=E(u),Y=E(l),Z=E(f),ye=M(d),Re={exports:{}},ae=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(ae){var Ve=new Uint8Array(16);Re.exports=function(){return ae(Ve),Ve}}else{var be=new Array(16);Re.exports=function(){for(var ve=0,Q;ve<16;ve++)ve&3||(Q=Math.random()*4294967296),be[ve]=Q>>>((ve&3)<<3)&255;return be}}for(var Te=[],we=0;we<256;++we)Te[we]=(we+256).toString(16).substr(1);function ge(ee,ve){var Q=ve||0,se=Te;return[se[ee[Q++]],se[ee[Q++]],se[ee[Q++]],se[ee[Q++]],"-",se[ee[Q++]],se[ee[Q++]],"-",se[ee[Q++]],se[ee[Q++]],"-",se[ee[Q++]],se[ee[Q++]],"-",se[ee[Q++]],se[ee[Q++]],se[ee[Q++]],se[ee[Q++]],se[ee[Q++]],se[ee[Q++]]].join("")}var $e=ge,De=Re.exports,G=$e,Qe,Et,ut=0,je=0;function te(ee,ve,Q){var se=ve&&Q||0,X=ve||[];ee=ee||{};var Ue=ee.node||Qe,Oe=ee.clockseq!==void 0?ee.clockseq:Et;if(Ue==null||Oe==null){var Ze=De();Ue==null&&(Ue=Qe=[Ze[0]|1,Ze[1],Ze[2],Ze[3],Ze[4],Ze[5]]),Oe==null&&(Oe=Et=(Ze[6]<<8|Ze[7])&16383)}var Ke=ee.msecs!==void 0?ee.msecs:new Date().getTime(),Je=ee.nsecs!==void 0?ee.nsecs:je+1,rt=Ke-ut+(Je-je)/1e4;if(rt<0&&ee.clockseq===void 0&&(Oe=Oe+1&16383),(rt<0||Ke>ut)&&ee.nsecs===void 0&&(Je=0),Je>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");ut=Ke,je=Je,Et=Oe,Ke+=122192928e5;var nt=((Ke&268435455)*1e4+Je)%4294967296;X[se++]=nt>>>24&255,X[se++]=nt>>>16&255,X[se++]=nt>>>8&255,X[se++]=nt&255;var Ye=Ke/4294967296*1e4&268435455;X[se++]=Ye>>>8&255,X[se++]=Ye&255,X[se++]=Ye>>>24&15|16,X[se++]=Ye>>>16&255,X[se++]=Oe>>>8|128,X[se++]=Oe&255;for(var tt=0;tt<6;++tt)X[se+tt]=Ue[tt];return ve||G(X)}var ur=te,Me=Re.exports,fe=$e;function Pt(ee,ve,Q){var se=ve&&Q||0;typeof ee=="string"&&(ve=ee==="binary"?new Array(16):null,ee=null),ee=ee||{};var X=ee.random||(ee.rng||Me)();if(X[6]=X[6]&15|64,X[8]=X[8]&63|128,ve)for(var Ue=0;Ue<16;++Ue)ve[se+Ue]=X[Ue];return ve||fe(X)}var We=Pt,Kt=ur,gt=We,xe=gt;xe.v1=Kt,xe.v4=gt;var ft=xe;function Tt(ee){var ve=Le();return function(){var se=ie.default(ee),X;if(ve){var Ue=ie.default(this).constructor;X=Reflect.construct(se,arguments,Ue)}else X=se.apply(this,arguments);return z.default(this,X)}}function Le(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Jt=function(ee){j.default(Q,ee);var ve=Tt(Q);function Q(se){var X;I.default(this,Q);var Ue=ft.v4(),Oe;return X=ve.call(this,function(Ze,Ke){return Oe=Ke,se(function(Je){Q.cancellationMap.delete(Ue),Ze(Je)},function(Je){Q.cancellationMap.delete(Ue),Ke(Je)},function(Je){Q.cancellationMap.set(Ue,Je)})}),X.id=Ue,X.rejectPromise=Oe,X}return x.default(Q,[{key:"cancel",value:function(){var X=Q.cancellationMap.get(this.id);return X==null||X(),this.rejectPromise&&(this.catch(function(){}),this.rejectPromise(new Error("Promise was cancelled"))),this}}]),Q}(oe.default(Promise));J.default(Jt,"cancellationMap",new Map);function vt(ee,ve,Q,se){var X=arguments.length,Ue=X<3?ve:se===null?se=Object.getOwnPropertyDescriptor(ve,Q):se,Oe;if((typeof Reflect>"u"?"undefined":Z.default(Reflect))==="object"&&typeof Reflect.decorate=="function")Ue=Reflect.decorate(ee,ve,Q,se);else for(var Ze=ee.length-1;Ze>=0;Ze--)(Oe=ee[Ze])&&(Ue=(X<3?Oe(Ue):X>3?Oe(ve,Q,Ue):Oe(ve,Q))||Ue);return X>3&&Ue&&Object.defineProperty(ve,Q,Ue),Ue}function zt(ee,ve){if((typeof Reflect>"u"?"undefined":Z.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(ee,ve)}function nr(ee,ve){return["".concat(new Date().toISOString()," MCS Client ").concat(ee,":")].concat(Array.from(ve))}var He=function(){function ee(ve){I.default(this,ee),J.default(this,"prefix",""),this.prefix=ve!=null&&ve.length>0?ve+" ":""}return x.default(ee,[{key:"setLevel",value:function(Q){ye.setLevel(Q)}},{key:"trace",value:function(){for(var Q=arguments.length,se=new Array(Q),X=0;X<Q;X++)se[X]=arguments[X];ye.trace.apply(null,nr(this.prefix+"T",se))}},{key:"debug",value:function(){for(var Q=arguments.length,se=new Array(Q),X=0;X<Q;X++)se[X]=arguments[X];ye.debug.apply(null,nr(this.prefix+"D",se))}},{key:"info",value:function(){for(var Q=arguments.length,se=new Array(Q),X=0;X<Q;X++)se[X]=arguments[X];ye.info.apply(null,nr(this.prefix+"I",se))}},{key:"warn",value:function(){for(var Q=arguments.length,se=new Array(Q),X=0;X<Q;X++)se[X]=arguments[X];ye.warn.apply(null,nr(this.prefix+"W",se))}},{key:"error",value:function(){for(var Q=arguments.length,se=new Array(Q),X=0;X<Q;X++)se[X]=arguments[X];ye.error.apply(null,nr(this.prefix+"E",se))}}],[{key:"scope",value:function(Q){return new ee(Q)}},{key:"setLevel",value:function(Q){ye.setLevel(Q)}},{key:"trace",value:function(){for(var Q=arguments.length,se=new Array(Q),X=0;X<Q;X++)se[X]=arguments[X];ye.trace.apply(null,nr("T",se))}},{key:"debug",value:function(){for(var Q=arguments.length,se=new Array(Q),X=0;X<Q;X++)se[X]=arguments[X];ye.debug.apply(null,nr("D",se))}},{key:"info",value:function(){for(var Q=arguments.length,se=new Array(Q),X=0;X<Q;X++)se[X]=arguments[X];ye.info.apply(null,nr("I",se))}},{key:"warn",value:function(){for(var Q=arguments.length,se=new Array(Q),X=0;X<Q;X++)se[X]=arguments[X];ye.warn.apply(null,nr("W",se))}},{key:"error",value:function(){for(var Q=arguments.length,se=new Array(Q),X=0;X<Q;X++)se[X]=arguments[X];ye.error.apply(null,nr("E",se))}}]),ee}(),Pr=1e3,Cr=4e3,Ct=3,kt=!0,yt=function(ve){return"https://mcs.".concat(ve??"us1",".twilio.com")},st=function(ve){return ve.startsWith("http")},Lt=function(ve,Q){return"".concat(st(ve)?"":yt(Q)).concat(ve)},Xt=function(){function ee(ve,Q,se,X){var Ue,Oe,Ze,Ke,Je,rt;I.default(this,ee);var nt=(Ue=(Oe=X.MCS)!==null&&Oe!==void 0?Oe:X)!==null&&Ue!==void 0?Ue:{};this.region=(Ze=(Ke=nt.region)!==null&&Ke!==void 0?Ke:X.region)!==null&&Ze!==void 0?Ze:"us1",this.mediaUrl=Lt(Q,this.region),this.mediaSetUrl=se?Lt(se):"".concat(this.mediaUrl,"Set"),this.token=ve,this.retryWhenThrottledOverride=(Je=nt.retryWhenThrottledOverride)!==null&&Je!==void 0?Je:kt,this.backoffConfigOverride=(rt=nt.backoffConfigOverride)!==null&&rt!==void 0?rt:ee.backoffConfigDefault}return x.default(ee,[{key:"updateToken",value:function(Q){this.token=Q}}],[{key:"backoffConfigDefault",get:function(){return{min:Pr,max:Cr,maxAttemptsCount:Ct}}},{key:"retryWhenThrottledDefault",get:function(){return kt}}]),ee}(),hr=function(){function ee(ve,Q,se){I.default(this,ee),this.config=ve,this.network=Q,this._update(se)}return x.default(ee,[{key:"sid",get:function(){return this.state.sid}},{key:"serviceSid",get:function(){return this.state.serviceSid}},{key:"dateCreated",get:function(){return this.state.dateCreated}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"contentType",get:function(){return this.state.contentType}},{key:"size",get:function(){return this.state.size}},{key:"fileName",get:function(){return this.state.filename}},{key:"filename",get:function(){return this.state.filename}},{key:"category",get:function(){return this.state.category}},{key:"getContentUrl",value:function(){var Q=this;return new Jt(function(){var se=L.default(Y.default.mark(function X(Ue,Oe,Ze){var Ke,Je;return Y.default.wrap(function(nt){for(;;)switch(nt.prev=nt.next){case 0:return Ke=Q.network.get("".concat(Q.config.mediaUrl,"/").concat(Q.sid)),Ze(function(){return Ke.cancel()}),nt.prev=2,nt.next=5,Ke;case 5:Je=nt.sent,Q._update(Je.body),Ue(Q.state.contentDirectUrl),nt.next=13;break;case 10:nt.prev=10,nt.t0=nt.catch(2),Oe(nt.t0);case 13:case"end":return nt.stop()}},X,null,[[2,10]])}));return function(X,Ue,Oe){return se.apply(this,arguments)}}())}},{key:"_update",value:function(Q){var se,X,Ue,Oe;this.state={sid:Q.sid,serviceSid:Q.service_sid,channelSid:Q.channel_sid,messageSid:Q.message_sid,dateCreated:Q.date_created?new Date(Q.date_created):null,dateUploadUpdated:Q.date_upload_updated?new Date(Q.date_upload_updated):null,dateUpdated:Q.date_updated?new Date(Q.date_updated):null,size:Q.size,contentType:Q.content_type,author:Q.author,url:Q.url,contentUrl:Q.links.content,contentDirectUrl:(se=Q.links.content_direct_temporary)!==null&&se!==void 0?se:null,filename:(X=Q.filename)!==null&&X!==void 0?X:null,category:(Ue=Q.category)!==null&&Ue!==void 0?Ue:"media",isMultipartUpstream:(Oe=Q.is_multipart_upstream)!==null&&Oe!==void 0?Oe:!1}}}]),ee}();function hn(ee){var ve=Pn();return function(){var se=ie.default(ee),X;if(ve){var Ue=ie.default(this).constructor;X=Reflect.construct(se,arguments,Ue)}else X=se.apply(this,arguments);return z.default(this,X)}}function Pn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var _r=function(ee){j.default(Q,ee);var ve=hn(Q);function Q(se,X,Ue,Oe,Ze){var Ke;return I.default(this,Q),Ke=ve.call(this,se),Ke.code=X,Ke.body=Ue,Ke.status=Oe,Ke.headers=Ze,Ke}return x.default(Q)}(oe.default(Error)),Wt=r.XMLHttpRequest||{};function Nr(ee){return ee?ee.split(`\r
|
|
320
|
+
`).map(function(ve){return ve.split(": ")}).filter(function(ve){return ve.length===2&&ve[1].length>0}).reduce(function(ve,Q){return ve[Q[0]]=Q[1],ve},{}):{}}function _e(ee){var ve=ee.getResponseHeader("Content-Type");if(!ve||ve.indexOf("application/json")!==0||ee.responseText.length===0)return ee.responseText;try{return JSON.parse(ee.responseText)}catch{return ee.responseText}}var Ce=function(){function ee(){I.default(this,ee)}return x.default(ee,[{key:"get",value:function(Q,se){return ee.request("GET",Q,se)}},{key:"post",value:function(Q,se,X){return ee.request("POST",Q,se,X)}}],[{key:"request",value:function(Q,se,X,Ue){return new Jt(function(Oe,Ze,Ke){var Je=new Wt,rt=!1;Ke(function(){Je.abort(),rt=!0}),Je.open(Q,se,!0),Je.onreadystatechange=function(){if(!(Je.readyState!==4||rt)){var tt=Nr(Je.getAllResponseHeaders()),it=_e(Je);if(200<=Je.status&&Je.status<300)Oe({status:Je.status,headers:tt,body:it});else{var ct,Sr=(ct=Je.statusText)!==null&&ct!==void 0?ct:"NONE",cr;if(typeof it=="string")if(it&&it.split(`
|
|
321
|
+
`,2).length===1)cr=it;else{var ot,Hr=(ot=it.replace(/<.*?>/g,"").split(/\r\n/g).filter(function(Wn){return Wn.length})[0])===null||ot===void 0?void 0:ot.split(" ");cr=(Hr==null?void 0:Hr.length)>2?Hr==null?void 0:Hr.slice(1).join(" "):""}else cr=JSON.stringify(it);var ir="".concat(Je.status,": [").concat(Sr,"] ").concat(cr);Ze(new _r(ir,Je.status,it,Sr,tt))}}};for(var nt in X)Je.setRequestHeader(nt,X[nt]),nt==="Content-Type"&&X[nt]==="application/json"&&(Ue=JSON.stringify(Ue));Je.send(Ue)})}}]),ee}(),ce=He.scope("Network"),de=function(){function ee(ve,Q){I.default(this,ee),this.config=ve,this.transport=Q}return x.default(ee,[{key:"backoffConfig",value:function(){return Object.assign(Xt.backoffConfigDefault,this.config.backoffConfigOverride)}},{key:"retryWhenThrottled",value:function(){var Q,se;return(Q=(se=this.config.retryWhenThrottledOverride)!==null&&se!==void 0?se:Xt.retryWhenThrottledDefault)!==null&&Q!==void 0?Q:!1}},{key:"executeWithRetry",value:function(Q,se){var X=this;return new Jt(function(){var Ue=L.default(Y.default.mark(function Oe(Ze,Ke,Je){var rt,nt;return Y.default.wrap(function(tt){for(;;)switch(tt.prev=tt.next){case 0:rt=new p.Retrier(X.backoffConfig()),nt=[502,503,504],se&&nt.push(429),Je(function(){rt.cancel(),rt.removeAllListeners()}),rt.on("attempt",L.default(Y.default.mark(function it(){var ct,Sr;return Y.default.wrap(function(ot){for(;;)switch(ot.prev=ot.next){case 0:return ot.prev=0,ct=Q(),Je(function(){ct.cancel(),rt.cancel(),rt.removeAllListeners()}),ot.next=5,ct;case 5:Sr=ot.sent,rt.succeeded(Sr),ot.next=12;break;case 9:ot.prev=9,ot.t0=ot.catch(0),nt.indexOf(ot.t0.status)>-1||ot.t0.message==="Twilsock disconnected"?rt.failed(ot.t0):(rt.removeAllListeners(),rt.cancel(),Ke(ot.t0));case 12:case"end":return ot.stop()}},it,null,[[0,9]])}))),rt.on("succeeded",function(it){Ze(it)}),rt.on("cancelled",function(it){return Ke(it)}),rt.on("failed",function(it){return Ke(it)}),rt.start();case 9:case"end":return tt.stop()}},Oe)}));return function(Oe,Ze,Ke){return Ue.apply(this,arguments)}}())}},{key:"get",value:function(Q){var se=this;return new Jt(function(){var X=L.default(Y.default.mark(function Ue(Oe,Ze,Ke){var Je,rt,nt;return Y.default.wrap(function(tt){for(;;)switch(tt.prev=tt.next){case 0:return Je={"X-Twilio-Token":se.config.token},rt=se.executeWithRetry(function(){return se.transport.get(Q,Je)},se.retryWhenThrottled()),ce.trace("sending GET request to ",Q," headers ",Je),Ke(function(){return rt.cancel()}),tt.prev=4,tt.next=7,rt;case 7:nt=tt.sent,ce.trace("response",nt),Oe(nt),tt.next=16;break;case 12:tt.prev=12,tt.t0=tt.catch(4),ce.debug("get() error ".concat(tt.t0)),Ze(tt.t0);case 16:case"end":return tt.stop()}},Ue,null,[[4,12]])}));return function(Ue,Oe,Ze){return X.apply(this,arguments)}}())}},{key:"post",value:function(Q,se,X,Ue,Oe){var Ze=this,Ke={"X-Twilio-Token":this.config.token};(typeof FormData>"u"||!(X instanceof FormData))&&Ue&&Object.assign(Ke,{"Content-Type":Ue});var Je=new URL(Q);return se&&Je.searchParams.append("Category",se),Oe&&Je.searchParams.append("Filename",Oe),new Jt(function(){var rt=L.default(Y.default.mark(function nt(Ye,tt,it){var ct,Sr;return Y.default.wrap(function(ot){for(;;)switch(ot.prev=ot.next){case 0:return ct=Ze.transport.post(Je.href,Ke,X),it(function(){return ct.cancel()}),ce.trace("sending POST request to ".concat(Q," with headers ").concat(Ke)),ot.prev=3,ot.next=6,ct;case 6:Sr=ot.sent,ot.next=17;break;case 9:if(ot.prev=9,ot.t0=ot.catch(3),!(r.XMLHttpRequest===void 0&&X instanceof FormData)){ot.next=14;break}return tt(new TypeError("Posting FormData supported only with browser engine's FormData")),ot.abrupt("return");case 14:return ce.debug("post() error ".concat(ot.t0)),tt(ot.t0),ot.abrupt("return");case 17:ce.trace("response",Sr),Ye(Sr);case 19:case"end":return ot.stop()}},nt,null,[[3,9]])}));return function(nt,Ye,tt){return rt.apply(this,arguments)}}())}}]),ee}(),le="0.6.5",ke,Ie=He.scope("");e.default=(ke=function(){function ee(ve,Q,se){var X,Ue,Oe=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};I.default(this,ee),this.options=Oe,this.options.logLevel=(X=this.options.logLevel)!==null&&X!==void 0?X:"silent",this.config=new Xt(ve,Q,se,this.options),Ie.setLevel(this.options.logLevel),this.options.transport=(Ue=this.options.transport)!==null&&Ue!==void 0?Ue:new Ce,this.transport=this.options.transport,this.network=new de(this.config,this.transport)}return x.default(ee,[{key:"updateToken",value:function(Q){Ie.info("updateToken"),this.config.updateToken(Q)}},{key:"get",value:function(Q){var se=this;return new Jt(function(){var X=L.default(Y.default.mark(function Ue(Oe,Ze,Ke){var Je,rt;return Y.default.wrap(function(Ye){for(;;)switch(Ye.prev=Ye.next){case 0:return Je=se.network.get("".concat(se.config.mediaUrl,"/").concat(Q)),Ke(function(){return Je.cancel()}),Ye.prev=2,Ye.next=5,Je;case 5:rt=Ye.sent,Oe(new hr(se.config,se.network,rt.body)),Ye.next=12;break;case 9:Ye.prev=9,Ye.t0=Ye.catch(2),Ze(Ye.t0);case 12:case"end":return Ye.stop()}},Ue,null,[[2,9]])}));return function(Ue,Oe,Ze){return X.apply(this,arguments)}}())}},{key:"post",value:function(Q,se,X,Ue){var Oe=this;return new Jt(function(){var Ze=L.default(Y.default.mark(function Ke(Je,rt,nt){var Ye,tt;return Y.default.wrap(function(ct){for(;;)switch(ct.prev=ct.next){case 0:return Ye=Oe.network.post(Oe.config.mediaUrl,X??"media",se,Q,Ue),nt(function(){return Ye.cancel()}),ct.prev=2,ct.next=5,Ye;case 5:tt=ct.sent,Je(new hr(Oe.config,Oe.network,tt.body)),ct.next=12;break;case 9:ct.prev=9,ct.t0=ct.catch(2),rt(ct.t0);case 12:case"end":return ct.stop()}},Ke,null,[[2,9]])}));return function(Ke,Je,rt){return Ze.apply(this,arguments)}}())}},{key:"postFormData",value:function(Q,se){var X=this;return new Jt(function(){var Ue=L.default(Y.default.mark(function Oe(Ze,Ke,Je){var rt,nt;return Y.default.wrap(function(tt){for(;;)switch(tt.prev=tt.next){case 0:return rt=X.network.post(X.config.mediaUrl,se??"media",Q),Je(function(){return rt.cancel()}),tt.prev=2,tt.next=5,rt;case 5:nt=tt.sent,Ze(new hr(X.config,X.network,nt.body)),tt.next=12;break;case 9:tt.prev=9,tt.t0=tt.catch(2),Ke(tt.t0);case 12:case"end":return tt.stop()}},Oe,null,[[2,9]])}));return function(Oe,Ze,Ke){return Ue.apply(this,arguments)}}())}},{key:"mediaSetGet",value:function(Q){var se=this;return new Jt(function(){var X=L.default(Y.default.mark(function Ue(Oe,Ze,Ke){var Je,rt,nt,Ye;return Y.default.wrap(function(it){for(;;)switch(it.prev=it.next){case 0:return Je={command:"get",list:Q.map(function(ct){return{media_sid:ct}})},rt=se.network.post("".concat(se.config.mediaSetUrl),null,Je,"application/json"),Ke(function(){return rt.cancel()}),it.prev=3,it.next=6,rt;case 6:nt=it.sent,Ye=nt.body.map(function(ct){if(ct.code!==200){Ze("Failed to obtain detailed information about Media items (failed SID ".concat(ct.media_record.sid,")"));return}return new hr(se.config,se.network,ct.media_record)}),Oe(Ye),it.next=14;break;case 11:it.prev=11,it.t0=it.catch(3),Ze(it.t0);case 14:case"end":return it.stop()}},Ue,null,[[3,11]])}));return function(Ue,Oe,Ze){return X.apply(this,arguments)}}())}},{key:"mediaSetGetContentUrls",value:function(Q){var se=this;return new Jt(function(){var X=L.default(Y.default.mark(function Ue(Oe,Ze,Ke){var Je,rt,nt,Ye;return Y.default.wrap(function(it){for(;;)switch(it.prev=it.next){case 0:return Je={command:"get",list:Q.map(function(ct){return{media_sid:ct}})},rt=se.network.post("".concat(se.config.mediaSetUrl),null,Je,"application/json"),Ke(function(){return rt.cancel()}),it.prev=3,it.next=6,rt;case 6:nt=it.sent,Ye=new Map,nt.body.forEach(function(ct){if(ct.code!==200){Ze("Failed to obtain detailed information about Media items (failed SID ".concat(ct.media_record.sid,")"));return}Ye.set(ct.media_record.sid,ct.media_record.links.content_direct_temporary)}),Oe(Ye),it.next=15;break;case 12:it.prev=12,it.t0=it.catch(3),Ze(it.t0);case 15:case"end":return it.stop()}},Ue,null,[[3,12]])}));return function(Ue,Oe,Ze){return X.apply(this,arguments)}}())}}]),ee}(),J.default(ke,"version",le),ke),vt([h.validateTypes(h.nonEmptyString),zt("design:type",Function),zt("design:paramtypes",[String]),zt("design:returntype",void 0)],e.default.prototype,"updateToken",null),vt([h.validateTypesAsync(h.nonEmptyString),zt("design:type",Function),zt("design:paramtypes",[String]),zt("design:returntype",Jt)],e.default.prototype,"get",null),e.default=vt([h.validateConstructorTypes(h.nonEmptyString,h.nonEmptyString,[h.nonEmptyString,h.literal(null)],[h.pureObject,"undefined"]),zt("design:paramtypes",[String,String,Object,Object])],e.default),e.CancellablePromise=Jt,e.Client=e.default,e.McsClient=e.default,e.McsMedia=hr,e.Media=hr})(bk);var qk=Ht,$9=Ir,O9=ui,I9=qk.aTypedArray,P9=qk.exportTypedArrayMethod;P9("at",function(r){var t=I9(this),n=$9(t),i=O9(r),a=i>=0?i:n+i;return a<0||a>=n?void 0:t[a]});var A9=St,M9=Rt,x9=eE,N9=Al,Om="ArrayBuffer",wS=x9[Om],L9=M9[Om];A9({global:!0,constructor:!0,forced:L9!==wS},{ArrayBuffer:wS});N9(Om);var D9=St,Gk=_t,j9=En,F9=xr,TS=Ir,U9=om,CS=br,Im=mt,B9=pm,q9=jl,ES=jE,G9=FE,kS=no,RS=UE,ca=[],$S=Gk(ca.sort),z9=Gk(ca.push),W9=Im(function(){ca.sort(void 0)}),V9=Im(function(){ca.sort(null)}),H9=q9("sort"),zk=!Im(function(){if(kS)return kS<70;if(!(ES&&ES>3)){if(G9)return!0;if(RS)return RS<603;var e="",r,t,n,i;for(r=65;r<76;r++){switch(t=String.fromCharCode(r),r){case 66:case 69:case 70:case 72:n=3;break;case 68:case 71:n=4;break;default:n=2}for(i=0;i<47;i++)ca.push({k:t+i,v:n})}for(ca.sort(function(a,s){return s.v-a.v}),i=0;i<ca.length;i++)t=ca[i].k.charAt(0),e.charAt(e.length-1)!==t&&(e+=t);return e!=="DGBEFHACIJK"}}),K9=W9||!V9||!H9||!zk,J9=function(e){return function(r,t){return t===void 0?-1:r===void 0?1:e!==void 0?+e(r,t)||0:CS(r)>CS(t)?1:-1}};D9({target:"Array",proto:!0,forced:K9},{sort:function(r){r!==void 0&&j9(r);var t=F9(this);if(zk)return r===void 0?$S(t):$S(t,r);var n=[],i=TS(t),a,s;for(s=0;s<i;s++)s in t&&z9(n,t[s]);for(B9(n,J9(r)),a=TS(n),s=0;s<a;)t[s]=n[s++];for(;s<i;)U9(t,s++);return t}});var Y9=St,X9=_t,Q9=_k,Z9=oi,OS=br,e7=Sk,t7=X9("".indexOf);Y9({target:"String",proto:!0,forced:!e7("includes")},{includes:function(r){return!!~t7(OS(Z9(this)),OS(Q9(r)),arguments.length>1?arguments[1]:void 0)}});var cf={},Wk={exports:{}};(function(e){(function(r,t){e.exports?e.exports=t():r.log=t()})(ze,function(){var r=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"];function a(E,M){var I=E[M];if(typeof I.bind=="function")return I.bind(E);try{return Function.prototype.bind.call(I,E)}catch{return function(){return Function.prototype.apply.apply(I,[E,arguments])}}}function s(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(E){return E==="debug"&&(E="log"),typeof console===t?!1:E==="trace"&&n?s:console[E]!==void 0?a(console,E):console.log!==void 0?a(console,"log"):r}function o(E,M){for(var I=0;I<i.length;I++){var x=i[I];this[x]=I<E?r:this.methodFactory(x,E,M)}this.log=this.debug}function u(E,M,I){return function(){typeof console!==t&&(o.call(this,M,I),this[E].apply(this,arguments))}}function l(E,M,I){return c(E)||u.apply(this,arguments)}function f(E,M,I){var x=this,j;M=M??"WARN";var z="loglevel";typeof E=="string"?z+=":"+E:typeof E=="symbol"&&(z=void 0);function ie(Y){var Z=(i[Y]||"silent").toUpperCase();if(!(typeof window===t||!z)){try{window.localStorage[z]=Z;return}catch{}try{window.document.cookie=encodeURIComponent(z)+"="+Z+";"}catch{}}}function oe(){var Y;if(!(typeof window===t||!z)){try{Y=window.localStorage[z]}catch{}if(typeof Y===t)try{var Z=window.document.cookie,ye=Z.indexOf(encodeURIComponent(z)+"=");ye!==-1&&(Y=/^([^;]+)/.exec(Z.slice(ye))[1])}catch{}return x.levels[Y]===void 0&&(Y=void 0),Y}}function J(){if(!(typeof window===t||!z)){try{window.localStorage.removeItem(z);return}catch{}try{window.document.cookie=encodeURIComponent(z)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}x.name=E,x.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},x.methodFactory=I||l,x.getLevel=function(){return j},x.setLevel=function(Y,Z){if(typeof Y=="string"&&x.levels[Y.toUpperCase()]!==void 0&&(Y=x.levels[Y.toUpperCase()]),typeof Y=="number"&&Y>=0&&Y<=x.levels.SILENT){if(j=Y,Z!==!1&&ie(Y),o.call(x,Y,E),typeof console===t&&Y<x.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+Y},x.setDefaultLevel=function(Y){M=Y,oe()||x.setLevel(Y,!1)},x.resetLevel=function(){x.setLevel(M,!1),J()},x.enableAll=function(Y){x.setLevel(x.levels.TRACE,Y)},x.disableAll=function(Y){x.setLevel(x.levels.SILENT,Y)};var L=oe();L==null&&(L=M),x.setLevel(L,!1)}var d=new f,p={};d.getLogger=function(M){if(typeof M!="symbol"&&typeof M!="string"||M==="")throw new TypeError("You must supply a name when creating a logger.");var I=p[M];return I||(I=p[M]=new f(M,d.getLevel(),d.methodFactory)),I};var h=typeof window!==t?window.log:void 0;return d.noConflict=function(){return typeof window!==t&&window.log===d&&(window.log=h),d},d.getLoggers=function(){return p},d.default=d,d})})(Wk);var r7=Wk.exports;/*
|
|
322
|
+
@license
|
|
323
|
+
Copyright (c) 2022 Twilio Inc.
|
|
324
|
+
|
|
325
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
326
|
+
|
|
327
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
328
|
+
|
|
329
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
*/Object.defineProperty(cf,"__esModule",{value:!0});var n7=r7;function i7(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var yc=i7(n7),a7=function(r,t,n){return function(i,a,s){if(typeof s.value!="function"&&(s==null?void 0:s.get)===void 0)throw new Error("The deprecated decorator can only be applied to methods or getters");if(typeof s.value=="function"){var c=s.value;s.value=function(){dh("The method ".concat(r," is deprecated").concat(t?", use "+t+" instead":"").concat(n?", "+n:"."));for(var u=arguments.length,l=new Array(u),f=0;f<u;f++)l[f]=arguments[f];return c.apply(this,l)};return}var o=s.get;s.get=function(){return dh("The getter ".concat(r," is deprecated").concat(t?", use "+t+" instead":"").concat(n?", "+n:".")),o==null?void 0:o.apply(this)}}},dh=function(r){var t=yc.default.getLevel();yc.default.setLevel("warn"),yc.default.warn(r),yc.default.setLevel(t)};cf.deprecated=a7;cf.deprecationWarning=dh;var s7=St,o7=fn.find,u7=Ov,ph="find",Vk=!0;ph in[]&&Array(1)[ph](function(){Vk=!1});s7({target:"Array",proto:!0,forced:Vk},{find:function(r){return o7(this,r,arguments.length>1?arguments[1]:void 0)}});u7(ph);var c7=St,l7=T0,f7=mt,d7=tr,p7=Wv.onFreeze,hh=Object.freeze,h7=f7(function(){hh(1)});c7({target:"Object",stat:!0,forced:h7,sham:!l7},{freeze:function(r){return hh&&d7(r)?hh(p7(r)):r}});/*
|
|
333
|
+
@license
|
|
334
|
+
The following license applies to all parts of this software except as
|
|
335
|
+
documented below.
|
|
336
|
+
|
|
337
|
+
Copyright (c) 2019, Twilio, inc.
|
|
338
|
+
All rights reserved.
|
|
339
|
+
|
|
340
|
+
Redistribution and use in source and binary forms, with or without
|
|
341
|
+
modification, are permitted provided that the following conditions are
|
|
342
|
+
met:
|
|
343
|
+
|
|
344
|
+
1. Redistributions of source code must retain the above copyright
|
|
345
|
+
notice, this list of conditions and the following disclaimer.
|
|
346
|
+
|
|
347
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
348
|
+
notice, this list of conditions and the following disclaimer in
|
|
349
|
+
the documentation and/or other materials provided with the
|
|
350
|
+
distribution.
|
|
351
|
+
|
|
352
|
+
3. Neither the name of Twilio nor the names of its contributors may
|
|
353
|
+
be used to endorse or promote products derived from this software
|
|
354
|
+
without specific prior written permission.
|
|
355
|
+
|
|
356
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
357
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
358
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
359
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
360
|
+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
361
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
362
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
363
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
364
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
365
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
366
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
367
|
+
|
|
368
|
+
This software includes javascript-state-machine under the following license.
|
|
369
|
+
|
|
370
|
+
Copyright (c) 2012, 2013, 2014, 2015, Jake Gordon and contributors
|
|
371
|
+
|
|
372
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
373
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
374
|
+
in the Software without restriction, including without limitation the rights
|
|
375
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
376
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
377
|
+
furnished to do so, subject to the following conditions:
|
|
378
|
+
|
|
379
|
+
The above copyright notice and this permission notice shall be included in all
|
|
380
|
+
copies or substantial portions of the Software.
|
|
381
|
+
|
|
382
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
383
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
384
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
385
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
386
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
387
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
388
|
+
|
|
389
|
+
This software includes loglevel under the following license.
|
|
390
|
+
|
|
391
|
+
Copyright (c) 2013 Tim Perry
|
|
392
|
+
|
|
393
|
+
Permission is hereby granted, free of charge, to any person
|
|
394
|
+
obtaining a copy of this software and associated documentation
|
|
395
|
+
files (the "Software"), to deal in the Software without
|
|
396
|
+
restriction, including without limitation the rights to use,
|
|
397
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
398
|
+
copies of the Software, and to permit persons to whom the
|
|
399
|
+
Software is furnished to do so, subject to the following
|
|
400
|
+
conditions:
|
|
401
|
+
|
|
402
|
+
The above copyright notice and this permission notice shall be
|
|
403
|
+
included in all copies or substantial portions of the Software.
|
|
404
|
+
|
|
405
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
406
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
407
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
408
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
409
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
410
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
411
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
412
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
413
|
+
|
|
414
|
+
This software includes q under the following license.
|
|
415
|
+
|
|
416
|
+
Copyright 2009–2014 Kristopher Michael Kowal. All rights reserved.
|
|
417
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
418
|
+
of this software and associated documentation files (the "Software"), to
|
|
419
|
+
deal in the Software without restriction, including without limitation the
|
|
420
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
421
|
+
sell copies of the Software, and to permit persons to whom the Software is
|
|
422
|
+
furnished to do so, subject to the following conditions:
|
|
423
|
+
|
|
424
|
+
The above copyright notice and this permission notice shall be included in
|
|
425
|
+
all copies or substantial portions of the Software.
|
|
426
|
+
|
|
427
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
428
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
429
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
430
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
431
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
432
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
433
|
+
IN THE SOFTWARE.
|
|
434
|
+
|
|
435
|
+
This software includes platform.js under the following license.
|
|
436
|
+
|
|
437
|
+
Copyright 2014 Benjamin Tan <https://d10.github.io/>
|
|
438
|
+
Copyright 2011-2015 John-David Dalton <http://allyoucanleet.com/>
|
|
439
|
+
|
|
440
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
441
|
+
a copy of this software and associated documentation files (the
|
|
442
|
+
"Software"), to deal in the Software without restriction, including
|
|
443
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
444
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
445
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
446
|
+
the following conditions:
|
|
447
|
+
|
|
448
|
+
The above copyright notice and this permission notice shall be
|
|
449
|
+
included in all copies or substantial portions of the Software.
|
|
450
|
+
|
|
451
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
452
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
453
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
454
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
455
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
456
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
457
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
458
|
+
|
|
459
|
+
*/(function(e){var r=typeof r<"u"?r:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(e,"__esModule",{value:!0});var t=Tu,n=os,i=li,a=fi,s=$n,c=us,o=wa,u=di,l=Ru,f=Rn,d=pr,p=u2,h=Tr,E=po,M=Uv,I=E3,x=fo,j=Wi,z=Yl,ie=QE,oe=tn,J=bk,L=cf,Y=sf,Z=ou;function ye(w){return w&&typeof w=="object"&&"default"in w?w:{default:w}}function Re(w){if(w&&w.__esModule)return w;var k=Object.create(null);return w&&Object.keys(w).forEach(function(S){if(S!=="default"){var m=Object.getOwnPropertyDescriptor(w,S);Object.defineProperty(k,S,m.get?m:{enumerable:!0,get:function(){return w[S]}})}}),k.default=w,Object.freeze(k)}var ae=ye(t),Ve=ye(n),be=ye(i),Te=ye(a),we=ye(s),ge=ye(c),$e=ye(o),De=ye(u),G=ye(l),Qe=ye(f),Et=Re(d),ut=ye(E),je=ye(I),te=ye(x),ur=ye(Y);function Me(w,k,S,m){var v=arguments.length,_=v<3?k:m===null?m=Object.getOwnPropertyDescriptor(k,S):m,g;if((typeof Reflect>"u"?"undefined":Qe.default(Reflect))==="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(w,k,S,m);else for(var y=w.length-1;y>=0;y--)(g=w[y])&&(_=(v<3?g(_):v>3?g(k,S,_):g(k,S))||_);return v>3&&_&&Object.defineProperty(k,S,_),_}function fe(w,k){if((typeof Reflect>"u"?"undefined":Qe.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(w,k)}function Pt(w,k){return["".concat(new Date().toISOString()," Conversations ").concat(w,":")].concat(Array.from(k))}var We=Et.getLogger("twilio-conversations"),Kt=function(){function w(k){De.default(this,w),ge.default(this,"prefix",""),this.prefix=k!=null&&k.length>0?k+" ":""}return $e.default(w,[{key:"setLevel",value:function(S){We.setLevel(S)}},{key:"trace",value:function(){for(var S=arguments.length,m=new Array(S),v=0;v<S;v++)m[v]=arguments[v];We.trace.apply(null,Pt(this.prefix+"T",m))}},{key:"debug",value:function(){for(var S=arguments.length,m=new Array(S),v=0;v<S;v++)m[v]=arguments[v];We.debug.apply(null,Pt(this.prefix+"D",m))}},{key:"info",value:function(){for(var S=arguments.length,m=new Array(S),v=0;v<S;v++)m[v]=arguments[v];We.info.apply(null,Pt(this.prefix+"I",m))}},{key:"warn",value:function(){for(var S=arguments.length,m=new Array(S),v=0;v<S;v++)m[v]=arguments[v];We.warn.apply(null,Pt(this.prefix+"W",m))}},{key:"error",value:function(){for(var S=arguments.length,m=new Array(S),v=0;v<S;v++)m[v]=arguments[v];We.error.apply(null,Pt(this.prefix+"E",m))}}],[{key:"scope",value:function(S){return new w(S)}},{key:"setLevel",value:function(S){We.setLevel(S)}},{key:"trace",value:function(){for(var S=arguments.length,m=new Array(S),v=0;v<S;v++)m[v]=arguments[v];We.trace.apply(null,Pt("T",m))}},{key:"debug",value:function(){for(var S=arguments.length,m=new Array(S),v=0;v<S;v++)m[v]=arguments[v];We.debug.apply(null,Pt("D",m))}},{key:"info",value:function(){for(var S=arguments.length,m=new Array(S),v=0;v<S;v++)m[v]=arguments[v];We.info.apply(null,Pt("I",m))}},{key:"warn",value:function(){for(var S=arguments.length,m=new Array(S),v=0;v<S;v++)m[v]=arguments[v];We.warn.apply(null,Pt("W",m))}},{key:"error",value:function(){for(var S=arguments.length,m=new Array(S),v=0;v<S;v++)m[v]=arguments[v];We.error.apply(null,Pt("E",m))}}]),w}();function gt(w,k){var S=Object.keys(w);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(w);k&&(m=m.filter(function(v){return Object.getOwnPropertyDescriptor(w,v).enumerable})),S.push.apply(S,m)}return S}function xe(w){for(var k=1;k<arguments.length;k++){var S=arguments[k]!=null?arguments[k]:{};k%2?gt(Object(S),!0).forEach(function(m){ge.default(w,m,S[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(w,Object.getOwnPropertyDescriptors(S)):gt(Object(S)).forEach(function(m){Object.defineProperty(w,m,Object.getOwnPropertyDescriptor(S,m))})}return w}var ft=5,Tt="PT5S",Le="PT5S",Jt=100,vt=1e3,zt=4e3,nr=3,He=!0,Pr=$e.default(function w(){var k,S,m,v,_,g,y,b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},T=arguments.length>1?arguments[1]:void 0,$=arguments.length>2?arguments[2]:void 0;De.default(this,w),ge.default(this,"typingIndicatorTimeoutDefault",ft*1e3);var H=b.Chat||b.IPMessaging||b||{};this.productId=H.productId,this.links={myConversations:T.links.my_conversations,conversations:T.links.conversations,users:T.links.users,currentUser:T.links.current_user,typing:T.links.typing,mediaService:T.links.media_service,mediaSetService:T.links.media_set_service,messagesReceipts:T.links.messages_receipts},this.limits={mediaAttachmentsCountLimit:T.options.media_attachments_count_limit,mediaAttachmentSizeLimitInMb:T.options.media_attachment_size_limit_in_mb,mediaAttachmentsTotalSizeLimitInMb:T.options.media_attachments_total_size_limit_in_mb,emailHistoriesAllowedContentTypes:T.options.email_histories_allowed_mime_types,emailBodiesAllowedContentTypes:T.options.email_bodies_allowed_mime_types},this.typingIndicatorTimeoutOverride=H.typingIndicatorTimeoutOverride,this.backoffConfiguration=xe({min:vt,max:zt,maxAttemptsCount:nr},H.backoffConfigOverride),this.retryWhenThrottled=H.retryWhenThrottledOverride!==void 0?H.retryWhenThrottledOverride:He,this.userInfosToSubscribe=(k=(S=H.userInfosToSubscribeOverride)!==null&&S!==void 0?S:T.options.user_infos_to_subscribe)!==null&&k!==void 0?k:Jt,this.reachabilityEnabled=T.options.reachability_enabled,this.userIdentity=T.identity,this.userInfo=T.sync_objects.my_user_info,this.myConversations=T.sync_objects.my_conversations;var K=(m=(v=H.httpCacheIntervalOverride)!==null&&v!==void 0?v:T.options.http_cache_interval)!==null&&m!==void 0?m:Tt;try{this.httpCacheInterval=p.toSeconds(p.parse(K))}catch{$.error("Failed to parse http cache interval ".concat(K,", using default value ").concat(Tt)),this.httpCacheInterval=p.toSeconds(p.parse(Tt))}var re=(_=(g=H.consumptionReportIntervalOverride)!==null&&g!==void 0?g:T.options.consumption_report_interval)!==null&&_!==void 0?_:Le;try{this.consumptionReportInterval=p.toSeconds(p.parse(re))}catch{$.error("Failed to parse consumption report interval ".concat(re,", using default value ").concat(Le)),this.consumptionReportInterval=p.toSeconds(p.parse(Le))}this.channelMetadataCacheCapacity=(y=b.channelMetadataCacheCapacity)!==null&&y!==void 0?y:100});function Cr(w){return JSON.parse(JSON.stringify(w))}function Ct(w){return typeof w<"u"&&!isNaN(Number(w))?Number(w):null}function kt(w){try{return new Date(w)}catch{return null}}function yt(w,k,S){var m={};if(w)try{m=JSON.parse(w)}catch(v){S.warn(k,v)}return m}var st=function(){function w(k){De.default(this,w),this.base=k.replace(/\/$/,""),this.args=[],this.paths=[]}return $e.default(w,[{key:"arg",value:function(S,m){return typeof m<"u"&&this.args.push(encodeURIComponent(S)+"="+encodeURIComponent(m)),this}},{key:"path",value:function(S){return this.paths.push(encodeURIComponent(S)),this}},{key:"build",value:function(){var S=this.base;return this.paths.length&&(S+="/"+this.paths.join("/")),this.args.length&&(S+="?"+this.args.join("&")),S}}]),w}(),Lt=h.custom(function(w){return[["string","number","boolean","object"].includes(Qe.default(w)),"a JSON type"]}),Xt=h.custom(function(w){return[["undefined","string","number","boolean","object"].includes(Qe.default(w)),"an optional JSON type"]}),hr=h.objectSchema("send media options",{contentType:[h.literal(null),"string"],filename:["string","undefined"],media:[h.literal("null"),"string"].concat(ut.default(typeof Buffer=="function"?[Buffer]:[]),ut.default(typeof Blob=="function"?[Blob]:[]))});function hn(w){var k=Pn();return function(){var m=we.default(w),v;if(k){var _=we.default(this).constructor;v=Reflect.construct(m,arguments,_)}else v=m.apply(this,arguments);return Te.default(this,v)}}function Pn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var _r=Kt.scope("User"),Wt=function(w){be.default(S,w);var k=hn(S);function S(m,v,_,g){var y;return De.default(this,S),y=k.call(this),ge.default(Ve.default(y),"promiseToFetch",null),ge.default(Ve.default(y),"updated","updated"),ge.default(Ve.default(y),"userSubscribed","userSubscribed"),ge.default(Ve.default(y),"userUnsubscribed","userUnsubscribed"),y.services=g,y.subscribed="initializing",y.setMaxListeners(0),y.state={identity:m,entityName:v,friendlyName:null,attributes:{},online:null,notifiable:null},y._initializationPromise=new Promise(function(b){y._resolveInitializationPromise=b}),_!==null&&y._resolveInitialization(_,m,v,!1),y}return $e.default(S,[{key:"identity",get:function(){return this.state.identity},set:function(v){this.state.identity=v}},{key:"entityName",set:function(v){this.state.entityName=v}},{key:"attributes",get:function(){return this.state.attributes}},{key:"friendlyName",get:function(){return this.state.friendlyName}},{key:"isOnline",get:function(){return this.state.online}},{key:"isNotifiable",get:function(){return this.state.notifiable}},{key:"isSubscribed",get:function(){return this.subscribed=="subscribed"}},{key:"_update",value:function(){var m=ae.default(G.default.mark(function _(g,y){var b,T;return G.default.wrap(function(H){for(;;)switch(H.prev=H.next){case 0:return H.next=2,this._initializationPromise;case 2:b=[],_r.debug("User for",this.state.identity,"updated:",g,y),H.t0=g,H.next=H.t0==="friendlyName"?7:H.t0==="attributes"?9:H.t0==="reachability"?12:15;break;case 7:return this.state.friendlyName!==y.value&&(b.push("friendlyName"),this.state.friendlyName=y.value),H.abrupt("break",16);case 9:return T=yt(y.value,"Retrieved malformed attributes from the server for user: ".concat(this.state.identity),_r),je.default(this.state.attributes,T)||(this.state.attributes=T,b.push("attributes")),H.abrupt("break",16);case 12:return this.state.online!==y.online&&(this.state.online=y.online,b.push("reachabilityOnline")),this.state.notifiable!==y.notifiable&&(this.state.notifiable=y.notifiable,b.push("reachabilityNotifiable")),H.abrupt("break",16);case 15:return H.abrupt("return");case 16:b.length>0&&this.emit("updated",{user:this,updateReasons:b});case 17:case"end":return H.stop()}},_,this)}));function v(_,g){return m.apply(this,arguments)}return v}()},{key:"_updateReachabilityInfo",value:function(){var m=ae.default(G.default.mark(function _(g,y){var b=this;return G.default.wrap(function($){for(;;)switch($.prev=$.next){case 0:return $.next=2,this._initializationPromise;case 2:if(this.configuration.reachabilityEnabled){$.next=4;break}return $.abrupt("return",Promise.resolve());case 4:return $.abrupt("return",g.get("reachability").then(y).catch(function(H){_r.warn("Failed to get reachability info for ",b.state.identity,H)}));case 5:case"end":return $.stop()}},_,this)}));function v(_,g){return m.apply(this,arguments)}return v}()},{key:"_fetch",value:function(){var m=ae.default(G.default.mark(function _(){var g=this;return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._initializationPromise;case 2:if(this.state.entityName){b.next=4;break}return b.abrupt("return",this);case 4:return this.promiseToFetch=this.services.syncClient.map({id:this.state.entityName,mode:"open_existing",includeItems:!0}).then(function(T){return g.entity=T,T.on("itemUpdated",function($){return _r.debug(g.state.entityName+" ("+g.state.identity+") itemUpdated: "+$.item.key),g._update($.item.key,$.item.data)}),T.on("itemAdded",function($){return _r.debug(g.state.entityName+" ("+g.state.identity+") itemAdded: "+$.item.key),g._update($.item.key,$.item.data)}),Promise.all([T.get("friendlyName").then(function($){return g._update($.key,$.data)}),T.get("attributes").then(function($){return g._update($.key,$.data)}),g._updateReachabilityInfo(T,function($){return g._update($.key,$.data)})])}).then(function(){return _r.debug("Fetched for",g.identity),g.subscribed="subscribed",g.emit("userSubscribed",g),g}).catch(function(T){throw g.promiseToFetch=null,T}),b.abrupt("return",this.promiseToFetch);case 6:case"end":return b.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"_ensureFetched",value:function(){var m=ae.default(G.default.mark(function _(){return G.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._initializationPromise;case 2:return y.abrupt("return",this.promiseToFetch||this._fetch());case 3:case"end":return y.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"updateAttributes",value:function(){var m=ae.default(G.default.mark(function _(g){return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._initializationPromise;case 2:if(this.subscribed!="unsubscribed"){b.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return b.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(g)});case 6:return b.abrupt("return",this);case 7:case"end":return b.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"updateFriendlyName",value:function(){var m=ae.default(G.default.mark(function _(g){return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._initializationPromise;case 2:if(this.subscribed!="unsubscribed"){b.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return b.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{friendly_name:g});case 6:return b.abrupt("return",this);case 7:case"end":return b.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"unsubscribe",value:function(){var m=ae.default(G.default.mark(function _(){return G.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._initializationPromise;case 2:if(!this.promiseToFetch){y.next=9;break}return y.next=5,this.promiseToFetch;case 5:this.entity.close(),this.promiseToFetch=null,this.subscribed="unsubscribed",this.emit("userUnsubscribed",this);case 9:case"end":return y.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"_resolveInitialization",value:function(v,_,g,y){this.configuration=v,this.identity=_,this.entityName=g,this.links={self:"".concat(this.configuration.links.users,"/").concat(encodeURIComponent(this.identity))},this._resolveInitializationPromise(),y&&this.emit("updated",{user:this,updateReasons:["friendlyName","attributes","reachabilityOnline","reachabilityNotifiable"]})}}]),S}(M.ReplayEventEmitter);Me([h.validateTypesAsync(Lt),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",Promise)],Wt.prototype,"updateAttributes",null),Me([h.validateTypesAsync(["string"]),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],Wt.prototype,"updateFriendlyName",null);function Nr(w,k){var S=typeof Symbol<"u"&&w[Symbol.iterator]||w["@@iterator"];if(!S){if(Array.isArray(w)||(S=_e(w))||k&&w&&typeof w.length=="number"){S&&(w=S);var m=0,v=function(){};return{s:v,n:function(){return m>=w.length?{done:!0}:{done:!1,value:w[m++]}},e:function(T){throw T},f:v}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
460
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,g=!1,y;return{s:function(){S=S.call(w)},n:function(){var T=S.next();return _=T.done,T},e:function(T){g=!0,y=T},f:function(){try{!_&&S.return!=null&&S.return()}finally{if(g)throw y}}}}function _e(w,k){if(w){if(typeof w=="string")return Ce(w,k);var S=Object.prototype.toString.call(w).slice(8,-1);if(S==="Object"&&w.constructor&&(S=w.constructor.name),S==="Map"||S==="Set")return Array.from(w);if(S==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(S))return Ce(w,k)}}function Ce(w,k){(k==null||k>w.length)&&(k=w.length);for(var S=0,m=new Array(k);S<k;S++)m[S]=w[S];return m}var ce=function(){function w(k,S){De.default(this,w),this.configuration=k,this.services=S,this.cache=new Map,this.cacheLifetime=this.configuration.httpCacheInterval*100,this.cleanupCache()}return $e.default(w,[{key:"isExpired",value:function(S){return!this.cacheLifetime||Date.now()-S>this.cacheLifetime}},{key:"cleanupCache",value:function(){var S=Nr(this.cache),m;try{for(S.s();!(m=S.n()).done;){var v=te.default(m.value,2),_=v[0],g=v[1];this.isExpired(g.timestamp)&&this.cache.delete(_)}}catch(y){S.e(y)}finally{S.f()}this.cache.size===0&&clearInterval(this.timer)}},{key:"pokeTimer",value:function(){var S=this;this.timer=this.timer||setInterval(function(){return S.cleanupCache()},this.cacheLifetime*2)}},{key:"executeWithRetry",value:function(S){var m=this,v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return new Promise(function(_,g){var y=[502,503,504];v&&y.push(429);var b=new j.Retrier(m.configuration.backoffConfiguration);b.on("attempt",function(){S().then(function(T){return b.succeeded(T)}).catch(function(T){y.indexOf(T.status)>-1||T.message==="Twilsock disconnected"?b.failed(T):(b.removeAllListeners(),b.cancel(),g(T))})}),b.on("succeeded",function(T){_(T)}),b.on("cancelled",function(T){return g(T)}),b.on("failed",function(T){return g(T)}),b.start()})}},{key:"get",value:function(){var k=ae.default(G.default.mark(function m(v){var _=this,g,y,b;return G.default.wrap(function($){for(;;)switch($.prev=$.next){case 0:if(g=this.cache.get(v),!(g&&!this.isExpired(g.timestamp))){$.next=3;break}return $.abrupt("return",g.response);case 3:return y={},$.next=6,this.executeWithRetry(function(){return _.services.transport.get(v,y,_.configuration.productId)},this.configuration.retryWhenThrottled);case 6:return b=$.sent,this.cache.set(v,{response:b,timestamp:Date.now()}),this.pokeTimer(),$.abrupt("return",b);case 10:case"end":return $.stop()}},m,this)}));function S(m){return k.apply(this,arguments)}return S}()}]),w}(),de=$e.default(function w(){De.default(this,w)});ge.default(de,"TYPING_INDICATOR","twilio.ipmsg.typing_indicator"),ge.default(de,"NEW_MESSAGE","twilio.conversations.new_message"),ge.default(de,"ADDED_TO_CONVERSATION","twilio.conversations.added_to_conversation"),ge.default(de,"REMOVED_FROM_CONVERSATION","twilio.conversations.removed_from_conversation"),ge.default(de,"CONSUMPTION_UPDATE","twilio.channel.consumption_update");function le(w){var k=ke();return function(){var m=we.default(w),v;if(k){var _=we.default(this).constructor;v=Reflect.construct(m,arguments,_)}else v=m.apply(this,arguments);return Te.default(this,v)}}function ke(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ie=Kt.scope("Participant"),ee=function(w){be.default(S,w);var k=le(S);function S(m,v,_,g,y){var b,T,$;if(De.default(this,S),$=k.call(this),$.conversation=_,$.links=g,$.services=y,$.state={attributes:yt(m.attributes,"Retrieved malformed attributes from the server for participant: "+v,Ie),dateCreated:m.dateCreated?kt(m.dateCreated):null,dateUpdated:m.dateCreated?kt(m.dateUpdated):null,sid:v,typingTimeout:null,isTyping:!1,identity:m.identity,roleSid:(b=m.roleSid)!==null&&b!==void 0?b:"",lastReadMessageIndex:Number.isInteger(m.lastConsumedMessageIndex)?m.lastConsumedMessageIndex:null,lastReadTimestamp:m.lastConsumptionTimestamp?kt(m.lastConsumptionTimestamp):null,type:m.type||"chat",userInfo:m.userInfo,bindings:(T=m.bindings)!==null&&T!==void 0?T:{}},!m.identity&&!m.type)throw new Error("Received invalid Participant object from server: Missing identity or type of Participant.");return $}return $e.default(S,[{key:"sid",get:function(){return this.state.sid}},{key:"attributes",get:function(){return this.state.attributes}},{key:"dateCreated",get:function(){return this.state.dateCreated}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"identity",get:function(){return this.state.identity}},{key:"isTyping",get:function(){return this.state.isTyping}},{key:"lastReadMessageIndex",get:function(){return this.state.lastReadMessageIndex}},{key:"lastReadTimestamp",get:function(){return this.state.lastReadTimestamp}},{key:"roleSid",get:function(){return this.state.roleSid}},{key:"type",get:function(){return this.state.type}},{key:"bindings",get:function(){var v;return(v=this.state.bindings)!==null&&v!==void 0?v:{}}},{key:"_startTyping",value:function(v){var _=this;return this.state.typingTimeout&&clearTimeout(this.state.typingTimeout),this.state.isTyping=!0,this.emit("typingStarted",this),this.conversation.emit("typingStarted",this),this.state.typingTimeout=Number(setTimeout(function(){return _._endTyping()},v)),this}},{key:"_endTyping",value:function(){this.state.typingTimeout&&(this.state.isTyping=!1,this.emit("typingEnded",this),this.conversation.emit("typingEnded",this),clearInterval(this.state.typingTimeout),this.state.typingTimeout=null)}},{key:"_update",value:function(v){var _=[],g=yt(v.attributes,"Retrieved malformed attributes from the server for participant: "+this.state.sid,Ie);v.attributes&&!je.default(this.state.attributes,g)&&(this.state.attributes=g,_.push("attributes"));var y=kt(v.dateUpdated);v.dateUpdated&&(y==null?void 0:y.getTime())!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=y,_.push("dateUpdated"));var b=kt(v.dateCreated);if(v.dateCreated&&(b==null?void 0:b.getTime())!==(this.state.dateCreated&&this.state.dateCreated.getTime())&&(this.state.dateCreated=b,_.push("dateCreated")),v.roleSid&&this.state.roleSid!==v.roleSid&&(this.state.roleSid=v.roleSid,_.push("roleSid")),(Number.isInteger(v.lastConsumedMessageIndex)||v.lastConsumedMessageIndex===null)&&this.state.lastReadMessageIndex!==v.lastConsumedMessageIndex&&(this.state.lastReadMessageIndex=v.lastConsumedMessageIndex,_.push("lastReadMessageIndex")),v.lastConsumptionTimestamp){var T=new Date(v.lastConsumptionTimestamp);(!this.state.lastReadTimestamp||this.state.lastReadTimestamp.getTime()!==T.getTime())&&(this.state.lastReadTimestamp=T,_.push("lastReadTimestamp"))}return v.bindings&&!je.default(this.state.bindings,v.bindings)&&(this.state.bindings=v.bindings,_.push("bindings")),_.length>0&&this.emit("updated",{participant:this,updateReasons:_}),this}},{key:"getUser",value:function(){var m=ae.default(G.default.mark(function _(){return G.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this.type=="chat"){y.next=2;break}throw new Error("Getting User is not supported for this Participant type: "+this.type);case 2:return y.abrupt("return",this.services.users.getUser(this.state.identity,this.state.userInfo));case 3:case"end":return y.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"remove",value:function(){var m=ae.default(G.default.mark(function _(){return G.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.abrupt("return",this.conversation.removeParticipant(this));case 1:case"end":return y.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"updateAttributes",value:function(){var m=ae.default(G.default.mark(function _(g){return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(g)});case 2:return b.abrupt("return",this);case 3:case"end":return b.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()}]),S}(M.ReplayEventEmitter);ge.default(ee,"typingStarted","typingStarted"),ge.default(ee,"typingEnded","typingEnded"),ge.default(ee,"updated","updated"),Me([h.validateTypesAsync(Lt),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",Promise)],ee.prototype,"updateAttributes",null);function ve(w){var k=Q();return function(){var m=we.default(w),v;if(k){var _=we.default(this).constructor;v=Reflect.construct(m,arguments,_)}else v=m.apply(this,arguments);return Te.default(this,v)}}function Q(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var se=Kt.scope("Participants"),X=function(w){be.default(S,w);var k=ve(S);function S(m,v,_,g,y){var b;return De.default(this,S),b=k.call(this),ge.default(Ve.default(b),"rosterEntityPromise",null),b.conversation=m,b.participants=v,b.links=_,b.configuration=g,b.services=y,b}return $e.default(S,[{key:"unsubscribe",value:function(){var m=ae.default(G.default.mark(function _(){var g;return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(!this.rosterEntityPromise){b.next=6;break}return b.next=3,this.rosterEntityPromise;case 3:g=b.sent,g.close(),this.rosterEntityPromise=null;case 6:case"end":return b.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"subscribe",value:function(v){var _=this,g=typeof v=="string"?this.services.syncClient.map({id:v,mode:"open_existing"}):Promise.resolve(v);return this.rosterEntityPromise=this.rosterEntityPromise||g.then(function(y){y.on("itemAdded",function($){se.debug(_.conversation.sid+" itemAdded: "+$.item.key),_.upsertParticipant($.item.key,$.item.data).then(function(H){_.emit("participantJoined",H)})}),y.on("itemRemoved",function($){se.debug(_.conversation.sid+" itemRemoved: "+$.key);var H=$.key;if(_.participants.has(H)){var K=_.participants.get(H);_.participants.delete(H),K&&_.emit("participantLeft",K)}}),y.on("itemUpdated",function($){se.debug(_.conversation.sid+" itemUpdated: "+$.item.key),_.upsertParticipant($.item.key,$.item.data)});var b=[],T=function $(H){return H.items.forEach(function(K){b.push(_.upsertParticipant(K.key,K.data))}),H.hasNextPage?H.nextPage().then($):null};return y.getItems().then(T).then(function(){return Promise.all(b)}).then(function(){return y})}).catch(function(y){throw _.rosterEntityPromise=null,_.services.syncClient.connectionState!="disconnected"&&se.error("Failed to get roster object for conversation",_.conversation.sid,y),se.debug("ERROR: Failed to get roster object for conversation",_.conversation.sid,y),y})}},{key:"upsertParticipantFromResponse",value:function(){var m=ae.default(G.default.mark(function _(g){var y,b,T,$,H,K,re,ue;return G.default.wrap(function(lt){for(;;)switch(lt.prev=lt.next){case 0:return b=g.sid,T=g.attributes,$=g.date_created,H=g.date_updated,K=g.identity,re=g.role_sid,ue=g.messaging_binding,lt.next=3,this.upsertParticipant(b,{attributes:T,dateCreated:new Date($),dateUpdated:new Date(H),identity:K,roleSid:re,lastConsumedMessageIndex:null,lastConsumptionTimestamp:null,type:(y=ue==null?void 0:ue.type)!==null&&y!==void 0?y:"chat"});case 3:return lt.abrupt("return",lt.sent);case 4:case"end":return lt.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"upsertParticipant",value:function(){var m=ae.default(G.default.mark(function _(g,y){var b=this,T,$;return G.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(T=this.participants.get(g),!T){K.next=3;break}return K.abrupt("return",T._update(y));case 3:return $={self:"".concat(this.links.participants,"/").concat(g)},T=new ee(y,g,this.conversation,$,this.services),this.participants.set(g,T),T.on("updated",function(re){return b.emit("participantUpdated",re)}),K.abrupt("return",T);case 8:case"end":return K.stop()}},_,this)}));function v(_,g){return m.apply(this,arguments)}return v}()},{key:"getParticipants",value:function(){var m=ae.default(G.default.mark(function _(){var g=this;return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then(function(){var T=[];return g.participants.forEach(function($){return T.push($)}),T}):[]);case 1:case"end":return b.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"getParticipantBySid",value:function(){var m=ae.default(G.default.mark(function _(g){var y=this;return G.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then(function(){var $=y.participants.get(g);if(!$)throw new Error("Participant with SID "+g+" was not found");return $}):null);case 1:case"end":return T.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"getParticipantByIdentity",value:function(){var m=ae.default(G.default.mark(function _(g){var y=this,b;return G.default.wrap(function($){for(;;)switch($.prev=$.next){case 0:return b=null,$.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then(function(){if(y.participants.forEach(function(H){H.identity===g&&(b=H)}),!b)throw new Error("Participant with identity "+g+" was not found");return b}):null);case 2:case"end":return $.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"add",value:function(){var m=ae.default(G.default.mark(function _(g,y){return G.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.next=2,this.services.commandExecutor.mutateResource("post",this.links.participants,{identity:g,attributes:typeof y<"u"?JSON.stringify(y):void 0});case 2:return T.abrupt("return",T.sent);case 3:case"end":return T.stop()}},_,this)}));function v(_,g){return m.apply(this,arguments)}return v}()},{key:"addNonChatParticipant",value:function(){var m=ae.default(G.default.mark(function _(g,y){var b,T,$,H,K=arguments;return G.default.wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:return $=K.length>2&&K[2]!==void 0?K[2]:{},H=K.length>3&&K[3]!==void 0?K[3]:{},ue.next=4,this.services.commandExecutor.mutateResource("post",this.links.participants,{attributes:typeof $<"u"?JSON.stringify($):void 0,messaging_binding:{address:y,proxy_address:g,name:H==null||(b=H.email)===null||b===void 0?void 0:b.name,level:H==null||(T=H.email)===null||T===void 0?void 0:T.level}});case 4:return ue.abrupt("return",ue.sent);case 5:case"end":return ue.stop()}},_,this)}));function v(_,g){return m.apply(this,arguments)}return v}()},{key:"remove",value:function(v){return this.services.commandExecutor.mutateResource("delete","".concat(this.links.participants,"/").concat(encodeURIComponent(v)))}}]),S}(M.ReplayEventEmitter),Ue=function(){function w(k,S){De.default(this,w),ge.default(this,"mcsMedia",null),this.services=S,k instanceof J.McsMedia&&(this.mcsMedia=k),this.state={sid:k.sid,category:k.category,filename:k.filename,contentType:k.contentType,size:k.size}}return $e.default(w,[{key:"sid",get:function(){return this.state.sid}},{key:"filename",get:function(){return this.state.filename}},{key:"contentType",get:function(){return this.state.contentType}},{key:"size",get:function(){return this.state.size}},{key:"category",get:function(){return this.state.category}},{key:"getContentTemporaryUrl",value:function(){var S=this;return new J.CancellablePromise(function(){var m=ae.default(G.default.mark(function v(_,g,y){var b,T,$,H;return G.default.wrap(function(re){for(;;)switch(re.prev=re.next){case 0:if(T=S._fetchMcsMedia(),$=(b=S.mcsMedia)===null||b===void 0?void 0:b.getContentUrl(),y(function(){T.cancel(),$&&$.cancel()}),re.prev=3,S.mcsMedia){re.next=9;break}return re.next=7,T;case 7:H=re.sent,$=H.getContentUrl();case 9:if(re.t0=_,!$){re.next=16;break}return re.next=13,$;case 13:re.t1=re.sent,re.next=17;break;case 16:re.t1=null;case 17:re.t2=re.t1,(0,re.t0)(re.t2),re.next=24;break;case 21:re.prev=21,re.t3=re.catch(3),g(re.t3);case 24:case"end":return re.stop()}},v,null,[[3,21]])}));return function(v,_,g){return m.apply(this,arguments)}}())}},{key:"_fetchMcsMedia",value:function(){var S=this;return new J.CancellablePromise(function(){var m=ae.default(G.default.mark(function v(_,g,y){var b;return G.default.wrap(function($){for(;;)switch($.prev=$.next){case 0:if(b=S.services.mcsClient.get(S.state.sid),!S.services.mcsClient){$.next=14;break}return y(function(){return b.cancel()}),$.prev=3,$.next=6,b;case 6:S.mcsMedia=$.sent,_(S.mcsMedia),$.next=13;break;case 10:$.prev=10,$.t0=$.catch(3),g($.t0);case 13:return $.abrupt("return");case 14:g(new Error("Media Content Service is unavailable"));case 15:case"end":return $.stop()}},v,null,[[3,10]])}));return function(v,_,g){return m.apply(this,arguments)}}())}}]),w}(),Oe=function(){function w(k){De.default(this,w),this.state=k}return $e.default(w,[{key:"total",get:function(){return this.state.total}},{key:"sent",get:function(){return this.state.sent}},{key:"delivered",get:function(){return this.state.delivered}},{key:"read",get:function(){return this.state.read}},{key:"undelivered",get:function(){return this.state.undelivered}},{key:"failed",get:function(){return this.state.failed}},{key:"_update",value:function(S){this.state=S}},{key:"_isEquals",value:function(S){var m=this.total===S.total,v=this.sent===S.sent,_=this.delivered===S.delivered,g=this.read===S.read,y=this.undelivered===S.undelivered,b=this.failed===S.failed;return m&&v&&_&&g&&y&&b}}]),w}(),Ze=function(){function w(k,S,m,v){De.default(this,w),this.state={prevToken:m,nextToken:v,source:S,items:k}}return $e.default(w,[{key:"hasNextPage",get:function(){return!!this.state.nextToken}},{key:"hasPrevPage",get:function(){return!!this.state.prevToken}},{key:"items",get:function(){return this.state.items}},{key:"nextPage",value:function(){return this.hasNextPage?this.state.source(this.state.nextToken):Promise.reject(new Error("No next page"))}},{key:"prevPage",value:function(){return this.hasPrevPage?this.state.source(this.state.prevToken):Promise.reject(new Error("No previous page"))}}]),w}(),Ke=$e.default(function w(k){De.default(this,w),this.sid=k.sid,this.messageSid=k.message_sid,this.conversationSid=k.conversation_sid,this.channelMessageSid=k.channel_message_sid,this.participantSid=k.participant_sid,this.status=k.status||"queued",this.errorCode=k.error_code||0,this.dateCreated=k.date_created,this.dateUpdated=k.date_updated}),Je=function(k){return k.map(function(S){var m,v,_,g,y=JSON.stringify(S);switch(S.type){case"QUICK_REPLY":return{type:"reply",title:S.title,id:(m=S.id)!==null&&m!==void 0?m:"",index:(v=S.index)!==null&&v!==void 0?v:0,rawData:y};case"PHONE_NUMBER":return{type:"phone",title:S.title,phone:(_=S.phone)!==null&&_!==void 0?_:"",rawData:y};case"URL":return{type:"url",title:S.title,url:(g=S.url)!==null&&g!==void 0?g:"",rawData:y};default:return{type:"other",rawData:y}}})},rt=function(k,S){var m=JSON.stringify(S);switch(k){case"twilio/text":{var v=S;return{type:"text",body:v.body,rawData:m}}case"twilio/media":{var _=S;return{type:"media",body:_.body,media:_.media,rawData:m}}case"twilio/location":{var g=S;return{type:"location",longitude:g.longitude,latitude:g.latitude,label:g.label,rawData:m}}case"twilio/quick-reply":{var y=S;return{type:"quickReply",body:y.body,replies:y.actions,rawData:m}}case"twilio/call-to-action":{var b=S;return{type:"callToAction",body:b.body,actions:Je(b.actions),rawData:m}}case"twilio/list-picker":{var T=S;return{type:"listPicker",body:T.body,button:T.button,items:T.items,rawData:m}}case"twilio/card":{var $,H,K=S;return{type:"card",title:K.title,subtitle:K.subtitle,media:($=K.media)!==null&&$!==void 0?$:[],actions:Je((H=K.actions)!==null&&H!==void 0?H:[]),rawData:m}}default:return{type:"other",rawData:m}}},nt=function(k){for(var S=new Map,m=0,v=Object.entries(k);m<v.length;m++){var _=te.default(v[m],2),g=_[0],y=_[1];S.set(g,rt(g,y))}return S},Ye=function(){function w(k,S){De.default(this,w),this.name=k,this.value=S}return $e.default(w,[{key:"copyWithValue",value:function(S){return new w(this.name,S)}}]),w}(),tt=$e.default(function w(k){De.default(this,w),this.sid=k.sid,this.friendlyName=k.friendly_name,this.variables=Object.entries(JSON.parse(k.variables)).map(function(S){var m=te.default(S,2),v=m[0],_=m[1];return new Ye(v,_)}),this.variants=nt(k.variants),this.dateCreated=new Date(k.date_created),this.dateUpdated=new Date(k.date_updated)});function it(w,k){var S=Object.keys(w);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(w);k&&(m=m.filter(function(v){return Object.getOwnPropertyDescriptor(w,v).enumerable})),S.push.apply(S,m)}return S}function ct(w){for(var k=1;k<arguments.length;k++){var S=arguments[k]!=null?arguments[k]:{};k%2?it(Object(S),!0).forEach(function(m){ge.default(w,m,S[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(w,Object.getOwnPropertyDescriptors(S)):it(Object(S)).forEach(function(m){Object.defineProperty(w,m,Object.getOwnPropertyDescriptor(S,m))})}return w}function Sr(w){var k=cr();return function(){var m=we.default(w),v;if(k){var _=we.default(this).constructor;v=Reflect.construct(m,arguments,_)}else v=m.apply(this,arguments);return Te.default(this,v)}}function cr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ot=Kt.scope("Message"),Hr=r.XMLHttpRequest||{},ir=function(w){be.default(S,w);var k=Sr(S);function S(m,v,_,g,y,b){var T,$,H,K,re,ue;return De.default(this,S),ue=k.call(this),ue.conversation=_,ue.links=g,ue.configuration=y,ue.services=b,ue.state={sid:v.sid,index:m,author:v.author,subject:v.subject,contentSid:v.contentSid,body:(T=v.text)!==null&&T!==void 0?T:null,timestamp:v.timestamp?new Date(v.timestamp):null,dateUpdated:v.dateUpdated?new Date(v.dateUpdated):null,lastUpdatedBy:($=v.lastUpdatedBy)!==null&&$!==void 0?$:null,attributes:yt(v.attributes,"Got malformed attributes for the message ".concat(v.sid),ot),type:(H=v.type)!==null&&H!==void 0?H:"text",media:v.type==="media"&&v.media?new Ue(v.media,ue.services):null,medias:v.type==="media"&&v.medias?v.medias.map(function(Xe){return new Ue(Xe,ue.services)}):v.type==="media"&&v.media&&!v.medias?[new Ue(ct(ct({},v.media),{},{category:"media"}),ue.services)]:null,participantSid:(K=v.memberSid)!==null&&K!==void 0?K:null,aggregatedDeliveryReceipt:v.delivery?new Oe(v.delivery):null,hasChannelMetadata:(re=v.channelMetadata)!==null&&re!==void 0?re:!1},ue}return $e.default(S,[{key:"sid",get:function(){return this.state.sid}},{key:"author",get:function(){return this.state.author}},{key:"subject",get:function(){return this.state.subject}},{key:"contentSid",get:function(){return this.state.contentSid}},{key:"body",get:function(){return this.state.body}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"index",get:function(){return this.state.index}},{key:"lastUpdatedBy",get:function(){return this.state.lastUpdatedBy}},{key:"dateCreated",get:function(){return this.state.timestamp}},{key:"attributes",get:function(){return this.state.attributes}},{key:"type",get:function(){return this.state.type}},{key:"media",get:function(){return this.state.media}},{key:"attachedMedia",get:function(){return this.getMediaByCategories(["media"])}},{key:"participantSid",get:function(){return this.state.participantSid}},{key:"aggregatedDeliveryReceipt",get:function(){return this.state.aggregatedDeliveryReceipt}},{key:"getMediaByCategory",value:function(v){return this.getMediaByCategories(v)}},{key:"getMediaByCategories",value:function(v){var _;return((_=this.state.medias)!==null&&_!==void 0?_:[]).filter(function(g){return v.includes(g.category)})}},{key:"getEmailBody",value:function(){var v,_,g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"text/plain";return(v=(_=this.getMediaByCategories(["body"]))===null||_===void 0?void 0:_.filter(function(y){return y.contentType==g}).shift())!==null&&v!==void 0?v:null}},{key:"getEmailHistory",value:function(){var v,_,g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"text/plain";return(v=(_=this.getMediaByCategories(["history"]))===null||_===void 0?void 0:_.filter(function(y){return y.contentType==g}).shift())!==null&&v!==void 0?v:null}},{key:"_update",value:function(v){var _=[];(v.text||typeof v.text=="string")&&v.text!==this.state.body&&(this.state.body=v.text,_.push("body")),v.subject&&v.subject!==this.state.subject&&(this.state.subject=v.subject,_.push("subject")),v.lastUpdatedBy&&v.lastUpdatedBy!==this.state.lastUpdatedBy&&(this.state.lastUpdatedBy=v.lastUpdatedBy,_.push("lastUpdatedBy")),v.author&&v.author!==this.state.author&&(this.state.author=v.author,_.push("author")),v.dateUpdated&&new Date(v.dateUpdated).getTime()!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=new Date(v.dateUpdated),_.push("dateUpdated")),v.timestamp&&new Date(v.timestamp).getTime()!==(this.state.timestamp&&this.state.timestamp.getTime())&&(this.state.timestamp=new Date(v.timestamp),_.push("dateCreated"));var g=yt(v.attributes,"Got malformed attributes for the message ".concat(this.sid),ot);je.default(this.state.attributes,g)||(this.state.attributes=g,_.push("attributes"));var y=v.delivery,b=this.state.aggregatedDeliveryReceipt,T=!!y&&!!y.total&&!!y.delivered&&!!y.failed&&!!y.read&&!!y.sent&&!!y.undelivered;T&&(b?b._isEquals(y)||(b._update(y),_.push("deliveryReceipt")):(this.state.aggregatedDeliveryReceipt=new Oe(y),_.push("deliveryReceipt"))),_.length>0&&this.emit("updated",{message:this,updateReasons:_})}},{key:"getParticipant",value:function(){var m=ae.default(G.default.mark(function _(){var g=this,y,b;return G.default.wrap(function($){for(;;)switch($.prev=$.next){case 0:if(y=null,!this.state.participantSid){$.next=5;break}return $.next=4,this.conversation.getParticipantBySid(this.state.participantSid).catch(function(){return ot.debug('Participant with sid "'.concat(g.participantSid,'" not found for message ').concat(g.sid)),null});case 4:y=$.sent;case 5:if(!(!y&&this.state.author)){$.next=9;break}return $.next=8,this.conversation.getParticipantByIdentity(this.state.author).catch(function(){return ot.debug('Participant with identity "'.concat(g.author,'" not found for message ').concat(g.sid)),null});case 8:y=$.sent;case 9:if(!y){$.next=11;break}return $.abrupt("return",y);case 11:throw b="Participant with ",this.state.participantSid&&(b+="SID '"+this.state.participantSid+"' "),this.state.author&&(this.state.participantSid&&(b+="or "),b+="identity '"+this.state.author+"' "),b==="Participant with "&&(b="Participant "),b+="was not found",new Error(b);case 17:case"end":return $.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"getDetailedDeliveryReceipts",value:function(){var m=ae.default(G.default.mark(function _(){var g,y;return G.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.next=2,this._getDetailedDeliveryReceiptsPaginator();case 2:g=T.sent,y=g.items;case 4:if(!g.hasNextPage){T.next=11;break}return T.next=7,g.nextPage();case 7:g=T.sent,y=[].concat(ut.default(y),ut.default(g.items)),T.next=4;break;case 11:return T.abrupt("return",y);case 12:case"end":return T.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"remove",value:function(){var m=ae.default(G.default.mark(function _(){return G.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this.services.commandExecutor.mutateResource("delete",this.links.self);case 2:return y.abrupt("return",this);case 3:case"end":return y.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"updateBody",value:function(){var m=ae.default(G.default.mark(function _(g){return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{body:g});case 2:return b.abrupt("return",this);case 3:case"end":return b.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"updateAttributes",value:function(){var m=ae.default(G.default.mark(function _(g){return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:typeof g<"u"?JSON.stringify(g):void 0});case 2:return b.abrupt("return",this);case 3:case"end":return b.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"attachTemporaryUrlsFor",value:function(){var m=ae.default(G.default.mark(function _(g){var y=this,b;return G.default.wrap(function($){for(;;)switch($.prev=$.next){case 0:if(b=g==null?void 0:g.map(function(H){return H.sid}),!(this.services.mcsClient&&b)){$.next=7;break}return $.next=4,this.services.mcsClient.mediaSetGet(b);case 4:return $.abrupt("return",$.sent.map(function(H){return new Ue(H,y.services)}));case 7:throw new Error("Media Content Service is unavailable");case 8:case"end":return $.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"getTemporaryContentUrlsForMedia",value:function(v){var _=v.map(function(g){return g.sid});return this.getTemporaryContentUrlsForMediaSids(_)}},{key:"getTemporaryContentUrlsForMediaSids",value:function(v){var _=this;return new J.CancellablePromise(function(){var g=ae.default(G.default.mark(function y(b,T,$){var H,K;return G.default.wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:if(H=_.services.mcsClient.mediaSetGetContentUrls(v??[]),!(!_.services.mcsClient||!v)){ue.next=4;break}return T(new Error("Media Content Service is unavailable")),ue.abrupt("return");case 4:return $(function(){H.cancel()}),ue.prev=5,ue.next=8,H;case 8:K=ue.sent,b(K),ue.next=15;break;case 12:ue.prev=12,ue.t0=ue.catch(5),T(ue.t0);case 15:case"end":return ue.stop()}},y,null,[[5,12]])}));return function(y,b,T){return g.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForAttachedMedia",value:function(){var v,_=this.attachedMedia,g=(v=_==null?void 0:_.map(function(y){return y.sid}))!==null&&v!==void 0?v:[];return this.getTemporaryContentUrlsForMediaSids(g)}},{key:"_getDetailedDeliveryReceiptsPaginator",value:function(){var m=ae.default(G.default.mark(function _(g){var y=this,b,T,$;return G.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:return b=this.configuration.links.messagesReceipts.replace("%s",this.conversation.sid).replace("%s",this.sid),T=new st(b).arg("PageToken",g==null?void 0:g.pageToken).arg("PageSize",g==null?void 0:g.pageSize).build(),K.next=4,this.services.network.get(T);case 4:return $=K.sent,K.abrupt("return",new Ze($.body.delivery_receipts.map(function(re){return new Ke(re)}),function(re,ue){return y._getDetailedDeliveryReceiptsPaginator({pageToken:re,pageSize:ue})},$.body.meta.previous_token,$.body.meta.next_token));case 6:case"end":return K.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"getContentData",value:function(){var v=this;return new J.CancellablePromise(function(){var _=ae.default(G.default.mark(function g(y,b,T){var $,H,K,re,ue,Xe,lt,C,A,D;return G.default.wrap(function(V){for(;;)switch(V.prev=V.next){case 0:if(v.state.contentSid!==null){V.next=3;break}return y(null),V.abrupt("return");case 3:if($=v.getMediaByCategories(["body"]),$!==null){V.next=7;break}return y(null),V.abrupt("return");case 7:if(H="application/x-vnd.com.twilio.rich.",K=$.filter(function(he){return he.contentType.startsWith(H)}),K.length!==0){V.next=12;break}return y(null),V.abrupt("return");case 12:return re=K[0],ue=re.getContentTemporaryUrl(),T(function(){ue.cancel()}),V.prev=15,V.next=18,ue;case 18:Xe=V.sent,V.next=25;break;case 21:return V.prev=21,V.t0=V.catch(15),b(V.t0),V.abrupt("return");case 25:if(Xe!==null){V.next=28;break}return y(null),V.abrupt("return");case 28:return lt=new Promise(function(he,Se){var Ee,Fe=!1,et=new Hr;et.open("GET",(Ee=Xe)!==null&&Ee!==void 0?Ee:"",!0),et.responseType="text",et.onreadystatechange=function(){et.readyState!==4||Fe||he(et.responseText)},et.onerror=function(){Se(et.statusText)},T(function(){Fe=!0,et.abort(),Se(new Error("XHR has been aborted"))}),et.send()}),V.prev=29,V.next=32,lt;case 32:A=V.sent,C=JSON.parse(A),V.next=40;break;case 36:return V.prev=36,V.t1=V.catch(29),b(V.t1),V.abrupt("return");case 40:D=re.contentType.replace(H,"").replace(".","/"),y(rt(D,C.data));case 42:case"end":return V.stop()}},g,null,[[15,21],[29,36]])}));return function(g,y,b){return _.apply(this,arguments)}}())}},{key:"getChannelMetadata",value:function(){var m=ae.default(G.default.mark(function _(){return G.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this.state.hasChannelMetadata){y.next=2;break}return y.abrupt("return",null);case 2:return y.next=4,this.services.channelMetadataClient.getChannelMetadata(this.conversation.sid,this.sid);case 4:return y.abrupt("return",y.sent);case 5:case"end":return y.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()}]),S}(M.ReplayEventEmitter);ge.default(ir,"updated","updated"),Me([L.deprecated("getMediaByCategory","getMediaByCategories"),fe("design:type",Function),fe("design:paramtypes",[Array]),fe("design:returntype",Array)],ir.prototype,"getMediaByCategory",null),Me([h.validateTypes([h.nonEmptyString,"undefined"]),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",Ue)],ir.prototype,"getEmailBody",null),Me([h.validateTypes([h.nonEmptyString,"undefined"]),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",Ue)],ir.prototype,"getEmailHistory",null),Me([h.validateTypesAsync("string"),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],ir.prototype,"updateBody",null),Me([h.validateTypesAsync(Lt),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",Promise)],ir.prototype,"updateAttributes",null),Me([L.deprecated("attachTemporaryUrlsFor","getTemporaryContentUrlsForMedia"),fe("design:type",Function),fe("design:paramtypes",[Array]),fe("design:returntype",Promise)],ir.prototype,"attachTemporaryUrlsFor",null),Me([h.validateTypesAsync(h.nonEmptyArray("media",Ue)),fe("design:type",Function),fe("design:paramtypes",[Array]),fe("design:returntype",J.CancellablePromise)],ir.prototype,"getTemporaryContentUrlsForMedia",null),Me([h.validateTypesAsync(h.nonEmptyArray("strings","string")),fe("design:type",Function),fe("design:paramtypes",[Array]),fe("design:returntype",J.CancellablePromise)],ir.prototype,"getTemporaryContentUrlsForMediaSids",null);function Wn(w,k){var S=Object.keys(w);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(w);k&&(m=m.filter(function(v){return Object.getOwnPropertyDescriptor(w,v).enumerable})),S.push.apply(S,m)}return S}function hi(w){for(var k=1;k<arguments.length;k++){var S=arguments[k]!=null?arguments[k]:{};k%2?Wn(Object(S),!0).forEach(function(m){ge.default(w,m,S[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(w,Object.getOwnPropertyDescriptors(S)):Wn(Object(S)).forEach(function(m){Object.defineProperty(w,m,Object.getOwnPropertyDescriptor(S,m))})}return w}function $a(w,k){var S=typeof Symbol<"u"&&w[Symbol.iterator]||w["@@iterator"];if(!S){if(Array.isArray(w)||(S=Kr(w))||k&&w&&typeof w.length=="number"){S&&(w=S);var m=0,v=function(){};return{s:v,n:function(){return m>=w.length?{done:!0}:{done:!1,value:w[m++]}},e:function(T){throw T},f:v}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
461
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,g=!1,y;return{s:function(){S=S.call(w)},n:function(){var T=S.next();return _=T.done,T},e:function(T){g=!0,y=T},f:function(){try{!_&&S.return!=null&&S.return()}finally{if(g)throw y}}}}function Kr(w,k){if(w){if(typeof w=="string")return Yi(w,k);var S=Object.prototype.toString.call(w).slice(8,-1);if(S==="Object"&&w.constructor&&(S=w.constructor.name),S==="Map"||S==="Set")return Array.from(w);if(S==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(S))return Yi(w,k)}}function Yi(w,k){(k==null||k>w.length)&&(k=w.length);for(var S=0,m=new Array(k);S<k;S++)m[S]=w[S];return m}function Oa(w){var k=Vn();return function(){var m=we.default(w),v;if(k){var _=we.default(this).constructor;v=Reflect.construct(m,arguments,_)}else v=m.apply(this,arguments);return Te.default(this,v)}}function Vn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Er=Kt.scope("Messages"),Ia=function(w){be.default(S,w);var k=Oa(S);function S(m,v,_){var g;return De.default(this,S),g=k.call(this),g.conversation=m,g.configuration=v,g.services=_,g.messagesByIndex=new Map,g.messagesListPromise=null,g}return $e.default(S,[{key:"subscribe",value:function(){var m=ae.default(G.default.mark(function _(g){var y=this,b;return G.default.wrap(function($){for(;;)switch($.prev=$.next){case 0:if(!this.messagesListPromise){$.next=2;break}return $.abrupt("return",this.messagesListPromise);case 2:return this.messagesListPromise=typeof g=="string"?this.services.syncClient.list({id:g,mode:"open_existing"}):Promise.resolve(g),$.prev=3,$.next=6,this.messagesListPromise;case 6:return b=$.sent,b.on("itemAdded",function(H){Er.debug("".concat(y.conversation.sid," itemAdded: ").concat(H.item.index));var K={self:"".concat(y.conversation._links.messages,"/").concat(H.item.data.sid),conversation:y.conversation._links.self,messages_receipts:"".concat(y.conversation._links.messages,"/").concat(H.item.data.sid,"/Receipts")},re=new ir(H.item.index,H.item.data,y.conversation,K,y.configuration,y.services);if(y.messagesByIndex.has(re.index)){Er.debug("Message arrived, but is already known and ignored",y.conversation.sid,re.index);return}y.messagesByIndex.set(re.index,re),re.on("updated",function(ue){return y.emit("messageUpdated",ue)}),y.emit("messageAdded",re)}),b.on("itemRemoved",function(H){Er.debug("#{this.conversation.sid} itemRemoved: ".concat(H.index));var K=H.index;if(y.messagesByIndex.has(K)){var re=y.messagesByIndex.get(K);if(!re)return;y.messagesByIndex.delete(re.index),re.removeAllListeners("updated"),y.emit("messageRemoved",re)}}),b.on("itemUpdated",function(H){Er.debug("".concat(y.conversation.sid," itemUpdated: ").concat(H.item.index));var K=y.messagesByIndex.get(H.item.index);K&&K._update(H.item.data)}),$.abrupt("return",b);case 13:throw $.prev=13,$.t0=$.catch(3),this.messagesListPromise=null,this.services.syncClient.connectionState!=="disconnected"&&Er.error("Failed to get messages object for conversation",this.conversation.sid,$.t0),Er.debug("ERROR: Failed to get messages object for conversation",this.conversation.sid,$.t0),$.t0;case 19:case"end":return $.stop()}},_,this,[[3,13]])}));function v(_){return m.apply(this,arguments)}return v}()},{key:"unsubscribe",value:function(){var m=ae.default(G.default.mark(function _(){var g;return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(this.messagesListPromise){b.next=2;break}return b.abrupt("return");case 2:return b.next=4,this.messagesListPromise;case 4:g=b.sent,g.close(),this.messagesListPromise=null;case 7:case"end":return b.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"sendV2",value:function(v){var _=this;return Er.debug("Sending message V2",v.mediaContent,v.attributes,v.emailOptions),new J.CancellablePromise(function(){var g=ae.default(G.default.mark(function y(b,T,$){var H,K,re,ue,Xe,lt,C,A,D,W,V,he;return G.default.wrap(function(Ee){for(;;)switch(Ee.prev=Ee.next){case 0:K=[],re=[],$(function(){re.forEach(function(Fe){return Fe.cancel()})}),ue=$a(v.mediaContent),Ee.prev=4,ue.s();case 6:if((Xe=ue.n()).done){Ee.next=25;break}return lt=te.default(Xe.value,2),C=lt[0],A=lt[1],Ee.prev=8,Er.debug("Adding media to a message as ".concat(A instanceof FormData?"FormData":"SendMediaOptions"),A),V=A instanceof FormData?_.services.mcsClient.postFormData(A,C):_.services.mcsClient.post((D=A.contentType)!==null&&D!==void 0?D:"",(W=A.media)!==null&&W!==void 0?W:"",C,A.filename),re.push(V),Ee.t0=K,Ee.next=15,V;case 15:Ee.t1=Ee.sent,Ee.t0.push.call(Ee.t0,Ee.t1),Ee.next=23;break;case 19:return Ee.prev=19,Ee.t2=Ee.catch(8),T(Ee.t2),Ee.abrupt("return");case 23:Ee.next=6;break;case 25:Ee.next=30;break;case 27:Ee.prev=27,Ee.t3=Ee.catch(4),ue.e(Ee.t3);case 30:return Ee.prev=30,ue.f(),Ee.finish(30);case 33:return he=_.services.commandExecutor.mutateResource("post",_.conversation._links.messages,{body:v.text,subject:(H=v.emailOptions)===null||H===void 0?void 0:H.subject,media_sids:K.map(function(Fe){return Fe.sid}),attributes:typeof v.attributes<"u"?JSON.stringify(v.attributes):void 0,content_sid:v.contentSid,content_variables:typeof v.contentVariables<"u"?JSON.stringify(v.contentVariables.reduce(function(Fe,et){return hi(hi({},Fe),{},ge.default({},et.name,et.value))},{})):void 0}),Ee.prev=34,Ee.t4=b,Ee.next=38,he;case 38:Ee.t5=Ee.sent,(0,Ee.t4)(Ee.t5),Ee.next=45;break;case 42:Ee.prev=42,Ee.t6=Ee.catch(34),T(Ee.t6);case 45:case"end":return Ee.stop()}},y,null,[[4,27,30,33],[8,19],[34,42]])}));return function(y,b,T){return g.apply(this,arguments)}}())}},{key:"send",value:function(){var m=ae.default(G.default.mark(function _(g){var y,b,T=arguments;return G.default.wrap(function(H){for(;;)switch(H.prev=H.next){case 0:return y=T.length>1&&T[1]!==void 0?T[1]:{},b=T.length>2?T[2]:void 0,Er.debug("Sending text message",g,y,b),H.abrupt("return",this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{body:g??"",attributes:typeof y<"u"?JSON.stringify(y):void 0,subject:b==null?void 0:b.subject}));case 4:case"end":return H.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"sendMedia",value:function(){var m=ae.default(G.default.mark(function _(g){var y,b,T,$,H,K=arguments;return G.default.wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:if(T=K.length>1&&K[1]!==void 0?K[1]:{},$=K.length>2?K[2]:void 0,Er.debug("Sending media message",g,T,$),Er.debug("Sending media message as ".concat(g instanceof FormData?"FormData":"SendMediaOptions"),g,T),!(g instanceof FormData)){ue.next=10;break}return ue.next=7,this.services.mcsClient.postFormData(g);case 7:ue.t0=ue.sent,ue.next=13;break;case 10:return ue.next=12,this.services.mcsClient.post((y=g.contentType)!==null&&y!==void 0?y:"",(b=g.media)!==null&&b!==void 0?b:"","media",g.filename);case 12:ue.t0=ue.sent;case 13:return H=ue.t0,ue.next=16,this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{media_sids:[H.sid],attributes:typeof T<"u"?JSON.stringify(T):void 0});case 16:return ue.abrupt("return",ue.sent);case 17:case"end":return ue.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"getMessages",value:function(){var m=ae.default(G.default.mark(function _(g,y){var b,T=arguments;return G.default.wrap(function(H){for(;;)switch(H.prev=H.next){case 0:return b=T.length>2&&T[2]!==void 0?T[2]:"backwards",H.abrupt("return",this._getMessages(g,y,b));case 2:case"end":return H.stop()}},_,this)}));function v(_,g){return m.apply(this,arguments)}return v}()},{key:"_wrapPaginator",value:function(v,_,g){var y=this,b=v==="desc",T=function(){return _.nextPage().then(function(K){return y._wrapPaginator(v,K,g)})},$=function(){return _.prevPage().then(function(K){return y._wrapPaginator(v,K,g)})};return g(_.items).then(function(H){return{items:H.sort(function(K,re){return K.index-re.index}),hasPrevPage:b?_.hasNextPage:_.hasPrevPage,hasNextPage:b?_.hasPrevPage:_.hasNextPage,prevPage:b?T:$,nextPage:b?$:T}})}},{key:"_upsertMessage",value:function(v,_){var g=this,y=this.messagesByIndex.get(v);if(y)return y;var b={self:"".concat(this.conversation._links.messages,"/").concat(_.sid),conversation:this.conversation._links.self,messages_receipts:"".concat(this.conversation._links.messages,"/").concat(_.sid,"/Receipts")},T=new ir(v,_,this.conversation,b,this.configuration,this.services);return this.messagesByIndex.set(T.index,T),T.on("updated",function($){return g.emit("messageUpdated",$)}),T}},{key:"_getMessages",value:function(){var m=ae.default(G.default.mark(function _(){var g=this,y,b,T,$,H,K,re=arguments;return G.default.wrap(function(Xe){for(;;)switch(Xe.prev=Xe.next){case 0:return y=re.length>0&&re[0]!==void 0?re[0]:30,b=re.length>1&&re[1]!==void 0?re[1]:"end",T=re.length>2&&re[2]!==void 0?re[2]:"forward",$=T==="backwards"?"desc":"asc",Xe.next=6,this.messagesListPromise;case 6:return H=Xe.sent,Xe.next=9,H==null?void 0:H.getItems({from:b!=="end"?b:void 0,pageSize:y,order:$,limit:y});case 9:return K=Xe.sent,Xe.next=12,this._wrapPaginator($,K,function(lt){return Promise.all(lt.map(function(C){return g._upsertMessage(C.index,C.data)}))});case 12:return Xe.abrupt("return",Xe.sent);case 13:case"end":return Xe.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()}]),S}(M.ReplayEventEmitter),rn=function(){function w(k){De.default(this,w),ge.default(this,"attributes",{}),ge.default(this,"mediaContent",[]),ge.default(this,"emailOptions",{}),this.messagesEntity=k}return $e.default(w,[{key:"send",value:function(){var S=this;return new J.CancellablePromise(function(){var m=ae.default(G.default.mark(function v(_,g,y){var b,T;return G.default.wrap(function(H){for(;;)switch(H.prev=H.next){case 0:return b=S.messagesEntity.sendV2(S),y(function(){return b.cancel()}),H.prev=2,H.next=5,b;case 5:T=H.sent,_(Ct(T.index)),H.next=12;break;case 9:H.prev=9,H.t0=H.catch(2),g(H.t0);case 12:case"end":return H.stop()}},v,null,[[2,9]])}));return function(v,_,g){return m.apply(this,arguments)}}())}}]),w}(),ar=function(){function w(k,S){De.default(this,w),this.limits=k,this.message=new rn(S),this.emailBodies=new Map,this.emailHistories=new Map}return $e.default(w,[{key:"setBody",value:function(S){return this.message.text=S,this}},{key:"setSubject",value:function(S){return this.message.emailOptions.subject=S,this}},{key:"setAttributes",value:function(S){return this.message.attributes=S,this}},{key:"setEmailBody",value:function(S,m){return this.emailBodies.set(S,m),this}},{key:"setEmailHistory",value:function(S,m){return this.emailHistories.set(S,m),this}},{key:"setContentTemplate",value:function(S){var m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return this.message.contentSid=S,this.message.contentVariables=m,this}},{key:"addMedia",value:function(S){if(typeof FormData>"u"&&S instanceof FormData)throw new Error("Could not add FormData content whilst not in a browser");if(!(S instanceof FormData)){var m=S;if(!m.contentType||!m.media)throw new Error("Media content in SendMediaOptions must contain non-empty contentType and media")}return this.message.mediaContent.push(["media",S]),this}},{key:"build",value:function(){var S=this;if(this.emailBodies.forEach(function(m,v){if(!S.limits.emailBodiesAllowedContentTypes.includes(v))throw new Error("Unsupported email body content type ".concat(v))}),this.emailHistories.forEach(function(m,v){if(!S.limits.emailHistoriesAllowedContentTypes.includes(v))throw new Error("Unsupported email history content type ".concat(v))}),this.emailBodies.size>this.limits.emailBodiesAllowedContentTypes.length)throw new Error("Too many email bodies attached to the message (".concat(this.emailBodies.size," > ").concat(this.limits.emailBodiesAllowedContentTypes.length,")"));if(this.emailHistories.size>this.limits.emailHistoriesAllowedContentTypes.length)throw new Error("Too many email histories attached to the message (".concat(this.emailHistories.size," > ").concat(this.limits.emailHistoriesAllowedContentTypes.length,")"));if(this.message.mediaContent.length>this.limits.mediaAttachmentsCountLimit)throw new Error("Too many media attachments in the message (".concat(this.message.mediaContent.length," > ").concat(this.limits.mediaAttachmentsCountLimit,")"));return this.emailBodies.forEach(function(m){S.message.mediaContent.push(["body",m])}),this.emailHistories.forEach(function(m){S.message.mediaContent.push(["history",m])}),this.message}},{key:"buildAndSend",value:function(){return this.build().send()}}]),w}();Me([h.validateTypes("string"),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",ar)],ar.prototype,"setBody",null),Me([h.validateTypes("string"),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",ar)],ar.prototype,"setSubject",null),Me([h.validateTypes(Lt),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",ar)],ar.prototype,"setAttributes",null),Me([h.validateTypes("string",[FormData,hr]),fe("design:type",Function),fe("design:paramtypes",[String,Object]),fe("design:returntype",ar)],ar.prototype,"setEmailBody",null),Me([h.validateTypes("string",[FormData,hr]),fe("design:type",Function),fe("design:paramtypes",[String,Object]),fe("design:returntype",ar)],ar.prototype,"setEmailHistory",null),Me([h.validateTypes("string",[h.array("content variables",Ye),"undefined"]),fe("design:type",Function),fe("design:paramtypes",[String,Array]),fe("design:returntype",ar)],ar.prototype,"setContentTemplate",null),Me([h.validateTypes([FormData,hr]),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",ar)],ar.prototype,"addMedia",null);function vi(w,k){var S=typeof Symbol<"u"&&w[Symbol.iterator]||w["@@iterator"];if(!S){if(Array.isArray(w)||(S=Jr(w))||k&&w&&typeof w.length=="number"){S&&(w=S);var m=0,v=function(){};return{s:v,n:function(){return m>=w.length?{done:!0}:{done:!1,value:w[m++]}},e:function(T){throw T},f:v}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
462
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,g=!1,y;return{s:function(){S=S.call(w)},n:function(){var T=S.next();return _=T.done,T},e:function(T){g=!0,y=T},f:function(){try{!_&&S.return!=null&&S.return()}finally{if(g)throw y}}}}function Jr(w,k){if(w){if(typeof w=="string")return Xi(w,k);var S=Object.prototype.toString.call(w).slice(8,-1);if(S==="Object"&&w.constructor&&(S=w.constructor.name),S==="Map"||S==="Set")return Array.from(w);if(S==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(S))return Xi(w,k)}}function Xi(w,k){(k==null||k>w.length)&&(k=w.length);for(var S=0,m=new Array(k);S<k;S++)m[S]=w[S];return m}function Pa(w){var k=Aa();return function(){var m=we.default(w),v;if(k){var _=we.default(this).constructor;v=Reflect.construct(m,arguments,_)}else v=m.apply(this,arguments);return Te.default(this,v)}}function Aa(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ar={lastMessage:"lastMessage",attributes:"attributes",createdBy:"createdBy",dateCreated:"dateCreated",dateUpdated:"dateUpdated",friendlyName:"friendlyName",lastConsumedMessageIndex:"lastConsumedMessageIndex",notificationLevel:"notificationLevel",sid:"sid",status:"status",uniqueName:"uniqueName",state:"state",bindings:"bindings"},At=function(w){be.default(S,w);var k=Pa(S);function S(m,v,_,g,y){var b,T,$;De.default(this,S),$=k.call(this),$.sid=v,$._links=_,$._configuration=g,$._services=y,$._entityName=m.channel,$._internalState={uniqueName:m.uniqueName||null,status:"notParticipating",attributes:(b=m.attributes)!==null&&b!==void 0?b:{},createdBy:m.createdBy,dateCreated:kt(m.dateCreated),dateUpdated:kt(m.dateUpdated),friendlyName:m.friendlyName||null,lastReadMessageIndex:Number.isInteger(m.lastConsumedMessageIndex)?m.lastConsumedMessageIndex:null,bindings:(T=m.bindings)!==null&&T!==void 0?T:{}},m.notificationLevel&&($._internalState.notificationLevel=m.notificationLevel);var H={participants:$._links.participants};return $._participants=new Map,$._participantsEntity=new X(Ve.default($),$._participants,H,$._configuration,$._services),$._participantsEntity.on("participantJoined",function(K){return $.emit("participantJoined",K)}),$._participantsEntity.on("participantLeft",function(K){return $.emit("participantLeft",K)}),$._participantsEntity.on("participantUpdated",function(K){return $.emit("participantUpdated",K)}),$._messagesEntity=new Ia(Ve.default($),g,y),$._messagesEntity.on("messageAdded",function(K){return $._onMessageAdded(K)}),$._messagesEntity.on("messageUpdated",function(K){return $.emit("messageUpdated",K)}),$._messagesEntity.on("messageRemoved",function(K){return $.emit("messageRemoved",K)}),$}return $e.default(S,[{key:"uniqueName",get:function(){return this._internalState.uniqueName}},{key:"status",get:function(){return this._internalState.status}},{key:"friendlyName",get:function(){return this._internalState.friendlyName}},{key:"dateUpdated",get:function(){return this._internalState.dateUpdated}},{key:"dateCreated",get:function(){return this._internalState.dateCreated}},{key:"createdBy",get:function(){var v;return(v=this._internalState.createdBy)!==null&&v!==void 0?v:""}},{key:"attributes",get:function(){return this._internalState.attributes}},{key:"lastReadMessageIndex",get:function(){return this._internalState.lastReadMessageIndex}},{key:"lastMessage",get:function(){var v;return(v=this._internalState.lastMessage)!==null&&v!==void 0?v:void 0}},{key:"notificationLevel",get:function(){var v;return(v=this._internalState.notificationLevel)!==null&&v!==void 0?v:"default"}},{key:"bindings",get:function(){return this._internalState.bindings}},{key:"limits",get:function(){return this._configuration.limits}},{key:"state",get:function(){return this._internalState.state}},{key:"_statusSource",get:function(){return this._dataSource}},{key:"add",value:function(){var m=ae.default(G.default.mark(function _(g,y){return G.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.abrupt("return",this._participantsEntity.add(g,y??{}));case 1:case"end":return T.stop()}},_,this)}));function v(_,g){return m.apply(this,arguments)}return v}()},{key:"addNonChatParticipant",value:function(){var m=ae.default(G.default.mark(function _(g,y){var b,T,$=arguments;return G.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:return b=$.length>2&&$[2]!==void 0?$[2]:{},T=$.length>3&&$[3]!==void 0?$[3]:{},K.abrupt("return",this._participantsEntity.addNonChatParticipant(g,y,b??{},T??{}));case 3:case"end":return K.stop()}},_,this)}));function v(_,g){return m.apply(this,arguments)}return v}()},{key:"advanceLastReadMessageIndex",value:function(){var m=ae.default(G.default.mark(function _(g){var y;return G.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.next=2,this._subscribeStreams();case 2:if(!(g<((y=this.lastReadMessageIndex)!==null&&y!==void 0?y:0))){T.next=6;break}return T.next=5,this._setLastReadMessageIndex(this.lastReadMessageIndex);case 5:return T.abrupt("return",T.sent);case 6:return T.next=8,this._setLastReadMessageIndex(g);case 8:return T.abrupt("return",T.sent);case 9:case"end":return T.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"delete",value:function(){var m=ae.default(G.default.mark(function _(){return G.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._services.commandExecutor.mutateResource("delete",this._links.self);case 2:return y.abrupt("return",this);case 3:case"end":return y.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"getAttributes",value:function(){var m=ae.default(G.default.mark(function _(){return G.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._subscribe();case 2:return y.abrupt("return",this.attributes);case 3:case"end":return y.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"getMessages",value:function(){var m=ae.default(G.default.mark(function _(g,y,b){return G.default.wrap(function($){for(;;)switch($.prev=$.next){case 0:return $.next=2,this._subscribeStreams();case 2:return $.abrupt("return",this._messagesEntity.getMessages(g,y,b));case 3:case"end":return $.stop()}},_,this)}));function v(_,g,y){return m.apply(this,arguments)}return v}()},{key:"getParticipants",value:function(){var m=ae.default(G.default.mark(function _(){return G.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._subscribeStreams();case 2:return y.abrupt("return",this._participantsEntity.getParticipants());case 3:case"end":return y.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"getParticipantsCount",value:function(){var m=ae.default(G.default.mark(function _(){var g,y,b;return G.default.wrap(function($){for(;;)switch($.prev=$.next){case 0:return y=new st(this._configuration.links.conversations).path(this.sid).build(),$.next=3,this._services.network.get(y);case 3:return b=$.sent,$.abrupt("return",(g=b.body.participants_count)!==null&&g!==void 0?g:0);case 5:case"end":return $.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"getParticipantBySid",value:function(){var m=ae.default(G.default.mark(function _(g){return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.abrupt("return",this._participantsEntity.getParticipantBySid(g));case 1:case"end":return b.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"getParticipantByIdentity",value:function(){var m=ae.default(G.default.mark(function _(){var g,y=arguments;return G.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return g=y.length>0&&y[0]!==void 0?y[0]:"",T.abrupt("return",this._participantsEntity.getParticipantByIdentity(g??""));case 2:case"end":return T.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"getMessagesCount",value:function(){var m=ae.default(G.default.mark(function _(){var g,y,b;return G.default.wrap(function($){for(;;)switch($.prev=$.next){case 0:return y=new st(this._configuration.links.conversations).path(this.sid).build(),$.next=3,this._services.network.get(y);case 3:return b=$.sent,$.abrupt("return",(g=b.body.messages_count)!==null&&g!==void 0?g:0);case 5:case"end":return $.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"getUnreadMessagesCount",value:function(){var m=ae.default(G.default.mark(function _(){var g,y,b;return G.default.wrap(function($){for(;;)switch($.prev=$.next){case 0:return g=new st(this._configuration.links.myConversations).path(this.sid).build(),$.next=3,this._services.network.get(g);case 3:if(y=$.sent,y.body.conversation_sid===this.sid){$.next=6;break}throw new Error("Conversation was not found in the user conversations list");case 6:if(b=y.body.unread_messages_count,typeof b!="number"){$.next=9;break}return $.abrupt("return",b);case 9:return $.abrupt("return",null);case 10:case"end":return $.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"join",value:function(){var m=ae.default(G.default.mark(function _(){return G.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._services.commandExecutor.mutateResource("post",this._links.participants,{identity:this._configuration.userIdentity});case 2:return y.abrupt("return",this);case 3:case"end":return y.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"leave",value:function(){var m=ae.default(G.default.mark(function _(){return G.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this._internalState.status!=="joined"){y.next=3;break}return y.next=3,this._services.commandExecutor.mutateResource("delete","".concat(this._links.participants,"/").concat(encodeURIComponent(this._configuration.userIdentity)));case 3:return y.abrupt("return",this);case 4:case"end":return y.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"removeParticipant",value:function(){var m=ae.default(G.default.mark(function _(g){return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._participantsEntity.remove(typeof g=="string"?g:g.sid);case 2:case"end":return b.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"sendMessage",value:function(){var m=ae.default(G.default.mark(function _(g,y,b){var T,$,H,K;return G.default.wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:if(!(typeof g=="string"||g===null)){ue.next=5;break}return ue.next=3,this._messagesEntity.send(g,y,b);case 3:return H=ue.sent,ue.abrupt("return",($=Ct(H.index))!==null&&$!==void 0?$:0);case 5:return ue.next=7,this._messagesEntity.sendMedia(g,y,b);case 7:return K=ue.sent,ue.abrupt("return",(T=Ct(K.index))!==null&&T!==void 0?T:0);case 9:case"end":return ue.stop()}},_,this)}));function v(_,g,y){return m.apply(this,arguments)}return v}()},{key:"prepareMessage",value:function(){return new ar(this.limits,this._messagesEntity)}},{key:"setAllMessagesRead",value:function(){var m=ae.default(G.default.mark(function _(){var g;return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._subscribeStreams();case 2:return b.next=4,this.getMessages(1);case 4:if(g=b.sent,!(g.items.length>0)){b.next=7;break}return b.abrupt("return",this.advanceLastReadMessageIndex(g.items[0].index));case 7:return b.abrupt("return",0);case 8:case"end":return b.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"setAllMessagesUnread",value:function(){var m=ae.default(G.default.mark(function _(){return G.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._subscribeStreams();case 2:return y.next=4,this._setLastReadMessageIndex(null);case 4:return y.abrupt("return",y.sent);case 5:case"end":return y.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"setUserNotificationLevel",value:function(){var m=ae.default(G.default.mark(function _(g){return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{notification_level:g});case 2:case"end":return b.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"typing",value:function(){return this._services.typingIndicator.send(this.sid)}},{key:"updateAttributes",value:function(){var m=ae.default(G.default.mark(function _(g){return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._services.commandExecutor.mutateResource("post",this._links.self,{attributes:g!==void 0?JSON.stringify(g):void 0});case 2:return b.abrupt("return",this);case 3:case"end":return b.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"updateFriendlyName",value:function(){var m=ae.default(G.default.mark(function _(g){return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(this._internalState.friendlyName===g){b.next=3;break}return b.next=3,this._services.commandExecutor.mutateResource("post",this._links.self,{friendly_name:g});case 3:return b.abrupt("return",this);case 4:case"end":return b.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"updateLastReadMessageIndex",value:function(){var m=ae.default(G.default.mark(function _(g){return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._subscribeStreams();case 2:return b.abrupt("return",this._setLastReadMessageIndex(g));case 3:case"end":return b.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"updateUniqueName",value:function(){var m=ae.default(G.default.mark(function _(g){return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(this._internalState.uniqueName===g){b.next=4;break}return g||(g=""),b.next=4,this._services.commandExecutor.mutateResource("post",this._links.self,{unique_name:g});case 4:return b.abrupt("return",this);case 5:case"end":return b.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"_subscribe",value:function(){var m=ae.default(G.default.mark(function _(){var g=this;return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(!this._entityPromise){b.next=2;break}return b.abrupt("return",this._entityPromise);case 2:return this._entityPromise=this._services.syncClient.document({id:this._entityName,mode:"open_existing"}),b.prev=3,b.next=6,this._entityPromise;case 6:return this._entity=b.sent,this._entity.on("updated",function(T){return g._update(T.data)}),this._entity.on("removed",function(){return g.emit("removed",g)}),this._update(this._entity.data),b.abrupt("return",this._entity);case 13:throw b.prev=13,b.t0=b.catch(3),this._entity=null,this._entityPromise=null,this._services.syncClient.connectionState!="disconnected"&&S._logger.error("Failed to get conversation object",b.t0),S._logger.debug("ERROR: Failed to get conversation object",b.t0),b.t0;case 20:case"end":return b.stop()}},_,this,[[3,13]])}));function v(){return m.apply(this,arguments)}return v}()},{key:"_fetchStreams",value:function(){var m=ae.default(G.default.mark(function _(){var g,y,b;return G.default.wrap(function($){for(;;)switch($.prev=$.next){case 0:return $.next=2,this._subscribe();case 2:return S._logger.trace("_streamsAvailable, this.entity.data=",(g=this._entity)===null||g===void 0?void 0:g.data),b=(y=this._entity)===null||y===void 0?void 0:y.data,$.next=6,this._services.syncClient.list({id:b.messages,mode:"open_existing"});case 6:return this._messagesList=$.sent,$.next=9,this._services.syncClient.map({id:b.roster,mode:"open_existing"});case 9:this._participantsMap=$.sent;case 10:case"end":return $.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"_subscribeStreams",value:function(){var m=ae.default(G.default.mark(function _(){var g,y,b,T,$,H,K;return G.default.wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:return ue.prev=0,ue.next=3,this._subscribe();case 3:return S._logger.trace("_subscribeStreams, this.entity.data=",(g=this._entity)===null||g===void 0?void 0:g.data),$=(y=this._entity)===null||y===void 0?void 0:y.data,H=$.messages,K=$.roster,ue.next=9,Promise.all([this._messagesEntity.subscribe((b=this._messagesList)!==null&&b!==void 0?b:H),this._participantsEntity.subscribe((T=this._participantsMap)!==null&&T!==void 0?T:K)]);case 9:ue.next=16;break;case 11:throw ue.prev=11,ue.t0=ue.catch(0),this._services.syncClient.connectionState!=="disconnected"&&S._logger.error("Failed to subscribe on conversation objects",this.sid,ue.t0),S._logger.debug("ERROR: Failed to subscribe on conversation objects",this.sid,ue.t0),ue.t0;case 16:case"end":return ue.stop()}},_,this,[[0,11]])}));function v(){return m.apply(this,arguments)}return v}()},{key:"_unsubscribe",value:function(){var m=ae.default(G.default.mark(function _(){return G.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(!this._entity){y.next=5;break}return y.next=3,this._entity.close();case 3:this._entity=null,this._entityPromise=null;case 5:return y.abrupt("return",Promise.all([this._participantsEntity.unsubscribe(),this._messagesEntity.unsubscribe()]));case 6:case"end":return y.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"_setStatus",value:function(v,_){var g=this;if(this._dataSource=_,this._internalState.status!==v){if(this._internalState.status=v,v==="joined"){this._subscribeStreams().catch(function(y){if(S._logger.debug("ERROR while setting conversation status "+v,y),g._services.syncClient.connectionState!=="disconnected")throw y});return}this._entityPromise&&this._unsubscribe().catch(function(y){if(S._logger.debug("ERROR while setting conversation status "+v,y),g._services.syncClient.connectionState!=="disconnected")throw y})}}},{key:"_update",value:function(v){var _,g,y,b,T;S._logger.trace("_update",v),S.preprocessUpdate(v,this.sid);for(var $=new Set,H=0,K=Object.keys(v);H<K.length;H++){var re=K[H],ue=Ar[re];if(ue)switch(ue){case Ar.status:if(!v.status||v.status==="unknown"||this._internalState.status===v.status)break;this._internalState.status=v.status,$.add(ue);break;case Ar.attributes:if(je.default(this._internalState.attributes,v.attributes))break;this._internalState.attributes=v.attributes,$.add(ue);break;case Ar.lastConsumedMessageIndex:if(v.lastConsumedMessageIndex===void 0||v.lastConsumedMessageIndex===this._internalState.lastReadMessageIndex)break;this._internalState.lastReadMessageIndex=v.lastConsumedMessageIndex,$.add("lastReadMessageIndex");break;case Ar.lastMessage:if(this._internalState.lastMessage&&!v.lastMessage){delete this._internalState.lastMessage,$.add(ue);break}this._internalState.lastMessage=this._internalState.lastMessage||{},((_=v.lastMessage)===null||_===void 0?void 0:_.index)!==void 0&&v.lastMessage.index!==this._internalState.lastMessage.index&&(this._internalState.lastMessage.index=v.lastMessage.index,$.add(ue)),((g=v.lastMessage)===null||g===void 0?void 0:g.timestamp)!==void 0&&((y=this._internalState.lastMessage)===null||y===void 0||(b=y.dateCreated)===null||b===void 0?void 0:b.getTime())!==v.lastMessage.timestamp.getTime()&&(this._internalState.lastMessage.dateCreated=v.lastMessage.timestamp,$.add(ue)),je.default(this._internalState.lastMessage,{})&&delete this._internalState.lastMessage;break;case Ar.state:var Xe=v.state||void 0;if(Xe!==void 0&&(Xe.dateUpdated=new Date(Xe.dateUpdated)),je.default(this._internalState.state,Xe))break;this._internalState.state=Xe,$.add(ue);break;case Ar.bindings:if(je.default(this._internalState.bindings,v.bindings))break;this._internalState.bindings=v.bindings,$.add(ue);break;default:var lt=v[re]instanceof Date,C=lt&&((T=this._internalState[ue])===null||T===void 0?void 0:T.getTime())===v[re].getTime(),A=!lt&&this[ue]===v[re];if(C||A)break;this._internalState[ue]=v[re],$.add(ue)}}$.size>0&&this.emit("updated",{conversation:this,updateReasons:ut.default($)})}},{key:"_onMessageAdded",value:function(v){var _=vi(this._participants.values()),g;try{for(_.s();!(g=_.n()).done;){var y=g.value;if(y.identity===v.author){y._endTyping();break}}}catch(b){_.e(b)}finally{_.f()}this.emit("messageAdded",v)}},{key:"_setLastReadMessageIndex",value:function(){var m=ae.default(G.default.mark(function _(g){var y;return G.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{last_read_message_index:g});case 2:return y=T.sent,T.abrupt("return",y.unread_messages_count);case 4:case"end":return T.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()}],[{key:"preprocessUpdate",value:function(v,_){try{typeof v.attributes=="string"?v.attributes=JSON.parse(v.attributes):v.attributes&&JSON.stringify(v.attributes)}catch{S._logger.warn("Retrieved malformed attributes from the server for conversation: "+_),v.attributes={}}try{v.dateCreated&&(v.dateCreated=new Date(v.dateCreated))}catch{S._logger.warn("Retrieved malformed dateCreated from the server for conversation: "+_),delete v.dateCreated}try{v.dateUpdated&&(v.dateUpdated=new Date(v.dateUpdated))}catch{S._logger.warn("Retrieved malformed dateUpdated from the server for conversation: "+_),delete v.dateUpdated}try{v.lastMessage&&v.lastMessage.timestamp&&(v.lastMessage.timestamp=new Date(v.lastMessage.timestamp))}catch{S._logger.warn("Retrieved malformed lastMessage.timestamp from the server for conversation: "+_),delete v.lastMessage.timestamp}}}]),S}(M.ReplayEventEmitter);ge.default(At,"participantJoined","participantJoined"),ge.default(At,"participantLeft","participantLeft"),ge.default(At,"participantUpdated","participantUpdated"),ge.default(At,"messageAdded","messageAdded"),ge.default(At,"messageRemoved","messageRemoved"),ge.default(At,"messageUpdated","messageUpdated"),ge.default(At,"typingEnded","typingEnded"),ge.default(At,"typingStarted","typingStarted"),ge.default(At,"updated","updated"),ge.default(At,"removed","removed"),ge.default(At,"_logger",Kt.scope("Conversation")),Me([h.validateTypesAsync(h.nonEmptyString,Xt),fe("design:type",Function),fe("design:paramtypes",[String,Object]),fe("design:returntype",Promise)],At.prototype,"add",null),Me([h.validateTypesAsync(h.nonEmptyString,h.nonEmptyString,Xt),fe("design:type",Function),fe("design:paramtypes",[String,String,Object,Object]),fe("design:returntype",Promise)],At.prototype,"addNonChatParticipant",null),Me([h.validateTypesAsync(h.nonNegativeInteger),fe("design:type",Function),fe("design:paramtypes",[Number]),fe("design:returntype",Promise)],At.prototype,"advanceLastReadMessageIndex",null),Me([h.validateTypesAsync(["undefined",h.nonNegativeInteger],["undefined",h.nonNegativeInteger],["undefined",h.literal("backwards","forward")]),fe("design:type",Function),fe("design:paramtypes",[Number,Number,String]),fe("design:returntype",Promise)],At.prototype,"getMessages",null),Me([h.validateTypesAsync(h.nonEmptyString),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],At.prototype,"getParticipantBySid",null),Me([h.validateTypesAsync(h.nonEmptyString),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],At.prototype,"getParticipantByIdentity",null),Me([h.validateTypesAsync([h.nonEmptyString,ee]),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",Promise)],At.prototype,"removeParticipant",null),Me([h.validateTypesAsync(["string",FormData,h.literal(null),h.objectSchema("media options",{contentType:h.nonEmptyString,media:h.custom(function(w){var k=typeof w=="string"&&w.length>0||w instanceof Uint8Array||w instanceof ArrayBuffer;return typeof Blob=="function"&&(k=k||w instanceof Blob),[k,"a non-empty string, an instance of Buffer or an instance of Blob"]})})],Xt,["undefined",h.literal(null),h.objectSchema("email attributes",{subject:[h.nonEmptyString,"undefined"]})]),fe("design:type",Function),fe("design:paramtypes",[Object,Object,Object]),fe("design:returntype",Promise)],At.prototype,"sendMessage",null),Me([h.validateTypesAsync(h.literal("default","muted")),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],At.prototype,"setUserNotificationLevel",null),Me([h.validateTypesAsync(Lt),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",Promise)],At.prototype,"updateAttributes",null),Me([h.validateTypesAsync("string"),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],At.prototype,"updateFriendlyName",null),Me([h.validateTypesAsync([h.literal(null),h.nonNegativeInteger]),fe("design:type",Function),fe("design:paramtypes",[Number]),fe("design:returntype",Promise)],At.prototype,"updateLastReadMessageIndex",null),Me([h.validateTypesAsync(["string",h.literal(null)]),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],At.prototype,"updateUniqueName",null);var mi=function(){function w(){var k=this;De.default(this,w),this._promise=new Promise(function(S,m){k._resolve=S,k._reject=m})}return $e.default(w,[{key:"promise",get:function(){return this._promise}},{key:"update",value:function(S){this._resolve(S)}},{key:"set",value:function(S){this.current=S,this._resolve(S)}},{key:"fail",value:function(S){this._reject(S)}}]),w}();function Hn(w,k){var S=typeof Symbol<"u"&&w[Symbol.iterator]||w["@@iterator"];if(!S){if(Array.isArray(w)||(S=Ma(w))||k&&w&&typeof w.length=="number"){S&&(w=S);var m=0,v=function(){};return{s:v,n:function(){return m>=w.length?{done:!0}:{done:!1,value:w[m++]}},e:function(T){throw T},f:v}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
463
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,g=!1,y;return{s:function(){S=S.call(w)},n:function(){var T=S.next();return _=T.done,T},e:function(T){g=!0,y=T},f:function(){try{!_&&S.return!=null&&S.return()}finally{if(g)throw y}}}}function Ma(w,k){if(w){if(typeof w=="string")return Yr(w,k);var S=Object.prototype.toString.call(w).slice(8,-1);if(S==="Object"&&w.constructor&&(S=w.constructor.name),S==="Map"||S==="Set")return Array.from(w);if(S==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(S))return Yr(w,k)}}function Yr(w,k){(k==null||k>w.length)&&(k=w.length);for(var S=0,m=new Array(k);S<k;S++)m[S]=w[S];return m}function gi(w,k){var S=Object.keys(w);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(w);k&&(m=m.filter(function(v){return Object.getOwnPropertyDescriptor(w,v).enumerable})),S.push.apply(S,m)}return S}function yi(w){for(var k=1;k<arguments.length;k++){var S=arguments[k]!=null?arguments[k]:{};k%2?gi(Object(S),!0).forEach(function(m){ge.default(w,m,S[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(w,Object.getOwnPropertyDescriptors(S)):gi(Object(S)).forEach(function(m){Object.defineProperty(w,m,Object.getOwnPropertyDescriptor(S,m))})}return w}function xa(w){var k=Na();return function(){var m=we.default(w),v;if(k){var _=we.default(this).constructor;v=Reflect.construct(m,arguments,_)}else v=m.apply(this,arguments);return Te.default(this,v)}}function Na(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var vr=Kt.scope("Conversations"),Qi=function(w){be.default(S,w);var k=xa(S);function S(m,v){var _;return De.default(this,S),_=k.call(this),ge.default(Ve.default(_),"conversations",new Map),ge.default(Ve.default(_),"myConversationsRead",new mi),ge.default(Ve.default(_),"tombstones",new Set),ge.default(Ve.default(_),"myConversationsFetched",!1),_.configuration=m,_.services=v,_}return $e.default(S,[{key:"addConversation",value:function(){var m=ae.default(G.default.mark(function _(g){var y,b,T,$,H,K,re,ue,Xe,lt;return G.default.wrap(function(A){for(;;)switch(A.prev=A.next){case 0:return $=typeof(g==null?void 0:g.attributes)<"u"?g.attributes:{},A.next=3,this.services.commandExecutor.mutateResource("post",this.configuration.links.conversations,{friendly_name:g.friendlyName,unique_name:g.uniqueName,attributes:typeof $<"u"?JSON.stringify($):void 0});case 3:if(H=A.sent,K=(y=H.sid)!==null&&y!==void 0?y:null,re=(b=(T=H.sync_objects)===null||T===void 0?void 0:T.conversation)!==null&&b!==void 0?b:null,ue=yi({self:H.url},H.links),Xe=this.conversations.get(K),!Xe){A.next=12;break}return A.next=11,Xe._subscribe();case 11:return A.abrupt("return",Xe);case 12:return lt=new At({channel:re,entityName:"",uniqueName:"",attributes:null,createdBy:"",friendlyName:"",lastConsumedMessageIndex:0,dateCreated:null,dateUpdated:null},K,ue,this.configuration,this.services),this.conversations.set(lt.sid,lt),this._registerForEvents(lt),A.next=17,lt._subscribe();case 17:return this.emit("conversationAdded",lt),A.abrupt("return",lt);case 19:case"end":return A.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"fetchConversations",value:function(){var m=ae.default(G.default.mark(function _(){var g=this,y,b,T,$,H,K,re;return G.default.wrap(function(Xe){for(;;)switch(Xe.prev=Xe.next){case 0:return Xe.prev=0,Xe.next=3,this._getMap();case 3:return y=Xe.sent,y.on("itemAdded",function(lt){vr.debug("itemAdded: ".concat(lt.item.key)),g._upsertConversation("sync",lt.item.key,lt.item.data)}),y.on("itemRemoved",function(lt){vr.debug("itemRemoved: ".concat(lt.key));var C=lt.key;g.myConversationsFetched||g.tombstones.add(C);var A=g.conversations.get(C);A&&(A.status==="joined"&&(A._setStatus("notParticipating","sync"),g.emit("conversationLeft",A)),g.conversations.delete(C),g.emit("conversationRemoved",A),A.emit("removed",A))}),y.on("itemUpdated",function(lt){vr.debug("itemUpdated: ".concat(lt.item.key)),g._upsertConversation("sync",lt.item.key,lt.item.data)}),Xe.next=9,this._fetchMyConversations();case 9:b=Xe.sent,T=[],$=Hn(b);try{for($.s();!(H=$.n()).done;)K=H.value,T.push(this._upsertConversation("rest",K.channel_sid,K))}catch(lt){$.e(lt)}finally{$.f()}return this.myConversationsRead.set(!0),Xe.next=16,Promise.all(T);case 16:return this.myConversationsFetched=!0,this.tombstones.clear(),vr.debug("The conversations list has been successfully fetched"),Xe.abrupt("return",this);case 22:throw Xe.prev=22,Xe.t0=Xe.catch(0),re="Failed to fetch the conversations list",this.services.syncClient.connectionState!=="disconnected"&&vr.error(re,Xe.t0),vr.debug("ERROR: ".concat(re),Xe.t0),Xe.t0;case 28:case"end":return Xe.stop()}},_,this,[[0,22]])}));function v(){return m.apply(this,arguments)}return v}()},{key:"getConversations",value:function(){var m=ae.default(G.default.mark(function _(){var g=this,y,b;return G.default.wrap(function($){for(;;)switch($.prev=$.next){case 0:return $.next=2,this._getMap();case 2:return y=$.sent,$.next=5,y.getItems();case 5:return b=$.sent,$.abrupt("return",this._wrapPaginator(b,function(H){return Promise.all(H.map(function(K){return g._upsertConversation("sync",K.key,K.data)}))}));case 7:case"end":return $.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"getConversation",value:function(){var m=ae.default(G.default.mark(function _(g){var y=this,b,T,$;return G.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:return K.next=2,this._getMap();case 2:return b=K.sent,K.next=5,b.getItems({key:g});case 5:return T=K.sent,$=T.items.map(function(re){return y._upsertConversation("sync",re.key,re.data)}),K.abrupt("return",$.length>0?$[0]:null);case 8:case"end":return K.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"getConversationByUniqueName",value:function(){var m=ae.default(G.default.mark(function _(g){var y,b,T,$,H;return G.default.wrap(function(re){for(;;)switch(re.prev=re.next){case 0:return y=new st(this.configuration.links.myConversations).path(g).build(),re.next=3,this.services.network.get(y);case 3:return b=re.sent,T=b.body,$=T.conversation_sid,H={entityName:null,lastConsumedMessageIndex:T.last_read_message_index,status:(T==null?void 0:T.status)||"unknown",friendlyName:T.friendly_name,dateUpdated:T.date_updated,dateCreated:T.date_created,uniqueName:T.unique_name,createdBy:T.created_by,attributes:T.attributes,channel:T.sync_objects.conversation,notificationLevel:T==null?void 0:T.notification_level,sid:$},re.abrupt("return",$?this._upsertConversation("sync",$,H):null);case 8:case"end":return re.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"peekConversation",value:function(){var m=ae.default(G.default.mark(function _(g){var y,b,T,$;return G.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:return y=new st(this.configuration.links.conversations).path(g).build(),K.next=3,this.services.network.get(y);case 3:return b=K.sent,T=b.body,$={entityName:null,status:(T==null?void 0:T.status)||"unknown",friendlyName:T.friendly_name,dateUpdated:T.date_updated,dateCreated:T.date_created,uniqueName:T.unique_name,createdBy:T.created_by,attributes:T.attributes,channel:"".concat(g,".channel"),sid:g},K.abrupt("return",this._upsertConversation("sync",g,$));case 7:case"end":return K.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"_getMap",value:function(){var m=ae.default(G.default.mark(function _(){return G.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this.services.syncClient.map({id:this.configuration.myConversations,mode:"open_existing"});case 2:return y.abrupt("return",y.sent);case 3:case"end":return y.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"_wrapPaginator",value:function(){var m=ae.default(G.default.mark(function _(g,y){var b=this,T;return G.default.wrap(function(H){for(;;)switch(H.prev=H.next){case 0:return H.next=2,y(g.items);case 2:return T=H.sent,H.abrupt("return",{items:T.filter(function(K){return K!==null}),hasNextPage:g.hasNextPage,hasPrevPage:g.hasPrevPage,nextPage:function(){return g.nextPage().then(function(re){return b._wrapPaginator(re,y)})},prevPage:function(){return g.prevPage().then(function(re){return b._wrapPaginator(re,y)})}});case 4:case"end":return H.stop()}},_)}));function v(_,g){return m.apply(this,arguments)}return v}()},{key:"_updateConversation",value:function(){var m=ae.default(G.default.mark(function _(g,y,b){var T,$,H;return G.default.wrap(function(re){for(;;)switch(re.prev=re.next){case 0:if(T=y._statusSource!==void 0&&g!==y._statusSource,$=g!=="rest"||y._statusSource==="sync",!(T&&$&&g!=="sync")){re.next=5;break}return vr.trace("upsertConversation: conversation is known from sync and came from REST, ignoring",{sid:y.sid,data:b.status,conversation:y.status}),re.abrupt("return");case 5:if(!(b.status==="joined"&&y.status!=="joined")){re.next=15;break}return y._setStatus("joined",g),H={},typeof b.notificationLevel<"u"&&(H.notificationLevel=b.notificationLevel),typeof b.lastConsumedMessageIndex<"u"&&(H.lastConsumedMessageIndex=b.lastConsumedMessageIndex),je.default(H,{})||y._update(H),re.next=13,y._subscribe();case 13:return this.emit("conversationJoined",y),re.abrupt("return");case 15:if(!(b.status==="notParticipating"&&y.status==="joined")){re.next=22;break}return y._setStatus("notParticipating",g),y._update(b),re.next=20,y._subscribe();case 20:return this.emit("conversationLeft",y),re.abrupt("return");case 22:if(b.status!=="notParticipating"){re.next=26;break}return re.next=25,y._subscribe();case 25:return re.abrupt("return");case 26:y._update(b);case 27:case"end":return re.stop()}},_,this)}));function v(_,g,y){return m.apply(this,arguments)}return v}()},{key:"_upsertConversation",value:function(){var m=ae.default(G.default.mark(function _(g,y,b){var T,$,H,K;return G.default.wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:if(vr.trace("upsertConversation called for ".concat(y),b),T=this.conversations.get(y),!T){ue.next=9;break}return vr.trace("upsertConversation: the conversation ".concat(T.sid," is known;")+"its status is known from the source ".concat(T._statusSource," ")+"and the update came from the source ".concat(g),T),ue.next=6,this._updateConversation(g,T,b);case 6:return ue.next=8,T._subscribe();case 8:return ue.abrupt("return",T);case 9:if(!(g==="rest"&&this.tombstones.has(y))){ue.next=12;break}return vr.trace("upsertChannel: the conversation is deleted but reappeared again from REST, ignoring",y),ue.abrupt("return",null);case 12:return vr.trace("upsertConversation: creating a local conversation object with sid "+y,b),$="".concat(this.configuration.links.conversations,"/").concat(y),H={self:$,messages:"".concat($,"/Messages"),participants:"".concat($,"/Participants")},K=new At(b,y,H,this.configuration,this.services),this.conversations.set(y,K),ue.prev=17,ue.next=20,K._subscribe();case 20:if(b.status!=="joined"){ue.next=23;break}return ue.next=23,K._fetchStreams();case 23:ue.next=32;break;case 25:if(ue.prev=25,ue.t0=ue.catch(17),ue.t0.name==="SyncError"){ue.next=29;break}throw ue.t0;case 29:return vr.trace("upsertChannel: the conversation is missing some Sync entity(ies), ignoring",y,ue.t0),this.conversations.delete(y),ue.abrupt("return",null);case 32:return this._registerForEvents(K),this.emit("conversationAdded",K),b.status==="joined"&&(K._setStatus("joined",g),this.emit("conversationJoined",K)),ue.abrupt("return",K);case 36:case"end":return ue.stop()}},_,this,[[17,25]])}));function v(_,g,y){return m.apply(this,arguments)}return v}()},{key:"_fetchMyConversations",value:function(){var m=ae.default(G.default.mark(function _(){var g,y,b,T,$,H;return G.default.wrap(function(re){for(;;)switch(re.prev=re.next){case 0:g=[],y=null;case 2:return T=new st(this.configuration.links.myConversations),y&&T.arg("PageToken",y),re.next=6,this.services.network.get(T.build());case 6:$=re.sent,H=(b=$.body)===null||b===void 0?void 0:b.conversations.map(function(ue){return{descriptor:ue,channel_sid:ue.conversation_sid,status:ue.status,channel:ue.sync_objects.conversation,messages:ue.sync_objects.messages,roster:"".concat(ue.conversation_sid,".roster"),lastConsumedMessageIndex:ue.last_read_message_index,notificationLevel:ue.notification_level}}),y=$.body.meta.next_token,g=[].concat(ut.default(g),ut.default(H));case 10:if(y){re.next=2;break}case 11:return re.abrupt("return",g);case 12:case"end":return re.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"_onConversationRemoved",value:function(v){var _=this.conversations.get(v);_&&(this.conversations.delete(v),this.emit("conversationRemoved",_))}},{key:"_registerForEvents",value:function(v){var _=this;v.on("removed",function(){return _._onConversationRemoved(v.sid)}),v.on("updated",function(g){return _.emit("conversationUpdated",g)}),v.on("participantJoined",function(g){return _.emit("participantJoined",g)}),v.on("participantLeft",function(g){return _.emit("participantLeft",g)}),v.on("participantUpdated",function(g){return _.emit("participantUpdated",g)}),v.on("messageAdded",function(g){return _.emit("messageAdded",g)}),v.on("messageUpdated",function(g){return _.emit("messageUpdated",g)}),v.on("messageRemoved",function(g){return _.emit("messageRemoved",g)}),v.on("typingStarted",function(g){return _.emit("typingStarted",g)}),v.on("typingEnded",function(g){return _.emit("typingEnded",g)})}}]),S}(M.ReplayEventEmitter);function Zi(w){var k=bi();return function(){var m=we.default(w),v;if(k){var _=we.default(this).constructor;v=Reflect.construct(m,arguments,_)}else v=m.apply(this,arguments);return Te.default(this,v)}}function bi(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ea=function(w){be.default(S,w);var k=Zi(S);function S(m,v,_){var g;return De.default(this,S),g=k.call(this),g.configuration=v,g.services=_,g.fifoStack=[],g.myself=m,g.myself.on("updated",function(y){return g.emit("userUpdated",y)}),g.myself.on("userSubscribed",function(){return g.emit("userSubscribed",g.myself)}),g.myself.on("userUnsubscribed",function(){g.emit("userUnsubscribed",g.myself),g.myself._ensureFetched()}),g.subscribedUsers=new Map,g}return $e.default(S,[{key:"handleUnsubscribeUser",value:function(v){this.subscribedUsers.has(v.identity)&&this.subscribedUsers.delete(v.identity);var _=0,g=this.fifoStack.find(function(y,b){return y==v.identity?(_=b,!0):!1});g&&this.fifoStack.splice(_,1),this.emit("userUnsubscribed",v)}},{key:"handleSubscribeUser",value:function(v){if(!this.subscribedUsers.has(v.identity)){if(this.fifoStack.length>=this.configuration.userInfosToSubscribe){var _,g,y=this.fifoStack.shift();(_=this.subscribedUsers)===null||_===void 0||(g=_.get(y))===null||g===void 0||g.unsubscribe()}this.fifoStack.push(v.identity),this.subscribedUsers.set(v.identity,v),this.emit("userSubscribed",v)}}},{key:"getUser",value:function(){var m=ae.default(G.default.mark(function _(g,y){var b,T=this,$,H;return G.default.wrap(function(re){for(;;)switch(re.prev=re.next){case 0:return re.next=2,this.myself._ensureFetched();case 2:if(g!=this.myself.identity){re.next=4;break}return re.abrupt("return",this.myself);case 4:if($=this.subscribedUsers.get(g),!$){re.next=7;break}return re.abrupt("return",$);case 7:if(!((b=y)!==null&&b!==void 0)){re.next=11;break}re.next=14;break;case 11:return re.next=13,this.getSyncUniqueName(g);case 13:y=re.sent;case 14:return H=new Wt(g,y,this.configuration,this.services),H.on("updated",function(ue){return T.emit("userUpdated",ue)}),H.on("userSubscribed",function(){return T.handleSubscribeUser(H)}),H.on("userUnsubscribed",function(){return T.handleUnsubscribeUser(H)}),re.next=20,H._ensureFetched();case 20:return re.abrupt("return",H);case 21:case"end":return re.stop()}},_,this)}));function v(_,g){return m.apply(this,arguments)}return v}()},{key:"getSubscribedUsers",value:function(){var m=ae.default(G.default.mark(function _(){var g;return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this.myself._ensureFetched();case 2:return g=[this.myself],this.subscribedUsers.forEach(function(T){return g.push(T)}),b.abrupt("return",g);case 5:case"end":return b.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"getSyncUniqueName",value:function(){var m=ae.default(G.default.mark(function _(g){var y,b,T,$;return G.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:return T=new st(this.configuration.links.users).path(g).build(),K.next=3,this.services.network.get(T);case 3:return $=K.sent,K.abrupt("return",(y=(b=$.body)===null||b===void 0?void 0:b.sync_objects.user_info_map)!==null&&y!==void 0?y:"");case 5:case"end":return K.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()}]),S}(M.ReplayEventEmitter),vn=Kt.scope("TypingIndicator"),An=function(){function w(k,S,m){De.default(this,w),this.configuration=S,this.services=m,this.getConversation=k,this.serviceTypingTimeout=null,this.sentUpdates=new Map}return $e.default(w,[{key:"typingTimeout",get:function(){return this.configuration.typingIndicatorTimeoutOverride||this.serviceTypingTimeout||this.configuration.typingIndicatorTimeoutDefault}},{key:"initialize",value:function(){var S=this;this.services.notificationClient.on("message",function(){var m=ae.default(G.default.mark(function v(_,g){return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(_!==de.TYPING_INDICATOR){b.next=3;break}return b.next=3,S._handleRemoteTyping(g);case 3:case"end":return b.stop()}},v)}));return function(v,_){return m.apply(this,arguments)}}())}},{key:"_handleRemoteTyping",value:function(){var k=ae.default(G.default.mark(function m(v){var _=this;return G.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:vn.trace("Got new typing indicator ",v),this.getConversation(v.channel_sid).then(function(b){b&&b._participants.forEach(function(T){if(T.identity===v.identity){var $=_.configuration.typingIndicatorTimeoutOverride?_.configuration.typingIndicatorTimeoutOverride+1e3:v.typing_timeout*1e3;T._startTyping($)}})}).catch(function(b){throw vn.error(b),b});case 2:case"end":return y.stop()}},m,this)}));function S(m){return k.apply(this,arguments)}return S}()},{key:"send",value:function(S){var m=this.sentUpdates.get(S);return m&&m>Date.now()-this.typingTimeout?Promise.resolve():(this.sentUpdates.set(S,Date.now()),this._send(S))}},{key:"_send",value:function(S){var m=this;vn.trace("Sending typing indicator");var v=this.configuration.links.typing,_={"Content-Type":"application/x-www-form-urlencoded"},g="ChannelSid=".concat(S);return this.services.twilsockClient.post(v,_,g,this.configuration.productId).then(function(y){y.body.hasOwnProperty("typing_timeout")&&(m.serviceTypingTimeout=y.body.typing_timeout*1e3)}).catch(function(y){throw vn.error("Failed to send typing indicator:",y),y})}}]),w}(),Zt=$e.default(function w(k){De.default(this,w),this.title=k.title||null,this.body=k.body||null,this.sound=k.sound||null,this.badge=k.badge||null,this.action=k.action||null,this.type=k.type||null,this.data=k.data||{}}),Kn="2.4.0";function Jn(w,k){var S=Object.keys(w);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(w);k&&(m=m.filter(function(v){return Object.getOwnPropertyDescriptor(w,v).enumerable})),S.push.apply(S,m)}return S}function kr(w){for(var k=1;k<arguments.length;k++){var S=arguments[k]!=null?arguments[k]:{};k%2?Jn(Object(S),!0).forEach(function(m){ge.default(w,m,S[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(w,Object.getOwnPropertyDescriptors(S)):Jn(Object(S)).forEach(function(m){Object.defineProperty(w,m,Object.getOwnPropertyDescriptor(S,m))})}return w}function nn(w){var k=ta();return function(){var m=we.default(w),v;if(k){var _=we.default(this).constructor;v=Reflect.construct(m,arguments,_)}else v=m.apply(this,arguments);return Te.default(this,v)}}function ta(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var F=function(k){return k.replace(/(^\/+|\/+$)/g,"")},q=function(k){return k.status.code===202},P=function(w){be.default(S,w);var k=nn(S);function S(m){return De.default(this,S),k.call(this,m)}return $e.default(S)}(ur.default(Error)),O=function(){function w(k,S,m){De.default(this,w),this._serviceUrl=k,this._services=S,this._productId=m}return $e.default(w,[{key:"_preProcessUrl",value:function(S){var m=F(S);return/^https?:\/\//.test(S)?m:"".concat(F(this._serviceUrl),"/").concat(m)}},{key:"_makeRequest",value:function(){var k=ae.default(G.default.mark(function m(v,_,g,y){var b,T,$,H;return G.default.wrap(function(re){for(;;)switch(re.prev=re.next){case 0:b=this._preProcessUrl(_),T=kr({"Content-Type":"application/json; charset=utf-8"},y||{}),re.t0=v,re.next=re.t0==="get"?5:re.t0==="post"?11:re.t0==="delete"?15:19;break;case 5:return H=b,g&&(H+="?"+Object.entries(g).map(function(ue){return ue.map(encodeURIComponent).join("=")}).join("&")),re.next=9,this._services.transport.get(H,T,this._productId);case 9:return $=re.sent,re.abrupt("break",19);case 11:return re.next=13,this._services.transport.post(b,T,JSON.stringify(g),this._productId);case 13:return $=re.sent,re.abrupt("break",19);case 15:return re.next=17,this._services.transport.delete(b,T,{},this._productId);case 17:return $=re.sent,re.abrupt("break",19);case 19:if(!($.status.code<200||$.status.code>=300)){re.next=21;break}throw new Error("Request responded with a non-success code ".concat($.status.code));case 21:return re.abrupt("return",$);case 22:case"end":return re.stop()}},m,this)}));function S(m,v,_,g){return k.apply(this,arguments)}return S}()},{key:"fetchResource",value:function(){var k=ae.default(G.default.mark(function m(v,_){var g=this,y,b,T;return G.default.wrap(function(H){for(;;)switch(H.prev=H.next){case 0:return y=6,b=new j.AsyncRetrier({min:50,max:1600,maxAttemptsCount:y}),H.prev=2,H.next=5,b.run(ae.default(G.default.mark(function K(){var re,ue,Xe;return G.default.wrap(function(C){for(;;)switch(C.prev=C.next){case 0:return C.prev=0,C.next=3,g._makeRequest("get",v,_);case 3:return re=C.sent,C.abrupt("return",{type:"success",data:re.body});case 7:if(C.prev=7,C.t0=C.catch(0),!((C.t0===null||C.t0===void 0||(ue=C.t0.body)===null||ue===void 0?void 0:ue.status)===404&&(C.t0===null||C.t0===void 0||(Xe=C.t0.body)===null||Xe===void 0?void 0:Xe.code)===50530)){C.next=11;break}return C.abrupt("return",{type:"noMetadata"});case 11:throw C.t0;case 12:case"end":return C.stop()}},K,null,[[0,7]])})));case 5:T=H.sent,H.next=11;break;case 8:throw H.prev=8,H.t0=H.catch(2),new Error('Fetch resource from "'.concat(v,'" failed.'));case 11:if(T.type!=="noMetadata"){H.next=13;break}throw new P("No metadata found.");case 13:return H.abrupt("return",T.data);case 14:case"end":return H.stop()}},m,null,[[2,8]])}));function S(m,v){return k.apply(this,arguments)}return S}()},{key:"mutateResource",value:function(){var k=ae.default(G.default.mark(function m(v,_,g){var y;return G.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.next=2,this._makeRequest(v,_,g,{"X-Twilio-Mutation-Id":Z.v4()});case 2:if(y=T.sent,!q(y)){T.next=7;break}return T.next=6,this.fetchResource(y.body.resource_url);case 6:return T.abrupt("return",T.sent);case 7:return T.abrupt("return",y.body);case 8:case"end":return T.stop()}},m,this)}));function S(m,v,_){return k.apply(this,arguments)}return S}()}]),w}(),R=function(){function w(k){var S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:100,m=arguments.length>2&&arguments[2]!==void 0?arguments[2]:5e3;De.default(this,w),ge.default(this,"_cachedTemplates",null),this._services=k,this._pageSize=S,this._cacheTtlMs=m}return $e.default(w,[{key:"getContentTemplates",value:function(){var k=ae.default(G.default.mark(function m(){var v=this,_,g,y,b,T,$,H;return G.default.wrap(function(re){for(;;)switch(re.prev=re.next){case 0:if(this._cachedTemplates===null){re.next=2;break}return re.abrupt("return",this._cachedTemplates);case 2:return re.next=4,this._fetchContentTemplates();case 4:_=re.sent,g=te.default(_,2),y=g[0],b=g[1],T=y;case 9:if(b===null){re.next=19;break}return re.next=12,this._fetchContentTemplates(b);case 12:$=re.sent,H=te.default($,2),y=H[0],b=H[1],T=[].concat(ut.default(T),ut.default(y)),re.next=9;break;case 19:return this._cachedTemplates=Object.freeze(T),setTimeout(function(){v._cachedTemplates=null},this._cacheTtlMs),re.abrupt("return",T);case 22:case"end":return re.stop()}},m,this)}));function S(){return k.apply(this,arguments)}return S}()},{key:"_fetchContentTemplates",value:function(){var k=ae.default(G.default.mark(function m(v){var _,g,y;return G.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return _="Client/v2/ContentTemplates",g=new st(_),g.arg("PageSize",this._pageSize),v!==void 0&&g.arg("PageToken",v),T.next=6,this._services.commandExecutor.fetchResource(g.build());case 6:return y=T.sent,T.abrupt("return",[y.templates.map(function($){return new tt($)}),y.meta.next_token]);case 8:case"end":return T.stop()}},m,this)}));function S(m){return k.apply(this,arguments)}return S}()}]),w}();function U(w,k){var S=typeof Symbol<"u"&&w[Symbol.iterator]||w["@@iterator"];if(!S){if(Array.isArray(w)||(S=N(w))||k&&w&&typeof w.length=="number"){S&&(w=S);var m=0,v=function(){};return{s:v,n:function(){return m>=w.length?{done:!0}:{done:!1,value:w[m++]}},e:function(T){throw T},f:v}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
464
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,g=!1,y;return{s:function(){S=S.call(w)},n:function(){var T=S.next();return _=T.done,T},e:function(T){g=!0,y=T},f:function(){try{!_&&S.return!=null&&S.return()}finally{if(g)throw y}}}}function N(w,k){if(w){if(typeof w=="string")return me(w,k);var S=Object.prototype.toString.call(w).slice(8,-1);if(S==="Object"&&w.constructor&&(S=w.constructor.name),S==="Map"||S==="Set")return Array.from(w);if(S==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(S))return me(w,k)}}function me(w,k){(k==null||k>w.length)&&(k=w.length);for(var S=0,m=new Array(k);S<k;S++)m[S]=w[S];return m}var pe=function(w){function k(){var S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(De.default(this,k),!(S.maxSize&&S.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=S.maxSize,this.onEviction=S.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}return $e.default(k,[{key:"_set",value:function(m,v){if(this.cache.set(m,v),this._size++,this._size>=this.maxSize){if(this._size=0,typeof this.onEviction=="function"){var _=U(this.oldCache.entries()),g;try{for(_.s();!(g=_.n()).done;){var y=te.default(g.value,2),b=y[0],T=y[1];this.onEviction(b,T)}}catch($){_.e($)}finally{_.f()}}this.oldCache=this.cache,this.cache=new Map}}},{key:"get",value:function(m){if(this.cache.has(m))return this.cache.get(m);if(this.oldCache.has(m)){var v=this.oldCache.get(m);return this.oldCache.delete(m),this._set(m,v),v}}},{key:"set",value:function(m,v){return this.cache.has(m)?this.cache.set(m,v):this._set(m,v),this}},{key:"has",value:function(m){return this.cache.has(m)||this.oldCache.has(m)}},{key:"peek",value:function(m){if(this.cache.has(m))return this.cache.get(m);if(this.oldCache.has(m))return this.oldCache.get(m)}},{key:"delete",value:function(m){var v=this.cache.delete(m);return v&&this._size--,this.oldCache.delete(m)||v}},{key:"clear",value:function(){this.cache.clear(),this.oldCache.clear(),this._size=0}},{key:"keys",value:G.default.mark(function S(){var m,v,_,g;return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:m=U(this),b.prev=1,m.s();case 3:if((v=m.n()).done){b.next=9;break}return _=te.default(v.value,1),g=_[0],b.next=7,g;case 7:b.next=3;break;case 9:b.next=14;break;case 11:b.prev=11,b.t0=b.catch(1),m.e(b.t0);case 14:return b.prev=14,m.f(),b.finish(14);case 17:case"end":return b.stop()}},S,this,[[1,11,14,17]])})},{key:"values",value:G.default.mark(function S(){var m,v,_,g;return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:m=U(this),b.prev=1,m.s();case 3:if((v=m.n()).done){b.next=9;break}return _=te.default(v.value,2),g=_[1],b.next=7,g;case 7:b.next=3;break;case 9:b.next=14;break;case 11:b.prev=11,b.t0=b.catch(1),m.e(b.t0);case 14:return b.prev=14,m.f(),b.finish(14);case 17:case"end":return b.stop()}},S,this,[[1,11,14,17]])})},{key:w,value:G.default.mark(function S(){var m,v,_,g,y,b,T,$;return G.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:m=U(this.cache),K.prev=1,m.s();case 3:if((v=m.n()).done){K.next=9;break}return _=v.value,K.next=7,_;case 7:K.next=3;break;case 9:K.next=14;break;case 11:K.prev=11,K.t0=K.catch(1),m.e(K.t0);case 14:return K.prev=14,m.f(),K.finish(14);case 17:g=U(this.oldCache),K.prev=18,g.s();case 20:if((y=g.n()).done){K.next=28;break}if(b=y.value,T=te.default(b,1),$=T[0],this.cache.has($)){K.next=26;break}return K.next=26,b;case 26:K.next=20;break;case 28:K.next=33;break;case 30:K.prev=30,K.t1=K.catch(18),g.e(K.t1);case 33:return K.prev=33,g.f(),K.finish(33);case 36:case"end":return K.stop()}},S,this,[[1,11,14,17],[18,30,33,36]])})},{key:"size",get:function(){var m=0,v=U(this.oldCache.keys()),_;try{for(v.s();!(_=v.n()).done;){var g=_.value;this.cache.has(g)||m++}}catch(y){v.e(y)}finally{v.f()}return Math.min(this._size+m,this.maxSize)}}]),k}(Symbol.iterator),Ae=pe,qe=$e.default(function w(k,S){De.default(this,w),this.type=k,this.data=S,Object.freeze(S)}),at=function(){function w(k,S){De.default(this,w),this._services=k,this._configuration=S,this._cache=new Ae({maxSize:S.channelMetadataCacheCapacity})}return $e.default(w,[{key:"getChannelMetadata",value:function(){var k=ae.default(G.default.mark(function m(v,_){var g,y,b,T,$;return G.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(g="".concat(v,",").concat(_),y=this._cache.get(g),!y){K.next=4;break}return K.abrupt("return",y.item);case 4:return b="".concat(this._configuration.links.conversations,"/").concat(v,"/Messages/").concat(_,"/ChannelMetadata"),K.prev=5,K.next=8,this._services.commandExecutor.fetchResource(b);case 8:T=K.sent,K.next=17;break;case 11:if(K.prev=11,K.t0=K.catch(5),!(K.t0 instanceof P)){K.next=16;break}return this._cache.set(g,{item:null}),K.abrupt("return",null);case 16:throw new Error(K.t0);case 17:return $=new qe(T.type,T.data),this._cache.set(g,{item:$}),K.abrupt("return",$);case 20:case"end":return K.stop()}},m,this,[[5,11]])}));function S(m,v){return k.apply(this,arguments)}return S}()}]),w}(),dt;function Lr(w,k){var S=Object.keys(w);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(w);k&&(m=m.filter(function(v){return Object.getOwnPropertyDescriptor(w,v).enumerable})),S.push.apply(S,m)}return S}function lr(w){for(var k=1;k<arguments.length;k++){var S=arguments[k]!=null?arguments[k]:{};k%2?Lr(Object(S),!0).forEach(function(m){ge.default(w,m,S[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(w,Object.getOwnPropertyDescriptors(S)):Lr(Object(S)).forEach(function(m){Object.defineProperty(w,m,Object.getOwnPropertyDescriptor(S,m))})}return w}function an(w){var k=_o();return function(){var m=we.default(w),v;if(k){var _=we.default(this).constructor;v=Reflect.construct(m,arguments,_)}else v=m.apply(this,arguments);return Te.default(this,v)}}function _o(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Qt,B=$e.default(function w(){De.default(this,w)});e.Client=Qt=(dt=function(w){be.default(S,w);var k=an(S);function S(m){var v,_,g,y,b,T,$=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(De.default(this,S),T=k.call(this),ge.default(Ve.default(T),"version",Kn),ge.default(Ve.default(T),"connectionState","unknown"),ge.default(Ve.default(T),"parsePushNotification",Qt.parsePushNotification),T._fpaToken=m??"",T._options=$??{},!T._options.disableDeepClone){var H=lr(lr({},T._options),{},{transport:void 0,twilsockClient:void 0});H=Cr(H),H.transport=T._options.transport,H.twilsockClient=T._options.twilsockClient,T._options=H}T._options.logLevel=(v=T._options.logLevel)!==null&&v!==void 0?v:"silent",Qt._logger.setLevel(T._options.logLevel);var K=T._options.productId="ip_messaging";if(T._options.clientMetadata=T._options.clientMetadata||{},T._options.clientMetadata.hasOwnProperty("type")||(T._options.clientMetadata.type="conversations"),T._options.clientMetadata.hasOwnProperty("sdk")||(T._options.clientMetadata.sdk="JS",T._options.clientMetadata.sdkv=Kn),T._options.Sync=T._options.Sync||{},typeof T._options.Sync.enableSessionStorage>"u"&&(T._options.Sync.enableSessionStorage=!0),T._options.region&&(T._options.Sync.region=T._options.region),!m)throw new Error("A valid Twilio token should be provided");T._services=new B,T._myself=new Wt("","",null,T._services);var re=!T._options.twilsockClient;if(!T._options.initRegistrations){var ue=new z.InitRegistration(K);Qt.populateInitRegistrations(ue),T._options.initRegistrations=[ue]}T._services.twilsockClient=T._options.twilsockClient=(_=T._options.twilsockClient)!==null&&_!==void 0?_:new z.TwilsockClient(m,K,T._options),T._services.twilsockClient.on("tokenAboutToExpire",function(){return T.emit("tokenAboutToExpire")}),T._services.twilsockClient.on("tokenExpired",function(){return T.emit("tokenExpired")}),T._services.twilsockClient.on("connectionError",function(W){return T.emit("connectionError",W)}),T._services.twilsockClient.on("stateChanged",function(W){Qt._logger.debug("Handling stateChanged for ConversationsClient: new state ".concat(W)),W!==T.connectionState&&(T.connectionState=W,T.emit("connectionStateChanged",T.connectionState))}),T._services.transport=T._options.transport=(g=T._options.transport)!==null&&g!==void 0?g:T._options.twilsockClient,T._services.notificationClient=T._options.notificationsClient=(y=T._options.notificationsClient)!==null&&y!==void 0?y:new ie.Notifications(m,T._options),T._services.syncClient=T._options.syncClient=(b=T._options.syncClient)!==null&&b!==void 0?b:new oe.SyncClient(m,T._options);var Xe=($==null?void 0:$.Chat)||($==null?void 0:$.IPMessaging)||$||{},lt=Xe.region||($==null?void 0:$.region),C=Xe.apiUri||Xe.typingUri||"https://aim.".concat(lt||"us1",".twilio.com");T._services.commandExecutor=new O(C,{transport:T._options.transport},K),T._services.contentClient=new R(T._services);var A=function(V){T._rejectEnsureReady(V),T.emit("stateChanged","failed"),T.emit("initFailed",{error:V})},D=function(){A({terminal:!0,message:"Twilsock has disconnected."})};return T._services.twilsockClient.once("connectionError",A),T._services.twilsockClient.once("disconnected",D),T._services.twilsockClient.once("connected",ae.default(G.default.mark(function W(){var V,he;return G.default.wrap(function(Ee){for(;;)switch(Ee.prev=Ee.next){case 0:return Qt._logger.debug("ConversationsClient started INITIALIZING"),T._services.twilsockClient.off("connectionError",A),T._services.twilsockClient.off("disconnected",D),Ee.prev=3,V="conversations.client.startup",T._services.twilsockClient.addPartialTelemetryEvent(new z.TelemetryEventDescription(V,"Conversations client startup",new Date),V,z.TelemetryPoint.Start),Ee.next=8,T._initialize();case 8:T._services.twilsockClient.addPartialTelemetryEvent(new z.TelemetryEventDescription("","",new Date),V,z.TelemetryPoint.End),Ee.next=17;break;case 11:Ee.prev=11,Ee.t0=Ee.catch(3),he={terminal:!0,message:Ee.t0.message},T._rejectEnsureReady(he),T.emit("stateChanged","failed"),T.emit("initFailed",{error:he});case 17:case"end":return Ee.stop()}},W,null,[[3,11]])}))),T._ensureReady=new Promise(function(W,V){T._resolveEnsureReady=W,T._rejectEnsureReady=V}).catch(function(){}),re&&T._services.twilsockClient.connect(),T}return $e.default(S,[{key:"user",get:function(){return this._myself}},{key:"reachabilityEnabled",get:function(){if(!this._configuration)throw new Error("Reachability information could not yet be accessed as the client has not yet been initialized. Subscribe to the 'stateChanged' event to properly react to the client initialization.");return this._configuration.reachabilityEnabled}},{key:"token",get:function(){return this._fpaToken}},{key:"shutdown",value:function(){var m=ae.default(G.default.mark(function _(){return G.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:return y.next=4,this._services.twilsockClient.disconnect();case 4:case"end":return y.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"updateToken",value:function(){var m=ae.default(G.default.mark(function _(g){return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._ensureReady;case 2:if(Qt._logger.info("updateToken"),this._fpaToken!==g){b.next=5;break}return b.abrupt("return",this);case 5:return b.next=7,this._services.twilsockClient.updateToken(g);case 7:return b.next=9,this._services.notificationClient.updateToken(g);case 9:return b.next=11,this._services.mcsClient.updateToken(g);case 11:return this._fpaToken=g,b.abrupt("return",this);case 13:case"end":return b.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"getConversationBySid",value:function(){var m=ae.default(G.default.mark(function _(g){var y;return G.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.next=2,this._ensureReady;case 2:return T.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return T.next=6,this._conversationsEntity.getConversation(g);case 6:if(y=T.sent,y){T.next=12;break}return T.next=10,this.peekConversationBySid(g);case 10:y=T.sent,y&&L.deprecationWarning("The method getConversationBySid is deprecated to retrieve conversations you're not part of. Use peekConversationBySid instead.");case 12:if(y){T.next=14;break}throw new Error("Conversation with SID ".concat(g," was not found."));case 14:return T.abrupt("return",y);case 15:case"end":return T.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"peekConversationBySid",value:function(){var m=ae.default(G.default.mark(function _(g){var y;return G.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.next=2,this._ensureReady;case 2:return T.next=4,this._conversationsEntity.peekConversation(g);case 4:if(y=T.sent,y){T.next=7;break}throw new Error("Conversation with SID ".concat(g," was not found."));case 7:return T.abrupt("return",y);case 8:case"end":return T.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"getConversationByUniqueName",value:function(){var m=ae.default(G.default.mark(function _(g){var y;return G.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.next=2,this._ensureReady;case 2:return T.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return T.next=6,this._conversationsEntity.getConversationByUniqueName(g);case 6:if(y=T.sent,y){T.next=9;break}throw new Error("Conversation with unique name ".concat(g," was not found."));case 9:return T.abrupt("return",y);case 10:case"end":return T.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"getSubscribedConversations",value:function(){var m=ae.default(G.default.mark(function _(){return G.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:return y.abrupt("return",this._conversationsPromise.then(function(b){return b.getConversations()}));case 3:case"end":return y.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"createConversation",value:function(){var m=ae.default(G.default.mark(function _(g){return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._ensureReady;case 2:return g=g||{},b.abrupt("return",this._conversationsPromise.then(function(T){return T.addConversation(g)}));case 4:case"end":return b.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"setPushRegistrationId",value:function(){var m=ae.default(G.default.mark(function _(g,y){return G.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.next=2,this._ensureReady;case 2:return this._subscribeToPushNotifications(g),this._services.notificationClient.setPushRegistrationId(g,y),T.next=6,this._services.notificationClient.commitChanges();case 6:case"end":return T.stop()}},_,this)}));function v(_,g){return m.apply(this,arguments)}return v}()},{key:"unsetPushRegistrationId",value:function(){var m=ae.default(G.default.mark(function _(g){return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._ensureReady;case 2:return this._unsubscribeFromPushNotifications(g),b.next=5,this._services.notificationClient.commitChanges();case 5:case"end":return b.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"removePushRegistrations",value:function(){var m=ae.default(G.default.mark(function _(g,y){return G.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.next=2,this._services.notificationClient.removeRegistrations(g,y);case 2:case"end":return T.stop()}},_,this)}));function v(_,g){return m.apply(this,arguments)}return v}()},{key:"handlePushNotification",value:function(){var m=ae.default(G.default.mark(function _(g){return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._ensureReady;case 2:Qt._logger.debug("handlePushNotification, notificationPayload=",g),this.emit("pushNotification",Qt.parsePushNotification(g));case 4:case"end":return b.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"getUser",value:function(){var m=ae.default(G.default.mark(function _(g){return G.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._ensureReady;case 2:return b.abrupt("return",this._services.users.getUser(g));case 3:case"end":return b.stop()}},_,this)}));function v(_){return m.apply(this,arguments)}return v}()},{key:"getSubscribedUsers",value:function(){var m=ae.default(G.default.mark(function _(){return G.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:return y.abrupt("return",this._services.users.getSubscribedUsers());case 3:case"end":return y.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"getTemporaryContentUrlsForMediaSids",value:function(v){var _=this;return new J.CancellablePromise(function(){var g=ae.default(G.default.mark(function y(b,T,$){var H,K;return G.default.wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:if(!(!_._services.mcsClient||!v)){ue.next=3;break}return T(new Error("Media Content Service is unavailable")),ue.abrupt("return");case 3:return H=_._services.mcsClient.mediaSetGetContentUrls(v),$(function(){H.cancel()}),ue.prev=5,ue.next=8,H;case 8:K=ue.sent,b(K),ue.next=15;break;case 12:ue.prev=12,ue.t0=ue.catch(5),T(ue.t0);case 15:case"end":return ue.stop()}},y,null,[[5,12]])}));return function(y,b,T){return g.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForMedia",value:function(v){var _=v.map(function(g){return g.sid});return this.getTemporaryContentUrlsForMediaSids(_)}},{key:"getContentTemplates",value:function(){var m=ae.default(G.default.mark(function _(){return G.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:return y.next=4,this._services.contentClient.getContentTemplates();case 4:return y.abrupt("return",y.sent);case 5:case"end":return y.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"_initialize",value:function(){var m=ae.default(G.default.mark(function _(){var g=this,y;return G.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.next=2,this._services.commandExecutor.fetchResource("Client/v2/Configuration");case 2:return y=T.sent,this._configuration=new Pr(this._options,y,Qt._logger),this._services.channelMetadataClient=new at(this._services,this._configuration),this._myself._resolveInitialization(this._configuration,this._configuration.userIdentity,this._configuration.userInfo,!0),this._services.typingIndicator=new An(this.getConversationBySid.bind(this),this._configuration,this._services),this._services.network=new ce(this._configuration,this._services),this._services.users=new ea(this._myself,this._configuration,this._services),this._services.users.on("userSubscribed",function($){g.emit("userSubscribed",$)}),this._services.users.on("userUpdated",function($){return g.emit("userUpdated",$)}),this._services.users.on("userUnsubscribed",function($){g.emit("userUnsubscribed",$)}),this._conversationsEntity=new Qi(this._configuration,this._services),this._conversationsEntity.on("conversationAdded",function($){g.emit("conversationAdded",$)}),this._conversationsEntity.on("conversationRemoved",function($){g.emit("conversationRemoved",$)}),this._conversationsEntity.on("conversationJoined",function($){g.emit("conversationJoined",$)}),this._conversationsEntity.on("conversationLeft",function($){g.emit("conversationLeft",$)}),this._conversationsEntity.on("conversationUpdated",function($){return g.emit("conversationUpdated",$)}),this._conversationsEntity.on("participantJoined",function($){g.emit("participantJoined",$)}),this._conversationsEntity.on("participantLeft",function($){g.emit("participantLeft",$)}),this._conversationsEntity.on("participantUpdated",function($){return g.emit("participantUpdated",$)}),this._conversationsEntity.on("messageAdded",function($){return g.emit("messageAdded",$)}),this._conversationsEntity.on("messageUpdated",function($){return g.emit("messageUpdated",$)}),this._conversationsEntity.on("messageRemoved",function($){return g.emit("messageRemoved",$)}),this._conversationsEntity.on("typingStarted",function($){return g.emit("typingStarted",$)}),this._conversationsEntity.on("typingEnded",function($){return g.emit("typingEnded",$)}),this._conversationsPromise=this._conversationsEntity.fetchConversations().then(function(){return g._conversationsEntity}).catch(function($){throw $}),T.next=29,this._services.users.myself._ensureFetched();case 29:Qt._supportedPushChannels.forEach(function($){return g._subscribeToPushNotifications($)}),this._services.typingIndicator.initialize(),this._services.mcsClient=new J.McsClient(this._fpaToken,this._configuration.links.mediaService,this._configuration.links.mediaSetService,lr(lr({},this._options),{},{transport:void 0})),this._resolveEnsureReady(),this.emit("stateChanged","initialized"),this.emit("initialized");case 35:case"end":return T.stop()}},_,this)}));function v(){return m.apply(this,arguments)}return v}()},{key:"_subscribeToPushNotifications",value:function(v){var _=this;[de.NEW_MESSAGE,de.ADDED_TO_CONVERSATION,de.REMOVED_FROM_CONVERSATION,de.TYPING_INDICATOR,de.CONSUMPTION_UPDATE].forEach(function(g){_._services.notificationClient.subscribe(v,g)})}},{key:"_unsubscribeFromPushNotifications",value:function(v){var _=this;[de.NEW_MESSAGE,de.ADDED_TO_CONVERSATION,de.REMOVED_FROM_CONVERSATION,de.TYPING_INDICATOR,de.CONSUMPTION_UPDATE].forEach(function(g){_._services.notificationClient.unsubscribe(v,g)})}}],[{key:"create",value:function(){var m=ae.default(G.default.mark(function _(g,y){var b;return G.default.wrap(function($){for(;;)switch($.prev=$.next){case 0:if(!(y!=null&&y.twilsockClient)){$.next=2;break}throw new Error("Obsolete usage of ConversationsClient.create() factory method: if you pass twilsock from the outside then you must use ConversationsClient constructor and be prepared to work with uninitialized client.");case 2:return b=new Qt(g,y),$.next=5,b._ensureReady;case 5:return $.abrupt("return",b);case 6:case"end":return $.stop()}},_)}));function v(_,g){return m.apply(this,arguments)}return v}()},{key:"parsePushNotification",value:function(v){if(Qt._logger.debug("parsePushNotification, notificationPayload=",v),typeof v.aps<"u"){if(!v.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var _=Qt._parsePushNotificationChatData(v),g=v.aps,y,b=null;if(typeof g.alert=="string")y=g.alert||null;else{var T,$;y=((T=g.alert)===null||T===void 0?void 0:T.body)||null,b=(($=g.alert)===null||$===void 0?void 0:$.title)||null}return new Zt({title:b,body:y,sound:g.sound||null,badge:g.badge||null,action:g.category||null,type:v.twi_message_type,data:_})}if(typeof v.data<"u"){var H=v.data;if(!H.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var K=Qt._parsePushNotificationChatData(v.data);return new Zt({title:H.twi_title||null,body:H.twi_body||null,sound:H.twi_sound||null,badge:null,action:H.twi_action||null,type:H.twi_message_type,data:K})}throw new Error("Provided push notification payload is not Programmable Chat notification")}},{key:"_parsePushNotificationChatData",value:function(v){var _={};for(var g in Qt._supportedPushDataFields){var y=v[g];if(!(typeof y>"u"||y===null)){if(g==="message_index"||g==="media_count"){var b=Ct(y);b!==null&&(_[Qt._supportedPushDataFields[g]]=b);continue}if(g==="media"){if(typeof y=="string")try{_[Qt._supportedPushDataFields[g]]=JSON.parse(y)}catch{Qt._logger.debug("Media message notification parsing error")}continue}_[Qt._supportedPushDataFields[g]]=y}}return _}},{key:"populateInitRegistrations",value:function(v){v.populateInitRegistrations([de.TYPING_INDICATOR]),oe.SyncClient.populateInitRegistrations(v)}}]),S}(M.ReplayEventEmitter),ge.default(dt,"conversationAdded","conversationAdded"),ge.default(dt,"conversationJoined","conversationJoined"),ge.default(dt,"conversationLeft","conversationLeft"),ge.default(dt,"conversationRemoved","conversationRemoved"),ge.default(dt,"conversationUpdated","conversationUpdated"),ge.default(dt,"participantJoined","participantJoined"),ge.default(dt,"participantLeft","participantLeft"),ge.default(dt,"participantUpdated","participantUpdated"),ge.default(dt,"messageAdded","messageAdded"),ge.default(dt,"messageRemoved","messageRemoved"),ge.default(dt,"messageUpdated","messageUpdated"),ge.default(dt,"tokenAboutToExpire","tokenAboutToExpire"),ge.default(dt,"tokenExpired","tokenExpired"),ge.default(dt,"typingEnded","typingEnded"),ge.default(dt,"typingStarted","typingStarted"),ge.default(dt,"pushNotification","pushNotification"),ge.default(dt,"userSubscribed","userSubscribed"),ge.default(dt,"userUnsubscribed","userUnsubscribed"),ge.default(dt,"userUpdated","userUpdated"),ge.default(dt,"stateChanged","stateChanged"),ge.default(dt,"initialized","initialized"),ge.default(dt,"initFailed","initFailed"),ge.default(dt,"connectionStateChanged","connectionStateChanged"),ge.default(dt,"connectionError","connectionError"),ge.default(dt,"version",Kn),ge.default(dt,"_logger",Kt.scope("Client")),ge.default(dt,"_supportedPushChannels",["fcm","apn"]),ge.default(dt,"_supportedPushDataFields",{conversation_sid:"conversationSid",conversation_title:"conversationTitle",message_sid:"messageSid",message_index:"messageIndex",media_count:"mediaCount",media:"media"}),dt),Me([L.deprecated("token"),fe("design:type",String),fe("design:paramtypes",[])],e.Client.prototype,"token",null),Me([h.validateTypesAsync(h.nonEmptyString),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],e.Client.prototype,"updateToken",null),Me([h.validateTypesAsync(h.nonEmptyString),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],e.Client.prototype,"getConversationBySid",null),Me([h.validateTypesAsync(h.nonEmptyString),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],e.Client.prototype,"peekConversationBySid",null),Me([h.validateTypesAsync(h.nonEmptyString),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],e.Client.prototype,"getConversationByUniqueName",null),Me([h.validateTypesAsync(["undefined",h.objectSchema("conversation options",{friendlyName:["string","undefined"],isPrivate:["boolean","undefined"],uniqueName:["string","undefined"]})]),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",Promise)],e.Client.prototype,"createConversation",null),Me([h.validateTypesAsync(h.literal("fcm","apn"),"string"),fe("design:type",Function),fe("design:paramtypes",[String,String]),fe("design:returntype",Promise)],e.Client.prototype,"setPushRegistrationId",null),Me([h.validateTypesAsync(h.literal("fcm","apn")),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],e.Client.prototype,"unsetPushRegistrationId",null),Me([h.validateTypesAsync(h.literal("fcm","apn"),h.nonEmptyString),fe("design:type",Function),fe("design:paramtypes",[String,String]),fe("design:returntype",Promise)],e.Client.prototype,"removePushRegistrations",null),Me([h.validateTypesAsync(h.pureObject),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",Promise)],e.Client.prototype,"handlePushNotification",null),Me([h.validateTypesAsync(h.nonEmptyString),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],e.Client.prototype,"getUser",null),Me([h.validateTypesAsync(h.nonEmptyArray("strings","string")),fe("design:type",Function),fe("design:paramtypes",[Array]),fe("design:returntype",J.CancellablePromise)],e.Client.prototype,"getTemporaryContentUrlsForMediaSids",null),Me([h.validateTypesAsync(h.nonEmptyArray("media",Ue)),fe("design:type",Function),fe("design:paramtypes",[Array]),fe("design:returntype",J.CancellablePromise)],e.Client.prototype,"getTemporaryContentUrlsForMedia",null),Me([L.deprecated("Client.create()","new Client()"),h.validateTypesAsync("string",["undefined",h.pureObject]),fe("design:type",Function),fe("design:paramtypes",[String,Object]),fe("design:returntype",Promise)],e.Client,"create",null),Me([h.validateTypes(h.pureObject),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",Zt)],e.Client,"parsePushNotification",null),e.Client=Qt=Me([h.validateConstructorTypes(h.nonEmptyString,[h.pureObject,"undefined"]),fe("design:paramtypes",[String,Object])],e.Client),Object.defineProperty(e,"CancellablePromise",{enumerable:!0,get:function(){return J.CancellablePromise}}),e.AggregatedDeliveryReceipt=Oe,e.ChannelMetadata=qe,e.ContentTemplate=tt,e.ContentTemplateVariable=Ye,e.Conversation=At,e.DetailedDeliveryReceipt=Ke,e.Media=Ue,e.Message=ir,e.MessageBuilder=ar,e.NotificationTypes=de,e.Participant=ee,e.PushNotification=Zt,e.RestPaginator=Ze,e.UnsentMessage=rn,e.User=Wt})(Rw);const Ln=new ts("twilio-chat");class Hk extends Gh{constructor(){super(...arguments);bt(this,"client");bt(this,"conversation")}async create(){const{token:t,identity:n}=await this.issueChatToken();this.identity=n,Ln.info(`Connecting chat, identity: ${n}, token: ${t}`);const i=new Rw.Client(t);i.on("tokenAboutToExpire",()=>{Ln.info("Token is about to expire"),this.refreshToken()}),i.on("tokenExpired",()=>{Ln.info("Token is expired"),this.refreshToken()}),this.client=i}async refreshToken(){const{token:t}=await this.issueChatToken();await this.client.updateToken(t)}async join(t){const n=await this.client.getConversationBySid(t);n.status==="joined"?Ln.info("already joined conversation:",t):(await n.join(),Ln.info("success joined conversation:",t)),this.registerEvents(n),this.conversation=n}async preview(t){await(await this.conversation.getParticipantByIdentity(this.identity)).updateAttributes({chat_preview:t,chat_preview_updated_at:new Date().toJSON()})}async destroy(){this.client&&(await this.client.shutdown(),this.client=null,this.conversation=null)}async fetchMessages(t){return(await this.conversation.getMessages()).items.map(i=>{const a=IS(i);return(a.type==="photo"||a.type==="video")&&(a.file=t[a.$index]),a})}async sendMessage(t){try{const n=await this.conversation.sendMessage(JSON.stringify(t));return Ln.info(`Message sent from ${this.conversation.sid}, index: ${n}`),n}catch(n){Ln.warn(`Failed to send a message from ${this.conversation.sid}`,{error:n})}}startTyping(){this.conversation&&this.conversation.typing()}stopTyping(){}registerEvents(t){t.on("messageAdded",n=>{const i=IS(n);Ln.info(`Message added from ${this.conversation.sid}, index: ${i.$index}, sid: ${i.$sid}, timestamp: ${i.$timestamp}, user type: ${i.$userType}`),i.$userType!=="end_user"&&this.ping(),this.events.triggerEvent("message",i)}),t.on("participantJoined",n=>{Ln.info("conversation: memberJoined",n),this.events.triggerEvent("memberJoined",n.identity)}),t.on("participantLeft",n=>{Ln.info("conversation: memberLeft",n),this.events.triggerEvent("memberLeft",n.identity)}),t.on("typingStarted",n=>{this.events.triggerEvent("typingStarted",n.identity)}),t.on("typingEnded",n=>{this.events.triggerEvent("typingEnded",n.identity)})}}bt(Hk,"type","twilio_conversations");zh(Hk);function IS(e){const{index:r,sid:t,author:n,dateCreated:i,body:a}=e,[s,c]=n.split("-");let o=0;c&&(o=parseInt(c,10));const u={$index:r,$sid:t,$timestamp:i,$userType:s,$userId:o};try{const l=JSON.parse(a);return l.message&&!l.type?{...u,...l,type:"message"}:{...u,...l}}catch(l){return Ln.warn("Format message failed",{error:l,data:a}),{...u,type:"text",content:a}}}var vh={exports:{}},Ra=yl;function yl(){}yl.mixin=function(e){var r=e.prototype||e;r.isWildEmitter=!0,r.on=function(t,n,i){this.callbacks=this.callbacks||{};var a=arguments.length===3,s=a?arguments[1]:void 0,c=a?arguments[2]:arguments[1];return c._groupName=s,(this.callbacks[t]=this.callbacks[t]||[]).push(c),this},r.once=function(t,n,i){var a=this,s=arguments.length===3,c=s?arguments[1]:void 0,o=s?arguments[2]:arguments[1];function u(){a.off(t,u),o.apply(this,arguments)}return this.on(t,c,u),this},r.releaseGroup=function(t){this.callbacks=this.callbacks||{};var n,i,a,s;for(n in this.callbacks)for(s=this.callbacks[n],i=0,a=s.length;i<a;i++)s[i]._groupName===t&&(s.splice(i,1),i--,a--);return this},r.off=function(t,n){this.callbacks=this.callbacks||{};var i=this.callbacks[t],a;return i?arguments.length===1?(delete this.callbacks[t],this):(a=i.indexOf(n),a!==-1&&(i.splice(a,1),i.length===0&&delete this.callbacks[t]),this):this},r.emit=function(t){this.callbacks=this.callbacks||{};var n=[].slice.call(arguments,1),i=this.callbacks[t],a=this.getWildcardCallbacks(t),s,c,o;if(i)for(o=i.slice(),s=0,c=o.length;s<c&&o[s];++s)o[s].apply(this,n);if(a)for(c=a.length,o=a.slice(),s=0,c=o.length;s<c&&o[s];++s)o[s].apply(this,[t].concat(n));return this},r.getWildcardCallbacks=function(t){this.callbacks=this.callbacks||{};var n,i,a=[];for(n in this.callbacks)i=n.split("*"),(n==="*"||i.length===2&&t.slice(0,i[0].length)===i[0])&&(a=a.concat(this.callbacks[n]));return a}};yl.mixin(yl);var Kk={exports:{}};(function(e){(function(r,t){e.exports?e.exports=t():r.prefix=t(r)})(ze,function(r){var t=function(l){for(var f=1,d=arguments.length,p;f<d;f++)for(p in arguments[f])Object.prototype.hasOwnProperty.call(arguments[f],p)&&(l[p]=arguments[f][p]);return l},n={template:"[%t] %l:",levelFormatter:function(l){return l.toUpperCase()},nameFormatter:function(l){return l||"root"},timestampFormatter:function(l){return l.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")},format:void 0},i,a={},s=function(l){if(!l||!l.getLogger)throw new TypeError("Argument is not a root logger");i=l},c=function(l,f){if(!l||!l.setLevel)throw new TypeError("Argument is not a logger");var d=l.methodFactory,p=l.name||"",h=a[p]||a[""]||n;function E(M,I,x){var j=d(M,I,x),z=a[x]||a[""],ie=z.template.indexOf("%t")!==-1,oe=z.template.indexOf("%l")!==-1,J=z.template.indexOf("%n")!==-1;return function(){for(var L="",Y=arguments.length,Z=Array(Y),ye=0;ye<Y;ye++)Z[ye]=arguments[ye];if(p||!a[x]){var Re=z.timestampFormatter(new Date),ae=z.levelFormatter(M),Ve=z.nameFormatter(x);z.format?L+=z.format(ae,Ve,Re):(L+=z.template,ie&&(L=L.replace(/%t/,Re)),oe&&(L=L.replace(/%l/,ae)),J&&(L=L.replace(/%n/,Ve))),Z.length&&typeof Z[0]=="string"?Z[0]=L+" "+Z[0]:Z.unshift(L)}j.apply(void 0,Z)}}return a[p]||(l.methodFactory=E),f=f||{},f.template&&(f.format=void 0),a[p]=t({},h,f),l.setLevel(l.getLevel()),i||l.warn("It is necessary to call the function reg() of loglevel-plugin-prefix before calling apply. From the next release, it will throw an error. See more: https://github.com/kutuluk/loglevel-plugin-prefix/blob/master/README.md"),l},o={reg:s,apply:c},u;return r&&(u=r.prefix,o.noConflict=function(){return r.prefix===o&&(r.prefix=u),o}),o})})(Kk);var v7=Kk.exports,mh={exports:{}},m7={"error:application:call:params":{type:"error:application:call:params",description:"not a valid String[] of usernames param"},"error:application:callServer:params":{type:"error:application:call:params",description:"not a valid String of phone number"},"error:call:reject":{type:"error:call:reject",description:"failed to reject the call"},"error:getUserMedia:permissions":{type:"error:getUserMedia:permissions",description:"missing getUserMedia permissions"},"error:media:params":{type:"error:media:params",description:"currently supported params media type= {audio:{muted:false, earmuffed:false}}"},"error:media:reenable":{type:"error:media:reenable",description:"missing reconnectRtcId required to reenable media"},"error:self":{type:"error:self",description:"Conversation Object is missing self (me)"},"error:user:relogin":{type:"error:user:relogin",description:"please relogin"},"error:seen:own-message":{type:"error:seen:own-message",description:"attempt to send seen for own message"},"error:already-seen":{type:"error:already-seen",description:"already marked as seen"},"error:delivered:own-message":{type:"error:delivered:own-message",description:"attempt to send delivered for own message"},"error:already-delivered":{type:"error:already-delivered",description:"already marked as delivered"},"error:fetch-image":{type:"error:fetch-image",description:"xhr.status received other than 200"},"error:delete-image":{type:"error:delete-image",description:"xhr.status received other than 204"},"error:missing:params":{type:"error:missing:params",description:"missing parameters"},"error:invite:missing:params":{type:"error:missing:params",description:"This invite cannot be sent to empty username and user_id"},"error:invalid:param:type":{type:"error:invalid:param:type",description:"Invalid Object type, passed in the parameters"},"error:audio:already-connecting":{type:"error:audio:already-connecting",description:"Audio call already in progress"},"error:audio:not-enabled":{type:"error:audio:not-enabled",description:"Audio is not enabled"},"error:media:already-connecting":{type:"error:media:already-connecting",description:"Media is already in progress"},"error:media:unsupported-browser":{type:"error:media:unsupported-browser",description:"This action is not supported on this browser"},"error:media:extension":{type:"error:media:extension",description:"Chrome extension has thrown an error"},"error:media:extension-not-installed":{type:"error:media:extension-not-installed",description:"Chrome extension should be installed"},"error:media:update:streams":{type:"error:media:update:streams",description:"cant update more than one stream"},"error:media:update:invalid":{type:"error:media:update:invalid",description:"state of media is not supported for this update"},"error:media:stream:not-found":{type:"error:media:stream:not-found",description:"A stream with the given index was not found"},"error:audio:dtmf:invalid-digit":{type:"error:audio:dtmf:invalid-digit",description:"not a valid string of dtmf digits (0-9,a-d,A-D,p,P,*,#)"},"error:audio:dtmf:audio-disabled":{type:"error:audio:dtmf:audio-disabled",description:"Audio must be enabled to send DTMF"},"error:invalid-order":{type:"error:invalid-order",description:"params not valid. Order must be asc or desc"},"error:custom-event:invalid":{type:"error:custom-event:invalid",description:"Custom event type not valid"},"error:message-event:invalid":{type:"error:message-event:invalid",description:"message_type is missing or is invalid"},"error:invalid-cursor":{type:"error:invalid-cursor",description:"page does not exist"},"error:client:reconnection_failed":{type:"error:client:reconnection_failed",description:"websocket failed to reconnect"},"error:conversation-service:version":{type:"error:conversation:version",description:'Wrong version of Conversation Service API. It should be one of "v1" or "v3"'},"error:no-media-offer":{type:"error:no-media-offer",description:"Media preload attempt without having an offer available"}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.NexmoApiError=r.NexmoClientError=void 0;const t=m7,n=pr;function i(c,o){o&&o.code&&(o.type=o.code,delete o.code),Object.assign(c,o),c.message="type: "+c.type+", description: "+(c.description?c.description:"")}class a{constructor(o){const u=t[o];u?i(this,u):(this.message=o&&o.message?o.message:o,this.stack=o.stack),this.log=n.getLogger(this.constructor.name),this.log.error(this),this.name="NexmoClientError",typeof ze.NXMbugsnagClient<"u"&&ze.NXMbugsnagClient.notify(this,{severity:"info"})}}r.NexmoClientError=a;class s{constructor(o){this.log=n.getLogger(this.constructor.name),o?i(this,o):(this.message=o&&o.message?o.message:o,this.stack=o&&o.stack?o.stack:new Error().stack),this.name="NexmoApiError",this.log=n.getLogger(this.constructor.name),this.log.error(this),typeof ze.NXMbugsnagClient<"u"&&ze.NXMbugsnagClient.notify(this,{severity:"info"})}}r.NexmoApiError=s,e.exports={NexmoClientError:a,NexmoApiError:s}})(mh,mh.exports);var In=mh.exports,gh={exports:{}},lf={},Pm={},ff={},Lu={},eo={},mo={},Fr={},Am={},Ii={};Object.defineProperty(Ii,"__esModule",{value:!0});Ii.ERROR_PACKET=Ii.PACKET_TYPES_REVERSE=Ii.PACKET_TYPES=void 0;const ni=Object.create(null);Ii.PACKET_TYPES=ni;ni.open="0";ni.close="1";ni.ping="2";ni.pong="3";ni.message="4";ni.upgrade="5";ni.noop="6";const Jk=Object.create(null);Ii.PACKET_TYPES_REVERSE=Jk;Object.keys(ni).forEach(e=>{Jk[ni[e]]=e});const g7={type:"error",data:"parser error"};Ii.ERROR_PACKET=g7;Object.defineProperty(Am,"__esModule",{value:!0});const y7=Ii,b7=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",_7=typeof ArrayBuffer=="function",S7=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,w7=({type:e,data:r},t,n)=>b7&&r instanceof Blob?t?n(r):PS(r,n):_7&&(r instanceof ArrayBuffer||S7(r))?t?n(r):PS(new Blob([r]),n):n(y7.PACKET_TYPES[e]+(r||"")),PS=(e,r)=>{const t=new FileReader;return t.onload=function(){const n=t.result.split(",")[1];r("b"+(n||""))},t.readAsDataURL(e)};Am.default=w7;var Mm={},to={};Object.defineProperty(to,"__esModule",{value:!0});to.decode=to.encode=void 0;const Ns="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",qo=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<Ns.length;e++)qo[Ns.charCodeAt(e)]=e;const T7=e=>{let r=new Uint8Array(e),t,n=r.length,i="";for(t=0;t<n;t+=3)i+=Ns[r[t]>>2],i+=Ns[(r[t]&3)<<4|r[t+1]>>4],i+=Ns[(r[t+1]&15)<<2|r[t+2]>>6],i+=Ns[r[t+2]&63];return n%3===2?i=i.substring(0,i.length-1)+"=":n%3===1&&(i=i.substring(0,i.length-2)+"=="),i};to.encode=T7;const C7=e=>{let r=e.length*.75,t=e.length,n,i=0,a,s,c,o;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);const u=new ArrayBuffer(r),l=new Uint8Array(u);for(n=0;n<t;n+=4)a=qo[e.charCodeAt(n)],s=qo[e.charCodeAt(n+1)],c=qo[e.charCodeAt(n+2)],o=qo[e.charCodeAt(n+3)],l[i++]=a<<2|s>>4,l[i++]=(s&15)<<4|c>>2,l[i++]=(c&3)<<6|o&63;return u};to.decode=C7;Object.defineProperty(Mm,"__esModule",{value:!0});const bc=Ii,E7=to,k7=typeof ArrayBuffer=="function",R7=(e,r)=>{if(typeof e!="string")return{type:"message",data:Yk(e,r)};const t=e.charAt(0);return t==="b"?{type:"message",data:$7(e.substring(1),r)}:bc.PACKET_TYPES_REVERSE[t]?e.length>1?{type:bc.PACKET_TYPES_REVERSE[t],data:e.substring(1)}:{type:bc.PACKET_TYPES_REVERSE[t]}:bc.ERROR_PACKET},$7=(e,r)=>{if(k7){const t=(0,E7.decode)(e);return Yk(t,r)}else return{base64:!0,data:e}},Yk=(e,r)=>{switch(r){case"blob":return e instanceof ArrayBuffer?new Blob([e]):e;case"arraybuffer":default:return e}};Mm.default=R7;Object.defineProperty(Fr,"__esModule",{value:!0});Fr.decodePayload=Fr.decodePacket=Fr.encodePayload=Fr.encodePacket=Fr.protocol=void 0;const Xk=Am;Fr.encodePacket=Xk.default;const Qk=Mm;Fr.decodePacket=Qk.default;const Zk=String.fromCharCode(30),O7=(e,r)=>{const t=e.length,n=new Array(t);let i=0;e.forEach((a,s)=>{(0,Xk.default)(a,!1,c=>{n[s]=c,++i===t&&r(n.join(Zk))})})};Fr.encodePayload=O7;const I7=(e,r)=>{const t=e.split(Zk),n=[];for(let i=0;i<t.length;i++){const a=(0,Qk.default)(t[i],r);if(n.push(a),a.type==="error")break}return n};Fr.decodePayload=I7;Fr.protocol=4;function Ur(e){if(e)return P7(e)}function P7(e){for(var r in Ur.prototype)e[r]=Ur.prototype[r];return e}Ur.prototype.on=Ur.prototype.addEventListener=function(e,r){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(r),this};Ur.prototype.once=function(e,r){function t(){this.off(e,t),r.apply(this,arguments)}return t.fn=r,this.on(e,t),this};Ur.prototype.off=Ur.prototype.removeListener=Ur.prototype.removeAllListeners=Ur.prototype.removeEventListener=function(e,r){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+e];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var n,i=0;i<t.length;i++)if(n=t[i],n===r||n.fn===r){t.splice(i,1);break}return t.length===0&&delete this._callbacks["$"+e],this};Ur.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var r=new Array(arguments.length-1),t=this._callbacks["$"+e],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if(t){t=t.slice(0);for(var n=0,i=t.length;n<i;++n)t[n].apply(this,r)}return this};Ur.prototype.emitReserved=Ur.prototype.emit;Ur.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};Ur.prototype.hasListeners=function(e){return!!this.listeners(e).length};const A7=Object.freeze(Object.defineProperty({__proto__:null,Emitter:Ur},Symbol.toStringTag,{value:"Module"})),go=kw(A7);var Cn={},hs={};Object.defineProperty(hs,"__esModule",{value:!0});hs.globalThisShim=void 0;hs.globalThisShim=(()=>typeof self<"u"?self:typeof window<"u"?window:Function("return this")())();Object.defineProperty(Cn,"__esModule",{value:!0});Cn.byteLength=Cn.installTimerFunctions=Cn.pick=void 0;const sa=hs;function M7(e,...r){return r.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}Cn.pick=M7;const x7=sa.globalThisShim.setTimeout,N7=sa.globalThisShim.clearTimeout;function L7(e,r){r.useNativeTimers?(e.setTimeoutFn=x7.bind(sa.globalThisShim),e.clearTimeoutFn=N7.bind(sa.globalThisShim)):(e.setTimeoutFn=sa.globalThisShim.setTimeout.bind(sa.globalThisShim),e.clearTimeoutFn=sa.globalThisShim.clearTimeout.bind(sa.globalThisShim))}Cn.installTimerFunctions=L7;const D7=1.33;function j7(e){return typeof e=="string"?F7(e):Math.ceil((e.byteLength||e.size)*D7)}Cn.byteLength=j7;function F7(e){let r=0,t=0;for(let n=0,i=e.length;n<i;n++)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:r<55296||r>=57344?t+=3:(n++,t+=4);return t}var yh={exports:{}},ap,AS;function U7(){if(AS)return ap;AS=1;var e=1e3,r=e*60,t=r*60,n=t*24,i=n*7,a=n*365.25;ap=function(l,f){f=f||{};var d=typeof l;if(d==="string"&&l.length>0)return s(l);if(d==="number"&&isFinite(l))return f.long?o(l):c(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))};function s(l){if(l=String(l),!(l.length>100)){var f=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(f){var d=parseFloat(f[1]),p=(f[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return d*a;case"weeks":case"week":case"w":return d*i;case"days":case"day":case"d":return d*n;case"hours":case"hour":case"hrs":case"hr":case"h":return d*t;case"minutes":case"minute":case"mins":case"min":case"m":return d*r;case"seconds":case"second":case"secs":case"sec":case"s":return d*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return d;default:return}}}}function c(l){var f=Math.abs(l);return f>=n?Math.round(l/n)+"d":f>=t?Math.round(l/t)+"h":f>=r?Math.round(l/r)+"m":f>=e?Math.round(l/e)+"s":l+"ms"}function o(l){var f=Math.abs(l);return f>=n?u(l,f,n,"day"):f>=t?u(l,f,t,"hour"):f>=r?u(l,f,r,"minute"):f>=e?u(l,f,e,"second"):l+" ms"}function u(l,f,d,p){var h=f>=d*1.5;return Math.round(l/d)+" "+p+(h?"s":"")}return ap}function B7(e){t.debug=t,t.default=t,t.coerce=o,t.disable=a,t.enable=i,t.enabled=s,t.humanize=U7(),t.destroy=u,Object.keys(e).forEach(l=>{t[l]=e[l]}),t.names=[],t.skips=[],t.formatters={};function r(l){let f=0;for(let d=0;d<l.length;d++)f=(f<<5)-f+l.charCodeAt(d),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=r;function t(l){let f,d=null,p,h;function E(...M){if(!E.enabled)return;const I=E,x=Number(new Date),j=x-(f||x);I.diff=j,I.prev=f,I.curr=x,f=x,M[0]=t.coerce(M[0]),typeof M[0]!="string"&&M.unshift("%O");let z=0;M[0]=M[0].replace(/%([a-zA-Z%])/g,(oe,J)=>{if(oe==="%%")return"%";z++;const L=t.formatters[J];if(typeof L=="function"){const Y=M[z];oe=L.call(I,Y),M.splice(z,1),z--}return oe}),t.formatArgs.call(I,M),(I.log||t.log).apply(I,M)}return E.namespace=l,E.useColors=t.useColors(),E.color=t.selectColor(l),E.extend=n,E.destroy=t.destroy,Object.defineProperty(E,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(p!==t.namespaces&&(p=t.namespaces,h=t.enabled(l)),h),set:M=>{d=M}}),typeof t.init=="function"&&t.init(E),E}function n(l,f){const d=t(this.namespace+(typeof f>"u"?":":f)+l);return d.log=this.log,d}function i(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let f;const d=(typeof l=="string"?l:"").split(/[\s,]+/),p=d.length;for(f=0;f<p;f++)d[f]&&(l=d[f].replace(/\*/g,".*?"),l[0]==="-"?t.skips.push(new RegExp("^"+l.slice(1)+"$")):t.names.push(new RegExp("^"+l+"$")))}function a(){const l=[...t.names.map(c),...t.skips.map(c).map(f=>"-"+f)].join(",");return t.enable(""),l}function s(l){if(l[l.length-1]==="*")return!0;let f,d;for(f=0,d=t.skips.length;f<d;f++)if(t.skips[f].test(l))return!1;for(f=0,d=t.names.length;f<d;f++)if(t.names[f].test(l))return!0;return!1}function c(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function o(l){return l instanceof Error?l.stack||l.message:l}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}var q7=B7;(function(e,r){r.formatArgs=n,r.save=i,r.load=a,r.useColors=t,r.storage=s(),r.destroy=(()=>{let o=!1;return()=>{o||(o=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),r.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function t(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function n(o){if(o[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+o[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const u="color: "+this.color;o.splice(1,0,u,"color: inherit");let l=0,f=0;o[0].replace(/%[a-zA-Z%]/g,d=>{d!=="%%"&&(l++,d==="%c"&&(f=l))}),o.splice(f,0,u)}r.log=console.debug||console.log||(()=>{});function i(o){try{o?r.storage.setItem("debug",o):r.storage.removeItem("debug")}catch{}}function a(){let o;try{o=r.storage.getItem("debug")}catch{}return!o&&typeof process<"u"&&"env"in process&&(o=process.env.DEBUG),o}function s(){try{return localStorage}catch{}}e.exports=q7(r);const{formatters:c}=e.exports;c.j=function(o){try{return JSON.stringify(o)}catch(u){return"[UnexpectedJSONParseError]: "+u.message}}})(yh,yh.exports);var Vi=yh.exports,G7=ze&&ze.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(mo,"__esModule",{value:!0});mo.Transport=void 0;const z7=Fr,W7=go,V7=Cn,H7=G7(Vi),K7=(0,H7.default)("engine.io-client:transport");class J7 extends Error{constructor(r,t,n){super(r),this.description=t,this.context=n,this.type="TransportError"}}class Y7 extends W7.Emitter{constructor(r){super(),this.writable=!1,(0,V7.installTimerFunctions)(this,r),this.opts=r,this.query=r.query,this.socket=r.socket}onError(r,t,n){return super.emitReserved("error",new J7(r,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(r){this.readyState==="open"?this.write(r):K7("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(r){const t=(0,z7.decodePacket)(r,this.socket.binaryType);this.onPacket(t)}onPacket(r){super.emitReserved("packet",r)}onClose(r){this.readyState="closed",super.emitReserved("close",r)}pause(r){}}mo.Transport=Y7;var Pi={};Object.defineProperty(Pi,"__esModule",{value:!0});Pi.yeast=Pi.decode=Pi.encode=void 0;const eR="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),bl=64,tR={};let MS=0,la=0,xS;function bh(e){let r="";do r=eR[e%bl]+r,e=Math.floor(e/bl);while(e>0);return r}Pi.encode=bh;function X7(e){let r=0;for(la=0;la<e.length;la++)r=r*bl+tR[e.charAt(la)];return r}Pi.decode=X7;function Q7(){const e=bh(+new Date);return e!==xS?(MS=0,xS=e):e+"."+bh(MS++)}Pi.yeast=Q7;for(;la<bl;la++)tR[eR[la]]=la;var ya={};Object.defineProperty(ya,"__esModule",{value:!0});ya.decode=ya.encode=void 0;function Z7(e){let r="";for(let t in e)e.hasOwnProperty(t)&&(r.length&&(r+="&"),r+=encodeURIComponent(t)+"="+encodeURIComponent(e[t]));return r}ya.encode=Z7;function eK(e){let r={},t=e.split("&");for(let n=0,i=t.length;n<i;n++){let a=t[n].split("=");r[decodeURIComponent(a[0])]=decodeURIComponent(a[1])}return r}ya.decode=eK;var df={},pf={};Object.defineProperty(pf,"__esModule",{value:!0});pf.hasCORS=void 0;let rR=!1;try{rR=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}pf.hasCORS=rR;Object.defineProperty(df,"__esModule",{value:!0});df.XHR=void 0;const tK=pf,rK=hs;function nK(e){const r=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!r||tK.hasCORS))return new XMLHttpRequest}catch{}if(!r)try{return new rK.globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}df.XHR=nK;var iK=ze&&ze.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(eo,"__esModule",{value:!0});eo.Request=eo.Polling=void 0;const aK=mo,sK=iK(Vi),oK=Pi,uK=ya,NS=Fr,nR=df,cK=go,LS=Cn,lK=hs,Xr=(0,sK.default)("engine.io-client:polling");function fK(){}const dK=function(){return new nR.XHR({xdomain:!1}).responseType!=null}();class pK extends aK.Transport{constructor(r){if(super(r),this.polling=!1,typeof location<"u"){const n=location.protocol==="https:";let i=location.port;i||(i=n?"443":"80"),this.xd=typeof location<"u"&&r.hostname!==location.hostname||i!==r.port,this.xs=r.secure!==n}const t=r&&r.forceBase64;this.supportsBinary=dK&&!t}get name(){return"polling"}doOpen(){this.poll()}pause(r){this.readyState="pausing";const t=()=>{Xr("paused"),this.readyState="paused",r()};if(this.polling||!this.writable){let n=0;this.polling&&(Xr("we are currently polling - waiting to pause"),n++,this.once("pollComplete",function(){Xr("pre-pause polling complete"),--n||t()})),this.writable||(Xr("we are currently writing - waiting to pause"),n++,this.once("drain",function(){Xr("pre-pause writing complete"),--n||t()}))}else t()}poll(){Xr("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(r){Xr("polling got data %s",r);const t=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};(0,NS.decodePayload)(r,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this.poll():Xr('ignoring poll - transport state "%s"',this.readyState))}doClose(){const r=()=>{Xr("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(Xr("transport open - closing"),r()):(Xr("transport not open - deferring close"),this.once("open",r))}write(r){this.writable=!1,(0,NS.encodePayload)(r,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let r=this.query||{};const t=this.opts.secure?"https":"http";let n="";this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=(0,oK.yeast)()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.opts.port&&(t==="https"&&Number(this.opts.port)!==443||t==="http"&&Number(this.opts.port)!==80)&&(n=":"+this.opts.port);const i=(0,uK.encode)(r),a=this.opts.hostname.indexOf(":")!==-1;return t+"://"+(a?"["+this.opts.hostname+"]":this.opts.hostname)+n+this.opts.path+(i.length?"?"+i:"")}request(r={}){return Object.assign(r,{xd:this.xd,xs:this.xs},this.opts),new Gn(this.uri(),r)}doWrite(r,t){const n=this.request({method:"POST",data:r});n.on("success",t),n.on("error",(i,a)=>{this.onError("xhr post error",i,a)})}doPoll(){Xr("xhr poll");const r=this.request();r.on("data",this.onData.bind(this)),r.on("error",(t,n)=>{this.onError("xhr poll error",t,n)}),this.pollXhr=r}}eo.Polling=pK;class Gn extends cK.Emitter{constructor(r,t){super(),(0,LS.installTimerFunctions)(this,t),this.opts=t,this.method=t.method||"GET",this.uri=r,this.async=t.async!==!1,this.data=t.data!==void 0?t.data:null,this.create()}create(){const r=(0,LS.pick)(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this.opts.xd,r.xscheme=!!this.opts.xs;const t=this.xhr=new nR.XHR(r);try{Xr("xhr open %s: %s",this.method,this.uri),t.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){t.setDisableHeaderCheck&&t.setDisableHeaderCheck(!0);for(let n in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(n)&&t.setRequestHeader(n,this.opts.extraHeaders[n])}}catch{}if(this.method==="POST")try{t.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{t.setRequestHeader("Accept","*/*")}catch{}"withCredentials"in t&&(t.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(t.timeout=this.opts.requestTimeout),t.onreadystatechange=()=>{t.readyState===4&&(t.status===200||t.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof t.status=="number"?t.status:0)},0))},Xr("xhr data %s",this.data),t.send(this.data)}catch(n){this.setTimeoutFn(()=>{this.onError(n)},0);return}typeof document<"u"&&(this.index=Gn.requestsCount++,Gn.requests[this.index]=this)}onError(r){this.emitReserved("error",r,this.xhr),this.cleanup(!0)}cleanup(r){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.xhr.onreadystatechange=fK,r)try{this.xhr.abort()}catch{}typeof document<"u"&&delete Gn.requests[this.index],this.xhr=null}}onLoad(){const r=this.xhr.responseText;r!==null&&(this.emitReserved("data",r),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}eo.Request=Gn;Gn.requestsCount=0;Gn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",DS);else if(typeof addEventListener=="function"){const e="onpagehide"in lK.globalThisShim?"pagehide":"unload";addEventListener(e,DS,!1)}}function DS(){for(let e in Gn.requests)Gn.requests.hasOwnProperty(e)&&Gn.requests[e].abort()}var hf={},qn={};Object.defineProperty(qn,"__esModule",{value:!0});qn.defaultBinaryType=qn.usingBrowserWebSocket=qn.WebSocket=qn.nextTick=void 0;const jS=hs;qn.nextTick=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?r=>Promise.resolve().then(r):(r,t)=>t(r,0))();qn.WebSocket=jS.globalThisShim.WebSocket||jS.globalThisShim.MozWebSocket;qn.usingBrowserWebSocket=!0;qn.defaultBinaryType="arraybuffer";var hK=ze&&ze.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(hf,"__esModule",{value:!0});hf.WS=void 0;const vK=mo,mK=ya,gK=Pi,yK=Cn,Si=qn,bK=hK(Vi),_K=Fr,SK=(0,bK.default)("engine.io-client:websocket"),FS=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class wK extends vK.Transport{constructor(r){super(r),this.supportsBinary=!r.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const r=this.uri(),t=this.opts.protocols,n=FS?{}:(0,yK.pick)(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=Si.usingBrowserWebSocket&&!FS?t?new Si.WebSocket(r,t):new Si.WebSocket(r):new Si.WebSocket(r,t,n)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType||Si.defaultBinaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=r=>this.onClose({description:"websocket connection closed",context:r}),this.ws.onmessage=r=>this.onData(r.data),this.ws.onerror=r=>this.onError("websocket error",r)}write(r){this.writable=!1;for(let t=0;t<r.length;t++){const n=r[t],i=t===r.length-1;(0,_K.encodePacket)(n,this.supportsBinary,a=>{const s={};Si.usingBrowserWebSocket||(n.options&&(s.compress=n.options.compress),this.opts.perMessageDeflate&&(typeof a=="string"?Buffer.byteLength(a):a.length)<this.opts.perMessageDeflate.threshold&&(s.compress=!1));try{Si.usingBrowserWebSocket?this.ws.send(a):this.ws.send(a,s)}catch{SK("websocket closed before onclose event")}i&&(0,Si.nextTick)(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){let r=this.query||{};const t=this.opts.secure?"wss":"ws";let n="";this.opts.port&&(t==="wss"&&Number(this.opts.port)!==443||t==="ws"&&Number(this.opts.port)!==80)&&(n=":"+this.opts.port),this.opts.timestampRequests&&(r[this.opts.timestampParam]=(0,gK.yeast)()),this.supportsBinary||(r.b64=1);const i=(0,mK.encode)(r),a=this.opts.hostname.indexOf(":")!==-1;return t+"://"+(a?"["+this.opts.hostname+"]":this.opts.hostname)+n+this.opts.path+(i.length?"?"+i:"")}check(){return!!Si.WebSocket}}hf.WS=wK;Object.defineProperty(Lu,"__esModule",{value:!0});Lu.transports=void 0;const TK=eo,CK=hf;Lu.transports={websocket:CK.WS,polling:TK.Polling};var Du={};Object.defineProperty(Du,"__esModule",{value:!0});Du.parse=void 0;const EK=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,kK=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function RK(e){const r=e,t=e.indexOf("["),n=e.indexOf("]");t!=-1&&n!=-1&&(e=e.substring(0,t)+e.substring(t,n).replace(/:/g,";")+e.substring(n,e.length));let i=EK.exec(e||""),a={},s=14;for(;s--;)a[kK[s]]=i[s]||"";return t!=-1&&n!=-1&&(a.source=r,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=$K(a,a.path),a.queryKey=OK(a,a.query),a}Du.parse=RK;function $K(e,r){const t=/\/{2,9}/g,n=r.replace(t,"/").split("/");return(r.slice(0,1)=="/"||r.length===0)&&n.splice(0,1),r.slice(-1)=="/"&&n.splice(n.length-1,1),n}function OK(e,r){const t={};return r.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,i,a){i&&(t[i]=a)}),t}var IK=ze&&ze.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ff,"__esModule",{value:!0});ff.Socket=void 0;const PK=Lu,US=Cn,AK=ya,BS=Du,MK=IK(Vi),xK=go,iR=Fr,er=(0,MK.default)("engine.io-client:socket");let aR=class Is extends xK.Emitter{constructor(r,t={}){super(),this.writeBuffer=[],r&&typeof r=="object"&&(t=r,r=null),r?(r=(0,BS.parse)(r),t.hostname=r.host,t.secure=r.protocol==="https"||r.protocol==="wss",t.port=r.port,r.query&&(t.query=r.query)):t.host&&(t.hostname=(0,BS.parse)(t.host).host),(0,US.installTimerFunctions)(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=(0,AK.decode)(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(r){er('creating transport "%s"',r);const t=Object.assign({},this.opts.query);t.EIO=iR.protocol,t.transport=r,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts.transportOptions[r],this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return er("options: %j",n),new PK.transports[r](n)}open(){let r;if(this.opts.rememberUpgrade&&Is.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)r="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else r=this.transports[0];this.readyState="opening";try{r=this.createTransport(r)}catch(t){er("error while creating transport: %s",t),this.transports.shift(),this.open();return}r.open(),this.setTransport(r)}setTransport(r){er("setting transport %s",r.name),this.transport&&(er("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=r,r.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",t=>this.onClose("transport close",t))}probe(r){er('probing transport "%s"',r);let t=this.createTransport(r),n=!1;Is.priorWebsocketSuccess=!1;const i=()=>{n||(er('probe transport "%s" opened',r),t.send([{type:"ping",data:"probe"}]),t.once("packet",f=>{if(!n)if(f.type==="pong"&&f.data==="probe"){if(er('probe transport "%s" pong',r),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;Is.priorWebsocketSuccess=t.name==="websocket",er('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{n||this.readyState!=="closed"&&(er("changing transport and sending upgrade packet"),l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{er('probe transport "%s" failed',r);const d=new Error("probe error");d.transport=t.name,this.emitReserved("upgradeError",d)}}))};function a(){n||(n=!0,l(),t.close(),t=null)}const s=f=>{const d=new Error("probe error: "+f);d.transport=t.name,a(),er('probe transport "%s" failed because of error: %s',r,f),this.emitReserved("upgradeError",d)};function c(){s("transport closed")}function o(){s("socket closed")}function u(f){t&&f.name!==t.name&&(er('"%s" works - aborting "%s"',f.name,t.name),a())}const l=()=>{t.removeListener("open",i),t.removeListener("error",s),t.removeListener("close",c),this.off("close",o),this.off("upgrading",u)};t.once("open",i),t.once("error",s),t.once("close",c),this.once("close",o),this.once("upgrading",u),t.open()}onOpen(){if(er("socket open"),this.readyState="open",Is.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){er("starting upgrade probes");let r=0;const t=this.upgrades.length;for(;r<t;r++)this.probe(this.upgrades[r])}}onPacket(r){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(er('socket receive: type "%s", data "%s"',r.type,r.data),this.emitReserved("packet",r),this.emitReserved("heartbeat"),r.type){case"open":this.onHandshake(JSON.parse(r.data));break;case"ping":this.resetPingTimeout(),this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const t=new Error("server error");t.code=r.data,this.onError(t);break;case"message":this.emitReserved("data",r.data),this.emitReserved("message",r.data);break}else er('packet received with socket readyState "%s"',this.readyState)}onHandshake(r){this.emitReserved("handshake",r),this.id=r.sid,this.transport.query.sid=r.sid,this.upgrades=this.filterUpgrades(r.upgrades),this.pingInterval=r.pingInterval,this.pingTimeout=r.pingTimeout,this.maxPayload=r.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const r=this.getWritablePackets();er("flushing %d packets in socket",r.length),this.transport.send(r),this.prevBufferLen=r.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let n=0;n<this.writeBuffer.length;n++){const i=this.writeBuffer[n].data;if(i&&(t+=(0,US.byteLength)(i)),n>0&&t>this.maxPayload)return er("only send %d out of %d packets",n,this.writeBuffer.length),this.writeBuffer.slice(0,n);t+=2}return er("payload size is %d (max: %d)",t,this.maxPayload),this.writeBuffer}write(r,t,n){return this.sendPacket("message",r,t,n),this}send(r,t,n){return this.sendPacket("message",r,t,n),this}sendPacket(r,t,n,i){if(typeof t=="function"&&(i=t,t=void 0),typeof n=="function"&&(i=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;const a={type:r,data:t,options:n};this.emitReserved("packetCreate",a),this.writeBuffer.push(a),i&&this.once("flush",i),this.flush()}close(){const r=()=>{this.onClose("forced close"),er("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),r()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():r()}):this.upgrading?n():r()),this}onError(r){er("socket error %j",r),Is.priorWebsocketSuccess=!1,this.emitReserved("error",r),this.onClose("transport error",r)}onClose(r,t){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(er('socket close with reason: "%s"',r),this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",r,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(r){const t=[];let n=0;const i=r.length;for(;n<i;n++)~this.transports.indexOf(r[n])&&t.push(r[n]);return t}};ff.Socket=aR;aR.protocol=iR.protocol;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.nextTick=e.parse=e.installTimerFunctions=e.transports=e.Transport=e.protocol=e.Socket=void 0;const r=ff;Object.defineProperty(e,"Socket",{enumerable:!0,get:function(){return r.Socket}}),e.protocol=r.Socket.protocol;var t=mo;Object.defineProperty(e,"Transport",{enumerable:!0,get:function(){return t.Transport}});var n=Lu;Object.defineProperty(e,"transports",{enumerable:!0,get:function(){return n.transports}});var i=Cn;Object.defineProperty(e,"installTimerFunctions",{enumerable:!0,get:function(){return i.installTimerFunctions}});var a=Du;Object.defineProperty(e,"parse",{enumerable:!0,get:function(){return a.parse}});var s=qn;Object.defineProperty(e,"nextTick",{enumerable:!0,get:function(){return s.nextTick}})})(Pm);var NK=ze&&ze.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(lf,"__esModule",{value:!0});lf.url=void 0;const LK=Pm,DK=NK(Vi),qS=DK.default("socket.io-client:url");function jK(e,r="",t){let n=e;t=t||typeof location<"u"&&location,e==null&&(e=t.protocol+"//"+t.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=t.protocol+e:e=t.host+e),/^(https?|wss?):\/\//.test(e)||(qS("protocol-less url %s",e),typeof t<"u"?e=t.protocol+"//"+e:e="https://"+e),qS("parse %s",e),n=LK.parse(e)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const a=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+a+":"+n.port+r,n.href=n.protocol+"://"+a+(t&&t.port===n.port?"":":"+n.port),n}lf.url=jK;var vf={},ju={},mf={},ro={},es={};Object.defineProperty(es,"__esModule",{value:!0});es.hasBinary=es.isBinary=void 0;const FK=typeof ArrayBuffer=="function",UK=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,sR=Object.prototype.toString,BK=typeof Blob=="function"||typeof Blob<"u"&&sR.call(Blob)==="[object BlobConstructor]",qK=typeof File=="function"||typeof File<"u"&&sR.call(File)==="[object FileConstructor]";function oR(e){return FK&&(e instanceof ArrayBuffer||UK(e))||BK&&e instanceof Blob||qK&&e instanceof File}es.isBinary=oR;function Vc(e,r){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(Vc(e[t]))return!0;return!1}if(oR(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Vc(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&Vc(e[t]))return!0;return!1}es.hasBinary=Vc;Object.defineProperty(ro,"__esModule",{value:!0});ro.reconstructPacket=ro.deconstructPacket=void 0;const GK=es;function zK(e){const r=[],t=e.data,n=e;return n.data=_h(t,r),n.attachments=r.length,{packet:n,buffers:r}}ro.deconstructPacket=zK;function _h(e,r){if(!e)return e;if((0,GK.isBinary)(e)){const t={_placeholder:!0,num:r.length};return r.push(e),t}else if(Array.isArray(e)){const t=new Array(e.length);for(let n=0;n<e.length;n++)t[n]=_h(e[n],r);return t}else if(typeof e=="object"&&!(e instanceof Date)){const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=_h(e[n],r));return t}return e}function WK(e,r){return e.data=Sh(e.data,r),delete e.attachments,e}ro.reconstructPacket=WK;function Sh(e,r){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<r.length)return r[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let t=0;t<e.length;t++)e[t]=Sh(e[t],r);else if(typeof e=="object")for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(e[t]=Sh(e[t],r));return e}(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Decoder=e.Encoder=e.PacketType=e.protocol=void 0;const r=go,t=ro,n=es,a=(0,Vi.default)("socket.io-parser"),s=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];e.protocol=5;var c;(function(d){d[d.CONNECT=0]="CONNECT",d[d.DISCONNECT=1]="DISCONNECT",d[d.EVENT=2]="EVENT",d[d.ACK=3]="ACK",d[d.CONNECT_ERROR=4]="CONNECT_ERROR",d[d.BINARY_EVENT=5]="BINARY_EVENT",d[d.BINARY_ACK=6]="BINARY_ACK"})(c=e.PacketType||(e.PacketType={}));class o{constructor(p){this.replacer=p}encode(p){return a("encoding packet %j",p),(p.type===c.EVENT||p.type===c.ACK)&&(0,n.hasBinary)(p)?this.encodeAsBinary({type:p.type===c.EVENT?c.BINARY_EVENT:c.BINARY_ACK,nsp:p.nsp,data:p.data,id:p.id}):[this.encodeAsString(p)]}encodeAsString(p){let h=""+p.type;return(p.type===c.BINARY_EVENT||p.type===c.BINARY_ACK)&&(h+=p.attachments+"-"),p.nsp&&p.nsp!=="/"&&(h+=p.nsp+","),p.id!=null&&(h+=p.id),p.data!=null&&(h+=JSON.stringify(p.data,this.replacer)),a("encoded %j as %s",p,h),h}encodeAsBinary(p){const h=(0,t.deconstructPacket)(p),E=this.encodeAsString(h.packet),M=h.buffers;return M.unshift(E),M}}e.Encoder=o;function u(d){return Object.prototype.toString.call(d)==="[object Object]"}class l extends r.Emitter{constructor(p){super(),this.reviver=p}add(p){let h;if(typeof p=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");h=this.decodeString(p);const E=h.type===c.BINARY_EVENT;E||h.type===c.BINARY_ACK?(h.type=E?c.EVENT:c.ACK,this.reconstructor=new f(h),h.attachments===0&&super.emitReserved("decoded",h)):super.emitReserved("decoded",h)}else if((0,n.isBinary)(p)||p.base64)if(this.reconstructor)h=this.reconstructor.takeBinaryData(p),h&&(this.reconstructor=null,super.emitReserved("decoded",h));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+p)}decodeString(p){let h=0;const E={type:Number(p.charAt(0))};if(c[E.type]===void 0)throw new Error("unknown packet type "+E.type);if(E.type===c.BINARY_EVENT||E.type===c.BINARY_ACK){const I=h+1;for(;p.charAt(++h)!=="-"&&h!=p.length;);const x=p.substring(I,h);if(x!=Number(x)||p.charAt(h)!=="-")throw new Error("Illegal attachments");E.attachments=Number(x)}if(p.charAt(h+1)==="/"){const I=h+1;for(;++h&&!(p.charAt(h)===","||h===p.length););E.nsp=p.substring(I,h)}else E.nsp="/";const M=p.charAt(h+1);if(M!==""&&Number(M)==M){const I=h+1;for(;++h;){const x=p.charAt(h);if(x==null||Number(x)!=x){--h;break}if(h===p.length)break}E.id=Number(p.substring(I,h+1))}if(p.charAt(++h)){const I=this.tryParse(p.substr(h));if(l.isPayloadValid(E.type,I))E.data=I;else throw new Error("invalid payload")}return a("decoded %s as %j",p,E),E}tryParse(p){try{return JSON.parse(p,this.reviver)}catch{return!1}}static isPayloadValid(p,h){switch(p){case c.CONNECT:return u(h);case c.DISCONNECT:return h===void 0;case c.CONNECT_ERROR:return typeof h=="string"||u(h);case c.EVENT:case c.BINARY_EVENT:return Array.isArray(h)&&(typeof h[0]=="number"||typeof h[0]=="string"&&s.indexOf(h[0])===-1);case c.ACK:case c.BINARY_ACK:return Array.isArray(h)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}e.Decoder=l;class f{constructor(p){this.packet=p,this.buffers=[],this.reconPack=p}takeBinaryData(p){if(this.buffers.push(p),this.buffers.length===this.reconPack.attachments){const h=(0,t.reconstructPacket)(this.reconPack,this.buffers);return this.finishedReconstruction(),h}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}})(mf);var Fu={};Object.defineProperty(Fu,"__esModule",{value:!0});Fu.on=void 0;function VK(e,r,t){return e.on(r,t),function(){e.off(r,t)}}Fu.on=VK;var HK=ze&&ze.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ju,"__esModule",{value:!0});ju.Socket=void 0;const Nn=mf,_c=Fu,KK=go,JK=HK(Vi),gr=JK.default("socket.io-client:socket"),YK=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class XK extends KK.Emitter{constructor(r,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=r,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const r=this.io;this.subs=[_c.on(r,"open",this.onopen.bind(this)),_c.on(r,"packet",this.onpacket.bind(this)),_c.on(r,"error",this.onerror.bind(this)),_c.on(r,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...r){return r.unshift("message"),this.emit.apply(this,r),this}emit(r,...t){if(YK.hasOwnProperty(r))throw new Error('"'+r.toString()+'" is a reserved event name');if(t.unshift(r),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const n={type:Nn.PacketType.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){const s=this.ids++;gr("emitting packet with ack id %d",s);const c=t.pop();this._registerAckCallback(s,c),n.id=s}const i=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!i||!this.connected)?gr("discard packet as the transport is not currently writable"):this.connected?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n),this.flags={},this}_registerAckCallback(r,t){var n;const i=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(i===void 0){this.acks[r]=t;return}const a=this.io.setTimeoutFn(()=>{delete this.acks[r];for(let s=0;s<this.sendBuffer.length;s++)this.sendBuffer[s].id===r&&(gr("removing packet with ack id %d from the buffer",r),this.sendBuffer.splice(s,1));gr("event with ack id %d has timed out after %d ms",r,i),t.call(this,new Error("operation has timed out"))},i);this.acks[r]=(...s)=>{this.io.clearTimeoutFn(a),t.apply(this,[null,...s])}}emitWithAck(r,...t){const n=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((i,a)=>{t.push((s,c)=>n?s?a(s):i(c):i(s)),this.emit(r,...t)})}_addToQueue(r){let t;typeof r[r.length-1]=="function"&&(t=r.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:r,flags:Object.assign({fromQueue:!0},this.flags)};r.push((i,...a)=>n!==this._queue[0]?void 0:(i!==null?n.tryCount>this._opts.retries&&(gr("packet [%d] is discarded after %d tries",n.id,n.tryCount),this._queue.shift(),t&&t(i)):(gr("packet [%d] was successfully sent",n.id),this._queue.shift(),t&&t(null,...a)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(r=!1){if(gr("draining queue"),!this.connected||this._queue.length===0)return;const t=this._queue[0];if(t.pending&&!r){gr("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,gr("sending packet [%d] (try n°%d)",t.id,t.tryCount),this.flags=t.flags,this.emit.apply(this,t.args)}packet(r){r.nsp=this.nsp,this.io._packet(r)}onopen(){gr("transport is open - connecting"),typeof this.auth=="function"?this.auth(r=>{this._sendConnectPacket(r)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(r){this.packet({type:Nn.PacketType.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},r):r})}onerror(r){this.connected||this.emitReserved("connect_error",r)}onclose(r,t){gr("close (%s)",r),this.connected=!1,delete this.id,this.emitReserved("disconnect",r,t)}onpacket(r){if(r.nsp===this.nsp)switch(r.type){case Nn.PacketType.CONNECT:r.data&&r.data.sid?this.onconnect(r.data.sid,r.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Nn.PacketType.EVENT:case Nn.PacketType.BINARY_EVENT:this.onevent(r);break;case Nn.PacketType.ACK:case Nn.PacketType.BINARY_ACK:this.onack(r);break;case Nn.PacketType.DISCONNECT:this.ondisconnect();break;case Nn.PacketType.CONNECT_ERROR:this.destroy();const n=new Error(r.data.message);n.data=r.data.data,this.emitReserved("connect_error",n);break}}onevent(r){const t=r.data||[];gr("emitting event %j",t),r.id!=null&&(gr("attaching ack callback to event"),t.push(this.ack(r.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(r){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const n of t)n.apply(this,r)}super.emit.apply(this,r),this._pid&&r.length&&typeof r[r.length-1]=="string"&&(this._lastOffset=r[r.length-1])}ack(r){const t=this;let n=!1;return function(...i){n||(n=!0,gr("sending ack %j",i),t.packet({type:Nn.PacketType.ACK,id:r,data:i}))}}onack(r){const t=this.acks[r.id];typeof t=="function"?(gr("calling ack %s with %j",r.id,r.data),t.apply(this,r.data),delete this.acks[r.id]):gr("bad ack %s",r.id)}onconnect(r,t){gr("socket connected with id %s",r),this.id=r,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(r=>this.emitEvent(r)),this.receiveBuffer=[],this.sendBuffer.forEach(r=>{this.notifyOutgoingListeners(r),this.packet(r)}),this.sendBuffer=[]}ondisconnect(){gr("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(r=>r()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(gr("performing disconnect (%s)",this.nsp),this.packet({type:Nn.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(r){return this.flags.compress=r,this}get volatile(){return this.flags.volatile=!0,this}timeout(r){return this.flags.timeout=r,this}onAny(r){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(r),this}prependAny(r){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(r),this}offAny(r){if(!this._anyListeners)return this;if(r){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(r===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(r){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(r),this}prependAnyOutgoing(r){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(r),this}offAnyOutgoing(r){if(!this._anyOutgoingListeners)return this;if(r){const t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(r===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(r){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,r.data)}}}ju.Socket=XK;var gf={};Object.defineProperty(gf,"__esModule",{value:!0});gf.Backoff=void 0;function yo(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}gf.Backoff=yo;yo.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var r=Math.random(),t=Math.floor(r*this.jitter*e);e=Math.floor(r*10)&1?e+t:e-t}return Math.min(e,this.max)|0};yo.prototype.reset=function(){this.attempts=0};yo.prototype.setMin=function(e){this.ms=e};yo.prototype.setMax=function(e){this.max=e};yo.prototype.setJitter=function(e){this.jitter=e};var QK=ze&&ze.__createBinding||(Object.create?function(e,r,t,n){n===void 0&&(n=t),Object.defineProperty(e,n,{enumerable:!0,get:function(){return r[t]}})}:function(e,r,t,n){n===void 0&&(n=t),e[n]=r[t]}),ZK=ze&&ze.__setModuleDefault||(Object.create?function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}:function(e,r){e.default=r}),eJ=ze&&ze.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var t in e)t!=="default"&&Object.prototype.hasOwnProperty.call(e,t)&&QK(r,e,t);return ZK(r,e),r},tJ=ze&&ze.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(vf,"__esModule",{value:!0});vf.Manager=void 0;const sp=Pm,rJ=ju,nJ=eJ(mf),za=Fu,iJ=gf,aJ=go,sJ=tJ(Vi),$r=sJ.default("socket.io-client:manager");class oJ extends aJ.Emitter{constructor(r,t){var n;super(),this.nsps={},this.subs=[],r&&typeof r=="object"&&(t=r,r=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,sp.installTimerFunctions(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((n=t.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new iJ.Backoff({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=r;const i=t.parser||nJ;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(r){return arguments.length?(this._reconnection=!!r,this):this._reconnection}reconnectionAttempts(r){return r===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=r,this)}reconnectionDelay(r){var t;return r===void 0?this._reconnectionDelay:(this._reconnectionDelay=r,(t=this.backoff)===null||t===void 0||t.setMin(r),this)}randomizationFactor(r){var t;return r===void 0?this._randomizationFactor:(this._randomizationFactor=r,(t=this.backoff)===null||t===void 0||t.setJitter(r),this)}reconnectionDelayMax(r){var t;return r===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=r,(t=this.backoff)===null||t===void 0||t.setMax(r),this)}timeout(r){return arguments.length?(this._timeout=r,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(r){if($r("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;$r("opening %s",this.uri),this.engine=new sp.Socket(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const i=za.on(t,"open",function(){n.onopen(),r&&r()}),a=za.on(t,"error",s=>{$r("error"),n.cleanup(),n._readyState="closed",this.emitReserved("error",s),r?r(s):n.maybeReconnectOnOpen()});if(this._timeout!==!1){const s=this._timeout;$r("connect attempt will timeout after %d",s),s===0&&i();const c=this.setTimeoutFn(()=>{$r("connect attempt timed out after %d",s),i(),t.close(),t.emit("error",new Error("timeout"))},s);this.opts.autoUnref&&c.unref(),this.subs.push(function(){clearTimeout(c)})}return this.subs.push(i),this.subs.push(a),this}connect(r){return this.open(r)}onopen(){$r("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");const r=this.engine;this.subs.push(za.on(r,"ping",this.onping.bind(this)),za.on(r,"data",this.ondata.bind(this)),za.on(r,"error",this.onerror.bind(this)),za.on(r,"close",this.onclose.bind(this)),za.on(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(r){try{this.decoder.add(r)}catch(t){this.onclose("parse error",t)}}ondecoded(r){sp.nextTick(()=>{this.emitReserved("packet",r)},this.setTimeoutFn)}onerror(r){$r("error",r),this.emitReserved("error",r)}socket(r,t){let n=this.nsps[r];return n?this._autoConnect&&!n.active&&n.connect():(n=new rJ.Socket(this,r,t),this.nsps[r]=n),n}_destroy(r){const t=Object.keys(this.nsps);for(const n of t)if(this.nsps[n].active){$r("socket %s is still active, skipping close",n);return}this._close()}_packet(r){$r("writing packet %j",r);const t=this.encoder.encode(r);for(let n=0;n<t.length;n++)this.engine.write(t[n],r.options)}cleanup(){$r("cleanup"),this.subs.forEach(r=>r()),this.subs.length=0,this.decoder.destroy()}_close(){$r("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(r,t){$r("closed due to %s",r),this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",r,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const r=this;if(this.backoff.attempts>=this._reconnectionAttempts)$r("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();$r("will wait %dms before reconnect attempt",t),this._reconnecting=!0;const n=this.setTimeoutFn(()=>{r.skipReconnect||($r("attempting reconnect"),this.emitReserved("reconnect_attempt",r.backoff.attempts),!r.skipReconnect&&r.open(i=>{i?($r("reconnect attempt error"),r._reconnecting=!1,r.reconnect(),this.emitReserved("reconnect_error",i)):($r("reconnect success"),r.onreconnect())}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(function(){clearTimeout(n)})}}onreconnect(){const r=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",r)}}vf.Manager=oJ;(function(e,r){var t=ze&&ze.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.connect=r.io=r.Socket=r.Manager=r.protocol=void 0;const n=lf,i=vf;Object.defineProperty(r,"Manager",{enumerable:!0,get:function(){return i.Manager}});const a=ju;Object.defineProperty(r,"Socket",{enumerable:!0,get:function(){return a.Socket}});const c=t(Vi).default("socket.io-client"),o={};function u(f,d){typeof f=="object"&&(d=f,f=void 0),d=d||{};const p=n.url(f,d.path||"/socket.io"),h=p.source,E=p.id,M=p.path,I=o[E]&&M in o[E].nsps,x=d.forceNew||d["force new connection"]||d.multiplex===!1||I;let j;return x?(c("ignoring socket cache for %s",h),j=new i.Manager(h,d)):(o[E]||(c("new io instance for %s",h),o[E]=new i.Manager(h,d)),j=o[E]),p.query&&!d.query&&(d.query=p.queryKey),j.socket(p.path,d)}r.io=u,r.connect=u,r.default=u,Object.assign(u,{Manager:i.Manager,Socket:a.Socket,io:u,connect:u});var l=mf;Object.defineProperty(r,"protocol",{enumerable:!0,get:function(){return l.protocol}}),e.exports=u})(gh,gh.exports);var uR=gh.exports,cR={exports:{}};(function(e,r){(function(t){e.exports=t()})(function(){var t=function(C,A,D){for(var W=D,V=0,he=C.length;V<he;V++)W=A(W,C[V],V,C);return W},n=function(C,A){return t(C,function(D,W,V,he){return A(W,V,he)?D.concat(W):D},[])},i=function(C,A){return t(C,function(D,W,V,he){return D.concat(A(W,V,he))},[])},a=function(C,A){return t(C,function(D,W,V,he){return D===!0||W===A},!1)},s=!{toString:null}.propertyIsEnumerable("toString"),c=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],o=function(C){var A=[],D;for(D in C)Object.prototype.hasOwnProperty.call(C,D)&&A.push(D);if(!s)return A;for(var W=0,V=c.length;W<V;W++)Object.prototype.hasOwnProperty.call(C,c[W])&&A.push(c[W]);return A},u=function(C){return Object.prototype.toString.call(C)==="[object Array]"},l=function(C){return C<10?"0"+C:C},f=function(){var C=new Date;return C.getUTCFullYear()+"-"+l(C.getUTCMonth()+1)+"-"+l(C.getUTCDate())+"T"+l(C.getUTCHours())+":"+l(C.getUTCMinutes())+":"+l(C.getUTCSeconds())+"."+(C.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"},d={map:i,reduce:t,filter:n,includes:a,keys:o,isArray:u,isoDate:f},p={};p.intRange=function(C,A){return C===void 0&&(C=1),A===void 0&&(A=1/0),function(D){return typeof D=="number"&&parseInt(""+D,10)===D&&D>=C&&D<=A}},p.stringWithLength=function(C){return typeof C=="string"&&!!C.length};var h={},E=d.filter,M=d.reduce,I=d.keys,x=d.isArray,j=d.includes,z=p.intRange,ie=p.stringWithLength;h.schema={apiKey:{defaultValue:function(){return null},message:"is required",validate:ie},appVersion:{defaultValue:function(){return null},message:"should be a string",validate:function(C){return C===null||ie(C)}},appType:{defaultValue:function(){return null},message:"should be a string",validate:function(C){return C===null||ie(C)}},autoNotify:{defaultValue:function(){return!0},message:"should be true|false",validate:function(C){return C===!0||C===!1}},beforeSend:{defaultValue:function(){return[]},message:"should be a function or array of functions",validate:function(C){return typeof C=="function"||x(C)&&E(C,function(A){return typeof A=="function"}).length===C.length}},endpoints:{defaultValue:function(){return{notify:"https://notify.bugsnag.com",sessions:"https://sessions.bugsnag.com"}},message:"should be an object containing endpoint URLs { notify, sessions }. sessions is optional if autoCaptureSessions=false",validate:function(C,A){return C&&typeof C=="object"&&ie(C.notify)&&(A.autoCaptureSessions===!1||ie(C.sessions))&&E(I(C),function(D){return!j(["notify","sessions"],D)}).length===0}},autoCaptureSessions:{defaultValue:function(C,A){return A.endpoints===void 0||!!A.endpoints&&!!A.endpoints.sessions},message:"should be true|false",validate:function(C){return C===!0||C===!1}},notifyReleaseStages:{defaultValue:function(){return null},message:"should be an array of strings",validate:function(C){return C===null||x(C)&&E(C,function(A){return typeof A=="string"}).length===C.length}},releaseStage:{defaultValue:function(){return"production"},message:"should be a string",validate:function(C){return typeof C=="string"&&C.length}},maxBreadcrumbs:{defaultValue:function(){return 20},message:"should be a number ≤40",validate:function(C){return z(0,40)(C)}},autoBreadcrumbs:{defaultValue:function(){return!0},message:"should be true|false",validate:function(C){return typeof C=="boolean"}},user:{defaultValue:function(){return null},message:"(object) user should be an object",validate:function(C){return typeof C=="object"}},metaData:{defaultValue:function(){return null},message:"should be an object",validate:function(C){return typeof C=="object"}},logger:{defaultValue:function(){},message:"should be null or an object with methods { debug, info, warn, error }",validate:function(C){return!C||C&&M(["debug","info","warn","error"],function(A,D){return A&&typeof C[D]=="function"},!0)}},filters:{defaultValue:function(){return["password"]},message:"should be an array of strings|regexes",validate:function(C){return x(C)&&C.length===E(C,function(A){return typeof A=="string"||A&&typeof A.test=="function"}).length}}},h.mergeDefaults=function(C,A){if(!C||!A)throw new Error("opts and schema objects are required");return M(I(A),function(D,W){return D[W]=C[W]!==void 0?C[W]:A[W].defaultValue(C[W],C),D},{})},h.validate=function(C,A){if(!C||!A)throw new Error("opts and schema objects are required");var D=M(I(A),function(W,V){return A[V].validate(C[V],C)?W:W.concat({key:V,message:A[V].message,value:C[V]})},[]);return{valid:!D.length,errors:D}};function oe(){return oe=Object.assign||function(C){for(var A=1;A<arguments.length;A++){var D=arguments[A];for(var W in D)Object.prototype.hasOwnProperty.call(D,W)&&(C[W]=D[W])}return C},oe.apply(this,arguments)}var J=h.schema,L=d.map,Y=p.stringWithLength,Z={releaseStage:{defaultValue:function(){return/^localhost(:\d+)?$/.test(window.location.host)?"development":"production"},message:"should be set",validate:Y},logger:oe({},J.logger,{defaultValue:function(){return typeof console<"u"&&typeof console.debug=="function"?ye():void 0}})},ye=function(){var C={},A=console.log;return L(["debug","info","warn","error"],function(D){var W=console[D];C[D]=typeof W=="function"?W.bind(console,"[bugsnag]"):A.bind(console,"[bugsnag]")}),C},Re=d.isoDate,ae=function(){function C(D,W,V,he){D===void 0&&(D="[anonymous]"),W===void 0&&(W={}),V===void 0&&(V="manual"),he===void 0&&(he=Re()),this.type=V,this.name=D,this.metaData=W,this.timestamp=he}var A=C.prototype;return A.toJSON=function(){return{type:this.type,name:this.name,timestamp:this.timestamp,metaData:this.metaData}},C}(),Ve=ae,be=function(C,A,D){var W=C.length,V=0,he=function(){if(V>=W)return D(null,!1);A(C[V],function(Se,Ee){if(Se)return D(Se,!1);if(Ee===!0)return D(null,!0);V++,he()})};he()},Te=function(C){return C.app&&typeof C.app.releaseStage=="string"?C.app.releaseStage:C.config.releaseStage},we=ge;function ge(C){switch(Object.prototype.toString.call(C)){case"[object Error]":return!0;case"[object Exception]":return!0;case"[object DOMException]":return!0;default:return C instanceof Error}}var $e=we,De=function(C,A){return function(D,W){if(typeof D!="function")return W(null,!1);try{if(D.length!==2){var V=D(C);return V&&typeof V.then=="function"?V.then(function(he){return setTimeout(function(){return W(null,G(C,he))},0)},function(he){setTimeout(function(){return A(he),W(null,!1)})}):W(null,G(C,V))}D(C,function(he,Se){if(he)return A(he),W(null,!1);W(null,G(C,Se))})}catch(he){A(he),W(null,!1)}}},G=function(C,A){return C.isIgnored()||A===!1},Qe={};(function(C,A){typeof Qe=="object"?Qe=A():C.StackFrame=A()})(this,function(){function C(Ge){return!isNaN(parseFloat(Ge))&&isFinite(Ge)}function A(Ge){return Ge.charAt(0).toUpperCase()+Ge.substring(1)}function D(Ge){return function(){return this[Ge]}}var W=["isConstructor","isEval","isNative","isToplevel"],V=["columnNumber","lineNumber"],he=["fileName","functionName","source"],Se=["args"],Ee=W.concat(V,he,Se);function Fe(Ge){if(Ge instanceof Object)for(var xt=0;xt<Ee.length;xt++)Ge.hasOwnProperty(Ee[xt])&&Ge[Ee[xt]]!==void 0&&this["set"+A(Ee[xt])](Ge[Ee[xt]])}Fe.prototype={getArgs:function(){return this.args},setArgs:function(Ge){if(Object.prototype.toString.call(Ge)!=="[object Array]")throw new TypeError("Args must be an Array");this.args=Ge},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(Ge){if(Ge instanceof Fe)this.evalOrigin=Ge;else if(Ge instanceof Object)this.evalOrigin=new Fe(Ge);else throw new TypeError("Eval Origin must be an Object or StackFrame")},toString:function(){var Ge=this.getFunctionName()||"{anonymous}",xt="("+(this.getArgs()||[]).join(",")+")",sn=this.getFileName()?"@"+this.getFileName():"",wt=C(this.getLineNumber())?":"+this.getLineNumber():"",$t=C(this.getColumnNumber())?":"+this.getColumnNumber():"";return Ge+xt+sn+wt+$t}};for(var et=0;et<W.length;et++)Fe.prototype["get"+A(W[et])]=D(W[et]),Fe.prototype["set"+A(W[et])]=function(Ge){return function(xt){this[Ge]=!!xt}}(W[et]);for(var pt=0;pt<V.length;pt++)Fe.prototype["get"+A(V[pt])]=D(V[pt]),Fe.prototype["set"+A(V[pt])]=function(Ge){return function(xt){if(!C(xt))throw new TypeError(Ge+" must be a Number");this[Ge]=Number(xt)}}(V[pt]);for(var Dt=0;Dt<he.length;Dt++)Fe.prototype["get"+A(he[Dt])]=D(he[Dt]),Fe.prototype["set"+A(he[Dt])]=function(Ge){return function(xt){this[Ge]=String(xt)}}(he[Dt]);return Fe});var Et={};(function(C,A){typeof Et=="object"?Et=A(Qe):C.ErrorStackParser=A(C.StackFrame)})(this,function(A){var D=/(^|@)\S+\:\d+/,W=/^\s*at .*(\S+\:\d+|\(native\))/m,V=/^(eval@)?(\[native code\])?$/;return{parse:function(Se){if(typeof Se.stacktrace<"u"||typeof Se["opera#sourceloc"]<"u")return this.parseOpera(Se);if(Se.stack&&Se.stack.match(W))return this.parseV8OrIE(Se);if(Se.stack)return this.parseFFOrSafari(Se);throw new Error("Cannot parse given Error object")},extractLocation:function(Se){if(Se.indexOf(":")===-1)return[Se];var Ee=/(.+?)(?:\:(\d+))?(?:\:(\d+))?$/,Fe=Ee.exec(Se.replace(/[\(\)]/g,""));return[Fe[1],Fe[2]||void 0,Fe[3]||void 0]},parseV8OrIE:function(Se){var Ee=Se.stack.split(`
|
|
465
|
+
`).filter(function(Fe){return!!Fe.match(W)},this);return Ee.map(function(Fe){Fe.indexOf("(eval ")>-1&&(Fe=Fe.replace(/eval code/g,"eval").replace(/(\(eval at [^\()]*)|(\)\,.*$)/g,""));var et=Fe.replace(/^\s+/,"").replace(/\(eval code/g,"("),pt=et.match(/ (\((.+):(\d+):(\d+)\)$)/);et=pt?et.replace(pt[0],""):et;var Dt=et.split(/\s+/).slice(1),Ge=this.extractLocation(pt?pt[1]:Dt.pop()),xt=Dt.join(" ")||void 0,sn=["eval","<anonymous>"].indexOf(Ge[0])>-1?void 0:Ge[0];return new A({functionName:xt,fileName:sn,lineNumber:Ge[1],columnNumber:Ge[2],source:Fe})},this)},parseFFOrSafari:function(Se){var Ee=Se.stack.split(`
|
|
466
|
+
`).filter(function(Fe){return!Fe.match(V)},this);return Ee.map(function(Fe){if(Fe.indexOf(" > eval")>-1&&(Fe=Fe.replace(/ line (\d+)(?: > eval line \d+)* > eval\:\d+\:\d+/g,":$1")),Fe.indexOf("@")===-1&&Fe.indexOf(":")===-1)return new A({functionName:Fe});var et=/((.*".+"[^@]*)?[^@]*)(?:@)/,pt=Fe.match(et),Dt=pt&&pt[1]?pt[1]:void 0,Ge=this.extractLocation(Fe.replace(et,""));return new A({functionName:Dt,fileName:Ge[0],lineNumber:Ge[1],columnNumber:Ge[2],source:Fe})},this)},parseOpera:function(Se){return!Se.stacktrace||Se.message.indexOf(`
|
|
467
|
+
`)>-1&&Se.message.split(`
|
|
468
|
+
`).length>Se.stacktrace.split(`
|
|
469
|
+
`).length?this.parseOpera9(Se):Se.stack?this.parseOpera11(Se):this.parseOpera10(Se)},parseOpera9:function(Se){for(var Ee=/Line (\d+).*script (?:in )?(\S+)/i,Fe=Se.message.split(`
|
|
470
|
+
`),et=[],pt=2,Dt=Fe.length;pt<Dt;pt+=2){var Ge=Ee.exec(Fe[pt]);Ge&&et.push(new A({fileName:Ge[2],lineNumber:Ge[1],source:Fe[pt]}))}return et},parseOpera10:function(Se){for(var Ee=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,Fe=Se.stacktrace.split(`
|
|
471
|
+
`),et=[],pt=0,Dt=Fe.length;pt<Dt;pt+=2){var Ge=Ee.exec(Fe[pt]);Ge&&et.push(new A({functionName:Ge[3]||void 0,fileName:Ge[2],lineNumber:Ge[1],source:Fe[pt]}))}return et},parseOpera11:function(Se){var Ee=Se.stack.split(`
|
|
472
|
+
`).filter(function(Fe){return!!Fe.match(D)&&!Fe.match(/^Error created at/)},this);return Ee.map(function(Fe){var et=Fe.split("@"),pt=this.extractLocation(et.pop()),Dt=et.shift()||"",Ge=Dt.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^\)]*\)/g,"")||void 0,xt;Dt.match(/\(([^\)]*)\)/)&&(xt=Dt.replace(/^[^\(]+\(([^\)]*)\)$/,"$1"));var sn=xt===void 0||xt==="[arguments not available]"?void 0:xt.split(",");return new A({functionName:Ge,args:sn,fileName:pt[0],lineNumber:pt[1],columnNumber:pt[2],source:Fe})},this)}}});var ut=Et,je=function(C){return!!C&&(!!C.stack||!!C.stacktrace||!!C["opera#sourceloc"])&&typeof(C.stack||C.stacktrace||C["opera#sourceloc"])=="string"&&C.stack!==C.name+": "+C.message},te="browserjs",ur={};(function(C,A){typeof ur=="object"?ur=A(Qe):C.StackGenerator=A(C.StackFrame)})(this,function(C){return{backtrace:function(D){var W=[],V=10;typeof D=="object"&&typeof D.maxStackSize=="number"&&(V=D.maxStackSize);for(var he=arguments.callee;he&&W.length<V&&he.arguments;){for(var Se=new Array(he.arguments.length),Ee=0;Ee<Se.length;++Ee)Se[Ee]=he.arguments[Ee];/function(?:\s+([\w$]+))+\s*\(/.test(he.toString())?W.push(new C({functionName:RegExp.$1||void 0,args:Se})):W.push(new C({args:Se}));try{he=he.caller}catch{break}}return W}}});function Me(){return Me=Object.assign||function(C){for(var A=1;A<arguments.length;A++){var D=arguments[A];for(var W in D)Object.prototype.hasOwnProperty.call(D,W)&&(C[W]=D[W])}return C},Me.apply(this,arguments)}var fe=d.reduce,Pt=d.filter,We=function(){function C(D,W,V,he,Se){V===void 0&&(V=[]),he===void 0&&(he=xe()),this.__isBugsnagReport=!0,this._ignored=!1,this._handledState=he,this.app=void 0,this.apiKey=void 0,this.breadcrumbs=[],this.context=void 0,this.device=void 0,this.errorClass=ft(D,"[no error class]"),this.errorMessage=ft(W,"[no error message]"),this.groupingHash=void 0,this.metaData={},this.request=void 0,this.severity=this._handledState.severity,this.stacktrace=fe(V,function(Ee,Fe){var et=Kt(Fe);try{return JSON.stringify(et)==="{}"?Ee:Ee.concat(et)}catch{return Ee}},[]),this.user=void 0,this.session=void 0,this.originalError=Se}var A=C.prototype;return A.ignore=function(){this._ignored=!0},A.isIgnored=function(){return this._ignored},A.updateMetaData=function(W){var V;if(!W)return this;var he;return(arguments.length<=1?void 0:arguments[1])===null?this.removeMetaData(W):(arguments.length<=2?void 0:arguments[2])===null?this.removeMetaData(W,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2]):(typeof(arguments.length<=1?void 0:arguments[1])=="object"&&(he=arguments.length<=1?void 0:arguments[1]),typeof(arguments.length<=1?void 0:arguments[1])=="string"&&(he=(V={},V[arguments.length<=1?void 0:arguments[1]]=arguments.length<=2?void 0:arguments[2],V)),he?(this.metaData[W]||(this.metaData[W]={}),this.metaData[W]=Me({},this.metaData[W],he),this):this)},A.removeMetaData=function(W,V){return typeof W!="string"?this:V?this.metaData[W]?(delete this.metaData[W][V],this):this:(delete this.metaData[W],this)},A.toJSON=function(){return{payloadVersion:"4",exceptions:[{errorClass:this.errorClass,message:this.errorMessage,stacktrace:this.stacktrace,type:te}],severity:this.severity,unhandled:this._handledState.unhandled,severityReason:this._handledState.severityReason,app:this.app,device:this.device,breadcrumbs:this.breadcrumbs,context:this.context,user:this.user,metaData:this.metaData,groupingHash:this.groupingHash,request:this.request,session:this.session}},C}(),Kt=function(C){var A={file:C.fileName,method:gt(C.functionName),lineNumber:C.lineNumber,columnNumber:C.columnNumber,code:void 0,inProject:void 0};return A.lineNumber>-1&&!A.file&&!A.method&&(A.file="global code"),A},gt=function(C){return/^global code$/i.test(C)?"global code":C},xe=function(){return{unhandled:!1,severity:"warning",severityReason:{type:"handledException"}}},ft=function(C,A){return typeof C=="string"&&C?C:A};We.getStacktrace=function(C,A,D){if(A===void 0&&(A=0),D===void 0&&(D=0),je(C))return ut.parse(C).slice(A);try{throw C}catch(W){if(je(W))return ut.parse(C).slice(1+D);try{return Pt(ur.backtrace(),function(V){return(V.functionName||"").indexOf("StackGenerator$$")===-1}).slice(1+D)}catch{return[]}}},We.ensureReport=function(C,A,D){if(A===void 0&&(A=0),D===void 0&&(D=0),C.__isBugsnagReport)return C;try{var W=We.getStacktrace(C,A,1+D);return new We(C.name,C.message,W,void 0,C)}catch{return new We(C.name,C.message,[],void 0,C)}};var Tt=We,Le=function(A,D){var W="000000000"+A;return W.substr(W.length-D)},Jt=typeof window=="object"?window:self,vt=0;for(var zt in Jt)Object.hasOwnProperty.call(Jt,zt)&&vt++;var nr=navigator.mimeTypes?navigator.mimeTypes.length:0,He=Le((nr+navigator.userAgent.length).toString(36)+vt.toString(36),4),Pr=function(){return He},Cr=0,Ct=4,kt=36,yt=Math.pow(kt,Ct);function st(){return Le((Math.random()*yt<<0).toString(kt),Ct)}function Lt(){return Cr=Cr<yt?Cr:0,Cr++,Cr-1}function Xt(){var C="c",A=new Date().getTime().toString(kt),D=Le(Lt().toString(kt),Ct),W=Pr(),V=st()+st();return C+A+D+W+V}Xt.fingerprint=Pr;var hr=Xt,hn=d.isoDate,Pn=function(){function C(){this.id=hr(),this.startedAt=hn(),this._handled=0,this._unhandled=0}var A=C.prototype;return A.toJSON=function(){return{id:this.id,startedAt:this.startedAt,events:{handled:this._handled,unhandled:this._unhandled}}},A.trackError=function(W){this[W._handledState.unhandled?"_unhandled":"_handled"]+=1},C}(),_r=Pn;function Wt(){return Wt=Object.assign||function(C){for(var A=1;A<arguments.length;A++){var D=arguments[A];for(var W in D)Object.prototype.hasOwnProperty.call(D,W)&&(C[W]=D[W])}return C},Wt.apply(this,arguments)}var Nr=d.map,_e=d.includes,Ce=d.isArray,ce="Usage error.",de="Bugsnag usage error.",le=function(){function C(D){if(!D||!D.name||!D.version||!D.url)throw new Error("`notifier` argument is required");this.notifier=D,this._configured=!1,this._opts={},this.config={},this._delivery={sendSession:function(){},sendReport:function(){}},this._logger={debug:function(){},info:function(){},warn:function(){},error:function(){}},this._plugins={},this._session=null,this.breadcrumbs=[],this.app={},this.context=void 0,this.device=void 0,this.metaData=void 0,this.request=void 0,this.user={},this.BugsnagClient=C,this.BugsnagReport=Tt,this.BugsnagBreadcrumb=Ve,this.BugsnagSession=_r;var W=this,V=this.notify;this.notify=function(){return V.apply(W,arguments)}}var A=C.prototype;return A.setOptions=function(W){this._opts=Wt({},this._opts,W)},A.configure=function(W){W===void 0&&(W=h.schema);var V=h.mergeDefaults(this._opts,W),he=h.validate(V,W);if(!he.valid)throw new Error(ee(he.errors));return typeof V.beforeSend=="function"&&(V.beforeSend=[V.beforeSend]),V.appVersion&&(this.app.version=V.appVersion),V.appType&&(this.app.type=V.appType),V.metaData&&(this.metaData=V.metaData),V.user&&(this.user=V.user),V.logger&&this.logger(V.logger),this.config=Wt({},this.config,V),this._configured=!0,this},A.use=function(W){if(!this._configured)throw new Error("client not configured");W.configSchema&&this.configure(W.configSchema);for(var V=arguments.length,he=new Array(V>1?V-1:0),Se=1;Se<V;Se++)he[Se-1]=arguments[Se];var Ee=W.init.apply(W,[this].concat(he));return W.name&&(this._plugins["~"+W.name+"~"]=Ee),this},A.getPlugin=function(W){return this._plugins["~"+W+"~"]},A.delivery=function(W){return this._delivery=W(this),this},A.logger=function(W,V){return this._logger=W,this},A.sessionDelegate=function(W){return this._sessionDelegate=W,this},A.startSession=function(){return this._sessionDelegate?this._sessionDelegate.startSession(this):(this._logger.warn("No session implementation is installed"),this)},A.leaveBreadcrumb=function(W,V,he,Se){if(!this._configured)throw new Error("client not configured");if(W=W||void 0,he=typeof he=="string"?he:void 0,Se=typeof Se=="string"?Se:void 0,V=typeof V=="object"&&V!==null?V:void 0,!(typeof W!="string"&&!V)){var Ee=new Ve(W,V,he,Se);return this.breadcrumbs.push(Ee),this.breadcrumbs.length>this.config.maxBreadcrumbs&&(this.breadcrumbs=this.breadcrumbs.slice(this.breadcrumbs.length-this.config.maxBreadcrumbs)),this}},A.notify=function(W,V,he){var Se=this;if(V===void 0&&(V={}),he===void 0&&(he=function(){}),!this._configured)throw new Error("client not configured");var Ee=Te(this),Fe=ke(W,V,this._logger),et=Fe.err,pt=Fe.errorFramesToSkip,Dt=Fe._opts;Dt&&(V=Dt),(typeof V!="object"||V===null)&&(V={});var Ge=Tt.ensureReport(et,pt,2);if(Ge.app=Wt({},{releaseStage:Ee},Ge.app,this.app),Ge.context=Ge.context||V.context||this.context||void 0,Ge.device=Wt({},Ge.device,this.device,V.device),Ge.request=Wt({},Ge.request,this.request,V.request),Ge.user=Wt({},Ge.user,this.user,V.user),Ge.metaData=Wt({},Ge.metaData,this.metaData,V.metaData),Ge.breadcrumbs=this.breadcrumbs.slice(0),this._session&&(this._session.trackError(Ge),Ge.session=this._session),V.severity!==void 0&&(Ge.severity=V.severity,Ge._handledState.severityReason={type:"userSpecifiedSeverity"}),Ce(this.config.notifyReleaseStages)&&!_e(this.config.notifyReleaseStages,Ee))return this._logger.warn("Report not sent due to releaseStage/notifyReleaseStages configuration"),he(null,Ge);var xt=Ge.severity,sn=[].concat(V.beforeSend).concat(this.config.beforeSend),wt=function($t){Se._logger.error("Error occurred in beforeSend callback, continuing anyway…"),Se._logger.error($t)};be(sn,De(Ge,wt),function($t,Rr){if($t&&wt($t),Rr)return Se._logger.debug("Report not sent due to beforeSend callback"),he(null,Ge);Se.config.autoBreadcrumbs&&Se.leaveBreadcrumb(Ge.errorClass,{errorClass:Ge.errorClass,errorMessage:Ge.errorMessage,severity:Ge.severity},"error"),xt!==Ge.severity&&(Ge._handledState.severityReason={type:"userCallbackSetSeverity"}),Se._delivery.sendReport({apiKey:Ge.apiKey||Se.config.apiKey,notifier:Se.notifier,events:[Ge]},function(mr){return he(mr,Ge)})})},C}(),ke=function(C,A,D){var W=3,V=function(Fe){var et=ve(Fe);return D.warn(ce+" "+et),new Error(de+" "+et)},he,Se=0,Ee;switch(typeof C){case"string":typeof A=="string"?(he=V("string/string"),Ee={metaData:{notifier:{notifyArgs:[C,A]}}}):(he=new Error(String(C)),Se=W);break;case"number":case"boolean":he=new Error(String(C));break;case"function":he=V("function");break;case"object":C!==null&&($e(C)||C.__isBugsnagReport)?he=C:C!==null&&Ie(C)?(he=new Error(C.message||C.errorMessage),he.name=C.name||C.errorClass,Se=W):he=V(C===null?"null":"unsupported object");break;default:he=V("nothing")}return{err:he,errorFramesToSkip:Se,_opts:Ee}},Ie=function(C){return(typeof C.name=="string"||typeof C.errorClass=="string")&&(typeof C.message=="string"||typeof C.errorMessage=="string")},ee=function(C){return`Bugsnag configuration error
|
|
473
|
+
`+Nr(C,function(A){return'"'+A.key+'" '+A.message+`
|
|
474
|
+
got `+Q(A.value)}).join(`
|
|
475
|
+
|
|
476
|
+
`)},ve=function(C){return"notify() expected error/opts parameters, got "+C},Q=function(C){return typeof C=="object"?JSON.stringify(C):String(C)},se=le,X=function(C,A,D,W){var V=W&&W.filterKeys?W.filterKeys:[],he=W&&W.filterPaths?W.filterPaths:[];return JSON.stringify(Sr(C,V,he),A,D)},Ue=20,Oe=25e3,Ze=8,Ke="...";function Je(C){return C instanceof Error||/^\[object (Error|(Dom)?Exception)\]$/.test(Object.prototype.toString.call(C))}function rt(C){return"[Throws: "+(C?C.message:"?")+"]"}function nt(C,A){for(var D=0,W=C.length;D<W;D++)if(C[D]===A)return!0;return!1}function Ye(C,A){for(var D=0,W=C.length;D<W;D++)if(A.indexOf(C[D])===0)return!0;return!1}function tt(C,A){for(var D=0,W=C.length;D<W;D++)if(typeof C[D]=="string"&&C[D]===A||C[D]&&typeof C[D].test=="function"&&C[D].test(A))return!0;return!1}function it(C){return Object.prototype.toString.call(C)==="[object Array]"}function ct(C,A){try{return C[A]}catch(D){return rt(D)}}function Sr(C,A,D){var W=[],V=0;function he(Se,Ee){function Fe(){return Ee.length>Ze&&V>Oe}if(V++,Ee.length>Ue||Fe())return Ke;if(Se===null||typeof Se!="object")return Se;if(nt(W,Se))return"[Circular]";if(W.push(Se),typeof Se.toJSON=="function")try{V--;var et=he(Se.toJSON(),Ee);return W.pop(),et}catch(Rr){return rt(Rr)}var pt=Je(Se);if(pt){V--;var Dt=he({name:Se.name,message:Se.message},Ee);return W.pop(),Dt}if(it(Se)){for(var Ge=[],xt=0,sn=Se.length;xt<sn;xt++){if(Fe()){Ge.push(Ke);break}Ge.push(he(Se[xt],Ee.concat("[]")))}return W.pop(),Ge}var wt={};try{for(var $t in Se)if(Object.prototype.hasOwnProperty.call(Se,$t)){if(Ye(D,Ee.join("."))&&tt(A,$t)){wt[$t]="[Filtered]";continue}if(Fe()){wt[$t]=Ke;break}wt[$t]=he(ct(Se,$t),Ee.concat($t))}}catch{}return W.pop(),wt}return he(C,[])}var cr={},ot=["events.[].app","events.[].metaData","events.[].user","events.[].breadcrumbs","events.[].request","events.[].device"],Hr=["device","app","user"];cr.report=function(C,A){var D=X(C,null,null,{filterPaths:ot,filterKeys:A});if(D.length>1e6&&(delete C.events[0].metaData,C.events[0].metaData={notifier:`WARNING!
|
|
477
|
+
Serialized payload was `+D.length/1e6+`MB (limit = 1MB)
|
|
478
|
+
metaData was removed`},D=X(C,null,null,{filterPaths:ot,filterKeys:A}),D.length>1e6))throw new Error("payload exceeded 1MB limit");return D},cr.session=function(C,A){var D=X(C,null,null,{filterPaths:Hr,filterKeys:A});if(D.length>1e6)throw new Error("payload exceeded 1MB limit");return D};var ir={},Wn=d.isoDate;ir=function(C,A){return A===void 0&&(A=window),{sendReport:function(D,W){W===void 0&&(W=function(){});var V=hi(C.config,"notify","4",A),he=new A.XDomainRequest;he.onload=function(){W(null)},he.open("POST",V),setTimeout(function(){try{he.send(cr.report(D,C.config.filters))}catch(Se){C._logger.error(Se),W(Se)}},0)},sendSession:function(D,W){W===void 0&&(W=function(){});var V=hi(C.config,"sessions","1",A),he=new A.XDomainRequest;he.onload=function(){W(null)},he.open("POST",V),setTimeout(function(){try{he.send(cr.session(D,C.config.filters))}catch(Se){C._logger.error(Se),W(Se)}},0)}}};var hi=function(C,A,D,W){return $a(C.endpoints[A],W.location.protocol)+"?apiKey="+encodeURIComponent(C.apiKey)+"&payloadVersion="+D+"&sentAt="+encodeURIComponent(Wn())},$a=ir._matchPageProtocol=function(C,A){return A==="http:"?C.replace(/^https:/,"http:"):C},Kr=d.isoDate,Yi=function(C,A){return A===void 0&&(A=window),{sendReport:function(D,W){W===void 0&&(W=function(){});try{var V=C.config.endpoints.notify,he=new A.XMLHttpRequest;he.onreadystatechange=function(){he.readyState===A.XMLHttpRequest.DONE&&W(null)},he.open("POST",V),he.setRequestHeader("Content-Type","application/json"),he.setRequestHeader("Bugsnag-Api-Key",D.apiKey||C.config.apiKey),he.setRequestHeader("Bugsnag-Payload-Version","4"),he.setRequestHeader("Bugsnag-Sent-At",Kr()),he.send(cr.report(D,C.config.filters))}catch(Se){C._logger.error(Se)}},sendSession:function(D,W){W===void 0&&(W=function(){});try{var V=C.config.endpoints.sessions,he=new A.XMLHttpRequest;he.onreadystatechange=function(){he.readyState===A.XMLHttpRequest.DONE&&W(null)},he.open("POST",V),he.setRequestHeader("Content-Type","application/json"),he.setRequestHeader("Bugsnag-Api-Key",C.config.apiKey),he.setRequestHeader("Bugsnag-Payload-Version","1"),he.setRequestHeader("Bugsnag-Sent-At",Kr()),he.send(cr.session(D,C.config.filters))}catch(Se){C._logger.error(Se)}}}},Oa={init:function(C,A){A===void 0&&(A=window),C.config.beforeSend.unshift(function(D){D.context||(D.context=A.location.pathname)})}};function Vn(){return Vn=Object.assign||function(C){for(var A=1;A<arguments.length;A++){var D=arguments[A];for(var W in D)Object.prototype.hasOwnProperty.call(D,W)&&(C[W]=D[W])}return C},Vn.apply(this,arguments)}var Er=d.isoDate,Ia={init:function(C,A){A===void 0&&(A=navigator);var D={locale:A.browserLanguage||A.systemLanguage||A.userLanguage||A.language,userAgent:A.userAgent};C.device=Vn({},D,C.device),C.config.beforeSend.unshift(function(W){W.device=Vn({},W.device,{time:Er()})})}};function rn(){return rn=Object.assign||function(C){for(var A=1;A<arguments.length;A++){var D=arguments[A];for(var W in D)Object.prototype.hasOwnProperty.call(D,W)&&(C[W]=D[W])}return C},rn.apply(this,arguments)}var ar={init:function(C,A){A===void 0&&(A=window),C.config.beforeSend.unshift(function(D){D.request&&D.request.url||(D.request=rn({},D.request,{url:A.location.href}))})}};function vi(){return vi=Object.assign||function(C){for(var A=1;A<arguments.length;A++){var D=arguments[A];for(var W in D)Object.prototype.hasOwnProperty.call(D,W)&&(C[W]=D[W])}return C},vi.apply(this,arguments)}var Jr=d.isArray,Xi=d.includes,Pa={init:function(C){return C.sessionDelegate(Aa)}},Aa={startSession:function(C){var A=C;A._session=new C.BugsnagSession;var D=Te(A);return Jr(A.config.notifyReleaseStages)&&!Xi(A.config.notifyReleaseStages,D)?(A._logger.warn("Session not sent due to releaseStage/notifyReleaseStages configuration"),A):A.config.endpoints.sessions?(A._delivery.sendSession({notifier:A.notifier,device:A.device,app:vi({},{releaseStage:D},A.app),sessions:[{id:A._session.id,startedAt:A._session.startedAt,user:A.user}]}),A):(A._logger.warn("Session not sent due to missing endpoints.sessions configuration"),A)}};function Ar(){return Ar=Object.assign||function(C){for(var A=1;A<arguments.length;A++){var D=arguments[A];for(var W in D)Object.prototype.hasOwnProperty.call(D,W)&&(C[W]=D[W])}return C},Ar.apply(this,arguments)}var At={init:function(C){C.config.collectUserIp||C.config.beforeSend.push(function(A){A.user&&typeof A.user.id>"u"&&delete A.user.id,A.user=Ar({id:"[NOT COLLECTED]"},A.user),A.request=Ar({clientIp:"[NOT COLLECTED]"},A.request)})},configSchema:{collectUserIp:{defaultValue:function(){return!0},message:"should be true|false",validate:function(C){return C===!0||C===!1}}}},mi={},Hn=d.map,Ma=d.reduce,Yr=d.filter;mi.init=function(C){var A=/^dev(elopment)?$/.test(C.config.releaseStage),D=C.config.consoleBreadcrumbsEnabled===!1,W=(C.config.autoBreadcrumbs===!1||A)&&C.config.consoleBreadcrumbsEnabled!==!0;D||W||Hn(gi,function(V){var he=console[V];console[V]=function(){for(var Se=arguments.length,Ee=new Array(Se),Fe=0;Fe<Se;Fe++)Ee[Fe]=arguments[Fe];C.leaveBreadcrumb("Console output",Ma(Ee,function(et,pt,Dt){var Ge="[Unknown value]";try{Ge=String(pt)}catch{}if(Ge==="[object Object]")try{Ge=JSON.stringify(pt)}catch{}return et["["+Dt+"]"]=Ge,et},{severity:V.indexOf("group")===0?"log":V}),"log"),he.apply(console,Ee)},console[V]._restore=function(){console[V]=he}})},mi.configSchema={consoleBreadcrumbsEnabled:{defaultValue:function(){},validate:function(C){return C===!0||C===!1||C===void 0},message:"should be true|false"}};var gi=Yr(["log","debug","info","warn","error"],function(C){return typeof console<"u"&&typeof console[C]=="function"}),yi=d.map,xa=d.reduce,Na=d.filter,vr=200,Qi=5e5,Zi={init:function(C,A,D){if(A===void 0&&(A=document),D===void 0&&(D=window),!C.config.trackInlineScripts)return;var W=D.location.href,V="",he=!1,Se=function(){return A.documentElement.outerHTML};V=Se();var Ee=A.onreadystatechange;A.onreadystatechange=function(){A.readyState==="interactive"&&(V=Se(),he=!0);try{Ee.apply(this,arguments)}catch{}};var Fe=null,et=function(wt){Fe=wt},pt=function(){var wt=A.currentScript||Fe;if(!wt&&!he){var $t=A.scripts||A.getElementsByTagName("script");wt=$t[$t.length-1]}return wt},Dt=function(wt){(!he||!V)&&(V=Se());var $t=["<!-- DOC START -->"].concat(V.split(`
|
|
479
|
+
`)),Rr=wt-1,mr=Math.max(Rr-3,0),La=Math.min(Rr+3,$t.length);return xa($t.slice(mr,La),function(Mn,So,Tf){return Mn[mr+1+Tf]=So.length<=vr?So:So.substr(0,vr),Mn},{})};C.config.beforeSend.unshift(function(wt){wt.stacktrace=Na(wt.stacktrace,function(La){return!/__trace__$/.test(La.method)});var $t=wt.stacktrace[0];if(!($t&&$t.file&&$t.file.replace(/#.*$/,"")!==W.replace(/#.*$/,""))){var Rr=pt();if(Rr){var mr=Rr.innerHTML;wt.updateMetaData("script","content",mr.length<=Qi?mr:mr.substr(0,Qi))}!$t||!$t.lineNumber||($t.code=Dt($t.lineNumber))}});var Ge=yi(["setTimeout","setInterval","setImmediate","requestAnimationFrame"],function(wt){return bi(D,wt,function($t){return sn($t,function(Rr){return{get:function(){return Rr[0]},replace:function(mr){Rr[0]=mr}}})})}),xt=Ge[0];yi(["EventTarget","Window","Node","ApplicationCache","AudioTrackList","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"],function(wt){!D[wt]||!D[wt].prototype||!D[wt].prototype.hasOwnProperty||!D[wt].prototype.hasOwnProperty("addEventListener")||(bi(D[wt].prototype,"addEventListener",function($t){return sn($t,ea)}),bi(D[wt].prototype,"removeEventListener",function($t){return sn($t,ea,!0)}))});function sn(wt,$t,Rr){return Rr===void 0&&(Rr=!1),function(){var mr=Array.prototype.slice.call(arguments);try{var La=$t(mr),Mn=La.get();if(Rr&&wt.apply(this,mr),typeof Mn!="function")return wt.apply(this,mr);if(Mn.__trace__)La.replace(Mn.__trace__);else{var So=pt();Mn.__trace__=function(){et(So),xt(function(){et(null)},0);var c1=Mn.apply(this,arguments);return et(null),c1},Mn.__trace__.__trace__=Mn.__trace__,La.replace(Mn.__trace__)}}catch{}if(wt.apply)return wt.apply(this,mr);switch(mr.length){case 1:return wt(mr[0]);case 2:return wt(mr[0],mr[1]);default:return wt()}}}},configSchema:{trackInlineScripts:{validate:function(C){return C===!0||C===!1},defaultValue:function(){return!0},message:"should be true|false"}}};function bi(C,A,D){var W=C[A];if(!W)return W;var V=D(W);return C[A]=V,W}function ea(C){var A=!!C[1]&&typeof C[1].handleEvent=="function";return{get:function(){return A?C[1].handleEvent:C[1]},replace:function(D){A?C[1].handleEvent=D:C[1]=D}}}var vn={init:function(C,A){if(A===void 0&&(A=window),"addEventListener"in A){var D=C.config.interactionBreadcrumbsEnabled===!1,W=C.config.autoBreadcrumbs===!1&&C.config.interactionBreadcrumbsEnabled!==!0;D||W||A.addEventListener("click",function(V){var he,Se;try{he=An(V.target),Se=Zt(V.target,A)}catch{he="[hidden]",Se="[hidden]",C._logger.error("Cross domain error when tracking click event. See docs: https://tinyurl.com/yy3rn63z")}C.leaveBreadcrumb("UI click",{targetText:he,targetSelector:Se},"user")},!0)}},configSchema:{interactionBreadcrumbsEnabled:{defaultValue:function(){},validate:function(C){return C===!0||C===!1||C===void 0},message:"should be true|false"}}},An=function(C){var A=C.textContent||C.innerText||"";return!A&&(C.type==="submit"||C.type==="button")&&(A=C.value),A=A.replace(/^\s+|\s+$/g,""),Kn(A,140)};function Zt(C,A){var D=[C.tagName];if(C.id&&D.push("#"+C.id),C.className&&C.className.length&&D.push("."+C.className.split(" ").join(".")),!A.document.querySelectorAll||!Array.prototype.indexOf)return D.join("");try{if(A.document.querySelectorAll(D.join("")).length===1)return D.join("")}catch{return D.join("")}if(C.parentNode.childNodes.length>1){var W=Array.prototype.indexOf.call(C.parentNode.childNodes,C)+1;D.push(":nth-child("+W+")")}return A.document.querySelectorAll(D.join("")).length===1?D.join(""):C.parentNode?Zt(C.parentNode,A)+" > "+D.join(""):D.join("")}function Kn(C,A){var D="(...)";return C&&C.length<=A?C:C.slice(0,A-D.length)+D}var Jn={};Jn.init=function(C,A){if(A===void 0&&(A=window),"addEventListener"in A){var D=C.config.navigationBreadcrumbsEnabled===!1,W=C.config.autoBreadcrumbs===!1&&C.config.navigationBreadcrumbsEnabled!==!0;if(!(D||W)){var V=function(he){return function(){return C.leaveBreadcrumb(he,{},"navigation")}};A.addEventListener("pagehide",V("Page hidden"),!0),A.addEventListener("pageshow",V("Page shown"),!0),A.addEventListener("load",V("Page loaded"),!0),A.document.addEventListener("DOMContentLoaded",V("DOMContentLoaded"),!0),A.addEventListener("load",function(){return A.addEventListener("popstate",V("Navigated back"),!0)}),A.addEventListener("hashchange",function(he){var Se=he.oldURL?{from:kr(he.oldURL,A),to:kr(he.newURL,A),state:F(A)}:{to:kr(A.location.href,A)};C.leaveBreadcrumb("Hash changed",Se,"navigation")},!0),A.history.replaceState&&ta(C,A.history,"replaceState",A),A.history.pushState&&ta(C,A.history,"pushState",A),C.leaveBreadcrumb("Bugsnag loaded",{},"navigation")}}},Jn.configSchema={navigationBreadcrumbsEnabled:{defaultValue:function(){},validate:function(C){return C===!0||C===!1||C===void 0},message:"should be true|false"}};var kr=function(C,A){var D=A.document.createElement("A");return D.href=C,""+D.pathname+D.search+D.hash},nn=function(C,A,D,W){var V=kr(C.location.href,C);return{title:D,state:A,prevState:F(C),to:W||V,from:V}},ta=function(C,A,D,W){var V=A[D];A[D]=function(he,Se,Ee){C.leaveBreadcrumb("History "+D,nn(W,he,Se,Ee),"navigation"),typeof C.refresh=="function"&&C.refresh(),C.config.autoCaptureSessions&&C.startSession(),V.apply(A,[he,Se].concat(Ee!==void 0?Ee:[]))}},F=function(C){try{return C.history.state}catch{}},q={},P="request",O="BS~~S",R="BS~~U",U="BS~~M",N=d.includes,me,pe,Ae,qe=function(){return[me.config.endpoints.notify,me.config.endpoints.sessions]};q.name="networkBreadcrumbs",q.init=function(C,A,D){A===void 0&&(A=qe),D===void 0&&(D=window);var W=C.config.networkBreadcrumbsEnabled===!1,V=C.config.autoBreadcrumbs===!1&&C.config.networkBreadcrumbsEnabled!==!0;W||V||(me=C,pe=D,Ae=A,at(),lr())},q.configSchema={networkBreadcrumbsEnabled:{defaultValue:function(){},validate:function(C){return C===!0||C===!1||C===void 0},message:"should be true|false"}};var at=function(){if("addEventListener"in pe.XMLHttpRequest.prototype){var C=pe.XMLHttpRequest.prototype.open;pe.XMLHttpRequest.prototype.open=function(D,W){this[R]=W,this[U]=D,this[O]&&(this.removeEventListener("load",dt),this.removeEventListener("error",Lr)),this.addEventListener("load",dt),this.addEventListener("error",Lr),this[O]=!0,C.apply(this,arguments)}}};function dt(){if(!N(Ae(),this[R])){var C={status:this.status,request:this[U]+" "+this[R]};this.status>=400?me.leaveBreadcrumb("XMLHttpRequest failed",C,P):me.leaveBreadcrumb("XMLHttpRequest succeeded",C,P)}}function Lr(){N(Ae,this[R])||me.leaveBreadcrumb("XMLHttpRequest error",{request:this[U]+" "+this[R]},P)}var lr=function(){if(!(!("fetch"in pe)||pe.fetch.polyfill)){var C=pe.fetch;pe.fetch=function(){var D=arguments,W=arguments[0],V=arguments[1],he,Se=null;return W&&typeof W=="object"?(Se=W.url,V&&"method"in V?he=V.method:W&&"method"in W&&(he=W.method)):(Se=W,V&&"method"in V&&(he=V.method)),he===void 0&&(he="GET"),new Promise(function(Ee,Fe){C.apply(void 0,D).then(function(et){an(et,he,Se),Ee(et)}).catch(function(et){_o(he,Se),Fe(et)})})}}},an=function(C,A,D){var W={status:C.status,request:A+" "+D};C.status>=400?me.leaveBreadcrumb("fetch() failed",W,P):me.leaveBreadcrumb("fetch() succeeded",W,P)},_o=function(C,A){me.leaveBreadcrumb("fetch() error",{request:C+" "+A},P)},Qt=p.intRange,B={init:function(C){var A=0;C.config.beforeSend.push(function(D){if(A>=C.config.maxEvents)return D.ignore();A++}),C.refresh=function(){A=0}},configSchema:{maxEvents:{defaultValue:function(){return 10},message:"should be a positive integer ≤100",validate:function(C){return Qt(1,100)(C)}}}},w={};function k(){return k=Object.assign||function(C){for(var A=1;A<arguments.length;A++){var D=arguments[A];for(var W in D)Object.prototype.hasOwnProperty.call(D,W)&&(C[W]=D[W])}return C},k.apply(this,arguments)}var S=d.map;w={init:function(C){C.config.beforeSend.push(function(A){A.stacktrace=S(A.stacktrace,function(D){return k({},D,{file:m(D.file)})})})}};var m=w._strip=function(C){return typeof C=="string"?C.replace(/\?.*$/,"").replace(/#.*$/,""):C},v={init:function(C,A){A===void 0&&(A=window);function D(V,he,Se,Ee,Fe){if(Se===0&&/Script error\.?/.test(V))C._logger.warn("Ignoring cross-domain or eval script error. See docs: https://tinyurl.com/yy3rn63z");else{var et={severity:"error",unhandled:!0,severityReason:{type:"unhandledException"}},pt;if(Fe)Fe.name&&Fe.message?pt=new C.BugsnagReport(Fe.name,Fe.message,_(C.BugsnagReport.getStacktrace(Fe),he,Se,Ee),et,Fe):(pt=new C.BugsnagReport("window.onerror",String(Fe),_(C.BugsnagReport.getStacktrace(Fe,1),he,Se,Ee),et,Fe),pt.updateMetaData("window onerror",{error:Fe}));else if(typeof V=="object"&&V!==null&&(!he||typeof he!="string")&&!Se&&!Ee&&!Fe){var Dt=V.type?"Event: "+V.type:"window.onerror",Ge=V.message||V.detail||"";pt=new C.BugsnagReport(Dt,Ge,C.BugsnagReport.getStacktrace(new Error,1).slice(1),et,V),pt.updateMetaData("window onerror",{event:V,extraParameters:he})}else pt=new C.BugsnagReport("window.onerror",String(V),_(C.BugsnagReport.getStacktrace(Fe,1),he,Se,Ee),et,V),pt.updateMetaData("window onerror",{event:V});C.notify(pt)}typeof W=="function"&&W.apply(this,arguments)}var W=A.onerror;A.onerror=D}},_=function(C,A,D,W){var V=C[0];return V&&(!V.fileName&&typeof A=="string"&&V.setFileName(A),!V.lineNumber&&g(D)&&V.setLineNumber(D),V.columnNumber||(g(W)?V.setColumnNumber(W):window.event&&g(window.event.errorCharacter)&&V.setColumnNumber(window.event.errorCharacter))),C},g=function(C){return typeof C=="number"&&String.call(C)!=="NaN"},y={},b=d.reduce;y.init=function(C,A){A===void 0&&(A=window);var D=function(W){var V=W.reason,he=!1;try{W.detail&&W.detail.reason&&(V=W.detail.reason,he=!0)}catch{}var Se={severity:"error",unhandled:!0,severityReason:{type:"unhandledPromiseRejection"}},Ee;if(V&&je(V))Ee=new C.BugsnagReport(V.name,V.message,ut.parse(V),Se,V),he&&(Ee.stacktrace=b(Ee.stacktrace,$(V),[]));else{var Fe='Rejection reason was not an Error. See "Promise" tab for more detail.';Ee=new C.BugsnagReport(V&&V.name?V.name:"UnhandledRejection",V&&V.message?V.message:Fe,[],Se,V),Ee.updateMetaData("promise","rejection reason",T(V))}C.notify(Ee)};"addEventListener"in A?A.addEventListener("unhandledrejection",D):A.onunhandledrejection=function(W,V){D({detail:{reason:W,promise:V}})}};var T=function(C){if(C==null)return"undefined (or null)";if($e(C)){var A;return A={},A[Object.prototype.toString.call(C)]={name:C.name,message:C.message,code:C.code,stack:C.stack},A}else return C},$=function(C){return function(A,D){return D.file===C.toString()?A:(D.method&&(D.method=D.method.replace(/^\s+/,"")),A.concat(D))}},H={};function K(){return K=Object.assign||function(C){for(var A=1;A<arguments.length;A++){var D=arguments[A];for(var W in D)Object.prototype.hasOwnProperty.call(D,W)&&(C[W]=D[W])}return C},K.apply(this,arguments)}var re="Bugsnag JavaScript",ue="6.5.2",Xe="https://github.com/bugsnag/bugsnag-js",lt=K({},h.schema,Z);return H=function(C){typeof C=="string"&&(C={apiKey:C});var A="";C.endpoints&&C.endpoints.notify&&!C.endpoints.sessions&&(A+="notify endpoint is set but sessions endpoint is not. No sessions will be sent.");var D=new se({name:re,version:ue,url:Xe});return D.setOptions(C),D.delivery(window.XDomainRequest?ir:Yi),D.configure(lt),A&&D._logger.warn(A),D.use(Ia),D.use(Oa),D.use(ar),D.use(B),D.use(Pa),D.use(At),D.use(w),D.config.autoNotify!==!1&&(D.use(v),D.use(y)),D.use(Jn),D.use(vn),D.use(q),D.use(mi),D.use(Zi),D._logger.debug("Loaded!"),D.config.autoCaptureSessions?D.startSession():D},H.Bugsnag={Client:se,Report:Tt,Session:_r,Breadcrumb:Ve},H.default=H,H})})(cR);var uJ=cR.exports,cJ=uJ,wh={exports:{}};const GS="[a-fA-F\\d:]",fa=e=>e&&e.includeBoundaries?`(?:(?<=\\s|^)(?=${GS})|(?<=${GS})(?=\\s|$))`:"",Dn="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",fr="[a-fA-F\\d]{1,4}",yf=`
|
|
480
|
+
(?:
|
|
481
|
+
(?:${fr}:){7}(?:${fr}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
|
|
482
|
+
(?:${fr}:){6}(?:${Dn}|:${fr}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
|
|
483
|
+
(?:${fr}:){5}(?::${Dn}|(?::${fr}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
|
|
484
|
+
(?:${fr}:){4}(?:(?::${fr}){0,1}:${Dn}|(?::${fr}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
|
|
485
|
+
(?:${fr}:){3}(?:(?::${fr}){0,2}:${Dn}|(?::${fr}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
|
|
486
|
+
(?:${fr}:){2}(?:(?::${fr}){0,3}:${Dn}|(?::${fr}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
|
|
487
|
+
(?:${fr}:){1}(?:(?::${fr}){0,4}:${Dn}|(?::${fr}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
|
|
488
|
+
(?::(?:(?::${fr}){0,5}:${Dn}|(?::${fr}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
|
|
489
|
+
)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
|
|
490
|
+
`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),lJ=new RegExp(`(?:^${Dn}$)|(?:^${yf}$)`),fJ=new RegExp(`^${Dn}$`),dJ=new RegExp(`^${yf}$`),xm=e=>e&&e.exact?lJ:new RegExp(`(?:${fa(e)}${Dn}${fa(e)})|(?:${fa(e)}${yf}${fa(e)})`,"g");xm.v4=e=>e&&e.exact?fJ:new RegExp(`${fa(e)}${Dn}${fa(e)}`,"g");xm.v6=e=>e&&e.exact?dJ:new RegExp(`${fa(e)}${yf}${fa(e)}`,"g");var pJ=xm;const Nm=pJ,Vs=e=>Nm({exact:!0}).test(e);Vs.v4=e=>Nm.v4({exact:!0}).test(e);Vs.v6=e=>Nm.v6({exact:!0}).test(e);Vs.version=e=>Vs(e)?Vs.v4(e)?4:6:void 0;var hJ=Vs;(function(e,r){var t=ze&&ze.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(hJ);class i extends Error{constructor(){super("Request was cancelled"),this.name="CancelError"}get isCanceled(){return!0}}const a={timeout:5e3},s={v4:["https://ipv4.icanhazip.com/","https://api.ipify.org/"],v6:["https://ipv6.icanhazip.com/","https://api6.ipify.org/"]},c=(l,f,d)=>{const p=new XMLHttpRequest;return new Promise((E,M)=>{p.addEventListener("error",M,{once:!0}),p.addEventListener("timeout",M,{once:!0}),p.addEventListener("load",()=>{const I=p.responseText.trim();if(!I||d==="v4"?!n.default.v4(I):!n.default.v6(I)){M();return}E(I)},{once:!0}),p.open("GET",l),p.timeout=f.timeout,p.send()})},o=(l,f)=>{let d;return async function(){const h=[].concat.apply(s[l],f.fallbackUrls||[]);for(const E of h)try{return d=c(E,f,l),await d}catch(M){if(M instanceof i)throw M}throw new Error("Couldn't find your IP")}()};class u{}r.default=u,u.v4=l=>o("v4",{...a,...l}),u.v6=l=>o("v6",{...a,...l}),e.exports=u})(wh,wh.exports);var vJ=wh.exports,Sc={exports:{}},wc={exports:{}},Th={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});const t=Ra;class n{constructor(a,s){this.application=a,Object.assign(this,s),t.mixin(n)}}r.default=n,e.exports=n})(Th,Th.exports);var lR=Th.exports,Tc={exports:{}},Cc={exports:{}},Ch={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});const t=Ra,n=In;class i{constructor(s,c){var o,u,l,f;if(this.conversation=s,c)for(const d in c)switch(d){case"type":c.type.startsWith("custom:")?this.type=c.type.replace("custom:",""):this.type=c.type;break;case"application_id":this.application_id=c.application_id;break;case"cid":this.cid=c.cid;break;case"from":["member:invited","member:joined","member:left"].indexOf(c.type)>-1?!((u=(o=c._embedded)===null||o===void 0?void 0:o.from_member)===null||u===void 0)&&u.id&&(this.from=(f=(l=c._embedded)===null||l===void 0?void 0:l.from_member)===null||f===void 0?void 0:f.id):this.from=c.from;break;case"timestamp":this.timestamp=c.timestamp;break;case"id":this.id=c.id;break;case"state":this.state=c.state;break;case"index":this.index=c.index;break;case"streamIndex":this.streamIndex=c.streamIndex;break;case"body":this.body=c.body,this.body.user&&this.body.user.user_id&&(this.body.user.id=this.body.user.user_id,delete this.body.user.user_id),this.body.digit&&(this.digit=this.body.digit,delete this.body.digit),this.body.digits&&(this.digit=this.body.digits,delete this.body.digits);break}t.mixin(i)}async del(s=this.id){try{await this.conversation.application.session.sendNetworkRequest({type:"DELETE",path:`conversations/${this.conversation.id}/events/${s}?from=${this.conversation.me.id}`,version:"beta2"});return}catch(c){throw new n.NexmoApiError(c)}}async delivered(s=this.id){if(this.type!=="text"&&this.type!=="image"&&this.type!=="message"&&(this.type="event"),this.conversation.me.id===this.from)throw new n.NexmoClientError("error:delivered:own-message");if(this.state&&this.state.delivered_to&&this.state.delivered_to[this.conversation.me.id])throw new n.NexmoClientError("error:already-delivered");try{await this.conversation.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.conversation.id}/events`,data:{type:`${this.type}:delivered`,from:this.conversation.me.id,body:{event_id:s}}});return}catch(c){throw new n.NexmoApiError(c)}}async seen(s=this.id){if(this.type!=="text"&&this.type!=="image"&&this.type!=="message"&&(this.type="event"),this.conversation.me.id===this.from)throw new n.NexmoClientError("error:seen:own-message");if(this.state&&this.state.seen_by&&this.state.seen_by[this.conversation.me.id])throw new n.NexmoClientError("error:already-seen");try{await this.conversation.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.conversation.id}/events`,data:{type:`${this.type}:seen`,from:this.conversation.me.id,body:{event_id:s}}});return}catch(c){throw new n.NexmoApiError(c)}}}r.default=i,e.exports=i})(Ch,Ch.exports);var Hi=Ch.exports,zS;function Lm(){return zS||(zS=1,function(e,r){var t=ze&&ze.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(r,"__esModule",{value:!0});const n=Ra,i=In,a=t(Hi),s=t(pi());class c{constructor(u,l){this.conversation=u,this.callStatus=null,this._normalise(l),n.mixin(c)}_normalise(u){if(u){this.user=this.user||{},this.channel=u.channel||{type:"app"};let l;for(l in u)switch(l){case"member_id":this.id=u.member_id;break;case"timestamp":this.timestamp=u.timestamp;break;case"state":this.state=u.state;break;case"from":this.id=u.from;break;case"user_id":this.user.id=u.user_id;break;case"name":this.user.name=u.name;break;case"user":this.user={name:u.user.name,id:u.user.user_id||u.user.id},this.display_name=this.display_name||u.user.display_name;break;case"invited_by":this.invited_by=u.invited_by;break;case"display_name":this.display_name=this.display_name||u.display_name;break;case"_embedded":u._embedded.user&&(this.user={id:u._embedded.user.id||this.user.id,name:u._embedded.user.name||this.user.name},this.display_name=this.display_name||u._embedded.user.display_name);case"conversation":break;default:u.type||(this[l]=u[l])}this.conversation.application.me&&u.user_id===this.conversation.application.me.id&&(this.user.name=this.conversation.application.me.name),delete this.user_id,delete this.name,delete this.user.user_id}}async playStream(u){try{const l=await this.conversation.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:{type:"audio:play",to:this.id,body:u}});return new a.default(this.conversation,l)}catch(l){throw new i.NexmoApiError(l)}}async sayText(u){try{const l=await this.conversation.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:{type:"audio:say",cid:this.id,from:this.conversation.me.id,to:this.id,body:{text:u.text,voice_name:u.voice_name||"Amy",level:u.level||1,queue:u.queue||!0,loop:u.loop||1,ssml:u.ssml||!1}}});return new a.default(this.conversation,l)}catch(l){throw new i.NexmoApiError(l)}}async kick(u){var l,f;let d=`conversations/${this.conversation.id}/members/${this.id}`,p=new URLSearchParams;!((f=(l=this===null||this===void 0?void 0:this.conversation)===null||l===void 0?void 0:l.me)===null||f===void 0)&&f.id&&p.append("from",this.conversation.me.id),u&&Object.keys(u).forEach(h=>{p.append(h,u[h])}),d+=`?${p.toString()}`;try{return await this.conversation.application.session.sendNetworkRequest({type:"DELETE",path:d})}catch(h){throw new i.NexmoApiError(h)}}mute(u,l=null){return this.conversation.media.mute(u,l)}earmuff(u){return this.conversation.media.earmuff(u)}_handleEvent(u){switch(u.type){case"member:invited":this._normalise(u.body),this.state="INVITED",this.timestamp.invited=u.body.timestamp.invited,!u.body.invited_by&&u.body.user.media&&u.body.user.media.audio_settings&&u.body.user.media.audio_settings.enabled&&this._setCallStatusAndEmit("started");break;case"member:joined":this._normalise(u.body),this.state="JOINED",this.timestamp.joined=u.body.timestamp.joined,u.body.channel&&u.body.channel.knocking_id&&this._setCallStatusAndEmit("started");break;case"member:left":this._normalise(u.body),this.state="LEFT",this.timestamp.left=u.body.timestamp.left,u.body.reason&&u.body.reason.text&&this._setCallStatusAndEmit(u.body.reason.text);break;case"member:media":this.media=u.body.media;break;case"leg:status:update":this.channel.legs=s.default.updateMemberLegs(this.channel.legs,u),this._setCallStatusAndEmit(u.body.status);break;case"audio:ringing:start":(!this.callStatus||this.callStatus==="started")&&this._setCallStatusAndEmit("ringing");break}}_setCallStatusAndEmit(u){this.callStatus!==String(u)&&(this.callStatus=u,this.conversation.emit("member:call:status",this))}}r.default=c,e.exports=c}(Cc,Cc.exports)),Cc.exports}var Eh={exports:{}};(function(e,r){var t=ze&&ze.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(Hi);class i extends n.default{constructor(s,c){super(s,c),this.type="text",this.conversation=s,this.state={seen_by:{},delivered_to:{}},c&&c.body&&c.body.timestamp&&(this.timestamp=c.body.timestamp),Object.assign(this,c)}seen(){return super.seen()}delivered(){return super.delivered()}del(){return super.del()}}r.default=i,e.exports=i})(Eh,Eh.exports);var Dm=Eh.exports,Ec={exports:{}},WS;function jm(){return WS||(WS=1,function(e,r){var t=ze&&ze.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(r,"__esModule",{value:!0});const n=pr,i=t(pi()),a=t(Hi),s=In;class c extends a.default{constructor(u,l){super(u,l),this.log=n.getLogger(this.constructor.name),this.type="message",this.conversation=u,this.state={seen_by:{},delivered_to:{},submitted_to:{},rejected_by:{},undeliverable_to:{}},l&&l.body&&l.body.timestamp&&(this.timestamp=l.body.timestamp),Object.assign(this,l)}seen(){return super.seen()}delivered(){return super.delivered()}del(){return super.del()}async fetchImage(){if(this.body.message_type!=="image")throw new s.NexmoClientError("error:message-event:invalid");try{return i.default._fetchImage(this.body.image.url,this.conversation.application.session.config.token)}catch(u){throw this.log.error(u),u}}}r.default=c,e.exports=c}(Ec,Ec.exports)),Ec.exports}var kc={exports:{}},Rc={exports:{}};let fR=!0,dR=!0;function Go(e,r,t){const n=e.match(r);return n&&n.length>=t&&parseInt(n[t],10)}function bo(e,r,t){if(!e.RTCPeerConnection)return;const n=e.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(s,c){if(s!==r)return i.apply(this,arguments);const o=u=>{const l=t(u);l&&(c.handleEvent?c.handleEvent(l):c(l))};return this._eventMap=this._eventMap||{},this._eventMap[r]||(this._eventMap[r]=new Map),this._eventMap[r].set(c,o),i.apply(this,[s,o])};const a=n.removeEventListener;n.removeEventListener=function(s,c){if(s!==r||!this._eventMap||!this._eventMap[r])return a.apply(this,arguments);if(!this._eventMap[r].has(c))return a.apply(this,arguments);const o=this._eventMap[r].get(c);return this._eventMap[r].delete(c),this._eventMap[r].size===0&&delete this._eventMap[r],Object.keys(this._eventMap).length===0&&delete this._eventMap,a.apply(this,[s,o])},Object.defineProperty(n,"on"+r,{get(){return this["_on"+r]},set(s){this["_on"+r]&&(this.removeEventListener(r,this["_on"+r]),delete this["_on"+r]),s&&this.addEventListener(r,this["_on"+r]=s)},enumerable:!0,configurable:!0})}function mJ(e){return typeof e!="boolean"?new Error("Argument type: "+typeof e+". Please use a boolean."):(fR=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function gJ(e){return typeof e!="boolean"?new Error("Argument type: "+typeof e+". Please use a boolean."):(dR=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function Fm(){if(typeof window=="object"){if(fR)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function bf(e,r){dR&&console.warn(e+" is deprecated, please use "+r+" instead.")}function yJ(e){const r={browser:null,version:null};if(typeof e>"u"||!e.navigator)return r.browser="Not a browser.",r;const{navigator:t}=e;if(t.mozGetUserMedia)r.browser="firefox",r.version=Go(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia||e.isSecureContext===!1&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)r.browser="chrome",r.version=Go(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/))r.browser="edge",r.version=Go(t.userAgent,/Edge\/(\d+).(\d+)$/,2);else if(e.RTCPeerConnection&&t.userAgent.match(/AppleWebKit\/(\d+)\./))r.browser="safari",r.version=Go(t.userAgent,/AppleWebKit\/(\d+)\./,1),r.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype;else return r.browser="Not a supported browser.",r;return r}function VS(e){return Object.prototype.toString.call(e)==="[object Object]"}function pR(e){return VS(e)?Object.keys(e).reduce(function(r,t){const n=VS(e[t]),i=n?pR(e[t]):e[t],a=n&&!Object.keys(i).length;return i===void 0||a?r:Object.assign(r,{[t]:i})},{}):e}function kh(e,r,t){!r||t.has(r.id)||(t.set(r.id,r),Object.keys(r).forEach(n=>{n.endsWith("Id")?kh(e,e.get(r[n]),t):n.endsWith("Ids")&&r[n].forEach(i=>{kh(e,e.get(i),t)})}))}function HS(e,r,t){const n=t?"outbound-rtp":"inbound-rtp",i=new Map;if(r===null)return i;const a=[];return e.forEach(s=>{s.type==="track"&&s.trackIdentifier===r.id&&a.push(s)}),a.forEach(s=>{e.forEach(c=>{c.type===n&&c.trackId===s.id&&kh(e,c,i)})}),i}const KS=Fm;function hR(e,r){const t=e&&e.navigator;if(!t.mediaDevices)return;const n=function(c){if(typeof c!="object"||c.mandatory||c.optional)return c;const o={};return Object.keys(c).forEach(u=>{if(u==="require"||u==="advanced"||u==="mediaSource")return;const l=typeof c[u]=="object"?c[u]:{ideal:c[u]};l.exact!==void 0&&typeof l.exact=="number"&&(l.min=l.max=l.exact);const f=function(d,p){return d?d+p.charAt(0).toUpperCase()+p.slice(1):p==="deviceId"?"sourceId":p};if(l.ideal!==void 0){o.optional=o.optional||[];let d={};typeof l.ideal=="number"?(d[f("min",u)]=l.ideal,o.optional.push(d),d={},d[f("max",u)]=l.ideal,o.optional.push(d)):(d[f("",u)]=l.ideal,o.optional.push(d))}l.exact!==void 0&&typeof l.exact!="number"?(o.mandatory=o.mandatory||{},o.mandatory[f("",u)]=l.exact):["min","max"].forEach(d=>{l[d]!==void 0&&(o.mandatory=o.mandatory||{},o.mandatory[f(d,u)]=l[d])})}),c.advanced&&(o.optional=(o.optional||[]).concat(c.advanced)),o},i=function(c,o){if(r.version>=61)return o(c);if(c=JSON.parse(JSON.stringify(c)),c&&typeof c.audio=="object"){const u=function(l,f,d){f in l&&!(d in l)&&(l[d]=l[f],delete l[f])};c=JSON.parse(JSON.stringify(c)),u(c.audio,"autoGainControl","googAutoGainControl"),u(c.audio,"noiseSuppression","googNoiseSuppression"),c.audio=n(c.audio)}if(c&&typeof c.video=="object"){let u=c.video.facingMode;u=u&&(typeof u=="object"?u:{ideal:u});const l=r.version<66;if(u&&(u.exact==="user"||u.exact==="environment"||u.ideal==="user"||u.ideal==="environment")&&!(t.mediaDevices.getSupportedConstraints&&t.mediaDevices.getSupportedConstraints().facingMode&&!l)){delete c.video.facingMode;let f;if(u.exact==="environment"||u.ideal==="environment"?f=["back","rear"]:(u.exact==="user"||u.ideal==="user")&&(f=["front"]),f)return t.mediaDevices.enumerateDevices().then(d=>{d=d.filter(h=>h.kind==="videoinput");let p=d.find(h=>f.some(E=>h.label.toLowerCase().includes(E)));return!p&&d.length&&f.includes("back")&&(p=d[d.length-1]),p&&(c.video.deviceId=u.exact?{exact:p.deviceId}:{ideal:p.deviceId}),c.video=n(c.video),KS("chrome: "+JSON.stringify(c)),o(c)})}c.video=n(c.video)}return KS("chrome: "+JSON.stringify(c)),o(c)},a=function(c){return r.version>=64?c:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[c.name]||c.name,message:c.message,constraint:c.constraint||c.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},s=function(c,o,u){i(c,l=>{t.webkitGetUserMedia(l,o,f=>{u&&u(a(f))})})};if(t.getUserMedia=s.bind(t),t.mediaDevices.getUserMedia){const c=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(o){return i(o,u=>c(u).then(l=>{if(u.audio&&!l.getAudioTracks().length||u.video&&!l.getVideoTracks().length)throw l.getTracks().forEach(f=>{f.stop()}),new DOMException("","NotFoundError");return l},l=>Promise.reject(a(l))))}}}function bJ(e,r){if(!(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices)&&e.navigator.mediaDevices){if(typeof r!="function"){console.error("shimGetDisplayMedia: getSourceId argument is not a function");return}e.navigator.mediaDevices.getDisplayMedia=function(n){return r(n).then(i=>{const a=n.video&&n.video.width,s=n.video&&n.video.height,c=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:i,maxFrameRate:c||3}},a&&(n.video.mandatory.maxWidth=a),s&&(n.video.mandatory.maxHeight=s),e.navigator.mediaDevices.getUserMedia(n)})}}}function vR(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function mR(e){if(typeof e=="object"&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(t){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=t)},enumerable:!0,configurable:!0});const r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=n=>{n.stream.addEventListener("addtrack",i=>{let a;e.RTCPeerConnection.prototype.getReceivers?a=this.getReceivers().find(c=>c.track&&c.track.id===i.track.id):a={track:i.track};const s=new Event("track");s.track=i.track,s.receiver=a,s.transceiver={receiver:a},s.streams=[n.stream],this.dispatchEvent(s)}),n.stream.getTracks().forEach(i=>{let a;e.RTCPeerConnection.prototype.getReceivers?a=this.getReceivers().find(c=>c.track&&c.track.id===i.id):a={track:i};const s=new Event("track");s.track=i,s.receiver=a,s.transceiver={receiver:a},s.streams=[n.stream],this.dispatchEvent(s)})},this.addEventListener("addstream",this._ontrackpoly)),r.apply(this,arguments)}}else bo(e,"track",r=>(r.transceiver||Object.defineProperty(r,"transceiver",{value:{receiver:r.receiver}}),r))}function gR(e){if(typeof e=="object"&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const r=function(i,a){return{track:a,get dtmf(){return this._dtmf===void 0&&(a.kind==="audio"?this._dtmf=i.createDTMFSender(a):this._dtmf=null),this._dtmf},_pc:i}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(c,o){let u=i.apply(this,arguments);return u||(u=r(this,c),this._senders.push(u)),u};const a=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(c){a.apply(this,arguments);const o=this._senders.indexOf(c);o!==-1&&this._senders.splice(o,1)}}const t=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(a){this._senders=this._senders||[],t.apply(this,[a]),a.getTracks().forEach(s=>{this._senders.push(r(this,s))})};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(a){this._senders=this._senders||[],n.apply(this,[a]),a.getTracks().forEach(s=>{const c=this._senders.find(o=>o.track===s);c&&this._senders.splice(this._senders.indexOf(c),1)})}}else if(typeof e=="object"&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const r=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const n=r.apply(this,[]);return n.forEach(i=>i._pc=this),n},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function yR(e){if(!e.RTCPeerConnection)return;const r=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[n,i,a]=arguments;if(arguments.length>0&&typeof n=="function")return r.apply(this,arguments);if(r.length===0&&(arguments.length===0||typeof n!="function"))return r.apply(this,[]);const s=function(o){const u={};return o.result().forEach(f=>{const d={id:f.id,timestamp:f.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[f.type]||f.type};f.names().forEach(p=>{d[p]=f.stat(p)}),u[d.id]=d}),u},c=function(o){return new Map(Object.keys(o).map(u=>[u,o[u]]))};if(arguments.length>=2){const o=function(u){i(c(s(u)))};return r.apply(this,[o,n])}return new Promise((o,u)=>{r.apply(this,[function(l){o(c(s(l)))},u])}).then(i,a)}}function bR(e){if(!(typeof e=="object"&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const a=t.apply(this,[]);return a.forEach(s=>s._pc=this),a});const n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){const a=n.apply(this,arguments);return a._pc=this,a}),e.RTCRtpSender.prototype.getStats=function(){const a=this;return this._pc.getStats().then(s=>HS(s,a.track,!0))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const i=t.apply(this,[]);return i.forEach(a=>a._pc=this),i}),bo(e,"track",n=>(n.receiver._pc=n.srcElement,n)),e.RTCRtpReceiver.prototype.getStats=function(){const i=this;return this._pc.getStats().then(a=>HS(a,i.track,!1))}}if(!("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype))return;const r=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const n=arguments[0];let i,a,s;return this.getSenders().forEach(c=>{c.track===n&&(i?s=!0:i=c)}),this.getReceivers().forEach(c=>(c.track===n&&(a?s=!0:a=c),c.track===n)),s||i&&a?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):i?i.getStats():a?a.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return r.apply(this,arguments)}}function _R(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(s=>this._shimmedLocalStreams[s][0])};const r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(s,c){if(!c)return r.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const o=r.apply(this,arguments);return this._shimmedLocalStreams[c.id]?this._shimmedLocalStreams[c.id].indexOf(o)===-1&&this._shimmedLocalStreams[c.id].push(o):this._shimmedLocalStreams[c.id]=[c,o],o};const t=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(s){this._shimmedLocalStreams=this._shimmedLocalStreams||{},s.getTracks().forEach(u=>{if(this.getSenders().find(f=>f.track===u))throw new DOMException("Track already exists.","InvalidAccessError")});const c=this.getSenders();t.apply(this,arguments);const o=this.getSenders().filter(u=>c.indexOf(u)===-1);this._shimmedLocalStreams[s.id]=[s].concat(o)};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(s){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[s.id],n.apply(this,arguments)};const i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(s){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},s&&Object.keys(this._shimmedLocalStreams).forEach(c=>{const o=this._shimmedLocalStreams[c].indexOf(s);o!==-1&&this._shimmedLocalStreams[c].splice(o,1),this._shimmedLocalStreams[c].length===1&&delete this._shimmedLocalStreams[c]}),i.apply(this,arguments)}}function SR(e,r){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&r.version>=65)return _R(e);const t=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const l=t.apply(this);return this._reverseStreams=this._reverseStreams||{},l.map(f=>this._reverseStreams[f.id])};const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(l){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},l.getTracks().forEach(f=>{if(this.getSenders().find(p=>p.track===f))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[l.id]){const f=new e.MediaStream(l.getTracks());this._streams[l.id]=f,this._reverseStreams[f.id]=l,l=f}n.apply(this,[l])};const i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(l){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[l.id]||l]),delete this._reverseStreams[this._streams[l.id]?this._streams[l.id].id:l.id],delete this._streams[l.id]},e.RTCPeerConnection.prototype.addTrack=function(l,f){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const d=[].slice.call(arguments,1);if(d.length!==1||!d[0].getTracks().find(E=>E===l))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(E=>E.track===l))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const h=this._streams[f.id];if(h)h.addTrack(l),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const E=new e.MediaStream([l]);this._streams[f.id]=E,this._reverseStreams[E.id]=f,this.addStream(E)}return this.getSenders().find(E=>E.track===l)};function a(u,l){let f=l.sdp;return Object.keys(u._reverseStreams||[]).forEach(d=>{const p=u._reverseStreams[d],h=u._streams[p.id];f=f.replace(new RegExp(h.id,"g"),p.id)}),new RTCSessionDescription({type:l.type,sdp:f})}function s(u,l){let f=l.sdp;return Object.keys(u._reverseStreams||[]).forEach(d=>{const p=u._reverseStreams[d],h=u._streams[p.id];f=f.replace(new RegExp(p.id,"g"),h.id)}),new RTCSessionDescription({type:l.type,sdp:f})}["createOffer","createAnswer"].forEach(function(u){const l=e.RTCPeerConnection.prototype[u],f={[u](){const d=arguments;return arguments.length&&typeof arguments[0]=="function"?l.apply(this,[h=>{const E=a(this,h);d[0].apply(null,[E])},h=>{d[1]&&d[1].apply(null,h)},arguments[2]]):l.apply(this,arguments).then(h=>a(this,h))}};e.RTCPeerConnection.prototype[u]=f[u]});const c=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?c.apply(this,arguments):(arguments[0]=s(this,arguments[0]),c.apply(this,arguments))};const o=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const u=o.get.apply(this);return u.type===""?u:a(this,u)}}),e.RTCPeerConnection.prototype.removeTrack=function(l){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!l._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(l._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let d;Object.keys(this._streams).forEach(p=>{this._streams[p].getTracks().find(E=>l.track===E)&&(d=this._streams[p])}),d&&(d.getTracks().length===1?this.removeStream(this._reverseStreams[d.id]):d.removeTrack(l.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Rh(e,r){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&r.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const n=e.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new(t==="addIceCandidate"?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=i[t]})}function wR(e,r){bo(e,"negotiationneeded",t=>{const n=t.target;if(!((r.version<72||n.getConfiguration&&n.getConfiguration().sdpSemantics==="plan-b")&&n.signalingState!=="stable"))return t})}const JS=Object.freeze(Object.defineProperty({__proto__:null,fixNegotiationNeeded:wR,shimAddTrackRemoveTrack:SR,shimAddTrackRemoveTrackWithNative:_R,shimGetDisplayMedia:bJ,shimGetSendersWithDtmf:gR,shimGetStats:yR,shimGetUserMedia:hR,shimMediaStream:vR,shimOnTrack:mR,shimPeerConnection:Rh,shimSenderReceiverGetStats:bR},Symbol.toStringTag,{value:"Module"}));function _J(e,r){let t=!1;return e=JSON.parse(JSON.stringify(e)),e.filter(n=>{if(n&&(n.urls||n.url)){let i=n.urls||n.url;n.url&&!n.urls&&bf("RTCIceServer.url","RTCIceServer.urls");const a=typeof i=="string";return a&&(i=[i]),i=i.filter(s=>{if(s.indexOf("stun:")===0)return!1;const c=s.startsWith("turn")&&!s.startsWith("turn:[")&&s.includes("transport=udp");return c&&!t?(t=!0,!0):c&&!t}),delete n.url,n.urls=a?i[0]:i,!!i.length}})}var TR={exports:{}};(function(e){var r={};r.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},r.localCName=r.generateIdentifier(),r.splitLines=function(t){return t.trim().split(`
|
|
491
|
+
`).map(function(n){return n.trim()})},r.splitSections=function(t){var n=t.split(`
|
|
492
|
+
m=`);return n.map(function(i,a){return(a>0?"m="+i:i).trim()+`\r
|
|
493
|
+
`})},r.getDescription=function(t){var n=r.splitSections(t);return n&&n[0]},r.getMediaSections=function(t){var n=r.splitSections(t);return n.shift(),n},r.matchPrefix=function(t,n){return r.splitLines(t).filter(function(i){return i.indexOf(n)===0})},r.parseCandidate=function(t){var n;t.indexOf("a=candidate:")===0?n=t.substring(12).split(" "):n=t.substring(10).split(" ");for(var i={foundation:n[0],component:parseInt(n[1],10),protocol:n[2].toLowerCase(),priority:parseInt(n[3],10),ip:n[4],address:n[4],port:parseInt(n[5],10),type:n[7]},a=8;a<n.length;a+=2)switch(n[a]){case"raddr":i.relatedAddress=n[a+1];break;case"rport":i.relatedPort=parseInt(n[a+1],10);break;case"tcptype":i.tcpType=n[a+1];break;case"ufrag":i.ufrag=n[a+1],i.usernameFragment=n[a+1];break;default:i[n[a]]=n[a+1];break}return i},r.writeCandidate=function(t){var n=[];n.push(t.foundation),n.push(t.component),n.push(t.protocol.toUpperCase()),n.push(t.priority),n.push(t.address||t.ip),n.push(t.port);var i=t.type;return n.push("typ"),n.push(i),i!=="host"&&t.relatedAddress&&t.relatedPort&&(n.push("raddr"),n.push(t.relatedAddress),n.push("rport"),n.push(t.relatedPort)),t.tcpType&&t.protocol.toLowerCase()==="tcp"&&(n.push("tcptype"),n.push(t.tcpType)),(t.usernameFragment||t.ufrag)&&(n.push("ufrag"),n.push(t.usernameFragment||t.ufrag)),"candidate:"+n.join(" ")},r.parseIceOptions=function(t){return t.substr(14).split(" ")},r.parseRtpMap=function(t){var n=t.substr(9).split(" "),i={payloadType:parseInt(n.shift(),10)};return n=n[0].split("/"),i.name=n[0],i.clockRate=parseInt(n[1],10),i.channels=n.length===3?parseInt(n[2],10):1,i.numChannels=i.channels,i},r.writeRtpMap=function(t){var n=t.payloadType;t.preferredPayloadType!==void 0&&(n=t.preferredPayloadType);var i=t.channels||t.numChannels||1;return"a=rtpmap:"+n+" "+t.name+"/"+t.clockRate+(i!==1?"/"+i:"")+`\r
|
|
494
|
+
`},r.parseExtmap=function(t){var n=t.substr(9).split(" ");return{id:parseInt(n[0],10),direction:n[0].indexOf("/")>0?n[0].split("/")[1]:"sendrecv",uri:n[1]}},r.writeExtmap=function(t){return"a=extmap:"+(t.id||t.preferredId)+(t.direction&&t.direction!=="sendrecv"?"/"+t.direction:"")+" "+t.uri+`\r
|
|
495
|
+
`},r.parseFmtp=function(t){for(var n={},i,a=t.substr(t.indexOf(" ")+1).split(";"),s=0;s<a.length;s++)i=a[s].trim().split("="),n[i[0].trim()]=i[1];return n},r.writeFmtp=function(t){var n="",i=t.payloadType;if(t.preferredPayloadType!==void 0&&(i=t.preferredPayloadType),t.parameters&&Object.keys(t.parameters).length){var a=[];Object.keys(t.parameters).forEach(function(s){t.parameters[s]?a.push(s+"="+t.parameters[s]):a.push(s)}),n+="a=fmtp:"+i+" "+a.join(";")+`\r
|
|
496
|
+
`}return n},r.parseRtcpFb=function(t){var n=t.substr(t.indexOf(" ")+1).split(" ");return{type:n.shift(),parameter:n.join(" ")}},r.writeRtcpFb=function(t){var n="",i=t.payloadType;return t.preferredPayloadType!==void 0&&(i=t.preferredPayloadType),t.rtcpFeedback&&t.rtcpFeedback.length&&t.rtcpFeedback.forEach(function(a){n+="a=rtcp-fb:"+i+" "+a.type+(a.parameter&&a.parameter.length?" "+a.parameter:"")+`\r
|
|
497
|
+
`}),n},r.parseSsrcMedia=function(t){var n=t.indexOf(" "),i={ssrc:parseInt(t.substr(7,n-7),10)},a=t.indexOf(":",n);return a>-1?(i.attribute=t.substr(n+1,a-n-1),i.value=t.substr(a+1)):i.attribute=t.substr(n+1),i},r.parseSsrcGroup=function(t){var n=t.substr(13).split(" ");return{semantics:n.shift(),ssrcs:n.map(function(i){return parseInt(i,10)})}},r.getMid=function(t){var n=r.matchPrefix(t,"a=mid:")[0];if(n)return n.substr(6)},r.parseFingerprint=function(t){var n=t.substr(14).split(" ");return{algorithm:n[0].toLowerCase(),value:n[1]}},r.getDtlsParameters=function(t,n){var i=r.matchPrefix(t+n,"a=fingerprint:");return{role:"auto",fingerprints:i.map(r.parseFingerprint)}},r.writeDtlsParameters=function(t,n){var i="a=setup:"+n+`\r
|
|
498
|
+
`;return t.fingerprints.forEach(function(a){i+="a=fingerprint:"+a.algorithm+" "+a.value+`\r
|
|
499
|
+
`}),i},r.parseCryptoLine=function(t){var n=t.substr(9).split(" ");return{tag:parseInt(n[0],10),cryptoSuite:n[1],keyParams:n[2],sessionParams:n.slice(3)}},r.writeCryptoLine=function(t){return"a=crypto:"+t.tag+" "+t.cryptoSuite+" "+(typeof t.keyParams=="object"?r.writeCryptoKeyParams(t.keyParams):t.keyParams)+(t.sessionParams?" "+t.sessionParams.join(" "):"")+`\r
|
|
500
|
+
`},r.parseCryptoKeyParams=function(t){if(t.indexOf("inline:")!==0)return null;var n=t.substr(7).split("|");return{keyMethod:"inline",keySalt:n[0],lifeTime:n[1],mkiValue:n[2]?n[2].split(":")[0]:void 0,mkiLength:n[2]?n[2].split(":")[1]:void 0}},r.writeCryptoKeyParams=function(t){return t.keyMethod+":"+t.keySalt+(t.lifeTime?"|"+t.lifeTime:"")+(t.mkiValue&&t.mkiLength?"|"+t.mkiValue+":"+t.mkiLength:"")},r.getCryptoParameters=function(t,n){var i=r.matchPrefix(t+n,"a=crypto:");return i.map(r.parseCryptoLine)},r.getIceParameters=function(t,n){var i=r.matchPrefix(t+n,"a=ice-ufrag:")[0],a=r.matchPrefix(t+n,"a=ice-pwd:")[0];return i&&a?{usernameFragment:i.substr(12),password:a.substr(10)}:null},r.writeIceParameters=function(t){return"a=ice-ufrag:"+t.usernameFragment+`\r
|
|
501
|
+
a=ice-pwd:`+t.password+`\r
|
|
502
|
+
`},r.parseRtpParameters=function(t){for(var n={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},i=r.splitLines(t),a=i[0].split(" "),s=3;s<a.length;s++){var c=a[s],o=r.matchPrefix(t,"a=rtpmap:"+c+" ")[0];if(o){var u=r.parseRtpMap(o),l=r.matchPrefix(t,"a=fmtp:"+c+" ");switch(u.parameters=l.length?r.parseFmtp(l[0]):{},u.rtcpFeedback=r.matchPrefix(t,"a=rtcp-fb:"+c+" ").map(r.parseRtcpFb),n.codecs.push(u),u.name.toUpperCase()){case"RED":case"ULPFEC":n.fecMechanisms.push(u.name.toUpperCase());break}}}return r.matchPrefix(t,"a=extmap:").forEach(function(f){n.headerExtensions.push(r.parseExtmap(f))}),n},r.writeRtpDescription=function(t,n){var i="";i+="m="+t+" ",i+=n.codecs.length>0?"9":"0",i+=" UDP/TLS/RTP/SAVPF ",i+=n.codecs.map(function(s){return s.preferredPayloadType!==void 0?s.preferredPayloadType:s.payloadType}).join(" ")+`\r
|
|
503
|
+
`,i+=`c=IN IP4 0.0.0.0\r
|
|
504
|
+
`,i+=`a=rtcp:9 IN IP4 0.0.0.0\r
|
|
505
|
+
`,n.codecs.forEach(function(s){i+=r.writeRtpMap(s),i+=r.writeFmtp(s),i+=r.writeRtcpFb(s)});var a=0;return n.codecs.forEach(function(s){s.maxptime>a&&(a=s.maxptime)}),a>0&&(i+="a=maxptime:"+a+`\r
|
|
506
|
+
`),i+=`a=rtcp-mux\r
|
|
507
|
+
`,n.headerExtensions&&n.headerExtensions.forEach(function(s){i+=r.writeExtmap(s)}),i},r.parseRtpEncodingParameters=function(t){var n=[],i=r.parseRtpParameters(t),a=i.fecMechanisms.indexOf("RED")!==-1,s=i.fecMechanisms.indexOf("ULPFEC")!==-1,c=r.matchPrefix(t,"a=ssrc:").map(function(d){return r.parseSsrcMedia(d)}).filter(function(d){return d.attribute==="cname"}),o=c.length>0&&c[0].ssrc,u,l=r.matchPrefix(t,"a=ssrc-group:FID").map(function(d){var p=d.substr(17).split(" ");return p.map(function(h){return parseInt(h,10)})});l.length>0&&l[0].length>1&&l[0][0]===o&&(u=l[0][1]),i.codecs.forEach(function(d){if(d.name.toUpperCase()==="RTX"&&d.parameters.apt){var p={ssrc:o,codecPayloadType:parseInt(d.parameters.apt,10)};o&&u&&(p.rtx={ssrc:u}),n.push(p),a&&(p=JSON.parse(JSON.stringify(p)),p.fec={ssrc:o,mechanism:s?"red+ulpfec":"red"},n.push(p))}}),n.length===0&&o&&n.push({ssrc:o});var f=r.matchPrefix(t,"b=");return f.length&&(f[0].indexOf("b=TIAS:")===0?f=parseInt(f[0].substr(7),10):f[0].indexOf("b=AS:")===0?f=parseInt(f[0].substr(5),10)*1e3*.95-50*40*8:f=void 0,n.forEach(function(d){d.maxBitrate=f})),n},r.parseRtcpParameters=function(t){var n={},i=r.matchPrefix(t,"a=ssrc:").map(function(c){return r.parseSsrcMedia(c)}).filter(function(c){return c.attribute==="cname"})[0];i&&(n.cname=i.value,n.ssrc=i.ssrc);var a=r.matchPrefix(t,"a=rtcp-rsize");n.reducedSize=a.length>0,n.compound=a.length===0;var s=r.matchPrefix(t,"a=rtcp-mux");return n.mux=s.length>0,n},r.parseMsid=function(t){var n,i=r.matchPrefix(t,"a=msid:");if(i.length===1)return n=i[0].substr(7).split(" "),{stream:n[0],track:n[1]};var a=r.matchPrefix(t,"a=ssrc:").map(function(s){return r.parseSsrcMedia(s)}).filter(function(s){return s.attribute==="msid"});if(a.length>0)return n=a[0].value.split(" "),{stream:n[0],track:n[1]}},r.parseSctpDescription=function(t){var n=r.parseMLine(t),i=r.matchPrefix(t,"a=max-message-size:"),a;i.length>0&&(a=parseInt(i[0].substr(19),10)),isNaN(a)&&(a=65536);var s=r.matchPrefix(t,"a=sctp-port:");if(s.length>0)return{port:parseInt(s[0].substr(12),10),protocol:n.fmt,maxMessageSize:a};var c=r.matchPrefix(t,"a=sctpmap:");if(c.length>0){var o=r.matchPrefix(t,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(o[0],10),protocol:o[1],maxMessageSize:a}}},r.writeSctpDescription=function(t,n){var i=[];return t.protocol!=="DTLS/SCTP"?i=["m="+t.kind+" 9 "+t.protocol+" "+n.protocol+`\r
|
|
508
|
+
`,`c=IN IP4 0.0.0.0\r
|
|
509
|
+
`,"a=sctp-port:"+n.port+`\r
|
|
510
|
+
`]:i=["m="+t.kind+" 9 "+t.protocol+" "+n.port+`\r
|
|
511
|
+
`,`c=IN IP4 0.0.0.0\r
|
|
512
|
+
`,"a=sctpmap:"+n.port+" "+n.protocol+` 65535\r
|
|
513
|
+
`],n.maxMessageSize!==void 0&&i.push("a=max-message-size:"+n.maxMessageSize+`\r
|
|
514
|
+
`),i.join("")},r.generateSessionId=function(){return Math.random().toString().substr(2,21)},r.writeSessionBoilerplate=function(t,n,i){var a,s=n!==void 0?n:2;t?a=t:a=r.generateSessionId();var c=i||"thisisadapterortc";return`v=0\r
|
|
515
|
+
o=`+c+" "+a+" "+s+` IN IP4 127.0.0.1\r
|
|
516
|
+
s=-\r
|
|
517
|
+
t=0 0\r
|
|
518
|
+
`},r.writeMediaSection=function(t,n,i,a){var s=r.writeRtpDescription(t.kind,n);if(s+=r.writeIceParameters(t.iceGatherer.getLocalParameters()),s+=r.writeDtlsParameters(t.dtlsTransport.getLocalParameters(),i==="offer"?"actpass":"active"),s+="a=mid:"+t.mid+`\r
|
|
519
|
+
`,t.direction?s+="a="+t.direction+`\r
|
|
520
|
+
`:t.rtpSender&&t.rtpReceiver?s+=`a=sendrecv\r
|
|
521
|
+
`:t.rtpSender?s+=`a=sendonly\r
|
|
522
|
+
`:t.rtpReceiver?s+=`a=recvonly\r
|
|
523
|
+
`:s+=`a=inactive\r
|
|
524
|
+
`,t.rtpSender){var c="msid:"+a.id+" "+t.rtpSender.track.id+`\r
|
|
525
|
+
`;s+="a="+c,s+="a=ssrc:"+t.sendEncodingParameters[0].ssrc+" "+c,t.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+t.sendEncodingParameters[0].rtx.ssrc+" "+c,s+="a=ssrc-group:FID "+t.sendEncodingParameters[0].ssrc+" "+t.sendEncodingParameters[0].rtx.ssrc+`\r
|
|
526
|
+
`)}return s+="a=ssrc:"+t.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+`\r
|
|
527
|
+
`,t.rtpSender&&t.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+t.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+`\r
|
|
528
|
+
`),s},r.getDirection=function(t,n){for(var i=r.splitLines(t),a=0;a<i.length;a++)switch(i[a]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return i[a].substr(2)}return n?r.getDirection(n):"sendrecv"},r.getKind=function(t){var n=r.splitLines(t),i=n[0].split(" ");return i[0].substr(2)},r.isRejected=function(t){return t.split(" ",2)[1]==="0"},r.parseMLine=function(t){var n=r.splitLines(t),i=n[0].substr(2).split(" ");return{kind:i[0],port:parseInt(i[1],10),protocol:i[2],fmt:i.slice(3).join(" ")}},r.parseOLine=function(t){var n=r.matchPrefix(t,"o=")[0],i=n.substr(2).split(" ");return{username:i[0],sessionId:i[1],sessionVersion:parseInt(i[2],10),netType:i[3],addressType:i[4],address:i[5]}},r.isValidSDP=function(t){if(typeof t!="string"||t.length===0)return!1;for(var n=r.splitLines(t),i=0;i<n.length;i++)if(n[i].length<2||n[i].charAt(1)!=="=")return!1;return!0},e.exports=r})(TR);var CR=TR.exports;const Hc=Vh(CR);var ht=CR;function SJ(e){return{inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type}function YS(e,r,t,n,i){var a=ht.writeRtpDescription(e.kind,r);if(a+=ht.writeIceParameters(e.iceGatherer.getLocalParameters()),a+=ht.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),t==="offer"?"actpass":i||"active"),a+="a=mid:"+e.mid+`\r
|
|
529
|
+
`,e.rtpSender&&e.rtpReceiver?a+=`a=sendrecv\r
|
|
530
|
+
`:e.rtpSender?a+=`a=sendonly\r
|
|
531
|
+
`:e.rtpReceiver?a+=`a=recvonly\r
|
|
532
|
+
`:a+=`a=inactive\r
|
|
533
|
+
`,e.rtpSender){var s=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=s;var c="msid:"+(n?n.id:"-")+" "+s+`\r
|
|
534
|
+
`;a+="a="+c,a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+c,e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+c,a+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+`\r
|
|
535
|
+
`)}return a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+ht.localCName+`\r
|
|
536
|
+
`,e.rtpSender&&e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+ht.localCName+`\r
|
|
537
|
+
`),a}function wJ(e,r){var t=!1;return e=JSON.parse(JSON.stringify(e)),e.filter(function(n){if(n&&(n.urls||n.url)){var i=n.urls||n.url;n.url&&!n.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var a=typeof i=="string";return a&&(i=[i]),i=i.filter(function(s){var c=s.indexOf("turn:")===0&&s.indexOf("transport=udp")!==-1&&s.indexOf("turn:[")===-1&&!t;return c?(t=!0,!0):s.indexOf("stun:")===0&&r>=14393&&s.indexOf("?transport=udp")===-1}),delete n.url,n.urls=a?i[0]:i,!!i.length}})}function $c(e,r){var t={codecs:[],headerExtensions:[],fecMechanisms:[]},n=function(a,s){a=parseInt(a,10);for(var c=0;c<s.length;c++)if(s[c].payloadType===a||s[c].preferredPayloadType===a)return s[c]},i=function(a,s,c,o){var u=n(a.parameters.apt,c),l=n(s.parameters.apt,o);return u&&l&&u.name.toLowerCase()===l.name.toLowerCase()};return e.codecs.forEach(function(a){for(var s=0;s<r.codecs.length;s++){var c=r.codecs[s];if(a.name.toLowerCase()===c.name.toLowerCase()&&a.clockRate===c.clockRate){if(a.name.toLowerCase()==="rtx"&&a.parameters&&c.parameters.apt&&!i(a,c,e.codecs,r.codecs))continue;c=JSON.parse(JSON.stringify(c)),c.numChannels=Math.min(a.numChannels,c.numChannels),t.codecs.push(c),c.rtcpFeedback=c.rtcpFeedback.filter(function(o){for(var u=0;u<a.rtcpFeedback.length;u++)if(a.rtcpFeedback[u].type===o.type&&a.rtcpFeedback[u].parameter===o.parameter)return!0;return!1});break}}}),e.headerExtensions.forEach(function(a){for(var s=0;s<r.headerExtensions.length;s++){var c=r.headerExtensions[s];if(a.uri===c.uri){t.headerExtensions.push(c);break}}}),t}function XS(e,r,t){return{offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}}[r][e].indexOf(t)!==-1}function op(e,r){var t=e.getRemoteCandidates().find(function(n){return r.foundation===n.foundation&&r.ip===n.ip&&r.port===n.port&&r.priority===n.priority&&r.protocol===n.protocol&&r.type===n.type});return t||e.addRemoteCandidate(r),!t}function Mr(e,r){var t=new Error(r);return t.name=e,t.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[e],t}var TJ=function(e,r){function t(o,u){u.addTrack(o),u.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:o}))}function n(o,u){u.removeTrack(o),u.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:o}))}function i(o,u,l,f){var d=new Event("track");d.track=u,d.receiver=l,d.transceiver={receiver:l},d.streams=f,e.setTimeout(function(){o._dispatchEvent("track",d)})}var a=function(o){var u=this,l=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(d){u[d]=l[d].bind(l)}),this.canTrickleIceCandidates=null,this.needNegotiation=!1,this.localStreams=[],this.remoteStreams=[],this._localDescription=null,this._remoteDescription=null,this.signalingState="stable",this.iceConnectionState="new",this.connectionState="new",this.iceGatheringState="new",o=JSON.parse(JSON.stringify(o||{})),this.usingBundle=o.bundlePolicy==="max-bundle",o.rtcpMuxPolicy==="negotiate")throw Mr("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(o.rtcpMuxPolicy||(o.rtcpMuxPolicy="require"),o.iceTransportPolicy){case"all":case"relay":break;default:o.iceTransportPolicy="all";break}switch(o.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:o.bundlePolicy="balanced";break}if(o.iceServers=wJ(o.iceServers||[],r),this._iceGatherers=[],o.iceCandidatePoolSize)for(var f=o.iceCandidatePoolSize;f>0;f--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:o.iceServers,gatherPolicy:o.iceTransportPolicy}));else o.iceCandidatePoolSize=0;this._config=o,this.transceivers=[],this._sdpSessionId=ht.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(a.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(a.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),a.prototype.onicecandidate=null,a.prototype.onaddstream=null,a.prototype.ontrack=null,a.prototype.onremovestream=null,a.prototype.onsignalingstatechange=null,a.prototype.oniceconnectionstatechange=null,a.prototype.onconnectionstatechange=null,a.prototype.onicegatheringstatechange=null,a.prototype.onnegotiationneeded=null,a.prototype.ondatachannel=null,a.prototype._dispatchEvent=function(o,u){this._isClosed||(this.dispatchEvent(u),typeof this["on"+o]=="function"&&this["on"+o](u))},a.prototype._emitGatheringStateChange=function(){var o=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",o)},a.prototype.getConfiguration=function(){return this._config},a.prototype.getLocalStreams=function(){return this.localStreams},a.prototype.getRemoteStreams=function(){return this.remoteStreams},a.prototype._createTransceiver=function(o,u){var l=this.transceivers.length>0,f={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:o,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&l)f.iceTransport=this.transceivers[0].iceTransport,f.dtlsTransport=this.transceivers[0].dtlsTransport;else{var d=this._createIceAndDtlsTransports();f.iceTransport=d.iceTransport,f.dtlsTransport=d.dtlsTransport}return u||this.transceivers.push(f),f},a.prototype.addTrack=function(o,u){if(this._isClosed)throw Mr("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var l=this.transceivers.find(function(p){return p.track===o});if(l)throw Mr("InvalidAccessError","Track already exists.");for(var f,d=0;d<this.transceivers.length;d++)!this.transceivers[d].track&&this.transceivers[d].kind===o.kind&&(f=this.transceivers[d]);return f||(f=this._createTransceiver(o.kind)),this._maybeFireNegotiationNeeded(),this.localStreams.indexOf(u)===-1&&this.localStreams.push(u),f.track=o,f.stream=u,f.rtpSender=new e.RTCRtpSender(o,f.dtlsTransport),f.rtpSender},a.prototype.addStream=function(o){var u=this;if(r>=15025)o.getTracks().forEach(function(f){u.addTrack(f,o)});else{var l=o.clone();o.getTracks().forEach(function(f,d){var p=l.getTracks()[d];f.addEventListener("enabled",function(h){p.enabled=h.enabled})}),l.getTracks().forEach(function(f){u.addTrack(f,l)})}},a.prototype.removeTrack=function(o){if(this._isClosed)throw Mr("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(o instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var u=this.transceivers.find(function(d){return d.rtpSender===o});if(!u)throw Mr("InvalidAccessError","Sender was not created by this connection.");var l=u.stream;u.rtpSender.stop(),u.rtpSender=null,u.track=null,u.stream=null;var f=this.transceivers.map(function(d){return d.stream});f.indexOf(l)===-1&&this.localStreams.indexOf(l)>-1&&this.localStreams.splice(this.localStreams.indexOf(l),1),this._maybeFireNegotiationNeeded()},a.prototype.removeStream=function(o){var u=this;o.getTracks().forEach(function(l){var f=u.getSenders().find(function(d){return d.track===l});f&&u.removeTrack(f)})},a.prototype.getSenders=function(){return this.transceivers.filter(function(o){return!!o.rtpSender}).map(function(o){return o.rtpSender})},a.prototype.getReceivers=function(){return this.transceivers.filter(function(o){return!!o.rtpReceiver}).map(function(o){return o.rtpReceiver})},a.prototype._createIceGatherer=function(o,u){var l=this;if(u&&o>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var f=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(f,"state",{value:"new",writable:!0}),this.transceivers[o].bufferedCandidateEvents=[],this.transceivers[o].bufferCandidates=function(d){var p=!d.candidate||Object.keys(d.candidate).length===0;f.state=p?"completed":"gathering",l.transceivers[o].bufferedCandidateEvents!==null&&l.transceivers[o].bufferedCandidateEvents.push(d)},f.addEventListener("localcandidate",this.transceivers[o].bufferCandidates),f},a.prototype._gather=function(o,u){var l=this,f=this.transceivers[u].iceGatherer;if(!f.onlocalcandidate){var d=this.transceivers[u].bufferedCandidateEvents;this.transceivers[u].bufferedCandidateEvents=null,f.removeEventListener("localcandidate",this.transceivers[u].bufferCandidates),f.onlocalcandidate=function(p){if(!(l.usingBundle&&u>0)){var h=new Event("icecandidate");h.candidate={sdpMid:o,sdpMLineIndex:u};var E=p.candidate,M=!E||Object.keys(E).length===0;if(M)(f.state==="new"||f.state==="gathering")&&(f.state="completed");else{f.state==="new"&&(f.state="gathering"),E.component=1,E.ufrag=f.getLocalParameters().usernameFragment;var I=ht.writeCandidate(E);h.candidate=Object.assign(h.candidate,ht.parseCandidate(I)),h.candidate.candidate=I,h.candidate.toJSON=function(){return{candidate:h.candidate.candidate,sdpMid:h.candidate.sdpMid,sdpMLineIndex:h.candidate.sdpMLineIndex,usernameFragment:h.candidate.usernameFragment}}}var x=ht.getMediaSections(l._localDescription.sdp);M?x[h.candidate.sdpMLineIndex]+=`a=end-of-candidates\r
|
|
538
|
+
`:x[h.candidate.sdpMLineIndex]+="a="+h.candidate.candidate+`\r
|
|
539
|
+
`,l._localDescription.sdp=ht.getDescription(l._localDescription.sdp)+x.join("");var j=l.transceivers.every(function(z){return z.iceGatherer&&z.iceGatherer.state==="completed"});l.iceGatheringState!=="gathering"&&(l.iceGatheringState="gathering",l._emitGatheringStateChange()),M||l._dispatchEvent("icecandidate",h),j&&(l._dispatchEvent("icecandidate",new Event("icecandidate")),l.iceGatheringState="complete",l._emitGatheringStateChange())}},e.setTimeout(function(){d.forEach(function(p){f.onlocalcandidate(p)})},0)}},a.prototype._createIceAndDtlsTransports=function(){var o=this,u=new e.RTCIceTransport(null);u.onicestatechange=function(){o._updateIceConnectionState(),o._updateConnectionState()};var l=new e.RTCDtlsTransport(u);return l.ondtlsstatechange=function(){o._updateConnectionState()},l.onerror=function(){Object.defineProperty(l,"state",{value:"failed",writable:!0}),o._updateConnectionState()},{iceTransport:u,dtlsTransport:l}},a.prototype._disposeIceAndDtlsTransports=function(o){var u=this.transceivers[o].iceGatherer;u&&(delete u.onlocalcandidate,delete this.transceivers[o].iceGatherer);var l=this.transceivers[o].iceTransport;l&&(delete l.onicestatechange,delete this.transceivers[o].iceTransport);var f=this.transceivers[o].dtlsTransport;f&&(delete f.ondtlsstatechange,delete f.onerror,delete this.transceivers[o].dtlsTransport)},a.prototype._transceive=function(o,u,l){var f=$c(o.localCapabilities,o.remoteCapabilities);u&&o.rtpSender&&(f.encodings=o.sendEncodingParameters,f.rtcp={cname:ht.localCName,compound:o.rtcpParameters.compound},o.recvEncodingParameters.length&&(f.rtcp.ssrc=o.recvEncodingParameters[0].ssrc),o.rtpSender.send(f)),l&&o.rtpReceiver&&f.codecs.length>0&&(o.kind==="video"&&o.recvEncodingParameters&&r<15019&&o.recvEncodingParameters.forEach(function(d){delete d.rtx}),o.recvEncodingParameters.length?f.encodings=o.recvEncodingParameters:f.encodings=[{}],f.rtcp={compound:o.rtcpParameters.compound},o.rtcpParameters.cname&&(f.rtcp.cname=o.rtcpParameters.cname),o.sendEncodingParameters.length&&(f.rtcp.ssrc=o.sendEncodingParameters[0].ssrc),o.rtpReceiver.receive(f))},a.prototype.setLocalDescription=function(o){var u=this;if(["offer","answer"].indexOf(o.type)===-1)return Promise.reject(Mr("TypeError",'Unsupported type "'+o.type+'"'));if(!XS("setLocalDescription",o.type,u.signalingState)||u._isClosed)return Promise.reject(Mr("InvalidStateError","Can not set local "+o.type+" in state "+u.signalingState));var l,f;if(o.type==="offer")l=ht.splitSections(o.sdp),f=l.shift(),l.forEach(function(p,h){var E=ht.parseRtpParameters(p);u.transceivers[h].localCapabilities=E}),u.transceivers.forEach(function(p,h){u._gather(p.mid,h)});else if(o.type==="answer"){l=ht.splitSections(u._remoteDescription.sdp),f=l.shift();var d=ht.matchPrefix(f,"a=ice-lite").length>0;l.forEach(function(p,h){var E=u.transceivers[h],M=E.iceGatherer,I=E.iceTransport,x=E.dtlsTransport,j=E.localCapabilities,z=E.remoteCapabilities,ie=ht.isRejected(p)&&ht.matchPrefix(p,"a=bundle-only").length===0;if(!ie&&!E.rejected){var oe=ht.getIceParameters(p,f),J=ht.getDtlsParameters(p,f);d&&(J.role="server"),(!u.usingBundle||h===0)&&(u._gather(E.mid,h),I.state==="new"&&I.start(M,oe,d?"controlling":"controlled"),x.state==="new"&&x.start(J));var L=$c(j,z);u._transceive(E,L.codecs.length>0,!1)}})}return u._localDescription={type:o.type,sdp:o.sdp},o.type==="offer"?u._updateSignalingState("have-local-offer"):u._updateSignalingState("stable"),Promise.resolve()},a.prototype.setRemoteDescription=function(o){var u=this;if(["offer","answer"].indexOf(o.type)===-1)return Promise.reject(Mr("TypeError",'Unsupported type "'+o.type+'"'));if(!XS("setRemoteDescription",o.type,u.signalingState)||u._isClosed)return Promise.reject(Mr("InvalidStateError","Can not set remote "+o.type+" in state "+u.signalingState));var l={};u.remoteStreams.forEach(function(I){l[I.id]=I});var f=[],d=ht.splitSections(o.sdp),p=d.shift(),h=ht.matchPrefix(p,"a=ice-lite").length>0,E=ht.matchPrefix(p,"a=group:BUNDLE ").length>0;u.usingBundle=E;var M=ht.matchPrefix(p,"a=ice-options:")[0];return M?u.canTrickleIceCandidates=M.substr(14).split(" ").indexOf("trickle")>=0:u.canTrickleIceCandidates=!1,d.forEach(function(I,x){var j=ht.splitLines(I),z=ht.getKind(I),ie=ht.isRejected(I)&&ht.matchPrefix(I,"a=bundle-only").length===0,oe=j[0].substr(2).split(" ")[2],J=ht.getDirection(I,p),L=ht.parseMsid(I),Y=ht.getMid(I)||ht.generateIdentifier();if(ie||z==="application"&&(oe==="DTLS/SCTP"||oe==="UDP/DTLS/SCTP")){u.transceivers[x]={mid:Y,kind:z,protocol:oe,rejected:!0};return}!ie&&u.transceivers[x]&&u.transceivers[x].rejected&&(u.transceivers[x]=u._createTransceiver(z,!0));var Z,ye,Re,ae,Ve,be,Te,we,ge,$e=ht.parseRtpParameters(I),De,G;ie||(De=ht.getIceParameters(I,p),G=ht.getDtlsParameters(I,p),G.role="client"),Te=ht.parseRtpEncodingParameters(I);var Qe=ht.parseRtcpParameters(I),Et=ht.matchPrefix(I,"a=end-of-candidates",p).length>0,ut=ht.matchPrefix(I,"a=candidate:").map(function(fe){return ht.parseCandidate(fe)}).filter(function(fe){return fe.component===1});if((o.type==="offer"||o.type==="answer")&&!ie&&E&&x>0&&u.transceivers[x]&&(u._disposeIceAndDtlsTransports(x),u.transceivers[x].iceGatherer=u.transceivers[0].iceGatherer,u.transceivers[x].iceTransport=u.transceivers[0].iceTransport,u.transceivers[x].dtlsTransport=u.transceivers[0].dtlsTransport,u.transceivers[x].rtpSender&&u.transceivers[x].rtpSender.setTransport(u.transceivers[0].dtlsTransport),u.transceivers[x].rtpReceiver&&u.transceivers[x].rtpReceiver.setTransport(u.transceivers[0].dtlsTransport)),o.type==="offer"&&!ie){Z=u.transceivers[x]||u._createTransceiver(z),Z.mid=Y,Z.iceGatherer||(Z.iceGatherer=u._createIceGatherer(x,E)),ut.length&&Z.iceTransport.state==="new"&&(Et&&(!E||x===0)?Z.iceTransport.setRemoteCandidates(ut):ut.forEach(function(fe){op(Z.iceTransport,fe)})),we=e.RTCRtpReceiver.getCapabilities(z),r<15019&&(we.codecs=we.codecs.filter(function(fe){return fe.name!=="rtx"})),be=Z.sendEncodingParameters||[{ssrc:(2*x+2)*1001}];var je=!1;if(J==="sendrecv"||J==="sendonly"){if(je=!Z.rtpReceiver,Ve=Z.rtpReceiver||new e.RTCRtpReceiver(Z.dtlsTransport,z),je){var te;ge=Ve.track,L&&L.stream==="-"||(L?(l[L.stream]||(l[L.stream]=new e.MediaStream,Object.defineProperty(l[L.stream],"id",{get:function(){return L.stream}})),Object.defineProperty(ge,"id",{get:function(){return L.track}}),te=l[L.stream]):(l.default||(l.default=new e.MediaStream),te=l.default)),te&&(t(ge,te),Z.associatedRemoteMediaStreams.push(te)),f.push([ge,Ve,te])}}else Z.rtpReceiver&&Z.rtpReceiver.track&&(Z.associatedRemoteMediaStreams.forEach(function(fe){var Pt=fe.getTracks().find(function(We){return We.id===Z.rtpReceiver.track.id});Pt&&n(Pt,fe)}),Z.associatedRemoteMediaStreams=[]);Z.localCapabilities=we,Z.remoteCapabilities=$e,Z.rtpReceiver=Ve,Z.rtcpParameters=Qe,Z.sendEncodingParameters=be,Z.recvEncodingParameters=Te,u._transceive(u.transceivers[x],!1,je)}else if(o.type==="answer"&&!ie){Z=u.transceivers[x],ye=Z.iceGatherer,Re=Z.iceTransport,ae=Z.dtlsTransport,Ve=Z.rtpReceiver,be=Z.sendEncodingParameters,we=Z.localCapabilities,u.transceivers[x].recvEncodingParameters=Te,u.transceivers[x].remoteCapabilities=$e,u.transceivers[x].rtcpParameters=Qe,ut.length&&Re.state==="new"&&((h||Et)&&(!E||x===0)?Re.setRemoteCandidates(ut):ut.forEach(function(fe){op(Z.iceTransport,fe)})),(!E||x===0)&&(Re.state==="new"&&Re.start(ye,De,"controlling"),ae.state==="new"&&ae.start(G));var ur=$c(Z.localCapabilities,Z.remoteCapabilities),Me=ur.codecs.filter(function(fe){return fe.name.toLowerCase()==="rtx"}).length;!Me&&Z.sendEncodingParameters[0].rtx&&delete Z.sendEncodingParameters[0].rtx,u._transceive(Z,J==="sendrecv"||J==="recvonly",J==="sendrecv"||J==="sendonly"),Ve&&(J==="sendrecv"||J==="sendonly")?(ge=Ve.track,L?(l[L.stream]||(l[L.stream]=new e.MediaStream),t(ge,l[L.stream]),f.push([ge,Ve,l[L.stream]])):(l.default||(l.default=new e.MediaStream),t(ge,l.default),f.push([ge,Ve,l.default]))):delete Z.rtpReceiver}}),u._dtlsRole===void 0&&(u._dtlsRole=o.type==="offer"?"active":"passive"),u._remoteDescription={type:o.type,sdp:o.sdp},o.type==="offer"?u._updateSignalingState("have-remote-offer"):u._updateSignalingState("stable"),Object.keys(l).forEach(function(I){var x=l[I];if(x.getTracks().length){if(u.remoteStreams.indexOf(x)===-1){u.remoteStreams.push(x);var j=new Event("addstream");j.stream=x,e.setTimeout(function(){u._dispatchEvent("addstream",j)})}f.forEach(function(z){var ie=z[0],oe=z[1];x.id===z[2].id&&i(u,ie,oe,[x])})}}),f.forEach(function(I){I[2]||i(u,I[0],I[1],[])}),e.setTimeout(function(){u&&u.transceivers&&u.transceivers.forEach(function(I){I.iceTransport&&I.iceTransport.state==="new"&&I.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),I.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},a.prototype.close=function(){this.transceivers.forEach(function(o){o.iceTransport&&o.iceTransport.stop(),o.dtlsTransport&&o.dtlsTransport.stop(),o.rtpSender&&o.rtpSender.stop(),o.rtpReceiver&&o.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},a.prototype._updateSignalingState=function(o){this.signalingState=o;var u=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",u)},a.prototype._maybeFireNegotiationNeeded=function(){var o=this;this.signalingState!=="stable"||this.needNegotiation===!0||(this.needNegotiation=!0,e.setTimeout(function(){if(o.needNegotiation){o.needNegotiation=!1;var u=new Event("negotiationneeded");o._dispatchEvent("negotiationneeded",u)}},0))},a.prototype._updateIceConnectionState=function(){var o,u={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(f){f.iceTransport&&!f.rejected&&u[f.iceTransport.state]++}),o="new",u.failed>0?o="failed":u.checking>0?o="checking":u.disconnected>0?o="disconnected":u.new>0?o="new":u.connected>0?o="connected":u.completed>0&&(o="completed"),o!==this.iceConnectionState){this.iceConnectionState=o;var l=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",l)}},a.prototype._updateConnectionState=function(){var o,u={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(f){f.iceTransport&&f.dtlsTransport&&!f.rejected&&(u[f.iceTransport.state]++,u[f.dtlsTransport.state]++)}),u.connected+=u.completed,o="new",u.failed>0?o="failed":u.connecting>0?o="connecting":u.disconnected>0?o="disconnected":u.new>0?o="new":u.connected>0&&(o="connected"),o!==this.connectionState){this.connectionState=o;var l=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",l)}},a.prototype.createOffer=function(){var o=this;if(o._isClosed)return Promise.reject(Mr("InvalidStateError","Can not call createOffer after close"));var u=o.transceivers.filter(function(h){return h.kind==="audio"}).length,l=o.transceivers.filter(function(h){return h.kind==="video"}).length,f=arguments[0];if(f){if(f.mandatory||f.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");f.offerToReceiveAudio!==void 0&&(f.offerToReceiveAudio===!0?u=1:f.offerToReceiveAudio===!1?u=0:u=f.offerToReceiveAudio),f.offerToReceiveVideo!==void 0&&(f.offerToReceiveVideo===!0?l=1:f.offerToReceiveVideo===!1?l=0:l=f.offerToReceiveVideo)}for(o.transceivers.forEach(function(h){h.kind==="audio"?(u--,u<0&&(h.wantReceive=!1)):h.kind==="video"&&(l--,l<0&&(h.wantReceive=!1))});u>0||l>0;)u>0&&(o._createTransceiver("audio"),u--),l>0&&(o._createTransceiver("video"),l--);var d=ht.writeSessionBoilerplate(o._sdpSessionId,o._sdpSessionVersion++);o.transceivers.forEach(function(h,E){var M=h.track,I=h.kind,x=h.mid||ht.generateIdentifier();h.mid=x,h.iceGatherer||(h.iceGatherer=o._createIceGatherer(E,o.usingBundle));var j=e.RTCRtpSender.getCapabilities(I);r<15019&&(j.codecs=j.codecs.filter(function(ie){return ie.name!=="rtx"})),j.codecs.forEach(function(ie){ie.name==="H264"&&ie.parameters["level-asymmetry-allowed"]===void 0&&(ie.parameters["level-asymmetry-allowed"]="1"),h.remoteCapabilities&&h.remoteCapabilities.codecs&&h.remoteCapabilities.codecs.forEach(function(oe){ie.name.toLowerCase()===oe.name.toLowerCase()&&ie.clockRate===oe.clockRate&&(ie.preferredPayloadType=oe.payloadType)})}),j.headerExtensions.forEach(function(ie){var oe=h.remoteCapabilities&&h.remoteCapabilities.headerExtensions||[];oe.forEach(function(J){ie.uri===J.uri&&(ie.id=J.id)})});var z=h.sendEncodingParameters||[{ssrc:(2*E+1)*1001}];M&&r>=15019&&I==="video"&&!z[0].rtx&&(z[0].rtx={ssrc:z[0].ssrc+1}),h.wantReceive&&(h.rtpReceiver=new e.RTCRtpReceiver(h.dtlsTransport,I)),h.localCapabilities=j,h.sendEncodingParameters=z}),o._config.bundlePolicy!=="max-compat"&&(d+="a=group:BUNDLE "+o.transceivers.map(function(h){return h.mid}).join(" ")+`\r
|
|
540
|
+
`),d+=`a=ice-options:trickle\r
|
|
541
|
+
`,o.transceivers.forEach(function(h,E){d+=YS(h,h.localCapabilities,"offer",h.stream,o._dtlsRole),d+=`a=rtcp-rsize\r
|
|
542
|
+
`,h.iceGatherer&&o.iceGatheringState!=="new"&&(E===0||!o.usingBundle)&&(h.iceGatherer.getLocalCandidates().forEach(function(M){M.component=1,d+="a="+ht.writeCandidate(M)+`\r
|
|
543
|
+
`}),h.iceGatherer.state==="completed"&&(d+=`a=end-of-candidates\r
|
|
544
|
+
`))});var p=new e.RTCSessionDescription({type:"offer",sdp:d});return Promise.resolve(p)},a.prototype.createAnswer=function(){var o=this;if(o._isClosed)return Promise.reject(Mr("InvalidStateError","Can not call createAnswer after close"));if(!(o.signalingState==="have-remote-offer"||o.signalingState==="have-local-pranswer"))return Promise.reject(Mr("InvalidStateError","Can not call createAnswer in signalingState "+o.signalingState));var u=ht.writeSessionBoilerplate(o._sdpSessionId,o._sdpSessionVersion++);o.usingBundle&&(u+="a=group:BUNDLE "+o.transceivers.map(function(d){return d.mid}).join(" ")+`\r
|
|
545
|
+
`),u+=`a=ice-options:trickle\r
|
|
546
|
+
`;var l=ht.getMediaSections(o._remoteDescription.sdp).length;o.transceivers.forEach(function(d,p){if(!(p+1>l)){if(d.rejected){d.kind==="application"?d.protocol==="DTLS/SCTP"?u+=`m=application 0 DTLS/SCTP 5000\r
|
|
547
|
+
`:u+="m=application 0 "+d.protocol+` webrtc-datachannel\r
|
|
548
|
+
`:d.kind==="audio"?u+=`m=audio 0 UDP/TLS/RTP/SAVPF 0\r
|
|
549
|
+
a=rtpmap:0 PCMU/8000\r
|
|
550
|
+
`:d.kind==="video"&&(u+=`m=video 0 UDP/TLS/RTP/SAVPF 120\r
|
|
551
|
+
a=rtpmap:120 VP8/90000\r
|
|
552
|
+
`),u+=`c=IN IP4 0.0.0.0\r
|
|
553
|
+
a=inactive\r
|
|
554
|
+
a=mid:`+d.mid+`\r
|
|
555
|
+
`;return}if(d.stream){var h;d.kind==="audio"?h=d.stream.getAudioTracks()[0]:d.kind==="video"&&(h=d.stream.getVideoTracks()[0]),h&&r>=15019&&d.kind==="video"&&!d.sendEncodingParameters[0].rtx&&(d.sendEncodingParameters[0].rtx={ssrc:d.sendEncodingParameters[0].ssrc+1})}var E=$c(d.localCapabilities,d.remoteCapabilities),M=E.codecs.filter(function(I){return I.name.toLowerCase()==="rtx"}).length;!M&&d.sendEncodingParameters[0].rtx&&delete d.sendEncodingParameters[0].rtx,u+=YS(d,E,"answer",d.stream,o._dtlsRole),d.rtcpParameters&&d.rtcpParameters.reducedSize&&(u+=`a=rtcp-rsize\r
|
|
556
|
+
`)}});var f=new e.RTCSessionDescription({type:"answer",sdp:u});return Promise.resolve(f)},a.prototype.addIceCandidate=function(o){var u=this,l;return o&&!(o.sdpMLineIndex!==void 0||o.sdpMid)?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(f,d){if(u._remoteDescription)if(!o||o.candidate==="")for(var p=0;p<u.transceivers.length&&!(!u.transceivers[p].rejected&&(u.transceivers[p].iceTransport.addRemoteCandidate({}),l=ht.getMediaSections(u._remoteDescription.sdp),l[p]+=`a=end-of-candidates\r
|
|
557
|
+
`,u._remoteDescription.sdp=ht.getDescription(u._remoteDescription.sdp)+l.join(""),u.usingBundle));p++);else{var h=o.sdpMLineIndex;if(o.sdpMid){for(var E=0;E<u.transceivers.length;E++)if(u.transceivers[E].mid===o.sdpMid){h=E;break}}var M=u.transceivers[h];if(M){if(M.rejected)return f();var I=Object.keys(o.candidate).length>0?ht.parseCandidate(o.candidate):{};if(I.protocol==="tcp"&&(I.port===0||I.port===9)||I.component&&I.component!==1)return f();if((h===0||h>0&&M.iceTransport!==u.transceivers[0].iceTransport)&&!op(M.iceTransport,I))return d(Mr("OperationError","Can not add ICE candidate"));var x=o.candidate.trim();x.indexOf("a=")===0&&(x=x.substr(2)),l=ht.getMediaSections(u._remoteDescription.sdp),l[h]+="a="+(I.type?x:"end-of-candidates")+`\r
|
|
558
|
+
`,u._remoteDescription.sdp=ht.getDescription(u._remoteDescription.sdp)+l.join("")}else return d(Mr("OperationError","Can not add ICE candidate"))}else return d(Mr("InvalidStateError","Can not add ICE candidate without a remote description"));f()})},a.prototype.getStats=function(o){if(o&&o instanceof e.MediaStreamTrack){var u=null;if(this.transceivers.forEach(function(f){f.rtpSender&&f.rtpSender.track===o?u=f.rtpSender:f.rtpReceiver&&f.rtpReceiver.track===o&&(u=f.rtpReceiver)}),!u)throw Mr("InvalidAccessError","Invalid selector.");return u.getStats()}var l=[];return this.transceivers.forEach(function(f){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(d){f[d]&&l.push(f[d].getStats())})}),Promise.all(l).then(function(f){var d=new Map;return f.forEach(function(p){p.forEach(function(h){d.set(h.id,h)})}),d})};var s=["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"];s.forEach(function(o){var u=e[o];if(u&&u.prototype&&u.prototype.getStats){var l=u.prototype.getStats;u.prototype.getStats=function(){return l.apply(this).then(function(f){var d=new Map;return Object.keys(f).forEach(function(p){f[p].type=SJ(f[p]),d.set(p,f[p])}),d})}}});var c=["createOffer","createAnswer"];return c.forEach(function(o){var u=a.prototype[o];a.prototype[o]=function(){var l=arguments;return typeof l[0]=="function"||typeof l[1]=="function"?u.apply(this,[arguments[2]]).then(function(f){typeof l[0]=="function"&&l[0].apply(null,[f])},function(f){typeof l[1]=="function"&&l[1].apply(null,[f])}):u.apply(this,arguments)}}),c=["setLocalDescription","setRemoteDescription","addIceCandidate"],c.forEach(function(o){var u=a.prototype[o];a.prototype[o]=function(){var l=arguments;return typeof l[1]=="function"||typeof l[2]=="function"?u.apply(this,arguments).then(function(){typeof l[1]=="function"&&l[1].apply(null)},function(f){typeof l[2]=="function"&&l[2].apply(null,[f])}):u.apply(this,arguments)}}),["getStats"].forEach(function(o){var u=a.prototype[o];a.prototype[o]=function(){var l=arguments;return typeof l[1]=="function"?u.apply(this,arguments).then(function(){typeof l[1]=="function"&&l[1].apply(null)}):u.apply(this,arguments)}}),a};const CJ=Vh(TJ);function ER(e){const r=e&&e.navigator,t=function(i){return{name:{PermissionDeniedError:"NotAllowedError"}[i.name]||i.name,message:i.message,constraint:i.constraint,toString(){return this.name}}},n=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(i){return n(i).catch(a=>Promise.reject(t(a)))}}function kR(e){"getDisplayMedia"in e.navigator&&e.navigator.mediaDevices&&(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||(e.navigator.mediaDevices.getDisplayMedia=e.navigator.getDisplayMedia.bind(e.navigator)))}function $h(e,r){if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(i){return i}),e.RTCSessionDescription||(e.RTCSessionDescription=function(i){return i}),r.version<15025)){const n=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set(i){n.set.call(this,i);const a=new Event("enabled");a.enabled=i,this.dispatchEvent(a)}})}e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)&&Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=new e.RTCDtmfSender(this):this.track.kind==="video"&&(this._dtmf=null)),this._dtmf}}),e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);const t=CJ(e,r.version);e.RTCPeerConnection=function(i){return i&&i.iceServers&&(i.iceServers=_J(i.iceServers,r.version),Fm("ICE servers after filtering:",i.iceServers)),new t(i)},e.RTCPeerConnection.prototype=t.prototype}function RR(e){e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)&&(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}const QS=Object.freeze(Object.defineProperty({__proto__:null,shimGetDisplayMedia:kR,shimGetUserMedia:ER,shimPeerConnection:$h,shimReplaceTrack:RR},Symbol.toStringTag,{value:"Module"}));function $R(e,r){const t=e&&e.navigator,n=e&&e.MediaStreamTrack;if(t.getUserMedia=function(i,a,s){bf("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),t.mediaDevices.getUserMedia(i).then(a,s)},!(r.version>55&&"autoGainControl"in t.mediaDevices.getSupportedConstraints())){const i=function(s,c,o){c in s&&!(o in s)&&(s[o]=s[c],delete s[c])},a=t.mediaDevices.getUserMedia.bind(t.mediaDevices);if(t.mediaDevices.getUserMedia=function(s){return typeof s=="object"&&typeof s.audio=="object"&&(s=JSON.parse(JSON.stringify(s)),i(s.audio,"autoGainControl","mozAutoGainControl"),i(s.audio,"noiseSuppression","mozNoiseSuppression")),a(s)},n&&n.prototype.getSettings){const s=n.prototype.getSettings;n.prototype.getSettings=function(){const c=s.apply(this,arguments);return i(c,"mozAutoGainControl","autoGainControl"),i(c,"mozNoiseSuppression","noiseSuppression"),c}}if(n&&n.prototype.applyConstraints){const s=n.prototype.applyConstraints;n.prototype.applyConstraints=function(c){return this.kind==="audio"&&typeof c=="object"&&(c=JSON.parse(JSON.stringify(c)),i(c,"autoGainControl","mozAutoGainControl"),i(c,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[c])}}}}function EJ(e,r){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(n){if(!(n&&n.video)){const i=new DOMException("getDisplayMedia without video constraints is undefined");return i.name="NotFoundError",i.code=8,Promise.reject(i)}return n.video===!0?n.video={mediaSource:r}:n.video.mediaSource=r,e.navigator.mediaDevices.getUserMedia(n)})}function OR(e){typeof e=="object"&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Oh(e,r){if(typeof e!="object"||!(e.RTCPeerConnection||e.mozRTCPeerConnection))return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),r.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(i){const a=e.RTCPeerConnection.prototype[i],s={[i](){return arguments[0]=new(i==="addIceCandidate"?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),a.apply(this,arguments)}};e.RTCPeerConnection.prototype[i]=s[i]});const t={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[a,s,c]=arguments;return n.apply(this,[a||null]).then(o=>{if(r.version<53&&!s)try{o.forEach(u=>{u.type=t[u.type]||u.type})}catch(u){if(u.name!=="TypeError")throw u;o.forEach((l,f)=>{o.set(f,Object.assign({},l,{type:t[l.type]||l.type}))})}return o}).then(s,c)}}function IR(e){if(!(typeof e=="object"&&e.RTCPeerConnection&&e.RTCRtpSender)||e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const r=e.RTCPeerConnection.prototype.getSenders;r&&(e.RTCPeerConnection.prototype.getSenders=function(){const i=r.apply(this,[]);return i.forEach(a=>a._pc=this),i});const t=e.RTCPeerConnection.prototype.addTrack;t&&(e.RTCPeerConnection.prototype.addTrack=function(){const i=t.apply(this,arguments);return i._pc=this,i}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function PR(e){if(!(typeof e=="object"&&e.RTCPeerConnection&&e.RTCRtpSender)||e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const r=e.RTCPeerConnection.prototype.getReceivers;r&&(e.RTCPeerConnection.prototype.getReceivers=function(){const n=r.apply(this,[]);return n.forEach(i=>i._pc=this),n}),bo(e,"track",t=>(t.receiver._pc=t.srcElement,t)),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function AR(e){!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(t){bf("removeStream","removeTrack"),this.getSenders().forEach(n=>{n.track&&t.getTracks().includes(n.track)&&this.removeTrack(n)})})}function MR(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function xR(e){if(!(typeof e=="object"&&e.RTCPeerConnection))return;const r=e.RTCPeerConnection.prototype.addTransceiver;r&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const n=arguments[1],i=n&&"sendEncodings"in n;i&&n.sendEncodings.forEach(s=>{if("rid"in s&&!/^[a-z0-9]{0,16}$/i.test(s.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in s&&!(parseFloat(s.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in s&&!(parseFloat(s.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const a=r.apply(this,arguments);if(i){const{sender:s}=a,c=s.getParameters();(!("encodings"in c)||c.encodings.length===1&&Object.keys(c.encodings[0]).length===0)&&(c.encodings=n.sendEncodings,s.sendEncodings=n.sendEncodings,this.setParametersPromises.push(s.setParameters(c).then(()=>{delete s.sendEncodings}).catch(()=>{delete s.sendEncodings})))}return a})}function NR(e){if(!(typeof e=="object"&&e.RTCRtpSender))return;const r=e.RTCRtpSender.prototype.getParameters;r&&(e.RTCRtpSender.prototype.getParameters=function(){const n=r.apply(this,arguments);return"encodings"in n||(n.encodings=[].concat(this.sendEncodings||[{}])),n})}function LR(e){if(!(typeof e=="object"&&e.RTCPeerConnection))return;const r=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>r.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):r.apply(this,arguments)}}function DR(e){if(!(typeof e=="object"&&e.RTCPeerConnection))return;const r=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>r.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):r.apply(this,arguments)}}const ZS=Object.freeze(Object.defineProperty({__proto__:null,shimAddTransceiver:xR,shimCreateAnswer:DR,shimCreateOffer:LR,shimGetDisplayMedia:EJ,shimGetParameters:NR,shimGetUserMedia:$R,shimOnTrack:OR,shimPeerConnection:Oh,shimRTCDataChannel:MR,shimReceiverGetStats:PR,shimRemoveStream:AR,shimSenderGetStats:IR},Symbol.toStringTag,{value:"Module"}));function jR(e){if(!(typeof e!="object"||!e.RTCPeerConnection)){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(n){this._localStreams||(this._localStreams=[]),this._localStreams.includes(n)||this._localStreams.push(n),n.getAudioTracks().forEach(i=>r.call(this,i,n)),n.getVideoTracks().forEach(i=>r.call(this,i,n))},e.RTCPeerConnection.prototype.addTrack=function(n,...i){return i&&i.forEach(a=>{this._localStreams?this._localStreams.includes(a)||this._localStreams.push(a):this._localStreams=[a]}),r.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(t){this._localStreams||(this._localStreams=[]);const n=this._localStreams.indexOf(t);if(n===-1)return;this._localStreams.splice(n,1);const i=t.getTracks();this.getSenders().forEach(a=>{i.includes(a.track)&&this.removeTrack(a)})})}}function FR(e){if(!(typeof e!="object"||!e.RTCPeerConnection)&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(t){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=t),this.addEventListener("track",this._onaddstreampoly=n=>{n.streams.forEach(i=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(i))return;this._remoteStreams.push(i);const a=new Event("addstream");a.stream=i,this.dispatchEvent(a)})})}});const r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const n=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(i){i.streams.forEach(a=>{if(n._remoteStreams||(n._remoteStreams=[]),n._remoteStreams.indexOf(a)>=0)return;n._remoteStreams.push(a);const s=new Event("addstream");s.stream=a,n.dispatchEvent(s)})}),r.apply(n,arguments)}}}function UR(e){if(typeof e!="object"||!e.RTCPeerConnection)return;const r=e.RTCPeerConnection.prototype,t=r.createOffer,n=r.createAnswer,i=r.setLocalDescription,a=r.setRemoteDescription,s=r.addIceCandidate;r.createOffer=function(u,l){const f=arguments.length>=2?arguments[2]:arguments[0],d=t.apply(this,[f]);return l?(d.then(u,l),Promise.resolve()):d},r.createAnswer=function(u,l){const f=arguments.length>=2?arguments[2]:arguments[0],d=n.apply(this,[f]);return l?(d.then(u,l),Promise.resolve()):d};let c=function(o,u,l){const f=i.apply(this,[o]);return l?(f.then(u,l),Promise.resolve()):f};r.setLocalDescription=c,c=function(o,u,l){const f=a.apply(this,[o]);return l?(f.then(u,l),Promise.resolve()):f},r.setRemoteDescription=c,c=function(o,u,l){const f=s.apply(this,[o]);return l?(f.then(u,l),Promise.resolve()):f},r.addIceCandidate=c}function BR(e){const r=e&&e.navigator;if(r.mediaDevices&&r.mediaDevices.getUserMedia){const t=r.mediaDevices,n=t.getUserMedia.bind(t);r.mediaDevices.getUserMedia=i=>n(qR(i))}!r.getUserMedia&&r.mediaDevices&&r.mediaDevices.getUserMedia&&(r.getUserMedia=function(n,i,a){r.mediaDevices.getUserMedia(n).then(i,a)}.bind(r))}function qR(e){return e&&e.video!==void 0?Object.assign({},e,{video:pR(e.video)}):e}function GR(e){if(!e.RTCPeerConnection)return;const r=e.RTCPeerConnection;e.RTCPeerConnection=function(n,i){if(n&&n.iceServers){const a=[];for(let s=0;s<n.iceServers.length;s++){let c=n.iceServers[s];!c.hasOwnProperty("urls")&&c.hasOwnProperty("url")?(bf("RTCIceServer.url","RTCIceServer.urls"),c=JSON.parse(JSON.stringify(c)),c.urls=c.url,delete c.url,a.push(c)):a.push(n.iceServers[s])}n.iceServers=a}return new r(n,i)},e.RTCPeerConnection.prototype=r.prototype,"generateCertificate"in r&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get(){return r.generateCertificate}})}function zR(e){typeof e=="object"&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function WR(e){const r=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(n){if(n){typeof n.offerToReceiveAudio<"u"&&(n.offerToReceiveAudio=!!n.offerToReceiveAudio);const i=this.getTransceivers().find(s=>s.receiver.track.kind==="audio");n.offerToReceiveAudio===!1&&i?i.direction==="sendrecv"?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":i.direction==="recvonly"&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):n.offerToReceiveAudio===!0&&!i&&this.addTransceiver("audio"),typeof n.offerToReceiveVideo<"u"&&(n.offerToReceiveVideo=!!n.offerToReceiveVideo);const a=this.getTransceivers().find(s=>s.receiver.track.kind==="video");n.offerToReceiveVideo===!1&&a?a.direction==="sendrecv"?a.setDirection?a.setDirection("sendonly"):a.direction="sendonly":a.direction==="recvonly"&&(a.setDirection?a.setDirection("inactive"):a.direction="inactive"):n.offerToReceiveVideo===!0&&!a&&this.addTransceiver("video")}return r.apply(this,arguments)}}function VR(e){typeof e!="object"||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}const ew=Object.freeze(Object.defineProperty({__proto__:null,shimAudioContext:VR,shimCallbacksAPI:UR,shimConstraints:qR,shimCreateOfferLegacy:WR,shimGetUserMedia:BR,shimLocalStreamsAPI:jR,shimRTCIceServerUrls:GR,shimRemoteStreamsAPI:FR,shimTrackEventTransceiver:zR},Symbol.toStringTag,{value:"Module"}));function Kc(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const r=e.RTCIceCandidate;e.RTCIceCandidate=function(n){if(typeof n=="object"&&n.candidate&&n.candidate.indexOf("a=")===0&&(n=JSON.parse(JSON.stringify(n)),n.candidate=n.candidate.substr(2)),n.candidate&&n.candidate.length){const i=new r(n),a=Hc.parseCandidate(n.candidate),s=Object.assign(i,a);return s.toJSON=function(){return{candidate:s.candidate,sdpMid:s.sdpMid,sdpMLineIndex:s.sdpMLineIndex,usernameFragment:s.usernameFragment}},s}return new r(n)},e.RTCIceCandidate.prototype=r.prototype,bo(e,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t))}function zo(e,r){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp}});const t=function(c){if(!c||!c.sdp)return!1;const o=Hc.splitSections(c.sdp);return o.shift(),o.some(u=>{const l=Hc.parseMLine(u);return l&&l.kind==="application"&&l.protocol.indexOf("SCTP")!==-1})},n=function(c){const o=c.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(o===null||o.length<2)return-1;const u=parseInt(o[1],10);return u!==u?-1:u},i=function(c){let o=65536;return r.browser==="firefox"&&(r.version<57?c===-1?o=16384:o=2147483637:r.version<60?o=r.version===57?65535:65536:o=2147483637),o},a=function(c,o){let u=65536;r.browser==="firefox"&&r.version===57&&(u=65535);const l=Hc.matchPrefix(c.sdp,"a=max-message-size:");return l.length>0?u=parseInt(l[0].substr(19),10):r.browser==="firefox"&&o!==-1&&(u=2147483637),u},s=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,r.browser==="chrome"&&r.version>=76){const{sdpSemantics:o}=this.getConfiguration();o==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp},enumerable:!0,configurable:!0})}if(t(arguments[0])){const o=n(arguments[0]),u=i(o),l=a(arguments[0],o);let f;u===0&&l===0?f=Number.POSITIVE_INFINITY:u===0||l===0?f=Math.max(u,l):f=Math.min(u,l);const d={};Object.defineProperty(d,"maxMessageSize",{get(){return f}}),this._sctp=d}return s.apply(this,arguments)}}function Wo(e){if(!(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype))return;function r(n,i){const a=n.send;n.send=function(){const c=arguments[0],o=c.length||c.size||c.byteLength;if(n.readyState==="open"&&i.sctp&&o>i.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+i.sctp.maxMessageSize+" bytes)");return a.apply(n,arguments)}}const t=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const i=t.apply(this,arguments);return r(i,this),i},bo(e,"datachannel",n=>(r(n.channel,n.target),n))}function Ih(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const r=e.RTCPeerConnection.prototype;Object.defineProperty(r,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(r,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(t){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),t&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=t)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(t=>{const n=r[t];r[t]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=i=>{const a=i.target;if(a._lastConnectionState!==a.connectionState){a._lastConnectionState=a.connectionState;const s=new Event("connectionstatechange",i);a.dispatchEvent(s)}return i},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}})}function Ph(e,r){if(!e.RTCPeerConnection||r.browser==="chrome"&&r.version>=71||r.browser==="safari"&&r.version>=605)return;const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(i){if(i&&i.sdp&&i.sdp.indexOf(`
|
|
559
|
+
a=extmap-allow-mixed`)!==-1){const a=i.sdp.split(`
|
|
560
|
+
`).filter(s=>s.trim()!=="a=extmap-allow-mixed").join(`
|
|
561
|
+
`);e.RTCSessionDescription&&i instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:i.type,sdp:a}):i.sdp=a}return t.apply(this,arguments)}}function Jc(e,r){if(!(e.RTCPeerConnection&&e.RTCPeerConnection.prototype))return;const t=e.RTCPeerConnection.prototype.addIceCandidate;!t||t.length===0||(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(r.browser==="chrome"&&r.version<78||r.browser==="firefox"&&r.version<68||r.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():t.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}const kJ=Object.freeze(Object.defineProperty({__proto__:null,removeExtmapAllowMixed:Ph,shimAddIceCandidateNullOrEmpty:Jc,shimConnectionState:Ih,shimMaxMessageSize:zo,shimRTCIceCandidate:Kc,shimSendThrowTypeError:Wo},Symbol.toStringTag,{value:"Module"}));function RJ({window:e}={},r={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const t=Fm,n=yJ(e),i={browserDetails:n,commonShim:kJ,extractVersion:Go,disableLog:mJ,disableWarnings:gJ};switch(n.browser){case"chrome":if(!JS||!Rh||!r.shimChrome)return t("Chrome shim is not included in this adapter release."),i;if(n.version===null)return t("Chrome shim can not determine version, not shimming."),i;t("adapter.js shimming chrome."),i.browserShim=JS,Jc(e,n),hR(e,n),vR(e),Rh(e,n),mR(e),SR(e,n),gR(e),yR(e),bR(e),wR(e,n),Kc(e),Ih(e),zo(e,n),Wo(e),Ph(e,n);break;case"firefox":if(!ZS||!Oh||!r.shimFirefox)return t("Firefox shim is not included in this adapter release."),i;t("adapter.js shimming firefox."),i.browserShim=ZS,Jc(e,n),$R(e,n),Oh(e,n),OR(e),AR(e),IR(e),PR(e),MR(e),xR(e),NR(e),LR(e),DR(e),Kc(e),Ih(e),zo(e,n),Wo(e);break;case"edge":if(!QS||!$h||!r.shimEdge)return t("MS edge shim is not included in this adapter release."),i;t("adapter.js shimming edge."),i.browserShim=QS,ER(e),kR(e),$h(e,n),RR(e),zo(e,n),Wo(e);break;case"safari":if(!ew||!r.shimSafari)return t("Safari shim is not included in this adapter release."),i;t("adapter.js shimming safari."),i.browserShim=ew,Jc(e,n),GR(e),WR(e),UR(e),jR(e),FR(e),zR(e),BR(e),VR(e),Kc(e),zo(e,n),Wo(e),Ph(e,n);break;default:t("Unsupported browser!");break}return i}RJ({window:typeof window>"u"?void 0:window});var Ki={},HR={},KR={exports:{}},tw=KR.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return e.address!=null?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return e.subtype!=null?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return e.sessionConfig!=null?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var r="candidate:%s %d %s %d %s %d typ %s";return r+=e.raddr!=null?" raddr %s rport %d":"%v%v",r+=e.tcptype!=null?" tcptype %s":"%v",e.generation!=null&&(r+=" generation %d"),r+=e["network-id"]!=null?" network-id %d":"%v",r+=e["network-cost"]!=null?" network-cost %d":"%v",r}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var r="ssrc:%d";return e.attribute!=null&&(r+=" %s",e.value!=null&&(r+=":%s")),r}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return e.maxMessageSize!=null?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(e.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var r="mediaclk:";return r+=e.id!=null?"id=%s %s":"%v%s",r+=e.mediaClockValue!=null?"=%s":"",r+=e.rateNumerator!=null?" rate=%s":"",r+=e.rateDenominator!=null?"/%s":"",r}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(tw).forEach(function(e){var r=tw[e];r.forEach(function(t){t.reg||(t.reg=/(.*)/),t.format||(t.format="%s")})});var JR=KR.exports;(function(e){var r=function(c){return String(Number(c))===c?Number(c):c},t=function(c,o,u,l){if(l&&!u)o[l]=r(c[1]);else for(var f=0;f<u.length;f+=1)c[f+1]!=null&&(o[u[f]]=r(c[f+1]))},n=function(c,o,u){var l=c.name&&c.names;c.push&&!o[c.push]?o[c.push]=[]:l&&!o[c.name]&&(o[c.name]={});var f=c.push?{}:l?o[c.name]:o;t(u.match(c.reg),f,c.names,c.name),c.push&&o[c.push].push(f)},i=JR,a=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(c){var o={},u=[],l=o;return c.split(/(\r\n|\r|\n)/).filter(a).forEach(function(f){var d=f[0],p=f.slice(2);d==="m"&&(u.push({rtp:[],fmtp:[]}),l=u[u.length-1]);for(var h=0;h<(i[d]||[]).length;h+=1){var E=i[d][h];if(E.reg.test(p))return n(E,l,p)}}),o.media=u,o};var s=function(c,o){var u=o.split(/=(.+)/,2);return u.length===2?c[u[0]]=r(u[1]):u.length===1&&o.length>1&&(c[u[0]]=void 0),c};e.parseParams=function(c){return c.split(/;\s?/).reduce(s,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(c){return c.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(c){for(var o=[],u=c.split(" ").map(r),l=0;l<u.length;l+=3)o.push({component:u[l],ip:u[l+1],port:u[l+2]});return o},e.parseImageAttributes=function(c){return c.split(" ").map(function(o){return o.substring(1,o.length-1).split(",").reduce(s,{})})},e.parseSimulcastStreamList=function(c){return c.split(";").map(function(o){return o.split(",").map(function(u){var l,f=!1;return u[0]!=="~"?l=r(u):(l=r(u.substring(1,u.length)),f=!0),{scid:l,paused:f}})})}})(HR);var up=JR,$J=/%[sdv%]/g,OJ=function(e){var r=1,t=arguments,n=t.length;return e.replace($J,function(i){if(r>=n)return i;var a=t[r];switch(r+=1,i){case"%%":return"%";case"%s":return String(a);case"%d":return Number(a);case"%v":return""}})},Lo=function(e,r,t){var n=r.format instanceof Function?r.format(r.push?t:t[r.name]):r.format,i=[e+"="+n];if(r.names)for(var a=0;a<r.names.length;a+=1){var s=r.names[a];r.name?i.push(t[r.name][s]):i.push(t[r.names[a]])}else i.push(t[r.name]);return OJ.apply(null,i)},IJ=["v","o","s","i","u","e","p","c","b","t","r","z","a"],PJ=["i","c","b","a"],AJ=function(e,r){r=r||{},e.version==null&&(e.version=0),e.name==null&&(e.name=" "),e.media.forEach(function(a){a.payloads==null&&(a.payloads="")});var t=r.outerOrder||IJ,n=r.innerOrder||PJ,i=[];return t.forEach(function(a){up[a].forEach(function(s){s.name in e&&e[s.name]!=null?i.push(Lo(a,s,e)):s.push in e&&e[s.push]!=null&&e[s.push].forEach(function(c){i.push(Lo(a,s,c))})})}),e.media.forEach(function(a){i.push(Lo("m",up.m[0],a)),n.forEach(function(s){up[s].forEach(function(c){c.name in a&&a[c.name]!=null?i.push(Lo(s,c,a)):c.push in a&&a[c.push]!=null&&a[c.push].forEach(function(o){i.push(Lo(s,c,o))})})})}),i.join(`\r
|
|
562
|
+
`)+`\r
|
|
563
|
+
`},vs=HR,MJ=AJ;Ki.write=MJ;Ki.parse=vs.parse;Ki.parseParams=vs.parseParams;Ki.parseFmtpConfig=vs.parseFmtpConfig;Ki.parsePayloads=vs.parsePayloads;Ki.parseRemoteCandidates=vs.parseRemoteCandidates;Ki.parseImageAttributes=vs.parseImageAttributes;Ki.parseSimulcastStreamList=vs.parseSimulcastStreamList;var Ji={},xJ=ze&&ze.__spreadArrays||function(){for(var e=0,r=0,t=arguments.length;r<t;r++)e+=arguments[r].length;for(var n=Array(e),i=0,r=0;r<t;r++)for(var a=arguments[r],s=0,c=a.length;s<c;s++,i++)n[i]=a[s];return n};Object.defineProperty(Ji,"__esModule",{value:!0});var YR=function(){function e(r,t,n){this.name=r,this.version=t,this.os=n}return e}();Ji.BrowserInfo=YR;var XR=function(){function e(r){this.version=r,this.name="node",this.os=process.platform}return e}();Ji.NodeInfo=XR;var QR=function(){function e(){this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}();Ji.BotInfo=QR;var NJ=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,LJ=/(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp)|(MSNBot)|(Ask Jeeves\/Teoma)|(ia_archiver)/,rw=3,DJ=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["vivaldi",/Vivaldi\/([0-9\.]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/Edg\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FBAV\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["searchbot",NJ]],nw=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/],["Search Bot",LJ]];function jJ(e){return e?Ah(e):typeof navigator<"u"?Ah(navigator.userAgent):e1()}Ji.detect=jJ;function Ah(e){var r=e!==""&&DJ.reduce(function(a,s){var c=s[0],o=s[1];if(a)return a;var u=o.exec(e);return!!u&&[c,u]},!1);if(!r)return null;var t=r[0],n=r[1];if(t==="searchbot")return new QR;var i=n[1]&&n[1].split(/[._]/).slice(0,3);return i?i.length<rw&&(i=xJ(i,FJ(rw-i.length))):i=[],new YR(t,i.join("."),ZR(e))}Ji.parseUserAgent=Ah;function ZR(e){for(var r=0,t=nw.length;r<t;r++){var n=nw[r],i=n[0],a=n[1],s=a.test(e);if(s)return i}return null}Ji.detectOS=ZR;function e1(){var e=typeof process<"u"&&process.version;return e?new XR(process.version.slice(1)):null}Ji.getNodeVersion=e1;function FJ(e){for(var r=[],t=0;t<e;t++)r.push("0");return r}var Oc={exports:{}};function UJ(e,r){if(typeof e[Symbol.iterator]=="function")for(const t of e){const n=Array.isArray(t)?t[1]:t;r(n)}else for(const t in e)if(e.hasOwnProperty(t)){const n=e[t];r(n)}}var t1={iterateReports:UJ};const r1={"outbound-rtp":{packetsSent:"audioSentPackets",bytesSent:"audioSentBytes"},"inbound-rtp":{packetsReceived:"audioRecvPackets",packetsLost:"audioRecvPacketsLost",bytesReceived:"audioRecvBytes",jitter:"audioRecvJitter"},"remote-inbound-rtp":{packetsLost:"audioSentPacketsLost",roundTripTime:"audioRtt",jitter:"audioSentJitter"}},BJ={"remote-candidate":function(e){return Ic(e)},"inbound-rtp":function(e){return Ic(e)},"outbound-rtp":function(e){return Ic(e)},"remote-inbound-rtp":function(e){return Ic(e)}},Ic=e=>{const{type:r}=e,t=r1[r],n={};for(let i in t)if(i in e){let a;typeof t[i]=="function"?a=t[i](e):a=t[i],n[a]=e[i]}else n[t[i]]=null;return n};var qJ={rules:r1,parsers:BJ};const{iterateReports:GJ}=t1;function zJ(e){let r=0,t=0,n=0,i=100,a=0,s,c,o;return GJ(e,u=>{u.type==="inbound-rtp"&&(r=u.jitter,n=u.packetsLost,t=u.packetsReceived)}),t+n>0&&(a=100*(n/(t+n))),s=i+r*2+10,s<160?c=93.2-s/40:c=93.2-(s-120)/10,c=c-a*2.5,c<1&&(c=1),o=1+.035*c+7e-6*c*(c-60)*(100-c),parseFloat(o).toFixed(6)}var n1=zJ;const{iterateReports:WJ}=t1,{parsers:iw}=qJ,VJ=n1;function HJ(e){const r={};return WJ(e,t=>{if(t.type in iw){const n=iw[t.type](t);Object.assign(r,n)}}),r.networkMos=parseFloat(VJ(e)),r}var KJ=HJ,aw;function JJ(){return aw||(aw=1,function(e,r){var t=ze&&ze.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(r,"__esModule",{value:!0});const n=KJ,i=n1,a=t(pi());class s{constructor(o){this.mos_report={min:5,max:0},this._reportsCount=0,this._mosSum=0,this.intervals=[],this._deprecationWarningSent=!1,!(!o||!o.application||!o.rtc_id||!o.pc)&&(this.conversation=null,this.application_id=null,this.attachHandlers(o),this.startSendingStats(o),this.startEmittingStats(o))}attachHandlers(o){const{pc:u}=o,l=u.onconnectionstatechange?u.onconnectionstatechange:()=>{};u.onconnectionstatechange=f=>{switch(l.call(u,f),u.connectionState){case"disconnected":case"failed":case"closed":this.removeIntervals(),this.emitLastReport(o)}},o.conversation?o.conversation.on("member:media",(d,p)=>{!this.application_id&&(o==null?void 0:o.rtc_id)===p.body.channel.id&&(this.application_id=p.application_id)}):o.application.on("member:joined",(d,p)=>{(!this.conversation||!this.application_id)&&(o==null?void 0:o.rtc_id)===p.body.channel.id&&(this.conversation=d.conversation,this.application_id=p.application_id)})}emitLastReport(o){const{application:u,conversation:l=null,rtc_id:f,config:{emit_events:d,emit_rtc_analytics:p}}=o,h=this.getMOSReport(),E=h.last;E&&(p&&u.emit("rtcstats:analytics",{type:"mos_report",mos:E,rtc_id:f,mos_report:h,api_key:u.session.apiKey,...this.application_id&&{application_id:this.application_id},...l&&{conversation_id:l.id,conversation_name:l.name}}),d&&(this._deprecationWarningSent||(this._deprecationWarningSent=!0,console.warn('"rtcstats:report" event is deprecated. Use "rtcstats:analytics" instead')),u.emit("rtcstats:report",E,null,l,h)))}startSendingStats(o){const{application:u,conversation:l=null,pc:f,rtc_id:d,config:{remote_collection:p,remote_collection_url:h,remote_collection_interval:E}}=o;if(!p)return;const M=setInterval(()=>{f.getStats(null).then(I=>{var x;const j=(x=l??this.conversation)!==null&&x!==void 0?x:null;a.default.networkRequest({url:h,type:"POST",data:{...n(I),legId:d,apiKey:u.session.apiKey,...this.application_id&&{applicationId:this.application_id},...j&&{conversationId:j.id,conversationName:j.name}}}).catch(()=>{})}).catch(()=>{}),(f.connectionState==="closed"||f.signalingState==="closed")&&this.removeIntervals()},E);this.intervals.push(M)}startEmittingStats(o){const{application:u,conversation:l=null,pc:f,rtc_id:d,config:{emit_events:p,emit_rtc_analytics:h,emit_interval:E}}=o;if(!p&&!h)return;const M=setInterval(()=>{var I;f.getStats(null).then(x=>{var j;const z=this.getMos(x);if(!z)return;const ie=(j=l??this.conversation)!==null&&j!==void 0?j:null;h&&u.emit("rtcstats:analytics",{type:"mos",mos:z,report:x,rtc_id:d,api_key:u.session.apiKey,...this.application_id&&{application_id:this.application_id},...ie&&{conversation_id:ie.id,conversation_name:ie.name}}),p&&(this._deprecationWarningSent||(this._deprecationWarningSent=!0,console.warn('"rtcstats:report" event is deprecated. Use "rtcstats:analytics" instead')),u.emit("rtcstats:report",z,x,l))}).catch(()=>{}),(f.connectionState==="closed"||f.signalingState==="closed")&&(this.removeIntervals(),this.emitLastReport({...o,conversation:(I=l??this.conversation)!==null&&I!==void 0?I:null}))},E);this.intervals.push(M)}removeIntervals(){this.intervals.forEach(o=>clearInterval(o)),this.intervals=[]}getMos(o){const u=i(o);return this.updateMOSReport(parseInt(u)),u}updateMOSReport(o){this._reportsCount++,this._mosSum+=o,this.mos_report.last=o,this.mos_report.min=o<this.mos_report.min?o:this.mos_report.min,this.mos_report.max=o>this.mos_report.max?o:this.mos_report.max,this.mos_report.average=this._mosSum/this._reportsCount}getMOSReport(){return this.mos_report.min=s.normaliseFloat(this.mos_report.min),this.mos_report.max=s.normaliseFloat(this.mos_report.max),this.mos_report.last=s.normaliseFloat(this.mos_report.last),this.mos_report.average=s.normaliseFloat(this.mos_report.average),this.mos_report}static normaliseFloat(o){return parseFloat(o).toFixed(6)}}r.default=s,e.exports=s}(Oc,Oc.exports)),Oc.exports}var sw;function _f(){return sw||(sw=1,function(e,r){var t=ze&&ze.__createBinding||(Object.create?function(p,h,E,M){M===void 0&&(M=E),Object.defineProperty(p,M,{enumerable:!0,get:function(){return h[E]}})}:function(p,h,E,M){M===void 0&&(M=E),p[M]=h[E]}),n=ze&&ze.__setModuleDefault||(Object.create?function(p,h){Object.defineProperty(p,"default",{enumerable:!0,value:h})}:function(p,h){p.default=h}),i=ze&&ze.__importStar||function(p){if(p&&p.__esModule)return p;var h={};if(p!=null)for(var E in p)E!=="default"&&Object.hasOwnProperty.call(p,E)&&t(h,p,E);return n(h,p),h},a=ze&&ze.__importDefault||function(p){return p&&p.__esModule?p:{default:p}};Object.defineProperty(r,"__esModule",{value:!0});const s=Ki,c=pr,o=i(Ji),u=In,l=a(JJ()),f=2e4;class d{constructor(){this.log=c.getLogger(this.constructor.name)}static getUserAudio(h=!0){let E={video:!1,audio:h};return navigator.mediaDevices.getUserMedia(E)}createRTCPeerConnection(h){const E=new RTCPeerConnection(h);return E.trace=()=>{},E}_getWindowLocationProtocol(){return window.location.protocol}static _getBrowserName(){return o.detect().name}static isNode(){return this._getBrowserName()==="node"}checkValidKeys(h,E){let M=!0;return Object.keys(h).forEach(I=>{E.hasOwnProperty(I)||(M=!1)}),M}static cleanCallMediaIfFailed(h){setTimeout(()=>{h.conversation||(this.cleanMediaProperties(h),h.status=h.CALL_STATUS.FAILED,h.application.emit("call:status:changed",h))},5e3)}static callDisconnectHandler(h,E){const M=[h.CALL_STATUS.ANSWERED,h.CALL_STATUS.STARTED,h.CALL_STATUS.RINGING];if(!(E.connectionState!=="disconnected"||!h||!h.conversation))return setTimeout(()=>{E.connectionState==="connected"||M.indexOf(h.status)==-1||(this.cleanMediaProperties(h),h.status=h.CALL_STATUS.COMPLETED,h.application.emit("call:status:changed",h))},f)}static cleanMediaProperties(h){if(h.rtcObjects)for(const E in h.rtcObjects)h.rtcObjects[E].pc.close(),delete h.rtcObjects[E].pc,d.closeStream(h.rtcObjects[E].stream);h.application.activeStreams=[],h.rtcObjects={},h.conversation&&h.conversation.media&&(h.conversation.media.rtcStats=null)}static playAudioStream(h){const E=new Audio;return E.srcObject=h,E.autoplay=!0,E}static createDummyCandidateSDP(h){const E={foundation:1176891032,component:1,transport:"udp",priority:2122260223,ip:"0.0.0.0",port:9,type:"host",generation:0,"network-id":1,"network-cost":50},M=s.parse(h.localDescription.sdp);return M.media[0].candidates=[E],s.write(M)}static createRTCPeerConnectionConfig(h){return{iceTransportPolicy:"all",bundlePolicy:"balanced",rtcpMuxPolicy:"require",iceCandidatePoolSize:"0",...h.session.config&&h.session.config.iceServers&&{iceServers:h.session.config.iceServers}}}static createPeerConnection(h){const E=this.createRTCPeerConnectionConfig(h);return new RTCPeerConnection(E)}static sendOffer(h,E,M,I){const j={sdp:this.createDummyCandidateSDP(E)};let z={from:M.me.id,body:{offer:j}},ie=`conversations/${M.id}/rtc`;return I&&(ie+=`/${I}/offer`),h.session.sendNetworkRequest({type:"POST",path:ie,data:z})}static sendAnswer(h,E,M,I){const x=this.createDummyCandidateSDP(E);let j={from:M.me.id,body:{answer:x}},z=`conversations/${M.id}/rtc/${I}/answer`;return h.session.sendNetworkRequest({type:"POST",path:z,data:j})}static createLeg(h,E){const I={sdp:this.createDummyCandidateSDP(E),type:"offer"};return h.session.sendNetworkRequest({type:"POST",path:"legs",version:"beta",data:{body:{offer:I}}})}static closeStream(h){h.getTracks().forEach(E=>{E.stop()})}static emitMediaStream(h,E,M){h.emit("media:stream:on",{pc:E,stream:M,type:"audio",streamIndex:0})}static _initStatsEvents(h){var E,M,I;if(!d.isNode()&&!((I=(M=(E=h==null?void 0:h.application)===null||E===void 0?void 0:E.session)===null||M===void 0?void 0:M.config)===null||I===void 0)&&I.rtcstats){const x=h.application.session.config.rtcstats,{emit_events:j,remote_collection:z,emit_rtc_analytics:ie}=x;if(j||z||ie){const oe={...h,config:{...x}};return new l.default(oe)}}}static attachConversationEventHandlers(h){const{conversation:E,pc:M,log:I}=h;E.once("rtc:answer",x=>{if(!M){I.warn("RTC: received an answer too late");return}M.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:x.body.answer}))})}static doAnswer(h,E,M){const{application:I,conversation:x,pc:j,reject:z,localStream:ie}=h;this.addPeerConnectionListeners(h,()=>d.sendAnswer(I,j,x,M).then(()=>({rtc_id:M}))),j.setRemoteDescription(new RTCSessionDescription({type:"offer",sdp:E})).then(()=>j.createAnswer()).then(oe=>j.setLocalDescription(oe)).catch(oe=>{ie&&this.closeStream(ie),z(oe)})}static attachPeerConnectionEventHandlers(h){const{application:E,conversation:M,pc:I,reconnectRtcId:x}=h;this.addPeerConnectionListeners(h,()=>d.sendOffer(E,I,M,x))}static addPeerConnectionListeners(h,E){const{application:M,conversation:I,pc:x,streamIndex:j,localStream:z,log:ie,rtcObjects:oe,resolve:J,reject:L}=h;let Y,Z=!1,ye;I.id&&(ye=M.calls.get(I.id)),x.ontrack=Re=>{Y=Re.streams[0],M.activeStreams.push(Y),d.emitMediaStream(I.me,x,Y)},x.onconnectionstatechange=Re=>this.onconnectionstatechangeHandler(x,ie,ye,()=>J(Y),()=>L()),x.onnegotiationneeded=()=>this.onnegotiationneededHandler(x,Re=>L(Re)),x.oniceconnectionstatechange=Re=>this.oniceconnectionstatechange(Re,x,ie,ae=>L(ae)),x.onicecandidate=async Re=>{if(Re.candidate&&!Z&&x){Z=!0;try{const{rtc_id:ae}=await E();d._initStatsEvents({application:M,rtc_id:ae,pc:x,conversation:I}),x.trace&&x.trace("rtc_id",ae),oe[ae]={rtc_id:ae,pc:x,stream:z,type:"audio",streamIndex:j}}catch(ae){z&&this.closeStream(z),L(new u.NexmoClientError(ae))}}},z.getTracks().forEach(Re=>x.addTrack(Re))}static prewarmLeg(h){const E=h.application;return new Promise(async(M,I)=>{let x=!1,j,z,ie={};const oe=c.getLogger(this.constructor.name);try{let J=await this.getUserAudio();const L=this.createPeerConnection(E);L.ontrack=Y=>{j=Y.streams[0],E.activeStreams.push(j)},L.onconnectionstatechange=Y=>this.onconnectionstatechangeHandler(L,oe,h,()=>M({stream:j,legId:z,rtcObjects:ie}),()=>I()),L.onnegotiationneeded=()=>this.onnegotiationneededHandler(L,Y=>I(Y)),L.oniceconnectionstatechange=Y=>this.oniceconnectionstatechange(Y,L,oe,Z=>I(Z)),L.onicecandidate=async Y=>{if(Y.candidate&&!x&&L){x=!0;const{rtc_id:Z,sdp:ye}=await this.createLeg(E,L);return d._initStatsEvents({application:E,rtc_id:Z,pc:L}),z=Z,ie[z]={rtc_id:Z,pc:L,stream:J,type:"audio",streamIndex:1},L.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:ye}))}},J.getTracks().forEach(Y=>L.addTrack(Y))}catch(J){I(new u.NexmoClientError(J))}})}}r.default=d,d.onconnectionstatechangeHandler=(p,h,E,M,I)=>{switch(p.connectionState){case"connected":h.info("The connection has become fully connected"),M();break;case"disconnected":if(!E)break;E.call_disconnect_timeout&&clearTimeout(E.call_disconnect_timeout),E.call_disconnect_timeout=d.callDisconnectHandler(E,p);break;case"failed":I(),h.info("One or more transports has terminated unexpectedly or in an error");break;case"closed":h.info("The connection has been closed");break}},d.oniceconnectionstatechange=(p,h,E,M)=>{switch(h.iceConnectionState){case"disconnected":E.warn("One or more transports is disconnected",h.iceConnectionState);break;case"failed":M(new u.NexmoClientError(p)),E.warn("One or more transports has terminated unexpectedly or in an error",p);break;default:E.info("The ice connection status changed",h.iceConnectionState)}},d.onnegotiationneededHandler=async(p,h)=>{try{const E=await p.createOffer();return p.setLocalDescription(E)}catch(E){h(new u.NexmoClientError(E))}},e.exports=d}(Rc,Rc.exports)),Rc.exports}var ow;function YJ(){return ow||(ow=1,function(e,r){var t=ze&&ze.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(r,"__esModule",{value:!0});const n=pr,i=In,a=t(_f()),s=t(pi()),c=t(Hi),o=t(s1()),u=t(wf());class l{constructor(d){var p,h,E;const M=d instanceof o.default?d:null,I=d instanceof u.default?d:null;this.log=n.getLogger(this.constructor.name),M?(this.rtcHelper=new a.default,this.application=M.application,this.application.activeStreams=this.application.activeStreams||[],this.parentConversation=M,this.rtcObjects={},this.streamIndex=0,this.rtcstats_conf=((E=(h=(p=this.application)===null||p===void 0?void 0:p.session)===null||h===void 0?void 0:h.config)===null||E===void 0?void 0:E.rtcStats)||{},this.rtcStats=null):I?(this.rtcHelper=new a.default,this.application=I):this.log.warn("No conversation object in Media")}_attachEndingEventHandlers(){this.parentConversation&&(this.log.debug("attaching leave listeners in media for "+this.parentConversation.id),this.parentConversation.on("rtc:hangup",async d=>{let p;if(this.parentConversation.members.has(d.from))p=this.parentConversation.members.get(d.from);else try{p=await this.parentConversation.getMember(d.from)}catch(h){this.log.warn(`There is an error getting the member ${h}`)}p.user.id===this.application.me.id&&this.application.activeStreams.length&&this._cleanMediaProperties(),p.user.id===this.application.me.id&&p.transferred_from&&p.transferred_from.media._cleanMediaProperties(),p.user.id===this.application.me.id&&this.parentConversation.off("rtc:hangup")}))}_enableStatsEvents(){this.rtcstats_conf.emit_rtc_analytics=!0,this.rtcstats_conf.remote_collection=!0;const d=this._findRtcObjectByType("audio");!this.rtcStats&&d&&(this.log.debug(`enabling stats events for ${d.rtc_id}`),this.rtcStats=a.default._initStatsEvents({application:this.application,rtc_id:d.rtc_id,pc:this.pc,conversation:this.parentConversation}))}_disableStatsEvents(){this.rtcstats_conf.emit_events=!1,this.rtcstats_conf.emit_rtc_analytics=!1,this.rtcstats_conf.remote_collection=!1,this.rtcStats.removeIntervals(),delete this.rtcStats}_audioInitHandler(d={},p){return new Promise(async(h,E)=>{const M=this.streamIndex;this.streamIndex++;const{audioConstraints:I}=d;try{const x=await a.default.getUserAudio(I),j=a.default.createPeerConnection(this.application);this.pc=j;const{application:z,log:ie,parentConversation:oe,rtcObjects:J}=this,L={pc:j,streamIndex:M,localStream:x,application:z,conversation:oe,log:ie,rtcObjects:J};p({...L,resolve:h,reject:E}),a.default.attachConversationEventHandlers(L),this._attachEndingEventHandlers()}catch(x){E(new i.NexmoClientError(x))}})}_execAnswer(d={}){const{offer:{sdp:p,leg_id:h}}=d;return this._audioInitHandler(d,E=>a.default.doAnswer(E,p,h))}_handleAudio(d={}){const{reconnectRtcId:p}=d;return this._audioInitHandler(d,h=>a.default.attachPeerConnectionEventHandlers({...h,reconnectRtcId:p}))}_findRtcObjectByType(d){return Object.values(this.rtcObjects).find(p=>p.type===d)}async _cleanConversationProperties(){this.pc&&this.pc.close(),delete this.pc,this.rtcStats=null,this.application.activeStreams=[],this.listeningToRtcEvent=!1,await Promise.resolve()}_cleanMediaProperties(){if(this.pc&&this.pc.close(),this.rtcObjects)for(const d in this.rtcObjects)a.default.closeStream(this.rtcObjects[d].stream);delete this.pc,this.rtcStats=null,this.application.activeStreams=[],this.rtcObjects={},this.listeningToRtcEvent=!1}async _disableLeg(d){const p=new Promise(async(E,M)=>{try{await this.application.session.sendNetworkRequest({type:"DELETE",path:`conversations/${this.parentConversation.id}/rtc/${d}?from=${this.parentConversation.me.id}&originating_session=${this.application.session.session_id}`,version:"beta2"}),E("rtc:terminate:success")}catch(I){M(new i.NexmoApiError(I))}}),h=new Promise(E=>{this.rtcObjects[d].pc&&this.rtcObjects[d].pc.close(),this.rtcObjects[d].stream&&a.default.closeStream(this.rtcObjects[d].stream),E()});try{return await Promise.all([p,h]),this.parentConversation.me.emit("media:stream:off",this.rtcObjects[d].streamIndex),delete this.rtcObjects[d],"rtc:terminate:success"}catch(E){throw E}}_enableMediaTracks(d,p){d.forEach(h=>{h.enabled=p})}async _setMediaTracksAndMute(d,p,h,E){this._enableMediaTracks(p,!h);try{return await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.parentConversation.id}/events`,data:{type:E,to:this.parentConversation.me.id,from:this.parentConversation.me.id,body:{rtc_id:d}}})}catch(M){throw this._enableMediaTracks(p,h),new i.NexmoApiError(M)}}async updateAudioConstraints(d={}){let p=this._findRtcObjectByType("audio");if(p&&p.pc)try{const h=await a.default.getUserAudio(d);return h.getTracks().forEach(E=>{const M=p.pc.getSenders().find(I=>I.track.kind===E.kind);M&&(E.enabled=M.track.enabled,M.replaceTrack(E))}),a.default.closeStream(p.stream),p.stream=h,h}catch(h){return h}else throw new i.NexmoApiError("error:media:stream:not-found")}mute(d=!1,p=null){const E="audio:mute:"+(d?"on":"off");let M=[],I={};if(p!==null){if(I[0]=Object.values(this.rtcObjects).find(x=>x.streamIndex===p),!I[0])throw new i.NexmoClientError("error:media:stream:not-found")}else I=this.rtcObjects;return Object.values(I).forEach(x=>{const j=x.stream.getAudioTracks(),z=this._setMediaTracksAndMute(x.rtc_id,j,d,E);M.push(z)}),Promise.all(M)}async earmuff(d){try{if(this.me===null)throw new i.NexmoClientError("error:self");{let p="audio:earmuff:off";d&&(p="audio:earmuff:on");const{response:h}=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.parentConversation.id}/events`,data:{type:p,to:this.parentConversation.me.id}});return h}}catch(p){throw new i.NexmoApiError(p)}}async enable(d){try{if(this.parentConversation.me===null)throw new i.NexmoClientError("error:self");{const{offer:p}=d??{};let h=await(p!==void 0?this._execAnswer(d):this._handleAudio(d)),E=d&&(d.autoPlayAudio||d.autoPlayAudio===void 0);return(!d||E)&&a.default.playAudioStream(h),h}}catch(p){throw p}}disable(){let d=[];d.push(this._cleanConversationProperties());for(const p in this.rtcObjects)d.push(this._disableLeg(p));return Promise.all(d)}async sayText(d){try{const p=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.parentConversation.id}/events`,data:{type:"audio:say",cid:this.parentConversation.id,from:this.parentConversation.me.id,body:{text:d.text,voice_name:d.voice_name||"Amy",level:d.level||1,queue:d.queue||!0,loop:d.loop||1,ssml:d.ssml||!1}}});return new c.default(this.parentConversation,p)}catch(p){throw new i.NexmoApiError(p)}}async sendDTMF(d){try{if(!s.default.validateDTMF(d))throw new i.NexmoClientError("error:audio:dtmf:invalid-digit");if(!(this._findRtcObjectByType("audio")||{}).rtc_id)throw new i.NexmoClientError("error:audio:dtmf:audio-disabled");const{id:h,timestamp:E}=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.parentConversation.id}/events`,data:{type:"audio:dtmf",from:this.parentConversation.me.id,body:{digit:d,channel:{type:"app",id:this._findRtcObjectByType("audio").rtc_id}}}}),M={body:{digit:d,dtmf_id:""},cid:this.parentConversation.id,from:this.parentConversation.me.id,id:h,timestamp:E,type:"audio:dtmf"},I=new c.default(this.parentConversation,M);return this.parentConversation.events.set(M.id,I),I}catch(p){throw new i.NexmoApiError(p)}}async playStream(d){try{const p=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.parentConversation.id}/events`,data:{type:"audio:play",body:d}});return new c.default(this.parentConversation,p)}catch(p){throw new i.NexmoApiError(p)}}async startRinging(){try{const d=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.parentConversation.id}/events`,data:{type:"audio:ringing:start",from:this.parentConversation.me.id,body:{}}});return new c.default(this.parentConversation,d)}catch(d){throw new i.NexmoApiError(d)}}async stopRinging(){try{const d=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.parentConversation.id}/events`,data:{type:"audio:ringing:stop",from:this.parentConversation.me.id,body:{}}});return new c.default(this.parentConversation,d)}catch(d){throw new i.NexmoApiError(d)}}}r.default=l,e.exports=l}(kc,kc.exports)),kc.exports}var Pc={exports:{}},Ac={exports:{}},uw;function i1(){return uw||(uw=1,function(e,r){var t=ze&&ze.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(pi()),i=pr,a=t(Hi);class s extends a.default{constructor(o,u){super(o,u),this.log=i.getLogger(this.constructor.name),this.type="image",this.conversation=o,this.state={seen_by:{},delivered_to:{}},u&&u.body&&u.body.timestamp&&(this.timestamp=u.body.timestamp),Object.assign(this,u)}seen(){return super.seen()}delivered(){return super.delivered()}async del(){return await n.default.networkRequest({type:"DELETE",url:this.body.representations.original.url,token:this.conversation.application.session.config.token}),super.del()}async fetchImage(o="thumbnail",u=this.body.representations){try{return n.default._fetchImage(u[o].url,this.conversation.application.session.config.token)}catch(l){throw this.log.error(l),l}}}r.default=s,e.exports=s}(Ac,Ac.exports)),Ac.exports}var cw;function XJ(){return cw||(cw=1,function(e,r){var t=ze&&ze.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(r,"__esModule",{value:!0});const n=pr,i=t(Hi),a=t(Dm),s=t(i1()),c=t(jm());class o{constructor(l,f){this.log=n.getLogger(this.constructor.name),this.application=l,this.conversation=f,this.constructed_event=null,this._handleEventMap={"event:delete":this._processDelete,image:this._processImage,"image:delivered":this._processDelivered,"image:seen":this._processSeen,"member:invited":this._processMember,"member:joined":this._processMember,"member:left":this._processMember,"audio:ringing:start":this._processMember,"leg:status:update":this._processLegStatus,"member:media":this._processMedia,text:this._processText,"text:delivered":this._processDelivered,"text:seen":this._processSeen,"audio:mute:on":this._processMuteForMedia,"audio:mute:off":this._processMuteForMedia,message:this._processMessage,"message:delivered":this._processDelivered,"message:seen":this._processSeen,"message:submitted":this._processSubmitted,"message:rejected":this._processRejected,"message:undeliverable":this._processUndeliverable}}handleEvent(l){return this._handleEventMap.hasOwnProperty(l.type)?this._handleEventMap[l.type].call(this,l)||new i.default(this.conversation,l):new i.default(this.conversation,l)}_processDelivered(l){let f=this.conversation.events.get(l.body.event_id);return f?(f.state=f.state||{},f.state.delivered_to=f.state.delivered_to||{},f.state.delivered_to[l.from]=l.timestamp,f):(this.log.warn("NXMEvent not found"),null)}_processDelete(l){var f;let d=this.conversation.events.get((f=l==null?void 0:l.body)===null||f===void 0?void 0:f.event_id);return d?(d.body.text&&(d.body.text=""),d.body.representations&&(d.body.representations=""),d.body.timestamp={deleted:l.timestamp},d):(this.log.warn("NXMEvent not found"),null)}_processImage(l){var f;const d=new s.default(this.conversation,l);return((f=this.conversation.me)===null||f===void 0?void 0:f.id)!==d.from&&d.delivered(),d}_processMember(l){return this.application.calls.has(this.conversation.id)&&this.application.calls.get(this.conversation.id)._handleStatusChange(l),this.conversation.members.has(l.from)&&this.conversation.members.get(l.from)._handleEvent(l),new i.default(this.conversation,l)}_processLegStatus(l){return this.conversation.members.has(l.from)&&this.conversation.members.get(l.from)._handleEvent(l),new i.default(this.conversation,l)}_processMedia(l){return this.conversation.members.has(l.from)&&this.conversation.members.get(l.from)._handleEvent(l),null}_processMuteForMedia(l){return this.conversation.media.rtcObjects[l.body.rtc_id]?l.streamIndex=this.conversation.media.rtcObjects[l.body.rtc_id].streamIndex:this.log.warn("No audio stream was found"),null}_processSeen(l){let f=this.conversation.events.get(l.body.event_id);return f?(f.state=f.state||{},f.state.seen_by=f.state.seen_by||{},f.state.seen_by[l.from]=l.timestamp,f):(this.log.warn("NXMEvent not found"),null)}_processText(l){var f,d;const p=new a.default(this.conversation,l);return((d=(f=this.conversation)===null||f===void 0?void 0:f.me)===null||d===void 0?void 0:d.id)!==p.from&&p.delivered(),p}_processMessage(l){var f,d;const p=new c.default(this.conversation,l);return((d=(f=this.conversation)===null||f===void 0?void 0:f.me)===null||d===void 0?void 0:d.id)!==p.from&&p.delivered(),p}_processSubmitted(l){let f=this.conversation.events.get(l.body.event_id);return f?(f.state=f.state||{},f.state.submitted_to=f.state.submitted_to||{},f.state.submitted_to[l.from]=l.timestamp,f):(this.log.warn("NXMEvent not found"),null)}_processRejected(l){let f=this.conversation.events.get(l.body.event_id);return f?(f.state=f.state||{},f.state.rejected_by=f.state.rejected_by||{},f.state.rejected_by[l.from]=l.timestamp,f):(this.log.warn("NXMEvent not found"),null)}_processUndeliverable(l){let f=this.conversation.events.get(l.body.event_id);return f?(f.state=f.state||{},f.state.undeliverable_to=f.state.undeliverable_to||{},f.state.undeliverable_to[l.from]=l.timestamp,f):(this.log.warn("NXMEvent not found"),null)}}r.default=o,e.exports=o}(Pc,Pc.exports)),Pc.exports}var Mh={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});class t{constructor(i={}){this.page_size=i.page_size||10,this.order=i.order||"asc",this.cursor=i.cursor||"",this.state=i.state||"",i.event_type&&(this.event_type=i.event_type)}}r.default=t,e.exports=t})(Mh,Mh.exports);var a1=Mh.exports,Mc={exports:{}},xh={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});const t=In;class n{constructor(a={}){this.page_size=a.page_size,this.order=a.order,this.cursor=a.cursor,this.application=a.application,a.event_type&&a.event_type.length>0&&(this.event_type=a.event_type)}hasPrev(){return this.cursor.prev?this.cursor.prev.length>0:!1}hasNext(){return this.cursor.next?this.cursor.next.length>0:!1}_getConfig(a){return{page_size:this.page_size,order:this.order,cursor:a,...this.event_type&&{event_type:this.event_type}}}_getError(){return Promise.reject(new t.NexmoClientError("error:invalid-cursor"))}}r.default=n,e.exports=n})(xh,xh.exports);var Sf=xh.exports,lw;function QJ(){return lw||(lw=1,function(e,r){var t=ze&&ze.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(Sf),i=t(Hi),a=t(Dm),s=t(i1()),c=t(jm());class o extends n.default{constructor(l){super(l),this.items=new Map,this.conversation=l.conversation,l.items.forEach(f=>{switch(f.type){case"text":this.items.set(f.id,new a.default(this.conversation,f));break;case"image":this.items.set(f.id,new s.default(this.conversation,f));break;case"message":this.items.set(f.id,new c.default(this.conversation,f));break;default:this.items.set(f.id,new i.default(this.conversation,f));break}}),this.conversation.events=new Map([...this.conversation.events,...this.items])}getPrev(){return this.hasPrev()?this.conversation.getEvents(this._getConfig(this.cursor.prev)):this._getError()}getNext(){return this.hasNext()?this.conversation.getEvents(this._getConfig(this.cursor.next)):this._getError()}}r.default=o,e.exports=o}(Mc,Mc.exports)),Mc.exports}var xc={exports:{}},fw;function ZJ(){return fw||(fw=1,function(e,r){var t=ze&&ze.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(Sf),i=t(Lm());class a extends n.default{constructor(c){super(c),this.conversation=c.conversation,this.items=new Map,c.items.forEach(o=>{this.items.set(o.id,new i.default(this.conversation,o))})}getPrev(){return this.hasPrev()?this.conversation.getMembers(this._getConfig(this.cursor.prev)):this._getError()}getNext(){return this.hasNext()?this.conversation.getMembers(this._getConfig(this.cursor.next)):this._getError()}}r.default=a,e.exports=a}(xc,xc.exports)),xc.exports}var dw;function s1(){return dw||(dw=1,function(e,r){var t=ze&&ze.__importDefault||function(x){return x&&x.__esModule?x:{default:x}};Object.defineProperty(r,"__esModule",{value:!0});const n=Ra,i=pr,a=In,s=t(Lm()),c=t(Hi),o=t(Dm),u=t(jm()),l=t(YJ()),f=t(XJ()),d=t(pi()),p=t(a1),h=t(QJ()),E=t(ZJ()),M=t(wf());class I{constructor(j,z){this.log=i.getLogger(this.constructor.name),this.application=j,this.id=null,this.name=null,this.display_name=null,this.timestamp=null,this.members=new Map,this.events=new Map,this.sequence_number=0,this.pageConfig=new p.default(((this.application.session||{}).config||{}).events_page_config),this.events_page_last=null,this.members_page_last=null,this.conversationEventHandler=new f.default(j,this),this.media=new l.default(this),this.me=null,this._updateObjectInstance(z),n.mixin(I)}_updateObjectInstance(j){for(let z in j)switch(z){case"id":this.id=j.id;break;case"name":this.name=j.name;break;case"display_name":this.display_name=j.display_name;break;case"members":j.members.forEach(oe=>{if(this.members.has(oe.member_id))this.members.get(oe.member_id)._normalise(oe),oe.user_id===this.application.me.id&&oe.state!=="LEFT"&&(this.me=this.members.get(oe.member_id),this.members.set(this.me.id,this.me));else{const J=new s.default(this,oe);oe.user_id===this.application.me.id&&oe.state!=="LEFT"&&(this.me=J),this.members.set(J.id,J)}});break;case"timestamp":this.timestamp=j.timestamp;break;case"sequence_number":this.sequence_number=j.sequence_number;break;case"member_id":const ie={id:j.member_id,state:j.state,user:this.application.me};if(this.members.has(j.member_id)){const oe=this.members.get(j.member_id);Object.assign(oe,ie)}else{const oe=new s.default(this,ie);this.me=oe,this.members.set(oe.id,oe)}break}}async join(j){var z,ie;try{let oe={state:"joined",channel:{type:"app"},user:{...!j&&{name:this.application.me.name,id:this.application.me.id},...j&&j.user_name&&{name:j.user_name},...j&&j.user_id&&{id:j.user_id}}};!((z=this===null||this===void 0?void 0:this.me)===null||z===void 0)&&z.id&&((ie=this===null||this===void 0?void 0:this.me)===null||ie===void 0?void 0:ie.state)!=="LEFT"&&(oe.from=this.me.id);const J=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/members`,version:"v0.3",data:oe}),L=new s.default(this,J);return J._embedded.user.id===this.application.me.id&&(this.me=L,this.members.set(L.id,L)),this.application.getConversation(this.id,M.default.CONVERSATION_API_VERSION.v3),L}catch(oe){throw new a.NexmoApiError(oe)}}async del(){try{const j=await this.application.session.sendNetworkRequest({type:"DELETE",path:`conversations/${this.id}`});return this.application.conversations.delete(this.id),j}catch(j){throw new a.NexmoApiError(j)}}deleteEvent(j){return j.del()}async invite(j){var z,ie;if(!j||!j.id&&!j.user_name)throw new a.NexmoClientError("error:invite:missing:params");const oe={state:"invited",user:{...j.id&&{id:j.id},...j.user_name&&{name:j.user_name}},media:j.media,channel:{from:{type:"app"},to:{type:"app"},type:"app"}};!((z=this===null||this===void 0?void 0:this.me)===null||z===void 0)&&z.id&&((ie=this===null||this===void 0?void 0:this.me)===null||ie===void 0?void 0:ie.state)!=="LEFT"&&(oe.from=this.me.id);try{const J=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/members`,version:"v0.3",data:oe});return new s.default(this,J)}catch(J){throw new a.NexmoApiError(J)}}inviteWithAudio(j){return!j||!j.id&&!j.user_name?Promise.reject(new a.NexmoClientError("error:invite:missing:params")):(j.media={audio_settings:{enabled:!0,muted:!1,earmuffed:!1}},this.invite(j))}leave(j){return this.me.kick(j)}async sendText(j){try{if(this.me===null)throw new a.NexmoClientError("error:self");const z={type:"text",cid:this.id,from:this.me.id,body:{text:j}},{id:ie,timestamp:oe}=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:z});return z.id=ie,z.body.timestamp=oe,new o.default(this,z)}catch(z){throw new a.NexmoApiError(z)}}async sendCustomEvent({type:j,body:z}){try{if(this.me===null)throw new a.NexmoClientError("error:self");if(!j||typeof j!="string"||j.length<1)throw new a.NexmoClientError("error:custom-event:invalid");const ie={type:`custom:${j}`,cid:this.id,from:this.me.id,body:z},{id:oe,timestamp:J}=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:ie});return ie.id=oe,ie.timestamp=J,new c.default(this,ie)}catch(ie){throw new a.NexmoApiError(ie)}}async uploadImage(j,z={quality_ratio:"100",medium_size_ratio:"50",thumbnail_size_ratio:"30"}){const ie=new FormData;ie.append("file",j),ie.append("quality_ratio",z.quality_ratio),ie.append("medium_size_ratio",z.medium_size_ratio),ie.append("thumbnail_size_ratio",z.thumbnail_size_ratio);const oe=await d.default.networkRequest({type:"POST",url:this.application.session.config.ips_url,data:ie,token:this.application.session.config.token});return oe.upload.addEventListener("progress",J=>{J.lengthComputable&&this.log.debug("uploading image "+J.loaded+"/"+J.total)},!1),oe.onreadystatechange=()=>{oe.status!==200&&this.log.error(oe)},oe}async sendImage(j,z={quality_ratio:"100",medium_size_ratio:"50",thumbnail_size_ratio:"30"}){const ie=await this.uploadImage(j,z);return ie.onreadystatechange=()=>{if(ie.readyState===4&&ie.status===200)try{this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:{type:"image",from:this.me.id,body:{representations:JSON.parse(ie.responseText)}}}),this.log.info(ie)}catch(oe){this.log.error(new a.NexmoApiError(oe))}},ie}abortSendImage(j){return j instanceof XMLHttpRequest?j.abort():new a.NexmoClientError("error:invalid:param:type")}async sendMessage(j){if(this.me===null)throw new a.NexmoClientError("error:self");if(!(j!=null&&j.message_type))throw new a.NexmoClientError("error:message-event:invalid");try{const z={type:"message",cid:this.id,from:this.me.id,body:{...j}},{id:ie,timestamp:oe}=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:z});return z.id=ie,z.body.timestamp=oe,new u.default(this,z)}catch(z){throw new a.NexmoApiError(z)}}async _typing(j){const z={activity:j==="on"?1:0},ie={type:"text:typing:"+j,cid:this.id,from:this.me.id,body:z};try{return await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:ie}),`text:typing:${j}:success`}catch(oe){throw new a.NexmoApiError(oe)}}startTyping(){return this._typing("on")}stopTyping(){return this._typing("off")}async getEvents(j={}){const z=`${this.application.session.config.nexmo_api_url}/beta2/conversations/${this.id}/events`;let ie=Object.keys(j).length===0?this.pageConfig:new p.default(j);try{const oe=await d.default.paginationRequest(z,ie,this.application.session.config.token);oe.application=this.application,oe.conversation=this;const J=new h.default(oe);return this.events_page_last=J,J}catch(oe){throw new a.NexmoApiError(oe)}}async getMembers(j={}){const z=`${this.application.session.config.nexmo_api_url}/beta2/conversations/${this.id}/members`;let ie=Object.keys(j).length===0?this.pageConfig:new p.default(j);try{const oe=await d.default.paginationRequest(z,ie,this.application.session.config.token);oe.application=this.application,oe.conversation=this;const J=new E.default(oe);return this.members_page_last=J,J}catch(oe){throw new a.NexmoApiError(oe)}}async getMyMember(){try{const j=await this.application.session.sendNetworkRequest({type:"GET",path:`conversations/${this.id}/members/me`,version:"v0.3"});return new s.default(this,j)}catch(j){throw new a.NexmoApiError(j)}}async getMember(j){try{const z=await this.application.session.sendNetworkRequest({type:"GET",path:`conversations/${this.id}/members/${j}`,version:"v0.3"});return new s.default(this,z)}catch(z){throw new a.NexmoApiError(z)}}_handleEvent(j){var z,ie;if(j.type.startsWith("rtc"))return this.emit(j.type,j),Promise.resolve(j);this.sequence_number++,j.body&&j.body.event_id&&typeof j.body.event_id=="string"&&(j.body.event_id=parseInt(j.body.event_id));let oe={memberId:j.from};if(!((z=j==null?void 0:j.body)===null||z===void 0)&&z.user){const{id:L,name:Y,display_name:Z,image_url:ye,custom_data:Re}=j.body.user;oe={...oe,...L&&{userId:L},...Y&&{userName:Y},...Z&&{displayName:Z},...ye&&{imageUrl:ye},...Re&&{customData:Re}}}else if(!((ie=j==null?void 0:j._embedded)===null||ie===void 0)&&ie.from_user){const{id:L,name:Y,display_name:Z,image_url:ye,custom_data:Re}=j._embedded.from_user;oe={...oe,...L&&{userId:L},...Y&&{userName:Y},...Z&&{displayName:Z},...ye&&{imageUrl:ye},...Re&&{customData:Re}}}let J=this.conversationEventHandler.handleEvent(j);return["text:typing:on","text:typing:off"].includes(j.type)||this.events.set(J.id,J),j.type.startsWith("custom:")?(this.emit(J.type,oe,J),Promise.resolve(j)):(this.emit(j.type,oe,J),Promise.resolve(j))}}r.default=I,e.exports=I}(Tc,Tc.exports)),Tc.exports}var Nc={exports:{}},pw;function o1(){return pw||(pw=1,function(e,r){var t=ze&&ze.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(r,"__esModule",{value:!0});const n=Ra,i=pr,a=In,s=t(_f());class c{constructor(u,l,f){this.application=u,this.log=i.getLogger(this.constructor.name),this.from=f,this.conversation=null,this.rtcObjects={},this.CALL_STATUS={STARTED:"started",RINGING:"ringing",ANSWERED:"answered",COMPLETED:"completed",BUSY:"busy",TIMEOUT:"timeout",UNANSWERED:"unanswered",REJECTED:"rejected",FAILED:"failed"},this.CALL_DIRECTION={INBOUND:"inbound",OUTBOUND:"outbound"},Object.freeze(this.CALL_DIRECTION),this.STATUS_PERMITTED_FLOW=new Map([["STARTED",new Set([this.CALL_STATUS.RINGING,this.CALL_STATUS.ANSWERED,this.CALL_STATUS.FAILED,this.CALL_STATUS.TIMEOUT,this.CALL_STATUS.UNANSWERED,this.CALL_STATUS.REJECTED,this.CALL_STATUS.BUSY])],["RINGING",new Set([this.CALL_STATUS.ANSWERED,this.CALL_STATUS.FAILED,this.CALL_STATUS.TIMEOUT,this.CALL_STATUS.UNANSWERED,this.CALL_STATUS.REJECTED,this.CALL_STATUS.BUSY])],["ANSWERED",new Set([this.CALL_STATUS.COMPLETED,this.CALL_STATUS.FAILED])]]),Object.freeze(this.STATUS_PERMITTED_FLOW),this.status=null,this.call_disconnect_timeout=null,this.direction=this.CALL_DIRECTION.INBOUND,this._setupConversationObject(l),n.mixin(c)}_enableStatsEvents(){this.conversation.media._enableStatsEvents()}_attachCallListeners(){this.log.debug("_attachCallListeners : ",{nxmCall:this});try{this.conversation.releaseGroup("call_module"),this.conversation.on("member:media","call_module",(u,l)=>{this.application.calls&&this.application.calls.has(this.conversation.id)&&this.application.calls.get(this.conversation.id)._handleStatusChange(l)})}catch(u){this.log.error("_attachCallListeners_error: ",{e:u})}}_isValidStatusTransition(u){if(!u)throw new a.NexmoClientError(`Provide the status to validate the transition from '${this.status}'`);if(!this.status)return!0;const l=this.status.toUpperCase();return!this.STATUS_PERMITTED_FLOW.has(l)||this.status===u?!1:this.STATUS_PERMITTED_FLOW.get(l).has(u)}hangUpIfAllLeft(){if(this.log.debug("hangUpIfAllLeft: ",{nxmCall:this}),!this.conversation.me||this.conversation.me.state==="LEFT"||this.conversation.members.size<=1)return Promise.resolve();for(let u of this.conversation.members.values())if(u.state!=="LEFT"&&this.conversation.me.user.id!==u.user.id)return Promise.resolve();return this.hangUp()}_setupConversationObject(u,l){u&&(this.conversation=u,u.me?(this.to=new Map(u.members),this.from&&this.to.delete(this.from.id)):this.log.warn("missing own member object"),this._attachCallListeners())}_setFrom(u){this.from=u}_setOffer(u){this.offer=u}_handleStatusChange(u){var l;const f=this.conversation?((l=this.conversation.me)===null||l===void 0?void 0:l.id)===u.from:!0,d=this.direction===this.CALL_DIRECTION.OUTBOUND;this.log.debug("_handleStatusChange: ",{event:u},`_isEventFromMe: ${f} _isOutbound: ${d}`);let p=new Map;if(p.set("member:joined",async()=>{if(u.body.channel&&u.body.channel.id)try{this._setStatusAndEmit(this.CALL_STATUS.STARTED);return}catch(h){throw this._setStatusAndEmit(this.CALL_STATUS.FAILED),this.log.error(h),h}return Promise.resolve()}),p.set("member:invited",()=>(u.body.invited_by===null&&u.body.user.media&&u.body.user.media.audio_settings&&this._setStatusAndEmit(this.CALL_STATUS.STARTED),Promise.resolve())),p.set("rtc:hangup",()=>this.status===this.CALL_STATUS.ANSWERED?(this._setStatusAndEmit(this.CALL_STATUS.COMPLETED),Promise.resolve()):f&&d||!f&&!d?(this._setStatusAndEmit(this.CALL_STATUS.UNANSWERED),Promise.resolve()):(this._setStatusAndEmit(this.CALL_STATUS.REJECTED),Promise.resolve())),p.set("member:left",()=>{if(!u.body.timestamp.hasOwnProperty("joined")&&this.status!==this.CALL_STATUS.ANSWERED)return f&&d||!f&&!d?(this._setStatusAndEmit(this.CALL_STATUS.UNANSWERED),Promise.resolve()):(this._setStatusAndEmit(this.CALL_STATUS.REJECTED),Promise.resolve())}),p.set("member:media",()=>(this.status!==this.CALL_STATUS.ANSWERED&&u.body.audio&&(f&&u.body.channel&&(this.id=u.body.channel.id),(!f||!d)&&this.id&&this._setStatusAndEmit(this.CALL_STATUS.ANSWERED)),Promise.resolve())),p.set("sip:ringing",()=>(this.status!==this.CALL_STATUS.RINGING&&this._setStatusAndEmit(this.CALL_STATUS.RINGING),Promise.resolve())),p.set("sip:hangup",()=>{switch(u.body.reason.sip_code){case 486:this._setStatusAndEmit(this.CALL_STATUS.BUSY);break;case 487:this._setStatusAndEmit(this.CALL_STATUS.TIMEOUT);break;case 403:this._setStatusAndEmit(this.CALL_STATUS.FAILED);break}return Promise.resolve()}),p.set("knocking:delete:success",()=>(this._setStatusAndEmit(this.CALL_STATUS.UNANSWERED),Promise.resolve())),p.has(u.type))return p.get(u.type).call(this)}_setStatusAndEmit(u){this._isValidStatusTransition(u)&&(this.status=u,this.log.debug(`_setStatusAndEmit: ${u}`,{nxmCall:this}),this.application.emit("call:status:changed",this))}async answer(u=!0){if(this.log.debug(`answer: { autoPlayAudio: ${u}`),this.conversation)try{await this.conversation.join();const l=await this.conversation.media.enable({autoPlayAudio:u,offer:this.offer});return this.offer=void 0,l}catch(l){throw this._setStatusAndEmit(this.CALL_STATUS.FAILED),this.log.error(l),l}else throw new a.NexmoClientError("error:call:answer")}async createCall(u,l=!0){if(this.log.debug(`createCall: { usernames: ${u}, autoPlayAudio: ${l} }`),!u||!Array.isArray(u)||u.length===0)return Promise.reject(new a.NexmoClientError("error:application:call:params"));try{const f=await this.application.newConversationAndJoin({display_name:"CALL_"+this.application.me.name+"_"+u.join("_").replace(" ","")});f.members.set(f.me.id,f.me),this.from=f.me,this.successful_invited_members=new Map;const d=u.map(async h=>{try{const E=await f.inviteWithAudio({user_name:h});return f.members.set(E.id,E),this.successful_invited_members.set(E.id,E),E}catch(E){return this.log.error(E),E}}),p=async()=>{if(this.successful_invited_members.size>0)return await f.media.enable({audio:{muted:!1,earmuffed:!1},autoPlayAudio:l}),this.application.calls.set(f.id,this),d;throw d};return await Promise.all(d),this._setupConversationObject(f),await p()}catch(f){throw this.log.error(f),this._setStatusAndEmit(this.CALL_STATUS.FAILED),f}}async createServerCall(u,l,f){this.log.debug(`createServerCall: { user: ${u}, type: ${l}, custom_data: `,{custom_data:f});const d={type:l};l==="phone"?d.number=u:d.user=u;try{const{stream:p,legId:h,rtcObjects:E}=await s.default.prewarmLeg(this);this.log.debug("createServerCall: ",{stream:p},{legId:h},{rtcObjects:E}),this.rtcObjects=E,this.stream=p,this.id=h,this.application._call_draft_list.set(h,this),s.default.playAudioStream(p);const M={type:"POST",path:"knocking",data:{channel:{type:"app",from:{type:"app"},to:d,id:h||null},...f&&Object.keys(f).length&&{properties:{custom_data:f}}}};try{const I=await this.application.session.sendNetworkRequest(M);this.knocking_id=I.id}catch(I){throw new a.NexmoApiError(I)}return s.default.cleanCallMediaIfFailed(this),p}catch(p){throw s.default.cleanMediaProperties(this),p}}async hangUp(u){if(this.log.debug(`hangUp: { reason: ${u} }`),this.conversation&&await this.conversation.media.disable(),!this.knocking_id&&this.conversation)return this.conversation.leave(u).catch(l=>{if(l.type!=="conversation:error:invalid-member-state")return Promise.reject(l)});{let l=`knocking/${this.knocking_id}`;if(u){let f=new URLSearchParams;Object.keys(u).forEach(d=>{f.append(d,u[d])}),l+=`?${f.toString()}`}try{const f=await this.application.session.sendNetworkRequest({type:"DELETE",path:l});return this.application._call_draft_list.get(this.client_ref)._handleStatusChange(f),this.application._call_draft_list.delete(this.client_ref),f}catch(f){if(this.conversation)return this.log.error(new a.NexmoApiError(f)),this.conversation.leave(u).catch(d=>{if(d.type!=="conversation:error:invalid-member-state")return Promise.reject(d)});this.log.debug("hangup: Problem cancelling the call. Knocking cancel failed and Conversation. Leave not available",f);return}}}reject(u){return this.log.debug(`reject: { reason: ${u} }`),this.conversation?this.conversation.leave(u):Promise.reject(new a.NexmoClientError("error:call:reject"))}}r.default=c,e.exports=c}(Nc,Nc.exports)),Nc.exports}var Nh={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});const t=pr;class n{constructor(a){this.log=t.getLogger(this.constructor.name),this.application=a,this._handleSipCallEventMap={"sip:hangup":this._processSipHangup,"sip:ringing":this._processSipRinging}}_handleSipCallEvent(a){if(this.log.debug("_handleSipCallEvent: ",{event:a}),!this.application.calls.has(a.cid)){this.log.warn("There is no call object for this Conversation id.");return}const s=this.application.calls.get(a.cid);if(this._handleSipCallEventMap.hasOwnProperty(a.type))return this._handleSipCallEventMap[a.type].call(this,s,a)}_processSipHangup(a,s){this.log.debug("_processSipHangup: ",s),a._handleStatusChange(s)}_processSipRinging(a,s){this.log.debug("_processSipRinging: ",s),a._handleStatusChange(s)}}r.default=n,e.exports=n})(Nh,Nh.exports);var eY=Nh.exports,Lh={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});const t=pr;class n{constructor(a){this.log=t.getLogger(this.constructor.name),this.application=a,this._handleRtcEventMap={"rtc:transfer":this._processRtcTransfer,"rtc:answer":this._processRtcAnswer,"rtc:hangup":this._processRtcHangup}}_handleRtcEvent(a){if(this._handleRtcEventMap.hasOwnProperty(a.type))return this._handleRtcEventMap[a.type].call(this,a)}_processRtcTransfer(a){this.log.debug("_processRtcTransfer: ",{event:a});const s=this.application.conversations.get(a.body.transferred_from),c=this.application.conversations.get(a.cid),o=this.application.calls.get(a.body.transferred_from);if(!o){this.log.warn("NXMCall transfer for unknown nxmCall");return}o.conversation.members.get(a.body.was_member).transferred_to=c,o._setupConversationObject(c),o.transferred=!0,this.application.calls.set(a.cid,o),this.application.calls.delete(a.body.transferred_from),s&&(c.members.get(a.from).transferred_from=s,c.media._attachEndingEventHandlers(),Object.entries(c.media.rtcObjects).length===0&&Object.entries(s.media.rtcObjects).length!==0&&Object.assign(c.media.rtcObjects,s.media.rtcObjects),!c.media.pc&&s.media.pc&&Object.assign(c.media.pc=s.media.pc),c.application.activeStreams.length===0&&s.application.activeStreams.length>0&&(c.application.activeStreams=s.application.activeStreams))}_processRtcAnswer(a){this.log.debug("_processRtcAnswer: ",{event:a}),this.application.calls.has(a.cid)&&(this.application.calls.get(a.cid).id=a.body.rtc_id)}_processRtcHangup(a){this.log.debug("_processRtcHangup: ",{event:a}),this.application.calls.has(a.cid)&&this.application.calls.get(a.cid)._handleStatusChange(a)}}r.default=n,e.exports=n})(Lh,Lh.exports);var tY=Lh.exports,Lc={exports:{}},hw;function rY(){return hw||(hw=1,function(e,r){var t=ze&&ze.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(r,"__esModule",{value:!0});const n=pr,i=t(Hi),a=t(o1()),s=t(pi()),c=t(_f());class o{constructor(l){this.log=n.getLogger(this.constructor.name),this.application=l,this._handleApplicationEventMap={"member:joined":this._processMemberJoined,"member:invited":this._processMemberInvited}}handleEvent(l){const f=this.application.conversations.get(l.cid),d=Object.assign({},l);return this._handleApplicationEventMap.hasOwnProperty(l.type)?this._handleApplicationEventMap[l.type].call(this,f,new i.default(f,d),l):new i.default(f,d)}_processMemberJoined(l,f,d){try{if(f.body.channel&&this.application._call_draft_list.has(f.body.channel.id)){this.log.debug("_processMemberJoined: outbound serverCall from sdk",{event:f});const p=this.application._call_draft_list.get(f.body.channel.id);let h=((p.rtcObjects||{})[f.body.channel.id]||{}).pc;if(p._setFrom(l.me),p._setupConversationObject(l,f.body.channel.id),l.media._attachEndingEventHandlers(),Object.entries(l.media.rtcObjects).length===0&&Object.entries(p.rtcObjects).length!==0&&Object.assign(l.media.rtcObjects,p.rtcObjects),!l.media.pc&&h&&Object.assign(l.media.pc=h),l.application.activeStreams.length===0&&p.application.activeStreams.length>0&&(l.application.activeStreams=p.application.activeStreams),delete p.client_ref,delete p.knocking_id,p.rtcStats&&(l.media.rtcStats=p.rtcStats),this.application._call_draft_list.delete(f.body.channel.id),this.application.calls.set(l.id,p),p._handleStatusChange(f),this.log.debug("_processMemberJoined: processedCall ",{nxmCall:p}),l.members&&f.body.member_id){const E=l.members.get(f.body.member_id);E&&this.application.emit("member:call",E,p)}setTimeout(()=>{l!=null&&l.me&&c.default.emitMediaStream(l.me,h,p.stream)},200)}return this.log.debug("_processMemberJoined: default member joined: ",{event:f}),f}catch(p){this.log.error("_processMemberJoined: ",{e:p})}}_processMemberInvited(l,f){var d,p,h,E,M,I;try{if(!l)return this.log.warn(`no conversation object for ${f.type}`),f;if(((d=l.me)===null||d===void 0?void 0:d.user.id)===f.body.invited_by||!(!((h=(p=f.body.user.media)===null||p===void 0?void 0:p.audio_settings)===null||h===void 0)&&h.enabled))return f;const x=s.default.getMemberNumberFromEventOrNull(f.body.channel)||s.default.getMemberFromNameOrNull(l,f.body.invited_by)||"unknown",j=new a.default(this.application,l,x);return this.application.calls.set(l.id,j),!((E=f.body)===null||E===void 0)&&E.sdp&&this.application.session.config.enableInboundOffer&&j._setOffer({sdp:f.body.sdp,leg_id:f.body.channel.id}),!((M=l.display_name)===null||M===void 0)&&M.startsWith("CALL_")||j._handleStatusChange(f),this.application.emit("member:call",this.application.conversations.get(f.cid).members.get((I=f.body)===null||I===void 0?void 0:I.member_id),j),f}catch(x){this.log.error("_processMemberInvited: ",{e:x})}}}r.default=o,e.exports=o}(Lc,Lc.exports)),Lc.exports}var Dh={exports:{}};(function(e,r){var t=ze&&ze.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(Sf);class i extends n.default{constructor(s){super(s),this.items=new Map,s.items.forEach(c=>{const o=this.application.updateOrCreateConversation(c);this.items.set(o.id,o)})}getPrev(){return this.hasPrev()?this.application.getConversations(this._getConfig(this.cursor.prev)):this._getError()}getNext(){return this.hasNext()?this.application.getConversations(this._getConfig(this.cursor.next)):this._getError()}}r.default=i,e.exports=i})(Dh,Dh.exports);var nY=Dh.exports,jh={exports:{}},Fh={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});const t=Ra;class n{constructor(a,s){var c,o;this.application=a,this.id=(c=s==null?void 0:s.id)!==null&&c!==void 0?c:null,this._embedded=(o=s==null?void 0:s._embedded)!==null&&o!==void 0?o:null,t.mixin(n)}}r.default=n,e.exports=n})(Fh,Fh.exports);var iY=Fh.exports;(function(e,r){var t=ze&&ze.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(Sf),i=t(iY);class a extends n.default{constructor(c){super(c),this.items=new Map,c.items.forEach(o=>{this.items.set(o.id,new i.default(this.application,o))})}getPrev(){return this.hasPrev()?this.application.getUserSessions(this._getConfig(this.cursor.prev)):this._getError()}getNext(){return this.hasNext()?this.application.getUserSessions(this._getConfig(this.cursor.next)):this._getError()}}r.default=a,e.exports=a})(jh,jh.exports);var aY=jh.exports,Dc={exports:{}},vw;function sY(){return vw||(vw=1,function(e,r){var t=ze&&ze.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(r,"__esModule",{value:!0}),r.ConversationEventsProcessor=r.EventsQueue=void 0;const n=In,i=t(pi()),a=pr;class s{constructor(u){this.callback=u,this.cidMap=new Map,this.log=a.getLogger(this.constructor.name)}async enqueue(u,l){var f,d,p,h;const{cid:E,id:M}=u,I=Number(M);if(!E||isNaN(I))return this.callback(u);if(!this.cidMap.get(E)){this.log.debug(`enqueue: create new ConversationEventsProcessor for ${E}`);const j=new c(E,I-1,l);if(this.cidMap.set(E,j),u.type=="member:media"&&(!((d=(f=u.body)===null||f===void 0?void 0:f.media)===null||d===void 0)&&d.audio)||u.type=="member:joined"&&(!((h=(p=u.body)===null||p===void 0?void 0:p.channel)===null||h===void 0)&&h.id)){const z=I-20<1?1:I-20,ie=await j.fetchConversationEvents(z,20);let oe=!1;ie.forEach(J=>{J.type==="rtc:transfer"&&J.from===u.from&&(oe=!0,j.lastEventIdProcessed=Number(J.id)-1),oe&&j.enqueue(Number(J.id),J)})}}const x=this.cidMap.get(E);x.enqueue(I,u),x.processing||(x.processing=!0,await x.processEvents())}}r.EventsQueue=s;class c{constructor(u,l,f){this.cid=u,this.eventsMap=new Map,this.callback=d=>f._handleEvent(d),this.lastEventIdProcessed=l,this.largestEventIdInQueue=l,this.processing=!1,this.application=f,this.eventsFetchRange=9,this.log=a.getLogger(this.constructor.name)}enqueue(u,l){return u>this.largestEventIdInQueue&&(this.largestEventIdInQueue=u),u>this.lastEventIdProcessed&&this.eventsMap.set(u,l),l}dequeue(u){const l=this.eventsMap.get(u);return this.eventsMap.delete(u),l}async processEvents(){const u=()=>(this.eventsMap.clear(),this.log.debug("processEvents: Done Processing"),this.processing=!1);if(this.eventsMap.size<1)return u();const l=this.lastEventIdProcessed+1,f=await this.processNextEvent(l);return f?(this.lastEventIdProcessed=Number(f.id),this.processEvents()):u()}async processNextEvent(u){this.log.debug(`processNextEvent: processing event number ${u}`);const l=this.dequeue(u);try{if(l)return await this.callback(l),l;if(this.largestEventIdInQueue>u){this.log.debug(`processNextEvent: largestEventIdInQueue-${this.largestEventIdInQueue} > eventId-${u}`);const f=await this.fetchEventsAndProcess(u);return f?(this.log.debug("processNextEvent: foundEvent ",{foundEvent:f}),await this.callback(f),f):(this.log.debug(`processNextEvent: not found process next ${u+1}`),this.processNextEvent(u+1))}return}catch{return}}async fetchEventsAndProcess(u){try{const l=await this.fetchConversationEvents(u,this.eventsFetchRange);this.log.debug("fetchEventsAndProcess: fetched events list ",{eventsList:l});let f;return l.forEach(d=>{d.cid=this.cid;const p=Number(d.id);isNaN(p)||p<u||(p>u?(this.log.debug(`fetchEventsAndProcess: event > missingEvent ${p} `,{missingEvent:u}),this.enqueue(p,d)):(this.log.debug("fetchEventsAndProcess: foundEvent ",{event:d}),f=d))}),f}catch(l){this.log.debug("fetchEventsAndProcess: error ",{e:l});return}}async fetchConversationEvents(u,l){this.log.debug("fetchConversationEvents: ",this.cid,u);const f=this.largestEventIdInQueue>u?this.largestEventIdInQueue+l:u+l,d=`${this.application.session.config.nexmo_api_url}/beta2/conversations/${this.cid}/events`;try{return(await i.default.paginationRequest(d,{start_id:u,end_id:f},this.application.session.config.token)).items}catch(p){throw new n.NexmoApiError(p)}}}r.ConversationEventsProcessor=c,e.exports={EventsQueue:s,ConversationEventsProcessor:c}}(Dc,Dc.exports)),Dc.exports}var mw;function wf(){return mw||(mw=1,function(e,r){var t=ze&&ze.__importDefault||function(oe){return oe&&oe.__esModule?oe:{default:oe}};Object.defineProperty(r,"__esModule",{value:!0});const n=Ra,i=pr,a=In,s=t(lR),c=t(s1()),o=t(o1()),u=t(eY),l=t(tY),f=t(rY()),d=t(pi()),p=t(a1),h=t(nY),E=t(aY),M=sY(),I=t(Lm());let x=null,j=null,z=null;class ie{constructor(J,L){this.log=i.getLogger(this.constructor.name),this.session=J,this.conversations=new Map,this.synced_conversations_count=0,this.start_sync_time=0,this.stop_sync_time=0,this.calls=new Map,this._call_draft_list=new Map,this.pageConfig=new p.default((J.config||{}).conversations_page_config),this.conversations_page_last=null,this.activeStreams=[],x=new u.default(this),j=new l.default(this),z=new f.default(this),this.me=null,Object.assign(this,L),n.mixin(ie)}updateOrCreateConversation(J){const L=this.conversations.get(J.id);return L?(L._updateObjectInstance(J),this.conversations.set(J.id,L)):this.conversations.set(J.id,new c.default(this,J)),this.conversations.get(J.id)}async _enqueueEvent(J){this.session.config.enableEventsQueue?(this.eventsQueue||(this.eventsQueue=new M.EventsQueue(L=>this._handleEvent(L))),this.eventsQueue.enqueue(J,this)):this._handleEvent(J)}async _handleEvent(J){var L,Y,Z,ye,Re,ae,Ve;const be=!((L=J._embedded)===null||L===void 0)&&L.from_user?((Z=(Y=J._embedded)===null||Y===void 0?void 0:Y.from_user)===null||Z===void 0?void 0:Z.id)===((ye=this.me)===null||ye===void 0?void 0:ye.id):((ae=(Re=J.body)===null||Re===void 0?void 0:Re.user)===null||ae===void 0?void 0:ae.user_id)===((Ve=this.me)===null||Ve===void 0?void 0:Ve.id),Te=d.default._checkIfUserIsReInvited(this.conversations,J);if(J.type.startsWith("sip"))return x._handleSipCallEvent(J),J;if(this.conversations.has(J.cid)&&J.type!=="rtc:transfer"&&!Te)return J.type.startsWith("rtc")&&j._handleRtcEvent(J),this.conversations.get(J.cid)._handleEvent(J),(J.type==="member:joined"||J.type==="member:invited")&&be&&this._handleApplicationEvent(J),J;if(J.cid)try{Te&&this.conversations.delete(J.cid);let we;return d.default._isCallEvent(J)?we=await this.getConversation(J.cid,ie.CONVERSATION_API_VERSION.v1):we=await this.getConversation(J.cid,ie.CONVERSATION_API_VERSION.v3),this.conversations.set(J.cid,we),await we._handleEvent(J),await this._handleApplicationEvent(J),J.type.startsWith("rtc")&&j._handleRtcEvent(J),Promise.resolve(J)}catch(we){return this.log.error(we),Promise.reject(we)}}async updateToken(J){if(this.session.connection&&this.session.connection.disconnected)return this.session.config.token=J,this.session.connection.io.opts.query.token=J,Promise.resolve();const L={url:`${this.session.config.nexmo_api_url}/v0.2/sessions/${this.session.session_id}`,type:"PUT",token:J};try{await d.default.networkRequest(L),this.me&&(this.session.config.token=J,this.session.connection.io.opts.query.token=J)}catch(Y){throw new a.NexmoApiError(Y)}}async _handleApplicationEvent(J){try{this.log.debug("_handleApplicationEvent: ",{event:J});const L=z.handleEvent(J),Y=this.conversations.get(J.cid);let Z;if(Y.members.has((L||{}).from))Z=Y.members.get(L.from);else if(J.type==="member:joined"||J.type==="member:invited"){const ye={...J.body,...J.from&&{member_id:J.from}};Z=new I.default(Y,ye)}else try{Z=await Y.getMember(L.from)}catch(ye){this.log.warn(`There is an error getting the member ${ye}`)}return this.emit(L.type,Z,L),J}catch(L){throw this.log.error("_handleApplicationEvent: ",L),L}}async inAppCall(J){if(!J||!Array.isArray(J)||J.length===0)return Promise.reject(new a.NexmoClientError("error:application:call:params"));try{const L=new o.default(this);return await L.createCall(J),L.direction=L.CALL_DIRECTION.OUTBOUND,L}catch(L){throw L}}async callServer(J,L="phone",Y={}){try{const Z=new o.default(this);return Z.direction=Z.CALL_DIRECTION.OUTBOUND,await Z.createServerCall(J,L,Y),Z}catch(Z){throw Z}}async reconnectCall(J,L,Y={}){try{if(!J||!L)throw new a.NexmoClientError("error:missing:params");const Z=await this.getConversation(J,ie.CONVERSATION_API_VERSION.v1);await Z.media.enable({...Y,reconnectRtcId:L});const ye=new o.default(this,Z),Re=Array.from(Z.events.values()).map(ae=>ae.type);return Re.includes("sip:answered")?ye.status=ye.CALL_STATUS.ANSWERED:Re.includes("sip:ringing")?ye.status=ye.CALL_STATUS.RINGING:ye.status=ye.CALL_STATUS.STARTED,ye.rtcObjects=Z.media.rtcObjects,this.calls.set(Z.id,ye),ye}catch(Z){throw Z}}async newConversation(J={}){try{const L=await this.session.sendNetworkRequest({type:"POST",path:"conversations",data:J}),Y=new c.default(this,L);return this.conversations.set(Y.id,Y),this.getConversation(Y.id,ie.CONVERSATION_API_VERSION.v1)}catch(L){throw new a.NexmoApiError(L)}}async newConversationAndJoin(J){const L=await this.newConversation(J);return await L.join(),L}async getConversation(J,L=ie.CONVERSATION_API_VERSION.v3){if(L!==ie.CONVERSATION_API_VERSION.v1&&L!==ie.CONVERSATION_API_VERSION.v3)throw new a.NexmoClientError("error:conversation-service:version");let Y;if(L===ie.CONVERSATION_API_VERSION.v1)try{Y=await this.session.sendNetworkRequest({type:"GET",path:`conversations/${J}`}),Y.id=Y.uuid,delete Y.uuid}catch(ye){throw new a.NexmoApiError(ye)}else try{Y=await this.session.sendNetworkRequest({type:"GET",path:`conversations/${J}`,version:"v0.3"})}catch(ye){throw new a.NexmoApiError(ye)}const Z=this.updateOrCreateConversation(Y);if(L===ie.CONVERSATION_API_VERSION.v3&&!Z.me)try{const ye=await Z.getMyMember();Z.me=ye,Z.members.set(ye.id,ye)}catch{try{const Re=await Z.getMyMember();Z.me=Re,Z.members.set(Re.id,Re)}catch{this.log.warn(`You don't have any membership in ${Z.id}`)}}if(this.session.config.sync==="full"){const{items:ye}=await Z.getEvents();return Z.events=ye,Z}else return Z}async getConversations(J={}){const L=`${this.session.config.nexmo_api_url}/beta2/users/${this.me.id}/conversations`;let Y=Object.keys(J).length===0?this.pageConfig:new p.default(J);try{const Z=await d.default.paginationRequest(L,Y,this.session.config.token);Z.application=this;const ye=new h.default(Z);return this.conversations_page_last=ye,ye}catch(Z){throw new a.NexmoApiError(Z)}}syncConversations(J){const L=Array.from(J.values()),Y=L.length,Z=new Date;this.start_sync_time=typeof window<"u"&&window.performance?window.performance.now():Z.getTime();const ye=async()=>{this.synced_conversations_percentage=Number((this.synced_conversations_count/Y*100).toFixed(2));const Re={sync_progress:this.synced_conversations_percentage};if(this.emit("sync:progress",Re),this.log.info("Loading sync progress: "+this.synced_conversations_count+"/"+Y+" - "+this.synced_conversations_percentage+"%"),this.synced_conversations_percentage>=100){const ae=new Date;this.stop_sync_time=typeof window<"u"&&window.performance?window.performance.now():ae.getTime(),this.log.info("Loaded conversations in "+(this.stop_sync_time-this.start_sync_time)+"ms")}this.synced_conversations_count<Y&&(await this.getConversation(L[this.synced_conversations_count].id),ye(),this.synced_conversations_count++,this.sync_progress_buffer++)};ye()}async getUser(J=this.me.id){try{const L=await this.session.sendNetworkRequest({type:"GET",path:`users/${J}`});return new s.default(this,L)}catch(L){throw new a.NexmoApiError(L)}}async getUserSessions(J={}){var L;const Y=((L=J)===null||L===void 0?void 0:L.user_id)||this.me.id,Z=`${this.session.config.nexmo_api_url}/v0.3/users/${Y}/sessions`;let ye=Object.keys(J).length===0?this.pageConfig:new p.default(J);try{const Re=await d.default.paginationRequest(Z,ye,this.session.config.token,ie.CONVERSATION_API_VERSION.v3);Re.application=this;const ae=new E.default(Re);return this.user_sessions_page_last=ae,ae}catch(Re){throw new a.NexmoApiError(Re)}}}r.default=ie,ie.CONVERSATION_API_VERSION={v1:"v0.1",v3:"v0.3"},e.exports=ie}(wc,wc.exports)),wc.exports}var gw;function pi(){return gw||(gw=1,function(e,r){var t=ze&&ze.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(ou),i=t(uR),a=t(wf()),s=4e4,c=2e4;class o{static getMemberFromNameOrNull(l,f){if(!l||!f)return null;for(let d of l.members.values())if(d.user.name===f)return d;return null}static getMemberNumberFromEventOrNull(l){const f=l&&l.from;return f&&(f.number||f.uri)?f.number||f.uri:null}static networkRequest(l){return new Promise((f,d)=>{!l.token&&!l.url.includes("logging")&&!l.url.includes("ping")&&d({response:{type:"error:user:token",description:"network error on request. Please create a new session."}});const p=new XMLHttpRequest;let h;p.open(l.type,l.url,!0),l.token&&p.setRequestHeader("Authorization","Bearer "+l.token),l&&l.url.includes("image")?(p.responseType="",h=l.data,p.onloadstart=()=>{f(p)}):(p.responseType=l.responseType||"json",h=JSON.stringify(l.data)||null,p.setRequestHeader("Content-type","application/json; charset=utf-8")),p.onload=()=>{p.status===200||p.status===201||p.status===204?f(p):d(p)},p.onerror=E=>{d(E)},p.send(h)})}static async paginationRequest(l,f,d,p=a.default.CONVERSATION_API_VERSION.v1){try{const h=await o.networkRequest({type:"GET",url:o.addUrlSearchParams(l,f),token:d}),{page_size:E,_embedded:M,_links:I}=h.response,x=l.split("/").pop().trim();return{items:p===a.default.CONVERSATION_API_VERSION.v1?M.data[x]:M[x],cursor:{prev:I.prev?new URLSearchParams(I.prev.href).get("cursor"):"",next:I.next?new URLSearchParams(I.next.href).get("cursor"):"",self:I.self?new URLSearchParams(I.self.href).get("cursor"):""},page_size:E,order:f.order||"asc",event_type:f.event_type||null}}catch({response:h}){const E=h||{type:"error:network:get-request",description:"network error on nexmo get request"};throw E.validation&&(E.description=E.validation[Object.keys(E.validation)[0]]),E}}static addUrlSearchParams(l,f={}){let d=new URL(l);return Object.keys(f).forEach(p=>{f[p]&&!(typeof f[p]=="string"&&f[p].length<1)&&f[p]!==null&&d.searchParams.set(p,f[p])}),d.href}static deepMergeObj(l,f){const d=JSON.parse(JSON.stringify(l));for(let p in f)Object.prototype.toString.call(f[p])==="[object Object]"?d[p]=o.deepMergeObj(d[p],f[p]):d[p]=f[p];return d}static injectScript(l,f){if(typeof document<"u"){let d=document.getElementsByTagName("head")[0],p=document.createElement("script");p.async=!0,p.src=l,p.onload=p.onreadystatechange=()=>{(!p.readyState||/loaded|complete/.test(p.readyState))&&(p.onload=p.onreadystatechange=null,p=null,f&&f())},d.insertBefore(p,d.firstChild)}}static allocateUUID(){return n.default.v4()}static validateDTMF(l){return typeof l=="string"?/^[\da-dA-D#*pP]{1,45}$$/.test(l):!1}static _getBugsnagKey(){return"76498fc1ca8d9b0a173a44e2b873d7ed"}static updateMemberLegs(l,f){if(l){const d=l.find(p=>p.leg_id===f.body.leg_id);if(!d)l.push({leg_id:f.body.leg_id,status:f.body.status});else if(d.status!==f.body.status){let p=l.indexOf(d);l.fill(d.status=f.body.status,p,p++)}}else l=[{leg_id:f.body.leg_id,status:f.body.status}];return l}static _isCallEvent(l){const{channel:f,media:d}=l.body;return!!(l.type==="rtc:transfer"||f&&(d&&d.audio_settings&&d.audio_settings.enabled||d&&d.audio&&d.audio.enabled||f.knocking_id))}static async _fetchImage(l,f){const{response:d}=await o.networkRequest({type:"GET",url:l,responseType:"arraybuffer",token:f}),p=new Uint8Array(d);let h="";const E=8*1024;let M;for(M=0;M<p.length/E;M++)h+=String.fromCharCode.apply(null,p.subarray(M*E,(M+1)*E));return h+=String.fromCharCode.apply(null,p.subarray(M*E)),"data:image/jpeg;base64,"+btoa(h)}static async _checkHttpConnectivity(l){const f=Date.now();try{await o.networkRequest({type:"GET",url:l});const d=Date.now()-f;return{url:l,canConnect:!0,connectionTime:d}}catch(d){return{url:l,canConnect:!1,error:d}}}static _checkWsConnectivity(l,f,d){return new Promise((p,h)=>{const E=Object.assign({path:f},d),M=Date.now(),I=i.default.connect(l,E),x=setTimeout(()=>p({url:l,canConnect:!1}),c);I.on("connect",()=>{const j=Date.now()-M;I.disconnect(),clearTimeout(x),p({url:l,canConnect:!0,connectionTime:j})}),I.on("error",j=>{I.disconnect(),clearTimeout(x),p({url:l,canConnect:!1,error:j})})})}static async _checkMediaServers(l,f,d){try{const{response:p}=await o.networkRequest({type:"GET",url:`${f}/v0.3/discovery/media/${d}`,token:l}),h=p.map(E=>o._checkMediaConnectivity(E.ip,E.port));return await Promise.all(h)}catch{return[]}}static async _checkMediaConnectivity(l,f){return new Promise(async(d,p)=>{const h={iceServers:[{urls:`stun:${l}:${f}`}]},E=new RTCPeerConnection(h),M=Date.now(),I=await E.createOffer({offerToReceiveAudio:!0});E.setLocalDescription(I);const x=setTimeout(()=>{E.close(),d({ip:l,canConnect:!1})},s);E.onicecandidate=({candidate:j})=>{if((j==null?void 0:j.type)==="srflx"){const z=Date.now()-M;clearTimeout(x),E.close(),d({ip:l,canConnect:!0,connectionTime:z})}},E.onicecandidateerror=j=>{j.errorCode&&(E.close(),clearTimeout(x),d({ip:l,canConnect:!1,error:j}))}})}static _checkIfUserIsReInvited(l,f){var d;if(!l.has(f.cid)||!(f.type==="member:invited"||f.type==="member:joined"))return!1;const p=(d=l.get(f.cid))===null||d===void 0?void 0:d.me;return p?p.user.name===f.body.user.name&&p.state==="LEFT":!1}}r.default=o,e.exports=o}(Sc,Sc.exports)),Sc.exports}var Uh={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});const t=pr,n=In;class i{constructor(s){if(this.log=t.getLogger(this.constructor.name),!s)throw new n.NexmoClientError("no emitter object passed for the Error Emitter");this.emitter=s,this.LISTENER_GROUP="NXM-errors"}emitResponseIfError(s){if(this._isTypeError(s.type))return this.emitter.emit(s.type,this.LISTENER_GROUP,s)}cleanup(){return this.emitter.releaseGroup(this.LISTENER_GROUP)}_isTypeError(s){return s.indexOf("error")!==-1}}r.default=i,e.exports=i})(Uh,Uh.exports);var oY=Uh.exports;(function(e,r){var t=ze&&ze.__importDefault||function(M){return M&&M.__esModule?M:{default:M}};Object.defineProperty(r,"__esModule",{value:!0});const n=Ra,i=t(v7),a=t(pr),s=In,c=t(uR),o=t(cJ),u=t(vJ),l=t(pi()),f=t(wf()),d=t(oY),p=t(lR),h=t(_f());i.default.reg(a.default),i.default.apply(a.default,{template:"[%t] %l (NXM-%n):",timestampFormatter:M=>M.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),levelFormatter:M=>M.toUpperCase(),nameFormatter:M=>M||"SDK"});class E{constructor(I={}){const x=I;if(this.config={debug:"silent",log_reporter:{enabled:!1,bugsnag_key:null},environment:"production",ips_url:"https://api-us.vonage.com/v1/image",nexmo_api_url:"https://api-us.vonage.com",path:"/v2/rtc",repository:"https://github.com/Nexmo/conversation-js-sdk",SDK_version:"9.3.0",socket_io:{reconnection:!0,reconnectionAttempts:5,reconnectionDelay:2e3,randomizationFactor:.75,reconnectionDelayMax:15e3,forceNew:!0,autoConnect:!0,transports:["websocket"]},sync:"none",url:"https://ws-us.vonage.com",iceServers:[],rtcstats:{remote_collection:!0,remote_collection_url:"https://hlg.tokbox.com/prod/logging/nexmo_client_js_stats",remote_collection_interval:5e3,emit_events:!1,emit_rtc_analytics:!1,emit_interval:1e3},conversations_page_config:{page_size:10,order:"asc",cursor:""},events_page_config:{page_size:10,order:"asc",event_type:""},enableEventsQueue:!0,enableInboundOffer:!1,acknowledgeEvents:!0,token:null},this.config.socket_io.query={token:"",SDK_version:this.config.SDK_version,session_version:I.enableInboundOffer?"0.0.2":"0.0.1",acknowledge_events:this.config.acknowledgeEvents,OS_family:"js",OS_revision:typeof navigator<"u"?navigator.userAgent:typeof window<"u"?window.navigator.userAgent:"Generic JS navigator"},this.sessionReady=!1,this.disconnectTimestamp=null,this.session_id=null,this.apiKey=null,this.requests={},this.application=null,["debug","info","warn","error"].includes(x.debug)?a.default.setLevel(x.debug):x.debug===!0?a.default.setLevel("debug"):a.default.setLevel("silent"),this.log=a.default.noConflict(),this.config=l.default.deepMergeObj(this.config,this._sanitizeConfig(x)),this.config.log_reporter.enabled){const j={apiKey:this.config.log_reporter.bugsnag_key||l.default._getBugsnagKey(),appVersion:this.config.socket_io.query.SDK_version,releaseStage:this.config.environment};ze.NXMbugsnagClient=o.default(j)}n.mixin(E)}_createAndSetConnection(){let I,x=Object.assign({path:this.config.path},this.config.socket_io);return I=c.default.connect(this.config.url,x),this.connection=I,I.on("connect",()=>{this.emit("ready"),this.sessionReady=!0,this.log.info("websocket ready")}),I.on("disconnect",(j,z)=>{this.emit("disconnect",j==="io client disconnect"?E.DISCONNECT_REASON.ClientDisconnected:j==="io server disconnect"&&this.session_id?E.DISCONNECT_REASON.TokenExpired:E.DISCONNECT_REASON.ConnectionError),this.disconnectTimestamp=Date.now(),this.log.info("websocket disconnected",j,z)}),I.io.on("reconnect",j=>{this.emit("reconnect",j),this.log.info("websocket reconnect",j),l.default.networkRequest({url:`${this.config.url.replace("wss://","https://")}/v2/rtc/metrics`,type:"POST",token:this.config.token,data:{sessionId:this.session_id,metrics:[{name:"TIME_TO_RECONNECT_SUCCESS",time:this.disconnectTimestamp?Date.now()-this.disconnectTimestamp:void 0,attempt:j}]}}).catch(z=>{this.log.warn("Failed to publish socket reconnection metrics",z)})}),I.io.on("reconnect_attempt",j=>{this.emit("reconnecting",j),this.log.info("websocket reconnecting",j)}),I.on("connect_error",j=>{this.emit("error",new s.NexmoClientError(j)),this.log.error("Socket.io reported a generic error",j)}),I.io.on("reconnect_failed",()=>{this.emit("error",new s.NexmoClientError("error:client:reconnection_failed")),this.log.error("websocket reconnection error")}),I.io.on("packet",j=>{if(j.type!==2||j.data[0]==="echo")return;const z=j.data[2];z&&typeof z=="function"&&z();const ie=j.data[1];if(ie.type=j.data[0],this.log.debug("<--",ie.type,ie),this.requests["session:login"]){const oe=this.requests["session:login"].callback;delete this.requests["session:login"],oe(ie)}else if(ie.rid in this.requests){const oe=this.requests[ie.rid].callback;delete this.requests[ie.rid],delete ie.delay,this.errorsEmitter&&this.errorsEmitter.emitResponseIfError(ie),oe(ie)}else this.errorsEmitter&&ie.type.startsWith("system:error:")?this.errorsEmitter.emitResponseIfError(ie):ie.type.startsWith("session:")?this.updateSession(ie):this.application&&this.application._enqueueEvent(ie)}),I}_sanitizeConfig(I){let x=I;return I.sync&&["none","lite","full"].indexOf(I.sync)===-1&&(this.log.warn(`invalid param '${I.sync}' for sync, reverting to ${this.config.sync}`),x.sync=this.config.sync),x}sendRequest(I,x){I.tid=l.default.allocateUUID();const j=I.type;delete I.type,this.log.debug("-->",j,I),this.log.info("-->",j,I.tid),this.connection.emit(j,I),this.requests[I.tid]={type:j,request:I,callback:x}}async sendNetworkRequest(I){const x=I.version||"beta",j=`${this.config.nexmo_api_url}/${x}/${I.path}`;I.type==="GET"||I.type==="DELETE"||(I.data?I.data.originating_session=this.session_id:I.data={originating_session:this.session_id});try{const z={type:I.type,url:j,data:I.data?I.data:null,token:(I.data||{}).token?I.data.token:this.config.token||null};this.log.debug("sendNetworkRequest: ",{request:z});const{response:ie}=await l.default.networkRequest(z);return ie}catch({response:z}){throw z}}createSession(I){return this.config.socket_io.query.token=I,this._createAndSetConnection(),new Promise((x,j)=>{this.log.info(`Client-SDK Version: ${this.config.SDK_version}`),this.config.token=null,this.requests["session:login"]={type:"session:login",callback:async z=>{if(z.type==="session:success")if(this.session_id=z.body.id,this.apiKey=z.body.api_key,this.config.token=I,this.connection.io.opts.query={session_id:this.session_id,token:this.config.token},(!this.application||this.application.me&&this.application.me.id!==z.body.user_id)&&(this.application=new f.default(this,{})),this.application.me||(this.application.me=new p.default(this.application,{id:z.body.user_id,name:z.body.name})),this.errorsEmitter||(this.errorsEmitter=new d.default(this.application)),this.config.log_reporter.enabled&&(ze.NXMbugsnagClient.user={id:this.application.me.id,name:this.application.me.name,session_id:z.body.id}),this.config.sync!=="none")try{await this.application.getConversations(),x(this.application)}catch(ie){j(ie)}else x(this.application);else j(new s.NexmoApiError(z))}}})}deleteSession(){return new Promise(async(I,x)=>{const j=()=>this.sendRequest({type:"session:logout",body:{}},z=>{z.type==="session:logged-out"||z.type==="session:terminated"?(this.disconnect(),delete this.errorsEmitter,delete this.application,delete this.connection,this.requests={},this.sessionReady=!1,I(z)):x(z)});if(this.application){let z=[];if(this.application.conversations.size)for(let ie of this.application.conversations.values())z.push(ie.media.disable());try{await Promise.all(z)}catch(ie){this.log.error("deleteSession: ",ie)}return j()}else return j()})}updateSession(I){I.type==="session:success"&&(this.session_id=I.body.id,this.connection.io.opts.query.session_id=I.body.id)}disconnect(){return this.connection.disconnect()}connect(){return this.connection.connect()}async connectivityReport(I,x){const z={machineInfo:{ip:h.default.isNode()?void 0:await u.default.v4()},connectivityReport:[]};try{const{response:ie}=await l.default.networkRequest({type:"GET",url:`${this.config.nexmo_api_url}/v0.3/discovery/api`,token:I});let oe=ie;x!=null&&x.dcListCallback&&(oe=x.dcListCallback(oe));for(const J in oe){const L=oe[J].endpoint,Y=oe[J].https,Z=oe[J].ws;try{const ye=await l.default._checkHttpConnectivity(Y),Re=await l.default._checkWsConnectivity(Z,this.config.path,this.config.socket_io),ae=await l.default._checkMediaServers(I,L,J),Ve={name:J,signalConnectionReport:{https:ye,ws:Re},mediaConnectionReport:ae};z.connectivityReport.push(Ve)}catch(ye){this.log.error(`Error generating report for ${J}`,ye)}}}catch(ie){this.log.error("Error fetching nexmo servers information",ie)}return z}async checkMediaServers(I,x,j){return await l.default._checkMediaServers(I,x,j)}async checkMediaConnectivity(I,x){return await l.default._checkMediaConnectivity(I,x)}}r.default=E,E.DISCONNECT_REASON={ClientDisconnected:"ClientDisconnected",TokenExpired:"TokenExpired",ConnectionError:"ConnectionError"},e.exports=E})(vh,vh.exports);var uY=vh.exports;const cY=Vh(uY),Ti=new ts("nexmo-chat"),lY=["us-3","us-4","eu-3","eu-4","ap-3","ap-4"];class u1 extends Gh{constructor(){super(...arguments);bt(this,"rtc");bt(this,"application");bt(this,"conversation")}get _client(){if(this.rtc)return this.rtc;const t=fY(this.region);return this.rtc=new cY({nexmo_api_url:`https://api-${this.region}.${t}`,url:`wss://ws-${this.region}.${t}`}),this.rtc}async create(){const{identity:t,token:n}=await this.issueChatToken();Ti.info(`Connecting chat, identity: ${t}, token: ${n}`),this.identity=t,this.application=await this._client.createSession(n)}async destroy(){this.rtc&&(await this.rtc.deleteSession(),this.rtc=null,this.application=null,this.conversation=null)}async join(t){const n=await this.application.getConversation(t);n.me.state==="JOINED"?Ti.info("already joined conversation:",t):(await n.join(),Ti.info("success joined conversation:",t)),this.registerEvents(n),this.conversation=n}async preview(t){await this.conversation.sendCustomEvent({type:"ujet_preview",body:{chat_preview:t,chat_preview_updated_at:new Date().toJSON()}})}async fetchMessages(t){const n=await this.conversation.getEvents({event_type:"message"}),i=[];return n.items.forEach(a=>{const s=a._embedded.from_user.name,c=yw(a,s);(c.type==="photo"||c.type==="video")&&(c.file=t[c.$index]),i.push(c)}),i}async sendMessage(t){try{const n=await this.conversation.sendMessage({message_type:"text",text:JSON.stringify(t)});return Ti.info(`Message sent from ${this.conversation.id}, id: ${n.id}`),parseInt(n.id,10)}catch(n){Ti.warn(`Failed to send a message from ${this.conversation.id}`,{error:n})}}startTyping(){this.conversation&&this.conversation.startTyping()}stopTyping(){this.conversation&&this.conversation.stopTyping()}registerEvents(t){t.on("message",(n,i)=>{const a=yw(i,n.userName);Ti.info(`Message added from ${this.conversation.id}, index: ${a.$index}, sid: ${a.$sid}, timestamp: ${a.$timestamp}, user type: ${a.$userType}`),a.$userType!=="end_user"&&this.ping(),this.events.triggerEvent("message",a)}),t.on("member:joined",n=>{Ti.info("conversation: memberJoined",n),this.events.triggerEvent("memberJoined",n.userName)}),t.on("member:left",n=>{Ti.info("conversation: memberLeft",n),this.events.triggerEvent("memberLeft",n.userName)}),t.on("text:typing:on",n=>{/^end_user/.test(n.userName)||this.events.triggerEvent("typingStarted",n.userName)}),t.on("text:typing:off",n=>{/^end_user/.test(n.userName)||this.events.triggerEvent("typingEnded",n.userName)})}}bt(u1,"type","nexmo_conversations");zh(u1);function fY(e){return lY.indexOf(e)>-1?"vonage.com":"nexmo.com"}function yw(e,r){const{id:t,timestamp:n,body:i}=e,[a,s]=r.split("-");let c=0;s&&(c=parseInt(s,10));const o={$index:parseInt(t,10),$sid:t,$timestamp:new Date(Date.parse(n)),$userType:a,$userId:c};try{const u=JSON.parse(i.text);return u.message&&!u.type?{...o,...u,type:"message"}:{...o,...u}}catch(u){return Ti.warn("Format message failed",{error:u,data:i.text}),{...o,type:"text",content:i.text}}}exports.Client=g$;exports.ENVIRONMENT=d1;exports.EventManager=qh;exports.Logger=ts;exports.MediaStore=Sw;exports.OPTIONS=Or;exports.VERSION=bw;exports.addProviderType=zh;exports.consoleLoggerHandler=v1;exports.formatLogData=_w;exports.newrelicLoggerHandler=m1;
|