@openc3/js-common 6.6.0 → 6.8.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/services.cjs CHANGED
@@ -1,16 +1,16 @@
1
- "use strict";var Gt=Object.defineProperty;var Zt=(n,e,t)=>e in n?Gt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var L=(n,e,t)=>Zt(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function mt(n,e){return function(){return n.apply(e,arguments)}}const{toString:Qt}=Object.prototype,{getPrototypeOf:De}=Object,{iterator:de,toStringTag:gt}=Symbol,fe=(n=>e=>{const t=Qt.call(e);return n[t]||(n[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),$=n=>(n=n.toLowerCase(),e=>fe(e)===n),pe=n=>e=>typeof e===n,{isArray:K}=Array,Y=pe("undefined");function Yt(n){return n!==null&&!Y(n)&&n.constructor!==null&&!Y(n.constructor)&&T(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const bt=$("ArrayBuffer");function en(n){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(n):e=n&&n.buffer&&bt(n.buffer),e}const tn=pe("string"),T=pe("function"),yt=pe("number"),me=n=>n!==null&&typeof n=="object",nn=n=>n===!0||n===!1,ce=n=>{if(fe(n)!=="object")return!1;const e=De(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(gt in n)&&!(de in n)},sn=$("Date"),rn=$("File"),on=$("Blob"),cn=$("FileList"),an=n=>me(n)&&T(n.pipe),ln=n=>{let e;return n&&(typeof FormData=="function"&&n instanceof FormData||T(n.append)&&((e=fe(n))==="formdata"||e==="object"&&T(n.toString)&&n.toString()==="[object FormData]"))},un=$("URLSearchParams"),[hn,dn,fn,pn]=["ReadableStream","Request","Response","Headers"].map($),mn=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ee(n,e,{allOwnKeys:t=!1}={}){if(n===null||typeof n>"u")return;let s,r;if(typeof n!="object"&&(n=[n]),K(n))for(s=0,r=n.length;s<r;s++)e.call(null,n[s],s,n);else{const i=t?Object.getOwnPropertyNames(n):Object.keys(n),o=i.length;let c;for(s=0;s<o;s++)c=i[s],e.call(null,n[c],c,n)}}function wt(n,e){e=e.toLowerCase();const t=Object.keys(n);let s=t.length,r;for(;s-- >0;)if(r=t[s],e===r.toLowerCase())return r;return null}const H=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,_t=n=>!Y(n)&&n!==H;function ke(){const{caseless:n}=_t(this)&&this||{},e={},t=(s,r)=>{const i=n&&wt(e,r)||r;ce(e[i])&&ce(s)?e[i]=ke(e[i],s):ce(s)?e[i]=ke({},s):K(s)?e[i]=s.slice():e[i]=s};for(let s=0,r=arguments.length;s<r;s++)arguments[s]&&ee(arguments[s],t);return e}const gn=(n,e,t,{allOwnKeys:s}={})=>(ee(e,(r,i)=>{t&&T(r)?n[i]=mt(r,t):n[i]=r},{allOwnKeys:s}),n),bn=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),yn=(n,e,t,s)=>{n.prototype=Object.create(e.prototype,s),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:e.prototype}),t&&Object.assign(n.prototype,t)},wn=(n,e,t,s)=>{let r,i,o;const c={};if(e=e||{},n==null)return e;do{for(r=Object.getOwnPropertyNames(n),i=r.length;i-- >0;)o=r[i],(!s||s(o,n,e))&&!c[o]&&(e[o]=n[o],c[o]=!0);n=t!==!1&&De(n)}while(n&&(!t||t(n,e))&&n!==Object.prototype);return e},_n=(n,e,t)=>{n=String(n),(t===void 0||t>n.length)&&(t=n.length),t-=e.length;const s=n.indexOf(e,t);return s!==-1&&s===t},En=n=>{if(!n)return null;if(K(n))return n;let e=n.length;if(!yt(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=n[e];return t},Sn=(n=>e=>n&&e instanceof n)(typeof Uint8Array<"u"&&De(Uint8Array)),xn=(n,e)=>{const s=(n&&n[de]).call(n);let r;for(;(r=s.next())&&!r.done;){const i=r.value;e.call(n,i[0],i[1])}},Rn=(n,e)=>{let t;const s=[];for(;(t=n.exec(e))!==null;)s.push(t);return s},An=$("HTMLFormElement"),Cn=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,s,r){return s.toUpperCase()+r}),We=(({hasOwnProperty:n})=>(e,t)=>n.call(e,t))(Object.prototype),On=$("RegExp"),Et=(n,e)=>{const t=Object.getOwnPropertyDescriptors(n),s={};ee(t,(r,i)=>{let o;(o=e(r,i,n))!==!1&&(s[i]=o||r)}),Object.defineProperties(n,s)},Tn=n=>{Et(n,(e,t)=>{if(T(n)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const s=n[t];if(T(s)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},kn=(n,e)=>{const t={},s=r=>{r.forEach(i=>{t[i]=!0})};return K(n)?s(n):s(String(n).split(e)),t},Nn=()=>{},Pn=(n,e)=>n!=null&&Number.isFinite(n=+n)?n:e;function In(n){return!!(n&&T(n.append)&&n[gt]==="FormData"&&n[de])}const vn=n=>{const e=new Array(10),t=(s,r)=>{if(me(s)){if(e.indexOf(s)>=0)return;if(!("toJSON"in s)){e[r]=s;const i=K(s)?[]:{};return ee(s,(o,c)=>{const h=t(o,r+1);!Y(h)&&(i[c]=h)}),e[r]=void 0,i}}return s};return t(n,0)},Ln=$("AsyncFunction"),jn=n=>n&&(me(n)||T(n))&&T(n.then)&&T(n.catch),St=((n,e)=>n?setImmediate:e?((t,s)=>(H.addEventListener("message",({source:r,data:i})=>{r===H&&i===t&&s.length&&s.shift()()},!1),r=>{s.push(r),H.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",T(H.postMessage)),$n=typeof queueMicrotask<"u"?queueMicrotask.bind(H):typeof process<"u"&&process.nextTick||St,Fn=n=>n!=null&&T(n[de]),l={isArray:K,isArrayBuffer:bt,isBuffer:Yt,isFormData:ln,isArrayBufferView:en,isString:tn,isNumber:yt,isBoolean:nn,isObject:me,isPlainObject:ce,isReadableStream:hn,isRequest:dn,isResponse:fn,isHeaders:pn,isUndefined:Y,isDate:sn,isFile:rn,isBlob:on,isRegExp:On,isFunction:T,isStream:an,isURLSearchParams:un,isTypedArray:Sn,isFileList:cn,forEach:ee,merge:ke,extend:gn,trim:mn,stripBOM:bn,inherits:yn,toFlatObject:wn,kindOf:fe,kindOfTest:$,endsWith:_n,toArray:En,forEachEntry:xn,matchAll:Rn,isHTMLForm:An,hasOwnProperty:We,hasOwnProp:We,reduceDescriptors:Et,freezeMethods:Tn,toObjectSet:kn,toCamelCase:Cn,noop:Nn,toFiniteNumber:Pn,findKey:wt,global:H,isContextDefined:_t,isSpecCompliantForm:In,toJSONObject:vn,isAsyncFn:Ln,isThenable:jn,setImmediate:St,asap:$n,isIterable:Fn};function y(n,e,t,s,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=n,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),s&&(this.request=s),r&&(this.response=r,this.status=r.status?r.status:null)}l.inherits(y,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:l.toJSONObject(this.config),code:this.code,status:this.status}}});const xt=y.prototype,Rt={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(n=>{Rt[n]={value:n}});Object.defineProperties(y,Rt);Object.defineProperty(xt,"isAxiosError",{value:!0});y.from=(n,e,t,s,r,i)=>{const o=Object.create(xt);return l.toFlatObject(n,o,function(h){return h!==Error.prototype},c=>c!=="isAxiosError"),y.call(o,n.message,e,t,s,r),o.cause=n,o.name=n.name,i&&Object.assign(o,i),o};const Un=null;function Ne(n){return l.isPlainObject(n)||l.isArray(n)}function At(n){return l.endsWith(n,"[]")?n.slice(0,-2):n}function Ke(n,e,t){return n?n.concat(e).map(function(r,i){return r=At(r),!t&&i?"["+r+"]":r}).join(t?".":""):e}function Dn(n){return l.isArray(n)&&!n.some(Ne)}const qn=l.toFlatObject(l,{},null,function(e){return/^is[A-Z]/.test(e)});function ge(n,e,t){if(!l.isObject(n))throw new TypeError("target must be an object");e=e||new FormData,t=l.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,p){return!l.isUndefined(p[m])});const s=t.metaTokens,r=t.visitor||a,i=t.dots,o=t.indexes,h=(t.Blob||typeof Blob<"u"&&Blob)&&l.isSpecCompliantForm(e);if(!l.isFunction(r))throw new TypeError("visitor must be a function");function u(f){if(f===null)return"";if(l.isDate(f))return f.toISOString();if(!h&&l.isBlob(f))throw new y("Blob is not supported. Use a Buffer instead.");return l.isArrayBuffer(f)||l.isTypedArray(f)?h&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function a(f,m,p){let _=f;if(f&&!p&&typeof f=="object"){if(l.endsWith(m,"{}"))m=s?m:m.slice(0,-2),f=JSON.stringify(f);else if(l.isArray(f)&&Dn(f)||(l.isFileList(f)||l.endsWith(m,"[]"))&&(_=l.toArray(f)))return m=At(m),_.forEach(function(S,N){!(l.isUndefined(S)||S===null)&&e.append(o===!0?Ke([m],N,i):o===null?m:m+"[]",u(S))}),!1}return Ne(f)?!0:(e.append(Ke(p,m,i),u(f)),!1)}const d=[],g=Object.assign(qn,{defaultVisitor:a,convertValue:u,isVisitable:Ne});function b(f,m){if(!l.isUndefined(f)){if(d.indexOf(f)!==-1)throw Error("Circular reference detected in "+m.join("."));d.push(f),l.forEach(f,function(_,E){(!(l.isUndefined(_)||_===null)&&r.call(e,_,l.isString(E)?E.trim():E,m,g))===!0&&b(_,m?m.concat(E):[E])}),d.pop()}}if(!l.isObject(n))throw new TypeError("data must be an object");return b(n),e}function Xe(n){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(s){return e[s]})}function qe(n,e){this._pairs=[],n&&ge(n,this,e)}const Ct=qe.prototype;Ct.append=function(e,t){this._pairs.push([e,t])};Ct.toString=function(e){const t=e?function(s){return e.call(this,s,Xe)}:Xe;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};function Bn(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Ot(n,e,t){if(!e)return n;const s=t&&t.encode||Bn;l.isFunction(t)&&(t={serialize:t});const r=t&&t.serialize;let i;if(r?i=r(e,t):i=l.isURLSearchParams(e)?e.toString():new qe(e,t).toString(s),i){const o=n.indexOf("#");o!==-1&&(n=n.slice(0,o)),n+=(n.indexOf("?")===-1?"?":"&")+i}return n}class Ge{constructor(){this.handlers=[]}use(e,t,s){return this.handlers.push({fulfilled:e,rejected:t,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){l.forEach(this.handlers,function(s){s!==null&&e(s)})}}const Tt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Mn=typeof URLSearchParams<"u"?URLSearchParams:qe,Hn=typeof FormData<"u"?FormData:null,zn=typeof Blob<"u"?Blob:null,Vn={isBrowser:!0,classes:{URLSearchParams:Mn,FormData:Hn,Blob:zn},protocols:["http","https","file","blob","url","data"]},Be=typeof window<"u"&&typeof document<"u",Pe=typeof navigator=="object"&&navigator||void 0,Jn=Be&&(!Pe||["ReactNative","NativeScript","NS"].indexOf(Pe.product)<0),Wn=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Kn=Be&&window.location.href||"http://localhost",Xn=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Be,hasStandardBrowserEnv:Jn,hasStandardBrowserWebWorkerEnv:Wn,navigator:Pe,origin:Kn},Symbol.toStringTag,{value:"Module"})),C={...Xn,...Vn};function Gn(n,e){return ge(n,new C.classes.URLSearchParams,Object.assign({visitor:function(t,s,r,i){return C.isNode&&l.isBuffer(t)?(this.append(s,t.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},e))}function Zn(n){return l.matchAll(/\w+|\[(\w*)]/g,n).map(e=>e[0]==="[]"?"":e[1]||e[0])}function Qn(n){const e={},t=Object.keys(n);let s;const r=t.length;let i;for(s=0;s<r;s++)i=t[s],e[i]=n[i];return e}function kt(n){function e(t,s,r,i){let o=t[i++];if(o==="__proto__")return!0;const c=Number.isFinite(+o),h=i>=t.length;return o=!o&&l.isArray(r)?r.length:o,h?(l.hasOwnProp(r,o)?r[o]=[r[o],s]:r[o]=s,!c):((!r[o]||!l.isObject(r[o]))&&(r[o]=[]),e(t,s,r[o],i)&&l.isArray(r[o])&&(r[o]=Qn(r[o])),!c)}if(l.isFormData(n)&&l.isFunction(n.entries)){const t={};return l.forEachEntry(n,(s,r)=>{e(Zn(s),r,t,0)}),t}return null}function Yn(n,e,t){if(l.isString(n))try{return(e||JSON.parse)(n),l.trim(n)}catch(s){if(s.name!=="SyntaxError")throw s}return(t||JSON.stringify)(n)}const te={transitional:Tt,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const s=t.getContentType()||"",r=s.indexOf("application/json")>-1,i=l.isObject(e);if(i&&l.isHTMLForm(e)&&(e=new FormData(e)),l.isFormData(e))return r?JSON.stringify(kt(e)):e;if(l.isArrayBuffer(e)||l.isBuffer(e)||l.isStream(e)||l.isFile(e)||l.isBlob(e)||l.isReadableStream(e))return e;if(l.isArrayBufferView(e))return e.buffer;if(l.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let c;if(i){if(s.indexOf("application/x-www-form-urlencoded")>-1)return Gn(e,this.formSerializer).toString();if((c=l.isFileList(e))||s.indexOf("multipart/form-data")>-1){const h=this.env&&this.env.FormData;return ge(c?{"files[]":e}:e,h&&new h,this.formSerializer)}}return i||r?(t.setContentType("application/json",!1),Yn(e)):e}],transformResponse:[function(e){const t=this.transitional||te.transitional,s=t&&t.forcedJSONParsing,r=this.responseType==="json";if(l.isResponse(e)||l.isReadableStream(e))return e;if(e&&l.isString(e)&&(s&&!this.responseType||r)){const o=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(c){if(o)throw c.name==="SyntaxError"?y.from(c,y.ERR_BAD_RESPONSE,this,null,this.response):c}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:C.classes.FormData,Blob:C.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};l.forEach(["delete","get","head","post","put","patch"],n=>{te.headers[n]={}});const es=l.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),ts=n=>{const e={};let t,s,r;return n&&n.split(`
2
- `).forEach(function(o){r=o.indexOf(":"),t=o.substring(0,r).trim().toLowerCase(),s=o.substring(r+1).trim(),!(!t||e[t]&&es[t])&&(t==="set-cookie"?e[t]?e[t].push(s):e[t]=[s]:e[t]=e[t]?e[t]+", "+s:s)}),e},Ze=Symbol("internals");function Z(n){return n&&String(n).trim().toLowerCase()}function ae(n){return n===!1||n==null?n:l.isArray(n)?n.map(ae):String(n)}function ns(n){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=t.exec(n);)e[s[1]]=s[2];return e}const ss=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function Ae(n,e,t,s,r){if(l.isFunction(s))return s.call(this,e,t);if(r&&(e=t),!!l.isString(e)){if(l.isString(s))return e.indexOf(s)!==-1;if(l.isRegExp(s))return s.test(e)}}function rs(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,s)=>t.toUpperCase()+s)}function is(n,e){const t=l.toCamelCase(" "+e);["get","set","has"].forEach(s=>{Object.defineProperty(n,s+t,{value:function(r,i,o){return this[s].call(this,e,r,i,o)},configurable:!0})})}let k=class{constructor(e){e&&this.set(e)}set(e,t,s){const r=this;function i(c,h,u){const a=Z(h);if(!a)throw new Error("header name must be a non-empty string");const d=l.findKey(r,a);(!d||r[d]===void 0||u===!0||u===void 0&&r[d]!==!1)&&(r[d||h]=ae(c))}const o=(c,h)=>l.forEach(c,(u,a)=>i(u,a,h));if(l.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(l.isString(e)&&(e=e.trim())&&!ss(e))o(ts(e),t);else if(l.isObject(e)&&l.isIterable(e)){let c={},h,u;for(const a of e){if(!l.isArray(a))throw TypeError("Object iterator must return a key-value pair");c[u=a[0]]=(h=c[u])?l.isArray(h)?[...h,a[1]]:[h,a[1]]:a[1]}o(c,t)}else e!=null&&i(t,e,s);return this}get(e,t){if(e=Z(e),e){const s=l.findKey(this,e);if(s){const r=this[s];if(!t)return r;if(t===!0)return ns(r);if(l.isFunction(t))return t.call(this,r,s);if(l.isRegExp(t))return t.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Z(e),e){const s=l.findKey(this,e);return!!(s&&this[s]!==void 0&&(!t||Ae(this,this[s],s,t)))}return!1}delete(e,t){const s=this;let r=!1;function i(o){if(o=Z(o),o){const c=l.findKey(s,o);c&&(!t||Ae(s,s[c],c,t))&&(delete s[c],r=!0)}}return l.isArray(e)?e.forEach(i):i(e),r}clear(e){const t=Object.keys(this);let s=t.length,r=!1;for(;s--;){const i=t[s];(!e||Ae(this,this[i],i,e,!0))&&(delete this[i],r=!0)}return r}normalize(e){const t=this,s={};return l.forEach(this,(r,i)=>{const o=l.findKey(s,i);if(o){t[o]=ae(r),delete t[i];return}const c=e?rs(i):String(i).trim();c!==i&&delete t[i],t[c]=ae(r),s[c]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return l.forEach(this,(s,r)=>{s!=null&&s!==!1&&(t[r]=e&&l.isArray(s)?s.join(", "):s)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
3
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const s=new this(e);return t.forEach(r=>s.set(r)),s}static accessor(e){const s=(this[Ze]=this[Ze]={accessors:{}}).accessors,r=this.prototype;function i(o){const c=Z(o);s[c]||(is(r,o),s[c]=!0)}return l.isArray(e)?e.forEach(i):i(e),this}};k.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);l.reduceDescriptors(k.prototype,({value:n},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>n,set(s){this[t]=s}}});l.freezeMethods(k);function Ce(n,e){const t=this||te,s=e||t,r=k.from(s.headers);let i=s.data;return l.forEach(n,function(c){i=c.call(t,i,r.normalize(),e?e.status:void 0)}),r.normalize(),i}function Nt(n){return!!(n&&n.__CANCEL__)}function X(n,e,t){y.call(this,n??"canceled",y.ERR_CANCELED,e,t),this.name="CanceledError"}l.inherits(X,y,{__CANCEL__:!0});function Pt(n,e,t){const s=t.config.validateStatus;!t.status||!s||s(t.status)?n(t):e(new y("Request failed with status code "+t.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function os(n){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return e&&e[1]||""}function cs(n,e){n=n||10;const t=new Array(n),s=new Array(n);let r=0,i=0,o;return e=e!==void 0?e:1e3,function(h){const u=Date.now(),a=s[i];o||(o=u),t[r]=h,s[r]=u;let d=i,g=0;for(;d!==r;)g+=t[d++],d=d%n;if(r=(r+1)%n,r===i&&(i=(i+1)%n),u-o<e)return;const b=a&&u-a;return b?Math.round(g*1e3/b):void 0}}function as(n,e){let t=0,s=1e3/e,r,i;const o=(u,a=Date.now())=>{t=a,r=null,i&&(clearTimeout(i),i=null),n.apply(null,u)};return[(...u)=>{const a=Date.now(),d=a-t;d>=s?o(u,a):(r=u,i||(i=setTimeout(()=>{i=null,o(r)},s-d)))},()=>r&&o(r)]}const ue=(n,e,t=3)=>{let s=0;const r=cs(50,250);return as(i=>{const o=i.loaded,c=i.lengthComputable?i.total:void 0,h=o-s,u=r(h),a=o<=c;s=o;const d={loaded:o,total:c,progress:c?o/c:void 0,bytes:h,rate:u||void 0,estimated:u&&c&&a?(c-o)/u:void 0,event:i,lengthComputable:c!=null,[e?"download":"upload"]:!0};n(d)},t)},Qe=(n,e)=>{const t=n!=null;return[s=>e[0]({lengthComputable:t,total:n,loaded:s}),e[1]]},Ye=n=>(...e)=>l.asap(()=>n(...e)),ls=C.hasStandardBrowserEnv?((n,e)=>t=>(t=new URL(t,C.origin),n.protocol===t.protocol&&n.host===t.host&&(e||n.port===t.port)))(new URL(C.origin),C.navigator&&/(msie|trident)/i.test(C.navigator.userAgent)):()=>!0,us=C.hasStandardBrowserEnv?{write(n,e,t,s,r,i){const o=[n+"="+encodeURIComponent(e)];l.isNumber(t)&&o.push("expires="+new Date(t).toGMTString()),l.isString(s)&&o.push("path="+s),l.isString(r)&&o.push("domain="+r),i===!0&&o.push("secure"),document.cookie=o.join("; ")},read(n){const e=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(n){this.write(n,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function hs(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function ds(n,e){return e?n.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):n}function It(n,e,t){let s=!hs(e);return n&&(s||t==!1)?ds(n,e):e}const et=n=>n instanceof k?{...n}:n;function V(n,e){e=e||{};const t={};function s(u,a,d,g){return l.isPlainObject(u)&&l.isPlainObject(a)?l.merge.call({caseless:g},u,a):l.isPlainObject(a)?l.merge({},a):l.isArray(a)?a.slice():a}function r(u,a,d,g){if(l.isUndefined(a)){if(!l.isUndefined(u))return s(void 0,u,d,g)}else return s(u,a,d,g)}function i(u,a){if(!l.isUndefined(a))return s(void 0,a)}function o(u,a){if(l.isUndefined(a)){if(!l.isUndefined(u))return s(void 0,u)}else return s(void 0,a)}function c(u,a,d){if(d in e)return s(u,a);if(d in n)return s(void 0,u)}const h={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(u,a,d)=>r(et(u),et(a),d,!0)};return l.forEach(Object.keys(Object.assign({},n,e)),function(a){const d=h[a]||r,g=d(n[a],e[a],a);l.isUndefined(g)&&d!==c||(t[a]=g)}),t}const vt=n=>{const e=V({},n);let{data:t,withXSRFToken:s,xsrfHeaderName:r,xsrfCookieName:i,headers:o,auth:c}=e;e.headers=o=k.from(o),e.url=Ot(It(e.baseURL,e.url,e.allowAbsoluteUrls),n.params,n.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let h;if(l.isFormData(t)){if(C.hasStandardBrowserEnv||C.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if((h=o.getContentType())!==!1){const[u,...a]=h?h.split(";").map(d=>d.trim()).filter(Boolean):[];o.setContentType([u||"multipart/form-data",...a].join("; "))}}if(C.hasStandardBrowserEnv&&(s&&l.isFunction(s)&&(s=s(e)),s||s!==!1&&ls(e.url))){const u=r&&i&&us.read(i);u&&o.set(r,u)}return e},fs=typeof XMLHttpRequest<"u",ps=fs&&function(n){return new Promise(function(t,s){const r=vt(n);let i=r.data;const o=k.from(r.headers).normalize();let{responseType:c,onUploadProgress:h,onDownloadProgress:u}=r,a,d,g,b,f;function m(){b&&b(),f&&f(),r.cancelToken&&r.cancelToken.unsubscribe(a),r.signal&&r.signal.removeEventListener("abort",a)}let p=new XMLHttpRequest;p.open(r.method.toUpperCase(),r.url,!0),p.timeout=r.timeout;function _(){if(!p)return;const S=k.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),x={data:!c||c==="text"||c==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:S,config:n,request:p};Pt(function(I){t(I),m()},function(I){s(I),m()},x),p=null}"onloadend"in p?p.onloadend=_:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(_)},p.onabort=function(){p&&(s(new y("Request aborted",y.ECONNABORTED,n,p)),p=null)},p.onerror=function(){s(new y("Network Error",y.ERR_NETWORK,n,p)),p=null},p.ontimeout=function(){let N=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const x=r.transitional||Tt;r.timeoutErrorMessage&&(N=r.timeoutErrorMessage),s(new y(N,x.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,n,p)),p=null},i===void 0&&o.setContentType(null),"setRequestHeader"in p&&l.forEach(o.toJSON(),function(N,x){p.setRequestHeader(x,N)}),l.isUndefined(r.withCredentials)||(p.withCredentials=!!r.withCredentials),c&&c!=="json"&&(p.responseType=r.responseType),u&&([g,f]=ue(u,!0),p.addEventListener("progress",g)),h&&p.upload&&([d,b]=ue(h),p.upload.addEventListener("progress",d),p.upload.addEventListener("loadend",b)),(r.cancelToken||r.signal)&&(a=S=>{p&&(s(!S||S.type?new X(null,n,p):S),p.abort(),p=null)},r.cancelToken&&r.cancelToken.subscribe(a),r.signal&&(r.signal.aborted?a():r.signal.addEventListener("abort",a)));const E=os(r.url);if(E&&C.protocols.indexOf(E)===-1){s(new y("Unsupported protocol "+E+":",y.ERR_BAD_REQUEST,n));return}p.send(i||null)})},ms=(n,e)=>{const{length:t}=n=n?n.filter(Boolean):[];if(e||t){let s=new AbortController,r;const i=function(u){if(!r){r=!0,c();const a=u instanceof Error?u:this.reason;s.abort(a instanceof y?a:new X(a instanceof Error?a.message:a))}};let o=e&&setTimeout(()=>{o=null,i(new y(`timeout ${e} of ms exceeded`,y.ETIMEDOUT))},e);const c=()=>{n&&(o&&clearTimeout(o),o=null,n.forEach(u=>{u.unsubscribe?u.unsubscribe(i):u.removeEventListener("abort",i)}),n=null)};n.forEach(u=>u.addEventListener("abort",i));const{signal:h}=s;return h.unsubscribe=()=>l.asap(c),h}},gs=function*(n,e){let t=n.byteLength;if(t<e){yield n;return}let s=0,r;for(;s<t;)r=s+e,yield n.slice(s,r),s=r},bs=async function*(n,e){for await(const t of ys(n))yield*gs(t,e)},ys=async function*(n){if(n[Symbol.asyncIterator]){yield*n;return}const e=n.getReader();try{for(;;){const{done:t,value:s}=await e.read();if(t)break;yield s}}finally{await e.cancel()}},tt=(n,e,t,s)=>{const r=bs(n,e);let i=0,o,c=h=>{o||(o=!0,s&&s(h))};return new ReadableStream({async pull(h){try{const{done:u,value:a}=await r.next();if(u){c(),h.close();return}let d=a.byteLength;if(t){let g=i+=d;t(g)}h.enqueue(new Uint8Array(a))}catch(u){throw c(u),u}},cancel(h){return c(h),r.return()}},{highWaterMark:2})},be=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Lt=be&&typeof ReadableStream=="function",ws=be&&(typeof TextEncoder=="function"?(n=>e=>n.encode(e))(new TextEncoder):async n=>new Uint8Array(await new Response(n).arrayBuffer())),jt=(n,...e)=>{try{return!!n(...e)}catch{return!1}},_s=Lt&&jt(()=>{let n=!1;const e=new Request(C.origin,{body:new ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type");return n&&!e}),nt=64*1024,Ie=Lt&&jt(()=>l.isReadableStream(new Response("").body)),he={stream:Ie&&(n=>n.body)};be&&(n=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!he[e]&&(he[e]=l.isFunction(n[e])?t=>t[e]():(t,s)=>{throw new y(`Response type '${e}' is not supported`,y.ERR_NOT_SUPPORT,s)})})})(new Response);const Es=async n=>{if(n==null)return 0;if(l.isBlob(n))return n.size;if(l.isSpecCompliantForm(n))return(await new Request(C.origin,{method:"POST",body:n}).arrayBuffer()).byteLength;if(l.isArrayBufferView(n)||l.isArrayBuffer(n))return n.byteLength;if(l.isURLSearchParams(n)&&(n=n+""),l.isString(n))return(await ws(n)).byteLength},Ss=async(n,e)=>{const t=l.toFiniteNumber(n.getContentLength());return t??Es(e)},xs=be&&(async n=>{let{url:e,method:t,data:s,signal:r,cancelToken:i,timeout:o,onDownloadProgress:c,onUploadProgress:h,responseType:u,headers:a,withCredentials:d="same-origin",fetchOptions:g}=vt(n);u=u?(u+"").toLowerCase():"text";let b=ms([r,i&&i.toAbortSignal()],o),f;const m=b&&b.unsubscribe&&(()=>{b.unsubscribe()});let p;try{if(h&&_s&&t!=="get"&&t!=="head"&&(p=await Ss(a,s))!==0){let x=new Request(e,{method:"POST",body:s,duplex:"half"}),P;if(l.isFormData(s)&&(P=x.headers.get("content-type"))&&a.setContentType(P),x.body){const[I,D]=Qe(p,ue(Ye(h)));s=tt(x.body,nt,I,D)}}l.isString(d)||(d=d?"include":"omit");const _="credentials"in Request.prototype;f=new Request(e,{...g,signal:b,method:t.toUpperCase(),headers:a.normalize().toJSON(),body:s,duplex:"half",credentials:_?d:void 0});let E=await fetch(f);const S=Ie&&(u==="stream"||u==="response");if(Ie&&(c||S&&m)){const x={};["status","statusText","headers"].forEach(U=>{x[U]=E[U]});const P=l.toFiniteNumber(E.headers.get("content-length")),[I,D]=c&&Qe(P,ue(Ye(c),!0))||[];E=new Response(tt(E.body,nt,I,()=>{D&&D(),m&&m()}),x)}u=u||"text";let N=await he[l.findKey(he,u)||"text"](E,n);return!S&&m&&m(),await new Promise((x,P)=>{Pt(x,P,{data:N,headers:k.from(E.headers),status:E.status,statusText:E.statusText,config:n,request:f})})}catch(_){throw m&&m(),_&&_.name==="TypeError"&&/Load failed|fetch/i.test(_.message)?Object.assign(new y("Network Error",y.ERR_NETWORK,n,f),{cause:_.cause||_}):y.from(_,_&&_.code,n,f)}}),ve={http:Un,xhr:ps,fetch:xs};l.forEach(ve,(n,e)=>{if(n){try{Object.defineProperty(n,"name",{value:e})}catch{}Object.defineProperty(n,"adapterName",{value:e})}});const st=n=>`- ${n}`,Rs=n=>l.isFunction(n)||n===null||n===!1,$t={getAdapter:n=>{n=l.isArray(n)?n:[n];const{length:e}=n;let t,s;const r={};for(let i=0;i<e;i++){t=n[i];let o;if(s=t,!Rs(t)&&(s=ve[(o=String(t)).toLowerCase()],s===void 0))throw new y(`Unknown adapter '${o}'`);if(s)break;r[o||"#"+i]=s}if(!s){const i=Object.entries(r).map(([c,h])=>`adapter ${c} `+(h===!1?"is not supported by the environment":"is not available in the build"));let o=e?i.length>1?`since :
4
- `+i.map(st).join(`
5
- `):" "+st(i[0]):"as no adapter specified";throw new y("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return s},adapters:ve};function Oe(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new X(null,n)}function rt(n){return Oe(n),n.headers=k.from(n.headers),n.data=Ce.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),$t.getAdapter(n.adapter||te.adapter)(n).then(function(s){return Oe(n),s.data=Ce.call(n,n.transformResponse,s),s.headers=k.from(s.headers),s},function(s){return Nt(s)||(Oe(n),s&&s.response&&(s.response.data=Ce.call(n,n.transformResponse,s.response),s.response.headers=k.from(s.response.headers))),Promise.reject(s)})}const Ft="1.9.0",ye={};["object","boolean","number","function","string","symbol"].forEach((n,e)=>{ye[n]=function(s){return typeof s===n||"a"+(e<1?"n ":" ")+n}});const it={};ye.transitional=function(e,t,s){function r(i,o){return"[Axios v"+Ft+"] Transitional option '"+i+"'"+o+(s?". "+s:"")}return(i,o,c)=>{if(e===!1)throw new y(r(o," has been removed"+(t?" in "+t:"")),y.ERR_DEPRECATED);return t&&!it[o]&&(it[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,o,c):!0}};ye.spelling=function(e){return(t,s)=>(console.warn(`${s} is likely a misspelling of ${e}`),!0)};function As(n,e,t){if(typeof n!="object")throw new y("options must be an object",y.ERR_BAD_OPTION_VALUE);const s=Object.keys(n);let r=s.length;for(;r-- >0;){const i=s[r],o=e[i];if(o){const c=n[i],h=c===void 0||o(c,i,n);if(h!==!0)throw new y("option "+i+" must be "+h,y.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new y("Unknown option "+i,y.ERR_BAD_OPTION)}}const le={assertOptions:As,validators:ye},F=le.validators;let z=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Ge,response:new Ge}}async request(e,t){try{return await this._request(e,t)}catch(s){if(s instanceof Error){let r={};Error.captureStackTrace?Error.captureStackTrace(r):r=new Error;const i=r.stack?r.stack.replace(/^.+\n/,""):"";try{s.stack?i&&!String(s.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(s.stack+=`
6
- `+i):s.stack=i}catch{}}throw s}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=V(this.defaults,t);const{transitional:s,paramsSerializer:r,headers:i}=t;s!==void 0&&le.assertOptions(s,{silentJSONParsing:F.transitional(F.boolean),forcedJSONParsing:F.transitional(F.boolean),clarifyTimeoutError:F.transitional(F.boolean)},!1),r!=null&&(l.isFunction(r)?t.paramsSerializer={serialize:r}:le.assertOptions(r,{encode:F.function,serialize:F.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),le.assertOptions(t,{baseUrl:F.spelling("baseURL"),withXsrfToken:F.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&l.merge(i.common,i[t.method]);i&&l.forEach(["delete","get","head","post","put","patch","common"],f=>{delete i[f]}),t.headers=k.concat(o,i);const c=[];let h=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(t)===!1||(h=h&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const u=[];this.interceptors.response.forEach(function(m){u.push(m.fulfilled,m.rejected)});let a,d=0,g;if(!h){const f=[rt.bind(this),void 0];for(f.unshift.apply(f,c),f.push.apply(f,u),g=f.length,a=Promise.resolve(t);d<g;)a=a.then(f[d++],f[d++]);return a}g=c.length;let b=t;for(d=0;d<g;){const f=c[d++],m=c[d++];try{b=f(b)}catch(p){m.call(this,p);break}}try{a=rt.call(this,b)}catch(f){return Promise.reject(f)}for(d=0,g=u.length;d<g;)a=a.then(u[d++],u[d++]);return a}getUri(e){e=V(this.defaults,e);const t=It(e.baseURL,e.url,e.allowAbsoluteUrls);return Ot(t,e.params,e.paramsSerializer)}};l.forEach(["delete","get","head","options"],function(e){z.prototype[e]=function(t,s){return this.request(V(s||{},{method:e,url:t,data:(s||{}).data}))}});l.forEach(["post","put","patch"],function(e){function t(s){return function(i,o,c){return this.request(V(c||{},{method:e,headers:s?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}z.prototype[e]=t(),z.prototype[e+"Form"]=t(!0)});let Cs=class Ut{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(i){t=i});const s=this;this.promise.then(r=>{if(!s._listeners)return;let i=s._listeners.length;for(;i-- >0;)s._listeners[i](r);s._listeners=null}),this.promise.then=r=>{let i;const o=new Promise(c=>{s.subscribe(c),i=c}).then(r);return o.cancel=function(){s.unsubscribe(i)},o},e(function(i,o,c){s.reason||(s.reason=new X(i,o,c),t(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=s=>{e.abort(s)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new Ut(function(r){e=r}),cancel:e}}};function Os(n){return function(t){return n.apply(null,t)}}function Ts(n){return l.isObject(n)&&n.isAxiosError===!0}const Le={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Le).forEach(([n,e])=>{Le[e]=n});function Dt(n){const e=new z(n),t=mt(z.prototype.request,e);return l.extend(t,z.prototype,e,{allOwnKeys:!0}),l.extend(t,e,null,{allOwnKeys:!0}),t.create=function(r){return Dt(V(n,r))},t}const R=Dt(te);R.Axios=z;R.CanceledError=X;R.CancelToken=Cs;R.isCancel=Nt;R.VERSION=Ft;R.toFormData=ge;R.AxiosError=y;R.Cancel=R.CanceledError;R.all=function(e){return Promise.all(e)};R.spread=Os;R.isAxiosError=Ts;R.mergeConfig=V;R.AxiosHeaders=k;R.formToJSON=n=>kt(l.isHTMLForm(n)?new FormData(n):n);R.getAdapter=$t.getAdapter;R.HttpStatusCode=Le;R.default=R;const{Axios:Zr,AxiosError:Qr,CanceledError:Yr,isCancel:ei,CancelToken:ti,VERSION:ni,all:si,Cancel:ri,isAxiosError:ii,spread:oi,toFormData:ci,AxiosHeaders:ai,HttpStatusCode:li,formToJSON:ui,getAdapter:hi,mergeConfig:di}=R,we=R.create({baseURL:location.origin,timeout:6e4,params:{}});we.interceptors.response.use(n=>n,n=>{var e,t,s,r,i,o,c,h,u,a,d;if(n.response){if(n.response.status===401&&OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity,!0).then(function(f){f&&OpenC3Auth.setTokens()}),n.response.config.headers["Ignore-Errors"]&&n.response.config.headers["Ignore-Errors"].includes(n.response.status.toString()))return Promise.reject(n);let g=`HTTP ${n.response.status} - `;(e=n.response)!=null&&e.statusText&&(g+=`${n.response.statusText} `),(s=(t=n.response)==null?void 0:t.config)!=null&&s.data&&(g+=`${n.response.config.data} `),(i=(r=n.response)==null?void 0:r.data)!=null&&i.message?g+=`${n.response.data.message}`:(c=(o=n.response)==null?void 0:o.data)!=null&&c.exception?g+=`${n.response.data.exception}`:(a=(u=(h=n.response)==null?void 0:h.data)==null?void 0:u.error)!=null&&a.message?(n.response.data.error.class&&(g+=`${n.response.data.error.class} `),g+=`${n.response.data.error.message}`):g+=`${(d=n.response)==null?void 0:d.data}`;const{$cosmosNotify:b}=window;throw b&&b.serious({title:"Network error",body:g}),n}else throw n});const re=async function(n,e,{data:t,params:s={},headers:r,noAuth:i=!1,noScope:o=!1,onUploadProgress:c=!1}={}){if(!i){try{await OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity)&&OpenC3Auth.setTokens()}catch{OpenC3Auth.login()}r.Authorization=localStorage.openc3Token}return r.manual=!0,!o&&!s.scope&&(s.scope=window.openc3Scope),we({method:n,url:e,data:t,params:s,headers:r,onUploadProgress:c})},je={Accept:"application/json"},ot={...je,"Content-Type":"application/json"},ks={get:function(n,{params:e,headers:t=je,noScope:s,noAuth:r,onUploadProgress:i}={}){return re("get",n,{params:e,headers:t,noScope:s,noAuth:r,onUploadProgress:i})},put:function(n,{data:e,params:t,headers:s=ot,noScope:r,noAuth:i,onUploadProgress:o}={}){return re("put",n,{data:e,params:t,headers:s,noScope:r,noAuth:i,onUploadProgress:o})},post:function(n,{data:e,params:t,headers:s=ot,noScope:r,noAuth:i,onUploadProgress:o}={}){return re("post",n,{data:e,params:t,headers:s,noScope:r,noAuth:i,onUploadProgress:o})},delete:function(n,{params:e,headers:t=je,noScope:s,noAuth:r,onUploadProgress:i}={}){return re("delete",n,{params:e,headers:t,noScope:s,noAuth:r,onUploadProgress:i})}};let _e=()=>({emit(n,...e){for(let t=this.events[n]||[],s=0,r=t.length;s<r;s++)t[s](...e)},events:{},on(n,e){var t;return((t=this.events)[n]||(t[n]=[])).push(e),()=>{var s;this.events[n]=(s=this.events[n])==null?void 0:s.filter(r=>e!==r)}}});class ne extends Error{constructor(e,t){e instanceof Error?(super(e.message),this.cause=e):super(e),this.reason=t,this.name="ReasonError"}}class Me extends ne{constructor(e){super("Rejected",e),this.name="SubscriptionRejectedError"}}class Ns extends ne{constructor(e){super(e||"Timed out to receive subscription ack"),this.name="SubscriptionTimeoutError"}}class j extends ne{constructor(e,t){t?super(e,t):super("Disconnected",e),this.name="DisconnectedError"}}class Ps extends j{constructor(e){super(e,"stale_connection"),this.name="StaleConnectionError"}}function qt(n){return n?`{${Object.keys(n).sort().filter(t=>n[t]!==void 0).map(t=>{let s=JSON.stringify(n[t]);return`${JSON.stringify(t)}:${s}`}).join(",")}}`:""}class Is{constructor(e){this.channel=e,this.listeners=[]}watch(){this.listeners.push(this.channel.on("presence",e=>{if(e.type==="info"){this._state||(this._state=this.stateFromInfo(e));return}this._state&&(e.type==="join"?this._state[e.id]=e.info:e.type==="leave"&&delete this._state[e.id])}))}reset(){delete this._state}dispose(){delete this._info,delete this._state,this.listeners.forEach(e=>e()),this.listeners.length=0}async join(e,t){if(!this._info)return this._info={id:e,info:t},this.channel.perform("$presence:join",this._info)}async leave(){if(!this._info)return;let e=await this.channel.perform("$presence:leave");return delete this._info,e}async info(){return this._state?this._state:(this._promise||(this._promise=this._sync()),await this._promise,this._state)}async _sync(){this.watch();try{let e=await this.channel.perform("$presence:info",{});return this._state=this.stateFromInfo(e),this._state}finally{delete this._promise}}stateFromInfo(e){return e.records.reduce((t,{id:s,info:r})=>(t[s]=r,t),{})}}const B=Symbol("state");class Bt{constructor(e={}){this.emitter=_e(),this.params=Object.freeze(e),this.presence=new Is(this),this.initialConnect=!0,this[B]="idle"}get identifier(){return this._identifier?this._identifier:(this._identifier=qt({channel:this.channelId,...this.params}),this._identifier)}get channelId(){return this.constructor.identifier}get state(){return this[B]}attached(e){if(this.receiver){if(this.receiver!==e)throw Error("Already connected to a different receiver");return!1}return this.receiver=e,!0}connecting(){this[B]="connecting"}connected(){if(this.state==="connected"||this.state==="closed")return;this[B]="connected";let e=!1;this.initialConnect?(this.initialConnect=!1,this.emit("connect",{reconnect:!1,restored:e})):this.emit("connect",{reconnect:!0,restored:e})}restored(){if(this.state==="connected")throw Error("Already connected");this[B]="connected";let e=!0,t=!0;this.initialConnect=!1,this.emit("connect",{reconnect:t,restored:e})}disconnected(e){this.state==="disconnected"||this.state==="closed"||(this[B]="disconnected",this.presence.reset(),this.emit("disconnect",e))}closed(e){this.state!=="closed"&&(this[B]="closed",delete this.receiver,this.initialConnect=!0,this.presence.dispose(),this.emit("close",e))}disconnect(){this.state==="idle"||this.state==="closed"||this.receiver.unsubscribe(this)}async perform(e,t){if(this.state==="idle"||this.state==="closed")throw Error("Channel is not subscribed");return this.receiver.perform(this.identifier,e,t)}async send(e){return this.perform(void 0,e)}async whisper(e){try{await this.perform("$whisper",e)}catch(t){let s=this.receiver?this.receiver.logger:null;s&&s.warn("whisper failed: ",t)}}receive(e,t){this.emit("message",e,t)}on(e,t){return this.emitter.on(e,t)}once(e,t){let s=this.emitter.on(e,(...r)=>{s(),t(...r)});return s}emit(e,...t){return this.emitter.emit(e,...t)}ensureSubscribed(){return this.state==="connected"?Promise.resolve():this.state==="closed"?Promise.reject(Error("Channel is unsubscribed")):this.pendingSubscribe()}pendingSubscribe(){return this._pendingSubscribe?this._pendingSubscribe:(this._pendingSubscribe=new Promise((e,t)=>{let s=[()=>delete this._pendingSubscribe];s.push(this.on("connect",()=>{s.forEach(r=>r()),e()})),s.push(this.on("close",r=>{s.forEach(i=>i()),t(r||new ne("Channel was disconnected before subscribing","canceled"))}))}),this._pendingSubscribe)}}class vs{constructor(e){this.id=e,this.intent="unsubscribed",this.state="idle",this.channels=[],this.disposed=!1,this._pendings=[]}add(e){this.channels.includes(e)||this.channels.push(e)}remove(e){let t=this.channels.indexOf(e);t>-1&&this.channels.splice(t,1)}notify(e,...t){this.state=e==="restored"?"connected":e,t.length===1?this.channels.forEach(s=>s[e](t[0])):this.channels.forEach(s=>s[e]())}pending(e){this._checkIntent(e);let t=this._pendings[0];return!t||t.intent!==e?Promise.resolve():t.promise}ensureResubscribed(){this.disposed||(this.intent=void 0,this.ensureSubscribed())}ensureSubscribed(){if(this.intent==="subscribed")return;if(this.disposed)throw Error("Subscription is disposed");this.intent="subscribed",!this._mergeWithPending("unsubscribed")&&this.subscriber(this)}maybeUnsubscribe(){this.disposed||this.intent==="unsubscribed"||this.channels.length>0||(this.intent="unsubscribed",this._mergeWithPending("subscribed"))||this.unsubscriber(this)}async acquire(e){this._checkIntent(e);let t,r={promise:new Promise(o=>{t=o}),intent:e,release:()=>{this._pendings.splice(this._pendings.indexOf(r),1),t(r)},canceled:!1,acquired:!1},i=this._pendingTop;return this._pendings.push(r),i&&await i.promise,this.gvl&&await this.gvl.acquire(r,e),r.acquired=!0,r}close(e){this.disposed=!0,this.intent=void 0,this.notify("closed",e)}_checkIntent(e){if(!(e==="unsubscribed"||e==="subscribed"))throw Error(`Unknown subscription intent: ${e}`)}get _pendingTop(){return this._pendings.length?this._pendings[this._pendings.length-1]:void 0}_mergeWithPending(e){let t=this._pendingTop;return!t||t.acquired||t.intent!==e?!1:(this._pendings.pop(),t.canceled=!0,!0)}}class Ls{constructor(){this.queue=[]}async acquire(e,t){t==="subscribed"&&(this.queue.push(e.promise.then(()=>{this.queue.splice(this.queue.indexOf(e),1)})),this.queue.length>1&&await this.queue[this.queue.length-2])}}class js{constructor(e){e.concurrentSubscribes===!1&&(this.glv=new Ls),this._subscriptions={},this._localToRemote={}}all(){return Object.values(this._subscriptions)}get(e){return this._subscriptions[e]}create(e,{subscribe:t,unsubscribe:s}){let r=this._subscriptions[e]=new vs(e);return r.remoteId=this._localToRemote[e],r.subscriber=t,r.unsubscriber=s,r.gvl=this.glv,r}remove(e){delete this._subscriptions[e],delete this._localToRemote[e]}storeRemoteId(e,t){this._localToRemote[e]=t;let s=this.get(e);s&&(s.remoteId=t)}}class $s{constructor(e={}){this.subscriptions=new js(e),this._pendingMessages=[],this._remoteToLocal={}}subscribe(e,t){this._remoteToLocal[t]=e,this.subscriptions.storeRemoteId(e,t),this.flush(t)}unsubscribe(e){let t=this.subscriptions.get(e);if(!t)return;let s=t.remoteId;s&&delete this._remoteToLocal[s],this.subscriptions.remove(e)}transmit(e,t,s){let r=this._remoteToLocal[e];if(!r){this._pendingMessages.push([e,t,s]);return}let i=this.subscriptions.get(r);i&&i.channels.forEach(o=>{o.receive(t,s)})}notify(e,t,s){let r=this._remoteToLocal[e];if(!r)return;let i=this.subscriptions.get(r);i&&i.channels.forEach(o=>o.emit(t,s))}close(){this._pendingMessages.length=0}get size(){return this.channels.length}get channels(){return this.subscriptions.all().flatMap(e=>e.channels)}flush(e){let t=[];for(let s of this._pendingMessages)s[0]===e?this.transmit(s[0],s[1],s[2]):t.push(s);this._pendingMessages=t}}const ct={debug:0,info:1,warn:2,error:3};class Mt{constructor(e){this.level=e||"warn"}log(e,t,s){ct[e]<ct[this.level]||this.writeLogEntry(e,t,s)}writeLogEntry(){throw Error("Not implemented")}debug(e,t){this.log("debug",e,t)}info(e,t){this.log("info",e,t)}warn(e,t){this.log("warn",e,t)}error(e,t){this.log("error",e,t)}}class se extends Mt{writeLogEntry(){}}class Fs{encode(e){return JSON.stringify(e)}decode(e){try{return JSON.parse(e)}catch{}}}let Us=0;class Ht{constructor(e={}){let{logger:t}=e;this.logger=t||new se,this.pendingSubscriptions={},this.pendingUnsubscriptions={},this.subscribeCooldownInterval=e.subscribeCooldownInterval||250,this.subscribeRetryInterval=e.subscribeRetryInterval||5e3}attached(e){this.cable=e}subscribe(e,t){let s={channel:e};t&&Object.assign(s,t);let r=qt(s);if(this.pendingUnsubscriptions[r]){let o=this.subscribeCooldownInterval*1.5;return this.logger.debug(`unsubscribed recently, cooldown for ${o}`,r),new Promise(c=>{setTimeout(()=>{c(this.subscribe(e,t))},o)})}if(this.pendingSubscriptions[r])return this.logger.warn("subscription is already pending, skipping",r),Promise.reject(Error("Already subscribing"));let i=this.subscribeRetryInterval;return new Promise((o,c)=>{let h=++Us;this.pendingSubscriptions[r]={resolve:o,reject:c,id:h},this.cable.send(this.buildSubscribeRequest(r)),this.maybeRetrySubscribe(h,r,i)})}buildSubscribeRequest(e){return{command:"subscribe",identifier:e}}maybeRetrySubscribe(e,t,s){setTimeout(()=>{let r=this.pendingSubscriptions[t];r&&r.id===e&&(this.logger.warn(`no subscription ack received in ${s}ms, retrying subscribe`,t),this.cable.send(this.buildSubscribeRequest(t)),this.maybeExpireSubscribe(e,t,s))},s)}maybeExpireSubscribe(e,t,s){setTimeout(()=>{let r=this.pendingSubscriptions[t];r&&r.id===e&&(delete this.pendingSubscriptions[t],r.reject(new Ns(`Haven't received subscription ack in ${s*2}ms for ${t}`)))},s)}unsubscribe(e){return this.cable.send({command:"unsubscribe",identifier:e}),this.pendingUnsubscriptions[e]=!0,setTimeout(()=>{delete this.pendingUnsubscriptions[e]},this.subscribeCooldownInterval),Promise.resolve()}perform(e,t,s){return t==="$whisper"?this.whisper(e,s):(s||(s={}),s.action=t,this.cable.send({command:"message",identifier:e,data:JSON.stringify(s)}),Promise.resolve())}whisper(e,t){return this.cable.send({command:"whisper",identifier:e,data:t}),Promise.resolve()}receive(e){if(typeof e!="object"){this.logger.error("unsupported message format",{message:e});return}let{type:t,identifier:s,message:r,reason:i,reconnect:o}=e;if(t==="ping")return this.cable.keepalive(e.message);if(this.cable.keepalive(),t==="welcome"){let c=e.sid;return c&&this.cable.setSessionId(c),this.cable.connected()}if(t==="disconnect"){let c=new j(i);this.reset(c),o===!1?this.cable.closed(c):this.cable.disconnected(c);return}if(t==="confirm_subscription"){let c=this.pendingSubscriptions[s];if(!c){this.logger.error("subscription not found, unsubscribing",{type:t,identifier:s}),this.unsubscribe(s);return}return delete this.pendingSubscriptions[s],c.resolve(s)}if(t==="reject_subscription"){let c=this.pendingSubscriptions[s];return c?(delete this.pendingSubscriptions[s],c.reject(new Me)):this.logger.error("subscription not found",{type:t,identifier:s})}if(r)return{identifier:s,message:r};this.logger.warn(`unknown message type: ${t}`,{message:e})}reset(e){for(let t in this.pendingSubscriptions)this.pendingSubscriptions[t].reject(e);this.pendingSubscriptions={}}recoverableClosure(){return!1}}const at=()=>Date.now()/1e3|0;class Ds extends Ht{constructor(e={}){super(e),this.streamsPositions={},this.subscriptionStreams={},this.pendingHistory={},this.pendingPresence={},this.presenceInfo={},this.restoreSince=e.historyTimestamp,this.disableSessionRecovery=e.disableSessionRecovery,this.restoreSince===void 0&&(this.restoreSince=at()),this.sessionId=void 0,this.sendPongs=e.pongs}reset(e){for(let t in this.pendingPresence)this.pendingPresence[t].reject(e);return this.pendingPresence={},super.reset()}receive(e){if(typeof e!="object"){this.logger.error("unsupported message format",{message:e});return}let{type:t,identifier:s,message:r}=e;if(t==="disconnect")return delete this.sessionId,this.cable.setSessionId(""),super.receive(e);if(t==="reject_subscription")return super.receive(e);if(t==="confirm_subscription")return this.subscriptionStreams[s]||(this.subscriptionStreams[s]=new Set),super.receive(e);if(t==="ping")return this.restoreSince&&(this.restoreSince=at()),this.sendPongs&&this.sendPong(),this.cable.keepalive(e.message);if(this.cable.keepalive(),t==="confirm_history"){this.logger.debug("history result received",e),this.cable.notify("history_received",s);return}if(t==="reject_history"){this.logger.warn("failed to retrieve history",e),this.cable.notify("history_not_found",s);return}if(t==="welcome"){if(this.disableSessionRecovery||(this.sessionId=e.sid,this.sessionId&&this.cable.setSessionId(this.sessionId)),e.restored){let i=e.restored_ids||Object.keys(this.subscriptionStreams);for(let o of i)this.cable.send({identifier:o,command:"history",history:this.historyRequestFor(o)}),this.presenceInfo[o]&&this.cable.send({identifier:o,command:"join",presence:this.presenceInfo[o]});return this.cable.restored(i)}return this.cable.connected(this.sessionId)}if(t==="presence"){let i=r.type;if(i==="info"){let o=this.pendingPresence[s];o&&(delete this.pendingPresence[s],o.resolve(r))}else if(i==="error"){let o=this.pendingPresence[s];o&&(delete this.pendingPresence[s],o.reject(new Error("failed to retrieve presence")))}return{type:t,identifier:s,message:r}}if(r){let i=this.trackStreamPosition(s,e.stream_id,e.epoch,e.offset);return{identifier:s,message:r,meta:i}}this.logger.warn(`unknown message type: ${t}`,{message:e})}perform(e,t,s){switch(t){case"$presence:join":return this.join(e,s);case"$presence:leave":return this.leave(e,s);case"$presence:info":return this.presence(e,s)}return super.perform(e,t,s)}unsubscribe(e){return delete this.presenceInfo[e],super.unsubscribe(e)}buildSubscribeRequest(e){let t=super.buildSubscribeRequest(e),s=this.historyRequestFor(e);s&&(t.history=s,this.pendingHistory[e]=!0);let r=this.presenceInfo[e];return r&&(t.presence=r),t}recoverableClosure(){return!!this.sessionId}historyRequestFor(e){let t={},s=!1;if(this.subscriptionStreams[e])for(let r of this.subscriptionStreams[e]){let i=this.streamsPositions[r];i&&(s=!0,t[r]=i)}if(!(!s&&!this.restoreSince))return{since:this.restoreSince,streams:t}}trackStreamPosition(e,t,s,r){if(!(!t||!s))return this.subscriptionStreams[e]||(this.subscriptionStreams[e]=new Set),this.subscriptionStreams[e].add(t),this.streamsPositions[t]={epoch:s,offset:r},{stream:t,epoch:s,offset:r}}async sendPong(){await new Promise(e=>setTimeout(e,0)),this.cable.state==="connected"&&this.cable.send({command:"pong"})}async join(e,t){return this.presenceInfo[e]=t,this.cable.send({command:"join",identifier:e,presence:t}),Promise.resolve()}async leave(e,t){return delete this.presenceInfo[e],this.cable.send({command:"leave",identifier:e,presence:t}),Promise.resolve()}presence(e,t){return this.pendingPresence[e]?(this.logger.warn("presence is already pending, skipping",e),Promise.reject(Error("presence request is already pending"))):new Promise((s,r)=>{this.pendingPresence[e]={resolve:s,reject:r},this.cable.send({command:"presence",identifier:e,data:t})})}}class qs extends ne{constructor(){super("No connection","closed"),this.name="NoConnectionError"}}class He extends Bt{constructor(e,t){super(t),this.channelId=e}set channelId(e){this._channelId=e}get channelId(){return this._channelId}}L(He,"identifier","__ghost__");const Bs="$pubsub";class $e extends Bt{async perform(e,t){if(e.startsWith("$"))return super.perform(e,t);throw Error("not implemented")}}L($e,"identifier",Bs);const M=Symbol("state");let Ms=class{constructor({transport:e,protocol:t,encoder:s,logger:r,lazy:i,hubOptions:o,performFailures:c,transportConfigurator:h}){this.emitter=_e(),this.transport=e,this.encoder=s,this.logger=r||new se,this.protocol=t,this.performFailures=c||"throw",this.protocol.attached(this),this.hub=new $s(o||{}),this[M]="idle",this.handleClose=this.handleClose.bind(this),this.handleIncoming=this.handleIncoming.bind(this),this.transportConfigurator=h,this.transport.on("close",this.handleClose),this.transport.on("data",this.handleIncoming),this.initialConnect=!0,this.recovering=!1,i===!1&&this.connect().catch(()=>{})}get state(){return this[M]}async connect(){if(this.state==="connected")return Promise.resolve();if(this.state==="connecting")return this.pendingConnect();let e=this.state==="idle";this[M]="connecting";let t=this.pendingConnect();this.logger.debug("connecting");try{this.transportConfigurator&&await this.transportConfigurator(this.transport,{initial:e}),await this.transport.open()}catch(s){this.handleClose(s)}return t}setSessionId(e){this.sessionId=e,this.transport.setParam("sid",e)}connected(){if(this.state==="connected")return;this.logger.info("connected"),this[M]="connected",this.recovering&&this.hub.subscriptions.all().forEach(t=>t.notify("disconnected",new j("recovery_failed"))),this.hub.subscriptions.all().forEach(t=>this._resubscribe(t));let e=!1;this.recovering=!1,this.initialConnect?(this.initialConnect=!1,this.emit("connect",{reconnect:!1,restored:e})):this.emit("connect",{reconnect:!0,restored:e})}restored(e){this.logger.info("connection recovered",{remoteIds:e}),this[M]="connected",this.hub.subscriptions.all().forEach(r=>{e&&r.remoteId&&e.includes(r.remoteId)?r.notify("restored"):(r.notify("disconnected",new j("recovery_failed")),this._resubscribe(r))});let t=!this.initialConnect,s=!0;this.recovering=!1,this.initialConnect=!1,this.emit("connect",{reconnect:t,restored:s})}notify(e,t,s){t&&typeof t!="string"&&(s=t,t=void 0),t?this.hub.notify(t,"info",{type:e,data:s}):this.emit("info",{type:e,data:s})}handleClose(e){this.logger.debug("transport closed",{error:e}),this.disconnected(new j(e,"transport_closed"))}disconnected(e){(this.state==="connected"||this.state==="connecting")&&(this.logger.info("disconnected",{reason:e}),this[M]="disconnected",this.recovering=this.protocol.recoverableClosure(e),this.recovering?this.hub.subscriptions.all().forEach(t=>t.notify("connecting")):this.hub.subscriptions.all().forEach(t=>{t.notify("disconnected",e)}),this.protocol.reset(e),this.hub.close(),this.transport.close(),this.emit("disconnect",e))}closed(e){if(this.state==="closed"||this.state==="idle")return;let t;e&&(t=e instanceof j?e:new j(e,void 0)),this.logger.info("closed",{reason:e||"user"}),this[M]="closed";let s=t||new j("cable_closed");this.hub.subscriptions.all().forEach(r=>r.notify("disconnected",s)),this.hub.close(),this.protocol.reset(),this.transport.close(),this.initialConnect=!0,this.emit("close",t)}disconnect(){this.closed()}handleIncoming(e){if(this.state==="closed"||this.state==="idle")return;let t=this.encoder.decode(e);if(t===void 0){this.logger.error("failed to decode message",{message:e});return}this.logger.debug("incoming data",t);let s=this.protocol.receive(t);if(s){this.logger.debug("processed incoming message",s);let{type:r,identifier:i,message:o,meta:c}=s;r?this.hub.notify(i,r,o):this.hub.transmit(i,o,c)}}send(e){if(this.state==="closed")throw Error("Cable is closed");let t=this.encoder.encode(e);if(t===void 0){this.logger.error("failed to encode message",{message:e});return}this.logger.debug("outgoing message",e),this.transport.send(t)}keepalive(e){this.emit("keepalive",e)}streamFrom(e){let t=new $e({stream_name:e});return this.subscribe(t)}streamFromSigned(e){let t=new $e({signed_stream_name:e});return this.subscribe(t)}subscribeTo(e,t){let s,r;return typeof e=="string"&&(r=e,e=He),s=r?new e(r,t):new e(t),this.subscribe(s)}subscribe(e){if(!e.attached(this))return e;let t=e.identifier;e.connecting();let s=this.hub.subscriptions.get(t)||this.hub.subscriptions.create(t,{subscribe:r=>this._subscribe(r,e.channelId,e.params),unsubscribe:r=>this._unsubscribe(r)});return s.add(e),s.intent==="subscribed"&&s.state==="connected"&&e.connected(),s.ensureSubscribed(),e}async _resubscribe(e){e.intent!=="subscribed"||!e.channels[0]||(e.notify("connecting"),e.ensureResubscribed())}async _subscribe(e,t,s){let r=e.id;if(this.state==="idle"&&this.connect().catch(()=>{}),this.state!=="connected"){this.logger.debug("cancel subscribe, no connection",{identifier:r});return}this.logger.debug("acquiring subscribe lock",{identifier:r});let i=await e.acquire("subscribed");if(i.canceled){this.logger.debug("subscribe lock has been canceled",{identifier:r}),i.release();return}if(this.logger.debug("subscribe lock has been acquired",{identifier:r}),e.intent!=="subscribed"){this.logger.debug("cancel subscribe request, already unsubscribed"),i.release();return}if(this.state!=="connected"){this.logger.debug("cancel subscribe, no connection",{identifier:r}),i.release();return}if(e.state==="connected"){this.logger.debug("already connected, skip subscribe command",{identifier:r}),e.notify("connected"),i.release();return}let o={identifier:t,params:s};this.logger.debug("subscribing",o);try{let c=await this.protocol.subscribe(t,s);this.hub.subscribe(r,c),this.logger.debug("subscribed",{...o,remoteId:c}),e.notify("connected")}catch(c){if(c){if(c instanceof Me&&this.logger.warn("rejected",o),c instanceof j){this.logger.debug("disconnected during subscription; will retry on connect",o),i.release();return}this.logger.error("failed to subscribe",{error:c,...o})}e.close(c),this.hub.unsubscribe(r)}i.release()}unsubscribe(e){let t=e.identifier,s=this.hub.subscriptions.get(t);if(!s)throw Error(`Subscription not found: ${t}`);s.remove(e),e.closed(),s.maybeUnsubscribe()}async _unsubscribe(e){let t=e.id;this.logger.debug("acquiring unsubscribe lock",{identifier:t});let s=await e.acquire("unsubscribed");if(s.canceled){this.logger.debug("unsubscribe lock has been canceled",{identifier:t}),s.release();return}if(this.logger.debug("unsubscribe lock has been acquired",{identifier:t}),e.intent!=="unsubscribed"){this.logger.debug("cancel unsubscribe, no longer needed",{identifier:t,intent:e.intent}),s.release();return}if(e.state==="disconnected"||e.state==="closed"){this.logger.debug(`already ${e.state} connected, skip unsubscribe command`,{identifier:t}),s.release();return}let r=e.remoteId;if(this.logger.debug("unsubscribing...",{remoteId:r}),this.state!=="connected"){this.logger.debug("unsubscribe skipped (cable is not connected)",{id:t}),e.close(),this.hub.unsubscribe(t),s.release();return}try{await this.protocol.unsubscribe(r),this.logger.debug("unsubscribed remotely",{id:t})}catch(i){i&&(i instanceof j?this.logger.debug("cable disconnected during the unsubscribe command execution",{id:t,error:i}):this.logger.error("unsubscribe failed",{id:t,error:i}))}e.intent==="unsubscribed"?(e.close(),this.hub.unsubscribe(t)):e.state="closed",s.release()}async perform(e,t,s){if(this.performFailures==="throw")return this._perform(e,t,s);try{return await this._perform(e,t,s)}catch(r){this.performFailures==="warn"&&this.logger.warn("perform failed",{error:r});return}}async _perform(e,t,s){if(this.state==="connecting"&&await this.pendingConnect(),this.state==="closed"||this.state==="disconnected")throw new qs;let r=this.hub.subscriptions.get(e);if(!r)throw Error(`Subscription not found: ${e}`);if(await r.pending("subscribed"),r.intent!=="subscribed")throw Error(`Subscription is closed: ${e}`);let i=r.remoteId,o={id:i,action:t,payload:s};this.logger.debug("perform",o);try{let c=await this.protocol.perform(i,t,s);return c&&this.logger.debug("perform result",{message:c,request:o}),c}catch(c){throw this.logger.error("perform failed",{error:c,request:o}),c}}on(e,t){return this.emitter.on(e,t)}once(e,t){let s=this.emitter.on(e,(...r)=>{s(),t(...r)});return s}emit(e,...t){return this.emitter.emit(e,...t)}pendingConnect(){return this._pendingConnect?this._pendingConnect:(this._pendingConnect=new Promise((e,t)=>{let s=[()=>delete this._pendingConnect];s.push(this.on("connect",()=>{s.forEach(r=>r()),e()})),s.push(this.on("close",r=>{s.forEach(i=>i()),t(r)})),s.push(this.on("disconnect",r=>{s.forEach(i=>i()),t(r)}))}),this._pendingConnect)}};const Hs={maxMissingPings:2,maxReconnectAttempts:1/0},W=()=>Date.now(),zt=(n,e)=>{e=e||{};let{backoffRate:t,jitterRatio:s,maxInterval:r}=e;return t=t||2,s===void 0&&(s=.5),i=>{let o=n*t**i,c=o*t,h=o+(c-o)*Math.random(),u=2*(Math.random()-.5)*s;return h=h*(1+u),r&&r<h&&(h=r),h}};let Vt=class{constructor({pingInterval:e,...t}){if(this.pingInterval=e,!this.pingInterval)throw Error(`Incorrect pingInterval is provided: ${e}`);if(t=Object.assign({},Hs,t),this.strategy=t.reconnectStrategy,!this.strategy)throw Error("Reconnect strategy must be provided");this.maxMissingPings=t.maxMissingPings,this.maxReconnectAttempts=t.maxReconnectAttempts,this.logger=t.logger||new se,this.state="pending_connect",this.attempts=0,this.disconnectedAt=W()}watch(e){this.target=e,this.initListeners()}reconnectNow(){return this.state==="connected"||this.state==="pending_connect"||this.state==="closed"?!1:(this.cancelReconnect(),this.state="pending_connect",this.target.connect().catch(e=>{this.logger.info("Failed at reconnecting: "+e)}),!0)}initListeners(){this.unbind=[],this.unbind.push(this.target.on("connect",()=>{this.attempts=0,this.pingedAt=W(),this.state="connected",this.cancelReconnect(),this.startPolling()})),this.unbind.push(this.target.on("disconnect",()=>{this.disconnectedAt=W(),this.state="disconnected",this.stopPolling(),this.scheduleReconnect()})),this.unbind.push(this.target.on("close",()=>{this.disconnectedAt=W(),this.state="closed",this.cancelReconnect(),this.stopPolling()})),this.unbind.push(this.target.on("keepalive",()=>{this.pingedAt=W()})),this.unbind.push(()=>{this.cancelReconnect(),this.stopPolling()})}dispose(){delete this.target,this.unbind&&this.unbind.forEach(e=>e()),delete this.unbind}startPolling(){this.pollId&&clearTimeout(this.pollId);let e=this.pingInterval+(Math.random()-.5)*this.pingInterval*.5;this.pollId=setTimeout(()=>{this.checkStale(),this.state==="connected"&&this.startPolling()},e)}stopPolling(){this.pollId&&clearTimeout(this.pollId)}checkStale(){let e=W()-this.pingedAt;e>this.maxMissingPings*this.pingInterval&&(this.logger.warn(`Stale connection: ${e}ms without pings`),this.state="pending_disconnect",this.target.disconnected(new Ps))}scheduleReconnect(){if(this.attempts>=this.maxReconnectAttempts){this.target.close();return}let e=this.strategy(this.attempts);this.attempts++,this.logger.info(`Reconnecting in ${e}ms (${this.attempts} attempt)`),this.state="pending_reconnect",this.reconnnectId=setTimeout(()=>this.reconnectNow(),e)}cancelReconnect(){this.reconnnectId&&(clearTimeout(this.reconnnectId),delete this.reconnnectId)}};class zs{constructor(e,t={}){this.transports=e,this.transport=null,this.emitter=_e(),this.unbind=[],this.logger=t.logger||new se}displayName(){return"fallbacked transport"}async open(){for(let e=0;e<this.transports.length;e++){let t=this.transports[e];try{this.transport=t,this.resetListeners(),this.logger.debug(`Trying to connect via ${t.displayName()}`),await t.open(),this.logger.debug(`Connected via ${t.displayName()}`);return}catch(s){this.logger.debug(`Failed to connect via ${t.displayName()}: ${s.message}`)}}throw this.transport=null,this.resetListeners(),new Error("Couldn't connect via any available transport")}send(e){if(!this.transport)throw new Error("No transport is open");this.transport.send(e)}async close(){if(!this.transport)throw new Error("No transport is open");await this.transport.close(),this.transport=null}setURL(){throw new Error("Not implemented. Set URL for each transport separately")}setParam(e,t){this.transports.forEach(s=>{s.setParam(e,t)})}setToken(e,t){this.transports.forEach(s=>{s.setToken(e,t)})}on(e,t){return this.emitter.on(e,t)}once(e,t){let s=this.emitter.on(e,(...r)=>{s(),t(...r)});return s}get url(){return this.transport?this.transport.url:""}resetListeners(){this.unbind.forEach(e=>e()),this.unbind.length=0,this.transport&&this.unbind.push(this.transport.on("open",()=>{this.emitter.emit("open")}),this.transport.on("data",e=>{this.emitter.emit("data",e)}),this.transport.on("close",e=>{this.emitter.emit("close",e)}),this.transport.on("error",e=>{this.emitter.emit("error",e)}))}}class Vs{constructor(e,t={}){this.url=e;let s=t.websocketImplementation;if(s)this.Impl=s;else if(typeof WebSocket<"u")this.Impl=WebSocket;else throw new Error("No WebSocket support");this.connected=!1,this.emitter=_e();let{format:r,subprotocol:i,authStrategy:o}=t;this.format=r||"text",this.connectionOptions=t.websocketOptions,this.authStrategy=o||"param",this.authProtocol="",this.subprotocol=i}displayName(){return"WebSocket("+this.url+")"}open(){let e=this.subprotocol;return this.authStrategy==="sub-protocol"&&(e=[this.subprotocol,this.authProtocol]),this.connectionOptions?this.ws=new this.Impl(this.url,e,this.connectionOptions):this.ws=new this.Impl(this.url,e),this.ws.binaryType="arraybuffer",this.initListeners(),new Promise((t,s)=>{let r=[];r.push(this.once("open",()=>{r.forEach(i=>i()),t()})),r.push(this.once("close",()=>{r.forEach(i=>i()),s(Error("WS connection closed"))}))})}setURL(e){this.url=e}setParam(e,t){let s=new URL(this.url);s.searchParams.set(e,t);let r=`${s.protocol}//${s.host}${s.pathname}?${s.searchParams}`;this.setURL(r)}setToken(e,t="jid"){if(this.authStrategy==="param")this.setParam(t,e);else if(this.authStrategy==="header"){this.connectionOptions=this.connectionOptions||{},this.connectionOptions.headers=this.connectionOptions.headers||{};let s=`x-${t}`.toLowerCase();s=Object.keys(this.connectionOptions.headers).find(i=>i.toLowerCase()===s)||s,this.connectionOptions.headers[s]=e}else if(this.authStrategy==="sub-protocol")this.authProtocol=`anycable-token.${e}`;else throw new Error("Unknown auth strategy: "+this.authStrategy)}send(e){if(!this.ws||!this.connected)throw Error("WebSocket is not connected");this.ws.send(e)}close(){this.ws?this.onclose():this.connected=!1}on(e,t){return this.emitter.on(e,t)}once(e,t){let s=this.emitter.on(e,(...r)=>{s(),t(...r)});return s}initListeners(){this.ws.onerror=e=>{this.connected&&this.emitter.emit("error",e.error||new Error("WS Error"))},this.ws.onclose=()=>{this.onclose()},this.ws.onmessage=e=>{let t=e.data;this.format==="binary"&&(t=new Uint8Array(t)),this.emitter.emit("data",t)},this.ws.onopen=()=>{this.connected=!0,this.emitter.emit("open")}}onclose(){this.ws.onclose=void 0,this.ws.onmessage=void 0,this.ws.onopen=void 0,this.ws.close(),delete this.ws,this.connected=!1,this.emitter.emit("close")}}const Jt={protocol:"actioncable-v1-json",pingInterval:3e3,maxReconnectAttempts:1/0,maxMissingPings:2,logLevel:"warn",lazy:!0};function Js(n,e){if(typeof n=="object"&&typeof e>"u"&&(e=n,n=void 0),e=e||{},!n&&!e.transport)throw Error("URL or transport must be specified");e=Object.assign({},Jt,e);let{protocol:t,websocketImplementation:s,websocketFormat:r,websocketOptions:i,websocketAuthStrategy:o,fallbacks:c,logLevel:h,logger:u,transport:a,encoder:d,lazy:g,monitor:b,pingInterval:f,reconnectStrategy:m,maxMissingPings:p,maxReconnectAttempts:_,subprotocol:E,tokenRefresher:S,historyTimestamp:N,protocolOptions:x,concurrentSubscribes:P,performFailures:I,transportConfigurator:D,auth:U}=e;if(u=u||new se(h),typeof t=="string"){E=E||t;let J=t.substring(0,t.lastIndexOf("-")),O=t.substring(t.lastIndexOf("-")+1);if(x=x||{},J==="actioncable-v1")t=new Ht({logger:u,...x});else if(J==="actioncable-v1-ext")t=new Ds({logger:u,historyTimestamp:N,...x});else throw Error(`Protocol is not supported yet: ${t}`);if(O==="json")d=d||new Fs,r=r||"text";else if(O==="msgpack"){if(r="binary",!d)throw Error("Msgpack encoder must be specified explicitly. Use `@anycable/msgpack-encoder` package or build your own")}else if(O==="protobuf"){if(r=r||"binary",!d)throw Error("Protobuf encoder must be specified explicitly. Use `@anycable/protobuf-encoder` package or build your own")}else throw Error(`Protocol is not supported yet: ${t}`)}if(!t)throw Error("Protocol must be specified");a=a||new Vs(n,{websocketImplementation:s,websocketOptions:i,subprotocol:E,authStrategy:o,format:r}),c&&(a=new zs([a,...c],{logger:u})),U&&U.token&&a.setToken(U.token,U.param||"jid"),m=m||zt(f),b!==!1&&(b=b||new Vt({pingInterval:f,reconnectStrategy:m,maxMissingPings:p,maxReconnectAttempts:_,logger:u}));let xe={concurrentSubscribes:P},v=new Ms({protocol:t,transport:a,encoder:d,logger:u,lazy:g,hubOptions:xe,performFailures:I,transportConfigurator:D});return b&&(b.watch(v),v.monitor=b),S&&Ws(v,async()=>{try{await S(a)}catch(J){return u.error("Failed to refresh authentication token: "+J),!1}return v.connect().catch(()=>{}),!0}),v}function Ws(n,e){let t=!1;n.on("connect",()=>t=!1),n.on("close",async s=>{if(s){if(t){n.logger.warn("Token auto-refresh is disabled",s);return}s.reason==="token_expired"&&(t=!0,await e())}})}class Ks{constructor(e){this.channel=e}notify(e,...t){typeof this[e]=="function"&&this[e](...t)}perform(e,t={}){this.channel.perform(e,t)}send(e){this.channel.send(e)}get identifier(){return this.channel.identifier}unsubscribe(){return this.channel.disconnect()}}class Xs extends He{constructor(e,t,s){super(e,t),this.subscription=new Ks(this),Object.assign(this.subscription,s),this.on("connect",({reconnect:r})=>this.subscription.notify("connected",{reconnected:r})),this.on("disconnect",()=>this.subscription.notify("disconnected",{allowReconnect:!0})),this.on("message",r=>this.subscription.notify("received",r)),this.on("close",r=>{r&&r instanceof Me?this.subscription.notify("rejected"):this.subscription.notify("disconnected",{allowReconnect:!1})})}}class Gs{constructor(e){this.cable=e}create(e,t){let s,r;typeof e=="object"?(s=e.channel,delete e.channel,r=e):(s=e,r={});let i=new Xs(s,r,t);return i.subscription.notify("initialized"),this.cable.subscribe(i),i.subscription}findAll(e){return this.cable.hub.channels.filter(t=>t.identifier===e).map(t=>t.subscription)}}class Zs{constructor(e){this.cable=e,this.subscriptions=new Gs(e)}}class Qs extends Mt{writeLogEntry(e,t,s){s?console[e](t,s):console[e](t)}}class Ys extends Vt{watch(e){super.watch(e),this.initActivityListeners()}initActivityListeners(){if(typeof document<"u"&&typeof window<"u"&&document.addEventListener&&window.addEventListener){let e=()=>{document.hidden||this.reconnectNow()&&this.logger.debug("Trigger reconnect due to visibility change")},t=r=>{this.reconnectNow()&&this.logger.debug("Trigger reconnect",{event:r})},s=()=>this.disconnect(new j("page_frozen"));document.addEventListener("visibilitychange",e,!1),window.addEventListener("focus",t,!1),window.addEventListener("online",t,!1),window.addEventListener("resume",t,!1),window.addEventListener("freeze",s,!1),this.unbind.push(()=>{document.removeEventListener("visibilitychange",e,!1),window.removeEventListener("focus",t,!1),window.removeEventListener("online",t,!1),window.removeEventListener("resume",t,!1),window.removeEventListener("freeze",s,!1)})}}disconnect(e){this.state==="disconnected"||this.state==="closed"||(this.logger.info("Disconnecting",{reason:e.message}),this.cancelReconnect(),this.stopPolling(),this.state="pending_disconnect",this.target.disconnected(e))}}const er=["cable","action-cable"],tr="/cable",Ee=(n,e)=>{for(let t of er){let s=n.head.querySelector(`meta[name='${t}-${e}']`);if(s)return s.getAttribute("content")}},lt=n=>n.match(/wss?:\/\//)?n:typeof window<"u"?`${window.location.protocol.replace("http","ws")}//${window.location.host}${n}`:n,nr=()=>{if(typeof document<"u"&&document.head){let n=Ee(document,"url");if(n)return lt(n)}return lt(tr)},sr=()=>{if(typeof document<"u"&&document.head){let n=Ee(document,"history-timestamp");if(n)return n|0}},rr=()=>{if(typeof document<"u"&&document.head)return Ee(document,"token")},ir=()=>{if(typeof document<"u"&&document.head)return Ee(document,"token-param")};function or(n,e){typeof n=="object"&&typeof e>"u"&&(e=n,n=void 0),n=n||nr(),e=e||{},e.historyTimestamp||(e.historyTimestamp=sr());let t=rr();if(t){let u=ir();e.auth=Object.assign({token:t,param:u},e.auth||{})}e=Object.assign({},Jt,e);let{logLevel:s,logger:r,pingInterval:i,reconnectStrategy:o,maxMissingPings:c,maxReconnectAttempts:h}=e;return r=e.logger=e.logger||new Qs(s),o=e.reconnectStrategy=e.reconnectStrategy||zt(i),e.monitor!==!1&&(e.monitor=e.monitor||new Ys({pingInterval:i,reconnectStrategy:o,maxMissingPings:c,maxReconnectAttempts:h,logger:r})),Js(n,e)}function cr(n,e){let t=or(n,e);return new Zs(t)}class ar{constructor(e="/openc3-api/cable"){this._cable=null,this._url=e}disconnect(){this._cable&&(this._cable.cable.disconnect(),this._cable=null)}createSubscription(e,t,s={},r={}){return OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity).then(i=>{if(i&&OpenC3Auth.setTokens(),this._cable==null){let o=this._url+"?scope="+encodeURIComponent(window.openc3Scope)+"&authorization="+encodeURIComponent(localStorage.openc3Token);o=new URL(o,document.baseURI).href,this._cable=cr(o)}return this._cable.subscriptions.create({channel:e,...r},s)})}recordPing(){}}class Fe{constructor(e,t,s="",r=""){this.keyword=e.keyword,this.parameters=e.parameters,this.filename=e.filename,this.line=e.line,this.lineNumber=e.lineNumber,this.message=t,this.usage=s,this.url=r}}class lr{constructor(){L(this,"keyword",null);L(this,"parameters",[]);L(this,"filename","");L(this,"line","");L(this,"lineNumber",0);L(this,"url","https://docs.openc3.com/docs/configuration")}verify_num_parameters(e,t,s=""){for(let r=1;r<=e;r++)if(this.parameters[r-1]===void 0)throw new Fe(this,`Not enough parameters for ${this.keyword}.`,s,this.url);if(t&&this.parameters[t]!==void 0)throw new Fe(this,`Too many parameters for ${this.keyword}.`,s,this.url)}remove_quotes(e){if(e.length<2)return e;let t=e.charAt(0);if(t!=='"'&&t!=="'")return e;let s=e.charAt(e.length-1);return t!==s?e:e.substring(1,e.length-1)}scan_string(e,t){if(!t.global)throw"rx must have 'global' flag set";let s=[];return e.replace(t,function(r){return s.push(r),r}),s}parse_string(e,t,s,r,i){let o=!1;this.line="",this.keyword=null,this.parameters=[],this.filename=t;let c=e.split(`
1
+ "use strict";var Qt=Object.defineProperty;var Zt=(n,e,t)=>e in n?Qt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var j=(n,e,t)=>Zt(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function gt(n,e){return function(){return n.apply(e,arguments)}}const{toString:Yt}=Object.prototype,{getPrototypeOf:qe}=Object,{iterator:me,toStringTag:bt}=Symbol,ge=(n=>e=>{const t=Yt.call(e);return n[t]||(n[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),$=n=>(n=n.toLowerCase(),e=>ge(e)===n),be=n=>e=>typeof e===n,{isArray:K}=Array,Y=be("undefined");function te(n){return n!==null&&!Y(n)&&n.constructor!==null&&!Y(n.constructor)&&T(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const yt=$("ArrayBuffer");function en(n){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(n):e=n&&n.buffer&&yt(n.buffer),e}const tn=be("string"),T=be("function"),wt=be("number"),ne=n=>n!==null&&typeof n=="object",nn=n=>n===!0||n===!1,ue=n=>{if(ge(n)!=="object")return!1;const e=qe(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(bt in n)&&!(me in n)},sn=n=>{if(!ne(n)||te(n))return!1;try{return Object.keys(n).length===0&&Object.getPrototypeOf(n)===Object.prototype}catch{return!1}},rn=$("Date"),on=$("File"),cn=$("Blob"),an=$("FileList"),ln=n=>ne(n)&&T(n.pipe),un=n=>{let e;return n&&(typeof FormData=="function"&&n instanceof FormData||T(n.append)&&((e=ge(n))==="formdata"||e==="object"&&T(n.toString)&&n.toString()==="[object FormData]"))},hn=$("URLSearchParams"),[dn,fn,pn,mn]=["ReadableStream","Request","Response","Headers"].map($),gn=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function se(n,e,{allOwnKeys:t=!1}={}){if(n===null||typeof n>"u")return;let s,r;if(typeof n!="object"&&(n=[n]),K(n))for(s=0,r=n.length;s<r;s++)e.call(null,n[s],s,n);else{if(te(n))return;const i=t?Object.getOwnPropertyNames(n):Object.keys(n),o=i.length;let c;for(s=0;s<o;s++)c=i[s],e.call(null,n[c],c,n)}}function _t(n,e){if(te(n))return null;e=e.toLowerCase();const t=Object.keys(n);let s=t.length,r;for(;s-- >0;)if(r=t[s],e===r.toLowerCase())return r;return null}const H=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,St=n=>!Y(n)&&n!==H;function Ne(){const{caseless:n}=St(this)&&this||{},e={},t=(s,r)=>{const i=n&&_t(e,r)||r;ue(e[i])&&ue(s)?e[i]=Ne(e[i],s):ue(s)?e[i]=Ne({},s):K(s)?e[i]=s.slice():e[i]=s};for(let s=0,r=arguments.length;s<r;s++)arguments[s]&&se(arguments[s],t);return e}const bn=(n,e,t,{allOwnKeys:s}={})=>(se(e,(r,i)=>{t&&T(r)?n[i]=gt(r,t):n[i]=r},{allOwnKeys:s}),n),yn=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),wn=(n,e,t,s)=>{n.prototype=Object.create(e.prototype,s),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:e.prototype}),t&&Object.assign(n.prototype,t)},_n=(n,e,t,s)=>{let r,i,o;const c={};if(e=e||{},n==null)return e;do{for(r=Object.getOwnPropertyNames(n),i=r.length;i-- >0;)o=r[i],(!s||s(o,n,e))&&!c[o]&&(e[o]=n[o],c[o]=!0);n=t!==!1&&qe(n)}while(n&&(!t||t(n,e))&&n!==Object.prototype);return e},Sn=(n,e,t)=>{n=String(n),(t===void 0||t>n.length)&&(t=n.length),t-=e.length;const s=n.indexOf(e,t);return s!==-1&&s===t},En=n=>{if(!n)return null;if(K(n))return n;let e=n.length;if(!wt(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=n[e];return t},xn=(n=>e=>n&&e instanceof n)(typeof Uint8Array<"u"&&qe(Uint8Array)),Rn=(n,e)=>{const s=(n&&n[me]).call(n);let r;for(;(r=s.next())&&!r.done;){const i=r.value;e.call(n,i[0],i[1])}},An=(n,e)=>{let t;const s=[];for(;(t=n.exec(e))!==null;)s.push(t);return s},On=$("HTMLFormElement"),Cn=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,s,r){return s.toUpperCase()+r}),Ke=(({hasOwnProperty:n})=>(e,t)=>n.call(e,t))(Object.prototype),Tn=$("RegExp"),Et=(n,e)=>{const t=Object.getOwnPropertyDescriptors(n),s={};se(t,(r,i)=>{let o;(o=e(r,i,n))!==!1&&(s[i]=o||r)}),Object.defineProperties(n,s)},kn=n=>{Et(n,(e,t)=>{if(T(n)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const s=n[t];if(T(s)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},Nn=(n,e)=>{const t={},s=r=>{r.forEach(i=>{t[i]=!0})};return K(n)?s(n):s(String(n).split(e)),t},Pn=()=>{},In=(n,e)=>n!=null&&Number.isFinite(n=+n)?n:e;function Ln(n){return!!(n&&T(n.append)&&n[bt]==="FormData"&&n[me])}const jn=n=>{const e=new Array(10),t=(s,r)=>{if(ne(s)){if(e.indexOf(s)>=0)return;if(te(s))return s;if(!("toJSON"in s)){e[r]=s;const i=K(s)?[]:{};return se(s,(o,c)=>{const h=t(o,r+1);!Y(h)&&(i[c]=h)}),e[r]=void 0,i}}return s};return t(n,0)},vn=$("AsyncFunction"),$n=n=>n&&(ne(n)||T(n))&&T(n.then)&&T(n.catch),xt=((n,e)=>n?setImmediate:e?((t,s)=>(H.addEventListener("message",({source:r,data:i})=>{r===H&&i===t&&s.length&&s.shift()()},!1),r=>{s.push(r),H.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",T(H.postMessage)),Fn=typeof queueMicrotask<"u"?queueMicrotask.bind(H):typeof process<"u"&&process.nextTick||xt,Un=n=>n!=null&&T(n[me]),l={isArray:K,isArrayBuffer:yt,isBuffer:te,isFormData:un,isArrayBufferView:en,isString:tn,isNumber:wt,isBoolean:nn,isObject:ne,isPlainObject:ue,isEmptyObject:sn,isReadableStream:dn,isRequest:fn,isResponse:pn,isHeaders:mn,isUndefined:Y,isDate:rn,isFile:on,isBlob:cn,isRegExp:Tn,isFunction:T,isStream:ln,isURLSearchParams:hn,isTypedArray:xn,isFileList:an,forEach:se,merge:Ne,extend:bn,trim:gn,stripBOM:yn,inherits:wn,toFlatObject:_n,kindOf:ge,kindOfTest:$,endsWith:Sn,toArray:En,forEachEntry:Rn,matchAll:An,isHTMLForm:On,hasOwnProperty:Ke,hasOwnProp:Ke,reduceDescriptors:Et,freezeMethods:kn,toObjectSet:Nn,toCamelCase:Cn,noop:Pn,toFiniteNumber:In,findKey:_t,global:H,isContextDefined:St,isSpecCompliantForm:Ln,toJSONObject:jn,isAsyncFn:vn,isThenable:$n,setImmediate:xt,asap:Fn,isIterable:Un};function y(n,e,t,s,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=n,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),s&&(this.request=s),r&&(this.response=r,this.status=r.status?r.status:null)}l.inherits(y,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:l.toJSONObject(this.config),code:this.code,status:this.status}}});const Rt=y.prototype,At={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(n=>{At[n]={value:n}});Object.defineProperties(y,At);Object.defineProperty(Rt,"isAxiosError",{value:!0});y.from=(n,e,t,s,r,i)=>{const o=Object.create(Rt);return l.toFlatObject(n,o,function(h){return h!==Error.prototype},c=>c!=="isAxiosError"),y.call(o,n.message,e,t,s,r),o.cause=n,o.name=n.name,i&&Object.assign(o,i),o};const Dn=null;function Pe(n){return l.isPlainObject(n)||l.isArray(n)}function Ot(n){return l.endsWith(n,"[]")?n.slice(0,-2):n}function Xe(n,e,t){return n?n.concat(e).map(function(r,i){return r=Ot(r),!t&&i?"["+r+"]":r}).join(t?".":""):e}function qn(n){return l.isArray(n)&&!n.some(Pe)}const Bn=l.toFlatObject(l,{},null,function(e){return/^is[A-Z]/.test(e)});function ye(n,e,t){if(!l.isObject(n))throw new TypeError("target must be an object");e=e||new FormData,t=l.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,p){return!l.isUndefined(p[m])});const s=t.metaTokens,r=t.visitor||a,i=t.dots,o=t.indexes,h=(t.Blob||typeof Blob<"u"&&Blob)&&l.isSpecCompliantForm(e);if(!l.isFunction(r))throw new TypeError("visitor must be a function");function u(f){if(f===null)return"";if(l.isDate(f))return f.toISOString();if(l.isBoolean(f))return f.toString();if(!h&&l.isBlob(f))throw new y("Blob is not supported. Use a Buffer instead.");return l.isArrayBuffer(f)||l.isTypedArray(f)?h&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function a(f,m,p){let _=f;if(f&&!p&&typeof f=="object"){if(l.endsWith(m,"{}"))m=s?m:m.slice(0,-2),f=JSON.stringify(f);else if(l.isArray(f)&&qn(f)||(l.isFileList(f)||l.endsWith(m,"[]"))&&(_=l.toArray(f)))return m=Ot(m),_.forEach(function(E,N){!(l.isUndefined(E)||E===null)&&e.append(o===!0?Xe([m],N,i):o===null?m:m+"[]",u(E))}),!1}return Pe(f)?!0:(e.append(Xe(p,m,i),u(f)),!1)}const d=[],g=Object.assign(Bn,{defaultVisitor:a,convertValue:u,isVisitable:Pe});function b(f,m){if(!l.isUndefined(f)){if(d.indexOf(f)!==-1)throw Error("Circular reference detected in "+m.join("."));d.push(f),l.forEach(f,function(_,S){(!(l.isUndefined(_)||_===null)&&r.call(e,_,l.isString(S)?S.trim():S,m,g))===!0&&b(_,m?m.concat(S):[S])}),d.pop()}}if(!l.isObject(n))throw new TypeError("data must be an object");return b(n),e}function Ge(n){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(s){return e[s]})}function Be(n,e){this._pairs=[],n&&ye(n,this,e)}const Ct=Be.prototype;Ct.append=function(e,t){this._pairs.push([e,t])};Ct.toString=function(e){const t=e?function(s){return e.call(this,s,Ge)}:Ge;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};function Mn(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Tt(n,e,t){if(!e)return n;const s=t&&t.encode||Mn;l.isFunction(t)&&(t={serialize:t});const r=t&&t.serialize;let i;if(r?i=r(e,t):i=l.isURLSearchParams(e)?e.toString():new Be(e,t).toString(s),i){const o=n.indexOf("#");o!==-1&&(n=n.slice(0,o)),n+=(n.indexOf("?")===-1?"?":"&")+i}return n}class Qe{constructor(){this.handlers=[]}use(e,t,s){return this.handlers.push({fulfilled:e,rejected:t,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){l.forEach(this.handlers,function(s){s!==null&&e(s)})}}const kt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Hn=typeof URLSearchParams<"u"?URLSearchParams:Be,zn=typeof FormData<"u"?FormData:null,Vn=typeof Blob<"u"?Blob:null,Jn={isBrowser:!0,classes:{URLSearchParams:Hn,FormData:zn,Blob:Vn},protocols:["http","https","file","blob","url","data"]},Me=typeof window<"u"&&typeof document<"u",Ie=typeof navigator=="object"&&navigator||void 0,Wn=Me&&(!Ie||["ReactNative","NativeScript","NS"].indexOf(Ie.product)<0),Kn=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Xn=Me&&window.location.href||"http://localhost",Gn=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Me,hasStandardBrowserEnv:Wn,hasStandardBrowserWebWorkerEnv:Kn,navigator:Ie,origin:Xn},Symbol.toStringTag,{value:"Module"})),O={...Gn,...Jn};function Qn(n,e){return ye(n,new O.classes.URLSearchParams,{visitor:function(t,s,r,i){return O.isNode&&l.isBuffer(t)?(this.append(s,t.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...e})}function Zn(n){return l.matchAll(/\w+|\[(\w*)]/g,n).map(e=>e[0]==="[]"?"":e[1]||e[0])}function Yn(n){const e={},t=Object.keys(n);let s;const r=t.length;let i;for(s=0;s<r;s++)i=t[s],e[i]=n[i];return e}function Nt(n){function e(t,s,r,i){let o=t[i++];if(o==="__proto__")return!0;const c=Number.isFinite(+o),h=i>=t.length;return o=!o&&l.isArray(r)?r.length:o,h?(l.hasOwnProp(r,o)?r[o]=[r[o],s]:r[o]=s,!c):((!r[o]||!l.isObject(r[o]))&&(r[o]=[]),e(t,s,r[o],i)&&l.isArray(r[o])&&(r[o]=Yn(r[o])),!c)}if(l.isFormData(n)&&l.isFunction(n.entries)){const t={};return l.forEachEntry(n,(s,r)=>{e(Zn(s),r,t,0)}),t}return null}function es(n,e,t){if(l.isString(n))try{return(e||JSON.parse)(n),l.trim(n)}catch(s){if(s.name!=="SyntaxError")throw s}return(t||JSON.stringify)(n)}const re={transitional:kt,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const s=t.getContentType()||"",r=s.indexOf("application/json")>-1,i=l.isObject(e);if(i&&l.isHTMLForm(e)&&(e=new FormData(e)),l.isFormData(e))return r?JSON.stringify(Nt(e)):e;if(l.isArrayBuffer(e)||l.isBuffer(e)||l.isStream(e)||l.isFile(e)||l.isBlob(e)||l.isReadableStream(e))return e;if(l.isArrayBufferView(e))return e.buffer;if(l.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let c;if(i){if(s.indexOf("application/x-www-form-urlencoded")>-1)return Qn(e,this.formSerializer).toString();if((c=l.isFileList(e))||s.indexOf("multipart/form-data")>-1){const h=this.env&&this.env.FormData;return ye(c?{"files[]":e}:e,h&&new h,this.formSerializer)}}return i||r?(t.setContentType("application/json",!1),es(e)):e}],transformResponse:[function(e){const t=this.transitional||re.transitional,s=t&&t.forcedJSONParsing,r=this.responseType==="json";if(l.isResponse(e)||l.isReadableStream(e))return e;if(e&&l.isString(e)&&(s&&!this.responseType||r)){const o=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(c){if(o)throw c.name==="SyntaxError"?y.from(c,y.ERR_BAD_RESPONSE,this,null,this.response):c}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:O.classes.FormData,Blob:O.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};l.forEach(["delete","get","head","post","put","patch"],n=>{re.headers[n]={}});const ts=l.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),ns=n=>{const e={};let t,s,r;return n&&n.split(`
2
+ `).forEach(function(o){r=o.indexOf(":"),t=o.substring(0,r).trim().toLowerCase(),s=o.substring(r+1).trim(),!(!t||e[t]&&ts[t])&&(t==="set-cookie"?e[t]?e[t].push(s):e[t]=[s]:e[t]=e[t]?e[t]+", "+s:s)}),e},Ze=Symbol("internals");function Q(n){return n&&String(n).trim().toLowerCase()}function he(n){return n===!1||n==null?n:l.isArray(n)?n.map(he):String(n)}function ss(n){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=t.exec(n);)e[s[1]]=s[2];return e}const rs=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function Oe(n,e,t,s,r){if(l.isFunction(s))return s.call(this,e,t);if(r&&(e=t),!!l.isString(e)){if(l.isString(s))return e.indexOf(s)!==-1;if(l.isRegExp(s))return s.test(e)}}function is(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,s)=>t.toUpperCase()+s)}function os(n,e){const t=l.toCamelCase(" "+e);["get","set","has"].forEach(s=>{Object.defineProperty(n,s+t,{value:function(r,i,o){return this[s].call(this,e,r,i,o)},configurable:!0})})}let k=class{constructor(e){e&&this.set(e)}set(e,t,s){const r=this;function i(c,h,u){const a=Q(h);if(!a)throw new Error("header name must be a non-empty string");const d=l.findKey(r,a);(!d||r[d]===void 0||u===!0||u===void 0&&r[d]!==!1)&&(r[d||h]=he(c))}const o=(c,h)=>l.forEach(c,(u,a)=>i(u,a,h));if(l.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(l.isString(e)&&(e=e.trim())&&!rs(e))o(ns(e),t);else if(l.isObject(e)&&l.isIterable(e)){let c={},h,u;for(const a of e){if(!l.isArray(a))throw TypeError("Object iterator must return a key-value pair");c[u=a[0]]=(h=c[u])?l.isArray(h)?[...h,a[1]]:[h,a[1]]:a[1]}o(c,t)}else e!=null&&i(t,e,s);return this}get(e,t){if(e=Q(e),e){const s=l.findKey(this,e);if(s){const r=this[s];if(!t)return r;if(t===!0)return ss(r);if(l.isFunction(t))return t.call(this,r,s);if(l.isRegExp(t))return t.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Q(e),e){const s=l.findKey(this,e);return!!(s&&this[s]!==void 0&&(!t||Oe(this,this[s],s,t)))}return!1}delete(e,t){const s=this;let r=!1;function i(o){if(o=Q(o),o){const c=l.findKey(s,o);c&&(!t||Oe(s,s[c],c,t))&&(delete s[c],r=!0)}}return l.isArray(e)?e.forEach(i):i(e),r}clear(e){const t=Object.keys(this);let s=t.length,r=!1;for(;s--;){const i=t[s];(!e||Oe(this,this[i],i,e,!0))&&(delete this[i],r=!0)}return r}normalize(e){const t=this,s={};return l.forEach(this,(r,i)=>{const o=l.findKey(s,i);if(o){t[o]=he(r),delete t[i];return}const c=e?is(i):String(i).trim();c!==i&&delete t[i],t[c]=he(r),s[c]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return l.forEach(this,(s,r)=>{s!=null&&s!==!1&&(t[r]=e&&l.isArray(s)?s.join(", "):s)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
3
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const s=new this(e);return t.forEach(r=>s.set(r)),s}static accessor(e){const s=(this[Ze]=this[Ze]={accessors:{}}).accessors,r=this.prototype;function i(o){const c=Q(o);s[c]||(os(r,o),s[c]=!0)}return l.isArray(e)?e.forEach(i):i(e),this}};k.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);l.reduceDescriptors(k.prototype,({value:n},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>n,set(s){this[t]=s}}});l.freezeMethods(k);function Ce(n,e){const t=this||re,s=e||t,r=k.from(s.headers);let i=s.data;return l.forEach(n,function(c){i=c.call(t,i,r.normalize(),e?e.status:void 0)}),r.normalize(),i}function Pt(n){return!!(n&&n.__CANCEL__)}function X(n,e,t){y.call(this,n??"canceled",y.ERR_CANCELED,e,t),this.name="CanceledError"}l.inherits(X,y,{__CANCEL__:!0});function It(n,e,t){const s=t.config.validateStatus;!t.status||!s||s(t.status)?n(t):e(new y("Request failed with status code "+t.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function cs(n){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return e&&e[1]||""}function as(n,e){n=n||10;const t=new Array(n),s=new Array(n);let r=0,i=0,o;return e=e!==void 0?e:1e3,function(h){const u=Date.now(),a=s[i];o||(o=u),t[r]=h,s[r]=u;let d=i,g=0;for(;d!==r;)g+=t[d++],d=d%n;if(r=(r+1)%n,r===i&&(i=(i+1)%n),u-o<e)return;const b=a&&u-a;return b?Math.round(g*1e3/b):void 0}}function ls(n,e){let t=0,s=1e3/e,r,i;const o=(u,a=Date.now())=>{t=a,r=null,i&&(clearTimeout(i),i=null),n(...u)};return[(...u)=>{const a=Date.now(),d=a-t;d>=s?o(u,a):(r=u,i||(i=setTimeout(()=>{i=null,o(r)},s-d)))},()=>r&&o(r)]}const fe=(n,e,t=3)=>{let s=0;const r=as(50,250);return ls(i=>{const o=i.loaded,c=i.lengthComputable?i.total:void 0,h=o-s,u=r(h),a=o<=c;s=o;const d={loaded:o,total:c,progress:c?o/c:void 0,bytes:h,rate:u||void 0,estimated:u&&c&&a?(c-o)/u:void 0,event:i,lengthComputable:c!=null,[e?"download":"upload"]:!0};n(d)},t)},Ye=(n,e)=>{const t=n!=null;return[s=>e[0]({lengthComputable:t,total:n,loaded:s}),e[1]]},et=n=>(...e)=>l.asap(()=>n(...e)),us=O.hasStandardBrowserEnv?((n,e)=>t=>(t=new URL(t,O.origin),n.protocol===t.protocol&&n.host===t.host&&(e||n.port===t.port)))(new URL(O.origin),O.navigator&&/(msie|trident)/i.test(O.navigator.userAgent)):()=>!0,hs=O.hasStandardBrowserEnv?{write(n,e,t,s,r,i){const o=[n+"="+encodeURIComponent(e)];l.isNumber(t)&&o.push("expires="+new Date(t).toGMTString()),l.isString(s)&&o.push("path="+s),l.isString(r)&&o.push("domain="+r),i===!0&&o.push("secure"),document.cookie=o.join("; ")},read(n){const e=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(n){this.write(n,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function ds(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function fs(n,e){return e?n.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):n}function Lt(n,e,t){let s=!ds(e);return n&&(s||t==!1)?fs(n,e):e}const tt=n=>n instanceof k?{...n}:n;function V(n,e){e=e||{};const t={};function s(u,a,d,g){return l.isPlainObject(u)&&l.isPlainObject(a)?l.merge.call({caseless:g},u,a):l.isPlainObject(a)?l.merge({},a):l.isArray(a)?a.slice():a}function r(u,a,d,g){if(l.isUndefined(a)){if(!l.isUndefined(u))return s(void 0,u,d,g)}else return s(u,a,d,g)}function i(u,a){if(!l.isUndefined(a))return s(void 0,a)}function o(u,a){if(l.isUndefined(a)){if(!l.isUndefined(u))return s(void 0,u)}else return s(void 0,a)}function c(u,a,d){if(d in e)return s(u,a);if(d in n)return s(void 0,u)}const h={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(u,a,d)=>r(tt(u),tt(a),d,!0)};return l.forEach(Object.keys({...n,...e}),function(a){const d=h[a]||r,g=d(n[a],e[a],a);l.isUndefined(g)&&d!==c||(t[a]=g)}),t}const jt=n=>{const e=V({},n);let{data:t,withXSRFToken:s,xsrfHeaderName:r,xsrfCookieName:i,headers:o,auth:c}=e;e.headers=o=k.from(o),e.url=Tt(Lt(e.baseURL,e.url,e.allowAbsoluteUrls),n.params,n.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let h;if(l.isFormData(t)){if(O.hasStandardBrowserEnv||O.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if((h=o.getContentType())!==!1){const[u,...a]=h?h.split(";").map(d=>d.trim()).filter(Boolean):[];o.setContentType([u||"multipart/form-data",...a].join("; "))}}if(O.hasStandardBrowserEnv&&(s&&l.isFunction(s)&&(s=s(e)),s||s!==!1&&us(e.url))){const u=r&&i&&hs.read(i);u&&o.set(r,u)}return e},ps=typeof XMLHttpRequest<"u",ms=ps&&function(n){return new Promise(function(t,s){const r=jt(n);let i=r.data;const o=k.from(r.headers).normalize();let{responseType:c,onUploadProgress:h,onDownloadProgress:u}=r,a,d,g,b,f;function m(){b&&b(),f&&f(),r.cancelToken&&r.cancelToken.unsubscribe(a),r.signal&&r.signal.removeEventListener("abort",a)}let p=new XMLHttpRequest;p.open(r.method.toUpperCase(),r.url,!0),p.timeout=r.timeout;function _(){if(!p)return;const E=k.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),x={data:!c||c==="text"||c==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:E,config:n,request:p};It(function(I){t(I),m()},function(I){s(I),m()},x),p=null}"onloadend"in p?p.onloadend=_:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(_)},p.onabort=function(){p&&(s(new y("Request aborted",y.ECONNABORTED,n,p)),p=null)},p.onerror=function(){s(new y("Network Error",y.ERR_NETWORK,n,p)),p=null},p.ontimeout=function(){let N=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const x=r.transitional||kt;r.timeoutErrorMessage&&(N=r.timeoutErrorMessage),s(new y(N,x.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,n,p)),p=null},i===void 0&&o.setContentType(null),"setRequestHeader"in p&&l.forEach(o.toJSON(),function(N,x){p.setRequestHeader(x,N)}),l.isUndefined(r.withCredentials)||(p.withCredentials=!!r.withCredentials),c&&c!=="json"&&(p.responseType=r.responseType),u&&([g,f]=fe(u,!0),p.addEventListener("progress",g)),h&&p.upload&&([d,b]=fe(h),p.upload.addEventListener("progress",d),p.upload.addEventListener("loadend",b)),(r.cancelToken||r.signal)&&(a=E=>{p&&(s(!E||E.type?new X(null,n,p):E),p.abort(),p=null)},r.cancelToken&&r.cancelToken.subscribe(a),r.signal&&(r.signal.aborted?a():r.signal.addEventListener("abort",a)));const S=cs(r.url);if(S&&O.protocols.indexOf(S)===-1){s(new y("Unsupported protocol "+S+":",y.ERR_BAD_REQUEST,n));return}p.send(i||null)})},gs=(n,e)=>{const{length:t}=n=n?n.filter(Boolean):[];if(e||t){let s=new AbortController,r;const i=function(u){if(!r){r=!0,c();const a=u instanceof Error?u:this.reason;s.abort(a instanceof y?a:new X(a instanceof Error?a.message:a))}};let o=e&&setTimeout(()=>{o=null,i(new y(`timeout ${e} of ms exceeded`,y.ETIMEDOUT))},e);const c=()=>{n&&(o&&clearTimeout(o),o=null,n.forEach(u=>{u.unsubscribe?u.unsubscribe(i):u.removeEventListener("abort",i)}),n=null)};n.forEach(u=>u.addEventListener("abort",i));const{signal:h}=s;return h.unsubscribe=()=>l.asap(c),h}},bs=function*(n,e){let t=n.byteLength;if(t<e){yield n;return}let s=0,r;for(;s<t;)r=s+e,yield n.slice(s,r),s=r},ys=async function*(n,e){for await(const t of ws(n))yield*bs(t,e)},ws=async function*(n){if(n[Symbol.asyncIterator]){yield*n;return}const e=n.getReader();try{for(;;){const{done:t,value:s}=await e.read();if(t)break;yield s}}finally{await e.cancel()}},nt=(n,e,t,s)=>{const r=ys(n,e);let i=0,o,c=h=>{o||(o=!0,s&&s(h))};return new ReadableStream({async pull(h){try{const{done:u,value:a}=await r.next();if(u){c(),h.close();return}let d=a.byteLength;if(t){let g=i+=d;t(g)}h.enqueue(new Uint8Array(a))}catch(u){throw c(u),u}},cancel(h){return c(h),r.return()}},{highWaterMark:2})},we=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",vt=we&&typeof ReadableStream=="function",_s=we&&(typeof TextEncoder=="function"?(n=>e=>n.encode(e))(new TextEncoder):async n=>new Uint8Array(await new Response(n).arrayBuffer())),$t=(n,...e)=>{try{return!!n(...e)}catch{return!1}},Ss=vt&&$t(()=>{let n=!1;const e=new Request(O.origin,{body:new ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type");return n&&!e}),st=64*1024,Le=vt&&$t(()=>l.isReadableStream(new Response("").body)),pe={stream:Le&&(n=>n.body)};we&&(n=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!pe[e]&&(pe[e]=l.isFunction(n[e])?t=>t[e]():(t,s)=>{throw new y(`Response type '${e}' is not supported`,y.ERR_NOT_SUPPORT,s)})})})(new Response);const Es=async n=>{if(n==null)return 0;if(l.isBlob(n))return n.size;if(l.isSpecCompliantForm(n))return(await new Request(O.origin,{method:"POST",body:n}).arrayBuffer()).byteLength;if(l.isArrayBufferView(n)||l.isArrayBuffer(n))return n.byteLength;if(l.isURLSearchParams(n)&&(n=n+""),l.isString(n))return(await _s(n)).byteLength},xs=async(n,e)=>{const t=l.toFiniteNumber(n.getContentLength());return t??Es(e)},Rs=we&&(async n=>{let{url:e,method:t,data:s,signal:r,cancelToken:i,timeout:o,onDownloadProgress:c,onUploadProgress:h,responseType:u,headers:a,withCredentials:d="same-origin",fetchOptions:g}=jt(n);u=u?(u+"").toLowerCase():"text";let b=gs([r,i&&i.toAbortSignal()],o),f;const m=b&&b.unsubscribe&&(()=>{b.unsubscribe()});let p;try{if(h&&Ss&&t!=="get"&&t!=="head"&&(p=await xs(a,s))!==0){let x=new Request(e,{method:"POST",body:s,duplex:"half"}),P;if(l.isFormData(s)&&(P=x.headers.get("content-type"))&&a.setContentType(P),x.body){const[I,D]=Ye(p,fe(et(h)));s=nt(x.body,st,I,D)}}l.isString(d)||(d=d?"include":"omit");const _="credentials"in Request.prototype;f=new Request(e,{...g,signal:b,method:t.toUpperCase(),headers:a.normalize().toJSON(),body:s,duplex:"half",credentials:_?d:void 0});let S=await fetch(f,g);const E=Le&&(u==="stream"||u==="response");if(Le&&(c||E&&m)){const x={};["status","statusText","headers"].forEach(U=>{x[U]=S[U]});const P=l.toFiniteNumber(S.headers.get("content-length")),[I,D]=c&&Ye(P,fe(et(c),!0))||[];S=new Response(nt(S.body,st,I,()=>{D&&D(),m&&m()}),x)}u=u||"text";let N=await pe[l.findKey(pe,u)||"text"](S,n);return!E&&m&&m(),await new Promise((x,P)=>{It(x,P,{data:N,headers:k.from(S.headers),status:S.status,statusText:S.statusText,config:n,request:f})})}catch(_){throw m&&m(),_&&_.name==="TypeError"&&/Load failed|fetch/i.test(_.message)?Object.assign(new y("Network Error",y.ERR_NETWORK,n,f),{cause:_.cause||_}):y.from(_,_&&_.code,n,f)}}),je={http:Dn,xhr:ms,fetch:Rs};l.forEach(je,(n,e)=>{if(n){try{Object.defineProperty(n,"name",{value:e})}catch{}Object.defineProperty(n,"adapterName",{value:e})}});const rt=n=>`- ${n}`,As=n=>l.isFunction(n)||n===null||n===!1,Ft={getAdapter:n=>{n=l.isArray(n)?n:[n];const{length:e}=n;let t,s;const r={};for(let i=0;i<e;i++){t=n[i];let o;if(s=t,!As(t)&&(s=je[(o=String(t)).toLowerCase()],s===void 0))throw new y(`Unknown adapter '${o}'`);if(s)break;r[o||"#"+i]=s}if(!s){const i=Object.entries(r).map(([c,h])=>`adapter ${c} `+(h===!1?"is not supported by the environment":"is not available in the build"));let o=e?i.length>1?`since :
4
+ `+i.map(rt).join(`
5
+ `):" "+rt(i[0]):"as no adapter specified";throw new y("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return s},adapters:je};function Te(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new X(null,n)}function it(n){return Te(n),n.headers=k.from(n.headers),n.data=Ce.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),Ft.getAdapter(n.adapter||re.adapter)(n).then(function(s){return Te(n),s.data=Ce.call(n,n.transformResponse,s),s.headers=k.from(s.headers),s},function(s){return Pt(s)||(Te(n),s&&s.response&&(s.response.data=Ce.call(n,n.transformResponse,s.response),s.response.headers=k.from(s.response.headers))),Promise.reject(s)})}const Ut="1.11.0",_e={};["object","boolean","number","function","string","symbol"].forEach((n,e)=>{_e[n]=function(s){return typeof s===n||"a"+(e<1?"n ":" ")+n}});const ot={};_e.transitional=function(e,t,s){function r(i,o){return"[Axios v"+Ut+"] Transitional option '"+i+"'"+o+(s?". "+s:"")}return(i,o,c)=>{if(e===!1)throw new y(r(o," has been removed"+(t?" in "+t:"")),y.ERR_DEPRECATED);return t&&!ot[o]&&(ot[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,o,c):!0}};_e.spelling=function(e){return(t,s)=>(console.warn(`${s} is likely a misspelling of ${e}`),!0)};function Os(n,e,t){if(typeof n!="object")throw new y("options must be an object",y.ERR_BAD_OPTION_VALUE);const s=Object.keys(n);let r=s.length;for(;r-- >0;){const i=s[r],o=e[i];if(o){const c=n[i],h=c===void 0||o(c,i,n);if(h!==!0)throw new y("option "+i+" must be "+h,y.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new y("Unknown option "+i,y.ERR_BAD_OPTION)}}const de={assertOptions:Os,validators:_e},F=de.validators;let z=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Qe,response:new Qe}}async request(e,t){try{return await this._request(e,t)}catch(s){if(s instanceof Error){let r={};Error.captureStackTrace?Error.captureStackTrace(r):r=new Error;const i=r.stack?r.stack.replace(/^.+\n/,""):"";try{s.stack?i&&!String(s.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(s.stack+=`
6
+ `+i):s.stack=i}catch{}}throw s}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=V(this.defaults,t);const{transitional:s,paramsSerializer:r,headers:i}=t;s!==void 0&&de.assertOptions(s,{silentJSONParsing:F.transitional(F.boolean),forcedJSONParsing:F.transitional(F.boolean),clarifyTimeoutError:F.transitional(F.boolean)},!1),r!=null&&(l.isFunction(r)?t.paramsSerializer={serialize:r}:de.assertOptions(r,{encode:F.function,serialize:F.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),de.assertOptions(t,{baseUrl:F.spelling("baseURL"),withXsrfToken:F.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&l.merge(i.common,i[t.method]);i&&l.forEach(["delete","get","head","post","put","patch","common"],f=>{delete i[f]}),t.headers=k.concat(o,i);const c=[];let h=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(t)===!1||(h=h&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const u=[];this.interceptors.response.forEach(function(m){u.push(m.fulfilled,m.rejected)});let a,d=0,g;if(!h){const f=[it.bind(this),void 0];for(f.unshift(...c),f.push(...u),g=f.length,a=Promise.resolve(t);d<g;)a=a.then(f[d++],f[d++]);return a}g=c.length;let b=t;for(d=0;d<g;){const f=c[d++],m=c[d++];try{b=f(b)}catch(p){m.call(this,p);break}}try{a=it.call(this,b)}catch(f){return Promise.reject(f)}for(d=0,g=u.length;d<g;)a=a.then(u[d++],u[d++]);return a}getUri(e){e=V(this.defaults,e);const t=Lt(e.baseURL,e.url,e.allowAbsoluteUrls);return Tt(t,e.params,e.paramsSerializer)}};l.forEach(["delete","get","head","options"],function(e){z.prototype[e]=function(t,s){return this.request(V(s||{},{method:e,url:t,data:(s||{}).data}))}});l.forEach(["post","put","patch"],function(e){function t(s){return function(i,o,c){return this.request(V(c||{},{method:e,headers:s?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}z.prototype[e]=t(),z.prototype[e+"Form"]=t(!0)});let Cs=class Dt{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(i){t=i});const s=this;this.promise.then(r=>{if(!s._listeners)return;let i=s._listeners.length;for(;i-- >0;)s._listeners[i](r);s._listeners=null}),this.promise.then=r=>{let i;const o=new Promise(c=>{s.subscribe(c),i=c}).then(r);return o.cancel=function(){s.unsubscribe(i)},o},e(function(i,o,c){s.reason||(s.reason=new X(i,o,c),t(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=s=>{e.abort(s)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new Dt(function(r){e=r}),cancel:e}}};function Ts(n){return function(t){return n.apply(null,t)}}function ks(n){return l.isObject(n)&&n.isAxiosError===!0}const ve={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ve).forEach(([n,e])=>{ve[e]=n});function qt(n){const e=new z(n),t=gt(z.prototype.request,e);return l.extend(t,z.prototype,e,{allOwnKeys:!0}),l.extend(t,e,null,{allOwnKeys:!0}),t.create=function(r){return qt(V(n,r))},t}const R=qt(re);R.Axios=z;R.CanceledError=X;R.CancelToken=Cs;R.isCancel=Pt;R.VERSION=Ut;R.toFormData=ye;R.AxiosError=y;R.Cancel=R.CanceledError;R.all=function(e){return Promise.all(e)};R.spread=Ts;R.isAxiosError=ks;R.mergeConfig=V;R.AxiosHeaders=k;R.formToJSON=n=>Nt(l.isHTMLForm(n)?new FormData(n):n);R.getAdapter=Ft.getAdapter;R.HttpStatusCode=ve;R.default=R;const{Axios:Xr,AxiosError:Gr,CanceledError:Qr,isCancel:Zr,CancelToken:Yr,VERSION:ei,all:ti,Cancel:ni,isAxiosError:si,spread:ri,toFormData:ii,AxiosHeaders:oi,HttpStatusCode:ci,formToJSON:ai,getAdapter:li,mergeConfig:ui}=R,Se=R.create({baseURL:location.origin,timeout:6e4,params:{}});Se.interceptors.response.use(n=>n,n=>{var e,t,s,r,i,o,c,h,u,a,d;if(n.response){if(n.response.status===401&&OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity,!0).then(function(f){f&&OpenC3Auth.setTokens()}),n.response.config.headers["Ignore-Errors"]&&n.response.config.headers["Ignore-Errors"].includes(n.response.status.toString()))return Promise.reject(n);let g=`HTTP ${n.response.status} - `;(e=n.response)!=null&&e.statusText&&(g+=`${n.response.statusText} `),(s=(t=n.response)==null?void 0:t.config)!=null&&s.data&&(g+=`${n.response.config.data} `),(i=(r=n.response)==null?void 0:r.data)!=null&&i.message?g+=`${n.response.data.message}`:(c=(o=n.response)==null?void 0:o.data)!=null&&c.exception?g+=`${n.response.data.exception}`:(a=(u=(h=n.response)==null?void 0:h.data)==null?void 0:u.error)!=null&&a.message?(n.response.data.error.class&&(g+=`${n.response.data.error.class} `),g+=`${n.response.data.error.message}`):g+=`${(d=n.response)==null?void 0:d.data}`;const{$cosmosNotify:b}=window;throw b&&b.serious({title:"Network error",body:g}),n}else throw n});const ce=async function(n,e,{data:t,params:s={},headers:r,noAuth:i=!1,noScope:o=!1,onUploadProgress:c=!1}={}){if(!i){try{await OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity)&&OpenC3Auth.setTokens()}catch{OpenC3Auth.login()}r.Authorization=localStorage.openc3Token}return r.manual=!0,!o&&!s.scope&&(s.scope=window.openc3Scope),Se({method:n,url:e,data:t,params:s,headers:r,onUploadProgress:c})},$e={Accept:"application/json"},ct={...$e,"Content-Type":"application/json"},Ns={get:function(n,{params:e,headers:t=$e,noScope:s,noAuth:r,onUploadProgress:i}={}){return ce("get",n,{params:e,headers:t,noScope:s,noAuth:r,onUploadProgress:i})},put:function(n,{data:e,params:t,headers:s=ct,noScope:r,noAuth:i,onUploadProgress:o}={}){return ce("put",n,{data:e,params:t,headers:s,noScope:r,noAuth:i,onUploadProgress:o})},post:function(n,{data:e,params:t,headers:s=ct,noScope:r,noAuth:i,onUploadProgress:o}={}){return ce("post",n,{data:e,params:t,headers:s,noScope:r,noAuth:i,onUploadProgress:o})},delete:function(n,{params:e,headers:t=$e,noScope:s,noAuth:r,onUploadProgress:i}={}){return ce("delete",n,{params:e,headers:t,noScope:s,noAuth:r,onUploadProgress:i})}};let Ee=()=>({emit(n,...e){for(let t=this.events[n]||[],s=0,r=t.length;s<r;s++)t[s](...e)},events:{},on(n,e){var t;return((t=this.events)[n]||(t[n]=[])).push(e),()=>{var s;this.events[n]=(s=this.events[n])==null?void 0:s.filter(r=>e!==r)}}});class ie extends Error{constructor(e,t){e instanceof Error?(super(e.message),this.cause=e):super(e),this.reason=t,this.name="ReasonError"}}class He extends ie{constructor(e){super("Rejected",e),this.name="SubscriptionRejectedError"}}class Ps extends ie{constructor(e){super(e||"Timed out to receive subscription ack"),this.name="SubscriptionTimeoutError"}}class v extends ie{constructor(e,t){t?super(e,t):super("Disconnected",e),this.name="DisconnectedError"}}class Is extends v{constructor(e){super(e,"stale_connection"),this.name="StaleConnectionError"}}function Bt(n){return n?`{${Object.keys(n).sort().filter(t=>n[t]!==void 0).map(t=>{let s=JSON.stringify(n[t]);return`${JSON.stringify(t)}:${s}`}).join(",")}}`:""}class Ls{constructor(e){this.channel=e,this.listeners=[]}watch(){this.listeners.push(this.channel.on("presence",e=>{if(e.type==="info"){this._state||(this._state=this.stateFromInfo(e));return}this._state&&(e.type==="join"?this._state[e.id]=e.info:e.type==="leave"&&delete this._state[e.id])}))}reset(){delete this._state}dispose(){delete this._info,delete this._state,this.listeners.forEach(e=>e()),this.listeners.length=0}async join(e,t){if(!this._info)return this._info={id:e,info:t},this.channel.perform("$presence:join",this._info)}async leave(){if(!this._info)return;let e=await this.channel.perform("$presence:leave");return delete this._info,e}async info(){return this._state?this._state:(this._promise||(this._promise=this._sync()),await this._promise,this._state)}async _sync(){this.watch();try{let e=await this.channel.perform("$presence:info",{});return this._state=this.stateFromInfo(e),this._state}finally{delete this._promise}}stateFromInfo(e){return e.records.reduce((t,{id:s,info:r})=>(t[s]=r,t),{})}}const B=Symbol("state");class Mt{constructor(e={}){this.emitter=Ee(),this.params=Object.freeze(e),this.presence=new Ls(this),this.initialConnect=!0,this[B]="idle"}get identifier(){return this._identifier?this._identifier:(this._identifier=Bt({channel:this.channelId,...this.params}),this._identifier)}get channelId(){return this.constructor.identifier}get state(){return this[B]}attached(e){if(this.receiver){if(this.receiver!==e)throw Error("Already connected to a different receiver");return!1}return this.receiver=e,!0}connecting(){this[B]="connecting"}connected(){if(this.state==="connected"||this.state==="closed")return;this[B]="connected";let e=!1;this.initialConnect?(this.initialConnect=!1,this.emit("connect",{reconnect:!1,restored:e})):this.emit("connect",{reconnect:!0,restored:e})}restored(){if(this.state==="connected")throw Error("Already connected");this[B]="connected";let e=!0,t=!0;this.initialConnect=!1,this.emit("connect",{reconnect:t,restored:e})}disconnected(e){this.state==="disconnected"||this.state==="closed"||(this[B]="disconnected",this.presence.reset(),this.emit("disconnect",e))}closed(e){this.state!=="closed"&&(this[B]="closed",delete this.receiver,this.initialConnect=!0,this.presence.dispose(),this.emit("close",e))}disconnect(){this.state==="idle"||this.state==="closed"||this.receiver.unsubscribe(this)}async perform(e,t){if(this.state==="idle"||this.state==="closed")throw Error("Channel is not subscribed");return this.receiver.perform(this.identifier,e,t)}async send(e){return this.perform(void 0,e)}async whisper(e){try{await this.perform("$whisper",e)}catch(t){let s=this.receiver?this.receiver.logger:null;s&&s.warn("whisper failed: ",t)}}receive(e,t){this.emit("message",e,t)}on(e,t){return this.emitter.on(e,t)}once(e,t){let s=this.emitter.on(e,(...r)=>{s(),t(...r)});return s}emit(e,...t){return this.emitter.emit(e,...t)}ensureSubscribed(){return this.state==="connected"?Promise.resolve():this.state==="closed"?Promise.reject(Error("Channel is unsubscribed")):this.pendingSubscribe()}pendingSubscribe(){return this._pendingSubscribe?this._pendingSubscribe:(this._pendingSubscribe=new Promise((e,t)=>{let s=[()=>delete this._pendingSubscribe];s.push(this.on("connect",()=>{s.forEach(r=>r()),e()})),s.push(this.on("close",r=>{s.forEach(i=>i()),t(r||new ie("Channel was disconnected before subscribing","canceled"))}))}),this._pendingSubscribe)}}class js{constructor(e){this.id=e,this.intent="unsubscribed",this.state="idle",this.channels=[],this.disposed=!1,this._pendings=[]}add(e){this.channels.includes(e)||this.channels.push(e)}remove(e){let t=this.channels.indexOf(e);t>-1&&this.channels.splice(t,1)}notify(e,...t){this.state=e==="restored"?"connected":e,t.length===1?this.channels.forEach(s=>s[e](t[0])):this.channels.forEach(s=>s[e]())}pending(e){this._checkIntent(e);let t=this._pendings[0];return!t||t.intent!==e?Promise.resolve():t.promise}ensureResubscribed(){this.disposed||(this.intent=void 0,this.ensureSubscribed())}ensureSubscribed(){if(this.intent==="subscribed")return;if(this.disposed)throw Error("Subscription is disposed");this.intent="subscribed",!this._mergeWithPending("unsubscribed")&&this.subscriber(this)}maybeUnsubscribe(){this.disposed||this.intent==="unsubscribed"||this.channels.length>0||(this.intent="unsubscribed",this._mergeWithPending("subscribed"))||this.unsubscriber(this)}async acquire(e){this._checkIntent(e);let t,r={promise:new Promise(o=>{t=o}),intent:e,release:()=>{this._pendings.splice(this._pendings.indexOf(r),1),t(r)},canceled:!1,acquired:!1},i=this._pendingTop;return this._pendings.push(r),i&&await i.promise,this.gvl&&await this.gvl.acquire(r,e),r.acquired=!0,r}close(e){this.disposed=!0,this.intent=void 0,this.notify("closed",e)}_checkIntent(e){if(!(e==="unsubscribed"||e==="subscribed"))throw Error(`Unknown subscription intent: ${e}`)}get _pendingTop(){return this._pendings.length?this._pendings[this._pendings.length-1]:void 0}_mergeWithPending(e){let t=this._pendingTop;return!t||t.acquired||t.intent!==e?!1:(this._pendings.pop(),t.canceled=!0,!0)}}class vs{constructor(){this.queue=[]}async acquire(e,t){t==="subscribed"&&(this.queue.push(e.promise.then(()=>{this.queue.splice(this.queue.indexOf(e),1)})),this.queue.length>1&&await this.queue[this.queue.length-2])}}class $s{constructor(e){e.concurrentSubscribes===!1&&(this.glv=new vs),this._subscriptions={},this._localToRemote={}}all(){return Object.values(this._subscriptions)}get(e){return this._subscriptions[e]}create(e,{subscribe:t,unsubscribe:s}){let r=this._subscriptions[e]=new js(e);return r.remoteId=this._localToRemote[e],r.subscriber=t,r.unsubscriber=s,r.gvl=this.glv,r}remove(e){delete this._subscriptions[e],delete this._localToRemote[e]}storeRemoteId(e,t){this._localToRemote[e]=t;let s=this.get(e);s&&(s.remoteId=t)}}class Fs{constructor(e={}){this.subscriptions=new $s(e),this._pendingMessages=[],this._remoteToLocal={}}subscribe(e,t){this._remoteToLocal[t]=e,this.subscriptions.storeRemoteId(e,t),this.flush(t)}unsubscribe(e){let t=this.subscriptions.get(e);if(!t)return;let s=t.remoteId;s&&delete this._remoteToLocal[s],this.subscriptions.remove(e)}transmit(e,t,s){let r=this._remoteToLocal[e];if(!r){this._pendingMessages.push([e,t,s]);return}let i=this.subscriptions.get(r);i&&i.channels.forEach(o=>{o.receive(t,s)})}notify(e,t,s){let r=this._remoteToLocal[e];if(!r)return;let i=this.subscriptions.get(r);i&&i.channels.forEach(o=>o.emit(t,s))}close(){this._pendingMessages.length=0}get size(){return this.channels.length}get channels(){return this.subscriptions.all().flatMap(e=>e.channels)}flush(e){let t=[];for(let s of this._pendingMessages)s[0]===e?this.transmit(s[0],s[1],s[2]):t.push(s);this._pendingMessages=t}}const at={debug:0,info:1,warn:2,error:3};class Ht{constructor(e){this.level=e||"warn"}log(e,t,s){at[e]<at[this.level]||this.writeLogEntry(e,t,s)}writeLogEntry(){throw Error("Not implemented")}debug(e,t){this.log("debug",e,t)}info(e,t){this.log("info",e,t)}warn(e,t){this.log("warn",e,t)}error(e,t){this.log("error",e,t)}}class oe extends Ht{writeLogEntry(){}}class Us{encode(e){return JSON.stringify(e)}decode(e){try{return JSON.parse(e)}catch{}}}let Ds=0;class zt{constructor(e={}){let{logger:t}=e;this.logger=t||new oe,this.pendingSubscriptions={},this.pendingUnsubscriptions={},this.subscribeCooldownInterval=e.subscribeCooldownInterval||250,this.subscribeRetryInterval=e.subscribeRetryInterval||5e3}attached(e){this.cable=e}subscribe(e,t){let s={channel:e};t&&Object.assign(s,t);let r=Bt(s);if(this.pendingUnsubscriptions[r]){let o=this.subscribeCooldownInterval*1.5;return this.logger.debug(`unsubscribed recently, cooldown for ${o}`,r),new Promise(c=>{setTimeout(()=>{c(this.subscribe(e,t))},o)})}if(this.pendingSubscriptions[r])return this.logger.warn("subscription is already pending, skipping",r),Promise.reject(Error("Already subscribing"));let i=this.subscribeRetryInterval;return new Promise((o,c)=>{let h=++Ds;this.pendingSubscriptions[r]={resolve:o,reject:c,id:h},this.cable.send(this.buildSubscribeRequest(r)),this.maybeRetrySubscribe(h,r,i)})}buildSubscribeRequest(e){return{command:"subscribe",identifier:e}}maybeRetrySubscribe(e,t,s){setTimeout(()=>{let r=this.pendingSubscriptions[t];r&&r.id===e&&(this.logger.warn(`no subscription ack received in ${s}ms, retrying subscribe`,t),this.cable.send(this.buildSubscribeRequest(t)),this.maybeExpireSubscribe(e,t,s))},s)}maybeExpireSubscribe(e,t,s){setTimeout(()=>{let r=this.pendingSubscriptions[t];r&&r.id===e&&(delete this.pendingSubscriptions[t],r.reject(new Ps(`Haven't received subscription ack in ${s*2}ms for ${t}`)))},s)}unsubscribe(e){return this.cable.send({command:"unsubscribe",identifier:e}),this.pendingUnsubscriptions[e]=!0,setTimeout(()=>{delete this.pendingUnsubscriptions[e]},this.subscribeCooldownInterval),Promise.resolve()}perform(e,t,s){return t==="$whisper"?this.whisper(e,s):(s||(s={}),s.action=t,this.cable.send({command:"message",identifier:e,data:JSON.stringify(s)}),Promise.resolve())}whisper(e,t){return this.cable.send({command:"whisper",identifier:e,data:t}),Promise.resolve()}receive(e){if(typeof e!="object"){this.logger.error("unsupported message format",{message:e});return}let{type:t,identifier:s,message:r,reason:i,reconnect:o}=e;if(t==="ping")return this.cable.keepalive(e.message);if(this.cable.keepalive(),t==="welcome"){let c=e.sid;return c&&this.cable.setSessionId(c),this.cable.connected()}if(t==="disconnect"){let c=new v(i);this.reset(c),o===!1?this.cable.closed(c):this.cable.disconnected(c);return}if(t==="confirm_subscription"){let c=this.pendingSubscriptions[s];if(!c){this.logger.error("subscription not found, unsubscribing",{type:t,identifier:s}),this.unsubscribe(s);return}return delete this.pendingSubscriptions[s],c.resolve(s)}if(t==="reject_subscription"){let c=this.pendingSubscriptions[s];return c?(delete this.pendingSubscriptions[s],c.reject(new He)):this.logger.error("subscription not found",{type:t,identifier:s})}if(r)return{identifier:s,message:r};this.logger.warn(`unknown message type: ${t}`,{message:e})}reset(e){for(let t in this.pendingSubscriptions)this.pendingSubscriptions[t].reject(e);this.pendingSubscriptions={}}recoverableClosure(){return!1}}const lt=()=>Date.now()/1e3|0;class qs extends zt{constructor(e={}){super(e),this.streamsPositions={},this.subscriptionStreams={},this.pendingHistory={},this.pendingPresence={},this.presenceInfo={},this.restoreSince=e.historyTimestamp,this.disableSessionRecovery=e.disableSessionRecovery,this.restoreSince===void 0&&(this.restoreSince=lt()),this.sessionId=void 0,this.sendPongs=e.pongs}reset(e){for(let t in this.pendingPresence)this.pendingPresence[t].reject(e);return this.pendingPresence={},super.reset()}receive(e){if(typeof e!="object"){this.logger.error("unsupported message format",{message:e});return}let{type:t,identifier:s,message:r}=e;if(t==="disconnect")return delete this.sessionId,this.cable.setSessionId(""),super.receive(e);if(t==="reject_subscription")return super.receive(e);if(t==="confirm_subscription")return this.subscriptionStreams[s]||(this.subscriptionStreams[s]=new Set),super.receive(e);if(t==="ping")return this.restoreSince&&(this.restoreSince=lt()),this.sendPongs&&this.sendPong(),this.cable.keepalive(e.message);if(this.cable.keepalive(),t==="confirm_history"){this.logger.debug("history result received",e),this.cable.notify("history_received",s);return}if(t==="reject_history"){this.logger.warn("failed to retrieve history",e),this.cable.notify("history_not_found",s);return}if(t==="welcome"){if(this.disableSessionRecovery||(this.sessionId=e.sid,this.sessionId&&this.cable.setSessionId(this.sessionId)),e.restored){let i=e.restored_ids||Object.keys(this.subscriptionStreams);for(let o of i)this.cable.send({identifier:o,command:"history",history:this.historyRequestFor(o)}),this.presenceInfo[o]&&this.cable.send({identifier:o,command:"join",presence:this.presenceInfo[o]});return this.cable.restored(i)}return this.cable.connected(this.sessionId)}if(t==="presence"){let i=r.type;if(i==="info"){let o=this.pendingPresence[s];o&&(delete this.pendingPresence[s],o.resolve(r))}else if(i==="error"){let o=this.pendingPresence[s];o&&(delete this.pendingPresence[s],o.reject(new Error("failed to retrieve presence")))}return{type:t,identifier:s,message:r}}if(r){let i=this.trackStreamPosition(s,e.stream_id,e.epoch,e.offset);return{identifier:s,message:r,meta:i}}this.logger.warn(`unknown message type: ${t}`,{message:e})}perform(e,t,s){switch(t){case"$presence:join":return this.join(e,s);case"$presence:leave":return this.leave(e,s);case"$presence:info":return this.presence(e,s)}return super.perform(e,t,s)}unsubscribe(e){return delete this.presenceInfo[e],super.unsubscribe(e)}buildSubscribeRequest(e){let t=super.buildSubscribeRequest(e),s=this.historyRequestFor(e);s&&(t.history=s,this.pendingHistory[e]=!0);let r=this.presenceInfo[e];return r&&(t.presence=r),t}recoverableClosure(){return!!this.sessionId}historyRequestFor(e){let t={},s=!1;if(this.subscriptionStreams[e])for(let r of this.subscriptionStreams[e]){let i=this.streamsPositions[r];i&&(s=!0,t[r]=i)}if(!(!s&&!this.restoreSince))return{since:this.restoreSince,streams:t}}trackStreamPosition(e,t,s,r){if(!(!t||!s))return this.subscriptionStreams[e]||(this.subscriptionStreams[e]=new Set),this.subscriptionStreams[e].add(t),this.streamsPositions[t]={epoch:s,offset:r},{stream:t,epoch:s,offset:r}}async sendPong(){await new Promise(e=>setTimeout(e,0)),this.cable.state==="connected"&&this.cable.send({command:"pong"})}async join(e,t){return this.presenceInfo[e]=t,this.cable.send({command:"join",identifier:e,presence:t}),Promise.resolve()}async leave(e,t){return delete this.presenceInfo[e],this.cable.send({command:"leave",identifier:e,presence:t}),Promise.resolve()}presence(e,t){return this.pendingPresence[e]?(this.logger.warn("presence is already pending, skipping",e),Promise.reject(Error("presence request is already pending"))):new Promise((s,r)=>{this.pendingPresence[e]={resolve:s,reject:r},this.cable.send({command:"presence",identifier:e,data:t})})}}class Bs extends ie{constructor(){super("No connection","closed"),this.name="NoConnectionError"}}class ze extends Mt{constructor(e,t){super(t),this.channelId=e}set channelId(e){this._channelId=e}get channelId(){return this._channelId}}j(ze,"identifier","__ghost__");const Ms="$pubsub";class Fe extends Mt{async perform(e,t){if(e.startsWith("$"))return super.perform(e,t);throw Error("not implemented")}}j(Fe,"identifier",Ms);const M=Symbol("state");let Hs=class{constructor({transport:e,protocol:t,encoder:s,logger:r,lazy:i,hubOptions:o,performFailures:c,transportConfigurator:h}){this.emitter=Ee(),this.transport=e,this.encoder=s,this.logger=r||new oe,this.protocol=t,this.performFailures=c||"throw",this.protocol.attached(this),this.hub=new Fs(o||{}),this[M]="idle",this.handleClose=this.handleClose.bind(this),this.handleIncoming=this.handleIncoming.bind(this),this.transportConfigurator=h,this.transport.on("close",this.handleClose),this.transport.on("data",this.handleIncoming),this.initialConnect=!0,this.recovering=!1,i===!1&&this.connect().catch(()=>{})}get state(){return this[M]}async connect(){if(this.state==="connected")return Promise.resolve();if(this.state==="connecting")return this.pendingConnect();let e=this.state==="idle";this[M]="connecting";let t=this.pendingConnect();this.logger.debug("connecting");try{this.transportConfigurator&&await this.transportConfigurator(this.transport,{initial:e}),await this.transport.open()}catch(s){this.handleClose(s)}return t}setSessionId(e){this.sessionId=e,this.transport.setParam("sid",e)}connected(){if(this.state==="connected")return;this.logger.info("connected"),this[M]="connected",this.recovering&&this.hub.subscriptions.all().forEach(t=>t.notify("disconnected",new v("recovery_failed"))),this.hub.subscriptions.all().forEach(t=>this._resubscribe(t));let e=!1;this.recovering=!1,this.initialConnect?(this.initialConnect=!1,this.emit("connect",{reconnect:!1,restored:e})):this.emit("connect",{reconnect:!0,restored:e})}restored(e){this.logger.info("connection recovered",{remoteIds:e}),this[M]="connected",this.hub.subscriptions.all().forEach(r=>{e&&r.remoteId&&e.includes(r.remoteId)?r.notify("restored"):(r.notify("disconnected",new v("recovery_failed")),this._resubscribe(r))});let t=!this.initialConnect,s=!0;this.recovering=!1,this.initialConnect=!1,this.emit("connect",{reconnect:t,restored:s})}notify(e,t,s){t&&typeof t!="string"&&(s=t,t=void 0),t?this.hub.notify(t,"info",{type:e,data:s}):this.emit("info",{type:e,data:s})}handleClose(e){this.logger.debug("transport closed",{error:e}),this.disconnected(new v(e,"transport_closed"))}disconnected(e){(this.state==="connected"||this.state==="connecting")&&(this.logger.info("disconnected",{reason:e}),this[M]="disconnected",this.recovering=this.protocol.recoverableClosure(e),this.recovering?this.hub.subscriptions.all().forEach(t=>t.notify("connecting")):this.hub.subscriptions.all().forEach(t=>{t.notify("disconnected",e)}),this.protocol.reset(e),this.hub.close(),this.transport.close(),this.emit("disconnect",e))}closed(e){if(this.state==="closed"||this.state==="idle")return;let t;e&&(t=e instanceof v?e:new v(e,void 0)),this.logger.info("closed",{reason:e||"user"}),this[M]="closed";let s=t||new v("cable_closed");this.hub.subscriptions.all().forEach(r=>r.notify("disconnected",s)),this.hub.close(),this.protocol.reset(),this.transport.close(),this.initialConnect=!0,this.emit("close",t)}disconnect(){this.closed()}handleIncoming(e){if(this.state==="closed"||this.state==="idle")return;let t=this.encoder.decode(e);if(t===void 0){this.logger.error("failed to decode message",{message:e});return}this.logger.debug("incoming data",t);let s=this.protocol.receive(t);if(s){this.logger.debug("processed incoming message",s);let{type:r,identifier:i,message:o,meta:c}=s;r?this.hub.notify(i,r,o):this.hub.transmit(i,o,c)}}send(e){if(this.state==="closed")throw Error("Cable is closed");let t=this.encoder.encode(e);if(t===void 0){this.logger.error("failed to encode message",{message:e});return}this.logger.debug("outgoing message",e),this.transport.send(t)}keepalive(e){this.emit("keepalive",e)}streamFrom(e){let t=new Fe({stream_name:e});return this.subscribe(t)}streamFromSigned(e){let t=new Fe({signed_stream_name:e});return this.subscribe(t)}subscribeTo(e,t){let s,r;return typeof e=="string"&&(r=e,e=ze),s=r?new e(r,t):new e(t),this.subscribe(s)}subscribe(e){if(!e.attached(this))return e;let t=e.identifier;e.connecting();let s=this.hub.subscriptions.get(t)||this.hub.subscriptions.create(t,{subscribe:r=>this._subscribe(r,e.channelId,e.params),unsubscribe:r=>this._unsubscribe(r)});return s.add(e),s.intent==="subscribed"&&s.state==="connected"&&e.connected(),s.ensureSubscribed(),e}async _resubscribe(e){e.intent!=="subscribed"||!e.channels[0]||(e.notify("connecting"),e.ensureResubscribed())}async _subscribe(e,t,s){let r=e.id;if(this.state==="idle"&&this.connect().catch(()=>{}),this.state!=="connected"){this.logger.debug("cancel subscribe, no connection",{identifier:r});return}this.logger.debug("acquiring subscribe lock",{identifier:r});let i=await e.acquire("subscribed");if(i.canceled){this.logger.debug("subscribe lock has been canceled",{identifier:r}),i.release();return}if(this.logger.debug("subscribe lock has been acquired",{identifier:r}),e.intent!=="subscribed"){this.logger.debug("cancel subscribe request, already unsubscribed"),i.release();return}if(this.state!=="connected"){this.logger.debug("cancel subscribe, no connection",{identifier:r}),i.release();return}if(e.state==="connected"){this.logger.debug("already connected, skip subscribe command",{identifier:r}),e.notify("connected"),i.release();return}let o={identifier:t,params:s};this.logger.debug("subscribing",o);try{let c=await this.protocol.subscribe(t,s);this.hub.subscribe(r,c),this.logger.debug("subscribed",{...o,remoteId:c}),e.notify("connected")}catch(c){if(c){if(c instanceof He&&this.logger.warn("rejected",o),c instanceof v){this.logger.debug("disconnected during subscription; will retry on connect",o),i.release();return}this.logger.error("failed to subscribe",{error:c,...o})}e.close(c),this.hub.unsubscribe(r)}i.release()}unsubscribe(e){let t=e.identifier,s=this.hub.subscriptions.get(t);if(!s)throw Error(`Subscription not found: ${t}`);s.remove(e),e.closed(),s.maybeUnsubscribe()}async _unsubscribe(e){let t=e.id;this.logger.debug("acquiring unsubscribe lock",{identifier:t});let s=await e.acquire("unsubscribed");if(s.canceled){this.logger.debug("unsubscribe lock has been canceled",{identifier:t}),s.release();return}if(this.logger.debug("unsubscribe lock has been acquired",{identifier:t}),e.intent!=="unsubscribed"){this.logger.debug("cancel unsubscribe, no longer needed",{identifier:t,intent:e.intent}),s.release();return}if(e.state==="disconnected"||e.state==="closed"){this.logger.debug(`already ${e.state} connected, skip unsubscribe command`,{identifier:t}),s.release();return}let r=e.remoteId;if(this.logger.debug("unsubscribing...",{remoteId:r}),this.state!=="connected"){this.logger.debug("unsubscribe skipped (cable is not connected)",{id:t}),e.close(),this.hub.unsubscribe(t),s.release();return}try{await this.protocol.unsubscribe(r),this.logger.debug("unsubscribed remotely",{id:t})}catch(i){i&&(i instanceof v?this.logger.debug("cable disconnected during the unsubscribe command execution",{id:t,error:i}):this.logger.error("unsubscribe failed",{id:t,error:i}))}e.intent==="unsubscribed"?(e.close(),this.hub.unsubscribe(t)):e.state="closed",s.release()}async perform(e,t,s){if(this.performFailures==="throw")return this._perform(e,t,s);try{return await this._perform(e,t,s)}catch(r){this.performFailures==="warn"&&this.logger.warn("perform failed",{error:r});return}}async _perform(e,t,s){if(this.state==="connecting"&&await this.pendingConnect(),this.state==="closed"||this.state==="disconnected")throw new Bs;let r=this.hub.subscriptions.get(e);if(!r)throw Error(`Subscription not found: ${e}`);if(await r.pending("subscribed"),r.intent!=="subscribed")throw Error(`Subscription is closed: ${e}`);let i=r.remoteId,o={id:i,action:t,payload:s};this.logger.debug("perform",o);try{let c=await this.protocol.perform(i,t,s);return c&&this.logger.debug("perform result",{message:c,request:o}),c}catch(c){throw this.logger.error("perform failed",{error:c,request:o}),c}}on(e,t){return this.emitter.on(e,t)}once(e,t){let s=this.emitter.on(e,(...r)=>{s(),t(...r)});return s}emit(e,...t){return this.emitter.emit(e,...t)}pendingConnect(){return this._pendingConnect?this._pendingConnect:(this._pendingConnect=new Promise((e,t)=>{let s=[()=>delete this._pendingConnect];s.push(this.on("connect",()=>{s.forEach(r=>r()),e()})),s.push(this.on("close",r=>{s.forEach(i=>i()),t(r)})),s.push(this.on("disconnect",r=>{s.forEach(i=>i()),t(r)}))}),this._pendingConnect)}};const zs={maxMissingPings:2,maxReconnectAttempts:1/0},W=()=>Date.now(),Vt=(n,e)=>{e=e||{};let{backoffRate:t,jitterRatio:s,maxInterval:r}=e;return t=t||2,s===void 0&&(s=.5),i=>{let o=n*t**i,c=o*t,h=o+(c-o)*Math.random(),u=2*(Math.random()-.5)*s;return h=h*(1+u),r&&r<h&&(h=r),h}};let Jt=class{constructor({pingInterval:e,...t}){if(this.pingInterval=e,!this.pingInterval)throw Error(`Incorrect pingInterval is provided: ${e}`);if(t=Object.assign({},zs,t),this.strategy=t.reconnectStrategy,!this.strategy)throw Error("Reconnect strategy must be provided");this.maxMissingPings=t.maxMissingPings,this.maxReconnectAttempts=t.maxReconnectAttempts,this.logger=t.logger||new oe,this.state="pending_connect",this.attempts=0,this.disconnectedAt=W()}watch(e){this.target=e,this.initListeners()}reconnectNow(){return this.state==="connected"||this.state==="pending_connect"||this.state==="closed"?!1:(this.cancelReconnect(),this.state="pending_connect",this.target.connect().catch(e=>{this.logger.info("Failed at reconnecting: "+e)}),!0)}initListeners(){this.unbind=[],this.unbind.push(this.target.on("connect",()=>{this.attempts=0,this.pingedAt=W(),this.state="connected",this.cancelReconnect(),this.startPolling()})),this.unbind.push(this.target.on("disconnect",()=>{this.disconnectedAt=W(),this.state="disconnected",this.stopPolling(),this.scheduleReconnect()})),this.unbind.push(this.target.on("close",()=>{this.disconnectedAt=W(),this.state="closed",this.cancelReconnect(),this.stopPolling()})),this.unbind.push(this.target.on("keepalive",()=>{this.pingedAt=W()})),this.unbind.push(()=>{this.cancelReconnect(),this.stopPolling()})}dispose(){delete this.target,this.unbind&&this.unbind.forEach(e=>e()),delete this.unbind}startPolling(){this.pollId&&clearTimeout(this.pollId);let e=this.pingInterval+(Math.random()-.5)*this.pingInterval*.5;this.pollId=setTimeout(()=>{this.checkStale(),this.state==="connected"&&this.startPolling()},e)}stopPolling(){this.pollId&&clearTimeout(this.pollId)}checkStale(){let e=W()-this.pingedAt;e>this.maxMissingPings*this.pingInterval&&(this.logger.warn(`Stale connection: ${e}ms without pings`),this.state="pending_disconnect",this.target.disconnected(new Is))}scheduleReconnect(){if(this.attempts>=this.maxReconnectAttempts){this.target.close();return}let e=this.strategy(this.attempts);this.attempts++,this.logger.info(`Reconnecting in ${e}ms (${this.attempts} attempt)`),this.state="pending_reconnect",this.reconnnectId=setTimeout(()=>this.reconnectNow(),e)}cancelReconnect(){this.reconnnectId&&(clearTimeout(this.reconnnectId),delete this.reconnnectId)}};class Vs{constructor(e,t={}){this.transports=e,this.transport=null,this.emitter=Ee(),this.unbind=[],this.logger=t.logger||new oe}displayName(){return"fallbacked transport"}async open(){for(let e=0;e<this.transports.length;e++){let t=this.transports[e];try{this.transport=t,this.resetListeners(),this.logger.debug(`Trying to connect via ${t.displayName()}`),await t.open(),this.logger.debug(`Connected via ${t.displayName()}`);return}catch(s){this.logger.debug(`Failed to connect via ${t.displayName()}: ${s.message}`)}}throw this.transport=null,this.resetListeners(),new Error("Couldn't connect via any available transport")}send(e){if(!this.transport)throw new Error("No transport is open");this.transport.send(e)}async close(){if(!this.transport)throw new Error("No transport is open");await this.transport.close(),this.transport=null}setURL(){throw new Error("Not implemented. Set URL for each transport separately")}setParam(e,t){this.transports.forEach(s=>{s.setParam(e,t)})}setToken(e,t){this.transports.forEach(s=>{s.setToken(e,t)})}on(e,t){return this.emitter.on(e,t)}once(e,t){let s=this.emitter.on(e,(...r)=>{s(),t(...r)});return s}get url(){return this.transport?this.transport.url:""}resetListeners(){this.unbind.forEach(e=>e()),this.unbind.length=0,this.transport&&this.unbind.push(this.transport.on("open",()=>{this.emitter.emit("open")}),this.transport.on("data",e=>{this.emitter.emit("data",e)}),this.transport.on("close",e=>{this.emitter.emit("close",e)}),this.transport.on("error",e=>{this.emitter.emit("error",e)}))}}class Js{constructor(e,t={}){this.url=e;let s=t.websocketImplementation;if(s)this.Impl=s;else if(typeof WebSocket<"u")this.Impl=WebSocket;else throw new Error("No WebSocket support");this.connected=!1,this.emitter=Ee();let{format:r,subprotocol:i,authStrategy:o}=t;this.format=r||"text",this.connectionOptions=t.websocketOptions,this.authStrategy=o||"param",this.authProtocol="",this.subprotocol=i}displayName(){return"WebSocket("+this.url+")"}open(){let e=this.subprotocol;return this.authStrategy==="sub-protocol"&&(e=[this.subprotocol,this.authProtocol]),this.connectionOptions?this.ws=new this.Impl(this.url,e,this.connectionOptions):this.ws=new this.Impl(this.url,e),this.ws.binaryType="arraybuffer",this.initListeners(),new Promise((t,s)=>{let r=[];r.push(this.once("open",()=>{r.forEach(i=>i()),t()})),r.push(this.once("close",()=>{r.forEach(i=>i()),s(Error("WS connection closed"))}))})}setURL(e){this.url=e}setParam(e,t){let s=new URL(this.url);s.searchParams.set(e,t);let r=`${s.protocol}//${s.host}${s.pathname}?${s.searchParams}`;this.setURL(r)}setToken(e,t="jid"){if(this.authStrategy==="param")this.setParam(t,e);else if(this.authStrategy==="header"){this.connectionOptions=this.connectionOptions||{},this.connectionOptions.headers=this.connectionOptions.headers||{};let s=`x-${t}`.toLowerCase();s=Object.keys(this.connectionOptions.headers).find(i=>i.toLowerCase()===s)||s,this.connectionOptions.headers[s]=e}else if(this.authStrategy==="sub-protocol")this.authProtocol=`anycable-token.${e}`;else throw new Error("Unknown auth strategy: "+this.authStrategy)}send(e){if(!this.ws||!this.connected)throw Error("WebSocket is not connected");this.ws.send(e)}close(){this.ws?this.onclose():this.connected=!1}on(e,t){return this.emitter.on(e,t)}once(e,t){let s=this.emitter.on(e,(...r)=>{s(),t(...r)});return s}initListeners(){this.ws.onerror=e=>{this.connected&&this.emitter.emit("error",e.error||new Error("WS Error"))},this.ws.onclose=()=>{this.onclose()},this.ws.onmessage=e=>{let t=e.data;this.format==="binary"&&(t=new Uint8Array(t)),this.emitter.emit("data",t)},this.ws.onopen=()=>{this.connected=!0,this.emitter.emit("open")}}onclose(){this.ws.onclose=void 0,this.ws.onmessage=void 0,this.ws.onopen=void 0,this.ws.close(),delete this.ws,this.connected=!1,this.emitter.emit("close")}}const Wt={protocol:"actioncable-v1-json",pingInterval:3e3,maxReconnectAttempts:1/0,maxMissingPings:2,logLevel:"warn",lazy:!0};function Ws(n,e){if(typeof n=="object"&&typeof e>"u"&&(e=n,n=void 0),e=e||{},!n&&!e.transport)throw Error("URL or transport must be specified");e=Object.assign({},Wt,e);let{protocol:t,websocketImplementation:s,websocketFormat:r,websocketOptions:i,websocketAuthStrategy:o,fallbacks:c,logLevel:h,logger:u,transport:a,encoder:d,lazy:g,monitor:b,pingInterval:f,reconnectStrategy:m,maxMissingPings:p,maxReconnectAttempts:_,subprotocol:S,tokenRefresher:E,historyTimestamp:N,protocolOptions:x,concurrentSubscribes:P,performFailures:I,transportConfigurator:D,auth:U}=e;if(u=u||new oe(h),typeof t=="string"){S=S||t;let J=t.substring(0,t.lastIndexOf("-")),C=t.substring(t.lastIndexOf("-")+1);if(x=x||{},J==="actioncable-v1")t=new zt({logger:u,...x});else if(J==="actioncable-v1-ext")t=new qs({logger:u,historyTimestamp:N,...x});else throw Error(`Protocol is not supported yet: ${t}`);if(C==="json")d=d||new Us,r=r||"text";else if(C==="msgpack"){if(r="binary",!d)throw Error("Msgpack encoder must be specified explicitly. Use `@anycable/msgpack-encoder` package or build your own")}else if(C==="protobuf"){if(r=r||"binary",!d)throw Error("Protobuf encoder must be specified explicitly. Use `@anycable/protobuf-encoder` package or build your own")}else throw Error(`Protocol is not supported yet: ${t}`)}if(!t)throw Error("Protocol must be specified");a=a||new Js(n,{websocketImplementation:s,websocketOptions:i,subprotocol:S,authStrategy:o,format:r}),c&&(a=new Vs([a,...c],{logger:u})),U&&U.token&&a.setToken(U.token,U.param||"jid"),m=m||Vt(f),b!==!1&&(b=b||new Jt({pingInterval:f,reconnectStrategy:m,maxMissingPings:p,maxReconnectAttempts:_,logger:u}));let Re={concurrentSubscribes:P},L=new Hs({protocol:t,transport:a,encoder:d,logger:u,lazy:g,hubOptions:Re,performFailures:I,transportConfigurator:D});return b&&(b.watch(L),L.monitor=b),E&&Ks(L,async()=>{try{await E(a)}catch(J){return u.error("Failed to refresh authentication token: "+J),!1}return L.connect().catch(()=>{}),!0}),L}function Ks(n,e){let t=!1;n.on("connect",()=>t=!1),n.on("close",async s=>{if(s){if(t){n.logger.warn("Token auto-refresh is disabled",s);return}s.reason==="token_expired"&&(t=!0,await e())}})}class Xs{constructor(e){this.channel=e}notify(e,...t){typeof this[e]=="function"&&this[e](...t)}perform(e,t={}){this.channel.perform(e,t)}send(e){this.channel.send(e)}get identifier(){return this.channel.identifier}unsubscribe(){return this.channel.disconnect()}}class Gs extends ze{constructor(e,t,s){super(e,t),this.subscription=new Xs(this),Object.assign(this.subscription,s),this.on("connect",({reconnect:r})=>this.subscription.notify("connected",{reconnected:r})),this.on("disconnect",()=>this.subscription.notify("disconnected",{allowReconnect:!0})),this.on("message",r=>this.subscription.notify("received",r)),this.on("close",r=>{r&&r instanceof He?this.subscription.notify("rejected"):this.subscription.notify("disconnected",{allowReconnect:!1})})}}class Qs{constructor(e){this.cable=e}create(e,t){let s,r;typeof e=="object"?(s=e.channel,delete e.channel,r=e):(s=e,r={});let i=new Gs(s,r,t);return i.subscription.notify("initialized"),this.cable.subscribe(i),i.subscription}findAll(e){return this.cable.hub.channels.filter(t=>t.identifier===e).map(t=>t.subscription)}}class Zs{constructor(e){this.cable=e,this.subscriptions=new Qs(e)}}class Ys extends Ht{writeLogEntry(e,t,s){s?console[e](t,s):console[e](t)}}class er extends Jt{watch(e){super.watch(e),this.initActivityListeners()}initActivityListeners(){if(typeof document<"u"&&typeof window<"u"&&document.addEventListener&&window.addEventListener){let e=()=>{document.hidden||this.reconnectNow()&&this.logger.debug("Trigger reconnect due to visibility change")},t=r=>{this.reconnectNow()&&this.logger.debug("Trigger reconnect",{event:r})},s=()=>this.disconnect(new v("page_frozen"));document.addEventListener("visibilitychange",e,!1),window.addEventListener("focus",t,!1),window.addEventListener("online",t,!1),window.addEventListener("resume",t,!1),window.addEventListener("freeze",s,!1),this.unbind.push(()=>{document.removeEventListener("visibilitychange",e,!1),window.removeEventListener("focus",t,!1),window.removeEventListener("online",t,!1),window.removeEventListener("resume",t,!1),window.removeEventListener("freeze",s,!1)})}}disconnect(e){this.state==="disconnected"||this.state==="closed"||(this.logger.info("Disconnecting",{reason:e.message}),this.cancelReconnect(),this.stopPolling(),this.state="pending_disconnect",this.target.disconnected(e))}}const tr=["cable","action-cable"],nr="/cable",xe=(n,e)=>{for(let t of tr){let s=n.head.querySelector(`meta[name='${t}-${e}']`);if(s)return s.getAttribute("content")}},ut=n=>n.match(/wss?:\/\//)?n:typeof window<"u"?`${window.location.protocol.replace("http","ws")}//${window.location.host}${n}`:n,sr=()=>{if(typeof document<"u"&&document.head){let n=xe(document,"url");if(n)return ut(n)}return ut(nr)},rr=()=>{if(typeof document<"u"&&document.head){let n=xe(document,"history-timestamp");if(n)return n|0}},ir=()=>{if(typeof document<"u"&&document.head)return xe(document,"token")},or=()=>{if(typeof document<"u"&&document.head)return xe(document,"token-param")};function cr(n,e){typeof n=="object"&&typeof e>"u"&&(e=n,n=void 0),n=n||sr(),e=e||{},e.historyTimestamp||(e.historyTimestamp=rr());let t=ir();if(t){let u=or();e.auth=Object.assign({token:t,param:u},e.auth||{})}e=Object.assign({},Wt,e);let{logLevel:s,logger:r,pingInterval:i,reconnectStrategy:o,maxMissingPings:c,maxReconnectAttempts:h}=e;return r=e.logger=e.logger||new Ys(s),o=e.reconnectStrategy=e.reconnectStrategy||Vt(i),e.monitor!==!1&&(e.monitor=e.monitor||new er({pingInterval:i,reconnectStrategy:o,maxMissingPings:c,maxReconnectAttempts:h,logger:r})),Ws(n,e)}function ar(n,e){let t=cr(n,e);return new Zs(t)}class lr{constructor(e="/openc3-api/cable"){this._cable=null,this._url=e}disconnect(){this._cable&&(this._cable.cable.disconnect(),this._cable=null)}createSubscription(e,t,s={},r={}){return OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity).then(i=>{if(i&&OpenC3Auth.setTokens(),this._cable==null){let o=this._url+"?scope="+encodeURIComponent(t)+"&authorization="+encodeURIComponent(localStorage.openc3Token);o=new URL(o,document.baseURI).href,this._cable=ar(o)}return this._cable.subscriptions.create({channel:e,...r},s)})}recordPing(){}}class Ue{constructor(e,t,s="",r=""){this.keyword=e.keyword,this.parameters=e.parameters,this.filename=e.filename,this.line=e.line,this.lineNumber=e.lineNumber,this.message=t,this.usage=s,this.url=r}}class ur{constructor(){j(this,"keyword",null);j(this,"parameters",[]);j(this,"filename","");j(this,"line","");j(this,"lineNumber",0);j(this,"url","https://docs.openc3.com/docs/configuration")}verify_num_parameters(e,t,s=""){for(let r=1;r<=e;r++)if(this.parameters[r-1]===void 0)throw new Ue(this,`Not enough parameters for ${this.keyword}.`,s,this.url);if(t&&this.parameters[t]!==void 0)throw new Ue(this,`Too many parameters for ${this.keyword}.`,s,this.url)}remove_quotes(e){if(e.length<2)return e;let t=e.charAt(0);if(t!=='"'&&t!=="'")return e;let s=e.charAt(e.length-1);return t!==s?e:e.substring(1,e.length-1)}scan_string(e,t){if(!t.global)throw"rx must have 'global' flag set";let s=[];return e.replace(t,function(r){return s.push(r),r}),s}parse_string(e,t,s,r,i){let o=!1;this.line="",this.keyword=null,this.parameters=[],this.filename=t;let c=e.split(`
7
7
  `),h=c.length;for(let u=0;u<h;u++){this.lineNumber=u+1;let a=c[u].trim();if(a.length===0){s&&i(null,[],this.line,this.lineNumber);continue}if(o===!0){if(a[0]==="#")continue;a=a.substring(1,a.length)}let d=a.charAt(a.length-1),g=!1;switch(d){case"+":g=!0;case"\\":let _=a.substring(0,a.length-1).trim();this.line+=_.substring(0,_.length-1),g&&(this.line+=`
8
- `),o=!0;continue;case"&":this.line+=a.substring(0,a.length-1);continue;default:this.line+=a}o=!1;let b=/("([^\\"]|\\.)*")|('([^\\']|\\.)*')|\S+/g,f=this.scan_string(this.line,b),m="";if(f.length>0&&(m=m+f[0]),m.length===0||m.charAt(0)==="#"?this.keyword=null:this.keyword=m.toUpperCase(),this.parameters=[],this.keyword===null){s&&i(this.keyword,this.parameters,this.line,this.lineNumber),this.line="";continue}let p=f.length;if(p>1)for(let _=1;_<p;_++){let E=f[_];if(E.length>0&&E.charAt(0)==="#")break;r?this.parameters.push(this.remove_quotes(E)):this.parameters.push(E)}i(this.keyword,this.parameters,this.line,this.lineNumber),this.line=""}}}function Se(n){return ur.test(n)}const ur=/^-?[0-9]+$/;function Wt(n){return hr.test(n)}const hr=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function Kt(n,e){const t=Number.parseFloat(n),s=String(t),r=ut(n),i=ut(s);return!!(r===i||(e==null?void 0:e.approx)===!0&&!Se(n)&&i.length>=14&&r.startsWith(i.substring(0,14)))}let Q=function(n){return n.underflow="underflow",n.overflow="overflow",n.truncate_integer="truncate_integer",n.truncate_float="truncate_float",n}({});function dr(n){if(Kt(n,{approx:!1}))return;if(Se(n))return Q.truncate_integer;const e=Number.parseFloat(n);return Number.isFinite(e)?e===0?Q.underflow:Q.truncate_float:Q.overflow}function ut(n){return n.replace(fr,"").replace(mr,"").replace(gr,"").replace(pr,"")}const fr=/[eE][+-]?\d+$/,pr=/^-?(0*)?/,mr=/\./,gr=/0+$/;class br{constructor(e){L(this,"isLosslessNumber",!0);if(!Wt(e))throw new Error(`Invalid number (value: "${e}")`);this.value=e}valueOf(){const e=dr(this.value);if(e===void 0||e===Q.truncate_float)return Number.parseFloat(this.value);if(Se(this.value))return BigInt(this.value);throw new Error(`Cannot safely convert to number: the value '${this.value}' would ${e} and become ${Number.parseFloat(this.value)}`)}toString(){return this.value}}function yr(n){return n&&typeof n=="object"&&n.isLosslessNumber===!0||!1}function wr(n){return new br(n)}function _r(n,e){return ze({"":n},"",n,e)}function ze(n,e,t,s){return Array.isArray(t)?s.call(n,e,Sr(t,s)):t&&typeof t=="object"&&!yr(t)?s.call(n,e,Er(t,s)):s.call(n,e,t)}function Er(n,e){for(const t of Object.keys(n)){const s=ze(n,t,n[t],e);s!==void 0?n[t]=s:delete n[t]}return n}function Sr(n,e){for(let t=0;t<n.length;t++)n[t]=ze(n,String(t),n[t],e);return n}function xr(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:wr,s=0;const r=c();return f(r),p(),e?_r(r,e):r;function i(){if(n.charCodeAt(s)===kr){s++,u();const w={};let A=!0;for(;s<n.length&&n.charCodeAt(s)!==dt;){A?A=!1:(g(),u());const q=s,G=a();if(G===void 0){S();return}u(),b();const Re=c();if(Re===void 0){U();return}Object.prototype.hasOwnProperty.call(w,G)&&!Ue(Re,w[G])&&N(G,q+1),w[G]=Re}return n.charCodeAt(s)!==dt&&x(),s++,w}}function o(){if(n.charCodeAt(s)===Nr){s++,u();const w=[];let A=!0;for(;s<n.length&&n.charCodeAt(s)!==ft;){A?A=!1:g();const q=c();m(q),w.push(q)}return n.charCodeAt(s)!==ft&&P(),s++,w}}function c(){u();const w=a()??d()??i()??o()??h("true",!0)??h("false",!1)??h("null",null);return u(),w}function h(w,A){if(n.slice(s,s+w.length)===w)return s+=w.length,A}function u(){for(;Rr(n.charCodeAt(s));)s++}function a(){if(n.charCodeAt(s)===Te){s++;let w="";for(;s<n.length&&n.charCodeAt(s)!==Te;){if(n.charCodeAt(s)===Tr){const A=n[s+1],q=Or[A];q!==void 0?(w+=q,s++):A==="u"?ie(n.charCodeAt(s+2))&&ie(n.charCodeAt(s+3))&&ie(n.charCodeAt(s+4))&&ie(n.charCodeAt(s+5))?(w+=String.fromCharCode(Number.parseInt(n.slice(s+2,s+6),16)),s+=5):xe(s):D(s)}else Cr(n.charCodeAt(s))?w+=n[s]:I(n[s]);s++}return E(),s++,w}}function d(){const w=s;if(n.charCodeAt(s)===pt&&(s++,_(w)),n.charCodeAt(s)===Ve)s++;else if(Ar(n.charCodeAt(s)))for(s++;oe(n.charCodeAt(s));)s++;if(n.charCodeAt(s)===Ur)for(s++,_(w);oe(n.charCodeAt(s));)s++;if(n.charCodeAt(s)===Hr||n.charCodeAt(s)===Mr)for(s++,(n.charCodeAt(s)===pt||n.charCodeAt(s)===jr)&&s++,_(w);oe(n.charCodeAt(s));)s++;if(s>w)return t(n.slice(w,s))}function g(){if(n.charCodeAt(s)!==Fr)throw new SyntaxError(`Comma ',' expected after value ${O()}`);s++}function b(){if(n.charCodeAt(s)!==Dr)throw new SyntaxError(`Colon ':' expected after property name ${O()}`);s++}function f(w){if(w===void 0)throw new SyntaxError(`JSON value expected ${O()}`)}function m(w){if(w===void 0)throw new SyntaxError(`Array item expected ${O()}`)}function p(){if(s<n.length)throw new SyntaxError(`Expected end of input ${O()}`)}function _(w){if(!oe(n.charCodeAt(s))){const A=n.slice(w,s);throw new SyntaxError(`Invalid number '${A}', expecting a digit ${O()}`)}}function E(){if(n.charCodeAt(s)!==Te)throw new SyntaxError(`End of string '"' expected ${O()}`)}function S(){throw new SyntaxError(`Quoted object key expected ${O()}`)}function N(w,A){throw new SyntaxError(`Duplicate key '${w}' encountered at position ${A}`)}function x(){throw new SyntaxError(`Quoted object key or end of object '}' expected ${O()}`)}function P(){throw new SyntaxError(`Array item or end of array ']' expected ${O()}`)}function I(w){throw new SyntaxError(`Invalid character '${w}' ${v()}`)}function D(w){const A=n.slice(w,w+2);throw new SyntaxError(`Invalid escape character '${A}' ${v()}`)}function U(){throw new SyntaxError(`Object value expected after ':' ${v()}`)}function xe(w){const A=n.slice(w,w+6);throw new SyntaxError(`Invalid unicode character '${A}' ${v()}`)}function v(){return`at position ${s}`}function J(){return s<n.length?`but got '${n[s]}'`:"but reached end of input"}function O(){return`${J()} ${v()}`}}function Rr(n){return n===Pr||n===Ir||n===vr||n===Lr}function ie(n){return n>=Ve&&n<=Je||n>=qr&&n<=zr||n>=Br&&n<=Vr}function oe(n){return n>=Ve&&n<=Je}function Ar(n){return n>=$r&&n<=Je}function Cr(n){return n>=32&&n<=1114111}function Ue(n,e){return n===e?!0:Array.isArray(n)&&Array.isArray(e)?n.length===e.length&&n.every((t,s)=>Ue(t,e[s])):ht(n)&&ht(e)?[...new Set([...Object.keys(n),...Object.keys(e)])].every(s=>Ue(n[s],e[s])):!1}function ht(n){return typeof n=="object"&&n!==null}const Or={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
9
- `,r:"\r",t:" "},Tr=92,kr=123,dt=125,Nr=91,ft=93,Pr=32,Ir=10,vr=9,Lr=13,Te=34,jr=43,pt=45,Ve=48,$r=49,Je=57,Fr=44,Ur=46,Dr=58,qr=65,Br=97,Mr=69,Hr=101,zr=70,Vr=102;function Xt(n,e,t,s){const r=void 0;return o(n,"");function o(a,d){if(Array.isArray(s)){const g=s.find(b=>b.test(a));if(g){const b=g.stringify(a);if(typeof b!="string"||!Wt(b))throw new Error(`Invalid JSON number: output of a number stringifier must be a string containing a JSON number (output: ${b})`);return b}}if(typeof a=="boolean"||typeof a=="number"||typeof a=="string"||a===null||a instanceof Date||a instanceof Boolean||a instanceof Number||a instanceof String)return JSON.stringify(a);if(a!=null&&a.isLosslessNumber||typeof a=="bigint")return a.toString();if(Array.isArray(a))return c(a,d);if(a&&typeof a=="object")return h(a,d)}function c(a,d){if(a.length===0)return"[]";const g=r?d+r:void 0;let b=r?`[
8
+ `),o=!0;continue;case"&":this.line+=a.substring(0,a.length-1);continue;default:this.line+=a}o=!1;let b=/("([^\\"]|\\.)*")|('([^\\']|\\.)*')|\S+/g,f=this.scan_string(this.line,b),m="";if(f.length>0&&(m=m+f[0]),m.length===0||m.charAt(0)==="#"?this.keyword=null:this.keyword=m.toUpperCase(),this.parameters=[],this.keyword===null){s&&i(this.keyword,this.parameters,this.line,this.lineNumber),this.line="";continue}let p=f.length;if(p>1)for(let _=1;_<p;_++){let S=f[_];if(S.length>0&&S.charAt(0)==="#")break;r?this.parameters.push(this.remove_quotes(S)):this.parameters.push(S)}i(this.keyword,this.parameters,this.line,this.lineNumber),this.line=""}}}function ee(n){return hr.test(n)}const hr=/^-?[0-9]+$/;function Kt(n){return dr.test(n)}const dr=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function Xt(n,e){if(ee(n))return Number.isSafeInteger(Number.parseInt(n,10));const t=Number.parseFloat(n),s=String(t);if(n===s)return!0;const r=ht(n),i=ht(s);return!!(r===i||(e==null?void 0:e.approx)===!0&&!ee(n)&&i.length>=14&&r.startsWith(i.substring(0,14)))}let Z=(function(n){return n.underflow="underflow",n.overflow="overflow",n.truncate_integer="truncate_integer",n.truncate_float="truncate_float",n})({});function fr(n){if(Xt(n,{approx:!1}))return;if(ee(n))return Z.truncate_integer;const e=Number.parseFloat(n);return Number.isFinite(e)?e===0?Z.underflow:Z.truncate_float:Z.overflow}function ht(n){const{start:e,end:t}=pr(n),s=n.substring(e,t),r=s.indexOf(".");return r===-1?s:s.substring(0,r)+s.substring(r+1)}function pr(n){let e=0;for(n[0]==="-"&&e++;n[e]==="0"||n[e]===".";)e++;let t=n.lastIndexOf("e");for(t===-1&&(t=n.lastIndexOf("E")),t===-1&&(t=n.length);(n[t-1]==="0"||n[t-1]===".")&&t>e;)t--;return{start:e,end:t}}class mr{constructor(e){j(this,"isLosslessNumber",!0);if(!Kt(e))throw new Error(`Invalid number (value: "${e}")`);this.value=e}valueOf(){const e=fr(this.value);if(e===void 0||e===Z.truncate_float)return Number.parseFloat(this.value);if(ee(this.value))return BigInt(this.value);throw new Error(`Cannot safely convert to number: the value '${this.value}' would ${e} and become ${Number.parseFloat(this.value)}`)}toString(){return this.value}}function gr(n){return n&&typeof n=="object"&&n.isLosslessNumber||!1}function br(n){return new mr(n)}function yr(n,e){return Ve({"":n},"",n,e)}function Ve(n,e,t,s){return Array.isArray(t)?s.call(n,e,_r(t,s)):t&&typeof t=="object"&&!gr(t)?s.call(n,e,wr(t,s)):s.call(n,e,t)}function wr(n,e){for(const t of Object.keys(n)){const s=Ve(n,t,n[t],e);s!==void 0?n[t]=s:delete n[t]}return n}function _r(n,e){for(let t=0;t<n.length;t++)n[t]=Ve(n,String(t),n[t],e);return n}function Sr(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:br,s=0;const r=c();return f(r),p(),e?yr(r,e):r;function i(){if(n.charCodeAt(s)===Cr){s++,u();const w={};let A=!0;for(;s<n.length&&n.charCodeAt(s)!==ft;){A?A=!1:(g(),u());const q=s,G=a();if(G===void 0){E();return}u(),b();const Ae=c();if(Ae===void 0){U();return}Object.prototype.hasOwnProperty.call(w,G)&&!De(Ae,w[G])&&N(G,q+1),w[G]=Ae}return n.charCodeAt(s)!==ft&&x(),s++,w}}function o(){if(n.charCodeAt(s)===Tr){s++,u();const w=[];let A=!0;for(;s<n.length&&n.charCodeAt(s)!==pt;){A?A=!1:g();const q=c();m(q),w.push(q)}return n.charCodeAt(s)!==pt&&P(),s++,w}}function c(){u();const w=a()??d()??i()??o()??h("true",!0)??h("false",!1)??h("null",null);return u(),w}function h(w,A){if(n.slice(s,s+w.length)===w)return s+=w.length,A}function u(){for(;Er(n.charCodeAt(s));)s++}function a(){if(n.charCodeAt(s)===ke){s++;let w="";for(;s<n.length&&n.charCodeAt(s)!==ke;){if(n.charCodeAt(s)===Or){const A=n[s+1],q=Ar[A];q!==void 0?(w+=q,s++):A==="u"?ae(n.charCodeAt(s+2))&&ae(n.charCodeAt(s+3))&&ae(n.charCodeAt(s+4))&&ae(n.charCodeAt(s+5))?(w+=String.fromCharCode(Number.parseInt(n.slice(s+2,s+6),16)),s+=5):Re(s):D(s)}else Rr(n.charCodeAt(s))?w+=n[s]:I(n[s]);s++}return S(),s++,w}}function d(){const w=s;if(n.charCodeAt(s)===mt&&(s++,_(w)),n.charCodeAt(s)===Je)s++;else if(xr(n.charCodeAt(s)))for(s++;le(n.charCodeAt(s));)s++;if(n.charCodeAt(s)===$r)for(s++,_(w);le(n.charCodeAt(s));)s++;if(n.charCodeAt(s)===Br||n.charCodeAt(s)===qr)for(s++,(n.charCodeAt(s)===mt||n.charCodeAt(s)===Lr)&&s++,_(w);le(n.charCodeAt(s));)s++;if(s>w)return t(n.slice(w,s))}function g(){if(n.charCodeAt(s)!==vr)throw new SyntaxError(`Comma ',' expected after value ${C()}`);s++}function b(){if(n.charCodeAt(s)!==Fr)throw new SyntaxError(`Colon ':' expected after property name ${C()}`);s++}function f(w){if(w===void 0)throw new SyntaxError(`JSON value expected ${C()}`)}function m(w){if(w===void 0)throw new SyntaxError(`Array item expected ${C()}`)}function p(){if(s<n.length)throw new SyntaxError(`Expected end of input ${C()}`)}function _(w){if(!le(n.charCodeAt(s))){const A=n.slice(w,s);throw new SyntaxError(`Invalid number '${A}', expecting a digit ${C()}`)}}function S(){if(n.charCodeAt(s)!==ke)throw new SyntaxError(`End of string '"' expected ${C()}`)}function E(){throw new SyntaxError(`Quoted object key expected ${C()}`)}function N(w,A){throw new SyntaxError(`Duplicate key '${w}' encountered at position ${A}`)}function x(){throw new SyntaxError(`Quoted object key or end of object '}' expected ${C()}`)}function P(){throw new SyntaxError(`Array item or end of array ']' expected ${C()}`)}function I(w){throw new SyntaxError(`Invalid character '${w}' ${L()}`)}function D(w){const A=n.slice(w,w+2);throw new SyntaxError(`Invalid escape character '${A}' ${L()}`)}function U(){throw new SyntaxError(`Object value expected after ':' ${L()}`)}function Re(w){const A=n.slice(w,w+6);throw new SyntaxError(`Invalid unicode character '${A}' ${L()}`)}function L(){return`at position ${s}`}function J(){return s<n.length?`but got '${n[s]}'`:"but reached end of input"}function C(){return`${J()} ${L()}`}}function Er(n){return n===kr||n===Nr||n===Pr||n===Ir}function ae(n){return n>=Je&&n<=We||n>=Ur&&n<=Mr||n>=Dr&&n<=Hr}function le(n){return n>=Je&&n<=We}function xr(n){return n>=jr&&n<=We}function Rr(n){return n>=32&&n<=1114111}function De(n,e){return n===e?!0:Array.isArray(n)&&Array.isArray(e)?n.length===e.length&&n.every((t,s)=>De(t,e[s])):dt(n)&&dt(e)?[...new Set([...Object.keys(n),...Object.keys(e)])].every(s=>De(n[s],e[s])):!1}function dt(n){return typeof n=="object"&&n!==null}const Ar={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
9
+ `,r:"\r",t:" "},Or=92,Cr=123,ft=125,Tr=91,pt=93,kr=32,Nr=10,Pr=9,Ir=13,ke=34,Lr=43,mt=45,Je=48,jr=49,We=57,vr=44,$r=46,Fr=58,Ur=65,Dr=97,qr=69,Br=101,Mr=70,Hr=102;function Gt(n,e,t,s){const r=void 0;return o(n,"");function o(a,d){if(Array.isArray(s)){const g=s.find(b=>b.test(a));if(g){const b=g.stringify(a);if(typeof b!="string"||!Kt(b))throw new Error(`Invalid JSON number: output of a number stringifier must be a string containing a JSON number (output: ${b})`);return b}}if(typeof a=="boolean"||typeof a=="number"||typeof a=="string"||a===null||a instanceof Date||a instanceof Boolean||a instanceof Number||a instanceof String)return JSON.stringify(a);if(a!=null&&a.isLosslessNumber||typeof a=="bigint")return a.toString();if(Array.isArray(a))return c(a,d);if(a&&typeof a=="object")return h(a,d)}function c(a,d){if(a.length===0)return"[]";const g=r?d+r:void 0;let b=r?`[
10
10
  `:"[";for(let f=0;f<a.length;f++){const m=a[f];r&&(b+=g),typeof m<"u"&&typeof m!="function"?b+=o(m,g):b+="null",f<a.length-1&&(b+=r?`,
11
11
  `:",")}return b+=r?`
12
- ${d}]`:"]",b}function h(a,d){if(typeof a.toJSON=="function")return Xt(a.toJSON(),e,t,void 0);const g=Array.isArray(e)?e.map(String):Object.keys(a);if(g.length===0)return"{}";const b=r?d+r:void 0;let f=!0,m=r?`{
12
+ ${d}]`:"]",b}function h(a,d){if(typeof a.toJSON=="function")return Gt(a.toJSON(),e,t,void 0);const g=Array.isArray(e)?e.map(String):Object.keys(a);if(g.length===0)return"{}";const b=r?d+r:void 0;let f=!0,m=r?`{
13
13
  `:"{";for(const p of g){const _=a[p];if(u(p,_)){f?f=!1:m+=r?`,
14
- `:",";const E=JSON.stringify(p);m+=r?`${b+E}: `:`${E}:`,m+=o(_,b)}}return m+=r?`
15
- ${d}}`:"}",m}function u(a,d){return typeof d<"u"&&typeof d!="function"&&typeof d!="symbol"}}function Jr(n){return Se(n)&&!Kt(n)?BigInt(n):parseFloat(n)}class Wr{constructor(){L(this,"id",1)}async exec(e,t,s={},r={},i=6e4){try{await OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity)&&OpenC3Auth.setTokens()}catch{OpenC3Auth.login()}this.id=this.id+1;try{return s.scope=window.openc3Scope,r.manual=!0,(await we.post("/openc3-api/api",{jsonrpc:"2.0",method:e,params:t,id:this.id,keyword_params:s},{headers:{Authorization:localStorage.openc3Token,"Content-Type":"application/json-rpc",...r},timeout:i,transformRequest:[(c,h)=>Xt(c)],transformResponse:[c=>xr(c,void 0,Jr)]})).data.result}catch(o){let c=new Error;throw o.response?(c.name=o.response.data.error.data.class,c.message=o.response.data.error.data.message,c.object=o.response.data.error):o.request?(c.name="Request error",c.message="Request error, no response received"):c=o,c}}decode_openc3_type(e){if(e!==null&&typeof e=="object"&&e.json_class=="Float"&&e.raw){if(e.raw=="NaN")return NaN;if(e.raw=="Infinity")return 1/0;if(e.raw=="-Infinity")return-1/0}return null}encode_openc3_type(e){return Number.isNaN(e)?{json_class:"Float",raw:"NaN"}:e==Number.POSITIVE_INFINITY?{json_class:"Float",raw:"Infinity"}:e==Number.NEGATIVE_INFINITY?{json_class:"Float",raw:"-Infinity"}:null}ensure_offline_access(){this.offline_access_needed().then(e=>{e&&(localStorage.openc3OfflineToken?this.set_offline_access(localStorage.openc3OfflineToken).then(()=>{delete localStorage.openc3OfflineToken}):OpenC3Auth.getOfflineAccess())})}offline_access_needed(){return this.exec("offline_access_needed",[])}set_offline_access(e){return this.exec("set_offline_access",[e])}get_all_interface_info(){return this.exec("get_all_interface_info",[])}map_target_to_interface(e,t){return this.exec("map_target_to_interface",[e,t])}connect_interface(e,...t){return t.length>0?this.exec("connect_interface",[e,...t]):this.exec("connect_interface",[e])}disconnect_interface(e){return this.exec("disconnect_interface",[e])}interface_cmd(e,t,...s){return this.exec("interface_cmd",[e,t,...s])}get_all_router_info(){return this.exec("get_all_router_info",[])}connect_router(e){return this.exec("connect_router",[e])}disconnect_router(e){return this.exec("disconnect_router",[e])}get_target_interfaces(){return this.exec("get_target_interfaces",[])}get_tlm_cnts(e){return this.exec("get_tlm_cnts",[e])}get_item(e,t,s){return this.exec("get_item",[e,t,s])}get_param(e,t,s){return this.exec("get_param",[e,t,s])}get_parameter(e,t,s){return this.exec("get_param",[e,t,s])}get_limits_sets(){return this.exec("get_limits_sets",[])}get_limits_set(){return this.exec("get_limits_set",[])}set_limits_set(e){return this.exec("set_limits_set",[e])}get_target(e){return this.exec("get_target",[e])}get_target_names(){return this.exec("get_target_names",[])}get_target_list(){return this.exec("get_target_names",[])}get_tlm(e,t){return this.exec("get_tlm",[e,t])}get_telemetry(e,t){return this.exec("get_tlm",[e,t])}get_all_tlm(e){return this.exec("get_all_tlm",[e])}get_all_telemetry(e){return this.exec("get_all_tlm",[e])}get_all_tlm_names(e,t=!1){return this.exec("get_all_tlm_names",[e],{hidden:t})}get_all_telemetry_names(e){return this.exec("get_all_tlm_names",[e])}get_all_tlm_item_names(e){return this.exec("get_all_tlm_item_names",[e])}async get_tlm_packet(e,t,s,r=30){const i=await this.exec("get_tlm_packet",[e,t],{type:s,stale_time:r});if(i!=null){let o=i.length,c=null;for(let h=0;h<o;h++)c=this.decode_openc3_type(i[h][1]),c!==null&&(i[h][1]=c)}return i}get_packet_derived_items(e,t){return this.exec("get_packet_derived_items",[e,t])}get_tlm_buffer(e,t){return this.exec("get_tlm_buffer",[e,t])}async get_tlm_values(e,t=30,s=null){let r={stale_time:t};s!==null&&(r.cache_timeout=s);const i=await this.exec("get_tlm_values",[e],r,{},1e4);let o=i[0].length,c=null;for(let h=0;h<o;h++)c=this.decode_openc3_type(i[0][h]),c!==null&&(i[0][h]=c);return i}get_limits(e,t,s){return this.exec("get_limits",[e,t,s])}async tlm(e,t,s,r="CONVERTED"){let i=null;if(t===void 0)i=await this.exec("tlm",[e]);else if(s===void 0)if(["RAW","CONVERTED","FORMATTED","WITH_UNITS"].includes(t))i=await this.exec("tlm",[e],{type:t});else{let c=new Error;throw c.name="TypeError",c.message=`Invalid data type ${t}. Valid options are RAW, CONVERTED, FORMATTED, and WITH_UNITS.`,c}else i=await this.exec("tlm",[e,t,s],{type:r});let o=this.decode_openc3_type(i);return o!==null&&(i=o),i}async inject_tlm(e,t,s=null,r="CONVERTED"){await this.exec("inject_tlm",[e,t,s],{type:r})}set_tlm(e,t,s,r){return this.exec("set_tlm",[e,t,s],{type:r})}override_tlm(e,t,s,r){return this.exec("override_tlm",[e,t,s],{type:r})}get_overrides(){return this.exec("get_overrides")}normalize_tlm(e,t,s,r){return this.exec("normalize_tlm",[e,t,s],{type:r})}get_all_cmds(e){return this.exec("get_all_cmds",[e])}get_all_commands(e){return this.exec("get_all_cmds",[e])}get_all_cmd_names(e,t=!1){return this.exec("get_all_cmd_names",[e],{hidden:t})}get_all_command_names(e){return this.exec("get_all_cmd_names",[e])}get_cmd(e,t){return this.exec("get_cmd",[e,t])}get_command(e,t){return this.exec("get_cmd",[e,t])}get_cmd_cnts(e){return this.exec("get_cmd_cnts",[e])}get_cmd_value(e,t,s,r="CONVERTED"){return this.exec("get_cmd_value",[e,t,s,r])}get_cmd_buffer(e,t){return this.exec("get_cmd_buffer",[e,t])}_cmd(e,t,s,r,i){let o=null;for(let c in r)Object.prototype.hasOwnProperty.call(r,c)&&(o=this.encode_openc3_type(r[c]),o!==null&&(r[c]=o));return this.exec(e,[t,s,r],{},i)}get_cmd_hazardous(e,t,s,r={}){return t===void 0?this.exec("get_cmd_hazardous",e,{},r):this._cmd("get_cmd_hazardous",e,t,s,r)}cmd(e,t,s,r={}){return t===void 0?this.exec("cmd",e,{},r):this._cmd("cmd",e,t,s,r)}cmd_no_range_check(e,t,s,r={}){return t===void 0?this.exec("cmd_no_range_check",e,{},r):this._cmd("cmd_no_range_check",e,t,s,r)}cmd_raw(e,t,s,r={}){return t===void 0?this.exec("cmd_raw",e,{},r):this._cmd("cmd_raw",e,t,s,r)}cmd_raw_no_range_check(e,t,s,r={}){return t===void 0?this.exec("cmd_raw_no_range_check",e,{},r):this._cmd("cmd_raw_no_range_check",e,t,s,r)}cmd_no_hazardous_check(e,t,s,r={}){return t===void 0?this.exec("cmd_no_hazardous_check",e,{},r):this._cmd("cmd_no_hazardous_check",e,t,s,r)}cmd_no_checks(e,t,s,r={}){return t===void 0?this.exec("cmd_no_checks",e,{},r):this._cmd("cmd_no_checks",e,t,s,r)}cmd_raw_no_hazardous_check(e,t,s,r={}){return t===void 0?this.exec("cmd_raw_no_hazardous_check",e,{},r):this._cmd("cmd_raw_no_hazardous_check",e,t,s,r)}cmd_raw_no_checks(e,t,s,r={}){return t===void 0?this.exec("cmd_raw_no_checks",e,{},r):this._cmd("cmd_raw_no_checks",e,t,s,r)}build_cmd(e,t,s){return t===void 0?this.exec("build_cmd",e):this._cmd("build_cmd",e,t,s)}build_command(e,t,s){return t===void 0?this.exec("build_cmd",e):this._cmd("build_cmd",e,t,s)}get_interface_names(){return this.exec("get_interface_names",[])}send_raw(e,t){return this.exec("send_raw",[e,t])}list_configs(e){return this.exec("list_configs",[e])}load_config(e,t){return this.exec("load_config",[e,t])}save_config(e,t,s){return this.exec("save_config",[e,t,s])}delete_config(e,t){return this.exec("delete_config",[e,t])}enable_limits(e,t,s){return this.exec("enable_limits",[e,t,s])}disable_limits(e,t,s){return this.exec("disable_limits",[e,t,s])}get_out_of_limits(){return this.exec("get_out_of_limits",[])}get_overall_limits_state(e){return this.exec("get_overall_limits_state",[e])}list_settings(){return this.exec("list_settings",[])}get_all_settings(){return this.exec("get_all_settings",[])}get_setting(e){return this.exec("get_setting",[e])}get_settings(e){return this.exec("get_settings",e)}set_setting(e,t){return this.exec("set_setting",[e,t])}update_news(){return this.exec("update_news",[])}save_setting(e,t){return this.exec("set_setting",[e,t])}get_metrics(){return this.exec("get_metrics",[])}async hashString(e){if(window.isSecureContext){const t=new TextEncoder().encode(e),s=await crypto.subtle.digest("SHA-256",t),r=new Uint8Array(s);return Array.from(r).map(i=>i.toString(16).padStart(2,"0")).join("")}}}exports.Api=ks;exports.Cable=ar;exports.ConfigParserError=Fe;exports.ConfigParserService=lr;exports.OpenC3Api=Wr;exports.axios=we;
14
+ `:",";const S=JSON.stringify(p);m+=r?`${b+S}: `:`${S}:`,m+=o(_,b)}}return m+=r?`
15
+ ${d}}`:"}",m}function u(a,d){return typeof d<"u"&&typeof d!="function"&&typeof d!="symbol"}}function zr(n){return ee(n)&&!Xt(n)?BigInt(n):parseFloat(n)}class Vr{constructor(){j(this,"id",1)}async exec(e,t,s={},r={},i=6e4){try{await OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity)&&OpenC3Auth.setTokens()}catch{OpenC3Auth.login()}this.id=this.id+1;try{return s.scope=window.openc3Scope,r.manual=!0,(await Se.post("/openc3-api/api",{jsonrpc:"2.0",method:e,params:t,id:this.id,keyword_params:s},{headers:{Authorization:localStorage.openc3Token,"Content-Type":"application/json-rpc",...r},timeout:i,transformRequest:[(c,h)=>Gt(c)],transformResponse:[c=>Sr(c,void 0,zr)]})).data.result}catch(o){let c=new Error;throw o.response?(c.name=o.response.data.error.data.class,c.message=o.response.data.error.data.message,c.object=o.response.data.error):o.request?(c.name="Request error",c.message="Request error, no response received"):c=o,c}}decode_openc3_type(e){if(e!==null&&typeof e=="object"&&e.json_class=="Float"&&e.raw){if(e.raw=="NaN")return NaN;if(e.raw=="Infinity")return 1/0;if(e.raw=="-Infinity")return-1/0}return null}encode_openc3_type(e){return Number.isNaN(e)?{json_class:"Float",raw:"NaN"}:e==Number.POSITIVE_INFINITY?{json_class:"Float",raw:"Infinity"}:e==Number.NEGATIVE_INFINITY?{json_class:"Float",raw:"-Infinity"}:null}ensure_offline_access(){this.offline_access_needed().then(e=>{e&&(localStorage.openc3OfflineToken?this.set_offline_access(localStorage.openc3OfflineToken).then(()=>{delete localStorage.openc3OfflineToken}):OpenC3Auth.getOfflineAccess())})}offline_access_needed(){return this.exec("offline_access_needed",[])}set_offline_access(e){return this.exec("set_offline_access",[e])}get_all_interface_info(){return this.exec("get_all_interface_info",[])}map_target_to_interface(e,t){return this.exec("map_target_to_interface",[e,t])}connect_interface(e,...t){return t.length>0?this.exec("connect_interface",[e,...t]):this.exec("connect_interface",[e])}disconnect_interface(e){return this.exec("disconnect_interface",[e])}interface_cmd(e,t,...s){return this.exec("interface_cmd",[e,t,...s])}get_all_router_info(){return this.exec("get_all_router_info",[])}connect_router(e){return this.exec("connect_router",[e])}disconnect_router(e){return this.exec("disconnect_router",[e])}get_target_interfaces(){return this.exec("get_target_interfaces",[])}get_tlm_cnts(e){return this.exec("get_tlm_cnts",[e])}get_item(e,t,s){return this.exec("get_item",[e,t,s])}get_param(e,t,s){return this.exec("get_param",[e,t,s])}get_parameter(e,t,s){return this.exec("get_param",[e,t,s])}get_limits_sets(){return this.exec("get_limits_sets",[])}get_limits_set(){return this.exec("get_limits_set",[])}set_limits_set(e){return this.exec("set_limits_set",[e])}get_target(e){return this.exec("get_target",[e])}get_target_names(){return this.exec("get_target_names",[])}get_target_list(){return this.exec("get_target_names",[])}get_tlm(e,t){return this.exec("get_tlm",[e,t])}get_telemetry(e,t){return this.exec("get_tlm",[e,t])}get_all_tlm(e){return this.exec("get_all_tlm",[e])}get_all_telemetry(e){return this.exec("get_all_tlm",[e])}get_all_tlm_names(e,t=!1){return this.exec("get_all_tlm_names",[e],{hidden:t})}get_all_telemetry_names(e){return this.exec("get_all_tlm_names",[e])}get_all_tlm_item_names(e){return this.exec("get_all_tlm_item_names",[e])}async get_tlm_packet(e,t,s,r=30){const i=await this.exec("get_tlm_packet",[e,t],{type:s,stale_time:r});if(i!=null){let o=i.length,c=null;for(let h=0;h<o;h++)c=this.decode_openc3_type(i[h][1]),c!==null&&(i[h][1]=c)}return i}get_packet_derived_items(e,t){return this.exec("get_packet_derived_items",[e,t])}get_tlm_buffer(e,t){return this.exec("get_tlm_buffer",[e,t])}get_tlm_available(e){return this.exec("get_tlm_available",[e])}async get_tlm_values(e,t=30,s=null,r=null,i=null){let o={stale_time:t};s!==null&&(o.cache_timeout=s),r!==null&&(o.start_time=r.toISOString()),i!==null&&(o.end_time=i.toISOString());const c=await this.exec("get_tlm_values",[e],o,{},1e4);if(c&&c.length>0){let h=c[0].length,u=null;for(let a=0;a<h;a++)u=this.decode_openc3_type(c[0][a]),u!==null&&(c[0][a]=u)}return c}get_limits(e,t,s){return this.exec("get_limits",[e,t,s])}async tlm(e,t,s,r="CONVERTED"){let i=null;if(t===void 0)i=await this.exec("tlm",[e]);else if(s===void 0)if(["RAW","CONVERTED","FORMATTED","WITH_UNITS"].includes(t))i=await this.exec("tlm",[e],{type:t});else{let c=new Error;throw c.name="TypeError",c.message=`Invalid data type ${t}. Valid options are RAW, CONVERTED, FORMATTED, and WITH_UNITS.`,c}else i=await this.exec("tlm",[e,t,s],{type:r});let o=this.decode_openc3_type(i);return o!==null&&(i=o),i}async inject_tlm(e,t,s=null,r="CONVERTED"){await this.exec("inject_tlm",[e,t,s],{type:r})}set_tlm(e,t,s,r){return this.exec("set_tlm",[e,t,s],{type:r})}override_tlm(e,t,s,r){return this.exec("override_tlm",[e,t,s],{type:r})}get_overrides(){return this.exec("get_overrides")}normalize_tlm(e,t,s,r){return this.exec("normalize_tlm",[e,t,s],{type:r})}get_all_cmds(e){return this.exec("get_all_cmds",[e])}get_all_commands(e){return this.exec("get_all_cmds",[e])}get_all_cmd_names(e,t=!1){return this.exec("get_all_cmd_names",[e],{hidden:t})}get_all_command_names(e){return this.exec("get_all_cmd_names",[e])}get_cmd(e,t){return this.exec("get_cmd",[e,t])}get_command(e,t){return this.exec("get_cmd",[e,t])}get_cmd_cnts(e){return this.exec("get_cmd_cnts",[e])}get_cmd_value(e,t,s,r="CONVERTED"){return this.exec("get_cmd_value",[e,t,s,r])}get_cmd_buffer(e,t){return this.exec("get_cmd_buffer",[e,t])}_cmd(e,t,s,r,i,o={}){let c=null;for(let h in r)Object.prototype.hasOwnProperty.call(r,h)&&(c=this.encode_openc3_type(r[h]),c!==null&&(r[h]=c));return this.exec(e,[t,s,r],o,i)}get_cmd_hazardous(e,t,s,r={}){return t===void 0?this.exec("get_cmd_hazardous",e,{},r):this._cmd("get_cmd_hazardous",e,t,s,r)}cmd(e,t,s,r={},i={}){return t===void 0?this.exec("cmd",e,{},r):this._cmd("cmd",e,t,s,r,i)}cmd_no_range_check(e,t,s,r={},i={}){return t===void 0?this.exec("cmd_no_range_check",e,{},r,i):this._cmd("cmd_no_range_check",e,t,s,r,i)}cmd_raw(e,t,s,r={},i={}){return t===void 0?this.exec("cmd_raw",e,{},r,i):this._cmd("cmd_raw",e,t,s,r,i)}cmd_raw_no_range_check(e,t,s,r={},i={}){return t===void 0?this.exec("cmd_raw_no_range_check",e,{},r,i):this._cmd("cmd_raw_no_range_check",e,t,s,r,i)}cmd_no_hazardous_check(e,t,s,r={},i={}){return t===void 0?this.exec("cmd_no_hazardous_check",e,{},r,i):this._cmd("cmd_no_hazardous_check",e,t,s,r,i)}cmd_no_checks(e,t,s,r={},i={}){return t===void 0?this.exec("cmd_no_checks",e,{},r,i):this._cmd("cmd_no_checks",e,t,s,r,i)}cmd_raw_no_hazardous_check(e,t,s,r={},i={}){return t===void 0?this.exec("cmd_raw_no_hazardous_check",e,{},r,i):this._cmd("cmd_raw_no_hazardous_check",e,t,s,r,i)}cmd_raw_no_checks(e,t,s,r={},i={}){return t===void 0?this.exec("cmd_raw_no_checks",e,{},r,i):this._cmd("cmd_raw_no_checks",e,t,s,r,i)}build_cmd(e,t,s,r={},i={}){return t===void 0?this.exec("build_cmd",e):this._cmd("build_cmd",e,t,s,r,i)}build_command(e,t,s,r={},i={}){return t===void 0?this.exec("build_cmd",e):this._cmd("build_cmd",e,t,s,r,i)}get_interface_names(){return this.exec("get_interface_names",[])}send_raw(e,t){return this.exec("send_raw",[e,t])}list_configs(e){return this.exec("list_configs",[e])}load_config(e,t){return this.exec("load_config",[e,t])}save_config(e,t,s){return this.exec("save_config",[e,t,s])}delete_config(e,t){return this.exec("delete_config",[e,t])}enable_limits(e,t,s){return this.exec("enable_limits",[e,t,s])}disable_limits(e,t,s){return this.exec("disable_limits",[e,t,s])}get_out_of_limits(){return this.exec("get_out_of_limits",[])}get_overall_limits_state(e){return this.exec("get_overall_limits_state",[e])}list_settings(){return this.exec("list_settings",[])}get_all_settings(){return this.exec("get_all_settings",[])}get_setting(e,t){return this.exec("get_setting",[e],t)}get_settings(e,t){return this.exec("get_settings",e,t)}set_setting(e,t){return this.exec("set_setting",[e,t])}update_news(){return this.exec("update_news",[])}update_plugin_store(){return this.exec("update_plugin_store",[])}save_setting(e,t){return this.exec("set_setting",[e,t])}get_metrics(){return this.exec("get_metrics",[])}async hashString(e){if(window.isSecureContext){const t=new TextEncoder().encode(e),s=await crypto.subtle.digest("SHA-256",t),r=new Uint8Array(s);return Array.from(r).map(i=>i.toString(16).padStart(2,"0")).join("")}}}exports.Api=Ns;exports.Cable=lr;exports.ConfigParserError=Ue;exports.ConfigParserService=ur;exports.OpenC3Api=Vr;exports.axios=Se;
16
16
  //# sourceMappingURL=services.cjs.map