@camera.ui/browser 0.0.77 → 0.0.80
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/bundle.js +1 -1
- package/dist/types/packages/client/browser/src/proxy/cameraDevice.d.ts +21 -7
- package/dist/types/packages/client/browser/src/proxy/deviceManager.d.ts +4 -0
- package/dist/types/packages/client/browser/src/socket.d.ts +7 -7
- package/dist/types/packages/client/browser/src/streaming/go2rts-session.d.ts +54 -0
- package/dist/types/packages/client/browser/src/types.d.ts +11 -8
- package/dist/types/packages/client/browser/src/utils.d.ts +12 -0
- package/dist/types/server/src/api/controllers/users.controller.d.ts +9 -3
- package/dist/types/server/src/api/database/index.d.ts +10 -3
- package/dist/types/server/src/api/database/types.d.ts +35 -29
- package/dist/types/server/src/api/go2rtc/api/config.d.ts +3 -4
- package/dist/types/server/src/api/go2rtc/api/index.d.ts +1 -2
- package/dist/types/server/src/api/go2rtc/api/streams.d.ts +5 -6
- package/dist/types/server/src/api/go2rtc/types.d.ts +5 -2
- package/dist/types/server/src/api/index.d.ts +7 -9
- package/dist/types/server/src/api/middlewares/pagination.middleware.d.ts +1 -1
- package/dist/types/server/src/api/plugins/logger.plugin.d.ts +7 -0
- package/dist/types/server/src/api/routes/index.d.ts +1 -2
- package/dist/types/server/src/api/schemas/backup.schema.d.ts +53 -155
- package/dist/types/server/src/api/schemas/cameras.schema.d.ts +201 -142
- package/dist/types/server/src/api/schemas/config.schema.d.ts +20 -20
- package/dist/types/server/src/api/schemas/go2rtc.schema.d.ts +60 -60
- package/dist/types/server/src/api/schemas/users.schema.d.ts +242 -136
- package/dist/types/server/src/api/services/cameras.service.d.ts +9 -7
- package/dist/types/server/src/api/services/plugins.service.d.ts +1 -0
- package/dist/types/server/src/api/services/users.service.d.ts +6 -2
- package/dist/types/server/src/api/types/index.d.ts +34 -8
- package/dist/types/server/src/api/utils/fetch.d.ts +2 -0
- package/dist/types/server/src/api/websocket/nsp/status.d.ts +1 -1
- package/dist/types/server/src/api/websocket/types.d.ts +1 -15
- package/dist/types/server/src/api.d.ts +1 -2
- package/dist/types/server/src/camera/controller.d.ts +23 -12
- package/dist/types/server/src/camera/device.d.ts +7 -16
- package/dist/types/server/src/camera/index.d.ts +31 -22
- package/dist/types/server/src/camera/interfaces/audioDetection.d.ts +10 -0
- package/dist/types/server/src/camera/interfaces/camera.d.ts +19 -0
- package/dist/types/server/src/camera/interfaces/motionDetection.d.ts +10 -0
- package/dist/types/server/src/camera/interfaces/objectDetection.d.ts +10 -0
- package/dist/types/server/src/camera/interfaces/prebuffer.d.ts +11 -0
- package/dist/types/server/src/camera/interfaces/ptz.d.ts +13 -0
- package/dist/types/server/src/camera/polygon.d.ts +3 -2
- package/dist/types/server/src/camera/streaming/peer-connection.d.ts +1 -1
- package/dist/types/server/src/camera/streaming/webrtc-connection.d.ts +2 -1
- package/dist/types/server/src/camera/streaming/{streaming-session.d.ts → werift-session.d.ts} +1 -1
- package/dist/types/server/src/camera/types.d.ts +60 -21
- package/dist/types/server/src/camera/videoFrame.d.ts +10 -11
- package/dist/types/server/src/decoder/types.d.ts +31 -22
- package/dist/types/server/src/decoder/worker.d.ts +4 -4
- package/dist/types/server/src/nats/index.d.ts +1 -1
- package/dist/types/server/src/nats/proxy/cameraDevice.d.ts +30 -36
- package/dist/types/server/src/nats/proxy/deviceManager.d.ts +1 -1
- package/dist/types/server/src/nats/proxy/pluginsManager.d.ts +1 -1
- package/dist/types/server/src/nats/proxy/systemManager.d.ts +1 -1
- package/dist/types/server/src/nats/server.d.ts +10 -7
- package/dist/types/server/src/nats/types.d.ts +27 -53
- package/dist/types/server/src/nats/websocket.d.ts +9 -5
- package/dist/types/server/src/plugins/base.d.ts +2 -3
- package/dist/types/server/src/plugins/index.d.ts +1 -0
- package/dist/types/server/src/plugins/types.d.ts +22 -5
- package/dist/types/server/src/plugins/worker.d.ts +1 -0
- package/dist/types/server/src/polyglot/node/plugins/api.d.ts +1 -2
- package/dist/types/server/src/polyglot/node/plugins/cameraStorage.d.ts +2 -2
- package/dist/types/server/src/polyglot/node/plugins/proxy/cameraDevice.d.ts +35 -14
- package/dist/types/server/src/polyglot/node/plugins/proxy/deviceManager.d.ts +5 -5
- package/dist/types/server/src/polyglot/node/plugins/proxy/pluginsManager.d.ts +5 -5
- package/dist/types/server/src/polyglot/node/plugins/proxy/systemManager.d.ts +5 -5
- package/dist/types/server/src/polyglot/node/plugins/schema.d.ts +10 -2
- package/dist/types/server/src/polyglot/node/plugins/storageController.d.ts +1 -1
- package/dist/types/server/src/services/config/constants.d.ts +0 -2
- package/dist/types/server/src/services/config/index.d.ts +29 -36
- package/dist/types/server/src/services/config/types.d.ts +1 -1
- package/dist/types/server/src/types.d.ts +4 -0
- package/dist/types/server/src/utils/packer.d.ts +2 -0
- package/dist/types/server/src/utils/pythonInstaller.d.ts +1 -1
- package/dist/types/server/src/utils/utils.d.ts +5 -0
- package/dist/types/shared/types/index.d.ts +5 -0
- package/package.json +10 -14
- package/dist/types/packages/client/browser/src/streaming/peer-connection.d.ts +0 -24
- package/dist/types/packages/client/browser/src/streaming/streaming-session.d.ts +0 -25
- package/dist/types/packages/client/browser/src/streaming/webrtc-connection.d.ts +0 -26
- package/dist/types/server/src/api/utils/axios.d.ts +0 -2
- package/dist/types/server/src/api/websocket/nsp/streams.d.ts +0 -15
package/dist/bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t={275:(t,e,r)=>{t=r.nmd(t);var n="__lodash_hash_undefined__",i=9007199254740991,s="[object Arguments]",o="[object Boolean]",a="[object Date]",c="[object Function]",u="[object GeneratorFunction]",h="[object Map]",l="[object Number]",f="[object Object]",d="[object Promise]",p="[object RegExp]",b="[object Set]",y="[object String]",g="[object Symbol]",v="[object WeakMap]",m="[object ArrayBuffer]",w="[object DataView]",S="[object Float32Array]",_="[object Float64Array]",E="[object Int8Array]",O="[object Int16Array]",k="[object Int32Array]",x="[object Uint8Array]",T="[object Uint8ClampedArray]",A="[object Uint16Array]",j="[object Uint32Array]",R=/\w*$/,C=/^\[object .+?Constructor\]$/,L=/^(?:0|[1-9]\d*)$/,D={};D[s]=D["[object Array]"]=D[m]=D[w]=D[o]=D[a]=D[S]=D[_]=D[E]=D[O]=D[k]=D[h]=D[l]=D[f]=D[p]=D[b]=D[y]=D[g]=D[x]=D[T]=D[A]=D[j]=!0,D["[object Error]"]=D[c]=D[v]=!1;var P="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g,B="object"==typeof self&&self&&self.Object===Object&&self,F=P||B||Function("return this")(),z=e&&!e.nodeType&&e,N=z&&t&&!t.nodeType&&t,I=N&&N.exports===z;function U(t,e){return t.set(e[0],e[1]),t}function M(t,e){return t.add(e),t}function q(t,e,r,n){var i=-1,s=t?t.length:0;for(n&&s&&(r=t[++i]);++i<s;)r=e(r,t[i],i,t);return r}function V(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function W(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function H(t,e){return function(r){return t(e(r))}}function $(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var G,J=Array.prototype,K=Function.prototype,Y=Object.prototype,X=F["__core-js_shared__"],Q=(G=/[^.]+$/.exec(X&&X.keys&&X.keys.IE_PROTO||""))?"Symbol(src)_1."+G:"",Z=K.toString,tt=Y.hasOwnProperty,et=Y.toString,rt=RegExp("^"+Z.call(tt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),nt=I?F.Buffer:void 0,it=F.Symbol,st=F.Uint8Array,ot=H(Object.getPrototypeOf,Object),at=Object.create,ct=Y.propertyIsEnumerable,ut=J.splice,ht=Object.getOwnPropertySymbols,lt=nt?nt.isBuffer:void 0,ft=H(Object.keys,Object),dt=Ft(F,"DataView"),pt=Ft(F,"Map"),bt=Ft(F,"Promise"),yt=Ft(F,"Set"),gt=Ft(F,"WeakMap"),vt=Ft(Object,"create"),mt=Mt(dt),wt=Mt(pt),St=Mt(bt),_t=Mt(yt),Et=Mt(gt),Ot=it?it.prototype:void 0,kt=Ot?Ot.valueOf:void 0;function xt(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Tt(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function At(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function jt(t){this.__data__=new Tt(t)}function Rt(t,e,r){var n=t[e];tt.call(t,e)&&qt(n,r)&&(void 0!==r||e in t)||(t[e]=r)}function Ct(t,e){for(var r=t.length;r--;)if(qt(t[r][0],e))return r;return-1}function Lt(t,e,r,n,i,d,v){var C;if(n&&(C=d?n(t,i,d,v):n(t)),void 0!==C)return C;if(!Gt(t))return t;var L=Vt(t);if(L){if(C=function(t){var e=t.length,r=t.constructor(e);return e&&"string"==typeof t[0]&&tt.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!e)return function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}(t,C)}else{var P=Nt(t),B=P==c||P==u;if(Ht(t))return function(t,e){if(e)return t.slice();var r=new t.constructor(t.length);return t.copy(r),r}(t,e);if(P==f||P==s||B&&!d){if(V(t))return d?t:{};if(C=function(t){return"function"!=typeof t.constructor||Ut(t)?{}:Gt(e=ot(t))?at(e):{};var e}(B?{}:t),!e)return function(t,e){return Pt(t,zt(t),e)}(t,function(t,e){return t&&Pt(e,Jt(e),t)}(C,t))}else{if(!D[P])return d?t:{};C=function(t,e,r,n){var i,s=t.constructor;switch(e){case m:return Dt(t);case o:case a:return new s(+t);case w:return function(t,e){var r=e?Dt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,n);case S:case _:case E:case O:case k:case x:case T:case A:case j:return function(t,e){var r=e?Dt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}(t,n);case h:return function(t,e,r){return q(e?r(W(t),!0):W(t),U,new t.constructor)}(t,n,r);case l:case y:return new s(t);case p:return function(t){var e=new t.constructor(t.source,R.exec(t));return e.lastIndex=t.lastIndex,e}(t);case b:return function(t,e,r){return q(e?r($(t),!0):$(t),M,new t.constructor)}(t,n,r);case g:return i=t,kt?Object(kt.call(i)):{}}}(t,P,Lt,e)}}v||(v=new jt);var F=v.get(t);if(F)return F;if(v.set(t,C),!L)var z=r?function(t){return function(t,e,r){var n=e(t);return Vt(t)?n:function(t,e){for(var r=-1,n=e.length,i=t.length;++r<n;)t[i+r]=e[r];return t}(n,r(t))}(t,Jt,zt)}(t):Jt(t);return function(t,e){for(var r=-1,n=t?t.length:0;++r<n&&!1!==e(t[r],r););}(z||t,(function(i,s){z&&(i=t[s=i]),Rt(C,s,Lt(i,e,r,n,s,t,v))})),C}function Dt(t){var e=new t.constructor(t.byteLength);return new st(e).set(new st(t)),e}function Pt(t,e,r,n){r||(r={});for(var i=-1,s=e.length;++i<s;){var o=e[i],a=n?n(r[o],t[o],o,r,t):void 0;Rt(r,o,void 0===a?t[o]:a)}return r}function Bt(t,e){var r,n,i=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?i["string"==typeof e?"string":"hash"]:i.map}function Ft(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){return!(!Gt(t)||(e=t,Q&&Q in e))&&($t(t)||V(t)?rt:C).test(Mt(t));var e}(r)?r:void 0}xt.prototype.clear=function(){this.__data__=vt?vt(null):{}},xt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},xt.prototype.get=function(t){var e=this.__data__;if(vt){var r=e[t];return r===n?void 0:r}return tt.call(e,t)?e[t]:void 0},xt.prototype.has=function(t){var e=this.__data__;return vt?void 0!==e[t]:tt.call(e,t)},xt.prototype.set=function(t,e){return this.__data__[t]=vt&&void 0===e?n:e,this},Tt.prototype.clear=function(){this.__data__=[]},Tt.prototype.delete=function(t){var e=this.__data__,r=Ct(e,t);return!(r<0||(r==e.length-1?e.pop():ut.call(e,r,1),0))},Tt.prototype.get=function(t){var e=this.__data__,r=Ct(e,t);return r<0?void 0:e[r][1]},Tt.prototype.has=function(t){return Ct(this.__data__,t)>-1},Tt.prototype.set=function(t,e){var r=this.__data__,n=Ct(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},At.prototype.clear=function(){this.__data__={hash:new xt,map:new(pt||Tt),string:new xt}},At.prototype.delete=function(t){return Bt(this,t).delete(t)},At.prototype.get=function(t){return Bt(this,t).get(t)},At.prototype.has=function(t){return Bt(this,t).has(t)},At.prototype.set=function(t,e){return Bt(this,t).set(t,e),this},jt.prototype.clear=function(){this.__data__=new Tt},jt.prototype.delete=function(t){return this.__data__.delete(t)},jt.prototype.get=function(t){return this.__data__.get(t)},jt.prototype.has=function(t){return this.__data__.has(t)},jt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Tt){var n=r.__data__;if(!pt||n.length<199)return n.push([t,e]),this;r=this.__data__=new At(n)}return r.set(t,e),this};var zt=ht?H(ht,Object):function(){return[]},Nt=function(t){return et.call(t)};function It(t,e){return!!(e=null==e?i:e)&&("number"==typeof t||L.test(t))&&t>-1&&t%1==0&&t<e}function Ut(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Y)}function Mt(t){if(null!=t){try{return Z.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function qt(t,e){return t===e||t!=t&&e!=e}(dt&&Nt(new dt(new ArrayBuffer(1)))!=w||pt&&Nt(new pt)!=h||bt&&Nt(bt.resolve())!=d||yt&&Nt(new yt)!=b||gt&&Nt(new gt)!=v)&&(Nt=function(t){var e=et.call(t),r=e==f?t.constructor:void 0,n=r?Mt(r):void 0;if(n)switch(n){case mt:return w;case wt:return h;case St:return d;case _t:return b;case Et:return v}return e});var Vt=Array.isArray;function Wt(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=i}(t.length)&&!$t(t)}var Ht=lt||function(){return!1};function $t(t){var e=Gt(t)?et.call(t):"";return e==c||e==u}function Gt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Jt(t){return Wt(t)?function(t,e){var r=Vt(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&Wt(t)}(t)&&tt.call(t,"callee")&&(!ct.call(t,"callee")||et.call(t)==s)}(t)?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],n=r.length,i=!!n;for(var o in t)!e&&!tt.call(t,o)||i&&("length"==o||It(o,n))||r.push(o);return r}(t):function(t){if(!Ut(t))return ft(t);var e=[];for(var r in Object(t))tt.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}t.exports=function(t){return Lt(t,!0,!0)}},512:(t,e,r)=>{t=r.nmd(t);var n="__lodash_hash_undefined__",i=1,s=2,o=9007199254740991,a="[object Arguments]",c="[object Array]",u="[object AsyncFunction]",h="[object Boolean]",l="[object Date]",f="[object Error]",d="[object Function]",p="[object GeneratorFunction]",b="[object Map]",y="[object Number]",g="[object Null]",v="[object Object]",m="[object Promise]",w="[object Proxy]",S="[object RegExp]",_="[object Set]",E="[object String]",O="[object Undefined]",k="[object WeakMap]",x="[object ArrayBuffer]",T="[object DataView]",A=/^\[object .+?Constructor\]$/,j=/^(?:0|[1-9]\d*)$/,R={};R["[object Float32Array]"]=R["[object Float64Array]"]=R["[object Int8Array]"]=R["[object Int16Array]"]=R["[object Int32Array]"]=R["[object Uint8Array]"]=R["[object Uint8ClampedArray]"]=R["[object Uint16Array]"]=R["[object Uint32Array]"]=!0,R[a]=R[c]=R[x]=R[h]=R[T]=R[l]=R[f]=R[d]=R[b]=R[y]=R[v]=R[S]=R[_]=R[E]=R[k]=!1;var C="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g,L="object"==typeof self&&self&&self.Object===Object&&self,D=C||L||Function("return this")(),P=e&&!e.nodeType&&e,B=P&&t&&!t.nodeType&&t,F=B&&B.exports===P,z=F&&C.process,N=function(){try{return z&&z.binding&&z.binding("util")}catch(t){}}(),I=N&&N.isTypedArray;function U(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}function M(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function q(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var V,W,H,$=Array.prototype,G=Function.prototype,J=Object.prototype,K=D["__core-js_shared__"],Y=G.toString,X=J.hasOwnProperty,Q=(V=/[^.]+$/.exec(K&&K.keys&&K.keys.IE_PROTO||""))?"Symbol(src)_1."+V:"",Z=J.toString,tt=RegExp("^"+Y.call(X).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),et=F?D.Buffer:void 0,rt=D.Symbol,nt=D.Uint8Array,it=J.propertyIsEnumerable,st=$.splice,ot=rt?rt.toStringTag:void 0,at=Object.getOwnPropertySymbols,ct=et?et.isBuffer:void 0,ut=(W=Object.keys,H=Object,function(t){return W(H(t))}),ht=Bt(D,"DataView"),lt=Bt(D,"Map"),ft=Bt(D,"Promise"),dt=Bt(D,"Set"),pt=Bt(D,"WeakMap"),bt=Bt(Object,"create"),yt=It(ht),gt=It(lt),vt=It(ft),mt=It(dt),wt=It(pt),St=rt?rt.prototype:void 0,_t=St?St.valueOf:void 0;function Et(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Ot(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function kt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function xt(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new kt;++e<r;)this.add(t[e])}function Tt(t){var e=this.__data__=new Ot(t);this.size=e.size}function At(t,e){for(var r=t.length;r--;)if(Ut(t[r][0],e))return r;return-1}function jt(t){return null==t?void 0===t?O:g:ot&&ot in Object(t)?function(t){var e=X.call(t,ot),r=t[ot];try{t[ot]=void 0;var n=!0}catch(t){}var i=Z.call(t);return n&&(e?t[ot]=r:delete t[ot]),i}(t):function(t){return Z.call(t)}(t)}function Rt(t){return Gt(t)&&jt(t)==a}function Ct(t,e,r,n,o){return t===e||(null==t||null==e||!Gt(t)&&!Gt(e)?t!=t&&e!=e:function(t,e,r,n,o,u){var d=qt(t),p=qt(e),g=d?c:zt(t),m=p?c:zt(e),w=(g=g==a?v:g)==v,O=(m=m==a?v:m)==v,k=g==m;if(k&&Vt(t)){if(!Vt(e))return!1;d=!0,w=!1}if(k&&!w)return u||(u=new Tt),d||Jt(t)?Lt(t,e,r,n,o,u):function(t,e,r,n,o,a,c){switch(r){case T:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case x:return!(t.byteLength!=e.byteLength||!a(new nt(t),new nt(e)));case h:case l:case y:return Ut(+t,+e);case f:return t.name==e.name&&t.message==e.message;case S:case E:return t==e+"";case b:var u=M;case _:var d=n&i;if(u||(u=q),t.size!=e.size&&!d)return!1;var p=c.get(t);if(p)return p==e;n|=s,c.set(t,e);var g=Lt(u(t),u(e),n,o,a,c);return c.delete(t),g;case"[object Symbol]":if(_t)return _t.call(t)==_t.call(e)}return!1}(t,e,g,r,n,o,u);if(!(r&i)){var A=w&&X.call(t,"__wrapped__"),j=O&&X.call(e,"__wrapped__");if(A||j){var R=A?t.value():t,C=j?e.value():e;return u||(u=new Tt),o(R,C,r,n,u)}}return!!k&&(u||(u=new Tt),function(t,e,r,n,s,o){var a=r&i,c=Dt(t),u=c.length;if(u!=Dt(e).length&&!a)return!1;for(var h=u;h--;){var l=c[h];if(!(a?l in e:X.call(e,l)))return!1}var f=o.get(t);if(f&&o.get(e))return f==e;var d=!0;o.set(t,e),o.set(e,t);for(var p=a;++h<u;){var b=t[l=c[h]],y=e[l];if(n)var g=a?n(y,b,l,e,t,o):n(b,y,l,t,e,o);if(!(void 0===g?b===y||s(b,y,r,n,o):g)){d=!1;break}p||(p="constructor"==l)}if(d&&!p){var v=t.constructor,m=e.constructor;v==m||!("constructor"in t)||!("constructor"in e)||"function"==typeof v&&v instanceof v&&"function"==typeof m&&m instanceof m||(d=!1)}return o.delete(t),o.delete(e),d}(t,e,r,n,o,u))}(t,e,r,n,Ct,o))}function Lt(t,e,r,n,o,a){var c=r&i,u=t.length,h=e.length;if(u!=h&&!(c&&h>u))return!1;var l=a.get(t);if(l&&a.get(e))return l==e;var f=-1,d=!0,p=r&s?new xt:void 0;for(a.set(t,e),a.set(e,t);++f<u;){var b=t[f],y=e[f];if(n)var g=c?n(y,b,f,e,t,a):n(b,y,f,t,e,a);if(void 0!==g){if(g)continue;d=!1;break}if(p){if(!U(e,(function(t,e){if(i=e,!p.has(i)&&(b===t||o(b,t,r,n,a)))return p.push(e);var i}))){d=!1;break}}else if(b!==y&&!o(b,y,r,n,a)){d=!1;break}}return a.delete(t),a.delete(e),d}function Dt(t){return function(t,e,r){var n=e(t);return qt(t)?n:function(t,e){for(var r=-1,n=e.length,i=t.length;++r<n;)t[i+r]=e[r];return t}(n,r(t))}(t,Kt,Ft)}function Pt(t,e){var r,n,i=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?i["string"==typeof e?"string":"hash"]:i.map}function Bt(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){return!(!$t(t)||function(t){return!!Q&&Q in t}(t))&&(Wt(t)?tt:A).test(It(t))}(r)?r:void 0}Et.prototype.clear=function(){this.__data__=bt?bt(null):{},this.size=0},Et.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Et.prototype.get=function(t){var e=this.__data__;if(bt){var r=e[t];return r===n?void 0:r}return X.call(e,t)?e[t]:void 0},Et.prototype.has=function(t){var e=this.__data__;return bt?void 0!==e[t]:X.call(e,t)},Et.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=bt&&void 0===e?n:e,this},Ot.prototype.clear=function(){this.__data__=[],this.size=0},Ot.prototype.delete=function(t){var e=this.__data__,r=At(e,t);return!(r<0||(r==e.length-1?e.pop():st.call(e,r,1),--this.size,0))},Ot.prototype.get=function(t){var e=this.__data__,r=At(e,t);return r<0?void 0:e[r][1]},Ot.prototype.has=function(t){return At(this.__data__,t)>-1},Ot.prototype.set=function(t,e){var r=this.__data__,n=At(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},kt.prototype.clear=function(){this.size=0,this.__data__={hash:new Et,map:new(lt||Ot),string:new Et}},kt.prototype.delete=function(t){var e=Pt(this,t).delete(t);return this.size-=e?1:0,e},kt.prototype.get=function(t){return Pt(this,t).get(t)},kt.prototype.has=function(t){return Pt(this,t).has(t)},kt.prototype.set=function(t,e){var r=Pt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},xt.prototype.add=xt.prototype.push=function(t){return this.__data__.set(t,n),this},xt.prototype.has=function(t){return this.__data__.has(t)},Tt.prototype.clear=function(){this.__data__=new Ot,this.size=0},Tt.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Tt.prototype.get=function(t){return this.__data__.get(t)},Tt.prototype.has=function(t){return this.__data__.has(t)},Tt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Ot){var n=r.__data__;if(!lt||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new kt(n)}return r.set(t,e),this.size=r.size,this};var Ft=at?function(t){return null==t?[]:(t=Object(t),function(e,r){for(var n=-1,i=null==e?0:e.length,s=0,o=[];++n<i;){var a=e[n];c=a,it.call(t,c)&&(o[s++]=a)}var c;return o}(at(t)))}:function(){return[]},zt=jt;function Nt(t,e){return!!(e=null==e?o:e)&&("number"==typeof t||j.test(t))&&t>-1&&t%1==0&&t<e}function It(t){if(null!=t){try{return Y.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Ut(t,e){return t===e||t!=t&&e!=e}(ht&&zt(new ht(new ArrayBuffer(1)))!=T||lt&&zt(new lt)!=b||ft&&zt(ft.resolve())!=m||dt&&zt(new dt)!=_||pt&&zt(new pt)!=k)&&(zt=function(t){var e=jt(t),r=e==v?t.constructor:void 0,n=r?It(r):"";if(n)switch(n){case yt:return T;case gt:return b;case vt:return m;case mt:return _;case wt:return k}return e});var Mt=Rt(function(){return arguments}())?Rt:function(t){return Gt(t)&&X.call(t,"callee")&&!it.call(t,"callee")},qt=Array.isArray,Vt=ct||function(){return!1};function Wt(t){if(!$t(t))return!1;var e=jt(t);return e==d||e==p||e==u||e==w}function Ht(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=o}function $t(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Gt(t){return null!=t&&"object"==typeof t}var Jt=I?function(t){return function(e){return t(e)}}(I):function(t){return Gt(t)&&Ht(t.length)&&!!R[jt(t)]};function Kt(t){return null!=(e=t)&&Ht(e.length)&&!Wt(e)?function(t,e){var r=qt(t),n=!r&&Mt(t),i=!r&&!n&&Vt(t),s=!r&&!n&&!i&&Jt(t),o=r||n||i||s,a=o?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],c=a.length;for(var u in t)!e&&!X.call(t,u)||o&&("length"==u||i&&("offset"==u||"parent"==u)||s&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||Nt(u,c))||a.push(u);return a}(t):function(t){if(r=(e=t)&&e.constructor,e!==("function"==typeof r&&r.prototype||J))return ut(t);var e,r,n=[];for(var i in Object(t))X.call(t,i)&&"constructor"!=i&&n.push(i);return n}(t);var e}t.exports=function(t,e){return Ct(t,e)}}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var s=e[n]={id:n,loaded:!1,exports:{}};return t[n](s,s.exports,r),s.loaded=!0,s.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.nmd=t=>(t.paths=[],t.children||(t.children=[]),t);var n={};(()=>{r.d(n,{j:()=>Ns});var t={};r.r(t),r.d(t,{hasBrowserEnv:()=>ot,hasStandardBrowserEnv:()=>at,hasStandardBrowserWebWorkerEnv:()=>ut,origin:()=>ht});var e={};function i(t,e){return function(){return t.apply(e,arguments)}}r.r(e),r.d(e,{Decoder:()=>As,Encoder:()=>xs,PacketType:()=>ks,protocol:()=>Os});const{toString:s}=Object.prototype,{getPrototypeOf:o}=Object,a=(t=>e=>{const r=s.call(e);return t[r]||(t[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),c=t=>(t=t.toLowerCase(),e=>a(e)===t),u=t=>e=>typeof e===t,{isArray:h}=Array,l=u("undefined"),f=c("ArrayBuffer"),d=u("string"),p=u("function"),b=u("number"),y=t=>null!==t&&"object"==typeof t,g=t=>{if("object"!==a(t))return!1;const e=o(t);return!(null!==e&&e!==Object.prototype&&null!==Object.getPrototypeOf(e)||Symbol.toStringTag in t||Symbol.iterator in t)},v=c("Date"),m=c("File"),w=c("Blob"),S=c("FileList"),_=c("URLSearchParams"),[E,O,k,x]=["ReadableStream","Request","Response","Headers"].map(c);function T(t,e,{allOwnKeys:r=!1}={}){if(null==t)return;let n,i;if("object"!=typeof t&&(t=[t]),h(t))for(n=0,i=t.length;n<i;n++)e.call(null,t[n],n,t);else{const i=r?Object.getOwnPropertyNames(t):Object.keys(t),s=i.length;let o;for(n=0;n<s;n++)o=i[n],e.call(null,t[o],o,t)}}function A(t,e){e=e.toLowerCase();const r=Object.keys(t);let n,i=r.length;for(;i-- >0;)if(n=r[i],e===n.toLowerCase())return n;return null}const j="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,R=t=>!l(t)&&t!==j,C=(L="undefined"!=typeof Uint8Array&&o(Uint8Array),t=>L&&t instanceof L);var L;const D=c("HTMLFormElement"),P=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),B=c("RegExp"),F=(t,e)=>{const r=Object.getOwnPropertyDescriptors(t),n={};T(r,((r,i)=>{let s;!1!==(s=e(r,i,t))&&(n[i]=s||r)})),Object.defineProperties(t,n)},z="abcdefghijklmnopqrstuvwxyz",N="0123456789",I={DIGIT:N,ALPHA:z,ALPHA_DIGIT:z+z.toUpperCase()+N},U=c("AsyncFunction"),M={isArray:h,isArrayBuffer:f,isBuffer:function(t){return null!==t&&!l(t)&&null!==t.constructor&&!l(t.constructor)&&p(t.constructor.isBuffer)&&t.constructor.isBuffer(t)},isFormData:t=>{let e;return t&&("function"==typeof FormData&&t instanceof FormData||p(t.append)&&("formdata"===(e=a(t))||"object"===e&&p(t.toString)&&"[object FormData]"===t.toString()))},isArrayBufferView:function(t){let e;return e="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&f(t.buffer),e},isString:d,isNumber:b,isBoolean:t=>!0===t||!1===t,isObject:y,isPlainObject:g,isReadableStream:E,isRequest:O,isResponse:k,isHeaders:x,isUndefined:l,isDate:v,isFile:m,isBlob:w,isRegExp:B,isFunction:p,isStream:t=>y(t)&&p(t.pipe),isURLSearchParams:_,isTypedArray:C,isFileList:S,forEach:T,merge:function t(){const{caseless:e}=R(this)&&this||{},r={},n=(n,i)=>{const s=e&&A(r,i)||i;g(r[s])&&g(n)?r[s]=t(r[s],n):g(n)?r[s]=t({},n):h(n)?r[s]=n.slice():r[s]=n};for(let t=0,e=arguments.length;t<e;t++)arguments[t]&&T(arguments[t],n);return r},extend:(t,e,r,{allOwnKeys:n}={})=>(T(e,((e,n)=>{r&&p(e)?t[n]=i(e,r):t[n]=e}),{allOwnKeys:n}),t),trim:t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:t=>(65279===t.charCodeAt(0)&&(t=t.slice(1)),t),inherits:(t,e,r,n)=>{t.prototype=Object.create(e.prototype,n),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),r&&Object.assign(t.prototype,r)},toFlatObject:(t,e,r,n)=>{let i,s,a;const c={};if(e=e||{},null==t)return e;do{for(i=Object.getOwnPropertyNames(t),s=i.length;s-- >0;)a=i[s],n&&!n(a,t,e)||c[a]||(e[a]=t[a],c[a]=!0);t=!1!==r&&o(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},kindOf:a,kindOfTest:c,endsWith:(t,e,r)=>{t=String(t),(void 0===r||r>t.length)&&(r=t.length),r-=e.length;const n=t.indexOf(e,r);return-1!==n&&n===r},toArray:t=>{if(!t)return null;if(h(t))return t;let e=t.length;if(!b(e))return null;const r=new Array(e);for(;e-- >0;)r[e]=t[e];return r},forEachEntry:(t,e)=>{const r=(t&&t[Symbol.iterator]).call(t);let n;for(;(n=r.next())&&!n.done;){const r=n.value;e.call(t,r[0],r[1])}},matchAll:(t,e)=>{let r;const n=[];for(;null!==(r=t.exec(e));)n.push(r);return n},isHTMLForm:D,hasOwnProperty:P,hasOwnProp:P,reduceDescriptors:F,freezeMethods:t=>{F(t,((e,r)=>{if(p(t)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=t[r];p(n)&&(e.enumerable=!1,"writable"in e?e.writable=!1:e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))}))},toObjectSet:(t,e)=>{const r={},n=t=>{t.forEach((t=>{r[t]=!0}))};return h(t)?n(t):n(String(t).split(e)),r},toCamelCase:t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(t,e,r){return e.toUpperCase()+r})),noop:()=>{},toFiniteNumber:(t,e)=>null!=t&&Number.isFinite(t=+t)?t:e,findKey:A,global:j,isContextDefined:R,ALPHABET:I,generateString:(t=16,e=I.ALPHA_DIGIT)=>{let r="";const{length:n}=e;for(;t--;)r+=e[Math.random()*n|0];return r},isSpecCompliantForm:function(t){return!!(t&&p(t.append)&&"FormData"===t[Symbol.toStringTag]&&t[Symbol.iterator])},toJSONObject:t=>{const e=new Array(10),r=(t,n)=>{if(y(t)){if(e.indexOf(t)>=0)return;if(!("toJSON"in t)){e[n]=t;const i=h(t)?[]:{};return T(t,((t,e)=>{const s=r(t,n+1);!l(s)&&(i[e]=s)})),e[n]=void 0,i}}return t};return r(t,0)},isAsyncFn:U,isThenable:t=>t&&(y(t)||p(t))&&p(t.then)&&p(t.catch)};function q(t,e,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=t,this.name="AxiosError",e&&(this.code=e),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i)}M.inherits(q,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:M.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const V=q.prototype,W={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((t=>{W[t]={value:t}})),Object.defineProperties(q,W),Object.defineProperty(V,"isAxiosError",{value:!0}),q.from=(t,e,r,n,i,s)=>{const o=Object.create(V);return M.toFlatObject(t,o,(function(t){return t!==Error.prototype}),(t=>"isAxiosError"!==t)),q.call(o,t.message,e,r,n,i),o.cause=t,o.name=t.name,s&&Object.assign(o,s),o};const H=q;function $(t){return M.isPlainObject(t)||M.isArray(t)}function G(t){return M.endsWith(t,"[]")?t.slice(0,-2):t}function J(t,e,r){return t?t.concat(e).map((function(t,e){return t=G(t),!r&&e?"["+t+"]":t})).join(r?".":""):e}const K=M.toFlatObject(M,{},null,(function(t){return/^is[A-Z]/.test(t)})),Y=function(t,e,r){if(!M.isObject(t))throw new TypeError("target must be an object");e=e||new FormData;const n=(r=M.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(t,e){return!M.isUndefined(e[t])}))).metaTokens,i=r.visitor||u,s=r.dots,o=r.indexes,a=(r.Blob||"undefined"!=typeof Blob&&Blob)&&M.isSpecCompliantForm(e);if(!M.isFunction(i))throw new TypeError("visitor must be a function");function c(t){if(null===t)return"";if(M.isDate(t))return t.toISOString();if(!a&&M.isBlob(t))throw new H("Blob is not supported. Use a Buffer instead.");return M.isArrayBuffer(t)||M.isTypedArray(t)?a&&"function"==typeof Blob?new Blob([t]):Buffer.from(t):t}function u(t,r,i){let a=t;if(t&&!i&&"object"==typeof t)if(M.endsWith(r,"{}"))r=n?r:r.slice(0,-2),t=JSON.stringify(t);else if(M.isArray(t)&&function(t){return M.isArray(t)&&!t.some($)}(t)||(M.isFileList(t)||M.endsWith(r,"[]"))&&(a=M.toArray(t)))return r=G(r),a.forEach((function(t,n){!M.isUndefined(t)&&null!==t&&e.append(!0===o?J([r],n,s):null===o?r:r+"[]",c(t))})),!1;return!!$(t)||(e.append(J(i,r,s),c(t)),!1)}const h=[],l=Object.assign(K,{defaultVisitor:u,convertValue:c,isVisitable:$});if(!M.isObject(t))throw new TypeError("data must be an object");return function t(r,n){if(!M.isUndefined(r)){if(-1!==h.indexOf(r))throw Error("Circular reference detected in "+n.join("."));h.push(r),M.forEach(r,(function(r,s){!0===(!(M.isUndefined(r)||null===r)&&i.call(e,r,M.isString(s)?s.trim():s,n,l))&&t(r,n?n.concat(s):[s])})),h.pop()}}(t),e};function X(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,(function(t){return e[t]}))}function Q(t,e){this._pairs=[],t&&Y(t,this,e)}const Z=Q.prototype;Z.append=function(t,e){this._pairs.push([t,e])},Z.toString=function(t){const e=t?function(e){return t.call(this,e,X)}:X;return this._pairs.map((function(t){return e(t[0])+"="+e(t[1])}),"").join("&")};const tt=Q;function et(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function rt(t,e,r){if(!e)return t;const n=r&&r.encode||et,i=r&&r.serialize;let s;if(s=i?i(e,r):M.isURLSearchParams(e)?e.toString():new tt(e,r).toString(n),s){const e=t.indexOf("#");-1!==e&&(t=t.slice(0,e)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t}const nt=class{constructor(){this.handlers=[]}use(t,e,r){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){M.forEach(this.handlers,(function(e){null!==e&&t(e)}))}},it={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},st={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:tt,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},ot="undefined"!=typeof window&&"undefined"!=typeof document,at=(ct="undefined"!=typeof navigator&&navigator.product,ot&&["ReactNative","NativeScript","NS"].indexOf(ct)<0);var ct;const ut="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,ht=ot&&window.location.href||"http://localhost",lt={...t,...st},ft=function(t){function e(t,r,n,i){let s=t[i++];if("__proto__"===s)return!0;const o=Number.isFinite(+s),a=i>=t.length;return s=!s&&M.isArray(n)?n.length:s,a?(M.hasOwnProp(n,s)?n[s]=[n[s],r]:n[s]=r,!o):(n[s]&&M.isObject(n[s])||(n[s]=[]),e(t,r,n[s],i)&&M.isArray(n[s])&&(n[s]=function(t){const e={},r=Object.keys(t);let n;const i=r.length;let s;for(n=0;n<i;n++)s=r[n],e[s]=t[s];return e}(n[s])),!o)}if(M.isFormData(t)&&M.isFunction(t.entries)){const r={};return M.forEachEntry(t,((t,n)=>{e(function(t){return M.matchAll(/\w+|\[(\w*)]/g,t).map((t=>"[]"===t[0]?"":t[1]||t[0]))}(t),n,r,0)})),r}return null},dt={transitional:it,adapter:["xhr","http","fetch"],transformRequest:[function(t,e){const r=e.getContentType()||"",n=r.indexOf("application/json")>-1,i=M.isObject(t);if(i&&M.isHTMLForm(t)&&(t=new FormData(t)),M.isFormData(t))return n?JSON.stringify(ft(t)):t;if(M.isArrayBuffer(t)||M.isBuffer(t)||M.isStream(t)||M.isFile(t)||M.isBlob(t)||M.isReadableStream(t))return t;if(M.isArrayBufferView(t))return t.buffer;if(M.isURLSearchParams(t))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let s;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(t,e){return Y(t,new lt.classes.URLSearchParams,Object.assign({visitor:function(t,e,r,n){return lt.isNode&&M.isBuffer(t)?(this.append(e,t.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},e))}(t,this.formSerializer).toString();if((s=M.isFileList(t))||r.indexOf("multipart/form-data")>-1){const e=this.env&&this.env.FormData;return Y(s?{"files[]":t}:t,e&&new e,this.formSerializer)}}return i||n?(e.setContentType("application/json",!1),function(t,e,r){if(M.isString(t))try{return(0,JSON.parse)(t),M.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(0,JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){const e=this.transitional||dt.transitional,r=e&&e.forcedJSONParsing,n="json"===this.responseType;if(M.isResponse(t)||M.isReadableStream(t))return t;if(t&&M.isString(t)&&(r&&!this.responseType||n)){const r=!(e&&e.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(t){if(r){if("SyntaxError"===t.name)throw H.from(t,H.ERR_BAD_RESPONSE,this,null,this.response);throw t}}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:lt.classes.FormData,Blob:lt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};M.forEach(["delete","get","head","post","put","patch"],(t=>{dt.headers[t]={}}));const pt=dt,bt=M.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"]),yt=Symbol("internals");function gt(t){return t&&String(t).trim().toLowerCase()}function vt(t){return!1===t||null==t?t:M.isArray(t)?t.map(vt):String(t)}function mt(t,e,r,n,i){return M.isFunction(n)?n.call(this,e,r):(i&&(e=r),M.isString(e)?M.isString(n)?-1!==e.indexOf(n):M.isRegExp(n)?n.test(e):void 0:void 0)}class wt{constructor(t){t&&this.set(t)}set(t,e,r){const n=this;function i(t,e,r){const i=gt(e);if(!i)throw new Error("header name must be a non-empty string");const s=M.findKey(n,i);(!s||void 0===n[s]||!0===r||void 0===r&&!1!==n[s])&&(n[s||e]=vt(t))}const s=(t,e)=>M.forEach(t,((t,r)=>i(t,r,e)));if(M.isPlainObject(t)||t instanceof this.constructor)s(t,e);else if(M.isString(t)&&(t=t.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim()))s((t=>{const e={};let r,n,i;return t&&t.split("\n").forEach((function(t){i=t.indexOf(":"),r=t.substring(0,i).trim().toLowerCase(),n=t.substring(i+1).trim(),!r||e[r]&&bt[r]||("set-cookie"===r?e[r]?e[r].push(n):e[r]=[n]:e[r]=e[r]?e[r]+", "+n:n)})),e})(t),e);else if(M.isHeaders(t))for(const[e,n]of t.entries())i(n,e,r);else null!=t&&i(e,t,r);return this}get(t,e){if(t=gt(t)){const r=M.findKey(this,t);if(r){const t=this[r];if(!e)return t;if(!0===e)return function(t){const e=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(t);)e[n[1]]=n[2];return e}(t);if(M.isFunction(e))return e.call(this,t,r);if(M.isRegExp(e))return e.exec(t);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){if(t=gt(t)){const r=M.findKey(this,t);return!(!r||void 0===this[r]||e&&!mt(0,this[r],r,e))}return!1}delete(t,e){const r=this;let n=!1;function i(t){if(t=gt(t)){const i=M.findKey(r,t);!i||e&&!mt(0,r[i],i,e)||(delete r[i],n=!0)}}return M.isArray(t)?t.forEach(i):i(t),n}clear(t){const e=Object.keys(this);let r=e.length,n=!1;for(;r--;){const i=e[r];t&&!mt(0,this[i],i,t,!0)||(delete this[i],n=!0)}return n}normalize(t){const e=this,r={};return M.forEach(this,((n,i)=>{const s=M.findKey(r,i);if(s)return e[s]=vt(n),void delete e[i];const o=t?function(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((t,e,r)=>e.toUpperCase()+r))}(i):String(i).trim();o!==i&&delete e[i],e[o]=vt(n),r[o]=!0})),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);return M.forEach(this,((r,n)=>{null!=r&&!1!==r&&(e[n]=t&&M.isArray(r)?r.join(", "):r)})),e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([t,e])=>t+": "+e)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...e){const r=new this(t);return e.forEach((t=>r.set(t))),r}static accessor(t){const e=(this[yt]=this[yt]={accessors:{}}).accessors,r=this.prototype;function n(t){const n=gt(t);e[n]||(function(t,e){const r=M.toCamelCase(" "+e);["get","set","has"].forEach((n=>{Object.defineProperty(t,n+r,{value:function(t,r,i){return this[n].call(this,e,t,r,i)},configurable:!0})}))}(r,t),e[n]=!0)}return M.isArray(t)?t.forEach(n):n(t),this}}wt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),M.reduceDescriptors(wt.prototype,(({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(t){this[r]=t}}})),M.freezeMethods(wt);const St=wt;function _t(t,e){const r=this||pt,n=e||r,i=St.from(n.headers);let s=n.data;return M.forEach(t,(function(t){s=t.call(r,s,i.normalize(),e?e.status:void 0)})),i.normalize(),s}function Et(t){return!(!t||!t.__CANCEL__)}function Ot(t,e,r){H.call(this,null==t?"canceled":t,H.ERR_CANCELED,e,r),this.name="CanceledError"}M.inherits(Ot,H,{__CANCEL__:!0});const kt=Ot;function xt(t,e,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?e(new H("Request failed with status code "+r.status,[H.ERR_BAD_REQUEST,H.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):t(r)}const Tt=(t,e,r=3)=>{let n=0;const i=function(t,e){t=t||10;const r=new Array(t),n=new Array(t);let i,s=0,o=0;return e=void 0!==e?e:1e3,function(a){const c=Date.now(),u=n[o];i||(i=c),r[s]=a,n[s]=c;let h=o,l=0;for(;h!==s;)l+=r[h++],h%=t;if(s=(s+1)%t,s===o&&(o=(o+1)%t),c-i<e)return;const f=u&&c-u;return f?Math.round(1e3*l/f):void 0}}(50,250);return function(t,e){let r=0;const n=1e3/e;let i=null;return function(){const e=!0===this,s=Date.now();if(e||s-r>n)return i&&(clearTimeout(i),i=null),r=s,t.apply(null,arguments);i||(i=setTimeout((()=>(i=null,r=Date.now(),t.apply(null,arguments))),n-(s-r)))}}((r=>{const s=r.loaded,o=r.lengthComputable?r.total:void 0,a=s-n,c=i(a);n=s;const u={loaded:s,total:o,progress:o?s/o:void 0,bytes:a,rate:c||void 0,estimated:c&&o&&s<=o?(o-s)/c:void 0,event:r,lengthComputable:null!=o};u[e?"download":"upload"]=!0,t(u)}),r)},At=lt.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),e=document.createElement("a");let r;function n(r){let n=r;return t&&(e.setAttribute("href",n),n=e.href),e.setAttribute("href",n),{href:e.href,protocol:e.protocol?e.protocol.replace(/:$/,""):"",host:e.host,search:e.search?e.search.replace(/^\?/,""):"",hash:e.hash?e.hash.replace(/^#/,""):"",hostname:e.hostname,port:e.port,pathname:"/"===e.pathname.charAt(0)?e.pathname:"/"+e.pathname}}return r=n(window.location.href),function(t){const e=M.isString(t)?n(t):t;return e.protocol===r.protocol&&e.host===r.host}}():function(){return!0},jt=lt.hasStandardBrowserEnv?{write(t,e,r,n,i,s){const o=[t+"="+encodeURIComponent(e)];M.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),M.isString(n)&&o.push("path="+n),M.isString(i)&&o.push("domain="+i),!0===s&&o.push("secure"),document.cookie=o.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Rt(t,e){return t&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)?function(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}(t,e):e}const Ct=t=>t instanceof St?{...t}:t;function Lt(t,e){e=e||{};const r={};function n(t,e,r){return M.isPlainObject(t)&&M.isPlainObject(e)?M.merge.call({caseless:r},t,e):M.isPlainObject(e)?M.merge({},e):M.isArray(e)?e.slice():e}function i(t,e,r){return M.isUndefined(e)?M.isUndefined(t)?void 0:n(void 0,t,r):n(t,e,r)}function s(t,e){if(!M.isUndefined(e))return n(void 0,e)}function o(t,e){return M.isUndefined(e)?M.isUndefined(t)?void 0:n(void 0,t):n(void 0,e)}function a(r,i,s){return s in e?n(r,i):s in t?n(void 0,r):void 0}const c={url:s,method:s,data:s,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:a,headers:(t,e)=>i(Ct(t),Ct(e),!0)};return M.forEach(Object.keys(Object.assign({},t,e)),(function(n){const s=c[n]||i,o=s(t[n],e[n],n);M.isUndefined(o)&&s!==a||(r[n]=o)})),r}const Dt=t=>{const e=Lt({},t);let r,{data:n,withXSRFToken:i,xsrfHeaderName:s,xsrfCookieName:o,headers:a,auth:c}=e;if(e.headers=a=St.from(a),e.url=rt(Rt(e.baseURL,e.url),t.params,t.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),M.isFormData(n))if(lt.hasStandardBrowserEnv||lt.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(!1!==(r=a.getContentType())){const[t,...e]=r?r.split(";").map((t=>t.trim())).filter(Boolean):[];a.setContentType([t||"multipart/form-data",...e].join("; "))}if(lt.hasStandardBrowserEnv&&(i&&M.isFunction(i)&&(i=i(e)),i||!1!==i&&At(e.url))){const t=s&&o&&jt.read(o);t&&a.set(s,t)}return e},Pt="undefined"!=typeof XMLHttpRequest&&function(t){return new Promise((function(e,r){const n=Dt(t);let i=n.data;const s=St.from(n.headers).normalize();let o,{responseType:a}=n;function c(){n.cancelToken&&n.cancelToken.unsubscribe(o),n.signal&&n.signal.removeEventListener("abort",o)}let u=new XMLHttpRequest;function h(){if(!u)return;const n=St.from("getAllResponseHeaders"in u&&u.getAllResponseHeaders());xt((function(t){e(t),c()}),(function(t){r(t),c()}),{data:a&&"text"!==a&&"json"!==a?u.response:u.responseText,status:u.status,statusText:u.statusText,headers:n,config:t,request:u}),u=null}u.open(n.method.toUpperCase(),n.url,!0),u.timeout=n.timeout,"onloadend"in u?u.onloadend=h:u.onreadystatechange=function(){u&&4===u.readyState&&(0!==u.status||u.responseURL&&0===u.responseURL.indexOf("file:"))&&setTimeout(h)},u.onabort=function(){u&&(r(new H("Request aborted",H.ECONNABORTED,n,u)),u=null)},u.onerror=function(){r(new H("Network Error",H.ERR_NETWORK,n,u)),u=null},u.ontimeout=function(){let t=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const e=n.transitional||it;n.timeoutErrorMessage&&(t=n.timeoutErrorMessage),r(new H(t,e.clarifyTimeoutError?H.ETIMEDOUT:H.ECONNABORTED,n,u)),u=null},void 0===i&&s.setContentType(null),"setRequestHeader"in u&&M.forEach(s.toJSON(),(function(t,e){u.setRequestHeader(e,t)})),M.isUndefined(n.withCredentials)||(u.withCredentials=!!n.withCredentials),a&&"json"!==a&&(u.responseType=n.responseType),"function"==typeof n.onDownloadProgress&&u.addEventListener("progress",Tt(n.onDownloadProgress,!0)),"function"==typeof n.onUploadProgress&&u.upload&&u.upload.addEventListener("progress",Tt(n.onUploadProgress)),(n.cancelToken||n.signal)&&(o=e=>{u&&(r(!e||e.type?new kt(null,t,u):e),u.abort(),u=null)},n.cancelToken&&n.cancelToken.subscribe(o),n.signal&&(n.signal.aborted?o():n.signal.addEventListener("abort",o)));const l=function(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}(n.url);l&&-1===lt.protocols.indexOf(l)?r(new H("Unsupported protocol "+l+":",H.ERR_BAD_REQUEST,t)):u.send(i||null)}))},Bt=(t,e)=>{let r,n=new AbortController;const i=function(t){if(!r){r=!0,o();const e=t instanceof Error?t:this.reason;n.abort(e instanceof H?e:new kt(e instanceof Error?e.message:e))}};let s=e&&setTimeout((()=>{i(new H(`timeout ${e} of ms exceeded`,H.ETIMEDOUT))}),e);const o=()=>{t&&(s&&clearTimeout(s),s=null,t.forEach((t=>{t&&(t.removeEventListener?t.removeEventListener("abort",i):t.unsubscribe(i))})),t=null)};t.forEach((t=>t&&t.addEventListener&&t.addEventListener("abort",i)));const{signal:a}=n;return a.unsubscribe=o,[a,()=>{s&&clearTimeout(s),s=null}]},Ft=function*(t,e){let r=t.byteLength;if(!e||r<e)return void(yield t);let n,i=0;for(;i<r;)n=i+e,yield t.slice(i,n),i=n},zt=(t,e,r,n,i)=>{const s=async function*(t,e,r){for await(const n of t)yield*Ft(ArrayBuffer.isView(n)?n:await r(String(n)),e)}(t,e,i);let o=0;return new ReadableStream({type:"bytes",async pull(t){const{done:e,value:i}=await s.next();if(e)return t.close(),void n();let a=i.byteLength;r&&r(o+=a),t.enqueue(new Uint8Array(i))},cancel:t=>(n(t),s.return())},{highWaterMark:2})},Nt=(t,e)=>{const r=null!=t;return n=>setTimeout((()=>e({lengthComputable:r,total:t,loaded:n})))},It="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,Ut=It&&"function"==typeof ReadableStream,Mt=It&&("function"==typeof TextEncoder?(qt=new TextEncoder,t=>qt.encode(t)):async t=>new Uint8Array(await new Response(t).arrayBuffer()));var qt;const Vt=Ut&&(()=>{let t=!1;const e=new Request(lt.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e})(),Wt=Ut&&!!(()=>{try{return M.isReadableStream(new Response("").body)}catch(t){}})(),Ht={stream:Wt&&(t=>t.body)};var $t;It&&($t=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((t=>{!Ht[t]&&(Ht[t]=M.isFunction($t[t])?e=>e[t]():(e,r)=>{throw new H(`Response type '${t}' is not supported`,H.ERR_NOT_SUPPORT,r)})})));const Gt=It&&(async t=>{let{url:e,method:r,data:n,signal:i,cancelToken:s,timeout:o,onDownloadProgress:a,onUploadProgress:c,responseType:u,headers:h,withCredentials:l="same-origin",fetchOptions:f}=Dt(t);u=u?(u+"").toLowerCase():"text";let d,p,[b,y]=i||s||o?Bt([i,s],o):[];const g=()=>{!d&&setTimeout((()=>{b&&b.unsubscribe()})),d=!0};let v;try{if(c&&Vt&&"get"!==r&&"head"!==r&&0!==(v=await(async(t,e)=>{const r=M.toFiniteNumber(t.getContentLength());return null==r?(async t=>null==t?0:M.isBlob(t)?t.size:M.isSpecCompliantForm(t)?(await new Request(t).arrayBuffer()).byteLength:M.isArrayBufferView(t)?t.byteLength:(M.isURLSearchParams(t)&&(t+=""),M.isString(t)?(await Mt(t)).byteLength:void 0))(e):r})(h,n))){let t,r=new Request(e,{method:"POST",body:n,duplex:"half"});M.isFormData(n)&&(t=r.headers.get("content-type"))&&h.setContentType(t),r.body&&(n=zt(r.body,65536,Nt(v,Tt(c)),null,Mt))}M.isString(l)||(l=l?"cors":"omit"),p=new Request(e,{...f,signal:b,method:r.toUpperCase(),headers:h.normalize().toJSON(),body:n,duplex:"half",withCredentials:l});let i=await fetch(p);const s=Wt&&("stream"===u||"response"===u);if(Wt&&(a||s)){const t={};["status","statusText","headers"].forEach((e=>{t[e]=i[e]}));const e=M.toFiniteNumber(i.headers.get("content-length"));i=new Response(zt(i.body,65536,a&&Nt(e,Tt(a,!0)),s&&g,Mt),t)}u=u||"text";let o=await Ht[M.findKey(Ht,u)||"text"](i,t);return!s&&g(),y&&y(),await new Promise(((e,r)=>{xt(e,r,{data:o,headers:St.from(i.headers),status:i.status,statusText:i.statusText,config:t,request:p})}))}catch(e){if(g(),e&&"TypeError"===e.name&&/fetch/i.test(e.message))throw Object.assign(new H("Network Error",H.ERR_NETWORK,t,p),{cause:e.cause||e});throw H.from(e,e&&e.code,t,p)}}),Jt={http:null,xhr:Pt,fetch:Gt};M.forEach(Jt,((t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch(t){}Object.defineProperty(t,"adapterName",{value:e})}}));const Kt=t=>`- ${t}`,Yt=t=>M.isFunction(t)||null===t||!1===t,Xt=t=>{t=M.isArray(t)?t:[t];const{length:e}=t;let r,n;const i={};for(let s=0;s<e;s++){let e;if(r=t[s],n=r,!Yt(r)&&(n=Jt[(e=String(r)).toLowerCase()],void 0===n))throw new H(`Unknown adapter '${e}'`);if(n)break;i[e||"#"+s]=n}if(!n){const t=Object.entries(i).map((([t,e])=>`adapter ${t} `+(!1===e?"is not supported by the environment":"is not available in the build")));let r=e?t.length>1?"since :\n"+t.map(Kt).join("\n"):" "+Kt(t[0]):"as no adapter specified";throw new H("There is no suitable adapter to dispatch the request "+r,"ERR_NOT_SUPPORT")}return n};function Qt(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new kt(null,t)}function Zt(t){return Qt(t),t.headers=St.from(t.headers),t.data=_t.call(t,t.transformRequest),-1!==["post","put","patch"].indexOf(t.method)&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Xt(t.adapter||pt.adapter)(t).then((function(e){return Qt(t),e.data=_t.call(t,t.transformResponse,e),e.headers=St.from(e.headers),e}),(function(e){return Et(e)||(Qt(t),e&&e.response&&(e.response.data=_t.call(t,t.transformResponse,e.response),e.response.headers=St.from(e.response.headers))),Promise.reject(e)}))}const te={};["object","boolean","number","function","string","symbol"].forEach(((t,e)=>{te[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}}));const ee={};te.transitional=function(t,e,r){function n(t,e){return"[Axios v1.7.2] Transitional option '"+t+"'"+e+(r?". "+r:"")}return(r,i,s)=>{if(!1===t)throw new H(n(i," has been removed"+(e?" in "+e:"")),H.ERR_DEPRECATED);return e&&!ee[i]&&(ee[i]=!0,console.warn(n(i," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(r,i,s)}};const re={assertOptions:function(t,e,r){if("object"!=typeof t)throw new H("options must be an object",H.ERR_BAD_OPTION_VALUE);const n=Object.keys(t);let i=n.length;for(;i-- >0;){const s=n[i],o=e[s];if(o){const e=t[s],r=void 0===e||o(e,s,t);if(!0!==r)throw new H("option "+s+" must be "+r,H.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new H("Unknown option "+s,H.ERR_BAD_OPTION)}},validators:te},ne=re.validators;class ie{constructor(t){this.defaults=t,this.interceptors={request:new nt,response:new nt}}async request(t,e){try{return await this._request(t,e)}catch(t){if(t instanceof Error){let e;Error.captureStackTrace?Error.captureStackTrace(e={}):e=new Error;const r=e.stack?e.stack.replace(/^.+\n/,""):"";try{t.stack?r&&!String(t.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(t.stack+="\n"+r):t.stack=r}catch(t){}}throw t}}_request(t,e){"string"==typeof t?(e=e||{}).url=t:e=t||{},e=Lt(this.defaults,e);const{transitional:r,paramsSerializer:n,headers:i}=e;void 0!==r&&re.assertOptions(r,{silentJSONParsing:ne.transitional(ne.boolean),forcedJSONParsing:ne.transitional(ne.boolean),clarifyTimeoutError:ne.transitional(ne.boolean)},!1),null!=n&&(M.isFunction(n)?e.paramsSerializer={serialize:n}:re.assertOptions(n,{encode:ne.function,serialize:ne.function},!0)),e.method=(e.method||this.defaults.method||"get").toLowerCase();let s=i&&M.merge(i.common,i[e.method]);i&&M.forEach(["delete","get","head","post","put","patch","common"],(t=>{delete i[t]})),e.headers=St.concat(s,i);const o=[];let a=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(a=a&&t.synchronous,o.unshift(t.fulfilled,t.rejected))}));const c=[];let u;this.interceptors.response.forEach((function(t){c.push(t.fulfilled,t.rejected)}));let h,l=0;if(!a){const t=[Zt.bind(this),void 0];for(t.unshift.apply(t,o),t.push.apply(t,c),h=t.length,u=Promise.resolve(e);l<h;)u=u.then(t[l++],t[l++]);return u}h=o.length;let f=e;for(l=0;l<h;){const t=o[l++],e=o[l++];try{f=t(f)}catch(t){e.call(this,t);break}}try{u=Zt.call(this,f)}catch(t){return Promise.reject(t)}for(l=0,h=c.length;l<h;)u=u.then(c[l++],c[l++]);return u}getUri(t){return rt(Rt((t=Lt(this.defaults,t)).baseURL,t.url),t.params,t.paramsSerializer)}}M.forEach(["delete","get","head","options"],(function(t){ie.prototype[t]=function(e,r){return this.request(Lt(r||{},{method:t,url:e,data:(r||{}).data}))}})),M.forEach(["post","put","patch"],(function(t){function e(e){return function(r,n,i){return this.request(Lt(i||{},{method:t,headers:e?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}ie.prototype[t]=e(),ie.prototype[t+"Form"]=e(!0)}));const se=ie;class oe{constructor(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");let e;this.promise=new Promise((function(t){e=t}));const r=this;this.promise.then((t=>{if(!r._listeners)return;let e=r._listeners.length;for(;e-- >0;)r._listeners[e](t);r._listeners=null})),this.promise.then=t=>{let e;const n=new Promise((t=>{r.subscribe(t),e=t})).then(t);return n.cancel=function(){r.unsubscribe(e)},n},t((function(t,n,i){r.reason||(r.reason=new kt(t,n,i),e(r.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}static source(){let t;return{token:new oe((function(e){t=e})),cancel:t}}}const ae=oe,ce={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(ce).forEach((([t,e])=>{ce[e]=t}));const ue=ce,he=function t(e){const r=new se(e),n=i(se.prototype.request,r);return M.extend(n,se.prototype,r,{allOwnKeys:!0}),M.extend(n,r,null,{allOwnKeys:!0}),n.create=function(r){return t(Lt(e,r))},n}(pt);he.Axios=se,he.CanceledError=kt,he.CancelToken=ae,he.isCancel=Et,he.VERSION="1.7.2",he.toFormData=Y,he.AxiosError=H,he.Cancel=he.CanceledError,he.all=function(t){return Promise.all(t)},he.spread=function(t){return function(e){return t.apply(null,e)}},he.isAxiosError=function(t){return M.isObject(t)&&!0===t.isAxiosError},he.mergeConfig=Lt,he.AxiosHeaders=St,he.formToJSON=t=>ft(M.isHTMLForm(t)?new FormData(t):t),he.getAdapter=Xt,he.HttpStatusCode=ue,he.default=he;const le=he;class fe{interceptor;constructor(t){this.interceptor=le.create({baseURL:`${t}/api`}),this.interceptor.interceptors.request.use((t=>{const e=le.CancelToken.source();return t.cancelToken=e.token,setTimeout((()=>{e.cancel("Timeout: request took more than 15 seconds")}),15e3),t}),(t=>Promise.reject(t)))}}var de=r(275),pe=r.n(de),be=r(512),ye=r.n(be);const ge="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,ve=new Set,me="object"==typeof process&&process?process:{},we=(t,e,r,n)=>{"function"==typeof me.emitWarning?me.emitWarning(t,e,r,n):console.error(`[${r}] ${e}: ${t}`)};let Se=globalThis.AbortController,_e=globalThis.AbortSignal;if(void 0===Se){_e=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},Se=class{constructor(){e()}signal=new _e;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==me.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,we("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}Symbol("type");const Ee=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),Oe=t=>Ee(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?ke:null:null;class ke extends Array{constructor(t){super(t),this.fill(0)}}class xe{heap;length;static#t=!1;static create(t){const e=Oe(t);if(!e)return[];xe.#t=!0;const r=new xe(t,e);return xe.#t=!1,r}constructor(t,e){if(!xe.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}}class Te{#e;#r;#n;#i;#s;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#o;#a;#c;#u;#h;#l;#f;#d;#p;#b;#y;#g;#v;#m;#w;#S;#_;static unsafeExposeInternals(t){return{starts:t.#v,ttls:t.#m,sizes:t.#g,keyMap:t.#c,keyList:t.#u,valList:t.#h,next:t.#l,prev:t.#f,get head(){return t.#d},get tail(){return t.#p},free:t.#b,isBackgroundFetch:e=>t.#E(e),backgroundFetch:(e,r,n,i)=>t.#O(e,r,n,i),moveToTail:e=>t.#k(e),indexes:e=>t.#x(e),rindexes:e=>t.#T(e),isStale:e=>t.#A(e)}}get max(){return this.#e}get maxSize(){return this.#r}get calculatedSize(){return this.#a}get size(){return this.#o}get fetchMethod(){return this.#s}get dispose(){return this.#n}get disposeAfter(){return this.#i}constructor(t){const{max:e=0,ttl:r,ttlResolution:n=1,ttlAutopurge:i,updateAgeOnGet:s,updateAgeOnHas:o,allowStale:a,dispose:c,disposeAfter:u,noDisposeOnSet:h,noUpdateTTL:l,maxSize:f=0,maxEntrySize:d=0,sizeCalculation:p,fetchMethod:b,noDeleteOnFetchRejection:y,noDeleteOnStaleGet:g,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:m,ignoreFetchAbort:w}=t;if(0!==e&&!Ee(e))throw new TypeError("max option must be a nonnegative integer");const S=e?Oe(e):Array;if(!S)throw new Error("invalid max value: "+e);if(this.#e=e,this.#r=f,this.maxEntrySize=d||this.#r,this.sizeCalculation=p,this.sizeCalculation){if(!this.#r&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==b&&"function"!=typeof b)throw new TypeError("fetchMethod must be a function if specified");if(this.#s=b,this.#S=!!b,this.#c=new Map,this.#u=new Array(e).fill(void 0),this.#h=new Array(e).fill(void 0),this.#l=new S(e),this.#f=new S(e),this.#d=0,this.#p=0,this.#b=xe.create(e),this.#o=0,this.#a=0,"function"==typeof c&&(this.#n=c),"function"==typeof u?(this.#i=u,this.#y=[]):(this.#i=void 0,this.#y=void 0),this.#w=!!this.#n,this.#_=!!this.#i,this.noDisposeOnSet=!!h,this.noUpdateTTL=!!l,this.noDeleteOnFetchRejection=!!y,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!m,this.ignoreFetchAbort=!!w,0!==this.maxEntrySize){if(0!==this.#r&&!Ee(this.#r))throw new TypeError("maxSize must be a positive integer if specified");if(!Ee(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#j()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!g,this.updateAgeOnGet=!!s,this.updateAgeOnHas=!!o,this.ttlResolution=Ee(n)||0===n?n:1,this.ttlAutopurge=!!i,this.ttl=r||0,this.ttl){if(!Ee(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#R()}if(0===this.#e&&0===this.ttl&&0===this.#r)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#r){const t="LRU_CACHE_UNBOUNDED";(t=>!ve.has(t))(t)&&(ve.add(t),we("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,Te))}}getRemainingTTL(t){return this.#c.has(t)?1/0:0}#R(){const t=new ke(this.#e),e=new ke(this.#e);this.#m=t,this.#v=e,this.#C=(r,n,i=ge.now())=>{if(e[r]=0!==n?i:0,t[r]=n,0!==n&&this.ttlAutopurge){const t=setTimeout((()=>{this.#A(r)&&this.delete(this.#u[r])}),n+1);t.unref&&t.unref()}},this.#L=r=>{e[r]=0!==t[r]?ge.now():0},this.#D=(i,s)=>{if(t[s]){const o=t[s],a=e[s];if(!o||!a)return;i.ttl=o,i.start=a,i.now=r||n();const c=i.now-a;i.remainingTTL=o-c}};let r=0;const n=()=>{const t=ge.now();if(this.ttlResolution>0){r=t;const e=setTimeout((()=>r=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=i=>{const s=this.#c.get(i);if(void 0===s)return 0;const o=t[s],a=e[s];return o&&a?o-((r||n())-a):1/0},this.#A=i=>{const s=e[i],o=t[i];return!!o&&!!s&&(r||n())-s>o}}#L=()=>{};#D=()=>{};#C=()=>{};#A=()=>!1;#j(){const t=new ke(this.#e);this.#a=0,this.#g=t,this.#P=e=>{this.#a-=t[e],t[e]=0},this.#B=(t,e,r,n)=>{if(this.#E(e))return 0;if(!Ee(r)){if(!n)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof n)throw new TypeError("sizeCalculation must be a function");if(r=n(e,t),!Ee(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return r},this.#F=(e,r,n)=>{if(t[e]=r,this.#r){const r=this.#r-t[e];for(;this.#a>r;)this.#z(!0)}this.#a+=t[e],n&&(n.entrySize=r,n.totalCalculatedSize=this.#a)}}#P=t=>{};#F=(t,e,r)=>{};#B=(t,e,r,n)=>{if(r||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#x({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#p;this.#N(e)&&(!t&&this.#A(e)||(yield e),e!==this.#d);)e=this.#f[e]}*#T({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#d;this.#N(e)&&(!t&&this.#A(e)||(yield e),e!==this.#p);)e=this.#l[e]}#N(t){return void 0!==t&&this.#c.get(this.#u[t])===t}*entries(){for(const t of this.#x())void 0===this.#h[t]||void 0===this.#u[t]||this.#E(this.#h[t])||(yield[this.#u[t],this.#h[t]])}*rentries(){for(const t of this.#T())void 0===this.#h[t]||void 0===this.#u[t]||this.#E(this.#h[t])||(yield[this.#u[t],this.#h[t]])}*keys(){for(const t of this.#x()){const e=this.#u[t];void 0===e||this.#E(this.#h[t])||(yield e)}}*rkeys(){for(const t of this.#T()){const e=this.#u[t];void 0===e||this.#E(this.#h[t])||(yield e)}}*values(){for(const t of this.#x())void 0===this.#h[t]||this.#E(this.#h[t])||(yield this.#h[t])}*rvalues(){for(const t of this.#T())void 0===this.#h[t]||this.#E(this.#h[t])||(yield this.#h[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(const r of this.#x()){const n=this.#h[r],i=this.#E(n)?n.__staleWhileFetching:n;if(void 0!==i&&t(i,this.#u[r],this))return this.get(this.#u[r],e)}}forEach(t,e=this){for(const r of this.#x()){const n=this.#h[r],i=this.#E(n)?n.__staleWhileFetching:n;void 0!==i&&t.call(e,i,this.#u[r],this)}}rforEach(t,e=this){for(const r of this.#T()){const n=this.#h[r],i=this.#E(n)?n.__staleWhileFetching:n;void 0!==i&&t.call(e,i,this.#u[r],this)}}purgeStale(){let t=!1;for(const e of this.#T({allowStale:!0}))this.#A(e)&&(this.delete(this.#u[e]),t=!0);return t}info(t){const e=this.#c.get(t);if(void 0===e)return;const r=this.#h[e],n=this.#E(r)?r.__staleWhileFetching:r;if(void 0===n)return;const i={value:n};if(this.#m&&this.#v){const t=this.#m[e],r=this.#v[e];if(t&&r){const e=t-(ge.now()-r);i.ttl=e,i.start=Date.now()}}return this.#g&&(i.size=this.#g[e]),i}dump(){const t=[];for(const e of this.#x({allowStale:!0})){const r=this.#u[e],n=this.#h[e],i=this.#E(n)?n.__staleWhileFetching:n;if(void 0===i||void 0===r)continue;const s={value:i};if(this.#m&&this.#v){s.ttl=this.#m[e];const t=ge.now()-this.#v[e];s.start=Math.floor(Date.now()-t)}this.#g&&(s.size=this.#g[e]),t.unshift([r,s])}return t}load(t){this.clear();for(const[e,r]of t){if(r.start){const t=Date.now()-r.start;r.start=ge.now()-t}this.set(e,r.value,r)}}set(t,e,r={}){if(void 0===e)return this.delete(t),this;const{ttl:n=this.ttl,start:i,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:a}=r;let{noUpdateTTL:c=this.noUpdateTTL}=r;const u=this.#B(t,e,r.size||0,o);if(this.maxEntrySize&&u>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.delete(t),this;let h=0===this.#o?void 0:this.#c.get(t);if(void 0===h)h=0===this.#o?this.#p:0!==this.#b.length?this.#b.pop():this.#o===this.#e?this.#z(!1):this.#o,this.#u[h]=t,this.#h[h]=e,this.#c.set(t,h),this.#l[this.#p]=h,this.#f[h]=this.#p,this.#p=h,this.#o++,this.#F(h,u,a),a&&(a.set="add"),c=!1;else{this.#k(h);const r=this.#h[h];if(e!==r){if(this.#S&&this.#E(r)){r.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=r;void 0===e||s||(this.#w&&this.#n?.(e,t,"set"),this.#_&&this.#y?.push([e,t,"set"]))}else s||(this.#w&&this.#n?.(r,t,"set"),this.#_&&this.#y?.push([r,t,"set"]));if(this.#P(h),this.#F(h,u,a),this.#h[h]=e,a){a.set="replace";const t=r&&this.#E(r)?r.__staleWhileFetching:r;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===n||this.#m||this.#R(),this.#m&&(c||this.#C(h,n,i),a&&this.#D(a,h)),!s&&this.#_&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#i?.(...e)}return this}pop(){try{for(;this.#o;){const t=this.#h[this.#d];if(this.#z(!0),this.#E(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#_&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#i?.(...e)}}}#z(t){const e=this.#d,r=this.#u[e],n=this.#h[e];return this.#S&&this.#E(n)?n.__abortController.abort(new Error("evicted")):(this.#w||this.#_)&&(this.#w&&this.#n?.(n,r,"evict"),this.#_&&this.#y?.push([n,r,"evict"])),this.#P(e),t&&(this.#u[e]=void 0,this.#h[e]=void 0,this.#b.push(e)),1===this.#o?(this.#d=this.#p=0,this.#b.length=0):this.#d=this.#l[e],this.#c.delete(r),this.#o--,e}has(t,e={}){const{updateAgeOnHas:r=this.updateAgeOnHas,status:n}=e,i=this.#c.get(t);if(void 0!==i){const t=this.#h[i];if(this.#E(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#A(i))return r&&this.#L(i),n&&(n.has="hit",this.#D(n,i)),!0;n&&(n.has="stale",this.#D(n,i))}else n&&(n.has="miss");return!1}peek(t,e={}){const{allowStale:r=this.allowStale}=e,n=this.#c.get(t);if(void 0===n||!r&&this.#A(n))return;const i=this.#h[n];return this.#E(i)?i.__staleWhileFetching:i}#O(t,e,r,n){const i=void 0===e?void 0:this.#h[e];if(this.#E(i))return i;const s=new Se,{signal:o}=r;o?.addEventListener("abort",(()=>s.abort(o.reason)),{signal:s.signal});const a={signal:s.signal,options:r,context:n},c=(n,i=!1)=>{const{aborted:o}=s.signal,c=r.ignoreFetchAbort&&void 0!==n;if(r.status&&(o&&!i?(r.status.fetchAborted=!0,r.status.fetchError=s.signal.reason,c&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),o&&!c&&!i)return u(s.signal.reason);const l=h;return this.#h[e]===h&&(void 0===n?l.__staleWhileFetching?this.#h[e]=l.__staleWhileFetching:this.delete(t):(r.status&&(r.status.fetchUpdated=!0),this.set(t,n,a.options))),n},u=n=>{const{aborted:i}=s.signal,o=i&&r.allowStaleOnFetchAbort,a=o||r.allowStaleOnFetchRejection,c=a||r.noDeleteOnFetchRejection,u=h;if(this.#h[e]===h&&(c&&void 0!==u.__staleWhileFetching?o||(this.#h[e]=u.__staleWhileFetching):this.delete(t)),a)return r.status&&void 0!==u.__staleWhileFetching&&(r.status.returnedStale=!0),u.__staleWhileFetching;if(u.__returned===u)throw n};r.status&&(r.status.fetchDispatched=!0);const h=new Promise(((e,n)=>{const o=this.#s?.(t,i,a);o&&o instanceof Promise&&o.then((t=>e(void 0===t?void 0:t)),n),s.signal.addEventListener("abort",(()=>{r.ignoreFetchAbort&&!r.allowStaleOnFetchAbort||(e(void 0),r.allowStaleOnFetchAbort&&(e=t=>c(t,!0)))}))})).then(c,(t=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=t),u(t)))),l=Object.assign(h,{__abortController:s,__staleWhileFetching:i,__returned:void 0});return void 0===e?(this.set(t,l,{...a.options,status:void 0}),e=this.#c.get(t)):this.#h[e]=l,l}#E(t){if(!this.#S)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof Se}async fetch(t,e={}){const{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:a=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:h=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:l=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:d=this.allowStaleOnFetchAbort,context:p,forceRefresh:b=!1,status:y,signal:g}=e;if(!this.#S)return y&&(y.fetch="get"),this.get(t,{allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:i,status:y});const v={allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:i,ttl:s,noDisposeOnSet:o,size:a,sizeCalculation:c,noUpdateTTL:u,noDeleteOnFetchRejection:h,allowStaleOnFetchRejection:l,allowStaleOnFetchAbort:d,ignoreFetchAbort:f,status:y,signal:g};let m=this.#c.get(t);if(void 0===m){y&&(y.fetch="miss");const e=this.#O(t,m,v,p);return e.__returned=e}{const e=this.#h[m];if(this.#E(e)){const t=r&&void 0!==e.__staleWhileFetching;return y&&(y.fetch="inflight",t&&(y.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const i=this.#A(m);if(!b&&!i)return y&&(y.fetch="hit"),this.#k(m),n&&this.#L(m),y&&this.#D(y,m),e;const s=this.#O(t,m,v,p),o=void 0!==s.__staleWhileFetching&&r;return y&&(y.fetch=i?"stale":"refresh",o&&i&&(y.returnedStale=!0)),o?s.__staleWhileFetching:s.__returned=s}}get(t,e={}){const{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:s}=e,o=this.#c.get(t);if(void 0!==o){const e=this.#h[o],a=this.#E(e);return s&&this.#D(s,o),this.#A(o)?(s&&(s.get="stale"),a?(s&&r&&void 0!==e.__staleWhileFetching&&(s.returnedStale=!0),r?e.__staleWhileFetching:void 0):(i||this.delete(t),s&&r&&(s.returnedStale=!0),r?e:void 0)):(s&&(s.get="hit"),a?e.__staleWhileFetching:(this.#k(o),n&&this.#L(o),e))}s&&(s.get="miss")}#I(t,e){this.#f[e]=t,this.#l[t]=e}#k(t){t!==this.#p&&(t===this.#d?this.#d=this.#l[t]:this.#I(this.#f[t],this.#l[t]),this.#I(this.#p,t),this.#p=t)}delete(t){let e=!1;if(0!==this.#o){const r=this.#c.get(t);if(void 0!==r)if(e=!0,1===this.#o)this.clear();else{this.#P(r);const e=this.#h[r];if(this.#E(e)?e.__abortController.abort(new Error("deleted")):(this.#w||this.#_)&&(this.#w&&this.#n?.(e,t,"delete"),this.#_&&this.#y?.push([e,t,"delete"])),this.#c.delete(t),this.#u[r]=void 0,this.#h[r]=void 0,r===this.#p)this.#p=this.#f[r];else if(r===this.#d)this.#d=this.#l[r];else{const t=this.#f[r];this.#l[t]=this.#l[r];const e=this.#l[r];this.#f[e]=this.#f[r]}this.#o--,this.#b.push(r)}}if(this.#_&&this.#y?.length){const t=this.#y;let e;for(;e=t?.shift();)this.#i?.(...e)}return e}clear(){for(const t of this.#T({allowStale:!0})){const e=this.#h[t];if(this.#E(e))e.__abortController.abort(new Error("deleted"));else{const r=this.#u[t];this.#w&&this.#n?.(e,r,"delete"),this.#_&&this.#y?.push([e,r,"delete"])}}if(this.#c.clear(),this.#h.fill(void 0),this.#u.fill(void 0),this.#m&&this.#v&&(this.#m.fill(0),this.#v.fill(0)),this.#g&&this.#g.fill(0),this.#d=0,this.#p=0,this.#b.length=0,this.#a=0,this.#o=0,this.#_&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#i?.(...e)}}}var Ae=function(t,e){return Ae=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},Ae(t,e)};function je(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}Ae(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function Re(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function Ce(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Le(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,s=r.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return o}function De(t,e,r){if(r||2===arguments.length)for(var n,i=0,s=e.length;i<s;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}function Pe(t){return this instanceof Pe?(this.v=t,this):new Pe(t)}function Be(t){return"function"==typeof t}function Fe(t){var e=t((function(t){Error.call(t),t.stack=(new Error).stack}));return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var ze=Fe((function(t){return function(e){t(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map((function(t,e){return e+1+") "+t.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=e}}));function Ne(t,e){if(t){var r=t.indexOf(e);0<=r&&t.splice(r,1)}}var Ie=function(){function t(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var t,e,r,n,i;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var o=Ce(s),a=o.next();!a.done;a=o.next())a.value.remove(this)}catch(e){t={error:e}}finally{try{a&&!a.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}else s.remove(this);var c=this.initialTeardown;if(Be(c))try{c()}catch(t){i=t instanceof ze?t.errors:[t]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var h=Ce(u),l=h.next();!l.done;l=h.next()){var f=l.value;try{qe(f)}catch(t){i=null!=i?i:[],t instanceof ze?i=De(De([],Le(i)),Le(t.errors)):i.push(t)}}}catch(t){r={error:t}}finally{try{l&&!l.done&&(n=h.return)&&n.call(h)}finally{if(r)throw r.error}}}if(i)throw new ze(i)}},t.prototype.add=function(e){var r;if(e&&e!==this)if(this.closed)qe(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(e)}},t.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},t.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},t.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&Ne(e,t)},t.prototype.remove=function(e){var r=this._finalizers;r&&Ne(r,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}(),Ue=Ie.EMPTY;function Me(t){return t instanceof Ie||t&&"closed"in t&&Be(t.remove)&&Be(t.add)&&Be(t.unsubscribe)}function qe(t){Be(t)?t():t.unsubscribe()}var Ve={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},We={setTimeout:function(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var i=We.delegate;return(null==i?void 0:i.setTimeout)?i.setTimeout.apply(i,De([t,e],Le(r))):setTimeout.apply(void 0,De([t,e],Le(r)))},clearTimeout:function(t){var e=We.delegate;return((null==e?void 0:e.clearTimeout)||clearTimeout)(t)},delegate:void 0};function He(t){We.setTimeout((function(){var e=Ve.onUnhandledError;if(!e)throw t;e(t)}))}function $e(){}var Ge=Je("C",void 0,void 0);function Je(t,e,r){return{kind:t,value:e,error:r}}var Ke=null;function Ye(t){if(Ve.useDeprecatedSynchronousErrorHandling){var e=!Ke;if(e&&(Ke={errorThrown:!1,error:null}),t(),e){var r=Ke,n=r.errorThrown,i=r.error;if(Ke=null,n)throw i}}else t()}var Xe=function(t){function e(e){var r=t.call(this)||this;return r.isStopped=!1,e?(r.destination=e,Me(e)&&e.add(r)):r.destination=ir,r}return je(e,t),e.create=function(t,e,r){return new er(t,e,r)},e.prototype.next=function(t){this.isStopped?nr(function(t){return Je("N",t,void 0)}(t),this):this._next(t)},e.prototype.error=function(t){this.isStopped?nr(Je("E",void 0,t),this):(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped?nr(Ge,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(Ie),Qe=Function.prototype.bind;function Ze(t,e){return Qe.call(t,e)}var tr=function(){function t(t){this.partialObserver=t}return t.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(t){rr(t)}},t.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(t){rr(t)}else rr(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){rr(t)}},t}(),er=function(t){function e(e,r,n){var i,s,o=t.call(this)||this;return Be(e)||!e?i={next:null!=e?e:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:o&&Ve.useDeprecatedNextContext?((s=Object.create(e)).unsubscribe=function(){return o.unsubscribe()},i={next:e.next&&Ze(e.next,s),error:e.error&&Ze(e.error,s),complete:e.complete&&Ze(e.complete,s)}):i=e,o.destination=new tr(i),o}return je(e,t),e}(Xe);function rr(t){var e;Ve.useDeprecatedSynchronousErrorHandling?(e=t,Ve.useDeprecatedSynchronousErrorHandling&&Ke&&(Ke.errorThrown=!0,Ke.error=e)):He(t)}function nr(t,e){var r=Ve.onStoppedNotification;r&&We.setTimeout((function(){return r(t,e)}))}var ir={closed:!0,next:$e,error:function(t){throw t},complete:$e},sr="function"==typeof Symbol&&Symbol.observable||"@@observable";function or(t){return t}var ar=function(){function t(t){t&&(this._subscribe=t)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(t,e,r){var n=this,i=function(t){return t&&t instanceof Xe||function(t){return t&&Be(t.next)&&Be(t.error)&&Be(t.complete)}(t)&&Me(t)}(t)?t:new er(t,e,r);return Ye((function(){var t=n,e=t.operator,r=t.source;i.add(e?e.call(i,r):r?n._subscribe(i):n._trySubscribe(i))})),i},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},t.prototype.forEach=function(t,e){var r=this;return new(e=cr(e))((function(e,n){var i=new er({next:function(e){try{t(e)}catch(t){n(t),i.unsubscribe()}},error:n,complete:e});r.subscribe(i)}))},t.prototype._subscribe=function(t){var e;return null===(e=this.source)||void 0===e?void 0:e.subscribe(t)},t.prototype[sr]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return(0===(r=t).length?or:1===r.length?r[0]:function(t){return r.reduce((function(t,e){return e(t)}),t)})(this);var r},t.prototype.toPromise=function(t){var e=this;return new(t=cr(t))((function(t,r){var n;e.subscribe((function(t){return n=t}),(function(t){return r(t)}),(function(){return t(n)}))}))},t.create=function(e){return new t(e)},t}();function cr(t){var e;return null!==(e=null!=t?t:Ve.Promise)&&void 0!==e?e:Promise}var ur=Fe((function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),hr=function(t){function e(){var e=t.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return je(e,t),e.prototype.lift=function(t){var e=new lr(this,this);return e.operator=t,e},e.prototype._throwIfClosed=function(){if(this.closed)throw new ur},e.prototype.next=function(t){var e=this;Ye((function(){var r,n;if(e._throwIfClosed(),!e.isStopped){e.currentObservers||(e.currentObservers=Array.from(e.observers));try{for(var i=Ce(e.currentObservers),s=i.next();!s.done;s=i.next())s.value.next(t)}catch(t){r={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}}}))},e.prototype.error=function(t){var e=this;Ye((function(){if(e._throwIfClosed(),!e.isStopped){e.hasError=e.isStopped=!0,e.thrownError=t;for(var r=e.observers;r.length;)r.shift().error(t)}}))},e.prototype.complete=function(){var t=this;Ye((function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var e=t.observers;e.length;)e.shift().complete()}}))},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var e=this,r=this,n=r.hasError,i=r.isStopped,s=r.observers;return n||i?Ue:(this.currentObservers=null,s.push(t),new Ie((function(){e.currentObservers=null,Ne(s,t)})))},e.prototype._checkFinalizedStatuses=function(t){var e=this,r=e.hasError,n=e.thrownError,i=e.isStopped;r?t.error(n):i&&t.complete()},e.prototype.asObservable=function(){var t=new ar;return t.source=this,t},e.create=function(t,e){return new lr(t,e)},e}(ar),lr=function(t){function e(e,r){var n=t.call(this)||this;return n.destination=e,n.source=r,n}return je(e,t),e.prototype.next=function(t){var e,r;null===(r=null===(e=this.destination)||void 0===e?void 0:e.next)||void 0===r||r.call(e,t)},e.prototype.error=function(t){var e,r;null===(r=null===(e=this.destination)||void 0===e?void 0:e.error)||void 0===r||r.call(e,t)},e.prototype.complete=function(){var t,e;null===(e=null===(t=this.destination)||void 0===t?void 0:t.complete)||void 0===e||e.call(t)},e.prototype._subscribe=function(t){var e,r;return null!==(r=null===(e=this.source)||void 0===e?void 0:e.subscribe(t))&&void 0!==r?r:Ue},e}(hr),fr=function(t){function e(e){var r=t.call(this)||this;return r._value=e,r}return je(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(e){var r=t.prototype._subscribe.call(this,e);return!r.closed&&e.next(this._value),r},e.prototype.getValue=function(){var t=this,e=t.hasError,r=t.thrownError,n=t._value;if(e)throw r;return this._throwIfClosed(),n},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},e}(hr),dr={now:function(){return(dr.delegate||Date).now()},delegate:void 0},pr=function(t){function e(e,r,n){void 0===e&&(e=1/0),void 0===r&&(r=1/0),void 0===n&&(n=dr);var i=t.call(this)||this;return i._bufferSize=e,i._windowTime=r,i._timestampProvider=n,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=r===1/0,i._bufferSize=Math.max(1,e),i._windowTime=Math.max(1,r),i}return je(e,t),e.prototype.next=function(e){var r=this,n=r.isStopped,i=r._buffer,s=r._infiniteTimeWindow,o=r._timestampProvider,a=r._windowTime;n||(i.push(e),!s&&i.push(o.now()+a)),this._trimBuffer(),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var e=this._innerSubscribe(t),r=this._infiniteTimeWindow,n=this._buffer.slice(),i=0;i<n.length&&!t.closed;i+=r?1:2)t.next(n[i]);return this._checkFinalizedStatuses(t),e},e.prototype._trimBuffer=function(){var t=this,e=t._bufferSize,r=t._timestampProvider,n=t._buffer,i=t._infiniteTimeWindow,s=(i?1:2)*e;if(e<1/0&&s<n.length&&n.splice(0,n.length-s),!i){for(var o=r.now(),a=0,c=1;c<n.length&&n[c]<=o;c+=2)a=c;a&&n.splice(0,a+1)}},e}(hr);function br(t){return function(e){if(function(t){return Be(null==t?void 0:t.lift)}(e))return e.lift((function(e){try{return t(e,this)}catch(t){this.error(t)}}));throw new TypeError("Unable to lift unknown Observable type")}}function yr(t,e,r,n,i){return new gr(t,e,r,n,i)}var gr=function(t){function e(e,r,n,i,s,o){var a=t.call(this,e)||this;return a.onFinalize=s,a.shouldUnsubscribe=o,a._next=r?function(t){try{r(t)}catch(t){e.error(t)}}:t.prototype._next,a._error=i?function(t){try{i(t)}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._error,a._complete=n?function(){try{n()}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._complete,a}return je(e,t),e.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&(null===(e=this.onFinalize)||void 0===e||e.call(this))}},e}(Xe);function vr(){return br((function(t,e){var r,n=!1;t.subscribe(yr(e,(function(t){var i=r;r=t,n&&e.next([i,t]),n=!0})))}))}function mr(t,e){return br((function(r,n){var i=0;r.subscribe(yr(n,(function(r){return t.call(e,r,i++)&&n.next(r)})))}))}function wr(t,e){return br((function(r,n){var i=0;r.subscribe(yr(n,(function(r){n.next(t.call(e,r,i++))})))}))}var Sr=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t},_r="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function Er(t){if(t instanceof ar)return t;if(null!=t){if(function(t){return Be(t[sr])}(t))return i=t,new ar((function(t){var e=i[sr]();if(Be(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(Sr(t))return n=t,new ar((function(t){for(var e=0;e<n.length&&!t.closed;e++)t.next(n[e]);t.complete()}));if(function(t){return Be(null==t?void 0:t.then)}(t))return r=t,new ar((function(t){r.then((function(e){t.closed||(t.next(e),t.complete())}),(function(e){return t.error(e)})).then(null,He)}));if(function(t){return Symbol.asyncIterator&&Be(null==t?void 0:t[Symbol.asyncIterator])}(t))return Or(t);if(function(t){return Be(null==t?void 0:t[_r])}(t))return e=t,new ar((function(t){var r,n;try{for(var i=Ce(e),s=i.next();!s.done;s=i.next()){var o=s.value;if(t.next(o),t.closed)return}}catch(t){r={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}t.complete()}));if(function(t){return Be(null==t?void 0:t.getReader)}(t))return Or(function(t){return function(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(t,e||[]),s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(t){i[t]&&(n[t]=function(e){return new Promise((function(r,n){s.push([t,e,r,n])>1||a(t,e)}))})}function a(t,e){try{(r=i[t](e)).value instanceof Pe?Promise.resolve(r.value.v).then(c,u):h(s[0][2],r)}catch(t){h(s[0][3],t)}var r}function c(t){a("next",t)}function u(t){a("throw",t)}function h(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}}(this,arguments,(function(){var e,r,n;return Re(this,(function(i){switch(i.label){case 0:e=t.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,Pe(e.read())];case 3:return r=i.sent(),n=r.value,r.done?[4,Pe(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,Pe(n)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}}))}))}(t))}var e,r,n,i;throw function(t){return new TypeError("You provided "+(null!==t&&"object"==typeof t?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}(t)}function Or(t){return new ar((function(e){(function(t,e){var r,n,i,s,o,a,c,u;return o=this,a=void 0,u=function(){var o,a;return Re(this,(function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),r=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=Ce(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,i){!function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)}(n,i,(e=t[r](e)).done,e.value)}))}}}(t),c.label=1;case 1:return[4,r.next()];case 2:if((n=c.sent()).done)return[3,4];if(o=n.value,e.next(o),e.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),i={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),n&&!n.done&&(s=r.return)?[4,s.call(r)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}}))},new((c=void 0)||(c=Promise))((function(t,e){function r(t){try{i(u.next(t))}catch(t){e(t)}}function n(t){try{i(u.throw(t))}catch(t){e(t)}}function i(e){e.done?t(e.value):function(t){return t instanceof c?t:new c((function(e){e(t)}))}(e.value).then(r,n)}i((u=u.apply(o,a||[])).next())}))})(t,e).catch((function(t){return e.error(t)}))}))}function kr(t){void 0===t&&(t={});var e=t.connector,r=void 0===e?function(){return new hr}:e,n=t.resetOnError,i=void 0===n||n,s=t.resetOnComplete,o=void 0===s||s,a=t.resetOnRefCountZero,c=void 0===a||a;return function(t){var e,n,s,a=0,u=!1,h=!1,l=function(){null==n||n.unsubscribe(),n=void 0},f=function(){l(),e=s=void 0,u=h=!1},d=function(){var t=e;f(),null==t||t.unsubscribe()};return br((function(t,p){a++,h||u||l();var b=s=null!=s?s:r();p.add((function(){0!=--a||h||u||(n=xr(d,c))})),b.subscribe(p),!e&&a>0&&(e=new er({next:function(t){return b.next(t)},error:function(t){h=!0,l(),n=xr(f,i,t),b.error(t)},complete:function(){u=!0,l(),n=xr(f,o),b.complete()}}),Er(t).subscribe(e))}))(t)}}function xr(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];if(!0!==e){if(!1!==e){var i=new er({next:function(){i.unsubscribe(),t()}});return Er(e.apply(void 0,De([],Le(r)))).subscribe(i)}}else t()}function Tr(t,e){return t===e}const Ar=(t,e)=>{const{origWidth:r,origHeight:n}=e,i=t.points.map((([t,e])=>[t*r/100,e*n/100]));return{...t,points:i}},jr=t=>{const{origWidth:e,origHeight:r,inputWidth:n,inputHeight:i}=t,[s,o,a,c]=t.boundingBox,u=s*e/n,h=o*r/i,l=a*e/n,f=c*r/i;return{...t,boundingBox:[u,h,l,f]}},Rr=(t,e)=>{const[r,n,i,s]=t.boundingBox,o={xmin:r,ymin:n,xmax:i,ymax:s};let a=!1;for(const r of e){const e=Ar(r,t);if(e.isPrivacyMask){if(Lr(o,e.points)){a=!1;break}}else"include"===e.filter?"contain"===e.type?Lr(o,e.points)&&(a=!0):"intersect"===e.type&&(Cr(o,e.points)||Lr(o,e.points))&&(a=!0):"exclude"===e.filter&&("contain"===e.type?Lr(o,e.points)||(a=!0):"intersect"===e.type&&(Cr(o,e.points)||Lr(o,e.points)||(a=!0)))}return a},Cr=(t,e)=>{const r=Dr(t);for(const t of r)for(let r=0;r<e.length;r++){const n=[e[r],e[(r+1)%e.length]];if(Pr(t,n))return!0}return!1},Lr=(t,e)=>[[t.xmin,t.ymin],[t.xmax,t.ymin],[t.xmax,t.ymax],[t.xmin,t.ymax]].every((t=>Br(t,e))),Dr=t=>{const{xmin:e,ymin:r,xmax:n,ymax:i}=t;return[[[e,r],[n,r]],[[n,r],[n,i]],[[n,i],[e,i]],[[e,i],[e,r]]]},Pr=(t,e)=>{const r=(t,e,r)=>(r[1]-t[1])*(e[0]-t[0])>(e[1]-t[1])*(r[0]-t[0]);return n=t[0],i=t[1],r(n,s=e[0],o=e[1])!==r(i,s,o)&&r(n,i,s)!==r(n,i,o);var n,i,s,o},Br=(t,e)=>{const[r,n]=t;let i=!1,[s,o]=e[e.length-1];for(const[t,a]of e)a>n!=o>n&&r<(s-t)*(n-a)/(o-a)+t&&(i=!i),[s,o]=[t,a];return i};class Fr{subscriptions=[];additionalSubscriptions=[];addSubscriptions(...t){this.subscriptions.push(...t)}addAdditionalSubscriptions(...t){this.additionalSubscriptions.push(...t)}unsubscribe(){this.subscriptions.forEach((t=>t.unsubscribe()))}unsubscribeAdditional(){this.additionalSubscriptions.forEach((t=>t.unsubscribe()))}}class zr extends Fr{logger;snapshotCache=new Te({max:100,ttl:3e5});cameraSubject;cameraState=new fr(!1);lightState=new fr({state:!1,timestamp:"0"});motionState=new fr({timestamp:"0",detections:[]});audioState=new fr({state:!1,timestamp:"0"});objectState=new fr({timestamp:"0",detections:[]});doorbellState=new fr({state:!1,timestamp:"0"});sirenState=new fr({state:!1,timestamp:"0"});batteryState=new fr({level:100,timestamp:"0"});prebufferStateSubjects={};onConnected=this.createStateObservable(this.cameraState);onLightSwitched=this.createStateObservable(this.lightState);onMotionDetected=this.createStateObservable(this.motionState);onAudioDetected=this.createStateObservable(this.audioState);onObjectDetected=this.createStateObservable(this.objectState);onDoorbellPressed=this.createStateObservable(this.doorbellState);onSirenDetected=this.createStateObservable(this.sirenState);onBatteryChanged=this.createStateObservable(this.batteryState);get id(){return this.cameraSubject.getValue()._id}get nativeId(){return this.cameraSubject.getValue().nativeId}get pluginId(){return this.cameraSubject.getValue().pluginId}get connected(){return this.cameraState.getValue()}get disabled(){return this.cameraSubject.getValue().disabled}get name(){return this.cameraSubject.getValue().name}get type(){return this.cameraSubject.getValue().type}get info(){return pe()(this.cameraSubject.getValue().info)}get isCloud(){return this.cameraSubject.getValue().isCloud}get hasLight(){return this.cameraSubject.getValue().hasLight}get hasSiren(){return this.cameraSubject.getValue().hasSiren}get hasBinarySensor(){return this.cameraSubject.getValue().hasBinarySensor}get hasBattery(){return this.cameraSubject.getValue().hasBattery}get hasMotionDetector(){return this.cameraSubject.getValue().hasMotionDetector}get hasAudioDetector(){return this.cameraSubject.getValue().hasAudioDetector}get hasObjectDetector(){return this.cameraSubject.getValue().hasObjectDetector}get hasPtz(){return this.cameraSubject.getValue().hasPtz}get hasPrebuffer(){return this.cameraSubject.getValue().hasPrebuffer}get hasIntercom(){return this.cameraSubject.getValue().hasIntercom}get activityZones(){return pe()(this.cameraSubject.getValue().activityZones)}get activitySettings(){return pe()(this.cameraSubject.getValue().activitySettings)}get sources(){return pe()(this.cameraSubject.getValue().sources).map((t=>({...t,updatePrebufferingState:async(e,r)=>this.updatePrebuffer(t._id,e,r),getPrebufferingState:e=>this.cameraSourcePrebufferState(t._id,e),onPrebuffering:e=>this.createPrebufferStateObservable(t._id,e),getStreamInfo:async()=>{}})))}get streamSource(){return this.sources.find((t=>t.roles.includes("stream")))||this.sources[0]}get snapshotSource(){return this.sources.find((t=>t.roles.includes("snapshot")))||this.streamSource}get recordingSource(){return this.sources.find((t=>t.roles.includes("record")))||this.streamSource}get detectionSource(){return this.sources.find((t=>t.roles.includes("detect")))||this.streamSource}constructor(t,e){super(),this.logger=e,this.cameraSubject=new fr(t),"native"===t.pluginId&&this.cameraState.next(!0)}getValue(t){switch(t){case"light":return pe()(this.lightState.getValue());case"motion":return pe()(this.motionState.getValue());case"audio":return pe()(this.audioState.getValue());case"object":return pe()(this.objectState.getValue());case"doorbell":return pe()(this.doorbellState.getValue());case"siren":return pe()(this.sirenState.getValue());case"battery":return pe()(this.batteryState.getValue());default:throw new Error(`Unknown state: ${t}`)}}updateStateInternal(t,e,r){let n,i=!1;if(r)i=!0,n=e;else{const r=this.checkStateInternal(t,e);i=r.changed,n=r.event}if(i)switch(t){case"light":this.lightState.next(this.getLightState(n));break;case"motion":this.motionState.next(this.getMotionState(n));break;case"audio":this.audioState.next(this.getAudioState(n));break;case"object":this.objectState.next(this.getObjectState(n));break;case"doorbell":this.doorbellState.next(this.getDoorbellState(n));break;case"siren":this.sirenState.next(this.getSirenState(n));break;case"battery":this.batteryState.next(this.getBatteryState(n));break;default:throw new Error(`Unknown state: ${t}`)}}onStateChange(t){return this[`${t}State`].pipe(vr(),mr((([e,r])=>"boolean"==typeof e||"boolean"==typeof r?e!==r:this.stateChanged(e,r,t))),wr((([t,e])=>({oldState:t,newState:e}))),kr({connector:()=>new pr(1)}))}onPropertyChange(t){return this.cameraSubject.pipe(vr(),mr((([e,r])=>!ye()(e[t],r[t]))),wr((([e,r])=>({oldData:e[t],newData:r[t]}))),kr({connector:()=>new pr(1)}))}removeAllListeners(){this.lightState.complete(),this.motionState.complete(),this.audioState.complete(),this.objectState.complete(),this.doorbellState.complete(),this.sirenState.complete(),this.batteryState.complete(),this.cameraSubject.complete(),this.cameraState.complete()}checkStateInternal(t,e){let r,n=!1;switch(t){case"audio":const i=e;r=this.getAudioState(i),n=this.stateChanged(this.audioState.getValue(),r,"audio");break;case"light":const s=e;r=this.getLightState(s),n=this.stateChanged(this.lightState.getValue(),r,"light");break;case"motion":const o=e;r=this.getMotionState(o),"boolean"==typeof r.state&&(r.detections=[]),r.detections=((t,e)=>{if(0===e.length)return[];const r=[];for(const n of t)Rr(jr(n),e)&&r.push(n);return r})(r.detections,this.activityZones),n=this.stateChanged(this.motionState.getValue(),r,"motion");break;case"object":const a=e;r=this.getObjectState(a),r.detections=((t,e)=>{if(0===e.length)return[];const r=[];for(const n of t)Rr(jr(n),e)&&r.push(n);return r.filter((t=>e.some((e=>!e.classes.length||e.classes.includes(t.label)))))})(r.detections,this.activityZones),n=this.stateChanged(this.objectState.getValue(),r,"object");break;case"doorbell":const c=e;r=this.getDoorbellState(c),n=this.stateChanged(this.doorbellState.getValue(),r,"doorbell");break;case"siren":const u=e;r=this.getSirenState(u),n=this.stateChanged(this.sirenState.getValue(),r,"siren");break;case"battery":const h=e;r=this.getBatteryState(h),n=this.stateChanged(this.batteryState.getValue(),r,"battery");break;default:throw new Error(`Unknown state: ${t}`)}return{changed:n,event:r}}getAudioState(t){const e=this.getValue("audio");let r;if(delete e.lastEvent,this.isStateEvent(t))r=t;else{const n={...t,timestamp:Date.now().toString()};r={...n,db:t.db||e.db,lastEvent:e.state?e:n.state?n:void 0}}return r}getMotionState(t){const e=this.getValue("motion");let r;if(delete e.lastEvent,this.isStateEvent(t))r=t;else{const n={...t,timestamp:Date.now().toString()};r={...n,lastEvent:e.detections.length?e:n.detections.length?n:void 0}}return r}getObjectState(t){const e=this.getValue("object");let r;if(delete e.lastEvent,this.isStateEvent(t))r=t;else{const n={...t,timestamp:Date.now().toString()};r={...n,lastEvent:e.detections.length?e:n.detections.length?n:void 0}}return r}getDoorbellState(t){const e=this.getValue("doorbell");let r;if(delete e.lastEvent,this.isStateEvent(t))r=t;else{const n={...t,timestamp:Date.now().toString()};r={...n,lastEvent:e.state?e:n.state?n:void 0}}return r}getLightState(t){const e=this.getValue("light");let r;if(delete e.lastEvent,this.isStateEvent(t))r=t;else{const n={...t,timestamp:Date.now().toString()};r={...n,lastEvent:e.state?e:n.state?n:void 0}}return r}getSirenState(t){const e=this.getValue("siren");let r;if(delete e.lastEvent,this.isStateEvent(t))r=t;else{const n={...t,timestamp:Date.now().toString()};r={...n,lastEvent:e.state?e:n.state?n:void 0}}return r}getBatteryState(t){const e=this.getValue("battery"),r=this.stateChanged(e,t,"battery");let n;if(delete e.lastEvent,this.isStateEvent(t))n=t;else{const i={...t,timestamp:Date.now().toString()};n={...i,charging:t.charging||e.charging,lowBattery:t.lowBattery||e.lowBattery,lastEvent:r?e:i}}return n}updateCamera(t){this.cameraSubject.next(t),this.updateCameraSourcesState()}async updatePrebuffer(t,e,r){this.prebufferStateSubjects[t]&&this.prebufferStateSubjects[t][e]&&this.prebufferStateSubjects[t][e].next({state:r.state,url:r.url||void 0,maxDuration:r.maxDuration,availableDuration:r.availableDuration})}updateCameraSourcesState(){const t=this.cameraSubject.getValue().sources;for(const e in this.prebufferStateSubjects)if(!t.some((t=>t._id===e))){for(const t in this.prebufferStateSubjects[e])this.prebufferStateSubjects[e][t].complete();delete this.prebufferStateSubjects[e]}}updateCameraState(t){this.cameraState.next(t)}cameraSourcePrebufferState(t,e){let r={state:!1,maxDuration:0,availableDuration:0};return this.prebufferStateSubjects[t]&&this.prebufferStateSubjects[t][e]&&(r=this.prebufferStateSubjects[t][e].getValue()),r}createStateObservable(t){return t.pipe(kr({connector:()=>new pr(1)}))}createPrebufferStateObservable(t,e){return this.prebufferStateSubjects[t]||(this.prebufferStateSubjects[t]={}),this.prebufferStateSubjects[t][e]||(this.prebufferStateSubjects[t][e]=new fr({state:!1,maxDuration:0,availableDuration:0})),this.prebufferStateSubjects[t][e].pipe((void 0===n&&(n=or),r=null!=(r=(t,e)=>t.state===e.state&&t.url===e.url)?r:Tr,br((function(t,e){var i,s=!0;t.subscribe(yr(e,(function(t){var o=n(t);!s&&r(i,o)||(s=!1,i=o,e.next(t))})))}))),kr({connector:()=>new pr(1)}));var r,n}stateChanged(t,e,r){if(!t||!e||!r)return!1;if("audio"==r){if(!this.hasAudioDetector)return!1;const r=t,n=e;return r.state!==n.state||r.db!==n.db}if("motion"==r){if(!this.hasMotionDetector)return!1;const r=t,n=e;return"state"in t&&"state"in e?r.state!==n.state:!ye()(r.detections,n.detections)}if("object"==r){if(!this.hasObjectDetector)return!1;const r=t,n=e;return!ye()(r.detections,n.detections)}if("siren"==r){if(!this.hasSiren)return!1;const r=t,n=e;return r.state!==n.state||r.level!==n.level}if("battery"==r){if(!this.hasBattery)return!1;const r=t,n=e;return r.level!==n.level||r.lowBattery!==n.lowBattery||r.charging!==n.charging}if("doorbell"==r){if(!this.hasBinarySensor)return!1;const r=e;return t.state!==r.state}if("light"==r){if(!this.hasLight)return!1;const r=e;return t.state!==r.state}return!1}isStateEvent(t){return"timestamp"in t}}var Nr=function(t,e){return Nr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},Nr(t,e)};function Ir(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}Nr(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function Ur(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function Mr(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function qr(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,s=r.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return o}function Vr(t,e,r){if(r||2===arguments.length)for(var n,i=0,s=e.length;i<s;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}function Wr(t){return this instanceof Wr?(this.v=t,this):new Wr(t)}function Hr(t){return"function"==typeof t}function $r(t){var e=t((function(t){Error.call(t),t.stack=(new Error).stack}));return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var Gr=$r((function(t){return function(e){t(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map((function(t,e){return e+1+") "+t.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=e}}));function Jr(t,e){if(t){var r=t.indexOf(e);0<=r&&t.splice(r,1)}}var Kr=function(){function t(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var t,e,r,n,i;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var o=Mr(s),a=o.next();!a.done;a=o.next())a.value.remove(this)}catch(e){t={error:e}}finally{try{a&&!a.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}else s.remove(this);var c=this.initialTeardown;if(Hr(c))try{c()}catch(t){i=t instanceof Gr?t.errors:[t]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var h=Mr(u),l=h.next();!l.done;l=h.next()){var f=l.value;try{Qr(f)}catch(t){i=null!=i?i:[],t instanceof Gr?i=Vr(Vr([],qr(i)),qr(t.errors)):i.push(t)}}}catch(t){r={error:t}}finally{try{l&&!l.done&&(n=h.return)&&n.call(h)}finally{if(r)throw r.error}}}if(i)throw new Gr(i)}},t.prototype.add=function(e){var r;if(e&&e!==this)if(this.closed)Qr(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(e)}},t.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},t.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},t.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&Jr(e,t)},t.prototype.remove=function(e){var r=this._finalizers;r&&Jr(r,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}(),Yr=Kr.EMPTY;function Xr(t){return t instanceof Kr||t&&"closed"in t&&Hr(t.remove)&&Hr(t.add)&&Hr(t.unsubscribe)}function Qr(t){Hr(t)?t():t.unsubscribe()}var Zr={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},tn={setTimeout:function(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var i=tn.delegate;return(null==i?void 0:i.setTimeout)?i.setTimeout.apply(i,Vr([t,e],qr(r))):setTimeout.apply(void 0,Vr([t,e],qr(r)))},clearTimeout:function(t){var e=tn.delegate;return((null==e?void 0:e.clearTimeout)||clearTimeout)(t)},delegate:void 0};function en(t){tn.setTimeout((function(){var e=Zr.onUnhandledError;if(!e)throw t;e(t)}))}function rn(){}var nn=sn("C",void 0,void 0);function sn(t,e,r){return{kind:t,value:e,error:r}}var on=null;function an(t){if(Zr.useDeprecatedSynchronousErrorHandling){var e=!on;if(e&&(on={errorThrown:!1,error:null}),t(),e){var r=on,n=r.errorThrown,i=r.error;if(on=null,n)throw i}}else t()}var cn=function(t){function e(e){var r=t.call(this)||this;return r.isStopped=!1,e?(r.destination=e,Xr(e)&&e.add(r)):r.destination=bn,r}return Ir(e,t),e.create=function(t,e,r){return new fn(t,e,r)},e.prototype.next=function(t){this.isStopped?pn(function(t){return sn("N",t,void 0)}(t),this):this._next(t)},e.prototype.error=function(t){this.isStopped?pn(sn("E",void 0,t),this):(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped?pn(nn,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(Kr),un=Function.prototype.bind;function hn(t,e){return un.call(t,e)}var ln=function(){function t(t){this.partialObserver=t}return t.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(t){dn(t)}},t.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(t){dn(t)}else dn(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){dn(t)}},t}(),fn=function(t){function e(e,r,n){var i,s,o=t.call(this)||this;return Hr(e)||!e?i={next:null!=e?e:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:o&&Zr.useDeprecatedNextContext?((s=Object.create(e)).unsubscribe=function(){return o.unsubscribe()},i={next:e.next&&hn(e.next,s),error:e.error&&hn(e.error,s),complete:e.complete&&hn(e.complete,s)}):i=e,o.destination=new ln(i),o}return Ir(e,t),e}(cn);function dn(t){var e;Zr.useDeprecatedSynchronousErrorHandling?(e=t,Zr.useDeprecatedSynchronousErrorHandling&&on&&(on.errorThrown=!0,on.error=e)):en(t)}function pn(t,e){var r=Zr.onStoppedNotification;r&&tn.setTimeout((function(){return r(t,e)}))}var bn={closed:!0,next:rn,error:function(t){throw t},complete:rn},yn="function"==typeof Symbol&&Symbol.observable||"@@observable";function gn(t){return t}var vn=function(){function t(t){t&&(this._subscribe=t)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(t,e,r){var n=this,i=function(t){return t&&t instanceof cn||function(t){return t&&Hr(t.next)&&Hr(t.error)&&Hr(t.complete)}(t)&&Xr(t)}(t)?t:new fn(t,e,r);return an((function(){var t=n,e=t.operator,r=t.source;i.add(e?e.call(i,r):r?n._subscribe(i):n._trySubscribe(i))})),i},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},t.prototype.forEach=function(t,e){var r=this;return new(e=mn(e))((function(e,n){var i=new fn({next:function(e){try{t(e)}catch(t){n(t),i.unsubscribe()}},error:n,complete:e});r.subscribe(i)}))},t.prototype._subscribe=function(t){var e;return null===(e=this.source)||void 0===e?void 0:e.subscribe(t)},t.prototype[yn]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return(0===(r=t).length?gn:1===r.length?r[0]:function(t){return r.reduce((function(t,e){return e(t)}),t)})(this);var r},t.prototype.toPromise=function(t){var e=this;return new(t=mn(t))((function(t,r){var n;e.subscribe((function(t){return n=t}),(function(t){return r(t)}),(function(){return t(n)}))}))},t.create=function(e){return new t(e)},t}();function mn(t){var e;return null!==(e=null!=t?t:Zr.Promise)&&void 0!==e?e:Promise}var wn=$r((function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),Sn=function(t){function e(){var e=t.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return Ir(e,t),e.prototype.lift=function(t){var e=new _n(this,this);return e.operator=t,e},e.prototype._throwIfClosed=function(){if(this.closed)throw new wn},e.prototype.next=function(t){var e=this;an((function(){var r,n;if(e._throwIfClosed(),!e.isStopped){e.currentObservers||(e.currentObservers=Array.from(e.observers));try{for(var i=Mr(e.currentObservers),s=i.next();!s.done;s=i.next())s.value.next(t)}catch(t){r={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}}}))},e.prototype.error=function(t){var e=this;an((function(){if(e._throwIfClosed(),!e.isStopped){e.hasError=e.isStopped=!0,e.thrownError=t;for(var r=e.observers;r.length;)r.shift().error(t)}}))},e.prototype.complete=function(){var t=this;an((function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var e=t.observers;e.length;)e.shift().complete()}}))},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var e=this,r=this,n=r.hasError,i=r.isStopped,s=r.observers;return n||i?Yr:(this.currentObservers=null,s.push(t),new Kr((function(){e.currentObservers=null,Jr(s,t)})))},e.prototype._checkFinalizedStatuses=function(t){var e=this,r=e.hasError,n=e.thrownError,i=e.isStopped;r?t.error(n):i&&t.complete()},e.prototype.asObservable=function(){var t=new vn;return t.source=this,t},e.create=function(t,e){return new _n(t,e)},e}(vn),_n=function(t){function e(e,r){var n=t.call(this)||this;return n.destination=e,n.source=r,n}return Ir(e,t),e.prototype.next=function(t){var e,r;null===(r=null===(e=this.destination)||void 0===e?void 0:e.next)||void 0===r||r.call(e,t)},e.prototype.error=function(t){var e,r;null===(r=null===(e=this.destination)||void 0===e?void 0:e.error)||void 0===r||r.call(e,t)},e.prototype.complete=function(){var t,e;null===(e=null===(t=this.destination)||void 0===t?void 0:t.complete)||void 0===e||e.call(t)},e.prototype._subscribe=function(t){var e,r;return null!==(r=null===(e=this.source)||void 0===e?void 0:e.subscribe(t))&&void 0!==r?r:Yr},e}(Sn),En={now:function(){return(En.delegate||Date).now()},delegate:void 0},On=function(t){function e(e,r,n){void 0===e&&(e=1/0),void 0===r&&(r=1/0),void 0===n&&(n=En);var i=t.call(this)||this;return i._bufferSize=e,i._windowTime=r,i._timestampProvider=n,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=r===1/0,i._bufferSize=Math.max(1,e),i._windowTime=Math.max(1,r),i}return Ir(e,t),e.prototype.next=function(e){var r=this,n=r.isStopped,i=r._buffer,s=r._infiniteTimeWindow,o=r._timestampProvider,a=r._windowTime;n||(i.push(e),!s&&i.push(o.now()+a)),this._trimBuffer(),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var e=this._innerSubscribe(t),r=this._infiniteTimeWindow,n=this._buffer.slice(),i=0;i<n.length&&!t.closed;i+=r?1:2)t.next(n[i]);return this._checkFinalizedStatuses(t),e},e.prototype._trimBuffer=function(){var t=this,e=t._bufferSize,r=t._timestampProvider,n=t._buffer,i=t._infiniteTimeWindow,s=(i?1:2)*e;if(e<1/0&&s<n.length&&n.splice(0,n.length-s),!i){for(var o=r.now(),a=0,c=1;c<n.length&&n[c]<=o;c+=2)a=c;a&&n.splice(0,a+1)}},e}(Sn),kn=function(t){function e(e){var r=t.call(this)||this;return r._value=e,r}return Ir(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(e){var r=t.prototype._subscribe.call(this,e);return!r.closed&&e.next(this._value),r},e.prototype.getValue=function(){var t=this,e=t.hasError,r=t.thrownError,n=t._value;if(e)throw r;return this._throwIfClosed(),n},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},e}(Sn),xn=$r((function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}}));function Tn(t){return function(e){if(function(t){return Hr(null==t?void 0:t.lift)}(e))return e.lift((function(e){try{return t(e,this)}catch(t){this.error(t)}}));throw new TypeError("Unable to lift unknown Observable type")}}var An=Array.isArray;function jn(t,e,r,n,i){return new Rn(t,e,r,n,i)}var Rn=function(t){function e(e,r,n,i,s,o){var a=t.call(this,e)||this;return a.onFinalize=s,a.shouldUnsubscribe=o,a._next=r?function(t){try{r(t)}catch(t){e.error(t)}}:t.prototype._next,a._error=i?function(t){try{i(t)}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._error,a._complete=n?function(){try{n()}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._complete,a}return Ir(e,t),e.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&(null===(e=this.onFinalize)||void 0===e||e.call(this))}},e}(cn);function Cn(t,e){return Tn((function(r,n){var i=0;r.subscribe(jn(n,(function(r){n.next(t.call(e,r,i++))})))}))}var Ln=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t};function Dn(t){return Hr(null==t?void 0:t.then)}function Pn(t){return Hr(t[yn])}function Bn(t){return Symbol.asyncIterator&&Hr(null==t?void 0:t[Symbol.asyncIterator])}function Fn(t){return new TypeError("You provided "+(null!==t&&"object"==typeof t?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var zn,Nn,In,Un="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function Mn(t){return Hr(null==t?void 0:t[Un])}function qn(t){return function(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(t,e||[]),s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(t){i[t]&&(n[t]=function(e){return new Promise((function(r,n){s.push([t,e,r,n])>1||a(t,e)}))})}function a(t,e){try{(r=i[t](e)).value instanceof Wr?Promise.resolve(r.value.v).then(c,u):h(s[0][2],r)}catch(t){h(s[0][3],t)}var r}function c(t){a("next",t)}function u(t){a("throw",t)}function h(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}}(this,arguments,(function(){var e,r,n;return Ur(this,(function(i){switch(i.label){case 0:e=t.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,Wr(e.read())];case 3:return r=i.sent(),n=r.value,r.done?[4,Wr(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,Wr(n)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}}))}))}function Vn(t){return Hr(null==t?void 0:t.getReader)}function Wn(t){if(t instanceof vn)return t;if(null!=t){if(Pn(t))return i=t,new vn((function(t){var e=i[yn]();if(Hr(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(Ln(t))return n=t,new vn((function(t){for(var e=0;e<n.length&&!t.closed;e++)t.next(n[e]);t.complete()}));if(Dn(t))return r=t,new vn((function(t){r.then((function(e){t.closed||(t.next(e),t.complete())}),(function(e){return t.error(e)})).then(null,en)}));if(Bn(t))return Hn(t);if(Mn(t))return e=t,new vn((function(t){var r,n;try{for(var i=Mr(e),s=i.next();!s.done;s=i.next()){var o=s.value;if(t.next(o),t.closed)return}}catch(t){r={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}t.complete()}));if(Vn(t))return Hn(qn(t))}var e,r,n,i;throw Fn(t)}function Hn(t){return new vn((function(e){(function(t,e){var r,n,i,s,o,a,c,u;return o=this,a=void 0,u=function(){var o,a;return Ur(this,(function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),r=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=Mr(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,i){!function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)}(n,i,(e=t[r](e)).done,e.value)}))}}}(t),c.label=1;case 1:return[4,r.next()];case 2:if((n=c.sent()).done)return[3,4];if(o=n.value,e.next(o),e.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),i={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),n&&!n.done&&(s=r.return)?[4,s.call(r)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}}))},new((c=void 0)||(c=Promise))((function(t,e){function r(t){try{i(u.next(t))}catch(t){e(t)}}function n(t){try{i(u.throw(t))}catch(t){e(t)}}function i(e){e.done?t(e.value):function(t){return t instanceof c?t:new c((function(e){e(t)}))}(e.value).then(r,n)}i((u=u.apply(o,a||[])).next())}))})(t,e).catch((function(t){return e.error(t)}))}))}function $n(t,e,r,n,i){void 0===n&&(n=0),void 0===i&&(i=!1);var s=e.schedule((function(){r(),i?t.add(this.schedule(null,n)):this.unsubscribe()}),n);if(t.add(s),!i)return s}function Gn(t,e,r){return void 0===r&&(r=1/0),Hr(e)?Gn((function(r,n){return Cn((function(t,i){return e(r,t,n,i)}))(Wn(t(r,n)))}),r):("number"==typeof e&&(r=e),Tn((function(e,n){return function(t,e,r,n,i,s,o,a){var c=[],u=0,h=0,l=!1,f=function(){!l||c.length||u||e.complete()},d=function(t){return u<n?p(t):c.push(t)},p=function(t){u++;var i=!1;Wn(r(t,h++)).subscribe(jn(e,(function(t){e.next(t)}),(function(){i=!0}),void 0,(function(){if(i)try{u--;for(;c.length&&u<n;)t=void 0,t=c.shift(),p(t);f()}catch(t){e.error(t)}var t})))};return t.subscribe(jn(e,d,(function(){l=!0,f()}))),function(){}}(e,n,t,r)})))}function Jn(t){return t[t.length-1]}function Kn(t,e){return void 0===e&&(e=0),Tn((function(r,n){r.subscribe(jn(n,(function(r){return $n(n,t,(function(){return n.next(r)}),e)}),(function(){return $n(n,t,(function(){return n.complete()}),e)}),(function(r){return $n(n,t,(function(){return n.error(r)}),e)})))}))}function Yn(t,e){return void 0===e&&(e=0),Tn((function(r,n){n.add(t.schedule((function(){return r.subscribe(n)}),e))}))}function Xn(t,e){if(!t)throw new Error("Iterable cannot be null");return new vn((function(r){$n(r,e,(function(){var n=t[Symbol.asyncIterator]();$n(r,e,(function(){n.next().then((function(t){t.done?r.complete():r.next(t.value)}))}),0,!0)}))}))}function Qn(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=function(t){return function(t){return t&&Hr(t.schedule)}(Jn(t))?t.pop():void 0}(t),n=function(t,e){return"number"==typeof Jn(t)?t.pop():1/0}(t);return t=function(t){return 1===t.length&&An(t[0])?t[0]:t}(t),Tn((function(e,i){(function(t){return void 0===t&&(t=1/0),Gn(gn,t)})(n)(function(t,e){return e?function(t,e){if(null!=t){if(Pn(t))return function(t,e){return Wn(t).pipe(Yn(e),Kn(e))}(t,e);if(Ln(t))return function(t,e){return new vn((function(r){var n=0;return e.schedule((function(){n===t.length?r.complete():(r.next(t[n++]),r.closed||this.schedule())}))}))}(t,e);if(Dn(t))return function(t,e){return Wn(t).pipe(Yn(e),Kn(e))}(t,e);if(Bn(t))return Xn(t,e);if(Mn(t))return function(t,e){return new vn((function(r){var n;return $n(r,e,(function(){n=t[Un](),$n(r,e,(function(){var t,e,i;try{e=(t=n.next()).value,i=t.done}catch(t){return void r.error(t)}i?r.complete():r.next(e)}),0,!0)})),function(){return Hr(null==n?void 0:n.return)&&n.return()}}))}(t,e);if(Vn(t))return function(t,e){return Xn(qn(t),e)}(t,e)}throw Fn(t)}(t,e):Wn(t)}(Vr([e],qr(t)),r)).subscribe(i)}))}function Zn(t,e){return t===e}function ti(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];if(!0!==e){if(!1!==e){var i=new fn({next:function(){i.unsubscribe(),t()}});return Wn(e.apply(void 0,Vr([],qr(r)))).subscribe(i)}}else t()}!function(t){t.READY="ready",t.STARTING="starting",t.STARTED="started",t.STOPPED="stopped",t.ERROR="error",t.UNKNOWN="unknown",t.DISABLED="disabled"}(zn||(zn={})),function(t){t.START="start",t.STOP="stop"}(Nn||(Nn={})),function(t){t.READY="ready",t.RESTARTING="restarting",t.STARTING="starting",t.STARTED="started",t.STOPPED="stopped",t.ERROR="error",t.UNKNOWN="unknown"}(In||(In={}));class ei{subscriptions=[];additionalSubscriptions=[];addSubscriptions(...t){this.subscriptions.push(...t)}addAdditionalSubscriptions(...t){this.additionalSubscriptions.push(...t)}unsubscribe(){this.subscriptions.forEach((t=>t.unsubscribe()))}unsubscribeAdditional(){this.additionalSubscriptions.forEach((t=>t.unsubscribe()))}}class ri extends ei{onCallAnswered=new On(1);onCallEnded=new On(1);onUsingOpus=new On(1);micState=new kn(!1);hasEnded=!1;cameraDevice;connection;logger;onMicrophoneEnabled=this.createStateObservable(this.micState);get isUsingOpus(){return t=this.onUsingOpus.pipe(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Qn.apply(void 0,Vr([],qr(t)))}(this.connection.onError.pipe(Cn((t=>{throw t}))))),new Promise((function(e,r){var n=new fn({next:function(t){e(t),n.unsubscribe()},error:r,complete:function(){r(new xn)}});t.subscribe(n)}));var t}constructor(t,e,r){super(),this.cameraDevice=t,this.logger=e,this.connection=r,this.bindToConnection(r)}enableMicrophone(t){this.hasEnded||(this.connection.pc.enableMicrophone(t),this.micState.next(!0))}disableMicrophone(){this.hasEnded||(this.connection.pc.disableMicrophone(),this.micState.next(!1))}stop(){this.callEnded()}createStateObservable(t){return t.pipe((e=(t,e)=>t===e,void 0===r&&(r=gn),e=null!=e?e:Zn,Tn((function(t,n){var i,s=!0;t.subscribe(jn(n,(function(t){var o=r(t);!s&&e(i,o)||(s=!1,i=o,n.next(t))})))}))),function(t){void 0===t&&(t={});var e=t.connector,r=void 0===e?function(){return new Sn}:e,n=t.resetOnError,i=void 0===n||n,s=t.resetOnComplete,o=void 0===s||s,a=t.resetOnRefCountZero,c=void 0===a||a;return function(t){var e,n,s,a=0,u=!1,h=!1,l=function(){null==n||n.unsubscribe(),n=void 0},f=function(){l(),e=s=void 0,u=h=!1},d=function(){var t=e;f(),null==t||t.unsubscribe()};return Tn((function(t,p){a++,h||u||l();var b=s=null!=s?s:r();p.add((function(){0!=--a||h||u||(n=ti(d,c))})),b.subscribe(p),!e&&a>0&&(e=new fn({next:function(t){return b.next(t)},error:function(t){h=!0,l(),n=ti(f,i,t),b.error(t)},complete:function(){u=!0,l(),n=ti(f,o),b.complete()}}),Wn(t).subscribe(e))}))(t)}}({connector:()=>new On(1)}));var e,r}bindToConnection(t){this.addSubscriptions(t.onCallAnswered.subscribe((t=>{this.onUsingOpus.next(t.toLocaleLowerCase().includes(" opus/"))})),t.onCallEnded.subscribe((()=>this.callEnded())))}callEnded(){this.hasEnded||(this.hasEnded=!0,this.unsubscribe(),this.onCallEnded.next(),this.connection.stop())}}var ni=Array.isArray;var ii=["addListener","removeListener"],si=["addEventListener","removeEventListener"],oi=["on","off"];function ai(t,e,r,n){if(Hr(r)&&(n=r,r=void 0),n)return ai(t,e,r).pipe((i=n,Cn((function(t){return function(t,e){return ni(e)?t.apply(void 0,Vr([],qr(e))):t(e)}(i,t)}))));var i,s=qr(function(t){return Hr(t.addEventListener)&&Hr(t.removeEventListener)}(t)?si.map((function(n){return function(i){return t[n](e,i,r)}})):function(t){return Hr(t.addListener)&&Hr(t.removeListener)}(t)?ii.map(ci(t,e)):function(t){return Hr(t.on)&&Hr(t.off)}(t)?oi.map(ci(t,e)):[],2),o=s[0],a=s[1];if(!o&&Ln(t))return Gn((function(t){return ai(t,e,r)}))(Wn(t));if(!o)throw new TypeError("Invalid event target");return new vn((function(t){var e=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.next(1<e.length?e:e[0])};return o(e),function(){return a(e)}}))}function ci(t,e){return function(r){return function(n){return t[r](e,n)}}}function ui(t){const e=[];return t.forEach((t=>{t.urls.forEach((r=>{e.push({urls:r,username:t.username,credential:t.credential})}))})),e}class hi extends ei{onIceCandidate=new Sn;onConnectionState=new On(1);videoTransceiver;audioTransceiver;cameraDevice;logger;pc;videoElement;constructor(t,e,r,n){super(),this.cameraDevice=t,this.logger=n,this.videoElement=e,this.pc=new RTCPeerConnection({iceServers:ui(r)}),this.audioTransceiver=this.pc.addTransceiver("audio",{direction:"sendrecv"}),this.videoTransceiver=this.pc.addTransceiver("video",{direction:"recvonly"}),this.pc.onconnectionstatechange=()=>{this.logger.debug(this.cameraDevice.name,"connectionStateChange:",this.pc.connectionState),this.onConnectionState.next(this.pc.connectionState)},this.pc.oniceconnectionstatechange=()=>{this.logger.debug(this.cameraDevice.name,"iceconnectionstatechange:",this.pc.iceConnectionState)},this.pc.onicegatheringstatechange=()=>{this.logger.debug(this.cameraDevice.name,"icegatheringstatechange:",this.pc.iceGatheringState)},this.pc.onicecandidate=t=>{t.candidate&&this.onIceCandidate.next(t.candidate)},this.pc.ontrack=t=>{this.logger.debug(this.cameraDevice.name,"ontrack:",t.track),e.srcObject?e.srcObject.addTrack(t.track):e.srcObject=new MediaStream([t.track])}}enableMicrophone(t){this.audioTransceiver.sender.replaceTrack(t)}disableMicrophone(){this.audioTransceiver.sender.replaceTrack(null)}async createOffer(){const t=await this.pc.createOffer();return await this.pc.setLocalDescription(t),t}async acceptAnswer(t){await this.pc.setRemoteDescription(t)}addIceCandidate(t){return this.pc.addIceCandidate(t)}close(){this.videoElement.srcObject=null,this.pc.close(),this.unsubscribe()}}class li extends ei{onCallAnswered=new On(1);onCallEnded=new On(1);onError=new On(1);onMessage=new On;onWsOpen;pc;ws;onOfferSent=new On(1);hasEnded=!1;cameraDevice;logger;constructor(t,e,r,n,i){super(),this.cameraDevice=t,this.logger=i;const s=t.sources.find((t=>t.name===e));if(!s)throw new Error(`Invalid source name ${e}`);this.ws=new WebSocket(s.urls.ws.webrtc),this.pc=new hi(t,r,n,i),this.onWsOpen=ai(this.ws,"open");const o=ai(this.ws,"message"),a=ai(this.ws,"error"),c=ai(this.ws,"close");var u,h;this.addSubscriptions(o.pipe((u=t=>{const e=JSON.parse(t.data);return this.onMessage.next(e),this.handleMessage(e).catch((t=>{throw this.onError.next(t),t}))},Hr(h)?Gn(u,h,1):Gn(u,1))).subscribe(),a.subscribe((t=>{this.logger.error(this.cameraDevice.name,t),this.callEnded()})),c.subscribe((()=>{this.callEnded()})),this.cameraDevice.onConnected.subscribe((t=>{t||this.callEnded()})),this.onError.subscribe((t=>{this.logger.error(this.cameraDevice.name,t),this.callEnded()})),this.onWsOpen.subscribe((()=>{this.initiateCall().catch((t=>{this.logger.error(this.cameraDevice.name,t),this.callEnded()}))})),this.pc.onConnectionState.subscribe((t=>{"failed"===t&&(this.logger.error(this.cameraDevice.name,"Stream connection failed"),this.callEnded()),"closed"===t&&(this.logger.debug(this.cameraDevice.name,"Stream connection closed"),this.callEnded())})),this.pc.onIceCandidate.subscribe((async t=>{this.sendMessage({type:"webrtc/candidate",value:t.toJSON().candidate||""})})))}stop(){this.callEnded()}async initiateCall(){const{sdp:t}=await this.pc.createOffer();this.sendMessage({type:"webrtc/offer",value:t||""}),this.onOfferSent.next()}async handleMessage(t){switch(t.type){case"webrtc/answer":const e=t.value;return await this.pc.acceptAnswer({type:"answer",sdp:e}),void this.onCallAnswered.next(e);case"webrtc/candidate":return void await this.pc.addIceCandidate({candidate:t.value,sdpMid:"0"});case"error":throw new Error(t.value);default:throw new Error(t)}}sendMessage(t){this.hasEnded||this.ws.send(JSON.stringify(t))}callEnded(){this.hasEnded||(this.hasEnded=!0,this.unsubscribe(),this.onCallEnded.next(),this.pc.close(),this.ws.close())}}class fi extends zr{socketService;socket;_started=!1;get started(){return this._started}get sources(){return super.sources.map((t=>({...t,updatePrebufferingState:(e,r)=>this.socketService.sendRequest({name:"cameraDevice",method:"updatePrebufferState",args:[{cameraId:this.id,sourceId:t._id,container:e,state:r,pluginId:"@camera.ui/client"}]},this.socket),getPrebufferingState:e=>super.cameraSourcePrebufferState(t._id,e),onPrebuffering:e=>super.createPrebufferStateObservable(t._id,e),getStreamInfo:async()=>this.socketService.sendRequest({name:"cameraDevice",method:"getStreamInfo",args:[{sourceName:t.name,pluginId:"@camera.ui/client"}]},this.socket)})))}constructor(t,e,r){super(t,r),this.socketService=e;const{socket:n}=this.socketService.createManager();this.socket=n,this.listenToMessages()}start(){this._started||(this._started=!0,this.socket.emit("joinRoomStates",this.id))}stop(){this._started=!1,this.socket.emit("leaveRoomStates",this.id)}close(){this.cleanup()}connect(){return this.socketService.sendRequest({name:"cameraDevice",method:"connect",args:[{cameraId:this.id,pluginId:"@camera.ui/client"}]},this.socket)}disconnect(){return this.socketService.sendRequest({name:"cameraDevice",method:"disconnect",args:[{cameraId:this.id,pluginId:"@camera.ui/client"}]},this.socket)}reboot(){return this.socketService.sendRequest({name:"cameraDevice",method:"reboot",args:[{cameraId:this.id,pluginId:"@camera.ui/client"}]},this.socket)}getIceServers(){return this.socketService.sendRequest({name:"cameraDevice",method:"getIceServers",args:[{cameraId:this.id,pluginId:"@camera.ui/client"}]},this.socket)}async snapshot(t=!1){const e=this.snapshotSource.urls.www.jpegSnapshot,r=this.snapshotCache.get(this.snapshotSource._id);if(!t&&r)return r;const n=await fetch(e);if(!n.ok)throw new Error("Status Code: "+n.status);const i=await n.arrayBuffer();return i.byteLength>0&&this.snapshotCache.set(this.snapshotSource._id,i),i}async createSession(t,e){const r=await this.getIceServers(),n=new li(this,t,e,r,this.logger);return new ri(this,this.logger,n)}async updateState(t,e){const{changed:r,event:n}=super.checkStateInternal(t,e);if(r)return super.updateStateInternal(t,n,!0),this.socketService.sendRequest({name:"cameraDevice",method:"updateState",args:[{cameraId:this.id,stateName:t,eventData:n,pluginId:"@camera.ui/client"}]},this.socket)}async refreshStates(){const t=await this.socketService.sendRequest({name:"cameraDevice",method:"refreshStates",args:[{cameraId:this.id,pluginId:"@camera.ui/client"}]},this.socket);super.updateCamera(t.camera),super.updateCameraState(t.cameraState);for(const[e,r]of Object.entries(t.states))super.updateStateInternal(e,r)}async cleanup(){this._started=!1,this.removeAllListeners(),this.unsubscribe(),this.socket.disconnect()}listenToMessages(){this.socket.emit("joinRoomDevice",this.id),this.socket.on("updateState",(t=>{t.cameraId===this.id&&super.updateStateInternal(t.stateName,t.data.newEvent)})),this.socket.on("updateDevice",(t=>{if(t.cameraId===this.id)switch(t.type){case"removed":this.cleanup();break;case"updated":super.updateCamera(t.data);break;case"cameraState":super.updateCameraState(t.data);break;case"prebufferState":super.updatePrebuffer(t.data.sourceId,t.data.container,t.data.state)}}))}}class di{socketService;logger;constructor(t,e){this.socketService=t,this.logger=e}async getCameraById(t){const e=await this.socketService.sendRequest({name:"deviceManager",method:"getCameraById",args:[{id:t,pluginId:"@camera.ui/client"}]});if(e){const t=new fi(e,this.socketService,this.logger);return await t.refreshStates(),t}}async getCameraByName(t){const e=await this.socketService.sendRequest({name:"deviceManager",method:"getCameraByName",args:[{name:t,pluginId:"@camera.ui/client"}]});if(e){const t=new fi(e,this.socketService,this.logger);return await t.refreshStates(),t}}}class pi{socketService;logger;constructor(t,e){this.socketService=t,this.logger=e}}class bi{socketService;logger;constructor(t,e){this.socketService=t,this.logger=e}}const yi=Object.create(null);yi.open="0",yi.close="1",yi.ping="2",yi.pong="3",yi.message="4",yi.upgrade="5",yi.noop="6";const gi=Object.create(null);Object.keys(yi).forEach((t=>{gi[yi[t]]=t}));const vi={type:"error",data:"parser error"},mi="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),wi="function"==typeof ArrayBuffer,Si=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,_i=({type:t,data:e},r,n)=>mi&&e instanceof Blob?r?n(e):Ei(e,n):wi&&(e instanceof ArrayBuffer||Si(e))?r?n(e):Ei(new Blob([e]),n):n(yi[t]+(e||"")),Ei=(t,e)=>{const r=new FileReader;return r.onload=function(){const t=r.result.split(",")[1];e("b"+(t||""))},r.readAsDataURL(t)};function Oi(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let ki;const xi="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let t=0;t<64;t++)xi["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(t)]=t;const Ti="function"==typeof ArrayBuffer,Ai=(t,e)=>{if("string"!=typeof t)return{type:"message",data:Ri(t,e)};const r=t.charAt(0);return"b"===r?{type:"message",data:ji(t.substring(1),e)}:gi[r]?t.length>1?{type:gi[r],data:t.substring(1)}:{type:gi[r]}:vi},ji=(t,e)=>{if(Ti){const r=(t=>{let e,r,n,i,s,o=.75*t.length,a=t.length,c=0;"="===t[t.length-1]&&(o--,"="===t[t.length-2]&&o--);const u=new ArrayBuffer(o),h=new Uint8Array(u);for(e=0;e<a;e+=4)r=xi[t.charCodeAt(e)],n=xi[t.charCodeAt(e+1)],i=xi[t.charCodeAt(e+2)],s=xi[t.charCodeAt(e+3)],h[c++]=r<<2|n>>4,h[c++]=(15&n)<<4|i>>2,h[c++]=(3&i)<<6|63&s;return u})(t);return Ri(r,e)}return{base64:!0,data:t}},Ri=(t,e)=>"blob"===e?t instanceof Blob?t:new Blob([t]):t instanceof ArrayBuffer?t:t.buffer,Ci=String.fromCharCode(30);let Li;function Di(t){return t.reduce(((t,e)=>t+e.length),0)}function Pi(t,e){if(t[0].length===e)return t.shift();const r=new Uint8Array(e);let n=0;for(let i=0;i<e;i++)r[i]=t[0][n++],n===t[0].length&&(t.shift(),n=0);return t.length&&n<t[0].length&&(t[0]=t[0].slice(n)),r}function Bi(t){if(t)return function(t){for(var e in Bi.prototype)t[e]=Bi.prototype[e];return t}(t)}Bi.prototype.on=Bi.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},Bi.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},Bi.prototype.off=Bi.prototype.removeListener=Bi.prototype.removeAllListeners=Bi.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i=0;i<n.length;i++)if((r=n[i])===e||r.fn===e){n.splice(i,1);break}return 0===n.length&&delete this._callbacks["$"+t],this},Bi.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),r=this._callbacks["$"+t],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(r){n=0;for(var i=(r=r.slice(0)).length;n<i;++n)r[n].apply(this,e)}return this},Bi.prototype.emitReserved=Bi.prototype.emit,Bi.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},Bi.prototype.hasListeners=function(t){return!!this.listeners(t).length};const Fi="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function zi(t,...e){return e.reduce(((e,r)=>(t.hasOwnProperty(r)&&(e[r]=t[r]),e)),{})}const Ni=Fi.setTimeout,Ii=Fi.clearTimeout;function Ui(t,e){e.useNativeTimers?(t.setTimeoutFn=Ni.bind(Fi),t.clearTimeoutFn=Ii.bind(Fi)):(t.setTimeoutFn=Fi.setTimeout.bind(Fi),t.clearTimeoutFn=Fi.clearTimeout.bind(Fi))}class Mi extends Error{constructor(t,e,r){super(t),this.description=e,this.context=r,this.type="TransportError"}}class qi extends Bi{constructor(t){super(),this.writable=!1,Ui(this,t),this.opts=t,this.query=t.query,this.socket=t.socket}onError(t,e,r){return super.emitReserved("error",new Mi(t,e,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(t){"open"===this.readyState&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const e=Ai(t,this.socket.binaryType);this.onPacket(e)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,e={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(e)}_hostname(){const t=this.opts.hostname;return-1===t.indexOf(":")?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(t){const e=function(t){let e="";for(let r in t)t.hasOwnProperty(r)&&(e.length&&(e+="&"),e+=encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e}(t);return e.length?"?"+e:""}}const Vi="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Wi=64,Hi={};let $i,Gi=0,Ji=0;function Ki(t){let e="";do{e=Vi[t%Wi]+e,t=Math.floor(t/Wi)}while(t>0);return e}function Yi(){const t=Ki(+new Date);return t!==$i?(Gi=0,$i=t):t+"."+Ki(Gi++)}for(;Ji<Wi;Ji++)Hi[Vi[Ji]]=Ji;let Xi=!1;try{Xi="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(t){}const Qi=Xi;function Zi(t){const e=t.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!e||Qi))return new XMLHttpRequest}catch(t){}if(!e)try{return new(Fi[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(t){}}function ts(){}const es=null!=new Zi({xdomain:!1}).responseType;class rs extends Bi{constructor(t,e){super(),Ui(this,e),this.opts=e,this.method=e.method||"GET",this.uri=t,this.data=void 0!==e.data?e.data:null,this.create()}create(){var t;const e=zi(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this.opts.xd;const r=this.xhr=new Zi(e);try{r.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let t in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(t)&&r.setRequestHeader(t,this.opts.extraHeaders[t])}}catch(t){}if("POST"===this.method)try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(t){}try{r.setRequestHeader("Accept","*/*")}catch(t){}null===(t=this.opts.cookieJar)||void 0===t||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(r.timeout=this.opts.requestTimeout),r.onreadystatechange=()=>{var t;3===r.readyState&&(null===(t=this.opts.cookieJar)||void 0===t||t.parseCookies(r)),4===r.readyState&&(200===r.status||1223===r.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof r.status?r.status:0)}),0))},r.send(this.data)}catch(t){return void this.setTimeoutFn((()=>{this.onError(t)}),0)}"undefined"!=typeof document&&(this.index=rs.requestsCount++,rs.requests[this.index]=this)}onError(t){this.emitReserved("error",t,this.xhr),this.cleanup(!0)}cleanup(t){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=ts,t)try{this.xhr.abort()}catch(t){}"undefined"!=typeof document&&delete rs.requests[this.index],this.xhr=null}}onLoad(){const t=this.xhr.responseText;null!==t&&(this.emitReserved("data",t),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}function ns(){for(let t in rs.requests)rs.requests.hasOwnProperty(t)&&rs.requests[t].abort()}rs.requestsCount=0,rs.requests={},"undefined"!=typeof document&&("function"==typeof attachEvent?attachEvent("onunload",ns):"function"==typeof addEventListener&&addEventListener("onpagehide"in Fi?"pagehide":"unload",ns,!1));const is="function"==typeof Promise&&"function"==typeof Promise.resolve?t=>Promise.resolve().then(t):(t,e)=>e(t,0),ss=Fi.WebSocket||Fi.MozWebSocket,os="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),as={websocket:class extends qi{constructor(t){super(t),this.supportsBinary=!t.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const t=this.uri(),e=this.opts.protocols,r=os?{}:zi(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=os?new ss(t,e,r):e?new ss(t,e):new ss(t)}catch(t){return this.emitReserved("error",t)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let e=0;e<t.length;e++){const r=t[e],n=e===t.length-1;_i(r,this.supportsBinary,(t=>{try{this.ws.send(t)}catch(t){}n&&is((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",e=this.query||{};return this.opts.timestampRequests&&(e[this.opts.timestampParam]=Yi()),this.supportsBinary||(e.b64=1),this.createUri(t,e)}check(){return!!ss}},webtransport:class extends qi{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((()=>{this.onClose()})).catch((t=>{this.onError("webtransport error",t)})),this.transport.ready.then((()=>{this.transport.createBidirectionalStream().then((t=>{const e=function(t,e){Li||(Li=new TextDecoder);const r=[];let n=0,i=-1,s=!1;return new TransformStream({transform(o,a){for(r.push(o);;){if(0===n){if(Di(r)<1)break;const t=Pi(r,1);s=!(128&~t[0]),i=127&t[0],n=i<126?3:126===i?1:2}else if(1===n){if(Di(r)<2)break;const t=Pi(r,2);i=new DataView(t.buffer,t.byteOffset,t.length).getUint16(0),n=3}else if(2===n){if(Di(r)<8)break;const t=Pi(r,8),e=new DataView(t.buffer,t.byteOffset,t.length),s=e.getUint32(0);if(s>Math.pow(2,21)-1){a.enqueue(vi);break}i=s*Math.pow(2,32)+e.getUint32(4),n=3}else{if(Di(r)<i)break;const t=Pi(r,i);a.enqueue(Ai(s?t:Li.decode(t),e)),n=0}if(0===i||i>t){a.enqueue(vi);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(e).getReader(),n=new TransformStream({transform(t,e){!function(t,e){mi&&t.data instanceof Blob?t.data.arrayBuffer().then(Oi).then(e):wi&&(t.data instanceof ArrayBuffer||Si(t.data))?e(Oi(t.data)):_i(t,!1,(t=>{ki||(ki=new TextEncoder),e(ki.encode(t))}))}(t,(r=>{const n=r.length;let i;if(n<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,n);else if(n<65536){i=new Uint8Array(3);const t=new DataView(i.buffer);t.setUint8(0,126),t.setUint16(1,n)}else{i=new Uint8Array(9);const t=new DataView(i.buffer);t.setUint8(0,127),t.setBigUint64(1,BigInt(n))}t.data&&"string"!=typeof t.data&&(i[0]|=128),e.enqueue(i),e.enqueue(r)}))}});n.readable.pipeTo(t.writable),this.writer=n.writable.getWriter();const i=()=>{r.read().then((({done:t,value:e})=>{t||(this.onPacket(e),i())})).catch((t=>{}))};i();const s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this.writer.write(s).then((()=>this.onOpen()))}))})))}write(t){this.writable=!1;for(let e=0;e<t.length;e++){const r=t[e],n=e===t.length-1;this.writer.write(r).then((()=>{n&&is((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var t;null===(t=this.transport)||void 0===t||t.close()}},polling:class extends qi{constructor(t){if(super(t),this.polling=!1,"undefined"!=typeof location){const e="https:"===location.protocol;let r=location.port;r||(r=e?"443":"80"),this.xd="undefined"!=typeof location&&t.hostname!==location.hostname||r!==t.port}const e=t&&t.forceBase64;this.supportsBinary=es&&!e,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(t){this.readyState="pausing";const e=()=>{this.readyState="paused",t()};if(this.polling||!this.writable){let t=0;this.polling&&(t++,this.once("pollComplete",(function(){--t||e()}))),this.writable||(t++,this.once("drain",(function(){--t||e()})))}else e()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){((t,e)=>{const r=t.split(Ci),n=[];for(let t=0;t<r.length;t++){const i=Ai(r[t],e);if(n.push(i),"error"===i.type)break}return n})(t,this.socket.binaryType).forEach((t=>{if("opening"===this.readyState&&"open"===t.type&&this.onOpen(),"close"===t.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(t)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const t=()=>{this.write([{type:"close"}])};"open"===this.readyState?t():this.once("open",t)}write(t){this.writable=!1,((t,e)=>{const r=t.length,n=new Array(r);let i=0;t.forEach(((t,s)=>{_i(t,!1,(t=>{n[s]=t,++i===r&&e(n.join(Ci))}))}))})(t,(t=>{this.doWrite(t,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const t=this.opts.secure?"https":"http",e=this.query||{};return!1!==this.opts.timestampRequests&&(e[this.opts.timestampParam]=Yi()),this.supportsBinary||e.sid||(e.b64=1),this.createUri(t,e)}request(t={}){return Object.assign(t,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new rs(this.uri(),t)}doWrite(t,e){const r=this.request({method:"POST",data:t});r.on("success",e),r.on("error",((t,e)=>{this.onError("xhr post error",t,e)}))}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",((t,e)=>{this.onError("xhr poll error",t,e)})),this.pollXhr=t}}},cs=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,us=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function hs(t){if(t.length>2e3)throw"URI too long";const e=t,r=t.indexOf("["),n=t.indexOf("]");-1!=r&&-1!=n&&(t=t.substring(0,r)+t.substring(r,n).replace(/:/g,";")+t.substring(n,t.length));let i=cs.exec(t||""),s={},o=14;for(;o--;)s[us[o]]=i[o]||"";return-1!=r&&-1!=n&&(s.source=e,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=function(t,e){const r=e.replace(/\/{2,9}/g,"/").split("/");return"/"!=e.slice(0,1)&&0!==e.length||r.splice(0,1),"/"==e.slice(-1)&&r.splice(r.length-1,1),r}(0,s.path),s.queryKey=function(t,e){const r={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(t,e,n){e&&(r[e]=n)})),r}(0,s.query),s}class ls extends Bi{constructor(t,e={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],t&&"object"==typeof t&&(e=t,t=null),t?(t=hs(t),e.hostname=t.host,e.secure="https"===t.protocol||"wss"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=hs(e.host).host),Ui(this,e),this.secure=null!=e.secure?e.secure:"undefined"!=typeof location&&"https:"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.hostname=e.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=e.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=e.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},e),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(t){let e={},r=t.split("&");for(let t=0,n=r.length;t<n;t++){let n=r[t].split("=");e[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return e}(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(t){const e=Object.assign({},this.opts.query);e.EIO=4,e.transport=t,this.id&&(e.sid=this.id);const r=Object.assign({},this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new as[t](r)}open(){let t;if(this.opts.rememberUpgrade&&ls.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(t){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(t=>this.onClose("transport close",t)))}probe(t){let e=this.createTransport(t),r=!1;ls.priorWebsocketSuccess=!1;const n=()=>{r||(e.send([{type:"ping",data:"probe"}]),e.once("packet",(t=>{if(!r)if("pong"===t.type&&"probe"===t.data){if(this.upgrading=!0,this.emitReserved("upgrading",e),!e)return;ls.priorWebsocketSuccess="websocket"===e.name,this.transport.pause((()=>{r||"closed"!==this.readyState&&(u(),this.setTransport(e),e.send([{type:"upgrade"}]),this.emitReserved("upgrade",e),e=null,this.upgrading=!1,this.flush())}))}else{const t=new Error("probe error");t.transport=e.name,this.emitReserved("upgradeError",t)}})))};function i(){r||(r=!0,u(),e.close(),e=null)}const s=t=>{const r=new Error("probe error: "+t);r.transport=e.name,i(),this.emitReserved("upgradeError",r)};function o(){s("transport closed")}function a(){s("socket closed")}function c(t){e&&t.name!==e.name&&i()}const u=()=>{e.removeListener("open",n),e.removeListener("error",s),e.removeListener("close",o),this.off("close",a),this.off("upgrading",c)};e.once("open",n),e.once("error",s),e.once("close",o),this.once("close",a),this.once("upgrading",c),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==t?this.setTimeoutFn((()=>{r||e.open()}),200):e.open()}onOpen(){if(this.readyState="open",ls.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){let t=0;const e=this.upgrades.length;for(;t<e;t++)this.probe(this.upgrades[t])}}onPacket(t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),this.resetPingTimeout(),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const e=new Error("server error");e.code=t.data,this.onError(e);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data)}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.maxPayload=t.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((()=>{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this.getWritablePackets();this.transport.send(t),this.prevBufferLen=t.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let r=0;r<this.writeBuffer.length;r++){const n=this.writeBuffer[r].data;if(n&&(t+="string"==typeof(e=n)?function(t){let e=0,r=0;for(let n=0,i=t.length;n<i;n++)e=t.charCodeAt(n),e<128?r+=1:e<2048?r+=2:e<55296||e>=57344?r+=3:(n++,r+=4);return r}(e):Math.ceil(1.33*(e.byteLength||e.size))),r>0&&t>this.maxPayload)return this.writeBuffer.slice(0,r);t+=2}var e;return this.writeBuffer}write(t,e,r){return this.sendPacket("message",t,e,r),this}send(t,e,r){return this.sendPacket("message",t,e,r),this}sendPacket(t,e,r,n){if("function"==typeof e&&(n=e,e=void 0),"function"==typeof r&&(n=r,r=null),"closing"===this.readyState||"closed"===this.readyState)return;(r=r||{}).compress=!1!==r.compress;const i={type:t,data:e,options:r};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),n&&this.once("flush",n),this.flush()}close(){const t=()=>{this.onClose("forced close"),this.transport.close()},e=()=>{this.off("upgrade",e),this.off("upgradeError",e),t()},r=()=>{this.once("upgrade",e),this.once("upgradeError",e)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?r():t()})):this.upgrading?r():t()),this}onError(t){ls.priorWebsocketSuccess=!1,this.emitReserved("error",t),this.onClose("transport error",t)}onClose(t,e){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const e=[];let r=0;const n=t.length;for(;r<n;r++)~this.transports.indexOf(t[r])&&e.push(t[r]);return e}}ls.protocol=4,ls.protocol;const fs="function"==typeof ArrayBuffer,ds=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,ps=Object.prototype.toString,bs="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===ps.call(Blob),ys="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===ps.call(File);function gs(t){return fs&&(t instanceof ArrayBuffer||ds(t))||bs&&t instanceof Blob||ys&&t instanceof File}function vs(t,e){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let e=0,r=t.length;e<r;e++)if(vs(t[e]))return!0;return!1}if(gs(t))return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return vs(t.toJSON(),!0);for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&vs(t[e]))return!0;return!1}function ms(t){const e=[],r=t.data,n=t;return n.data=ws(r,e),n.attachments=e.length,{packet:n,buffers:e}}function ws(t,e){if(!t)return t;if(gs(t)){const r={_placeholder:!0,num:e.length};return e.push(t),r}if(Array.isArray(t)){const r=new Array(t.length);for(let n=0;n<t.length;n++)r[n]=ws(t[n],e);return r}if("object"==typeof t&&!(t instanceof Date)){const r={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=ws(t[n],e));return r}return t}function Ss(t,e){return t.data=_s(t.data,e),delete t.attachments,t}function _s(t,e){if(!t)return t;if(t&&!0===t._placeholder){if("number"==typeof t.num&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]=_s(t[r],e);else if("object"==typeof t)for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(t[r]=_s(t[r],e));return t}const Es=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Os=5;var ks;!function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"}(ks||(ks={}));class xs{constructor(t){this.replacer=t}encode(t){return t.type!==ks.EVENT&&t.type!==ks.ACK||!vs(t)?[this.encodeAsString(t)]:this.encodeAsBinary({type:t.type===ks.EVENT?ks.BINARY_EVENT:ks.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id})}encodeAsString(t){let e=""+t.type;return t.type!==ks.BINARY_EVENT&&t.type!==ks.BINARY_ACK||(e+=t.attachments+"-"),t.nsp&&"/"!==t.nsp&&(e+=t.nsp+","),null!=t.id&&(e+=t.id),null!=t.data&&(e+=JSON.stringify(t.data,this.replacer)),e}encodeAsBinary(t){const e=ms(t),r=this.encodeAsString(e.packet),n=e.buffers;return n.unshift(r),n}}function Ts(t){return"[object Object]"===Object.prototype.toString.call(t)}class As extends Bi{constructor(t){super(),this.reviver=t}add(t){let e;if("string"==typeof t){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");e=this.decodeString(t);const r=e.type===ks.BINARY_EVENT;r||e.type===ks.BINARY_ACK?(e.type=r?ks.EVENT:ks.ACK,this.reconstructor=new js(e),0===e.attachments&&super.emitReserved("decoded",e)):super.emitReserved("decoded",e)}else{if(!gs(t)&&!t.base64)throw new Error("Unknown type: "+t);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");e=this.reconstructor.takeBinaryData(t),e&&(this.reconstructor=null,super.emitReserved("decoded",e))}}decodeString(t){let e=0;const r={type:Number(t.charAt(0))};if(void 0===ks[r.type])throw new Error("unknown packet type "+r.type);if(r.type===ks.BINARY_EVENT||r.type===ks.BINARY_ACK){const n=e+1;for(;"-"!==t.charAt(++e)&&e!=t.length;);const i=t.substring(n,e);if(i!=Number(i)||"-"!==t.charAt(e))throw new Error("Illegal attachments");r.attachments=Number(i)}if("/"===t.charAt(e+1)){const n=e+1;for(;++e&&","!==t.charAt(e)&&e!==t.length;);r.nsp=t.substring(n,e)}else r.nsp="/";const n=t.charAt(e+1);if(""!==n&&Number(n)==n){const n=e+1;for(;++e;){const r=t.charAt(e);if(null==r||Number(r)!=r){--e;break}if(e===t.length)break}r.id=Number(t.substring(n,e+1))}if(t.charAt(++e)){const n=this.tryParse(t.substr(e));if(!As.isPayloadValid(r.type,n))throw new Error("invalid payload");r.data=n}return r}tryParse(t){try{return JSON.parse(t,this.reviver)}catch(t){return!1}}static isPayloadValid(t,e){switch(t){case ks.CONNECT:return Ts(e);case ks.DISCONNECT:return void 0===e;case ks.CONNECT_ERROR:return"string"==typeof e||Ts(e);case ks.EVENT:case ks.BINARY_EVENT:return Array.isArray(e)&&("number"==typeof e[0]||"string"==typeof e[0]&&-1===Es.indexOf(e[0]));case ks.ACK:case ks.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class js{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const t=Ss(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function Rs(t,e,r){return t.on(e,r),function(){t.off(e,r)}}const Cs=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Ls extends Bi{constructor(t,e,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Rs(t,"open",this.onopen.bind(this)),Rs(t,"packet",this.onpacket.bind(this)),Rs(t,"error",this.onerror.bind(this)),Rs(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...e){if(Cs.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(e.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(e),this;const r={type:ks.EVENT,data:e,options:{}};if(r.options.compress=!1!==this.flags.compress,"function"==typeof e[e.length-1]){const t=this.ids++,n=e.pop();this._registerAckCallback(t,n),r.id=t}const n=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!n||!this.connected)||(this.connected?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r)),this.flags={},this}_registerAckCallback(t,e){var r;const n=null!==(r=this.flags.timeout)&&void 0!==r?r:this._opts.ackTimeout;if(void 0===n)return void(this.acks[t]=e);const i=this.io.setTimeoutFn((()=>{delete this.acks[t];for(let e=0;e<this.sendBuffer.length;e++)this.sendBuffer[e].id===t&&this.sendBuffer.splice(e,1);e.call(this,new Error("operation has timed out"))}),n),s=(...t)=>{this.io.clearTimeoutFn(i),e.apply(this,t)};s.withError=!0,this.acks[t]=s}emitWithAck(t,...e){return new Promise(((r,n)=>{const i=(t,e)=>t?n(t):r(e);i.withError=!0,e.push(i),this.emit(t,...e)}))}_addToQueue(t){let e;"function"==typeof t[t.length-1]&&(e=t.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push(((t,...n)=>{if(r===this._queue[0])return null!==t?r.tryCount>this._opts.retries&&(this._queue.shift(),e&&e(t)):(this._queue.shift(),e&&e(null,...n)),r.pending=!1,this._drainQueue()})),this._queue.push(r),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||0===this._queue.length)return;const e=this._queue[0];e.pending&&!t||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){"function"==typeof this.auth?this.auth((t=>{this._sendConnectPacket(t)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:ks.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,e){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,e),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach((t=>{if(!this.sendBuffer.some((e=>String(e.id)===t))){const e=this.acks[t];delete this.acks[t],e.withError&&e.call(this,new Error("socket has been disconnected"))}}))}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case ks.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case ks.EVENT:case ks.BINARY_EVENT:this.onevent(t);break;case ks.ACK:case ks.BINARY_ACK:this.onack(t);break;case ks.DISCONNECT:this.ondisconnect();break;case ks.CONNECT_ERROR:this.destroy();const e=new Error(t.data.message);e.data=t.data.data,this.emitReserved("connect_error",e)}}onevent(t){const e=t.data||[];null!=t.id&&e.push(this.ack(t.id)),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const r of e)r.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&"string"==typeof t[t.length-1]&&(this._lastOffset=t[t.length-1])}ack(t){const e=this;let r=!1;return function(...n){r||(r=!0,e.packet({type:ks.ACK,id:t,data:n}))}}onack(t){const e=this.acks[t.id];"function"==typeof e&&(delete this.acks[t.id],e.withError&&t.data.unshift(null),e.apply(this,t.data))}onconnect(t,e){this.id=t,this.recovered=e&&this._pid===e,this._pid=e,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((t=>this.emitEvent(t))),this.receiveBuffer=[],this.sendBuffer.forEach((t=>{this.notifyOutgoingListeners(t),this.packet(t)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((t=>t())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:ks.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let r=0;r<e.length;r++)if(t===e[r])return e.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const e=this._anyOutgoingListeners;for(let r=0;r<e.length;r++)if(t===e[r])return e.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const e=this._anyOutgoingListeners.slice();for(const r of e)r.apply(this,t.data)}}}function Ds(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}Ds.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),r=Math.floor(e*this.jitter*t);t=1&Math.floor(10*e)?t+r:t-r}return 0|Math.min(t,this.max)},Ds.prototype.reset=function(){this.attempts=0},Ds.prototype.setMin=function(t){this.ms=t},Ds.prototype.setMax=function(t){this.max=t},Ds.prototype.setJitter=function(t){this.jitter=t};class Ps extends Bi{constructor(t,r){var n;super(),this.nsps={},this.subs=[],t&&"object"==typeof t&&(r=t,t=void 0),(r=r||{}).path=r.path||"/socket.io",this.opts=r,Ui(this,r),this.reconnection(!1!==r.reconnection),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(n=r.randomizationFactor)&&void 0!==n?n:.5),this.backoff=new Ds({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==r.timeout?2e4:r.timeout),this._readyState="closed",this.uri=t;const i=r.parser||e;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==r.autoConnect,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection}reconnectionAttempts(t){return void 0===t?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var e;return void 0===t?this._reconnectionDelay:(this._reconnectionDelay=t,null===(e=this.backoff)||void 0===e||e.setMin(t),this)}randomizationFactor(t){var e;return void 0===t?this._randomizationFactor:(this._randomizationFactor=t,null===(e=this.backoff)||void 0===e||e.setJitter(t),this)}reconnectionDelayMax(t){var e;return void 0===t?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,null===(e=this.backoff)||void 0===e||e.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new ls(this.uri,this.opts);const e=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const n=Rs(e,"open",(function(){r.onopen(),t&&t()})),i=e=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",e),t?t(e):this.maybeReconnectOnOpen()},s=Rs(e,"error",i);if(!1!==this._timeout){const t=this._timeout,r=this.setTimeoutFn((()=>{n(),i(new Error("timeout")),e.close()}),t);this.opts.autoUnref&&r.unref(),this.subs.push((()=>{this.clearTimeoutFn(r)}))}return this.subs.push(n),this.subs.push(s),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(Rs(t,"ping",this.onping.bind(this)),Rs(t,"data",this.ondata.bind(this)),Rs(t,"error",this.onerror.bind(this)),Rs(t,"close",this.onclose.bind(this)),Rs(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(t){this.onclose("parse error",t)}}ondecoded(t){is((()=>{this.emitReserved("packet",t)}),this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,e){let r=this.nsps[t];return r?this._autoConnect&&!r.active&&r.connect():(r=new Ls(this,t,e),this.nsps[t]=r),r}_destroy(t){const e=Object.keys(this.nsps);for(const t of e)if(this.nsps[t].active)return;this._close()}_packet(t){const e=this.encoder.encode(t);for(let r=0;r<e.length;r++)this.engine.write(e[r],t.options)}cleanup(){this.subs.forEach((t=>t())),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(t,e){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const e=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn((()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),t.skipReconnect||t.open((e=>{e?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",e)):t.onreconnect()})))}),e);this.opts.autoUnref&&r.unref(),this.subs.push((()=>{this.clearTimeoutFn(r)}))}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const Bs={};function Fs(t,e){"object"==typeof t&&(e=t,t=void 0);const r=function(t,e="",r){let n=t;r=r||"undefined"!=typeof location&&location,null==t&&(t=r.protocol+"//"+r.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?r.protocol+t:r.host+t),/^(https?|wss?):\/\//.test(t)||(t=void 0!==r?r.protocol+"//"+t:"https://"+t),n=hs(t)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const i=-1!==n.host.indexOf(":")?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+i+":"+n.port+e,n.href=n.protocol+"://"+i+(r&&r.port===n.port?"":":"+n.port),n}(t,(e=e||{}).path||"/socket.io"),n=r.source,i=r.id,s=r.path,o=Bs[i]&&s in Bs[i].nsps;let a;return e.forceNew||e["force new connection"]||!1===e.multiplex||o?a=new Ps(n,e):(Bs[i]||(Bs[i]=new Ps(n,e)),a=Bs[i]),r.query&&!e.query&&(e.query=r.queryKey),a.socket(r.path,e)}Object.assign(Fs,{Manager:Ps,Socket:Ls,io:Fs,connect:Fs});class zs{manager;token;endpoint;get socket(){return this.manager.socket("/proxy",{auth:{token:`Bearer ${this.token}`}})}constructor(t,e){this.endpoint=t.replace("https://","wss://").replace("http://","ws://"),this.token=e,this.manager=new Ps(this.endpoint,{reconnection:!1,rejectUnauthorized:!1,autoConnect:!0,transports:["websocket"]})}createManager(){const t=new Ps(this.endpoint,{reconnection:!1,rejectUnauthorized:!1,autoConnect:!0,transports:["websocket"],forceNew:!0}),e=t.socket("/proxy",{auth:{token:`Bearer ${this.token}`}});return{manager:t,socket:e}}sendRequest(t,e){return e=e||this.socket,new Promise(((r,n)=>{e.emit("request",t,(t=>{t.success?r(t.data):n(t.error)}))}))}close(){this.socket.emit("end"),this.socket.removeAllListeners(),this.socket.disconnect()}}class Ns{api;socketService;config;logger;token;deviceManager;pluginsManager;systemManager;constructor(t){this.config=t,this.logger=t.logger||{...console,attention:console.warn},this.api=new fe(t.endpoint)}async connect(){return this.deviceManager&&this.pluginsManager&&this.systemManager||(this.cleanUpClient(),await this.login(),this.token=this.token||this.config.token,this.socketService=new zs(this.config.endpoint,this.token),this.deviceManager=new di(this.socketService,this.logger),this.pluginsManager=new pi(this.socketService,this.logger),this.systemManager=new bi(this.socketService,this.logger),this.checkSession()),{deviceManager:this.deviceManager,pluginsManager:this.pluginsManager,systemManager:this.systemManager}}async disconnect(){this.socketService?.close(),this.cleanUpClient(),this.config.username&&this.config.password&&await this.api.interceptor.post("/auth/logout",void 0,{headers:{Authorization:`Bearer ${this.token}`}})}async updateCredentials(t){this.config={...this.config,...t},this.socketService&&await this.disconnect(),await this.connect()}async login(){if(this.config.username&&this.config.password)try{const t=await this.api.interceptor.post("/auth/login",{username:this.config.username,password:this.config.password});this.token=t.data.access_token}catch(t){throw 401===t.response?.status?new Error("Invalid credentials"):new Error(`Failed to get token: ${t.message}`)}else if(this.config.token&&!this.config.skipCheck)try{await this.api.interceptor.get("/auth/check",{headers:{Authorization:`Bearer ${this.config.token}`}})}catch(t){throw new Error(`Invalid token: ${t.message}`)}this.token=this.token||this.config.token}getDeviceManager(){return this.deviceManager}getPluginsManager(){return this.pluginsManager}getSystemManager(){return this.systemManager}checkSession(){this.socketService?.socket.removeListener("invalidToken"),this.socketService?.socket.on("invalidToken",(async t=>{t===this.token&&await this.disconnect()}))}cleanUpClient(){this.deviceManager=void 0,this.pluginsManager=void 0,this.systemManager=void 0}}})();var i=n.j;export{i as CameraUiClient};
|
|
1
|
+
var t={d:(e,s)=>{for(var r in s)t.o(s,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:s[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.d(e,{j:()=>wi});var s={};t.r(s),t.d(s,{hasBrowserEnv:()=>ot,hasStandardBrowserEnv:()=>at,hasStandardBrowserWebWorkerEnv:()=>ht,origin:()=>ut});var r={};function i(t,e){return function(){return t.apply(e,arguments)}}t.r(r),t.d(r,{Decoder:()=>ui,Encoder:()=>ci,PacketType:()=>ai,protocol:()=>oi});const{toString:n}=Object.prototype,{getPrototypeOf:o}=Object,a=(t=>e=>{const s=n.call(e);return t[s]||(t[s]=s.slice(8,-1).toLowerCase())})(Object.create(null)),c=t=>(t=t.toLowerCase(),e=>a(e)===t),h=t=>e=>typeof e===t,{isArray:u}=Array,l=h("undefined"),d=c("ArrayBuffer"),f=h("string"),p=h("function"),g=h("number"),m=t=>null!==t&&"object"==typeof t,y=t=>{if("object"!==a(t))return!1;const e=o(t);return!(null!==e&&e!==Object.prototype&&null!==Object.getPrototypeOf(e)||Symbol.toStringTag in t||Symbol.iterator in t)},b=c("Date"),v=c("File"),w=c("Blob"),S=c("FileList"),k=c("URLSearchParams"),[E,_,O,T]=["ReadableStream","Request","Response","Headers"].map(c);function x(t,e,{allOwnKeys:s=!1}={}){if(null==t)return;let r,i;if("object"!=typeof t&&(t=[t]),u(t))for(r=0,i=t.length;r<i;r++)e.call(null,t[r],r,t);else{const i=s?Object.getOwnPropertyNames(t):Object.keys(t),n=i.length;let o;for(r=0;r<n;r++)o=i[r],e.call(null,t[o],o,t)}}function A(t,e){e=e.toLowerCase();const s=Object.keys(t);let r,i=s.length;for(;i-- >0;)if(r=s[i],e===r.toLowerCase())return r;return null}const R="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,L=t=>!l(t)&&t!==R,C=(j="undefined"!=typeof Uint8Array&&o(Uint8Array),t=>j&&t instanceof j);var j;const B=c("HTMLFormElement"),P=(({hasOwnProperty:t})=>(e,s)=>t.call(e,s))(Object.prototype),D=c("RegExp"),F=(t,e)=>{const s=Object.getOwnPropertyDescriptors(t),r={};x(s,((s,i)=>{let n;!1!==(n=e(s,i,t))&&(r[i]=n||s)})),Object.defineProperties(t,r)},N="abcdefghijklmnopqrstuvwxyz",M="0123456789",I={DIGIT:M,ALPHA:N,ALPHA_DIGIT:N+N.toUpperCase()+M},z=c("AsyncFunction"),q={isArray:u,isArrayBuffer:d,isBuffer:function(t){return null!==t&&!l(t)&&null!==t.constructor&&!l(t.constructor)&&p(t.constructor.isBuffer)&&t.constructor.isBuffer(t)},isFormData:t=>{let e;return t&&("function"==typeof FormData&&t instanceof FormData||p(t.append)&&("formdata"===(e=a(t))||"object"===e&&p(t.toString)&&"[object FormData]"===t.toString()))},isArrayBufferView:function(t){let e;return e="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&d(t.buffer),e},isString:f,isNumber:g,isBoolean:t=>!0===t||!1===t,isObject:m,isPlainObject:y,isReadableStream:E,isRequest:_,isResponse:O,isHeaders:T,isUndefined:l,isDate:b,isFile:v,isBlob:w,isRegExp:D,isFunction:p,isStream:t=>m(t)&&p(t.pipe),isURLSearchParams:k,isTypedArray:C,isFileList:S,forEach:x,merge:function t(){const{caseless:e}=L(this)&&this||{},s={},r=(r,i)=>{const n=e&&A(s,i)||i;y(s[n])&&y(r)?s[n]=t(s[n],r):y(r)?s[n]=t({},r):u(r)?s[n]=r.slice():s[n]=r};for(let t=0,e=arguments.length;t<e;t++)arguments[t]&&x(arguments[t],r);return s},extend:(t,e,s,{allOwnKeys:r}={})=>(x(e,((e,r)=>{s&&p(e)?t[r]=i(e,s):t[r]=e}),{allOwnKeys:r}),t),trim:t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:t=>(65279===t.charCodeAt(0)&&(t=t.slice(1)),t),inherits:(t,e,s,r)=>{t.prototype=Object.create(e.prototype,r),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),s&&Object.assign(t.prototype,s)},toFlatObject:(t,e,s,r)=>{let i,n,a;const c={};if(e=e||{},null==t)return e;do{for(i=Object.getOwnPropertyNames(t),n=i.length;n-- >0;)a=i[n],r&&!r(a,t,e)||c[a]||(e[a]=t[a],c[a]=!0);t=!1!==s&&o(t)}while(t&&(!s||s(t,e))&&t!==Object.prototype);return e},kindOf:a,kindOfTest:c,endsWith:(t,e,s)=>{t=String(t),(void 0===s||s>t.length)&&(s=t.length),s-=e.length;const r=t.indexOf(e,s);return-1!==r&&r===s},toArray:t=>{if(!t)return null;if(u(t))return t;let e=t.length;if(!g(e))return null;const s=new Array(e);for(;e-- >0;)s[e]=t[e];return s},forEachEntry:(t,e)=>{const s=(t&&t[Symbol.iterator]).call(t);let r;for(;(r=s.next())&&!r.done;){const s=r.value;e.call(t,s[0],s[1])}},matchAll:(t,e)=>{let s;const r=[];for(;null!==(s=t.exec(e));)r.push(s);return r},isHTMLForm:B,hasOwnProperty:P,hasOwnProp:P,reduceDescriptors:F,freezeMethods:t=>{F(t,((e,s)=>{if(p(t)&&-1!==["arguments","caller","callee"].indexOf(s))return!1;const r=t[s];p(r)&&(e.enumerable=!1,"writable"in e?e.writable=!1:e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")}))}))},toObjectSet:(t,e)=>{const s={},r=t=>{t.forEach((t=>{s[t]=!0}))};return u(t)?r(t):r(String(t).split(e)),s},toCamelCase:t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(t,e,s){return e.toUpperCase()+s})),noop:()=>{},toFiniteNumber:(t,e)=>null!=t&&Number.isFinite(t=+t)?t:e,findKey:A,global:R,isContextDefined:L,ALPHABET:I,generateString:(t=16,e=I.ALPHA_DIGIT)=>{let s="";const{length:r}=e;for(;t--;)s+=e[Math.random()*r|0];return s},isSpecCompliantForm:function(t){return!!(t&&p(t.append)&&"FormData"===t[Symbol.toStringTag]&&t[Symbol.iterator])},toJSONObject:t=>{const e=new Array(10),s=(t,r)=>{if(m(t)){if(e.indexOf(t)>=0)return;if(!("toJSON"in t)){e[r]=t;const i=u(t)?[]:{};return x(t,((t,e)=>{const n=s(t,r+1);!l(n)&&(i[e]=n)})),e[r]=void 0,i}}return t};return s(t,0)},isAsyncFn:z,isThenable:t=>t&&(m(t)||p(t))&&p(t.then)&&p(t.catch)};function U(t,e,s,r,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=t,this.name="AxiosError",e&&(this.code=e),s&&(this.config=s),r&&(this.request=r),i&&(this.response=i)}q.inherits(U,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:q.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const V=U.prototype,W={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((t=>{W[t]={value:t}})),Object.defineProperties(U,W),Object.defineProperty(V,"isAxiosError",{value:!0}),U.from=(t,e,s,r,i,n)=>{const o=Object.create(V);return q.toFlatObject(t,o,(function(t){return t!==Error.prototype}),(t=>"isAxiosError"!==t)),U.call(o,t.message,e,s,r,i),o.cause=t,o.name=t.name,n&&Object.assign(o,n),o};const H=U;function $(t){return q.isPlainObject(t)||q.isArray(t)}function J(t){return q.endsWith(t,"[]")?t.slice(0,-2):t}function G(t,e,s){return t?t.concat(e).map((function(t,e){return t=J(t),!s&&e?"["+t+"]":t})).join(s?".":""):e}const K=q.toFlatObject(q,{},null,(function(t){return/^is[A-Z]/.test(t)})),Y=function(t,e,s){if(!q.isObject(t))throw new TypeError("target must be an object");e=e||new FormData;const r=(s=q.toFlatObject(s,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(t,e){return!q.isUndefined(e[t])}))).metaTokens,i=s.visitor||h,n=s.dots,o=s.indexes,a=(s.Blob||"undefined"!=typeof Blob&&Blob)&&q.isSpecCompliantForm(e);if(!q.isFunction(i))throw new TypeError("visitor must be a function");function c(t){if(null===t)return"";if(q.isDate(t))return t.toISOString();if(!a&&q.isBlob(t))throw new H("Blob is not supported. Use a Buffer instead.");return q.isArrayBuffer(t)||q.isTypedArray(t)?a&&"function"==typeof Blob?new Blob([t]):Buffer.from(t):t}function h(t,s,i){let a=t;if(t&&!i&&"object"==typeof t)if(q.endsWith(s,"{}"))s=r?s:s.slice(0,-2),t=JSON.stringify(t);else if(q.isArray(t)&&function(t){return q.isArray(t)&&!t.some($)}(t)||(q.isFileList(t)||q.endsWith(s,"[]"))&&(a=q.toArray(t)))return s=J(s),a.forEach((function(t,r){!q.isUndefined(t)&&null!==t&&e.append(!0===o?G([s],r,n):null===o?s:s+"[]",c(t))})),!1;return!!$(t)||(e.append(G(i,s,n),c(t)),!1)}const u=[],l=Object.assign(K,{defaultVisitor:h,convertValue:c,isVisitable:$});if(!q.isObject(t))throw new TypeError("data must be an object");return function t(s,r){if(!q.isUndefined(s)){if(-1!==u.indexOf(s))throw Error("Circular reference detected in "+r.join("."));u.push(s),q.forEach(s,(function(s,n){!0===(!(q.isUndefined(s)||null===s)&&i.call(e,s,q.isString(n)?n.trim():n,r,l))&&t(s,r?r.concat(n):[n])})),u.pop()}}(t),e};function X(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,(function(t){return e[t]}))}function Q(t,e){this._pairs=[],t&&Y(t,this,e)}const Z=Q.prototype;Z.append=function(t,e){this._pairs.push([t,e])},Z.toString=function(t){const e=t?function(e){return t.call(this,e,X)}:X;return this._pairs.map((function(t){return e(t[0])+"="+e(t[1])}),"").join("&")};const tt=Q;function et(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function st(t,e,s){if(!e)return t;const r=s&&s.encode||et,i=s&&s.serialize;let n;if(n=i?i(e,s):q.isURLSearchParams(e)?e.toString():new tt(e,s).toString(r),n){const e=t.indexOf("#");-1!==e&&(t=t.slice(0,e)),t+=(-1===t.indexOf("?")?"?":"&")+n}return t}const rt=class{constructor(){this.handlers=[]}use(t,e,s){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!s&&s.synchronous,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){q.forEach(this.handlers,(function(e){null!==e&&t(e)}))}},it={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},nt={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:tt,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},ot="undefined"!=typeof window&&"undefined"!=typeof document,at=(ct="undefined"!=typeof navigator&&navigator.product,ot&&["ReactNative","NativeScript","NS"].indexOf(ct)<0);var ct;const ht="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,ut=ot&&window.location.href||"http://localhost",lt={...s,...nt},dt=function(t){function e(t,s,r,i){let n=t[i++];if("__proto__"===n)return!0;const o=Number.isFinite(+n),a=i>=t.length;return n=!n&&q.isArray(r)?r.length:n,a?(q.hasOwnProp(r,n)?r[n]=[r[n],s]:r[n]=s,!o):(r[n]&&q.isObject(r[n])||(r[n]=[]),e(t,s,r[n],i)&&q.isArray(r[n])&&(r[n]=function(t){const e={},s=Object.keys(t);let r;const i=s.length;let n;for(r=0;r<i;r++)n=s[r],e[n]=t[n];return e}(r[n])),!o)}if(q.isFormData(t)&&q.isFunction(t.entries)){const s={};return q.forEachEntry(t,((t,r)=>{e(function(t){return q.matchAll(/\w+|\[(\w*)]/g,t).map((t=>"[]"===t[0]?"":t[1]||t[0]))}(t),r,s,0)})),s}return null},ft={transitional:it,adapter:["xhr","http","fetch"],transformRequest:[function(t,e){const s=e.getContentType()||"",r=s.indexOf("application/json")>-1,i=q.isObject(t);if(i&&q.isHTMLForm(t)&&(t=new FormData(t)),q.isFormData(t))return r?JSON.stringify(dt(t)):t;if(q.isArrayBuffer(t)||q.isBuffer(t)||q.isStream(t)||q.isFile(t)||q.isBlob(t)||q.isReadableStream(t))return t;if(q.isArrayBufferView(t))return t.buffer;if(q.isURLSearchParams(t))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let n;if(i){if(s.indexOf("application/x-www-form-urlencoded")>-1)return function(t,e){return Y(t,new lt.classes.URLSearchParams,Object.assign({visitor:function(t,e,s,r){return lt.isNode&&q.isBuffer(t)?(this.append(e,t.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},e))}(t,this.formSerializer).toString();if((n=q.isFileList(t))||s.indexOf("multipart/form-data")>-1){const e=this.env&&this.env.FormData;return Y(n?{"files[]":t}:t,e&&new e,this.formSerializer)}}return i||r?(e.setContentType("application/json",!1),function(t,e,s){if(q.isString(t))try{return(0,JSON.parse)(t),q.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(0,JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){const e=this.transitional||ft.transitional,s=e&&e.forcedJSONParsing,r="json"===this.responseType;if(q.isResponse(t)||q.isReadableStream(t))return t;if(t&&q.isString(t)&&(s&&!this.responseType||r)){const s=!(e&&e.silentJSONParsing)&&r;try{return JSON.parse(t)}catch(t){if(s){if("SyntaxError"===t.name)throw H.from(t,H.ERR_BAD_RESPONSE,this,null,this.response);throw t}}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:lt.classes.FormData,Blob:lt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};q.forEach(["delete","get","head","post","put","patch"],(t=>{ft.headers[t]={}}));const pt=ft,gt=q.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"]),mt=Symbol("internals");function yt(t){return t&&String(t).trim().toLowerCase()}function bt(t){return!1===t||null==t?t:q.isArray(t)?t.map(bt):String(t)}function vt(t,e,s,r,i){return q.isFunction(r)?r.call(this,e,s):(i&&(e=s),q.isString(e)?q.isString(r)?-1!==e.indexOf(r):q.isRegExp(r)?r.test(e):void 0:void 0)}class wt{constructor(t){t&&this.set(t)}set(t,e,s){const r=this;function i(t,e,s){const i=yt(e);if(!i)throw new Error("header name must be a non-empty string");const n=q.findKey(r,i);(!n||void 0===r[n]||!0===s||void 0===s&&!1!==r[n])&&(r[n||e]=bt(t))}const n=(t,e)=>q.forEach(t,((t,s)=>i(t,s,e)));if(q.isPlainObject(t)||t instanceof this.constructor)n(t,e);else if(q.isString(t)&&(t=t.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim()))n((t=>{const e={};let s,r,i;return t&&t.split("\n").forEach((function(t){i=t.indexOf(":"),s=t.substring(0,i).trim().toLowerCase(),r=t.substring(i+1).trim(),!s||e[s]&>[s]||("set-cookie"===s?e[s]?e[s].push(r):e[s]=[r]:e[s]=e[s]?e[s]+", "+r:r)})),e})(t),e);else if(q.isHeaders(t))for(const[e,r]of t.entries())i(r,e,s);else null!=t&&i(e,t,s);return this}get(t,e){if(t=yt(t)){const s=q.findKey(this,t);if(s){const t=this[s];if(!e)return t;if(!0===e)return function(t){const e=Object.create(null),s=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=s.exec(t);)e[r[1]]=r[2];return e}(t);if(q.isFunction(e))return e.call(this,t,s);if(q.isRegExp(e))return e.exec(t);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){if(t=yt(t)){const s=q.findKey(this,t);return!(!s||void 0===this[s]||e&&!vt(0,this[s],s,e))}return!1}delete(t,e){const s=this;let r=!1;function i(t){if(t=yt(t)){const i=q.findKey(s,t);!i||e&&!vt(0,s[i],i,e)||(delete s[i],r=!0)}}return q.isArray(t)?t.forEach(i):i(t),r}clear(t){const e=Object.keys(this);let s=e.length,r=!1;for(;s--;){const i=e[s];t&&!vt(0,this[i],i,t,!0)||(delete this[i],r=!0)}return r}normalize(t){const e=this,s={};return q.forEach(this,((r,i)=>{const n=q.findKey(s,i);if(n)return e[n]=bt(r),void delete e[i];const o=t?function(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((t,e,s)=>e.toUpperCase()+s))}(i):String(i).trim();o!==i&&delete e[i],e[o]=bt(r),s[o]=!0})),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);return q.forEach(this,((s,r)=>{null!=s&&!1!==s&&(e[r]=t&&q.isArray(s)?s.join(", "):s)})),e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([t,e])=>t+": "+e)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...e){const s=new this(t);return e.forEach((t=>s.set(t))),s}static accessor(t){const e=(this[mt]=this[mt]={accessors:{}}).accessors,s=this.prototype;function r(t){const r=yt(t);e[r]||(function(t,e){const s=q.toCamelCase(" "+e);["get","set","has"].forEach((r=>{Object.defineProperty(t,r+s,{value:function(t,s,i){return this[r].call(this,e,t,s,i)},configurable:!0})}))}(s,t),e[r]=!0)}return q.isArray(t)?t.forEach(r):r(t),this}}wt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),q.reduceDescriptors(wt.prototype,(({value:t},e)=>{let s=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(t){this[s]=t}}})),q.freezeMethods(wt);const St=wt;function kt(t,e){const s=this||pt,r=e||s,i=St.from(r.headers);let n=r.data;return q.forEach(t,(function(t){n=t.call(s,n,i.normalize(),e?e.status:void 0)})),i.normalize(),n}function Et(t){return!(!t||!t.__CANCEL__)}function _t(t,e,s){H.call(this,null==t?"canceled":t,H.ERR_CANCELED,e,s),this.name="CanceledError"}q.inherits(_t,H,{__CANCEL__:!0});const Ot=_t;function Tt(t,e,s){const r=s.config.validateStatus;s.status&&r&&!r(s.status)?e(new H("Request failed with status code "+s.status,[H.ERR_BAD_REQUEST,H.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s)):t(s)}const xt=(t,e,s=3)=>{let r=0;const i=function(t,e){t=t||10;const s=new Array(t),r=new Array(t);let i,n=0,o=0;return e=void 0!==e?e:1e3,function(a){const c=Date.now(),h=r[o];i||(i=c),s[n]=a,r[n]=c;let u=o,l=0;for(;u!==n;)l+=s[u++],u%=t;if(n=(n+1)%t,n===o&&(o=(o+1)%t),c-i<e)return;const d=h&&c-h;return d?Math.round(1e3*l/d):void 0}}(50,250);return function(t,e){let s=0;const r=1e3/e;let i=null;return function(){const e=!0===this,n=Date.now();if(e||n-s>r)return i&&(clearTimeout(i),i=null),s=n,t.apply(null,arguments);i||(i=setTimeout((()=>(i=null,s=Date.now(),t.apply(null,arguments))),r-(n-s)))}}((s=>{const n=s.loaded,o=s.lengthComputable?s.total:void 0,a=n-r,c=i(a);r=n;const h={loaded:n,total:o,progress:o?n/o:void 0,bytes:a,rate:c||void 0,estimated:c&&o&&n<=o?(o-n)/c:void 0,event:s,lengthComputable:null!=o};h[e?"download":"upload"]=!0,t(h)}),s)},At=lt.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),e=document.createElement("a");let s;function r(s){let r=s;return t&&(e.setAttribute("href",r),r=e.href),e.setAttribute("href",r),{href:e.href,protocol:e.protocol?e.protocol.replace(/:$/,""):"",host:e.host,search:e.search?e.search.replace(/^\?/,""):"",hash:e.hash?e.hash.replace(/^#/,""):"",hostname:e.hostname,port:e.port,pathname:"/"===e.pathname.charAt(0)?e.pathname:"/"+e.pathname}}return s=r(window.location.href),function(t){const e=q.isString(t)?r(t):t;return e.protocol===s.protocol&&e.host===s.host}}():function(){return!0},Rt=lt.hasStandardBrowserEnv?{write(t,e,s,r,i,n){const o=[t+"="+encodeURIComponent(e)];q.isNumber(s)&&o.push("expires="+new Date(s).toGMTString()),q.isString(r)&&o.push("path="+r),q.isString(i)&&o.push("domain="+i),!0===n&&o.push("secure"),document.cookie=o.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Lt(t,e){return t&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)?function(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}(t,e):e}const Ct=t=>t instanceof St?{...t}:t;function jt(t,e){e=e||{};const s={};function r(t,e,s){return q.isPlainObject(t)&&q.isPlainObject(e)?q.merge.call({caseless:s},t,e):q.isPlainObject(e)?q.merge({},e):q.isArray(e)?e.slice():e}function i(t,e,s){return q.isUndefined(e)?q.isUndefined(t)?void 0:r(void 0,t,s):r(t,e,s)}function n(t,e){if(!q.isUndefined(e))return r(void 0,e)}function o(t,e){return q.isUndefined(e)?q.isUndefined(t)?void 0:r(void 0,t):r(void 0,e)}function a(s,i,n){return n in e?r(s,i):n in t?r(void 0,s):void 0}const c={url:n,method:n,data:n,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:a,headers:(t,e)=>i(Ct(t),Ct(e),!0)};return q.forEach(Object.keys(Object.assign({},t,e)),(function(r){const n=c[r]||i,o=n(t[r],e[r],r);q.isUndefined(o)&&n!==a||(s[r]=o)})),s}const Bt=t=>{const e=jt({},t);let s,{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:o,headers:a,auth:c}=e;if(e.headers=a=St.from(a),e.url=st(Lt(e.baseURL,e.url),t.params,t.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),q.isFormData(r))if(lt.hasStandardBrowserEnv||lt.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(!1!==(s=a.getContentType())){const[t,...e]=s?s.split(";").map((t=>t.trim())).filter(Boolean):[];a.setContentType([t||"multipart/form-data",...e].join("; "))}if(lt.hasStandardBrowserEnv&&(i&&q.isFunction(i)&&(i=i(e)),i||!1!==i&&At(e.url))){const t=n&&o&&Rt.read(o);t&&a.set(n,t)}return e},Pt="undefined"!=typeof XMLHttpRequest&&function(t){return new Promise((function(e,s){const r=Bt(t);let i=r.data;const n=St.from(r.headers).normalize();let o,{responseType:a}=r;function c(){r.cancelToken&&r.cancelToken.unsubscribe(o),r.signal&&r.signal.removeEventListener("abort",o)}let h=new XMLHttpRequest;function u(){if(!h)return;const r=St.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders());Tt((function(t){e(t),c()}),(function(t){s(t),c()}),{data:a&&"text"!==a&&"json"!==a?h.response:h.responseText,status:h.status,statusText:h.statusText,headers:r,config:t,request:h}),h=null}h.open(r.method.toUpperCase(),r.url,!0),h.timeout=r.timeout,"onloadend"in h?h.onloadend=u:h.onreadystatechange=function(){h&&4===h.readyState&&(0!==h.status||h.responseURL&&0===h.responseURL.indexOf("file:"))&&setTimeout(u)},h.onabort=function(){h&&(s(new H("Request aborted",H.ECONNABORTED,r,h)),h=null)},h.onerror=function(){s(new H("Network Error",H.ERR_NETWORK,r,h)),h=null},h.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const e=r.transitional||it;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),s(new H(t,e.clarifyTimeoutError?H.ETIMEDOUT:H.ECONNABORTED,r,h)),h=null},void 0===i&&n.setContentType(null),"setRequestHeader"in h&&q.forEach(n.toJSON(),(function(t,e){h.setRequestHeader(e,t)})),q.isUndefined(r.withCredentials)||(h.withCredentials=!!r.withCredentials),a&&"json"!==a&&(h.responseType=r.responseType),"function"==typeof r.onDownloadProgress&&h.addEventListener("progress",xt(r.onDownloadProgress,!0)),"function"==typeof r.onUploadProgress&&h.upload&&h.upload.addEventListener("progress",xt(r.onUploadProgress)),(r.cancelToken||r.signal)&&(o=e=>{h&&(s(!e||e.type?new Ot(null,t,h):e),h.abort(),h=null)},r.cancelToken&&r.cancelToken.subscribe(o),r.signal&&(r.signal.aborted?o():r.signal.addEventListener("abort",o)));const l=function(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}(r.url);l&&-1===lt.protocols.indexOf(l)?s(new H("Unsupported protocol "+l+":",H.ERR_BAD_REQUEST,t)):h.send(i||null)}))},Dt=(t,e)=>{let s,r=new AbortController;const i=function(t){if(!s){s=!0,o();const e=t instanceof Error?t:this.reason;r.abort(e instanceof H?e:new Ot(e instanceof Error?e.message:e))}};let n=e&&setTimeout((()=>{i(new H(`timeout ${e} of ms exceeded`,H.ETIMEDOUT))}),e);const o=()=>{t&&(n&&clearTimeout(n),n=null,t.forEach((t=>{t&&(t.removeEventListener?t.removeEventListener("abort",i):t.unsubscribe(i))})),t=null)};t.forEach((t=>t&&t.addEventListener&&t.addEventListener("abort",i)));const{signal:a}=r;return a.unsubscribe=o,[a,()=>{n&&clearTimeout(n),n=null}]},Ft=function*(t,e){let s=t.byteLength;if(!e||s<e)return void(yield t);let r,i=0;for(;i<s;)r=i+e,yield t.slice(i,r),i=r},Nt=(t,e,s,r,i)=>{const n=async function*(t,e,s){for await(const r of t)yield*Ft(ArrayBuffer.isView(r)?r:await s(String(r)),e)}(t,e,i);let o=0;return new ReadableStream({type:"bytes",async pull(t){const{done:e,value:i}=await n.next();if(e)return t.close(),void r();let a=i.byteLength;s&&s(o+=a),t.enqueue(new Uint8Array(i))},cancel:t=>(r(t),n.return())},{highWaterMark:2})},Mt=(t,e)=>{const s=null!=t;return r=>setTimeout((()=>e({lengthComputable:s,total:t,loaded:r})))},It="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,zt=It&&"function"==typeof ReadableStream,qt=It&&("function"==typeof TextEncoder?(Ut=new TextEncoder,t=>Ut.encode(t)):async t=>new Uint8Array(await new Response(t).arrayBuffer()));var Ut;const Vt=zt&&(()=>{let t=!1;const e=new Request(lt.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e})(),Wt=zt&&!!(()=>{try{return q.isReadableStream(new Response("").body)}catch(t){}})(),Ht={stream:Wt&&(t=>t.body)};var $t;It&&($t=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((t=>{!Ht[t]&&(Ht[t]=q.isFunction($t[t])?e=>e[t]():(e,s)=>{throw new H(`Response type '${t}' is not supported`,H.ERR_NOT_SUPPORT,s)})})));const Jt=It&&(async t=>{let{url:e,method:s,data:r,signal:i,cancelToken:n,timeout:o,onDownloadProgress:a,onUploadProgress:c,responseType:h,headers:u,withCredentials:l="same-origin",fetchOptions:d}=Bt(t);h=h?(h+"").toLowerCase():"text";let f,p,[g,m]=i||n||o?Dt([i,n],o):[];const y=()=>{!f&&setTimeout((()=>{g&&g.unsubscribe()})),f=!0};let b;try{if(c&&Vt&&"get"!==s&&"head"!==s&&0!==(b=await(async(t,e)=>{const s=q.toFiniteNumber(t.getContentLength());return null==s?(async t=>null==t?0:q.isBlob(t)?t.size:q.isSpecCompliantForm(t)?(await new Request(t).arrayBuffer()).byteLength:q.isArrayBufferView(t)?t.byteLength:(q.isURLSearchParams(t)&&(t+=""),q.isString(t)?(await qt(t)).byteLength:void 0))(e):s})(u,r))){let t,s=new Request(e,{method:"POST",body:r,duplex:"half"});q.isFormData(r)&&(t=s.headers.get("content-type"))&&u.setContentType(t),s.body&&(r=Nt(s.body,65536,Mt(b,xt(c)),null,qt))}q.isString(l)||(l=l?"cors":"omit"),p=new Request(e,{...d,signal:g,method:s.toUpperCase(),headers:u.normalize().toJSON(),body:r,duplex:"half",withCredentials:l});let i=await fetch(p);const n=Wt&&("stream"===h||"response"===h);if(Wt&&(a||n)){const t={};["status","statusText","headers"].forEach((e=>{t[e]=i[e]}));const e=q.toFiniteNumber(i.headers.get("content-length"));i=new Response(Nt(i.body,65536,a&&Mt(e,xt(a,!0)),n&&y,qt),t)}h=h||"text";let o=await Ht[q.findKey(Ht,h)||"text"](i,t);return!n&&y(),m&&m(),await new Promise(((e,s)=>{Tt(e,s,{data:o,headers:St.from(i.headers),status:i.status,statusText:i.statusText,config:t,request:p})}))}catch(e){if(y(),e&&"TypeError"===e.name&&/fetch/i.test(e.message))throw Object.assign(new H("Network Error",H.ERR_NETWORK,t,p),{cause:e.cause||e});throw H.from(e,e&&e.code,t,p)}}),Gt={http:null,xhr:Pt,fetch:Jt};q.forEach(Gt,((t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch(t){}Object.defineProperty(t,"adapterName",{value:e})}}));const Kt=t=>`- ${t}`,Yt=t=>q.isFunction(t)||null===t||!1===t,Xt=t=>{t=q.isArray(t)?t:[t];const{length:e}=t;let s,r;const i={};for(let n=0;n<e;n++){let e;if(s=t[n],r=s,!Yt(s)&&(r=Gt[(e=String(s)).toLowerCase()],void 0===r))throw new H(`Unknown adapter '${e}'`);if(r)break;i[e||"#"+n]=r}if(!r){const t=Object.entries(i).map((([t,e])=>`adapter ${t} `+(!1===e?"is not supported by the environment":"is not available in the build")));let s=e?t.length>1?"since :\n"+t.map(Kt).join("\n"):" "+Kt(t[0]):"as no adapter specified";throw new H("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return r};function Qt(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Ot(null,t)}function Zt(t){return Qt(t),t.headers=St.from(t.headers),t.data=kt.call(t,t.transformRequest),-1!==["post","put","patch"].indexOf(t.method)&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Xt(t.adapter||pt.adapter)(t).then((function(e){return Qt(t),e.data=kt.call(t,t.transformResponse,e),e.headers=St.from(e.headers),e}),(function(e){return Et(e)||(Qt(t),e&&e.response&&(e.response.data=kt.call(t,t.transformResponse,e.response),e.response.headers=St.from(e.response.headers))),Promise.reject(e)}))}const te={};["object","boolean","number","function","string","symbol"].forEach(((t,e)=>{te[t]=function(s){return typeof s===t||"a"+(e<1?"n ":" ")+t}}));const ee={};te.transitional=function(t,e,s){function r(t,e){return"[Axios v1.7.2] Transitional option '"+t+"'"+e+(s?". "+s:"")}return(s,i,n)=>{if(!1===t)throw new H(r(i," has been removed"+(e?" in "+e:"")),H.ERR_DEPRECATED);return e&&!ee[i]&&(ee[i]=!0,console.warn(r(i," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(s,i,n)}};const se={assertOptions:function(t,e,s){if("object"!=typeof t)throw new H("options must be an object",H.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let i=r.length;for(;i-- >0;){const n=r[i],o=e[n];if(o){const e=t[n],s=void 0===e||o(e,n,t);if(!0!==s)throw new H("option "+n+" must be "+s,H.ERR_BAD_OPTION_VALUE)}else if(!0!==s)throw new H("Unknown option "+n,H.ERR_BAD_OPTION)}},validators:te},re=se.validators;class ie{constructor(t){this.defaults=t,this.interceptors={request:new rt,response:new rt}}async request(t,e){try{return await this._request(t,e)}catch(t){if(t instanceof Error){let e;Error.captureStackTrace?Error.captureStackTrace(e={}):e=new Error;const s=e.stack?e.stack.replace(/^.+\n/,""):"";try{t.stack?s&&!String(t.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(t.stack+="\n"+s):t.stack=s}catch(t){}}throw t}}_request(t,e){"string"==typeof t?(e=e||{}).url=t:e=t||{},e=jt(this.defaults,e);const{transitional:s,paramsSerializer:r,headers:i}=e;void 0!==s&&se.assertOptions(s,{silentJSONParsing:re.transitional(re.boolean),forcedJSONParsing:re.transitional(re.boolean),clarifyTimeoutError:re.transitional(re.boolean)},!1),null!=r&&(q.isFunction(r)?e.paramsSerializer={serialize:r}:se.assertOptions(r,{encode:re.function,serialize:re.function},!0)),e.method=(e.method||this.defaults.method||"get").toLowerCase();let n=i&&q.merge(i.common,i[e.method]);i&&q.forEach(["delete","get","head","post","put","patch","common"],(t=>{delete i[t]})),e.headers=St.concat(n,i);const o=[];let a=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(a=a&&t.synchronous,o.unshift(t.fulfilled,t.rejected))}));const c=[];let h;this.interceptors.response.forEach((function(t){c.push(t.fulfilled,t.rejected)}));let u,l=0;if(!a){const t=[Zt.bind(this),void 0];for(t.unshift.apply(t,o),t.push.apply(t,c),u=t.length,h=Promise.resolve(e);l<u;)h=h.then(t[l++],t[l++]);return h}u=o.length;let d=e;for(l=0;l<u;){const t=o[l++],e=o[l++];try{d=t(d)}catch(t){e.call(this,t);break}}try{h=Zt.call(this,d)}catch(t){return Promise.reject(t)}for(l=0,u=c.length;l<u;)h=h.then(c[l++],c[l++]);return h}getUri(t){return st(Lt((t=jt(this.defaults,t)).baseURL,t.url),t.params,t.paramsSerializer)}}q.forEach(["delete","get","head","options"],(function(t){ie.prototype[t]=function(e,s){return this.request(jt(s||{},{method:t,url:e,data:(s||{}).data}))}})),q.forEach(["post","put","patch"],(function(t){function e(e){return function(s,r,i){return this.request(jt(i||{},{method:t,headers:e?{"Content-Type":"multipart/form-data"}:{},url:s,data:r}))}}ie.prototype[t]=e(),ie.prototype[t+"Form"]=e(!0)}));const ne=ie;class oe{constructor(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");let e;this.promise=new Promise((function(t){e=t}));const s=this;this.promise.then((t=>{if(!s._listeners)return;let e=s._listeners.length;for(;e-- >0;)s._listeners[e](t);s._listeners=null})),this.promise.then=t=>{let e;const r=new Promise((t=>{s.subscribe(t),e=t})).then(t);return r.cancel=function(){s.unsubscribe(e)},r},t((function(t,r,i){s.reason||(s.reason=new Ot(t,r,i),e(s.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}static source(){let t;return{token:new oe((function(e){t=e})),cancel:t}}}const ae=oe,ce={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(ce).forEach((([t,e])=>{ce[e]=t}));const he=ce,ue=function t(e){const s=new ne(e),r=i(ne.prototype.request,s);return q.extend(r,ne.prototype,s,{allOwnKeys:!0}),q.extend(r,s,null,{allOwnKeys:!0}),r.create=function(s){return t(jt(e,s))},r}(pt);ue.Axios=ne,ue.CanceledError=Ot,ue.CancelToken=ae,ue.isCancel=Et,ue.VERSION="1.7.2",ue.toFormData=Y,ue.AxiosError=H,ue.Cancel=ue.CanceledError,ue.all=function(t){return Promise.all(t)},ue.spread=function(t){return function(e){return t.apply(null,e)}},ue.isAxiosError=function(t){return q.isObject(t)&&!0===t.isAxiosError},ue.mergeConfig=jt,ue.AxiosHeaders=St,ue.formToJSON=t=>dt(q.isHTMLForm(t)?new FormData(t):t),ue.getAdapter=Xt,ue.HttpStatusCode=he,ue.default=ue;const le=ue;class de{interceptor;constructor(t){this.interceptor=le.create({baseURL:`${t}/api`}),this.interceptor.interceptors.request.use((t=>{const e=le.CancelToken.source();return t.cancelToken=e.token,setTimeout((()=>{e.cancel("Timeout: request took more than 15 seconds")}),15e3),t}),(t=>Promise.reject(t)))}}const fe="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,pe=new Set,ge="object"==typeof process&&process?process:{},me=(t,e,s,r)=>{"function"==typeof ge.emitWarning?ge.emitWarning(t,e,s,r):console.error(`[${s}] ${e}: ${t}`)};let ye=globalThis.AbortController,be=globalThis.AbortSignal;if(void 0===ye){be=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},ye=class{constructor(){e()}signal=new be;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==ge.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,me("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}Symbol("type");const ve=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),we=t=>ve(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?Se:null:null;class Se extends Array{constructor(t){super(t),this.fill(0)}}class ke{heap;length;static#t=!1;static create(t){const e=we(t);if(!e)return[];ke.#t=!0;const s=new ke(t,e);return ke.#t=!1,s}constructor(t,e){if(!ke.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}}class Ee{#e;#s;#r;#i;#n;#o;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#c;#h;#u;#l;#d;#f;#p;#g;#m;#y;#b;#v;#w;#S;#k;#E;static unsafeExposeInternals(t){return{starts:t.#v,ttls:t.#w,sizes:t.#b,keyMap:t.#h,keyList:t.#u,valList:t.#l,next:t.#d,prev:t.#f,get head(){return t.#p},get tail(){return t.#g},free:t.#m,isBackgroundFetch:e=>t.#_(e),backgroundFetch:(e,s,r,i)=>t.#O(e,s,r,i),moveToTail:e=>t.#T(e),indexes:e=>t.#x(e),rindexes:e=>t.#A(e),isStale:e=>t.#R(e)}}get max(){return this.#e}get maxSize(){return this.#s}get calculatedSize(){return this.#c}get size(){return this.#a}get fetchMethod(){return this.#n}get memoMethod(){return this.#o}get dispose(){return this.#r}get disposeAfter(){return this.#i}constructor(t){const{max:e=0,ttl:s,ttlResolution:r=1,ttlAutopurge:i,updateAgeOnGet:n,updateAgeOnHas:o,allowStale:a,dispose:c,disposeAfter:h,noDisposeOnSet:u,noUpdateTTL:l,maxSize:d=0,maxEntrySize:f=0,sizeCalculation:p,fetchMethod:g,memoMethod:m,noDeleteOnFetchRejection:y,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:w,ignoreFetchAbort:S}=t;if(0!==e&&!ve(e))throw new TypeError("max option must be a nonnegative integer");const k=e?we(e):Array;if(!k)throw new Error("invalid max value: "+e);if(this.#e=e,this.#s=d,this.maxEntrySize=f||this.#s,this.sizeCalculation=p,this.sizeCalculation){if(!this.#s&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==m&&"function"!=typeof m)throw new TypeError("memoMethod must be a function if defined");if(this.#o=m,void 0!==g&&"function"!=typeof g)throw new TypeError("fetchMethod must be a function if specified");if(this.#n=g,this.#k=!!g,this.#h=new Map,this.#u=new Array(e).fill(void 0),this.#l=new Array(e).fill(void 0),this.#d=new k(e),this.#f=new k(e),this.#p=0,this.#g=0,this.#m=ke.create(e),this.#a=0,this.#c=0,"function"==typeof c&&(this.#r=c),"function"==typeof h?(this.#i=h,this.#y=[]):(this.#i=void 0,this.#y=void 0),this.#S=!!this.#r,this.#E=!!this.#i,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!l,this.noDeleteOnFetchRejection=!!y,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!S,0!==this.maxEntrySize){if(0!==this.#s&&!ve(this.#s))throw new TypeError("maxSize must be a positive integer if specified");if(!ve(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#L()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!o,this.ttlResolution=ve(r)||0===r?r:1,this.ttlAutopurge=!!i,this.ttl=s||0,this.ttl){if(!ve(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#C()}if(0===this.#e&&0===this.ttl&&0===this.#s)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#s){const t="LRU_CACHE_UNBOUNDED";(t=>!pe.has(t))(t)&&(pe.add(t),me("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,Ee))}}getRemainingTTL(t){return this.#h.has(t)?1/0:0}#C(){const t=new Se(this.#e),e=new Se(this.#e);this.#w=t,this.#v=e,this.#j=(s,r,i=fe.now())=>{if(e[s]=0!==r?i:0,t[s]=r,0!==r&&this.ttlAutopurge){const t=setTimeout((()=>{this.#R(s)&&this.#B(this.#u[s],"expire")}),r+1);t.unref&&t.unref()}},this.#P=s=>{e[s]=0!==t[s]?fe.now():0},this.#D=(i,n)=>{if(t[n]){const o=t[n],a=e[n];if(!o||!a)return;i.ttl=o,i.start=a,i.now=s||r();const c=i.now-a;i.remainingTTL=o-c}};let s=0;const r=()=>{const t=fe.now();if(this.ttlResolution>0){s=t;const e=setTimeout((()=>s=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=i=>{const n=this.#h.get(i);if(void 0===n)return 0;const o=t[n],a=e[n];return o&&a?o-((s||r())-a):1/0},this.#R=i=>{const n=e[i],o=t[i];return!!o&&!!n&&(s||r())-n>o}}#P=()=>{};#D=()=>{};#j=()=>{};#R=()=>!1;#L(){const t=new Se(this.#e);this.#c=0,this.#b=t,this.#F=e=>{this.#c-=t[e],t[e]=0},this.#N=(t,e,s,r)=>{if(this.#_(e))return 0;if(!ve(s)){if(!r)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof r)throw new TypeError("sizeCalculation must be a function");if(s=r(e,t),!ve(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return s},this.#M=(e,s,r)=>{if(t[e]=s,this.#s){const s=this.#s-t[e];for(;this.#c>s;)this.#I(!0)}this.#c+=t[e],r&&(r.entrySize=s,r.totalCalculatedSize=this.#c)}}#F=t=>{};#M=(t,e,s)=>{};#N=(t,e,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#x({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#g;this.#z(e)&&(!t&&this.#R(e)||(yield e),e!==this.#p);)e=this.#f[e]}*#A({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#p;this.#z(e)&&(!t&&this.#R(e)||(yield e),e!==this.#g);)e=this.#d[e]}#z(t){return void 0!==t&&this.#h.get(this.#u[t])===t}*entries(){for(const t of this.#x())void 0===this.#l[t]||void 0===this.#u[t]||this.#_(this.#l[t])||(yield[this.#u[t],this.#l[t]])}*rentries(){for(const t of this.#A())void 0===this.#l[t]||void 0===this.#u[t]||this.#_(this.#l[t])||(yield[this.#u[t],this.#l[t]])}*keys(){for(const t of this.#x()){const e=this.#u[t];void 0===e||this.#_(this.#l[t])||(yield e)}}*rkeys(){for(const t of this.#A()){const e=this.#u[t];void 0===e||this.#_(this.#l[t])||(yield e)}}*values(){for(const t of this.#x())void 0===this.#l[t]||this.#_(this.#l[t])||(yield this.#l[t])}*rvalues(){for(const t of this.#A())void 0===this.#l[t]||this.#_(this.#l[t])||(yield this.#l[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(const s of this.#x()){const r=this.#l[s],i=this.#_(r)?r.__staleWhileFetching:r;if(void 0!==i&&t(i,this.#u[s],this))return this.get(this.#u[s],e)}}forEach(t,e=this){for(const s of this.#x()){const r=this.#l[s],i=this.#_(r)?r.__staleWhileFetching:r;void 0!==i&&t.call(e,i,this.#u[s],this)}}rforEach(t,e=this){for(const s of this.#A()){const r=this.#l[s],i=this.#_(r)?r.__staleWhileFetching:r;void 0!==i&&t.call(e,i,this.#u[s],this)}}purgeStale(){let t=!1;for(const e of this.#A({allowStale:!0}))this.#R(e)&&(this.#B(this.#u[e],"expire"),t=!0);return t}info(t){const e=this.#h.get(t);if(void 0===e)return;const s=this.#l[e],r=this.#_(s)?s.__staleWhileFetching:s;if(void 0===r)return;const i={value:r};if(this.#w&&this.#v){const t=this.#w[e],s=this.#v[e];if(t&&s){const e=t-(fe.now()-s);i.ttl=e,i.start=Date.now()}}return this.#b&&(i.size=this.#b[e]),i}dump(){const t=[];for(const e of this.#x({allowStale:!0})){const s=this.#u[e],r=this.#l[e],i=this.#_(r)?r.__staleWhileFetching:r;if(void 0===i||void 0===s)continue;const n={value:i};if(this.#w&&this.#v){n.ttl=this.#w[e];const t=fe.now()-this.#v[e];n.start=Math.floor(Date.now()-t)}this.#b&&(n.size=this.#b[e]),t.unshift([s,n])}return t}load(t){this.clear();for(const[e,s]of t){if(s.start){const t=Date.now()-s.start;s.start=fe.now()-t}this.set(e,s.value,s)}}set(t,e,s={}){if(void 0===e)return this.delete(t),this;const{ttl:r=this.ttl,start:i,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:a}=s;let{noUpdateTTL:c=this.noUpdateTTL}=s;const h=this.#N(t,e,s.size||0,o);if(this.maxEntrySize&&h>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#B(t,"set"),this;let u=0===this.#a?void 0:this.#h.get(t);if(void 0===u)u=0===this.#a?this.#g:0!==this.#m.length?this.#m.pop():this.#a===this.#e?this.#I(!1):this.#a,this.#u[u]=t,this.#l[u]=e,this.#h.set(t,u),this.#d[this.#g]=u,this.#f[u]=this.#g,this.#g=u,this.#a++,this.#M(u,h,a),a&&(a.set="add"),c=!1;else{this.#T(u);const s=this.#l[u];if(e!==s){if(this.#k&&this.#_(s)){s.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=s;void 0===e||n||(this.#S&&this.#r?.(e,t,"set"),this.#E&&this.#y?.push([e,t,"set"]))}else n||(this.#S&&this.#r?.(s,t,"set"),this.#E&&this.#y?.push([s,t,"set"]));if(this.#F(u),this.#M(u,h,a),this.#l[u]=e,a){a.set="replace";const t=s&&this.#_(s)?s.__staleWhileFetching:s;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===r||this.#w||this.#C(),this.#w&&(c||this.#j(u,r,i),a&&this.#D(a,u)),!n&&this.#E&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#i?.(...e)}return this}pop(){try{for(;this.#a;){const t=this.#l[this.#p];if(this.#I(!0),this.#_(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#E&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#i?.(...e)}}}#I(t){const e=this.#p,s=this.#u[e],r=this.#l[e];return this.#k&&this.#_(r)?r.__abortController.abort(new Error("evicted")):(this.#S||this.#E)&&(this.#S&&this.#r?.(r,s,"evict"),this.#E&&this.#y?.push([r,s,"evict"])),this.#F(e),t&&(this.#u[e]=void 0,this.#l[e]=void 0,this.#m.push(e)),1===this.#a?(this.#p=this.#g=0,this.#m.length=0):this.#p=this.#d[e],this.#h.delete(s),this.#a--,e}has(t,e={}){const{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=e,i=this.#h.get(t);if(void 0!==i){const t=this.#l[i];if(this.#_(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#R(i))return s&&this.#P(i),r&&(r.has="hit",this.#D(r,i)),!0;r&&(r.has="stale",this.#D(r,i))}else r&&(r.has="miss");return!1}peek(t,e={}){const{allowStale:s=this.allowStale}=e,r=this.#h.get(t);if(void 0===r||!s&&this.#R(r))return;const i=this.#l[r];return this.#_(i)?i.__staleWhileFetching:i}#O(t,e,s,r){const i=void 0===e?void 0:this.#l[e];if(this.#_(i))return i;const n=new ye,{signal:o}=s;o?.addEventListener("abort",(()=>n.abort(o.reason)),{signal:n.signal});const a={signal:n.signal,options:s,context:r},c=(r,i=!1)=>{const{aborted:o}=n.signal,c=s.ignoreFetchAbort&&void 0!==r;if(s.status&&(o&&!i?(s.status.fetchAborted=!0,s.status.fetchError=n.signal.reason,c&&(s.status.fetchAbortIgnored=!0)):s.status.fetchResolved=!0),o&&!c&&!i)return h(n.signal.reason);const l=u;return this.#l[e]===u&&(void 0===r?l.__staleWhileFetching?this.#l[e]=l.__staleWhileFetching:this.#B(t,"fetch"):(s.status&&(s.status.fetchUpdated=!0),this.set(t,r,a.options))),r},h=r=>{const{aborted:i}=n.signal,o=i&&s.allowStaleOnFetchAbort,a=o||s.allowStaleOnFetchRejection,c=a||s.noDeleteOnFetchRejection,h=u;if(this.#l[e]===u&&(c&&void 0!==h.__staleWhileFetching?o||(this.#l[e]=h.__staleWhileFetching):this.#B(t,"fetch")),a)return s.status&&void 0!==h.__staleWhileFetching&&(s.status.returnedStale=!0),h.__staleWhileFetching;if(h.__returned===h)throw r};s.status&&(s.status.fetchDispatched=!0);const u=new Promise(((e,r)=>{const o=this.#n?.(t,i,a);o&&o instanceof Promise&&o.then((t=>e(void 0===t?void 0:t)),r),n.signal.addEventListener("abort",(()=>{s.ignoreFetchAbort&&!s.allowStaleOnFetchAbort||(e(void 0),s.allowStaleOnFetchAbort&&(e=t=>c(t,!0)))}))})).then(c,(t=>(s.status&&(s.status.fetchRejected=!0,s.status.fetchError=t),h(t)))),l=Object.assign(u,{__abortController:n,__staleWhileFetching:i,__returned:void 0});return void 0===e?(this.set(t,l,{...a.options,status:void 0}),e=this.#h.get(t)):this.#l[e]=l,l}#_(t){if(!this.#k)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof ye}async fetch(t,e={}){const{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:a=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:l=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:f=this.allowStaleOnFetchAbort,context:p,forceRefresh:g=!1,status:m,signal:y}=e;if(!this.#k)return m&&(m.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:i,status:m});const b={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:i,ttl:n,noDisposeOnSet:o,size:a,sizeCalculation:c,noUpdateTTL:h,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:l,allowStaleOnFetchAbort:f,ignoreFetchAbort:d,status:m,signal:y};let v=this.#h.get(t);if(void 0===v){m&&(m.fetch="miss");const e=this.#O(t,v,b,p);return e.__returned=e}{const e=this.#l[v];if(this.#_(e)){const t=s&&void 0!==e.__staleWhileFetching;return m&&(m.fetch="inflight",t&&(m.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const i=this.#R(v);if(!g&&!i)return m&&(m.fetch="hit"),this.#T(v),r&&this.#P(v),m&&this.#D(m,v),e;const n=this.#O(t,v,b,p),o=void 0!==n.__staleWhileFetching&&s;return m&&(m.fetch=i?"stale":"refresh",o&&i&&(m.returnedStale=!0)),o?n.__staleWhileFetching:n.__returned=n}}async forceFetch(t,e={}){const s=await this.fetch(t,e);if(void 0===s)throw new Error("fetch() returned undefined");return s}memo(t,e={}){const s=this.#o;if(!s)throw new Error("no memoMethod provided to constructor");const{context:r,forceRefresh:i,...n}=e,o=this.get(t,n);if(!i&&void 0!==o)return o;const a=s(t,o,{options:n,context:r});return this.set(t,a,n),a}get(t,e={}){const{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:n}=e,o=this.#h.get(t);if(void 0!==o){const e=this.#l[o],a=this.#_(e);return n&&this.#D(n,o),this.#R(o)?(n&&(n.get="stale"),a?(n&&s&&void 0!==e.__staleWhileFetching&&(n.returnedStale=!0),s?e.__staleWhileFetching:void 0):(i||this.#B(t,"expire"),n&&s&&(n.returnedStale=!0),s?e:void 0)):(n&&(n.get="hit"),a?e.__staleWhileFetching:(this.#T(o),r&&this.#P(o),e))}n&&(n.get="miss")}#q(t,e){this.#f[e]=t,this.#d[t]=e}#T(t){t!==this.#g&&(t===this.#p?this.#p=this.#d[t]:this.#q(this.#f[t],this.#d[t]),this.#q(this.#g,t),this.#g=t)}delete(t){return this.#B(t,"delete")}#B(t,e){let s=!1;if(0!==this.#a){const r=this.#h.get(t);if(void 0!==r)if(s=!0,1===this.#a)this.#U(e);else{this.#F(r);const s=this.#l[r];if(this.#_(s)?s.__abortController.abort(new Error("deleted")):(this.#S||this.#E)&&(this.#S&&this.#r?.(s,t,e),this.#E&&this.#y?.push([s,t,e])),this.#h.delete(t),this.#u[r]=void 0,this.#l[r]=void 0,r===this.#g)this.#g=this.#f[r];else if(r===this.#p)this.#p=this.#d[r];else{const t=this.#f[r];this.#d[t]=this.#d[r];const e=this.#d[r];this.#f[e]=this.#f[r]}this.#a--,this.#m.push(r)}}if(this.#E&&this.#y?.length){const t=this.#y;let e;for(;e=t?.shift();)this.#i?.(...e)}return s}clear(){return this.#U("delete")}#U(t){for(const e of this.#A({allowStale:!0})){const s=this.#l[e];if(this.#_(s))s.__abortController.abort(new Error("deleted"));else{const r=this.#u[e];this.#S&&this.#r?.(s,r,t),this.#E&&this.#y?.push([s,r,t])}}if(this.#h.clear(),this.#l.fill(void 0),this.#u.fill(void 0),this.#w&&this.#v&&(this.#w.fill(0),this.#v.fill(0)),this.#b&&this.#b.fill(0),this.#p=0,this.#g=0,this.#m.length=0,this.#c=0,this.#a=0,this.#E&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#i?.(...e)}}}var _e=function(t,e){return _e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])},_e(t,e)};function Oe(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function s(){this.constructor=t}_e(t,e),t.prototype=null===e?Object.create(e):(s.prototype=e.prototype,new s)}function Te(t,e){var s,r,i,n,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return n={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function a(a){return function(c){return function(a){if(s)throw new TypeError("Generator is already executing.");for(;n&&(n=0,a[0]&&(o=0)),o;)try{if(s=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],r=0}finally{s=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function xe(t){var e="function"==typeof Symbol&&Symbol.iterator,s=e&&t[e],r=0;if(s)return s.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ae(t,e){var s="function"==typeof Symbol&&t[Symbol.iterator];if(!s)return t;var r,i,n=s.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(r=n.next()).done;)o.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(s=n.return)&&s.call(n)}finally{if(i)throw i.error}}return o}function Re(t,e,s){if(s||2===arguments.length)for(var r,i=0,n=e.length;i<n;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}function Le(t){return this instanceof Le?(this.v=t,this):new Le(t)}function Ce(t){return"function"==typeof t}function je(t){var e=t((function(t){Error.call(t),t.stack=(new Error).stack}));return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var Be=je((function(t){return function(e){t(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map((function(t,e){return e+1+") "+t.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=e}}));function Pe(t,e){if(t){var s=t.indexOf(e);0<=s&&t.splice(s,1)}}var De=function(){function t(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var t,e,s,r,i;if(!this.closed){this.closed=!0;var n=this._parentage;if(n)if(this._parentage=null,Array.isArray(n))try{for(var o=xe(n),a=o.next();!a.done;a=o.next())a.value.remove(this)}catch(e){t={error:e}}finally{try{a&&!a.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}else n.remove(this);var c=this.initialTeardown;if(Ce(c))try{c()}catch(t){i=t instanceof Be?t.errors:[t]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var u=xe(h),l=u.next();!l.done;l=u.next()){var d=l.value;try{Me(d)}catch(t){i=null!=i?i:[],t instanceof Be?i=Re(Re([],Ae(i)),Ae(t.errors)):i.push(t)}}}catch(t){s={error:t}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(s)throw s.error}}}if(i)throw new Be(i)}},t.prototype.add=function(e){var s;if(e&&e!==this)if(this.closed)Me(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=null!==(s=this._finalizers)&&void 0!==s?s:[]).push(e)}},t.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},t.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},t.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&Pe(e,t)},t.prototype.remove=function(e){var s=this._finalizers;s&&Pe(s,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}(),Fe=De.EMPTY;function Ne(t){return t instanceof De||t&&"closed"in t&&Ce(t.remove)&&Ce(t.add)&&Ce(t.unsubscribe)}function Me(t){Ce(t)?t():t.unsubscribe()}var Ie={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ze={setTimeout:function(t,e){for(var s=[],r=2;r<arguments.length;r++)s[r-2]=arguments[r];var i=ze.delegate;return(null==i?void 0:i.setTimeout)?i.setTimeout.apply(i,Re([t,e],Ae(s))):setTimeout.apply(void 0,Re([t,e],Ae(s)))},clearTimeout:function(t){var e=ze.delegate;return((null==e?void 0:e.clearTimeout)||clearTimeout)(t)},delegate:void 0};function qe(t){ze.setTimeout((function(){var e=Ie.onUnhandledError;if(!e)throw t;e(t)}))}function Ue(){}var Ve=We("C",void 0,void 0);function We(t,e,s){return{kind:t,value:e,error:s}}var He=null;function $e(t){if(Ie.useDeprecatedSynchronousErrorHandling){var e=!He;if(e&&(He={errorThrown:!1,error:null}),t(),e){var s=He,r=s.errorThrown,i=s.error;if(He=null,r)throw i}}else t()}var Je=function(t){function e(e){var s=t.call(this)||this;return s.isStopped=!1,e?(s.destination=e,Ne(e)&&e.add(s)):s.destination=ts,s}return Oe(e,t),e.create=function(t,e,s){return new Xe(t,e,s)},e.prototype.next=function(t){this.isStopped?Ze(function(t){return We("N",t,void 0)}(t),this):this._next(t)},e.prototype.error=function(t){this.isStopped?Ze(We("E",void 0,t),this):(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped?Ze(Ve,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(De),Ge=Function.prototype.bind;function Ke(t,e){return Ge.call(t,e)}var Ye=function(){function t(t){this.partialObserver=t}return t.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(t){Qe(t)}},t.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(t){Qe(t)}else Qe(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){Qe(t)}},t}(),Xe=function(t){function e(e,s,r){var i,n,o=t.call(this)||this;return Ce(e)||!e?i={next:null!=e?e:void 0,error:null!=s?s:void 0,complete:null!=r?r:void 0}:o&&Ie.useDeprecatedNextContext?((n=Object.create(e)).unsubscribe=function(){return o.unsubscribe()},i={next:e.next&&Ke(e.next,n),error:e.error&&Ke(e.error,n),complete:e.complete&&Ke(e.complete,n)}):i=e,o.destination=new Ye(i),o}return Oe(e,t),e}(Je);function Qe(t){var e;Ie.useDeprecatedSynchronousErrorHandling?(e=t,Ie.useDeprecatedSynchronousErrorHandling&&He&&(He.errorThrown=!0,He.error=e)):qe(t)}function Ze(t,e){var s=Ie.onStoppedNotification;s&&ze.setTimeout((function(){return s(t,e)}))}var ts={closed:!0,next:Ue,error:function(t){throw t},complete:Ue},es="function"==typeof Symbol&&Symbol.observable||"@@observable";function ss(t){return t}var rs=function(){function t(t){t&&(this._subscribe=t)}return t.prototype.lift=function(e){var s=new t;return s.source=this,s.operator=e,s},t.prototype.subscribe=function(t,e,s){var r=this,i=function(t){return t&&t instanceof Je||function(t){return t&&Ce(t.next)&&Ce(t.error)&&Ce(t.complete)}(t)&&Ne(t)}(t)?t:new Xe(t,e,s);return $e((function(){var t=r,e=t.operator,s=t.source;i.add(e?e.call(i,s):s?r._subscribe(i):r._trySubscribe(i))})),i},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},t.prototype.forEach=function(t,e){var s=this;return new(e=is(e))((function(e,r){var i=new Xe({next:function(e){try{t(e)}catch(t){r(t),i.unsubscribe()}},error:r,complete:e});s.subscribe(i)}))},t.prototype._subscribe=function(t){var e;return null===(e=this.source)||void 0===e?void 0:e.subscribe(t)},t.prototype[es]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return(0===(s=t).length?ss:1===s.length?s[0]:function(t){return s.reduce((function(t,e){return e(t)}),t)})(this);var s},t.prototype.toPromise=function(t){var e=this;return new(t=is(t))((function(t,s){var r;e.subscribe((function(t){return r=t}),(function(t){return s(t)}),(function(){return t(r)}))}))},t.create=function(e){return new t(e)},t}();function is(t){var e;return null!==(e=null!=t?t:Ie.Promise)&&void 0!==e?e:Promise}var ns=je((function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),os=function(t){function e(){var e=t.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return Oe(e,t),e.prototype.lift=function(t){var e=new as(this,this);return e.operator=t,e},e.prototype._throwIfClosed=function(){if(this.closed)throw new ns},e.prototype.next=function(t){var e=this;$e((function(){var s,r;if(e._throwIfClosed(),!e.isStopped){e.currentObservers||(e.currentObservers=Array.from(e.observers));try{for(var i=xe(e.currentObservers),n=i.next();!n.done;n=i.next())n.value.next(t)}catch(t){s={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(s)throw s.error}}}}))},e.prototype.error=function(t){var e=this;$e((function(){if(e._throwIfClosed(),!e.isStopped){e.hasError=e.isStopped=!0,e.thrownError=t;for(var s=e.observers;s.length;)s.shift().error(t)}}))},e.prototype.complete=function(){var t=this;$e((function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var e=t.observers;e.length;)e.shift().complete()}}))},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var e=this,s=this,r=s.hasError,i=s.isStopped,n=s.observers;return r||i?Fe:(this.currentObservers=null,n.push(t),new De((function(){e.currentObservers=null,Pe(n,t)})))},e.prototype._checkFinalizedStatuses=function(t){var e=this,s=e.hasError,r=e.thrownError,i=e.isStopped;s?t.error(r):i&&t.complete()},e.prototype.asObservable=function(){var t=new rs;return t.source=this,t},e.create=function(t,e){return new as(t,e)},e}(rs),as=function(t){function e(e,s){var r=t.call(this)||this;return r.destination=e,r.source=s,r}return Oe(e,t),e.prototype.next=function(t){var e,s;null===(s=null===(e=this.destination)||void 0===e?void 0:e.next)||void 0===s||s.call(e,t)},e.prototype.error=function(t){var e,s;null===(s=null===(e=this.destination)||void 0===e?void 0:e.error)||void 0===s||s.call(e,t)},e.prototype.complete=function(){var t,e;null===(e=null===(t=this.destination)||void 0===t?void 0:t.complete)||void 0===e||e.call(t)},e.prototype._subscribe=function(t){var e,s;return null!==(s=null===(e=this.source)||void 0===e?void 0:e.subscribe(t))&&void 0!==s?s:Fe},e}(os),cs=function(t){function e(e){var s=t.call(this)||this;return s._value=e,s}return Oe(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(e){var s=t.prototype._subscribe.call(this,e);return!s.closed&&e.next(this._value),s},e.prototype.getValue=function(){var t=this,e=t.hasError,s=t.thrownError,r=t._value;if(e)throw s;return this._throwIfClosed(),r},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},e}(os),hs={now:function(){return(hs.delegate||Date).now()},delegate:void 0},us=function(t){function e(e,s,r){void 0===e&&(e=1/0),void 0===s&&(s=1/0),void 0===r&&(r=hs);var i=t.call(this)||this;return i._bufferSize=e,i._windowTime=s,i._timestampProvider=r,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=s===1/0,i._bufferSize=Math.max(1,e),i._windowTime=Math.max(1,s),i}return Oe(e,t),e.prototype.next=function(e){var s=this,r=s.isStopped,i=s._buffer,n=s._infiniteTimeWindow,o=s._timestampProvider,a=s._windowTime;r||(i.push(e),!n&&i.push(o.now()+a)),this._trimBuffer(),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var e=this._innerSubscribe(t),s=this._infiniteTimeWindow,r=this._buffer.slice(),i=0;i<r.length&&!t.closed;i+=s?1:2)t.next(r[i]);return this._checkFinalizedStatuses(t),e},e.prototype._trimBuffer=function(){var t=this,e=t._bufferSize,s=t._timestampProvider,r=t._buffer,i=t._infiniteTimeWindow,n=(i?1:2)*e;if(e<1/0&&n<r.length&&r.splice(0,r.length-n),!i){for(var o=s.now(),a=0,c=1;c<r.length&&r[c]<=o;c+=2)a=c;a&&r.splice(0,a+1)}},e}(os);function ls(t){return function(e){if(function(t){return Ce(null==t?void 0:t.lift)}(e))return e.lift((function(e){try{return t(e,this)}catch(t){this.error(t)}}));throw new TypeError("Unable to lift unknown Observable type")}}function ds(t,e,s,r,i){return new fs(t,e,s,r,i)}var fs=function(t){function e(e,s,r,i,n,o){var a=t.call(this,e)||this;return a.onFinalize=n,a.shouldUnsubscribe=o,a._next=s?function(t){try{s(t)}catch(t){e.error(t)}}:t.prototype._next,a._error=i?function(t){try{i(t)}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._error,a._complete=r?function(){try{r()}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._complete,a}return Oe(e,t),e.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var s=this.closed;t.prototype.unsubscribe.call(this),!s&&(null===(e=this.onFinalize)||void 0===e||e.call(this))}},e}(Je);function ps(){return ls((function(t,e){var s,r=!1;t.subscribe(ds(e,(function(t){var i=s;s=t,r&&e.next([i,t]),r=!0})))}))}function gs(t,e){return ls((function(s,r){var i=0;s.subscribe(ds(r,(function(s){return t.call(e,s,i++)&&r.next(s)})))}))}function ms(t,e){return ls((function(s,r){var i=0;s.subscribe(ds(r,(function(s){r.next(t.call(e,s,i++))})))}))}var ys=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t},bs="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function vs(t){if(t instanceof rs)return t;if(null!=t){if(function(t){return Ce(t[es])}(t))return i=t,new rs((function(t){var e=i[es]();if(Ce(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(ys(t))return r=t,new rs((function(t){for(var e=0;e<r.length&&!t.closed;e++)t.next(r[e]);t.complete()}));if(function(t){return Ce(null==t?void 0:t.then)}(t))return s=t,new rs((function(t){s.then((function(e){t.closed||(t.next(e),t.complete())}),(function(e){return t.error(e)})).then(null,qe)}));if(function(t){return Symbol.asyncIterator&&Ce(null==t?void 0:t[Symbol.asyncIterator])}(t))return ws(t);if(function(t){return Ce(null==t?void 0:t[bs])}(t))return e=t,new rs((function(t){var s,r;try{for(var i=xe(e),n=i.next();!n.done;n=i.next()){var o=n.value;if(t.next(o),t.closed)return}}catch(t){s={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(s)throw s.error}}t.complete()}));if(function(t){return Ce(null==t?void 0:t.getReader)}(t))return ws(function(t){return function(t,e,s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=s.apply(t,e||[]),n=[];return r={},o("next"),o("throw"),o("return",(function(t){return function(e){return Promise.resolve(e).then(t,h)}})),r[Symbol.asyncIterator]=function(){return this},r;function o(t,e){i[t]&&(r[t]=function(e){return new Promise((function(s,r){n.push([t,e,s,r])>1||a(t,e)}))},e&&(r[t]=e(r[t])))}function a(t,e){try{(s=i[t](e)).value instanceof Le?Promise.resolve(s.value.v).then(c,h):u(n[0][2],s)}catch(t){u(n[0][3],t)}var s}function c(t){a("next",t)}function h(t){a("throw",t)}function u(t,e){t(e),n.shift(),n.length&&a(n[0][0],n[0][1])}}(this,arguments,(function(){var e,s,r;return Te(this,(function(i){switch(i.label){case 0:e=t.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,Le(e.read())];case 3:return s=i.sent(),r=s.value,s.done?[4,Le(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,Le(r)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}}))}))}(t))}var e,s,r,i;throw function(t){return new TypeError("You provided "+(null!==t&&"object"==typeof t?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}(t)}function ws(t){return new rs((function(e){(function(t,e){var s,r,i,n,o,a,c,h;return o=this,a=void 0,h=function(){var o,a;return Te(this,(function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),s=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,s=t[Symbol.asyncIterator];return s?s.call(t):(t=xe(t),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(s){e[s]=t[s]&&function(e){return new Promise((function(r,i){!function(t,e,s,r){Promise.resolve(r).then((function(e){t({value:e,done:s})}),e)}(r,i,(e=t[s](e)).done,e.value)}))}}}(t),c.label=1;case 1:return[4,s.next()];case 2:if((r=c.sent()).done)return[3,4];if(o=r.value,e.next(o),e.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),i={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),r&&!r.done&&(n=s.return)?[4,n.call(s)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}}))},new((c=void 0)||(c=Promise))((function(t,e){function s(t){try{i(h.next(t))}catch(t){e(t)}}function r(t){try{i(h.throw(t))}catch(t){e(t)}}function i(e){e.done?t(e.value):function(t){return t instanceof c?t:new c((function(e){e(t)}))}(e.value).then(s,r)}i((h=h.apply(o,a||[])).next())}))})(t,e).catch((function(t){return e.error(t)}))}))}function Ss(t){void 0===t&&(t={});var e=t.connector,s=void 0===e?function(){return new os}:e,r=t.resetOnError,i=void 0===r||r,n=t.resetOnComplete,o=void 0===n||n,a=t.resetOnRefCountZero,c=void 0===a||a;return function(t){var e,r,n,a=0,h=!1,u=!1,l=function(){null==r||r.unsubscribe(),r=void 0},d=function(){l(),e=n=void 0,h=u=!1},f=function(){var t=e;d(),null==t||t.unsubscribe()};return ls((function(t,p){a++,u||h||l();var g=n=null!=n?n:s();p.add((function(){0!=--a||u||h||(r=ks(f,c))})),g.subscribe(p),!e&&a>0&&(e=new Xe({next:function(t){return g.next(t)},error:function(t){u=!0,l(),r=ks(d,i,t),g.error(t)},complete:function(){h=!0,l(),r=ks(d,o),g.complete()}}),vs(t).subscribe(e))}))(t)}}function ks(t,e){for(var s=[],r=2;r<arguments.length;r++)s[r-2]=arguments[r];if(!0!==e){if(!1!==e){var i=new Xe({next:function(){i.unsubscribe(),t()}});return vs(e.apply(void 0,Re([],Ae(s)))).subscribe(i)}}else t()}function Es(t,e,s){return void 0===s&&(s=1/0),Ce(e)?Es((function(s,r){return ms((function(t,i){return e(s,t,r,i)}))(vs(t(s,r)))}),s):("number"==typeof e&&(s=e),ls((function(e,r){return function(t,e,s,r,i,n,o,a){var c=[],h=0,u=0,l=!1,d=function(){!l||c.length||h||e.complete()},f=function(t){return h<r?p(t):c.push(t)},p=function(t){h++;var i=!1;vs(s(t,u++)).subscribe(ds(e,(function(t){e.next(t)}),(function(){i=!0}),void 0,(function(){if(i)try{h--;for(var t=function(){var t=c.shift();p(t)};c.length&&h<r;)t();d()}catch(t){e.error(t)}})))};return t.subscribe(ds(e,f,(function(){l=!0,d()}))),function(){}}(e,r,t,s)})))}function _s(t,e){return t===e}const Os=(t,e,s=!1)=>{if(t===e)return!0;if((void 0===t||void 0===e||null===t||null===e)&&(t||e))return!1;const r=t?.constructor.name,i=e?.constructor.name;if(r!==i)return!1;if("Array"===r&&"Array"===i){if(t.length!==e.length)return!1;if(s){const r=[...e];return t.every((t=>{const e=r.findIndex((e=>Os(t,e,s)));return-1!==e&&(r.splice(e,1),!0)}))}{let r=!0;for(let i=0;i<t.length;i++)if(!Os(t[i],e[i],s)){r=!1;break}return r}}if("Object"===r&&"Object"===i){let r=!0;const i=Object.keys(t),n=Object.keys(e);if(i.length!==n.length)return!1;for(let n=0;n<i.length;n++)if(t[i[n]]&&e[i[n]]){if(t[i[n]]===e[i[n]])continue;if(!t[i[n]]||"Array"!==t[i[n]].constructor.name&&"Object"!==t[i[n]].constructor.name){if(t[i[n]]!==e[i[n]]){r=!1;break}}else if(r=Os(t[i[n]],e[i[n]],s),!r)break}else if(t[i[n]]&&!e[i[n]]||!t[i[n]]&&e[i[n]]){r=!1;break}return r}return t===e},Ts=t=>JSON.parse(JSON.stringify(t)),xs=(t,e)=>{const{origWidth:s,origHeight:r}=e,i=t.points.map((([t,e])=>[t*s/100,e*r/100]));return{...t,points:i}},As=t=>{const{origWidth:e,origHeight:s,inputWidth:r,inputHeight:i}=t,[n,o,a,c]=t.boundingBox,h=n*e/r,u=o*s/i,l=a*e/r,d=c*s/i;return{...t,boundingBox:[h,u,l,d]}},Rs=(t,e,s)=>{if(t.confidence<s.object.confidence)return!1;if(0===e.length)return!0;const[r,i,n,o]=t.boundingBox,a={xmin:r,ymin:i,xmax:n,ymax:o};let c=!1;for(const s of e){const e=xs(s,t);if(e.isPrivacyMask){if(Cs(a,e.points)){c=!1;break}}else"include"===e.filter?"contain"===e.type?Cs(a,e.points)&&(c=!0):"intersect"===e.type&&(Ls(a,e.points)||Cs(a,e.points))&&(c=!0):"exclude"===e.filter&&("contain"===e.type?Cs(a,e.points)||(c=!0):"intersect"===e.type&&(Ls(a,e.points)||Cs(a,e.points)||(c=!0)))}return c},Ls=(t,e)=>{const s=js(t);for(const t of s)for(let s=0;s<e.length;s++){const r=[e[s],e[(s+1)%e.length]];if(Bs(t,r))return!0}return!1},Cs=(t,e)=>[[t.xmin,t.ymin],[t.xmax,t.ymin],[t.xmax,t.ymax],[t.xmin,t.ymax]].every((t=>Ps(t,e))),js=t=>{const{xmin:e,ymin:s,xmax:r,ymax:i}=t;return[[[e,s],[r,s]],[[r,s],[r,i]],[[r,i],[e,i]],[[e,i],[e,s]]]},Bs=(t,e)=>{const s=(t,e,s)=>(s[1]-t[1])*(e[0]-t[0])>(e[1]-t[1])*(s[0]-t[0]);return r=t[0],i=t[1],s(r,n=e[0],o=e[1])!==s(i,n,o)&&s(r,i,n)!==s(r,i,o);var r,i,n,o},Ps=(t,e)=>{const[s,r]=t;let i=!1,[n,o]=e[e.length-1];for(const[t,a]of e)a>r!=o>r&&s<(n-t)*(r-a)/(o-a)+t&&(i=!i),[n,o]=[t,a];return i};class Ds{subscriptions=[];additionalSubscriptions=[];addSubscriptions(...t){this.subscriptions.push(...t)}addAdditionalSubscriptions(...t){this.additionalSubscriptions.push(...t)}unsubscribe(){this.subscriptions.forEach((t=>t.unsubscribe()))}unsubscribeAdditional(){this.additionalSubscriptions.forEach((t=>t.unsubscribe()))}}class Fs extends Ds{logger;snapshotCache=new Ee({max:100,ttl:3e5});cameraSubject;cameraState=new cs(!1);lightState=new cs(this.getLightState({state:!1},!0));motionState=new cs(this.getMotionState({detections:[],state:!1},!0));audioState=new cs(this.getAudioState({state:!1,db:0},!0));objectState=new cs(this.getObjectState({detections:[]},!0));doorbellState=new cs(this.getDoorbellState({state:!1},!0));sirenState=new cs(this.getSirenState({state:!1,level:0},!0));batteryState=new cs(this.getBatteryState({level:100,charging:!1,lowBattery:!1},!0));prebufferStateSubjects={};onConnected=this.createStateObservable(this.cameraState);onLightSwitched=this.createStateObservable(this.lightState);onMotionDetected=this.createStateObservable(this.motionState);onAudioDetected=this.createStateObservable(this.audioState);onObjectDetected=this.createStateObservable(this.objectState);onDoorbellPressed=this.createStateObservable(this.doorbellState);onSirenDetected=this.createStateObservable(this.sirenState);onBatteryChanged=this.createStateObservable(this.batteryState);get cameraObject(){return Ts(this.cameraSubject.getValue())}get id(){return this.cameraSubject.getValue()._id}get nativeId(){return this.cameraSubject.getValue().nativeId}get pluginId(){return this.cameraSubject.getValue().pluginId}get connected(){return this.cameraState.getValue()}get disabled(){return this.cameraSubject.getValue().disabled}get name(){return this.cameraSubject.getValue().name}get type(){return this.cameraSubject.getValue().type}get info(){return Ts(this.cameraSubject.getValue().info)}get isCloud(){return this.cameraSubject.getValue().isCloud}get hasLight(){return this.cameraSubject.getValue().hasLight}get hasSiren(){return this.cameraSubject.getValue().hasSiren}get hasBinarySensor(){return this.cameraSubject.getValue().hasBinarySensor}get hasBattery(){return this.cameraSubject.getValue().hasBattery}get hasMotionDetector(){return this.cameraSubject.getValue().hasMotionDetector}get hasAudioDetector(){return this.cameraSubject.getValue().hasAudioDetector}get hasObjectDetector(){return this.cameraSubject.getValue().hasObjectDetector}get hasPtz(){return this.cameraSubject.getValue().hasPtz}get hasPrebuffer(){return this.cameraSubject.getValue().hasPrebuffer}get activityZones(){return Ts(this.cameraSubject.getValue().activityZones)}get activitySettings(){return Ts(this.cameraSubject.getValue().activitySettings)}get frameWorkerSettings(){return Ts(this.cameraSubject.getValue().frameWorkerSettings)}get sources(){return Ts(this.cameraSubject.getValue().sources).map((t=>({...t,updatePrebufferingState:async(e,s)=>this.updatePrebuffer(t._id,e,s),getPrebufferingState:e=>this.cameraSourcePrebufferState(t._id,e),onPrebuffering:e=>this.createPrebufferStateObservable(t._id,e),getStreamInfo:async()=>{}})))}get streamSource(){return this.sources.find((t=>t.roles.includes("stream")))||this.sources[0]}get snapshotSource(){return this.sources.find((t=>t.roles.includes("snapshot")))||this.streamSource}get recordingSource(){return this.sources.find((t=>t.roles.includes("record")))||this.streamSource}get detectionSource(){return this.sources.find((t=>t.roles.includes("detect")))||this.streamSource}constructor(t,e){super(),this.logger=e,this.cameraSubject=new cs(t),"native"===t.pluginId&&this.cameraState.next(!0)}getValue(t){switch(t){case"light":return Ts(this.lightState.getValue());case"motion":return Ts(this.motionState.getValue());case"audio":return Ts(this.audioState.getValue());case"object":return Ts(this.objectState.getValue());case"doorbell":return Ts(this.doorbellState.getValue());case"siren":return Ts(this.sirenState.getValue());case"battery":return Ts(this.batteryState.getValue());default:throw new Error(`Unknown state: ${t}`)}}async snapshot(t){const e=this.snapshotSource.urls.www.jpegSnapshot,s=this.snapshotCache.get(this.snapshotSource._id);if(!t&&s)return s;const r=await fetch(e);if(!r.ok)throw new Error("Status Code: "+r.status);const i=await r.arrayBuffer();return i.byteLength>0&&this.snapshotCache.set(this.snapshotSource._id,i),i}onStateChange(t){return this[`${t}State`].pipe(ps(),gs((([e,s])=>"boolean"==typeof e||"boolean"==typeof s?e!==s:this.stateChanged(e,s,t))),ms((([t,e])=>({oldState:t,newState:e}))),Ss({connector:()=>new us(1)}))}updateStateInternal(t,e,s){let r,i=!1;if(s)i=!0,r=e;else{const s=this.checkStateInternal(t,e);i=s.changed,r=s.event}if(i)switch(t){case"light":this.lightState.next(this.getLightState(r));break;case"motion":this.motionState.next(this.getMotionState(r));break;case"audio":this.audioState.next(this.getAudioState(r));break;case"object":this.objectState.next(this.getObjectState(r));break;case"doorbell":this.doorbellState.next(this.getDoorbellState(r));break;case"siren":this.sirenState.next(this.getSirenState(r));break;case"battery":this.batteryState.next(this.getBatteryState(r));break;default:throw new Error(`Unknown state: ${t}`)}}onPropertyChange(t){return this.cameraSubject.pipe(ps(),Es((([e,s])=>(Array.isArray(t)?t:[t]).map((t=>({property:t,oldData:e[t],newData:s[t]}))))),gs((({oldData:t,newData:e})=>!Os(t,e,!0))),Ss({connector:()=>new us(1)}))}removeAllListeners(){this.lightState.complete(),this.motionState.complete(),this.audioState.complete(),this.objectState.complete(),this.doorbellState.complete(),this.sirenState.complete(),this.batteryState.complete(),this.cameraSubject.complete(),this.cameraState.complete()}checkStateInternal(t,e){let s,r=!1;switch(t){case"audio":const i=e;s=this.getAudioState(i),r=this.stateChanged(this.getValue("audio"),s,"audio");break;case"light":const n=e;s=this.getLightState(n),r=this.stateChanged(this.getValue("light"),s,"light");break;case"motion":const o=e;void 0!==o.state&&(o.detections=[]),o.detections=((t,e,s)=>{const r=[];for(const i of t)Rs(As(i),e,s)&&e.some((t=>!t.classes.length||t.classes.includes(i.label)))&&r.push(i);return r})(o.detections,this.activityZones,this.activitySettings),s=this.getMotionState(o),r=this.stateChanged(this.getValue("motion"),s,"motion");break;case"object":const a=e;a.detections=((t,e,s)=>{const r=[];for(const i of t)Rs(As(i),e,s)&&e.some((t=>!t.classes.length||t.classes.includes(i.label)))&&r.push(i);return r})(a.detections,this.activityZones,this.activitySettings),s=this.getObjectState(a),r=this.stateChanged(this.getValue("object"),s,"object");break;case"doorbell":const c=e;s=this.getDoorbellState(c),r=this.stateChanged(this.getValue("doorbell"),s,"doorbell");break;case"siren":const h=e;s=this.getSirenState(h),r=this.stateChanged(this.getValue("siren"),s,"siren");break;case"battery":const u=e;s=this.getBatteryState(u),r=this.stateChanged(this.getValue("battery"),s,"battery");break;default:throw new Error(`Unknown state: ${t}`)}return{changed:r,event:s}}getAudioState(t,e=!1){let s,r;if(!e){const t=this.getValue("audio");t.state?s=t:t.lastEvent?.state&&(s=t.lastEvent),s&&delete s.lastEvent}if(this.isStateEvent(t))r=t;else{const e={...t,timestamp:Date.now()};r={...e,db:e.db||s?.db||0,lastEvent:s||(e.state?e:void 0)}}return r}getMotionState(t,e=!1){let s,r;if(!e){const t=this.getValue("motion");t.detections.length?s=t:t.lastEvent?.detections.length&&(s=t.lastEvent),s&&delete s.lastEvent}if(this.isStateEvent(t))r=t;else{const e={...t,timestamp:Date.now()};r={...e,lastEvent:s||(e.detections.length?e:void 0)}}return r}getObjectState(t,e=!1){let s,r;if(!e){const t=this.getValue("object");t.detections.length?s=t:t.lastEvent?.detections.length&&(s=t.lastEvent),s&&delete s.lastEvent}if(this.isStateEvent(t))r=t;else{const e={...t,timestamp:Date.now()};r={...e,lastEvent:s||(e.detections.length?e:void 0)}}return r}getDoorbellState(t,e=!1){let s,r;if(!e){const t=this.getValue("doorbell");t.state?s=t:t.lastEvent?.state&&(s=t.lastEvent),s&&delete s.lastEvent}if(this.isStateEvent(t))r=t;else{const e={...t,timestamp:Date.now()};r={...e,lastEvent:s||(e.state?e:void 0)}}return r}getLightState(t,e=!1){let s,r;if(!e){const t=this.getValue("light");t.state?s=t:t.lastEvent?.state&&(s=t.lastEvent),s&&delete s.lastEvent}if(this.isStateEvent(t))r=t;else{const e={...t,timestamp:Date.now()};r={...e,lastEvent:s||(e.state?e:void 0)}}return r}getSirenState(t,e=!1){let s,r;if(!e){const t=this.getValue("siren");t.state?s=t:t.lastEvent?.state&&(s=t.lastEvent),s&&delete s.lastEvent}if(this.isStateEvent(t))r=t;else{const e={...t,timestamp:Date.now()};r={...e,level:e.level||s?.level||0,lastEvent:s||(e.state?e:void 0)}}return r}getBatteryState(t,e=!1){let s,r;if(!e){const e=this.getValue("battery");this.stateChanged(e,t,"battery")?s=e:e.lastEvent&&this.stateChanged(e.lastEvent,t,"battery")&&(s=e.lastEvent),s&&delete s.lastEvent}if(this.isStateEvent(t))r=t;else{const e={...t,timestamp:Date.now()};r={...e,charging:t.charging||s?.charging||!1,lowBattery:t.lowBattery||s?.lowBattery||!1,lastEvent:s||e}}return r}updateCamera(t){this.cameraSubject.next(t),this.updateCameraSourcesState()}async updatePrebuffer(t,e,s){this.prebufferStateSubjects[t]&&this.prebufferStateSubjects[t][e]&&this.prebufferStateSubjects[t][e].next({state:s.state,url:s.url||void 0,maxDuration:s.maxDuration,availableDuration:s.availableDuration})}updateCameraSourcesState(){const t=this.cameraSubject.getValue().sources;for(const e in this.prebufferStateSubjects)if(!t.some((t=>t._id===e))){for(const t in this.prebufferStateSubjects[e])this.prebufferStateSubjects[e][t].complete();delete this.prebufferStateSubjects[e]}}updateCameraState(t){this.cameraState.next(t)}cameraSourcePrebufferState(t,e){let s={state:!1,maxDuration:0,availableDuration:0};return this.prebufferStateSubjects[t]&&this.prebufferStateSubjects[t][e]&&(s=this.prebufferStateSubjects[t][e].getValue()),s}createStateObservable(t){return t.pipe(Ss({connector:()=>new us(1)}))}createPrebufferStateObservable(t,e){return this.prebufferStateSubjects[t]||(this.prebufferStateSubjects[t]={}),this.prebufferStateSubjects[t][e]||(this.prebufferStateSubjects[t][e]=new cs({state:!1,maxDuration:0,availableDuration:0})),this.prebufferStateSubjects[t][e].pipe((void 0===r&&(r=ss),s=null!=(s=(t,e)=>t.state===e.state&&t.url===e.url)?s:_s,ls((function(t,e){var i,n=!0;t.subscribe(ds(e,(function(t){var o=r(t);!n&&s(i,o)||(n=!1,i=o,e.next(t))})))}))),Ss({connector:()=>new us(1)}));var s,r}stateChanged(t,e,s){if(!t||!e||!s)return!1;if("audio"==s){if(!this.hasAudioDetector)return!1;const s=t,r=e;return s.state!==r.state||s.db!==r.db}if("motion"==s){if(!this.hasMotionDetector)return!1;const s=t,r=e;return void 0!==r.state?s.state!==r.state:!Os(s.detections,r.detections,!0)}if("object"==s){if(!this.hasObjectDetector)return!1;const s=e;return!Os(t.detections,s.detections,!0)}if("siren"==s){if(!this.hasSiren)return!1;const s=t,r=e;return s.state!==r.state||s.level!==r.level}if("battery"==s){if(!this.hasBattery)return!1;const s=t,r=e;return s.level!==r.level||s.lowBattery!==r.lowBattery||s.charging!==r.charging}if("doorbell"==s){if(!this.hasBinarySensor)return!1;const s=e;return t.state!==s.state}if("light"==s){if(!this.hasLight)return!1;const s=e;return t.state!==s.state}return!1}isStateEvent(t){return"timestamp"in t}}class Ns{}class Ms{}class Is{}class zs{}class qs{}class Us extends qs{delegate;onRequest;logger;constructor(t,e){super(),this.onRequest=t,this.logger=e}async detectAudio(t){return this.delegate?this.delegate.detectAudio(t):this._onRequest("detectAudio",[t])}_onRequest(t,e,s){return this.onRequest("audioDetectorDelegate",t,e,s)}}class Vs extends Is{delegate;onRequest;logger;constructor(t,e){super(),this.onRequest=t,this.logger=e}async detectImage(t){return this.delegate?this.delegate.detectImage(t):this._onRequest("detectImage",[t])}_onRequest(t,e,s){return this.onRequest("motionDetectorDelegate",t,e,s)}}class Ws extends zs{delegate;onRequest;logger;constructor(t,e){super(),this.onRequest=t,this.logger=e}async detectImage(t){return this.delegate?this.delegate.detectImage(t):this._onRequest("detectImage",[t])}_onRequest(t,e,s){return this.onRequest("objectDetectorDelegate",t,e,s)}}class Hs extends Ns{delegate;onRequest;logger;constructor(t,e){super(),this.onRequest=t,this.logger=e}async getStreamInfo(t){return this.delegate?this.delegate.getStreamInfo(t):this._onRequest("prebuffer","getStreamInfo",[t])}async updatePrebufferState(t,e,s){return this._onRequest("cameraFn","updatePrebufferState",{sourceId:t,container:e,state:s},0)}_onRequest(t,e,s,r){return this.onRequest("ptzDelegate",e,s,r)}}class $s extends Ms{delegate;onRequest;logger;constructor(t,e){super(),this.onRequest=t,this.logger=e}async moveAbsolute(t,e,s){return this.delegate?this.delegate.moveAbsolute(t,e,s):this._onRequest("moveAbsolute",[t,e,s])}async moveRelative(t,e,s){return this.delegate?this.delegate.moveRelative(t,e,s):this._onRequest("moveRelative",[t,e,s])}async moveContinuous(t,e,s){return this.delegate?this.delegate.moveContinuous(t,e,s):this._onRequest("moveContinuous",[t,e,s])}async stop(){return this.delegate?this.delegate.stop():this._onRequest("stop",[])}_onRequest(t,e,s){return this.onRequest("ptzDelegate",t,e,s)}}class Js extends EventTarget{cameraDevice;socketService;logger;options;videoPlayer;socket;streamId;closed=!1;micTransceiver=null;pc=null;buf=new Uint8Array(2097152);mediaSource=null;sourceBuffer=null;bufLen=0;mseCodecs="";videoPlayerMp4;media=["video","audio","microphone"];codecList=[];reconnectTimeout;_finishLoading=!1;get mode(){return this.options.mode}webrtcReconnectTimeout;constructor(t,e,s,r){super(),this.options=r,this.videoPlayer=r.videoElement,this.cameraDevice=t,this.socketService=e,this.logger=s;const{socket:i}=this.socketService.getSocket(`${t.id}-go2rtcSession`,!0);this.socket=i,this.socket.connect(),this.streamId=this.uuidv4(),this.createCodecsList()}connect(t){t&&(this.options.mode=t),this.socket.on("ws-open",this.onWsOpen.bind(this)),this.socket.on("ws-close",this.onWsClose.bind(this)),this.socket.on("ws-message",this.onWsMessage.bind(this)),this.socket.emit("ws-open",{id:this.streamId,cameraSource:this.options.sourceName,mode:this.options.mode})}disconnect(){this.socket.removeListener("ws-open",this.onWsOpen.bind(this)),this.socket.removeListener("ws-close",this.onWsClose.bind(this)),this.socket.removeListener("ws-message",this.onWsMessage.bind(this)),this.socket.emit("ws-close",{id:this.streamId})}async reconnect(t){this.dispatchEvent(new Event("reconnect")),this.close(),await new Promise((t=>setTimeout(t,100))),this.connect(t)}reset(){this._finishLoading=!1,this.pc?.getTransceivers().forEach((t=>t.sender?.track?.stop())),this.pc?.close(),this.pc=null,this.videoPlayerMp4?.remove(),this.videoPlayerMp4=void 0,this.videoPlayer.srcObject=null,this.videoPlayer.src="",this.videoPlayer.poster=""}close(){this.closed=!0,this.reset(),this.disconnect(),this.socket.emit("end"),this.socket.removeAllListeners()}onWsOpen({id:t}){if(t===this.streamId)switch(this.options.mode){case"webrtc":case"webrtc/tcp":this.requestWebrtc();break;case"mse":this.requestMse();break;case"hls":this.requestHls();break;case"mp4":this.requestMp4();break;case"mjpeg":this.requestMjpeg();break;default:this.dispatchEvent(new ErrorEvent("error",{message:"Unknown mode: "+this.options.mode}))}}onWsClose({id:t}){t===this.streamId&&(this.closed||void 0===this.options.reconnectInterval||(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=setTimeout((()=>{this.reconnect()}),this.options.reconnectInterval)))}onWsMessage({id:t,data:e}){if(t===this.streamId&&e.type)switch(e.type){case"mse":this.onMseData(e);break;case"hls":this.onHlsData(e);break;case"webrtc/candidate":case"webrtc/answer":this.onWebrtcData(e);break;case"mse-binary":this.onMseBuffer(e);break;case"mjpeg-binary":this.onMjpegBuffer(e);break;case"mp4-binary":this.onMp4Buffer(e);break;case"error":this.dispatchEvent(new ErrorEvent("error",{error:e,message:e.value}))}}async requestWebrtc(){this.reset(),this.pc=new RTCPeerConnection({bundlePolicy:"max-bundle",iceServers:[{urls:"stun:stun.l.google.com:19302"}],sdpSemantics:"unified-plan"}),this.pc.addEventListener("icecandidate",(t=>{if("webrtc/tcp"===this.options.mode&&"udp"===t.candidate?.protocol)return;const e=t.candidate?.toJSON().candidate||"";this.socket.emit("stream-payload",{id:this.streamId,data:{type:"webrtc/candidate",value:e}})})),this.pc.addEventListener("connectionstatechange",(()=>{if("connected"===this.pc?.connectionState){const t=this.pc?.getTransceivers().filter((t=>"recvonly"===t.currentDirection)).map((t=>t.receiver.track));this.videoPlayer.srcObject=new MediaStream(t),this.finishLoading(),this.play(),this.disconnect()}else"failed"!==this.pc?.connectionState&&"disconnected"!==this.pc?.connectionState||(clearTimeout(this.webrtcReconnectTimeout),this.webrtcReconnectTimeout=setTimeout((()=>{"failed"!==this.pc?.connectionState&&"disconnected"!==this.pc?.connectionState||this.reconnect()}),1e3))}));const t=await this.createOffer();t&&this.socket.emit("stream-payload",{id:this.streamId,data:{type:"webrtc/offer",value:t.sdp}})}async onWebrtcData(t){try{switch(t.type){case"webrtc/candidate":if("webrtc/tcp"===this.options.mode&&t.value.indexOf(" udp ")>0)return;await(this.pc?.addIceCandidate({candidate:t.value,sdpMid:"0"}));break;case"webrtc/answer":await(this.pc?.setRemoteDescription({type:"answer",sdp:t.value}));break;case"error":if(t.value.indexOf("webrtc/offer")<0)return;this.pc?.close()}}catch(t){this.dispatchEvent(new ErrorEvent("error",{error:t,message:t.message}))}}async createOffer(){if(this.pc){this.pc.addTransceiver("video",{direction:"recvonly"}),this.pc.addTransceiver("audio",{direction:"recvonly"}),this.micTransceiver=this.pc.addTransceiver("audio",{direction:"sendonly"});const t=await this.pc.createOffer();return await this.pc.setLocalDescription(t),t}}requestMse(){if(this.reset(),"ManagedMediaSource"in window){const t=window.ManagedMediaSource;this.mediaSource=new t,this.mediaSource.addEventListener("sourceopen",(()=>{this.socket.emit("stream-payload",{id:this.streamId,data:{type:"mse",value:this.parseCodecs(t.isTypeSupported)}})}),{once:!0}),this.videoPlayer.disableRemotePlayback=!0,this.videoPlayer.srcObject=this.mediaSource}else this.mediaSource=new MediaSource,this.mediaSource.addEventListener("sourceopen",(()=>{URL.revokeObjectURL(this.videoPlayer.src),this.socket.emit("stream-payload",{id:this.streamId,data:{type:"mse",value:this.parseCodecs(MediaSource.isTypeSupported)}})}),{once:!0}),this.videoPlayer.src=URL.createObjectURL(this.mediaSource),this.videoPlayer.srcObject=null;this.play(),this.mseCodecs=""}onMseData(t){this.mediaSource&&(this.mseCodecs=t.value,this.bufLen=0,this.buf=new Uint8Array(2097152),this.sourceBuffer=this.mediaSource.addSourceBuffer(t.value),this.sourceBuffer.mode="segments",this.sourceBuffer.addEventListener("updateend",(()=>{if(!this.sourceBuffer?.updating)try{if(this.bufLen>0){const t=this.buf.slice(0,this.bufLen);this.bufLen=0,this.sourceBuffer?.appendBuffer(t)}else if(this.sourceBuffer?.buffered?.length){const t=this.sourceBuffer.buffered.end(this.sourceBuffer.buffered.length-1)-15,e=this.sourceBuffer.buffered.start(0);t>e&&(this.sourceBuffer.remove(e,t),this.mediaSource?.setLiveSeekableRange(t,t+15))}}catch(t){}})))}async onMseBuffer(t){if("closed"!==this.mediaSource?.readyState)if(this.finishLoading(),this.sourceBuffer?.updating||this.bufLen>0){const e=new Uint8Array(t.value);this.buf.set(e,this.bufLen),this.bufLen+=e.byteLength}else try{this.sourceBuffer?.appendBuffer(t.value)}catch(t){}else this.closed||(this.closed=!0,this.dispatchEvent(new ErrorEvent("error",{message:"MediaSource closed"})),this.options.mode="webrtc",this.requestWebrtc())}requestMjpeg(){this.reset(),this.socket.emit("stream-payload",{id:this.streamId,data:{type:"mjpeg"}})}onMjpegBuffer(t){this.videoPlayer.controls=!1,this.videoPlayer.poster="data:image/jpeg;base64,"+this.btoaBinary(t.value),this.finishLoading()}requestMp4(){this.reset();const t=document.createElement("canvas");let e=null;this.videoPlayerMp4=document.createElement("video"),this.videoPlayerMp4.autoplay=!0,this.videoPlayerMp4.playsInline=!0,this.videoPlayerMp4.muted=!0,this.videoPlayerMp4.addEventListener("loadeddata",(()=>{this.videoPlayerMp4&&(e||(t.width=this.videoPlayerMp4.videoWidth,t.height=this.videoPlayerMp4.videoHeight,e=t.getContext("2d")),e?.drawImage(this.videoPlayerMp4,0,0,t.width,t.height),this.videoPlayer.controls=!1,this.videoPlayer.poster=t.toDataURL("image/jpeg"))}));const s=this.codecList.filter((t=>this.media.includes(t.indexOf("vc1")>0?"video":"audio"))).filter((t=>this.videoPlayer.canPlayType(`video/mp4; codecs="${t}"`))).join();this.socket.emit("stream-payload",{id:this.streamId,data:{type:"mp4",value:s}})}onMp4Buffer(t){this.finishLoading(),this.videoPlayerMp4&&(this.videoPlayerMp4.src="data:video/mp4;base64,"+this.btoaBinary(t.value))}requestHls(){this.reset(),this.socket.emit("stream-payload",{id:this.streamId,data:{type:"hls",value:this.parseCodecs((t=>this.videoPlayer.canPlayType(t)))}})}onHlsData(t){const e="http"+t.wsURL.substring(2,t.wsURL.indexOf("/ws"))+"/hls/",s=t.value.replace("hls/",e),r="data:application/vnd.apple.mpegurl;base64,"+btoa(s.toString());this.videoPlayer.src=r,this.finishLoading(),this.play()}async play(){try{await this.videoPlayer.play()}catch(t){if(!this.videoPlayer.muted)return this.videoPlayer.muted=!0,this.play();this.logger.warn(this.cameraDevice.name,t)}}finishLoading(){this._finishLoading||(this._finishLoading=!0,this.dispatchEvent(new Event("finishLoading")))}createCodecsList(){const t=["avc1.640029","avc1.64002A","avc1.640033","hvc1.1.6.L153.B0","mp4a.40.2","mp4a.40.5","flac","opus"],e="undefined"==typeof window?null:navigator.userAgent.match(/Version\/(\d+).+Safari/);if(e?.[1]){const s=e[1]<"13"?"mp4a.40.2":e[1]<"14"?"flac":"opus";t.splice(t.indexOf(s))}this.codecList=t}parseCodecs(t){return this.codecList.filter((t=>this.media.includes(t.indexOf("vc1")>0?"video":"audio"))).filter((e=>t(`video/mp4; codecs="${e}"`))).join()}btoaBinary(t){const e=new Uint8Array(t),s=e.byteLength;let r="";for(let t=0;t<s;t++)r+=String.fromCharCode(e[t]);return window.btoa(r)}uuidv4(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)))}}class Gs extends Fs{socketService;socket;pluginName="@camera.ui/client";subject;_started=!1;get started(){return this._started}prebufferDelegate=new Hs(this.onRequest,this.logger);ptzDelegate=new $s(this.onRequest,this.logger);audioDetectorDelegate=new Us(this.onRequest,this.logger);motionDetectorDelegate=new Vs(this.onRequest,this.logger);objectDetectorDelegate=new Ws(this.onRequest,this.logger);get sources(){return super.sources.map((t=>({...t,updatePrebufferingState:(e,s)=>this.prebufferDelegate.updatePrebufferState(t._id,e,s.state),getPrebufferingState:e=>super.cameraSourcePrebufferState(t._id,e),onPrebuffering:e=>super.createPrebufferStateObservable(t._id,e),getStreamInfo:async()=>this.prebufferDelegate.getStreamInfo(t.name)})))}constructor(t,e,s){super(t,s),this.socketService=e;const{socket:r}=this.socketService.getSocket(this.id,!0);this.socket=r,this.socket.connect(),this.subject=`${this.pluginName}.camera.${this.id}`,this.listenToMessages()}async start(){this._started||(this._started=!0,await this.refreshStates(),this.socket.emit("joinRoomStates",this.id))}stop(){this._started=!1,this.socket.emit("leaveRoomStates",this.id)}close(){this.cleanup()}connect(){return this.onRequest("cameraFn","connect")}disconnect(){return this.onRequest("cameraFn","disconnect")}getIceServers(){return this.onRequest("cameraFn","getIceServers")}createSession(t){return new Js(this,this.socketService,this.logger,t)}async updateState(t,e){const{changed:s,event:r}=super.checkStateInternal(t,e);if(s)return super.updateStateInternal(t,r,!0),this.onRequest("cameraFn","updateState",{stateName:t,eventData:r},0)}addCameraSource(t){return this.onRequest("cameraFn","addCameraSource",{source:t})}updateCameraSource(t,e){return this.onRequest("cameraFn","updateCameraSource",{id:t,...e})}removeCameraSource(t){return this.onRequest("cameraFn","removeCameraSource",{id:t})}async refreshStates(){const t=await this.onRequest("cameraFn","refreshStates");super.updateCamera(t.camera),super.updateCameraState(t.cameraState);for(const[e,s]of Object.entries(t.states))super.updateStateInternal(e,s,!0)}async cleanup(){this.stop(),this.removeAllListeners(),this.unsubscribe(),this.socket.removeAllListeners()}listenToMessages(){this.socket.emit("joinRoomDevice",this.id),this.socket.on("updateState",(t=>{t.cameraId===this.id&&super.updateStateInternal(t.stateName,t.data.newEvent,!0)})),this.socket.on("updateDevice",(t=>{if(t.cameraId===this.id)switch(t.type){case"removed":this.cleanup();break;case"updated":super.updateCamera(t.data);break;case"cameraState":super.updateCameraState(t.data);break;case"prebufferState":super.updatePrebuffer(t.data.sourceId,t.data.container,t.data.state)}}))}onRequest(t,e,s=[],r=5e3){const i={requestId:crypto.randomUUID(),targetId:this.subject,targetName:this.name,pluginId:this.pluginName,cameraId:this.id,type:"request",proxy:"camera",client:t,fn:e,args:s,timestamp:Date.now(),timeout:r};return new Promise(((t,e)=>{this.socket.emit("request",i,(s=>{s.response?t(s.response):s.error?e(s.error):t()}))}))}}class Ks{socketService;socket;logger;pluginName="@camera.ui/client";subject;constructor(t,e){this.socketService=t,this.socket=t.socket,this.logger=e,this.subject=`${this.pluginName}.deviceManager`}async getCameraById(t){const e=await this.onRequest("getCameraById",{id:t});if(e){const t=new Gs(e,this.socketService,this.logger);return await t.refreshStates(),t}}async getCameraByName(t){const e=await this.onRequest("getCameraByName",{name:t});if(e){const t=new Gs(e,this.socketService,this.logger);return await t.refreshStates(),t}}onRequest(t,e={}){const s={requestId:crypto.randomUUID(),targetId:this.subject,targetName:this.pluginName,pluginId:this.pluginName,type:"request",proxy:"device",client:"device",fn:t,args:e,timestamp:Date.now(),timeout:5e3};return new Promise(((t,e)=>{this.socket.emit("request",s,(s=>{s.response?t(s.response):s.error?e(s.error):t()}))}))}}class Ys{socketService;logger;constructor(t,e){this.socketService=t,this.logger=e}}class Xs{socketService;logger;constructor(t,e){this.socketService=t,this.logger=e}}const Qs=Object.create(null);Qs.open="0",Qs.close="1",Qs.ping="2",Qs.pong="3",Qs.message="4",Qs.upgrade="5",Qs.noop="6";const Zs=Object.create(null);Object.keys(Qs).forEach((t=>{Zs[Qs[t]]=t}));const tr={type:"error",data:"parser error"},er="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),sr="function"==typeof ArrayBuffer,rr=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,ir=({type:t,data:e},s,r)=>er&&e instanceof Blob?s?r(e):nr(e,r):sr&&(e instanceof ArrayBuffer||rr(e))?s?r(e):nr(new Blob([e]),r):r(Qs[t]+(e||"")),nr=(t,e)=>{const s=new FileReader;return s.onload=function(){const t=s.result.split(",")[1];e("b"+(t||""))},s.readAsDataURL(t)};function or(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let ar;const cr="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let t=0;t<64;t++)cr["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(t)]=t;const hr="function"==typeof ArrayBuffer,ur=(t,e)=>{if("string"!=typeof t)return{type:"message",data:dr(t,e)};const s=t.charAt(0);return"b"===s?{type:"message",data:lr(t.substring(1),e)}:Zs[s]?t.length>1?{type:Zs[s],data:t.substring(1)}:{type:Zs[s]}:tr},lr=(t,e)=>{if(hr){const s=(t=>{let e,s,r,i,n,o=.75*t.length,a=t.length,c=0;"="===t[t.length-1]&&(o--,"="===t[t.length-2]&&o--);const h=new ArrayBuffer(o),u=new Uint8Array(h);for(e=0;e<a;e+=4)s=cr[t.charCodeAt(e)],r=cr[t.charCodeAt(e+1)],i=cr[t.charCodeAt(e+2)],n=cr[t.charCodeAt(e+3)],u[c++]=s<<2|r>>4,u[c++]=(15&r)<<4|i>>2,u[c++]=(3&i)<<6|63&n;return h})(t);return dr(s,e)}return{base64:!0,data:t}},dr=(t,e)=>"blob"===e?t instanceof Blob?t:new Blob([t]):t instanceof ArrayBuffer?t:t.buffer,fr=String.fromCharCode(30);let pr;function gr(t){return t.reduce(((t,e)=>t+e.length),0)}function mr(t,e){if(t[0].length===e)return t.shift();const s=new Uint8Array(e);let r=0;for(let i=0;i<e;i++)s[i]=t[0][r++],r===t[0].length&&(t.shift(),r=0);return t.length&&r<t[0].length&&(t[0]=t[0].slice(r)),s}function yr(t){if(t)return function(t){for(var e in yr.prototype)t[e]=yr.prototype[e];return t}(t)}yr.prototype.on=yr.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},yr.prototype.once=function(t,e){function s(){this.off(t,s),e.apply(this,arguments)}return s.fn=e,this.on(t,s),this},yr.prototype.off=yr.prototype.removeListener=yr.prototype.removeAllListeners=yr.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var s,r=this._callbacks["$"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i=0;i<r.length;i++)if((s=r[i])===e||s.fn===e){r.splice(i,1);break}return 0===r.length&&delete this._callbacks["$"+t],this},yr.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),s=this._callbacks["$"+t],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(s){r=0;for(var i=(s=s.slice(0)).length;r<i;++r)s[r].apply(this,e)}return this},yr.prototype.emitReserved=yr.prototype.emit,yr.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},yr.prototype.hasListeners=function(t){return!!this.listeners(t).length};const br="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function vr(t,...e){return e.reduce(((e,s)=>(t.hasOwnProperty(s)&&(e[s]=t[s]),e)),{})}const wr=br.setTimeout,Sr=br.clearTimeout;function kr(t,e){e.useNativeTimers?(t.setTimeoutFn=wr.bind(br),t.clearTimeoutFn=Sr.bind(br)):(t.setTimeoutFn=br.setTimeout.bind(br),t.clearTimeoutFn=br.clearTimeout.bind(br))}class Er extends Error{constructor(t,e,s){super(t),this.description=e,this.context=s,this.type="TransportError"}}class _r extends yr{constructor(t){super(),this.writable=!1,kr(this,t),this.opts=t,this.query=t.query,this.socket=t.socket}onError(t,e,s){return super.emitReserved("error",new Er(t,e,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(t){"open"===this.readyState&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const e=ur(t,this.socket.binaryType);this.onPacket(e)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,e={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(e)}_hostname(){const t=this.opts.hostname;return-1===t.indexOf(":")?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(t){const e=function(t){let e="";for(let s in t)t.hasOwnProperty(s)&&(e.length&&(e+="&"),e+=encodeURIComponent(s)+"="+encodeURIComponent(t[s]));return e}(t);return e.length?"?"+e:""}}const Or="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Tr=64,xr={};let Ar,Rr=0,Lr=0;function Cr(t){let e="";do{e=Or[t%Tr]+e,t=Math.floor(t/Tr)}while(t>0);return e}function jr(){const t=Cr(+new Date);return t!==Ar?(Rr=0,Ar=t):t+"."+Cr(Rr++)}for(;Lr<Tr;Lr++)xr[Or[Lr]]=Lr;let Br=!1;try{Br="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(t){}const Pr=Br;function Dr(t){const e=t.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!e||Pr))return new XMLHttpRequest}catch(t){}if(!e)try{return new(br[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(t){}}function Fr(){}const Nr=null!=new Dr({xdomain:!1}).responseType;class Mr extends yr{constructor(t,e){super(),kr(this,e),this.opts=e,this.method=e.method||"GET",this.uri=t,this.data=void 0!==e.data?e.data:null,this.create()}create(){var t;const e=vr(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this.opts.xd;const s=this.xhr=new Dr(e);try{s.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let t in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(t)&&s.setRequestHeader(t,this.opts.extraHeaders[t])}}catch(t){}if("POST"===this.method)try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(t){}try{s.setRequestHeader("Accept","*/*")}catch(t){}null===(t=this.opts.cookieJar)||void 0===t||t.addCookies(s),"withCredentials"in s&&(s.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(s.timeout=this.opts.requestTimeout),s.onreadystatechange=()=>{var t;3===s.readyState&&(null===(t=this.opts.cookieJar)||void 0===t||t.parseCookies(s)),4===s.readyState&&(200===s.status||1223===s.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof s.status?s.status:0)}),0))},s.send(this.data)}catch(t){return void this.setTimeoutFn((()=>{this.onError(t)}),0)}"undefined"!=typeof document&&(this.index=Mr.requestsCount++,Mr.requests[this.index]=this)}onError(t){this.emitReserved("error",t,this.xhr),this.cleanup(!0)}cleanup(t){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=Fr,t)try{this.xhr.abort()}catch(t){}"undefined"!=typeof document&&delete Mr.requests[this.index],this.xhr=null}}onLoad(){const t=this.xhr.responseText;null!==t&&(this.emitReserved("data",t),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}function Ir(){for(let t in Mr.requests)Mr.requests.hasOwnProperty(t)&&Mr.requests[t].abort()}Mr.requestsCount=0,Mr.requests={},"undefined"!=typeof document&&("function"==typeof attachEvent?attachEvent("onunload",Ir):"function"==typeof addEventListener&&addEventListener("onpagehide"in br?"pagehide":"unload",Ir,!1));const zr="function"==typeof Promise&&"function"==typeof Promise.resolve?t=>Promise.resolve().then(t):(t,e)=>e(t,0),qr=br.WebSocket||br.MozWebSocket,Ur="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),Vr={websocket:class extends _r{constructor(t){super(t),this.supportsBinary=!t.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const t=this.uri(),e=this.opts.protocols,s=Ur?{}:vr(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=Ur?new qr(t,e,s):e?new qr(t,e):new qr(t)}catch(t){return this.emitReserved("error",t)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let e=0;e<t.length;e++){const s=t[e],r=e===t.length-1;ir(s,this.supportsBinary,(t=>{try{this.ws.send(t)}catch(t){}r&&zr((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",e=this.query||{};return this.opts.timestampRequests&&(e[this.opts.timestampParam]=jr()),this.supportsBinary||(e.b64=1),this.createUri(t,e)}check(){return!!qr}},webtransport:class extends _r{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((()=>{this.onClose()})).catch((t=>{this.onError("webtransport error",t)})),this.transport.ready.then((()=>{this.transport.createBidirectionalStream().then((t=>{const e=function(t,e){pr||(pr=new TextDecoder);const s=[];let r=0,i=-1,n=!1;return new TransformStream({transform(o,a){for(s.push(o);;){if(0===r){if(gr(s)<1)break;const t=mr(s,1);n=!(128&~t[0]),i=127&t[0],r=i<126?3:126===i?1:2}else if(1===r){if(gr(s)<2)break;const t=mr(s,2);i=new DataView(t.buffer,t.byteOffset,t.length).getUint16(0),r=3}else if(2===r){if(gr(s)<8)break;const t=mr(s,8),e=new DataView(t.buffer,t.byteOffset,t.length),n=e.getUint32(0);if(n>Math.pow(2,21)-1){a.enqueue(tr);break}i=n*Math.pow(2,32)+e.getUint32(4),r=3}else{if(gr(s)<i)break;const t=mr(s,i);a.enqueue(ur(n?t:pr.decode(t),e)),r=0}if(0===i||i>t){a.enqueue(tr);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=t.readable.pipeThrough(e).getReader(),r=new TransformStream({transform(t,e){!function(t,e){er&&t.data instanceof Blob?t.data.arrayBuffer().then(or).then(e):sr&&(t.data instanceof ArrayBuffer||rr(t.data))?e(or(t.data)):ir(t,!1,(t=>{ar||(ar=new TextEncoder),e(ar.encode(t))}))}(t,(s=>{const r=s.length;let i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);const t=new DataView(i.buffer);t.setUint8(0,126),t.setUint16(1,r)}else{i=new Uint8Array(9);const t=new DataView(i.buffer);t.setUint8(0,127),t.setBigUint64(1,BigInt(r))}t.data&&"string"!=typeof t.data&&(i[0]|=128),e.enqueue(i),e.enqueue(s)}))}});r.readable.pipeTo(t.writable),this.writer=r.writable.getWriter();const i=()=>{s.read().then((({done:t,value:e})=>{t||(this.onPacket(e),i())})).catch((t=>{}))};i();const n={type:"open"};this.query.sid&&(n.data=`{"sid":"${this.query.sid}"}`),this.writer.write(n).then((()=>this.onOpen()))}))})))}write(t){this.writable=!1;for(let e=0;e<t.length;e++){const s=t[e],r=e===t.length-1;this.writer.write(s).then((()=>{r&&zr((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var t;null===(t=this.transport)||void 0===t||t.close()}},polling:class extends _r{constructor(t){if(super(t),this.polling=!1,"undefined"!=typeof location){const e="https:"===location.protocol;let s=location.port;s||(s=e?"443":"80"),this.xd="undefined"!=typeof location&&t.hostname!==location.hostname||s!==t.port}const e=t&&t.forceBase64;this.supportsBinary=Nr&&!e,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(t){this.readyState="pausing";const e=()=>{this.readyState="paused",t()};if(this.polling||!this.writable){let t=0;this.polling&&(t++,this.once("pollComplete",(function(){--t||e()}))),this.writable||(t++,this.once("drain",(function(){--t||e()})))}else e()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){((t,e)=>{const s=t.split(fr),r=[];for(let t=0;t<s.length;t++){const i=ur(s[t],e);if(r.push(i),"error"===i.type)break}return r})(t,this.socket.binaryType).forEach((t=>{if("opening"===this.readyState&&"open"===t.type&&this.onOpen(),"close"===t.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(t)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const t=()=>{this.write([{type:"close"}])};"open"===this.readyState?t():this.once("open",t)}write(t){this.writable=!1,((t,e)=>{const s=t.length,r=new Array(s);let i=0;t.forEach(((t,n)=>{ir(t,!1,(t=>{r[n]=t,++i===s&&e(r.join(fr))}))}))})(t,(t=>{this.doWrite(t,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const t=this.opts.secure?"https":"http",e=this.query||{};return!1!==this.opts.timestampRequests&&(e[this.opts.timestampParam]=jr()),this.supportsBinary||e.sid||(e.b64=1),this.createUri(t,e)}request(t={}){return Object.assign(t,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new Mr(this.uri(),t)}doWrite(t,e){const s=this.request({method:"POST",data:t});s.on("success",e),s.on("error",((t,e)=>{this.onError("xhr post error",t,e)}))}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",((t,e)=>{this.onError("xhr poll error",t,e)})),this.pollXhr=t}}},Wr=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Hr=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function $r(t){if(t.length>2e3)throw"URI too long";const e=t,s=t.indexOf("["),r=t.indexOf("]");-1!=s&&-1!=r&&(t=t.substring(0,s)+t.substring(s,r).replace(/:/g,";")+t.substring(r,t.length));let i=Wr.exec(t||""),n={},o=14;for(;o--;)n[Hr[o]]=i[o]||"";return-1!=s&&-1!=r&&(n.source=e,n.host=n.host.substring(1,n.host.length-1).replace(/;/g,":"),n.authority=n.authority.replace("[","").replace("]","").replace(/;/g,":"),n.ipv6uri=!0),n.pathNames=function(t,e){const s=e.replace(/\/{2,9}/g,"/").split("/");return"/"!=e.slice(0,1)&&0!==e.length||s.splice(0,1),"/"==e.slice(-1)&&s.splice(s.length-1,1),s}(0,n.path),n.queryKey=function(t,e){const s={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(t,e,r){e&&(s[e]=r)})),s}(0,n.query),n}class Jr extends yr{constructor(t,e={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],t&&"object"==typeof t&&(e=t,t=null),t?(t=$r(t),e.hostname=t.host,e.secure="https"===t.protocol||"wss"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=$r(e.host).host),kr(this,e),this.secure=null!=e.secure?e.secure:"undefined"!=typeof location&&"https:"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.hostname=e.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=e.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=e.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},e),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(t){let e={},s=t.split("&");for(let t=0,r=s.length;t<r;t++){let r=s[t].split("=");e[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return e}(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(t){const e=Object.assign({},this.opts.query);e.EIO=4,e.transport=t,this.id&&(e.sid=this.id);const s=Object.assign({},this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new Vr[t](s)}open(){let t;if(this.opts.rememberUpgrade&&Jr.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(t){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(t=>this.onClose("transport close",t)))}probe(t){let e=this.createTransport(t),s=!1;Jr.priorWebsocketSuccess=!1;const r=()=>{s||(e.send([{type:"ping",data:"probe"}]),e.once("packet",(t=>{if(!s)if("pong"===t.type&&"probe"===t.data){if(this.upgrading=!0,this.emitReserved("upgrading",e),!e)return;Jr.priorWebsocketSuccess="websocket"===e.name,this.transport.pause((()=>{s||"closed"!==this.readyState&&(h(),this.setTransport(e),e.send([{type:"upgrade"}]),this.emitReserved("upgrade",e),e=null,this.upgrading=!1,this.flush())}))}else{const t=new Error("probe error");t.transport=e.name,this.emitReserved("upgradeError",t)}})))};function i(){s||(s=!0,h(),e.close(),e=null)}const n=t=>{const s=new Error("probe error: "+t);s.transport=e.name,i(),this.emitReserved("upgradeError",s)};function o(){n("transport closed")}function a(){n("socket closed")}function c(t){e&&t.name!==e.name&&i()}const h=()=>{e.removeListener("open",r),e.removeListener("error",n),e.removeListener("close",o),this.off("close",a),this.off("upgrading",c)};e.once("open",r),e.once("error",n),e.once("close",o),this.once("close",a),this.once("upgrading",c),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==t?this.setTimeoutFn((()=>{s||e.open()}),200):e.open()}onOpen(){if(this.readyState="open",Jr.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){let t=0;const e=this.upgrades.length;for(;t<e;t++)this.probe(this.upgrades[t])}}onPacket(t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),this.resetPingTimeout(),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const e=new Error("server error");e.code=t.data,this.onError(e);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data)}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.maxPayload=t.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((()=>{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this.getWritablePackets();this.transport.send(t),this.prevBufferLen=t.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let s=0;s<this.writeBuffer.length;s++){const r=this.writeBuffer[s].data;if(r&&(t+="string"==typeof(e=r)?function(t){let e=0,s=0;for(let r=0,i=t.length;r<i;r++)e=t.charCodeAt(r),e<128?s+=1:e<2048?s+=2:e<55296||e>=57344?s+=3:(r++,s+=4);return s}(e):Math.ceil(1.33*(e.byteLength||e.size))),s>0&&t>this.maxPayload)return this.writeBuffer.slice(0,s);t+=2}var e;return this.writeBuffer}write(t,e,s){return this.sendPacket("message",t,e,s),this}send(t,e,s){return this.sendPacket("message",t,e,s),this}sendPacket(t,e,s,r){if("function"==typeof e&&(r=e,e=void 0),"function"==typeof s&&(r=s,s=null),"closing"===this.readyState||"closed"===this.readyState)return;(s=s||{}).compress=!1!==s.compress;const i={type:t,data:e,options:s};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}close(){const t=()=>{this.onClose("forced close"),this.transport.close()},e=()=>{this.off("upgrade",e),this.off("upgradeError",e),t()},s=()=>{this.once("upgrade",e),this.once("upgradeError",e)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?s():t()})):this.upgrading?s():t()),this}onError(t){Jr.priorWebsocketSuccess=!1,this.emitReserved("error",t),this.onClose("transport error",t)}onClose(t,e){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const e=[];let s=0;const r=t.length;for(;s<r;s++)~this.transports.indexOf(t[s])&&e.push(t[s]);return e}}Jr.protocol=4,Jr.protocol;const Gr="function"==typeof ArrayBuffer,Kr=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,Yr=Object.prototype.toString,Xr="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Yr.call(Blob),Qr="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===Yr.call(File);function Zr(t){return Gr&&(t instanceof ArrayBuffer||Kr(t))||Xr&&t instanceof Blob||Qr&&t instanceof File}function ti(t,e){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let e=0,s=t.length;e<s;e++)if(ti(t[e]))return!0;return!1}if(Zr(t))return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return ti(t.toJSON(),!0);for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&ti(t[e]))return!0;return!1}function ei(t){const e=[],s=t.data,r=t;return r.data=si(s,e),r.attachments=e.length,{packet:r,buffers:e}}function si(t,e){if(!t)return t;if(Zr(t)){const s={_placeholder:!0,num:e.length};return e.push(t),s}if(Array.isArray(t)){const s=new Array(t.length);for(let r=0;r<t.length;r++)s[r]=si(t[r],e);return s}if("object"==typeof t&&!(t instanceof Date)){const s={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(s[r]=si(t[r],e));return s}return t}function ri(t,e){return t.data=ii(t.data,e),delete t.attachments,t}function ii(t,e){if(!t)return t;if(t&&!0===t._placeholder){if("number"==typeof t.num&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}if(Array.isArray(t))for(let s=0;s<t.length;s++)t[s]=ii(t[s],e);else if("object"==typeof t)for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(t[s]=ii(t[s],e));return t}const ni=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],oi=5;var ai;!function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"}(ai||(ai={}));class ci{constructor(t){this.replacer=t}encode(t){return t.type!==ai.EVENT&&t.type!==ai.ACK||!ti(t)?[this.encodeAsString(t)]:this.encodeAsBinary({type:t.type===ai.EVENT?ai.BINARY_EVENT:ai.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id})}encodeAsString(t){let e=""+t.type;return t.type!==ai.BINARY_EVENT&&t.type!==ai.BINARY_ACK||(e+=t.attachments+"-"),t.nsp&&"/"!==t.nsp&&(e+=t.nsp+","),null!=t.id&&(e+=t.id),null!=t.data&&(e+=JSON.stringify(t.data,this.replacer)),e}encodeAsBinary(t){const e=ei(t),s=this.encodeAsString(e.packet),r=e.buffers;return r.unshift(s),r}}function hi(t){return"[object Object]"===Object.prototype.toString.call(t)}class ui extends yr{constructor(t){super(),this.reviver=t}add(t){let e;if("string"==typeof t){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");e=this.decodeString(t);const s=e.type===ai.BINARY_EVENT;s||e.type===ai.BINARY_ACK?(e.type=s?ai.EVENT:ai.ACK,this.reconstructor=new li(e),0===e.attachments&&super.emitReserved("decoded",e)):super.emitReserved("decoded",e)}else{if(!Zr(t)&&!t.base64)throw new Error("Unknown type: "+t);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");e=this.reconstructor.takeBinaryData(t),e&&(this.reconstructor=null,super.emitReserved("decoded",e))}}decodeString(t){let e=0;const s={type:Number(t.charAt(0))};if(void 0===ai[s.type])throw new Error("unknown packet type "+s.type);if(s.type===ai.BINARY_EVENT||s.type===ai.BINARY_ACK){const r=e+1;for(;"-"!==t.charAt(++e)&&e!=t.length;);const i=t.substring(r,e);if(i!=Number(i)||"-"!==t.charAt(e))throw new Error("Illegal attachments");s.attachments=Number(i)}if("/"===t.charAt(e+1)){const r=e+1;for(;++e&&","!==t.charAt(e)&&e!==t.length;);s.nsp=t.substring(r,e)}else s.nsp="/";const r=t.charAt(e+1);if(""!==r&&Number(r)==r){const r=e+1;for(;++e;){const s=t.charAt(e);if(null==s||Number(s)!=s){--e;break}if(e===t.length)break}s.id=Number(t.substring(r,e+1))}if(t.charAt(++e)){const r=this.tryParse(t.substr(e));if(!ui.isPayloadValid(s.type,r))throw new Error("invalid payload");s.data=r}return s}tryParse(t){try{return JSON.parse(t,this.reviver)}catch(t){return!1}}static isPayloadValid(t,e){switch(t){case ai.CONNECT:return hi(e);case ai.DISCONNECT:return void 0===e;case ai.CONNECT_ERROR:return"string"==typeof e||hi(e);case ai.EVENT:case ai.BINARY_EVENT:return Array.isArray(e)&&("number"==typeof e[0]||"string"==typeof e[0]&&-1===ni.indexOf(e[0]));case ai.ACK:case ai.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class li{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const t=ri(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function di(t,e,s){return t.on(e,s),function(){t.off(e,s)}}const fi=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class pi extends yr{constructor(t,e,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[di(t,"open",this.onopen.bind(this)),di(t,"packet",this.onpacket.bind(this)),di(t,"error",this.onerror.bind(this)),di(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...e){if(fi.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(e.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(e),this;const s={type:ai.EVENT,data:e,options:{}};if(s.options.compress=!1!==this.flags.compress,"function"==typeof e[e.length-1]){const t=this.ids++,r=e.pop();this._registerAckCallback(t,r),s.id=t}const r=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!r||!this.connected)||(this.connected?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),this.flags={},this}_registerAckCallback(t,e){var s;const r=null!==(s=this.flags.timeout)&&void 0!==s?s:this._opts.ackTimeout;if(void 0===r)return void(this.acks[t]=e);const i=this.io.setTimeoutFn((()=>{delete this.acks[t];for(let e=0;e<this.sendBuffer.length;e++)this.sendBuffer[e].id===t&&this.sendBuffer.splice(e,1);e.call(this,new Error("operation has timed out"))}),r),n=(...t)=>{this.io.clearTimeoutFn(i),e.apply(this,t)};n.withError=!0,this.acks[t]=n}emitWithAck(t,...e){return new Promise(((s,r)=>{const i=(t,e)=>t?r(t):s(e);i.withError=!0,e.push(i),this.emit(t,...e)}))}_addToQueue(t){let e;"function"==typeof t[t.length-1]&&(e=t.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push(((t,...r)=>{if(s===this._queue[0])return null!==t?s.tryCount>this._opts.retries&&(this._queue.shift(),e&&e(t)):(this._queue.shift(),e&&e(null,...r)),s.pending=!1,this._drainQueue()})),this._queue.push(s),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||0===this._queue.length)return;const e=this._queue[0];e.pending&&!t||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){"function"==typeof this.auth?this.auth((t=>{this._sendConnectPacket(t)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:ai.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,e){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,e),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach((t=>{if(!this.sendBuffer.some((e=>String(e.id)===t))){const e=this.acks[t];delete this.acks[t],e.withError&&e.call(this,new Error("socket has been disconnected"))}}))}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case ai.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case ai.EVENT:case ai.BINARY_EVENT:this.onevent(t);break;case ai.ACK:case ai.BINARY_ACK:this.onack(t);break;case ai.DISCONNECT:this.ondisconnect();break;case ai.CONNECT_ERROR:this.destroy();const e=new Error(t.data.message);e.data=t.data.data,this.emitReserved("connect_error",e)}}onevent(t){const e=t.data||[];null!=t.id&&e.push(this.ack(t.id)),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const s of e)s.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&"string"==typeof t[t.length-1]&&(this._lastOffset=t[t.length-1])}ack(t){const e=this;let s=!1;return function(...r){s||(s=!0,e.packet({type:ai.ACK,id:t,data:r}))}}onack(t){const e=this.acks[t.id];"function"==typeof e&&(delete this.acks[t.id],e.withError&&t.data.unshift(null),e.apply(this,t.data))}onconnect(t,e){this.id=t,this.recovered=e&&this._pid===e,this._pid=e,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((t=>this.emitEvent(t))),this.receiveBuffer=[],this.sendBuffer.forEach((t=>{this.notifyOutgoingListeners(t),this.packet(t)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((t=>t())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:ai.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let s=0;s<e.length;s++)if(t===e[s])return e.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const e=this._anyOutgoingListeners;for(let s=0;s<e.length;s++)if(t===e[s])return e.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const e=this._anyOutgoingListeners.slice();for(const s of e)s.apply(this,t.data)}}}function gi(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}gi.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),s=Math.floor(e*this.jitter*t);t=1&Math.floor(10*e)?t+s:t-s}return 0|Math.min(t,this.max)},gi.prototype.reset=function(){this.attempts=0},gi.prototype.setMin=function(t){this.ms=t},gi.prototype.setMax=function(t){this.max=t},gi.prototype.setJitter=function(t){this.jitter=t};class mi extends yr{constructor(t,e){var s;super(),this.nsps={},this.subs=[],t&&"object"==typeof t&&(e=t,t=void 0),(e=e||{}).path=e.path||"/socket.io",this.opts=e,kr(this,e),this.reconnection(!1!==e.reconnection),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(s=e.randomizationFactor)&&void 0!==s?s:.5),this.backoff=new gi({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==e.timeout?2e4:e.timeout),this._readyState="closed",this.uri=t;const i=e.parser||r;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==e.autoConnect,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection}reconnectionAttempts(t){return void 0===t?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var e;return void 0===t?this._reconnectionDelay:(this._reconnectionDelay=t,null===(e=this.backoff)||void 0===e||e.setMin(t),this)}randomizationFactor(t){var e;return void 0===t?this._randomizationFactor:(this._randomizationFactor=t,null===(e=this.backoff)||void 0===e||e.setJitter(t),this)}reconnectionDelayMax(t){var e;return void 0===t?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,null===(e=this.backoff)||void 0===e||e.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new Jr(this.uri,this.opts);const e=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const r=di(e,"open",(function(){s.onopen(),t&&t()})),i=e=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",e),t?t(e):this.maybeReconnectOnOpen()},n=di(e,"error",i);if(!1!==this._timeout){const t=this._timeout,s=this.setTimeoutFn((()=>{r(),i(new Error("timeout")),e.close()}),t);this.opts.autoUnref&&s.unref(),this.subs.push((()=>{this.clearTimeoutFn(s)}))}return this.subs.push(r),this.subs.push(n),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(di(t,"ping",this.onping.bind(this)),di(t,"data",this.ondata.bind(this)),di(t,"error",this.onerror.bind(this)),di(t,"close",this.onclose.bind(this)),di(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(t){this.onclose("parse error",t)}}ondecoded(t){zr((()=>{this.emitReserved("packet",t)}),this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,e){let s=this.nsps[t];return s?this._autoConnect&&!s.active&&s.connect():(s=new pi(this,t,e),this.nsps[t]=s),s}_destroy(t){const e=Object.keys(this.nsps);for(const t of e)if(this.nsps[t].active)return;this._close()}_packet(t){const e=this.encoder.encode(t);for(let s=0;s<e.length;s++)this.engine.write(e[s],t.options)}cleanup(){this.subs.forEach((t=>t())),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(t,e){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const e=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn((()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),t.skipReconnect||t.open((e=>{e?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",e)):t.onreconnect()})))}),e);this.opts.autoUnref&&s.unref(),this.subs.push((()=>{this.clearTimeoutFn(s)}))}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const yi={};function bi(t,e){"object"==typeof t&&(e=t,t=void 0);const s=function(t,e="",s){let r=t;s=s||"undefined"!=typeof location&&location,null==t&&(t=s.protocol+"//"+s.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?s.protocol+t:s.host+t),/^(https?|wss?):\/\//.test(t)||(t=void 0!==s?s.protocol+"//"+t:"https://"+t),r=$r(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const i=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+e,r.href=r.protocol+"://"+i+(s&&s.port===r.port?"":":"+r.port),r}(t,(e=e||{}).path||"/socket.io"),r=s.source,i=s.id,n=s.path,o=yi[i]&&n in yi[i].nsps;let a;return e.forceNew||e["force new connection"]||!1===e.multiplex||o?a=new mi(r,e):(yi[i]||(yi[i]=new mi(r,e)),a=yi[i]),s.query&&!e.query&&(e.query=s.queryKey),a.socket(s.path,e)}Object.assign(bi,{Manager:mi,Socket:pi,io:bi,connect:bi});class vi{socket;token;endpoint;socketList=new Map;constructor(t,e){this.endpoint=t.replace("https://","wss://").replace("http://","ws://"),this.token=e,this.socket=this.getSocket("default").socket,this.socket.connect()}close(){this.socket.emit("end"),this.socket.removeAllListeners(),this.socket.disconnect()}getSocket(t,e){return this.socketList.has(t)||this.socketList.set(t,this.createManager(e)),this.socketList.get(t)}createManager(t){const e=new mi(this.endpoint,{reconnection:!0,reconnectionDelay:500,rejectUnauthorized:!1,transports:["websocket"],forceNew:t}),s=e.socket("/proxy",{auth:{token:`Bearer ${this.token}`}});return{manager:e,socket:s}}}class wi{api;socketService;config;logger;token;deviceManager;pluginsManager;systemManager;constructor(t){this.config=t,this.logger=t.logger||{...console,attention:console.warn},this.api=new de(t.endpoint)}async connect(){return this.deviceManager&&this.pluginsManager&&this.systemManager||(this.cleanUpClient(),await this.login(),this.token=this.token||this.config.token,this.socketService=new vi(this.config.endpoint,this.token),this.deviceManager=new Ks(this.socketService,this.logger),this.pluginsManager=new Ys(this.socketService,this.logger),this.systemManager=new Xs(this.socketService,this.logger),this.checkSession()),{deviceManager:this.deviceManager,pluginsManager:this.pluginsManager,systemManager:this.systemManager}}async disconnect(){this.socketService?.close(),this.cleanUpClient(),this.config.username&&this.config.password&&await this.api.interceptor.post("/auth/logout",void 0,{headers:{Authorization:`Bearer ${this.token}`}})}async updateCredentials(t){this.config={...this.config,...t},this.socketService&&await this.disconnect(),await this.connect()}async login(){if(this.config.username&&this.config.password)try{const t=await this.api.interceptor.post("/auth/login",{username:this.config.username,password:this.config.password});this.token=t.data.access_token}catch(t){throw 401===t.response?.status?new Error("Invalid credentials"):new Error(`Failed to get token: ${t.message}`)}else if(this.config.token&&!this.config.skipCheck)try{await this.api.interceptor.get("/auth/check",{headers:{Authorization:`Bearer ${this.config.token}`}})}catch(t){throw new Error(`Invalid token: ${t.message}`)}this.token=this.token||this.config.token}getDeviceManager(){return this.deviceManager}getPluginsManager(){return this.pluginsManager}getSystemManager(){return this.systemManager}checkSession(){this.socketService?.socket.removeListener("invalidToken"),this.socketService?.socket.on("invalidToken",(async t=>{t===this.token&&await this.disconnect()}))}cleanUpClient(){this.deviceManager=void 0,this.pluginsManager=void 0,this.systemManager=void 0}}var Si=e.j;export{Si as CameraUiClient};
|