@formant/data-sdk 1.33.1 → 1.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-sdk.cjs.js +1 -1
- package/dist/data-sdk.cjs.js.map +1 -1
- package/dist/data-sdk.es.js +2 -2
- package/dist/data-sdk.es.js.map +1 -1
- package/dist/data-sdk.es6.js +2 -2
- package/dist/data-sdk.umd.js +1 -1
- package/dist/types/data-sdk/src/stores/AuthenticationStore.d.ts +1 -1
- package/dist/types/data-sdk/src/stores/IAuthenticationStore.d.ts +1 -1
- package/package.json +1 -1
package/dist/data-sdk.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Rn=Object.defineProperty;var Bn=(e,t,n)=>t in e?Rn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Fe=(e,t,n)=>(Bn(e,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const require$$0=require("google-protobuf"),require$$1=require("google-protobuf/google/protobuf/wrappers_pb.js"),DEFAULT_FORMANT_API_URL="https://api.formant.io";function whichFormantApiUrl(e,t){try{if(t.get("formant_stage"))return"https://api-stage.formant.io";if(t.get("formant_dev"))return"https://api-dev.formant.io";if(t.get("formant_local"))return"https://api.formant.local";if(t.get("formant_url")){const n=t.get("formant_url");if(n!==null)try{return new URL(n).origin}catch{console.warn(`Ignoring malformed \`formant_url\` url parameter: ${n}`)}}}catch{}return typeof e!="undefined"&&"FORMANT_API_URL"in e&&typeof e.FORMANT_API_URL=="string"?e.FORMANT_API_URL:DEFAULT_FORMANT_API_URL}const FORMANT_API_URL=whichFormantApiUrl(typeof window!="undefined"?window:globalThis,new URLSearchParams(typeof window!="undefined"&&window.location?window.location.search:void 0));var commonjsGlobal=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var base64={exports:{}};/*! https://mths.be/base64 v1.0.0 by @mathias | MIT license */base64.exports;(function(e,t){(function(n){var r=t,l=e&&e.exports==r&&e,s=typeof commonjsGlobal=="object"&&commonjsGlobal;(s.global===s||s.window===s)&&(n=s);var c=function(g){this.message=g};c.prototype=new Error,c.prototype.name="InvalidCharacterError";var o=function(g){throw new c(g)},d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=/[\t\n\f\r ]/g,U=function(g){g=String(g).replace(u,"");var h=g.length;h%4==0&&(g=g.replace(/==?$/,""),h=g.length),(h%4==1||/[^+a-zA-Z0-9/]/.test(g))&&o("Invalid character: the string to be decoded is not correctly encoded.");for(var m=0,N,D,y="",b=-1;++b<h;)D=d.indexOf(g.charAt(b)),N=m%4?N*64+D:D,m++%4&&(y+=String.fromCharCode(255&N>>(-2*m&6)));return y},B=function(g){g=String(g),/[^\0-\xFF]/.test(g)&&o("The string to be encoded contains characters outside of the Latin1 range.");for(var h=g.length%3,m="",N=-1,D,y,b,F,v=g.length-h;++N<v;)D=g.charCodeAt(N)<<16,y=g.charCodeAt(++N)<<8,b=g.charCodeAt(++N),F=D+y+b,m+=d.charAt(F>>18&63)+d.charAt(F>>12&63)+d.charAt(F>>6&63)+d.charAt(F&63);return h==2?(D=g.charCodeAt(N)<<8,y=g.charCodeAt(++N),F=D+y,m+=d.charAt(F>>10)+d.charAt(F>>4&63)+d.charAt(F<<2&63)+"="):h==1&&(F=g.charCodeAt(N),m+=d.charAt(F>>2)+d.charAt(F<<4&63)+"=="),m},R={encode:B,decode:U,version:"1.0.0"};if(r&&!r.nodeType)if(l)l.exports=R;else for(var p in R)R.hasOwnProperty(p)&&(r[p]=R[p]);else n.base64=R})(commonjsGlobal)})(base64,base64.exports);var base64Exports=base64.exports;class LoginFailureError extends Error{constructor(n){super("login failed");Fe(this,"reason");this.reason=n,this.name="LoginFailureError",Object.setPrototypeOf(this,new.target.prototype)}}class LoginChallengedError extends Error{constructor(n){super("login challenged");Fe(this,"challenge");this.challenge=n,this.name="LoginChallengedError",Object.setPrototypeOf(this,new.target.prototype)}}class AuthenticationStore{constructor({apiUrl:t,refreshAuthToken:n,addAccessTokenRefreshListener:r}){Fe(this,"_refreshToken");Fe(this,"_isShareToken",!1);Fe(this,"_currentOrganization");Fe(this,"_currentUser");Fe(this,"_defaultDeviceId");Fe(this,"_token");Fe(this,"_waitingForAuth",new Set);Fe(this,"_refreshTimer");Fe(this,"_apiUrl");Fe(this,"_refreshAuthToken");Fe(this,"_addAccessTokenRefreshListener");this._apiUrl=t,this._refreshAuthToken=n,this._addAccessTokenRefreshListener=r}get token(){return this._token}get currentUser(){return this._currentUser}get currentOrganization(){return this._currentOrganization}get defaultDeviceId(){return this._defaultDeviceId}get refreshToken(){return this._refreshToken}get isShareToken(){return this._isShareToken}async login(t,n,r={}){const{advanced:l=!1}=r;try{const s=await fetch(`${this._apiUrl}/v1/admin/auth/login`,{method:"POST",body:JSON.stringify({email:t,password:n}),headers:{"Content-Type":"application/json"}}),c=await s.json();if(s.status!==200)throw new LoginFailureError(c.message);if("challenge"in c)throw new LoginChallengedError(c.challenge);const{authentication:o}=c;return await this.loginWithToken(o.accessToken,o.refreshToken),l?{result:"success",authentication:o}:o}catch(s){if(l||console.error("login() failed",{err:s}),this._waitingForAuth.forEach(c=>c(!1)),this._waitingForAuth.clear(),!l)throw s;return s instanceof LoginChallengedError?{result:"challenged",challenge:s.challenge}:{result:"failure",reason:s instanceof LoginFailureError?s.reason:s instanceof Error?s.message:String(s)}}}async loginWithToken(t,n){var l;const r=JSON.parse(base64Exports.decode(t.split(".")[1]));try{let s;if(this._isShareToken=r["formant:claims"]&&r["formant:claims"].type=="share",r["formant:claims"]&&(this._currentOrganization=r["formant:claims"].organizationId),r["custom:organization_id"]&&(this._currentOrganization=r["custom:organization_id"]),this._isShareToken||(s=r.sub),r["formant:claims"]&&r["formant:claims"].userId&&(s=r["formant:claims"].userId),s&&((l=this._currentUser)==null?void 0:l.id)!==s){const c=await fetch(`${this._apiUrl}/v1/admin/users/${s}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+t}}),o=await c.json();if(c.status!==200)throw new Error(o.message);this._currentUser=o}this._token=t,this._waitingForAuth.forEach(c=>c(!0))}catch(s){console.error("loginWithToken() failed",{err:s}),this._waitingForAuth.forEach(c=>c(!1))}finally{this._waitingForAuth.clear()}n&&(this._refreshToken=n,setInterval(async()=>{if(this._refreshToken){const c=await(await fetch(`${this._apiUrl}/v1/admin/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:this._refreshToken})})).json();this._token=c.authentication.accessToken}},1e3*60*60))}isAuthenticated(){return this._token!==void 0}async loginToPeer(t,n){if((await fetch(`${t}/login`,{method:"POST",body:JSON.stringify({password:n}),headers:{"Content-Type":"application/json"}})).status!==200)throw new LoginFailureError("Invalid authentication")}getCurrentUser(){return this._currentUser}async waitTilAuthenticated(){return this.token!==void 0?!0:new Promise(t=>{this._waitingForAuth.add(t)})}async listenForRefresh(){const n=()=>{this._refreshTimer=void 0,this._refreshAuthToken()};this._addAccessTokenRefreshListener(r=>{this._refreshTimer&&clearTimeout(this._refreshTimer),this._refreshTimer=setTimeout(n,36e5),this.loginWithToken(r)}),this._refreshTimer=setTimeout(n,36e5)}async forgotPassword(t){await fetch(`${this._apiUrl}/v1/admin/auth/forgot-password`,{method:"POST",body:JSON.stringify({email:t}),headers:{"Content-Type":"application/json"}})}async confirmForgotPassword(t){return(await fetch(`${this._apiUrl}/v1/admin/auth/confirm-forgot-password`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})).ok}async respondToNewPasswordRequiredChallenge(t){const n=await fetch(`${this._apiUrl}/v1/admin/auth/respond-to-new-password-required-challenge`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}});if(n.ok)return await n.json();throw new Error("respond-to-new-password-required-challenge failed")}async loginWithGoogle(t){return await(await fetch(`${this._apiUrl}/v1/admin/auth/login-google`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})).json()}async refresh(t){const r=await(await fetch(`${this._apiUrl}/v1/admin/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t})})).json();await this.loginWithToken(r.authentication.accessToken,t)}async checkSso(t,n){return await(await fetch(`${this._apiUrl}/v1/admin/auth/check-sso`,{method:"POST",body:JSON.stringify({email:t,allowUserAutoCreation:n}),headers:{"Content-Type":"application/json"}})).json()}async loginWithSso(t,n){const l=await(await fetch(`${this._apiUrl}/v1/admin/auth/login-sso`,{method:"POST",body:JSON.stringify({token:t,refreshToken:n}),headers:{"Content-Type":"application/json"}})).json();if(!l.authentication)throw new Error("Failed to login with SSO");return await this.loginWithToken(l.authentication.accessToken,l.authentication.refreshToken)}}function getCurrentModuleContext(){return typeof window!="undefined"&&window.location?new URLSearchParams(window.location.search).get("module"):null}function sendAppMessage(e){if(!(window&&window.parent))throw new Error("cannot send message to non-existent parent");window.parent.postMessage(e,"*")}function refreshAuthToken(){const e=getCurrentModuleContext();if(!e)throw new Error("No module context");sendAppMessage({type:"refresh_auth_token",module:e})}function addAccessTokenRefreshListener(e){function t(n){const r=n.data;r.type==="auth_token"&&e(r.token)}return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}}const Authentication=new AuthenticationStore({apiUrl:FORMANT_API_URL,refreshAuthToken,addAccessTokenRefreshListener});async function getModuleConfiguration(e){return(await(await fetch(`${FORMANT_API_URL}/v1/admin/module-configurations/${e}`,{headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).configuration}function disableAnalyticsBottomBar(){sendAppMessage({type:"hide_analytics_date_picker"})}function goToDevice(e){sendAppMessage({type:"go_to_device",deviceId:e})}function goToTime(e){sendAppMessage({type:"go_to_time",time:e.getTime()})}function requestModuleData(){const e=getCurrentModuleContext();if(!e)throw new Error("No module context");sendAppMessage({type:"request_module_data",module:e})}function sendChannelData(e,t){const n=getCurrentModuleContext();if(!n)throw new Error("No module context");sendAppMessage({type:"send_channel_data",source:n,channel:e,data:t})}function setModuleDateTimeRange(e,t){const n=getCurrentModuleContext();if(!n)throw new Error("No module context");sendAppMessage({type:"set_module_data_time_range",module:n,before:e,after:t||0})}function setupModuleMenus(e){const t=getCurrentModuleContext();if(!t)throw new Error("No module context");sendAppMessage({type:"setup_module_menus",module:t,menus:e})}function showMessage(e){sendAppMessage({type:"show_message",message:e})}function addChannelDataListener(e,t){const n=r=>{const l=r.data;l.type==="channel_data"&&l.channel===e&&t({source:l.source,data:l.data})};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)}function addMenuListener(e){const t=n=>{const r=n.data;r.type==="module_menu_item_clicked"&&e(r.menu)};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}function addModuleConfigurationListener(e){const t=n=>{const r=n.data;r.type==="module_configuration"&&e(r)};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}function addModuleDataListener(e){const t=getCurrentModuleContext();t&&sendAppMessage({type:"request_module_data",module:t});const n=r=>{const l=r.data;l.type==="module_data"&&e({streams:l.streams,time:l.time,queryRange:l.queryRange})};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)}function addOverviewDeviceListener(e){sendAppMessage({type:"request_devices"});const t=n=>{const r=n.data;r.type==="overview_devices"&&e(r.data)};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}function _typeof(e){return _typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(e)}function toInteger(e){if(e===null||e===!0||e===!1)return NaN;var t=Number(e);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}function requiredArgs(e,t){if(t.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+t.length+" present")}function toDate(e){requiredArgs(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||_typeof(e)==="object"&&t==="[object Date]"?new Date(e.getTime()):typeof e=="number"||t==="[object Number]"?new Date(e):((typeof e=="string"||t==="[object String]")&&typeof console!="undefined"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}function addDays(e,t){requiredArgs(2,arguments);var n=toDate(e),r=toInteger(t);return isNaN(r)?new Date(NaN):(r&&n.setDate(n.getDate()+r),n)}function addMonths(e,t){requiredArgs(2,arguments);var n=toDate(e),r=toInteger(t);if(isNaN(r))return new Date(NaN);if(!r)return n;var l=n.getDate(),s=new Date(n.getTime());s.setMonth(n.getMonth()+r+1,0);var c=s.getDate();return l>=c?s:(n.setFullYear(s.getFullYear(),s.getMonth(),l),n)}function addMilliseconds(e,t){requiredArgs(2,arguments);var n=toDate(e).getTime(),r=toInteger(t);return new Date(n+r)}var MILLISECONDS_IN_HOUR=36e5;function addHours(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMilliseconds(e,n*MILLISECONDS_IN_HOUR)}var defaultOptions={};function getDefaultOptions(){return defaultOptions}function startOfWeek(e,t){var n,r,l,s,c,o,d,u;requiredArgs(1,arguments);var U=getDefaultOptions(),B=toInteger((n=(r=(l=(s=t==null?void 0:t.weekStartsOn)!==null&&s!==void 0?s:t==null||(c=t.locale)===null||c===void 0||(o=c.options)===null||o===void 0?void 0:o.weekStartsOn)!==null&&l!==void 0?l:U.weekStartsOn)!==null&&r!==void 0?r:(d=U.locale)===null||d===void 0||(u=d.options)===null||u===void 0?void 0:u.weekStartsOn)!==null&&n!==void 0?n:0);if(!(B>=0&&B<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var R=toDate(e),p=R.getDay(),g=(p<B?7:0)+p-B;return R.setDate(R.getDate()-g),R.setHours(0,0,0,0),R}function startOfDay(e){requiredArgs(1,arguments);var t=toDate(e);return t.setHours(0,0,0,0),t}var MILLISECONDS_IN_MINUTE=6e4;function addMinutes(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMilliseconds(e,n*MILLISECONDS_IN_MINUTE)}function addQuarters(e,t){requiredArgs(2,arguments);var n=toInteger(t),r=n*3;return addMonths(e,r)}function addSeconds(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMilliseconds(e,n*1e3)}function addWeeks(e,t){requiredArgs(2,arguments);var n=toInteger(t),r=n*7;return addDays(e,r)}function addYears(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMonths(e,n*12)}function getQuarter(e){requiredArgs(1,arguments);var t=toDate(e),n=Math.floor(t.getMonth()/3)+1;return n}var roundingMap={ceil:Math.ceil,round:Math.round,floor:Math.floor,trunc:function(t){return t<0?Math.ceil(t):Math.floor(t)}},defaultRoundingMethod="trunc";function getRoundingMethod(e){return e?roundingMap[e]:roundingMap[defaultRoundingMethod]}function endOfDay(e){requiredArgs(1,arguments);var t=toDate(e);return t.setHours(23,59,59,999),t}function endOfMonth(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function eachDayOfInterval(e,t){var n;requiredArgs(1,arguments);var r=e||{},l=toDate(r.start),s=toDate(r.end),c=s.getTime();if(!(l.getTime()<=c))throw new RangeError("Invalid interval");var o=[],d=l;d.setHours(0,0,0,0);var u=Number((n=t==null?void 0:t.step)!==null&&n!==void 0?n:1);if(u<1||isNaN(u))throw new RangeError("`options.step` must be a number greater than 1");for(;d.getTime()<=c;)o.push(toDate(d)),d.setDate(d.getDate()+u),d.setHours(0,0,0,0);return o}function eachHourOfInterval(e,t){var n;requiredArgs(1,arguments);var r=e||{},l=toDate(r.start),s=toDate(r.end),c=l.getTime(),o=s.getTime();if(!(c<=o))throw new RangeError("Invalid interval");var d=[],u=l;u.setMinutes(0,0,0);var U=Number((n=t==null?void 0:t.step)!==null&&n!==void 0?n:1);if(U<1||isNaN(U))throw new RangeError("`options.step` must be a number greater than 1");for(;u.getTime()<=o;)d.push(toDate(u)),u=addHours(u,U);return d}function startOfMinute(e){requiredArgs(1,arguments);var t=toDate(e);return t.setSeconds(0,0),t}function eachMinuteOfInterval(e,t){var n;requiredArgs(1,arguments);var r=startOfMinute(toDate(e.start)),l=toDate(e.end),s=r.getTime(),c=l.getTime();if(s>=c)throw new RangeError("Invalid interval");var o=[],d=r,u=Number((n=t==null?void 0:t.step)!==null&&n!==void 0?n:1);if(u<1||isNaN(u))throw new RangeError("`options.step` must be a number equal to or greater than 1");for(;d.getTime()<=c;)o.push(toDate(d)),d=addMinutes(d,u);return o}function eachMonthOfInterval(e){requiredArgs(1,arguments);var t=e||{},n=toDate(t.start),r=toDate(t.end),l=r.getTime(),s=[];if(!(n.getTime()<=l))throw new RangeError("Invalid interval");var c=n;for(c.setHours(0,0,0,0),c.setDate(1);c.getTime()<=l;)s.push(toDate(c)),c.setMonth(c.getMonth()+1);return s}function startOfQuarter(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getMonth(),r=n-n%3;return t.setMonth(r,1),t.setHours(0,0,0,0),t}function eachQuarterOfInterval(e){requiredArgs(1,arguments);var t=e||{},n=toDate(t.start),r=toDate(t.end),l=r.getTime();if(!(n.getTime()<=l))throw new RangeError("Invalid interval");var s=startOfQuarter(n),c=startOfQuarter(r);l=c.getTime();for(var o=[],d=s;d.getTime()<=l;)o.push(toDate(d)),d=addQuarters(d,1);return o}function eachWeekOfInterval(e,t){requiredArgs(1,arguments);var n=e||{},r=toDate(n.start),l=toDate(n.end),s=l.getTime();if(!(r.getTime()<=s))throw new RangeError("Invalid interval");var c=startOfWeek(r,t),o=startOfWeek(l,t);c.setHours(15),o.setHours(15),s=o.getTime();for(var d=[],u=c;u.getTime()<=s;)u.setHours(0),d.push(toDate(u)),u=addWeeks(u,1),u.setHours(15);return d}function startOfMonth(e){requiredArgs(1,arguments);var t=toDate(e);return t.setDate(1),t.setHours(0,0,0,0),t}function endOfYear(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getFullYear();return t.setFullYear(n+1,0,0),t.setHours(23,59,59,999),t}function startOfYear(e){requiredArgs(1,arguments);var t=toDate(e),n=new Date(0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n}function eachYearOfInterval(e){requiredArgs(1,arguments);var t=e||{},n=toDate(t.start),r=toDate(t.end),l=r.getTime();if(!(n.getTime()<=l))throw new RangeError("Invalid interval");var s=[],c=n;for(c.setHours(0,0,0,0),c.setMonth(0,1);c.getTime()<=l;)s.push(toDate(c)),c.setFullYear(c.getFullYear()+1);return s}function endOfHour(e){requiredArgs(1,arguments);var t=toDate(e);return t.setMinutes(59,59,999),t}function endOfWeek(e,t){var n,r,l,s,c,o,d,u;requiredArgs(1,arguments);var U=getDefaultOptions(),B=toInteger((n=(r=(l=(s=t==null?void 0:t.weekStartsOn)!==null&&s!==void 0?s:t==null||(c=t.locale)===null||c===void 0||(o=c.options)===null||o===void 0?void 0:o.weekStartsOn)!==null&&l!==void 0?l:U.weekStartsOn)!==null&&r!==void 0?r:(d=U.locale)===null||d===void 0||(u=d.options)===null||u===void 0?void 0:u.weekStartsOn)!==null&&n!==void 0?n:0);if(!(B>=0&&B<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var R=toDate(e),p=R.getDay(),g=(p<B?-7:0)+6-(p-B);return R.setDate(R.getDate()+g),R.setHours(23,59,59,999),R}function endOfMinute(e){requiredArgs(1,arguments);var t=toDate(e);return t.setSeconds(59,999),t}function endOfQuarter(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getMonth(),r=n-n%3+3;return t.setMonth(r,0),t.setHours(23,59,59,999),t}function getDay(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getDay();return n}function getHours(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getHours();return n}function getMinutes(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getMinutes();return n}function getMonth(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getMonth();return n}function getWeekYear(e,t){var n,r,l,s,c,o,d,u;requiredArgs(1,arguments);var U=toDate(e),B=U.getFullYear(),R=getDefaultOptions(),p=toInteger((n=(r=(l=(s=t==null?void 0:t.firstWeekContainsDate)!==null&&s!==void 0?s:t==null||(c=t.locale)===null||c===void 0||(o=c.options)===null||o===void 0?void 0:o.firstWeekContainsDate)!==null&&l!==void 0?l:R.firstWeekContainsDate)!==null&&r!==void 0?r:(d=R.locale)===null||d===void 0||(u=d.options)===null||u===void 0?void 0:u.firstWeekContainsDate)!==null&&n!==void 0?n:1);if(!(p>=1&&p<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var g=new Date(0);g.setFullYear(B+1,0,p),g.setHours(0,0,0,0);var h=startOfWeek(g,t),m=new Date(0);m.setFullYear(B,0,p),m.setHours(0,0,0,0);var N=startOfWeek(m,t);return U.getTime()>=h.getTime()?B+1:U.getTime()>=N.getTime()?B:B-1}function startOfWeekYear(e,t){var n,r,l,s,c,o,d,u;requiredArgs(1,arguments);var U=getDefaultOptions(),B=toInteger((n=(r=(l=(s=t==null?void 0:t.firstWeekContainsDate)!==null&&s!==void 0?s:t==null||(c=t.locale)===null||c===void 0||(o=c.options)===null||o===void 0?void 0:o.firstWeekContainsDate)!==null&&l!==void 0?l:U.firstWeekContainsDate)!==null&&r!==void 0?r:(d=U.locale)===null||d===void 0||(u=d.options)===null||u===void 0?void 0:u.firstWeekContainsDate)!==null&&n!==void 0?n:1),R=getWeekYear(e,t),p=new Date(0);p.setFullYear(R,0,B),p.setHours(0,0,0,0);var g=startOfWeek(p,t);return g}var MILLISECONDS_IN_WEEK=6048e5;function getWeek(e,t){requiredArgs(1,arguments);var n=toDate(e),r=startOfWeek(n,t).getTime()-startOfWeekYear(n,t).getTime();return Math.round(r/MILLISECONDS_IN_WEEK)+1}function getYear(e){return requiredArgs(1,arguments),toDate(e).getFullYear()}function startOfHour(e){requiredArgs(1,arguments);var t=toDate(e);return t.setMinutes(0,0,0),t}function subDays(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addDays(e,-n)}function roundToNearestMinutes(e,t){var n;if(arguments.length<1)throw new TypeError("1 argument required, but only none provided present");var r=toInteger((n=t==null?void 0:t.nearestTo)!==null&&n!==void 0?n:1);if(r<1||r>30)throw new RangeError("`options.nearestTo` must be between 1 and 30");var l=toDate(e),s=l.getSeconds(),c=l.getMinutes()+s/60,o=getRoundingMethod(t==null?void 0:t.roundingMethod),d=o(c/r)*r,u=c%r,U=Math.round(u/r)*r;return new Date(l.getFullYear(),l.getMonth(),l.getDate(),l.getHours(),d+U)}function subMonths(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMonths(e,-n)}function subHours(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addHours(e,-n)}function subMinutes(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMinutes(e,-n)}function subQuarters(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addQuarters(e,-n)}function subWeeks(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addWeeks(e,-n)}function subYears(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addYears(e,-n)}const millisecond$2=1,second$2=1e3,minute$2=60*second$2,hour$2=60*minute$2,day$2=24*hour$2,week$2=7*day$2,month$2=30*day$2,year$2=365*day$2,duration$2={millisecond:millisecond$2,second:second$2,minute:minute$2,hour:hour$2,day:day$2,week:week$2,month:month$2,year:year$2};function filterDataByType$1(e,t){return e.filter(n=>t.includes(n.type))}function filterDataByTime$1(e,t,n){const r=t.getTime(),l=n.getTime();return e.map(s=>({...s,points:s.points.filter(([c])=>c>=r&&c<l)})).filter(({points:s})=>s.length>0)}let StoreCache$1=class{constructor({capacity:t,timeout:n}={}){Fe(this,"entries",new Map);Fe(this,"metadata",new Map);Fe(this,"capacity");Fe(this,"staleIntervalMs");this.capacity=t||1e4,this.staleIntervalMs=n||duration$2.minute}get(t,n){const r=this.keyToCacheKey(t);return this.isStale(r)&&!this.isGenerating(r)&&n&&this.generate(t,n),this.entries.get(r)}set(t,n){const r=this.keyToCacheKey(t);this.metadata.set(r,{generating:!1,staleAt:performance.now()+this.staleIntervalMs});const l=this.entries.get(r);JSON.stringify(l)===JSON.stringify(n)||(this.entries.set(r,n),this.enforceMaxSize())}clear(){this.entries.clear(),[...this.metadata.values()].forEach(t=>t.generating=!1)}clearKey(t){this.metadata.delete(t),this.entries.delete(t)}keyToCacheKey(t){return JSON.stringify(t)}enforceMaxSize(){for(;this.metadata.size>this.capacity&&this.metadata.size>0;){const[t]=[...this.metadata.entries()].reduce(([n,r],[l,s])=>s.staleAt<r.staleAt?[l,s]:[n,r]);this.clearKey(t)}}isStale(t){const n=this.metadata.get(t);return n?(n==null?void 0:n.staleAt)<performance.now():!0}isGenerating(t){const n=this.metadata.get(t);return n?n.generating:!1}generate(t,n){const r=this.keyToCacheKey(t),l=this.metadata.get(r)||{},s=n().then(c=>{const o=this.metadata.get(r);return(o==null?void 0:o.generating)!==s||this.set(t,c),c}).catch(c=>{throw this.metadata.delete(r),c});this.metadata.set(r,{...l,generating:s,staleAt:performance.now()+this.staleIntervalMs})}};async function queryTelemetry(e){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/queries/queries`,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}let QueryStore$1=class{constructor(){Fe(this,"queryStoreCache",new StoreCache$1({capacity:1e4,timeout:20*duration$2.second}));Fe(this,"liveQueryStoreCache",new StoreCache$1({capacity:1e4,timeout:200*duration$2.millisecond}))}moduleQuery(t,n,r,l,s,c=!1){const o={...t,names:[...n],types:[...r]},d=this.query(o,l,s,c);return d===void 0||d==="too much data"?d:filterDataByType$1(d,r)}query(t,n,r,l=!1){const s={...t,start:startOfMinute(n).toISOString(),end:l?r.toISOString():addMinutes(roundToNearestMinutes(r),1).toISOString(),latestOnly:l},c=r>addSeconds(new Date,-20);let o;return c?o=this.liveQueryCache(s):o=this.queryCache(s),!o||o==="too much data"||l?o:filterDataByTime$1(o,n,r)}queryCache(t){return this.queryStoreCache.get(t,async()=>{try{return await queryTelemetry(t)}catch(n){throw n}})}liveQueryCache(t){return this.liveQueryStoreCache.get(t,async()=>{try{return await queryTelemetry(t)}catch(n){throw n}})}};const queryStore=new QueryStore$1;function addStreamListener(e,t,n){const r=l=>{const s=l.data;if(s.type==="module_data"){const{start:c,end:o}=s.queryRange;n(queryStore.moduleQuery({},e,t,new Date(c),new Date(o),!1))}};return window.addEventListener("message",r),()=>window.removeEventListener("message",r)}async function getDate(e,t,n){return new Promise(r=>{sendAppMessage({type:"request_date",minTime:t,maxTime:n,time:e});const l=s=>{const c=s.data;c.type==="date_response"&&(window.removeEventListener("message",l),r(c.data))};window.addEventListener("message",l)})}async function prompt(e,t){return new Promise(n=>{const r=Math.random().toString();sendAppMessage({type:"prompt",promptId:r,schema:e,okText:t==null?void 0:t.okText,cancelText:t==null?void 0:t.cancelText});const l=s=>{const c=s.data;c.type==="prompt_response"&&c.promptId===r&&n(c.data),window.removeEventListener("message",l)};window.addEventListener("message",l)})}const Ht=class{static isModule(){return getCurrentModuleContext()!==null}static async getCurrentModuleConfiguration(){let t=new URLSearchParams("");typeof window!="undefined"&&window.location&&(t=new URLSearchParams(window.location.search));const n=t.get("configuration");if(!(n===null||n.trim()===""))return getModuleConfiguration(n.trim())}static get isOnline(){return Ht._isOnline}static listenForConnectionEvents(){const t=n=>{const{data:r}=n;r.type==="formant_online"&&(this._isOnline=r.online)};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}static checkConnection(t=1e3){return new Promise((n,r)=>{const l=setTimeout(()=>r(new Error("deadline expired: took too long")),t),s=c=>{window.removeEventListener("message",s),clearTimeout(l);const{data:o}=c;o.type==="formant_online"&&(this._isOnline=o.online,n(o.online))};window.addEventListener("message",s),sendAppMessage({type:"formant_online"})})}static waitForConnection(t=5e3){let n=!1;const r=new Promise((c,o)=>{setTimeout(()=>{n=!0,o(new Error("deadline expired: took too long"))},t)}),l=c=>new Promise(o=>setTimeout(o,c)),s=async()=>{for(await l(50);!n&&!(this.isOnline||await this.checkConnection);)await l(500)};return Promise.race([r,s()])}};let App=Ht;Fe(App,"getCurrentModuleContext",getCurrentModuleContext),Fe(App,"disableAnalyticsBottomBar",disableAnalyticsBottomBar),Fe(App,"goToDevice",goToDevice),Fe(App,"goToTime",goToTime),Fe(App,"refreshAuthToken",refreshAuthToken),Fe(App,"requestModuleData",requestModuleData),Fe(App,"sendChannelData",sendChannelData),Fe(App,"setModuleDateTimeRange",setModuleDateTimeRange),Fe(App,"setupModuleMenus",setupModuleMenus),Fe(App,"showMessage",showMessage),Fe(App,"addAccessTokenRefreshListener",addAccessTokenRefreshListener),Fe(App,"addChannelDataListener",addChannelDataListener),Fe(App,"addMenuListener",addMenuListener),Fe(App,"addModuleConfigurationListener",addModuleConfigurationListener),Fe(App,"addModuleDataListener",addModuleDataListener),Fe(App,"addOverviewDeviceListener",addOverviewDeviceListener),Fe(App,"addStreamListener",addStreamListener),Fe(App,"getDate",getDate),Fe(App,"prompt",prompt),Fe(App,"_isOnline",null);function defined$1(e,t){if(e!==void 0)return e;throw new Error(t||"Value is undefined")}function notNull(e,t){if(e!==null)return e;throw new Error(t||"Value is null")}function definedAndNotNull(e,t){return notNull(defined$1(e,t),t)}var dist={exports:{}};/*! For license information please see index.js.LICENSE.txt */(function(module,exports){(function(e,t){module.exports=t()})(window,function(){return function(e){function t(u){for(var U,B,R=u[0],p=u[1],g=0,h=[];g<R.length;g++)B=R[g],Object.prototype.hasOwnProperty.call(r,B)&&r[B]&&h.push(r[B][0]),r[B]=0;for(U in p)Object.prototype.hasOwnProperty.call(p,U)&&(e[U]=p[U]);for(d&&d(u);h.length;)h.shift()()}var n={},r={0:0};function l(u){if(n[u])return n[u].exports;var U=n[u]={i:u,l:!1,exports:{}};return e[u].call(U.exports,U,U.exports,l),U.l=!0,U.exports}l.e=function(){return Promise.resolve()},l.m=e,l.c=n,l.d=function(u,U,B){l.o(u,U)||Object.defineProperty(u,U,{enumerable:!0,get:B})},l.r=function(u){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(u,"__esModule",{value:!0})},l.t=function(u,U){if(1&U&&(u=l(u)),8&U||4&U&&typeof u=="object"&&u&&u.__esModule)return u;var B=Object.create(null);if(l.r(B),Object.defineProperty(B,"default",{enumerable:!0,value:u}),2&U&&typeof u!="string")for(var R in u)l.d(B,R,function(p){return u[p]}.bind(null,R));return B},l.n=function(u){var U=u&&u.__esModule?function(){return u.default}:function(){return u};return l.d(U,"a",U),U},l.o=function(u,U){return Object.prototype.hasOwnProperty.call(u,U)},l.p="",l.oe=function(u){throw console.error(u),u};var s=window.webpackJsonpFormantRealtimeSDK=window.webpackJsonpFormantRealtimeSDK||[],c=s.push.bind(s);s.push=t,s=s.slice();for(var o=0;o<s.length;o++)t(s[o]);var d=c;return l(l.s=232)}([function(e,t,n){n.d(t,"a",function(){return _});var r=n(16),l=n(55),s=n(15),c=n.n(s),o=n(18);function d(X,H){if(H.length<X)throw new TypeError(X+" argument"+(X>1?"s":"")+" required, but only "+H.length+" present")}function u(X){if(X===null||X===!0||X===!1)return NaN;var H=Number(X);return isNaN(H)?H:H<0?Math.ceil(H):Math.floor(H)}var U={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},B=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,R=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,p=/^([+-])(\d{2})(?::?(\d{2}))?$/;function g(X){var H,ne={},ie=X.split(U.dateTimeDelimiter);if(ie.length>2)return ne;if(/:/.test(ie[0])?H=ie[0]:(ne.date=ie[0],H=ie[1],U.timeZoneDelimiter.test(ne.date)&&(ne.date=X.split(U.timeZoneDelimiter)[0],H=X.substr(ne.date.length,X.length))),H){var ce=U.timezone.exec(H);ce?(ne.time=H.replace(ce[1],""),ne.timezone=ce[1]):ne.time=H}return ne}function h(X,H){var ne=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+H)+"})|(\\d{2}|[+-]\\d{"+(2+H)+"})$)"),ie=X.match(ne);if(!ie)return{year:NaN,restDateString:""};var ce=ie[1]?parseInt(ie[1]):null,Se=ie[2]?parseInt(ie[2]):null;return{year:Se===null?ce:100*Se,restDateString:X.slice((ie[1]||ie[2]).length)}}function m(X,H){if(H===null)return new Date(NaN);var ne=X.match(B);if(!ne)return new Date(NaN);var ie=!!ne[4],ce=N(ne[1]),Se=N(ne[2])-1,Te=N(ne[3]),ye=N(ne[4]),we=N(ne[5])-1;if(ie)return function(Ee,_e,Ae){return _e>=1&&_e<=53&&Ae>=0&&Ae<=6}(0,ye,we)?function(Ee,_e,Ae){var Le=new Date(0);Le.setUTCFullYear(Ee,0,4);var et=Le.getUTCDay()||7,Qt=7*(_e-1)+Ae+1-et;return Le.setUTCDate(Le.getUTCDate()+Qt),Le}(H,ye,we):new Date(NaN);var be=new Date(0);return function(Ee,_e,Ae){return _e>=0&&_e<=11&&Ae>=1&&Ae<=(F[_e]||(v(Ee)?29:28))}(H,Se,Te)&&function(Ee,_e){return _e>=1&&_e<=(v(Ee)?366:365)}(H,ce)?(be.setUTCFullYear(H,Se,Math.max(ce,Te)),be):new Date(NaN)}function N(X){return X?parseInt(X):1}function D(X){var H=X.match(R);if(!H)return NaN;var ne=y(H[1]),ie=y(H[2]),ce=y(H[3]);return function(Se,Te,ye){return Se===24?Te===0&&ye===0:ye>=0&&ye<60&&Te>=0&&Te<60&&Se>=0&&Se<25}(ne,ie,ce)?36e5*ne+6e4*ie+1e3*ce:NaN}function y(X){return X&&parseFloat(X.replace(",","."))||0}function b(X){if(X==="Z")return 0;var H=X.match(p);if(!H)return 0;var ne=H[1]==="+"?-1:1,ie=parseInt(H[2]),ce=H[3]&&parseInt(H[3])||0;return function(Se,Te){return Te>=0&&Te<=59}(0,ce)?ne*(36e5*ie+6e4*ce):NaN}var F=[31,null,31,30,31,30,31,31,30,31,30,31];function v(X){return X%400==0||X%4==0&&X%100!=0}function j(X){return(j=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(H){return typeof H}:function(H){return H&&typeof Symbol=="function"&&H.constructor===Symbol&&H!==Symbol.prototype?"symbol":typeof H})(X)}function K(X){return d(1,arguments),X instanceof Date||j(X)==="object"&&Object.prototype.toString.call(X)==="[object Date]"}function f(X){return(f=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(H){return typeof H}:function(H){return H&&typeof Symbol=="function"&&H.constructor===Symbol&&H!==Symbol.prototype?"symbol":typeof H})(X)}function Q(X){d(1,arguments);var H=Object.prototype.toString.call(X);return X instanceof Date||f(X)==="object"&&H==="[object Date]"?new Date(X.getTime()):typeof X=="number"||H==="[object Number]"?new Date(X):(typeof X!="string"&&H!=="[object String]"||typeof console=="undefined"||(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}function P(X){const H=function(ne,ie){var ce;d(1,arguments);var Se=u((ce=ie==null?void 0:ie.additionalDigits)!==null&&ce!==void 0?ce:2);if(Se!==2&&Se!==1&&Se!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(typeof ne!="string"&&Object.prototype.toString.call(ne)!=="[object String]")return new Date(NaN);var Te,ye=g(ne);if(ye.date){var we=h(ye.date,Se);Te=m(we.restDateString,we.year)}if(!Te||isNaN(Te.getTime()))return new Date(NaN);var be,Ee=Te.getTime(),_e=0;if(ye.time&&(_e=D(ye.time),isNaN(_e)))return new Date(NaN);if(!ye.timezone){var Ae=new Date(Ee+_e),Le=new Date(0);return Le.setFullYear(Ae.getUTCFullYear(),Ae.getUTCMonth(),Ae.getUTCDate()),Le.setHours(Ae.getUTCHours(),Ae.getUTCMinutes(),Ae.getUTCSeconds(),Ae.getUTCMilliseconds()),Le}return be=b(ye.timezone),isNaN(be)?new Date(NaN):new Date(Ee+_e+be)}(X);if(!function(ne){if(d(1,arguments),!K(ne)&&typeof ne!="number")return!1;var ie=Q(ne);return!isNaN(Number(ie))}(H))throw new Error(`Invalid ISO 8601 date string (${X})`);return H}const w=Math.pow(2,20),V=w;var I=n(4),W=n(28);function k(X){return c()(X,{cycles:!0})}var T=function(X,H){var ne={};for(var ie in X)Object.prototype.hasOwnProperty.call(X,ie)&&H.indexOf(ie)<0&&(ne[ie]=X[ie]);if(X!=null&&typeof Object.getOwnPropertySymbols=="function"){var ce=0;for(ie=Object.getOwnPropertySymbols(X);ce<ie.length;ce++)H.indexOf(ie[ce])<0&&Object.prototype.propertyIsEnumerable.call(X,ie[ce])&&(ne[ie[ce]]=X[ie[ce]])}return ne};function Z(X,H={}){const{redacted:ne=!0}=H,ie=we=>ne?Object(W.a)(we):we;if(!X.stack)return{message:k(ie(X))};const{name:ce,message:Se,stack:Te}=X,ye=T(X,["name","message","stack"]);return{name:ce,message:Se!==void 0?Se:k(ie(X)),stack:Te,meta:ye&&Object.keys(ye).length===0?void 0:ie(ye)}}function O(X,H={}){const{message:ne,stack:ie,meta:ce}=Z(X,H);return`${ie||ne||""}${ce&&Object.keys(ce).length>0?` -- ${k(ce)}`:""}`}var E=n(40),L=n(14),G=n.n(L),$=function(X,H,ne,ie){return new(ne||(ne=Promise))(function(ce,Se){function Te(be){try{we(ie.next(be))}catch(Ee){Se(Ee)}}function ye(be){try{we(ie.throw(be))}catch(Ee){Se(Ee)}}function we(be){var Ee;be.done?ce(be.value):(Ee=be.value,Ee instanceof ne?Ee:new ne(function(_e){_e(Ee)})).then(Te,ye)}we((ie=ie.apply(X,H||[])).next())})},ee=function(X,H){var ne={};for(var ie in X)Object.prototype.hasOwnProperty.call(X,ie)&&H.indexOf(ie)<0&&(ne[ie]=X[ie]);if(X!=null&&typeof Object.getOwnPropertySymbols=="function"){var ce=0;for(ie=Object.getOwnPropertySymbols(X);ce<ie.length;ce++)H.indexOf(ie[ce])<0&&Object.prototype.propertyIsEnumerable.call(X,ie[ce])&&(ne[ie[ce]]=X[ie[ce]])}return ne};class te extends G.a{constructor(H,ne){super(),this.endpoint=H,this.metadata=ne,this.logClient=this.getLogClient()}getLogClient(){return $(this,void 0,void 0,function*(){const{LogClient:H}=yield Promise.resolve().then(n.bind(null,235));return new H(this.endpoint)})}log(H,ne){return $(this,void 0,void 0,function*(){const{level:ie,message:ce,error:Se}=H,Te=ee(H,["level","message","error"]);this.emit("logged");try{yield(yield this.logClient).log([{timestamp:new Date().toISOString(),level:ie,message:`${ce}`.substring(0,1e3),error:Se!==void 0?Z(Se):void 0,meta:Object.assign(Object.assign({},Te),this.metadata)}])}catch(ye){console.error(`Failed to log to log-api: ${O(ye)}`)}ne()})}}var M=function(X,H){var ne={};for(var ie in X)Object.prototype.hasOwnProperty.call(X,ie)&&H.indexOf(ie)<0&&(ne[ie]=X[ie]);if(X!=null&&typeof Object.getOwnPropertySymbols=="function"){var ce=0;for(ie=Object.getOwnPropertySymbols(X);ce<ie.length;ce++)H.indexOf(ie[ce])<0&&Object.prototype.propertyIsEnumerable.call(X,ie[ce])&&(ne[ie[ce]]=X[ie[ce]])}return ne};const C={app:I.a,namespace:I.i,buildTag:I.b,instanceId:E.a},S=I.e?o.format.printf(X=>{var{timestamp:H,level:ne,message:ie,error:ce}=X,Se=M(X,["timestamp","level","message","error"]);const Te=Object.assign(Object.assign({timestamp:H?P(H).getTime():new Date().getTime(),level:ne.toUpperCase(),message:ie},ce?{error:Z(ce)}:{}),{meta:Object.assign(Object.assign({},C),Se)});return c()(Te,{cycles:!0})}):o.format.printf(X=>{var{timestamp:H,level:ne,message:ie,error:ce}=X,Se=M(X,["timestamp","level","message","error"]);let Te=`${H||new Date().toISOString()} ${ne.toUpperCase()}: ${ie} `;return Object.keys(Se).length>0&&(Te+=c()(Se,{cycles:!0})),ce&&(Te+=`
|
|
1
|
+
"use strict";var Rn=Object.defineProperty;var Bn=(e,t,n)=>t in e?Rn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Fe=(e,t,n)=>(Bn(e,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const require$$0=require("google-protobuf"),require$$1=require("google-protobuf/google/protobuf/wrappers_pb.js"),DEFAULT_FORMANT_API_URL="https://api.formant.io";function whichFormantApiUrl(e,t){try{if(t.get("formant_stage"))return"https://api-stage.formant.io";if(t.get("formant_dev"))return"https://api-dev.formant.io";if(t.get("formant_local"))return"https://api.formant.local";if(t.get("formant_url")){const n=t.get("formant_url");if(n!==null)try{return new URL(n).origin}catch{console.warn(`Ignoring malformed \`formant_url\` url parameter: ${n}`)}}}catch{}return typeof e!="undefined"&&"FORMANT_API_URL"in e&&typeof e.FORMANT_API_URL=="string"?e.FORMANT_API_URL:DEFAULT_FORMANT_API_URL}const FORMANT_API_URL=whichFormantApiUrl(typeof window!="undefined"?window:globalThis,new URLSearchParams(typeof window!="undefined"&&window.location?window.location.search:void 0));var commonjsGlobal=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var base64={exports:{}};/*! https://mths.be/base64 v1.0.0 by @mathias | MIT license */base64.exports;(function(e,t){(function(n){var r=t,l=e&&e.exports==r&&e,s=typeof commonjsGlobal=="object"&&commonjsGlobal;(s.global===s||s.window===s)&&(n=s);var c=function(g){this.message=g};c.prototype=new Error,c.prototype.name="InvalidCharacterError";var o=function(g){throw new c(g)},d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=/[\t\n\f\r ]/g,U=function(g){g=String(g).replace(u,"");var h=g.length;h%4==0&&(g=g.replace(/==?$/,""),h=g.length),(h%4==1||/[^+a-zA-Z0-9/]/.test(g))&&o("Invalid character: the string to be decoded is not correctly encoded.");for(var m=0,N,D,y="",b=-1;++b<h;)D=d.indexOf(g.charAt(b)),N=m%4?N*64+D:D,m++%4&&(y+=String.fromCharCode(255&N>>(-2*m&6)));return y},B=function(g){g=String(g),/[^\0-\xFF]/.test(g)&&o("The string to be encoded contains characters outside of the Latin1 range.");for(var h=g.length%3,m="",N=-1,D,y,b,F,v=g.length-h;++N<v;)D=g.charCodeAt(N)<<16,y=g.charCodeAt(++N)<<8,b=g.charCodeAt(++N),F=D+y+b,m+=d.charAt(F>>18&63)+d.charAt(F>>12&63)+d.charAt(F>>6&63)+d.charAt(F&63);return h==2?(D=g.charCodeAt(N)<<8,y=g.charCodeAt(++N),F=D+y,m+=d.charAt(F>>10)+d.charAt(F>>4&63)+d.charAt(F<<2&63)+"="):h==1&&(F=g.charCodeAt(N),m+=d.charAt(F>>2)+d.charAt(F<<4&63)+"=="),m},R={encode:B,decode:U,version:"1.0.0"};if(r&&!r.nodeType)if(l)l.exports=R;else for(var p in R)R.hasOwnProperty(p)&&(r[p]=R[p]);else n.base64=R})(commonjsGlobal)})(base64,base64.exports);var base64Exports=base64.exports;class LoginFailureError extends Error{constructor(n){super("login failed");Fe(this,"reason");this.reason=n,this.name="LoginFailureError",Object.setPrototypeOf(this,new.target.prototype)}}class LoginChallengedError extends Error{constructor(n){super("login challenged");Fe(this,"challenge");this.challenge=n,this.name="LoginChallengedError",Object.setPrototypeOf(this,new.target.prototype)}}class AuthenticationStore{constructor({apiUrl:t,refreshAuthToken:n,addAccessTokenRefreshListener:r}){Fe(this,"_refreshToken");Fe(this,"_isShareToken",!1);Fe(this,"_currentOrganization");Fe(this,"_currentUser");Fe(this,"_defaultDeviceId");Fe(this,"_token");Fe(this,"_waitingForAuth",new Set);Fe(this,"_refreshTimer");Fe(this,"_apiUrl");Fe(this,"_refreshAuthToken");Fe(this,"_addAccessTokenRefreshListener");this._apiUrl=t,this._refreshAuthToken=n,this._addAccessTokenRefreshListener=r}get token(){return this._token}get currentUser(){return this._currentUser}get currentOrganization(){return this._currentOrganization}get defaultDeviceId(){return this._defaultDeviceId}get refreshToken(){return this._refreshToken}get isShareToken(){return this._isShareToken}async login(t,n,r={}){const{advanced:l=!1}=r;try{const s=await fetch(`${this._apiUrl}/v1/admin/auth/login`,{method:"POST",body:JSON.stringify({email:t,password:n}),headers:{"Content-Type":"application/json"}}),c=await s.json();if(s.status!==200)throw new LoginFailureError(c.message);if("challenge"in c)throw new LoginChallengedError(c.challenge);const{authentication:o}=c;return await this.loginWithToken(o.accessToken,o.refreshToken),l?{result:"success",authentication:o}:o}catch(s){if(l||console.error("login() failed",{err:s}),this._waitingForAuth.forEach(c=>c(!1)),this._waitingForAuth.clear(),!l)throw s;return s instanceof LoginChallengedError?{result:"challenged",challenge:s.challenge}:{result:"failure",reason:s instanceof LoginFailureError?s.reason:s instanceof Error?s.message:String(s)}}}async loginWithToken(t,n){var l;const r=JSON.parse(base64Exports.decode(t.split(".")[1]));try{let s;if(this._isShareToken=r["formant:claims"]&&r["formant:claims"].type=="share",r["formant:claims"]&&(this._currentOrganization=r["formant:claims"].organizationId),r["custom:organization_id"]&&(this._currentOrganization=r["custom:organization_id"]),this._isShareToken||(s=r.sub),r["formant:claims"]&&r["formant:claims"].userId&&(s=r["formant:claims"].userId),s&&((l=this._currentUser)==null?void 0:l.id)!==s){const c=await fetch(`${this._apiUrl}/v1/admin/users/${s}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+t}}),o=await c.json();if(c.status!==200)throw new Error(o.message);this._currentUser=o}this._token=t,this._waitingForAuth.forEach(c=>c(!0))}catch(s){console.error("loginWithToken() failed",{err:s}),this._waitingForAuth.forEach(c=>c(!1))}finally{this._waitingForAuth.clear()}n&&(this._refreshToken=n,setInterval(async()=>{if(this._refreshToken){const c=await(await fetch(`${this._apiUrl}/v1/admin/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:this._refreshToken})})).json();this._token=c.authentication.accessToken}},1e3*60*60))}isAuthenticated(){return this._token!==void 0}async loginToPeer(t,n,r){if((await fetch(`${t}/login`,{method:"POST",body:JSON.stringify({username:n,password:r}),headers:{"Content-Type":"application/json"}})).status!==200)throw new LoginFailureError("Invalid authentication")}getCurrentUser(){return this._currentUser}async waitTilAuthenticated(){return this.token!==void 0?!0:new Promise(t=>{this._waitingForAuth.add(t)})}async listenForRefresh(){const n=()=>{this._refreshTimer=void 0,this._refreshAuthToken()};this._addAccessTokenRefreshListener(r=>{this._refreshTimer&&clearTimeout(this._refreshTimer),this._refreshTimer=setTimeout(n,36e5),this.loginWithToken(r)}),this._refreshTimer=setTimeout(n,36e5)}async forgotPassword(t){await fetch(`${this._apiUrl}/v1/admin/auth/forgot-password`,{method:"POST",body:JSON.stringify({email:t}),headers:{"Content-Type":"application/json"}})}async confirmForgotPassword(t){return(await fetch(`${this._apiUrl}/v1/admin/auth/confirm-forgot-password`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})).ok}async respondToNewPasswordRequiredChallenge(t){const n=await fetch(`${this._apiUrl}/v1/admin/auth/respond-to-new-password-required-challenge`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}});if(n.ok)return await n.json();throw new Error("respond-to-new-password-required-challenge failed")}async loginWithGoogle(t){return await(await fetch(`${this._apiUrl}/v1/admin/auth/login-google`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})).json()}async refresh(t){const r=await(await fetch(`${this._apiUrl}/v1/admin/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t})})).json();await this.loginWithToken(r.authentication.accessToken,t)}async checkSso(t,n){return await(await fetch(`${this._apiUrl}/v1/admin/auth/check-sso`,{method:"POST",body:JSON.stringify({email:t,allowUserAutoCreation:n}),headers:{"Content-Type":"application/json"}})).json()}async loginWithSso(t,n){const l=await(await fetch(`${this._apiUrl}/v1/admin/auth/login-sso`,{method:"POST",body:JSON.stringify({token:t,refreshToken:n}),headers:{"Content-Type":"application/json"}})).json();if(!l.authentication)throw new Error("Failed to login with SSO");return await this.loginWithToken(l.authentication.accessToken,l.authentication.refreshToken)}}function getCurrentModuleContext(){return typeof window!="undefined"&&window.location?new URLSearchParams(window.location.search).get("module"):null}function sendAppMessage(e){if(!(window&&window.parent))throw new Error("cannot send message to non-existent parent");window.parent.postMessage(e,"*")}function refreshAuthToken(){const e=getCurrentModuleContext();if(!e)throw new Error("No module context");sendAppMessage({type:"refresh_auth_token",module:e})}function addAccessTokenRefreshListener(e){function t(n){const r=n.data;r.type==="auth_token"&&e(r.token)}return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}}const Authentication=new AuthenticationStore({apiUrl:FORMANT_API_URL,refreshAuthToken,addAccessTokenRefreshListener});async function getModuleConfiguration(e){return(await(await fetch(`${FORMANT_API_URL}/v1/admin/module-configurations/${e}`,{headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).configuration}function disableAnalyticsBottomBar(){sendAppMessage({type:"hide_analytics_date_picker"})}function goToDevice(e){sendAppMessage({type:"go_to_device",deviceId:e})}function goToTime(e){sendAppMessage({type:"go_to_time",time:e.getTime()})}function requestModuleData(){const e=getCurrentModuleContext();if(!e)throw new Error("No module context");sendAppMessage({type:"request_module_data",module:e})}function sendChannelData(e,t){const n=getCurrentModuleContext();if(!n)throw new Error("No module context");sendAppMessage({type:"send_channel_data",source:n,channel:e,data:t})}function setModuleDateTimeRange(e,t){const n=getCurrentModuleContext();if(!n)throw new Error("No module context");sendAppMessage({type:"set_module_data_time_range",module:n,before:e,after:t||0})}function setupModuleMenus(e){const t=getCurrentModuleContext();if(!t)throw new Error("No module context");sendAppMessage({type:"setup_module_menus",module:t,menus:e})}function showMessage(e){sendAppMessage({type:"show_message",message:e})}function addChannelDataListener(e,t){const n=r=>{const l=r.data;l.type==="channel_data"&&l.channel===e&&t({source:l.source,data:l.data})};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)}function addMenuListener(e){const t=n=>{const r=n.data;r.type==="module_menu_item_clicked"&&e(r.menu)};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}function addModuleConfigurationListener(e){const t=n=>{const r=n.data;r.type==="module_configuration"&&e(r)};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}function addModuleDataListener(e){const t=getCurrentModuleContext();t&&sendAppMessage({type:"request_module_data",module:t});const n=r=>{const l=r.data;l.type==="module_data"&&e({streams:l.streams,time:l.time,queryRange:l.queryRange})};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)}function addOverviewDeviceListener(e){sendAppMessage({type:"request_devices"});const t=n=>{const r=n.data;r.type==="overview_devices"&&e(r.data)};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}function _typeof(e){return _typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(e)}function toInteger(e){if(e===null||e===!0||e===!1)return NaN;var t=Number(e);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}function requiredArgs(e,t){if(t.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+t.length+" present")}function toDate(e){requiredArgs(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||_typeof(e)==="object"&&t==="[object Date]"?new Date(e.getTime()):typeof e=="number"||t==="[object Number]"?new Date(e):((typeof e=="string"||t==="[object String]")&&typeof console!="undefined"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}function addDays(e,t){requiredArgs(2,arguments);var n=toDate(e),r=toInteger(t);return isNaN(r)?new Date(NaN):(r&&n.setDate(n.getDate()+r),n)}function addMonths(e,t){requiredArgs(2,arguments);var n=toDate(e),r=toInteger(t);if(isNaN(r))return new Date(NaN);if(!r)return n;var l=n.getDate(),s=new Date(n.getTime());s.setMonth(n.getMonth()+r+1,0);var c=s.getDate();return l>=c?s:(n.setFullYear(s.getFullYear(),s.getMonth(),l),n)}function addMilliseconds(e,t){requiredArgs(2,arguments);var n=toDate(e).getTime(),r=toInteger(t);return new Date(n+r)}var MILLISECONDS_IN_HOUR=36e5;function addHours(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMilliseconds(e,n*MILLISECONDS_IN_HOUR)}var defaultOptions={};function getDefaultOptions(){return defaultOptions}function startOfWeek(e,t){var n,r,l,s,c,o,d,u;requiredArgs(1,arguments);var U=getDefaultOptions(),B=toInteger((n=(r=(l=(s=t==null?void 0:t.weekStartsOn)!==null&&s!==void 0?s:t==null||(c=t.locale)===null||c===void 0||(o=c.options)===null||o===void 0?void 0:o.weekStartsOn)!==null&&l!==void 0?l:U.weekStartsOn)!==null&&r!==void 0?r:(d=U.locale)===null||d===void 0||(u=d.options)===null||u===void 0?void 0:u.weekStartsOn)!==null&&n!==void 0?n:0);if(!(B>=0&&B<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var R=toDate(e),p=R.getDay(),g=(p<B?7:0)+p-B;return R.setDate(R.getDate()-g),R.setHours(0,0,0,0),R}function startOfDay(e){requiredArgs(1,arguments);var t=toDate(e);return t.setHours(0,0,0,0),t}var MILLISECONDS_IN_MINUTE=6e4;function addMinutes(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMilliseconds(e,n*MILLISECONDS_IN_MINUTE)}function addQuarters(e,t){requiredArgs(2,arguments);var n=toInteger(t),r=n*3;return addMonths(e,r)}function addSeconds(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMilliseconds(e,n*1e3)}function addWeeks(e,t){requiredArgs(2,arguments);var n=toInteger(t),r=n*7;return addDays(e,r)}function addYears(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMonths(e,n*12)}function getQuarter(e){requiredArgs(1,arguments);var t=toDate(e),n=Math.floor(t.getMonth()/3)+1;return n}var roundingMap={ceil:Math.ceil,round:Math.round,floor:Math.floor,trunc:function(t){return t<0?Math.ceil(t):Math.floor(t)}},defaultRoundingMethod="trunc";function getRoundingMethod(e){return e?roundingMap[e]:roundingMap[defaultRoundingMethod]}function endOfDay(e){requiredArgs(1,arguments);var t=toDate(e);return t.setHours(23,59,59,999),t}function endOfMonth(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function eachDayOfInterval(e,t){var n;requiredArgs(1,arguments);var r=e||{},l=toDate(r.start),s=toDate(r.end),c=s.getTime();if(!(l.getTime()<=c))throw new RangeError("Invalid interval");var o=[],d=l;d.setHours(0,0,0,0);var u=Number((n=t==null?void 0:t.step)!==null&&n!==void 0?n:1);if(u<1||isNaN(u))throw new RangeError("`options.step` must be a number greater than 1");for(;d.getTime()<=c;)o.push(toDate(d)),d.setDate(d.getDate()+u),d.setHours(0,0,0,0);return o}function eachHourOfInterval(e,t){var n;requiredArgs(1,arguments);var r=e||{},l=toDate(r.start),s=toDate(r.end),c=l.getTime(),o=s.getTime();if(!(c<=o))throw new RangeError("Invalid interval");var d=[],u=l;u.setMinutes(0,0,0);var U=Number((n=t==null?void 0:t.step)!==null&&n!==void 0?n:1);if(U<1||isNaN(U))throw new RangeError("`options.step` must be a number greater than 1");for(;u.getTime()<=o;)d.push(toDate(u)),u=addHours(u,U);return d}function startOfMinute(e){requiredArgs(1,arguments);var t=toDate(e);return t.setSeconds(0,0),t}function eachMinuteOfInterval(e,t){var n;requiredArgs(1,arguments);var r=startOfMinute(toDate(e.start)),l=toDate(e.end),s=r.getTime(),c=l.getTime();if(s>=c)throw new RangeError("Invalid interval");var o=[],d=r,u=Number((n=t==null?void 0:t.step)!==null&&n!==void 0?n:1);if(u<1||isNaN(u))throw new RangeError("`options.step` must be a number equal to or greater than 1");for(;d.getTime()<=c;)o.push(toDate(d)),d=addMinutes(d,u);return o}function eachMonthOfInterval(e){requiredArgs(1,arguments);var t=e||{},n=toDate(t.start),r=toDate(t.end),l=r.getTime(),s=[];if(!(n.getTime()<=l))throw new RangeError("Invalid interval");var c=n;for(c.setHours(0,0,0,0),c.setDate(1);c.getTime()<=l;)s.push(toDate(c)),c.setMonth(c.getMonth()+1);return s}function startOfQuarter(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getMonth(),r=n-n%3;return t.setMonth(r,1),t.setHours(0,0,0,0),t}function eachQuarterOfInterval(e){requiredArgs(1,arguments);var t=e||{},n=toDate(t.start),r=toDate(t.end),l=r.getTime();if(!(n.getTime()<=l))throw new RangeError("Invalid interval");var s=startOfQuarter(n),c=startOfQuarter(r);l=c.getTime();for(var o=[],d=s;d.getTime()<=l;)o.push(toDate(d)),d=addQuarters(d,1);return o}function eachWeekOfInterval(e,t){requiredArgs(1,arguments);var n=e||{},r=toDate(n.start),l=toDate(n.end),s=l.getTime();if(!(r.getTime()<=s))throw new RangeError("Invalid interval");var c=startOfWeek(r,t),o=startOfWeek(l,t);c.setHours(15),o.setHours(15),s=o.getTime();for(var d=[],u=c;u.getTime()<=s;)u.setHours(0),d.push(toDate(u)),u=addWeeks(u,1),u.setHours(15);return d}function startOfMonth(e){requiredArgs(1,arguments);var t=toDate(e);return t.setDate(1),t.setHours(0,0,0,0),t}function endOfYear(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getFullYear();return t.setFullYear(n+1,0,0),t.setHours(23,59,59,999),t}function startOfYear(e){requiredArgs(1,arguments);var t=toDate(e),n=new Date(0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n}function eachYearOfInterval(e){requiredArgs(1,arguments);var t=e||{},n=toDate(t.start),r=toDate(t.end),l=r.getTime();if(!(n.getTime()<=l))throw new RangeError("Invalid interval");var s=[],c=n;for(c.setHours(0,0,0,0),c.setMonth(0,1);c.getTime()<=l;)s.push(toDate(c)),c.setFullYear(c.getFullYear()+1);return s}function endOfHour(e){requiredArgs(1,arguments);var t=toDate(e);return t.setMinutes(59,59,999),t}function endOfWeek(e,t){var n,r,l,s,c,o,d,u;requiredArgs(1,arguments);var U=getDefaultOptions(),B=toInteger((n=(r=(l=(s=t==null?void 0:t.weekStartsOn)!==null&&s!==void 0?s:t==null||(c=t.locale)===null||c===void 0||(o=c.options)===null||o===void 0?void 0:o.weekStartsOn)!==null&&l!==void 0?l:U.weekStartsOn)!==null&&r!==void 0?r:(d=U.locale)===null||d===void 0||(u=d.options)===null||u===void 0?void 0:u.weekStartsOn)!==null&&n!==void 0?n:0);if(!(B>=0&&B<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var R=toDate(e),p=R.getDay(),g=(p<B?-7:0)+6-(p-B);return R.setDate(R.getDate()+g),R.setHours(23,59,59,999),R}function endOfMinute(e){requiredArgs(1,arguments);var t=toDate(e);return t.setSeconds(59,999),t}function endOfQuarter(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getMonth(),r=n-n%3+3;return t.setMonth(r,0),t.setHours(23,59,59,999),t}function getDay(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getDay();return n}function getHours(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getHours();return n}function getMinutes(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getMinutes();return n}function getMonth(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getMonth();return n}function getWeekYear(e,t){var n,r,l,s,c,o,d,u;requiredArgs(1,arguments);var U=toDate(e),B=U.getFullYear(),R=getDefaultOptions(),p=toInteger((n=(r=(l=(s=t==null?void 0:t.firstWeekContainsDate)!==null&&s!==void 0?s:t==null||(c=t.locale)===null||c===void 0||(o=c.options)===null||o===void 0?void 0:o.firstWeekContainsDate)!==null&&l!==void 0?l:R.firstWeekContainsDate)!==null&&r!==void 0?r:(d=R.locale)===null||d===void 0||(u=d.options)===null||u===void 0?void 0:u.firstWeekContainsDate)!==null&&n!==void 0?n:1);if(!(p>=1&&p<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var g=new Date(0);g.setFullYear(B+1,0,p),g.setHours(0,0,0,0);var h=startOfWeek(g,t),m=new Date(0);m.setFullYear(B,0,p),m.setHours(0,0,0,0);var N=startOfWeek(m,t);return U.getTime()>=h.getTime()?B+1:U.getTime()>=N.getTime()?B:B-1}function startOfWeekYear(e,t){var n,r,l,s,c,o,d,u;requiredArgs(1,arguments);var U=getDefaultOptions(),B=toInteger((n=(r=(l=(s=t==null?void 0:t.firstWeekContainsDate)!==null&&s!==void 0?s:t==null||(c=t.locale)===null||c===void 0||(o=c.options)===null||o===void 0?void 0:o.firstWeekContainsDate)!==null&&l!==void 0?l:U.firstWeekContainsDate)!==null&&r!==void 0?r:(d=U.locale)===null||d===void 0||(u=d.options)===null||u===void 0?void 0:u.firstWeekContainsDate)!==null&&n!==void 0?n:1),R=getWeekYear(e,t),p=new Date(0);p.setFullYear(R,0,B),p.setHours(0,0,0,0);var g=startOfWeek(p,t);return g}var MILLISECONDS_IN_WEEK=6048e5;function getWeek(e,t){requiredArgs(1,arguments);var n=toDate(e),r=startOfWeek(n,t).getTime()-startOfWeekYear(n,t).getTime();return Math.round(r/MILLISECONDS_IN_WEEK)+1}function getYear(e){return requiredArgs(1,arguments),toDate(e).getFullYear()}function startOfHour(e){requiredArgs(1,arguments);var t=toDate(e);return t.setMinutes(0,0,0),t}function subDays(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addDays(e,-n)}function roundToNearestMinutes(e,t){var n;if(arguments.length<1)throw new TypeError("1 argument required, but only none provided present");var r=toInteger((n=t==null?void 0:t.nearestTo)!==null&&n!==void 0?n:1);if(r<1||r>30)throw new RangeError("`options.nearestTo` must be between 1 and 30");var l=toDate(e),s=l.getSeconds(),c=l.getMinutes()+s/60,o=getRoundingMethod(t==null?void 0:t.roundingMethod),d=o(c/r)*r,u=c%r,U=Math.round(u/r)*r;return new Date(l.getFullYear(),l.getMonth(),l.getDate(),l.getHours(),d+U)}function subMonths(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMonths(e,-n)}function subHours(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addHours(e,-n)}function subMinutes(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMinutes(e,-n)}function subQuarters(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addQuarters(e,-n)}function subWeeks(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addWeeks(e,-n)}function subYears(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addYears(e,-n)}const millisecond$2=1,second$2=1e3,minute$2=60*second$2,hour$2=60*minute$2,day$2=24*hour$2,week$2=7*day$2,month$2=30*day$2,year$2=365*day$2,duration$2={millisecond:millisecond$2,second:second$2,minute:minute$2,hour:hour$2,day:day$2,week:week$2,month:month$2,year:year$2};function filterDataByType$1(e,t){return e.filter(n=>t.includes(n.type))}function filterDataByTime$1(e,t,n){const r=t.getTime(),l=n.getTime();return e.map(s=>({...s,points:s.points.filter(([c])=>c>=r&&c<l)})).filter(({points:s})=>s.length>0)}let StoreCache$1=class{constructor({capacity:t,timeout:n}={}){Fe(this,"entries",new Map);Fe(this,"metadata",new Map);Fe(this,"capacity");Fe(this,"staleIntervalMs");this.capacity=t||1e4,this.staleIntervalMs=n||duration$2.minute}get(t,n){const r=this.keyToCacheKey(t);return this.isStale(r)&&!this.isGenerating(r)&&n&&this.generate(t,n),this.entries.get(r)}set(t,n){const r=this.keyToCacheKey(t);this.metadata.set(r,{generating:!1,staleAt:performance.now()+this.staleIntervalMs});const l=this.entries.get(r);JSON.stringify(l)===JSON.stringify(n)||(this.entries.set(r,n),this.enforceMaxSize())}clear(){this.entries.clear(),[...this.metadata.values()].forEach(t=>t.generating=!1)}clearKey(t){this.metadata.delete(t),this.entries.delete(t)}keyToCacheKey(t){return JSON.stringify(t)}enforceMaxSize(){for(;this.metadata.size>this.capacity&&this.metadata.size>0;){const[t]=[...this.metadata.entries()].reduce(([n,r],[l,s])=>s.staleAt<r.staleAt?[l,s]:[n,r]);this.clearKey(t)}}isStale(t){const n=this.metadata.get(t);return n?(n==null?void 0:n.staleAt)<performance.now():!0}isGenerating(t){const n=this.metadata.get(t);return n?n.generating:!1}generate(t,n){const r=this.keyToCacheKey(t),l=this.metadata.get(r)||{},s=n().then(c=>{const o=this.metadata.get(r);return(o==null?void 0:o.generating)!==s||this.set(t,c),c}).catch(c=>{throw this.metadata.delete(r),c});this.metadata.set(r,{...l,generating:s,staleAt:performance.now()+this.staleIntervalMs})}};async function queryTelemetry(e){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/queries/queries`,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}let QueryStore$1=class{constructor(){Fe(this,"queryStoreCache",new StoreCache$1({capacity:1e4,timeout:20*duration$2.second}));Fe(this,"liveQueryStoreCache",new StoreCache$1({capacity:1e4,timeout:200*duration$2.millisecond}))}moduleQuery(t,n,r,l,s,c=!1){const o={...t,names:[...n],types:[...r]},d=this.query(o,l,s,c);return d===void 0||d==="too much data"?d:filterDataByType$1(d,r)}query(t,n,r,l=!1){const s={...t,start:startOfMinute(n).toISOString(),end:l?r.toISOString():addMinutes(roundToNearestMinutes(r),1).toISOString(),latestOnly:l},c=r>addSeconds(new Date,-20);let o;return c?o=this.liveQueryCache(s):o=this.queryCache(s),!o||o==="too much data"||l?o:filterDataByTime$1(o,n,r)}queryCache(t){return this.queryStoreCache.get(t,async()=>{try{return await queryTelemetry(t)}catch(n){throw n}})}liveQueryCache(t){return this.liveQueryStoreCache.get(t,async()=>{try{return await queryTelemetry(t)}catch(n){throw n}})}};const queryStore=new QueryStore$1;function addStreamListener(e,t,n){const r=l=>{const s=l.data;if(s.type==="module_data"){const{start:c,end:o}=s.queryRange;n(queryStore.moduleQuery({},e,t,new Date(c),new Date(o),!1))}};return window.addEventListener("message",r),()=>window.removeEventListener("message",r)}async function getDate(e,t,n){return new Promise(r=>{sendAppMessage({type:"request_date",minTime:t,maxTime:n,time:e});const l=s=>{const c=s.data;c.type==="date_response"&&(window.removeEventListener("message",l),r(c.data))};window.addEventListener("message",l)})}async function prompt(e,t){return new Promise(n=>{const r=Math.random().toString();sendAppMessage({type:"prompt",promptId:r,schema:e,okText:t==null?void 0:t.okText,cancelText:t==null?void 0:t.cancelText});const l=s=>{const c=s.data;c.type==="prompt_response"&&c.promptId===r&&n(c.data),window.removeEventListener("message",l)};window.addEventListener("message",l)})}const Ht=class{static isModule(){return getCurrentModuleContext()!==null}static async getCurrentModuleConfiguration(){let t=new URLSearchParams("");typeof window!="undefined"&&window.location&&(t=new URLSearchParams(window.location.search));const n=t.get("configuration");if(!(n===null||n.trim()===""))return getModuleConfiguration(n.trim())}static get isOnline(){return Ht._isOnline}static listenForConnectionEvents(){const t=n=>{const{data:r}=n;r.type==="formant_online"&&(this._isOnline=r.online)};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}static checkConnection(t=1e3){return new Promise((n,r)=>{const l=setTimeout(()=>r(new Error("deadline expired: took too long")),t),s=c=>{window.removeEventListener("message",s),clearTimeout(l);const{data:o}=c;o.type==="formant_online"&&(this._isOnline=o.online,n(o.online))};window.addEventListener("message",s),sendAppMessage({type:"formant_online"})})}static waitForConnection(t=5e3){let n=!1;const r=new Promise((c,o)=>{setTimeout(()=>{n=!0,o(new Error("deadline expired: took too long"))},t)}),l=c=>new Promise(o=>setTimeout(o,c)),s=async()=>{for(await l(50);!n&&!(this.isOnline||await this.checkConnection);)await l(500)};return Promise.race([r,s()])}};let App=Ht;Fe(App,"getCurrentModuleContext",getCurrentModuleContext),Fe(App,"disableAnalyticsBottomBar",disableAnalyticsBottomBar),Fe(App,"goToDevice",goToDevice),Fe(App,"goToTime",goToTime),Fe(App,"refreshAuthToken",refreshAuthToken),Fe(App,"requestModuleData",requestModuleData),Fe(App,"sendChannelData",sendChannelData),Fe(App,"setModuleDateTimeRange",setModuleDateTimeRange),Fe(App,"setupModuleMenus",setupModuleMenus),Fe(App,"showMessage",showMessage),Fe(App,"addAccessTokenRefreshListener",addAccessTokenRefreshListener),Fe(App,"addChannelDataListener",addChannelDataListener),Fe(App,"addMenuListener",addMenuListener),Fe(App,"addModuleConfigurationListener",addModuleConfigurationListener),Fe(App,"addModuleDataListener",addModuleDataListener),Fe(App,"addOverviewDeviceListener",addOverviewDeviceListener),Fe(App,"addStreamListener",addStreamListener),Fe(App,"getDate",getDate),Fe(App,"prompt",prompt),Fe(App,"_isOnline",null);function defined$1(e,t){if(e!==void 0)return e;throw new Error(t||"Value is undefined")}function notNull(e,t){if(e!==null)return e;throw new Error(t||"Value is null")}function definedAndNotNull(e,t){return notNull(defined$1(e,t),t)}var dist={exports:{}};/*! For license information please see index.js.LICENSE.txt */(function(module,exports){(function(e,t){module.exports=t()})(window,function(){return function(e){function t(u){for(var U,B,R=u[0],p=u[1],g=0,h=[];g<R.length;g++)B=R[g],Object.prototype.hasOwnProperty.call(r,B)&&r[B]&&h.push(r[B][0]),r[B]=0;for(U in p)Object.prototype.hasOwnProperty.call(p,U)&&(e[U]=p[U]);for(d&&d(u);h.length;)h.shift()()}var n={},r={0:0};function l(u){if(n[u])return n[u].exports;var U=n[u]={i:u,l:!1,exports:{}};return e[u].call(U.exports,U,U.exports,l),U.l=!0,U.exports}l.e=function(){return Promise.resolve()},l.m=e,l.c=n,l.d=function(u,U,B){l.o(u,U)||Object.defineProperty(u,U,{enumerable:!0,get:B})},l.r=function(u){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(u,"__esModule",{value:!0})},l.t=function(u,U){if(1&U&&(u=l(u)),8&U||4&U&&typeof u=="object"&&u&&u.__esModule)return u;var B=Object.create(null);if(l.r(B),Object.defineProperty(B,"default",{enumerable:!0,value:u}),2&U&&typeof u!="string")for(var R in u)l.d(B,R,function(p){return u[p]}.bind(null,R));return B},l.n=function(u){var U=u&&u.__esModule?function(){return u.default}:function(){return u};return l.d(U,"a",U),U},l.o=function(u,U){return Object.prototype.hasOwnProperty.call(u,U)},l.p="",l.oe=function(u){throw console.error(u),u};var s=window.webpackJsonpFormantRealtimeSDK=window.webpackJsonpFormantRealtimeSDK||[],c=s.push.bind(s);s.push=t,s=s.slice();for(var o=0;o<s.length;o++)t(s[o]);var d=c;return l(l.s=232)}([function(e,t,n){n.d(t,"a",function(){return _});var r=n(16),l=n(55),s=n(15),c=n.n(s),o=n(18);function d(X,H){if(H.length<X)throw new TypeError(X+" argument"+(X>1?"s":"")+" required, but only "+H.length+" present")}function u(X){if(X===null||X===!0||X===!1)return NaN;var H=Number(X);return isNaN(H)?H:H<0?Math.ceil(H):Math.floor(H)}var U={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},B=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,R=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,p=/^([+-])(\d{2})(?::?(\d{2}))?$/;function g(X){var H,ne={},ie=X.split(U.dateTimeDelimiter);if(ie.length>2)return ne;if(/:/.test(ie[0])?H=ie[0]:(ne.date=ie[0],H=ie[1],U.timeZoneDelimiter.test(ne.date)&&(ne.date=X.split(U.timeZoneDelimiter)[0],H=X.substr(ne.date.length,X.length))),H){var ce=U.timezone.exec(H);ce?(ne.time=H.replace(ce[1],""),ne.timezone=ce[1]):ne.time=H}return ne}function h(X,H){var ne=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+H)+"})|(\\d{2}|[+-]\\d{"+(2+H)+"})$)"),ie=X.match(ne);if(!ie)return{year:NaN,restDateString:""};var ce=ie[1]?parseInt(ie[1]):null,Se=ie[2]?parseInt(ie[2]):null;return{year:Se===null?ce:100*Se,restDateString:X.slice((ie[1]||ie[2]).length)}}function m(X,H){if(H===null)return new Date(NaN);var ne=X.match(B);if(!ne)return new Date(NaN);var ie=!!ne[4],ce=N(ne[1]),Se=N(ne[2])-1,Te=N(ne[3]),ye=N(ne[4]),we=N(ne[5])-1;if(ie)return function(Ee,_e,Ae){return _e>=1&&_e<=53&&Ae>=0&&Ae<=6}(0,ye,we)?function(Ee,_e,Ae){var Le=new Date(0);Le.setUTCFullYear(Ee,0,4);var et=Le.getUTCDay()||7,Qt=7*(_e-1)+Ae+1-et;return Le.setUTCDate(Le.getUTCDate()+Qt),Le}(H,ye,we):new Date(NaN);var be=new Date(0);return function(Ee,_e,Ae){return _e>=0&&_e<=11&&Ae>=1&&Ae<=(F[_e]||(v(Ee)?29:28))}(H,Se,Te)&&function(Ee,_e){return _e>=1&&_e<=(v(Ee)?366:365)}(H,ce)?(be.setUTCFullYear(H,Se,Math.max(ce,Te)),be):new Date(NaN)}function N(X){return X?parseInt(X):1}function D(X){var H=X.match(R);if(!H)return NaN;var ne=y(H[1]),ie=y(H[2]),ce=y(H[3]);return function(Se,Te,ye){return Se===24?Te===0&&ye===0:ye>=0&&ye<60&&Te>=0&&Te<60&&Se>=0&&Se<25}(ne,ie,ce)?36e5*ne+6e4*ie+1e3*ce:NaN}function y(X){return X&&parseFloat(X.replace(",","."))||0}function b(X){if(X==="Z")return 0;var H=X.match(p);if(!H)return 0;var ne=H[1]==="+"?-1:1,ie=parseInt(H[2]),ce=H[3]&&parseInt(H[3])||0;return function(Se,Te){return Te>=0&&Te<=59}(0,ce)?ne*(36e5*ie+6e4*ce):NaN}var F=[31,null,31,30,31,30,31,31,30,31,30,31];function v(X){return X%400==0||X%4==0&&X%100!=0}function j(X){return(j=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(H){return typeof H}:function(H){return H&&typeof Symbol=="function"&&H.constructor===Symbol&&H!==Symbol.prototype?"symbol":typeof H})(X)}function K(X){return d(1,arguments),X instanceof Date||j(X)==="object"&&Object.prototype.toString.call(X)==="[object Date]"}function f(X){return(f=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(H){return typeof H}:function(H){return H&&typeof Symbol=="function"&&H.constructor===Symbol&&H!==Symbol.prototype?"symbol":typeof H})(X)}function Q(X){d(1,arguments);var H=Object.prototype.toString.call(X);return X instanceof Date||f(X)==="object"&&H==="[object Date]"?new Date(X.getTime()):typeof X=="number"||H==="[object Number]"?new Date(X):(typeof X!="string"&&H!=="[object String]"||typeof console=="undefined"||(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}function P(X){const H=function(ne,ie){var ce;d(1,arguments);var Se=u((ce=ie==null?void 0:ie.additionalDigits)!==null&&ce!==void 0?ce:2);if(Se!==2&&Se!==1&&Se!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(typeof ne!="string"&&Object.prototype.toString.call(ne)!=="[object String]")return new Date(NaN);var Te,ye=g(ne);if(ye.date){var we=h(ye.date,Se);Te=m(we.restDateString,we.year)}if(!Te||isNaN(Te.getTime()))return new Date(NaN);var be,Ee=Te.getTime(),_e=0;if(ye.time&&(_e=D(ye.time),isNaN(_e)))return new Date(NaN);if(!ye.timezone){var Ae=new Date(Ee+_e),Le=new Date(0);return Le.setFullYear(Ae.getUTCFullYear(),Ae.getUTCMonth(),Ae.getUTCDate()),Le.setHours(Ae.getUTCHours(),Ae.getUTCMinutes(),Ae.getUTCSeconds(),Ae.getUTCMilliseconds()),Le}return be=b(ye.timezone),isNaN(be)?new Date(NaN):new Date(Ee+_e+be)}(X);if(!function(ne){if(d(1,arguments),!K(ne)&&typeof ne!="number")return!1;var ie=Q(ne);return!isNaN(Number(ie))}(H))throw new Error(`Invalid ISO 8601 date string (${X})`);return H}const w=Math.pow(2,20),V=w;var I=n(4),W=n(28);function k(X){return c()(X,{cycles:!0})}var T=function(X,H){var ne={};for(var ie in X)Object.prototype.hasOwnProperty.call(X,ie)&&H.indexOf(ie)<0&&(ne[ie]=X[ie]);if(X!=null&&typeof Object.getOwnPropertySymbols=="function"){var ce=0;for(ie=Object.getOwnPropertySymbols(X);ce<ie.length;ce++)H.indexOf(ie[ce])<0&&Object.prototype.propertyIsEnumerable.call(X,ie[ce])&&(ne[ie[ce]]=X[ie[ce]])}return ne};function Z(X,H={}){const{redacted:ne=!0}=H,ie=we=>ne?Object(W.a)(we):we;if(!X.stack)return{message:k(ie(X))};const{name:ce,message:Se,stack:Te}=X,ye=T(X,["name","message","stack"]);return{name:ce,message:Se!==void 0?Se:k(ie(X)),stack:Te,meta:ye&&Object.keys(ye).length===0?void 0:ie(ye)}}function O(X,H={}){const{message:ne,stack:ie,meta:ce}=Z(X,H);return`${ie||ne||""}${ce&&Object.keys(ce).length>0?` -- ${k(ce)}`:""}`}var E=n(40),L=n(14),G=n.n(L),$=function(X,H,ne,ie){return new(ne||(ne=Promise))(function(ce,Se){function Te(be){try{we(ie.next(be))}catch(Ee){Se(Ee)}}function ye(be){try{we(ie.throw(be))}catch(Ee){Se(Ee)}}function we(be){var Ee;be.done?ce(be.value):(Ee=be.value,Ee instanceof ne?Ee:new ne(function(_e){_e(Ee)})).then(Te,ye)}we((ie=ie.apply(X,H||[])).next())})},ee=function(X,H){var ne={};for(var ie in X)Object.prototype.hasOwnProperty.call(X,ie)&&H.indexOf(ie)<0&&(ne[ie]=X[ie]);if(X!=null&&typeof Object.getOwnPropertySymbols=="function"){var ce=0;for(ie=Object.getOwnPropertySymbols(X);ce<ie.length;ce++)H.indexOf(ie[ce])<0&&Object.prototype.propertyIsEnumerable.call(X,ie[ce])&&(ne[ie[ce]]=X[ie[ce]])}return ne};class te extends G.a{constructor(H,ne){super(),this.endpoint=H,this.metadata=ne,this.logClient=this.getLogClient()}getLogClient(){return $(this,void 0,void 0,function*(){const{LogClient:H}=yield Promise.resolve().then(n.bind(null,235));return new H(this.endpoint)})}log(H,ne){return $(this,void 0,void 0,function*(){const{level:ie,message:ce,error:Se}=H,Te=ee(H,["level","message","error"]);this.emit("logged");try{yield(yield this.logClient).log([{timestamp:new Date().toISOString(),level:ie,message:`${ce}`.substring(0,1e3),error:Se!==void 0?Z(Se):void 0,meta:Object.assign(Object.assign({},Te),this.metadata)}])}catch(ye){console.error(`Failed to log to log-api: ${O(ye)}`)}ne()})}}var M=function(X,H){var ne={};for(var ie in X)Object.prototype.hasOwnProperty.call(X,ie)&&H.indexOf(ie)<0&&(ne[ie]=X[ie]);if(X!=null&&typeof Object.getOwnPropertySymbols=="function"){var ce=0;for(ie=Object.getOwnPropertySymbols(X);ce<ie.length;ce++)H.indexOf(ie[ce])<0&&Object.prototype.propertyIsEnumerable.call(X,ie[ce])&&(ne[ie[ce]]=X[ie[ce]])}return ne};const C={app:I.a,namespace:I.i,buildTag:I.b,instanceId:E.a},S=I.e?o.format.printf(X=>{var{timestamp:H,level:ne,message:ie,error:ce}=X,Se=M(X,["timestamp","level","message","error"]);const Te=Object.assign(Object.assign({timestamp:H?P(H).getTime():new Date().getTime(),level:ne.toUpperCase(),message:ie},ce?{error:Z(ce)}:{}),{meta:Object.assign(Object.assign({},C),Se)});return c()(Te,{cycles:!0})}):o.format.printf(X=>{var{timestamp:H,level:ne,message:ie,error:ce}=X,Se=M(X,["timestamp","level","message","error"]);let Te=`${H||new Date().toISOString()} ${ne.toUpperCase()}: ${ie} `;return Object.keys(Se).length>0&&(Te+=c()(Se,{cycles:!0})),ce&&(Te+=`
|
|
2
2
|
${O(ce)}`),Te}),_=Object(o.createLogger)({level:I.f});if(_.add(new o.transports.Console({format:S,level:"debug"})),_.transports.forEach(X=>{X.silent=!I.g}),I.d&&_.add(new te(I.d,C)),I.h){const X=l.resolve(r.tmpdir(),`silly-${I.a}.log`);_.debug("Logging silly logs to file",{filename:X}),_.add(new o.transports.File({filename:X,maxsize:1*V,maxFiles:10,format:o.format.combine((z="silly",Object(o.format)(H=>H.level===z&&H)()),S),level:"silly"}))}var z},function(e,t,n){n.d(t,"a",function(){return r});const r={millisecond:1,second:1e3,minute:6e4,hour:36e5,day:864e5,week:6048e5,month:2592e6,year:31536e6}},function(e,t){var n,r,l=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function c(){throw new Error("clearTimeout has not been defined")}function o(m){if(n===setTimeout)return setTimeout(m,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(m,0);try{return n(m,0)}catch{try{return n.call(null,m,0)}catch{return n.call(this,m,0)}}}(function(){try{n=typeof setTimeout=="function"?setTimeout:s}catch{n=s}try{r=typeof clearTimeout=="function"?clearTimeout:c}catch{r=c}})();var d,u=[],U=!1,B=-1;function R(){U&&d&&(U=!1,d.length?u=d.concat(u):B=-1,u.length&&p())}function p(){if(!U){var m=o(R);U=!0;for(var N=u.length;N;){for(d=u,u=[];++B<N;)d&&d[B].run();B=-1,N=u.length}d=null,U=!1,function(D){if(r===clearTimeout)return clearTimeout(D);if((r===c||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(D);try{r(D)}catch{try{return r.call(null,D)}catch{return r.call(this,D)}}}(m)}}function g(m,N){this.fun=m,this.array=N}function h(){}l.nextTick=function(m){var N=new Array(arguments.length-1);if(arguments.length>1)for(var D=1;D<arguments.length;D++)N[D-1]=arguments[D];u.push(new g(m,N)),u.length!==1||U||o(p)},g.prototype.run=function(){this.fun.apply(null,this.array)},l.title="browser",l.browser=!0,l.env={},l.argv=[],l.version="",l.versions={},l.on=h,l.addListener=h,l.once=h,l.off=h,l.removeListener=h,l.removeAllListeners=h,l.emit=h,l.prependListener=h,l.prependOnceListener=h,l.listeners=function(m){return[]},l.binding=function(m){throw new Error("process.binding is not supported")},l.cwd=function(){return"/"},l.chdir=function(m){throw new Error("process.chdir is not supported")},l.umask=function(){return 0}},function(e,t,n){Object.defineProperty(t,"LEVEL",{value:Symbol.for("level")}),Object.defineProperty(t,"MESSAGE",{value:Symbol.for("message")}),Object.defineProperty(t,"SPLAT",{value:Symbol.for("splat")}),Object.defineProperty(t,"configs",{value:n(116)})},function(e,t,n){(function(r){n.d(t,"a",function(){return c}),n.d(t,"i",function(){return o}),n.d(t,"j",function(){return d}),n.d(t,"b",function(){return u}),n.d(t,"f",function(){return U}),n.d(t,"e",function(){return B}),n.d(t,"g",function(){return R}),n.d(t,"d",function(){return p}),n.d(t,"c",function(){return g}),n.d(t,"h",function(){return h});var l=n(101);const s=l.from({ENVIRONMENT:r.env.ENV,AGGREGATE_LEVEL:r.env.AGGREGATE_LEVEL,API_ENDPOINT:r.env.API_ENDPOINT,APP:"realtime-sdk",APP_PATH:r.env.APP_PATH,BUILD_TAG:r.env.BUILD_TAG,ENABLE_SELF_SERVE:r.env.ENABLE_SELF_SERVE,ENABLE_SENTRY:r.env.ENABLE_SENTRY,ENABLE_SENTRY_PROFILING:r.env.ENABLE_SENTRY_PROFILING,GIT_COMMIT:r.env.GIT_COMMIT,JEST_WORKER_ID:r.env.JEST_WORKER_ID,LOG_API_ENDPOINT:r.env.LOG_API_ENDPOINT,LOG_JSON:"false",LOG_LEVEL:r.env.LOG_LEVEL,LOG_TO_CONSOLE:r.env.LOG_TO_CONSOLE,LOG_TO_FILE:r.env.LOG_TO_FILE,NAMESPACE:"production",SENTRY_DSN:r.env.SENTRY_DSN,SHEET_EXPORT_MAX_ROW_COUNT:r.env.SHEET_EXPORT_MAX_ROW_COUNT,STABLE_AGENT_VERSION:r.env.STABLE_AGENT_VERSION,VERSION:r.env.VERSION}),c=(s.get("ENVIRONMENT").default("").asString(),s.get("APP").default("").asString()),o=(s.get("APP_PATH").default("").asString(),s.get("API_ENDPOINT").default("").asString(),s.get("NAMESPACE").default("").asString()),d=s.get("VERSION").default("").asString(),u=s.get("BUILD_TAG").default("").asString(),U=(s.get("GIT_COMMIT").default("").asString(),s.get("ENABLE_SENTRY").default("false").asBool(),s.get("ENABLE_SENTRY_PROFILING").default("false").asBool(),s.get("SENTRY_DSN").default("").asString(),s.get("LOG_LEVEL").default("debug").asString()),B=s.get("LOG_JSON").default("true").asBool(),R=s.get("LOG_TO_CONSOLE").default("true").asBool(),p=(s.get("STABLE_AGENT_VERSION").default("").asString(),s.get("LOG_API_ENDPOINT").asString()),g=s.get("JEST_WORKER_ID").asString(),h=(s.get("SHEET_EXPORT_MAX_ROW_COUNT").default("10000").asIntPositive(),s.get("LOG_TO_FILE").default("false").asBoolStrict());s.get("ENABLE_SELF_SERVE").default("true").asBoolStrict(),s.get("AGGREGATE_LEVEL").default("hour").asEnum(["day","hour","minute"])}).call(this,n(2))},function(e,t,n){(function(r){var l=n(141),s=n(142),c=n(63);function o(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function d(S,_){if(o()<_)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(S=new Uint8Array(_)).__proto__=u.prototype:(S===null&&(S=new u(_)),S.length=_),S}function u(S,_,z){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(S,_,z);if(typeof S=="number"){if(typeof _=="string")throw new Error("If encoding is specified then the first argument must be a string");return R(this,S)}return U(this,S,_,z)}function U(S,_,z,X){if(typeof _=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer!="undefined"&&_ instanceof ArrayBuffer?function(H,ne,ie,ce){if(ne.byteLength,ie<0||ne.byteLength<ie)throw new RangeError("'offset' is out of bounds");if(ne.byteLength<ie+(ce||0))throw new RangeError("'length' is out of bounds");return ne=ie===void 0&&ce===void 0?new Uint8Array(ne):ce===void 0?new Uint8Array(ne,ie):new Uint8Array(ne,ie,ce),u.TYPED_ARRAY_SUPPORT?(H=ne).__proto__=u.prototype:H=p(H,ne),H}(S,_,z,X):typeof _=="string"?function(H,ne,ie){if(typeof ie=="string"&&ie!==""||(ie="utf8"),!u.isEncoding(ie))throw new TypeError('"encoding" must be a valid string encoding');var ce=0|h(ne,ie),Se=(H=d(H,ce)).write(ne,ie);return Se!==ce&&(H=H.slice(0,Se)),H}(S,_,z):function(H,ne){if(u.isBuffer(ne)){var ie=0|g(ne.length);return(H=d(H,ie)).length===0||ne.copy(H,0,0,ie),H}if(ne){if(typeof ArrayBuffer!="undefined"&&ne.buffer instanceof ArrayBuffer||"length"in ne)return typeof ne.length!="number"||(ce=ne.length)!=ce?d(H,0):p(H,ne);if(ne.type==="Buffer"&&c(ne.data))return p(H,ne.data)}var ce;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(S,_)}function B(S){if(typeof S!="number")throw new TypeError('"size" argument must be a number');if(S<0)throw new RangeError('"size" argument must not be negative')}function R(S,_){if(B(_),S=d(S,_<0?0:0|g(_)),!u.TYPED_ARRAY_SUPPORT)for(var z=0;z<_;++z)S[z]=0;return S}function p(S,_){var z=_.length<0?0:0|g(_.length);S=d(S,z);for(var X=0;X<z;X+=1)S[X]=255&_[X];return S}function g(S){if(S>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|S}function h(S,_){if(u.isBuffer(S))return S.length;if(typeof ArrayBuffer!="undefined"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(S)||S instanceof ArrayBuffer))return S.byteLength;typeof S!="string"&&(S=""+S);var z=S.length;if(z===0)return 0;for(var X=!1;;)switch(_){case"ascii":case"latin1":case"binary":return z;case"utf8":case"utf-8":case void 0:return te(S).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*z;case"hex":return z>>>1;case"base64":return M(S).length;default:if(X)return te(S).length;_=(""+_).toLowerCase(),X=!0}}function m(S,_,z){var X=!1;if((_===void 0||_<0)&&(_=0),_>this.length||((z===void 0||z>this.length)&&(z=this.length),z<=0)||(z>>>=0)<=(_>>>=0))return"";for(S||(S="utf8");;)switch(S){case"hex":return I(this,_,z);case"utf8":case"utf-8":return P(this,_,z);case"ascii":return w(this,_,z);case"latin1":case"binary":return V(this,_,z);case"base64":return Q(this,_,z);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return W(this,_,z);default:if(X)throw new TypeError("Unknown encoding: "+S);S=(S+"").toLowerCase(),X=!0}}function N(S,_,z){var X=S[_];S[_]=S[z],S[z]=X}function D(S,_,z,X,H){if(S.length===0)return-1;if(typeof z=="string"?(X=z,z=0):z>2147483647?z=2147483647:z<-2147483648&&(z=-2147483648),z=+z,isNaN(z)&&(z=H?0:S.length-1),z<0&&(z=S.length+z),z>=S.length){if(H)return-1;z=S.length-1}else if(z<0){if(!H)return-1;z=0}if(typeof _=="string"&&(_=u.from(_,X)),u.isBuffer(_))return _.length===0?-1:y(S,_,z,X,H);if(typeof _=="number")return _&=255,u.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?H?Uint8Array.prototype.indexOf.call(S,_,z):Uint8Array.prototype.lastIndexOf.call(S,_,z):y(S,[_],z,X,H);throw new TypeError("val must be string, number or Buffer")}function y(S,_,z,X,H){var ne,ie=1,ce=S.length,Se=_.length;if(X!==void 0&&((X=String(X).toLowerCase())==="ucs2"||X==="ucs-2"||X==="utf16le"||X==="utf-16le")){if(S.length<2||_.length<2)return-1;ie=2,ce/=2,Se/=2,z/=2}function Te(Ee,_e){return ie===1?Ee[_e]:Ee.readUInt16BE(_e*ie)}if(H){var ye=-1;for(ne=z;ne<ce;ne++)if(Te(S,ne)===Te(_,ye===-1?0:ne-ye)){if(ye===-1&&(ye=ne),ne-ye+1===Se)return ye*ie}else ye!==-1&&(ne-=ne-ye),ye=-1}else for(z+Se>ce&&(z=ce-Se),ne=z;ne>=0;ne--){for(var we=!0,be=0;be<Se;be++)if(Te(S,ne+be)!==Te(_,be)){we=!1;break}if(we)return ne}return-1}function b(S,_,z,X){z=Number(z)||0;var H=S.length-z;X?(X=Number(X))>H&&(X=H):X=H;var ne=_.length;if(ne%2!=0)throw new TypeError("Invalid hex string");X>ne/2&&(X=ne/2);for(var ie=0;ie<X;++ie){var ce=parseInt(_.substr(2*ie,2),16);if(isNaN(ce))return ie;S[z+ie]=ce}return ie}function F(S,_,z,X){return C(te(_,S.length-z),S,z,X)}function v(S,_,z,X){return C(function(H){for(var ne=[],ie=0;ie<H.length;++ie)ne.push(255&H.charCodeAt(ie));return ne}(_),S,z,X)}function j(S,_,z,X){return v(S,_,z,X)}function K(S,_,z,X){return C(M(_),S,z,X)}function f(S,_,z,X){return C(function(H,ne){for(var ie,ce,Se,Te=[],ye=0;ye<H.length&&!((ne-=2)<0);++ye)ie=H.charCodeAt(ye),ce=ie>>8,Se=ie%256,Te.push(Se),Te.push(ce);return Te}(_,S.length-z),S,z,X)}function Q(S,_,z){return _===0&&z===S.length?l.fromByteArray(S):l.fromByteArray(S.slice(_,z))}function P(S,_,z){z=Math.min(S.length,z);for(var X=[],H=_;H<z;){var ne,ie,ce,Se,Te=S[H],ye=null,we=Te>239?4:Te>223?3:Te>191?2:1;if(H+we<=z)switch(we){case 1:Te<128&&(ye=Te);break;case 2:(192&(ne=S[H+1]))==128&&(Se=(31&Te)<<6|63&ne)>127&&(ye=Se);break;case 3:ne=S[H+1],ie=S[H+2],(192&ne)==128&&(192&ie)==128&&(Se=(15&Te)<<12|(63&ne)<<6|63&ie)>2047&&(Se<55296||Se>57343)&&(ye=Se);break;case 4:ne=S[H+1],ie=S[H+2],ce=S[H+3],(192&ne)==128&&(192&ie)==128&&(192&ce)==128&&(Se=(15&Te)<<18|(63&ne)<<12|(63&ie)<<6|63&ce)>65535&&Se<1114112&&(ye=Se)}ye===null?(ye=65533,we=1):ye>65535&&(ye-=65536,X.push(ye>>>10&1023|55296),ye=56320|1023&ye),X.push(ye),H+=we}return function(be){var Ee=be.length;if(Ee<=4096)return String.fromCharCode.apply(String,be);for(var _e="",Ae=0;Ae<Ee;)_e+=String.fromCharCode.apply(String,be.slice(Ae,Ae+=4096));return _e}(X)}t.Buffer=u,t.SlowBuffer=function(S){return+S!=S&&(S=0),u.alloc(+S)},t.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=r.TYPED_ARRAY_SUPPORT!==void 0?r.TYPED_ARRAY_SUPPORT:function(){try{var S=new Uint8Array(1);return S.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},S.foo()===42&&typeof S.subarray=="function"&&S.subarray(1,1).byteLength===0}catch{return!1}}(),t.kMaxLength=o(),u.poolSize=8192,u._augment=function(S){return S.__proto__=u.prototype,S},u.from=function(S,_,z){return U(null,S,_,z)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,typeof Symbol!="undefined"&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(S,_,z){return function(X,H,ne,ie){return B(H),H<=0?d(X,H):ne!==void 0?typeof ie=="string"?d(X,H).fill(ne,ie):d(X,H).fill(ne):d(X,H)}(null,S,_,z)},u.allocUnsafe=function(S){return R(null,S)},u.allocUnsafeSlow=function(S){return R(null,S)},u.isBuffer=function(S){return!(S==null||!S._isBuffer)},u.compare=function(S,_){if(!u.isBuffer(S)||!u.isBuffer(_))throw new TypeError("Arguments must be Buffers");if(S===_)return 0;for(var z=S.length,X=_.length,H=0,ne=Math.min(z,X);H<ne;++H)if(S[H]!==_[H]){z=S[H],X=_[H];break}return z<X?-1:X<z?1:0},u.isEncoding=function(S){switch(String(S).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(S,_){if(!c(S))throw new TypeError('"list" argument must be an Array of Buffers');if(S.length===0)return u.alloc(0);var z;if(_===void 0)for(_=0,z=0;z<S.length;++z)_+=S[z].length;var X=u.allocUnsafe(_),H=0;for(z=0;z<S.length;++z){var ne=S[z];if(!u.isBuffer(ne))throw new TypeError('"list" argument must be an Array of Buffers');ne.copy(X,H),H+=ne.length}return X},u.byteLength=h,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var S=this.length;if(S%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var _=0;_<S;_+=2)N(this,_,_+1);return this},u.prototype.swap32=function(){var S=this.length;if(S%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var _=0;_<S;_+=4)N(this,_,_+3),N(this,_+1,_+2);return this},u.prototype.swap64=function(){var S=this.length;if(S%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var _=0;_<S;_+=8)N(this,_,_+7),N(this,_+1,_+6),N(this,_+2,_+5),N(this,_+3,_+4);return this},u.prototype.toString=function(){var S=0|this.length;return S===0?"":arguments.length===0?P(this,0,S):m.apply(this,arguments)},u.prototype.equals=function(S){if(!u.isBuffer(S))throw new TypeError("Argument must be a Buffer");return this===S||u.compare(this,S)===0},u.prototype.inspect=function(){var S="",_=t.INSPECT_MAX_BYTES;return this.length>0&&(S=this.toString("hex",0,_).match(/.{2}/g).join(" "),this.length>_&&(S+=" ... ")),"<Buffer "+S+">"},u.prototype.compare=function(S,_,z,X,H){if(!u.isBuffer(S))throw new TypeError("Argument must be a Buffer");if(_===void 0&&(_=0),z===void 0&&(z=S?S.length:0),X===void 0&&(X=0),H===void 0&&(H=this.length),_<0||z>S.length||X<0||H>this.length)throw new RangeError("out of range index");if(X>=H&&_>=z)return 0;if(X>=H)return-1;if(_>=z)return 1;if(this===S)return 0;for(var ne=(H>>>=0)-(X>>>=0),ie=(z>>>=0)-(_>>>=0),ce=Math.min(ne,ie),Se=this.slice(X,H),Te=S.slice(_,z),ye=0;ye<ce;++ye)if(Se[ye]!==Te[ye]){ne=Se[ye],ie=Te[ye];break}return ne<ie?-1:ie<ne?1:0},u.prototype.includes=function(S,_,z){return this.indexOf(S,_,z)!==-1},u.prototype.indexOf=function(S,_,z){return D(this,S,_,z,!0)},u.prototype.lastIndexOf=function(S,_,z){return D(this,S,_,z,!1)},u.prototype.write=function(S,_,z,X){if(_===void 0)X="utf8",z=this.length,_=0;else if(z===void 0&&typeof _=="string")X=_,z=this.length,_=0;else{if(!isFinite(_))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");_|=0,isFinite(z)?(z|=0,X===void 0&&(X="utf8")):(X=z,z=void 0)}var H=this.length-_;if((z===void 0||z>H)&&(z=H),S.length>0&&(z<0||_<0)||_>this.length)throw new RangeError("Attempt to write outside buffer bounds");X||(X="utf8");for(var ne=!1;;)switch(X){case"hex":return b(this,S,_,z);case"utf8":case"utf-8":return F(this,S,_,z);case"ascii":return v(this,S,_,z);case"latin1":case"binary":return j(this,S,_,z);case"base64":return K(this,S,_,z);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return f(this,S,_,z);default:if(ne)throw new TypeError("Unknown encoding: "+X);X=(""+X).toLowerCase(),ne=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function w(S,_,z){var X="";z=Math.min(S.length,z);for(var H=_;H<z;++H)X+=String.fromCharCode(127&S[H]);return X}function V(S,_,z){var X="";z=Math.min(S.length,z);for(var H=_;H<z;++H)X+=String.fromCharCode(S[H]);return X}function I(S,_,z){var X=S.length;(!_||_<0)&&(_=0),(!z||z<0||z>X)&&(z=X);for(var H="",ne=_;ne<z;++ne)H+=ee(S[ne]);return H}function W(S,_,z){for(var X=S.slice(_,z),H="",ne=0;ne<X.length;ne+=2)H+=String.fromCharCode(X[ne]+256*X[ne+1]);return H}function k(S,_,z){if(S%1!=0||S<0)throw new RangeError("offset is not uint");if(S+_>z)throw new RangeError("Trying to access beyond buffer length")}function T(S,_,z,X,H,ne){if(!u.isBuffer(S))throw new TypeError('"buffer" argument must be a Buffer instance');if(_>H||_<ne)throw new RangeError('"value" argument is out of bounds');if(z+X>S.length)throw new RangeError("Index out of range")}function Z(S,_,z,X){_<0&&(_=65535+_+1);for(var H=0,ne=Math.min(S.length-z,2);H<ne;++H)S[z+H]=(_&255<<8*(X?H:1-H))>>>8*(X?H:1-H)}function O(S,_,z,X){_<0&&(_=4294967295+_+1);for(var H=0,ne=Math.min(S.length-z,4);H<ne;++H)S[z+H]=_>>>8*(X?H:3-H)&255}function E(S,_,z,X,H,ne){if(z+X>S.length)throw new RangeError("Index out of range");if(z<0)throw new RangeError("Index out of range")}function L(S,_,z,X,H){return H||E(S,0,z,4),s.write(S,_,z,X,23,4),z+4}function G(S,_,z,X,H){return H||E(S,0,z,8),s.write(S,_,z,X,52,8),z+8}u.prototype.slice=function(S,_){var z,X=this.length;if((S=~~S)<0?(S+=X)<0&&(S=0):S>X&&(S=X),(_=_===void 0?X:~~_)<0?(_+=X)<0&&(_=0):_>X&&(_=X),_<S&&(_=S),u.TYPED_ARRAY_SUPPORT)(z=this.subarray(S,_)).__proto__=u.prototype;else{var H=_-S;z=new u(H,void 0);for(var ne=0;ne<H;++ne)z[ne]=this[ne+S]}return z},u.prototype.readUIntLE=function(S,_,z){S|=0,_|=0,z||k(S,_,this.length);for(var X=this[S],H=1,ne=0;++ne<_&&(H*=256);)X+=this[S+ne]*H;return X},u.prototype.readUIntBE=function(S,_,z){S|=0,_|=0,z||k(S,_,this.length);for(var X=this[S+--_],H=1;_>0&&(H*=256);)X+=this[S+--_]*H;return X},u.prototype.readUInt8=function(S,_){return _||k(S,1,this.length),this[S]},u.prototype.readUInt16LE=function(S,_){return _||k(S,2,this.length),this[S]|this[S+1]<<8},u.prototype.readUInt16BE=function(S,_){return _||k(S,2,this.length),this[S]<<8|this[S+1]},u.prototype.readUInt32LE=function(S,_){return _||k(S,4,this.length),(this[S]|this[S+1]<<8|this[S+2]<<16)+16777216*this[S+3]},u.prototype.readUInt32BE=function(S,_){return _||k(S,4,this.length),16777216*this[S]+(this[S+1]<<16|this[S+2]<<8|this[S+3])},u.prototype.readIntLE=function(S,_,z){S|=0,_|=0,z||k(S,_,this.length);for(var X=this[S],H=1,ne=0;++ne<_&&(H*=256);)X+=this[S+ne]*H;return X>=(H*=128)&&(X-=Math.pow(2,8*_)),X},u.prototype.readIntBE=function(S,_,z){S|=0,_|=0,z||k(S,_,this.length);for(var X=_,H=1,ne=this[S+--X];X>0&&(H*=256);)ne+=this[S+--X]*H;return ne>=(H*=128)&&(ne-=Math.pow(2,8*_)),ne},u.prototype.readInt8=function(S,_){return _||k(S,1,this.length),128&this[S]?-1*(255-this[S]+1):this[S]},u.prototype.readInt16LE=function(S,_){_||k(S,2,this.length);var z=this[S]|this[S+1]<<8;return 32768&z?4294901760|z:z},u.prototype.readInt16BE=function(S,_){_||k(S,2,this.length);var z=this[S+1]|this[S]<<8;return 32768&z?4294901760|z:z},u.prototype.readInt32LE=function(S,_){return _||k(S,4,this.length),this[S]|this[S+1]<<8|this[S+2]<<16|this[S+3]<<24},u.prototype.readInt32BE=function(S,_){return _||k(S,4,this.length),this[S]<<24|this[S+1]<<16|this[S+2]<<8|this[S+3]},u.prototype.readFloatLE=function(S,_){return _||k(S,4,this.length),s.read(this,S,!0,23,4)},u.prototype.readFloatBE=function(S,_){return _||k(S,4,this.length),s.read(this,S,!1,23,4)},u.prototype.readDoubleLE=function(S,_){return _||k(S,8,this.length),s.read(this,S,!0,52,8)},u.prototype.readDoubleBE=function(S,_){return _||k(S,8,this.length),s.read(this,S,!1,52,8)},u.prototype.writeUIntLE=function(S,_,z,X){S=+S,_|=0,z|=0,X||T(this,S,_,z,Math.pow(2,8*z)-1,0);var H=1,ne=0;for(this[_]=255&S;++ne<z&&(H*=256);)this[_+ne]=S/H&255;return _+z},u.prototype.writeUIntBE=function(S,_,z,X){S=+S,_|=0,z|=0,X||T(this,S,_,z,Math.pow(2,8*z)-1,0);var H=z-1,ne=1;for(this[_+H]=255&S;--H>=0&&(ne*=256);)this[_+H]=S/ne&255;return _+z},u.prototype.writeUInt8=function(S,_,z){return S=+S,_|=0,z||T(this,S,_,1,255,0),u.TYPED_ARRAY_SUPPORT||(S=Math.floor(S)),this[_]=255&S,_+1},u.prototype.writeUInt16LE=function(S,_,z){return S=+S,_|=0,z||T(this,S,_,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[_]=255&S,this[_+1]=S>>>8):Z(this,S,_,!0),_+2},u.prototype.writeUInt16BE=function(S,_,z){return S=+S,_|=0,z||T(this,S,_,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[_]=S>>>8,this[_+1]=255&S):Z(this,S,_,!1),_+2},u.prototype.writeUInt32LE=function(S,_,z){return S=+S,_|=0,z||T(this,S,_,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[_+3]=S>>>24,this[_+2]=S>>>16,this[_+1]=S>>>8,this[_]=255&S):O(this,S,_,!0),_+4},u.prototype.writeUInt32BE=function(S,_,z){return S=+S,_|=0,z||T(this,S,_,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[_]=S>>>24,this[_+1]=S>>>16,this[_+2]=S>>>8,this[_+3]=255&S):O(this,S,_,!1),_+4},u.prototype.writeIntLE=function(S,_,z,X){if(S=+S,_|=0,!X){var H=Math.pow(2,8*z-1);T(this,S,_,z,H-1,-H)}var ne=0,ie=1,ce=0;for(this[_]=255&S;++ne<z&&(ie*=256);)S<0&&ce===0&&this[_+ne-1]!==0&&(ce=1),this[_+ne]=(S/ie>>0)-ce&255;return _+z},u.prototype.writeIntBE=function(S,_,z,X){if(S=+S,_|=0,!X){var H=Math.pow(2,8*z-1);T(this,S,_,z,H-1,-H)}var ne=z-1,ie=1,ce=0;for(this[_+ne]=255&S;--ne>=0&&(ie*=256);)S<0&&ce===0&&this[_+ne+1]!==0&&(ce=1),this[_+ne]=(S/ie>>0)-ce&255;return _+z},u.prototype.writeInt8=function(S,_,z){return S=+S,_|=0,z||T(this,S,_,1,127,-128),u.TYPED_ARRAY_SUPPORT||(S=Math.floor(S)),S<0&&(S=255+S+1),this[_]=255&S,_+1},u.prototype.writeInt16LE=function(S,_,z){return S=+S,_|=0,z||T(this,S,_,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[_]=255&S,this[_+1]=S>>>8):Z(this,S,_,!0),_+2},u.prototype.writeInt16BE=function(S,_,z){return S=+S,_|=0,z||T(this,S,_,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[_]=S>>>8,this[_+1]=255&S):Z(this,S,_,!1),_+2},u.prototype.writeInt32LE=function(S,_,z){return S=+S,_|=0,z||T(this,S,_,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[_]=255&S,this[_+1]=S>>>8,this[_+2]=S>>>16,this[_+3]=S>>>24):O(this,S,_,!0),_+4},u.prototype.writeInt32BE=function(S,_,z){return S=+S,_|=0,z||T(this,S,_,4,2147483647,-2147483648),S<0&&(S=4294967295+S+1),u.TYPED_ARRAY_SUPPORT?(this[_]=S>>>24,this[_+1]=S>>>16,this[_+2]=S>>>8,this[_+3]=255&S):O(this,S,_,!1),_+4},u.prototype.writeFloatLE=function(S,_,z){return L(this,S,_,!0,z)},u.prototype.writeFloatBE=function(S,_,z){return L(this,S,_,!1,z)},u.prototype.writeDoubleLE=function(S,_,z){return G(this,S,_,!0,z)},u.prototype.writeDoubleBE=function(S,_,z){return G(this,S,_,!1,z)},u.prototype.copy=function(S,_,z,X){if(z||(z=0),X||X===0||(X=this.length),_>=S.length&&(_=S.length),_||(_=0),X>0&&X<z&&(X=z),X===z||S.length===0||this.length===0)return 0;if(_<0)throw new RangeError("targetStart out of bounds");if(z<0||z>=this.length)throw new RangeError("sourceStart out of bounds");if(X<0)throw new RangeError("sourceEnd out of bounds");X>this.length&&(X=this.length),S.length-_<X-z&&(X=S.length-_+z);var H,ne=X-z;if(this===S&&z<_&&_<X)for(H=ne-1;H>=0;--H)S[H+_]=this[H+z];else if(ne<1e3||!u.TYPED_ARRAY_SUPPORT)for(H=0;H<ne;++H)S[H+_]=this[H+z];else Uint8Array.prototype.set.call(S,this.subarray(z,z+ne),_);return ne},u.prototype.fill=function(S,_,z,X){if(typeof S=="string"){if(typeof _=="string"?(X=_,_=0,z=this.length):typeof z=="string"&&(X=z,z=this.length),S.length===1){var H=S.charCodeAt(0);H<256&&(S=H)}if(X!==void 0&&typeof X!="string")throw new TypeError("encoding must be a string");if(typeof X=="string"&&!u.isEncoding(X))throw new TypeError("Unknown encoding: "+X)}else typeof S=="number"&&(S&=255);if(_<0||this.length<_||this.length<z)throw new RangeError("Out of range index");if(z<=_)return this;var ne;if(_>>>=0,z=z===void 0?this.length:z>>>0,S||(S=0),typeof S=="number")for(ne=_;ne<z;++ne)this[ne]=S;else{var ie=u.isBuffer(S)?S:te(new u(S,X).toString()),ce=ie.length;for(ne=0;ne<z-_;++ne)this[ne+_]=ie[ne%ce]}return this};var $=/[^+\/0-9A-Za-z-_]/g;function ee(S){return S<16?"0"+S.toString(16):S.toString(16)}function te(S,_){var z;_=_||1/0;for(var X=S.length,H=null,ne=[],ie=0;ie<X;++ie){if((z=S.charCodeAt(ie))>55295&&z<57344){if(!H){if(z>56319){(_-=3)>-1&&ne.push(239,191,189);continue}if(ie+1===X){(_-=3)>-1&&ne.push(239,191,189);continue}H=z;continue}if(z<56320){(_-=3)>-1&&ne.push(239,191,189),H=z;continue}z=65536+(H-55296<<10|z-56320)}else H&&(_-=3)>-1&&ne.push(239,191,189);if(H=null,z<128){if((_-=1)<0)break;ne.push(z)}else if(z<2048){if((_-=2)<0)break;ne.push(z>>6|192,63&z|128)}else if(z<65536){if((_-=3)<0)break;ne.push(z>>12|224,z>>6&63|128,63&z|128)}else{if(!(z<1114112))throw new Error("Invalid code point");if((_-=4)<0)break;ne.push(z>>18|240,z>>12&63|128,z>>6&63|128,63&z|128)}}return ne}function M(S){return l.toByteArray(function(_){if((_=function(z){return z.trim?z.trim():z.replace(/^\s+|\s+$/g,"")}(_).replace($,"")).length<2)return"";for(;_.length%4!=0;)_+="=";return _}(S))}function C(S,_,z,X){for(var H=0;H<X&&!(H+z>=_.length||H>=S.length);++H)_[H+z]=S[H];return H}}).call(this,n(6))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch{typeof window=="object"&&(n=window)}e.exports=n},function(e,t){typeof Object.create=="function"?e.exports=function(n,r){r&&(n.super_=r,n.prototype=Object.create(r.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(n,r){if(r){n.super_=r;var l=function(){};l.prototype=r.prototype,n.prototype=new l,n.prototype.constructor=n}}},function(e,t,n){function r(R){return(r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(p){return typeof p}:function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p})(R)}function l(R,p){if(p&&(r(p)==="object"||typeof p=="function"))return p;if(p!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return s(R)}function s(R){if(R===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return R}function c(R){var p=typeof Map=="function"?new Map:void 0;return(c=function(g){if(g===null||(h=g,Function.toString.call(h).indexOf("[native code]")===-1))return g;var h;if(typeof g!="function")throw new TypeError("Super expression must either be null or a function");if(p!==void 0){if(p.has(g))return p.get(g);p.set(g,m)}function m(){return o(g,arguments,U(this).constructor)}return m.prototype=Object.create(g.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),u(m,g)})(R)}function o(R,p,g){return(o=d()?Reflect.construct.bind():function(h,m,N){var D=[null];D.push.apply(D,m);var y=new(Function.bind.apply(h,D));return N&&u(y,N.prototype),y}).apply(null,arguments)}function d(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function u(R,p){return(u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,h){return g.__proto__=h,g})(R,p)}function U(R){return(U=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(p){return p.__proto__||Object.getPrototypeOf(p)})(R)}var B=function(R){(function(D,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function");D.prototype=Object.create(y&&y.prototype,{constructor:{value:D,writable:!0,configurable:!0}}),Object.defineProperty(D,"prototype",{writable:!1}),y&&u(D,y)})(N,R);var p,g,h,m=(p=N,g=d(),function(){var D,y=U(p);if(g){var b=U(this).constructor;D=Reflect.construct(y,arguments,b)}else D=y.apply(this,arguments);return l(this,D)});function N(D){var y;return function(b,F){if(!(b instanceof F))throw new TypeError("Cannot call a class as a function")}(this,N),y=m.call(this,`Format functions must be synchronous taking a two arguments: (info, opts)
|
|
3
3
|
Found: `.concat(D.toString().split(`
|
|
4
4
|
`)[0],`
|