@ujet/websdk-headless 3.0.6 → 3.1.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 +45 -6
- package/dist/index.d.ts +564 -415
- package/dist/index.js +139 -41281
- package/dist/index.mjs +42064 -0
- package/package.json +4 -9
- package/dist/index.cjs +0 -563
package/dist/index.cjs
DELETED
|
@@ -1,563 +0,0 @@
|
|
|
1
|
-
"use strict";var E$=Object.defineProperty;var k$=(e,r,t)=>r in e?E$(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var bt=(e,r,t)=>(k$(e,typeof r!="symbol"?r+"":r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R$="prod",h0="3.0.6",vg="https://main.api.ujet.co",Or={companyId:"",tenant:"",trackerId:"",deviceId:"",application:"websdk",version:h0};function $$(e){return(e==null?void 0:e.constructor)===Object}async function mg(e,r=3){let t=0,n;for(;t<=r;){t+=1;try{return await e()}catch(i){n=i,console.error(i),await O$(1e3*Math.pow(2,t))}}throw n}function O$(e){return new Promise(r=>{setTimeout(()=>{r(0)},e)})}const gg=[];class ts{constructor(r){bt(this,"channel");this.channel=r}static addHandler(r){gg.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){gg.forEach(n=>{n(this.channel,r,...t)})}}const I$=(e,r,...t)=>{console[r](`[${r}][${e}]`,...t)};function P$(e){return function(r,t,...n){const i="https://log-api.newrelic.com/log/v1",a=v0(r,t,...n);return fetch(i,{method:"POST",body:JSON.stringify(a),headers:{"api-key":e,"content-type":"application/json"}})}}function v0(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:M$(n),message:fv(i)};return Or.trackerId&&(a.tracker_id=Or.trackerId),a}const A$=["user","phone","phone_number","phoneNumber","email"],x$=[/(?: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 fv(e){return typeof e=="string"?x$.forEach(r=>{e=e.replace(r,"__MASKED__")}):e&&$$(e)&&(e={...e},Object.keys(e).forEach(r=>{A$.indexOf(r)!==-1?e[r]="__MASKED__":fv(e[r])})),e}function M$(e){if(e.error){const r=e.error;return{error:{name:r.name,message:r.message,stack:r.stack}}}return fv(e.data)}const $f=new ts("communicator");class N${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=L$(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($f.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($f.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?($f.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 L$(e){var i;let r=e.host;r||(e.tenant?r=vg.replace("main.api",e.tenant+".api"):r=vg);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.ujet.co/v3/bridge.html"}}const yg=new ts("MediaStore"),D$=window.indexedDB||window.webkitIndexedDB||window.mozIndexedDB||window.OIndexedDB||window.msIndexedDB,j$="chat-media",bg=1,el="file";class m0{constructor(){bt(this,"db")}store(){return new Promise((r,t)=>{if(this.db)return r(_g(this.db));const n=D$.open(j$,bg);n.onerror=()=>{t(new Error("indexedDB open failed"))},n.onsuccess=()=>{const i=n.result;this.db=i,r(_g(i))},n.onupgradeneeded=i=>{const a=n.result;i.oldVersion>0&&i.oldVersion<bg&&(yg.info("deprecating media store"),a.deleteObjectStore(el)),yg.info("creating media store"),a.createObjectStore(el)}})}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 _g(e){return e.transaction(el,"readwrite").objectStore(el)}class dv{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 F$=new ts("chat-provider");class pv{constructor(r,t){bt(this,"audio");bt(this,"issueChatToken");bt(this,"identity");bt(this,"channelId");bt(this,"region");bt(this,"events");this.events=new dv,this.region=r.region,this.issueChatToken=t}ping(){this.audio||(this.audio=new window.Audio("https://websdk.ujet.co/v3/ping.mp3"));try{this.audio.play()}catch(r){F$.warn("Chat audio play failed",{error:r})}}on(r,t){this.events.addEventListener(r,t)}off(r,t){this.events.removeEventListener(r,t)}}bt(pv,"type","base");const g0={};function hv(e){g0[e.type]=e}function U$(e){return g0[e]}const B$=["assigned","va_assigned"],y0=["dismissed","va_dismissed"],q$=["queued",...B$,...y0],G$=["timeout","canceled","failed","finished"],wg=new ts("Chat");class V${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 m0;const n=U$(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 q$.indexOf(this.state.status)!=-1}get dismissed(){return y0.indexOf(this.state.status)!=-1}get ended(){return G$.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 mg(()=>this.provider.create(),3),await mg(()=>this.provider.join(this.state.provider_channel_id),3),this.connected=!0,this.triggerEvent("connected",this),wg.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(),wg.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(){if(this.connected){const r=await this.store.getAllFiles();return this.provider.fetchMessages(r)}else throw new Error("Please fetchMessages after chat connected.")}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 z$(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=W$(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 W$(e){return new window.DOMParser().parseFromString(e,"text/xml").getElementsByTagName("Key")[0].childNodes[0].nodeValue}function H$(e="none"){return/^image/.test(e)?"photo":/^video/.test(e)?"video":"file"}function b0(e){return e.map(K$).filter(r=>r.enabled)}function K$(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=J$(e);if(t&&(r.redirection=e.redirection),e.children&&e.children.length){const n=b0(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}=Y$(e.channels);r.deflection=i,t||(r.channels=n),r.enabled=n.length>0||t}return r}function J$(e){let r=!1;const t=e.redirection;return t&&(t.option==="message"||t.option==="url")&&(r=!!t.data),r}function Y$(e){const r=X$(e);Q$(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 X$(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 Q$(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 Z$={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 eO(e){return{languages:e.languages.filter(t=>t.enabled).map(t=>({lang:t.lang,name:t.name,localeName:Z$[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 tO{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 eO(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:b0(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}async getChatDeflection(r){const{data:t}=await this.get(`chats/${r}/deflections`);return t&&t.enabled?t:null}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)}sendChatTranscripts(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=H$(t.type),a=t.name.replace(/\.[^.]+$/i,""),s=await this.post(`chats/${r}/${i}s/upload`,{filename:a}),c=await z$(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 V$(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 Of="ujet:",Dr={set(e,r){return localStorage.setItem(Of+e,r)},get(e){return localStorage.getItem(Of+e)},del(e){return localStorage.removeItem(Of+e)}},_0={href:window.location.href,interval:24*60*60};function rO(e,r){if(!Array.isArray(e)||!e.length)return null;const t=oO(),n=t===0,i=t+1;return uO(i),e.filter(s=>{const c=nO(s,_0.href),o=iO(s.visitor_type,n),u=aO(s.messages,r),l=i>=s.page_visit_count,f=!sO(s.id);return c&&o&&u&&l&&f}).sort((s,c)=>s.stay_time-c.stay_time)[0]||null}function nO(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 iO(e,r){return e==="visitor_type_new"?r:e==="visitor_type_returning"?!r:!0}function aO(e,r){return e.filter(n=>n.lang===r).length>0}function sO(e){try{const r=parseInt(Dr.get(`trigger:${e}`),10);return Date.now()/1e3-r<_0.interval}catch{return!1}}function oO(){try{const e=Dr.get("visits");return e?parseInt(e,10):0}catch{return 0}}function uO(e){try{Dr.set("visits",e.toString())}catch{}}class vv{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 cO();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 vv(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,fO(this._cobrowse,this.messages,this.lang),dO(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 cO(){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 lO=`<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 fO(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=lO,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 dO(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 pO={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"},hO={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"},vO={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"},mO={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"},gO={confirmSessionTitle:"共同ブラウジングセッションリクエスト",confirmSessionContent:"現在の画面を担当者と共有したいですか。",endSessionText:"共同ブラウジングセッションを終了",confirmRemoteControlTitle:"リモートアクセスリクエスト",confirmRemoteControlContent:"担当者は、お客様をさらにお手伝いするために、現在共有中の画面へのアクセスを希望しています。許可しますか。",confirmFullDeviceTitle:"画面共有リクエスト",confirmFullDeviceContent:"画面全体を担当者と共有したいですか。担当者は画面上で一切の操作ができません。",allowText:"許可",denyText:"拒否"},yO={confirmSessionTitle:"코브라우징 세션 요청",confirmSessionContent:"현재 화면을 상담원과 공유하시겠습니까?",endSessionText:"코브라우징 세션 종료",confirmRemoteControlTitle:"원격 액세스 요청",confirmRemoteControlContent:"상담원이 추가 지원을 위해 현재 공유된 화면에 액세스할 수 있기를 원합니다. 허용하시겠습니까?",confirmFullDeviceTitle:"화면 공유 요청",confirmFullDeviceContent:"상담원과 전체 화면을 공유하시겠습니까? 상담원은 화면의 어떤 부분도 제어할 수 없습니다.",allowText:"허용",denyText:"거절"},bO={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"},_O={confirmSessionTitle:"同步浏览会话请求",confirmSessionContent:"您是否要向该客服代表共享当前的屏幕?",endSessionText:"结束同步浏览会话",confirmRemoteControlTitle:"远程访问请求",confirmRemoteControlContent:"为了进一步协助您,客服代表想访问您当前的共享屏幕。您是否允许这样做?",confirmFullDeviceTitle:"屏幕共享请求",confirmFullDeviceContent:"您是否要向该客服代表共享全屏?客服代表将不能控制屏幕上的任何东西。",allowText:"允许",denyText:"拒绝"},wO={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"},SO={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"},TO={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ä"},CO={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"},EO={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"},kO={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"},RO={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"},$O={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"},OO={confirmSessionTitle:"ขอเซสชันเรียกดูร่วม",confirmSessionContent:"คุณต้องการแชร์หน้าจอปัจจุบันกับตัวแทนหรือไม่",endSessionText:"สิ้นสุดเซสชันเรียกดูร่วม",confirmRemoteControlTitle:"ขอการเข้าถึงระยะไกล",confirmRemoteControlContent:"ตัวแทนต้องการเข้าถึงหน้าจอของคุณที่แชร์อยู่ในปัจจุบันเพื่อให้ความช่วยเหลือคุณต่อไป คุณจะอนุญาตหรือไม่",confirmFullDeviceTitle:"ขอแชร์หน้าจอ",confirmFullDeviceContent:"คุณต้องการแชร์ทั้งหน้าของคุณกับตัวแทนหรือไม่ ตัวแทนจะไม่สามารถควบคุมอะไรบนหน้าจอ",allowText:"ยินยอม",denyText:"ปฏิเสธ"},IO={confirmSessionTitle:"طلب جلسة تصفح مشترك",confirmSessionContent:"هل تريد مشاركة شاشتك الحالية مع الموظف؟",endSessionText:"إنهاء جلسة التصفح المشترك",confirmRemoteControlTitle:"طلب التحكم عن بعد",confirmRemoteControlContent:"يرغب مسئول الدعم في رؤية شاشتك المشاركة حالياً لمساعدتك بشكلٍ أكبر. هل تسمح بذلك؟",confirmFullDeviceTitle:"طلب مشاركة الشاشة",confirmFullDeviceContent:"هل تريد مشاركة شاشتك الكاملة مع مسئول الدعم؟ لن يتمكن المسئول من التحكم في أي شيء على الشاشة.",allowText:"السماح",denyText:"الرفض"},PO={en:pO,"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:hO,"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:vO,"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:mO,ja:gO,ko:yO,it:bO,zh:_O,"zh-Hant":{confirmSessionTitle:"共同瀏覽工作階段要求",confirmSessionContent:"要與專員分享您目前的畫面嗎?",endSessionText:"結束共同瀏覽工作階段",confirmRemoteControlTitle:"遠端存取要求",confirmRemoteControlContent:"專員想要存取您目前分享的螢幕畫面以進一步協助您。要允許嗎?",confirmFullDeviceTitle:"螢幕畫面分享要求",confirmFullDeviceContent:"要與專員分享全螢幕嗎?專員將無法控制畫面上的任何項目。",allowText:"允許",denyText:"拒絕"},sv:wO,pt:SO,"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:TO,nb:CO,da:EO,nl:kO,tr:RO,vi:$O,th:OO,ar:IO};let AO=class{constructor(r){bt(this,"options");bt(this,"communicator");bt(this,"methods");bt(this,"events",new dv);bt(this,"request");bt(this,"chat");bt(this,"cobrowse");this.options=r,this.communicator=new N$(r,this.events);const t=this.communicator.request.bind(this.communicator);this.methods=new tO(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 rO(t,r||this.lang)}getMenus(r,t){return this.methods.getMenus(t||this.lang,r)}getAfterHourMessage(r){return this.methods.getAfterHourMessage(r||this.lang)}getTimeSlots(r,t){return this.methods.getTimeSlots(r,t||this.lang)}getWaitTimes(r,t){return this.methods.getWaitTimes(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="")}getChatDeflection(){return this.methods.getChatDeflection(this.chat.id)}sendChatTranscripts(r){return this.methods.sendChatTranscripts(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)}fetchMessages(){return this.chat.fetchMessages()}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||PO[r],n={...this.options.cobrowse,messages:t,lang:r};this.cobrowse=await vv.create(n),this.cobrowse.start(),["loaded","updated","ended"].forEach(a=>{this.cobrowse.on(`session.${a}`,s=>{this.events.triggerEvent(`cobrowse.${a}`,s)})})}}registerOngoingChat(r){this.events.triggerEvent("chat.ongoing",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 Ve=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function mv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function w0(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 S0={},Fu=function(e){return e&&e.Math==Math&&e},Rt=Fu(typeof globalThis=="object"&&globalThis)||Fu(typeof window=="object"&&window)||Fu(typeof self=="object"&&self)||Fu(typeof Ve=="object"&&Ve)||function(){return this}()||Ve||Function("return this")(),ii={},mt=function(e){try{return!!e()}catch{return!0}},xO=mt,Yt=!xO(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),MO=mt,ou=!MO(function(){var e=function(){}.bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),NO=ou,Uu=Function.prototype.call,qt=NO?Uu.bind(Uu):function(){return Uu.apply(Uu,arguments)},uu={},T0={}.propertyIsEnumerable,C0=Object.getOwnPropertyDescriptor,LO=C0&&!T0.call({1:2},1);uu.f=LO?function(r){var t=C0(this,r);return!!t&&t.enumerable}:T0;var rs=function(e,r){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:r}},E0=ou,k0=Function.prototype,$p=k0.call,DO=E0&&k0.bind.bind($p,$p),_t=E0?DO:function(e){return function(){return $p.apply(e,arguments)}},R0=_t,jO=R0({}.toString),FO=R0("".slice),ai=function(e){return FO(jO(e),8,-1)},UO=_t,BO=mt,qO=ai,If=Object,GO=UO("".split),cu=BO(function(){return!If("z").propertyIsEnumerable(0)})?function(e){return qO(e)=="String"?GO(e,""):If(e)}:If,si=function(e){return e==null},VO=si,zO=TypeError,oi=function(e){if(VO(e))throw zO("Can't call method on "+e);return e},WO=cu,HO=oi,ln=function(e){return WO(HO(e))},Op=typeof document=="object"&&document.all,KO=typeof Op>"u"&&Op!==void 0,$0={all:Op,IS_HTMLDDA:KO},O0=$0,JO=O0.all,Bt=O0.IS_HTMLDDA?function(e){return typeof e=="function"||e===JO}:function(e){return typeof e=="function"},Sg=Bt,I0=$0,YO=I0.all,tr=I0.IS_HTMLDDA?function(e){return typeof e=="object"?e!==null:Sg(e)||e===YO}:function(e){return typeof e=="object"?e!==null:Sg(e)},Pf=Rt,XO=Bt,QO=function(e){return XO(e)?e:void 0},Vn=function(e,r){return arguments.length<2?QO(Pf[e]):Pf[e]&&Pf[e][r]},ZO=_t,Di=ZO({}.isPrototypeOf),ns=typeof navigator<"u"&&String(navigator.userAgent)||"",P0=Rt,Af=ns,Tg=P0.process,Cg=P0.Deno,Eg=Tg&&Tg.versions||Cg&&Cg.version,kg=Eg&&Eg.v8,jn,tl;kg&&(jn=kg.split("."),tl=jn[0]>0&&jn[0]<4?1:+(jn[0]+jn[1]));!tl&&Af&&(jn=Af.match(/Edge\/(\d+)/),(!jn||jn[1]>=74)&&(jn=Af.match(/Chrome\/(\d+)/),jn&&(tl=+jn[1])));var no=tl,Rg=no,eI=mt,tI=Rt,rI=tI.String,io=!!Object.getOwnPropertySymbols&&!eI(function(){var e=Symbol();return!rI(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&Rg&&Rg<41}),nI=io,A0=nI&&!Symbol.sham&&typeof Symbol.iterator=="symbol",iI=Vn,aI=Bt,sI=Di,oI=A0,uI=Object,ao=oI?function(e){return typeof e=="symbol"}:function(e){var r=iI("Symbol");return aI(r)&&sI(r.prototype,uI(e))},cI=String,is=function(e){try{return cI(e)}catch{return"Object"}},lI=Bt,fI=is,dI=TypeError,En=function(e){if(lI(e))return e;throw dI(fI(e)+" is not a function")},pI=En,hI=si,as=function(e,r){var t=e[r];return hI(t)?void 0:pI(t)},xf=qt,Mf=Bt,Nf=tr,vI=TypeError,mI=function(e,r){var t,n;if(r==="string"&&Mf(t=e.toString)&&!Nf(n=xf(t,e))||Mf(t=e.valueOf)&&!Nf(n=xf(t,e))||r!=="string"&&Mf(t=e.toString)&&!Nf(n=xf(t,e)))return n;throw vI("Can't convert object to primitive value")},x0={exports:{}},M0=!1,$g=Rt,gI=Object.defineProperty,gv=function(e,r){try{gI($g,e,{value:r,configurable:!0,writable:!0})}catch{$g[e]=r}return r},yI=Rt,bI=gv,Og="__core-js_shared__",_I=yI[Og]||bI(Og,{}),yv=_I,Ig=yv;(x0.exports=function(e,r){return Ig[e]||(Ig[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=x0.exports,wI=oi,SI=Object,Mr=function(e){return SI(wI(e))},TI=_t,CI=Mr,EI=TI({}.hasOwnProperty),rr=Object.hasOwn||function(r,t){return EI(CI(r),t)},kI=_t,RI=0,$I=Math.random(),OI=kI(1 .toString),lu=function(e){return"Symbol("+(e===void 0?"":e)+")_"+OI(++RI+$I,36)},II=Rt,PI=so,Pg=rr,AI=lu,xI=io,MI=A0,Ps=II.Symbol,Lf=PI("wks"),NI=MI?Ps.for||Ps:Ps&&Ps.withoutSetter||AI,Gt=function(e){return Pg(Lf,e)||(Lf[e]=xI&&Pg(Ps,e)?Ps[e]:NI("Symbol."+e)),Lf[e]},LI=qt,Ag=tr,xg=ao,DI=as,jI=mI,FI=Gt,UI=TypeError,BI=FI("toPrimitive"),bv=function(e,r){if(!Ag(e)||xg(e))return e;var t=DI(e,BI),n;if(t){if(r===void 0&&(r="default"),n=LI(t,e,r),!Ag(n)||xg(n))return n;throw UI("Can't convert object to primitive value")}return r===void 0&&(r="number"),jI(e,r)},qI=bv,GI=ao,fu=function(e){var r=qI(e,"string");return GI(r)?r:r+""},VI=Rt,Mg=tr,Ip=VI.document,zI=Mg(Ip)&&Mg(Ip.createElement),Cl=function(e){return zI?Ip.createElement(e):{}},WI=Yt,HI=mt,KI=Cl,N0=!WI&&!HI(function(){return Object.defineProperty(KI("div"),"a",{get:function(){return 7}}).a!=7}),JI=Yt,YI=qt,XI=uu,QI=rs,ZI=ln,eP=fu,tP=rr,rP=N0,Ng=Object.getOwnPropertyDescriptor;ii.f=JI?Ng:function(r,t){if(r=ZI(r),t=eP(t),rP)try{return Ng(r,t)}catch{}if(tP(r,t))return QI(!YI(XI.f,r,t),r[t])};var qr={},nP=Yt,iP=mt,L0=nP&&iP(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),aP=tr,sP=String,oP=TypeError,sr=function(e){if(aP(e))return e;throw oP(sP(e)+" is not an object")},uP=Yt,cP=N0,lP=L0,Bu=sr,Lg=fu,fP=TypeError,Df=Object.defineProperty,dP=Object.getOwnPropertyDescriptor,jf="enumerable",Ff="configurable",Uf="writable";qr.f=uP?lP?function(r,t,n){if(Bu(r),t=Lg(t),Bu(n),typeof r=="function"&&t==="prototype"&&"value"in n&&Uf in n&&!n[Uf]){var i=dP(r,t);i&&i[Uf]&&(r[t]=n.value,n={configurable:Ff in n?n[Ff]:i[Ff],enumerable:jf in n?n[jf]:i[jf],writable:!1})}return Df(r,t,n)}:Df:function(r,t,n){if(Bu(r),t=Lg(t),Bu(n),cP)try{return Df(r,t,n)}catch{}if("get"in n||"set"in n)throw fP("Accessors not supported");return"value"in n&&(r[t]=n.value),r};var pP=Yt,hP=qr,vP=rs,ji=pP?function(e,r,t){return hP.f(e,r,vP(1,t))}:function(e,r,t){return e[r]=t,e},D0={exports:{}},Pp=Yt,mP=rr,j0=Function.prototype,gP=Pp&&Object.getOwnPropertyDescriptor,_v=mP(j0,"name"),yP=_v&&function(){}.name==="something",bP=_v&&(!Pp||Pp&&gP(j0,"name").configurable),du={EXISTS:_v,PROPER:yP,CONFIGURABLE:bP},_P=_t,wP=Bt,Ap=yv,SP=_P(Function.toString);wP(Ap.inspectSource)||(Ap.inspectSource=function(e){return SP(e)});var wv=Ap.inspectSource,TP=Rt,CP=Bt,Dg=TP.WeakMap,EP=CP(Dg)&&/native code/.test(String(Dg)),kP=so,RP=lu,jg=kP("keys"),El=function(e){return jg[e]||(jg[e]=RP(e))},pu={},$P=EP,F0=Rt,OP=tr,IP=ji,Bf=rr,qf=yv,PP=El,AP=pu,Fg="Object already initialized",xp=F0.TypeError,xP=F0.WeakMap,rl,Qo,nl,MP=function(e){return nl(e)?Qo(e):rl(e,{})},NP=function(e){return function(r){var t;if(!OP(r)||(t=Qo(r)).type!==e)throw xp("Incompatible receiver, "+e+" required");return t}};if($P||qf.state){var Yn=qf.state||(qf.state=new xP);Yn.get=Yn.get,Yn.has=Yn.has,Yn.set=Yn.set,rl=function(e,r){if(Yn.has(e))throw xp(Fg);return r.facade=e,Yn.set(e,r),r},Qo=function(e){return Yn.get(e)||{}},nl=function(e){return Yn.has(e)}}else{var ms=PP("state");AP[ms]=!0,rl=function(e,r){if(Bf(e,ms))throw xp(Fg);return r.facade=e,IP(e,ms,r),r},Qo=function(e){return Bf(e,ms)?e[ms]:{}},nl=function(e){return Bf(e,ms)}}var kn={set:rl,get:Qo,has:nl,enforce:MP,getterFor:NP},Sv=_t,LP=mt,DP=Bt,qu=rr,Mp=Yt,jP=du.CONFIGURABLE,FP=wv,U0=kn,UP=U0.enforce,BP=U0.get,Ug=String,qc=Object.defineProperty,qP=Sv("".slice),GP=Sv("".replace),VP=Sv([].join),zP=Mp&&!LP(function(){return qc(function(){},"length",{value:8}).length!==8}),WP=String(String).split("String"),HP=D0.exports=function(e,r,t){qP(Ug(r),0,7)==="Symbol("&&(r="["+GP(Ug(r),/^Symbol\(([^)]*)\)/,"$1")+"]"),t&&t.getter&&(r="get "+r),t&&t.setter&&(r="set "+r),(!qu(e,"name")||jP&&e.name!==r)&&(Mp?qc(e,"name",{value:r,configurable:!0}):e.name=r),zP&&t&&qu(t,"arity")&&e.length!==t.arity&&qc(e,"length",{value:t.arity});try{t&&qu(t,"constructor")&&t.constructor?Mp&&qc(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch{}var n=UP(e);return qu(n,"source")||(n.source=VP(WP,typeof r=="string"?r:"")),e};Function.prototype.toString=HP(function(){return DP(this)&&BP(this).source||FP(this)},"toString");var B0=D0.exports,KP=Bt,JP=qr,YP=B0,XP=gv,Gr=function(e,r,t,n){n||(n={});var i=n.enumerable,a=n.name!==void 0?n.name:r;if(KP(t)&&YP(t,a,n),n.global)i?e[r]=t:XP(r,t);else{try{n.unsafe?e[r]&&(i=!0):delete e[r]}catch{}i?e[r]=t:JP.f(e,r,{value:t,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return e},ba={},QP=Math.ceil,ZP=Math.floor,eA=Math.trunc||function(r){var t=+r;return(t>0?ZP:QP)(t)},tA=eA,ui=function(e){var r=+e;return r!==r||r===0?0:tA(r)},rA=ui,nA=Math.max,iA=Math.min,ss=function(e,r){var t=rA(e);return t<0?nA(t+r,0):iA(t,r)},aA=ui,sA=Math.min,Fi=function(e){return e>0?sA(aA(e),9007199254740991):0},oA=Fi,Ir=function(e){return oA(e.length)},uA=ln,cA=ss,lA=Ir,Bg=function(e){return function(r,t,n){var i=uA(r),a=lA(i),s=cA(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}},kl={includes:Bg(!0),indexOf:Bg(!1)},fA=_t,Gf=rr,dA=ln,pA=kl.indexOf,hA=pu,qg=fA([].push),q0=function(e,r){var t=dA(e),n=0,i=[],a;for(a in t)!Gf(hA,a)&&Gf(t,a)&&qg(i,a);for(;r.length>n;)Gf(t,a=r[n++])&&(~pA(i,a)||qg(i,a));return i},Tv=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],vA=q0,mA=Tv,gA=mA.concat("length","prototype");ba.f=Object.getOwnPropertyNames||function(r){return vA(r,gA)};var hu={};hu.f=Object.getOwnPropertySymbols;var yA=Vn,bA=_t,_A=ba,wA=hu,SA=sr,TA=bA([].concat),G0=yA("Reflect","ownKeys")||function(r){var t=_A.f(SA(r)),n=wA.f;return n?TA(t,n(r)):t},Gg=rr,CA=G0,EA=ii,kA=qr,V0=function(e,r,t){for(var n=CA(r),i=kA.f,a=EA.f,s=0;s<n.length;s++){var c=n[s];!Gg(e,c)&&!(t&&Gg(t,c))&&i(e,c,a(r,c))}},RA=mt,$A=Bt,OA=/#|\.prototype\./,vu=function(e,r){var t=PA[IA(e)];return t==xA?!0:t==AA?!1:$A(r)?RA(r):!!r},IA=vu.normalize=function(e){return String(e).replace(OA,".").toLowerCase()},PA=vu.data={},AA=vu.NATIVE="N",xA=vu.POLYFILL="P",Rl=vu,Vf=Rt,MA=ii.f,NA=ji,LA=Gr,DA=gv,jA=V0,FA=Rl,wt=function(e,r){var t=e.target,n=e.global,i=e.stat,a,s,c,o,u,l;if(n?s=Vf:i?s=Vf[t]||DA(t,{}):s=(Vf[t]||{}).prototype,s)for(c in r){if(u=r[c],e.dontCallGetSet?(l=MA(s,c),o=l&&l.value):o=s[c],a=FA(n?c:t+(i?".":"#")+c,e.forced),!a&&o!==void 0){if(typeof u==typeof o)continue;jA(u,o)}(e.sham||o&&o.sham)&&NA(u,"sham",!0),LA(s,c,u,e)}},UA=qr.f,BA=rr,qA=Gt,Vg=qA("toStringTag"),Ui=function(e,r,t){e&&!t&&(e=e.prototype),e&&!BA(e,Vg)&&UA(e,Vg,{configurable:!0,value:r})},GA=wt,VA=Rt,zA=Ui;GA({global:!0},{Reflect:{}});zA(VA.Reflect,"Reflect",!0);var WA=ou,z0=Function.prototype,zg=z0.apply,Wg=z0.call,_a=typeof Reflect=="object"&&Reflect.apply||(WA?Wg.bind(zg):function(){return Wg.apply(zg,arguments)}),HA=_t,oo=HA([].slice),W0=_t,KA=En,JA=tr,YA=rr,Hg=oo,XA=ou,H0=Function,QA=W0([].concat),ZA=W0([].join),zf={},ex=function(e,r,t){if(!YA(zf,r)){for(var n=[],i=0;i<r;i++)n[i]="a["+i+"]";zf[r]=H0("C,a","return new C("+ZA(n,",")+")")}return zf[r](e,t)},tx=XA?H0.bind:function(r){var t=KA(this),n=t.prototype,i=Hg(arguments,1),a=function(){var c=QA(i,Hg(arguments));return this instanceof a?ex(t,c.length,c):t.apply(r,c)};return JA(n)&&(a.prototype=n),a},rx=Gt,nx=rx("toStringTag"),K0={};K0[nx]="z";var Cv=String(K0)==="[object z]",ix=Cv,ax=Bt,Gc=ai,sx=Gt,ox=sx("toStringTag"),ux=Object,cx=Gc(function(){return arguments}())=="Arguments",lx=function(e,r){try{return e[r]}catch{}},Bi=ix?Gc:function(e){var r,t,n;return e===void 0?"Undefined":e===null?"Null":typeof(t=lx(r=ux(e),ox))=="string"?t:cx?Gc(r):(n=Gc(r))=="Object"&&ax(r.callee)?"Arguments":n},fx=_t,dx=mt,J0=Bt,px=Bi,hx=Vn,vx=wv,Y0=function(){},mx=[],X0=hx("Reflect","construct"),Ev=/^\s*(?:class|function)\b/,gx=fx(Ev.exec),yx=!Ev.exec(Y0),So=function(r){if(!J0(r))return!1;try{return X0(Y0,mx,r),!0}catch{return!1}},Q0=function(r){if(!J0(r))return!1;switch(px(r)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return yx||!!gx(Ev,vx(r))}catch{return!0}};Q0.sham=!0;var $l=!X0||dx(function(){var e;return So(So.call)||!So(Object)||!So(function(){e=!0})||e})?Q0:So,bx=$l,_x=is,wx=TypeError,kv=function(e){if(bx(e))return e;throw wx(_x(e)+" is not a constructor")},Rv={},Sx=q0,Tx=Tv,mu=Object.keys||function(r){return Sx(r,Tx)},Cx=Yt,Ex=L0,kx=qr,Rx=sr,$x=ln,Ox=mu;Rv.f=Cx&&!Ex?Object.defineProperties:function(r,t){Rx(r);for(var n=$x(t),i=Ox(t),a=i.length,s=0,c;a>s;)kx.f(r,c=i[s++],n[c]);return r};var Ix=Vn,Z0=Ix("document","documentElement"),Px=sr,Ax=Rv,Kg=Tv,xx=pu,Mx=Z0,Nx=Cl,Lx=El,Jg=">",Yg="<",Np="prototype",Lp="script",eT=Lx("IE_PROTO"),Wf=function(){},tT=function(e){return Yg+Lp+Jg+e+Yg+"/"+Lp+Jg},Xg=function(e){e.write(tT("")),e.close();var r=e.parentWindow.Object;return e=null,r},Dx=function(){var e=Nx("iframe"),r="java"+Lp+":",t;return e.style.display="none",Mx.appendChild(e),e.src=String(r),t=e.contentWindow.document,t.open(),t.write(tT("document.F=Object")),t.close(),t.F},Gu,Vc=function(){try{Gu=new ActiveXObject("htmlfile")}catch{}Vc=typeof document<"u"?document.domain&&Gu?Xg(Gu):Dx():Xg(Gu);for(var e=Kg.length;e--;)delete Vc[Np][Kg[e]];return Vc()};xx[eT]=!0;var wa=Object.create||function(r,t){var n;return r!==null?(Wf[Np]=Px(r),n=new Wf,Wf[Np]=null,n[eT]=r):n=Vc(),t===void 0?n:Ax.f(n,t)},jx=wt,Fx=Vn,Hf=_a,Ux=tx,Qg=kv,Bx=sr,Zg=tr,qx=wa,rT=mt,$v=Fx("Reflect","construct"),Gx=Object.prototype,Vx=[].push,nT=rT(function(){function e(){}return!($v(function(){},[],e)instanceof e)}),iT=!rT(function(){$v(function(){})}),ey=nT||iT;jx({target:"Reflect",stat:!0,forced:ey,sham:ey},{construct:function(r,t){Qg(r),Bx(t);var n=arguments.length<3?r:Qg(arguments[2]);if(iT&&!nT)return $v(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 Hf(Vx,i,t),new(Hf(Ux,r,i))}var a=n.prototype,s=qx(Zg(a)?a:Gx),c=Hf(r,s,t);return Zg(c)?c:s}});var zx=wt,Wx=Mr,aT=mu,Hx=mt,Kx=Hx(function(){aT(1)});zx({target:"Object",stat:!0,forced:Kx},{keys:function(r){return aT(Wx(r))}});var Jx=Bi,Yx=String,br=function(e){if(Jx(e)==="Symbol")throw TypeError("Cannot convert a Symbol value to a string");return Yx(e)},Ov={},Xx=fu,Qx=qr,Zx=rs,uo=function(e,r,t){var n=Xx(r);n in e?Qx.f(e,n,Zx(0,t)):e[n]=t},ty=ss,eM=Ir,tM=uo,rM=Array,nM=Math.max,gu=function(e,r,t){for(var n=eM(e),i=ty(r,n),a=ty(t===void 0?n:t,n),s=rM(nM(a-i,0)),c=0;i<a;i++,c++)tM(s,c,e[i]);return s.length=c,s},iM=ai,aM=ln,sT=ba.f,sM=gu,oT=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],oM=function(e){try{return sT(e)}catch{return sM(oT)}};Ov.f=function(r){return oT&&iM(r)=="Window"?oM(r):sT(aM(r))};var ry=B0,uM=qr,ci=function(e,r,t){return t.get&&ry(t.get,r,{getter:!0}),t.set&&ry(t.set,r,{setter:!0}),uM.f(e,r,t)},Iv={},cM=Gt;Iv.f=cM;var lM=Rt,uT=lM,ny=uT,fM=rr,dM=Iv,pM=qr.f,cT=function(e){var r=ny.Symbol||(ny.Symbol={});fM(r,e)||pM(r,e,{value:dM.f(e)})},hM=qt,vM=Vn,mM=Gt,gM=Gr,yM=function(){var e=vM("Symbol"),r=e&&e.prototype,t=r&&r.valueOf,n=mM("toPrimitive");r&&!r[n]&&gM(r,n,function(i){return hM(t,this)},{arity:1})},bM=ai,_M=_t,Ol=function(e){if(bM(e)==="Function")return _M(e)},iy=Ol,wM=En,SM=ou,TM=iy(iy.bind),qi=function(e,r){return wM(e),r===void 0?e:SM?TM(e,r):function(){return e.apply(r,arguments)}},CM=ai,yu=Array.isArray||function(r){return CM(r)=="Array"},ay=yu,EM=$l,kM=tr,RM=Gt,$M=RM("species"),sy=Array,OM=function(e){var r;return ay(e)&&(r=e.constructor,EM(r)&&(r===sy||ay(r.prototype))?r=void 0:kM(r)&&(r=r[$M],r===null&&(r=void 0))),r===void 0?sy:r},IM=OM,Pv=function(e,r){return new(IM(e))(r===0?0:r)},PM=qi,AM=_t,xM=cu,MM=Mr,NM=Ir,LM=Pv,oy=AM([].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=MM(o),p=xM(d),h=PM(u,l),E=NM(p),x=0,I=f||LM,M=r?I(o,E):t||s?I(o,0):void 0,j,V;E>x;x++)if((c||x in p)&&(j=p[x],V=h(j,x,d),e))if(r)M[x]=V;else if(V)switch(e){case 3:return!0;case 5:return j;case 6:return x;case 2:oy(M,j)}else switch(e){case 4:return!1;case 7:oy(M,j)}return a?-1:n||i?i:M}},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)},Il=wt,Av=Rt,xv=qt,DM=_t,Hs=Yt,Ks=io,jM=mt,Sr=rr,FM=Di,Dp=sr,Pl=ln,Mv=fu,UM=br,jp=rs,Zo=wa,lT=mu,BM=ba,fT=Ov,qM=hu,dT=ii,pT=qr,GM=Rv,hT=uu,Kf=Gr,VM=ci,Nv=so,zM=El,vT=pu,uy=lu,WM=Gt,HM=Iv,KM=cT,JM=yM,YM=Ui,mT=kn,Al=fn.forEach,Qr=zM("hidden"),xl="Symbol",eu="prototype",XM=mT.set,cy=mT.getterFor(xl),Tn=Object[eu],Ka=Av.Symbol,Do=Ka&&Ka[eu],QM=Av.TypeError,Jf=Av.QObject,gT=dT.f,za=pT.f,yT=fT.f,ZM=hT.f,bT=DM([].push),Ai=Nv("symbols"),bu=Nv("op-symbols"),eN=Nv("wks"),Fp=!Jf||!Jf[eu]||!Jf[eu].findChild,Up=Hs&&jM(function(){return Zo(za({},"a",{get:function(){return za(this,"a",{value:7}).a}})).a!=7})?function(e,r,t){var n=gT(Tn,r);n&&delete Tn[r],za(e,r,t),n&&e!==Tn&&za(Tn,r,n)}:za,Yf=function(e,r){var t=Ai[e]=Zo(Do);return XM(t,{type:xl,tag:e,description:r}),Hs||(t.description=r),t},Ml=function(r,t,n){r===Tn&&Ml(bu,t,n),Dp(r);var i=Mv(t);return Dp(n),Sr(Ai,i)?(n.enumerable?(Sr(r,Qr)&&r[Qr][i]&&(r[Qr][i]=!1),n=Zo(n,{enumerable:jp(0,!1)})):(Sr(r,Qr)||za(r,Qr,jp(1,{})),r[Qr][i]=!0),Up(r,i,n)):za(r,i,n)},Lv=function(r,t){Dp(r);var n=Pl(t),i=lT(n).concat(ST(n));return Al(i,function(a){(!Hs||xv(Bp,n,a))&&Ml(r,a,n[a])}),r},tN=function(r,t){return t===void 0?Zo(r):Lv(Zo(r),t)},Bp=function(r){var t=Mv(r),n=xv(ZM,this,t);return this===Tn&&Sr(Ai,t)&&!Sr(bu,t)?!1:n||!Sr(this,t)||!Sr(Ai,t)||Sr(this,Qr)&&this[Qr][t]?n:!0},_T=function(r,t){var n=Pl(r),i=Mv(t);if(!(n===Tn&&Sr(Ai,i)&&!Sr(bu,i))){var a=gT(n,i);return a&&Sr(Ai,i)&&!(Sr(n,Qr)&&n[Qr][i])&&(a.enumerable=!0),a}},wT=function(r){var t=yT(Pl(r)),n=[];return Al(t,function(i){!Sr(Ai,i)&&!Sr(vT,i)&&bT(n,i)}),n},ST=function(e){var r=e===Tn,t=yT(r?bu:Pl(e)),n=[];return Al(t,function(i){Sr(Ai,i)&&(!r||Sr(Tn,i))&&bT(n,Ai[i])}),n};Ks||(Ka=function(){if(FM(Do,this))throw QM("Symbol is not a constructor");var r=!arguments.length||arguments[0]===void 0?void 0:UM(arguments[0]),t=uy(r),n=function(i){this===Tn&&xv(n,bu,i),Sr(this,Qr)&&Sr(this[Qr],t)&&(this[Qr][t]=!1),Up(this,t,jp(1,i))};return Hs&&Fp&&Up(Tn,t,{configurable:!0,set:n}),Yf(t,r)},Do=Ka[eu],Kf(Do,"toString",function(){return cy(this).tag}),Kf(Ka,"withoutSetter",function(e){return Yf(uy(e),e)}),hT.f=Bp,pT.f=Ml,GM.f=Lv,dT.f=_T,BM.f=fT.f=wT,qM.f=ST,HM.f=function(e){return Yf(WM(e),e)},Hs&&(VM(Do,"description",{configurable:!0,get:function(){return cy(this).description}}),Kf(Tn,"propertyIsEnumerable",Bp,{unsafe:!0})));Il({global:!0,constructor:!0,wrap:!0,forced:!Ks,sham:!Ks},{Symbol:Ka});Al(lT(eN),function(e){KM(e)});Il({target:xl,stat:!0,forced:!Ks},{useSetter:function(){Fp=!0},useSimple:function(){Fp=!1}});Il({target:"Object",stat:!0,forced:!Ks,sham:!Hs},{create:tN,defineProperty:Ml,defineProperties:Lv,getOwnPropertyDescriptor:_T});Il({target:"Object",stat:!0,forced:!Ks},{getOwnPropertyNames:wT});JM();YM(Ka,xl);vT[Qr]=!0;var rN=io,TT=rN&&!!Symbol.for&&!!Symbol.keyFor,nN=wt,iN=Vn,aN=rr,sN=br,CT=so,oN=TT,Xf=CT("string-to-symbol-registry"),uN=CT("symbol-to-string-registry");nN({target:"Symbol",stat:!0,forced:!oN},{for:function(e){var r=sN(e);if(aN(Xf,r))return Xf[r];var t=iN("Symbol")(r);return Xf[r]=t,uN[t]=r,t}});var cN=wt,lN=rr,fN=ao,dN=is,pN=so,hN=TT,ly=pN("symbol-to-string-registry");cN({target:"Symbol",stat:!0,forced:!hN},{keyFor:function(r){if(!fN(r))throw TypeError(dN(r)+" is not a symbol");if(lN(ly,r))return ly[r]}});var vN=_t,fy=yu,mN=Bt,dy=ai,gN=br,py=vN([].push),yN=function(e){if(mN(e))return e;if(fy(e)){for(var r=e.length,t=[],n=0;n<r;n++){var i=e[n];typeof i=="string"?py(t,i):(typeof i=="number"||dy(i)=="Number"||dy(i)=="String")&&py(t,gN(i))}var a=t.length,s=!0;return function(c,o){if(s)return s=!1,o;if(fy(this))return o;for(var u=0;u<a;u++)if(t[u]===c)return o}}},bN=wt,ET=Vn,kT=_a,_N=qt,_u=_t,RT=mt,hy=Bt,vy=ao,$T=oo,wN=yN,SN=io,TN=String,da=ET("JSON","stringify"),Vu=_u(/./.exec),my=_u("".charAt),CN=_u("".charCodeAt),EN=_u("".replace),kN=_u(1 .toString),RN=/[\uD800-\uDFFF]/g,gy=/^[\uD800-\uDBFF]$/,yy=/^[\uDC00-\uDFFF]$/,by=!SN||RT(function(){var e=ET("Symbol")();return da([e])!="[null]"||da({a:e})!="{}"||da(Object(e))!="{}"}),_y=RT(function(){return da("\uDF06\uD834")!=='"\\udf06\\ud834"'||da("\uDEAD")!=='"\\udead"'}),$N=function(e,r){var t=$T(arguments),n=wN(r);if(!(!hy(n)&&(e===void 0||vy(e))))return t[1]=function(i,a){if(hy(n)&&(a=_N(n,this,TN(i),a)),!vy(a))return a},kT(da,null,t)},ON=function(e,r,t){var n=my(t,r-1),i=my(t,r+1);return Vu(gy,e)&&!Vu(yy,i)||Vu(yy,e)&&!Vu(gy,n)?"\\u"+kN(CN(e,0),16):e};da&&bN({target:"JSON",stat:!0,arity:3,forced:by||_y},{stringify:function(r,t,n){var i=$T(arguments),a=kT(by?$N:da,null,i);return _y&&typeof a=="string"?EN(a,RN,ON):a}});var IN=wt,PN=io,AN=mt,OT=hu,xN=Mr,MN=!PN||AN(function(){OT.f(1)});IN({target:"Object",stat:!0,forced:MN},{getOwnPropertySymbols:function(r){var t=OT.f;return t?t(xN(r)):[]}});var NN=mt,LN=Gt,DN=no,jN=LN("species"),wu=function(e){return DN>=51||!NN(function(){var r=[],t=r.constructor={};return t[jN]=function(){return{foo:1}},r[e](Boolean).foo!==1})},FN=wt,UN=fn.filter,BN=wu,qN=BN("filter");FN({target:"Array",proto:!0,forced:!qN},{filter:function(r){return UN(this,r,arguments.length>1?arguments[1]:void 0)}});var GN=wt,VN=mt,zN=ln,IT=ii.f,PT=Yt,WN=!PT||VN(function(){IT(1)});GN({target:"Object",stat:!0,forced:WN,sham:!PT},{getOwnPropertyDescriptor:function(r,t){return IT(zN(r),t)}});var HN=wt,KN=Yt,JN=G0,YN=ln,XN=ii,QN=uo;HN({target:"Object",stat:!0,sham:!KN},{getOwnPropertyDescriptors:function(r){for(var t=YN(r),n=XN.f,i=JN(t),a={},s=0,c,o;i.length>s;)o=n(t,c=i[s++]),o!==void 0&&QN(a,c,o);return a}});var AT={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})(AT);var Su=AT.exports,xT={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})(xT);var os=xT.exports,MT={exports:{}},NT={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})(NT);var Dv=NT.exports;(function(e){var r=Dv;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})(MT);var li=MT.exports,LT={exports:{}},DT={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})(DT);var Rn=DT.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})(LT);var fi=LT.exports,jT={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})(jT);var $n=jT.exports,FT={exports:{}},UT={exports:{}},BT={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})(BT);var ZN=BT.exports;(function(e){var r=Rn.default,t=ZN;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})(UT);var qT=UT.exports;(function(e){var r=qT;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})(FT);var us=FT.exports,GT={exports:{}};(function(e){var r=qT;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})(GT);var Sa=GT.exports,VT={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})(VT);var di=VT.exports,eL=Cv,tL=Bi,rL=eL?{}.toString:function(){return"[object "+tL(this)+"]"},nL=Cv,iL=Gr,aL=rL;nL||iL(Object.prototype,"toString",aL,{unsafe:!0});var sL=ai,Nl=typeof process<"u"&&sL(process)=="process",oL=_t,uL=En,cL=function(e,r,t){try{return oL(uL(Object.getOwnPropertyDescriptor(e,r)[t]))}catch{}},lL=Bt,fL=String,dL=TypeError,pL=function(e){if(typeof e=="object"||lL(e))return e;throw dL("Can't set "+fL(e)+" as a prototype")},hL=cL,vL=sr,mL=pL,co=Object.setPrototypeOf||("__proto__"in{}?function(){var e=!1,r={},t;try{t=hL(Object.prototype,"__proto__","set"),t(r,[]),e=r instanceof Array}catch{}return function(i,a){return vL(i),mL(a),e?t(i,a):i.__proto__=a,i}}():void 0),gL=Vn,yL=ci,bL=Gt,_L=Yt,wy=bL("species"),Ll=function(e){var r=gL(e);_L&&r&&!r[wy]&&yL(r,wy,{configurable:!0,get:function(){return this}})},wL=Di,SL=TypeError,cs=function(e,r){if(wL(r,e))return e;throw SL("Incorrect invocation")},Sy=sr,TL=kv,CL=si,EL=Gt,kL=EL("species"),jv=function(e,r){var t=Sy(e).constructor,n;return t===void 0||CL(n=Sy(t)[kL])?r:TL(n)},RL=TypeError,Fv=function(e,r){if(e<r)throw RL("Not enough arguments");return e},$L=ns,zT=/(?:ipad|iphone|ipod).*applewebkit/i.test($L),cn=Rt,OL=_a,IL=qi,Ty=Bt,PL=rr,WT=mt,Cy=Z0,AL=oo,Ey=Cl,xL=Fv,ML=zT,NL=Nl,qp=cn.setImmediate,Gp=cn.clearImmediate,LL=cn.process,Qf=cn.Dispatch,DL=cn.Function,ky=cn.MessageChannel,jL=cn.String,Zf=0,Wo={},Ry="onreadystatechange",tu,Da,ed,td;WT(function(){tu=cn.location});var Uv=function(e){if(PL(Wo,e)){var r=Wo[e];delete Wo[e],r()}},rd=function(e){return function(){Uv(e)}},$y=function(e){Uv(e.data)},Oy=function(e){cn.postMessage(jL(e),tu.protocol+"//"+tu.host)};(!qp||!Gp)&&(qp=function(r){xL(arguments.length,1);var t=Ty(r)?r:DL(r),n=AL(arguments,1);return Wo[++Zf]=function(){OL(t,void 0,n)},Da(Zf),Zf},Gp=function(r){delete Wo[r]},NL?Da=function(e){LL.nextTick(rd(e))}:Qf&&Qf.now?Da=function(e){Qf.now(rd(e))}:ky&&!ML?(ed=new ky,td=ed.port2,ed.port1.onmessage=$y,Da=IL(td.postMessage,td)):cn.addEventListener&&Ty(cn.postMessage)&&!cn.importScripts&&tu&&tu.protocol!=="file:"&&!WT(Oy)?(Da=Oy,cn.addEventListener("message",$y,!1)):Ry in Ey("script")?Da=function(e){Cy.appendChild(Ey("script"))[Ry]=function(){Cy.removeChild(this),Uv(e)}}:Da=function(e){setTimeout(rd(e),0)});var HT={set:qp,clear:Gp},KT=function(){this.head=null,this.tail=null};KT.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 JT=KT,FL=ns,UL=/ipad|iphone|ipod/i.test(FL)&&typeof Pebble<"u",BL=ns,qL=/web0s(?!.*chrome)/i.test(BL),Ya=Rt,Iy=qi,GL=ii.f,nd=HT.set,VL=JT,zL=zT,WL=UL,HL=qL,id=Nl,Py=Ya.MutationObserver||Ya.WebKitMutationObserver,Ay=Ya.document,xy=Ya.process,zu=Ya.Promise,My=GL(Ya,"queueMicrotask"),Vp=My&&My.value,gs,ad,sd,Wu,Ny;if(!Vp){var Hu=new VL,Ku=function(){var e,r;for(id&&(e=xy.domain)&&e.exit();r=Hu.get();)try{r()}catch(t){throw Hu.head&&gs(),t}e&&e.enter()};!zL&&!id&&!HL&&Py&&Ay?(ad=!0,sd=Ay.createTextNode(""),new Py(Ku).observe(sd,{characterData:!0}),gs=function(){sd.data=ad=!ad}):!WL&&zu&&zu.resolve?(Wu=zu.resolve(void 0),Wu.constructor=zu,Ny=Iy(Wu.then,Wu),gs=function(){Ny(Ku)}):id?gs=function(){xy.nextTick(Ku)}:(nd=Iy(nd,Ya),gs=function(){nd(Ku)}),Vp=function(e){Hu.head||gs(),Hu.add(e)}}var KL=Vp,JL=function(e,r){try{arguments.length==1?console.error(e):console.error(e,r)}catch{}},Bv=function(e){try{return{error:!1,value:e()}}catch(r){return{error:!0,value:r}}},YL=Rt,Dl=YL.Promise,YT=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",XL=YT,QL=Nl,ZL=!XL&&!QL&&typeof window=="object"&&typeof document=="object",eD=Rt,Ho=Dl,tD=Bt,rD=Rl,nD=wv,iD=Gt,aD=ZL,sD=YT,od=no;Ho&&Ho.prototype;var oD=iD("species"),zp=!1,XT=tD(eD.PromiseRejectionEvent),uD=rD("Promise",function(){var e=nD(Ho),r=e!==String(Ho);if(!r&&od===66)return!0;if(!od||od<51||!/native code/.test(e)){var t=new Ho(function(a){a(1)}),n=function(a){a(function(){},function(){})},i=t.constructor={};if(i[oD]=n,zp=t.then(function(){})instanceof n,!zp)return!0}return!r&&(aD||sD)&&!XT}),Tu={CONSTRUCTOR:uD,REJECTION_EVENT:XT,SUBCLASSING:zp},lo={},Ly=En,cD=TypeError,lD=function(e){var r,t;this.promise=new e(function(n,i){if(r!==void 0||t!==void 0)throw cD("Bad Promise constructor");r=n,t=i}),this.resolve=Ly(r),this.reject=Ly(t)};lo.f=function(e){return new lD(e)};var fD=wt,il=Nl,ma=Rt,Js=qt,Dy=Gr,jy=co,dD=Ui,pD=Ll,hD=En,zc=Bt,vD=tr,mD=cs,gD=jv,QT=HT.set,qv=KL,yD=JL,bD=Bv,_D=JT,ZT=kn,al=Dl,Gv=Tu,eC=lo,jl="Promise",tC=Gv.CONSTRUCTOR,wD=Gv.REJECTION_EVENT,SD=Gv.SUBCLASSING,ud=ZT.getterFor(jl),TD=ZT.set,Rs=al&&al.prototype,Wa=al,Ju=Rs,rC=ma.TypeError,Wp=ma.document,Vv=ma.process,Hp=eC.f,CD=Hp,ED=!!(Wp&&Wp.createEvent&&ma.dispatchEvent),nC="unhandledrejection",kD="rejectionhandled",Fy=0,iC=1,RD=2,zv=1,aC=2,Yu,Uy,$D,By,sC=function(e){var r;return vD(e)&&zc(r=e.then)?r:!1},oC=function(e,r){var t=r.value,n=r.state==iC,i=n?e.ok:e.fail,a=e.resolve,s=e.reject,c=e.domain,o,u,l;try{i?(n||(r.rejection===aC&&ID(r),r.rejection=zv),i===!0?o=t:(c&&c.enter(),o=i(t),c&&(c.exit(),l=!0)),o===e.promise?s(rC("Promise-chain cycle")):(u=sC(o))?Js(u,o,a,s):a(o)):s(t)}catch(f){c&&!l&&c.exit(),s(f)}},uC=function(e,r){e.notified||(e.notified=!0,qv(function(){for(var t=e.reactions,n;n=t.get();)oC(n,e);e.notified=!1,r&&!e.rejection&&OD(e)}))},cC=function(e,r,t){var n,i;ED?(n=Wp.createEvent("Event"),n.promise=r,n.reason=t,n.initEvent(e,!1,!0),ma.dispatchEvent(n)):n={promise:r,reason:t},!wD&&(i=ma["on"+e])?i(n):e===nC&&yD("Unhandled promise rejection",t)},OD=function(e){Js(QT,ma,function(){var r=e.facade,t=e.value,n=qy(e),i;if(n&&(i=bD(function(){il?Vv.emit("unhandledRejection",t,r):cC(nC,r,t)}),e.rejection=il||qy(e)?aC:zv,i.error))throw i.value})},qy=function(e){return e.rejection!==zv&&!e.parent},ID=function(e){Js(QT,ma,function(){var r=e.facade;il?Vv.emit("rejectionHandled",r):cC(kD,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=RD,uC(e,!0))},Kp=function(e,r,t){if(!e.done){e.done=!0,t&&(e=t);try{if(e.facade===r)throw rC("Promise can't be resolved itself");var n=sC(r);n?qv(function(){var i={done:!1};try{Js(n,r,As(Kp,i,e),As(Ls,i,e))}catch(a){Ls(i,a,e)}}):(e.value=r,e.state=iC,uC(e,!1))}catch(i){Ls({done:!1},i,e)}}};if(tC&&(Wa=function(r){mD(this,Ju),hD(r),Js(Yu,this);var t=ud(this);try{r(As(Kp,t),As(Ls,t))}catch(n){Ls(t,n)}},Ju=Wa.prototype,Yu=function(r){TD(this,{type:jl,done:!1,notified:!1,parent:!1,reactions:new _D,rejection:!1,state:Fy,value:void 0})},Yu.prototype=Dy(Ju,"then",function(r,t){var n=ud(this),i=Hp(gD(this,Wa));return n.parent=!0,i.ok=zc(r)?r:!0,i.fail=zc(t)&&t,i.domain=il?Vv.domain:void 0,n.state==Fy?n.reactions.add(i):qv(function(){oC(i,n)}),i.promise}),Uy=function(){var e=new Yu,r=ud(e);this.promise=e,this.resolve=As(Kp,r),this.reject=As(Ls,r)},eC.f=Hp=function(e){return e===Wa||e===$D?new Uy(e):CD(e)},zc(al)&&Rs!==Object.prototype)){By=Rs.then,SD||Dy(Rs,"then",function(r,t){var n=this;return new Wa(function(i,a){Js(By,n,i,a)}).then(r,t)},{unsafe:!0});try{delete Rs.constructor}catch{}jy&&jy(Rs,Ju)}fD({global:!0,constructor:!0,wrap:!0,forced:tC},{Promise:Wa});dD(Wa,jl,!1);pD(jl);var Cu={},PD=Gt,AD=Cu,xD=PD("iterator"),MD=Array.prototype,Wv=function(e){return e!==void 0&&(AD.Array===e||MD[xD]===e)},ND=Bi,Gy=as,LD=si,DD=Cu,jD=Gt,FD=jD("iterator"),Eu=function(e){if(!LD(e))return Gy(e,FD)||Gy(e,"@@iterator")||DD[ND(e)]},UD=qt,BD=En,qD=sr,GD=is,VD=Eu,zD=TypeError,Fl=function(e,r){var t=arguments.length<2?VD(e):r;if(BD(t))return qD(UD(t,e));throw zD(GD(e)+" is not iterable")},WD=qt,Vy=sr,HD=as,lC=function(e,r,t){var n,i;Vy(e);try{if(n=HD(e,"return"),!n){if(r==="throw")throw t;return t}n=WD(n,e)}catch(a){i=!0,n=a}if(r==="throw")throw t;if(i)throw n;return Vy(n),t},KD=qi,JD=qt,YD=sr,XD=is,QD=Wv,ZD=Ir,zy=Di,e2=Fl,t2=Eu,Wy=lC,r2=TypeError,Wc=function(e,r){this.stopped=e,this.result=r},Hy=Wc.prototype,Ul=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=KD(r,n),u,l,f,d,p,h,E,x=function(M){return u&&Wy(u,"normal",M),new Wc(!0,M)},I=function(M){return i?(YD(M),c?o(M[0],M[1],x):o(M[0],M[1])):c?o(M,x):o(M)};if(a)u=e.iterator;else if(s)u=e;else{if(l=t2(e),!l)throw r2(XD(e)+" is not iterable");if(QD(l)){for(f=0,d=ZD(e);d>f;f++)if(p=I(e[f]),p&&zy(Hy,p))return p;return new Wc(!1)}u=e2(e,l)}for(h=a?e.next:u.next;!(E=JD(h,u)).done;){try{p=I(E.value)}catch(M){Wy(u,"throw",M)}if(typeof p=="object"&&p&&zy(Hy,p))return p}return new Wc(!1)},n2=Gt,fC=n2("iterator"),dC=!1;try{var i2=0,Ky={next:function(){return{done:!!i2++}},return:function(){dC=!0}};Ky[fC]=function(){return this},Array.from(Ky,function(){throw 2})}catch{}var Bl=function(e,r){if(!r&&!dC)return!1;var t=!1;try{var n={};n[fC]=function(){return{next:function(){return{done:t=!0}}}},e(n)}catch{}return t},a2=Dl,s2=Bl,o2=Tu.CONSTRUCTOR,pC=o2||!s2(function(e){a2.all(e).then(void 0,function(){})}),u2=wt,c2=qt,l2=En,f2=lo,d2=Bv,p2=Ul,h2=pC;u2({target:"Promise",stat:!0,forced:h2},{all:function(r){var t=this,n=f2.f(t),i=n.resolve,a=n.reject,s=d2(function(){var c=l2(t.resolve),o=[],u=0,l=1;p2(r,function(f){var d=u++,p=!1;l++,c2(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 v2=wt,m2=Tu.CONSTRUCTOR,Jp=Dl,g2=Vn,y2=Bt,b2=Gr,Jy=Jp&&Jp.prototype;v2({target:"Promise",proto:!0,forced:m2,real:!0},{catch:function(e){return this.then(void 0,e)}});if(y2(Jp)){var Yy=g2("Promise").prototype.catch;Jy.catch!==Yy&&b2(Jy,"catch",Yy,{unsafe:!0})}var _2=wt,w2=qt,S2=En,T2=lo,C2=Bv,E2=Ul,k2=pC;_2({target:"Promise",stat:!0,forced:k2},{race:function(r){var t=this,n=T2.f(t),i=n.reject,a=C2(function(){var s=S2(t.resolve);E2(r,function(c){w2(s,t,c).then(n.resolve,i)})});return a.error&&i(a.value),n.promise}});var R2=wt,$2=qt,O2=lo,I2=Tu.CONSTRUCTOR;R2({target:"Promise",stat:!0,forced:I2},{reject:function(r){var t=O2.f(this);return $2(t.reject,void 0,r),t.promise}});var P2=sr,A2=tr,x2=lo,M2=function(e,r){if(P2(e),A2(r)&&r.constructor===e)return r;var t=x2.f(e),n=t.resolve;return n(r),t.promise},N2=wt,L2=Vn,D2=Tu.CONSTRUCTOR,j2=M2;L2("Promise");N2({target:"Promise",stat:!0,forced:D2},{resolve:function(r){return j2(this,r)}});var F2=wt,U2=fn.map,B2=wu,q2=B2("map");F2({target:"Array",proto:!0,forced:!q2},{map:function(r){return U2(this,r,arguments.length>1?arguments[1]:void 0)}});var hC={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},G2=Cl,cd=G2("span").classList,Xy=cd&&cd.constructor&&cd.constructor.prototype,vC=Xy===Object.prototype?void 0:Xy,V2=mt,ql=function(e,r){var t=[][e];return!!t&&V2(function(){t.call(null,r||function(){return 1},1)})},z2=fn.forEach,W2=ql,H2=W2("forEach"),K2=H2?[].forEach:function(r){return z2(this,r,arguments.length>1?arguments[1]:void 0)},Qy=Rt,Zy=hC,J2=vC,ld=K2,Y2=ji,mC=function(e){if(e&&e.forEach!==ld)try{Y2(e,"forEach",ld)}catch{e.forEach=ld}};for(var fd in Zy)Zy[fd]&&mC(Qy[fd]&&Qy[fd].prototype);mC(J2);var gC={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,Se){be[Te]=Se.value},c=typeof Symbol=="function"?Symbol:{},o=c.iterator||"@@iterator",u=c.asyncIterator||"@@asyncIterator",l=c.toStringTag||"@@toStringTag";function f(be,Te,Se){return Object.defineProperty(be,Te,{value:Se,enumerable:!0,configurable:!0,writable:!0}),be[Te]}try{f({},"")}catch{f=function(Se,ge,$e){return Se[ge]=$e}}function d(be,Te,Se,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,Se,G)}),De}function p(be,Te,Se){try{return{type:"normal",arg:be.call(Te,Se)}}catch(ge){return{type:"throw",arg:ge}}}n.wrap=d;var h={};function E(){}function x(){}function I(){}var M={};f(M,o,function(){return this});var j=Object.getPrototypeOf,V=j&&j(j(ae([])));V&&V!==i&&a.call(V,o)&&(M=V);var ie=I.prototype=E.prototype=Object.create(M);function oe(be){["next","throw","return"].forEach(function(Te){f(be,Te,function(Se){return this._invoke(Te,Se)})})}function J(be,Te){function Se($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){Se("next",te,G,Qe)},function(te){Se("throw",te,G,Qe)}):Te.resolve(je).then(function(te){ut.value=te,G(ut)},function(te){return Se("throw",te,G,Qe)})}Qe(Et.arg)}var ge;s(this,"_invoke",{value:function(De,G){function Qe(){return new Te(function(Et,ut){Se(De,G,Et,ut)})}return ge=ge?ge.then(Qe,Qe):Qe()}})}function L(be,Te,Se){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 We()}for(Se.method=$e,Se.arg=De;;){var G=Se.delegate;if(G){var Qe=Y(G,Se);if(Qe){if(Qe===h)continue;return Qe}}if(Se.method==="next")Se.sent=Se._sent=Se.arg;else if(Se.method==="throw"){if(ge==="suspendedStart")throw ge="completed",Se.arg;Se.dispatchException(Se.arg)}else Se.method==="return"&&Se.abrupt("return",Se.arg);ge="executing";var Et=p(be,Te,Se);if(Et.type==="normal"){if(ge=Se.done?"completed":"suspendedYield",Et.arg===h)continue;return{value:Et.arg,done:Se.done}}Et.type==="throw"&&(ge="completed",Se.method="throw",Se.arg=Et.arg)}}}function Y(be,Te){var Se=Te.method,ge=be.iterator[Se];if(ge===void 0)return Te.delegate=null,Se==="throw"&&be.iterator.return&&(Te.method="return",Te.arg=void 0,Y(be,Te),Te.method==="throw")||Se!=="return"&&(Te.method="throw",Te.arg=new TypeError("The iterator does not provide a '"+Se+"' 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 Se=-1,ge=function $e(){for(;++Se<be.length;)if(a.call(be,Se))return $e.value=be[Se],$e.done=!1,$e;return $e.value=void 0,$e.done=!0,$e};return ge.next=ge}}return{next:We}}function We(){return{value:void 0,done:!0}}return x.prototype=I,s(ie,"constructor",{value:I,configurable:!0}),s(I,"constructor",{value:x,configurable:!0}),x.displayName=f(I,l,"GeneratorFunction"),n.isGeneratorFunction=function(be){var Te=typeof be=="function"&&be.constructor;return!!Te&&(Te===x||(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,Se,ge,$e){$e===void 0&&($e=Promise);var De=new J(d(be,Te,Se,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),Se=[];for(var ge in Te)Se.push(ge);return Se.reverse(),function $e(){for(;Se.length;){var De=Se.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 Se in this)Se.charAt(0)==="t"&&a.call(this,Se)&&!isNaN(+Se.slice(1))&&(this[Se]=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 Se=this;function ge(ut,je){return G.type="throw",G.arg=Te,Se.next=ut,je&&(Se.method="next",Se.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,Se){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<=Se&&Se<=De.finallyLoc&&(De=null);var G=De?De.completion:{};return G.type=Te,G.arg=Se,De?(this.method="next",this.next=De.finallyLoc,h):this.complete(G)},complete:function(Te,Se){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"&&Se&&(this.next=Se),h},finish:function(Te){for(var Se=this.tryEntries.length-1;Se>=0;--Se){var ge=this.tryEntries[Se];if(ge.finallyLoc===Te)return this.complete(ge.completion,ge.afterLoc),ye(ge),h}},catch:function(Te){for(var Se=this.tryEntries.length-1;Se>=0;--Se){var ge=this.tryEntries[Se];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,Se,ge){return this.delegate={iterator:ae(Te),resultName:Se,nextLoc:ge},this.method==="next"&&(this.arg=void 0),h}},n}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(gC);var X2=gC.exports,Hc=X2(),ku=Hc;try{regeneratorRuntime=Hc}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=Hc:Function("r","regeneratorRuntime = r")(Hc)}var Q2=TypeError,Z2=9007199254740991,yC=function(e){if(e>Z2)throw Q2("Maximum allowed index exceeded");return e},ej=wt,tj=mt,rj=yu,nj=tr,ij=Mr,aj=Ir,eb=yC,tb=uo,sj=Pv,oj=wu,uj=Gt,cj=no,bC=uj("isConcatSpreadable"),lj=cj>=51||!tj(function(){var e=[];return e[bC]=!1,e.concat()[0]!==e}),fj=function(e){if(!nj(e))return!1;var r=e[bC];return r!==void 0?!!r:rj(e)},dj=!lj||!oj("concat");ej({target:"Array",proto:!0,arity:1,forced:dj},{concat:function(r){var t=ij(this),n=sj(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],fj(u))for(o=aj(u),eb(i+o),s=0;s<o;s++,i++)s in u&&tb(n,i,u[s]);else eb(i+1),tb(n,i++,u);return n.length=i,n}});var pj=sr,hj=lC,vj=function(e,r,t,n){try{return n?r(pj(t)[0],t[1]):r(t)}catch(i){hj(e,"throw",i)}},mj=qi,gj=qt,yj=Mr,bj=vj,_j=Wv,wj=$l,Sj=Ir,rb=uo,Tj=Fl,Cj=Eu,nb=Array,_C=function(r){var t=yj(r),n=wj(this),i=arguments.length,a=i>1?arguments[1]:void 0,s=a!==void 0;s&&(a=mj(a,i>2?arguments[2]:void 0));var c=Cj(t),o=0,u,l,f,d,p,h;if(c&&!(this===nb&&_j(c)))for(d=Tj(t,c),p=d.next,l=n?new this:[];!(f=gj(p,d)).done;o++)h=s?bj(d,a,[f.value,o],!0):f.value,rb(l,o,h);else for(u=Sj(t),l=n?new this(u):nb(u);u>o;o++)h=s?a(t[o],o):t[o],rb(l,o,h);return l.length=o,l},Ej=wt,kj=_C,Rj=Bl,$j=!Rj(function(e){Array.from(e)});Ej({target:"Array",stat:!0,forced:$j},{from:kj});var Hv=_t,Oj=ui,Ij=br,Pj=oi,Aj=Hv("".charAt),ib=Hv("".charCodeAt),xj=Hv("".slice),ab=function(e){return function(r,t){var n=Ij(Pj(r)),i=Oj(t),a=n.length,s,c;return i<0||i>=a?e?"":void 0:(s=ib(n,i),s<55296||s>56319||i+1===a||(c=ib(n,i+1))<56320||c>57343?e?Aj(n,i):s:e?xj(n,i,i+2):(s-55296<<10)+(c-56320)+65536)}},Kv={codeAt:ab(!1),charAt:ab(!0)},Mj=mt,Nj=!Mj(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),Lj=rr,Dj=Bt,jj=Mr,Fj=El,Uj=Nj,sb=Fj("IE_PROTO"),Yp=Object,Bj=Yp.prototype,Gl=Uj?Yp.getPrototypeOf:function(e){var r=jj(e);if(Lj(r,sb))return r[sb];var t=r.constructor;return Dj(t)&&r instanceof t?t.prototype:r instanceof Yp?Bj:null},qj=mt,Gj=Bt,Vj=tr,ob=Gl,zj=Gr,Wj=Gt,Xp=Wj("iterator"),wC=!1,Xa,dd,pd;[].keys&&(pd=[].keys(),"next"in pd?(dd=ob(ob(pd)),dd!==Object.prototype&&(Xa=dd)):wC=!0);var Hj=!Vj(Xa)||qj(function(){var e={};return Xa[Xp].call(e)!==e});Hj&&(Xa={});Gj(Xa[Xp])||zj(Xa,Xp,function(){return this});var SC={IteratorPrototype:Xa,BUGGY_SAFARI_ITERATORS:wC},Kj=SC.IteratorPrototype,Jj=wa,Yj=rs,Xj=Ui,Qj=Cu,Zj=function(){return this},TC=function(e,r,t,n){var i=r+" Iterator";return e.prototype=Jj(Kj,{next:Yj(+!n,t)}),Xj(e,i,!1),Qj[i]=Zj,e},eF=wt,tF=qt,CC=du,rF=Bt,nF=TC,ub=Gl,cb=co,iF=Ui,aF=ji,hd=Gr,sF=Gt,oF=Cu,EC=SC,uF=CC.PROPER,cF=CC.CONFIGURABLE,lb=EC.IteratorPrototype,Xu=EC.BUGGY_SAFARI_ITERATORS,To=sF("iterator"),fb="keys",Co="values",db="entries",lF=function(){return this},Jv=function(e,r,t,n,i,a,s){nF(t,r,n);var c=function(I){if(I===i&&d)return d;if(!Xu&&I in l)return l[I];switch(I){case fb:return function(){return new t(this,I)};case Co:return function(){return new t(this,I)};case db: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=!Xu&&f||c(i),p=r=="Array"&&l.entries||f,h,E,x;if(p&&(h=ub(p.call(new e)),h!==Object.prototype&&h.next&&(ub(h)!==lb&&(cb?cb(h,lb):rF(h[To])||hd(h,To,lF)),iF(h,o,!0))),uF&&i==Co&&f&&f.name!==Co&&(cF?aF(l,"name",Co):(u=!0,d=function(){return tF(f,this)})),i)if(E={values:c(Co),keys:a?d:c(fb),entries:c(db)},s)for(x in E)(Xu||u||!(x in l))&&hd(l,x,E[x]);else eF({target:r,proto:!0,forced:Xu||u},E);return l[To]!==d&&hd(l,To,d,{name:i}),oF[r]=d,E},Yv=function(e,r){return{value:e,done:r}},fF=Kv.charAt,dF=br,kC=kn,pF=Jv,pb=Yv,RC="String Iterator",hF=kC.set,vF=kC.getterFor(RC);pF(String,"String",function(e){hF(this,{type:RC,string:dF(e),index:0})},function(){var r=vF(this),t=r.string,n=r.index,i;return n>=t.length?pb(void 0,!0):(i=fF(t,n),r.index+=i.length,pb(i,!1))});var $C={exports:{}};(function(e){(function(r,t){e.exports?e.exports=t():r.log=t()})(Ve,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,x){var I=E[x];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,x){for(var I=0;I<i.length;I++){var M=i[I];this[M]=I<E?r:this.methodFactory(M,E,x)}this.log=this.debug}function u(E,x,I){return function(){typeof console!==t&&(o.call(this,x,I),this[E].apply(this,arguments))}}function l(E,x,I){return c(E)||u.apply(this,arguments)}function f(E,x,I){var M=this,j;x=x??"WARN";var V="loglevel";typeof E=="string"?V+=":"+E:typeof E=="symbol"&&(V=void 0);function ie(Y){var Z=(i[Y]||"silent").toUpperCase();if(!(typeof window===t||!V)){try{window.localStorage[V]=Z;return}catch{}try{window.document.cookie=encodeURIComponent(V)+"="+Z+";"}catch{}}}function oe(){var Y;if(!(typeof window===t||!V)){try{Y=window.localStorage[V]}catch{}if(typeof Y===t)try{var Z=window.document.cookie,ye=Z.indexOf(encodeURIComponent(V)+"=");ye!==-1&&(Y=/^([^;]+)/.exec(Z.slice(ye))[1])}catch{}return M.levels[Y]===void 0&&(Y=void 0),Y}}function J(){if(!(typeof window===t||!V)){try{window.localStorage.removeItem(V);return}catch{}try{window.document.cookie=encodeURIComponent(V)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}M.name=E,M.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},M.methodFactory=I||l,M.getLevel=function(){return j},M.setLevel=function(Y,Z){if(typeof Y=="string"&&M.levels[Y.toUpperCase()]!==void 0&&(Y=M.levels[Y.toUpperCase()]),typeof Y=="number"&&Y>=0&&Y<=M.levels.SILENT){if(j=Y,Z!==!1&&ie(Y),o.call(M,Y,E),typeof console===t&&Y<M.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+Y},M.setDefaultLevel=function(Y){x=Y,oe()||M.setLevel(Y,!1)},M.resetLevel=function(){M.setLevel(x,!1),J()},M.enableAll=function(Y){M.setLevel(M.levels.TRACE,Y)},M.disableAll=function(Y){M.setLevel(M.levels.SILENT,Y)};var L=oe();L==null&&(L=x),M.setLevel(L,!1)}var d=new f,p={};d.getLogger=function(x){if(typeof x!="symbol"&&typeof x!="string"||x==="")throw new TypeError("You must supply a name when creating a logger.");var I=p[x];return I||(I=p[x]=new f(x,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})})($C);var pr=$C.exports;const Ja="\\d+(?:[\\.,]\\d+)?",mF=`(${Ja}W)`,gF=`(${Ja}Y)?(${Ja}M)?(${Ja}D)?`,yF=`T(${Ja}H)?(${Ja}M)?(${Ja}S)?`,bF=`P(?:${mF}|${gF}(?:${yF})?)`,_F=["weeks","years","months","days","hours","minutes","seconds"],Xv=new RegExp(bF),OC=e=>e.match(Xv).slice(1).reduce((r,t,n)=>(r[_F[n]]=parseFloat(t)||0,r),{}),Qv=(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},IC=(e,r)=>{const t=r?r.getTime():Date.now(),n=new Date(t);return(Qv(e,n).getTime()-n.getTime())/1e3},wF={end:Qv,toSeconds:IC,pattern:Xv,parse:OC},SF=Object.freeze(Object.defineProperty({__proto__:null,default:wF,end:Qv,parse:OC,pattern:Xv,toSeconds:IC},Symbol.toStringTag,{value:"Module"})),TF=w0(SF);var CF=Gt,EF=wa,kF=qr.f,Qp=CF("unscopables"),Zp=Array.prototype;Zp[Qp]==null&&kF(Zp,Qp,{configurable:!0,value:EF(null)});var Zv=function(e){Zp[Qp][e]=!0},RF=ln,em=Zv,hb=Cu,PC=kn,$F=qr.f,OF=Jv,Qu=Yv,IF=Yt,AC="Array Iterator",PF=PC.set,AF=PC.getterFor(AC),xC=OF(Array,"Array",function(e,r){PF(this,{type:AC,target:RF(e),index:0,kind:r})},function(){var e=AF(this),r=e.target,t=e.kind,n=e.index++;return!r||n>=r.length?(e.target=void 0,Qu(void 0,!0)):t=="keys"?Qu(n,!1):t=="values"?Qu(r[n],!1):Qu([n,r[n]],!1)},"values"),vb=hb.Arguments=hb.Array;em("keys");em("values");em("entries");if(IF&&vb.name!=="values")try{$F(vb,"name",{value:"values"})}catch{}var mb=Rt,MC=hC,xF=vC,jo=xC,vd=ji,NC=Gt,md=NC("iterator"),gb=NC("toStringTag"),gd=jo.values,LC=function(e,r){if(e){if(e[md]!==gd)try{vd(e,md,gd)}catch{e[md]=gd}if(e[gb]||vd(e,gb,r),MC[r]){for(var t in jo)if(e[t]!==jo[t])try{vd(e,t,jo[t])}catch{e[t]=jo[t]}}}};for(var yd in MC)LC(mb[yd]&&mb[yd].prototype,yd);LC(xF,"DOMTokenList");var MF=Bt,NF=tr,yb=co,tm=function(e,r,t){var n,i;return yb&&MF(n=r.constructor)&&n!==t&&NF(i=n.prototype)&&i!==t.prototype&&yb(e,i),e},LF=_t,DF=LF(1 .valueOf),jF=`
|
|
9
|
-
\v\f\r \u2028\u2029\uFEFF`,FF=_t,UF=oi,BF=br,eh=jF,bb=FF("".replace),qF=RegExp("^["+eh+"]+"),GF=RegExp("(^|[^"+eh+"])["+eh+"]+$"),bd=function(e){return function(r){var t=BF(UF(r));return e&1&&(t=bb(t,qF,"")),e&2&&(t=bb(t,GF,"$1")),t}},VF={start:bd(1),end:bd(2),trim:bd(3)},zF=wt,DC=M0,WF=Yt,jC=Rt,FC=uT,UC=_t,HF=Rl,_b=rr,KF=tm,JF=Di,YF=ao,BC=bv,XF=mt,QF=ba.f,ZF=ii.f,eU=qr.f,tU=DF,rU=VF.trim,Vl="Number",Ds=jC[Vl];FC[Vl];var rm=Ds.prototype,nU=jC.TypeError,iU=UC("".slice),Zu=UC("".charCodeAt),aU=function(e){var r=BC(e,"number");return typeof r=="bigint"?r:sU(r)},sU=function(e){var r=BC(e,"number"),t,n,i,a,s,c,o,u;if(YF(r))throw nU("Cannot convert a Symbol value to a number");if(typeof r=="string"&&r.length>2){if(r=rU(r),t=Zu(r,0),t===43||t===45){if(n=Zu(r,2),n===88||n===120)return NaN}else if(t===48){switch(Zu(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=iU(r,2),c=s.length,o=0;o<c;o++)if(u=Zu(s,o),u<48||u>a)return NaN;return parseInt(s,i)}}return+r},nm=HF(Vl,!Ds(" 0o1")||!Ds("0b1")||Ds("+0x1")),oU=function(e){return JF(rm,e)&&XF(function(){tU(e)})},zl=function(r){var t=arguments.length<1?0:Ds(aU(r));return oU(this)?KF(Object(t),this,zl):t};zl.prototype=rm;nm&&!DC&&(rm.constructor=zl);zF({global:!0,constructor:!0,wrap:!0,forced:nm},{Number:zl});var uU=function(e,r){for(var t=WF?QF(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++)_b(r,i=t[n])&&!_b(e,i)&&eU(e,i,ZF(r,i))};(nm||DC)&&uU(FC[Vl],Ds);var cU=sr,qC=function(){var e=cU(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},im=mt,lU=Rt,am=lU.RegExp,sm=im(function(){var e=am("a","y");return e.lastIndex=2,e.exec("abcd")!=null}),fU=sm||im(function(){return!am("a","y").sticky}),dU=sm||im(function(){var e=am("^r","gy");return e.lastIndex=2,e.exec("str")!=null}),GC={BROKEN_CARET:dU,MISSED_STICKY:fU,UNSUPPORTED_Y:sm},pU=mt,hU=Rt,vU=hU.RegExp,mU=pU(function(){var e=vU(".","s");return!(e.dotAll&&e.exec(`
|
|
10
|
-
`)&&e.flags==="s")}),gU=mt,yU=Rt,bU=yU.RegExp,_U=gU(function(){var e=bU("(?<a>b)","g");return e.exec("b").groups.a!=="b"||"b".replace(e,"$<a>c")!=="bc"}),xs=qt,Wl=_t,wU=br,SU=qC,TU=GC,CU=so,EU=wa,kU=kn.get,RU=mU,$U=_U,OU=CU("native-string-replace",String.prototype.replace),sl=RegExp.prototype.exec,th=sl,IU=Wl("".charAt),PU=Wl("".indexOf),AU=Wl("".replace),_d=Wl("".slice),rh=function(){var e=/a/,r=/b*/g;return xs(sl,e,"a"),xs(sl,r,"a"),e.lastIndex!==0||r.lastIndex!==0}(),VC=TU.BROKEN_CARET,nh=/()??/.exec("")[1]!==void 0,xU=rh||nh||VC||RU||$U;xU&&(th=function(r){var t=this,n=kU(t),i=wU(r),a=n.raw,s,c,o,u,l,f,d;if(a)return a.lastIndex=t.lastIndex,s=xs(th,a,i),t.lastIndex=a.lastIndex,s;var p=n.groups,h=VC&&t.sticky,E=xs(SU,t),x=t.source,I=0,M=i;if(h&&(E=AU(E,"y",""),PU(E,"g")===-1&&(E+="g"),M=_d(i,t.lastIndex),t.lastIndex>0&&(!t.multiline||t.multiline&&IU(i,t.lastIndex-1)!==`
|
|
11
|
-
`)&&(x="(?: "+x+")",M=" "+M,I++),c=new RegExp("^(?:"+x+")",E)),nh&&(c=new RegExp("^"+x+"$(?!\\s)",E)),rh&&(o=t.lastIndex),u=xs(sl,h?c:t,M),h?u?(u.input=_d(u.input,I),u[0]=_d(u[0],I),u.index=t.lastIndex,t.lastIndex+=u[0].length):t.lastIndex=0:rh&&u&&(t.lastIndex=t.global?u.index+u[0].length:o),nh&&u&&u.length>1&&xs(OU,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=EU(null),l=0;l<p.length;l++)d=p[l],f[d[0]]=u[d[1]];return u});var Hl=th,MU=wt,wb=Hl;MU({target:"RegExp",proto:!0,forced:/./.exec!==wb},{exec:wb});var Sb=Ol,Tb=Gr,NU=Hl,Cb=mt,zC=Gt,LU=ji,DU=zC("species"),wd=RegExp.prototype,Kl=function(e,r,t,n){var i=zC(e),a=!Cb(function(){var u={};return u[i]=function(){return 7},""[e](u)!=7}),s=a&&!Cb(function(){var u=!1,l=/a/;return e==="split"&&(l={},l.constructor={},l.constructor[DU]=function(){return l},l.flags="",l[i]=/./[i]),l.exec=function(){return u=!0,null},l[i](""),!u});if(!a||!s||t){var c=Sb(/./[i]),o=r(i,""[e],function(u,l,f,d,p){var h=Sb(u),E=l.exec;return E===NU||E===wd.exec?a&&!p?{done:!0,value:c(l,f,d)}:{done:!0,value:h(f,l,d)}:{done:!1}});Tb(String.prototype,e,o[0]),Tb(wd,i,o[1])}n&&LU(wd[i],"sham",!0)},jU=Kv.charAt,om=function(e,r,t){return r+(t?jU(e,r).length:1)},um=_t,FU=Mr,UU=Math.floor,Sd=um("".charAt),BU=um("".replace),Td=um("".slice),qU=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,GU=/\$([$&'`]|\d{1,2})/g,VU=function(e,r,t,n,i,a){var s=t+e.length,c=n.length,o=GU;return i!==void 0&&(i=FU(i),o=qU),BU(a,o,function(u,l){var f;switch(Sd(l,0)){case"$":return"$";case"&":return e;case"`":return Td(r,0,t);case"'":return Td(r,s);case"<":f=i[Td(l,1,-1)];break;default:var d=+l;if(d===0)return u;if(d>c){var p=UU(d/10);return p===0?u:p<=c?n[p-1]===void 0?Sd(l,1):n[p-1]+Sd(l,1):u}f=n[d-1]}return f===void 0?"":f})},Eb=qt,zU=sr,WU=Bt,HU=ai,KU=Hl,JU=TypeError,Jl=function(e,r){var t=e.exec;if(WU(t)){var n=Eb(t,e,r);return n!==null&&zU(n),n}if(HU(e)==="RegExp")return Eb(KU,e,r);throw JU("RegExp#exec called on incompatible receiver")},YU=_a,kb=qt,Yl=_t,XU=Kl,QU=mt,ZU=sr,eB=Bt,tB=si,rB=ui,nB=Fi,ys=br,iB=oi,aB=om,sB=as,oB=VU,uB=Jl,cB=Gt,ih=cB("replace"),lB=Math.max,fB=Math.min,dB=Yl([].concat),Cd=Yl([].push),Rb=Yl("".indexOf),$b=Yl("".slice),pB=function(e){return e===void 0?e:String(e)},hB=function(){return"a".replace(/./,"$0")==="$0"}(),Ob=function(){return/./[ih]?/./[ih]("a","$0")==="":!1}(),vB=!QU(function(){var e=/./;return e.exec=function(){var r=[];return r.groups={a:"7"},r},"".replace(e,"$<a>")!=="7"});XU("replace",function(e,r,t){var n=Ob?"$":"$0";return[function(a,s){var c=iB(this),o=tB(a)?void 0:sB(a,ih);return o?kb(o,a,c,s):kb(r,ys(c),a,s)},function(i,a){var s=ZU(this),c=ys(i);if(typeof a=="string"&&Rb(a,n)===-1&&Rb(a,"$<")===-1){var o=t(r,s,c,a);if(o.done)return o.value}var u=eB(a);u||(a=ys(a));var l=s.global;if(l){var f=s.unicode;s.lastIndex=0}for(var d=[];;){var p=uB(s,c);if(p===null||(Cd(d,p),!l))break;var h=ys(p[0]);h===""&&(s.lastIndex=aB(c,nB(s.lastIndex),f))}for(var E="",x=0,I=0;I<d.length;I++){p=d[I];for(var M=ys(p[0]),j=lB(fB(rB(p.index),c.length),0),V=[],ie=1;ie<p.length;ie++)Cd(V,pB(p[ie]));var oe=p.groups;if(u){var J=dB([M],V,j,c);oe!==void 0&&Cd(J,oe);var L=ys(YU(a,void 0,J))}else L=oB(M,c,j,V,oe,a);j>=x&&(E+=$b(c,x,j)+L,x=j+M.length)}return E+$b(c,x)}]},!vB||!hB||Ob);var mB=wt,gB=_t,yB=cu,bB=ln,_B=ql,wB=gB([].join),SB=yB!=Object,TB=SB||!_B("join",",");mB({target:"Array",proto:!0,forced:TB},{join:function(r){return wB(bB(this),r===void 0?",":r)}});var Tr={},CB=wt,Ib=yu,EB=$l,kB=tr,Pb=ss,RB=Ir,$B=ln,OB=uo,IB=Gt,PB=wu,AB=oo,xB=PB("slice"),MB=IB("species"),Ed=Array,NB=Math.max;CB({target:"Array",proto:!0,forced:!xB},{slice:function(r,t){var n=$B(this),i=RB(n),a=Pb(r,i),s=Pb(t===void 0?i:t,i),c,o,u;if(Ib(n)&&(c=n.constructor,EB(c)&&(c===Ed||Ib(c.prototype))?c=void 0:kB(c)&&(c=c[MB],c===null&&(c=void 0)),c===Ed||c===void 0))return AB(n,a,s);for(o=new(c===void 0?Ed:c)(NB(s-a,0)),u=0;a<s;a++,u++)a in n&&OB(o,u,n[a]);return o.length=u,o}});var LB=wt,Ab=qt,DB=Bt,xb=sr,jB=br,FB=function(){var e=!1,r=/[ac]/;return r.exec=function(){return e=!0,/./.exec.apply(this,arguments)},r.test("abc")===!0&&e}(),UB=/./.test;LB({target:"RegExp",proto:!0,forced:!FB},{test:function(e){var r=xb(this),t=jB(e),n=r.exec;if(!DB(n))return Ab(UB,r,t);var i=Ab(n,r,t);return i===null?!1:(xb(i),!0)}});var BB=wt,qB=Yt,GB=Rt,ec=_t,VB=rr,zB=Bt,WB=Di,HB=br,KB=ci,JB=V0,Ci=GB.Symbol,ja=Ci&&Ci.prototype;if(qB&&zB(Ci)&&(!("description"in ja)||Ci().description!==void 0)){var Mb={},tc=function(){var r=arguments.length<1||arguments[0]===void 0?void 0:HB(arguments[0]),t=WB(ja,this)?new Ci(r):r===void 0?Ci():Ci(r);return r===""&&(Mb[t]=!0),t};JB(tc,Ci),tc.prototype=ja,ja.constructor=tc;var YB=String(Ci("test"))=="Symbol(test)",XB=ec(ja.valueOf),QB=ec(ja.toString),ZB=/^Symbol\((.*)\)[^)]+$/,e3=ec("".replace),t3=ec("".slice);KB(ja,"description",{configurable:!0,get:function(){var r=XB(this);if(VB(Mb,r))return"";var t=QB(r),n=YB?t3(t,7,-1):e3(t,ZB,"$1");return n===""?void 0:n}}),BB({global:!0,constructor:!0,forced:!0},{Symbol:tc})}var r3=cT;r3("iterator");var n3=Yt,i3=du.EXISTS,WC=_t,a3=ci,HC=Function.prototype,s3=WC(HC.toString),KC=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,o3=WC(KC.exec),u3="name";n3&&!i3&&a3(HC,u3,{configurable:!0,get:function(){try{return o3(KC,s3(this))[1]}catch{return""}}});var JC={exports:{}},YC={exports:{}};(function(e){function r(t){if(Array.isArray(t))return t}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(YC);var c3=YC.exports,XC={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})(XC);var l3=XC.exports,QC={exports:{}},ZC={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})(ZC);var eE=ZC.exports;(function(e){var r=eE;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})(QC);var tE=QC.exports,rE={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})(rE);var f3=rE.exports;(function(e){var r=c3,t=l3,n=tE,i=f3;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})(JC);var fo=JC.exports,nE={exports:{}},iE={exports:{}};(function(e){var r=eE;function t(n){if(Array.isArray(n))return r(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(iE);var d3=iE.exports,aE={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})(aE);var p3=aE.exports,sE={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})(sE);var h3=sE.exports;(function(e){var r=d3,t=p3,n=tE,i=h3;function a(s){return r(s)||t(s)||n(s)||i()}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports})(nE);var po=nE.exports,v3=wt,m3=kl.includes,g3=mt,y3=Zv,b3=g3(function(){return!Array(1).includes()});v3({target:"Array",proto:!0,forced:b3},{includes:function(r){return m3(this,r,arguments.length>1?arguments[1]:void 0)}});y3("includes");var _3=tr,w3=Math.floor,oE=Number.isInteger||function(r){return!_3(r)&&isFinite(r)&&w3(r)===r},S3=wt,T3=oE;S3({target:"Number",stat:!0},{isInteger:T3});var C3=Yt,uE=_t,E3=mu,k3=ln,R3=uu.f,$3=uE(R3),O3=uE([].push),Nb=function(e){return function(r){for(var t=k3(r),n=E3(t),i=n.length,a=0,s=[],c;i>a;)c=n[a++],(!C3||$3(t,c))&&O3(s,e?[c,t[c]]:t[c]);return s}},I3={entries:Nb(!0),values:Nb(!1)},P3=wt,A3=I3.entries;P3({target:"Object",stat:!0},{entries:function(r){return A3(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 x3=Rn,M3=fo,N3=po,L3=Sa,D3=di,j3=li,F3=fi,U3=$n;function Ta(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var js=Ta(x3),xi=Ta(M3),kd=Ta(N3),B3=Ta(L3),q3=Ta(D3),G3=Ta(j3),V3=Ta(F3),Lb=Ta(U3),Gi=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return{checks:t}};function z3(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=W3(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 W3(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 cE=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=z3(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 H3(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=K3(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 K3(e,r){if(e){if(typeof e=="string")return jb(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 jb(e,r)}}function jb(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 J3=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=H3(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 Y3(e){var r=X3();return function(){var n=Lb.default(e),i;if(r){var a=Lb.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return V3.default(this,i)}}function X3(){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=Q3(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 Q3(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 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=ru(t.entries()),i;try{for(n.s();!(i=n.n()).done;){var a=xi.default(i.value,2),s=a[0],c=a[1],o=Zl(r[s],c),u=xi.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()}},lE=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},Z3=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=cm(t);return function(a){return function(s){G3.default(o,s);var c=Y3(o);function o(){q3.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 B3.default(o)}(a)}},e4=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=cm(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)}}},t4=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=cm(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)}}},cm=function(r){var t=[],n=ru(r),i;try{for(n.s();!(i=n.n()).done;){var a=i.value;t.push(Ql(a))}}catch(s){n.e(s)}finally{n.f()}return t},Ql=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(cE(s));continue}t.push(s)}}catch(c){i.e(c)}finally{i.f()}return t},Zl=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=xi.default(d,3),h=p[0],E=p[1],x=p[2];a=a||h,!i&&x&&(i=x),E&&(n=typeof E=="string"?[].concat(kd.default(n),[E]):[].concat(kd.default(n),kd.default(E)))}}catch(V){u.e(V)}finally{u.f()}}}catch(V){s.e(V)}finally{s.f()}if(a)return[!0];var I=i||lE(t),M=n.length-1,j=M>0?"".concat(n.slice(0,M).join(", ")," or ").concat(n[M]):n.join(", ");return[!1,I,j,M>1?";":","]};function r4(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=n4(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 n4(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 i4=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=r4(n.entries()),a;try{for(i.s();!(a=i.n()).done;){var s=xi.default(a.value,2),c=s[0],o=s[1],u=Zl(Ql(t),o),l=xi.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]})},a4=Gi(function(e){return[typeof e=="string"&&e.length>0,"a non-empty string"]}),s4=Gi(function(e){return[typeof e=="number"&&Number.isInteger(e)&&e>=0,"a non-negative integer"]}),o4=Gi(function(e){return[js.default(e)==="object"&&e!==null&&!Array.isArray(e),"a pure object (non-null and non-array)"]}),u4=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=xi.default(a[i],2),c=s[0],o=s[1],u=Zl(Ql(o),n[c]),l=xi.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 c4(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=l4(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 l4(e,r){if(e){if(typeof e=="string")return Bb(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 Bb(e,r)}}function Bb(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 f4=function(r,t){return Gi(function(n){if(!Array.isArray(n))return[!1,"an array of ".concat(r)];var i=c4(n.entries()),a;try{for(i.s();!(a=i.n()).done;){var s=xi.default(a.value,2),c=s[0],o=s[1],u=Zl(Ql(t),o),l=xi.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=f4;Tr.custom=Gi;Tr.literal=J3;Tr.nonEmptyArray=i4;Tr.nonEmptyString=a4;Tr.nonNegativeInteger=s4;Tr.objectSchema=u4;Tr.pureObject=o4;Tr.runtimeTypeValidation=Xl;Tr.stringifyReceivedType=lE;Tr.type=cE;Tr.validateConstructorTypes=Z3;Tr.validateTypes=e4;Tr.validateTypesAsync=t4;var lm={},fE={exports:{}},dE={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})(dE);var d4=dE.exports;(function(e){var r=d4;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})(fE);var fm=fE.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(lm,"__esModule",{value:!0});var p4=po,h4=di,v4=Sa,m4=os,g4=fm,y4=li,b4=fi,_4=$n,w4=us;function Vi(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var qb=Vi(p4),S4=Vi(h4),T4=Vi(v4),C4=Vi(m4),Fa=Vi(g4),E4=Vi(y4),k4=Vi(b4),Ei=Vi(_4),R4=Vi(w4),$4;function pa(){}pa.prototype=Object.create(null);function Wt(){Wt.init.call(this)}Wt.EventEmitter=Wt;Wt.usingDomains=!1;Wt.prototype.domain=void 0;Wt.prototype._events=void 0;Wt.prototype._maxListeners=void 0;Wt.defaultMaxListeners=10;Wt.init=function(){this.domain=null,Wt.usingDomains&&$4.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new pa,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Wt.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 pE(e){return e._maxListeners===void 0?Wt.defaultMaxListeners:e._maxListeners}Wt.prototype.getMaxListeners=function(){return pE(this)};function O4(e,r,t){if(r)e.call(t);else for(var n=e.length,i=Ru(e,n),a=0;a<n;++a)i[a].call(t)}function I4(e,r,t,n){if(r)e.call(t,n);else for(var i=e.length,a=Ru(e,i),s=0;s<i;++s)a[s].call(t,n)}function P4(e,r,t,n,i){if(r)e.call(t,n,i);else for(var a=e.length,s=Ru(e,a),c=0;c<a;++c)s[c].call(t,n,i)}function A4(e,r,t,n,i,a){if(r)e.call(t,n,i,a);else for(var s=e.length,c=Ru(e,s),o=0;o<s;++o)c[o].call(t,n,i,a)}function x4(e,r,t,n){if(r)e.apply(t,n);else for(var i=e.length,a=Ru(e,i),s=0;s<i;++s)a[s].apply(t,n)}Wt.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:O4(n,f,this);break;case 2:I4(n,f,this,arguments[1]);break;case 3:P4(n,f,this,arguments[1],arguments[2]);break;case 4:A4(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];x4(n,f,this,a)}return!0};function hE(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=pE(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,M4(c)}return e}function M4(e){typeof console.warn=="function"?console.warn(e):console.log(e)}Wt.prototype.addListener=function(r,t){return hE(this,r,t,!1)};Wt.prototype.on=Wt.prototype.addListener;Wt.prototype.prependListener=function(r,t){return hE(this,r,t,!0)};function vE(e,r,t){var n=!1;function i(){e.removeListener(r,i),n||(n=!0,t.apply(e,arguments))}return i.listener=t,i}Wt.prototype.once=function(r,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.on(r,vE(this,r,t)),this};Wt.prototype.prependOnceListener=function(r,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(r,vE(this,r,t)),this};Wt.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 N4(n,a);i.removeListener&&this.emit("removeListener",r,c||t)}return this};Wt.prototype.off=function(e,r){return this.removeListener(e,r)};Wt.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};Wt.prototype.listeners=function(r){var t,n,i=this._events;return i?(t=i[r],t?typeof t=="function"?n=[t.listener||t]:n=L4(t):n=[]):n=[],n};Wt.listenerCount=function(e,r){return typeof e.listenerCount=="function"?e.listenerCount(r):mE.call(e,r)};Wt.prototype.listenerCount=mE;function mE(e){var r=this._events;if(r){var t=r[e];if(typeof t=="function")return 1;if(t)return t.length}return 0}Wt.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function N4(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 Ru(e,r){for(var t=new Array(r);r--;)t[r]=e[r];return t}function L4(e){for(var r=new Array(e.length),t=0;t<r.length;++t)r[t]=e[t].listener||e[t];return r}function D4(e){var r=j4();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 k4.default(this,i)}}function j4(){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 F4=function(e){E4.default(t,e);var r=D4(t);function t(){var n;return S4.default(this,t),n=r.call(this),R4.default(C4.default(n),"eventHistory",new Map),n}return T4.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,qb.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,qb.default(s)),this):Fa.default(Ei.default(t.prototype),"once",this).call(this,i,a)}}]),t}(Wt);lm.ReplayEventEmitter=F4;var ol={exports:{}};ol.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]",x="[object Number]",I="[object Null]",M="[object Object]",j="[object Promise]",V="[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]",We="[object Float64Array]",be="[object Int8Array]",Te="[object Int16Array]",Se="[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[We]=je[be]=je[Te]=je[Se]=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[x]=je[M]=je[ie]=je[oe]=je[J]=je[Z]=!1;var te=typeof Ve=="object"&&Ve&&Ve.Object===Object&&Ve,ur=typeof self=="object"&&self&&self.Object===Object&&self,xe=te||ur||Function("return this")(),fe=r&&!r.nodeType&&r,Pt=fe&&!0&&e&&!e.nodeType&&e,ze=Pt&&Pt.exports===fe,Kt=ze&&te.process,gt=function(){try{return Kt&&Kt.binding&&Kt.binding("util")}catch{}}(),Me=gt&>.isTypedArray;function ft(B,S){for(var k=-1,w=B==null?0:B.length,m=0,v=[];++k<w;){var _=B[k];S(_,k,B)&&(v[m++]=_)}return v}function Tt(B,S){for(var k=-1,w=S.length,m=B.length;++k<w;)B[m+k]=S[k];return B}function Le(B,S){for(var k=-1,w=B==null?0:B.length;++k<w;)if(S(B[k],k,B))return!0;return!1}function Jt(B,S){for(var k=-1,w=Array(B);++k<B;)w[k]=S(k);return w}function vt(B){return function(S){return B(S)}}function Vt(B,S){return B.has(S)}function nr(B,S){return B==null?void 0:B[S]}function He(B){var S=-1,k=Array(B.size);return B.forEach(function(w,m){k[++S]=[m,w]}),k}function Pr(B,S){return function(k){return B(S(k))}}function Cr(B){var S=-1,k=Array(B.size);return B.forEach(function(w){k[++S]=w}),k}var Ct=Array.prototype,kt=Function.prototype,yt=Object.prototype,st=xe["__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=ze?xe.Buffer:void 0,zt=xe.Symbol,Nr=xe.Uint8Array,_e=yt.propertyIsEnumerable,Ce=Ct.splice,ce=zt?zt.toStringTag:void 0,de=Object.getOwnPropertySymbols,le=_r?_r.isBuffer:void 0,ke=Pr(Object.keys,Object),Ie=Zt(xe,"DataView"),ee=Zt(xe,"Map"),ve=Zt(xe,"Promise"),Q=Zt(xe,"Set"),se=Zt(xe,"WeakMap"),X=Zt(Object,"create"),Ue=O(Ie),Oe=O(ee),Ze=O(ve),Ke=O(Q),Je=O(se),rt=zt?zt.prototype:void 0,nt=rt?rt.valueOf:void 0;function Ye(B){var S=-1,k=B==null?0:B.length;for(this.clear();++S<k;){var w=B[S];this.set(w[0],w[1])}}function tt(){this.__data__=X?X(null):{},this.size=0}function it(B){var S=this.has(B)&&delete this.__data__[B];return this.size-=S?1:0,S}function ct(B){var S=this.__data__;if(X){var k=S[B];return k===n?void 0:k}return Xt.call(S,B)?S[B]:void 0}function wr(B){var S=this.__data__;return X?S[B]!==void 0:Xt.call(S,B)}function cr(B,S){var k=this.__data__;return this.size+=this.has(B)?0:1,k[B]=X&&S===void 0?n:S,this}Ye.prototype.clear=tt,Ye.prototype.delete=it,Ye.prototype.get=ct,Ye.prototype.has=wr,Ye.prototype.set=cr;function ot(B){var S=-1,k=B==null?0:B.length;for(this.clear();++S<k;){var w=B[S];this.set(w[0],w[1])}}function Hr(){this.__data__=[],this.size=0}function ir(B){var S=this.__data__,k=Hn(S,B);if(k<0)return!1;var w=S.length-1;return k==w?S.pop():Ce.call(S,k,1),--this.size,!0}function zn(B){var S=this.__data__,k=Hn(S,B);return k<0?void 0:S[k][1]}function hi(B){return Hn(this.__data__,B)>-1}function $a(B,S){var k=this.__data__,w=Hn(k,B);return w<0?(++this.size,k.push([B,S])):k[w][1]=S,this}ot.prototype.clear=Hr,ot.prototype.delete=ir,ot.prototype.get=zn,ot.prototype.has=hi,ot.prototype.set=$a;function Kr(B){var S=-1,k=B==null?0:B.length;for(this.clear();++S<k;){var w=B[S];this.set(w[0],w[1])}}function Yi(){this.size=0,this.__data__={hash:new Ye,map:new(ee||ot),string:new Ye}}function Oa(B){var S=An(this,B).delete(B);return this.size-=S?1:0,S}function Wn(B){return An(this,B).get(B)}function Er(B){return An(this,B).has(B)}function Ia(B,S){var k=An(this,B),w=k.size;return k.set(B,S),this.size+=k.size==w?0:1,this}Kr.prototype.clear=Yi,Kr.prototype.delete=Oa,Kr.prototype.get=Wn,Kr.prototype.has=Er,Kr.prototype.set=Ia;function rn(B){var S=-1,k=B==null?0:B.length;for(this.__data__=new Kr;++S<k;)this.add(B[S])}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 S=this.__data__=new ot(B);this.size=S.size}function Xi(){this.__data__=new ot,this.size=0}function Pa(B){var S=this.__data__,k=S.delete(B);return this.size=S.size,k}function Aa(B){return this.__data__.get(B)}function Ar(B){return this.__data__.has(B)}function At(B,S){var k=this.__data__;if(k instanceof ot){var w=k.__data__;if(!ee||w.length<t-1)return w.push([B,S]),this.size=++k.size,this;k=this.__data__=new Kr(w)}return k.set(B,S),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,S){var k=N(B),w=!k&&U(B),m=!k&&!w&&pe(B),v=!k&&!w&&!m&&lr(B),_=k||w||m||v,g=_?Jt(B.length,String):[],y=g.length;for(var b in B)(S||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,S){for(var k=B.length;k--;)if(R(B[k][0],S))return k;return-1}function xa(B,S,k){var w=S(B);return N(B)?w:Tt(w,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,S,k,w,m){return B===S?!0:B==null||S==null||!Lr(B)&&!Lr(S)?B!==B&&S!==S:Ma(B,S,k,w,yi,m)}function Ma(B,S,k,w,m,v){var _=N(B),g=N(S),y=_?o:kr(B),b=g?o:kr(S);y=y==c?M:y,b=b==c?M:b;var T=y==M,$=b==M,H=y==b;if(H&&pe(B)){if(!pe(S))return!1;_=!0,T=!1}if(H&&!T)return v||(v=new Jr),_||lr(B)?Zi(B,S,k,w,m,v):bi(B,S,y,k,w,m,v);if(!(k&i)){var K=T&&Xt.call(B,"__wrapped__"),re=$&&Xt.call(S,"__wrapped__");if(K||re){var ue=K?B.value():B,Xe=re?S.value():S;return v||(v=new Jr),m(ue,Xe,k,w,v)}}return H?(v||(v=new Jr),ea(B,S,k,w,m,v)):!1}function Na(B){if(!dt(B)||F(B))return!1;var S=qe(B)?Pn:Et;return S.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 S=[];for(var k in Object(B))Xt.call(B,k)&&k!="constructor"&&S.push(k);return S}function Zi(B,S,k,w,m,v){var _=k&i,g=B.length,y=S.length;if(g!=y&&!(_&&y>g))return!1;var b=v.get(B);if(b&&v.get(S))return b==S;var T=-1,$=!0,H=k&a?new rn:void 0;for(v.set(B,S),v.set(S,B);++T<g;){var K=B[T],re=S[T];if(w)var ue=_?w(re,K,T,S,B,v):w(K,re,T,B,S,v);if(ue!==void 0){if(ue)continue;$=!1;break}if(H){if(!Le(S,function(Xe,lt){if(!Vt(H,lt)&&(K===Xe||m(K,Xe,k,w,v)))return H.push(lt)})){$=!1;break}}else if(!(K===re||m(K,re,k,w,v))){$=!1;break}}return v.delete(B),v.delete(S),$}function bi(B,S,k,w,m,v,_){switch(k){case Re:if(B.byteLength!=S.byteLength||B.byteOffset!=S.byteOffset)return!1;B=B.buffer,S=S.buffer;case ye:return!(B.byteLength!=S.byteLength||!v(new Nr(B),new Nr(S)));case l:case f:case x:return R(+B,+S);case d:return B.name==S.name&&B.message==S.message;case ie:case J:return B==S+"";case E:var g=He;case oe:var y=w&i;if(g||(g=Cr),B.size!=S.size&&!y)return!1;var b=_.get(B);if(b)return b==S;w|=a,_.set(B,S);var T=Zi(g(B),g(S),w,m,v,_);return _.delete(B),T;case L:if(nt)return nt.call(B)==nt.call(S)}return!1}function ea(B,S,k,w,m,v){var _=k&i,g=vn(B),y=g.length,b=vn(S),T=b.length;if(y!=T&&!_)return!1;for(var $=y;$--;){var H=g[$];if(!(_?H in S:Xt.call(S,H)))return!1}var K=v.get(B);if(K&&v.get(S))return K==S;var re=!0;v.set(B,S),v.set(S,B);for(var ue=_;++$<y;){H=g[$];var Xe=B[H],lt=S[H];if(w)var C=_?w(lt,Xe,H,S,B,v):w(Xe,lt,H,B,S,v);if(!(C===void 0?Xe===lt||m(Xe,lt,k,w,v):C)){re=!1;break}ue||(ue=H=="constructor")}if(re&&!ue){var A=B.constructor,D=S.constructor;A!=D&&"constructor"in B&&"constructor"in S&&!(typeof A=="function"&&A instanceof A&&typeof D=="function"&&D instanceof D)&&(re=!1)}return v.delete(B),v.delete(S),re}function vn(B){return xa(B,an,Jn)}function An(B,S){var k=B.__data__;return ta(S)?k[typeof S=="string"?"string":"hash"]:k.map}function Zt(B,S){var k=nr(B,S);return Na(k)?k:void 0}function Kn(B){var S=Xt.call(B,ce),k=B[ce];try{B[ce]=void 0;var w=!0}catch{}var m=hn.call(B);return w&&(S?B[ce]=k:delete B[ce]),m}var Jn=de?function(B){return B==null?[]:(B=Object(B),ft(de(B),function(S){return _e.call(B,S)}))}:_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 S=Yr(B),k=S==M?B.constructor:void 0,w=k?O(k):"";if(w)switch(w){case Ue:return Re;case Oe:return E;case Ze:return j;case Ke:return oe;case Je:return Z}return S});function nn(B,S){return S=S??s,!!S&&(typeof B=="number"||ut.test(B))&&B>-1&&B%1==0&&B<S}function ta(B){var S=typeof B;return S=="string"||S=="number"||S=="symbol"||S=="boolean"?B!=="__proto__":B===null}function F(B){return!!hr&&hr in B}function q(B){var S=B&&B.constructor,k=typeof S=="function"&&S.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,S){return B===S||B!==B&&S!==S}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,S){return yi(B,S)}function qe(B){if(!dt(B))return!1;var S=Yr(B);return S==p||S==h||S==u||S==V}function at(B){return typeof B=="number"&&B>-1&&B%1==0&&B<=s}function dt(B){var S=typeof B;return B!=null&&(S=="object"||S=="function")}function Lr(B){return B!=null&&typeof B=="object"}var lr=Me?vt(Me):vr;function an(B){return me(B)?mi(B):Qi(B)}function _o(){return[]}function Qt(){return!1}e.exports=Ae})(ol,ol.exports);var U4=ol.exports,gE={exports:{}},B4=mt,q4=B4(function(){if(typeof ArrayBuffer=="function"){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}}),G4=mt,V4=tr,z4=ai,Gb=q4,Kc=Object.isExtensible,W4=G4(function(){Kc(1)}),H4=W4||Gb?function(r){return!V4(r)||Gb&&z4(r)=="ArrayBuffer"?!1:Kc?Kc(r):!0}:Kc,K4=mt,yE=!K4(function(){return Object.isExtensible(Object.preventExtensions({}))}),J4=wt,Y4=_t,X4=pu,Q4=tr,dm=rr,Z4=qr.f,Vb=ba,eq=Ov,pm=H4,tq=lu,rq=yE,bE=!1,Mi=tq("meta"),nq=0,hm=function(e){Z4(e,Mi,{value:{objectID:"O"+nq++,weakData:{}}})},iq=function(e,r){if(!Q4(e))return typeof e=="symbol"?e:(typeof e=="string"?"S":"P")+e;if(!dm(e,Mi)){if(!pm(e))return"F";if(!r)return"E";hm(e)}return e[Mi].objectID},aq=function(e,r){if(!dm(e,Mi)){if(!pm(e))return!0;if(!r)return!1;hm(e)}return e[Mi].weakData},sq=function(e){return rq&&bE&&pm(e)&&!dm(e,Mi)&&hm(e),e},oq=function(){uq.enable=function(){},bE=!0;var e=Vb.f,r=Y4([].splice),t={};t[Mi]=1,e(t).length&&(Vb.f=function(n){for(var i=e(n),a=0,s=i.length;a<s;a++)if(i[a]===Mi){r(i,a,1);break}return i},J4({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:eq.f}))},uq=gE.exports={enable:oq,fastKey:iq,getWeakData:aq,onFreeze:sq};X4[Mi]=!0;var vm=gE.exports,cq=wt,lq=Rt,fq=_t,zb=Rl,dq=Gr,pq=vm,hq=Ul,vq=cs,mq=Bt,gq=si,Rd=tr,$d=mt,yq=Bl,bq=Ui,_q=tm,_E=function(e,r,t){var n=e.indexOf("Map")!==-1,i=e.indexOf("Weak")!==-1,a=n?"set":"add",s=lq[e],c=s&&s.prototype,o=s,u={},l=function(I){var M=fq(c[I]);dq(c,I,I=="add"?function(V){return M(this,V===0?0:V),this}:I=="delete"?function(j){return i&&!Rd(j)?!1:M(this,j===0?0:j)}:I=="get"?function(V){return i&&!Rd(V)?void 0:M(this,V===0?0:V)}:I=="has"?function(V){return i&&!Rd(V)?!1:M(this,V===0?0:V)}:function(V,ie){return M(this,V===0?0:V,ie),this})},f=zb(e,!mq(s)||!(i||c.forEach&&!$d(function(){new s().entries().next()})));if(f)o=t.getConstructor(r,e,n,a),pq.enable();else if(zb(e,!0)){var d=new o,p=d[a](i?{}:-0,1)!=d,h=$d(function(){d.has(1)}),E=yq(function(I){new s(I)}),x=!i&&$d(function(){for(var I=new s,M=5;M--;)I[a](M,M);return!I.has(-0)});E||(o=r(function(I,M){vq(I,c);var j=_q(new s,I,o);return gq(M)||hq(M,j[a],{that:j,AS_ENTRIES:n}),j}),o.prototype=c,c.constructor=o),(h||x)&&(l("delete"),l("has"),n&&l("get")),(x||p)&&l(a),i&&c.clear&&delete c.clear}return u[e]=o,cq({global:!0,constructor:!0,forced:o!=s},u),bq(o,e),i||t.setStrong(o,e,n),o},wq=Gr,mm=function(e,r,t){for(var n in r)wq(e,n,r[n],t);return e},Sq=wa,Tq=ci,Wb=mm,Cq=qi,Eq=cs,kq=si,Rq=Ul,$q=Jv,rc=Yv,Oq=Ll,Eo=Yt,Hb=vm.fastKey,wE=kn,Kb=wE.set,Od=wE.getterFor,SE={getConstructor:function(e,r,t,n){var i=e(function(u,l){Eq(u,a),Kb(u,{type:r,index:Sq(null),first:void 0,last:void 0,size:0}),Eo||(u.size=0),kq(l)||Rq(l,u[n],{that:u,AS_ENTRIES:t})}),a=i.prototype,s=Od(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=Hb(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=Hb(l),p;if(d!=="F")return f.index[d];for(p=f.first;p;p=p.next)if(p.key==l)return p};return Wb(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=Cq(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)}}),Wb(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&&Tq(a,"size",{configurable:!0,get:function(){return s(this).size}}),i},setStrong:function(e,r,t){var n=r+" Iterator",i=Od(r),a=Od(n);$q(e,r,function(s,c){Kb(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,rc(void 0,!0)):c=="keys"?rc(o.key,!1):c=="values"?rc(o.value,!1):rc([o.key,o.value],!1)},t?"entries":"values",!t,!0),Oq(r)}},Iq=_E,Pq=SE;Iq("Map",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},Pq);var zi={};/*
|
|
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(zi,"__esModule",{value:!0});var Aq=di,xq=Sa,Mq=os,Nq=li,Lq=fi,Dq=$n,jq=us;function ls(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var gm=ls(Aq),ym=ls(xq),Ri=ls(Mq),bm=ls(Nq),TE=ls(Lq),ul=ls(Dq),$i=ls(jq),Fq;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&&Fq.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 CE(e){return e._maxListeners===void 0?Ft.defaultMaxListeners:e._maxListeners}Ft.prototype.getMaxListeners=function(){return CE(this)};function Uq(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 Bq(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 qq(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 Gq(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 Vq(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)}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:Uq(n,f,this);break;case 2:Bq(n,f,this,arguments[1]);break;case 3:qq(n,f,this,arguments[1],arguments[2]);break;case 4:Gq(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];Vq(n,f,this,a)}return!0};function EE(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=CE(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,zq(c)}return e}function zq(e){typeof console.warn=="function"?console.warn(e):console.log(e)}Ft.prototype.addListener=function(r,t){return EE(this,r,t,!1)};Ft.prototype.on=Ft.prototype.addListener;Ft.prototype.prependListener=function(r,t){return EE(this,r,t,!0)};function kE(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,kE(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,kE(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 Wq(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=Hq(t):n=[]):n=[],n};Ft.listenerCount=function(e,r){return typeof e.listenerCount=="function"?e.listenerCount(r):RE.call(e,r)};Ft.prototype.listenerCount=RE;function RE(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 Wq(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 Hq(e){for(var r=new Array(e.length),t=0;t<r.length;++t)r[t]=e[t].listener||e[t];return r}function $E(e){var r=Kq();return function(){var n=ul.default(e),i;if(r){var a=ul.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return TE.default(this,i)}}function Kq(){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 OE=function(e){bm.default(t,e);var r=$E(t);function t(n){var i;return gm.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 ym.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),Jq=function(e){bm.default(t,e);var r=$E(t);function t(n){var i;return gm.default(this,t),i=r.call(this),$i.default(Ri.default(i),"resolve",function(){}),$i.default(Ri.default(i),"reject",function(){}),i.retrier=new OE(n),i}return ym.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 Yq(e){var r=Xq();return function(){var n=ul.default(e),i;if(r){var a=ul.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return TE.default(this,i)}}function Xq(){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 nc(e){return e!=null}var Qq=function(e){bm.default(t,e);var r=Yq(t);function t(n){var i;gm.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(nc(s)&&s<1)throw new Error("The initial timeout must be equal to or greater than 1.");if(nc(c)&&c<=1)throw new Error("The maximal timeout must be greater than 1.");if(nc(o)&&(o<0||o>1))throw new Error("The randomisation factor must be between 0 and 1.");if(nc(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 ym.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);zi.AsyncRetrier=Jq;zi.Backoff=Qq;zi.Retrier=OE;var ef={},Zq=qt,e6=rr,t6=Di,r6=qC,Jb=RegExp.prototype,n6=function(e){var r=e.flags;return r===void 0&&!("flags"in Jb)&&!e6(e,"flags")&&t6(Jb,e)?Zq(r6,e):r},i6=du.PROPER,a6=Gr,s6=sr,Yb=br,o6=mt,u6=n6,_m="toString",c6=RegExp.prototype,IE=c6[_m],l6=o6(function(){return IE.call({source:"a",flags:"b"})!="/a/b"}),f6=i6&&IE.name!=_m;(l6||f6)&&a6(RegExp.prototype,_m,function(){var r=s6(this),t=Yb(r.source),n=Yb(u6(r));return"/"+t+"/"+n},{unsafe:!0});var Vr={};/*
|
|
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(Vr,"__esModule",{value:!0});var d6=Rn,p6=fo,h6=po,v6=di,m6=li,g6=fi,y6=$n;function fs(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Fs=fs(d6),Qa=fs(p6),Id=fs(h6),b6=fs(v6),_6=fs(m6),w6=fs(g6),Xb=fs(y6),Ca=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return{checks:t}};function S6(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=T6(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 T6(e,r){if(e){if(typeof e=="string")return Qb(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 Qb(e,r)}}function Qb(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 PE=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=S6(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 C6(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=E6(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 E6(e,r){if(e){if(typeof e=="string")return Zb(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 Zb(e,r)}}function Zb(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 k6=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=C6(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]})},R6=Ca(function(e){return[typeof e=="string"&&e.length>0,"a non-empty string"]}),$6=Ca(function(e){return[typeof e=="number"&&Number.isInteger(e)&&e>=0,"a non-negative integer"]}),O6=Ca(function(e){return[Fs.default(e)==="object"&&e!==null&&!Array.isArray(e),"a pure object (non-null and non-array)"]});function I6(e){var r=P6();return function(){var n=Xb.default(e),i;if(r){var a=Xb.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return w6.default(this,i)}}function P6(){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=A6(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 A6(e,r){if(e){if(typeof e=="string")return e_(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 e_(e,r)}}function e_(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 tf=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=Tm(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()}},AE=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},x6=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=wm(t);return function(a){return function(s){_6.default(o,s);var c=I6(o);function o(){b6.default(this,o);for(var u=arguments.length,l=new Array(u),f=0;f<u;f++)l[f]=arguments[f];return tf(i,l),c.call.apply(c,[this].concat(l))}return o}(a)}},M6=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=wm(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 tf(i,l),o.apply(this,l)}}},N6=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=wm(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{tf(i,l)}catch(d){return Promise.reject(d)}return o.apply(this,l)}}},wm=function(r){var t=[],n=nu(r),i;try{for(n.s();!(i=n.n()).done;){var a=i.value;t.push(Sm(a))}}catch(s){n.e(s)}finally{n.f()}return t},Sm=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(PE(s));continue}t.push(s)}}catch(c){i.e(c)}finally{i.f()}return t},Tm=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],x=p[2];a=a||h,!i&&x&&(i=x),E&&(n=typeof E=="string"?[].concat(Id.default(n),[E]):[].concat(Id.default(n),Id.default(E)))}}catch(V){u.e(V)}finally{u.f()}}}catch(V){s.e(V)}finally{s.f()}if(a)return[!0];var I=i||AE(t),M=n.length-1,j=M>0?"".concat(n.slice(0,M).join(", ")," or ").concat(n[M]):n.join(", ");return[!1,I,j,M>1?";":","]},L6=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=Tm(Sm(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 D6(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=j6(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 j6(e,r){if(e){if(typeof e=="string")return t_(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 t_(e,r)}}function t_(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 F6=function(r,t){return Ca(function(n){if(!Array.isArray(n))return[!1,"an array of ".concat(r)];var i=D6(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=Tm(Sm(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]})};Vr.array=F6;Vr.custom=Ca;Vr.literal=k6;Vr.nonEmptyString=R6;Vr.nonNegativeInteger=$6;Vr.objectSchema=L6;Vr.pureObject=O6;Vr.runtimeTypeValidation=tf;Vr.stringifyReceivedType=AE;Vr.type=PE;Vr.validateConstructorTypes=x6;Vr.validateTypes=M6;Vr.validateTypesAsync=N6;var U6=_E,B6=SE;U6("Set",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},B6);var xE={exports:{}};(function(e,r){(function(n,i){e.exports=i()})(Ve,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],x=l[0][2];if(f[0].event=h,h&&x&&h!==d&&c.hook(this,"lifecycle",f),E.length===0)return l.shift(),this.observeEvents(l,f,h,p);var I=E.shift(),M=I[h].apply(I,f);return M&&typeof M.then=="function"?M.then(this.observeEvents.bind(this,l,f,h)).catch(this.failTransit.bind(this)):M===!1?this.endTransit(!1):this.observeEvents(l,f,h,M)},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(x){return this._fsm.is(x)},can:function(x){return this._fsm.can(x)},cannot:function(x){return this._fsm.cannot(x)},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(x,I,M){return this._fsm.onInvalidTransition(x,I,M)},onPendingTransition:function(x,I,M){return this._fsm.onPendingTransition(x,I,M)}},f={state:{configurable:!1,enumerable:!0,get:function(){return this._fsm.state},set:function(x){throw Error("use transitions to change state")}}};function d(x){return h(this||{},x)}function p(){var x,I;typeof arguments[0]=="function"?(x=arguments[0],I=arguments[1]||{}):(x=function(){this._fsm.apply(this,arguments)},I=arguments[0]||{});var M=new o(I,d);return E(x.prototype,M),x.prototype._fsm.config=M,x}function h(x,I){var M=new o(I,d);return E(x,M),x._fsm(),x}function E(x,I){if(typeof x!="object"||Array.isArray(x))throw Error("StateMachine can only be applied to objects");c.build(x,I),Object.defineProperties(x,f),a(x,l),a(x,I.methods),I.allTransitions().forEach(function(M){x[s(M)]=function(){return this._fsm.fire(M,[].slice.call(arguments))}}),x._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}}])})})(xE);var q6=xE.exports,ah={exports:{}},r_=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(r_){var n_=new Uint8Array(16);ah.exports=function(){return r_(n_),n_}}else{var i_=new Array(16);ah.exports=function(){for(var r=0,t;r<16;r++)r&3||(t=Math.random()*4294967296),i_[r]=t>>>((r&3)<<3)&255;return i_}}var ME=ah.exports,NE=[];for(var ic=0;ic<256;++ic)NE[ic]=(ic+256).toString(16).substr(1);function G6(e,r){var t=r||0,n=NE;return[n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]]].join("")}var LE=G6,V6=ME,z6=LE,a_,Pd,Ad=0,xd=0;function W6(e,r,t){var n=r&&t||0,i=r||[];e=e||{};var a=e.node||a_,s=e.clockseq!==void 0?e.clockseq:Pd;if(a==null||s==null){var c=V6();a==null&&(a=a_=[c[0]|1,c[1],c[2],c[3],c[4],c[5]]),s==null&&(s=Pd=(c[6]<<8|c[7])&16383)}var o=e.msecs!==void 0?e.msecs:new Date().getTime(),u=e.nsecs!==void 0?e.nsecs:xd+1,l=o-Ad+(u-xd)/1e4;if(l<0&&e.clockseq===void 0&&(s=s+1&16383),(l<0||o>Ad)&&e.nsecs===void 0&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Ad=o,xd=u,Pd=s,o+=122192928e5;var f=((o&268435455)*1e4+u)%4294967296;i[n++]=f>>>24&255,i[n++]=f>>>16&255,i[n++]=f>>>8&255,i[n++]=f&255;var d=o/4294967296*1e4&268435455;i[n++]=d>>>8&255,i[n++]=d&255,i[n++]=d>>>24&15|16,i[n++]=d>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var p=0;p<6;++p)i[n+p]=a[p];return r||z6(i)}var H6=W6,K6=ME,J6=LE;function Y6(e,r,t){var n=r&&t||0;typeof e=="string"&&(r=e==="binary"?new Array(16):null,e=null),e=e||{};var i=e.random||(e.rng||K6)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,r)for(var a=0;a<16;++a)r[n+a]=i[a];return r||J6(i)}var X6=Y6,Q6=H6,DE=X6,Cm=DE;Cm.v1=Q6;Cm.v4=DE;var Z6=Cm,sh={exports:{}},jE=typeof ArrayBuffer<"u"&&typeof DataView<"u",e5=jE,Em=Yt,Br=Rt,FE=Bt,rf=tr,ga=rr,km=Bi,t5=is,r5=ji,oh=Gr,n5=ci,i5=Di,nf=Gl,ho=co,a5=Gt,s5=lu,UE=kn,BE=UE.enforce,o5=UE.get,cl=Br.Int8Array,uh=cl&&cl.prototype,s_=Br.Uint8ClampedArray,o_=s_&&s_.prototype,ei=cl&&nf(cl),Un=uh&&nf(uh),u5=Object.prototype,Rm=Br.TypeError,u_=a5("toStringTag"),ch=s5("TYPED_ARRAY_TAG"),ll="TypedArrayConstructor",Ni=e5&&!!ho&&km(Br.opera)!=="Opera",qE=!1,Zr,oa,Us,Li={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},$m={BigInt64Array:8,BigUint64Array:8},c5=function(r){if(!rf(r))return!1;var t=km(r);return t==="DataView"||ga(Li,t)||ga($m,t)},GE=function(e){var r=nf(e);if(rf(r)){var t=o5(r);return t&&ga(t,ll)?t[ll]:GE(r)}},VE=function(e){if(!rf(e))return!1;var r=km(e);return ga(Li,r)||ga($m,r)},l5=function(e){if(VE(e))return e;throw Rm("Target is not a typed array")},f5=function(e){if(FE(e)&&(!ho||i5(ei,e)))return e;throw Rm(t5(e)+" is not a typed array constructor")},d5=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)&&oh(Un,e,t?r:Ni&&uh[e]||r,n)}},p5=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 oh(ei,e,t?r:Ni&&ei[e]||r)}catch{}else return}for(n in Li)i=Br[n],i&&(!i[e]||t)&&oh(i,e,r)}};for(Zr in Li)oa=Br[Zr],Us=oa&&oa.prototype,Us?BE(Us)[ll]=oa:Ni=!1;for(Zr in $m)oa=Br[Zr],Us=oa&&oa.prototype,Us&&(BE(Us)[ll]=oa);if((!Ni||!FE(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===u5)&&(Un=ei.prototype,Ni))for(Zr in Li)Br[Zr]&&ho(Br[Zr].prototype,Un);Ni&&nf(o_)!==Un&&ho(o_,Un);if(Em&&!ga(Un,u_)){qE=!0,n5(Un,u_,{configurable:!0,get:function(){return rf(this)?this[ch]:void 0}});for(Zr in Li)Br[Zr]&&r5(Br[Zr],ch,Zr)}var Ht={NATIVE_ARRAY_BUFFER_VIEWS:Ni,TYPED_ARRAY_TAG:qE&&ch,aTypedArray:l5,aTypedArrayConstructor:f5,exportTypedArrayMethod:d5,exportTypedArrayStaticMethod:p5,getTypedArrayConstructor:GE,isView:c5,isTypedArray:VE,TypedArray:ei,TypedArrayPrototype:Un},zE=Rt,Md=mt,h5=Bl,v5=Ht.NATIVE_ARRAY_BUFFER_VIEWS,m5=zE.ArrayBuffer,Ua=zE.Int8Array,g5=!v5||!Md(function(){Ua(1)})||!Md(function(){new Ua(-1)})||!h5(function(e){new Ua,new Ua(null),new Ua(1.5),new Ua(e)},!0)||Md(function(){return new Ua(new m5(2),1,void 0).length!==1}),y5=ui,b5=Fi,_5=RangeError,WE=function(e){if(e===void 0)return 0;var r=y5(e),t=b5(r);if(r!==t)throw _5("Wrong length or index");return t},w5=Array,S5=Math.abs,ki=Math.pow,T5=Math.floor,C5=Math.log,E5=Math.LN2,k5=function(e,r,t){var n=w5(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=S5(e),e!=e||e===1/0?(f=e!=e?1:0,l=a):(l=T5(C5(e)/E5),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},R5=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)},$5={pack:k5,unpack:R5},O5=Mr,c_=ss,I5=Ir,HE=function(r){for(var t=O5(this),n=I5(t),i=arguments.length,a=c_(i>1?arguments[1]:void 0,n),s=i>2?arguments[2]:void 0,c=s===void 0?n:c_(s,n);c>a;)t[a++]=r;return t},af=Rt,Om=_t,Nd=Yt,P5=jE,KE=du,l_=ji,A5=ci,f_=mm,Ld=mt,ac=cs,x5=ui,M5=Fi,fl=WE,JE=$5,N5=Gl,d_=co,L5=ba.f,D5=HE,j5=gu,YE=Ui,Im=kn,F5=KE.PROPER,p_=KE.CONFIGURABLE,Bs="ArrayBuffer",sf="DataView",qs="prototype",U5="Wrong length",XE="Wrong index",h_=Im.getterFor(Bs),Ko=Im.getterFor(sf),v_=Im.set,bn=af[Bs],on=bn,bs=on&&on[qs],Qn=af[sf],Ba=Qn&&Qn[qs],m_=Object.prototype,B5=af.Array,dl=af.RangeError,q5=Om(D5),G5=Om([].reverse),QE=JE.pack,g_=JE.unpack,y_=function(e){return[e&255]},b_=function(e){return[e&255,e>>8&255]},__=function(e){return[e&255,e>>8&255,e>>16&255,e>>24&255]},w_=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},V5=function(e){return QE(e,23,4)},z5=function(e){return QE(e,52,8)},sc=function(e,r,t){A5(e[qs],r,{configurable:!0,get:function(){return t(this)[r]}})},na=function(e,r,t,n){var i=fl(t),a=Ko(e);if(i+r>a.byteLength)throw dl(XE);var s=a.bytes,c=i+a.byteOffset,o=j5(s,c,c+r);return n?o:G5(o)},ia=function(e,r,t,n,i,a){var s=fl(t),c=Ko(e);if(s+r>c.byteLength)throw dl(XE);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(!P5)on=function(r){ac(this,bs);var t=fl(r);v_(this,{type:Bs,bytes:q5(B5(t),0),byteLength:t}),Nd||(this.byteLength=t,this.detached=!1)},bs=on[qs],Qn=function(r,t,n){ac(this,Ba),ac(r,bs);var i=h_(r),a=i.byteLength,s=x5(t);if(s<0||s>a)throw dl("Wrong offset");if(n=n===void 0?a-s:M5(n),s+n>a)throw dl(U5);v_(this,{type:sf,buffer:r,byteLength:n,byteOffset:s,bytes:i.bytes}),Nd||(this.buffer=r,this.byteLength=n,this.byteOffset=s)},Ba=Qn[qs],Nd&&(sc(on,"byteLength",h_),sc(Qn,"buffer",Ko),sc(Qn,"byteLength",Ko),sc(Qn,"byteOffset",Ko)),f_(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 w_(na(this,4,r,arguments.length>1?arguments[1]:void 0))},getUint32:function(r){return w_(na(this,4,r,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(r){return g_(na(this,4,r,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(r){return g_(na(this,8,r,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(r,t){ia(this,1,r,y_,t)},setUint8:function(r,t){ia(this,1,r,y_,t)},setInt16:function(r,t){ia(this,2,r,b_,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(r,t){ia(this,2,r,b_,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(r,t){ia(this,4,r,__,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(r,t){ia(this,4,r,__,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(r,t){ia(this,4,r,V5,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(r,t){ia(this,8,r,z5,t,arguments.length>2?arguments[2]:void 0)}});else{var S_=F5&&bn.name!==Bs;if(!Ld(function(){bn(1)})||!Ld(function(){new bn(-1)})||Ld(function(){return new bn,new bn(1.5),new bn(NaN),bn.length!=1||S_&&!p_})){on=function(r){return ac(this,bs),new bn(fl(r))},on[qs]=bs;for(var T_=L5(bn),C_=0,Dd;T_.length>C_;)(Dd=T_[C_++])in on||l_(on,Dd,bn[Dd]);bs.constructor=on}else S_&&p_&&l_(bn,"name",Bs);d_&&N5(Ba)!==m_&&d_(Ba,m_);var oc=new Qn(new on(2)),E_=Om(Ba.setInt8);oc.setInt8(0,2147483648),oc.setInt8(1,2147483649),(oc.getInt8(0)||!oc.getInt8(1))&&f_(Ba,{setInt8:function(r,t){E_(this,r,t<<24>>24)},setUint8:function(r,t){E_(this,r,t<<24>>24)}},{unsafe:!0})}YE(on,Bs);YE(Qn,sf);var ZE={ArrayBuffer:on,DataView:Qn},W5=ui,H5=RangeError,K5=function(e){var r=W5(e);if(r<0)throw H5("The argument can't be less than 0");return r},J5=K5,Y5=RangeError,ek=function(e,r){var t=J5(e);if(t%r)throw Y5("Wrong offset");return t},X5=Bi,Q5=function(e){var r=X5(e);return r=="BigInt64Array"||r=="BigUint64Array"},Z5=bv,eG=TypeError,tk=function(e){var r=Z5(e,"number");if(typeof r=="number")throw eG("Can't convert number to bigint");return BigInt(r)},tG=qi,rG=qt,nG=kv,iG=Mr,aG=Ir,sG=Fl,oG=Eu,uG=Wv,cG=Q5,lG=Ht.aTypedArrayConstructor,fG=tk,dG=function(r){var t=nG(this),n=iG(r),i=arguments.length,a=i>1?arguments[1]:void 0,s=a!==void 0,c=oG(n),o,u,l,f,d,p,h,E;if(c&&!uG(c))for(h=sG(n,c),E=h.next,n=[];!(p=rG(E,h)).done;)n.push(p.value);for(s&&i>2&&(a=tG(a,arguments[2])),u=aG(n),l=new(lG(t))(u),f=cG(l),o=0;u>o;o++)d=s?a(n[o],o):n[o],l[o]=f?fG(d):+d;return l},k_=wt,rk=Rt,R_=qt,pG=Yt,hG=g5,vo=Ht,nk=ZE,$_=cs,vG=rs,ko=ji,mG=oE,gG=Fi,O_=WE,jd=ek,ik=fu,Ro=rr,yG=Bi,lh=tr,bG=ao,_G=wa,wG=Di,uc=co,SG=ba.f,I_=dG,TG=fn.forEach,CG=Ll,EG=ci,ak=qr,sk=ii,Pm=kn,kG=tm,fh=Pm.get,RG=Pm.set,$G=Pm.enforce,ok=ak.f,OG=sk.f,IG=Math.round,Fd=rk.RangeError,uk=nk.ArrayBuffer,PG=uk.prototype,AG=nk.DataView,cc=vo.NATIVE_ARRAY_BUFFER_VIEWS,P_=vo.TYPED_ARRAY_TAG,A_=vo.TypedArray,$o=vo.TypedArrayPrototype,xG=vo.aTypedArrayConstructor,dh=vo.isTypedArray,lc="BYTES_PER_ELEMENT",Ud="Wrong length",x_=function(e,r){xG(e);for(var t=0,n=r.length,i=new e(n);n>t;)i[t]=r[t++];return i},fc=function(e,r){EG(e,r,{configurable:!0,get:function(){return fh(this)[r]}})},M_=function(e){var r;return wG(PG,e)||(r=yG(e))=="ArrayBuffer"||r=="SharedArrayBuffer"},ck=function(e,r){return dh(e)&&!bG(r)&&r in e&&mG(+r)&&r>=0},N_=function(r,t){return t=ik(t),ck(r,t)?vG(2,r[t]):OG(r,t)},L_=function(r,t,n){return t=ik(t),ck(r,t)&&lh(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):ok(r,t,n)};pG?(cc||(sk.f=N_,ak.f=L_,fc($o,"buffer"),fc($o,"byteOffset"),fc($o,"byteLength"),fc($o,"length")),k_({target:"Object",stat:!0,forced:!cc},{getOwnPropertyDescriptor:N_,defineProperty:L_}),sh.exports=function(e,r,t){var n=e.match(/\d+/)[0]/8,i=e+(t?"Clamped":"")+"Array",a="get"+e,s="set"+e,c=rk[i],o=c,u=o&&o.prototype,l={},f=function(E,x){var I=fh(E);return I.view[a](x*n+I.byteOffset,!0)},d=function(E,x,I){var M=fh(E);t&&(I=(I=IG(I))<0?0:I>255?255:I&255),M.view[s](x*n+M.byteOffset,I,!0)},p=function(E,x){ok(E,x,{get:function(){return f(this,x)},set:function(I){return d(this,x,I)},enumerable:!0})};cc?hG&&(o=r(function(E,x,I,M){return $_(E,u),kG(function(){return lh(x)?M_(x)?M!==void 0?new c(x,jd(I,n),M):I!==void 0?new c(x,jd(I,n)):new c(x):dh(x)?x_(o,x):R_(I_,o,x):new c(O_(x))}(),E,o)}),uc&&uc(o,A_),TG(SG(c),function(E){E in o||ko(o,E,c[E])}),o.prototype=u):(o=r(function(E,x,I,M){$_(E,u);var j=0,V=0,ie,oe,J;if(!lh(x))J=O_(x),oe=J*n,ie=new uk(oe);else if(M_(x)){ie=x,V=jd(I,n);var L=x.byteLength;if(M===void 0){if(L%n||(oe=L-V,oe<0))throw Fd(Ud)}else if(oe=gG(M)*n,oe+V>L)throw Fd(Ud);J=oe/n}else return dh(x)?x_(o,x):R_(I_,o,x);for(RG(E,{buffer:ie,byteOffset:V,byteLength:oe,length:J,view:new AG(ie)});j<J;)p(E,j++)}),uc&&uc(o,A_),u=o.prototype=_G($o)),u.constructor!==o&&ko(u,"constructor",o),$G(u).TypedArrayConstructor=o,P_&&ko(u,P_,i);var h=o!=c;l[i]=o,k_({global:!0,constructor:!0,forced:h,sham:!cc},l),lc in o||ko(o,lc,n),lc in u||ko(u,lc,n),CG(i)}):sh.exports=function(){};var MG=sh.exports,NG=MG;NG("Uint8",function(e){return function(t,n,i){return e(this,t,n,i)}});var D_=is,LG=TypeError,Am=function(e,r){if(!delete e[r])throw LG("Cannot delete property "+D_(r)+" of "+D_(e))},DG=Mr,Bd=ss,jG=Ir,FG=Am,UG=Math.min,BG=[].copyWithin||function(r,t){var n=DG(this),i=jG(n),a=Bd(r,i),s=Bd(t,i),c=arguments.length>2?arguments[2]:void 0,o=UG((c===void 0?i:Bd(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]:FG(n,a),a+=u,s+=u;return n},qG=_t,lk=Ht,GG=BG,VG=qG(GG),zG=lk.aTypedArray,WG=lk.exportTypedArrayMethod;WG("copyWithin",function(r,t){return VG(zG(this),r,t,arguments.length>2?arguments[2]:void 0)});var fk=Ht,HG=fn.every,KG=fk.aTypedArray,JG=fk.exportTypedArrayMethod;JG("every",function(r){return HG(KG(this),r,arguments.length>1?arguments[1]:void 0)});var dk=Ht,YG=HE,XG=tk,QG=Bi,ZG=qt,eV=_t,tV=mt,rV=dk.aTypedArray,nV=dk.exportTypedArrayMethod,iV=eV("".slice),aV=tV(function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),e!==1});nV("fill",function(r){var t=arguments.length;rV(this);var n=iV(QG(this),0,3)==="Big"?XG(r):+r;return ZG(YG,this,n,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)},aV);var sV=Ir,oV=function(e,r){for(var t=0,n=sV(r),i=new e(n);n>t;)i[t]=r[t++];return i},pk=Ht,uV=jv,cV=pk.aTypedArrayConstructor,lV=pk.getTypedArrayConstructor,of=function(e){return cV(uV(e,lV(e)))},fV=oV,dV=of,pV=function(e,r){return fV(dV(e),r)},hk=Ht,hV=fn.filter,vV=pV,mV=hk.aTypedArray,gV=hk.exportTypedArrayMethod;gV("filter",function(r){var t=hV(mV(this),r,arguments.length>1?arguments[1]:void 0);return vV(this,t)});var vk=Ht,yV=fn.find,bV=vk.aTypedArray,_V=vk.exportTypedArrayMethod;_V("find",function(r){return yV(bV(this),r,arguments.length>1?arguments[1]:void 0)});var mk=Ht,wV=fn.findIndex,SV=mk.aTypedArray,TV=mk.exportTypedArrayMethod;TV("findIndex",function(r){return wV(SV(this),r,arguments.length>1?arguments[1]:void 0)});var gk=Ht,CV=fn.forEach,EV=gk.aTypedArray,kV=gk.exportTypedArrayMethod;kV("forEach",function(r){CV(EV(this),r,arguments.length>1?arguments[1]:void 0)});var yk=Ht,RV=kl.includes,$V=yk.aTypedArray,OV=yk.exportTypedArrayMethod;OV("includes",function(r){return RV($V(this),r,arguments.length>1?arguments[1]:void 0)});var bk=Ht,IV=kl.indexOf,PV=bk.aTypedArray,AV=bk.exportTypedArrayMethod;AV("indexOf",function(r){return IV(PV(this),r,arguments.length>1?arguments[1]:void 0)});var xV=Rt,MV=mt,xm=_t,_k=Ht,Mm=xC,NV=Gt,Nm=NV("iterator"),j_=xV.Uint8Array,LV=xm(Mm.values),DV=xm(Mm.keys),jV=xm(Mm.entries),Lm=_k.aTypedArray,uf=_k.exportTypedArrayMethod,$s=j_&&j_.prototype,cf=!MV(function(){$s[Nm].call([1])}),wk=!!$s&&$s.values&&$s[Nm]===$s.values&&$s.values.name==="values",Sk=function(){return LV(Lm(this))};uf("entries",function(){return jV(Lm(this))},cf);uf("keys",function(){return DV(Lm(this))},cf);uf("values",Sk,cf||!wk,{name:"values"});uf(Nm,Sk,cf||!wk,{name:"values"});var Tk=Ht,FV=_t,UV=Tk.aTypedArray,BV=Tk.exportTypedArrayMethod,qV=FV([].join);BV("join",function(r){return qV(UV(this),r)});var GV=_a,VV=ln,zV=ui,WV=Ir,HV=ql,KV=Math.min,ph=[].lastIndexOf,Ck=!!ph&&1/[1].lastIndexOf(1,-0)<0,JV=HV("lastIndexOf"),YV=Ck||!JV,XV=YV?function(r){if(Ck)return GV(ph,this,arguments)||0;var t=VV(this),n=WV(t),i=n-1;for(arguments.length>1&&(i=KV(i,zV(arguments[1]))),i<0&&(i=n+i);i>=0;i--)if(i in t&&t[i]===r)return i||0;return-1}:ph,Ek=Ht,QV=_a,ZV=XV,ez=Ek.aTypedArray,tz=Ek.exportTypedArrayMethod;tz("lastIndexOf",function(r){var t=arguments.length;return QV(ZV,ez(this),t>1?[r,arguments[1]]:[r])});var kk=Ht,rz=fn.map,nz=of,iz=kk.aTypedArray,az=kk.exportTypedArrayMethod;az("map",function(r){return rz(iz(this),r,arguments.length>1?arguments[1]:void 0,function(t,n){return new(nz(t))(n)})});var sz=En,oz=Mr,uz=cu,cz=Ir,lz=TypeError,F_=function(e){return function(r,t,n,i){sz(t);var a=oz(r),s=uz(a),c=cz(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 lz("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}},Rk={left:F_(!1),right:F_(!0)},$k=Ht,fz=Rk.left,dz=$k.aTypedArray,pz=$k.exportTypedArrayMethod;pz("reduce",function(r){var t=arguments.length;return fz(dz(this),r,t,t>1?arguments[1]:void 0)});var Ok=Ht,hz=Rk.right,vz=Ok.aTypedArray,mz=Ok.exportTypedArrayMethod;mz("reduceRight",function(r){var t=arguments.length;return hz(vz(this),r,t,t>1?arguments[1]:void 0)});var Ik=Ht,gz=Ik.aTypedArray,yz=Ik.exportTypedArrayMethod,bz=Math.floor;yz("reverse",function(){for(var r=this,t=gz(r).length,n=bz(t/2),i=0,a;i<n;)a=r[i],r[i++]=r[--t],r[t]=a;return r});var Pk=Rt,Ak=qt,Dm=Ht,_z=Ir,wz=ek,Sz=Mr,xk=mt,Tz=Pk.RangeError,hh=Pk.Int8Array,U_=hh&&hh.prototype,Mk=U_&&U_.set,Cz=Dm.aTypedArray,Ez=Dm.exportTypedArrayMethod,vh=!xk(function(){var e=new Uint8ClampedArray(2);return Ak(Mk,e,{length:1,0:3},1),e[1]!==3}),kz=vh&&Dm.NATIVE_ARRAY_BUFFER_VIEWS&&xk(function(){var e=new hh(2);return e.set(1),e.set("2",1),e[0]!==0||e[1]!==2});Ez("set",function(r){Cz(this);var t=wz(arguments.length>1?arguments[1]:void 0,1),n=Sz(r);if(vh)return Ak(Mk,this,n,t);var i=this.length,a=_z(n),s=0;if(a+t>i)throw Tz("Wrong length");for(;s<a;)this[t+s]=n[s++]},!vh||kz);var Nk=Ht,Rz=of,$z=mt,Oz=oo,Iz=Nk.aTypedArray,Pz=Nk.exportTypedArrayMethod,Az=$z(function(){new Int8Array(1).slice()});Pz("slice",function(r,t){for(var n=Oz(Iz(this),r,t),i=Rz(this),a=0,s=n.length,c=new i(s);s>a;)c[a]=n[a++];return c},Az);var Lk=Ht,xz=fn.some,Mz=Lk.aTypedArray,Nz=Lk.exportTypedArrayMethod;Nz("some",function(r){return xz(Mz(this),r,arguments.length>1?arguments[1]:void 0)});var B_=gu,Lz=Math.floor,mh=function(e,r){var t=e.length,n=Lz(t/2);return t<8?Dz(e,r):jz(e,mh(B_(e,0,n),r),mh(B_(e,n),r),r)},Dz=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},jz=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},jm=mh,Fz=ns,q_=Fz.match(/firefox\/(\d+)/i),Dk=!!q_&&+q_[1],Uz=ns,jk=/MSIE|Trident/.test(Uz),Bz=ns,G_=Bz.match(/AppleWebKit\/(\d+)\./),Fk=!!G_&&+G_[1],qz=Rt,Gz=Ol,gh=mt,Vz=En,zz=jm,Uk=Ht,V_=Dk,Wz=jk,z_=no,W_=Fk,Hz=Uk.aTypedArray,Kz=Uk.exportTypedArrayMethod,iu=qz.Uint16Array,Gs=iu&&Gz(iu.prototype.sort),Jz=!!Gs&&!(gh(function(){Gs(new iu(2),null)})&&gh(function(){Gs(new iu(2),{})})),H_=!!Gs&&!gh(function(){if(z_)return z_<74;if(V_)return V_<67;if(Wz)return!0;if(W_)return W_<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}),Yz=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}};Kz("sort",function(r){return r!==void 0&&Vz(r),H_?Gs(this,r):zz(Hz(this),Yz(r))},!H_||Jz);var Bk=Ht,Xz=Fi,K_=ss,Qz=of,Zz=Bk.aTypedArray,e8=Bk.exportTypedArrayMethod;e8("subarray",function(r,t){var n=Zz(this),i=n.length,a=K_(r,i),s=Qz(n);return new s(n.buffer,n.byteOffset+a*n.BYTES_PER_ELEMENT,Xz((t===void 0?i:K_(t,i))-a))});var t8=Rt,r8=_a,qk=Ht,yh=mt,J_=oo,pl=t8.Int8Array,Y_=qk.aTypedArray,n8=qk.exportTypedArrayMethod,Gk=[].toLocaleString,i8=!!pl&&yh(function(){Gk.call(new pl(1))}),a8=yh(function(){return[1,2].toLocaleString()!=new pl([1,2]).toLocaleString()})||!yh(function(){pl.prototype.toLocaleString.call([1,2])});n8("toLocaleString",function(){return r8(Gk,i8?J_(Y_(this)):Y_(this),J_(arguments))},a8);var s8=Ht.exportTypedArrayMethod,o8=mt,u8=Rt,c8=_t,X_=u8.Uint8Array,l8=X_&&X_.prototype||{},hl=[].toString,f8=c8([].join);o8(function(){hl.call({})})&&(hl=function(){return f8(this)});var d8=l8.toString!=hl;s8("toString",hl,d8);var p8=tr,h8=ai,v8=Gt,m8=v8("match"),Vk=function(e){var r;return p8(e)&&((r=e[m8])!==void 0?!!r:h8(e)=="RegExp")},g8=_a,Oo=qt,Fm=_t,y8=Kl,b8=sr,_8=si,w8=Vk,Q_=oi,S8=jv,T8=om,C8=Fi,qd=br,E8=as,Z_=gu,ew=Jl,k8=Hl,R8=GC,$8=mt,_s=R8.UNSUPPORTED_Y,tw=4294967295,O8=Math.min,zk=[].push,I8=Fm(/./.exec),ws=Fm(zk),Io=Fm("".slice),P8=!$8(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"});y8("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=qd(Q_(this)),c=a===void 0?tw:a>>>0;if(c===0)return[];if(i===void 0)return[s];if(!w8(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(k8,f,s))&&(p=f.lastIndex,!(p>l&&(ws(o,Io(s,l,d.index)),d.length>1&&d.index<s.length&&g8(zk,o,Z_(d,1)),h=d[0].length,l=p,o.length>=c)));)f.lastIndex===d.index&&f.lastIndex++;return l===s.length?(h||!I8(f,""))&&ws(o,""):ws(o,Io(s,l)),o.length>c?Z_(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=Q_(this),o=_8(a)?void 0:E8(a,e);return o?Oo(o,a,c,s):Oo(n,qd(c),a,s)},function(i,a){var s=b8(this),c=qd(i),o=t(n,s,c,a,n!==r);if(o.done)return o.value;var u=S8(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?tw:a>>>0;if(p===0)return[];if(c.length===0)return ew(d,c)===null?[c]:[];for(var h=0,E=0,x=[];E<c.length;){d.lastIndex=_s?0:E;var I=ew(d,_s?Io(c,E):c),M;if(I===null||(M=O8(C8(d.lastIndex+(_s?E:0)),c.length))===h)E=T8(c,E,l);else{if(ws(x,Io(c,h,E)),x.length===p)return x;for(var j=1;j<=I.length-1;j++)if(ws(x,I[j]),x.length===p)return x;E=h=M}}return ws(x,Io(c,h)),x}]},!P8,_s);var Wk={exports:{}},Hk={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})(Hk);var A8=Hk.exports,Kk={exports:{}},Jk={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})(Jk);var x8=Jk.exports;(function(e){var r=Dv,t=x8;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})(Kk);var M8=Kk.exports;(function(e){var r=$n,t=Dv,n=A8,i=M8;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})(Wk);var lf=Wk.exports,vl={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
|
-
*/vl.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 Ve=="object"&&Ve;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 x(L,Y)}function E(L){return L=ie(L),/^(?:webOS|i(?:OS|P))/.test(L)?L:d(L)}function x(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 M(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 V(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()),We="Object",be=Z?We:"ScriptBridgingProxyObject",Te=Z?We:"Environment",Se=Z&&Y.java?"JavaPackage":I(Y.java),ge=Z?We:"RuntimeObject",$e=/\bJava/.test(Se)&&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,xe=[],fe=null,Pt=L==Re,ze=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"]),Me=Vt(["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 V(kt,function(yt,st){return yt||RegExp("\\b"+(st.pattern||j(st))+"\\b","i").exec(L)&&(st.label||st)})}function vt(kt){return V(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 Vt(kt){return V(kt,function(yt,st){return yt||RegExp("\\b"+(st.pattern||j(st))+"\\b","i").exec(L)&&(st.label||st)})}function nr(kt){return V(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 V(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 V(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"),Me=="Opera Mini"&&/\bOPiOS\b/.test(L)&&xe.push("running in Turbo/Uncompressed mode"),Me=="IE"&&/\blike iPhone OS\b/.test(L)?(te=oe(L.replace(/like iPhone OS/,"")),Tt=te.manufacturer,ft=te.product):/^iP/.test(ft)?(Me||(Me="Safari"),Le="iOS"+((te=/ OS ([\d_]+)/i.exec(L))?" "+te[1].replace(/_/g,"."):"")):Me=="Konqueror"&&/^Linux\b/i.test(Le)?Le="Kubuntu":Tt&&Tt!="Google"&&(/Chrome/.test(Me)&&!/\bMobile Safari\b/i.test(L)||/\bVita\b/.test(ft))||/\bAndroid\b/.test(Le)&&/^Chrome/.test(Me)&&/\bVersion\//i.test(L)?(Me="Android Browser",Le=/\bAndroid\b/.test(Le)?Le:"Android"):Me=="Silk"?(/\bMobi/i.test(L)||(Le="Android",xe.unshift("desktop mode")),/Accelerated *= *true/i.test(L)&&xe.unshift("accelerated")):Me=="UC Browser"&&/\bUCWEB\b/.test(L)?xe.push("speed mode"):Me=="PaleMoon"&&(te=/\bFirefox\/([\d.]+)\b/.exec(L))?xe.push("identifying as Firefox "+te[1]):Me=="Firefox"&&(te=/\b(Mobile|Tablet|TV)\b/i.exec(L))?(Le||(Le="Firefox OS"),ft||(ft=te[1])):!Me||(te=!/\bMinefield\b/i.test(L)&&/\b(?:Firefox|Safari)\b/.exec(Me))?(Me&&!ft&&/[\/,]|^[^(]+?\)/.test(L.slice(L.indexOf(te+"/")+8))&&(Me=null),(te=ft||Tt||Le)&&(ft||Tt||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(Le))&&(Me=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(Le)?Le:te)+" Browser")):Me=="Electron"&&(te=(/\bChrome\/([\d.]+)\b/.exec(L)||0)[1])&&xe.push("Chromium "+te),ze||(ze=Pr(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",j(Me),"(?:Firefox|Minefield|NetFront)"])),(te=gt=="iCab"&&parseFloat(ze)>3&&"WebKit"||/\bOpera\b/.test(Me)&&(/\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(Me)&&"NetFront")&&(gt=[te]),Me=="IE"&&(te=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(L)||0)[1])?(Me+=" Mobile",Le="Windows Phone "+(/\+$/.test(te)?te:te+".x"),xe.unshift("desktop mode")):/\bWPDesktop\b/i.test(L)?(Me="IE Mobile",Le="Windows Phone 8.x",xe.unshift("desktop mode"),ze||(ze=(/\brv:([\d.]+)/.exec(L)||0)[1])):Me!="IE"&>=="Trident"&&(te=/\brv:([\d.]+)/.exec(L))&&(Me&&xe.push("identifying as "+Me+(ze?" "+ze:"")),Me="IE",ze=te[1]),Pt){if(M(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{ze=Y.require("ringo/engine").version.join("."),Me="RingoJS"}catch{(te=Y.system)&&te.global.system==Y.system&&(Me="Narwhal",Le||(Le=te[0].os||null))}Me||(Me="Rhino")}else typeof Y.process=="object"&&!Y.process.browser&&(te=Y.process)&&(typeof te.versions=="object"&&(typeof te.versions.electron=="string"?(xe.push("Node "+te.versions.node),Me="Electron",ze=te.versions.electron):typeof te.versions.nw=="string"&&(xe.push("Chromium "+ze,"Node "+te.versions.node),Me="NW.js",ze=te.versions.nw)),Me||(Me="Node.js",ur=te.arch,Le=te.platform,ze=/[\d.]+/.exec(te.version),ze=ze?ze[0]:null));else I(te=Y.runtime)==be?(Me="Adobe AIR",Le=te.flash.system.Capabilities.os):I(te=Y.phantom)==ge?(Me="PhantomJS",ze=(te=te.version||null)&&te.major+"."+te.minor+"."+te.patch):typeof Et.documentMode=="number"&&(te=/\bTrident\/(\d+)/i.exec(L))?(ze=[ze,Et.documentMode],(te=+te[1]+4)!=ze[1]&&(xe.push("IE "+ze[1]+" mode"),gt&&(gt[1]=""),ze[1]=te),ze=Me=="IE"?String(ze[1].toFixed(1)):ze[0]):typeof Et.documentMode=="number"&&/^(?:Chrome|Firefox)\b/.test(Me)&&(xe.push("masking as "+Me+" "+ze),Me="IE",ze="11.0",gt=["Trident"],Le="Windows");Le=Le&&E(Le)}if(ze&&(te=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(ze)||/(?:alpha|beta)(?: ?\d)?/i.exec(L+";"+(Pt&&ye.appMinorVersion))||/\bMinefield\b/i.test(L)&&"a")&&(fe=/b/i.test(te)?"beta":"alpha",ze=ze.replace(RegExp(te+"\\+?$"),"")+(fe=="beta"?Qe:G)+(/\d+\+?/.exec(te)||"")),Me=="Fennec"||Me=="Firefox"&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(Le))Me="Firefox Mobile";else if(Me=="Maxthon"&&ze)ze=ze.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(ft))ft=="Xbox 360"&&(Le=null),ft=="Xbox 360"&&/\bIEMobile\b/.test(L)&&xe.unshift("mobile mode");else if((/^(?:Chrome|IE|Opera)$/.test(Me)||Me&&!ft&&!/Browser|Mobi/.test(Me))&&(Le=="Windows CE"||/Mobi/i.test(L)))Me+=" Mobile";else if(Me=="IE"&&Pt)try{Y.external===null&&xe.unshift("platform preview")}catch{xe.unshift("embedded")}else(/\bBlackBerry\b/.test(ft)||/\bBB10\b/.test(L))&&(te=(RegExp(ft.replace(/ +/g," *")+"/([.\\d]+)","i").exec(L)||0)[1]||ze)?(te=[te,/BB10/.test(L)],Le=(te[1]?(ft=null,Tt="BlackBerry"):"Device Software")+" "+te[0],ze=null):this!=x&&ft!="Wii"&&(Pt&&ut||/Opera/.test(Me)&&/\b(?:MSIE|Firefox)\b/i.test(L)||Me=="Firefox"&&/\bOS X (?:\d+\.){2,}/.test(Le)||Me=="IE"&&(Le&&!/^Win/.test(Le)&&ze>5.5||/\bWindows XP\b/.test(Le)&&ze>8||ze==8&&!/\bTrident\b/.test(L)))&&!o.test(te=oe.call(x,L.replace(o,"")+";"))&&te.name&&(te="ing as "+te.name+((te=te.version)?" "+te:""),o.test(Me)?(/\bIE\b/.test(te)&&Le=="Mac OS"&&(Le=null),te="identify"+te):(te="mask"+te,je?Me=E(je.replace(/([a-z])([A-Z])/g,"$1 $2")):Me="Opera",/\bIE\b/.test(te)&&(Le=null),Pt||(ze=null)),gt=["Presto"],xe.push(te));(te=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(L)||0)[1])&&(te=[parseFloat(te.replace(/\.(\d)$/,".0$1")),te],Me=="Safari"&&te[1].slice(-1)=="+"?(Me="WebKit Nightly",fe="alpha",ze=te[1].slice(0,-1)):(ze==te[1]||ze==(te[2]=(/\bSafari\/([\d.]+\+?)/i.exec(L)||0)[1]))&&(ze=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)?"":"+")),Me=="Safari"&&(!ze||parseInt(ze)>45)?ze=te:Me=="Chrome"&&/\bHeadlessChrome/i.test(L)&&xe.unshift("headless")),Me=="Opera"&&(te=/\bzbov|zvav$/.exec(Le))?(Me+=" ",xe.unshift("desktop mode"),te=="zvav"?(Me+="Mini",ze=null):Me+="Mobile",Le=Le.replace(RegExp(" *"+te+"$"),"")):Me=="Safari"&&/\bChrome\b/.exec(gt&>[1])?(xe.unshift("desktop mode"),Me="Chrome Mobile",ze=null,/\bOS X\b/.test(Le)?(Tt="Apple",Le="iOS 4.3+"):Le=null):/\bSRWare Iron\b/.test(Me)&&!ze&&(ze=Pr("Chrome")),ze&&ze.indexOf(te=/[\d.]+$/.exec(Le))==0&&L.indexOf("/"+te+"-")>-1&&(Le=ie(Le.replace(te,""))),Le&&Le.indexOf(Me)!=-1&&!RegExp(Me+" OS").test(Le)&&(Le=Le.replace(RegExp(" *"+j(Me)+" *"),"")),gt&&!/\b(?:Avant|Nook)\b/.test(Me)&&(/Browser|Lunascape|Maxthon/.test(Me)||Me!="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(Me)&>[1])&&(te=gt[gt.length-1])&&xe.push(te),xe.length&&(xe=["("+xe.join("; ")+")"]),Tt&&ft&&ft.indexOf(Tt)<0&&xe.push("on "+Tt),ft&&xe.push((/^on /.test(xe[xe.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),"")),Me&&(/\bWOW64\b/i.test(L)||Pt&&/\w(?:86|32)$/.test(ye.cpuClass||ye.platform)&&!/\bWin64; x64\b/i.test(L))&&xe.unshift("32-bit")):Le&&/^OS X/.test(Le.family)&&Me=="Chrome"&&parseFloat(ze)>=39&&(Le.architecture=64),L||(L=null);var Ct={};return Ct.description=L,Ct.layout=gt&>[0],Ct.manufacturer=Tt,Ct.name=Me,Ct.prerelease=fe,Ct.product=ft,Ct.ua=L,Ct.version=Me&&ze,Ct.os=Le||{architecture:null,family:null,version:null,toString:function(){return"null"}},Ct.parse=oe,Ct.toString=Cr,Ct.version&&xe.unshift(ze),Ct.name&&xe.unshift(Me),Le&&Me&&!(Le==String(Le).split(" ")[0]&&(Le==Me.split(" ")[0]||ft))&&xe.push(ft?"("+Le+")":"on "+Le),xe.length&&(Ct.description=xe.join(" ")),Ct}var J=oe();i&&a?x(J,function(L,Y){i[Y]=L}):n.platform=J}).call(Ve)})(vl,vl.exports);var Yk=vl.exports,N8=qt,L8=Kl,D8=sr,j8=si,F8=Fi,Gd=br,U8=oi,B8=as,q8=om,rw=Jl;L8("match",function(e,r,t){return[function(i){var a=U8(this),s=j8(i)?void 0:B8(i,e);return s?N8(s,i,a):new RegExp(i)[e](Gd(a))},function(n){var i=D8(this),a=Gd(n),s=t(r,i,a);if(s.done)return s.value;if(!i.global)return rw(i,a);var c=i.unicode;i.lastIndex=0;for(var o=[],u=0,l;(l=rw(i,a))!==null;){var f=Gd(l[0]);o[u]=f,f===""&&(i.lastIndex=q8(a,F8(i.lastIndex),c)),u++}return u===0?null:o}]});var G8=Object.is||function(r,t){return r===t?r!==0||1/r===1/t:r!=r&&t!=t},V8=qt,z8=Kl,W8=sr,H8=si,K8=oi,nw=G8,iw=br,J8=as,Y8=Jl;z8("search",function(e,r,t){return[function(i){var a=K8(this),s=H8(i)?void 0:J8(i,e);return s?V8(s,i,a):new RegExp(i)[e](iw(a))},function(n){var i=W8(this),a=iw(n),s=t(r,i,a);if(s.done)return s.value;var c=i.lastIndex;nw(c,0)||(i.lastIndex=0);var o=Y8(i,a);return nw(i.lastIndex,c)||(i.lastIndex=c),o===null?-1:o.index}]});var X8=Yt,Q8=yu,Z8=TypeError,eW=Object.getOwnPropertyDescriptor,tW=X8&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}(),rW=tW?function(e,r){if(Q8(e)&&!eW(e,"length").writable)throw Z8("Cannot set read only .length");return e.length=r}:function(e,r){return e.length=r},nW=wt,iW=Mr,aW=ss,sW=ui,oW=Ir,uW=rW,cW=yC,lW=Pv,fW=uo,Vd=Am,dW=wu,pW=dW("splice"),hW=Math.max,vW=Math.min;nW({target:"Array",proto:!0,forced:!pW},{splice:function(r,t){var n=iW(this),i=oW(n),a=aW(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=vW(hW(sW(t),0),i-a)),cW(i+c-o),u=lW(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]:Vd(n,d);for(l=i;l>i-o+c;l--)Vd(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]:Vd(n,d);for(l=0;l<c;l++)n[l+a]=arguments[l+2];return uW(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=Su,n=Sa,i=os,a=fm,s=li,c=fi,o=$n,u=di,l=us,f=ku,d=Rn,p=Vr,h=pr,E=q6,x=Z6,I=lf,M=zi,j=Yk;function V(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=V(t),J=V(n),L=V(i),Y=V(a),Z=V(s),ye=V(c),Re=V(o),ae=V(u),We=V(l),be=V(f),Te=V(d),Se=ie(h),ge=ie(E),$e=V(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 xe(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 ze(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:xe(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];ze(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 Me(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,Me(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,Me(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=Se.getLogger("twilsock");function Vt(F,q){return["".concat(new Date().toISOString()," Twilsock ").concat(F,":")].concat(Array.from(q))}var nr=function(){function F(q){ae.default(this,F),We.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,Vt("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,Vt("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,Vt("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,Vt("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,Vt("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,Vt("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,Vt("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,Vt("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,Vt("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,Vt("E",O))}}]),F}(),He=new nr(""),Pr="0.12.2",Cr=function(){function F(q,P,O){ae.default(this,F),We.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(x.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),We.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),We.default(L.default(R),"method","update"),R.token=O,R}return P}(Ct);function zt(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=zt(P);function P(O,R,U){var N;return ae.default(this,P),N=q.call(this),We.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),We.default(L.default(R),"method","reply"),We.default(L.default(R),"payload_type","application/json"),We.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),We.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),We.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 wr(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?wr(Object(P),!0).forEach(function(O){We.default(F,O,P[O])}):Object.getOwnPropertyDescriptors?Object.defineProperties(F,Object.getOwnPropertyDescriptors(P)):wr(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),We.default(L.default(R),"newBackoff",null),We.default(L.default(R),"usedBackoff",null),We.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 M.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 zn(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=zn(P);function P(O,R,U){var N;ae.default(this,P),N=q.call(this),We.default(L.default(N),"disconnectingTimer",null),We.default(L.default(N),"disconnectedPromiseResolve",null),We.default(L.default(N),"terminalStates",["disconnected","rejected"]),We.default(L.default(N),"tokenExpiredSasCode",20104),We.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}(),Wn=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))},Wn)};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(x.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),We.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=x.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=xa();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 xa(){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 Ma(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),!(Ma(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),We.default(this,"initializedFlag","twilio_twilsock_token_storage"),We.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}();We.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),We.default(this,"minEventsPortionToSend",50),We.default(this,"maxEventsPortionToSend",100),We.default(this,"pendingEvents",new Map),We.default(this,"readyEvents",[]),We.default(this,"hasInitializationFinished",!1),We.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)};We.default(nn,"TWILSOCK_CONNECT","twilsock.sdk.connect"),We.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),We.default(L.default(N),"version",Pr),We.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})(ef);var Xk={},aw=Yt,mW=_t,gW=qt,yW=mt,zd=mu,bW=hu,_W=uu,wW=Mr,SW=cu,Ss=Object.assign,sw=Object.defineProperty,TW=mW([].concat),Qk=!Ss||yW(function(){if(aw&&Ss({b:1},Ss(sw({},"a",{enumerable:!0,get:function(){sw(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}),Ss({},e)[t]!=7||zd(Ss({},r)).join("")!=n})?function(r,t){for(var n=wW(r),i=arguments.length,a=1,s=bW.f,c=_W.f;i>a;)for(var o=SW(arguments[a++]),u=s?TW(zd(o),s(o)):zd(o),l=u.length,f=0,d;l>f;)d=u[f++],(!aw||gW(c,o,d))&&(n[d]=o[d]);return n}:Ss,CW=wt,ow=Qk;CW({target:"Object",stat:!0,arity:2,forced:Object.assign!==ow},{assign:ow});var bh={exports:{}},uw=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(uw){var cw=new Uint8Array(16);bh.exports=function(){return uw(cw),cw}}else{var lw=new Array(16);bh.exports=function(){for(var r=0,t;r<16;r++)r&3||(t=Math.random()*4294967296),lw[r]=t>>>((r&3)<<3)&255;return lw}}var Zk=bh.exports,eR=[];for(var dc=0;dc<256;++dc)eR[dc]=(dc+256).toString(16).substr(1);function EW(e,r){var t=r||0,n=eR;return[n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]]].join("")}var tR=EW,kW=Zk,RW=tR,fw,Wd,Hd=0,Kd=0;function $W(e,r,t){var n=r&&t||0,i=r||[];e=e||{};var a=e.node||fw,s=e.clockseq!==void 0?e.clockseq:Wd;if(a==null||s==null){var c=kW();a==null&&(a=fw=[c[0]|1,c[1],c[2],c[3],c[4],c[5]]),s==null&&(s=Wd=(c[6]<<8|c[7])&16383)}var o=e.msecs!==void 0?e.msecs:new Date().getTime(),u=e.nsecs!==void 0?e.nsecs:Kd+1,l=o-Hd+(u-Kd)/1e4;if(l<0&&e.clockseq===void 0&&(s=s+1&16383),(l<0||o>Hd)&&e.nsecs===void 0&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Hd=o,Kd=u,Wd=s,o+=122192928e5;var f=((o&268435455)*1e4+u)%4294967296;i[n++]=f>>>24&255,i[n++]=f>>>16&255,i[n++]=f>>>8&255,i[n++]=f&255;var d=o/4294967296*1e4&268435455;i[n++]=d>>>8&255,i[n++]=d&255,i[n++]=d>>>24&15|16,i[n++]=d>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var p=0;p<6;++p)i[n+p]=a[p];return r||RW(i)}var OW=$W,IW=Zk,PW=tR;function AW(e,r,t){var n=r&&t||0;typeof e=="string"&&(r=e==="binary"?new Array(16):null,e=null),e=e||{};var i=e.random||(e.rng||IW)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,r)for(var a=0;a<16;++a)r[n+a]=i[a];return r||PW(i)}var xW=AW,MW=OW,rR=xW,Um=rR;Um.v1=MW;Um.v4=rR;var NW=Um;/*
|
|
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=Su,t=di,n=Sa,i=li,a=fi,s=$n,c=ku,o=Rn,u=ef,l=os,f=us,d=zi,p=fo,h=po,E=pr,x=NW,I=Tr;function M(_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 V=M(r),ie=M(t),oe=M(n),J=M(i),L=M(a),Y=M(s),Z=M(c),ye=M(o),Re=M(l),ae=M(f),We=M(p),be=M(h),Te=j(E),Se=j(x);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=Me(_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=Me(_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=Me(_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=Me(_e,Ie),ve=0;ve<Ie;++ve)ee[ve].call(ce,de,le,ke)}function xe(_e,Ce,ce,de){if(Ce)_e.apply(ce,de);else for(var le=_e.length,ke=Me(_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];xe(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 ze(_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,ze(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,ze(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 Me(_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 Vt(_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=Vt(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=V.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=We.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=V.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=V.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=V.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",Se.v4()),Ie.productId=de,Ie.platform=le,Ie.twilsock=ke,Ie}return oe.default(ce,[{key:"updateRegistration",value:function(){var de=V.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=V.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=V.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 zt,Nr=I.literal("apn","fcm","twilsock");e.Notifications=zt=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=zt._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=V.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=V.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=V.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=zt=ge([I.validateConstructorTypes(I.nonEmptyString,[I.pureObject,"undefined",I.literal(null)]),$e("design:paramtypes",[String,Object])],e.Notifications)})(Xk);var tn={},zr={};/*
|
|
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(zr,"__esModule",{value:!0});var LW=Rn,DW=fo,jW=po,FW=di,UW=li,BW=fi,qW=$n;function ds(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Vs=ds(LW),Za=ds(DW),Jd=ds(jW),GW=ds(FW),VW=ds(UW),zW=ds(BW),dw=ds(qW),Ea=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return{checks:t}};function WW(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=HW(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 HW(e,r){if(e){if(typeof e=="string")return pw(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 pw(e,r)}}function pw(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 nR=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=WW(t),o;try{for(c.s();!(o=c.n()).done;){var u=o.value;if(typeof u=="string"){a=a||Vs.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 KW(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=JW(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 JW(e,r){if(e){if(typeof e=="string")return hw(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 hw(e,r)}}function hw(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 YW=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=KW(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]})},XW=Ea(function(e){return[typeof e=="string"&&e.length>0,"a non-empty string"]}),QW=Ea(function(e){return[typeof e=="number"&&Number.isInteger(e)&&e>=0,"a non-negative integer"]}),ZW=Ea(function(e){return[Vs.default(e)==="object"&&e!==null&&!Array.isArray(e),"a pure object (non-null and non-array)"]});function eH(e){var r=tH();return function(){var n=dw.default(e),i;if(r){var a=dw.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return zW.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}}function au(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=rH(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 rH(e,r){if(e){if(typeof e=="string")return vw(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 vw(e,r)}}function vw(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 ff=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()}},iR=function(r){var t,n,i=["undefined","boolean","number","bigint","string"];if(i.includes(Vs.default(r))&&(n=typeof r=="string"?'"'.concat(r,'"'):"".concat(r)),Vs.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=Vs.default(r)),n},nH=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=Bm(t);return function(a){return function(s){VW.default(o,s);var c=eH(o);function o(){GW.default(this,o);for(var u=arguments.length,l=new Array(u),f=0;f<u;f++)l[f]=arguments[f];return ff(i,l),c.call.apply(c,[this].concat(l))}return o}(a)}},iH=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=Bm(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 ff(i,l),o.apply(this,l)}}},aH=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=Bm(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{ff(i,l)}catch(d){return Promise.reject(d)}return o.apply(this,l)}}},Bm=function(r){var t=[],n=au(r),i;try{for(n.s();!(i=n.n()).done;){var a=i.value;t.push(qm(a))}}catch(s){n.e(s)}finally{n.f()}return t},qm=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(nR(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],x=p[2];a=a||h,!i&&x&&(i=x),E&&(n=typeof E=="string"?[].concat(Jd.default(n),[E]):[].concat(Jd.default(n),Jd.default(E)))}}catch(V){u.e(V)}finally{u.f()}}}catch(V){s.e(V)}finally{s.f()}if(a)return[!0];var I=i||iR(t),M=n.length-1,j=M>0?"".concat(n.slice(0,M).join(", ")," or ").concat(n[M]):n.join(", ");return[!1,I,j,M>1?";":","]},sH=function(r,t){return Ea(function(n){if(Vs.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(qm(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 oH(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=uH(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 uH(e,r){if(e){if(typeof e=="string")return mw(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 mw(e,r)}}function mw(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 cH=function(r,t){return Ea(function(n){if(!Array.isArray(n))return[!1,"an array of ".concat(r)];var i=oH(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(qm(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]})};zr.array=cH;zr.custom=Ea;zr.literal=YW;zr.nonEmptyString=XW;zr.nonNegativeInteger=QW;zr.objectSchema=sH;zr.pureObject=ZW;zr.runtimeTypeValidation=ff;zr.stringifyReceivedType=iR;zr.type=nR;zr.validateConstructorTypes=nH;zr.validateTypes=iH;zr.validateTypesAsync=aH;var _h={exports:{}},gw=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(gw){var yw=new Uint8Array(16);_h.exports=function(){return gw(yw),yw}}else{var bw=new Array(16);_h.exports=function(){for(var r=0,t;r<16;r++)r&3||(t=Math.random()*4294967296),bw[r]=t>>>((r&3)<<3)&255;return bw}}var aR=_h.exports,sR=[];for(var pc=0;pc<256;++pc)sR[pc]=(pc+256).toString(16).substr(1);function lH(e,r){var t=r||0,n=sR;return[n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]]].join("")}var oR=lH,fH=aR,dH=oR,_w,Yd,Xd=0,Qd=0;function pH(e,r,t){var n=r&&t||0,i=r||[];e=e||{};var a=e.node||_w,s=e.clockseq!==void 0?e.clockseq:Yd;if(a==null||s==null){var c=fH();a==null&&(a=_w=[c[0]|1,c[1],c[2],c[3],c[4],c[5]]),s==null&&(s=Yd=(c[6]<<8|c[7])&16383)}var o=e.msecs!==void 0?e.msecs:new Date().getTime(),u=e.nsecs!==void 0?e.nsecs:Qd+1,l=o-Xd+(u-Qd)/1e4;if(l<0&&e.clockseq===void 0&&(s=s+1&16383),(l<0||o>Xd)&&e.nsecs===void 0&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Xd=o,Qd=u,Yd=s,o+=122192928e5;var f=((o&268435455)*1e4+u)%4294967296;i[n++]=f>>>24&255,i[n++]=f>>>16&255,i[n++]=f>>>8&255,i[n++]=f&255;var d=o/4294967296*1e4&268435455;i[n++]=d>>>8&255,i[n++]=d&255,i[n++]=d>>>24&15|16,i[n++]=d>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var p=0;p<6;++p)i[n+p]=a[p];return r||dH(i)}var hH=pH,vH=aR,mH=oR;function gH(e,r,t){var n=r&&t||0;typeof e=="string"&&(r=e==="binary"?new Array(16):null,e=null),e=e||{};var i=e.random||(e.rng||vH)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,r)for(var a=0;a<16;++a)r[n+a]=i[a];return r||mH(i)}var yH=gH,bH=hH,uR=yH,Vm=uR;Vm.v1=bH;Vm.v4=uR;var _H=Vm;/*
|
|
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 wH=Su,SH=di,TH=Sa,CH=os,EH=li,kH=fi,RH=$n,$H=us,OH=ku,IH=Rn,Pe=zr,ml=ef,PH=lf,AH=pr,xH=fo,cR=zi,lR=_H,MH=fm,NH=Yk;function dn(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function zm(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(wH),Ot=dn(SH),Nt=dn(TH),ti=dn(CH),Wr=dn(EH),ka=dn(kH),or=dn(RH),jt=dn($H),ne=dn(OH),fR=dn(IH),LH=dn(PH),DH=zm(AH),dR=dn(xH),jH=zm(lR),Ou=dn(MH),hc=zm(NH);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":fR.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":fR.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,r)}var FH;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&&FH.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 pR(e){return e._maxListeners===void 0?Ut.defaultMaxListeners:e._maxListeners}Ut.prototype.getMaxListeners=function(){return pR(this)};function UH(e,r,t){if(r)e.call(t);else for(var n=e.length,i=Iu(e,n),a=0;a<n;++a)i[a].call(t)}function BH(e,r,t,n){if(r)e.call(t,n);else for(var i=e.length,a=Iu(e,i),s=0;s<i;++s)a[s].call(t,n)}function qH(e,r,t,n,i){if(r)e.call(t,n,i);else for(var a=e.length,s=Iu(e,a),c=0;c<a;++c)s[c].call(t,n,i)}function GH(e,r,t,n,i,a){if(r)e.call(t,n,i,a);else for(var s=e.length,c=Iu(e,s),o=0;o<s;++o)c[o].call(t,n,i,a)}function VH(e,r,t,n){if(r)e.apply(t,n);else for(var i=e.length,a=Iu(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:UH(n,f,this);break;case 2:BH(n,f,this,arguments[1]);break;case 3:qH(n,f,this,arguments[1],arguments[2]);break;case 4:GH(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];VH(n,f,this,a)}return!0};function hR(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=pR(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,zH(c)}return e}function zH(e){typeof console.warn=="function"?console.warn(e):console.log(e)}Ut.prototype.addListener=function(r,t){return hR(this,r,t,!1)};Ut.prototype.on=Ut.prototype.addListener;Ut.prototype.prependListener=function(r,t){return hR(this,r,t,!0)};function vR(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,vR(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,vR(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 WH(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=HH(t):n=[]):n=[],n};Ut.listenerCount=function(e,r){return typeof e.listenerCount=="function"?e.listenerCount(r):mR.call(e,r)};Ut.prototype.listenerCount=mR;function mR(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 WH(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 Iu(e,r){for(var t=new Array(r);r--;)t[r]=e[r];return t}function HH(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 gR(e){var r=KH();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 KH(){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){Wr.default(t,e);var r=gR(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}(LH.default(Error)),JH=function(e){Wr.default(t,e);var r=gR(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 yR(e){var r=e===void 0||Wm(e);if(!r)throw new en("Invalid pageSize parameter. Expected a positive integer, was '".concat(e,"'."),400,20007)}function YH(e){return!isNaN(parseInt(e))&&isFinite(e)}function Wm(e){return YH(e)&&e>0}var Ts=DH.getLogger("twilio-sync");function Po(e,r){return["".concat(new Date().toISOString()," Sync ").concat(e,":")].concat(Array.from(r))}var xt={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))}},XH="/v4/Subscriptions",QH="/v3/Maps",ZH="/v3/Lists",e9="/v3/Documents",t9="/v3/Streams",r9="/v3/Insights";function n9(e,r,t){return e&&typeof e[r]<"u"?e[r]:t}var i9=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+XH,documentsUri:i+e9,listsUri:i+ZH,mapsUri:i+QH,streamsUri:i+t9,insightsUri:i+r9,sessionStorageEnabled:n9(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=a9(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 a9(e,r){if(e){if(typeof e=="string")return ww(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 ww(e,r)}}function ww(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 s9=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}(),o9=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=cR.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(),xt.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=dR.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(x){l.e(x)}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,x,I,M,j,V,ie,oe;return ne.default.wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(this.isConnected){L.next=4;break}return xt.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),x=E&&h>0,x&&(this.subscriptionTtlTimer=setTimeout(function(){return s.onSubscriptionTtlElapsed()},h*1e3))),i==="establish"&&(I=d.body.estimated_delivery_in_ms,M=!isNaN(parseFloat(I))&&isFinite(I),j=M&&I>0,j?setTimeout(function(){return s.verifyPokeDelivery(c,I,a)},I):xt.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),V=Ao(a);try{for(V.s();!(ie=V.n()).done;)oe=ie.value,this.recordActionFailureOn(oe,i)}catch(Y){V.e(Y)}finally{V.f()}L.t0 instanceof ml.TransportUnavailableError?(xt.debug("Twilsock connection (required for subscription) not ready (c:".concat(c,"); waiting…")),this.backoff.reset()):(xt.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;xt.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){xt.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 s9(n)),this.persist())}},{key:"remove",value:function(t){xt.debug("Establishing intent to unsubscribe from ".concat(t));var n=this.subscriptions.delete(t);n&&this.persist()}},{key:"acceptMessage",value:function(t,n){xt.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:xt.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"?(xt.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"&&(xt.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()):xt.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)):xt.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&&(xt.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)):xt.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){xt.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}(),u9=4e3,c9=6e4,l9=9e4,f9=.2;function Sw(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 Tw(e){return e.body?e.body.code:0}function xo(e){return e.status===409?new JH(Sw(e),e.status,Tw(e),e.body):e.status?new en(Sw(e),e.status,Tw(e)):e instanceof ml.TransportUnavailableError?e:new en(e.message,0,0)}var d9=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"+jH.v4().replace(/-/g,"")}}},{key:"backoffConfig",value:function(){return Object.assign({min:u9,max:c9,maxAttemptsTime:l9,randomness:f9},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 cR.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(xo(u),isNaN(l)?null:l*1e3)}else u.message==="Twilsock disconnected"?o.failed(xo(u)):(o.removeAllListeners(),o.cancel(),s(xo(u)))})}),o.on("succeeded",function(u){a(u)}),o.on("cancelled",function(u){return s(xo(u))}),o.on("failed",function(u){return s(xo(u))}),o.start()})}},{key:"get",value:function(t){var n=this,i=this.createHeaders();return xt.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),xt.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),xt.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 xt.debug("DELETE",t,"ID:",i["Twilio-Request-Id"]),this.executeWithRetry(function(){return n.transport.delete(t,i,n.config.productId)},!1)}}]),e}(),p9=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 h9(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=v9(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 v9(e,r){if(e){if(typeof e=="string")return Cw(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 Cw(e,r)}}function Cw(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 Pu=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=h9(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}(),bR=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}(),_R=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 bR(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 m9(e){var r=g9();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 g9(){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 Au=function(e){Wr.default(t,e);var r=m9(t);function t(){var n;return Ot.default(this,t),n=r.call(this),n.closed=!1,n.uuid=lR.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 wR(e){var r=y9();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 y9(){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 wh=function(e){Wr.default(t,e);var r=wR(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 bR(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){xt.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):xt.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}(Pu),Sn=function(e){Wr.default(t,e);var r=wR(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 wh.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(){Ou.default(or.default(t.prototype),"close",this).call(this),this.syncDocumentImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return wh.type}}]),t}(Au);jt.default(Sn,"removed","removed");jt.default(Sn,"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)],Sn.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)],Sn.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)],Sn.prototype,"update",null);It([Pe.validateTypesAsync(Pe.nonNegativeInteger),Ne("design:type",Function),Ne("design:paramtypes",[Number]),Ne("design:returntype",Promise)],Sn.prototype,"setTtl",null);var Sh=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}(),Hm=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 b9(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=_9(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 _9(e,r){if(e){if(typeof e=="string")return Ew(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 Ew(e,r)}}function Ew(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 w9=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}(),S9=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 w9(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=b9(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 T9(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=C9(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 C9(e,r){if(e){if(typeof e=="string")return kw(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 kw(e,r)}}function kw(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 E9=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}(),k9=function(){function e(r){Ot.default(this,e),this.revision=r}return Nt.default(e,[{key:"isValid",get:function(){return!1}}]),e}(),Km=function(){function e(){Ot.default(this,e),this.items=new S9}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 E9(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 k9(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=T9(this.items),i;try{for(n.s();!(i=n.n()).done;){var a=dR.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 SR(e){var r=R9();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 R9(){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){Wr.default(t,e);var r=SR(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 _R(c),s.cache=new Km,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 Sh({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 Hm(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||{},yR(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)){xt.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 Sh({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):(xt.trace("Context update skipped, current:",this.lastEventId,", remote:",a),!1)}}],[{key:"type",get:function(){return"list"}}]),t}(Pu),dr=function(e){Wr.default(t,e);var r=SR(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(){Ou.default(or.default(t.prototype),"close",this).call(this),this.syncListImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return Th.type}}]),t}(Au);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[Wm(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 TR(e){var r=$9();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 $9(){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 Ch=function(e){Wr.default(t,e);var r=TR(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 _R(c),s.cache=new Km,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(x){if(x.status===404)return new Fo({key:s,data:{},last_event_id:-1,revision:"-1",url:null,date_updated:null,date_expires:null});throw x});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(x){for(;;)switch(x.prev=x.next){case 0:return l=new Ys(this.links.items).pathSegment(s).build(),f={data:c},u!==void 0&&(f.ttl=u),x.prev=3,x.next=6,this.services.network.put(l,f,o);case 6:return d=x.sent,p=d.body,p.data=c,p.date_updated=new Date(p.date_updated),h=d.status.code===201,x.abrupt("return",{added:h,item:p});case 14:throw x.prev=14,x.t0=x.catch(3),x.t0.status===404&&this.onRemoved(!1),x.t0;case 18:case"end":return x.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 Hm(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||{},yR(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)){xt.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}(Pu),yr=function(e){Wr.default(t,e);var r=TR(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 Ch.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(){Ou.default(or.default(t.prototype),"close",this).call(this),this.syncMapImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return Ch.type}}]),t}(Au);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[Wm(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 CR(e){var r=O9();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 O9(){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){Wr.default(t,e);var r=CR(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}(Pu);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){Wr.default(t,e);var r=CR(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(){Ou.default(or.default(t.prototype),"close",this).call(this),this.syncStreamImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return su.type}}]),t}(Au);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 I9=function e(r){Ot.default(this,e),this.sdk="js",this.sdkVer=r,this.os=hc.os.family,this.osVer=hc.os.version,this.pl=hc.name,this.plVer=hc.version},P9=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 Jm(e){var r=A9();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 A9(){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 x9=function e(){Ot.default(this,e)},Eh=function(e){Wr.default(t,e);var r=Jm(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 Km,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))xt.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)?xt.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}(Pu);function ER(e){return kh.apply(this,arguments)}function kh(){return kh=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)})),kh.apply(this,arguments)}var Oi=function(e){Wr.default(t,e);var r=Jm(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 Eh.type}},{key:"lastEventId",get:function(){return this.liveQueryImpl.lastEventId}},{key:"sid",get:function(){return this.liveQueryImpl.sid}},{key:"close",value:function(){Ou.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 Eh.type}}]),t}(Au);jt.default(Oi,"itemUpdated","itemUpdated");jt.default(Oi,"itemRemoved","itemRemoved");var xu=function(e){Wr.default(t,e);var r=Jm(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",ER({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 xt.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 M9="3.1.0";function N9(e){var r=L9();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 L9(){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 Rw(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 $w(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?Rw(Object(t),!0).forEach(function(n){jt.default(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Rw(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}var D9="data_sync",Zd=M9;function vc(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 $w($w({},e),{},{mode:r})}else return{mode:"create_new"}}var Ow="com.twilio.rtd.cds.document",Iw="com.twilio.rtd.cds.list",Pw="com.twilio.rtd.cds.map",Aw="twilio.sync.event",pn=function(e){Wr.default(t,e);var r=N9(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")?xt.setLevel(a.logLevel):xt.setLevel("silent");var s=a.productId=a.productId||D9;a.clientMetadata=a.clientMetadata||{},a.clientMetadata.hasOwnProperty("type")||(a.clientMetadata.type="sync"),a.clientMetadata.hasOwnProperty("sdk")||(a.clientMetadata.sdk="JS",a.clientMetadata.sdkv=Zd);var c=!a.twilsockClient;if(!a.initRegistrations){var o=new ml.InitRegistration(s);t.populateInitRegistrations(o),a.initRegistrations=[o]}var u=a.twilsockClient=a.twilsockClient||new ml.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 i9(a),f=new d9(new I9(Zd),l,u),d=new p9(l);return i.services={config:l,twilsock:u,network:f,storage:d,router:ti.default(i),subscriptions:null},i.services.subscriptions=new o9(i.services),i.entities=new P9,c&&u.connect(),i}return Nt.default(t,[{key:"_routeMessage",value:function(i,a){switch(xt.trace("Notification type:",i,"content:",a),i){case Ow:case Iw:case Pw:this.services.subscriptions.acceptMessage(a,!1);break;case Aw: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),xt.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(Sn.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=vc(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,Sn.type),!l){p.next=14;break}return p.abrupt("return",new Sn(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(Sn.type,o.id,u),f=new wh(this.services,u,function(h,E,x){return c.removeFromCacheAndSession(h,E,x)}),f=this.entities.store(f),p.abrupt("return",new Sn(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=vc(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 Ch(this.services,u,function(h,E,x){return c.removeFromCacheAndSession(h,E,x)}),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=vc(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,x){return c.removeFromCacheAndSession(h,E,x)}),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=vc(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(x,I,M){return c.removeFromCacheAndSession(x,I,M)},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,ER({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,M,j){return o.removeFromCacheAndSession(I,M,j)},f=new Eh(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([Aw,Ow,Iw,Pw])}},{key:"version",get:function(){return Zd}}]),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=x9;tn.InstantQuery=xu;tn.LiveQuery=Oi;tn.Paginator=Hm;tn.SyncClient=pn;tn.SyncDocument=Sn;tn.SyncList=dr;tn.SyncListItem=Sh;tn.SyncMap=yr;tn.SyncMapItem=Fo;tn.SyncStream=Zn;var kR={},j9=Vk,F9=TypeError,RR=function(e){if(j9(e))throw F9("The method doesn't accept regular expressions");return e},U9=Gt,B9=U9("match"),$R=function(e){var r=/./;try{"/./"[e](r)}catch{try{return r[B9]=!1,"/./"[e](r)}catch{}}return!1},q9=wt,OR=Ol,G9=ii.f,V9=Fi,xw=br,z9=RR,W9=oi,H9=$R,Mw=OR("".startsWith),K9=OR("".slice),J9=Math.min,IR=H9("startsWith"),Y9=!IR&&!!function(){var e=G9(String.prototype,"startsWith");return e&&!e.writable}();q9({target:"String",proto:!0,forced:!Y9&&!IR},{startsWith:function(r){var t=xw(W9(this));z9(r);var n=V9(J9(arguments.length>1?arguments[1]:void 0,t.length)),i=xw(r);return Mw?Mw(t,i,n):K9(t,n,n+i.length)===i}});var X9=mt,Q9=Gt,Z9=Yt,Nw=M0,e7=Q9("iterator"),PR=!X9(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}),Nw&&!e.toJSON||!r.size&&(Nw||!Z9)||!r.sort||e.href!=="http://a/c%20d?a=1&c=3"||r.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!r[e7]||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,ep=2147483647,Jo=36,AR=1,Rh=26,t7=38,r7=700,n7=72,i7=128,a7="-",s7=/[^\0-\u007E]/,xR=/[.\u3002\uFF0E\uFF61]/g,Lw="Overflow: input needs wider integers to process",tp=Jo-AR,Dw=RangeError,o7=ps(xR.exec),Ms=Math.floor,rp=String.fromCharCode,jw=ps("".charCodeAt),MR=ps([].join),ua=ps([].push),u7=ps("".replace),c7=ps("".split),l7=ps("".toLowerCase),f7=function(e){for(var r=[],t=0,n=e.length;t<n;){var i=jw(e,t++);if(i>=55296&&i<=56319&&t<n){var a=jw(e,t++);(a&64512)==56320?ua(r,((i&1023)<<10)+(a&1023)+65536):(ua(r,i),t--)}else ua(r,i)}return r},Fw=function(e){return e+22+75*(e<26)},d7=function(e,r,t){var n=0;for(e=t?Ms(e/r7):e>>1,e+=Ms(e/r);e>tp*Rh>>1;)e=Ms(e/tp),n+=Jo;return Ms(n+(tp+1)*e/(e+t7))},p7=function(e){var r=[];e=f7(e);var t=e.length,n=i7,i=0,a=n7,s,c;for(s=0;s<e.length;s++)c=e[s],c<128&&ua(r,rp(c));var o=r.length,u=o;for(o&&ua(r,a7);u<t;){var l=ep;for(s=0;s<e.length;s++)c=e[s],c>=n&&c<l&&(l=c);var f=u+1;if(l-n>Ms((ep-i)/f))throw Dw(Lw);for(i+=(l-n)*f,n=l,s=0;s<e.length;s++){if(c=e[s],c<n&&++i>ep)throw Dw(Lw);if(c==n){for(var d=i,p=Jo;;){var h=p<=a?AR:p>=a+Rh?Rh:p-a;if(d<h)break;var E=d-h,x=Jo-h;ua(r,rp(Fw(h+E%x))),d=Ms(E/x),p+=Jo}ua(r,rp(Fw(d))),a=d7(i,f,u==o),i=0,u++}}i++,n++}return MR(r,"")},h7=function(e){var r=[],t=c7(u7(l7(e),xR,"."),"."),n,i;for(n=0;n<t.length;n++)i=t[n],ua(r,o7(s7,i)?"xn--"+p7(i):i);return MR(r,".")},$h=wt,Xs=Rt,mc=qt,ri=_t,zs=Yt,NR=PR,LR=Gr,v7=ci,m7=mm,g7=Ui,y7=TC,Ym=kn,DR=cs,np=Bt,b7=rr,_7=qi,w7=Bi,S7=sr,jR=tr,un=br,T7=wa,Uw=rs,Oh=Fl,C7=Eu,Cs=Fv,E7=Gt,k7=jm,R7=E7("iterator"),Mu="URLSearchParams",FR=Mu+"Iterator",UR=Ym.set,_n=Ym.getterFor(Mu),$7=Ym.getterFor(FR),O7=Object.getOwnPropertyDescriptor,Xm=function(e){if(!zs)return Xs[e];var r=O7(Xs,e);return r&&r.value},Bw=Xm("fetch"),gl=Xm("Request"),Yo=Xm("Headers"),ip=gl&&gl.prototype,qw=Yo&&Yo.prototype,I7=Xs.RegExp,P7=Xs.TypeError,BR=Xs.decodeURIComponent,A7=Xs.encodeURIComponent,x7=ri("".charAt),Gw=ri([].join),Ha=ri([].push),Ih=ri("".replace),M7=ri([].shift),Vw=ri([].splice),zw=ri("".split),N7=ri("".slice),L7=/\+/g,Ww=Array(4),D7=function(e){return Ww[e-1]||(Ww[e-1]=I7("((?:%[\\da-f]{2}){"+e+"})","gi"))},j7=function(e){try{return BR(e)}catch{return e}},Hw=function(e){var r=Ih(e,L7," "),t=4;try{return BR(r)}catch{for(;t;)r=Ih(r,D7(t--),j7);return r}},F7=/[!'()~]|%20/g,U7={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},B7=function(e){return U7[e]},Kw=function(e){return Ih(A7(e),F7,B7)},ap=y7(function(r,t){UR(this,{type:FR,iterator:Oh(_n(r).entries),kind:t})},"Iterator",function(){var r=$7(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),qR=function(e){this.entries=[],this.url=null,e!==void 0&&(jR(e)?this.parseObject(e):this.parseQuery(typeof e=="string"?x7(e,0)==="?"?N7(e,1):e:un(e)))};qR.prototype={type:Mu,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var r=C7(e),t,n,i,a,s,c,o;if(r)for(t=Oh(e,r),n=t.next;!(i=mc(n,t)).done;){if(a=Oh(S7(i.value)),s=a.next,(c=mc(s,a)).done||(o=mc(s,a)).done||!mc(s,a).done)throw P7("Expected sequence with length 2");Ha(this.entries,{key:un(c.value),value:un(o.value)})}else for(var u in e)b7(e,u)&&Ha(this.entries,{key:u,value:un(e[u])})},parseQuery:function(e){if(e)for(var r=zw(e,"&"),t=0,n,i;t<r.length;)n=r[t++],n.length&&(i=zw(n,"="),Ha(this.entries,{key:Hw(M7(i)),value:Hw(Gw(i,"="))}))},serialize:function(){for(var e=this.entries,r=[],t=0,n;t<e.length;)n=e[t++],Ha(r,Kw(n.key)+"="+Kw(n.value));return Gw(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var df=function(){DR(this,Qs);var r=arguments.length>0?arguments[0]:void 0,t=UR(this,new qR(r));zs||(this.length=t.entries.length)},Qs=df.prototype;m7(Qs,{append:function(r,t){Cs(arguments.length,2);var n=_n(this);Ha(n.entries,{key:un(r),value:un(t)}),zs||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?Vw(t,i,1):i++;zs||(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?Vw(i,o--,1):(a=!0,u.value=c));a||Ha(i,{key:s,value:c}),zs||(this.length=i.length),n.updateURL()},sort:function(){var r=_n(this);k7(r.entries,function(t,n){return t.key>n.key?1:-1}),r.updateURL()},forEach:function(r){for(var t=_n(this).entries,n=_7(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 ap(this,"keys")},values:function(){return new ap(this,"values")},entries:function(){return new ap(this,"entries")}},{enumerable:!0});LR(Qs,R7,Qs.entries,{name:"entries"});LR(Qs,"toString",function(){return _n(this).serialize()},{enumerable:!0});zs&&v7(Qs,"size",{get:function(){return _n(this).entries.length},configurable:!0,enumerable:!0});g7(df,Mu);$h({global:!0,constructor:!0,forced:!NR},{URLSearchParams:df});if(!NR&&np(Yo)){var q7=ri(qw.has),G7=ri(qw.set),Jw=function(e){if(jR(e)){var r=e.body,t;if(w7(r)===Mu)return t=e.headers?new Yo(e.headers):new Yo,q7(t,"content-type")||G7(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),T7(e,{body:Uw(0,un(r)),headers:Uw(0,t)})}return e};if(np(Bw)&&$h({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(r){return Bw(r,arguments.length>1?Jw(arguments[1]):{})}}),np(gl)){var sp=function(r){return DR(this,ip),new gl(r,arguments.length>1?Jw(arguments[1]):{})};ip.constructor=sp,sp.prototype=ip,$h({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:sp})}}var V7={URLSearchParams:df,getState:_n},z7=wt,Qm=Yt,W7=PR,Zm=Rt,Yw=qi,On=_t,yl=Gr,mn=ci,H7=cs,Ph=rr,eg=Qk,Es=_C,Mn=gu,K7=Kv.codeAt,J7=h7,Si=br,Y7=Ui,X7=Fv,GR=V7,VR=kn,Q7=VR.set,bl=VR.getterFor("URL"),Z7=GR.URLSearchParams,eK=GR.getState,Mo=Zm.URL,Ah=Zm.TypeError,_l=Zm.parseInt,tK=Math.floor,Xw=Math.pow,wn=On("".charAt),Fn=On(/./.exec),Uo=On([].join),rK=On(1 .toString),nK=On([].pop),Os=On([].push),op=On("".replace),iK=On([].shift),aK=On("".split),Xo=On("".slice),wl=On("".toLowerCase),sK=On([].unshift),oK="Invalid authority",up="Invalid scheme",qa="Invalid host",Qw="Invalid port",zR=/[a-z]/i,uK=/[\d+-.a-z]/i,xh=/\d/,cK=/^0x/i,lK=/^[0-7]+$/,fK=/^\d+$/,WR=/^[\da-f]+$/i,dK=/[\0\t\n\r #%/:<>?@[\\\]^|]/,pK=/[\0\t\n\r #/:<>?@[\\\]^|]/,hK=/^[\u0000-\u0020]+/,vK=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,mK=/[\t\n\r]/g,gn,gK=function(e){var r=aK(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&&wn(a,0)=="0"&&(s=Fn(cK,a)?16:8,a=Xo(a,s==8?1:2)),a==="")c=0;else{if(!Fn(s==10?fK:s==8?lK:WR,a))return e;c=_l(a,s)}Os(n,c)}for(i=0;i<t;i++)if(c=n[i],i==t-1){if(c>=Xw(256,5-t))return null}else if(c>255)return null;for(o=nK(n),i=0;i<n.length;i++)o+=n[i]*Xw(256,3-i);return o},yK=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 wn(e,i)};if(d()==":"){if(wn(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(WR,d());)a=a*16+_l(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(xh,d()))return;for(;Fn(xh,d());){if(u=_l(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},bK=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++)sK(r,e%256),e=tK(e/256);return Uo(r,".")}else if(typeof e=="object"){for(r="",n=bK(e),t=0;t<8;t++)i&&e[t]===0||(i&&(i=!1),n===t?(r+=t?":":"::",i=!0):(r+=rK(e[t],16),t<7&&(r+=":")));return"["+r+"]"}return e},Jc={},HR=eg({},Jc,{" ":1,'"':1,"<":1,">":1,"`":1}),KR=eg({},HR,{"#":1,"?":1,"{":1,"}":1}),cp=eg({},KR,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),aa=function(e,r){var t=K7(e,0);return t>32&&t<127&&!Ph(r,e)?e:encodeURIComponent(e)},gc={ftp:21,file:null,http:80,https:443,ws:80,wss:443},Bo=function(e,r){var t;return e.length==2&&Fn(zR,wn(e,0))&&((t=wn(e,1))==":"||!r&&t=="|")},Zw=function(e){var r;return e.length>1&&Bo(Xo(e,0,2))&&(e.length==2||(r=wn(e,2))==="/"||r==="\\"||r==="?"||r==="#")},_K=function(e){return e==="."||wl(e)==="%2e"},wK=function(e){return e=wl(e),e===".."||e==="%2e."||e===".%2e"||e==="%2e%2e"},lp={},eS={},fp={},tS={},rS={},dp={},nS={},iS={},yc={},bc={},pp={},hp={},vp={},mp={},aS={},gp={},ks={},Xn={},sS={},Ga={},_i={},tg=function(e,r,t){var n=Si(e),i,a,s;if(r){if(a=this.parse(n),a)throw Ah(a);this.searchParams=null}else{if(t!==void 0&&(i=new tg(t,!0)),a=this.parse(n,null,i),a)throw Ah(a);s=eK(new Z7),s.bindURL(this),this.searchParams=s}};tg.prototype={type:"URL",parse:function(e,r,t){var n=this,i=r||lp,a=0,s="",c=!1,o=!1,u=!1,l,f,d,p;for(e=Si(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=op(e,hK,""),e=op(e,vK,"$1")),e=op(e,mK,""),l=Es(e);a<=l.length;){switch(f=l[a],i){case lp:if(f&&Fn(zR,f))s+=wl(f),i=eS;else{if(r)return up;i=fp;continue}break;case eS:if(f&&(Fn(uK,f)||f=="+"||f=="-"||f=="."))s+=wl(f);else if(f==":"){if(r&&(n.isSpecial()!=Ph(gc,s)||s=="file"&&(n.includesCredentials()||n.port!==null)||n.scheme=="file"&&!n.host))return;if(n.scheme=s,r){n.isSpecial()&&gc[n.scheme]==n.port&&(n.port=null);return}s="",n.scheme=="file"?i=mp:n.isSpecial()&&t&&t.scheme==n.scheme?i=tS:n.isSpecial()?i=iS:l[a+1]=="/"?(i=rS,a++):(n.cannotBeABaseURL=!0,Os(n.path,""),i=sS)}else{if(r)return up;s="",i=fp,a=0;continue}break;case fp:if(!t||t.cannotBeABaseURL&&f!="#")return up;if(t.cannotBeABaseURL&&f=="#"){n.scheme=t.scheme,n.path=Mn(t.path),n.query=t.query,n.fragment="",n.cannotBeABaseURL=!0,i=_i;break}i=t.scheme=="file"?mp:dp;continue;case tS:if(f=="/"&&l[a+1]=="/")i=yc,a++;else{i=dp;continue}break;case rS:if(f=="/"){i=bc;break}else{i=Xn;continue}case dp: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=Mn(t.path),n.query=t.query;else if(f=="/"||f=="\\"&&n.isSpecial())i=nS;else if(f=="?")n.username=t.username,n.password=t.password,n.host=t.host,n.port=t.port,n.path=Mn(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=Mn(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=Mn(t.path),n.path.length--,i=Xn;continue}break;case nS:if(n.isSpecial()&&(f=="/"||f=="\\"))i=yc;else if(f=="/")i=bc;else{n.username=t.username,n.password=t.password,n.host=t.host,n.port=t.port,i=Xn;continue}break;case iS:if(i=yc,f!="/"||wn(s,a+1)!="/")continue;a++;break;case yc:if(f!="/"&&f!="\\"){i=bc;continue}break;case bc: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 x=aa(E,cp);u?n.password+=x:n.username+=x}s=""}else if(f==gn||f=="/"||f=="?"||f=="#"||f=="\\"&&n.isSpecial()){if(c&&s=="")return oK;a-=Es(s).length+1,s="",i=pp}else s+=f;break;case pp:case hp:if(r&&n.scheme=="file"){i=gp;continue}else if(f==":"&&!o){if(s=="")return qa;if(p=n.parseHost(s),p)return p;if(s="",i=vp,r==hp)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 vp:if(Fn(xh,f))s+=f;else if(f==gn||f=="/"||f=="?"||f=="#"||f=="\\"&&n.isSpecial()||r){if(s!=""){var I=_l(s,10);if(I>65535)return Qw;n.port=n.isSpecial()&&I===gc[n.scheme]?null:I,s=""}if(r)return;i=ks;continue}else return Qw;break;case mp:if(n.scheme="file",f=="/"||f=="\\")i=aS;else if(t&&t.scheme=="file")if(f==gn)n.host=t.host,n.path=Mn(t.path),n.query=t.query;else if(f=="?")n.host=t.host,n.path=Mn(t.path),n.query="",i=Ga;else if(f=="#")n.host=t.host,n.path=Mn(t.path),n.query=t.query,n.fragment="",i=_i;else{Zw(Uo(Mn(l,a),""))||(n.host=t.host,n.path=Mn(t.path),n.shortenPath()),i=Xn;continue}else{i=Xn;continue}break;case aS:if(f=="/"||f=="\\"){i=gp;break}t&&t.scheme=="file"&&!Zw(Uo(Mn(l,a),""))&&(Bo(t.path[0],!0)?Os(n.path,t.path[0]):n.host=t.host),i=Xn;continue;case gp: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(wK(s)?(n.shortenPath(),f!="/"&&!(f=="\\"&&n.isSpecial())&&Os(n.path,"")):_K(s)?f!="/"&&!(f=="\\"&&n.isSpecial())&&Os(n.path,""):(n.scheme=="file"&&!n.path.length&&Bo(s)&&(n.host&&(n.host=""),s=wn(s,0)+":"),Os(n.path,s)),s="",n.scheme=="file"&&(f==gn||f=="?"||f=="#"))for(;n.path.length>1&&n.path[0]==="";)iK(n.path);f=="?"?(n.query="",i=Ga):f=="#"&&(n.fragment="",i=_i)}else s+=aa(f,KR);break;case sS:f=="?"?(n.query="",i=Ga):f=="#"?(n.fragment="",i=_i):f!=gn&&(n.path[0]+=aa(f,Jc));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,Jc));break;case _i:f!=gn&&(n.fragment+=aa(f,HR));break}a++}},parseHost:function(e){var r,t,n;if(wn(e,0)=="["){if(wn(e,e.length-1)!="]"||(r=yK(Xo(e,1,-1)),!r))return qa;this.host=r}else if(this.isSpecial()){if(e=J7(e),Fn(dK,e)||(r=gK(e),r===null))return qa;this.host=r}else{if(Fn(pK,e))return qa;for(r="",t=Es(e),n=0;n<t.length;n++)r+=aa(t[n],Jc);this.host=r}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||this.scheme=="file"},includesCredentials:function(){return this.username!=""||this.password!=""},isSpecial:function(){return Ph(gc,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 Ah(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(Si(e)+":",lp)},getUsername:function(){return this.username},setUsername:function(e){var r=Es(Si(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var t=0;t<r.length;t++)this.username+=aa(r[t],cp)}},getPassword:function(){return this.password},setPassword:function(e){var r=Es(Si(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var t=0;t<r.length;t++)this.password+=aa(r[t],cp)}},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,pp)},getHostname:function(){var e=this.host;return e===null?"":No(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,hp)},getPort:function(){var e=this.port;return e===null?"":Si(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(e=Si(e),e==""?this.port=null:this.parse(e,vp))},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=Si(e),e==""?this.query=null:(wn(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=Si(e),e==""){this.fragment=null;return}wn(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=H7(this,jr),n=X7(arguments.length,1)>1?arguments[1]:void 0,i=Q7(t,new tg(r,!1,n));Qm||(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 bl(this)[e]()},set:r&&function(t){return bl(this)[r](t)},configurable:!0,enumerable:!0}};Qm&&(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")));yl(jr,"toJSON",function(){return bl(this).serialize()},{enumerable:!0});yl(jr,"toString",function(){return bl(this).serialize()},{enumerable:!0});if(Mo){var oS=Mo.createObjectURL,uS=Mo.revokeObjectURL;oS&&yl(Zs,"createObjectURL",Yw(oS,Mo)),uS&&yl(Zs,"revokeObjectURL",Yw(uS,Mo))}Y7(Zs,"URL");z7({global:!0,constructor:!0,forced:!W7,sham:!Qm},{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=Sa,i=li,a=fi,s=$n,c=lf,o=us,u=Su,l=ku,f=Rn,d=pr,p=zi,h=Tr;function E(ee){return ee&&typeof ee=="object"&&"default"in ee?ee:{default:ee}}function x(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),M=E(n),j=E(i),V=E(a),ie=E(s),oe=E(c),J=E(o),L=E(u),Y=E(l),Z=E(f),ye=x(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 We=new Uint8Array(16);Re.exports=function(){return ae(We),We}}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=[],Se=0;Se<256;++Se)Te[Se]=(Se+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,xe=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||xe)();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 ze=Pt,Kt=ur,gt=ze,Me=gt;Me.v1=Kt,Me.v4=gt;var ft=Me;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 V.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 M.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 Vt(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 M.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 M.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 M.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 V.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 M.default(Q)}(oe.default(Error)),zt=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 M.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 zt,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,wr=(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(zn){return zn.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(wr,"] ").concat(cr);Ze(new _r(ir,Je.status,it,wr,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 M.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,wr;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:wr=ot.sent,rt.succeeded(wr),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,wr;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:wr=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",wr),Ye(wr);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 M.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),Vt("design:type",Function),Vt("design:paramtypes",[String]),Vt("design:returntype",void 0)],e.default.prototype,"updateToken",null),vt([h.validateTypesAsync(h.nonEmptyString),Vt("design:type",Function),Vt("design:paramtypes",[String]),Vt("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"]),Vt("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})(kR);var JR=Ht,SK=Ir,TK=ui,CK=JR.aTypedArray,EK=JR.exportTypedArrayMethod;EK("at",function(r){var t=CK(this),n=SK(t),i=TK(r),a=i>=0?i:n+i;return a<0||a>=n?void 0:t[a]});var kK=wt,RK=Rt,$K=ZE,OK=Ll,rg="ArrayBuffer",cS=$K[rg],IK=RK[rg];kK({global:!0,constructor:!0,forced:IK!==cS},{ArrayBuffer:cS});OK(rg);var PK=wt,YR=_t,AK=En,xK=Mr,lS=Ir,MK=Am,fS=br,ng=mt,NK=jm,LK=ql,dS=Dk,DK=jk,pS=no,hS=Fk,ca=[],vS=YR(ca.sort),jK=YR(ca.push),FK=ng(function(){ca.sort(void 0)}),UK=ng(function(){ca.sort(null)}),BK=LK("sort"),XR=!ng(function(){if(pS)return pS<70;if(!(dS&&dS>3)){if(DK)return!0;if(hS)return hS<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"}}),qK=FK||!UK||!BK||!XR,GK=function(e){return function(r,t){return t===void 0?-1:r===void 0?1:e!==void 0?+e(r,t)||0:fS(r)>fS(t)?1:-1}};PK({target:"Array",proto:!0,forced:qK},{sort:function(r){r!==void 0&&AK(r);var t=xK(this);if(XR)return r===void 0?vS(t):vS(t,r);var n=[],i=lS(t),a,s;for(s=0;s<i;s++)s in t&&jK(n,t[s]);for(NK(n,GK(r)),a=lS(n),s=0;s<a;)t[s]=n[s++];for(;s<i;)MK(t,s++);return t}});var VK=wt,zK=_t,WK=RR,HK=oi,mS=br,KK=$R,JK=zK("".indexOf);VK({target:"String",proto:!0,forced:!KK("includes")},{includes:function(r){return!!~JK(mS(HK(this)),mS(WK(r)),arguments.length>1?arguments[1]:void 0)}});var pf={},QR={exports:{}};(function(e){(function(r,t){e.exports?e.exports=t():r.log=t()})(Ve,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,x){var I=E[x];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,x){for(var I=0;I<i.length;I++){var M=i[I];this[M]=I<E?r:this.methodFactory(M,E,x)}this.log=this.debug}function u(E,x,I){return function(){typeof console!==t&&(o.call(this,x,I),this[E].apply(this,arguments))}}function l(E,x,I){return c(E)||u.apply(this,arguments)}function f(E,x,I){var M=this,j;x=x??"WARN";var V="loglevel";typeof E=="string"?V+=":"+E:typeof E=="symbol"&&(V=void 0);function ie(Y){var Z=(i[Y]||"silent").toUpperCase();if(!(typeof window===t||!V)){try{window.localStorage[V]=Z;return}catch{}try{window.document.cookie=encodeURIComponent(V)+"="+Z+";"}catch{}}}function oe(){var Y;if(!(typeof window===t||!V)){try{Y=window.localStorage[V]}catch{}if(typeof Y===t)try{var Z=window.document.cookie,ye=Z.indexOf(encodeURIComponent(V)+"=");ye!==-1&&(Y=/^([^;]+)/.exec(Z.slice(ye))[1])}catch{}return M.levels[Y]===void 0&&(Y=void 0),Y}}function J(){if(!(typeof window===t||!V)){try{window.localStorage.removeItem(V);return}catch{}try{window.document.cookie=encodeURIComponent(V)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}M.name=E,M.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},M.methodFactory=I||l,M.getLevel=function(){return j},M.setLevel=function(Y,Z){if(typeof Y=="string"&&M.levels[Y.toUpperCase()]!==void 0&&(Y=M.levels[Y.toUpperCase()]),typeof Y=="number"&&Y>=0&&Y<=M.levels.SILENT){if(j=Y,Z!==!1&&ie(Y),o.call(M,Y,E),typeof console===t&&Y<M.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+Y},M.setDefaultLevel=function(Y){x=Y,oe()||M.setLevel(Y,!1)},M.resetLevel=function(){M.setLevel(x,!1),J()},M.enableAll=function(Y){M.setLevel(M.levels.TRACE,Y)},M.disableAll=function(Y){M.setLevel(M.levels.SILENT,Y)};var L=oe();L==null&&(L=x),M.setLevel(L,!1)}var d=new f,p={};d.getLogger=function(x){if(typeof x!="symbol"&&typeof x!="string"||x==="")throw new TypeError("You must supply a name when creating a logger.");var I=p[x];return I||(I=p[x]=new f(x,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})})(QR);var YK=QR.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(pf,"__esModule",{value:!0});var XK=YK;function QK(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var _c=QK(XK),ZK=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(){Mh("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 Mh("The getter ".concat(r," is deprecated").concat(t?", use "+t+" instead":"").concat(n?", "+n:".")),o==null?void 0:o.apply(this)}}},Mh=function(r){var t=_c.default.getLevel();_c.default.setLevel("warn"),_c.default.warn(r),_c.default.setLevel(t)};pf.deprecated=ZK;pf.deprecationWarning=Mh;var eJ=wt,tJ=fn.find,rJ=Zv,Nh="find",ZR=!0;Nh in[]&&Array(1)[Nh](function(){ZR=!1});eJ({target:"Array",proto:!0,forced:ZR},{find:function(r){return tJ(this,r,arguments.length>1?arguments[1]:void 0)}});rJ(Nh);var Lh={exports:{}},gS=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(gS){var yS=new Uint8Array(16);Lh.exports=function(){return gS(yS),yS}}else{var bS=new Array(16);Lh.exports=function(){for(var r=0,t;r<16;r++)r&3||(t=Math.random()*4294967296),bS[r]=t>>>((r&3)<<3)&255;return bS}}var e1=Lh.exports,t1=[];for(var wc=0;wc<256;++wc)t1[wc]=(wc+256).toString(16).substr(1);function nJ(e,r){var t=r||0,n=t1;return[n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]]].join("")}var r1=nJ,iJ=e1,aJ=r1,_S,yp,bp=0,_p=0;function sJ(e,r,t){var n=r&&t||0,i=r||[];e=e||{};var a=e.node||_S,s=e.clockseq!==void 0?e.clockseq:yp;if(a==null||s==null){var c=iJ();a==null&&(a=_S=[c[0]|1,c[1],c[2],c[3],c[4],c[5]]),s==null&&(s=yp=(c[6]<<8|c[7])&16383)}var o=e.msecs!==void 0?e.msecs:new Date().getTime(),u=e.nsecs!==void 0?e.nsecs:_p+1,l=o-bp+(u-_p)/1e4;if(l<0&&e.clockseq===void 0&&(s=s+1&16383),(l<0||o>bp)&&e.nsecs===void 0&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");bp=o,_p=u,yp=s,o+=122192928e5;var f=((o&268435455)*1e4+u)%4294967296;i[n++]=f>>>24&255,i[n++]=f>>>16&255,i[n++]=f>>>8&255,i[n++]=f&255;var d=o/4294967296*1e4&268435455;i[n++]=d>>>8&255,i[n++]=d&255,i[n++]=d>>>24&15|16,i[n++]=d>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var p=0;p<6;++p)i[n+p]=a[p];return r||aJ(i)}var oJ=sJ,uJ=e1,cJ=r1;function lJ(e,r,t){var n=r&&t||0;typeof e=="string"&&(r=e==="binary"?new Array(16):null,e=null),e=e||{};var i=e.random||(e.rng||uJ)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,r)for(var a=0;a<16;++a)r[n+a]=i[a];return r||cJ(i)}var fJ=lJ,dJ=oJ,n1=fJ,ig=n1;ig.v1=dJ;ig.v4=n1;var pJ=ig,hJ=wt,vJ=yE,mJ=mt,gJ=tr,yJ=vm.onFreeze,Dh=Object.freeze,bJ=mJ(function(){Dh(1)});hJ({target:"Object",stat:!0,forced:bJ,sham:!vJ},{freeze:function(r){return Dh&&gJ(r)?Dh(yJ(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=Su,n=os,i=li,a=fi,s=$n,c=us,o=Sa,u=di,l=ku,f=Rn,d=pr,p=TF,h=Tr,E=po,x=lm,I=U4,M=fo,j=zi,V=ef,ie=Xk,oe=tn,J=kR,L=pf,Y=lf,Z=pJ;function ye(S){return S&&typeof S=="object"&&"default"in S?S:{default:S}}function Re(S){if(S&&S.__esModule)return S;var k=Object.create(null);return S&&Object.keys(S).forEach(function(w){if(w!=="default"){var m=Object.getOwnPropertyDescriptor(S,w);Object.defineProperty(k,w,m.get?m:{enumerable:!0,get:function(){return S[w]}})}}),k.default=S,Object.freeze(k)}var ae=ye(t),We=ye(n),be=ye(i),Te=ye(a),Se=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(M),ur=ye(Y);function xe(S,k,w,m){var v=arguments.length,_=v<3?k:m===null?m=Object.getOwnPropertyDescriptor(k,w):m,g;if((typeof Reflect>"u"?"undefined":Qe.default(Reflect))==="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(S,k,w,m);else for(var y=S.length-1;y>=0;y--)(g=S[y])&&(_=(v<3?g(_):v>3?g(k,w,_):g(k,w))||_);return v>3&&_&&Object.defineProperty(k,w,_),_}function fe(S,k){if((typeof Reflect>"u"?"undefined":Qe.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(S,k)}function Pt(S,k){return["".concat(new Date().toISOString()," Conversations ").concat(S,":")].concat(Array.from(k))}var ze=Et.getLogger("twilio-conversations"),Kt=function(){function S(k){De.default(this,S),ge.default(this,"prefix",""),this.prefix=k!=null&&k.length>0?k+" ":""}return $e.default(S,[{key:"setLevel",value:function(w){ze.setLevel(w)}},{key:"trace",value:function(){for(var w=arguments.length,m=new Array(w),v=0;v<w;v++)m[v]=arguments[v];ze.trace.apply(null,Pt(this.prefix+"T",m))}},{key:"debug",value:function(){for(var w=arguments.length,m=new Array(w),v=0;v<w;v++)m[v]=arguments[v];ze.debug.apply(null,Pt(this.prefix+"D",m))}},{key:"info",value:function(){for(var w=arguments.length,m=new Array(w),v=0;v<w;v++)m[v]=arguments[v];ze.info.apply(null,Pt(this.prefix+"I",m))}},{key:"warn",value:function(){for(var w=arguments.length,m=new Array(w),v=0;v<w;v++)m[v]=arguments[v];ze.warn.apply(null,Pt(this.prefix+"W",m))}},{key:"error",value:function(){for(var w=arguments.length,m=new Array(w),v=0;v<w;v++)m[v]=arguments[v];ze.error.apply(null,Pt(this.prefix+"E",m))}}],[{key:"scope",value:function(w){return new S(w)}},{key:"setLevel",value:function(w){ze.setLevel(w)}},{key:"trace",value:function(){for(var w=arguments.length,m=new Array(w),v=0;v<w;v++)m[v]=arguments[v];ze.trace.apply(null,Pt("T",m))}},{key:"debug",value:function(){for(var w=arguments.length,m=new Array(w),v=0;v<w;v++)m[v]=arguments[v];ze.debug.apply(null,Pt("D",m))}},{key:"info",value:function(){for(var w=arguments.length,m=new Array(w),v=0;v<w;v++)m[v]=arguments[v];ze.info.apply(null,Pt("I",m))}},{key:"warn",value:function(){for(var w=arguments.length,m=new Array(w),v=0;v<w;v++)m[v]=arguments[v];ze.warn.apply(null,Pt("W",m))}},{key:"error",value:function(){for(var w=arguments.length,m=new Array(w),v=0;v<w;v++)m[v]=arguments[v];ze.error.apply(null,Pt("E",m))}}]),S}();function gt(S,k){var w=Object.keys(S);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(S);k&&(m=m.filter(function(v){return Object.getOwnPropertyDescriptor(S,v).enumerable})),w.push.apply(w,m)}return w}function Me(S){for(var k=1;k<arguments.length;k++){var w=arguments[k]!=null?arguments[k]:{};k%2?gt(Object(w),!0).forEach(function(m){ge.default(S,m,w[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(S,Object.getOwnPropertyDescriptors(w)):gt(Object(w)).forEach(function(m){Object.defineProperty(S,m,Object.getOwnPropertyDescriptor(w,m))})}return S}var ft=5,Tt="PT5S",Le="PT5S",Jt=100,vt=1e3,Vt=4e3,nr=3,He=!0,Pr=$e.default(function S(){var k,w,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,S),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=Me({min:vt,max:Vt,maxAttemptsCount:nr},H.backoffConfigOverride),this.retryWhenThrottled=H.retryWhenThrottledOverride!==void 0?H.retryWhenThrottledOverride:He,this.userInfosToSubscribe=(k=(w=H.userInfosToSubscribeOverride)!==null&&w!==void 0?w: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(S){return JSON.parse(JSON.stringify(S))}function Ct(S){return typeof S<"u"&&!isNaN(Number(S))?Number(S):null}function kt(S){try{return new Date(S)}catch{return null}}function yt(S,k,w){var m={};if(S)try{m=JSON.parse(S)}catch(v){w.warn(k,v)}return m}var st=function(){function S(k){De.default(this,S),this.base=k.replace(/\/$/,""),this.args=[],this.paths=[]}return $e.default(S,[{key:"arg",value:function(w,m){return typeof m<"u"&&this.args.push(encodeURIComponent(w)+"="+encodeURIComponent(m)),this}},{key:"path",value:function(w){return this.paths.push(encodeURIComponent(w)),this}},{key:"build",value:function(){var w=this.base;return this.paths.length&&(w+="/"+this.paths.join("/")),this.args.length&&(w+="?"+this.args.join("&")),w}}]),S}(),Lt=h.custom(function(S){return[["string","number","boolean","object"].includes(Qe.default(S)),"a JSON type"]}),Xt=h.custom(function(S){return[["undefined","string","number","boolean","object"].includes(Qe.default(S)),"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(S){var k=Pn();return function(){var m=Se.default(S),v;if(k){var _=Se.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"),zt=function(S){be.default(w,S);var k=hn(w);function w(m,v,_,g){var y;return De.default(this,w),y=k.call(this),ge.default(We.default(y),"promiseToFetch",null),ge.default(We.default(y),"updated","updated"),ge.default(We.default(y),"userSubscribed","userSubscribed"),ge.default(We.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(w,[{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"]})}}]),w}(x.ReplayEventEmitter);xe([h.validateTypesAsync(Lt),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",Promise)],zt.prototype,"updateAttributes",null),xe([h.validateTypesAsync(["string"]),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],zt.prototype,"updateFriendlyName",null);function Nr(S,k){var w=typeof Symbol<"u"&&S[Symbol.iterator]||S["@@iterator"];if(!w){if(Array.isArray(S)||(w=_e(S))||k&&S&&typeof S.length=="number"){w&&(S=w);var m=0,v=function(){};return{s:v,n:function(){return m>=S.length?{done:!0}:{done:!1,value:S[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(){w=w.call(S)},n:function(){var T=w.next();return _=T.done,T},e:function(T){g=!0,y=T},f:function(){try{!_&&w.return!=null&&w.return()}finally{if(g)throw y}}}}function _e(S,k){if(S){if(typeof S=="string")return Ce(S,k);var w=Object.prototype.toString.call(S).slice(8,-1);if(w==="Object"&&S.constructor&&(w=S.constructor.name),w==="Map"||w==="Set")return Array.from(S);if(w==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))return Ce(S,k)}}function Ce(S,k){(k==null||k>S.length)&&(k=S.length);for(var w=0,m=new Array(k);w<k;w++)m[w]=S[w];return m}var ce=function(){function S(k,w){De.default(this,S),this.configuration=k,this.services=w,this.cache=new Map,this.cacheLifetime=this.configuration.httpCacheInterval*100,this.cleanupCache()}return $e.default(S,[{key:"isExpired",value:function(w){return!this.cacheLifetime||Date.now()-w>this.cacheLifetime}},{key:"cleanupCache",value:function(){var w=Nr(this.cache),m;try{for(w.s();!(m=w.n()).done;){var v=te.default(m.value,2),_=v[0],g=v[1];this.isExpired(g.timestamp)&&this.cache.delete(_)}}catch(y){w.e(y)}finally{w.f()}this.cache.size===0&&clearInterval(this.timer)}},{key:"pokeTimer",value:function(){var w=this;this.timer=this.timer||setInterval(function(){return w.cleanupCache()},this.cacheLifetime*2)}},{key:"executeWithRetry",value:function(w){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(){w().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 w(m){return k.apply(this,arguments)}return w}()}]),S}(),de=$e.default(function S(){De.default(this,S)});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(S){var k=ke();return function(){var m=Se.default(S),v;if(k){var _=Se.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(S){be.default(w,S);var k=le(w);function w(m,v,_,g,y){var b,T,$;if(De.default(this,w),$=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(w,[{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}()}]),w}(x.ReplayEventEmitter);ge.default(ee,"typingStarted","typingStarted"),ge.default(ee,"typingEnded","typingEnded"),ge.default(ee,"updated","updated"),xe([h.validateTypesAsync(Lt),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",Promise)],ee.prototype,"updateAttributes",null);function ve(S){var k=Q();return function(){var m=Se.default(S),v;if(k){var _=Se.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(S){be.default(w,S);var k=ve(w);function w(m,v,_,g,y){var b;return De.default(this,w),b=k.call(this),ge.default(We.default(b),"rosterEntityPromise",null),b.conversation=m,b.participants=v,b.links=_,b.configuration=g,b.services=y,b}return $e.default(w,[{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)))}}]),w}(x.ReplayEventEmitter),Ue=function(){function S(k,w){De.default(this,S),ge.default(this,"mcsMedia",null),this.services=w,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(S,[{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 w=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=w._fetchMcsMedia(),$=(b=w.mcsMedia)===null||b===void 0?void 0:b.getContentUrl(),y(function(){T.cancel(),$&&$.cancel()}),re.prev=3,w.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 w=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=w.services.mcsClient.get(w.state.sid),!w.services.mcsClient){$.next=14;break}return y(function(){return b.cancel()}),$.prev=3,$.next=6,b;case 6:w.mcsMedia=$.sent,_(w.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)}}())}}]),S}(),Oe=function(){function S(k){De.default(this,S),this.state=k}return $e.default(S,[{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(w){this.state=w}},{key:"_isEquals",value:function(w){var m=this.total===w.total,v=this.sent===w.sent,_=this.delivered===w.delivered,g=this.read===w.read,y=this.undelivered===w.undelivered,b=this.failed===w.failed;return m&&v&&_&&g&&y&&b}}]),S}(),Ze=function(){function S(k,w,m,v){De.default(this,S),this.state={prevToken:m,nextToken:v,source:w,items:k}}return $e.default(S,[{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"))}}]),S}(),Ke=$e.default(function S(k){De.default(this,S),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(w){var m,v,_,g,y=JSON.stringify(w);switch(w.type){case"QUICK_REPLY":return{type:"reply",title:w.title,id:(m=w.id)!==null&&m!==void 0?m:"",index:(v=w.index)!==null&&v!==void 0?v:0,rawData:y};case"PHONE_NUMBER":return{type:"phone",title:w.title,phone:(_=w.phone)!==null&&_!==void 0?_:"",rawData:y};case"URL":return{type:"url",title:w.title,url:(g=w.url)!==null&&g!==void 0?g:"",rawData:y};default:return{type:"other",rawData:y}}})},rt=function(k,w){var m=JSON.stringify(w);switch(k){case"twilio/text":{var v=w;return{type:"text",body:v.body,rawData:m}}case"twilio/media":{var _=w;return{type:"media",body:_.body,media:_.media,rawData:m}}case"twilio/location":{var g=w;return{type:"location",longitude:g.longitude,latitude:g.latitude,label:g.label,rawData:m}}case"twilio/quick-reply":{var y=w;return{type:"quickReply",body:y.body,replies:y.actions,rawData:m}}case"twilio/call-to-action":{var b=w;return{type:"callToAction",body:b.body,actions:Je(b.actions),rawData:m}}case"twilio/list-picker":{var T=w;return{type:"listPicker",body:T.body,button:T.button,items:T.items,rawData:m}}case"twilio/card":{var $,H,K=w;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 w=new Map,m=0,v=Object.entries(k);m<v.length;m++){var _=te.default(v[m],2),g=_[0],y=_[1];w.set(g,rt(g,y))}return w},Ye=function(){function S(k,w){De.default(this,S),this.name=k,this.value=w}return $e.default(S,[{key:"copyWithValue",value:function(w){return new S(this.name,w)}}]),S}(),tt=$e.default(function S(k){De.default(this,S),this.sid=k.sid,this.friendlyName=k.friendly_name,this.variables=Object.entries(JSON.parse(k.variables)).map(function(w){var m=te.default(w,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(S,k){var w=Object.keys(S);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(S);k&&(m=m.filter(function(v){return Object.getOwnPropertyDescriptor(S,v).enumerable})),w.push.apply(w,m)}return w}function ct(S){for(var k=1;k<arguments.length;k++){var w=arguments[k]!=null?arguments[k]:{};k%2?it(Object(w),!0).forEach(function(m){ge.default(S,m,w[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(S,Object.getOwnPropertyDescriptors(w)):it(Object(w)).forEach(function(m){Object.defineProperty(S,m,Object.getOwnPropertyDescriptor(w,m))})}return S}function wr(S){var k=cr();return function(){var m=Se.default(S),v;if(k){var _=Se.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(S){be.default(w,S);var k=wr(w);function w(m,v,_,g,y,b){var T,$,H,K,re,ue;return De.default(this,w),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(w,[{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(W){for(;;)switch(W.prev=W.next){case 0:if(v.state.contentSid!==null){W.next=3;break}return y(null),W.abrupt("return");case 3:if($=v.getMediaByCategories(["body"]),$!==null){W.next=7;break}return y(null),W.abrupt("return");case 7:if(H="application/x-vnd.com.twilio.rich.",K=$.filter(function(he){return he.contentType.startsWith(H)}),K.length!==0){W.next=12;break}return y(null),W.abrupt("return");case 12:return re=K[0],ue=re.getContentTemporaryUrl(),T(function(){ue.cancel()}),W.prev=15,W.next=18,ue;case 18:Xe=W.sent,W.next=25;break;case 21:return W.prev=21,W.t0=W.catch(15),b(W.t0),W.abrupt("return");case 25:if(Xe!==null){W.next=28;break}return y(null),W.abrupt("return");case 28:return lt=new Promise(function(he,we){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(){we(et.statusText)},T(function(){Fe=!0,et.abort(),we(new Error("XHR has been aborted"))}),et.send()}),W.prev=29,W.next=32,lt;case 32:A=W.sent,C=JSON.parse(A),W.next=40;break;case 36:return W.prev=36,W.t1=W.catch(29),b(W.t1),W.abrupt("return");case 40:D=re.contentType.replace(H,"").replace(".","/"),y(rt(D,C.data));case 42:case"end":return W.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}()}]),w}(x.ReplayEventEmitter);ge.default(ir,"updated","updated"),xe([L.deprecated("getMediaByCategory","getMediaByCategories"),fe("design:type",Function),fe("design:paramtypes",[Array]),fe("design:returntype",Array)],ir.prototype,"getMediaByCategory",null),xe([h.validateTypes([h.nonEmptyString,"undefined"]),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",Ue)],ir.prototype,"getEmailBody",null),xe([h.validateTypes([h.nonEmptyString,"undefined"]),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",Ue)],ir.prototype,"getEmailHistory",null),xe([h.validateTypesAsync("string"),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],ir.prototype,"updateBody",null),xe([h.validateTypesAsync(Lt),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",Promise)],ir.prototype,"updateAttributes",null),xe([L.deprecated("attachTemporaryUrlsFor","getTemporaryContentUrlsForMedia"),fe("design:type",Function),fe("design:paramtypes",[Array]),fe("design:returntype",Promise)],ir.prototype,"attachTemporaryUrlsFor",null),xe([h.validateTypesAsync(h.nonEmptyArray("media",Ue)),fe("design:type",Function),fe("design:paramtypes",[Array]),fe("design:returntype",J.CancellablePromise)],ir.prototype,"getTemporaryContentUrlsForMedia",null),xe([h.validateTypesAsync(h.nonEmptyArray("strings","string")),fe("design:type",Function),fe("design:paramtypes",[Array]),fe("design:returntype",J.CancellablePromise)],ir.prototype,"getTemporaryContentUrlsForMediaSids",null);function zn(S,k){var w=Object.keys(S);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(S);k&&(m=m.filter(function(v){return Object.getOwnPropertyDescriptor(S,v).enumerable})),w.push.apply(w,m)}return w}function hi(S){for(var k=1;k<arguments.length;k++){var w=arguments[k]!=null?arguments[k]:{};k%2?zn(Object(w),!0).forEach(function(m){ge.default(S,m,w[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(S,Object.getOwnPropertyDescriptors(w)):zn(Object(w)).forEach(function(m){Object.defineProperty(S,m,Object.getOwnPropertyDescriptor(w,m))})}return S}function $a(S,k){var w=typeof Symbol<"u"&&S[Symbol.iterator]||S["@@iterator"];if(!w){if(Array.isArray(S)||(w=Kr(S))||k&&S&&typeof S.length=="number"){w&&(S=w);var m=0,v=function(){};return{s:v,n:function(){return m>=S.length?{done:!0}:{done:!1,value:S[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(){w=w.call(S)},n:function(){var T=w.next();return _=T.done,T},e:function(T){g=!0,y=T},f:function(){try{!_&&w.return!=null&&w.return()}finally{if(g)throw y}}}}function Kr(S,k){if(S){if(typeof S=="string")return Yi(S,k);var w=Object.prototype.toString.call(S).slice(8,-1);if(w==="Object"&&S.constructor&&(w=S.constructor.name),w==="Map"||w==="Set")return Array.from(S);if(w==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))return Yi(S,k)}}function Yi(S,k){(k==null||k>S.length)&&(k=S.length);for(var w=0,m=new Array(k);w<k;w++)m[w]=S[w];return m}function Oa(S){var k=Wn();return function(){var m=Se.default(S),v;if(k){var _=Se.default(this).constructor;v=Reflect.construct(m,arguments,_)}else v=m.apply(this,arguments);return Te.default(this,v)}}function Wn(){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(S){be.default(w,S);var k=Oa(w);function w(m,v,_){var g;return De.default(this,w),g=k.call(this),g.conversation=m,g.configuration=v,g.services=_,g.messagesByIndex=new Map,g.messagesListPromise=null,g}return $e.default(w,[{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,z,W,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),W=A instanceof FormData?_.services.mcsClient.postFormData(A,C):_.services.mcsClient.post((D=A.contentType)!==null&&D!==void 0?D:"",(z=A.media)!==null&&z!==void 0?z:"",C,A.filename),re.push(W),Ee.t0=K,Ee.next=15,W;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}()}]),w}(x.ReplayEventEmitter),rn=function(){function S(k){De.default(this,S),ge.default(this,"attributes",{}),ge.default(this,"mediaContent",[]),ge.default(this,"emailOptions",{}),this.messagesEntity=k}return $e.default(S,[{key:"send",value:function(){var w=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=w.messagesEntity.sendV2(w),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)}}())}}]),S}(),ar=function(){function S(k,w){De.default(this,S),this.limits=k,this.message=new rn(w),this.emailBodies=new Map,this.emailHistories=new Map}return $e.default(S,[{key:"setBody",value:function(w){return this.message.text=w,this}},{key:"setSubject",value:function(w){return this.message.emailOptions.subject=w,this}},{key:"setAttributes",value:function(w){return this.message.attributes=w,this}},{key:"setEmailBody",value:function(w,m){return this.emailBodies.set(w,m),this}},{key:"setEmailHistory",value:function(w,m){return this.emailHistories.set(w,m),this}},{key:"setContentTemplate",value:function(w){var m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return this.message.contentSid=w,this.message.contentVariables=m,this}},{key:"addMedia",value:function(w){if(typeof FormData>"u"&&w instanceof FormData)throw new Error("Could not add FormData content whilst not in a browser");if(!(w instanceof FormData)){var m=w;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",w]),this}},{key:"build",value:function(){var w=this;if(this.emailBodies.forEach(function(m,v){if(!w.limits.emailBodiesAllowedContentTypes.includes(v))throw new Error("Unsupported email body content type ".concat(v))}),this.emailHistories.forEach(function(m,v){if(!w.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){w.message.mediaContent.push(["body",m])}),this.emailHistories.forEach(function(m){w.message.mediaContent.push(["history",m])}),this.message}},{key:"buildAndSend",value:function(){return this.build().send()}}]),S}();xe([h.validateTypes("string"),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",ar)],ar.prototype,"setBody",null),xe([h.validateTypes("string"),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",ar)],ar.prototype,"setSubject",null),xe([h.validateTypes(Lt),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",ar)],ar.prototype,"setAttributes",null),xe([h.validateTypes("string",[FormData,hr]),fe("design:type",Function),fe("design:paramtypes",[String,Object]),fe("design:returntype",ar)],ar.prototype,"setEmailBody",null),xe([h.validateTypes("string",[FormData,hr]),fe("design:type",Function),fe("design:paramtypes",[String,Object]),fe("design:returntype",ar)],ar.prototype,"setEmailHistory",null),xe([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),xe([h.validateTypes([FormData,hr]),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",ar)],ar.prototype,"addMedia",null);function vi(S,k){var w=typeof Symbol<"u"&&S[Symbol.iterator]||S["@@iterator"];if(!w){if(Array.isArray(S)||(w=Jr(S))||k&&S&&typeof S.length=="number"){w&&(S=w);var m=0,v=function(){};return{s:v,n:function(){return m>=S.length?{done:!0}:{done:!1,value:S[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(){w=w.call(S)},n:function(){var T=w.next();return _=T.done,T},e:function(T){g=!0,y=T},f:function(){try{!_&&w.return!=null&&w.return()}finally{if(g)throw y}}}}function Jr(S,k){if(S){if(typeof S=="string")return Xi(S,k);var w=Object.prototype.toString.call(S).slice(8,-1);if(w==="Object"&&S.constructor&&(w=S.constructor.name),w==="Map"||w==="Set")return Array.from(S);if(w==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))return Xi(S,k)}}function Xi(S,k){(k==null||k>S.length)&&(k=S.length);for(var w=0,m=new Array(k);w<k;w++)m[w]=S[w];return m}function Pa(S){var k=Aa();return function(){var m=Se.default(S),v;if(k){var _=Se.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(S){be.default(w,S);var k=Pa(w);function w(m,v,_,g,y){var b,T,$;De.default(this,w),$=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(We.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(We.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(w,[{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"&&w._logger.error("Failed to get conversation object",b.t0),w._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 w._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 w._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"&&w._logger.error("Failed to subscribe on conversation objects",this.sid,ue.t0),w._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(w._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(w._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;w._logger.trace("_update",v),w.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{w._logger.warn("Retrieved malformed attributes from the server for conversation: "+_),v.attributes={}}try{v.dateCreated&&(v.dateCreated=new Date(v.dateCreated))}catch{w._logger.warn("Retrieved malformed dateCreated from the server for conversation: "+_),delete v.dateCreated}try{v.dateUpdated&&(v.dateUpdated=new Date(v.dateUpdated))}catch{w._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{w._logger.warn("Retrieved malformed lastMessage.timestamp from the server for conversation: "+_),delete v.lastMessage.timestamp}}}]),w}(x.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")),xe([h.validateTypesAsync(h.nonEmptyString,Xt),fe("design:type",Function),fe("design:paramtypes",[String,Object]),fe("design:returntype",Promise)],At.prototype,"add",null),xe([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),xe([h.validateTypesAsync(h.nonNegativeInteger),fe("design:type",Function),fe("design:paramtypes",[Number]),fe("design:returntype",Promise)],At.prototype,"advanceLastReadMessageIndex",null),xe([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),xe([h.validateTypesAsync(h.nonEmptyString),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],At.prototype,"getParticipantBySid",null),xe([h.validateTypesAsync(h.nonEmptyString),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],At.prototype,"getParticipantByIdentity",null),xe([h.validateTypesAsync([h.nonEmptyString,ee]),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",Promise)],At.prototype,"removeParticipant",null),xe([h.validateTypesAsync(["string",FormData,h.literal(null),h.objectSchema("media options",{contentType:h.nonEmptyString,media:h.custom(function(S){var k=typeof S=="string"&&S.length>0||S instanceof Uint8Array||S instanceof ArrayBuffer;return typeof Blob=="function"&&(k=k||S 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),xe([h.validateTypesAsync(h.literal("default","muted")),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],At.prototype,"setUserNotificationLevel",null),xe([h.validateTypesAsync(Lt),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",Promise)],At.prototype,"updateAttributes",null),xe([h.validateTypesAsync("string"),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],At.prototype,"updateFriendlyName",null),xe([h.validateTypesAsync([h.literal(null),h.nonNegativeInteger]),fe("design:type",Function),fe("design:paramtypes",[Number]),fe("design:returntype",Promise)],At.prototype,"updateLastReadMessageIndex",null),xe([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 S(){var k=this;De.default(this,S),this._promise=new Promise(function(w,m){k._resolve=w,k._reject=m})}return $e.default(S,[{key:"promise",get:function(){return this._promise}},{key:"update",value:function(w){this._resolve(w)}},{key:"set",value:function(w){this.current=w,this._resolve(w)}},{key:"fail",value:function(w){this._reject(w)}}]),S}();function Hn(S,k){var w=typeof Symbol<"u"&&S[Symbol.iterator]||S["@@iterator"];if(!w){if(Array.isArray(S)||(w=xa(S))||k&&S&&typeof S.length=="number"){w&&(S=w);var m=0,v=function(){};return{s:v,n:function(){return m>=S.length?{done:!0}:{done:!1,value:S[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(){w=w.call(S)},n:function(){var T=w.next();return _=T.done,T},e:function(T){g=!0,y=T},f:function(){try{!_&&w.return!=null&&w.return()}finally{if(g)throw y}}}}function xa(S,k){if(S){if(typeof S=="string")return Yr(S,k);var w=Object.prototype.toString.call(S).slice(8,-1);if(w==="Object"&&S.constructor&&(w=S.constructor.name),w==="Map"||w==="Set")return Array.from(S);if(w==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))return Yr(S,k)}}function Yr(S,k){(k==null||k>S.length)&&(k=S.length);for(var w=0,m=new Array(k);w<k;w++)m[w]=S[w];return m}function gi(S,k){var w=Object.keys(S);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(S);k&&(m=m.filter(function(v){return Object.getOwnPropertyDescriptor(S,v).enumerable})),w.push.apply(w,m)}return w}function yi(S){for(var k=1;k<arguments.length;k++){var w=arguments[k]!=null?arguments[k]:{};k%2?gi(Object(w),!0).forEach(function(m){ge.default(S,m,w[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(S,Object.getOwnPropertyDescriptors(w)):gi(Object(w)).forEach(function(m){Object.defineProperty(S,m,Object.getOwnPropertyDescriptor(w,m))})}return S}function Ma(S){var k=Na();return function(){var m=Se.default(S),v;if(k){var _=Se.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(S){be.default(w,S);var k=Ma(w);function w(m,v){var _;return De.default(this,w),_=k.call(this),ge.default(We.default(_),"conversations",new Map),ge.default(We.default(_),"myConversationsRead",new mi),ge.default(We.default(_),"tombstones",new Set),ge.default(We.default(_),"myConversationsFetched",!1),_.configuration=m,_.services=v,_}return $e.default(w,[{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)})}}]),w}(x.ReplayEventEmitter);function Zi(S){var k=bi();return function(){var m=Se.default(S),v;if(k){var _=Se.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(S){be.default(w,S);var k=Zi(w);function w(m,v,_){var g;return De.default(this,w),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(w,[{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 zt(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}()}]),w}(x.ReplayEventEmitter),vn=Kt.scope("TypingIndicator"),An=function(){function S(k,w,m){De.default(this,S),this.configuration=w,this.services=m,this.getConversation=k,this.serviceTypingTimeout=null,this.sentUpdates=new Map}return $e.default(S,[{key:"typingTimeout",get:function(){return this.configuration.typingIndicatorTimeoutOverride||this.serviceTypingTimeout||this.configuration.typingIndicatorTimeoutDefault}},{key:"initialize",value:function(){var w=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,w._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 w(m){return k.apply(this,arguments)}return w}()},{key:"send",value:function(w){var m=this.sentUpdates.get(w);return m&&m>Date.now()-this.typingTimeout?Promise.resolve():(this.sentUpdates.set(w,Date.now()),this._send(w))}},{key:"_send",value:function(w){var m=this;vn.trace("Sending typing indicator");var v=this.configuration.links.typing,_={"Content-Type":"application/x-www-form-urlencoded"},g="ChannelSid=".concat(w);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})}}]),S}(),Zt=$e.default(function S(k){De.default(this,S),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(S,k){var w=Object.keys(S);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(S);k&&(m=m.filter(function(v){return Object.getOwnPropertyDescriptor(S,v).enumerable})),w.push.apply(w,m)}return w}function kr(S){for(var k=1;k<arguments.length;k++){var w=arguments[k]!=null?arguments[k]:{};k%2?Jn(Object(w),!0).forEach(function(m){ge.default(S,m,w[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(S,Object.getOwnPropertyDescriptors(w)):Jn(Object(w)).forEach(function(m){Object.defineProperty(S,m,Object.getOwnPropertyDescriptor(w,m))})}return S}function nn(S){var k=ta();return function(){var m=Se.default(S),v;if(k){var _=Se.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(S){be.default(w,S);var k=nn(w);function w(m){return De.default(this,w),k.call(this,m)}return $e.default(w)}(ur.default(Error)),O=function(){function S(k,w,m){De.default(this,S),this._serviceUrl=k,this._services=w,this._productId=m}return $e.default(S,[{key:"_preProcessUrl",value:function(w){var m=F(w);return/^https?:\/\//.test(w)?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 w(m,v,_,g){return k.apply(this,arguments)}return w}()},{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 w(m,v){return k.apply(this,arguments)}return w}()},{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 w(m,v,_){return k.apply(this,arguments)}return w}()}]),S}(),R=function(){function S(k){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:100,m=arguments.length>2&&arguments[2]!==void 0?arguments[2]:5e3;De.default(this,S),ge.default(this,"_cachedTemplates",null),this._services=k,this._pageSize=w,this._cacheTtlMs=m}return $e.default(S,[{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 w(){return k.apply(this,arguments)}return w}()},{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 w(m){return k.apply(this,arguments)}return w}()}]),S}();function U(S,k){var w=typeof Symbol<"u"&&S[Symbol.iterator]||S["@@iterator"];if(!w){if(Array.isArray(S)||(w=N(S))||k&&S&&typeof S.length=="number"){w&&(S=w);var m=0,v=function(){};return{s:v,n:function(){return m>=S.length?{done:!0}:{done:!1,value:S[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(){w=w.call(S)},n:function(){var T=w.next();return _=T.done,T},e:function(T){g=!0,y=T},f:function(){try{!_&&w.return!=null&&w.return()}finally{if(g)throw y}}}}function N(S,k){if(S){if(typeof S=="string")return me(S,k);var w=Object.prototype.toString.call(S).slice(8,-1);if(w==="Object"&&S.constructor&&(w=S.constructor.name),w==="Map"||w==="Set")return Array.from(S);if(w==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))return me(S,k)}}function me(S,k){(k==null||k>S.length)&&(k=S.length);for(var w=0,m=new Array(k);w<k;w++)m[w]=S[w];return m}var pe=function(S){function k(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(De.default(this,k),!(w.maxSize&&w.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=w.maxSize,this.onEviction=w.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 w(){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()}},w,this,[[1,11,14,17]])})},{key:"values",value:G.default.mark(function w(){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()}},w,this,[[1,11,14,17]])})},{key:S,value:G.default.mark(function w(){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()}},w,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 S(k,w){De.default(this,S),this.type=k,this.data=w,Object.freeze(w)}),at=function(){function S(k,w){De.default(this,S),this._services=k,this._configuration=w,this._cache=new Ae({maxSize:w.channelMetadataCacheCapacity})}return $e.default(S,[{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 w(m,v){return k.apply(this,arguments)}return w}()}]),S}(),dt;function Lr(S,k){var w=Object.keys(S);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(S);k&&(m=m.filter(function(v){return Object.getOwnPropertyDescriptor(S,v).enumerable})),w.push.apply(w,m)}return w}function lr(S){for(var k=1;k<arguments.length;k++){var w=arguments[k]!=null?arguments[k]:{};k%2?Lr(Object(w),!0).forEach(function(m){ge.default(S,m,w[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(S,Object.getOwnPropertyDescriptors(w)):Lr(Object(w)).forEach(function(m){Object.defineProperty(S,m,Object.getOwnPropertyDescriptor(w,m))})}return S}function an(S){var k=_o();return function(){var m=Se.default(S),v;if(k){var _=Se.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 S(){De.default(this,S)});e.Client=Qt=(dt=function(S){be.default(w,S);var k=an(w);function w(m){var v,_,g,y,b,T,$=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(De.default(this,w),T=k.call(this),ge.default(We.default(T),"version",Kn),ge.default(We.default(T),"connectionState","unknown"),ge.default(We.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 zt("","",null,T._services);var re=!T._options.twilsockClient;if(!T._options.initRegistrations){var ue=new V.InitRegistration(K);Qt.populateInitRegistrations(ue),T._options.initRegistrations=[ue]}T._services.twilsockClient=T._options.twilsockClient=(_=T._options.twilsockClient)!==null&&_!==void 0?_:new V.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(z){return T.emit("connectionError",z)}),T._services.twilsockClient.on("stateChanged",function(z){Qt._logger.debug("Handling stateChanged for ConversationsClient: new state ".concat(z)),z!==T.connectionState&&(T.connectionState=z,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(W){T._rejectEnsureReady(W),T.emit("stateChanged","failed"),T.emit("initFailed",{error:W})},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 z(){var W,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,W="conversations.client.startup",T._services.twilsockClient.addPartialTelemetryEvent(new V.TelemetryEventDescription(W,"Conversations client startup",new Date),W,V.TelemetryPoint.Start),Ee.next=8,T._initialize();case 8:T._services.twilsockClient.addPartialTelemetryEvent(new V.TelemetryEventDescription("","",new Date),W,V.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()}},z,null,[[3,11]])}))),T._ensureReady=new Promise(function(z,W){T._resolveEnsureReady=z,T._rejectEnsureReady=W}).catch(function(){}),re&&T._services.twilsockClient.connect(),T}return $e.default(w,[{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)}}]),w}(x.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),xe([L.deprecated("token"),fe("design:type",String),fe("design:paramtypes",[])],e.Client.prototype,"token",null),xe([h.validateTypesAsync(h.nonEmptyString),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],e.Client.prototype,"updateToken",null),xe([h.validateTypesAsync(h.nonEmptyString),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],e.Client.prototype,"getConversationBySid",null),xe([h.validateTypesAsync(h.nonEmptyString),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],e.Client.prototype,"peekConversationBySid",null),xe([h.validateTypesAsync(h.nonEmptyString),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],e.Client.prototype,"getConversationByUniqueName",null),xe([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),xe([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),xe([h.validateTypesAsync(h.literal("fcm","apn")),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],e.Client.prototype,"unsetPushRegistrationId",null),xe([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),xe([h.validateTypesAsync(h.pureObject),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",Promise)],e.Client.prototype,"handlePushNotification",null),xe([h.validateTypesAsync(h.nonEmptyString),fe("design:type",Function),fe("design:paramtypes",[String]),fe("design:returntype",Promise)],e.Client.prototype,"getUser",null),xe([h.validateTypesAsync(h.nonEmptyArray("strings","string")),fe("design:type",Function),fe("design:paramtypes",[Array]),fe("design:returntype",J.CancellablePromise)],e.Client.prototype,"getTemporaryContentUrlsForMediaSids",null),xe([h.validateTypesAsync(h.nonEmptyArray("media",Ue)),fe("design:type",Function),fe("design:paramtypes",[Array]),fe("design:returntype",J.CancellablePromise)],e.Client.prototype,"getTemporaryContentUrlsForMedia",null),xe([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),xe([h.validateTypes(h.pureObject),fe("design:type",Function),fe("design:paramtypes",[Object]),fe("design:returntype",Zt)],e.Client,"parsePushNotification",null),e.Client=Qt=xe([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=zt})(S0);const Ln=new ts("twilio-chat");class i1 extends pv{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 S0.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=wS(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=wS(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(i1,"type","twilio_conversations");hv(i1);function wS(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 jh={exports:{}},Ra=Sl;function Sl(){}Sl.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}};Sl.mixin(Sl);var a1={exports:{}};(function(e){(function(r,t){e.exports?e.exports=t():r.prefix=t(r)})(Ve,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(x,I,M){var j=d(x,I,M),V=a[M]||a[""],ie=V.template.indexOf("%t")!==-1,oe=V.template.indexOf("%l")!==-1,J=V.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[M]){var Re=V.timestampFormatter(new Date),ae=V.levelFormatter(x),We=V.nameFormatter(M);V.format?L+=V.format(ae,We,Re):(L+=V.template,ie&&(L=L.replace(/%t/,Re)),oe&&(L=L.replace(/%l/,ae)),J&&(L=L.replace(/%n/,We))),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})})(a1);var _J=a1.exports,Fh={exports:{}},wJ={"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=wJ,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 Ve.NXMbugsnagClient<"u"&&Ve.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 Ve.NXMbugsnagClient<"u"&&Ve.NXMbugsnagClient.notify(this,{severity:"info"})}}r.NexmoApiError=s,e.exports={NexmoClientError:a,NexmoApiError:s}})(Fh,Fh.exports);var In=Fh.exports,Uh={exports:{}},hf={},ag={},vf={},Nu={},eo={},mo={},Fr={},sg={},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 s1=Object.create(null);Ii.PACKET_TYPES_REVERSE=s1;Object.keys(ni).forEach(e=>{s1[ni[e]]=e});const SJ={type:"error",data:"parser error"};Ii.ERROR_PACKET=SJ;Object.defineProperty(sg,"__esModule",{value:!0});const TJ=Ii,CJ=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",EJ=typeof ArrayBuffer=="function",kJ=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,RJ=({type:e,data:r},t,n)=>CJ&&r instanceof Blob?t?n(r):SS(r,n):EJ&&(r instanceof ArrayBuffer||kJ(r))?t?n(r):SS(new Blob([r]),n):n(TJ.PACKET_TYPES[e]+(r||"")),SS=(e,r)=>{const t=new FileReader;return t.onload=function(){const n=t.result.split(",")[1];r("b"+(n||""))},t.readAsDataURL(e)};sg.default=RJ;var og={},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 $J=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=$J;const OJ=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=OJ;Object.defineProperty(og,"__esModule",{value:!0});const Sc=Ii,IJ=to,PJ=typeof ArrayBuffer=="function",AJ=(e,r)=>{if(typeof e!="string")return{type:"message",data:o1(e,r)};const t=e.charAt(0);return t==="b"?{type:"message",data:xJ(e.substring(1),r)}:Sc.PACKET_TYPES_REVERSE[t]?e.length>1?{type:Sc.PACKET_TYPES_REVERSE[t],data:e.substring(1)}:{type:Sc.PACKET_TYPES_REVERSE[t]}:Sc.ERROR_PACKET},xJ=(e,r)=>{if(PJ){const t=(0,IJ.decode)(e);return o1(t,r)}else return{base64:!0,data:e}},o1=(e,r)=>{switch(r){case"blob":return e instanceof ArrayBuffer?new Blob([e]):e;case"arraybuffer":default:return e}};og.default=AJ;Object.defineProperty(Fr,"__esModule",{value:!0});Fr.decodePayload=Fr.decodePacket=Fr.encodePayload=Fr.encodePacket=Fr.protocol=void 0;const u1=sg;Fr.encodePacket=u1.default;const c1=og;Fr.decodePacket=c1.default;const l1=String.fromCharCode(30),MJ=(e,r)=>{const t=e.length,n=new Array(t);let i=0;e.forEach((a,s)=>{(0,u1.default)(a,!1,c=>{n[s]=c,++i===t&&r(n.join(l1))})})};Fr.encodePayload=MJ;const NJ=(e,r)=>{const t=e.split(l1),n=[];for(let i=0;i<t.length;i++){const a=(0,c1.default)(t[i],r);if(n.push(a),a.type==="error")break}return n};Fr.decodePayload=NJ;Fr.protocol=4;function Ur(e){if(e)return LJ(e)}function LJ(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 DJ=Object.freeze(Object.defineProperty({__proto__:null,Emitter:Ur},Symbol.toStringTag,{value:"Module"})),go=w0(DJ);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 jJ(e,...r){return r.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}Cn.pick=jJ;const FJ=sa.globalThisShim.setTimeout,UJ=sa.globalThisShim.clearTimeout;function BJ(e,r){r.useNativeTimers?(e.setTimeoutFn=FJ.bind(sa.globalThisShim),e.clearTimeoutFn=UJ.bind(sa.globalThisShim)):(e.setTimeoutFn=sa.globalThisShim.setTimeout.bind(sa.globalThisShim),e.clearTimeoutFn=sa.globalThisShim.clearTimeout.bind(sa.globalThisShim))}Cn.installTimerFunctions=BJ;const qJ=1.33;function GJ(e){return typeof e=="string"?VJ(e):Math.ceil((e.byteLength||e.size)*qJ)}Cn.byteLength=GJ;function VJ(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 Bh={exports:{}},wp,TS;function zJ(){if(TS)return wp;TS=1;var e=1e3,r=e*60,t=r*60,n=t*24,i=n*7,a=n*365.25;wp=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 wp}function WJ(e){t.debug=t,t.default=t,t.coerce=o,t.disable=a,t.enable=i,t.enabled=s,t.humanize=zJ(),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(...x){if(!E.enabled)return;const I=E,M=Number(new Date),j=M-(f||M);I.diff=j,I.prev=f,I.curr=M,f=M,x[0]=t.coerce(x[0]),typeof x[0]!="string"&&x.unshift("%O");let V=0;x[0]=x[0].replace(/%([a-zA-Z%])/g,(oe,J)=>{if(oe==="%%")return"%";V++;const L=t.formatters[J];if(typeof L=="function"){const Y=x[V];oe=L.call(I,Y),x.splice(V,1),V--}return oe}),t.formatArgs.call(I,x),(I.log||t.log).apply(I,x)}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:x=>{d=x}}),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 HJ=WJ;(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=HJ(r);const{formatters:c}=e.exports;c.j=function(o){try{return JSON.stringify(o)}catch(u){return"[UnexpectedJSONParseError]: "+u.message}}})(Bh,Bh.exports);var Wi=Bh.exports,KJ=Ve&&Ve.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(mo,"__esModule",{value:!0});mo.Transport=void 0;const JJ=Fr,YJ=go,XJ=Cn,QJ=KJ(Wi),ZJ=(0,QJ.default)("engine.io-client:transport");class eY extends Error{constructor(r,t,n){super(r),this.description=t,this.context=n,this.type="TransportError"}}class tY extends YJ.Emitter{constructor(r){super(),this.writable=!1,(0,XJ.installTimerFunctions)(this,r),this.opts=r,this.query=r.query,this.socket=r.socket}onError(r,t,n){return super.emitReserved("error",new eY(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):ZJ("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(r){const t=(0,JJ.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=tY;var Pi={};Object.defineProperty(Pi,"__esModule",{value:!0});Pi.yeast=Pi.decode=Pi.encode=void 0;const f1="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Tl=64,d1={};let CS=0,la=0,ES;function qh(e){let r="";do r=f1[e%Tl]+r,e=Math.floor(e/Tl);while(e>0);return r}Pi.encode=qh;function rY(e){let r=0;for(la=0;la<e.length;la++)r=r*Tl+d1[e.charAt(la)];return r}Pi.decode=rY;function nY(){const e=qh(+new Date);return e!==ES?(CS=0,ES=e):e+"."+qh(CS++)}Pi.yeast=nY;for(;la<Tl;la++)d1[f1[la]]=la;var ya={};Object.defineProperty(ya,"__esModule",{value:!0});ya.decode=ya.encode=void 0;function iY(e){let r="";for(let t in e)e.hasOwnProperty(t)&&(r.length&&(r+="&"),r+=encodeURIComponent(t)+"="+encodeURIComponent(e[t]));return r}ya.encode=iY;function aY(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=aY;var mf={},gf={};Object.defineProperty(gf,"__esModule",{value:!0});gf.hasCORS=void 0;let p1=!1;try{p1=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}gf.hasCORS=p1;Object.defineProperty(mf,"__esModule",{value:!0});mf.XHR=void 0;const sY=gf,oY=hs;function uY(e){const r=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!r||sY.hasCORS))return new XMLHttpRequest}catch{}if(!r)try{return new oY.globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}mf.XHR=uY;var cY=Ve&&Ve.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(eo,"__esModule",{value:!0});eo.Request=eo.Polling=void 0;const lY=mo,fY=cY(Wi),dY=Pi,pY=ya,kS=Fr,h1=mf,hY=go,RS=Cn,vY=hs,Xr=(0,fY.default)("engine.io-client:polling");function mY(){}const gY=function(){return new h1.XHR({xdomain:!1}).responseType!=null}();class yY extends lY.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=gY&&!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,kS.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,kS.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,dY.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,pY.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=yY;class Gn extends hY.Emitter{constructor(r,t){super(),(0,RS.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,RS.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 h1.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=mY,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",$S);else if(typeof addEventListener=="function"){const e="onpagehide"in vY.globalThisShim?"pagehide":"unload";addEventListener(e,$S,!1)}}function $S(){for(let e in Gn.requests)Gn.requests.hasOwnProperty(e)&&Gn.requests[e].abort()}var yf={},qn={};Object.defineProperty(qn,"__esModule",{value:!0});qn.defaultBinaryType=qn.usingBrowserWebSocket=qn.WebSocket=qn.nextTick=void 0;const OS=hs;qn.nextTick=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?r=>Promise.resolve().then(r):(r,t)=>t(r,0))();qn.WebSocket=OS.globalThisShim.WebSocket||OS.globalThisShim.MozWebSocket;qn.usingBrowserWebSocket=!0;qn.defaultBinaryType="arraybuffer";var bY=Ve&&Ve.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(yf,"__esModule",{value:!0});yf.WS=void 0;const _Y=mo,wY=ya,SY=Pi,TY=Cn,wi=qn,CY=bY(Wi),EY=Fr,kY=(0,CY.default)("engine.io-client:websocket"),IS=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class RY extends _Y.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=IS?{}:(0,TY.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=wi.usingBrowserWebSocket&&!IS?t?new wi.WebSocket(r,t):new wi.WebSocket(r):new wi.WebSocket(r,t,n)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType||wi.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,EY.encodePacket)(n,this.supportsBinary,a=>{const s={};wi.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{wi.usingBrowserWebSocket?this.ws.send(a):this.ws.send(a,s)}catch{kY("websocket closed before onclose event")}i&&(0,wi.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,SY.yeast)()),this.supportsBinary||(r.b64=1);const i=(0,wY.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!!wi.WebSocket}}yf.WS=RY;Object.defineProperty(Nu,"__esModule",{value:!0});Nu.transports=void 0;const $Y=eo,OY=yf;Nu.transports={websocket:OY.WS,polling:$Y.Polling};var Lu={};Object.defineProperty(Lu,"__esModule",{value:!0});Lu.parse=void 0;const IY=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,PY=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function AY(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=IY.exec(e||""),a={},s=14;for(;s--;)a[PY[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=xY(a,a.path),a.queryKey=MY(a,a.query),a}Lu.parse=AY;function xY(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 MY(e,r){const t={};return r.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,i,a){i&&(t[i]=a)}),t}var NY=Ve&&Ve.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(vf,"__esModule",{value:!0});vf.Socket=void 0;const LY=Nu,PS=Cn,DY=ya,AS=Lu,jY=NY(Wi),FY=go,v1=Fr,er=(0,jY.default)("engine.io-client:socket");let m1=class Is extends FY.Emitter{constructor(r,t={}){super(),this.writeBuffer=[],r&&typeof r=="object"&&(t=r,r=null),r?(r=(0,AS.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,AS.parse)(t.host).host),(0,PS.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,DY.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=v1.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 LY.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,PS.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}};vf.Socket=m1;m1.protocol=v1.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=vf;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=Nu;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=Lu;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}})})(ag);var UY=Ve&&Ve.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(hf,"__esModule",{value:!0});hf.url=void 0;const BY=ag,qY=UY(Wi),xS=qY.default("socket.io-client:url");function GY(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)||(xS("protocol-less url %s",e),typeof t<"u"?e=t.protocol+"//"+e:e="https://"+e),xS("parse %s",e),n=BY.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}hf.url=GY;var bf={},Du={},_f={},ro={},es={};Object.defineProperty(es,"__esModule",{value:!0});es.hasBinary=es.isBinary=void 0;const VY=typeof ArrayBuffer=="function",zY=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,g1=Object.prototype.toString,WY=typeof Blob=="function"||typeof Blob<"u"&&g1.call(Blob)==="[object BlobConstructor]",HY=typeof File=="function"||typeof File<"u"&&g1.call(File)==="[object FileConstructor]";function y1(e){return VY&&(e instanceof ArrayBuffer||zY(e))||WY&&e instanceof Blob||HY&&e instanceof File}es.isBinary=y1;function Yc(e,r){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(Yc(e[t]))return!0;return!1}if(y1(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Yc(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&Yc(e[t]))return!0;return!1}es.hasBinary=Yc;Object.defineProperty(ro,"__esModule",{value:!0});ro.reconstructPacket=ro.deconstructPacket=void 0;const KY=es;function JY(e){const r=[],t=e.data,n=e;return n.data=Gh(t,r),n.attachments=r.length,{packet:n,buffers:r}}ro.deconstructPacket=JY;function Gh(e,r){if(!e)return e;if((0,KY.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]=Gh(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]=Gh(e[n],r));return t}return e}function YY(e,r){return e.data=Vh(e.data,r),delete e.attachments,e}ro.reconstructPacket=YY;function Vh(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]=Vh(e[t],r);else if(typeof e=="object")for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(e[t]=Vh(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,Wi.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),x=h.buffers;return x.unshift(E),x}}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 M=p.substring(I,h);if(M!=Number(M)||p.charAt(h)!=="-")throw new Error("Illegal attachments");E.attachments=Number(M)}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 x=p.charAt(h+1);if(x!==""&&Number(x)==x){const I=h+1;for(;++h;){const M=p.charAt(h);if(M==null||Number(M)!=M){--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=[]}}})(_f);var ju={};Object.defineProperty(ju,"__esModule",{value:!0});ju.on=void 0;function XY(e,r,t){return e.on(r,t),function(){e.off(r,t)}}ju.on=XY;var QY=Ve&&Ve.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Du,"__esModule",{value:!0});Du.Socket=void 0;const Nn=_f,Tc=ju,ZY=go,eX=QY(Wi),gr=eX.default("socket.io-client:socket"),tX=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class rX extends ZY.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=[Tc.on(r,"open",this.onopen.bind(this)),Tc.on(r,"packet",this.onpacket.bind(this)),Tc.on(r,"error",this.onerror.bind(this)),Tc.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(tX.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)}}}Du.Socket=rX;var wf={};Object.defineProperty(wf,"__esModule",{value:!0});wf.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}wf.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 nX=Ve&&Ve.__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]}),iX=Ve&&Ve.__setModuleDefault||(Object.create?function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}:function(e,r){e.default=r}),aX=Ve&&Ve.__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)&&nX(r,e,t);return iX(r,e),r},sX=Ve&&Ve.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(bf,"__esModule",{value:!0});bf.Manager=void 0;const Sp=ag,oX=Du,uX=aX(_f),Va=ju,cX=wf,lX=go,fX=sX(Wi),$r=fX.default("socket.io-client:manager");class dX extends lX.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 cX.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||uX;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=Va.on(t,"open",function(){n.onopen(),r&&r()}),a=Va.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(Va.on(r,"ping",this.onping.bind(this)),Va.on(r,"data",this.ondata.bind(this)),Va.on(r,"error",this.onerror.bind(this)),Va.on(r,"close",this.onclose.bind(this)),Va.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 oX.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)}}bf.Manager=dX;(function(e,r){var t=Ve&&Ve.__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=hf,i=bf;Object.defineProperty(r,"Manager",{enumerable:!0,get:function(){return i.Manager}});const a=Du;Object.defineProperty(r,"Socket",{enumerable:!0,get:function(){return a.Socket}});const c=t(Wi).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,x=p.path,I=o[E]&&x in o[E].nsps,M=d.forceNew||d["force new connection"]||d.multiplex===!1||I;let j;return M?(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=_f;Object.defineProperty(r,"protocol",{enumerable:!0,get:function(){return l.protocol}}),e.exports=u})(Uh,Uh.exports);var b1=Uh.exports,_1={exports:{}};(function(e,r){(function(t){e.exports=t()})(function(){var t=function(C,A,D){for(var z=D,W=0,he=C.length;W<he;W++)z=A(z,C[W],W,C);return z},n=function(C,A){return t(C,function(D,z,W,he){return A(z,W,he)?D.concat(z):D},[])},i=function(C,A){return t(C,function(D,z,W,he){return D.concat(A(z,W,he))},[])},a=function(C,A){return t(C,function(D,z,W,he){return D===!0||z===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 z=0,W=c.length;z<W;z++)Object.prototype.hasOwnProperty.call(C,c[z])&&A.push(c[z]);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,x=d.reduce,I=d.keys,M=d.isArray,j=d.includes,V=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"||M(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||M(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 V(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&&x(["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 M(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 x(I(A),function(D,z){return D[z]=C[z]!==void 0?C[z]:A[z].defaultValue(C[z],C),D},{})},h.validate=function(C,A){if(!C||!A)throw new Error("opts and schema objects are required");var D=x(I(A),function(z,W){return A[W].validate(C[W],C)?z:z.concat({key:W,message:A[W].message,value:C[W]})},[]);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 z in D)Object.prototype.hasOwnProperty.call(D,z)&&(C[z]=D[z])}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 z=console[D];C[D]=typeof z=="function"?z.bind(console,"[bugsnag]"):A.bind(console,"[bugsnag]")}),C},Re=d.isoDate,ae=function(){function C(D,z,W,he){D===void 0&&(D="[anonymous]"),z===void 0&&(z={}),W===void 0&&(W="manual"),he===void 0&&(he=Re()),this.type=W,this.name=D,this.metaData=z,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}(),We=ae,be=function(C,A,D){var z=C.length,W=0,he=function(){if(W>=z)return D(null,!1);A(C[W],function(we,Ee){if(we)return D(we,!1);if(Ee===!0)return D(null,!0);W++,he()})};he()},Te=function(C){return C.app&&typeof C.app.releaseStage=="string"?C.app.releaseStage:C.config.releaseStage},Se=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=Se,De=function(C,A){return function(D,z){if(typeof D!="function")return z(null,!1);try{if(D.length!==2){var W=D(C);return W&&typeof W.then=="function"?W.then(function(he){return setTimeout(function(){return z(null,G(C,he))},0)},function(he){setTimeout(function(){return A(he),z(null,!1)})}):z(null,G(C,W))}D(C,function(he,we){if(he)return A(he),z(null,!1);z(null,G(C,we))})}catch(he){A(he),z(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 z=["isConstructor","isEval","isNative","isToplevel"],W=["columnNumber","lineNumber"],he=["fileName","functionName","source"],we=["args"],Ee=z.concat(W,he,we);function Fe(Ge){if(Ge instanceof Object)for(var Mt=0;Mt<Ee.length;Mt++)Ge.hasOwnProperty(Ee[Mt])&&Ge[Ee[Mt]]!==void 0&&this["set"+A(Ee[Mt])](Ge[Ee[Mt]])}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}",Mt="("+(this.getArgs()||[]).join(",")+")",sn=this.getFileName()?"@"+this.getFileName():"",St=C(this.getLineNumber())?":"+this.getLineNumber():"",$t=C(this.getColumnNumber())?":"+this.getColumnNumber():"";return Ge+Mt+sn+St+$t}};for(var et=0;et<z.length;et++)Fe.prototype["get"+A(z[et])]=D(z[et]),Fe.prototype["set"+A(z[et])]=function(Ge){return function(Mt){this[Ge]=!!Mt}}(z[et]);for(var pt=0;pt<W.length;pt++)Fe.prototype["get"+A(W[pt])]=D(W[pt]),Fe.prototype["set"+A(W[pt])]=function(Ge){return function(Mt){if(!C(Mt))throw new TypeError(Ge+" must be a Number");this[Ge]=Number(Mt)}}(W[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(Mt){this[Ge]=String(Mt)}}(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+/,z=/^\s*at .*(\S+\:\d+|\(native\))/m,W=/^(eval@)?(\[native code\])?$/;return{parse:function(we){if(typeof we.stacktrace<"u"||typeof we["opera#sourceloc"]<"u")return this.parseOpera(we);if(we.stack&&we.stack.match(z))return this.parseV8OrIE(we);if(we.stack)return this.parseFFOrSafari(we);throw new Error("Cannot parse given Error object")},extractLocation:function(we){if(we.indexOf(":")===-1)return[we];var Ee=/(.+?)(?:\:(\d+))?(?:\:(\d+))?$/,Fe=Ee.exec(we.replace(/[\(\)]/g,""));return[Fe[1],Fe[2]||void 0,Fe[3]||void 0]},parseV8OrIE:function(we){var Ee=we.stack.split(`
|
|
465
|
-
`).filter(function(Fe){return!!Fe.match(z)},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()),Mt=Dt.join(" ")||void 0,sn=["eval","<anonymous>"].indexOf(Ge[0])>-1?void 0:Ge[0];return new A({functionName:Mt,fileName:sn,lineNumber:Ge[1],columnNumber:Ge[2],source:Fe})},this)},parseFFOrSafari:function(we){var Ee=we.stack.split(`
|
|
466
|
-
`).filter(function(Fe){return!Fe.match(W)},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(we){return!we.stacktrace||we.message.indexOf(`
|
|
467
|
-
`)>-1&&we.message.split(`
|
|
468
|
-
`).length>we.stacktrace.split(`
|
|
469
|
-
`).length?this.parseOpera9(we):we.stack?this.parseOpera11(we):this.parseOpera10(we)},parseOpera9:function(we){for(var Ee=/Line (\d+).*script (?:in )?(\S+)/i,Fe=we.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(we){for(var Ee=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,Fe=we.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(we){var Ee=we.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,Mt;Dt.match(/\(([^\)]*)\)/)&&(Mt=Dt.replace(/^[^\(]+\(([^\)]*)\)$/,"$1"));var sn=Mt===void 0||Mt==="[arguments not available]"?void 0:Mt.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 z=[],W=10;typeof D=="object"&&typeof D.maxStackSize=="number"&&(W=D.maxStackSize);for(var he=arguments.callee;he&&z.length<W&&he.arguments;){for(var we=new Array(he.arguments.length),Ee=0;Ee<we.length;++Ee)we[Ee]=he.arguments[Ee];/function(?:\s+([\w$]+))+\s*\(/.test(he.toString())?z.push(new C({functionName:RegExp.$1||void 0,args:we})):z.push(new C({args:we}));try{he=he.caller}catch{break}}return z}}});function xe(){return xe=Object.assign||function(C){for(var A=1;A<arguments.length;A++){var D=arguments[A];for(var z in D)Object.prototype.hasOwnProperty.call(D,z)&&(C[z]=D[z])}return C},xe.apply(this,arguments)}var fe=d.reduce,Pt=d.filter,ze=function(){function C(D,z,W,he,we){W===void 0&&(W=[]),he===void 0&&(he=Me()),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(z,"[no error message]"),this.groupingHash=void 0,this.metaData={},this.request=void 0,this.severity=this._handledState.severity,this.stacktrace=fe(W,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=we}var A=C.prototype;return A.ignore=function(){this._ignored=!0},A.isIgnored=function(){return this._ignored},A.updateMetaData=function(z){var W;if(!z)return this;var he;return(arguments.length<=1?void 0:arguments[1])===null?this.removeMetaData(z):(arguments.length<=2?void 0:arguments[2])===null?this.removeMetaData(z,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=(W={},W[arguments.length<=1?void 0:arguments[1]]=arguments.length<=2?void 0:arguments[2],W)),he?(this.metaData[z]||(this.metaData[z]={}),this.metaData[z]=xe({},this.metaData[z],he),this):this)},A.removeMetaData=function(z,W){return typeof z!="string"?this:W?this.metaData[z]?(delete this.metaData[z][W],this):this:(delete this.metaData[z],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},Me=function(){return{unhandled:!1,severity:"warning",severityReason:{type:"handledException"}}},ft=function(C,A){return typeof C=="string"&&C?C:A};ze.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(z){if(je(z))return ut.parse(C).slice(1+D);try{return Pt(ur.backtrace(),function(W){return(W.functionName||"").indexOf("StackGenerator$$")===-1}).slice(1+D)}catch{return[]}}},ze.ensureReport=function(C,A,D){if(A===void 0&&(A=0),D===void 0&&(D=0),C.__isBugsnagReport)return C;try{var z=ze.getStacktrace(C,A,1+D);return new ze(C.name,C.message,z,void 0,C)}catch{return new ze(C.name,C.message,[],void 0,C)}};var Tt=ze,Le=function(A,D){var z="000000000"+A;return z.substr(z.length-D)},Jt=typeof window=="object"?window:self,vt=0;for(var Vt in Jt)Object.hasOwnProperty.call(Jt,Vt)&&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),z=Pr(),W=st()+st();return C+A+D+z+W}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(z){this[z._handledState.unhandled?"_unhandled":"_handled"]+=1},C}(),_r=Pn;function zt(){return zt=Object.assign||function(C){for(var A=1;A<arguments.length;A++){var D=arguments[A];for(var z in D)Object.prototype.hasOwnProperty.call(D,z)&&(C[z]=D[z])}return C},zt.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=We,this.BugsnagSession=_r;var z=this,W=this.notify;this.notify=function(){return W.apply(z,arguments)}}var A=C.prototype;return A.setOptions=function(z){this._opts=zt({},this._opts,z)},A.configure=function(z){z===void 0&&(z=h.schema);var W=h.mergeDefaults(this._opts,z),he=h.validate(W,z);if(!he.valid)throw new Error(ee(he.errors));return typeof W.beforeSend=="function"&&(W.beforeSend=[W.beforeSend]),W.appVersion&&(this.app.version=W.appVersion),W.appType&&(this.app.type=W.appType),W.metaData&&(this.metaData=W.metaData),W.user&&(this.user=W.user),W.logger&&this.logger(W.logger),this.config=zt({},this.config,W),this._configured=!0,this},A.use=function(z){if(!this._configured)throw new Error("client not configured");z.configSchema&&this.configure(z.configSchema);for(var W=arguments.length,he=new Array(W>1?W-1:0),we=1;we<W;we++)he[we-1]=arguments[we];var Ee=z.init.apply(z,[this].concat(he));return z.name&&(this._plugins["~"+z.name+"~"]=Ee),this},A.getPlugin=function(z){return this._plugins["~"+z+"~"]},A.delivery=function(z){return this._delivery=z(this),this},A.logger=function(z,W){return this._logger=z,this},A.sessionDelegate=function(z){return this._sessionDelegate=z,this},A.startSession=function(){return this._sessionDelegate?this._sessionDelegate.startSession(this):(this._logger.warn("No session implementation is installed"),this)},A.leaveBreadcrumb=function(z,W,he,we){if(!this._configured)throw new Error("client not configured");if(z=z||void 0,he=typeof he=="string"?he:void 0,we=typeof we=="string"?we:void 0,W=typeof W=="object"&&W!==null?W:void 0,!(typeof z!="string"&&!W)){var Ee=new We(z,W,he,we);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(z,W,he){var we=this;if(W===void 0&&(W={}),he===void 0&&(he=function(){}),!this._configured)throw new Error("client not configured");var Ee=Te(this),Fe=ke(z,W,this._logger),et=Fe.err,pt=Fe.errorFramesToSkip,Dt=Fe._opts;Dt&&(W=Dt),(typeof W!="object"||W===null)&&(W={});var Ge=Tt.ensureReport(et,pt,2);if(Ge.app=zt({},{releaseStage:Ee},Ge.app,this.app),Ge.context=Ge.context||W.context||this.context||void 0,Ge.device=zt({},Ge.device,this.device,W.device),Ge.request=zt({},Ge.request,this.request,W.request),Ge.user=zt({},Ge.user,this.user,W.user),Ge.metaData=zt({},Ge.metaData,this.metaData,W.metaData),Ge.breadcrumbs=this.breadcrumbs.slice(0),this._session&&(this._session.trackError(Ge),Ge.session=this._session),W.severity!==void 0&&(Ge.severity=W.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 Mt=Ge.severity,sn=[].concat(W.beforeSend).concat(this.config.beforeSend),St=function($t){we._logger.error("Error occurred in beforeSend callback, continuing anyway…"),we._logger.error($t)};be(sn,De(Ge,St),function($t,Rr){if($t&&St($t),Rr)return we._logger.debug("Report not sent due to beforeSend callback"),he(null,Ge);we.config.autoBreadcrumbs&&we.leaveBreadcrumb(Ge.errorClass,{errorClass:Ge.errorClass,errorMessage:Ge.errorMessage,severity:Ge.severity},"error"),Mt!==Ge.severity&&(Ge._handledState.severityReason={type:"userCallbackSetSeverity"}),we._delivery.sendReport({apiKey:Ge.apiKey||we.config.apiKey,notifier:we.notifier,events:[Ge]},function(mr){return he(mr,Ge)})})},C}(),ke=function(C,A,D){var z=3,W=function(Fe){var et=ve(Fe);return D.warn(ce+" "+et),new Error(de+" "+et)},he,we=0,Ee;switch(typeof C){case"string":typeof A=="string"?(he=W("string/string"),Ee={metaData:{notifier:{notifyArgs:[C,A]}}}):(he=new Error(String(C)),we=z);break;case"number":case"boolean":he=new Error(String(C));break;case"function":he=W("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,we=z):he=W(C===null?"null":"unsupported object");break;default:he=W("nothing")}return{err:he,errorFramesToSkip:we,_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,z){var W=z&&z.filterKeys?z.filterKeys:[],he=z&&z.filterPaths?z.filterPaths:[];return JSON.stringify(wr(C,W,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,z=C.length;D<z;D++)if(C[D]===A)return!0;return!1}function Ye(C,A){for(var D=0,z=C.length;D<z;D++)if(A.indexOf(C[D])===0)return!0;return!1}function tt(C,A){for(var D=0,z=C.length;D<z;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 wr(C,A,D){var z=[],W=0;function he(we,Ee){function Fe(){return Ee.length>Ze&&W>Oe}if(W++,Ee.length>Ue||Fe())return Ke;if(we===null||typeof we!="object")return we;if(nt(z,we))return"[Circular]";if(z.push(we),typeof we.toJSON=="function")try{W--;var et=he(we.toJSON(),Ee);return z.pop(),et}catch(Rr){return rt(Rr)}var pt=Je(we);if(pt){W--;var Dt=he({name:we.name,message:we.message},Ee);return z.pop(),Dt}if(it(we)){for(var Ge=[],Mt=0,sn=we.length;Mt<sn;Mt++){if(Fe()){Ge.push(Ke);break}Ge.push(he(we[Mt],Ee.concat("[]")))}return z.pop(),Ge}var St={};try{for(var $t in we)if(Object.prototype.hasOwnProperty.call(we,$t)){if(Ye(D,Ee.join("."))&&tt(A,$t)){St[$t]="[Filtered]";continue}if(Fe()){St[$t]=Ke;break}St[$t]=he(ct(we,$t),Ee.concat($t))}}catch{}return z.pop(),St}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={},zn=d.isoDate;ir=function(C,A){return A===void 0&&(A=window),{sendReport:function(D,z){z===void 0&&(z=function(){});var W=hi(C.config,"notify","4",A),he=new A.XDomainRequest;he.onload=function(){z(null)},he.open("POST",W),setTimeout(function(){try{he.send(cr.report(D,C.config.filters))}catch(we){C._logger.error(we),z(we)}},0)},sendSession:function(D,z){z===void 0&&(z=function(){});var W=hi(C.config,"sessions","1",A),he=new A.XDomainRequest;he.onload=function(){z(null)},he.open("POST",W),setTimeout(function(){try{he.send(cr.session(D,C.config.filters))}catch(we){C._logger.error(we),z(we)}},0)}}};var hi=function(C,A,D,z){return $a(C.endpoints[A],z.location.protocol)+"?apiKey="+encodeURIComponent(C.apiKey)+"&payloadVersion="+D+"&sentAt="+encodeURIComponent(zn())},$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,z){z===void 0&&(z=function(){});try{var W=C.config.endpoints.notify,he=new A.XMLHttpRequest;he.onreadystatechange=function(){he.readyState===A.XMLHttpRequest.DONE&&z(null)},he.open("POST",W),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(we){C._logger.error(we)}},sendSession:function(D,z){z===void 0&&(z=function(){});try{var W=C.config.endpoints.sessions,he=new A.XMLHttpRequest;he.onreadystatechange=function(){he.readyState===A.XMLHttpRequest.DONE&&z(null)},he.open("POST",W),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(we){C._logger.error(we)}}}},Oa={init:function(C,A){A===void 0&&(A=window),C.config.beforeSend.unshift(function(D){D.context||(D.context=A.location.pathname)})}};function Wn(){return Wn=Object.assign||function(C){for(var A=1;A<arguments.length;A++){var D=arguments[A];for(var z in D)Object.prototype.hasOwnProperty.call(D,z)&&(C[z]=D[z])}return C},Wn.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=Wn({},D,C.device),C.config.beforeSend.unshift(function(z){z.device=Wn({},z.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 z in D)Object.prototype.hasOwnProperty.call(D,z)&&(C[z]=D[z])}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 z in D)Object.prototype.hasOwnProperty.call(D,z)&&(C[z]=D[z])}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 z in D)Object.prototype.hasOwnProperty.call(D,z)&&(C[z]=D[z])}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,xa=d.reduce,Yr=d.filter;mi.init=function(C){var A=/^dev(elopment)?$/.test(C.config.releaseStage),D=C.config.consoleBreadcrumbsEnabled===!1,z=(C.config.autoBreadcrumbs===!1||A)&&C.config.consoleBreadcrumbsEnabled!==!0;D||z||Hn(gi,function(W){var he=console[W];console[W]=function(){for(var we=arguments.length,Ee=new Array(we),Fe=0;Fe<we;Fe++)Ee[Fe]=arguments[Fe];C.leaveBreadcrumb("Console output",xa(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:W.indexOf("group")===0?"log":W}),"log"),he.apply(console,Ee)},console[W]._restore=function(){console[W]=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,Ma=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 z=D.location.href,W="",he=!1,we=function(){return A.documentElement.outerHTML};W=we();var Ee=A.onreadystatechange;A.onreadystatechange=function(){A.readyState==="interactive"&&(W=we(),he=!0);try{Ee.apply(this,arguments)}catch{}};var Fe=null,et=function(St){Fe=St},pt=function(){var St=A.currentScript||Fe;if(!St&&!he){var $t=A.scripts||A.getElementsByTagName("script");St=$t[$t.length-1]}return St},Dt=function(St){(!he||!W)&&(W=we());var $t=["<!-- DOC START -->"].concat(W.split(`
|
|
479
|
-
`)),Rr=St-1,mr=Math.max(Rr-3,0),La=Math.min(Rr+3,$t.length);return Ma($t.slice(mr,La),function(xn,wo,Rf){return xn[mr+1+Rf]=wo.length<=vr?wo:wo.substr(0,vr),xn},{})};C.config.beforeSend.unshift(function(St){St.stacktrace=Na(St.stacktrace,function(La){return!/__trace__$/.test(La.method)});var $t=St.stacktrace[0];if(!($t&&$t.file&&$t.file.replace(/#.*$/,"")!==z.replace(/#.*$/,""))){var Rr=pt();if(Rr){var mr=Rr.innerHTML;St.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(St){return bi(D,St,function($t){return sn($t,function(Rr){return{get:function(){return Rr[0]},replace:function(mr){Rr[0]=mr}}})})}),Mt=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(St){!D[St]||!D[St].prototype||!D[St].prototype.hasOwnProperty||!D[St].prototype.hasOwnProperty("addEventListener")||(bi(D[St].prototype,"addEventListener",function($t){return sn($t,ea)}),bi(D[St].prototype,"removeEventListener",function($t){return sn($t,ea,!0)}))});function sn(St,$t,Rr){return Rr===void 0&&(Rr=!1),function(){var mr=Array.prototype.slice.call(arguments);try{var La=$t(mr),xn=La.get();if(Rr&&St.apply(this,mr),typeof xn!="function")return St.apply(this,mr);if(xn.__trace__)La.replace(xn.__trace__);else{var wo=pt();xn.__trace__=function(){et(wo),Mt(function(){et(null)},0);var C$=xn.apply(this,arguments);return et(null),C$},xn.__trace__.__trace__=xn.__trace__,La.replace(xn.__trace__)}}catch{}if(St.apply)return St.apply(this,mr);switch(mr.length){case 1:return St(mr[0]);case 2:return St(mr[0],mr[1]);default:return St()}}}},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 z=C[A];if(!z)return z;var W=D(z);return C[A]=W,z}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,z=C.config.autoBreadcrumbs===!1&&C.config.interactionBreadcrumbsEnabled!==!0;D||z||A.addEventListener("click",function(W){var he,we;try{he=An(W.target),we=Zt(W.target,A)}catch{he="[hidden]",we="[hidden]",C._logger.error("Cross domain error when tracking click event. See docs: https://tinyurl.com/yy3rn63z")}C.leaveBreadcrumb("UI click",{targetText:he,targetSelector:we},"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 z=Array.prototype.indexOf.call(C.parentNode.childNodes,C)+1;D.push(":nth-child("+z+")")}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,z=C.config.autoBreadcrumbs===!1&&C.config.navigationBreadcrumbsEnabled!==!0;if(!(D||z)){var W=function(he){return function(){return C.leaveBreadcrumb(he,{},"navigation")}};A.addEventListener("pagehide",W("Page hidden"),!0),A.addEventListener("pageshow",W("Page shown"),!0),A.addEventListener("load",W("Page loaded"),!0),A.document.addEventListener("DOMContentLoaded",W("DOMContentLoaded"),!0),A.addEventListener("load",function(){return A.addEventListener("popstate",W("Navigated back"),!0)}),A.addEventListener("hashchange",function(he){var we=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",we,"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,z){var W=kr(C.location.href,C);return{title:D,state:A,prevState:F(C),to:z||W,from:W}},ta=function(C,A,D,z){var W=A[D];A[D]=function(he,we,Ee){C.leaveBreadcrumb("History "+D,nn(z,he,we,Ee),"navigation"),typeof C.refresh=="function"&&C.refresh(),C.config.autoCaptureSessions&&C.startSession(),W.apply(A,[he,we].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 z=C.config.networkBreadcrumbsEnabled===!1,W=C.config.autoBreadcrumbs===!1&&C.config.networkBreadcrumbsEnabled!==!0;z||W||(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,z){this[R]=z,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,z=arguments[0],W=arguments[1],he,we=null;return z&&typeof z=="object"?(we=z.url,W&&"method"in W?he=W.method:z&&"method"in z&&(he=z.method)):(we=z,W&&"method"in W&&(he=W.method)),he===void 0&&(he="GET"),new Promise(function(Ee,Fe){C.apply(void 0,D).then(function(et){an(et,he,we),Ee(et)}).catch(function(et){_o(he,we),Fe(et)})})}}},an=function(C,A,D){var z={status:C.status,request:A+" "+D};C.status>=400?me.leaveBreadcrumb("fetch() failed",z,P):me.leaveBreadcrumb("fetch() succeeded",z,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)}}}},S={};function k(){return k=Object.assign||function(C){for(var A=1;A<arguments.length;A++){var D=arguments[A];for(var z in D)Object.prototype.hasOwnProperty.call(D,z)&&(C[z]=D[z])}return C},k.apply(this,arguments)}var w=d.map;S={init:function(C){C.config.beforeSend.push(function(A){A.stacktrace=w(A.stacktrace,function(D){return k({},D,{file:m(D.file)})})})}};var m=S._strip=function(C){return typeof C=="string"?C.replace(/\?.*$/,"").replace(/#.*$/,""):C},v={init:function(C,A){A===void 0&&(A=window);function D(W,he,we,Ee,Fe){if(we===0&&/Script error\.?/.test(W))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,we,Ee),et,Fe):(pt=new C.BugsnagReport("window.onerror",String(Fe),_(C.BugsnagReport.getStacktrace(Fe,1),he,we,Ee),et,Fe),pt.updateMetaData("window onerror",{error:Fe}));else if(typeof W=="object"&&W!==null&&(!he||typeof he!="string")&&!we&&!Ee&&!Fe){var Dt=W.type?"Event: "+W.type:"window.onerror",Ge=W.message||W.detail||"";pt=new C.BugsnagReport(Dt,Ge,C.BugsnagReport.getStacktrace(new Error,1).slice(1),et,W),pt.updateMetaData("window onerror",{event:W,extraParameters:he})}else pt=new C.BugsnagReport("window.onerror",String(W),_(C.BugsnagReport.getStacktrace(Fe,1),he,we,Ee),et,W),pt.updateMetaData("window onerror",{event:W});C.notify(pt)}typeof z=="function"&&z.apply(this,arguments)}var z=A.onerror;A.onerror=D}},_=function(C,A,D,z){var W=C[0];return W&&(!W.fileName&&typeof A=="string"&&W.setFileName(A),!W.lineNumber&&g(D)&&W.setLineNumber(D),W.columnNumber||(g(z)?W.setColumnNumber(z):window.event&&g(window.event.errorCharacter)&&W.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(z){var W=z.reason,he=!1;try{z.detail&&z.detail.reason&&(W=z.detail.reason,he=!0)}catch{}var we={severity:"error",unhandled:!0,severityReason:{type:"unhandledPromiseRejection"}},Ee;if(W&&je(W))Ee=new C.BugsnagReport(W.name,W.message,ut.parse(W),we,W),he&&(Ee.stacktrace=b(Ee.stacktrace,$(W),[]));else{var Fe='Rejection reason was not an Error. See "Promise" tab for more detail.';Ee=new C.BugsnagReport(W&&W.name?W.name:"UnhandledRejection",W&&W.message?W.message:Fe,[],we,W),Ee.updateMetaData("promise","rejection reason",T(W))}C.notify(Ee)};"addEventListener"in A?A.addEventListener("unhandledrejection",D):A.onunhandledrejection=function(z,W){D({detail:{reason:z,promise:W}})}};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 z in D)Object.prototype.hasOwnProperty.call(D,z)&&(C[z]=D[z])}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(S),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:We},H.default=H,H})})(_1);var pX=_1.exports,hX=pX,zh={exports:{}};const MS="[a-fA-F\\d:]",fa=e=>e&&e.includeBoundaries?`(?:(?<=\\s|^)(?=${MS})|(?<=${MS})(?=\\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}",Sf=`
|
|
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(),vX=new RegExp(`(?:^${Dn}$)|(?:^${Sf}$)`),mX=new RegExp(`^${Dn}$`),gX=new RegExp(`^${Sf}$`),ug=e=>e&&e.exact?vX:new RegExp(`(?:${fa(e)}${Dn}${fa(e)})|(?:${fa(e)}${Sf}${fa(e)})`,"g");ug.v4=e=>e&&e.exact?mX:new RegExp(`${fa(e)}${Dn}${fa(e)}`,"g");ug.v6=e=>e&&e.exact?gX:new RegExp(`${fa(e)}${Sf}${fa(e)}`,"g");var yX=ug;const cg=yX,Ws=e=>cg({exact:!0}).test(e);Ws.v4=e=>cg.v4({exact:!0}).test(e);Ws.v6=e=>cg.v6({exact:!0}).test(e);Ws.version=e=>Ws(e)?Ws.v4(e)?4:6:void 0;var bX=Ws;(function(e,r){var t=Ve&&Ve.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(bX);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,x)=>{p.addEventListener("error",x,{once:!0}),p.addEventListener("timeout",x,{once:!0}),p.addEventListener("load",()=>{const I=p.responseText.trim();if(!I||d==="v4"?!n.default.v4(I):!n.default.v6(I)){x();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(x){if(x instanceof i)throw x}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})(zh,zh.exports);var _X=zh.exports,Cc={exports:{}},Wh={exports:{}},NS=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(NS){var LS=new Uint8Array(16);Wh.exports=function(){return NS(LS),LS}}else{var DS=new Array(16);Wh.exports=function(){for(var r=0,t;r<16;r++)r&3||(t=Math.random()*4294967296),DS[r]=t>>>((r&3)<<3)&255;return DS}}var w1=Wh.exports,S1=[];for(var Ec=0;Ec<256;++Ec)S1[Ec]=(Ec+256).toString(16).substr(1);function wX(e,r){var t=r||0,n=S1;return[n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]]].join("")}var T1=wX,SX=w1,TX=T1,jS,Tp,Cp=0,Ep=0;function CX(e,r,t){var n=r&&t||0,i=r||[];e=e||{};var a=e.node||jS,s=e.clockseq!==void 0?e.clockseq:Tp;if(a==null||s==null){var c=SX();a==null&&(a=jS=[c[0]|1,c[1],c[2],c[3],c[4],c[5]]),s==null&&(s=Tp=(c[6]<<8|c[7])&16383)}var o=e.msecs!==void 0?e.msecs:new Date().getTime(),u=e.nsecs!==void 0?e.nsecs:Ep+1,l=o-Cp+(u-Ep)/1e4;if(l<0&&e.clockseq===void 0&&(s=s+1&16383),(l<0||o>Cp)&&e.nsecs===void 0&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Cp=o,Ep=u,Tp=s,o+=122192928e5;var f=((o&268435455)*1e4+u)%4294967296;i[n++]=f>>>24&255,i[n++]=f>>>16&255,i[n++]=f>>>8&255,i[n++]=f&255;var d=o/4294967296*1e4&268435455;i[n++]=d>>>8&255,i[n++]=d&255,i[n++]=d>>>24&15|16,i[n++]=d>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var p=0;p<6;++p)i[n+p]=a[p];return r||TX(i)}var EX=CX,kX=w1,RX=T1;function $X(e,r,t){var n=r&&t||0;typeof e=="string"&&(r=e==="binary"?new Array(16):null,e=null),e=e||{};var i=e.random||(e.rng||kX)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,r)for(var a=0;a<16;++a)r[n+a]=i[a];return r||RX(i)}var OX=$X,IX=EX,C1=OX,lg=C1;lg.v1=IX;lg.v4=C1;var PX=lg,kc={exports:{}},Hh={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})(Hh,Hh.exports);var E1=Hh.exports,Rc={exports:{}},$c={exports:{}},Kh={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})(Kh,Kh.exports);var Hi=Kh.exports,FS;function fg(){return FS||(FS=1,function(e,r){var t=Ve&&Ve.__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}($c,$c.exports)),$c.exports}var Jh={exports:{}};(function(e,r){var t=Ve&&Ve.__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})(Jh,Jh.exports);var dg=Jh.exports,Oc={exports:{}},US;function pg(){return US||(US=1,function(e,r){var t=Ve&&Ve.__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}(Oc,Oc.exports)),Oc.exports}var Ic={exports:{}},Pc={exports:{}};let k1=!0,R1=!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 AX(e){return typeof e!="boolean"?new Error("Argument type: "+typeof e+". Please use a boolean."):(k1=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function xX(e){return typeof e!="boolean"?new Error("Argument type: "+typeof e+". Please use a boolean."):(R1=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function hg(){if(typeof window=="object"){if(k1)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function Tf(e,r){R1&&console.warn(e+" is deprecated, please use "+r+" instead.")}function MX(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 BS(e){return Object.prototype.toString.call(e)==="[object Object]"}function $1(e){return BS(e)?Object.keys(e).reduce(function(r,t){const n=BS(e[t]),i=n?$1(e[t]):e[t],a=n&&!Object.keys(i).length;return i===void 0||a?r:Object.assign(r,{[t]:i})},{}):e}function Yh(e,r,t){!r||t.has(r.id)||(t.set(r.id,r),Object.keys(r).forEach(n=>{n.endsWith("Id")?Yh(e,e.get(r[n]),t):n.endsWith("Ids")&&r[n].forEach(i=>{Yh(e,e.get(i),t)})}))}function qS(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&&Yh(e,c,i)})}),i}const GS=hg;function O1(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),GS("chrome: "+JSON.stringify(c)),o(c)})}c.video=n(c.video)}return GS("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 NX(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 I1(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function P1(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 A1(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 x1(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 M1(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=>qS(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=>qS(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 N1(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 L1(e,r){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&r.version>=65)return N1(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 Xh(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 D1(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 VS=Object.freeze(Object.defineProperty({__proto__:null,fixNegotiationNeeded:D1,shimAddTrackRemoveTrack:L1,shimAddTrackRemoveTrackWithNative:N1,shimGetDisplayMedia:NX,shimGetSendersWithDtmf:A1,shimGetStats:x1,shimGetUserMedia:O1,shimMediaStream:I1,shimOnTrack:P1,shimPeerConnection:Xh,shimSenderReceiverGetStats:M1},Symbol.toStringTag,{value:"Module"}));function LX(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&&Tf("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 j1={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})(j1);var F1=j1.exports;const Xc=mv(F1);var ht=F1;function DX(e){return{inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type}function zS(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 jX(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 Ac(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 WS(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 kp(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 xr(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 FX=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 xr("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=jX(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 xr("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var l=this.transceivers.find(function(p){return p.track===o});if(l)throw xr("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 xr("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 xr("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,x=!E||Object.keys(E).length===0;if(x)(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 M=ht.getMediaSections(l._localDescription.sdp);x?M[h.candidate.sdpMLineIndex]+=`a=end-of-candidates\r
|
|
538
|
-
`:M[h.candidate.sdpMLineIndex]+="a="+h.candidate.candidate+`\r
|
|
539
|
-
`,l._localDescription.sdp=ht.getDescription(l._localDescription.sdp)+M.join("");var j=l.transceivers.every(function(V){return V.iceGatherer&&V.iceGatherer.state==="completed"});l.iceGatheringState!=="gathering"&&(l.iceGatheringState="gathering",l._emitGatheringStateChange()),x||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=Ac(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(xr("TypeError",'Unsupported type "'+o.type+'"'));if(!WS("setLocalDescription",o.type,u.signalingState)||u._isClosed)return Promise.reject(xr("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],x=E.iceGatherer,I=E.iceTransport,M=E.dtlsTransport,j=E.localCapabilities,V=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(x,oe,d?"controlling":"controlled"),M.state==="new"&&M.start(J));var L=Ac(j,V);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(xr("TypeError",'Unsupported type "'+o.type+'"'));if(!WS("setRemoteDescription",o.type,u.signalingState)||u._isClosed)return Promise.reject(xr("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 x=ht.matchPrefix(p,"a=ice-options:")[0];return x?u.canTrickleIceCandidates=x.substr(14).split(" ").indexOf("trickle")>=0:u.canTrickleIceCandidates=!1,d.forEach(function(I,M){var j=ht.splitLines(I),V=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||V==="application"&&(oe==="DTLS/SCTP"||oe==="UDP/DTLS/SCTP")){u.transceivers[M]={mid:Y,kind:V,protocol:oe,rejected:!0};return}!ie&&u.transceivers[M]&&u.transceivers[M].rejected&&(u.transceivers[M]=u._createTransceiver(V,!0));var Z,ye,Re,ae,We,be,Te,Se,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&&M>0&&u.transceivers[M]&&(u._disposeIceAndDtlsTransports(M),u.transceivers[M].iceGatherer=u.transceivers[0].iceGatherer,u.transceivers[M].iceTransport=u.transceivers[0].iceTransport,u.transceivers[M].dtlsTransport=u.transceivers[0].dtlsTransport,u.transceivers[M].rtpSender&&u.transceivers[M].rtpSender.setTransport(u.transceivers[0].dtlsTransport),u.transceivers[M].rtpReceiver&&u.transceivers[M].rtpReceiver.setTransport(u.transceivers[0].dtlsTransport)),o.type==="offer"&&!ie){Z=u.transceivers[M]||u._createTransceiver(V),Z.mid=Y,Z.iceGatherer||(Z.iceGatherer=u._createIceGatherer(M,E)),ut.length&&Z.iceTransport.state==="new"&&(Et&&(!E||M===0)?Z.iceTransport.setRemoteCandidates(ut):ut.forEach(function(fe){kp(Z.iceTransport,fe)})),Se=e.RTCRtpReceiver.getCapabilities(V),r<15019&&(Se.codecs=Se.codecs.filter(function(fe){return fe.name!=="rtx"})),be=Z.sendEncodingParameters||[{ssrc:(2*M+2)*1001}];var je=!1;if(J==="sendrecv"||J==="sendonly"){if(je=!Z.rtpReceiver,We=Z.rtpReceiver||new e.RTCRtpReceiver(Z.dtlsTransport,V),je){var te;ge=We.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,We,te])}}else Z.rtpReceiver&&Z.rtpReceiver.track&&(Z.associatedRemoteMediaStreams.forEach(function(fe){var Pt=fe.getTracks().find(function(ze){return ze.id===Z.rtpReceiver.track.id});Pt&&n(Pt,fe)}),Z.associatedRemoteMediaStreams=[]);Z.localCapabilities=Se,Z.remoteCapabilities=$e,Z.rtpReceiver=We,Z.rtcpParameters=Qe,Z.sendEncodingParameters=be,Z.recvEncodingParameters=Te,u._transceive(u.transceivers[M],!1,je)}else if(o.type==="answer"&&!ie){Z=u.transceivers[M],ye=Z.iceGatherer,Re=Z.iceTransport,ae=Z.dtlsTransport,We=Z.rtpReceiver,be=Z.sendEncodingParameters,Se=Z.localCapabilities,u.transceivers[M].recvEncodingParameters=Te,u.transceivers[M].remoteCapabilities=$e,u.transceivers[M].rtcpParameters=Qe,ut.length&&Re.state==="new"&&((h||Et)&&(!E||M===0)?Re.setRemoteCandidates(ut):ut.forEach(function(fe){kp(Z.iceTransport,fe)})),(!E||M===0)&&(Re.state==="new"&&Re.start(ye,De,"controlling"),ae.state==="new"&&ae.start(G));var ur=Ac(Z.localCapabilities,Z.remoteCapabilities),xe=ur.codecs.filter(function(fe){return fe.name.toLowerCase()==="rtx"}).length;!xe&&Z.sendEncodingParameters[0].rtx&&delete Z.sendEncodingParameters[0].rtx,u._transceive(Z,J==="sendrecv"||J==="recvonly",J==="sendrecv"||J==="sendonly"),We&&(J==="sendrecv"||J==="sendonly")?(ge=We.track,L?(l[L.stream]||(l[L.stream]=new e.MediaStream),t(ge,l[L.stream]),f.push([ge,We,l[L.stream]])):(l.default||(l.default=new e.MediaStream),t(ge,l.default),f.push([ge,We,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 M=l[I];if(M.getTracks().length){if(u.remoteStreams.indexOf(M)===-1){u.remoteStreams.push(M);var j=new Event("addstream");j.stream=M,e.setTimeout(function(){u._dispatchEvent("addstream",j)})}f.forEach(function(V){var ie=V[0],oe=V[1];M.id===V[2].id&&i(u,ie,oe,[M])})}}),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(xr("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 x=h.track,I=h.kind,M=h.mid||ht.generateIdentifier();h.mid=M,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 V=h.sendEncodingParameters||[{ssrc:(2*E+1)*1001}];x&&r>=15019&&I==="video"&&!V[0].rtx&&(V[0].rtx={ssrc:V[0].ssrc+1}),h.wantReceive&&(h.rtpReceiver=new e.RTCRtpReceiver(h.dtlsTransport,I)),h.localCapabilities=j,h.sendEncodingParameters=V}),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+=zS(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(x){x.component=1,d+="a="+ht.writeCandidate(x)+`\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(xr("InvalidStateError","Can not call createAnswer after close"));if(!(o.signalingState==="have-remote-offer"||o.signalingState==="have-local-pranswer"))return Promise.reject(xr("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=Ac(d.localCapabilities,d.remoteCapabilities),x=E.codecs.filter(function(I){return I.name.toLowerCase()==="rtx"}).length;!x&&d.sendEncodingParameters[0].rtx&&delete d.sendEncodingParameters[0].rtx,u+=zS(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 x=u.transceivers[h];if(x){if(x.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&&x.iceTransport!==u.transceivers[0].iceTransport)&&!kp(x.iceTransport,I))return d(xr("OperationError","Can not add ICE candidate"));var M=o.candidate.trim();M.indexOf("a=")===0&&(M=M.substr(2)),l=ht.getMediaSections(u._remoteDescription.sdp),l[h]+="a="+(I.type?M:"end-of-candidates")+`\r
|
|
558
|
-
`,u._remoteDescription.sdp=ht.getDescription(u._remoteDescription.sdp)+l.join("")}else return d(xr("OperationError","Can not add ICE candidate"))}else return d(xr("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 xr("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=DX(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 UX=mv(FX);function U1(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 B1(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 Qh(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=UX(e,r.version);e.RTCPeerConnection=function(i){return i&&i.iceServers&&(i.iceServers=LX(i.iceServers,r.version),hg("ICE servers after filtering:",i.iceServers)),new t(i)},e.RTCPeerConnection.prototype=t.prototype}function q1(e){e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)&&(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}const HS=Object.freeze(Object.defineProperty({__proto__:null,shimGetDisplayMedia:B1,shimGetUserMedia:U1,shimPeerConnection:Qh,shimReplaceTrack:q1},Symbol.toStringTag,{value:"Module"}));function G1(e,r){const t=e&&e.navigator,n=e&&e.MediaStreamTrack;if(t.getUserMedia=function(i,a,s){Tf("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 BX(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 V1(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 Zh(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 z1(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 W1(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 H1(e){!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(t){Tf("removeStream","removeTrack"),this.getSenders().forEach(n=>{n.track&&t.getTracks().includes(n.track)&&this.removeTrack(n)})})}function K1(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function J1(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 Y1(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 X1(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 Q1(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 KS=Object.freeze(Object.defineProperty({__proto__:null,shimAddTransceiver:J1,shimCreateAnswer:Q1,shimCreateOffer:X1,shimGetDisplayMedia:BX,shimGetParameters:Y1,shimGetUserMedia:G1,shimOnTrack:V1,shimPeerConnection:Zh,shimRTCDataChannel:K1,shimReceiverGetStats:W1,shimRemoveStream:H1,shimSenderGetStats:z1},Symbol.toStringTag,{value:"Module"}));function Z1(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 e$(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 t$(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 r$(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(n$(i))}!r.getUserMedia&&r.mediaDevices&&r.mediaDevices.getUserMedia&&(r.getUserMedia=function(n,i,a){r.mediaDevices.getUserMedia(n).then(i,a)}.bind(r))}function n$(e){return e&&e.video!==void 0?Object.assign({},e,{video:$1(e.video)}):e}function i$(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")?(Tf("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 a$(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 s$(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 o$(e){typeof e!="object"||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}const JS=Object.freeze(Object.defineProperty({__proto__:null,shimAudioContext:o$,shimCallbacksAPI:t$,shimConstraints:n$,shimCreateOfferLegacy:s$,shimGetUserMedia:r$,shimLocalStreamsAPI:Z1,shimRTCIceServerUrls:i$,shimRemoteStreamsAPI:e$,shimTrackEventTransceiver:a$},Symbol.toStringTag,{value:"Module"}));function Qc(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=Xc.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 Vo(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=Xc.splitSections(c.sdp);return o.shift(),o.some(u=>{const l=Xc.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=Xc.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 zo(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 ev(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 tv(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 Zc(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 qX=Object.freeze(Object.defineProperty({__proto__:null,removeExtmapAllowMixed:tv,shimAddIceCandidateNullOrEmpty:Zc,shimConnectionState:ev,shimMaxMessageSize:Vo,shimRTCIceCandidate:Qc,shimSendThrowTypeError:zo},Symbol.toStringTag,{value:"Module"}));function GX({window:e}={},r={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const t=hg,n=MX(e),i={browserDetails:n,commonShim:qX,extractVersion:Go,disableLog:AX,disableWarnings:xX};switch(n.browser){case"chrome":if(!VS||!Xh||!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=VS,Zc(e,n),O1(e,n),I1(e),Xh(e,n),P1(e),L1(e,n),A1(e),x1(e),M1(e),D1(e,n),Qc(e),ev(e),Vo(e,n),zo(e),tv(e,n);break;case"firefox":if(!KS||!Zh||!r.shimFirefox)return t("Firefox shim is not included in this adapter release."),i;t("adapter.js shimming firefox."),i.browserShim=KS,Zc(e,n),G1(e,n),Zh(e,n),V1(e),H1(e),z1(e),W1(e),K1(e),J1(e),Y1(e),X1(e),Q1(e),Qc(e),ev(e),Vo(e,n),zo(e);break;case"edge":if(!HS||!Qh||!r.shimEdge)return t("MS edge shim is not included in this adapter release."),i;t("adapter.js shimming edge."),i.browserShim=HS,U1(e),B1(e),Qh(e,n),q1(e),Vo(e,n),zo(e);break;case"safari":if(!JS||!r.shimSafari)return t("Safari shim is not included in this adapter release."),i;t("adapter.js shimming safari."),i.browserShim=JS,Zc(e,n),i$(e),s$(e),t$(e),Z1(e),e$(e),a$(e),r$(e),o$(e),Qc(e),Vo(e,n),zo(e),tv(e,n);break;default:t("Unsupported browser!");break}return i}GX({window:typeof window>"u"?void 0:window});var Ki={},u$={},c$={exports:{}},YS=c$.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(YS).forEach(function(e){var r=YS[e];r.forEach(function(t){t.reg||(t.reg=/(.*)/),t.format||(t.format="%s")})});var l$=c$.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=l$,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}})})}})(u$);var Rp=l$,VX=/%[sdv%]/g,zX=function(e){var r=1,t=arguments,n=t.length;return e.replace(VX,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 zX.apply(null,i)},WX=["v","o","s","i","u","e","p","c","b","t","r","z","a"],HX=["i","c","b","a"],KX=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||WX,n=r.innerOrder||HX,i=[];return t.forEach(function(a){Rp[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",Rp.m[0],a)),n.forEach(function(s){Rp[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=u$,JX=KX;Ki.write=JX;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={},YX=Ve&&Ve.__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 f$=function(){function e(r,t,n){this.name=r,this.version=t,this.os=n}return e}();Ji.BrowserInfo=f$;var d$=function(){function e(r){this.version=r,this.name="node",this.os=process.platform}return e}();Ji.NodeInfo=d$;var p$=function(){function e(){this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}();Ji.BotInfo=p$;var XX=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,QX=/(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp)|(MSNBot)|(Ask Jeeves\/Teoma)|(ia_archiver)/,XS=3,ZX=[["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",XX]],QS=[["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",QX]];function eQ(e){return e?rv(e):typeof navigator<"u"?rv(navigator.userAgent):v$()}Ji.detect=eQ;function rv(e){var r=e!==""&&ZX.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 p$;var i=n[1]&&n[1].split(/[._]/).slice(0,3);return i?i.length<XS&&(i=YX(i,tQ(XS-i.length))):i=[],new f$(t,i.join("."),h$(e))}Ji.parseUserAgent=rv;function h$(e){for(var r=0,t=QS.length;r<t;r++){var n=QS[r],i=n[0],a=n[1],s=a.test(e);if(s)return i}return null}Ji.detectOS=h$;function v$(){var e=typeof process<"u"&&process.version;return e?new d$(process.version.slice(1)):null}Ji.getNodeVersion=v$;function tQ(e){for(var r=[],t=0;t<e;t++)r.push("0");return r}var xc={exports:{}};function rQ(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 m$={iterateReports:rQ};const g$={"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"}},nQ={"remote-candidate":function(e){return Mc(e)},"inbound-rtp":function(e){return Mc(e)},"outbound-rtp":function(e){return Mc(e)},"remote-inbound-rtp":function(e){return Mc(e)}},Mc=e=>{const{type:r}=e,t=g$[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 iQ={rules:g$,parsers:nQ};const{iterateReports:aQ}=m$;function sQ(e){let r=0,t=0,n=0,i=100,a=0,s,c,o;return aQ(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 y$=sQ;const{iterateReports:oQ}=m$,{parsers:ZS}=iQ,uQ=y$;function cQ(e){const r={};return oQ(e,t=>{if(t.type in ZS){const n=ZS[t.type](t);Object.assign(r,n)}}),r.networkMos=parseFloat(uQ(e)),r}var lQ=cQ,e0;function fQ(){return e0||(e0=1,function(e,r){var t=Ve&&Ve.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(r,"__esModule",{value:!0});const n=lQ,i=y$,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 x=setInterval(()=>{f.getStats(null).then(I=>{var M;const j=(M=l??this.conversation)!==null&&M!==void 0?M: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(x)}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 x=setInterval(()=>{var I;f.getStats(null).then(M=>{var j;const V=this.getMos(M);if(!V)return;const ie=(j=l??this.conversation)!==null&&j!==void 0?j:null;h&&u.emit("rtcstats:analytics",{type:"mos",mos:V,report:M,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",V,M,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(x)}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}(xc,xc.exports)),xc.exports}var t0;function Cf(){return t0||(t0=1,function(e,r){var t=Ve&&Ve.__createBinding||(Object.create?function(p,h,E,x){x===void 0&&(x=E),Object.defineProperty(p,x,{enumerable:!0,get:function(){return h[E]}})}:function(p,h,E,x){x===void 0&&(x=E),p[x]=h[E]}),n=Ve&&Ve.__setModuleDefault||(Object.create?function(p,h){Object.defineProperty(p,"default",{enumerable:!0,value:h})}:function(p,h){p.default=h}),i=Ve&&Ve.__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=Ve&&Ve.__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(fQ()),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 x=!0;return Object.keys(h).forEach(I=>{E.hasOwnProperty(I)||(x=!1)}),x}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 x=[h.CALL_STATUS.ANSWERED,h.CALL_STATUS.STARTED,h.CALL_STATUS.RINGING];if(!(E.connectionState!=="disconnected"||!h||!h.conversation))return setTimeout(()=>{E.connectionState==="connected"||x.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},x=s.parse(h.localDescription.sdp);return x.media[0].candidates=[E],s.write(x)}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,x,I){const j={sdp:this.createDummyCandidateSDP(E)};let V={from:x.me.id,body:{offer:j}},ie=`conversations/${x.id}/rtc`;return I&&(ie+=`/${I}/offer`),h.session.sendNetworkRequest({type:"POST",path:ie,data:V})}static sendAnswer(h,E,x,I){const M=this.createDummyCandidateSDP(E);let j={from:x.me.id,body:{answer:M}},V=`conversations/${x.id}/rtc/${I}/answer`;return h.session.sendNetworkRequest({type:"POST",path:V,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,x){h.emit("media:stream:on",{pc:E,stream:x,type:"audio",streamIndex:0})}static _initStatsEvents(h){var E,x,I;if(!d.isNode()&&!((I=(x=(E=h==null?void 0:h.application)===null||E===void 0?void 0:E.session)===null||x===void 0?void 0:x.config)===null||I===void 0)&&I.rtcstats){const M=h.application.session.config.rtcstats,{emit_events:j,remote_collection:V,emit_rtc_analytics:ie}=M;if(j||V||ie){const oe={...h,config:{...M}};return new l.default(oe)}}}static attachConversationEventHandlers(h){const{conversation:E,pc:x,log:I}=h;E.once("rtc:answer",M=>{if(!x){I.warn("RTC: received an answer too late");return}x.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:M.body.answer}))})}static doAnswer(h,E,x){const{application:I,conversation:M,pc:j,reject:V,localStream:ie}=h;this.addPeerConnectionListeners(h,()=>d.sendAnswer(I,j,M,x).then(()=>({rtc_id:x}))),j.setRemoteDescription(new RTCSessionDescription({type:"offer",sdp:E})).then(()=>j.createAnswer()).then(oe=>j.setLocalDescription(oe)).catch(oe=>{ie&&this.closeStream(ie),V(oe)})}static attachPeerConnectionEventHandlers(h){const{application:E,conversation:x,pc:I,reconnectRtcId:M}=h;this.addPeerConnectionListeners(h,()=>d.sendOffer(E,I,x,M))}static addPeerConnectionListeners(h,E){const{application:x,conversation:I,pc:M,streamIndex:j,localStream:V,log:ie,rtcObjects:oe,resolve:J,reject:L}=h;let Y,Z=!1,ye;I.id&&(ye=x.calls.get(I.id)),M.ontrack=Re=>{Y=Re.streams[0],x.activeStreams.push(Y),d.emitMediaStream(I.me,M,Y)},M.onconnectionstatechange=Re=>this.onconnectionstatechangeHandler(M,ie,ye,()=>J(Y),()=>L()),M.onnegotiationneeded=()=>this.onnegotiationneededHandler(M,Re=>L(Re)),M.oniceconnectionstatechange=Re=>this.oniceconnectionstatechange(Re,M,ie,ae=>L(ae)),M.onicecandidate=async Re=>{if(Re.candidate&&!Z&&M){Z=!0;try{const{rtc_id:ae}=await E();d._initStatsEvents({application:x,rtc_id:ae,pc:M,conversation:I}),M.trace&&M.trace("rtc_id",ae),oe[ae]={rtc_id:ae,pc:M,stream:V,type:"audio",streamIndex:j}}catch(ae){V&&this.closeStream(V),L(new u.NexmoClientError(ae))}}},V.getTracks().forEach(Re=>M.addTrack(Re))}static prewarmLeg(h){const E=h.application;return new Promise(async(x,I)=>{let M=!1,j,V,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,()=>x({stream:j,legId:V,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&&!M&&L){M=!0;const{rtc_id:Z,sdp:ye}=await this.createLeg(E,L);return d._initStatsEvents({application:E,rtc_id:Z,pc:L}),V=Z,ie[V]={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,x,I)=>{switch(p.connectionState){case"connected":h.info("The connection has become fully connected"),x();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,x)=>{switch(h.iceConnectionState){case"disconnected":E.warn("One or more transports is disconnected",h.iceConnectionState);break;case"failed":x(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}(Pc,Pc.exports)),Pc.exports}var r0;function dQ(){return r0||(r0=1,function(e,r){var t=Ve&&Ve.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(r,"__esModule",{value:!0});const n=pr,i=In,a=t(Cf()),s=t(pi()),c=t(Hi),o=t(w$()),u=t(kf());class l{constructor(d){var p,h,E;const x=d instanceof o.default?d:null,I=d instanceof u.default?d:null;this.log=n.getLogger(this.constructor.name),x?(this.rtcHelper=new a.default,this.application=x.application,this.application.activeStreams=this.application.activeStreams||[],this.parentConversation=x,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 x=this.streamIndex;this.streamIndex++;const{audioConstraints:I}=d;try{const M=await a.default.getUserAudio(I),j=a.default.createPeerConnection(this.application);this.pc=j;const{application:V,log:ie,parentConversation:oe,rtcObjects:J}=this,L={pc:j,streamIndex:x,localStream:M,application:V,conversation:oe,log:ie,rtcObjects:J};p({...L,resolve:h,reject:E}),a.default.attachConversationEventHandlers(L),this._attachEndingEventHandlers()}catch(M){E(new i.NexmoClientError(M))}})}_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,x)=>{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){x(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(x){throw this._enableMediaTracks(p,h),new i.NexmoApiError(x)}}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 x=p.pc.getSenders().find(I=>I.track.kind===E.kind);x&&(E.enabled=x.track.enabled,x.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 x=[],I={};if(p!==null){if(I[0]=Object.values(this.rtcObjects).find(M=>M.streamIndex===p),!I[0])throw new i.NexmoClientError("error:media:stream:not-found")}else I=this.rtcObjects;return Object.values(I).forEach(M=>{const j=M.stream.getAudioTracks(),V=this._setMediaTracksAndMute(M.rtc_id,j,d,E);x.push(V)}),Promise.all(x)}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}}}}),x={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,x);return this.parentConversation.events.set(x.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}(Ic,Ic.exports)),Ic.exports}var Nc={exports:{}},Lc={exports:{}},n0;function b$(){return n0||(n0=1,function(e,r){var t=Ve&&Ve.__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}(Lc,Lc.exports)),Lc.exports}var i0;function pQ(){return i0||(i0=1,function(e,r){var t=Ve&&Ve.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(r,"__esModule",{value:!0});const n=pr,i=t(Hi),a=t(dg),s=t(b$()),c=t(pg());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}(Nc,Nc.exports)),Nc.exports}var nv={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})(nv,nv.exports);var _$=nv.exports,Dc={exports:{}},iv={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})(iv,iv.exports);var Ef=iv.exports,a0;function hQ(){return a0||(a0=1,function(e,r){var t=Ve&&Ve.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(Ef),i=t(Hi),a=t(dg),s=t(b$()),c=t(pg());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}(Dc,Dc.exports)),Dc.exports}var jc={exports:{}},s0;function vQ(){return s0||(s0=1,function(e,r){var t=Ve&&Ve.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(Ef),i=t(fg());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}(jc,jc.exports)),jc.exports}var o0;function w$(){return o0||(o0=1,function(e,r){var t=Ve&&Ve.__importDefault||function(M){return M&&M.__esModule?M:{default:M}};Object.defineProperty(r,"__esModule",{value:!0});const n=Ra,i=pr,a=In,s=t(fg()),c=t(Hi),o=t(dg),u=t(pg()),l=t(dQ()),f=t(pQ()),d=t(pi()),p=t(_$),h=t(hQ()),E=t(vQ()),x=t(kf());class I{constructor(j,V){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(V),n.mixin(I)}_updateObjectInstance(j){for(let V in j)switch(V){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 V,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}}};!((V=this===null||this===void 0?void 0:this.me)===null||V===void 0)&&V.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,x.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 V,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"}};!((V=this===null||this===void 0?void 0:this.me)===null||V===void 0)&&V.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 V={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:V});return V.id=ie,V.body.timestamp=oe,new o.default(this,V)}catch(V){throw new a.NexmoApiError(V)}}async sendCustomEvent({type:j,body:V}){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:V},{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,V={quality_ratio:"100",medium_size_ratio:"50",thumbnail_size_ratio:"30"}){const ie=new FormData;ie.append("file",j),ie.append("quality_ratio",V.quality_ratio),ie.append("medium_size_ratio",V.medium_size_ratio),ie.append("thumbnail_size_ratio",V.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,V={quality_ratio:"100",medium_size_ratio:"50",thumbnail_size_ratio:"30"}){const ie=await this.uploadImage(j,V);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 V={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:V});return V.id=ie,V.body.timestamp=oe,new u.default(this,V)}catch(V){throw new a.NexmoApiError(V)}}async _typing(j){const V={activity:j==="on"?1:0},ie={type:"text:typing:"+j,cid:this.id,from:this.me.id,body:V};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 V=`${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(V,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 V=`${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(V,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 V=await this.application.session.sendNetworkRequest({type:"GET",path:`conversations/${this.id}/members/${j}`,version:"v0.3"});return new s.default(this,V)}catch(V){throw new a.NexmoApiError(V)}}_handleEvent(j){var V,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(!((V=j==null?void 0:j.body)===null||V===void 0)&&V.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}(Rc,Rc.exports)),Rc.exports}var Fc={exports:{}},u0;function S$(){return u0||(u0=1,function(e,r){var t=Ve&&Ve.__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(Cf());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 x={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(x);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}(Fc,Fc.exports)),Fc.exports}var av={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})(av,av.exports);var mQ=av.exports,sv={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})(sv,sv.exports);var gQ=sv.exports,Uc={exports:{}},c0;function yQ(){return c0||(c0=1,function(e,r){var t=Ve&&Ve.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(r,"__esModule",{value:!0});const n=pr,i=t(Hi),a=t(S$()),s=t(pi()),c=t(Cf());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,x,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 M=s.default.getMemberNumberFromEventOrNull(f.body.channel)||s.default.getMemberFromNameOrNull(l,f.body.invited_by)||"unknown",j=new a.default(this.application,l,M);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}),!((x=l.display_name)===null||x===void 0)&&x.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(M){this.log.error("_processMemberInvited: ",{e:M})}}}r.default=o,e.exports=o}(Uc,Uc.exports)),Uc.exports}var ov={exports:{}};(function(e,r){var t=Ve&&Ve.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(Ef);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})(ov,ov.exports);var bQ=ov.exports,uv={exports:{}},cv={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})(cv,cv.exports);var _Q=cv.exports;(function(e,r){var t=Ve&&Ve.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(Ef),i=t(_Q);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})(uv,uv.exports);var wQ=uv.exports,Bc={exports:{}},l0;function SQ(){return l0||(l0=1,function(e,r){var t=Ve&&Ve.__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:x}=u,I=Number(x);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 V=I-20<1?1:I-20,ie=await j.fetchConversationEvents(V,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 M=this.cidMap.get(E);M.enqueue(I,u),M.processing||(M.processing=!0,await M.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}}(Bc,Bc.exports)),Bc.exports}var f0;function kf(){return f0||(f0=1,function(e,r){var t=Ve&&Ve.__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(E1),c=t(w$()),o=t(S$()),u=t(mQ),l=t(gQ),f=t(yQ()),d=t(pi()),p=t(_$),h=t(bQ),E=t(wQ),x=SQ(),I=t(fg());let M=null,j=null,V=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=[],M=new u.default(this),j=new l.default(this),V=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 x.EventsQueue(L=>this._handleEvent(L))),this.eventsQueue.enqueue(J,this)):this._handleEvent(J)}async _handleEvent(J){var L,Y,Z,ye,Re,ae,We;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)===((We=this.me)===null||We===void 0?void 0:We.id),Te=d.default._checkIfUserIsReInvited(this.conversations,J);if(J.type.startsWith("sip"))return M._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 Se;return d.default._isCallEvent(J)?Se=await this.getConversation(J.cid,ie.CONVERSATION_API_VERSION.v1):Se=await this.getConversation(J.cid,ie.CONVERSATION_API_VERSION.v3),this.conversations.set(J.cid,Se),await Se._handleEvent(J),await this._handleApplicationEvent(J),J.type.startsWith("rtc")&&j._handleRtcEvent(J),Promise.resolve(J)}catch(Se){return this.log.error(Se),Promise.reject(Se)}}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=V.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}(kc,kc.exports)),kc.exports}var d0;function pi(){return d0||(d0=1,function(e,r){var t=Ve&&Ve.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(PX),i=t(b1),a=t(kf()),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:x,_links:I}=h.response,M=l.split("/").pop().trim();return{items:p===a.default.CONVERSATION_API_VERSION.v1?x.data[M]:x[M],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 x;for(x=0;x<p.length/E;x++)h+=String.fromCharCode.apply(null,p.subarray(x*E,(x+1)*E));return h+=String.fromCharCode.apply(null,p.subarray(x*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),x=Date.now(),I=i.default.connect(l,E),M=setTimeout(()=>p({url:l,canConnect:!1}),c);I.on("connect",()=>{const j=Date.now()-x;I.disconnect(),clearTimeout(M),p({url:l,canConnect:!0,connectionTime:j})}),I.on("error",j=>{I.disconnect(),clearTimeout(M),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),x=Date.now(),I=await E.createOffer({offerToReceiveAudio:!0});E.setLocalDescription(I);const M=setTimeout(()=>{E.close(),d({ip:l,canConnect:!1})},s);E.onicecandidate=({candidate:j})=>{if((j==null?void 0:j.type)==="srflx"){const V=Date.now()-x;clearTimeout(M),E.close(),d({ip:l,canConnect:!0,connectionTime:V})}},E.onicecandidateerror=j=>{j.errorCode&&(E.close(),clearTimeout(M),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}(Cc,Cc.exports)),Cc.exports}var lv={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})(lv,lv.exports);var TQ=lv.exports;(function(e,r){var t=Ve&&Ve.__importDefault||function(x){return x&&x.__esModule?x:{default:x}};Object.defineProperty(r,"__esModule",{value:!0});const n=Ra,i=t(_J),a=t(pr),s=In,c=t(b1),o=t(hX),u=t(_X),l=t(pi()),f=t(kf()),d=t(TQ),p=t(E1),h=t(Cf());i.default.reg(a.default),i.default.apply(a.default,{template:"[%t] %l (NXM-%n):",timestampFormatter:x=>x.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),levelFormatter:x=>x.toUpperCase(),nameFormatter:x=>x||"SDK"});class E{constructor(I={}){const M=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(M.debug)?a.default.setLevel(M.debug):M.debug===!0?a.default.setLevel("debug"):a.default.setLevel("silent"),this.log=a.default.noConflict(),this.config=l.default.deepMergeObj(this.config,this._sanitizeConfig(M)),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};Ve.NXMbugsnagClient=o.default(j)}n.mixin(E)}_createAndSetConnection(){let I,M=Object.assign({path:this.config.path},this.config.socket_io);return I=c.default.connect(this.config.url,M),this.connection=I,I.on("connect",()=>{this.emit("ready"),this.sessionReady=!0,this.log.info("websocket ready")}),I.on("disconnect",(j,V)=>{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,V)}),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(V=>{this.log.warn("Failed to publish socket reconnection metrics",V)})}),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 V=j.data[2];V&&typeof V=="function"&&V();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 M=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}`),M.sync=this.config.sync),M}sendRequest(I,M){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:M}}async sendNetworkRequest(I){const M=I.version||"beta",j=`${this.config.nexmo_api_url}/${M}/${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 V={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:V});const{response:ie}=await l.default.networkRequest(V);return ie}catch({response:V}){throw V}}createSession(I){return this.config.socket_io.query.token=I,this._createAndSetConnection(),new Promise((M,j)=>{this.log.info(`Client-SDK Version: ${this.config.SDK_version}`),this.config.token=null,this.requests["session:login"]={type:"session:login",callback:async V=>{if(V.type==="session:success")if(this.session_id=V.body.id,this.apiKey=V.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!==V.body.user_id)&&(this.application=new f.default(this,{})),this.application.me||(this.application.me=new p.default(this.application,{id:V.body.user_id,name:V.body.name})),this.errorsEmitter||(this.errorsEmitter=new d.default(this.application)),this.config.log_reporter.enabled&&(Ve.NXMbugsnagClient.user={id:this.application.me.id,name:this.application.me.name,session_id:V.body.id}),this.config.sync!=="none")try{await this.application.getConversations(),M(this.application)}catch(ie){j(ie)}else M(this.application);else j(new s.NexmoApiError(V))}}})}deleteSession(){return new Promise(async(I,M)=>{const j=()=>this.sendRequest({type:"session:logout",body:{}},V=>{V.type==="session:logged-out"||V.type==="session:terminated"?(this.disconnect(),delete this.errorsEmitter,delete this.application,delete this.connection,this.requests={},this.sessionReady=!1,I(V)):M(V)});if(this.application){let V=[];if(this.application.conversations.size)for(let ie of this.application.conversations.values())V.push(ie.media.disable());try{await Promise.all(V)}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,M){const V={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;M!=null&&M.dcListCallback&&(oe=M.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),We={name:J,signalConnectionReport:{https:ye,ws:Re},mediaConnectionReport:ae};V.connectivityReport.push(We)}catch(ye){this.log.error(`Error generating report for ${J}`,ye)}}}catch(ie){this.log.error("Error fetching nexmo servers information",ie)}return V}async checkMediaServers(I,M,j){return await l.default._checkMediaServers(I,M,j)}async checkMediaConnectivity(I,M){return await l.default._checkMediaConnectivity(I,M)}}r.default=E,E.DISCONNECT_REASON={ClientDisconnected:"ClientDisconnected",TokenExpired:"TokenExpired",ConnectionError:"ConnectionError"},e.exports=E})(jh,jh.exports);var CQ=jh.exports;const EQ=mv(CQ),Ti=new ts("nexmo-chat"),kQ=["us-3","us-4","eu-3","eu-4","ap-3","ap-4"];class T$ extends pv{constructor(){super(...arguments);bt(this,"rtc");bt(this,"application");bt(this,"conversation")}get _client(){if(this.rtc)return this.rtc;const t=RQ(this.region);return this.rtc=new EQ({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=p0(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=p0(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(T$,"type","nexmo_conversations");hv(T$);function RQ(e){return kQ.indexOf(e)>-1?"vonage.com":"nexmo.com"}function p0(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=AO;exports.ENVIRONMENT=R$;exports.EventManager=dv;exports.Logger=ts;exports.MediaStore=m0;exports.OPTIONS=Or;exports.VERSION=h0;exports.addProviderType=hv;exports.consoleLoggerHandler=I$;exports.formatLogData=v0;exports.newrelicLoggerHandler=P$;
|