planx 19.85.0 → 19.86.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +1,23 @@
1
1
  import { createRequire } from 'module';
2
2
  const require = createRequire(import.meta.url);
3
3
 
4
- var AR=Object.create;var ym=Object.defineProperty;var NR=Object.getOwnPropertyDescriptor;var PR=Object.getOwnPropertyNames;var RR=Object.getPrototypeOf,kR=Object.prototype.hasOwnProperty;var LR=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(n,e)=>(typeof require<"u"?require:n)[e]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var v=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports),jR=(t,n)=>{for(var e in n)ym(t,e,{get:n[e],enumerable:!0})},FR=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of PR(n))!kR.call(t,i)&&i!==e&&ym(t,i,{get:()=>n[i],enumerable:!(r=NR(n,i))||r.enumerable});return t};var U=(t,n,e)=>(e=t!=null?AR(RR(t)):{},FR(n||!t||!t.__esModule?ym(e,"default",{value:t,enumerable:!0}):e,t));var ke=v(Gc=>{"use strict";Object.defineProperty(Gc,"__esModule",{value:!0});Gc.isFunction=void 0;function $R(t){return typeof t=="function"}Gc.isFunction=$R});var lr=v(zc=>{"use strict";Object.defineProperty(zc,"__esModule",{value:!0});zc.createErrorClass=void 0;function qR(t){var n=function(r){Error.call(r),r.stack=new Error().stack},e=t(n);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}zc.createErrorClass=qR});var vm=v(Kc=>{"use strict";Object.defineProperty(Kc,"__esModule",{value:!0});Kc.UnsubscriptionError=void 0;var BR=lr();Kc.UnsubscriptionError=BR.createErrorClass(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
4
+ var NR=Object.create;var ym=Object.defineProperty;var PR=Object.getOwnPropertyDescriptor;var RR=Object.getOwnPropertyNames;var kR=Object.getPrototypeOf,LR=Object.prototype.hasOwnProperty;var jR=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(n,e)=>(typeof require<"u"?require:n)[e]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var v=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports),FR=(t,n)=>{for(var e in n)ym(t,e,{get:n[e],enumerable:!0})},$R=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of RR(n))!LR.call(t,i)&&i!==e&&ym(t,i,{get:()=>n[i],enumerable:!(r=PR(n,i))||r.enumerable});return t};var U=(t,n,e)=>(e=t!=null?NR(kR(t)):{},$R(n||!t||!t.__esModule?ym(e,"default",{value:t,enumerable:!0}):e,t));var ke=v(Gc=>{"use strict";Object.defineProperty(Gc,"__esModule",{value:!0});Gc.isFunction=void 0;function qR(t){return typeof t=="function"}Gc.isFunction=qR});var lr=v(zc=>{"use strict";Object.defineProperty(zc,"__esModule",{value:!0});zc.createErrorClass=void 0;function BR(t){var n=function(r){Error.call(r),r.stack=new Error().stack},e=t(n);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}zc.createErrorClass=BR});var vm=v(Kc=>{"use strict";Object.defineProperty(Kc,"__esModule",{value:!0});Kc.UnsubscriptionError=void 0;var HR=lr();Kc.UnsubscriptionError=HR.createErrorClass(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
5
5
  `+e.map(function(r,i){return i+1+") "+r.toString()}).join(`
6
- `):"",this.name="UnsubscriptionError",this.errors=e}})});var Rn=v(Yc=>{"use strict";Object.defineProperty(Yc,"__esModule",{value:!0});Yc.arrRemove=void 0;function HR(t,n){if(t){var e=t.indexOf(n);0<=e&&t.splice(e,1)}}Yc.arrRemove=HR});var Lt=v(Ct=>{"use strict";var rS=Ct&&Ct.__values||function(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")},iS=Ct&&Ct.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},oS=Ct&&Ct.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Ct,"__esModule",{value:!0});Ct.isSubscription=Ct.EMPTY_SUBSCRIPTION=Ct.Subscription=void 0;var ia=ke(),_m=vm(),sS=Rn(),bm=(function(){function t(n){this.initialTeardown=n,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var n,e,r,i,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var a=rS(s),c=a.next();!c.done;c=a.next()){var u=c.value;u.remove(this)}}catch(y){n={error:y}}finally{try{c&&!c.done&&(e=a.return)&&e.call(a)}finally{if(n)throw n.error}}else s.remove(this);var l=this.initialTeardown;if(ia.isFunction(l))try{l()}catch(y){o=y instanceof _m.UnsubscriptionError?y.errors:[y]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var f=rS(d),p=f.next();!p.done;p=f.next()){var m=p.value;try{aS(m)}catch(y){o=o??[],y instanceof _m.UnsubscriptionError?o=oS(oS([],iS(o)),iS(y.errors)):o.push(y)}}}catch(y){r={error:y}}finally{try{p&&!p.done&&(i=f.return)&&i.call(f)}finally{if(r)throw r.error}}}if(o)throw new _m.UnsubscriptionError(o)}},t.prototype.add=function(n){var e;if(n&&n!==this)if(this.closed)aS(n);else{if(n instanceof t){if(n.closed||n._hasParent(this))return;n._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(n)}},t.prototype._hasParent=function(n){var e=this._parentage;return e===n||Array.isArray(e)&&e.includes(n)},t.prototype._addParent=function(n){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(n),e):e?[e,n]:n},t.prototype._removeParent=function(n){var e=this._parentage;e===n?this._parentage=null:Array.isArray(e)&&sS.arrRemove(e,n)},t.prototype.remove=function(n){var e=this._finalizers;e&&sS.arrRemove(e,n),n instanceof t&&n._removeParent(this)},t.EMPTY=(function(){var n=new t;return n.closed=!0,n})(),t})();Ct.Subscription=bm;Ct.EMPTY_SUBSCRIPTION=bm.EMPTY;function UR(t){return t instanceof bm||t&&"closed"in t&&ia.isFunction(t.remove)&&ia.isFunction(t.add)&&ia.isFunction(t.unsubscribe)}Ct.isSubscription=UR;function aS(t){ia.isFunction(t)?t():t.unsubscribe()}});var ro=v(Zc=>{"use strict";Object.defineProperty(Zc,"__esModule",{value:!0});Zc.config=void 0;Zc.config={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1}});var wm=v(pn=>{"use strict";var cS=pn&&pn.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},uS=pn&&pn.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(pn,"__esModule",{value:!0});pn.timeoutProvider=void 0;pn.timeoutProvider={setTimeout:function(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var i=pn.timeoutProvider.delegate;return i?.setTimeout?i.setTimeout.apply(i,uS([t,n],cS(e))):setTimeout.apply(void 0,uS([t,n],cS(e)))},clearTimeout:function(t){var n=pn.timeoutProvider.delegate;return(n?.clearTimeout||clearTimeout)(t)},delegate:void 0}});var Em=v(Qc=>{"use strict";Object.defineProperty(Qc,"__esModule",{value:!0});Qc.reportUnhandledError=void 0;var VR=ro(),WR=wm();function GR(t){WR.timeoutProvider.setTimeout(function(){var n=VR.config.onUnhandledError;if(n)n(t);else throw t})}Qc.reportUnhandledError=GR});var ct=v(Jc=>{"use strict";Object.defineProperty(Jc,"__esModule",{value:!0});Jc.noop=void 0;function zR(){}Jc.noop=zR});var lS=v(mn=>{"use strict";Object.defineProperty(mn,"__esModule",{value:!0});mn.createNotification=mn.nextNotification=mn.errorNotification=mn.COMPLETE_NOTIFICATION=void 0;mn.COMPLETE_NOTIFICATION=(function(){return Xc("C",void 0,void 0)})();function KR(t){return Xc("E",void 0,t)}mn.errorNotification=KR;function YR(t){return Xc("N",t,void 0)}mn.nextNotification=YR;function Xc(t,n,e){return{kind:t,value:n,error:e}}mn.createNotification=Xc});var eu=v(io=>{"use strict";Object.defineProperty(io,"__esModule",{value:!0});io.captureError=io.errorContext=void 0;var dS=ro(),oi=null;function ZR(t){if(dS.config.useDeprecatedSynchronousErrorHandling){var n=!oi;if(n&&(oi={errorThrown:!1,error:null}),t(),n){var e=oi,r=e.errorThrown,i=e.error;if(oi=null,r)throw i}}else t()}io.errorContext=ZR;function QR(t){dS.config.useDeprecatedSynchronousErrorHandling&&oi&&(oi.errorThrown=!0,oi.error=t)}io.captureError=QR});var oo=v(nn=>{"use strict";var pS=nn&&nn.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(nn,"__esModule",{value:!0});nn.EMPTY_OBSERVER=nn.SafeSubscriber=nn.Subscriber=void 0;var JR=ke(),fS=Lt(),Tm=ro(),XR=Em(),hS=ct(),Sm=lS(),ek=wm(),tk=eu(),mS=(function(t){pS(n,t);function n(e){var r=t.call(this)||this;return r.isStopped=!1,e?(r.destination=e,fS.isSubscription(e)&&e.add(r)):r.destination=nn.EMPTY_OBSERVER,r}return n.create=function(e,r,i){return new gS(e,r,i)},n.prototype.next=function(e){this.isStopped?Im(Sm.nextNotification(e),this):this._next(e)},n.prototype.error=function(e){this.isStopped?Im(Sm.errorNotification(e),this):(this.isStopped=!0,this._error(e))},n.prototype.complete=function(){this.isStopped?Im(Sm.COMPLETE_NOTIFICATION,this):(this.isStopped=!0,this._complete())},n.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},n.prototype._next=function(e){this.destination.next(e)},n.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},n.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},n})(fS.Subscription);nn.Subscriber=mS;var nk=Function.prototype.bind;function Cm(t,n){return nk.call(t,n)}var rk=(function(){function t(n){this.partialObserver=n}return t.prototype.next=function(n){var e=this.partialObserver;if(e.next)try{e.next(n)}catch(r){tu(r)}},t.prototype.error=function(n){var e=this.partialObserver;if(e.error)try{e.error(n)}catch(r){tu(r)}else tu(n)},t.prototype.complete=function(){var n=this.partialObserver;if(n.complete)try{n.complete()}catch(e){tu(e)}},t})(),gS=(function(t){pS(n,t);function n(e,r,i){var o=t.call(this)||this,s;if(JR.isFunction(e)||!e)s={next:e??void 0,error:r??void 0,complete:i??void 0};else{var a;o&&Tm.config.useDeprecatedNextContext?(a=Object.create(e),a.unsubscribe=function(){return o.unsubscribe()},s={next:e.next&&Cm(e.next,a),error:e.error&&Cm(e.error,a),complete:e.complete&&Cm(e.complete,a)}):s=e}return o.destination=new rk(s),o}return n})(mS);nn.SafeSubscriber=gS;function tu(t){Tm.config.useDeprecatedSynchronousErrorHandling?tk.captureError(t):XR.reportUnhandledError(t)}function ik(t){throw t}function Im(t,n){var e=Tm.config.onStoppedNotification;e&&ek.timeoutProvider.setTimeout(function(){return e(t,n)})}nn.EMPTY_OBSERVER={closed:!0,next:hS.noop,error:ik,complete:hS.noop}});var oa=v(nu=>{"use strict";Object.defineProperty(nu,"__esModule",{value:!0});nu.observable=void 0;nu.observable=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})()});var ut=v(ru=>{"use strict";Object.defineProperty(ru,"__esModule",{value:!0});ru.identity=void 0;function ok(t){return t}ru.identity=ok});var sa=v(so=>{"use strict";Object.defineProperty(so,"__esModule",{value:!0});so.pipeFromArray=so.pipe=void 0;var sk=ut();function ak(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return yS(t)}so.pipe=ak;function yS(t){return t.length===0?sk.identity:t.length===1?t[0]:function(e){return t.reduce(function(r,i){return i(r)},e)}}so.pipeFromArray=yS});var je=v(iu=>{"use strict";Object.defineProperty(iu,"__esModule",{value:!0});iu.Observable=void 0;var Dm=oo(),ck=Lt(),uk=oa(),lk=sa(),dk=ro(),xm=ke(),fk=eu(),hk=(function(){function t(n){n&&(this._subscribe=n)}return t.prototype.lift=function(n){var e=new t;return e.source=this,e.operator=n,e},t.prototype.subscribe=function(n,e,r){var i=this,o=mk(n)?n:new Dm.SafeSubscriber(n,e,r);return fk.errorContext(function(){var s=i,a=s.operator,c=s.source;o.add(a?a.call(o,c):c?i._subscribe(o):i._trySubscribe(o))}),o},t.prototype._trySubscribe=function(n){try{return this._subscribe(n)}catch(e){n.error(e)}},t.prototype.forEach=function(n,e){var r=this;return e=vS(e),new e(function(i,o){var s=new Dm.SafeSubscriber({next:function(a){try{n(a)}catch(c){o(c),s.unsubscribe()}},error:o,complete:i});r.subscribe(s)})},t.prototype._subscribe=function(n){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(n)},t.prototype[uk.observable]=function(){return this},t.prototype.pipe=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return lk.pipeFromArray(n)(this)},t.prototype.toPromise=function(n){var e=this;return n=vS(n),new n(function(r,i){var o;e.subscribe(function(s){return o=s},function(s){return i(s)},function(){return r(o)})})},t.create=function(n){return new t(n)},t})();iu.Observable=hk;function vS(t){var n;return(n=t??dk.config.Promise)!==null&&n!==void 0?n:Promise}function pk(t){return t&&xm.isFunction(t.next)&&xm.isFunction(t.error)&&xm.isFunction(t.complete)}function mk(t){return t&&t instanceof Dm.Subscriber||pk(t)&&ck.isSubscription(t)}});var L=v(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.operate=ao.hasLift=void 0;var gk=ke();function _S(t){return gk.isFunction(t?.lift)}ao.hasLift=_S;function yk(t){return function(n){if(_S(n))return n.lift(function(e){try{return t(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}ao.operate=yk});var V=v(dr=>{"use strict";var vk=dr&&dr.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(dr,"__esModule",{value:!0});dr.OperatorSubscriber=dr.createOperatorSubscriber=void 0;var _k=oo();function bk(t,n,e,r,i){return new bS(t,n,e,r,i)}dr.createOperatorSubscriber=bk;var bS=(function(t){vk(n,t);function n(e,r,i,o,s,a){var c=t.call(this,e)||this;return c.onFinalize=s,c.shouldUnsubscribe=a,c._next=r?function(u){try{r(u)}catch(l){e.error(l)}}:t.prototype._next,c._error=o?function(u){try{o(u)}catch(l){e.error(l)}finally{this.unsubscribe()}}:t.prototype._error,c._complete=i?function(){try{i()}catch(u){e.error(u)}finally{this.unsubscribe()}}:t.prototype._complete,c}return n.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},n})(_k.Subscriber);dr.OperatorSubscriber=bS});var su=v(ou=>{"use strict";Object.defineProperty(ou,"__esModule",{value:!0});ou.refCount=void 0;var wk=L(),Ek=V();function Sk(){return wk.operate(function(t,n){var e=null;t._refCount++;var r=Ek.createOperatorSubscriber(n,void 0,void 0,void 0,function(){if(!t||t._refCount<=0||0<--t._refCount){e=null;return}var i=t._connection,o=e;e=null,i&&(!o||i===o)&&i.unsubscribe(),n.unsubscribe()});t.subscribe(r),r.closed||(e=t.connect())})}ou.refCount=Sk});var aa=v(co=>{"use strict";var Ck=co&&co.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(co,"__esModule",{value:!0});co.ConnectableObservable=void 0;var Ik=je(),wS=Lt(),Tk=su(),xk=V(),Dk=L(),Ok=(function(t){Ck(n,t);function n(e,r){var i=t.call(this)||this;return i.source=e,i.subjectFactory=r,i._subject=null,i._refCount=0,i._connection=null,Dk.hasLift(e)&&(i.lift=e.lift),i}return n.prototype._subscribe=function(e){return this.getSubject().subscribe(e)},n.prototype.getSubject=function(){var e=this._subject;return(!e||e.isStopped)&&(this._subject=this.subjectFactory()),this._subject},n.prototype._teardown=function(){this._refCount=0;var e=this._connection;this._subject=this._connection=null,e?.unsubscribe()},n.prototype.connect=function(){var e=this,r=this._connection;if(!r){r=this._connection=new wS.Subscription;var i=this.getSubject();r.add(this.source.subscribe(xk.createOperatorSubscriber(i,void 0,function(){e._teardown(),i.complete()},function(o){e._teardown(),i.error(o)},function(){return e._teardown()}))),r.closed&&(this._connection=null,r=wS.Subscription.EMPTY)}return r},n.prototype.refCount=function(){return Tk.refCount()(this)},n})(Ik.Observable);co.ConnectableObservable=Ok});var ES=v(ca=>{"use strict";Object.defineProperty(ca,"__esModule",{value:!0});ca.performanceTimestampProvider=void 0;ca.performanceTimestampProvider={now:function(){return(ca.performanceTimestampProvider.delegate||performance).now()},delegate:void 0}});var Om=v(rn=>{"use strict";var SS=rn&&rn.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},CS=rn&&rn.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(rn,"__esModule",{value:!0});rn.animationFrameProvider=void 0;var Mk=Lt();rn.animationFrameProvider={schedule:function(t){var n=requestAnimationFrame,e=cancelAnimationFrame,r=rn.animationFrameProvider.delegate;r&&(n=r.requestAnimationFrame,e=r.cancelAnimationFrame);var i=n(function(o){e=void 0,t(o)});return new Mk.Subscription(function(){return e?.(i)})},requestAnimationFrame:function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=rn.animationFrameProvider.delegate;return(e?.requestAnimationFrame||requestAnimationFrame).apply(void 0,CS([],SS(t)))},cancelAnimationFrame:function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=rn.animationFrameProvider.delegate;return(e?.cancelAnimationFrame||cancelAnimationFrame).apply(void 0,CS([],SS(t)))},delegate:void 0}});var xS=v(au=>{"use strict";Object.defineProperty(au,"__esModule",{value:!0});au.animationFrames=void 0;var Ak=je(),Nk=ES(),IS=Om();function Pk(t){return t?TS(t):Rk}au.animationFrames=Pk;function TS(t){return new Ak.Observable(function(n){var e=t||Nk.performanceTimestampProvider,r=e.now(),i=0,o=function(){n.closed||(i=IS.animationFrameProvider.requestAnimationFrame(function(s){i=0;var a=e.now();n.next({timestamp:t?a:s,elapsed:a-r}),o()}))};return o(),function(){i&&IS.animationFrameProvider.cancelAnimationFrame(i)}})}var Rk=TS()});var Mm=v(cu=>{"use strict";Object.defineProperty(cu,"__esModule",{value:!0});cu.ObjectUnsubscribedError=void 0;var kk=lr();cu.ObjectUnsubscribedError=kk.createErrorClass(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})});var lt=v(gn=>{"use strict";var OS=gn&&gn.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})(),Lk=gn&&gn.__values||function(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(gn,"__esModule",{value:!0});gn.AnonymousSubject=gn.Subject=void 0;var DS=je(),Nm=Lt(),jk=Mm(),Fk=Rn(),Am=eu(),MS=(function(t){OS(n,t);function n(){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 n.prototype.lift=function(e){var r=new Pm(this,this);return r.operator=e,r},n.prototype._throwIfClosed=function(){if(this.closed)throw new jk.ObjectUnsubscribedError},n.prototype.next=function(e){var r=this;Am.errorContext(function(){var i,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=Lk(r.currentObservers),a=s.next();!a.done;a=s.next()){var c=a.value;c.next(e)}}catch(u){i={error:u}}finally{try{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}})},n.prototype.error=function(e){var r=this;Am.errorContext(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=e;for(var i=r.observers;i.length;)i.shift().error(e)}})},n.prototype.complete=function(){var e=this;Am.errorContext(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var r=e.observers;r.length;)r.shift().complete()}})},n.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(n.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),n.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},n.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},n.prototype._innerSubscribe=function(e){var r=this,i=this,o=i.hasError,s=i.isStopped,a=i.observers;return o||s?Nm.EMPTY_SUBSCRIPTION:(this.currentObservers=null,a.push(e),new Nm.Subscription(function(){r.currentObservers=null,Fk.arrRemove(a,e)}))},n.prototype._checkFinalizedStatuses=function(e){var r=this,i=r.hasError,o=r.thrownError,s=r.isStopped;i?e.error(o):s&&e.complete()},n.prototype.asObservable=function(){var e=new DS.Observable;return e.source=this,e},n.create=function(e,r){return new Pm(e,r)},n})(DS.Observable);gn.Subject=MS;var Pm=(function(t){OS(n,t);function n(e,r){var i=t.call(this)||this;return i.destination=e,i.source=r,i}return n.prototype.next=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,e)},n.prototype.error=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.call(r,e)},n.prototype.complete=function(){var e,r;(r=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||r===void 0||r.call(e)},n.prototype._subscribe=function(e){var r,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(e))!==null&&i!==void 0?i:Nm.EMPTY_SUBSCRIPTION},n})(MS);gn.AnonymousSubject=Pm});var Rm=v(uo=>{"use strict";var $k=uo&&uo.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(uo,"__esModule",{value:!0});uo.BehaviorSubject=void 0;var qk=lt(),Bk=(function(t){$k(n,t);function n(e){var r=t.call(this)||this;return r._value=e,r}return Object.defineProperty(n.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),n.prototype._subscribe=function(e){var r=t.prototype._subscribe.call(this,e);return!r.closed&&e.next(this._value),r},n.prototype.getValue=function(){var e=this,r=e.hasError,i=e.thrownError,o=e._value;if(r)throw i;return this._throwIfClosed(),o},n.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},n})(qk.Subject);uo.BehaviorSubject=Bk});var uu=v(ua=>{"use strict";Object.defineProperty(ua,"__esModule",{value:!0});ua.dateTimestampProvider=void 0;ua.dateTimestampProvider={now:function(){return(ua.dateTimestampProvider.delegate||Date).now()},delegate:void 0}});var lu=v(lo=>{"use strict";var Hk=lo&&lo.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(lo,"__esModule",{value:!0});lo.ReplaySubject=void 0;var Uk=lt(),Vk=uu(),Wk=(function(t){Hk(n,t);function n(e,r,i){e===void 0&&(e=1/0),r===void 0&&(r=1/0),i===void 0&&(i=Vk.dateTimestampProvider);var o=t.call(this)||this;return o._bufferSize=e,o._windowTime=r,o._timestampProvider=i,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,e),o._windowTime=Math.max(1,r),o}return n.prototype.next=function(e){var r=this,i=r.isStopped,o=r._buffer,s=r._infiniteTimeWindow,a=r._timestampProvider,c=r._windowTime;i||(o.push(e),!s&&o.push(a.now()+c)),this._trimBuffer(),t.prototype.next.call(this,e)},n.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(e),i=this,o=i._infiniteTimeWindow,s=i._buffer,a=s.slice(),c=0;c<a.length&&!e.closed;c+=o?1:2)e.next(a[c]);return this._checkFinalizedStatuses(e),r},n.prototype._trimBuffer=function(){var e=this,r=e._bufferSize,i=e._timestampProvider,o=e._buffer,s=e._infiniteTimeWindow,a=(s?1:2)*r;if(r<1/0&&a<o.length&&o.splice(0,o.length-a),!s){for(var c=i.now(),u=0,l=1;l<o.length&&o[l]<=c;l+=2)u=l;u&&o.splice(0,u+1)}},n})(Uk.Subject);lo.ReplaySubject=Wk});var du=v(fo=>{"use strict";var Gk=fo&&fo.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(fo,"__esModule",{value:!0});fo.AsyncSubject=void 0;var zk=lt(),Kk=(function(t){Gk(n,t);function n(){var e=t!==null&&t.apply(this,arguments)||this;return e._value=null,e._hasValue=!1,e._isComplete=!1,e}return n.prototype._checkFinalizedStatuses=function(e){var r=this,i=r.hasError,o=r._hasValue,s=r._value,a=r.thrownError,c=r.isStopped,u=r._isComplete;i?e.error(a):(c||u)&&(o&&e.next(s),e.complete())},n.prototype.next=function(e){this.isStopped||(this._value=e,this._hasValue=!0)},n.prototype.complete=function(){var e=this,r=e._hasValue,i=e._value,o=e._isComplete;o||(this._isComplete=!0,r&&t.prototype.next.call(this,i),t.prototype.complete.call(this))},n})(zk.Subject);fo.AsyncSubject=Kk});var AS=v(ho=>{"use strict";var Yk=ho&&ho.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(ho,"__esModule",{value:!0});ho.Action=void 0;var Zk=Lt(),Qk=(function(t){Yk(n,t);function n(e,r){return t.call(this)||this}return n.prototype.schedule=function(e,r){return r===void 0&&(r=0),this},n})(Zk.Subscription);ho.Action=Qk});var RS=v(yn=>{"use strict";var NS=yn&&yn.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},PS=yn&&yn.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(yn,"__esModule",{value:!0});yn.intervalProvider=void 0;yn.intervalProvider={setInterval:function(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var i=yn.intervalProvider.delegate;return i?.setInterval?i.setInterval.apply(i,PS([t,n],NS(e))):setInterval.apply(void 0,PS([t,n],NS(e)))},clearInterval:function(t){var n=yn.intervalProvider.delegate;return(n?.clearInterval||clearInterval)(t)},delegate:void 0}});var mo=v(po=>{"use strict";var Jk=po&&po.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(po,"__esModule",{value:!0});po.AsyncAction=void 0;var Xk=AS(),kS=RS(),e1=Rn(),t1=(function(t){Jk(n,t);function n(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i.pending=!1,i}return n.prototype.schedule=function(e,r){var i;if(r===void 0&&(r=0),this.closed)return this;this.state=e;var o=this.id,s=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(s,o,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(s,this.id,r),this},n.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),kS.intervalProvider.setInterval(e.flush.bind(e,this),i)},n.prototype.recycleAsyncId=function(e,r,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return r;r!=null&&kS.intervalProvider.clearInterval(r)},n.prototype.execute=function(e,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(e,r);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},n.prototype._execute=function(e,r){var i=!1,o;try{this.work(e)}catch(s){i=!0,o=s||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),o},n.prototype.unsubscribe=function(){if(!this.closed){var e=this,r=e.id,i=e.scheduler,o=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,e1.arrRemove(o,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},n})(Xk.Action);po.AsyncAction=t1});var jS=v(go=>{"use strict";Object.defineProperty(go,"__esModule",{value:!0});go.TestTools=go.Immediate=void 0;var n1=1,km,fu={};function LS(t){return t in fu?(delete fu[t],!0):!1}go.Immediate={setImmediate:function(t){var n=n1++;return fu[n]=!0,km||(km=Promise.resolve()),km.then(function(){return LS(n)&&t()}),n},clearImmediate:function(t){LS(t)}};go.TestTools={pending:function(){return Object.keys(fu).length}}});var $S=v(vn=>{"use strict";var r1=vn&&vn.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},i1=vn&&vn.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(vn,"__esModule",{value:!0});vn.immediateProvider=void 0;var FS=jS(),o1=FS.Immediate.setImmediate,s1=FS.Immediate.clearImmediate;vn.immediateProvider={setImmediate:function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=vn.immediateProvider.delegate;return(e?.setImmediate||o1).apply(void 0,i1([],r1(t)))},clearImmediate:function(t){var n=vn.immediateProvider.delegate;return(n?.clearImmediate||s1)(t)},delegate:void 0}});var BS=v(yo=>{"use strict";var a1=yo&&yo.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(yo,"__esModule",{value:!0});yo.AsapAction=void 0;var c1=mo(),qS=$S(),u1=(function(t){a1(n,t);function n(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i}return n.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),i!==null&&i>0?t.prototype.requestAsyncId.call(this,e,r,i):(e.actions.push(this),e._scheduled||(e._scheduled=qS.immediateProvider.setImmediate(e.flush.bind(e,void 0))))},n.prototype.recycleAsyncId=function(e,r,i){var o;if(i===void 0&&(i=0),i!=null?i>0:this.delay>0)return t.prototype.recycleAsyncId.call(this,e,r,i);var s=e.actions;r!=null&&((o=s[s.length-1])===null||o===void 0?void 0:o.id)!==r&&(qS.immediateProvider.clearImmediate(r),e._scheduled===r&&(e._scheduled=void 0))},n})(c1.AsyncAction);yo.AsapAction=u1});var Lm=v(hu=>{"use strict";Object.defineProperty(hu,"__esModule",{value:!0});hu.Scheduler=void 0;var l1=uu(),d1=(function(){function t(n,e){e===void 0&&(e=t.now),this.schedulerActionCtor=n,this.now=e}return t.prototype.schedule=function(n,e,r){return e===void 0&&(e=0),new this.schedulerActionCtor(this,n).schedule(r,e)},t.now=l1.dateTimestampProvider.now,t})();hu.Scheduler=d1});var _o=v(vo=>{"use strict";var f1=vo&&vo.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(vo,"__esModule",{value:!0});vo.AsyncScheduler=void 0;var HS=Lm(),h1=(function(t){f1(n,t);function n(e,r){r===void 0&&(r=HS.Scheduler.now);var i=t.call(this,e,r)||this;return i.actions=[],i._active=!1,i}return n.prototype.flush=function(e){var r=this.actions;if(this._active){r.push(e);return}var i;this._active=!0;do if(i=e.execute(e.state,e.delay))break;while(e=r.shift());if(this._active=!1,i){for(;e=r.shift();)e.unsubscribe();throw i}},n})(HS.Scheduler);vo.AsyncScheduler=h1});var US=v(bo=>{"use strict";var p1=bo&&bo.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(bo,"__esModule",{value:!0});bo.AsapScheduler=void 0;var m1=_o(),g1=(function(t){p1(n,t);function n(){return t!==null&&t.apply(this,arguments)||this}return n.prototype.flush=function(e){this._active=!0;var r=this._scheduled;this._scheduled=void 0;var i=this.actions,o;e=e||i.shift();do if(o=e.execute(e.state,e.delay))break;while((e=i[0])&&e.id===r&&i.shift());if(this._active=!1,o){for(;(e=i[0])&&e.id===r&&i.shift();)e.unsubscribe();throw o}},n})(m1.AsyncScheduler);bo.AsapScheduler=g1});var VS=v(si=>{"use strict";Object.defineProperty(si,"__esModule",{value:!0});si.asap=si.asapScheduler=void 0;var y1=BS(),v1=US();si.asapScheduler=new v1.AsapScheduler(y1.AsapAction);si.asap=si.asapScheduler});var It=v(ai=>{"use strict";Object.defineProperty(ai,"__esModule",{value:!0});ai.async=ai.asyncScheduler=void 0;var _1=mo(),b1=_o();ai.asyncScheduler=new b1.AsyncScheduler(_1.AsyncAction);ai.async=ai.asyncScheduler});var WS=v(wo=>{"use strict";var w1=wo&&wo.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(wo,"__esModule",{value:!0});wo.QueueAction=void 0;var E1=mo(),S1=(function(t){w1(n,t);function n(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i}return n.prototype.schedule=function(e,r){return r===void 0&&(r=0),r>0?t.prototype.schedule.call(this,e,r):(this.delay=r,this.state=e,this.scheduler.flush(this),this)},n.prototype.execute=function(e,r){return r>0||this.closed?t.prototype.execute.call(this,e,r):this._execute(e,r)},n.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),i!=null&&i>0||i==null&&this.delay>0?t.prototype.requestAsyncId.call(this,e,r,i):(e.flush(this),0)},n})(E1.AsyncAction);wo.QueueAction=S1});var GS=v(Eo=>{"use strict";var C1=Eo&&Eo.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(Eo,"__esModule",{value:!0});Eo.QueueScheduler=void 0;var I1=_o(),T1=(function(t){C1(n,t);function n(){return t!==null&&t.apply(this,arguments)||this}return n})(I1.AsyncScheduler);Eo.QueueScheduler=T1});var zS=v(ci=>{"use strict";Object.defineProperty(ci,"__esModule",{value:!0});ci.queue=ci.queueScheduler=void 0;var x1=WS(),D1=GS();ci.queueScheduler=new D1.QueueScheduler(x1.QueueAction);ci.queue=ci.queueScheduler});var YS=v(So=>{"use strict";var O1=So&&So.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(So,"__esModule",{value:!0});So.AnimationFrameAction=void 0;var M1=mo(),KS=Om(),A1=(function(t){O1(n,t);function n(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i}return n.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),i!==null&&i>0?t.prototype.requestAsyncId.call(this,e,r,i):(e.actions.push(this),e._scheduled||(e._scheduled=KS.animationFrameProvider.requestAnimationFrame(function(){return e.flush(void 0)})))},n.prototype.recycleAsyncId=function(e,r,i){var o;if(i===void 0&&(i=0),i!=null?i>0:this.delay>0)return t.prototype.recycleAsyncId.call(this,e,r,i);var s=e.actions;r!=null&&r===e._scheduled&&((o=s[s.length-1])===null||o===void 0?void 0:o.id)!==r&&(KS.animationFrameProvider.cancelAnimationFrame(r),e._scheduled=void 0)},n})(M1.AsyncAction);So.AnimationFrameAction=A1});var ZS=v(Co=>{"use strict";var N1=Co&&Co.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(Co,"__esModule",{value:!0});Co.AnimationFrameScheduler=void 0;var P1=_o(),R1=(function(t){N1(n,t);function n(){return t!==null&&t.apply(this,arguments)||this}return n.prototype.flush=function(e){this._active=!0;var r;e?r=e.id:(r=this._scheduled,this._scheduled=void 0);var i=this.actions,o;e=e||i.shift();do if(o=e.execute(e.state,e.delay))break;while((e=i[0])&&e.id===r&&i.shift());if(this._active=!1,o){for(;(e=i[0])&&e.id===r&&i.shift();)e.unsubscribe();throw o}},n})(P1.AsyncScheduler);Co.AnimationFrameScheduler=R1});var QS=v(ui=>{"use strict";Object.defineProperty(ui,"__esModule",{value:!0});ui.animationFrame=ui.animationFrameScheduler=void 0;var k1=YS(),L1=ZS();ui.animationFrameScheduler=new L1.AnimationFrameScheduler(k1.AnimationFrameAction);ui.animationFrame=ui.animationFrameScheduler});var eC=v(fr=>{"use strict";var JS=fr&&fr.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(fr,"__esModule",{value:!0});fr.VirtualAction=fr.VirtualTimeScheduler=void 0;var j1=mo(),F1=Lt(),$1=_o(),q1=(function(t){JS(n,t);function n(e,r){e===void 0&&(e=XS),r===void 0&&(r=1/0);var i=t.call(this,e,function(){return i.frame})||this;return i.maxFrames=r,i.frame=0,i.index=-1,i}return n.prototype.flush=function(){for(var e=this,r=e.actions,i=e.maxFrames,o,s;(s=r[0])&&s.delay<=i&&(r.shift(),this.frame=s.delay,!(o=s.execute(s.state,s.delay))););if(o){for(;s=r.shift();)s.unsubscribe();throw o}},n.frameTimeFactor=10,n})($1.AsyncScheduler);fr.VirtualTimeScheduler=q1;var XS=(function(t){JS(n,t);function n(e,r,i){i===void 0&&(i=e.index+=1);var o=t.call(this,e,r)||this;return o.scheduler=e,o.work=r,o.index=i,o.active=!0,o.index=e.index=i,o}return n.prototype.schedule=function(e,r){if(r===void 0&&(r=0),Number.isFinite(r)){if(!this.id)return t.prototype.schedule.call(this,e,r);this.active=!1;var i=new n(this.scheduler,this.work);return this.add(i),i.schedule(e,r)}else return F1.Subscription.EMPTY},n.prototype.requestAsyncId=function(e,r,i){i===void 0&&(i=0),this.delay=e.frame+i;var o=e.actions;return o.push(this),o.sort(n.sortActions),1},n.prototype.recycleAsyncId=function(e,r,i){i===void 0&&(i=0)},n.prototype._execute=function(e,r){if(this.active===!0)return t.prototype._execute.call(this,e,r)},n.sortActions=function(e,r){return e.delay===r.delay?e.index===r.index?0:e.index>r.index?1:-1:e.delay>r.delay?1:-1},n})(j1.AsyncAction);fr.VirtualAction=XS});var on=v(li=>{"use strict";Object.defineProperty(li,"__esModule",{value:!0});li.empty=li.EMPTY=void 0;var tC=je();li.EMPTY=new tC.Observable(function(t){return t.complete()});function B1(t){return t?H1(t):li.EMPTY}li.empty=B1;function H1(t){return new tC.Observable(function(n){return t.schedule(function(){return n.complete()})})}});var la=v(pu=>{"use strict";Object.defineProperty(pu,"__esModule",{value:!0});pu.isScheduler=void 0;var U1=ke();function V1(t){return t&&U1.isFunction(t.schedule)}pu.isScheduler=V1});var Tt=v(hr=>{"use strict";Object.defineProperty(hr,"__esModule",{value:!0});hr.popNumber=hr.popScheduler=hr.popResultSelector=void 0;var W1=ke(),G1=la();function jm(t){return t[t.length-1]}function z1(t){return W1.isFunction(jm(t))?t.pop():void 0}hr.popResultSelector=z1;function K1(t){return G1.isScheduler(jm(t))?t.pop():void 0}hr.popScheduler=K1;function Y1(t,n){return typeof jm(t)=="number"?t.pop():n}hr.popNumber=Y1});var gu=v(mu=>{"use strict";Object.defineProperty(mu,"__esModule",{value:!0});mu.isArrayLike=void 0;mu.isArrayLike=function(t){return t&&typeof t.length=="number"&&typeof t!="function"}});var Fm=v(yu=>{"use strict";Object.defineProperty(yu,"__esModule",{value:!0});yu.isPromise=void 0;var Z1=ke();function Q1(t){return Z1.isFunction(t?.then)}yu.isPromise=Q1});var $m=v(vu=>{"use strict";Object.defineProperty(vu,"__esModule",{value:!0});vu.isInteropObservable=void 0;var J1=oa(),X1=ke();function eL(t){return X1.isFunction(t[J1.observable])}vu.isInteropObservable=eL});var qm=v(_u=>{"use strict";Object.defineProperty(_u,"__esModule",{value:!0});_u.isAsyncIterable=void 0;var tL=ke();function nL(t){return Symbol.asyncIterator&&tL.isFunction(t?.[Symbol.asyncIterator])}_u.isAsyncIterable=nL});var Bm=v(bu=>{"use strict";Object.defineProperty(bu,"__esModule",{value:!0});bu.createInvalidObservableTypeError=void 0;function rL(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}bu.createInvalidObservableTypeError=rL});var Hm=v(Io=>{"use strict";Object.defineProperty(Io,"__esModule",{value:!0});Io.iterator=Io.getSymbolIterator=void 0;function nC(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}Io.getSymbolIterator=nC;Io.iterator=nC()});var Um=v(wu=>{"use strict";Object.defineProperty(wu,"__esModule",{value:!0});wu.isIterable=void 0;var iL=Hm(),oL=ke();function sL(t){return oL.isFunction(t?.[iL.iterator])}wu.isIterable=sL});var Eu=v(Gt=>{"use strict";var aL=Gt&&Gt.__generator||function(t,n){var e={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(u){return function(l){return c([u,l])}}function c(u){if(r)throw new TypeError("Generator is already executing.");for(;e;)try{if(r=1,i&&(o=u[0]&2?i.return:u[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,u[1])).done)return o;switch(i=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return e.label++,{value:u[1],done:!1};case 5:e.label++,i=u[1],u=[0];continue;case 7:u=e.ops.pop(),e.trys.pop();continue;default:if(o=e.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){e.label=u[1];break}if(u[0]===6&&e.label<o[1]){e.label=o[1],o=u;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(u);break}o[2]&&e.ops.pop(),e.trys.pop();continue}u=n.call(t,e)}catch(l){u=[6,l],i=0}finally{r=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}},To=Gt&&Gt.__await||function(t){return this instanceof To?(this.v=t,this):new To(t)},cL=Gt&&Gt.__asyncGenerator||function(t,n,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(t,n||[]),i,o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(f){r[f]&&(i[f]=function(p){return new Promise(function(m,y){o.push([f,p,m,y])>1||a(f,p)})})}function a(f,p){try{c(r[f](p))}catch(m){d(o[0][3],m)}}function c(f){f.value instanceof To?Promise.resolve(f.value.v).then(u,l):d(o[0][2],f)}function u(f){a("next",f)}function l(f){a("throw",f)}function d(f,p){f(p),o.shift(),o.length&&a(o[0][0],o[0][1])}};Object.defineProperty(Gt,"__esModule",{value:!0});Gt.isReadableStreamLike=Gt.readableStreamLikeToAsyncGenerator=void 0;var uL=ke();function lL(t){return cL(this,arguments,function(){var e,r,i,o;return aL(this,function(s){switch(s.label){case 0:e=t.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,To(e.read())];case 3:return r=s.sent(),i=r.value,o=r.done,o?[4,To(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,To(i)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}Gt.readableStreamLikeToAsyncGenerator=lL;function dL(t){return uL.isFunction(t?.getReader)}Gt.isReadableStreamLike=dL});var se=v(Ge=>{"use strict";var fL=Ge&&Ge.__awaiter||function(t,n,e,r){function i(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function a(l){try{u(r.next(l))}catch(d){s(d)}}function c(l){try{u(r.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):i(l.value).then(a,c)}u((r=r.apply(t,n||[])).next())})},hL=Ge&&Ge.__generator||function(t,n){var e={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(u){return function(l){return c([u,l])}}function c(u){if(r)throw new TypeError("Generator is already executing.");for(;e;)try{if(r=1,i&&(o=u[0]&2?i.return:u[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,u[1])).done)return o;switch(i=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return e.label++,{value:u[1],done:!1};case 5:e.label++,i=u[1],u=[0];continue;case 7:u=e.ops.pop(),e.trys.pop();continue;default:if(o=e.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){e.label=u[1];break}if(u[0]===6&&e.label<o[1]){e.label=o[1],o=u;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(u);break}o[2]&&e.ops.pop(),e.trys.pop();continue}u=n.call(t,e)}catch(l){u=[6,l],i=0}finally{r=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}},pL=Ge&&Ge.__asyncValues||function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t[Symbol.asyncIterator],e;return n?n.call(t):(t=typeof Vm=="function"?Vm(t):t[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(o){e[o]=t[o]&&function(s){return new Promise(function(a,c){s=t[o](s),i(a,c,s.done,s.value)})}}function i(o,s,a,c){Promise.resolve(c).then(function(u){o({value:u,done:a})},s)}},Vm=Ge&&Ge.__values||function(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Ge,"__esModule",{value:!0});Ge.fromReadableStreamLike=Ge.fromAsyncIterable=Ge.fromIterable=Ge.fromPromise=Ge.fromArrayLike=Ge.fromInteropObservable=Ge.innerFrom=void 0;var mL=gu(),gL=Fm(),xo=je(),yL=$m(),vL=qm(),_L=Bm(),bL=Um(),rC=Eu(),wL=ke(),EL=Em(),SL=oa();function CL(t){if(t instanceof xo.Observable)return t;if(t!=null){if(yL.isInteropObservable(t))return iC(t);if(mL.isArrayLike(t))return oC(t);if(gL.isPromise(t))return sC(t);if(vL.isAsyncIterable(t))return Wm(t);if(bL.isIterable(t))return aC(t);if(rC.isReadableStreamLike(t))return cC(t)}throw _L.createInvalidObservableTypeError(t)}Ge.innerFrom=CL;function iC(t){return new xo.Observable(function(n){var e=t[SL.observable]();if(wL.isFunction(e.subscribe))return e.subscribe(n);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}Ge.fromInteropObservable=iC;function oC(t){return new xo.Observable(function(n){for(var e=0;e<t.length&&!n.closed;e++)n.next(t[e]);n.complete()})}Ge.fromArrayLike=oC;function sC(t){return new xo.Observable(function(n){t.then(function(e){n.closed||(n.next(e),n.complete())},function(e){return n.error(e)}).then(null,EL.reportUnhandledError)})}Ge.fromPromise=sC;function aC(t){return new xo.Observable(function(n){var e,r;try{for(var i=Vm(t),o=i.next();!o.done;o=i.next()){var s=o.value;if(n.next(s),n.closed)return}}catch(a){e={error:a}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}n.complete()})}Ge.fromIterable=aC;function Wm(t){return new xo.Observable(function(n){IL(t,n).catch(function(e){return n.error(e)})})}Ge.fromAsyncIterable=Wm;function cC(t){return Wm(rC.readableStreamLikeToAsyncGenerator(t))}Ge.fromReadableStreamLike=cC;function IL(t,n){var e,r,i,o;return fL(this,void 0,void 0,function(){var s,a;return hL(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),e=pL(t),c.label=1;case 1:return[4,e.next()];case 2:if(r=c.sent(),!!r.done)return[3,4];if(s=r.value,n.next(s),n.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&&(o=e.return)?[4,o.call(e)]:[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 n.complete(),[2]}})})}});var kn=v(Su=>{"use strict";Object.defineProperty(Su,"__esModule",{value:!0});Su.executeSchedule=void 0;function TL(t,n,e,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var o=n.schedule(function(){e(),i?t.add(this.schedule(null,r)):this.unsubscribe()},r);if(t.add(o),!i)return o}Su.executeSchedule=TL});var Do=v(Cu=>{"use strict";Object.defineProperty(Cu,"__esModule",{value:!0});Cu.observeOn=void 0;var Gm=kn(),xL=L(),DL=V();function OL(t,n){return n===void 0&&(n=0),xL.operate(function(e,r){e.subscribe(DL.createOperatorSubscriber(r,function(i){return Gm.executeSchedule(r,t,function(){return r.next(i)},n)},function(){return Gm.executeSchedule(r,t,function(){return r.complete()},n)},function(i){return Gm.executeSchedule(r,t,function(){return r.error(i)},n)}))})}Cu.observeOn=OL});var Oo=v(Iu=>{"use strict";Object.defineProperty(Iu,"__esModule",{value:!0});Iu.subscribeOn=void 0;var ML=L();function AL(t,n){return n===void 0&&(n=0),ML.operate(function(e,r){r.add(t.schedule(function(){return e.subscribe(r)},n))})}Iu.subscribeOn=AL});var uC=v(Tu=>{"use strict";Object.defineProperty(Tu,"__esModule",{value:!0});Tu.scheduleObservable=void 0;var NL=se(),PL=Do(),RL=Oo();function kL(t,n){return NL.innerFrom(t).pipe(RL.subscribeOn(n),PL.observeOn(n))}Tu.scheduleObservable=kL});var lC=v(xu=>{"use strict";Object.defineProperty(xu,"__esModule",{value:!0});xu.schedulePromise=void 0;var LL=se(),jL=Do(),FL=Oo();function $L(t,n){return LL.innerFrom(t).pipe(FL.subscribeOn(n),jL.observeOn(n))}xu.schedulePromise=$L});var dC=v(Du=>{"use strict";Object.defineProperty(Du,"__esModule",{value:!0});Du.scheduleArray=void 0;var qL=je();function BL(t,n){return new qL.Observable(function(e){var r=0;return n.schedule(function(){r===t.length?e.complete():(e.next(t[r++]),e.closed||this.schedule())})})}Du.scheduleArray=BL});var zm=v(Ou=>{"use strict";Object.defineProperty(Ou,"__esModule",{value:!0});Ou.scheduleIterable=void 0;var HL=je(),UL=Hm(),VL=ke(),fC=kn();function WL(t,n){return new HL.Observable(function(e){var r;return fC.executeSchedule(e,n,function(){r=t[UL.iterator](),fC.executeSchedule(e,n,function(){var i,o,s;try{i=r.next(),o=i.value,s=i.done}catch(a){e.error(a);return}s?e.complete():e.next(o)},0,!0)}),function(){return VL.isFunction(r?.return)&&r.return()}})}Ou.scheduleIterable=WL});var Km=v(Mu=>{"use strict";Object.defineProperty(Mu,"__esModule",{value:!0});Mu.scheduleAsyncIterable=void 0;var GL=je(),hC=kn();function zL(t,n){if(!t)throw new Error("Iterable cannot be null");return new GL.Observable(function(e){hC.executeSchedule(e,n,function(){var r=t[Symbol.asyncIterator]();hC.executeSchedule(e,n,function(){r.next().then(function(i){i.done?e.complete():e.next(i.value)})},0,!0)})})}Mu.scheduleAsyncIterable=zL});var pC=v(Au=>{"use strict";Object.defineProperty(Au,"__esModule",{value:!0});Au.scheduleReadableStreamLike=void 0;var KL=Km(),YL=Eu();function ZL(t,n){return KL.scheduleAsyncIterable(YL.readableStreamLikeToAsyncGenerator(t),n)}Au.scheduleReadableStreamLike=ZL});var Ym=v(Nu=>{"use strict";Object.defineProperty(Nu,"__esModule",{value:!0});Nu.scheduled=void 0;var QL=uC(),JL=lC(),XL=dC(),ej=zm(),tj=Km(),nj=$m(),rj=Fm(),ij=gu(),oj=Um(),sj=qm(),aj=Bm(),cj=Eu(),uj=pC();function lj(t,n){if(t!=null){if(nj.isInteropObservable(t))return QL.scheduleObservable(t,n);if(ij.isArrayLike(t))return XL.scheduleArray(t,n);if(rj.isPromise(t))return JL.schedulePromise(t,n);if(sj.isAsyncIterable(t))return tj.scheduleAsyncIterable(t,n);if(oj.isIterable(t))return ej.scheduleIterable(t,n);if(cj.isReadableStreamLike(t))return uj.scheduleReadableStreamLike(t,n)}throw aj.createInvalidObservableTypeError(t)}Nu.scheduled=lj});var Ln=v(Pu=>{"use strict";Object.defineProperty(Pu,"__esModule",{value:!0});Pu.from=void 0;var dj=Ym(),fj=se();function hj(t,n){return n?dj.scheduled(t,n):fj.innerFrom(t)}Pu.from=hj});var ku=v(Ru=>{"use strict";Object.defineProperty(Ru,"__esModule",{value:!0});Ru.of=void 0;var pj=Tt(),mj=Ln();function gj(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=pj.popScheduler(t);return mj.from(t,e)}Ru.of=gj});var Zm=v(Lu=>{"use strict";Object.defineProperty(Lu,"__esModule",{value:!0});Lu.throwError=void 0;var yj=je(),vj=ke();function _j(t,n){var e=vj.isFunction(t)?t:function(){return t},r=function(i){return i.error(e())};return new yj.Observable(n?function(i){return n.schedule(r,0,i)}:r)}Lu.throwError=_j});var ju=v(jn=>{"use strict";Object.defineProperty(jn,"__esModule",{value:!0});jn.observeNotification=jn.Notification=jn.NotificationKind=void 0;var bj=on(),wj=ku(),Ej=Zm(),Sj=ke(),Cj;(function(t){t.NEXT="N",t.ERROR="E",t.COMPLETE="C"})(Cj=jn.NotificationKind||(jn.NotificationKind={}));var Ij=(function(){function t(n,e,r){this.kind=n,this.value=e,this.error=r,this.hasValue=n==="N"}return t.prototype.observe=function(n){return mC(this,n)},t.prototype.do=function(n,e,r){var i=this,o=i.kind,s=i.value,a=i.error;return o==="N"?n?.(s):o==="E"?e?.(a):r?.()},t.prototype.accept=function(n,e,r){var i;return Sj.isFunction((i=n)===null||i===void 0?void 0:i.next)?this.observe(n):this.do(n,e,r)},t.prototype.toObservable=function(){var n=this,e=n.kind,r=n.value,i=n.error,o=e==="N"?wj.of(r):e==="E"?Ej.throwError(function(){return i}):e==="C"?bj.EMPTY:0;if(!o)throw new TypeError("Unexpected notification kind "+e);return o},t.createNext=function(n){return new t("N",n)},t.createError=function(n){return new t("E",void 0,n)},t.createComplete=function(){return t.completeNotification},t.completeNotification=new t("C"),t})();jn.Notification=Ij;function mC(t,n){var e,r,i,o=t,s=o.kind,a=o.value,c=o.error;if(typeof s!="string")throw new TypeError('Invalid notification, missing "kind"');s==="N"?(e=n.next)===null||e===void 0||e.call(n,a):s==="E"?(r=n.error)===null||r===void 0||r.call(n,c):(i=n.complete)===null||i===void 0||i.call(n)}jn.observeNotification=mC});var yC=v(Fu=>{"use strict";Object.defineProperty(Fu,"__esModule",{value:!0});Fu.isObservable=void 0;var Tj=je(),gC=ke();function xj(t){return!!t&&(t instanceof Tj.Observable||gC.isFunction(t.lift)&&gC.isFunction(t.subscribe))}Fu.isObservable=xj});var pr=v($u=>{"use strict";Object.defineProperty($u,"__esModule",{value:!0});$u.EmptyError=void 0;var Dj=lr();$u.EmptyError=Dj.createErrorClass(function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}})});var vC=v(qu=>{"use strict";Object.defineProperty(qu,"__esModule",{value:!0});qu.lastValueFrom=void 0;var Oj=pr();function Mj(t,n){var e=typeof n=="object";return new Promise(function(r,i){var o=!1,s;t.subscribe({next:function(a){s=a,o=!0},error:i,complete:function(){o?r(s):e?r(n.defaultValue):i(new Oj.EmptyError)}})})}qu.lastValueFrom=Mj});var _C=v(Bu=>{"use strict";Object.defineProperty(Bu,"__esModule",{value:!0});Bu.firstValueFrom=void 0;var Aj=pr(),Nj=oo();function Pj(t,n){var e=typeof n=="object";return new Promise(function(r,i){var o=new Nj.SafeSubscriber({next:function(s){r(s),o.unsubscribe()},error:i,complete:function(){e?r(n.defaultValue):i(new Aj.EmptyError)}});t.subscribe(o)})}Bu.firstValueFrom=Pj});var Qm=v(Hu=>{"use strict";Object.defineProperty(Hu,"__esModule",{value:!0});Hu.ArgumentOutOfRangeError=void 0;var Rj=lr();Hu.ArgumentOutOfRangeError=Rj.createErrorClass(function(t){return function(){t(this),this.name="ArgumentOutOfRangeError",this.message="argument out of range"}})});var Jm=v(Uu=>{"use strict";Object.defineProperty(Uu,"__esModule",{value:!0});Uu.NotFoundError=void 0;var kj=lr();Uu.NotFoundError=kj.createErrorClass(function(t){return function(e){t(this),this.name="NotFoundError",this.message=e}})});var Xm=v(Vu=>{"use strict";Object.defineProperty(Vu,"__esModule",{value:!0});Vu.SequenceError=void 0;var Lj=lr();Vu.SequenceError=Lj.createErrorClass(function(t){return function(e){t(this),this.name="SequenceError",this.message=e}})});var Gu=v(Wu=>{"use strict";Object.defineProperty(Wu,"__esModule",{value:!0});Wu.isValidDate=void 0;function jj(t){return t instanceof Date&&!isNaN(t)}Wu.isValidDate=jj});var da=v(di=>{"use strict";Object.defineProperty(di,"__esModule",{value:!0});di.timeout=di.TimeoutError=void 0;var Fj=It(),$j=Gu(),qj=L(),Bj=se(),Hj=lr(),Uj=V(),Vj=kn();di.TimeoutError=Hj.createErrorClass(function(t){return function(e){e===void 0&&(e=null),t(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=e}});function Wj(t,n){var e=$j.isValidDate(t)?{first:t}:typeof t=="number"?{each:t}:t,r=e.first,i=e.each,o=e.with,s=o===void 0?Gj:o,a=e.scheduler,c=a===void 0?n??Fj.asyncScheduler:a,u=e.meta,l=u===void 0?null:u;if(r==null&&i==null)throw new TypeError("No timeout provided.");return qj.operate(function(d,f){var p,m,y=null,b=0,E=function(D){m=Vj.executeSchedule(f,c,function(){try{p.unsubscribe(),Bj.innerFrom(s({meta:l,lastValue:y,seen:b})).subscribe(f)}catch(T){f.error(T)}},D)};p=d.subscribe(Uj.createOperatorSubscriber(f,function(D){m?.unsubscribe(),b++,f.next(y=D),i>0&&E(i)},void 0,void 0,function(){m?.closed||m?.unsubscribe(),y=null})),!b&&E(r!=null?typeof r=="number"?r:+r-c.now():i)})}di.timeout=Wj;function Gj(t){throw new di.TimeoutError(t)}});var Fn=v(zu=>{"use strict";Object.defineProperty(zu,"__esModule",{value:!0});zu.map=void 0;var zj=L(),Kj=V();function Yj(t,n){return zj.operate(function(e,r){var i=0;e.subscribe(Kj.createOperatorSubscriber(r,function(o){r.next(t.call(n,o,i++))}))})}zu.map=Yj});var gr=v(mr=>{"use strict";var Zj=mr&&mr.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},Qj=mr&&mr.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(mr,"__esModule",{value:!0});mr.mapOneOrManyArgs=void 0;var Jj=Fn(),Xj=Array.isArray;function eF(t,n){return Xj(n)?t.apply(void 0,Qj([],Zj(n))):t(n)}function tF(t){return Jj.map(function(n){return eF(t,n)})}mr.mapOneOrManyArgs=tF});var tg=v(yr=>{"use strict";var nF=yr&&yr.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},bC=yr&&yr.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(yr,"__esModule",{value:!0});yr.bindCallbackInternals=void 0;var rF=la(),iF=je(),oF=Oo(),sF=gr(),aF=Do(),cF=du();function eg(t,n,e,r){if(e)if(rF.isScheduler(e))r=e;else return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];return eg(t,n,r).apply(this,i).pipe(sF.mapOneOrManyArgs(e))};return r?function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];return eg(t,n).apply(this,i).pipe(oF.subscribeOn(r),aF.observeOn(r))}:function(){for(var i=this,o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];var a=new cF.AsyncSubject,c=!0;return new iF.Observable(function(u){var l=a.subscribe(u);if(c){c=!1;var d=!1,f=!1;n.apply(i,bC(bC([],nF(o)),[function(){for(var p=[],m=0;m<arguments.length;m++)p[m]=arguments[m];if(t){var y=p.shift();if(y!=null){a.error(y);return}}a.next(1<p.length?p:p[0]),f=!0,d&&a.complete()}])),f&&a.complete(),d=!0}return l})}}yr.bindCallbackInternals=eg});var wC=v(Ku=>{"use strict";Object.defineProperty(Ku,"__esModule",{value:!0});Ku.bindCallback=void 0;var uF=tg();function lF(t,n,e){return uF.bindCallbackInternals(!1,t,n,e)}Ku.bindCallback=lF});var EC=v(Yu=>{"use strict";Object.defineProperty(Yu,"__esModule",{value:!0});Yu.bindNodeCallback=void 0;var dF=tg();function fF(t,n,e){return dF.bindCallbackInternals(!0,t,n,e)}Yu.bindNodeCallback=fF});var ng=v(Zu=>{"use strict";Object.defineProperty(Zu,"__esModule",{value:!0});Zu.argsArgArrayOrObject=void 0;var hF=Array.isArray,pF=Object.getPrototypeOf,mF=Object.prototype,gF=Object.keys;function yF(t){if(t.length===1){var n=t[0];if(hF(n))return{args:n,keys:null};if(vF(n)){var e=gF(n);return{args:e.map(function(r){return n[r]}),keys:e}}}return{args:t,keys:null}}Zu.argsArgArrayOrObject=yF;function vF(t){return t&&typeof t=="object"&&pF(t)===mF}});var rg=v(Qu=>{"use strict";Object.defineProperty(Qu,"__esModule",{value:!0});Qu.createObject=void 0;function _F(t,n){return t.reduce(function(e,r,i){return e[r]=n[i],e},{})}Qu.createObject=_F});var Ju=v(Mo=>{"use strict";Object.defineProperty(Mo,"__esModule",{value:!0});Mo.combineLatestInit=Mo.combineLatest=void 0;var bF=je(),wF=ng(),IC=Ln(),TC=ut(),EF=gr(),SC=Tt(),SF=rg(),CF=V(),IF=kn();function TF(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=SC.popScheduler(t),r=SC.popResultSelector(t),i=wF.argsArgArrayOrObject(t),o=i.args,s=i.keys;if(o.length===0)return IC.from([],e);var a=new bF.Observable(xC(o,e,s?function(c){return SF.createObject(s,c)}:TC.identity));return r?a.pipe(EF.mapOneOrManyArgs(r)):a}Mo.combineLatest=TF;function xC(t,n,e){return e===void 0&&(e=TC.identity),function(r){CC(n,function(){for(var i=t.length,o=new Array(i),s=i,a=i,c=function(l){CC(n,function(){var d=IC.from(t[l],n),f=!1;d.subscribe(CF.createOperatorSubscriber(r,function(p){o[l]=p,f||(f=!0,a--),a||r.next(e(o.slice()))},function(){--s||r.complete()}))},r)},u=0;u<i;u++)c(u)},r)}}Mo.combineLatestInit=xC;function CC(t,n,e){t?IF.executeSchedule(e,t,n):n()}});var el=v(Xu=>{"use strict";Object.defineProperty(Xu,"__esModule",{value:!0});Xu.mergeInternals=void 0;var xF=se(),DF=kn(),DC=V();function OF(t,n,e,r,i,o,s,a){var c=[],u=0,l=0,d=!1,f=function(){d&&!c.length&&!u&&n.complete()},p=function(y){return u<r?m(y):c.push(y)},m=function(y){o&&n.next(y),u++;var b=!1;xF.innerFrom(e(y,l++)).subscribe(DC.createOperatorSubscriber(n,function(E){i?.(E),o?p(E):n.next(E)},function(){b=!0},void 0,function(){if(b)try{u--;for(var E=function(){var D=c.shift();s?DF.executeSchedule(n,s,function(){return m(D)}):m(D)};c.length&&u<r;)E();f()}catch(D){n.error(D)}}))};return t.subscribe(DC.createOperatorSubscriber(n,p,function(){d=!0,f()})),function(){a?.()}}Xu.mergeInternals=OF});var _n=v(tl=>{"use strict";Object.defineProperty(tl,"__esModule",{value:!0});tl.mergeMap=void 0;var MF=Fn(),AF=se(),NF=L(),PF=el(),RF=ke();function OC(t,n,e){return e===void 0&&(e=1/0),RF.isFunction(n)?OC(function(r,i){return MF.map(function(o,s){return n(r,o,i,s)})(AF.innerFrom(t(r,i)))},e):(typeof n=="number"&&(e=n),NF.operate(function(r,i){return PF.mergeInternals(r,i,t,e)}))}tl.mergeMap=OC});var Ao=v(nl=>{"use strict";Object.defineProperty(nl,"__esModule",{value:!0});nl.mergeAll=void 0;var kF=_n(),LF=ut();function jF(t){return t===void 0&&(t=1/0),kF.mergeMap(LF.identity,t)}nl.mergeAll=jF});var fa=v(rl=>{"use strict";Object.defineProperty(rl,"__esModule",{value:!0});rl.concatAll=void 0;var FF=Ao();function $F(){return FF.mergeAll(1)}rl.concatAll=$F});var ha=v(il=>{"use strict";Object.defineProperty(il,"__esModule",{value:!0});il.concat=void 0;var qF=fa(),BF=Tt(),HF=Ln();function UF(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return qF.concatAll()(HF.from(t,BF.popScheduler(t)))}il.concat=UF});var pa=v(ol=>{"use strict";Object.defineProperty(ol,"__esModule",{value:!0});ol.defer=void 0;var VF=je(),WF=se();function GF(t){return new VF.Observable(function(n){WF.innerFrom(t()).subscribe(n)})}ol.defer=GF});var MC=v(sl=>{"use strict";Object.defineProperty(sl,"__esModule",{value:!0});sl.connectable=void 0;var zF=lt(),KF=je(),YF=pa(),ZF={connector:function(){return new zF.Subject},resetOnDisconnect:!0};function QF(t,n){n===void 0&&(n=ZF);var e=null,r=n.connector,i=n.resetOnDisconnect,o=i===void 0?!0:i,s=r(),a=new KF.Observable(function(c){return s.subscribe(c)});return a.connect=function(){return(!e||e.closed)&&(e=YF.defer(function(){return t}).subscribe(s),o&&e.add(function(){return s=r()})),e},a}sl.connectable=QF});var AC=v(al=>{"use strict";Object.defineProperty(al,"__esModule",{value:!0});al.forkJoin=void 0;var JF=je(),XF=ng(),e$=se(),t$=Tt(),n$=V(),r$=gr(),i$=rg();function o$(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=t$.popResultSelector(t),r=XF.argsArgArrayOrObject(t),i=r.args,o=r.keys,s=new JF.Observable(function(a){var c=i.length;if(!c){a.complete();return}for(var u=new Array(c),l=c,d=c,f=function(m){var y=!1;e$.innerFrom(i[m]).subscribe(n$.createOperatorSubscriber(a,function(b){y||(y=!0,d--),u[m]=b},function(){return l--},void 0,function(){(!l||!y)&&(d||a.next(o?i$.createObject(o,u):u),a.complete())}))},p=0;p<c;p++)f(p)});return e?s.pipe(r$.mapOneOrManyArgs(e)):s}al.forkJoin=o$});var PC=v(No=>{"use strict";var s$=No&&No.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o};Object.defineProperty(No,"__esModule",{value:!0});No.fromEvent=void 0;var a$=se(),c$=je(),u$=_n(),l$=gu(),fi=ke(),d$=gr(),f$=["addListener","removeListener"],h$=["addEventListener","removeEventListener"],p$=["on","off"];function ig(t,n,e,r){if(fi.isFunction(e)&&(r=e,e=void 0),r)return ig(t,n,e).pipe(d$.mapOneOrManyArgs(r));var i=s$(y$(t)?h$.map(function(a){return function(c){return t[a](n,c,e)}}):m$(t)?f$.map(NC(t,n)):g$(t)?p$.map(NC(t,n)):[],2),o=i[0],s=i[1];if(!o&&l$.isArrayLike(t))return u$.mergeMap(function(a){return ig(a,n,e)})(a$.innerFrom(t));if(!o)throw new TypeError("Invalid event target");return new c$.Observable(function(a){var c=function(){for(var u=[],l=0;l<arguments.length;l++)u[l]=arguments[l];return a.next(1<u.length?u:u[0])};return o(c),function(){return s(c)}})}No.fromEvent=ig;function NC(t,n){return function(e){return function(r){return t[e](n,r)}}}function m$(t){return fi.isFunction(t.addListener)&&fi.isFunction(t.removeListener)}function g$(t){return fi.isFunction(t.on)&&fi.isFunction(t.off)}function y$(t){return fi.isFunction(t.addEventListener)&&fi.isFunction(t.removeEventListener)}});var kC=v(cl=>{"use strict";Object.defineProperty(cl,"__esModule",{value:!0});cl.fromEventPattern=void 0;var v$=je(),_$=ke(),b$=gr();function RC(t,n,e){return e?RC(t,n).pipe(b$.mapOneOrManyArgs(e)):new v$.Observable(function(r){var i=function(){for(var s=[],a=0;a<arguments.length;a++)s[a]=arguments[a];return r.next(s.length===1?s[0]:s)},o=t(i);return _$.isFunction(n)?function(){return n(i,o)}:void 0})}cl.fromEventPattern=RC});var jC=v(Po=>{"use strict";var w$=Po&&Po.__generator||function(t,n){var e={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(u){return function(l){return c([u,l])}}function c(u){if(r)throw new TypeError("Generator is already executing.");for(;e;)try{if(r=1,i&&(o=u[0]&2?i.return:u[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,u[1])).done)return o;switch(i=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return e.label++,{value:u[1],done:!1};case 5:e.label++,i=u[1],u=[0];continue;case 7:u=e.ops.pop(),e.trys.pop();continue;default:if(o=e.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){e.label=u[1];break}if(u[0]===6&&e.label<o[1]){e.label=o[1],o=u;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(u);break}o[2]&&e.ops.pop(),e.trys.pop();continue}u=n.call(t,e)}catch(l){u=[6,l],i=0}finally{r=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}};Object.defineProperty(Po,"__esModule",{value:!0});Po.generate=void 0;var LC=ut(),E$=la(),S$=pa(),C$=zm();function I$(t,n,e,r,i){var o,s,a,c;arguments.length===1?(o=t,c=o.initialState,n=o.condition,e=o.iterate,s=o.resultSelector,a=s===void 0?LC.identity:s,i=o.scheduler):(c=t,!r||E$.isScheduler(r)?(a=LC.identity,i=r):a=r);function u(){var l;return w$(this,function(d){switch(d.label){case 0:l=c,d.label=1;case 1:return!n||n(l)?[4,a(l)]:[3,4];case 2:d.sent(),d.label=3;case 3:return l=e(l),[3,1];case 4:return[2]}})}return S$.defer(i?function(){return C$.scheduleIterable(u(),i)}:u)}Po.generate=I$});var FC=v(ul=>{"use strict";Object.defineProperty(ul,"__esModule",{value:!0});ul.iif=void 0;var T$=pa();function x$(t,n,e){return T$.defer(function(){return t()?n:e})}ul.iif=x$});var vr=v(ll=>{"use strict";Object.defineProperty(ll,"__esModule",{value:!0});ll.timer=void 0;var D$=je(),O$=It(),M$=la(),A$=Gu();function N$(t,n,e){t===void 0&&(t=0),e===void 0&&(e=O$.async);var r=-1;return n!=null&&(M$.isScheduler(n)?e=n:r=n),new D$.Observable(function(i){var o=A$.isValidDate(t)?+t-e.now():t;o<0&&(o=0);var s=0;return e.schedule(function(){i.closed||(i.next(s++),0<=r?this.schedule(void 0,r):i.complete())},o)})}ll.timer=N$});var og=v(dl=>{"use strict";Object.defineProperty(dl,"__esModule",{value:!0});dl.interval=void 0;var P$=It(),R$=vr();function k$(t,n){return t===void 0&&(t=0),n===void 0&&(n=P$.asyncScheduler),t<0&&(t=0),R$.timer(t,t,n)}dl.interval=k$});var qC=v(fl=>{"use strict";Object.defineProperty(fl,"__esModule",{value:!0});fl.merge=void 0;var L$=Ao(),j$=se(),F$=on(),$C=Tt(),$$=Ln();function q$(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=$C.popScheduler(t),r=$C.popNumber(t,1/0),i=t;return i.length?i.length===1?j$.innerFrom(i[0]):L$.mergeAll(r)($$.from(i,e)):F$.EMPTY}fl.merge=q$});var sg=v(hi=>{"use strict";Object.defineProperty(hi,"__esModule",{value:!0});hi.never=hi.NEVER=void 0;var B$=je(),H$=ct();hi.NEVER=new B$.Observable(H$.noop);function U$(){return hi.NEVER}hi.never=U$});var pi=v(hl=>{"use strict";Object.defineProperty(hl,"__esModule",{value:!0});hl.argsOrArgArray=void 0;var V$=Array.isArray;function W$(t){return t.length===1&&V$(t[0])?t[0]:t}hl.argsOrArgArray=W$});var ag=v(pl=>{"use strict";Object.defineProperty(pl,"__esModule",{value:!0});pl.onErrorResumeNext=void 0;var G$=je(),z$=pi(),K$=V(),BC=ct(),Y$=se();function Z$(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=z$.argsOrArgArray(t);return new G$.Observable(function(r){var i=0,o=function(){if(i<e.length){var s=void 0;try{s=Y$.innerFrom(e[i++])}catch{o();return}var a=new K$.OperatorSubscriber(r,void 0,BC.noop,BC.noop);s.subscribe(a),a.add(o)}else r.complete()};o()})}pl.onErrorResumeNext=Z$});var HC=v(ml=>{"use strict";Object.defineProperty(ml,"__esModule",{value:!0});ml.pairs=void 0;var Q$=Ln();function J$(t,n){return Q$.from(Object.entries(t),n)}ml.pairs=J$});var cg=v(gl=>{"use strict";Object.defineProperty(gl,"__esModule",{value:!0});gl.not=void 0;function X$(t,n){return function(e,r){return!t.call(n,e,r)}}gl.not=X$});var $n=v(yl=>{"use strict";Object.defineProperty(yl,"__esModule",{value:!0});yl.filter=void 0;var eq=L(),tq=V();function nq(t,n){return eq.operate(function(e,r){var i=0;e.subscribe(tq.createOperatorSubscriber(r,function(o){return t.call(n,o,i++)&&r.next(o)}))})}yl.filter=nq});var WC=v(vl=>{"use strict";Object.defineProperty(vl,"__esModule",{value:!0});vl.partition=void 0;var rq=cg(),UC=$n(),VC=se();function iq(t,n,e){return[UC.filter(n,e)(VC.innerFrom(t)),UC.filter(rq.not(n,e))(VC.innerFrom(t))]}vl.partition=iq});var ug=v(Ro=>{"use strict";Object.defineProperty(Ro,"__esModule",{value:!0});Ro.raceInit=Ro.race=void 0;var oq=je(),GC=se(),sq=pi(),aq=V();function cq(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t=sq.argsOrArgArray(t),t.length===1?GC.innerFrom(t[0]):new oq.Observable(zC(t))}Ro.race=cq;function zC(t){return function(n){for(var e=[],r=function(o){e.push(GC.innerFrom(t[o]).subscribe(aq.createOperatorSubscriber(n,function(s){if(e){for(var a=0;a<e.length;a++)a!==o&&e[a].unsubscribe();e=null}n.next(s)})))},i=0;e&&!n.closed&&i<t.length;i++)r(i)}}Ro.raceInit=zC});var KC=v(_l=>{"use strict";Object.defineProperty(_l,"__esModule",{value:!0});_l.range=void 0;var uq=je(),lq=on();function dq(t,n,e){if(n==null&&(n=t,t=0),n<=0)return lq.EMPTY;var r=n+t;return new uq.Observable(e?function(i){var o=t;return e.schedule(function(){o<r?(i.next(o++),this.schedule()):i.complete()})}:function(i){for(var o=t;o<r&&!i.closed;)i.next(o++);i.complete()})}_l.range=dq});var YC=v(bl=>{"use strict";Object.defineProperty(bl,"__esModule",{value:!0});bl.using=void 0;var fq=je(),hq=se(),pq=on();function mq(t,n){return new fq.Observable(function(e){var r=t(),i=n(r),o=i?hq.innerFrom(i):pq.EMPTY;return o.subscribe(e),function(){r&&r.unsubscribe()}})}bl.using=mq});var wl=v(_r=>{"use strict";var gq=_r&&_r.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},yq=_r&&_r.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(_r,"__esModule",{value:!0});_r.zip=void 0;var vq=je(),_q=se(),bq=pi(),wq=on(),Eq=V(),Sq=Tt();function Cq(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=Sq.popResultSelector(t),r=bq.argsOrArgArray(t);return r.length?new vq.Observable(function(i){var o=r.map(function(){return[]}),s=r.map(function(){return!1});i.add(function(){o=s=null});for(var a=function(u){_q.innerFrom(r[u]).subscribe(Eq.createOperatorSubscriber(i,function(l){if(o[u].push(l),o.every(function(f){return f.length})){var d=o.map(function(f){return f.shift()});i.next(e?e.apply(void 0,yq([],gq(d))):d),o.some(function(f,p){return!f.length&&s[p]})&&i.complete()}},function(){s[u]=!0,!o[u].length&&i.complete()}))},c=0;!i.closed&&c<r.length;c++)a(c);return function(){o=s=null}}):wq.EMPTY}_r.zip=Cq});var QC=v(ZC=>{"use strict";Object.defineProperty(ZC,"__esModule",{value:!0})});var Sl=v(El=>{"use strict";Object.defineProperty(El,"__esModule",{value:!0});El.audit=void 0;var Iq=L(),Tq=se(),JC=V();function xq(t){return Iq.operate(function(n,e){var r=!1,i=null,o=null,s=!1,a=function(){if(o?.unsubscribe(),o=null,r){r=!1;var u=i;i=null,e.next(u)}s&&e.complete()},c=function(){o=null,s&&e.complete()};n.subscribe(JC.createOperatorSubscriber(e,function(u){r=!0,i=u,o||Tq.innerFrom(t(u)).subscribe(o=JC.createOperatorSubscriber(e,a,c))},function(){s=!0,(!r||!o||o.closed)&&e.complete()}))})}El.audit=xq});var lg=v(Cl=>{"use strict";Object.defineProperty(Cl,"__esModule",{value:!0});Cl.auditTime=void 0;var Dq=It(),Oq=Sl(),Mq=vr();function Aq(t,n){return n===void 0&&(n=Dq.asyncScheduler),Oq.audit(function(){return Mq.timer(t,n)})}Cl.auditTime=Aq});var dg=v(Il=>{"use strict";Object.defineProperty(Il,"__esModule",{value:!0});Il.buffer=void 0;var Nq=L(),Pq=ct(),XC=V(),Rq=se();function kq(t){return Nq.operate(function(n,e){var r=[];return n.subscribe(XC.createOperatorSubscriber(e,function(i){return r.push(i)},function(){e.next(r),e.complete()})),Rq.innerFrom(t).subscribe(XC.createOperatorSubscriber(e,function(){var i=r;r=[],e.next(i)},Pq.noop)),function(){r=null}})}Il.buffer=kq});var hg=v(ko=>{"use strict";var fg=ko&&ko.__values||function(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(ko,"__esModule",{value:!0});ko.bufferCount=void 0;var Lq=L(),jq=V(),Fq=Rn();function $q(t,n){return n===void 0&&(n=null),n=n??t,Lq.operate(function(e,r){var i=[],o=0;e.subscribe(jq.createOperatorSubscriber(r,function(s){var a,c,u,l,d=null;o++%n===0&&i.push([]);try{for(var f=fg(i),p=f.next();!p.done;p=f.next()){var m=p.value;m.push(s),t<=m.length&&(d=d??[],d.push(m))}}catch(E){a={error:E}}finally{try{p&&!p.done&&(c=f.return)&&c.call(f)}finally{if(a)throw a.error}}if(d)try{for(var y=fg(d),b=y.next();!b.done;b=y.next()){var m=b.value;Fq.arrRemove(i,m),r.next(m)}}catch(E){u={error:E}}finally{try{b&&!b.done&&(l=y.return)&&l.call(y)}finally{if(u)throw u.error}}},function(){var s,a;try{for(var c=fg(i),u=c.next();!u.done;u=c.next()){var l=u.value;r.next(l)}}catch(d){s={error:d}}finally{try{u&&!u.done&&(a=c.return)&&a.call(c)}finally{if(s)throw s.error}}r.complete()},void 0,function(){i=null}))})}ko.bufferCount=$q});var pg=v(Lo=>{"use strict";var qq=Lo&&Lo.__values||function(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Lo,"__esModule",{value:!0});Lo.bufferTime=void 0;var Bq=Lt(),Hq=L(),Uq=V(),Vq=Rn(),Wq=It(),Gq=Tt(),eI=kn();function zq(t){for(var n,e,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];var o=(n=Gq.popScheduler(r))!==null&&n!==void 0?n:Wq.asyncScheduler,s=(e=r[0])!==null&&e!==void 0?e:null,a=r[1]||1/0;return Hq.operate(function(c,u){var l=[],d=!1,f=function(y){var b=y.buffer,E=y.subs;E.unsubscribe(),Vq.arrRemove(l,y),u.next(b),d&&p()},p=function(){if(l){var y=new Bq.Subscription;u.add(y);var b=[],E={buffer:b,subs:y};l.push(E),eI.executeSchedule(y,o,function(){return f(E)},t)}};s!==null&&s>=0?eI.executeSchedule(u,o,p,s,!0):d=!0,p();var m=Uq.createOperatorSubscriber(u,function(y){var b,E,D=l.slice();try{for(var T=qq(D),K=T.next();!K.done;K=T.next()){var H=K.value,re=H.buffer;re.push(y),a<=re.length&&f(H)}}catch(Ee){b={error:Ee}}finally{try{K&&!K.done&&(E=T.return)&&E.call(T)}finally{if(b)throw b.error}}},function(){for(;l?.length;)u.next(l.shift().buffer);m?.unsubscribe(),u.complete(),u.unsubscribe()},void 0,function(){return l=null});c.subscribe(m)})}Lo.bufferTime=zq});var gg=v(jo=>{"use strict";var Kq=jo&&jo.__values||function(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(jo,"__esModule",{value:!0});jo.bufferToggle=void 0;var Yq=Lt(),Zq=L(),tI=se(),mg=V(),nI=ct(),Qq=Rn();function Jq(t,n){return Zq.operate(function(e,r){var i=[];tI.innerFrom(t).subscribe(mg.createOperatorSubscriber(r,function(o){var s=[];i.push(s);var a=new Yq.Subscription,c=function(){Qq.arrRemove(i,s),r.next(s),a.unsubscribe()};a.add(tI.innerFrom(n(o)).subscribe(mg.createOperatorSubscriber(r,c,nI.noop)))},nI.noop)),e.subscribe(mg.createOperatorSubscriber(r,function(o){var s,a;try{for(var c=Kq(i),u=c.next();!u.done;u=c.next()){var l=u.value;l.push(o)}}catch(d){s={error:d}}finally{try{u&&!u.done&&(a=c.return)&&a.call(c)}finally{if(s)throw s.error}}},function(){for(;i.length>0;)r.next(i.shift());r.complete()}))})}jo.bufferToggle=Jq});var yg=v(Tl=>{"use strict";Object.defineProperty(Tl,"__esModule",{value:!0});Tl.bufferWhen=void 0;var Xq=L(),eB=ct(),rI=V(),tB=se();function nB(t){return Xq.operate(function(n,e){var r=null,i=null,o=function(){i?.unsubscribe();var s=r;r=[],s&&e.next(s),tB.innerFrom(t()).subscribe(i=rI.createOperatorSubscriber(e,o,eB.noop))};o(),n.subscribe(rI.createOperatorSubscriber(e,function(s){return r?.push(s)},function(){r&&e.next(r),e.complete()},void 0,function(){return r=i=null}))})}Tl.bufferWhen=nB});var vg=v(xl=>{"use strict";Object.defineProperty(xl,"__esModule",{value:!0});xl.catchError=void 0;var rB=se(),iB=V(),oB=L();function iI(t){return oB.operate(function(n,e){var r=null,i=!1,o;r=n.subscribe(iB.createOperatorSubscriber(e,void 0,void 0,function(s){o=rB.innerFrom(t(s,iI(t)(n))),r?(r.unsubscribe(),r=null,o.subscribe(e)):i=!0})),i&&(r.unsubscribe(),r=null,o.subscribe(e))})}xl.catchError=iI});var _g=v(Dl=>{"use strict";Object.defineProperty(Dl,"__esModule",{value:!0});Dl.scanInternals=void 0;var sB=V();function aB(t,n,e,r,i){return function(o,s){var a=e,c=n,u=0;o.subscribe(sB.createOperatorSubscriber(s,function(l){var d=u++;c=a?t(c,l,d):(a=!0,l),r&&s.next(c)},i&&function(){a&&s.next(c),s.complete()}))}}Dl.scanInternals=aB});var mi=v(Ol=>{"use strict";Object.defineProperty(Ol,"__esModule",{value:!0});Ol.reduce=void 0;var cB=_g(),uB=L();function lB(t,n){return uB.operate(cB.scanInternals(t,n,arguments.length>=2,!1,!0))}Ol.reduce=lB});var Al=v(Ml=>{"use strict";Object.defineProperty(Ml,"__esModule",{value:!0});Ml.toArray=void 0;var dB=mi(),fB=L(),hB=function(t,n){return t.push(n),t};function pB(){return fB.operate(function(t,n){dB.reduce(hB,[])(t).subscribe(n)})}Ml.toArray=pB});var bg=v(Nl=>{"use strict";Object.defineProperty(Nl,"__esModule",{value:!0});Nl.joinAllInternals=void 0;var mB=ut(),gB=gr(),yB=sa(),vB=_n(),_B=Al();function bB(t,n){return yB.pipe(_B.toArray(),vB.mergeMap(function(e){return t(e)}),n?gB.mapOneOrManyArgs(n):mB.identity)}Nl.joinAllInternals=bB});var Rl=v(Pl=>{"use strict";Object.defineProperty(Pl,"__esModule",{value:!0});Pl.combineLatestAll=void 0;var wB=Ju(),EB=bg();function SB(t){return EB.joinAllInternals(wB.combineLatest,t)}Pl.combineLatestAll=SB});var wg=v(kl=>{"use strict";Object.defineProperty(kl,"__esModule",{value:!0});kl.combineAll=void 0;var CB=Rl();kl.combineAll=CB.combineLatestAll});var Eg=v(br=>{"use strict";var oI=br&&br.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},sI=br&&br.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(br,"__esModule",{value:!0});br.combineLatest=void 0;var IB=Ju(),TB=L(),xB=pi(),DB=gr(),OB=sa(),MB=Tt();function aI(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=MB.popResultSelector(t);return e?OB.pipe(aI.apply(void 0,sI([],oI(t))),DB.mapOneOrManyArgs(e)):TB.operate(function(r,i){IB.combineLatestInit(sI([r],oI(xB.argsOrArgArray(t))))(i)})}br.combineLatest=aI});var Sg=v(wr=>{"use strict";var AB=wr&&wr.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},NB=wr&&wr.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(wr,"__esModule",{value:!0});wr.combineLatestWith=void 0;var PB=Eg();function RB(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return PB.combineLatest.apply(void 0,NB([],AB(t)))}wr.combineLatestWith=RB});var jl=v(Ll=>{"use strict";Object.defineProperty(Ll,"__esModule",{value:!0});Ll.concatMap=void 0;var cI=_n(),kB=ke();function LB(t,n){return kB.isFunction(n)?cI.mergeMap(t,n,1):cI.mergeMap(t,1)}Ll.concatMap=LB});var Cg=v(Fl=>{"use strict";Object.defineProperty(Fl,"__esModule",{value:!0});Fl.concatMapTo=void 0;var uI=jl(),jB=ke();function FB(t,n){return jB.isFunction(n)?uI.concatMap(function(){return t},n):uI.concatMap(function(){return t})}Fl.concatMapTo=FB});var Ig=v(Er=>{"use strict";var $B=Er&&Er.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},qB=Er&&Er.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Er,"__esModule",{value:!0});Er.concat=void 0;var BB=L(),HB=fa(),UB=Tt(),VB=Ln();function WB(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=UB.popScheduler(t);return BB.operate(function(r,i){HB.concatAll()(VB.from(qB([r],$B(t)),e)).subscribe(i)})}Er.concat=WB});var Tg=v(Sr=>{"use strict";var GB=Sr&&Sr.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},zB=Sr&&Sr.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Sr,"__esModule",{value:!0});Sr.concatWith=void 0;var KB=Ig();function YB(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return KB.concat.apply(void 0,zB([],GB(t)))}Sr.concatWith=YB});var lI=v($l=>{"use strict";Object.defineProperty($l,"__esModule",{value:!0});$l.fromSubscribable=void 0;var ZB=je();function QB(t){return new ZB.Observable(function(n){return t.subscribe(n)})}$l.fromSubscribable=QB});var ma=v(ql=>{"use strict";Object.defineProperty(ql,"__esModule",{value:!0});ql.connect=void 0;var JB=lt(),XB=se(),eH=L(),tH=lI(),nH={connector:function(){return new JB.Subject}};function rH(t,n){n===void 0&&(n=nH);var e=n.connector;return eH.operate(function(r,i){var o=e();XB.innerFrom(t(tH.fromSubscribable(o))).subscribe(i),i.add(r.subscribe(o))})}ql.connect=rH});var xg=v(Bl=>{"use strict";Object.defineProperty(Bl,"__esModule",{value:!0});Bl.count=void 0;var iH=mi();function oH(t){return iH.reduce(function(n,e,r){return!t||t(e,r)?n+1:n},0)}Bl.count=oH});var Dg=v(Hl=>{"use strict";Object.defineProperty(Hl,"__esModule",{value:!0});Hl.debounce=void 0;var sH=L(),aH=ct(),dI=V(),cH=se();function uH(t){return sH.operate(function(n,e){var r=!1,i=null,o=null,s=function(){if(o?.unsubscribe(),o=null,r){r=!1;var a=i;i=null,e.next(a)}};n.subscribe(dI.createOperatorSubscriber(e,function(a){o?.unsubscribe(),r=!0,i=a,o=dI.createOperatorSubscriber(e,s,aH.noop),cH.innerFrom(t(a)).subscribe(o)},function(){s(),e.complete()},void 0,function(){i=o=null}))})}Hl.debounce=uH});var Og=v(Ul=>{"use strict";Object.defineProperty(Ul,"__esModule",{value:!0});Ul.debounceTime=void 0;var lH=It(),dH=L(),fH=V();function hH(t,n){return n===void 0&&(n=lH.asyncScheduler),dH.operate(function(e,r){var i=null,o=null,s=null,a=function(){if(i){i.unsubscribe(),i=null;var u=o;o=null,r.next(u)}};function c(){var u=s+t,l=n.now();if(l<u){i=this.schedule(void 0,u-l),r.add(i);return}a()}e.subscribe(fH.createOperatorSubscriber(r,function(u){o=u,s=n.now(),i||(i=n.schedule(c,t),r.add(i))},function(){a(),r.complete()},void 0,function(){o=i=null}))})}Ul.debounceTime=hH});var Fo=v(Vl=>{"use strict";Object.defineProperty(Vl,"__esModule",{value:!0});Vl.defaultIfEmpty=void 0;var pH=L(),mH=V();function gH(t){return pH.operate(function(n,e){var r=!1;n.subscribe(mH.createOperatorSubscriber(e,function(i){r=!0,e.next(i)},function(){r||e.next(t),e.complete()}))})}Vl.defaultIfEmpty=gH});var $o=v(Wl=>{"use strict";Object.defineProperty(Wl,"__esModule",{value:!0});Wl.take=void 0;var yH=on(),vH=L(),_H=V();function bH(t){return t<=0?function(){return yH.EMPTY}:vH.operate(function(n,e){var r=0;n.subscribe(_H.createOperatorSubscriber(e,function(i){++r<=t&&(e.next(i),t<=r&&e.complete())}))})}Wl.take=bH});var zl=v(Gl=>{"use strict";Object.defineProperty(Gl,"__esModule",{value:!0});Gl.ignoreElements=void 0;var wH=L(),EH=V(),SH=ct();function CH(){return wH.operate(function(t,n){t.subscribe(EH.createOperatorSubscriber(n,SH.noop))})}Gl.ignoreElements=CH});var Yl=v(Kl=>{"use strict";Object.defineProperty(Kl,"__esModule",{value:!0});Kl.mapTo=void 0;var IH=Fn();function TH(t){return IH.map(function(){return t})}Kl.mapTo=TH});var Ql=v(Zl=>{"use strict";Object.defineProperty(Zl,"__esModule",{value:!0});Zl.delayWhen=void 0;var xH=ha(),fI=$o(),DH=zl(),OH=Yl(),MH=_n(),AH=se();function hI(t,n){return n?function(e){return xH.concat(n.pipe(fI.take(1),DH.ignoreElements()),e.pipe(hI(t)))}:MH.mergeMap(function(e,r){return AH.innerFrom(t(e,r)).pipe(fI.take(1),OH.mapTo(e))})}Zl.delayWhen=hI});var Mg=v(Jl=>{"use strict";Object.defineProperty(Jl,"__esModule",{value:!0});Jl.delay=void 0;var NH=It(),PH=Ql(),RH=vr();function kH(t,n){n===void 0&&(n=NH.asyncScheduler);var e=RH.timer(t,n);return PH.delayWhen(function(){return e})}Jl.delay=kH});var Ag=v(Xl=>{"use strict";Object.defineProperty(Xl,"__esModule",{value:!0});Xl.dematerialize=void 0;var LH=ju(),jH=L(),FH=V();function $H(){return jH.operate(function(t,n){t.subscribe(FH.createOperatorSubscriber(n,function(e){return LH.observeNotification(e,n)}))})}Xl.dematerialize=$H});var Ng=v(ed=>{"use strict";Object.defineProperty(ed,"__esModule",{value:!0});ed.distinct=void 0;var qH=L(),pI=V(),BH=ct(),HH=se();function UH(t,n){return qH.operate(function(e,r){var i=new Set;e.subscribe(pI.createOperatorSubscriber(r,function(o){var s=t?t(o):o;i.has(s)||(i.add(s),r.next(o))})),n&&HH.innerFrom(n).subscribe(pI.createOperatorSubscriber(r,function(){return i.clear()},BH.noop))})}ed.distinct=UH});var nd=v(td=>{"use strict";Object.defineProperty(td,"__esModule",{value:!0});td.distinctUntilChanged=void 0;var VH=ut(),WH=L(),GH=V();function zH(t,n){return n===void 0&&(n=VH.identity),t=t??KH,WH.operate(function(e,r){var i,o=!0;e.subscribe(GH.createOperatorSubscriber(r,function(s){var a=n(s);(o||!t(i,a))&&(o=!1,i=a,r.next(s))}))})}td.distinctUntilChanged=zH;function KH(t,n){return t===n}});var Pg=v(rd=>{"use strict";Object.defineProperty(rd,"__esModule",{value:!0});rd.distinctUntilKeyChanged=void 0;var YH=nd();function ZH(t,n){return YH.distinctUntilChanged(function(e,r){return n?n(e[t],r[t]):e[t]===r[t]})}rd.distinctUntilKeyChanged=ZH});var qo=v(id=>{"use strict";Object.defineProperty(id,"__esModule",{value:!0});id.throwIfEmpty=void 0;var QH=pr(),JH=L(),XH=V();function eU(t){return t===void 0&&(t=tU),JH.operate(function(n,e){var r=!1;n.subscribe(XH.createOperatorSubscriber(e,function(i){r=!0,e.next(i)},function(){return r?e.complete():e.error(t())}))})}id.throwIfEmpty=eU;function tU(){return new QH.EmptyError}});var Rg=v(od=>{"use strict";Object.defineProperty(od,"__esModule",{value:!0});od.elementAt=void 0;var mI=Qm(),nU=$n(),rU=qo(),iU=Fo(),oU=$o();function sU(t,n){if(t<0)throw new mI.ArgumentOutOfRangeError;var e=arguments.length>=2;return function(r){return r.pipe(nU.filter(function(i,o){return o===t}),oU.take(1),e?iU.defaultIfEmpty(n):rU.throwIfEmpty(function(){return new mI.ArgumentOutOfRangeError}))}}od.elementAt=sU});var kg=v(Cr=>{"use strict";var aU=Cr&&Cr.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},cU=Cr&&Cr.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Cr,"__esModule",{value:!0});Cr.endWith=void 0;var uU=ha(),lU=ku();function dU(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return function(e){return uU.concat(e,lU.of.apply(void 0,cU([],aU(t))))}}Cr.endWith=dU});var Lg=v(sd=>{"use strict";Object.defineProperty(sd,"__esModule",{value:!0});sd.every=void 0;var fU=L(),hU=V();function pU(t,n){return fU.operate(function(e,r){var i=0;e.subscribe(hU.createOperatorSubscriber(r,function(o){t.call(n,o,i++,e)||(r.next(!1),r.complete())},function(){r.next(!0),r.complete()}))})}sd.every=pU});var cd=v(ad=>{"use strict";Object.defineProperty(ad,"__esModule",{value:!0});ad.exhaustMap=void 0;var mU=Fn(),gI=se(),gU=L(),yI=V();function vI(t,n){return n?function(e){return e.pipe(vI(function(r,i){return gI.innerFrom(t(r,i)).pipe(mU.map(function(o,s){return n(r,o,i,s)}))}))}:gU.operate(function(e,r){var i=0,o=null,s=!1;e.subscribe(yI.createOperatorSubscriber(r,function(a){o||(o=yI.createOperatorSubscriber(r,void 0,function(){o=null,s&&r.complete()}),gI.innerFrom(t(a,i++)).subscribe(o))},function(){s=!0,!o&&r.complete()}))})}ad.exhaustMap=vI});var ld=v(ud=>{"use strict";Object.defineProperty(ud,"__esModule",{value:!0});ud.exhaustAll=void 0;var yU=cd(),vU=ut();function _U(){return yU.exhaustMap(vU.identity)}ud.exhaustAll=_U});var jg=v(dd=>{"use strict";Object.defineProperty(dd,"__esModule",{value:!0});dd.exhaust=void 0;var bU=ld();dd.exhaust=bU.exhaustAll});var Fg=v(fd=>{"use strict";Object.defineProperty(fd,"__esModule",{value:!0});fd.expand=void 0;var wU=L(),EU=el();function SU(t,n,e){return n===void 0&&(n=1/0),n=(n||0)<1?1/0:n,wU.operate(function(r,i){return EU.mergeInternals(r,i,t,n,void 0,!0,e)})}fd.expand=SU});var $g=v(hd=>{"use strict";Object.defineProperty(hd,"__esModule",{value:!0});hd.finalize=void 0;var CU=L();function IU(t){return CU.operate(function(n,e){try{n.subscribe(e)}finally{e.add(t)}})}hd.finalize=IU});var pd=v(Bo=>{"use strict";Object.defineProperty(Bo,"__esModule",{value:!0});Bo.createFind=Bo.find=void 0;var TU=L(),xU=V();function DU(t,n){return TU.operate(_I(t,n,"value"))}Bo.find=DU;function _I(t,n,e){var r=e==="index";return function(i,o){var s=0;i.subscribe(xU.createOperatorSubscriber(o,function(a){var c=s++;t.call(n,a,c,i)&&(o.next(r?c:a),o.complete())},function(){o.next(r?-1:void 0),o.complete()}))}}Bo.createFind=_I});var qg=v(md=>{"use strict";Object.defineProperty(md,"__esModule",{value:!0});md.findIndex=void 0;var OU=L(),MU=pd();function AU(t,n){return OU.operate(MU.createFind(t,n,"index"))}md.findIndex=AU});var Bg=v(gd=>{"use strict";Object.defineProperty(gd,"__esModule",{value:!0});gd.first=void 0;var NU=pr(),PU=$n(),RU=$o(),kU=Fo(),LU=qo(),jU=ut();function FU(t,n){var e=arguments.length>=2;return function(r){return r.pipe(t?PU.filter(function(i,o){return t(i,o,r)}):jU.identity,RU.take(1),e?kU.defaultIfEmpty(n):LU.throwIfEmpty(function(){return new NU.EmptyError}))}}gd.first=FU});var Hg=v(yd=>{"use strict";Object.defineProperty(yd,"__esModule",{value:!0});yd.groupBy=void 0;var $U=je(),qU=se(),BU=lt(),HU=L(),bI=V();function UU(t,n,e,r){return HU.operate(function(i,o){var s;!n||typeof n=="function"?s=n:(e=n.duration,s=n.element,r=n.connector);var a=new Map,c=function(m){a.forEach(m),m(o)},u=function(m){return c(function(y){return y.error(m)})},l=0,d=!1,f=new bI.OperatorSubscriber(o,function(m){try{var y=t(m),b=a.get(y);if(!b){a.set(y,b=r?r():new BU.Subject);var E=p(y,b);if(o.next(E),e){var D=bI.createOperatorSubscriber(b,function(){b.complete(),D?.unsubscribe()},void 0,void 0,function(){return a.delete(y)});f.add(qU.innerFrom(e(E)).subscribe(D))}}b.next(s?s(m):m)}catch(T){u(T)}},function(){return c(function(m){return m.complete()})},u,function(){return a.clear()},function(){return d=!0,l===0});i.subscribe(f);function p(m,y){var b=new $U.Observable(function(E){l++;var D=y.subscribe(E);return function(){D.unsubscribe(),--l===0&&d&&f.unsubscribe()}});return b.key=m,b}})}yd.groupBy=UU});var Ug=v(vd=>{"use strict";Object.defineProperty(vd,"__esModule",{value:!0});vd.isEmpty=void 0;var VU=L(),WU=V();function GU(){return VU.operate(function(t,n){t.subscribe(WU.createOperatorSubscriber(n,function(){n.next(!1),n.complete()},function(){n.next(!0),n.complete()}))})}vd.isEmpty=GU});var _d=v(Ho=>{"use strict";var zU=Ho&&Ho.__values||function(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Ho,"__esModule",{value:!0});Ho.takeLast=void 0;var KU=on(),YU=L(),ZU=V();function QU(t){return t<=0?function(){return KU.EMPTY}:YU.operate(function(n,e){var r=[];n.subscribe(ZU.createOperatorSubscriber(e,function(i){r.push(i),t<r.length&&r.shift()},function(){var i,o;try{for(var s=zU(r),a=s.next();!a.done;a=s.next()){var c=a.value;e.next(c)}}catch(u){i={error:u}}finally{try{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}e.complete()},void 0,function(){r=null}))})}Ho.takeLast=QU});var Vg=v(bd=>{"use strict";Object.defineProperty(bd,"__esModule",{value:!0});bd.last=void 0;var JU=pr(),XU=$n(),eV=_d(),tV=qo(),nV=Fo(),rV=ut();function iV(t,n){var e=arguments.length>=2;return function(r){return r.pipe(t?XU.filter(function(i,o){return t(i,o,r)}):rV.identity,eV.takeLast(1),e?nV.defaultIfEmpty(n):tV.throwIfEmpty(function(){return new JU.EmptyError}))}}bd.last=iV});var Gg=v(wd=>{"use strict";Object.defineProperty(wd,"__esModule",{value:!0});wd.materialize=void 0;var Wg=ju(),oV=L(),sV=V();function aV(){return oV.operate(function(t,n){t.subscribe(sV.createOperatorSubscriber(n,function(e){n.next(Wg.Notification.createNext(e))},function(){n.next(Wg.Notification.createComplete()),n.complete()},function(e){n.next(Wg.Notification.createError(e)),n.complete()}))})}wd.materialize=aV});var zg=v(Ed=>{"use strict";Object.defineProperty(Ed,"__esModule",{value:!0});Ed.max=void 0;var cV=mi(),uV=ke();function lV(t){return cV.reduce(uV.isFunction(t)?function(n,e){return t(n,e)>0?n:e}:function(n,e){return n>e?n:e})}Ed.max=lV});var Kg=v(Sd=>{"use strict";Object.defineProperty(Sd,"__esModule",{value:!0});Sd.flatMap=void 0;var dV=_n();Sd.flatMap=dV.mergeMap});var Yg=v(Cd=>{"use strict";Object.defineProperty(Cd,"__esModule",{value:!0});Cd.mergeMapTo=void 0;var wI=_n(),fV=ke();function hV(t,n,e){return e===void 0&&(e=1/0),fV.isFunction(n)?wI.mergeMap(function(){return t},n,e):(typeof n=="number"&&(e=n),wI.mergeMap(function(){return t},e))}Cd.mergeMapTo=hV});var Zg=v(Id=>{"use strict";Object.defineProperty(Id,"__esModule",{value:!0});Id.mergeScan=void 0;var pV=L(),mV=el();function gV(t,n,e){return e===void 0&&(e=1/0),pV.operate(function(r,i){var o=n;return mV.mergeInternals(r,i,function(s,a){return t(o,s,a)},e,function(s){o=s},!1,void 0,function(){return o=null})})}Id.mergeScan=gV});var Qg=v(Ir=>{"use strict";var yV=Ir&&Ir.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},vV=Ir&&Ir.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Ir,"__esModule",{value:!0});Ir.merge=void 0;var _V=L(),bV=Ao(),EI=Tt(),wV=Ln();function EV(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=EI.popScheduler(t),r=EI.popNumber(t,1/0);return _V.operate(function(i,o){bV.mergeAll(r)(wV.from(vV([i],yV(t)),e)).subscribe(o)})}Ir.merge=EV});var Jg=v(Tr=>{"use strict";var SV=Tr&&Tr.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},CV=Tr&&Tr.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Tr,"__esModule",{value:!0});Tr.mergeWith=void 0;var IV=Qg();function TV(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return IV.merge.apply(void 0,CV([],SV(t)))}Tr.mergeWith=TV});var Xg=v(Td=>{"use strict";Object.defineProperty(Td,"__esModule",{value:!0});Td.min=void 0;var xV=mi(),DV=ke();function OV(t){return xV.reduce(DV.isFunction(t)?function(n,e){return t(n,e)<0?n:e}:function(n,e){return n<e?n:e})}Td.min=OV});var ga=v(xd=>{"use strict";Object.defineProperty(xd,"__esModule",{value:!0});xd.multicast=void 0;var MV=aa(),SI=ke(),AV=ma();function NV(t,n){var e=SI.isFunction(t)?t:function(){return t};return SI.isFunction(n)?AV.connect(n,{connector:e}):function(r){return new MV.ConnectableObservable(r,e)}}xd.multicast=NV});var ey=v(bn=>{"use strict";var PV=bn&&bn.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},RV=bn&&bn.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(bn,"__esModule",{value:!0});bn.onErrorResumeNext=bn.onErrorResumeNextWith=void 0;var kV=pi(),LV=ag();function CI(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=kV.argsOrArgArray(t);return function(r){return LV.onErrorResumeNext.apply(void 0,RV([r],PV(e)))}}bn.onErrorResumeNextWith=CI;bn.onErrorResumeNext=CI});var ty=v(Dd=>{"use strict";Object.defineProperty(Dd,"__esModule",{value:!0});Dd.pairwise=void 0;var jV=L(),FV=V();function $V(){return jV.operate(function(t,n){var e,r=!1;t.subscribe(FV.createOperatorSubscriber(n,function(i){var o=e;e=i,r&&n.next([o,i]),r=!0}))})}Dd.pairwise=$V});var ny=v(Od=>{"use strict";Object.defineProperty(Od,"__esModule",{value:!0});Od.pluck=void 0;var qV=Fn();function BV(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=t.length;if(e===0)throw new Error("list of properties cannot be empty.");return qV.map(function(r){for(var i=r,o=0;o<e;o++){var s=i?.[t[o]];if(typeof s<"u")i=s;else return}return i})}Od.pluck=BV});var ry=v(Md=>{"use strict";Object.defineProperty(Md,"__esModule",{value:!0});Md.publish=void 0;var HV=lt(),UV=ga(),VV=ma();function WV(t){return t?function(n){return VV.connect(t)(n)}:function(n){return UV.multicast(new HV.Subject)(n)}}Md.publish=WV});var iy=v(Ad=>{"use strict";Object.defineProperty(Ad,"__esModule",{value:!0});Ad.publishBehavior=void 0;var GV=Rm(),zV=aa();function KV(t){return function(n){var e=new GV.BehaviorSubject(t);return new zV.ConnectableObservable(n,function(){return e})}}Ad.publishBehavior=KV});var oy=v(Nd=>{"use strict";Object.defineProperty(Nd,"__esModule",{value:!0});Nd.publishLast=void 0;var YV=du(),ZV=aa();function QV(){return function(t){var n=new YV.AsyncSubject;return new ZV.ConnectableObservable(t,function(){return n})}}Nd.publishLast=QV});var sy=v(Pd=>{"use strict";Object.defineProperty(Pd,"__esModule",{value:!0});Pd.publishReplay=void 0;var JV=lu(),XV=ga(),II=ke();function e2(t,n,e,r){e&&!II.isFunction(e)&&(r=e);var i=II.isFunction(e)?e:void 0;return function(o){return XV.multicast(new JV.ReplaySubject(t,n,r),i)(o)}}Pd.publishReplay=e2});var Rd=v(xr=>{"use strict";var t2=xr&&xr.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},n2=xr&&xr.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(xr,"__esModule",{value:!0});xr.raceWith=void 0;var r2=ug(),i2=L(),o2=ut();function s2(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t.length?i2.operate(function(e,r){r2.raceInit(n2([e],t2(t)))(r)}):o2.identity}xr.raceWith=s2});var ay=v(kd=>{"use strict";Object.defineProperty(kd,"__esModule",{value:!0});kd.repeat=void 0;var a2=on(),c2=L(),TI=V(),u2=se(),l2=vr();function d2(t){var n,e=1/0,r;return t!=null&&(typeof t=="object"?(n=t.count,e=n===void 0?1/0:n,r=t.delay):e=t),e<=0?function(){return a2.EMPTY}:c2.operate(function(i,o){var s=0,a,c=function(){if(a?.unsubscribe(),a=null,r!=null){var l=typeof r=="number"?l2.timer(r):u2.innerFrom(r(s)),d=TI.createOperatorSubscriber(o,function(){d.unsubscribe(),u()});l.subscribe(d)}else u()},u=function(){var l=!1;a=i.subscribe(TI.createOperatorSubscriber(o,void 0,function(){++s<e?a?c():l=!0:o.complete()})),l&&c()};u()})}kd.repeat=d2});var cy=v(Ld=>{"use strict";Object.defineProperty(Ld,"__esModule",{value:!0});Ld.repeatWhen=void 0;var f2=se(),h2=lt(),p2=L(),xI=V();function m2(t){return p2.operate(function(n,e){var r,i=!1,o,s=!1,a=!1,c=function(){return a&&s&&(e.complete(),!0)},u=function(){return o||(o=new h2.Subject,f2.innerFrom(t(o)).subscribe(xI.createOperatorSubscriber(e,function(){r?l():i=!0},function(){s=!0,c()}))),o},l=function(){a=!1,r=n.subscribe(xI.createOperatorSubscriber(e,void 0,function(){a=!0,!c()&&u().next()})),i&&(r.unsubscribe(),r=null,i=!1,l())};l()})}Ld.repeatWhen=m2});var uy=v(jd=>{"use strict";Object.defineProperty(jd,"__esModule",{value:!0});jd.retry=void 0;var g2=L(),DI=V(),y2=ut(),v2=vr(),_2=se();function b2(t){t===void 0&&(t=1/0);var n;t&&typeof t=="object"?n=t:n={count:t};var e=n.count,r=e===void 0?1/0:e,i=n.delay,o=n.resetOnSuccess,s=o===void 0?!1:o;return r<=0?y2.identity:g2.operate(function(a,c){var u=0,l,d=function(){var f=!1;l=a.subscribe(DI.createOperatorSubscriber(c,function(p){s&&(u=0),c.next(p)},void 0,function(p){if(u++<r){var m=function(){l?(l.unsubscribe(),l=null,d()):f=!0};if(i!=null){var y=typeof i=="number"?v2.timer(i):_2.innerFrom(i(p,u)),b=DI.createOperatorSubscriber(c,function(){b.unsubscribe(),m()},function(){c.complete()});y.subscribe(b)}else m()}else c.error(p)})),f&&(l.unsubscribe(),l=null,d())};d()})}jd.retry=b2});var ly=v(Fd=>{"use strict";Object.defineProperty(Fd,"__esModule",{value:!0});Fd.retryWhen=void 0;var w2=se(),E2=lt(),S2=L(),OI=V();function C2(t){return S2.operate(function(n,e){var r,i=!1,o,s=function(){r=n.subscribe(OI.createOperatorSubscriber(e,void 0,void 0,function(a){o||(o=new E2.Subject,w2.innerFrom(t(o)).subscribe(OI.createOperatorSubscriber(e,function(){return r?s():i=!0}))),o&&o.next(a)})),i&&(r.unsubscribe(),r=null,i=!1,s())};s()})}Fd.retryWhen=C2});var qd=v($d=>{"use strict";Object.defineProperty($d,"__esModule",{value:!0});$d.sample=void 0;var I2=se(),T2=L(),x2=ct(),MI=V();function D2(t){return T2.operate(function(n,e){var r=!1,i=null;n.subscribe(MI.createOperatorSubscriber(e,function(o){r=!0,i=o})),I2.innerFrom(t).subscribe(MI.createOperatorSubscriber(e,function(){if(r){r=!1;var o=i;i=null,e.next(o)}},x2.noop))})}$d.sample=D2});var dy=v(Bd=>{"use strict";Object.defineProperty(Bd,"__esModule",{value:!0});Bd.sampleTime=void 0;var O2=It(),M2=qd(),A2=og();function N2(t,n){return n===void 0&&(n=O2.asyncScheduler),M2.sample(A2.interval(t,n))}Bd.sampleTime=N2});var fy=v(Hd=>{"use strict";Object.defineProperty(Hd,"__esModule",{value:!0});Hd.scan=void 0;var P2=L(),R2=_g();function k2(t,n){return P2.operate(R2.scanInternals(t,n,arguments.length>=2,!0))}Hd.scan=k2});var hy=v(Ud=>{"use strict";Object.defineProperty(Ud,"__esModule",{value:!0});Ud.sequenceEqual=void 0;var L2=L(),j2=V(),F2=se();function $2(t,n){return n===void 0&&(n=function(e,r){return e===r}),L2.operate(function(e,r){var i=AI(),o=AI(),s=function(c){r.next(c),r.complete()},a=function(c,u){var l=j2.createOperatorSubscriber(r,function(d){var f=u.buffer,p=u.complete;f.length===0?p?s(!1):c.buffer.push(d):!n(d,f.shift())&&s(!1)},function(){c.complete=!0;var d=u.complete,f=u.buffer;d&&s(f.length===0),l?.unsubscribe()});return l};e.subscribe(a(i,o)),F2.innerFrom(t).subscribe(a(o,i))})}Ud.sequenceEqual=$2;function AI(){return{buffer:[],complete:!1}}});var Vd=v(Dr=>{"use strict";var q2=Dr&&Dr.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},B2=Dr&&Dr.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Dr,"__esModule",{value:!0});Dr.share=void 0;var NI=se(),H2=lt(),PI=oo(),U2=L();function V2(t){t===void 0&&(t={});var n=t.connector,e=n===void 0?function(){return new H2.Subject}:n,r=t.resetOnError,i=r===void 0?!0:r,o=t.resetOnComplete,s=o===void 0?!0:o,a=t.resetOnRefCountZero,c=a===void 0?!0:a;return function(u){var l,d,f,p=0,m=!1,y=!1,b=function(){d?.unsubscribe(),d=void 0},E=function(){b(),l=f=void 0,m=y=!1},D=function(){var T=l;E(),T?.unsubscribe()};return U2.operate(function(T,K){p++,!y&&!m&&b();var H=f=f??e();K.add(function(){p--,p===0&&!y&&!m&&(d=py(D,c))}),H.subscribe(K),!l&&p>0&&(l=new PI.SafeSubscriber({next:function(re){return H.next(re)},error:function(re){y=!0,b(),d=py(E,i,re),H.error(re)},complete:function(){m=!0,b(),d=py(E,s),H.complete()}}),NI.innerFrom(T).subscribe(l))})(u)}}Dr.share=V2;function py(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];if(n===!0){t();return}if(n!==!1){var i=new PI.SafeSubscriber({next:function(){i.unsubscribe(),t()}});return NI.innerFrom(n.apply(void 0,B2([],q2(e)))).subscribe(i)}}});var my=v(Wd=>{"use strict";Object.defineProperty(Wd,"__esModule",{value:!0});Wd.shareReplay=void 0;var W2=lu(),G2=Vd();function z2(t,n,e){var r,i,o,s,a=!1;return t&&typeof t=="object"?(r=t.bufferSize,s=r===void 0?1/0:r,i=t.windowTime,n=i===void 0?1/0:i,o=t.refCount,a=o===void 0?!1:o,e=t.scheduler):s=t??1/0,G2.share({connector:function(){return new W2.ReplaySubject(s,n,e)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:a})}Wd.shareReplay=z2});var gy=v(Gd=>{"use strict";Object.defineProperty(Gd,"__esModule",{value:!0});Gd.single=void 0;var K2=pr(),Y2=Xm(),Z2=Jm(),Q2=L(),J2=V();function X2(t){return Q2.operate(function(n,e){var r=!1,i,o=!1,s=0;n.subscribe(J2.createOperatorSubscriber(e,function(a){o=!0,(!t||t(a,s++,n))&&(r&&e.error(new Y2.SequenceError("Too many matching values")),r=!0,i=a)},function(){r?(e.next(i),e.complete()):e.error(o?new Z2.NotFoundError("No matching values"):new K2.EmptyError)}))})}Gd.single=X2});var yy=v(zd=>{"use strict";Object.defineProperty(zd,"__esModule",{value:!0});zd.skip=void 0;var eW=$n();function tW(t){return eW.filter(function(n,e){return t<=e})}zd.skip=tW});var vy=v(Kd=>{"use strict";Object.defineProperty(Kd,"__esModule",{value:!0});Kd.skipLast=void 0;var nW=ut(),rW=L(),iW=V();function oW(t){return t<=0?nW.identity:rW.operate(function(n,e){var r=new Array(t),i=0;return n.subscribe(iW.createOperatorSubscriber(e,function(o){var s=i++;if(s<t)r[s]=o;else{var a=s%t,c=r[a];r[a]=o,e.next(c)}})),function(){r=null}})}Kd.skipLast=oW});var _y=v(Yd=>{"use strict";Object.defineProperty(Yd,"__esModule",{value:!0});Yd.skipUntil=void 0;var sW=L(),RI=V(),aW=se(),cW=ct();function uW(t){return sW.operate(function(n,e){var r=!1,i=RI.createOperatorSubscriber(e,function(){i?.unsubscribe(),r=!0},cW.noop);aW.innerFrom(t).subscribe(i),n.subscribe(RI.createOperatorSubscriber(e,function(o){return r&&e.next(o)}))})}Yd.skipUntil=uW});var by=v(Zd=>{"use strict";Object.defineProperty(Zd,"__esModule",{value:!0});Zd.skipWhile=void 0;var lW=L(),dW=V();function fW(t){return lW.operate(function(n,e){var r=!1,i=0;n.subscribe(dW.createOperatorSubscriber(e,function(o){return(r||(r=!t(o,i++)))&&e.next(o)}))})}Zd.skipWhile=fW});var wy=v(Qd=>{"use strict";Object.defineProperty(Qd,"__esModule",{value:!0});Qd.startWith=void 0;var kI=ha(),hW=Tt(),pW=L();function mW(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=hW.popScheduler(t);return pW.operate(function(r,i){(e?kI.concat(t,r,e):kI.concat(t,r)).subscribe(i)})}Qd.startWith=mW});var Uo=v(Jd=>{"use strict";Object.defineProperty(Jd,"__esModule",{value:!0});Jd.switchMap=void 0;var gW=se(),yW=L(),LI=V();function vW(t,n){return yW.operate(function(e,r){var i=null,o=0,s=!1,a=function(){return s&&!i&&r.complete()};e.subscribe(LI.createOperatorSubscriber(r,function(c){i?.unsubscribe();var u=0,l=o++;gW.innerFrom(t(c,l)).subscribe(i=LI.createOperatorSubscriber(r,function(d){return r.next(n?n(c,d,l,u++):d)},function(){i=null,a()}))},function(){s=!0,a()}))})}Jd.switchMap=vW});var Ey=v(Xd=>{"use strict";Object.defineProperty(Xd,"__esModule",{value:!0});Xd.switchAll=void 0;var _W=Uo(),bW=ut();function wW(){return _W.switchMap(bW.identity)}Xd.switchAll=wW});var Sy=v(ef=>{"use strict";Object.defineProperty(ef,"__esModule",{value:!0});ef.switchMapTo=void 0;var jI=Uo(),EW=ke();function SW(t,n){return EW.isFunction(n)?jI.switchMap(function(){return t},n):jI.switchMap(function(){return t})}ef.switchMapTo=SW});var Cy=v(tf=>{"use strict";Object.defineProperty(tf,"__esModule",{value:!0});tf.switchScan=void 0;var CW=Uo(),IW=L();function TW(t,n){return IW.operate(function(e,r){var i=n;return CW.switchMap(function(o,s){return t(i,o,s)},function(o,s){return i=s,s})(e).subscribe(r),function(){i=null}})}tf.switchScan=TW});var Iy=v(nf=>{"use strict";Object.defineProperty(nf,"__esModule",{value:!0});nf.takeUntil=void 0;var xW=L(),DW=V(),OW=se(),MW=ct();function AW(t){return xW.operate(function(n,e){OW.innerFrom(t).subscribe(DW.createOperatorSubscriber(e,function(){return e.complete()},MW.noop)),!e.closed&&n.subscribe(e)})}nf.takeUntil=AW});var Ty=v(rf=>{"use strict";Object.defineProperty(rf,"__esModule",{value:!0});rf.takeWhile=void 0;var NW=L(),PW=V();function RW(t,n){return n===void 0&&(n=!1),NW.operate(function(e,r){var i=0;e.subscribe(PW.createOperatorSubscriber(r,function(o){var s=t(o,i++);(s||n)&&r.next(o),!s&&r.complete()}))})}rf.takeWhile=RW});var xy=v(of=>{"use strict";Object.defineProperty(of,"__esModule",{value:!0});of.tap=void 0;var kW=ke(),LW=L(),jW=V(),FW=ut();function $W(t,n,e){var r=kW.isFunction(t)||n||e?{next:t,error:n,complete:e}:t;return r?LW.operate(function(i,o){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var a=!0;i.subscribe(jW.createOperatorSubscriber(o,function(c){var u;(u=r.next)===null||u===void 0||u.call(r,c),o.next(c)},function(){var c;a=!1,(c=r.complete)===null||c===void 0||c.call(r),o.complete()},function(c){var u;a=!1,(u=r.error)===null||u===void 0||u.call(r,c),o.error(c)},function(){var c,u;a&&((c=r.unsubscribe)===null||c===void 0||c.call(r)),(u=r.finalize)===null||u===void 0||u.call(r)}))}):FW.identity}of.tap=$W});var af=v(sf=>{"use strict";Object.defineProperty(sf,"__esModule",{value:!0});sf.throttle=void 0;var qW=L(),FI=V(),BW=se();function HW(t,n){return qW.operate(function(e,r){var i=n??{},o=i.leading,s=o===void 0?!0:o,a=i.trailing,c=a===void 0?!1:a,u=!1,l=null,d=null,f=!1,p=function(){d?.unsubscribe(),d=null,c&&(b(),f&&r.complete())},m=function(){d=null,f&&r.complete()},y=function(E){return d=BW.innerFrom(t(E)).subscribe(FI.createOperatorSubscriber(r,p,m))},b=function(){if(u){u=!1;var E=l;l=null,r.next(E),!f&&y(E)}};e.subscribe(FI.createOperatorSubscriber(r,function(E){u=!0,l=E,!(d&&!d.closed)&&(s?b():y(E))},function(){f=!0,!(c&&u&&d&&!d.closed)&&r.complete()}))})}sf.throttle=HW});var Dy=v(cf=>{"use strict";Object.defineProperty(cf,"__esModule",{value:!0});cf.throttleTime=void 0;var UW=It(),VW=af(),WW=vr();function GW(t,n,e){n===void 0&&(n=UW.asyncScheduler);var r=WW.timer(t,n);return VW.throttle(function(){return r},e)}cf.throttleTime=GW});var Oy=v(Vo=>{"use strict";Object.defineProperty(Vo,"__esModule",{value:!0});Vo.TimeInterval=Vo.timeInterval=void 0;var zW=It(),KW=L(),YW=V();function ZW(t){return t===void 0&&(t=zW.asyncScheduler),KW.operate(function(n,e){var r=t.now();n.subscribe(YW.createOperatorSubscriber(e,function(i){var o=t.now(),s=o-r;r=o,e.next(new $I(i,s))}))})}Vo.timeInterval=ZW;var $I=(function(){function t(n,e){this.value=n,this.interval=e}return t})();Vo.TimeInterval=$I});var My=v(uf=>{"use strict";Object.defineProperty(uf,"__esModule",{value:!0});uf.timeoutWith=void 0;var QW=It(),JW=Gu(),XW=da();function eG(t,n,e){var r,i,o;if(e=e??QW.async,JW.isValidDate(t)?r=t:typeof t=="number"&&(i=t),n)o=function(){return n};else throw new TypeError("No observable provided to switch to");if(r==null&&i==null)throw new TypeError("No timeout provided.");return XW.timeout({first:r,each:i,scheduler:e,with:o})}uf.timeoutWith=eG});var Ay=v(lf=>{"use strict";Object.defineProperty(lf,"__esModule",{value:!0});lf.timestamp=void 0;var tG=uu(),nG=Fn();function rG(t){return t===void 0&&(t=tG.dateTimestampProvider),nG.map(function(n){return{value:n,timestamp:t.now()}})}lf.timestamp=rG});var Ny=v(df=>{"use strict";Object.defineProperty(df,"__esModule",{value:!0});df.window=void 0;var qI=lt(),iG=L(),BI=V(),oG=ct(),sG=se();function aG(t){return iG.operate(function(n,e){var r=new qI.Subject;e.next(r.asObservable());var i=function(o){r.error(o),e.error(o)};return n.subscribe(BI.createOperatorSubscriber(e,function(o){return r?.next(o)},function(){r.complete(),e.complete()},i)),sG.innerFrom(t).subscribe(BI.createOperatorSubscriber(e,function(){r.complete(),e.next(r=new qI.Subject)},oG.noop,i)),function(){r?.unsubscribe(),r=null}})}df.window=aG});var Py=v(Wo=>{"use strict";var cG=Wo&&Wo.__values||function(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Wo,"__esModule",{value:!0});Wo.windowCount=void 0;var HI=lt(),uG=L(),lG=V();function dG(t,n){n===void 0&&(n=0);var e=n>0?n:t;return uG.operate(function(r,i){var o=[new HI.Subject],s=[],a=0;i.next(o[0].asObservable()),r.subscribe(lG.createOperatorSubscriber(i,function(c){var u,l;try{for(var d=cG(o),f=d.next();!f.done;f=d.next()){var p=f.value;p.next(c)}}catch(b){u={error:b}}finally{try{f&&!f.done&&(l=d.return)&&l.call(d)}finally{if(u)throw u.error}}var m=a-t+1;if(m>=0&&m%e===0&&o.shift().complete(),++a%e===0){var y=new HI.Subject;o.push(y),i.next(y.asObservable())}},function(){for(;o.length>0;)o.shift().complete();i.complete()},function(c){for(;o.length>0;)o.shift().error(c);i.error(c)},function(){s=null,o=null}))})}Wo.windowCount=dG});var Ry=v(ff=>{"use strict";Object.defineProperty(ff,"__esModule",{value:!0});ff.windowTime=void 0;var fG=lt(),hG=It(),pG=Lt(),mG=L(),gG=V(),yG=Rn(),vG=Tt(),UI=kn();function _G(t){for(var n,e,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];var o=(n=vG.popScheduler(r))!==null&&n!==void 0?n:hG.asyncScheduler,s=(e=r[0])!==null&&e!==void 0?e:null,a=r[1]||1/0;return mG.operate(function(c,u){var l=[],d=!1,f=function(b){var E=b.window,D=b.subs;E.complete(),D.unsubscribe(),yG.arrRemove(l,b),d&&p()},p=function(){if(l){var b=new pG.Subscription;u.add(b);var E=new fG.Subject,D={window:E,subs:b,seen:0};l.push(D),u.next(E.asObservable()),UI.executeSchedule(b,o,function(){return f(D)},t)}};s!==null&&s>=0?UI.executeSchedule(u,o,p,s,!0):d=!0,p();var m=function(b){return l.slice().forEach(b)},y=function(b){m(function(E){var D=E.window;return b(D)}),b(u),u.unsubscribe()};return c.subscribe(gG.createOperatorSubscriber(u,function(b){m(function(E){E.window.next(b),a<=++E.seen&&f(E)})},function(){return y(function(b){return b.complete()})},function(b){return y(function(E){return E.error(b)})})),function(){l=null}})}ff.windowTime=_G});var Ly=v(Go=>{"use strict";var bG=Go&&Go.__values||function(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Go,"__esModule",{value:!0});Go.windowToggle=void 0;var wG=lt(),EG=Lt(),SG=L(),VI=se(),ky=V(),WI=ct(),CG=Rn();function IG(t,n){return SG.operate(function(e,r){var i=[],o=function(s){for(;0<i.length;)i.shift().error(s);r.error(s)};VI.innerFrom(t).subscribe(ky.createOperatorSubscriber(r,function(s){var a=new wG.Subject;i.push(a);var c=new EG.Subscription,u=function(){CG.arrRemove(i,a),a.complete(),c.unsubscribe()},l;try{l=VI.innerFrom(n(s))}catch(d){o(d);return}r.next(a.asObservable()),c.add(l.subscribe(ky.createOperatorSubscriber(r,u,WI.noop,o)))},WI.noop)),e.subscribe(ky.createOperatorSubscriber(r,function(s){var a,c,u=i.slice();try{for(var l=bG(u),d=l.next();!d.done;d=l.next()){var f=d.value;f.next(s)}}catch(p){a={error:p}}finally{try{d&&!d.done&&(c=l.return)&&c.call(l)}finally{if(a)throw a.error}}},function(){for(;0<i.length;)i.shift().complete();r.complete()},o,function(){for(;0<i.length;)i.shift().unsubscribe()}))})}Go.windowToggle=IG});var jy=v(hf=>{"use strict";Object.defineProperty(hf,"__esModule",{value:!0});hf.windowWhen=void 0;var TG=lt(),xG=L(),GI=V(),DG=se();function OG(t){return xG.operate(function(n,e){var r,i,o=function(a){r.error(a),e.error(a)},s=function(){i?.unsubscribe(),r?.complete(),r=new TG.Subject,e.next(r.asObservable());var a;try{a=DG.innerFrom(t())}catch(c){o(c);return}a.subscribe(i=GI.createOperatorSubscriber(e,s,s,o))};s(),n.subscribe(GI.createOperatorSubscriber(e,function(a){return r.next(a)},function(){r.complete(),e.complete()},o,function(){i?.unsubscribe(),r=null}))})}hf.windowWhen=OG});var Fy=v(Or=>{"use strict";var zI=Or&&Or.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},KI=Or&&Or.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Or,"__esModule",{value:!0});Or.withLatestFrom=void 0;var MG=L(),YI=V(),AG=se(),NG=ut(),PG=ct(),RG=Tt();function kG(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=RG.popResultSelector(t);return MG.operate(function(r,i){for(var o=t.length,s=new Array(o),a=t.map(function(){return!1}),c=!1,u=function(d){AG.innerFrom(t[d]).subscribe(YI.createOperatorSubscriber(i,function(f){s[d]=f,!c&&!a[d]&&(a[d]=!0,(c=a.every(NG.identity))&&(a=null))},PG.noop))},l=0;l<o;l++)u(l);r.subscribe(YI.createOperatorSubscriber(i,function(d){if(c){var f=KI([d],zI(s));i.next(e?e.apply(void 0,KI([],zI(f))):f)}}))})}Or.withLatestFrom=kG});var $y=v(pf=>{"use strict";Object.defineProperty(pf,"__esModule",{value:!0});pf.zipAll=void 0;var LG=wl(),jG=bg();function FG(t){return jG.joinAllInternals(LG.zip,t)}pf.zipAll=FG});var qy=v(Mr=>{"use strict";var $G=Mr&&Mr.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},qG=Mr&&Mr.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Mr,"__esModule",{value:!0});Mr.zip=void 0;var BG=wl(),HG=L();function UG(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return HG.operate(function(e,r){BG.zip.apply(void 0,qG([e],$G(t))).subscribe(r)})}Mr.zip=UG});var By=v(Ar=>{"use strict";var VG=Ar&&Ar.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},WG=Ar&&Ar.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Ar,"__esModule",{value:!0});Ar.zipWith=void 0;var GG=qy();function zG(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return GG.zip.apply(void 0,WG([],VG(t)))}Ar.zipWith=zG});var Q=v(h=>{"use strict";var KG=h&&h.__createBinding||(Object.create?function(t,n,e,r){r===void 0&&(r=e),Object.defineProperty(t,r,{enumerable:!0,get:function(){return n[e]}})}:function(t,n,e,r){r===void 0&&(r=e),t[r]=n[e]}),YG=h&&h.__exportStar||function(t,n){for(var e in t)e!=="default"&&!Object.prototype.hasOwnProperty.call(n,e)&&KG(n,t,e)};Object.defineProperty(h,"__esModule",{value:!0});h.interval=h.iif=h.generate=h.fromEventPattern=h.fromEvent=h.from=h.forkJoin=h.empty=h.defer=h.connectable=h.concat=h.combineLatest=h.bindNodeCallback=h.bindCallback=h.UnsubscriptionError=h.TimeoutError=h.SequenceError=h.ObjectUnsubscribedError=h.NotFoundError=h.EmptyError=h.ArgumentOutOfRangeError=h.firstValueFrom=h.lastValueFrom=h.isObservable=h.identity=h.noop=h.pipe=h.NotificationKind=h.Notification=h.Subscriber=h.Subscription=h.Scheduler=h.VirtualAction=h.VirtualTimeScheduler=h.animationFrameScheduler=h.animationFrame=h.queueScheduler=h.queue=h.asyncScheduler=h.async=h.asapScheduler=h.asap=h.AsyncSubject=h.ReplaySubject=h.BehaviorSubject=h.Subject=h.animationFrames=h.observable=h.ConnectableObservable=h.Observable=void 0;h.filter=h.expand=h.exhaustMap=h.exhaustAll=h.exhaust=h.every=h.endWith=h.elementAt=h.distinctUntilKeyChanged=h.distinctUntilChanged=h.distinct=h.dematerialize=h.delayWhen=h.delay=h.defaultIfEmpty=h.debounceTime=h.debounce=h.count=h.connect=h.concatWith=h.concatMapTo=h.concatMap=h.concatAll=h.combineLatestWith=h.combineLatestAll=h.combineAll=h.catchError=h.bufferWhen=h.bufferToggle=h.bufferTime=h.bufferCount=h.buffer=h.auditTime=h.audit=h.config=h.NEVER=h.EMPTY=h.scheduled=h.zip=h.using=h.timer=h.throwError=h.range=h.race=h.partition=h.pairs=h.onErrorResumeNext=h.of=h.never=h.merge=void 0;h.switchMap=h.switchAll=h.subscribeOn=h.startWith=h.skipWhile=h.skipUntil=h.skipLast=h.skip=h.single=h.shareReplay=h.share=h.sequenceEqual=h.scan=h.sampleTime=h.sample=h.refCount=h.retryWhen=h.retry=h.repeatWhen=h.repeat=h.reduce=h.raceWith=h.publishReplay=h.publishLast=h.publishBehavior=h.publish=h.pluck=h.pairwise=h.onErrorResumeNextWith=h.observeOn=h.multicast=h.min=h.mergeWith=h.mergeScan=h.mergeMapTo=h.mergeMap=h.flatMap=h.mergeAll=h.max=h.materialize=h.mapTo=h.map=h.last=h.isEmpty=h.ignoreElements=h.groupBy=h.first=h.findIndex=h.find=h.finalize=void 0;h.zipWith=h.zipAll=h.withLatestFrom=h.windowWhen=h.windowToggle=h.windowTime=h.windowCount=h.window=h.toArray=h.timestamp=h.timeoutWith=h.timeout=h.timeInterval=h.throwIfEmpty=h.throttleTime=h.throttle=h.tap=h.takeWhile=h.takeUntil=h.takeLast=h.take=h.switchScan=h.switchMapTo=void 0;var ZG=je();Object.defineProperty(h,"Observable",{enumerable:!0,get:function(){return ZG.Observable}});var QG=aa();Object.defineProperty(h,"ConnectableObservable",{enumerable:!0,get:function(){return QG.ConnectableObservable}});var JG=oa();Object.defineProperty(h,"observable",{enumerable:!0,get:function(){return JG.observable}});var XG=xS();Object.defineProperty(h,"animationFrames",{enumerable:!0,get:function(){return XG.animationFrames}});var e4=lt();Object.defineProperty(h,"Subject",{enumerable:!0,get:function(){return e4.Subject}});var t4=Rm();Object.defineProperty(h,"BehaviorSubject",{enumerable:!0,get:function(){return t4.BehaviorSubject}});var n4=lu();Object.defineProperty(h,"ReplaySubject",{enumerable:!0,get:function(){return n4.ReplaySubject}});var r4=du();Object.defineProperty(h,"AsyncSubject",{enumerable:!0,get:function(){return r4.AsyncSubject}});var ZI=VS();Object.defineProperty(h,"asap",{enumerable:!0,get:function(){return ZI.asap}});Object.defineProperty(h,"asapScheduler",{enumerable:!0,get:function(){return ZI.asapScheduler}});var QI=It();Object.defineProperty(h,"async",{enumerable:!0,get:function(){return QI.async}});Object.defineProperty(h,"asyncScheduler",{enumerable:!0,get:function(){return QI.asyncScheduler}});var JI=zS();Object.defineProperty(h,"queue",{enumerable:!0,get:function(){return JI.queue}});Object.defineProperty(h,"queueScheduler",{enumerable:!0,get:function(){return JI.queueScheduler}});var XI=QS();Object.defineProperty(h,"animationFrame",{enumerable:!0,get:function(){return XI.animationFrame}});Object.defineProperty(h,"animationFrameScheduler",{enumerable:!0,get:function(){return XI.animationFrameScheduler}});var eT=eC();Object.defineProperty(h,"VirtualTimeScheduler",{enumerable:!0,get:function(){return eT.VirtualTimeScheduler}});Object.defineProperty(h,"VirtualAction",{enumerable:!0,get:function(){return eT.VirtualAction}});var i4=Lm();Object.defineProperty(h,"Scheduler",{enumerable:!0,get:function(){return i4.Scheduler}});var o4=Lt();Object.defineProperty(h,"Subscription",{enumerable:!0,get:function(){return o4.Subscription}});var s4=oo();Object.defineProperty(h,"Subscriber",{enumerable:!0,get:function(){return s4.Subscriber}});var tT=ju();Object.defineProperty(h,"Notification",{enumerable:!0,get:function(){return tT.Notification}});Object.defineProperty(h,"NotificationKind",{enumerable:!0,get:function(){return tT.NotificationKind}});var a4=sa();Object.defineProperty(h,"pipe",{enumerable:!0,get:function(){return a4.pipe}});var c4=ct();Object.defineProperty(h,"noop",{enumerable:!0,get:function(){return c4.noop}});var u4=ut();Object.defineProperty(h,"identity",{enumerable:!0,get:function(){return u4.identity}});var l4=yC();Object.defineProperty(h,"isObservable",{enumerable:!0,get:function(){return l4.isObservable}});var d4=vC();Object.defineProperty(h,"lastValueFrom",{enumerable:!0,get:function(){return d4.lastValueFrom}});var f4=_C();Object.defineProperty(h,"firstValueFrom",{enumerable:!0,get:function(){return f4.firstValueFrom}});var h4=Qm();Object.defineProperty(h,"ArgumentOutOfRangeError",{enumerable:!0,get:function(){return h4.ArgumentOutOfRangeError}});var p4=pr();Object.defineProperty(h,"EmptyError",{enumerable:!0,get:function(){return p4.EmptyError}});var m4=Jm();Object.defineProperty(h,"NotFoundError",{enumerable:!0,get:function(){return m4.NotFoundError}});var g4=Mm();Object.defineProperty(h,"ObjectUnsubscribedError",{enumerable:!0,get:function(){return g4.ObjectUnsubscribedError}});var y4=Xm();Object.defineProperty(h,"SequenceError",{enumerable:!0,get:function(){return y4.SequenceError}});var v4=da();Object.defineProperty(h,"TimeoutError",{enumerable:!0,get:function(){return v4.TimeoutError}});var _4=vm();Object.defineProperty(h,"UnsubscriptionError",{enumerable:!0,get:function(){return _4.UnsubscriptionError}});var b4=wC();Object.defineProperty(h,"bindCallback",{enumerable:!0,get:function(){return b4.bindCallback}});var w4=EC();Object.defineProperty(h,"bindNodeCallback",{enumerable:!0,get:function(){return w4.bindNodeCallback}});var E4=Ju();Object.defineProperty(h,"combineLatest",{enumerable:!0,get:function(){return E4.combineLatest}});var S4=ha();Object.defineProperty(h,"concat",{enumerable:!0,get:function(){return S4.concat}});var C4=MC();Object.defineProperty(h,"connectable",{enumerable:!0,get:function(){return C4.connectable}});var I4=pa();Object.defineProperty(h,"defer",{enumerable:!0,get:function(){return I4.defer}});var T4=on();Object.defineProperty(h,"empty",{enumerable:!0,get:function(){return T4.empty}});var x4=AC();Object.defineProperty(h,"forkJoin",{enumerable:!0,get:function(){return x4.forkJoin}});var D4=Ln();Object.defineProperty(h,"from",{enumerable:!0,get:function(){return D4.from}});var O4=PC();Object.defineProperty(h,"fromEvent",{enumerable:!0,get:function(){return O4.fromEvent}});var M4=kC();Object.defineProperty(h,"fromEventPattern",{enumerable:!0,get:function(){return M4.fromEventPattern}});var A4=jC();Object.defineProperty(h,"generate",{enumerable:!0,get:function(){return A4.generate}});var N4=FC();Object.defineProperty(h,"iif",{enumerable:!0,get:function(){return N4.iif}});var P4=og();Object.defineProperty(h,"interval",{enumerable:!0,get:function(){return P4.interval}});var R4=qC();Object.defineProperty(h,"merge",{enumerable:!0,get:function(){return R4.merge}});var k4=sg();Object.defineProperty(h,"never",{enumerable:!0,get:function(){return k4.never}});var L4=ku();Object.defineProperty(h,"of",{enumerable:!0,get:function(){return L4.of}});var j4=ag();Object.defineProperty(h,"onErrorResumeNext",{enumerable:!0,get:function(){return j4.onErrorResumeNext}});var F4=HC();Object.defineProperty(h,"pairs",{enumerable:!0,get:function(){return F4.pairs}});var $4=WC();Object.defineProperty(h,"partition",{enumerable:!0,get:function(){return $4.partition}});var q4=ug();Object.defineProperty(h,"race",{enumerable:!0,get:function(){return q4.race}});var B4=KC();Object.defineProperty(h,"range",{enumerable:!0,get:function(){return B4.range}});var H4=Zm();Object.defineProperty(h,"throwError",{enumerable:!0,get:function(){return H4.throwError}});var U4=vr();Object.defineProperty(h,"timer",{enumerable:!0,get:function(){return U4.timer}});var V4=YC();Object.defineProperty(h,"using",{enumerable:!0,get:function(){return V4.using}});var W4=wl();Object.defineProperty(h,"zip",{enumerable:!0,get:function(){return W4.zip}});var G4=Ym();Object.defineProperty(h,"scheduled",{enumerable:!0,get:function(){return G4.scheduled}});var z4=on();Object.defineProperty(h,"EMPTY",{enumerable:!0,get:function(){return z4.EMPTY}});var K4=sg();Object.defineProperty(h,"NEVER",{enumerable:!0,get:function(){return K4.NEVER}});YG(QC(),h);var Y4=ro();Object.defineProperty(h,"config",{enumerable:!0,get:function(){return Y4.config}});var Z4=Sl();Object.defineProperty(h,"audit",{enumerable:!0,get:function(){return Z4.audit}});var Q4=lg();Object.defineProperty(h,"auditTime",{enumerable:!0,get:function(){return Q4.auditTime}});var J4=dg();Object.defineProperty(h,"buffer",{enumerable:!0,get:function(){return J4.buffer}});var X4=hg();Object.defineProperty(h,"bufferCount",{enumerable:!0,get:function(){return X4.bufferCount}});var e3=pg();Object.defineProperty(h,"bufferTime",{enumerable:!0,get:function(){return e3.bufferTime}});var t3=gg();Object.defineProperty(h,"bufferToggle",{enumerable:!0,get:function(){return t3.bufferToggle}});var n3=yg();Object.defineProperty(h,"bufferWhen",{enumerable:!0,get:function(){return n3.bufferWhen}});var r3=vg();Object.defineProperty(h,"catchError",{enumerable:!0,get:function(){return r3.catchError}});var i3=wg();Object.defineProperty(h,"combineAll",{enumerable:!0,get:function(){return i3.combineAll}});var o3=Rl();Object.defineProperty(h,"combineLatestAll",{enumerable:!0,get:function(){return o3.combineLatestAll}});var s3=Sg();Object.defineProperty(h,"combineLatestWith",{enumerable:!0,get:function(){return s3.combineLatestWith}});var a3=fa();Object.defineProperty(h,"concatAll",{enumerable:!0,get:function(){return a3.concatAll}});var c3=jl();Object.defineProperty(h,"concatMap",{enumerable:!0,get:function(){return c3.concatMap}});var u3=Cg();Object.defineProperty(h,"concatMapTo",{enumerable:!0,get:function(){return u3.concatMapTo}});var l3=Tg();Object.defineProperty(h,"concatWith",{enumerable:!0,get:function(){return l3.concatWith}});var d3=ma();Object.defineProperty(h,"connect",{enumerable:!0,get:function(){return d3.connect}});var f3=xg();Object.defineProperty(h,"count",{enumerable:!0,get:function(){return f3.count}});var h3=Dg();Object.defineProperty(h,"debounce",{enumerable:!0,get:function(){return h3.debounce}});var p3=Og();Object.defineProperty(h,"debounceTime",{enumerable:!0,get:function(){return p3.debounceTime}});var m3=Fo();Object.defineProperty(h,"defaultIfEmpty",{enumerable:!0,get:function(){return m3.defaultIfEmpty}});var g3=Mg();Object.defineProperty(h,"delay",{enumerable:!0,get:function(){return g3.delay}});var y3=Ql();Object.defineProperty(h,"delayWhen",{enumerable:!0,get:function(){return y3.delayWhen}});var v3=Ag();Object.defineProperty(h,"dematerialize",{enumerable:!0,get:function(){return v3.dematerialize}});var _3=Ng();Object.defineProperty(h,"distinct",{enumerable:!0,get:function(){return _3.distinct}});var b3=nd();Object.defineProperty(h,"distinctUntilChanged",{enumerable:!0,get:function(){return b3.distinctUntilChanged}});var w3=Pg();Object.defineProperty(h,"distinctUntilKeyChanged",{enumerable:!0,get:function(){return w3.distinctUntilKeyChanged}});var E3=Rg();Object.defineProperty(h,"elementAt",{enumerable:!0,get:function(){return E3.elementAt}});var S3=kg();Object.defineProperty(h,"endWith",{enumerable:!0,get:function(){return S3.endWith}});var C3=Lg();Object.defineProperty(h,"every",{enumerable:!0,get:function(){return C3.every}});var I3=jg();Object.defineProperty(h,"exhaust",{enumerable:!0,get:function(){return I3.exhaust}});var T3=ld();Object.defineProperty(h,"exhaustAll",{enumerable:!0,get:function(){return T3.exhaustAll}});var x3=cd();Object.defineProperty(h,"exhaustMap",{enumerable:!0,get:function(){return x3.exhaustMap}});var D3=Fg();Object.defineProperty(h,"expand",{enumerable:!0,get:function(){return D3.expand}});var O3=$n();Object.defineProperty(h,"filter",{enumerable:!0,get:function(){return O3.filter}});var M3=$g();Object.defineProperty(h,"finalize",{enumerable:!0,get:function(){return M3.finalize}});var A3=pd();Object.defineProperty(h,"find",{enumerable:!0,get:function(){return A3.find}});var N3=qg();Object.defineProperty(h,"findIndex",{enumerable:!0,get:function(){return N3.findIndex}});var P3=Bg();Object.defineProperty(h,"first",{enumerable:!0,get:function(){return P3.first}});var R3=Hg();Object.defineProperty(h,"groupBy",{enumerable:!0,get:function(){return R3.groupBy}});var k3=zl();Object.defineProperty(h,"ignoreElements",{enumerable:!0,get:function(){return k3.ignoreElements}});var L3=Ug();Object.defineProperty(h,"isEmpty",{enumerable:!0,get:function(){return L3.isEmpty}});var j3=Vg();Object.defineProperty(h,"last",{enumerable:!0,get:function(){return j3.last}});var F3=Fn();Object.defineProperty(h,"map",{enumerable:!0,get:function(){return F3.map}});var $3=Yl();Object.defineProperty(h,"mapTo",{enumerable:!0,get:function(){return $3.mapTo}});var q3=Gg();Object.defineProperty(h,"materialize",{enumerable:!0,get:function(){return q3.materialize}});var B3=zg();Object.defineProperty(h,"max",{enumerable:!0,get:function(){return B3.max}});var H3=Ao();Object.defineProperty(h,"mergeAll",{enumerable:!0,get:function(){return H3.mergeAll}});var U3=Kg();Object.defineProperty(h,"flatMap",{enumerable:!0,get:function(){return U3.flatMap}});var V3=_n();Object.defineProperty(h,"mergeMap",{enumerable:!0,get:function(){return V3.mergeMap}});var W3=Yg();Object.defineProperty(h,"mergeMapTo",{enumerable:!0,get:function(){return W3.mergeMapTo}});var G3=Zg();Object.defineProperty(h,"mergeScan",{enumerable:!0,get:function(){return G3.mergeScan}});var z3=Jg();Object.defineProperty(h,"mergeWith",{enumerable:!0,get:function(){return z3.mergeWith}});var K3=Xg();Object.defineProperty(h,"min",{enumerable:!0,get:function(){return K3.min}});var Y3=ga();Object.defineProperty(h,"multicast",{enumerable:!0,get:function(){return Y3.multicast}});var Z3=Do();Object.defineProperty(h,"observeOn",{enumerable:!0,get:function(){return Z3.observeOn}});var Q3=ey();Object.defineProperty(h,"onErrorResumeNextWith",{enumerable:!0,get:function(){return Q3.onErrorResumeNextWith}});var J3=ty();Object.defineProperty(h,"pairwise",{enumerable:!0,get:function(){return J3.pairwise}});var X3=ny();Object.defineProperty(h,"pluck",{enumerable:!0,get:function(){return X3.pluck}});var ez=ry();Object.defineProperty(h,"publish",{enumerable:!0,get:function(){return ez.publish}});var tz=iy();Object.defineProperty(h,"publishBehavior",{enumerable:!0,get:function(){return tz.publishBehavior}});var nz=oy();Object.defineProperty(h,"publishLast",{enumerable:!0,get:function(){return nz.publishLast}});var rz=sy();Object.defineProperty(h,"publishReplay",{enumerable:!0,get:function(){return rz.publishReplay}});var iz=Rd();Object.defineProperty(h,"raceWith",{enumerable:!0,get:function(){return iz.raceWith}});var oz=mi();Object.defineProperty(h,"reduce",{enumerable:!0,get:function(){return oz.reduce}});var sz=ay();Object.defineProperty(h,"repeat",{enumerable:!0,get:function(){return sz.repeat}});var az=cy();Object.defineProperty(h,"repeatWhen",{enumerable:!0,get:function(){return az.repeatWhen}});var cz=uy();Object.defineProperty(h,"retry",{enumerable:!0,get:function(){return cz.retry}});var uz=ly();Object.defineProperty(h,"retryWhen",{enumerable:!0,get:function(){return uz.retryWhen}});var lz=su();Object.defineProperty(h,"refCount",{enumerable:!0,get:function(){return lz.refCount}});var dz=qd();Object.defineProperty(h,"sample",{enumerable:!0,get:function(){return dz.sample}});var fz=dy();Object.defineProperty(h,"sampleTime",{enumerable:!0,get:function(){return fz.sampleTime}});var hz=fy();Object.defineProperty(h,"scan",{enumerable:!0,get:function(){return hz.scan}});var pz=hy();Object.defineProperty(h,"sequenceEqual",{enumerable:!0,get:function(){return pz.sequenceEqual}});var mz=Vd();Object.defineProperty(h,"share",{enumerable:!0,get:function(){return mz.share}});var gz=my();Object.defineProperty(h,"shareReplay",{enumerable:!0,get:function(){return gz.shareReplay}});var yz=gy();Object.defineProperty(h,"single",{enumerable:!0,get:function(){return yz.single}});var vz=yy();Object.defineProperty(h,"skip",{enumerable:!0,get:function(){return vz.skip}});var _z=vy();Object.defineProperty(h,"skipLast",{enumerable:!0,get:function(){return _z.skipLast}});var bz=_y();Object.defineProperty(h,"skipUntil",{enumerable:!0,get:function(){return bz.skipUntil}});var wz=by();Object.defineProperty(h,"skipWhile",{enumerable:!0,get:function(){return wz.skipWhile}});var Ez=wy();Object.defineProperty(h,"startWith",{enumerable:!0,get:function(){return Ez.startWith}});var Sz=Oo();Object.defineProperty(h,"subscribeOn",{enumerable:!0,get:function(){return Sz.subscribeOn}});var Cz=Ey();Object.defineProperty(h,"switchAll",{enumerable:!0,get:function(){return Cz.switchAll}});var Iz=Uo();Object.defineProperty(h,"switchMap",{enumerable:!0,get:function(){return Iz.switchMap}});var Tz=Sy();Object.defineProperty(h,"switchMapTo",{enumerable:!0,get:function(){return Tz.switchMapTo}});var xz=Cy();Object.defineProperty(h,"switchScan",{enumerable:!0,get:function(){return xz.switchScan}});var Dz=$o();Object.defineProperty(h,"take",{enumerable:!0,get:function(){return Dz.take}});var Oz=_d();Object.defineProperty(h,"takeLast",{enumerable:!0,get:function(){return Oz.takeLast}});var Mz=Iy();Object.defineProperty(h,"takeUntil",{enumerable:!0,get:function(){return Mz.takeUntil}});var Az=Ty();Object.defineProperty(h,"takeWhile",{enumerable:!0,get:function(){return Az.takeWhile}});var Nz=xy();Object.defineProperty(h,"tap",{enumerable:!0,get:function(){return Nz.tap}});var Pz=af();Object.defineProperty(h,"throttle",{enumerable:!0,get:function(){return Pz.throttle}});var Rz=Dy();Object.defineProperty(h,"throttleTime",{enumerable:!0,get:function(){return Rz.throttleTime}});var kz=qo();Object.defineProperty(h,"throwIfEmpty",{enumerable:!0,get:function(){return kz.throwIfEmpty}});var Lz=Oy();Object.defineProperty(h,"timeInterval",{enumerable:!0,get:function(){return Lz.timeInterval}});var jz=da();Object.defineProperty(h,"timeout",{enumerable:!0,get:function(){return jz.timeout}});var Fz=My();Object.defineProperty(h,"timeoutWith",{enumerable:!0,get:function(){return Fz.timeoutWith}});var $z=Ay();Object.defineProperty(h,"timestamp",{enumerable:!0,get:function(){return $z.timestamp}});var qz=Al();Object.defineProperty(h,"toArray",{enumerable:!0,get:function(){return qz.toArray}});var Bz=Ny();Object.defineProperty(h,"window",{enumerable:!0,get:function(){return Bz.window}});var Hz=Py();Object.defineProperty(h,"windowCount",{enumerable:!0,get:function(){return Hz.windowCount}});var Uz=Ry();Object.defineProperty(h,"windowTime",{enumerable:!0,get:function(){return Uz.windowTime}});var Vz=Ly();Object.defineProperty(h,"windowToggle",{enumerable:!0,get:function(){return Vz.windowToggle}});var Wz=jy();Object.defineProperty(h,"windowWhen",{enumerable:!0,get:function(){return Wz.windowWhen}});var Gz=Fy();Object.defineProperty(h,"withLatestFrom",{enumerable:!0,get:function(){return Gz.withLatestFrom}});var zz=$y();Object.defineProperty(h,"zipAll",{enumerable:!0,get:function(){return zz.zipAll}});var Kz=By();Object.defineProperty(h,"zipWith",{enumerable:!0,get:function(){return Kz.zipWith}})});var Ky=v((Gy,zy)=>{(function(t,n){typeof Gy=="object"&&typeof zy<"u"?zy.exports=n():typeof define=="function"&&define.amd?define(n):(t=typeof globalThis<"u"?globalThis:t||self).dayjs=n()})(Gy,function(){"use strict";var t=1e3,n=6e4,e=36e5,r="millisecond",i="second",o="minute",s="hour",a="day",c="week",u="month",l="quarter",d="year",f="date",p="Invalid Date",m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,b={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function($){var x=["th","st","nd","rd"],C=$%100;return"["+$+(x[(C-20)%10]||x[C]||x[0])+"]"}},E=function($,x,C){var P=String($);return!P||P.length>=x?$:""+Array(x+1-P.length).join(C)+$},D={s:E,z:function($){var x=-$.utcOffset(),C=Math.abs(x),P=Math.floor(C/60),O=C%60;return(x<=0?"+":"-")+E(P,2,"0")+":"+E(O,2,"0")},m:function $(x,C){if(x.date()<C.date())return-$(C,x);var P=12*(C.year()-x.year())+(C.month()-x.month()),O=x.clone().add(P,u),B=C-O<0,G=x.clone().add(P+(B?-1:1),u);return+(-(P+(C-O)/(B?O-G:G-O))||0)},a:function($){return $<0?Math.ceil($)||0:Math.floor($)},p:function($){return{M:u,y:d,w:c,d:a,D:f,h:s,m:o,s:i,ms:r,Q:l}[$]||String($||"").toLowerCase().replace(/s$/,"")},u:function($){return $===void 0}},T="en",K={};K[T]=b;var H="$isDayjsObject",re=function($){return $ instanceof rt||!(!$||!$[H])},Ee=function $(x,C,P){var O;if(!x)return T;if(typeof x=="string"){var B=x.toLowerCase();K[B]&&(O=B),C&&(K[B]=C,O=B);var G=x.split("-");if(!O&&G.length>1)return $(G[0])}else{var ie=x.name;K[ie]=x,O=ie}return!P&&O&&(T=O),O||!P&&T},pe=function($,x){if(re($))return $.clone();var C=typeof x=="object"?x:{};return C.date=$,C.args=arguments,new rt(C)},z=D;z.l=Ee,z.i=re,z.w=function($,x){return pe($,{locale:x.$L,utc:x.$u,x:x.$x,$offset:x.$offset})};var rt=(function(){function $(C){this.$L=Ee(C.locale,null,!0),this.parse(C),this.$x=this.$x||C.x||{},this[H]=!0}var x=$.prototype;return x.parse=function(C){this.$d=(function(P){var O=P.date,B=P.utc;if(O===null)return new Date(NaN);if(z.u(O))return new Date;if(O instanceof Date)return new Date(O);if(typeof O=="string"&&!/Z$/i.test(O)){var G=O.match(m);if(G){var ie=G[2]-1||0,Te=(G[7]||"0").substring(0,3);return B?new Date(Date.UTC(G[1],ie,G[3]||1,G[4]||0,G[5]||0,G[6]||0,Te)):new Date(G[1],ie,G[3]||1,G[4]||0,G[5]||0,G[6]||0,Te)}}return new Date(O)})(C),this.init()},x.init=function(){var C=this.$d;this.$y=C.getFullYear(),this.$M=C.getMonth(),this.$D=C.getDate(),this.$W=C.getDay(),this.$H=C.getHours(),this.$m=C.getMinutes(),this.$s=C.getSeconds(),this.$ms=C.getMilliseconds()},x.$utils=function(){return z},x.isValid=function(){return this.$d.toString()!==p},x.isSame=function(C,P){var O=pe(C);return this.startOf(P)<=O&&O<=this.endOf(P)},x.isAfter=function(C,P){return pe(C)<this.startOf(P)},x.isBefore=function(C,P){return this.endOf(P)<pe(C)},x.$g=function(C,P,O){return z.u(C)?this[P]:this.set(O,C)},x.unix=function(){return Math.floor(this.valueOf()/1e3)},x.valueOf=function(){return this.$d.getTime()},x.startOf=function(C,P){var O=this,B=!!z.u(P)||P,G=z.p(C),ie=function(Pn,mt){var it=z.w(O.$u?Date.UTC(O.$y,mt,Pn):new Date(O.$y,mt,Pn),O);return B?it:it.endOf(a)},Te=function(Pn,mt){return z.w(O.toDate()[Pn].apply(O.toDate("s"),(B?[0,0,0,0]:[23,59,59,999]).slice(mt)),O)},oe=this.$W,$e=this.$M,st=this.$D,Le="set"+(this.$u?"UTC":"");switch(G){case d:return B?ie(1,0):ie(31,11);case u:return B?ie(1,$e):ie(0,$e+1);case c:var hn=this.$locale().weekStart||0,ii=(oe<hn?oe+7:oe)-hn;return ie(B?st-ii:st+(6-ii),$e);case a:case f:return Te(Le+"Hours",0);case s:return Te(Le+"Minutes",1);case o:return Te(Le+"Seconds",2);case i:return Te(Le+"Milliseconds",3);default:return this.clone()}},x.endOf=function(C){return this.startOf(C,!1)},x.$set=function(C,P){var O,B=z.p(C),G="set"+(this.$u?"UTC":""),ie=(O={},O[a]=G+"Date",O[f]=G+"Date",O[u]=G+"Month",O[d]=G+"FullYear",O[s]=G+"Hours",O[o]=G+"Minutes",O[i]=G+"Seconds",O[r]=G+"Milliseconds",O)[B],Te=B===a?this.$D+(P-this.$W):P;if(B===u||B===d){var oe=this.clone().set(f,1);oe.$d[ie](Te),oe.init(),this.$d=oe.set(f,Math.min(this.$D,oe.daysInMonth())).$d}else ie&&this.$d[ie](Te);return this.init(),this},x.set=function(C,P){return this.clone().$set(C,P)},x.get=function(C){return this[z.p(C)]()},x.add=function(C,P){var O,B=this;C=Number(C);var G=z.p(P),ie=function($e){var st=pe(B);return z.w(st.date(st.date()+Math.round($e*C)),B)};if(G===u)return this.set(u,this.$M+C);if(G===d)return this.set(d,this.$y+C);if(G===a)return ie(1);if(G===c)return ie(7);var Te=(O={},O[o]=n,O[s]=e,O[i]=t,O)[G]||1,oe=this.$d.getTime()+C*Te;return z.w(oe,this)},x.subtract=function(C,P){return this.add(-1*C,P)},x.format=function(C){var P=this,O=this.$locale();if(!this.isValid())return O.invalidDate||p;var B=C||"YYYY-MM-DDTHH:mm:ssZ",G=z.z(this),ie=this.$H,Te=this.$m,oe=this.$M,$e=O.weekdays,st=O.months,Le=O.meridiem,hn=function(mt,it,cr,tn){return mt&&(mt[it]||mt(P,B))||cr[it].slice(0,tn)},ii=function(mt){return z.s(ie%12||12,mt,"0")},Pn=Le||function(mt,it,cr){var tn=mt<12?"AM":"PM";return cr?tn.toLowerCase():tn};return B.replace(y,function(mt,it){return it||(function(cr){switch(cr){case"YY":return String(P.$y).slice(-2);case"YYYY":return z.s(P.$y,4,"0");case"M":return oe+1;case"MM":return z.s(oe+1,2,"0");case"MMM":return hn(O.monthsShort,oe,st,3);case"MMMM":return hn(st,oe);case"D":return P.$D;case"DD":return z.s(P.$D,2,"0");case"d":return String(P.$W);case"dd":return hn(O.weekdaysMin,P.$W,$e,2);case"ddd":return hn(O.weekdaysShort,P.$W,$e,3);case"dddd":return $e[P.$W];case"H":return String(ie);case"HH":return z.s(ie,2,"0");case"h":return ii(1);case"hh":return ii(2);case"a":return Pn(ie,Te,!0);case"A":return Pn(ie,Te,!1);case"m":return String(Te);case"mm":return z.s(Te,2,"0");case"s":return String(P.$s);case"ss":return z.s(P.$s,2,"0");case"SSS":return z.s(P.$ms,3,"0");case"Z":return G}return null})(mt)||G.replace(":","")})},x.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},x.diff=function(C,P,O){var B,G=this,ie=z.p(P),Te=pe(C),oe=(Te.utcOffset()-this.utcOffset())*n,$e=this-Te,st=function(){return z.m(G,Te)};switch(ie){case d:B=st()/12;break;case u:B=st();break;case l:B=st()/3;break;case c:B=($e-oe)/6048e5;break;case a:B=($e-oe)/864e5;break;case s:B=$e/e;break;case o:B=$e/n;break;case i:B=$e/t;break;default:B=$e}return O?B:z.a(B)},x.daysInMonth=function(){return this.endOf(u).$D},x.$locale=function(){return K[this.$L]},x.locale=function(C,P){if(!C)return this.$L;var O=this.clone(),B=Ee(C,P,!0);return B&&(O.$L=B),O},x.clone=function(){return z.w(this.$d,this)},x.toDate=function(){return new Date(this.valueOf())},x.toJSON=function(){return this.isValid()?this.toISOString():null},x.toISOString=function(){return this.$d.toISOString()},x.toString=function(){return this.$d.toUTCString()},$})(),ee=rt.prototype;return pe.prototype=ee,[["$ms",r],["$s",i],["$m",o],["$H",s],["$W",a],["$M",u],["$y",d],["$D",f]].forEach(function($){ee[$[1]]=function(x){return this.$g(x,$[0],$[1])}}),pe.extend=function($,x){return $.$i||($(x,rt,pe),$.$i=!0),pe},pe.locale=Ee,pe.isDayjs=re,pe.unix=function($){return pe(1e3*$)},pe.en=K[T],pe.Ls=K,pe.p={},pe})});var cx=v(th=>{"use strict";Object.defineProperty(th,"__esModule",{value:!0});th.partition=void 0;var o6=cg(),ax=$n();function s6(t,n){return function(e){return[ax.filter(t,n)(e),ax.filter(o6.not(t,n))(e)]}}th.partition=s6});var ux=v(Br=>{"use strict";var a6=Br&&Br.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},c6=Br&&Br.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Br,"__esModule",{value:!0});Br.race=void 0;var u6=pi(),l6=Rd();function d6(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return l6.raceWith.apply(void 0,c6([],a6(u6.argsOrArgArray(t))))}Br.race=d6});var Ni=v(g=>{"use strict";Object.defineProperty(g,"__esModule",{value:!0});g.mergeAll=g.merge=g.max=g.materialize=g.mapTo=g.map=g.last=g.isEmpty=g.ignoreElements=g.groupBy=g.first=g.findIndex=g.find=g.finalize=g.filter=g.expand=g.exhaustMap=g.exhaustAll=g.exhaust=g.every=g.endWith=g.elementAt=g.distinctUntilKeyChanged=g.distinctUntilChanged=g.distinct=g.dematerialize=g.delayWhen=g.delay=g.defaultIfEmpty=g.debounceTime=g.debounce=g.count=g.connect=g.concatWith=g.concatMapTo=g.concatMap=g.concatAll=g.concat=g.combineLatestWith=g.combineLatest=g.combineLatestAll=g.combineAll=g.catchError=g.bufferWhen=g.bufferToggle=g.bufferTime=g.bufferCount=g.buffer=g.auditTime=g.audit=void 0;g.timeInterval=g.throwIfEmpty=g.throttleTime=g.throttle=g.tap=g.takeWhile=g.takeUntil=g.takeLast=g.take=g.switchScan=g.switchMapTo=g.switchMap=g.switchAll=g.subscribeOn=g.startWith=g.skipWhile=g.skipUntil=g.skipLast=g.skip=g.single=g.shareReplay=g.share=g.sequenceEqual=g.scan=g.sampleTime=g.sample=g.refCount=g.retryWhen=g.retry=g.repeatWhen=g.repeat=g.reduce=g.raceWith=g.race=g.publishReplay=g.publishLast=g.publishBehavior=g.publish=g.pluck=g.partition=g.pairwise=g.onErrorResumeNext=g.observeOn=g.multicast=g.min=g.mergeWith=g.mergeScan=g.mergeMapTo=g.mergeMap=g.flatMap=void 0;g.zipWith=g.zipAll=g.zip=g.withLatestFrom=g.windowWhen=g.windowToggle=g.windowTime=g.windowCount=g.window=g.toArray=g.timestamp=g.timeoutWith=g.timeout=void 0;var f6=Sl();Object.defineProperty(g,"audit",{enumerable:!0,get:function(){return f6.audit}});var h6=lg();Object.defineProperty(g,"auditTime",{enumerable:!0,get:function(){return h6.auditTime}});var p6=dg();Object.defineProperty(g,"buffer",{enumerable:!0,get:function(){return p6.buffer}});var m6=hg();Object.defineProperty(g,"bufferCount",{enumerable:!0,get:function(){return m6.bufferCount}});var g6=pg();Object.defineProperty(g,"bufferTime",{enumerable:!0,get:function(){return g6.bufferTime}});var y6=gg();Object.defineProperty(g,"bufferToggle",{enumerable:!0,get:function(){return y6.bufferToggle}});var v6=yg();Object.defineProperty(g,"bufferWhen",{enumerable:!0,get:function(){return v6.bufferWhen}});var _6=vg();Object.defineProperty(g,"catchError",{enumerable:!0,get:function(){return _6.catchError}});var b6=wg();Object.defineProperty(g,"combineAll",{enumerable:!0,get:function(){return b6.combineAll}});var w6=Rl();Object.defineProperty(g,"combineLatestAll",{enumerable:!0,get:function(){return w6.combineLatestAll}});var E6=Eg();Object.defineProperty(g,"combineLatest",{enumerable:!0,get:function(){return E6.combineLatest}});var S6=Sg();Object.defineProperty(g,"combineLatestWith",{enumerable:!0,get:function(){return S6.combineLatestWith}});var C6=Ig();Object.defineProperty(g,"concat",{enumerable:!0,get:function(){return C6.concat}});var I6=fa();Object.defineProperty(g,"concatAll",{enumerable:!0,get:function(){return I6.concatAll}});var T6=jl();Object.defineProperty(g,"concatMap",{enumerable:!0,get:function(){return T6.concatMap}});var x6=Cg();Object.defineProperty(g,"concatMapTo",{enumerable:!0,get:function(){return x6.concatMapTo}});var D6=Tg();Object.defineProperty(g,"concatWith",{enumerable:!0,get:function(){return D6.concatWith}});var O6=ma();Object.defineProperty(g,"connect",{enumerable:!0,get:function(){return O6.connect}});var M6=xg();Object.defineProperty(g,"count",{enumerable:!0,get:function(){return M6.count}});var A6=Dg();Object.defineProperty(g,"debounce",{enumerable:!0,get:function(){return A6.debounce}});var N6=Og();Object.defineProperty(g,"debounceTime",{enumerable:!0,get:function(){return N6.debounceTime}});var P6=Fo();Object.defineProperty(g,"defaultIfEmpty",{enumerable:!0,get:function(){return P6.defaultIfEmpty}});var R6=Mg();Object.defineProperty(g,"delay",{enumerable:!0,get:function(){return R6.delay}});var k6=Ql();Object.defineProperty(g,"delayWhen",{enumerable:!0,get:function(){return k6.delayWhen}});var L6=Ag();Object.defineProperty(g,"dematerialize",{enumerable:!0,get:function(){return L6.dematerialize}});var j6=Ng();Object.defineProperty(g,"distinct",{enumerable:!0,get:function(){return j6.distinct}});var F6=nd();Object.defineProperty(g,"distinctUntilChanged",{enumerable:!0,get:function(){return F6.distinctUntilChanged}});var $6=Pg();Object.defineProperty(g,"distinctUntilKeyChanged",{enumerable:!0,get:function(){return $6.distinctUntilKeyChanged}});var q6=Rg();Object.defineProperty(g,"elementAt",{enumerable:!0,get:function(){return q6.elementAt}});var B6=kg();Object.defineProperty(g,"endWith",{enumerable:!0,get:function(){return B6.endWith}});var H6=Lg();Object.defineProperty(g,"every",{enumerable:!0,get:function(){return H6.every}});var U6=jg();Object.defineProperty(g,"exhaust",{enumerable:!0,get:function(){return U6.exhaust}});var V6=ld();Object.defineProperty(g,"exhaustAll",{enumerable:!0,get:function(){return V6.exhaustAll}});var W6=cd();Object.defineProperty(g,"exhaustMap",{enumerable:!0,get:function(){return W6.exhaustMap}});var G6=Fg();Object.defineProperty(g,"expand",{enumerable:!0,get:function(){return G6.expand}});var z6=$n();Object.defineProperty(g,"filter",{enumerable:!0,get:function(){return z6.filter}});var K6=$g();Object.defineProperty(g,"finalize",{enumerable:!0,get:function(){return K6.finalize}});var Y6=pd();Object.defineProperty(g,"find",{enumerable:!0,get:function(){return Y6.find}});var Z6=qg();Object.defineProperty(g,"findIndex",{enumerable:!0,get:function(){return Z6.findIndex}});var Q6=Bg();Object.defineProperty(g,"first",{enumerable:!0,get:function(){return Q6.first}});var J6=Hg();Object.defineProperty(g,"groupBy",{enumerable:!0,get:function(){return J6.groupBy}});var X6=zl();Object.defineProperty(g,"ignoreElements",{enumerable:!0,get:function(){return X6.ignoreElements}});var eK=Ug();Object.defineProperty(g,"isEmpty",{enumerable:!0,get:function(){return eK.isEmpty}});var tK=Vg();Object.defineProperty(g,"last",{enumerable:!0,get:function(){return tK.last}});var nK=Fn();Object.defineProperty(g,"map",{enumerable:!0,get:function(){return nK.map}});var rK=Yl();Object.defineProperty(g,"mapTo",{enumerable:!0,get:function(){return rK.mapTo}});var iK=Gg();Object.defineProperty(g,"materialize",{enumerable:!0,get:function(){return iK.materialize}});var oK=zg();Object.defineProperty(g,"max",{enumerable:!0,get:function(){return oK.max}});var sK=Qg();Object.defineProperty(g,"merge",{enumerable:!0,get:function(){return sK.merge}});var aK=Ao();Object.defineProperty(g,"mergeAll",{enumerable:!0,get:function(){return aK.mergeAll}});var cK=Kg();Object.defineProperty(g,"flatMap",{enumerable:!0,get:function(){return cK.flatMap}});var uK=_n();Object.defineProperty(g,"mergeMap",{enumerable:!0,get:function(){return uK.mergeMap}});var lK=Yg();Object.defineProperty(g,"mergeMapTo",{enumerable:!0,get:function(){return lK.mergeMapTo}});var dK=Zg();Object.defineProperty(g,"mergeScan",{enumerable:!0,get:function(){return dK.mergeScan}});var fK=Jg();Object.defineProperty(g,"mergeWith",{enumerable:!0,get:function(){return fK.mergeWith}});var hK=Xg();Object.defineProperty(g,"min",{enumerable:!0,get:function(){return hK.min}});var pK=ga();Object.defineProperty(g,"multicast",{enumerable:!0,get:function(){return pK.multicast}});var mK=Do();Object.defineProperty(g,"observeOn",{enumerable:!0,get:function(){return mK.observeOn}});var gK=ey();Object.defineProperty(g,"onErrorResumeNext",{enumerable:!0,get:function(){return gK.onErrorResumeNext}});var yK=ty();Object.defineProperty(g,"pairwise",{enumerable:!0,get:function(){return yK.pairwise}});var vK=cx();Object.defineProperty(g,"partition",{enumerable:!0,get:function(){return vK.partition}});var _K=ny();Object.defineProperty(g,"pluck",{enumerable:!0,get:function(){return _K.pluck}});var bK=ry();Object.defineProperty(g,"publish",{enumerable:!0,get:function(){return bK.publish}});var wK=iy();Object.defineProperty(g,"publishBehavior",{enumerable:!0,get:function(){return wK.publishBehavior}});var EK=oy();Object.defineProperty(g,"publishLast",{enumerable:!0,get:function(){return EK.publishLast}});var SK=sy();Object.defineProperty(g,"publishReplay",{enumerable:!0,get:function(){return SK.publishReplay}});var CK=ux();Object.defineProperty(g,"race",{enumerable:!0,get:function(){return CK.race}});var IK=Rd();Object.defineProperty(g,"raceWith",{enumerable:!0,get:function(){return IK.raceWith}});var TK=mi();Object.defineProperty(g,"reduce",{enumerable:!0,get:function(){return TK.reduce}});var xK=ay();Object.defineProperty(g,"repeat",{enumerable:!0,get:function(){return xK.repeat}});var DK=cy();Object.defineProperty(g,"repeatWhen",{enumerable:!0,get:function(){return DK.repeatWhen}});var OK=uy();Object.defineProperty(g,"retry",{enumerable:!0,get:function(){return OK.retry}});var MK=ly();Object.defineProperty(g,"retryWhen",{enumerable:!0,get:function(){return MK.retryWhen}});var AK=su();Object.defineProperty(g,"refCount",{enumerable:!0,get:function(){return AK.refCount}});var NK=qd();Object.defineProperty(g,"sample",{enumerable:!0,get:function(){return NK.sample}});var PK=dy();Object.defineProperty(g,"sampleTime",{enumerable:!0,get:function(){return PK.sampleTime}});var RK=fy();Object.defineProperty(g,"scan",{enumerable:!0,get:function(){return RK.scan}});var kK=hy();Object.defineProperty(g,"sequenceEqual",{enumerable:!0,get:function(){return kK.sequenceEqual}});var LK=Vd();Object.defineProperty(g,"share",{enumerable:!0,get:function(){return LK.share}});var jK=my();Object.defineProperty(g,"shareReplay",{enumerable:!0,get:function(){return jK.shareReplay}});var FK=gy();Object.defineProperty(g,"single",{enumerable:!0,get:function(){return FK.single}});var $K=yy();Object.defineProperty(g,"skip",{enumerable:!0,get:function(){return $K.skip}});var qK=vy();Object.defineProperty(g,"skipLast",{enumerable:!0,get:function(){return qK.skipLast}});var BK=_y();Object.defineProperty(g,"skipUntil",{enumerable:!0,get:function(){return BK.skipUntil}});var HK=by();Object.defineProperty(g,"skipWhile",{enumerable:!0,get:function(){return HK.skipWhile}});var UK=wy();Object.defineProperty(g,"startWith",{enumerable:!0,get:function(){return UK.startWith}});var VK=Oo();Object.defineProperty(g,"subscribeOn",{enumerable:!0,get:function(){return VK.subscribeOn}});var WK=Ey();Object.defineProperty(g,"switchAll",{enumerable:!0,get:function(){return WK.switchAll}});var GK=Uo();Object.defineProperty(g,"switchMap",{enumerable:!0,get:function(){return GK.switchMap}});var zK=Sy();Object.defineProperty(g,"switchMapTo",{enumerable:!0,get:function(){return zK.switchMapTo}});var KK=Cy();Object.defineProperty(g,"switchScan",{enumerable:!0,get:function(){return KK.switchScan}});var YK=$o();Object.defineProperty(g,"take",{enumerable:!0,get:function(){return YK.take}});var ZK=_d();Object.defineProperty(g,"takeLast",{enumerable:!0,get:function(){return ZK.takeLast}});var QK=Iy();Object.defineProperty(g,"takeUntil",{enumerable:!0,get:function(){return QK.takeUntil}});var JK=Ty();Object.defineProperty(g,"takeWhile",{enumerable:!0,get:function(){return JK.takeWhile}});var XK=xy();Object.defineProperty(g,"tap",{enumerable:!0,get:function(){return XK.tap}});var e5=af();Object.defineProperty(g,"throttle",{enumerable:!0,get:function(){return e5.throttle}});var t5=Dy();Object.defineProperty(g,"throttleTime",{enumerable:!0,get:function(){return t5.throttleTime}});var n5=qo();Object.defineProperty(g,"throwIfEmpty",{enumerable:!0,get:function(){return n5.throwIfEmpty}});var r5=Oy();Object.defineProperty(g,"timeInterval",{enumerable:!0,get:function(){return r5.timeInterval}});var i5=da();Object.defineProperty(g,"timeout",{enumerable:!0,get:function(){return i5.timeout}});var o5=My();Object.defineProperty(g,"timeoutWith",{enumerable:!0,get:function(){return o5.timeoutWith}});var s5=Ay();Object.defineProperty(g,"timestamp",{enumerable:!0,get:function(){return s5.timestamp}});var a5=Al();Object.defineProperty(g,"toArray",{enumerable:!0,get:function(){return a5.toArray}});var c5=Ny();Object.defineProperty(g,"window",{enumerable:!0,get:function(){return c5.window}});var u5=Py();Object.defineProperty(g,"windowCount",{enumerable:!0,get:function(){return u5.windowCount}});var l5=Ry();Object.defineProperty(g,"windowTime",{enumerable:!0,get:function(){return l5.windowTime}});var d5=Ly();Object.defineProperty(g,"windowToggle",{enumerable:!0,get:function(){return d5.windowToggle}});var f5=jy();Object.defineProperty(g,"windowWhen",{enumerable:!0,get:function(){return f5.windowWhen}});var h5=Fy();Object.defineProperty(g,"withLatestFrom",{enumerable:!0,get:function(){return h5.withLatestFrom}});var p5=qy();Object.defineProperty(g,"zip",{enumerable:!0,get:function(){return p5.zip}});var m5=$y();Object.defineProperty(g,"zipAll",{enumerable:!0,get:function(){return m5.zipAll}});var g5=By();Object.defineProperty(g,"zipWith",{enumerable:!0,get:function(){return g5.zipWith}})});var nS;(function(t){(function(n){var e=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:Function("return this;")(),r=i(t);typeof e.Reflect>"u"?e.Reflect=t:r=i(e.Reflect,r),n(r);function i(o,s){return function(a,c){typeof o[a]!="function"&&Object.defineProperty(o,a,{configurable:!0,writable:!0,value:c}),s&&s(a,c)}}})(function(n){var e=Object.prototype.hasOwnProperty,r=typeof Symbol=="function",i=r&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",o=r&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",s=typeof Object.create=="function",a={__proto__:[]}instanceof Array,c=!s&&!a,u={create:s?function(){return gm(Object.create(null))}:a?function(){return gm({__proto__:null})}:function(){return gm({})},has:c?function(_,S){return e.call(_,S)}:function(_,S){return S in _},get:c?function(_,S){return e.call(_,S)?_[S]:void 0}:function(_,S){return _[S]}},l=Object.getPrototypeOf(Function),d=typeof process=="object"&&process.env&&process.env.REFLECT_METADATA_USE_MAP_POLYFILL==="true",f=!d&&typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:DR(),p=!d&&typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:OR(),m=!d&&typeof WeakMap=="function"?WeakMap:MR(),y=new m;function b(_,S,M,k){if(oe(M)){if(!cr(_))throw new TypeError;if(!XE(S))throw new TypeError;return rt(_,S)}else{if(!cr(_))throw new TypeError;if(!Le(S))throw new TypeError;if(!Le(k)&&!oe(k)&&!$e(k))throw new TypeError;return $e(k)&&(k=void 0),M=it(M),ee(_,S,M,k)}}n("decorate",b);function E(_,S){function M(k,Y){if(!Le(k))throw new TypeError;if(!oe(Y)&&!SR(Y))throw new TypeError;B(_,S,k,Y)}return M}n("metadata",E);function D(_,S,M,k){if(!Le(M))throw new TypeError;return oe(k)||(k=it(k)),B(_,S,M,k)}n("defineMetadata",D);function T(_,S,M){if(!Le(S))throw new TypeError;return oe(M)||(M=it(M)),x(_,S,M)}n("hasMetadata",T);function K(_,S,M){if(!Le(S))throw new TypeError;return oe(M)||(M=it(M)),C(_,S,M)}n("hasOwnMetadata",K);function H(_,S,M){if(!Le(S))throw new TypeError;return oe(M)||(M=it(M)),P(_,S,M)}n("getMetadata",H);function re(_,S,M){if(!Le(S))throw new TypeError;return oe(M)||(M=it(M)),O(_,S,M)}n("getOwnMetadata",re);function Ee(_,S){if(!Le(_))throw new TypeError;return oe(S)||(S=it(S)),G(_,S)}n("getMetadataKeys",Ee);function pe(_,S){if(!Le(_))throw new TypeError;return oe(S)||(S=it(S)),ie(_,S)}n("getOwnMetadataKeys",pe);function z(_,S,M){if(!Le(S))throw new TypeError;oe(M)||(M=it(M));var k=$(S,M,!1);if(oe(k)||!k.delete(_))return!1;if(k.size>0)return!0;var Y=y.get(S);return Y.delete(M),Y.size>0||y.delete(S),!0}n("deleteMetadata",z);function rt(_,S){for(var M=_.length-1;M>=0;--M){var k=_[M],Y=k(S);if(!oe(Y)&&!$e(Y)){if(!XE(Y))throw new TypeError;S=Y}}return S}function ee(_,S,M,k){for(var Y=_.length-1;Y>=0;--Y){var at=_[Y],ue=at(S,M,k);if(!oe(ue)&&!$e(ue)){if(!Le(ue))throw new TypeError;k=ue}}return k}function $(_,S,M){var k=y.get(_);if(oe(k)){if(!M)return;k=new f,y.set(_,k)}var Y=k.get(S);if(oe(Y)){if(!M)return;Y=new f,k.set(S,Y)}return Y}function x(_,S,M){var k=C(_,S,M);if(k)return!0;var Y=mm(S);return $e(Y)?!1:x(_,Y,M)}function C(_,S,M){var k=$(S,M,!1);return oe(k)?!1:Pn(k.has(_))}function P(_,S,M){var k=C(_,S,M);if(k)return O(_,S,M);var Y=mm(S);if(!$e(Y))return P(_,Y,M)}function O(_,S,M){var k=$(S,M,!1);if(!oe(k))return k.get(_)}function B(_,S,M,k){var Y=$(M,k,!0);Y.set(_,S)}function G(_,S){var M=ie(_,S),k=mm(_);if(k===null)return M;var Y=G(k,S);if(Y.length<=0)return M;if(M.length<=0)return Y;for(var at=new p,ue=[],me=0,X=M;me<X.length;me++){var xe=X[me],De=at.has(xe);De||(at.add(xe),ue.push(xe))}for(var ur=0,tS=Y;ur<tS.length;ur++){var xe=tS[ur],De=at.has(xe);De||(at.add(xe),ue.push(xe))}return ue}function ie(_,S){var M=[],k=$(_,S,!1);if(oe(k))return M;for(var Y=k.keys(),at=CR(Y),ue=0;;){var me=TR(at);if(!me)return M.length=ue,M;var X=IR(me);try{M[ue]=X}catch(xe){try{xR(at)}finally{throw xe}}ue++}}function Te(_){if(_===null)return 1;switch(typeof _){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return _===null?1:6;default:return 6}}function oe(_){return _===void 0}function $e(_){return _===null}function st(_){return typeof _=="symbol"}function Le(_){return typeof _=="object"?_!==null:typeof _=="function"}function hn(_,S){switch(Te(_)){case 0:return _;case 1:return _;case 2:return _;case 3:return _;case 4:return _;case 5:return _}var M=S===3?"string":S===5?"number":"default",k=eS(_,i);if(k!==void 0){var Y=k.call(_,M);if(Le(Y))throw new TypeError;return Y}return ii(_,M==="default"?"number":M)}function ii(_,S){if(S==="string"){var M=_.toString;if(tn(M)){var k=M.call(_);if(!Le(k))return k}var Y=_.valueOf;if(tn(Y)){var k=Y.call(_);if(!Le(k))return k}}else{var Y=_.valueOf;if(tn(Y)){var k=Y.call(_);if(!Le(k))return k}var at=_.toString;if(tn(at)){var k=at.call(_);if(!Le(k))return k}}throw new TypeError}function Pn(_){return!!_}function mt(_){return""+_}function it(_){var S=hn(_,3);return st(S)?S:mt(S)}function cr(_){return Array.isArray?Array.isArray(_):_ instanceof Object?_ instanceof Array:Object.prototype.toString.call(_)==="[object Array]"}function tn(_){return typeof _=="function"}function XE(_){return typeof _=="function"}function SR(_){switch(Te(_)){case 3:return!0;case 4:return!0;default:return!1}}function eS(_,S){var M=_[S];if(M!=null){if(!tn(M))throw new TypeError;return M}}function CR(_){var S=eS(_,o);if(!tn(S))throw new TypeError;var M=S.call(_);if(!Le(M))throw new TypeError;return M}function IR(_){return _.value}function TR(_){var S=_.next();return S.done?!1:S}function xR(_){var S=_.return;S&&S.call(_)}function mm(_){var S=Object.getPrototypeOf(_);if(typeof _!="function"||_===l||S!==l)return S;var M=_.prototype,k=M&&Object.getPrototypeOf(M);if(k==null||k===Object.prototype)return S;var Y=k.constructor;return typeof Y!="function"||Y===_?S:Y}function DR(){var _={},S=[],M=(function(){function ue(me,X,xe){this._index=0,this._keys=me,this._values=X,this._selector=xe}return ue.prototype["@@iterator"]=function(){return this},ue.prototype[o]=function(){return this},ue.prototype.next=function(){var me=this._index;if(me>=0&&me<this._keys.length){var X=this._selector(this._keys[me],this._values[me]);return me+1>=this._keys.length?(this._index=-1,this._keys=S,this._values=S):this._index++,{value:X,done:!1}}return{value:void 0,done:!0}},ue.prototype.throw=function(me){throw this._index>=0&&(this._index=-1,this._keys=S,this._values=S),me},ue.prototype.return=function(me){return this._index>=0&&(this._index=-1,this._keys=S,this._values=S),{value:me,done:!0}},ue})();return(function(){function ue(){this._keys=[],this._values=[],this._cacheKey=_,this._cacheIndex=-2}return Object.defineProperty(ue.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),ue.prototype.has=function(me){return this._find(me,!1)>=0},ue.prototype.get=function(me){var X=this._find(me,!1);return X>=0?this._values[X]:void 0},ue.prototype.set=function(me,X){var xe=this._find(me,!0);return this._values[xe]=X,this},ue.prototype.delete=function(me){var X=this._find(me,!1);if(X>=0){for(var xe=this._keys.length,De=X+1;De<xe;De++)this._keys[De-1]=this._keys[De],this._values[De-1]=this._values[De];return this._keys.length--,this._values.length--,me===this._cacheKey&&(this._cacheKey=_,this._cacheIndex=-2),!0}return!1},ue.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=_,this._cacheIndex=-2},ue.prototype.keys=function(){return new M(this._keys,this._values,k)},ue.prototype.values=function(){return new M(this._keys,this._values,Y)},ue.prototype.entries=function(){return new M(this._keys,this._values,at)},ue.prototype["@@iterator"]=function(){return this.entries()},ue.prototype[o]=function(){return this.entries()},ue.prototype._find=function(me,X){return this._cacheKey!==me&&(this._cacheIndex=this._keys.indexOf(this._cacheKey=me)),this._cacheIndex<0&&X&&(this._cacheIndex=this._keys.length,this._keys.push(me),this._values.push(void 0)),this._cacheIndex},ue})();function k(ue,me){return ue}function Y(ue,me){return me}function at(ue,me){return[ue,me]}}function OR(){return(function(){function _(){this._map=new f}return Object.defineProperty(_.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),_.prototype.has=function(S){return this._map.has(S)},_.prototype.add=function(S){return this._map.set(S,S),this},_.prototype.delete=function(S){return this._map.delete(S)},_.prototype.clear=function(){this._map.clear()},_.prototype.keys=function(){return this._map.keys()},_.prototype.values=function(){return this._map.values()},_.prototype.entries=function(){return this._map.entries()},_.prototype["@@iterator"]=function(){return this.keys()},_.prototype[o]=function(){return this.keys()},_})()}function MR(){var _=16,S=u.create(),M=k();return(function(){function X(){this._key=k()}return X.prototype.has=function(xe){var De=Y(xe,!1);return De!==void 0?u.has(De,this._key):!1},X.prototype.get=function(xe){var De=Y(xe,!1);return De!==void 0?u.get(De,this._key):void 0},X.prototype.set=function(xe,De){var ur=Y(xe,!0);return ur[this._key]=De,this},X.prototype.delete=function(xe){var De=Y(xe,!1);return De!==void 0?delete De[this._key]:!1},X.prototype.clear=function(){this._key=k()},X})();function k(){var X;do X="@@WeakMap@@"+me();while(u.has(S,X));return S[X]=!0,X}function Y(X,xe){if(!e.call(X,M)){if(!xe)return;Object.defineProperty(X,M,{value:u.create()})}return X[M]}function at(X,xe){for(var De=0;De<xe;++De)X[De]=Math.random()*255|0;return X}function ue(X){return typeof Uint8Array=="function"?typeof crypto<"u"?crypto.getRandomValues(new Uint8Array(X)):typeof msCrypto<"u"?msCrypto.getRandomValues(new Uint8Array(X)):at(new Uint8Array(X),X):at(new Array(X),X)}function me(){var X=ue(_);X[6]=X[6]&79|64,X[8]=X[8]&191|128;for(var xe="",De=0;De<_;++De){var ur=X[De];(De===4||De===6||De===8)&&(xe+="-"),ur<16&&(xe+="0"),xe+=ur.toString(16).toLowerCase()}return xe}}function gm(_){return _.__=void 0,delete _.__,_}})})(nS||(nS={}));var ER=U(Q(),1);import{createServer as Yz}from"http";import{Http2ServerRequest as Zz}from"http2";import{Http2ServerRequest as Hy}from"http2";import{Readable as nT}from"stream";import c8 from"crypto";var gi=class extends Error{constructor(t,n){super(t,n),this.name="RequestError"}},Qz=t=>t instanceof gi?t:new gi(t.message,{cause:t}),Jz=global.Request,ya=class extends Jz{constructor(t,n){typeof t=="object"&&Yo in t&&(t=t[Yo]()),typeof n?.body?.getReader<"u"&&(n.duplex??="half"),super(t,n)}},Xz=t=>{let n=[],e=t.rawHeaders;for(let r=0;r<e.length;r+=2){let{[r]:i,[r+1]:o}=e;i.charCodeAt(0)!==58&&n.push([i,o])}return new Headers(n)},iT=Symbol("wrapBodyStream"),e8=(t,n,e,r,i)=>{let o={method:t,headers:e,signal:i.signal};if(t==="TRACE"){o.method="GET";let s=new ya(n,o);return Object.defineProperty(s,"method",{get(){return"TRACE"}}),s}if(!(t==="GET"||t==="HEAD"))if("rawBody"in r&&r.rawBody instanceof Buffer)o.body=new ReadableStream({start(s){s.enqueue(r.rawBody),s.close()}});else if(r[iT]){let s;o.body=new ReadableStream({async pull(a){try{s||=nT.toWeb(r).getReader();let{done:c,value:u}=await s.read();c?a.close():a.enqueue(u)}catch(c){a.error(c)}}})}else o.body=nT.toWeb(r);return new ya(n,o)},Yo=Symbol("getRequestCache"),t8=Symbol("requestCache"),mf=Symbol("incomingKey"),gf=Symbol("urlKey"),n8=Symbol("headersKey"),Ko=Symbol("abortControllerKey"),r8=Symbol("getAbortController"),yf={get method(){return this[mf].method||"GET"},get url(){return this[gf]},get headers(){return this[n8]||=Xz(this[mf])},[r8](){return this[Yo](),this[Ko]},[Yo](){return this[Ko]||=new AbortController,this[t8]||=e8(this.method,this[gf],this.headers,this[mf],this[Ko])}};["body","bodyUsed","cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","signal","keepalive"].forEach(t=>{Object.defineProperty(yf,t,{get(){return this[Yo]()[t]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(t=>{Object.defineProperty(yf,t,{value:function(){return this[Yo]()[t]()}})});Object.setPrototypeOf(yf,ya.prototype);var i8=(t,n)=>{let e=Object.create(yf);e[mf]=t;let r=t.url||"";if(r[0]!=="/"&&(r.startsWith("http://")||r.startsWith("https://"))){if(t instanceof Hy)throw new gi("Absolute URL for :path is not allowed in HTTP/2");try{let a=new URL(r);e[gf]=a.href}catch(a){throw new gi("Invalid absolute URL",{cause:a})}return e}let i=(t instanceof Hy?t.authority:t.headers.host)||n;if(!i)throw new gi("Missing host header");let o;if(t instanceof Hy){if(o=t.scheme,!(o==="http"||o==="https"))throw new gi("Unsupported scheme")}else o=t.socket&&t.socket.encrypted?"https":"http";let s=new URL(`${o}://${i}${r}`);if(s.hostname.length!==i.length&&s.hostname!==i.replace(/:\d+$/,""))throw new gi("Invalid host header");return e[gf]=s.href,e},rT=Symbol("responseCache"),zo=Symbol("getResponseCache"),yi=Symbol("cache"),Vy=global.Response,va=class oT{#t;#e;[zo](){return delete this[yi],this[rT]||=new Vy(this.#t,this.#e)}constructor(n,e){let r;if(this.#t=n,e instanceof oT){let i=e[rT];if(i){this.#e=i,this[zo]();return}else this.#e=e.#e,r=new Headers(e.#e.headers)}else this.#e=e;(typeof n=="string"||typeof n?.getReader<"u"||n instanceof Blob||n instanceof Uint8Array)&&(r||=e?.headers||{"content-type":"text/plain; charset=UTF-8"},this[yi]=[e?.status||200,n,r])}get headers(){let n=this[yi];return n?(n[2]instanceof Headers||(n[2]=new Headers(n[2])),n[2]):this[zo]().headers}get status(){return this[yi]?.[0]??this[zo]().status}get ok(){let n=this.status;return n>=200&&n<300}};["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(t=>{Object.defineProperty(va.prototype,t,{get(){return this[zo]()[t]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(t=>{Object.defineProperty(va.prototype,t,{value:function(){return this[zo]()[t]()}})});Object.setPrototypeOf(va,Vy);Object.setPrototypeOf(va.prototype,Vy.prototype);async function o8(t){return Promise.race([t,Promise.resolve().then(()=>Promise.resolve(void 0))])}function sT(t,n,e){let r=a=>{t.cancel(a).catch(()=>{})};return n.on("close",r),n.on("error",r),(e??t.read()).then(s,i),t.closed.finally(()=>{n.off("close",r),n.off("error",r)});function i(a){a&&n.destroy(a)}function o(){t.read().then(s,i)}function s({done:a,value:c}){try{if(a)n.end();else if(!n.write(c))n.once("drain",o);else return t.read().then(s,i)}catch(u){i(u)}}}function s8(t,n){if(t.locked)throw new TypeError("ReadableStream is locked.");return n.destroyed?void 0:sT(t.getReader(),n)}var aT=t=>{let n={};t instanceof Headers||(t=new Headers(t??void 0));let e=[];for(let[r,i]of t)r==="set-cookie"?e.push(i):n[r]=i;return e.length>0&&(n["set-cookie"]=e),n["content-type"]??="text/plain; charset=UTF-8",n},a8="x-hono-already-sent",u8=global.fetch;typeof global.crypto>"u"&&(global.crypto=c8);global.fetch=(t,n)=>(n={compress:!1,...n},u8(t,n));var Wy=Symbol("outgoingEnded"),l8=()=>new Response(null,{status:400}),cT=t=>new Response(null,{status:t instanceof Error&&(t.name==="TimeoutError"||t.constructor.name==="TimeoutError")?504:500}),Uy=(t,n)=>{let e=t instanceof Error?t:new Error("unknown error",{cause:t});e.code==="ERR_STREAM_PREMATURE_CLOSE"?console.info("The user aborted a request."):(console.error(t),n.headersSent||n.writeHead(500,{"Content-Type":"text/plain"}),n.end(`Error: ${e.message}`),n.destroy(e))},uT=t=>{"flushHeaders"in t&&t.writable&&t.flushHeaders()},lT=async(t,n)=>{let[e,r,i]=t[yi];i instanceof Headers&&(i=aT(i)),typeof r=="string"?i["Content-Length"]=Buffer.byteLength(r):r instanceof Uint8Array?i["Content-Length"]=r.byteLength:r instanceof Blob&&(i["Content-Length"]=r.size),n.writeHead(e,i),typeof r=="string"||r instanceof Uint8Array?n.end(r):r instanceof Blob?n.end(new Uint8Array(await r.arrayBuffer())):(uT(n),await s8(r,n)?.catch(o=>Uy(o,n))),n[Wy]?.()},d8=t=>typeof t.then=="function",f8=async(t,n,e={})=>{if(d8(t))if(e.errorHandler)try{t=await t}catch(i){let o=await e.errorHandler(i);if(!o)return;t=o}else t=await t.catch(cT);if(yi in t)return lT(t,n);let r=aT(t.headers);if(t.body){let i=t.body.getReader(),o=[],s=!1,a;if(r["transfer-encoding"]!=="chunked"){let c=2;for(let u=0;u<c;u++){a||=i.read();let l=await o8(a).catch(d=>{console.error(d),s=!0});if(!l){if(u===1){await new Promise(d=>setTimeout(d)),c=3;continue}break}if(a=void 0,l.value&&o.push(l.value),l.done){s=!0;break}}s&&!("content-length"in r)&&(r["content-length"]=o.reduce((u,l)=>u+l.length,0))}n.writeHead(t.status,r),o.forEach(c=>{n.write(c)}),s?n.end():(o.length===0&&uT(n),await sT(i,n,a))}else r[a8]||(n.writeHead(t.status,r),n.end());n[Wy]?.()},h8=(t,n={})=>{let e=n.autoCleanupIncoming??!0;return n.overrideGlobalObjects!==!1&&global.Request!==ya&&(Object.defineProperty(global,"Request",{value:ya}),Object.defineProperty(global,"Response",{value:va})),async(r,i)=>{let o,s;try{s=i8(r,n.hostname);let a=!e||r.method==="GET"||r.method==="HEAD";if(a||(r[iT]=!0,r.on("end",()=>{a=!0}),r instanceof Zz&&(i[Wy]=()=>{a||setTimeout(()=>{a||setTimeout(()=>{r.destroy(),i.destroy()})})})),i.on("close",()=>{s[Ko]&&(r.errored?s[Ko].abort(r.errored.toString()):i.writableFinished||s[Ko].abort("Client connection prematurely closed.")),a||setTimeout(()=>{a||setTimeout(()=>{r.destroy()})})}),o=t(s,{incoming:r,outgoing:i}),yi in o)return lT(o,i)}catch(a){if(o)return Uy(a,i);if(n.errorHandler){if(o=await n.errorHandler(s?a:Qz(a)),!o)return}else s?o=cT(a):o=l8()}try{return await f8(o,i,n)}catch(a){return Uy(a,i)}}},p8=t=>{let n=t.fetch,e=h8(n,{hostname:t.hostname,overrideGlobalObjects:t.overrideGlobalObjects,autoCleanupIncoming:t.autoCleanupIncoming});return(t.createServer||Yz)(t.serverOptions||{},e)},dT=(t,n)=>{let e=p8(t);return e.listen(t?.port??3e3,t.hostname,()=>{let r=e.address();n&&n(r)}),e};var m8=U(Ky());var g8=U(Ky());var gt=null,vf=!1,Jy=1,y8=null,zt=Symbol("SIGNAL");function ge(t){let n=gt;return gt=t,n}function bf(){return gt}var Zo={version:0,lastCleanEpoch:0,dirty:!1,producers:void 0,producersTail:void 0,consumers:void 0,consumersTail:void 0,recomputing:!1,consumerAllowSignalWrites:!1,consumerIsAlwaysLive:!1,kind:"unknown",producerMustRecompute:()=>!1,producerRecomputeValue:()=>{},consumerMarkedDirty:()=>{},consumerOnSignalRead:()=>{}};function Xy(t){if(vf)throw new Error("");if(gt===null)return;gt.consumerOnSignalRead(t);let n=gt.producersTail;if(n!==void 0&&n.producer===t)return;let e,r=gt.recomputing;if(r&&(e=n!==void 0?n.nextProducer:gt.producers,e!==void 0&&e.producer===t)){gt.producersTail=e,e.lastReadVersion=t.version;return}let i=t.consumersTail;if(i!==void 0&&i.consumer===gt&&(!r||_8(i,gt)))return;let o=Jo(gt),s={producer:t,consumer:gt,nextProducer:e,prevConsumer:i,lastReadVersion:t.version,nextConsumer:void 0};gt.producersTail=s,n!==void 0?n.nextProducer=s:gt.producers=s,o&&mT(t,s)}function fT(){Jy++}function ev(t){if(!(Jo(t)&&!t.dirty)&&!(!t.dirty&&t.lastCleanEpoch===Jy)){if(!t.producerMustRecompute(t)&&!Ef(t)){Qy(t);return}t.producerRecomputeValue(t),Qy(t)}}function tv(t){if(t.consumers===void 0)return;let n=vf;vf=!0;try{for(let e=t.consumers;e!==void 0;e=e.nextConsumer){let r=e.consumer;r.dirty||v8(r)}}finally{vf=n}}function nv(){return gt?.consumerAllowSignalWrites!==!1}function v8(t){t.dirty=!0,tv(t),t.consumerMarkedDirty?.(t)}function Qy(t){t.dirty=!1,t.lastCleanEpoch=Jy}function _a(t){return t&&hT(t),ge(t)}function hT(t){t.producersTail=void 0,t.recomputing=!0}function wf(t,n){ge(n),t&&pT(t)}function pT(t){t.recomputing=!1;let n=t.producersTail,e=n!==void 0?n.nextProducer:t.producers;if(e!==void 0){if(Jo(t))do e=rv(e);while(e!==void 0);n!==void 0?n.nextProducer=void 0:t.producers=void 0}}function Ef(t){for(let n=t.producers;n!==void 0;n=n.nextProducer){let e=n.producer,r=n.lastReadVersion;if(r!==e.version||(ev(e),r!==e.version))return!0}return!1}function Qo(t){if(Jo(t)){let n=t.producers;for(;n!==void 0;)n=rv(n)}t.producers=void 0,t.producersTail=void 0,t.consumers=void 0,t.consumersTail=void 0}function mT(t,n){let e=t.consumersTail,r=Jo(t);if(e!==void 0?(n.nextConsumer=e.nextConsumer,e.nextConsumer=n):(n.nextConsumer=void 0,t.consumers=n),n.prevConsumer=e,t.consumersTail=n,!r)for(let i=t.producers;i!==void 0;i=i.nextProducer)mT(i.producer,i)}function rv(t){let n=t.producer,e=t.nextProducer,r=t.nextConsumer,i=t.prevConsumer;if(t.nextConsumer=void 0,t.prevConsumer=void 0,r!==void 0?r.prevConsumer=i:n.consumersTail=i,i!==void 0)i.nextConsumer=r;else if(n.consumers=r,!Jo(n)){let o=n.producers;for(;o!==void 0;)o=rv(o)}return e}function Jo(t){return t.consumerIsAlwaysLive||t.consumers!==void 0}function iv(t){y8?.(t)}function _8(t,n){let e=n.producersTail;if(e!==void 0){let r=n.producers;do{if(r===t)return!0;if(r===e)break;r=r.nextProducer}while(r!==void 0)}return!1}function ov(t,n){return Object.is(t,n)}function Sf(t,n){let e=Object.create(b8);e.computation=t,n!==void 0&&(e.equal=n);let r=()=>{if(ev(e),Xy(e),e.value===_f)throw e.error;return e.value};return r[zt]=e,iv(e),r}var Yy=Symbol("UNSET"),Zy=Symbol("COMPUTING"),_f=Symbol("ERRORED"),b8={...Zo,value:Yy,dirty:!0,error:null,equal:ov,kind:"computed",producerMustRecompute(t){return t.value===Yy||t.value===Zy},producerRecomputeValue(t){if(t.value===Zy)throw new Error("");let n=t.value;t.value=Zy;let e=_a(t),r,i=!1;try{r=t.computation(),ge(null),i=n!==Yy&&n!==_f&&r!==_f&&t.equal(n,r)}catch(o){r=_f,t.error=o}finally{wf(t,e)}if(i){t.value=n;return}t.value=r,t.version++}};function w8(){throw new Error}var E8=w8;function gT(t){E8(t)}var S8=null;function sv(t,n){let e=Object.create(_T);e.value=t,n!==void 0&&(e.equal=n);let r=()=>yT(e);return r[zt]=e,iv(e),[r,s=>av(e,s),s=>vT(e,s)]}function yT(t){return Xy(t),t.value}function av(t,n){nv()||gT(t),t.equal(t.value,n)||(t.value=n,C8(t))}function vT(t,n){nv()||gT(t),av(t,n(t.value))}var _T={...Zo,equal:ov,value:void 0,kind:"signal"};function C8(t){t.version++,fT(),tv(t),S8?.(t)}function cv(t){let n=ge(null);try{return t()}finally{ge(n)}}var uv={...Zo,consumerIsAlwaysLive:!0,consumerAllowSignalWrites:!0,dirty:!0,kind:"effect"};function lv(t){if(t.dirty=!1,t.version>0&&!Ef(t))return;t.version++;let n=_a(t);try{t.cleanup(),t.fn()}finally{wf(t,n)}}var Rr=U(Q(),1);var dv;function Cf(){return dv}function wn(t){let n=dv;return dv=t,n}var bT=Symbol("NotFound");function Xo(t){return t===bT||t?.name==="\u0275NotFound"}var Re=class extends Error{code;constructor(n,e){super(Cv(n,e)),this.code=n}};function T8(t){return`NG0${Math.abs(t)}`}function Cv(t,n){return`${T8(t)}${n?": "+n:""}`}function qe(t){for(let n in t)if(t[n]===qe)return n;throw Error("")}function _i(t){if(typeof t=="string")return t;if(Array.isArray(t))return`[${t.map(_i).join(", ")}]`;if(t==null)return""+t;let n=t.overriddenName||t.name;if(n)return`${n}`;let e=t.toString();if(e==null)return""+e;let r=e.indexOf(`
7
- `);return r>=0?e.slice(0,r):e}function Iv(t,n){return t?n?`${t} ${n}`:t:n||""}var x8=qe({__forward_ref__:qe});function Nf(t){return t.__forward_ref__=Nf,t.toString=function(){return _i(this())},t}function xt(t){return Tv(t)?t():t}function Tv(t){return typeof t=="function"&&t.hasOwnProperty(x8)&&t.__forward_ref__===Nf}function N(t){return{token:t.token,providedIn:t.providedIn||null,factory:t.factory,value:void 0}}function Pf(t){return D8(t,Rf)}function D8(t,n){return t.hasOwnProperty(n)&&t[n]||null}function O8(t){let n=t?.[Rf]??null;return n||null}function hv(t){return t&&t.hasOwnProperty(Tf)?t[Tf]:null}var Rf=qe({\u0275prov:qe}),Tf=qe({\u0275inj:qe}),_e=class{_desc;ngMetadataName="InjectionToken";\u0275prov;constructor(n,e){this._desc=n,this.\u0275prov=void 0,typeof e=="number"?this.__NG_ELEMENT_ID__=e:e!==void 0&&(this.\u0275prov=N({token:this,providedIn:e.providedIn||"root",factory:e.factory}))}get multi(){return this}toString(){return`InjectionToken ${this._desc}`}};function xv(t){return t&&!!t.\u0275providers}var Dv=qe({\u0275cmp:qe}),Ov=qe({\u0275dir:qe});var wa=qe({\u0275fac:qe}),Ii=qe({__NG_ELEMENT_ID__:qe}),wT=qe({__NG_ENV_ID__:qe});function kf(t){return TT(t,"@Component"),t[Dv]||null}function IT(t){return TT(t,"@Directive"),t[Ov]||null}function TT(t,n){if(t==null)throw new Re(-919,!1)}var xT=qe({ngErrorCode:qe}),M8=qe({ngErrorMessage:qe}),A8=qe({ngTokenPath:qe});function Mv(t,n){return DT("",-200,n)}function Lf(t,n){throw new Re(-201,!1)}function DT(t,n,e){let r=new Re(n,t);return r[xT]=n,r[M8]=t,e&&(r[A8]=e),r}function N8(t){return t[xT]}var pv;function OT(){return pv}function jt(t){let n=pv;return pv=t,n}function Av(t,n,e){let r=Pf(t);if(r&&r.providedIn=="root")return r.value===void 0?r.value=r.factory():r.value;if(e&8)return null;if(n!==void 0)return n;Lf(t,"")}var P8={},vi=P8,R8="__NG_DI_FLAG__",mv=class{injector;constructor(n){this.injector=n}retrieve(n,e){let r=bi(e)||0;try{return this.injector.get(n,r&8?null:vi,r)}catch(i){if(Xo(i))return i;throw i}}};function k8(t,n=0){let e=Cf();if(e===void 0)throw new Re(-203,!1);if(e===null)return Av(t,void 0,n);{let r=L8(n),i=e.retrieve(t,r);if(Xo(i)){if(r.optional)return null;throw i}return i}}function Hn(t,n=0){return(OT()||k8)(xt(t),n)}function w(t,n){return Hn(t,bi(n))}function bi(t){return typeof t>"u"||typeof t=="number"?t:0|(t.optional&&8)|(t.host&&1)|(t.self&&2)|(t.skipSelf&&4)}function L8(t){return{optional:!!(t&8),host:!!(t&1),self:!!(t&2),skipSelf:!!(t&4)}}function gv(t){let n=[];for(let e=0;e<t.length;e++){let r=xt(t[e]);if(Array.isArray(r)){if(r.length===0)throw new Re(900,!1);let i,o=0;for(let s=0;s<r.length;s++){let a=r[s],c=j8(a);typeof c=="number"?c===-1?i=a.token:o|=c:i=a}n.push(Hn(i,o))}else n.push(Hn(r))}return n}function j8(t){return t[R8]}function wi(t,n){let e=t.hasOwnProperty(wa);return e?t[wa]:null}function jf(t,n){t.forEach(e=>Array.isArray(e)?jf(e,n):n(e))}function Nv(t,n){return n>=t.length-1?t.pop():t.splice(n,1)[0]}var Ff={},Ea=[],$f=new _e(""),Pv=new _e("",-1),Rv=new _e(""),Sa=class{get(n,e=vi){if(e===vi){let i=DT("",-201);throw i.name="\u0275NotFound",i}return e}};function ts(t){return{\u0275providers:t}}function MT(...t){return{\u0275providers:AT(!0,t),\u0275fromNgModule:!0}}function AT(t,...n){let e=[],r=new Set,i,o=s=>{e.push(s)};return jf(n,s=>{let a=s;xf(a,o,[],r)&&(i||=[],i.push(a))}),i!==void 0&&NT(i,o),e}function NT(t,n){for(let e=0;e<t.length;e++){let{ngModule:r,providers:i}=t[e];kv(i,o=>{n(o,r)})}}function xf(t,n,e,r){if(t=xt(t),!t)return!1;let i=null,o=hv(t),s=!o&&kf(t);if(!o&&!s){let c=t.ngModule;if(o=hv(c),o)i=c;else return!1}else{if(s&&!s.standalone)return!1;i=t}let a=r.has(i);if(s){if(a)return!1;if(r.add(i),s.dependencies){let c=typeof s.dependencies=="function"?s.dependencies():s.dependencies;for(let u of c)xf(u,n,e,r)}}else if(o){if(o.imports!=null&&!a){r.add(i);let u;jf(o.imports,l=>{xf(l,n,e,r)&&(u||=[],u.push(l))}),u!==void 0&&NT(u,n)}if(!a){let u=wi(i)||(()=>new i);n({provide:i,useFactory:u,deps:Ea},i),n({provide:Rv,useValue:i,multi:!0},i),n({provide:$f,useValue:()=>Hn(i),multi:!0},i)}let c=o.providers;if(c!=null&&!a){let u=t;kv(c,l=>{n(l,u)})}}else return!1;return i!==t&&t.providers!==void 0}function kv(t,n){for(let e of t)xv(e)&&(e=e.\u0275providers),Array.isArray(e)?kv(e,n):n(e)}var F8=qe({provide:String,useValue:qe});function PT(t){return t!==null&&typeof t=="object"&&F8 in t}function $8(t){return!!(t&&t.useExisting)}function q8(t){return!!(t&&t.useFactory)}function Df(t){return typeof t=="function"}var qf=new _e(""),If={},ET={},fv;function Da(){return fv===void 0&&(fv=new Sa),fv}var En=class{},Ei=class extends En{parent;source;scopes;records=new Map;_ngOnDestroyHooks=new Set;_onDestroyHooks=[];get destroyed(){return this._destroyed}_destroyed=!1;injectorDefTypes;constructor(n,e,r,i){super(),this.parent=e,this.source=r,this.scopes=i,vv(n,s=>this.processProvider(s)),this.records.set(Pv,es(void 0,this)),i.has("environment")&&this.records.set(En,es(void 0,this));let o=this.records.get(qf);o!=null&&typeof o.value=="string"&&this.scopes.add(o.value),this.injectorDefTypes=new Set(this.get(Rv,Ea,{self:!0}))}retrieve(n,e){let r=bi(e)||0;try{return this.get(n,vi,r)}catch(i){if(Xo(i))return i;throw i}}destroy(){ba(this),this._destroyed=!0;let n=ge(null);try{for(let r of this._ngOnDestroyHooks)r.ngOnDestroy();let e=this._onDestroyHooks;this._onDestroyHooks=[];for(let r of e)r()}finally{this.records.clear(),this._ngOnDestroyHooks.clear(),this.injectorDefTypes.clear(),ge(n)}}onDestroy(n){return ba(this),this._onDestroyHooks.push(n),()=>this.removeOnDestroy(n)}runInContext(n){ba(this);let e=wn(this),r=jt(void 0),i;try{return n()}finally{wn(e),jt(r)}}get(n,e=vi,r){if(ba(this),n.hasOwnProperty(wT))return n[wT](this);let i=bi(r),o,s=wn(this),a=jt(void 0);try{if(!(i&4)){let u=this.records.get(n);if(u===void 0){let l=W8(n)&&Pf(n);l&&this.injectableDefInScope(l)?u=es(yv(n),If):u=null,this.records.set(n,u)}if(u!=null)return this.hydrate(n,u,i)}let c=i&2?Da():this.parent;return e=i&8&&e===vi?null:e,c.get(n,e)}catch(c){let u=N8(c);throw u===-200||u===-201?new Re(u,null):c}finally{jt(a),wn(s)}}resolveInjectorInitializers(){let n=ge(null),e=wn(this),r=jt(void 0),i;try{let o=this.get($f,Ea,{self:!0});for(let s of o)s()}finally{wn(e),jt(r),ge(n)}}toString(){let n=[],e=this.records;for(let r of e.keys())n.push(_i(r));return`R3Injector[${n.join(", ")}]`}processProvider(n){n=xt(n);let e=Df(n)?n:xt(n&&n.provide),r=H8(n);if(!Df(n)&&n.multi===!0){let i=this.records.get(e);i||(i=es(void 0,If,!0),i.factory=()=>gv(i.multi),this.records.set(e,i)),e=n,i.multi.push(n)}this.records.set(e,r)}hydrate(n,e,r){let i=ge(null);try{if(e.value===ET)throw Mv(_i(n));return e.value===If&&(e.value=ET,e.value=e.factory(void 0,r)),typeof e.value=="object"&&e.value&&V8(e.value)&&this._ngOnDestroyHooks.add(e.value),e.value}finally{ge(i)}}injectableDefInScope(n){if(!n.providedIn)return!1;let e=xt(n.providedIn);return typeof e=="string"?e==="any"||this.scopes.has(e):this.injectorDefTypes.has(e)}removeOnDestroy(n){let e=this._onDestroyHooks.indexOf(n);e!==-1&&this._onDestroyHooks.splice(e,1)}};function yv(t){let n=Pf(t),e=n!==null?n.factory:wi(t);if(e!==null)return e;if(t instanceof _e)throw new Re(-204,!1);if(t instanceof Function)return B8(t);throw new Re(-204,!1)}function B8(t){if(t.length>0)throw new Re(-204,!1);let e=O8(t);return e!==null?()=>e.factory(t):()=>new t}function H8(t){if(PT(t))return es(void 0,t.useValue);{let n=RT(t);return es(n,If)}}function RT(t,n,e){let r;if(Df(t)){let i=xt(t);return wi(i)||yv(i)}else if(PT(t))r=()=>xt(t.useValue);else if(q8(t))r=()=>t.useFactory(...gv(t.deps||[]));else if($8(t))r=(i,o)=>Hn(xt(t.useExisting),o!==void 0&&o&8?8:void 0);else{let i=xt(t&&(t.useClass||t.provide));if(U8(t))r=()=>new i(...gv(t.deps));else return wi(i)||yv(i)}return r}function ba(t){if(t.destroyed)throw new Re(-205,!1)}function es(t,n,e=!1){return{factory:t,value:n,multi:e?[]:void 0}}function U8(t){return!!t.deps}function V8(t){return t!==null&&typeof t=="object"&&typeof t.ngOnDestroy=="function"}function W8(t){return typeof t=="function"||typeof t=="object"&&t.ngMetadataName==="InjectionToken"}function vv(t,n){for(let e of t)Array.isArray(e)?vv(e,n):e&&xv(e)?vv(e.\u0275providers,n):n(e)}function Oa(t,n){let e;t instanceof Ei?(ba(t),e=t):e=new mv(t);let r,i=wn(e),o=jt(void 0);try{return n()}finally{wn(i),jt(o)}}function kT(){return OT()!==void 0||Cf()!=null}var Un=0,Ae=1,le=2,Ft=3,Vn=4,kr=5,Bf=6,Hf=7,$t=8,Ti=9,Wn=10,xi=11,ns=12,Lv=13,rs=14,Sn=15,Ma=16,Di=17,Uf=18,Lr=19,jv=20,Bn=21,Vf=22,Nr=23,qt=24,Wf=25,Aa=26,jr=27,LT=1;var Gf=7,jT=8,Na=9,Gn=10;function zn(t){return Array.isArray(t)&&typeof t[LT]=="object"}function Fr(t){return Array.isArray(t)&&t[LT]===!0}function Fv(t){return(t.flags&4)!==0}function zf(t){return t.componentOffset>-1}function is(t){return!!t.template}function os(t){return(t[le]&512)!==0}function Oi(t){return(t[le]&256)===256}var FT="svg",$T="math";function Mi(t){for(;Array.isArray(t);)t=t[Un];return t}function $v(t,n){return Mi(n[t.index])}function qv(t,n){return t.data[n]}function $r(t,n){let e=n[t];return zn(e)?e:e[Un]}function Kf(t){return(t[le]&128)===128}function Bv(t,n){return n==null?null:t[n]}function Hv(t){t[Di]=0}function Uv(t){t[le]&1024||(t[le]|=1024,Kf(t)&&ss(t))}function Pa(t){return!!(t[le]&9216||t[qt]?.dirty)}function Vv(t){t[Wn].changeDetectionScheduler?.notify(8),t[le]&64&&(t[le]|=1024),Pa(t)&&ss(t)}function ss(t){t[Wn].changeDetectionScheduler?.notify(0);let n=Si(t);for(;n!==null&&!(n[le]&8192||(n[le]|=8192,!Kf(n)));)n=Si(n)}function Wv(t,n){if(Oi(t))throw new Re(911,!1);t[Bn]===null&&(t[Bn]=[]),t[Bn].push(n)}function qT(t,n){if(t[Bn]===null)return;let e=t[Bn].indexOf(n);e!==-1&&t[Bn].splice(e,1)}function Si(t){let n=t[Ft];return Fr(n)?n[Ft]:n}var Je={lFrame:ZT(null),bindingsEnabled:!0,skipHydrationRootTNode:null};var _v=!1;function BT(){return Je.skipHydrationRootTNode!==null}function Ai(){return Je.lFrame.lView}function as(){let t=Gv();for(;t!==null&&t.type===64;)t=t.parent;return t}function Gv(){return Je.lFrame.currentTNode}function HT(){let t=Je.lFrame,n=t.currentTNode;return t.isParent?n:n.parent}function UT(t,n){let e=Je.lFrame;e.currentTNode=t,e.isParent=n}function VT(){return Je.lFrame.isParent}function zv(){return _v}function Ca(t){let n=_v;return _v=t,n}function WT(t){return Je.lFrame.bindingIndex=t}function GT(){return Je.lFrame.inI18n}function zT(t,n){let e=Je.lFrame;e.bindingIndex=e.bindingRootIndex=t,Yf(n)}function KT(){return Je.lFrame.currentDirectiveIndex}function Yf(t){Je.lFrame.currentDirectiveIndex=t}function Kv(t){Je.lFrame.currentQueryIndex=t}function G8(t){let n=t[Ae];return n.type===2?n.declTNode:n.type===1?t[kr]:null}function Yv(t,n,e){if(e&4){let i=n,o=t;for(;i=i.parent,i===null&&!(e&1);)if(i=G8(o),i===null||(o=o[rs],i.type&10))break;if(i===null)return!1;n=i,t=o}let r=Je.lFrame=YT();return r.currentTNode=n,r.lView=t,!0}function Zf(t){let n=YT(),e=t[Ae];Je.lFrame=n,n.currentTNode=e.firstChild,n.lView=t,n.tView=e,n.contextLView=t,n.bindingIndex=e.bindingStartIndex,n.inI18n=!1}function YT(){let t=Je.lFrame,n=t===null?null:t.child;return n===null?ZT(t):n}function ZT(t){let n={currentTNode:null,isParent:!0,lView:null,tView:null,selectedIndex:-1,contextLView:null,elementDepthCount:0,currentNamespace:null,currentDirectiveIndex:-1,bindingRootIndex:-1,bindingIndex:-1,currentQueryIndex:0,parent:t,child:null,inI18n:!1};return t!==null&&(t.child=n),n}function QT(){let t=Je.lFrame;return Je.lFrame=t.parent,t.currentTNode=null,t.lView=null,t}var Zv=QT;function Qf(){let t=QT();t.isParent=!0,t.tView=null,t.selectedIndex=-1,t.contextLView=null,t.elementDepthCount=0,t.currentDirectiveIndex=-1,t.currentNamespace=null,t.bindingRootIndex=-1,t.bindingIndex=-1,t.currentQueryIndex=0}function JT(){return Je.lFrame.selectedIndex}function qr(t){Je.lFrame.selectedIndex=t}function bv(t,n=null,e=null,r){let i=XT(t,n,e,r);return i.resolveInjectorInitializers(),i}function XT(t,n=null,e=null,r,i=new Set){let o=[e||Ea,MT(t)];return r=r||(typeof t=="object"?void 0:_i(t)),new Ei(o,n||Da(),r||null,i)}var sn=class t{static THROW_IF_NOT_FOUND=vi;static NULL=new Sa;static create(n,e){if(Array.isArray(n))return bv({name:""},e,n,"");{let r=n.name??"";return bv({name:r},n.parent,n.providers,r)}}static \u0275prov=N({token:t,providedIn:"any",factory:()=>Hn(Pv)});static __NG_ELEMENT_ID__=-1};var Kt=(()=>{class t{static __NG_ELEMENT_ID__=z8;static __NG_ENV_ID__=e=>e}return t})(),Of=class extends Kt{_lView;constructor(n){super(),this._lView=n}get destroyed(){return Oi(this._lView)}onDestroy(n){let e=this._lView;return Wv(e,n),()=>qT(e,n)}};function z8(){return new Of(Ai())}var ex=!1,tx=new _e(""),Ra=(()=>{class t{taskId=0;pendingTasks=new Set;destroyed=!1;pendingTask=new Rr.BehaviorSubject(!1);debugTaskTracker=w(tx,{optional:!0});get hasPendingTasks(){return this.destroyed?!1:this.pendingTask.value}get hasPendingTasksObservable(){return this.destroyed?new Rr.Observable(e=>{e.next(!1),e.complete()}):this.pendingTask}add(){!this.hasPendingTasks&&!this.destroyed&&this.pendingTask.next(!0);let e=this.taskId++;return this.pendingTasks.add(e),this.debugTaskTracker?.add(e),e}has(e){return this.pendingTasks.has(e)}remove(e){this.pendingTasks.delete(e),this.debugTaskTracker?.remove(e),this.pendingTasks.size===0&&this.hasPendingTasks&&this.pendingTask.next(!1)}ngOnDestroy(){this.pendingTasks.clear(),this.hasPendingTasks&&this.pendingTask.next(!1),this.destroyed=!0,this.pendingTask.unsubscribe()}static \u0275prov=N({token:t,providedIn:"root",factory:()=>new t})}return t})(),wv=class extends Rr.Subject{__isAsync;destroyRef=void 0;pendingTasks=void 0;constructor(n=!1){super(),this.__isAsync=n,kT()&&(this.destroyRef=w(Kt,{optional:!0})??void 0,this.pendingTasks=w(Ra,{optional:!0})??void 0)}emit(n){let e=ge(null);try{super.next(n)}finally{ge(e)}}subscribe(n,e,r){let i=n,o=e||(()=>null),s=r;if(n&&typeof n=="object"){let c=n;i=c.next?.bind(c),o=c.error?.bind(c),s=c.complete?.bind(c)}this.__isAsync&&(o=this.wrapInTimeout(o),i&&(i=this.wrapInTimeout(i)),s&&(s=this.wrapInTimeout(s)));let a=super.subscribe({next:i,error:o,complete:s});return n instanceof Rr.Subscription&&n.add(a),a}wrapInTimeout(n){return e=>{let r=this.pendingTasks?.add();setTimeout(()=>{try{n(e)}finally{r!==void 0&&this.pendingTasks?.remove(r)}})}}},qn=wv;function Mf(...t){}function Qv(t){let n,e;function r(){t=Mf;try{e!==void 0&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(e),n!==void 0&&clearTimeout(n)}catch{}}return n=setTimeout(()=>{t(),r()}),typeof requestAnimationFrame=="function"&&(e=requestAnimationFrame(()=>{t(),r()})),()=>r()}function nx(t){return queueMicrotask(()=>t()),()=>{t=Mf}}var Jv="isAngularZone",Ia=Jv+"_ID",K8=0,Pr=class t{hasPendingMacrotasks=!1;hasPendingMicrotasks=!1;isStable=!0;onUnstable=new qn(!1);onMicrotaskEmpty=new qn(!1);onStable=new qn(!1);onError=new qn(!1);constructor(n){let{enableLongStackTrace:e=!1,shouldCoalesceEventChangeDetection:r=!1,shouldCoalesceRunChangeDetection:i=!1,scheduleInRootZone:o=ex}=n;if(typeof Zone>"u")throw new Re(908,!1);Zone.assertZonePatched();let s=this;s._nesting=0,s._outer=s._inner=Zone.current,Zone.TaskTrackingZoneSpec&&(s._inner=s._inner.fork(new Zone.TaskTrackingZoneSpec)),e&&Zone.longStackTraceZoneSpec&&(s._inner=s._inner.fork(Zone.longStackTraceZoneSpec)),s.shouldCoalesceEventChangeDetection=!i&&r,s.shouldCoalesceRunChangeDetection=i,s.callbackScheduled=!1,s.scheduleInRootZone=o,Q8(s)}static isInAngularZone(){return typeof Zone<"u"&&Zone.current.get(Jv)===!0}static assertInAngularZone(){if(!t.isInAngularZone())throw new Re(909,!1)}static assertNotInAngularZone(){if(t.isInAngularZone())throw new Re(909,!1)}run(n,e,r){return this._inner.run(n,e,r)}runTask(n,e,r,i){let o=this._inner,s=o.scheduleEventTask("NgZoneEvent: "+i,n,Y8,Mf,Mf);try{return o.runTask(s,e,r)}finally{o.cancelTask(s)}}runGuarded(n,e,r){return this._inner.runGuarded(n,e,r)}runOutsideAngular(n){return this._outer.run(n)}},Y8={};function Xv(t){if(t._nesting==0&&!t.hasPendingMicrotasks&&!t.isStable)try{t._nesting++,t.onMicrotaskEmpty.emit(null)}finally{if(t._nesting--,!t.hasPendingMicrotasks)try{t.runOutsideAngular(()=>t.onStable.emit(null))}finally{t.isStable=!0}}}function Z8(t){if(t.isCheckStableRunning||t.callbackScheduled)return;t.callbackScheduled=!0;function n(){Qv(()=>{t.callbackScheduled=!1,Ev(t),t.isCheckStableRunning=!0,Xv(t),t.isCheckStableRunning=!1})}t.scheduleInRootZone?Zone.root.run(()=>{n()}):t._outer.run(()=>{n()}),Ev(t)}function Q8(t){let n=()=>{Z8(t)},e=K8++;t._inner=t._inner.fork({name:"angular",properties:{[Jv]:!0,[Ia]:e,[Ia+e]:!0},onInvokeTask:(r,i,o,s,a,c)=>{if(J8(c))return r.invokeTask(o,s,a,c);try{return ST(t),r.invokeTask(o,s,a,c)}finally{(t.shouldCoalesceEventChangeDetection&&s.type==="eventTask"||t.shouldCoalesceRunChangeDetection)&&n(),CT(t)}},onInvoke:(r,i,o,s,a,c,u)=>{try{return ST(t),r.invoke(o,s,a,c,u)}finally{t.shouldCoalesceRunChangeDetection&&!t.callbackScheduled&&!X8(c)&&n(),CT(t)}},onHasTask:(r,i,o,s)=>{r.hasTask(o,s),i===o&&(s.change=="microTask"?(t._hasPendingMicrotasks=s.microTask,Ev(t),Xv(t)):s.change=="macroTask"&&(t.hasPendingMacrotasks=s.macroTask))},onHandleError:(r,i,o,s)=>(r.handleError(o,s),t.runOutsideAngular(()=>t.onError.emit(s)),!1)})}function Ev(t){t._hasPendingMicrotasks||(t.shouldCoalesceEventChangeDetection||t.shouldCoalesceRunChangeDetection)&&t.callbackScheduled===!0?t.hasPendingMicrotasks=!0:t.hasPendingMicrotasks=!1}function ST(t){t._nesting++,t.isStable&&(t.isStable=!1,t.onUnstable.emit(null))}function CT(t){t._nesting--,Xv(t)}var Ta=class{hasPendingMicrotasks=!1;hasPendingMacrotasks=!1;isStable=!0;onUnstable=new qn;onMicrotaskEmpty=new qn;onStable=new qn;onError=new qn;run(n,e,r){return n.apply(e,r)}runGuarded(n,e,r){return n.apply(e,r)}runOutsideAngular(n){return n()}runTask(n,e,r,i){return n.apply(e,r)}};function J8(t){return rx(t,"__ignore_ng_zone__")}function X8(t){return rx(t,"__scheduler_tick__")}function rx(t,n){return!Array.isArray(t)||t.length!==1?!1:t[0]?.data?.[n]===!0}var xa=class{_console=console;handleError(n){this._console.error("ERROR",n)}},Jf=new _e("",{factory:()=>{let t=w(Pr),n=w(En),e;return r=>{t.runOutsideAngular(()=>{n.destroyed&&!e?setTimeout(()=>{throw r}):(e??=n.get(xa),e.handleError(r))})}}});function an(t,n){let[e,r,i]=sv(t,n?.equal),o=e,s=o[zt];return o.set=r,o.update=i,o.asReadonly=ix.bind(o),o}function ix(){let t=this[zt];if(t.readonlyFn===void 0){let n=()=>this();n[zt]=t,t.readonlyFn=n}return t.readonlyFn}var Xf=(()=>{class t{view;node;constructor(e,r){this.view=e,this.node=r}static __NG_ELEMENT_ID__=e6}return t})();function e6(){return new Xf(Ai(),as())}var Ci=class{},ka=new _e("",{factory:()=>!0});var e_=new _e("");var eh=(()=>{class t{static \u0275prov=N({token:t,providedIn:"root",factory:()=>new Sv})}return t})(),Sv=class{dirtyEffectCount=0;queues=new Map;add(n){this.enqueue(n),this.schedule(n)}schedule(n){n.dirty&&this.dirtyEffectCount++}remove(n){let e=n.zone,r=this.queues.get(e);r.has(n)&&(r.delete(n),n.dirty&&this.dirtyEffectCount--)}enqueue(n){let e=n.zone;this.queues.has(e)||this.queues.set(e,new Set);let r=this.queues.get(e);r.has(n)||r.add(n)}flush(){for(;this.dirtyEffectCount>0;){let n=!1;for(let[e,r]of this.queues)e===null?n||=this.flushQueue(r):n||=e.run(()=>this.flushQueue(r));n||(this.dirtyEffectCount=0)}}flushQueue(n){let e=!1;for(let r of n)r.dirty&&(this.dirtyEffectCount--,e=!0,r.run());return e}},Af=class{[zt];constructor(n){this[zt]=n}destroy(){this[zt].destroy()}};function t_(t,n){let e=n?.injector??w(sn),r=n?.manualCleanup!==!0?e.get(Kt):null,i,o=e.get(Xf,null,{optional:!0}),s=e.get(Ci);return o!==null?(i=r6(o.view,s,t),r instanceof Of&&r._lView===o.view&&(r=null)):i=i6(t,e.get(eh),s),i.injector=e,r!==null&&(i.onDestroyFns=[r.onDestroy(()=>i.destroy())]),new Af(i)}var ox={...uv,cleanupFns:void 0,zone:null,onDestroyFns:null,run(){let t=Ca(!1);try{lv(this)}finally{Ca(t)}},cleanup(){if(!this.cleanupFns?.length)return;let t=ge(null);try{for(;this.cleanupFns.length;)this.cleanupFns.pop()()}finally{this.cleanupFns=[],ge(t)}}},t6={...ox,consumerMarkedDirty(){this.scheduler.schedule(this),this.notifier.notify(12)},destroy(){if(Qo(this),this.onDestroyFns!==null)for(let t of this.onDestroyFns)t();this.cleanup(),this.scheduler.remove(this)}},n6={...ox,consumerMarkedDirty(){this.view[le]|=8192,ss(this.view),this.notifier.notify(13)},destroy(){if(Qo(this),this.onDestroyFns!==null)for(let t of this.onDestroyFns)t();this.cleanup(),this.view[Nr]?.delete(this)}};function r6(t,n,e){let r=Object.create(n6);return r.view=t,r.zone=typeof Zone<"u"?Zone.current:null,r.notifier=n,r.fn=sx(r,e),t[Nr]??=new Set,t[Nr].add(r),r.consumerMarkedDirty(r),r}function i6(t,n,e){let r=Object.create(t6);return r.fn=sx(r,t),r.scheduler=n,r.notifier=e,r.zone=typeof Zone<"u"?Zone.current:null,r.scheduler.add(r),r.notifier.notify(12),r}function sx(t,n){return()=>{n(e=>(t.cleanupFns??=[]).push(e))}}function La(t){return cv(t)}var dh=U(Q(),1);var Dx=U(Ni(),1);function Ox(t){return{toString:t}.toString()}function Mx(t,n,e,r){n!==null?n.applyValueToInputSignal(n,r):t[e]=r}var oh=class{previousValue;currentValue;firstChange;constructor(n,e,r){this.previousValue=n,this.currentValue=e,this.firstChange=r}isFirstChange(){return this.firstChange}};function R5(t){return t.type.prototype.ngOnChanges&&(t.setInput=L5),k5}function k5(){let t=Nx(this),n=t?.current;if(n){let e=t.previous;if(e===Ff)t.previous=n;else for(let r in n)e[r]=n[r];t.current=null,this.ngOnChanges(n)}}function L5(t,n,e,r,i){let o=this.declaredInputs[r],s=Nx(t)||j5(t,{previous:Ff,current:null}),a=s.current||(s.current={}),c=s.previous,u=c[o];a[o]=new oh(u&&u.currentValue,e,c===Ff),Mx(t,n,i,e)}var Ax="__ngSimpleChanges__";function Nx(t){return t[Ax]||null}function j5(t,n){return t[Ax]=n}var lx=[];var Ke=function(t,n=null,e){for(let r=0;r<lx.length;r++){let i=lx[r];i(t,n,e)}},Be=(function(t){return t[t.TemplateCreateStart=0]="TemplateCreateStart",t[t.TemplateCreateEnd=1]="TemplateCreateEnd",t[t.TemplateUpdateStart=2]="TemplateUpdateStart",t[t.TemplateUpdateEnd=3]="TemplateUpdateEnd",t[t.LifecycleHookStart=4]="LifecycleHookStart",t[t.LifecycleHookEnd=5]="LifecycleHookEnd",t[t.OutputStart=6]="OutputStart",t[t.OutputEnd=7]="OutputEnd",t[t.BootstrapApplicationStart=8]="BootstrapApplicationStart",t[t.BootstrapApplicationEnd=9]="BootstrapApplicationEnd",t[t.BootstrapComponentStart=10]="BootstrapComponentStart",t[t.BootstrapComponentEnd=11]="BootstrapComponentEnd",t[t.ChangeDetectionStart=12]="ChangeDetectionStart",t[t.ChangeDetectionEnd=13]="ChangeDetectionEnd",t[t.ChangeDetectionSyncStart=14]="ChangeDetectionSyncStart",t[t.ChangeDetectionSyncEnd=15]="ChangeDetectionSyncEnd",t[t.AfterRenderHooksStart=16]="AfterRenderHooksStart",t[t.AfterRenderHooksEnd=17]="AfterRenderHooksEnd",t[t.ComponentStart=18]="ComponentStart",t[t.ComponentEnd=19]="ComponentEnd",t[t.DeferBlockStateStart=20]="DeferBlockStateStart",t[t.DeferBlockStateEnd=21]="DeferBlockStateEnd",t[t.DynamicComponentStart=22]="DynamicComponentStart",t[t.DynamicComponentEnd=23]="DynamicComponentEnd",t[t.HostBindingsUpdateStart=24]="HostBindingsUpdateStart",t[t.HostBindingsUpdateEnd=25]="HostBindingsUpdateEnd",t})(Be||{});function F5(t,n,e){let{ngOnChanges:r,ngOnInit:i,ngDoCheck:o}=n.type.prototype;if(r){let s=R5(n);(e.preOrderHooks??=[]).push(t,s),(e.preOrderCheckHooks??=[]).push(t,s)}i&&(e.preOrderHooks??=[]).push(0-t,i),o&&((e.preOrderHooks??=[]).push(t,o),(e.preOrderCheckHooks??=[]).push(t,o))}function $5(t,n){for(let e=n.directiveStart,r=n.directiveEnd;e<r;e++){let o=t.data[e].type.prototype,{ngAfterContentInit:s,ngAfterContentChecked:a,ngAfterViewInit:c,ngAfterViewChecked:u,ngOnDestroy:l}=o;s&&(t.contentHooks??=[]).push(-e,s),a&&((t.contentHooks??=[]).push(e,a),(t.contentCheckHooks??=[]).push(e,a)),c&&(t.viewHooks??=[]).push(-e,c),u&&((t.viewHooks??=[]).push(e,u),(t.viewCheckHooks??=[]).push(e,u)),l!=null&&(t.destroyHooks??=[]).push(e,l)}}function nh(t,n,e){Px(t,n,3,e)}function rh(t,n,e,r){(t[le]&3)===e&&Px(t,n,e,r)}function n_(t,n){let e=t[le];(e&3)===n&&(e&=16383,e+=1,t[le]=e)}function Px(t,n,e,r){let i=r!==void 0?t[Di]&65535:0,o=r??-1,s=n.length-1,a=0;for(let c=i;c<s;c++)if(typeof n[c+1]=="number"){if(a=n[c],r!=null&&a>=r)break}else n[c]<0&&(t[Di]+=65536),(a<o||o==-1)&&(q5(t,e,n,c),t[Di]=(t[Di]&4294901760)+c+2),c++}function dx(t,n){Ke(Be.LifecycleHookStart,t,n);let e=ge(null);try{n.call(t)}finally{ge(e),Ke(Be.LifecycleHookEnd,t,n)}}function q5(t,n,e,r){let i=e[r]<0,o=e[r+1],s=i?-e[r]:e[r],a=t[s];i?t[le]>>14<t[Di]>>16&&(t[le]&3)===n&&(t[le]+=16384,dx(a,o)):dx(a,o)}var us=-1,ja=class{factory;name;injectImpl;resolving=!1;canSeeViewProviders;multi;componentProviders;index;providerFactory;constructor(n,e,r,i){this.factory=n,this.name=i,this.canSeeViewProviders=e,this.injectImpl=r}};function B5(t,n,e){let r=0;for(;r<e.length;){let i=e[r];if(typeof i=="number"){if(i!==0)break;r++;let o=e[r++],s=e[r++],a=e[r++];t.setAttribute(n,s,a,o)}else{let o=i,s=e[++r];H5(o)?t.setProperty(n,o,s):t.setAttribute(n,o,s),r++}}return r}function H5(t){return t.charCodeAt(0)===64}function Rx(t,n){if(!(n===null||n.length===0))if(t===null||t.length===0)t=n.slice();else{let e=-1;for(let r=0;r<n.length;r++){let i=n[r];typeof i=="number"?e=i:e===0||(e===-1||e===2?fx(t,e,i,null,n[++r]):fx(t,e,i,null,null))}}return t}function fx(t,n,e,r,i){let o=0,s=t.length;if(n===-1)s=-1;else for(;o<t.length;){let a=t[o++];if(typeof a=="number"){if(a===n){s=-1;break}else if(a>n){s=o-1;break}}}for(;o<t.length;){let a=t[o];if(typeof a=="number")break;if(a===e){i!==null&&(t[o+1]=i);return}o++,i!==null&&o++}s!==-1&&(t.splice(s,0,n),o=s+1),t.splice(o++,0,e),i!==null&&t.splice(o++,0,i)}function U5(t){return t!==us}function s_(t){return t&32767}function V5(t){return t>>16}function a_(t,n){let e=V5(t),r=n;for(;e>0;)r=r[rs],e--;return r}var c_=!0;function hx(t){let n=c_;return c_=t,n}var W5=256,kx=W5-1,Lx=5,G5=0,Cn={};function z5(t,n,e){let r;typeof e=="string"?r=e.charCodeAt(0)||0:e.hasOwnProperty(Ii)&&(r=e[Ii]),r==null&&(r=e[Ii]=G5++);let i=r&kx,o=1<<i;n.data[t+(i>>Lx)]|=o}function jx(t,n){let e=Fx(t,n);if(e!==-1)return e;let r=n[Ae];r.firstCreatePass&&(t.injectorIndex=n.length,r_(r.data,t),r_(n,null),r_(r.blueprint,null));let i=$x(t,n),o=t.injectorIndex;if(U5(i)){let s=s_(i),a=a_(i,n),c=a[Ae].data;for(let u=0;u<8;u++)n[o+u]=a[s+u]|c[s+u]}return n[o+8]=i,o}function r_(t,n){t.push(0,0,0,0,0,0,0,0,n)}function Fx(t,n){return t.injectorIndex===-1||t.parent&&t.parent.injectorIndex===t.injectorIndex||n[t.injectorIndex+8]===null?-1:t.injectorIndex}function $x(t,n){if(t.parent&&t.parent.injectorIndex!==-1)return t.parent.injectorIndex;let e=0,r=null,i=n;for(;i!==null;){if(r=Vx(i),r===null)return us;if(e++,i=i[rs],r.injectorIndex!==-1)return r.injectorIndex|e<<16}return us}function K5(t,n,e){z5(t,n,e)}function qx(t,n,e){if(e&8||t!==void 0)return t;Lf(n,"NodeInjector")}function Bx(t,n,e,r){if(e&8&&r===void 0&&(r=null),(e&3)===0){let i=t[Ti],o=jt(void 0);try{return i?i.get(n,r,e&8):Av(n,r,e&8)}finally{jt(o)}}return qx(r,n,e)}function Hx(t,n,e,r=0,i){if(t!==null){if(n[le]&2048&&!(r&2)){let s=X5(t,n,e,r,Cn);if(s!==Cn)return s}let o=Ux(t,n,e,r,Cn);if(o!==Cn)return o}return Bx(n,e,r,i)}function Ux(t,n,e,r,i){let o=Q5(e);if(typeof o=="function"){if(!Yv(n,t,r))return r&1?qx(i,e,r):Bx(n,e,r,i);try{let s;if(s=o(r),s==null&&!(r&8))Lf(e);else return s}finally{Zv()}}else if(typeof o=="number"){let s=null,a=Fx(t,n),c=us,u=r&1?n[Sn][kr]:null;for((a===-1||r&4)&&(c=a===-1?$x(t,n):n[a+8],c===us||!mx(r,!1)?a=-1:(s=n[Ae],a=s_(c),n=a_(c,n)));a!==-1;){let l=n[Ae];if(px(o,a,l.data)){let d=Y5(a,n,e,s,r,u);if(d!==Cn)return d}c=n[a+8],c!==us&&mx(r,n[Ae].data[a+8]===u)&&px(o,a,n)?(s=l,a=s_(c),n=a_(c,n)):a=-1}}return i}function Y5(t,n,e,r,i,o){let s=n[Ae],a=s.data[t+8],c=r==null?zf(a)&&c_:r!=s&&(a.type&3)!==0,u=i&1&&o===a,l=Z5(a,s,e,c,u);return l!==null?u_(n,s,l,a,i):Cn}function Z5(t,n,e,r,i){let o=t.providerIndexes,s=n.data,a=o&1048575,c=t.directiveStart,u=t.directiveEnd,l=o>>20,d=r?a:a+l,f=i?a+l:u;for(let p=d;p<f;p++){let m=s[p];if(p<c&&e===m||p>=c&&m.type===e)return p}if(i){let p=s[c];if(p&&is(p)&&p.type===e)return c}return null}function u_(t,n,e,r,i){let o=t[e],s=n.data;if(o instanceof ja){let a=o;if(a.resolving)throw Mv("");let c=hx(a.canSeeViewProviders);a.resolving=!0;let u=s[e].type||s[e],l,d=a.injectImpl?jt(a.injectImpl):null,f=Yv(t,r,0);try{o=t[e]=a.factory(void 0,i,s,t,r),n.firstCreatePass&&e>=r.directiveStart&&F5(e,s[e],n)}finally{d!==null&&jt(d),hx(c),a.resolving=!1,Zv()}}return o}function Q5(t){if(typeof t=="string")return t.charCodeAt(0)||0;let n=t.hasOwnProperty(Ii)?t[Ii]:void 0;return typeof n=="number"?n>=0?n&kx:J5:n}function px(t,n,e){let r=1<<t;return!!(e[n+(t>>Lx)]&r)}function mx(t,n){return!(t&2)&&!(t&1&&n)}var sh=class{_tNode;_lView;constructor(n,e){this._tNode=n,this._lView=e}get(n,e,r){return Hx(this._tNode,this._lView,n,bi(r),e)}};function J5(){return new sh(as(),Ai())}function Bt(t){return Ox(()=>{let n=t.prototype.constructor,e=n[wa]||l_(n),r=Object.prototype,i=Object.getPrototypeOf(t.prototype).constructor;for(;i&&i!==r;){let o=i[wa]||l_(i);if(o&&o!==e)return o;i=Object.getPrototypeOf(i)}return o=>new o})}function l_(t){return Tv(t)?()=>{let n=l_(xt(t));return n&&n()}:wi(t)}function X5(t,n,e,r,i){let o=t,s=n;for(;o!==null&&s!==null&&s[le]&2048&&!os(s);){let a=Ux(o,s,e,r|2,Cn);if(a!==Cn)return a;let c=o.parent;if(!c){let u=s[jv];if(u){let l=u.get(e,Cn,r);if(l!==Cn)return l}c=Vx(s),s=s[rs]}o=c}return i}function Vx(t){let n=t[Ae],e=n.type;return e===2?n.declTNode:e===1?t[kr]:null}function eY(){return Wx(as(),Ai())}function Wx(t,n){return new Gx($v(t,n))}var Gx=(()=>{class t{nativeElement;constructor(e){this.nativeElement=e}static __NG_ELEMENT_ID__=eY}return t})();function tY(t){return(t.flags&128)===128}var zx=new Map,nY=0;function rY(){return nY++}function iY(t){zx.set(t[Lr],t)}function d_(t){zx.delete(t[Lr])}var gx="__ngContext__";function C_(t,n){zn(n)?(t[gx]=n[Lr],iY(n)):t[gx]=n}function Kx(t){return Zx(t[ns])}function Yx(t){return Zx(t[Vn])}function Zx(t){for(;t!==null&&!Fr(t);)t=t[Vn];return t}var Qx=!1,oY=new _e("",{factory:()=>Qx});function sY(t){return(t.flags&32)===32}var aY=()=>null;function Jx(t,n,e=!1){return aY(t,n,e)}function Xx(t,n){let e=t.contentQueries;if(e!==null){let r=ge(null);try{for(let i=0;i<e.length;i+=2){let o=e[i],s=e[i+1];if(s!==-1){let a=t.data[s];Kv(o),a.contentQueries(2,n[s],s)}}}finally{ge(r)}}}function f_(t,n,e){Kv(0);let r=ge(null);try{n(t,e)}finally{ge(r)}}function cY(t,n,e){if(Fv(n)){let r=ge(null);try{let i=n.directiveStart,o=n.directiveEnd;for(let s=i;s<o;s++){let a=t.data[s];if(a.contentQueries){let c=e[s];a.contentQueries(1,c,s)}}}finally{ge(r)}}}var h_=(function(t){return t[t.Emulated=0]="Emulated",t[t.None=2]="None",t[t.ShadowDom=3]="ShadowDom",t[t.ExperimentalIsolatedShadowDom=4]="ExperimentalIsolatedShadowDom",t})(h_||{});function uY(t,n,e){return t.createElement(n,e)}function yx(t,n,e,r,i){t.insertBefore(n,e,r,i)}function lY(t,n,e){t.appendChild(n,e)}function dY(t,n,e,r){t.removeChild(null,n,e,r)}function fY(t,n,e){t.setAttribute(n,"style",e)}function hY(t,n,e){e===""?t.removeAttribute(n,"class"):t.setAttribute(n,"class",e)}function pY(t,n,e){let{mergedAttrs:r,classes:i,styles:o}=e;r!==null&&B5(t,n,r),i!==null&&hY(t,n,i),o!==null&&fY(t,n,o)}var mY="ng-template";function gY(t){return t.type===4&&t.value!==mY}function p_(t){return(t&1)===0}function vx(t,n){return t?":not("+n.trim()+")":n}function yY(t){let n=t[0],e=1,r=2,i="",o=!1;for(;e<t.length;){let s=t[e];if(typeof s=="string")if(r&2){let a=t[++e];i+="["+s+(a.length>0?'="'+a+'"':"")+"]"}else r&8?i+="."+s:r&4&&(i+=" "+s);else i!==""&&!p_(s)&&(n+=vx(o,i),i=""),r=s,o=o||!p_(r);e++}return i!==""&&(n+=vx(o,i)),n}function vY(t){return t.map(yY).join(",")}function _Y(t){let n=[],e=[],r=1,i=2;for(;r<t.length;){let o=t[r];if(typeof o=="string")i===2?o!==""&&n.push(o,t[++r]):i===8&&e.push(o);else{if(!p_(i))break;i=o}r++}return e.length&&n.push(1,...e),n}var I_={};function e0(t,n,e,r,i,o,s,a,c,u,l){let d=jr+r,f=d+i,p=bY(d,f),m=typeof u=="function"?u():u;return p[Ae]={type:t,blueprint:p,template:e,queries:null,viewQuery:a,declTNode:n,data:p.slice().fill(null,d),bindingStartIndex:d,expandoStartIndex:f,hostBindingOpCodes:null,firstCreatePass:!0,firstUpdatePass:!0,staticViewQueries:!1,staticContentQueries:!1,preOrderHooks:null,preOrderCheckHooks:null,contentHooks:null,contentCheckHooks:null,viewHooks:null,viewCheckHooks:null,destroyHooks:null,cleanup:null,contentQueries:null,components:null,directiveRegistry:typeof o=="function"?o():o,pipeRegistry:typeof s=="function"?s():s,firstChild:null,schemas:c,consts:m,incompleteFirstPass:!1,ssrId:l}}function bY(t,n){let e=[];for(let r=0;r<n;r++)e.push(r<t?null:I_);return e}function wY(t){let n=t.tView;return n===null||n.incompleteFirstPass?t.tView=e0(1,null,t.template,t.decls,t.vars,t.directiveDefs,t.pipeDefs,t.viewQuery,t.schemas,t.consts,t.id):n}function t0(t,n,e,r,i,o,s,a,c,u,l){let d=n.blueprint.slice();return d[Un]=i,d[le]=r|4|128|8|64|1024,(u!==null||t&&t[le]&2048)&&(d[le]|=2048),Hv(d),d[Ft]=d[rs]=t,d[$t]=e,d[Wn]=s||t&&t[Wn],d[xi]=a||t&&t[xi],d[Ti]=c||t&&t[Ti]||null,d[kr]=o,d[Lr]=rY(),d[Bf]=l,d[jv]=u,d[Sn]=n.type==2?t[Sn]:d,d}function EY(t,n,e){let r=$v(n,t),i=wY(e),o=t[Wn].rendererFactory,s=SY(t,t0(t,i,null,n0(e),r,n,null,o.createRenderer(r,e),null,null,null));return t[n.index]=s}function n0(t){let n=16;return t.signals?n=4096:t.onPush&&(n=64),n}function r0(t,n,e,r){if(e===0)return-1;let i=n.length;for(let o=0;o<e;o++)n.push(r),t.blueprint.push(r),t.data.push(null);return i}function SY(t,n){return t[ns]?t[Lv][Vn]=n:t[ns]=n,t[Lv]=n,n}function CY(t,n,e,r){if(!r)if((n[le]&3)===3){let o=t.preOrderCheckHooks;o!==null&&nh(n,o,e)}else{let o=t.preOrderHooks;o!==null&&rh(n,o,0,e)}qr(e)}var T_=(function(t){return t[t.None=0]="None",t[t.SignalBased=1]="SignalBased",t[t.HasDecoratorInputTransform=2]="HasDecoratorInputTransform",t})(T_||{});function m_(t,n,e,r){let i=ge(null);try{let[o,s,a]=t.inputs[e],c=null;(s&T_.SignalBased)!==0&&(c=n[o][zt]),c!==null&&c.transformFn!==void 0?r=c.transformFn(r):a!==null&&(r=a.call(n,r)),t.setInput!==null?t.setInput(n,c,r,e,o):Mx(n,c,o,r)}finally{ge(i)}}var IY;function i0(t,n){return IY(t,n)}var ah=new Set,x_=(function(t){return t[t.CHANGE_DETECTION=0]="CHANGE_DETECTION",t[t.AFTER_NEXT_RENDER=1]="AFTER_NEXT_RENDER",t})(x_||{}),o0=new _e(""),_x=new Set;function TY(t){_x.has(t)||(_x.add(t),performance?.mark?.("mark_feature_usage",{detail:{feature:t}}))}var xY=(()=>{class t{impl=null;execute(){this.impl?.execute()}static \u0275prov=N({token:t,providedIn:"root",factory:()=>new t})}return t})();var s0=new _e("",{factory:()=>({queue:new Set,isScheduled:!1,scheduler:null,injector:w(En)})});function a0(t,n,e){let r=t.get(s0);if(Array.isArray(n))for(let i of n)r.queue.add(i),e?.detachedLeaveAnimationFns?.push(i);else r.queue.add(n),e?.detachedLeaveAnimationFns?.push(n);r.scheduler&&r.scheduler(t)}function DY(t,n){for(let[e,r]of n)a0(t,r.animateFns)}function OY(t,n){let e=t.get(s0);if(Array.isArray(n))for(let r of n)e.queue.delete(r);else e.queue.delete(n)}function bx(t,n,e,r){let i=t?.[Aa]?.enter;n!==null&&i&&i.has(e.index)&&DY(r,i)}function cs(t,n,e,r,i,o,s,a){if(i!=null){let c,u=!1;Fr(i)?c=i:zn(i)&&(u=!0,i=i[Un]);let l=Mi(i);t===0&&r!==null?(bx(a,r,o,e),s==null?lY(n,r,l):yx(n,r,l,s||null,!0)):t===1&&r!==null?(bx(a,r,o,e),yx(n,r,l,s||null,!0)):t===2?wx(a,o,e,d=>{dY(n,l,u,d)}):t===3&&wx(a,o,e,()=>{n.destroyNode(l)}),c!=null&&FY(n,t,e,c,o,r,s)}}function MY(t,n){c0(t,n),n[Un]=null,n[kr]=null}function c0(t,n){n[Wn].changeDetectionScheduler?.notify(9),M_(t,n,n[xi],2,null,null)}function AY(t){let n=t[ns];if(!n)return i_(t[Ae],t);for(;n;){let e=null;if(zn(n))e=n[ns];else{let r=n[Gn];r&&(e=r)}if(!e){for(;n&&!n[Vn]&&n!==t;)zn(n)&&i_(n[Ae],n),n=n[Ft];n===null&&(n=t),zn(n)&&i_(n[Ae],n),e=n&&n[Vn]}n=e}}function D_(t,n){let e=t[Na],r=e.indexOf(n);e.splice(r,1)}function NY(t,n){if(Oi(n))return;let e=n[xi];e.destroyNode&&M_(t,n,e,3,null,null),AY(n)}function i_(t,n){if(Oi(n))return;let e=ge(null);try{n[le]&=-129,n[le]|=256,n[qt]&&Qo(n[qt]),kY(t,n),RY(t,n),n[Ae].type===1&&n[xi].destroy();let r=n[Ma];if(r!==null&&Fr(n[Ft])){r!==n[Ft]&&D_(r,n);let i=n[Uf];i!==null&&i.detachView(t)}d_(n)}finally{ge(e)}}function wx(t,n,e,r){let i=t?.[Aa];if(i?.enter?.has(n.index)&&OY(e,i.enter.get(n.index).animateFns),i==null||i.leave==null||!i.leave.has(n.index))return r(!1);t&&ah.add(t[Lr]),a0(e,()=>{if(i.leave&&i.leave.has(n.index)){let s=i.leave.get(n.index),a=[];if(s){for(let c=0;c<s.animateFns.length;c++){let u=s.animateFns[c],{promise:l}=u();a.push(l)}i.detachedLeaveAnimationFns=void 0}i.running=Promise.allSettled(a),PY(t,r)}else t&&ah.delete(t[Lr]),r(!1)},i)}function PY(t,n){let e=t[Aa]?.running;if(e){e.then(()=>{t[Aa].running=void 0,ah.delete(t[Lr]),n(!0)});return}n(!1)}function RY(t,n){let e=t.cleanup,r=n[Hf];if(e!==null)for(let s=0;s<e.length-1;s+=2)if(typeof e[s]=="string"){let a=e[s+3];a>=0?r[a]():r[-a].unsubscribe(),s+=2}else{let a=r[e[s+1]];e[s].call(a)}r!==null&&(n[Hf]=null);let i=n[Bn];if(i!==null){n[Bn]=null;for(let s=0;s<i.length;s++){let a=i[s];a()}}let o=n[Nr];if(o!==null){n[Nr]=null;for(let s of o)s.destroy()}}function kY(t,n){let e;if(t!=null&&(e=t.destroyHooks)!=null)for(let r=0;r<e.length;r+=2){let i=n[e[r]];if(!(i instanceof ja)){let o=e[r+1];if(Array.isArray(o))for(let s=0;s<o.length;s+=2){let a=i[o[s]],c=o[s+1];Ke(Be.LifecycleHookStart,a,c);try{c.call(a)}finally{Ke(Be.LifecycleHookEnd,a,c)}}else{Ke(Be.LifecycleHookStart,i,o);try{o.call(i)}finally{Ke(Be.LifecycleHookEnd,i,o)}}}}}function LY(t,n){if(n!==null){let r=t[Sn][kr],i=n.projection;return r.projection[i]}return null}function O_(t,n,e,r,i,o,s){for(;e!=null;){let a=r[Ti];if(e.type===128){e=e.next;continue}let c=r[e.index],u=e.type;if(s&&n===0&&(c&&C_(Mi(c),r),e.flags|=2),!sY(e))if(u&8)O_(t,n,e.child,r,i,o,!1),cs(n,t,a,i,c,e,o,r);else if(u&32){let l=i0(e,r),d;for(;d=l();)cs(n,t,a,i,d,e,o,r);cs(n,t,a,i,c,e,o,r)}else u&16?jY(t,n,r,e,i,o):cs(n,t,a,i,c,e,o,r);e=s?e.projectionNext:e.next}}function M_(t,n,e,r,i,o){O_(e,r,t.firstChild,n,i,o,!1)}function jY(t,n,e,r,i,o){let s=e[Sn],c=s[kr].projection[r.projection];if(Array.isArray(c))for(let u=0;u<c.length;u++){let l=c[u];cs(n,t,e[Ti],i,l,r,o,e)}else{let u=c,l=s[Ft];tY(r)&&(u.flags|=128),O_(t,n,u,l,i,o,!0)}}function FY(t,n,e,r,i,o,s){let a=r[Gf],c=Mi(r);a!==c&&cs(n,t,e,o,a,i,s);for(let u=Gn;u<r.length;u++){let l=r[u];M_(l[Ae],l,t,n,o,a)}}function u0(t,n,e,r,i){let o=JT(),s=r&2;try{qr(-1),s&&n.length>jr&&CY(t,n,jr,!1);let a=s?Be.TemplateUpdateStart:Be.TemplateCreateStart;Ke(a,i,e),e(r,i)}finally{qr(o);let a=s?Be.TemplateUpdateEnd:Be.TemplateCreateEnd;Ke(a,i,e)}}function $Y(t,n,e){UY(t,n,e),(e.flags&64)===64&&VY(t,n,e)}function qY(t,n,e,r){let o=r.get(oY,Qx)||e===h_.ShadowDom||e===h_.ExperimentalIsolatedShadowDom,s=t.selectRootElement(n,o);return BY(s),s}function BY(t){HY(t)}var HY=()=>null;function UY(t,n,e){let r=e.directiveStart,i=e.directiveEnd;zf(e)&&EY(n,e,t.data[r+e.componentOffset]),t.firstCreatePass||jx(e,n);let o=e.initialInputs;for(let s=r;s<i;s++){let a=t.data[s],c=u_(n,t,s,e);if(C_(c,n),o!==null&&GY(n,s-r,c,a,e,o),is(a)){let u=$r(e.index,n);u[$t]=u_(n,t,s,e)}}}function VY(t,n,e){let r=e.directiveStart,i=e.directiveEnd,o=e.index,s=KT();try{qr(o);for(let a=r;a<i;a++){let c=t.data[a],u=n[a];Yf(a),(c.hostBindings!==null||c.hostVars!==0||c.hostAttrs!==null)&&WY(c,u)}}finally{qr(-1),Yf(s)}}function WY(t,n){t.hostBindings!==null&&t.hostBindings(1,n)}function GY(t,n,e,r,i,o){let s=o[n];if(s!==null)for(let a=0;a<s.length;a+=2){let c=s[a],u=s[a+1];m_(r,e,c,u)}}function zY(t,n,e,r,i){let o=t.inputs?.[r],s=t.hostDirectiveInputs?.[r],a=!1;if(s)for(let c=0;c<s.length;c+=2){let u=s[c],l=s[c+1],d=n.data[u];m_(d,e[u],l,i),a=!0}if(o)for(let c of o){let u=e[c],l=n.data[c];m_(l,u,r,i),a=!0}return a}function KY(t,n){let e=$r(n,t),r=e[Ae];YY(r,e);let i=e[Un];i!==null&&e[Bf]===null&&(e[Bf]=Jx(i,e[Ti])),Ke(Be.ComponentStart);try{l0(r,e,e[$t])}finally{Ke(Be.ComponentEnd,e[$t])}}function YY(t,n){for(let e=n.length;e<t.blueprint.length;e++)n.push(t.blueprint[e])}function l0(t,n,e){Zf(n);try{let r=t.viewQuery;r!==null&&f_(1,r,e);let i=t.template;i!==null&&u0(t,n,i,1,e),t.firstCreatePass&&(t.firstCreatePass=!1),n[Uf]?.finishViewCreation(t),t.staticContentQueries&&Xx(t,n),t.staticViewQueries&&f_(2,t.viewQuery,e);let o=t.components;o!==null&&ZY(n,o)}catch(r){throw t.firstCreatePass&&(t.incompleteFirstPass=!0,t.firstCreatePass=!1),r}finally{n[le]&=-5,Qf()}}function ZY(t,n){for(let e=0;e<n.length;e++)KY(t,n[e])}function ch(t,n,e,r,i=!1){for(;e!==null;){if(e.type===128){e=i?e.projectionNext:e.next;continue}let o=n[e.index];o!==null&&r.push(Mi(o)),Fr(o)&&QY(o,r);let s=e.type;if(s&8)ch(t,n,e.child,r);else if(s&32){let a=i0(e,n),c;for(;c=a();)r.push(c)}else if(s&16){let a=LY(n,e);if(Array.isArray(a))r.push(...a);else{let c=Si(n[Sn]);ch(c[Ae],c,a,r,!0)}}e=i?e.projectionNext:e.next}return r}function QY(t,n){for(let e=Gn;e<t.length;e++){let r=t[e],i=r[Ae].firstChild;i!==null&&ch(r[Ae],r,i,n)}t[Gf]!==t[Un]&&n.push(t[Gf])}function d0(t){if(t[Wf]!==null){for(let n of t[Wf])n.impl.addSequence(n);t[Wf].length=0}}var f0=[];function JY(t){return t[qt]??XY(t)}function XY(t){let n=f0.pop()??Object.create(t9);return n.lView=t,n}function e9(t){t.lView[qt]!==t&&(t.lView=null,f0.push(t))}var t9={...Zo,consumerIsAlwaysLive:!0,kind:"template",consumerMarkedDirty:t=>{ss(t.lView)},consumerOnSignalRead(){this.lView[qt]=this}};function n9(t){let n=t[qt]??Object.create(r9);return n.lView=t,n}var r9={...Zo,consumerIsAlwaysLive:!0,kind:"template",consumerMarkedDirty:t=>{let n=Si(t.lView);for(;n&&!h0(n[Ae]);)n=Si(n);n&&Uv(n)},consumerOnSignalRead(){this.lView[qt]=this}};function h0(t){return t.type!==2}function p0(t){if(t[Nr]===null)return;let n=!0;for(;n;){let e=!1;for(let r of t[Nr])r.dirty&&(e=!0,r.zone===null||Zone.current===r.zone?r.run():r.zone.run(()=>r.run()));n=e&&!!(t[le]&8192)}}var i9=100;function m0(t,n=0){let r=t[Wn].rendererFactory,i=!1;i||r.begin?.();try{o9(t,n)}finally{i||r.end?.()}}function o9(t,n){let e=zv();try{Ca(!0),g_(t,n);let r=0;for(;Pa(t);){if(r===i9)throw new Re(103,!1);r++,g_(t,1)}}finally{Ca(e)}}function s9(t,n,e,r){if(Oi(n))return;let i=n[le],o=!1,s=!1;Zf(n);let a=!0,c=null,u=null;o||(h0(t)?(u=JY(n),c=_a(u)):bf()===null?(a=!1,u=n9(n),c=_a(u)):n[qt]&&(Qo(n[qt]),n[qt]=null));try{Hv(n),WT(t.bindingStartIndex),e!==null&&u0(t,n,e,2,r);let l=(i&3)===3;if(!o)if(l){let p=t.preOrderCheckHooks;p!==null&&nh(n,p,null)}else{let p=t.preOrderHooks;p!==null&&rh(n,p,0,null),n_(n,0)}if(s||a9(n),p0(n),g0(n,0),t.contentQueries!==null&&Xx(t,n),!o)if(l){let p=t.contentCheckHooks;p!==null&&nh(n,p)}else{let p=t.contentHooks;p!==null&&rh(n,p,1),n_(n,1)}u9(t,n);let d=t.components;d!==null&&v0(n,d,0);let f=t.viewQuery;if(f!==null&&f_(2,f,r),!o)if(l){let p=t.viewCheckHooks;p!==null&&nh(n,p)}else{let p=t.viewHooks;p!==null&&rh(n,p,2),n_(n,2)}if(t.firstUpdatePass===!0&&(t.firstUpdatePass=!1),n[Vf]){for(let p of n[Vf])p();n[Vf]=null}o||(d0(n),n[le]&=-73)}catch(l){throw o||ss(n),l}finally{u!==null&&(wf(u,c),a&&e9(u)),Qf()}}function g0(t,n){for(let e=Kx(t);e!==null;e=Yx(e))for(let r=Gn;r<e.length;r++){let i=e[r];y0(i,n)}}function a9(t){for(let n=Kx(t);n!==null;n=Yx(n)){if(!(n[le]&2))continue;let e=n[Na];for(let r=0;r<e.length;r++){let i=e[r];Uv(i)}}}function c9(t,n,e){Ke(Be.ComponentStart);let r=$r(n,t);try{y0(r,e)}finally{Ke(Be.ComponentEnd,r[$t])}}function y0(t,n){Kf(t)&&g_(t,n)}function g_(t,n){let r=t[Ae],i=t[le],o=t[qt],s=!!(n===0&&i&16);if(s||=!!(i&64&&n===0),s||=!!(i&1024),s||=!!(o?.dirty&&Ef(o)),s||=!1,o&&(o.dirty=!1),t[le]&=-9217,s)s9(r,t,r.template,t[$t]);else if(i&8192){let a=ge(null);try{p0(t),g0(t,1);let c=r.components;c!==null&&v0(t,c,1),d0(t)}finally{ge(a)}}}function v0(t,n,e){for(let r=0;r<n.length;r++)c9(t,n[r],e)}function u9(t,n){let e=t.hostBindingOpCodes;if(e!==null)try{for(let r=0;r<e.length;r++){let i=e[r];if(i<0)qr(~i);else{let o=i,s=e[++r],a=e[++r];zT(s,o);let c=n[o];Ke(Be.HostBindingsUpdateStart,c);try{a(2,c)}finally{Ke(Be.HostBindingsUpdateEnd,c)}}}}finally{qr(-1)}}function _0(t,n){let e=zv()?64:1088;for(t[Wn].changeDetectionScheduler?.notify(n);t;){t[le]|=e;let r=Si(t);if(os(t)&&!r)return t;t=r}return null}function l9(t,n){if(t.length<=Gn)return;let e=Gn+n,r=t[e];if(r){let i=r[Ma];i!==null&&i!==t&&D_(i,r),n>0&&(t[e-1][Vn]=r[Vn]);let o=Nv(t,Gn+n);MY(r[Ae],r);let s=o[Uf];s!==null&&s.detachView(o[Ae]),r[Ft]=null,r[Vn]=null,r[le]&=-129}return r}function d9(t,n){let e=t[Na],r=n[Ft];if(zn(r))t[le]|=2;else{let i=r[Ft][Sn];n[Sn]!==i&&(t[le]|=2)}e===null?t[Na]=[n]:e.push(n)}var y_=class{_lView;_cdRefInjectingView;_appRef=null;_attachedToViewContainer=!1;exhaustive;get rootNodes(){let n=this._lView,e=n[Ae];return ch(e,n,e.firstChild,[])}constructor(n,e){this._lView=n,this._cdRefInjectingView=e}get context(){return this._lView[$t]}set context(n){this._lView[$t]=n}get destroyed(){return Oi(this._lView)}destroy(){if(this._appRef)this._appRef.detachView(this);else if(this._attachedToViewContainer){let n=this._lView[Ft];if(Fr(n)){let e=n[jT],r=e?e.indexOf(this):-1;r>-1&&(l9(n,r),Nv(e,r))}this._attachedToViewContainer=!1}NY(this._lView[Ae],this._lView)}onDestroy(n){Wv(this._lView,n)}markForCheck(){_0(this._cdRefInjectingView||this._lView,4)}detach(){this._lView[le]&=-129}reattach(){Vv(this._lView),this._lView[le]|=128}detectChanges(){this._lView[le]|=1024,m0(this._lView)}checkNoChanges(){}attachToViewContainerRef(){if(this._appRef)throw new Re(902,!1);this._attachedToViewContainer=!0}detachFromAppRef(){this._appRef=null;let n=os(this._lView),e=this._lView[Ma];e!==null&&!n&&D_(e,this._lView),c0(this._lView[Ae],this._lView)}attachToAppRef(n){if(this._attachedToViewContainer)throw new Re(902,!1);this._appRef=n;let e=os(this._lView),r=this._lView[Ma];r!==null&&!e&&d9(r,this._lView),Vv(this._lView)}};function f9(t,n,e,r,i){let o=t.data[n];if(o===null)o=h9(t,n,e,r,i),GT()&&(o.flags|=32);else if(o.type&64){o.type=e,o.value=r,o.attrs=i;let s=HT();o.injectorIndex=s===null?-1:s.injectorIndex}return UT(o,!0),o}function h9(t,n,e,r,i){let o=Gv(),s=VT(),a=s?o:o&&o.parent,c=t.data[n]=m9(t,a,e,n,r,i);return p9(t,c,o,s),c}function p9(t,n,e,r){t.firstChild===null&&(t.firstChild=n),e!==null&&(r?e.child==null&&n.parent!==null&&(e.child=n):e.next===null&&(e.next=n,n.prev=e))}function m9(t,n,e,r,i,o){let s=n?n.injectorIndex:-1,a=0;return BT()&&(a|=128),{type:e,index:r,insertBeforeIndex:null,injectorIndex:s,directiveStart:-1,directiveEnd:-1,directiveStylingLast:-1,componentOffset:-1,fieldIndex:-1,customControlIndex:-1,propertyBindings:null,flags:a,providerIndexes:0,value:i,attrs:o,mergedAttrs:null,localNames:null,initialInputs:null,inputs:null,hostDirectiveInputs:null,outputs:null,hostDirectiveOutputs:null,directiveToIndex:null,tView:null,next:null,prev:null,projectionNext:null,child:null,parent:n,projection:null,styles:null,stylesWithoutHost:null,residualStyles:void 0,classes:null,classesWithoutHost:null,residualClasses:void 0,classBindings:0,styleBindings:0}}var b0=class{},fh=class{},v_=class{resolveComponentFactory(n){throw new Re(917,!1)}},hh=class{static NULL=new v_},Fa=class{};var w0=(()=>{class t{static \u0275prov=N({token:t,providedIn:"root",factory:()=>null})}return t})();var ih={},__=class{injector;parentInjector;constructor(n,e){this.injector=n,this.parentInjector=e}get(n,e,r){let i=this.injector.get(n,ih,r);return i!==ih||e===ih?i:this.parentInjector.get(n,e,r)}};function Ex(t,n,e){let r=e?t.styles:null,i=e?t.classes:null,o=0;if(n!==null)for(let s=0;s<n.length;s++){let a=n[s];if(typeof a=="number")o=a;else if(o==1)i=Iv(i,a);else if(o==2){let c=a,u=n[++s];r=Iv(r,c+": "+u+";")}}e?t.styles=r:t.stylesWithoutHost=r,e?t.classes=i:t.classesWithoutHost=i}function E0(t,n=0){let e=Ai();if(e===null)return Hn(t,n);let r=as();return Hx(r,e,xt(t),n)}function g9(t,n,e,r,i){let o=r===null?null:{"":-1},s=i(t,e);if(s!==null){let a=s,c=null,u=null;for(let l of s)if(l.resolveHostDirectives!==null){[a,c,u]=l.resolveHostDirectives(s);break}_9(t,n,e,a,o,c,u)}o!==null&&r!==null&&y9(e,r,o)}function y9(t,n,e){let r=t.localNames=[];for(let i=0;i<n.length;i+=2){let o=e[n[i+1]];if(o==null)throw new Re(-301,!1);r.push(n[i],o)}}function v9(t,n,e){n.componentOffset=e,(t.components??=[]).push(n.index)}function _9(t,n,e,r,i,o,s){let a=r.length,c=null;for(let f=0;f<a;f++){let p=r[f];c===null&&is(p)&&(c=p,v9(t,e,f)),K5(jx(e,n),t,p.type)}I9(e,t.data.length,a),c?.viewProvidersResolver&&c.viewProvidersResolver(c);for(let f=0;f<a;f++){let p=r[f];p.providersResolver&&p.providersResolver(p)}let u=!1,l=!1,d=r0(t,n,a,null);a>0&&(e.directiveToIndex=new Map);for(let f=0;f<a;f++){let p=r[f];if(e.mergedAttrs=Rx(e.mergedAttrs,p.hostAttrs),w9(t,e,n,d,p),C9(d,p,i),s!==null&&s.has(p)){let[y,b]=s.get(p);e.directiveToIndex.set(p.type,[d,y+e.directiveStart,b+e.directiveStart])}else(o===null||!o.has(p))&&e.directiveToIndex.set(p.type,d);p.contentQueries!==null&&(e.flags|=4),(p.hostBindings!==null||p.hostAttrs!==null||p.hostVars!==0)&&(e.flags|=64);let m=p.type.prototype;!u&&(m.ngOnChanges||m.ngOnInit||m.ngDoCheck)&&((t.preOrderHooks??=[]).push(e.index),u=!0),!l&&(m.ngOnChanges||m.ngDoCheck)&&((t.preOrderCheckHooks??=[]).push(e.index),l=!0),d++}b9(t,e,o)}function b9(t,n,e){for(let r=n.directiveStart;r<n.directiveEnd;r++){let i=t.data[r];if(e===null||!e.has(i))Sx(0,n,i,r),Sx(1,n,i,r),Ix(n,r,!1);else{let o=e.get(i);Cx(0,n,o,r),Cx(1,n,o,r),Ix(n,r,!0)}}}function Sx(t,n,e,r){let i=t===0?e.inputs:e.outputs;for(let o in i)if(i.hasOwnProperty(o)){let s;t===0?s=n.inputs??={}:s=n.outputs??={},s[o]??=[],s[o].push(r),S0(n,o)}}function Cx(t,n,e,r){let i=t===0?e.inputs:e.outputs;for(let o in i)if(i.hasOwnProperty(o)){let s=i[o],a;t===0?a=n.hostDirectiveInputs??={}:a=n.hostDirectiveOutputs??={},a[s]??=[],a[s].push(r,o),S0(n,s)}}function S0(t,n){n==="class"?t.flags|=8:n==="style"&&(t.flags|=16)}function Ix(t,n,e){let{attrs:r,inputs:i,hostDirectiveInputs:o}=t;if(r===null||!e&&i===null||e&&o===null||gY(t)){t.initialInputs??=[],t.initialInputs.push(null);return}let s=null,a=0;for(;a<r.length;){let c=r[a];if(c===0){a+=4;continue}else if(c===5){a+=2;continue}else if(typeof c=="number")break;if(!e&&i.hasOwnProperty(c)){let u=i[c];for(let l of u)if(l===n){s??=[],s.push(c,r[a+1]);break}}else if(e&&o.hasOwnProperty(c)){let u=o[c];for(let l=0;l<u.length;l+=2)if(u[l]===n){s??=[],s.push(u[l+1],r[a+1]);break}}a+=2}t.initialInputs??=[],t.initialInputs.push(s)}function w9(t,n,e,r,i){t.data[r]=i;let o=i.factory||(i.factory=wi(i.type,!0)),s=new ja(o,is(i),E0,null);t.blueprint[r]=s,e[r]=s,E9(t,n,r,r0(t,e,i.hostVars,I_),i)}function E9(t,n,e,r,i){let o=i.hostBindings;if(o){let s=t.hostBindingOpCodes;s===null&&(s=t.hostBindingOpCodes=[]);let a=~n.index;S9(s)!=a&&s.push(a),s.push(e,r,o)}}function S9(t){let n=t.length;for(;n>0;){let e=t[--n];if(typeof e=="number"&&e<0)return e}return 0}function C9(t,n,e){if(e){if(n.exportAs)for(let r=0;r<n.exportAs.length;r++)e[n.exportAs[r]]=t;is(n)&&(e[""]=t)}}function I9(t,n,e){t.flags|=1,t.directiveStart=n,t.directiveEnd=n+e,t.providerIndexes=n}function T9(t,n,e,r,i,o,s,a){let c=n[Ae],u=c.consts,l=Bv(u,s),d=f9(c,t,e,r,l);return o&&g9(c,n,d,Bv(u,a),i),d.mergedAttrs=Rx(d.mergedAttrs,d.attrs),d.attrs!==null&&Ex(d,d.attrs,!1),d.mergedAttrs!==null&&Ex(d,d.mergedAttrs,!0),c.queries!==null&&c.queries.elementStart(c,d),d}function x9(t,n){$5(t,n),Fv(n)&&t.queries.elementEnd(n)}var b_=Symbol("BINDING");var w_=class extends hh{ngModule;constructor(n){super(),this.ngModule=n}resolveComponentFactory(n){let e=kf(n);return new E_(e,this.ngModule)}};function D9(t){return Object.keys(t).map(n=>{let[e,r,i]=t[n],o={propName:e,templateName:n,isSignal:(r&T_.SignalBased)!==0};return i&&(o.transform=i),o})}function O9(t){return Object.keys(t).map(n=>({propName:t[n],templateName:n}))}function M9(t,n,e){let r=n instanceof En?n:n?.injector;return r&&t.getStandaloneInjector!==null&&(r=t.getStandaloneInjector(r)||r),r?new __(e,r):e}function A9(t){let n=t.get(Fa,null);if(n===null)throw new Re(407,!1);let e=t.get(w0,null),r=t.get(Ci,null);return{rendererFactory:n,sanitizer:e,changeDetectionScheduler:r,ngReflect:!1}}function N9(t,n){let e=C0(t);return uY(n,e,e==="svg"?FT:e==="math"?$T:null)}function C0(t){return(t.selectors[0][0]||"div").toLowerCase()}var E_=class extends fh{componentDef;ngModule;selector;componentType;ngContentSelectors;isBoundToModule;cachedInputs=null;cachedOutputs=null;get inputs(){return this.cachedInputs??=D9(this.componentDef.inputs),this.cachedInputs}get outputs(){return this.cachedOutputs??=O9(this.componentDef.outputs),this.cachedOutputs}constructor(n,e){super(),this.componentDef=n,this.ngModule=e,this.componentType=n.type,this.selector=vY(n.selectors),this.ngContentSelectors=n.ngContentSelectors??[],this.isBoundToModule=!!e}create(n,e,r,i,o,s){Ke(Be.DynamicComponentStart);let a=ge(null);try{let c=this.componentDef,u=P9(r,c,s,o),l=M9(c,i||this.ngModule,n),d=A9(l),f=d.rendererFactory.createRenderer(null,c),p=r?qY(f,r,c.encapsulation,l):N9(c,f),m=s?.some(Tx)||o?.some(E=>typeof E!="function"&&E.bindings.some(Tx)),y=t0(null,u,null,512|n0(c),null,null,d,f,l,null,Jx(p,l,!0));y[jr]=p,Zf(y);let b=null;try{let E=T9(jr,y,2,"#host",()=>u.directiveRegistry,!0,0);pY(f,p,E),C_(p,y),$Y(u,y,E),cY(u,E,y),x9(u,E),e!==void 0&&k9(E,this.ngContentSelectors,e),b=$r(E.index,y),y[$t]=b[$t],l0(u,y,null)}catch(E){throw b!==null&&d_(b),d_(y),E}finally{Ke(Be.DynamicComponentEnd),Qf()}return new uh(this.componentType,y,!!m)}finally{ge(a)}}};function P9(t,n,e,r){let i=t?["ng-version","21.1.6"]:_Y(n.selectors[0]),o=null,s=null,a=0;if(e)for(let l of e)a+=l[b_].requiredVars,l.create&&(l.targetIdx=0,(o??=[]).push(l)),l.update&&(l.targetIdx=0,(s??=[]).push(l));if(r)for(let l=0;l<r.length;l++){let d=r[l];if(typeof d!="function")for(let f of d.bindings){a+=f[b_].requiredVars;let p=l+1;f.create&&(f.targetIdx=p,(o??=[]).push(f)),f.update&&(f.targetIdx=p,(s??=[]).push(f))}}let c=[n];if(r)for(let l of r){let d=typeof l=="function"?l:l.type,f=IT(d);c.push(f)}return e0(0,null,R9(o,s),1,a,c,null,null,null,[i],null)}function R9(t,n){return!t&&!n?null:e=>{if(e&1&&t)for(let r of t)r.create();if(e&2&&n)for(let r of n)r.update()}}function Tx(t){let n=t[b_].kind;return n==="input"||n==="twoWay"}var uh=class extends b0{_rootLView;_hasInputBindings;instance;hostView;changeDetectorRef;componentType;location;previousInputValues=null;_tNode;constructor(n,e,r){super(),this._rootLView=e,this._hasInputBindings=r,this._tNode=qv(e[Ae],jr),this.location=Wx(this._tNode,e),this.instance=$r(this._tNode.index,e)[$t],this.hostView=this.changeDetectorRef=new y_(e,void 0),this.componentType=n}setInput(n,e){this._hasInputBindings;let r=this._tNode;if(this.previousInputValues??=new Map,this.previousInputValues.has(n)&&Object.is(this.previousInputValues.get(n),e))return;let i=this._rootLView,o=zY(r,i[Ae],i,n,e);this.previousInputValues.set(n,e);let s=$r(r.index,i);_0(s,1)}get injector(){return new sh(this._tNode,this._rootLView)}destroy(){this.hostView.destroy()}onDestroy(n){this.hostView.onDestroy(n)}};function k9(t,n,e){let r=t.projection=[];for(let i=0;i<n.length;i++){let o=e[i];r.push(o!=null&&o.length?Array.from(o):null)}}var lh=class{};var S_=class extends lh{injector;componentFactoryResolver=new w_(this);instance=null;constructor(n){super();let e=new Ei([...n.providers,{provide:lh,useValue:this},{provide:hh,useValue:this.componentFactoryResolver}],n.parent||Da(),n.debugName,new Set(["environment"]));this.injector=e,n.runEnvironmentInitializers&&e.resolveInjectorInitializers()}destroy(){this.injector.destroy()}onDestroy(n){this.injector.onDestroy(n)}};function A_(t,n,e=null){return new S_({providers:t,parent:n,debugName:e,runEnvironmentInitializers:!0}).injector}var I0=new _e("");function L9(t){return!!t&&typeof t.then=="function"}function T0(t){return!!t&&typeof t.subscribe=="function"}var x0=new _e("");var j9=(()=>{class t{resolve;reject;initialized=!1;done=!1;donePromise=new Promise((e,r)=>{this.resolve=e,this.reject=r});appInits=w(x0,{optional:!0})??[];injector=w(sn);constructor(){}runInitializers(){if(this.initialized)return;let e=[];for(let i of this.appInits){let o=Oa(this.injector,i);if(L9(o))e.push(o);else if(T0(o)){let s=new Promise((a,c)=>{o.subscribe({complete:a,error:c})});e.push(s)}}let r=()=>{this.done=!0,this.resolve()};Promise.all(e).then(()=>{r()}).catch(i=>{this.reject(i)}),e.length===0&&r(),this.initialized=!0}static \u0275fac=function(r){return new(r||t)};static \u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})(),F9=new _e("");function D0(t){return t.isBoundToModule}var $9=10;var q9=(()=>{class t{_runningTick=!1;_destroyed=!1;_destroyListeners=[];_views=[];internalErrorHandler=w(Jf);afterRenderManager=w(xY);zonelessEnabled=w(ka);rootEffectScheduler=w(eh);dirtyFlags=0;tracingSnapshot=null;allTestViews=new Set;autoDetectTestViews=new Set;includeAllTestViews=!1;afterTick=new dh.Subject;get allViews(){return[...(this.includeAllTestViews?this.allTestViews:this.autoDetectTestViews).keys(),...this._views]}get destroyed(){return this._destroyed}componentTypes=[];components=[];internalPendingTask=w(Ra);get isStable(){return this.internalPendingTask.hasPendingTasksObservable.pipe((0,Dx.map)(e=>!e))}constructor(){w(o0,{optional:!0})}whenStable(){let e;return new Promise(r=>{e=this.isStable.subscribe({next:i=>{i&&r()}})}).finally(()=>{e.unsubscribe()})}_injector=w(En);_rendererFactory=null;get injector(){return this._injector}bootstrap(e,r){return this.bootstrapImpl(e,r)}bootstrapImpl(e,r,i=sn.NULL){return this._injector.get(Pr).run(()=>{Ke(Be.BootstrapComponentStart);let s=e instanceof fh;if(!this._injector.get(j9).done){let m="";throw new Re(405,m)}let c;s?c=e:c=this._injector.get(hh).resolveComponentFactory(e),this.componentTypes.push(c.componentType);let u=D0(c)?void 0:this._injector.get(lh),l=r||c.selector,d=c.create(i,[],l,u),f=d.location.nativeElement,p=d.injector.get(I0,null);return p?.registerApplication(f),d.onDestroy(()=>{this.detachView(d.hostView),o_(this.components,d),p?.unregisterApplication(f)}),this._loadComponent(d),Ke(Be.BootstrapComponentEnd,d),d})}tick(){this.zonelessEnabled||(this.dirtyFlags|=1),this._tick()}_tick(){Ke(Be.ChangeDetectionStart),this.tracingSnapshot!==null?this.tracingSnapshot.run(x_.CHANGE_DETECTION,this.tickImpl):this.tickImpl()}tickImpl=()=>{if(this._runningTick)throw Ke(Be.ChangeDetectionEnd),new Re(101,!1);let e=ge(null);try{this._runningTick=!0,this.synchronize()}finally{this._runningTick=!1,this.tracingSnapshot?.dispose(),this.tracingSnapshot=null,ge(e),this.afterTick.next(),Ke(Be.ChangeDetectionEnd)}};synchronize(){this._rendererFactory===null&&!this._injector.destroyed&&(this._rendererFactory=this._injector.get(Fa,null,{optional:!0}));let e=0;for(;this.dirtyFlags!==0&&e++<$9;){Ke(Be.ChangeDetectionSyncStart);try{this.synchronizeOnce()}finally{Ke(Be.ChangeDetectionSyncEnd)}}}synchronizeOnce(){this.dirtyFlags&16&&(this.dirtyFlags&=-17,this.rootEffectScheduler.flush());let e=!1;if(this.dirtyFlags&7){let r=!!(this.dirtyFlags&1);this.dirtyFlags&=-8,this.dirtyFlags|=8;for(let{_lView:i}of this.allViews){if(!r&&!Pa(i))continue;let o=r&&!this.zonelessEnabled?0:1;m0(i,o),e=!0}if(this.dirtyFlags&=-5,this.syncDirtyFlagsWithViews(),this.dirtyFlags&23)return}e||(this._rendererFactory?.begin?.(),this._rendererFactory?.end?.()),this.dirtyFlags&8&&(this.dirtyFlags&=-9,this.afterRenderManager.execute()),this.syncDirtyFlagsWithViews()}syncDirtyFlagsWithViews(){if(this.allViews.some(({_lView:e})=>Pa(e))){this.dirtyFlags|=2;return}else this.dirtyFlags&=-8}attachView(e){let r=e;this._views.push(r),r.attachToAppRef(this)}detachView(e){let r=e;o_(this._views,r),r.detachFromAppRef()}_loadComponent(e){this.attachView(e.hostView);try{this.tick()}catch(i){this.internalErrorHandler(i)}this.components.push(e),this._injector.get(F9,[]).forEach(i=>i(e))}ngOnDestroy(){if(!this._destroyed)try{this._destroyListeners.forEach(e=>e()),this._views.slice().forEach(e=>e.destroy())}finally{this._destroyed=!0,this._views=[],this._destroyListeners=[]}}onDestroy(e){return this._destroyListeners.push(e),()=>o_(this._destroyListeners,e)}destroy(){if(this._destroyed)throw new Re(406,!1);let e=this._injector;e.destroy&&!e.destroyed&&e.destroy()}get viewCount(){return this._views.length}static \u0275fac=function(r){return new(r||t)};static \u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})();function o_(t,n){let e=t.indexOf(n);e>-1&&t.splice(e,1)}var xle=(typeof ngServerMode>"u"||!ngServerMode)&&typeof document<"u"&&typeof document?.documentElement?.getAnimations=="function";var B9=(()=>{class t{applicationErrorHandler=w(Jf);appRef=w(q9);taskService=w(Ra);ngZone=w(Pr);zonelessEnabled=w(ka);tracing=w(o0,{optional:!0});zoneIsDefined=typeof Zone<"u"&&!!Zone.root.run;schedulerTickApplyArgs=[{data:{__scheduler_tick__:!0}}];subscriptions=new dh.Subscription;angularZoneId=this.zoneIsDefined?this.ngZone._inner?.get(Ia):null;scheduleInRootZone=!this.zonelessEnabled&&this.zoneIsDefined&&(w(e_,{optional:!0})??!1);cancelScheduledCallback=null;useMicrotaskScheduler=!1;runningTick=!1;pendingRenderTaskId=null;constructor(){this.subscriptions.add(this.appRef.afterTick.subscribe(()=>{let e=this.taskService.add();if(!this.runningTick&&(this.cleanup(),!this.zonelessEnabled||this.appRef.includeAllTestViews)){this.taskService.remove(e);return}this.switchToMicrotaskScheduler(),this.taskService.remove(e)})),this.subscriptions.add(this.ngZone.onUnstable.subscribe(()=>{this.runningTick||this.cleanup()}))}switchToMicrotaskScheduler(){this.ngZone.runOutsideAngular(()=>{let e=this.taskService.add();this.useMicrotaskScheduler=!0,queueMicrotask(()=>{this.useMicrotaskScheduler=!1,this.taskService.remove(e)})})}notify(e){if(!this.zonelessEnabled&&e===5)return;switch(e){case 0:{this.appRef.dirtyFlags|=2;break}case 3:case 2:case 4:case 5:case 1:{this.appRef.dirtyFlags|=4;break}case 6:{this.appRef.dirtyFlags|=2;break}case 12:{this.appRef.dirtyFlags|=16;break}case 13:{this.appRef.dirtyFlags|=2;break}case 11:break;default:this.appRef.dirtyFlags|=8}if(this.appRef.tracingSnapshot=this.tracing?.snapshot(this.appRef.tracingSnapshot)??null,!this.shouldScheduleTick())return;let r=this.useMicrotaskScheduler?nx:Qv;this.pendingRenderTaskId=this.taskService.add(),this.scheduleInRootZone?this.cancelScheduledCallback=Zone.root.run(()=>r(()=>this.tick())):this.cancelScheduledCallback=this.ngZone.runOutsideAngular(()=>r(()=>this.tick()))}shouldScheduleTick(){return!(this.appRef.destroyed||this.pendingRenderTaskId!==null||this.runningTick||this.appRef._runningTick||!this.zonelessEnabled&&this.zoneIsDefined&&Zone.current.get(Ia+this.angularZoneId))}tick(){if(this.runningTick||this.appRef.destroyed)return;if(this.appRef.dirtyFlags===0){this.cleanup();return}!this.zonelessEnabled&&this.appRef.dirtyFlags&7&&(this.appRef.dirtyFlags|=1);let e=this.taskService.add();try{this.ngZone.run(()=>{this.runningTick=!0,this.appRef._tick()},void 0,this.schedulerTickApplyArgs)}catch(r){this.applicationErrorHandler(r)}finally{this.taskService.remove(e),this.cleanup()}}ngOnDestroy(){this.subscriptions.unsubscribe(),this.cleanup()}cleanup(){if(this.runningTick=!1,this.cancelScheduledCallback?.(),this.cancelScheduledCallback=null,this.pendingRenderTaskId!==null){let e=this.pendingRenderTaskId;this.pendingRenderTaskId=null,this.taskService.remove(e)}}static \u0275fac=function(r){return new(r||t)};static \u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})();function N_(){return TY("NgZoneless"),ts([...H9(),[]])}function H9(){return[{provide:Ci,useExisting:B9},{provide:Pr,useClass:Ta},{provide:ka,useValue:!0}]}function dt(t,n){return Sf(t,n?.equal)}var z9=1e4;var dge=z9-1e3;function O0(t=[]){return K9(t)}function K9(t=[]){let n=t.map(r=>Y9(r)?r:ts([r]));n.push(ts([{provide:qf,useValue:"root"}])),n.push(N_());let e=A_(n,null);return Promise.resolve(e)}function Y9(t){return"\u0275providers"in t}async function P_(t,n,e=[],r){let i=t.getKeyPair(),o=t.getPeerId(),s=await n.toUuid(i.publicKey),a={};a[s]=i.publicKey;let c={};for(let u of e){if(!u)continue;let l=await n.toUuid(u);a[l]=u;let d=r?.[u];d&&(c[l]=d)}return{peerId:o,publicKey:i.publicKey,signalingId:s,privateKey:i.privateKey,peers:a,...r?{peersMeta:c}:{}}}async function $a(t){let n=new TextEncoder().encode(t),e=await crypto.subtle.digest("SHA-256",n),r=new Uint8Array(e).slice(0,16);r[0]=32,r[1]=1,r[2]=0,r[3]=42,r[6]=r[6]&15|128,r[8]=r[8]&63|128;let i=Array.from(r).map(o=>o.toString(16).padStart(2,"0")).join("");return[i.slice(0,8),i.slice(8,12),i.slice(12,16),i.slice(16,20),i.slice(20,32)].join("-")}var M0={maxAgeMs:3e4,now:()=>Date.now()};function A0(t){return new ReadableStream({start(n){n.enqueue(t),n.close()}})}async function N0(t){return new Uint8Array(await new Response(t).arrayBuffer())}async function P0(t){let n=new CompressionStream("deflate-raw");return N0(A0(t).pipeThrough(n))}async function R0(t){let n=new DecompressionStream("deflate-raw");return N0(A0(t).pipeThrough(n))}var ls=(()=>{class t{async getPeerId(e){return $a(e.publicKey)}bufferToBase64(e){let r=new Uint8Array(e),i="";for(let o=0;o<r.length;o++)i+=String.fromCharCode(r[o]);return btoa(i)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();var Hr=(()=>{class t{async encrypt(e,r){return this.encryptBytes(new TextEncoder().encode(e),r)}async decrypt(e,r,i){return new TextDecoder().decode(await this.decryptBytes(e,r,i))}base64ToBuffer(e){let r=atob(e),i=new Uint8Array(r.length);for(let o=0;o<r.length;o++)i[o]=r.charCodeAt(o);return i.buffer}bufferToBase64(e){let r=new Uint8Array(e),i="";for(let o=0;o<r.length;o++)i+=String.fromCharCode(r[o]);return btoa(i)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();var Ur=(()=>{class t{async sha256(e){let r=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(i)).map(s=>s.toString(16).padStart(2,"0")).join("")}async toUuid(e){let r=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",r),o=new Uint8Array(i).slice(0,16);o[0]=32,o[1]=1,o[2]=0,o[3]=42,o[6]=o[6]&15|128,o[8]=o[8]&63|128;let s=Array.from(o).map(a=>a.toString(16).padStart(2,"0")).join("");return[s.slice(0,8),s.slice(8,12),s.slice(12,16),s.slice(16,20),s.slice(20,32)].join("-")}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var R_=(()=>{class t extends Ur{static{this.\u0275fac=(()=>{let e;return function(i){return(e||(e=Bt(t)))(i||t)}})()}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();var Pi=(()=>{class t{canonicalStringify(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?"["+e.map(o=>this.canonicalStringify(o)).join(",")+"]":"{"+Object.keys(e).sort().filter(o=>e[o]!==void 0).map(o=>JSON.stringify(o)+":"+this.canonicalStringify(e[o])).join(",")+"}"}async sign(e,r){let i=this.canonicalStringify(e),o=await this.createSignature(i,r);return{payload:e,signature:o}}async verify(e,r){try{let i=this.canonicalStringify(e.payload);return await this.verifySignature(i,e.signature,r)?{valid:!0,verifiedBy:r}:{valid:!1,error:"Signature verification failed"}}catch(i){return{valid:!1,error:`Verification error: ${i}`}}}validateTimestamp(e,r=M0){let o=(r.now?r.now():Date.now())-e;return o>=0&&o<=r.maxAgeMs}base64ToBuffer(e){let r=atob(e),i=new Uint8Array(r.length);for(let o=0;o<r.length;o++)i[o]=r.charCodeAt(o);return i.buffer}bufferToBase64(e){let r=new Uint8Array(e),i="";for(let o=0;o<r.length;o++)i+=String.fromCharCode(r[o]);return btoa(i)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();var ds=(()=>{class t{static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();var k0=(()=>{class t{constructor(){this.keyGenerator=w(ls),this.storage=w(ds),this.keyPair=null,this.peerId=null,this._initialized=an(!1)}async initialize(){if(this._initialized())return;let e=await this.storage.load();e?this.keyPair=e:(this.keyPair=await this.keyGenerator.generateKeyPair(),await this.storage.save(this.keyPair)),this.peerId=await $a(this.keyPair.publicKey),this._initialized.set(!0)}getKeyPair(){if(!this.keyPair)throw new Error("KeyManager not initialized");return this.keyPair}getPeerId(){if(!this.peerId)throw new Error("KeyManager not initialized");return this.peerId}isInitialized(){return this._initialized()}async waitForInitialization(e=1e4){if(this._initialized())return;let r=Date.now(),i=50;return new Promise((o,s)=>{let a=()=>{if(this._initialized()){o();return}if(Date.now()-r>e){s(new Error("KeyManager initialization timeout"));return}setTimeout(a,i)};a()})}async reset(){await this.storage.delete(),this.keyPair=null,this.peerId=null,this._initialized.set(!1),await this.initialize()}async rotateKeyPair(){if(!this.keyPair)throw new Error("KeyManager not initialized");await this.storage.saveBackup(this.keyPair,Date.now());let e=await this.keyGenerator.generateKeyPair();return await this.storage.save(e),this.keyPair=e,this.peerId=await $a(e.publicKey),e}async getBackupKeyPairs(){return this.storage.loadBackups()}async cleanupOldBackups(e=10080*60*1e3){await this.storage.cleanupBackups(e)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var fs=new _e("SIGNALING_CHANNELS");function hs(t){return[{provide:fs,useFactory:t,multi:!0}]}function In(t){return typeof t=="object"&&t!==null&&"encrypted"in t&&"iv"in t&&typeof t.encrypted=="string"&&typeof t.iv=="string"}var qa=new _e("SIGNALING_MESSAGE_SENDER");function L0(t){return"lost"in t&&t.lost===!0}var He=(function(t){return t[t.DEBUG=0]="DEBUG",t[t.INFO=1]="INFO",t[t.WARN=2]="WARN",t[t.ERROR=3]="ERROR",t[t.FATAL=4]="FATAL",t})(He||{});var ph=new _e("Logger"),j0=(()=>{class t{debug(e,r){this.log(He.DEBUG,e,r)}info(e,r){this.log(He.INFO,e,r)}warn(e,r){this.log(He.WARN,e,r)}error(e,r,i){this.log(He.ERROR,e,i,r)}fatal(e,r,i){this.log(He.FATAL,e,i,r)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();var k_=new _e("LogFilter");var Ba=(()=>{class t{constructor(){this.loggers=w(ph,{optional:!0})??[],this.filter=w(k_,{optional:!0})}getLogger(e,r){let i=(...s)=>s.map(a=>{if(typeof a=="string")return a;if(a===void 0)return"undefined";if(a===null)return"null";let c=JSON.stringify(a);return c!==void 0?c:String(a)}).join(" "),o={component:e};return r?.package!=null&&(o.package=r.package),{log:(...s)=>this.log(He.INFO,i(...s),o),debug:(...s)=>this.log(He.DEBUG,i(...s),o),info:(...s)=>this.log(He.INFO,i(...s),o),warn:(...s)=>this.log(He.WARN,i(...s),o),error:(...s)=>this.log(He.ERROR,i(...s),o),child:s=>this.getLogger(`${e}.${s}`,r)}}log(e,r,i,o){this.filter&&!this.filter(e,i)||this.loggers.forEach(s=>s.log(e,r,i,o))}close(){this.loggers.forEach(e=>e.close())}debug(e,r){this.log(He.DEBUG,e,r)}info(e,r){this.log(He.INFO,e,r)}warn(e,r){this.log(He.WARN,e,r)}error(e,r,i){this.log(He.ERROR,e,i,r)}fatal(e,r,i){this.log(He.FATAL,e,i,r)}setLogLevel(e){}setComponent(e){}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var F0=null;function $0(t){F0=t}var Ha=()=>{},q0={log:Ha,debug:Ha,info:Ha,warn:Ha,error:Ha,child:()=>q0};function j(t,n){return F0?.getLogger(t,n)??q0}var mh={prod:{hasuraUrl:"https://graphql-prod.machina.at/v1/graphql",apiNextUrl:"https://api.machina.at",signalingUrl:"https://signaling.machina.at",firebaseDatabaseUrl:"https://x-x-machina-default-rtdb.asia-southeast1.firebasedatabase.app",webServerUrl:"https://server.machina.at",invoiceAppUrl:"https://presenter.machina.at/stable"},stg:{hasuraUrl:"https://graphql-stg.machina.at/v1/graphql",apiNextUrl:"https://api.stg.machina.at",signalingUrl:"https://signaling-stg.machina.at",firebaseDatabaseUrl:"https://x-x-machina-stg.asia-southeast1.firebasedatabase.app",webServerUrl:"https://server.machina.at",invoiceAppUrl:"https://x-x-machina-invoice.web.app"}},L_={PLANX_GRAPHQL_URL:mh.prod.hasuraUrl,PLANX_CLOUD_API_URL:mh.prod.apiNextUrl,PLANX_SIGNALING_URL:mh.prod.signalingUrl,PLANX_FIREBASE_DATABASE_URL:mh.prod.firebaseDatabaseUrl};var Z9={name:"port-forward",prefix:"pf:",profile:"reliable-ordered",defaultCap:1e3,defaultBackpressureProfile:"http",buildLabel:t=>`pf:${t}`,parseLabel:t=>t.startsWith("pf:")?t.slice(3):null},Q9={name:"heartbeat",prefix:"__heartbeat__",profile:"heartbeat",defaultCap:1,defaultBackpressureProfile:"control",buildLabel:()=>"__heartbeat__",parseLabel:t=>t==="__heartbeat__"?"":null},J9={name:"l7-http",prefix:"l7:http:",profile:"reliable-ordered",defaultCap:1e3,defaultBackpressureProfile:"http",buildLabel:t=>`l7:http:${t}`,parseLabel:t=>t.startsWith("l7:http:")?t.slice(8):null},X9={name:"l7-datagram",prefix:"l7:dg:",profile:"unreliable",defaultCap:8,defaultBackpressureProfile:"terminal",buildLabel:t=>`l7:dg:${t}`,parseLabel:t=>t.startsWith("l7:dg:")?t.slice(6):null},eZ={name:"l7-qpack",prefix:"l7:qpack:",profile:"reliable-ordered",defaultCap:8,defaultBackpressureProfile:"control",buildLabel:t=>`l7:qpack:${t}`,parseLabel:t=>t.startsWith("l7:qpack:")?t.slice(9):null},ps={portForward:Z9,heartbeat:Q9,l7Http:J9,l7Dg:X9,l7Qpack:eZ};var j_=(t,n,e)=>(r,i)=>{let o=-1;return s(0);async function s(a){if(a<=o)throw new Error("next() called multiple times");o=a;let c,u=!1,l;if(t[a]?(l=t[a][0][0],r.req.routeIndex=a):l=a===t.length&&i||void 0,l)try{c=await l(r,()=>s(a+1))}catch(d){if(d instanceof Error&&n)r.error=d,c=await n(d,r),u=!0;else throw d}else r.finalized===!1&&e&&(c=await e(r));return c&&(r.finalized===!1||u)&&(r.res=c),r}};var B0=Symbol();var H0=async(t,n=Object.create(null))=>{let{all:e=!1,dot:r=!1}=n,o=(t instanceof gh?t.raw.headers:t.headers).get("Content-Type");return o?.startsWith("multipart/form-data")||o?.startsWith("application/x-www-form-urlencoded")?tZ(t,{all:e,dot:r}):{}};async function tZ(t,n){let e=await t.formData();return e?nZ(e,n):{}}function nZ(t,n){let e=Object.create(null);return t.forEach((r,i)=>{n.all||i.endsWith("[]")?rZ(e,i,r):e[i]=r}),n.dot&&Object.entries(e).forEach(([r,i])=>{r.includes(".")&&(iZ(e,r,i),delete e[r])}),e}var rZ=(t,n,e)=>{t[n]!==void 0?Array.isArray(t[n])?t[n].push(e):t[n]=[t[n],e]:n.endsWith("[]")?t[n]=[e]:t[n]=e},iZ=(t,n,e)=>{let r=t,i=n.split(".");i.forEach((o,s)=>{s===i.length-1?r[o]=e:((!r[o]||typeof r[o]!="object"||Array.isArray(r[o])||r[o]instanceof File)&&(r[o]=Object.create(null)),r=r[o])})};var $_=t=>{let n=t.split("/");return n[0]===""&&n.shift(),n},U0=t=>{let{groups:n,path:e}=oZ(t),r=$_(e);return sZ(r,n)},oZ=t=>{let n=[];return t=t.replace(/\{[^}]+\}/g,(e,r)=>{let i=`@${r}`;return n.push([i,e]),i}),{groups:n,path:t}},sZ=(t,n)=>{for(let e=n.length-1;e>=0;e--){let[r]=n[e];for(let i=t.length-1;i>=0;i--)if(t[i].includes(r)){t[i]=t[i].replace(r,n[e][1]);break}}return t},yh={},V0=(t,n)=>{if(t==="*")return"*";let e=t.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(e){let r=`${t}#${n}`;return yh[r]||(e[2]?yh[r]=n&&n[0]!==":"&&n[0]!=="*"?[r,e[1],new RegExp(`^${e[2]}(?=/${n})`)]:[t,e[1],new RegExp(`^${e[2]}$`)]:yh[r]=[t,e[1],!0]),yh[r]}return null},vh=(t,n)=>{try{return n(t)}catch{return t.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return n(e)}catch{return e}})}},aZ=t=>vh(t,decodeURI),q_=t=>{let n=t.url,e=n.indexOf("/",n.indexOf(":")+4),r=e;for(;r<n.length;r++){let i=n.charCodeAt(r);if(i===37){let o=n.indexOf("?",r),s=n.slice(e,o===-1?void 0:o);return aZ(s.includes("%25")?s.replace(/%25/g,"%2525"):s)}else if(i===63)break}return n.slice(e,r)};var W0=t=>{let n=q_(t);return n.length>1&&n.at(-1)==="/"?n.slice(0,-1):n},Ri=(t,n,...e)=>(e.length&&(n=Ri(n,...e)),`${t?.[0]==="/"?"":"/"}${t}${n==="/"?"":`${t?.at(-1)==="/"?"":"/"}${n?.[0]==="/"?n.slice(1):n}`}`),_h=t=>{if(t.charCodeAt(t.length-1)!==63||!t.includes(":"))return null;let n=t.split("/"),e=[],r="";return n.forEach(i=>{if(i!==""&&!/\:/.test(i))r+="/"+i;else if(/\:/.test(i))if(/\?/.test(i)){e.length===0&&r===""?e.push("/"):e.push(r);let o=i.replace("?","");r+="/"+o,e.push(r)}else r+="/"+i}),e.filter((i,o,s)=>s.indexOf(i)===o)},F_=t=>/[%+]/.test(t)?(t.indexOf("+")!==-1&&(t=t.replace(/\+/g," ")),t.indexOf("%")!==-1?vh(t,B_):t):t,G0=(t,n,e)=>{let r;if(!e&&n&&!/[%+]/.test(n)){let s=t.indexOf(`?${n}`,8);for(s===-1&&(s=t.indexOf(`&${n}`,8));s!==-1;){let a=t.charCodeAt(s+n.length+1);if(a===61){let c=s+n.length+2,u=t.indexOf("&",c);return F_(t.slice(c,u===-1?void 0:u))}else if(a==38||isNaN(a))return"";s=t.indexOf(`&${n}`,s+1)}if(r=/[%+]/.test(t),!r)return}let i={};r??=/[%+]/.test(t);let o=t.indexOf("?",8);for(;o!==-1;){let s=t.indexOf("&",o+1),a=t.indexOf("=",o);a>s&&s!==-1&&(a=-1);let c=t.slice(o+1,a===-1?s===-1?void 0:s:a);if(r&&(c=F_(c)),o=s,c==="")continue;let u;a===-1?u="":(u=t.slice(a+1,s===-1?void 0:s),r&&(u=F_(u))),e?(i[c]&&Array.isArray(i[c])||(i[c]=[]),i[c].push(u)):i[c]??=u}return n?i[n]:i},z0=G0,K0=(t,n)=>G0(t,n,!0),B_=decodeURIComponent;var Y0=t=>vh(t,B_),gh=class{raw;#t;#e;routeIndex=0;path;bodyCache={};constructor(t,n="/",e=[[]]){this.raw=t,this.path=n,this.#e=e,this.#t={}}param(t){return t?this.#n(t):this.#o()}#n(t){let n=this.#e[0][this.routeIndex][1][t],e=this.#i(n);return e&&/\%/.test(e)?Y0(e):e}#o(){let t={},n=Object.keys(this.#e[0][this.routeIndex][1]);for(let e of n){let r=this.#i(this.#e[0][this.routeIndex][1][e]);r!==void 0&&(t[e]=/\%/.test(r)?Y0(r):r)}return t}#i(t){return this.#e[1]?this.#e[1][t]:t}query(t){return z0(this.url,t)}queries(t){return K0(this.url,t)}header(t){if(t)return this.raw.headers.get(t)??void 0;let n={};return this.raw.headers.forEach((e,r)=>{n[r]=e}),n}async parseBody(t){return this.bodyCache.parsedBody??=await H0(this,t)}#r=t=>{let{bodyCache:n,raw:e}=this,r=n[t];if(r)return r;let i=Object.keys(n)[0];return i?n[i].then(o=>(i==="json"&&(o=JSON.stringify(o)),new Response(o)[t]())):n[t]=e[t]()};json(){return this.#r("text").then(t=>JSON.parse(t))}text(){return this.#r("text")}arrayBuffer(){return this.#r("arrayBuffer")}blob(){return this.#r("blob")}formData(){return this.#r("formData")}addValidatedData(t,n){this.#t[t]=n}valid(t){return this.#t[t]}get url(){return this.raw.url}get method(){return this.raw.method}get[B0](){return this.#e}get matchedRoutes(){return this.#e[0].map(([[,t]])=>t)}get routePath(){return this.#e[0].map(([[,t]])=>t)[this.routeIndex].path}};var Z0={Stringify:1,BeforeStream:2,Stream:3},cZ=(t,n)=>{let e=new String(t);return e.isEscaped=!0,e.callbacks=n,e};var H_=async(t,n,e,r,i)=>{typeof t=="object"&&!(t instanceof String)&&(t instanceof Promise||(t=t.toString()),t instanceof Promise&&(t=await t));let o=t.callbacks;if(!o?.length)return Promise.resolve(t);i?i[0]+=t:i=[t];let s=Promise.all(o.map(a=>a({phase:n,buffer:i,context:r}))).then(a=>Promise.all(a.filter(Boolean).map(c=>H_(c,n,!1,r,i))).then(()=>i[0]));return e?cZ(await s,o):s};var uZ="text/plain; charset=UTF-8",U_=(t,n)=>({"Content-Type":t,...n}),Q0=class{#t;#e;env={};#n;finalized=!1;error;#o;#i;#r;#l;#c;#u;#a;#d;#f;constructor(t,n){this.#t=t,n&&(this.#i=n.executionCtx,this.env=n.env,this.#u=n.notFoundHandler,this.#f=n.path,this.#d=n.matchResult)}get req(){return this.#e??=new gh(this.#t,this.#f,this.#d),this.#e}get event(){if(this.#i&&"respondWith"in this.#i)return this.#i;throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#i)return this.#i;throw Error("This context has no ExecutionContext")}get res(){return this.#r||=new Response(null,{headers:this.#a??=new Headers})}set res(t){if(this.#r&&t){t=new Response(t.body,t);for(let[n,e]of this.#r.headers.entries())if(n!=="content-type")if(n==="set-cookie"){let r=this.#r.headers.getSetCookie();t.headers.delete("set-cookie");for(let i of r)t.headers.append("set-cookie",i)}else t.headers.set(n,e)}this.#r=t,this.finalized=!0}render=(...t)=>(this.#c??=n=>this.html(n),this.#c(...t));setLayout=t=>this.#l=t;getLayout=()=>this.#l;setRenderer=t=>{this.#c=t};header=(t,n,e)=>{this.finalized&&(this.#r=new Response(this.#r.body,this.#r));let r=this.#r?this.#r.headers:this.#a??=new Headers;n===void 0?r.delete(t):e?.append?r.append(t,n):r.set(t,n)};status=t=>{this.#o=t};set=(t,n)=>{this.#n??=new Map,this.#n.set(t,n)};get=t=>this.#n?this.#n.get(t):void 0;get var(){return this.#n?Object.fromEntries(this.#n):{}}#s(t,n,e){let r=this.#r?new Headers(this.#r.headers):this.#a??new Headers;if(typeof n=="object"&&"headers"in n){let o=n.headers instanceof Headers?n.headers:new Headers(n.headers);for(let[s,a]of o)s.toLowerCase()==="set-cookie"?r.append(s,a):r.set(s,a)}if(e)for(let[o,s]of Object.entries(e))if(typeof s=="string")r.set(o,s);else{r.delete(o);for(let a of s)r.append(o,a)}let i=typeof n=="number"?n:n?.status??this.#o;return new Response(t,{status:i,headers:r})}newResponse=(...t)=>this.#s(...t);body=(t,n,e)=>this.#s(t,n,e);text=(t,n,e)=>!this.#a&&!this.#o&&!n&&!e&&!this.finalized?new Response(t):this.#s(t,n,U_(uZ,e));json=(t,n,e)=>this.#s(JSON.stringify(t),n,U_("application/json",e));html=(t,n,e)=>{let r=i=>this.#s(i,n,U_("text/html; charset=UTF-8",e));return typeof t=="object"?H_(t,Z0.Stringify,!1,{}).then(r):r(t)};redirect=(t,n)=>{let e=String(t);return this.header("Location",/[^\x00-\xFF]/.test(e)?encodeURI(e):e),this.newResponse(null,n??302)};notFound=()=>(this.#u??=()=>new Response,this.#u(this))};var ze="ALL",J0="all",X0=["get","post","put","delete","options","patch"],bh="Can not add a route since the matcher is already built.",wh=class extends Error{};var eD="__COMPOSED_HANDLER";var lZ=t=>t.text("404 Not Found",404),tD=(t,n)=>{if("getResponse"in t){let e=t.getResponse();return n.newResponse(e.body,e)}return console.error(t),n.text("Internal Server Error",500)},V_=class{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath="/";#t="/";routes=[];constructor(t={}){[...X0,J0].forEach(i=>{this[i]=(o,...s)=>(typeof o=="string"?this.#t=o:this.#o(i,this.#t,o),s.forEach(a=>{this.#o(i,this.#t,a)}),this)}),this.on=(i,o,...s)=>{for(let a of[o].flat()){this.#t=a;for(let c of[i].flat())s.map(u=>{this.#o(c.toUpperCase(),this.#t,u)})}return this},this.use=(i,...o)=>(typeof i=="string"?this.#t=i:(this.#t="*",o.unshift(i)),o.forEach(s=>{this.#o(ze,this.#t,s)}),this);let{strict:e,...r}=t;Object.assign(this,r),this.getPath=e??!0?t.getPath??q_:W0}#e(){let t=new V_({router:this.router,getPath:this.getPath});return t.errorHandler=this.errorHandler,t.#n=this.#n,t.routes=this.routes,t}#n=lZ;errorHandler=tD;route(t,n){let e=this.basePath(t);return n.routes.map(r=>{let i;n.errorHandler===tD?i=r.handler:(i=async(o,s)=>(await j_([],n.errorHandler)(o,()=>r.handler(o,s))).res,i[eD]=r.handler),e.#o(r.method,r.path,i)}),this}basePath(t){let n=this.#e();return n._basePath=Ri(this._basePath,t),n}onError=t=>(this.errorHandler=t,this);notFound=t=>(this.#n=t,this);mount(t,n,e){let r,i;e&&(typeof e=="function"?i=e:(i=e.optionHandler,e.replaceRequest===!1?r=a=>a:r=e.replaceRequest));let o=i?a=>{let c=i(a);return Array.isArray(c)?c:[c]}:a=>{let c;try{c=a.executionCtx}catch{}return[a.env,c]};r||=(()=>{let a=Ri(this._basePath,t),c=a==="/"?0:a.length;return u=>{let l=new URL(u.url);return l.pathname=l.pathname.slice(c)||"/",new Request(l,u)}})();let s=async(a,c)=>{let u=await n(r(a.req.raw),...o(a));if(u)return u;await c()};return this.#o(ze,Ri(t,"*"),s),this}#o(t,n,e){t=t.toUpperCase(),n=Ri(this._basePath,n);let r={basePath:this._basePath,path:n,method:t,handler:e};this.router.add(t,n,[e,r]),this.routes.push(r)}#i(t,n){if(t instanceof Error)return this.errorHandler(t,n);throw t}#r(t,n,e,r){if(r==="HEAD")return(async()=>new Response(null,await this.#r(t,n,e,"GET")))();let i=this.getPath(t,{env:e}),o=this.router.match(r,i),s=new Q0(t,{path:i,matchResult:o,env:e,executionCtx:n,notFoundHandler:this.#n});if(o[0].length===1){let c;try{c=o[0][0][0][0](s,async()=>{s.res=await this.#n(s)})}catch(u){return this.#i(u,s)}return c instanceof Promise?c.then(u=>u||(s.finalized?s.res:this.#n(s))).catch(u=>this.#i(u,s)):c??this.#n(s)}let a=j_(o[0],this.errorHandler,this.#n);return(async()=>{try{let c=await a(s);if(!c.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return c.res}catch(c){return this.#i(c,s)}})()}fetch=(t,...n)=>this.#r(t,n[1],n[0],t.method);request=(t,n,e,r)=>t instanceof Request?this.fetch(n?new Request(t,n):t,e,r):(t=t.toString(),this.fetch(new Request(/^https?:\/\//.test(t)?t:`http://localhost${Ri("/",t)}`,n),e,r));fire=()=>{addEventListener("fetch",t=>{t.respondWith(this.#r(t.request,t,void 0,t.request.method))})}};var Eh=[];function W_(t,n){let e=this.buildAllMatchers(),r=(i,o)=>{let s=e[i]||e[ze],a=s[2][o];if(a)return a;let c=o.match(s[0]);if(!c)return[[],Eh];let u=c.indexOf("",1);return[s[1][u],c]};return this.match=r,r(t,n)}var Sh="[^/]+",Ua=".*",Va="(?:|/.*)",ki=Symbol(),dZ=new Set(".\\+*[^]$()");function fZ(t,n){return t.length===1?n.length===1?t<n?-1:1:-1:n.length===1||t===Ua||t===Va?1:n===Ua||n===Va?-1:t===Sh?1:n===Sh?-1:t.length===n.length?t<n?-1:1:n.length-t.length}var Ch=class{#t;#e;#n=Object.create(null);insert(t,n,e,r,i){if(t.length===0){if(this.#t!==void 0)throw ki;if(i)return;this.#t=n;return}let[o,...s]=t,a=o==="*"?s.length===0?["","",Ua]:["","",Sh]:o==="/*"?["","",Va]:o.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),c;if(a){let u=a[1],l=a[2]||Sh;if(u&&a[2]&&(l===".*"||(l=l.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(l))))throw ki;if(c=this.#n[l],!c){if(Object.keys(this.#n).some(d=>d!==Ua&&d!==Va))throw ki;if(i)return;c=this.#n[l]=new Ch,u!==""&&(c.#e=r.varIndex++)}!i&&u!==""&&e.push([u,c.#e])}else if(c=this.#n[o],!c){if(Object.keys(this.#n).some(u=>u.length>1&&u!==Ua&&u!==Va))throw ki;if(i)return;c=this.#n[o]=new Ch}c.insert(s,n,e,r,i)}buildRegExpStr(){let n=Object.keys(this.#n).sort(fZ).map(e=>{let r=this.#n[e];return(typeof r.#e=="number"?`(${e})@${r.#e}`:dZ.has(e)?`\\${e}`:e)+r.buildRegExpStr()});return typeof this.#t=="number"&&n.unshift(`#${this.#t}`),n.length===0?"":n.length===1?n[0]:"(?:"+n.join("|")+")"}};var nD=class{#t={varIndex:0};#e=new Ch;insert(t,n,e){let r=[],i=[];for(let s=0;;){let a=!1;if(t=t.replace(/\{[^}]+\}/g,c=>{let u=`@\\${s}`;return i[s]=[u,c],s++,a=!0,u}),!a)break}let o=t.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let s=i.length-1;s>=0;s--){let[a]=i[s];for(let c=o.length-1;c>=0;c--)if(o[c].indexOf(a)!==-1){o[c]=o[c].replace(a,i[s][1]);break}}return this.#e.insert(o,n,r,this.#t,e),r}buildRegExp(){let t=this.#e.buildRegExpStr();if(t==="")return[/^$/,[],[]];let n=0,e=[],r=[];return t=t.replace(/#(\d+)|@(\d+)|\.\*\$/g,(i,o,s)=>o!==void 0?(e[++n]=Number(o),"$()"):(s!==void 0&&(r[Number(s)]=++n),"")),[new RegExp(`^${t}`),e,r]}};var hZ=[/^$/,[],Object.create(null)],rD=Object.create(null);function iD(t){return rD[t]??=new RegExp(t==="*"?"":`^${t.replace(/\/\*$|([.\\+*[^\]$()])/g,(n,e)=>e?`\\${e}`:"(?:|/.*)")}$`)}function pZ(){rD=Object.create(null)}function mZ(t){let n=new nD,e=[];if(t.length===0)return hZ;let r=t.map(u=>[!/\*|\/:/.test(u[0]),...u]).sort(([u,l],[d,f])=>u?1:d?-1:l.length-f.length),i=Object.create(null);for(let u=0,l=-1,d=r.length;u<d;u++){let[f,p,m]=r[u];f?i[p]=[m.map(([b])=>[b,Object.create(null)]),Eh]:l++;let y;try{y=n.insert(p,l,f)}catch(b){throw b===ki?new wh(p):b}f||(e[l]=m.map(([b,E])=>{let D=Object.create(null);for(E-=1;E>=0;E--){let[T,K]=y[E];D[T]=K}return[b,D]}))}let[o,s,a]=n.buildRegExp();for(let u=0,l=e.length;u<l;u++)for(let d=0,f=e[u].length;d<f;d++){let p=e[u][d]?.[1];if(!p)continue;let m=Object.keys(p);for(let y=0,b=m.length;y<b;y++)p[m[y]]=a[p[m[y]]]}let c=[];for(let u in s)c[u]=e[s[u]];return[o,c,i]}function ms(t,n){if(t){for(let e of Object.keys(t).sort((r,i)=>i.length-r.length))if(iD(e).test(n))return[...t[e]]}}var Ih=class{name="RegExpRouter";#t;#e;constructor(){this.#t={[ze]:Object.create(null)},this.#e={[ze]:Object.create(null)}}add(t,n,e){let r=this.#t,i=this.#e;if(!r||!i)throw new Error(bh);r[t]||[r,i].forEach(a=>{a[t]=Object.create(null),Object.keys(a[ze]).forEach(c=>{a[t][c]=[...a[ze][c]]})}),n==="/*"&&(n="*");let o=(n.match(/\/:/g)||[]).length;if(/\*$/.test(n)){let a=iD(n);t===ze?Object.keys(r).forEach(c=>{r[c][n]||=ms(r[c],n)||ms(r[ze],n)||[]}):r[t][n]||=ms(r[t],n)||ms(r[ze],n)||[],Object.keys(r).forEach(c=>{(t===ze||t===c)&&Object.keys(r[c]).forEach(u=>{a.test(u)&&r[c][u].push([e,o])})}),Object.keys(i).forEach(c=>{(t===ze||t===c)&&Object.keys(i[c]).forEach(u=>a.test(u)&&i[c][u].push([e,o]))});return}let s=_h(n)||[n];for(let a=0,c=s.length;a<c;a++){let u=s[a];Object.keys(i).forEach(l=>{(t===ze||t===l)&&(i[l][u]||=[...ms(r[l],u)||ms(r[ze],u)||[]],i[l][u].push([e,o-c+a+1]))})}}match=W_;buildAllMatchers(){let t=Object.create(null);return Object.keys(this.#e).concat(Object.keys(this.#t)).forEach(n=>{t[n]||=this.#n(n)}),this.#t=this.#e=void 0,pZ(),t}#n(t){let n=[],e=t===ze;return[this.#t,this.#e].forEach(r=>{let i=r[t]?Object.keys(r[t]).map(o=>[o,r[t][o]]):[];i.length!==0?(e||=!0,n.push(...i)):t!==ze&&n.push(...Object.keys(r[ze]).map(o=>[o,r[ze][o]]))}),e?mZ(n):null}};var G_=class{name="SmartRouter";#t=[];#e=[];constructor(t){this.#t=t.routers}add(t,n,e){if(!this.#e)throw new Error(bh);this.#e.push([t,n,e])}match(t,n){if(!this.#e)throw new Error("Fatal error");let e=this.#t,r=this.#e,i=e.length,o=0,s;for(;o<i;o++){let a=e[o];try{for(let c=0,u=r.length;c<u;c++)a.add(...r[c]);s=a.match(t,n)}catch(c){if(c instanceof wh)continue;throw c}this.match=a.match.bind(a),this.#t=[a],this.#e=void 0;break}if(o===i)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,s}get activeRouter(){if(this.#e||this.#t.length!==1)throw new Error("No active router has been determined yet.");return this.#t[0]}};var Wa=Object.create(null),z_=class{#t;#e;#n;#o=0;#i=Wa;constructor(t,n,e){if(this.#e=e||Object.create(null),this.#t=[],t&&n){let r=Object.create(null);r[t]={handler:n,possibleKeys:[],score:0},this.#t=[r]}this.#n=[]}insert(t,n,e){this.#o=++this.#o;let r=this,i=U0(n),o=[];for(let s=0,a=i.length;s<a;s++){let c=i[s],u=i[s+1],l=V0(c,u),d=Array.isArray(l)?l[0]:c;if(d in r.#e){r=r.#e[d],l&&o.push(l[1]);continue}r.#e[d]=new z_,l&&(r.#n.push(l),o.push(l[1])),r=r.#e[d]}return r.#t.push({[t]:{handler:e,possibleKeys:o.filter((s,a,c)=>c.indexOf(s)===a),score:this.#o}}),r}#r(t,n,e,r){let i=[];for(let o=0,s=t.#t.length;o<s;o++){let a=t.#t[o],c=a[n]||a[ze],u={};if(c!==void 0&&(c.params=Object.create(null),i.push(c),e!==Wa||r&&r!==Wa))for(let l=0,d=c.possibleKeys.length;l<d;l++){let f=c.possibleKeys[l],p=u[c.score];c.params[f]=r?.[f]&&!p?r[f]:e[f]??r?.[f],u[c.score]=!0}}return i}search(t,n){let e=[];this.#i=Wa;let i=[this],o=$_(n),s=[];for(let a=0,c=o.length;a<c;a++){let u=o[a],l=a===c-1,d=[];for(let f=0,p=i.length;f<p;f++){let m=i[f],y=m.#e[u];y&&(y.#i=m.#i,l?(y.#e["*"]&&e.push(...this.#r(y.#e["*"],t,m.#i)),e.push(...this.#r(y,t,m.#i))):d.push(y));for(let b=0,E=m.#n.length;b<E;b++){let D=m.#n[b],T=m.#i===Wa?{}:{...m.#i};if(D==="*"){let z=m.#e["*"];z&&(e.push(...this.#r(z,t,m.#i)),z.#i=T,d.push(z));continue}let[K,H,re]=D;if(!u&&!(re instanceof RegExp))continue;let Ee=m.#e[K],pe=o.slice(a).join("/");if(re instanceof RegExp){let z=re.exec(pe);if(z){if(T[H]=z[0],e.push(...this.#r(Ee,t,m.#i,T)),Object.keys(Ee.#e).length){Ee.#i=T;let rt=z[0].match(/\//)?.length??0;(s[rt]||=[]).push(Ee)}continue}}(re===!0||re.test(u))&&(T[H]=u,l?(e.push(...this.#r(Ee,t,T,m.#i)),Ee.#e["*"]&&e.push(...this.#r(Ee.#e["*"],t,T,m.#i))):(Ee.#i=T,d.push(Ee)))}}i=d.concat(s.shift()??[])}return e.length>1&&e.sort((a,c)=>a.score-c.score),[e.map(({handler:a,params:c})=>[a,c])]}};var K_=class{name="TrieRouter";#t;constructor(){this.#t=new z_}add(t,n,e){let r=_h(n);if(r){for(let i=0,o=r.length;i<o;i++)this.#t.insert(t,r[i],e);return}this.#t.insert(t,n,e)}match(t,n){return this.#t.search(t,n)}};var Y_=class extends V_{constructor(t={}){super(t),this.router=t.router??new G_({routers:[new Ih,new K_]})}};function gZ(){let{process:t,Deno:n}=globalThis;return!(typeof n?.noColor=="boolean"?n.noColor:t!==void 0?"NO_COLOR"in t?.env:!1)}async function oD(){let{navigator:t}=globalThis,n="cloudflare:workers";return!(t!==void 0&&t.userAgent==="Cloudflare-Workers"?await(async()=>{try{return"NO_COLOR"in((await import(n)).env??{})}catch{return!1}})():!gZ())}var yZ=t=>{let[n,e]=[",","."];return t.map(i=>i.replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1"+n)).join(e)},vZ=t=>{let n=Date.now()-t;return yZ([n<1e3?n+"ms":Math.round(n/1e3)+"s"])},_Z=async t=>{if(await oD())switch(t/100|0){case 5:return`\x1B[31m${t}\x1B[0m`;case 4:return`\x1B[33m${t}\x1B[0m`;case 3:return`\x1B[36m${t}\x1B[0m`;case 2:return`\x1B[32m${t}\x1B[0m`}return`${t}`};async function sD(t,n,e,r,i=0,o){let s=n==="<--"?`${n} ${e} ${r}`:`${n} ${e} ${r} ${await _Z(i)} ${o}`;t(s)}var aD=(t=console.log)=>async function(e,r){let{method:i,url:o}=e.req,s=o.slice(o.indexOf("/",8));await sD(t,"<--",i,s);let a=Date.now();await r(),await sD(t,"-->",i,s,e.res.status,vZ(a))};function Th(t,...n){let e=Object.assign(Ht(),t);for(let r of n)for(let i in r){if(i in e&&e[i]!==r[i])throw new Error(`Duplicate key ${i}`);e[i]=r[i]}return e}function ft(t){return!!t&&!Array.isArray(t)&&typeof t=="object"}function xh(t){return typeof t=="function"}function Ht(){return Object.create(null)}var bZ=typeof Symbol=="function"&&!!Symbol.asyncIterator;function Ga(t){return bZ&&ft(t)&&Symbol.asyncIterator in t}var za=t=>t();function cD(t){return t}function uD(t){if(typeof AbortSignal.any=="function")return AbortSignal.any(t);let n=new AbortController;for(let r of t){if(r.aborted){e();break}r.addEventListener("abort",e,{once:!0})}return n.signal;function e(){n.abort();for(let r of t)r.removeEventListener("abort",e)}}var gs={PARSE_ERROR:-32700,BAD_REQUEST:-32600,INTERNAL_SERVER_ERROR:-32603,NOT_IMPLEMENTED:-32603,BAD_GATEWAY:-32603,SERVICE_UNAVAILABLE:-32603,GATEWAY_TIMEOUT:-32603,UNAUTHORIZED:-32001,PAYMENT_REQUIRED:-32002,FORBIDDEN:-32003,NOT_FOUND:-32004,METHOD_NOT_SUPPORTED:-32005,TIMEOUT:-32008,CONFLICT:-32009,PRECONDITION_FAILED:-32012,PAYLOAD_TOO_LARGE:-32013,UNSUPPORTED_MEDIA_TYPE:-32015,UNPROCESSABLE_CONTENT:-32022,PRECONDITION_REQUIRED:-32028,TOO_MANY_REQUESTS:-32029,CLIENT_CLOSED_REQUEST:-32099},lD={[-32700]:"PARSE_ERROR",[-32600]:"BAD_REQUEST",[-32603]:"INTERNAL_SERVER_ERROR",[-32001]:"UNAUTHORIZED",[-32002]:"PAYMENT_REQUIRED",[-32003]:"FORBIDDEN",[-32004]:"NOT_FOUND",[-32005]:"METHOD_NOT_SUPPORTED",[-32008]:"TIMEOUT",[-32009]:"CONFLICT",[-32012]:"PRECONDITION_FAILED",[-32013]:"PAYLOAD_TOO_LARGE",[-32015]:"UNSUPPORTED_MEDIA_TYPE",[-32022]:"UNPROCESSABLE_CONTENT",[-32028]:"PRECONDITION_REQUIRED",[-32029]:"TOO_MANY_REQUESTS",[-32099]:"CLIENT_CLOSED_REQUEST"},Owe=[gs.BAD_GATEWAY,gs.SERVICE_UNAVAILABLE,gs.GATEWAY_TIMEOUT,gs.INTERNAL_SERVER_ERROR];var wZ=Object.create,hD=Object.defineProperty,EZ=Object.getOwnPropertyDescriptor,pD=Object.getOwnPropertyNames,SZ=Object.getPrototypeOf,CZ=Object.prototype.hasOwnProperty,wt=(t,n)=>function(){return n||(0,t[pD(t)[0]])((n={exports:{}}).exports,n),n.exports},IZ=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(var i=pD(n),o=0,s=i.length,a;o<s;o++)a=i[o],!CZ.call(t,a)&&a!==e&&hD(t,a,{get:(c=>n[c]).bind(null,a),enumerable:!(r=EZ(n,a))||r.enumerable});return t},Se=(t,n,e)=>(e=t!=null?wZ(SZ(t)):{},IZ(n||!t||!t.__esModule?hD(e,"default",{value:t,enumerable:!0}):e,t)),TZ=()=>{},dD=t=>{Object.freeze&&Object.freeze(t)};function mD(t,n,e){var r;let i=n.join(".");return(r=e[i])!==null&&r!==void 0||(e[i]=new Proxy(TZ,{get(o,s){if(!(typeof s!="string"||s==="then"))return mD(t,[...n,s],e)},apply(o,s,a){let c=n[n.length-1],u={args:a,path:n};return c==="call"?u={args:a.length>=2?[a[1]]:[],path:n.slice(0,-1)}:c==="apply"&&(u={args:a.length>=2?a[1]:[],path:n.slice(0,-1)}),dD(u.args),dD(u.path),t(u)}})),e[i]}var gD=t=>mD(t,[],Ht());var xZ={PARSE_ERROR:400,BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_SUPPORTED:405,TIMEOUT:408,CONFLICT:409,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,UNSUPPORTED_MEDIA_TYPE:415,UNPROCESSABLE_CONTENT:422,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,CLIENT_CLOSED_REQUEST:499,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504};function yD(t){var n;return(n=xZ[t])!==null&&n!==void 0?n:500}function vD(t){let n=Array.isArray(t)?t:[t],e=new Set(n.map(i=>{if("error"in i&&ft(i.error.data)){var o;if(typeof((o=i.error.data)===null||o===void 0?void 0:o.httpStatus)=="number")return i.error.data.httpStatus;let s=lD[i.error.code];return yD(s)}return 200}));return e.size!==1?207:e.values().next().value}function DZ(t){return yD(t.code)}var _D=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(t,n){function e(r){"@babel/helpers - typeof";return n.exports=e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(i){return typeof i}:function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},n.exports.__esModule=!0,n.exports.default=n.exports,e(r)}n.exports=e,n.exports.__esModule=!0,n.exports.default=n.exports}}),OZ=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(t,n){var e=_D().default;function r(i,o){if(e(i)!="object"||!i)return i;var s=i[Symbol.toPrimitive];if(s!==void 0){var a=s.call(i,o||"default");if(e(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(i)}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),MZ=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(t,n){var e=_D().default,r=OZ();function i(o){var s=r(o,"string");return e(s)=="symbol"?s:s+""}n.exports=i,n.exports.__esModule=!0,n.exports.default=n.exports}}),Li=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(t,n){var e=MZ();function r(i,o,s){return(o=e(o))in i?Object.defineProperty(i,o,{value:s,enumerable:!0,configurable:!0,writable:!0}):i[o]=s,i}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),Ut=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(t,n){var e=Li();function r(o,s){var a=Object.keys(o);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(o);s&&(c=c.filter(function(u){return Object.getOwnPropertyDescriptor(o,u).enumerable})),a.push.apply(a,c)}return a}function i(o){for(var s=1;s<arguments.length;s++){var a=arguments[s]!=null?arguments[s]:{};s%2?r(Object(a),!0).forEach(function(c){e(o,c,a[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(a)):r(Object(a)).forEach(function(c){Object.defineProperty(o,c,Object.getOwnPropertyDescriptor(a,c))})}return o}n.exports=i,n.exports.__esModule=!0,n.exports.default=n.exports}}),fD=Se(Ut(),1);function ji(t){let{path:n,error:e,config:r}=t,{code:i}=t.error,o={message:e.message,code:gs[i],data:{code:i,httpStatus:DZ(e)}};return r.isDev&&typeof t.error.stack=="string"&&(o.data.stack=t.error.stack),typeof n=="string"&&(o.data.path=n),r.errorFormatter((0,fD.default)((0,fD.default)({},t),{},{shape:o}))}var vs=({shape:t})=>t,bD=Se(Li(),1),AZ=class extends Error{};function NZ(t){if(t instanceof Error)return t;let n=typeof t;if(!(n==="undefined"||n==="function"||t===null)){if(n!=="object")return new Error(String(t));if(ft(t))return Object.assign(new AZ,t)}}function Yt(t){if(t instanceof Ue||t instanceof Error&&t.name==="TRPCError")return t;let n=new Ue({code:"INTERNAL_SERVER_ERROR",cause:t});return t instanceof Error&&t.stack&&(n.stack=t.stack),n}var Ue=class extends Error{constructor(t){var n,e,r;let i=NZ(t.cause),o=(n=(e=t.message)!==null&&e!==void 0?e:i?.message)!==null&&n!==void 0?n:t.code;super(o,{cause:i}),(0,bD.default)(this,"cause",void 0),(0,bD.default)(this,"code",void 0),this.code=t.code,this.name="TRPCError",(r=this.cause)!==null&&r!==void 0||(this.cause=i)}},ys=Se(Ut(),1);function ED(t){return"input"in t?t:{input:t,output:t}}var _s={input:{serialize:t=>t,deserialize:t=>t},output:{serialize:t=>t,deserialize:t=>t}};function wD(t,n){return"error"in n?(0,ys.default)((0,ys.default)({},n),{},{error:t.transformer.output.serialize(n.error)}):"data"in n.result?(0,ys.default)((0,ys.default)({},n),{},{result:(0,ys.default)((0,ys.default)({},n.result),{},{data:t.transformer.output.serialize(n.result.data)})}):n}function Oh(t,n){return Array.isArray(n)?n.map(e=>wD(t,e)):wD(t,n)}var Dh=Se(Ut(),1),PZ="lazyMarker";function RZ(t){let n=Symbol(),e=n;return()=>(e===n&&(e=t()),e)}function kZ(t){return typeof t=="function"&&PZ in t}function LZ(t){return ft(t)&&ft(t._def)&&"router"in t._def}var jZ={_ctx:null,_errorShape:null,_meta:null,queries:{},mutations:{},subscriptions:{},errorFormatter:vs,transformer:_s},FZ=["then","call","apply"];function Z_(t){function n(e){let r=new Set(Object.keys(e).filter(d=>FZ.includes(d)));if(r.size>0)throw new Error("Reserved words used in `router({})` call: "+Array.from(r).join(", "));let i=Ht(),o=Ht();function s(d){return{ref:d.ref,load:RZ(async()=>{let f=await d.ref(),p=[...d.path,d.key],m=p.join(".");d.aggregate[d.key]=a(f._def.record,p),delete o[m];for(let[y,b]of Object.entries(f._def.lazy)){let E=[...p,y].join(".");o[E]=s({ref:b.ref,path:p,key:y,aggregate:d.aggregate[d.key]})}})}}function a(d,f=[]){let p=Ht();for(let[m,y]of Object.entries(d??{})){if(kZ(y)){o[[...f,m].join(".")]=s({path:f,ref:y,key:m,aggregate:p});continue}if(LZ(y)){p[m]=a(y._def.record,[...f,m]);continue}if(!$Z(y)){p[m]=a(y,[...f,m]);continue}let b=[...f,m].join(".");if(i[b])throw new Error(`Duplicate key: ${b}`);i[b]=y,p[m]=y}return p}let c=a(e),u=(0,Dh.default)((0,Dh.default)({_config:t,router:!0,procedures:i,lazy:o},jZ),{},{record:c});return(0,Dh.default)((0,Dh.default)({},c),{},{_def:u,createCaller:Q_()({_def:u})})}return n}function $Z(t){return typeof t=="function"}async function Ka(t,n){let{_def:e}=t,r=e.procedures[n];for(;!r;){let i=Object.keys(e.lazy).find(s=>n.startsWith(s));if(!i)return null;await e.lazy[i].load(),r=e.procedures[n]}return r}function Q_(){return function(n){let{_def:e}=n;return function(i,o){return gD(async s=>{let{path:a,args:c}=s,u=a.join(".");if(a.length===1&&a[0]==="_def")return e;let l=await Ka(n,u),d;try{if(!l)throw new Ue({code:"NOT_FOUND",message:`No procedure found on path "${a}"`});return d=xh(i)?await Promise.resolve(i()):i,await l({path:u,getRawInput:async()=>c[0],ctx:d,type:l._def.type,signal:o?.signal,batchIndex:0})}catch(m){var f,p;throw o==null||(f=o.onError)===null||f===void 0||f.call(o,{ctx:d,error:Yt(m),input:c[0],path:u,type:(p=l?._def.type)!==null&&p!==void 0?p:"unknown"}),m}})}}}function SD(...t){var n,e;let r=Th({},...t.map(a=>a._def.record)),i=t.reduce((a,c)=>{if(c._def._config.errorFormatter&&c._def._config.errorFormatter!==vs){if(a!==vs&&a!==c._def._config.errorFormatter)throw new Error("You seem to have several error formatters");return c._def._config.errorFormatter}return a},vs),o=t.reduce((a,c)=>{if(c._def._config.transformer&&c._def._config.transformer!==_s){if(a!==_s&&a!==c._def._config.transformer)throw new Error("You seem to have several transformers");return c._def._config.transformer}return a},_s);return Z_({errorFormatter:i,transformer:o,isDev:t.every(a=>a._def._config.isDev),allowOutsideOfServer:t.every(a=>a._def._config.allowOutsideOfServer),isServer:t.every(a=>a._def._config.isServer),$types:(n=t[0])===null||n===void 0?void 0:n._def._config.$types,sse:(e=t[0])===null||e===void 0?void 0:e._def._config.sse})(r)}var qZ=Symbol();function CD(t){return Array.isArray(t)&&t[2]===qZ}function Ya(t){return typeof t=="object"&&t!==null&&"subscribe"in t}function Zt(t){let n={subscribe(e){let r=null,i=!1,o=!1,s=!1;function a(){if(r===null){s=!0;return}o||(o=!0,typeof r=="function"?r():r&&r.unsubscribe())}return r=t({next(c){var u;i||(u=e.next)===null||u===void 0||u.call(e,c)},error(c){var u;i||(i=!0,(u=e.error)===null||u===void 0||u.call(e,c),a())},complete(){var c;i||(i=!0,(c=e.complete)===null||c===void 0||c.call(e),a())}}),s&&a(),{unsubscribe:a}},pipe(...e){return e.reduce(BZ,n)}};return n}function BZ(t,n){return n(t)}function HZ(t,n){let e=null,r=()=>{e?.unsubscribe(),e=null,n.removeEventListener("abort",r)};return new ReadableStream({start(i){e=t.subscribe({next(o){i.enqueue({ok:!0,value:o})},error(o){i.enqueue({ok:!1,error:o}),i.close()},complete(){i.close()}}),n.aborted?r():n.addEventListener("abort",r,{once:!0})},cancel(){r()}})}function Mh(t,n){let r=HZ(t,n).getReader(),i={async next(){let o=await r.read();if(o.done)return{value:void 0,done:!0};let{value:s}=o;if(!s.ok)throw s.error;return{value:s.value,done:!1}},async return(){return await r.cancel(),{value:void 0,done:!0}}};return{[Symbol.asyncIterator](){return i}}}function UZ(t){try{if(t===null)return null;if(!ft(t))throw new Error("Expected object");let n=Object.entries(t).filter(([e,r])=>typeof r!="string");if(n.length>0)throw new Error(`Expected connectionParams to be string values. Got ${n.map(([e,r])=>`${e}: ${typeof r}`).join(", ")}`);return t}catch(n){throw new Ue({code:"PARSE_ERROR",message:"Invalid connection params shape",cause:n})}}function VZ(t){let n;try{n=JSON.parse(t)}catch(e){throw new Ue({code:"PARSE_ERROR",message:"Not JSON-parsable query params",cause:e})}return UZ(n)}var ID=Se(Ut(),1);function ib(t){let n=null,e=Symbol.for("@trpc/server/http/memo"),r=e;return{read:async()=>{var i;return r!==e||((i=n)!==null&&i!==void 0||(n=t().catch(o=>{throw o instanceof Ue?o:new Ue({code:"BAD_REQUEST",message:o instanceof Error?o.message:"Invalid input",cause:o})})),r=await n,n=null),r},result:()=>r!==e?r:void 0}}var qD={isMatch(t){var n;return!!(!((n=t.headers.get("content-type"))===null||n===void 0)&&n.startsWith("application/json"))},async parse(t){var n;let{req:e}=t,r=t.searchParams.get("batch")==="1",i=r?t.path.split(","):[t.path],o=ib(async()=>{let d;if(e.method==="GET"){let p=t.searchParams.get("input");p&&(d=JSON.parse(p))}else d=await e.json();if(d===void 0)return Ht();if(!r){let p=Ht();return p[0]=t.router._def._config.transformer.input.deserialize(d),p}if(!ft(d))throw new Ue({code:"BAD_REQUEST",message:'"input" needs to be an object when doing a batch call'});let f=Ht();for(let p of i.keys()){let m=d[p];m!==void 0&&(f[p]=t.router._def._config.transformer.input.deserialize(m))}return f}),s=await Promise.all(i.map(async(d,f)=>{let p=await Ka(t.router,d);return{batchIndex:f,path:d,procedure:p,getRawInput:async()=>{let y=(await o.read())[f];if(p?._def.type==="subscription"){var b,E;let T=(b=(E=t.headers.get("last-event-id"))!==null&&E!==void 0?E:t.searchParams.get("lastEventId"))!==null&&b!==void 0?b:t.searchParams.get("Last-Event-Id");if(T)if(ft(y))y=(0,ID.default)((0,ID.default)({},y),{},{lastEventId:T});else{var D;(D=y)!==null&&D!==void 0||(y={lastEventId:T})}}return y},result:()=>{var m;return(m=o.result())===null||m===void 0?void 0:m[f]}}})),a=new Set(s.map(d=>{var f;return(f=d.procedure)===null||f===void 0?void 0:f._def.type}).filter(Boolean));if(a.size>1)throw new Ue({code:"BAD_REQUEST",message:`Cannot mix procedure types in call: ${Array.from(a).join(", ")}`});let c=(n=a.values().next().value)!==null&&n!==void 0?n:"unknown",u=t.searchParams.get("connectionParams");return{isBatchCall:r,accept:e.headers.get("trpc-accept"),calls:s,type:c,connectionParams:u===null?null:VZ(u),signal:e.signal,url:t.url}}},WZ={isMatch(t){var n;return!!(!((n=t.headers.get("content-type"))===null||n===void 0)&&n.startsWith("multipart/form-data"))},async parse(t){let{req:n}=t;if(n.method!=="POST")throw new Ue({code:"METHOD_NOT_SUPPORTED",message:"Only POST requests are supported for multipart/form-data requests"});let e=ib(async()=>await n.formData()),r=await Ka(t.router,t.path);return{accept:null,calls:[{batchIndex:0,path:t.path,getRawInput:e.read,result:e.result,procedure:r}],isBatchCall:!1,type:"mutation",connectionParams:null,signal:n.signal,url:t.url}}},GZ={isMatch(t){var n;return!!(!((n=t.headers.get("content-type"))===null||n===void 0)&&n.startsWith("application/octet-stream"))},async parse(t){let{req:n}=t;if(n.method!=="POST")throw new Ue({code:"METHOD_NOT_SUPPORTED",message:"Only POST requests are supported for application/octet-stream requests"});let e=ib(async()=>n.body);return{calls:[{batchIndex:0,path:t.path,getRawInput:e.read,result:e.result,procedure:await Ka(t.router,t.path)}],isBatchCall:!1,accept:null,type:"mutation",connectionParams:null,signal:n.signal,url:t.url}}},zZ=[qD,WZ,GZ];function KZ(t){let n=zZ.find(e=>e.isMatch(t));if(n)return n;if(!n&&t.method==="GET")return qD;throw new Ue({code:"UNSUPPORTED_MEDIA_TYPE",message:t.headers.has("content-type")?`Unsupported content-type "${t.headers.get("content-type")}`:"Missing content-type header"})}async function YZ(t){return await KZ(t.req).parse(t)}function ZZ(t){return ft(t)&&t.name==="AbortError"}function QZ(t="AbortError"){throw new DOMException(t,"AbortError")}function TD(t){return Object.prototype.toString.call(t)==="[object Object]"}function JZ(t){var n,e;return TD(t)===!1?!1:(n=t.constructor,n===void 0?!0:(e=n.prototype,!(TD(e)===!1||e.hasOwnProperty("isPrototypeOf")===!1)))}var Ah=Se(Li(),1),BD,J_=new WeakMap,XZ=()=>{};BD=Symbol.toStringTag;var ob=class Fi{constructor(n){(0,Ah.default)(this,"promise",void 0),(0,Ah.default)(this,"subscribers",[]),(0,Ah.default)(this,"settlement",null),(0,Ah.default)(this,BD,"Unpromise"),typeof n=="function"?this.promise=new Promise(n):this.promise=n;let e=this.promise.then(r=>{let{subscribers:i}=this;this.subscribers=null,this.settlement={status:"fulfilled",value:r},i?.forEach(({resolve:o})=>{o(r)})});"catch"in e&&e.catch(r=>{let{subscribers:i}=this;this.subscribers=null,this.settlement={status:"rejected",reason:r},i?.forEach(({reject:o})=>{o(r)})})}subscribe(){let n,e,{settlement:r}=this;if(r===null){if(this.subscribers===null)throw new Error("Unpromise settled but still has subscribers");let i=tQ();this.subscribers=nQ(this.subscribers,i),n=i.promise,e=()=>{this.subscribers!==null&&(this.subscribers=iQ(this.subscribers,i))}}else{let{status:i}=r;i==="fulfilled"?n=Promise.resolve(r.value):n=Promise.reject(r.reason),e=XZ}return Object.assign(n,{unsubscribe:e})}then(n,e){let r=this.subscribe(),{unsubscribe:i}=r;return Object.assign(r.then(n,e),{unsubscribe:i})}catch(n){let e=this.subscribe(),{unsubscribe:r}=e;return Object.assign(e.catch(n),{unsubscribe:r})}finally(n){let e=this.subscribe(),{unsubscribe:r}=e;return Object.assign(e.finally(n),{unsubscribe:r})}static proxy(n){let e=Fi.getSubscribablePromise(n);return typeof e<"u"?e:Fi.createSubscribablePromise(n)}static createSubscribablePromise(n){let e=new Fi(n);return J_.set(n,e),J_.set(e,e),e}static getSubscribablePromise(n){return J_.get(n)}static resolve(n){let e=typeof n=="object"&&n!==null&&"then"in n&&typeof n.then=="function"?n:Promise.resolve(n);return Fi.proxy(e).subscribe()}static async any(n){let r=(Array.isArray(n)?n:[...n]).map(Fi.resolve);try{return await Promise.any(r)}finally{r.forEach(({unsubscribe:i})=>{i()})}}static async race(n){let r=(Array.isArray(n)?n:[...n]).map(Fi.resolve);try{return await Promise.race(r)}finally{r.forEach(({unsubscribe:i})=>{i()})}}static async raceReferences(n){let e=n.map(eQ);try{return await Promise.race(e)}finally{for(let r of e)r.unsubscribe()}}};function eQ(t){return ob.proxy(t).then(()=>[t])}function tQ(){let t,n;return{promise:new Promise((r,i)=>{t=r,n=i}),resolve:t,reject:n}}function nQ(t,n){return[...t,n]}function rQ(t,n){return[...t.slice(0,n),...t.slice(n+1)]}function iQ(t,n){let e=t.indexOf(n);return e!==-1?rQ(t,e):t}var xD,DD,OD,MD;(DD=(xD=Symbol).dispose)!==null&&DD!==void 0||(xD.dispose=Symbol());(MD=(OD=Symbol).asyncDispose)!==null&&MD!==void 0||(OD.asyncDispose=Symbol());function oQ(t,n){let e=t,r=e[Symbol.dispose];return e[Symbol.dispose]=()=>{n(),r?.()},e}function HD(t,n){let e=t,r=e[Symbol.asyncDispose];return e[Symbol.asyncDispose]=async()=>{await n(),await r?.()},e}var sb=Symbol();function UD(t){let n=null;return oQ({start(){if(n)throw new Error("Timer already started");return new Promise(r=>{n=setTimeout(()=>r(sb),t)})}},()=>{n&&clearTimeout(n)})}var Xa=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(t,n){function e(){var r=typeof SuppressedError=="function"?SuppressedError:function(a,c){var u=Error();return u.name="SuppressedError",u.error=a,u.suppressed=c,u},i={},o=[];function s(a,c){if(c!=null){if(Object(c)!==c)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(a)var u=c[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(u===void 0&&(u=c[Symbol.dispose||Symbol.for("Symbol.dispose")],a))var l=u;if(typeof u!="function")throw new TypeError("Object is not disposable.");l&&(u=function(){try{l.call(c)}catch(f){return Promise.reject(f)}}),o.push({v:c,d:u,a})}else a&&o.push({d:c,a});return c}return{e:i,u:s.bind(null,!1),a:s.bind(null,!0),d:function(){var c,u=this.e,l=0;function d(){for(;c=o.pop();)try{if(!c.a&&l===1)return l=0,o.push(c),Promise.resolve().then(d);if(c.d){var p=c.d.call(c.v);if(c.a)return l|=2,Promise.resolve(p).then(d,f)}else l|=1}catch(m){return f(m)}if(l===1)return u!==i?Promise.reject(u):Promise.resolve();if(u!==i)throw u}function f(p){return u=u!==i?new r(p,u):p,d()}return d()}}}n.exports=e,n.exports.__esModule=!0,n.exports.default=n.exports}}),ab=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(t,n){function e(r,i){this.v=r,this.k=i}n.exports=e,n.exports.__esModule=!0,n.exports.default=n.exports}}),ec=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(t,n){var e=ab();function r(i){return new e(i,0)}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),bs=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(t,n){var e=ab();function r(o){return function(){return new i(o.apply(this,arguments))}}function i(o){var s,a;function c(l,d){try{var f=o[l](d),p=f.value,m=p instanceof e;Promise.resolve(m?p.v:p).then(function(y){if(m){var b=l==="return"?"return":"next";if(!p.k||y.done)return c(b,y);y=o[b](y).value}u(f.done?"return":"normal",y)},function(y){c("throw",y)})}catch(y){u("throw",y)}}function u(l,d){switch(l){case"return":s.resolve({value:d,done:!0});break;case"throw":s.reject(d);break;default:s.resolve({value:d,done:!1})}(s=s.next)?c(s.key,s.arg):a=null}this._invoke=function(l,d){return new Promise(function(f,p){var m={key:l,arg:d,resolve:f,reject:p,next:null};a?a=a.next=m:(s=a=m,c(l,d))})},typeof o.return!="function"&&(this.return=void 0)}i.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},i.prototype.next=function(o){return this._invoke("next",o)},i.prototype.throw=function(o){return this._invoke("throw",o)},i.prototype.return=function(o){return this._invoke("return",o)},n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),sQ=Se(Xa(),1),AD=Se(ec(),1),aQ=Se(bs(),1);function cb(t){let n=t[Symbol.asyncIterator]();return n[Symbol.asyncDispose]?n:HD(n,async()=>{var e;await((e=n.return)===null||e===void 0?void 0:e.call(n))})}function cQ(t,n){return tb.apply(this,arguments)}function tb(){return tb=(0,aQ.default)(function*(t,n){try{var e=(0,sQ.default)();let r=e.a(cb(t)),i,o=e.u(UD(n.gracePeriodMs)),s=n.count,a=new Promise(()=>{});for(;;){if(i=yield(0,AD.default)(ob.race([r.next(),a])),i===sb&&QZ(),i.done)return i.value;yield i.value,--s===0&&(a=o.start()),i=null}}catch(r){e.e=r}finally{yield(0,AD.default)(e.d())}}),tb.apply(this,arguments)}function ND(){let t,n;return{promise:new Promise((r,i)=>{t=r,n=i}),resolve:t,reject:n}}var uQ=Se(Xa(),1),PD=Se(ec(),1),lQ=Se(bs(),1);function dQ(t,n){let e=t[Symbol.asyncIterator](),r="idle";function i(){r="done",n=()=>{}}function o(){if(r!=="idle")return;r="pending",e.next().then(a=>{if(a.done){r="done",n({status:"return",value:a.value}),i();return}r="idle",n({status:"yield",value:a.value})}).catch(a=>{n({status:"error",error:a}),i()})}return{pull:o,destroy:async()=>{var s;i(),await((s=e.return)===null||s===void 0?void 0:s.call(e))}}}function fQ(){let t="idle",n=ND(),e=[],r=new Set,i=[];function o(s){if(t!=="pending")return;let a=dQ(s,c=>{if(t==="pending"){switch(c.status){case"yield":i.push([a,c]);break;case"return":r.delete(a);break;case"error":i.push([a,c]),r.delete(a);break}n.resolve()}});r.add(a),a.pull()}return{add(s){switch(t){case"idle":e.push(s);break;case"pending":o(s);break;case"done":break}},[Symbol.asyncIterator](){return(0,lQ.default)(function*(){try{var s=(0,uQ.default)();if(t!=="idle")throw new Error("Cannot iterate twice");t="pending";let a=s.a(HD({},async()=>{t="done";let c=[];if(await Promise.all(Array.from(r.values()).map(async u=>{try{await u.destroy()}catch(l){c.push(l)}})),i.length=0,r.clear(),n.resolve(),c.length>0)throw new AggregateError(c)}));for(;e.length>0;)o(e.shift());for(;r.size>0;){for(yield(0,PD.default)(n.promise);i.length>0;){let[c,u]=i.shift();switch(u.status){case"yield":yield u.value,c.pull();break;case"error":throw u.error}}n=ND()}}catch(a){s.e=a}finally{yield(0,PD.default)(s.d())}})()}}}function VD(t){let n=t[Symbol.asyncIterator]();return new ReadableStream({async cancel(){var e;await((e=n.return)===null||e===void 0?void 0:e.call(n))},async pull(e){let r=await n.next();if(r.done){e.close();return}e.enqueue(r.value)}})}var RD=Se(Xa(),1),kD=Se(ec(),1),hQ=Se(bs(),1),Ja=Symbol("ping");function WD(t,n){return nb.apply(this,arguments)}function nb(){return nb=(0,hQ.default)(function*(t,n){try{var e=(0,RD.default)();let i=e.a(cb(t)),o,s=i.next();for(;;)try{var r=(0,RD.default)();let a=r.u(UD(n));if(o=yield(0,kD.default)(ob.race([s,a.start()])),o===sb){yield Ja;continue}if(o.done)return o.value;s=i.next(),yield o.value,o=null}catch(a){r.e=a}finally{r.d()}}catch(i){e.e=i}finally{yield(0,kD.default)(e.d())}}),nb.apply(this,arguments)}var GD=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(t,n){function e(i){var o,s,a,c=2;for(typeof Symbol<"u"&&(s=Symbol.asyncIterator,a=Symbol.iterator);c--;){if(s&&(o=i[s])!=null)return o.call(i);if(a&&(o=i[a])!=null)return new r(o.call(i));s="@@asyncIterator",a="@@iterator"}throw new TypeError("Object is not async iterable")}function r(i){function o(s){if(Object(s)!==s)return Promise.reject(new TypeError(s+" is not an object."));var a=s.done;return Promise.resolve(s.value).then(function(c){return{value:c,done:a}})}return r=function(a){this.s=a,this.n=a.next},r.prototype={s:null,n:null,next:function(){return o(this.n.apply(this.s,arguments))},return:function(a){var c=this.s.return;return c===void 0?Promise.resolve({value:a,done:!0}):o(c.apply(this.s,arguments))},throw:function(a){var c=this.s.return;return c===void 0?Promise.reject(a):o(c.apply(this.s,arguments))}},new r(i)}n.exports=e,n.exports.__esModule=!0,n.exports.default=n.exports}}),Za=Se(ec(),1),X_=Se(bs(),1),pQ=Se(Xa(),1),mQ=Se(GD(),1),gQ=0,yQ=1,vQ=0,_Q=1,bQ=0,wQ=1,EQ=2;function zD(t){return(ft(t)||xh(t))&&typeof t?.then=="function"&&typeof t?.catch=="function"}var SQ=class extends Error{constructor(t){super("Max depth reached at path: "+t.join(".")),this.path=t}};function CQ(t){return rb.apply(this,arguments)}function rb(){return rb=(0,X_.default)(function*(t){let{data:n}=t,e=0,r=0,i=fQ();function o(D){let T=e++,K=D(T);return i.add(K),T}function s(D,T){return o((function(){var K=(0,X_.default)(function*(H){let re=c(T);re&&(D.catch(z=>{var rt;(rt=t.onError)===null||rt===void 0||rt.call(t,{error:z,path:T})}),D=Promise.reject(re));try{let z=yield(0,Za.default)(D);yield[H,vQ,l(z,T)]}catch(z){var Ee,pe;(Ee=t.onError)===null||Ee===void 0||Ee.call(t,{error:z,path:T}),yield[H,_Q,(pe=t.formatError)===null||pe===void 0?void 0:pe.call(t,{error:z,path:T})]}});return function(H){return K.apply(this,arguments)}})())}function a(D,T){return o((function(){var K=(0,X_.default)(function*(H){try{var re=(0,pQ.default)();let z=c(T);if(z)throw z;let rt=re.a(cb(D));try{for(;;){let ee=yield(0,Za.default)(rt.next());if(ee.done){yield[H,bQ,l(ee.value,T)];break}yield[H,wQ,l(ee.value,T)]}}catch(ee){var Ee,pe;(Ee=t.onError)===null||Ee===void 0||Ee.call(t,{error:ee,path:T}),yield[H,EQ,(pe=t.formatError)===null||pe===void 0?void 0:pe.call(t,{error:ee,path:T})]}}catch(z){re.e=z}finally{yield(0,Za.default)(re.d())}});return function(H){return K.apply(this,arguments)}})())}function c(D){return t.maxDepth&&D.length>t.maxDepth?new SQ(D):null}function u(D,T){if(zD(D))return[gQ,s(D,T)];if(Ga(D)){if(t.maxDepth&&T.length>=t.maxDepth)throw new Error("Max depth reached");return[yQ,a(D,T)]}return null}function l(D,T){if(D===void 0)return[[]];let K=u(D,T);if(K)return[[r],[null,...K]];if(!JZ(D))return[[D]];let H=Ht(),re=[];for(let[Ee,pe]of Object.entries(D)){let z=u(pe,[...T,Ee]);if(!z){H[Ee]=pe;continue}H[Ee]=r,re.push([Ee,...z])}return[[H],...re]}let d=Ht();for(let[D,T]of Object.entries(n))d[D]=l(T,[D]);yield d;let f=i;t.pingMs&&(f=WD(i,t.pingMs));var p=!1,m=!1,y;try{for(var b=(0,mQ.default)(f),E;p=!(E=yield(0,Za.default)(b.next())).done;p=!1)yield E.value}catch(D){m=!0,y=D}finally{try{p&&b.return!=null&&(yield(0,Za.default)(b.return()))}finally{if(m)throw y}}}),rb.apply(this,arguments)}function IQ(t){let n=VD(CQ(t)),{serialize:e}=t;return e&&(n=n.pipeThrough(new TransformStream({transform(r,i){r===Ja?i.enqueue(Ja):i.enqueue(e(r))}}))),n.pipeThrough(new TransformStream({transform(r,i){r===Ja?i.enqueue(" "):i.enqueue(JSON.stringify(r)+`
8
- `)}})).pipeThrough(new TextEncoderStream)}var TQ=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncGeneratorDelegate.js"(t,n){var e=ab();function r(i){var o={},s=!1;function a(c,u){return s=!0,u=new Promise(function(l){l(i[c](u))}),{done:!1,value:new e(u,1)}}return o[typeof Symbol<"u"&&Symbol.iterator||"@@iterator"]=function(){return this},o.next=function(c){return s?(s=!1,c):a("next",c)},typeof i.throw=="function"&&(o.throw=function(c){if(s)throw s=!1,c;return a("throw",c)}),typeof i.return=="function"&&(o.return=function(c){return s?(s=!1,c):a("return",c)}),o}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),LD=Se(GD(),1),jD=Se(ec(),1),FD=Se(bs(),1),xQ=Se(TQ(),1),Uwe=Se(Xa(),1),DQ="ping",OQ="serialized-error",MQ="connected",AQ="return";function NQ(t){var n,e,r,i,o;let{serialize:s=cD}=t,a={enabled:(n=(e=t.ping)===null||e===void 0?void 0:e.enabled)!==null&&n!==void 0?n:!1,intervalMs:(r=(i=t.ping)===null||i===void 0?void 0:i.intervalMs)!==null&&r!==void 0?r:1e3},c=(o=t.client)!==null&&o!==void 0?o:{};if(a.enabled&&c.reconnectAfterInactivityMs&&a.intervalMs>c.reconnectAfterInactivityMs)throw new Error(`Ping interval must be less than client reconnect interval to prevent unnecessary reconnection - ping.intervalMs: ${a.intervalMs} client.reconnectAfterInactivityMs: ${c.reconnectAfterInactivityMs}`);function u(){return l.apply(this,arguments)}function l(){return l=(0,FD.default)(function*(){yield{event:MQ,data:JSON.stringify(c)};let m=t.data;t.emitAndEndImmediately&&(m=cQ(m,{count:1,gracePeriodMs:1})),a.enabled&&a.intervalMs!==1/0&&a.intervalMs>0&&(m=WD(m,a.intervalMs));let y,b;var E=!1,D=!1,T;try{for(var K=(0,LD.default)(m),H;E=!(H=yield(0,jD.default)(K.next())).done;E=!1){y=H.value;{if(y===Ja){yield{event:DQ,data:""};continue}b=CD(y)?{id:y[0],data:y[1]}:{data:y},b.data=JSON.stringify(s(b.data)),yield b,y=null,b=null}}}catch(re){D=!0,T=re}finally{try{E&&K.return!=null&&(yield(0,jD.default)(K.return()))}finally{if(D)throw T}}}),l.apply(this,arguments)}function d(){return f.apply(this,arguments)}function f(){return f=(0,FD.default)(function*(){try{yield*(0,xQ.default)((0,LD.default)(u())),yield{event:AQ,data:""}}catch(b){var m,y;if(ZZ(b))return;let E=Yt(b),D=(m=(y=t.formatError)===null||y===void 0?void 0:y.call(t,{error:E}))!==null&&m!==void 0?m:null;yield{event:OQ,data:JSON.stringify(s(D))}}}),f.apply(this,arguments)}return VD(d()).pipeThrough(new TransformStream({transform(m,y){"event"in m&&y.enqueue(`event: ${m.event}
6
+ `):"",this.name="UnsubscriptionError",this.errors=e}})});var Rn=v(Yc=>{"use strict";Object.defineProperty(Yc,"__esModule",{value:!0});Yc.arrRemove=void 0;function UR(t,n){if(t){var e=t.indexOf(n);0<=e&&t.splice(e,1)}}Yc.arrRemove=UR});var Lt=v(Ct=>{"use strict";var rS=Ct&&Ct.__values||function(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")},iS=Ct&&Ct.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},oS=Ct&&Ct.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Ct,"__esModule",{value:!0});Ct.isSubscription=Ct.EMPTY_SUBSCRIPTION=Ct.Subscription=void 0;var ia=ke(),_m=vm(),sS=Rn(),bm=(function(){function t(n){this.initialTeardown=n,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var n,e,r,i,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var a=rS(s),c=a.next();!c.done;c=a.next()){var u=c.value;u.remove(this)}}catch(y){n={error:y}}finally{try{c&&!c.done&&(e=a.return)&&e.call(a)}finally{if(n)throw n.error}}else s.remove(this);var l=this.initialTeardown;if(ia.isFunction(l))try{l()}catch(y){o=y instanceof _m.UnsubscriptionError?y.errors:[y]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var f=rS(d),p=f.next();!p.done;p=f.next()){var m=p.value;try{aS(m)}catch(y){o=o??[],y instanceof _m.UnsubscriptionError?o=oS(oS([],iS(o)),iS(y.errors)):o.push(y)}}}catch(y){r={error:y}}finally{try{p&&!p.done&&(i=f.return)&&i.call(f)}finally{if(r)throw r.error}}}if(o)throw new _m.UnsubscriptionError(o)}},t.prototype.add=function(n){var e;if(n&&n!==this)if(this.closed)aS(n);else{if(n instanceof t){if(n.closed||n._hasParent(this))return;n._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(n)}},t.prototype._hasParent=function(n){var e=this._parentage;return e===n||Array.isArray(e)&&e.includes(n)},t.prototype._addParent=function(n){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(n),e):e?[e,n]:n},t.prototype._removeParent=function(n){var e=this._parentage;e===n?this._parentage=null:Array.isArray(e)&&sS.arrRemove(e,n)},t.prototype.remove=function(n){var e=this._finalizers;e&&sS.arrRemove(e,n),n instanceof t&&n._removeParent(this)},t.EMPTY=(function(){var n=new t;return n.closed=!0,n})(),t})();Ct.Subscription=bm;Ct.EMPTY_SUBSCRIPTION=bm.EMPTY;function VR(t){return t instanceof bm||t&&"closed"in t&&ia.isFunction(t.remove)&&ia.isFunction(t.add)&&ia.isFunction(t.unsubscribe)}Ct.isSubscription=VR;function aS(t){ia.isFunction(t)?t():t.unsubscribe()}});var ro=v(Zc=>{"use strict";Object.defineProperty(Zc,"__esModule",{value:!0});Zc.config=void 0;Zc.config={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1}});var wm=v(pn=>{"use strict";var cS=pn&&pn.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},uS=pn&&pn.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(pn,"__esModule",{value:!0});pn.timeoutProvider=void 0;pn.timeoutProvider={setTimeout:function(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var i=pn.timeoutProvider.delegate;return i?.setTimeout?i.setTimeout.apply(i,uS([t,n],cS(e))):setTimeout.apply(void 0,uS([t,n],cS(e)))},clearTimeout:function(t){var n=pn.timeoutProvider.delegate;return(n?.clearTimeout||clearTimeout)(t)},delegate:void 0}});var Em=v(Qc=>{"use strict";Object.defineProperty(Qc,"__esModule",{value:!0});Qc.reportUnhandledError=void 0;var WR=ro(),GR=wm();function zR(t){GR.timeoutProvider.setTimeout(function(){var n=WR.config.onUnhandledError;if(n)n(t);else throw t})}Qc.reportUnhandledError=zR});var ct=v(Jc=>{"use strict";Object.defineProperty(Jc,"__esModule",{value:!0});Jc.noop=void 0;function KR(){}Jc.noop=KR});var lS=v(mn=>{"use strict";Object.defineProperty(mn,"__esModule",{value:!0});mn.createNotification=mn.nextNotification=mn.errorNotification=mn.COMPLETE_NOTIFICATION=void 0;mn.COMPLETE_NOTIFICATION=(function(){return Xc("C",void 0,void 0)})();function YR(t){return Xc("E",void 0,t)}mn.errorNotification=YR;function ZR(t){return Xc("N",t,void 0)}mn.nextNotification=ZR;function Xc(t,n,e){return{kind:t,value:n,error:e}}mn.createNotification=Xc});var eu=v(io=>{"use strict";Object.defineProperty(io,"__esModule",{value:!0});io.captureError=io.errorContext=void 0;var dS=ro(),oi=null;function QR(t){if(dS.config.useDeprecatedSynchronousErrorHandling){var n=!oi;if(n&&(oi={errorThrown:!1,error:null}),t(),n){var e=oi,r=e.errorThrown,i=e.error;if(oi=null,r)throw i}}else t()}io.errorContext=QR;function JR(t){dS.config.useDeprecatedSynchronousErrorHandling&&oi&&(oi.errorThrown=!0,oi.error=t)}io.captureError=JR});var oo=v(nn=>{"use strict";var pS=nn&&nn.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(nn,"__esModule",{value:!0});nn.EMPTY_OBSERVER=nn.SafeSubscriber=nn.Subscriber=void 0;var XR=ke(),fS=Lt(),Tm=ro(),ek=Em(),hS=ct(),Sm=lS(),tk=wm(),nk=eu(),mS=(function(t){pS(n,t);function n(e){var r=t.call(this)||this;return r.isStopped=!1,e?(r.destination=e,fS.isSubscription(e)&&e.add(r)):r.destination=nn.EMPTY_OBSERVER,r}return n.create=function(e,r,i){return new gS(e,r,i)},n.prototype.next=function(e){this.isStopped?Im(Sm.nextNotification(e),this):this._next(e)},n.prototype.error=function(e){this.isStopped?Im(Sm.errorNotification(e),this):(this.isStopped=!0,this._error(e))},n.prototype.complete=function(){this.isStopped?Im(Sm.COMPLETE_NOTIFICATION,this):(this.isStopped=!0,this._complete())},n.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},n.prototype._next=function(e){this.destination.next(e)},n.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},n.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},n})(fS.Subscription);nn.Subscriber=mS;var rk=Function.prototype.bind;function Cm(t,n){return rk.call(t,n)}var ik=(function(){function t(n){this.partialObserver=n}return t.prototype.next=function(n){var e=this.partialObserver;if(e.next)try{e.next(n)}catch(r){tu(r)}},t.prototype.error=function(n){var e=this.partialObserver;if(e.error)try{e.error(n)}catch(r){tu(r)}else tu(n)},t.prototype.complete=function(){var n=this.partialObserver;if(n.complete)try{n.complete()}catch(e){tu(e)}},t})(),gS=(function(t){pS(n,t);function n(e,r,i){var o=t.call(this)||this,s;if(XR.isFunction(e)||!e)s={next:e??void 0,error:r??void 0,complete:i??void 0};else{var a;o&&Tm.config.useDeprecatedNextContext?(a=Object.create(e),a.unsubscribe=function(){return o.unsubscribe()},s={next:e.next&&Cm(e.next,a),error:e.error&&Cm(e.error,a),complete:e.complete&&Cm(e.complete,a)}):s=e}return o.destination=new ik(s),o}return n})(mS);nn.SafeSubscriber=gS;function tu(t){Tm.config.useDeprecatedSynchronousErrorHandling?nk.captureError(t):ek.reportUnhandledError(t)}function ok(t){throw t}function Im(t,n){var e=Tm.config.onStoppedNotification;e&&tk.timeoutProvider.setTimeout(function(){return e(t,n)})}nn.EMPTY_OBSERVER={closed:!0,next:hS.noop,error:ok,complete:hS.noop}});var oa=v(nu=>{"use strict";Object.defineProperty(nu,"__esModule",{value:!0});nu.observable=void 0;nu.observable=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})()});var ut=v(ru=>{"use strict";Object.defineProperty(ru,"__esModule",{value:!0});ru.identity=void 0;function sk(t){return t}ru.identity=sk});var sa=v(so=>{"use strict";Object.defineProperty(so,"__esModule",{value:!0});so.pipeFromArray=so.pipe=void 0;var ak=ut();function ck(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return yS(t)}so.pipe=ck;function yS(t){return t.length===0?ak.identity:t.length===1?t[0]:function(e){return t.reduce(function(r,i){return i(r)},e)}}so.pipeFromArray=yS});var je=v(iu=>{"use strict";Object.defineProperty(iu,"__esModule",{value:!0});iu.Observable=void 0;var Dm=oo(),uk=Lt(),lk=oa(),dk=sa(),fk=ro(),xm=ke(),hk=eu(),pk=(function(){function t(n){n&&(this._subscribe=n)}return t.prototype.lift=function(n){var e=new t;return e.source=this,e.operator=n,e},t.prototype.subscribe=function(n,e,r){var i=this,o=gk(n)?n:new Dm.SafeSubscriber(n,e,r);return hk.errorContext(function(){var s=i,a=s.operator,c=s.source;o.add(a?a.call(o,c):c?i._subscribe(o):i._trySubscribe(o))}),o},t.prototype._trySubscribe=function(n){try{return this._subscribe(n)}catch(e){n.error(e)}},t.prototype.forEach=function(n,e){var r=this;return e=vS(e),new e(function(i,o){var s=new Dm.SafeSubscriber({next:function(a){try{n(a)}catch(c){o(c),s.unsubscribe()}},error:o,complete:i});r.subscribe(s)})},t.prototype._subscribe=function(n){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(n)},t.prototype[lk.observable]=function(){return this},t.prototype.pipe=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return dk.pipeFromArray(n)(this)},t.prototype.toPromise=function(n){var e=this;return n=vS(n),new n(function(r,i){var o;e.subscribe(function(s){return o=s},function(s){return i(s)},function(){return r(o)})})},t.create=function(n){return new t(n)},t})();iu.Observable=pk;function vS(t){var n;return(n=t??fk.config.Promise)!==null&&n!==void 0?n:Promise}function mk(t){return t&&xm.isFunction(t.next)&&xm.isFunction(t.error)&&xm.isFunction(t.complete)}function gk(t){return t&&t instanceof Dm.Subscriber||mk(t)&&uk.isSubscription(t)}});var L=v(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.operate=ao.hasLift=void 0;var yk=ke();function _S(t){return yk.isFunction(t?.lift)}ao.hasLift=_S;function vk(t){return function(n){if(_S(n))return n.lift(function(e){try{return t(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}ao.operate=vk});var V=v(dr=>{"use strict";var _k=dr&&dr.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(dr,"__esModule",{value:!0});dr.OperatorSubscriber=dr.createOperatorSubscriber=void 0;var bk=oo();function wk(t,n,e,r,i){return new bS(t,n,e,r,i)}dr.createOperatorSubscriber=wk;var bS=(function(t){_k(n,t);function n(e,r,i,o,s,a){var c=t.call(this,e)||this;return c.onFinalize=s,c.shouldUnsubscribe=a,c._next=r?function(u){try{r(u)}catch(l){e.error(l)}}:t.prototype._next,c._error=o?function(u){try{o(u)}catch(l){e.error(l)}finally{this.unsubscribe()}}:t.prototype._error,c._complete=i?function(){try{i()}catch(u){e.error(u)}finally{this.unsubscribe()}}:t.prototype._complete,c}return n.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},n})(bk.Subscriber);dr.OperatorSubscriber=bS});var su=v(ou=>{"use strict";Object.defineProperty(ou,"__esModule",{value:!0});ou.refCount=void 0;var Ek=L(),Sk=V();function Ck(){return Ek.operate(function(t,n){var e=null;t._refCount++;var r=Sk.createOperatorSubscriber(n,void 0,void 0,void 0,function(){if(!t||t._refCount<=0||0<--t._refCount){e=null;return}var i=t._connection,o=e;e=null,i&&(!o||i===o)&&i.unsubscribe(),n.unsubscribe()});t.subscribe(r),r.closed||(e=t.connect())})}ou.refCount=Ck});var aa=v(co=>{"use strict";var Ik=co&&co.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(co,"__esModule",{value:!0});co.ConnectableObservable=void 0;var Tk=je(),wS=Lt(),xk=su(),Dk=V(),Ok=L(),Mk=(function(t){Ik(n,t);function n(e,r){var i=t.call(this)||this;return i.source=e,i.subjectFactory=r,i._subject=null,i._refCount=0,i._connection=null,Ok.hasLift(e)&&(i.lift=e.lift),i}return n.prototype._subscribe=function(e){return this.getSubject().subscribe(e)},n.prototype.getSubject=function(){var e=this._subject;return(!e||e.isStopped)&&(this._subject=this.subjectFactory()),this._subject},n.prototype._teardown=function(){this._refCount=0;var e=this._connection;this._subject=this._connection=null,e?.unsubscribe()},n.prototype.connect=function(){var e=this,r=this._connection;if(!r){r=this._connection=new wS.Subscription;var i=this.getSubject();r.add(this.source.subscribe(Dk.createOperatorSubscriber(i,void 0,function(){e._teardown(),i.complete()},function(o){e._teardown(),i.error(o)},function(){return e._teardown()}))),r.closed&&(this._connection=null,r=wS.Subscription.EMPTY)}return r},n.prototype.refCount=function(){return xk.refCount()(this)},n})(Tk.Observable);co.ConnectableObservable=Mk});var ES=v(ca=>{"use strict";Object.defineProperty(ca,"__esModule",{value:!0});ca.performanceTimestampProvider=void 0;ca.performanceTimestampProvider={now:function(){return(ca.performanceTimestampProvider.delegate||performance).now()},delegate:void 0}});var Om=v(rn=>{"use strict";var SS=rn&&rn.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},CS=rn&&rn.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(rn,"__esModule",{value:!0});rn.animationFrameProvider=void 0;var Ak=Lt();rn.animationFrameProvider={schedule:function(t){var n=requestAnimationFrame,e=cancelAnimationFrame,r=rn.animationFrameProvider.delegate;r&&(n=r.requestAnimationFrame,e=r.cancelAnimationFrame);var i=n(function(o){e=void 0,t(o)});return new Ak.Subscription(function(){return e?.(i)})},requestAnimationFrame:function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=rn.animationFrameProvider.delegate;return(e?.requestAnimationFrame||requestAnimationFrame).apply(void 0,CS([],SS(t)))},cancelAnimationFrame:function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=rn.animationFrameProvider.delegate;return(e?.cancelAnimationFrame||cancelAnimationFrame).apply(void 0,CS([],SS(t)))},delegate:void 0}});var xS=v(au=>{"use strict";Object.defineProperty(au,"__esModule",{value:!0});au.animationFrames=void 0;var Nk=je(),Pk=ES(),IS=Om();function Rk(t){return t?TS(t):kk}au.animationFrames=Rk;function TS(t){return new Nk.Observable(function(n){var e=t||Pk.performanceTimestampProvider,r=e.now(),i=0,o=function(){n.closed||(i=IS.animationFrameProvider.requestAnimationFrame(function(s){i=0;var a=e.now();n.next({timestamp:t?a:s,elapsed:a-r}),o()}))};return o(),function(){i&&IS.animationFrameProvider.cancelAnimationFrame(i)}})}var kk=TS()});var Mm=v(cu=>{"use strict";Object.defineProperty(cu,"__esModule",{value:!0});cu.ObjectUnsubscribedError=void 0;var Lk=lr();cu.ObjectUnsubscribedError=Lk.createErrorClass(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})});var lt=v(gn=>{"use strict";var OS=gn&&gn.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})(),jk=gn&&gn.__values||function(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(gn,"__esModule",{value:!0});gn.AnonymousSubject=gn.Subject=void 0;var DS=je(),Nm=Lt(),Fk=Mm(),$k=Rn(),Am=eu(),MS=(function(t){OS(n,t);function n(){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 n.prototype.lift=function(e){var r=new Pm(this,this);return r.operator=e,r},n.prototype._throwIfClosed=function(){if(this.closed)throw new Fk.ObjectUnsubscribedError},n.prototype.next=function(e){var r=this;Am.errorContext(function(){var i,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=jk(r.currentObservers),a=s.next();!a.done;a=s.next()){var c=a.value;c.next(e)}}catch(u){i={error:u}}finally{try{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}})},n.prototype.error=function(e){var r=this;Am.errorContext(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=e;for(var i=r.observers;i.length;)i.shift().error(e)}})},n.prototype.complete=function(){var e=this;Am.errorContext(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var r=e.observers;r.length;)r.shift().complete()}})},n.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(n.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),n.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},n.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},n.prototype._innerSubscribe=function(e){var r=this,i=this,o=i.hasError,s=i.isStopped,a=i.observers;return o||s?Nm.EMPTY_SUBSCRIPTION:(this.currentObservers=null,a.push(e),new Nm.Subscription(function(){r.currentObservers=null,$k.arrRemove(a,e)}))},n.prototype._checkFinalizedStatuses=function(e){var r=this,i=r.hasError,o=r.thrownError,s=r.isStopped;i?e.error(o):s&&e.complete()},n.prototype.asObservable=function(){var e=new DS.Observable;return e.source=this,e},n.create=function(e,r){return new Pm(e,r)},n})(DS.Observable);gn.Subject=MS;var Pm=(function(t){OS(n,t);function n(e,r){var i=t.call(this)||this;return i.destination=e,i.source=r,i}return n.prototype.next=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,e)},n.prototype.error=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.call(r,e)},n.prototype.complete=function(){var e,r;(r=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||r===void 0||r.call(e)},n.prototype._subscribe=function(e){var r,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(e))!==null&&i!==void 0?i:Nm.EMPTY_SUBSCRIPTION},n})(MS);gn.AnonymousSubject=Pm});var Rm=v(uo=>{"use strict";var qk=uo&&uo.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(uo,"__esModule",{value:!0});uo.BehaviorSubject=void 0;var Bk=lt(),Hk=(function(t){qk(n,t);function n(e){var r=t.call(this)||this;return r._value=e,r}return Object.defineProperty(n.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),n.prototype._subscribe=function(e){var r=t.prototype._subscribe.call(this,e);return!r.closed&&e.next(this._value),r},n.prototype.getValue=function(){var e=this,r=e.hasError,i=e.thrownError,o=e._value;if(r)throw i;return this._throwIfClosed(),o},n.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},n})(Bk.Subject);uo.BehaviorSubject=Hk});var uu=v(ua=>{"use strict";Object.defineProperty(ua,"__esModule",{value:!0});ua.dateTimestampProvider=void 0;ua.dateTimestampProvider={now:function(){return(ua.dateTimestampProvider.delegate||Date).now()},delegate:void 0}});var lu=v(lo=>{"use strict";var Uk=lo&&lo.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(lo,"__esModule",{value:!0});lo.ReplaySubject=void 0;var Vk=lt(),Wk=uu(),Gk=(function(t){Uk(n,t);function n(e,r,i){e===void 0&&(e=1/0),r===void 0&&(r=1/0),i===void 0&&(i=Wk.dateTimestampProvider);var o=t.call(this)||this;return o._bufferSize=e,o._windowTime=r,o._timestampProvider=i,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,e),o._windowTime=Math.max(1,r),o}return n.prototype.next=function(e){var r=this,i=r.isStopped,o=r._buffer,s=r._infiniteTimeWindow,a=r._timestampProvider,c=r._windowTime;i||(o.push(e),!s&&o.push(a.now()+c)),this._trimBuffer(),t.prototype.next.call(this,e)},n.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(e),i=this,o=i._infiniteTimeWindow,s=i._buffer,a=s.slice(),c=0;c<a.length&&!e.closed;c+=o?1:2)e.next(a[c]);return this._checkFinalizedStatuses(e),r},n.prototype._trimBuffer=function(){var e=this,r=e._bufferSize,i=e._timestampProvider,o=e._buffer,s=e._infiniteTimeWindow,a=(s?1:2)*r;if(r<1/0&&a<o.length&&o.splice(0,o.length-a),!s){for(var c=i.now(),u=0,l=1;l<o.length&&o[l]<=c;l+=2)u=l;u&&o.splice(0,u+1)}},n})(Vk.Subject);lo.ReplaySubject=Gk});var du=v(fo=>{"use strict";var zk=fo&&fo.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(fo,"__esModule",{value:!0});fo.AsyncSubject=void 0;var Kk=lt(),Yk=(function(t){zk(n,t);function n(){var e=t!==null&&t.apply(this,arguments)||this;return e._value=null,e._hasValue=!1,e._isComplete=!1,e}return n.prototype._checkFinalizedStatuses=function(e){var r=this,i=r.hasError,o=r._hasValue,s=r._value,a=r.thrownError,c=r.isStopped,u=r._isComplete;i?e.error(a):(c||u)&&(o&&e.next(s),e.complete())},n.prototype.next=function(e){this.isStopped||(this._value=e,this._hasValue=!0)},n.prototype.complete=function(){var e=this,r=e._hasValue,i=e._value,o=e._isComplete;o||(this._isComplete=!0,r&&t.prototype.next.call(this,i),t.prototype.complete.call(this))},n})(Kk.Subject);fo.AsyncSubject=Yk});var AS=v(ho=>{"use strict";var Zk=ho&&ho.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(ho,"__esModule",{value:!0});ho.Action=void 0;var Qk=Lt(),Jk=(function(t){Zk(n,t);function n(e,r){return t.call(this)||this}return n.prototype.schedule=function(e,r){return r===void 0&&(r=0),this},n})(Qk.Subscription);ho.Action=Jk});var RS=v(yn=>{"use strict";var NS=yn&&yn.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},PS=yn&&yn.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(yn,"__esModule",{value:!0});yn.intervalProvider=void 0;yn.intervalProvider={setInterval:function(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var i=yn.intervalProvider.delegate;return i?.setInterval?i.setInterval.apply(i,PS([t,n],NS(e))):setInterval.apply(void 0,PS([t,n],NS(e)))},clearInterval:function(t){var n=yn.intervalProvider.delegate;return(n?.clearInterval||clearInterval)(t)},delegate:void 0}});var mo=v(po=>{"use strict";var Xk=po&&po.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(po,"__esModule",{value:!0});po.AsyncAction=void 0;var e1=AS(),kS=RS(),t1=Rn(),n1=(function(t){Xk(n,t);function n(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i.pending=!1,i}return n.prototype.schedule=function(e,r){var i;if(r===void 0&&(r=0),this.closed)return this;this.state=e;var o=this.id,s=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(s,o,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(s,this.id,r),this},n.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),kS.intervalProvider.setInterval(e.flush.bind(e,this),i)},n.prototype.recycleAsyncId=function(e,r,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return r;r!=null&&kS.intervalProvider.clearInterval(r)},n.prototype.execute=function(e,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(e,r);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},n.prototype._execute=function(e,r){var i=!1,o;try{this.work(e)}catch(s){i=!0,o=s||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),o},n.prototype.unsubscribe=function(){if(!this.closed){var e=this,r=e.id,i=e.scheduler,o=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,t1.arrRemove(o,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},n})(e1.Action);po.AsyncAction=n1});var jS=v(go=>{"use strict";Object.defineProperty(go,"__esModule",{value:!0});go.TestTools=go.Immediate=void 0;var r1=1,km,fu={};function LS(t){return t in fu?(delete fu[t],!0):!1}go.Immediate={setImmediate:function(t){var n=r1++;return fu[n]=!0,km||(km=Promise.resolve()),km.then(function(){return LS(n)&&t()}),n},clearImmediate:function(t){LS(t)}};go.TestTools={pending:function(){return Object.keys(fu).length}}});var $S=v(vn=>{"use strict";var i1=vn&&vn.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},o1=vn&&vn.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(vn,"__esModule",{value:!0});vn.immediateProvider=void 0;var FS=jS(),s1=FS.Immediate.setImmediate,a1=FS.Immediate.clearImmediate;vn.immediateProvider={setImmediate:function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=vn.immediateProvider.delegate;return(e?.setImmediate||s1).apply(void 0,o1([],i1(t)))},clearImmediate:function(t){var n=vn.immediateProvider.delegate;return(n?.clearImmediate||a1)(t)},delegate:void 0}});var BS=v(yo=>{"use strict";var c1=yo&&yo.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(yo,"__esModule",{value:!0});yo.AsapAction=void 0;var u1=mo(),qS=$S(),l1=(function(t){c1(n,t);function n(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i}return n.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),i!==null&&i>0?t.prototype.requestAsyncId.call(this,e,r,i):(e.actions.push(this),e._scheduled||(e._scheduled=qS.immediateProvider.setImmediate(e.flush.bind(e,void 0))))},n.prototype.recycleAsyncId=function(e,r,i){var o;if(i===void 0&&(i=0),i!=null?i>0:this.delay>0)return t.prototype.recycleAsyncId.call(this,e,r,i);var s=e.actions;r!=null&&((o=s[s.length-1])===null||o===void 0?void 0:o.id)!==r&&(qS.immediateProvider.clearImmediate(r),e._scheduled===r&&(e._scheduled=void 0))},n})(u1.AsyncAction);yo.AsapAction=l1});var Lm=v(hu=>{"use strict";Object.defineProperty(hu,"__esModule",{value:!0});hu.Scheduler=void 0;var d1=uu(),f1=(function(){function t(n,e){e===void 0&&(e=t.now),this.schedulerActionCtor=n,this.now=e}return t.prototype.schedule=function(n,e,r){return e===void 0&&(e=0),new this.schedulerActionCtor(this,n).schedule(r,e)},t.now=d1.dateTimestampProvider.now,t})();hu.Scheduler=f1});var _o=v(vo=>{"use strict";var h1=vo&&vo.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(vo,"__esModule",{value:!0});vo.AsyncScheduler=void 0;var HS=Lm(),p1=(function(t){h1(n,t);function n(e,r){r===void 0&&(r=HS.Scheduler.now);var i=t.call(this,e,r)||this;return i.actions=[],i._active=!1,i}return n.prototype.flush=function(e){var r=this.actions;if(this._active){r.push(e);return}var i;this._active=!0;do if(i=e.execute(e.state,e.delay))break;while(e=r.shift());if(this._active=!1,i){for(;e=r.shift();)e.unsubscribe();throw i}},n})(HS.Scheduler);vo.AsyncScheduler=p1});var US=v(bo=>{"use strict";var m1=bo&&bo.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(bo,"__esModule",{value:!0});bo.AsapScheduler=void 0;var g1=_o(),y1=(function(t){m1(n,t);function n(){return t!==null&&t.apply(this,arguments)||this}return n.prototype.flush=function(e){this._active=!0;var r=this._scheduled;this._scheduled=void 0;var i=this.actions,o;e=e||i.shift();do if(o=e.execute(e.state,e.delay))break;while((e=i[0])&&e.id===r&&i.shift());if(this._active=!1,o){for(;(e=i[0])&&e.id===r&&i.shift();)e.unsubscribe();throw o}},n})(g1.AsyncScheduler);bo.AsapScheduler=y1});var VS=v(si=>{"use strict";Object.defineProperty(si,"__esModule",{value:!0});si.asap=si.asapScheduler=void 0;var v1=BS(),_1=US();si.asapScheduler=new _1.AsapScheduler(v1.AsapAction);si.asap=si.asapScheduler});var It=v(ai=>{"use strict";Object.defineProperty(ai,"__esModule",{value:!0});ai.async=ai.asyncScheduler=void 0;var b1=mo(),w1=_o();ai.asyncScheduler=new w1.AsyncScheduler(b1.AsyncAction);ai.async=ai.asyncScheduler});var WS=v(wo=>{"use strict";var E1=wo&&wo.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(wo,"__esModule",{value:!0});wo.QueueAction=void 0;var S1=mo(),C1=(function(t){E1(n,t);function n(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i}return n.prototype.schedule=function(e,r){return r===void 0&&(r=0),r>0?t.prototype.schedule.call(this,e,r):(this.delay=r,this.state=e,this.scheduler.flush(this),this)},n.prototype.execute=function(e,r){return r>0||this.closed?t.prototype.execute.call(this,e,r):this._execute(e,r)},n.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),i!=null&&i>0||i==null&&this.delay>0?t.prototype.requestAsyncId.call(this,e,r,i):(e.flush(this),0)},n})(S1.AsyncAction);wo.QueueAction=C1});var GS=v(Eo=>{"use strict";var I1=Eo&&Eo.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(Eo,"__esModule",{value:!0});Eo.QueueScheduler=void 0;var T1=_o(),x1=(function(t){I1(n,t);function n(){return t!==null&&t.apply(this,arguments)||this}return n})(T1.AsyncScheduler);Eo.QueueScheduler=x1});var zS=v(ci=>{"use strict";Object.defineProperty(ci,"__esModule",{value:!0});ci.queue=ci.queueScheduler=void 0;var D1=WS(),O1=GS();ci.queueScheduler=new O1.QueueScheduler(D1.QueueAction);ci.queue=ci.queueScheduler});var YS=v(So=>{"use strict";var M1=So&&So.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(So,"__esModule",{value:!0});So.AnimationFrameAction=void 0;var A1=mo(),KS=Om(),N1=(function(t){M1(n,t);function n(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i}return n.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),i!==null&&i>0?t.prototype.requestAsyncId.call(this,e,r,i):(e.actions.push(this),e._scheduled||(e._scheduled=KS.animationFrameProvider.requestAnimationFrame(function(){return e.flush(void 0)})))},n.prototype.recycleAsyncId=function(e,r,i){var o;if(i===void 0&&(i=0),i!=null?i>0:this.delay>0)return t.prototype.recycleAsyncId.call(this,e,r,i);var s=e.actions;r!=null&&r===e._scheduled&&((o=s[s.length-1])===null||o===void 0?void 0:o.id)!==r&&(KS.animationFrameProvider.cancelAnimationFrame(r),e._scheduled=void 0)},n})(A1.AsyncAction);So.AnimationFrameAction=N1});var ZS=v(Co=>{"use strict";var P1=Co&&Co.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(Co,"__esModule",{value:!0});Co.AnimationFrameScheduler=void 0;var R1=_o(),k1=(function(t){P1(n,t);function n(){return t!==null&&t.apply(this,arguments)||this}return n.prototype.flush=function(e){this._active=!0;var r;e?r=e.id:(r=this._scheduled,this._scheduled=void 0);var i=this.actions,o;e=e||i.shift();do if(o=e.execute(e.state,e.delay))break;while((e=i[0])&&e.id===r&&i.shift());if(this._active=!1,o){for(;(e=i[0])&&e.id===r&&i.shift();)e.unsubscribe();throw o}},n})(R1.AsyncScheduler);Co.AnimationFrameScheduler=k1});var QS=v(ui=>{"use strict";Object.defineProperty(ui,"__esModule",{value:!0});ui.animationFrame=ui.animationFrameScheduler=void 0;var L1=YS(),j1=ZS();ui.animationFrameScheduler=new j1.AnimationFrameScheduler(L1.AnimationFrameAction);ui.animationFrame=ui.animationFrameScheduler});var eC=v(fr=>{"use strict";var JS=fr&&fr.__extends||(function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(n,e)};return function(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(n,e);function r(){this.constructor=n}n.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}})();Object.defineProperty(fr,"__esModule",{value:!0});fr.VirtualAction=fr.VirtualTimeScheduler=void 0;var F1=mo(),$1=Lt(),q1=_o(),B1=(function(t){JS(n,t);function n(e,r){e===void 0&&(e=XS),r===void 0&&(r=1/0);var i=t.call(this,e,function(){return i.frame})||this;return i.maxFrames=r,i.frame=0,i.index=-1,i}return n.prototype.flush=function(){for(var e=this,r=e.actions,i=e.maxFrames,o,s;(s=r[0])&&s.delay<=i&&(r.shift(),this.frame=s.delay,!(o=s.execute(s.state,s.delay))););if(o){for(;s=r.shift();)s.unsubscribe();throw o}},n.frameTimeFactor=10,n})(q1.AsyncScheduler);fr.VirtualTimeScheduler=B1;var XS=(function(t){JS(n,t);function n(e,r,i){i===void 0&&(i=e.index+=1);var o=t.call(this,e,r)||this;return o.scheduler=e,o.work=r,o.index=i,o.active=!0,o.index=e.index=i,o}return n.prototype.schedule=function(e,r){if(r===void 0&&(r=0),Number.isFinite(r)){if(!this.id)return t.prototype.schedule.call(this,e,r);this.active=!1;var i=new n(this.scheduler,this.work);return this.add(i),i.schedule(e,r)}else return $1.Subscription.EMPTY},n.prototype.requestAsyncId=function(e,r,i){i===void 0&&(i=0),this.delay=e.frame+i;var o=e.actions;return o.push(this),o.sort(n.sortActions),1},n.prototype.recycleAsyncId=function(e,r,i){i===void 0&&(i=0)},n.prototype._execute=function(e,r){if(this.active===!0)return t.prototype._execute.call(this,e,r)},n.sortActions=function(e,r){return e.delay===r.delay?e.index===r.index?0:e.index>r.index?1:-1:e.delay>r.delay?1:-1},n})(F1.AsyncAction);fr.VirtualAction=XS});var on=v(li=>{"use strict";Object.defineProperty(li,"__esModule",{value:!0});li.empty=li.EMPTY=void 0;var tC=je();li.EMPTY=new tC.Observable(function(t){return t.complete()});function H1(t){return t?U1(t):li.EMPTY}li.empty=H1;function U1(t){return new tC.Observable(function(n){return t.schedule(function(){return n.complete()})})}});var la=v(pu=>{"use strict";Object.defineProperty(pu,"__esModule",{value:!0});pu.isScheduler=void 0;var V1=ke();function W1(t){return t&&V1.isFunction(t.schedule)}pu.isScheduler=W1});var Tt=v(hr=>{"use strict";Object.defineProperty(hr,"__esModule",{value:!0});hr.popNumber=hr.popScheduler=hr.popResultSelector=void 0;var G1=ke(),z1=la();function jm(t){return t[t.length-1]}function K1(t){return G1.isFunction(jm(t))?t.pop():void 0}hr.popResultSelector=K1;function Y1(t){return z1.isScheduler(jm(t))?t.pop():void 0}hr.popScheduler=Y1;function Z1(t,n){return typeof jm(t)=="number"?t.pop():n}hr.popNumber=Z1});var gu=v(mu=>{"use strict";Object.defineProperty(mu,"__esModule",{value:!0});mu.isArrayLike=void 0;mu.isArrayLike=function(t){return t&&typeof t.length=="number"&&typeof t!="function"}});var Fm=v(yu=>{"use strict";Object.defineProperty(yu,"__esModule",{value:!0});yu.isPromise=void 0;var Q1=ke();function J1(t){return Q1.isFunction(t?.then)}yu.isPromise=J1});var $m=v(vu=>{"use strict";Object.defineProperty(vu,"__esModule",{value:!0});vu.isInteropObservable=void 0;var X1=oa(),eL=ke();function tL(t){return eL.isFunction(t[X1.observable])}vu.isInteropObservable=tL});var qm=v(_u=>{"use strict";Object.defineProperty(_u,"__esModule",{value:!0});_u.isAsyncIterable=void 0;var nL=ke();function rL(t){return Symbol.asyncIterator&&nL.isFunction(t?.[Symbol.asyncIterator])}_u.isAsyncIterable=rL});var Bm=v(bu=>{"use strict";Object.defineProperty(bu,"__esModule",{value:!0});bu.createInvalidObservableTypeError=void 0;function iL(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}bu.createInvalidObservableTypeError=iL});var Hm=v(Io=>{"use strict";Object.defineProperty(Io,"__esModule",{value:!0});Io.iterator=Io.getSymbolIterator=void 0;function nC(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}Io.getSymbolIterator=nC;Io.iterator=nC()});var Um=v(wu=>{"use strict";Object.defineProperty(wu,"__esModule",{value:!0});wu.isIterable=void 0;var oL=Hm(),sL=ke();function aL(t){return sL.isFunction(t?.[oL.iterator])}wu.isIterable=aL});var Eu=v(Gt=>{"use strict";var cL=Gt&&Gt.__generator||function(t,n){var e={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(u){return function(l){return c([u,l])}}function c(u){if(r)throw new TypeError("Generator is already executing.");for(;e;)try{if(r=1,i&&(o=u[0]&2?i.return:u[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,u[1])).done)return o;switch(i=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return e.label++,{value:u[1],done:!1};case 5:e.label++,i=u[1],u=[0];continue;case 7:u=e.ops.pop(),e.trys.pop();continue;default:if(o=e.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){e.label=u[1];break}if(u[0]===6&&e.label<o[1]){e.label=o[1],o=u;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(u);break}o[2]&&e.ops.pop(),e.trys.pop();continue}u=n.call(t,e)}catch(l){u=[6,l],i=0}finally{r=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}},To=Gt&&Gt.__await||function(t){return this instanceof To?(this.v=t,this):new To(t)},uL=Gt&&Gt.__asyncGenerator||function(t,n,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(t,n||[]),i,o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(f){r[f]&&(i[f]=function(p){return new Promise(function(m,y){o.push([f,p,m,y])>1||a(f,p)})})}function a(f,p){try{c(r[f](p))}catch(m){d(o[0][3],m)}}function c(f){f.value instanceof To?Promise.resolve(f.value.v).then(u,l):d(o[0][2],f)}function u(f){a("next",f)}function l(f){a("throw",f)}function d(f,p){f(p),o.shift(),o.length&&a(o[0][0],o[0][1])}};Object.defineProperty(Gt,"__esModule",{value:!0});Gt.isReadableStreamLike=Gt.readableStreamLikeToAsyncGenerator=void 0;var lL=ke();function dL(t){return uL(this,arguments,function(){var e,r,i,o;return cL(this,function(s){switch(s.label){case 0:e=t.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,To(e.read())];case 3:return r=s.sent(),i=r.value,o=r.done,o?[4,To(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,To(i)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}Gt.readableStreamLikeToAsyncGenerator=dL;function fL(t){return lL.isFunction(t?.getReader)}Gt.isReadableStreamLike=fL});var se=v(Ge=>{"use strict";var hL=Ge&&Ge.__awaiter||function(t,n,e,r){function i(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function a(l){try{u(r.next(l))}catch(d){s(d)}}function c(l){try{u(r.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):i(l.value).then(a,c)}u((r=r.apply(t,n||[])).next())})},pL=Ge&&Ge.__generator||function(t,n){var e={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(u){return function(l){return c([u,l])}}function c(u){if(r)throw new TypeError("Generator is already executing.");for(;e;)try{if(r=1,i&&(o=u[0]&2?i.return:u[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,u[1])).done)return o;switch(i=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return e.label++,{value:u[1],done:!1};case 5:e.label++,i=u[1],u=[0];continue;case 7:u=e.ops.pop(),e.trys.pop();continue;default:if(o=e.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){e.label=u[1];break}if(u[0]===6&&e.label<o[1]){e.label=o[1],o=u;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(u);break}o[2]&&e.ops.pop(),e.trys.pop();continue}u=n.call(t,e)}catch(l){u=[6,l],i=0}finally{r=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}},mL=Ge&&Ge.__asyncValues||function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t[Symbol.asyncIterator],e;return n?n.call(t):(t=typeof Vm=="function"?Vm(t):t[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(o){e[o]=t[o]&&function(s){return new Promise(function(a,c){s=t[o](s),i(a,c,s.done,s.value)})}}function i(o,s,a,c){Promise.resolve(c).then(function(u){o({value:u,done:a})},s)}},Vm=Ge&&Ge.__values||function(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Ge,"__esModule",{value:!0});Ge.fromReadableStreamLike=Ge.fromAsyncIterable=Ge.fromIterable=Ge.fromPromise=Ge.fromArrayLike=Ge.fromInteropObservable=Ge.innerFrom=void 0;var gL=gu(),yL=Fm(),xo=je(),vL=$m(),_L=qm(),bL=Bm(),wL=Um(),rC=Eu(),EL=ke(),SL=Em(),CL=oa();function IL(t){if(t instanceof xo.Observable)return t;if(t!=null){if(vL.isInteropObservable(t))return iC(t);if(gL.isArrayLike(t))return oC(t);if(yL.isPromise(t))return sC(t);if(_L.isAsyncIterable(t))return Wm(t);if(wL.isIterable(t))return aC(t);if(rC.isReadableStreamLike(t))return cC(t)}throw bL.createInvalidObservableTypeError(t)}Ge.innerFrom=IL;function iC(t){return new xo.Observable(function(n){var e=t[CL.observable]();if(EL.isFunction(e.subscribe))return e.subscribe(n);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}Ge.fromInteropObservable=iC;function oC(t){return new xo.Observable(function(n){for(var e=0;e<t.length&&!n.closed;e++)n.next(t[e]);n.complete()})}Ge.fromArrayLike=oC;function sC(t){return new xo.Observable(function(n){t.then(function(e){n.closed||(n.next(e),n.complete())},function(e){return n.error(e)}).then(null,SL.reportUnhandledError)})}Ge.fromPromise=sC;function aC(t){return new xo.Observable(function(n){var e,r;try{for(var i=Vm(t),o=i.next();!o.done;o=i.next()){var s=o.value;if(n.next(s),n.closed)return}}catch(a){e={error:a}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}n.complete()})}Ge.fromIterable=aC;function Wm(t){return new xo.Observable(function(n){TL(t,n).catch(function(e){return n.error(e)})})}Ge.fromAsyncIterable=Wm;function cC(t){return Wm(rC.readableStreamLikeToAsyncGenerator(t))}Ge.fromReadableStreamLike=cC;function TL(t,n){var e,r,i,o;return hL(this,void 0,void 0,function(){var s,a;return pL(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),e=mL(t),c.label=1;case 1:return[4,e.next()];case 2:if(r=c.sent(),!!r.done)return[3,4];if(s=r.value,n.next(s),n.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&&(o=e.return)?[4,o.call(e)]:[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 n.complete(),[2]}})})}});var kn=v(Su=>{"use strict";Object.defineProperty(Su,"__esModule",{value:!0});Su.executeSchedule=void 0;function xL(t,n,e,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var o=n.schedule(function(){e(),i?t.add(this.schedule(null,r)):this.unsubscribe()},r);if(t.add(o),!i)return o}Su.executeSchedule=xL});var Do=v(Cu=>{"use strict";Object.defineProperty(Cu,"__esModule",{value:!0});Cu.observeOn=void 0;var Gm=kn(),DL=L(),OL=V();function ML(t,n){return n===void 0&&(n=0),DL.operate(function(e,r){e.subscribe(OL.createOperatorSubscriber(r,function(i){return Gm.executeSchedule(r,t,function(){return r.next(i)},n)},function(){return Gm.executeSchedule(r,t,function(){return r.complete()},n)},function(i){return Gm.executeSchedule(r,t,function(){return r.error(i)},n)}))})}Cu.observeOn=ML});var Oo=v(Iu=>{"use strict";Object.defineProperty(Iu,"__esModule",{value:!0});Iu.subscribeOn=void 0;var AL=L();function NL(t,n){return n===void 0&&(n=0),AL.operate(function(e,r){r.add(t.schedule(function(){return e.subscribe(r)},n))})}Iu.subscribeOn=NL});var uC=v(Tu=>{"use strict";Object.defineProperty(Tu,"__esModule",{value:!0});Tu.scheduleObservable=void 0;var PL=se(),RL=Do(),kL=Oo();function LL(t,n){return PL.innerFrom(t).pipe(kL.subscribeOn(n),RL.observeOn(n))}Tu.scheduleObservable=LL});var lC=v(xu=>{"use strict";Object.defineProperty(xu,"__esModule",{value:!0});xu.schedulePromise=void 0;var jL=se(),FL=Do(),$L=Oo();function qL(t,n){return jL.innerFrom(t).pipe($L.subscribeOn(n),FL.observeOn(n))}xu.schedulePromise=qL});var dC=v(Du=>{"use strict";Object.defineProperty(Du,"__esModule",{value:!0});Du.scheduleArray=void 0;var BL=je();function HL(t,n){return new BL.Observable(function(e){var r=0;return n.schedule(function(){r===t.length?e.complete():(e.next(t[r++]),e.closed||this.schedule())})})}Du.scheduleArray=HL});var zm=v(Ou=>{"use strict";Object.defineProperty(Ou,"__esModule",{value:!0});Ou.scheduleIterable=void 0;var UL=je(),VL=Hm(),WL=ke(),fC=kn();function GL(t,n){return new UL.Observable(function(e){var r;return fC.executeSchedule(e,n,function(){r=t[VL.iterator](),fC.executeSchedule(e,n,function(){var i,o,s;try{i=r.next(),o=i.value,s=i.done}catch(a){e.error(a);return}s?e.complete():e.next(o)},0,!0)}),function(){return WL.isFunction(r?.return)&&r.return()}})}Ou.scheduleIterable=GL});var Km=v(Mu=>{"use strict";Object.defineProperty(Mu,"__esModule",{value:!0});Mu.scheduleAsyncIterable=void 0;var zL=je(),hC=kn();function KL(t,n){if(!t)throw new Error("Iterable cannot be null");return new zL.Observable(function(e){hC.executeSchedule(e,n,function(){var r=t[Symbol.asyncIterator]();hC.executeSchedule(e,n,function(){r.next().then(function(i){i.done?e.complete():e.next(i.value)})},0,!0)})})}Mu.scheduleAsyncIterable=KL});var pC=v(Au=>{"use strict";Object.defineProperty(Au,"__esModule",{value:!0});Au.scheduleReadableStreamLike=void 0;var YL=Km(),ZL=Eu();function QL(t,n){return YL.scheduleAsyncIterable(ZL.readableStreamLikeToAsyncGenerator(t),n)}Au.scheduleReadableStreamLike=QL});var Ym=v(Nu=>{"use strict";Object.defineProperty(Nu,"__esModule",{value:!0});Nu.scheduled=void 0;var JL=uC(),XL=lC(),ej=dC(),tj=zm(),nj=Km(),rj=$m(),ij=Fm(),oj=gu(),sj=Um(),aj=qm(),cj=Bm(),uj=Eu(),lj=pC();function dj(t,n){if(t!=null){if(rj.isInteropObservable(t))return JL.scheduleObservable(t,n);if(oj.isArrayLike(t))return ej.scheduleArray(t,n);if(ij.isPromise(t))return XL.schedulePromise(t,n);if(aj.isAsyncIterable(t))return nj.scheduleAsyncIterable(t,n);if(sj.isIterable(t))return tj.scheduleIterable(t,n);if(uj.isReadableStreamLike(t))return lj.scheduleReadableStreamLike(t,n)}throw cj.createInvalidObservableTypeError(t)}Nu.scheduled=dj});var Ln=v(Pu=>{"use strict";Object.defineProperty(Pu,"__esModule",{value:!0});Pu.from=void 0;var fj=Ym(),hj=se();function pj(t,n){return n?fj.scheduled(t,n):hj.innerFrom(t)}Pu.from=pj});var ku=v(Ru=>{"use strict";Object.defineProperty(Ru,"__esModule",{value:!0});Ru.of=void 0;var mj=Tt(),gj=Ln();function yj(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=mj.popScheduler(t);return gj.from(t,e)}Ru.of=yj});var Zm=v(Lu=>{"use strict";Object.defineProperty(Lu,"__esModule",{value:!0});Lu.throwError=void 0;var vj=je(),_j=ke();function bj(t,n){var e=_j.isFunction(t)?t:function(){return t},r=function(i){return i.error(e())};return new vj.Observable(n?function(i){return n.schedule(r,0,i)}:r)}Lu.throwError=bj});var ju=v(jn=>{"use strict";Object.defineProperty(jn,"__esModule",{value:!0});jn.observeNotification=jn.Notification=jn.NotificationKind=void 0;var wj=on(),Ej=ku(),Sj=Zm(),Cj=ke(),Ij;(function(t){t.NEXT="N",t.ERROR="E",t.COMPLETE="C"})(Ij=jn.NotificationKind||(jn.NotificationKind={}));var Tj=(function(){function t(n,e,r){this.kind=n,this.value=e,this.error=r,this.hasValue=n==="N"}return t.prototype.observe=function(n){return mC(this,n)},t.prototype.do=function(n,e,r){var i=this,o=i.kind,s=i.value,a=i.error;return o==="N"?n?.(s):o==="E"?e?.(a):r?.()},t.prototype.accept=function(n,e,r){var i;return Cj.isFunction((i=n)===null||i===void 0?void 0:i.next)?this.observe(n):this.do(n,e,r)},t.prototype.toObservable=function(){var n=this,e=n.kind,r=n.value,i=n.error,o=e==="N"?Ej.of(r):e==="E"?Sj.throwError(function(){return i}):e==="C"?wj.EMPTY:0;if(!o)throw new TypeError("Unexpected notification kind "+e);return o},t.createNext=function(n){return new t("N",n)},t.createError=function(n){return new t("E",void 0,n)},t.createComplete=function(){return t.completeNotification},t.completeNotification=new t("C"),t})();jn.Notification=Tj;function mC(t,n){var e,r,i,o=t,s=o.kind,a=o.value,c=o.error;if(typeof s!="string")throw new TypeError('Invalid notification, missing "kind"');s==="N"?(e=n.next)===null||e===void 0||e.call(n,a):s==="E"?(r=n.error)===null||r===void 0||r.call(n,c):(i=n.complete)===null||i===void 0||i.call(n)}jn.observeNotification=mC});var yC=v(Fu=>{"use strict";Object.defineProperty(Fu,"__esModule",{value:!0});Fu.isObservable=void 0;var xj=je(),gC=ke();function Dj(t){return!!t&&(t instanceof xj.Observable||gC.isFunction(t.lift)&&gC.isFunction(t.subscribe))}Fu.isObservable=Dj});var pr=v($u=>{"use strict";Object.defineProperty($u,"__esModule",{value:!0});$u.EmptyError=void 0;var Oj=lr();$u.EmptyError=Oj.createErrorClass(function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}})});var vC=v(qu=>{"use strict";Object.defineProperty(qu,"__esModule",{value:!0});qu.lastValueFrom=void 0;var Mj=pr();function Aj(t,n){var e=typeof n=="object";return new Promise(function(r,i){var o=!1,s;t.subscribe({next:function(a){s=a,o=!0},error:i,complete:function(){o?r(s):e?r(n.defaultValue):i(new Mj.EmptyError)}})})}qu.lastValueFrom=Aj});var _C=v(Bu=>{"use strict";Object.defineProperty(Bu,"__esModule",{value:!0});Bu.firstValueFrom=void 0;var Nj=pr(),Pj=oo();function Rj(t,n){var e=typeof n=="object";return new Promise(function(r,i){var o=new Pj.SafeSubscriber({next:function(s){r(s),o.unsubscribe()},error:i,complete:function(){e?r(n.defaultValue):i(new Nj.EmptyError)}});t.subscribe(o)})}Bu.firstValueFrom=Rj});var Qm=v(Hu=>{"use strict";Object.defineProperty(Hu,"__esModule",{value:!0});Hu.ArgumentOutOfRangeError=void 0;var kj=lr();Hu.ArgumentOutOfRangeError=kj.createErrorClass(function(t){return function(){t(this),this.name="ArgumentOutOfRangeError",this.message="argument out of range"}})});var Jm=v(Uu=>{"use strict";Object.defineProperty(Uu,"__esModule",{value:!0});Uu.NotFoundError=void 0;var Lj=lr();Uu.NotFoundError=Lj.createErrorClass(function(t){return function(e){t(this),this.name="NotFoundError",this.message=e}})});var Xm=v(Vu=>{"use strict";Object.defineProperty(Vu,"__esModule",{value:!0});Vu.SequenceError=void 0;var jj=lr();Vu.SequenceError=jj.createErrorClass(function(t){return function(e){t(this),this.name="SequenceError",this.message=e}})});var Gu=v(Wu=>{"use strict";Object.defineProperty(Wu,"__esModule",{value:!0});Wu.isValidDate=void 0;function Fj(t){return t instanceof Date&&!isNaN(t)}Wu.isValidDate=Fj});var da=v(di=>{"use strict";Object.defineProperty(di,"__esModule",{value:!0});di.timeout=di.TimeoutError=void 0;var $j=It(),qj=Gu(),Bj=L(),Hj=se(),Uj=lr(),Vj=V(),Wj=kn();di.TimeoutError=Uj.createErrorClass(function(t){return function(e){e===void 0&&(e=null),t(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=e}});function Gj(t,n){var e=qj.isValidDate(t)?{first:t}:typeof t=="number"?{each:t}:t,r=e.first,i=e.each,o=e.with,s=o===void 0?zj:o,a=e.scheduler,c=a===void 0?n??$j.asyncScheduler:a,u=e.meta,l=u===void 0?null:u;if(r==null&&i==null)throw new TypeError("No timeout provided.");return Bj.operate(function(d,f){var p,m,y=null,b=0,E=function(D){m=Wj.executeSchedule(f,c,function(){try{p.unsubscribe(),Hj.innerFrom(s({meta:l,lastValue:y,seen:b})).subscribe(f)}catch(T){f.error(T)}},D)};p=d.subscribe(Vj.createOperatorSubscriber(f,function(D){m?.unsubscribe(),b++,f.next(y=D),i>0&&E(i)},void 0,void 0,function(){m?.closed||m?.unsubscribe(),y=null})),!b&&E(r!=null?typeof r=="number"?r:+r-c.now():i)})}di.timeout=Gj;function zj(t){throw new di.TimeoutError(t)}});var Fn=v(zu=>{"use strict";Object.defineProperty(zu,"__esModule",{value:!0});zu.map=void 0;var Kj=L(),Yj=V();function Zj(t,n){return Kj.operate(function(e,r){var i=0;e.subscribe(Yj.createOperatorSubscriber(r,function(o){r.next(t.call(n,o,i++))}))})}zu.map=Zj});var gr=v(mr=>{"use strict";var Qj=mr&&mr.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},Jj=mr&&mr.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(mr,"__esModule",{value:!0});mr.mapOneOrManyArgs=void 0;var Xj=Fn(),eF=Array.isArray;function tF(t,n){return eF(n)?t.apply(void 0,Jj([],Qj(n))):t(n)}function nF(t){return Xj.map(function(n){return tF(t,n)})}mr.mapOneOrManyArgs=nF});var tg=v(yr=>{"use strict";var rF=yr&&yr.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},bC=yr&&yr.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(yr,"__esModule",{value:!0});yr.bindCallbackInternals=void 0;var iF=la(),oF=je(),sF=Oo(),aF=gr(),cF=Do(),uF=du();function eg(t,n,e,r){if(e)if(iF.isScheduler(e))r=e;else return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];return eg(t,n,r).apply(this,i).pipe(aF.mapOneOrManyArgs(e))};return r?function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];return eg(t,n).apply(this,i).pipe(sF.subscribeOn(r),cF.observeOn(r))}:function(){for(var i=this,o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];var a=new uF.AsyncSubject,c=!0;return new oF.Observable(function(u){var l=a.subscribe(u);if(c){c=!1;var d=!1,f=!1;n.apply(i,bC(bC([],rF(o)),[function(){for(var p=[],m=0;m<arguments.length;m++)p[m]=arguments[m];if(t){var y=p.shift();if(y!=null){a.error(y);return}}a.next(1<p.length?p:p[0]),f=!0,d&&a.complete()}])),f&&a.complete(),d=!0}return l})}}yr.bindCallbackInternals=eg});var wC=v(Ku=>{"use strict";Object.defineProperty(Ku,"__esModule",{value:!0});Ku.bindCallback=void 0;var lF=tg();function dF(t,n,e){return lF.bindCallbackInternals(!1,t,n,e)}Ku.bindCallback=dF});var EC=v(Yu=>{"use strict";Object.defineProperty(Yu,"__esModule",{value:!0});Yu.bindNodeCallback=void 0;var fF=tg();function hF(t,n,e){return fF.bindCallbackInternals(!0,t,n,e)}Yu.bindNodeCallback=hF});var ng=v(Zu=>{"use strict";Object.defineProperty(Zu,"__esModule",{value:!0});Zu.argsArgArrayOrObject=void 0;var pF=Array.isArray,mF=Object.getPrototypeOf,gF=Object.prototype,yF=Object.keys;function vF(t){if(t.length===1){var n=t[0];if(pF(n))return{args:n,keys:null};if(_F(n)){var e=yF(n);return{args:e.map(function(r){return n[r]}),keys:e}}}return{args:t,keys:null}}Zu.argsArgArrayOrObject=vF;function _F(t){return t&&typeof t=="object"&&mF(t)===gF}});var rg=v(Qu=>{"use strict";Object.defineProperty(Qu,"__esModule",{value:!0});Qu.createObject=void 0;function bF(t,n){return t.reduce(function(e,r,i){return e[r]=n[i],e},{})}Qu.createObject=bF});var Ju=v(Mo=>{"use strict";Object.defineProperty(Mo,"__esModule",{value:!0});Mo.combineLatestInit=Mo.combineLatest=void 0;var wF=je(),EF=ng(),IC=Ln(),TC=ut(),SF=gr(),SC=Tt(),CF=rg(),IF=V(),TF=kn();function xF(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=SC.popScheduler(t),r=SC.popResultSelector(t),i=EF.argsArgArrayOrObject(t),o=i.args,s=i.keys;if(o.length===0)return IC.from([],e);var a=new wF.Observable(xC(o,e,s?function(c){return CF.createObject(s,c)}:TC.identity));return r?a.pipe(SF.mapOneOrManyArgs(r)):a}Mo.combineLatest=xF;function xC(t,n,e){return e===void 0&&(e=TC.identity),function(r){CC(n,function(){for(var i=t.length,o=new Array(i),s=i,a=i,c=function(l){CC(n,function(){var d=IC.from(t[l],n),f=!1;d.subscribe(IF.createOperatorSubscriber(r,function(p){o[l]=p,f||(f=!0,a--),a||r.next(e(o.slice()))},function(){--s||r.complete()}))},r)},u=0;u<i;u++)c(u)},r)}}Mo.combineLatestInit=xC;function CC(t,n,e){t?TF.executeSchedule(e,t,n):n()}});var el=v(Xu=>{"use strict";Object.defineProperty(Xu,"__esModule",{value:!0});Xu.mergeInternals=void 0;var DF=se(),OF=kn(),DC=V();function MF(t,n,e,r,i,o,s,a){var c=[],u=0,l=0,d=!1,f=function(){d&&!c.length&&!u&&n.complete()},p=function(y){return u<r?m(y):c.push(y)},m=function(y){o&&n.next(y),u++;var b=!1;DF.innerFrom(e(y,l++)).subscribe(DC.createOperatorSubscriber(n,function(E){i?.(E),o?p(E):n.next(E)},function(){b=!0},void 0,function(){if(b)try{u--;for(var E=function(){var D=c.shift();s?OF.executeSchedule(n,s,function(){return m(D)}):m(D)};c.length&&u<r;)E();f()}catch(D){n.error(D)}}))};return t.subscribe(DC.createOperatorSubscriber(n,p,function(){d=!0,f()})),function(){a?.()}}Xu.mergeInternals=MF});var _n=v(tl=>{"use strict";Object.defineProperty(tl,"__esModule",{value:!0});tl.mergeMap=void 0;var AF=Fn(),NF=se(),PF=L(),RF=el(),kF=ke();function OC(t,n,e){return e===void 0&&(e=1/0),kF.isFunction(n)?OC(function(r,i){return AF.map(function(o,s){return n(r,o,i,s)})(NF.innerFrom(t(r,i)))},e):(typeof n=="number"&&(e=n),PF.operate(function(r,i){return RF.mergeInternals(r,i,t,e)}))}tl.mergeMap=OC});var Ao=v(nl=>{"use strict";Object.defineProperty(nl,"__esModule",{value:!0});nl.mergeAll=void 0;var LF=_n(),jF=ut();function FF(t){return t===void 0&&(t=1/0),LF.mergeMap(jF.identity,t)}nl.mergeAll=FF});var fa=v(rl=>{"use strict";Object.defineProperty(rl,"__esModule",{value:!0});rl.concatAll=void 0;var $F=Ao();function qF(){return $F.mergeAll(1)}rl.concatAll=qF});var ha=v(il=>{"use strict";Object.defineProperty(il,"__esModule",{value:!0});il.concat=void 0;var BF=fa(),HF=Tt(),UF=Ln();function VF(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return BF.concatAll()(UF.from(t,HF.popScheduler(t)))}il.concat=VF});var pa=v(ol=>{"use strict";Object.defineProperty(ol,"__esModule",{value:!0});ol.defer=void 0;var WF=je(),GF=se();function zF(t){return new WF.Observable(function(n){GF.innerFrom(t()).subscribe(n)})}ol.defer=zF});var MC=v(sl=>{"use strict";Object.defineProperty(sl,"__esModule",{value:!0});sl.connectable=void 0;var KF=lt(),YF=je(),ZF=pa(),QF={connector:function(){return new KF.Subject},resetOnDisconnect:!0};function JF(t,n){n===void 0&&(n=QF);var e=null,r=n.connector,i=n.resetOnDisconnect,o=i===void 0?!0:i,s=r(),a=new YF.Observable(function(c){return s.subscribe(c)});return a.connect=function(){return(!e||e.closed)&&(e=ZF.defer(function(){return t}).subscribe(s),o&&e.add(function(){return s=r()})),e},a}sl.connectable=JF});var AC=v(al=>{"use strict";Object.defineProperty(al,"__esModule",{value:!0});al.forkJoin=void 0;var XF=je(),e$=ng(),t$=se(),n$=Tt(),r$=V(),i$=gr(),o$=rg();function s$(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=n$.popResultSelector(t),r=e$.argsArgArrayOrObject(t),i=r.args,o=r.keys,s=new XF.Observable(function(a){var c=i.length;if(!c){a.complete();return}for(var u=new Array(c),l=c,d=c,f=function(m){var y=!1;t$.innerFrom(i[m]).subscribe(r$.createOperatorSubscriber(a,function(b){y||(y=!0,d--),u[m]=b},function(){return l--},void 0,function(){(!l||!y)&&(d||a.next(o?o$.createObject(o,u):u),a.complete())}))},p=0;p<c;p++)f(p)});return e?s.pipe(i$.mapOneOrManyArgs(e)):s}al.forkJoin=s$});var PC=v(No=>{"use strict";var a$=No&&No.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o};Object.defineProperty(No,"__esModule",{value:!0});No.fromEvent=void 0;var c$=se(),u$=je(),l$=_n(),d$=gu(),fi=ke(),f$=gr(),h$=["addListener","removeListener"],p$=["addEventListener","removeEventListener"],m$=["on","off"];function ig(t,n,e,r){if(fi.isFunction(e)&&(r=e,e=void 0),r)return ig(t,n,e).pipe(f$.mapOneOrManyArgs(r));var i=a$(v$(t)?p$.map(function(a){return function(c){return t[a](n,c,e)}}):g$(t)?h$.map(NC(t,n)):y$(t)?m$.map(NC(t,n)):[],2),o=i[0],s=i[1];if(!o&&d$.isArrayLike(t))return l$.mergeMap(function(a){return ig(a,n,e)})(c$.innerFrom(t));if(!o)throw new TypeError("Invalid event target");return new u$.Observable(function(a){var c=function(){for(var u=[],l=0;l<arguments.length;l++)u[l]=arguments[l];return a.next(1<u.length?u:u[0])};return o(c),function(){return s(c)}})}No.fromEvent=ig;function NC(t,n){return function(e){return function(r){return t[e](n,r)}}}function g$(t){return fi.isFunction(t.addListener)&&fi.isFunction(t.removeListener)}function y$(t){return fi.isFunction(t.on)&&fi.isFunction(t.off)}function v$(t){return fi.isFunction(t.addEventListener)&&fi.isFunction(t.removeEventListener)}});var kC=v(cl=>{"use strict";Object.defineProperty(cl,"__esModule",{value:!0});cl.fromEventPattern=void 0;var _$=je(),b$=ke(),w$=gr();function RC(t,n,e){return e?RC(t,n).pipe(w$.mapOneOrManyArgs(e)):new _$.Observable(function(r){var i=function(){for(var s=[],a=0;a<arguments.length;a++)s[a]=arguments[a];return r.next(s.length===1?s[0]:s)},o=t(i);return b$.isFunction(n)?function(){return n(i,o)}:void 0})}cl.fromEventPattern=RC});var jC=v(Po=>{"use strict";var E$=Po&&Po.__generator||function(t,n){var e={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(u){return function(l){return c([u,l])}}function c(u){if(r)throw new TypeError("Generator is already executing.");for(;e;)try{if(r=1,i&&(o=u[0]&2?i.return:u[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,u[1])).done)return o;switch(i=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return e.label++,{value:u[1],done:!1};case 5:e.label++,i=u[1],u=[0];continue;case 7:u=e.ops.pop(),e.trys.pop();continue;default:if(o=e.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){e.label=u[1];break}if(u[0]===6&&e.label<o[1]){e.label=o[1],o=u;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(u);break}o[2]&&e.ops.pop(),e.trys.pop();continue}u=n.call(t,e)}catch(l){u=[6,l],i=0}finally{r=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}};Object.defineProperty(Po,"__esModule",{value:!0});Po.generate=void 0;var LC=ut(),S$=la(),C$=pa(),I$=zm();function T$(t,n,e,r,i){var o,s,a,c;arguments.length===1?(o=t,c=o.initialState,n=o.condition,e=o.iterate,s=o.resultSelector,a=s===void 0?LC.identity:s,i=o.scheduler):(c=t,!r||S$.isScheduler(r)?(a=LC.identity,i=r):a=r);function u(){var l;return E$(this,function(d){switch(d.label){case 0:l=c,d.label=1;case 1:return!n||n(l)?[4,a(l)]:[3,4];case 2:d.sent(),d.label=3;case 3:return l=e(l),[3,1];case 4:return[2]}})}return C$.defer(i?function(){return I$.scheduleIterable(u(),i)}:u)}Po.generate=T$});var FC=v(ul=>{"use strict";Object.defineProperty(ul,"__esModule",{value:!0});ul.iif=void 0;var x$=pa();function D$(t,n,e){return x$.defer(function(){return t()?n:e})}ul.iif=D$});var vr=v(ll=>{"use strict";Object.defineProperty(ll,"__esModule",{value:!0});ll.timer=void 0;var O$=je(),M$=It(),A$=la(),N$=Gu();function P$(t,n,e){t===void 0&&(t=0),e===void 0&&(e=M$.async);var r=-1;return n!=null&&(A$.isScheduler(n)?e=n:r=n),new O$.Observable(function(i){var o=N$.isValidDate(t)?+t-e.now():t;o<0&&(o=0);var s=0;return e.schedule(function(){i.closed||(i.next(s++),0<=r?this.schedule(void 0,r):i.complete())},o)})}ll.timer=P$});var og=v(dl=>{"use strict";Object.defineProperty(dl,"__esModule",{value:!0});dl.interval=void 0;var R$=It(),k$=vr();function L$(t,n){return t===void 0&&(t=0),n===void 0&&(n=R$.asyncScheduler),t<0&&(t=0),k$.timer(t,t,n)}dl.interval=L$});var qC=v(fl=>{"use strict";Object.defineProperty(fl,"__esModule",{value:!0});fl.merge=void 0;var j$=Ao(),F$=se(),$$=on(),$C=Tt(),q$=Ln();function B$(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=$C.popScheduler(t),r=$C.popNumber(t,1/0),i=t;return i.length?i.length===1?F$.innerFrom(i[0]):j$.mergeAll(r)(q$.from(i,e)):$$.EMPTY}fl.merge=B$});var sg=v(hi=>{"use strict";Object.defineProperty(hi,"__esModule",{value:!0});hi.never=hi.NEVER=void 0;var H$=je(),U$=ct();hi.NEVER=new H$.Observable(U$.noop);function V$(){return hi.NEVER}hi.never=V$});var pi=v(hl=>{"use strict";Object.defineProperty(hl,"__esModule",{value:!0});hl.argsOrArgArray=void 0;var W$=Array.isArray;function G$(t){return t.length===1&&W$(t[0])?t[0]:t}hl.argsOrArgArray=G$});var ag=v(pl=>{"use strict";Object.defineProperty(pl,"__esModule",{value:!0});pl.onErrorResumeNext=void 0;var z$=je(),K$=pi(),Y$=V(),BC=ct(),Z$=se();function Q$(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=K$.argsOrArgArray(t);return new z$.Observable(function(r){var i=0,o=function(){if(i<e.length){var s=void 0;try{s=Z$.innerFrom(e[i++])}catch{o();return}var a=new Y$.OperatorSubscriber(r,void 0,BC.noop,BC.noop);s.subscribe(a),a.add(o)}else r.complete()};o()})}pl.onErrorResumeNext=Q$});var HC=v(ml=>{"use strict";Object.defineProperty(ml,"__esModule",{value:!0});ml.pairs=void 0;var J$=Ln();function X$(t,n){return J$.from(Object.entries(t),n)}ml.pairs=X$});var cg=v(gl=>{"use strict";Object.defineProperty(gl,"__esModule",{value:!0});gl.not=void 0;function eq(t,n){return function(e,r){return!t.call(n,e,r)}}gl.not=eq});var $n=v(yl=>{"use strict";Object.defineProperty(yl,"__esModule",{value:!0});yl.filter=void 0;var tq=L(),nq=V();function rq(t,n){return tq.operate(function(e,r){var i=0;e.subscribe(nq.createOperatorSubscriber(r,function(o){return t.call(n,o,i++)&&r.next(o)}))})}yl.filter=rq});var WC=v(vl=>{"use strict";Object.defineProperty(vl,"__esModule",{value:!0});vl.partition=void 0;var iq=cg(),UC=$n(),VC=se();function oq(t,n,e){return[UC.filter(n,e)(VC.innerFrom(t)),UC.filter(iq.not(n,e))(VC.innerFrom(t))]}vl.partition=oq});var ug=v(Ro=>{"use strict";Object.defineProperty(Ro,"__esModule",{value:!0});Ro.raceInit=Ro.race=void 0;var sq=je(),GC=se(),aq=pi(),cq=V();function uq(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t=aq.argsOrArgArray(t),t.length===1?GC.innerFrom(t[0]):new sq.Observable(zC(t))}Ro.race=uq;function zC(t){return function(n){for(var e=[],r=function(o){e.push(GC.innerFrom(t[o]).subscribe(cq.createOperatorSubscriber(n,function(s){if(e){for(var a=0;a<e.length;a++)a!==o&&e[a].unsubscribe();e=null}n.next(s)})))},i=0;e&&!n.closed&&i<t.length;i++)r(i)}}Ro.raceInit=zC});var KC=v(_l=>{"use strict";Object.defineProperty(_l,"__esModule",{value:!0});_l.range=void 0;var lq=je(),dq=on();function fq(t,n,e){if(n==null&&(n=t,t=0),n<=0)return dq.EMPTY;var r=n+t;return new lq.Observable(e?function(i){var o=t;return e.schedule(function(){o<r?(i.next(o++),this.schedule()):i.complete()})}:function(i){for(var o=t;o<r&&!i.closed;)i.next(o++);i.complete()})}_l.range=fq});var YC=v(bl=>{"use strict";Object.defineProperty(bl,"__esModule",{value:!0});bl.using=void 0;var hq=je(),pq=se(),mq=on();function gq(t,n){return new hq.Observable(function(e){var r=t(),i=n(r),o=i?pq.innerFrom(i):mq.EMPTY;return o.subscribe(e),function(){r&&r.unsubscribe()}})}bl.using=gq});var wl=v(_r=>{"use strict";var yq=_r&&_r.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},vq=_r&&_r.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(_r,"__esModule",{value:!0});_r.zip=void 0;var _q=je(),bq=se(),wq=pi(),Eq=on(),Sq=V(),Cq=Tt();function Iq(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=Cq.popResultSelector(t),r=wq.argsOrArgArray(t);return r.length?new _q.Observable(function(i){var o=r.map(function(){return[]}),s=r.map(function(){return!1});i.add(function(){o=s=null});for(var a=function(u){bq.innerFrom(r[u]).subscribe(Sq.createOperatorSubscriber(i,function(l){if(o[u].push(l),o.every(function(f){return f.length})){var d=o.map(function(f){return f.shift()});i.next(e?e.apply(void 0,vq([],yq(d))):d),o.some(function(f,p){return!f.length&&s[p]})&&i.complete()}},function(){s[u]=!0,!o[u].length&&i.complete()}))},c=0;!i.closed&&c<r.length;c++)a(c);return function(){o=s=null}}):Eq.EMPTY}_r.zip=Iq});var QC=v(ZC=>{"use strict";Object.defineProperty(ZC,"__esModule",{value:!0})});var Sl=v(El=>{"use strict";Object.defineProperty(El,"__esModule",{value:!0});El.audit=void 0;var Tq=L(),xq=se(),JC=V();function Dq(t){return Tq.operate(function(n,e){var r=!1,i=null,o=null,s=!1,a=function(){if(o?.unsubscribe(),o=null,r){r=!1;var u=i;i=null,e.next(u)}s&&e.complete()},c=function(){o=null,s&&e.complete()};n.subscribe(JC.createOperatorSubscriber(e,function(u){r=!0,i=u,o||xq.innerFrom(t(u)).subscribe(o=JC.createOperatorSubscriber(e,a,c))},function(){s=!0,(!r||!o||o.closed)&&e.complete()}))})}El.audit=Dq});var lg=v(Cl=>{"use strict";Object.defineProperty(Cl,"__esModule",{value:!0});Cl.auditTime=void 0;var Oq=It(),Mq=Sl(),Aq=vr();function Nq(t,n){return n===void 0&&(n=Oq.asyncScheduler),Mq.audit(function(){return Aq.timer(t,n)})}Cl.auditTime=Nq});var dg=v(Il=>{"use strict";Object.defineProperty(Il,"__esModule",{value:!0});Il.buffer=void 0;var Pq=L(),Rq=ct(),XC=V(),kq=se();function Lq(t){return Pq.operate(function(n,e){var r=[];return n.subscribe(XC.createOperatorSubscriber(e,function(i){return r.push(i)},function(){e.next(r),e.complete()})),kq.innerFrom(t).subscribe(XC.createOperatorSubscriber(e,function(){var i=r;r=[],e.next(i)},Rq.noop)),function(){r=null}})}Il.buffer=Lq});var hg=v(ko=>{"use strict";var fg=ko&&ko.__values||function(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(ko,"__esModule",{value:!0});ko.bufferCount=void 0;var jq=L(),Fq=V(),$q=Rn();function qq(t,n){return n===void 0&&(n=null),n=n??t,jq.operate(function(e,r){var i=[],o=0;e.subscribe(Fq.createOperatorSubscriber(r,function(s){var a,c,u,l,d=null;o++%n===0&&i.push([]);try{for(var f=fg(i),p=f.next();!p.done;p=f.next()){var m=p.value;m.push(s),t<=m.length&&(d=d??[],d.push(m))}}catch(E){a={error:E}}finally{try{p&&!p.done&&(c=f.return)&&c.call(f)}finally{if(a)throw a.error}}if(d)try{for(var y=fg(d),b=y.next();!b.done;b=y.next()){var m=b.value;$q.arrRemove(i,m),r.next(m)}}catch(E){u={error:E}}finally{try{b&&!b.done&&(l=y.return)&&l.call(y)}finally{if(u)throw u.error}}},function(){var s,a;try{for(var c=fg(i),u=c.next();!u.done;u=c.next()){var l=u.value;r.next(l)}}catch(d){s={error:d}}finally{try{u&&!u.done&&(a=c.return)&&a.call(c)}finally{if(s)throw s.error}}r.complete()},void 0,function(){i=null}))})}ko.bufferCount=qq});var pg=v(Lo=>{"use strict";var Bq=Lo&&Lo.__values||function(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Lo,"__esModule",{value:!0});Lo.bufferTime=void 0;var Hq=Lt(),Uq=L(),Vq=V(),Wq=Rn(),Gq=It(),zq=Tt(),eI=kn();function Kq(t){for(var n,e,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];var o=(n=zq.popScheduler(r))!==null&&n!==void 0?n:Gq.asyncScheduler,s=(e=r[0])!==null&&e!==void 0?e:null,a=r[1]||1/0;return Uq.operate(function(c,u){var l=[],d=!1,f=function(y){var b=y.buffer,E=y.subs;E.unsubscribe(),Wq.arrRemove(l,y),u.next(b),d&&p()},p=function(){if(l){var y=new Hq.Subscription;u.add(y);var b=[],E={buffer:b,subs:y};l.push(E),eI.executeSchedule(y,o,function(){return f(E)},t)}};s!==null&&s>=0?eI.executeSchedule(u,o,p,s,!0):d=!0,p();var m=Vq.createOperatorSubscriber(u,function(y){var b,E,D=l.slice();try{for(var T=Bq(D),K=T.next();!K.done;K=T.next()){var H=K.value,re=H.buffer;re.push(y),a<=re.length&&f(H)}}catch(Ee){b={error:Ee}}finally{try{K&&!K.done&&(E=T.return)&&E.call(T)}finally{if(b)throw b.error}}},function(){for(;l?.length;)u.next(l.shift().buffer);m?.unsubscribe(),u.complete(),u.unsubscribe()},void 0,function(){return l=null});c.subscribe(m)})}Lo.bufferTime=Kq});var gg=v(jo=>{"use strict";var Yq=jo&&jo.__values||function(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(jo,"__esModule",{value:!0});jo.bufferToggle=void 0;var Zq=Lt(),Qq=L(),tI=se(),mg=V(),nI=ct(),Jq=Rn();function Xq(t,n){return Qq.operate(function(e,r){var i=[];tI.innerFrom(t).subscribe(mg.createOperatorSubscriber(r,function(o){var s=[];i.push(s);var a=new Zq.Subscription,c=function(){Jq.arrRemove(i,s),r.next(s),a.unsubscribe()};a.add(tI.innerFrom(n(o)).subscribe(mg.createOperatorSubscriber(r,c,nI.noop)))},nI.noop)),e.subscribe(mg.createOperatorSubscriber(r,function(o){var s,a;try{for(var c=Yq(i),u=c.next();!u.done;u=c.next()){var l=u.value;l.push(o)}}catch(d){s={error:d}}finally{try{u&&!u.done&&(a=c.return)&&a.call(c)}finally{if(s)throw s.error}}},function(){for(;i.length>0;)r.next(i.shift());r.complete()}))})}jo.bufferToggle=Xq});var yg=v(Tl=>{"use strict";Object.defineProperty(Tl,"__esModule",{value:!0});Tl.bufferWhen=void 0;var eB=L(),tB=ct(),rI=V(),nB=se();function rB(t){return eB.operate(function(n,e){var r=null,i=null,o=function(){i?.unsubscribe();var s=r;r=[],s&&e.next(s),nB.innerFrom(t()).subscribe(i=rI.createOperatorSubscriber(e,o,tB.noop))};o(),n.subscribe(rI.createOperatorSubscriber(e,function(s){return r?.push(s)},function(){r&&e.next(r),e.complete()},void 0,function(){return r=i=null}))})}Tl.bufferWhen=rB});var vg=v(xl=>{"use strict";Object.defineProperty(xl,"__esModule",{value:!0});xl.catchError=void 0;var iB=se(),oB=V(),sB=L();function iI(t){return sB.operate(function(n,e){var r=null,i=!1,o;r=n.subscribe(oB.createOperatorSubscriber(e,void 0,void 0,function(s){o=iB.innerFrom(t(s,iI(t)(n))),r?(r.unsubscribe(),r=null,o.subscribe(e)):i=!0})),i&&(r.unsubscribe(),r=null,o.subscribe(e))})}xl.catchError=iI});var _g=v(Dl=>{"use strict";Object.defineProperty(Dl,"__esModule",{value:!0});Dl.scanInternals=void 0;var aB=V();function cB(t,n,e,r,i){return function(o,s){var a=e,c=n,u=0;o.subscribe(aB.createOperatorSubscriber(s,function(l){var d=u++;c=a?t(c,l,d):(a=!0,l),r&&s.next(c)},i&&function(){a&&s.next(c),s.complete()}))}}Dl.scanInternals=cB});var mi=v(Ol=>{"use strict";Object.defineProperty(Ol,"__esModule",{value:!0});Ol.reduce=void 0;var uB=_g(),lB=L();function dB(t,n){return lB.operate(uB.scanInternals(t,n,arguments.length>=2,!1,!0))}Ol.reduce=dB});var Al=v(Ml=>{"use strict";Object.defineProperty(Ml,"__esModule",{value:!0});Ml.toArray=void 0;var fB=mi(),hB=L(),pB=function(t,n){return t.push(n),t};function mB(){return hB.operate(function(t,n){fB.reduce(pB,[])(t).subscribe(n)})}Ml.toArray=mB});var bg=v(Nl=>{"use strict";Object.defineProperty(Nl,"__esModule",{value:!0});Nl.joinAllInternals=void 0;var gB=ut(),yB=gr(),vB=sa(),_B=_n(),bB=Al();function wB(t,n){return vB.pipe(bB.toArray(),_B.mergeMap(function(e){return t(e)}),n?yB.mapOneOrManyArgs(n):gB.identity)}Nl.joinAllInternals=wB});var Rl=v(Pl=>{"use strict";Object.defineProperty(Pl,"__esModule",{value:!0});Pl.combineLatestAll=void 0;var EB=Ju(),SB=bg();function CB(t){return SB.joinAllInternals(EB.combineLatest,t)}Pl.combineLatestAll=CB});var wg=v(kl=>{"use strict";Object.defineProperty(kl,"__esModule",{value:!0});kl.combineAll=void 0;var IB=Rl();kl.combineAll=IB.combineLatestAll});var Eg=v(br=>{"use strict";var oI=br&&br.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},sI=br&&br.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(br,"__esModule",{value:!0});br.combineLatest=void 0;var TB=Ju(),xB=L(),DB=pi(),OB=gr(),MB=sa(),AB=Tt();function aI(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=AB.popResultSelector(t);return e?MB.pipe(aI.apply(void 0,sI([],oI(t))),OB.mapOneOrManyArgs(e)):xB.operate(function(r,i){TB.combineLatestInit(sI([r],oI(DB.argsOrArgArray(t))))(i)})}br.combineLatest=aI});var Sg=v(wr=>{"use strict";var NB=wr&&wr.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},PB=wr&&wr.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(wr,"__esModule",{value:!0});wr.combineLatestWith=void 0;var RB=Eg();function kB(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return RB.combineLatest.apply(void 0,PB([],NB(t)))}wr.combineLatestWith=kB});var jl=v(Ll=>{"use strict";Object.defineProperty(Ll,"__esModule",{value:!0});Ll.concatMap=void 0;var cI=_n(),LB=ke();function jB(t,n){return LB.isFunction(n)?cI.mergeMap(t,n,1):cI.mergeMap(t,1)}Ll.concatMap=jB});var Cg=v(Fl=>{"use strict";Object.defineProperty(Fl,"__esModule",{value:!0});Fl.concatMapTo=void 0;var uI=jl(),FB=ke();function $B(t,n){return FB.isFunction(n)?uI.concatMap(function(){return t},n):uI.concatMap(function(){return t})}Fl.concatMapTo=$B});var Ig=v(Er=>{"use strict";var qB=Er&&Er.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},BB=Er&&Er.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Er,"__esModule",{value:!0});Er.concat=void 0;var HB=L(),UB=fa(),VB=Tt(),WB=Ln();function GB(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=VB.popScheduler(t);return HB.operate(function(r,i){UB.concatAll()(WB.from(BB([r],qB(t)),e)).subscribe(i)})}Er.concat=GB});var Tg=v(Sr=>{"use strict";var zB=Sr&&Sr.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},KB=Sr&&Sr.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Sr,"__esModule",{value:!0});Sr.concatWith=void 0;var YB=Ig();function ZB(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return YB.concat.apply(void 0,KB([],zB(t)))}Sr.concatWith=ZB});var lI=v($l=>{"use strict";Object.defineProperty($l,"__esModule",{value:!0});$l.fromSubscribable=void 0;var QB=je();function JB(t){return new QB.Observable(function(n){return t.subscribe(n)})}$l.fromSubscribable=JB});var ma=v(ql=>{"use strict";Object.defineProperty(ql,"__esModule",{value:!0});ql.connect=void 0;var XB=lt(),eH=se(),tH=L(),nH=lI(),rH={connector:function(){return new XB.Subject}};function iH(t,n){n===void 0&&(n=rH);var e=n.connector;return tH.operate(function(r,i){var o=e();eH.innerFrom(t(nH.fromSubscribable(o))).subscribe(i),i.add(r.subscribe(o))})}ql.connect=iH});var xg=v(Bl=>{"use strict";Object.defineProperty(Bl,"__esModule",{value:!0});Bl.count=void 0;var oH=mi();function sH(t){return oH.reduce(function(n,e,r){return!t||t(e,r)?n+1:n},0)}Bl.count=sH});var Dg=v(Hl=>{"use strict";Object.defineProperty(Hl,"__esModule",{value:!0});Hl.debounce=void 0;var aH=L(),cH=ct(),dI=V(),uH=se();function lH(t){return aH.operate(function(n,e){var r=!1,i=null,o=null,s=function(){if(o?.unsubscribe(),o=null,r){r=!1;var a=i;i=null,e.next(a)}};n.subscribe(dI.createOperatorSubscriber(e,function(a){o?.unsubscribe(),r=!0,i=a,o=dI.createOperatorSubscriber(e,s,cH.noop),uH.innerFrom(t(a)).subscribe(o)},function(){s(),e.complete()},void 0,function(){i=o=null}))})}Hl.debounce=lH});var Og=v(Ul=>{"use strict";Object.defineProperty(Ul,"__esModule",{value:!0});Ul.debounceTime=void 0;var dH=It(),fH=L(),hH=V();function pH(t,n){return n===void 0&&(n=dH.asyncScheduler),fH.operate(function(e,r){var i=null,o=null,s=null,a=function(){if(i){i.unsubscribe(),i=null;var u=o;o=null,r.next(u)}};function c(){var u=s+t,l=n.now();if(l<u){i=this.schedule(void 0,u-l),r.add(i);return}a()}e.subscribe(hH.createOperatorSubscriber(r,function(u){o=u,s=n.now(),i||(i=n.schedule(c,t),r.add(i))},function(){a(),r.complete()},void 0,function(){o=i=null}))})}Ul.debounceTime=pH});var Fo=v(Vl=>{"use strict";Object.defineProperty(Vl,"__esModule",{value:!0});Vl.defaultIfEmpty=void 0;var mH=L(),gH=V();function yH(t){return mH.operate(function(n,e){var r=!1;n.subscribe(gH.createOperatorSubscriber(e,function(i){r=!0,e.next(i)},function(){r||e.next(t),e.complete()}))})}Vl.defaultIfEmpty=yH});var $o=v(Wl=>{"use strict";Object.defineProperty(Wl,"__esModule",{value:!0});Wl.take=void 0;var vH=on(),_H=L(),bH=V();function wH(t){return t<=0?function(){return vH.EMPTY}:_H.operate(function(n,e){var r=0;n.subscribe(bH.createOperatorSubscriber(e,function(i){++r<=t&&(e.next(i),t<=r&&e.complete())}))})}Wl.take=wH});var zl=v(Gl=>{"use strict";Object.defineProperty(Gl,"__esModule",{value:!0});Gl.ignoreElements=void 0;var EH=L(),SH=V(),CH=ct();function IH(){return EH.operate(function(t,n){t.subscribe(SH.createOperatorSubscriber(n,CH.noop))})}Gl.ignoreElements=IH});var Yl=v(Kl=>{"use strict";Object.defineProperty(Kl,"__esModule",{value:!0});Kl.mapTo=void 0;var TH=Fn();function xH(t){return TH.map(function(){return t})}Kl.mapTo=xH});var Ql=v(Zl=>{"use strict";Object.defineProperty(Zl,"__esModule",{value:!0});Zl.delayWhen=void 0;var DH=ha(),fI=$o(),OH=zl(),MH=Yl(),AH=_n(),NH=se();function hI(t,n){return n?function(e){return DH.concat(n.pipe(fI.take(1),OH.ignoreElements()),e.pipe(hI(t)))}:AH.mergeMap(function(e,r){return NH.innerFrom(t(e,r)).pipe(fI.take(1),MH.mapTo(e))})}Zl.delayWhen=hI});var Mg=v(Jl=>{"use strict";Object.defineProperty(Jl,"__esModule",{value:!0});Jl.delay=void 0;var PH=It(),RH=Ql(),kH=vr();function LH(t,n){n===void 0&&(n=PH.asyncScheduler);var e=kH.timer(t,n);return RH.delayWhen(function(){return e})}Jl.delay=LH});var Ag=v(Xl=>{"use strict";Object.defineProperty(Xl,"__esModule",{value:!0});Xl.dematerialize=void 0;var jH=ju(),FH=L(),$H=V();function qH(){return FH.operate(function(t,n){t.subscribe($H.createOperatorSubscriber(n,function(e){return jH.observeNotification(e,n)}))})}Xl.dematerialize=qH});var Ng=v(ed=>{"use strict";Object.defineProperty(ed,"__esModule",{value:!0});ed.distinct=void 0;var BH=L(),pI=V(),HH=ct(),UH=se();function VH(t,n){return BH.operate(function(e,r){var i=new Set;e.subscribe(pI.createOperatorSubscriber(r,function(o){var s=t?t(o):o;i.has(s)||(i.add(s),r.next(o))})),n&&UH.innerFrom(n).subscribe(pI.createOperatorSubscriber(r,function(){return i.clear()},HH.noop))})}ed.distinct=VH});var nd=v(td=>{"use strict";Object.defineProperty(td,"__esModule",{value:!0});td.distinctUntilChanged=void 0;var WH=ut(),GH=L(),zH=V();function KH(t,n){return n===void 0&&(n=WH.identity),t=t??YH,GH.operate(function(e,r){var i,o=!0;e.subscribe(zH.createOperatorSubscriber(r,function(s){var a=n(s);(o||!t(i,a))&&(o=!1,i=a,r.next(s))}))})}td.distinctUntilChanged=KH;function YH(t,n){return t===n}});var Pg=v(rd=>{"use strict";Object.defineProperty(rd,"__esModule",{value:!0});rd.distinctUntilKeyChanged=void 0;var ZH=nd();function QH(t,n){return ZH.distinctUntilChanged(function(e,r){return n?n(e[t],r[t]):e[t]===r[t]})}rd.distinctUntilKeyChanged=QH});var qo=v(id=>{"use strict";Object.defineProperty(id,"__esModule",{value:!0});id.throwIfEmpty=void 0;var JH=pr(),XH=L(),eU=V();function tU(t){return t===void 0&&(t=nU),XH.operate(function(n,e){var r=!1;n.subscribe(eU.createOperatorSubscriber(e,function(i){r=!0,e.next(i)},function(){return r?e.complete():e.error(t())}))})}id.throwIfEmpty=tU;function nU(){return new JH.EmptyError}});var Rg=v(od=>{"use strict";Object.defineProperty(od,"__esModule",{value:!0});od.elementAt=void 0;var mI=Qm(),rU=$n(),iU=qo(),oU=Fo(),sU=$o();function aU(t,n){if(t<0)throw new mI.ArgumentOutOfRangeError;var e=arguments.length>=2;return function(r){return r.pipe(rU.filter(function(i,o){return o===t}),sU.take(1),e?oU.defaultIfEmpty(n):iU.throwIfEmpty(function(){return new mI.ArgumentOutOfRangeError}))}}od.elementAt=aU});var kg=v(Cr=>{"use strict";var cU=Cr&&Cr.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},uU=Cr&&Cr.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Cr,"__esModule",{value:!0});Cr.endWith=void 0;var lU=ha(),dU=ku();function fU(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return function(e){return lU.concat(e,dU.of.apply(void 0,uU([],cU(t))))}}Cr.endWith=fU});var Lg=v(sd=>{"use strict";Object.defineProperty(sd,"__esModule",{value:!0});sd.every=void 0;var hU=L(),pU=V();function mU(t,n){return hU.operate(function(e,r){var i=0;e.subscribe(pU.createOperatorSubscriber(r,function(o){t.call(n,o,i++,e)||(r.next(!1),r.complete())},function(){r.next(!0),r.complete()}))})}sd.every=mU});var cd=v(ad=>{"use strict";Object.defineProperty(ad,"__esModule",{value:!0});ad.exhaustMap=void 0;var gU=Fn(),gI=se(),yU=L(),yI=V();function vI(t,n){return n?function(e){return e.pipe(vI(function(r,i){return gI.innerFrom(t(r,i)).pipe(gU.map(function(o,s){return n(r,o,i,s)}))}))}:yU.operate(function(e,r){var i=0,o=null,s=!1;e.subscribe(yI.createOperatorSubscriber(r,function(a){o||(o=yI.createOperatorSubscriber(r,void 0,function(){o=null,s&&r.complete()}),gI.innerFrom(t(a,i++)).subscribe(o))},function(){s=!0,!o&&r.complete()}))})}ad.exhaustMap=vI});var ld=v(ud=>{"use strict";Object.defineProperty(ud,"__esModule",{value:!0});ud.exhaustAll=void 0;var vU=cd(),_U=ut();function bU(){return vU.exhaustMap(_U.identity)}ud.exhaustAll=bU});var jg=v(dd=>{"use strict";Object.defineProperty(dd,"__esModule",{value:!0});dd.exhaust=void 0;var wU=ld();dd.exhaust=wU.exhaustAll});var Fg=v(fd=>{"use strict";Object.defineProperty(fd,"__esModule",{value:!0});fd.expand=void 0;var EU=L(),SU=el();function CU(t,n,e){return n===void 0&&(n=1/0),n=(n||0)<1?1/0:n,EU.operate(function(r,i){return SU.mergeInternals(r,i,t,n,void 0,!0,e)})}fd.expand=CU});var $g=v(hd=>{"use strict";Object.defineProperty(hd,"__esModule",{value:!0});hd.finalize=void 0;var IU=L();function TU(t){return IU.operate(function(n,e){try{n.subscribe(e)}finally{e.add(t)}})}hd.finalize=TU});var pd=v(Bo=>{"use strict";Object.defineProperty(Bo,"__esModule",{value:!0});Bo.createFind=Bo.find=void 0;var xU=L(),DU=V();function OU(t,n){return xU.operate(_I(t,n,"value"))}Bo.find=OU;function _I(t,n,e){var r=e==="index";return function(i,o){var s=0;i.subscribe(DU.createOperatorSubscriber(o,function(a){var c=s++;t.call(n,a,c,i)&&(o.next(r?c:a),o.complete())},function(){o.next(r?-1:void 0),o.complete()}))}}Bo.createFind=_I});var qg=v(md=>{"use strict";Object.defineProperty(md,"__esModule",{value:!0});md.findIndex=void 0;var MU=L(),AU=pd();function NU(t,n){return MU.operate(AU.createFind(t,n,"index"))}md.findIndex=NU});var Bg=v(gd=>{"use strict";Object.defineProperty(gd,"__esModule",{value:!0});gd.first=void 0;var PU=pr(),RU=$n(),kU=$o(),LU=Fo(),jU=qo(),FU=ut();function $U(t,n){var e=arguments.length>=2;return function(r){return r.pipe(t?RU.filter(function(i,o){return t(i,o,r)}):FU.identity,kU.take(1),e?LU.defaultIfEmpty(n):jU.throwIfEmpty(function(){return new PU.EmptyError}))}}gd.first=$U});var Hg=v(yd=>{"use strict";Object.defineProperty(yd,"__esModule",{value:!0});yd.groupBy=void 0;var qU=je(),BU=se(),HU=lt(),UU=L(),bI=V();function VU(t,n,e,r){return UU.operate(function(i,o){var s;!n||typeof n=="function"?s=n:(e=n.duration,s=n.element,r=n.connector);var a=new Map,c=function(m){a.forEach(m),m(o)},u=function(m){return c(function(y){return y.error(m)})},l=0,d=!1,f=new bI.OperatorSubscriber(o,function(m){try{var y=t(m),b=a.get(y);if(!b){a.set(y,b=r?r():new HU.Subject);var E=p(y,b);if(o.next(E),e){var D=bI.createOperatorSubscriber(b,function(){b.complete(),D?.unsubscribe()},void 0,void 0,function(){return a.delete(y)});f.add(BU.innerFrom(e(E)).subscribe(D))}}b.next(s?s(m):m)}catch(T){u(T)}},function(){return c(function(m){return m.complete()})},u,function(){return a.clear()},function(){return d=!0,l===0});i.subscribe(f);function p(m,y){var b=new qU.Observable(function(E){l++;var D=y.subscribe(E);return function(){D.unsubscribe(),--l===0&&d&&f.unsubscribe()}});return b.key=m,b}})}yd.groupBy=VU});var Ug=v(vd=>{"use strict";Object.defineProperty(vd,"__esModule",{value:!0});vd.isEmpty=void 0;var WU=L(),GU=V();function zU(){return WU.operate(function(t,n){t.subscribe(GU.createOperatorSubscriber(n,function(){n.next(!1),n.complete()},function(){n.next(!0),n.complete()}))})}vd.isEmpty=zU});var _d=v(Ho=>{"use strict";var KU=Ho&&Ho.__values||function(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Ho,"__esModule",{value:!0});Ho.takeLast=void 0;var YU=on(),ZU=L(),QU=V();function JU(t){return t<=0?function(){return YU.EMPTY}:ZU.operate(function(n,e){var r=[];n.subscribe(QU.createOperatorSubscriber(e,function(i){r.push(i),t<r.length&&r.shift()},function(){var i,o;try{for(var s=KU(r),a=s.next();!a.done;a=s.next()){var c=a.value;e.next(c)}}catch(u){i={error:u}}finally{try{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}e.complete()},void 0,function(){r=null}))})}Ho.takeLast=JU});var Vg=v(bd=>{"use strict";Object.defineProperty(bd,"__esModule",{value:!0});bd.last=void 0;var XU=pr(),eV=$n(),tV=_d(),nV=qo(),rV=Fo(),iV=ut();function oV(t,n){var e=arguments.length>=2;return function(r){return r.pipe(t?eV.filter(function(i,o){return t(i,o,r)}):iV.identity,tV.takeLast(1),e?rV.defaultIfEmpty(n):nV.throwIfEmpty(function(){return new XU.EmptyError}))}}bd.last=oV});var Gg=v(wd=>{"use strict";Object.defineProperty(wd,"__esModule",{value:!0});wd.materialize=void 0;var Wg=ju(),sV=L(),aV=V();function cV(){return sV.operate(function(t,n){t.subscribe(aV.createOperatorSubscriber(n,function(e){n.next(Wg.Notification.createNext(e))},function(){n.next(Wg.Notification.createComplete()),n.complete()},function(e){n.next(Wg.Notification.createError(e)),n.complete()}))})}wd.materialize=cV});var zg=v(Ed=>{"use strict";Object.defineProperty(Ed,"__esModule",{value:!0});Ed.max=void 0;var uV=mi(),lV=ke();function dV(t){return uV.reduce(lV.isFunction(t)?function(n,e){return t(n,e)>0?n:e}:function(n,e){return n>e?n:e})}Ed.max=dV});var Kg=v(Sd=>{"use strict";Object.defineProperty(Sd,"__esModule",{value:!0});Sd.flatMap=void 0;var fV=_n();Sd.flatMap=fV.mergeMap});var Yg=v(Cd=>{"use strict";Object.defineProperty(Cd,"__esModule",{value:!0});Cd.mergeMapTo=void 0;var wI=_n(),hV=ke();function pV(t,n,e){return e===void 0&&(e=1/0),hV.isFunction(n)?wI.mergeMap(function(){return t},n,e):(typeof n=="number"&&(e=n),wI.mergeMap(function(){return t},e))}Cd.mergeMapTo=pV});var Zg=v(Id=>{"use strict";Object.defineProperty(Id,"__esModule",{value:!0});Id.mergeScan=void 0;var mV=L(),gV=el();function yV(t,n,e){return e===void 0&&(e=1/0),mV.operate(function(r,i){var o=n;return gV.mergeInternals(r,i,function(s,a){return t(o,s,a)},e,function(s){o=s},!1,void 0,function(){return o=null})})}Id.mergeScan=yV});var Qg=v(Ir=>{"use strict";var vV=Ir&&Ir.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},_V=Ir&&Ir.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Ir,"__esModule",{value:!0});Ir.merge=void 0;var bV=L(),wV=Ao(),EI=Tt(),EV=Ln();function SV(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=EI.popScheduler(t),r=EI.popNumber(t,1/0);return bV.operate(function(i,o){wV.mergeAll(r)(EV.from(_V([i],vV(t)),e)).subscribe(o)})}Ir.merge=SV});var Jg=v(Tr=>{"use strict";var CV=Tr&&Tr.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},IV=Tr&&Tr.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Tr,"__esModule",{value:!0});Tr.mergeWith=void 0;var TV=Qg();function xV(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return TV.merge.apply(void 0,IV([],CV(t)))}Tr.mergeWith=xV});var Xg=v(Td=>{"use strict";Object.defineProperty(Td,"__esModule",{value:!0});Td.min=void 0;var DV=mi(),OV=ke();function MV(t){return DV.reduce(OV.isFunction(t)?function(n,e){return t(n,e)<0?n:e}:function(n,e){return n<e?n:e})}Td.min=MV});var ga=v(xd=>{"use strict";Object.defineProperty(xd,"__esModule",{value:!0});xd.multicast=void 0;var AV=aa(),SI=ke(),NV=ma();function PV(t,n){var e=SI.isFunction(t)?t:function(){return t};return SI.isFunction(n)?NV.connect(n,{connector:e}):function(r){return new AV.ConnectableObservable(r,e)}}xd.multicast=PV});var ey=v(bn=>{"use strict";var RV=bn&&bn.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},kV=bn&&bn.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(bn,"__esModule",{value:!0});bn.onErrorResumeNext=bn.onErrorResumeNextWith=void 0;var LV=pi(),jV=ag();function CI(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=LV.argsOrArgArray(t);return function(r){return jV.onErrorResumeNext.apply(void 0,kV([r],RV(e)))}}bn.onErrorResumeNextWith=CI;bn.onErrorResumeNext=CI});var ty=v(Dd=>{"use strict";Object.defineProperty(Dd,"__esModule",{value:!0});Dd.pairwise=void 0;var FV=L(),$V=V();function qV(){return FV.operate(function(t,n){var e,r=!1;t.subscribe($V.createOperatorSubscriber(n,function(i){var o=e;e=i,r&&n.next([o,i]),r=!0}))})}Dd.pairwise=qV});var ny=v(Od=>{"use strict";Object.defineProperty(Od,"__esModule",{value:!0});Od.pluck=void 0;var BV=Fn();function HV(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=t.length;if(e===0)throw new Error("list of properties cannot be empty.");return BV.map(function(r){for(var i=r,o=0;o<e;o++){var s=i?.[t[o]];if(typeof s<"u")i=s;else return}return i})}Od.pluck=HV});var ry=v(Md=>{"use strict";Object.defineProperty(Md,"__esModule",{value:!0});Md.publish=void 0;var UV=lt(),VV=ga(),WV=ma();function GV(t){return t?function(n){return WV.connect(t)(n)}:function(n){return VV.multicast(new UV.Subject)(n)}}Md.publish=GV});var iy=v(Ad=>{"use strict";Object.defineProperty(Ad,"__esModule",{value:!0});Ad.publishBehavior=void 0;var zV=Rm(),KV=aa();function YV(t){return function(n){var e=new zV.BehaviorSubject(t);return new KV.ConnectableObservable(n,function(){return e})}}Ad.publishBehavior=YV});var oy=v(Nd=>{"use strict";Object.defineProperty(Nd,"__esModule",{value:!0});Nd.publishLast=void 0;var ZV=du(),QV=aa();function JV(){return function(t){var n=new ZV.AsyncSubject;return new QV.ConnectableObservable(t,function(){return n})}}Nd.publishLast=JV});var sy=v(Pd=>{"use strict";Object.defineProperty(Pd,"__esModule",{value:!0});Pd.publishReplay=void 0;var XV=lu(),e2=ga(),II=ke();function t2(t,n,e,r){e&&!II.isFunction(e)&&(r=e);var i=II.isFunction(e)?e:void 0;return function(o){return e2.multicast(new XV.ReplaySubject(t,n,r),i)(o)}}Pd.publishReplay=t2});var Rd=v(xr=>{"use strict";var n2=xr&&xr.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},r2=xr&&xr.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(xr,"__esModule",{value:!0});xr.raceWith=void 0;var i2=ug(),o2=L(),s2=ut();function a2(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t.length?o2.operate(function(e,r){i2.raceInit(r2([e],n2(t)))(r)}):s2.identity}xr.raceWith=a2});var ay=v(kd=>{"use strict";Object.defineProperty(kd,"__esModule",{value:!0});kd.repeat=void 0;var c2=on(),u2=L(),TI=V(),l2=se(),d2=vr();function f2(t){var n,e=1/0,r;return t!=null&&(typeof t=="object"?(n=t.count,e=n===void 0?1/0:n,r=t.delay):e=t),e<=0?function(){return c2.EMPTY}:u2.operate(function(i,o){var s=0,a,c=function(){if(a?.unsubscribe(),a=null,r!=null){var l=typeof r=="number"?d2.timer(r):l2.innerFrom(r(s)),d=TI.createOperatorSubscriber(o,function(){d.unsubscribe(),u()});l.subscribe(d)}else u()},u=function(){var l=!1;a=i.subscribe(TI.createOperatorSubscriber(o,void 0,function(){++s<e?a?c():l=!0:o.complete()})),l&&c()};u()})}kd.repeat=f2});var cy=v(Ld=>{"use strict";Object.defineProperty(Ld,"__esModule",{value:!0});Ld.repeatWhen=void 0;var h2=se(),p2=lt(),m2=L(),xI=V();function g2(t){return m2.operate(function(n,e){var r,i=!1,o,s=!1,a=!1,c=function(){return a&&s&&(e.complete(),!0)},u=function(){return o||(o=new p2.Subject,h2.innerFrom(t(o)).subscribe(xI.createOperatorSubscriber(e,function(){r?l():i=!0},function(){s=!0,c()}))),o},l=function(){a=!1,r=n.subscribe(xI.createOperatorSubscriber(e,void 0,function(){a=!0,!c()&&u().next()})),i&&(r.unsubscribe(),r=null,i=!1,l())};l()})}Ld.repeatWhen=g2});var uy=v(jd=>{"use strict";Object.defineProperty(jd,"__esModule",{value:!0});jd.retry=void 0;var y2=L(),DI=V(),v2=ut(),_2=vr(),b2=se();function w2(t){t===void 0&&(t=1/0);var n;t&&typeof t=="object"?n=t:n={count:t};var e=n.count,r=e===void 0?1/0:e,i=n.delay,o=n.resetOnSuccess,s=o===void 0?!1:o;return r<=0?v2.identity:y2.operate(function(a,c){var u=0,l,d=function(){var f=!1;l=a.subscribe(DI.createOperatorSubscriber(c,function(p){s&&(u=0),c.next(p)},void 0,function(p){if(u++<r){var m=function(){l?(l.unsubscribe(),l=null,d()):f=!0};if(i!=null){var y=typeof i=="number"?_2.timer(i):b2.innerFrom(i(p,u)),b=DI.createOperatorSubscriber(c,function(){b.unsubscribe(),m()},function(){c.complete()});y.subscribe(b)}else m()}else c.error(p)})),f&&(l.unsubscribe(),l=null,d())};d()})}jd.retry=w2});var ly=v(Fd=>{"use strict";Object.defineProperty(Fd,"__esModule",{value:!0});Fd.retryWhen=void 0;var E2=se(),S2=lt(),C2=L(),OI=V();function I2(t){return C2.operate(function(n,e){var r,i=!1,o,s=function(){r=n.subscribe(OI.createOperatorSubscriber(e,void 0,void 0,function(a){o||(o=new S2.Subject,E2.innerFrom(t(o)).subscribe(OI.createOperatorSubscriber(e,function(){return r?s():i=!0}))),o&&o.next(a)})),i&&(r.unsubscribe(),r=null,i=!1,s())};s()})}Fd.retryWhen=I2});var qd=v($d=>{"use strict";Object.defineProperty($d,"__esModule",{value:!0});$d.sample=void 0;var T2=se(),x2=L(),D2=ct(),MI=V();function O2(t){return x2.operate(function(n,e){var r=!1,i=null;n.subscribe(MI.createOperatorSubscriber(e,function(o){r=!0,i=o})),T2.innerFrom(t).subscribe(MI.createOperatorSubscriber(e,function(){if(r){r=!1;var o=i;i=null,e.next(o)}},D2.noop))})}$d.sample=O2});var dy=v(Bd=>{"use strict";Object.defineProperty(Bd,"__esModule",{value:!0});Bd.sampleTime=void 0;var M2=It(),A2=qd(),N2=og();function P2(t,n){return n===void 0&&(n=M2.asyncScheduler),A2.sample(N2.interval(t,n))}Bd.sampleTime=P2});var fy=v(Hd=>{"use strict";Object.defineProperty(Hd,"__esModule",{value:!0});Hd.scan=void 0;var R2=L(),k2=_g();function L2(t,n){return R2.operate(k2.scanInternals(t,n,arguments.length>=2,!0))}Hd.scan=L2});var hy=v(Ud=>{"use strict";Object.defineProperty(Ud,"__esModule",{value:!0});Ud.sequenceEqual=void 0;var j2=L(),F2=V(),$2=se();function q2(t,n){return n===void 0&&(n=function(e,r){return e===r}),j2.operate(function(e,r){var i=AI(),o=AI(),s=function(c){r.next(c),r.complete()},a=function(c,u){var l=F2.createOperatorSubscriber(r,function(d){var f=u.buffer,p=u.complete;f.length===0?p?s(!1):c.buffer.push(d):!n(d,f.shift())&&s(!1)},function(){c.complete=!0;var d=u.complete,f=u.buffer;d&&s(f.length===0),l?.unsubscribe()});return l};e.subscribe(a(i,o)),$2.innerFrom(t).subscribe(a(o,i))})}Ud.sequenceEqual=q2;function AI(){return{buffer:[],complete:!1}}});var Vd=v(Dr=>{"use strict";var B2=Dr&&Dr.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},H2=Dr&&Dr.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Dr,"__esModule",{value:!0});Dr.share=void 0;var NI=se(),U2=lt(),PI=oo(),V2=L();function W2(t){t===void 0&&(t={});var n=t.connector,e=n===void 0?function(){return new U2.Subject}:n,r=t.resetOnError,i=r===void 0?!0:r,o=t.resetOnComplete,s=o===void 0?!0:o,a=t.resetOnRefCountZero,c=a===void 0?!0:a;return function(u){var l,d,f,p=0,m=!1,y=!1,b=function(){d?.unsubscribe(),d=void 0},E=function(){b(),l=f=void 0,m=y=!1},D=function(){var T=l;E(),T?.unsubscribe()};return V2.operate(function(T,K){p++,!y&&!m&&b();var H=f=f??e();K.add(function(){p--,p===0&&!y&&!m&&(d=py(D,c))}),H.subscribe(K),!l&&p>0&&(l=new PI.SafeSubscriber({next:function(re){return H.next(re)},error:function(re){y=!0,b(),d=py(E,i,re),H.error(re)},complete:function(){m=!0,b(),d=py(E,s),H.complete()}}),NI.innerFrom(T).subscribe(l))})(u)}}Dr.share=W2;function py(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];if(n===!0){t();return}if(n!==!1){var i=new PI.SafeSubscriber({next:function(){i.unsubscribe(),t()}});return NI.innerFrom(n.apply(void 0,H2([],B2(e)))).subscribe(i)}}});var my=v(Wd=>{"use strict";Object.defineProperty(Wd,"__esModule",{value:!0});Wd.shareReplay=void 0;var G2=lu(),z2=Vd();function K2(t,n,e){var r,i,o,s,a=!1;return t&&typeof t=="object"?(r=t.bufferSize,s=r===void 0?1/0:r,i=t.windowTime,n=i===void 0?1/0:i,o=t.refCount,a=o===void 0?!1:o,e=t.scheduler):s=t??1/0,z2.share({connector:function(){return new G2.ReplaySubject(s,n,e)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:a})}Wd.shareReplay=K2});var gy=v(Gd=>{"use strict";Object.defineProperty(Gd,"__esModule",{value:!0});Gd.single=void 0;var Y2=pr(),Z2=Xm(),Q2=Jm(),J2=L(),X2=V();function eW(t){return J2.operate(function(n,e){var r=!1,i,o=!1,s=0;n.subscribe(X2.createOperatorSubscriber(e,function(a){o=!0,(!t||t(a,s++,n))&&(r&&e.error(new Z2.SequenceError("Too many matching values")),r=!0,i=a)},function(){r?(e.next(i),e.complete()):e.error(o?new Q2.NotFoundError("No matching values"):new Y2.EmptyError)}))})}Gd.single=eW});var yy=v(zd=>{"use strict";Object.defineProperty(zd,"__esModule",{value:!0});zd.skip=void 0;var tW=$n();function nW(t){return tW.filter(function(n,e){return t<=e})}zd.skip=nW});var vy=v(Kd=>{"use strict";Object.defineProperty(Kd,"__esModule",{value:!0});Kd.skipLast=void 0;var rW=ut(),iW=L(),oW=V();function sW(t){return t<=0?rW.identity:iW.operate(function(n,e){var r=new Array(t),i=0;return n.subscribe(oW.createOperatorSubscriber(e,function(o){var s=i++;if(s<t)r[s]=o;else{var a=s%t,c=r[a];r[a]=o,e.next(c)}})),function(){r=null}})}Kd.skipLast=sW});var _y=v(Yd=>{"use strict";Object.defineProperty(Yd,"__esModule",{value:!0});Yd.skipUntil=void 0;var aW=L(),RI=V(),cW=se(),uW=ct();function lW(t){return aW.operate(function(n,e){var r=!1,i=RI.createOperatorSubscriber(e,function(){i?.unsubscribe(),r=!0},uW.noop);cW.innerFrom(t).subscribe(i),n.subscribe(RI.createOperatorSubscriber(e,function(o){return r&&e.next(o)}))})}Yd.skipUntil=lW});var by=v(Zd=>{"use strict";Object.defineProperty(Zd,"__esModule",{value:!0});Zd.skipWhile=void 0;var dW=L(),fW=V();function hW(t){return dW.operate(function(n,e){var r=!1,i=0;n.subscribe(fW.createOperatorSubscriber(e,function(o){return(r||(r=!t(o,i++)))&&e.next(o)}))})}Zd.skipWhile=hW});var wy=v(Qd=>{"use strict";Object.defineProperty(Qd,"__esModule",{value:!0});Qd.startWith=void 0;var kI=ha(),pW=Tt(),mW=L();function gW(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=pW.popScheduler(t);return mW.operate(function(r,i){(e?kI.concat(t,r,e):kI.concat(t,r)).subscribe(i)})}Qd.startWith=gW});var Uo=v(Jd=>{"use strict";Object.defineProperty(Jd,"__esModule",{value:!0});Jd.switchMap=void 0;var yW=se(),vW=L(),LI=V();function _W(t,n){return vW.operate(function(e,r){var i=null,o=0,s=!1,a=function(){return s&&!i&&r.complete()};e.subscribe(LI.createOperatorSubscriber(r,function(c){i?.unsubscribe();var u=0,l=o++;yW.innerFrom(t(c,l)).subscribe(i=LI.createOperatorSubscriber(r,function(d){return r.next(n?n(c,d,l,u++):d)},function(){i=null,a()}))},function(){s=!0,a()}))})}Jd.switchMap=_W});var Ey=v(Xd=>{"use strict";Object.defineProperty(Xd,"__esModule",{value:!0});Xd.switchAll=void 0;var bW=Uo(),wW=ut();function EW(){return bW.switchMap(wW.identity)}Xd.switchAll=EW});var Sy=v(ef=>{"use strict";Object.defineProperty(ef,"__esModule",{value:!0});ef.switchMapTo=void 0;var jI=Uo(),SW=ke();function CW(t,n){return SW.isFunction(n)?jI.switchMap(function(){return t},n):jI.switchMap(function(){return t})}ef.switchMapTo=CW});var Cy=v(tf=>{"use strict";Object.defineProperty(tf,"__esModule",{value:!0});tf.switchScan=void 0;var IW=Uo(),TW=L();function xW(t,n){return TW.operate(function(e,r){var i=n;return IW.switchMap(function(o,s){return t(i,o,s)},function(o,s){return i=s,s})(e).subscribe(r),function(){i=null}})}tf.switchScan=xW});var Iy=v(nf=>{"use strict";Object.defineProperty(nf,"__esModule",{value:!0});nf.takeUntil=void 0;var DW=L(),OW=V(),MW=se(),AW=ct();function NW(t){return DW.operate(function(n,e){MW.innerFrom(t).subscribe(OW.createOperatorSubscriber(e,function(){return e.complete()},AW.noop)),!e.closed&&n.subscribe(e)})}nf.takeUntil=NW});var Ty=v(rf=>{"use strict";Object.defineProperty(rf,"__esModule",{value:!0});rf.takeWhile=void 0;var PW=L(),RW=V();function kW(t,n){return n===void 0&&(n=!1),PW.operate(function(e,r){var i=0;e.subscribe(RW.createOperatorSubscriber(r,function(o){var s=t(o,i++);(s||n)&&r.next(o),!s&&r.complete()}))})}rf.takeWhile=kW});var xy=v(of=>{"use strict";Object.defineProperty(of,"__esModule",{value:!0});of.tap=void 0;var LW=ke(),jW=L(),FW=V(),$W=ut();function qW(t,n,e){var r=LW.isFunction(t)||n||e?{next:t,error:n,complete:e}:t;return r?jW.operate(function(i,o){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var a=!0;i.subscribe(FW.createOperatorSubscriber(o,function(c){var u;(u=r.next)===null||u===void 0||u.call(r,c),o.next(c)},function(){var c;a=!1,(c=r.complete)===null||c===void 0||c.call(r),o.complete()},function(c){var u;a=!1,(u=r.error)===null||u===void 0||u.call(r,c),o.error(c)},function(){var c,u;a&&((c=r.unsubscribe)===null||c===void 0||c.call(r)),(u=r.finalize)===null||u===void 0||u.call(r)}))}):$W.identity}of.tap=qW});var af=v(sf=>{"use strict";Object.defineProperty(sf,"__esModule",{value:!0});sf.throttle=void 0;var BW=L(),FI=V(),HW=se();function UW(t,n){return BW.operate(function(e,r){var i=n??{},o=i.leading,s=o===void 0?!0:o,a=i.trailing,c=a===void 0?!1:a,u=!1,l=null,d=null,f=!1,p=function(){d?.unsubscribe(),d=null,c&&(b(),f&&r.complete())},m=function(){d=null,f&&r.complete()},y=function(E){return d=HW.innerFrom(t(E)).subscribe(FI.createOperatorSubscriber(r,p,m))},b=function(){if(u){u=!1;var E=l;l=null,r.next(E),!f&&y(E)}};e.subscribe(FI.createOperatorSubscriber(r,function(E){u=!0,l=E,!(d&&!d.closed)&&(s?b():y(E))},function(){f=!0,!(c&&u&&d&&!d.closed)&&r.complete()}))})}sf.throttle=UW});var Dy=v(cf=>{"use strict";Object.defineProperty(cf,"__esModule",{value:!0});cf.throttleTime=void 0;var VW=It(),WW=af(),GW=vr();function zW(t,n,e){n===void 0&&(n=VW.asyncScheduler);var r=GW.timer(t,n);return WW.throttle(function(){return r},e)}cf.throttleTime=zW});var Oy=v(Vo=>{"use strict";Object.defineProperty(Vo,"__esModule",{value:!0});Vo.TimeInterval=Vo.timeInterval=void 0;var KW=It(),YW=L(),ZW=V();function QW(t){return t===void 0&&(t=KW.asyncScheduler),YW.operate(function(n,e){var r=t.now();n.subscribe(ZW.createOperatorSubscriber(e,function(i){var o=t.now(),s=o-r;r=o,e.next(new $I(i,s))}))})}Vo.timeInterval=QW;var $I=(function(){function t(n,e){this.value=n,this.interval=e}return t})();Vo.TimeInterval=$I});var My=v(uf=>{"use strict";Object.defineProperty(uf,"__esModule",{value:!0});uf.timeoutWith=void 0;var JW=It(),XW=Gu(),eG=da();function tG(t,n,e){var r,i,o;if(e=e??JW.async,XW.isValidDate(t)?r=t:typeof t=="number"&&(i=t),n)o=function(){return n};else throw new TypeError("No observable provided to switch to");if(r==null&&i==null)throw new TypeError("No timeout provided.");return eG.timeout({first:r,each:i,scheduler:e,with:o})}uf.timeoutWith=tG});var Ay=v(lf=>{"use strict";Object.defineProperty(lf,"__esModule",{value:!0});lf.timestamp=void 0;var nG=uu(),rG=Fn();function iG(t){return t===void 0&&(t=nG.dateTimestampProvider),rG.map(function(n){return{value:n,timestamp:t.now()}})}lf.timestamp=iG});var Ny=v(df=>{"use strict";Object.defineProperty(df,"__esModule",{value:!0});df.window=void 0;var qI=lt(),oG=L(),BI=V(),sG=ct(),aG=se();function cG(t){return oG.operate(function(n,e){var r=new qI.Subject;e.next(r.asObservable());var i=function(o){r.error(o),e.error(o)};return n.subscribe(BI.createOperatorSubscriber(e,function(o){return r?.next(o)},function(){r.complete(),e.complete()},i)),aG.innerFrom(t).subscribe(BI.createOperatorSubscriber(e,function(){r.complete(),e.next(r=new qI.Subject)},sG.noop,i)),function(){r?.unsubscribe(),r=null}})}df.window=cG});var Py=v(Wo=>{"use strict";var uG=Wo&&Wo.__values||function(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Wo,"__esModule",{value:!0});Wo.windowCount=void 0;var HI=lt(),lG=L(),dG=V();function fG(t,n){n===void 0&&(n=0);var e=n>0?n:t;return lG.operate(function(r,i){var o=[new HI.Subject],s=[],a=0;i.next(o[0].asObservable()),r.subscribe(dG.createOperatorSubscriber(i,function(c){var u,l;try{for(var d=uG(o),f=d.next();!f.done;f=d.next()){var p=f.value;p.next(c)}}catch(b){u={error:b}}finally{try{f&&!f.done&&(l=d.return)&&l.call(d)}finally{if(u)throw u.error}}var m=a-t+1;if(m>=0&&m%e===0&&o.shift().complete(),++a%e===0){var y=new HI.Subject;o.push(y),i.next(y.asObservable())}},function(){for(;o.length>0;)o.shift().complete();i.complete()},function(c){for(;o.length>0;)o.shift().error(c);i.error(c)},function(){s=null,o=null}))})}Wo.windowCount=fG});var Ry=v(ff=>{"use strict";Object.defineProperty(ff,"__esModule",{value:!0});ff.windowTime=void 0;var hG=lt(),pG=It(),mG=Lt(),gG=L(),yG=V(),vG=Rn(),_G=Tt(),UI=kn();function bG(t){for(var n,e,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];var o=(n=_G.popScheduler(r))!==null&&n!==void 0?n:pG.asyncScheduler,s=(e=r[0])!==null&&e!==void 0?e:null,a=r[1]||1/0;return gG.operate(function(c,u){var l=[],d=!1,f=function(b){var E=b.window,D=b.subs;E.complete(),D.unsubscribe(),vG.arrRemove(l,b),d&&p()},p=function(){if(l){var b=new mG.Subscription;u.add(b);var E=new hG.Subject,D={window:E,subs:b,seen:0};l.push(D),u.next(E.asObservable()),UI.executeSchedule(b,o,function(){return f(D)},t)}};s!==null&&s>=0?UI.executeSchedule(u,o,p,s,!0):d=!0,p();var m=function(b){return l.slice().forEach(b)},y=function(b){m(function(E){var D=E.window;return b(D)}),b(u),u.unsubscribe()};return c.subscribe(yG.createOperatorSubscriber(u,function(b){m(function(E){E.window.next(b),a<=++E.seen&&f(E)})},function(){return y(function(b){return b.complete()})},function(b){return y(function(E){return E.error(b)})})),function(){l=null}})}ff.windowTime=bG});var Ly=v(Go=>{"use strict";var wG=Go&&Go.__values||function(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Go,"__esModule",{value:!0});Go.windowToggle=void 0;var EG=lt(),SG=Lt(),CG=L(),VI=se(),ky=V(),WI=ct(),IG=Rn();function TG(t,n){return CG.operate(function(e,r){var i=[],o=function(s){for(;0<i.length;)i.shift().error(s);r.error(s)};VI.innerFrom(t).subscribe(ky.createOperatorSubscriber(r,function(s){var a=new EG.Subject;i.push(a);var c=new SG.Subscription,u=function(){IG.arrRemove(i,a),a.complete(),c.unsubscribe()},l;try{l=VI.innerFrom(n(s))}catch(d){o(d);return}r.next(a.asObservable()),c.add(l.subscribe(ky.createOperatorSubscriber(r,u,WI.noop,o)))},WI.noop)),e.subscribe(ky.createOperatorSubscriber(r,function(s){var a,c,u=i.slice();try{for(var l=wG(u),d=l.next();!d.done;d=l.next()){var f=d.value;f.next(s)}}catch(p){a={error:p}}finally{try{d&&!d.done&&(c=l.return)&&c.call(l)}finally{if(a)throw a.error}}},function(){for(;0<i.length;)i.shift().complete();r.complete()},o,function(){for(;0<i.length;)i.shift().unsubscribe()}))})}Go.windowToggle=TG});var jy=v(hf=>{"use strict";Object.defineProperty(hf,"__esModule",{value:!0});hf.windowWhen=void 0;var xG=lt(),DG=L(),GI=V(),OG=se();function MG(t){return DG.operate(function(n,e){var r,i,o=function(a){r.error(a),e.error(a)},s=function(){i?.unsubscribe(),r?.complete(),r=new xG.Subject,e.next(r.asObservable());var a;try{a=OG.innerFrom(t())}catch(c){o(c);return}a.subscribe(i=GI.createOperatorSubscriber(e,s,s,o))};s(),n.subscribe(GI.createOperatorSubscriber(e,function(a){return r.next(a)},function(){r.complete(),e.complete()},o,function(){i?.unsubscribe(),r=null}))})}hf.windowWhen=MG});var Fy=v(Or=>{"use strict";var zI=Or&&Or.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},KI=Or&&Or.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Or,"__esModule",{value:!0});Or.withLatestFrom=void 0;var AG=L(),YI=V(),NG=se(),PG=ut(),RG=ct(),kG=Tt();function LG(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=kG.popResultSelector(t);return AG.operate(function(r,i){for(var o=t.length,s=new Array(o),a=t.map(function(){return!1}),c=!1,u=function(d){NG.innerFrom(t[d]).subscribe(YI.createOperatorSubscriber(i,function(f){s[d]=f,!c&&!a[d]&&(a[d]=!0,(c=a.every(PG.identity))&&(a=null))},RG.noop))},l=0;l<o;l++)u(l);r.subscribe(YI.createOperatorSubscriber(i,function(d){if(c){var f=KI([d],zI(s));i.next(e?e.apply(void 0,KI([],zI(f))):f)}}))})}Or.withLatestFrom=LG});var $y=v(pf=>{"use strict";Object.defineProperty(pf,"__esModule",{value:!0});pf.zipAll=void 0;var jG=wl(),FG=bg();function $G(t){return FG.joinAllInternals(jG.zip,t)}pf.zipAll=$G});var qy=v(Mr=>{"use strict";var qG=Mr&&Mr.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},BG=Mr&&Mr.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Mr,"__esModule",{value:!0});Mr.zip=void 0;var HG=wl(),UG=L();function VG(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return UG.operate(function(e,r){HG.zip.apply(void 0,BG([e],qG(t))).subscribe(r)})}Mr.zip=VG});var By=v(Ar=>{"use strict";var WG=Ar&&Ar.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},GG=Ar&&Ar.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Ar,"__esModule",{value:!0});Ar.zipWith=void 0;var zG=qy();function KG(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return zG.zip.apply(void 0,GG([],WG(t)))}Ar.zipWith=KG});var Q=v(h=>{"use strict";var YG=h&&h.__createBinding||(Object.create?function(t,n,e,r){r===void 0&&(r=e),Object.defineProperty(t,r,{enumerable:!0,get:function(){return n[e]}})}:function(t,n,e,r){r===void 0&&(r=e),t[r]=n[e]}),ZG=h&&h.__exportStar||function(t,n){for(var e in t)e!=="default"&&!Object.prototype.hasOwnProperty.call(n,e)&&YG(n,t,e)};Object.defineProperty(h,"__esModule",{value:!0});h.interval=h.iif=h.generate=h.fromEventPattern=h.fromEvent=h.from=h.forkJoin=h.empty=h.defer=h.connectable=h.concat=h.combineLatest=h.bindNodeCallback=h.bindCallback=h.UnsubscriptionError=h.TimeoutError=h.SequenceError=h.ObjectUnsubscribedError=h.NotFoundError=h.EmptyError=h.ArgumentOutOfRangeError=h.firstValueFrom=h.lastValueFrom=h.isObservable=h.identity=h.noop=h.pipe=h.NotificationKind=h.Notification=h.Subscriber=h.Subscription=h.Scheduler=h.VirtualAction=h.VirtualTimeScheduler=h.animationFrameScheduler=h.animationFrame=h.queueScheduler=h.queue=h.asyncScheduler=h.async=h.asapScheduler=h.asap=h.AsyncSubject=h.ReplaySubject=h.BehaviorSubject=h.Subject=h.animationFrames=h.observable=h.ConnectableObservable=h.Observable=void 0;h.filter=h.expand=h.exhaustMap=h.exhaustAll=h.exhaust=h.every=h.endWith=h.elementAt=h.distinctUntilKeyChanged=h.distinctUntilChanged=h.distinct=h.dematerialize=h.delayWhen=h.delay=h.defaultIfEmpty=h.debounceTime=h.debounce=h.count=h.connect=h.concatWith=h.concatMapTo=h.concatMap=h.concatAll=h.combineLatestWith=h.combineLatestAll=h.combineAll=h.catchError=h.bufferWhen=h.bufferToggle=h.bufferTime=h.bufferCount=h.buffer=h.auditTime=h.audit=h.config=h.NEVER=h.EMPTY=h.scheduled=h.zip=h.using=h.timer=h.throwError=h.range=h.race=h.partition=h.pairs=h.onErrorResumeNext=h.of=h.never=h.merge=void 0;h.switchMap=h.switchAll=h.subscribeOn=h.startWith=h.skipWhile=h.skipUntil=h.skipLast=h.skip=h.single=h.shareReplay=h.share=h.sequenceEqual=h.scan=h.sampleTime=h.sample=h.refCount=h.retryWhen=h.retry=h.repeatWhen=h.repeat=h.reduce=h.raceWith=h.publishReplay=h.publishLast=h.publishBehavior=h.publish=h.pluck=h.pairwise=h.onErrorResumeNextWith=h.observeOn=h.multicast=h.min=h.mergeWith=h.mergeScan=h.mergeMapTo=h.mergeMap=h.flatMap=h.mergeAll=h.max=h.materialize=h.mapTo=h.map=h.last=h.isEmpty=h.ignoreElements=h.groupBy=h.first=h.findIndex=h.find=h.finalize=void 0;h.zipWith=h.zipAll=h.withLatestFrom=h.windowWhen=h.windowToggle=h.windowTime=h.windowCount=h.window=h.toArray=h.timestamp=h.timeoutWith=h.timeout=h.timeInterval=h.throwIfEmpty=h.throttleTime=h.throttle=h.tap=h.takeWhile=h.takeUntil=h.takeLast=h.take=h.switchScan=h.switchMapTo=void 0;var QG=je();Object.defineProperty(h,"Observable",{enumerable:!0,get:function(){return QG.Observable}});var JG=aa();Object.defineProperty(h,"ConnectableObservable",{enumerable:!0,get:function(){return JG.ConnectableObservable}});var XG=oa();Object.defineProperty(h,"observable",{enumerable:!0,get:function(){return XG.observable}});var e4=xS();Object.defineProperty(h,"animationFrames",{enumerable:!0,get:function(){return e4.animationFrames}});var t4=lt();Object.defineProperty(h,"Subject",{enumerable:!0,get:function(){return t4.Subject}});var n4=Rm();Object.defineProperty(h,"BehaviorSubject",{enumerable:!0,get:function(){return n4.BehaviorSubject}});var r4=lu();Object.defineProperty(h,"ReplaySubject",{enumerable:!0,get:function(){return r4.ReplaySubject}});var i4=du();Object.defineProperty(h,"AsyncSubject",{enumerable:!0,get:function(){return i4.AsyncSubject}});var ZI=VS();Object.defineProperty(h,"asap",{enumerable:!0,get:function(){return ZI.asap}});Object.defineProperty(h,"asapScheduler",{enumerable:!0,get:function(){return ZI.asapScheduler}});var QI=It();Object.defineProperty(h,"async",{enumerable:!0,get:function(){return QI.async}});Object.defineProperty(h,"asyncScheduler",{enumerable:!0,get:function(){return QI.asyncScheduler}});var JI=zS();Object.defineProperty(h,"queue",{enumerable:!0,get:function(){return JI.queue}});Object.defineProperty(h,"queueScheduler",{enumerable:!0,get:function(){return JI.queueScheduler}});var XI=QS();Object.defineProperty(h,"animationFrame",{enumerable:!0,get:function(){return XI.animationFrame}});Object.defineProperty(h,"animationFrameScheduler",{enumerable:!0,get:function(){return XI.animationFrameScheduler}});var eT=eC();Object.defineProperty(h,"VirtualTimeScheduler",{enumerable:!0,get:function(){return eT.VirtualTimeScheduler}});Object.defineProperty(h,"VirtualAction",{enumerable:!0,get:function(){return eT.VirtualAction}});var o4=Lm();Object.defineProperty(h,"Scheduler",{enumerable:!0,get:function(){return o4.Scheduler}});var s4=Lt();Object.defineProperty(h,"Subscription",{enumerable:!0,get:function(){return s4.Subscription}});var a4=oo();Object.defineProperty(h,"Subscriber",{enumerable:!0,get:function(){return a4.Subscriber}});var tT=ju();Object.defineProperty(h,"Notification",{enumerable:!0,get:function(){return tT.Notification}});Object.defineProperty(h,"NotificationKind",{enumerable:!0,get:function(){return tT.NotificationKind}});var c4=sa();Object.defineProperty(h,"pipe",{enumerable:!0,get:function(){return c4.pipe}});var u4=ct();Object.defineProperty(h,"noop",{enumerable:!0,get:function(){return u4.noop}});var l4=ut();Object.defineProperty(h,"identity",{enumerable:!0,get:function(){return l4.identity}});var d4=yC();Object.defineProperty(h,"isObservable",{enumerable:!0,get:function(){return d4.isObservable}});var f4=vC();Object.defineProperty(h,"lastValueFrom",{enumerable:!0,get:function(){return f4.lastValueFrom}});var h4=_C();Object.defineProperty(h,"firstValueFrom",{enumerable:!0,get:function(){return h4.firstValueFrom}});var p4=Qm();Object.defineProperty(h,"ArgumentOutOfRangeError",{enumerable:!0,get:function(){return p4.ArgumentOutOfRangeError}});var m4=pr();Object.defineProperty(h,"EmptyError",{enumerable:!0,get:function(){return m4.EmptyError}});var g4=Jm();Object.defineProperty(h,"NotFoundError",{enumerable:!0,get:function(){return g4.NotFoundError}});var y4=Mm();Object.defineProperty(h,"ObjectUnsubscribedError",{enumerable:!0,get:function(){return y4.ObjectUnsubscribedError}});var v4=Xm();Object.defineProperty(h,"SequenceError",{enumerable:!0,get:function(){return v4.SequenceError}});var _4=da();Object.defineProperty(h,"TimeoutError",{enumerable:!0,get:function(){return _4.TimeoutError}});var b4=vm();Object.defineProperty(h,"UnsubscriptionError",{enumerable:!0,get:function(){return b4.UnsubscriptionError}});var w4=wC();Object.defineProperty(h,"bindCallback",{enumerable:!0,get:function(){return w4.bindCallback}});var E4=EC();Object.defineProperty(h,"bindNodeCallback",{enumerable:!0,get:function(){return E4.bindNodeCallback}});var S4=Ju();Object.defineProperty(h,"combineLatest",{enumerable:!0,get:function(){return S4.combineLatest}});var C4=ha();Object.defineProperty(h,"concat",{enumerable:!0,get:function(){return C4.concat}});var I4=MC();Object.defineProperty(h,"connectable",{enumerable:!0,get:function(){return I4.connectable}});var T4=pa();Object.defineProperty(h,"defer",{enumerable:!0,get:function(){return T4.defer}});var x4=on();Object.defineProperty(h,"empty",{enumerable:!0,get:function(){return x4.empty}});var D4=AC();Object.defineProperty(h,"forkJoin",{enumerable:!0,get:function(){return D4.forkJoin}});var O4=Ln();Object.defineProperty(h,"from",{enumerable:!0,get:function(){return O4.from}});var M4=PC();Object.defineProperty(h,"fromEvent",{enumerable:!0,get:function(){return M4.fromEvent}});var A4=kC();Object.defineProperty(h,"fromEventPattern",{enumerable:!0,get:function(){return A4.fromEventPattern}});var N4=jC();Object.defineProperty(h,"generate",{enumerable:!0,get:function(){return N4.generate}});var P4=FC();Object.defineProperty(h,"iif",{enumerable:!0,get:function(){return P4.iif}});var R4=og();Object.defineProperty(h,"interval",{enumerable:!0,get:function(){return R4.interval}});var k4=qC();Object.defineProperty(h,"merge",{enumerable:!0,get:function(){return k4.merge}});var L4=sg();Object.defineProperty(h,"never",{enumerable:!0,get:function(){return L4.never}});var j4=ku();Object.defineProperty(h,"of",{enumerable:!0,get:function(){return j4.of}});var F4=ag();Object.defineProperty(h,"onErrorResumeNext",{enumerable:!0,get:function(){return F4.onErrorResumeNext}});var $4=HC();Object.defineProperty(h,"pairs",{enumerable:!0,get:function(){return $4.pairs}});var q4=WC();Object.defineProperty(h,"partition",{enumerable:!0,get:function(){return q4.partition}});var B4=ug();Object.defineProperty(h,"race",{enumerable:!0,get:function(){return B4.race}});var H4=KC();Object.defineProperty(h,"range",{enumerable:!0,get:function(){return H4.range}});var U4=Zm();Object.defineProperty(h,"throwError",{enumerable:!0,get:function(){return U4.throwError}});var V4=vr();Object.defineProperty(h,"timer",{enumerable:!0,get:function(){return V4.timer}});var W4=YC();Object.defineProperty(h,"using",{enumerable:!0,get:function(){return W4.using}});var G4=wl();Object.defineProperty(h,"zip",{enumerable:!0,get:function(){return G4.zip}});var z4=Ym();Object.defineProperty(h,"scheduled",{enumerable:!0,get:function(){return z4.scheduled}});var K4=on();Object.defineProperty(h,"EMPTY",{enumerable:!0,get:function(){return K4.EMPTY}});var Y4=sg();Object.defineProperty(h,"NEVER",{enumerable:!0,get:function(){return Y4.NEVER}});ZG(QC(),h);var Z4=ro();Object.defineProperty(h,"config",{enumerable:!0,get:function(){return Z4.config}});var Q4=Sl();Object.defineProperty(h,"audit",{enumerable:!0,get:function(){return Q4.audit}});var J4=lg();Object.defineProperty(h,"auditTime",{enumerable:!0,get:function(){return J4.auditTime}});var X4=dg();Object.defineProperty(h,"buffer",{enumerable:!0,get:function(){return X4.buffer}});var e3=hg();Object.defineProperty(h,"bufferCount",{enumerable:!0,get:function(){return e3.bufferCount}});var t3=pg();Object.defineProperty(h,"bufferTime",{enumerable:!0,get:function(){return t3.bufferTime}});var n3=gg();Object.defineProperty(h,"bufferToggle",{enumerable:!0,get:function(){return n3.bufferToggle}});var r3=yg();Object.defineProperty(h,"bufferWhen",{enumerable:!0,get:function(){return r3.bufferWhen}});var i3=vg();Object.defineProperty(h,"catchError",{enumerable:!0,get:function(){return i3.catchError}});var o3=wg();Object.defineProperty(h,"combineAll",{enumerable:!0,get:function(){return o3.combineAll}});var s3=Rl();Object.defineProperty(h,"combineLatestAll",{enumerable:!0,get:function(){return s3.combineLatestAll}});var a3=Sg();Object.defineProperty(h,"combineLatestWith",{enumerable:!0,get:function(){return a3.combineLatestWith}});var c3=fa();Object.defineProperty(h,"concatAll",{enumerable:!0,get:function(){return c3.concatAll}});var u3=jl();Object.defineProperty(h,"concatMap",{enumerable:!0,get:function(){return u3.concatMap}});var l3=Cg();Object.defineProperty(h,"concatMapTo",{enumerable:!0,get:function(){return l3.concatMapTo}});var d3=Tg();Object.defineProperty(h,"concatWith",{enumerable:!0,get:function(){return d3.concatWith}});var f3=ma();Object.defineProperty(h,"connect",{enumerable:!0,get:function(){return f3.connect}});var h3=xg();Object.defineProperty(h,"count",{enumerable:!0,get:function(){return h3.count}});var p3=Dg();Object.defineProperty(h,"debounce",{enumerable:!0,get:function(){return p3.debounce}});var m3=Og();Object.defineProperty(h,"debounceTime",{enumerable:!0,get:function(){return m3.debounceTime}});var g3=Fo();Object.defineProperty(h,"defaultIfEmpty",{enumerable:!0,get:function(){return g3.defaultIfEmpty}});var y3=Mg();Object.defineProperty(h,"delay",{enumerable:!0,get:function(){return y3.delay}});var v3=Ql();Object.defineProperty(h,"delayWhen",{enumerable:!0,get:function(){return v3.delayWhen}});var _3=Ag();Object.defineProperty(h,"dematerialize",{enumerable:!0,get:function(){return _3.dematerialize}});var b3=Ng();Object.defineProperty(h,"distinct",{enumerable:!0,get:function(){return b3.distinct}});var w3=nd();Object.defineProperty(h,"distinctUntilChanged",{enumerable:!0,get:function(){return w3.distinctUntilChanged}});var E3=Pg();Object.defineProperty(h,"distinctUntilKeyChanged",{enumerable:!0,get:function(){return E3.distinctUntilKeyChanged}});var S3=Rg();Object.defineProperty(h,"elementAt",{enumerable:!0,get:function(){return S3.elementAt}});var C3=kg();Object.defineProperty(h,"endWith",{enumerable:!0,get:function(){return C3.endWith}});var I3=Lg();Object.defineProperty(h,"every",{enumerable:!0,get:function(){return I3.every}});var T3=jg();Object.defineProperty(h,"exhaust",{enumerable:!0,get:function(){return T3.exhaust}});var x3=ld();Object.defineProperty(h,"exhaustAll",{enumerable:!0,get:function(){return x3.exhaustAll}});var D3=cd();Object.defineProperty(h,"exhaustMap",{enumerable:!0,get:function(){return D3.exhaustMap}});var O3=Fg();Object.defineProperty(h,"expand",{enumerable:!0,get:function(){return O3.expand}});var M3=$n();Object.defineProperty(h,"filter",{enumerable:!0,get:function(){return M3.filter}});var A3=$g();Object.defineProperty(h,"finalize",{enumerable:!0,get:function(){return A3.finalize}});var N3=pd();Object.defineProperty(h,"find",{enumerable:!0,get:function(){return N3.find}});var P3=qg();Object.defineProperty(h,"findIndex",{enumerable:!0,get:function(){return P3.findIndex}});var R3=Bg();Object.defineProperty(h,"first",{enumerable:!0,get:function(){return R3.first}});var k3=Hg();Object.defineProperty(h,"groupBy",{enumerable:!0,get:function(){return k3.groupBy}});var L3=zl();Object.defineProperty(h,"ignoreElements",{enumerable:!0,get:function(){return L3.ignoreElements}});var j3=Ug();Object.defineProperty(h,"isEmpty",{enumerable:!0,get:function(){return j3.isEmpty}});var F3=Vg();Object.defineProperty(h,"last",{enumerable:!0,get:function(){return F3.last}});var $3=Fn();Object.defineProperty(h,"map",{enumerable:!0,get:function(){return $3.map}});var q3=Yl();Object.defineProperty(h,"mapTo",{enumerable:!0,get:function(){return q3.mapTo}});var B3=Gg();Object.defineProperty(h,"materialize",{enumerable:!0,get:function(){return B3.materialize}});var H3=zg();Object.defineProperty(h,"max",{enumerable:!0,get:function(){return H3.max}});var U3=Ao();Object.defineProperty(h,"mergeAll",{enumerable:!0,get:function(){return U3.mergeAll}});var V3=Kg();Object.defineProperty(h,"flatMap",{enumerable:!0,get:function(){return V3.flatMap}});var W3=_n();Object.defineProperty(h,"mergeMap",{enumerable:!0,get:function(){return W3.mergeMap}});var G3=Yg();Object.defineProperty(h,"mergeMapTo",{enumerable:!0,get:function(){return G3.mergeMapTo}});var z3=Zg();Object.defineProperty(h,"mergeScan",{enumerable:!0,get:function(){return z3.mergeScan}});var K3=Jg();Object.defineProperty(h,"mergeWith",{enumerable:!0,get:function(){return K3.mergeWith}});var Y3=Xg();Object.defineProperty(h,"min",{enumerable:!0,get:function(){return Y3.min}});var Z3=ga();Object.defineProperty(h,"multicast",{enumerable:!0,get:function(){return Z3.multicast}});var Q3=Do();Object.defineProperty(h,"observeOn",{enumerable:!0,get:function(){return Q3.observeOn}});var J3=ey();Object.defineProperty(h,"onErrorResumeNextWith",{enumerable:!0,get:function(){return J3.onErrorResumeNextWith}});var X3=ty();Object.defineProperty(h,"pairwise",{enumerable:!0,get:function(){return X3.pairwise}});var ez=ny();Object.defineProperty(h,"pluck",{enumerable:!0,get:function(){return ez.pluck}});var tz=ry();Object.defineProperty(h,"publish",{enumerable:!0,get:function(){return tz.publish}});var nz=iy();Object.defineProperty(h,"publishBehavior",{enumerable:!0,get:function(){return nz.publishBehavior}});var rz=oy();Object.defineProperty(h,"publishLast",{enumerable:!0,get:function(){return rz.publishLast}});var iz=sy();Object.defineProperty(h,"publishReplay",{enumerable:!0,get:function(){return iz.publishReplay}});var oz=Rd();Object.defineProperty(h,"raceWith",{enumerable:!0,get:function(){return oz.raceWith}});var sz=mi();Object.defineProperty(h,"reduce",{enumerable:!0,get:function(){return sz.reduce}});var az=ay();Object.defineProperty(h,"repeat",{enumerable:!0,get:function(){return az.repeat}});var cz=cy();Object.defineProperty(h,"repeatWhen",{enumerable:!0,get:function(){return cz.repeatWhen}});var uz=uy();Object.defineProperty(h,"retry",{enumerable:!0,get:function(){return uz.retry}});var lz=ly();Object.defineProperty(h,"retryWhen",{enumerable:!0,get:function(){return lz.retryWhen}});var dz=su();Object.defineProperty(h,"refCount",{enumerable:!0,get:function(){return dz.refCount}});var fz=qd();Object.defineProperty(h,"sample",{enumerable:!0,get:function(){return fz.sample}});var hz=dy();Object.defineProperty(h,"sampleTime",{enumerable:!0,get:function(){return hz.sampleTime}});var pz=fy();Object.defineProperty(h,"scan",{enumerable:!0,get:function(){return pz.scan}});var mz=hy();Object.defineProperty(h,"sequenceEqual",{enumerable:!0,get:function(){return mz.sequenceEqual}});var gz=Vd();Object.defineProperty(h,"share",{enumerable:!0,get:function(){return gz.share}});var yz=my();Object.defineProperty(h,"shareReplay",{enumerable:!0,get:function(){return yz.shareReplay}});var vz=gy();Object.defineProperty(h,"single",{enumerable:!0,get:function(){return vz.single}});var _z=yy();Object.defineProperty(h,"skip",{enumerable:!0,get:function(){return _z.skip}});var bz=vy();Object.defineProperty(h,"skipLast",{enumerable:!0,get:function(){return bz.skipLast}});var wz=_y();Object.defineProperty(h,"skipUntil",{enumerable:!0,get:function(){return wz.skipUntil}});var Ez=by();Object.defineProperty(h,"skipWhile",{enumerable:!0,get:function(){return Ez.skipWhile}});var Sz=wy();Object.defineProperty(h,"startWith",{enumerable:!0,get:function(){return Sz.startWith}});var Cz=Oo();Object.defineProperty(h,"subscribeOn",{enumerable:!0,get:function(){return Cz.subscribeOn}});var Iz=Ey();Object.defineProperty(h,"switchAll",{enumerable:!0,get:function(){return Iz.switchAll}});var Tz=Uo();Object.defineProperty(h,"switchMap",{enumerable:!0,get:function(){return Tz.switchMap}});var xz=Sy();Object.defineProperty(h,"switchMapTo",{enumerable:!0,get:function(){return xz.switchMapTo}});var Dz=Cy();Object.defineProperty(h,"switchScan",{enumerable:!0,get:function(){return Dz.switchScan}});var Oz=$o();Object.defineProperty(h,"take",{enumerable:!0,get:function(){return Oz.take}});var Mz=_d();Object.defineProperty(h,"takeLast",{enumerable:!0,get:function(){return Mz.takeLast}});var Az=Iy();Object.defineProperty(h,"takeUntil",{enumerable:!0,get:function(){return Az.takeUntil}});var Nz=Ty();Object.defineProperty(h,"takeWhile",{enumerable:!0,get:function(){return Nz.takeWhile}});var Pz=xy();Object.defineProperty(h,"tap",{enumerable:!0,get:function(){return Pz.tap}});var Rz=af();Object.defineProperty(h,"throttle",{enumerable:!0,get:function(){return Rz.throttle}});var kz=Dy();Object.defineProperty(h,"throttleTime",{enumerable:!0,get:function(){return kz.throttleTime}});var Lz=qo();Object.defineProperty(h,"throwIfEmpty",{enumerable:!0,get:function(){return Lz.throwIfEmpty}});var jz=Oy();Object.defineProperty(h,"timeInterval",{enumerable:!0,get:function(){return jz.timeInterval}});var Fz=da();Object.defineProperty(h,"timeout",{enumerable:!0,get:function(){return Fz.timeout}});var $z=My();Object.defineProperty(h,"timeoutWith",{enumerable:!0,get:function(){return $z.timeoutWith}});var qz=Ay();Object.defineProperty(h,"timestamp",{enumerable:!0,get:function(){return qz.timestamp}});var Bz=Al();Object.defineProperty(h,"toArray",{enumerable:!0,get:function(){return Bz.toArray}});var Hz=Ny();Object.defineProperty(h,"window",{enumerable:!0,get:function(){return Hz.window}});var Uz=Py();Object.defineProperty(h,"windowCount",{enumerable:!0,get:function(){return Uz.windowCount}});var Vz=Ry();Object.defineProperty(h,"windowTime",{enumerable:!0,get:function(){return Vz.windowTime}});var Wz=Ly();Object.defineProperty(h,"windowToggle",{enumerable:!0,get:function(){return Wz.windowToggle}});var Gz=jy();Object.defineProperty(h,"windowWhen",{enumerable:!0,get:function(){return Gz.windowWhen}});var zz=Fy();Object.defineProperty(h,"withLatestFrom",{enumerable:!0,get:function(){return zz.withLatestFrom}});var Kz=$y();Object.defineProperty(h,"zipAll",{enumerable:!0,get:function(){return Kz.zipAll}});var Yz=By();Object.defineProperty(h,"zipWith",{enumerable:!0,get:function(){return Yz.zipWith}})});var Ky=v((Gy,zy)=>{(function(t,n){typeof Gy=="object"&&typeof zy<"u"?zy.exports=n():typeof define=="function"&&define.amd?define(n):(t=typeof globalThis<"u"?globalThis:t||self).dayjs=n()})(Gy,function(){"use strict";var t=1e3,n=6e4,e=36e5,r="millisecond",i="second",o="minute",s="hour",a="day",c="week",u="month",l="quarter",d="year",f="date",p="Invalid Date",m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,b={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function($){var x=["th","st","nd","rd"],C=$%100;return"["+$+(x[(C-20)%10]||x[C]||x[0])+"]"}},E=function($,x,C){var P=String($);return!P||P.length>=x?$:""+Array(x+1-P.length).join(C)+$},D={s:E,z:function($){var x=-$.utcOffset(),C=Math.abs(x),P=Math.floor(C/60),O=C%60;return(x<=0?"+":"-")+E(P,2,"0")+":"+E(O,2,"0")},m:function $(x,C){if(x.date()<C.date())return-$(C,x);var P=12*(C.year()-x.year())+(C.month()-x.month()),O=x.clone().add(P,u),B=C-O<0,G=x.clone().add(P+(B?-1:1),u);return+(-(P+(C-O)/(B?O-G:G-O))||0)},a:function($){return $<0?Math.ceil($)||0:Math.floor($)},p:function($){return{M:u,y:d,w:c,d:a,D:f,h:s,m:o,s:i,ms:r,Q:l}[$]||String($||"").toLowerCase().replace(/s$/,"")},u:function($){return $===void 0}},T="en",K={};K[T]=b;var H="$isDayjsObject",re=function($){return $ instanceof rt||!(!$||!$[H])},Ee=function $(x,C,P){var O;if(!x)return T;if(typeof x=="string"){var B=x.toLowerCase();K[B]&&(O=B),C&&(K[B]=C,O=B);var G=x.split("-");if(!O&&G.length>1)return $(G[0])}else{var ie=x.name;K[ie]=x,O=ie}return!P&&O&&(T=O),O||!P&&T},pe=function($,x){if(re($))return $.clone();var C=typeof x=="object"?x:{};return C.date=$,C.args=arguments,new rt(C)},z=D;z.l=Ee,z.i=re,z.w=function($,x){return pe($,{locale:x.$L,utc:x.$u,x:x.$x,$offset:x.$offset})};var rt=(function(){function $(C){this.$L=Ee(C.locale,null,!0),this.parse(C),this.$x=this.$x||C.x||{},this[H]=!0}var x=$.prototype;return x.parse=function(C){this.$d=(function(P){var O=P.date,B=P.utc;if(O===null)return new Date(NaN);if(z.u(O))return new Date;if(O instanceof Date)return new Date(O);if(typeof O=="string"&&!/Z$/i.test(O)){var G=O.match(m);if(G){var ie=G[2]-1||0,Te=(G[7]||"0").substring(0,3);return B?new Date(Date.UTC(G[1],ie,G[3]||1,G[4]||0,G[5]||0,G[6]||0,Te)):new Date(G[1],ie,G[3]||1,G[4]||0,G[5]||0,G[6]||0,Te)}}return new Date(O)})(C),this.init()},x.init=function(){var C=this.$d;this.$y=C.getFullYear(),this.$M=C.getMonth(),this.$D=C.getDate(),this.$W=C.getDay(),this.$H=C.getHours(),this.$m=C.getMinutes(),this.$s=C.getSeconds(),this.$ms=C.getMilliseconds()},x.$utils=function(){return z},x.isValid=function(){return this.$d.toString()!==p},x.isSame=function(C,P){var O=pe(C);return this.startOf(P)<=O&&O<=this.endOf(P)},x.isAfter=function(C,P){return pe(C)<this.startOf(P)},x.isBefore=function(C,P){return this.endOf(P)<pe(C)},x.$g=function(C,P,O){return z.u(C)?this[P]:this.set(O,C)},x.unix=function(){return Math.floor(this.valueOf()/1e3)},x.valueOf=function(){return this.$d.getTime()},x.startOf=function(C,P){var O=this,B=!!z.u(P)||P,G=z.p(C),ie=function(Pn,mt){var it=z.w(O.$u?Date.UTC(O.$y,mt,Pn):new Date(O.$y,mt,Pn),O);return B?it:it.endOf(a)},Te=function(Pn,mt){return z.w(O.toDate()[Pn].apply(O.toDate("s"),(B?[0,0,0,0]:[23,59,59,999]).slice(mt)),O)},oe=this.$W,$e=this.$M,st=this.$D,Le="set"+(this.$u?"UTC":"");switch(G){case d:return B?ie(1,0):ie(31,11);case u:return B?ie(1,$e):ie(0,$e+1);case c:var hn=this.$locale().weekStart||0,ii=(oe<hn?oe+7:oe)-hn;return ie(B?st-ii:st+(6-ii),$e);case a:case f:return Te(Le+"Hours",0);case s:return Te(Le+"Minutes",1);case o:return Te(Le+"Seconds",2);case i:return Te(Le+"Milliseconds",3);default:return this.clone()}},x.endOf=function(C){return this.startOf(C,!1)},x.$set=function(C,P){var O,B=z.p(C),G="set"+(this.$u?"UTC":""),ie=(O={},O[a]=G+"Date",O[f]=G+"Date",O[u]=G+"Month",O[d]=G+"FullYear",O[s]=G+"Hours",O[o]=G+"Minutes",O[i]=G+"Seconds",O[r]=G+"Milliseconds",O)[B],Te=B===a?this.$D+(P-this.$W):P;if(B===u||B===d){var oe=this.clone().set(f,1);oe.$d[ie](Te),oe.init(),this.$d=oe.set(f,Math.min(this.$D,oe.daysInMonth())).$d}else ie&&this.$d[ie](Te);return this.init(),this},x.set=function(C,P){return this.clone().$set(C,P)},x.get=function(C){return this[z.p(C)]()},x.add=function(C,P){var O,B=this;C=Number(C);var G=z.p(P),ie=function($e){var st=pe(B);return z.w(st.date(st.date()+Math.round($e*C)),B)};if(G===u)return this.set(u,this.$M+C);if(G===d)return this.set(d,this.$y+C);if(G===a)return ie(1);if(G===c)return ie(7);var Te=(O={},O[o]=n,O[s]=e,O[i]=t,O)[G]||1,oe=this.$d.getTime()+C*Te;return z.w(oe,this)},x.subtract=function(C,P){return this.add(-1*C,P)},x.format=function(C){var P=this,O=this.$locale();if(!this.isValid())return O.invalidDate||p;var B=C||"YYYY-MM-DDTHH:mm:ssZ",G=z.z(this),ie=this.$H,Te=this.$m,oe=this.$M,$e=O.weekdays,st=O.months,Le=O.meridiem,hn=function(mt,it,cr,tn){return mt&&(mt[it]||mt(P,B))||cr[it].slice(0,tn)},ii=function(mt){return z.s(ie%12||12,mt,"0")},Pn=Le||function(mt,it,cr){var tn=mt<12?"AM":"PM";return cr?tn.toLowerCase():tn};return B.replace(y,function(mt,it){return it||(function(cr){switch(cr){case"YY":return String(P.$y).slice(-2);case"YYYY":return z.s(P.$y,4,"0");case"M":return oe+1;case"MM":return z.s(oe+1,2,"0");case"MMM":return hn(O.monthsShort,oe,st,3);case"MMMM":return hn(st,oe);case"D":return P.$D;case"DD":return z.s(P.$D,2,"0");case"d":return String(P.$W);case"dd":return hn(O.weekdaysMin,P.$W,$e,2);case"ddd":return hn(O.weekdaysShort,P.$W,$e,3);case"dddd":return $e[P.$W];case"H":return String(ie);case"HH":return z.s(ie,2,"0");case"h":return ii(1);case"hh":return ii(2);case"a":return Pn(ie,Te,!0);case"A":return Pn(ie,Te,!1);case"m":return String(Te);case"mm":return z.s(Te,2,"0");case"s":return String(P.$s);case"ss":return z.s(P.$s,2,"0");case"SSS":return z.s(P.$ms,3,"0");case"Z":return G}return null})(mt)||G.replace(":","")})},x.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},x.diff=function(C,P,O){var B,G=this,ie=z.p(P),Te=pe(C),oe=(Te.utcOffset()-this.utcOffset())*n,$e=this-Te,st=function(){return z.m(G,Te)};switch(ie){case d:B=st()/12;break;case u:B=st();break;case l:B=st()/3;break;case c:B=($e-oe)/6048e5;break;case a:B=($e-oe)/864e5;break;case s:B=$e/e;break;case o:B=$e/n;break;case i:B=$e/t;break;default:B=$e}return O?B:z.a(B)},x.daysInMonth=function(){return this.endOf(u).$D},x.$locale=function(){return K[this.$L]},x.locale=function(C,P){if(!C)return this.$L;var O=this.clone(),B=Ee(C,P,!0);return B&&(O.$L=B),O},x.clone=function(){return z.w(this.$d,this)},x.toDate=function(){return new Date(this.valueOf())},x.toJSON=function(){return this.isValid()?this.toISOString():null},x.toISOString=function(){return this.$d.toISOString()},x.toString=function(){return this.$d.toUTCString()},$})(),ee=rt.prototype;return pe.prototype=ee,[["$ms",r],["$s",i],["$m",o],["$H",s],["$W",a],["$M",u],["$y",d],["$D",f]].forEach(function($){ee[$[1]]=function(x){return this.$g(x,$[0],$[1])}}),pe.extend=function($,x){return $.$i||($(x,rt,pe),$.$i=!0),pe},pe.locale=Ee,pe.isDayjs=re,pe.unix=function($){return pe(1e3*$)},pe.en=K[T],pe.Ls=K,pe.p={},pe})});var cx=v(th=>{"use strict";Object.defineProperty(th,"__esModule",{value:!0});th.partition=void 0;var s6=cg(),ax=$n();function a6(t,n){return function(e){return[ax.filter(t,n)(e),ax.filter(s6.not(t,n))(e)]}}th.partition=a6});var ux=v(Br=>{"use strict";var c6=Br&&Br.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],s;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o},u6=Br&&Br.__spreadArray||function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t};Object.defineProperty(Br,"__esModule",{value:!0});Br.race=void 0;var l6=pi(),d6=Rd();function f6(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return d6.raceWith.apply(void 0,u6([],c6(l6.argsOrArgArray(t))))}Br.race=f6});var Ni=v(g=>{"use strict";Object.defineProperty(g,"__esModule",{value:!0});g.mergeAll=g.merge=g.max=g.materialize=g.mapTo=g.map=g.last=g.isEmpty=g.ignoreElements=g.groupBy=g.first=g.findIndex=g.find=g.finalize=g.filter=g.expand=g.exhaustMap=g.exhaustAll=g.exhaust=g.every=g.endWith=g.elementAt=g.distinctUntilKeyChanged=g.distinctUntilChanged=g.distinct=g.dematerialize=g.delayWhen=g.delay=g.defaultIfEmpty=g.debounceTime=g.debounce=g.count=g.connect=g.concatWith=g.concatMapTo=g.concatMap=g.concatAll=g.concat=g.combineLatestWith=g.combineLatest=g.combineLatestAll=g.combineAll=g.catchError=g.bufferWhen=g.bufferToggle=g.bufferTime=g.bufferCount=g.buffer=g.auditTime=g.audit=void 0;g.timeInterval=g.throwIfEmpty=g.throttleTime=g.throttle=g.tap=g.takeWhile=g.takeUntil=g.takeLast=g.take=g.switchScan=g.switchMapTo=g.switchMap=g.switchAll=g.subscribeOn=g.startWith=g.skipWhile=g.skipUntil=g.skipLast=g.skip=g.single=g.shareReplay=g.share=g.sequenceEqual=g.scan=g.sampleTime=g.sample=g.refCount=g.retryWhen=g.retry=g.repeatWhen=g.repeat=g.reduce=g.raceWith=g.race=g.publishReplay=g.publishLast=g.publishBehavior=g.publish=g.pluck=g.partition=g.pairwise=g.onErrorResumeNext=g.observeOn=g.multicast=g.min=g.mergeWith=g.mergeScan=g.mergeMapTo=g.mergeMap=g.flatMap=void 0;g.zipWith=g.zipAll=g.zip=g.withLatestFrom=g.windowWhen=g.windowToggle=g.windowTime=g.windowCount=g.window=g.toArray=g.timestamp=g.timeoutWith=g.timeout=void 0;var h6=Sl();Object.defineProperty(g,"audit",{enumerable:!0,get:function(){return h6.audit}});var p6=lg();Object.defineProperty(g,"auditTime",{enumerable:!0,get:function(){return p6.auditTime}});var m6=dg();Object.defineProperty(g,"buffer",{enumerable:!0,get:function(){return m6.buffer}});var g6=hg();Object.defineProperty(g,"bufferCount",{enumerable:!0,get:function(){return g6.bufferCount}});var y6=pg();Object.defineProperty(g,"bufferTime",{enumerable:!0,get:function(){return y6.bufferTime}});var v6=gg();Object.defineProperty(g,"bufferToggle",{enumerable:!0,get:function(){return v6.bufferToggle}});var _6=yg();Object.defineProperty(g,"bufferWhen",{enumerable:!0,get:function(){return _6.bufferWhen}});var b6=vg();Object.defineProperty(g,"catchError",{enumerable:!0,get:function(){return b6.catchError}});var w6=wg();Object.defineProperty(g,"combineAll",{enumerable:!0,get:function(){return w6.combineAll}});var E6=Rl();Object.defineProperty(g,"combineLatestAll",{enumerable:!0,get:function(){return E6.combineLatestAll}});var S6=Eg();Object.defineProperty(g,"combineLatest",{enumerable:!0,get:function(){return S6.combineLatest}});var C6=Sg();Object.defineProperty(g,"combineLatestWith",{enumerable:!0,get:function(){return C6.combineLatestWith}});var I6=Ig();Object.defineProperty(g,"concat",{enumerable:!0,get:function(){return I6.concat}});var T6=fa();Object.defineProperty(g,"concatAll",{enumerable:!0,get:function(){return T6.concatAll}});var x6=jl();Object.defineProperty(g,"concatMap",{enumerable:!0,get:function(){return x6.concatMap}});var D6=Cg();Object.defineProperty(g,"concatMapTo",{enumerable:!0,get:function(){return D6.concatMapTo}});var O6=Tg();Object.defineProperty(g,"concatWith",{enumerable:!0,get:function(){return O6.concatWith}});var M6=ma();Object.defineProperty(g,"connect",{enumerable:!0,get:function(){return M6.connect}});var A6=xg();Object.defineProperty(g,"count",{enumerable:!0,get:function(){return A6.count}});var N6=Dg();Object.defineProperty(g,"debounce",{enumerable:!0,get:function(){return N6.debounce}});var P6=Og();Object.defineProperty(g,"debounceTime",{enumerable:!0,get:function(){return P6.debounceTime}});var R6=Fo();Object.defineProperty(g,"defaultIfEmpty",{enumerable:!0,get:function(){return R6.defaultIfEmpty}});var k6=Mg();Object.defineProperty(g,"delay",{enumerable:!0,get:function(){return k6.delay}});var L6=Ql();Object.defineProperty(g,"delayWhen",{enumerable:!0,get:function(){return L6.delayWhen}});var j6=Ag();Object.defineProperty(g,"dematerialize",{enumerable:!0,get:function(){return j6.dematerialize}});var F6=Ng();Object.defineProperty(g,"distinct",{enumerable:!0,get:function(){return F6.distinct}});var $6=nd();Object.defineProperty(g,"distinctUntilChanged",{enumerable:!0,get:function(){return $6.distinctUntilChanged}});var q6=Pg();Object.defineProperty(g,"distinctUntilKeyChanged",{enumerable:!0,get:function(){return q6.distinctUntilKeyChanged}});var B6=Rg();Object.defineProperty(g,"elementAt",{enumerable:!0,get:function(){return B6.elementAt}});var H6=kg();Object.defineProperty(g,"endWith",{enumerable:!0,get:function(){return H6.endWith}});var U6=Lg();Object.defineProperty(g,"every",{enumerable:!0,get:function(){return U6.every}});var V6=jg();Object.defineProperty(g,"exhaust",{enumerable:!0,get:function(){return V6.exhaust}});var W6=ld();Object.defineProperty(g,"exhaustAll",{enumerable:!0,get:function(){return W6.exhaustAll}});var G6=cd();Object.defineProperty(g,"exhaustMap",{enumerable:!0,get:function(){return G6.exhaustMap}});var z6=Fg();Object.defineProperty(g,"expand",{enumerable:!0,get:function(){return z6.expand}});var K6=$n();Object.defineProperty(g,"filter",{enumerable:!0,get:function(){return K6.filter}});var Y6=$g();Object.defineProperty(g,"finalize",{enumerable:!0,get:function(){return Y6.finalize}});var Z6=pd();Object.defineProperty(g,"find",{enumerable:!0,get:function(){return Z6.find}});var Q6=qg();Object.defineProperty(g,"findIndex",{enumerable:!0,get:function(){return Q6.findIndex}});var J6=Bg();Object.defineProperty(g,"first",{enumerable:!0,get:function(){return J6.first}});var X6=Hg();Object.defineProperty(g,"groupBy",{enumerable:!0,get:function(){return X6.groupBy}});var eK=zl();Object.defineProperty(g,"ignoreElements",{enumerable:!0,get:function(){return eK.ignoreElements}});var tK=Ug();Object.defineProperty(g,"isEmpty",{enumerable:!0,get:function(){return tK.isEmpty}});var nK=Vg();Object.defineProperty(g,"last",{enumerable:!0,get:function(){return nK.last}});var rK=Fn();Object.defineProperty(g,"map",{enumerable:!0,get:function(){return rK.map}});var iK=Yl();Object.defineProperty(g,"mapTo",{enumerable:!0,get:function(){return iK.mapTo}});var oK=Gg();Object.defineProperty(g,"materialize",{enumerable:!0,get:function(){return oK.materialize}});var sK=zg();Object.defineProperty(g,"max",{enumerable:!0,get:function(){return sK.max}});var aK=Qg();Object.defineProperty(g,"merge",{enumerable:!0,get:function(){return aK.merge}});var cK=Ao();Object.defineProperty(g,"mergeAll",{enumerable:!0,get:function(){return cK.mergeAll}});var uK=Kg();Object.defineProperty(g,"flatMap",{enumerable:!0,get:function(){return uK.flatMap}});var lK=_n();Object.defineProperty(g,"mergeMap",{enumerable:!0,get:function(){return lK.mergeMap}});var dK=Yg();Object.defineProperty(g,"mergeMapTo",{enumerable:!0,get:function(){return dK.mergeMapTo}});var fK=Zg();Object.defineProperty(g,"mergeScan",{enumerable:!0,get:function(){return fK.mergeScan}});var hK=Jg();Object.defineProperty(g,"mergeWith",{enumerable:!0,get:function(){return hK.mergeWith}});var pK=Xg();Object.defineProperty(g,"min",{enumerable:!0,get:function(){return pK.min}});var mK=ga();Object.defineProperty(g,"multicast",{enumerable:!0,get:function(){return mK.multicast}});var gK=Do();Object.defineProperty(g,"observeOn",{enumerable:!0,get:function(){return gK.observeOn}});var yK=ey();Object.defineProperty(g,"onErrorResumeNext",{enumerable:!0,get:function(){return yK.onErrorResumeNext}});var vK=ty();Object.defineProperty(g,"pairwise",{enumerable:!0,get:function(){return vK.pairwise}});var _K=cx();Object.defineProperty(g,"partition",{enumerable:!0,get:function(){return _K.partition}});var bK=ny();Object.defineProperty(g,"pluck",{enumerable:!0,get:function(){return bK.pluck}});var wK=ry();Object.defineProperty(g,"publish",{enumerable:!0,get:function(){return wK.publish}});var EK=iy();Object.defineProperty(g,"publishBehavior",{enumerable:!0,get:function(){return EK.publishBehavior}});var SK=oy();Object.defineProperty(g,"publishLast",{enumerable:!0,get:function(){return SK.publishLast}});var CK=sy();Object.defineProperty(g,"publishReplay",{enumerable:!0,get:function(){return CK.publishReplay}});var IK=ux();Object.defineProperty(g,"race",{enumerable:!0,get:function(){return IK.race}});var TK=Rd();Object.defineProperty(g,"raceWith",{enumerable:!0,get:function(){return TK.raceWith}});var xK=mi();Object.defineProperty(g,"reduce",{enumerable:!0,get:function(){return xK.reduce}});var DK=ay();Object.defineProperty(g,"repeat",{enumerable:!0,get:function(){return DK.repeat}});var OK=cy();Object.defineProperty(g,"repeatWhen",{enumerable:!0,get:function(){return OK.repeatWhen}});var MK=uy();Object.defineProperty(g,"retry",{enumerable:!0,get:function(){return MK.retry}});var AK=ly();Object.defineProperty(g,"retryWhen",{enumerable:!0,get:function(){return AK.retryWhen}});var NK=su();Object.defineProperty(g,"refCount",{enumerable:!0,get:function(){return NK.refCount}});var PK=qd();Object.defineProperty(g,"sample",{enumerable:!0,get:function(){return PK.sample}});var RK=dy();Object.defineProperty(g,"sampleTime",{enumerable:!0,get:function(){return RK.sampleTime}});var kK=fy();Object.defineProperty(g,"scan",{enumerable:!0,get:function(){return kK.scan}});var LK=hy();Object.defineProperty(g,"sequenceEqual",{enumerable:!0,get:function(){return LK.sequenceEqual}});var jK=Vd();Object.defineProperty(g,"share",{enumerable:!0,get:function(){return jK.share}});var FK=my();Object.defineProperty(g,"shareReplay",{enumerable:!0,get:function(){return FK.shareReplay}});var $K=gy();Object.defineProperty(g,"single",{enumerable:!0,get:function(){return $K.single}});var qK=yy();Object.defineProperty(g,"skip",{enumerable:!0,get:function(){return qK.skip}});var BK=vy();Object.defineProperty(g,"skipLast",{enumerable:!0,get:function(){return BK.skipLast}});var HK=_y();Object.defineProperty(g,"skipUntil",{enumerable:!0,get:function(){return HK.skipUntil}});var UK=by();Object.defineProperty(g,"skipWhile",{enumerable:!0,get:function(){return UK.skipWhile}});var VK=wy();Object.defineProperty(g,"startWith",{enumerable:!0,get:function(){return VK.startWith}});var WK=Oo();Object.defineProperty(g,"subscribeOn",{enumerable:!0,get:function(){return WK.subscribeOn}});var GK=Ey();Object.defineProperty(g,"switchAll",{enumerable:!0,get:function(){return GK.switchAll}});var zK=Uo();Object.defineProperty(g,"switchMap",{enumerable:!0,get:function(){return zK.switchMap}});var KK=Sy();Object.defineProperty(g,"switchMapTo",{enumerable:!0,get:function(){return KK.switchMapTo}});var YK=Cy();Object.defineProperty(g,"switchScan",{enumerable:!0,get:function(){return YK.switchScan}});var ZK=$o();Object.defineProperty(g,"take",{enumerable:!0,get:function(){return ZK.take}});var QK=_d();Object.defineProperty(g,"takeLast",{enumerable:!0,get:function(){return QK.takeLast}});var JK=Iy();Object.defineProperty(g,"takeUntil",{enumerable:!0,get:function(){return JK.takeUntil}});var XK=Ty();Object.defineProperty(g,"takeWhile",{enumerable:!0,get:function(){return XK.takeWhile}});var e5=xy();Object.defineProperty(g,"tap",{enumerable:!0,get:function(){return e5.tap}});var t5=af();Object.defineProperty(g,"throttle",{enumerable:!0,get:function(){return t5.throttle}});var n5=Dy();Object.defineProperty(g,"throttleTime",{enumerable:!0,get:function(){return n5.throttleTime}});var r5=qo();Object.defineProperty(g,"throwIfEmpty",{enumerable:!0,get:function(){return r5.throwIfEmpty}});var i5=Oy();Object.defineProperty(g,"timeInterval",{enumerable:!0,get:function(){return i5.timeInterval}});var o5=da();Object.defineProperty(g,"timeout",{enumerable:!0,get:function(){return o5.timeout}});var s5=My();Object.defineProperty(g,"timeoutWith",{enumerable:!0,get:function(){return s5.timeoutWith}});var a5=Ay();Object.defineProperty(g,"timestamp",{enumerable:!0,get:function(){return a5.timestamp}});var c5=Al();Object.defineProperty(g,"toArray",{enumerable:!0,get:function(){return c5.toArray}});var u5=Ny();Object.defineProperty(g,"window",{enumerable:!0,get:function(){return u5.window}});var l5=Py();Object.defineProperty(g,"windowCount",{enumerable:!0,get:function(){return l5.windowCount}});var d5=Ry();Object.defineProperty(g,"windowTime",{enumerable:!0,get:function(){return d5.windowTime}});var f5=Ly();Object.defineProperty(g,"windowToggle",{enumerable:!0,get:function(){return f5.windowToggle}});var h5=jy();Object.defineProperty(g,"windowWhen",{enumerable:!0,get:function(){return h5.windowWhen}});var p5=Fy();Object.defineProperty(g,"withLatestFrom",{enumerable:!0,get:function(){return p5.withLatestFrom}});var m5=qy();Object.defineProperty(g,"zip",{enumerable:!0,get:function(){return m5.zip}});var g5=$y();Object.defineProperty(g,"zipAll",{enumerable:!0,get:function(){return g5.zipAll}});var y5=By();Object.defineProperty(g,"zipWith",{enumerable:!0,get:function(){return y5.zipWith}})});var nS;(function(t){(function(n){var e=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:Function("return this;")(),r=i(t);typeof e.Reflect>"u"?e.Reflect=t:r=i(e.Reflect,r),n(r);function i(o,s){return function(a,c){typeof o[a]!="function"&&Object.defineProperty(o,a,{configurable:!0,writable:!0,value:c}),s&&s(a,c)}}})(function(n){var e=Object.prototype.hasOwnProperty,r=typeof Symbol=="function",i=r&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",o=r&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",s=typeof Object.create=="function",a={__proto__:[]}instanceof Array,c=!s&&!a,u={create:s?function(){return gm(Object.create(null))}:a?function(){return gm({__proto__:null})}:function(){return gm({})},has:c?function(_,S){return e.call(_,S)}:function(_,S){return S in _},get:c?function(_,S){return e.call(_,S)?_[S]:void 0}:function(_,S){return _[S]}},l=Object.getPrototypeOf(Function),d=typeof process=="object"&&process.env&&process.env.REFLECT_METADATA_USE_MAP_POLYFILL==="true",f=!d&&typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:OR(),p=!d&&typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:MR(),m=!d&&typeof WeakMap=="function"?WeakMap:AR(),y=new m;function b(_,S,M,k){if(oe(M)){if(!cr(_))throw new TypeError;if(!XE(S))throw new TypeError;return rt(_,S)}else{if(!cr(_))throw new TypeError;if(!Le(S))throw new TypeError;if(!Le(k)&&!oe(k)&&!$e(k))throw new TypeError;return $e(k)&&(k=void 0),M=it(M),ee(_,S,M,k)}}n("decorate",b);function E(_,S){function M(k,Y){if(!Le(k))throw new TypeError;if(!oe(Y)&&!CR(Y))throw new TypeError;B(_,S,k,Y)}return M}n("metadata",E);function D(_,S,M,k){if(!Le(M))throw new TypeError;return oe(k)||(k=it(k)),B(_,S,M,k)}n("defineMetadata",D);function T(_,S,M){if(!Le(S))throw new TypeError;return oe(M)||(M=it(M)),x(_,S,M)}n("hasMetadata",T);function K(_,S,M){if(!Le(S))throw new TypeError;return oe(M)||(M=it(M)),C(_,S,M)}n("hasOwnMetadata",K);function H(_,S,M){if(!Le(S))throw new TypeError;return oe(M)||(M=it(M)),P(_,S,M)}n("getMetadata",H);function re(_,S,M){if(!Le(S))throw new TypeError;return oe(M)||(M=it(M)),O(_,S,M)}n("getOwnMetadata",re);function Ee(_,S){if(!Le(_))throw new TypeError;return oe(S)||(S=it(S)),G(_,S)}n("getMetadataKeys",Ee);function pe(_,S){if(!Le(_))throw new TypeError;return oe(S)||(S=it(S)),ie(_,S)}n("getOwnMetadataKeys",pe);function z(_,S,M){if(!Le(S))throw new TypeError;oe(M)||(M=it(M));var k=$(S,M,!1);if(oe(k)||!k.delete(_))return!1;if(k.size>0)return!0;var Y=y.get(S);return Y.delete(M),Y.size>0||y.delete(S),!0}n("deleteMetadata",z);function rt(_,S){for(var M=_.length-1;M>=0;--M){var k=_[M],Y=k(S);if(!oe(Y)&&!$e(Y)){if(!XE(Y))throw new TypeError;S=Y}}return S}function ee(_,S,M,k){for(var Y=_.length-1;Y>=0;--Y){var at=_[Y],ue=at(S,M,k);if(!oe(ue)&&!$e(ue)){if(!Le(ue))throw new TypeError;k=ue}}return k}function $(_,S,M){var k=y.get(_);if(oe(k)){if(!M)return;k=new f,y.set(_,k)}var Y=k.get(S);if(oe(Y)){if(!M)return;Y=new f,k.set(S,Y)}return Y}function x(_,S,M){var k=C(_,S,M);if(k)return!0;var Y=mm(S);return $e(Y)?!1:x(_,Y,M)}function C(_,S,M){var k=$(S,M,!1);return oe(k)?!1:Pn(k.has(_))}function P(_,S,M){var k=C(_,S,M);if(k)return O(_,S,M);var Y=mm(S);if(!$e(Y))return P(_,Y,M)}function O(_,S,M){var k=$(S,M,!1);if(!oe(k))return k.get(_)}function B(_,S,M,k){var Y=$(M,k,!0);Y.set(_,S)}function G(_,S){var M=ie(_,S),k=mm(_);if(k===null)return M;var Y=G(k,S);if(Y.length<=0)return M;if(M.length<=0)return Y;for(var at=new p,ue=[],me=0,X=M;me<X.length;me++){var xe=X[me],De=at.has(xe);De||(at.add(xe),ue.push(xe))}for(var ur=0,tS=Y;ur<tS.length;ur++){var xe=tS[ur],De=at.has(xe);De||(at.add(xe),ue.push(xe))}return ue}function ie(_,S){var M=[],k=$(_,S,!1);if(oe(k))return M;for(var Y=k.keys(),at=IR(Y),ue=0;;){var me=xR(at);if(!me)return M.length=ue,M;var X=TR(me);try{M[ue]=X}catch(xe){try{DR(at)}finally{throw xe}}ue++}}function Te(_){if(_===null)return 1;switch(typeof _){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return _===null?1:6;default:return 6}}function oe(_){return _===void 0}function $e(_){return _===null}function st(_){return typeof _=="symbol"}function Le(_){return typeof _=="object"?_!==null:typeof _=="function"}function hn(_,S){switch(Te(_)){case 0:return _;case 1:return _;case 2:return _;case 3:return _;case 4:return _;case 5:return _}var M=S===3?"string":S===5?"number":"default",k=eS(_,i);if(k!==void 0){var Y=k.call(_,M);if(Le(Y))throw new TypeError;return Y}return ii(_,M==="default"?"number":M)}function ii(_,S){if(S==="string"){var M=_.toString;if(tn(M)){var k=M.call(_);if(!Le(k))return k}var Y=_.valueOf;if(tn(Y)){var k=Y.call(_);if(!Le(k))return k}}else{var Y=_.valueOf;if(tn(Y)){var k=Y.call(_);if(!Le(k))return k}var at=_.toString;if(tn(at)){var k=at.call(_);if(!Le(k))return k}}throw new TypeError}function Pn(_){return!!_}function mt(_){return""+_}function it(_){var S=hn(_,3);return st(S)?S:mt(S)}function cr(_){return Array.isArray?Array.isArray(_):_ instanceof Object?_ instanceof Array:Object.prototype.toString.call(_)==="[object Array]"}function tn(_){return typeof _=="function"}function XE(_){return typeof _=="function"}function CR(_){switch(Te(_)){case 3:return!0;case 4:return!0;default:return!1}}function eS(_,S){var M=_[S];if(M!=null){if(!tn(M))throw new TypeError;return M}}function IR(_){var S=eS(_,o);if(!tn(S))throw new TypeError;var M=S.call(_);if(!Le(M))throw new TypeError;return M}function TR(_){return _.value}function xR(_){var S=_.next();return S.done?!1:S}function DR(_){var S=_.return;S&&S.call(_)}function mm(_){var S=Object.getPrototypeOf(_);if(typeof _!="function"||_===l||S!==l)return S;var M=_.prototype,k=M&&Object.getPrototypeOf(M);if(k==null||k===Object.prototype)return S;var Y=k.constructor;return typeof Y!="function"||Y===_?S:Y}function OR(){var _={},S=[],M=(function(){function ue(me,X,xe){this._index=0,this._keys=me,this._values=X,this._selector=xe}return ue.prototype["@@iterator"]=function(){return this},ue.prototype[o]=function(){return this},ue.prototype.next=function(){var me=this._index;if(me>=0&&me<this._keys.length){var X=this._selector(this._keys[me],this._values[me]);return me+1>=this._keys.length?(this._index=-1,this._keys=S,this._values=S):this._index++,{value:X,done:!1}}return{value:void 0,done:!0}},ue.prototype.throw=function(me){throw this._index>=0&&(this._index=-1,this._keys=S,this._values=S),me},ue.prototype.return=function(me){return this._index>=0&&(this._index=-1,this._keys=S,this._values=S),{value:me,done:!0}},ue})();return(function(){function ue(){this._keys=[],this._values=[],this._cacheKey=_,this._cacheIndex=-2}return Object.defineProperty(ue.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),ue.prototype.has=function(me){return this._find(me,!1)>=0},ue.prototype.get=function(me){var X=this._find(me,!1);return X>=0?this._values[X]:void 0},ue.prototype.set=function(me,X){var xe=this._find(me,!0);return this._values[xe]=X,this},ue.prototype.delete=function(me){var X=this._find(me,!1);if(X>=0){for(var xe=this._keys.length,De=X+1;De<xe;De++)this._keys[De-1]=this._keys[De],this._values[De-1]=this._values[De];return this._keys.length--,this._values.length--,me===this._cacheKey&&(this._cacheKey=_,this._cacheIndex=-2),!0}return!1},ue.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=_,this._cacheIndex=-2},ue.prototype.keys=function(){return new M(this._keys,this._values,k)},ue.prototype.values=function(){return new M(this._keys,this._values,Y)},ue.prototype.entries=function(){return new M(this._keys,this._values,at)},ue.prototype["@@iterator"]=function(){return this.entries()},ue.prototype[o]=function(){return this.entries()},ue.prototype._find=function(me,X){return this._cacheKey!==me&&(this._cacheIndex=this._keys.indexOf(this._cacheKey=me)),this._cacheIndex<0&&X&&(this._cacheIndex=this._keys.length,this._keys.push(me),this._values.push(void 0)),this._cacheIndex},ue})();function k(ue,me){return ue}function Y(ue,me){return me}function at(ue,me){return[ue,me]}}function MR(){return(function(){function _(){this._map=new f}return Object.defineProperty(_.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),_.prototype.has=function(S){return this._map.has(S)},_.prototype.add=function(S){return this._map.set(S,S),this},_.prototype.delete=function(S){return this._map.delete(S)},_.prototype.clear=function(){this._map.clear()},_.prototype.keys=function(){return this._map.keys()},_.prototype.values=function(){return this._map.values()},_.prototype.entries=function(){return this._map.entries()},_.prototype["@@iterator"]=function(){return this.keys()},_.prototype[o]=function(){return this.keys()},_})()}function AR(){var _=16,S=u.create(),M=k();return(function(){function X(){this._key=k()}return X.prototype.has=function(xe){var De=Y(xe,!1);return De!==void 0?u.has(De,this._key):!1},X.prototype.get=function(xe){var De=Y(xe,!1);return De!==void 0?u.get(De,this._key):void 0},X.prototype.set=function(xe,De){var ur=Y(xe,!0);return ur[this._key]=De,this},X.prototype.delete=function(xe){var De=Y(xe,!1);return De!==void 0?delete De[this._key]:!1},X.prototype.clear=function(){this._key=k()},X})();function k(){var X;do X="@@WeakMap@@"+me();while(u.has(S,X));return S[X]=!0,X}function Y(X,xe){if(!e.call(X,M)){if(!xe)return;Object.defineProperty(X,M,{value:u.create()})}return X[M]}function at(X,xe){for(var De=0;De<xe;++De)X[De]=Math.random()*255|0;return X}function ue(X){return typeof Uint8Array=="function"?typeof crypto<"u"?crypto.getRandomValues(new Uint8Array(X)):typeof msCrypto<"u"?msCrypto.getRandomValues(new Uint8Array(X)):at(new Uint8Array(X),X):at(new Array(X),X)}function me(){var X=ue(_);X[6]=X[6]&79|64,X[8]=X[8]&191|128;for(var xe="",De=0;De<_;++De){var ur=X[De];(De===4||De===6||De===8)&&(xe+="-"),ur<16&&(xe+="0"),xe+=ur.toString(16).toLowerCase()}return xe}}function gm(_){return _.__=void 0,delete _.__,_}})})(nS||(nS={}));var SR=U(Q(),1);import{createServer as Zz}from"http";import{Http2ServerRequest as Qz}from"http2";import{Http2ServerRequest as Hy}from"http2";import{Readable as nT}from"stream";import u8 from"crypto";var gi=class extends Error{constructor(t,n){super(t,n),this.name="RequestError"}},Jz=t=>t instanceof gi?t:new gi(t.message,{cause:t}),Xz=global.Request,ya=class extends Xz{constructor(t,n){typeof t=="object"&&Yo in t&&(t=t[Yo]()),typeof n?.body?.getReader<"u"&&(n.duplex??="half"),super(t,n)}},e8=t=>{let n=[],e=t.rawHeaders;for(let r=0;r<e.length;r+=2){let{[r]:i,[r+1]:o}=e;i.charCodeAt(0)!==58&&n.push([i,o])}return new Headers(n)},iT=Symbol("wrapBodyStream"),t8=(t,n,e,r,i)=>{let o={method:t,headers:e,signal:i.signal};if(t==="TRACE"){o.method="GET";let s=new ya(n,o);return Object.defineProperty(s,"method",{get(){return"TRACE"}}),s}if(!(t==="GET"||t==="HEAD"))if("rawBody"in r&&r.rawBody instanceof Buffer)o.body=new ReadableStream({start(s){s.enqueue(r.rawBody),s.close()}});else if(r[iT]){let s;o.body=new ReadableStream({async pull(a){try{s||=nT.toWeb(r).getReader();let{done:c,value:u}=await s.read();c?a.close():a.enqueue(u)}catch(c){a.error(c)}}})}else o.body=nT.toWeb(r);return new ya(n,o)},Yo=Symbol("getRequestCache"),n8=Symbol("requestCache"),mf=Symbol("incomingKey"),gf=Symbol("urlKey"),r8=Symbol("headersKey"),Ko=Symbol("abortControllerKey"),i8=Symbol("getAbortController"),yf={get method(){return this[mf].method||"GET"},get url(){return this[gf]},get headers(){return this[r8]||=e8(this[mf])},[i8](){return this[Yo](),this[Ko]},[Yo](){return this[Ko]||=new AbortController,this[n8]||=t8(this.method,this[gf],this.headers,this[mf],this[Ko])}};["body","bodyUsed","cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","signal","keepalive"].forEach(t=>{Object.defineProperty(yf,t,{get(){return this[Yo]()[t]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(t=>{Object.defineProperty(yf,t,{value:function(){return this[Yo]()[t]()}})});Object.setPrototypeOf(yf,ya.prototype);var o8=(t,n)=>{let e=Object.create(yf);e[mf]=t;let r=t.url||"";if(r[0]!=="/"&&(r.startsWith("http://")||r.startsWith("https://"))){if(t instanceof Hy)throw new gi("Absolute URL for :path is not allowed in HTTP/2");try{let a=new URL(r);e[gf]=a.href}catch(a){throw new gi("Invalid absolute URL",{cause:a})}return e}let i=(t instanceof Hy?t.authority:t.headers.host)||n;if(!i)throw new gi("Missing host header");let o;if(t instanceof Hy){if(o=t.scheme,!(o==="http"||o==="https"))throw new gi("Unsupported scheme")}else o=t.socket&&t.socket.encrypted?"https":"http";let s=new URL(`${o}://${i}${r}`);if(s.hostname.length!==i.length&&s.hostname!==i.replace(/:\d+$/,""))throw new gi("Invalid host header");return e[gf]=s.href,e},rT=Symbol("responseCache"),zo=Symbol("getResponseCache"),yi=Symbol("cache"),Vy=global.Response,va=class oT{#t;#e;[zo](){return delete this[yi],this[rT]||=new Vy(this.#t,this.#e)}constructor(n,e){let r;if(this.#t=n,e instanceof oT){let i=e[rT];if(i){this.#e=i,this[zo]();return}else this.#e=e.#e,r=new Headers(e.#e.headers)}else this.#e=e;(typeof n=="string"||typeof n?.getReader<"u"||n instanceof Blob||n instanceof Uint8Array)&&(r||=e?.headers||{"content-type":"text/plain; charset=UTF-8"},this[yi]=[e?.status||200,n,r])}get headers(){let n=this[yi];return n?(n[2]instanceof Headers||(n[2]=new Headers(n[2])),n[2]):this[zo]().headers}get status(){return this[yi]?.[0]??this[zo]().status}get ok(){let n=this.status;return n>=200&&n<300}};["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(t=>{Object.defineProperty(va.prototype,t,{get(){return this[zo]()[t]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(t=>{Object.defineProperty(va.prototype,t,{value:function(){return this[zo]()[t]()}})});Object.setPrototypeOf(va,Vy);Object.setPrototypeOf(va.prototype,Vy.prototype);async function s8(t){return Promise.race([t,Promise.resolve().then(()=>Promise.resolve(void 0))])}function sT(t,n,e){let r=a=>{t.cancel(a).catch(()=>{})};return n.on("close",r),n.on("error",r),(e??t.read()).then(s,i),t.closed.finally(()=>{n.off("close",r),n.off("error",r)});function i(a){a&&n.destroy(a)}function o(){t.read().then(s,i)}function s({done:a,value:c}){try{if(a)n.end();else if(!n.write(c))n.once("drain",o);else return t.read().then(s,i)}catch(u){i(u)}}}function a8(t,n){if(t.locked)throw new TypeError("ReadableStream is locked.");return n.destroyed?void 0:sT(t.getReader(),n)}var aT=t=>{let n={};t instanceof Headers||(t=new Headers(t??void 0));let e=[];for(let[r,i]of t)r==="set-cookie"?e.push(i):n[r]=i;return e.length>0&&(n["set-cookie"]=e),n["content-type"]??="text/plain; charset=UTF-8",n},c8="x-hono-already-sent",l8=global.fetch;typeof global.crypto>"u"&&(global.crypto=u8);global.fetch=(t,n)=>(n={compress:!1,...n},l8(t,n));var Wy=Symbol("outgoingEnded"),d8=()=>new Response(null,{status:400}),cT=t=>new Response(null,{status:t instanceof Error&&(t.name==="TimeoutError"||t.constructor.name==="TimeoutError")?504:500}),Uy=(t,n)=>{let e=t instanceof Error?t:new Error("unknown error",{cause:t});e.code==="ERR_STREAM_PREMATURE_CLOSE"?console.info("The user aborted a request."):(console.error(t),n.headersSent||n.writeHead(500,{"Content-Type":"text/plain"}),n.end(`Error: ${e.message}`),n.destroy(e))},uT=t=>{"flushHeaders"in t&&t.writable&&t.flushHeaders()},lT=async(t,n)=>{let[e,r,i]=t[yi];i instanceof Headers&&(i=aT(i)),typeof r=="string"?i["Content-Length"]=Buffer.byteLength(r):r instanceof Uint8Array?i["Content-Length"]=r.byteLength:r instanceof Blob&&(i["Content-Length"]=r.size),n.writeHead(e,i),typeof r=="string"||r instanceof Uint8Array?n.end(r):r instanceof Blob?n.end(new Uint8Array(await r.arrayBuffer())):(uT(n),await a8(r,n)?.catch(o=>Uy(o,n))),n[Wy]?.()},f8=t=>typeof t.then=="function",h8=async(t,n,e={})=>{if(f8(t))if(e.errorHandler)try{t=await t}catch(i){let o=await e.errorHandler(i);if(!o)return;t=o}else t=await t.catch(cT);if(yi in t)return lT(t,n);let r=aT(t.headers);if(t.body){let i=t.body.getReader(),o=[],s=!1,a;if(r["transfer-encoding"]!=="chunked"){let c=2;for(let u=0;u<c;u++){a||=i.read();let l=await s8(a).catch(d=>{console.error(d),s=!0});if(!l){if(u===1){await new Promise(d=>setTimeout(d)),c=3;continue}break}if(a=void 0,l.value&&o.push(l.value),l.done){s=!0;break}}s&&!("content-length"in r)&&(r["content-length"]=o.reduce((u,l)=>u+l.length,0))}n.writeHead(t.status,r),o.forEach(c=>{n.write(c)}),s?n.end():(o.length===0&&uT(n),await sT(i,n,a))}else r[c8]||(n.writeHead(t.status,r),n.end());n[Wy]?.()},p8=(t,n={})=>{let e=n.autoCleanupIncoming??!0;return n.overrideGlobalObjects!==!1&&global.Request!==ya&&(Object.defineProperty(global,"Request",{value:ya}),Object.defineProperty(global,"Response",{value:va})),async(r,i)=>{let o,s;try{s=o8(r,n.hostname);let a=!e||r.method==="GET"||r.method==="HEAD";if(a||(r[iT]=!0,r.on("end",()=>{a=!0}),r instanceof Qz&&(i[Wy]=()=>{a||setTimeout(()=>{a||setTimeout(()=>{r.destroy(),i.destroy()})})})),i.on("close",()=>{s[Ko]&&(r.errored?s[Ko].abort(r.errored.toString()):i.writableFinished||s[Ko].abort("Client connection prematurely closed.")),a||setTimeout(()=>{a||setTimeout(()=>{r.destroy()})})}),o=t(s,{incoming:r,outgoing:i}),yi in o)return lT(o,i)}catch(a){if(o)return Uy(a,i);if(n.errorHandler){if(o=await n.errorHandler(s?a:Jz(a)),!o)return}else s?o=cT(a):o=d8()}try{return await h8(o,i,n)}catch(a){return Uy(a,i)}}},m8=t=>{let n=t.fetch,e=p8(n,{hostname:t.hostname,overrideGlobalObjects:t.overrideGlobalObjects,autoCleanupIncoming:t.autoCleanupIncoming});return(t.createServer||Zz)(t.serverOptions||{},e)},dT=(t,n)=>{let e=m8(t);return e.listen(t?.port??3e3,t.hostname,()=>{let r=e.address();n&&n(r)}),e};var g8=U(Ky());var y8=U(Ky());var gt=null,vf=!1,Jy=1,v8=null,zt=Symbol("SIGNAL");function ge(t){let n=gt;return gt=t,n}function bf(){return gt}var Zo={version:0,lastCleanEpoch:0,dirty:!1,producers:void 0,producersTail:void 0,consumers:void 0,consumersTail:void 0,recomputing:!1,consumerAllowSignalWrites:!1,consumerIsAlwaysLive:!1,kind:"unknown",producerMustRecompute:()=>!1,producerRecomputeValue:()=>{},consumerMarkedDirty:()=>{},consumerOnSignalRead:()=>{}};function Xy(t){if(vf)throw new Error("");if(gt===null)return;gt.consumerOnSignalRead(t);let n=gt.producersTail;if(n!==void 0&&n.producer===t)return;let e,r=gt.recomputing;if(r&&(e=n!==void 0?n.nextProducer:gt.producers,e!==void 0&&e.producer===t)){gt.producersTail=e,e.lastReadVersion=t.version;return}let i=t.consumersTail;if(i!==void 0&&i.consumer===gt&&(!r||b8(i,gt)))return;let o=Jo(gt),s={producer:t,consumer:gt,nextProducer:e,prevConsumer:i,lastReadVersion:t.version,nextConsumer:void 0};gt.producersTail=s,n!==void 0?n.nextProducer=s:gt.producers=s,o&&mT(t,s)}function fT(){Jy++}function ev(t){if(!(Jo(t)&&!t.dirty)&&!(!t.dirty&&t.lastCleanEpoch===Jy)){if(!t.producerMustRecompute(t)&&!Ef(t)){Qy(t);return}t.producerRecomputeValue(t),Qy(t)}}function tv(t){if(t.consumers===void 0)return;let n=vf;vf=!0;try{for(let e=t.consumers;e!==void 0;e=e.nextConsumer){let r=e.consumer;r.dirty||_8(r)}}finally{vf=n}}function nv(){return gt?.consumerAllowSignalWrites!==!1}function _8(t){t.dirty=!0,tv(t),t.consumerMarkedDirty?.(t)}function Qy(t){t.dirty=!1,t.lastCleanEpoch=Jy}function _a(t){return t&&hT(t),ge(t)}function hT(t){t.producersTail=void 0,t.recomputing=!0}function wf(t,n){ge(n),t&&pT(t)}function pT(t){t.recomputing=!1;let n=t.producersTail,e=n!==void 0?n.nextProducer:t.producers;if(e!==void 0){if(Jo(t))do e=rv(e);while(e!==void 0);n!==void 0?n.nextProducer=void 0:t.producers=void 0}}function Ef(t){for(let n=t.producers;n!==void 0;n=n.nextProducer){let e=n.producer,r=n.lastReadVersion;if(r!==e.version||(ev(e),r!==e.version))return!0}return!1}function Qo(t){if(Jo(t)){let n=t.producers;for(;n!==void 0;)n=rv(n)}t.producers=void 0,t.producersTail=void 0,t.consumers=void 0,t.consumersTail=void 0}function mT(t,n){let e=t.consumersTail,r=Jo(t);if(e!==void 0?(n.nextConsumer=e.nextConsumer,e.nextConsumer=n):(n.nextConsumer=void 0,t.consumers=n),n.prevConsumer=e,t.consumersTail=n,!r)for(let i=t.producers;i!==void 0;i=i.nextProducer)mT(i.producer,i)}function rv(t){let n=t.producer,e=t.nextProducer,r=t.nextConsumer,i=t.prevConsumer;if(t.nextConsumer=void 0,t.prevConsumer=void 0,r!==void 0?r.prevConsumer=i:n.consumersTail=i,i!==void 0)i.nextConsumer=r;else if(n.consumers=r,!Jo(n)){let o=n.producers;for(;o!==void 0;)o=rv(o)}return e}function Jo(t){return t.consumerIsAlwaysLive||t.consumers!==void 0}function iv(t){v8?.(t)}function b8(t,n){let e=n.producersTail;if(e!==void 0){let r=n.producers;do{if(r===t)return!0;if(r===e)break;r=r.nextProducer}while(r!==void 0)}return!1}function ov(t,n){return Object.is(t,n)}function Sf(t,n){let e=Object.create(w8);e.computation=t,n!==void 0&&(e.equal=n);let r=()=>{if(ev(e),Xy(e),e.value===_f)throw e.error;return e.value};return r[zt]=e,iv(e),r}var Yy=Symbol("UNSET"),Zy=Symbol("COMPUTING"),_f=Symbol("ERRORED"),w8={...Zo,value:Yy,dirty:!0,error:null,equal:ov,kind:"computed",producerMustRecompute(t){return t.value===Yy||t.value===Zy},producerRecomputeValue(t){if(t.value===Zy)throw new Error("");let n=t.value;t.value=Zy;let e=_a(t),r,i=!1;try{r=t.computation(),ge(null),i=n!==Yy&&n!==_f&&r!==_f&&t.equal(n,r)}catch(o){r=_f,t.error=o}finally{wf(t,e)}if(i){t.value=n;return}t.value=r,t.version++}};function E8(){throw new Error}var S8=E8;function gT(t){S8(t)}var C8=null;function sv(t,n){let e=Object.create(_T);e.value=t,n!==void 0&&(e.equal=n);let r=()=>yT(e);return r[zt]=e,iv(e),[r,s=>av(e,s),s=>vT(e,s)]}function yT(t){return Xy(t),t.value}function av(t,n){nv()||gT(t),t.equal(t.value,n)||(t.value=n,I8(t))}function vT(t,n){nv()||gT(t),av(t,n(t.value))}var _T={...Zo,equal:ov,value:void 0,kind:"signal"};function I8(t){t.version++,fT(),tv(t),C8?.(t)}function cv(t){let n=ge(null);try{return t()}finally{ge(n)}}var uv={...Zo,consumerIsAlwaysLive:!0,consumerAllowSignalWrites:!0,dirty:!0,kind:"effect"};function lv(t){if(t.dirty=!1,t.version>0&&!Ef(t))return;t.version++;let n=_a(t);try{t.cleanup(),t.fn()}finally{wf(t,n)}}var Rr=U(Q(),1);var dv;function Cf(){return dv}function wn(t){let n=dv;return dv=t,n}var bT=Symbol("NotFound");function Xo(t){return t===bT||t?.name==="\u0275NotFound"}var Re=class extends Error{code;constructor(n,e){super(Cv(n,e)),this.code=n}};function x8(t){return`NG0${Math.abs(t)}`}function Cv(t,n){return`${x8(t)}${n?": "+n:""}`}function qe(t){for(let n in t)if(t[n]===qe)return n;throw Error("")}function _i(t){if(typeof t=="string")return t;if(Array.isArray(t))return`[${t.map(_i).join(", ")}]`;if(t==null)return""+t;let n=t.overriddenName||t.name;if(n)return`${n}`;let e=t.toString();if(e==null)return""+e;let r=e.indexOf(`
7
+ `);return r>=0?e.slice(0,r):e}function Iv(t,n){return t?n?`${t} ${n}`:t:n||""}var D8=qe({__forward_ref__:qe});function Nf(t){return t.__forward_ref__=Nf,t.toString=function(){return _i(this())},t}function xt(t){return Tv(t)?t():t}function Tv(t){return typeof t=="function"&&t.hasOwnProperty(D8)&&t.__forward_ref__===Nf}function N(t){return{token:t.token,providedIn:t.providedIn||null,factory:t.factory,value:void 0}}function Pf(t){return O8(t,Rf)}function O8(t,n){return t.hasOwnProperty(n)&&t[n]||null}function M8(t){let n=t?.[Rf]??null;return n||null}function hv(t){return t&&t.hasOwnProperty(Tf)?t[Tf]:null}var Rf=qe({\u0275prov:qe}),Tf=qe({\u0275inj:qe}),_e=class{_desc;ngMetadataName="InjectionToken";\u0275prov;constructor(n,e){this._desc=n,this.\u0275prov=void 0,typeof e=="number"?this.__NG_ELEMENT_ID__=e:e!==void 0&&(this.\u0275prov=N({token:this,providedIn:e.providedIn||"root",factory:e.factory}))}get multi(){return this}toString(){return`InjectionToken ${this._desc}`}};function xv(t){return t&&!!t.\u0275providers}var Dv=qe({\u0275cmp:qe}),Ov=qe({\u0275dir:qe});var wa=qe({\u0275fac:qe}),Ii=qe({__NG_ELEMENT_ID__:qe}),wT=qe({__NG_ENV_ID__:qe});function kf(t){return TT(t,"@Component"),t[Dv]||null}function IT(t){return TT(t,"@Directive"),t[Ov]||null}function TT(t,n){if(t==null)throw new Re(-919,!1)}var xT=qe({ngErrorCode:qe}),A8=qe({ngErrorMessage:qe}),N8=qe({ngTokenPath:qe});function Mv(t,n){return DT("",-200,n)}function Lf(t,n){throw new Re(-201,!1)}function DT(t,n,e){let r=new Re(n,t);return r[xT]=n,r[A8]=t,e&&(r[N8]=e),r}function P8(t){return t[xT]}var pv;function OT(){return pv}function jt(t){let n=pv;return pv=t,n}function Av(t,n,e){let r=Pf(t);if(r&&r.providedIn=="root")return r.value===void 0?r.value=r.factory():r.value;if(e&8)return null;if(n!==void 0)return n;Lf(t,"")}var R8={},vi=R8,k8="__NG_DI_FLAG__",mv=class{injector;constructor(n){this.injector=n}retrieve(n,e){let r=bi(e)||0;try{return this.injector.get(n,r&8?null:vi,r)}catch(i){if(Xo(i))return i;throw i}}};function L8(t,n=0){let e=Cf();if(e===void 0)throw new Re(-203,!1);if(e===null)return Av(t,void 0,n);{let r=j8(n),i=e.retrieve(t,r);if(Xo(i)){if(r.optional)return null;throw i}return i}}function Hn(t,n=0){return(OT()||L8)(xt(t),n)}function w(t,n){return Hn(t,bi(n))}function bi(t){return typeof t>"u"||typeof t=="number"?t:0|(t.optional&&8)|(t.host&&1)|(t.self&&2)|(t.skipSelf&&4)}function j8(t){return{optional:!!(t&8),host:!!(t&1),self:!!(t&2),skipSelf:!!(t&4)}}function gv(t){let n=[];for(let e=0;e<t.length;e++){let r=xt(t[e]);if(Array.isArray(r)){if(r.length===0)throw new Re(900,!1);let i,o=0;for(let s=0;s<r.length;s++){let a=r[s],c=F8(a);typeof c=="number"?c===-1?i=a.token:o|=c:i=a}n.push(Hn(i,o))}else n.push(Hn(r))}return n}function F8(t){return t[k8]}function wi(t,n){let e=t.hasOwnProperty(wa);return e?t[wa]:null}function jf(t,n){t.forEach(e=>Array.isArray(e)?jf(e,n):n(e))}function Nv(t,n){return n>=t.length-1?t.pop():t.splice(n,1)[0]}var Ff={},Ea=[],$f=new _e(""),Pv=new _e("",-1),Rv=new _e(""),Sa=class{get(n,e=vi){if(e===vi){let i=DT("",-201);throw i.name="\u0275NotFound",i}return e}};function ts(t){return{\u0275providers:t}}function MT(...t){return{\u0275providers:AT(!0,t),\u0275fromNgModule:!0}}function AT(t,...n){let e=[],r=new Set,i,o=s=>{e.push(s)};return jf(n,s=>{let a=s;xf(a,o,[],r)&&(i||=[],i.push(a))}),i!==void 0&&NT(i,o),e}function NT(t,n){for(let e=0;e<t.length;e++){let{ngModule:r,providers:i}=t[e];kv(i,o=>{n(o,r)})}}function xf(t,n,e,r){if(t=xt(t),!t)return!1;let i=null,o=hv(t),s=!o&&kf(t);if(!o&&!s){let c=t.ngModule;if(o=hv(c),o)i=c;else return!1}else{if(s&&!s.standalone)return!1;i=t}let a=r.has(i);if(s){if(a)return!1;if(r.add(i),s.dependencies){let c=typeof s.dependencies=="function"?s.dependencies():s.dependencies;for(let u of c)xf(u,n,e,r)}}else if(o){if(o.imports!=null&&!a){r.add(i);let u;jf(o.imports,l=>{xf(l,n,e,r)&&(u||=[],u.push(l))}),u!==void 0&&NT(u,n)}if(!a){let u=wi(i)||(()=>new i);n({provide:i,useFactory:u,deps:Ea},i),n({provide:Rv,useValue:i,multi:!0},i),n({provide:$f,useValue:()=>Hn(i),multi:!0},i)}let c=o.providers;if(c!=null&&!a){let u=t;kv(c,l=>{n(l,u)})}}else return!1;return i!==t&&t.providers!==void 0}function kv(t,n){for(let e of t)xv(e)&&(e=e.\u0275providers),Array.isArray(e)?kv(e,n):n(e)}var $8=qe({provide:String,useValue:qe});function PT(t){return t!==null&&typeof t=="object"&&$8 in t}function q8(t){return!!(t&&t.useExisting)}function B8(t){return!!(t&&t.useFactory)}function Df(t){return typeof t=="function"}var qf=new _e(""),If={},ET={},fv;function Da(){return fv===void 0&&(fv=new Sa),fv}var En=class{},Ei=class extends En{parent;source;scopes;records=new Map;_ngOnDestroyHooks=new Set;_onDestroyHooks=[];get destroyed(){return this._destroyed}_destroyed=!1;injectorDefTypes;constructor(n,e,r,i){super(),this.parent=e,this.source=r,this.scopes=i,vv(n,s=>this.processProvider(s)),this.records.set(Pv,es(void 0,this)),i.has("environment")&&this.records.set(En,es(void 0,this));let o=this.records.get(qf);o!=null&&typeof o.value=="string"&&this.scopes.add(o.value),this.injectorDefTypes=new Set(this.get(Rv,Ea,{self:!0}))}retrieve(n,e){let r=bi(e)||0;try{return this.get(n,vi,r)}catch(i){if(Xo(i))return i;throw i}}destroy(){ba(this),this._destroyed=!0;let n=ge(null);try{for(let r of this._ngOnDestroyHooks)r.ngOnDestroy();let e=this._onDestroyHooks;this._onDestroyHooks=[];for(let r of e)r()}finally{this.records.clear(),this._ngOnDestroyHooks.clear(),this.injectorDefTypes.clear(),ge(n)}}onDestroy(n){return ba(this),this._onDestroyHooks.push(n),()=>this.removeOnDestroy(n)}runInContext(n){ba(this);let e=wn(this),r=jt(void 0),i;try{return n()}finally{wn(e),jt(r)}}get(n,e=vi,r){if(ba(this),n.hasOwnProperty(wT))return n[wT](this);let i=bi(r),o,s=wn(this),a=jt(void 0);try{if(!(i&4)){let u=this.records.get(n);if(u===void 0){let l=G8(n)&&Pf(n);l&&this.injectableDefInScope(l)?u=es(yv(n),If):u=null,this.records.set(n,u)}if(u!=null)return this.hydrate(n,u,i)}let c=i&2?Da():this.parent;return e=i&8&&e===vi?null:e,c.get(n,e)}catch(c){let u=P8(c);throw u===-200||u===-201?new Re(u,null):c}finally{jt(a),wn(s)}}resolveInjectorInitializers(){let n=ge(null),e=wn(this),r=jt(void 0),i;try{let o=this.get($f,Ea,{self:!0});for(let s of o)s()}finally{wn(e),jt(r),ge(n)}}toString(){let n=[],e=this.records;for(let r of e.keys())n.push(_i(r));return`R3Injector[${n.join(", ")}]`}processProvider(n){n=xt(n);let e=Df(n)?n:xt(n&&n.provide),r=U8(n);if(!Df(n)&&n.multi===!0){let i=this.records.get(e);i||(i=es(void 0,If,!0),i.factory=()=>gv(i.multi),this.records.set(e,i)),e=n,i.multi.push(n)}this.records.set(e,r)}hydrate(n,e,r){let i=ge(null);try{if(e.value===ET)throw Mv(_i(n));return e.value===If&&(e.value=ET,e.value=e.factory(void 0,r)),typeof e.value=="object"&&e.value&&W8(e.value)&&this._ngOnDestroyHooks.add(e.value),e.value}finally{ge(i)}}injectableDefInScope(n){if(!n.providedIn)return!1;let e=xt(n.providedIn);return typeof e=="string"?e==="any"||this.scopes.has(e):this.injectorDefTypes.has(e)}removeOnDestroy(n){let e=this._onDestroyHooks.indexOf(n);e!==-1&&this._onDestroyHooks.splice(e,1)}};function yv(t){let n=Pf(t),e=n!==null?n.factory:wi(t);if(e!==null)return e;if(t instanceof _e)throw new Re(-204,!1);if(t instanceof Function)return H8(t);throw new Re(-204,!1)}function H8(t){if(t.length>0)throw new Re(-204,!1);let e=M8(t);return e!==null?()=>e.factory(t):()=>new t}function U8(t){if(PT(t))return es(void 0,t.useValue);{let n=RT(t);return es(n,If)}}function RT(t,n,e){let r;if(Df(t)){let i=xt(t);return wi(i)||yv(i)}else if(PT(t))r=()=>xt(t.useValue);else if(B8(t))r=()=>t.useFactory(...gv(t.deps||[]));else if(q8(t))r=(i,o)=>Hn(xt(t.useExisting),o!==void 0&&o&8?8:void 0);else{let i=xt(t&&(t.useClass||t.provide));if(V8(t))r=()=>new i(...gv(t.deps));else return wi(i)||yv(i)}return r}function ba(t){if(t.destroyed)throw new Re(-205,!1)}function es(t,n,e=!1){return{factory:t,value:n,multi:e?[]:void 0}}function V8(t){return!!t.deps}function W8(t){return t!==null&&typeof t=="object"&&typeof t.ngOnDestroy=="function"}function G8(t){return typeof t=="function"||typeof t=="object"&&t.ngMetadataName==="InjectionToken"}function vv(t,n){for(let e of t)Array.isArray(e)?vv(e,n):e&&xv(e)?vv(e.\u0275providers,n):n(e)}function Oa(t,n){let e;t instanceof Ei?(ba(t),e=t):e=new mv(t);let r,i=wn(e),o=jt(void 0);try{return n()}finally{wn(i),jt(o)}}function kT(){return OT()!==void 0||Cf()!=null}var Un=0,Ae=1,le=2,Ft=3,Vn=4,kr=5,Bf=6,Hf=7,$t=8,Ti=9,Wn=10,xi=11,ns=12,Lv=13,rs=14,Sn=15,Ma=16,Di=17,Uf=18,Lr=19,jv=20,Bn=21,Vf=22,Nr=23,qt=24,Wf=25,Aa=26,jr=27,LT=1;var Gf=7,jT=8,Na=9,Gn=10;function zn(t){return Array.isArray(t)&&typeof t[LT]=="object"}function Fr(t){return Array.isArray(t)&&t[LT]===!0}function Fv(t){return(t.flags&4)!==0}function zf(t){return t.componentOffset>-1}function is(t){return!!t.template}function os(t){return(t[le]&512)!==0}function Oi(t){return(t[le]&256)===256}var FT="svg",$T="math";function Mi(t){for(;Array.isArray(t);)t=t[Un];return t}function $v(t,n){return Mi(n[t.index])}function qv(t,n){return t.data[n]}function $r(t,n){let e=n[t];return zn(e)?e:e[Un]}function Kf(t){return(t[le]&128)===128}function Bv(t,n){return n==null?null:t[n]}function Hv(t){t[Di]=0}function Uv(t){t[le]&1024||(t[le]|=1024,Kf(t)&&ss(t))}function Pa(t){return!!(t[le]&9216||t[qt]?.dirty)}function Vv(t){t[Wn].changeDetectionScheduler?.notify(8),t[le]&64&&(t[le]|=1024),Pa(t)&&ss(t)}function ss(t){t[Wn].changeDetectionScheduler?.notify(0);let n=Si(t);for(;n!==null&&!(n[le]&8192||(n[le]|=8192,!Kf(n)));)n=Si(n)}function Wv(t,n){if(Oi(t))throw new Re(911,!1);t[Bn]===null&&(t[Bn]=[]),t[Bn].push(n)}function qT(t,n){if(t[Bn]===null)return;let e=t[Bn].indexOf(n);e!==-1&&t[Bn].splice(e,1)}function Si(t){let n=t[Ft];return Fr(n)?n[Ft]:n}var Je={lFrame:ZT(null),bindingsEnabled:!0,skipHydrationRootTNode:null};var _v=!1;function BT(){return Je.skipHydrationRootTNode!==null}function Ai(){return Je.lFrame.lView}function as(){let t=Gv();for(;t!==null&&t.type===64;)t=t.parent;return t}function Gv(){return Je.lFrame.currentTNode}function HT(){let t=Je.lFrame,n=t.currentTNode;return t.isParent?n:n.parent}function UT(t,n){let e=Je.lFrame;e.currentTNode=t,e.isParent=n}function VT(){return Je.lFrame.isParent}function zv(){return _v}function Ca(t){let n=_v;return _v=t,n}function WT(t){return Je.lFrame.bindingIndex=t}function GT(){return Je.lFrame.inI18n}function zT(t,n){let e=Je.lFrame;e.bindingIndex=e.bindingRootIndex=t,Yf(n)}function KT(){return Je.lFrame.currentDirectiveIndex}function Yf(t){Je.lFrame.currentDirectiveIndex=t}function Kv(t){Je.lFrame.currentQueryIndex=t}function z8(t){let n=t[Ae];return n.type===2?n.declTNode:n.type===1?t[kr]:null}function Yv(t,n,e){if(e&4){let i=n,o=t;for(;i=i.parent,i===null&&!(e&1);)if(i=z8(o),i===null||(o=o[rs],i.type&10))break;if(i===null)return!1;n=i,t=o}let r=Je.lFrame=YT();return r.currentTNode=n,r.lView=t,!0}function Zf(t){let n=YT(),e=t[Ae];Je.lFrame=n,n.currentTNode=e.firstChild,n.lView=t,n.tView=e,n.contextLView=t,n.bindingIndex=e.bindingStartIndex,n.inI18n=!1}function YT(){let t=Je.lFrame,n=t===null?null:t.child;return n===null?ZT(t):n}function ZT(t){let n={currentTNode:null,isParent:!0,lView:null,tView:null,selectedIndex:-1,contextLView:null,elementDepthCount:0,currentNamespace:null,currentDirectiveIndex:-1,bindingRootIndex:-1,bindingIndex:-1,currentQueryIndex:0,parent:t,child:null,inI18n:!1};return t!==null&&(t.child=n),n}function QT(){let t=Je.lFrame;return Je.lFrame=t.parent,t.currentTNode=null,t.lView=null,t}var Zv=QT;function Qf(){let t=QT();t.isParent=!0,t.tView=null,t.selectedIndex=-1,t.contextLView=null,t.elementDepthCount=0,t.currentDirectiveIndex=-1,t.currentNamespace=null,t.bindingRootIndex=-1,t.bindingIndex=-1,t.currentQueryIndex=0}function JT(){return Je.lFrame.selectedIndex}function qr(t){Je.lFrame.selectedIndex=t}function bv(t,n=null,e=null,r){let i=XT(t,n,e,r);return i.resolveInjectorInitializers(),i}function XT(t,n=null,e=null,r,i=new Set){let o=[e||Ea,MT(t)];return r=r||(typeof t=="object"?void 0:_i(t)),new Ei(o,n||Da(),r||null,i)}var sn=class t{static THROW_IF_NOT_FOUND=vi;static NULL=new Sa;static create(n,e){if(Array.isArray(n))return bv({name:""},e,n,"");{let r=n.name??"";return bv({name:r},n.parent,n.providers,r)}}static \u0275prov=N({token:t,providedIn:"any",factory:()=>Hn(Pv)});static __NG_ELEMENT_ID__=-1};var Kt=(()=>{class t{static __NG_ELEMENT_ID__=K8;static __NG_ENV_ID__=e=>e}return t})(),Of=class extends Kt{_lView;constructor(n){super(),this._lView=n}get destroyed(){return Oi(this._lView)}onDestroy(n){let e=this._lView;return Wv(e,n),()=>qT(e,n)}};function K8(){return new Of(Ai())}var ex=!1,tx=new _e(""),Ra=(()=>{class t{taskId=0;pendingTasks=new Set;destroyed=!1;pendingTask=new Rr.BehaviorSubject(!1);debugTaskTracker=w(tx,{optional:!0});get hasPendingTasks(){return this.destroyed?!1:this.pendingTask.value}get hasPendingTasksObservable(){return this.destroyed?new Rr.Observable(e=>{e.next(!1),e.complete()}):this.pendingTask}add(){!this.hasPendingTasks&&!this.destroyed&&this.pendingTask.next(!0);let e=this.taskId++;return this.pendingTasks.add(e),this.debugTaskTracker?.add(e),e}has(e){return this.pendingTasks.has(e)}remove(e){this.pendingTasks.delete(e),this.debugTaskTracker?.remove(e),this.pendingTasks.size===0&&this.hasPendingTasks&&this.pendingTask.next(!1)}ngOnDestroy(){this.pendingTasks.clear(),this.hasPendingTasks&&this.pendingTask.next(!1),this.destroyed=!0,this.pendingTask.unsubscribe()}static \u0275prov=N({token:t,providedIn:"root",factory:()=>new t})}return t})(),wv=class extends Rr.Subject{__isAsync;destroyRef=void 0;pendingTasks=void 0;constructor(n=!1){super(),this.__isAsync=n,kT()&&(this.destroyRef=w(Kt,{optional:!0})??void 0,this.pendingTasks=w(Ra,{optional:!0})??void 0)}emit(n){let e=ge(null);try{super.next(n)}finally{ge(e)}}subscribe(n,e,r){let i=n,o=e||(()=>null),s=r;if(n&&typeof n=="object"){let c=n;i=c.next?.bind(c),o=c.error?.bind(c),s=c.complete?.bind(c)}this.__isAsync&&(o=this.wrapInTimeout(o),i&&(i=this.wrapInTimeout(i)),s&&(s=this.wrapInTimeout(s)));let a=super.subscribe({next:i,error:o,complete:s});return n instanceof Rr.Subscription&&n.add(a),a}wrapInTimeout(n){return e=>{let r=this.pendingTasks?.add();setTimeout(()=>{try{n(e)}finally{r!==void 0&&this.pendingTasks?.remove(r)}})}}},qn=wv;function Mf(...t){}function Qv(t){let n,e;function r(){t=Mf;try{e!==void 0&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(e),n!==void 0&&clearTimeout(n)}catch{}}return n=setTimeout(()=>{t(),r()}),typeof requestAnimationFrame=="function"&&(e=requestAnimationFrame(()=>{t(),r()})),()=>r()}function nx(t){return queueMicrotask(()=>t()),()=>{t=Mf}}var Jv="isAngularZone",Ia=Jv+"_ID",Y8=0,Pr=class t{hasPendingMacrotasks=!1;hasPendingMicrotasks=!1;isStable=!0;onUnstable=new qn(!1);onMicrotaskEmpty=new qn(!1);onStable=new qn(!1);onError=new qn(!1);constructor(n){let{enableLongStackTrace:e=!1,shouldCoalesceEventChangeDetection:r=!1,shouldCoalesceRunChangeDetection:i=!1,scheduleInRootZone:o=ex}=n;if(typeof Zone>"u")throw new Re(908,!1);Zone.assertZonePatched();let s=this;s._nesting=0,s._outer=s._inner=Zone.current,Zone.TaskTrackingZoneSpec&&(s._inner=s._inner.fork(new Zone.TaskTrackingZoneSpec)),e&&Zone.longStackTraceZoneSpec&&(s._inner=s._inner.fork(Zone.longStackTraceZoneSpec)),s.shouldCoalesceEventChangeDetection=!i&&r,s.shouldCoalesceRunChangeDetection=i,s.callbackScheduled=!1,s.scheduleInRootZone=o,J8(s)}static isInAngularZone(){return typeof Zone<"u"&&Zone.current.get(Jv)===!0}static assertInAngularZone(){if(!t.isInAngularZone())throw new Re(909,!1)}static assertNotInAngularZone(){if(t.isInAngularZone())throw new Re(909,!1)}run(n,e,r){return this._inner.run(n,e,r)}runTask(n,e,r,i){let o=this._inner,s=o.scheduleEventTask("NgZoneEvent: "+i,n,Z8,Mf,Mf);try{return o.runTask(s,e,r)}finally{o.cancelTask(s)}}runGuarded(n,e,r){return this._inner.runGuarded(n,e,r)}runOutsideAngular(n){return this._outer.run(n)}},Z8={};function Xv(t){if(t._nesting==0&&!t.hasPendingMicrotasks&&!t.isStable)try{t._nesting++,t.onMicrotaskEmpty.emit(null)}finally{if(t._nesting--,!t.hasPendingMicrotasks)try{t.runOutsideAngular(()=>t.onStable.emit(null))}finally{t.isStable=!0}}}function Q8(t){if(t.isCheckStableRunning||t.callbackScheduled)return;t.callbackScheduled=!0;function n(){Qv(()=>{t.callbackScheduled=!1,Ev(t),t.isCheckStableRunning=!0,Xv(t),t.isCheckStableRunning=!1})}t.scheduleInRootZone?Zone.root.run(()=>{n()}):t._outer.run(()=>{n()}),Ev(t)}function J8(t){let n=()=>{Q8(t)},e=Y8++;t._inner=t._inner.fork({name:"angular",properties:{[Jv]:!0,[Ia]:e,[Ia+e]:!0},onInvokeTask:(r,i,o,s,a,c)=>{if(X8(c))return r.invokeTask(o,s,a,c);try{return ST(t),r.invokeTask(o,s,a,c)}finally{(t.shouldCoalesceEventChangeDetection&&s.type==="eventTask"||t.shouldCoalesceRunChangeDetection)&&n(),CT(t)}},onInvoke:(r,i,o,s,a,c,u)=>{try{return ST(t),r.invoke(o,s,a,c,u)}finally{t.shouldCoalesceRunChangeDetection&&!t.callbackScheduled&&!e6(c)&&n(),CT(t)}},onHasTask:(r,i,o,s)=>{r.hasTask(o,s),i===o&&(s.change=="microTask"?(t._hasPendingMicrotasks=s.microTask,Ev(t),Xv(t)):s.change=="macroTask"&&(t.hasPendingMacrotasks=s.macroTask))},onHandleError:(r,i,o,s)=>(r.handleError(o,s),t.runOutsideAngular(()=>t.onError.emit(s)),!1)})}function Ev(t){t._hasPendingMicrotasks||(t.shouldCoalesceEventChangeDetection||t.shouldCoalesceRunChangeDetection)&&t.callbackScheduled===!0?t.hasPendingMicrotasks=!0:t.hasPendingMicrotasks=!1}function ST(t){t._nesting++,t.isStable&&(t.isStable=!1,t.onUnstable.emit(null))}function CT(t){t._nesting--,Xv(t)}var Ta=class{hasPendingMicrotasks=!1;hasPendingMacrotasks=!1;isStable=!0;onUnstable=new qn;onMicrotaskEmpty=new qn;onStable=new qn;onError=new qn;run(n,e,r){return n.apply(e,r)}runGuarded(n,e,r){return n.apply(e,r)}runOutsideAngular(n){return n()}runTask(n,e,r,i){return n.apply(e,r)}};function X8(t){return rx(t,"__ignore_ng_zone__")}function e6(t){return rx(t,"__scheduler_tick__")}function rx(t,n){return!Array.isArray(t)||t.length!==1?!1:t[0]?.data?.[n]===!0}var xa=class{_console=console;handleError(n){this._console.error("ERROR",n)}},Jf=new _e("",{factory:()=>{let t=w(Pr),n=w(En),e;return r=>{t.runOutsideAngular(()=>{n.destroyed&&!e?setTimeout(()=>{throw r}):(e??=n.get(xa),e.handleError(r))})}}});function an(t,n){let[e,r,i]=sv(t,n?.equal),o=e,s=o[zt];return o.set=r,o.update=i,o.asReadonly=ix.bind(o),o}function ix(){let t=this[zt];if(t.readonlyFn===void 0){let n=()=>this();n[zt]=t,t.readonlyFn=n}return t.readonlyFn}var Xf=(()=>{class t{view;node;constructor(e,r){this.view=e,this.node=r}static __NG_ELEMENT_ID__=t6}return t})();function t6(){return new Xf(Ai(),as())}var Ci=class{},ka=new _e("",{factory:()=>!0});var e_=new _e("");var eh=(()=>{class t{static \u0275prov=N({token:t,providedIn:"root",factory:()=>new Sv})}return t})(),Sv=class{dirtyEffectCount=0;queues=new Map;add(n){this.enqueue(n),this.schedule(n)}schedule(n){n.dirty&&this.dirtyEffectCount++}remove(n){let e=n.zone,r=this.queues.get(e);r.has(n)&&(r.delete(n),n.dirty&&this.dirtyEffectCount--)}enqueue(n){let e=n.zone;this.queues.has(e)||this.queues.set(e,new Set);let r=this.queues.get(e);r.has(n)||r.add(n)}flush(){for(;this.dirtyEffectCount>0;){let n=!1;for(let[e,r]of this.queues)e===null?n||=this.flushQueue(r):n||=e.run(()=>this.flushQueue(r));n||(this.dirtyEffectCount=0)}}flushQueue(n){let e=!1;for(let r of n)r.dirty&&(this.dirtyEffectCount--,e=!0,r.run());return e}},Af=class{[zt];constructor(n){this[zt]=n}destroy(){this[zt].destroy()}};function t_(t,n){let e=n?.injector??w(sn),r=n?.manualCleanup!==!0?e.get(Kt):null,i,o=e.get(Xf,null,{optional:!0}),s=e.get(Ci);return o!==null?(i=i6(o.view,s,t),r instanceof Of&&r._lView===o.view&&(r=null)):i=o6(t,e.get(eh),s),i.injector=e,r!==null&&(i.onDestroyFns=[r.onDestroy(()=>i.destroy())]),new Af(i)}var ox={...uv,cleanupFns:void 0,zone:null,onDestroyFns:null,run(){let t=Ca(!1);try{lv(this)}finally{Ca(t)}},cleanup(){if(!this.cleanupFns?.length)return;let t=ge(null);try{for(;this.cleanupFns.length;)this.cleanupFns.pop()()}finally{this.cleanupFns=[],ge(t)}}},n6={...ox,consumerMarkedDirty(){this.scheduler.schedule(this),this.notifier.notify(12)},destroy(){if(Qo(this),this.onDestroyFns!==null)for(let t of this.onDestroyFns)t();this.cleanup(),this.scheduler.remove(this)}},r6={...ox,consumerMarkedDirty(){this.view[le]|=8192,ss(this.view),this.notifier.notify(13)},destroy(){if(Qo(this),this.onDestroyFns!==null)for(let t of this.onDestroyFns)t();this.cleanup(),this.view[Nr]?.delete(this)}};function i6(t,n,e){let r=Object.create(r6);return r.view=t,r.zone=typeof Zone<"u"?Zone.current:null,r.notifier=n,r.fn=sx(r,e),t[Nr]??=new Set,t[Nr].add(r),r.consumerMarkedDirty(r),r}function o6(t,n,e){let r=Object.create(n6);return r.fn=sx(r,t),r.scheduler=n,r.notifier=e,r.zone=typeof Zone<"u"?Zone.current:null,r.scheduler.add(r),r.notifier.notify(12),r}function sx(t,n){return()=>{n(e=>(t.cleanupFns??=[]).push(e))}}function La(t){return cv(t)}var dh=U(Q(),1);var Dx=U(Ni(),1);function Ox(t){return{toString:t}.toString()}function Mx(t,n,e,r){n!==null?n.applyValueToInputSignal(n,r):t[e]=r}var oh=class{previousValue;currentValue;firstChange;constructor(n,e,r){this.previousValue=n,this.currentValue=e,this.firstChange=r}isFirstChange(){return this.firstChange}};function k5(t){return t.type.prototype.ngOnChanges&&(t.setInput=j5),L5}function L5(){let t=Nx(this),n=t?.current;if(n){let e=t.previous;if(e===Ff)t.previous=n;else for(let r in n)e[r]=n[r];t.current=null,this.ngOnChanges(n)}}function j5(t,n,e,r,i){let o=this.declaredInputs[r],s=Nx(t)||F5(t,{previous:Ff,current:null}),a=s.current||(s.current={}),c=s.previous,u=c[o];a[o]=new oh(u&&u.currentValue,e,c===Ff),Mx(t,n,i,e)}var Ax="__ngSimpleChanges__";function Nx(t){return t[Ax]||null}function F5(t,n){return t[Ax]=n}var lx=[];var Ke=function(t,n=null,e){for(let r=0;r<lx.length;r++){let i=lx[r];i(t,n,e)}},Be=(function(t){return t[t.TemplateCreateStart=0]="TemplateCreateStart",t[t.TemplateCreateEnd=1]="TemplateCreateEnd",t[t.TemplateUpdateStart=2]="TemplateUpdateStart",t[t.TemplateUpdateEnd=3]="TemplateUpdateEnd",t[t.LifecycleHookStart=4]="LifecycleHookStart",t[t.LifecycleHookEnd=5]="LifecycleHookEnd",t[t.OutputStart=6]="OutputStart",t[t.OutputEnd=7]="OutputEnd",t[t.BootstrapApplicationStart=8]="BootstrapApplicationStart",t[t.BootstrapApplicationEnd=9]="BootstrapApplicationEnd",t[t.BootstrapComponentStart=10]="BootstrapComponentStart",t[t.BootstrapComponentEnd=11]="BootstrapComponentEnd",t[t.ChangeDetectionStart=12]="ChangeDetectionStart",t[t.ChangeDetectionEnd=13]="ChangeDetectionEnd",t[t.ChangeDetectionSyncStart=14]="ChangeDetectionSyncStart",t[t.ChangeDetectionSyncEnd=15]="ChangeDetectionSyncEnd",t[t.AfterRenderHooksStart=16]="AfterRenderHooksStart",t[t.AfterRenderHooksEnd=17]="AfterRenderHooksEnd",t[t.ComponentStart=18]="ComponentStart",t[t.ComponentEnd=19]="ComponentEnd",t[t.DeferBlockStateStart=20]="DeferBlockStateStart",t[t.DeferBlockStateEnd=21]="DeferBlockStateEnd",t[t.DynamicComponentStart=22]="DynamicComponentStart",t[t.DynamicComponentEnd=23]="DynamicComponentEnd",t[t.HostBindingsUpdateStart=24]="HostBindingsUpdateStart",t[t.HostBindingsUpdateEnd=25]="HostBindingsUpdateEnd",t})(Be||{});function $5(t,n,e){let{ngOnChanges:r,ngOnInit:i,ngDoCheck:o}=n.type.prototype;if(r){let s=k5(n);(e.preOrderHooks??=[]).push(t,s),(e.preOrderCheckHooks??=[]).push(t,s)}i&&(e.preOrderHooks??=[]).push(0-t,i),o&&((e.preOrderHooks??=[]).push(t,o),(e.preOrderCheckHooks??=[]).push(t,o))}function q5(t,n){for(let e=n.directiveStart,r=n.directiveEnd;e<r;e++){let o=t.data[e].type.prototype,{ngAfterContentInit:s,ngAfterContentChecked:a,ngAfterViewInit:c,ngAfterViewChecked:u,ngOnDestroy:l}=o;s&&(t.contentHooks??=[]).push(-e,s),a&&((t.contentHooks??=[]).push(e,a),(t.contentCheckHooks??=[]).push(e,a)),c&&(t.viewHooks??=[]).push(-e,c),u&&((t.viewHooks??=[]).push(e,u),(t.viewCheckHooks??=[]).push(e,u)),l!=null&&(t.destroyHooks??=[]).push(e,l)}}function nh(t,n,e){Px(t,n,3,e)}function rh(t,n,e,r){(t[le]&3)===e&&Px(t,n,e,r)}function n_(t,n){let e=t[le];(e&3)===n&&(e&=16383,e+=1,t[le]=e)}function Px(t,n,e,r){let i=r!==void 0?t[Di]&65535:0,o=r??-1,s=n.length-1,a=0;for(let c=i;c<s;c++)if(typeof n[c+1]=="number"){if(a=n[c],r!=null&&a>=r)break}else n[c]<0&&(t[Di]+=65536),(a<o||o==-1)&&(B5(t,e,n,c),t[Di]=(t[Di]&4294901760)+c+2),c++}function dx(t,n){Ke(Be.LifecycleHookStart,t,n);let e=ge(null);try{n.call(t)}finally{ge(e),Ke(Be.LifecycleHookEnd,t,n)}}function B5(t,n,e,r){let i=e[r]<0,o=e[r+1],s=i?-e[r]:e[r],a=t[s];i?t[le]>>14<t[Di]>>16&&(t[le]&3)===n&&(t[le]+=16384,dx(a,o)):dx(a,o)}var us=-1,ja=class{factory;name;injectImpl;resolving=!1;canSeeViewProviders;multi;componentProviders;index;providerFactory;constructor(n,e,r,i){this.factory=n,this.name=i,this.canSeeViewProviders=e,this.injectImpl=r}};function H5(t,n,e){let r=0;for(;r<e.length;){let i=e[r];if(typeof i=="number"){if(i!==0)break;r++;let o=e[r++],s=e[r++],a=e[r++];t.setAttribute(n,s,a,o)}else{let o=i,s=e[++r];U5(o)?t.setProperty(n,o,s):t.setAttribute(n,o,s),r++}}return r}function U5(t){return t.charCodeAt(0)===64}function Rx(t,n){if(!(n===null||n.length===0))if(t===null||t.length===0)t=n.slice();else{let e=-1;for(let r=0;r<n.length;r++){let i=n[r];typeof i=="number"?e=i:e===0||(e===-1||e===2?fx(t,e,i,null,n[++r]):fx(t,e,i,null,null))}}return t}function fx(t,n,e,r,i){let o=0,s=t.length;if(n===-1)s=-1;else for(;o<t.length;){let a=t[o++];if(typeof a=="number"){if(a===n){s=-1;break}else if(a>n){s=o-1;break}}}for(;o<t.length;){let a=t[o];if(typeof a=="number")break;if(a===e){i!==null&&(t[o+1]=i);return}o++,i!==null&&o++}s!==-1&&(t.splice(s,0,n),o=s+1),t.splice(o++,0,e),i!==null&&t.splice(o++,0,i)}function V5(t){return t!==us}function s_(t){return t&32767}function W5(t){return t>>16}function a_(t,n){let e=W5(t),r=n;for(;e>0;)r=r[rs],e--;return r}var c_=!0;function hx(t){let n=c_;return c_=t,n}var G5=256,kx=G5-1,Lx=5,z5=0,Cn={};function K5(t,n,e){let r;typeof e=="string"?r=e.charCodeAt(0)||0:e.hasOwnProperty(Ii)&&(r=e[Ii]),r==null&&(r=e[Ii]=z5++);let i=r&kx,o=1<<i;n.data[t+(i>>Lx)]|=o}function jx(t,n){let e=Fx(t,n);if(e!==-1)return e;let r=n[Ae];r.firstCreatePass&&(t.injectorIndex=n.length,r_(r.data,t),r_(n,null),r_(r.blueprint,null));let i=$x(t,n),o=t.injectorIndex;if(V5(i)){let s=s_(i),a=a_(i,n),c=a[Ae].data;for(let u=0;u<8;u++)n[o+u]=a[s+u]|c[s+u]}return n[o+8]=i,o}function r_(t,n){t.push(0,0,0,0,0,0,0,0,n)}function Fx(t,n){return t.injectorIndex===-1||t.parent&&t.parent.injectorIndex===t.injectorIndex||n[t.injectorIndex+8]===null?-1:t.injectorIndex}function $x(t,n){if(t.parent&&t.parent.injectorIndex!==-1)return t.parent.injectorIndex;let e=0,r=null,i=n;for(;i!==null;){if(r=Vx(i),r===null)return us;if(e++,i=i[rs],r.injectorIndex!==-1)return r.injectorIndex|e<<16}return us}function Y5(t,n,e){K5(t,n,e)}function qx(t,n,e){if(e&8||t!==void 0)return t;Lf(n,"NodeInjector")}function Bx(t,n,e,r){if(e&8&&r===void 0&&(r=null),(e&3)===0){let i=t[Ti],o=jt(void 0);try{return i?i.get(n,r,e&8):Av(n,r,e&8)}finally{jt(o)}}return qx(r,n,e)}function Hx(t,n,e,r=0,i){if(t!==null){if(n[le]&2048&&!(r&2)){let s=eY(t,n,e,r,Cn);if(s!==Cn)return s}let o=Ux(t,n,e,r,Cn);if(o!==Cn)return o}return Bx(n,e,r,i)}function Ux(t,n,e,r,i){let o=J5(e);if(typeof o=="function"){if(!Yv(n,t,r))return r&1?qx(i,e,r):Bx(n,e,r,i);try{let s;if(s=o(r),s==null&&!(r&8))Lf(e);else return s}finally{Zv()}}else if(typeof o=="number"){let s=null,a=Fx(t,n),c=us,u=r&1?n[Sn][kr]:null;for((a===-1||r&4)&&(c=a===-1?$x(t,n):n[a+8],c===us||!mx(r,!1)?a=-1:(s=n[Ae],a=s_(c),n=a_(c,n)));a!==-1;){let l=n[Ae];if(px(o,a,l.data)){let d=Z5(a,n,e,s,r,u);if(d!==Cn)return d}c=n[a+8],c!==us&&mx(r,n[Ae].data[a+8]===u)&&px(o,a,n)?(s=l,a=s_(c),n=a_(c,n)):a=-1}}return i}function Z5(t,n,e,r,i,o){let s=n[Ae],a=s.data[t+8],c=r==null?zf(a)&&c_:r!=s&&(a.type&3)!==0,u=i&1&&o===a,l=Q5(a,s,e,c,u);return l!==null?u_(n,s,l,a,i):Cn}function Q5(t,n,e,r,i){let o=t.providerIndexes,s=n.data,a=o&1048575,c=t.directiveStart,u=t.directiveEnd,l=o>>20,d=r?a:a+l,f=i?a+l:u;for(let p=d;p<f;p++){let m=s[p];if(p<c&&e===m||p>=c&&m.type===e)return p}if(i){let p=s[c];if(p&&is(p)&&p.type===e)return c}return null}function u_(t,n,e,r,i){let o=t[e],s=n.data;if(o instanceof ja){let a=o;if(a.resolving)throw Mv("");let c=hx(a.canSeeViewProviders);a.resolving=!0;let u=s[e].type||s[e],l,d=a.injectImpl?jt(a.injectImpl):null,f=Yv(t,r,0);try{o=t[e]=a.factory(void 0,i,s,t,r),n.firstCreatePass&&e>=r.directiveStart&&$5(e,s[e],n)}finally{d!==null&&jt(d),hx(c),a.resolving=!1,Zv()}}return o}function J5(t){if(typeof t=="string")return t.charCodeAt(0)||0;let n=t.hasOwnProperty(Ii)?t[Ii]:void 0;return typeof n=="number"?n>=0?n&kx:X5:n}function px(t,n,e){let r=1<<t;return!!(e[n+(t>>Lx)]&r)}function mx(t,n){return!(t&2)&&!(t&1&&n)}var sh=class{_tNode;_lView;constructor(n,e){this._tNode=n,this._lView=e}get(n,e,r){return Hx(this._tNode,this._lView,n,bi(r),e)}};function X5(){return new sh(as(),Ai())}function Bt(t){return Ox(()=>{let n=t.prototype.constructor,e=n[wa]||l_(n),r=Object.prototype,i=Object.getPrototypeOf(t.prototype).constructor;for(;i&&i!==r;){let o=i[wa]||l_(i);if(o&&o!==e)return o;i=Object.getPrototypeOf(i)}return o=>new o})}function l_(t){return Tv(t)?()=>{let n=l_(xt(t));return n&&n()}:wi(t)}function eY(t,n,e,r,i){let o=t,s=n;for(;o!==null&&s!==null&&s[le]&2048&&!os(s);){let a=Ux(o,s,e,r|2,Cn);if(a!==Cn)return a;let c=o.parent;if(!c){let u=s[jv];if(u){let l=u.get(e,Cn,r);if(l!==Cn)return l}c=Vx(s),s=s[rs]}o=c}return i}function Vx(t){let n=t[Ae],e=n.type;return e===2?n.declTNode:e===1?t[kr]:null}function tY(){return Wx(as(),Ai())}function Wx(t,n){return new Gx($v(t,n))}var Gx=(()=>{class t{nativeElement;constructor(e){this.nativeElement=e}static __NG_ELEMENT_ID__=tY}return t})();function nY(t){return(t.flags&128)===128}var zx=new Map,rY=0;function iY(){return rY++}function oY(t){zx.set(t[Lr],t)}function d_(t){zx.delete(t[Lr])}var gx="__ngContext__";function C_(t,n){zn(n)?(t[gx]=n[Lr],oY(n)):t[gx]=n}function Kx(t){return Zx(t[ns])}function Yx(t){return Zx(t[Vn])}function Zx(t){for(;t!==null&&!Fr(t);)t=t[Vn];return t}var Qx=!1,sY=new _e("",{factory:()=>Qx});function aY(t){return(t.flags&32)===32}var cY=()=>null;function Jx(t,n,e=!1){return cY(t,n,e)}function Xx(t,n){let e=t.contentQueries;if(e!==null){let r=ge(null);try{for(let i=0;i<e.length;i+=2){let o=e[i],s=e[i+1];if(s!==-1){let a=t.data[s];Kv(o),a.contentQueries(2,n[s],s)}}}finally{ge(r)}}}function f_(t,n,e){Kv(0);let r=ge(null);try{n(t,e)}finally{ge(r)}}function uY(t,n,e){if(Fv(n)){let r=ge(null);try{let i=n.directiveStart,o=n.directiveEnd;for(let s=i;s<o;s++){let a=t.data[s];if(a.contentQueries){let c=e[s];a.contentQueries(1,c,s)}}}finally{ge(r)}}}var h_=(function(t){return t[t.Emulated=0]="Emulated",t[t.None=2]="None",t[t.ShadowDom=3]="ShadowDom",t[t.ExperimentalIsolatedShadowDom=4]="ExperimentalIsolatedShadowDom",t})(h_||{});function lY(t,n,e){return t.createElement(n,e)}function yx(t,n,e,r,i){t.insertBefore(n,e,r,i)}function dY(t,n,e){t.appendChild(n,e)}function fY(t,n,e,r){t.removeChild(null,n,e,r)}function hY(t,n,e){t.setAttribute(n,"style",e)}function pY(t,n,e){e===""?t.removeAttribute(n,"class"):t.setAttribute(n,"class",e)}function mY(t,n,e){let{mergedAttrs:r,classes:i,styles:o}=e;r!==null&&H5(t,n,r),i!==null&&pY(t,n,i),o!==null&&hY(t,n,o)}var gY="ng-template";function yY(t){return t.type===4&&t.value!==gY}function p_(t){return(t&1)===0}function vx(t,n){return t?":not("+n.trim()+")":n}function vY(t){let n=t[0],e=1,r=2,i="",o=!1;for(;e<t.length;){let s=t[e];if(typeof s=="string")if(r&2){let a=t[++e];i+="["+s+(a.length>0?'="'+a+'"':"")+"]"}else r&8?i+="."+s:r&4&&(i+=" "+s);else i!==""&&!p_(s)&&(n+=vx(o,i),i=""),r=s,o=o||!p_(r);e++}return i!==""&&(n+=vx(o,i)),n}function _Y(t){return t.map(vY).join(",")}function bY(t){let n=[],e=[],r=1,i=2;for(;r<t.length;){let o=t[r];if(typeof o=="string")i===2?o!==""&&n.push(o,t[++r]):i===8&&e.push(o);else{if(!p_(i))break;i=o}r++}return e.length&&n.push(1,...e),n}var I_={};function eD(t,n,e,r,i,o,s,a,c,u,l){let d=jr+r,f=d+i,p=wY(d,f),m=typeof u=="function"?u():u;return p[Ae]={type:t,blueprint:p,template:e,queries:null,viewQuery:a,declTNode:n,data:p.slice().fill(null,d),bindingStartIndex:d,expandoStartIndex:f,hostBindingOpCodes:null,firstCreatePass:!0,firstUpdatePass:!0,staticViewQueries:!1,staticContentQueries:!1,preOrderHooks:null,preOrderCheckHooks:null,contentHooks:null,contentCheckHooks:null,viewHooks:null,viewCheckHooks:null,destroyHooks:null,cleanup:null,contentQueries:null,components:null,directiveRegistry:typeof o=="function"?o():o,pipeRegistry:typeof s=="function"?s():s,firstChild:null,schemas:c,consts:m,incompleteFirstPass:!1,ssrId:l}}function wY(t,n){let e=[];for(let r=0;r<n;r++)e.push(r<t?null:I_);return e}function EY(t){let n=t.tView;return n===null||n.incompleteFirstPass?t.tView=eD(1,null,t.template,t.decls,t.vars,t.directiveDefs,t.pipeDefs,t.viewQuery,t.schemas,t.consts,t.id):n}function tD(t,n,e,r,i,o,s,a,c,u,l){let d=n.blueprint.slice();return d[Un]=i,d[le]=r|4|128|8|64|1024,(u!==null||t&&t[le]&2048)&&(d[le]|=2048),Hv(d),d[Ft]=d[rs]=t,d[$t]=e,d[Wn]=s||t&&t[Wn],d[xi]=a||t&&t[xi],d[Ti]=c||t&&t[Ti]||null,d[kr]=o,d[Lr]=iY(),d[Bf]=l,d[jv]=u,d[Sn]=n.type==2?t[Sn]:d,d}function SY(t,n,e){let r=$v(n,t),i=EY(e),o=t[Wn].rendererFactory,s=CY(t,tD(t,i,null,nD(e),r,n,null,o.createRenderer(r,e),null,null,null));return t[n.index]=s}function nD(t){let n=16;return t.signals?n=4096:t.onPush&&(n=64),n}function rD(t,n,e,r){if(e===0)return-1;let i=n.length;for(let o=0;o<e;o++)n.push(r),t.blueprint.push(r),t.data.push(null);return i}function CY(t,n){return t[ns]?t[Lv][Vn]=n:t[ns]=n,t[Lv]=n,n}function IY(t,n,e,r){if(!r)if((n[le]&3)===3){let o=t.preOrderCheckHooks;o!==null&&nh(n,o,e)}else{let o=t.preOrderHooks;o!==null&&rh(n,o,0,e)}qr(e)}var T_=(function(t){return t[t.None=0]="None",t[t.SignalBased=1]="SignalBased",t[t.HasDecoratorInputTransform=2]="HasDecoratorInputTransform",t})(T_||{});function m_(t,n,e,r){let i=ge(null);try{let[o,s,a]=t.inputs[e],c=null;(s&T_.SignalBased)!==0&&(c=n[o][zt]),c!==null&&c.transformFn!==void 0?r=c.transformFn(r):a!==null&&(r=a.call(n,r)),t.setInput!==null?t.setInput(n,c,r,e,o):Mx(n,c,o,r)}finally{ge(i)}}var TY;function iD(t,n){return TY(t,n)}var ah=new Set,x_=(function(t){return t[t.CHANGE_DETECTION=0]="CHANGE_DETECTION",t[t.AFTER_NEXT_RENDER=1]="AFTER_NEXT_RENDER",t})(x_||{}),oD=new _e(""),_x=new Set;function xY(t){_x.has(t)||(_x.add(t),performance?.mark?.("mark_feature_usage",{detail:{feature:t}}))}var DY=(()=>{class t{impl=null;execute(){this.impl?.execute()}static \u0275prov=N({token:t,providedIn:"root",factory:()=>new t})}return t})();var sD=new _e("",{factory:()=>({queue:new Set,isScheduled:!1,scheduler:null,injector:w(En)})});function aD(t,n,e){let r=t.get(sD);if(Array.isArray(n))for(let i of n)r.queue.add(i),e?.detachedLeaveAnimationFns?.push(i);else r.queue.add(n),e?.detachedLeaveAnimationFns?.push(n);r.scheduler&&r.scheduler(t)}function OY(t,n){for(let[e,r]of n)aD(t,r.animateFns)}function MY(t,n){let e=t.get(sD);if(Array.isArray(n))for(let r of n)e.queue.delete(r);else e.queue.delete(n)}function bx(t,n,e,r){let i=t?.[Aa]?.enter;n!==null&&i&&i.has(e.index)&&OY(r,i)}function cs(t,n,e,r,i,o,s,a){if(i!=null){let c,u=!1;Fr(i)?c=i:zn(i)&&(u=!0,i=i[Un]);let l=Mi(i);t===0&&r!==null?(bx(a,r,o,e),s==null?dY(n,r,l):yx(n,r,l,s||null,!0)):t===1&&r!==null?(bx(a,r,o,e),yx(n,r,l,s||null,!0)):t===2?wx(a,o,e,d=>{fY(n,l,u,d)}):t===3&&wx(a,o,e,()=>{n.destroyNode(l)}),c!=null&&$Y(n,t,e,c,o,r,s)}}function AY(t,n){cD(t,n),n[Un]=null,n[kr]=null}function cD(t,n){n[Wn].changeDetectionScheduler?.notify(9),M_(t,n,n[xi],2,null,null)}function NY(t){let n=t[ns];if(!n)return i_(t[Ae],t);for(;n;){let e=null;if(zn(n))e=n[ns];else{let r=n[Gn];r&&(e=r)}if(!e){for(;n&&!n[Vn]&&n!==t;)zn(n)&&i_(n[Ae],n),n=n[Ft];n===null&&(n=t),zn(n)&&i_(n[Ae],n),e=n&&n[Vn]}n=e}}function D_(t,n){let e=t[Na],r=e.indexOf(n);e.splice(r,1)}function PY(t,n){if(Oi(n))return;let e=n[xi];e.destroyNode&&M_(t,n,e,3,null,null),NY(n)}function i_(t,n){if(Oi(n))return;let e=ge(null);try{n[le]&=-129,n[le]|=256,n[qt]&&Qo(n[qt]),LY(t,n),kY(t,n),n[Ae].type===1&&n[xi].destroy();let r=n[Ma];if(r!==null&&Fr(n[Ft])){r!==n[Ft]&&D_(r,n);let i=n[Uf];i!==null&&i.detachView(t)}d_(n)}finally{ge(e)}}function wx(t,n,e,r){let i=t?.[Aa];if(i?.enter?.has(n.index)&&MY(e,i.enter.get(n.index).animateFns),i==null||i.leave==null||!i.leave.has(n.index))return r(!1);t&&ah.add(t[Lr]),aD(e,()=>{if(i.leave&&i.leave.has(n.index)){let s=i.leave.get(n.index),a=[];if(s){for(let c=0;c<s.animateFns.length;c++){let u=s.animateFns[c],{promise:l}=u();a.push(l)}i.detachedLeaveAnimationFns=void 0}i.running=Promise.allSettled(a),RY(t,r)}else t&&ah.delete(t[Lr]),r(!1)},i)}function RY(t,n){let e=t[Aa]?.running;if(e){e.then(()=>{t[Aa].running=void 0,ah.delete(t[Lr]),n(!0)});return}n(!1)}function kY(t,n){let e=t.cleanup,r=n[Hf];if(e!==null)for(let s=0;s<e.length-1;s+=2)if(typeof e[s]=="string"){let a=e[s+3];a>=0?r[a]():r[-a].unsubscribe(),s+=2}else{let a=r[e[s+1]];e[s].call(a)}r!==null&&(n[Hf]=null);let i=n[Bn];if(i!==null){n[Bn]=null;for(let s=0;s<i.length;s++){let a=i[s];a()}}let o=n[Nr];if(o!==null){n[Nr]=null;for(let s of o)s.destroy()}}function LY(t,n){let e;if(t!=null&&(e=t.destroyHooks)!=null)for(let r=0;r<e.length;r+=2){let i=n[e[r]];if(!(i instanceof ja)){let o=e[r+1];if(Array.isArray(o))for(let s=0;s<o.length;s+=2){let a=i[o[s]],c=o[s+1];Ke(Be.LifecycleHookStart,a,c);try{c.call(a)}finally{Ke(Be.LifecycleHookEnd,a,c)}}else{Ke(Be.LifecycleHookStart,i,o);try{o.call(i)}finally{Ke(Be.LifecycleHookEnd,i,o)}}}}}function jY(t,n){if(n!==null){let r=t[Sn][kr],i=n.projection;return r.projection[i]}return null}function O_(t,n,e,r,i,o,s){for(;e!=null;){let a=r[Ti];if(e.type===128){e=e.next;continue}let c=r[e.index],u=e.type;if(s&&n===0&&(c&&C_(Mi(c),r),e.flags|=2),!aY(e))if(u&8)O_(t,n,e.child,r,i,o,!1),cs(n,t,a,i,c,e,o,r);else if(u&32){let l=iD(e,r),d;for(;d=l();)cs(n,t,a,i,d,e,o,r);cs(n,t,a,i,c,e,o,r)}else u&16?FY(t,n,r,e,i,o):cs(n,t,a,i,c,e,o,r);e=s?e.projectionNext:e.next}}function M_(t,n,e,r,i,o){O_(e,r,t.firstChild,n,i,o,!1)}function FY(t,n,e,r,i,o){let s=e[Sn],c=s[kr].projection[r.projection];if(Array.isArray(c))for(let u=0;u<c.length;u++){let l=c[u];cs(n,t,e[Ti],i,l,r,o,e)}else{let u=c,l=s[Ft];nY(r)&&(u.flags|=128),O_(t,n,u,l,i,o,!0)}}function $Y(t,n,e,r,i,o,s){let a=r[Gf],c=Mi(r);a!==c&&cs(n,t,e,o,a,i,s);for(let u=Gn;u<r.length;u++){let l=r[u];M_(l[Ae],l,t,n,o,a)}}function uD(t,n,e,r,i){let o=JT(),s=r&2;try{qr(-1),s&&n.length>jr&&IY(t,n,jr,!1);let a=s?Be.TemplateUpdateStart:Be.TemplateCreateStart;Ke(a,i,e),e(r,i)}finally{qr(o);let a=s?Be.TemplateUpdateEnd:Be.TemplateCreateEnd;Ke(a,i,e)}}function qY(t,n,e){VY(t,n,e),(e.flags&64)===64&&WY(t,n,e)}function BY(t,n,e,r){let o=r.get(sY,Qx)||e===h_.ShadowDom||e===h_.ExperimentalIsolatedShadowDom,s=t.selectRootElement(n,o);return HY(s),s}function HY(t){UY(t)}var UY=()=>null;function VY(t,n,e){let r=e.directiveStart,i=e.directiveEnd;zf(e)&&SY(n,e,t.data[r+e.componentOffset]),t.firstCreatePass||jx(e,n);let o=e.initialInputs;for(let s=r;s<i;s++){let a=t.data[s],c=u_(n,t,s,e);if(C_(c,n),o!==null&&zY(n,s-r,c,a,e,o),is(a)){let u=$r(e.index,n);u[$t]=u_(n,t,s,e)}}}function WY(t,n,e){let r=e.directiveStart,i=e.directiveEnd,o=e.index,s=KT();try{qr(o);for(let a=r;a<i;a++){let c=t.data[a],u=n[a];Yf(a),(c.hostBindings!==null||c.hostVars!==0||c.hostAttrs!==null)&&GY(c,u)}}finally{qr(-1),Yf(s)}}function GY(t,n){t.hostBindings!==null&&t.hostBindings(1,n)}function zY(t,n,e,r,i,o){let s=o[n];if(s!==null)for(let a=0;a<s.length;a+=2){let c=s[a],u=s[a+1];m_(r,e,c,u)}}function KY(t,n,e,r,i){let o=t.inputs?.[r],s=t.hostDirectiveInputs?.[r],a=!1;if(s)for(let c=0;c<s.length;c+=2){let u=s[c],l=s[c+1],d=n.data[u];m_(d,e[u],l,i),a=!0}if(o)for(let c of o){let u=e[c],l=n.data[c];m_(l,u,r,i),a=!0}return a}function YY(t,n){let e=$r(n,t),r=e[Ae];ZY(r,e);let i=e[Un];i!==null&&e[Bf]===null&&(e[Bf]=Jx(i,e[Ti])),Ke(Be.ComponentStart);try{lD(r,e,e[$t])}finally{Ke(Be.ComponentEnd,e[$t])}}function ZY(t,n){for(let e=n.length;e<t.blueprint.length;e++)n.push(t.blueprint[e])}function lD(t,n,e){Zf(n);try{let r=t.viewQuery;r!==null&&f_(1,r,e);let i=t.template;i!==null&&uD(t,n,i,1,e),t.firstCreatePass&&(t.firstCreatePass=!1),n[Uf]?.finishViewCreation(t),t.staticContentQueries&&Xx(t,n),t.staticViewQueries&&f_(2,t.viewQuery,e);let o=t.components;o!==null&&QY(n,o)}catch(r){throw t.firstCreatePass&&(t.incompleteFirstPass=!0,t.firstCreatePass=!1),r}finally{n[le]&=-5,Qf()}}function QY(t,n){for(let e=0;e<n.length;e++)YY(t,n[e])}function ch(t,n,e,r,i=!1){for(;e!==null;){if(e.type===128){e=i?e.projectionNext:e.next;continue}let o=n[e.index];o!==null&&r.push(Mi(o)),Fr(o)&&JY(o,r);let s=e.type;if(s&8)ch(t,n,e.child,r);else if(s&32){let a=iD(e,n),c;for(;c=a();)r.push(c)}else if(s&16){let a=jY(n,e);if(Array.isArray(a))r.push(...a);else{let c=Si(n[Sn]);ch(c[Ae],c,a,r,!0)}}e=i?e.projectionNext:e.next}return r}function JY(t,n){for(let e=Gn;e<t.length;e++){let r=t[e],i=r[Ae].firstChild;i!==null&&ch(r[Ae],r,i,n)}t[Gf]!==t[Un]&&n.push(t[Gf])}function dD(t){if(t[Wf]!==null){for(let n of t[Wf])n.impl.addSequence(n);t[Wf].length=0}}var fD=[];function XY(t){return t[qt]??e9(t)}function e9(t){let n=fD.pop()??Object.create(n9);return n.lView=t,n}function t9(t){t.lView[qt]!==t&&(t.lView=null,fD.push(t))}var n9={...Zo,consumerIsAlwaysLive:!0,kind:"template",consumerMarkedDirty:t=>{ss(t.lView)},consumerOnSignalRead(){this.lView[qt]=this}};function r9(t){let n=t[qt]??Object.create(i9);return n.lView=t,n}var i9={...Zo,consumerIsAlwaysLive:!0,kind:"template",consumerMarkedDirty:t=>{let n=Si(t.lView);for(;n&&!hD(n[Ae]);)n=Si(n);n&&Uv(n)},consumerOnSignalRead(){this.lView[qt]=this}};function hD(t){return t.type!==2}function pD(t){if(t[Nr]===null)return;let n=!0;for(;n;){let e=!1;for(let r of t[Nr])r.dirty&&(e=!0,r.zone===null||Zone.current===r.zone?r.run():r.zone.run(()=>r.run()));n=e&&!!(t[le]&8192)}}var o9=100;function mD(t,n=0){let r=t[Wn].rendererFactory,i=!1;i||r.begin?.();try{s9(t,n)}finally{i||r.end?.()}}function s9(t,n){let e=zv();try{Ca(!0),g_(t,n);let r=0;for(;Pa(t);){if(r===o9)throw new Re(103,!1);r++,g_(t,1)}}finally{Ca(e)}}function a9(t,n,e,r){if(Oi(n))return;let i=n[le],o=!1,s=!1;Zf(n);let a=!0,c=null,u=null;o||(hD(t)?(u=XY(n),c=_a(u)):bf()===null?(a=!1,u=r9(n),c=_a(u)):n[qt]&&(Qo(n[qt]),n[qt]=null));try{Hv(n),WT(t.bindingStartIndex),e!==null&&uD(t,n,e,2,r);let l=(i&3)===3;if(!o)if(l){let p=t.preOrderCheckHooks;p!==null&&nh(n,p,null)}else{let p=t.preOrderHooks;p!==null&&rh(n,p,0,null),n_(n,0)}if(s||c9(n),pD(n),gD(n,0),t.contentQueries!==null&&Xx(t,n),!o)if(l){let p=t.contentCheckHooks;p!==null&&nh(n,p)}else{let p=t.contentHooks;p!==null&&rh(n,p,1),n_(n,1)}l9(t,n);let d=t.components;d!==null&&vD(n,d,0);let f=t.viewQuery;if(f!==null&&f_(2,f,r),!o)if(l){let p=t.viewCheckHooks;p!==null&&nh(n,p)}else{let p=t.viewHooks;p!==null&&rh(n,p,2),n_(n,2)}if(t.firstUpdatePass===!0&&(t.firstUpdatePass=!1),n[Vf]){for(let p of n[Vf])p();n[Vf]=null}o||(dD(n),n[le]&=-73)}catch(l){throw o||ss(n),l}finally{u!==null&&(wf(u,c),a&&t9(u)),Qf()}}function gD(t,n){for(let e=Kx(t);e!==null;e=Yx(e))for(let r=Gn;r<e.length;r++){let i=e[r];yD(i,n)}}function c9(t){for(let n=Kx(t);n!==null;n=Yx(n)){if(!(n[le]&2))continue;let e=n[Na];for(let r=0;r<e.length;r++){let i=e[r];Uv(i)}}}function u9(t,n,e){Ke(Be.ComponentStart);let r=$r(n,t);try{yD(r,e)}finally{Ke(Be.ComponentEnd,r[$t])}}function yD(t,n){Kf(t)&&g_(t,n)}function g_(t,n){let r=t[Ae],i=t[le],o=t[qt],s=!!(n===0&&i&16);if(s||=!!(i&64&&n===0),s||=!!(i&1024),s||=!!(o?.dirty&&Ef(o)),s||=!1,o&&(o.dirty=!1),t[le]&=-9217,s)a9(r,t,r.template,t[$t]);else if(i&8192){let a=ge(null);try{pD(t),gD(t,1);let c=r.components;c!==null&&vD(t,c,1),dD(t)}finally{ge(a)}}}function vD(t,n,e){for(let r=0;r<n.length;r++)u9(t,n[r],e)}function l9(t,n){let e=t.hostBindingOpCodes;if(e!==null)try{for(let r=0;r<e.length;r++){let i=e[r];if(i<0)qr(~i);else{let o=i,s=e[++r],a=e[++r];zT(s,o);let c=n[o];Ke(Be.HostBindingsUpdateStart,c);try{a(2,c)}finally{Ke(Be.HostBindingsUpdateEnd,c)}}}}finally{qr(-1)}}function _D(t,n){let e=zv()?64:1088;for(t[Wn].changeDetectionScheduler?.notify(n);t;){t[le]|=e;let r=Si(t);if(os(t)&&!r)return t;t=r}return null}function d9(t,n){if(t.length<=Gn)return;let e=Gn+n,r=t[e];if(r){let i=r[Ma];i!==null&&i!==t&&D_(i,r),n>0&&(t[e-1][Vn]=r[Vn]);let o=Nv(t,Gn+n);AY(r[Ae],r);let s=o[Uf];s!==null&&s.detachView(o[Ae]),r[Ft]=null,r[Vn]=null,r[le]&=-129}return r}function f9(t,n){let e=t[Na],r=n[Ft];if(zn(r))t[le]|=2;else{let i=r[Ft][Sn];n[Sn]!==i&&(t[le]|=2)}e===null?t[Na]=[n]:e.push(n)}var y_=class{_lView;_cdRefInjectingView;_appRef=null;_attachedToViewContainer=!1;exhaustive;get rootNodes(){let n=this._lView,e=n[Ae];return ch(e,n,e.firstChild,[])}constructor(n,e){this._lView=n,this._cdRefInjectingView=e}get context(){return this._lView[$t]}set context(n){this._lView[$t]=n}get destroyed(){return Oi(this._lView)}destroy(){if(this._appRef)this._appRef.detachView(this);else if(this._attachedToViewContainer){let n=this._lView[Ft];if(Fr(n)){let e=n[jT],r=e?e.indexOf(this):-1;r>-1&&(d9(n,r),Nv(e,r))}this._attachedToViewContainer=!1}PY(this._lView[Ae],this._lView)}onDestroy(n){Wv(this._lView,n)}markForCheck(){_D(this._cdRefInjectingView||this._lView,4)}detach(){this._lView[le]&=-129}reattach(){Vv(this._lView),this._lView[le]|=128}detectChanges(){this._lView[le]|=1024,mD(this._lView)}checkNoChanges(){}attachToViewContainerRef(){if(this._appRef)throw new Re(902,!1);this._attachedToViewContainer=!0}detachFromAppRef(){this._appRef=null;let n=os(this._lView),e=this._lView[Ma];e!==null&&!n&&D_(e,this._lView),cD(this._lView[Ae],this._lView)}attachToAppRef(n){if(this._attachedToViewContainer)throw new Re(902,!1);this._appRef=n;let e=os(this._lView),r=this._lView[Ma];r!==null&&!e&&f9(r,this._lView),Vv(this._lView)}};function h9(t,n,e,r,i){let o=t.data[n];if(o===null)o=p9(t,n,e,r,i),GT()&&(o.flags|=32);else if(o.type&64){o.type=e,o.value=r,o.attrs=i;let s=HT();o.injectorIndex=s===null?-1:s.injectorIndex}return UT(o,!0),o}function p9(t,n,e,r,i){let o=Gv(),s=VT(),a=s?o:o&&o.parent,c=t.data[n]=g9(t,a,e,n,r,i);return m9(t,c,o,s),c}function m9(t,n,e,r){t.firstChild===null&&(t.firstChild=n),e!==null&&(r?e.child==null&&n.parent!==null&&(e.child=n):e.next===null&&(e.next=n,n.prev=e))}function g9(t,n,e,r,i,o){let s=n?n.injectorIndex:-1,a=0;return BT()&&(a|=128),{type:e,index:r,insertBeforeIndex:null,injectorIndex:s,directiveStart:-1,directiveEnd:-1,directiveStylingLast:-1,componentOffset:-1,fieldIndex:-1,customControlIndex:-1,propertyBindings:null,flags:a,providerIndexes:0,value:i,attrs:o,mergedAttrs:null,localNames:null,initialInputs:null,inputs:null,hostDirectiveInputs:null,outputs:null,hostDirectiveOutputs:null,directiveToIndex:null,tView:null,next:null,prev:null,projectionNext:null,child:null,parent:n,projection:null,styles:null,stylesWithoutHost:null,residualStyles:void 0,classes:null,classesWithoutHost:null,residualClasses:void 0,classBindings:0,styleBindings:0}}var bD=class{},fh=class{},v_=class{resolveComponentFactory(n){throw new Re(917,!1)}},hh=class{static NULL=new v_},Fa=class{};var wD=(()=>{class t{static \u0275prov=N({token:t,providedIn:"root",factory:()=>null})}return t})();var ih={},__=class{injector;parentInjector;constructor(n,e){this.injector=n,this.parentInjector=e}get(n,e,r){let i=this.injector.get(n,ih,r);return i!==ih||e===ih?i:this.parentInjector.get(n,e,r)}};function Ex(t,n,e){let r=e?t.styles:null,i=e?t.classes:null,o=0;if(n!==null)for(let s=0;s<n.length;s++){let a=n[s];if(typeof a=="number")o=a;else if(o==1)i=Iv(i,a);else if(o==2){let c=a,u=n[++s];r=Iv(r,c+": "+u+";")}}e?t.styles=r:t.stylesWithoutHost=r,e?t.classes=i:t.classesWithoutHost=i}function ED(t,n=0){let e=Ai();if(e===null)return Hn(t,n);let r=as();return Hx(r,e,xt(t),n)}function y9(t,n,e,r,i){let o=r===null?null:{"":-1},s=i(t,e);if(s!==null){let a=s,c=null,u=null;for(let l of s)if(l.resolveHostDirectives!==null){[a,c,u]=l.resolveHostDirectives(s);break}b9(t,n,e,a,o,c,u)}o!==null&&r!==null&&v9(e,r,o)}function v9(t,n,e){let r=t.localNames=[];for(let i=0;i<n.length;i+=2){let o=e[n[i+1]];if(o==null)throw new Re(-301,!1);r.push(n[i],o)}}function _9(t,n,e){n.componentOffset=e,(t.components??=[]).push(n.index)}function b9(t,n,e,r,i,o,s){let a=r.length,c=null;for(let f=0;f<a;f++){let p=r[f];c===null&&is(p)&&(c=p,_9(t,e,f)),Y5(jx(e,n),t,p.type)}T9(e,t.data.length,a),c?.viewProvidersResolver&&c.viewProvidersResolver(c);for(let f=0;f<a;f++){let p=r[f];p.providersResolver&&p.providersResolver(p)}let u=!1,l=!1,d=rD(t,n,a,null);a>0&&(e.directiveToIndex=new Map);for(let f=0;f<a;f++){let p=r[f];if(e.mergedAttrs=Rx(e.mergedAttrs,p.hostAttrs),E9(t,e,n,d,p),I9(d,p,i),s!==null&&s.has(p)){let[y,b]=s.get(p);e.directiveToIndex.set(p.type,[d,y+e.directiveStart,b+e.directiveStart])}else(o===null||!o.has(p))&&e.directiveToIndex.set(p.type,d);p.contentQueries!==null&&(e.flags|=4),(p.hostBindings!==null||p.hostAttrs!==null||p.hostVars!==0)&&(e.flags|=64);let m=p.type.prototype;!u&&(m.ngOnChanges||m.ngOnInit||m.ngDoCheck)&&((t.preOrderHooks??=[]).push(e.index),u=!0),!l&&(m.ngOnChanges||m.ngDoCheck)&&((t.preOrderCheckHooks??=[]).push(e.index),l=!0),d++}w9(t,e,o)}function w9(t,n,e){for(let r=n.directiveStart;r<n.directiveEnd;r++){let i=t.data[r];if(e===null||!e.has(i))Sx(0,n,i,r),Sx(1,n,i,r),Ix(n,r,!1);else{let o=e.get(i);Cx(0,n,o,r),Cx(1,n,o,r),Ix(n,r,!0)}}}function Sx(t,n,e,r){let i=t===0?e.inputs:e.outputs;for(let o in i)if(i.hasOwnProperty(o)){let s;t===0?s=n.inputs??={}:s=n.outputs??={},s[o]??=[],s[o].push(r),SD(n,o)}}function Cx(t,n,e,r){let i=t===0?e.inputs:e.outputs;for(let o in i)if(i.hasOwnProperty(o)){let s=i[o],a;t===0?a=n.hostDirectiveInputs??={}:a=n.hostDirectiveOutputs??={},a[s]??=[],a[s].push(r,o),SD(n,s)}}function SD(t,n){n==="class"?t.flags|=8:n==="style"&&(t.flags|=16)}function Ix(t,n,e){let{attrs:r,inputs:i,hostDirectiveInputs:o}=t;if(r===null||!e&&i===null||e&&o===null||yY(t)){t.initialInputs??=[],t.initialInputs.push(null);return}let s=null,a=0;for(;a<r.length;){let c=r[a];if(c===0){a+=4;continue}else if(c===5){a+=2;continue}else if(typeof c=="number")break;if(!e&&i.hasOwnProperty(c)){let u=i[c];for(let l of u)if(l===n){s??=[],s.push(c,r[a+1]);break}}else if(e&&o.hasOwnProperty(c)){let u=o[c];for(let l=0;l<u.length;l+=2)if(u[l]===n){s??=[],s.push(u[l+1],r[a+1]);break}}a+=2}t.initialInputs??=[],t.initialInputs.push(s)}function E9(t,n,e,r,i){t.data[r]=i;let o=i.factory||(i.factory=wi(i.type,!0)),s=new ja(o,is(i),ED,null);t.blueprint[r]=s,e[r]=s,S9(t,n,r,rD(t,e,i.hostVars,I_),i)}function S9(t,n,e,r,i){let o=i.hostBindings;if(o){let s=t.hostBindingOpCodes;s===null&&(s=t.hostBindingOpCodes=[]);let a=~n.index;C9(s)!=a&&s.push(a),s.push(e,r,o)}}function C9(t){let n=t.length;for(;n>0;){let e=t[--n];if(typeof e=="number"&&e<0)return e}return 0}function I9(t,n,e){if(e){if(n.exportAs)for(let r=0;r<n.exportAs.length;r++)e[n.exportAs[r]]=t;is(n)&&(e[""]=t)}}function T9(t,n,e){t.flags|=1,t.directiveStart=n,t.directiveEnd=n+e,t.providerIndexes=n}function x9(t,n,e,r,i,o,s,a){let c=n[Ae],u=c.consts,l=Bv(u,s),d=h9(c,t,e,r,l);return o&&y9(c,n,d,Bv(u,a),i),d.mergedAttrs=Rx(d.mergedAttrs,d.attrs),d.attrs!==null&&Ex(d,d.attrs,!1),d.mergedAttrs!==null&&Ex(d,d.mergedAttrs,!0),c.queries!==null&&c.queries.elementStart(c,d),d}function D9(t,n){q5(t,n),Fv(n)&&t.queries.elementEnd(n)}var b_=Symbol("BINDING");var w_=class extends hh{ngModule;constructor(n){super(),this.ngModule=n}resolveComponentFactory(n){let e=kf(n);return new E_(e,this.ngModule)}};function O9(t){return Object.keys(t).map(n=>{let[e,r,i]=t[n],o={propName:e,templateName:n,isSignal:(r&T_.SignalBased)!==0};return i&&(o.transform=i),o})}function M9(t){return Object.keys(t).map(n=>({propName:t[n],templateName:n}))}function A9(t,n,e){let r=n instanceof En?n:n?.injector;return r&&t.getStandaloneInjector!==null&&(r=t.getStandaloneInjector(r)||r),r?new __(e,r):e}function N9(t){let n=t.get(Fa,null);if(n===null)throw new Re(407,!1);let e=t.get(wD,null),r=t.get(Ci,null);return{rendererFactory:n,sanitizer:e,changeDetectionScheduler:r,ngReflect:!1}}function P9(t,n){let e=CD(t);return lY(n,e,e==="svg"?FT:e==="math"?$T:null)}function CD(t){return(t.selectors[0][0]||"div").toLowerCase()}var E_=class extends fh{componentDef;ngModule;selector;componentType;ngContentSelectors;isBoundToModule;cachedInputs=null;cachedOutputs=null;get inputs(){return this.cachedInputs??=O9(this.componentDef.inputs),this.cachedInputs}get outputs(){return this.cachedOutputs??=M9(this.componentDef.outputs),this.cachedOutputs}constructor(n,e){super(),this.componentDef=n,this.ngModule=e,this.componentType=n.type,this.selector=_Y(n.selectors),this.ngContentSelectors=n.ngContentSelectors??[],this.isBoundToModule=!!e}create(n,e,r,i,o,s){Ke(Be.DynamicComponentStart);let a=ge(null);try{let c=this.componentDef,u=R9(r,c,s,o),l=A9(c,i||this.ngModule,n),d=N9(l),f=d.rendererFactory.createRenderer(null,c),p=r?BY(f,r,c.encapsulation,l):P9(c,f),m=s?.some(Tx)||o?.some(E=>typeof E!="function"&&E.bindings.some(Tx)),y=tD(null,u,null,512|nD(c),null,null,d,f,l,null,Jx(p,l,!0));y[jr]=p,Zf(y);let b=null;try{let E=x9(jr,y,2,"#host",()=>u.directiveRegistry,!0,0);mY(f,p,E),C_(p,y),qY(u,y,E),uY(u,E,y),D9(u,E),e!==void 0&&L9(E,this.ngContentSelectors,e),b=$r(E.index,y),y[$t]=b[$t],lD(u,y,null)}catch(E){throw b!==null&&d_(b),d_(y),E}finally{Ke(Be.DynamicComponentEnd),Qf()}return new uh(this.componentType,y,!!m)}finally{ge(a)}}};function R9(t,n,e,r){let i=t?["ng-version","21.1.6"]:bY(n.selectors[0]),o=null,s=null,a=0;if(e)for(let l of e)a+=l[b_].requiredVars,l.create&&(l.targetIdx=0,(o??=[]).push(l)),l.update&&(l.targetIdx=0,(s??=[]).push(l));if(r)for(let l=0;l<r.length;l++){let d=r[l];if(typeof d!="function")for(let f of d.bindings){a+=f[b_].requiredVars;let p=l+1;f.create&&(f.targetIdx=p,(o??=[]).push(f)),f.update&&(f.targetIdx=p,(s??=[]).push(f))}}let c=[n];if(r)for(let l of r){let d=typeof l=="function"?l:l.type,f=IT(d);c.push(f)}return eD(0,null,k9(o,s),1,a,c,null,null,null,[i],null)}function k9(t,n){return!t&&!n?null:e=>{if(e&1&&t)for(let r of t)r.create();if(e&2&&n)for(let r of n)r.update()}}function Tx(t){let n=t[b_].kind;return n==="input"||n==="twoWay"}var uh=class extends bD{_rootLView;_hasInputBindings;instance;hostView;changeDetectorRef;componentType;location;previousInputValues=null;_tNode;constructor(n,e,r){super(),this._rootLView=e,this._hasInputBindings=r,this._tNode=qv(e[Ae],jr),this.location=Wx(this._tNode,e),this.instance=$r(this._tNode.index,e)[$t],this.hostView=this.changeDetectorRef=new y_(e,void 0),this.componentType=n}setInput(n,e){this._hasInputBindings;let r=this._tNode;if(this.previousInputValues??=new Map,this.previousInputValues.has(n)&&Object.is(this.previousInputValues.get(n),e))return;let i=this._rootLView,o=KY(r,i[Ae],i,n,e);this.previousInputValues.set(n,e);let s=$r(r.index,i);_D(s,1)}get injector(){return new sh(this._tNode,this._rootLView)}destroy(){this.hostView.destroy()}onDestroy(n){this.hostView.onDestroy(n)}};function L9(t,n,e){let r=t.projection=[];for(let i=0;i<n.length;i++){let o=e[i];r.push(o!=null&&o.length?Array.from(o):null)}}var lh=class{};var S_=class extends lh{injector;componentFactoryResolver=new w_(this);instance=null;constructor(n){super();let e=new Ei([...n.providers,{provide:lh,useValue:this},{provide:hh,useValue:this.componentFactoryResolver}],n.parent||Da(),n.debugName,new Set(["environment"]));this.injector=e,n.runEnvironmentInitializers&&e.resolveInjectorInitializers()}destroy(){this.injector.destroy()}onDestroy(n){this.injector.onDestroy(n)}};function A_(t,n,e=null){return new S_({providers:t,parent:n,debugName:e,runEnvironmentInitializers:!0}).injector}var ID=new _e("");function j9(t){return!!t&&typeof t.then=="function"}function TD(t){return!!t&&typeof t.subscribe=="function"}var xD=new _e("");var F9=(()=>{class t{resolve;reject;initialized=!1;done=!1;donePromise=new Promise((e,r)=>{this.resolve=e,this.reject=r});appInits=w(xD,{optional:!0})??[];injector=w(sn);constructor(){}runInitializers(){if(this.initialized)return;let e=[];for(let i of this.appInits){let o=Oa(this.injector,i);if(j9(o))e.push(o);else if(TD(o)){let s=new Promise((a,c)=>{o.subscribe({complete:a,error:c})});e.push(s)}}let r=()=>{this.done=!0,this.resolve()};Promise.all(e).then(()=>{r()}).catch(i=>{this.reject(i)}),e.length===0&&r(),this.initialized=!0}static \u0275fac=function(r){return new(r||t)};static \u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})(),$9=new _e("");function DD(t){return t.isBoundToModule}var q9=10;var B9=(()=>{class t{_runningTick=!1;_destroyed=!1;_destroyListeners=[];_views=[];internalErrorHandler=w(Jf);afterRenderManager=w(DY);zonelessEnabled=w(ka);rootEffectScheduler=w(eh);dirtyFlags=0;tracingSnapshot=null;allTestViews=new Set;autoDetectTestViews=new Set;includeAllTestViews=!1;afterTick=new dh.Subject;get allViews(){return[...(this.includeAllTestViews?this.allTestViews:this.autoDetectTestViews).keys(),...this._views]}get destroyed(){return this._destroyed}componentTypes=[];components=[];internalPendingTask=w(Ra);get isStable(){return this.internalPendingTask.hasPendingTasksObservable.pipe((0,Dx.map)(e=>!e))}constructor(){w(oD,{optional:!0})}whenStable(){let e;return new Promise(r=>{e=this.isStable.subscribe({next:i=>{i&&r()}})}).finally(()=>{e.unsubscribe()})}_injector=w(En);_rendererFactory=null;get injector(){return this._injector}bootstrap(e,r){return this.bootstrapImpl(e,r)}bootstrapImpl(e,r,i=sn.NULL){return this._injector.get(Pr).run(()=>{Ke(Be.BootstrapComponentStart);let s=e instanceof fh;if(!this._injector.get(F9).done){let m="";throw new Re(405,m)}let c;s?c=e:c=this._injector.get(hh).resolveComponentFactory(e),this.componentTypes.push(c.componentType);let u=DD(c)?void 0:this._injector.get(lh),l=r||c.selector,d=c.create(i,[],l,u),f=d.location.nativeElement,p=d.injector.get(ID,null);return p?.registerApplication(f),d.onDestroy(()=>{this.detachView(d.hostView),o_(this.components,d),p?.unregisterApplication(f)}),this._loadComponent(d),Ke(Be.BootstrapComponentEnd,d),d})}tick(){this.zonelessEnabled||(this.dirtyFlags|=1),this._tick()}_tick(){Ke(Be.ChangeDetectionStart),this.tracingSnapshot!==null?this.tracingSnapshot.run(x_.CHANGE_DETECTION,this.tickImpl):this.tickImpl()}tickImpl=()=>{if(this._runningTick)throw Ke(Be.ChangeDetectionEnd),new Re(101,!1);let e=ge(null);try{this._runningTick=!0,this.synchronize()}finally{this._runningTick=!1,this.tracingSnapshot?.dispose(),this.tracingSnapshot=null,ge(e),this.afterTick.next(),Ke(Be.ChangeDetectionEnd)}};synchronize(){this._rendererFactory===null&&!this._injector.destroyed&&(this._rendererFactory=this._injector.get(Fa,null,{optional:!0}));let e=0;for(;this.dirtyFlags!==0&&e++<q9;){Ke(Be.ChangeDetectionSyncStart);try{this.synchronizeOnce()}finally{Ke(Be.ChangeDetectionSyncEnd)}}}synchronizeOnce(){this.dirtyFlags&16&&(this.dirtyFlags&=-17,this.rootEffectScheduler.flush());let e=!1;if(this.dirtyFlags&7){let r=!!(this.dirtyFlags&1);this.dirtyFlags&=-8,this.dirtyFlags|=8;for(let{_lView:i}of this.allViews){if(!r&&!Pa(i))continue;let o=r&&!this.zonelessEnabled?0:1;mD(i,o),e=!0}if(this.dirtyFlags&=-5,this.syncDirtyFlagsWithViews(),this.dirtyFlags&23)return}e||(this._rendererFactory?.begin?.(),this._rendererFactory?.end?.()),this.dirtyFlags&8&&(this.dirtyFlags&=-9,this.afterRenderManager.execute()),this.syncDirtyFlagsWithViews()}syncDirtyFlagsWithViews(){if(this.allViews.some(({_lView:e})=>Pa(e))){this.dirtyFlags|=2;return}else this.dirtyFlags&=-8}attachView(e){let r=e;this._views.push(r),r.attachToAppRef(this)}detachView(e){let r=e;o_(this._views,r),r.detachFromAppRef()}_loadComponent(e){this.attachView(e.hostView);try{this.tick()}catch(i){this.internalErrorHandler(i)}this.components.push(e),this._injector.get($9,[]).forEach(i=>i(e))}ngOnDestroy(){if(!this._destroyed)try{this._destroyListeners.forEach(e=>e()),this._views.slice().forEach(e=>e.destroy())}finally{this._destroyed=!0,this._views=[],this._destroyListeners=[]}}onDestroy(e){return this._destroyListeners.push(e),()=>o_(this._destroyListeners,e)}destroy(){if(this._destroyed)throw new Re(406,!1);let e=this._injector;e.destroy&&!e.destroyed&&e.destroy()}get viewCount(){return this._views.length}static \u0275fac=function(r){return new(r||t)};static \u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})();function o_(t,n){let e=t.indexOf(n);e>-1&&t.splice(e,1)}var xle=(typeof ngServerMode>"u"||!ngServerMode)&&typeof document<"u"&&typeof document?.documentElement?.getAnimations=="function";var H9=(()=>{class t{applicationErrorHandler=w(Jf);appRef=w(B9);taskService=w(Ra);ngZone=w(Pr);zonelessEnabled=w(ka);tracing=w(oD,{optional:!0});zoneIsDefined=typeof Zone<"u"&&!!Zone.root.run;schedulerTickApplyArgs=[{data:{__scheduler_tick__:!0}}];subscriptions=new dh.Subscription;angularZoneId=this.zoneIsDefined?this.ngZone._inner?.get(Ia):null;scheduleInRootZone=!this.zonelessEnabled&&this.zoneIsDefined&&(w(e_,{optional:!0})??!1);cancelScheduledCallback=null;useMicrotaskScheduler=!1;runningTick=!1;pendingRenderTaskId=null;constructor(){this.subscriptions.add(this.appRef.afterTick.subscribe(()=>{let e=this.taskService.add();if(!this.runningTick&&(this.cleanup(),!this.zonelessEnabled||this.appRef.includeAllTestViews)){this.taskService.remove(e);return}this.switchToMicrotaskScheduler(),this.taskService.remove(e)})),this.subscriptions.add(this.ngZone.onUnstable.subscribe(()=>{this.runningTick||this.cleanup()}))}switchToMicrotaskScheduler(){this.ngZone.runOutsideAngular(()=>{let e=this.taskService.add();this.useMicrotaskScheduler=!0,queueMicrotask(()=>{this.useMicrotaskScheduler=!1,this.taskService.remove(e)})})}notify(e){if(!this.zonelessEnabled&&e===5)return;switch(e){case 0:{this.appRef.dirtyFlags|=2;break}case 3:case 2:case 4:case 5:case 1:{this.appRef.dirtyFlags|=4;break}case 6:{this.appRef.dirtyFlags|=2;break}case 12:{this.appRef.dirtyFlags|=16;break}case 13:{this.appRef.dirtyFlags|=2;break}case 11:break;default:this.appRef.dirtyFlags|=8}if(this.appRef.tracingSnapshot=this.tracing?.snapshot(this.appRef.tracingSnapshot)??null,!this.shouldScheduleTick())return;let r=this.useMicrotaskScheduler?nx:Qv;this.pendingRenderTaskId=this.taskService.add(),this.scheduleInRootZone?this.cancelScheduledCallback=Zone.root.run(()=>r(()=>this.tick())):this.cancelScheduledCallback=this.ngZone.runOutsideAngular(()=>r(()=>this.tick()))}shouldScheduleTick(){return!(this.appRef.destroyed||this.pendingRenderTaskId!==null||this.runningTick||this.appRef._runningTick||!this.zonelessEnabled&&this.zoneIsDefined&&Zone.current.get(Ia+this.angularZoneId))}tick(){if(this.runningTick||this.appRef.destroyed)return;if(this.appRef.dirtyFlags===0){this.cleanup();return}!this.zonelessEnabled&&this.appRef.dirtyFlags&7&&(this.appRef.dirtyFlags|=1);let e=this.taskService.add();try{this.ngZone.run(()=>{this.runningTick=!0,this.appRef._tick()},void 0,this.schedulerTickApplyArgs)}catch(r){this.applicationErrorHandler(r)}finally{this.taskService.remove(e),this.cleanup()}}ngOnDestroy(){this.subscriptions.unsubscribe(),this.cleanup()}cleanup(){if(this.runningTick=!1,this.cancelScheduledCallback?.(),this.cancelScheduledCallback=null,this.pendingRenderTaskId!==null){let e=this.pendingRenderTaskId;this.pendingRenderTaskId=null,this.taskService.remove(e)}}static \u0275fac=function(r){return new(r||t)};static \u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})();function N_(){return xY("NgZoneless"),ts([...U9(),[]])}function U9(){return[{provide:Ci,useExisting:H9},{provide:Pr,useClass:Ta},{provide:ka,useValue:!0}]}function dt(t,n){return Sf(t,n?.equal)}var K9=1e4;var dge=K9-1e3;function OD(t=[]){return Y9(t)}function Y9(t=[]){let n=t.map(r=>Z9(r)?r:ts([r]));n.push(ts([{provide:qf,useValue:"root"}])),n.push(N_());let e=A_(n,null);return Promise.resolve(e)}function Z9(t){return"\u0275providers"in t}async function P_(t,n,e=[],r){let i=t.getKeyPair(),o=t.getPeerId(),s=await n.toUuid(i.publicKey),a={};a[s]=i.publicKey;let c={};for(let u of e){if(!u)continue;let l=await n.toUuid(u);a[l]=u;let d=r?.[u];d&&(c[l]=d)}return{peerId:o,publicKey:i.publicKey,signalingId:s,privateKey:i.privateKey,peers:a,...r?{peersMeta:c}:{}}}async function $a(t){let n=new TextEncoder().encode(t),e=await crypto.subtle.digest("SHA-256",n),r=new Uint8Array(e).slice(0,16);r[0]=32,r[1]=1,r[2]=0,r[3]=42,r[6]=r[6]&15|128,r[8]=r[8]&63|128;let i=Array.from(r).map(o=>o.toString(16).padStart(2,"0")).join("");return[i.slice(0,8),i.slice(8,12),i.slice(12,16),i.slice(16,20),i.slice(20,32)].join("-")}var MD={maxAgeMs:3e4,now:()=>Date.now()};function AD(t){return new ReadableStream({start(n){n.enqueue(t),n.close()}})}async function ND(t){return new Uint8Array(await new Response(t).arrayBuffer())}async function PD(t){let n=new CompressionStream("deflate-raw");return ND(AD(t).pipeThrough(n))}async function RD(t){let n=new DecompressionStream("deflate-raw");return ND(AD(t).pipeThrough(n))}var ls=(()=>{class t{async getPeerId(e){return $a(e.publicKey)}bufferToBase64(e){let r=new Uint8Array(e),i="";for(let o=0;o<r.length;o++)i+=String.fromCharCode(r[o]);return btoa(i)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();var Hr=(()=>{class t{async encrypt(e,r){return this.encryptBytes(new TextEncoder().encode(e),r)}async decrypt(e,r,i){return new TextDecoder().decode(await this.decryptBytes(e,r,i))}base64ToBuffer(e){let r=atob(e),i=new Uint8Array(r.length);for(let o=0;o<r.length;o++)i[o]=r.charCodeAt(o);return i.buffer}bufferToBase64(e){let r=new Uint8Array(e),i="";for(let o=0;o<r.length;o++)i+=String.fromCharCode(r[o]);return btoa(i)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();var Ur=(()=>{class t{async sha256(e){let r=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(i)).map(s=>s.toString(16).padStart(2,"0")).join("")}async toUuid(e){let r=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",r),o=new Uint8Array(i).slice(0,16);o[0]=32,o[1]=1,o[2]=0,o[3]=42,o[6]=o[6]&15|128,o[8]=o[8]&63|128;let s=Array.from(o).map(a=>a.toString(16).padStart(2,"0")).join("");return[s.slice(0,8),s.slice(8,12),s.slice(12,16),s.slice(16,20),s.slice(20,32)].join("-")}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var R_=(()=>{class t extends Ur{static{this.\u0275fac=(()=>{let e;return function(i){return(e||(e=Bt(t)))(i||t)}})()}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();var Pi=(()=>{class t{canonicalStringify(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?"["+e.map(o=>this.canonicalStringify(o)).join(",")+"]":"{"+Object.keys(e).sort().filter(o=>e[o]!==void 0).map(o=>JSON.stringify(o)+":"+this.canonicalStringify(e[o])).join(",")+"}"}async sign(e,r){let i=this.canonicalStringify(e),o=await this.createSignature(i,r);return{payload:e,signature:o}}async verify(e,r){try{let i=this.canonicalStringify(e.payload);return await this.verifySignature(i,e.signature,r)?{valid:!0,verifiedBy:r}:{valid:!1,error:"Signature verification failed"}}catch(i){return{valid:!1,error:`Verification error: ${i}`}}}validateTimestamp(e,r=MD){let o=(r.now?r.now():Date.now())-e;return o>=0&&o<=r.maxAgeMs}base64ToBuffer(e){let r=atob(e),i=new Uint8Array(r.length);for(let o=0;o<r.length;o++)i[o]=r.charCodeAt(o);return i.buffer}bufferToBase64(e){let r=new Uint8Array(e),i="";for(let o=0;o<r.length;o++)i+=String.fromCharCode(r[o]);return btoa(i)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();var ds=(()=>{class t{static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();var kD=(()=>{class t{constructor(){this.keyGenerator=w(ls),this.storage=w(ds),this.keyPair=null,this.peerId=null,this._initialized=an(!1)}async initialize(){if(this._initialized())return;let e=await this.storage.load();e?this.keyPair=e:(this.keyPair=await this.keyGenerator.generateKeyPair(),await this.storage.save(this.keyPair)),this.peerId=await $a(this.keyPair.publicKey),this._initialized.set(!0)}getKeyPair(){if(!this.keyPair)throw new Error("KeyManager not initialized");return this.keyPair}getPeerId(){if(!this.peerId)throw new Error("KeyManager not initialized");return this.peerId}isInitialized(){return this._initialized()}async waitForInitialization(e=1e4){if(this._initialized())return;let r=Date.now(),i=50;return new Promise((o,s)=>{let a=()=>{if(this._initialized()){o();return}if(Date.now()-r>e){s(new Error("KeyManager initialization timeout"));return}setTimeout(a,i)};a()})}async reset(){await this.storage.delete(),this.keyPair=null,this.peerId=null,this._initialized.set(!1),await this.initialize()}async rotateKeyPair(){if(!this.keyPair)throw new Error("KeyManager not initialized");await this.storage.saveBackup(this.keyPair,Date.now());let e=await this.keyGenerator.generateKeyPair();return await this.storage.save(e),this.keyPair=e,this.peerId=await $a(e.publicKey),e}async getBackupKeyPairs(){return this.storage.loadBackups()}async cleanupOldBackups(e=10080*60*1e3){await this.storage.cleanupBackups(e)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var fs=new _e("SIGNALING_CHANNELS");function hs(t){return[{provide:fs,useFactory:t,multi:!0}]}function In(t){return typeof t=="object"&&t!==null&&"encrypted"in t&&"iv"in t&&typeof t.encrypted=="string"&&typeof t.iv=="string"}var qa=new _e("SIGNALING_MESSAGE_SENDER");function LD(t){return"lost"in t&&t.lost===!0}var He=(function(t){return t[t.DEBUG=0]="DEBUG",t[t.INFO=1]="INFO",t[t.WARN=2]="WARN",t[t.ERROR=3]="ERROR",t[t.FATAL=4]="FATAL",t[t.SILENT=5]="SILENT",t})(He||{});var ph=new _e("Logger"),jD=(()=>{class t{debug(e,r){this.log(He.DEBUG,e,r)}info(e,r){this.log(He.INFO,e,r)}warn(e,r){this.log(He.WARN,e,r)}error(e,r,i){this.log(He.ERROR,e,i,r)}fatal(e,r,i){this.log(He.FATAL,e,i,r)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();var k_=new _e("LogFilter");var Ba=(()=>{class t{constructor(){this.loggers=w(ph,{optional:!0})??[],this.filter=w(k_,{optional:!0})}getLogger(e,r){let i=(...s)=>s.map(a=>{if(typeof a=="string")return a;if(a===void 0)return"undefined";if(a===null)return"null";let c=JSON.stringify(a);return c!==void 0?c:String(a)}).join(" "),o={component:e};return r?.package!=null&&(o.package=r.package),{log:(...s)=>this.log(He.INFO,i(...s),o),debug:(...s)=>this.log(He.DEBUG,i(...s),o),info:(...s)=>this.log(He.INFO,i(...s),o),warn:(...s)=>this.log(He.WARN,i(...s),o),error:(...s)=>this.log(He.ERROR,i(...s),o),child:s=>this.getLogger(`${e}.${s}`,r)}}log(e,r,i,o){this.filter&&!this.filter(e,i)||this.loggers.forEach(s=>s.log(e,r,i,o))}close(){this.loggers.forEach(e=>e.close())}debug(e,r){this.log(He.DEBUG,e,r)}info(e,r){this.log(He.INFO,e,r)}warn(e,r){this.log(He.WARN,e,r)}error(e,r,i){this.log(He.ERROR,e,i,r)}fatal(e,r,i){this.log(He.FATAL,e,i,r)}setLogLevel(e){}setComponent(e){}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var FD=null;function $D(t){FD=t}var Ha=()=>{},qD={log:Ha,debug:Ha,info:Ha,warn:Ha,error:Ha,child:()=>qD};function j(t,n){return FD?.getLogger(t,n)??qD}var mh={prod:{hasuraUrl:"https://graphql-prod.machina.at/v1/graphql",apiNextUrl:"https://api.machina.at",signalingUrl:"https://signaling.machina.at",firebaseDatabaseUrl:"https://x-x-machina-default-rtdb.asia-southeast1.firebasedatabase.app",webServerUrl:"https://server.machina.at",invoiceAppUrl:"https://presenter.machina.at/stable"},stg:{hasuraUrl:"https://graphql-stg.machina.at/v1/graphql",apiNextUrl:"https://api.stg.machina.at",signalingUrl:"https://signaling-stg.machina.at",firebaseDatabaseUrl:"https://x-x-machina-stg.asia-southeast1.firebasedatabase.app",webServerUrl:"https://server.machina.at",invoiceAppUrl:"https://x-x-machina-invoice.web.app"}},L_={PLANX_GRAPHQL_URL:mh.prod.hasuraUrl,PLANX_CLOUD_API_URL:mh.prod.apiNextUrl,PLANX_SIGNALING_URL:mh.prod.signalingUrl,PLANX_FIREBASE_DATABASE_URL:mh.prod.firebaseDatabaseUrl};var Q9={name:"port-forward",prefix:"pf:",profile:"reliable-ordered",defaultCap:1e3,defaultBackpressureProfile:"http",buildLabel:t=>`pf:${t}`,parseLabel:t=>t.startsWith("pf:")?t.slice(3):null},J9={name:"heartbeat",prefix:"__heartbeat__",profile:"heartbeat",defaultCap:1,defaultBackpressureProfile:"control",buildLabel:()=>"__heartbeat__",parseLabel:t=>t==="__heartbeat__"?"":null},X9={name:"l7-http",prefix:"l7:http:",profile:"reliable-ordered",defaultCap:1e3,defaultBackpressureProfile:"http",buildLabel:t=>`l7:http:${t}`,parseLabel:t=>t.startsWith("l7:http:")?t.slice(8):null},eZ={name:"l7-datagram",prefix:"l7:dg:",profile:"unreliable",defaultCap:8,defaultBackpressureProfile:"terminal",buildLabel:t=>`l7:dg:${t}`,parseLabel:t=>t.startsWith("l7:dg:")?t.slice(6):null},tZ={name:"l7-qpack",prefix:"l7:qpack:",profile:"reliable-ordered",defaultCap:8,defaultBackpressureProfile:"control",buildLabel:t=>`l7:qpack:${t}`,parseLabel:t=>t.startsWith("l7:qpack:")?t.slice(9):null},ps={portForward:Q9,heartbeat:J9,l7Http:X9,l7Dg:eZ,l7Qpack:tZ};var j_=(t,n,e)=>(r,i)=>{let o=-1;return s(0);async function s(a){if(a<=o)throw new Error("next() called multiple times");o=a;let c,u=!1,l;if(t[a]?(l=t[a][0][0],r.req.routeIndex=a):l=a===t.length&&i||void 0,l)try{c=await l(r,()=>s(a+1))}catch(d){if(d instanceof Error&&n)r.error=d,c=await n(d,r),u=!0;else throw d}else r.finalized===!1&&e&&(c=await e(r));return c&&(r.finalized===!1||u)&&(r.res=c),r}};var BD=Symbol();var HD=async(t,n=Object.create(null))=>{let{all:e=!1,dot:r=!1}=n,o=(t instanceof gh?t.raw.headers:t.headers).get("Content-Type");return o?.startsWith("multipart/form-data")||o?.startsWith("application/x-www-form-urlencoded")?nZ(t,{all:e,dot:r}):{}};async function nZ(t,n){let e=await t.formData();return e?rZ(e,n):{}}function rZ(t,n){let e=Object.create(null);return t.forEach((r,i)=>{n.all||i.endsWith("[]")?iZ(e,i,r):e[i]=r}),n.dot&&Object.entries(e).forEach(([r,i])=>{r.includes(".")&&(oZ(e,r,i),delete e[r])}),e}var iZ=(t,n,e)=>{t[n]!==void 0?Array.isArray(t[n])?t[n].push(e):t[n]=[t[n],e]:n.endsWith("[]")?t[n]=[e]:t[n]=e},oZ=(t,n,e)=>{let r=t,i=n.split(".");i.forEach((o,s)=>{s===i.length-1?r[o]=e:((!r[o]||typeof r[o]!="object"||Array.isArray(r[o])||r[o]instanceof File)&&(r[o]=Object.create(null)),r=r[o])})};var $_=t=>{let n=t.split("/");return n[0]===""&&n.shift(),n},UD=t=>{let{groups:n,path:e}=sZ(t),r=$_(e);return aZ(r,n)},sZ=t=>{let n=[];return t=t.replace(/\{[^}]+\}/g,(e,r)=>{let i=`@${r}`;return n.push([i,e]),i}),{groups:n,path:t}},aZ=(t,n)=>{for(let e=n.length-1;e>=0;e--){let[r]=n[e];for(let i=t.length-1;i>=0;i--)if(t[i].includes(r)){t[i]=t[i].replace(r,n[e][1]);break}}return t},yh={},VD=(t,n)=>{if(t==="*")return"*";let e=t.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(e){let r=`${t}#${n}`;return yh[r]||(e[2]?yh[r]=n&&n[0]!==":"&&n[0]!=="*"?[r,e[1],new RegExp(`^${e[2]}(?=/${n})`)]:[t,e[1],new RegExp(`^${e[2]}$`)]:yh[r]=[t,e[1],!0]),yh[r]}return null},vh=(t,n)=>{try{return n(t)}catch{return t.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return n(e)}catch{return e}})}},cZ=t=>vh(t,decodeURI),q_=t=>{let n=t.url,e=n.indexOf("/",n.indexOf(":")+4),r=e;for(;r<n.length;r++){let i=n.charCodeAt(r);if(i===37){let o=n.indexOf("?",r),s=n.slice(e,o===-1?void 0:o);return cZ(s.includes("%25")?s.replace(/%25/g,"%2525"):s)}else if(i===63)break}return n.slice(e,r)};var WD=t=>{let n=q_(t);return n.length>1&&n.at(-1)==="/"?n.slice(0,-1):n},Ri=(t,n,...e)=>(e.length&&(n=Ri(n,...e)),`${t?.[0]==="/"?"":"/"}${t}${n==="/"?"":`${t?.at(-1)==="/"?"":"/"}${n?.[0]==="/"?n.slice(1):n}`}`),_h=t=>{if(t.charCodeAt(t.length-1)!==63||!t.includes(":"))return null;let n=t.split("/"),e=[],r="";return n.forEach(i=>{if(i!==""&&!/\:/.test(i))r+="/"+i;else if(/\:/.test(i))if(/\?/.test(i)){e.length===0&&r===""?e.push("/"):e.push(r);let o=i.replace("?","");r+="/"+o,e.push(r)}else r+="/"+i}),e.filter((i,o,s)=>s.indexOf(i)===o)},F_=t=>/[%+]/.test(t)?(t.indexOf("+")!==-1&&(t=t.replace(/\+/g," ")),t.indexOf("%")!==-1?vh(t,B_):t):t,GD=(t,n,e)=>{let r;if(!e&&n&&!/[%+]/.test(n)){let s=t.indexOf(`?${n}`,8);for(s===-1&&(s=t.indexOf(`&${n}`,8));s!==-1;){let a=t.charCodeAt(s+n.length+1);if(a===61){let c=s+n.length+2,u=t.indexOf("&",c);return F_(t.slice(c,u===-1?void 0:u))}else if(a==38||isNaN(a))return"";s=t.indexOf(`&${n}`,s+1)}if(r=/[%+]/.test(t),!r)return}let i={};r??=/[%+]/.test(t);let o=t.indexOf("?",8);for(;o!==-1;){let s=t.indexOf("&",o+1),a=t.indexOf("=",o);a>s&&s!==-1&&(a=-1);let c=t.slice(o+1,a===-1?s===-1?void 0:s:a);if(r&&(c=F_(c)),o=s,c==="")continue;let u;a===-1?u="":(u=t.slice(a+1,s===-1?void 0:s),r&&(u=F_(u))),e?(i[c]&&Array.isArray(i[c])||(i[c]=[]),i[c].push(u)):i[c]??=u}return n?i[n]:i},zD=GD,KD=(t,n)=>GD(t,n,!0),B_=decodeURIComponent;var YD=t=>vh(t,B_),gh=class{raw;#t;#e;routeIndex=0;path;bodyCache={};constructor(t,n="/",e=[[]]){this.raw=t,this.path=n,this.#e=e,this.#t={}}param(t){return t?this.#n(t):this.#o()}#n(t){let n=this.#e[0][this.routeIndex][1][t],e=this.#i(n);return e&&/\%/.test(e)?YD(e):e}#o(){let t={},n=Object.keys(this.#e[0][this.routeIndex][1]);for(let e of n){let r=this.#i(this.#e[0][this.routeIndex][1][e]);r!==void 0&&(t[e]=/\%/.test(r)?YD(r):r)}return t}#i(t){return this.#e[1]?this.#e[1][t]:t}query(t){return zD(this.url,t)}queries(t){return KD(this.url,t)}header(t){if(t)return this.raw.headers.get(t)??void 0;let n={};return this.raw.headers.forEach((e,r)=>{n[r]=e}),n}async parseBody(t){return this.bodyCache.parsedBody??=await HD(this,t)}#r=t=>{let{bodyCache:n,raw:e}=this,r=n[t];if(r)return r;let i=Object.keys(n)[0];return i?n[i].then(o=>(i==="json"&&(o=JSON.stringify(o)),new Response(o)[t]())):n[t]=e[t]()};json(){return this.#r("text").then(t=>JSON.parse(t))}text(){return this.#r("text")}arrayBuffer(){return this.#r("arrayBuffer")}blob(){return this.#r("blob")}formData(){return this.#r("formData")}addValidatedData(t,n){this.#t[t]=n}valid(t){return this.#t[t]}get url(){return this.raw.url}get method(){return this.raw.method}get[BD](){return this.#e}get matchedRoutes(){return this.#e[0].map(([[,t]])=>t)}get routePath(){return this.#e[0].map(([[,t]])=>t)[this.routeIndex].path}};var ZD={Stringify:1,BeforeStream:2,Stream:3},uZ=(t,n)=>{let e=new String(t);return e.isEscaped=!0,e.callbacks=n,e};var H_=async(t,n,e,r,i)=>{typeof t=="object"&&!(t instanceof String)&&(t instanceof Promise||(t=t.toString()),t instanceof Promise&&(t=await t));let o=t.callbacks;if(!o?.length)return Promise.resolve(t);i?i[0]+=t:i=[t];let s=Promise.all(o.map(a=>a({phase:n,buffer:i,context:r}))).then(a=>Promise.all(a.filter(Boolean).map(c=>H_(c,n,!1,r,i))).then(()=>i[0]));return e?uZ(await s,o):s};var lZ="text/plain; charset=UTF-8",U_=(t,n)=>({"Content-Type":t,...n}),QD=class{#t;#e;env={};#n;finalized=!1;error;#o;#i;#r;#l;#c;#u;#a;#d;#f;constructor(t,n){this.#t=t,n&&(this.#i=n.executionCtx,this.env=n.env,this.#u=n.notFoundHandler,this.#f=n.path,this.#d=n.matchResult)}get req(){return this.#e??=new gh(this.#t,this.#f,this.#d),this.#e}get event(){if(this.#i&&"respondWith"in this.#i)return this.#i;throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#i)return this.#i;throw Error("This context has no ExecutionContext")}get res(){return this.#r||=new Response(null,{headers:this.#a??=new Headers})}set res(t){if(this.#r&&t){t=new Response(t.body,t);for(let[n,e]of this.#r.headers.entries())if(n!=="content-type")if(n==="set-cookie"){let r=this.#r.headers.getSetCookie();t.headers.delete("set-cookie");for(let i of r)t.headers.append("set-cookie",i)}else t.headers.set(n,e)}this.#r=t,this.finalized=!0}render=(...t)=>(this.#c??=n=>this.html(n),this.#c(...t));setLayout=t=>this.#l=t;getLayout=()=>this.#l;setRenderer=t=>{this.#c=t};header=(t,n,e)=>{this.finalized&&(this.#r=new Response(this.#r.body,this.#r));let r=this.#r?this.#r.headers:this.#a??=new Headers;n===void 0?r.delete(t):e?.append?r.append(t,n):r.set(t,n)};status=t=>{this.#o=t};set=(t,n)=>{this.#n??=new Map,this.#n.set(t,n)};get=t=>this.#n?this.#n.get(t):void 0;get var(){return this.#n?Object.fromEntries(this.#n):{}}#s(t,n,e){let r=this.#r?new Headers(this.#r.headers):this.#a??new Headers;if(typeof n=="object"&&"headers"in n){let o=n.headers instanceof Headers?n.headers:new Headers(n.headers);for(let[s,a]of o)s.toLowerCase()==="set-cookie"?r.append(s,a):r.set(s,a)}if(e)for(let[o,s]of Object.entries(e))if(typeof s=="string")r.set(o,s);else{r.delete(o);for(let a of s)r.append(o,a)}let i=typeof n=="number"?n:n?.status??this.#o;return new Response(t,{status:i,headers:r})}newResponse=(...t)=>this.#s(...t);body=(t,n,e)=>this.#s(t,n,e);text=(t,n,e)=>!this.#a&&!this.#o&&!n&&!e&&!this.finalized?new Response(t):this.#s(t,n,U_(lZ,e));json=(t,n,e)=>this.#s(JSON.stringify(t),n,U_("application/json",e));html=(t,n,e)=>{let r=i=>this.#s(i,n,U_("text/html; charset=UTF-8",e));return typeof t=="object"?H_(t,ZD.Stringify,!1,{}).then(r):r(t)};redirect=(t,n)=>{let e=String(t);return this.header("Location",/[^\x00-\xFF]/.test(e)?encodeURI(e):e),this.newResponse(null,n??302)};notFound=()=>(this.#u??=()=>new Response,this.#u(this))};var ze="ALL",JD="all",XD=["get","post","put","delete","options","patch"],bh="Can not add a route since the matcher is already built.",wh=class extends Error{};var e0="__COMPOSED_HANDLER";var dZ=t=>t.text("404 Not Found",404),t0=(t,n)=>{if("getResponse"in t){let e=t.getResponse();return n.newResponse(e.body,e)}return console.error(t),n.text("Internal Server Error",500)},V_=class{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath="/";#t="/";routes=[];constructor(t={}){[...XD,JD].forEach(i=>{this[i]=(o,...s)=>(typeof o=="string"?this.#t=o:this.#o(i,this.#t,o),s.forEach(a=>{this.#o(i,this.#t,a)}),this)}),this.on=(i,o,...s)=>{for(let a of[o].flat()){this.#t=a;for(let c of[i].flat())s.map(u=>{this.#o(c.toUpperCase(),this.#t,u)})}return this},this.use=(i,...o)=>(typeof i=="string"?this.#t=i:(this.#t="*",o.unshift(i)),o.forEach(s=>{this.#o(ze,this.#t,s)}),this);let{strict:e,...r}=t;Object.assign(this,r),this.getPath=e??!0?t.getPath??q_:WD}#e(){let t=new V_({router:this.router,getPath:this.getPath});return t.errorHandler=this.errorHandler,t.#n=this.#n,t.routes=this.routes,t}#n=dZ;errorHandler=t0;route(t,n){let e=this.basePath(t);return n.routes.map(r=>{let i;n.errorHandler===t0?i=r.handler:(i=async(o,s)=>(await j_([],n.errorHandler)(o,()=>r.handler(o,s))).res,i[e0]=r.handler),e.#o(r.method,r.path,i)}),this}basePath(t){let n=this.#e();return n._basePath=Ri(this._basePath,t),n}onError=t=>(this.errorHandler=t,this);notFound=t=>(this.#n=t,this);mount(t,n,e){let r,i;e&&(typeof e=="function"?i=e:(i=e.optionHandler,e.replaceRequest===!1?r=a=>a:r=e.replaceRequest));let o=i?a=>{let c=i(a);return Array.isArray(c)?c:[c]}:a=>{let c;try{c=a.executionCtx}catch{}return[a.env,c]};r||=(()=>{let a=Ri(this._basePath,t),c=a==="/"?0:a.length;return u=>{let l=new URL(u.url);return l.pathname=l.pathname.slice(c)||"/",new Request(l,u)}})();let s=async(a,c)=>{let u=await n(r(a.req.raw),...o(a));if(u)return u;await c()};return this.#o(ze,Ri(t,"*"),s),this}#o(t,n,e){t=t.toUpperCase(),n=Ri(this._basePath,n);let r={basePath:this._basePath,path:n,method:t,handler:e};this.router.add(t,n,[e,r]),this.routes.push(r)}#i(t,n){if(t instanceof Error)return this.errorHandler(t,n);throw t}#r(t,n,e,r){if(r==="HEAD")return(async()=>new Response(null,await this.#r(t,n,e,"GET")))();let i=this.getPath(t,{env:e}),o=this.router.match(r,i),s=new QD(t,{path:i,matchResult:o,env:e,executionCtx:n,notFoundHandler:this.#n});if(o[0].length===1){let c;try{c=o[0][0][0][0](s,async()=>{s.res=await this.#n(s)})}catch(u){return this.#i(u,s)}return c instanceof Promise?c.then(u=>u||(s.finalized?s.res:this.#n(s))).catch(u=>this.#i(u,s)):c??this.#n(s)}let a=j_(o[0],this.errorHandler,this.#n);return(async()=>{try{let c=await a(s);if(!c.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return c.res}catch(c){return this.#i(c,s)}})()}fetch=(t,...n)=>this.#r(t,n[1],n[0],t.method);request=(t,n,e,r)=>t instanceof Request?this.fetch(n?new Request(t,n):t,e,r):(t=t.toString(),this.fetch(new Request(/^https?:\/\//.test(t)?t:`http://localhost${Ri("/",t)}`,n),e,r));fire=()=>{addEventListener("fetch",t=>{t.respondWith(this.#r(t.request,t,void 0,t.request.method))})}};var Eh=[];function W_(t,n){let e=this.buildAllMatchers(),r=(i,o)=>{let s=e[i]||e[ze],a=s[2][o];if(a)return a;let c=o.match(s[0]);if(!c)return[[],Eh];let u=c.indexOf("",1);return[s[1][u],c]};return this.match=r,r(t,n)}var Sh="[^/]+",Ua=".*",Va="(?:|/.*)",ki=Symbol(),fZ=new Set(".\\+*[^]$()");function hZ(t,n){return t.length===1?n.length===1?t<n?-1:1:-1:n.length===1||t===Ua||t===Va?1:n===Ua||n===Va?-1:t===Sh?1:n===Sh?-1:t.length===n.length?t<n?-1:1:n.length-t.length}var Ch=class{#t;#e;#n=Object.create(null);insert(t,n,e,r,i){if(t.length===0){if(this.#t!==void 0)throw ki;if(i)return;this.#t=n;return}let[o,...s]=t,a=o==="*"?s.length===0?["","",Ua]:["","",Sh]:o==="/*"?["","",Va]:o.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),c;if(a){let u=a[1],l=a[2]||Sh;if(u&&a[2]&&(l===".*"||(l=l.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(l))))throw ki;if(c=this.#n[l],!c){if(Object.keys(this.#n).some(d=>d!==Ua&&d!==Va))throw ki;if(i)return;c=this.#n[l]=new Ch,u!==""&&(c.#e=r.varIndex++)}!i&&u!==""&&e.push([u,c.#e])}else if(c=this.#n[o],!c){if(Object.keys(this.#n).some(u=>u.length>1&&u!==Ua&&u!==Va))throw ki;if(i)return;c=this.#n[o]=new Ch}c.insert(s,n,e,r,i)}buildRegExpStr(){let n=Object.keys(this.#n).sort(hZ).map(e=>{let r=this.#n[e];return(typeof r.#e=="number"?`(${e})@${r.#e}`:fZ.has(e)?`\\${e}`:e)+r.buildRegExpStr()});return typeof this.#t=="number"&&n.unshift(`#${this.#t}`),n.length===0?"":n.length===1?n[0]:"(?:"+n.join("|")+")"}};var n0=class{#t={varIndex:0};#e=new Ch;insert(t,n,e){let r=[],i=[];for(let s=0;;){let a=!1;if(t=t.replace(/\{[^}]+\}/g,c=>{let u=`@\\${s}`;return i[s]=[u,c],s++,a=!0,u}),!a)break}let o=t.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let s=i.length-1;s>=0;s--){let[a]=i[s];for(let c=o.length-1;c>=0;c--)if(o[c].indexOf(a)!==-1){o[c]=o[c].replace(a,i[s][1]);break}}return this.#e.insert(o,n,r,this.#t,e),r}buildRegExp(){let t=this.#e.buildRegExpStr();if(t==="")return[/^$/,[],[]];let n=0,e=[],r=[];return t=t.replace(/#(\d+)|@(\d+)|\.\*\$/g,(i,o,s)=>o!==void 0?(e[++n]=Number(o),"$()"):(s!==void 0&&(r[Number(s)]=++n),"")),[new RegExp(`^${t}`),e,r]}};var pZ=[/^$/,[],Object.create(null)],r0=Object.create(null);function i0(t){return r0[t]??=new RegExp(t==="*"?"":`^${t.replace(/\/\*$|([.\\+*[^\]$()])/g,(n,e)=>e?`\\${e}`:"(?:|/.*)")}$`)}function mZ(){r0=Object.create(null)}function gZ(t){let n=new n0,e=[];if(t.length===0)return pZ;let r=t.map(u=>[!/\*|\/:/.test(u[0]),...u]).sort(([u,l],[d,f])=>u?1:d?-1:l.length-f.length),i=Object.create(null);for(let u=0,l=-1,d=r.length;u<d;u++){let[f,p,m]=r[u];f?i[p]=[m.map(([b])=>[b,Object.create(null)]),Eh]:l++;let y;try{y=n.insert(p,l,f)}catch(b){throw b===ki?new wh(p):b}f||(e[l]=m.map(([b,E])=>{let D=Object.create(null);for(E-=1;E>=0;E--){let[T,K]=y[E];D[T]=K}return[b,D]}))}let[o,s,a]=n.buildRegExp();for(let u=0,l=e.length;u<l;u++)for(let d=0,f=e[u].length;d<f;d++){let p=e[u][d]?.[1];if(!p)continue;let m=Object.keys(p);for(let y=0,b=m.length;y<b;y++)p[m[y]]=a[p[m[y]]]}let c=[];for(let u in s)c[u]=e[s[u]];return[o,c,i]}function ms(t,n){if(t){for(let e of Object.keys(t).sort((r,i)=>i.length-r.length))if(i0(e).test(n))return[...t[e]]}}var Ih=class{name="RegExpRouter";#t;#e;constructor(){this.#t={[ze]:Object.create(null)},this.#e={[ze]:Object.create(null)}}add(t,n,e){let r=this.#t,i=this.#e;if(!r||!i)throw new Error(bh);r[t]||[r,i].forEach(a=>{a[t]=Object.create(null),Object.keys(a[ze]).forEach(c=>{a[t][c]=[...a[ze][c]]})}),n==="/*"&&(n="*");let o=(n.match(/\/:/g)||[]).length;if(/\*$/.test(n)){let a=i0(n);t===ze?Object.keys(r).forEach(c=>{r[c][n]||=ms(r[c],n)||ms(r[ze],n)||[]}):r[t][n]||=ms(r[t],n)||ms(r[ze],n)||[],Object.keys(r).forEach(c=>{(t===ze||t===c)&&Object.keys(r[c]).forEach(u=>{a.test(u)&&r[c][u].push([e,o])})}),Object.keys(i).forEach(c=>{(t===ze||t===c)&&Object.keys(i[c]).forEach(u=>a.test(u)&&i[c][u].push([e,o]))});return}let s=_h(n)||[n];for(let a=0,c=s.length;a<c;a++){let u=s[a];Object.keys(i).forEach(l=>{(t===ze||t===l)&&(i[l][u]||=[...ms(r[l],u)||ms(r[ze],u)||[]],i[l][u].push([e,o-c+a+1]))})}}match=W_;buildAllMatchers(){let t=Object.create(null);return Object.keys(this.#e).concat(Object.keys(this.#t)).forEach(n=>{t[n]||=this.#n(n)}),this.#t=this.#e=void 0,mZ(),t}#n(t){let n=[],e=t===ze;return[this.#t,this.#e].forEach(r=>{let i=r[t]?Object.keys(r[t]).map(o=>[o,r[t][o]]):[];i.length!==0?(e||=!0,n.push(...i)):t!==ze&&n.push(...Object.keys(r[ze]).map(o=>[o,r[ze][o]]))}),e?gZ(n):null}};var G_=class{name="SmartRouter";#t=[];#e=[];constructor(t){this.#t=t.routers}add(t,n,e){if(!this.#e)throw new Error(bh);this.#e.push([t,n,e])}match(t,n){if(!this.#e)throw new Error("Fatal error");let e=this.#t,r=this.#e,i=e.length,o=0,s;for(;o<i;o++){let a=e[o];try{for(let c=0,u=r.length;c<u;c++)a.add(...r[c]);s=a.match(t,n)}catch(c){if(c instanceof wh)continue;throw c}this.match=a.match.bind(a),this.#t=[a],this.#e=void 0;break}if(o===i)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,s}get activeRouter(){if(this.#e||this.#t.length!==1)throw new Error("No active router has been determined yet.");return this.#t[0]}};var Wa=Object.create(null),z_=class{#t;#e;#n;#o=0;#i=Wa;constructor(t,n,e){if(this.#e=e||Object.create(null),this.#t=[],t&&n){let r=Object.create(null);r[t]={handler:n,possibleKeys:[],score:0},this.#t=[r]}this.#n=[]}insert(t,n,e){this.#o=++this.#o;let r=this,i=UD(n),o=[];for(let s=0,a=i.length;s<a;s++){let c=i[s],u=i[s+1],l=VD(c,u),d=Array.isArray(l)?l[0]:c;if(d in r.#e){r=r.#e[d],l&&o.push(l[1]);continue}r.#e[d]=new z_,l&&(r.#n.push(l),o.push(l[1])),r=r.#e[d]}return r.#t.push({[t]:{handler:e,possibleKeys:o.filter((s,a,c)=>c.indexOf(s)===a),score:this.#o}}),r}#r(t,n,e,r){let i=[];for(let o=0,s=t.#t.length;o<s;o++){let a=t.#t[o],c=a[n]||a[ze],u={};if(c!==void 0&&(c.params=Object.create(null),i.push(c),e!==Wa||r&&r!==Wa))for(let l=0,d=c.possibleKeys.length;l<d;l++){let f=c.possibleKeys[l],p=u[c.score];c.params[f]=r?.[f]&&!p?r[f]:e[f]??r?.[f],u[c.score]=!0}}return i}search(t,n){let e=[];this.#i=Wa;let i=[this],o=$_(n),s=[];for(let a=0,c=o.length;a<c;a++){let u=o[a],l=a===c-1,d=[];for(let f=0,p=i.length;f<p;f++){let m=i[f],y=m.#e[u];y&&(y.#i=m.#i,l?(y.#e["*"]&&e.push(...this.#r(y.#e["*"],t,m.#i)),e.push(...this.#r(y,t,m.#i))):d.push(y));for(let b=0,E=m.#n.length;b<E;b++){let D=m.#n[b],T=m.#i===Wa?{}:{...m.#i};if(D==="*"){let z=m.#e["*"];z&&(e.push(...this.#r(z,t,m.#i)),z.#i=T,d.push(z));continue}let[K,H,re]=D;if(!u&&!(re instanceof RegExp))continue;let Ee=m.#e[K],pe=o.slice(a).join("/");if(re instanceof RegExp){let z=re.exec(pe);if(z){if(T[H]=z[0],e.push(...this.#r(Ee,t,m.#i,T)),Object.keys(Ee.#e).length){Ee.#i=T;let rt=z[0].match(/\//)?.length??0;(s[rt]||=[]).push(Ee)}continue}}(re===!0||re.test(u))&&(T[H]=u,l?(e.push(...this.#r(Ee,t,T,m.#i)),Ee.#e["*"]&&e.push(...this.#r(Ee.#e["*"],t,T,m.#i))):(Ee.#i=T,d.push(Ee)))}}i=d.concat(s.shift()??[])}return e.length>1&&e.sort((a,c)=>a.score-c.score),[e.map(({handler:a,params:c})=>[a,c])]}};var K_=class{name="TrieRouter";#t;constructor(){this.#t=new z_}add(t,n,e){let r=_h(n);if(r){for(let i=0,o=r.length;i<o;i++)this.#t.insert(t,r[i],e);return}this.#t.insert(t,n,e)}match(t,n){return this.#t.search(t,n)}};var Y_=class extends V_{constructor(t={}){super(t),this.router=t.router??new G_({routers:[new Ih,new K_]})}};function yZ(){let{process:t,Deno:n}=globalThis;return!(typeof n?.noColor=="boolean"?n.noColor:t!==void 0?"NO_COLOR"in t?.env:!1)}async function o0(){let{navigator:t}=globalThis,n="cloudflare:workers";return!(t!==void 0&&t.userAgent==="Cloudflare-Workers"?await(async()=>{try{return"NO_COLOR"in((await import(n)).env??{})}catch{return!1}})():!yZ())}var vZ=t=>{let[n,e]=[",","."];return t.map(i=>i.replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1"+n)).join(e)},_Z=t=>{let n=Date.now()-t;return vZ([n<1e3?n+"ms":Math.round(n/1e3)+"s"])},bZ=async t=>{if(await o0())switch(t/100|0){case 5:return`\x1B[31m${t}\x1B[0m`;case 4:return`\x1B[33m${t}\x1B[0m`;case 3:return`\x1B[36m${t}\x1B[0m`;case 2:return`\x1B[32m${t}\x1B[0m`}return`${t}`};async function s0(t,n,e,r,i=0,o){let s=n==="<--"?`${n} ${e} ${r}`:`${n} ${e} ${r} ${await bZ(i)} ${o}`;t(s)}var a0=(t=console.log)=>async function(e,r){let{method:i,url:o}=e.req,s=o.slice(o.indexOf("/",8));await s0(t,"<--",i,s);let a=Date.now();await r(),await s0(t,"-->",i,s,e.res.status,_Z(a))};function Th(t,...n){let e=Object.assign(Ht(),t);for(let r of n)for(let i in r){if(i in e&&e[i]!==r[i])throw new Error(`Duplicate key ${i}`);e[i]=r[i]}return e}function ft(t){return!!t&&!Array.isArray(t)&&typeof t=="object"}function xh(t){return typeof t=="function"}function Ht(){return Object.create(null)}var wZ=typeof Symbol=="function"&&!!Symbol.asyncIterator;function Ga(t){return wZ&&ft(t)&&Symbol.asyncIterator in t}var za=t=>t();function c0(t){return t}function u0(t){if(typeof AbortSignal.any=="function")return AbortSignal.any(t);let n=new AbortController;for(let r of t){if(r.aborted){e();break}r.addEventListener("abort",e,{once:!0})}return n.signal;function e(){n.abort();for(let r of t)r.removeEventListener("abort",e)}}var gs={PARSE_ERROR:-32700,BAD_REQUEST:-32600,INTERNAL_SERVER_ERROR:-32603,NOT_IMPLEMENTED:-32603,BAD_GATEWAY:-32603,SERVICE_UNAVAILABLE:-32603,GATEWAY_TIMEOUT:-32603,UNAUTHORIZED:-32001,PAYMENT_REQUIRED:-32002,FORBIDDEN:-32003,NOT_FOUND:-32004,METHOD_NOT_SUPPORTED:-32005,TIMEOUT:-32008,CONFLICT:-32009,PRECONDITION_FAILED:-32012,PAYLOAD_TOO_LARGE:-32013,UNSUPPORTED_MEDIA_TYPE:-32015,UNPROCESSABLE_CONTENT:-32022,PRECONDITION_REQUIRED:-32028,TOO_MANY_REQUESTS:-32029,CLIENT_CLOSED_REQUEST:-32099},l0={[-32700]:"PARSE_ERROR",[-32600]:"BAD_REQUEST",[-32603]:"INTERNAL_SERVER_ERROR",[-32001]:"UNAUTHORIZED",[-32002]:"PAYMENT_REQUIRED",[-32003]:"FORBIDDEN",[-32004]:"NOT_FOUND",[-32005]:"METHOD_NOT_SUPPORTED",[-32008]:"TIMEOUT",[-32009]:"CONFLICT",[-32012]:"PRECONDITION_FAILED",[-32013]:"PAYLOAD_TOO_LARGE",[-32015]:"UNSUPPORTED_MEDIA_TYPE",[-32022]:"UNPROCESSABLE_CONTENT",[-32028]:"PRECONDITION_REQUIRED",[-32029]:"TOO_MANY_REQUESTS",[-32099]:"CLIENT_CLOSED_REQUEST"},Owe=[gs.BAD_GATEWAY,gs.SERVICE_UNAVAILABLE,gs.GATEWAY_TIMEOUT,gs.INTERNAL_SERVER_ERROR];var EZ=Object.create,h0=Object.defineProperty,SZ=Object.getOwnPropertyDescriptor,p0=Object.getOwnPropertyNames,CZ=Object.getPrototypeOf,IZ=Object.prototype.hasOwnProperty,wt=(t,n)=>function(){return n||(0,t[p0(t)[0]])((n={exports:{}}).exports,n),n.exports},TZ=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(var i=p0(n),o=0,s=i.length,a;o<s;o++)a=i[o],!IZ.call(t,a)&&a!==e&&h0(t,a,{get:(c=>n[c]).bind(null,a),enumerable:!(r=SZ(n,a))||r.enumerable});return t},Se=(t,n,e)=>(e=t!=null?EZ(CZ(t)):{},TZ(n||!t||!t.__esModule?h0(e,"default",{value:t,enumerable:!0}):e,t)),xZ=()=>{},d0=t=>{Object.freeze&&Object.freeze(t)};function m0(t,n,e){var r;let i=n.join(".");return(r=e[i])!==null&&r!==void 0||(e[i]=new Proxy(xZ,{get(o,s){if(!(typeof s!="string"||s==="then"))return m0(t,[...n,s],e)},apply(o,s,a){let c=n[n.length-1],u={args:a,path:n};return c==="call"?u={args:a.length>=2?[a[1]]:[],path:n.slice(0,-1)}:c==="apply"&&(u={args:a.length>=2?a[1]:[],path:n.slice(0,-1)}),d0(u.args),d0(u.path),t(u)}})),e[i]}var g0=t=>m0(t,[],Ht());var DZ={PARSE_ERROR:400,BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_SUPPORTED:405,TIMEOUT:408,CONFLICT:409,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,UNSUPPORTED_MEDIA_TYPE:415,UNPROCESSABLE_CONTENT:422,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,CLIENT_CLOSED_REQUEST:499,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504};function y0(t){var n;return(n=DZ[t])!==null&&n!==void 0?n:500}function v0(t){let n=Array.isArray(t)?t:[t],e=new Set(n.map(i=>{if("error"in i&&ft(i.error.data)){var o;if(typeof((o=i.error.data)===null||o===void 0?void 0:o.httpStatus)=="number")return i.error.data.httpStatus;let s=l0[i.error.code];return y0(s)}return 200}));return e.size!==1?207:e.values().next().value}function OZ(t){return y0(t.code)}var _0=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(t,n){function e(r){"@babel/helpers - typeof";return n.exports=e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(i){return typeof i}:function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},n.exports.__esModule=!0,n.exports.default=n.exports,e(r)}n.exports=e,n.exports.__esModule=!0,n.exports.default=n.exports}}),MZ=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(t,n){var e=_0().default;function r(i,o){if(e(i)!="object"||!i)return i;var s=i[Symbol.toPrimitive];if(s!==void 0){var a=s.call(i,o||"default");if(e(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(i)}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),AZ=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(t,n){var e=_0().default,r=MZ();function i(o){var s=r(o,"string");return e(s)=="symbol"?s:s+""}n.exports=i,n.exports.__esModule=!0,n.exports.default=n.exports}}),Li=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(t,n){var e=AZ();function r(i,o,s){return(o=e(o))in i?Object.defineProperty(i,o,{value:s,enumerable:!0,configurable:!0,writable:!0}):i[o]=s,i}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),Ut=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(t,n){var e=Li();function r(o,s){var a=Object.keys(o);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(o);s&&(c=c.filter(function(u){return Object.getOwnPropertyDescriptor(o,u).enumerable})),a.push.apply(a,c)}return a}function i(o){for(var s=1;s<arguments.length;s++){var a=arguments[s]!=null?arguments[s]:{};s%2?r(Object(a),!0).forEach(function(c){e(o,c,a[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(a)):r(Object(a)).forEach(function(c){Object.defineProperty(o,c,Object.getOwnPropertyDescriptor(a,c))})}return o}n.exports=i,n.exports.__esModule=!0,n.exports.default=n.exports}}),f0=Se(Ut(),1);function ji(t){let{path:n,error:e,config:r}=t,{code:i}=t.error,o={message:e.message,code:gs[i],data:{code:i,httpStatus:OZ(e)}};return r.isDev&&typeof t.error.stack=="string"&&(o.data.stack=t.error.stack),typeof n=="string"&&(o.data.path=n),r.errorFormatter((0,f0.default)((0,f0.default)({},t),{},{shape:o}))}var vs=({shape:t})=>t,b0=Se(Li(),1),NZ=class extends Error{};function PZ(t){if(t instanceof Error)return t;let n=typeof t;if(!(n==="undefined"||n==="function"||t===null)){if(n!=="object")return new Error(String(t));if(ft(t))return Object.assign(new NZ,t)}}function Yt(t){if(t instanceof Ue||t instanceof Error&&t.name==="TRPCError")return t;let n=new Ue({code:"INTERNAL_SERVER_ERROR",cause:t});return t instanceof Error&&t.stack&&(n.stack=t.stack),n}var Ue=class extends Error{constructor(t){var n,e,r;let i=PZ(t.cause),o=(n=(e=t.message)!==null&&e!==void 0?e:i?.message)!==null&&n!==void 0?n:t.code;super(o,{cause:i}),(0,b0.default)(this,"cause",void 0),(0,b0.default)(this,"code",void 0),this.code=t.code,this.name="TRPCError",(r=this.cause)!==null&&r!==void 0||(this.cause=i)}},ys=Se(Ut(),1);function E0(t){return"input"in t?t:{input:t,output:t}}var _s={input:{serialize:t=>t,deserialize:t=>t},output:{serialize:t=>t,deserialize:t=>t}};function w0(t,n){return"error"in n?(0,ys.default)((0,ys.default)({},n),{},{error:t.transformer.output.serialize(n.error)}):"data"in n.result?(0,ys.default)((0,ys.default)({},n),{},{result:(0,ys.default)((0,ys.default)({},n.result),{},{data:t.transformer.output.serialize(n.result.data)})}):n}function Oh(t,n){return Array.isArray(n)?n.map(e=>w0(t,e)):w0(t,n)}var Dh=Se(Ut(),1),RZ="lazyMarker";function kZ(t){let n=Symbol(),e=n;return()=>(e===n&&(e=t()),e)}function LZ(t){return typeof t=="function"&&RZ in t}function jZ(t){return ft(t)&&ft(t._def)&&"router"in t._def}var FZ={_ctx:null,_errorShape:null,_meta:null,queries:{},mutations:{},subscriptions:{},errorFormatter:vs,transformer:_s},$Z=["then","call","apply"];function Z_(t){function n(e){let r=new Set(Object.keys(e).filter(d=>$Z.includes(d)));if(r.size>0)throw new Error("Reserved words used in `router({})` call: "+Array.from(r).join(", "));let i=Ht(),o=Ht();function s(d){return{ref:d.ref,load:kZ(async()=>{let f=await d.ref(),p=[...d.path,d.key],m=p.join(".");d.aggregate[d.key]=a(f._def.record,p),delete o[m];for(let[y,b]of Object.entries(f._def.lazy)){let E=[...p,y].join(".");o[E]=s({ref:b.ref,path:p,key:y,aggregate:d.aggregate[d.key]})}})}}function a(d,f=[]){let p=Ht();for(let[m,y]of Object.entries(d??{})){if(LZ(y)){o[[...f,m].join(".")]=s({path:f,ref:y,key:m,aggregate:p});continue}if(jZ(y)){p[m]=a(y._def.record,[...f,m]);continue}if(!qZ(y)){p[m]=a(y,[...f,m]);continue}let b=[...f,m].join(".");if(i[b])throw new Error(`Duplicate key: ${b}`);i[b]=y,p[m]=y}return p}let c=a(e),u=(0,Dh.default)((0,Dh.default)({_config:t,router:!0,procedures:i,lazy:o},FZ),{},{record:c});return(0,Dh.default)((0,Dh.default)({},c),{},{_def:u,createCaller:Q_()({_def:u})})}return n}function qZ(t){return typeof t=="function"}async function Ka(t,n){let{_def:e}=t,r=e.procedures[n];for(;!r;){let i=Object.keys(e.lazy).find(s=>n.startsWith(s));if(!i)return null;await e.lazy[i].load(),r=e.procedures[n]}return r}function Q_(){return function(n){let{_def:e}=n;return function(i,o){return g0(async s=>{let{path:a,args:c}=s,u=a.join(".");if(a.length===1&&a[0]==="_def")return e;let l=await Ka(n,u),d;try{if(!l)throw new Ue({code:"NOT_FOUND",message:`No procedure found on path "${a}"`});return d=xh(i)?await Promise.resolve(i()):i,await l({path:u,getRawInput:async()=>c[0],ctx:d,type:l._def.type,signal:o?.signal,batchIndex:0})}catch(m){var f,p;throw o==null||(f=o.onError)===null||f===void 0||f.call(o,{ctx:d,error:Yt(m),input:c[0],path:u,type:(p=l?._def.type)!==null&&p!==void 0?p:"unknown"}),m}})}}}function S0(...t){var n,e;let r=Th({},...t.map(a=>a._def.record)),i=t.reduce((a,c)=>{if(c._def._config.errorFormatter&&c._def._config.errorFormatter!==vs){if(a!==vs&&a!==c._def._config.errorFormatter)throw new Error("You seem to have several error formatters");return c._def._config.errorFormatter}return a},vs),o=t.reduce((a,c)=>{if(c._def._config.transformer&&c._def._config.transformer!==_s){if(a!==_s&&a!==c._def._config.transformer)throw new Error("You seem to have several transformers");return c._def._config.transformer}return a},_s);return Z_({errorFormatter:i,transformer:o,isDev:t.every(a=>a._def._config.isDev),allowOutsideOfServer:t.every(a=>a._def._config.allowOutsideOfServer),isServer:t.every(a=>a._def._config.isServer),$types:(n=t[0])===null||n===void 0?void 0:n._def._config.$types,sse:(e=t[0])===null||e===void 0?void 0:e._def._config.sse})(r)}var BZ=Symbol();function C0(t){return Array.isArray(t)&&t[2]===BZ}function Ya(t){return typeof t=="object"&&t!==null&&"subscribe"in t}function Zt(t){let n={subscribe(e){let r=null,i=!1,o=!1,s=!1;function a(){if(r===null){s=!0;return}o||(o=!0,typeof r=="function"?r():r&&r.unsubscribe())}return r=t({next(c){var u;i||(u=e.next)===null||u===void 0||u.call(e,c)},error(c){var u;i||(i=!0,(u=e.error)===null||u===void 0||u.call(e,c),a())},complete(){var c;i||(i=!0,(c=e.complete)===null||c===void 0||c.call(e),a())}}),s&&a(),{unsubscribe:a}},pipe(...e){return e.reduce(HZ,n)}};return n}function HZ(t,n){return n(t)}function UZ(t,n){let e=null,r=()=>{e?.unsubscribe(),e=null,n.removeEventListener("abort",r)};return new ReadableStream({start(i){e=t.subscribe({next(o){i.enqueue({ok:!0,value:o})},error(o){i.enqueue({ok:!1,error:o}),i.close()},complete(){i.close()}}),n.aborted?r():n.addEventListener("abort",r,{once:!0})},cancel(){r()}})}function Mh(t,n){let r=UZ(t,n).getReader(),i={async next(){let o=await r.read();if(o.done)return{value:void 0,done:!0};let{value:s}=o;if(!s.ok)throw s.error;return{value:s.value,done:!1}},async return(){return await r.cancel(),{value:void 0,done:!0}}};return{[Symbol.asyncIterator](){return i}}}function VZ(t){try{if(t===null)return null;if(!ft(t))throw new Error("Expected object");let n=Object.entries(t).filter(([e,r])=>typeof r!="string");if(n.length>0)throw new Error(`Expected connectionParams to be string values. Got ${n.map(([e,r])=>`${e}: ${typeof r}`).join(", ")}`);return t}catch(n){throw new Ue({code:"PARSE_ERROR",message:"Invalid connection params shape",cause:n})}}function WZ(t){let n;try{n=JSON.parse(t)}catch(e){throw new Ue({code:"PARSE_ERROR",message:"Not JSON-parsable query params",cause:e})}return VZ(n)}var I0=Se(Ut(),1);function ib(t){let n=null,e=Symbol.for("@trpc/server/http/memo"),r=e;return{read:async()=>{var i;return r!==e||((i=n)!==null&&i!==void 0||(n=t().catch(o=>{throw o instanceof Ue?o:new Ue({code:"BAD_REQUEST",message:o instanceof Error?o.message:"Invalid input",cause:o})})),r=await n,n=null),r},result:()=>r!==e?r:void 0}}var q0={isMatch(t){var n;return!!(!((n=t.headers.get("content-type"))===null||n===void 0)&&n.startsWith("application/json"))},async parse(t){var n;let{req:e}=t,r=t.searchParams.get("batch")==="1",i=r?t.path.split(","):[t.path],o=ib(async()=>{let d;if(e.method==="GET"){let p=t.searchParams.get("input");p&&(d=JSON.parse(p))}else d=await e.json();if(d===void 0)return Ht();if(!r){let p=Ht();return p[0]=t.router._def._config.transformer.input.deserialize(d),p}if(!ft(d))throw new Ue({code:"BAD_REQUEST",message:'"input" needs to be an object when doing a batch call'});let f=Ht();for(let p of i.keys()){let m=d[p];m!==void 0&&(f[p]=t.router._def._config.transformer.input.deserialize(m))}return f}),s=await Promise.all(i.map(async(d,f)=>{let p=await Ka(t.router,d);return{batchIndex:f,path:d,procedure:p,getRawInput:async()=>{let y=(await o.read())[f];if(p?._def.type==="subscription"){var b,E;let T=(b=(E=t.headers.get("last-event-id"))!==null&&E!==void 0?E:t.searchParams.get("lastEventId"))!==null&&b!==void 0?b:t.searchParams.get("Last-Event-Id");if(T)if(ft(y))y=(0,I0.default)((0,I0.default)({},y),{},{lastEventId:T});else{var D;(D=y)!==null&&D!==void 0||(y={lastEventId:T})}}return y},result:()=>{var m;return(m=o.result())===null||m===void 0?void 0:m[f]}}})),a=new Set(s.map(d=>{var f;return(f=d.procedure)===null||f===void 0?void 0:f._def.type}).filter(Boolean));if(a.size>1)throw new Ue({code:"BAD_REQUEST",message:`Cannot mix procedure types in call: ${Array.from(a).join(", ")}`});let c=(n=a.values().next().value)!==null&&n!==void 0?n:"unknown",u=t.searchParams.get("connectionParams");return{isBatchCall:r,accept:e.headers.get("trpc-accept"),calls:s,type:c,connectionParams:u===null?null:WZ(u),signal:e.signal,url:t.url}}},GZ={isMatch(t){var n;return!!(!((n=t.headers.get("content-type"))===null||n===void 0)&&n.startsWith("multipart/form-data"))},async parse(t){let{req:n}=t;if(n.method!=="POST")throw new Ue({code:"METHOD_NOT_SUPPORTED",message:"Only POST requests are supported for multipart/form-data requests"});let e=ib(async()=>await n.formData()),r=await Ka(t.router,t.path);return{accept:null,calls:[{batchIndex:0,path:t.path,getRawInput:e.read,result:e.result,procedure:r}],isBatchCall:!1,type:"mutation",connectionParams:null,signal:n.signal,url:t.url}}},zZ={isMatch(t){var n;return!!(!((n=t.headers.get("content-type"))===null||n===void 0)&&n.startsWith("application/octet-stream"))},async parse(t){let{req:n}=t;if(n.method!=="POST")throw new Ue({code:"METHOD_NOT_SUPPORTED",message:"Only POST requests are supported for application/octet-stream requests"});let e=ib(async()=>n.body);return{calls:[{batchIndex:0,path:t.path,getRawInput:e.read,result:e.result,procedure:await Ka(t.router,t.path)}],isBatchCall:!1,accept:null,type:"mutation",connectionParams:null,signal:n.signal,url:t.url}}},KZ=[q0,GZ,zZ];function YZ(t){let n=KZ.find(e=>e.isMatch(t));if(n)return n;if(!n&&t.method==="GET")return q0;throw new Ue({code:"UNSUPPORTED_MEDIA_TYPE",message:t.headers.has("content-type")?`Unsupported content-type "${t.headers.get("content-type")}`:"Missing content-type header"})}async function ZZ(t){return await YZ(t.req).parse(t)}function QZ(t){return ft(t)&&t.name==="AbortError"}function JZ(t="AbortError"){throw new DOMException(t,"AbortError")}function T0(t){return Object.prototype.toString.call(t)==="[object Object]"}function XZ(t){var n,e;return T0(t)===!1?!1:(n=t.constructor,n===void 0?!0:(e=n.prototype,!(T0(e)===!1||e.hasOwnProperty("isPrototypeOf")===!1)))}var Ah=Se(Li(),1),B0,J_=new WeakMap,eQ=()=>{};B0=Symbol.toStringTag;var ob=class Fi{constructor(n){(0,Ah.default)(this,"promise",void 0),(0,Ah.default)(this,"subscribers",[]),(0,Ah.default)(this,"settlement",null),(0,Ah.default)(this,B0,"Unpromise"),typeof n=="function"?this.promise=new Promise(n):this.promise=n;let e=this.promise.then(r=>{let{subscribers:i}=this;this.subscribers=null,this.settlement={status:"fulfilled",value:r},i?.forEach(({resolve:o})=>{o(r)})});"catch"in e&&e.catch(r=>{let{subscribers:i}=this;this.subscribers=null,this.settlement={status:"rejected",reason:r},i?.forEach(({reject:o})=>{o(r)})})}subscribe(){let n,e,{settlement:r}=this;if(r===null){if(this.subscribers===null)throw new Error("Unpromise settled but still has subscribers");let i=nQ();this.subscribers=rQ(this.subscribers,i),n=i.promise,e=()=>{this.subscribers!==null&&(this.subscribers=oQ(this.subscribers,i))}}else{let{status:i}=r;i==="fulfilled"?n=Promise.resolve(r.value):n=Promise.reject(r.reason),e=eQ}return Object.assign(n,{unsubscribe:e})}then(n,e){let r=this.subscribe(),{unsubscribe:i}=r;return Object.assign(r.then(n,e),{unsubscribe:i})}catch(n){let e=this.subscribe(),{unsubscribe:r}=e;return Object.assign(e.catch(n),{unsubscribe:r})}finally(n){let e=this.subscribe(),{unsubscribe:r}=e;return Object.assign(e.finally(n),{unsubscribe:r})}static proxy(n){let e=Fi.getSubscribablePromise(n);return typeof e<"u"?e:Fi.createSubscribablePromise(n)}static createSubscribablePromise(n){let e=new Fi(n);return J_.set(n,e),J_.set(e,e),e}static getSubscribablePromise(n){return J_.get(n)}static resolve(n){let e=typeof n=="object"&&n!==null&&"then"in n&&typeof n.then=="function"?n:Promise.resolve(n);return Fi.proxy(e).subscribe()}static async any(n){let r=(Array.isArray(n)?n:[...n]).map(Fi.resolve);try{return await Promise.any(r)}finally{r.forEach(({unsubscribe:i})=>{i()})}}static async race(n){let r=(Array.isArray(n)?n:[...n]).map(Fi.resolve);try{return await Promise.race(r)}finally{r.forEach(({unsubscribe:i})=>{i()})}}static async raceReferences(n){let e=n.map(tQ);try{return await Promise.race(e)}finally{for(let r of e)r.unsubscribe()}}};function tQ(t){return ob.proxy(t).then(()=>[t])}function nQ(){let t,n;return{promise:new Promise((r,i)=>{t=r,n=i}),resolve:t,reject:n}}function rQ(t,n){return[...t,n]}function iQ(t,n){return[...t.slice(0,n),...t.slice(n+1)]}function oQ(t,n){let e=t.indexOf(n);return e!==-1?iQ(t,e):t}var x0,D0,O0,M0;(D0=(x0=Symbol).dispose)!==null&&D0!==void 0||(x0.dispose=Symbol());(M0=(O0=Symbol).asyncDispose)!==null&&M0!==void 0||(O0.asyncDispose=Symbol());function sQ(t,n){let e=t,r=e[Symbol.dispose];return e[Symbol.dispose]=()=>{n(),r?.()},e}function H0(t,n){let e=t,r=e[Symbol.asyncDispose];return e[Symbol.asyncDispose]=async()=>{await n(),await r?.()},e}var sb=Symbol();function U0(t){let n=null;return sQ({start(){if(n)throw new Error("Timer already started");return new Promise(r=>{n=setTimeout(()=>r(sb),t)})}},()=>{n&&clearTimeout(n)})}var Xa=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(t,n){function e(){var r=typeof SuppressedError=="function"?SuppressedError:function(a,c){var u=Error();return u.name="SuppressedError",u.error=a,u.suppressed=c,u},i={},o=[];function s(a,c){if(c!=null){if(Object(c)!==c)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(a)var u=c[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(u===void 0&&(u=c[Symbol.dispose||Symbol.for("Symbol.dispose")],a))var l=u;if(typeof u!="function")throw new TypeError("Object is not disposable.");l&&(u=function(){try{l.call(c)}catch(f){return Promise.reject(f)}}),o.push({v:c,d:u,a})}else a&&o.push({d:c,a});return c}return{e:i,u:s.bind(null,!1),a:s.bind(null,!0),d:function(){var c,u=this.e,l=0;function d(){for(;c=o.pop();)try{if(!c.a&&l===1)return l=0,o.push(c),Promise.resolve().then(d);if(c.d){var p=c.d.call(c.v);if(c.a)return l|=2,Promise.resolve(p).then(d,f)}else l|=1}catch(m){return f(m)}if(l===1)return u!==i?Promise.reject(u):Promise.resolve();if(u!==i)throw u}function f(p){return u=u!==i?new r(p,u):p,d()}return d()}}}n.exports=e,n.exports.__esModule=!0,n.exports.default=n.exports}}),ab=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(t,n){function e(r,i){this.v=r,this.k=i}n.exports=e,n.exports.__esModule=!0,n.exports.default=n.exports}}),ec=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(t,n){var e=ab();function r(i){return new e(i,0)}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),bs=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(t,n){var e=ab();function r(o){return function(){return new i(o.apply(this,arguments))}}function i(o){var s,a;function c(l,d){try{var f=o[l](d),p=f.value,m=p instanceof e;Promise.resolve(m?p.v:p).then(function(y){if(m){var b=l==="return"?"return":"next";if(!p.k||y.done)return c(b,y);y=o[b](y).value}u(f.done?"return":"normal",y)},function(y){c("throw",y)})}catch(y){u("throw",y)}}function u(l,d){switch(l){case"return":s.resolve({value:d,done:!0});break;case"throw":s.reject(d);break;default:s.resolve({value:d,done:!1})}(s=s.next)?c(s.key,s.arg):a=null}this._invoke=function(l,d){return new Promise(function(f,p){var m={key:l,arg:d,resolve:f,reject:p,next:null};a?a=a.next=m:(s=a=m,c(l,d))})},typeof o.return!="function"&&(this.return=void 0)}i.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},i.prototype.next=function(o){return this._invoke("next",o)},i.prototype.throw=function(o){return this._invoke("throw",o)},i.prototype.return=function(o){return this._invoke("return",o)},n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),aQ=Se(Xa(),1),A0=Se(ec(),1),cQ=Se(bs(),1);function cb(t){let n=t[Symbol.asyncIterator]();return n[Symbol.asyncDispose]?n:H0(n,async()=>{var e;await((e=n.return)===null||e===void 0?void 0:e.call(n))})}function uQ(t,n){return tb.apply(this,arguments)}function tb(){return tb=(0,cQ.default)(function*(t,n){try{var e=(0,aQ.default)();let r=e.a(cb(t)),i,o=e.u(U0(n.gracePeriodMs)),s=n.count,a=new Promise(()=>{});for(;;){if(i=yield(0,A0.default)(ob.race([r.next(),a])),i===sb&&JZ(),i.done)return i.value;yield i.value,--s===0&&(a=o.start()),i=null}}catch(r){e.e=r}finally{yield(0,A0.default)(e.d())}}),tb.apply(this,arguments)}function N0(){let t,n;return{promise:new Promise((r,i)=>{t=r,n=i}),resolve:t,reject:n}}var lQ=Se(Xa(),1),P0=Se(ec(),1),dQ=Se(bs(),1);function fQ(t,n){let e=t[Symbol.asyncIterator](),r="idle";function i(){r="done",n=()=>{}}function o(){if(r!=="idle")return;r="pending",e.next().then(a=>{if(a.done){r="done",n({status:"return",value:a.value}),i();return}r="idle",n({status:"yield",value:a.value})}).catch(a=>{n({status:"error",error:a}),i()})}return{pull:o,destroy:async()=>{var s;i(),await((s=e.return)===null||s===void 0?void 0:s.call(e))}}}function hQ(){let t="idle",n=N0(),e=[],r=new Set,i=[];function o(s){if(t!=="pending")return;let a=fQ(s,c=>{if(t==="pending"){switch(c.status){case"yield":i.push([a,c]);break;case"return":r.delete(a);break;case"error":i.push([a,c]),r.delete(a);break}n.resolve()}});r.add(a),a.pull()}return{add(s){switch(t){case"idle":e.push(s);break;case"pending":o(s);break;case"done":break}},[Symbol.asyncIterator](){return(0,dQ.default)(function*(){try{var s=(0,lQ.default)();if(t!=="idle")throw new Error("Cannot iterate twice");t="pending";let a=s.a(H0({},async()=>{t="done";let c=[];if(await Promise.all(Array.from(r.values()).map(async u=>{try{await u.destroy()}catch(l){c.push(l)}})),i.length=0,r.clear(),n.resolve(),c.length>0)throw new AggregateError(c)}));for(;e.length>0;)o(e.shift());for(;r.size>0;){for(yield(0,P0.default)(n.promise);i.length>0;){let[c,u]=i.shift();switch(u.status){case"yield":yield u.value,c.pull();break;case"error":throw u.error}}n=N0()}}catch(a){s.e=a}finally{yield(0,P0.default)(s.d())}})()}}}function V0(t){let n=t[Symbol.asyncIterator]();return new ReadableStream({async cancel(){var e;await((e=n.return)===null||e===void 0?void 0:e.call(n))},async pull(e){let r=await n.next();if(r.done){e.close();return}e.enqueue(r.value)}})}var R0=Se(Xa(),1),k0=Se(ec(),1),pQ=Se(bs(),1),Ja=Symbol("ping");function W0(t,n){return nb.apply(this,arguments)}function nb(){return nb=(0,pQ.default)(function*(t,n){try{var e=(0,R0.default)();let i=e.a(cb(t)),o,s=i.next();for(;;)try{var r=(0,R0.default)();let a=r.u(U0(n));if(o=yield(0,k0.default)(ob.race([s,a.start()])),o===sb){yield Ja;continue}if(o.done)return o.value;s=i.next(),yield o.value,o=null}catch(a){r.e=a}finally{r.d()}}catch(i){e.e=i}finally{yield(0,k0.default)(e.d())}}),nb.apply(this,arguments)}var G0=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(t,n){function e(i){var o,s,a,c=2;for(typeof Symbol<"u"&&(s=Symbol.asyncIterator,a=Symbol.iterator);c--;){if(s&&(o=i[s])!=null)return o.call(i);if(a&&(o=i[a])!=null)return new r(o.call(i));s="@@asyncIterator",a="@@iterator"}throw new TypeError("Object is not async iterable")}function r(i){function o(s){if(Object(s)!==s)return Promise.reject(new TypeError(s+" is not an object."));var a=s.done;return Promise.resolve(s.value).then(function(c){return{value:c,done:a}})}return r=function(a){this.s=a,this.n=a.next},r.prototype={s:null,n:null,next:function(){return o(this.n.apply(this.s,arguments))},return:function(a){var c=this.s.return;return c===void 0?Promise.resolve({value:a,done:!0}):o(c.apply(this.s,arguments))},throw:function(a){var c=this.s.return;return c===void 0?Promise.reject(a):o(c.apply(this.s,arguments))}},new r(i)}n.exports=e,n.exports.__esModule=!0,n.exports.default=n.exports}}),Za=Se(ec(),1),X_=Se(bs(),1),mQ=Se(Xa(),1),gQ=Se(G0(),1),yQ=0,vQ=1,_Q=0,bQ=1,wQ=0,EQ=1,SQ=2;function z0(t){return(ft(t)||xh(t))&&typeof t?.then=="function"&&typeof t?.catch=="function"}var CQ=class extends Error{constructor(t){super("Max depth reached at path: "+t.join(".")),this.path=t}};function IQ(t){return rb.apply(this,arguments)}function rb(){return rb=(0,X_.default)(function*(t){let{data:n}=t,e=0,r=0,i=hQ();function o(D){let T=e++,K=D(T);return i.add(K),T}function s(D,T){return o((function(){var K=(0,X_.default)(function*(H){let re=c(T);re&&(D.catch(z=>{var rt;(rt=t.onError)===null||rt===void 0||rt.call(t,{error:z,path:T})}),D=Promise.reject(re));try{let z=yield(0,Za.default)(D);yield[H,_Q,l(z,T)]}catch(z){var Ee,pe;(Ee=t.onError)===null||Ee===void 0||Ee.call(t,{error:z,path:T}),yield[H,bQ,(pe=t.formatError)===null||pe===void 0?void 0:pe.call(t,{error:z,path:T})]}});return function(H){return K.apply(this,arguments)}})())}function a(D,T){return o((function(){var K=(0,X_.default)(function*(H){try{var re=(0,mQ.default)();let z=c(T);if(z)throw z;let rt=re.a(cb(D));try{for(;;){let ee=yield(0,Za.default)(rt.next());if(ee.done){yield[H,wQ,l(ee.value,T)];break}yield[H,EQ,l(ee.value,T)]}}catch(ee){var Ee,pe;(Ee=t.onError)===null||Ee===void 0||Ee.call(t,{error:ee,path:T}),yield[H,SQ,(pe=t.formatError)===null||pe===void 0?void 0:pe.call(t,{error:ee,path:T})]}}catch(z){re.e=z}finally{yield(0,Za.default)(re.d())}});return function(H){return K.apply(this,arguments)}})())}function c(D){return t.maxDepth&&D.length>t.maxDepth?new CQ(D):null}function u(D,T){if(z0(D))return[yQ,s(D,T)];if(Ga(D)){if(t.maxDepth&&T.length>=t.maxDepth)throw new Error("Max depth reached");return[vQ,a(D,T)]}return null}function l(D,T){if(D===void 0)return[[]];let K=u(D,T);if(K)return[[r],[null,...K]];if(!XZ(D))return[[D]];let H=Ht(),re=[];for(let[Ee,pe]of Object.entries(D)){let z=u(pe,[...T,Ee]);if(!z){H[Ee]=pe;continue}H[Ee]=r,re.push([Ee,...z])}return[[H],...re]}let d=Ht();for(let[D,T]of Object.entries(n))d[D]=l(T,[D]);yield d;let f=i;t.pingMs&&(f=W0(i,t.pingMs));var p=!1,m=!1,y;try{for(var b=(0,gQ.default)(f),E;p=!(E=yield(0,Za.default)(b.next())).done;p=!1)yield E.value}catch(D){m=!0,y=D}finally{try{p&&b.return!=null&&(yield(0,Za.default)(b.return()))}finally{if(m)throw y}}}),rb.apply(this,arguments)}function TQ(t){let n=V0(IQ(t)),{serialize:e}=t;return e&&(n=n.pipeThrough(new TransformStream({transform(r,i){r===Ja?i.enqueue(Ja):i.enqueue(e(r))}}))),n.pipeThrough(new TransformStream({transform(r,i){r===Ja?i.enqueue(" "):i.enqueue(JSON.stringify(r)+`
8
+ `)}})).pipeThrough(new TextEncoderStream)}var xQ=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncGeneratorDelegate.js"(t,n){var e=ab();function r(i){var o={},s=!1;function a(c,u){return s=!0,u=new Promise(function(l){l(i[c](u))}),{done:!1,value:new e(u,1)}}return o[typeof Symbol<"u"&&Symbol.iterator||"@@iterator"]=function(){return this},o.next=function(c){return s?(s=!1,c):a("next",c)},typeof i.throw=="function"&&(o.throw=function(c){if(s)throw s=!1,c;return a("throw",c)}),typeof i.return=="function"&&(o.return=function(c){return s?(s=!1,c):a("return",c)}),o}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),L0=Se(G0(),1),j0=Se(ec(),1),F0=Se(bs(),1),DQ=Se(xQ(),1),Uwe=Se(Xa(),1),OQ="ping",MQ="serialized-error",AQ="connected",NQ="return";function PQ(t){var n,e,r,i,o;let{serialize:s=c0}=t,a={enabled:(n=(e=t.ping)===null||e===void 0?void 0:e.enabled)!==null&&n!==void 0?n:!1,intervalMs:(r=(i=t.ping)===null||i===void 0?void 0:i.intervalMs)!==null&&r!==void 0?r:1e3},c=(o=t.client)!==null&&o!==void 0?o:{};if(a.enabled&&c.reconnectAfterInactivityMs&&a.intervalMs>c.reconnectAfterInactivityMs)throw new Error(`Ping interval must be less than client reconnect interval to prevent unnecessary reconnection - ping.intervalMs: ${a.intervalMs} client.reconnectAfterInactivityMs: ${c.reconnectAfterInactivityMs}`);function u(){return l.apply(this,arguments)}function l(){return l=(0,F0.default)(function*(){yield{event:AQ,data:JSON.stringify(c)};let m=t.data;t.emitAndEndImmediately&&(m=uQ(m,{count:1,gracePeriodMs:1})),a.enabled&&a.intervalMs!==1/0&&a.intervalMs>0&&(m=W0(m,a.intervalMs));let y,b;var E=!1,D=!1,T;try{for(var K=(0,L0.default)(m),H;E=!(H=yield(0,j0.default)(K.next())).done;E=!1){y=H.value;{if(y===Ja){yield{event:OQ,data:""};continue}b=C0(y)?{id:y[0],data:y[1]}:{data:y},b.data=JSON.stringify(s(b.data)),yield b,y=null,b=null}}}catch(re){D=!0,T=re}finally{try{E&&K.return!=null&&(yield(0,j0.default)(K.return()))}finally{if(D)throw T}}}),l.apply(this,arguments)}function d(){return f.apply(this,arguments)}function f(){return f=(0,F0.default)(function*(){try{yield*(0,DQ.default)((0,L0.default)(u())),yield{event:NQ,data:""}}catch(b){var m,y;if(QZ(b))return;let E=Yt(b),D=(m=(y=t.formatError)===null||y===void 0?void 0:y.call(t,{error:E}))!==null&&m!==void 0?m:null;yield{event:MQ,data:JSON.stringify(s(D))}}}),f.apply(this,arguments)}return V0(d()).pipeThrough(new TransformStream({transform(m,y){"event"in m&&y.enqueue(`event: ${m.event}
9
9
  `),"data"in m&&y.enqueue(`data: ${m.data}
10
10
  `),"id"in m&&y.enqueue(`id: ${m.id}
11
11
  `),"comment"in m&&y.enqueue(`: ${m.comment}
12
12
  `),y.enqueue(`
13
13
 
14
- `)}})).pipeThrough(new TextEncoderStream)}var PQ={"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform","X-Accel-Buffering":"no",Connection:"keep-alive"},RQ=Se(bs(),1),Nh=Se(Ut(),1);function eb(t){return za((0,RQ.default)(function*(){throw t}))}function kQ(t){let n=new AbortController;return{signal:uD([t,n.signal]),controller:n}}var LQ={mutation:["POST"],query:["GET"],subscription:["GET"]},jQ={mutation:["POST"],query:["GET","POST"],subscription:["GET","POST"]};function Qa(t){var n,e,r;let{ctx:i,info:o,responseMeta:s,untransformedJSON:a,errors:c=[],headers:u}=t,l=a?vD(a):200,d=!a,f=d?[]:Array.isArray(a)?a:[a],p=(n=s?.({ctx:i,info:o,paths:o?.calls.map(m=>m.path),data:f,errors:c,eagerGeneration:d,type:(e=o==null||(r=o.calls.find(m=>{var y;return(y=m.procedure)===null||y===void 0?void 0:y._def.type}))===null||r===void 0||(r=r.procedure)===null||r===void 0?void 0:r._def.type)!==null&&e!==void 0?e:"unknown"}))!==null&&n!==void 0?n:{};if(p.headers)if(p.headers instanceof Headers)for(let[m,y]of p.headers.entries())u.append(m,y);else for(let[m,y]of Object.entries(p.headers))if(Array.isArray(y))for(let b of y)u.append(m,b);else typeof y=="string"&&u.set(m,y);return p.status&&(l=p.status),{status:l}}function FQ(t,n){let{router:e,req:r,onError:i}=n.opts,o=Yt(t);i?.({error:o,path:n.path,input:n.input,ctx:n.ctx,type:n.type,req:r});let s={error:ji({config:e._def._config,error:o,type:n.type,path:n.path,input:n.input,ctx:n.ctx})},a=Oh(e._def._config,s),c=JSON.stringify(a);return{error:o,untransformedJSON:s,body:c}}function $D(t){return ft(t)?Ga(t)?!0:Object.values(t).some(zD)||Object.values(t).some(Ga):!1}async function KD(t){var n,e,r,i,o,s;let{router:a,req:c}=t,u=new Headers([["vary","trpc-accept"]]),l=a._def._config,d=new URL(c.url);if(c.method==="HEAD")return new Response(null,{status:204});let f=(n=(e=t.allowBatching)!==null&&e!==void 0?e:(r=t.batching)===null||r===void 0?void 0:r.enabled)!==null&&n!==void 0?n:!0,p=((i=t.allowMethodOverride)!==null&&i!==void 0?i:!1)&&c.method==="POST",m=await za(async()=>{try{return[void 0,await YZ({req:c,path:decodeURIComponent(t.path),router:a,searchParams:d.searchParams,headers:t.req.headers,url:d})]}catch(K){return[Yt(K),void 0]}}),y=za(()=>{let K;return{valueOrUndefined:()=>{if(K)return K[1]},value:()=>{let[H,re]=K;if(H)throw H;return re},create:async H=>{if(K)throw new Error("This should only be called once - report a bug in tRPC");try{K=[void 0,await t.createContext({info:H})]}catch(re){K=[Yt(re),void 0]}}}}),b=p?jQ:LQ,E=c.headers.get("trpc-accept")==="application/jsonl",D=(o=(s=l.sse)===null||s===void 0?void 0:s.enabled)!==null&&o!==void 0?o:!0;try{let[K,H]=m;if(K)throw K;if(H.isBatchCall&&!f)throw new Ue({code:"BAD_REQUEST",message:"Batching is not enabled on the server"});if(E&&!H.isBatchCall)throw new Ue({message:"Streaming requests must be batched (you can do a batch of 1)",code:"BAD_REQUEST"});await y.create(H);let re=H.calls.map(async ee=>{let $=ee.procedure,x=kQ(t.req.signal);try{if(t.error)throw t.error;if(!$)throw new Ue({code:"NOT_FOUND",message:`No procedure found on path "${ee.path}"`});if(!b[$._def.type].includes(c.method))throw new Ue({code:"METHOD_NOT_SUPPORTED",message:`Unsupported ${c.method}-request to ${$._def.type} procedure at path "${ee.path}"`});if($._def.type==="subscription"){var C;if(H.isBatchCall)throw new Ue({code:"BAD_REQUEST",message:"Cannot batch subscription calls"});if(!((C=l.sse)===null||C===void 0)&&C.maxDurationMs){let ie=function(){clearTimeout(Te),x.signal.removeEventListener("abort",ie),x.controller.abort()},Te=setTimeout(ie,l.sse.maxDurationMs);x.signal.addEventListener("abort",ie)}}return[void 0,{data:await $({path:ee.path,getRawInput:ee.getRawInput,ctx:y.value(),type:$._def.type,signal:x.signal,batchIndex:ee.batchIndex})}]}catch(G){var P,O,B;let ie=Yt(G),Te=ee.result();return(P=t.onError)===null||P===void 0||P.call(t,{error:ie,path:ee.path,input:Te,ctx:y.valueOrUndefined(),type:(O=(B=ee.procedure)===null||B===void 0?void 0:B._def.type)!==null&&O!==void 0?O:"unknown",req:t.req}),[ie,void 0]}});if(!H.isBatchCall){let[ee]=H.calls,[$,x]=await re[0];switch(H.type){case"unknown":case"mutation":case"query":{if(u.set("content-type","application/json"),$D(x?.data))throw new Ue({code:"UNSUPPORTED_MEDIA_TYPE",message:"Cannot use stream-like response in non-streaming request - use httpBatchStreamLink"});let C=$?{error:ji({config:l,ctx:y.valueOrUndefined(),error:$,input:ee.result(),path:ee.path,type:H.type})}:{result:{data:x.data}},P=Qa({ctx:y.valueOrUndefined(),info:H,responseMeta:t.responseMeta,errors:$?[$]:[],headers:u,untransformedJSON:[C]});return new Response(JSON.stringify(Oh(l,C)),{status:P.status,headers:u})}case"subscription":{let C=za(()=>$?eb($):D?!Ya(x.data)&&!Ga(x.data)?eb(new Ue({message:`Subscription ${ee.path} did not return an observable or a AsyncGenerator`,code:"INTERNAL_SERVER_ERROR"})):Ya(x.data)?Mh(x.data,t.req.signal):x.data:eb(new Ue({code:"METHOD_NOT_SUPPORTED",message:'Missing experimental flag "sseSubscriptions"'}))),P=NQ((0,Nh.default)((0,Nh.default)({},l.sse),{},{data:C,serialize:B=>l.transformer.output.serialize(B),formatError(B){var G,ie,Te;let oe=Yt(B.error),$e=ee?.result(),st=ee?.path,Le=(G=ee==null||(ie=ee.procedure)===null||ie===void 0?void 0:ie._def.type)!==null&&G!==void 0?G:"unknown";return(Te=t.onError)===null||Te===void 0||Te.call(t,{error:oe,path:st,input:$e,ctx:y.valueOrUndefined(),req:t.req,type:Le}),ji({config:l,ctx:y.valueOrUndefined(),error:oe,input:$e,path:st,type:Le})}}));for(let[B,G]of Object.entries(PQ))u.set(B,G);let O=Qa({ctx:y.valueOrUndefined(),info:H,responseMeta:t.responseMeta,errors:[],headers:u,untransformedJSON:null});return new Response(P,{headers:u,status:O.status})}}}if(H.accept==="application/jsonl"){u.set("content-type","application/json"),u.set("transfer-encoding","chunked");let ee=Qa({ctx:y.valueOrUndefined(),info:H,responseMeta:t.responseMeta,errors:[],headers:u,untransformedJSON:null}),$=IQ((0,Nh.default)((0,Nh.default)({},l.jsonl),{},{maxDepth:1/0,data:re.map(async x=>{let[C,P]=await x,O=H.calls[0];if(C){var B,G;return{error:ji({config:l,ctx:y.valueOrUndefined(),error:C,input:O.result(),path:O.path,type:(B=(G=O.procedure)===null||G===void 0?void 0:G._def.type)!==null&&B!==void 0?B:"unknown"})}}let ie=Ya(P.data)?Mh(P.data,t.req.signal):Promise.resolve(P.data);return{result:Promise.resolve({data:ie})}}),serialize:x=>l.transformer.output.serialize(x),onError:x=>{var C,P;(C=t.onError)===null||C===void 0||C.call(t,{error:Yt(x),path:void 0,input:void 0,ctx:y.valueOrUndefined(),req:t.req,type:(P=H?.type)!==null&&P!==void 0?P:"unknown"})},formatError(x){var C,P;let O=H?.calls[x.path[0]],B=Yt(x.error),G=O?.result(),ie=O?.path,Te=(C=O==null||(P=O.procedure)===null||P===void 0?void 0:P._def.type)!==null&&C!==void 0?C:"unknown";return ji({config:l,ctx:y.valueOrUndefined(),error:B,input:G,path:ie,type:Te})}}));return new Response($,{headers:u,status:ee.status})}u.set("content-type","application/json");let Ee=(await Promise.all(re)).map(ee=>{let[$,x]=ee;return $?ee:$D(x.data)?[new Ue({code:"UNSUPPORTED_MEDIA_TYPE",message:"Cannot use stream-like response in non-streaming request - use httpBatchStreamLink"}),void 0]:ee}),pe=Ee.map(([ee,$],x)=>{let C=H.calls[x];if(ee){var P,O;return{error:ji({config:l,ctx:y.valueOrUndefined(),error:ee,input:C.result(),path:C.path,type:(P=(O=C.procedure)===null||O===void 0?void 0:O._def.type)!==null&&P!==void 0?P:"unknown"})}}return{result:{data:$.data}}}),z=Ee.map(([ee])=>ee).filter(Boolean),rt=Qa({ctx:y.valueOrUndefined(),info:H,responseMeta:t.responseMeta,untransformedJSON:pe,errors:z,headers:u});return new Response(JSON.stringify(Oh(l,pe)),{status:rt.status,headers:u})}catch(K){var T;let[H,re]=m,Ee=y.valueOrUndefined(),{error:pe,untransformedJSON:z,body:rt}=FQ(K,{opts:t,ctx:y.valueOrUndefined(),type:(T=re?.type)!==null&&T!==void 0?T:"unknown"}),ee=Qa({ctx:Ee,info:re,responseMeta:t.responseMeta,untransformedJSON:z,errors:[pe],headers:u});return new Response(rt,{status:ee.status,headers:u})}}var tc=Se(Ut(),1),ub=t=>(t=t.startsWith("/")?t.slice(1):t,t=t.endsWith("/")?t.slice(0,-1):t,t);async function lb(t){let n=new Headers,e=async a=>{var c;return(c=t.createContext)===null||c===void 0?void 0:c.call(t,(0,tc.default)({req:t.req,resHeaders:n},a))},r=new URL(t.req.url),i=ub(r.pathname),o=ub(t.endpoint),s=ub(i.slice(o.length));return await KD((0,tc.default)((0,tc.default)({},t),{},{req:t.req,createContext:e,path:s,error:null,onError(a){var c;t==null||(c=t.onError)===null||c===void 0||c.call(t,(0,tc.default)((0,tc.default)({},a),{},{req:t.req}))},responseMeta(a){var c;let u=(c=t.responseMeta)===null||c===void 0?void 0:c.call(t,a);if(u?.headers)if(u.headers instanceof Headers)for(let[l,d]of u.headers.entries())n.append(l,d);else for(let[l,d]of Object.entries(u.headers))if(Array.isArray(d))for(let f of d)n.append(l,f);else typeof d=="string"&&n.set(l,d);return{headers:n,status:u?.status}}}))}var Ph=Se(Ut(),1),JD="middlewareMarker";function $Q(){function t(e){return{_middlewares:e,unstable_pipe(r){let i="_middlewares"in r?r._middlewares:[r];return t([...e,...i])}}}function n(e){return t([e])}return n}function qQ(t){let n=async function(r){let i,o=await r.getRawInput();try{i=await t(o)}catch(a){throw new Ue({code:"BAD_REQUEST",cause:a})}let s=ft(r.input)&&ft(i)?(0,Ph.default)((0,Ph.default)({},r.input),i):i;return r.next({input:s})};return n._type="input",n}function BQ(t){let n=async function({next:r}){let i=await r();if(!i.ok)return i;try{let o=await t(i.data);return(0,Ph.default)((0,Ph.default)({},i),{},{data:o})}catch(o){throw new Ue({message:"Output validation failed",code:"INTERNAL_SERVER_ERROR",cause:o})}};return n._type="output",n}var HQ=Se(Li(),1),XD=class extends Error{constructor(t){var n;super((n=t[0])===null||n===void 0?void 0:n.message),(0,HQ.default)(this,"issues",void 0),this.name="SchemaError",this.issues=t}};function YD(t){let n=t,e="~standard"in n;if(typeof n=="function"&&typeof n.assert=="function")return n.assert.bind(n);if(typeof n=="function"&&!e)return n;if(typeof n.parseAsync=="function")return n.parseAsync.bind(n);if(typeof n.parse=="function")return n.parse.bind(n);if(typeof n.validateSync=="function")return n.validateSync.bind(n);if(typeof n.create=="function")return n.create.bind(n);if(typeof n.assert=="function")return r=>(n.assert(r),r);if(e)return async r=>{let i=await n["~standard"].validate(r);if(i.issues)throw new XD(i.issues);return i.value};throw new Error("Could not find a validator fn")}var UQ=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutPropertiesLoose.js"(t,n){function e(r,i){if(r==null)return{};var o={};for(var s in r)if({}.hasOwnProperty.call(r,s)){if(i.includes(s))continue;o[s]=r[s]}return o}n.exports=e,n.exports.__esModule=!0,n.exports.default=n.exports}}),VQ=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutProperties.js"(t,n){var e=UQ();function r(i,o){if(i==null)return{};var s,a,c=e(i,o);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(i);for(a=0;a<u.length;a++)s=u[a],o.includes(s)||{}.propertyIsEnumerable.call(i,s)&&(c[s]=i[s])}return c}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),WQ=Se(VQ(),1),Xe=Se(Ut(),1),GQ=["middlewares","inputs","meta"];function Vr(t,n){let{middlewares:e=[],inputs:r,meta:i}=n,o=(0,WQ.default)(n,GQ);return eO((0,Xe.default)((0,Xe.default)({},Th(t,o)),{},{inputs:[...t.inputs,...r??[]],middlewares:[...t.middlewares,...e],meta:t.meta&&i?(0,Xe.default)((0,Xe.default)({},t.meta),i):i??t.meta}))}function eO(t={}){let n=(0,Xe.default)({procedure:!0,inputs:[],middlewares:[]},t);return{_def:n,input(r){let i=YD(r);return Vr(n,{inputs:[r],middlewares:[qQ(i)]})},output(r){let i=YD(r);return Vr(n,{output:r,middlewares:[BQ(i)]})},meta(r){return Vr(n,{meta:r})},use(r){let i="_middlewares"in r?r._middlewares:[r];return Vr(n,{middlewares:i})},unstable_concat(r){return Vr(n,r._def)},concat(r){return Vr(n,r._def)},query(r){return db((0,Xe.default)((0,Xe.default)({},n),{},{type:"query"}),r)},mutation(r){return db((0,Xe.default)((0,Xe.default)({},n),{},{type:"mutation"}),r)},subscription(r){return db((0,Xe.default)((0,Xe.default)({},n),{},{type:"subscription"}),r)},experimental_caller(r){return Vr(n,{caller:r})}}}function db(t,n){let e=Vr(t,{resolver:n,middlewares:[async function(c){let u=await n(c);return{marker:JD,ok:!0,data:u,ctx:c.ctx}}]}),r=(0,Xe.default)((0,Xe.default)({},e._def),{},{type:t.type,experimental_caller:!!e._def.caller,meta:e._def.meta,$types:null}),i=KQ(e._def),o=e._def.caller;if(!o)return i;let s=async(...a)=>await o({args:a,invoke:i,_def:r});return s._def=r,s}var zQ=`
14
+ `)}})).pipeThrough(new TextEncoderStream)}var RQ={"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform","X-Accel-Buffering":"no",Connection:"keep-alive"},kQ=Se(bs(),1),Nh=Se(Ut(),1);function eb(t){return za((0,kQ.default)(function*(){throw t}))}function LQ(t){let n=new AbortController;return{signal:u0([t,n.signal]),controller:n}}var jQ={mutation:["POST"],query:["GET"],subscription:["GET"]},FQ={mutation:["POST"],query:["GET","POST"],subscription:["GET","POST"]};function Qa(t){var n,e,r;let{ctx:i,info:o,responseMeta:s,untransformedJSON:a,errors:c=[],headers:u}=t,l=a?v0(a):200,d=!a,f=d?[]:Array.isArray(a)?a:[a],p=(n=s?.({ctx:i,info:o,paths:o?.calls.map(m=>m.path),data:f,errors:c,eagerGeneration:d,type:(e=o==null||(r=o.calls.find(m=>{var y;return(y=m.procedure)===null||y===void 0?void 0:y._def.type}))===null||r===void 0||(r=r.procedure)===null||r===void 0?void 0:r._def.type)!==null&&e!==void 0?e:"unknown"}))!==null&&n!==void 0?n:{};if(p.headers)if(p.headers instanceof Headers)for(let[m,y]of p.headers.entries())u.append(m,y);else for(let[m,y]of Object.entries(p.headers))if(Array.isArray(y))for(let b of y)u.append(m,b);else typeof y=="string"&&u.set(m,y);return p.status&&(l=p.status),{status:l}}function $Q(t,n){let{router:e,req:r,onError:i}=n.opts,o=Yt(t);i?.({error:o,path:n.path,input:n.input,ctx:n.ctx,type:n.type,req:r});let s={error:ji({config:e._def._config,error:o,type:n.type,path:n.path,input:n.input,ctx:n.ctx})},a=Oh(e._def._config,s),c=JSON.stringify(a);return{error:o,untransformedJSON:s,body:c}}function $0(t){return ft(t)?Ga(t)?!0:Object.values(t).some(z0)||Object.values(t).some(Ga):!1}async function K0(t){var n,e,r,i,o,s;let{router:a,req:c}=t,u=new Headers([["vary","trpc-accept"]]),l=a._def._config,d=new URL(c.url);if(c.method==="HEAD")return new Response(null,{status:204});let f=(n=(e=t.allowBatching)!==null&&e!==void 0?e:(r=t.batching)===null||r===void 0?void 0:r.enabled)!==null&&n!==void 0?n:!0,p=((i=t.allowMethodOverride)!==null&&i!==void 0?i:!1)&&c.method==="POST",m=await za(async()=>{try{return[void 0,await ZZ({req:c,path:decodeURIComponent(t.path),router:a,searchParams:d.searchParams,headers:t.req.headers,url:d})]}catch(K){return[Yt(K),void 0]}}),y=za(()=>{let K;return{valueOrUndefined:()=>{if(K)return K[1]},value:()=>{let[H,re]=K;if(H)throw H;return re},create:async H=>{if(K)throw new Error("This should only be called once - report a bug in tRPC");try{K=[void 0,await t.createContext({info:H})]}catch(re){K=[Yt(re),void 0]}}}}),b=p?FQ:jQ,E=c.headers.get("trpc-accept")==="application/jsonl",D=(o=(s=l.sse)===null||s===void 0?void 0:s.enabled)!==null&&o!==void 0?o:!0;try{let[K,H]=m;if(K)throw K;if(H.isBatchCall&&!f)throw new Ue({code:"BAD_REQUEST",message:"Batching is not enabled on the server"});if(E&&!H.isBatchCall)throw new Ue({message:"Streaming requests must be batched (you can do a batch of 1)",code:"BAD_REQUEST"});await y.create(H);let re=H.calls.map(async ee=>{let $=ee.procedure,x=LQ(t.req.signal);try{if(t.error)throw t.error;if(!$)throw new Ue({code:"NOT_FOUND",message:`No procedure found on path "${ee.path}"`});if(!b[$._def.type].includes(c.method))throw new Ue({code:"METHOD_NOT_SUPPORTED",message:`Unsupported ${c.method}-request to ${$._def.type} procedure at path "${ee.path}"`});if($._def.type==="subscription"){var C;if(H.isBatchCall)throw new Ue({code:"BAD_REQUEST",message:"Cannot batch subscription calls"});if(!((C=l.sse)===null||C===void 0)&&C.maxDurationMs){let ie=function(){clearTimeout(Te),x.signal.removeEventListener("abort",ie),x.controller.abort()},Te=setTimeout(ie,l.sse.maxDurationMs);x.signal.addEventListener("abort",ie)}}return[void 0,{data:await $({path:ee.path,getRawInput:ee.getRawInput,ctx:y.value(),type:$._def.type,signal:x.signal,batchIndex:ee.batchIndex})}]}catch(G){var P,O,B;let ie=Yt(G),Te=ee.result();return(P=t.onError)===null||P===void 0||P.call(t,{error:ie,path:ee.path,input:Te,ctx:y.valueOrUndefined(),type:(O=(B=ee.procedure)===null||B===void 0?void 0:B._def.type)!==null&&O!==void 0?O:"unknown",req:t.req}),[ie,void 0]}});if(!H.isBatchCall){let[ee]=H.calls,[$,x]=await re[0];switch(H.type){case"unknown":case"mutation":case"query":{if(u.set("content-type","application/json"),$0(x?.data))throw new Ue({code:"UNSUPPORTED_MEDIA_TYPE",message:"Cannot use stream-like response in non-streaming request - use httpBatchStreamLink"});let C=$?{error:ji({config:l,ctx:y.valueOrUndefined(),error:$,input:ee.result(),path:ee.path,type:H.type})}:{result:{data:x.data}},P=Qa({ctx:y.valueOrUndefined(),info:H,responseMeta:t.responseMeta,errors:$?[$]:[],headers:u,untransformedJSON:[C]});return new Response(JSON.stringify(Oh(l,C)),{status:P.status,headers:u})}case"subscription":{let C=za(()=>$?eb($):D?!Ya(x.data)&&!Ga(x.data)?eb(new Ue({message:`Subscription ${ee.path} did not return an observable or a AsyncGenerator`,code:"INTERNAL_SERVER_ERROR"})):Ya(x.data)?Mh(x.data,t.req.signal):x.data:eb(new Ue({code:"METHOD_NOT_SUPPORTED",message:'Missing experimental flag "sseSubscriptions"'}))),P=PQ((0,Nh.default)((0,Nh.default)({},l.sse),{},{data:C,serialize:B=>l.transformer.output.serialize(B),formatError(B){var G,ie,Te;let oe=Yt(B.error),$e=ee?.result(),st=ee?.path,Le=(G=ee==null||(ie=ee.procedure)===null||ie===void 0?void 0:ie._def.type)!==null&&G!==void 0?G:"unknown";return(Te=t.onError)===null||Te===void 0||Te.call(t,{error:oe,path:st,input:$e,ctx:y.valueOrUndefined(),req:t.req,type:Le}),ji({config:l,ctx:y.valueOrUndefined(),error:oe,input:$e,path:st,type:Le})}}));for(let[B,G]of Object.entries(RQ))u.set(B,G);let O=Qa({ctx:y.valueOrUndefined(),info:H,responseMeta:t.responseMeta,errors:[],headers:u,untransformedJSON:null});return new Response(P,{headers:u,status:O.status})}}}if(H.accept==="application/jsonl"){u.set("content-type","application/json"),u.set("transfer-encoding","chunked");let ee=Qa({ctx:y.valueOrUndefined(),info:H,responseMeta:t.responseMeta,errors:[],headers:u,untransformedJSON:null}),$=TQ((0,Nh.default)((0,Nh.default)({},l.jsonl),{},{maxDepth:1/0,data:re.map(async x=>{let[C,P]=await x,O=H.calls[0];if(C){var B,G;return{error:ji({config:l,ctx:y.valueOrUndefined(),error:C,input:O.result(),path:O.path,type:(B=(G=O.procedure)===null||G===void 0?void 0:G._def.type)!==null&&B!==void 0?B:"unknown"})}}let ie=Ya(P.data)?Mh(P.data,t.req.signal):Promise.resolve(P.data);return{result:Promise.resolve({data:ie})}}),serialize:x=>l.transformer.output.serialize(x),onError:x=>{var C,P;(C=t.onError)===null||C===void 0||C.call(t,{error:Yt(x),path:void 0,input:void 0,ctx:y.valueOrUndefined(),req:t.req,type:(P=H?.type)!==null&&P!==void 0?P:"unknown"})},formatError(x){var C,P;let O=H?.calls[x.path[0]],B=Yt(x.error),G=O?.result(),ie=O?.path,Te=(C=O==null||(P=O.procedure)===null||P===void 0?void 0:P._def.type)!==null&&C!==void 0?C:"unknown";return ji({config:l,ctx:y.valueOrUndefined(),error:B,input:G,path:ie,type:Te})}}));return new Response($,{headers:u,status:ee.status})}u.set("content-type","application/json");let Ee=(await Promise.all(re)).map(ee=>{let[$,x]=ee;return $?ee:$0(x.data)?[new Ue({code:"UNSUPPORTED_MEDIA_TYPE",message:"Cannot use stream-like response in non-streaming request - use httpBatchStreamLink"}),void 0]:ee}),pe=Ee.map(([ee,$],x)=>{let C=H.calls[x];if(ee){var P,O;return{error:ji({config:l,ctx:y.valueOrUndefined(),error:ee,input:C.result(),path:C.path,type:(P=(O=C.procedure)===null||O===void 0?void 0:O._def.type)!==null&&P!==void 0?P:"unknown"})}}return{result:{data:$.data}}}),z=Ee.map(([ee])=>ee).filter(Boolean),rt=Qa({ctx:y.valueOrUndefined(),info:H,responseMeta:t.responseMeta,untransformedJSON:pe,errors:z,headers:u});return new Response(JSON.stringify(Oh(l,pe)),{status:rt.status,headers:u})}catch(K){var T;let[H,re]=m,Ee=y.valueOrUndefined(),{error:pe,untransformedJSON:z,body:rt}=$Q(K,{opts:t,ctx:y.valueOrUndefined(),type:(T=re?.type)!==null&&T!==void 0?T:"unknown"}),ee=Qa({ctx:Ee,info:re,responseMeta:t.responseMeta,untransformedJSON:z,errors:[pe],headers:u});return new Response(rt,{status:ee.status,headers:u})}}var tc=Se(Ut(),1),ub=t=>(t=t.startsWith("/")?t.slice(1):t,t=t.endsWith("/")?t.slice(0,-1):t,t);async function lb(t){let n=new Headers,e=async a=>{var c;return(c=t.createContext)===null||c===void 0?void 0:c.call(t,(0,tc.default)({req:t.req,resHeaders:n},a))},r=new URL(t.req.url),i=ub(r.pathname),o=ub(t.endpoint),s=ub(i.slice(o.length));return await K0((0,tc.default)((0,tc.default)({},t),{},{req:t.req,createContext:e,path:s,error:null,onError(a){var c;t==null||(c=t.onError)===null||c===void 0||c.call(t,(0,tc.default)((0,tc.default)({},a),{},{req:t.req}))},responseMeta(a){var c;let u=(c=t.responseMeta)===null||c===void 0?void 0:c.call(t,a);if(u?.headers)if(u.headers instanceof Headers)for(let[l,d]of u.headers.entries())n.append(l,d);else for(let[l,d]of Object.entries(u.headers))if(Array.isArray(d))for(let f of d)n.append(l,f);else typeof d=="string"&&n.set(l,d);return{headers:n,status:u?.status}}}))}var Ph=Se(Ut(),1),J0="middlewareMarker";function qQ(){function t(e){return{_middlewares:e,unstable_pipe(r){let i="_middlewares"in r?r._middlewares:[r];return t([...e,...i])}}}function n(e){return t([e])}return n}function BQ(t){let n=async function(r){let i,o=await r.getRawInput();try{i=await t(o)}catch(a){throw new Ue({code:"BAD_REQUEST",cause:a})}let s=ft(r.input)&&ft(i)?(0,Ph.default)((0,Ph.default)({},r.input),i):i;return r.next({input:s})};return n._type="input",n}function HQ(t){let n=async function({next:r}){let i=await r();if(!i.ok)return i;try{let o=await t(i.data);return(0,Ph.default)((0,Ph.default)({},i),{},{data:o})}catch(o){throw new Ue({message:"Output validation failed",code:"INTERNAL_SERVER_ERROR",cause:o})}};return n._type="output",n}var UQ=Se(Li(),1),X0=class extends Error{constructor(t){var n;super((n=t[0])===null||n===void 0?void 0:n.message),(0,UQ.default)(this,"issues",void 0),this.name="SchemaError",this.issues=t}};function Y0(t){let n=t,e="~standard"in n;if(typeof n=="function"&&typeof n.assert=="function")return n.assert.bind(n);if(typeof n=="function"&&!e)return n;if(typeof n.parseAsync=="function")return n.parseAsync.bind(n);if(typeof n.parse=="function")return n.parse.bind(n);if(typeof n.validateSync=="function")return n.validateSync.bind(n);if(typeof n.create=="function")return n.create.bind(n);if(typeof n.assert=="function")return r=>(n.assert(r),r);if(e)return async r=>{let i=await n["~standard"].validate(r);if(i.issues)throw new X0(i.issues);return i.value};throw new Error("Could not find a validator fn")}var VQ=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutPropertiesLoose.js"(t,n){function e(r,i){if(r==null)return{};var o={};for(var s in r)if({}.hasOwnProperty.call(r,s)){if(i.includes(s))continue;o[s]=r[s]}return o}n.exports=e,n.exports.__esModule=!0,n.exports.default=n.exports}}),WQ=wt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutProperties.js"(t,n){var e=VQ();function r(i,o){if(i==null)return{};var s,a,c=e(i,o);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(i);for(a=0;a<u.length;a++)s=u[a],o.includes(s)||{}.propertyIsEnumerable.call(i,s)&&(c[s]=i[s])}return c}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),GQ=Se(WQ(),1),Xe=Se(Ut(),1),zQ=["middlewares","inputs","meta"];function Vr(t,n){let{middlewares:e=[],inputs:r,meta:i}=n,o=(0,GQ.default)(n,zQ);return eO((0,Xe.default)((0,Xe.default)({},Th(t,o)),{},{inputs:[...t.inputs,...r??[]],middlewares:[...t.middlewares,...e],meta:t.meta&&i?(0,Xe.default)((0,Xe.default)({},t.meta),i):i??t.meta}))}function eO(t={}){let n=(0,Xe.default)({procedure:!0,inputs:[],middlewares:[]},t);return{_def:n,input(r){let i=Y0(r);return Vr(n,{inputs:[r],middlewares:[BQ(i)]})},output(r){let i=Y0(r);return Vr(n,{output:r,middlewares:[HQ(i)]})},meta(r){return Vr(n,{meta:r})},use(r){let i="_middlewares"in r?r._middlewares:[r];return Vr(n,{middlewares:i})},unstable_concat(r){return Vr(n,r._def)},concat(r){return Vr(n,r._def)},query(r){return db((0,Xe.default)((0,Xe.default)({},n),{},{type:"query"}),r)},mutation(r){return db((0,Xe.default)((0,Xe.default)({},n),{},{type:"mutation"}),r)},subscription(r){return db((0,Xe.default)((0,Xe.default)({},n),{},{type:"subscription"}),r)},experimental_caller(r){return Vr(n,{caller:r})}}}function db(t,n){let e=Vr(t,{resolver:n,middlewares:[async function(c){let u=await n(c);return{marker:J0,ok:!0,data:u,ctx:c.ctx}}]}),r=(0,Xe.default)((0,Xe.default)({},e._def),{},{type:t.type,experimental_caller:!!e._def.caller,meta:e._def.meta,$types:null}),i=YQ(e._def),o=e._def.caller;if(!o)return i;let s=async(...a)=>await o({args:a,invoke:i,_def:r});return s._def=r,s}var KQ=`
15
15
  This is a client-only function.
16
16
  If you want to call this function on the server, see https://trpc.io/docs/v11/server/server-side-calls
17
- `.trim();async function tO(t,n,e){try{let r=n.middlewares[t];return await r((0,Xe.default)((0,Xe.default)({},e),{},{meta:n.meta,input:e.input,next(o){var s;let a=o;return tO(t+1,n,(0,Xe.default)((0,Xe.default)({},e),{},{ctx:a?.ctx?(0,Xe.default)((0,Xe.default)({},e.ctx),a.ctx):e.ctx,input:a&&"input"in a?a.input:e.input,getRawInput:(s=a?.getRawInput)!==null&&s!==void 0?s:e.getRawInput}))}}))}catch(r){return{ok:!1,error:Yt(r),marker:JD}}}function KQ(t){async function n(e){if(!e||!("getRawInput"in e))throw new Error(zQ);let r=await tO(0,t,e);if(!r)throw new Ue({code:"INTERNAL_SERVER_ERROR",message:"No result from middlewares - did you forget to `return next()`?"});if(!r.ok)throw r.error;return r.data}return n._def=t,n.procedure=!0,n.meta=t.meta,n}var ws,Es,Ss,ZD=typeof window>"u"||"Deno"in window||((ws=globalThis.process)===null||ws===void 0||(ws=ws.env)===null||ws===void 0?void 0:ws.NODE_ENV)==="test"||!!(!((Es=globalThis.process)===null||Es===void 0||(Es=Es.env)===null||Es===void 0)&&Es.JEST_WORKER_ID)||!!(!((Ss=globalThis.process)===null||Ss===void 0||(Ss=Ss.env)===null||Ss===void 0)&&Ss.VITEST_WORKER_ID),QD=Se(Ut(),1),YQ=class fb{context(){return new fb}meta(){return new fb}create(n){var e,r,i,o,s,a;let c=(0,QD.default)((0,QD.default)({},n),{},{transformer:ED((e=n?.transformer)!==null&&e!==void 0?e:_s),isDev:(r=n?.isDev)!==null&&r!==void 0?r:((i=globalThis.process)===null||i===void 0?void 0:i.env.NODE_ENV)!=="production",allowOutsideOfServer:(o=n?.allowOutsideOfServer)!==null&&o!==void 0?o:!1,errorFormatter:(s=n?.errorFormatter)!==null&&s!==void 0?s:vs,isServer:(a=n?.isServer)!==null&&a!==void 0?a:ZD,$types:null});{var u;if(!((u=n?.isServer)!==null&&u!==void 0?u:ZD)&&n?.allowOutsideOfServer!==!0)throw new Error("You're trying to use @trpc/server in a non-server environment. This is not supported by default.")}return{_config:c,procedure:eO({meta:n?.defaultMeta}),middleware:$Q(),router:Z_(c),mergeRouters:SD,createCallerFactory:Q_()}}},hb=new YQ;var nO=hb.context().create({allowOutsideOfServer:!0}),yt=nO.router,fe=nO.procedure;var rO=yt({ping:fe.query(()=>({status:"ok",timestamp:Date.now()}))});var q={};jR(q,{BRAND:()=>w7,DIRTY:()=>$i,EMPTY_PATH:()=>XQ,INVALID:()=>J,NEVER:()=>oJ,OK:()=>vt,ParseStatus:()=>ht,Schema:()=>de,ZodAny:()=>Lh,ZodArray:()=>ic,ZodBigInt:()=>yb,ZodBoolean:()=>vb,ZodBranded:()=>oc,ZodCatch:()=>Db,ZodDate:()=>_b,ZodDefault:()=>xb,ZodDiscriminatedUnion:()=>jh,ZodEffects:()=>Os,ZodEnum:()=>Bh,ZodError:()=>xn,ZodFirstPartyTypeKind:()=>te,ZodFunction:()=>$h,ZodIntersection:()=>Sb,ZodIssueCode:()=>I,ZodLazy:()=>Cb,ZodLiteral:()=>Ib,ZodMap:()=>hO,ZodNaN:()=>gO,ZodNativeEnum:()=>Tb,ZodNever:()=>qi,ZodNull:()=>wb,ZodNullable:()=>Ms,ZodNumber:()=>gb,ZodObject:()=>xs,ZodOptional:()=>Gr,ZodParsedType:()=>F,ZodPipeline:()=>sc,ZodPromise:()=>Hh,ZodReadonly:()=>Ob,ZodRecord:()=>Fh,ZodSchema:()=>de,ZodSet:()=>pO,ZodString:()=>qh,ZodSymbol:()=>dO,ZodTransformer:()=>Os,ZodTuple:()=>Ds,ZodType:()=>de,ZodUndefined:()=>bb,ZodUnion:()=>Eb,ZodUnknown:()=>rc,ZodVoid:()=>fO,addIssueToContext:()=>R,any:()=>M7,array:()=>R7,bigint:()=>I7,boolean:()=>bO,coerce:()=>iJ,custom:()=>yO,date:()=>T7,datetimeRegex:()=>lO,defaultErrorMap:()=>Kn,discriminatedUnion:()=>F7,effect:()=>Z7,enum:()=>z7,function:()=>V7,getErrorMap:()=>Cs,getParsedType:()=>Tn,instanceof:()=>S7,intersection:()=>$7,isAborted:()=>Rh,isAsync:()=>Is,isDirty:()=>kh,isValid:()=>Wr,late:()=>E7,lazy:()=>W7,literal:()=>G7,makeIssue:()=>nc,map:()=>H7,nan:()=>C7,nativeEnum:()=>K7,never:()=>N7,null:()=>O7,nullable:()=>J7,number:()=>_O,object:()=>k7,objectUtil:()=>iO,oboolean:()=>rJ,onumber:()=>nJ,optional:()=>Q7,ostring:()=>tJ,pipeline:()=>eJ,preprocess:()=>X7,promise:()=>Y7,quotelessJson:()=>ZQ,record:()=>B7,set:()=>U7,setErrorMap:()=>JQ,strictObject:()=>L7,string:()=>vO,symbol:()=>x7,transformer:()=>Z7,tuple:()=>q7,undefined:()=>D7,union:()=>j7,unknown:()=>A7,util:()=>we,void:()=>P7});var we;(function(t){t.assertEqual=i=>{};function n(i){}t.assertIs=n;function e(i){throw new Error}t.assertNever=e,t.arrayToEnum=i=>{let o={};for(let s of i)o[s]=s;return o},t.getValidEnumValues=i=>{let o=t.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),s={};for(let a of o)s[a]=i[a];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(o){return i[o]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let o=[];for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&o.push(s);return o},t.find=(i,o)=>{for(let s of i)if(o(s))return s},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,o=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(o)}t.joinValues=r,t.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(we||(we={}));var iO=(function(t){return t.mergeShapes=(n,e)=>({...n,...e}),t})(iO||{}),F=we.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Tn=t=>{switch(typeof t){case"undefined":return F.undefined;case"string":return F.string;case"number":return Number.isNaN(t)?F.nan:F.number;case"boolean":return F.boolean;case"function":return F.function;case"bigint":return F.bigint;case"symbol":return F.symbol;case"object":return Array.isArray(t)?F.array:t===null?F.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?F.promise:typeof Map<"u"&&t instanceof Map?F.map:typeof Set<"u"&&t instanceof Set?F.set:typeof Date<"u"&&t instanceof Date?F.date:F.object;default:return F.unknown}};var I=we.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),ZQ=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),xn=(()=>{class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(s){return s.message},i={_errors:[]},o=s=>{for(let a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(o);else if(a.code==="invalid_return_type")o(a.returnTypeError);else if(a.code==="invalid_arguments")o(a.argumentsError);else if(a.path.length===0)i._errors.push(r(a));else{let c=i,u=0;for(;u<a.path.length;){let l=a.path[u];u===a.path.length-1?(c[l]=c[l]||{_errors:[]},c[l]._errors.push(r(a))):c[l]=c[l]||{_errors:[]},c=c[l],u++}}};return o(this),i}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,we.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},i=[];for(let o of this.issues)if(o.path.length>0){let s=o.path[0];r[s]=r[s]||[],r[s].push(e(o))}else i.push(e(o));return{formErrors:i,fieldErrors:r}}get formErrors(){return this.flatten()}}return t.create=n=>new t(n),t})();var QQ=(t,n)=>{let e;switch(t.code){case I.invalid_type:t.received===F.undefined?e="Required":e=`Expected ${t.expected}, received ${t.received}`;break;case I.invalid_literal:e=`Invalid literal value, expected ${JSON.stringify(t.expected,we.jsonStringifyReplacer)}`;break;case I.unrecognized_keys:e=`Unrecognized key(s) in object: ${we.joinValues(t.keys,", ")}`;break;case I.invalid_union:e="Invalid input";break;case I.invalid_union_discriminator:e=`Invalid discriminator value. Expected ${we.joinValues(t.options)}`;break;case I.invalid_enum_value:e=`Invalid enum value. Expected ${we.joinValues(t.options)}, received '${t.received}'`;break;case I.invalid_arguments:e="Invalid function arguments";break;case I.invalid_return_type:e="Invalid function return type";break;case I.invalid_date:e="Invalid date";break;case I.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(e=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(e=`${e} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?e=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?e=`Invalid input: must end with "${t.validation.endsWith}"`:we.assertNever(t.validation):t.validation!=="regex"?e=`Invalid ${t.validation}`:e="Invalid";break;case I.too_small:t.type==="array"?e=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?e=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?e=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?e=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?e=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:e="Invalid input";break;case I.too_big:t.type==="array"?e=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?e=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?e=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?e=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?e=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:e="Invalid input";break;case I.custom:e="Invalid input";break;case I.invalid_intersection_types:e="Intersection results could not be merged";break;case I.not_multiple_of:e=`Number must be a multiple of ${t.multipleOf}`;break;case I.not_finite:e="Number must be finite";break;default:e=n.defaultError,we.assertNever(t)}return{message:e}},Kn=QQ;var oO=Kn;function JQ(t){oO=t}function Cs(){return oO}var nc=t=>{let{data:n,path:e,errorMaps:r,issueData:i}=t,o=[...e,...i.path||[]],s={...i,path:o};if(i.message!==void 0)return{...i,path:o,message:i.message};let a="",c=r.filter(u=>!!u).slice().reverse();for(let u of c)a=u(s,{data:n,defaultError:a}).message;return{...i,path:o,message:a}},XQ=[];function R(t,n){let e=Cs(),r=nc({issueData:n,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,e,e===Kn?void 0:Kn].filter(i=>!!i)});t.common.issues.push(r)}var ht=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(n,e){let r=[];for(let i of e){if(i.status==="aborted")return J;i.status==="dirty"&&n.dirty(),r.push(i.value)}return{status:n.value,value:r}}static async mergeObjectAsync(n,e){let r=[];for(let i of e){let o=await i.key,s=await i.value;r.push({key:o,value:s})}return t.mergeObjectSync(n,r)}static mergeObjectSync(n,e){let r={};for(let i of e){let{key:o,value:s}=i;if(o.status==="aborted"||s.status==="aborted")return J;o.status==="dirty"&&n.dirty(),s.status==="dirty"&&n.dirty(),o.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(r[o.value]=s.value)}return{status:n.value,value:r}}},J=Object.freeze({status:"aborted"}),$i=t=>({status:"dirty",value:t}),vt=t=>({status:"valid",value:t}),Rh=t=>t.status==="aborted",kh=t=>t.status==="dirty",Wr=t=>t.status==="valid",Is=t=>typeof Promise<"u"&&t instanceof Promise;var W=(function(t){return t.errToObj=n=>typeof n=="string"?{message:n}:n||{},t.toString=n=>typeof n=="string"?n:n?.message,t})(W||{});var Qt=class{constructor(n,e,r,i){this._cachedPath=[],this.parent=n,this.data=e,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},sO=(t,n)=>{if(Wr(n))return{success:!0,data:n.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let e=new xn(t.common.issues);return this._error=e,this._error}}};function ae(t){if(!t)return{};let{errorMap:n,invalid_type_error:e,required_error:r,description:i}=t;if(n&&(e||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return n?{errorMap:n,description:i}:{errorMap:(s,a)=>{let{message:c}=t;return s.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??r??a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:c??e??a.defaultError}},description:i}}var de=class{get description(){return this._def.description}_getType(n){return Tn(n.data)}_getOrReturnCtx(n,e){return e||{common:n.parent.common,data:n.data,parsedType:Tn(n.data),schemaErrorMap:this._def.errorMap,path:n.path,parent:n.parent}}_processInputParams(n){return{status:new ht,ctx:{common:n.parent.common,data:n.data,parsedType:Tn(n.data),schemaErrorMap:this._def.errorMap,path:n.path,parent:n.parent}}}_parseSync(n){let e=this._parse(n);if(Is(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(n){let e=this._parse(n);return Promise.resolve(e)}parse(n,e){let r=this.safeParse(n,e);if(r.success)return r.data;throw r.error}safeParse(n,e){let r={common:{issues:[],async:e?.async??!1,contextualErrorMap:e?.errorMap},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:n,parsedType:Tn(n)},i=this._parseSync({data:n,path:r.path,parent:r});return sO(r,i)}"~validate"(n){let e={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:n,parsedType:Tn(n)};if(!this["~standard"].async)try{let r=this._parseSync({data:n,path:[],parent:e});return Wr(r)?{value:r.value}:{issues:e.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),e.common={issues:[],async:!0}}return this._parseAsync({data:n,path:[],parent:e}).then(r=>Wr(r)?{value:r.value}:{issues:e.common.issues})}async parseAsync(n,e){let r=await this.safeParseAsync(n,e);if(r.success)return r.data;throw r.error}async safeParseAsync(n,e){let r={common:{issues:[],contextualErrorMap:e?.errorMap,async:!0},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:n,parsedType:Tn(n)},i=this._parse({data:n,path:r.path,parent:r}),o=await(Is(i)?i:Promise.resolve(i));return sO(r,o)}refine(n,e){let r=i=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(i):e;return this._refinement((i,o)=>{let s=n(i),a=()=>o.addIssue({code:I.custom,...r(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(c=>c?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(n,e){return this._refinement((r,i)=>n(r)?!0:(i.addIssue(typeof e=="function"?e(r,i):e),!1))}_refinement(n){return new Os({schema:this,typeName:te.ZodEffects,effect:{type:"refinement",refinement:n}})}superRefine(n){return this._refinement(n)}constructor(n){this.spa=this.safeParseAsync,this._def=n,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Gr.create(this,this._def)}nullable(){return Ms.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ic.create(this)}promise(){return Hh.create(this,this._def)}or(n){return Eb.create([this,n],this._def)}and(n){return Sb.create(this,n,this._def)}transform(n){return new Os({...ae(this._def),schema:this,typeName:te.ZodEffects,effect:{type:"transform",transform:n}})}default(n){let e=typeof n=="function"?n:()=>n;return new xb({...ae(this._def),innerType:this,defaultValue:e,typeName:te.ZodDefault})}brand(){return new oc({typeName:te.ZodBranded,type:this,...ae(this._def)})}catch(n){let e=typeof n=="function"?n:()=>n;return new Db({...ae(this._def),innerType:this,catchValue:e,typeName:te.ZodCatch})}describe(n){let e=this.constructor;return new e({...this._def,description:n})}pipe(n){return sc.create(this,n)}readonly(){return Ob.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},e7=/^c[^\s-]{8,}$/i,t7=/^[0-9a-z]+$/,n7=/^[0-9A-HJKMNP-TV-Z]{26}$/i,r7=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,i7=/^[a-z0-9_-]{21}$/i,o7=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,s7=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,a7=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,c7="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",pb,u7=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,l7=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,d7=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,f7=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,h7=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,p7=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,cO="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",m7=new RegExp(`^${cO}$`);function uO(t){let n="[0-5]\\d";t.precision?n=`${n}\\.\\d{${t.precision}}`:t.precision==null&&(n=`${n}(\\.\\d+)?`);let e=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${n})${e}`}function g7(t){return new RegExp(`^${uO(t)}$`)}function lO(t){let n=`${cO}T${uO(t)}`,e=[];return e.push(t.local?"Z?":"Z"),t.offset&&e.push("([+-]\\d{2}:?\\d{2})"),n=`${n}(${e.join("|")})`,new RegExp(`^${n}$`)}function y7(t,n){return!!((n==="v4"||!n)&&u7.test(t)||(n==="v6"||!n)&&d7.test(t))}function v7(t,n){if(!o7.test(t))return!1;try{let[e]=t.split(".");if(!e)return!1;let r=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||n&&i.alg!==n)}catch{return!1}}function _7(t,n){return!!((n==="v4"||!n)&&l7.test(t)||(n==="v6"||!n)&&f7.test(t))}var qh=(()=>{class t extends de{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==F.string){let s=this._getOrReturnCtx(e);return R(s,{code:I.invalid_type,expected:F.string,received:s.parsedType}),J}let i=new ht,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),R(o,{code:I.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),i.dirty());else if(s.kind==="max")e.data.length>s.value&&(o=this._getOrReturnCtx(e,o),R(o,{code:I.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),i.dirty());else if(s.kind==="length"){let a=e.data.length>s.value,c=e.data.length<s.value;(a||c)&&(o=this._getOrReturnCtx(e,o),a?R(o,{code:I.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&R(o,{code:I.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),i.dirty())}else if(s.kind==="email")a7.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"email",code:I.invalid_string,message:s.message}),i.dirty());else if(s.kind==="emoji")pb||(pb=new RegExp(c7,"u")),pb.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"emoji",code:I.invalid_string,message:s.message}),i.dirty());else if(s.kind==="uuid")r7.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"uuid",code:I.invalid_string,message:s.message}),i.dirty());else if(s.kind==="nanoid")i7.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"nanoid",code:I.invalid_string,message:s.message}),i.dirty());else if(s.kind==="cuid")e7.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"cuid",code:I.invalid_string,message:s.message}),i.dirty());else if(s.kind==="cuid2")t7.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"cuid2",code:I.invalid_string,message:s.message}),i.dirty());else if(s.kind==="ulid")n7.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"ulid",code:I.invalid_string,message:s.message}),i.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),R(o,{validation:"url",code:I.invalid_string,message:s.message}),i.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"regex",code:I.invalid_string,message:s.message}),i.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(e,o),R(o,{code:I.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),i.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(o=this._getOrReturnCtx(e,o),R(o,{code:I.invalid_string,validation:{startsWith:s.value},message:s.message}),i.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),R(o,{code:I.invalid_string,validation:{endsWith:s.value},message:s.message}),i.dirty()):s.kind==="datetime"?lO(s).test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{code:I.invalid_string,validation:"datetime",message:s.message}),i.dirty()):s.kind==="date"?m7.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{code:I.invalid_string,validation:"date",message:s.message}),i.dirty()):s.kind==="time"?g7(s).test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{code:I.invalid_string,validation:"time",message:s.message}),i.dirty()):s.kind==="duration"?s7.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"duration",code:I.invalid_string,message:s.message}),i.dirty()):s.kind==="ip"?y7(e.data,s.version)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"ip",code:I.invalid_string,message:s.message}),i.dirty()):s.kind==="jwt"?v7(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"jwt",code:I.invalid_string,message:s.message}),i.dirty()):s.kind==="cidr"?_7(e.data,s.version)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"cidr",code:I.invalid_string,message:s.message}),i.dirty()):s.kind==="base64"?h7.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"base64",code:I.invalid_string,message:s.message}),i.dirty()):s.kind==="base64url"?p7.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"base64url",code:I.invalid_string,message:s.message}),i.dirty()):we.assertNever(s);return{status:i.value,value:e.data}}_regex(e,r,i){return this.refinement(o=>e.test(o),{validation:r,code:I.invalid_string,...W.errToObj(i)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...W.errToObj(e)})}url(e){return this._addCheck({kind:"url",...W.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...W.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...W.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...W.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...W.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...W.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...W.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...W.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...W.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...W.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...W.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...W.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...W.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...W.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...W.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...W.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...W.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...W.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...W.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...W.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...W.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...W.errToObj(r)})}nonempty(e){return this.min(1,W.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}return t.create=n=>new t({checks:[],typeName:te.ZodString,coerce:n?.coerce??!1,...ae(n)}),t})();function b7(t,n){let e=(t.toString().split(".")[1]||"").length,r=(n.toString().split(".")[1]||"").length,i=e>r?e:r,o=Number.parseInt(t.toFixed(i).replace(".","")),s=Number.parseInt(n.toFixed(i).replace(".",""));return o%s/10**i}var gb=(()=>{class t extends de{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==F.number){let s=this._getOrReturnCtx(e);return R(s,{code:I.invalid_type,expected:F.number,received:s.parsedType}),J}let i,o=new ht;for(let s of this._def.checks)s.kind==="int"?we.isInteger(e.data)||(i=this._getOrReturnCtx(e,i),R(i,{code:I.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(i=this._getOrReturnCtx(e,i),R(i,{code:I.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(i=this._getOrReturnCtx(e,i),R(i,{code:I.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?b7(e.data,s.value)!==0&&(i=this._getOrReturnCtx(e,i),R(i,{code:I.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(i=this._getOrReturnCtx(e,i),R(i,{code:I.not_finite,message:s.message}),o.dirty()):we.assertNever(s);return{status:o.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,W.toString(r))}gt(e,r){return this.setLimit("min",e,!1,W.toString(r))}lte(e,r){return this.setLimit("max",e,!0,W.toString(r))}lt(e,r){return this.setLimit("max",e,!1,W.toString(r))}setLimit(e,r,i,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:i,message:W.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:W.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:W.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:W.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:W.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:W.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:W.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:W.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:W.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:W.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&we.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(r===null||i.value>r)&&(r=i.value):i.kind==="max"&&(e===null||i.value<e)&&(e=i.value)}return Number.isFinite(r)&&Number.isFinite(e)}}return t.create=n=>new t({checks:[],typeName:te.ZodNumber,coerce:n?.coerce||!1,...ae(n)}),t})(),yb=(()=>{class t extends de{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==F.bigint)return this._getInvalidInput(e);let i,o=new ht;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(i=this._getOrReturnCtx(e,i),R(i,{code:I.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(i=this._getOrReturnCtx(e,i),R(i,{code:I.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(i=this._getOrReturnCtx(e,i),R(i,{code:I.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):we.assertNever(s);return{status:o.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return R(r,{code:I.invalid_type,expected:F.bigint,received:r.parsedType}),J}gte(e,r){return this.setLimit("min",e,!0,W.toString(r))}gt(e,r){return this.setLimit("min",e,!1,W.toString(r))}lte(e,r){return this.setLimit("max",e,!0,W.toString(r))}lt(e,r){return this.setLimit("max",e,!1,W.toString(r))}setLimit(e,r,i,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:i,message:W.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:W.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:W.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:W.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:W.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:W.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}return t.create=n=>new t({checks:[],typeName:te.ZodBigInt,coerce:n?.coerce??!1,...ae(n)}),t})(),vb=(()=>{class t extends de{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==F.boolean){let i=this._getOrReturnCtx(e);return R(i,{code:I.invalid_type,expected:F.boolean,received:i.parsedType}),J}return vt(e.data)}}return t.create=n=>new t({typeName:te.ZodBoolean,coerce:n?.coerce||!1,...ae(n)}),t})(),_b=(()=>{class t extends de{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==F.date){let s=this._getOrReturnCtx(e);return R(s,{code:I.invalid_type,expected:F.date,received:s.parsedType}),J}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return R(s,{code:I.invalid_date}),J}let i=new ht,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),R(o,{code:I.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),i.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(o=this._getOrReturnCtx(e,o),R(o,{code:I.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),i.dirty()):we.assertNever(s);return{status:i.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:W.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:W.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}return t.create=n=>new t({checks:[],coerce:n?.coerce||!1,typeName:te.ZodDate,...ae(n)}),t})(),dO=(()=>{class t extends de{_parse(e){if(this._getType(e)!==F.symbol){let i=this._getOrReturnCtx(e);return R(i,{code:I.invalid_type,expected:F.symbol,received:i.parsedType}),J}return vt(e.data)}}return t.create=n=>new t({typeName:te.ZodSymbol,...ae(n)}),t})(),bb=(()=>{class t extends de{_parse(e){if(this._getType(e)!==F.undefined){let i=this._getOrReturnCtx(e);return R(i,{code:I.invalid_type,expected:F.undefined,received:i.parsedType}),J}return vt(e.data)}}return t.create=n=>new t({typeName:te.ZodUndefined,...ae(n)}),t})(),wb=(()=>{class t extends de{_parse(e){if(this._getType(e)!==F.null){let i=this._getOrReturnCtx(e);return R(i,{code:I.invalid_type,expected:F.null,received:i.parsedType}),J}return vt(e.data)}}return t.create=n=>new t({typeName:te.ZodNull,...ae(n)}),t})(),Lh=(()=>{class t extends de{constructor(){super(...arguments),this._any=!0}_parse(e){return vt(e.data)}}return t.create=n=>new t({typeName:te.ZodAny,...ae(n)}),t})(),rc=(()=>{class t extends de{constructor(){super(...arguments),this._unknown=!0}_parse(e){return vt(e.data)}}return t.create=n=>new t({typeName:te.ZodUnknown,...ae(n)}),t})(),qi=(()=>{class t extends de{_parse(e){let r=this._getOrReturnCtx(e);return R(r,{code:I.invalid_type,expected:F.never,received:r.parsedType}),J}}return t.create=n=>new t({typeName:te.ZodNever,...ae(n)}),t})(),fO=(()=>{class t extends de{_parse(e){if(this._getType(e)!==F.undefined){let i=this._getOrReturnCtx(e);return R(i,{code:I.invalid_type,expected:F.void,received:i.parsedType}),J}return vt(e.data)}}return t.create=n=>new t({typeName:te.ZodVoid,...ae(n)}),t})(),ic=(()=>{class t extends de{_parse(e){let{ctx:r,status:i}=this._processInputParams(e),o=this._def;if(r.parsedType!==F.array)return R(r,{code:I.invalid_type,expected:F.array,received:r.parsedType}),J;if(o.exactLength!==null){let a=r.data.length>o.exactLength.value,c=r.data.length<o.exactLength.value;(a||c)&&(R(r,{code:a?I.too_big:I.too_small,minimum:c?o.exactLength.value:void 0,maximum:a?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),i.dirty())}if(o.minLength!==null&&r.data.length<o.minLength.value&&(R(r,{code:I.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),i.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&(R(r,{code:I.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),i.dirty()),r.common.async)return Promise.all([...r.data].map((a,c)=>o.type._parseAsync(new Qt(r,a,r.path,c)))).then(a=>ht.mergeArray(i,a));let s=[...r.data].map((a,c)=>o.type._parseSync(new Qt(r,a,r.path,c)));return ht.mergeArray(i,s)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:W.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:W.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:W.toString(r)}})}nonempty(e){return this.min(1,e)}}return t.create=(n,e)=>new t({type:n,minLength:null,maxLength:null,exactLength:null,typeName:te.ZodArray,...ae(e)}),t})();function Ts(t){if(t instanceof xs){let n={};for(let e in t.shape){let r=t.shape[e];n[e]=Gr.create(Ts(r))}return new xs({...t._def,shape:()=>n})}else return t instanceof ic?new ic({...t._def,type:Ts(t.element)}):t instanceof Gr?Gr.create(Ts(t.unwrap())):t instanceof Ms?Ms.create(Ts(t.unwrap())):t instanceof Ds?Ds.create(t.items.map(n=>Ts(n))):t}var xs=(()=>{class t extends de{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=we.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==F.object){let l=this._getOrReturnCtx(e);return R(l,{code:I.invalid_type,expected:F.object,received:l.parsedType}),J}let{status:i,ctx:o}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),c=[];if(!(this._def.catchall instanceof qi&&this._def.unknownKeys==="strip"))for(let l in o.data)a.includes(l)||c.push(l);let u=[];for(let l of a){let d=s[l],f=o.data[l];u.push({key:{status:"valid",value:l},value:d._parse(new Qt(o,f,o.path,l)),alwaysSet:l in o.data})}if(this._def.catchall instanceof qi){let l=this._def.unknownKeys;if(l==="passthrough")for(let d of c)u.push({key:{status:"valid",value:d},value:{status:"valid",value:o.data[d]}});else if(l==="strict")c.length>0&&(R(o,{code:I.unrecognized_keys,keys:c}),i.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let d of c){let f=o.data[d];u.push({key:{status:"valid",value:d},value:l._parse(new Qt(o,f,o.path,d)),alwaysSet:d in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let l=[];for(let d of u){let f=await d.key,p=await d.value;l.push({key:f,value:p,alwaysSet:d.alwaysSet})}return l}).then(l=>ht.mergeObjectSync(i,l)):ht.mergeObjectSync(i,u)}get shape(){return this._def.shape()}strict(e){return W.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,i)=>{let o=this._def.errorMap?.(r,i).message??i.defaultError;return r.code==="unrecognized_keys"?{message:W.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:te.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let i of we.objectKeys(e))e[i]&&this.shape[i]&&(r[i]=this.shape[i]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let i of we.objectKeys(this.shape))e[i]||(r[i]=this.shape[i]);return new t({...this._def,shape:()=>r})}deepPartial(){return Ts(this)}partial(e){let r={};for(let i of we.objectKeys(this.shape)){let o=this.shape[i];e&&!e[i]?r[i]=o:r[i]=o.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let i of we.objectKeys(this.shape))if(e&&!e[i])r[i]=this.shape[i];else{let s=this.shape[i];for(;s instanceof Gr;)s=s._def.innerType;r[i]=s}return new t({...this._def,shape:()=>r})}keyof(){return mO(we.objectKeys(this.shape))}}return t.create=(n,e)=>new t({shape:()=>n,unknownKeys:"strip",catchall:qi.create(),typeName:te.ZodObject,...ae(e)}),t.strictCreate=(n,e)=>new t({shape:()=>n,unknownKeys:"strict",catchall:qi.create(),typeName:te.ZodObject,...ae(e)}),t.lazycreate=(n,e)=>new t({shape:n,unknownKeys:"strip",catchall:qi.create(),typeName:te.ZodObject,...ae(e)}),t})(),Eb=(()=>{class t extends de{_parse(e){let{ctx:r}=this._processInputParams(e),i=this._def.options;function o(s){for(let c of s)if(c.result.status==="valid")return c.result;for(let c of s)if(c.result.status==="dirty")return r.common.issues.push(...c.ctx.common.issues),c.result;let a=s.map(c=>new xn(c.ctx.common.issues));return R(r,{code:I.invalid_union,unionErrors:a}),J}if(r.common.async)return Promise.all(i.map(async s=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(o);{let s,a=[];for(let u of i){let l={...r,common:{...r.common,issues:[]},parent:null},d=u._parseSync({data:r.data,path:r.path,parent:l});if(d.status==="valid")return d;d.status==="dirty"&&!s&&(s={result:d,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let c=a.map(u=>new xn(u));return R(r,{code:I.invalid_union,unionErrors:c}),J}}get options(){return this._def.options}}return t.create=(n,e)=>new t({options:n,typeName:te.ZodUnion,...ae(e)}),t})(),Yn=t=>t instanceof Cb?Yn(t.schema):t instanceof Os?Yn(t.innerType()):t instanceof Ib?[t.value]:t instanceof Bh?t.options:t instanceof Tb?we.objectValues(t.enum):t instanceof xb?Yn(t._def.innerType):t instanceof bb?[void 0]:t instanceof wb?[null]:t instanceof Gr?[void 0,...Yn(t.unwrap())]:t instanceof Ms?[null,...Yn(t.unwrap())]:t instanceof oc||t instanceof Ob?Yn(t.unwrap()):t instanceof Db?Yn(t._def.innerType):[],jh=class t extends de{_parse(n){let{ctx:e}=this._processInputParams(n);if(e.parsedType!==F.object)return R(e,{code:I.invalid_type,expected:F.object,received:e.parsedType}),J;let r=this.discriminator,i=e.data[r],o=this.optionsMap.get(i);return o?e.common.async?o._parseAsync({data:e.data,path:e.path,parent:e}):o._parseSync({data:e.data,path:e.path,parent:e}):(R(e,{code:I.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),J)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(n,e,r){let i=new Map;for(let o of e){let s=Yn(o.shape[n]);if(!s.length)throw new Error(`A discriminator value for key \`${n}\` could not be extracted from all schema options`);for(let a of s){if(i.has(a))throw new Error(`Discriminator property ${String(n)} has duplicate value ${String(a)}`);i.set(a,o)}}return new t({typeName:te.ZodDiscriminatedUnion,discriminator:n,options:e,optionsMap:i,...ae(r)})}};function mb(t,n){let e=Tn(t),r=Tn(n);if(t===n)return{valid:!0,data:t};if(e===F.object&&r===F.object){let i=we.objectKeys(n),o=we.objectKeys(t).filter(a=>i.indexOf(a)!==-1),s={...t,...n};for(let a of o){let c=mb(t[a],n[a]);if(!c.valid)return{valid:!1};s[a]=c.data}return{valid:!0,data:s}}else if(e===F.array&&r===F.array){if(t.length!==n.length)return{valid:!1};let i=[];for(let o=0;o<t.length;o++){let s=t[o],a=n[o],c=mb(s,a);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return e===F.date&&r===F.date&&+t==+n?{valid:!0,data:t}:{valid:!1}}var Sb=(()=>{class t extends de{_parse(e){let{status:r,ctx:i}=this._processInputParams(e),o=(s,a)=>{if(Rh(s)||Rh(a))return J;let c=mb(s.value,a.value);return c.valid?((kh(s)||kh(a))&&r.dirty(),{status:r.value,value:c.data}):(R(i,{code:I.invalid_intersection_types}),J)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([s,a])=>o(s,a)):o(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}}return t.create=(n,e,r)=>new t({left:n,right:e,typeName:te.ZodIntersection,...ae(r)}),t})(),Ds=(()=>{class t extends de{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==F.array)return R(i,{code:I.invalid_type,expected:F.array,received:i.parsedType}),J;if(i.data.length<this._def.items.length)return R(i,{code:I.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),J;!this._def.rest&&i.data.length>this._def.items.length&&(R(i,{code:I.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let s=[...i.data].map((a,c)=>{let u=this._def.items[c]||this._def.rest;return u?u._parse(new Qt(i,a,i.path,c)):null}).filter(a=>!!a);return i.common.async?Promise.all(s).then(a=>ht.mergeArray(r,a)):ht.mergeArray(r,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}}return t.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new t({items:n,typeName:te.ZodTuple,rest:null,...ae(e)})},t})(),Fh=class t extends de{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(n){let{status:e,ctx:r}=this._processInputParams(n);if(r.parsedType!==F.object)return R(r,{code:I.invalid_type,expected:F.object,received:r.parsedType}),J;let i=[],o=this._def.keyType,s=this._def.valueType;for(let a in r.data)i.push({key:o._parse(new Qt(r,a,r.path,a)),value:s._parse(new Qt(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?ht.mergeObjectAsync(e,i):ht.mergeObjectSync(e,i)}get element(){return this._def.valueType}static create(n,e,r){return e instanceof de?new t({keyType:n,valueType:e,typeName:te.ZodRecord,...ae(r)}):new t({keyType:qh.create(),valueType:n,typeName:te.ZodRecord,...ae(e)})}},hO=(()=>{class t extends de{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==F.map)return R(i,{code:I.invalid_type,expected:F.map,received:i.parsedType}),J;let o=this._def.keyType,s=this._def.valueType,a=[...i.data.entries()].map(([c,u],l)=>({key:o._parse(new Qt(i,c,i.path,[l,"key"])),value:s._parse(new Qt(i,u,i.path,[l,"value"]))}));if(i.common.async){let c=new Map;return Promise.resolve().then(async()=>{for(let u of a){let l=await u.key,d=await u.value;if(l.status==="aborted"||d.status==="aborted")return J;(l.status==="dirty"||d.status==="dirty")&&r.dirty(),c.set(l.value,d.value)}return{status:r.value,value:c}})}else{let c=new Map;for(let u of a){let l=u.key,d=u.value;if(l.status==="aborted"||d.status==="aborted")return J;(l.status==="dirty"||d.status==="dirty")&&r.dirty(),c.set(l.value,d.value)}return{status:r.value,value:c}}}}return t.create=(n,e,r)=>new t({valueType:e,keyType:n,typeName:te.ZodMap,...ae(r)}),t})(),pO=(()=>{class t extends de{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==F.set)return R(i,{code:I.invalid_type,expected:F.set,received:i.parsedType}),J;let o=this._def;o.minSize!==null&&i.data.size<o.minSize.value&&(R(i,{code:I.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&i.data.size>o.maxSize.value&&(R(i,{code:I.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());let s=this._def.valueType;function a(u){let l=new Set;for(let d of u){if(d.status==="aborted")return J;d.status==="dirty"&&r.dirty(),l.add(d.value)}return{status:r.value,value:l}}let c=[...i.data.values()].map((u,l)=>s._parse(new Qt(i,u,i.path,l)));return i.common.async?Promise.all(c).then(u=>a(u)):a(c)}min(e,r){return new t({...this._def,minSize:{value:e,message:W.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:W.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}return t.create=(n,e)=>new t({valueType:n,minSize:null,maxSize:null,typeName:te.ZodSet,...ae(e)}),t})(),$h=class t extends de{constructor(){super(...arguments),this.validate=this.implement}_parse(n){let{ctx:e}=this._processInputParams(n);if(e.parsedType!==F.function)return R(e,{code:I.invalid_type,expected:F.function,received:e.parsedType}),J;function r(a,c){return nc({data:a,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,Cs(),Kn].filter(u=>!!u),issueData:{code:I.invalid_arguments,argumentsError:c}})}function i(a,c){return nc({data:a,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,Cs(),Kn].filter(u=>!!u),issueData:{code:I.invalid_return_type,returnTypeError:c}})}let o={errorMap:e.common.contextualErrorMap},s=e.data;if(this._def.returns instanceof Hh){let a=this;return vt(async function(...c){let u=new xn([]),l=await a._def.args.parseAsync(c,o).catch(p=>{throw u.addIssue(r(c,p)),u}),d=await Reflect.apply(s,this,l);return await a._def.returns._def.type.parseAsync(d,o).catch(p=>{throw u.addIssue(i(d,p)),u})})}else{let a=this;return vt(function(...c){let u=a._def.args.safeParse(c,o);if(!u.success)throw new xn([r(c,u.error)]);let l=Reflect.apply(s,this,u.data),d=a._def.returns.safeParse(l,o);if(!d.success)throw new xn([i(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...n){return new t({...this._def,args:Ds.create(n).rest(rc.create())})}returns(n){return new t({...this._def,returns:n})}implement(n){return this.parse(n)}strictImplement(n){return this.parse(n)}static create(n,e,r){return new t({args:n||Ds.create([]).rest(rc.create()),returns:e||rc.create(),typeName:te.ZodFunction,...ae(r)})}},Cb=(()=>{class t extends de{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}return t.create=(n,e)=>new t({getter:n,typeName:te.ZodLazy,...ae(e)}),t})(),Ib=(()=>{class t extends de{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return R(r,{received:r.data,code:I.invalid_literal,expected:this._def.value}),J}return{status:"valid",value:e.data}}get value(){return this._def.value}}return t.create=(n,e)=>new t({value:n,typeName:te.ZodLiteral,...ae(e)}),t})();function mO(t,n){return new Bh({values:t,typeName:te.ZodEnum,...ae(n)})}var Bh=(()=>{class t extends de{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),i=this._def.values;return R(r,{expected:we.joinValues(i),received:r.parsedType,code:I.invalid_type}),J}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),i=this._def.values;return R(r,{received:r.data,code:I.invalid_enum_value,options:i}),J}return vt(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(i=>!e.includes(i)),{...this._def,...r})}}return t.create=mO,t})(),Tb=(()=>{class t extends de{_parse(e){let r=we.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(e);if(i.parsedType!==F.string&&i.parsedType!==F.number){let o=we.objectValues(r);return R(i,{expected:we.joinValues(o),received:i.parsedType,code:I.invalid_type}),J}if(this._cache||(this._cache=new Set(we.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=we.objectValues(r);return R(i,{received:i.data,code:I.invalid_enum_value,options:o}),J}return vt(e.data)}get enum(){return this._def.values}}return t.create=(n,e)=>new t({values:n,typeName:te.ZodNativeEnum,...ae(e)}),t})(),Hh=(()=>{class t extends de{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==F.promise&&r.common.async===!1)return R(r,{code:I.invalid_type,expected:F.promise,received:r.parsedType}),J;let i=r.parsedType===F.promise?r.data:Promise.resolve(r.data);return vt(i.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}}return t.create=(n,e)=>new t({type:n,typeName:te.ZodPromise,...ae(e)}),t})(),Os=(()=>{class t extends de{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===te.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:i}=this._processInputParams(e),o=this._def.effect||null,s={addIssue:a=>{R(i,a),a.fatal?r.abort():r.dirty()},get path(){return i.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let a=o.transform(i.data,s);if(i.common.async)return Promise.resolve(a).then(async c=>{if(r.value==="aborted")return J;let u=await this._def.schema._parseAsync({data:c,path:i.path,parent:i});return u.status==="aborted"?J:u.status==="dirty"?$i(u.value):r.value==="dirty"?$i(u.value):u});{if(r.value==="aborted")return J;let c=this._def.schema._parseSync({data:a,path:i.path,parent:i});return c.status==="aborted"?J:c.status==="dirty"?$i(c.value):r.value==="dirty"?$i(c.value):c}}if(o.type==="refinement"){let a=c=>{let u=o.refinement(c,s);if(i.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(i.common.async===!1){let c=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return c.status==="aborted"?J:(c.status==="dirty"&&r.dirty(),a(c.value),{status:r.value,value:c.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(c=>c.status==="aborted"?J:(c.status==="dirty"&&r.dirty(),a(c.value).then(()=>({status:r.value,value:c.value}))))}if(o.type==="transform")if(i.common.async===!1){let a=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!Wr(a))return J;let c=o.transform(a.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:c}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(a=>Wr(a)?Promise.resolve(o.transform(a.value,s)).then(c=>({status:r.value,value:c})):J);we.assertNever(o)}}return t.create=(n,e,r)=>new t({schema:n,typeName:te.ZodEffects,effect:e,...ae(r)}),t.createWithPreprocess=(n,e,r)=>new t({schema:e,effect:{type:"preprocess",transform:n},typeName:te.ZodEffects,...ae(r)}),t})();var Gr=(()=>{class t extends de{_parse(e){return this._getType(e)===F.undefined?vt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}return t.create=(n,e)=>new t({innerType:n,typeName:te.ZodOptional,...ae(e)}),t})(),Ms=(()=>{class t extends de{_parse(e){return this._getType(e)===F.null?vt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}return t.create=(n,e)=>new t({innerType:n,typeName:te.ZodNullable,...ae(e)}),t})(),xb=(()=>{class t extends de{_parse(e){let{ctx:r}=this._processInputParams(e),i=r.data;return r.parsedType===F.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}return t.create=(n,e)=>new t({innerType:n,typeName:te.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ae(e)}),t})(),Db=(()=>{class t extends de{_parse(e){let{ctx:r}=this._processInputParams(e),i={...r,common:{...r.common,issues:[]}},o=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return Is(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new xn(i.common.issues)},input:i.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new xn(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}}return t.create=(n,e)=>new t({innerType:n,typeName:te.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ae(e)}),t})(),gO=(()=>{class t extends de{_parse(e){if(this._getType(e)!==F.nan){let i=this._getOrReturnCtx(e);return R(i,{code:I.invalid_type,expected:F.nan,received:i.parsedType}),J}return{status:"valid",value:e.data}}}return t.create=n=>new t({typeName:te.ZodNaN,...ae(n)}),t})(),w7=Symbol("zod_brand"),oc=class extends de{_parse(n){let{ctx:e}=this._processInputParams(n),r=e.data;return this._def.type._parse({data:r,path:e.path,parent:e})}unwrap(){return this._def.type}},sc=class t extends de{_parse(n){let{status:e,ctx:r}=this._processInputParams(n);if(r.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?J:o.status==="dirty"?(e.dirty(),$i(o.value)):this._def.out._parseAsync({data:o.value,path:r.path,parent:r})})();{let i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?J:i.status==="dirty"?(e.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(n,e){return new t({in:n,out:e,typeName:te.ZodPipeline})}},Ob=(()=>{class t extends de{_parse(e){let r=this._def.innerType._parse(e),i=o=>(Wr(o)&&(o.value=Object.freeze(o.value)),o);return Is(r)?r.then(o=>i(o)):i(r)}unwrap(){return this._def.innerType}}return t.create=(n,e)=>new t({innerType:n,typeName:te.ZodReadonly,...ae(e)}),t})();function aO(t,n){let e=typeof t=="function"?t(n):typeof t=="string"?{message:t}:t;return typeof e=="string"?{message:e}:e}function yO(t,n={},e){return t?Lh.create().superRefine((r,i)=>{let o=t(r);if(o instanceof Promise)return o.then(s=>{if(!s){let a=aO(n,r),c=a.fatal??e??!0;i.addIssue({code:"custom",...a,fatal:c})}});if(!o){let s=aO(n,r),a=s.fatal??e??!0;i.addIssue({code:"custom",...s,fatal:a})}}):Lh.create()}var E7={object:xs.lazycreate},te=(function(t){return t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly",t})(te||{});var S7=(t,n={message:`Input not instance of ${t.name}`})=>yO(e=>e instanceof t,n),vO=qh.create,_O=gb.create,C7=gO.create,I7=yb.create,bO=vb.create,T7=_b.create,x7=dO.create,D7=bb.create,O7=wb.create,M7=Lh.create,A7=rc.create,N7=qi.create,P7=fO.create,R7=ic.create,k7=xs.create,L7=xs.strictCreate,j7=Eb.create,F7=jh.create,$7=Sb.create,q7=Ds.create,B7=Fh.create,H7=hO.create,U7=pO.create,V7=$h.create,W7=Cb.create,G7=Ib.create,z7=Bh.create,K7=Tb.create,Y7=Hh.create,Z7=Os.create,Q7=Gr.create,J7=Ms.create,X7=Os.createWithPreprocess,eJ=sc.create,tJ=()=>vO().optional(),nJ=()=>_O().optional(),rJ=()=>bO().optional(),iJ={string:t=>qh.create({...t,coerce:!0}),number:t=>gb.create({...t,coerce:!0}),boolean:t=>vb.create({...t,coerce:!0}),bigint:t=>yb.create({...t,coerce:!0}),date:t=>_b.create({...t,coerce:!0})};var oJ=J;var wO=new _e("LogScope");function EO(t){return{injectLogger:n=>{let e=w(wO,{optional:!0}),r=e!=null?`${e}.${n}`:n;return w(Ba).getLogger(r,{package:t})},getLogger:n=>j(n,{package:t})}}var{injectLogger:YEe,getLogger:SO}=EO("@planx.machina.at/webrtc");var jM=U(Q(),1);var Uh=U(Q(),1),CO=U(Ni(),1);function IO(t){t||(t=w(Kt));let n=new Uh.Observable(e=>{if(t.destroyed){e.next();return}return t.onDestroy(e.next.bind(e))});return e=>e.pipe((0,CO.takeUntil)(n))}function TO(t,n){let e=n?.injector??w(sn),r=new Uh.ReplaySubject(1),i=t_(()=>{let o;try{o=t()}catch(s){La(()=>r.error(s));return}La(()=>r.next(o))},{injector:e,manualCleanup:!0});return e.get(Kt).onDestroy(()=>{i.destroy(),r.complete()}),r.asObservable()}function xO(t,n){let r=!n?.manualCleanup?n?.injector?.get(Kt)??w(Kt):null,i=sJ(n?.equal),o;n?.requireSync?o=an({kind:0},{equal:i}):o=an({kind:1,value:n?.initialValue},{equal:i});let s,a=t.subscribe({next:c=>o.set({kind:1,value:c}),error:c=>{o.set({kind:2,error:c}),s?.()},complete:()=>{s?.()}});if(n?.requireSync&&o().kind===0)throw new Re(601,!1);return s=r?.onDestroy(a.unsubscribe.bind(a)),dt(()=>{let c=o();switch(c.kind){case 1:return c.value;case 2:throw c.error;case 0:throw new Re(601,!1)}},{equal:n?.equal})}function sJ(t=Object.is){return(n,e)=>n.kind===1&&e.kind===1&&t(n.value,e.value)}var Zn=U(Q(),1);var Bi=new _e("WEB_RTC_CONFIG");function DO(t){return{provide:Bi,useFactory:t}}var Oe=(()=>{class t{constructor(){this._diagInstanceId=(()=>{let e=Math.random().toString(36).slice(2,8);return console.warn(`[config:construct] WebRTCConfigService constructed instanceId=${e}`),e})(),this._config=w(Bi),this.config=an(this._config),this.config$=TO(this.config),this.identity$=this.config$.pipe((0,Zn.map)(e=>e.identity),(0,Zn.filter)(e=>!!e?.peerId),(0,Zn.shareReplay)({bufferSize:1,refCount:!1})),this.rolesReady$=this.config$.pipe((0,Zn.map)(e=>({peerId:e.identity?.peerId??"",roles:e.roles??[]})),(0,Zn.filter)(e=>!!e.peerId&&e.roles.length>0),(0,Zn.shareReplay)({bufferSize:1,refCount:!1})),this.connectionTimeoutMs=dt(()=>this.config().connection?.timeoutMs??12e3),this.maxRetryCount=dt(()=>this.config().connection?.maxRetryCount??1),this.retryDelayMs=dt(()=>this.config().connection?.retryDelayMs??1e3),this.autoReconnect=dt(()=>this.config().connection?.autoReconnect??!0),this.reconnectMaxAttempts=dt(()=>this.config().connection?.reconnectMaxAttempts??20),this.reconnectInitialDelayMs=dt(()=>this.config().connection?.reconnectInitialDelayMs??200),this.shortServerId=dt(()=>{let e=this.config().identity?.peerId??"";return e?e.replace(/-/g,"").substring(8,16):""}),this.peerId=dt(()=>this.config().identity?.peerId??""),this.publicKey=dt(()=>this.config().identity?.publicKey??null),this.signalingId=dt(()=>this.config().identity?.signalingId??""),this.peersByPublicKey=dt(()=>{let e=this.config().identity?.peers??{},r={};for(let[i,o]of Object.entries(e))r[o]=i;return r})}resolveSignalingId(e){return this.peersByPublicKey()[e]??null}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var Vh=(()=>{class t{constructor(){this.logger=j("SignalingCryptoService"),this.config=w(Oe),this.signatureAdapter=w(Pi),this.encryptionAdapter=w(Hr)}get privateKey(){let e=this.config.config().identity?.privateKey;if(!e)throw new Error("Identity not configured. Call configure() or initializeKeys() first.");return e}async encryptForPeer(e,r){if(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r)){let o=await this.resolvePublicKey(r);if(!o)throw new Error(`Cannot resolve publicKey for peer: ${r}`);return this.encryptData(e,o)}return this.encryptData(e,r)}async encryptData(e,r){let i=await this.encryptionAdapter.deriveSharedKey(this.privateKey,r),o=await P0(new TextEncoder().encode(JSON.stringify(e)));return this.encryptionAdapter.encryptBytes(o,i)}async decryptData(e,r,i){let o=await this.encryptionAdapter.deriveSharedKey(this.privateKey,i),s=await R0(await this.encryptionAdapter.decryptBytes(e,r,o));return JSON.parse(new TextDecoder().decode(s))}async decryptMessageData(e,r){try{return await this.decryptData(e.encrypted,e.iv,r)}catch(i){return this.logger.warn("[decryptMessageData] Failed:",{error:i?.message}),null}}async createSignature(e){try{return(await this.signatureAdapter.sign(e,this.privateKey)).signature}catch(r){return this.logger.error("[createSignature] Failed:",{name:r?.name,message:r?.message}),""}}async verifySignature(e){if(!e.signature)return this.logger.info("[signaling:verify] no-signature",{type:e.payload.type,from:e.payload.from?.slice(0,16)}),!1;try{let r=await this.resolvePublicKey(e.payload.from);if(!r)return this.logger.info("[signaling:verify] publicKey-MISS",{type:e.payload.type,from:e.payload.from?.slice(0,16),peersCount:Object.keys(this.config.config().identity?.peers??{}).length}),!1;let i=await this.signatureAdapter.verify({payload:e.payload,signature:e.signature},r);return i.valid||this.logger.info("[signaling:verify] signature-INVALID",{type:e.payload.type,from:e.payload.from?.slice(0,16),pubKeyLen:r.length}),i.valid}catch(r){return this.logger.error("[signaling:verify] EXCEPTION:",{name:r?.name,message:r?.message}),!1}}async filterValidSignatures(e){return(await Promise.all(e.map(async i=>({message:i,valid:await this.verifySignature(i)})))).filter(i=>i.valid).map(i=>i.message)}async resolvePublicKey(e){return(this.config.config().identity?.peers??{})[e]??null}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var et=U(Q(),1);var Vt=U(Q(),1),cn=U(Ni(),1);var Wh=(()=>{class t{constructor(){this.channels=w(fs,{optional:!0})??[],this.logger=j("SignalingChannelManager"),console.error("[signaling:channel-manager] constructor channels.length=",this.channels.length,"channels=",JSON.stringify(this.channels.map(e=>({name:e.name,isAvailable:e.isAvailable}))),"pid=",globalThis.process?.pid??"n/a")}get availableChannels(){return this.channels.filter(e=>e.isAvailable)}async create(e){return this.send(e)}async send(e){let r=this.requireChannels("send"),i=r.filter(o=>o.acceptsMessage?.(e)??!0);if(i.length===0)throw new Error(`[send] No channels accept message type ${e.payload.type}`);try{return await this.raceFastest(i,e)}catch(o){let s=r.filter(a=>!i.includes(a)&&(a.acceptsFallback?.(e)??!1));if(s.length===0)throw o;return this.logger.warn("[send] primary channels all failed, trying fallback tier:",s.map(a=>a.name)),this.raceFastest(s,e)}}async raceFastest(e,r){this.logger.info("[send] race-fastest broadcast:",e.map(s=>s.name));let i=[],o=(0,Vt.merge)(...e.map(s=>(0,Vt.from)(s.send(r)).pipe((0,cn.map)(a=>(this.logger.info(`[send] ${s.name}: SUCCESS`,a),a)),(0,cn.catchError)(a=>(this.logger.error(`[send] ${s.name}: FAILED`,a instanceof Error?a.stack??a.message:String(a)),i.push(a),Vt.EMPTY))))).pipe((0,cn.take)(1));try{return await(0,Vt.firstValueFrom)(o)}catch{throw new AggregateError(i,"All signaling channels failed")}}listenEvents(e,r){let o=this.requireChannels("listenEvents").map(s=>s.events(e,r).pipe((0,cn.catchError)(a=>(this.logger.warn(`[listenEvents] ${s.name} errored, isolating:`,a?.message||a),Vt.EMPTY))));return(0,Vt.merge)(...o).pipe((0,cn.share)({resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!1}))}observePresence(e,r){let i=this.availableChannels.filter(s=>typeof s.presence=="function");if(i.length===0)return Vt.EMPTY;let o=i.map(s=>s.presence(e,r).pipe((0,cn.catchError)(a=>(this.logger.warn(`[observePresence] ${s.name} errored, isolating:`,a?.message||a),Vt.EMPTY))));return(0,Vt.merge)(...o).pipe((0,cn.share)({resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!1}))}requireChannels(e){let r=this.availableChannels;if(r.length===0)throw new Error(`[${e}] No signaling channels available`);return r}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var OO=6e4,MO=(()=>{class t{constructor(){this.logger=j("SignalingRateCounter"),this.counts=new Map}start(){this.timer||(this.timer=setInterval(()=>this.emit(),OO))}ngOnDestroy(){this.timer&&(clearInterval(this.timer),this.timer=void 0)}record(e){this.counts.set(e,(this.counts.get(e)??0)+1)}emit(){let e=0,r={};for(let[i,o]of this.counts)r[i]=o,e+=o;this.logger.info("[signaling-rate-metric]",{total:e,perMinute:e,intervalMs:OO,types:r}),this.counts.clear()}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var Z=U(Q(),1);function AO(t){if(!t?.payload)return!1;let{type:n,from:e,to:r,timestamp:i,data:o}=t.payload;if(!n||!e||!r||typeof i!="number")return!1;switch(n){case"announce":return!!o?.roles&&Array.isArray(o.roles);case"offer":case"answer":return In(o)||!!o?.sdp;case"candidates":return In(o)||!!o?.candidate||Array.isArray(o?.candidates)&&o.candidates.length>0;default:return!1}}function Mb(t,n,e){return t==="restricted"?n.includes(e):t==="unrestricted"?!0:n.length===0||n.includes(e)}function NO(t){let n=[],e=r=>{for(;n.length>0&&r-n[0].stashedAt>6e4;)n.shift()};return{stash(r){let i=Date.now();e(i),n.push({record:r,stashedAt:i}),n.length>64&&n.shift(),t?.warn("[pending-admit] stashed non-admitted signaling message (awaiting allowPeers propagation)",{id:r.id,type:r.payload.type,from:r.payload.from?.substring(0,16),pending:n.length})},drainAdmitted(r){e(Date.now());let i=[];for(let o=n.length-1;o>=0;o--)r(n[o].record.payload.from)&&(i.unshift(n[o].record),n.splice(o,1));return i.length>0&&t?.info("[pending-admit] replaying admitted signaling messages after allowPeers update",{count:i.length,ids:i.map(o=>o.id)}),i}}}function RO(t){let{channelManager:n,config:e,cryptoService:r,processedMessageIds:i,refresh$:o,destroy$:s,getMySignalingIds:a,filterSelfMessage:c,logger:u,onAdmitDrop:l}=t,d=NO(u);return(0,Z.combineLatest)([(0,Z.concat)((0,Z.defer)(()=>(0,Z.of)({subscriptionStartTime:new Date(Date.now()-5e3)})),(0,Z.merge)((0,Z.interval)(6e4),o).pipe((0,Z.map)(()=>({subscriptionStartTime:new Date(Date.now()-5e3)})))),e.config$.pipe((0,Z.map)(f=>({signalingId:f.identity?.signalingId,peerKeys:Object.keys(f.identity?.peers??{}).sort().join("|")})),(0,Z.filter)(f=>!!f.signalingId),(0,Z.distinctUntilChanged)((f,p)=>f.signalingId===p.signalingId&&f.peerKeys===p.peerKeys))]).pipe((0,Z.switchMap)(([{subscriptionStartTime:f}])=>(0,Z.from)(a()).pipe((0,Z.switchMap)(p=>{if(p.length===0)return Z.EMPTY;let m=Object.keys(e.config().identity?.peers??{}),y=e.config().allowPeersMode,b=d.drainAdmitted(E=>Mb(y,m,E));return(0,Z.concat)((0,Z.from)(b),n.listenEvents(p,{subscriptionStartTime:f,allowedFromPeers:m})).pipe((0,Z.filter)(E=>Mb(y,m,E.payload.from)?!0:(u.warn("[signaling:admit] DROP unadmitted sender",{from:E.payload.from?.slice(0,16),type:E.payload.type,mode:y,allowCount:m.length}),d.stash(E),l?.(E.payload.from),!1)),(0,Z.map)(E=>[E]))}))),(0,Z.tap)(f=>{f.length>0&&u.info("[signaling:msg:before-crypto]",{count:f.length,types:f.map(p=>p.payload.type),froms:f.map(p=>p.payload.from?.slice(0,16))})}),(0,Z.concatMap)(f=>(0,Z.from)(r.filterValidSignatures(f))),(0,Z.tap)(f=>{f.length>0&&u.info("[signaling:msg:after-crypto]",{count:f.length,types:f.map(p=>p.payload.type)})}),(0,Z.map)(f=>f.filter(p=>i.has(p.id)?!1:(i.set(p.id,Date.now()),!0))),(0,Z.tap)(f=>{f.length>0&&u.info("[signaling:msg:after-dedup]",{count:f.length,types:f.map(p=>p.payload.type),froms:f.map(p=>p.payload.from?.slice(0,16))})}),(0,Z.mergeMap)(f=>(0,Z.from)(f)),(0,Z.filter)(f=>AO(f)),(0,Z.concatMap)(f=>(0,Z.from)(c(f))),(0,Z.filter)(f=>f!==null),(0,Z.tap)(f=>u.info("[message$] Emitting:",{type:f.payload.type})),(0,Z.retry)({delay:(f,p)=>{let m=Math.min(1e3*Math.pow(2,p-1),3e4);return u.warn("[message$] Retrying after upstream error:",{message:f?.message||String(f),retryCount:p,delayMs:m}),(0,Z.timer)(m)}}),(0,Z.takeUntil)(s),(0,Z.shareReplay)({bufferSize:1,refCount:!0}))}var Gh=(()=>{class t{constructor(){this.logger=j("SignalingMessageHandler"),this.config=w(Oe),this.channelManager=w(Wh),this.cryptoService=w(Vh),this.rateCounter=w(MO),this.processedMessageIds=new Map,this.destroy$=new et.Subject,this.refresh$=new et.Subject,this._unadmittedSender$=new et.BehaviorSubject(null),this.unadmittedSender$=this._unadmittedSender$.asObservable(),this.message$=RO({channelManager:this.channelManager,config:this.config,cryptoService:this.cryptoService,processedMessageIds:this.processedMessageIds,refresh$:this.refresh$,destroy$:this.destroy$,getMySignalingIds:()=>this.getMySignalingId_asList(),filterSelfMessage:e=>this.filterSelfMessage(e),logger:this.logger,onAdmitDrop:e=>this._unadmittedSender$.next({from:e,at:Date.now()})}),this.presence$=this.config.config$.pipe((0,et.map)(e=>({signalingId:e.identity?.signalingId??"",peerKeys:Object.keys(e.identity?.peers??{}).sort(),metaKeys:Object.keys(e.identity?.peersMeta??{}).sort()})),(0,et.distinctUntilChanged)((e,r)=>e.signalingId===r.signalingId&&e.peerKeys.join("|")===r.peerKeys.join("|")&&e.metaKeys.join("|")===r.metaKeys.join("|")),(0,et.switchMap)(({signalingId:e,peerKeys:r})=>e===""?et.EMPTY:this.channelManager.observePresence([e],{allowedFromPeers:r})),(0,et.takeUntil)(this.destroy$)),(0,et.interval)(6e4).pipe((0,et.takeUntil)(this.destroy$)).subscribe(()=>this.cleanup()),this.rateCounter.start(),this.message$.pipe((0,et.takeUntil)(this.destroy$)).subscribe(e=>this.rateCounter.record(e.payload.type))}async getMySignalingId(){return this.config.signalingId()??""}async getMySignalingId_asList(){let e=this.config.signalingId();return e?[e]:[]}isHashedId(e){return/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(e)}async getTargetSignalingId(e){if(this.isHashedId(e))return e;let r=this.config.resolveSignalingId(e);if(r)return r;let i=this.config.config()?.identity?.peers??{};throw console.warn(`[signaling:resolve-fail] resolve failed instanceId=${this.config._diagInstanceId} targetPrefix=${e.substring(0,20)} identityPeersCount=${Object.keys(i).length} identityPeersHasTarget=${Object.values(i).includes(e)} identityPeersKeys=${Object.keys(i).join(",")}`),new Error(`[getTargetSignalingId] Cannot resolve publicKey to signalingId: ${e.substring(0,20)}...`)}async filterSelfMessage(e){let r=await this.getMySignalingId();return r&&r===e.payload.from?null:e}cleanup(){if(this.processedMessageIds.size<=5e4)return;let e=[...this.processedMessageIds.entries()].sort((i,o)=>i[1]-o[1]),r=this.processedMessageIds.size-5e4;for(let i=0;i<r;i++)this.processedMessageIds.delete(e[i][0])}refresh(){this.logger.info("[refresh] Forcing subscription refresh"),this.refresh$.next()}ngOnDestroy(){this.processedMessageIds.clear(),this.destroy$.next(),this.destroy$.complete(),this.refresh$.complete()}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var zh=(()=>{class t{constructor(){this.logger=j("SignalingService"),this.config=w(Oe),this.messageSender=w(qa),this.cryptoService=w(Vh),this.messageHandler=w(Gh),this.message$=this.messageHandler.message$}async send(e){let r=await this.messageHandler.getMySignalingId(),i=e.payload.to==="all"?"all":await this.messageHandler.getTargetSignalingId(e.payload.to),o={...e.payload,from:r,to:i},s=await this.cryptoService.createSignature(o);return this.messageSender.create({payload:o,signature:s})}async sendAnnounce(e){let r=await this.messageHandler.getMySignalingId();this.logger.info("[sendAnnounce]",{roles:e.join(","),pid:typeof process<"u"?process.pid:"n/a"});let i={type:"announce",from:r,to:"all",timestamp:Date.now(),data:{roles:e}};return this.messageSender.create({payload:i,signature:""})}async sendOffer(e,r,i){let[o,s]=await Promise.all([this.messageHandler.getMySignalingId(),this.messageHandler.getTargetSignalingId(e)]),c={...await this.cryptoService.encryptForPeer(r,e),token:i},u={type:"offer",from:o,to:s,timestamp:Date.now(),data:c},l=await this.cryptoService.createSignature(u);return this.messageSender.create({payload:u,signature:l})}async sendAnswer(e,r){let[i,o]=await Promise.all([this.messageHandler.getMySignalingId(),this.messageHandler.getTargetSignalingId(e)]),s=await this.cryptoService.encryptForPeer(r,e),a={type:"answer",from:i,to:o,timestamp:Date.now(),data:s},c=await this.cryptoService.createSignature(a);return this.messageSender.create({payload:a,signature:c})}async sendCandidates(e,r){let[i,o]=await Promise.all([this.messageHandler.getMySignalingId(),this.messageHandler.getTargetSignalingId(e)]),s=await this.cryptoService.encryptForPeer({candidates:r},e),a={type:"candidates",from:i,to:o,timestamp:Date.now(),data:s},c=await this.cryptoService.createSignature(a);return this.messageSender.create({payload:a,signature:c})}async sendCandidate(e,r){return this.sendCandidates(e,[r])}async decryptMessageData(e,r){return this.cryptoService.decryptMessageData(e,r)}async getSenderPublicKey(e){return this.cryptoService.resolvePublicKey(e)}ngOnDestroy(){this.messageHandler.ngOnDestroy()}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var Yh=U(Q(),1),ot=U(Ni(),1);function LO(t,n,e){let r=new Map(t),i=[];for(let[o,s]of t.entries())!s.lastSeen||n-s.lastSeen<=6e4||e?.(o)||(i.push(s),r.delete(o));return{updated:r,removed:i}}function jO(t,n,e,r){let i=t.get(n.peerId),o=!!i&&e!==void 0&&i.generation!==void 0&&e!==i.generation,s=!!i?.lastSeen&&r-i.lastSeen>6e4,a=o||s,c={id:n.peerId,publicKey:n.publicKey,name:n.meta.name,roles:n.meta.roles,lastSeen:r,generation:e},u=new Map(t);if(u.set(n.peerId,c),!i)return{kind:"added",peers:u,peer:c};let l=a?o?`generation changed (${i.generation} \u2192 ${e})`:`gap=${r-(i.lastSeen??0)}ms > ${6e4}ms`:void 0;return{kind:"updated",peers:u,peer:c,restartDetected:a,reason:l}}var Ab={peers:new Map,events:[]},As=(()=>{class t{constructor(){this.logger=j("PeerListService"),this.config=w(Oe),this.destroyRef=w(Kt),this.messageHandler=w(Gh),this.commandSubject=new Yh.Subject,this.announceFromPresence$=this.messageHandler.presence$.pipe((0,ot.map)(e=>{if(L0(e))return{kind:"presence-lost",peerId:e.fromKey,at:e.observedAt};let r=this.config.config().identity,i=r?.peers?.[e.fromKey],o=r?.peersMeta?.[e.fromKey];return!i||!o?null:{kind:"presence",input:{peerId:e.fromKey,publicKey:i,meta:o},generation:e.generation,at:e.observedAt}}),(0,ot.tap)(e=>{e===null&&this.logger.debug("[presence] identity.peers/peersMeta not populated, dropping (presence$ will redeliver once identity is updated)")}),(0,ot.filter)(e=>e!==null)),this.state$=(0,Yh.merge)(this.announceFromPresence$,this.commandSubject).pipe((0,ot.scan)((e,r)=>{if(r.kind==="clear")return{peers:new Map,events:[]};if(r.kind==="presence-lost"){let o=e.peers.get(r.peerId);if(!o)return{peers:e.peers,events:[]};let s=new Map(e.peers);return s.delete(r.peerId),{peers:s,events:[{type:"removed",peer:o}]}}if(r.kind==="remove-expired"){let{updated:o,removed:s}=LO(e.peers,r.at,r.isActive);return s.length>0?{peers:o,events:s.map(a=>({type:"removed",peer:a}))}:{peers:e.peers,events:[]}}let i=jO(e.peers,r.input,r.generation,r.at);return i.kind==="added"?{peers:i.peers,events:[{type:"added",peer:i.peer}]}:{peers:i.peers,events:[{type:"updated",peer:i.peer,restartDetected:i.restartDetected}]}},Ab),(0,ot.tap)(({peers:e,events:r})=>{for(let i of r)i.type==="added"?this.logger.info(`[peerEvents] New peer added: ${i.peer.id} roles=${i.peer.roles} name=${i.peer.name} | total peers: ${e.size}`):i.type==="updated"?i.restartDetected?this.logger.info(`[peerEvents] Restart detected for peer ${i.peer.id}`):this.logger.debug("[peerEvents] Peer updated:",i.peer.id):this.logger.info(`[peerEvents] Removed expired peer: ${i.peer.id} | ${e.size} peers remaining`)}),(0,ot.startWith)(Ab),(0,ot.share)()),this.peers$=this.state$.pipe((0,ot.map)(e=>e.peers),(0,ot.distinctUntilChanged)(),(0,ot.shareReplay)({bufferSize:1,refCount:!1})),this.peersSignal=xO(this.peers$,{initialValue:Ab.peers}),this.state$.pipe(IO(this.destroyRef)).subscribe()}removeExpiredPeers(e){this.commandSubject.next({kind:"remove-expired",at:Date.now(),isActive:e})}getServerPeers(){return Array.from(this.peersSignal().values()).filter(e=>e.roles.includes("server"))}getClientPeers(){return Array.from(this.peersSignal().values()).filter(e=>e.roles.includes("client"))}getPeer(e){return this.peersSignal().get(e)}getPeerByPublicKey(e){for(let r of this.peersSignal().values())if(r.publicKey===e)return r}getPeerByName(e){for(let r of this.peersSignal().values())if(r.name===e)return r}clear(){this.commandSubject.next({kind:"clear"})}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var zr=U(Q(),1);var lJ=new Map;function dJ(t,n){let e=[];for(let[r,i]of n){let o=t.get(r);if(!o){e.push({type:"added",peer:i});continue}if(o===i)continue;let s=o.generation!==void 0&&i.generation!==void 0&&o.generation!==i.generation,a=!!o.lastSeen&&!!i.lastSeen&&i.lastSeen-o.lastSeen>6e4;e.push({type:"updated",peer:i,restartDetected:s||a})}for(let[r,i]of t)n.has(r)||e.push({type:"removed",peer:i});return e}function FO(t){return t.pipe((0,zr.startWith)(lJ),(0,zr.pairwise)(),(0,zr.mergeMap)(([n,e])=>(0,zr.from)(dJ(n,e))))}var Ns={"reliable-ordered":{ordered:!0},"reliable-unordered":{ordered:!1},unreliable:{ordered:!1,maxRetransmits:0},"unreliable-ordered":{ordered:!0,maxRetransmits:0},heartbeat:{ordered:!0,negotiated:!0,id:1023,priority:"high"},"reliable-ordered-pr":{ordered:!0,maxRetransmits:3}};var fJ=/^[0-9a-f]{40}$/i,Zh=class{constructor(n,e){this.registry=n,this.registrar=e,this.logger=j("DataChannelLifecycleService"),this.peerSubscriptions=new Map,this.attachedSources=new Map}attachPeer(n,e){let r=this.attachedSources.get(n);if(r===e)return;this.peerSubscriptions.get(n)?.unsubscribe(),r&&(this.logger.info("[attachPeer] Cleaning up old generation channels:",{peerId:n}),this.registrar.cleanupPeer(n)),this.attachedSources.set(n,e),this.registrar.ensurePeerMap(n);let i=this.registry.attach(n,e,(o,s)=>this.registrar.register(o,s,"remote"),o=>fJ.test(o));i.add(e.lifecycle$.subscribe(o=>{o==="closed"&&(this.logger.warn("[lifecycle] Cleaning up channels (closed):",{peerId:n}),this.cleanupPeer(n))})),this.peerSubscriptions.set(n,i)}cleanupPeer(n){this.logger.debug("[cleanupPeer] called:",{peerId:n.substring(0,20)}),this.peerSubscriptions.get(n)?.unsubscribe(),this.peerSubscriptions.delete(n),this.attachedSources.delete(n),this.registrar.cleanupPeer(n),this.registry.delete(n),this.logger.debug("[cleanupPeer] Cleaned up:",n)}};var Rb=U(Q(),1);var ac=U(Q(),1);var hJ=j("DataChannelRegistrar");function $O(t,n,e,r,i=5e3){return new Promise((o,s)=>{let a=null,c=null,u=()=>{c&&clearTimeout(c),a&&a.unsubscribe()};c=setTimeout(()=>{u(),s(new Error(`Channel open timeout: ${e}/${r}`))},i);let l=t.get(e)?.get(r);if(l?.readyState==="open"){u(),o();return}if(l){let d=()=>{u(),l.removeEventListener("open",d),o()};l.addEventListener("open",d);return}hJ.debug("[waitForOpen] Channel not yet registered, waiting for channelOpened$:",{peerId:e,label:r}),a=n.subscribe(d=>{d.peerId===e&&d.label===r&&(u(),o())})})}var Qh=class{constructor(){this.logger=j("DataChannelRegistrar"),this.channels=new Map,this.channelOpened$=new ac.ReplaySubject(32),this.channelClosed$=new ac.Subject,this.channelMessage$=new ac.Subject}getChannel(n,e){return this.channels.get(n)?.get(e)}hasChannel(n,e){return this.channels.get(n)?.get(e)?.readyState==="open"}ensurePeerMap(n){this.channels.has(n)||this.channels.set(n,new Map)}register(n,e,r){let i=e.label;this.ensurePeerMap(n);let o=this.channels.get(n).get(i),s=o?.readyState==="open";if(o&&o!==e){this.logger.info("[register] Replacing existing channel:",{peerId:n.substring(0,20),label:i}),o.onmessage=null,o.onclose=null,o.onerror=null,o.onopen=null;try{o.close()}catch{}}this.channels.get(n).set(i,e),e.readyState==="open"?s?this.logger.debug("[channel] Replaced (no re-emit):",{peerId:n,label:i}):(this.logger.debug("[channel] Already open:",{peerId:n,label:i}),this.channelOpened$.next({peerId:n,label:i,origin:r})):e.onopen=()=>{this.logger.debug("[channel] Opened:",{peerId:n,label:i}),this.channelOpened$.next({peerId:n,label:i,origin:r})},e.onclose=a=>{let c=this.channels.get(n)?.get(i)===e,u=e.readyState;this.logger.info("[channel] Closed:",{peerId:n.substring(0,20),label:i,readyState:u,isCurrent:c,closeEvent:a?.type}),c&&(this.channels.get(n)?.delete(i),this.channelClosed$.next({peerId:n,label:i,readyState:u,reason:"natural"}))},e.onerror=a=>{let c=a?.error;this.logger.error("[channel] Error:",{peerId:n.substring(0,20),label:i,readyState:e.readyState,errorDetail:c?.errorDetail,message:c?.message??a?.message})},e.onmessage=a=>{this.channelMessage$.next({peerId:n,label:i,data:a.data})}}evictStale(n,e){let r=this.channels.get(n);r?.has(e)&&(r.delete(e),this.logger.warn("[evictStale] Removed stale channel:",{peerId:n,label:e}),this.channelClosed$.next({peerId:n,label:e,reason:"evict"}))}cleanupPeer(n){let e=this.channels.get(n);if(e){let r=Array.from(e.keys()),i=new Error().stack?.split(`
18
- `)[2]?.trim()??"unknown";this.logger.info("[cleanupPeer] Closing channels:",{peerId:n.substring(0,20),labels:r,caller:i});for(let[o,s]of e){let a=s.readyState;s.close(),this.channelClosed$.next({peerId:n,label:o,readyState:a,reason:"cleanup"})}this.channels.delete(n)}}waitForOpen(n,e,r=5e3){return $O(this.channels,this.channelOpened$,n,e,r)}};function pJ(t){return typeof t=="string"?t.length:t.byteLength}var Nb=class{constructor(){this.lastAt=new Map}shouldWarn(n,e,r=Date.now()){let i=this.lastAt.get(n);return i!==void 0&&r-i<e?!1:(this.lastAt.set(n,r),!0)}reset(){this.lastAt.clear()}},qO=(()=>{class t{static{this.WARN_THROTTLE_MS=1e3}constructor(e,r){this.registrar=e,this.channelSent$=r,this.logger=j("DataChannelTransport"),this.warnThrottle=new Nb}send(e,r,i){let o=this.registrar.getChannel(e,r);return o?.readyState==="open"?(o.send(i),this.channelSent$.next({peerId:e,label:r,bytes:pJ(i)}),!0):(this.warnThrottled(e,r,o?.readyState),!1)}warnThrottled(e,r,i){let o=`${e}\0${r}`;this.warnThrottle.shouldWarn(o,t.WARN_THROTTLE_MS)&&this.logger.warn("[send] Channel not ready (throttled):",{peerId:e,label:r,state:i})}}return t})();var Hi=U(Q(),1);var BO=U(Q(),1);function Pb(t){let n=typeof performance<"u"?performance.now():Date.now();return{conn:t.connectionState,ice:t.iceConnectionState??"new",signaling:t.signalingState,iceGathering:t.iceGatheringState??"new",sctp:t.sctp?.state??"none",dtls:t.sctp?.transport?.state??"none",at:n}}function HO(t){return new BO.Observable(n=>{let e=()=>n.next(Pb(t));return t.addEventListener("connectionstatechange",e),t.addEventListener("iceconnectionstatechange",e),()=>{t.removeEventListener("connectionstatechange",e),t.removeEventListener("iceconnectionstatechange",e)}})}var mJ=new Set(["closed","failed"]);function UO(t){return t.sctp==="closed"&&mJ.has(t.dtls)}var gJ=j("PeerConnectionRegistry");async function VO(t,n,e){try{let r=await n.getStats(),i,o=new Map,s=new Map;r.forEach(a=>{a.type==="transport"&&a.selectedCandidatePairId&&(i=a.selectedCandidatePairId),a.type==="local-candidate"&&o.set(a.id,a),a.type==="remote-candidate"&&s.set(a.id,a)}),r.forEach(a=>{if(a.type==="candidate-pair"&&a.nominated&&a.state==="succeeded"&&!i||a.type==="candidate-pair"&&a.id===i){let c=o.get(a.localCandidateId),u=s.get(a.remoteCandidateId);c&&u&&e.set(t,{local:c.candidateType??"unknown",remote:u.candidateType??"unknown",protocol:c.protocol??"unknown"})}})}catch(r){gJ.debug("[updateCandidatePair] failed",r)}}var yJ=1e3,WO=(()=>{class t{constructor(){this.logger=j("PeerConnectionRegistry"),this.sources=new Map,this.registered$=new Hi.Subject,this.lastStates=new Map,this.lastConnectedAt=new Map,this.candidatePairs=new Map,this.connectionStateChanged$=new Hi.Subject,this.iceStateChanged$=new Hi.Subject,this.unhealthy$=new Hi.Subject}getLastState(e){return this.lastStates.get(e)}getSource(e){return this.sources.get(e)}has(e){return this.sources.has(e)}attach(e,r,i,o){this.logger.debug("[attach] called:",{peerId:e.substring(0,20)}),this.sources.set(e,r);let s=new Hi.Subscription,a={};s.add(r.diagnostics$.subscribe(u=>this.onDiagnostics(e,r,u,a))),s.add(r.incomingChannels$.subscribe(u=>{o(u.label)||i(e,u)}));let c=setInterval(()=>{this.onDiagnostics(e,r,r.captureDiagnosticsSnapshot(),a)},yJ);return s.add(()=>clearInterval(c)),this.registered$.next(e),s}onDiagnostics(e,r,i,o){let s=o.conn,a=o.ice;o.conn=i.conn,o.ice=i.ice;let c=this.lastConnectedAt.get(e),u=c!==void 0?Math.round(i.at-c):void 0;i.conn==="connected"&&this.lastConnectedAt.set(e,i.at);let l={...i,idleMs:u,selectedPair:this.candidatePairs.get(e)};this.lastStates.set(e,l),i.conn!==s&&(this.logger.info("[connectionStateChange]",{peerId:e.substring(0,20),...l}),this.connectionStateChanged$.next({peerId:e,state:i.conn}),i.conn==="connected"&&VO(e,r,this.candidatePairs)),i.ice!==a&&(this.logger.info("[iceConnectionStateChange]",{peerId:e.substring(0,20),...l}),this.iceStateChanged$.next({peerId:e,state:i.ice})),UO(i)&&this.unhealthy$.next({peerId:e})}waitFor(e,r=5e3){let i=this.sources.get(e);return i?Promise.resolve(i):new Promise((o,s)=>{let a=null,c=this.registered$.subscribe(u=>{u===e&&(a&&clearTimeout(a),c.unsubscribe(),o(this.sources.get(e)))});a=setTimeout(()=>{c.unsubscribe(),s(new Error(`waitForPeerConnection timeout: ${e}`))},r)})}delete(e){this.sources.delete(e)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();async function GO(t,n,e,r){let i={label:e,readyState:"open",send:o=>{let s;typeof o=="string"||o instanceof ArrayBuffer?s=o:o.byteOffset===0&&o.byteLength===o.buffer.byteLength?s=o.buffer:s=o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength),t.channelMessage$.next({peerId:n,label:e,data:s})},close:()=>{},onopen:null,onmessage:null,onclose:null,onerror:null,bufferedAmount:0};t.register(n,i)}var Ps=j("DataChannelManagerService"),vJ=new Set(["disconnected","failed","closed"]);function Jh(t,n,e,r,i,o="reliable-ordered"){Ps.debug("[createChannel] called:",{peerId:r.substring(0,20),label:i});let s=t.getSource(r);if(!s)return Ps.warn("[createChannel] PeerConnection not found:",r),null;if(vJ.has(s.connectionState))return Ps.warn("[createChannel] PeerConnection unhealthy:",{peerId:r,state:s.connectionState}),e.next({peerId:r,reason:"pre-check"}),null;let a=n.getChannel(r,i);if(a&&a.readyState!=="closed")return Ps.debug("[createChannel] Reusing existing channel:",{peerId:r,label:i}),a;let c;try{c=s.createDataChannel(i,Ns[o])}catch(u){throw Ps.warn("[createChannel] createDataChannel threw, marking unhealthy",{peerId:r,label:i,error:u}),e.next({peerId:r,reason:"create-failed"}),u}return n.register(r,c,"local"),Ps.info("[createChannel] Created:",{peerId:r,label:i,profile:o}),c}var _J=j("DataChannelManagerService");async function zO(t,n,e,r,i,o,s){let a=Jh(t,n,e,r,i,o);if(!a)throw new Error(`createChannelAsync failed: ${r}/${i}`);if(a.readyState!=="open")try{await n.waitForOpen(r,i,s)}catch(c){_J.warn("[createChannelAsync] channel stuck at open (timeout), cleaning up for caller escalation",{peerId:r.substring(0,16),label:i,err:c?.message});try{a.close()}catch{}throw n.evictStale(r,i),c}return a}var Dt=(()=>{class t{constructor(){this.logger=j("DataChannelManagerService"),this.registry=w(WO),this.registrar=new Qh,this.lifecycle=new Zh(this.registry,this.registrar),this.channelSent$=new Rb.Subject,this.unhealthy$=new Rb.Subject,this.transport=new qO(this.registrar,this.channelSent$),this.channelOpened$=this.registrar.channelOpened$,this.channelClosed$=this.registrar.channelClosed$,this.channelMessage$=this.registrar.channelMessage$,this.connectionStateChanged$=this.registry.connectionStateChanged$,this.iceStateChanged$=this.registry.iceStateChanged$,this.peerUnhealthy$=this.registry.unhealthy$}getLastPeerState(e){return this.registry.getLastState(e)}attachPeer(e,r){this.lifecycle.attachPeer(e,r)}async registerInProcessChannel(e,r,i){await GO(this.registrar,e,r,i)}sendInProcess(e,r,i,o){let s=this.registrar.getChannel(e,r);return s?.readyState==="open"?o!=null?(this.registrar.channelMessage$.next({peerId:e,label:r,data:i,senderClientId:o}),"sent"):(s.send(i),"sent"):"not_open"}cleanupPeer(e){this.lifecycle.cleanupPeer(e)}waitForPeerConnection(e,r=5e3){return this.registry.waitFor(e,r)}async createChannelAsync(e,r,i="reliable-ordered",o=5e3){return await this.waitForPeerConnection(e,o),zO(this.registry,this.registrar,this.unhealthy$,e,r,i,o)}createChannel(e,r,i="reliable-ordered"){return Jh(this.registry,this.registrar,this.unhealthy$,e,r,i)}closeChannel(e,r){let i=this.registrar.getChannel(e,r);if(i){let o=i.readyState;i.close(),this.registrar.channels.get(e)?.delete(r),this.channelClosed$.next({peerId:e,label:r,readyState:o,reason:"explicit"})}}send(e,r,i){return this.transport.send(e,r,i)}getBufferedAmount(e,r){return this.registrar.getChannel(e,r)?.bufferedAmount??0}hasChannel(e,r){return this.registrar.hasChannel(e,r)}getChannel(e,r){return this.registrar.getChannel(e,r)}getPeerChannels(e){return this.registrar.channels.get(e)}waitForOpen(e,r,i=5e3){return this.registrar.waitForOpen(e,r,i)}registerChannel(e,r){this.registrar.register(e,r)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();function Xh(t){return t?.type==="renegotiate-offer"}function ep(t){return t?.type==="renegotiate-answer"}var bJ=j("PeerStateMachine"),wJ={IDLE:["CONNECTING","CLOSED"],CONNECTING:["CONNECTED","FAILED","CLOSED"],CONNECTED:["FAILED","CLOSED"],FAILED:["RECONNECTING","CLOSED","CONNECTING"],RECONNECTING:["CONNECTING","CONNECTED","FAILED","CLOSED"],CLOSED:[]};function EJ(t,n){return t===n?!0:wJ[t]?.includes(n)??!1}function KO(t,n,e){if(EJ(t,n))return n;let r=e?e.substring(0,8):"?";return bJ.warn("[PeerStateMachine] invalid transition",{peerId:r,from:t,to:n}),null}function YO(t="CONNECTING"){return t}var tp=class{constructor(){this.entries=new Map}getOrCreate(n,e){let r=this.entries.get(n);if(r)return r;let i={initiator:e,reconnecting:!1,connecting:!1,lifecycle:"IDLE"};return this.entries.set(n,i),i}get(n){return this.entries.get(n)}delete(n){this.entries.delete(n)}isReconnecting(n){return this.entries.get(n)?.reconnecting??!1}markReconnecting(n,e){let r=this.entries.get(n);r&&(r.reconnecting=e)}isConnecting(n){return this.entries.get(n)?.connecting??!1}getInitiator(n){return this.entries.get(n)?.initiator}getLifecycle(n){return this.entries.get(n)?.lifecycle}transition(n,e){let r=this.entries.get(n);if(!r)return!1;let i=KO(r.lifecycle,e,n);return i===null?!1:(r.lifecycle=i,this.syncFlags(r),!0)}syncFlags(n){n.reconnecting=n.lifecycle==="RECONNECTING",n.lifecycle==="CONNECTING"?n.connecting=!0:(n.lifecycle==="CONNECTED"||n.lifecycle==="CLOSED"||n.lifecycle==="FAILED"||n.lifecycle==="IDLE")&&(n.connecting=!1)}resetOnExplicitConnect(n,e){let r=this.getOrCreate(n,e);r.initiator=e,r.reconnecting=!1,r.connecting=!1,r.lifecycle=YO("IDLE")}};var Kr=(()=>{class t{constructor(){this.state=new tp}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();function cc(){if(globalThis.__WEBRTC_VERBOSE_DIAG===!0)return!0;try{if(typeof localStorage<"u"&&localStorage.getItem("webrtc-verbose-diag")==="1")return!0}catch{}return!1}function ZO(t,n){!cc()||!t||t.subscribe(e=>{console.log(`[pc-diag] snapshot peer=${n} conn=${e.conn} ice=${e.ice} signaling=${e.signaling} gather=${e.iceGathering} sctp=${e.sctp} dtls=${e.dtls}`)})}function QO(t,n){if(!cc()||n.type!=="offer"&&n.type!=="answer")return;let e=n.sdp||"",r=e.match(/a=fingerprint:\s*(\S+)\s+(\S+)/i),i=e.match(/a=setup:(\S+)/i);console.log(`[peer-event-SDP] local ${n.type} peer=${t} fp=${r?.[1]??"MISS"}:${r?.[2]?.substring(0,40)??"MISS"} setup=${i?.[1]??"MISS"} len=${e.length}`)}function JO(t,n){cc()&&n.candidate&&console.log(`[peer-event-ICE] local candidate peer=${t} candidate=${JSON.stringify(n).substring(0,120)}`)}function XO(t,n,e){if(!cc())return;let r=e;console.log(`[peer-event-SIGNAL] peer=${t} connected=${n.connected} type=${r?.type??"ice"} hasCandidate=${!!r?.candidate}`)}function eM(t,n){cc()&&console.log(`[peer-event-CONNECT] peer=${t} conn=${n?.conn} ice=${n?.ice} signaling=${n?.signaling} gathering=${n?.iceGathering} sctp=${n?.sctp??"N/A"}`)}function tM(t,n){let e=t?.code??"UNKNOWN",r=t?.message||t,i=typeof navigator<"u"?navigator.onLine:"n/a",o=typeof document<"u"?document.visibilityState:"n/a",s=n?.selectedPair?`pair=${n.selectedPair.local}/${n.selectedPair.remote}/${n.selectedPair.protocol}`:"pair=none",a=n?.idleMs!==void 0?`idle=${n.idleMs}ms`:"idle=n/a",c=n?`ice=${n.ice} conn=${n.conn} dtls=${n.dtls} sctp=${n.sctp} signal=${n.signaling}`:"state=unknown";return`${r} [code=${e} ${c} ${s} ${a} online=${i} vis=${o}]`}var nM=(()=>{class t{constructor(){this.logger=j("PeerEventHandler"),this.channelManager=w(Dt),this.reconnectService=w(Kr)}setupPeerEvents(e,r,i,o,s,a){let c=r.substring(0,8);e.channels&&this.channelManager.attachPeer(r,e.channels),ZO(e.reactive?.diagnostics$,c),this.attachSignalListener(e,r,c,i,o),this.attachConnectListener(e,r,c,i),this.attachErrorListener(e,r,c,i,s),this.attachCloseListener(e,r,c,i,s),this.attachDataListener(e,r,c,i,s,a)}attachSignalListener(e,r,i,o,s){e.on("signal",a=>{if(XO(i,e,a),e.connected){s(r,{type:"peer-signal",signal:a});return}QO(i,a),JO(i,a),a.type==="offer"?o.next({type:"[session.transport.webrtc.peer] offer",peerId:r,data:a}):a.type==="answer"?o.next({type:"[session.transport.webrtc.peer] answer",peerId:r,data:a}):o.next({type:"[session.transport.webrtc.peer] ice-candidate",to:r,data:a})})}attachConnectListener(e,r,i,o){e.on("connect",()=>{this.logger.info("[peer-event] connect",{peerId:i,connectionState:e.connectionState}),eM(i,this.channelManager.getLastPeerState(r)),e.channels?this.channelManager.attachPeer(r,e.channels):this.logger.warn("[peer-event] connect: peer.channels capability missing",{peerId:r.substring(0,20)}),this.reconnectService.state.transition(r,"CONNECTED"),o.next({type:"[session.transport.webrtc.peer] connected",peerId:r})})}attachErrorListener(e,r,i,o,s){e.on("error",a=>{if(!(s(r)===e)){this.logger.debug("[peer-event] error (stale, ignored)",{peerId:i});return}let u=this.channelManager.getLastPeerState(r),l=tM(a,u);this.logger.error("[peer-event] error",{peerId:i,message:l,connected:e.connected});let d=new Error(l);d.name=a?.name??"Error",this.reconnectService.state.transition(r,"FAILED"),o.next({type:"[session.transport.webrtc.peer] error",peerId:r,error:d})})}attachCloseListener(e,r,i,o,s){e.on("close",()=>{let a=s(r)===e;this.logger.info("[peer-event] close",{peerId:i,isCurrentPeer:a}),a?(this.reconnectService.state.transition(r,"CLOSED"),o.next({type:"[session.transport.webrtc.peer] close",peerId:r})):this.logger.debug("[peer-event] close (stale, ignored)",{peerId:i})})}attachDataListener(e,r,i,o,s,a){e.on("data",c=>{let u=JSON.parse(c.toString());if(this.logger.debug("[setupPeerEvents] Received data:",i,"type:",u?.type),u?.type==="peer-signal"){let l=s(r);l&&l.signal(u.signal);return}if(Xh(u)||ep(u)){a(r,u).catch(l=>{this.logger.error("[setupPeerEvents] Renegotiation failed:",i,l?.message||l)});return}o.next({type:"[session.transport.webrtc.peer] data",peerId:r,data:u})})}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var rM=(()=>{class t{constructor(){this.logger=j("PeerRenegotiationHandler"),this.channelManager=w(Dt),this.pendingRenegotiations=new Map}async createDynamicChannel(e,r,i,o){let s=o(e)?.channels;if(!s)throw new Error(`No peer connection: ${e}`);let a=s.createDataChannel(r,Ns[i]);return await this.waitForChannelOpen(a),this.channelManager.registerChannel(e,a),a}async handleRenegotiateSignal(e,r,i,o){let s=i(e)?.reactive;if(s)if(r.type==="[session.transport.webrtc.peer] renegotiate-offer"){let a=await s.applySignal({offer:r.sdp});if(!a)return;o.next({type:"[session.transport.webrtc.peer] renegotiate-answer",peerId:e,label:r.label,sdp:a.answer})}else await s.applySignal({answer:r.sdp}),this.resolvePending(e,r.label)}async handleRenegotiationMessage(e,r,i,o){let s=i(e)?.reactive;if(s)if(Xh(r)){let a=await s.applySignal({offer:r.sdp});if(!a)return;o(e,{type:"renegotiate-answer",sdp:a.answer,label:r.label})}else ep(r)&&(await s.applySignal({answer:r.sdp}),this.resolvePending(e,r.label))}resolvePending(e,r){let i=this.pendingRenegotiations.get(`${e}:${r}`);i&&(clearTimeout(i.timeoutId),i.resolve(),this.pendingRenegotiations.delete(`${e}:${r}`))}waitForChannelOpen(e,r=1e4){return new Promise((i,o)=>{if(e.readyState==="open")return i();let s=setTimeout(()=>o(new Error(`Channel open timeout: ${e.label}`)),r);e.onopen=()=>{clearTimeout(s),i()},e.onerror=a=>{clearTimeout(s),o(a)}})}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var iM=(()=>{class t{constructor(){this.logger=j("PeerLifecycleCoordinator"),this.channelManager=w(Dt)}async coordinateDisconnect(e,r){this.logger.info("[coordinateDisconnect] disconnecting peer:",e.substring(0,8),{connected:r?.connected??!1}),r&&await r.destroy(),this.channelManager.cleanupPeer(e)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var Yr=U(Q(),1);var np=(()=>{class t{constructor(){this.logger=j("PeerHandshakeCoordinator"),this.config=w(Oe),this.reconnectService=w(Kr),this.inFlight=new Map,this.inFlightInitiator=new Map}async beginHandshakeFromOffer(e,r,i,o={}){return this.runHandshake(e,i,o,async()=>{await i.ensurePeer()})}async beginHandshakeAsInitiator(e,r,i={}){let o=this.inFlightInitiator.get(e);if(o)return this.logger.info("[handshake] joining existing in-flight initiator handshake (race dedup)",{peerId:e.substring(0,8)}),o;let s=this.withOverallDeadline(e,this.runHandshake(e,r,i,async()=>{await r.ensurePeer()}),i);return this.inFlightInitiator.set(e,s),s.finally(()=>{this.inFlightInitiator.get(e)===s&&this.inFlightInitiator.delete(e)}),s}withOverallDeadline(e,r,i){let o=Math.max((i.timeoutMs??this.config.connectionTimeoutMs())*3,45e3),s=null,a=new Promise(c=>{s=setTimeout(()=>{this.logger.warn("[handshake] overall deadline exceeded, aborting stuck attempt",{peerId:e.substring(0,8),deadlineMs:o}),this.abort(e),c({outcome:"timeout",error:new Error(`handshake overall deadline ${o}ms exceeded`)})},o)});return Promise.race([r,a]).finally(()=>{s&&clearTimeout(s)})}abort(e){let r=this.inFlight.get(e);r&&(this.logger.debug("[abort] aborting in-flight handshake",{peerId:e.substring(0,8)}),r.abort(),this.inFlight.delete(e))}abortForDisconnect(e){this.abort(e),this.inFlightInitiator.delete(e)&&this.logger.info("[abortForDisconnect] cleared in-flight initiator handshake (explicit disconnect)",{peerId:e.substring(0,8)})}async runHandshake(e,r,i,o){this.abortInFlight(e);let s=new AbortController;this.inFlight.set(e,s),this.transitionEnter(e);try{if(await o(),r.isConnected())return this.markConnected(e);if(s.signal.aborted)return this.markAborted(e,r);if(r.awaitsInPrologue)return this.markConnected(e);let a=i.timeoutMs??this.config.connectionTimeoutMs();return await this.awaitConnected(e,r.message$,a,s.signal),r.isConnected()?this.markConnected(e):s.signal.aborted?this.markAborted(e,r):this.markConnected(e)}catch(a){return this.handleFailure(e,r,s.signal,a)}finally{this.inFlight.get(e)===s&&this.inFlight.delete(e)}}abortInFlight(e){let r=this.inFlight.get(e);r&&(this.logger.info("[runHandshake] aborting prior in-flight handshake",{peerId:e.substring(0,8)}),r.abort(),this.inFlight.delete(e))}transitionEnter(e){let r=this.reconnectService.state.get(e);r||this.reconnectService.state.getOrCreate(e,!1),this.reconnectService.state.transition(e,"CONNECTING")||(this.reconnectService.state.resetOnExplicitConnect(e,r?.initiator??!1),this.reconnectService.state.transition(e,"CONNECTING"))}markConnected(e){return this.reconnectService.state.transition(e,"CONNECTED"),{outcome:"connected"}}async markAborted(e,r){return this.reconnectService.state.transition(e,"FAILED"),await r.disconnect(),{outcome:"aborted"}}async handleFailure(e,r,i,o){let s=o instanceof Error?o:new Error(String(o));if(r.isConnected())return this.markConnected(e);let a=s.name==="TimeoutError"||/timeout/i.test(s.message);return this.reconnectService.state.transition(e,"FAILED"),await r.disconnect(),i.aborted?{outcome:"aborted",error:s}:{outcome:a?"timeout":"failed",error:s}}async awaitConnected(e,r,i,o){if(o.aborted)throw new Error("aborted");await(0,Yr.firstValueFrom)(r.pipe((0,Yr.filter)(s=>s.type==="[session.transport.webrtc.peer] connected"&&s.peerId===e),(0,Yr.take)(1),(0,Yr.timeout)(i)))}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var Ot=U(Q(),1);var uc=(()=>{class t{constructor(){this.configService=w(Oe,{optional:!0}),this.tokenConfig=w(Bi,{optional:!0}),this.config=()=>{if(this.configService&&typeof this.configService.config=="function")return this.configService.config();if(this.tokenConfig)return this.tokenConfig;throw new Error("[PeerSessionAdapter] Neither WebRTCConfigService nor WEB_RTC_CONFIG provided")}}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();async function oM(t,n){for(let e=1;e<=n.maxAttempts;e++)try{return await t()}catch(r){if(n.onError?.(e,r),e<n.maxAttempts){let i=n.exponential?n.delay*Math.pow(2,e-1):n.delay;await new Promise(o=>setTimeout(o,i))}else throw r}throw new Error("Retry failed")}var rp=class{constructor(){this.forward=new Map,this.reverse=new Map}set(n,e){this.forward.set(n,e),this.reverse.set(e,n)}getByKey(n){return this.forward.get(n)}getByValue(n){return this.reverse.get(n)}deleteByKey(n){let e=this.forward.get(n);e!==void 0&&(this.forward.delete(n),this.reverse.delete(e))}deleteByValue(n){let e=this.reverse.get(n);e!==void 0&&(this.reverse.delete(n),this.forward.delete(e))}hasKey(n){return this.forward.has(n)}hasValue(n){return this.reverse.has(n)}clear(){this.forward.clear(),this.reverse.clear()}get size(){return this.forward.size}};function sM(t,n,e){let r=typeof t=="string"?n.get(t):t;if(!r)return!1;if(r.destroyed)return!0;let i=r.connectionState;if(i==="failed"||i==="closed")return!0;let o=typeof t=="string"?t:[...n.entries()].find(([,s])=>s===r)?.[0];if(i==="disconnected"){if(!o)return!0;let s=e.get(o);return s===void 0?(e.set(o,Date.now()),!1):Date.now()-s>3e3}return o&&e.delete(o),!1}function aM(t,n){let e=typeof t=="string"?n.get(t):t;if(!e)return!1;if(e.destroyed)return!0;let r=e.connectionState;return r==="failed"||r==="closed"||r==="disconnected"}function cM(t,n,e,r,i,o){let s=t.map.get(n);if(s&&!t.isPeerDead(s))return t.logger.debug("[ensurePeer] Reusing existing peer:",n.substring(0,8),"connected:",s.connected),s;s&&(t.logger.info("[ensurePeer] Destroying dead peer:",n.substring(0,8),{destroyed:s.destroyed,connectionState:s.connectionState}),t.disconnect(n));let a=t.selfPeerId(),c=a?a<n:void 0;t.logger.info("[ensurePeer] Creating new peer:",n.substring(0,8),"initiator:",e,"polite:",c),t.reconnectService.state.getOrCreate(n,e),t.reconnectService.state.transition(n,"CONNECTING");let u=t.sessionAdapter.create({initiator:e,polite:c});return t.eventHandler.setupPeerEvents(u,n,r,i,l=>t.map.get(l),o),t.map.set(n,u),u}var uM=(()=>{class t{constructor(){this.config=w(Oe),this.logger=j("PeerConnectionManager"),this.sessionAdapter=w(uc),this.eventHandler=w(nM),this.lifecycleCoordinator=w(iM),this.reconnectService=w(Kr),this.channelManager=w(Dt),this.map=new Map,this.disconnectedSinceMap=new Map}async connect(e,r,i,o,s){if(!this.isConnected(e)){if(this.map.has(e))try{await this.waitForConnected(e,i);return}catch{if(this.isConnected(e))return;this.disconnect(e)}await this.retryConnect(e,r,i,o,s)}}async retryConnect(e,r,i,o,s){try{await oM(()=>this.connectOnce(e,r,i,o,s),{maxAttempts:this.config.maxRetryCount(),delay:this.config.retryDelayMs(),onError:()=>{this.isConnected(e)||this.disconnect(e)}})}catch(a){if(this.isConnected(e))return;throw a}}ensurePeer(e,r,i,o,s){return cM({map:this.map,logger:this.logger,sessionAdapter:this.sessionAdapter,eventHandler:this.eventHandler,reconnectService:this.reconnectService,selfPeerId:()=>typeof this.config.peerId=="function"?this.config.peerId():"",isPeerDead:a=>this.isPeerDead(a),disconnect:a=>this.disconnect(a)},e,r,i,o,s)}isPeerDead(e){return sM(e,this.map,this.disconnectedSinceMap)}isPeerDeadIgnoringGrace(e){return aM(e,this.map)}connected$(e,r){return this.connectedWait?.(e)??r.pipe((0,Ot.filter)(i=>i.type==="[session.transport.webrtc.peer] connected"),(0,Ot.filter)(i=>i.peerId===e),(0,Ot.map)(()=>{}))}async connectOnce(e,r,i,o,s){this.ensurePeer(e,r,i,o,s),!this.isConnected(e)&&await(0,Ot.firstValueFrom)(this.connected$(e,i).pipe((0,Ot.take)(1),(0,Ot.timeout)(this.config.connectionTimeoutMs())))}async waitForConnected(e,r){await(0,Ot.firstValueFrom)(this.connected$(e,r).pipe((0,Ot.take)(1),(0,Ot.timeout)(this.config.connectionTimeoutMs())))}async disconnect(e){let r=this.map.get(e);try{await this.lifecycleCoordinator.coordinateDisconnect(e,r)}catch(i){this.logger.warn("[disconnect] cascade failed",{peerId:e.substring(0,8),err:String(i)})}finally{this.map.get(e)===r&&this.map.delete(e),this.disconnectedSinceMap.delete(e)}}isConnected(e){return this.map.get(e)?.connected??!1}hasPeer(e){return this.map.has(e)}getPeer(e){return this.map.get(e)}async dispose(){let e=Array.from(this.map.values()).map(r=>r.destroy());this.map.clear(),await Promise.all(e)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var Me=U(Q(),1);var fM=U(Q(),1);var lM=(()=>{class t{constructor(){this.logger=j("PeerHeartbeat")}static{this.PING_INTERVAL_MS=500}static{this.PONG_TIMEOUT_MS=5e3}static{this.HANDSHAKE_TIMEOUT_MS=6e4}static{this.BUFFER_PRESSURE_THRESHOLD=256*1024}start(e,r,i,o=()=>!0,s=()=>!1,a){let c=a?.pingIntervalMs??t.PING_INTERVAL_MS,u=a?.pongTimeoutMs??t.PONG_TIMEOUT_MS,l=a?.handshakeTimeoutMs??t.HANDSHAKE_TIMEOUT_MS,d=Date.now(),f=!1,p=0,m=-1,y=Math.ceil(u/c),b=D=>{try{let T=JSON.parse(String(D.data));if(T&&T.type==="pong")typeof T.seq=="number"?T.seq>m&&(m=T.seq):m=Math.max(m,p-1),f=!0;else if(T&&T.type==="ping"&&typeof T.t=="number"&&r.readyState==="open"&&o()){let K={type:"pong",t:T.t};typeof T.seq=="number"&&(K.seq=T.seq),r.send(JSON.stringify(K))}}catch{}};r.addEventListener("message",b);let E=setInterval(()=>{if(r.readyState!=="open"||!o())return;let D=Date.now();if(f&&p-1-m>=y)if(s())this.logger.debug(`[peer-heartbeat] active timeout deferred (wire active) peer=${e.substring(0,8)}`,{peerId:e.substring(0,8),sentPings:p,lastAckedSequence:m,diff:p-1-m,limit:y});else{this.logger.warn(`[peer-heartbeat] active timeout peer=${e.substring(0,8)}`,{peerId:e.substring(0,8),sentPings:p,lastAckedSequence:m,diff:p-1-m,limit:y}),i(e);return}if(!f&&D-d>l)if(s())this.logger.debug(`[peer-heartbeat] handshake timeout deferred (wire active) peer=${e.substring(0,8)}`,{peerId:e.substring(0,8),elapsed:D-d});else{this.logger.warn(`[peer-heartbeat] handshake timeout peer=${e.substring(0,8)}`,{peerId:e.substring(0,8),elapsed:D-d}),i(e);return}if(r.bufferedAmount>t.BUFFER_PRESSURE_THRESHOLD){this.logger.warn(`[peer-heartbeat] buffer pressure peer=${e.substring(0,8)}`,{peerId:e.substring(0,8),bufferedAmount:r.bufferedAmount,threshold:t.BUFFER_PRESSURE_THRESHOLD}),i(e);return}try{let T=p;p++,r.send(JSON.stringify({type:"ping",t:D,seq:T}))}catch(T){this.logger.warn(`[peer-heartbeat] send-failed peer=${e.substring(0,8)}`,{peerId:e.substring(0,8),err:String(T)})}},c);return()=>{clearInterval(E),r.removeEventListener("message",b)}}isPong(e,r){try{let i=JSON.parse(r);return i&&i.type==="pong"}catch{return!1}}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var dM=ps.heartbeat.buildLabel(),ip=(()=>{class t{constructor(){this.logger=j("PeerHeartbeatCoordinator"),this.heartbeat=w(lM),this.channelManager=w(Dt),this.stops=new Map,this.silentFailSubject=new fM.Subject,this.silentFail$=this.silentFailSubject.asObservable()}static{this.WIRE_STALL_BYTES=512}async start(e,r=()=>!0,i){this.stop(e);let o=await this.channelManager.createChannelAsync(e,dM,"heartbeat"),s=o,a=()=>{let u=this.channelManager.getPeerChannels(e);if(!u)return!1;let l=!1;for(let[d,f]of u)if(d!==dM&&f.readyState==="open"){l=!0;break}return l?o.bufferedAmount<=t.WIRE_STALL_BYTES:!1},c=this.heartbeat.start(e,s,u=>this.silentFailSubject.next({peerId:u}),r,a,i);this.stops.set(e,c),this.logger.debug("[start] heartbeat started",{peerId:e.substring(0,8)})}stop(e){let r=this.stops.get(e);r&&(r(),this.stops.delete(e),this.logger.debug("[stop] heartbeat stopped",{peerId:e.substring(0,8)}))}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var Qn=U(Q(),1);function hM(t,n,e,r=()=>Date.now()){let i=r(),o=s=>{let a=r();e.next({peerId:t,event:s,at:a,elapsedMs:a-i})};return{iceRestart$:()=>(0,Qn.defer)(()=>(o("tier1-attempt"),n.iceRestart$())).pipe((0,Qn.tap)({complete:()=>o("tier1-ok")})),fullReconnect$:()=>(0,Qn.defer)(()=>(o("tier2-attempt"),n.fullReconnect$())),onReconnected:s=>{o("tier2-ok"),n.onReconnected(s)},cleanup:()=>{o("exhausted"),n.cleanup()}}}function pM(t){return t.pipe((0,Qn.filter)(n=>n.event==="exhausted"),(0,Qn.map)(({peerId:n})=>({peerId:n})))}function Zr(t){return t.substring(0,8)}function mM(t,n){return t.subscribe(e=>{n.debug("[recovery-event]",{peerId:Zr(e.peerId),event:e.event,elapsedMs:e.elapsedMs})})}var Rs=U(Q(),1);var op=U(Q(),1);function gM(t,n){return t.pipe((0,op.switchMap)(()=>new op.Observable(e=>{let r=n();return e.next(r.value),()=>r.teardown()})))}var sp=U(Q(),1);function yM(t){return t.lifecycle$.pipe((0,sp.distinctUntilChanged)(),(0,sp.filter)(n=>n==="interrupted"||n==="failed")).subscribe(n=>{n==="interrupted"?t.restartIce():t.reconnect()})}var vM=U(Q(),1);function _M(t,n){return(0,vM.using)(()=>{let e=t();return{peer:e,unsubscribe:()=>e.close()}},e=>n(e.peer))}function bM(t,n){return gM(t,()=>({value:_M(n,e=>(0,Rs.merge)(e.lifecycle$,new Rs.Observable(()=>yM(e)))),teardown:()=>{}})).pipe((0,Rs.switchMap)(e=>e))}var Ie=U(Q(),1);var wM=t=>"peerId"in t&&typeof t.peerId=="string",EM=t=>t.type==="recovery-exhausted";function ap(t){return{peerId:t,phase:"idle",generation:0,attachGeneration:0,tier2InFlight:!1,present:!0}}var cp=t=>t.phase==="exhausted";function SM(t,n){switch(n.type){case"[session.transport.webrtc.peer] connected":return{...t,phase:"connected",generation:t.generation+1,attachGeneration:t.tier2InFlight?t.attachGeneration:t.attachGeneration+1};case"tier2-started":return{...t,phase:"recovering",tier2InFlight:!0};case"tier2-ended":return{...t,tier2InFlight:!1};case"recovery-exhausted":return{...t,phase:"exhausted",tier2InFlight:!1};case"peer-appeared":return t.present?t:{...t,present:!0};case"peer-lost":return t.present?{...t,present:!1}:t;case"[session.transport.webrtc.peer] error":case"heartbeat-silent-fail":case"peer-unhealthy":return t.phase==="connected"?{...t,phase:"idle"}:t;case"[session.transport.webrtc.peer] close":return t.tier2InFlight?t:t.phase==="connected"?{...t,phase:"idle"}:t;default:return t}}function CM(t,n){let e=new Ie.Subject;return t.pipe((0,Ie.groupBy)(r=>r.peerId,{duration:r=>(0,Ie.merge)(r.pipe((0,Ie.filter)(EM)),e.pipe((0,Ie.filter)(i=>i===r.key)))}),(0,Ie.mergeMap)(r=>{let i={dispatched:!1},o=r.pipe((0,Ie.scan)((c,u)=>({snapshot:SM(c.snapshot,u),prev:c.snapshot,event:u}),{snapshot:ap(r.key),prev:ap(r.key),event:null}),(0,Ie.share)()),s=o.pipe((0,Ie.tap)(({snapshot:c,event:u})=>{u&&SJ(u,c,i,n)}),(0,Ie.ignoreElements)()),a=o.pipe((0,Ie.map)(({snapshot:c})=>c),(0,Ie.distinctUntilChanged)((c,u)=>c.attachGeneration===u.attachGeneration&&cp(c)===cp(u)),(0,Ie.switchMap)(c=>c.attachGeneration===0||cp(c)?Ie.EMPTY:n.lifecycle$(c.peerId)),(0,Ie.ignoreElements)());return(0,Ie.merge)(o.pipe((0,Ie.map)(({snapshot:c})=>c)),s,a).pipe((0,Ie.catchError)(c=>{n.onGroupError(r.key,c);try{n.stopHeartbeat(r.key),n.disconnect(r.key)}catch{}return e.next(r.key),(0,Ie.of)({...ap(r.key),phase:"exhausted"})}))}),(0,Ie.share)())}function SJ(t,n,e,r){switch(t.type){case"[session.transport.webrtc.peer] error":r.stopHeartbeat(t.peerId),r.disconnect(t.peerId);return;case"[session.transport.webrtc.peer] close":if(r.isPcConnected(t.peerId)||n.tier2InFlight||(r.stopHeartbeat(t.peerId),e.dispatched))return;e.dispatched=!0,r.disconnect(t.peerId);return;case"[session.transport.webrtc.peer] connected":e.dispatched=!1,r.startHeartbeat(t.peerId);return;case"heartbeat-silent-fail":r.stopHeartbeat(t.peerId),r.disconnect(t.peerId);return;case"peer-unhealthy":r.stopHeartbeat(t.peerId),r.disconnect(t.peerId);return;default:return}}var tt=U(Q(),1);var Jn=U(Q(),1);function up(t,n,e){return(0,Jn.defer)(()=>(t.restartIce(),n.pipe((0,Jn.map)(r=>{if(r==="failed")throw new Error("[restartIce] pc failed during ICE restart");return r}),(0,Jn.first)(r=>r==="connected"),(0,Jn.timeout)(e),(0,Jn.map)(()=>{}))))}var Dn=U(Q(),1);var Xn=U(Q(),1),Mt=U(Ni(),1);var kb={n1IceRestart:2,n2FullReconnect:20,iceRestartTimeoutMs:6e3,initialBackoffMs:200,maxBackoffMs:1e4};function Lb(t,n,e=Math.random){if(n<=1)return 0;let r=Math.min(t.initialBackoffMs*Math.pow(2,n-1),t.maxBackoffMs);return Math.floor(e()*r)}function IM(t,n,e,r=()=>(0,Xn.of)(0)){let i=s=>(0,Xn.defer)(r).pipe((0,Mt.take)(1),(0,Mt.switchMap)(()=>s())),o=i(()=>t.fullReconnect$()).pipe((0,Mt.tap)(s=>t.onReconnected(s)),(0,Mt.retry)({count:n.n2FullReconnect,delay:(s,a)=>(0,Xn.timer)(Lb(n,a))}),(0,Mt.catchError)(()=>(t.cleanup(),Xn.EMPTY)));return e?o:i(()=>t.iceRestart$().pipe((0,Mt.timeout)(n.iceRestartTimeoutMs))).pipe((0,Mt.retry)({count:n.n1IceRestart,delay:(s,a)=>(0,Xn.timer)(Lb(n,a))}),(0,Mt.catchError)(()=>o))}function TM(t){let n=new Dn.BehaviorSubject(t.reactivePeer),e=new Dn.Subject,r=s=>({...s,onReconnected:a=>{s.onReconnected(a);let c=n.value;n.next(t.nextGeneration(a)),c.close()}}),i=(0,Dn.merge)(e,t.externalDeath$).pipe((0,Dn.exhaustMap)(s=>IM(r(t.tiers()),t.cfg,s.skipIce,t.retryGate))).subscribe(),o=!1;return{lifecycle$:n.pipe((0,Dn.switchMap)(s=>s.lifecycle$)),restartIce:()=>e.next({skipIce:!1}),reconnect:()=>e.next({skipIce:!0}),close:()=>{o||(o=!0,i.unsubscribe(),n.value.close(),n.complete(),e.complete())}}}function DM(t){if(!t?.reactive||!t.restartIce)return;let{reactive:n}=t;return{lifecycle$:n.lifecycle$,restartIce:()=>t.restartIce(),get connectionState(){return t.connectionState}}}function CJ(t,n){let e=(r,i)=>r.pipe((0,tt.filter)(o=>o.peerId===t),(0,tt.filter)(()=>n.autoReconnect()&&!n.state.isReconnecting(t)),(0,tt.map)(()=>({skipIce:!0,source:i})));return(0,tt.merge)(e(n.silentFail$,"heartbeat"),e(n.sendFailed$,"send-failed"),e(n.peerUnhealthy$,"zombie"))}async function IJ(t,n){let e=n.state.getInitiator(t)??!0;n.state.markReconnecting(t,!0),await n.disconnect(t),await n.connect(t,e)}function TJ(t,n){return{iceRestart$:()=>(0,tt.defer)(()=>{let e=n.getRecoveryPeer(t);if(!e)throw new Error("[recovery] no peer for iceRestart");return n.logger.info("[recovery] Tier1 restartIce",{peerId:Zr(t)}),up(e,e.lifecycle$,kb.iceRestartTimeoutMs)}),fullReconnect$:()=>(0,tt.defer)(()=>(n.logger.warn("[recovery] Tier2 full reconnect",{peerId:Zr(t)}),(0,tt.from)(IJ(t,n)).pipe((0,tt.map)(()=>{let e=n.getRecoveryPeer(t);if(!e)throw new Error("[recovery] no peer after reconnect");if(e.connectionState!=="connected")throw new Error(`[recovery] reconnect did not yield connected pc (state=${e.connectionState})`);return e}),(0,tt.finalize)(()=>n.state.markReconnecting(t,!1))))),onReconnected:()=>{n.logger.info("[recovery] reconnected, re-watch",{peerId:Zr(t)})},cleanup:()=>{n.logger.warn("[recovery] Tier3 cleanup (recovery exhausted)",{peerId:Zr(t)}),n.disconnect(t),n.onExhausted(t)}}}var xM=t=>({lifecycle$:t.lifecycle$,close:()=>{}});function OM(t,n){let e=n.getRecoveryPeer(t);if(!e)return{lifecycle$:tt.NEVER,restartIce:()=>{},reconnect:()=>{},close:()=>{}};let r=o=>n.logger.info("[recovery] trigger",{peerId:Zr(t),source:o.source,skipIce:o.skipIce}),i=TM({reactivePeer:xM(e),externalDeath$:CJ(t,n).pipe((0,tt.tap)(r)),tiers:()=>hM(t,TJ(t,n),n.recoveryEvents$),cfg:kb,nextGeneration:xM,retryGate:()=>n.presentGate$(t)});return{...i,restartIce:()=>{r({skipIce:!1,source:"pc-state"}),i.restartIce()},reconnect:()=>{r({skipIce:!0,source:"pc-state"}),i.reconnect()}}}function MM(t,n,e,r){if(!t||t.connected){let i=e.type;(i==="offer"||i==="answer")&&r("[handleSignal] drop",{peerId:n.substring(0,8),hasPeer:!!t,connected:t?.connected===!0,sdpType:i});return}t.signal(e)}function AM(t){return!t||t.destroyed?!1:t.connectionState===void 0?!0:t.connectionState!=="closed"&&t.connectionState!=="failed"&&t.signalingState!=="closed"}function NM(t,n,e,r){if(!t)return r.logger.warn("[send] Peer not found:",n.substring(0,8)),!1;if(!t.connected)return r.logger.warn("[send] Peer not connected:",n.substring(0,8)),!1;try{return t.send(JSON.stringify(e)),!0}catch(i){return r.logger.error("[send] Failed:",n.substring(0,8),i),r.onSendFailed(n),!1}}var ks=(()=>{class t{attachPresence(e){this.presenceSource$.next(e)}constructor(){this.logger=j("PeerService"),this.connectionManager=w(uM),this.handshakeCoordinator=w(np),this.renegotiationHandler=w(rM),this.reconnectService=w(Kr),this.heartbeatCoordinator=w(ip),this.config=w(Oe),this.channelManager=w(Dt),this.message$=new Me.ReplaySubject(1),this.sendFailed$=new Me.Subject,this.recoveryEvents$=new Me.Subject,this.recoveryExhausted$=pM(this.recoveryEvents$),this.internalEvents$=new Me.Subject,this.presenceSource$=new Me.ReplaySubject(1),this.presenceEvents$=this.presenceSource$.pipe((0,Me.switchMap)(e=>e)),this.wiringDeps={getRecoveryPeer:e=>DM(this.connectionManager.getPeer(e)),disconnect:e=>this.connectionManager.disconnect(e),connect:(e,r)=>this.connectionManager.connect(e,r,this.message$,(i,o)=>this.send(i,o),(i,o)=>this.handleRenegotiationMessage(i,o)),state:{getInitiator:e=>this.reconnectService.state.getInitiator(e),markReconnecting:(e,r)=>{this.internalEvents$.next({type:r?"tier2-started":"tier2-ended",peerId:e}),this.reconnectService.state.markReconnecting(e,r)},isReconnecting:e=>this.snapshotOf(e)?.tier2InFlight===!0},autoReconnect:()=>this.config.autoReconnect(),presentGate$:e=>(0,Me.defer)(()=>this.snapshotOf(e)?.present!==!1?(0,Me.of)(0):this.peerState$.pipe((0,Me.filter)(r=>r.peerId===e&&r.present),(0,Me.take)(1))),silentFail$:this.heartbeatCoordinator.silentFail$,sendFailed$:this.sendFailed$,peerUnhealthy$:this.channelManager.peerUnhealthy$,recoveryEvents$:this.recoveryEvents$,onExhausted:e=>this.internalEvents$.next({type:"recovery-exhausted",peerId:e}),logger:this.logger},this.orchestratorEvents$=(0,Me.merge)(this.message$.pipe((0,Me.filter)(wM)),this.heartbeatCoordinator.silentFail$.pipe((0,Me.map)(({peerId:e})=>({type:"heartbeat-silent-fail",peerId:e}))),this.channelManager.peerUnhealthy$.pipe((0,Me.map)(({peerId:e})=>({type:"peer-unhealthy",peerId:e}))),this.internalEvents$,this.presenceEvents$),this.peerState$=CM(this.orchestratorEvents$,{startHeartbeat:e=>{this.heartbeatCoordinator.start(e,()=>AM(this.connectionManager.getPeer(e))).catch(r=>this.logger.warn("[heartbeat] start failed",{peerId:e.substring(0,8),err:String(r)}))},stopHeartbeat:e=>this.heartbeatCoordinator.stop(e),disconnect:e=>this.disconnect(e),isPcConnected:e=>this.connectionManager.getPeer(e)?.connected===!0,lifecycle$:e=>bM((0,Me.of)(0),()=>OM(e,this.wiringDeps)),onGroupError:(e,r)=>this.logger.warn("[orchestrator] group error (isolated)",{peerId:e.substring(0,8),err:String(r)})}),this.stateProjection=new Map,this.destroyed$=new Me.Subject,this.peerState$.pipe((0,Me.takeUntil)(this.destroyed$)).subscribe(e=>this.stateProjection.set(e.peerId,e)),this.connectionManager.connectedWait=e=>this.connectedOf$(e),mM(this.recoveryEvents$,this.logger)}snapshotOf(e){return this.stateProjection.get(e)}connectedOf$(e){return(0,Me.defer)(()=>this.snapshotOf(e)?.phase==="connected"?(0,Me.of)(void 0):this.peerState$.pipe((0,Me.filter)(r=>r.peerId===e&&r.phase==="connected"),(0,Me.take)(1),(0,Me.map)(()=>{})))}async connect(e,r){this.reconnectService.state.resetOnExplicitConnect(e,r);let i=await this.handshakeCoordinator.beginHandshakeAsInitiator(e,{message$:this.message$,awaitsInPrologue:!0,ensurePeer:async()=>{await this.connectionManager.connect(e,r,this.message$,(o,s)=>this.send(o,s),(o,s)=>this.handleRenegotiationMessage(o,s))},disconnect:()=>this.connectionManager.disconnect(e),isConnected:()=>this.connectionManager.isConnected(e)});if(i.outcome!=="connected")throw i.error??new Error(`handshake ${i.outcome}`)}ensurePeer(e,r){return this.reconnectService.state.resetOnExplicitConnect(e,r),this.connectionManager.ensurePeer(e,r,this.message$,(i,o)=>this.send(i,o),(i,o)=>this.handleRenegotiationMessage(i,o))}handleSignal(e,r){MM(this.connectionManager.getPeer(e),e,r,(i,o)=>this.logger.warn(i,o))}send(e,r){return NM(this.connectionManager.getPeer(e),e,r,{logger:this.logger,onSendFailed:i=>{this.disconnect(i),this.sendFailed$.next({peerId:i})}})}disconnect(e){this.handshakeCoordinator.abortForDisconnect(e),this.connectionManager.disconnect(e)}async disconnectAndAwait(e){this.handshakeCoordinator.abortForDisconnect(e),await this.connectionManager.disconnect(e)}isConnected(e){return this.connectionManager.isConnected(e)}hasPeer(e){return this.connectionManager.hasPeer(e)}isPeerDead(e){return this.connectionManager.isPeerDead(e)}isPeerDeadIgnoringGrace(e){return this.connectionManager.isPeerDeadIgnoringGrace(e)}getConnectedPeerIds(){return Array.from(this.connectionManager.map.keys())}async createDynamicChannel(e,r,i="reliable-ordered"){return this.renegotiationHandler.createDynamicChannel(e,r,i,o=>this.connectionManager.getPeer(o))}async handleRenegotiateSignal(e,r){return this.renegotiationHandler.handleRenegotiateSignal(e,r,i=>this.connectionManager.getPeer(i),this.message$)}async handleRenegotiationMessage(e,r){return this.renegotiationHandler.handleRenegotiationMessage(e,r,i=>this.connectionManager.getPeer(i),(i,o)=>this.send(i,o))}async dispose(){this.destroyed$.next(),this.destroyed$.complete(),await this.connectionManager.dispose()}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var lp=class{constructor(){this.map=new Map}add(n,e){let r=this.map.get(n);r?r.push(e):this.map.set(n,[e])}size(){return this.map.size}has(n){return this.map.has(n)}dispose(n){let e=this.map.get(n);if(e){for(let r of e)try{r.unsubscribe()}catch{}this.map.delete(n)}}disposeAll(){for(let[,n]of this.map)for(let e of n)try{e.unsubscribe()}catch{}this.map.clear()}};var On=U(Q(),1);var lc=U(Q(),1);var xJ=/\s(\d{1,3}\.\d{1,3}\.\d{1,3}\.0)\s\d+\styp host(\s|$)/;function PM(t){return t?xJ.test(t):!1}function DJ(t){if(Array.isArray(t))return t;if(typeof t!="object"||t===null)return[];let n=t;return Array.isArray(n.candidates)?n.candidates:n.candidate?[n.candidate]:"candidate"in n||"sdpMid"in n||"sdpMLineIndex"in n?[n]:[]}function jb(t){let{message$:n,signaling:e,peer:r,destroy$:i,dispatch:o,myHashedId:s,logger:a}=t;a.info("[signaling:candidate:setup] myHashedId",{myHashedId:s?.slice(0,16),len:s?.length}),n.pipe((0,lc.filter)(c=>c.payload.type==="candidates"),(0,lc.filter)(c=>{let u=c.payload.to===s;return u||a.info("[signaling:candidate:to-mismatch]",{to:c.payload.to?.slice(0,16),myHashedId:s?.slice(0,16),from:c.payload.from?.slice(0,16)}),u}),(0,lc.takeUntil)(i)).subscribe(async c=>{let u=await e.getSenderPublicKey(c.payload.from);if(!u)return;let l=c.payload.data,d=In(l)?await e.decryptMessageData(l,u):l;if(d==null)return;let f=DJ(d);for(let p of f)if(p){if(PM(p.candidate??void 0)){a.info("[candidate-handler] drop junk host candidate (.0 network address)",{candidate:p.candidate?.slice(0,80)});continue}r.handleSignal(u,{candidate:p}),o({type:"[session.transport.webrtc] ice-candidate-received",peerId:u,candidate:p?.candidate})}})}var dc=U(Q(),1);function Fb(t){let{message$:n,signaling:e,peer:r,destroy$:i,dispatch:o,myHashedId:s}=t;n.pipe((0,dc.filter)(a=>a.payload.type==="answer"),(0,dc.filter)(a=>a.payload.to===s),(0,dc.takeUntil)(i)).subscribe(async a=>{let c=await e.getSenderPublicKey(a.payload.from);if(!c)return;let u=a.payload.data,l=In(u)?await e.decryptMessageData(u,c):u.sdp;l!==null&&($b(o,c,l),r.handleSignal(c,l),o({type:"[session.transport.webrtc] answer-received",peerId:c}))})}function RM(t){if(!t)return;let n=t.split(/\r?\n/),e=!1;for(let r of n){if(/^m=application\b/.test(r)){e=!0;continue}if(/^m=/.test(r)){e=!1;continue}if(!e)continue;let i=r.match(/^a=max-message-size:(.+)$/);if(!i)continue;let o=i[1].trim(),s=Number(o);return!Number.isFinite(s)||s<=0?void 0:Math.floor(s)}}var OJ=4e4;function kM(t){let{message$:n,signaling:e,peer:r,registry:i,destroy$:o,dispatch:s,coordinator:a}=t;n.pipe((0,On.filter)(c=>c.payload.type==="offer"),(0,On.groupBy)(c=>c.payload.from),(0,On.mergeMap)(c=>c.pipe((0,On.throttleTime)(500))),(0,On.takeUntil)(o)).subscribe(async c=>{if(Date.now()-c.payload.timestamp>OJ)return;let l=await e.getSenderPublicKey(c.payload.from);if(!l)return;let d=c.payload.data,f=In(d)?await e.decryptMessageData(d,l):d.sdp;if(f!==null){$b(s,l,f);try{await MJ(r,i,l,f,a)}catch(p){t.logger.error("[setupOfferHandler] runOfferHandshake threw",{err:p?.message||String(p)})}s({type:"[session.transport.webrtc] offer-received",peerId:l})}})}function $b(t,n,e){if(!e||typeof e.sdp!="string")return;let r=RM(e.sdp);r!==void 0&&t({type:"[session.transport.webrtc] sdp-caps-received",peerId:n,maxMessageSize:r})}async function MJ(t,n,e,r,i){let o=r,s=()=>{t.hasPeer(e)&&t.isPeerDeadIgnoringGrace(e)&&(n.dispose(e),t.disconnect(e)),t.ensurePeer(e,!1),t.handleSignal(e,o)};if(!i){s();return}await i.beginHandshakeFromOffer(e,o,{message$:t.message$,awaitsInPrologue:!0,ensurePeer:()=>{s()},disconnect:()=>t.disconnect(e),isConnected:()=>t.isConnected(e)},{timeoutMs:3e4})}var _t=U(Q(),1);var un=U(Q(),1);function qb(t){let{peerListService:n,peer:e,registry:r,destroy$:i,dispatch:o}=t,s=FO(n.peers$);return e.attachPresence(s.pipe((0,un.map)(a=>a.type==="removed"?{type:"peer-lost",peerId:a.peer.publicKey??a.peer.id}:{type:"peer-appeared",peerId:a.peer.publicKey??a.peer.id}),(0,un.takeUntil)(i))),s.pipe((0,un.filter)(a=>a.type!=="removed"),(0,un.takeUntil)(i)).subscribe(({peer:a})=>{o({type:"[session.transport.webrtc] announce-received",peerId:a.publicKey??a.id,roles:a.roles??[],name:a.name,serverName:a.roles?.includes("server")?a.name:void 0})}),s.pipe((0,un.filter)(a=>a.type==="removed"),(0,un.takeUntil)(i)).subscribe(({peer:a})=>{let c=a.publicKey??a.id;e.isConnected(c)||(r.dispose(c),e.disconnect(c),o({type:"[session.transport.webrtc] peer-close",peerId:c}))}),un.EMPTY}function Bb(t){return t instanceof Error?t.stack??t.message:String(t)}function LM(t){let{peer:n,signaling:e,registry:r,logger:i,destroy$:o,dispatch:s}=t,a=new Map;function c(u){let l=a.get(u);!l||l.flushing||(l.flushing=!0,(async()=>{for(;l.queue.length>0;){let d=l.queue.splice(0,l.queue.length);try{await e.sendCandidates(u,d)}catch(f){i.error("[signaling] Send failed:",Bb(f))}}l.flushing=!1})())}n.message$.pipe((0,_t.filter)(u=>u.type==="[session.transport.webrtc.peer] offer"),(0,_t.takeUntil)(o)).subscribe(u=>{s({type:"[session.transport.webrtc] offer-sent",peerId:u.peerId}),e.sendOffer(u.peerId,u.data).catch(l=>i.error("[signaling] Send failed:",Bb(l)))}),n.message$.pipe((0,_t.filter)(u=>u.type==="[session.transport.webrtc.peer] answer"),(0,_t.takeUntil)(o)).subscribe(u=>{s({type:"[session.transport.webrtc] answer-sent",peerId:u.peerId}),e.sendAnswer(u.peerId,u.data).catch(l=>i.error("[signaling] Send failed:",Bb(l)))}),n.message$.pipe((0,_t.filter)(u=>u.type==="[session.transport.webrtc.peer] ice-candidate"),(0,_t.takeUntil)(o)).subscribe(u=>{let l=u.to,d=u.data?.candidate;s({type:"[session.transport.webrtc] ice-candidate-sent",peerId:l,candidate:d?.candidate});let f=a.get(l);f||(f={queue:[],flushing:!1},a.set(l,f)),f.queue.push(d),c(l)}),n.message$.pipe((0,_t.filter)(u=>u.type==="[session.transport.webrtc.peer] connected"),(0,_t.takeUntil)(o)).subscribe(u=>s({type:"[session.transport.webrtc] peer-connected",peerId:u.peerId})),n.message$.pipe((0,_t.filter)(u=>u.type==="[session.transport.webrtc.peer] data"),(0,_t.takeUntil)(o)).subscribe(u=>s({type:"[session.transport.webrtc] data",data:u.data,peerId:u.peerId})),n.message$.pipe((0,_t.filter)(u=>u.type==="[session.transport.webrtc.peer] error"),(0,_t.takeUntil)(o)).subscribe(u=>s({type:"[session.transport.webrtc] error",error:u.error,peerId:u.peerId})),n.message$.pipe((0,_t.filter)(u=>u.type==="[session.transport.webrtc.peer] close"),(0,_t.takeUntil)(o)).subscribe(u=>{r.dispose(u.peerId),a.delete(u.peerId),s({type:"[session.transport.webrtc] close",peerId:u.peerId})})}var FM=(()=>{class t{constructor(){this.logger=j("WebRTCSignalingHandler"),this.config=w(Oe),this.signaling=w(zh),this.peerListService=w(As),this.peer=w(ks),this.handshakeCoordinator=w(np),this.registry=new lp}get message$(){return this.signaling.message$}setupSignalingHandlers(e,r,i){let o={message$:this.message$,signaling:this.signaling,peerListService:this.peerListService,peer:this.peer,registry:this.registry,logger:this.logger,destroy$:r,dispatch:i,coordinator:this.handshakeCoordinator};kM(o),Fb({...o,myHashedId:e}),jb({...o,myHashedId:e}),qb({...o,config:this.config}),LM({...o,config:this.config}),r.pipe((0,jM.take)(1)).subscribe(()=>this.registry.disposeAll())}dispose(e){this.registry.dispose(e)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var Jt=U(Q(),1);var Ls=U(Q(),1);var Hb=j("AnnounceSchedulerService");function $M(t){let{roles:n,tag:e,sendAnnounce:r,onTick:i,authService:o}=t;i();try{let s=r(n);BM(s,qM).then(()=>{}).catch(async a=>{let c=a?.message||a;Hb.warn(`${e} Failed to send announce (network may be unavailable):`,c),String(c).includes("Socket closed")&&o&&(Hb.info(`${e} Attempting token refresh after socket closed`),await o.refreshIdToken())})}catch(s){Hb.error(`${e} sync error caught while invoking sendAnnounce`,s)}}var HM=new _e("AUTH_REFRESH_SERVICE"),qM=1e4,Ub=class extends Error{constructor(n){super(`sendAnnounce timed out after ${n}ms`),this.timeoutMs=n,this.name="SendAnnounceTimeoutError"}};function BM(t,n){let e,r=new Promise((i,o)=>{e=setTimeout(()=>o(new Ub(n)),n)});return Promise.race([t,r]).finally(()=>{e!==void 0&&clearTimeout(e)})}var UM=U(Q(),1),VM=U(Ni(),1);var fc=j("AnnounceSchedulerService");function WM(t){let{roles:n,intervalMs:e,destroy$:r,priorSubscription:i,fireAnnounce:o,reSubscribe:s}=t;fc.info("[signaling:announce] subscribeInterval ENTRY",{intervalMs:e,hadPriorSubscription:!!i}),i?.unsubscribe();let a=0;return(0,UM.interval)(e).pipe((0,VM.takeUntil)(r)).subscribe({next:()=>{a++,fc.info("[signaling:announce] interval TICK fired",{tickCount:a,intervalMs:e}),o(n),fc.info("[signaling:announce] interval TICK callback complete",{tickCount:a})},error:c=>{fc.error("[signaling:announce] interval subscription ERRORED, re-subscribing",{tickCount:a,error:c instanceof Error?{name:c.name,message:c.message,stack:c.stack}:c}),s()},complete:()=>{fc.info("[signaling:announce] interval subscription COMPLETED (takeUntil destroy$ fired)",{tickCount:a})}})}var GM=(()=>{class t{constructor(){this.signalingService=w(zh),this.configService=w(Oe),this.authService=w(HM,{optional:!0}),this.channels=w(fs,{optional:!0})??[],this.logger=j("AnnounceSchedulerService"),this.destroy$=new Ls.Subject,this._lastAnnounceAt=an(0),this.intervalSubscription=null,this.lastAnnounceAt=this._lastAnnounceAt.asReadonly()}async start(e){if(this.logger.info("[start] Starting with roles:",e),!this.configService.config().identity&&!this.configService.peerId()){this.logger.warn("[start] Identity not configured, skipping announce");return}let r=this.channels.filter(i=>i.isAvailable&&i.reconnect$).map(i=>i.reconnect$);if(r.length>0){this.logger.info("[start] presence channels detected, reconnect-driven mode",{channels:this.channels.filter(i=>i.reconnect$).map(i=>i.name)}),(0,Ls.merge)(...r).pipe((0,Ls.takeUntil)(this.destroy$)).subscribe(()=>this.fireAnnounce(e,"[presence]"));return}this.fireAnnounce(e,"[start]"),this.subscribeIntervalHelper(e,3e4)}stop(){this.logger.info("[stop] Stopping scheduler"),this.destroy$.next(),this.intervalSubscription?.unsubscribe(),this.intervalSubscription=null}ngOnDestroy(){this.stop(),this.destroy$.complete()}subscribeIntervalHelper(e,r){this.intervalSubscription=WM({roles:e,intervalMs:r,destroy$:this.destroy$,priorSubscription:this.intervalSubscription,fireAnnounce:i=>this.fireAnnounce(i,"[interval]"),reSubscribe:()=>(this.subscribeIntervalHelper(e,r),this.intervalSubscription)})}fireAnnounce(e,r){$M({roles:e,tag:r,sendAnnounce:i=>this.signalingService.sendAnnounce(i),onTick:()=>this._lastAnnounceAt.set(Date.now()),authService:this.authService})}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var zM=(()=>{class t{constructor(){this.config=w(Oe),this.peerListService=w(As),this.announceScheduler=w(GM),this.peer=w(ks),this.signalingHandler=w(FM),this.logger=j("WebRTCCoreService"),this.myHashedId=null,this.destroy$=new Jt.ReplaySubject(1),this.message$=new Jt.ReplaySubject(1),this.peerId=dt(()=>this.config.peerId()),this.started=!1,this.peerIds$=this.peerListService.peers$.pipe((0,Jt.map)(e=>Array.from(e.keys())),(0,Jt.distinctUntilChanged)((e,r)=>JSON.stringify(e)===JSON.stringify(r)),(0,Jt.shareReplay)({bufferSize:1,refCount:!0})),this.peers$=this.peerListService.peers$.pipe((0,Jt.map)(e=>Array.from(e.values())),(0,Jt.shareReplay)({bufferSize:1,refCount:!0}))}async start(){this.started||(this.started=!0,this.myHashedId=this.config.signalingId(),await this.announceScheduler.start(this.config.config().roles),this.signalingHandler.setupSignalingHandlers(this.myHashedId,this.destroy$,e=>this.dispatch(e)))}dispatch(e){this.message$.next(e)}async connect(e){await this.peer.connect(e,!0)}async disconnect(e){await this.peer.disconnectAndAwait(e)}async close(){this.destroy$.next(),this.destroy$.complete(),this.destroy$=new Jt.ReplaySubject(1),this.started=!1,this.announceScheduler.stop(),this.peerListService.clear(),await this.peer.dispose()}send(e,r){this.peer.send(e,r)}broadcast(e){for(let r of this.peer.getConnectedPeerIds())this.send(r,e)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var ne=U(Q(),1);var Et=U(Q(),1);var NJ=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;function dp(t){return NJ.test(t)}var KM=1e4,fp=class{constructor(n,e){this.peerList=n,this.config=e,this.logger=j("ConnectionIdResolver"),this.idMap=new rp,this.activeKeys=new Set,this.immediateCache=new Map}cacheMapping(n,e){this.idMap.set(n,e)}lockActiveKey(n){this.activeKeys.add(n)}releaseActiveKey(n){this.activeKeys.delete(n)}hasActiveKey(n){return this.activeKeys.has(n)}forgetPeer(n){this.activeKeys.delete(n),this.idMap.deleteByKey(n),this.idMap.deleteByValue(n),this.immediateCache.delete(n)}tryResolveSync(n){return this.tryImmediate(n)??(dp(n)?void 0:n)}resolve$(n,e=KM){return(0,Et.defer)(()=>{let r=this.tryImmediate(n);return r!==void 0?(0,Et.of)(r):dp(n)?(this.logger.info("[ConnectionIdResolver] waiting peerList:",{peerId:n}),this.waitInPeerList(n).pipe((0,Et.timeout)(e),(0,Et.map)(i=>(this.cacheMapping(n,i),i)))):(0,Et.of)(n)})}resolve(n,e=KM){return new Promise((r,i)=>{this.resolve$(n,e).pipe((0,Et.take)(1)).subscribe({next:r,error:()=>i(new Error(`[ConnectionIdResolver] Failed to resolve publicKey for peerId: ${n}`))})})}resolveUuid(n){if(dp(n))return n;let e=this.idMap.getByValue(n);if(e)return e;let r=this.peerList.getPeerByPublicKey(n);if(r?.id)return this.cacheMapping(r.id,n),r.id;let i=this.config.config()?.identity?.peers??{};for(let[o,s]of Object.entries(i))if(s===n)return this.cacheMapping(o,n),o;throw new Error(`[ConnectionIdResolver] peerId \u3092 UUID \u7A7A\u9593\u306B\u89E3\u6C7A\u3067\u304D\u307E\u305B\u3093 (publicKey \u7D20\u901A\u3057\u7981\u6B62): ${n.slice(0,24)}\u2026 \u2014 peerList / identity.peers \u306B\u672A\u767B\u9332\u306E peer \u3067\u3059`)}tryImmediate(n){let e=this.immediateCache.get(n);if(e!==void 0)return e;let r;if(this.activeKeys.has(n)){let i=this.idMap.getByKey(n);i&&(r=i)}if(r===void 0){let i=this.peerList.getPeer(n);i?.publicKey&&(this.cacheMapping(n,i.publicKey),r=i.publicKey)}if(r===void 0){let i=this.idMap.getByKey(n);i&&(r=i)}if(r===void 0){let i=this.config.config()?.identity?.peers?.[n];i&&(this.cacheMapping(n,i),r=i)}return r!==void 0&&this.immediateCache.set(n,r),r}waitInPeerList(n){return this.peerList.peers$.pipe((0,Et.map)(e=>e.get(n)?.publicKey),(0,Et.filter)(e=>!!e),(0,Et.take)(1))}};var Qr=U(Q(),1),hp=class{constructor(){this.ready$$=new Qr.BehaviorSubject(new Set),this.maxMessageSizes=new Map,this.deadPeers=new Set,this.peerDead$$=new Qr.Subject,this.ready$=this.ready$$.asObservable(),this.peerDead$=this.peerDead$$.asObservable()}isReady(n){return this.ready$$.value.has(n)}observeReady(n){return this.ready$.pipe((0,Qr.map)(e=>e.has(n)),(0,Qr.distinctUntilChanged)())}markReady(n){if(this.deadPeers.delete(n),this.ready$$.value.has(n))return;let e=new Set(this.ready$$.value);e.add(n),this.ready$$.next(e)}unmarkReady(n){if(!this.ready$$.value.has(n))return;let e=new Set(this.ready$$.value);e.delete(n),this.ready$$.next(e)}setMaxMessageSize(n,e){this.maxMessageSizes.set(n,e)}getMaxMessageSize(n){return this.maxMessageSizes.get(n)}unsetMaxMessageSize(n){this.maxMessageSizes.delete(n)}forgetPeer(n){this.unmarkReady(n),this.unsetMaxMessageSize(n)}markDead(n,e){this.deadPeers.has(n)||(this.deadPeers.add(n),this.forgetPeer(n),this.peerDead$$.next({peerId:n,reason:e}))}};var js=U(Q(),1);function YM(t){let{webrtc:n,resolver:e,state:r,message$:i,selfPeerId:o,log:s,onPeerInvalidated:a}=t;n.message$.pipe((0,js.filter)(u=>u.type==="[session.transport.webrtc] data")).subscribe(u=>{let l=u.data,d=u.peerId;s("webrtc data",{peerId:d,dataType:l?.type}),l?.from&&l.from!==d&&e.cacheMapping(l.from,d);let f=e.resolveUuid(d);l?.type==="[session.transport] ready"&&l?.peerId&&r.markReady(f),i.next({...l,peerId:f})}),n.message$.pipe((0,js.filter)(u=>u.type==="[session.transport.webrtc] peer-connected")).subscribe(u=>n.send(u.peerId,{type:"[session.transport] ready",peerId:o()})),n.message$.pipe((0,js.filter)(u=>u.type==="[session.transport.webrtc] error")).subscribe(u=>{let l=u,d=e.resolveUuid(l.peerId);c(d,l.peerId),i.next({type:"[session.transport] error",error:l.error,peerId:d})}),n.message$.pipe((0,js.filter)(u=>u.type==="[session.transport.webrtc] sdp-caps-received")).subscribe(u=>{let l=u;r.setMaxMessageSize(l.peerId,l.maxMessageSize)}),n.message$.pipe((0,js.filter)(u=>u.type==="[session.transport.webrtc] close")).subscribe(u=>{let l=u.peerId,d=e.resolveUuid(l);c(d,l),i.next({type:"[session.transport] close",peerId:d})});function c(u,l){r.forgetPeer(u),l!==u&&r.forgetPeer(l),e.forgetPeer(u),l!==u&&e.forgetPeer(l),a?.(u),l!==u&&a?.(l)}}var PJ=j("peer-dead-aggregation");function ZM(t){let{state:n,channelManager:e,heartbeatCoordinator:r,peerService:i}=t;e.unhealthy$.subscribe(({peerId:o,reason:s})=>{s==="create-failed"&&i.disconnect(o)}),r.silentFail$.subscribe(({peerId:o})=>{n.markDead(o,"heartbeat-timeout")}),i.recoveryExhausted$.subscribe(({peerId:o})=>{n.markDead(o,"recovery-exhausted")}),e.connectionStateChanged$.subscribe(({peerId:o,state:s})=>{s==="failed"?n.markDead(o,"pc-failed"):s==="closed"&&n.markDead(o,"pc-closed")}),e.peerUnhealthy$.subscribe(({peerId:o})=>{let s=e.getLastPeerState(o),a=e.getPeerChannels(o),c=a?Object.fromEntries([...a].map(([u,l])=>[u,l.readyState])):void 0;PJ.warn("[isZombie] sctp-stall \u691C\u77E5 \u2014 3\u968E\u5C64\u306E state \u98DF\u3044\u9055\u3044\u3092\u8A18\u9332",{peerId:o,conn:s?.conn,ice:s?.ice,sctp:s?.sctp,dtls:s?.dtls,idleMs:s?.idleMs,channelReadyStates:c}),n.markDead(o,"sctp-stall")})}function QM(t){let{resolver:n,state:e,channelManager:r,channelSent$:i}=t;return{tryConnectionIdSync(o){return n.tryResolveSync(o)},bufferedAmountSync(o,s){let a=n.tryResolveSync(o);if(a!==void 0)return r.getBufferedAmount(a,s)},sendToChannelSync(o,s,a){let c=n.tryResolveSync(o);if(c===void 0)return!1;let u=r.send(c,s,a);return u&&i.next({peerId:o,label:s,bytes:typeof a=="string"?a.length:a.byteLength}),u},getRemoteMaxMessageSizeSync(o){let s=n.tryResolveSync(o);if(s!==void 0)return e.getMaxMessageSize(s)}}}var pp=class{constructor(n,e){this.peerId=n,this.ctx=e,this.invalidated=!1}invalidate(){this.invalidated=!0,this.cidPromise=void 0}ensureFresh(){if(this.invalidated)throw new Error(`[PeerHandle] stale handle for peer=${this.peerId.substring(0,16)} (peer disconnected). Re-acquire via transport.peerOf().`)}isReady(){return this.invalidated?!1:this.ctx.state.isReady(this.peerId)||this.ctx.resolver.hasActiveKey(this.peerId)}cid(){if(this.ensureFresh(),!this.cidPromise){let n=this.ctx.resolver.tryResolveSync(this.peerId);this.cidPromise=n!==void 0?Promise.resolve(n):this.ctx.resolver.resolve(this.peerId)}return this.cidPromise}async send(n){this.ctx.sent$.next({type:"[session.transport] data",peerId:this.peerId,data:n}),this.ctx.webrtc.send(await this.cid(),{type:"[session.transport] data",peerId:this.ctx.config.peerId(),data:n})}async createChannel(n,e="reliable-ordered"){await this.ctx.channelManager.createChannelAsync(await this.cid(),n,e)}async closeChannel(n){this.ctx.channelManager.closeChannel(await this.cid(),n)}async hasChannel(n){return this.ctx.channelManager.hasChannel(await this.cid(),n)}async waitForChannelOpen(n,e=5e3){return this.ctx.channelManager.waitForOpen(await this.cid(),n,e)}async getRemoteMaxMessageSize(){return this.ctx.state.getMaxMessageSize(await this.cid())}};function JM(t){let n=new Map;return{peerOf(e){let r=n.get(e);return r||(r=new pp(e,t),n.set(e,r)),r},invalidate(e){let r=n.get(e);r&&r.invalidate(),n.delete(e)}}}var RJ="waitForPeerConnection timeout";function XM(t){let n=t?.message;return typeof n=="string"&&n.includes(RJ)}function eA(t){let n=new Map,e=i=>{n.set(i.peerId,Date.now())};t.channelOpened$.subscribe(e),t.channelMessage$.subscribe(e);let r=t.thresholdMs??3e3;return{isRecentlyActive:(i,o=Date.now())=>o-(n.get(i)??Number.NEGATIVE_INFINITY)<r}}var Vb={control:{high:8192,low:4096,drainTimeoutMs:100,chunkSize:8192},terminal:{high:262144,low:65536,drainTimeoutMs:500,chunkSize:16384},http:{high:1048576,low:262144,drainTimeoutMs:500,chunkSize:16384},bulk:{high:4194304,low:1048576,drainTimeoutMs:1e3,chunkSize:16384}};var St=class t extends Error{constructor(n,e,r,i,o){super(`transport send failed: code=${n} peer=${e} label=${r} offset=${i}`,o),this.code=n,this.peerId=e,this.label=r,this.offset=i,Object.setPrototypeOf(this,t.prototype),this.name="TransportSendError"}toJSON(){return{name:this.name,code:this.code,peerId:this.peerId,label:this.label,offset:this.offset,message:this.message}}};async function mp(t){let{channel:n,peerId:e,label:r,bytes:i,profile:o,boundary:s,signal:a,flushToEmpty:c}=t;if(i.byteLength===0)return;if(!n||n.readyState!=="open")throw new St("not_open",e,r,0);if(a?.aborted)throw new St("aborted",e,r,0);if(i.byteLength<=o.chunkSize&&n.bufferedAmount<=o.high){try{n.send(i)}catch(d){throw new St("channel_closed",e,r,0,{cause:d})}c&&await nA(n,a,e,r,i.byteLength);return}let u=0,l=i;for(await tA(n,o,a,e,r,u);l.byteLength>0;){if(a?.aborted)throw new St("aborted",e,r,u);if(n.readyState!=="open")throw new St("channel_closed",e,r,u);let{head:d,tail:f}=LJ(l,o.chunkSize,s);try{n.send(d)}catch(p){throw new St("channel_closed",e,r,u,{cause:p})}u+=d.byteLength,l=f,l.byteLength>0&&await tA(n,o,a,e,r,u)}c&&await nA(n,a,e,r,u)}function LJ(t,n,e){return e?e.split(t,n):t.byteLength<=n?{head:t,tail:FJ()}:{head:t.subarray(0,n),tail:t.subarray(n)}}var jJ=new Uint8Array(0);function FJ(){return jJ}var $J=500;async function tA(t,n,e,r,i,o){t.bufferedAmount<=n.high||(t.bufferedAmountLowThreshold=n.low,await rA(t,e,r,i,o,()=>t.bufferedAmount<=n.low))}var qJ=1e4;async function nA(t,n,e,r,i){t.bufferedAmount!==0&&(t.bufferedAmountLowThreshold=0,await rA(t,n,e,r,i,()=>t.bufferedAmount===0,qJ))}async function rA(t,n,e,r,i,o,s){let a=t.bufferedAmount,c=s!=null?Date.now()+s:null;for(;!o();){if(n?.aborted)throw new St("aborted",e,r,i);if(t.readyState!=="open")throw new St("channel_closed",e,r,i);if(c!=null){let u=t.bufferedAmount;if(u<a)a=u,c=Date.now()+s;else if(Date.now()>=c)return}await BJ(t,n,$J)}}function BJ(t,n,e){return new Promise(r=>{let i=null,o=null,s=()=>{a(),r()},a=()=>{t.removeEventListener("bufferedamountlow",s),i&&(clearTimeout(i),i=null),o&&n&&n.removeEventListener("abort",o)};t.addEventListener("bufferedamountlow",s),i=setTimeout(()=>{a(),r()},Math.max(1,e)),n&&(o=()=>{a(),r()},n.addEventListener("abort",o,{once:!0}))})}function Wb(t){let{resolver:n,channelManager:e,channelSendError$:r}=t,i=new Map,o=(s,a,c)=>{let u=`${s}:${a}`,d=(i.get(u)??Promise.resolve()).catch(()=>{}).then(c),f=d.catch(()=>{}).finally(()=>{i.get(u)===f&&i.delete(u)});return i.set(u,f),d};return{async send(s,a,c,u={}){let l=UJ(c);if(l.byteLength===0)return;let d=Vb[u.profile??VJ(a)];return o(s,a,async()=>{try{let f=n.tryResolveSync(s)??await n.resolve(s),p=e.getChannel(f,a);await mp({channel:p,peerId:s,label:a,bytes:l,profile:d,boundary:u.boundary,signal:u.signal,flushToEmpty:u.flushToEmpty})}catch(f){throw f instanceof St&&r.next({peerId:s,label:a,code:f.code,offset:f.offset}),f}})},mutexSize:()=>i.size}}var HJ=new TextEncoder;function UJ(t){return typeof t=="string"?HJ.encode(t):t instanceof Uint8Array?t:new Uint8Array(t)}function VJ(t){for(let n of Object.values(ps))if(n.parseLabel(t)!==null)return n.defaultBackpressureProfile;return"http"}var At=U(Q(),1);function iA(t,n){let e=r=>n(r);return(0,At.merge)(t.channelOpened$.pipe((0,At.map)(r=>({kind:"channel-opened",peerId:e(r.peerId),label:r.label}))),t.channelClosed$.pipe((0,At.map)(r=>({kind:"channel-closed",peerId:e(r.peerId),label:r.label,reason:r.reason,readyState:r.readyState}))),t.connectionStateChanged$.pipe((0,At.map)(r=>({kind:"connection-state",peerId:e(r.peerId),state:r.state}))),t.iceStateChanged$.pipe((0,At.map)(r=>({kind:"ice-state",peerId:e(r.peerId),state:r.state}))),t.message$.pipe((0,At.filter)(r=>r.type==="[session.transport] ready"||r.type==="[session.transport] data"),(0,At.map)(r=>r.type==="[session.transport] ready"?{kind:"ready",peerId:e(r.peerId)}:{kind:"data",peerId:e(r.peerId),data:r.data})),t.sent$.pipe((0,At.map)(r=>({kind:"sent",peerId:e(r.peerId),data:r.data}))),t.recoveryEvents$.pipe((0,At.map)(r=>({kind:"recovery",peerId:e(r.peerId),event:r.event,elapsedMs:r.elapsedMs}))),t.channelMessage$.pipe((0,At.map)(r=>({kind:"channel-message",peerId:e(r.peerId),label:r.label,bytes:r.data instanceof ArrayBuffer?r.data.byteLength:r.data.length}))),t.channelSent$.pipe((0,At.map)(r=>({kind:"channel-sent",peerId:e(r.peerId),label:r.label,bytes:r.bytes}))))}var Ce=(()=>{class t{peerOf(e){return this.handles.peerOf(e)}invalidatePeerHandle(e){this.handles.invalidate(e)}resolveUuid(e){return this.resolver.resolveUuid(e)}resolveExternalPeerId(e){return this.resolver.resolveUuid(e)}get peerState$(){return this.peerService.peerState$.pipe((0,ne.map)(this.remap))}constructor(){this.logger=SO("WebRTCService"),this.webrtc=w(zM),this.channelManager=w(Dt),this.message$=new ne.Subject,this.sent$=new ne.Subject,this.channelSent$=new ne.Subject,this.channelSendError$=new ne.ReplaySubject(1),this.config=w(Oe),this.peers$=this.webrtc.peers$.pipe((0,ne.tap)(e=>this.logger.info("[transport:peers] TS.peers$ emit",{peers:e.length}))),this.peerService=w(ks),this.peer=this.peerService,this.peerList=w(As),this.heartbeatCoordinator=w(ip),this.state=new hp,this.resolver=new fp(this.peerList,this.config),this.ctx={resolver:this.resolver,state:this.state,webrtc:this.webrtc,channelManager:this.channelManager,config:this.config,sent$:this.sent$,channelSent$:this.channelSent$},this.handles=JM(this.ctx),this.remap=e=>({...e,peerId:this.resolver.resolveUuid(e.peerId)}),this.channelOpened$=this.channelManager.channelOpened$.pipe((0,ne.map)(this.remap)),this.channelClosed$=this.channelManager.channelClosed$.pipe((0,ne.map)(this.remap)),this.channelMessage$=this.channelManager.channelMessage$.pipe((0,ne.map)(this.remap),(0,ne.share)()),this.connectionStateChanged$=this.channelManager.connectionStateChanged$.pipe((0,ne.map)(this.remap)),this.iceStateChanged$=this.channelManager.iceStateChanged$.pipe((0,ne.map)(this.remap)),this.peerUnhealthy$=this.channelManager.peerUnhealthy$.pipe((0,ne.map)(this.remap)),this.peerDead$=this.state.peerDead$.pipe((0,ne.map)(this.remap)),this.recoveryEvents$=(this.peerService.recoveryEvents$??ne.EMPTY).pipe((0,ne.map)(this.remap)),this.transportEvents$=iA({channelOpened$:this.channelManager.channelOpened$,channelClosed$:this.channelManager.channelClosed$,connectionStateChanged$:this.channelManager.connectionStateChanged$,iceStateChanged$:this.channelManager.iceStateChanged$,message$:this.message$,sent$:this.sent$,recoveryEvents$:this.peerService.recoveryEvents$??ne.EMPTY,channelMessage$:this.channelMessage$,channelSent$:this.channelSent$},e=>this.resolver.resolveUuid(e)),this.sync=QM({resolver:this.resolver,state:this.state,channelManager:this.channelManager,channelSent$:this.channelSent$}),this.channelSendOrch=Wb({resolver:this.resolver,channelManager:this.channelManager,channelSendError$:this.channelSendError$}),this.channelStuckReconnects=new Map,this.peerActivity=eA({channelOpened$:this.channelManager.channelOpened$,channelMessage$:this.channelManager.channelMessage$}),YM({webrtc:this.webrtc,resolver:this.resolver,state:this.state,message$:this.message$,selfPeerId:()=>this.config.peerId(),log:(e,r)=>this.logger.debug(`[transport] ${e}`,r??{}),onPeerInvalidated:e=>this.invalidatePeerHandle(e)}),ZM({state:this.state,channelManager:this.channelManager,heartbeatCoordinator:this.heartbeatCoordinator,peerService:this.peerService}),this.channelSendError$.subscribe(e=>this.logger.warn("transport channelSend failed",e))}async connect(e,r={timeout:3e4}){this.logger.info("[transport:connect] TS.connect entry",{peerId:e}),await(0,ne.firstValueFrom)(this.resolver.resolve$(e).pipe((0,ne.switchMap)(async i=>{this.logger.info("[transport:connect] TS resolver.resolve",{connectionId:i}),this.resolver.lockActiveKey(e),e!==i&&this.resolver.cacheMapping(e,i),this.logger.info("[transport:connect] TS webrtc.connect pre",{cid:i}),await this.webrtc.connect(i),e!==i&&this.state.isReady(i)&&this.state.markReady(e)}),(0,ne.switchMap)(()=>{this.logger.info("[transport:connect] TS observeReady await",{peer:e});let i=this.resolver.resolveUuid(e);return(i!==e?(0,ne.merge)(this.state.observeReady(e),this.state.observeReady(i)):this.state.observeReady(e)).pipe((0,ne.filter)(s=>s),(0,ne.take)(1))}),(0,ne.timeout)(r.timeout)))}async waitForPeerReady(e,r={timeout:1e4}){await(0,ne.firstValueFrom)(this.state.observeReady(e).pipe((0,ne.filter)(i=>i),(0,ne.take)(1),(0,ne.timeout)(r.timeout)))}async start(){this.logger.info("[transport:start] TS.start() entry"),await this.webrtc.start(),this.logger.info("[transport:start] webrtc.start done")}async stop(){return this.webrtc.close()}async disconnect(){this.stop()}disconnectPeer(e){this.peerService.disconnect(e)}async getWebRTCConfig(){return this.config.config()}async setWebRTCConfig(e){this.config.config.set(e)}async updateWebRTCConfig(e){this.config.config.update(r=>{let i=e(r);return console.warn(`[transport:config] WebRTCService.updateWebRTCConfig instanceId=${this.config._diagInstanceId} prevPeersCount=${Object.keys(r?.identity?.peers??{}).length} nextAllowPeersCount=${(i?.allowPeersPublicKeys??[]).length} nextHasIdentity=${!!i?.identity}`),i?.identity&&r?.identity?.peers&&(i.identity={...i.identity,peers:{...r.identity.peers,...i.identity.peers??{}}}),i?.identity&&r?.identity?.peersMeta&&(i.identity={...i.identity,peersMeta:{...r.identity.peersMeta,...i.identity.peersMeta??{}}}),i})}send(e,r){return e===this.config.peerId()?(this.sent$.next({type:"[session.transport] data",peerId:e,data:r}),this.message$.next({type:"[session.transport] data",peerId:e,data:r}),Promise.resolve()):this.peerOf(e).send(r)}async broadcast(e){this.sent$.next({type:"[session.transport] data",peerId:this.config.peerId(),data:e}),this.webrtc.broadcast({type:"[session.transport] data",data:e,peerId:this.config.peerId()})}escalateChannelStuckReconnect(e,r,i){let o=this.resolver.tryResolveSync(e)??e,s=this.channelStuckReconnects.get(o);if(s)return this.logger.warn("[createChannel] joining in-flight stuck-channel reconnect (single-flight)",{peerId:e.substring(0,16),label:r}),s;this.logger.warn("[createChannel] channel open stuck, escalating to fresh peer connection",{peerId:e.substring(0,16),cid:o.substring(0,16),label:r,err:i?.message});let a=(async()=>{await this.webrtc.disconnect(o),await this.connect(e,{timeout:15e3})})();return this.channelStuckReconnects.set(o,a),a.finally(()=>{this.channelStuckReconnects.get(o)===a&&this.channelStuckReconnects.delete(o)}).catch(()=>{}),a}async createChannel(e,r,i="reliable-ordered"){if(e===this.config.peerId())return this.channelManager.registerInProcessChannel(e,r,i);try{await this.peerOf(e).createChannel(r,i)}catch(o){if(r.startsWith(ps.l7Qpack.prefix)||XM(o))throw o;let s=this.resolver.tryResolveSync(e)??e;if(this.peerActivity.isRecentlyActive(s))throw this.logger.warn("[createChannel] open failed but peer recently active \u2014 skipping escalation (congestion, not wedge)",{peerId:e.substring(0,16),label:r,err:o?.message}),o;await this.escalateChannelStuckReconnect(e,r,o),await this.peerOf(e).createChannel(r,i)}}closeChannel(e,r){return this.peerOf(e).closeChannel(r)}hasChannel(e,r){return e===this.config.peerId()?Promise.resolve(this.channelManager.hasChannel(e,r)):this.peerOf(e).hasChannel(r)}hasConnection(e){return this.peerOf(e).isReady()}waitForChannelOpen(e,r,i=5e3){return e===this.config.peerId()?this.channelManager.hasChannel(e,r)?Promise.resolve():(0,ne.firstValueFrom)(this.channelManager.channelOpened$.pipe((0,ne.filter)(o=>o.peerId===e&&o.label===r),(0,ne.map)(()=>{}),(0,ne.timeout)({each:i,with:()=>(0,ne.throwError)(()=>new Error(`waitForChannelOpen timeout (self in-process): ${e}/${r}`))}))):this.peerOf(e).waitForChannelOpen(r,i)}getRemoteMaxMessageSize(e){return this.peerOf(e).getRemoteMaxMessageSize()}channelSend(e,r,i,o){if(e===this.config.peerId()){let s=typeof i=="string"?i:i instanceof Uint8Array?WJ(i):i;return this.channelManager.sendInProcess(e,r,s,o?.senderClientId),Promise.resolve()}return this.channelSendOrch.send(e,r,i,o)}tryConnectionIdSync(e){return this.sync.tryConnectionIdSync(e)}bufferedAmountSync(e,r){return this.sync.bufferedAmountSync(e,r)}sendToChannelSync(e,r,i){return this.sync.sendToChannelSync(e,r,i)}getRemoteMaxMessageSizeSync(e){return this.sync.getRemoteMaxMessageSizeSync(e)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();function WJ(t){return t.byteOffset===0&&t.byteLength===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}(function(t){t.WEB_RTC_CONFIG=Bi})(Ce||(Ce={}));var GJ=q.object({urls:q.union([q.string(),q.array(q.string())]),username:q.string().optional(),credential:q.string().optional()}),zJ=q.enum(["daemon","cli-server","server","web-server","web-proxy","app"]),KJ=q.object({identity:q.object({peerId:q.string(),publicKey:q.string(),signalingId:q.string(),privateKey:q.string(),peers:q.record(q.string()),peersMeta:q.record(q.object({roles:q.array(q.enum(["client","server"])),name:q.string().optional()})).optional()}).optional(),iceServers:q.array(GJ).optional(),version:q.string().optional(),name:q.string().optional(),serverName:q.string().optional(),origin:zJ.optional(),roles:q.array(q.enum(["client","server"])).optional(),allowPeersPublicKeys:q.array(q.string()).optional(),allowPeersMode:q.enum(["unrestricted","restricted"]).optional(),peers:q.record(q.string()).optional(),peersMeta:q.record(q.object({roles:q.array(q.enum(["client","server"])),name:q.string().optional()})).optional()}),oA=yt({peerId:fe.query(async({ctx:t})=>t.injector.get(Oe).peerId()),publicKey:fe.query(async({ctx:t})=>t.injector.get(Oe).publicKey()),shortServerId:fe.query(async({ctx:t})=>t.injector.get(Oe).shortServerId()),getWebRTCConfig:fe.query(async({ctx:t})=>t.injector.get(Ce).getWebRTCConfig()),update:fe.input(KJ).mutation(async({ctx:t,input:n})=>{await t.injector.get(Ce).updateWebRTCConfig(r=>{let i={...r};return n.identity?i.identity={peerId:n.identity.peerId,publicKey:n.identity.publicKey,signalingId:n.identity.signalingId,privateKey:n.identity.privateKey,peers:{...r.identity?.peers??{},...n.identity.peers,...n.peers??{}},peersMeta:{...r.identity?.peersMeta??{},...n.identity.peersMeta??{},...n.peersMeta??{}}}:(n.peers||n.peersMeta)&&r.identity&&(i.identity={...r.identity,peers:{...r.identity.peers??{},...n.peers??{}},peersMeta:{...r.identity.peersMeta??{},...n.peersMeta??{}}}),n.iceServers&&(i.peerSessionOptions={...r.peerSessionOptions??{},config:{...r.peerSessionOptions?.config??{},iceServers:n.iceServers}}),n.version!==void 0&&(i.version=n.version),n.name!==void 0&&(i.name=n.name),n.serverName!==void 0&&(i.serverName=n.serverName),n.origin!==void 0&&(i.origin=n.origin),n.roles!==void 0&&(i.roles=n.roles),n.allowPeersPublicKeys&&(i.allowPeersPublicKeys=n.allowPeersPublicKeys),n.allowPeersMode!==void 0&&(i.allowPeersMode=n.allowPeersMode),i})})});var sA=yt({isInitialized:fe.query(({ctx:t})=>!!t.injector.get(Oe).config().identity),initialize:fe.mutation(()=>{}),waitForInitialization:fe.mutation(()=>{})});var aA=yt({send:fe.input(q.object({peerId:q.string(),message:q.unknown()})).mutation(async({ctx:t,input:n})=>(await t.injector.get(Ce).send(n.peerId,n.message),{success:!0})),broadcast:fe.input(q.object({message:q.unknown()})).mutation(async({ctx:t,input:n})=>(await t.injector.get(Ce).broadcast(n.message),{success:!0})),generateId:fe.query(async({ctx:t})=>t.injector.get(Oe).peerId()),subscribe:fe.subscription(({ctx:t})=>{let n=t.injector.get(Ce);return Zt(e=>{let r=n.message$.subscribe({next:i=>e.next(i),error:i=>e.error(i)});return()=>r.unsubscribe()})})});var cA=typeof process<"u"&&!!process.env?.PLANX_PROXY_DEBUG,uA=yt({send:fe.input(q.object({peerId:q.string(),data:q.unknown()})).mutation(async({ctx:t,input:n})=>{let e=t.injector.get(Ce);if(cA){let r=n.data?.type;console.log(`[messaging:send] peerId=${n.peerId.slice(0,12)} dataType=${String(r)}`)}await e.send(n.peerId,n.data)}),broadcast:fe.input(q.object({data:q.unknown()})).mutation(async({ctx:t,input:n})=>{await t.injector.get(Ce).broadcast(n.data)}),onMessage:fe.subscription(({ctx:t})=>{let n=t.injector.get(Ce);return Zt(e=>{let r=n.message$.subscribe({next:i=>{if(cA){let o=i;console.log(`[messaging:relay] type=${String(o?.type)} peerId=${String(o?.peerId).slice(0,12)} dataType=${String(o?.data?.type)}`)}e.next(i)},error:i=>e.error(i)});return()=>r.unsubscribe()})})});var hc=q.object({peerId:q.string(),label:q.string()});function YJ(t){if(t instanceof ArrayBuffer)return{data:Buffer.from(new Uint8Array(t)).toString("base64"),binary:!0};if(ArrayBuffer.isView(t)){let n=t;return{data:Buffer.from(n.buffer,n.byteOffset,n.byteLength).toString("base64"),binary:!0}}return{data:String(t),binary:!1}}function ZJ(t,n){if(!n)return t;let e=Buffer.from(t,"base64");return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}var lA=yt({create:fe.input(hc).mutation(async({ctx:t,input:n})=>{await t.injector.get(Ce).createChannel(n.peerId,n.label)}),close:fe.input(hc).mutation(async({ctx:t,input:n})=>{await t.injector.get(Ce).closeChannel(n.peerId,n.label)}),has:fe.input(hc).query(async({ctx:t,input:n})=>t.injector.get(Ce).hasChannel(n.peerId,n.label)),channelSend:fe.input(hc.extend({data:q.string(),binary:q.boolean().optional(),opts:q.object({profile:q.enum(["control","terminal","http","bulk"]).optional(),senderClientId:q.string().optional()}).optional()})).mutation(async({ctx:t,input:n})=>t.injector.get(Ce).channelSend(n.peerId,n.label,ZJ(n.data,n.binary),n.opts)),waitForOpen:fe.input(hc.extend({timeoutMs:q.number().optional()})).mutation(async({ctx:t,input:n})=>{await t.injector.get(Ce).waitForChannelOpen(n.peerId,n.label,n.timeoutMs)}),onOpened:fe.subscription(({ctx:t})=>{let n=t.injector.get(Ce);return Zt(e=>{let r=n.channelOpened$.subscribe({next:i=>e.next(i),error:i=>e.error(i)});return()=>r.unsubscribe()})}),onClosed:fe.subscription(({ctx:t})=>{let n=t.injector.get(Ce);return Zt(e=>{let r=n.channelClosed$.subscribe({next:i=>e.next(i),error:i=>e.error(i)});return()=>r.unsubscribe()})}),onMessage:fe.input(q.object({clientId:q.string().optional()}).optional()).subscription(({ctx:t,input:n})=>{let e=t.injector.get(Ce);return Zt(r=>{let i=e.channelMessage$.subscribe({next:o=>{let s=o;if(s.senderClientId!=null&&s.senderClientId===n?.clientId)return;let{data:a,binary:c}=YJ(s.data);r.next({peerId:s.peerId,label:s.label,data:a,binary:c})},error:o=>r.error(o)});return()=>i.unsubscribe()})})});var gp=U(Q(),1);var dA=yt({peers:fe.query(({ctx:t})=>{let n=t.injector.get(Ce);return(0,gp.firstValueFrom)(n.peers$.pipe((0,gp.take)(1)))}),onPeersChanged:fe.subscription(({ctx:t})=>{let n=t.injector.get(Ce);return Zt(e=>{let r=n.peers$.subscribe({next:i=>e.next(i),error:i=>e.error(i)});return()=>r.unsubscribe()})}),onConnectionStateChanged:fe.subscription(({ctx:t})=>{let n=t.injector.get(Ce);return Zt(e=>{let r=n.connectionStateChanged$.subscribe({next:i=>e.next(i),error:i=>e.error(i)});return()=>r.unsubscribe()})}),connect:fe.input(q.object({peerId:q.string(),timeout:q.number().default(3e4)})).mutation(async({ctx:t,input:n})=>{await t.injector.get(Ce).connect(n.peerId,{timeout:n.timeout})}),start:fe.mutation(async({ctx:t})=>{await t.injector.get(Ce).start()}),stop:fe.mutation(async({ctx:t})=>{await t.injector.get(Ce).stop()}),disconnect:fe.mutation(async({ctx:t})=>{await t.injector.get(Ce).disconnect()}),hasConnection:fe.input(q.object({peerId:q.string()})).query(async({ctx:t,input:n})=>t.injector.get(Ce).hasConnection(n.peerId))});var Gb=yt({health:rO,config:oA,key:sA,signaling:aA,messaging:uA,channel:lA,transport:dA});function fA(t){let{injector:n,enableLogger:e=!0}=t,r=new Y_;return e&&r.use("*",aD()),r.get("/health",i=>i.json({ok:!0,service:"transport"})),r.all("/trpc/*",i=>lb({endpoint:"/trpc",req:i.req.raw,router:Gb,createContext:()=>({injector:n})})),r.all("/*",i=>lb({endpoint:"",req:i.req.raw,router:Gb,createContext:()=>({injector:n})})),r}function hA(t,n){process.stdout.write(`{"service":"transport","port":${t},"pid":${n}}
17
+ `.trim();async function tO(t,n,e){try{let r=n.middlewares[t];return await r((0,Xe.default)((0,Xe.default)({},e),{},{meta:n.meta,input:e.input,next(o){var s;let a=o;return tO(t+1,n,(0,Xe.default)((0,Xe.default)({},e),{},{ctx:a?.ctx?(0,Xe.default)((0,Xe.default)({},e.ctx),a.ctx):e.ctx,input:a&&"input"in a?a.input:e.input,getRawInput:(s=a?.getRawInput)!==null&&s!==void 0?s:e.getRawInput}))}}))}catch(r){return{ok:!1,error:Yt(r),marker:J0}}}function YQ(t){async function n(e){if(!e||!("getRawInput"in e))throw new Error(KQ);let r=await tO(0,t,e);if(!r)throw new Ue({code:"INTERNAL_SERVER_ERROR",message:"No result from middlewares - did you forget to `return next()`?"});if(!r.ok)throw r.error;return r.data}return n._def=t,n.procedure=!0,n.meta=t.meta,n}var ws,Es,Ss,Z0=typeof window>"u"||"Deno"in window||((ws=globalThis.process)===null||ws===void 0||(ws=ws.env)===null||ws===void 0?void 0:ws.NODE_ENV)==="test"||!!(!((Es=globalThis.process)===null||Es===void 0||(Es=Es.env)===null||Es===void 0)&&Es.JEST_WORKER_ID)||!!(!((Ss=globalThis.process)===null||Ss===void 0||(Ss=Ss.env)===null||Ss===void 0)&&Ss.VITEST_WORKER_ID),Q0=Se(Ut(),1),ZQ=class fb{context(){return new fb}meta(){return new fb}create(n){var e,r,i,o,s,a;let c=(0,Q0.default)((0,Q0.default)({},n),{},{transformer:E0((e=n?.transformer)!==null&&e!==void 0?e:_s),isDev:(r=n?.isDev)!==null&&r!==void 0?r:((i=globalThis.process)===null||i===void 0?void 0:i.env.NODE_ENV)!=="production",allowOutsideOfServer:(o=n?.allowOutsideOfServer)!==null&&o!==void 0?o:!1,errorFormatter:(s=n?.errorFormatter)!==null&&s!==void 0?s:vs,isServer:(a=n?.isServer)!==null&&a!==void 0?a:Z0,$types:null});{var u;if(!((u=n?.isServer)!==null&&u!==void 0?u:Z0)&&n?.allowOutsideOfServer!==!0)throw new Error("You're trying to use @trpc/server in a non-server environment. This is not supported by default.")}return{_config:c,procedure:eO({meta:n?.defaultMeta}),middleware:qQ(),router:Z_(c),mergeRouters:S0,createCallerFactory:Q_()}}},hb=new ZQ;var nO=hb.context().create({allowOutsideOfServer:!0}),yt=nO.router,fe=nO.procedure;var rO=yt({ping:fe.query(()=>({status:"ok",timestamp:Date.now()}))});var q={};FR(q,{BRAND:()=>E7,DIRTY:()=>$i,EMPTY_PATH:()=>e7,INVALID:()=>J,NEVER:()=>sJ,OK:()=>vt,ParseStatus:()=>ht,Schema:()=>de,ZodAny:()=>Lh,ZodArray:()=>ic,ZodBigInt:()=>yb,ZodBoolean:()=>vb,ZodBranded:()=>oc,ZodCatch:()=>Db,ZodDate:()=>_b,ZodDefault:()=>xb,ZodDiscriminatedUnion:()=>jh,ZodEffects:()=>Os,ZodEnum:()=>Bh,ZodError:()=>xn,ZodFirstPartyTypeKind:()=>te,ZodFunction:()=>$h,ZodIntersection:()=>Sb,ZodIssueCode:()=>I,ZodLazy:()=>Cb,ZodLiteral:()=>Ib,ZodMap:()=>hO,ZodNaN:()=>gO,ZodNativeEnum:()=>Tb,ZodNever:()=>qi,ZodNull:()=>wb,ZodNullable:()=>Ms,ZodNumber:()=>gb,ZodObject:()=>xs,ZodOptional:()=>Gr,ZodParsedType:()=>F,ZodPipeline:()=>sc,ZodPromise:()=>Hh,ZodReadonly:()=>Ob,ZodRecord:()=>Fh,ZodSchema:()=>de,ZodSet:()=>pO,ZodString:()=>qh,ZodSymbol:()=>dO,ZodTransformer:()=>Os,ZodTuple:()=>Ds,ZodType:()=>de,ZodUndefined:()=>bb,ZodUnion:()=>Eb,ZodUnknown:()=>rc,ZodVoid:()=>fO,addIssueToContext:()=>R,any:()=>A7,array:()=>k7,bigint:()=>T7,boolean:()=>bO,coerce:()=>oJ,custom:()=>yO,date:()=>x7,datetimeRegex:()=>lO,defaultErrorMap:()=>Kn,discriminatedUnion:()=>$7,effect:()=>Q7,enum:()=>K7,function:()=>W7,getErrorMap:()=>Cs,getParsedType:()=>Tn,instanceof:()=>C7,intersection:()=>q7,isAborted:()=>Rh,isAsync:()=>Is,isDirty:()=>kh,isValid:()=>Wr,late:()=>S7,lazy:()=>G7,literal:()=>z7,makeIssue:()=>nc,map:()=>U7,nan:()=>I7,nativeEnum:()=>Y7,never:()=>P7,null:()=>M7,nullable:()=>X7,number:()=>_O,object:()=>L7,objectUtil:()=>iO,oboolean:()=>iJ,onumber:()=>rJ,optional:()=>J7,ostring:()=>nJ,pipeline:()=>tJ,preprocess:()=>eJ,promise:()=>Z7,quotelessJson:()=>QQ,record:()=>H7,set:()=>V7,setErrorMap:()=>XQ,strictObject:()=>j7,string:()=>vO,symbol:()=>D7,transformer:()=>Q7,tuple:()=>B7,undefined:()=>O7,union:()=>F7,unknown:()=>N7,util:()=>we,void:()=>R7});var we;(function(t){t.assertEqual=i=>{};function n(i){}t.assertIs=n;function e(i){throw new Error}t.assertNever=e,t.arrayToEnum=i=>{let o={};for(let s of i)o[s]=s;return o},t.getValidEnumValues=i=>{let o=t.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),s={};for(let a of o)s[a]=i[a];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(o){return i[o]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let o=[];for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&o.push(s);return o},t.find=(i,o)=>{for(let s of i)if(o(s))return s},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,o=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(o)}t.joinValues=r,t.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(we||(we={}));var iO=(function(t){return t.mergeShapes=(n,e)=>({...n,...e}),t})(iO||{}),F=we.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Tn=t=>{switch(typeof t){case"undefined":return F.undefined;case"string":return F.string;case"number":return Number.isNaN(t)?F.nan:F.number;case"boolean":return F.boolean;case"function":return F.function;case"bigint":return F.bigint;case"symbol":return F.symbol;case"object":return Array.isArray(t)?F.array:t===null?F.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?F.promise:typeof Map<"u"&&t instanceof Map?F.map:typeof Set<"u"&&t instanceof Set?F.set:typeof Date<"u"&&t instanceof Date?F.date:F.object;default:return F.unknown}};var I=we.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),QQ=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),xn=(()=>{class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(s){return s.message},i={_errors:[]},o=s=>{for(let a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(o);else if(a.code==="invalid_return_type")o(a.returnTypeError);else if(a.code==="invalid_arguments")o(a.argumentsError);else if(a.path.length===0)i._errors.push(r(a));else{let c=i,u=0;for(;u<a.path.length;){let l=a.path[u];u===a.path.length-1?(c[l]=c[l]||{_errors:[]},c[l]._errors.push(r(a))):c[l]=c[l]||{_errors:[]},c=c[l],u++}}};return o(this),i}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,we.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},i=[];for(let o of this.issues)if(o.path.length>0){let s=o.path[0];r[s]=r[s]||[],r[s].push(e(o))}else i.push(e(o));return{formErrors:i,fieldErrors:r}}get formErrors(){return this.flatten()}}return t.create=n=>new t(n),t})();var JQ=(t,n)=>{let e;switch(t.code){case I.invalid_type:t.received===F.undefined?e="Required":e=`Expected ${t.expected}, received ${t.received}`;break;case I.invalid_literal:e=`Invalid literal value, expected ${JSON.stringify(t.expected,we.jsonStringifyReplacer)}`;break;case I.unrecognized_keys:e=`Unrecognized key(s) in object: ${we.joinValues(t.keys,", ")}`;break;case I.invalid_union:e="Invalid input";break;case I.invalid_union_discriminator:e=`Invalid discriminator value. Expected ${we.joinValues(t.options)}`;break;case I.invalid_enum_value:e=`Invalid enum value. Expected ${we.joinValues(t.options)}, received '${t.received}'`;break;case I.invalid_arguments:e="Invalid function arguments";break;case I.invalid_return_type:e="Invalid function return type";break;case I.invalid_date:e="Invalid date";break;case I.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(e=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(e=`${e} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?e=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?e=`Invalid input: must end with "${t.validation.endsWith}"`:we.assertNever(t.validation):t.validation!=="regex"?e=`Invalid ${t.validation}`:e="Invalid";break;case I.too_small:t.type==="array"?e=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?e=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?e=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?e=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?e=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:e="Invalid input";break;case I.too_big:t.type==="array"?e=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?e=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?e=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?e=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?e=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:e="Invalid input";break;case I.custom:e="Invalid input";break;case I.invalid_intersection_types:e="Intersection results could not be merged";break;case I.not_multiple_of:e=`Number must be a multiple of ${t.multipleOf}`;break;case I.not_finite:e="Number must be finite";break;default:e=n.defaultError,we.assertNever(t)}return{message:e}},Kn=JQ;var oO=Kn;function XQ(t){oO=t}function Cs(){return oO}var nc=t=>{let{data:n,path:e,errorMaps:r,issueData:i}=t,o=[...e,...i.path||[]],s={...i,path:o};if(i.message!==void 0)return{...i,path:o,message:i.message};let a="",c=r.filter(u=>!!u).slice().reverse();for(let u of c)a=u(s,{data:n,defaultError:a}).message;return{...i,path:o,message:a}},e7=[];function R(t,n){let e=Cs(),r=nc({issueData:n,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,e,e===Kn?void 0:Kn].filter(i=>!!i)});t.common.issues.push(r)}var ht=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(n,e){let r=[];for(let i of e){if(i.status==="aborted")return J;i.status==="dirty"&&n.dirty(),r.push(i.value)}return{status:n.value,value:r}}static async mergeObjectAsync(n,e){let r=[];for(let i of e){let o=await i.key,s=await i.value;r.push({key:o,value:s})}return t.mergeObjectSync(n,r)}static mergeObjectSync(n,e){let r={};for(let i of e){let{key:o,value:s}=i;if(o.status==="aborted"||s.status==="aborted")return J;o.status==="dirty"&&n.dirty(),s.status==="dirty"&&n.dirty(),o.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(r[o.value]=s.value)}return{status:n.value,value:r}}},J=Object.freeze({status:"aborted"}),$i=t=>({status:"dirty",value:t}),vt=t=>({status:"valid",value:t}),Rh=t=>t.status==="aborted",kh=t=>t.status==="dirty",Wr=t=>t.status==="valid",Is=t=>typeof Promise<"u"&&t instanceof Promise;var W=(function(t){return t.errToObj=n=>typeof n=="string"?{message:n}:n||{},t.toString=n=>typeof n=="string"?n:n?.message,t})(W||{});var Qt=class{constructor(n,e,r,i){this._cachedPath=[],this.parent=n,this.data=e,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},sO=(t,n)=>{if(Wr(n))return{success:!0,data:n.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let e=new xn(t.common.issues);return this._error=e,this._error}}};function ae(t){if(!t)return{};let{errorMap:n,invalid_type_error:e,required_error:r,description:i}=t;if(n&&(e||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return n?{errorMap:n,description:i}:{errorMap:(s,a)=>{let{message:c}=t;return s.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??r??a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:c??e??a.defaultError}},description:i}}var de=class{get description(){return this._def.description}_getType(n){return Tn(n.data)}_getOrReturnCtx(n,e){return e||{common:n.parent.common,data:n.data,parsedType:Tn(n.data),schemaErrorMap:this._def.errorMap,path:n.path,parent:n.parent}}_processInputParams(n){return{status:new ht,ctx:{common:n.parent.common,data:n.data,parsedType:Tn(n.data),schemaErrorMap:this._def.errorMap,path:n.path,parent:n.parent}}}_parseSync(n){let e=this._parse(n);if(Is(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(n){let e=this._parse(n);return Promise.resolve(e)}parse(n,e){let r=this.safeParse(n,e);if(r.success)return r.data;throw r.error}safeParse(n,e){let r={common:{issues:[],async:e?.async??!1,contextualErrorMap:e?.errorMap},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:n,parsedType:Tn(n)},i=this._parseSync({data:n,path:r.path,parent:r});return sO(r,i)}"~validate"(n){let e={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:n,parsedType:Tn(n)};if(!this["~standard"].async)try{let r=this._parseSync({data:n,path:[],parent:e});return Wr(r)?{value:r.value}:{issues:e.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),e.common={issues:[],async:!0}}return this._parseAsync({data:n,path:[],parent:e}).then(r=>Wr(r)?{value:r.value}:{issues:e.common.issues})}async parseAsync(n,e){let r=await this.safeParseAsync(n,e);if(r.success)return r.data;throw r.error}async safeParseAsync(n,e){let r={common:{issues:[],contextualErrorMap:e?.errorMap,async:!0},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:n,parsedType:Tn(n)},i=this._parse({data:n,path:r.path,parent:r}),o=await(Is(i)?i:Promise.resolve(i));return sO(r,o)}refine(n,e){let r=i=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(i):e;return this._refinement((i,o)=>{let s=n(i),a=()=>o.addIssue({code:I.custom,...r(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(c=>c?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(n,e){return this._refinement((r,i)=>n(r)?!0:(i.addIssue(typeof e=="function"?e(r,i):e),!1))}_refinement(n){return new Os({schema:this,typeName:te.ZodEffects,effect:{type:"refinement",refinement:n}})}superRefine(n){return this._refinement(n)}constructor(n){this.spa=this.safeParseAsync,this._def=n,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Gr.create(this,this._def)}nullable(){return Ms.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ic.create(this)}promise(){return Hh.create(this,this._def)}or(n){return Eb.create([this,n],this._def)}and(n){return Sb.create(this,n,this._def)}transform(n){return new Os({...ae(this._def),schema:this,typeName:te.ZodEffects,effect:{type:"transform",transform:n}})}default(n){let e=typeof n=="function"?n:()=>n;return new xb({...ae(this._def),innerType:this,defaultValue:e,typeName:te.ZodDefault})}brand(){return new oc({typeName:te.ZodBranded,type:this,...ae(this._def)})}catch(n){let e=typeof n=="function"?n:()=>n;return new Db({...ae(this._def),innerType:this,catchValue:e,typeName:te.ZodCatch})}describe(n){let e=this.constructor;return new e({...this._def,description:n})}pipe(n){return sc.create(this,n)}readonly(){return Ob.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},t7=/^c[^\s-]{8,}$/i,n7=/^[0-9a-z]+$/,r7=/^[0-9A-HJKMNP-TV-Z]{26}$/i,i7=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,o7=/^[a-z0-9_-]{21}$/i,s7=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,a7=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,c7=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,u7="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",pb,l7=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,d7=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,f7=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,h7=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,p7=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,m7=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,cO="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",g7=new RegExp(`^${cO}$`);function uO(t){let n="[0-5]\\d";t.precision?n=`${n}\\.\\d{${t.precision}}`:t.precision==null&&(n=`${n}(\\.\\d+)?`);let e=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${n})${e}`}function y7(t){return new RegExp(`^${uO(t)}$`)}function lO(t){let n=`${cO}T${uO(t)}`,e=[];return e.push(t.local?"Z?":"Z"),t.offset&&e.push("([+-]\\d{2}:?\\d{2})"),n=`${n}(${e.join("|")})`,new RegExp(`^${n}$`)}function v7(t,n){return!!((n==="v4"||!n)&&l7.test(t)||(n==="v6"||!n)&&f7.test(t))}function _7(t,n){if(!s7.test(t))return!1;try{let[e]=t.split(".");if(!e)return!1;let r=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||n&&i.alg!==n)}catch{return!1}}function b7(t,n){return!!((n==="v4"||!n)&&d7.test(t)||(n==="v6"||!n)&&h7.test(t))}var qh=(()=>{class t extends de{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==F.string){let s=this._getOrReturnCtx(e);return R(s,{code:I.invalid_type,expected:F.string,received:s.parsedType}),J}let i=new ht,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),R(o,{code:I.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),i.dirty());else if(s.kind==="max")e.data.length>s.value&&(o=this._getOrReturnCtx(e,o),R(o,{code:I.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),i.dirty());else if(s.kind==="length"){let a=e.data.length>s.value,c=e.data.length<s.value;(a||c)&&(o=this._getOrReturnCtx(e,o),a?R(o,{code:I.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&R(o,{code:I.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),i.dirty())}else if(s.kind==="email")c7.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"email",code:I.invalid_string,message:s.message}),i.dirty());else if(s.kind==="emoji")pb||(pb=new RegExp(u7,"u")),pb.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"emoji",code:I.invalid_string,message:s.message}),i.dirty());else if(s.kind==="uuid")i7.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"uuid",code:I.invalid_string,message:s.message}),i.dirty());else if(s.kind==="nanoid")o7.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"nanoid",code:I.invalid_string,message:s.message}),i.dirty());else if(s.kind==="cuid")t7.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"cuid",code:I.invalid_string,message:s.message}),i.dirty());else if(s.kind==="cuid2")n7.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"cuid2",code:I.invalid_string,message:s.message}),i.dirty());else if(s.kind==="ulid")r7.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"ulid",code:I.invalid_string,message:s.message}),i.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),R(o,{validation:"url",code:I.invalid_string,message:s.message}),i.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"regex",code:I.invalid_string,message:s.message}),i.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(e,o),R(o,{code:I.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),i.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(o=this._getOrReturnCtx(e,o),R(o,{code:I.invalid_string,validation:{startsWith:s.value},message:s.message}),i.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),R(o,{code:I.invalid_string,validation:{endsWith:s.value},message:s.message}),i.dirty()):s.kind==="datetime"?lO(s).test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{code:I.invalid_string,validation:"datetime",message:s.message}),i.dirty()):s.kind==="date"?g7.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{code:I.invalid_string,validation:"date",message:s.message}),i.dirty()):s.kind==="time"?y7(s).test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{code:I.invalid_string,validation:"time",message:s.message}),i.dirty()):s.kind==="duration"?a7.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"duration",code:I.invalid_string,message:s.message}),i.dirty()):s.kind==="ip"?v7(e.data,s.version)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"ip",code:I.invalid_string,message:s.message}),i.dirty()):s.kind==="jwt"?_7(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"jwt",code:I.invalid_string,message:s.message}),i.dirty()):s.kind==="cidr"?b7(e.data,s.version)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"cidr",code:I.invalid_string,message:s.message}),i.dirty()):s.kind==="base64"?p7.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"base64",code:I.invalid_string,message:s.message}),i.dirty()):s.kind==="base64url"?m7.test(e.data)||(o=this._getOrReturnCtx(e,o),R(o,{validation:"base64url",code:I.invalid_string,message:s.message}),i.dirty()):we.assertNever(s);return{status:i.value,value:e.data}}_regex(e,r,i){return this.refinement(o=>e.test(o),{validation:r,code:I.invalid_string,...W.errToObj(i)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...W.errToObj(e)})}url(e){return this._addCheck({kind:"url",...W.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...W.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...W.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...W.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...W.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...W.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...W.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...W.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...W.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...W.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...W.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...W.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...W.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...W.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...W.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...W.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...W.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...W.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...W.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...W.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...W.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...W.errToObj(r)})}nonempty(e){return this.min(1,W.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}return t.create=n=>new t({checks:[],typeName:te.ZodString,coerce:n?.coerce??!1,...ae(n)}),t})();function w7(t,n){let e=(t.toString().split(".")[1]||"").length,r=(n.toString().split(".")[1]||"").length,i=e>r?e:r,o=Number.parseInt(t.toFixed(i).replace(".","")),s=Number.parseInt(n.toFixed(i).replace(".",""));return o%s/10**i}var gb=(()=>{class t extends de{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==F.number){let s=this._getOrReturnCtx(e);return R(s,{code:I.invalid_type,expected:F.number,received:s.parsedType}),J}let i,o=new ht;for(let s of this._def.checks)s.kind==="int"?we.isInteger(e.data)||(i=this._getOrReturnCtx(e,i),R(i,{code:I.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(i=this._getOrReturnCtx(e,i),R(i,{code:I.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(i=this._getOrReturnCtx(e,i),R(i,{code:I.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?w7(e.data,s.value)!==0&&(i=this._getOrReturnCtx(e,i),R(i,{code:I.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(i=this._getOrReturnCtx(e,i),R(i,{code:I.not_finite,message:s.message}),o.dirty()):we.assertNever(s);return{status:o.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,W.toString(r))}gt(e,r){return this.setLimit("min",e,!1,W.toString(r))}lte(e,r){return this.setLimit("max",e,!0,W.toString(r))}lt(e,r){return this.setLimit("max",e,!1,W.toString(r))}setLimit(e,r,i,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:i,message:W.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:W.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:W.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:W.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:W.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:W.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:W.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:W.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:W.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:W.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&we.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(r===null||i.value>r)&&(r=i.value):i.kind==="max"&&(e===null||i.value<e)&&(e=i.value)}return Number.isFinite(r)&&Number.isFinite(e)}}return t.create=n=>new t({checks:[],typeName:te.ZodNumber,coerce:n?.coerce||!1,...ae(n)}),t})(),yb=(()=>{class t extends de{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==F.bigint)return this._getInvalidInput(e);let i,o=new ht;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(i=this._getOrReturnCtx(e,i),R(i,{code:I.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(i=this._getOrReturnCtx(e,i),R(i,{code:I.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(i=this._getOrReturnCtx(e,i),R(i,{code:I.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):we.assertNever(s);return{status:o.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return R(r,{code:I.invalid_type,expected:F.bigint,received:r.parsedType}),J}gte(e,r){return this.setLimit("min",e,!0,W.toString(r))}gt(e,r){return this.setLimit("min",e,!1,W.toString(r))}lte(e,r){return this.setLimit("max",e,!0,W.toString(r))}lt(e,r){return this.setLimit("max",e,!1,W.toString(r))}setLimit(e,r,i,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:i,message:W.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:W.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:W.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:W.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:W.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:W.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}return t.create=n=>new t({checks:[],typeName:te.ZodBigInt,coerce:n?.coerce??!1,...ae(n)}),t})(),vb=(()=>{class t extends de{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==F.boolean){let i=this._getOrReturnCtx(e);return R(i,{code:I.invalid_type,expected:F.boolean,received:i.parsedType}),J}return vt(e.data)}}return t.create=n=>new t({typeName:te.ZodBoolean,coerce:n?.coerce||!1,...ae(n)}),t})(),_b=(()=>{class t extends de{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==F.date){let s=this._getOrReturnCtx(e);return R(s,{code:I.invalid_type,expected:F.date,received:s.parsedType}),J}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return R(s,{code:I.invalid_date}),J}let i=new ht,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),R(o,{code:I.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),i.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(o=this._getOrReturnCtx(e,o),R(o,{code:I.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),i.dirty()):we.assertNever(s);return{status:i.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:W.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:W.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}return t.create=n=>new t({checks:[],coerce:n?.coerce||!1,typeName:te.ZodDate,...ae(n)}),t})(),dO=(()=>{class t extends de{_parse(e){if(this._getType(e)!==F.symbol){let i=this._getOrReturnCtx(e);return R(i,{code:I.invalid_type,expected:F.symbol,received:i.parsedType}),J}return vt(e.data)}}return t.create=n=>new t({typeName:te.ZodSymbol,...ae(n)}),t})(),bb=(()=>{class t extends de{_parse(e){if(this._getType(e)!==F.undefined){let i=this._getOrReturnCtx(e);return R(i,{code:I.invalid_type,expected:F.undefined,received:i.parsedType}),J}return vt(e.data)}}return t.create=n=>new t({typeName:te.ZodUndefined,...ae(n)}),t})(),wb=(()=>{class t extends de{_parse(e){if(this._getType(e)!==F.null){let i=this._getOrReturnCtx(e);return R(i,{code:I.invalid_type,expected:F.null,received:i.parsedType}),J}return vt(e.data)}}return t.create=n=>new t({typeName:te.ZodNull,...ae(n)}),t})(),Lh=(()=>{class t extends de{constructor(){super(...arguments),this._any=!0}_parse(e){return vt(e.data)}}return t.create=n=>new t({typeName:te.ZodAny,...ae(n)}),t})(),rc=(()=>{class t extends de{constructor(){super(...arguments),this._unknown=!0}_parse(e){return vt(e.data)}}return t.create=n=>new t({typeName:te.ZodUnknown,...ae(n)}),t})(),qi=(()=>{class t extends de{_parse(e){let r=this._getOrReturnCtx(e);return R(r,{code:I.invalid_type,expected:F.never,received:r.parsedType}),J}}return t.create=n=>new t({typeName:te.ZodNever,...ae(n)}),t})(),fO=(()=>{class t extends de{_parse(e){if(this._getType(e)!==F.undefined){let i=this._getOrReturnCtx(e);return R(i,{code:I.invalid_type,expected:F.void,received:i.parsedType}),J}return vt(e.data)}}return t.create=n=>new t({typeName:te.ZodVoid,...ae(n)}),t})(),ic=(()=>{class t extends de{_parse(e){let{ctx:r,status:i}=this._processInputParams(e),o=this._def;if(r.parsedType!==F.array)return R(r,{code:I.invalid_type,expected:F.array,received:r.parsedType}),J;if(o.exactLength!==null){let a=r.data.length>o.exactLength.value,c=r.data.length<o.exactLength.value;(a||c)&&(R(r,{code:a?I.too_big:I.too_small,minimum:c?o.exactLength.value:void 0,maximum:a?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),i.dirty())}if(o.minLength!==null&&r.data.length<o.minLength.value&&(R(r,{code:I.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),i.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&(R(r,{code:I.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),i.dirty()),r.common.async)return Promise.all([...r.data].map((a,c)=>o.type._parseAsync(new Qt(r,a,r.path,c)))).then(a=>ht.mergeArray(i,a));let s=[...r.data].map((a,c)=>o.type._parseSync(new Qt(r,a,r.path,c)));return ht.mergeArray(i,s)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:W.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:W.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:W.toString(r)}})}nonempty(e){return this.min(1,e)}}return t.create=(n,e)=>new t({type:n,minLength:null,maxLength:null,exactLength:null,typeName:te.ZodArray,...ae(e)}),t})();function Ts(t){if(t instanceof xs){let n={};for(let e in t.shape){let r=t.shape[e];n[e]=Gr.create(Ts(r))}return new xs({...t._def,shape:()=>n})}else return t instanceof ic?new ic({...t._def,type:Ts(t.element)}):t instanceof Gr?Gr.create(Ts(t.unwrap())):t instanceof Ms?Ms.create(Ts(t.unwrap())):t instanceof Ds?Ds.create(t.items.map(n=>Ts(n))):t}var xs=(()=>{class t extends de{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=we.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==F.object){let l=this._getOrReturnCtx(e);return R(l,{code:I.invalid_type,expected:F.object,received:l.parsedType}),J}let{status:i,ctx:o}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),c=[];if(!(this._def.catchall instanceof qi&&this._def.unknownKeys==="strip"))for(let l in o.data)a.includes(l)||c.push(l);let u=[];for(let l of a){let d=s[l],f=o.data[l];u.push({key:{status:"valid",value:l},value:d._parse(new Qt(o,f,o.path,l)),alwaysSet:l in o.data})}if(this._def.catchall instanceof qi){let l=this._def.unknownKeys;if(l==="passthrough")for(let d of c)u.push({key:{status:"valid",value:d},value:{status:"valid",value:o.data[d]}});else if(l==="strict")c.length>0&&(R(o,{code:I.unrecognized_keys,keys:c}),i.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let d of c){let f=o.data[d];u.push({key:{status:"valid",value:d},value:l._parse(new Qt(o,f,o.path,d)),alwaysSet:d in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let l=[];for(let d of u){let f=await d.key,p=await d.value;l.push({key:f,value:p,alwaysSet:d.alwaysSet})}return l}).then(l=>ht.mergeObjectSync(i,l)):ht.mergeObjectSync(i,u)}get shape(){return this._def.shape()}strict(e){return W.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,i)=>{let o=this._def.errorMap?.(r,i).message??i.defaultError;return r.code==="unrecognized_keys"?{message:W.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:te.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let i of we.objectKeys(e))e[i]&&this.shape[i]&&(r[i]=this.shape[i]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let i of we.objectKeys(this.shape))e[i]||(r[i]=this.shape[i]);return new t({...this._def,shape:()=>r})}deepPartial(){return Ts(this)}partial(e){let r={};for(let i of we.objectKeys(this.shape)){let o=this.shape[i];e&&!e[i]?r[i]=o:r[i]=o.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let i of we.objectKeys(this.shape))if(e&&!e[i])r[i]=this.shape[i];else{let s=this.shape[i];for(;s instanceof Gr;)s=s._def.innerType;r[i]=s}return new t({...this._def,shape:()=>r})}keyof(){return mO(we.objectKeys(this.shape))}}return t.create=(n,e)=>new t({shape:()=>n,unknownKeys:"strip",catchall:qi.create(),typeName:te.ZodObject,...ae(e)}),t.strictCreate=(n,e)=>new t({shape:()=>n,unknownKeys:"strict",catchall:qi.create(),typeName:te.ZodObject,...ae(e)}),t.lazycreate=(n,e)=>new t({shape:n,unknownKeys:"strip",catchall:qi.create(),typeName:te.ZodObject,...ae(e)}),t})(),Eb=(()=>{class t extends de{_parse(e){let{ctx:r}=this._processInputParams(e),i=this._def.options;function o(s){for(let c of s)if(c.result.status==="valid")return c.result;for(let c of s)if(c.result.status==="dirty")return r.common.issues.push(...c.ctx.common.issues),c.result;let a=s.map(c=>new xn(c.ctx.common.issues));return R(r,{code:I.invalid_union,unionErrors:a}),J}if(r.common.async)return Promise.all(i.map(async s=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(o);{let s,a=[];for(let u of i){let l={...r,common:{...r.common,issues:[]},parent:null},d=u._parseSync({data:r.data,path:r.path,parent:l});if(d.status==="valid")return d;d.status==="dirty"&&!s&&(s={result:d,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let c=a.map(u=>new xn(u));return R(r,{code:I.invalid_union,unionErrors:c}),J}}get options(){return this._def.options}}return t.create=(n,e)=>new t({options:n,typeName:te.ZodUnion,...ae(e)}),t})(),Yn=t=>t instanceof Cb?Yn(t.schema):t instanceof Os?Yn(t.innerType()):t instanceof Ib?[t.value]:t instanceof Bh?t.options:t instanceof Tb?we.objectValues(t.enum):t instanceof xb?Yn(t._def.innerType):t instanceof bb?[void 0]:t instanceof wb?[null]:t instanceof Gr?[void 0,...Yn(t.unwrap())]:t instanceof Ms?[null,...Yn(t.unwrap())]:t instanceof oc||t instanceof Ob?Yn(t.unwrap()):t instanceof Db?Yn(t._def.innerType):[],jh=class t extends de{_parse(n){let{ctx:e}=this._processInputParams(n);if(e.parsedType!==F.object)return R(e,{code:I.invalid_type,expected:F.object,received:e.parsedType}),J;let r=this.discriminator,i=e.data[r],o=this.optionsMap.get(i);return o?e.common.async?o._parseAsync({data:e.data,path:e.path,parent:e}):o._parseSync({data:e.data,path:e.path,parent:e}):(R(e,{code:I.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),J)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(n,e,r){let i=new Map;for(let o of e){let s=Yn(o.shape[n]);if(!s.length)throw new Error(`A discriminator value for key \`${n}\` could not be extracted from all schema options`);for(let a of s){if(i.has(a))throw new Error(`Discriminator property ${String(n)} has duplicate value ${String(a)}`);i.set(a,o)}}return new t({typeName:te.ZodDiscriminatedUnion,discriminator:n,options:e,optionsMap:i,...ae(r)})}};function mb(t,n){let e=Tn(t),r=Tn(n);if(t===n)return{valid:!0,data:t};if(e===F.object&&r===F.object){let i=we.objectKeys(n),o=we.objectKeys(t).filter(a=>i.indexOf(a)!==-1),s={...t,...n};for(let a of o){let c=mb(t[a],n[a]);if(!c.valid)return{valid:!1};s[a]=c.data}return{valid:!0,data:s}}else if(e===F.array&&r===F.array){if(t.length!==n.length)return{valid:!1};let i=[];for(let o=0;o<t.length;o++){let s=t[o],a=n[o],c=mb(s,a);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return e===F.date&&r===F.date&&+t==+n?{valid:!0,data:t}:{valid:!1}}var Sb=(()=>{class t extends de{_parse(e){let{status:r,ctx:i}=this._processInputParams(e),o=(s,a)=>{if(Rh(s)||Rh(a))return J;let c=mb(s.value,a.value);return c.valid?((kh(s)||kh(a))&&r.dirty(),{status:r.value,value:c.data}):(R(i,{code:I.invalid_intersection_types}),J)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([s,a])=>o(s,a)):o(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}}return t.create=(n,e,r)=>new t({left:n,right:e,typeName:te.ZodIntersection,...ae(r)}),t})(),Ds=(()=>{class t extends de{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==F.array)return R(i,{code:I.invalid_type,expected:F.array,received:i.parsedType}),J;if(i.data.length<this._def.items.length)return R(i,{code:I.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),J;!this._def.rest&&i.data.length>this._def.items.length&&(R(i,{code:I.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let s=[...i.data].map((a,c)=>{let u=this._def.items[c]||this._def.rest;return u?u._parse(new Qt(i,a,i.path,c)):null}).filter(a=>!!a);return i.common.async?Promise.all(s).then(a=>ht.mergeArray(r,a)):ht.mergeArray(r,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}}return t.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new t({items:n,typeName:te.ZodTuple,rest:null,...ae(e)})},t})(),Fh=class t extends de{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(n){let{status:e,ctx:r}=this._processInputParams(n);if(r.parsedType!==F.object)return R(r,{code:I.invalid_type,expected:F.object,received:r.parsedType}),J;let i=[],o=this._def.keyType,s=this._def.valueType;for(let a in r.data)i.push({key:o._parse(new Qt(r,a,r.path,a)),value:s._parse(new Qt(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?ht.mergeObjectAsync(e,i):ht.mergeObjectSync(e,i)}get element(){return this._def.valueType}static create(n,e,r){return e instanceof de?new t({keyType:n,valueType:e,typeName:te.ZodRecord,...ae(r)}):new t({keyType:qh.create(),valueType:n,typeName:te.ZodRecord,...ae(e)})}},hO=(()=>{class t extends de{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==F.map)return R(i,{code:I.invalid_type,expected:F.map,received:i.parsedType}),J;let o=this._def.keyType,s=this._def.valueType,a=[...i.data.entries()].map(([c,u],l)=>({key:o._parse(new Qt(i,c,i.path,[l,"key"])),value:s._parse(new Qt(i,u,i.path,[l,"value"]))}));if(i.common.async){let c=new Map;return Promise.resolve().then(async()=>{for(let u of a){let l=await u.key,d=await u.value;if(l.status==="aborted"||d.status==="aborted")return J;(l.status==="dirty"||d.status==="dirty")&&r.dirty(),c.set(l.value,d.value)}return{status:r.value,value:c}})}else{let c=new Map;for(let u of a){let l=u.key,d=u.value;if(l.status==="aborted"||d.status==="aborted")return J;(l.status==="dirty"||d.status==="dirty")&&r.dirty(),c.set(l.value,d.value)}return{status:r.value,value:c}}}}return t.create=(n,e,r)=>new t({valueType:e,keyType:n,typeName:te.ZodMap,...ae(r)}),t})(),pO=(()=>{class t extends de{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==F.set)return R(i,{code:I.invalid_type,expected:F.set,received:i.parsedType}),J;let o=this._def;o.minSize!==null&&i.data.size<o.minSize.value&&(R(i,{code:I.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&i.data.size>o.maxSize.value&&(R(i,{code:I.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());let s=this._def.valueType;function a(u){let l=new Set;for(let d of u){if(d.status==="aborted")return J;d.status==="dirty"&&r.dirty(),l.add(d.value)}return{status:r.value,value:l}}let c=[...i.data.values()].map((u,l)=>s._parse(new Qt(i,u,i.path,l)));return i.common.async?Promise.all(c).then(u=>a(u)):a(c)}min(e,r){return new t({...this._def,minSize:{value:e,message:W.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:W.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}return t.create=(n,e)=>new t({valueType:n,minSize:null,maxSize:null,typeName:te.ZodSet,...ae(e)}),t})(),$h=class t extends de{constructor(){super(...arguments),this.validate=this.implement}_parse(n){let{ctx:e}=this._processInputParams(n);if(e.parsedType!==F.function)return R(e,{code:I.invalid_type,expected:F.function,received:e.parsedType}),J;function r(a,c){return nc({data:a,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,Cs(),Kn].filter(u=>!!u),issueData:{code:I.invalid_arguments,argumentsError:c}})}function i(a,c){return nc({data:a,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,Cs(),Kn].filter(u=>!!u),issueData:{code:I.invalid_return_type,returnTypeError:c}})}let o={errorMap:e.common.contextualErrorMap},s=e.data;if(this._def.returns instanceof Hh){let a=this;return vt(async function(...c){let u=new xn([]),l=await a._def.args.parseAsync(c,o).catch(p=>{throw u.addIssue(r(c,p)),u}),d=await Reflect.apply(s,this,l);return await a._def.returns._def.type.parseAsync(d,o).catch(p=>{throw u.addIssue(i(d,p)),u})})}else{let a=this;return vt(function(...c){let u=a._def.args.safeParse(c,o);if(!u.success)throw new xn([r(c,u.error)]);let l=Reflect.apply(s,this,u.data),d=a._def.returns.safeParse(l,o);if(!d.success)throw new xn([i(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...n){return new t({...this._def,args:Ds.create(n).rest(rc.create())})}returns(n){return new t({...this._def,returns:n})}implement(n){return this.parse(n)}strictImplement(n){return this.parse(n)}static create(n,e,r){return new t({args:n||Ds.create([]).rest(rc.create()),returns:e||rc.create(),typeName:te.ZodFunction,...ae(r)})}},Cb=(()=>{class t extends de{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}return t.create=(n,e)=>new t({getter:n,typeName:te.ZodLazy,...ae(e)}),t})(),Ib=(()=>{class t extends de{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return R(r,{received:r.data,code:I.invalid_literal,expected:this._def.value}),J}return{status:"valid",value:e.data}}get value(){return this._def.value}}return t.create=(n,e)=>new t({value:n,typeName:te.ZodLiteral,...ae(e)}),t})();function mO(t,n){return new Bh({values:t,typeName:te.ZodEnum,...ae(n)})}var Bh=(()=>{class t extends de{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),i=this._def.values;return R(r,{expected:we.joinValues(i),received:r.parsedType,code:I.invalid_type}),J}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),i=this._def.values;return R(r,{received:r.data,code:I.invalid_enum_value,options:i}),J}return vt(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(i=>!e.includes(i)),{...this._def,...r})}}return t.create=mO,t})(),Tb=(()=>{class t extends de{_parse(e){let r=we.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(e);if(i.parsedType!==F.string&&i.parsedType!==F.number){let o=we.objectValues(r);return R(i,{expected:we.joinValues(o),received:i.parsedType,code:I.invalid_type}),J}if(this._cache||(this._cache=new Set(we.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=we.objectValues(r);return R(i,{received:i.data,code:I.invalid_enum_value,options:o}),J}return vt(e.data)}get enum(){return this._def.values}}return t.create=(n,e)=>new t({values:n,typeName:te.ZodNativeEnum,...ae(e)}),t})(),Hh=(()=>{class t extends de{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==F.promise&&r.common.async===!1)return R(r,{code:I.invalid_type,expected:F.promise,received:r.parsedType}),J;let i=r.parsedType===F.promise?r.data:Promise.resolve(r.data);return vt(i.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}}return t.create=(n,e)=>new t({type:n,typeName:te.ZodPromise,...ae(e)}),t})(),Os=(()=>{class t extends de{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===te.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:i}=this._processInputParams(e),o=this._def.effect||null,s={addIssue:a=>{R(i,a),a.fatal?r.abort():r.dirty()},get path(){return i.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let a=o.transform(i.data,s);if(i.common.async)return Promise.resolve(a).then(async c=>{if(r.value==="aborted")return J;let u=await this._def.schema._parseAsync({data:c,path:i.path,parent:i});return u.status==="aborted"?J:u.status==="dirty"?$i(u.value):r.value==="dirty"?$i(u.value):u});{if(r.value==="aborted")return J;let c=this._def.schema._parseSync({data:a,path:i.path,parent:i});return c.status==="aborted"?J:c.status==="dirty"?$i(c.value):r.value==="dirty"?$i(c.value):c}}if(o.type==="refinement"){let a=c=>{let u=o.refinement(c,s);if(i.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(i.common.async===!1){let c=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return c.status==="aborted"?J:(c.status==="dirty"&&r.dirty(),a(c.value),{status:r.value,value:c.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(c=>c.status==="aborted"?J:(c.status==="dirty"&&r.dirty(),a(c.value).then(()=>({status:r.value,value:c.value}))))}if(o.type==="transform")if(i.common.async===!1){let a=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!Wr(a))return J;let c=o.transform(a.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:c}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(a=>Wr(a)?Promise.resolve(o.transform(a.value,s)).then(c=>({status:r.value,value:c})):J);we.assertNever(o)}}return t.create=(n,e,r)=>new t({schema:n,typeName:te.ZodEffects,effect:e,...ae(r)}),t.createWithPreprocess=(n,e,r)=>new t({schema:e,effect:{type:"preprocess",transform:n},typeName:te.ZodEffects,...ae(r)}),t})();var Gr=(()=>{class t extends de{_parse(e){return this._getType(e)===F.undefined?vt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}return t.create=(n,e)=>new t({innerType:n,typeName:te.ZodOptional,...ae(e)}),t})(),Ms=(()=>{class t extends de{_parse(e){return this._getType(e)===F.null?vt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}return t.create=(n,e)=>new t({innerType:n,typeName:te.ZodNullable,...ae(e)}),t})(),xb=(()=>{class t extends de{_parse(e){let{ctx:r}=this._processInputParams(e),i=r.data;return r.parsedType===F.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}return t.create=(n,e)=>new t({innerType:n,typeName:te.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ae(e)}),t})(),Db=(()=>{class t extends de{_parse(e){let{ctx:r}=this._processInputParams(e),i={...r,common:{...r.common,issues:[]}},o=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return Is(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new xn(i.common.issues)},input:i.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new xn(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}}return t.create=(n,e)=>new t({innerType:n,typeName:te.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ae(e)}),t})(),gO=(()=>{class t extends de{_parse(e){if(this._getType(e)!==F.nan){let i=this._getOrReturnCtx(e);return R(i,{code:I.invalid_type,expected:F.nan,received:i.parsedType}),J}return{status:"valid",value:e.data}}}return t.create=n=>new t({typeName:te.ZodNaN,...ae(n)}),t})(),E7=Symbol("zod_brand"),oc=class extends de{_parse(n){let{ctx:e}=this._processInputParams(n),r=e.data;return this._def.type._parse({data:r,path:e.path,parent:e})}unwrap(){return this._def.type}},sc=class t extends de{_parse(n){let{status:e,ctx:r}=this._processInputParams(n);if(r.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?J:o.status==="dirty"?(e.dirty(),$i(o.value)):this._def.out._parseAsync({data:o.value,path:r.path,parent:r})})();{let i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?J:i.status==="dirty"?(e.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(n,e){return new t({in:n,out:e,typeName:te.ZodPipeline})}},Ob=(()=>{class t extends de{_parse(e){let r=this._def.innerType._parse(e),i=o=>(Wr(o)&&(o.value=Object.freeze(o.value)),o);return Is(r)?r.then(o=>i(o)):i(r)}unwrap(){return this._def.innerType}}return t.create=(n,e)=>new t({innerType:n,typeName:te.ZodReadonly,...ae(e)}),t})();function aO(t,n){let e=typeof t=="function"?t(n):typeof t=="string"?{message:t}:t;return typeof e=="string"?{message:e}:e}function yO(t,n={},e){return t?Lh.create().superRefine((r,i)=>{let o=t(r);if(o instanceof Promise)return o.then(s=>{if(!s){let a=aO(n,r),c=a.fatal??e??!0;i.addIssue({code:"custom",...a,fatal:c})}});if(!o){let s=aO(n,r),a=s.fatal??e??!0;i.addIssue({code:"custom",...s,fatal:a})}}):Lh.create()}var S7={object:xs.lazycreate},te=(function(t){return t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly",t})(te||{});var C7=(t,n={message:`Input not instance of ${t.name}`})=>yO(e=>e instanceof t,n),vO=qh.create,_O=gb.create,I7=gO.create,T7=yb.create,bO=vb.create,x7=_b.create,D7=dO.create,O7=bb.create,M7=wb.create,A7=Lh.create,N7=rc.create,P7=qi.create,R7=fO.create,k7=ic.create,L7=xs.create,j7=xs.strictCreate,F7=Eb.create,$7=jh.create,q7=Sb.create,B7=Ds.create,H7=Fh.create,U7=hO.create,V7=pO.create,W7=$h.create,G7=Cb.create,z7=Ib.create,K7=Bh.create,Y7=Tb.create,Z7=Hh.create,Q7=Os.create,J7=Gr.create,X7=Ms.create,eJ=Os.createWithPreprocess,tJ=sc.create,nJ=()=>vO().optional(),rJ=()=>_O().optional(),iJ=()=>bO().optional(),oJ={string:t=>qh.create({...t,coerce:!0}),number:t=>gb.create({...t,coerce:!0}),boolean:t=>vb.create({...t,coerce:!0}),bigint:t=>yb.create({...t,coerce:!0}),date:t=>_b.create({...t,coerce:!0})};var sJ=J;var wO=new _e("LogScope");function EO(t){return{injectLogger:n=>{let e=w(wO,{optional:!0}),r=e!=null?`${e}.${n}`:n;return w(Ba).getLogger(r,{package:t})},getLogger:n=>j(n,{package:t})}}var{injectLogger:YEe,getLogger:SO}=EO("@planx.machina.at/webrtc");var jM=U(Q(),1);var Uh=U(Q(),1),CO=U(Ni(),1);function IO(t){t||(t=w(Kt));let n=new Uh.Observable(e=>{if(t.destroyed){e.next();return}return t.onDestroy(e.next.bind(e))});return e=>e.pipe((0,CO.takeUntil)(n))}function TO(t,n){let e=n?.injector??w(sn),r=new Uh.ReplaySubject(1),i=t_(()=>{let o;try{o=t()}catch(s){La(()=>r.error(s));return}La(()=>r.next(o))},{injector:e,manualCleanup:!0});return e.get(Kt).onDestroy(()=>{i.destroy(),r.complete()}),r.asObservable()}function xO(t,n){let r=!n?.manualCleanup?n?.injector?.get(Kt)??w(Kt):null,i=aJ(n?.equal),o;n?.requireSync?o=an({kind:0},{equal:i}):o=an({kind:1,value:n?.initialValue},{equal:i});let s,a=t.subscribe({next:c=>o.set({kind:1,value:c}),error:c=>{o.set({kind:2,error:c}),s?.()},complete:()=>{s?.()}});if(n?.requireSync&&o().kind===0)throw new Re(601,!1);return s=r?.onDestroy(a.unsubscribe.bind(a)),dt(()=>{let c=o();switch(c.kind){case 1:return c.value;case 2:throw c.error;case 0:throw new Re(601,!1)}},{equal:n?.equal})}function aJ(t=Object.is){return(n,e)=>n.kind===1&&e.kind===1&&t(n.value,e.value)}var Zn=U(Q(),1);var Bi=new _e("WEB_RTC_CONFIG");function DO(t){return{provide:Bi,useFactory:t}}var Oe=(()=>{class t{constructor(){this._diagInstanceId=(()=>{let e=Math.random().toString(36).slice(2,8);return console.warn(`[config:construct] WebRTCConfigService constructed instanceId=${e}`),e})(),this._config=w(Bi),this.config=an(this._config),this.config$=TO(this.config),this.identity$=this.config$.pipe((0,Zn.map)(e=>e.identity),(0,Zn.filter)(e=>!!e?.peerId),(0,Zn.shareReplay)({bufferSize:1,refCount:!1})),this.rolesReady$=this.config$.pipe((0,Zn.map)(e=>({peerId:e.identity?.peerId??"",roles:e.roles??[]})),(0,Zn.filter)(e=>!!e.peerId&&e.roles.length>0),(0,Zn.shareReplay)({bufferSize:1,refCount:!1})),this.connectionTimeoutMs=dt(()=>this.config().connection?.timeoutMs??12e3),this.maxRetryCount=dt(()=>this.config().connection?.maxRetryCount??1),this.retryDelayMs=dt(()=>this.config().connection?.retryDelayMs??1e3),this.autoReconnect=dt(()=>this.config().connection?.autoReconnect??!0),this.reconnectMaxAttempts=dt(()=>this.config().connection?.reconnectMaxAttempts??20),this.reconnectInitialDelayMs=dt(()=>this.config().connection?.reconnectInitialDelayMs??200),this.shortServerId=dt(()=>{let e=this.config().identity?.peerId??"";return e?e.replace(/-/g,"").substring(8,16):""}),this.peerId=dt(()=>this.config().identity?.peerId??""),this.publicKey=dt(()=>this.config().identity?.publicKey??null),this.signalingId=dt(()=>this.config().identity?.signalingId??""),this.peersByPublicKey=dt(()=>{let e=this.config().identity?.peers??{},r={};for(let[i,o]of Object.entries(e))r[o]=i;return r})}resolveSignalingId(e){return this.peersByPublicKey()[e]??null}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var Vh=(()=>{class t{constructor(){this.logger=j("SignalingCryptoService"),this.config=w(Oe),this.signatureAdapter=w(Pi),this.encryptionAdapter=w(Hr)}get privateKey(){let e=this.config.config().identity?.privateKey;if(!e)throw new Error("Identity not configured. Call configure() or initializeKeys() first.");return e}async encryptForPeer(e,r){if(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r)){let o=await this.resolvePublicKey(r);if(!o)throw new Error(`Cannot resolve publicKey for peer: ${r}`);return this.encryptData(e,o)}return this.encryptData(e,r)}async encryptData(e,r){let i=await this.encryptionAdapter.deriveSharedKey(this.privateKey,r),o=await PD(new TextEncoder().encode(JSON.stringify(e)));return this.encryptionAdapter.encryptBytes(o,i)}async decryptData(e,r,i){let o=await this.encryptionAdapter.deriveSharedKey(this.privateKey,i),s=await RD(await this.encryptionAdapter.decryptBytes(e,r,o));return JSON.parse(new TextDecoder().decode(s))}async decryptMessageData(e,r){try{return await this.decryptData(e.encrypted,e.iv,r)}catch(i){return this.logger.warn("[decryptMessageData] Failed:",{error:i?.message}),null}}async createSignature(e){try{return(await this.signatureAdapter.sign(e,this.privateKey)).signature}catch(r){return this.logger.error("[createSignature] Failed:",{name:r?.name,message:r?.message}),""}}async verifySignature(e){if(!e.signature)return this.logger.info("[signaling:verify] no-signature",{type:e.payload.type,from:e.payload.from?.slice(0,16)}),!1;try{let r=await this.resolvePublicKey(e.payload.from);if(!r)return this.logger.info("[signaling:verify] publicKey-MISS",{type:e.payload.type,from:e.payload.from?.slice(0,16),peersCount:Object.keys(this.config.config().identity?.peers??{}).length}),!1;let i=await this.signatureAdapter.verify({payload:e.payload,signature:e.signature},r);return i.valid||this.logger.info("[signaling:verify] signature-INVALID",{type:e.payload.type,from:e.payload.from?.slice(0,16),pubKeyLen:r.length}),i.valid}catch(r){return this.logger.error("[signaling:verify] EXCEPTION:",{name:r?.name,message:r?.message}),!1}}async filterValidSignatures(e){return(await Promise.all(e.map(async i=>({message:i,valid:await this.verifySignature(i)})))).filter(i=>i.valid).map(i=>i.message)}async resolvePublicKey(e){return(this.config.config().identity?.peers??{})[e]??null}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var et=U(Q(),1);var Vt=U(Q(),1),cn=U(Ni(),1);var Wh=(()=>{class t{constructor(){this.channels=w(fs,{optional:!0})??[],this.logger=j("SignalingChannelManager"),console.error("[signaling:channel-manager] constructor channels.length=",this.channels.length,"channels=",JSON.stringify(this.channels.map(e=>({name:e.name,isAvailable:e.isAvailable}))),"pid=",globalThis.process?.pid??"n/a")}get availableChannels(){return this.channels.filter(e=>e.isAvailable)}async create(e){return this.send(e)}async send(e){let r=this.requireChannels("send"),i=r.filter(o=>o.acceptsMessage?.(e)??!0);if(i.length===0)throw new Error(`[send] No channels accept message type ${e.payload.type}`);try{return await this.raceFastest(i,e)}catch(o){let s=r.filter(a=>!i.includes(a)&&(a.acceptsFallback?.(e)??!1));if(s.length===0)throw o;return this.logger.warn("[send] primary channels all failed, trying fallback tier:",s.map(a=>a.name)),this.raceFastest(s,e)}}async raceFastest(e,r){this.logger.info("[send] race-fastest broadcast:",e.map(s=>s.name));let i=[],o=(0,Vt.merge)(...e.map(s=>(0,Vt.from)(s.send(r)).pipe((0,cn.map)(a=>(this.logger.info(`[send] ${s.name}: SUCCESS`,a),a)),(0,cn.catchError)(a=>(this.logger.error(`[send] ${s.name}: FAILED`,a instanceof Error?a.stack??a.message:String(a)),i.push(a),Vt.EMPTY))))).pipe((0,cn.take)(1));try{return await(0,Vt.firstValueFrom)(o)}catch{throw new AggregateError(i,"All signaling channels failed")}}listenEvents(e,r){let o=this.requireChannels("listenEvents").map(s=>s.events(e,r).pipe((0,cn.catchError)(a=>(this.logger.warn(`[listenEvents] ${s.name} errored, isolating:`,a?.message||a),Vt.EMPTY))));return(0,Vt.merge)(...o).pipe((0,cn.share)({resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!1}))}observePresence(e,r){let i=this.availableChannels.filter(s=>typeof s.presence=="function");if(i.length===0)return Vt.EMPTY;let o=i.map(s=>s.presence(e,r).pipe((0,cn.catchError)(a=>(this.logger.warn(`[observePresence] ${s.name} errored, isolating:`,a?.message||a),Vt.EMPTY))));return(0,Vt.merge)(...o).pipe((0,cn.share)({resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!1}))}requireChannels(e){let r=this.availableChannels;if(r.length===0)throw new Error(`[${e}] No signaling channels available`);return r}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var OO=6e4,MO=(()=>{class t{constructor(){this.logger=j("SignalingRateCounter"),this.counts=new Map}start(){this.timer||(this.timer=setInterval(()=>this.emit(),OO))}ngOnDestroy(){this.timer&&(clearInterval(this.timer),this.timer=void 0)}record(e){this.counts.set(e,(this.counts.get(e)??0)+1)}emit(){let e=0,r={};for(let[i,o]of this.counts)r[i]=o,e+=o;this.logger.info("[signaling-rate-metric]",{total:e,perMinute:e,intervalMs:OO,types:r}),this.counts.clear()}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var Z=U(Q(),1);function AO(t){if(!t?.payload)return!1;let{type:n,from:e,to:r,timestamp:i,data:o}=t.payload;if(!n||!e||!r||typeof i!="number")return!1;switch(n){case"announce":return!!o?.roles&&Array.isArray(o.roles);case"offer":case"answer":return In(o)||!!o?.sdp;case"candidates":return In(o)||!!o?.candidate||Array.isArray(o?.candidates)&&o.candidates.length>0;default:return!1}}function Mb(t,n,e){return t==="restricted"?n.includes(e):t==="unrestricted"?!0:n.length===0||n.includes(e)}function NO(t){let n=[],e=r=>{for(;n.length>0&&r-n[0].stashedAt>6e4;)n.shift()};return{stash(r){let i=Date.now();e(i),n.push({record:r,stashedAt:i}),n.length>64&&n.shift(),t?.warn("[pending-admit] stashed non-admitted signaling message (awaiting allowPeers propagation)",{id:r.id,type:r.payload.type,from:r.payload.from?.substring(0,16),pending:n.length})},drainAdmitted(r){e(Date.now());let i=[];for(let o=n.length-1;o>=0;o--)r(n[o].record.payload.from)&&(i.unshift(n[o].record),n.splice(o,1));return i.length>0&&t?.info("[pending-admit] replaying admitted signaling messages after allowPeers update",{count:i.length,ids:i.map(o=>o.id)}),i}}}function RO(t){let{channelManager:n,config:e,cryptoService:r,processedMessageIds:i,refresh$:o,destroy$:s,getMySignalingIds:a,filterSelfMessage:c,logger:u,onAdmitDrop:l}=t,d=NO(u);return(0,Z.combineLatest)([(0,Z.concat)((0,Z.defer)(()=>(0,Z.of)({subscriptionStartTime:new Date(Date.now()-5e3)})),(0,Z.merge)((0,Z.interval)(6e4),o).pipe((0,Z.map)(()=>({subscriptionStartTime:new Date(Date.now()-5e3)})))),e.config$.pipe((0,Z.map)(f=>({signalingId:f.identity?.signalingId,peerKeys:Object.keys(f.identity?.peers??{}).sort().join("|")})),(0,Z.filter)(f=>!!f.signalingId),(0,Z.distinctUntilChanged)((f,p)=>f.signalingId===p.signalingId&&f.peerKeys===p.peerKeys))]).pipe((0,Z.switchMap)(([{subscriptionStartTime:f}])=>(0,Z.from)(a()).pipe((0,Z.switchMap)(p=>{if(p.length===0)return Z.EMPTY;let m=Object.keys(e.config().identity?.peers??{}),y=e.config().allowPeersMode,b=d.drainAdmitted(E=>Mb(y,m,E));return(0,Z.concat)((0,Z.from)(b),n.listenEvents(p,{subscriptionStartTime:f,allowedFromPeers:m})).pipe((0,Z.filter)(E=>Mb(y,m,E.payload.from)?!0:(u.warn("[signaling:admit] DROP unadmitted sender",{from:E.payload.from?.slice(0,16),type:E.payload.type,mode:y,allowCount:m.length}),d.stash(E),l?.(E.payload.from),!1)),(0,Z.map)(E=>[E]))}))),(0,Z.tap)(f=>{f.length>0&&u.info("[signaling:msg:before-crypto]",{count:f.length,types:f.map(p=>p.payload.type),froms:f.map(p=>p.payload.from?.slice(0,16))})}),(0,Z.concatMap)(f=>(0,Z.from)(r.filterValidSignatures(f))),(0,Z.tap)(f=>{f.length>0&&u.info("[signaling:msg:after-crypto]",{count:f.length,types:f.map(p=>p.payload.type)})}),(0,Z.map)(f=>f.filter(p=>i.has(p.id)?!1:(i.set(p.id,Date.now()),!0))),(0,Z.tap)(f=>{f.length>0&&u.info("[signaling:msg:after-dedup]",{count:f.length,types:f.map(p=>p.payload.type),froms:f.map(p=>p.payload.from?.slice(0,16))})}),(0,Z.mergeMap)(f=>(0,Z.from)(f)),(0,Z.filter)(f=>AO(f)),(0,Z.concatMap)(f=>(0,Z.from)(c(f))),(0,Z.filter)(f=>f!==null),(0,Z.tap)(f=>u.info("[message$] Emitting:",{type:f.payload.type})),(0,Z.retry)({delay:(f,p)=>{let m=Math.min(1e3*Math.pow(2,p-1),3e4);return u.warn("[message$] Retrying after upstream error:",{message:f?.message||String(f),retryCount:p,delayMs:m}),(0,Z.timer)(m)}}),(0,Z.takeUntil)(s),(0,Z.shareReplay)({bufferSize:1,refCount:!0}))}var Gh=(()=>{class t{constructor(){this.logger=j("SignalingMessageHandler"),this.config=w(Oe),this.channelManager=w(Wh),this.cryptoService=w(Vh),this.rateCounter=w(MO),this.processedMessageIds=new Map,this.destroy$=new et.Subject,this.refresh$=new et.Subject,this._unadmittedSender$=new et.BehaviorSubject(null),this.unadmittedSender$=this._unadmittedSender$.asObservable(),this.message$=RO({channelManager:this.channelManager,config:this.config,cryptoService:this.cryptoService,processedMessageIds:this.processedMessageIds,refresh$:this.refresh$,destroy$:this.destroy$,getMySignalingIds:()=>this.getMySignalingId_asList(),filterSelfMessage:e=>this.filterSelfMessage(e),logger:this.logger,onAdmitDrop:e=>this._unadmittedSender$.next({from:e,at:Date.now()})}),this.presence$=this.config.config$.pipe((0,et.map)(e=>({signalingId:e.identity?.signalingId??"",peerKeys:Object.keys(e.identity?.peers??{}).sort(),metaKeys:Object.keys(e.identity?.peersMeta??{}).sort()})),(0,et.distinctUntilChanged)((e,r)=>e.signalingId===r.signalingId&&e.peerKeys.join("|")===r.peerKeys.join("|")&&e.metaKeys.join("|")===r.metaKeys.join("|")),(0,et.switchMap)(({signalingId:e,peerKeys:r})=>e===""?et.EMPTY:this.channelManager.observePresence([e],{allowedFromPeers:r})),(0,et.takeUntil)(this.destroy$)),(0,et.interval)(6e4).pipe((0,et.takeUntil)(this.destroy$)).subscribe(()=>this.cleanup()),this.rateCounter.start(),this.message$.pipe((0,et.takeUntil)(this.destroy$)).subscribe(e=>this.rateCounter.record(e.payload.type))}async getMySignalingId(){return this.config.signalingId()??""}async getMySignalingId_asList(){let e=this.config.signalingId();return e?[e]:[]}isHashedId(e){return/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(e)}async getTargetSignalingId(e){if(this.isHashedId(e))return e;let r=this.config.resolveSignalingId(e);if(r)return r;let i=this.config.config()?.identity?.peers??{};throw console.warn(`[signaling:resolve-fail] resolve failed instanceId=${this.config._diagInstanceId} targetPrefix=${e.substring(0,20)} identityPeersCount=${Object.keys(i).length} identityPeersHasTarget=${Object.values(i).includes(e)} identityPeersKeys=${Object.keys(i).join(",")}`),new Error(`[getTargetSignalingId] Cannot resolve publicKey to signalingId: ${e.substring(0,20)}...`)}async filterSelfMessage(e){let r=await this.getMySignalingId();return r&&r===e.payload.from?null:e}cleanup(){if(this.processedMessageIds.size<=5e4)return;let e=[...this.processedMessageIds.entries()].sort((i,o)=>i[1]-o[1]),r=this.processedMessageIds.size-5e4;for(let i=0;i<r;i++)this.processedMessageIds.delete(e[i][0])}refresh(){this.logger.info("[refresh] Forcing subscription refresh"),this.refresh$.next()}ngOnDestroy(){this.processedMessageIds.clear(),this.destroy$.next(),this.destroy$.complete(),this.refresh$.complete()}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var zh=(()=>{class t{constructor(){this.logger=j("SignalingService"),this.config=w(Oe),this.messageSender=w(qa),this.cryptoService=w(Vh),this.messageHandler=w(Gh),this.message$=this.messageHandler.message$}async send(e){let r=await this.messageHandler.getMySignalingId(),i=e.payload.to==="all"?"all":await this.messageHandler.getTargetSignalingId(e.payload.to),o={...e.payload,from:r,to:i},s=await this.cryptoService.createSignature(o);return this.messageSender.create({payload:o,signature:s})}async sendAnnounce(e){let r=await this.messageHandler.getMySignalingId();this.logger.info("[sendAnnounce]",{roles:e.join(","),pid:typeof process<"u"?process.pid:"n/a"});let i={type:"announce",from:r,to:"all",timestamp:Date.now(),data:{roles:e}};return this.messageSender.create({payload:i,signature:""})}async sendOffer(e,r,i){let[o,s]=await Promise.all([this.messageHandler.getMySignalingId(),this.messageHandler.getTargetSignalingId(e)]),c={...await this.cryptoService.encryptForPeer(r,e),token:i},u={type:"offer",from:o,to:s,timestamp:Date.now(),data:c},l=await this.cryptoService.createSignature(u);return this.messageSender.create({payload:u,signature:l})}async sendAnswer(e,r){let[i,o]=await Promise.all([this.messageHandler.getMySignalingId(),this.messageHandler.getTargetSignalingId(e)]),s=await this.cryptoService.encryptForPeer(r,e),a={type:"answer",from:i,to:o,timestamp:Date.now(),data:s},c=await this.cryptoService.createSignature(a);return this.messageSender.create({payload:a,signature:c})}async sendCandidates(e,r){let[i,o]=await Promise.all([this.messageHandler.getMySignalingId(),this.messageHandler.getTargetSignalingId(e)]),s=await this.cryptoService.encryptForPeer({candidates:r},e),a={type:"candidates",from:i,to:o,timestamp:Date.now(),data:s},c=await this.cryptoService.createSignature(a);return this.messageSender.create({payload:a,signature:c})}async sendCandidate(e,r){return this.sendCandidates(e,[r])}async decryptMessageData(e,r){return this.cryptoService.decryptMessageData(e,r)}async getSenderPublicKey(e){return this.cryptoService.resolvePublicKey(e)}ngOnDestroy(){this.messageHandler.ngOnDestroy()}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var Yh=U(Q(),1),ot=U(Ni(),1);function LO(t,n,e){let r=new Map(t),i=[];for(let[o,s]of t.entries())!s.lastSeen||n-s.lastSeen<=6e4||e?.(o)||(i.push(s),r.delete(o));return{updated:r,removed:i}}function jO(t,n,e,r){let i=t.get(n.peerId),o=!!i&&e!==void 0&&i.generation!==void 0&&e!==i.generation,s=!!i?.lastSeen&&r-i.lastSeen>6e4,a=o||s,c={id:n.peerId,publicKey:n.publicKey,name:n.meta.name,roles:n.meta.roles,lastSeen:r,generation:e},u=new Map(t);if(u.set(n.peerId,c),!i)return{kind:"added",peers:u,peer:c};let l=a?o?`generation changed (${i.generation} \u2192 ${e})`:`gap=${r-(i.lastSeen??0)}ms > ${6e4}ms`:void 0;return{kind:"updated",peers:u,peer:c,restartDetected:a,reason:l}}var Ab={peers:new Map,events:[]},As=(()=>{class t{constructor(){this.logger=j("PeerListService"),this.config=w(Oe),this.destroyRef=w(Kt),this.messageHandler=w(Gh),this.commandSubject=new Yh.Subject,this.announceFromPresence$=this.messageHandler.presence$.pipe((0,ot.map)(e=>{if(LD(e))return{kind:"presence-lost",peerId:e.fromKey,at:e.observedAt};let r=this.config.config().identity,i=r?.peers?.[e.fromKey],o=r?.peersMeta?.[e.fromKey];return!i||!o?null:{kind:"presence",input:{peerId:e.fromKey,publicKey:i,meta:o},generation:e.generation,at:e.observedAt}}),(0,ot.tap)(e=>{e===null&&this.logger.debug("[presence] identity.peers/peersMeta not populated, dropping (presence$ will redeliver once identity is updated)")}),(0,ot.filter)(e=>e!==null)),this.state$=(0,Yh.merge)(this.announceFromPresence$,this.commandSubject).pipe((0,ot.scan)((e,r)=>{if(r.kind==="clear")return{peers:new Map,events:[]};if(r.kind==="presence-lost"){let o=e.peers.get(r.peerId);if(!o)return{peers:e.peers,events:[]};let s=new Map(e.peers);return s.delete(r.peerId),{peers:s,events:[{type:"removed",peer:o}]}}if(r.kind==="remove-expired"){let{updated:o,removed:s}=LO(e.peers,r.at,r.isActive);return s.length>0?{peers:o,events:s.map(a=>({type:"removed",peer:a}))}:{peers:e.peers,events:[]}}let i=jO(e.peers,r.input,r.generation,r.at);return i.kind==="added"?{peers:i.peers,events:[{type:"added",peer:i.peer}]}:{peers:i.peers,events:[{type:"updated",peer:i.peer,restartDetected:i.restartDetected}]}},Ab),(0,ot.tap)(({peers:e,events:r})=>{for(let i of r)i.type==="added"?this.logger.info(`[peerEvents] New peer added: ${i.peer.id} roles=${i.peer.roles} name=${i.peer.name} | total peers: ${e.size}`):i.type==="updated"?i.restartDetected?this.logger.info(`[peerEvents] Restart detected for peer ${i.peer.id}`):this.logger.debug("[peerEvents] Peer updated:",i.peer.id):this.logger.info(`[peerEvents] Removed expired peer: ${i.peer.id} | ${e.size} peers remaining`)}),(0,ot.startWith)(Ab),(0,ot.share)()),this.peers$=this.state$.pipe((0,ot.map)(e=>e.peers),(0,ot.distinctUntilChanged)(),(0,ot.shareReplay)({bufferSize:1,refCount:!1})),this.peersSignal=xO(this.peers$,{initialValue:Ab.peers}),this.state$.pipe(IO(this.destroyRef)).subscribe()}removeExpiredPeers(e){this.commandSubject.next({kind:"remove-expired",at:Date.now(),isActive:e})}getServerPeers(){return Array.from(this.peersSignal().values()).filter(e=>e.roles.includes("server"))}getClientPeers(){return Array.from(this.peersSignal().values()).filter(e=>e.roles.includes("client"))}getPeer(e){return this.peersSignal().get(e)}getPeerByPublicKey(e){for(let r of this.peersSignal().values())if(r.publicKey===e)return r}getPeerByName(e){for(let r of this.peersSignal().values())if(r.name===e)return r}clear(){this.commandSubject.next({kind:"clear"})}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var zr=U(Q(),1);var dJ=new Map;function fJ(t,n){let e=[];for(let[r,i]of n){let o=t.get(r);if(!o){e.push({type:"added",peer:i});continue}if(o===i)continue;let s=o.generation!==void 0&&i.generation!==void 0&&o.generation!==i.generation,a=!!o.lastSeen&&!!i.lastSeen&&i.lastSeen-o.lastSeen>6e4;e.push({type:"updated",peer:i,restartDetected:s||a})}for(let[r,i]of t)n.has(r)||e.push({type:"removed",peer:i});return e}function FO(t){return t.pipe((0,zr.startWith)(dJ),(0,zr.pairwise)(),(0,zr.mergeMap)(([n,e])=>(0,zr.from)(fJ(n,e))))}var Ns={"reliable-ordered":{ordered:!0},"reliable-unordered":{ordered:!1},unreliable:{ordered:!1,maxRetransmits:0},"unreliable-ordered":{ordered:!0,maxRetransmits:0},heartbeat:{ordered:!0,negotiated:!0,id:1023,priority:"high"},"reliable-ordered-pr":{ordered:!0,maxRetransmits:3}};var hJ=/^[0-9a-f]{40}$/i,Zh=class{constructor(n,e){this.registry=n,this.registrar=e,this.logger=j("DataChannelLifecycleService"),this.peerSubscriptions=new Map,this.attachedSources=new Map}attachPeer(n,e){let r=this.attachedSources.get(n);if(r===e)return;this.peerSubscriptions.get(n)?.unsubscribe(),r&&(this.logger.info("[attachPeer] Cleaning up old generation channels:",{peerId:n}),this.registrar.cleanupPeer(n)),this.attachedSources.set(n,e),this.registrar.ensurePeerMap(n);let i=this.registry.attach(n,e,(o,s)=>this.registrar.register(o,s,"remote"),o=>hJ.test(o));i.add(e.lifecycle$.subscribe(o=>{o==="closed"&&(this.logger.warn("[lifecycle] Cleaning up channels (closed):",{peerId:n}),this.cleanupPeer(n))})),this.peerSubscriptions.set(n,i)}cleanupPeer(n){this.logger.debug("[cleanupPeer] called:",{peerId:n.substring(0,20)}),this.peerSubscriptions.get(n)?.unsubscribe(),this.peerSubscriptions.delete(n),this.attachedSources.delete(n),this.registrar.cleanupPeer(n),this.registry.delete(n),this.logger.debug("[cleanupPeer] Cleaned up:",n)}};var Rb=U(Q(),1);var ac=U(Q(),1);var pJ=j("DataChannelRegistrar");function $O(t,n,e,r,i=5e3){return new Promise((o,s)=>{let a=null,c=null,u=()=>{c&&clearTimeout(c),a&&a.unsubscribe()};c=setTimeout(()=>{u(),s(new Error(`Channel open timeout: ${e}/${r}`))},i);let l=t.get(e)?.get(r);if(l?.readyState==="open"){u(),o();return}if(l){let d=()=>{u(),l.removeEventListener("open",d),o()};l.addEventListener("open",d);return}pJ.debug("[waitForOpen] Channel not yet registered, waiting for channelOpened$:",{peerId:e,label:r}),a=n.subscribe(d=>{d.peerId===e&&d.label===r&&(u(),o())})})}var Qh=class{constructor(){this.logger=j("DataChannelRegistrar"),this.channels=new Map,this.channelOpened$=new ac.ReplaySubject(32),this.channelClosed$=new ac.Subject,this.channelMessage$=new ac.Subject}getChannel(n,e){return this.channels.get(n)?.get(e)}hasChannel(n,e){return this.channels.get(n)?.get(e)?.readyState==="open"}ensurePeerMap(n){this.channels.has(n)||this.channels.set(n,new Map)}register(n,e,r){let i=e.label;this.ensurePeerMap(n);let o=this.channels.get(n).get(i),s=o?.readyState==="open";if(o&&o!==e){this.logger.info("[register] Replacing existing channel:",{peerId:n.substring(0,20),label:i}),o.onmessage=null,o.onclose=null,o.onerror=null,o.onopen=null;try{o.close()}catch{}}this.channels.get(n).set(i,e),e.readyState==="open"?s?this.logger.debug("[channel] Replaced (no re-emit):",{peerId:n,label:i}):(this.logger.debug("[channel] Already open:",{peerId:n,label:i}),this.channelOpened$.next({peerId:n,label:i,origin:r})):e.onopen=()=>{this.logger.debug("[channel] Opened:",{peerId:n,label:i}),this.channelOpened$.next({peerId:n,label:i,origin:r})},e.onclose=a=>{let c=this.channels.get(n)?.get(i)===e,u=e.readyState;this.logger.info("[channel] Closed:",{peerId:n.substring(0,20),label:i,readyState:u,isCurrent:c,closeEvent:a?.type}),c&&(this.channels.get(n)?.delete(i),this.channelClosed$.next({peerId:n,label:i,readyState:u,reason:"natural"}))},e.onerror=a=>{let c=a?.error;this.logger.error("[channel] Error:",{peerId:n.substring(0,20),label:i,readyState:e.readyState,errorDetail:c?.errorDetail,message:c?.message??a?.message})},e.onmessage=a=>{this.channelMessage$.next({peerId:n,label:i,data:a.data})}}evictStale(n,e){let r=this.channels.get(n);r?.has(e)&&(r.delete(e),this.logger.warn("[evictStale] Removed stale channel:",{peerId:n,label:e}),this.channelClosed$.next({peerId:n,label:e,reason:"evict"}))}cleanupPeer(n){let e=this.channels.get(n);if(e){let r=Array.from(e.keys()),i=new Error().stack?.split(`
18
+ `)[2]?.trim()??"unknown";this.logger.info("[cleanupPeer] Closing channels:",{peerId:n.substring(0,20),labels:r,caller:i});for(let[o,s]of e){let a=s.readyState;s.close(),this.channelClosed$.next({peerId:n,label:o,readyState:a,reason:"cleanup"})}this.channels.delete(n)}}waitForOpen(n,e,r=5e3){return $O(this.channels,this.channelOpened$,n,e,r)}};function mJ(t){return typeof t=="string"?t.length:t.byteLength}var Nb=class{constructor(){this.lastAt=new Map}shouldWarn(n,e,r=Date.now()){let i=this.lastAt.get(n);return i!==void 0&&r-i<e?!1:(this.lastAt.set(n,r),!0)}reset(){this.lastAt.clear()}},qO=(()=>{class t{static{this.WARN_THROTTLE_MS=1e3}constructor(e,r){this.registrar=e,this.channelSent$=r,this.logger=j("DataChannelTransport"),this.warnThrottle=new Nb}send(e,r,i){let o=this.registrar.getChannel(e,r);return o?.readyState==="open"?(o.send(i),this.channelSent$.next({peerId:e,label:r,bytes:mJ(i)}),!0):(this.warnThrottled(e,r,o?.readyState),!1)}warnThrottled(e,r,i){let o=`${e}\0${r}`;this.warnThrottle.shouldWarn(o,t.WARN_THROTTLE_MS)&&this.logger.warn("[send] Channel not ready (throttled):",{peerId:e,label:r,state:i})}}return t})();var Hi=U(Q(),1);var BO=U(Q(),1);function Pb(t){let n=typeof performance<"u"?performance.now():Date.now();return{conn:t.connectionState,ice:t.iceConnectionState??"new",signaling:t.signalingState,iceGathering:t.iceGatheringState??"new",sctp:t.sctp?.state??"none",dtls:t.sctp?.transport?.state??"none",at:n}}function HO(t){return new BO.Observable(n=>{let e=()=>n.next(Pb(t));return t.addEventListener("connectionstatechange",e),t.addEventListener("iceconnectionstatechange",e),()=>{t.removeEventListener("connectionstatechange",e),t.removeEventListener("iceconnectionstatechange",e)}})}var gJ=new Set(["closed","failed"]);function UO(t){return t.sctp==="closed"&&gJ.has(t.dtls)}var yJ=j("PeerConnectionRegistry");async function VO(t,n,e){try{let r=await n.getStats(),i,o=new Map,s=new Map;r.forEach(a=>{a.type==="transport"&&a.selectedCandidatePairId&&(i=a.selectedCandidatePairId),a.type==="local-candidate"&&o.set(a.id,a),a.type==="remote-candidate"&&s.set(a.id,a)}),r.forEach(a=>{if(a.type==="candidate-pair"&&a.nominated&&a.state==="succeeded"&&!i||a.type==="candidate-pair"&&a.id===i){let c=o.get(a.localCandidateId),u=s.get(a.remoteCandidateId);c&&u&&e.set(t,{local:c.candidateType??"unknown",remote:u.candidateType??"unknown",protocol:c.protocol??"unknown"})}})}catch(r){yJ.debug("[updateCandidatePair] failed",r)}}var vJ=1e3,WO=(()=>{class t{constructor(){this.logger=j("PeerConnectionRegistry"),this.sources=new Map,this.registered$=new Hi.Subject,this.lastStates=new Map,this.lastConnectedAt=new Map,this.candidatePairs=new Map,this.connectionStateChanged$=new Hi.Subject,this.iceStateChanged$=new Hi.Subject,this.unhealthy$=new Hi.Subject}getLastState(e){return this.lastStates.get(e)}getSource(e){return this.sources.get(e)}has(e){return this.sources.has(e)}attach(e,r,i,o){this.logger.debug("[attach] called:",{peerId:e.substring(0,20)}),this.sources.set(e,r);let s=new Hi.Subscription,a={};s.add(r.diagnostics$.subscribe(u=>this.onDiagnostics(e,r,u,a))),s.add(r.incomingChannels$.subscribe(u=>{o(u.label)||i(e,u)}));let c=setInterval(()=>{this.onDiagnostics(e,r,r.captureDiagnosticsSnapshot(),a)},vJ);return s.add(()=>clearInterval(c)),this.registered$.next(e),s}onDiagnostics(e,r,i,o){let s=o.conn,a=o.ice;o.conn=i.conn,o.ice=i.ice;let c=this.lastConnectedAt.get(e),u=c!==void 0?Math.round(i.at-c):void 0;i.conn==="connected"&&this.lastConnectedAt.set(e,i.at);let l={...i,idleMs:u,selectedPair:this.candidatePairs.get(e)};this.lastStates.set(e,l),i.conn!==s&&(this.logger.info("[connectionStateChange]",{peerId:e.substring(0,20),...l}),this.connectionStateChanged$.next({peerId:e,state:i.conn}),i.conn==="connected"&&VO(e,r,this.candidatePairs)),i.ice!==a&&(this.logger.info("[iceConnectionStateChange]",{peerId:e.substring(0,20),...l}),this.iceStateChanged$.next({peerId:e,state:i.ice})),UO(i)&&this.unhealthy$.next({peerId:e})}waitFor(e,r=5e3){let i=this.sources.get(e);return i?Promise.resolve(i):new Promise((o,s)=>{let a=null,c=this.registered$.subscribe(u=>{u===e&&(a&&clearTimeout(a),c.unsubscribe(),o(this.sources.get(e)))});a=setTimeout(()=>{c.unsubscribe(),s(new Error(`waitForPeerConnection timeout: ${e}`))},r)})}delete(e){this.sources.delete(e)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();async function GO(t,n,e,r){let i={label:e,readyState:"open",send:o=>{let s;typeof o=="string"||o instanceof ArrayBuffer?s=o:o.byteOffset===0&&o.byteLength===o.buffer.byteLength?s=o.buffer:s=o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength),t.channelMessage$.next({peerId:n,label:e,data:s})},close:()=>{},onopen:null,onmessage:null,onclose:null,onerror:null,bufferedAmount:0};t.register(n,i)}var Ps=j("DataChannelManagerService"),_J=new Set(["disconnected","failed","closed"]);function Jh(t,n,e,r,i,o="reliable-ordered"){Ps.debug("[createChannel] called:",{peerId:r.substring(0,20),label:i});let s=t.getSource(r);if(!s)return Ps.warn("[createChannel] PeerConnection not found:",r),null;if(_J.has(s.connectionState))return Ps.warn("[createChannel] PeerConnection unhealthy:",{peerId:r,state:s.connectionState}),e.next({peerId:r,reason:"pre-check"}),null;let a=n.getChannel(r,i);if(a&&a.readyState!=="closed")return Ps.debug("[createChannel] Reusing existing channel:",{peerId:r,label:i}),a;let c;try{c=s.createDataChannel(i,Ns[o])}catch(u){throw Ps.warn("[createChannel] createDataChannel threw, marking unhealthy",{peerId:r,label:i,error:u}),e.next({peerId:r,reason:"create-failed"}),u}return n.register(r,c,"local"),Ps.info("[createChannel] Created:",{peerId:r,label:i,profile:o}),c}var bJ=j("DataChannelManagerService");async function zO(t,n,e,r,i,o,s){let a=Jh(t,n,e,r,i,o);if(!a)throw new Error(`createChannelAsync failed: ${r}/${i}`);if(a.readyState!=="open")try{await n.waitForOpen(r,i,s)}catch(c){bJ.warn("[createChannelAsync] channel stuck at open (timeout), cleaning up for caller escalation",{peerId:r.substring(0,16),label:i,err:c?.message});try{a.close()}catch{}throw n.evictStale(r,i),c}return a}var Dt=(()=>{class t{constructor(){this.logger=j("DataChannelManagerService"),this.registry=w(WO),this.registrar=new Qh,this.lifecycle=new Zh(this.registry,this.registrar),this.channelSent$=new Rb.Subject,this.unhealthy$=new Rb.Subject,this.transport=new qO(this.registrar,this.channelSent$),this.channelOpened$=this.registrar.channelOpened$,this.channelClosed$=this.registrar.channelClosed$,this.channelMessage$=this.registrar.channelMessage$,this.connectionStateChanged$=this.registry.connectionStateChanged$,this.iceStateChanged$=this.registry.iceStateChanged$,this.peerUnhealthy$=this.registry.unhealthy$}getLastPeerState(e){return this.registry.getLastState(e)}attachPeer(e,r){this.lifecycle.attachPeer(e,r)}async registerInProcessChannel(e,r,i){await GO(this.registrar,e,r,i)}sendInProcess(e,r,i,o){let s=this.registrar.getChannel(e,r);return s?.readyState==="open"?o!=null?(this.registrar.channelMessage$.next({peerId:e,label:r,data:i,senderClientId:o}),"sent"):(s.send(i),"sent"):"not_open"}cleanupPeer(e){this.lifecycle.cleanupPeer(e)}waitForPeerConnection(e,r=5e3){return this.registry.waitFor(e,r)}async createChannelAsync(e,r,i="reliable-ordered",o=5e3){return await this.waitForPeerConnection(e,o),zO(this.registry,this.registrar,this.unhealthy$,e,r,i,o)}createChannel(e,r,i="reliable-ordered"){return Jh(this.registry,this.registrar,this.unhealthy$,e,r,i)}closeChannel(e,r){let i=this.registrar.getChannel(e,r);if(i){let o=i.readyState;i.close(),this.registrar.channels.get(e)?.delete(r),this.channelClosed$.next({peerId:e,label:r,readyState:o,reason:"explicit"})}}send(e,r,i){return this.transport.send(e,r,i)}getBufferedAmount(e,r){return this.registrar.getChannel(e,r)?.bufferedAmount??0}hasChannel(e,r){return this.registrar.hasChannel(e,r)}getChannel(e,r){return this.registrar.getChannel(e,r)}getPeerChannels(e){return this.registrar.channels.get(e)}waitForOpen(e,r,i=5e3){return this.registrar.waitForOpen(e,r,i)}registerChannel(e,r){this.registrar.register(e,r)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();function Xh(t){return t?.type==="renegotiate-offer"}function ep(t){return t?.type==="renegotiate-answer"}var wJ=j("PeerStateMachine"),EJ={IDLE:["CONNECTING","CLOSED"],CONNECTING:["CONNECTED","FAILED","CLOSED"],CONNECTED:["FAILED","CLOSED"],FAILED:["RECONNECTING","CLOSED","CONNECTING"],RECONNECTING:["CONNECTING","CONNECTED","FAILED","CLOSED"],CLOSED:[]};function SJ(t,n){return t===n?!0:EJ[t]?.includes(n)??!1}function KO(t,n,e){if(SJ(t,n))return n;let r=e?e.substring(0,8):"?";return wJ.warn("[PeerStateMachine] invalid transition",{peerId:r,from:t,to:n}),null}function YO(t="CONNECTING"){return t}var tp=class{constructor(){this.entries=new Map}getOrCreate(n,e){let r=this.entries.get(n);if(r)return r;let i={initiator:e,reconnecting:!1,connecting:!1,lifecycle:"IDLE"};return this.entries.set(n,i),i}get(n){return this.entries.get(n)}delete(n){this.entries.delete(n)}isReconnecting(n){return this.entries.get(n)?.reconnecting??!1}markReconnecting(n,e){let r=this.entries.get(n);r&&(r.reconnecting=e)}isConnecting(n){return this.entries.get(n)?.connecting??!1}getInitiator(n){return this.entries.get(n)?.initiator}getLifecycle(n){return this.entries.get(n)?.lifecycle}transition(n,e){let r=this.entries.get(n);if(!r)return!1;let i=KO(r.lifecycle,e,n);return i===null?!1:(r.lifecycle=i,this.syncFlags(r),!0)}syncFlags(n){n.reconnecting=n.lifecycle==="RECONNECTING",n.lifecycle==="CONNECTING"?n.connecting=!0:(n.lifecycle==="CONNECTED"||n.lifecycle==="CLOSED"||n.lifecycle==="FAILED"||n.lifecycle==="IDLE")&&(n.connecting=!1)}resetOnExplicitConnect(n,e){let r=this.getOrCreate(n,e);r.initiator=e,r.reconnecting=!1,r.connecting=!1,r.lifecycle=YO("IDLE")}};var Kr=(()=>{class t{constructor(){this.state=new tp}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();function cc(){if(globalThis.__WEBRTC_VERBOSE_DIAG===!0)return!0;try{if(typeof localStorage<"u"&&localStorage.getItem("webrtc-verbose-diag")==="1")return!0}catch{}return!1}function ZO(t,n){!cc()||!t||t.subscribe(e=>{console.log(`[pc-diag] snapshot peer=${n} conn=${e.conn} ice=${e.ice} signaling=${e.signaling} gather=${e.iceGathering} sctp=${e.sctp} dtls=${e.dtls}`)})}function QO(t,n){if(!cc()||n.type!=="offer"&&n.type!=="answer")return;let e=n.sdp||"",r=e.match(/a=fingerprint:\s*(\S+)\s+(\S+)/i),i=e.match(/a=setup:(\S+)/i);console.log(`[peer-event-SDP] local ${n.type} peer=${t} fp=${r?.[1]??"MISS"}:${r?.[2]?.substring(0,40)??"MISS"} setup=${i?.[1]??"MISS"} len=${e.length}`)}function JO(t,n){cc()&&n.candidate&&console.log(`[peer-event-ICE] local candidate peer=${t} candidate=${JSON.stringify(n).substring(0,120)}`)}function XO(t,n,e){if(!cc())return;let r=e;console.log(`[peer-event-SIGNAL] peer=${t} connected=${n.connected} type=${r?.type??"ice"} hasCandidate=${!!r?.candidate}`)}function eM(t,n){cc()&&console.log(`[peer-event-CONNECT] peer=${t} conn=${n?.conn} ice=${n?.ice} signaling=${n?.signaling} gathering=${n?.iceGathering} sctp=${n?.sctp??"N/A"}`)}function tM(t,n){let e=t?.code??"UNKNOWN",r=t?.message||t,i=typeof navigator<"u"?navigator.onLine:"n/a",o=typeof document<"u"?document.visibilityState:"n/a",s=n?.selectedPair?`pair=${n.selectedPair.local}/${n.selectedPair.remote}/${n.selectedPair.protocol}`:"pair=none",a=n?.idleMs!==void 0?`idle=${n.idleMs}ms`:"idle=n/a",c=n?`ice=${n.ice} conn=${n.conn} dtls=${n.dtls} sctp=${n.sctp} signal=${n.signaling}`:"state=unknown";return`${r} [code=${e} ${c} ${s} ${a} online=${i} vis=${o}]`}var nM=(()=>{class t{constructor(){this.logger=j("PeerEventHandler"),this.channelManager=w(Dt),this.reconnectService=w(Kr)}setupPeerEvents(e,r,i,o,s,a){let c=r.substring(0,8);e.channels&&this.channelManager.attachPeer(r,e.channels),ZO(e.reactive?.diagnostics$,c),this.attachSignalListener(e,r,c,i,o),this.attachConnectListener(e,r,c,i),this.attachErrorListener(e,r,c,i,s),this.attachCloseListener(e,r,c,i,s),this.attachDataListener(e,r,c,i,s,a)}attachSignalListener(e,r,i,o,s){e.on("signal",a=>{if(XO(i,e,a),e.connected){s(r,{type:"peer-signal",signal:a});return}QO(i,a),JO(i,a),a.type==="offer"?o.next({type:"[session.transport.webrtc.peer] offer",peerId:r,data:a}):a.type==="answer"?o.next({type:"[session.transport.webrtc.peer] answer",peerId:r,data:a}):o.next({type:"[session.transport.webrtc.peer] ice-candidate",to:r,data:a})})}attachConnectListener(e,r,i,o){e.on("connect",()=>{this.logger.info("[peer-event] connect",{peerId:i,connectionState:e.connectionState}),eM(i,this.channelManager.getLastPeerState(r)),e.channels?this.channelManager.attachPeer(r,e.channels):this.logger.warn("[peer-event] connect: peer.channels capability missing",{peerId:r.substring(0,20)}),this.reconnectService.state.transition(r,"CONNECTED"),o.next({type:"[session.transport.webrtc.peer] connected",peerId:r})})}attachErrorListener(e,r,i,o,s){e.on("error",a=>{if(!(s(r)===e)){this.logger.debug("[peer-event] error (stale, ignored)",{peerId:i});return}let u=this.channelManager.getLastPeerState(r),l=tM(a,u);this.logger.error("[peer-event] error",{peerId:i,message:l,connected:e.connected});let d=new Error(l);d.name=a?.name??"Error",this.reconnectService.state.transition(r,"FAILED"),o.next({type:"[session.transport.webrtc.peer] error",peerId:r,error:d})})}attachCloseListener(e,r,i,o,s){e.on("close",()=>{let a=s(r)===e;this.logger.info("[peer-event] close",{peerId:i,isCurrentPeer:a}),a?(this.reconnectService.state.transition(r,"CLOSED"),o.next({type:"[session.transport.webrtc.peer] close",peerId:r})):this.logger.debug("[peer-event] close (stale, ignored)",{peerId:i})})}attachDataListener(e,r,i,o,s,a){e.on("data",c=>{let u=JSON.parse(c.toString());if(this.logger.debug("[setupPeerEvents] Received data:",i,"type:",u?.type),u?.type==="peer-signal"){let l=s(r);l&&l.signal(u.signal);return}if(Xh(u)||ep(u)){a(r,u).catch(l=>{this.logger.error("[setupPeerEvents] Renegotiation failed:",i,l?.message||l)});return}o.next({type:"[session.transport.webrtc.peer] data",peerId:r,data:u})})}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var rM=(()=>{class t{constructor(){this.logger=j("PeerRenegotiationHandler"),this.channelManager=w(Dt),this.pendingRenegotiations=new Map}async createDynamicChannel(e,r,i,o){let s=o(e)?.channels;if(!s)throw new Error(`No peer connection: ${e}`);let a=s.createDataChannel(r,Ns[i]);return await this.waitForChannelOpen(a),this.channelManager.registerChannel(e,a),a}async handleRenegotiateSignal(e,r,i,o){let s=i(e)?.reactive;if(s)if(r.type==="[session.transport.webrtc.peer] renegotiate-offer"){let a=await s.applySignal({offer:r.sdp});if(!a)return;o.next({type:"[session.transport.webrtc.peer] renegotiate-answer",peerId:e,label:r.label,sdp:a.answer})}else await s.applySignal({answer:r.sdp}),this.resolvePending(e,r.label)}async handleRenegotiationMessage(e,r,i,o){let s=i(e)?.reactive;if(s)if(Xh(r)){let a=await s.applySignal({offer:r.sdp});if(!a)return;o(e,{type:"renegotiate-answer",sdp:a.answer,label:r.label})}else ep(r)&&(await s.applySignal({answer:r.sdp}),this.resolvePending(e,r.label))}resolvePending(e,r){let i=this.pendingRenegotiations.get(`${e}:${r}`);i&&(clearTimeout(i.timeoutId),i.resolve(),this.pendingRenegotiations.delete(`${e}:${r}`))}waitForChannelOpen(e,r=1e4){return new Promise((i,o)=>{if(e.readyState==="open")return i();let s=setTimeout(()=>o(new Error(`Channel open timeout: ${e.label}`)),r);e.onopen=()=>{clearTimeout(s),i()},e.onerror=a=>{clearTimeout(s),o(a)}})}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var iM=(()=>{class t{constructor(){this.logger=j("PeerLifecycleCoordinator"),this.channelManager=w(Dt)}async coordinateDisconnect(e,r){this.logger.info("[coordinateDisconnect] disconnecting peer:",e.substring(0,8),{connected:r?.connected??!1}),r&&await r.destroy(),this.channelManager.cleanupPeer(e)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var Yr=U(Q(),1);var np=(()=>{class t{constructor(){this.logger=j("PeerHandshakeCoordinator"),this.config=w(Oe),this.reconnectService=w(Kr),this.inFlight=new Map,this.inFlightInitiator=new Map}async beginHandshakeFromOffer(e,r,i,o={}){return this.runHandshake(e,i,o,async()=>{await i.ensurePeer()})}async beginHandshakeAsInitiator(e,r,i={}){let o=this.inFlightInitiator.get(e);if(o)return this.logger.info("[handshake] joining existing in-flight initiator handshake (race dedup)",{peerId:e.substring(0,8)}),o;let s=this.withOverallDeadline(e,this.runHandshake(e,r,i,async()=>{await r.ensurePeer()}),i);return this.inFlightInitiator.set(e,s),s.finally(()=>{this.inFlightInitiator.get(e)===s&&this.inFlightInitiator.delete(e)}),s}withOverallDeadline(e,r,i){let o=Math.max((i.timeoutMs??this.config.connectionTimeoutMs())*3,45e3),s=null,a=new Promise(c=>{s=setTimeout(()=>{this.logger.warn("[handshake] overall deadline exceeded, aborting stuck attempt",{peerId:e.substring(0,8),deadlineMs:o}),this.abort(e),c({outcome:"timeout",error:new Error(`handshake overall deadline ${o}ms exceeded`)})},o)});return Promise.race([r,a]).finally(()=>{s&&clearTimeout(s)})}abort(e){let r=this.inFlight.get(e);r&&(this.logger.debug("[abort] aborting in-flight handshake",{peerId:e.substring(0,8)}),r.abort(),this.inFlight.delete(e))}abortForDisconnect(e){this.abort(e),this.inFlightInitiator.delete(e)&&this.logger.info("[abortForDisconnect] cleared in-flight initiator handshake (explicit disconnect)",{peerId:e.substring(0,8)})}async runHandshake(e,r,i,o){this.abortInFlight(e);let s=new AbortController;this.inFlight.set(e,s),this.transitionEnter(e);try{if(await o(),r.isConnected())return this.markConnected(e);if(s.signal.aborted)return this.markAborted(e,r);if(r.awaitsInPrologue)return this.markConnected(e);let a=i.timeoutMs??this.config.connectionTimeoutMs();return await this.awaitConnected(e,r.message$,a,s.signal),r.isConnected()?this.markConnected(e):s.signal.aborted?this.markAborted(e,r):this.markConnected(e)}catch(a){return this.handleFailure(e,r,s.signal,a)}finally{this.inFlight.get(e)===s&&this.inFlight.delete(e)}}abortInFlight(e){let r=this.inFlight.get(e);r&&(this.logger.info("[runHandshake] aborting prior in-flight handshake",{peerId:e.substring(0,8)}),r.abort(),this.inFlight.delete(e))}transitionEnter(e){let r=this.reconnectService.state.get(e);r||this.reconnectService.state.getOrCreate(e,!1),this.reconnectService.state.transition(e,"CONNECTING")||(this.reconnectService.state.resetOnExplicitConnect(e,r?.initiator??!1),this.reconnectService.state.transition(e,"CONNECTING"))}markConnected(e){return this.reconnectService.state.transition(e,"CONNECTED"),{outcome:"connected"}}async markAborted(e,r){return this.reconnectService.state.transition(e,"FAILED"),await r.disconnect(),{outcome:"aborted"}}async handleFailure(e,r,i,o){let s=o instanceof Error?o:new Error(String(o));if(r.isConnected())return this.markConnected(e);let a=s.name==="TimeoutError"||/timeout/i.test(s.message);return this.reconnectService.state.transition(e,"FAILED"),await r.disconnect(),i.aborted?{outcome:"aborted",error:s}:{outcome:a?"timeout":"failed",error:s}}async awaitConnected(e,r,i,o){if(o.aborted)throw new Error("aborted");await(0,Yr.firstValueFrom)(r.pipe((0,Yr.filter)(s=>s.type==="[session.transport.webrtc.peer] connected"&&s.peerId===e),(0,Yr.take)(1),(0,Yr.timeout)(i)))}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var Ot=U(Q(),1);var uc=(()=>{class t{constructor(){this.configService=w(Oe,{optional:!0}),this.tokenConfig=w(Bi,{optional:!0}),this.config=()=>{if(this.configService&&typeof this.configService.config=="function")return this.configService.config();if(this.tokenConfig)return this.tokenConfig;throw new Error("[PeerSessionAdapter] Neither WebRTCConfigService nor WEB_RTC_CONFIG provided")}}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();async function oM(t,n){for(let e=1;e<=n.maxAttempts;e++)try{return await t()}catch(r){if(n.onError?.(e,r),e<n.maxAttempts){let i=n.exponential?n.delay*Math.pow(2,e-1):n.delay;await new Promise(o=>setTimeout(o,i))}else throw r}throw new Error("Retry failed")}var rp=class{constructor(){this.forward=new Map,this.reverse=new Map}set(n,e){this.forward.set(n,e),this.reverse.set(e,n)}getByKey(n){return this.forward.get(n)}getByValue(n){return this.reverse.get(n)}deleteByKey(n){let e=this.forward.get(n);e!==void 0&&(this.forward.delete(n),this.reverse.delete(e))}deleteByValue(n){let e=this.reverse.get(n);e!==void 0&&(this.reverse.delete(n),this.forward.delete(e))}hasKey(n){return this.forward.has(n)}hasValue(n){return this.reverse.has(n)}clear(){this.forward.clear(),this.reverse.clear()}get size(){return this.forward.size}};function sM(t,n,e){let r=typeof t=="string"?n.get(t):t;if(!r)return!1;if(r.destroyed)return!0;let i=r.connectionState;if(i==="failed"||i==="closed")return!0;let o=typeof t=="string"?t:[...n.entries()].find(([,s])=>s===r)?.[0];if(i==="disconnected"){if(!o)return!0;let s=e.get(o);return s===void 0?(e.set(o,Date.now()),!1):Date.now()-s>3e3}return o&&e.delete(o),!1}function aM(t,n){let e=typeof t=="string"?n.get(t):t;if(!e)return!1;if(e.destroyed)return!0;let r=e.connectionState;return r==="failed"||r==="closed"||r==="disconnected"}function cM(t,n,e,r,i,o){let s=t.map.get(n);if(s&&!t.isPeerDead(s))return t.logger.debug("[ensurePeer] Reusing existing peer:",n.substring(0,8),"connected:",s.connected),s;s&&(t.logger.info("[ensurePeer] Destroying dead peer:",n.substring(0,8),{destroyed:s.destroyed,connectionState:s.connectionState}),t.disconnect(n));let a=t.selfPeerId(),c=a?a<n:void 0;t.logger.info("[ensurePeer] Creating new peer:",n.substring(0,8),"initiator:",e,"polite:",c),t.reconnectService.state.getOrCreate(n,e),t.reconnectService.state.transition(n,"CONNECTING");let u=t.sessionAdapter.create({initiator:e,polite:c});return t.eventHandler.setupPeerEvents(u,n,r,i,l=>t.map.get(l),o),t.map.set(n,u),u}var uM=(()=>{class t{constructor(){this.config=w(Oe),this.logger=j("PeerConnectionManager"),this.sessionAdapter=w(uc),this.eventHandler=w(nM),this.lifecycleCoordinator=w(iM),this.reconnectService=w(Kr),this.channelManager=w(Dt),this.map=new Map,this.disconnectedSinceMap=new Map}async connect(e,r,i,o,s){if(!this.isConnected(e)){if(this.map.has(e))try{await this.waitForConnected(e,i);return}catch{if(this.isConnected(e))return;this.disconnect(e)}await this.retryConnect(e,r,i,o,s)}}async retryConnect(e,r,i,o,s){try{await oM(()=>this.connectOnce(e,r,i,o,s),{maxAttempts:this.config.maxRetryCount(),delay:this.config.retryDelayMs(),onError:()=>{this.isConnected(e)||this.disconnect(e)}})}catch(a){if(this.isConnected(e))return;throw a}}ensurePeer(e,r,i,o,s){return cM({map:this.map,logger:this.logger,sessionAdapter:this.sessionAdapter,eventHandler:this.eventHandler,reconnectService:this.reconnectService,selfPeerId:()=>typeof this.config.peerId=="function"?this.config.peerId():"",isPeerDead:a=>this.isPeerDead(a),disconnect:a=>this.disconnect(a)},e,r,i,o,s)}isPeerDead(e){return sM(e,this.map,this.disconnectedSinceMap)}isPeerDeadIgnoringGrace(e){return aM(e,this.map)}connected$(e,r){return this.connectedWait?.(e)??r.pipe((0,Ot.filter)(i=>i.type==="[session.transport.webrtc.peer] connected"),(0,Ot.filter)(i=>i.peerId===e),(0,Ot.map)(()=>{}))}async connectOnce(e,r,i,o,s){this.ensurePeer(e,r,i,o,s),!this.isConnected(e)&&await(0,Ot.firstValueFrom)(this.connected$(e,i).pipe((0,Ot.take)(1),(0,Ot.timeout)(this.config.connectionTimeoutMs())))}async waitForConnected(e,r){await(0,Ot.firstValueFrom)(this.connected$(e,r).pipe((0,Ot.take)(1),(0,Ot.timeout)(this.config.connectionTimeoutMs())))}async disconnect(e){let r=this.map.get(e);try{await this.lifecycleCoordinator.coordinateDisconnect(e,r)}catch(i){this.logger.warn("[disconnect] cascade failed",{peerId:e.substring(0,8),err:String(i)})}finally{this.map.get(e)===r&&this.map.delete(e),this.disconnectedSinceMap.delete(e)}}isConnected(e){return this.map.get(e)?.connected??!1}hasPeer(e){return this.map.has(e)}getPeer(e){return this.map.get(e)}async dispose(){let e=Array.from(this.map.values()).map(r=>r.destroy());this.map.clear(),await Promise.all(e)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var Me=U(Q(),1);var fM=U(Q(),1);var lM=(()=>{class t{constructor(){this.logger=j("PeerHeartbeat")}static{this.PING_INTERVAL_MS=500}static{this.PONG_TIMEOUT_MS=5e3}static{this.HANDSHAKE_TIMEOUT_MS=6e4}static{this.BUFFER_PRESSURE_THRESHOLD=256*1024}start(e,r,i,o=()=>!0,s=()=>!1,a){let c=a?.pingIntervalMs??t.PING_INTERVAL_MS,u=a?.pongTimeoutMs??t.PONG_TIMEOUT_MS,l=a?.handshakeTimeoutMs??t.HANDSHAKE_TIMEOUT_MS,d=Date.now(),f=!1,p=0,m=-1,y=Math.ceil(u/c),b=D=>{try{let T=JSON.parse(String(D.data));if(T&&T.type==="pong")typeof T.seq=="number"?T.seq>m&&(m=T.seq):m=Math.max(m,p-1),f=!0;else if(T&&T.type==="ping"&&typeof T.t=="number"&&r.readyState==="open"&&o()){let K={type:"pong",t:T.t};typeof T.seq=="number"&&(K.seq=T.seq),r.send(JSON.stringify(K))}}catch{}};r.addEventListener("message",b);let E=setInterval(()=>{if(r.readyState!=="open"||!o())return;let D=Date.now();if(f&&p-1-m>=y)if(s())this.logger.debug(`[peer-heartbeat] active timeout deferred (wire active) peer=${e.substring(0,8)}`,{peerId:e.substring(0,8),sentPings:p,lastAckedSequence:m,diff:p-1-m,limit:y});else{this.logger.warn(`[peer-heartbeat] active timeout peer=${e.substring(0,8)}`,{peerId:e.substring(0,8),sentPings:p,lastAckedSequence:m,diff:p-1-m,limit:y}),i(e);return}if(!f&&D-d>l)if(s())this.logger.debug(`[peer-heartbeat] handshake timeout deferred (wire active) peer=${e.substring(0,8)}`,{peerId:e.substring(0,8),elapsed:D-d});else{this.logger.warn(`[peer-heartbeat] handshake timeout peer=${e.substring(0,8)}`,{peerId:e.substring(0,8),elapsed:D-d}),i(e);return}if(r.bufferedAmount>t.BUFFER_PRESSURE_THRESHOLD){this.logger.warn(`[peer-heartbeat] buffer pressure peer=${e.substring(0,8)}`,{peerId:e.substring(0,8),bufferedAmount:r.bufferedAmount,threshold:t.BUFFER_PRESSURE_THRESHOLD}),i(e);return}try{let T=p;p++,r.send(JSON.stringify({type:"ping",t:D,seq:T}))}catch(T){this.logger.warn(`[peer-heartbeat] send-failed peer=${e.substring(0,8)}`,{peerId:e.substring(0,8),err:String(T)})}},c);return()=>{clearInterval(E),r.removeEventListener("message",b)}}isPong(e,r){try{let i=JSON.parse(r);return i&&i.type==="pong"}catch{return!1}}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var dM=ps.heartbeat.buildLabel(),ip=(()=>{class t{constructor(){this.logger=j("PeerHeartbeatCoordinator"),this.heartbeat=w(lM),this.channelManager=w(Dt),this.stops=new Map,this.silentFailSubject=new fM.Subject,this.silentFail$=this.silentFailSubject.asObservable()}static{this.WIRE_STALL_BYTES=512}async start(e,r=()=>!0,i){this.stop(e);let o=await this.channelManager.createChannelAsync(e,dM,"heartbeat"),s=o,a=()=>{let u=this.channelManager.getPeerChannels(e);if(!u)return!1;let l=!1;for(let[d,f]of u)if(d!==dM&&f.readyState==="open"){l=!0;break}return l?o.bufferedAmount<=t.WIRE_STALL_BYTES:!1},c=this.heartbeat.start(e,s,u=>this.silentFailSubject.next({peerId:u}),r,a,i);this.stops.set(e,c),this.logger.debug("[start] heartbeat started",{peerId:e.substring(0,8)})}stop(e){let r=this.stops.get(e);r&&(r(),this.stops.delete(e),this.logger.debug("[stop] heartbeat stopped",{peerId:e.substring(0,8)}))}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var Qn=U(Q(),1);function hM(t,n,e,r=()=>Date.now()){let i=r(),o=s=>{let a=r();e.next({peerId:t,event:s,at:a,elapsedMs:a-i})};return{iceRestart$:()=>(0,Qn.defer)(()=>(o("tier1-attempt"),n.iceRestart$())).pipe((0,Qn.tap)({complete:()=>o("tier1-ok")})),fullReconnect$:()=>(0,Qn.defer)(()=>(o("tier2-attempt"),n.fullReconnect$())),onReconnected:s=>{o("tier2-ok"),n.onReconnected(s)},cleanup:()=>{o("exhausted"),n.cleanup()}}}function pM(t){return t.pipe((0,Qn.filter)(n=>n.event==="exhausted"),(0,Qn.map)(({peerId:n})=>({peerId:n})))}function Zr(t){return t.substring(0,8)}function mM(t,n){return t.subscribe(e=>{n.debug("[recovery-event]",{peerId:Zr(e.peerId),event:e.event,elapsedMs:e.elapsedMs})})}var Rs=U(Q(),1);var op=U(Q(),1);function gM(t,n){return t.pipe((0,op.switchMap)(()=>new op.Observable(e=>{let r=n();return e.next(r.value),()=>r.teardown()})))}var sp=U(Q(),1);function yM(t){return t.lifecycle$.pipe((0,sp.distinctUntilChanged)(),(0,sp.filter)(n=>n==="interrupted"||n==="failed")).subscribe(n=>{n==="interrupted"?t.restartIce():t.reconnect()})}var vM=U(Q(),1);function _M(t,n){return(0,vM.using)(()=>{let e=t();return{peer:e,unsubscribe:()=>e.close()}},e=>n(e.peer))}function bM(t,n){return gM(t,()=>({value:_M(n,e=>(0,Rs.merge)(e.lifecycle$,new Rs.Observable(()=>yM(e)))),teardown:()=>{}})).pipe((0,Rs.switchMap)(e=>e))}var Ie=U(Q(),1);var wM=t=>"peerId"in t&&typeof t.peerId=="string",EM=t=>t.type==="recovery-exhausted";function ap(t){return{peerId:t,phase:"idle",generation:0,attachGeneration:0,tier2InFlight:!1,present:!0}}var cp=t=>t.phase==="exhausted";function SM(t,n){switch(n.type){case"[session.transport.webrtc.peer] connected":return{...t,phase:"connected",generation:t.generation+1,attachGeneration:t.tier2InFlight?t.attachGeneration:t.attachGeneration+1};case"tier2-started":return{...t,phase:"recovering",tier2InFlight:!0};case"tier2-ended":return{...t,tier2InFlight:!1};case"recovery-exhausted":return{...t,phase:"exhausted",tier2InFlight:!1};case"peer-appeared":return t.present?t:{...t,present:!0};case"peer-lost":return t.present?{...t,present:!1}:t;case"[session.transport.webrtc.peer] error":case"heartbeat-silent-fail":case"peer-unhealthy":return t.phase==="connected"?{...t,phase:"idle"}:t;case"[session.transport.webrtc.peer] close":return t.tier2InFlight?t:t.phase==="connected"?{...t,phase:"idle"}:t;default:return t}}function CM(t,n){let e=new Ie.Subject;return t.pipe((0,Ie.groupBy)(r=>r.peerId,{duration:r=>(0,Ie.merge)(r.pipe((0,Ie.filter)(EM)),e.pipe((0,Ie.filter)(i=>i===r.key)))}),(0,Ie.mergeMap)(r=>{let i={dispatched:!1},o=r.pipe((0,Ie.scan)((c,u)=>({snapshot:SM(c.snapshot,u),prev:c.snapshot,event:u}),{snapshot:ap(r.key),prev:ap(r.key),event:null}),(0,Ie.share)()),s=o.pipe((0,Ie.tap)(({snapshot:c,event:u})=>{u&&CJ(u,c,i,n)}),(0,Ie.ignoreElements)()),a=o.pipe((0,Ie.map)(({snapshot:c})=>c),(0,Ie.distinctUntilChanged)((c,u)=>c.attachGeneration===u.attachGeneration&&cp(c)===cp(u)),(0,Ie.switchMap)(c=>c.attachGeneration===0||cp(c)?Ie.EMPTY:n.lifecycle$(c.peerId)),(0,Ie.ignoreElements)());return(0,Ie.merge)(o.pipe((0,Ie.map)(({snapshot:c})=>c)),s,a).pipe((0,Ie.catchError)(c=>{n.onGroupError(r.key,c);try{n.stopHeartbeat(r.key),n.disconnect(r.key)}catch{}return e.next(r.key),(0,Ie.of)({...ap(r.key),phase:"exhausted"})}))}),(0,Ie.share)())}function CJ(t,n,e,r){switch(t.type){case"[session.transport.webrtc.peer] error":r.stopHeartbeat(t.peerId),r.disconnect(t.peerId);return;case"[session.transport.webrtc.peer] close":if(r.isPcConnected(t.peerId)||n.tier2InFlight||(r.stopHeartbeat(t.peerId),e.dispatched))return;e.dispatched=!0,r.disconnect(t.peerId);return;case"[session.transport.webrtc.peer] connected":e.dispatched=!1,r.startHeartbeat(t.peerId);return;case"heartbeat-silent-fail":r.stopHeartbeat(t.peerId),r.disconnect(t.peerId);return;case"peer-unhealthy":r.stopHeartbeat(t.peerId),r.disconnect(t.peerId);return;default:return}}var tt=U(Q(),1);var Jn=U(Q(),1);function up(t,n,e){return(0,Jn.defer)(()=>(t.restartIce(),n.pipe((0,Jn.map)(r=>{if(r==="failed")throw new Error("[restartIce] pc failed during ICE restart");return r}),(0,Jn.first)(r=>r==="connected"),(0,Jn.timeout)(e),(0,Jn.map)(()=>{}))))}var Dn=U(Q(),1);var Xn=U(Q(),1),Mt=U(Ni(),1);var kb={n1IceRestart:2,n2FullReconnect:20,iceRestartTimeoutMs:6e3,initialBackoffMs:200,maxBackoffMs:1e4};function Lb(t,n,e=Math.random){if(n<=1)return 0;let r=Math.min(t.initialBackoffMs*Math.pow(2,n-1),t.maxBackoffMs);return Math.floor(e()*r)}function IM(t,n,e,r=()=>(0,Xn.of)(0)){let i=s=>(0,Xn.defer)(r).pipe((0,Mt.take)(1),(0,Mt.switchMap)(()=>s())),o=i(()=>t.fullReconnect$()).pipe((0,Mt.tap)(s=>t.onReconnected(s)),(0,Mt.retry)({count:n.n2FullReconnect,delay:(s,a)=>(0,Xn.timer)(Lb(n,a))}),(0,Mt.catchError)(()=>(t.cleanup(),Xn.EMPTY)));return e?o:i(()=>t.iceRestart$().pipe((0,Mt.timeout)(n.iceRestartTimeoutMs))).pipe((0,Mt.retry)({count:n.n1IceRestart,delay:(s,a)=>(0,Xn.timer)(Lb(n,a))}),(0,Mt.catchError)(()=>o))}function TM(t){let n=new Dn.BehaviorSubject(t.reactivePeer),e=new Dn.Subject,r=s=>({...s,onReconnected:a=>{s.onReconnected(a);let c=n.value;n.next(t.nextGeneration(a)),c.close()}}),i=(0,Dn.merge)(e,t.externalDeath$).pipe((0,Dn.exhaustMap)(s=>IM(r(t.tiers()),t.cfg,s.skipIce,t.retryGate))).subscribe(),o=!1;return{lifecycle$:n.pipe((0,Dn.switchMap)(s=>s.lifecycle$)),restartIce:()=>e.next({skipIce:!1}),reconnect:()=>e.next({skipIce:!0}),close:()=>{o||(o=!0,i.unsubscribe(),n.value.close(),n.complete(),e.complete())}}}function DM(t){if(!t?.reactive||!t.restartIce)return;let{reactive:n}=t;return{lifecycle$:n.lifecycle$,restartIce:()=>t.restartIce(),get connectionState(){return t.connectionState}}}function IJ(t,n){let e=(r,i)=>r.pipe((0,tt.filter)(o=>o.peerId===t),(0,tt.filter)(()=>n.autoReconnect()&&!n.state.isReconnecting(t)),(0,tt.map)(()=>({skipIce:!0,source:i})));return(0,tt.merge)(e(n.silentFail$,"heartbeat"),e(n.sendFailed$,"send-failed"),e(n.peerUnhealthy$,"zombie"))}async function TJ(t,n){let e=n.state.getInitiator(t)??!0;n.state.markReconnecting(t,!0),await n.disconnect(t),await n.connect(t,e)}function xJ(t,n){return{iceRestart$:()=>(0,tt.defer)(()=>{let e=n.getRecoveryPeer(t);if(!e)throw new Error("[recovery] no peer for iceRestart");return n.logger.info("[recovery] Tier1 restartIce",{peerId:Zr(t)}),up(e,e.lifecycle$,kb.iceRestartTimeoutMs)}),fullReconnect$:()=>(0,tt.defer)(()=>(n.logger.warn("[recovery] Tier2 full reconnect",{peerId:Zr(t)}),(0,tt.from)(TJ(t,n)).pipe((0,tt.map)(()=>{let e=n.getRecoveryPeer(t);if(!e)throw new Error("[recovery] no peer after reconnect");if(e.connectionState!=="connected")throw new Error(`[recovery] reconnect did not yield connected pc (state=${e.connectionState})`);return e}),(0,tt.finalize)(()=>n.state.markReconnecting(t,!1))))),onReconnected:()=>{n.logger.info("[recovery] reconnected, re-watch",{peerId:Zr(t)})},cleanup:()=>{n.logger.warn("[recovery] Tier3 cleanup (recovery exhausted)",{peerId:Zr(t)}),n.disconnect(t),n.onExhausted(t)}}}var xM=t=>({lifecycle$:t.lifecycle$,close:()=>{}});function OM(t,n){let e=n.getRecoveryPeer(t);if(!e)return{lifecycle$:tt.NEVER,restartIce:()=>{},reconnect:()=>{},close:()=>{}};let r=o=>n.logger.info("[recovery] trigger",{peerId:Zr(t),source:o.source,skipIce:o.skipIce}),i=TM({reactivePeer:xM(e),externalDeath$:IJ(t,n).pipe((0,tt.tap)(r)),tiers:()=>hM(t,xJ(t,n),n.recoveryEvents$),cfg:kb,nextGeneration:xM,retryGate:()=>n.presentGate$(t)});return{...i,restartIce:()=>{r({skipIce:!1,source:"pc-state"}),i.restartIce()},reconnect:()=>{r({skipIce:!0,source:"pc-state"}),i.reconnect()}}}function MM(t,n,e,r){if(!t||t.connected){let i=e.type;(i==="offer"||i==="answer")&&r("[handleSignal] drop",{peerId:n.substring(0,8),hasPeer:!!t,connected:t?.connected===!0,sdpType:i});return}t.signal(e)}function AM(t){return!t||t.destroyed?!1:t.connectionState===void 0?!0:t.connectionState!=="closed"&&t.connectionState!=="failed"&&t.signalingState!=="closed"}function NM(t,n,e,r){if(!t)return r.logger.warn("[send] Peer not found:",n.substring(0,8)),!1;if(!t.connected)return r.logger.warn("[send] Peer not connected:",n.substring(0,8)),!1;try{return t.send(JSON.stringify(e)),!0}catch(i){return r.logger.error("[send] Failed:",n.substring(0,8),i),r.onSendFailed(n),!1}}var ks=(()=>{class t{attachPresence(e){this.presenceSource$.next(e)}constructor(){this.logger=j("PeerService"),this.connectionManager=w(uM),this.handshakeCoordinator=w(np),this.renegotiationHandler=w(rM),this.reconnectService=w(Kr),this.heartbeatCoordinator=w(ip),this.config=w(Oe),this.channelManager=w(Dt),this.message$=new Me.ReplaySubject(1),this.sendFailed$=new Me.Subject,this.recoveryEvents$=new Me.Subject,this.recoveryExhausted$=pM(this.recoveryEvents$),this.internalEvents$=new Me.Subject,this.presenceSource$=new Me.ReplaySubject(1),this.presenceEvents$=this.presenceSource$.pipe((0,Me.switchMap)(e=>e)),this.wiringDeps={getRecoveryPeer:e=>DM(this.connectionManager.getPeer(e)),disconnect:e=>this.connectionManager.disconnect(e),connect:(e,r)=>this.connectionManager.connect(e,r,this.message$,(i,o)=>this.send(i,o),(i,o)=>this.handleRenegotiationMessage(i,o)),state:{getInitiator:e=>this.reconnectService.state.getInitiator(e),markReconnecting:(e,r)=>{this.internalEvents$.next({type:r?"tier2-started":"tier2-ended",peerId:e}),this.reconnectService.state.markReconnecting(e,r)},isReconnecting:e=>this.snapshotOf(e)?.tier2InFlight===!0},autoReconnect:()=>this.config.autoReconnect(),presentGate$:e=>(0,Me.defer)(()=>this.snapshotOf(e)?.present!==!1?(0,Me.of)(0):this.peerState$.pipe((0,Me.filter)(r=>r.peerId===e&&r.present),(0,Me.take)(1))),silentFail$:this.heartbeatCoordinator.silentFail$,sendFailed$:this.sendFailed$,peerUnhealthy$:this.channelManager.peerUnhealthy$,recoveryEvents$:this.recoveryEvents$,onExhausted:e=>this.internalEvents$.next({type:"recovery-exhausted",peerId:e}),logger:this.logger},this.orchestratorEvents$=(0,Me.merge)(this.message$.pipe((0,Me.filter)(wM)),this.heartbeatCoordinator.silentFail$.pipe((0,Me.map)(({peerId:e})=>({type:"heartbeat-silent-fail",peerId:e}))),this.channelManager.peerUnhealthy$.pipe((0,Me.map)(({peerId:e})=>({type:"peer-unhealthy",peerId:e}))),this.internalEvents$,this.presenceEvents$),this.peerState$=CM(this.orchestratorEvents$,{startHeartbeat:e=>{this.heartbeatCoordinator.start(e,()=>AM(this.connectionManager.getPeer(e))).catch(r=>this.logger.warn("[heartbeat] start failed",{peerId:e.substring(0,8),err:String(r)}))},stopHeartbeat:e=>this.heartbeatCoordinator.stop(e),disconnect:e=>this.disconnect(e),isPcConnected:e=>this.connectionManager.getPeer(e)?.connected===!0,lifecycle$:e=>bM((0,Me.of)(0),()=>OM(e,this.wiringDeps)),onGroupError:(e,r)=>this.logger.warn("[orchestrator] group error (isolated)",{peerId:e.substring(0,8),err:String(r)})}),this.stateProjection=new Map,this.destroyed$=new Me.Subject,this.peerState$.pipe((0,Me.takeUntil)(this.destroyed$)).subscribe(e=>this.stateProjection.set(e.peerId,e)),this.connectionManager.connectedWait=e=>this.connectedOf$(e),mM(this.recoveryEvents$,this.logger)}snapshotOf(e){return this.stateProjection.get(e)}connectedOf$(e){return(0,Me.defer)(()=>this.snapshotOf(e)?.phase==="connected"?(0,Me.of)(void 0):this.peerState$.pipe((0,Me.filter)(r=>r.peerId===e&&r.phase==="connected"),(0,Me.take)(1),(0,Me.map)(()=>{})))}async connect(e,r){this.reconnectService.state.resetOnExplicitConnect(e,r);let i=await this.handshakeCoordinator.beginHandshakeAsInitiator(e,{message$:this.message$,awaitsInPrologue:!0,ensurePeer:async()=>{await this.connectionManager.connect(e,r,this.message$,(o,s)=>this.send(o,s),(o,s)=>this.handleRenegotiationMessage(o,s))},disconnect:()=>this.connectionManager.disconnect(e),isConnected:()=>this.connectionManager.isConnected(e)});if(i.outcome!=="connected")throw i.error??new Error(`handshake ${i.outcome}`)}ensurePeer(e,r){return this.reconnectService.state.resetOnExplicitConnect(e,r),this.connectionManager.ensurePeer(e,r,this.message$,(i,o)=>this.send(i,o),(i,o)=>this.handleRenegotiationMessage(i,o))}handleSignal(e,r){MM(this.connectionManager.getPeer(e),e,r,(i,o)=>this.logger.warn(i,o))}send(e,r){return NM(this.connectionManager.getPeer(e),e,r,{logger:this.logger,onSendFailed:i=>{this.disconnect(i),this.sendFailed$.next({peerId:i})}})}disconnect(e){this.handshakeCoordinator.abortForDisconnect(e),this.connectionManager.disconnect(e)}async disconnectAndAwait(e){this.handshakeCoordinator.abortForDisconnect(e),await this.connectionManager.disconnect(e)}isConnected(e){return this.connectionManager.isConnected(e)}hasPeer(e){return this.connectionManager.hasPeer(e)}isPeerDead(e){return this.connectionManager.isPeerDead(e)}isPeerDeadIgnoringGrace(e){return this.connectionManager.isPeerDeadIgnoringGrace(e)}getConnectedPeerIds(){return Array.from(this.connectionManager.map.keys())}async createDynamicChannel(e,r,i="reliable-ordered"){return this.renegotiationHandler.createDynamicChannel(e,r,i,o=>this.connectionManager.getPeer(o))}async handleRenegotiateSignal(e,r){return this.renegotiationHandler.handleRenegotiateSignal(e,r,i=>this.connectionManager.getPeer(i),this.message$)}async handleRenegotiationMessage(e,r){return this.renegotiationHandler.handleRenegotiationMessage(e,r,i=>this.connectionManager.getPeer(i),(i,o)=>this.send(i,o))}async dispose(){this.destroyed$.next(),this.destroyed$.complete(),await this.connectionManager.dispose()}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var lp=class{constructor(){this.map=new Map}add(n,e){let r=this.map.get(n);r?r.push(e):this.map.set(n,[e])}size(){return this.map.size}has(n){return this.map.has(n)}dispose(n){let e=this.map.get(n);if(e){for(let r of e)try{r.unsubscribe()}catch{}this.map.delete(n)}}disposeAll(){for(let[,n]of this.map)for(let e of n)try{e.unsubscribe()}catch{}this.map.clear()}};var On=U(Q(),1);var lc=U(Q(),1);var DJ=/\s(\d{1,3}\.\d{1,3}\.\d{1,3}\.0)\s\d+\styp host(\s|$)/;function PM(t){return t?DJ.test(t):!1}function OJ(t){if(Array.isArray(t))return t;if(typeof t!="object"||t===null)return[];let n=t;return Array.isArray(n.candidates)?n.candidates:n.candidate?[n.candidate]:"candidate"in n||"sdpMid"in n||"sdpMLineIndex"in n?[n]:[]}function jb(t){let{message$:n,signaling:e,peer:r,destroy$:i,dispatch:o,myHashedId:s,logger:a}=t;a.info("[signaling:candidate:setup] myHashedId",{myHashedId:s?.slice(0,16),len:s?.length}),n.pipe((0,lc.filter)(c=>c.payload.type==="candidates"),(0,lc.filter)(c=>{let u=c.payload.to===s;return u||a.info("[signaling:candidate:to-mismatch]",{to:c.payload.to?.slice(0,16),myHashedId:s?.slice(0,16),from:c.payload.from?.slice(0,16)}),u}),(0,lc.takeUntil)(i)).subscribe(async c=>{let u=await e.getSenderPublicKey(c.payload.from);if(!u)return;let l=c.payload.data,d=In(l)?await e.decryptMessageData(l,u):l;if(d==null)return;let f=OJ(d);for(let p of f)if(p){if(PM(p.candidate??void 0)){a.info("[candidate-handler] drop junk host candidate (.0 network address)",{candidate:p.candidate?.slice(0,80)});continue}r.handleSignal(u,{candidate:p}),o({type:"[session.transport.webrtc] ice-candidate-received",peerId:u,candidate:p?.candidate})}})}var dc=U(Q(),1);function Fb(t){let{message$:n,signaling:e,peer:r,destroy$:i,dispatch:o,myHashedId:s}=t;n.pipe((0,dc.filter)(a=>a.payload.type==="answer"),(0,dc.filter)(a=>a.payload.to===s),(0,dc.takeUntil)(i)).subscribe(async a=>{let c=await e.getSenderPublicKey(a.payload.from);if(!c)return;let u=a.payload.data,l=In(u)?await e.decryptMessageData(u,c):u.sdp;l!==null&&($b(o,c,l),r.handleSignal(c,l),o({type:"[session.transport.webrtc] answer-received",peerId:c}))})}function RM(t){if(!t)return;let n=t.split(/\r?\n/),e=!1;for(let r of n){if(/^m=application\b/.test(r)){e=!0;continue}if(/^m=/.test(r)){e=!1;continue}if(!e)continue;let i=r.match(/^a=max-message-size:(.+)$/);if(!i)continue;let o=i[1].trim(),s=Number(o);return!Number.isFinite(s)||s<=0?void 0:Math.floor(s)}}var MJ=4e4;function kM(t){let{message$:n,signaling:e,peer:r,registry:i,destroy$:o,dispatch:s,coordinator:a}=t;n.pipe((0,On.filter)(c=>c.payload.type==="offer"),(0,On.groupBy)(c=>c.payload.from),(0,On.mergeMap)(c=>c.pipe((0,On.throttleTime)(500))),(0,On.takeUntil)(o)).subscribe(async c=>{if(Date.now()-c.payload.timestamp>MJ)return;let l=await e.getSenderPublicKey(c.payload.from);if(!l)return;let d=c.payload.data,f=In(d)?await e.decryptMessageData(d,l):d.sdp;if(f!==null){$b(s,l,f);try{await AJ(r,i,l,f,a)}catch(p){t.logger.error("[setupOfferHandler] runOfferHandshake threw",{err:p?.message||String(p)})}s({type:"[session.transport.webrtc] offer-received",peerId:l})}})}function $b(t,n,e){if(!e||typeof e.sdp!="string")return;let r=RM(e.sdp);r!==void 0&&t({type:"[session.transport.webrtc] sdp-caps-received",peerId:n,maxMessageSize:r})}async function AJ(t,n,e,r,i){let o=r,s=()=>{t.hasPeer(e)&&t.isPeerDeadIgnoringGrace(e)&&(n.dispose(e),t.disconnect(e)),t.ensurePeer(e,!1),t.handleSignal(e,o)};if(!i){s();return}await i.beginHandshakeFromOffer(e,o,{message$:t.message$,awaitsInPrologue:!0,ensurePeer:()=>{s()},disconnect:()=>t.disconnect(e),isConnected:()=>t.isConnected(e)},{timeoutMs:3e4})}var _t=U(Q(),1);var un=U(Q(),1);function qb(t){let{peerListService:n,peer:e,registry:r,destroy$:i,dispatch:o}=t,s=FO(n.peers$);return e.attachPresence(s.pipe((0,un.map)(a=>a.type==="removed"?{type:"peer-lost",peerId:a.peer.publicKey??a.peer.id}:{type:"peer-appeared",peerId:a.peer.publicKey??a.peer.id}),(0,un.takeUntil)(i))),s.pipe((0,un.filter)(a=>a.type!=="removed"),(0,un.takeUntil)(i)).subscribe(({peer:a})=>{o({type:"[session.transport.webrtc] announce-received",peerId:a.publicKey??a.id,roles:a.roles??[],name:a.name,serverName:a.roles?.includes("server")?a.name:void 0})}),s.pipe((0,un.filter)(a=>a.type==="removed"),(0,un.takeUntil)(i)).subscribe(({peer:a})=>{let c=a.publicKey??a.id;e.isConnected(c)||(r.dispose(c),e.disconnect(c),o({type:"[session.transport.webrtc] peer-close",peerId:c}))}),un.EMPTY}function Bb(t){return t instanceof Error?t.stack??t.message:String(t)}function LM(t){let{peer:n,signaling:e,registry:r,logger:i,destroy$:o,dispatch:s}=t,a=new Map;function c(u){let l=a.get(u);!l||l.flushing||(l.flushing=!0,(async()=>{for(;l.queue.length>0;){let d=l.queue.splice(0,l.queue.length);try{await e.sendCandidates(u,d)}catch(f){i.error("[signaling] Send failed:",Bb(f))}}l.flushing=!1})())}n.message$.pipe((0,_t.filter)(u=>u.type==="[session.transport.webrtc.peer] offer"),(0,_t.takeUntil)(o)).subscribe(u=>{s({type:"[session.transport.webrtc] offer-sent",peerId:u.peerId}),e.sendOffer(u.peerId,u.data).catch(l=>i.error("[signaling] Send failed:",Bb(l)))}),n.message$.pipe((0,_t.filter)(u=>u.type==="[session.transport.webrtc.peer] answer"),(0,_t.takeUntil)(o)).subscribe(u=>{s({type:"[session.transport.webrtc] answer-sent",peerId:u.peerId}),e.sendAnswer(u.peerId,u.data).catch(l=>i.error("[signaling] Send failed:",Bb(l)))}),n.message$.pipe((0,_t.filter)(u=>u.type==="[session.transport.webrtc.peer] ice-candidate"),(0,_t.takeUntil)(o)).subscribe(u=>{let l=u.to,d=u.data?.candidate;s({type:"[session.transport.webrtc] ice-candidate-sent",peerId:l,candidate:d?.candidate});let f=a.get(l);f||(f={queue:[],flushing:!1},a.set(l,f)),f.queue.push(d),c(l)}),n.message$.pipe((0,_t.filter)(u=>u.type==="[session.transport.webrtc.peer] connected"),(0,_t.takeUntil)(o)).subscribe(u=>s({type:"[session.transport.webrtc] peer-connected",peerId:u.peerId})),n.message$.pipe((0,_t.filter)(u=>u.type==="[session.transport.webrtc.peer] data"),(0,_t.takeUntil)(o)).subscribe(u=>s({type:"[session.transport.webrtc] data",data:u.data,peerId:u.peerId})),n.message$.pipe((0,_t.filter)(u=>u.type==="[session.transport.webrtc.peer] error"),(0,_t.takeUntil)(o)).subscribe(u=>s({type:"[session.transport.webrtc] error",error:u.error,peerId:u.peerId})),n.message$.pipe((0,_t.filter)(u=>u.type==="[session.transport.webrtc.peer] close"),(0,_t.takeUntil)(o)).subscribe(u=>{r.dispose(u.peerId),a.delete(u.peerId),s({type:"[session.transport.webrtc] close",peerId:u.peerId})})}var FM=(()=>{class t{constructor(){this.logger=j("WebRTCSignalingHandler"),this.config=w(Oe),this.signaling=w(zh),this.peerListService=w(As),this.peer=w(ks),this.handshakeCoordinator=w(np),this.registry=new lp}get message$(){return this.signaling.message$}setupSignalingHandlers(e,r,i){let o={message$:this.message$,signaling:this.signaling,peerListService:this.peerListService,peer:this.peer,registry:this.registry,logger:this.logger,destroy$:r,dispatch:i,coordinator:this.handshakeCoordinator};kM(o),Fb({...o,myHashedId:e}),jb({...o,myHashedId:e}),qb({...o,config:this.config}),LM({...o,config:this.config}),r.pipe((0,jM.take)(1)).subscribe(()=>this.registry.disposeAll())}dispose(e){this.registry.dispose(e)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var Jt=U(Q(),1);var Ls=U(Q(),1);var Hb=j("AnnounceSchedulerService");function $M(t){let{roles:n,tag:e,sendAnnounce:r,onTick:i,authService:o}=t;i();try{let s=r(n);BM(s,qM).then(()=>{}).catch(async a=>{let c=a?.message||a;Hb.warn(`${e} Failed to send announce (network may be unavailable):`,c),String(c).includes("Socket closed")&&o&&(Hb.info(`${e} Attempting token refresh after socket closed`),await o.refreshIdToken())})}catch(s){Hb.error(`${e} sync error caught while invoking sendAnnounce`,s)}}var HM=new _e("AUTH_REFRESH_SERVICE"),qM=1e4,Ub=class extends Error{constructor(n){super(`sendAnnounce timed out after ${n}ms`),this.timeoutMs=n,this.name="SendAnnounceTimeoutError"}};function BM(t,n){let e,r=new Promise((i,o)=>{e=setTimeout(()=>o(new Ub(n)),n)});return Promise.race([t,r]).finally(()=>{e!==void 0&&clearTimeout(e)})}var UM=U(Q(),1),VM=U(Ni(),1);var fc=j("AnnounceSchedulerService");function WM(t){let{roles:n,intervalMs:e,destroy$:r,priorSubscription:i,fireAnnounce:o,reSubscribe:s}=t;fc.info("[signaling:announce] subscribeInterval ENTRY",{intervalMs:e,hadPriorSubscription:!!i}),i?.unsubscribe();let a=0;return(0,UM.interval)(e).pipe((0,VM.takeUntil)(r)).subscribe({next:()=>{a++,fc.info("[signaling:announce] interval TICK fired",{tickCount:a,intervalMs:e}),o(n),fc.info("[signaling:announce] interval TICK callback complete",{tickCount:a})},error:c=>{fc.error("[signaling:announce] interval subscription ERRORED, re-subscribing",{tickCount:a,error:c instanceof Error?{name:c.name,message:c.message,stack:c.stack}:c}),s()},complete:()=>{fc.info("[signaling:announce] interval subscription COMPLETED (takeUntil destroy$ fired)",{tickCount:a})}})}var GM=(()=>{class t{constructor(){this.signalingService=w(zh),this.configService=w(Oe),this.authService=w(HM,{optional:!0}),this.channels=w(fs,{optional:!0})??[],this.logger=j("AnnounceSchedulerService"),this.destroy$=new Ls.Subject,this._lastAnnounceAt=an(0),this.intervalSubscription=null,this.lastAnnounceAt=this._lastAnnounceAt.asReadonly()}async start(e){if(this.logger.info("[start] Starting with roles:",e),!this.configService.config().identity&&!this.configService.peerId()){this.logger.warn("[start] Identity not configured, skipping announce");return}let r=this.channels.filter(i=>i.isAvailable&&i.reconnect$).map(i=>i.reconnect$);if(r.length>0){this.logger.info("[start] presence channels detected, reconnect-driven mode",{channels:this.channels.filter(i=>i.reconnect$).map(i=>i.name)}),(0,Ls.merge)(...r).pipe((0,Ls.takeUntil)(this.destroy$)).subscribe(()=>this.fireAnnounce(e,"[presence]"));return}this.fireAnnounce(e,"[start]"),this.subscribeIntervalHelper(e,3e4)}stop(){this.logger.info("[stop] Stopping scheduler"),this.destroy$.next(),this.intervalSubscription?.unsubscribe(),this.intervalSubscription=null}ngOnDestroy(){this.stop(),this.destroy$.complete()}subscribeIntervalHelper(e,r){this.intervalSubscription=WM({roles:e,intervalMs:r,destroy$:this.destroy$,priorSubscription:this.intervalSubscription,fireAnnounce:i=>this.fireAnnounce(i,"[interval]"),reSubscribe:()=>(this.subscribeIntervalHelper(e,r),this.intervalSubscription)})}fireAnnounce(e,r){$M({roles:e,tag:r,sendAnnounce:i=>this.signalingService.sendAnnounce(i),onTick:()=>this._lastAnnounceAt.set(Date.now()),authService:this.authService})}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var zM=(()=>{class t{constructor(){this.config=w(Oe),this.peerListService=w(As),this.announceScheduler=w(GM),this.peer=w(ks),this.signalingHandler=w(FM),this.logger=j("WebRTCCoreService"),this.myHashedId=null,this.destroy$=new Jt.ReplaySubject(1),this.message$=new Jt.ReplaySubject(1),this.peerId=dt(()=>this.config.peerId()),this.started=!1,this.peerIds$=this.peerListService.peers$.pipe((0,Jt.map)(e=>Array.from(e.keys())),(0,Jt.distinctUntilChanged)((e,r)=>JSON.stringify(e)===JSON.stringify(r)),(0,Jt.shareReplay)({bufferSize:1,refCount:!0})),this.peers$=this.peerListService.peers$.pipe((0,Jt.map)(e=>Array.from(e.values())),(0,Jt.shareReplay)({bufferSize:1,refCount:!0}))}async start(){this.started||(this.started=!0,this.myHashedId=this.config.signalingId(),await this.announceScheduler.start(this.config.config().roles),this.signalingHandler.setupSignalingHandlers(this.myHashedId,this.destroy$,e=>this.dispatch(e)))}dispatch(e){this.message$.next(e)}async connect(e){await this.peer.connect(e,!0)}async disconnect(e){await this.peer.disconnectAndAwait(e)}async close(){this.destroy$.next(),this.destroy$.complete(),this.destroy$=new Jt.ReplaySubject(1),this.started=!1,this.announceScheduler.stop(),this.peerListService.clear(),await this.peer.dispose()}send(e,r){this.peer.send(e,r)}broadcast(e){for(let r of this.peer.getConnectedPeerIds())this.send(r,e)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var ne=U(Q(),1);var Et=U(Q(),1);var PJ=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;function dp(t){return PJ.test(t)}var KM=1e4,fp=class{constructor(n,e){this.peerList=n,this.config=e,this.logger=j("ConnectionIdResolver"),this.idMap=new rp,this.activeKeys=new Set,this.immediateCache=new Map}cacheMapping(n,e){this.idMap.set(n,e)}lockActiveKey(n){this.activeKeys.add(n)}releaseActiveKey(n){this.activeKeys.delete(n)}hasActiveKey(n){return this.activeKeys.has(n)}forgetPeer(n){this.activeKeys.delete(n),this.idMap.deleteByKey(n),this.idMap.deleteByValue(n),this.immediateCache.delete(n)}tryResolveSync(n){return this.tryImmediate(n)??(dp(n)?void 0:n)}resolve$(n,e=KM){return(0,Et.defer)(()=>{let r=this.tryImmediate(n);return r!==void 0?(0,Et.of)(r):dp(n)?(this.logger.info("[ConnectionIdResolver] waiting peerList:",{peerId:n}),this.waitInPeerList(n).pipe((0,Et.timeout)(e),(0,Et.map)(i=>(this.cacheMapping(n,i),i)))):(0,Et.of)(n)})}resolve(n,e=KM){return new Promise((r,i)=>{this.resolve$(n,e).pipe((0,Et.take)(1)).subscribe({next:r,error:()=>i(new Error(`[ConnectionIdResolver] Failed to resolve publicKey for peerId: ${n}`))})})}resolveUuid(n){if(dp(n))return n;let e=this.idMap.getByValue(n);if(e)return e;let r=this.peerList.getPeerByPublicKey(n);if(r?.id)return this.cacheMapping(r.id,n),r.id;let i=this.config.config()?.identity?.peers??{};for(let[o,s]of Object.entries(i))if(s===n)return this.cacheMapping(o,n),o;throw new Error(`[ConnectionIdResolver] peerId \u3092 UUID \u7A7A\u9593\u306B\u89E3\u6C7A\u3067\u304D\u307E\u305B\u3093 (publicKey \u7D20\u901A\u3057\u7981\u6B62): ${n.slice(0,24)}\u2026 \u2014 peerList / identity.peers \u306B\u672A\u767B\u9332\u306E peer \u3067\u3059`)}tryImmediate(n){let e=this.immediateCache.get(n);if(e!==void 0)return e;let r;if(this.activeKeys.has(n)){let i=this.idMap.getByKey(n);i&&(r=i)}if(r===void 0){let i=this.peerList.getPeer(n);i?.publicKey&&(this.cacheMapping(n,i.publicKey),r=i.publicKey)}if(r===void 0){let i=this.idMap.getByKey(n);i&&(r=i)}if(r===void 0){let i=this.config.config()?.identity?.peers?.[n];i&&(this.cacheMapping(n,i),r=i)}return r!==void 0&&this.immediateCache.set(n,r),r}waitInPeerList(n){return this.peerList.peers$.pipe((0,Et.map)(e=>e.get(n)?.publicKey),(0,Et.filter)(e=>!!e),(0,Et.take)(1))}};var Qr=U(Q(),1),hp=class{constructor(){this.ready$$=new Qr.BehaviorSubject(new Set),this.maxMessageSizes=new Map,this.deadPeers=new Set,this.peerDead$$=new Qr.Subject,this.ready$=this.ready$$.asObservable(),this.peerDead$=this.peerDead$$.asObservable()}isReady(n){return this.ready$$.value.has(n)}observeReady(n){return this.ready$.pipe((0,Qr.map)(e=>e.has(n)),(0,Qr.distinctUntilChanged)())}markReady(n){if(this.deadPeers.delete(n),this.ready$$.value.has(n))return;let e=new Set(this.ready$$.value);e.add(n),this.ready$$.next(e)}unmarkReady(n){if(!this.ready$$.value.has(n))return;let e=new Set(this.ready$$.value);e.delete(n),this.ready$$.next(e)}setMaxMessageSize(n,e){this.maxMessageSizes.set(n,e)}getMaxMessageSize(n){return this.maxMessageSizes.get(n)}unsetMaxMessageSize(n){this.maxMessageSizes.delete(n)}forgetPeer(n){this.unmarkReady(n),this.unsetMaxMessageSize(n)}markDead(n,e){this.deadPeers.has(n)||(this.deadPeers.add(n),this.forgetPeer(n),this.peerDead$$.next({peerId:n,reason:e}))}};var js=U(Q(),1);function YM(t){let{webrtc:n,resolver:e,state:r,message$:i,selfPeerId:o,log:s,onPeerInvalidated:a}=t;n.message$.pipe((0,js.filter)(u=>u.type==="[session.transport.webrtc] data")).subscribe(u=>{let l=u.data,d=u.peerId;s("webrtc data",{peerId:d,dataType:l?.type}),l?.from&&l.from!==d&&e.cacheMapping(l.from,d);let f=e.resolveUuid(d);l?.type==="[session.transport] ready"&&l?.peerId&&r.markReady(f),i.next({...l,peerId:f})}),n.message$.pipe((0,js.filter)(u=>u.type==="[session.transport.webrtc] peer-connected")).subscribe(u=>n.send(u.peerId,{type:"[session.transport] ready",peerId:o()})),n.message$.pipe((0,js.filter)(u=>u.type==="[session.transport.webrtc] error")).subscribe(u=>{let l=u,d=e.resolveUuid(l.peerId);c(d,l.peerId),i.next({type:"[session.transport] error",error:l.error,peerId:d})}),n.message$.pipe((0,js.filter)(u=>u.type==="[session.transport.webrtc] sdp-caps-received")).subscribe(u=>{let l=u;r.setMaxMessageSize(l.peerId,l.maxMessageSize)}),n.message$.pipe((0,js.filter)(u=>u.type==="[session.transport.webrtc] close")).subscribe(u=>{let l=u.peerId,d=e.resolveUuid(l);c(d,l),i.next({type:"[session.transport] close",peerId:d})});function c(u,l){r.forgetPeer(u),l!==u&&r.forgetPeer(l),e.forgetPeer(u),l!==u&&e.forgetPeer(l),a?.(u),l!==u&&a?.(l)}}var RJ=j("peer-dead-aggregation");function ZM(t){let{state:n,channelManager:e,heartbeatCoordinator:r,peerService:i}=t;e.unhealthy$.subscribe(({peerId:o,reason:s})=>{s==="create-failed"&&i.disconnect(o)}),r.silentFail$.subscribe(({peerId:o})=>{n.markDead(o,"heartbeat-timeout")}),i.recoveryExhausted$.subscribe(({peerId:o})=>{n.markDead(o,"recovery-exhausted")}),e.connectionStateChanged$.subscribe(({peerId:o,state:s})=>{s==="failed"?n.markDead(o,"pc-failed"):s==="closed"&&n.markDead(o,"pc-closed")}),e.peerUnhealthy$.subscribe(({peerId:o})=>{let s=e.getLastPeerState(o),a=e.getPeerChannels(o),c=a?Object.fromEntries([...a].map(([u,l])=>[u,l.readyState])):void 0;RJ.warn("[isZombie] sctp-stall \u691C\u77E5 \u2014 3\u968E\u5C64\u306E state \u98DF\u3044\u9055\u3044\u3092\u8A18\u9332",{peerId:o,conn:s?.conn,ice:s?.ice,sctp:s?.sctp,dtls:s?.dtls,idleMs:s?.idleMs,channelReadyStates:c}),n.markDead(o,"sctp-stall")})}function QM(t){let{resolver:n,state:e,channelManager:r,channelSent$:i}=t;return{tryConnectionIdSync(o){return n.tryResolveSync(o)},bufferedAmountSync(o,s){let a=n.tryResolveSync(o);if(a!==void 0)return r.getBufferedAmount(a,s)},sendToChannelSync(o,s,a){let c=n.tryResolveSync(o);if(c===void 0)return!1;let u=r.send(c,s,a);return u&&i.next({peerId:o,label:s,bytes:typeof a=="string"?a.length:a.byteLength}),u},getRemoteMaxMessageSizeSync(o){let s=n.tryResolveSync(o);if(s!==void 0)return e.getMaxMessageSize(s)}}}var pp=class{constructor(n,e){this.peerId=n,this.ctx=e,this.invalidated=!1}invalidate(){this.invalidated=!0,this.cidPromise=void 0}ensureFresh(){if(this.invalidated)throw new Error(`[PeerHandle] stale handle for peer=${this.peerId.substring(0,16)} (peer disconnected). Re-acquire via transport.peerOf().`)}isReady(){return this.invalidated?!1:this.ctx.state.isReady(this.peerId)||this.ctx.resolver.hasActiveKey(this.peerId)}cid(){if(this.ensureFresh(),!this.cidPromise){let n=this.ctx.resolver.tryResolveSync(this.peerId);this.cidPromise=n!==void 0?Promise.resolve(n):this.ctx.resolver.resolve(this.peerId)}return this.cidPromise}async send(n){this.ctx.sent$.next({type:"[session.transport] data",peerId:this.peerId,data:n}),this.ctx.webrtc.send(await this.cid(),{type:"[session.transport] data",peerId:this.ctx.config.peerId(),data:n})}async createChannel(n,e="reliable-ordered"){await this.ctx.channelManager.createChannelAsync(await this.cid(),n,e)}async closeChannel(n){this.ctx.channelManager.closeChannel(await this.cid(),n)}async hasChannel(n){return this.ctx.channelManager.hasChannel(await this.cid(),n)}async waitForChannelOpen(n,e=5e3){return this.ctx.channelManager.waitForOpen(await this.cid(),n,e)}async getRemoteMaxMessageSize(){return this.ctx.state.getMaxMessageSize(await this.cid())}};function JM(t){let n=new Map;return{peerOf(e){let r=n.get(e);return r||(r=new pp(e,t),n.set(e,r)),r},invalidate(e){let r=n.get(e);r&&r.invalidate(),n.delete(e)}}}var kJ="waitForPeerConnection timeout";function XM(t){let n=t?.message;return typeof n=="string"&&n.includes(kJ)}function eA(t){let n=new Map,e=i=>{n.set(i.peerId,Date.now())};t.channelOpened$.subscribe(e),t.channelMessage$.subscribe(e);let r=t.thresholdMs??3e3;return{isRecentlyActive:(i,o=Date.now())=>o-(n.get(i)??Number.NEGATIVE_INFINITY)<r}}var Vb={control:{high:8192,low:4096,drainTimeoutMs:100,chunkSize:8192},terminal:{high:262144,low:65536,drainTimeoutMs:500,chunkSize:16384},http:{high:1048576,low:262144,drainTimeoutMs:500,chunkSize:16384},bulk:{high:4194304,low:1048576,drainTimeoutMs:1e3,chunkSize:16384}};var St=class t extends Error{constructor(n,e,r,i,o){super(`transport send failed: code=${n} peer=${e} label=${r} offset=${i}`,o),this.code=n,this.peerId=e,this.label=r,this.offset=i,Object.setPrototypeOf(this,t.prototype),this.name="TransportSendError"}toJSON(){return{name:this.name,code:this.code,peerId:this.peerId,label:this.label,offset:this.offset,message:this.message}}};async function mp(t){let{channel:n,peerId:e,label:r,bytes:i,profile:o,boundary:s,signal:a,flushToEmpty:c}=t;if(i.byteLength===0)return;if(!n||n.readyState!=="open")throw new St("not_open",e,r,0);if(a?.aborted)throw new St("aborted",e,r,0);if(i.byteLength<=o.chunkSize&&n.bufferedAmount<=o.high){try{n.send(i)}catch(d){throw new St("channel_closed",e,r,0,{cause:d})}c&&await nA(n,a,e,r,i.byteLength);return}let u=0,l=i;for(await tA(n,o,a,e,r,u);l.byteLength>0;){if(a?.aborted)throw new St("aborted",e,r,u);if(n.readyState!=="open")throw new St("channel_closed",e,r,u);let{head:d,tail:f}=jJ(l,o.chunkSize,s);try{n.send(d)}catch(p){throw new St("channel_closed",e,r,u,{cause:p})}u+=d.byteLength,l=f,l.byteLength>0&&await tA(n,o,a,e,r,u)}c&&await nA(n,a,e,r,u)}function jJ(t,n,e){return e?e.split(t,n):t.byteLength<=n?{head:t,tail:$J()}:{head:t.subarray(0,n),tail:t.subarray(n)}}var FJ=new Uint8Array(0);function $J(){return FJ}var qJ=500;async function tA(t,n,e,r,i,o){t.bufferedAmount<=n.high||(t.bufferedAmountLowThreshold=n.low,await rA(t,e,r,i,o,()=>t.bufferedAmount<=n.low))}var BJ=1e4;async function nA(t,n,e,r,i){t.bufferedAmount!==0&&(t.bufferedAmountLowThreshold=0,await rA(t,n,e,r,i,()=>t.bufferedAmount===0,BJ))}async function rA(t,n,e,r,i,o,s){let a=t.bufferedAmount,c=s!=null?Date.now()+s:null;for(;!o();){if(n?.aborted)throw new St("aborted",e,r,i);if(t.readyState!=="open")throw new St("channel_closed",e,r,i);if(c!=null){let u=t.bufferedAmount;if(u<a)a=u,c=Date.now()+s;else if(Date.now()>=c)return}await HJ(t,n,qJ)}}function HJ(t,n,e){return new Promise(r=>{let i=null,o=null,s=()=>{a(),r()},a=()=>{t.removeEventListener("bufferedamountlow",s),i&&(clearTimeout(i),i=null),o&&n&&n.removeEventListener("abort",o)};t.addEventListener("bufferedamountlow",s),i=setTimeout(()=>{a(),r()},Math.max(1,e)),n&&(o=()=>{a(),r()},n.addEventListener("abort",o,{once:!0}))})}function Wb(t){let{resolver:n,channelManager:e,channelSendError$:r}=t,i=new Map,o=(s,a,c)=>{let u=`${s}:${a}`,d=(i.get(u)??Promise.resolve()).catch(()=>{}).then(c),f=d.catch(()=>{}).finally(()=>{i.get(u)===f&&i.delete(u)});return i.set(u,f),d};return{async send(s,a,c,u={}){let l=VJ(c);if(l.byteLength===0)return;let d=Vb[u.profile??WJ(a)];return o(s,a,async()=>{try{let f=n.tryResolveSync(s)??await n.resolve(s),p=e.getChannel(f,a);await mp({channel:p,peerId:s,label:a,bytes:l,profile:d,boundary:u.boundary,signal:u.signal,flushToEmpty:u.flushToEmpty})}catch(f){throw f instanceof St&&r.next({peerId:s,label:a,code:f.code,offset:f.offset}),f}})},mutexSize:()=>i.size}}var UJ=new TextEncoder;function VJ(t){return typeof t=="string"?UJ.encode(t):t instanceof Uint8Array?t:new Uint8Array(t)}function WJ(t){for(let n of Object.values(ps))if(n.parseLabel(t)!==null)return n.defaultBackpressureProfile;return"http"}var At=U(Q(),1);function iA(t,n){let e=r=>n(r);return(0,At.merge)(t.channelOpened$.pipe((0,At.map)(r=>({kind:"channel-opened",peerId:e(r.peerId),label:r.label}))),t.channelClosed$.pipe((0,At.map)(r=>({kind:"channel-closed",peerId:e(r.peerId),label:r.label,reason:r.reason,readyState:r.readyState}))),t.connectionStateChanged$.pipe((0,At.map)(r=>({kind:"connection-state",peerId:e(r.peerId),state:r.state}))),t.iceStateChanged$.pipe((0,At.map)(r=>({kind:"ice-state",peerId:e(r.peerId),state:r.state}))),t.message$.pipe((0,At.filter)(r=>r.type==="[session.transport] ready"||r.type==="[session.transport] data"),(0,At.map)(r=>r.type==="[session.transport] ready"?{kind:"ready",peerId:e(r.peerId)}:{kind:"data",peerId:e(r.peerId),data:r.data})),t.sent$.pipe((0,At.map)(r=>({kind:"sent",peerId:e(r.peerId),data:r.data}))),t.recoveryEvents$.pipe((0,At.map)(r=>({kind:"recovery",peerId:e(r.peerId),event:r.event,elapsedMs:r.elapsedMs}))),t.channelMessage$.pipe((0,At.map)(r=>({kind:"channel-message",peerId:e(r.peerId),label:r.label,bytes:r.data instanceof ArrayBuffer?r.data.byteLength:r.data.length}))),t.channelSent$.pipe((0,At.map)(r=>({kind:"channel-sent",peerId:e(r.peerId),label:r.label,bytes:r.bytes}))))}var Ce=(()=>{class t{peerOf(e){return this.handles.peerOf(e)}invalidatePeerHandle(e){this.handles.invalidate(e)}resolveUuid(e){return this.resolver.resolveUuid(e)}resolveExternalPeerId(e){return this.resolver.resolveUuid(e)}get peerState$(){return this.peerService.peerState$.pipe((0,ne.map)(this.remap))}constructor(){this.logger=SO("WebRTCService"),this.webrtc=w(zM),this.channelManager=w(Dt),this.message$=new ne.Subject,this.sent$=new ne.Subject,this.channelSent$=new ne.Subject,this.channelSendError$=new ne.ReplaySubject(1),this.config=w(Oe),this.peers$=this.webrtc.peers$.pipe((0,ne.tap)(e=>this.logger.info("[transport:peers] TS.peers$ emit",{peers:e.length}))),this.peerService=w(ks),this.peer=this.peerService,this.peerList=w(As),this.heartbeatCoordinator=w(ip),this.state=new hp,this.resolver=new fp(this.peerList,this.config),this.ctx={resolver:this.resolver,state:this.state,webrtc:this.webrtc,channelManager:this.channelManager,config:this.config,sent$:this.sent$,channelSent$:this.channelSent$},this.handles=JM(this.ctx),this.remap=e=>({...e,peerId:this.resolver.resolveUuid(e.peerId)}),this.channelOpened$=this.channelManager.channelOpened$.pipe((0,ne.map)(this.remap)),this.channelClosed$=this.channelManager.channelClosed$.pipe((0,ne.map)(this.remap)),this.channelMessage$=this.channelManager.channelMessage$.pipe((0,ne.map)(this.remap),(0,ne.share)()),this.connectionStateChanged$=this.channelManager.connectionStateChanged$.pipe((0,ne.map)(this.remap)),this.iceStateChanged$=this.channelManager.iceStateChanged$.pipe((0,ne.map)(this.remap)),this.peerUnhealthy$=this.channelManager.peerUnhealthy$.pipe((0,ne.map)(this.remap)),this.peerDead$=this.state.peerDead$.pipe((0,ne.map)(this.remap)),this.recoveryEvents$=(this.peerService.recoveryEvents$??ne.EMPTY).pipe((0,ne.map)(this.remap)),this.transportEvents$=iA({channelOpened$:this.channelManager.channelOpened$,channelClosed$:this.channelManager.channelClosed$,connectionStateChanged$:this.channelManager.connectionStateChanged$,iceStateChanged$:this.channelManager.iceStateChanged$,message$:this.message$,sent$:this.sent$,recoveryEvents$:this.peerService.recoveryEvents$??ne.EMPTY,channelMessage$:this.channelMessage$,channelSent$:this.channelSent$},e=>this.resolver.resolveUuid(e)),this.sync=QM({resolver:this.resolver,state:this.state,channelManager:this.channelManager,channelSent$:this.channelSent$}),this.channelSendOrch=Wb({resolver:this.resolver,channelManager:this.channelManager,channelSendError$:this.channelSendError$}),this.channelStuckReconnects=new Map,this.peerActivity=eA({channelOpened$:this.channelManager.channelOpened$,channelMessage$:this.channelManager.channelMessage$}),YM({webrtc:this.webrtc,resolver:this.resolver,state:this.state,message$:this.message$,selfPeerId:()=>this.config.peerId(),log:(e,r)=>this.logger.debug(`[transport] ${e}`,r??{}),onPeerInvalidated:e=>this.invalidatePeerHandle(e)}),ZM({state:this.state,channelManager:this.channelManager,heartbeatCoordinator:this.heartbeatCoordinator,peerService:this.peerService}),this.channelSendError$.subscribe(e=>this.logger.warn("transport channelSend failed",e))}async connect(e,r={timeout:3e4}){this.logger.info("[transport:connect] TS.connect entry",{peerId:e}),await(0,ne.firstValueFrom)(this.resolver.resolve$(e).pipe((0,ne.switchMap)(async i=>{this.logger.info("[transport:connect] TS resolver.resolve",{connectionId:i}),this.resolver.lockActiveKey(e),e!==i&&this.resolver.cacheMapping(e,i),this.logger.info("[transport:connect] TS webrtc.connect pre",{cid:i}),await this.webrtc.connect(i),e!==i&&this.state.isReady(i)&&this.state.markReady(e)}),(0,ne.switchMap)(()=>{this.logger.info("[transport:connect] TS observeReady await",{peer:e});let i=this.resolver.resolveUuid(e);return(i!==e?(0,ne.merge)(this.state.observeReady(e),this.state.observeReady(i)):this.state.observeReady(e)).pipe((0,ne.filter)(s=>s),(0,ne.take)(1))}),(0,ne.timeout)(r.timeout)))}async waitForPeerReady(e,r={timeout:1e4}){await(0,ne.firstValueFrom)(this.state.observeReady(e).pipe((0,ne.filter)(i=>i),(0,ne.take)(1),(0,ne.timeout)(r.timeout)))}async start(){this.logger.info("[transport:start] TS.start() entry"),await this.webrtc.start(),this.logger.info("[transport:start] webrtc.start done")}async stop(){return this.webrtc.close()}async disconnect(){this.stop()}disconnectPeer(e){this.peerService.disconnect(e)}async getWebRTCConfig(){return this.config.config()}async setWebRTCConfig(e){this.config.config.set(e)}async updateWebRTCConfig(e){this.config.config.update(r=>{let i=e(r);return console.warn(`[transport:config] WebRTCService.updateWebRTCConfig instanceId=${this.config._diagInstanceId} prevPeersCount=${Object.keys(r?.identity?.peers??{}).length} nextAllowPeersCount=${(i?.allowPeersPublicKeys??[]).length} nextHasIdentity=${!!i?.identity}`),i?.identity&&r?.identity?.peers&&(i.identity={...i.identity,peers:{...r.identity.peers,...i.identity.peers??{}}}),i?.identity&&r?.identity?.peersMeta&&(i.identity={...i.identity,peersMeta:{...r.identity.peersMeta,...i.identity.peersMeta??{}}}),i})}send(e,r){return e===this.config.peerId()?(this.sent$.next({type:"[session.transport] data",peerId:e,data:r}),this.message$.next({type:"[session.transport] data",peerId:e,data:r}),Promise.resolve()):this.peerOf(e).send(r)}async broadcast(e){this.sent$.next({type:"[session.transport] data",peerId:this.config.peerId(),data:e}),this.webrtc.broadcast({type:"[session.transport] data",data:e,peerId:this.config.peerId()})}escalateChannelStuckReconnect(e,r,i){let o=this.resolver.tryResolveSync(e)??e,s=this.channelStuckReconnects.get(o);if(s)return this.logger.warn("[createChannel] joining in-flight stuck-channel reconnect (single-flight)",{peerId:e.substring(0,16),label:r}),s;this.logger.warn("[createChannel] channel open stuck, escalating to fresh peer connection",{peerId:e.substring(0,16),cid:o.substring(0,16),label:r,err:i?.message});let a=(async()=>{await this.webrtc.disconnect(o),await this.connect(e,{timeout:15e3})})();return this.channelStuckReconnects.set(o,a),a.finally(()=>{this.channelStuckReconnects.get(o)===a&&this.channelStuckReconnects.delete(o)}).catch(()=>{}),a}async createChannel(e,r,i="reliable-ordered"){if(e===this.config.peerId())return this.channelManager.registerInProcessChannel(e,r,i);try{await this.peerOf(e).createChannel(r,i)}catch(o){if(r.startsWith(ps.l7Qpack.prefix)||XM(o))throw o;let s=this.resolver.tryResolveSync(e)??e;if(this.peerActivity.isRecentlyActive(s))throw this.logger.warn("[createChannel] open failed but peer recently active \u2014 skipping escalation (congestion, not wedge)",{peerId:e.substring(0,16),label:r,err:o?.message}),o;await this.escalateChannelStuckReconnect(e,r,o),await this.peerOf(e).createChannel(r,i)}}closeChannel(e,r){return this.peerOf(e).closeChannel(r)}hasChannel(e,r){return e===this.config.peerId()?Promise.resolve(this.channelManager.hasChannel(e,r)):this.peerOf(e).hasChannel(r)}hasConnection(e){return this.peerOf(e).isReady()}waitForChannelOpen(e,r,i=5e3){return e===this.config.peerId()?this.channelManager.hasChannel(e,r)?Promise.resolve():(0,ne.firstValueFrom)(this.channelManager.channelOpened$.pipe((0,ne.filter)(o=>o.peerId===e&&o.label===r),(0,ne.map)(()=>{}),(0,ne.timeout)({each:i,with:()=>(0,ne.throwError)(()=>new Error(`waitForChannelOpen timeout (self in-process): ${e}/${r}`))}))):this.peerOf(e).waitForChannelOpen(r,i)}getRemoteMaxMessageSize(e){return this.peerOf(e).getRemoteMaxMessageSize()}channelSend(e,r,i,o){if(e===this.config.peerId()){let s=typeof i=="string"?i:i instanceof Uint8Array?GJ(i):i;return this.channelManager.sendInProcess(e,r,s,o?.senderClientId),Promise.resolve()}return this.channelSendOrch.send(e,r,i,o)}tryConnectionIdSync(e){return this.sync.tryConnectionIdSync(e)}bufferedAmountSync(e,r){return this.sync.bufferedAmountSync(e,r)}sendToChannelSync(e,r,i){return this.sync.sendToChannelSync(e,r,i)}getRemoteMaxMessageSizeSync(e){return this.sync.getRemoteMaxMessageSizeSync(e)}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=N({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();function GJ(t){return t.byteOffset===0&&t.byteLength===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}(function(t){t.WEB_RTC_CONFIG=Bi})(Ce||(Ce={}));var zJ=q.object({urls:q.union([q.string(),q.array(q.string())]),username:q.string().optional(),credential:q.string().optional()}),KJ=q.enum(["daemon","cli-server","server","web-server","web-proxy","app"]),YJ=q.object({identity:q.object({peerId:q.string(),publicKey:q.string(),signalingId:q.string(),privateKey:q.string(),peers:q.record(q.string()),peersMeta:q.record(q.object({roles:q.array(q.enum(["client","server"])),name:q.string().optional()})).optional()}).optional(),iceServers:q.array(zJ).optional(),version:q.string().optional(),name:q.string().optional(),serverName:q.string().optional(),origin:KJ.optional(),roles:q.array(q.enum(["client","server"])).optional(),allowPeersPublicKeys:q.array(q.string()).optional(),allowPeersMode:q.enum(["unrestricted","restricted"]).optional(),peers:q.record(q.string()).optional(),peersMeta:q.record(q.object({roles:q.array(q.enum(["client","server"])),name:q.string().optional()})).optional()}),oA=yt({peerId:fe.query(async({ctx:t})=>t.injector.get(Oe).peerId()),publicKey:fe.query(async({ctx:t})=>t.injector.get(Oe).publicKey()),shortServerId:fe.query(async({ctx:t})=>t.injector.get(Oe).shortServerId()),getWebRTCConfig:fe.query(async({ctx:t})=>t.injector.get(Ce).getWebRTCConfig()),update:fe.input(YJ).mutation(async({ctx:t,input:n})=>{await t.injector.get(Ce).updateWebRTCConfig(r=>{let i={...r};return n.identity?i.identity={peerId:n.identity.peerId,publicKey:n.identity.publicKey,signalingId:n.identity.signalingId,privateKey:n.identity.privateKey,peers:{...r.identity?.peers??{},...n.identity.peers,...n.peers??{}},peersMeta:{...r.identity?.peersMeta??{},...n.identity.peersMeta??{},...n.peersMeta??{}}}:(n.peers||n.peersMeta)&&r.identity&&(i.identity={...r.identity,peers:{...r.identity.peers??{},...n.peers??{}},peersMeta:{...r.identity.peersMeta??{},...n.peersMeta??{}}}),n.iceServers&&(i.peerSessionOptions={...r.peerSessionOptions??{},config:{...r.peerSessionOptions?.config??{},iceServers:n.iceServers}}),n.version!==void 0&&(i.version=n.version),n.name!==void 0&&(i.name=n.name),n.serverName!==void 0&&(i.serverName=n.serverName),n.origin!==void 0&&(i.origin=n.origin),n.roles!==void 0&&(i.roles=n.roles),n.allowPeersPublicKeys&&(i.allowPeersPublicKeys=n.allowPeersPublicKeys),n.allowPeersMode!==void 0&&(i.allowPeersMode=n.allowPeersMode),i})})});var sA=yt({isInitialized:fe.query(({ctx:t})=>!!t.injector.get(Oe).config().identity),initialize:fe.mutation(()=>{}),waitForInitialization:fe.mutation(()=>{})});var aA=yt({send:fe.input(q.object({peerId:q.string(),message:q.unknown()})).mutation(async({ctx:t,input:n})=>(await t.injector.get(Ce).send(n.peerId,n.message),{success:!0})),broadcast:fe.input(q.object({message:q.unknown()})).mutation(async({ctx:t,input:n})=>(await t.injector.get(Ce).broadcast(n.message),{success:!0})),generateId:fe.query(async({ctx:t})=>t.injector.get(Oe).peerId()),subscribe:fe.subscription(({ctx:t})=>{let n=t.injector.get(Ce);return Zt(e=>{let r=n.message$.subscribe({next:i=>e.next(i),error:i=>e.error(i)});return()=>r.unsubscribe()})})});var cA=typeof process<"u"&&!!process.env?.PLANX_PROXY_DEBUG,uA=yt({send:fe.input(q.object({peerId:q.string(),data:q.unknown()})).mutation(async({ctx:t,input:n})=>{let e=t.injector.get(Ce);if(cA){let r=n.data?.type;console.log(`[messaging:send] peerId=${n.peerId.slice(0,12)} dataType=${String(r)}`)}await e.send(n.peerId,n.data)}),broadcast:fe.input(q.object({data:q.unknown()})).mutation(async({ctx:t,input:n})=>{await t.injector.get(Ce).broadcast(n.data)}),onMessage:fe.subscription(({ctx:t})=>{let n=t.injector.get(Ce);return Zt(e=>{let r=n.message$.subscribe({next:i=>{if(cA){let o=i;console.log(`[messaging:relay] type=${String(o?.type)} peerId=${String(o?.peerId).slice(0,12)} dataType=${String(o?.data?.type)}`)}e.next(i)},error:i=>e.error(i)});return()=>r.unsubscribe()})})});var hc=q.object({peerId:q.string(),label:q.string()});function ZJ(t){if(t instanceof ArrayBuffer)return{data:Buffer.from(new Uint8Array(t)).toString("base64"),binary:!0};if(ArrayBuffer.isView(t)){let n=t;return{data:Buffer.from(n.buffer,n.byteOffset,n.byteLength).toString("base64"),binary:!0}}return{data:String(t),binary:!1}}function QJ(t,n){if(!n)return t;let e=Buffer.from(t,"base64");return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}var lA=yt({create:fe.input(hc).mutation(async({ctx:t,input:n})=>{await t.injector.get(Ce).createChannel(n.peerId,n.label)}),close:fe.input(hc).mutation(async({ctx:t,input:n})=>{await t.injector.get(Ce).closeChannel(n.peerId,n.label)}),has:fe.input(hc).query(async({ctx:t,input:n})=>t.injector.get(Ce).hasChannel(n.peerId,n.label)),channelSend:fe.input(hc.extend({data:q.string(),binary:q.boolean().optional(),opts:q.object({profile:q.enum(["control","terminal","http","bulk"]).optional(),senderClientId:q.string().optional()}).optional()})).mutation(async({ctx:t,input:n})=>t.injector.get(Ce).channelSend(n.peerId,n.label,QJ(n.data,n.binary),n.opts)),waitForOpen:fe.input(hc.extend({timeoutMs:q.number().optional()})).mutation(async({ctx:t,input:n})=>{await t.injector.get(Ce).waitForChannelOpen(n.peerId,n.label,n.timeoutMs)}),onOpened:fe.subscription(({ctx:t})=>{let n=t.injector.get(Ce);return Zt(e=>{let r=n.channelOpened$.subscribe({next:i=>e.next(i),error:i=>e.error(i)});return()=>r.unsubscribe()})}),onClosed:fe.subscription(({ctx:t})=>{let n=t.injector.get(Ce);return Zt(e=>{let r=n.channelClosed$.subscribe({next:i=>e.next(i),error:i=>e.error(i)});return()=>r.unsubscribe()})}),onMessage:fe.input(q.object({clientId:q.string().optional()}).optional()).subscription(({ctx:t,input:n})=>{let e=t.injector.get(Ce);return Zt(r=>{let i=e.channelMessage$.subscribe({next:o=>{let s=o;if(s.senderClientId!=null&&s.senderClientId===n?.clientId)return;let{data:a,binary:c}=ZJ(s.data);r.next({peerId:s.peerId,label:s.label,data:a,binary:c})},error:o=>r.error(o)});return()=>i.unsubscribe()})})});var gp=U(Q(),1);var dA=yt({peers:fe.query(({ctx:t})=>{let n=t.injector.get(Ce);return(0,gp.firstValueFrom)(n.peers$.pipe((0,gp.take)(1)))}),onPeersChanged:fe.subscription(({ctx:t})=>{let n=t.injector.get(Ce);return Zt(e=>{let r=n.peers$.subscribe({next:i=>e.next(i),error:i=>e.error(i)});return()=>r.unsubscribe()})}),onConnectionStateChanged:fe.subscription(({ctx:t})=>{let n=t.injector.get(Ce);return Zt(e=>{let r=n.connectionStateChanged$.subscribe({next:i=>e.next(i),error:i=>e.error(i)});return()=>r.unsubscribe()})}),connect:fe.input(q.object({peerId:q.string(),timeout:q.number().default(3e4)})).mutation(async({ctx:t,input:n})=>{await t.injector.get(Ce).connect(n.peerId,{timeout:n.timeout})}),start:fe.mutation(async({ctx:t})=>{await t.injector.get(Ce).start()}),stop:fe.mutation(async({ctx:t})=>{await t.injector.get(Ce).stop()}),disconnect:fe.mutation(async({ctx:t})=>{await t.injector.get(Ce).disconnect()}),hasConnection:fe.input(q.object({peerId:q.string()})).query(async({ctx:t,input:n})=>t.injector.get(Ce).hasConnection(n.peerId))});var Gb=yt({health:rO,config:oA,key:sA,signaling:aA,messaging:uA,channel:lA,transport:dA});function fA(t){let{injector:n,enableLogger:e=!0}=t,r=new Y_;return e&&r.use("*",a0()),r.get("/health",i=>i.json({ok:!0,service:"transport"})),r.all("/trpc/*",i=>lb({endpoint:"/trpc",req:i.req.raw,router:Gb,createContext:()=>({injector:n})})),r.all("/*",i=>lb({endpoint:"",req:i.req.raw,router:Gb,createContext:()=>({injector:n})})),r}function hA(t,n){process.stdout.write(`{"service":"transport","port":${t},"pid":${n}}
19
19
  `)}function pA(t){process.stdout.write(`{"event":"identity-ready","peerId":"${t}"}
20
- `)}var IA=U(Q(),1);var mA=U(Q(),1);var QJ={new:"new",connecting:"connecting",connected:"connected",disconnected:"interrupted",failed:"failed",closed:"closed"};function zb(t){return QJ[t]}function gA(t){let n=new mA.BehaviorSubject(zb(t.connectionState)),e=!1,r=()=>{e||t.connectionState!=="closed"&&n.next(zb(t.connectionState))};return t.addEventListener("connectionstatechange",r),{lifecycle$:n.asObservable(),snapshot:()=>n.getValue(),close:()=>{e||(e=!0,t.removeEventListener("connectionstatechange",r),n.next("closed"),n.complete(),t.close())}}}function yA(t,n,e){let r=o=>{let s=o?.candidate;s&&n({candidate:s})},i=()=>{(async()=>{e?.(!0);try{let o=await t.createOffer();await t.setLocalDescription(o),t.localDescription&&n({offer:t.localDescription})}catch(o){console.warn("[wire-pc-signals] abandon own offer (glare/state race):",o instanceof Error?o.message:o)}finally{e?.(!1)}})()};return t.addEventListener("icecandidate",r),t.addEventListener("negotiationneeded",i),()=>{t.removeEventListener("icecandidate",r),t.removeEventListener("negotiationneeded",i)}}var vA=U(Q(),1);function yp(t){return new vA.Observable(n=>{let e=i=>n.next(i?.data),r=()=>n.complete();return t.addEventListener("message",e),t.addEventListener("close",r),()=>{t.removeEventListener("message",e),t.removeEventListener("close",r)}})}function _A(t){let n=[],e=!1,r=i=>t.addIceCandidate(i).catch(()=>{});return{addCandidate(i){t.remoteDescription?r(i):n.push(i)},async flush(){if(e)return;e=!0;let i=n.splice(0);for(let o of i)await r(o)}}}async function bA(t,n,e,r){if("candidate"in e){n.addCandidate(e.candidate);return}if("answer"in e){await t.setRemoteDescription(e.answer),await n.flush();return}let i=r.makingOffer||t.signalingState!=="stable";if(!r.polite&&i)return;i&&t.signalingState!=="stable"&&await t.setLocalDescription({type:"rollback"}),await t.setRemoteDescription(e.offer);let o=await t.createAnswer();return await t.setLocalDescription(o),await n.flush(),{answer:o}}var wA=U(Q(),1);function vp(t,n,e){return new wA.Observable(r=>{if(t.readyState!=="open"){r.error(new Error("[send-sink] channel_closed"));return}if(e?.aborted){r.error(new Error("[send-sink] aborted"));return}if(t.send(n),t.bufferedAmount<=t.bufferedAmountLowThreshold){r.complete();return}let i=()=>r.complete(),o=()=>r.error(new Error("[send-sink] aborted"));return t.addEventListener("bufferedamountlow",i),e?.addEventListener("abort",o),()=>{t.removeEventListener("bufferedamountlow",i),e?.removeEventListener("abort",o)}})}var Kb=U(Q(),1);function EA(t){return{label:t.label,messages$:yp(t),send$:(n,e)=>vp(t,n,e)}}function SA(t,n,e){return new Kb.Observable(r=>{let i=t.createDataChannel(n,Ns[e]),o=()=>r.next(EA(i));return i.readyState==="open"?o():i.addEventListener("open",o),()=>{i.removeEventListener("open",o),i.close()}})}function CA(t,n=()=>!1){return new Kb.Observable(e=>{let r=i=>{let o=i?.channel;!o||n(o.label)||e.next(EA(o))};return t.addEventListener("datachannel",r),()=>t.removeEventListener("datachannel",r)})}function TA(t,n,e){let r=gA(t),i=_A(t),o=new IA.Subject,s=!1,a=!1,c=yA(t,l=>o.next(l),l=>{s=l}),u=e.restartTimeoutMs??15e3;return{lifecycle$:r.lifecycle$,outgoing$:o.asObservable(),messages$:yp(n),openChannel:(l,d)=>SA(t,l,d),incomingChannels$:CA(t,e.isMainChannelLabel),diagnostics$:HO(t),snapshot:()=>r.snapshot(),restartIce$:()=>up(t,r.lifecycle$,u),applySignal:l=>bA(t,i,l,{polite:e.polite,makingOffer:s}),send$:(l,d)=>vp(n,l,d),close:()=>{a||(a=!0,c(),o.complete(),r.close())}}}function xA(t){return t.connectionState==="closed"?Promise.resolve():new Promise(n=>{let e=null,r=()=>{t.connectionState==="closed"&&(t.removeEventListener("connectionstatechange",r),e!==null&&clearTimeout(e),n())};t.addEventListener("connectionstatechange",r),e=setTimeout(()=>{t.removeEventListener("connectionstatechange",r),n()},2e3)})}function DA(t){return{get readyState(){return t()?.readyState??"connecting"},get bufferedAmount(){return t()?.bufferedAmount??0},get bufferedAmountLowThreshold(){return t()?.bufferedAmountLowThreshold??0},addEventListener:(n,e)=>t()?.addEventListener(n,e),removeEventListener:(n,e)=>t()?.removeEventListener(n,e),send:n=>t()?.send(n)}}function OA(t,n){let e=new AbortController,r={signal:e.signal};return t.addEventListener("open",()=>n.onConnect(),r),t.addEventListener("message",i=>n.onData(i.data),r),t.addEventListener("close",()=>{if(!n.isDestroyed()){if(n.pcConnectionState()==="connected"){console.warn("[native-peer-adapter] mainChannel close while pc connected \u2014 suppress cascade (peer alive, defer to pc.connectionState + heartbeat)",{connectionState:n.pcConnectionState(),iceConnectionState:n.pcIceConnectionState()});return}n.onCascadeClose()}},r),()=>e.abort()}function MA(t,n){if(n.isDestroyed())return;if(!n.polite){try{t.close()}catch{}return}let e=n.currentMainChannel();n.attachMainChannel(t);try{e?.close()}catch{}}var AA=U(Q(),1);function NA(t,n,e){let r=new AA.Observable(i=>{let o=s=>{let a=s.channel;a&&a.label!==e&&i.next(a)};return t.addEventListener("datachannel",o),()=>t.removeEventListener("datachannel",o)});return{get connectionState(){return t.connectionState},lifecycle$:n.lifecycle$,diagnostics$:n.diagnostics$,incomingChannels$:r,createDataChannel:(i,o)=>t.createDataChannel(i,o),getStats:()=>t.getStats(),captureDiagnosticsSnapshot:()=>Pb(t)}}function PA(t,n){"candidate"in t?n({candidate:t.candidate}):"offer"in t?n({type:"offer",sdp:t.offer.sdp}):n({type:"answer",sdp:t.answer.sdp})}async function RA(t,n,e,r){if(n.type==="offer"||n.type==="answer"){let i={type:n.type,sdp:n.sdp},o=await t.applySignal(n.type==="offer"?{offer:i}:{answer:i});o&&e({type:"answer",sdp:r()??o.answer.sdp})}else n.candidate&&await t.applySignal({candidate:n.candidate})}var pc="default",_p=class{constructor(n){this.listeners=new Map,this._connected=!1,this._destroyed=!1;let e={...n.config??{}};e.iceCandidatePoolSize==null&&(e.iceCandidatePoolSize=0),this._pc=new n.PeerConnection(e),this.skipDefaultChannel=n.skipDefaultChannel??!1,this.polite=n.polite??!n.initiator,this.reactive=TA(this._pc,DA(()=>this.mainChannel),{polite:this.polite,isMainChannelLabel:r=>r===pc}),this.channels=NA(this._pc,this.reactive,pc),this.reactive.outgoing$.subscribe(r=>PA(r,i=>this.emit("signal",i))),this.skipDefaultChannel?this._pc.addEventListener("connectionstatechange",()=>{this._destroyed||this._pc.connectionState==="connected"&&!this._connected&&(this._connected=!0,this.emit("connect"))}):n.initiator?(this.attachMainChannel(this._pc.createDataChannel(pc,{ordered:!0})),this._pc.addEventListener("datachannel",r=>{r.channel.label===pc&&MA(r.channel,{polite:this.polite,isDestroyed:()=>this._destroyed,currentMainChannel:()=>this.mainChannel,attachMainChannel:i=>this.attachMainChannel(i)})})):this._pc.addEventListener("datachannel",r=>{r.channel.label===pc&&this.attachMainChannel(r.channel)})}on(n,e){this.listeners.has(n)||this.listeners.set(n,[]),this.listeners.get(n).push(e)}async signal(n){try{await RA(this.reactive,n,e=>this.emit("signal",e),()=>this._pc.localDescription?.sdp)}catch(e){this.emit("error",e instanceof Error?e:new Error(String(e)))}}send(n){this._destroyed||!this.mainChannel||this.mainChannel.readyState!=="open"||this.mainChannel.send(n)}async destroy(){if(!this._destroyed){this._destroyed=!0,this._connected=!1;try{this.mainChannel?.close()}catch{}try{this.reactive.close()}catch{}await xA(this._pc),this.emit("close"),this.listeners.clear()}}get connected(){return this._connected&&!this._destroyed&&this._pc.connectionState==="connected"}get destroyed(){return this._destroyed}get connectionState(){return this._pc.connectionState}get signalingState(){return this._pc.signalingState}restartIce(){this._pc.restartIce()}attachMainChannel(n){this.mainChannelDetach?.(),this.mainChannel=n,this.mainChannelDetach=OA(n,{isDestroyed:()=>this._destroyed,pcConnectionState:()=>this._pc.connectionState,pcIceConnectionState:()=>this._pc.iceConnectionState,onConnect:()=>{this._connected=!0,this.emit("connect")},onData:e=>this.emit("data",e),onCascadeClose:()=>this.emit("close")}),n.readyState==="open"&&!this._connected&&(this._connected=!0,this.emit("connect"))}emit(n,...e){let r=this.listeners.get(n);if(r)for(let i of[...r])try{i(...e)}catch{}}};var kA;try{kA=LR("@roamhq/wrtc")}catch{}var JJ=(()=>{class t extends uc{create(e){return new _p({initiator:e.initiator,polite:e.polite,config:this.config().peerSessionOptions.config,PeerConnection:kA?.RTCPeerConnection})}static{this.\u0275fac=(()=>{let e;return function(i){return(e||(e=Bt(t)))(i||t)}})()}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();function Yb(){return[{provide:uc,useClass:JJ}]}var LA=new _e("CONFIG_FILE_PATH"),jA=new _e("IDENTITY_OVERRIDE"),XJ=(()=>{class t extends ds{constructor(){super(...arguments),this.configPath=w(LA),this.identityOverride=w(jA,{optional:!0})}async loadConfig(){let e=await import("fs/promises");try{let r=await e.readFile(this.configPath,"utf-8");return JSON.parse(r)}catch(r){if(r.code==="ENOENT")return{};throw r}}static{this.atomicWriteCounter=0}async saveConfig(e){let r=await import("fs/promises"),i=await import("path");await r.mkdir(i.dirname(this.configPath),{recursive:!0});let o=`${this.configPath}.${process.pid}.${++t.atomicWriteCounter}.tmp`;await r.writeFile(o,JSON.stringify(e,null,2),{mode:384}),await r.rename(o,this.configPath)}async save(e){let r=await this.loadConfig();r.identity={publicKey:e.publicKey,privateKey:e.privateKey,algorithm:e.algorithm,createdAt:e.createdAt.toISOString()},await this.saveConfig(r)}async load(){if(this.identityOverride)return this.identityOverride;let e=await this.loadConfig();return e.identity?{publicKey:e.identity.publicKey,privateKey:e.identity.privateKey,algorithm:e.identity.algorithm,createdAt:new Date(e.identity.createdAt)}:null}async exists(){return this.identityOverride?!0:!!(await this.loadConfig()).identity}async delete(){let e=await this.loadConfig();delete e.identity,await this.saveConfig(e)}async saveBackup(e,r){let i=await this.loadConfig(),o={publicKey:e.publicKey,privateKey:e.privateKey,algorithm:e.algorithm,createdAt:e.createdAt.toISOString(),rotatedAt:r};i.identityBackups=i.identityBackups||[],i.identityBackups.push(o),await this.saveConfig(i)}async loadBackups(){let e=await this.loadConfig();return e.identityBackups?e.identityBackups.map(r=>({keyPair:{publicKey:r.publicKey,privateKey:r.privateKey,algorithm:r.algorithm,createdAt:new Date(r.createdAt)},rotatedAt:r.rotatedAt})):[]}async cleanupBackups(e){let r=await this.loadConfig();if(!r.identityBackups)return;let i=Date.now()-e;r.identityBackups=r.identityBackups.filter(o=>o.rotatedAt>i),await this.saveConfig(r)}static{this.\u0275fac=(()=>{let e;return function(i){return(e||(e=Bt(t)))(i||t)}})()}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();function bp(t,n){return[{provide:LA,useValue:t},{provide:ds,useClass:XJ},{provide:jA,useValue:n??null}]}async function eX(){try{return await import("node:crypto")}catch(t){let n=globalThis.cryptoModule;if(n)return n;throw t}}var tX=(()=>{class t extends ls{async generateKeyPair(){let e=await eX(),r=e,i=typeof self<"u"?self:void 0;if(typeof r.generateKeyPairSync!="function"&&i?.crypto?.subtle){let a=i.crypto.subtle,c=await a.generateKey({name:"ECDSA",namedCurve:"P-256"},!0,["sign","verify"]),u=await a.exportKey("spki",c.publicKey),l=await a.exportKey("pkcs8",c.privateKey);return{publicKey:this.bufferToBase64(u),privateKey:this.bufferToBase64(l),algorithm:"P-256",createdAt:new Date}}let{publicKey:o,privateKey:s}=e.generateKeyPairSync("ec",{namedCurve:"prime256v1",publicKeyEncoding:{type:"spki",format:"der"},privateKeyEncoding:{type:"pkcs8",format:"der"}});return{publicKey:o.toString("base64"),privateKey:s.toString("base64"),algorithm:"P-256",createdAt:new Date}}static{this.\u0275fac=(()=>{let e;return function(i){return(e||(e=Bt(t)))(i||t)}})()}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();function FA(){return[{provide:ls,useClass:tX}]}import*as Nt from"node:crypto";var nX=(()=>{class t extends Hr{constructor(){super(...arguments),this.derivedKeys=new Map}async deriveSharedKey(e,r){let i=Buffer.from(e,"base64"),o=Nt.createPrivateKey({key:i,format:"der",type:"pkcs8"}),s=Buffer.from(r,"base64"),a=Nt.createPublicKey({key:s,format:"der",type:"spki"}),c=Nt.diffieHellman({privateKey:o,publicKey:a}),u=Nt.createHash("sha256").update(c).digest(),l=`${e.substring(0,20)}_${r.substring(0,20)}`;return this.derivedKeys.set(l,u),{cacheKey:l}}async encryptBytes(e,r){let{cacheKey:i}=r,o=this.derivedKeys.get(i);if(!o)throw new Error("Shared key not found");let s=Nt.randomBytes(12),a=Nt.createCipheriv("aes-256-gcm",o,s),c=Buffer.concat([a.update(e),a.final()]),u=a.getAuthTag();return{encrypted:Buffer.concat([c,u]).toString("base64"),iv:s.toString("base64")}}async decryptBytes(e,r,i){let{cacheKey:o}=i,s=this.derivedKeys.get(o);if(!s)throw new Error("Shared key not found");let a=Buffer.from(e,"base64"),c=a.subarray(-16),u=a.subarray(0,-16),l=Nt.createDecipheriv("aes-256-gcm",s,Buffer.from(r,"base64"));l.setAuthTag(c);let d=Buffer.concat([l.update(u),l.final()]);return new Uint8Array(d)}static{this.\u0275fac=(()=>{let e;return function(i){return(e||(e=Bt(t)))(i||t)}})()}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();function $A(){return[{provide:Hr,useClass:nX}]}async function qA(){try{return await import("node:crypto")}catch(t){let n=globalThis.cryptoModule;if(n)return n;throw t}}var rX=(()=>{class t extends Pi{async createSignature(e,r){let i=await qA(),o=i.createPrivateKey({key:Buffer.from(r,"base64"),format:"der",type:"pkcs8"}),s=i.createSign("SHA256");return s.update(e),s.sign(o).toString("base64")}async verifySignature(e,r,i){let o=await qA(),s=o.createPublicKey({key:Buffer.from(i,"base64"),format:"der",type:"spki"}),a=Buffer.from(r,"base64"),c=this.isRawSignature(a)?this.rawToDer(a):a,u=o.createVerify("SHA256");return u.update(e),u.verify(s,c)}isRawSignature(e){return e.length===64}rawToDer(e){let r=e.subarray(0,32),i=e.subarray(32,64),o=r[0]>=128?Buffer.concat([Buffer.from([0]),r]):this.trimLeadingZeros(r),s=i[0]>=128?Buffer.concat([Buffer.from([0]),i]):this.trimLeadingZeros(i),a=Buffer.concat([Buffer.from([2,o.length]),o]),c=Buffer.concat([Buffer.from([2,s.length]),s]),u=a.length+c.length;return Buffer.concat([Buffer.from([48,u]),a,c])}trimLeadingZeros(e){let r=0;for(;r<e.length-1&&e[r]===0&&e[r+1]<128;)r++;return e.subarray(r)}static{this.\u0275fac=(()=>{let e;return function(i){return(e||(e=Bt(t)))(i||t)}})()}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();function BA(){return[{provide:Pi,useClass:rX}]}function wp(t){return[...FA(),...$A(),{provide:Ur,useClass:R_},...BA(),...bp(t.keyFilePath,t.identityOverride)]}import{WebSocketServer as mke}from"ws";import wee from"faye-websocket";var HA=()=>{};var Ep={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"};var A=function(t,n){if(!t)throw Vi(n)},Vi=function(t){return new Error("Firebase Database ("+Ep.SDK_VERSION+") INTERNAL ASSERT FAILED: "+t)};var WA=function(t){let n=[],e=0;for(let r=0;r<t.length;r++){let i=t.charCodeAt(r);i<128?n[e++]=i:i<2048?(n[e++]=i>>6|192,n[e++]=i&63|128):(i&64512)===55296&&r+1<t.length&&(t.charCodeAt(r+1)&64512)===56320?(i=65536+((i&1023)<<10)+(t.charCodeAt(++r)&1023),n[e++]=i>>18|240,n[e++]=i>>12&63|128,n[e++]=i>>6&63|128,n[e++]=i&63|128):(n[e++]=i>>12|224,n[e++]=i>>6&63|128,n[e++]=i&63|128)}return n},aX=function(t){let n=[],e=0,r=0;for(;e<t.length;){let i=t[e++];if(i<128)n[r++]=String.fromCharCode(i);else if(i>191&&i<224){let o=t[e++];n[r++]=String.fromCharCode((i&31)<<6|o&63)}else if(i>239&&i<365){let o=t[e++],s=t[e++],a=t[e++],c=((i&7)<<18|(o&63)<<12|(s&63)<<6|a&63)-65536;n[r++]=String.fromCharCode(55296+(c>>10)),n[r++]=String.fromCharCode(56320+(c&1023))}else{let o=t[e++],s=t[e++];n[r++]=String.fromCharCode((i&15)<<12|(o&63)<<6|s&63)}}return n.join("")},Ip={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(t,n){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();let e=n?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let i=0;i<t.length;i+=3){let o=t[i],s=i+1<t.length,a=s?t[i+1]:0,c=i+2<t.length,u=c?t[i+2]:0,l=o>>2,d=(o&3)<<4|a>>4,f=(a&15)<<2|u>>6,p=u&63;c||(p=64,s||(f=64)),r.push(e[l],e[d],e[f],e[p])}return r.join("")},encodeString(t,n){return this.HAS_NATIVE_SUPPORT&&!n?btoa(t):this.encodeByteArray(WA(t),n)},decodeString(t,n){return this.HAS_NATIVE_SUPPORT&&!n?atob(t):aX(this.decodeStringToByteArray(t,n))},decodeStringToByteArray(t,n){this.init_();let e=n?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let i=0;i<t.length;){let o=e[t.charAt(i++)],a=i<t.length?e[t.charAt(i)]:0;++i;let u=i<t.length?e[t.charAt(i)]:64;++i;let d=i<t.length?e[t.charAt(i)]:64;if(++i,o==null||a==null||u==null||d==null)throw new Zb;let f=o<<2|a>>4;if(r.push(f),u!==64){let p=a<<4&240|u>>2;if(r.push(p),d!==64){let m=u<<6&192|d;r.push(m)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let t=0;t<this.ENCODED_VALS.length;t++)this.byteToCharMap_[t]=this.ENCODED_VALS.charAt(t),this.charToByteMap_[this.byteToCharMap_[t]]=t,this.byteToCharMapWebSafe_[t]=this.ENCODED_VALS_WEBSAFE.charAt(t),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]]=t,t>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}},Zb=class extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}},Qb=function(t){let n=WA(t);return Ip.encodeByteArray(n,!0)},gc=function(t){return Qb(t).replace(/\./g,"")},Sp=function(t){try{return Ip.decodeString(t,!0)}catch(n){console.error("base64Decode failed: ",n)}return null};function GA(t){return zA(void 0,t)}function zA(t,n){if(!(n instanceof Object))return n;switch(n.constructor){case Date:let e=n;return new Date(e.getTime());case Object:t===void 0&&(t={});break;case Array:t=[];break;default:return n}for(let e in n)!n.hasOwnProperty(e)||!cX(e)||(t[e]=zA(t[e],n[e]));return t}function cX(t){return t!=="__proto__"}function uX(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}var lX=()=>uX().__FIREBASE_DEFAULTS__,dX=()=>{if(typeof process>"u"||typeof process.env>"u")return;let t=process.env.__FIREBASE_DEFAULTS__;if(t)return JSON.parse(t)},fX=()=>{if(typeof document>"u")return;let t;try{t=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}let n=t&&Sp(t[1]);return n&&JSON.parse(n)},KA=()=>{try{return HA()||lX()||dX()||fX()}catch(t){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${t}`);return}},hX=t=>KA()?.emulatorHosts?.[t],YA=t=>{let n=hX(t);if(!n)return;let e=n.lastIndexOf(":");if(e<=0||e+1===n.length)throw new Error(`Invalid host ${n} with no separate hostname and port!`);let r=parseInt(n.substring(e+1),10);return n[0]==="["?[n.substring(1,e-1),r]:[n.substring(0,e),r]},Jb=()=>KA()?.config;var Wt=class{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((n,e)=>{this.resolve=n,this.reject=e})}wrapCallback(n){return(e,r)=>{e?this.reject(e):this.resolve(r),typeof n=="function"&&(this.promise.catch(()=>{}),n.length===1?n(e):n(e,r))}}};function Tp(t){try{return(t.startsWith("http://")||t.startsWith("https://")?new URL(t).hostname:t).endsWith(".cloudworkstations.dev")}catch{return!1}}async function ZA(t){return(await fetch(t,{credentials:"include"})).ok}function QA(t,n){if(t.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');let e={alg:"none",type:"JWT"},r=n||"demo-project",i=t.iat||0,o=t.sub||t.user_id;if(!o)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");let s={iss:`https://securetoken.google.com/${r}`,aud:r,iat:i,exp:i+3600,auth_time:i,sub:o,user_id:o,firebase:{sign_in_provider:"custom",identities:{}},...t};return[gc(JSON.stringify(e)),gc(JSON.stringify(s)),""].join(".")}var mc={};function pX(){let t={prod:[],emulator:[]};for(let n of Object.keys(mc))mc[n]?t.emulator.push(n):t.prod.push(n);return t}function mX(t){let n=document.getElementById(t),e=!1;return n||(n=document.createElement("div"),n.setAttribute("id",t),e=!0),{created:e,element:n}}var UA=!1;function JA(t,n){if(typeof window>"u"||typeof document>"u"||!Tp(window.location.host)||mc[t]===n||mc[t]||UA)return;mc[t]=n;function e(f){return`__firebase__banner__${f}`}let r="__firebase__banner",o=pX().prod.length>0;function s(){let f=document.getElementById(r);f&&f.remove()}function a(f){f.style.display="flex",f.style.background="#7faaf0",f.style.position="fixed",f.style.bottom="5px",f.style.left="5px",f.style.padding=".5em",f.style.borderRadius="5px",f.style.alignItems="center"}function c(f,p){f.setAttribute("width","24"),f.setAttribute("id",p),f.setAttribute("height","24"),f.setAttribute("viewBox","0 0 24 24"),f.setAttribute("fill","none"),f.style.marginLeft="-6px"}function u(){let f=document.createElement("span");return f.style.cursor="pointer",f.style.marginLeft="16px",f.style.fontSize="24px",f.innerHTML=" &times;",f.onclick=()=>{UA=!0,s()},f}function l(f,p){f.setAttribute("id",p),f.innerText="Learn more",f.href="https://firebase.google.com/docs/studio/preview-apps#preview-backend",f.setAttribute("target","__blank"),f.style.paddingLeft="5px",f.style.textDecoration="underline"}function d(){let f=mX(r),p=e("text"),m=document.getElementById(p)||document.createElement("span"),y=e("learnmore"),b=document.getElementById(y)||document.createElement("a"),E=e("preprendIcon"),D=document.getElementById(E)||document.createElementNS("http://www.w3.org/2000/svg","svg");if(f.created){let T=f.element;a(T),l(b,y);let K=u();c(D,E),T.append(D,m,b,K),document.body.appendChild(T)}o?(m.innerText="Preview backend disconnected.",D.innerHTML=`<g clip-path="url(#clip0_6013_33858)">
20
+ `)}var IA=U(Q(),1);var mA=U(Q(),1);var JJ={new:"new",connecting:"connecting",connected:"connected",disconnected:"interrupted",failed:"failed",closed:"closed"};function zb(t){return JJ[t]}function gA(t){let n=new mA.BehaviorSubject(zb(t.connectionState)),e=!1,r=()=>{e||t.connectionState!=="closed"&&n.next(zb(t.connectionState))};return t.addEventListener("connectionstatechange",r),{lifecycle$:n.asObservable(),snapshot:()=>n.getValue(),close:()=>{e||(e=!0,t.removeEventListener("connectionstatechange",r),n.next("closed"),n.complete(),t.close())}}}function yA(t,n,e){let r=o=>{let s=o?.candidate;s&&n({candidate:s})},i=()=>{(async()=>{e?.(!0);try{let o=await t.createOffer();await t.setLocalDescription(o),t.localDescription&&n({offer:t.localDescription})}catch(o){console.warn("[wire-pc-signals] abandon own offer (glare/state race):",o instanceof Error?o.message:o)}finally{e?.(!1)}})()};return t.addEventListener("icecandidate",r),t.addEventListener("negotiationneeded",i),()=>{t.removeEventListener("icecandidate",r),t.removeEventListener("negotiationneeded",i)}}var vA=U(Q(),1);function yp(t){return new vA.Observable(n=>{let e=i=>n.next(i?.data),r=()=>n.complete();return t.addEventListener("message",e),t.addEventListener("close",r),()=>{t.removeEventListener("message",e),t.removeEventListener("close",r)}})}function _A(t){let n=[],e=!1,r=i=>t.addIceCandidate(i).catch(()=>{});return{addCandidate(i){t.remoteDescription?r(i):n.push(i)},async flush(){if(e)return;e=!0;let i=n.splice(0);for(let o of i)await r(o)}}}async function bA(t,n,e,r){if("candidate"in e){n.addCandidate(e.candidate);return}if("answer"in e){await t.setRemoteDescription(e.answer),await n.flush();return}let i=r.makingOffer||t.signalingState!=="stable";if(!r.polite&&i)return;i&&t.signalingState!=="stable"&&await t.setLocalDescription({type:"rollback"}),await t.setRemoteDescription(e.offer);let o=await t.createAnswer();return await t.setLocalDescription(o),await n.flush(),{answer:o}}var wA=U(Q(),1);function vp(t,n,e){return new wA.Observable(r=>{if(t.readyState!=="open"){r.error(new Error("[send-sink] channel_closed"));return}if(e?.aborted){r.error(new Error("[send-sink] aborted"));return}if(t.send(n),t.bufferedAmount<=t.bufferedAmountLowThreshold){r.complete();return}let i=()=>r.complete(),o=()=>r.error(new Error("[send-sink] aborted"));return t.addEventListener("bufferedamountlow",i),e?.addEventListener("abort",o),()=>{t.removeEventListener("bufferedamountlow",i),e?.removeEventListener("abort",o)}})}var Kb=U(Q(),1);function EA(t){return{label:t.label,messages$:yp(t),send$:(n,e)=>vp(t,n,e)}}function SA(t,n,e){return new Kb.Observable(r=>{let i=t.createDataChannel(n,Ns[e]),o=()=>r.next(EA(i));return i.readyState==="open"?o():i.addEventListener("open",o),()=>{i.removeEventListener("open",o),i.close()}})}function CA(t,n=()=>!1){return new Kb.Observable(e=>{let r=i=>{let o=i?.channel;!o||n(o.label)||e.next(EA(o))};return t.addEventListener("datachannel",r),()=>t.removeEventListener("datachannel",r)})}function TA(t,n,e){let r=gA(t),i=_A(t),o=new IA.Subject,s=!1,a=!1,c=yA(t,l=>o.next(l),l=>{s=l}),u=e.restartTimeoutMs??15e3;return{lifecycle$:r.lifecycle$,outgoing$:o.asObservable(),messages$:yp(n),openChannel:(l,d)=>SA(t,l,d),incomingChannels$:CA(t,e.isMainChannelLabel),diagnostics$:HO(t),snapshot:()=>r.snapshot(),restartIce$:()=>up(t,r.lifecycle$,u),applySignal:l=>bA(t,i,l,{polite:e.polite,makingOffer:s}),send$:(l,d)=>vp(n,l,d),close:()=>{a||(a=!0,c(),o.complete(),r.close())}}}function xA(t){return t.connectionState==="closed"?Promise.resolve():new Promise(n=>{let e=null,r=()=>{t.connectionState==="closed"&&(t.removeEventListener("connectionstatechange",r),e!==null&&clearTimeout(e),n())};t.addEventListener("connectionstatechange",r),e=setTimeout(()=>{t.removeEventListener("connectionstatechange",r),n()},2e3)})}function DA(t){return{get readyState(){return t()?.readyState??"connecting"},get bufferedAmount(){return t()?.bufferedAmount??0},get bufferedAmountLowThreshold(){return t()?.bufferedAmountLowThreshold??0},addEventListener:(n,e)=>t()?.addEventListener(n,e),removeEventListener:(n,e)=>t()?.removeEventListener(n,e),send:n=>t()?.send(n)}}function OA(t,n){let e=new AbortController,r={signal:e.signal};return t.addEventListener("open",()=>n.onConnect(),r),t.addEventListener("message",i=>n.onData(i.data),r),t.addEventListener("close",()=>{if(!n.isDestroyed()){if(n.pcConnectionState()==="connected"){console.warn("[native-peer-adapter] mainChannel close while pc connected \u2014 suppress cascade (peer alive, defer to pc.connectionState + heartbeat)",{connectionState:n.pcConnectionState(),iceConnectionState:n.pcIceConnectionState()});return}n.onCascadeClose()}},r),()=>e.abort()}function MA(t,n){if(n.isDestroyed())return;if(!n.polite){try{t.close()}catch{}return}let e=n.currentMainChannel();n.attachMainChannel(t);try{e?.close()}catch{}}var AA=U(Q(),1);function NA(t,n,e){let r=new AA.Observable(i=>{let o=s=>{let a=s.channel;a&&a.label!==e&&i.next(a)};return t.addEventListener("datachannel",o),()=>t.removeEventListener("datachannel",o)});return{get connectionState(){return t.connectionState},lifecycle$:n.lifecycle$,diagnostics$:n.diagnostics$,incomingChannels$:r,createDataChannel:(i,o)=>t.createDataChannel(i,o),getStats:()=>t.getStats(),captureDiagnosticsSnapshot:()=>Pb(t)}}function PA(t,n){"candidate"in t?n({candidate:t.candidate}):"offer"in t?n({type:"offer",sdp:t.offer.sdp}):n({type:"answer",sdp:t.answer.sdp})}async function RA(t,n,e,r){if(n.type==="offer"||n.type==="answer"){let i={type:n.type,sdp:n.sdp},o=await t.applySignal(n.type==="offer"?{offer:i}:{answer:i});o&&e({type:"answer",sdp:r()??o.answer.sdp})}else n.candidate&&await t.applySignal({candidate:n.candidate})}var pc="default",_p=class{constructor(n){this.listeners=new Map,this._connected=!1,this._destroyed=!1;let e={...n.config??{}};e.iceCandidatePoolSize==null&&(e.iceCandidatePoolSize=0),this._pc=new n.PeerConnection(e),this.skipDefaultChannel=n.skipDefaultChannel??!1,this.polite=n.polite??!n.initiator,this.reactive=TA(this._pc,DA(()=>this.mainChannel),{polite:this.polite,isMainChannelLabel:r=>r===pc}),this.channels=NA(this._pc,this.reactive,pc),this.reactive.outgoing$.subscribe(r=>PA(r,i=>this.emit("signal",i))),this.skipDefaultChannel?this._pc.addEventListener("connectionstatechange",()=>{this._destroyed||this._pc.connectionState==="connected"&&!this._connected&&(this._connected=!0,this.emit("connect"))}):n.initiator?(this.attachMainChannel(this._pc.createDataChannel(pc,{ordered:!0})),this._pc.addEventListener("datachannel",r=>{r.channel.label===pc&&MA(r.channel,{polite:this.polite,isDestroyed:()=>this._destroyed,currentMainChannel:()=>this.mainChannel,attachMainChannel:i=>this.attachMainChannel(i)})})):this._pc.addEventListener("datachannel",r=>{r.channel.label===pc&&this.attachMainChannel(r.channel)})}on(n,e){this.listeners.has(n)||this.listeners.set(n,[]),this.listeners.get(n).push(e)}async signal(n){try{await RA(this.reactive,n,e=>this.emit("signal",e),()=>this._pc.localDescription?.sdp)}catch(e){this.emit("error",e instanceof Error?e:new Error(String(e)))}}send(n){this._destroyed||!this.mainChannel||this.mainChannel.readyState!=="open"||this.mainChannel.send(n)}async destroy(){if(!this._destroyed){this._destroyed=!0,this._connected=!1;try{this.mainChannel?.close()}catch{}try{this.reactive.close()}catch{}await xA(this._pc),this.emit("close"),this.listeners.clear()}}get connected(){return this._connected&&!this._destroyed&&this._pc.connectionState==="connected"}get destroyed(){return this._destroyed}get connectionState(){return this._pc.connectionState}get signalingState(){return this._pc.signalingState}restartIce(){this._pc.restartIce()}attachMainChannel(n){this.mainChannelDetach?.(),this.mainChannel=n,this.mainChannelDetach=OA(n,{isDestroyed:()=>this._destroyed,pcConnectionState:()=>this._pc.connectionState,pcIceConnectionState:()=>this._pc.iceConnectionState,onConnect:()=>{this._connected=!0,this.emit("connect")},onData:e=>this.emit("data",e),onCascadeClose:()=>this.emit("close")}),n.readyState==="open"&&!this._connected&&(this._connected=!0,this.emit("connect"))}emit(n,...e){let r=this.listeners.get(n);if(r)for(let i of[...r])try{i(...e)}catch{}}};var kA;try{kA=jR("@roamhq/wrtc")}catch{}var XJ=(()=>{class t extends uc{create(e){return new _p({initiator:e.initiator,polite:e.polite,config:this.config().peerSessionOptions.config,PeerConnection:kA?.RTCPeerConnection})}static{this.\u0275fac=(()=>{let e;return function(i){return(e||(e=Bt(t)))(i||t)}})()}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();function Yb(){return[{provide:uc,useClass:XJ}]}var LA=new _e("CONFIG_FILE_PATH"),jA=new _e("IDENTITY_OVERRIDE"),eX=(()=>{class t extends ds{constructor(){super(...arguments),this.configPath=w(LA),this.identityOverride=w(jA,{optional:!0})}async loadConfig(){let e=await import("fs/promises");try{let r=await e.readFile(this.configPath,"utf-8");return JSON.parse(r)}catch(r){if(r.code==="ENOENT")return{};throw r}}static{this.atomicWriteCounter=0}async saveConfig(e){let r=await import("fs/promises"),i=await import("path");await r.mkdir(i.dirname(this.configPath),{recursive:!0});let o=`${this.configPath}.${process.pid}.${++t.atomicWriteCounter}.tmp`;await r.writeFile(o,JSON.stringify(e,null,2),{mode:384}),await r.rename(o,this.configPath)}async save(e){let r=await this.loadConfig();r.identity={publicKey:e.publicKey,privateKey:e.privateKey,algorithm:e.algorithm,createdAt:e.createdAt.toISOString()},await this.saveConfig(r)}async load(){if(this.identityOverride)return this.identityOverride;let e=await this.loadConfig();return e.identity?{publicKey:e.identity.publicKey,privateKey:e.identity.privateKey,algorithm:e.identity.algorithm,createdAt:new Date(e.identity.createdAt)}:null}async exists(){return this.identityOverride?!0:!!(await this.loadConfig()).identity}async delete(){let e=await this.loadConfig();delete e.identity,await this.saveConfig(e)}async saveBackup(e,r){let i=await this.loadConfig(),o={publicKey:e.publicKey,privateKey:e.privateKey,algorithm:e.algorithm,createdAt:e.createdAt.toISOString(),rotatedAt:r};i.identityBackups=i.identityBackups||[],i.identityBackups.push(o),await this.saveConfig(i)}async loadBackups(){let e=await this.loadConfig();return e.identityBackups?e.identityBackups.map(r=>({keyPair:{publicKey:r.publicKey,privateKey:r.privateKey,algorithm:r.algorithm,createdAt:new Date(r.createdAt)},rotatedAt:r.rotatedAt})):[]}async cleanupBackups(e){let r=await this.loadConfig();if(!r.identityBackups)return;let i=Date.now()-e;r.identityBackups=r.identityBackups.filter(o=>o.rotatedAt>i),await this.saveConfig(r)}static{this.\u0275fac=(()=>{let e;return function(i){return(e||(e=Bt(t)))(i||t)}})()}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();function bp(t,n){return[{provide:LA,useValue:t},{provide:ds,useClass:eX},{provide:jA,useValue:n??null}]}async function tX(){try{return await import("node:crypto")}catch(t){let n=globalThis.cryptoModule;if(n)return n;throw t}}var nX=(()=>{class t extends ls{async generateKeyPair(){let e=await tX(),r=e,i=typeof self<"u"?self:void 0;if(typeof r.generateKeyPairSync!="function"&&i?.crypto?.subtle){let a=i.crypto.subtle,c=await a.generateKey({name:"ECDSA",namedCurve:"P-256"},!0,["sign","verify"]),u=await a.exportKey("spki",c.publicKey),l=await a.exportKey("pkcs8",c.privateKey);return{publicKey:this.bufferToBase64(u),privateKey:this.bufferToBase64(l),algorithm:"P-256",createdAt:new Date}}let{publicKey:o,privateKey:s}=e.generateKeyPairSync("ec",{namedCurve:"prime256v1",publicKeyEncoding:{type:"spki",format:"der"},privateKeyEncoding:{type:"pkcs8",format:"der"}});return{publicKey:o.toString("base64"),privateKey:s.toString("base64"),algorithm:"P-256",createdAt:new Date}}static{this.\u0275fac=(()=>{let e;return function(i){return(e||(e=Bt(t)))(i||t)}})()}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();function FA(){return[{provide:ls,useClass:nX}]}import*as Nt from"node:crypto";var rX=(()=>{class t extends Hr{constructor(){super(...arguments),this.derivedKeys=new Map}async deriveSharedKey(e,r){let i=Buffer.from(e,"base64"),o=Nt.createPrivateKey({key:i,format:"der",type:"pkcs8"}),s=Buffer.from(r,"base64"),a=Nt.createPublicKey({key:s,format:"der",type:"spki"}),c=Nt.diffieHellman({privateKey:o,publicKey:a}),u=Nt.createHash("sha256").update(c).digest(),l=`${e.substring(0,20)}_${r.substring(0,20)}`;return this.derivedKeys.set(l,u),{cacheKey:l}}async encryptBytes(e,r){let{cacheKey:i}=r,o=this.derivedKeys.get(i);if(!o)throw new Error("Shared key not found");let s=Nt.randomBytes(12),a=Nt.createCipheriv("aes-256-gcm",o,s),c=Buffer.concat([a.update(e),a.final()]),u=a.getAuthTag();return{encrypted:Buffer.concat([c,u]).toString("base64"),iv:s.toString("base64")}}async decryptBytes(e,r,i){let{cacheKey:o}=i,s=this.derivedKeys.get(o);if(!s)throw new Error("Shared key not found");let a=Buffer.from(e,"base64"),c=a.subarray(-16),u=a.subarray(0,-16),l=Nt.createDecipheriv("aes-256-gcm",s,Buffer.from(r,"base64"));l.setAuthTag(c);let d=Buffer.concat([l.update(u),l.final()]);return new Uint8Array(d)}static{this.\u0275fac=(()=>{let e;return function(i){return(e||(e=Bt(t)))(i||t)}})()}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();function $A(){return[{provide:Hr,useClass:rX}]}async function qA(){try{return await import("node:crypto")}catch(t){let n=globalThis.cryptoModule;if(n)return n;throw t}}var iX=(()=>{class t extends Pi{async createSignature(e,r){let i=await qA(),o=i.createPrivateKey({key:Buffer.from(r,"base64"),format:"der",type:"pkcs8"}),s=i.createSign("SHA256");return s.update(e),s.sign(o).toString("base64")}async verifySignature(e,r,i){let o=await qA(),s=o.createPublicKey({key:Buffer.from(i,"base64"),format:"der",type:"spki"}),a=Buffer.from(r,"base64"),c=this.isRawSignature(a)?this.rawToDer(a):a,u=o.createVerify("SHA256");return u.update(e),u.verify(s,c)}isRawSignature(e){return e.length===64}rawToDer(e){let r=e.subarray(0,32),i=e.subarray(32,64),o=r[0]>=128?Buffer.concat([Buffer.from([0]),r]):this.trimLeadingZeros(r),s=i[0]>=128?Buffer.concat([Buffer.from([0]),i]):this.trimLeadingZeros(i),a=Buffer.concat([Buffer.from([2,o.length]),o]),c=Buffer.concat([Buffer.from([2,s.length]),s]),u=a.length+c.length;return Buffer.concat([Buffer.from([48,u]),a,c])}trimLeadingZeros(e){let r=0;for(;r<e.length-1&&e[r]===0&&e[r+1]<128;)r++;return e.subarray(r)}static{this.\u0275fac=(()=>{let e;return function(i){return(e||(e=Bt(t)))(i||t)}})()}static{this.\u0275prov=N({token:t,factory:t.\u0275fac})}}return t})();function BA(){return[{provide:Pi,useClass:iX}]}function wp(t){return[...FA(),...$A(),{provide:Ur,useClass:R_},...BA(),...bp(t.keyFilePath,t.identityOverride)]}import{WebSocketServer as mke}from"ws";import Eee from"faye-websocket";var HA=()=>{};var Ep={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"};var A=function(t,n){if(!t)throw Vi(n)},Vi=function(t){return new Error("Firebase Database ("+Ep.SDK_VERSION+") INTERNAL ASSERT FAILED: "+t)};var WA=function(t){let n=[],e=0;for(let r=0;r<t.length;r++){let i=t.charCodeAt(r);i<128?n[e++]=i:i<2048?(n[e++]=i>>6|192,n[e++]=i&63|128):(i&64512)===55296&&r+1<t.length&&(t.charCodeAt(r+1)&64512)===56320?(i=65536+((i&1023)<<10)+(t.charCodeAt(++r)&1023),n[e++]=i>>18|240,n[e++]=i>>12&63|128,n[e++]=i>>6&63|128,n[e++]=i&63|128):(n[e++]=i>>12|224,n[e++]=i>>6&63|128,n[e++]=i&63|128)}return n},cX=function(t){let n=[],e=0,r=0;for(;e<t.length;){let i=t[e++];if(i<128)n[r++]=String.fromCharCode(i);else if(i>191&&i<224){let o=t[e++];n[r++]=String.fromCharCode((i&31)<<6|o&63)}else if(i>239&&i<365){let o=t[e++],s=t[e++],a=t[e++],c=((i&7)<<18|(o&63)<<12|(s&63)<<6|a&63)-65536;n[r++]=String.fromCharCode(55296+(c>>10)),n[r++]=String.fromCharCode(56320+(c&1023))}else{let o=t[e++],s=t[e++];n[r++]=String.fromCharCode((i&15)<<12|(o&63)<<6|s&63)}}return n.join("")},Ip={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(t,n){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();let e=n?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let i=0;i<t.length;i+=3){let o=t[i],s=i+1<t.length,a=s?t[i+1]:0,c=i+2<t.length,u=c?t[i+2]:0,l=o>>2,d=(o&3)<<4|a>>4,f=(a&15)<<2|u>>6,p=u&63;c||(p=64,s||(f=64)),r.push(e[l],e[d],e[f],e[p])}return r.join("")},encodeString(t,n){return this.HAS_NATIVE_SUPPORT&&!n?btoa(t):this.encodeByteArray(WA(t),n)},decodeString(t,n){return this.HAS_NATIVE_SUPPORT&&!n?atob(t):cX(this.decodeStringToByteArray(t,n))},decodeStringToByteArray(t,n){this.init_();let e=n?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let i=0;i<t.length;){let o=e[t.charAt(i++)],a=i<t.length?e[t.charAt(i)]:0;++i;let u=i<t.length?e[t.charAt(i)]:64;++i;let d=i<t.length?e[t.charAt(i)]:64;if(++i,o==null||a==null||u==null||d==null)throw new Zb;let f=o<<2|a>>4;if(r.push(f),u!==64){let p=a<<4&240|u>>2;if(r.push(p),d!==64){let m=u<<6&192|d;r.push(m)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let t=0;t<this.ENCODED_VALS.length;t++)this.byteToCharMap_[t]=this.ENCODED_VALS.charAt(t),this.charToByteMap_[this.byteToCharMap_[t]]=t,this.byteToCharMapWebSafe_[t]=this.ENCODED_VALS_WEBSAFE.charAt(t),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]]=t,t>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}},Zb=class extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}},Qb=function(t){let n=WA(t);return Ip.encodeByteArray(n,!0)},gc=function(t){return Qb(t).replace(/\./g,"")},Sp=function(t){try{return Ip.decodeString(t,!0)}catch(n){console.error("base64Decode failed: ",n)}return null};function GA(t){return zA(void 0,t)}function zA(t,n){if(!(n instanceof Object))return n;switch(n.constructor){case Date:let e=n;return new Date(e.getTime());case Object:t===void 0&&(t={});break;case Array:t=[];break;default:return n}for(let e in n)!n.hasOwnProperty(e)||!uX(e)||(t[e]=zA(t[e],n[e]));return t}function uX(t){return t!=="__proto__"}function lX(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}var dX=()=>lX().__FIREBASE_DEFAULTS__,fX=()=>{if(typeof process>"u"||typeof process.env>"u")return;let t=process.env.__FIREBASE_DEFAULTS__;if(t)return JSON.parse(t)},hX=()=>{if(typeof document>"u")return;let t;try{t=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}let n=t&&Sp(t[1]);return n&&JSON.parse(n)},KA=()=>{try{return HA()||dX()||fX()||hX()}catch(t){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${t}`);return}},pX=t=>KA()?.emulatorHosts?.[t],YA=t=>{let n=pX(t);if(!n)return;let e=n.lastIndexOf(":");if(e<=0||e+1===n.length)throw new Error(`Invalid host ${n} with no separate hostname and port!`);let r=parseInt(n.substring(e+1),10);return n[0]==="["?[n.substring(1,e-1),r]:[n.substring(0,e),r]},Jb=()=>KA()?.config;var Wt=class{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((n,e)=>{this.resolve=n,this.reject=e})}wrapCallback(n){return(e,r)=>{e?this.reject(e):this.resolve(r),typeof n=="function"&&(this.promise.catch(()=>{}),n.length===1?n(e):n(e,r))}}};function Tp(t){try{return(t.startsWith("http://")||t.startsWith("https://")?new URL(t).hostname:t).endsWith(".cloudworkstations.dev")}catch{return!1}}async function ZA(t){return(await fetch(t,{credentials:"include"})).ok}function QA(t,n){if(t.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');let e={alg:"none",type:"JWT"},r=n||"demo-project",i=t.iat||0,o=t.sub||t.user_id;if(!o)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");let s={iss:`https://securetoken.google.com/${r}`,aud:r,iat:i,exp:i+3600,auth_time:i,sub:o,user_id:o,firebase:{sign_in_provider:"custom",identities:{}},...t};return[gc(JSON.stringify(e)),gc(JSON.stringify(s)),""].join(".")}var mc={};function mX(){let t={prod:[],emulator:[]};for(let n of Object.keys(mc))mc[n]?t.emulator.push(n):t.prod.push(n);return t}function gX(t){let n=document.getElementById(t),e=!1;return n||(n=document.createElement("div"),n.setAttribute("id",t),e=!0),{created:e,element:n}}var UA=!1;function JA(t,n){if(typeof window>"u"||typeof document>"u"||!Tp(window.location.host)||mc[t]===n||mc[t]||UA)return;mc[t]=n;function e(f){return`__firebase__banner__${f}`}let r="__firebase__banner",o=mX().prod.length>0;function s(){let f=document.getElementById(r);f&&f.remove()}function a(f){f.style.display="flex",f.style.background="#7faaf0",f.style.position="fixed",f.style.bottom="5px",f.style.left="5px",f.style.padding=".5em",f.style.borderRadius="5px",f.style.alignItems="center"}function c(f,p){f.setAttribute("width","24"),f.setAttribute("id",p),f.setAttribute("height","24"),f.setAttribute("viewBox","0 0 24 24"),f.setAttribute("fill","none"),f.style.marginLeft="-6px"}function u(){let f=document.createElement("span");return f.style.cursor="pointer",f.style.marginLeft="16px",f.style.fontSize="24px",f.innerHTML=" &times;",f.onclick=()=>{UA=!0,s()},f}function l(f,p){f.setAttribute("id",p),f.innerText="Learn more",f.href="https://firebase.google.com/docs/studio/preview-apps#preview-backend",f.setAttribute("target","__blank"),f.style.paddingLeft="5px",f.style.textDecoration="underline"}function d(){let f=gX(r),p=e("text"),m=document.getElementById(p)||document.createElement("span"),y=e("learnmore"),b=document.getElementById(y)||document.createElement("a"),E=e("preprendIcon"),D=document.getElementById(E)||document.createElementNS("http://www.w3.org/2000/svg","svg");if(f.created){let T=f.element;a(T),l(b,y);let K=u();c(D,E),T.append(D,m,b,K),document.body.appendChild(T)}o?(m.innerText="Preview backend disconnected.",D.innerHTML=`<g clip-path="url(#clip0_6013_33858)">
21
21
  <path d="M4.8 17.6L12 5.6L19.2 17.6H4.8ZM6.91667 16.4H17.0833L12 7.93333L6.91667 16.4ZM12 15.6C12.1667 15.6 12.3056 15.5444 12.4167 15.4333C12.5389 15.3111 12.6 15.1667 12.6 15C12.6 14.8333 12.5389 14.6944 12.4167 14.5833C12.3056 14.4611 12.1667 14.4 12 14.4C11.8333 14.4 11.6889 14.4611 11.5667 14.5833C11.4556 14.6944 11.4 14.8333 11.4 15C11.4 15.1667 11.4556 15.3111 11.5667 15.4333C11.6889 15.5444 11.8333 15.6 12 15.6ZM11.4 13.6H12.6V10.4H11.4V13.6Z" fill="#212121"/>
22
22
  </g>
23
23
  <defs>
@@ -31,13 +31,13 @@ If you want to call this function on the server, see https://trpc.io/docs/v11/se
31
31
  <clipPath id="clip0_6083_34804">
32
32
  <rect width="24" height="24" fill="white"/>
33
33
  </clipPath>
34
- </defs>`,m.innerText="Preview backend running in this workspace."),m.setAttribute("id",p)}document.readyState==="loading"?window.addEventListener("DOMContentLoaded",d):d()}function gX(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function Xb(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(gX())}function XA(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function Mn(){return Ep.NODE_CLIENT===!0||Ep.NODE_ADMIN===!0}function eN(){try{return typeof indexedDB=="object"}catch{return!1}}function tN(){return new Promise((t,n)=>{try{let e=!0,r="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close(),e||self.indexedDB.deleteDatabase(r),t(!0)},i.onupgradeneeded=()=>{e=!1},i.onerror=()=>{n(i.error?.message||"")}}catch(e){n(e)}})}var yX="FirebaseError",Ui=class t extends Error{constructor(n,e,r){super(e),this.code=n,this.customData=r,this.name=yX,Object.setPrototypeOf(this,t.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,yc.prototype.create)}},yc=class{constructor(n,e,r){this.service=n,this.serviceName=e,this.errors=r}create(n,...e){let r=e[0]||{},i=`${this.service}/${n}`,o=this.errors[n],s=o?vX(o,r):"Error",a=`${this.serviceName}: ${s} (${i}).`;return new Ui(i,a,r)}};function vX(t,n){return t.replace(_X,(e,r)=>{let i=n[r];return i!=null?String(i):`<${r}?>`})}var _X=/\{\$([^}]+)}/g;function Fs(t){return JSON.parse(t)}function nt(t){return JSON.stringify(t)}var nN=function(t){let n={},e={},r={},i="";try{let o=t.split(".");n=Fs(Sp(o[0])||""),e=Fs(Sp(o[1])||""),i=o[2],r=e.d||{},delete e.d}catch{}return{header:n,claims:e,data:r,signature:i}};var rN=function(t){let n=nN(t),e=n.claims;return!!e&&typeof e=="object"&&e.hasOwnProperty("iat")},iN=function(t){let n=nN(t).claims;return typeof n=="object"&&n.admin===!0};function ln(t,n){return Object.prototype.hasOwnProperty.call(t,n)}function Wi(t,n){if(Object.prototype.hasOwnProperty.call(t,n))return t[n]}function xp(t){for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n))return!1;return!0}function vc(t,n,e){let r={};for(let i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[i]=n.call(e,t[i],i,t));return r}function $s(t,n){if(t===n)return!0;let e=Object.keys(t),r=Object.keys(n);for(let i of e){if(!r.includes(i))return!1;let o=t[i],s=n[i];if(VA(o)&&VA(s)){if(!$s(o,s))return!1}else if(o!==s)return!1}for(let i of r)if(!e.includes(i))return!1;return!0}function VA(t){return t!==null&&typeof t=="object"}function oN(t){let n=[];for(let[e,r]of Object.entries(t))Array.isArray(r)?r.forEach(i=>{n.push(encodeURIComponent(e)+"="+encodeURIComponent(i))}):n.push(encodeURIComponent(e)+"="+encodeURIComponent(r));return n.length?"&"+n.join("&"):""}var Cp=class{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=512/8,this.pad_[0]=128;for(let n=1;n<this.blockSize;++n)this.pad_[n]=0;this.reset()}reset(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0}compress_(n,e){e||(e=0);let r=this.W_;if(typeof n=="string")for(let d=0;d<16;d++)r[d]=n.charCodeAt(e)<<24|n.charCodeAt(e+1)<<16|n.charCodeAt(e+2)<<8|n.charCodeAt(e+3),e+=4;else for(let d=0;d<16;d++)r[d]=n[e]<<24|n[e+1]<<16|n[e+2]<<8|n[e+3],e+=4;for(let d=16;d<80;d++){let f=r[d-3]^r[d-8]^r[d-14]^r[d-16];r[d]=(f<<1|f>>>31)&4294967295}let i=this.chain_[0],o=this.chain_[1],s=this.chain_[2],a=this.chain_[3],c=this.chain_[4],u,l;for(let d=0;d<80;d++){d<40?d<20?(u=a^o&(s^a),l=1518500249):(u=o^s^a,l=1859775393):d<60?(u=o&s|a&(o|s),l=2400959708):(u=o^s^a,l=3395469782);let f=(i<<5|i>>>27)+u+c+l+r[d]&4294967295;c=a,a=s,s=(o<<30|o>>>2)&4294967295,o=i,i=f}this.chain_[0]=this.chain_[0]+i&4294967295,this.chain_[1]=this.chain_[1]+o&4294967295,this.chain_[2]=this.chain_[2]+s&4294967295,this.chain_[3]=this.chain_[3]+a&4294967295,this.chain_[4]=this.chain_[4]+c&4294967295}update(n,e){if(n==null)return;e===void 0&&(e=n.length);let r=e-this.blockSize,i=0,o=this.buf_,s=this.inbuf_;for(;i<e;){if(s===0)for(;i<=r;)this.compress_(n,i),i+=this.blockSize;if(typeof n=="string"){for(;i<e;)if(o[s]=n.charCodeAt(i),++s,++i,s===this.blockSize){this.compress_(o),s=0;break}}else for(;i<e;)if(o[s]=n[i],++s,++i,s===this.blockSize){this.compress_(o),s=0;break}}this.inbuf_=s,this.total_+=e}digest(){let n=[],e=this.total_*8;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let i=this.blockSize-1;i>=56;i--)this.buf_[i]=e&255,e/=256;this.compress_(this.buf_);let r=0;for(let i=0;i<5;i++)for(let o=24;o>=0;o-=8)n[r]=this.chain_[i]>>o&255,++r;return n}};function Gi(t,n){return`${t} failed: ${n} argument `}var sN=function(t){let n=[],e=0;for(let r=0;r<t.length;r++){let i=t.charCodeAt(r);if(i>=55296&&i<=56319){let o=i-55296;r++,A(r<t.length,"Surrogate pair missing trail surrogate.");let s=t.charCodeAt(r)-56320;i=65536+(o<<10)+s}i<128?n[e++]=i:i<2048?(n[e++]=i>>6|192,n[e++]=i&63|128):i<65536?(n[e++]=i>>12|224,n[e++]=i>>6&63|128,n[e++]=i&63|128):(n[e++]=i>>18|240,n[e++]=i>>12&63|128,n[e++]=i>>6&63|128,n[e++]=i&63|128)}return n},_c=function(t){let n=0;for(let e=0;e<t.length;e++){let r=t.charCodeAt(e);r<128?n++:r<2048?n+=2:r>=55296&&r<=56319?(n+=4,e++):n+=3}return n};var Lke=14400*1e3;function Jr(t){return t&&t._delegate?t._delegate:t}Ep.NODE_CLIENT=!0;var bX=[],Ve=(function(t){return t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT",t})(Ve||{}),wX={debug:Ve.DEBUG,verbose:Ve.VERBOSE,info:Ve.INFO,warn:Ve.WARN,error:Ve.ERROR,silent:Ve.SILENT},EX=Ve.INFO,SX={[Ve.DEBUG]:"log",[Ve.VERBOSE]:"log",[Ve.INFO]:"info",[Ve.WARN]:"warn",[Ve.ERROR]:"error"},CX=(t,n,...e)=>{if(n<t.logLevel)return;let r=new Date().toISOString(),i=SX[n];if(i)console[i](`[${r}] ${t.name}:`,...e);else throw new Error(`Attempted to log a message with an invalid logType (value: ${n})`)},qs=class{constructor(n){this.name=n,this._logLevel=EX,this._logHandler=CX,this._userLogHandler=null,bX.push(this)}get logLevel(){return this._logLevel}set logLevel(n){if(!(n in Ve))throw new TypeError(`Invalid value "${n}" assigned to \`logLevel\``);this._logLevel=n}setLogLevel(n){this._logLevel=typeof n=="string"?wX[n]:n}get logHandler(){return this._logHandler}set logHandler(n){if(typeof n!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=n}get userLogHandler(){return this._userLogHandler}set userLogHandler(n){this._userLogHandler=n}debug(...n){this._userLogHandler&&this._userLogHandler(this,Ve.DEBUG,...n),this._logHandler(this,Ve.DEBUG,...n)}log(...n){this._userLogHandler&&this._userLogHandler(this,Ve.VERBOSE,...n),this._logHandler(this,Ve.VERBOSE,...n)}info(...n){this._userLogHandler&&this._userLogHandler(this,Ve.INFO,...n),this._logHandler(this,Ve.INFO,...n)}warn(...n){this._userLogHandler&&this._userLogHandler(this,Ve.WARN,...n),this._logHandler(this,Ve.WARN,...n)}error(...n){this._userLogHandler&&this._userLogHandler(this,Ve.ERROR,...n),this._logHandler(this,Ve.ERROR,...n)}};var er=class{constructor(n,e,r){this.name=n,this.instanceFactory=e,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(n){return this.instantiationMode=n,this}setMultipleInstances(n){return this.multipleInstances=n,this}setServiceProps(n){return this.serviceProps=n,this}setInstanceCreatedCallback(n){return this.onInstanceCreated=n,this}};var zi="[DEFAULT]";var Dp=class{constructor(n,e){this.name=n,this.container=e,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(n){let e=this.normalizeInstanceIdentifier(n);if(!this.instancesDeferred.has(e)){let r=new Wt;if(this.instancesDeferred.set(e,r),this.isInitialized(e)||this.shouldAutoInitialize())try{let i=this.getOrInitializeService({instanceIdentifier:e});i&&r.resolve(i)}catch{}}return this.instancesDeferred.get(e).promise}getImmediate(n){let e=this.normalizeInstanceIdentifier(n?.identifier),r=n?.optional??!1;if(this.isInitialized(e)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:e})}catch(i){if(r)return null;throw i}else{if(r)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(n){if(n.name!==this.name)throw Error(`Mismatching Component ${n.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=n,!!this.shouldAutoInitialize()){if(TX(n))try{this.getOrInitializeService({instanceIdentifier:zi})}catch{}for(let[e,r]of this.instancesDeferred.entries()){let i=this.normalizeInstanceIdentifier(e);try{let o=this.getOrInitializeService({instanceIdentifier:i});r.resolve(o)}catch{}}}}clearInstance(n=zi){this.instancesDeferred.delete(n),this.instancesOptions.delete(n),this.instances.delete(n)}async delete(){let n=Array.from(this.instances.values());await Promise.all([...n.filter(e=>"INTERNAL"in e).map(e=>e.INTERNAL.delete()),...n.filter(e=>"_delete"in e).map(e=>e._delete())])}isComponentSet(){return this.component!=null}isInitialized(n=zi){return this.instances.has(n)}getOptions(n=zi){return this.instancesOptions.get(n)||{}}initialize(n={}){let{options:e={}}=n,r=this.normalizeInstanceIdentifier(n.instanceIdentifier);if(this.isInitialized(r))throw Error(`${this.name}(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);let i=this.getOrInitializeService({instanceIdentifier:r,options:e});for(let[o,s]of this.instancesDeferred.entries()){let a=this.normalizeInstanceIdentifier(o);r===a&&s.resolve(i)}return i}onInit(n,e){let r=this.normalizeInstanceIdentifier(e),i=this.onInitCallbacks.get(r)??new Set;i.add(n),this.onInitCallbacks.set(r,i);let o=this.instances.get(r);return o&&n(o,r),()=>{i.delete(n)}}invokeOnInitCallbacks(n,e){let r=this.onInitCallbacks.get(e);if(r)for(let i of r)try{i(n,e)}catch{}}getOrInitializeService({instanceIdentifier:n,options:e={}}){let r=this.instances.get(n);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:IX(n),options:e}),this.instances.set(n,r),this.instancesOptions.set(n,e),this.invokeOnInitCallbacks(r,n),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,n,r)}catch{}return r||null}normalizeInstanceIdentifier(n=zi){return this.component?this.component.multipleInstances?n:zi:n}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}};function IX(t){return t===zi?void 0:t}function TX(t){return t.instantiationMode==="EAGER"}var bc=class{constructor(n){this.name=n,this.providers=new Map}addComponent(n){let e=this.getProvider(n.name);if(e.isComponentSet())throw new Error(`Component ${n.name} has already been registered with ${this.name}`);e.setComponent(n)}addOrOverwriteComponent(n){this.getProvider(n.name).isComponentSet()&&this.providers.delete(n.name),this.addComponent(n)}getProvider(n){if(this.providers.has(n))return this.providers.get(n);let e=new Dp(n,this);return this.providers.set(n,e),e}getProviders(){return Array.from(this.providers.values())}};var xX=(t,n)=>n.some(e=>t instanceof e),aN,cN;function DX(){return aN||(aN=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function OX(){return cN||(cN=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var uN=new WeakMap,tw=new WeakMap,lN=new WeakMap,ew=new WeakMap,rw=new WeakMap;function MX(t){let n=new Promise((e,r)=>{let i=()=>{t.removeEventListener("success",o),t.removeEventListener("error",s)},o=()=>{e(An(t.result)),i()},s=()=>{r(t.error),i()};t.addEventListener("success",o),t.addEventListener("error",s)});return n.then(e=>{e instanceof IDBCursor&&uN.set(e,t)}).catch(()=>{}),rw.set(n,t),n}function AX(t){if(tw.has(t))return;let n=new Promise((e,r)=>{let i=()=>{t.removeEventListener("complete",o),t.removeEventListener("error",s),t.removeEventListener("abort",s)},o=()=>{e(),i()},s=()=>{r(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",o),t.addEventListener("error",s),t.addEventListener("abort",s)});tw.set(t,n)}var nw={get(t,n,e){if(t instanceof IDBTransaction){if(n==="done")return tw.get(t);if(n==="objectStoreNames")return t.objectStoreNames||lN.get(t);if(n==="store")return e.objectStoreNames[1]?void 0:e.objectStore(e.objectStoreNames[0])}return An(t[n])},set(t,n,e){return t[n]=e,!0},has(t,n){return t instanceof IDBTransaction&&(n==="done"||n==="store")?!0:n in t}};function dN(t){nw=t(nw)}function NX(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(n,...e){let r=t.call(Op(this),n,...e);return lN.set(r,n.sort?n.sort():[n]),An(r)}:OX().includes(t)?function(...n){return t.apply(Op(this),n),An(uN.get(this))}:function(...n){return An(t.apply(Op(this),n))}}function PX(t){return typeof t=="function"?NX(t):(t instanceof IDBTransaction&&AX(t),xX(t,DX())?new Proxy(t,nw):t)}function An(t){if(t instanceof IDBRequest)return MX(t);if(ew.has(t))return ew.get(t);let n=PX(t);return n!==t&&(ew.set(t,n),rw.set(n,t)),n}var Op=t=>rw.get(t);function hN(t,n,{blocked:e,upgrade:r,blocking:i,terminated:o}={}){let s=indexedDB.open(t,n),a=An(s);return r&&s.addEventListener("upgradeneeded",c=>{r(An(s.result),c.oldVersion,c.newVersion,An(s.transaction),c)}),e&&s.addEventListener("blocked",c=>e(c.oldVersion,c.newVersion,c)),a.then(c=>{o&&c.addEventListener("close",()=>o()),i&&c.addEventListener("versionchange",u=>i(u.oldVersion,u.newVersion,u))}).catch(()=>{}),a}var RX=["get","getKey","getAll","getAllKeys","count"],kX=["put","add","delete","clear"],iw=new Map;function fN(t,n){if(!(t instanceof IDBDatabase&&!(n in t)&&typeof n=="string"))return;if(iw.get(n))return iw.get(n);let e=n.replace(/FromIndex$/,""),r=n!==e,i=kX.includes(e);if(!(e in(r?IDBIndex:IDBObjectStore).prototype)||!(i||RX.includes(e)))return;let o=async function(s,...a){let c=this.transaction(s,i?"readwrite":"readonly"),u=c.store;return r&&(u=u.index(a.shift())),(await Promise.all([u[e](...a),i&&c.done]))[0]};return iw.set(n,o),o}dN(t=>({...t,get:(n,e,r)=>fN(n,e)||t.get(n,e,r),has:(n,e)=>!!fN(n,e)||t.has(n,e)}));var sw=class{constructor(n){this.container=n}getPlatformInfoString(){return this.container.getProviders().map(e=>{if(LX(e)){let r=e.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(e=>e).join(" ")}};function LX(t){return t.getComponent()?.type==="VERSION"}var aw="@firebase/app",pN="0.14.6";var tr=new qs("@firebase/app"),jX="@firebase/app-compat",FX="@firebase/analytics-compat",$X="@firebase/analytics",qX="@firebase/app-check-compat",BX="@firebase/app-check",HX="@firebase/auth",UX="@firebase/auth-compat",VX="@firebase/database",WX="@firebase/data-connect",GX="@firebase/database-compat",zX="@firebase/functions",KX="@firebase/functions-compat",YX="@firebase/installations",ZX="@firebase/installations-compat",QX="@firebase/messaging",JX="@firebase/messaging-compat",XX="@firebase/performance",eee="@firebase/performance-compat",tee="@firebase/remote-config",nee="@firebase/remote-config-compat",ree="@firebase/storage",iee="@firebase/storage-compat",oee="@firebase/firestore",see="@firebase/ai",aee="@firebase/firestore-compat",cee="firebase",uee="12.6.0";var cw="[DEFAULT]",lee={[aw]:"fire-core",[jX]:"fire-core-compat",[$X]:"fire-analytics",[FX]:"fire-analytics-compat",[BX]:"fire-app-check",[qX]:"fire-app-check-compat",[HX]:"fire-auth",[UX]:"fire-auth-compat",[VX]:"fire-rtdb",[WX]:"fire-data-connect",[GX]:"fire-rtdb-compat",[zX]:"fire-fn",[KX]:"fire-fn-compat",[YX]:"fire-iid",[ZX]:"fire-iid-compat",[QX]:"fire-fcm",[JX]:"fire-fcm-compat",[XX]:"fire-perf",[eee]:"fire-perf-compat",[tee]:"fire-rc",[nee]:"fire-rc-compat",[ree]:"fire-gcs",[iee]:"fire-gcs-compat",[oee]:"fire-fst",[aee]:"fire-fst-compat",[see]:"fire-vertex","fire-js":"fire-js",[cee]:"fire-js-all"};var wc=new Map,dee=new Map,uw=new Map;function mN(t,n){try{t.container.addComponent(n)}catch(e){tr.debug(`Component ${n.name} failed to register with FirebaseApp ${t.name}`,e)}}function Ec(t){let n=t.name;if(uw.has(n))return tr.debug(`There were multiple attempts to register component ${n}.`),!1;uw.set(n,t);for(let e of wc.values())mN(e,t);for(let e of dee.values())mN(e,t);return!0}function _N(t,n){let e=t.container.getProvider("heartbeat").getImmediate({optional:!0});return e&&e.triggerHeartbeat(),t.container.getProvider(n)}function bN(t){return t==null?!1:t.settings!==void 0}var fee={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},Xr=new yc("app","Firebase",fee);var lw=class{constructor(n,e,r){this._isDeleted=!1,this._options={...n},this._config={...e},this._name=e.name,this._automaticDataCollectionEnabled=e.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new er("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(n){this.checkDestroyed(),this._automaticDataCollectionEnabled=n}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(n){this._isDeleted=n}checkDestroyed(){if(this.isDeleted)throw Xr.create("app-deleted",{appName:this._name})}};var wN=uee;function hw(t,n={}){let e=t;typeof n!="object"&&(n={name:n});let r={name:cw,automaticDataCollectionEnabled:!0,...n},i=r.name;if(typeof i!="string"||!i)throw Xr.create("bad-app-name",{appName:String(i)});if(e||(e=Jb()),!e)throw Xr.create("no-options");let o=wc.get(i);if(o){if($s(e,o.options)&&$s(r,o.config))return o;throw Xr.create("duplicate-app",{appName:i})}let s=new bc(i);for(let c of uw.values())s.addComponent(c);let a=new lw(e,r,s);return wc.set(i,a),a}function EN(t=cw){let n=wc.get(t);if(!n&&t===cw&&Jb())return hw();if(!n)throw Xr.create("no-app",{appName:t});return n}function pw(){return Array.from(wc.values())}function ei(t,n,e){let r=lee[t]??t;e&&(r+=`-${e}`);let i=r.match(/\s|\//),o=n.match(/\s|\//);if(i||o){let s=[`Unable to register library "${r}" with version "${n}":`];i&&s.push(`library name "${r}" contains illegal characters (whitespace or "/")`),i&&o&&s.push("and"),o&&s.push(`version name "${n}" contains illegal characters (whitespace or "/")`),tr.warn(s.join(" "));return}Ec(new er(`${r}-version`,()=>({library:r,version:n}),"VERSION"))}var hee="firebase-heartbeat-database",pee=1,Sc="firebase-heartbeat-store",ow=null;function SN(){return ow||(ow=hN(hee,pee,{upgrade:(t,n)=>{switch(n){case 0:try{t.createObjectStore(Sc)}catch(e){console.warn(e)}}}}).catch(t=>{throw Xr.create("idb-open",{originalErrorMessage:t.message})})),ow}async function mee(t){try{let e=(await SN()).transaction(Sc),r=await e.objectStore(Sc).get(CN(t));return await e.done,r}catch(n){if(n instanceof Ui)tr.warn(n.message);else{let e=Xr.create("idb-get",{originalErrorMessage:n?.message});tr.warn(e.message)}}}async function gN(t,n){try{let r=(await SN()).transaction(Sc,"readwrite");await r.objectStore(Sc).put(n,CN(t)),await r.done}catch(e){if(e instanceof Ui)tr.warn(e.message);else{let r=Xr.create("idb-set",{originalErrorMessage:e?.message});tr.warn(r.message)}}}function CN(t){return`${t.name}!${t.options.appId}`}var gee=1024,yee=30,dw=class{constructor(n){this.container=n,this._heartbeatsCache=null;let e=this.container.getProvider("app").getImmediate();this._storage=new fw(e),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}async triggerHeartbeat(){try{let e=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),r=yN();if(this._heartbeatsCache?.heartbeats==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null)||this._heartbeatsCache.lastSentHeartbeatDate===r||this._heartbeatsCache.heartbeats.some(i=>i.date===r))return;if(this._heartbeatsCache.heartbeats.push({date:r,agent:e}),this._heartbeatsCache.heartbeats.length>yee){let i=_ee(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(i,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(n){tr.warn(n)}}async getHeartbeatsHeader(){try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null||this._heartbeatsCache.heartbeats.length===0)return"";let n=yN(),{heartbeatsToSend:e,unsentEntries:r}=vee(this._heartbeatsCache.heartbeats),i=gc(JSON.stringify({version:2,heartbeats:e}));return this._heartbeatsCache.lastSentHeartbeatDate=n,r.length>0?(this._heartbeatsCache.heartbeats=r,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),i}catch(n){return tr.warn(n),""}}};function yN(){return new Date().toISOString().substring(0,10)}function vee(t,n=gee){let e=[],r=t.slice();for(let i of t){let o=e.find(s=>s.agent===i.agent);if(o){if(o.dates.push(i.date),vN(e)>n){o.dates.pop();break}}else if(e.push({agent:i.agent,dates:[i.date]}),vN(e)>n){e.pop();break}r=r.slice(1)}return{heartbeatsToSend:e,unsentEntries:r}}var fw=class{constructor(n){this.app=n,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return eN()?tN().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){let e=await mee(this.app);return e?.heartbeats?e:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(n){if(await this._canUseIndexedDBPromise){let r=await this.read();return gN(this.app,{lastSentHeartbeatDate:n.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:n.heartbeats})}else return}async add(n){if(await this._canUseIndexedDBPromise){let r=await this.read();return gN(this.app,{lastSentHeartbeatDate:n.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:[...r.heartbeats,...n.heartbeats]})}else return}};function vN(t){return gc(JSON.stringify({version:2,heartbeats:t})).length}function _ee(t){if(t.length===0)return-1;let n=0,e=t[0].date;for(let r=1;r<t.length;r++)t[r].date<e&&(e=t[r].date,n=r);return n}function bee(t){Ec(new er("platform-logger",n=>new sw(n),"PRIVATE")),Ec(new er("heartbeat",n=>new dw(n),"PRIVATE")),ei(aw,pN,t),ei(aw,pN,"esm2020"),ei("fire-js","")}bee("");var Ap="5",aP="v",cP="s",uP="r",lP="f",dP=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,fP="ls",hP="p",Ew="ac",pP="websocket",mP="long_polling";var Sw=class{constructor(n){this.domStorage_=n,this.prefix_="firebase:"}set(n,e){e==null?this.domStorage_.removeItem(this.prefixedName_(n)):this.domStorage_.setItem(this.prefixedName_(n),nt(e))}get(n){let e=this.domStorage_.getItem(this.prefixedName_(n));return e==null?null:Fs(e)}remove(n){this.domStorage_.removeItem(this.prefixedName_(n))}prefixedName_(n){return this.prefix_+n}toString(){return this.domStorage_.toString()}};var Cw=class{constructor(){this.cache_={},this.isInMemoryStorage=!0}set(n,e){e==null?delete this.cache_[n]:this.cache_[n]=e}get(n){return ln(this.cache_,n)?this.cache_[n]:null}remove(n){delete this.cache_[n]}};var gP=function(t){try{if(typeof window<"u"&&typeof window[t]<"u"){let n=window[t];return n.setItem("firebase:sentinel","cache"),n.removeItem("firebase:sentinel"),new Sw(n)}}catch{}return new Cw},Yi=gP("localStorage"),Iw=gP("sessionStorage");var Us=new qs("@firebase/database"),Eee=(function(){let t=1;return function(){return t++}})(),yP=function(t){let n=sN(t),e=new Cp;e.update(n);let r=e.digest();return Ip.encodeByteArray(r)},Bc=function(...t){let n="";for(let e=0;e<t.length;e++){let r=t[e];Array.isArray(r)||r&&typeof r=="object"&&typeof r.length=="number"?n+=Bc.apply(null,r):typeof r=="object"?n+=nt(r):n+=r,n+=" "}return n},Ji=null,IN=!0,See=function(t,n){A(!n||t===!0||t===!1,"Can't turn on custom loggers persistently."),t===!0?(Us.logLevel=Ve.VERBOSE,Ji=Us.log.bind(Us),n&&Iw.set("logging_enabled",!0)):typeof t=="function"?Ji=t:(Ji=null,Iw.remove("logging_enabled"))},pt=function(...t){if(IN===!0&&(IN=!1,Ji===null&&Iw.get("logging_enabled")===!0&&See(!0)),Ji){let n=Bc.apply(null,t);Ji(n)}},Hc=function(t){return function(...n){pt(t,...n)}},Tw=function(...t){let n="FIREBASE INTERNAL ERROR: "+Bc(...t);Us.error(n)},nr=function(...t){let n=`FIREBASE FATAL ERROR: ${Bc(...t)}`;throw Us.error(n),new Error(n)},Rt=function(...t){let n="FIREBASE WARNING: "+Bc(...t);Us.warn(n)},Cee=function(){typeof window<"u"&&window.location&&window.location.protocol&&window.location.protocol.indexOf("https:")!==-1&&Rt("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().")},Xp=function(t){return typeof t=="number"&&(t!==t||t===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY)},Iee=function(t){if(Mn()||document.readyState==="complete")t();else{let n=!1,e=function(){if(!document.body){setTimeout(e,Math.floor(10));return}n||(n=!0,t())};document.addEventListener?(document.addEventListener("DOMContentLoaded",e,!1),window.addEventListener("load",e,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",()=>{document.readyState==="complete"&&e()}),window.attachEvent("onload",e))}},Gs="[MIN_NAME]",Xi="[MAX_NAME]",to=function(t,n){if(t===n)return 0;if(t===Gs||n===Xi)return-1;if(n===Gs||t===Xi)return 1;{let e=TN(t),r=TN(n);return e!==null?r!==null?e-r===0?t.length-n.length:e-r:-1:r!==null?1:t<n?-1:1}},Tee=function(t,n){return t===n?0:t<n?-1:1},Cc=function(t,n){if(n&&t in n)return n[t];throw new Error("Missing required key ("+t+") in object: "+nt(n))},wE=function(t){if(typeof t!="object"||t===null)return nt(t);let n=[];for(let r in t)n.push(r);n.sort();let e="{";for(let r=0;r<n.length;r++)r!==0&&(e+=","),e+=nt(n[r]),e+=":",e+=wE(t[n[r]]);return e+="}",e},vP=function(t,n){let e=t.length;if(e<=n)return[t];let r=[];for(let i=0;i<e;i+=n)i+n>e?r.push(t.substring(i,e)):r.push(t.substring(i,i+n));return r};function bt(t,n){for(let e in t)t.hasOwnProperty(e)&&n(e,t[e])}var _P=function(t){A(!Xp(t),"Invalid JSON number");let n=11,e=52,r=(1<<n-1)-1,i,o,s,a,c;t===0?(o=0,s=0,i=1/t===-1/0?1:0):(i=t<0,t=Math.abs(t),t>=Math.pow(2,1-r)?(a=Math.min(Math.floor(Math.log(t)/Math.LN2),r),o=a+r,s=Math.round(t*Math.pow(2,e-a)-Math.pow(2,e))):(o=0,s=Math.round(t/Math.pow(2,1-r-e))));let u=[];for(c=e;c;c-=1)u.push(s%2?1:0),s=Math.floor(s/2);for(c=n;c;c-=1)u.push(o%2?1:0),o=Math.floor(o/2);u.push(i?1:0),u.reverse();let l=u.join(""),d="";for(c=0;c<64;c+=8){let f=parseInt(l.substr(c,8),2).toString(16);f.length===1&&(f="0"+f),d=d+f}return d.toLowerCase()},xee=function(){return!!(typeof window=="object"&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href))},Dee=function(){return typeof Windows=="object"&&typeof Windows.UI=="object"};function Oee(t,n){let e="Unknown Error";t==="too_big"?e="The data requested exceeds the maximum size that can be accessed with a single request.":t==="permission_denied"?e="Client doesn't have permission to access the desired data.":t==="unavailable"&&(e="The service is unavailable");let r=new Error(t+" at "+n._path.toString()+": "+e);return r.code=t.toUpperCase(),r}var Mee=new RegExp("^-?(0*)\\d{1,10}$"),Aee=-2147483648,Nee=2147483647,TN=function(t){if(Mee.test(t)){let n=Number(t);if(n>=Aee&&n<=Nee)return n}return null},ta=function(t){try{t()}catch(n){setTimeout(()=>{let e=n.stack||"";throw Rt("Exception was thrown by user callback.",e),n},Math.floor(0))}},Pee=function(){return(typeof window=="object"&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)>=0},Oc=function(t,n){let e=setTimeout(t,n);return typeof e=="number"&&typeof Deno<"u"&&Deno.unrefTimer?Deno.unrefTimer(e):typeof e=="object"&&e.unref&&e.unref(),e};var Np=class{constructor(n,e,r,i,o=!1,s="",a=!1,c=!1,u=null){this.secure=e,this.namespace=r,this.webSocketOnly=i,this.nodeAdmin=o,this.persistenceKey=s,this.includeNamespaceInQueryParams=a,this.isUsingEmulator=c,this.emulatorOptions=u,this._host=n.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=Yi.get("host:"+n)||this._host}isCacheableHost(){return this.internalHost.substr(0,2)==="s-"}isCustomHost(){return this._domain!=="firebaseio.com"&&this._domain!=="firebaseio-demo.com"}get host(){return this._host}set host(n){n!==this.internalHost&&(this.internalHost=n,this.isCacheableHost()&&Yi.set("host:"+this._host,this.internalHost))}toString(){let n=this.toURLString();return this.persistenceKey&&(n+="<"+this.persistenceKey+">"),n}toURLString(){let n=this.secure?"https://":"http://",e=this.includeNamespaceInQueryParams?`?ns=${this.namespace}`:"";return`${n}${this.host}/${e}`}};function Ree(t){return t.host!==t.internalHost||t.isCustomHost()||t.includeNamespaceInQueryParams}function bP(t,n,e){A(typeof n=="string","typeof type must == string"),A(typeof e=="object","typeof params must == object");let r;if(n===pP)r=(t.secure?"wss://":"ws://")+t.internalHost+"/.ws?";else if(n===mP)r=(t.secure?"https://":"http://")+t.internalHost+"/.lp?";else throw new Error("Unknown connection type: "+n);Ree(t)&&(e.ns=t.namespace);let i=[];return bt(e,(o,s)=>{i.push(o+"="+s)}),r+i.join("&")}var xw=class{constructor(){this.counters_={}}incrementCounter(n,e=1){ln(this.counters_,n)||(this.counters_[n]=0),this.counters_[n]+=e}get(){return GA(this.counters_)}};var mw={},gw={};function EE(t){let n=t.toString();return mw[n]||(mw[n]=new xw),mw[n]}function kee(t,n){let e=t.toString();return gw[e]||(gw[e]=n()),gw[e]}var SE="";function Lee(t){SE=t}var jee=16384,Fee=45e3,Rc=null;typeof MozWebSocket<"u"?Rc=MozWebSocket:typeof WebSocket<"u"&&(Rc=WebSocket);function $ee(t){Rc=t}var Ic=(()=>{class t{constructor(e,r,i,o,s,a,c){this.connId=e,this.applicationId=i,this.appCheckToken=o,this.authToken=s,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=Hc(this.connId),this.stats_=EE(r),this.connURL=t.connectionURL_(r,a,c,o,i),this.nodeAdmin=r.nodeAdmin}static connectionURL_(e,r,i,o,s){let a={};return a[aP]=Ap,!Mn()&&typeof location<"u"&&location.hostname&&dP.test(location.hostname)&&(a[uP]=lP),r&&(a[cP]=r),i&&(a[fP]=i),o&&(a[Ew]=o),s&&(a[hP]=s),bP(e,pP,a)}open(e,r){this.onDisconnect=r,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,Yi.set("previous_websocket_failure",!0);try{let i;if(Mn()){let o=this.nodeAdmin?"AdminNode":"Node";i={headers:{"User-Agent":`Firebase/${Ap}/${SE}/${process.platform}/${o}`,"X-Firebase-GMPID":this.applicationId||""}},this.authToken&&(i.headers.Authorization=`Bearer ${this.authToken}`),this.appCheckToken&&(i.headers["X-Firebase-AppCheck"]=this.appCheckToken);let s=process.env,a=this.connURL.indexOf("wss://")===0?s.HTTPS_PROXY||s.https_proxy:s.HTTP_PROXY||s.http_proxy;a&&(i.proxy={origin:a})}this.mySock=new Rc(this.connURL,[],i)}catch(i){this.log_("Error instantiating WebSocket.");let o=i.message||i.data;o&&this.log_(o),this.onClosed_();return}this.mySock.onopen=()=>{this.log_("Websocket connected."),this.everConnected_=!0},this.mySock.onclose=()=>{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()},this.mySock.onmessage=i=>{this.handleIncomingFrame(i)},this.mySock.onerror=i=>{this.log_("WebSocket error. Closing connection.");let o=i.message||i.data;o&&this.log_(o),this.onClosed_()}}start(){}static forceDisallow(){t.forceDisallow_=!0}static isAvailable(){let e=!1;if(typeof navigator<"u"&&navigator.userAgent){let r=/Android ([0-9]{0,}\.[0-9]{0,})/,i=navigator.userAgent.match(r);i&&i.length>1&&parseFloat(i[1])<4.4&&(e=!0)}return!e&&Rc!==null&&!t.forceDisallow_}static previouslyFailed(){return Yi.isInMemoryStorage||Yi.get("previous_websocket_failure")===!0}markConnectionHealthy(){Yi.remove("previous_websocket_failure")}appendFrame_(e){if(this.frames.push(e),this.frames.length===this.totalFrames){let r=this.frames.join("");this.frames=null;let i=Fs(r);this.onMessage(i)}}handleNewFrameCount_(e){this.totalFrames=e,this.frames=[]}extractFrameCount_(e){if(A(this.frames===null,"We already have a frame buffer"),e.length<=6){let r=Number(e);if(!isNaN(r))return this.handleNewFrameCount_(r),null}return this.handleNewFrameCount_(1),e}handleIncomingFrame(e){if(this.mySock===null)return;let r=e.data;if(this.bytesReceived+=r.length,this.stats_.incrementCounter("bytes_received",r.length),this.resetKeepAlive(),this.frames!==null)this.appendFrame_(r);else{let i=this.extractFrameCount_(r);i!==null&&this.appendFrame_(i)}}send(e){this.resetKeepAlive();let r=nt(e);this.bytesSent+=r.length,this.stats_.incrementCounter("bytes_sent",r.length);let i=vP(r,jee);i.length>1&&this.sendString_(String(i.length));for(let o=0;o<i.length;o++)this.sendString_(i[o])}shutdown_(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)}onClosed_(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))}close(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())}resetKeepAlive(){clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(()=>{this.mySock&&this.sendString_("0"),this.resetKeepAlive()},Math.floor(Fee))}sendString_(e){try{this.mySock.send(e)}catch(r){this.log_("Exception thrown from WebSocket.send():",r.message||r.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}}}return t.responsesRequiredToBeHealthy=2,t.healthyTimeout=3e4,t})(),xN="@firebase/database",DN="1.1.0";var Dw=class{constructor(n,e){this.appCheckProvider=e,this.appName=n.name,bN(n)&&n.settings.appCheckToken&&(this.serverAppAppCheckToken=n.settings.appCheckToken),this.appCheck=e?.getImmediate({optional:!0}),this.appCheck||e?.get().then(r=>this.appCheck=r)}getToken(n){if(this.serverAppAppCheckToken){if(n)throw new Error("Attempted reuse of `FirebaseServerApp.appCheckToken` after previous usage failed.");return Promise.resolve({token:this.serverAppAppCheckToken})}return this.appCheck?this.appCheck.getToken(n):new Promise((e,r)=>{setTimeout(()=>{this.appCheck?this.getToken(n).then(e,r):e(null)},0)})}addTokenChangeListener(n){this.appCheckProvider?.get().then(e=>e.addTokenListener(n))}notifyForInvalidToken(){Rt(`Provided AppCheck credentials for the app named "${this.appName}" are invalid. This usually indicates your app was not initialized correctly.`)}};var Ow=class{constructor(n,e,r){this.appName_=n,this.firebaseOptions_=e,this.authProvider_=r,this.auth_=null,this.auth_=r.getImmediate({optional:!0}),this.auth_||r.onInit(i=>this.auth_=i)}getToken(n){return this.auth_?this.auth_.getToken(n).catch(e=>e&&e.code==="auth/token-not-initialized"?(pt("Got auth/token-not-initialized error. Treating as null token."),null):Promise.reject(e)):new Promise((e,r)=>{setTimeout(()=>{this.auth_?this.getToken(n).then(e,r):e(null)},0)})}addTokenChangeListener(n){this.auth_?this.auth_.addAuthTokenListener(n):this.authProvider_.get().then(e=>e.addAuthTokenListener(n))}removeTokenChangeListener(n){this.authProvider_.get().then(e=>e.removeAuthTokenListener(n))}notifyForInvalidToken(){let n='Provided authentication credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.firebaseOptions_?n+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.firebaseOptions_?n+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':n+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',Rt(n)}},Mc=(()=>{class t{constructor(e){this.accessToken=e}getToken(e){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(e){e(this.accessToken)}removeTokenChangeListener(e){}notifyForInvalidToken(){}}t.OWNER="owner";return t})(),Mw=class{constructor(n){this.onMessage_=n,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}closeAfter(n,e){this.closeAfterResponse=n,this.onClose=e,this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)}handleResponse(n,e){for(this.pendingResponses[n]=e;this.pendingResponses[this.currentResponseNum];){let r=this.pendingResponses[this.currentResponseNum];delete this.pendingResponses[this.currentResponseNum];for(let i=0;i<r.length;++i)r[i]&&ta(()=>{this.onMessage_(r[i])});if(this.currentResponseNum===this.closeAfterResponse){this.onClose&&(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}};var ON="start",qee="close",Bee="pLPCommand",Hee="pRTLPCB",wP="id",EP="pw",SP="ser",Uee="cb",Vee="seg",Wee="ts",Gee="d",zee="dframe",CP=1870,IP=30,Kee=CP-IP,Yee=25e3,Zee=3e4,Aw=class t{constructor(n,e,r,i,o,s,a){this.connId=n,this.repoInfo=e,this.applicationId=r,this.appCheckToken=i,this.authToken=o,this.transportSessionId=s,this.lastSessionId=a,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=Hc(n),this.stats_=EE(e),this.urlFn=c=>(this.appCheckToken&&(c[Ew]=this.appCheckToken),bP(e,mP,c))}open(n,e){this.curSegmentNum=0,this.onDisconnect_=e,this.myPacketOrderer=new Mw(n),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(()=>{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null},Math.floor(Zee)),Iee(()=>{if(this.isClosed_)return;this.scriptTagHolder=new Nw((...o)=>{let[s,a,c,u,l]=o;if(this.incrementIncomingBytes_(o),!!this.scriptTagHolder)if(this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null),this.everConnected_=!0,s===ON)this.id=a,this.password=c;else if(s===qee)a?(this.scriptTagHolder.sendNewPolls=!1,this.myPacketOrderer.closeAfter(a,()=>{this.onClosed_()})):this.onClosed_();else throw new Error("Unrecognized command received: "+s)},(...o)=>{let[s,a]=o;this.incrementIncomingBytes_(o),this.myPacketOrderer.handleResponse(s,a)},()=>{this.onClosed_()},this.urlFn);let r={};r[ON]="t",r[SP]=Math.floor(Math.random()*1e8),this.scriptTagHolder.uniqueCallbackIdentifier&&(r[Uee]=this.scriptTagHolder.uniqueCallbackIdentifier),r[aP]=Ap,this.transportSessionId&&(r[cP]=this.transportSessionId),this.lastSessionId&&(r[fP]=this.lastSessionId),this.applicationId&&(r[hP]=this.applicationId),this.appCheckToken&&(r[Ew]=this.appCheckToken),typeof location<"u"&&location.hostname&&dP.test(location.hostname)&&(r[uP]=lP);let i=this.urlFn(r);this.log_("Connecting via long-poll to "+i),this.scriptTagHolder.addTag(i,()=>{})})}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){t.forceAllow_=!0}static forceDisallow(){t.forceDisallow_=!0}static isAvailable(){return Mn()?!1:t.forceAllow_?!0:!t.forceDisallow_&&typeof document<"u"&&document.createElement!=null&&!xee()&&!Dee()}markConnectionHealthy(){}shutdown_(){this.isClosed_=!0,this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)}onClosed_(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))}close(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())}send(n){let e=nt(n);this.bytesSent+=e.length,this.stats_.incrementCounter("bytes_sent",e.length);let r=Qb(e),i=vP(r,Kee);for(let o=0;o<i.length;o++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,i.length,i[o]),this.curSegmentNum++}addDisconnectPingFrame(n,e){if(Mn())return;this.myDisconnFrame=document.createElement("iframe");let r={};r[zee]="t",r[wP]=n,r[EP]=e,this.myDisconnFrame.src=this.urlFn(r),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}incrementIncomingBytes_(n){let e=nt(n).length;this.bytesReceived+=e,this.stats_.incrementCounter("bytes_received",e)}},Nw=class t{constructor(n,e,r,i){if(this.onDisconnect=r,this.urlFn=i,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(Math.random()*1e8),this.sendNewPolls=!0,Mn())this.commandCB=n,this.onMessageCB=e;else{this.uniqueCallbackIdentifier=Eee(),window[Bee+this.uniqueCallbackIdentifier]=n,window[Hee+this.uniqueCallbackIdentifier]=e,this.myIFrame=t.createIFrame_();let o="";this.myIFrame.src&&this.myIFrame.src.substr(0,11)==="javascript:"&&(o='<script>document.domain="'+document.domain+'";</script>');let s="<html><body>"+o+"</body></html>";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(s),this.myIFrame.doc.close()}catch(a){pt("frame writing exception"),a.stack&&pt(a.stack),pt(a)}}}static createIFrame_(){let n=document.createElement("iframe");if(n.style.display="none",document.body){document.body.appendChild(n);try{n.contentWindow.document||pt("No IE domain setting required")}catch{let r=document.domain;n.src="javascript:void((function(){document.open();document.domain='"+r+"';document.close();})())"}}else throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";return n.contentDocument?n.doc=n.contentDocument:n.contentWindow?n.doc=n.contentWindow.document:n.document&&(n.doc=n.document),n}close(){this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.textContent="",setTimeout(()=>{this.myIFrame!==null&&(document.body.removeChild(this.myIFrame),this.myIFrame=null)},Math.floor(0)));let n=this.onDisconnect;n&&(this.onDisconnect=null,n())}startLongPoll(n,e){for(this.myID=n,this.myPW=e,this.alive=!0;this.newRequest_(););}newRequest_(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(this.pendingSegs.length>0?2:1)){this.currentSerial++;let n={};n[wP]=this.myID,n[EP]=this.myPW,n[SP]=this.currentSerial;let e=this.urlFn(n),r="",i=0;for(;this.pendingSegs.length>0&&this.pendingSegs[0].d.length+IP+r.length<=CP;){let s=this.pendingSegs.shift();r=r+"&"+Vee+i+"="+s.seg+"&"+Wee+i+"="+s.ts+"&"+Gee+i+"="+s.d,i++}return e=e+r,this.addLongPollTag_(e,this.currentSerial),!0}else return!1}enqueueSegment(n,e,r){this.pendingSegs.push({seg:n,ts:e,d:r}),this.alive&&this.newRequest_()}addLongPollTag_(n,e){this.outstandingRequests.add(e);let r=()=>{this.outstandingRequests.delete(e),this.newRequest_()},i=setTimeout(r,Math.floor(Yee)),o=()=>{clearTimeout(i),r()};this.addTag(n,o)}addTag(n,e){Mn()?this.doNodeLongPoll(n,e):setTimeout(()=>{try{if(!this.sendNewPolls)return;let r=this.myIFrame.doc.createElement("script");r.type="text/javascript",r.async=!0,r.src=n,r.onload=r.onreadystatechange=function(){let i=r.readyState;(!i||i==="loaded"||i==="complete")&&(r.onload=r.onreadystatechange=null,r.parentNode&&r.parentNode.removeChild(r),e())},r.onerror=()=>{pt("Long-poll script failed to load: "+n),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(r)}catch{}},Math.floor(1))}};var Qee=(()=>{class t{static get ALL_TRANSPORTS(){return[Aw,Ic]}static get IS_TRANSPORT_INITIALIZED(){return this.globalTransportInitialized_}constructor(e){this.initTransports_(e)}initTransports_(e){let r=Ic&&Ic.isAvailable(),i=r&&!Ic.previouslyFailed();if(e.webSocketOnly&&(r||Rt("wss:// URL used, but browser isn't known to support websockets. Trying anyway."),i=!0),i)this.transports_=[Ic];else{let o=this.transports_=[];for(let s of t.ALL_TRANSPORTS)s&&s.isAvailable()&&o.push(s);t.globalTransportInitialized_=!0}}initialTransport(){if(this.transports_.length>0)return this.transports_[0];throw new Error("No transports available")}upgradeTransport(){return this.transports_.length>1?this.transports_[1]:null}}t.globalTransportInitialized_=!1;return t})(),Jee=6e4,Xee=5e3,ete=10*1024,tte=100*1024,yw="t",MN="d",nte="s",AN="r",rte="e",NN="o",PN="a",RN="n",kN="p",ite="h",Pw=class{constructor(n,e,r,i,o,s,a,c,u,l){this.id=n,this.repoInfo_=e,this.applicationId_=r,this.appCheckToken_=i,this.authToken_=o,this.onMessage_=s,this.onReady_=a,this.onDisconnect_=c,this.onKill_=u,this.lastSessionId=l,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=Hc("c:"+this.id+":"),this.transportManager_=new Qee(e),this.log_("Connection created"),this.start_()}start_(){let n=this.transportManager_.initialTransport();this.conn_=new n(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,null,this.lastSessionId),this.primaryResponsesRequired_=n.responsesRequiredToBeHealthy||0;let e=this.connReceiver_(this.conn_),r=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout(()=>{this.conn_&&this.conn_.open(e,r)},Math.floor(0));let i=n.healthyTimeout||0;i>0&&(this.healthyTimeout_=Oc(()=>{this.healthyTimeout_=null,this.isHealthy_||(this.conn_&&this.conn_.bytesReceived>tte?(this.log_("Connection exceeded healthy timeout but has received "+this.conn_.bytesReceived+" bytes. Marking connection healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()):this.conn_&&this.conn_.bytesSent>ete?this.log_("Connection exceeded healthy timeout but has sent "+this.conn_.bytesSent+" bytes. Leaving connection alive."):(this.log_("Closing unhealthy connection after timeout."),this.close()))},Math.floor(i)))}nextTransportId_(){return"c:"+this.id+":"+this.connectionCount++}disconnReceiver_(n){return e=>{n===this.conn_?this.onConnectionLost_(e):n===this.secondaryConn_?(this.log_("Secondary connection lost."),this.onSecondaryConnectionLost_()):this.log_("closing an old connection")}}connReceiver_(n){return e=>{this.state_!==2&&(n===this.rx_?this.onPrimaryMessageReceived_(e):n===this.secondaryConn_?this.onSecondaryMessageReceived_(e):this.log_("message on old connection"))}}sendRequest(n){let e={t:"d",d:n};this.sendData_(e)}tryCleanupConnection(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)}onSecondaryControl_(n){if(yw in n){let e=n[yw];e===PN?this.upgradeIfSecondaryHealthy_():e===AN?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),(this.tx_===this.secondaryConn_||this.rx_===this.secondaryConn_)&&this.close()):e===NN&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}}onSecondaryMessageReceived_(n){let e=Cc("t",n),r=Cc("d",n);if(e==="c")this.onSecondaryControl_(r);else if(e==="d")this.pendingDataMessages.push(r);else throw new Error("Unknown protocol layer: "+e)}upgradeIfSecondaryHealthy_(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t:"c",d:{t:kN,d:{}}}))}proceedWithUpgrade_(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:PN,d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:RN,d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()}onPrimaryMessageReceived_(n){let e=Cc("t",n),r=Cc("d",n);e==="c"?this.onControl_(r):e==="d"&&this.onDataMessage_(r)}onDataMessage_(n){this.onPrimaryResponse_(),this.onMessage_(n)}onPrimaryResponse_(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))}onControl_(n){let e=Cc(yw,n);if(MN in n){let r=n[MN];if(e===ite){let i={...r};this.repoInfo_.isUsingEmulator&&(i.h=this.repoInfo_.host),this.onHandshake_(i)}else if(e===RN){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(let i=0;i<this.pendingDataMessages.length;++i)this.onDataMessage_(this.pendingDataMessages[i]);this.pendingDataMessages=[],this.tryCleanupConnection()}else e===nte?this.onConnectionShutdown_(r):e===AN?this.onReset_(r):e===rte?Tw("Server Error: "+r):e===NN?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):Tw("Unknown control packet command: "+e)}}onHandshake_(n){let e=n.ts,r=n.v,i=n.h;this.sessionId=n.s,this.repoInfo_.host=i,this.state_===0&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,e),Ap!==r&&Rt("Protocol version mismatch detected"),this.tryStartUpgrade_())}tryStartUpgrade_(){let n=this.transportManager_.upgradeTransport();n&&this.startUpgrade_(n)}startUpgrade_(n){this.secondaryConn_=new n(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,this.sessionId),this.secondaryResponsesRequired_=n.responsesRequiredToBeHealthy||0;let e=this.connReceiver_(this.secondaryConn_),r=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(e,r),Oc(()=>{this.secondaryConn_&&(this.log_("Timed out trying to upgrade."),this.secondaryConn_.close())},Math.floor(Jee))}onReset_(n){this.log_("Reset packet received. New host: "+n),this.repoInfo_.host=n,this.state_===1?this.close():(this.closeConnections_(),this.start_())}onConnectionEstablished_(n,e){this.log_("Realtime connection established."),this.conn_=n,this.state_=1,this.onReady_&&(this.onReady_(e,this.sessionId),this.onReady_=null),this.primaryResponsesRequired_===0?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):Oc(()=>{this.sendPingOnPrimaryIfNecessary_()},Math.floor(Xee))}sendPingOnPrimaryIfNecessary_(){!this.isHealthy_&&this.state_===1&&(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:kN,d:{}}}))}onSecondaryConnectionLost_(){let n=this.secondaryConn_;this.secondaryConn_=null,(this.tx_===n||this.rx_===n)&&this.close()}onConnectionLost_(n){this.conn_=null,!n&&this.state_===0?(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(Yi.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)):this.state_===1&&this.log_("Realtime connection lost."),this.close()}onConnectionShutdown_(n){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&&(this.onKill_(n),this.onKill_=null),this.onDisconnect_=null,this.close()}sendData_(n){if(this.state_!==1)throw"Connection is not connected";this.tx_.send(n)}close(){this.state_!==2&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))}closeConnections_(){this.log_("Shutting down all connections"),this.conn_&&(this.conn_.close(),this.conn_=null),this.secondaryConn_&&(this.secondaryConn_.close(),this.secondaryConn_=null),this.healthyTimeout_&&(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)}};var Pp=class{put(n,e,r,i){}merge(n,e,r,i){}refreshAuthToken(n){}refreshAppCheckToken(n){}onDisconnectPut(n,e,r){}onDisconnectMerge(n,e,r){}onDisconnectCancel(n,e){}reportStats(n){}};var Rp=class{constructor(n){this.allowedEvents_=n,this.listeners_={},A(Array.isArray(n)&&n.length>0,"Requires a non-empty array")}trigger(n,...e){if(Array.isArray(this.listeners_[n])){let r=[...this.listeners_[n]];for(let i=0;i<r.length;i++)r[i].callback.apply(r[i].context,e)}}on(n,e,r){this.validateEventType_(n),this.listeners_[n]=this.listeners_[n]||[],this.listeners_[n].push({callback:e,context:r});let i=this.getInitialEvent(n);i&&e.apply(r,i)}off(n,e,r){this.validateEventType_(n);let i=this.listeners_[n]||[];for(let o=0;o<i.length;o++)if(i[o].callback===e&&(!r||r===i[o].context)){i.splice(o,1);return}}validateEventType_(n){A(this.allowedEvents_.find(e=>e===n),"Unknown event: "+n)}};var kp=class t extends Rp{static getInstance(){return new t}constructor(){super(["online"]),this.online_=!0,typeof window<"u"&&typeof window.addEventListener<"u"&&!Xb()&&(window.addEventListener("online",()=>{this.online_||(this.online_=!0,this.trigger("online",!0))},!1),window.addEventListener("offline",()=>{this.online_&&(this.online_=!1,this.trigger("online",!1))},!1))}getInitialEvent(n){return A(n==="online","Unknown event type: "+n),[this.online_]}currentlyOnline(){return this.online_}};var LN=32,jN=768,Pe=class{constructor(n,e){if(e===void 0){this.pieces_=n.split("/");let r=0;for(let i=0;i<this.pieces_.length;i++)this.pieces_[i].length>0&&(this.pieces_[r]=this.pieces_[i],r++);this.pieces_.length=r,this.pieceNum_=0}else this.pieces_=n,this.pieceNum_=e}toString(){let n="";for(let e=this.pieceNum_;e<this.pieces_.length;e++)this.pieces_[e]!==""&&(n+="/"+this.pieces_[e]);return n||"/"}};function Ne(){return new Pe("")}function he(t){return t.pieceNum_>=t.pieces_.length?null:t.pieces_[t.pieceNum_]}function ni(t){return t.pieces_.length-t.pieceNum_}function Fe(t){let n=t.pieceNum_;return n<t.pieces_.length&&n++,new Pe(t.pieces_,n)}function CE(t){return t.pieceNum_<t.pieces_.length?t.pieces_[t.pieces_.length-1]:null}function ote(t){let n="";for(let e=t.pieceNum_;e<t.pieces_.length;e++)t.pieces_[e]!==""&&(n+="/"+encodeURIComponent(String(t.pieces_[e])));return n||"/"}function kc(t,n=0){return t.pieces_.slice(t.pieceNum_+n)}function TP(t){if(t.pieceNum_>=t.pieces_.length)return null;let n=[];for(let e=t.pieceNum_;e<t.pieces_.length-1;e++)n.push(t.pieces_[e]);return new Pe(n,0)}function Ze(t,n){let e=[];for(let r=t.pieceNum_;r<t.pieces_.length;r++)e.push(t.pieces_[r]);if(n instanceof Pe)for(let r=n.pieceNum_;r<n.pieces_.length;r++)e.push(n.pieces_[r]);else{let r=n.split("/");for(let i=0;i<r.length;i++)r[i].length>0&&e.push(r[i])}return new Pe(e,0)}function ye(t){return t.pieceNum_>=t.pieces_.length}function Pt(t,n){let e=he(t),r=he(n);if(e===null)return n;if(e===r)return Pt(Fe(t),Fe(n));throw new Error("INTERNAL ERROR: innerPath ("+n+") is not within outerPath ("+t+")")}function ste(t,n){let e=kc(t,0),r=kc(n,0);for(let i=0;i<e.length&&i<r.length;i++){let o=to(e[i],r[i]);if(o!==0)return o}return e.length===r.length?0:e.length<r.length?-1:1}function IE(t,n){if(ni(t)!==ni(n))return!1;for(let e=t.pieceNum_,r=n.pieceNum_;e<=t.pieces_.length;e++,r++)if(t.pieces_[e]!==n.pieces_[r])return!1;return!0}function Xt(t,n){let e=t.pieceNum_,r=n.pieceNum_;if(ni(t)>ni(n))return!1;for(;e<t.pieces_.length;){if(t.pieces_[e]!==n.pieces_[r])return!1;++e,++r}return!0}var Rw=class{constructor(n,e){this.errorPrefix_=e,this.parts_=kc(n,0),this.byteLength_=Math.max(1,this.parts_.length);for(let r=0;r<this.parts_.length;r++)this.byteLength_+=_c(this.parts_[r]);xP(this)}};function ate(t,n){t.parts_.length>0&&(t.byteLength_+=1),t.parts_.push(n),t.byteLength_+=_c(n),xP(t)}function cte(t){let n=t.parts_.pop();t.byteLength_-=_c(n),t.parts_.length>0&&(t.byteLength_-=1)}function xP(t){if(t.byteLength_>jN)throw new Error(t.errorPrefix_+"has a key path longer than "+jN+" bytes ("+t.byteLength_+").");if(t.parts_.length>LN)throw new Error(t.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+LN+") or object contains a cycle "+Ki(t))}function Ki(t){return t.parts_.length===0?"":"in property '"+t.parts_.join(".")+"'"}var kw=class t extends Rp{static getInstance(){return new t}constructor(){super(["visible"]);let n,e;typeof document<"u"&&typeof document.addEventListener<"u"&&(typeof document.hidden<"u"?(e="visibilitychange",n="hidden"):typeof document.mozHidden<"u"?(e="mozvisibilitychange",n="mozHidden"):typeof document.msHidden<"u"?(e="msvisibilitychange",n="msHidden"):typeof document.webkitHidden<"u"&&(e="webkitvisibilitychange",n="webkitHidden")),this.visible_=!0,e&&document.addEventListener(e,()=>{let r=!document[n];r!==this.visible_&&(this.visible_=r,this.trigger("visible",r))},!1)}getInitialEvent(n){return A(n==="visible","Unknown event type: "+n),[this.visible_]}};var Tc=1e3,ute=300*1e3,FN=30*1e3,lte=1.3,dte=3e4,fte="server_kill",$N=3,TE=(()=>{class t extends Pp{constructor(e,r,i,o,s,a,c,u){if(super(),this.repoInfo_=e,this.applicationId_=r,this.onDataUpdate_=i,this.onConnectStatus_=o,this.onServerInfoUpdate_=s,this.authTokenProvider_=a,this.appCheckTokenProvider_=c,this.authOverride_=u,this.id=t.nextPersistentConnectionId_++,this.log_=Hc("p:"+this.id+":"),this.interruptReasons_={},this.listens=new Map,this.outstandingPuts_=[],this.outstandingGets_=[],this.outstandingPutCount_=0,this.outstandingGetCount_=0,this.onDisconnectRequestQueue_=[],this.connected_=!1,this.reconnectDelay_=Tc,this.maxReconnectDelay_=ute,this.securityDebugCallback_=null,this.lastSessionId=null,this.establishConnectionTimer_=null,this.visible_=!1,this.requestCBHash_={},this.requestNumber_=0,this.realtime_=null,this.authToken_=null,this.appCheckToken_=null,this.forceTokenRefresh_=!1,this.invalidAuthTokenCount_=0,this.invalidAppCheckTokenCount_=0,this.firstConnection_=!0,this.lastConnectionAttemptTime_=null,this.lastConnectionEstablishedTime_=null,u&&!Mn())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");kw.getInstance().on("visible",this.onVisible_,this),e.host.indexOf("fblocal")===-1&&kp.getInstance().on("online",this.onOnline_,this)}sendRequest(e,r,i){let o=++this.requestNumber_,s={r:o,a:e,b:r};this.log_(nt(s)),A(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(s),i&&(this.requestCBHash_[o]=i)}get(e){this.initConnection_();let r=new Wt,o={action:"g",request:{p:e._path.toString(),q:e._queryObject},onComplete:a=>{let c=a.d;a.s==="ok"?r.resolve(c):r.reject(c)}};this.outstandingGets_.push(o),this.outstandingGetCount_++;let s=this.outstandingGets_.length-1;return this.connected_&&this.sendGet_(s),r.promise}listen(e,r,i,o){this.initConnection_();let s=e._queryIdentifier,a=e._path.toString();this.log_("Listen called for "+a+" "+s),this.listens.has(a)||this.listens.set(a,new Map),A(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),A(!this.listens.get(a).has(s),"listen() called twice for same path/queryId.");let c={onComplete:o,hashFn:r,query:e,tag:i};this.listens.get(a).set(s,c),this.connected_&&this.sendListen_(c)}sendGet_(e){let r=this.outstandingGets_[e];this.sendRequest("g",r.request,i=>{delete this.outstandingGets_[e],this.outstandingGetCount_--,this.outstandingGetCount_===0&&(this.outstandingGets_=[]),r.onComplete&&r.onComplete(i)})}sendListen_(e){let r=e.query,i=r._path.toString(),o=r._queryIdentifier;this.log_("Listen on "+i+" for "+o);let s={p:i},a="q";e.tag&&(s.q=r._queryObject,s.t=e.tag),s.h=e.hashFn(),this.sendRequest(a,s,c=>{let u=c.d,l=c.s;t.warnOnListenWarnings_(u,r),(this.listens.get(i)&&this.listens.get(i).get(o))===e&&(this.log_("listen response",c),l!=="ok"&&this.removeListen_(i,o),e.onComplete&&e.onComplete(l,u))})}static warnOnListenWarnings_(e,r){if(e&&typeof e=="object"&&ln(e,"w")){let i=Wi(e,"w");if(Array.isArray(i)&&~i.indexOf("no_index")){let o='".indexOn": "'+r._queryParams.getIndex().toString()+'"',s=r._path.toString();Rt(`Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ${o} at ${s} to your security rules for better performance.`)}}}refreshAuthToken(e){this.authToken_=e,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},()=>{}),this.reduceReconnectDelayIfAdminCredential_(e)}reduceReconnectDelayIfAdminCredential_(e){(e&&e.length===40||iN(e))&&(this.log_("Admin auth credential detected. Reducing max reconnect time."),this.maxReconnectDelay_=FN)}refreshAppCheckToken(e){this.appCheckToken_=e,this.log_("App check token refreshed"),this.appCheckToken_?this.tryAppCheck():this.connected_&&this.sendRequest("unappeck",{},()=>{})}tryAuth(){if(this.connected_&&this.authToken_){let e=this.authToken_,r=rN(e)?"auth":"gauth",i={cred:e};this.authOverride_===null?i.noauth=!0:typeof this.authOverride_=="object"&&(i.authvar=this.authOverride_),this.sendRequest(r,i,o=>{let s=o.s,a=o.d||"error";this.authToken_===e&&(s==="ok"?this.invalidAuthTokenCount_=0:this.onAuthRevoked_(s,a))})}}tryAppCheck(){this.connected_&&this.appCheckToken_&&this.sendRequest("appcheck",{token:this.appCheckToken_},e=>{let r=e.s,i=e.d||"error";r==="ok"?this.invalidAppCheckTokenCount_=0:this.onAppCheckRevoked_(r,i)})}unlisten(e,r){let i=e._path.toString(),o=e._queryIdentifier;this.log_("Unlisten called for "+i+" "+o),A(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(i,o)&&this.connected_&&this.sendUnlisten_(i,o,e._queryObject,r)}sendUnlisten_(e,r,i,o){this.log_("Unlisten on "+e+" for "+r);let s={p:e},a="n";o&&(s.q=i,s.t=o),this.sendRequest(a,s)}onDisconnectPut(e,r,i){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",e,r,i):this.onDisconnectRequestQueue_.push({pathString:e,action:"o",data:r,onComplete:i})}onDisconnectMerge(e,r,i){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",e,r,i):this.onDisconnectRequestQueue_.push({pathString:e,action:"om",data:r,onComplete:i})}onDisconnectCancel(e,r){this.initConnection_(),this.connected_?this.sendOnDisconnect_("oc",e,null,r):this.onDisconnectRequestQueue_.push({pathString:e,action:"oc",data:null,onComplete:r})}sendOnDisconnect_(e,r,i,o){let s={p:r,d:i};this.log_("onDisconnect "+e,s),this.sendRequest(e,s,a=>{o&&setTimeout(()=>{o(a.s,a.d)},Math.floor(0))})}put(e,r,i,o){this.putInternal("p",e,r,i,o)}merge(e,r,i,o){this.putInternal("m",e,r,i,o)}putInternal(e,r,i,o,s){this.initConnection_();let a={p:r,d:i};s!==void 0&&(a.h=s),this.outstandingPuts_.push({action:e,request:a,onComplete:o}),this.outstandingPutCount_++;let c=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(c):this.log_("Buffering put: "+r)}sendPut_(e){let r=this.outstandingPuts_[e].action,i=this.outstandingPuts_[e].request,o=this.outstandingPuts_[e].onComplete;this.outstandingPuts_[e].queued=this.connected_,this.sendRequest(r,i,s=>{this.log_(r+" response",s),delete this.outstandingPuts_[e],this.outstandingPutCount_--,this.outstandingPutCount_===0&&(this.outstandingPuts_=[]),o&&o(s.s,s.d)})}reportStats(e){if(this.connected_){let r={c:e};this.log_("reportStats",r),this.sendRequest("s",r,i=>{if(i.s!=="ok"){let s=i.d;this.log_("reportStats","Error sending stats: "+s)}})}}onDataMessage_(e){if("r"in e){this.log_("from server: "+nt(e));let r=e.r,i=this.requestCBHash_[r];i&&(delete this.requestCBHash_[r],i(e.b))}else{if("error"in e)throw"A server-side error has occurred: "+e.error;"a"in e&&this.onDataPush_(e.a,e.b)}}onDataPush_(e,r){this.log_("handleServerMessage",e,r),e==="d"?this.onDataUpdate_(r.p,r.d,!1,r.t):e==="m"?this.onDataUpdate_(r.p,r.d,!0,r.t):e==="c"?this.onListenRevoked_(r.p,r.q):e==="ac"?this.onAuthRevoked_(r.s,r.d):e==="apc"?this.onAppCheckRevoked_(r.s,r.d):e==="sd"?this.onSecurityDebugPacket_(r):Tw("Unrecognized action received from server: "+nt(e)+`
35
- Are you using the latest client?`)}onReady_(e,r){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=new Date().getTime(),this.handleTimestamp_(e),this.lastSessionId=r,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)}scheduleConnect_(e){A(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout(()=>{this.establishConnectionTimer_=null,this.establishConnection_()},Math.floor(e))}initConnection_(){!this.realtime_&&this.firstConnection_&&this.scheduleConnect_(0)}onVisible_(e){e&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible. Reducing delay."),this.reconnectDelay_=Tc,this.realtime_||this.scheduleConnect_(0)),this.visible_=e}onOnline_(e){e?(this.log_("Browser went online."),this.reconnectDelay_=Tc,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline. Killing connection."),this.realtime_&&this.realtime_.close())}onRealtimeDisconnect_(){if(this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()){this.visible_?this.lastConnectionEstablishedTime_&&(new Date().getTime()-this.lastConnectionEstablishedTime_>dte&&(this.reconnectDelay_=Tc),this.lastConnectionEstablishedTime_=null):(this.log_("Window isn't visible. Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=new Date().getTime());let e=Math.max(0,new Date().getTime()-this.lastConnectionAttemptTime_),r=Math.max(0,this.reconnectDelay_-e);r=Math.random()*r,this.log_("Trying to reconnect in "+r+"ms"),this.scheduleConnect_(r),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,this.reconnectDelay_*lte)}this.onConnectStatus_(!1)}async establishConnection_(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=new Date().getTime(),this.lastConnectionEstablishedTime_=null;let e=this.onDataMessage_.bind(this),r=this.onReady_.bind(this),i=this.onRealtimeDisconnect_.bind(this),o=this.id+":"+t.nextConnectionId_++,s=this.lastSessionId,a=!1,c=null,u=function(){c?c.close():(a=!0,i())},l=function(f){A(c,"sendRequest call when we're not connected not allowed."),c.sendRequest(f)};this.realtime_={close:u,sendRequest:l};let d=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{let[f,p]=await Promise.all([this.authTokenProvider_.getToken(d),this.appCheckTokenProvider_.getToken(d)]);a?pt("getToken() completed but was canceled"):(pt("getToken() completed. Creating connection."),this.authToken_=f&&f.accessToken,this.appCheckToken_=p&&p.token,c=new Pw(o,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,r,i,m=>{Rt(m+" ("+this.repoInfo_.toString()+")"),this.interrupt(fte)},s))}catch(f){this.log_("Failed to get token: "+f),a||(this.repoInfo_.nodeAdmin&&Rt(f),u())}}}interrupt(e){pt("Interrupting connection for reason: "+e),this.interruptReasons_[e]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())}resume(e){pt("Resuming connection for reason: "+e),delete this.interruptReasons_[e],xp(this.interruptReasons_)&&(this.reconnectDelay_=Tc,this.realtime_||this.scheduleConnect_(0))}handleTimestamp_(e){let r=e-new Date().getTime();this.onServerInfoUpdate_({serverTimeOffset:r})}cancelSentTransactions_(){for(let e=0;e<this.outstandingPuts_.length;e++){let r=this.outstandingPuts_[e];r&&"h"in r.request&&r.queued&&(r.onComplete&&r.onComplete("disconnect"),delete this.outstandingPuts_[e],this.outstandingPutCount_--)}this.outstandingPutCount_===0&&(this.outstandingPuts_=[])}onListenRevoked_(e,r){let i;r?i=r.map(s=>wE(s)).join("$"):i="default";let o=this.removeListen_(e,i);o&&o.onComplete&&o.onComplete("permission_denied")}removeListen_(e,r){let i=new Pe(e).toString(),o;if(this.listens.has(i)){let s=this.listens.get(i);o=s.get(r),s.delete(r),s.size===0&&this.listens.delete(i)}else o=void 0;return o}onAuthRevoked_(e,r){pt("Auth token revoked: "+e+"/"+r),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),(e==="invalid_token"||e==="permission_denied")&&(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_>=$N&&(this.reconnectDelay_=FN,this.authTokenProvider_.notifyForInvalidToken()))}onAppCheckRevoked_(e,r){pt("App check token revoked: "+e+"/"+r),this.appCheckToken_=null,this.forceTokenRefresh_=!0,(e==="invalid_token"||e==="permission_denied")&&(this.invalidAppCheckTokenCount_++,this.invalidAppCheckTokenCount_>=$N&&this.appCheckTokenProvider_.notifyForInvalidToken())}onSecurityDebugPacket_(e){this.securityDebugCallback_?this.securityDebugCallback_(e):"msg"in e&&console.log("FIREBASE: "+e.msg.replace(`
34
+ </defs>`,m.innerText="Preview backend running in this workspace."),m.setAttribute("id",p)}document.readyState==="loading"?window.addEventListener("DOMContentLoaded",d):d()}function yX(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function Xb(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(yX())}function XA(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function Mn(){return Ep.NODE_CLIENT===!0||Ep.NODE_ADMIN===!0}function eN(){try{return typeof indexedDB=="object"}catch{return!1}}function tN(){return new Promise((t,n)=>{try{let e=!0,r="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close(),e||self.indexedDB.deleteDatabase(r),t(!0)},i.onupgradeneeded=()=>{e=!1},i.onerror=()=>{n(i.error?.message||"")}}catch(e){n(e)}})}var vX="FirebaseError",Ui=class t extends Error{constructor(n,e,r){super(e),this.code=n,this.customData=r,this.name=vX,Object.setPrototypeOf(this,t.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,yc.prototype.create)}},yc=class{constructor(n,e,r){this.service=n,this.serviceName=e,this.errors=r}create(n,...e){let r=e[0]||{},i=`${this.service}/${n}`,o=this.errors[n],s=o?_X(o,r):"Error",a=`${this.serviceName}: ${s} (${i}).`;return new Ui(i,a,r)}};function _X(t,n){return t.replace(bX,(e,r)=>{let i=n[r];return i!=null?String(i):`<${r}?>`})}var bX=/\{\$([^}]+)}/g;function Fs(t){return JSON.parse(t)}function nt(t){return JSON.stringify(t)}var nN=function(t){let n={},e={},r={},i="";try{let o=t.split(".");n=Fs(Sp(o[0])||""),e=Fs(Sp(o[1])||""),i=o[2],r=e.d||{},delete e.d}catch{}return{header:n,claims:e,data:r,signature:i}};var rN=function(t){let n=nN(t),e=n.claims;return!!e&&typeof e=="object"&&e.hasOwnProperty("iat")},iN=function(t){let n=nN(t).claims;return typeof n=="object"&&n.admin===!0};function ln(t,n){return Object.prototype.hasOwnProperty.call(t,n)}function Wi(t,n){if(Object.prototype.hasOwnProperty.call(t,n))return t[n]}function xp(t){for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n))return!1;return!0}function vc(t,n,e){let r={};for(let i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[i]=n.call(e,t[i],i,t));return r}function $s(t,n){if(t===n)return!0;let e=Object.keys(t),r=Object.keys(n);for(let i of e){if(!r.includes(i))return!1;let o=t[i],s=n[i];if(VA(o)&&VA(s)){if(!$s(o,s))return!1}else if(o!==s)return!1}for(let i of r)if(!e.includes(i))return!1;return!0}function VA(t){return t!==null&&typeof t=="object"}function oN(t){let n=[];for(let[e,r]of Object.entries(t))Array.isArray(r)?r.forEach(i=>{n.push(encodeURIComponent(e)+"="+encodeURIComponent(i))}):n.push(encodeURIComponent(e)+"="+encodeURIComponent(r));return n.length?"&"+n.join("&"):""}var Cp=class{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=512/8,this.pad_[0]=128;for(let n=1;n<this.blockSize;++n)this.pad_[n]=0;this.reset()}reset(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0}compress_(n,e){e||(e=0);let r=this.W_;if(typeof n=="string")for(let d=0;d<16;d++)r[d]=n.charCodeAt(e)<<24|n.charCodeAt(e+1)<<16|n.charCodeAt(e+2)<<8|n.charCodeAt(e+3),e+=4;else for(let d=0;d<16;d++)r[d]=n[e]<<24|n[e+1]<<16|n[e+2]<<8|n[e+3],e+=4;for(let d=16;d<80;d++){let f=r[d-3]^r[d-8]^r[d-14]^r[d-16];r[d]=(f<<1|f>>>31)&4294967295}let i=this.chain_[0],o=this.chain_[1],s=this.chain_[2],a=this.chain_[3],c=this.chain_[4],u,l;for(let d=0;d<80;d++){d<40?d<20?(u=a^o&(s^a),l=1518500249):(u=o^s^a,l=1859775393):d<60?(u=o&s|a&(o|s),l=2400959708):(u=o^s^a,l=3395469782);let f=(i<<5|i>>>27)+u+c+l+r[d]&4294967295;c=a,a=s,s=(o<<30|o>>>2)&4294967295,o=i,i=f}this.chain_[0]=this.chain_[0]+i&4294967295,this.chain_[1]=this.chain_[1]+o&4294967295,this.chain_[2]=this.chain_[2]+s&4294967295,this.chain_[3]=this.chain_[3]+a&4294967295,this.chain_[4]=this.chain_[4]+c&4294967295}update(n,e){if(n==null)return;e===void 0&&(e=n.length);let r=e-this.blockSize,i=0,o=this.buf_,s=this.inbuf_;for(;i<e;){if(s===0)for(;i<=r;)this.compress_(n,i),i+=this.blockSize;if(typeof n=="string"){for(;i<e;)if(o[s]=n.charCodeAt(i),++s,++i,s===this.blockSize){this.compress_(o),s=0;break}}else for(;i<e;)if(o[s]=n[i],++s,++i,s===this.blockSize){this.compress_(o),s=0;break}}this.inbuf_=s,this.total_+=e}digest(){let n=[],e=this.total_*8;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let i=this.blockSize-1;i>=56;i--)this.buf_[i]=e&255,e/=256;this.compress_(this.buf_);let r=0;for(let i=0;i<5;i++)for(let o=24;o>=0;o-=8)n[r]=this.chain_[i]>>o&255,++r;return n}};function Gi(t,n){return`${t} failed: ${n} argument `}var sN=function(t){let n=[],e=0;for(let r=0;r<t.length;r++){let i=t.charCodeAt(r);if(i>=55296&&i<=56319){let o=i-55296;r++,A(r<t.length,"Surrogate pair missing trail surrogate.");let s=t.charCodeAt(r)-56320;i=65536+(o<<10)+s}i<128?n[e++]=i:i<2048?(n[e++]=i>>6|192,n[e++]=i&63|128):i<65536?(n[e++]=i>>12|224,n[e++]=i>>6&63|128,n[e++]=i&63|128):(n[e++]=i>>18|240,n[e++]=i>>12&63|128,n[e++]=i>>6&63|128,n[e++]=i&63|128)}return n},_c=function(t){let n=0;for(let e=0;e<t.length;e++){let r=t.charCodeAt(e);r<128?n++:r<2048?n+=2:r>=55296&&r<=56319?(n+=4,e++):n+=3}return n};var Lke=14400*1e3;function Jr(t){return t&&t._delegate?t._delegate:t}Ep.NODE_CLIENT=!0;var wX=[],Ve=(function(t){return t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT",t})(Ve||{}),EX={debug:Ve.DEBUG,verbose:Ve.VERBOSE,info:Ve.INFO,warn:Ve.WARN,error:Ve.ERROR,silent:Ve.SILENT},SX=Ve.INFO,CX={[Ve.DEBUG]:"log",[Ve.VERBOSE]:"log",[Ve.INFO]:"info",[Ve.WARN]:"warn",[Ve.ERROR]:"error"},IX=(t,n,...e)=>{if(n<t.logLevel)return;let r=new Date().toISOString(),i=CX[n];if(i)console[i](`[${r}] ${t.name}:`,...e);else throw new Error(`Attempted to log a message with an invalid logType (value: ${n})`)},qs=class{constructor(n){this.name=n,this._logLevel=SX,this._logHandler=IX,this._userLogHandler=null,wX.push(this)}get logLevel(){return this._logLevel}set logLevel(n){if(!(n in Ve))throw new TypeError(`Invalid value "${n}" assigned to \`logLevel\``);this._logLevel=n}setLogLevel(n){this._logLevel=typeof n=="string"?EX[n]:n}get logHandler(){return this._logHandler}set logHandler(n){if(typeof n!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=n}get userLogHandler(){return this._userLogHandler}set userLogHandler(n){this._userLogHandler=n}debug(...n){this._userLogHandler&&this._userLogHandler(this,Ve.DEBUG,...n),this._logHandler(this,Ve.DEBUG,...n)}log(...n){this._userLogHandler&&this._userLogHandler(this,Ve.VERBOSE,...n),this._logHandler(this,Ve.VERBOSE,...n)}info(...n){this._userLogHandler&&this._userLogHandler(this,Ve.INFO,...n),this._logHandler(this,Ve.INFO,...n)}warn(...n){this._userLogHandler&&this._userLogHandler(this,Ve.WARN,...n),this._logHandler(this,Ve.WARN,...n)}error(...n){this._userLogHandler&&this._userLogHandler(this,Ve.ERROR,...n),this._logHandler(this,Ve.ERROR,...n)}};var er=class{constructor(n,e,r){this.name=n,this.instanceFactory=e,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(n){return this.instantiationMode=n,this}setMultipleInstances(n){return this.multipleInstances=n,this}setServiceProps(n){return this.serviceProps=n,this}setInstanceCreatedCallback(n){return this.onInstanceCreated=n,this}};var zi="[DEFAULT]";var Dp=class{constructor(n,e){this.name=n,this.container=e,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(n){let e=this.normalizeInstanceIdentifier(n);if(!this.instancesDeferred.has(e)){let r=new Wt;if(this.instancesDeferred.set(e,r),this.isInitialized(e)||this.shouldAutoInitialize())try{let i=this.getOrInitializeService({instanceIdentifier:e});i&&r.resolve(i)}catch{}}return this.instancesDeferred.get(e).promise}getImmediate(n){let e=this.normalizeInstanceIdentifier(n?.identifier),r=n?.optional??!1;if(this.isInitialized(e)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:e})}catch(i){if(r)return null;throw i}else{if(r)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(n){if(n.name!==this.name)throw Error(`Mismatching Component ${n.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=n,!!this.shouldAutoInitialize()){if(xX(n))try{this.getOrInitializeService({instanceIdentifier:zi})}catch{}for(let[e,r]of this.instancesDeferred.entries()){let i=this.normalizeInstanceIdentifier(e);try{let o=this.getOrInitializeService({instanceIdentifier:i});r.resolve(o)}catch{}}}}clearInstance(n=zi){this.instancesDeferred.delete(n),this.instancesOptions.delete(n),this.instances.delete(n)}async delete(){let n=Array.from(this.instances.values());await Promise.all([...n.filter(e=>"INTERNAL"in e).map(e=>e.INTERNAL.delete()),...n.filter(e=>"_delete"in e).map(e=>e._delete())])}isComponentSet(){return this.component!=null}isInitialized(n=zi){return this.instances.has(n)}getOptions(n=zi){return this.instancesOptions.get(n)||{}}initialize(n={}){let{options:e={}}=n,r=this.normalizeInstanceIdentifier(n.instanceIdentifier);if(this.isInitialized(r))throw Error(`${this.name}(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);let i=this.getOrInitializeService({instanceIdentifier:r,options:e});for(let[o,s]of this.instancesDeferred.entries()){let a=this.normalizeInstanceIdentifier(o);r===a&&s.resolve(i)}return i}onInit(n,e){let r=this.normalizeInstanceIdentifier(e),i=this.onInitCallbacks.get(r)??new Set;i.add(n),this.onInitCallbacks.set(r,i);let o=this.instances.get(r);return o&&n(o,r),()=>{i.delete(n)}}invokeOnInitCallbacks(n,e){let r=this.onInitCallbacks.get(e);if(r)for(let i of r)try{i(n,e)}catch{}}getOrInitializeService({instanceIdentifier:n,options:e={}}){let r=this.instances.get(n);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:TX(n),options:e}),this.instances.set(n,r),this.instancesOptions.set(n,e),this.invokeOnInitCallbacks(r,n),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,n,r)}catch{}return r||null}normalizeInstanceIdentifier(n=zi){return this.component?this.component.multipleInstances?n:zi:n}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}};function TX(t){return t===zi?void 0:t}function xX(t){return t.instantiationMode==="EAGER"}var bc=class{constructor(n){this.name=n,this.providers=new Map}addComponent(n){let e=this.getProvider(n.name);if(e.isComponentSet())throw new Error(`Component ${n.name} has already been registered with ${this.name}`);e.setComponent(n)}addOrOverwriteComponent(n){this.getProvider(n.name).isComponentSet()&&this.providers.delete(n.name),this.addComponent(n)}getProvider(n){if(this.providers.has(n))return this.providers.get(n);let e=new Dp(n,this);return this.providers.set(n,e),e}getProviders(){return Array.from(this.providers.values())}};var DX=(t,n)=>n.some(e=>t instanceof e),aN,cN;function OX(){return aN||(aN=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function MX(){return cN||(cN=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var uN=new WeakMap,tw=new WeakMap,lN=new WeakMap,ew=new WeakMap,rw=new WeakMap;function AX(t){let n=new Promise((e,r)=>{let i=()=>{t.removeEventListener("success",o),t.removeEventListener("error",s)},o=()=>{e(An(t.result)),i()},s=()=>{r(t.error),i()};t.addEventListener("success",o),t.addEventListener("error",s)});return n.then(e=>{e instanceof IDBCursor&&uN.set(e,t)}).catch(()=>{}),rw.set(n,t),n}function NX(t){if(tw.has(t))return;let n=new Promise((e,r)=>{let i=()=>{t.removeEventListener("complete",o),t.removeEventListener("error",s),t.removeEventListener("abort",s)},o=()=>{e(),i()},s=()=>{r(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",o),t.addEventListener("error",s),t.addEventListener("abort",s)});tw.set(t,n)}var nw={get(t,n,e){if(t instanceof IDBTransaction){if(n==="done")return tw.get(t);if(n==="objectStoreNames")return t.objectStoreNames||lN.get(t);if(n==="store")return e.objectStoreNames[1]?void 0:e.objectStore(e.objectStoreNames[0])}return An(t[n])},set(t,n,e){return t[n]=e,!0},has(t,n){return t instanceof IDBTransaction&&(n==="done"||n==="store")?!0:n in t}};function dN(t){nw=t(nw)}function PX(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(n,...e){let r=t.call(Op(this),n,...e);return lN.set(r,n.sort?n.sort():[n]),An(r)}:MX().includes(t)?function(...n){return t.apply(Op(this),n),An(uN.get(this))}:function(...n){return An(t.apply(Op(this),n))}}function RX(t){return typeof t=="function"?PX(t):(t instanceof IDBTransaction&&NX(t),DX(t,OX())?new Proxy(t,nw):t)}function An(t){if(t instanceof IDBRequest)return AX(t);if(ew.has(t))return ew.get(t);let n=RX(t);return n!==t&&(ew.set(t,n),rw.set(n,t)),n}var Op=t=>rw.get(t);function hN(t,n,{blocked:e,upgrade:r,blocking:i,terminated:o}={}){let s=indexedDB.open(t,n),a=An(s);return r&&s.addEventListener("upgradeneeded",c=>{r(An(s.result),c.oldVersion,c.newVersion,An(s.transaction),c)}),e&&s.addEventListener("blocked",c=>e(c.oldVersion,c.newVersion,c)),a.then(c=>{o&&c.addEventListener("close",()=>o()),i&&c.addEventListener("versionchange",u=>i(u.oldVersion,u.newVersion,u))}).catch(()=>{}),a}var kX=["get","getKey","getAll","getAllKeys","count"],LX=["put","add","delete","clear"],iw=new Map;function fN(t,n){if(!(t instanceof IDBDatabase&&!(n in t)&&typeof n=="string"))return;if(iw.get(n))return iw.get(n);let e=n.replace(/FromIndex$/,""),r=n!==e,i=LX.includes(e);if(!(e in(r?IDBIndex:IDBObjectStore).prototype)||!(i||kX.includes(e)))return;let o=async function(s,...a){let c=this.transaction(s,i?"readwrite":"readonly"),u=c.store;return r&&(u=u.index(a.shift())),(await Promise.all([u[e](...a),i&&c.done]))[0]};return iw.set(n,o),o}dN(t=>({...t,get:(n,e,r)=>fN(n,e)||t.get(n,e,r),has:(n,e)=>!!fN(n,e)||t.has(n,e)}));var sw=class{constructor(n){this.container=n}getPlatformInfoString(){return this.container.getProviders().map(e=>{if(jX(e)){let r=e.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(e=>e).join(" ")}};function jX(t){return t.getComponent()?.type==="VERSION"}var aw="@firebase/app",pN="0.14.6";var tr=new qs("@firebase/app"),FX="@firebase/app-compat",$X="@firebase/analytics-compat",qX="@firebase/analytics",BX="@firebase/app-check-compat",HX="@firebase/app-check",UX="@firebase/auth",VX="@firebase/auth-compat",WX="@firebase/database",GX="@firebase/data-connect",zX="@firebase/database-compat",KX="@firebase/functions",YX="@firebase/functions-compat",ZX="@firebase/installations",QX="@firebase/installations-compat",JX="@firebase/messaging",XX="@firebase/messaging-compat",eee="@firebase/performance",tee="@firebase/performance-compat",nee="@firebase/remote-config",ree="@firebase/remote-config-compat",iee="@firebase/storage",oee="@firebase/storage-compat",see="@firebase/firestore",aee="@firebase/ai",cee="@firebase/firestore-compat",uee="firebase",lee="12.6.0";var cw="[DEFAULT]",dee={[aw]:"fire-core",[FX]:"fire-core-compat",[qX]:"fire-analytics",[$X]:"fire-analytics-compat",[HX]:"fire-app-check",[BX]:"fire-app-check-compat",[UX]:"fire-auth",[VX]:"fire-auth-compat",[WX]:"fire-rtdb",[GX]:"fire-data-connect",[zX]:"fire-rtdb-compat",[KX]:"fire-fn",[YX]:"fire-fn-compat",[ZX]:"fire-iid",[QX]:"fire-iid-compat",[JX]:"fire-fcm",[XX]:"fire-fcm-compat",[eee]:"fire-perf",[tee]:"fire-perf-compat",[nee]:"fire-rc",[ree]:"fire-rc-compat",[iee]:"fire-gcs",[oee]:"fire-gcs-compat",[see]:"fire-fst",[cee]:"fire-fst-compat",[aee]:"fire-vertex","fire-js":"fire-js",[uee]:"fire-js-all"};var wc=new Map,fee=new Map,uw=new Map;function mN(t,n){try{t.container.addComponent(n)}catch(e){tr.debug(`Component ${n.name} failed to register with FirebaseApp ${t.name}`,e)}}function Ec(t){let n=t.name;if(uw.has(n))return tr.debug(`There were multiple attempts to register component ${n}.`),!1;uw.set(n,t);for(let e of wc.values())mN(e,t);for(let e of fee.values())mN(e,t);return!0}function _N(t,n){let e=t.container.getProvider("heartbeat").getImmediate({optional:!0});return e&&e.triggerHeartbeat(),t.container.getProvider(n)}function bN(t){return t==null?!1:t.settings!==void 0}var hee={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},Xr=new yc("app","Firebase",hee);var lw=class{constructor(n,e,r){this._isDeleted=!1,this._options={...n},this._config={...e},this._name=e.name,this._automaticDataCollectionEnabled=e.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new er("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(n){this.checkDestroyed(),this._automaticDataCollectionEnabled=n}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(n){this._isDeleted=n}checkDestroyed(){if(this.isDeleted)throw Xr.create("app-deleted",{appName:this._name})}};var wN=lee;function hw(t,n={}){let e=t;typeof n!="object"&&(n={name:n});let r={name:cw,automaticDataCollectionEnabled:!0,...n},i=r.name;if(typeof i!="string"||!i)throw Xr.create("bad-app-name",{appName:String(i)});if(e||(e=Jb()),!e)throw Xr.create("no-options");let o=wc.get(i);if(o){if($s(e,o.options)&&$s(r,o.config))return o;throw Xr.create("duplicate-app",{appName:i})}let s=new bc(i);for(let c of uw.values())s.addComponent(c);let a=new lw(e,r,s);return wc.set(i,a),a}function EN(t=cw){let n=wc.get(t);if(!n&&t===cw&&Jb())return hw();if(!n)throw Xr.create("no-app",{appName:t});return n}function pw(){return Array.from(wc.values())}function ei(t,n,e){let r=dee[t]??t;e&&(r+=`-${e}`);let i=r.match(/\s|\//),o=n.match(/\s|\//);if(i||o){let s=[`Unable to register library "${r}" with version "${n}":`];i&&s.push(`library name "${r}" contains illegal characters (whitespace or "/")`),i&&o&&s.push("and"),o&&s.push(`version name "${n}" contains illegal characters (whitespace or "/")`),tr.warn(s.join(" "));return}Ec(new er(`${r}-version`,()=>({library:r,version:n}),"VERSION"))}var pee="firebase-heartbeat-database",mee=1,Sc="firebase-heartbeat-store",ow=null;function SN(){return ow||(ow=hN(pee,mee,{upgrade:(t,n)=>{switch(n){case 0:try{t.createObjectStore(Sc)}catch(e){console.warn(e)}}}}).catch(t=>{throw Xr.create("idb-open",{originalErrorMessage:t.message})})),ow}async function gee(t){try{let e=(await SN()).transaction(Sc),r=await e.objectStore(Sc).get(CN(t));return await e.done,r}catch(n){if(n instanceof Ui)tr.warn(n.message);else{let e=Xr.create("idb-get",{originalErrorMessage:n?.message});tr.warn(e.message)}}}async function gN(t,n){try{let r=(await SN()).transaction(Sc,"readwrite");await r.objectStore(Sc).put(n,CN(t)),await r.done}catch(e){if(e instanceof Ui)tr.warn(e.message);else{let r=Xr.create("idb-set",{originalErrorMessage:e?.message});tr.warn(r.message)}}}function CN(t){return`${t.name}!${t.options.appId}`}var yee=1024,vee=30,dw=class{constructor(n){this.container=n,this._heartbeatsCache=null;let e=this.container.getProvider("app").getImmediate();this._storage=new fw(e),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}async triggerHeartbeat(){try{let e=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),r=yN();if(this._heartbeatsCache?.heartbeats==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null)||this._heartbeatsCache.lastSentHeartbeatDate===r||this._heartbeatsCache.heartbeats.some(i=>i.date===r))return;if(this._heartbeatsCache.heartbeats.push({date:r,agent:e}),this._heartbeatsCache.heartbeats.length>vee){let i=bee(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(i,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(n){tr.warn(n)}}async getHeartbeatsHeader(){try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null||this._heartbeatsCache.heartbeats.length===0)return"";let n=yN(),{heartbeatsToSend:e,unsentEntries:r}=_ee(this._heartbeatsCache.heartbeats),i=gc(JSON.stringify({version:2,heartbeats:e}));return this._heartbeatsCache.lastSentHeartbeatDate=n,r.length>0?(this._heartbeatsCache.heartbeats=r,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),i}catch(n){return tr.warn(n),""}}};function yN(){return new Date().toISOString().substring(0,10)}function _ee(t,n=yee){let e=[],r=t.slice();for(let i of t){let o=e.find(s=>s.agent===i.agent);if(o){if(o.dates.push(i.date),vN(e)>n){o.dates.pop();break}}else if(e.push({agent:i.agent,dates:[i.date]}),vN(e)>n){e.pop();break}r=r.slice(1)}return{heartbeatsToSend:e,unsentEntries:r}}var fw=class{constructor(n){this.app=n,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return eN()?tN().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){let e=await gee(this.app);return e?.heartbeats?e:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(n){if(await this._canUseIndexedDBPromise){let r=await this.read();return gN(this.app,{lastSentHeartbeatDate:n.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:n.heartbeats})}else return}async add(n){if(await this._canUseIndexedDBPromise){let r=await this.read();return gN(this.app,{lastSentHeartbeatDate:n.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:[...r.heartbeats,...n.heartbeats]})}else return}};function vN(t){return gc(JSON.stringify({version:2,heartbeats:t})).length}function bee(t){if(t.length===0)return-1;let n=0,e=t[0].date;for(let r=1;r<t.length;r++)t[r].date<e&&(e=t[r].date,n=r);return n}function wee(t){Ec(new er("platform-logger",n=>new sw(n),"PRIVATE")),Ec(new er("heartbeat",n=>new dw(n),"PRIVATE")),ei(aw,pN,t),ei(aw,pN,"esm2020"),ei("fire-js","")}wee("");var Ap="5",aP="v",cP="s",uP="r",lP="f",dP=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,fP="ls",hP="p",Ew="ac",pP="websocket",mP="long_polling";var Sw=class{constructor(n){this.domStorage_=n,this.prefix_="firebase:"}set(n,e){e==null?this.domStorage_.removeItem(this.prefixedName_(n)):this.domStorage_.setItem(this.prefixedName_(n),nt(e))}get(n){let e=this.domStorage_.getItem(this.prefixedName_(n));return e==null?null:Fs(e)}remove(n){this.domStorage_.removeItem(this.prefixedName_(n))}prefixedName_(n){return this.prefix_+n}toString(){return this.domStorage_.toString()}};var Cw=class{constructor(){this.cache_={},this.isInMemoryStorage=!0}set(n,e){e==null?delete this.cache_[n]:this.cache_[n]=e}get(n){return ln(this.cache_,n)?this.cache_[n]:null}remove(n){delete this.cache_[n]}};var gP=function(t){try{if(typeof window<"u"&&typeof window[t]<"u"){let n=window[t];return n.setItem("firebase:sentinel","cache"),n.removeItem("firebase:sentinel"),new Sw(n)}}catch{}return new Cw},Yi=gP("localStorage"),Iw=gP("sessionStorage");var Us=new qs("@firebase/database"),See=(function(){let t=1;return function(){return t++}})(),yP=function(t){let n=sN(t),e=new Cp;e.update(n);let r=e.digest();return Ip.encodeByteArray(r)},Bc=function(...t){let n="";for(let e=0;e<t.length;e++){let r=t[e];Array.isArray(r)||r&&typeof r=="object"&&typeof r.length=="number"?n+=Bc.apply(null,r):typeof r=="object"?n+=nt(r):n+=r,n+=" "}return n},Ji=null,IN=!0,Cee=function(t,n){A(!n||t===!0||t===!1,"Can't turn on custom loggers persistently."),t===!0?(Us.logLevel=Ve.VERBOSE,Ji=Us.log.bind(Us),n&&Iw.set("logging_enabled",!0)):typeof t=="function"?Ji=t:(Ji=null,Iw.remove("logging_enabled"))},pt=function(...t){if(IN===!0&&(IN=!1,Ji===null&&Iw.get("logging_enabled")===!0&&Cee(!0)),Ji){let n=Bc.apply(null,t);Ji(n)}},Hc=function(t){return function(...n){pt(t,...n)}},Tw=function(...t){let n="FIREBASE INTERNAL ERROR: "+Bc(...t);Us.error(n)},nr=function(...t){let n=`FIREBASE FATAL ERROR: ${Bc(...t)}`;throw Us.error(n),new Error(n)},Rt=function(...t){let n="FIREBASE WARNING: "+Bc(...t);Us.warn(n)},Iee=function(){typeof window<"u"&&window.location&&window.location.protocol&&window.location.protocol.indexOf("https:")!==-1&&Rt("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().")},Xp=function(t){return typeof t=="number"&&(t!==t||t===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY)},Tee=function(t){if(Mn()||document.readyState==="complete")t();else{let n=!1,e=function(){if(!document.body){setTimeout(e,Math.floor(10));return}n||(n=!0,t())};document.addEventListener?(document.addEventListener("DOMContentLoaded",e,!1),window.addEventListener("load",e,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",()=>{document.readyState==="complete"&&e()}),window.attachEvent("onload",e))}},Gs="[MIN_NAME]",Xi="[MAX_NAME]",to=function(t,n){if(t===n)return 0;if(t===Gs||n===Xi)return-1;if(n===Gs||t===Xi)return 1;{let e=TN(t),r=TN(n);return e!==null?r!==null?e-r===0?t.length-n.length:e-r:-1:r!==null?1:t<n?-1:1}},xee=function(t,n){return t===n?0:t<n?-1:1},Cc=function(t,n){if(n&&t in n)return n[t];throw new Error("Missing required key ("+t+") in object: "+nt(n))},wE=function(t){if(typeof t!="object"||t===null)return nt(t);let n=[];for(let r in t)n.push(r);n.sort();let e="{";for(let r=0;r<n.length;r++)r!==0&&(e+=","),e+=nt(n[r]),e+=":",e+=wE(t[n[r]]);return e+="}",e},vP=function(t,n){let e=t.length;if(e<=n)return[t];let r=[];for(let i=0;i<e;i+=n)i+n>e?r.push(t.substring(i,e)):r.push(t.substring(i,i+n));return r};function bt(t,n){for(let e in t)t.hasOwnProperty(e)&&n(e,t[e])}var _P=function(t){A(!Xp(t),"Invalid JSON number");let n=11,e=52,r=(1<<n-1)-1,i,o,s,a,c;t===0?(o=0,s=0,i=1/t===-1/0?1:0):(i=t<0,t=Math.abs(t),t>=Math.pow(2,1-r)?(a=Math.min(Math.floor(Math.log(t)/Math.LN2),r),o=a+r,s=Math.round(t*Math.pow(2,e-a)-Math.pow(2,e))):(o=0,s=Math.round(t/Math.pow(2,1-r-e))));let u=[];for(c=e;c;c-=1)u.push(s%2?1:0),s=Math.floor(s/2);for(c=n;c;c-=1)u.push(o%2?1:0),o=Math.floor(o/2);u.push(i?1:0),u.reverse();let l=u.join(""),d="";for(c=0;c<64;c+=8){let f=parseInt(l.substr(c,8),2).toString(16);f.length===1&&(f="0"+f),d=d+f}return d.toLowerCase()},Dee=function(){return!!(typeof window=="object"&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href))},Oee=function(){return typeof Windows=="object"&&typeof Windows.UI=="object"};function Mee(t,n){let e="Unknown Error";t==="too_big"?e="The data requested exceeds the maximum size that can be accessed with a single request.":t==="permission_denied"?e="Client doesn't have permission to access the desired data.":t==="unavailable"&&(e="The service is unavailable");let r=new Error(t+" at "+n._path.toString()+": "+e);return r.code=t.toUpperCase(),r}var Aee=new RegExp("^-?(0*)\\d{1,10}$"),Nee=-2147483648,Pee=2147483647,TN=function(t){if(Aee.test(t)){let n=Number(t);if(n>=Nee&&n<=Pee)return n}return null},ta=function(t){try{t()}catch(n){setTimeout(()=>{let e=n.stack||"";throw Rt("Exception was thrown by user callback.",e),n},Math.floor(0))}},Ree=function(){return(typeof window=="object"&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)>=0},Oc=function(t,n){let e=setTimeout(t,n);return typeof e=="number"&&typeof Deno<"u"&&Deno.unrefTimer?Deno.unrefTimer(e):typeof e=="object"&&e.unref&&e.unref(),e};var Np=class{constructor(n,e,r,i,o=!1,s="",a=!1,c=!1,u=null){this.secure=e,this.namespace=r,this.webSocketOnly=i,this.nodeAdmin=o,this.persistenceKey=s,this.includeNamespaceInQueryParams=a,this.isUsingEmulator=c,this.emulatorOptions=u,this._host=n.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=Yi.get("host:"+n)||this._host}isCacheableHost(){return this.internalHost.substr(0,2)==="s-"}isCustomHost(){return this._domain!=="firebaseio.com"&&this._domain!=="firebaseio-demo.com"}get host(){return this._host}set host(n){n!==this.internalHost&&(this.internalHost=n,this.isCacheableHost()&&Yi.set("host:"+this._host,this.internalHost))}toString(){let n=this.toURLString();return this.persistenceKey&&(n+="<"+this.persistenceKey+">"),n}toURLString(){let n=this.secure?"https://":"http://",e=this.includeNamespaceInQueryParams?`?ns=${this.namespace}`:"";return`${n}${this.host}/${e}`}};function kee(t){return t.host!==t.internalHost||t.isCustomHost()||t.includeNamespaceInQueryParams}function bP(t,n,e){A(typeof n=="string","typeof type must == string"),A(typeof e=="object","typeof params must == object");let r;if(n===pP)r=(t.secure?"wss://":"ws://")+t.internalHost+"/.ws?";else if(n===mP)r=(t.secure?"https://":"http://")+t.internalHost+"/.lp?";else throw new Error("Unknown connection type: "+n);kee(t)&&(e.ns=t.namespace);let i=[];return bt(e,(o,s)=>{i.push(o+"="+s)}),r+i.join("&")}var xw=class{constructor(){this.counters_={}}incrementCounter(n,e=1){ln(this.counters_,n)||(this.counters_[n]=0),this.counters_[n]+=e}get(){return GA(this.counters_)}};var mw={},gw={};function EE(t){let n=t.toString();return mw[n]||(mw[n]=new xw),mw[n]}function Lee(t,n){let e=t.toString();return gw[e]||(gw[e]=n()),gw[e]}var SE="";function jee(t){SE=t}var Fee=16384,$ee=45e3,Rc=null;typeof MozWebSocket<"u"?Rc=MozWebSocket:typeof WebSocket<"u"&&(Rc=WebSocket);function qee(t){Rc=t}var Ic=(()=>{class t{constructor(e,r,i,o,s,a,c){this.connId=e,this.applicationId=i,this.appCheckToken=o,this.authToken=s,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=Hc(this.connId),this.stats_=EE(r),this.connURL=t.connectionURL_(r,a,c,o,i),this.nodeAdmin=r.nodeAdmin}static connectionURL_(e,r,i,o,s){let a={};return a[aP]=Ap,!Mn()&&typeof location<"u"&&location.hostname&&dP.test(location.hostname)&&(a[uP]=lP),r&&(a[cP]=r),i&&(a[fP]=i),o&&(a[Ew]=o),s&&(a[hP]=s),bP(e,pP,a)}open(e,r){this.onDisconnect=r,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,Yi.set("previous_websocket_failure",!0);try{let i;if(Mn()){let o=this.nodeAdmin?"AdminNode":"Node";i={headers:{"User-Agent":`Firebase/${Ap}/${SE}/${process.platform}/${o}`,"X-Firebase-GMPID":this.applicationId||""}},this.authToken&&(i.headers.Authorization=`Bearer ${this.authToken}`),this.appCheckToken&&(i.headers["X-Firebase-AppCheck"]=this.appCheckToken);let s=process.env,a=this.connURL.indexOf("wss://")===0?s.HTTPS_PROXY||s.https_proxy:s.HTTP_PROXY||s.http_proxy;a&&(i.proxy={origin:a})}this.mySock=new Rc(this.connURL,[],i)}catch(i){this.log_("Error instantiating WebSocket.");let o=i.message||i.data;o&&this.log_(o),this.onClosed_();return}this.mySock.onopen=()=>{this.log_("Websocket connected."),this.everConnected_=!0},this.mySock.onclose=()=>{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()},this.mySock.onmessage=i=>{this.handleIncomingFrame(i)},this.mySock.onerror=i=>{this.log_("WebSocket error. Closing connection.");let o=i.message||i.data;o&&this.log_(o),this.onClosed_()}}start(){}static forceDisallow(){t.forceDisallow_=!0}static isAvailable(){let e=!1;if(typeof navigator<"u"&&navigator.userAgent){let r=/Android ([0-9]{0,}\.[0-9]{0,})/,i=navigator.userAgent.match(r);i&&i.length>1&&parseFloat(i[1])<4.4&&(e=!0)}return!e&&Rc!==null&&!t.forceDisallow_}static previouslyFailed(){return Yi.isInMemoryStorage||Yi.get("previous_websocket_failure")===!0}markConnectionHealthy(){Yi.remove("previous_websocket_failure")}appendFrame_(e){if(this.frames.push(e),this.frames.length===this.totalFrames){let r=this.frames.join("");this.frames=null;let i=Fs(r);this.onMessage(i)}}handleNewFrameCount_(e){this.totalFrames=e,this.frames=[]}extractFrameCount_(e){if(A(this.frames===null,"We already have a frame buffer"),e.length<=6){let r=Number(e);if(!isNaN(r))return this.handleNewFrameCount_(r),null}return this.handleNewFrameCount_(1),e}handleIncomingFrame(e){if(this.mySock===null)return;let r=e.data;if(this.bytesReceived+=r.length,this.stats_.incrementCounter("bytes_received",r.length),this.resetKeepAlive(),this.frames!==null)this.appendFrame_(r);else{let i=this.extractFrameCount_(r);i!==null&&this.appendFrame_(i)}}send(e){this.resetKeepAlive();let r=nt(e);this.bytesSent+=r.length,this.stats_.incrementCounter("bytes_sent",r.length);let i=vP(r,Fee);i.length>1&&this.sendString_(String(i.length));for(let o=0;o<i.length;o++)this.sendString_(i[o])}shutdown_(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)}onClosed_(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))}close(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())}resetKeepAlive(){clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(()=>{this.mySock&&this.sendString_("0"),this.resetKeepAlive()},Math.floor($ee))}sendString_(e){try{this.mySock.send(e)}catch(r){this.log_("Exception thrown from WebSocket.send():",r.message||r.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}}}return t.responsesRequiredToBeHealthy=2,t.healthyTimeout=3e4,t})(),xN="@firebase/database",DN="1.1.0";var Dw=class{constructor(n,e){this.appCheckProvider=e,this.appName=n.name,bN(n)&&n.settings.appCheckToken&&(this.serverAppAppCheckToken=n.settings.appCheckToken),this.appCheck=e?.getImmediate({optional:!0}),this.appCheck||e?.get().then(r=>this.appCheck=r)}getToken(n){if(this.serverAppAppCheckToken){if(n)throw new Error("Attempted reuse of `FirebaseServerApp.appCheckToken` after previous usage failed.");return Promise.resolve({token:this.serverAppAppCheckToken})}return this.appCheck?this.appCheck.getToken(n):new Promise((e,r)=>{setTimeout(()=>{this.appCheck?this.getToken(n).then(e,r):e(null)},0)})}addTokenChangeListener(n){this.appCheckProvider?.get().then(e=>e.addTokenListener(n))}notifyForInvalidToken(){Rt(`Provided AppCheck credentials for the app named "${this.appName}" are invalid. This usually indicates your app was not initialized correctly.`)}};var Ow=class{constructor(n,e,r){this.appName_=n,this.firebaseOptions_=e,this.authProvider_=r,this.auth_=null,this.auth_=r.getImmediate({optional:!0}),this.auth_||r.onInit(i=>this.auth_=i)}getToken(n){return this.auth_?this.auth_.getToken(n).catch(e=>e&&e.code==="auth/token-not-initialized"?(pt("Got auth/token-not-initialized error. Treating as null token."),null):Promise.reject(e)):new Promise((e,r)=>{setTimeout(()=>{this.auth_?this.getToken(n).then(e,r):e(null)},0)})}addTokenChangeListener(n){this.auth_?this.auth_.addAuthTokenListener(n):this.authProvider_.get().then(e=>e.addAuthTokenListener(n))}removeTokenChangeListener(n){this.authProvider_.get().then(e=>e.removeAuthTokenListener(n))}notifyForInvalidToken(){let n='Provided authentication credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.firebaseOptions_?n+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.firebaseOptions_?n+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':n+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',Rt(n)}},Mc=(()=>{class t{constructor(e){this.accessToken=e}getToken(e){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(e){e(this.accessToken)}removeTokenChangeListener(e){}notifyForInvalidToken(){}}t.OWNER="owner";return t})(),Mw=class{constructor(n){this.onMessage_=n,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}closeAfter(n,e){this.closeAfterResponse=n,this.onClose=e,this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)}handleResponse(n,e){for(this.pendingResponses[n]=e;this.pendingResponses[this.currentResponseNum];){let r=this.pendingResponses[this.currentResponseNum];delete this.pendingResponses[this.currentResponseNum];for(let i=0;i<r.length;++i)r[i]&&ta(()=>{this.onMessage_(r[i])});if(this.currentResponseNum===this.closeAfterResponse){this.onClose&&(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}};var ON="start",Bee="close",Hee="pLPCommand",Uee="pRTLPCB",wP="id",EP="pw",SP="ser",Vee="cb",Wee="seg",Gee="ts",zee="d",Kee="dframe",CP=1870,IP=30,Yee=CP-IP,Zee=25e3,Qee=3e4,Aw=class t{constructor(n,e,r,i,o,s,a){this.connId=n,this.repoInfo=e,this.applicationId=r,this.appCheckToken=i,this.authToken=o,this.transportSessionId=s,this.lastSessionId=a,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=Hc(n),this.stats_=EE(e),this.urlFn=c=>(this.appCheckToken&&(c[Ew]=this.appCheckToken),bP(e,mP,c))}open(n,e){this.curSegmentNum=0,this.onDisconnect_=e,this.myPacketOrderer=new Mw(n),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(()=>{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null},Math.floor(Qee)),Tee(()=>{if(this.isClosed_)return;this.scriptTagHolder=new Nw((...o)=>{let[s,a,c,u,l]=o;if(this.incrementIncomingBytes_(o),!!this.scriptTagHolder)if(this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null),this.everConnected_=!0,s===ON)this.id=a,this.password=c;else if(s===Bee)a?(this.scriptTagHolder.sendNewPolls=!1,this.myPacketOrderer.closeAfter(a,()=>{this.onClosed_()})):this.onClosed_();else throw new Error("Unrecognized command received: "+s)},(...o)=>{let[s,a]=o;this.incrementIncomingBytes_(o),this.myPacketOrderer.handleResponse(s,a)},()=>{this.onClosed_()},this.urlFn);let r={};r[ON]="t",r[SP]=Math.floor(Math.random()*1e8),this.scriptTagHolder.uniqueCallbackIdentifier&&(r[Vee]=this.scriptTagHolder.uniqueCallbackIdentifier),r[aP]=Ap,this.transportSessionId&&(r[cP]=this.transportSessionId),this.lastSessionId&&(r[fP]=this.lastSessionId),this.applicationId&&(r[hP]=this.applicationId),this.appCheckToken&&(r[Ew]=this.appCheckToken),typeof location<"u"&&location.hostname&&dP.test(location.hostname)&&(r[uP]=lP);let i=this.urlFn(r);this.log_("Connecting via long-poll to "+i),this.scriptTagHolder.addTag(i,()=>{})})}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){t.forceAllow_=!0}static forceDisallow(){t.forceDisallow_=!0}static isAvailable(){return Mn()?!1:t.forceAllow_?!0:!t.forceDisallow_&&typeof document<"u"&&document.createElement!=null&&!Dee()&&!Oee()}markConnectionHealthy(){}shutdown_(){this.isClosed_=!0,this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)}onClosed_(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))}close(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())}send(n){let e=nt(n);this.bytesSent+=e.length,this.stats_.incrementCounter("bytes_sent",e.length);let r=Qb(e),i=vP(r,Yee);for(let o=0;o<i.length;o++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,i.length,i[o]),this.curSegmentNum++}addDisconnectPingFrame(n,e){if(Mn())return;this.myDisconnFrame=document.createElement("iframe");let r={};r[Kee]="t",r[wP]=n,r[EP]=e,this.myDisconnFrame.src=this.urlFn(r),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}incrementIncomingBytes_(n){let e=nt(n).length;this.bytesReceived+=e,this.stats_.incrementCounter("bytes_received",e)}},Nw=class t{constructor(n,e,r,i){if(this.onDisconnect=r,this.urlFn=i,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(Math.random()*1e8),this.sendNewPolls=!0,Mn())this.commandCB=n,this.onMessageCB=e;else{this.uniqueCallbackIdentifier=See(),window[Hee+this.uniqueCallbackIdentifier]=n,window[Uee+this.uniqueCallbackIdentifier]=e,this.myIFrame=t.createIFrame_();let o="";this.myIFrame.src&&this.myIFrame.src.substr(0,11)==="javascript:"&&(o='<script>document.domain="'+document.domain+'";</script>');let s="<html><body>"+o+"</body></html>";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(s),this.myIFrame.doc.close()}catch(a){pt("frame writing exception"),a.stack&&pt(a.stack),pt(a)}}}static createIFrame_(){let n=document.createElement("iframe");if(n.style.display="none",document.body){document.body.appendChild(n);try{n.contentWindow.document||pt("No IE domain setting required")}catch{let r=document.domain;n.src="javascript:void((function(){document.open();document.domain='"+r+"';document.close();})())"}}else throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";return n.contentDocument?n.doc=n.contentDocument:n.contentWindow?n.doc=n.contentWindow.document:n.document&&(n.doc=n.document),n}close(){this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.textContent="",setTimeout(()=>{this.myIFrame!==null&&(document.body.removeChild(this.myIFrame),this.myIFrame=null)},Math.floor(0)));let n=this.onDisconnect;n&&(this.onDisconnect=null,n())}startLongPoll(n,e){for(this.myID=n,this.myPW=e,this.alive=!0;this.newRequest_(););}newRequest_(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(this.pendingSegs.length>0?2:1)){this.currentSerial++;let n={};n[wP]=this.myID,n[EP]=this.myPW,n[SP]=this.currentSerial;let e=this.urlFn(n),r="",i=0;for(;this.pendingSegs.length>0&&this.pendingSegs[0].d.length+IP+r.length<=CP;){let s=this.pendingSegs.shift();r=r+"&"+Wee+i+"="+s.seg+"&"+Gee+i+"="+s.ts+"&"+zee+i+"="+s.d,i++}return e=e+r,this.addLongPollTag_(e,this.currentSerial),!0}else return!1}enqueueSegment(n,e,r){this.pendingSegs.push({seg:n,ts:e,d:r}),this.alive&&this.newRequest_()}addLongPollTag_(n,e){this.outstandingRequests.add(e);let r=()=>{this.outstandingRequests.delete(e),this.newRequest_()},i=setTimeout(r,Math.floor(Zee)),o=()=>{clearTimeout(i),r()};this.addTag(n,o)}addTag(n,e){Mn()?this.doNodeLongPoll(n,e):setTimeout(()=>{try{if(!this.sendNewPolls)return;let r=this.myIFrame.doc.createElement("script");r.type="text/javascript",r.async=!0,r.src=n,r.onload=r.onreadystatechange=function(){let i=r.readyState;(!i||i==="loaded"||i==="complete")&&(r.onload=r.onreadystatechange=null,r.parentNode&&r.parentNode.removeChild(r),e())},r.onerror=()=>{pt("Long-poll script failed to load: "+n),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(r)}catch{}},Math.floor(1))}};var Jee=(()=>{class t{static get ALL_TRANSPORTS(){return[Aw,Ic]}static get IS_TRANSPORT_INITIALIZED(){return this.globalTransportInitialized_}constructor(e){this.initTransports_(e)}initTransports_(e){let r=Ic&&Ic.isAvailable(),i=r&&!Ic.previouslyFailed();if(e.webSocketOnly&&(r||Rt("wss:// URL used, but browser isn't known to support websockets. Trying anyway."),i=!0),i)this.transports_=[Ic];else{let o=this.transports_=[];for(let s of t.ALL_TRANSPORTS)s&&s.isAvailable()&&o.push(s);t.globalTransportInitialized_=!0}}initialTransport(){if(this.transports_.length>0)return this.transports_[0];throw new Error("No transports available")}upgradeTransport(){return this.transports_.length>1?this.transports_[1]:null}}t.globalTransportInitialized_=!1;return t})(),Xee=6e4,ete=5e3,tte=10*1024,nte=100*1024,yw="t",MN="d",rte="s",AN="r",ite="e",NN="o",PN="a",RN="n",kN="p",ote="h",Pw=class{constructor(n,e,r,i,o,s,a,c,u,l){this.id=n,this.repoInfo_=e,this.applicationId_=r,this.appCheckToken_=i,this.authToken_=o,this.onMessage_=s,this.onReady_=a,this.onDisconnect_=c,this.onKill_=u,this.lastSessionId=l,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=Hc("c:"+this.id+":"),this.transportManager_=new Jee(e),this.log_("Connection created"),this.start_()}start_(){let n=this.transportManager_.initialTransport();this.conn_=new n(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,null,this.lastSessionId),this.primaryResponsesRequired_=n.responsesRequiredToBeHealthy||0;let e=this.connReceiver_(this.conn_),r=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout(()=>{this.conn_&&this.conn_.open(e,r)},Math.floor(0));let i=n.healthyTimeout||0;i>0&&(this.healthyTimeout_=Oc(()=>{this.healthyTimeout_=null,this.isHealthy_||(this.conn_&&this.conn_.bytesReceived>nte?(this.log_("Connection exceeded healthy timeout but has received "+this.conn_.bytesReceived+" bytes. Marking connection healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()):this.conn_&&this.conn_.bytesSent>tte?this.log_("Connection exceeded healthy timeout but has sent "+this.conn_.bytesSent+" bytes. Leaving connection alive."):(this.log_("Closing unhealthy connection after timeout."),this.close()))},Math.floor(i)))}nextTransportId_(){return"c:"+this.id+":"+this.connectionCount++}disconnReceiver_(n){return e=>{n===this.conn_?this.onConnectionLost_(e):n===this.secondaryConn_?(this.log_("Secondary connection lost."),this.onSecondaryConnectionLost_()):this.log_("closing an old connection")}}connReceiver_(n){return e=>{this.state_!==2&&(n===this.rx_?this.onPrimaryMessageReceived_(e):n===this.secondaryConn_?this.onSecondaryMessageReceived_(e):this.log_("message on old connection"))}}sendRequest(n){let e={t:"d",d:n};this.sendData_(e)}tryCleanupConnection(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)}onSecondaryControl_(n){if(yw in n){let e=n[yw];e===PN?this.upgradeIfSecondaryHealthy_():e===AN?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),(this.tx_===this.secondaryConn_||this.rx_===this.secondaryConn_)&&this.close()):e===NN&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}}onSecondaryMessageReceived_(n){let e=Cc("t",n),r=Cc("d",n);if(e==="c")this.onSecondaryControl_(r);else if(e==="d")this.pendingDataMessages.push(r);else throw new Error("Unknown protocol layer: "+e)}upgradeIfSecondaryHealthy_(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t:"c",d:{t:kN,d:{}}}))}proceedWithUpgrade_(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:PN,d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:RN,d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()}onPrimaryMessageReceived_(n){let e=Cc("t",n),r=Cc("d",n);e==="c"?this.onControl_(r):e==="d"&&this.onDataMessage_(r)}onDataMessage_(n){this.onPrimaryResponse_(),this.onMessage_(n)}onPrimaryResponse_(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))}onControl_(n){let e=Cc(yw,n);if(MN in n){let r=n[MN];if(e===ote){let i={...r};this.repoInfo_.isUsingEmulator&&(i.h=this.repoInfo_.host),this.onHandshake_(i)}else if(e===RN){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(let i=0;i<this.pendingDataMessages.length;++i)this.onDataMessage_(this.pendingDataMessages[i]);this.pendingDataMessages=[],this.tryCleanupConnection()}else e===rte?this.onConnectionShutdown_(r):e===AN?this.onReset_(r):e===ite?Tw("Server Error: "+r):e===NN?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):Tw("Unknown control packet command: "+e)}}onHandshake_(n){let e=n.ts,r=n.v,i=n.h;this.sessionId=n.s,this.repoInfo_.host=i,this.state_===0&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,e),Ap!==r&&Rt("Protocol version mismatch detected"),this.tryStartUpgrade_())}tryStartUpgrade_(){let n=this.transportManager_.upgradeTransport();n&&this.startUpgrade_(n)}startUpgrade_(n){this.secondaryConn_=new n(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,this.sessionId),this.secondaryResponsesRequired_=n.responsesRequiredToBeHealthy||0;let e=this.connReceiver_(this.secondaryConn_),r=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(e,r),Oc(()=>{this.secondaryConn_&&(this.log_("Timed out trying to upgrade."),this.secondaryConn_.close())},Math.floor(Xee))}onReset_(n){this.log_("Reset packet received. New host: "+n),this.repoInfo_.host=n,this.state_===1?this.close():(this.closeConnections_(),this.start_())}onConnectionEstablished_(n,e){this.log_("Realtime connection established."),this.conn_=n,this.state_=1,this.onReady_&&(this.onReady_(e,this.sessionId),this.onReady_=null),this.primaryResponsesRequired_===0?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):Oc(()=>{this.sendPingOnPrimaryIfNecessary_()},Math.floor(ete))}sendPingOnPrimaryIfNecessary_(){!this.isHealthy_&&this.state_===1&&(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:kN,d:{}}}))}onSecondaryConnectionLost_(){let n=this.secondaryConn_;this.secondaryConn_=null,(this.tx_===n||this.rx_===n)&&this.close()}onConnectionLost_(n){this.conn_=null,!n&&this.state_===0?(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(Yi.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)):this.state_===1&&this.log_("Realtime connection lost."),this.close()}onConnectionShutdown_(n){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&&(this.onKill_(n),this.onKill_=null),this.onDisconnect_=null,this.close()}sendData_(n){if(this.state_!==1)throw"Connection is not connected";this.tx_.send(n)}close(){this.state_!==2&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))}closeConnections_(){this.log_("Shutting down all connections"),this.conn_&&(this.conn_.close(),this.conn_=null),this.secondaryConn_&&(this.secondaryConn_.close(),this.secondaryConn_=null),this.healthyTimeout_&&(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)}};var Pp=class{put(n,e,r,i){}merge(n,e,r,i){}refreshAuthToken(n){}refreshAppCheckToken(n){}onDisconnectPut(n,e,r){}onDisconnectMerge(n,e,r){}onDisconnectCancel(n,e){}reportStats(n){}};var Rp=class{constructor(n){this.allowedEvents_=n,this.listeners_={},A(Array.isArray(n)&&n.length>0,"Requires a non-empty array")}trigger(n,...e){if(Array.isArray(this.listeners_[n])){let r=[...this.listeners_[n]];for(let i=0;i<r.length;i++)r[i].callback.apply(r[i].context,e)}}on(n,e,r){this.validateEventType_(n),this.listeners_[n]=this.listeners_[n]||[],this.listeners_[n].push({callback:e,context:r});let i=this.getInitialEvent(n);i&&e.apply(r,i)}off(n,e,r){this.validateEventType_(n);let i=this.listeners_[n]||[];for(let o=0;o<i.length;o++)if(i[o].callback===e&&(!r||r===i[o].context)){i.splice(o,1);return}}validateEventType_(n){A(this.allowedEvents_.find(e=>e===n),"Unknown event: "+n)}};var kp=class t extends Rp{static getInstance(){return new t}constructor(){super(["online"]),this.online_=!0,typeof window<"u"&&typeof window.addEventListener<"u"&&!Xb()&&(window.addEventListener("online",()=>{this.online_||(this.online_=!0,this.trigger("online",!0))},!1),window.addEventListener("offline",()=>{this.online_&&(this.online_=!1,this.trigger("online",!1))},!1))}getInitialEvent(n){return A(n==="online","Unknown event type: "+n),[this.online_]}currentlyOnline(){return this.online_}};var LN=32,jN=768,Pe=class{constructor(n,e){if(e===void 0){this.pieces_=n.split("/");let r=0;for(let i=0;i<this.pieces_.length;i++)this.pieces_[i].length>0&&(this.pieces_[r]=this.pieces_[i],r++);this.pieces_.length=r,this.pieceNum_=0}else this.pieces_=n,this.pieceNum_=e}toString(){let n="";for(let e=this.pieceNum_;e<this.pieces_.length;e++)this.pieces_[e]!==""&&(n+="/"+this.pieces_[e]);return n||"/"}};function Ne(){return new Pe("")}function he(t){return t.pieceNum_>=t.pieces_.length?null:t.pieces_[t.pieceNum_]}function ni(t){return t.pieces_.length-t.pieceNum_}function Fe(t){let n=t.pieceNum_;return n<t.pieces_.length&&n++,new Pe(t.pieces_,n)}function CE(t){return t.pieceNum_<t.pieces_.length?t.pieces_[t.pieces_.length-1]:null}function ste(t){let n="";for(let e=t.pieceNum_;e<t.pieces_.length;e++)t.pieces_[e]!==""&&(n+="/"+encodeURIComponent(String(t.pieces_[e])));return n||"/"}function kc(t,n=0){return t.pieces_.slice(t.pieceNum_+n)}function TP(t){if(t.pieceNum_>=t.pieces_.length)return null;let n=[];for(let e=t.pieceNum_;e<t.pieces_.length-1;e++)n.push(t.pieces_[e]);return new Pe(n,0)}function Ze(t,n){let e=[];for(let r=t.pieceNum_;r<t.pieces_.length;r++)e.push(t.pieces_[r]);if(n instanceof Pe)for(let r=n.pieceNum_;r<n.pieces_.length;r++)e.push(n.pieces_[r]);else{let r=n.split("/");for(let i=0;i<r.length;i++)r[i].length>0&&e.push(r[i])}return new Pe(e,0)}function ye(t){return t.pieceNum_>=t.pieces_.length}function Pt(t,n){let e=he(t),r=he(n);if(e===null)return n;if(e===r)return Pt(Fe(t),Fe(n));throw new Error("INTERNAL ERROR: innerPath ("+n+") is not within outerPath ("+t+")")}function ate(t,n){let e=kc(t,0),r=kc(n,0);for(let i=0;i<e.length&&i<r.length;i++){let o=to(e[i],r[i]);if(o!==0)return o}return e.length===r.length?0:e.length<r.length?-1:1}function IE(t,n){if(ni(t)!==ni(n))return!1;for(let e=t.pieceNum_,r=n.pieceNum_;e<=t.pieces_.length;e++,r++)if(t.pieces_[e]!==n.pieces_[r])return!1;return!0}function Xt(t,n){let e=t.pieceNum_,r=n.pieceNum_;if(ni(t)>ni(n))return!1;for(;e<t.pieces_.length;){if(t.pieces_[e]!==n.pieces_[r])return!1;++e,++r}return!0}var Rw=class{constructor(n,e){this.errorPrefix_=e,this.parts_=kc(n,0),this.byteLength_=Math.max(1,this.parts_.length);for(let r=0;r<this.parts_.length;r++)this.byteLength_+=_c(this.parts_[r]);xP(this)}};function cte(t,n){t.parts_.length>0&&(t.byteLength_+=1),t.parts_.push(n),t.byteLength_+=_c(n),xP(t)}function ute(t){let n=t.parts_.pop();t.byteLength_-=_c(n),t.parts_.length>0&&(t.byteLength_-=1)}function xP(t){if(t.byteLength_>jN)throw new Error(t.errorPrefix_+"has a key path longer than "+jN+" bytes ("+t.byteLength_+").");if(t.parts_.length>LN)throw new Error(t.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+LN+") or object contains a cycle "+Ki(t))}function Ki(t){return t.parts_.length===0?"":"in property '"+t.parts_.join(".")+"'"}var kw=class t extends Rp{static getInstance(){return new t}constructor(){super(["visible"]);let n,e;typeof document<"u"&&typeof document.addEventListener<"u"&&(typeof document.hidden<"u"?(e="visibilitychange",n="hidden"):typeof document.mozHidden<"u"?(e="mozvisibilitychange",n="mozHidden"):typeof document.msHidden<"u"?(e="msvisibilitychange",n="msHidden"):typeof document.webkitHidden<"u"&&(e="webkitvisibilitychange",n="webkitHidden")),this.visible_=!0,e&&document.addEventListener(e,()=>{let r=!document[n];r!==this.visible_&&(this.visible_=r,this.trigger("visible",r))},!1)}getInitialEvent(n){return A(n==="visible","Unknown event type: "+n),[this.visible_]}};var Tc=1e3,lte=300*1e3,FN=30*1e3,dte=1.3,fte=3e4,hte="server_kill",$N=3,TE=(()=>{class t extends Pp{constructor(e,r,i,o,s,a,c,u){if(super(),this.repoInfo_=e,this.applicationId_=r,this.onDataUpdate_=i,this.onConnectStatus_=o,this.onServerInfoUpdate_=s,this.authTokenProvider_=a,this.appCheckTokenProvider_=c,this.authOverride_=u,this.id=t.nextPersistentConnectionId_++,this.log_=Hc("p:"+this.id+":"),this.interruptReasons_={},this.listens=new Map,this.outstandingPuts_=[],this.outstandingGets_=[],this.outstandingPutCount_=0,this.outstandingGetCount_=0,this.onDisconnectRequestQueue_=[],this.connected_=!1,this.reconnectDelay_=Tc,this.maxReconnectDelay_=lte,this.securityDebugCallback_=null,this.lastSessionId=null,this.establishConnectionTimer_=null,this.visible_=!1,this.requestCBHash_={},this.requestNumber_=0,this.realtime_=null,this.authToken_=null,this.appCheckToken_=null,this.forceTokenRefresh_=!1,this.invalidAuthTokenCount_=0,this.invalidAppCheckTokenCount_=0,this.firstConnection_=!0,this.lastConnectionAttemptTime_=null,this.lastConnectionEstablishedTime_=null,u&&!Mn())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");kw.getInstance().on("visible",this.onVisible_,this),e.host.indexOf("fblocal")===-1&&kp.getInstance().on("online",this.onOnline_,this)}sendRequest(e,r,i){let o=++this.requestNumber_,s={r:o,a:e,b:r};this.log_(nt(s)),A(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(s),i&&(this.requestCBHash_[o]=i)}get(e){this.initConnection_();let r=new Wt,o={action:"g",request:{p:e._path.toString(),q:e._queryObject},onComplete:a=>{let c=a.d;a.s==="ok"?r.resolve(c):r.reject(c)}};this.outstandingGets_.push(o),this.outstandingGetCount_++;let s=this.outstandingGets_.length-1;return this.connected_&&this.sendGet_(s),r.promise}listen(e,r,i,o){this.initConnection_();let s=e._queryIdentifier,a=e._path.toString();this.log_("Listen called for "+a+" "+s),this.listens.has(a)||this.listens.set(a,new Map),A(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),A(!this.listens.get(a).has(s),"listen() called twice for same path/queryId.");let c={onComplete:o,hashFn:r,query:e,tag:i};this.listens.get(a).set(s,c),this.connected_&&this.sendListen_(c)}sendGet_(e){let r=this.outstandingGets_[e];this.sendRequest("g",r.request,i=>{delete this.outstandingGets_[e],this.outstandingGetCount_--,this.outstandingGetCount_===0&&(this.outstandingGets_=[]),r.onComplete&&r.onComplete(i)})}sendListen_(e){let r=e.query,i=r._path.toString(),o=r._queryIdentifier;this.log_("Listen on "+i+" for "+o);let s={p:i},a="q";e.tag&&(s.q=r._queryObject,s.t=e.tag),s.h=e.hashFn(),this.sendRequest(a,s,c=>{let u=c.d,l=c.s;t.warnOnListenWarnings_(u,r),(this.listens.get(i)&&this.listens.get(i).get(o))===e&&(this.log_("listen response",c),l!=="ok"&&this.removeListen_(i,o),e.onComplete&&e.onComplete(l,u))})}static warnOnListenWarnings_(e,r){if(e&&typeof e=="object"&&ln(e,"w")){let i=Wi(e,"w");if(Array.isArray(i)&&~i.indexOf("no_index")){let o='".indexOn": "'+r._queryParams.getIndex().toString()+'"',s=r._path.toString();Rt(`Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ${o} at ${s} to your security rules for better performance.`)}}}refreshAuthToken(e){this.authToken_=e,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},()=>{}),this.reduceReconnectDelayIfAdminCredential_(e)}reduceReconnectDelayIfAdminCredential_(e){(e&&e.length===40||iN(e))&&(this.log_("Admin auth credential detected. Reducing max reconnect time."),this.maxReconnectDelay_=FN)}refreshAppCheckToken(e){this.appCheckToken_=e,this.log_("App check token refreshed"),this.appCheckToken_?this.tryAppCheck():this.connected_&&this.sendRequest("unappeck",{},()=>{})}tryAuth(){if(this.connected_&&this.authToken_){let e=this.authToken_,r=rN(e)?"auth":"gauth",i={cred:e};this.authOverride_===null?i.noauth=!0:typeof this.authOverride_=="object"&&(i.authvar=this.authOverride_),this.sendRequest(r,i,o=>{let s=o.s,a=o.d||"error";this.authToken_===e&&(s==="ok"?this.invalidAuthTokenCount_=0:this.onAuthRevoked_(s,a))})}}tryAppCheck(){this.connected_&&this.appCheckToken_&&this.sendRequest("appcheck",{token:this.appCheckToken_},e=>{let r=e.s,i=e.d||"error";r==="ok"?this.invalidAppCheckTokenCount_=0:this.onAppCheckRevoked_(r,i)})}unlisten(e,r){let i=e._path.toString(),o=e._queryIdentifier;this.log_("Unlisten called for "+i+" "+o),A(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(i,o)&&this.connected_&&this.sendUnlisten_(i,o,e._queryObject,r)}sendUnlisten_(e,r,i,o){this.log_("Unlisten on "+e+" for "+r);let s={p:e},a="n";o&&(s.q=i,s.t=o),this.sendRequest(a,s)}onDisconnectPut(e,r,i){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",e,r,i):this.onDisconnectRequestQueue_.push({pathString:e,action:"o",data:r,onComplete:i})}onDisconnectMerge(e,r,i){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",e,r,i):this.onDisconnectRequestQueue_.push({pathString:e,action:"om",data:r,onComplete:i})}onDisconnectCancel(e,r){this.initConnection_(),this.connected_?this.sendOnDisconnect_("oc",e,null,r):this.onDisconnectRequestQueue_.push({pathString:e,action:"oc",data:null,onComplete:r})}sendOnDisconnect_(e,r,i,o){let s={p:r,d:i};this.log_("onDisconnect "+e,s),this.sendRequest(e,s,a=>{o&&setTimeout(()=>{o(a.s,a.d)},Math.floor(0))})}put(e,r,i,o){this.putInternal("p",e,r,i,o)}merge(e,r,i,o){this.putInternal("m",e,r,i,o)}putInternal(e,r,i,o,s){this.initConnection_();let a={p:r,d:i};s!==void 0&&(a.h=s),this.outstandingPuts_.push({action:e,request:a,onComplete:o}),this.outstandingPutCount_++;let c=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(c):this.log_("Buffering put: "+r)}sendPut_(e){let r=this.outstandingPuts_[e].action,i=this.outstandingPuts_[e].request,o=this.outstandingPuts_[e].onComplete;this.outstandingPuts_[e].queued=this.connected_,this.sendRequest(r,i,s=>{this.log_(r+" response",s),delete this.outstandingPuts_[e],this.outstandingPutCount_--,this.outstandingPutCount_===0&&(this.outstandingPuts_=[]),o&&o(s.s,s.d)})}reportStats(e){if(this.connected_){let r={c:e};this.log_("reportStats",r),this.sendRequest("s",r,i=>{if(i.s!=="ok"){let s=i.d;this.log_("reportStats","Error sending stats: "+s)}})}}onDataMessage_(e){if("r"in e){this.log_("from server: "+nt(e));let r=e.r,i=this.requestCBHash_[r];i&&(delete this.requestCBHash_[r],i(e.b))}else{if("error"in e)throw"A server-side error has occurred: "+e.error;"a"in e&&this.onDataPush_(e.a,e.b)}}onDataPush_(e,r){this.log_("handleServerMessage",e,r),e==="d"?this.onDataUpdate_(r.p,r.d,!1,r.t):e==="m"?this.onDataUpdate_(r.p,r.d,!0,r.t):e==="c"?this.onListenRevoked_(r.p,r.q):e==="ac"?this.onAuthRevoked_(r.s,r.d):e==="apc"?this.onAppCheckRevoked_(r.s,r.d):e==="sd"?this.onSecurityDebugPacket_(r):Tw("Unrecognized action received from server: "+nt(e)+`
35
+ Are you using the latest client?`)}onReady_(e,r){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=new Date().getTime(),this.handleTimestamp_(e),this.lastSessionId=r,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)}scheduleConnect_(e){A(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout(()=>{this.establishConnectionTimer_=null,this.establishConnection_()},Math.floor(e))}initConnection_(){!this.realtime_&&this.firstConnection_&&this.scheduleConnect_(0)}onVisible_(e){e&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible. Reducing delay."),this.reconnectDelay_=Tc,this.realtime_||this.scheduleConnect_(0)),this.visible_=e}onOnline_(e){e?(this.log_("Browser went online."),this.reconnectDelay_=Tc,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline. Killing connection."),this.realtime_&&this.realtime_.close())}onRealtimeDisconnect_(){if(this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()){this.visible_?this.lastConnectionEstablishedTime_&&(new Date().getTime()-this.lastConnectionEstablishedTime_>fte&&(this.reconnectDelay_=Tc),this.lastConnectionEstablishedTime_=null):(this.log_("Window isn't visible. Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=new Date().getTime());let e=Math.max(0,new Date().getTime()-this.lastConnectionAttemptTime_),r=Math.max(0,this.reconnectDelay_-e);r=Math.random()*r,this.log_("Trying to reconnect in "+r+"ms"),this.scheduleConnect_(r),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,this.reconnectDelay_*dte)}this.onConnectStatus_(!1)}async establishConnection_(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=new Date().getTime(),this.lastConnectionEstablishedTime_=null;let e=this.onDataMessage_.bind(this),r=this.onReady_.bind(this),i=this.onRealtimeDisconnect_.bind(this),o=this.id+":"+t.nextConnectionId_++,s=this.lastSessionId,a=!1,c=null,u=function(){c?c.close():(a=!0,i())},l=function(f){A(c,"sendRequest call when we're not connected not allowed."),c.sendRequest(f)};this.realtime_={close:u,sendRequest:l};let d=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{let[f,p]=await Promise.all([this.authTokenProvider_.getToken(d),this.appCheckTokenProvider_.getToken(d)]);a?pt("getToken() completed but was canceled"):(pt("getToken() completed. Creating connection."),this.authToken_=f&&f.accessToken,this.appCheckToken_=p&&p.token,c=new Pw(o,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,r,i,m=>{Rt(m+" ("+this.repoInfo_.toString()+")"),this.interrupt(hte)},s))}catch(f){this.log_("Failed to get token: "+f),a||(this.repoInfo_.nodeAdmin&&Rt(f),u())}}}interrupt(e){pt("Interrupting connection for reason: "+e),this.interruptReasons_[e]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())}resume(e){pt("Resuming connection for reason: "+e),delete this.interruptReasons_[e],xp(this.interruptReasons_)&&(this.reconnectDelay_=Tc,this.realtime_||this.scheduleConnect_(0))}handleTimestamp_(e){let r=e-new Date().getTime();this.onServerInfoUpdate_({serverTimeOffset:r})}cancelSentTransactions_(){for(let e=0;e<this.outstandingPuts_.length;e++){let r=this.outstandingPuts_[e];r&&"h"in r.request&&r.queued&&(r.onComplete&&r.onComplete("disconnect"),delete this.outstandingPuts_[e],this.outstandingPutCount_--)}this.outstandingPutCount_===0&&(this.outstandingPuts_=[])}onListenRevoked_(e,r){let i;r?i=r.map(s=>wE(s)).join("$"):i="default";let o=this.removeListen_(e,i);o&&o.onComplete&&o.onComplete("permission_denied")}removeListen_(e,r){let i=new Pe(e).toString(),o;if(this.listens.has(i)){let s=this.listens.get(i);o=s.get(r),s.delete(r),s.size===0&&this.listens.delete(i)}else o=void 0;return o}onAuthRevoked_(e,r){pt("Auth token revoked: "+e+"/"+r),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),(e==="invalid_token"||e==="permission_denied")&&(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_>=$N&&(this.reconnectDelay_=FN,this.authTokenProvider_.notifyForInvalidToken()))}onAppCheckRevoked_(e,r){pt("App check token revoked: "+e+"/"+r),this.appCheckToken_=null,this.forceTokenRefresh_=!0,(e==="invalid_token"||e==="permission_denied")&&(this.invalidAppCheckTokenCount_++,this.invalidAppCheckTokenCount_>=$N&&this.appCheckTokenProvider_.notifyForInvalidToken())}onSecurityDebugPacket_(e){this.securityDebugCallback_?this.securityDebugCallback_(e):"msg"in e&&console.log("FIREBASE: "+e.msg.replace(`
36
36
  `,`
37
- FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(let e of this.listens.values())for(let r of e.values())this.sendListen_(r);for(let e=0;e<this.outstandingPuts_.length;e++)this.outstandingPuts_[e]&&this.sendPut_(e);for(;this.onDisconnectRequestQueue_.length;){let e=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(e.action,e.pathString,e.data,e.onComplete)}for(let e=0;e<this.outstandingGets_.length;e++)this.outstandingGets_[e]&&this.sendGet_(e)}sendConnectStats_(){let e={},r="js";Mn()&&(this.repoInfo_.nodeAdmin?r="admin_node":r="node"),e["sdk."+r+"."+SE.replace(/\./g,"-")]=1,Xb()?e["framework.cordova"]=1:XA()&&(e["framework.reactnative"]=1),this.reportStats(e)}shouldReconnect_(){let e=kp.getInstance().currentlyOnline();return xp(this.interruptReasons_)&&e}}t.nextPersistentConnectionId_=0,t.nextConnectionId_=0;return t})(),ve=class t{constructor(n,e){this.name=n,this.node=e}static Wrap(n,e){return new t(n,e)}};var zs=class{getCompare(){return this.compare.bind(this)}indexedValueChanged(n,e){let r=new ve(Gs,n),i=new ve(Gs,e);return this.compare(r,i)!==0}minPost(){return ve.MIN}};var Mp,Lp=class extends zs{static get __EMPTY_NODE(){return Mp}static set __EMPTY_NODE(n){Mp=n}compare(n,e){return to(n.name,e.name)}isDefinedOn(n){throw Vi("KeyIndex.isDefinedOn not expected to be called.")}indexedValueChanged(n,e){return!1}minPost(){return ve.MIN}maxPost(){return new ve(Xi,Mp)}makePost(n,e){return A(typeof n=="string","KeyIndex indexValue must always be a string."),new ve(n,Mp)}toString(){return".key"}},Vs=new Lp;var Hs=class{constructor(n,e,r,i,o=null){this.isReverse_=i,this.resultGenerator_=o,this.nodeStack_=[];let s=1;for(;!n.isEmpty();)if(n=n,s=e?r(n.key,e):1,i&&(s*=-1),s<0)this.isReverse_?n=n.left:n=n.right;else if(s===0){this.nodeStack_.push(n);break}else this.nodeStack_.push(n),this.isReverse_?n=n.right:n=n.left}getNext(){if(this.nodeStack_.length===0)return null;let n=this.nodeStack_.pop(),e;if(this.resultGenerator_?e=this.resultGenerator_(n.key,n.value):e={key:n.key,value:n.value},this.isReverse_)for(n=n.left;!n.isEmpty();)this.nodeStack_.push(n),n=n.right;else for(n=n.right;!n.isEmpty();)this.nodeStack_.push(n),n=n.left;return e}hasNext(){return this.nodeStack_.length>0}peek(){if(this.nodeStack_.length===0)return null;let n=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(n.key,n.value):{key:n.key,value:n.value}}},dn=(()=>{class t{constructor(e,r,i,o,s){this.key=e,this.value=r,this.color=i??t.RED,this.left=o??en.EMPTY_NODE,this.right=s??en.EMPTY_NODE}copy(e,r,i,o,s){return new t(e??this.key,r??this.value,i??this.color,o??this.left,s??this.right)}count(){return this.left.count()+1+this.right.count()}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||!!e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min_(){return this.left.isEmpty()?this:this.left.min_()}minKey(){return this.min_().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,r,i){let o=this,s=i(e,o.key);return s<0?o=o.copy(null,null,null,o.left.insert(e,r,i),null):s===0?o=o.copy(null,r,null,null,null):o=o.copy(null,null,null,null,o.right.insert(e,r,i)),o.fixUp_()}removeMin_(){if(this.left.isEmpty())return en.EMPTY_NODE;let e=this;return!e.left.isRed_()&&!e.left.left.isRed_()&&(e=e.moveRedLeft_()),e=e.copy(null,null,null,e.left.removeMin_(),null),e.fixUp_()}remove(e,r){let i,o;if(i=this,r(e,i.key)<0)!i.left.isEmpty()&&!i.left.isRed_()&&!i.left.left.isRed_()&&(i=i.moveRedLeft_()),i=i.copy(null,null,null,i.left.remove(e,r),null);else{if(i.left.isRed_()&&(i=i.rotateRight_()),!i.right.isEmpty()&&!i.right.isRed_()&&!i.right.left.isRed_()&&(i=i.moveRedRight_()),r(e,i.key)===0){if(i.right.isEmpty())return en.EMPTY_NODE;o=i.right.min_(),i=i.copy(o.key,o.value,null,null,i.right.removeMin_())}i=i.copy(null,null,null,null,i.right.remove(e,r))}return i.fixUp_()}isRed_(){return this.color}fixUp_(){let e=this;return e.right.isRed_()&&!e.left.isRed_()&&(e=e.rotateLeft_()),e.left.isRed_()&&e.left.left.isRed_()&&(e=e.rotateRight_()),e.left.isRed_()&&e.right.isRed_()&&(e=e.colorFlip_()),e}moveRedLeft_(){let e=this.colorFlip_();return e.right.left.isRed_()&&(e=e.copy(null,null,null,null,e.right.rotateRight_()),e=e.rotateLeft_(),e=e.colorFlip_()),e}moveRedRight_(){let e=this.colorFlip_();return e.left.left.isRed_()&&(e=e.rotateRight_(),e=e.colorFlip_()),e}rotateLeft_(){let e=this.copy(null,null,t.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight_(){let e=this.copy(null,null,t.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip_(){let e=this.left.copy(null,null,!this.left.color,null,null),r=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,r)}checkMaxDepth_(){let e=this.check_();return Math.pow(2,e)<=this.count()+1}check_(){if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");let e=this.left.check_();if(e!==this.right.check_())throw new Error("Black depths differ");return e+(this.isRed_()?0:1)}}return t.RED=!0,t.BLACK=!1,t})(),Lw=class{copy(n,e,r,i,o){return this}insert(n,e,r){return new dn(n,e,null)}remove(n,e){return this}count(){return 0}isEmpty(){return!0}inorderTraversal(n){return!1}reverseTraversal(n){return!1}minKey(){return null}maxKey(){return null}check_(){return 0}isRed_(){return!1}},en=class t{constructor(n,e=t.EMPTY_NODE){this.comparator_=n,this.root_=e}insert(n,e){return new t(this.comparator_,this.root_.insert(n,e,this.comparator_).copy(null,null,dn.BLACK,null,null))}remove(n){return new t(this.comparator_,this.root_.remove(n,this.comparator_).copy(null,null,dn.BLACK,null,null))}get(n){let e,r=this.root_;for(;!r.isEmpty();){if(e=this.comparator_(n,r.key),e===0)return r.value;e<0?r=r.left:e>0&&(r=r.right)}return null}getPredecessorKey(n){let e,r=this.root_,i=null;for(;!r.isEmpty();)if(e=this.comparator_(n,r.key),e===0){if(r.left.isEmpty())return i?i.key:null;for(r=r.left;!r.right.isEmpty();)r=r.right;return r.key}else e<0?r=r.left:e>0&&(i=r,r=r.right);throw new Error("Attempted to find predecessor key for a nonexistent key. What gives?")}isEmpty(){return this.root_.isEmpty()}count(){return this.root_.count()}minKey(){return this.root_.minKey()}maxKey(){return this.root_.maxKey()}inorderTraversal(n){return this.root_.inorderTraversal(n)}reverseTraversal(n){return this.root_.reverseTraversal(n)}getIterator(n){return new Hs(this.root_,null,this.comparator_,!1,n)}getIteratorFrom(n,e){return new Hs(this.root_,n,this.comparator_,!1,e)}getReverseIteratorFrom(n,e){return new Hs(this.root_,n,this.comparator_,!0,e)}getReverseIterator(n){return new Hs(this.root_,null,this.comparator_,!0,n)}};en.EMPTY_NODE=new Lw;function hte(t,n){return to(t.name,n.name)}function xE(t,n){return to(t,n)}var jw;function pte(t){jw=t}var DP=function(t){return typeof t=="number"?"number:"+_P(t):"string:"+t},OP=function(t){if(t.isLeafNode()){let n=t.val();A(typeof n=="string"||typeof n=="number"||typeof n=="object"&&ln(n,".sv"),"Priority must be a string or number.")}else A(t===jw||t.isEmpty(),"priority of unexpected type.");A(t===jw||t.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")};var qN,Ks=(()=>{class t{static set __childrenNodeConstructor(e){qN=e}static get __childrenNodeConstructor(){return qN}constructor(e,r=t.__childrenNodeConstructor.EMPTY_NODE){this.value_=e,this.priorityNode_=r,this.lazyHash_=null,A(this.value_!==void 0&&this.value_!==null,"LeafNode shouldn't be created with null/undefined value."),OP(this.priorityNode_)}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new t(this.value_,e)}getImmediateChild(e){return e===".priority"?this.priorityNode_:t.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return ye(e)?this:he(e)===".priority"?this.priorityNode_:t.__childrenNodeConstructor.EMPTY_NODE}hasChild(){return!1}getPredecessorChildName(e,r){return null}updateImmediateChild(e,r){return e===".priority"?this.updatePriority(r):r.isEmpty()&&e!==".priority"?this:t.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,r).updatePriority(this.priorityNode_)}updateChild(e,r){let i=he(e);return i===null?r:r.isEmpty()&&i!==".priority"?this:(A(i!==".priority"||ni(e)===1,".priority must be the last token in a path"),this.updateImmediateChild(i,t.__childrenNodeConstructor.EMPTY_NODE.updateChild(Fe(e),r)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(e,r){return!1}val(e){return e&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()}hash(){if(this.lazyHash_===null){let e="";this.priorityNode_.isEmpty()||(e+="priority:"+DP(this.priorityNode_.val())+":");let r=typeof this.value_;e+=r+":",r==="number"?e+=_P(this.value_):e+=this.value_,this.lazyHash_=yP(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===t.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof t.__childrenNodeConstructor?-1:(A(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){let r=typeof e.value_,i=typeof this.value_,o=t.VALUE_TYPE_ORDER.indexOf(r),s=t.VALUE_TYPE_ORDER.indexOf(i);return A(o>=0,"Unknown leaf type: "+r),A(s>=0,"Unknown leaf type: "+i),o===s?i==="object"?0:this.value_<e.value_?-1:this.value_===e.value_?0:1:s-o}withIndex(){return this}isIndexed(){return!0}equals(e){if(e===this)return!0;if(e.isLeafNode()){let r=e;return this.value_===r.value_&&this.priorityNode_.equals(r.priorityNode_)}else return!1}}t.VALUE_TYPE_ORDER=["object","boolean","number","string"];return t})(),MP,AP;function mte(t){MP=t}function gte(t){AP=t}var Fw=class extends zs{compare(n,e){let r=n.node.getPriority(),i=e.node.getPriority(),o=r.compareTo(i);return o===0?to(n.name,e.name):o}isDefinedOn(n){return!n.getPriority().isEmpty()}indexedValueChanged(n,e){return!n.getPriority().equals(e.getPriority())}minPost(){return ve.MIN}maxPost(){return new ve(Xi,new Ks("[PRIORITY-POST]",AP))}makePost(n,e){let r=MP(n);return new ve(e,new Ks("[PRIORITY-POST]",r))}toString(){return".priority"}},Ye=new Fw;var yte=Math.log(2),$w=class{constructor(n){let e=o=>parseInt(Math.log(o)/yte,10),r=o=>parseInt(Array(o+1).join("1"),2);this.count=e(n+1),this.current_=this.count-1;let i=r(this.count);this.bits_=n+1&i}nextBitIsOne(){let n=!(this.bits_&1<<this.current_);return this.current_--,n}},jp=function(t,n,e,r){t.sort(n);let i=function(c,u){let l=u-c,d,f;if(l===0)return null;if(l===1)return d=t[c],f=e?e(d):d,new dn(f,d.node,dn.BLACK,null,null);{let p=parseInt(l/2,10)+c,m=i(c,p),y=i(p+1,u);return d=t[p],f=e?e(d):d,new dn(f,d.node,dn.BLACK,m,y)}},o=function(c){let u=null,l=null,d=t.length,f=function(m,y){let b=d-m,E=d;d-=m;let D=i(b+1,E),T=t[b],K=e?e(T):T;p(new dn(K,T.node,y,null,D))},p=function(m){u?(u.left=m,u=m):(l=m,u=m)};for(let m=0;m<c.count;++m){let y=c.nextBitIsOne(),b=Math.pow(2,c.count-(m+1));y?f(b,dn.BLACK):(f(b,dn.BLACK),f(b,dn.RED))}return l},s=new $w(t.length),a=o(s);return new en(r||n,a)};var vw,Bs={},Ys=class t{static get Default(){return A(Bs&&Ye,"ChildrenNode.ts has not been loaded"),vw=vw||new t({".priority":Bs},{".priority":Ye}),vw}constructor(n,e){this.indexes_=n,this.indexSet_=e}get(n){let e=Wi(this.indexes_,n);if(!e)throw new Error("No index defined for "+n);return e instanceof en?e:null}hasIndex(n){return ln(this.indexSet_,n.toString())}addIndex(n,e){A(n!==Vs,"KeyIndex always exists and isn't meant to be added to the IndexMap.");let r=[],i=!1,o=e.getIterator(ve.Wrap),s=o.getNext();for(;s;)i=i||n.isDefinedOn(s.node),r.push(s),s=o.getNext();let a;i?a=jp(r,n.getCompare()):a=Bs;let c=n.toString(),u={...this.indexSet_};u[c]=n;let l={...this.indexes_};return l[c]=a,new t(l,u)}addToIndexes(n,e){let r=vc(this.indexes_,(i,o)=>{let s=Wi(this.indexSet_,o);if(A(s,"Missing index implementation for "+o),i===Bs)if(s.isDefinedOn(n.node)){let a=[],c=e.getIterator(ve.Wrap),u=c.getNext();for(;u;)u.name!==n.name&&a.push(u),u=c.getNext();return a.push(n),jp(a,s.getCompare())}else return Bs;else{let a=e.get(n.name),c=i;return a&&(c=c.remove(new ve(n.name,a))),c.insert(n,n.node)}});return new t(r,this.indexSet_)}removeFromIndexes(n,e){let r=vc(this.indexes_,i=>{if(i===Bs)return i;{let o=e.get(n.name);return o?i.remove(new ve(n.name,o)):i}});return new t(r,this.indexSet_)}};var xc,ce=(()=>{class t{static get EMPTY_NODE(){return xc||(xc=new t(new en(xE),null,Ys.Default))}constructor(e,r,i){this.children_=e,this.priorityNode_=r,this.indexMap_=i,this.lazyHash_=null,this.priorityNode_&&OP(this.priorityNode_),this.children_.isEmpty()&&A(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}isLeafNode(){return!1}getPriority(){return this.priorityNode_||xc}updatePriority(e){return this.children_.isEmpty()?this:new t(this.children_,e,this.indexMap_)}getImmediateChild(e){if(e===".priority")return this.getPriority();{let r=this.children_.get(e);return r===null?xc:r}}getChild(e){let r=he(e);return r===null?this:this.getImmediateChild(r).getChild(Fe(e))}hasChild(e){return this.children_.get(e)!==null}updateImmediateChild(e,r){if(A(r,"We should always be passing snapshot nodes"),e===".priority")return this.updatePriority(r);{let i=new ve(e,r),o,s;r.isEmpty()?(o=this.children_.remove(e),s=this.indexMap_.removeFromIndexes(i,this.children_)):(o=this.children_.insert(e,r),s=this.indexMap_.addToIndexes(i,this.children_));let a=o.isEmpty()?xc:this.priorityNode_;return new t(o,a,s)}}updateChild(e,r){let i=he(e);if(i===null)return r;{A(he(e)!==".priority"||ni(e)===1,".priority must be the last token in a path");let o=this.getImmediateChild(i).updateChild(Fe(e),r);return this.updateImmediateChild(i,o)}}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(e){if(this.isEmpty())return null;let r={},i=0,o=0,s=!0;if(this.forEachChild(Ye,(a,c)=>{r[a]=c.val(e),i++,s&&t.INTEGER_REGEXP_.test(a)?o=Math.max(o,Number(a)):s=!1}),!e&&s&&o<2*i){let a=[];for(let c in r)a[c]=r[c];return a}else return e&&!this.getPriority().isEmpty()&&(r[".priority"]=this.getPriority().val()),r}hash(){if(this.lazyHash_===null){let e="";this.getPriority().isEmpty()||(e+="priority:"+DP(this.getPriority().val())+":"),this.forEachChild(Ye,(r,i)=>{let o=i.hash();o!==""&&(e+=":"+r+":"+o)}),this.lazyHash_=e===""?"":yP(e)}return this.lazyHash_}getPredecessorChildName(e,r,i){let o=this.resolveIndex_(i);if(o){let s=o.getPredecessorKey(new ve(e,r));return s?s.name:null}else return this.children_.getPredecessorKey(e)}getFirstChildName(e){let r=this.resolveIndex_(e);if(r){let i=r.minKey();return i&&i.name}else return this.children_.minKey()}getFirstChild(e){let r=this.getFirstChildName(e);return r?new ve(r,this.children_.get(r)):null}getLastChildName(e){let r=this.resolveIndex_(e);if(r){let i=r.maxKey();return i&&i.name}else return this.children_.maxKey()}getLastChild(e){let r=this.getLastChildName(e);return r?new ve(r,this.children_.get(r)):null}forEachChild(e,r){let i=this.resolveIndex_(e);return i?i.inorderTraversal(o=>r(o.name,o.node)):this.children_.inorderTraversal(r)}getIterator(e){return this.getIteratorFrom(e.minPost(),e)}getIteratorFrom(e,r){let i=this.resolveIndex_(r);if(i)return i.getIteratorFrom(e,o=>o);{let o=this.children_.getIteratorFrom(e.name,ve.Wrap),s=o.peek();for(;s!=null&&r.compare(s,e)<0;)o.getNext(),s=o.peek();return o}}getReverseIterator(e){return this.getReverseIteratorFrom(e.maxPost(),e)}getReverseIteratorFrom(e,r){let i=this.resolveIndex_(r);if(i)return i.getReverseIteratorFrom(e,o=>o);{let o=this.children_.getReverseIteratorFrom(e.name,ve.Wrap),s=o.peek();for(;s!=null&&r.compare(s,e)>0;)o.getNext(),s=o.peek();return o}}compareTo(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===Uc?-1:0}withIndex(e){if(e===Vs||this.indexMap_.hasIndex(e))return this;{let r=this.indexMap_.addIndex(e,this.children_);return new t(this.children_,this.priorityNode_,r)}}isIndexed(e){return e===Vs||this.indexMap_.hasIndex(e)}equals(e){if(e===this)return!0;if(e.isLeafNode())return!1;{let r=e;if(this.getPriority().equals(r.getPriority()))if(this.children_.count()===r.children_.count()){let i=this.getIterator(Ye),o=r.getIterator(Ye),s=i.getNext(),a=o.getNext();for(;s&&a;){if(s.name!==a.name||!s.node.equals(a.node))return!1;s=i.getNext(),a=o.getNext()}return s===null&&a===null}else return!1;else return!1}}resolveIndex_(e){return e===Vs?null:this.indexMap_.get(e.toString())}}return t.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/,t})(),qw=class extends ce{constructor(){super(new en(xE),ce.EMPTY_NODE,Ys.Default)}compareTo(n){return n===this?0:1}equals(n){return n===this}getPriority(){return this}getImmediateChild(n){return ce.EMPTY_NODE}isEmpty(){return!1}},Uc=new qw;Object.defineProperties(ve,{MIN:{value:new ve(Gs,ce.EMPTY_NODE)},MAX:{value:new ve(Xi,Uc)}});Lp.__EMPTY_NODE=ce.EMPTY_NODE;Ks.__childrenNodeConstructor=ce;pte(Uc);gte(Uc);var vte=!0;function Qe(t,n=null){if(t===null)return ce.EMPTY_NODE;if(typeof t=="object"&&".priority"in t&&(n=t[".priority"]),A(n===null||typeof n=="string"||typeof n=="number"||typeof n=="object"&&".sv"in n,"Invalid priority type found: "+typeof n),typeof t=="object"&&".value"in t&&t[".value"]!==null&&(t=t[".value"]),typeof t!="object"||".sv"in t){let e=t;return new Ks(e,Qe(n))}if(!(t instanceof Array)&&vte){let e=[],r=!1;if(bt(t,(s,a)=>{if(s.substring(0,1)!=="."){let c=Qe(a);c.isEmpty()||(r=r||!c.getPriority().isEmpty(),e.push(new ve(s,c)))}}),e.length===0)return ce.EMPTY_NODE;let o=jp(e,hte,s=>s.name,xE);if(r){let s=jp(e,Ye.getCompare());return new ce(o,Qe(n),new Ys({".priority":s},{".priority":Ye}))}else return new ce(o,Qe(n),Ys.Default)}else{let e=ce.EMPTY_NODE;return bt(t,(r,i)=>{if(ln(t,r)&&r.substring(0,1)!=="."){let o=Qe(i);(o.isLeafNode()||!o.isEmpty())&&(e=e.updateImmediateChild(r,o))}}),e.updatePriority(Qe(n))}}mte(Qe);var Bw=class extends zs{constructor(n){super(),this.indexPath_=n,A(!ye(n)&&he(n)!==".priority","Can't create PathIndex with empty path or .priority key")}extractChild(n){return n.getChild(this.indexPath_)}isDefinedOn(n){return!n.getChild(this.indexPath_).isEmpty()}compare(n,e){let r=this.extractChild(n.node),i=this.extractChild(e.node),o=r.compareTo(i);return o===0?to(n.name,e.name):o}makePost(n,e){let r=Qe(n),i=ce.EMPTY_NODE.updateChild(this.indexPath_,r);return new ve(e,i)}maxPost(){let n=ce.EMPTY_NODE.updateChild(this.indexPath_,Uc);return new ve(Xi,n)}toString(){return kc(this.indexPath_,0).join("/")}};var Hw=class extends zs{compare(n,e){let r=n.node.compareTo(e.node);return r===0?to(n.name,e.name):r}isDefinedOn(n){return!0}indexedValueChanged(n,e){return!n.equals(e)}minPost(){return ve.MIN}maxPost(){return ve.MAX}makePost(n,e){let r=Qe(n);return new ve(e,r)}toString(){return".value"}},_te=new Hw;function NP(t){return{type:"value",snapshotNode:t}}function Zs(t,n){return{type:"child_added",snapshotNode:n,childName:t}}function Lc(t,n){return{type:"child_removed",snapshotNode:n,childName:t}}function jc(t,n,e){return{type:"child_changed",snapshotNode:n,childName:t,oldSnap:e}}function bte(t,n){return{type:"child_moved",snapshotNode:n,childName:t}}var Fc=class{constructor(n){this.index_=n}updateChild(n,e,r,i,o,s){A(n.isIndexed(this.index_),"A node must be indexed if only a child is updated");let a=n.getImmediateChild(e);return a.getChild(i).equals(r.getChild(i))&&a.isEmpty()===r.isEmpty()||(s!=null&&(r.isEmpty()?n.hasChild(e)?s.trackChildChange(Lc(e,a)):A(n.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):a.isEmpty()?s.trackChildChange(Zs(e,r)):s.trackChildChange(jc(e,r,a))),n.isLeafNode()&&r.isEmpty())?n:n.updateImmediateChild(e,r).withIndex(this.index_)}updateFullNode(n,e,r){return r!=null&&(n.isLeafNode()||n.forEachChild(Ye,(i,o)=>{e.hasChild(i)||r.trackChildChange(Lc(i,o))}),e.isLeafNode()||e.forEachChild(Ye,(i,o)=>{if(n.hasChild(i)){let s=n.getImmediateChild(i);s.equals(o)||r.trackChildChange(jc(i,o,s))}else r.trackChildChange(Zs(i,o))})),e.withIndex(this.index_)}updatePriority(n,e){return n.isEmpty()?ce.EMPTY_NODE:n.updatePriority(e)}filtersNodes(){return!1}getIndexedFilter(){return this}getIndex(){return this.index_}};var Fp=class t{constructor(n){this.indexedFilter_=new Fc(n.getIndex()),this.index_=n.getIndex(),this.startPost_=t.getStartPost_(n),this.endPost_=t.getEndPost_(n),this.startIsInclusive_=!n.startAfterSet_,this.endIsInclusive_=!n.endBeforeSet_}getStartPost(){return this.startPost_}getEndPost(){return this.endPost_}matches(n){let e=this.startIsInclusive_?this.index_.compare(this.getStartPost(),n)<=0:this.index_.compare(this.getStartPost(),n)<0,r=this.endIsInclusive_?this.index_.compare(n,this.getEndPost())<=0:this.index_.compare(n,this.getEndPost())<0;return e&&r}updateChild(n,e,r,i,o,s){return this.matches(new ve(e,r))||(r=ce.EMPTY_NODE),this.indexedFilter_.updateChild(n,e,r,i,o,s)}updateFullNode(n,e,r){e.isLeafNode()&&(e=ce.EMPTY_NODE);let i=e.withIndex(this.index_);i=i.updatePriority(ce.EMPTY_NODE);let o=this;return e.forEachChild(Ye,(s,a)=>{o.matches(new ve(s,a))||(i=i.updateImmediateChild(s,ce.EMPTY_NODE))}),this.indexedFilter_.updateFullNode(n,i,r)}updatePriority(n,e){return n}filtersNodes(){return!0}getIndexedFilter(){return this.indexedFilter_}getIndex(){return this.index_}static getStartPost_(n){if(n.hasStart()){let e=n.getIndexStartName();return n.getIndex().makePost(n.getIndexStartValue(),e)}else return n.getIndex().minPost()}static getEndPost_(n){if(n.hasEnd()){let e=n.getIndexEndName();return n.getIndex().makePost(n.getIndexEndValue(),e)}else return n.getIndex().maxPost()}};var Uw=class{constructor(n){this.withinDirectionalStart=e=>this.reverse_?this.withinEndPost(e):this.withinStartPost(e),this.withinDirectionalEnd=e=>this.reverse_?this.withinStartPost(e):this.withinEndPost(e),this.withinStartPost=e=>{let r=this.index_.compare(this.rangedFilter_.getStartPost(),e);return this.startIsInclusive_?r<=0:r<0},this.withinEndPost=e=>{let r=this.index_.compare(e,this.rangedFilter_.getEndPost());return this.endIsInclusive_?r<=0:r<0},this.rangedFilter_=new Fp(n),this.index_=n.getIndex(),this.limit_=n.getLimit(),this.reverse_=!n.isViewFromLeft(),this.startIsInclusive_=!n.startAfterSet_,this.endIsInclusive_=!n.endBeforeSet_}updateChild(n,e,r,i,o,s){return this.rangedFilter_.matches(new ve(e,r))||(r=ce.EMPTY_NODE),n.getImmediateChild(e).equals(r)?n:n.numChildren()<this.limit_?this.rangedFilter_.getIndexedFilter().updateChild(n,e,r,i,o,s):this.fullLimitUpdateChild_(n,e,r,o,s)}updateFullNode(n,e,r){let i;if(e.isLeafNode()||e.isEmpty())i=ce.EMPTY_NODE.withIndex(this.index_);else if(this.limit_*2<e.numChildren()&&e.isIndexed(this.index_)){i=ce.EMPTY_NODE.withIndex(this.index_);let o;this.reverse_?o=e.getReverseIteratorFrom(this.rangedFilter_.getEndPost(),this.index_):o=e.getIteratorFrom(this.rangedFilter_.getStartPost(),this.index_);let s=0;for(;o.hasNext()&&s<this.limit_;){let a=o.getNext();if(this.withinDirectionalStart(a))if(this.withinDirectionalEnd(a))i=i.updateImmediateChild(a.name,a.node),s++;else break;else continue}}else{i=e.withIndex(this.index_),i=i.updatePriority(ce.EMPTY_NODE);let o;this.reverse_?o=i.getReverseIterator(this.index_):o=i.getIterator(this.index_);let s=0;for(;o.hasNext();){let a=o.getNext();s<this.limit_&&this.withinDirectionalStart(a)&&this.withinDirectionalEnd(a)?s++:i=i.updateImmediateChild(a.name,ce.EMPTY_NODE)}}return this.rangedFilter_.getIndexedFilter().updateFullNode(n,i,r)}updatePriority(n,e){return n}filtersNodes(){return!0}getIndexedFilter(){return this.rangedFilter_.getIndexedFilter()}getIndex(){return this.index_}fullLimitUpdateChild_(n,e,r,i,o){let s;if(this.reverse_){let d=this.index_.getCompare();s=(f,p)=>d(p,f)}else s=this.index_.getCompare();let a=n;A(a.numChildren()===this.limit_,"");let c=new ve(e,r),u=this.reverse_?a.getFirstChild(this.index_):a.getLastChild(this.index_),l=this.rangedFilter_.matches(c);if(a.hasChild(e)){let d=a.getImmediateChild(e),f=i.getChildAfterChild(this.index_,u,this.reverse_);for(;f!=null&&(f.name===e||a.hasChild(f.name));)f=i.getChildAfterChild(this.index_,f,this.reverse_);let p=f==null?1:s(f,c);if(l&&!r.isEmpty()&&p>=0)return o?.trackChildChange(jc(e,r,d)),a.updateImmediateChild(e,r);{o?.trackChildChange(Lc(e,d));let y=a.updateImmediateChild(e,ce.EMPTY_NODE);return f!=null&&this.rangedFilter_.matches(f)?(o?.trackChildChange(Zs(f.name,f.node)),y.updateImmediateChild(f.name,f.node)):y}}else return r.isEmpty()?n:l&&s(u,c)>=0?(o!=null&&(o.trackChildChange(Lc(u.name,u.node)),o.trackChildChange(Zs(e,r))),a.updateImmediateChild(e,r).updateImmediateChild(u.name,ce.EMPTY_NODE)):n}};var Vw=class t{constructor(){this.limitSet_=!1,this.startSet_=!1,this.startNameSet_=!1,this.startAfterSet_=!1,this.endSet_=!1,this.endNameSet_=!1,this.endBeforeSet_=!1,this.limit_=0,this.viewFrom_="",this.indexStartValue_=null,this.indexStartName_="",this.indexEndValue_=null,this.indexEndName_="",this.index_=Ye}hasStart(){return this.startSet_}isViewFromLeft(){return this.viewFrom_===""?this.startSet_:this.viewFrom_==="l"}getIndexStartValue(){return A(this.startSet_,"Only valid if start has been set"),this.indexStartValue_}getIndexStartName(){return A(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:Gs}hasEnd(){return this.endSet_}getIndexEndValue(){return A(this.endSet_,"Only valid if end has been set"),this.indexEndValue_}getIndexEndName(){return A(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:Xi}hasLimit(){return this.limitSet_}hasAnchoredLimit(){return this.limitSet_&&this.viewFrom_!==""}getLimit(){return A(this.limitSet_,"Only valid if limit has been set"),this.limit_}getIndex(){return this.index_}loadsAllData(){return!(this.startSet_||this.endSet_||this.limitSet_)}isDefault(){return this.loadsAllData()&&this.index_===Ye}copy(){let n=new t;return n.limitSet_=this.limitSet_,n.limit_=this.limit_,n.startSet_=this.startSet_,n.startAfterSet_=this.startAfterSet_,n.indexStartValue_=this.indexStartValue_,n.startNameSet_=this.startNameSet_,n.indexStartName_=this.indexStartName_,n.endSet_=this.endSet_,n.endBeforeSet_=this.endBeforeSet_,n.indexEndValue_=this.indexEndValue_,n.endNameSet_=this.endNameSet_,n.indexEndName_=this.indexEndName_,n.index_=this.index_,n.viewFrom_=this.viewFrom_,n}};function wte(t){return t.loadsAllData()?new Fc(t.getIndex()):t.hasLimit()?new Uw(t):new Fp(t)}function BN(t){let n={};if(t.isDefault())return n;let e;if(t.index_===Ye?e="$priority":t.index_===_te?e="$value":t.index_===Vs?e="$key":(A(t.index_ instanceof Bw,"Unrecognized index type!"),e=t.index_.toString()),n.orderBy=nt(e),t.startSet_){let r=t.startAfterSet_?"startAfter":"startAt";n[r]=nt(t.indexStartValue_),t.startNameSet_&&(n[r]+=","+nt(t.indexStartName_))}if(t.endSet_){let r=t.endBeforeSet_?"endBefore":"endAt";n[r]=nt(t.indexEndValue_),t.endNameSet_&&(n[r]+=","+nt(t.indexEndName_))}return t.limitSet_&&(t.isViewFromLeft()?n.limitToFirst=t.limit_:n.limitToLast=t.limit_),n}function HN(t){let n={};if(t.startSet_&&(n.sp=t.indexStartValue_,t.startNameSet_&&(n.sn=t.indexStartName_),n.sin=!t.startAfterSet_),t.endSet_&&(n.ep=t.indexEndValue_,t.endNameSet_&&(n.en=t.indexEndName_),n.ein=!t.endBeforeSet_),t.limitSet_){n.l=t.limit_;let e=t.viewFrom_;e===""&&(t.isViewFromLeft()?e="l":e="r"),n.vf=e}return t.index_!==Ye&&(n.i=t.index_.toString()),n}var Ww=class t extends Pp{reportStats(n){throw new Error("Method not implemented.")}static getListenId_(n,e){return e!==void 0?"tag$"+e:(A(n._queryParams.isDefault(),"should have a tag if it's not a default query."),n._path.toString())}constructor(n,e,r,i){super(),this.repoInfo_=n,this.onDataUpdate_=e,this.authTokenProvider_=r,this.appCheckTokenProvider_=i,this.log_=Hc("p:rest:"),this.listens_={}}listen(n,e,r,i){let o=n._path.toString();this.log_("Listen called for "+o+" "+n._queryIdentifier);let s=t.getListenId_(n,r),a={};this.listens_[s]=a;let c=BN(n._queryParams);this.restRequest_(o+".json",c,(u,l)=>{let d=l;if(u===404&&(d=null,u=null),u===null&&this.onDataUpdate_(o,d,!1,r),Wi(this.listens_,s)===a){let f;u?u===401?f="permission_denied":f="rest_error:"+u:f="ok",i(f,null)}})}unlisten(n,e){let r=t.getListenId_(n,e);delete this.listens_[r]}get(n){let e=BN(n._queryParams),r=n._path.toString(),i=new Wt;return this.restRequest_(r+".json",e,(o,s)=>{let a=s;o===404&&(a=null,o=null),o===null?(this.onDataUpdate_(r,a,!1,null),i.resolve(a)):i.reject(new Error(a))}),i.promise}refreshAuthToken(n){}restRequest_(n,e={},r){return e.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then(([i,o])=>{i&&i.accessToken&&(e.auth=i.accessToken),o&&o.token&&(e.ac=o.token);let s=(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host+n+"?ns="+this.repoInfo_.namespace+oN(e);this.log_("Sending REST request for "+s);let a=new XMLHttpRequest;a.onreadystatechange=()=>{if(r&&a.readyState===4){this.log_("REST Response for "+s+" received. status:",a.status,"response:",a.responseText);let c=null;if(a.status>=200&&a.status<300){try{c=Fs(a.responseText)}catch{Rt("Failed to parse JSON response for "+s+": "+a.responseText)}r(null,c)}else a.status!==401&&a.status!==404&&Rt("Got unsuccessful REST response for "+s+" Status: "+a.status),r(a.status);r=null}},a.open("GET",s,!0),a.send()})}};var Gw=class{constructor(){this.rootNode_=ce.EMPTY_NODE}getNode(n){return this.rootNode_.getChild(n)}updateSnapshot(n,e){this.rootNode_=this.rootNode_.updateChild(n,e)}};function $p(){return{value:null,children:new Map}}function na(t,n,e){if(ye(n))t.value=e,t.children.clear();else if(t.value!==null)t.value=t.value.updateChild(n,e);else{let r=he(n);t.children.has(r)||t.children.set(r,$p());let i=t.children.get(r);n=Fe(n),na(i,n,e)}}function zw(t,n){if(ye(n))return t.value=null,t.children.clear(),!0;if(t.value!==null){if(t.value.isLeafNode())return!1;{let e=t.value;return t.value=null,e.forEachChild(Ye,(r,i)=>{na(t,new Pe(r),i)}),zw(t,n)}}else if(t.children.size>0){let e=he(n);return n=Fe(n),t.children.has(e)&&zw(t.children.get(e),n)&&t.children.delete(e),t.children.size===0}else return!0}function Kw(t,n,e){t.value!==null?e(n,t.value):Ete(t,(r,i)=>{let o=new Pe(n.toString()+"/"+r);Kw(i,o,e)})}function Ete(t,n){t.children.forEach((e,r)=>{n(r,e)})}var Yw=class{constructor(n){this.collection_=n,this.last_=null}get(){let n=this.collection_.get(),e={...n};return this.last_&&bt(this.last_,(r,i)=>{e[r]=e[r]-i}),this.last_=n,e}};var UN=10*1e3,Ste=30*1e3,Cte=300*1e3,Zw=class{constructor(n,e){this.server_=e,this.statsToReport_={},this.statsListener_=new Yw(n);let r=UN+(Ste-UN)*Math.random();Oc(this.reportStats_.bind(this),Math.floor(r))}reportStats_(){let n=this.statsListener_.get(),e={},r=!1;bt(n,(i,o)=>{o>0&&ln(this.statsToReport_,i)&&(e[i]=o,r=!0)}),r&&this.server_.reportStats(e),Oc(this.reportStats_.bind(this),Math.floor(Math.random()*2*Cte))}};var Nn=(function(t){return t[t.OVERWRITE=0]="OVERWRITE",t[t.MERGE=1]="MERGE",t[t.ACK_USER_WRITE=2]="ACK_USER_WRITE",t[t.LISTEN_COMPLETE=3]="LISTEN_COMPLETE",t})(Nn||{});function PP(){return{fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}function DE(){return{fromUser:!1,fromServer:!0,queryId:null,tagged:!1}}function OE(t){return{fromUser:!1,fromServer:!0,queryId:t,tagged:!0}}var Qw=class t{constructor(n,e,r){this.path=n,this.affectedTree=e,this.revert=r,this.type=Nn.ACK_USER_WRITE,this.source=PP()}operationForChild(n){if(ye(this.path)){if(this.affectedTree.value!=null)return A(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;{let e=this.affectedTree.subtree(new Pe(n));return new t(Ne(),e,this.revert)}}else return A(he(this.path)===n,"operationForChild called for unrelated child."),new t(Fe(this.path),this.affectedTree,this.revert)}};var qp=class t{constructor(n,e){this.source=n,this.path=e,this.type=Nn.LISTEN_COMPLETE}operationForChild(n){return ye(this.path)?new t(this.source,Ne()):new t(this.source,Fe(this.path))}};var Qs=class t{constructor(n,e,r){this.source=n,this.path=e,this.snap=r,this.type=Nn.OVERWRITE}operationForChild(n){return ye(this.path)?new t(this.source,Ne(),this.snap.getImmediateChild(n)):new t(this.source,Fe(this.path),this.snap)}};var Bp=class t{constructor(n,e,r){this.source=n,this.path=e,this.children=r,this.type=Nn.MERGE}operationForChild(n){if(ye(this.path)){let e=this.children.subtree(new Pe(n));return e.isEmpty()?null:e.value?new Qs(this.source,Ne(),e.value):new t(this.source,Ne(),e)}else return A(he(this.path)===n,"Can't get a merge for a child not on the path of the operation"),new t(this.source,Fe(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}};var rr=class{constructor(n,e,r){this.node_=n,this.fullyInitialized_=e,this.filtered_=r}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(n){if(ye(n))return this.isFullyInitialized()&&!this.filtered_;let e=he(n);return this.isCompleteForChild(e)}isCompleteForChild(n){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(n)}getNode(){return this.node_}};var Jw=class{constructor(n){this.query_=n,this.index_=this.query_._queryParams.getIndex()}};function Ite(t,n,e,r){let i=[],o=[];return n.forEach(s=>{s.type==="child_changed"&&t.index_.indexedValueChanged(s.oldSnap,s.snapshotNode)&&o.push(bte(s.childName,s.snapshotNode))}),Dc(t,i,"child_removed",n,r,e),Dc(t,i,"child_added",n,r,e),Dc(t,i,"child_moved",o,r,e),Dc(t,i,"child_changed",n,r,e),Dc(t,i,"value",n,r,e),i}function Dc(t,n,e,r,i,o){let s=r.filter(a=>a.type===e);s.sort((a,c)=>xte(t,a,c)),s.forEach(a=>{let c=Tte(t,a,o);i.forEach(u=>{u.respondsTo(a.type)&&n.push(u.createEvent(c,t.query_))})})}function Tte(t,n,e){return n.type==="value"||n.type==="child_removed"||(n.prevName=e.getPredecessorChildName(n.childName,n.snapshotNode,t.index_)),n}function xte(t,n,e){if(n.childName==null||e.childName==null)throw Vi("Should only compare child_ events.");let r=new ve(n.childName,n.snapshotNode),i=new ve(e.childName,e.snapshotNode);return t.index_.compare(r,i)}function em(t,n){return{eventCache:t,serverCache:n}}function Ac(t,n,e,r){return em(new rr(n,e,r),t.serverCache)}function RP(t,n,e,r){return em(t.eventCache,new rr(n,e,r))}function Xw(t){return t.eventCache.isFullyInitialized()?t.eventCache.getNode():null}function eo(t){return t.serverCache.isFullyInitialized()?t.serverCache.getNode():null}var _w,Dte=()=>(_w||(_w=new en(Tee)),_w),kt=class t{static fromObject(n){let e=new t(null);return bt(n,(r,i)=>{e=e.set(new Pe(r),i)}),e}constructor(n,e=Dte()){this.value=n,this.children=e}isEmpty(){return this.value===null&&this.children.isEmpty()}findRootMostMatchingPathAndValue(n,e){if(this.value!=null&&e(this.value))return{path:Ne(),value:this.value};if(ye(n))return null;{let r=he(n),i=this.children.get(r);if(i!==null){let o=i.findRootMostMatchingPathAndValue(Fe(n),e);return o!=null?{path:Ze(new Pe(r),o.path),value:o.value}:null}else return null}}findRootMostValueAndPath(n){return this.findRootMostMatchingPathAndValue(n,()=>!0)}subtree(n){if(ye(n))return this;{let e=he(n),r=this.children.get(e);return r!==null?r.subtree(Fe(n)):new t(null)}}set(n,e){if(ye(n))return new t(e,this.children);{let r=he(n),o=(this.children.get(r)||new t(null)).set(Fe(n),e),s=this.children.insert(r,o);return new t(this.value,s)}}remove(n){if(ye(n))return this.children.isEmpty()?new t(null):new t(null,this.children);{let e=he(n),r=this.children.get(e);if(r){let i=r.remove(Fe(n)),o;return i.isEmpty()?o=this.children.remove(e):o=this.children.insert(e,i),this.value===null&&o.isEmpty()?new t(null):new t(this.value,o)}else return this}}get(n){if(ye(n))return this.value;{let e=he(n),r=this.children.get(e);return r?r.get(Fe(n)):null}}setTree(n,e){if(ye(n))return e;{let r=he(n),o=(this.children.get(r)||new t(null)).setTree(Fe(n),e),s;return o.isEmpty()?s=this.children.remove(r):s=this.children.insert(r,o),new t(this.value,s)}}fold(n){return this.fold_(Ne(),n)}fold_(n,e){let r={};return this.children.inorderTraversal((i,o)=>{r[i]=o.fold_(Ze(n,i),e)}),e(n,this.value,r)}findOnPath(n,e){return this.findOnPath_(n,Ne(),e)}findOnPath_(n,e,r){let i=this.value?r(e,this.value):!1;if(i)return i;if(ye(n))return null;{let o=he(n),s=this.children.get(o);return s?s.findOnPath_(Fe(n),Ze(e,o),r):null}}foreachOnPath(n,e){return this.foreachOnPath_(n,Ne(),e)}foreachOnPath_(n,e,r){if(ye(n))return this;{this.value&&r(e,this.value);let i=he(n),o=this.children.get(i);return o?o.foreachOnPath_(Fe(n),Ze(e,i),r):new t(null)}}foreach(n){this.foreach_(Ne(),n)}foreach_(n,e){this.children.inorderTraversal((r,i)=>{i.foreach_(Ze(n,r),e)}),this.value&&e(n,this.value)}foreachChild(n){this.children.inorderTraversal((e,r)=>{r.value&&n(e,r.value)})}};var fn=class t{constructor(n){this.writeTree_=n}static empty(){return new t(new kt(null))}};function Nc(t,n,e){if(ye(n))return new fn(new kt(e));{let r=t.writeTree_.findRootMostValueAndPath(n);if(r!=null){let i=r.path,o=r.value,s=Pt(i,n);return o=o.updateChild(s,e),new fn(t.writeTree_.set(i,o))}else{let i=new kt(e),o=t.writeTree_.setTree(n,i);return new fn(o)}}}function VN(t,n,e){let r=t;return bt(e,(i,o)=>{r=Nc(r,Ze(n,i),o)}),r}function WN(t,n){if(ye(n))return fn.empty();{let e=t.writeTree_.setTree(n,new kt(null));return new fn(e)}}function eE(t,n){return no(t,n)!=null}function no(t,n){let e=t.writeTree_.findRootMostValueAndPath(n);return e!=null?t.writeTree_.get(e.path).getChild(Pt(e.path,n)):null}function GN(t){let n=[],e=t.writeTree_.value;return e!=null?e.isLeafNode()||e.forEachChild(Ye,(r,i)=>{n.push(new ve(r,i))}):t.writeTree_.children.inorderTraversal((r,i)=>{i.value!=null&&n.push(new ve(r,i.value))}),n}function ti(t,n){if(ye(n))return t;{let e=no(t,n);return e!=null?new fn(new kt(e)):new fn(t.writeTree_.subtree(n))}}function tE(t){return t.writeTree_.isEmpty()}function Js(t,n){return kP(Ne(),t.writeTree_,n)}function kP(t,n,e){if(n.value!=null)return e.updateChild(t,n.value);{let r=null;return n.children.inorderTraversal((i,o)=>{i===".priority"?(A(o.value!==null,"Priority writes must always be leaf nodes"),r=o.value):e=kP(Ze(t,i),o,e)}),!e.getChild(t).isEmpty()&&r!==null&&(e=e.updateChild(Ze(t,".priority"),r)),e}}function ME(t,n){return $P(n,t)}function Ote(t,n,e,r,i){A(r>t.lastWriteId,"Stacking an older write on top of newer ones"),i===void 0&&(i=!0),t.allWrites.push({path:n,snap:e,writeId:r,visible:i}),i&&(t.visibleWrites=Nc(t.visibleWrites,n,e)),t.lastWriteId=r}function Mte(t,n){for(let e=0;e<t.allWrites.length;e++){let r=t.allWrites[e];if(r.writeId===n)return r}return null}function Ate(t,n){let e=t.allWrites.findIndex(a=>a.writeId===n);A(e>=0,"removeWrite called with nonexistent writeId.");let r=t.allWrites[e];t.allWrites.splice(e,1);let i=r.visible,o=!1,s=t.allWrites.length-1;for(;i&&s>=0;){let a=t.allWrites[s];a.visible&&(s>=e&&Nte(a,r.path)?i=!1:Xt(r.path,a.path)&&(o=!0)),s--}if(i){if(o)return Pte(t),!0;if(r.snap)t.visibleWrites=WN(t.visibleWrites,r.path);else{let a=r.children;bt(a,c=>{t.visibleWrites=WN(t.visibleWrites,Ze(r.path,c))})}return!0}else return!1}function Nte(t,n){if(t.snap)return Xt(t.path,n);for(let e in t.children)if(t.children.hasOwnProperty(e)&&Xt(Ze(t.path,e),n))return!0;return!1}function Pte(t){t.visibleWrites=LP(t.allWrites,Rte,Ne()),t.allWrites.length>0?t.lastWriteId=t.allWrites[t.allWrites.length-1].writeId:t.lastWriteId=-1}function Rte(t){return t.visible}function LP(t,n,e){let r=fn.empty();for(let i=0;i<t.length;++i){let o=t[i];if(n(o)){let s=o.path,a;if(o.snap)Xt(e,s)?(a=Pt(e,s),r=Nc(r,a,o.snap)):Xt(s,e)&&(a=Pt(s,e),r=Nc(r,Ne(),o.snap.getChild(a)));else if(o.children){if(Xt(e,s))a=Pt(e,s),r=VN(r,a,o.children);else if(Xt(s,e))if(a=Pt(s,e),ye(a))r=VN(r,Ne(),o.children);else{let c=Wi(o.children,he(a));if(c){let u=c.getChild(Fe(a));r=Nc(r,Ne(),u)}}}else throw Vi("WriteRecord should have .snap or .children")}}return r}function jP(t,n,e,r,i){if(!r&&!i){let o=no(t.visibleWrites,n);if(o!=null)return o;{let s=ti(t.visibleWrites,n);if(tE(s))return e;if(e==null&&!eE(s,Ne()))return null;{let a=e||ce.EMPTY_NODE;return Js(s,a)}}}else{let o=ti(t.visibleWrites,n);if(!i&&tE(o))return e;if(!i&&e==null&&!eE(o,Ne()))return null;{let s=function(u){return(u.visible||i)&&(!r||!~r.indexOf(u.writeId))&&(Xt(u.path,n)||Xt(n,u.path))},a=LP(t.allWrites,s,n),c=e||ce.EMPTY_NODE;return Js(a,c)}}}function kte(t,n,e){let r=ce.EMPTY_NODE,i=no(t.visibleWrites,n);if(i)return i.isLeafNode()||i.forEachChild(Ye,(o,s)=>{r=r.updateImmediateChild(o,s)}),r;if(e){let o=ti(t.visibleWrites,n);return e.forEachChild(Ye,(s,a)=>{let c=Js(ti(o,new Pe(s)),a);r=r.updateImmediateChild(s,c)}),GN(o).forEach(s=>{r=r.updateImmediateChild(s.name,s.node)}),r}else{let o=ti(t.visibleWrites,n);return GN(o).forEach(s=>{r=r.updateImmediateChild(s.name,s.node)}),r}}function Lte(t,n,e,r,i){A(r||i,"Either existingEventSnap or existingServerSnap must exist");let o=Ze(n,e);if(eE(t.visibleWrites,o))return null;{let s=ti(t.visibleWrites,o);return tE(s)?i.getChild(e):Js(s,i.getChild(e))}}function jte(t,n,e,r){let i=Ze(n,e),o=no(t.visibleWrites,i);if(o!=null)return o;if(r.isCompleteForChild(e)){let s=ti(t.visibleWrites,i);return Js(s,r.getNode().getImmediateChild(e))}else return null}function Fte(t,n){return no(t.visibleWrites,n)}function $te(t,n,e,r,i,o,s){let a,c=ti(t.visibleWrites,n),u=no(c,Ne());if(u!=null)a=u;else if(e!=null)a=Js(c,e);else return[];if(a=a.withIndex(s),!a.isEmpty()&&!a.isLeafNode()){let l=[],d=s.getCompare(),f=o?a.getReverseIteratorFrom(r,s):a.getIteratorFrom(r,s),p=f.getNext();for(;p&&l.length<i;)d(p,r)!==0&&l.push(p),p=f.getNext();return l}else return[]}function qte(){return{visibleWrites:fn.empty(),allWrites:[],lastWriteId:-1}}function Hp(t,n,e,r){return jP(t.writeTree,t.treePath,n,e,r)}function AE(t,n){return kte(t.writeTree,t.treePath,n)}function zN(t,n,e,r){return Lte(t.writeTree,t.treePath,n,e,r)}function Up(t,n){return Fte(t.writeTree,Ze(t.treePath,n))}function Bte(t,n,e,r,i,o){return $te(t.writeTree,t.treePath,n,e,r,i,o)}function NE(t,n,e){return jte(t.writeTree,t.treePath,n,e)}function FP(t,n){return $P(Ze(t.treePath,n),t.writeTree)}function $P(t,n){return{treePath:t,writeTree:n}}var nE=class{constructor(){this.changeMap=new Map}trackChildChange(n){let e=n.type,r=n.childName;A(e==="child_added"||e==="child_changed"||e==="child_removed","Only child changes supported for tracking"),A(r!==".priority","Only non-priority child changes can be tracked.");let i=this.changeMap.get(r);if(i){let o=i.type;if(e==="child_added"&&o==="child_removed")this.changeMap.set(r,jc(r,n.snapshotNode,i.snapshotNode));else if(e==="child_removed"&&o==="child_added")this.changeMap.delete(r);else if(e==="child_removed"&&o==="child_changed")this.changeMap.set(r,Lc(r,i.oldSnap));else if(e==="child_changed"&&o==="child_added")this.changeMap.set(r,Zs(r,n.snapshotNode));else if(e==="child_changed"&&o==="child_changed")this.changeMap.set(r,jc(r,n.snapshotNode,i.oldSnap));else throw Vi("Illegal combination of changes: "+n+" occurred after "+i)}else this.changeMap.set(r,n)}getChanges(){return Array.from(this.changeMap.values())}};var rE=class{getCompleteChild(n){return null}getChildAfterChild(n,e,r){return null}},qP=new rE,$c=class{constructor(n,e,r=null){this.writes_=n,this.viewCache_=e,this.optCompleteServerCache_=r}getCompleteChild(n){let e=this.viewCache_.eventCache;if(e.isCompleteForChild(n))return e.getNode().getImmediateChild(n);{let r=this.optCompleteServerCache_!=null?new rr(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return NE(this.writes_,n,r)}}getChildAfterChild(n,e,r){let i=this.optCompleteServerCache_!=null?this.optCompleteServerCache_:eo(this.viewCache_),o=Bte(this.writes_,i,e,1,r,n);return o.length===0?null:o[0]}};function Hte(t){return{filter:t}}function Ute(t,n){A(n.eventCache.getNode().isIndexed(t.filter.getIndex()),"Event snap not indexed"),A(n.serverCache.getNode().isIndexed(t.filter.getIndex()),"Server snap not indexed")}function Vte(t,n,e,r,i){let o=new nE,s,a;if(e.type===Nn.OVERWRITE){let u=e;u.source.fromUser?s=iE(t,n,u.path,u.snap,r,i,o):(A(u.source.fromServer,"Unknown source."),a=u.source.tagged||n.serverCache.isFiltered()&&!ye(u.path),s=Vp(t,n,u.path,u.snap,r,i,a,o))}else if(e.type===Nn.MERGE){let u=e;u.source.fromUser?s=Gte(t,n,u.path,u.children,r,i,o):(A(u.source.fromServer,"Unknown source."),a=u.source.tagged||n.serverCache.isFiltered(),s=oE(t,n,u.path,u.children,r,i,a,o))}else if(e.type===Nn.ACK_USER_WRITE){let u=e;u.revert?s=Yte(t,n,u.path,r,i,o):s=zte(t,n,u.path,u.affectedTree,r,i,o)}else if(e.type===Nn.LISTEN_COMPLETE)s=Kte(t,n,e.path,r,o);else throw Vi("Unknown operation type: "+e.type);let c=o.getChanges();return Wte(n,s,c),{viewCache:s,changes:c}}function Wte(t,n,e){let r=n.eventCache;if(r.isFullyInitialized()){let i=r.getNode().isLeafNode()||r.getNode().isEmpty(),o=Xw(t);(e.length>0||!t.eventCache.isFullyInitialized()||i&&!r.getNode().equals(o)||!r.getNode().getPriority().equals(o.getPriority()))&&e.push(NP(Xw(n)))}}function BP(t,n,e,r,i,o){let s=n.eventCache;if(Up(r,e)!=null)return n;{let a,c;if(ye(e))if(A(n.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),n.serverCache.isFiltered()){let u=eo(n),l=u instanceof ce?u:ce.EMPTY_NODE,d=AE(r,l);a=t.filter.updateFullNode(n.eventCache.getNode(),d,o)}else{let u=Hp(r,eo(n));a=t.filter.updateFullNode(n.eventCache.getNode(),u,o)}else{let u=he(e);if(u===".priority"){A(ni(e)===1,"Can't have a priority with additional path components");let l=s.getNode();c=n.serverCache.getNode();let d=zN(r,e,l,c);d!=null?a=t.filter.updatePriority(l,d):a=s.getNode()}else{let l=Fe(e),d;if(s.isCompleteForChild(u)){c=n.serverCache.getNode();let f=zN(r,e,s.getNode(),c);f!=null?d=s.getNode().getImmediateChild(u).updateChild(l,f):d=s.getNode().getImmediateChild(u)}else d=NE(r,u,n.serverCache);d!=null?a=t.filter.updateChild(s.getNode(),u,d,l,i,o):a=s.getNode()}}return Ac(n,a,s.isFullyInitialized()||ye(e),t.filter.filtersNodes())}}function Vp(t,n,e,r,i,o,s,a){let c=n.serverCache,u,l=s?t.filter:t.filter.getIndexedFilter();if(ye(e))u=l.updateFullNode(c.getNode(),r,null);else if(l.filtersNodes()&&!c.isFiltered()){let p=c.getNode().updateChild(e,r);u=l.updateFullNode(c.getNode(),p,null)}else{let p=he(e);if(!c.isCompleteForPath(e)&&ni(e)>1)return n;let m=Fe(e),b=c.getNode().getImmediateChild(p).updateChild(m,r);p===".priority"?u=l.updatePriority(c.getNode(),b):u=l.updateChild(c.getNode(),p,b,m,qP,null)}let d=RP(n,u,c.isFullyInitialized()||ye(e),l.filtersNodes()),f=new $c(i,d,o);return BP(t,d,e,i,f,a)}function iE(t,n,e,r,i,o,s){let a=n.eventCache,c,u,l=new $c(i,n,o);if(ye(e))u=t.filter.updateFullNode(n.eventCache.getNode(),r,s),c=Ac(n,u,!0,t.filter.filtersNodes());else{let d=he(e);if(d===".priority")u=t.filter.updatePriority(n.eventCache.getNode(),r),c=Ac(n,u,a.isFullyInitialized(),a.isFiltered());else{let f=Fe(e),p=a.getNode().getImmediateChild(d),m;if(ye(f))m=r;else{let y=l.getCompleteChild(d);y!=null?CE(f)===".priority"&&y.getChild(TP(f)).isEmpty()?m=y:m=y.updateChild(f,r):m=ce.EMPTY_NODE}if(p.equals(m))c=n;else{let y=t.filter.updateChild(a.getNode(),d,m,f,l,s);c=Ac(n,y,a.isFullyInitialized(),t.filter.filtersNodes())}}}return c}function KN(t,n){return t.eventCache.isCompleteForChild(n)}function Gte(t,n,e,r,i,o,s){let a=n;return r.foreach((c,u)=>{let l=Ze(e,c);KN(n,he(l))&&(a=iE(t,a,l,u,i,o,s))}),r.foreach((c,u)=>{let l=Ze(e,c);KN(n,he(l))||(a=iE(t,a,l,u,i,o,s))}),a}function YN(t,n,e){return e.foreach((r,i)=>{n=n.updateChild(r,i)}),n}function oE(t,n,e,r,i,o,s,a){if(n.serverCache.getNode().isEmpty()&&!n.serverCache.isFullyInitialized())return n;let c=n,u;ye(e)?u=r:u=new kt(null).setTree(e,r);let l=n.serverCache.getNode();return u.children.inorderTraversal((d,f)=>{if(l.hasChild(d)){let p=n.serverCache.getNode().getImmediateChild(d),m=YN(t,p,f);c=Vp(t,c,new Pe(d),m,i,o,s,a)}}),u.children.inorderTraversal((d,f)=>{let p=!n.serverCache.isCompleteForChild(d)&&f.value===null;if(!l.hasChild(d)&&!p){let m=n.serverCache.getNode().getImmediateChild(d),y=YN(t,m,f);c=Vp(t,c,new Pe(d),y,i,o,s,a)}}),c}function zte(t,n,e,r,i,o,s){if(Up(i,e)!=null)return n;let a=n.serverCache.isFiltered(),c=n.serverCache;if(r.value!=null){if(ye(e)&&c.isFullyInitialized()||c.isCompleteForPath(e))return Vp(t,n,e,c.getNode().getChild(e),i,o,a,s);if(ye(e)){let u=new kt(null);return c.getNode().forEachChild(Vs,(l,d)=>{u=u.set(new Pe(l),d)}),oE(t,n,e,u,i,o,a,s)}else return n}else{let u=new kt(null);return r.foreach((l,d)=>{let f=Ze(e,l);c.isCompleteForPath(f)&&(u=u.set(l,c.getNode().getChild(f)))}),oE(t,n,e,u,i,o,a,s)}}function Kte(t,n,e,r,i){let o=n.serverCache,s=RP(n,o.getNode(),o.isFullyInitialized()||ye(e),o.isFiltered());return BP(t,s,e,r,qP,i)}function Yte(t,n,e,r,i,o){let s;if(Up(r,e)!=null)return n;{let a=new $c(r,n,i),c=n.eventCache.getNode(),u;if(ye(e)||he(e)===".priority"){let l;if(n.serverCache.isFullyInitialized())l=Hp(r,eo(n));else{let d=n.serverCache.getNode();A(d instanceof ce,"serverChildren would be complete if leaf node"),l=AE(r,d)}l=l,u=t.filter.updateFullNode(c,l,o)}else{let l=he(e),d=NE(r,l,n.serverCache);d==null&&n.serverCache.isCompleteForChild(l)&&(d=c.getImmediateChild(l)),d!=null?u=t.filter.updateChild(c,l,d,Fe(e),a,o):n.eventCache.getNode().hasChild(l)?u=t.filter.updateChild(c,l,ce.EMPTY_NODE,Fe(e),a,o):u=c,u.isEmpty()&&n.serverCache.isFullyInitialized()&&(s=Hp(r,eo(n)),s.isLeafNode()&&(u=t.filter.updateFullNode(u,s,o)))}return s=n.serverCache.isFullyInitialized()||Up(r,Ne())!=null,Ac(n,u,s,t.filter.filtersNodes())}}var sE=class{constructor(n,e){this.query_=n,this.eventRegistrations_=[];let r=this.query_._queryParams,i=new Fc(r.getIndex()),o=wte(r);this.processor_=Hte(o);let s=e.serverCache,a=e.eventCache,c=i.updateFullNode(ce.EMPTY_NODE,s.getNode(),null),u=o.updateFullNode(ce.EMPTY_NODE,a.getNode(),null),l=new rr(c,s.isFullyInitialized(),i.filtersNodes()),d=new rr(u,a.isFullyInitialized(),o.filtersNodes());this.viewCache_=em(d,l),this.eventGenerator_=new Jw(this.query_)}get query(){return this.query_}};function Zte(t){return t.viewCache_.serverCache.getNode()}function Qte(t,n){let e=eo(t.viewCache_);return e&&(t.query._queryParams.loadsAllData()||!ye(n)&&!e.getImmediateChild(he(n)).isEmpty())?e.getChild(n):null}function ZN(t){return t.eventRegistrations_.length===0}function Jte(t,n){t.eventRegistrations_.push(n)}function QN(t,n,e){let r=[];if(e){A(n==null,"A cancel should cancel all event registrations.");let i=t.query._path;t.eventRegistrations_.forEach(o=>{let s=o.createCancelEvent(e,i);s&&r.push(s)})}if(n){let i=[];for(let o=0;o<t.eventRegistrations_.length;++o){let s=t.eventRegistrations_[o];if(!s.matches(n))i.push(s);else if(n.hasAnyCallback()){i=i.concat(t.eventRegistrations_.slice(o+1));break}}t.eventRegistrations_=i}else t.eventRegistrations_=[];return r}function JN(t,n,e,r){n.type===Nn.MERGE&&n.source.queryId!==null&&(A(eo(t.viewCache_),"We should always have a full cache before handling merges"),A(Xw(t.viewCache_),"Missing event cache, even though we have a server cache"));let i=t.viewCache_,o=Vte(t.processor_,i,n,e,r);return Ute(t.processor_,o.viewCache),A(o.viewCache.serverCache.isFullyInitialized()||!i.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),t.viewCache_=o.viewCache,HP(t,o.changes,o.viewCache.eventCache.getNode(),null)}function Xte(t,n){let e=t.viewCache_.eventCache,r=[];return e.getNode().isLeafNode()||e.getNode().forEachChild(Ye,(o,s)=>{r.push(Zs(o,s))}),e.isFullyInitialized()&&r.push(NP(e.getNode())),HP(t,r,e.getNode(),n)}function HP(t,n,e,r){let i=r?[r]:t.eventRegistrations_;return Ite(t.eventGenerator_,n,e,i)}var Wp,aE=class{constructor(){this.views=new Map}};function ene(t){A(!Wp,"__referenceConstructor has already been defined"),Wp=t}function tne(){return A(Wp,"Reference.ts has not been loaded"),Wp}function nne(t){return t.views.size===0}function PE(t,n,e,r){let i=n.source.queryId;if(i!==null){let o=t.views.get(i);return A(o!=null,"SyncTree gave us an op for an invalid query."),JN(o,n,e,r)}else{let o=[];for(let s of t.views.values())o=o.concat(JN(s,n,e,r));return o}}function rne(t,n,e,r,i){let o=n._queryIdentifier,s=t.views.get(o);if(!s){let a=Hp(e,i?r:null),c=!1;a?c=!0:r instanceof ce?(a=AE(e,r),c=!1):(a=ce.EMPTY_NODE,c=!1);let u=em(new rr(a,c,!1),new rr(r,i,!1));return new sE(n,u)}return s}function ine(t,n,e,r,i,o){let s=rne(t,n,r,i,o);return t.views.has(n._queryIdentifier)||t.views.set(n._queryIdentifier,s),Jte(s,e),Xte(s,e)}function one(t,n,e,r){let i=n._queryIdentifier,o=[],s=[],a=ri(t);if(i==="default")for(let[c,u]of t.views.entries())s=s.concat(QN(u,e,r)),ZN(u)&&(t.views.delete(c),u.query._queryParams.loadsAllData()||o.push(u.query));else{let c=t.views.get(i);c&&(s=s.concat(QN(c,e,r)),ZN(c)&&(t.views.delete(i),c.query._queryParams.loadsAllData()||o.push(c.query)))}return a&&!ri(t)&&o.push(new(tne())(n._repo,n._path)),{removed:o,events:s}}function UP(t){let n=[];for(let e of t.views.values())e.query._queryParams.loadsAllData()||n.push(e);return n}function Ws(t,n){let e=null;for(let r of t.views.values())e=e||Qte(r,n);return e}function VP(t,n){if(n._queryParams.loadsAllData())return tm(t);{let r=n._queryIdentifier;return t.views.get(r)}}function WP(t,n){return VP(t,n)!=null}function ri(t){return tm(t)!=null}function tm(t){for(let n of t.views.values())if(n.query._queryParams.loadsAllData())return n;return null}var Gp;function sne(t){A(!Gp,"__referenceConstructor has already been defined"),Gp=t}function ane(){return A(Gp,"Reference.ts has not been loaded"),Gp}var cne=1,zp=class{constructor(n){this.listenProvider_=n,this.syncPointTree_=new kt(null),this.pendingWriteTree_=qte(),this.tagToQueryMap=new Map,this.queryToTagMap=new Map}};function GP(t,n,e,r,i){return Ote(t.pendingWriteTree_,n,e,r,i),i?Vc(t,new Qs(PP(),n,e)):[]}function Zi(t,n,e=!1){let r=Mte(t.pendingWriteTree_,n);if(Ate(t.pendingWriteTree_,n)){let o=new kt(null);return r.snap!=null?o=o.set(Ne(),!0):bt(r.children,s=>{o=o.set(new Pe(s),!0)}),Vc(t,new Qw(r.path,o,e))}else return[]}function nm(t,n,e){return Vc(t,new Qs(DE(),n,e))}function une(t,n,e){let r=kt.fromObject(e);return Vc(t,new Bp(DE(),n,r))}function lne(t,n){return Vc(t,new qp(DE(),n))}function dne(t,n,e){let r=kE(t,e);if(r){let i=LE(r),o=i.path,s=i.queryId,a=Pt(o,n),c=new qp(OE(s),a);return jE(t,o,c)}else return[]}function cE(t,n,e,r,i=!1){let o=n._path,s=t.syncPointTree_.get(o),a=[];if(s&&(n._queryIdentifier==="default"||WP(s,n))){let c=one(s,n,e,r);nne(s)&&(t.syncPointTree_=t.syncPointTree_.remove(o));let u=c.removed;if(a=c.events,!i){let l=u.findIndex(f=>f._queryParams.loadsAllData())!==-1,d=t.syncPointTree_.findOnPath(o,(f,p)=>ri(p));if(l&&!d){let f=t.syncPointTree_.subtree(o);if(!f.isEmpty()){let p=pne(f);for(let m=0;m<p.length;++m){let y=p[m],b=y.query,E=YP(t,y);t.listenProvider_.startListening(Pc(b),Kp(t,b),E.hashFn,E.onComplete)}}}!d&&u.length>0&&!r&&(l?t.listenProvider_.stopListening(Pc(n),null):u.forEach(f=>{let p=t.queryToTagMap.get(rm(f));t.listenProvider_.stopListening(Pc(f),p)}))}mne(t,u)}return a}function fne(t,n,e,r){let i=kE(t,r);if(i!=null){let o=LE(i),s=o.path,a=o.queryId,c=Pt(s,n),u=new Qs(OE(a),c,e);return jE(t,s,u)}else return[]}function hne(t,n,e,r){let i=kE(t,r);if(i){let o=LE(i),s=o.path,a=o.queryId,c=Pt(s,n),u=kt.fromObject(e),l=new Bp(OE(a),c,u);return jE(t,s,l)}else return[]}function XN(t,n,e,r=!1){let i=n._path,o=null,s=!1;t.syncPointTree_.foreachOnPath(i,(f,p)=>{let m=Pt(f,i);o=o||Ws(p,m),s=s||ri(p)});let a=t.syncPointTree_.get(i);a?(s=s||ri(a),o=o||Ws(a,Ne())):(a=new aE,t.syncPointTree_=t.syncPointTree_.set(i,a));let c;o!=null?c=!0:(c=!1,o=ce.EMPTY_NODE,t.syncPointTree_.subtree(i).foreachChild((p,m)=>{let y=Ws(m,Ne());y&&(o=o.updateImmediateChild(p,y))}));let u=WP(a,n);if(!u&&!n._queryParams.loadsAllData()){let f=rm(n);A(!t.queryToTagMap.has(f),"View does not exist, but we have a tag");let p=gne();t.queryToTagMap.set(f,p),t.tagToQueryMap.set(p,f)}let l=ME(t.pendingWriteTree_,i),d=ine(a,n,e,l,o,c);if(!u&&!s&&!r){let f=VP(a,n);d=d.concat(yne(t,n,f))}return d}function RE(t,n,e){let i=t.pendingWriteTree_,o=t.syncPointTree_.findOnPath(n,(s,a)=>{let c=Pt(s,n),u=Ws(a,c);if(u)return u});return jP(i,n,o,e,!0)}function Vc(t,n){return zP(n,t.syncPointTree_,null,ME(t.pendingWriteTree_,Ne()))}function zP(t,n,e,r){if(ye(t.path))return KP(t,n,e,r);{let i=n.get(Ne());e==null&&i!=null&&(e=Ws(i,Ne()));let o=[],s=he(t.path),a=t.operationForChild(s),c=n.children.get(s);if(c&&a){let u=e?e.getImmediateChild(s):null,l=FP(r,s);o=o.concat(zP(a,c,u,l))}return i&&(o=o.concat(PE(i,t,r,e))),o}}function KP(t,n,e,r){let i=n.get(Ne());e==null&&i!=null&&(e=Ws(i,Ne()));let o=[];return n.children.inorderTraversal((s,a)=>{let c=e?e.getImmediateChild(s):null,u=FP(r,s),l=t.operationForChild(s);l&&(o=o.concat(KP(l,a,c,u)))}),i&&(o=o.concat(PE(i,t,r,e))),o}function YP(t,n){let e=n.query,r=Kp(t,e);return{hashFn:()=>(Zte(n)||ce.EMPTY_NODE).hash(),onComplete:i=>{if(i==="ok")return r?dne(t,e._path,r):lne(t,e._path);{let o=Oee(i,e);return cE(t,e,null,o)}}}}function Kp(t,n){let e=rm(n);return t.queryToTagMap.get(e)}function rm(t){return t._path.toString()+"$"+t._queryIdentifier}function kE(t,n){return t.tagToQueryMap.get(n)}function LE(t){let n=t.indexOf("$");return A(n!==-1&&n<t.length-1,"Bad queryKey."),{queryId:t.substr(n+1),path:new Pe(t.substr(0,n))}}function jE(t,n,e){let r=t.syncPointTree_.get(n);A(r,"Missing sync point for query tag that we're tracking");let i=ME(t.pendingWriteTree_,n);return PE(r,e,i,null)}function pne(t){return t.fold((n,e,r)=>{if(e&&ri(e))return[tm(e)];{let i=[];return e&&(i=UP(e)),bt(r,(o,s)=>{i=i.concat(s)}),i}})}function Pc(t){return t._queryParams.loadsAllData()&&!t._queryParams.isDefault()?new(ane())(t._repo,t._path):t}function mne(t,n){for(let e=0;e<n.length;++e){let r=n[e];if(!r._queryParams.loadsAllData()){let i=rm(r),o=t.queryToTagMap.get(i);t.queryToTagMap.delete(i),t.tagToQueryMap.delete(o)}}}function gne(){return cne++}function yne(t,n,e){let r=n._path,i=Kp(t,n),o=YP(t,e),s=t.listenProvider_.startListening(Pc(n),i,o.hashFn,o.onComplete),a=t.syncPointTree_.subtree(r);if(i)A(!ri(a.value),"If we're adding a query, it shouldn't be shadowed");else{let c=a.fold((u,l,d)=>{if(!ye(u)&&l&&ri(l))return[tm(l).query];{let f=[];return l&&(f=f.concat(UP(l).map(p=>p.query))),bt(d,(p,m)=>{f=f.concat(m)}),f}});for(let u=0;u<c.length;++u){let l=c[u];t.listenProvider_.stopListening(Pc(l),Kp(t,l))}}return s}var uE=class t{constructor(n){this.node_=n}getImmediateChild(n){let e=this.node_.getImmediateChild(n);return new t(e)}node(){return this.node_}},lE=class t{constructor(n,e){this.syncTree_=n,this.path_=e}getImmediateChild(n){let e=Ze(this.path_,n);return new t(this.syncTree_,e)}node(){return RE(this.syncTree_,this.path_)}},vne=function(t){return t=t||{},t.timestamp=t.timestamp||new Date().getTime(),t},eP=function(t,n,e){if(!t||typeof t!="object")return t;if(A(".sv"in t,"Unexpected leaf node or priority contents"),typeof t[".sv"]=="string")return _ne(t[".sv"],n,e);if(typeof t[".sv"]=="object")return bne(t[".sv"],n);A(!1,"Unexpected server value: "+JSON.stringify(t,null,2))},_ne=function(t,n,e){if(t==="timestamp")return e.timestamp;A(!1,"Unexpected server value: "+t)},bne=function(t,n,e){t.hasOwnProperty("increment")||A(!1,"Unexpected server value: "+JSON.stringify(t,null,2));let r=t.increment;typeof r!="number"&&A(!1,"Unexpected increment value: "+r);let i=n.node();if(A(i!==null&&typeof i<"u","Expected ChildrenNode.EMPTY_NODE for nulls"),!i.isLeafNode())return r;let s=i.getValue();return typeof s!="number"?r:s+r},wne=function(t,n,e,r){return FE(n,new lE(e,t),r)},ZP=function(t,n,e){return FE(t,new uE(n),e)};function FE(t,n,e){let r=t.getPriority().val(),i=eP(r,n.getImmediateChild(".priority"),e),o;if(t.isLeafNode()){let s=t,a=eP(s.getValue(),n,e);return a!==s.getValue()||i!==s.getPriority().val()?new Ks(a,Qe(i)):t}else{let s=t;return o=s,i!==s.getPriority().val()&&(o=o.updatePriority(new Ks(i))),s.forEachChild(Ye,(a,c)=>{let u=FE(c,n.getImmediateChild(a),e);u!==c&&(o=o.updateImmediateChild(a,u))}),o}}var qc=class{constructor(n="",e=null,r={children:{},childCount:0}){this.name=n,this.parent=e,this.node=r}};function $E(t,n){let e=n instanceof Pe?n:new Pe(n),r=t,i=he(e);for(;i!==null;){let o=Wi(r.node.children,i)||{children:{},childCount:0};r=new qc(i,r,o),e=Fe(e),i=he(e)}return r}function ra(t){return t.node.value}function QP(t,n){t.node.value=n,dE(t)}function JP(t){return t.node.childCount>0}function Ene(t){return ra(t)===void 0&&!JP(t)}function im(t,n){bt(t.node.children,(e,r)=>{n(new qc(e,t,r))})}function XP(t,n,e,r){e&&!r&&n(t),im(t,i=>{XP(i,n,!0,r)}),e&&r&&n(t)}function Sne(t,n,e){let r=e?t:t.parent;for(;r!==null;){if(n(r))return!0;r=r.parent}return!1}function Wc(t){return new Pe(t.parent===null?t.name:Wc(t.parent)+"/"+t.name)}function dE(t){t.parent!==null&&Cne(t.parent,t.name,t)}function Cne(t,n,e){let r=Ene(e),i=ln(t.node.children,n);r&&i?(delete t.node.children[n],t.node.childCount--,dE(t)):!r&&!i&&(t.node.children[n]=e.node,t.node.childCount++,dE(t))}var Ine=/[\[\].#$\/\u0000-\u001F\u007F]/,Tne=/[\[\].#$\u0000-\u001F\u007F]/,bw=10*1024*1024,qE=function(t){return typeof t=="string"&&t.length!==0&&!Ine.test(t)},eR=function(t){return typeof t=="string"&&t.length!==0&&!Tne.test(t)},xne=function(t){return t&&(t=t.replace(/^\/*\.info(\/|$)/,"/")),eR(t)},tR=function(t){return t===null||typeof t=="string"||typeof t=="number"&&!Xp(t)||t&&typeof t=="object"&&ln(t,".sv")},Yp=function(t,n,e,r){r&&n===void 0||om(Gi(t,"value"),n,e)},om=function(t,n,e){let r=e instanceof Pe?new Rw(e,t):e;if(n===void 0)throw new Error(t+"contains undefined "+Ki(r));if(typeof n=="function")throw new Error(t+"contains a function "+Ki(r)+" with contents = "+n.toString());if(Xp(n))throw new Error(t+"contains "+n.toString()+" "+Ki(r));if(typeof n=="string"&&n.length>bw/3&&_c(n)>bw)throw new Error(t+"contains a string greater than "+bw+" utf8 bytes "+Ki(r)+" ('"+n.substring(0,50)+"...')");if(n&&typeof n=="object"){let i=!1,o=!1;if(bt(n,(s,a)=>{if(s===".value")i=!0;else if(s!==".priority"&&s!==".sv"&&(o=!0,!qE(s)))throw new Error(t+" contains an invalid key ("+s+") "+Ki(r)+`. Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"`);ate(r,s),om(t,a,r),cte(r)}),i&&o)throw new Error(t+' contains ".value" child '+Ki(r)+" in addition to actual children.")}},Dne=function(t,n){let e,r;for(e=0;e<n.length;e++){r=n[e];let o=kc(r);for(let s=0;s<o.length;s++)if(!(o[s]===".priority"&&s===o.length-1)){if(!qE(o[s]))throw new Error(t+"contains an invalid key ("+o[s]+") in path "+r.toString()+`. Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"`)}}n.sort(ste);let i=null;for(e=0;e<n.length;e++){if(r=n[e],i!==null&&Xt(i,r))throw new Error(t+"contains a path "+i.toString()+" that is ancestor of another path "+r.toString());i=r}},One=function(t,n,e,r){if(r&&n===void 0)return;let i=Gi(t,"values");if(!(n&&typeof n=="object")||Array.isArray(n))throw new Error(i+" must be an object containing the children to replace.");let o=[];bt(n,(s,a)=>{let c=new Pe(s);if(om(i,a,Ze(e,c)),CE(c)===".priority"&&!tR(a))throw new Error(i+"contains an invalid value for '"+c.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");o.push(c)}),Dne(i,o)},Mne=function(t,n,e){if(!(e&&n===void 0)){if(Xp(n))throw new Error(Gi(t,"priority")+"is "+n.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!tR(n))throw new Error(Gi(t,"priority")+"must be a valid Firebase priority (a string, finite number, server value, or null).")}};var nR=function(t,n,e,r){if(!(r&&e===void 0)&&!eR(e))throw new Error(Gi(t,n)+'was an invalid path = "'+e+`". Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]"`)},Ane=function(t,n,e,r){e&&(e=e.replace(/^\/*\.info(\/|$)/,"/")),nR(t,n,e,r)},Qi=function(t,n){if(he(n)===".info")throw new Error(t+" failed = Can't modify data under /.info/")},Nne=function(t,n){let e=n.path.toString();if(typeof n.repoInfo.host!="string"||n.repoInfo.host.length===0||!qE(n.repoInfo.namespace)&&n.repoInfo.host.split(":")[0]!=="localhost"||e.length!==0&&!xne(e))throw new Error(Gi(t,"url")+`must be a valid firebase URL and the path can't contain ".", "#", "$", "[", or "]".`)};var fE=class{constructor(){this.eventLists_=[],this.recursionDepth_=0}};function BE(t,n){let e=null;for(let r=0;r<n.length;r++){let i=n[r],o=i.getPath();e!==null&&!IE(o,e.path)&&(t.eventLists_.push(e),e=null),e===null&&(e={events:[],path:o}),e.events.push(i)}e&&t.eventLists_.push(e)}function rR(t,n,e){BE(t,e),iR(t,r=>IE(r,n))}function ir(t,n,e){BE(t,e),iR(t,r=>Xt(r,n)||Xt(n,r))}function iR(t,n){t.recursionDepth_++;let e=!0;for(let r=0;r<t.eventLists_.length;r++){let i=t.eventLists_[r];if(i){let o=i.path;n(o)?(Pne(t.eventLists_[r]),t.eventLists_[r]=null):e=!1}}e&&(t.eventLists_=[]),t.recursionDepth_--}function Pne(t){for(let n=0;n<t.events.length;n++){let e=t.events[n];if(e!==null){t.events[n]=null;let r=e.getEventRunner();Ji&&pt("event: "+e.toString()),ta(r)}}}var Rne="repo_interrupt",kne=25,hE=class{constructor(n,e,r,i){this.repoInfo_=n,this.forceRestClient_=e,this.authTokenProvider_=r,this.appCheckProvider_=i,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new fE,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=$p(),this.transactionQueueTree_=new qc,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}};function Lne(t,n,e){if(t.stats_=EE(t.repoInfo_),t.forceRestClient_||Pee())t.server_=new Ww(t.repoInfo_,(r,i,o,s)=>{tP(t,r,i,o,s)},t.authTokenProvider_,t.appCheckProvider_),setTimeout(()=>nP(t,!0),0);else{if(typeof e<"u"&&e!==null){if(typeof e!="object")throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{nt(e)}catch(r){throw new Error("Invalid authOverride provided: "+r)}}t.persistentConnection_=new TE(t.repoInfo_,n,(r,i,o,s)=>{tP(t,r,i,o,s)},r=>{nP(t,r)},r=>{jne(t,r)},t.authTokenProvider_,t.appCheckProvider_,e),t.server_=t.persistentConnection_}t.authTokenProvider_.addTokenChangeListener(r=>{t.server_.refreshAuthToken(r)}),t.appCheckProvider_.addTokenChangeListener(r=>{t.server_.refreshAppCheckToken(r.token)}),t.statsReporter_=kee(t.repoInfo_,()=>new Zw(t.stats_,t.server_)),t.infoData_=new Gw,t.infoSyncTree_=new zp({startListening:(r,i,o,s)=>{let a=[],c=t.infoData_.getNode(r._path);return c.isEmpty()||(a=nm(t.infoSyncTree_,r._path,c),setTimeout(()=>{s("ok")},0)),a},stopListening:()=>{}}),UE(t,"connected",!1),t.serverSyncTree_=new zp({startListening:(r,i,o,s)=>(t.server_.listen(r,o,i,(a,c)=>{let u=s(a,c);ir(t.eventQueue_,r._path,u)}),[]),stopListening:(r,i)=>{t.server_.unlisten(r,i)}})}function oR(t){let e=t.infoData_.getNode(new Pe(".info/serverTimeOffset")).val()||0;return new Date().getTime()+e}function HE(t){return vne({timestamp:oR(t)})}function tP(t,n,e,r,i){t.dataUpdateCount++;let o=new Pe(n);e=t.interceptServerDataCallback_?t.interceptServerDataCallback_(n,e):e;let s=[];if(i)if(r){let c=vc(e,u=>Qe(u));s=hne(t.serverSyncTree_,o,c,i)}else{let c=Qe(e);s=fne(t.serverSyncTree_,o,c,i)}else if(r){let c=vc(e,u=>Qe(u));s=une(t.serverSyncTree_,o,c)}else{let c=Qe(e);s=nm(t.serverSyncTree_,o,c)}let a=o;s.length>0&&(a=sm(t,o)),ir(t.eventQueue_,a,s)}function nP(t,n){UE(t,"connected",n),n===!1&&$ne(t)}function jne(t,n){bt(n,(e,r)=>{UE(t,e,r)})}function UE(t,n,e){let r=new Pe("/.info/"+n),i=Qe(e);t.infoData_.updateSnapshot(r,i);let o=nm(t.infoSyncTree_,r,i);ir(t.eventQueue_,r,o)}function sR(t){return t.nextWriteId_++}function Fne(t,n,e,r,i){VE(t,"set",{path:n.toString(),value:e,priority:r});let o=HE(t),s=Qe(e,r),a=RE(t.serverSyncTree_,n),c=ZP(s,a,o),u=sR(t),l=GP(t.serverSyncTree_,n,c,u,!0);BE(t.eventQueue_,l),t.server_.put(n.toString(),s.val(!0),(f,p)=>{let m=f==="ok";m||Rt("set at "+n+" failed: "+f);let y=Zi(t.serverSyncTree_,u,!m);ir(t.eventQueue_,n,y),Xs(t,i,f,p)});let d=dR(t,n);sm(t,d),ir(t.eventQueue_,d,[])}function $ne(t){VE(t,"onDisconnectEvents");let n=HE(t),e=$p();Kw(t.onDisconnect_,Ne(),(i,o)=>{let s=wne(i,o,t.serverSyncTree_,n);na(e,i,s)});let r=[];Kw(e,Ne(),(i,o)=>{r=r.concat(nm(t.serverSyncTree_,i,o));let s=dR(t,i);sm(t,s)}),t.onDisconnect_=$p(),ir(t.eventQueue_,Ne(),r)}function qne(t,n,e){t.server_.onDisconnectCancel(n.toString(),(r,i)=>{r==="ok"&&zw(t.onDisconnect_,n),Xs(t,e,r,i)})}function rP(t,n,e,r){let i=Qe(e);t.server_.onDisconnectPut(n.toString(),i.val(!0),(o,s)=>{o==="ok"&&na(t.onDisconnect_,n,i),Xs(t,r,o,s)})}function Bne(t,n,e,r,i){let o=Qe(e,r);t.server_.onDisconnectPut(n.toString(),o.val(!0),(s,a)=>{s==="ok"&&na(t.onDisconnect_,n,o),Xs(t,i,s,a)})}function Hne(t,n,e,r){if(xp(e)){pt("onDisconnect().update() called with empty data. Don't do anything."),Xs(t,r,"ok",void 0);return}t.server_.onDisconnectMerge(n.toString(),e,(i,o)=>{i==="ok"&&bt(e,(s,a)=>{let c=Qe(a);na(t.onDisconnect_,Ze(n,s),c)}),Xs(t,r,i,o)})}function Une(t,n,e){let r;he(n._path)===".info"?r=XN(t.infoSyncTree_,n,e):r=XN(t.serverSyncTree_,n,e),rR(t.eventQueue_,n._path,r)}function iP(t,n,e){let r;he(n._path)===".info"?r=cE(t.infoSyncTree_,n,e):r=cE(t.serverSyncTree_,n,e),rR(t.eventQueue_,n._path,r)}function Vne(t){t.persistentConnection_&&t.persistentConnection_.interrupt(Rne)}function VE(t,...n){let e="";t.persistentConnection_&&(e=t.persistentConnection_.id+":"),pt(e,...n)}function Xs(t,n,e,r){n&&ta(()=>{if(e==="ok")n(null);else{let i=(e||"error").toUpperCase(),o=i;r&&(o+=": "+r);let s=new Error(o);s.code=i,n(s)}})}function aR(t,n,e){return RE(t.serverSyncTree_,n,e)||ce.EMPTY_NODE}function WE(t,n=t.transactionQueueTree_){if(n||am(t,n),ra(n)){let e=uR(t,n);A(e.length>0,"Sending zero length transaction queue"),e.every(i=>i.status===0)&&Wne(t,Wc(n),e)}else JP(n)&&im(n,e=>{WE(t,e)})}function Wne(t,n,e){let r=e.map(u=>u.currentWriteId),i=aR(t,n,r),o=i,s=i.hash();for(let u=0;u<e.length;u++){let l=e[u];A(l.status===0,"tryToSendTransactionQueue_: items in queue should all be run."),l.status=1,l.retryCount++;let d=Pt(n,l.path);o=o.updateChild(d,l.currentOutputSnapshotRaw)}let a=o.val(!0),c=n;t.server_.put(c.toString(),a,u=>{VE(t,"transaction put response",{path:c.toString(),status:u});let l=[];if(u==="ok"){let d=[];for(let f=0;f<e.length;f++)e[f].status=2,l=l.concat(Zi(t.serverSyncTree_,e[f].currentWriteId)),e[f].onComplete&&d.push(()=>e[f].onComplete(null,!0,e[f].currentOutputSnapshotResolved)),e[f].unwatcher();am(t,$E(t.transactionQueueTree_,n)),WE(t,t.transactionQueueTree_),ir(t.eventQueue_,n,l);for(let f=0;f<d.length;f++)ta(d[f])}else{if(u==="datastale")for(let d=0;d<e.length;d++)e[d].status===3?e[d].status=4:e[d].status=0;else{Rt("transaction at "+c.toString()+" failed: "+u);for(let d=0;d<e.length;d++)e[d].status=4,e[d].abortReason=u}sm(t,n)}},s)}function sm(t,n){let e=cR(t,n),r=Wc(e),i=uR(t,e);return Gne(t,i,r),r}function Gne(t,n,e){if(n.length===0)return;let r=[],i=[],s=n.filter(a=>a.status===0).map(a=>a.currentWriteId);for(let a=0;a<n.length;a++){let c=n[a],u=Pt(e,c.path),l=!1,d;if(A(u!==null,"rerunTransactionsUnderNode_: relativePath should not be null."),c.status===4)l=!0,d=c.abortReason,i=i.concat(Zi(t.serverSyncTree_,c.currentWriteId,!0));else if(c.status===0)if(c.retryCount>=kne)l=!0,d="maxretry",i=i.concat(Zi(t.serverSyncTree_,c.currentWriteId,!0));else{let f=aR(t,c.path,s);c.currentInputSnapshot=f;let p=n[a].update(f.val());if(p!==void 0){om("transaction failed: Data returned ",p,c.path);let m=Qe(p);typeof p=="object"&&p!=null&&ln(p,".priority")||(m=m.updatePriority(f.getPriority()));let b=c.currentWriteId,E=HE(t),D=ZP(m,f,E);c.currentOutputSnapshotRaw=m,c.currentOutputSnapshotResolved=D,c.currentWriteId=sR(t),s.splice(s.indexOf(b),1),i=i.concat(GP(t.serverSyncTree_,c.path,D,c.currentWriteId,c.applyLocally)),i=i.concat(Zi(t.serverSyncTree_,b,!0))}else l=!0,d="nodata",i=i.concat(Zi(t.serverSyncTree_,c.currentWriteId,!0))}ir(t.eventQueue_,e,i),i=[],l&&(n[a].status=2,(function(f){setTimeout(f,Math.floor(0))})(n[a].unwatcher),n[a].onComplete&&(d==="nodata"?r.push(()=>n[a].onComplete(null,!1,n[a].currentInputSnapshot)):r.push(()=>n[a].onComplete(new Error(d),!1,null))))}am(t,t.transactionQueueTree_);for(let a=0;a<r.length;a++)ta(r[a]);WE(t,t.transactionQueueTree_)}function cR(t,n){let e,r=t.transactionQueueTree_;for(e=he(n);e!==null&&ra(r)===void 0;)r=$E(r,e),n=Fe(n),e=he(n);return r}function uR(t,n){let e=[];return lR(t,n,e),e.sort((r,i)=>r.order-i.order),e}function lR(t,n,e){let r=ra(n);if(r)for(let i=0;i<r.length;i++)e.push(r[i]);im(n,i=>{lR(t,i,e)})}function am(t,n){let e=ra(n);if(e){let r=0;for(let i=0;i<e.length;i++)e[i].status!==2&&(e[r]=e[i],r++);e.length=r,QP(n,e.length>0?e:void 0)}im(n,r=>{am(t,r)})}function dR(t,n){let e=Wc(cR(t,n)),r=$E(t.transactionQueueTree_,n);return Sne(r,i=>{ww(t,i)}),ww(t,r),XP(r,i=>{ww(t,i)}),e}function ww(t,n){let e=ra(n);if(e){let r=[],i=[],o=-1;for(let s=0;s<e.length;s++)e[s].status===3||(e[s].status===1?(A(o===s-1,"All SENT items should be at beginning of queue."),o=s,e[s].status=3,e[s].abortReason="set"):(A(e[s].status===0,"Unexpected transaction status in abort"),e[s].unwatcher(),i=i.concat(Zi(t.serverSyncTree_,e[s].currentWriteId,!0)),e[s].onComplete&&r.push(e[s].onComplete.bind(null,new Error("set"),!1,null))));o===-1?QP(n,void 0):e.length=o+1,ir(t.eventQueue_,Wc(n),i);for(let s=0;s<r.length;s++)ta(r[s])}}function zne(t){let n="",e=t.split("/");for(let r=0;r<e.length;r++)if(e[r].length>0){let i=e[r];try{i=decodeURIComponent(i.replace(/\+/g," "))}catch{}n+="/"+i}return n}function Kne(t){let n={};t.charAt(0)==="?"&&(t=t.substring(1));for(let e of t.split("&")){if(e.length===0)continue;let r=e.split("=");r.length===2?n[decodeURIComponent(r[0])]=decodeURIComponent(r[1]):Rt(`Invalid query segment '${e}' in query '${t}'`)}return n}var oP=function(t,n){let e=Yne(t),r=e.namespace;e.domain==="firebase.com"&&nr(e.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),(!r||r==="undefined")&&e.domain!=="localhost"&&nr("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),e.secure||Cee();let i=e.scheme==="ws"||e.scheme==="wss";return{repoInfo:new Np(e.host,e.secure,r,i,n,"",r!==e.subdomain),path:new Pe(e.pathString)}},Yne=function(t){let n="",e="",r="",i="",o="",s=!0,a="https",c=443;if(typeof t=="string"){let u=t.indexOf("//");u>=0&&(a=t.substring(0,u-1),t=t.substring(u+2));let l=t.indexOf("/");l===-1&&(l=t.length);let d=t.indexOf("?");d===-1&&(d=t.length),n=t.substring(0,Math.min(l,d)),l<d&&(i=zne(t.substring(l,d)));let f=Kne(t.substring(Math.min(t.length,d)));u=n.indexOf(":"),u>=0?(s=a==="https"||a==="wss",c=parseInt(n.substring(u+1),10)):u=n.length;let p=n.slice(0,u);if(p.toLowerCase()==="localhost")e="localhost";else if(p.split(".").length<=2)e=p;else{let m=n.indexOf(".");r=n.substring(0,m).toLowerCase(),e=n.substring(m+1),o=r}"ns"in f&&(o=f.ns)}return{host:n,port:c,domain:e,subdomain:r,secure:s,scheme:a,pathString:i,namespace:o}};var sP="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",Zne=(function(){let t=0,n=[];return function(e){let r=e===t;t=e;let i,o=new Array(8);for(i=7;i>=0;i--)o[i]=sP.charAt(e%64),e=Math.floor(e/64);A(e===0,"Cannot push at time == 0");let s=o.join("");if(r){for(i=11;i>=0&&n[i]===63;i--)n[i]=0;n[i]++}else for(i=0;i<12;i++)n[i]=Math.floor(Math.random()*64);for(i=0;i<12;i++)s+=sP.charAt(n[i]);return A(s.length===20,"nextPushId: Length should be 20."),s}})();var Zp=class{constructor(n,e,r,i){this.eventType=n,this.eventRegistration=e,this.snapshot=r,this.prevName=i}getPath(){let n=this.snapshot.ref;return this.eventType==="value"?n._path:n.parent._path}getEventType(){return this.eventType}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.getPath().toString()+":"+this.eventType+":"+nt(this.snapshot.exportVal())}},Qp=class{constructor(n,e,r){this.eventRegistration=n,this.error=e,this.path=r}getPath(){return this.path}getEventType(){return"cancel"}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.path.toString()+":cancel"}};var pE=class{constructor(n,e){this.snapshotCallback=n,this.cancelCallback=e}onValue(n,e){this.snapshotCallback.call(null,n,e)}onCancel(n){return A(this.hasCancelCallback,"Raising a cancel event on a listener with no cancel callback"),this.cancelCallback.call(null,n)}get hasCancelCallback(){return!!this.cancelCallback}matches(n){return this.snapshotCallback===n.snapshotCallback||this.snapshotCallback.userCallback!==void 0&&this.snapshotCallback.userCallback===n.snapshotCallback.userCallback&&this.snapshotCallback.context===n.snapshotCallback.context}};var mE=class{constructor(n,e){this._repo=n,this._path=e}cancel(){let n=new Wt;return qne(this._repo,this._path,n.wrapCallback(()=>{})),n.promise}remove(){Qi("OnDisconnect.remove",this._path);let n=new Wt;return rP(this._repo,this._path,null,n.wrapCallback(()=>{})),n.promise}set(n){Qi("OnDisconnect.set",this._path),Yp("OnDisconnect.set",n,this._path,!1);let e=new Wt;return rP(this._repo,this._path,n,e.wrapCallback(()=>{})),e.promise}setWithPriority(n,e){Qi("OnDisconnect.setWithPriority",this._path),Yp("OnDisconnect.setWithPriority",n,this._path,!1),Mne("OnDisconnect.setWithPriority",e,!1);let r=new Wt;return Bne(this._repo,this._path,n,e,r.wrapCallback(()=>{})),r.promise}update(n){Qi("OnDisconnect.update",this._path),One("OnDisconnect.update",n,this._path,!1);let e=new Wt;return Hne(this._repo,this._path,n,e.wrapCallback(()=>{})),e.promise}};var gE=class t{constructor(n,e,r,i){this._repo=n,this._path=e,this._queryParams=r,this._orderByCalled=i}get key(){return ye(this._path)?null:CE(this._path)}get ref(){return new or(this._repo,this._path)}get _queryIdentifier(){let n=HN(this._queryParams),e=wE(n);return e==="{}"?"default":e}get _queryObject(){return HN(this._queryParams)}isEqual(n){if(n=Jr(n),!(n instanceof t))return!1;let e=this._repo===n._repo,r=IE(this._path,n._path),i=this._queryIdentifier===n._queryIdentifier;return e&&r&&i}toJSON(){return this.toString()}toString(){return this._repo.toString()+ote(this._path)}};var or=class t extends gE{constructor(n,e){super(n,e,new Vw,!1)}get parent(){let n=TP(this._path);return n===null?null:new t(this._repo,n)}get root(){let n=this;for(;n.parent!==null;)n=n.parent;return n}},Jp=class t{constructor(n,e,r){this._node=n,this.ref=e,this._index=r}get priority(){return this._node.getPriority().val()}get key(){return this.ref.key}get size(){return this._node.numChildren()}child(n){let e=new Pe(n),r=ea(this.ref,n);return new t(this._node.getChild(e),r,Ye)}exists(){return!this._node.isEmpty()}exportVal(){return this._node.val(!0)}forEach(n){return this._node.isLeafNode()?!1:!!this._node.forEachChild(this._index,(r,i)=>n(new t(i,ea(this.ref,r),Ye)))}hasChild(n){let e=new Pe(n);return!this._node.getChild(e).isEmpty()}hasChildren(){return this._node.isLeafNode()?!1:!this._node.isEmpty()}toJSON(){return this.exportVal()}val(){return this._node.val()}};function sr(t,n){return t=Jr(t),t._checkNotDeleted("ref"),n!==void 0?ea(t._root,n):t._root}function ea(t,n){return t=Jr(t),he(t._path)===null?Ane("child","path",n,!1):nR("child","path",n,!1),new or(t._repo,Ze(t._path,n))}function fR(t){return t=Jr(t),new mE(t._repo,t._path)}function GE(t,n){t=Jr(t),Qi("push",t._path),Yp("push",n,t._path,!0);let e=oR(t._repo),r=Zne(e),i=ea(t,r),o=ea(t,r),s;return n!=null?s=cm(o,n).then(()=>o):s=Promise.resolve(o),i.then=s.then.bind(s),i.catch=s.then.bind(s,void 0),i}function hR(t){return Qi("remove",t._path),cm(t,null)}function cm(t,n){t=Jr(t),Qi("set",t._path),Yp("set",n,t._path,!1);let e=new Wt;return Fne(t._repo,t._path,n,null,e.wrapCallback(()=>{})),e.promise}var yE=class t{constructor(n){this.callbackContext=n}respondsTo(n){return n==="value"}createEvent(n,e){let r=e._queryParams.getIndex();return new Zp("value",this,new Jp(n.snapshotNode,new or(e._repo,e._path),r))}getEventRunner(n){return n.getEventType()==="cancel"?()=>this.callbackContext.onCancel(n.error):()=>this.callbackContext.onValue(n.snapshot,null)}createCancelEvent(n,e){return this.callbackContext.hasCancelCallback?new Qp(this,n,e):null}matches(n){return n instanceof t?!n.callbackContext||!this.callbackContext?!0:n.callbackContext.matches(this.callbackContext):!1}hasAnyCallback(){return this.callbackContext!==null}},vE=class t{constructor(n,e){this.eventType=n,this.callbackContext=e}respondsTo(n){let e=n==="children_added"?"child_added":n;return e=e==="children_removed"?"child_removed":e,this.eventType===e}createCancelEvent(n,e){return this.callbackContext.hasCancelCallback?new Qp(this,n,e):null}createEvent(n,e){A(n.childName!=null,"Child events should have a childName.");let r=ea(new or(e._repo,e._path),n.childName),i=e._queryParams.getIndex();return new Zp(n.type,this,new Jp(n.snapshotNode,r,i),n.prevName)}getEventRunner(n){return n.getEventType()==="cancel"?()=>this.callbackContext.onCancel(n.error):()=>this.callbackContext.onValue(n.snapshot,n.prevName)}matches(n){return n instanceof t?this.eventType===n.eventType&&(!this.callbackContext||!n.callbackContext||this.callbackContext.matches(n.callbackContext)):!1}hasAnyCallback(){return!!this.callbackContext}};function pR(t,n,e,r,i){let o;if(typeof r=="object"&&(o=void 0,i=r),typeof r=="function"&&(o=r),i&&i.onlyOnce){let c=e,u=(l,d)=>{iP(t._repo,t,a),c(l,d)};u.userCallback=e.userCallback,u.context=e.context,e=u}let s=new pE(e,o||void 0),a=n==="value"?new yE(s):new vE(n,s);return Une(t._repo,t,a),()=>iP(t._repo,t,a)}function um(t,n,e,r){return pR(t,"value",n,e,r)}function zE(t,n,e,r){return pR(t,"child_added",n,e,r)}ene(or);sne(or);var Qne="FIREBASE_DATABASE_EMULATOR_HOST",_E={},Jne=!1;function Xne(t,n,e,r){let i=n.lastIndexOf(":"),o=n.substring(0,i),s=Tp(o);t.repoInfo_=new Np(n,s,t.repoInfo_.namespace,t.repoInfo_.webSocketOnly,t.repoInfo_.nodeAdmin,t.repoInfo_.persistenceKey,t.repoInfo_.includeNamespaceInQueryParams,!0,e),r&&(t.authTokenProvider_=r)}function ere(t,n,e,r,i){let o=r||t.options.databaseURL;o===void 0&&(t.options.projectId||nr("Can't determine Firebase Database URL. Be sure to include a Project ID when calling firebase.initializeApp()."),pt("Using default host for project ",t.options.projectId),o=`${t.options.projectId}-default-rtdb.firebaseio.com`);let s=oP(o,i),a=s.repoInfo,c,u;typeof process<"u"&&process.env&&(u=process.env[Qne]),u?(c=!0,o=`http://${u}?ns=${a.namespace}`,s=oP(o,i),a=s.repoInfo):c=!s.repoInfo.secure;let l=i&&c?new Mc(Mc.OWNER):new Ow(t.name,t.options,n);Nne("Invalid Firebase Database URL",s),ye(s.path)||nr("Database URL must point to the root of a Firebase Database (not including a child path).");let d=nre(a,t,l,new Dw(t,e));return new bE(d,t)}function tre(t,n){let e=_E[n];(!e||e[t.key]!==t)&&nr(`Database ${n}(${t.repoInfo_}) has already been deleted.`),Vne(t),delete e[t.key]}function nre(t,n,e,r){let i=_E[n.name];i||(i={},_E[n.name]=i);let o=i[t.toURLString()];return o&&nr("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),o=new hE(t,Jne,e,r),i[t.toURLString()]=o,o}var bE=class{constructor(n,e){this._repoInternal=n,this.app=e,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(Lne(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new or(this._repo,Ne())),this._rootInternal}_delete(){return this._rootInternal!==null&&(tre(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(n){this._rootInternal===null&&nr("Cannot call "+n+" on a deleted database.")}};function mR(t=EN(),n){let e=_N(t,"database").getImmediate({identifier:n});if(!e._instanceStarted){let r=YA("database");r&&KE(e,...r)}return e}function KE(t,n,e,r={}){t=Jr(t),t._checkNotDeleted("useEmulator");let i=`${n}:${e}`,o=t._repoInternal;if(t._instanceStarted){if(i===t._repoInternal.repoInfo_.host&&$s(r,o.repoInfo_.emulatorOptions))return;nr("connectDatabaseEmulator() cannot initialize or alter the emulator configuration after the database instance has started.")}let s;if(o.repoInfo_.nodeAdmin)r.mockUserToken&&nr('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),s=new Mc(Mc.OWNER);else if(r.mockUserToken){let a=typeof r.mockUserToken=="string"?r.mockUserToken:QA(r.mockUserToken,t.app.options.projectId);s=new Mc(a)}Tp(n)&&(ZA(n),JA("Database",!0)),Xne(o,i,r,s)}function rre(t){Lee(wN),Ec(new er("database",(n,{instanceIdentifier:e})=>{let r=n.getProvider("app").getImmediate(),i=n.getProvider("auth-internal"),o=n.getProvider("app-check-internal");return ere(r,i,o,e)},"PUBLIC").setMultipleInstances(!0)),ei(xN,DN,t),ei(xN,DN,"esm2020")}TE.prototype.simpleListen=function(t,n){this.sendRequest("q",{p:t},n)};TE.prototype.echo=function(t,n){this.sendRequest("echo",{d:t},n)};$ee(wee.Client);rre("node");var m1e=j("FirebaseSignalingChannel"),g1e=240*1e3;function gR(t,n,e,r,i=new Date().toISOString()){let{component:o,package:s,...a}=e??{},c={ts:i,lvl:He[t],component:o??"unknown",msg:n};return s!=null&&(c.package=s),Object.keys(a).length>0&&(c.ctx=a),r!=null&&(c.err={message:r.message,stack:r.stack}),c}var ire={DEBUG:"\x1B[90m",INFO:"\x1B[36m",WARN:"\x1B[33m",ERROR:"\x1B[31m",FATAL:"\x1B[35m"},ore="\x1B[0m";function yR(t,n){let r=n?.color??!1?`${ire[t.lvl]??""}${t.lvl}${ore}`:t.lvl,i=t.package!=null?`[${t.package}][${t.component}]`:`[${t.component}]`,o=`[${t.ts}][${r}]${i} ${t.msg}`;return t.ctx!=null&&(o+=` ${JSON.stringify(t.ctx)}`),t.err!=null&&(o+=`
37
+ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(let e of this.listens.values())for(let r of e.values())this.sendListen_(r);for(let e=0;e<this.outstandingPuts_.length;e++)this.outstandingPuts_[e]&&this.sendPut_(e);for(;this.onDisconnectRequestQueue_.length;){let e=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(e.action,e.pathString,e.data,e.onComplete)}for(let e=0;e<this.outstandingGets_.length;e++)this.outstandingGets_[e]&&this.sendGet_(e)}sendConnectStats_(){let e={},r="js";Mn()&&(this.repoInfo_.nodeAdmin?r="admin_node":r="node"),e["sdk."+r+"."+SE.replace(/\./g,"-")]=1,Xb()?e["framework.cordova"]=1:XA()&&(e["framework.reactnative"]=1),this.reportStats(e)}shouldReconnect_(){let e=kp.getInstance().currentlyOnline();return xp(this.interruptReasons_)&&e}}t.nextPersistentConnectionId_=0,t.nextConnectionId_=0;return t})(),ve=class t{constructor(n,e){this.name=n,this.node=e}static Wrap(n,e){return new t(n,e)}};var zs=class{getCompare(){return this.compare.bind(this)}indexedValueChanged(n,e){let r=new ve(Gs,n),i=new ve(Gs,e);return this.compare(r,i)!==0}minPost(){return ve.MIN}};var Mp,Lp=class extends zs{static get __EMPTY_NODE(){return Mp}static set __EMPTY_NODE(n){Mp=n}compare(n,e){return to(n.name,e.name)}isDefinedOn(n){throw Vi("KeyIndex.isDefinedOn not expected to be called.")}indexedValueChanged(n,e){return!1}minPost(){return ve.MIN}maxPost(){return new ve(Xi,Mp)}makePost(n,e){return A(typeof n=="string","KeyIndex indexValue must always be a string."),new ve(n,Mp)}toString(){return".key"}},Vs=new Lp;var Hs=class{constructor(n,e,r,i,o=null){this.isReverse_=i,this.resultGenerator_=o,this.nodeStack_=[];let s=1;for(;!n.isEmpty();)if(n=n,s=e?r(n.key,e):1,i&&(s*=-1),s<0)this.isReverse_?n=n.left:n=n.right;else if(s===0){this.nodeStack_.push(n);break}else this.nodeStack_.push(n),this.isReverse_?n=n.right:n=n.left}getNext(){if(this.nodeStack_.length===0)return null;let n=this.nodeStack_.pop(),e;if(this.resultGenerator_?e=this.resultGenerator_(n.key,n.value):e={key:n.key,value:n.value},this.isReverse_)for(n=n.left;!n.isEmpty();)this.nodeStack_.push(n),n=n.right;else for(n=n.right;!n.isEmpty();)this.nodeStack_.push(n),n=n.left;return e}hasNext(){return this.nodeStack_.length>0}peek(){if(this.nodeStack_.length===0)return null;let n=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(n.key,n.value):{key:n.key,value:n.value}}},dn=(()=>{class t{constructor(e,r,i,o,s){this.key=e,this.value=r,this.color=i??t.RED,this.left=o??en.EMPTY_NODE,this.right=s??en.EMPTY_NODE}copy(e,r,i,o,s){return new t(e??this.key,r??this.value,i??this.color,o??this.left,s??this.right)}count(){return this.left.count()+1+this.right.count()}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||!!e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min_(){return this.left.isEmpty()?this:this.left.min_()}minKey(){return this.min_().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,r,i){let o=this,s=i(e,o.key);return s<0?o=o.copy(null,null,null,o.left.insert(e,r,i),null):s===0?o=o.copy(null,r,null,null,null):o=o.copy(null,null,null,null,o.right.insert(e,r,i)),o.fixUp_()}removeMin_(){if(this.left.isEmpty())return en.EMPTY_NODE;let e=this;return!e.left.isRed_()&&!e.left.left.isRed_()&&(e=e.moveRedLeft_()),e=e.copy(null,null,null,e.left.removeMin_(),null),e.fixUp_()}remove(e,r){let i,o;if(i=this,r(e,i.key)<0)!i.left.isEmpty()&&!i.left.isRed_()&&!i.left.left.isRed_()&&(i=i.moveRedLeft_()),i=i.copy(null,null,null,i.left.remove(e,r),null);else{if(i.left.isRed_()&&(i=i.rotateRight_()),!i.right.isEmpty()&&!i.right.isRed_()&&!i.right.left.isRed_()&&(i=i.moveRedRight_()),r(e,i.key)===0){if(i.right.isEmpty())return en.EMPTY_NODE;o=i.right.min_(),i=i.copy(o.key,o.value,null,null,i.right.removeMin_())}i=i.copy(null,null,null,null,i.right.remove(e,r))}return i.fixUp_()}isRed_(){return this.color}fixUp_(){let e=this;return e.right.isRed_()&&!e.left.isRed_()&&(e=e.rotateLeft_()),e.left.isRed_()&&e.left.left.isRed_()&&(e=e.rotateRight_()),e.left.isRed_()&&e.right.isRed_()&&(e=e.colorFlip_()),e}moveRedLeft_(){let e=this.colorFlip_();return e.right.left.isRed_()&&(e=e.copy(null,null,null,null,e.right.rotateRight_()),e=e.rotateLeft_(),e=e.colorFlip_()),e}moveRedRight_(){let e=this.colorFlip_();return e.left.left.isRed_()&&(e=e.rotateRight_(),e=e.colorFlip_()),e}rotateLeft_(){let e=this.copy(null,null,t.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight_(){let e=this.copy(null,null,t.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip_(){let e=this.left.copy(null,null,!this.left.color,null,null),r=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,r)}checkMaxDepth_(){let e=this.check_();return Math.pow(2,e)<=this.count()+1}check_(){if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");let e=this.left.check_();if(e!==this.right.check_())throw new Error("Black depths differ");return e+(this.isRed_()?0:1)}}return t.RED=!0,t.BLACK=!1,t})(),Lw=class{copy(n,e,r,i,o){return this}insert(n,e,r){return new dn(n,e,null)}remove(n,e){return this}count(){return 0}isEmpty(){return!0}inorderTraversal(n){return!1}reverseTraversal(n){return!1}minKey(){return null}maxKey(){return null}check_(){return 0}isRed_(){return!1}},en=class t{constructor(n,e=t.EMPTY_NODE){this.comparator_=n,this.root_=e}insert(n,e){return new t(this.comparator_,this.root_.insert(n,e,this.comparator_).copy(null,null,dn.BLACK,null,null))}remove(n){return new t(this.comparator_,this.root_.remove(n,this.comparator_).copy(null,null,dn.BLACK,null,null))}get(n){let e,r=this.root_;for(;!r.isEmpty();){if(e=this.comparator_(n,r.key),e===0)return r.value;e<0?r=r.left:e>0&&(r=r.right)}return null}getPredecessorKey(n){let e,r=this.root_,i=null;for(;!r.isEmpty();)if(e=this.comparator_(n,r.key),e===0){if(r.left.isEmpty())return i?i.key:null;for(r=r.left;!r.right.isEmpty();)r=r.right;return r.key}else e<0?r=r.left:e>0&&(i=r,r=r.right);throw new Error("Attempted to find predecessor key for a nonexistent key. What gives?")}isEmpty(){return this.root_.isEmpty()}count(){return this.root_.count()}minKey(){return this.root_.minKey()}maxKey(){return this.root_.maxKey()}inorderTraversal(n){return this.root_.inorderTraversal(n)}reverseTraversal(n){return this.root_.reverseTraversal(n)}getIterator(n){return new Hs(this.root_,null,this.comparator_,!1,n)}getIteratorFrom(n,e){return new Hs(this.root_,n,this.comparator_,!1,e)}getReverseIteratorFrom(n,e){return new Hs(this.root_,n,this.comparator_,!0,e)}getReverseIterator(n){return new Hs(this.root_,null,this.comparator_,!0,n)}};en.EMPTY_NODE=new Lw;function pte(t,n){return to(t.name,n.name)}function xE(t,n){return to(t,n)}var jw;function mte(t){jw=t}var DP=function(t){return typeof t=="number"?"number:"+_P(t):"string:"+t},OP=function(t){if(t.isLeafNode()){let n=t.val();A(typeof n=="string"||typeof n=="number"||typeof n=="object"&&ln(n,".sv"),"Priority must be a string or number.")}else A(t===jw||t.isEmpty(),"priority of unexpected type.");A(t===jw||t.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")};var qN,Ks=(()=>{class t{static set __childrenNodeConstructor(e){qN=e}static get __childrenNodeConstructor(){return qN}constructor(e,r=t.__childrenNodeConstructor.EMPTY_NODE){this.value_=e,this.priorityNode_=r,this.lazyHash_=null,A(this.value_!==void 0&&this.value_!==null,"LeafNode shouldn't be created with null/undefined value."),OP(this.priorityNode_)}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new t(this.value_,e)}getImmediateChild(e){return e===".priority"?this.priorityNode_:t.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return ye(e)?this:he(e)===".priority"?this.priorityNode_:t.__childrenNodeConstructor.EMPTY_NODE}hasChild(){return!1}getPredecessorChildName(e,r){return null}updateImmediateChild(e,r){return e===".priority"?this.updatePriority(r):r.isEmpty()&&e!==".priority"?this:t.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,r).updatePriority(this.priorityNode_)}updateChild(e,r){let i=he(e);return i===null?r:r.isEmpty()&&i!==".priority"?this:(A(i!==".priority"||ni(e)===1,".priority must be the last token in a path"),this.updateImmediateChild(i,t.__childrenNodeConstructor.EMPTY_NODE.updateChild(Fe(e),r)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(e,r){return!1}val(e){return e&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()}hash(){if(this.lazyHash_===null){let e="";this.priorityNode_.isEmpty()||(e+="priority:"+DP(this.priorityNode_.val())+":");let r=typeof this.value_;e+=r+":",r==="number"?e+=_P(this.value_):e+=this.value_,this.lazyHash_=yP(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===t.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof t.__childrenNodeConstructor?-1:(A(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){let r=typeof e.value_,i=typeof this.value_,o=t.VALUE_TYPE_ORDER.indexOf(r),s=t.VALUE_TYPE_ORDER.indexOf(i);return A(o>=0,"Unknown leaf type: "+r),A(s>=0,"Unknown leaf type: "+i),o===s?i==="object"?0:this.value_<e.value_?-1:this.value_===e.value_?0:1:s-o}withIndex(){return this}isIndexed(){return!0}equals(e){if(e===this)return!0;if(e.isLeafNode()){let r=e;return this.value_===r.value_&&this.priorityNode_.equals(r.priorityNode_)}else return!1}}t.VALUE_TYPE_ORDER=["object","boolean","number","string"];return t})(),MP,AP;function gte(t){MP=t}function yte(t){AP=t}var Fw=class extends zs{compare(n,e){let r=n.node.getPriority(),i=e.node.getPriority(),o=r.compareTo(i);return o===0?to(n.name,e.name):o}isDefinedOn(n){return!n.getPriority().isEmpty()}indexedValueChanged(n,e){return!n.getPriority().equals(e.getPriority())}minPost(){return ve.MIN}maxPost(){return new ve(Xi,new Ks("[PRIORITY-POST]",AP))}makePost(n,e){let r=MP(n);return new ve(e,new Ks("[PRIORITY-POST]",r))}toString(){return".priority"}},Ye=new Fw;var vte=Math.log(2),$w=class{constructor(n){let e=o=>parseInt(Math.log(o)/vte,10),r=o=>parseInt(Array(o+1).join("1"),2);this.count=e(n+1),this.current_=this.count-1;let i=r(this.count);this.bits_=n+1&i}nextBitIsOne(){let n=!(this.bits_&1<<this.current_);return this.current_--,n}},jp=function(t,n,e,r){t.sort(n);let i=function(c,u){let l=u-c,d,f;if(l===0)return null;if(l===1)return d=t[c],f=e?e(d):d,new dn(f,d.node,dn.BLACK,null,null);{let p=parseInt(l/2,10)+c,m=i(c,p),y=i(p+1,u);return d=t[p],f=e?e(d):d,new dn(f,d.node,dn.BLACK,m,y)}},o=function(c){let u=null,l=null,d=t.length,f=function(m,y){let b=d-m,E=d;d-=m;let D=i(b+1,E),T=t[b],K=e?e(T):T;p(new dn(K,T.node,y,null,D))},p=function(m){u?(u.left=m,u=m):(l=m,u=m)};for(let m=0;m<c.count;++m){let y=c.nextBitIsOne(),b=Math.pow(2,c.count-(m+1));y?f(b,dn.BLACK):(f(b,dn.BLACK),f(b,dn.RED))}return l},s=new $w(t.length),a=o(s);return new en(r||n,a)};var vw,Bs={},Ys=class t{static get Default(){return A(Bs&&Ye,"ChildrenNode.ts has not been loaded"),vw=vw||new t({".priority":Bs},{".priority":Ye}),vw}constructor(n,e){this.indexes_=n,this.indexSet_=e}get(n){let e=Wi(this.indexes_,n);if(!e)throw new Error("No index defined for "+n);return e instanceof en?e:null}hasIndex(n){return ln(this.indexSet_,n.toString())}addIndex(n,e){A(n!==Vs,"KeyIndex always exists and isn't meant to be added to the IndexMap.");let r=[],i=!1,o=e.getIterator(ve.Wrap),s=o.getNext();for(;s;)i=i||n.isDefinedOn(s.node),r.push(s),s=o.getNext();let a;i?a=jp(r,n.getCompare()):a=Bs;let c=n.toString(),u={...this.indexSet_};u[c]=n;let l={...this.indexes_};return l[c]=a,new t(l,u)}addToIndexes(n,e){let r=vc(this.indexes_,(i,o)=>{let s=Wi(this.indexSet_,o);if(A(s,"Missing index implementation for "+o),i===Bs)if(s.isDefinedOn(n.node)){let a=[],c=e.getIterator(ve.Wrap),u=c.getNext();for(;u;)u.name!==n.name&&a.push(u),u=c.getNext();return a.push(n),jp(a,s.getCompare())}else return Bs;else{let a=e.get(n.name),c=i;return a&&(c=c.remove(new ve(n.name,a))),c.insert(n,n.node)}});return new t(r,this.indexSet_)}removeFromIndexes(n,e){let r=vc(this.indexes_,i=>{if(i===Bs)return i;{let o=e.get(n.name);return o?i.remove(new ve(n.name,o)):i}});return new t(r,this.indexSet_)}};var xc,ce=(()=>{class t{static get EMPTY_NODE(){return xc||(xc=new t(new en(xE),null,Ys.Default))}constructor(e,r,i){this.children_=e,this.priorityNode_=r,this.indexMap_=i,this.lazyHash_=null,this.priorityNode_&&OP(this.priorityNode_),this.children_.isEmpty()&&A(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}isLeafNode(){return!1}getPriority(){return this.priorityNode_||xc}updatePriority(e){return this.children_.isEmpty()?this:new t(this.children_,e,this.indexMap_)}getImmediateChild(e){if(e===".priority")return this.getPriority();{let r=this.children_.get(e);return r===null?xc:r}}getChild(e){let r=he(e);return r===null?this:this.getImmediateChild(r).getChild(Fe(e))}hasChild(e){return this.children_.get(e)!==null}updateImmediateChild(e,r){if(A(r,"We should always be passing snapshot nodes"),e===".priority")return this.updatePriority(r);{let i=new ve(e,r),o,s;r.isEmpty()?(o=this.children_.remove(e),s=this.indexMap_.removeFromIndexes(i,this.children_)):(o=this.children_.insert(e,r),s=this.indexMap_.addToIndexes(i,this.children_));let a=o.isEmpty()?xc:this.priorityNode_;return new t(o,a,s)}}updateChild(e,r){let i=he(e);if(i===null)return r;{A(he(e)!==".priority"||ni(e)===1,".priority must be the last token in a path");let o=this.getImmediateChild(i).updateChild(Fe(e),r);return this.updateImmediateChild(i,o)}}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(e){if(this.isEmpty())return null;let r={},i=0,o=0,s=!0;if(this.forEachChild(Ye,(a,c)=>{r[a]=c.val(e),i++,s&&t.INTEGER_REGEXP_.test(a)?o=Math.max(o,Number(a)):s=!1}),!e&&s&&o<2*i){let a=[];for(let c in r)a[c]=r[c];return a}else return e&&!this.getPriority().isEmpty()&&(r[".priority"]=this.getPriority().val()),r}hash(){if(this.lazyHash_===null){let e="";this.getPriority().isEmpty()||(e+="priority:"+DP(this.getPriority().val())+":"),this.forEachChild(Ye,(r,i)=>{let o=i.hash();o!==""&&(e+=":"+r+":"+o)}),this.lazyHash_=e===""?"":yP(e)}return this.lazyHash_}getPredecessorChildName(e,r,i){let o=this.resolveIndex_(i);if(o){let s=o.getPredecessorKey(new ve(e,r));return s?s.name:null}else return this.children_.getPredecessorKey(e)}getFirstChildName(e){let r=this.resolveIndex_(e);if(r){let i=r.minKey();return i&&i.name}else return this.children_.minKey()}getFirstChild(e){let r=this.getFirstChildName(e);return r?new ve(r,this.children_.get(r)):null}getLastChildName(e){let r=this.resolveIndex_(e);if(r){let i=r.maxKey();return i&&i.name}else return this.children_.maxKey()}getLastChild(e){let r=this.getLastChildName(e);return r?new ve(r,this.children_.get(r)):null}forEachChild(e,r){let i=this.resolveIndex_(e);return i?i.inorderTraversal(o=>r(o.name,o.node)):this.children_.inorderTraversal(r)}getIterator(e){return this.getIteratorFrom(e.minPost(),e)}getIteratorFrom(e,r){let i=this.resolveIndex_(r);if(i)return i.getIteratorFrom(e,o=>o);{let o=this.children_.getIteratorFrom(e.name,ve.Wrap),s=o.peek();for(;s!=null&&r.compare(s,e)<0;)o.getNext(),s=o.peek();return o}}getReverseIterator(e){return this.getReverseIteratorFrom(e.maxPost(),e)}getReverseIteratorFrom(e,r){let i=this.resolveIndex_(r);if(i)return i.getReverseIteratorFrom(e,o=>o);{let o=this.children_.getReverseIteratorFrom(e.name,ve.Wrap),s=o.peek();for(;s!=null&&r.compare(s,e)>0;)o.getNext(),s=o.peek();return o}}compareTo(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===Uc?-1:0}withIndex(e){if(e===Vs||this.indexMap_.hasIndex(e))return this;{let r=this.indexMap_.addIndex(e,this.children_);return new t(this.children_,this.priorityNode_,r)}}isIndexed(e){return e===Vs||this.indexMap_.hasIndex(e)}equals(e){if(e===this)return!0;if(e.isLeafNode())return!1;{let r=e;if(this.getPriority().equals(r.getPriority()))if(this.children_.count()===r.children_.count()){let i=this.getIterator(Ye),o=r.getIterator(Ye),s=i.getNext(),a=o.getNext();for(;s&&a;){if(s.name!==a.name||!s.node.equals(a.node))return!1;s=i.getNext(),a=o.getNext()}return s===null&&a===null}else return!1;else return!1}}resolveIndex_(e){return e===Vs?null:this.indexMap_.get(e.toString())}}return t.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/,t})(),qw=class extends ce{constructor(){super(new en(xE),ce.EMPTY_NODE,Ys.Default)}compareTo(n){return n===this?0:1}equals(n){return n===this}getPriority(){return this}getImmediateChild(n){return ce.EMPTY_NODE}isEmpty(){return!1}},Uc=new qw;Object.defineProperties(ve,{MIN:{value:new ve(Gs,ce.EMPTY_NODE)},MAX:{value:new ve(Xi,Uc)}});Lp.__EMPTY_NODE=ce.EMPTY_NODE;Ks.__childrenNodeConstructor=ce;mte(Uc);yte(Uc);var _te=!0;function Qe(t,n=null){if(t===null)return ce.EMPTY_NODE;if(typeof t=="object"&&".priority"in t&&(n=t[".priority"]),A(n===null||typeof n=="string"||typeof n=="number"||typeof n=="object"&&".sv"in n,"Invalid priority type found: "+typeof n),typeof t=="object"&&".value"in t&&t[".value"]!==null&&(t=t[".value"]),typeof t!="object"||".sv"in t){let e=t;return new Ks(e,Qe(n))}if(!(t instanceof Array)&&_te){let e=[],r=!1;if(bt(t,(s,a)=>{if(s.substring(0,1)!=="."){let c=Qe(a);c.isEmpty()||(r=r||!c.getPriority().isEmpty(),e.push(new ve(s,c)))}}),e.length===0)return ce.EMPTY_NODE;let o=jp(e,pte,s=>s.name,xE);if(r){let s=jp(e,Ye.getCompare());return new ce(o,Qe(n),new Ys({".priority":s},{".priority":Ye}))}else return new ce(o,Qe(n),Ys.Default)}else{let e=ce.EMPTY_NODE;return bt(t,(r,i)=>{if(ln(t,r)&&r.substring(0,1)!=="."){let o=Qe(i);(o.isLeafNode()||!o.isEmpty())&&(e=e.updateImmediateChild(r,o))}}),e.updatePriority(Qe(n))}}gte(Qe);var Bw=class extends zs{constructor(n){super(),this.indexPath_=n,A(!ye(n)&&he(n)!==".priority","Can't create PathIndex with empty path or .priority key")}extractChild(n){return n.getChild(this.indexPath_)}isDefinedOn(n){return!n.getChild(this.indexPath_).isEmpty()}compare(n,e){let r=this.extractChild(n.node),i=this.extractChild(e.node),o=r.compareTo(i);return o===0?to(n.name,e.name):o}makePost(n,e){let r=Qe(n),i=ce.EMPTY_NODE.updateChild(this.indexPath_,r);return new ve(e,i)}maxPost(){let n=ce.EMPTY_NODE.updateChild(this.indexPath_,Uc);return new ve(Xi,n)}toString(){return kc(this.indexPath_,0).join("/")}};var Hw=class extends zs{compare(n,e){let r=n.node.compareTo(e.node);return r===0?to(n.name,e.name):r}isDefinedOn(n){return!0}indexedValueChanged(n,e){return!n.equals(e)}minPost(){return ve.MIN}maxPost(){return ve.MAX}makePost(n,e){let r=Qe(n);return new ve(e,r)}toString(){return".value"}},bte=new Hw;function NP(t){return{type:"value",snapshotNode:t}}function Zs(t,n){return{type:"child_added",snapshotNode:n,childName:t}}function Lc(t,n){return{type:"child_removed",snapshotNode:n,childName:t}}function jc(t,n,e){return{type:"child_changed",snapshotNode:n,childName:t,oldSnap:e}}function wte(t,n){return{type:"child_moved",snapshotNode:n,childName:t}}var Fc=class{constructor(n){this.index_=n}updateChild(n,e,r,i,o,s){A(n.isIndexed(this.index_),"A node must be indexed if only a child is updated");let a=n.getImmediateChild(e);return a.getChild(i).equals(r.getChild(i))&&a.isEmpty()===r.isEmpty()||(s!=null&&(r.isEmpty()?n.hasChild(e)?s.trackChildChange(Lc(e,a)):A(n.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):a.isEmpty()?s.trackChildChange(Zs(e,r)):s.trackChildChange(jc(e,r,a))),n.isLeafNode()&&r.isEmpty())?n:n.updateImmediateChild(e,r).withIndex(this.index_)}updateFullNode(n,e,r){return r!=null&&(n.isLeafNode()||n.forEachChild(Ye,(i,o)=>{e.hasChild(i)||r.trackChildChange(Lc(i,o))}),e.isLeafNode()||e.forEachChild(Ye,(i,o)=>{if(n.hasChild(i)){let s=n.getImmediateChild(i);s.equals(o)||r.trackChildChange(jc(i,o,s))}else r.trackChildChange(Zs(i,o))})),e.withIndex(this.index_)}updatePriority(n,e){return n.isEmpty()?ce.EMPTY_NODE:n.updatePriority(e)}filtersNodes(){return!1}getIndexedFilter(){return this}getIndex(){return this.index_}};var Fp=class t{constructor(n){this.indexedFilter_=new Fc(n.getIndex()),this.index_=n.getIndex(),this.startPost_=t.getStartPost_(n),this.endPost_=t.getEndPost_(n),this.startIsInclusive_=!n.startAfterSet_,this.endIsInclusive_=!n.endBeforeSet_}getStartPost(){return this.startPost_}getEndPost(){return this.endPost_}matches(n){let e=this.startIsInclusive_?this.index_.compare(this.getStartPost(),n)<=0:this.index_.compare(this.getStartPost(),n)<0,r=this.endIsInclusive_?this.index_.compare(n,this.getEndPost())<=0:this.index_.compare(n,this.getEndPost())<0;return e&&r}updateChild(n,e,r,i,o,s){return this.matches(new ve(e,r))||(r=ce.EMPTY_NODE),this.indexedFilter_.updateChild(n,e,r,i,o,s)}updateFullNode(n,e,r){e.isLeafNode()&&(e=ce.EMPTY_NODE);let i=e.withIndex(this.index_);i=i.updatePriority(ce.EMPTY_NODE);let o=this;return e.forEachChild(Ye,(s,a)=>{o.matches(new ve(s,a))||(i=i.updateImmediateChild(s,ce.EMPTY_NODE))}),this.indexedFilter_.updateFullNode(n,i,r)}updatePriority(n,e){return n}filtersNodes(){return!0}getIndexedFilter(){return this.indexedFilter_}getIndex(){return this.index_}static getStartPost_(n){if(n.hasStart()){let e=n.getIndexStartName();return n.getIndex().makePost(n.getIndexStartValue(),e)}else return n.getIndex().minPost()}static getEndPost_(n){if(n.hasEnd()){let e=n.getIndexEndName();return n.getIndex().makePost(n.getIndexEndValue(),e)}else return n.getIndex().maxPost()}};var Uw=class{constructor(n){this.withinDirectionalStart=e=>this.reverse_?this.withinEndPost(e):this.withinStartPost(e),this.withinDirectionalEnd=e=>this.reverse_?this.withinStartPost(e):this.withinEndPost(e),this.withinStartPost=e=>{let r=this.index_.compare(this.rangedFilter_.getStartPost(),e);return this.startIsInclusive_?r<=0:r<0},this.withinEndPost=e=>{let r=this.index_.compare(e,this.rangedFilter_.getEndPost());return this.endIsInclusive_?r<=0:r<0},this.rangedFilter_=new Fp(n),this.index_=n.getIndex(),this.limit_=n.getLimit(),this.reverse_=!n.isViewFromLeft(),this.startIsInclusive_=!n.startAfterSet_,this.endIsInclusive_=!n.endBeforeSet_}updateChild(n,e,r,i,o,s){return this.rangedFilter_.matches(new ve(e,r))||(r=ce.EMPTY_NODE),n.getImmediateChild(e).equals(r)?n:n.numChildren()<this.limit_?this.rangedFilter_.getIndexedFilter().updateChild(n,e,r,i,o,s):this.fullLimitUpdateChild_(n,e,r,o,s)}updateFullNode(n,e,r){let i;if(e.isLeafNode()||e.isEmpty())i=ce.EMPTY_NODE.withIndex(this.index_);else if(this.limit_*2<e.numChildren()&&e.isIndexed(this.index_)){i=ce.EMPTY_NODE.withIndex(this.index_);let o;this.reverse_?o=e.getReverseIteratorFrom(this.rangedFilter_.getEndPost(),this.index_):o=e.getIteratorFrom(this.rangedFilter_.getStartPost(),this.index_);let s=0;for(;o.hasNext()&&s<this.limit_;){let a=o.getNext();if(this.withinDirectionalStart(a))if(this.withinDirectionalEnd(a))i=i.updateImmediateChild(a.name,a.node),s++;else break;else continue}}else{i=e.withIndex(this.index_),i=i.updatePriority(ce.EMPTY_NODE);let o;this.reverse_?o=i.getReverseIterator(this.index_):o=i.getIterator(this.index_);let s=0;for(;o.hasNext();){let a=o.getNext();s<this.limit_&&this.withinDirectionalStart(a)&&this.withinDirectionalEnd(a)?s++:i=i.updateImmediateChild(a.name,ce.EMPTY_NODE)}}return this.rangedFilter_.getIndexedFilter().updateFullNode(n,i,r)}updatePriority(n,e){return n}filtersNodes(){return!0}getIndexedFilter(){return this.rangedFilter_.getIndexedFilter()}getIndex(){return this.index_}fullLimitUpdateChild_(n,e,r,i,o){let s;if(this.reverse_){let d=this.index_.getCompare();s=(f,p)=>d(p,f)}else s=this.index_.getCompare();let a=n;A(a.numChildren()===this.limit_,"");let c=new ve(e,r),u=this.reverse_?a.getFirstChild(this.index_):a.getLastChild(this.index_),l=this.rangedFilter_.matches(c);if(a.hasChild(e)){let d=a.getImmediateChild(e),f=i.getChildAfterChild(this.index_,u,this.reverse_);for(;f!=null&&(f.name===e||a.hasChild(f.name));)f=i.getChildAfterChild(this.index_,f,this.reverse_);let p=f==null?1:s(f,c);if(l&&!r.isEmpty()&&p>=0)return o?.trackChildChange(jc(e,r,d)),a.updateImmediateChild(e,r);{o?.trackChildChange(Lc(e,d));let y=a.updateImmediateChild(e,ce.EMPTY_NODE);return f!=null&&this.rangedFilter_.matches(f)?(o?.trackChildChange(Zs(f.name,f.node)),y.updateImmediateChild(f.name,f.node)):y}}else return r.isEmpty()?n:l&&s(u,c)>=0?(o!=null&&(o.trackChildChange(Lc(u.name,u.node)),o.trackChildChange(Zs(e,r))),a.updateImmediateChild(e,r).updateImmediateChild(u.name,ce.EMPTY_NODE)):n}};var Vw=class t{constructor(){this.limitSet_=!1,this.startSet_=!1,this.startNameSet_=!1,this.startAfterSet_=!1,this.endSet_=!1,this.endNameSet_=!1,this.endBeforeSet_=!1,this.limit_=0,this.viewFrom_="",this.indexStartValue_=null,this.indexStartName_="",this.indexEndValue_=null,this.indexEndName_="",this.index_=Ye}hasStart(){return this.startSet_}isViewFromLeft(){return this.viewFrom_===""?this.startSet_:this.viewFrom_==="l"}getIndexStartValue(){return A(this.startSet_,"Only valid if start has been set"),this.indexStartValue_}getIndexStartName(){return A(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:Gs}hasEnd(){return this.endSet_}getIndexEndValue(){return A(this.endSet_,"Only valid if end has been set"),this.indexEndValue_}getIndexEndName(){return A(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:Xi}hasLimit(){return this.limitSet_}hasAnchoredLimit(){return this.limitSet_&&this.viewFrom_!==""}getLimit(){return A(this.limitSet_,"Only valid if limit has been set"),this.limit_}getIndex(){return this.index_}loadsAllData(){return!(this.startSet_||this.endSet_||this.limitSet_)}isDefault(){return this.loadsAllData()&&this.index_===Ye}copy(){let n=new t;return n.limitSet_=this.limitSet_,n.limit_=this.limit_,n.startSet_=this.startSet_,n.startAfterSet_=this.startAfterSet_,n.indexStartValue_=this.indexStartValue_,n.startNameSet_=this.startNameSet_,n.indexStartName_=this.indexStartName_,n.endSet_=this.endSet_,n.endBeforeSet_=this.endBeforeSet_,n.indexEndValue_=this.indexEndValue_,n.endNameSet_=this.endNameSet_,n.indexEndName_=this.indexEndName_,n.index_=this.index_,n.viewFrom_=this.viewFrom_,n}};function Ete(t){return t.loadsAllData()?new Fc(t.getIndex()):t.hasLimit()?new Uw(t):new Fp(t)}function BN(t){let n={};if(t.isDefault())return n;let e;if(t.index_===Ye?e="$priority":t.index_===bte?e="$value":t.index_===Vs?e="$key":(A(t.index_ instanceof Bw,"Unrecognized index type!"),e=t.index_.toString()),n.orderBy=nt(e),t.startSet_){let r=t.startAfterSet_?"startAfter":"startAt";n[r]=nt(t.indexStartValue_),t.startNameSet_&&(n[r]+=","+nt(t.indexStartName_))}if(t.endSet_){let r=t.endBeforeSet_?"endBefore":"endAt";n[r]=nt(t.indexEndValue_),t.endNameSet_&&(n[r]+=","+nt(t.indexEndName_))}return t.limitSet_&&(t.isViewFromLeft()?n.limitToFirst=t.limit_:n.limitToLast=t.limit_),n}function HN(t){let n={};if(t.startSet_&&(n.sp=t.indexStartValue_,t.startNameSet_&&(n.sn=t.indexStartName_),n.sin=!t.startAfterSet_),t.endSet_&&(n.ep=t.indexEndValue_,t.endNameSet_&&(n.en=t.indexEndName_),n.ein=!t.endBeforeSet_),t.limitSet_){n.l=t.limit_;let e=t.viewFrom_;e===""&&(t.isViewFromLeft()?e="l":e="r"),n.vf=e}return t.index_!==Ye&&(n.i=t.index_.toString()),n}var Ww=class t extends Pp{reportStats(n){throw new Error("Method not implemented.")}static getListenId_(n,e){return e!==void 0?"tag$"+e:(A(n._queryParams.isDefault(),"should have a tag if it's not a default query."),n._path.toString())}constructor(n,e,r,i){super(),this.repoInfo_=n,this.onDataUpdate_=e,this.authTokenProvider_=r,this.appCheckTokenProvider_=i,this.log_=Hc("p:rest:"),this.listens_={}}listen(n,e,r,i){let o=n._path.toString();this.log_("Listen called for "+o+" "+n._queryIdentifier);let s=t.getListenId_(n,r),a={};this.listens_[s]=a;let c=BN(n._queryParams);this.restRequest_(o+".json",c,(u,l)=>{let d=l;if(u===404&&(d=null,u=null),u===null&&this.onDataUpdate_(o,d,!1,r),Wi(this.listens_,s)===a){let f;u?u===401?f="permission_denied":f="rest_error:"+u:f="ok",i(f,null)}})}unlisten(n,e){let r=t.getListenId_(n,e);delete this.listens_[r]}get(n){let e=BN(n._queryParams),r=n._path.toString(),i=new Wt;return this.restRequest_(r+".json",e,(o,s)=>{let a=s;o===404&&(a=null,o=null),o===null?(this.onDataUpdate_(r,a,!1,null),i.resolve(a)):i.reject(new Error(a))}),i.promise}refreshAuthToken(n){}restRequest_(n,e={},r){return e.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then(([i,o])=>{i&&i.accessToken&&(e.auth=i.accessToken),o&&o.token&&(e.ac=o.token);let s=(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host+n+"?ns="+this.repoInfo_.namespace+oN(e);this.log_("Sending REST request for "+s);let a=new XMLHttpRequest;a.onreadystatechange=()=>{if(r&&a.readyState===4){this.log_("REST Response for "+s+" received. status:",a.status,"response:",a.responseText);let c=null;if(a.status>=200&&a.status<300){try{c=Fs(a.responseText)}catch{Rt("Failed to parse JSON response for "+s+": "+a.responseText)}r(null,c)}else a.status!==401&&a.status!==404&&Rt("Got unsuccessful REST response for "+s+" Status: "+a.status),r(a.status);r=null}},a.open("GET",s,!0),a.send()})}};var Gw=class{constructor(){this.rootNode_=ce.EMPTY_NODE}getNode(n){return this.rootNode_.getChild(n)}updateSnapshot(n,e){this.rootNode_=this.rootNode_.updateChild(n,e)}};function $p(){return{value:null,children:new Map}}function na(t,n,e){if(ye(n))t.value=e,t.children.clear();else if(t.value!==null)t.value=t.value.updateChild(n,e);else{let r=he(n);t.children.has(r)||t.children.set(r,$p());let i=t.children.get(r);n=Fe(n),na(i,n,e)}}function zw(t,n){if(ye(n))return t.value=null,t.children.clear(),!0;if(t.value!==null){if(t.value.isLeafNode())return!1;{let e=t.value;return t.value=null,e.forEachChild(Ye,(r,i)=>{na(t,new Pe(r),i)}),zw(t,n)}}else if(t.children.size>0){let e=he(n);return n=Fe(n),t.children.has(e)&&zw(t.children.get(e),n)&&t.children.delete(e),t.children.size===0}else return!0}function Kw(t,n,e){t.value!==null?e(n,t.value):Ste(t,(r,i)=>{let o=new Pe(n.toString()+"/"+r);Kw(i,o,e)})}function Ste(t,n){t.children.forEach((e,r)=>{n(r,e)})}var Yw=class{constructor(n){this.collection_=n,this.last_=null}get(){let n=this.collection_.get(),e={...n};return this.last_&&bt(this.last_,(r,i)=>{e[r]=e[r]-i}),this.last_=n,e}};var UN=10*1e3,Cte=30*1e3,Ite=300*1e3,Zw=class{constructor(n,e){this.server_=e,this.statsToReport_={},this.statsListener_=new Yw(n);let r=UN+(Cte-UN)*Math.random();Oc(this.reportStats_.bind(this),Math.floor(r))}reportStats_(){let n=this.statsListener_.get(),e={},r=!1;bt(n,(i,o)=>{o>0&&ln(this.statsToReport_,i)&&(e[i]=o,r=!0)}),r&&this.server_.reportStats(e),Oc(this.reportStats_.bind(this),Math.floor(Math.random()*2*Ite))}};var Nn=(function(t){return t[t.OVERWRITE=0]="OVERWRITE",t[t.MERGE=1]="MERGE",t[t.ACK_USER_WRITE=2]="ACK_USER_WRITE",t[t.LISTEN_COMPLETE=3]="LISTEN_COMPLETE",t})(Nn||{});function PP(){return{fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}function DE(){return{fromUser:!1,fromServer:!0,queryId:null,tagged:!1}}function OE(t){return{fromUser:!1,fromServer:!0,queryId:t,tagged:!0}}var Qw=class t{constructor(n,e,r){this.path=n,this.affectedTree=e,this.revert=r,this.type=Nn.ACK_USER_WRITE,this.source=PP()}operationForChild(n){if(ye(this.path)){if(this.affectedTree.value!=null)return A(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;{let e=this.affectedTree.subtree(new Pe(n));return new t(Ne(),e,this.revert)}}else return A(he(this.path)===n,"operationForChild called for unrelated child."),new t(Fe(this.path),this.affectedTree,this.revert)}};var qp=class t{constructor(n,e){this.source=n,this.path=e,this.type=Nn.LISTEN_COMPLETE}operationForChild(n){return ye(this.path)?new t(this.source,Ne()):new t(this.source,Fe(this.path))}};var Qs=class t{constructor(n,e,r){this.source=n,this.path=e,this.snap=r,this.type=Nn.OVERWRITE}operationForChild(n){return ye(this.path)?new t(this.source,Ne(),this.snap.getImmediateChild(n)):new t(this.source,Fe(this.path),this.snap)}};var Bp=class t{constructor(n,e,r){this.source=n,this.path=e,this.children=r,this.type=Nn.MERGE}operationForChild(n){if(ye(this.path)){let e=this.children.subtree(new Pe(n));return e.isEmpty()?null:e.value?new Qs(this.source,Ne(),e.value):new t(this.source,Ne(),e)}else return A(he(this.path)===n,"Can't get a merge for a child not on the path of the operation"),new t(this.source,Fe(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}};var rr=class{constructor(n,e,r){this.node_=n,this.fullyInitialized_=e,this.filtered_=r}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(n){if(ye(n))return this.isFullyInitialized()&&!this.filtered_;let e=he(n);return this.isCompleteForChild(e)}isCompleteForChild(n){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(n)}getNode(){return this.node_}};var Jw=class{constructor(n){this.query_=n,this.index_=this.query_._queryParams.getIndex()}};function Tte(t,n,e,r){let i=[],o=[];return n.forEach(s=>{s.type==="child_changed"&&t.index_.indexedValueChanged(s.oldSnap,s.snapshotNode)&&o.push(wte(s.childName,s.snapshotNode))}),Dc(t,i,"child_removed",n,r,e),Dc(t,i,"child_added",n,r,e),Dc(t,i,"child_moved",o,r,e),Dc(t,i,"child_changed",n,r,e),Dc(t,i,"value",n,r,e),i}function Dc(t,n,e,r,i,o){let s=r.filter(a=>a.type===e);s.sort((a,c)=>Dte(t,a,c)),s.forEach(a=>{let c=xte(t,a,o);i.forEach(u=>{u.respondsTo(a.type)&&n.push(u.createEvent(c,t.query_))})})}function xte(t,n,e){return n.type==="value"||n.type==="child_removed"||(n.prevName=e.getPredecessorChildName(n.childName,n.snapshotNode,t.index_)),n}function Dte(t,n,e){if(n.childName==null||e.childName==null)throw Vi("Should only compare child_ events.");let r=new ve(n.childName,n.snapshotNode),i=new ve(e.childName,e.snapshotNode);return t.index_.compare(r,i)}function em(t,n){return{eventCache:t,serverCache:n}}function Ac(t,n,e,r){return em(new rr(n,e,r),t.serverCache)}function RP(t,n,e,r){return em(t.eventCache,new rr(n,e,r))}function Xw(t){return t.eventCache.isFullyInitialized()?t.eventCache.getNode():null}function eo(t){return t.serverCache.isFullyInitialized()?t.serverCache.getNode():null}var _w,Ote=()=>(_w||(_w=new en(xee)),_w),kt=class t{static fromObject(n){let e=new t(null);return bt(n,(r,i)=>{e=e.set(new Pe(r),i)}),e}constructor(n,e=Ote()){this.value=n,this.children=e}isEmpty(){return this.value===null&&this.children.isEmpty()}findRootMostMatchingPathAndValue(n,e){if(this.value!=null&&e(this.value))return{path:Ne(),value:this.value};if(ye(n))return null;{let r=he(n),i=this.children.get(r);if(i!==null){let o=i.findRootMostMatchingPathAndValue(Fe(n),e);return o!=null?{path:Ze(new Pe(r),o.path),value:o.value}:null}else return null}}findRootMostValueAndPath(n){return this.findRootMostMatchingPathAndValue(n,()=>!0)}subtree(n){if(ye(n))return this;{let e=he(n),r=this.children.get(e);return r!==null?r.subtree(Fe(n)):new t(null)}}set(n,e){if(ye(n))return new t(e,this.children);{let r=he(n),o=(this.children.get(r)||new t(null)).set(Fe(n),e),s=this.children.insert(r,o);return new t(this.value,s)}}remove(n){if(ye(n))return this.children.isEmpty()?new t(null):new t(null,this.children);{let e=he(n),r=this.children.get(e);if(r){let i=r.remove(Fe(n)),o;return i.isEmpty()?o=this.children.remove(e):o=this.children.insert(e,i),this.value===null&&o.isEmpty()?new t(null):new t(this.value,o)}else return this}}get(n){if(ye(n))return this.value;{let e=he(n),r=this.children.get(e);return r?r.get(Fe(n)):null}}setTree(n,e){if(ye(n))return e;{let r=he(n),o=(this.children.get(r)||new t(null)).setTree(Fe(n),e),s;return o.isEmpty()?s=this.children.remove(r):s=this.children.insert(r,o),new t(this.value,s)}}fold(n){return this.fold_(Ne(),n)}fold_(n,e){let r={};return this.children.inorderTraversal((i,o)=>{r[i]=o.fold_(Ze(n,i),e)}),e(n,this.value,r)}findOnPath(n,e){return this.findOnPath_(n,Ne(),e)}findOnPath_(n,e,r){let i=this.value?r(e,this.value):!1;if(i)return i;if(ye(n))return null;{let o=he(n),s=this.children.get(o);return s?s.findOnPath_(Fe(n),Ze(e,o),r):null}}foreachOnPath(n,e){return this.foreachOnPath_(n,Ne(),e)}foreachOnPath_(n,e,r){if(ye(n))return this;{this.value&&r(e,this.value);let i=he(n),o=this.children.get(i);return o?o.foreachOnPath_(Fe(n),Ze(e,i),r):new t(null)}}foreach(n){this.foreach_(Ne(),n)}foreach_(n,e){this.children.inorderTraversal((r,i)=>{i.foreach_(Ze(n,r),e)}),this.value&&e(n,this.value)}foreachChild(n){this.children.inorderTraversal((e,r)=>{r.value&&n(e,r.value)})}};var fn=class t{constructor(n){this.writeTree_=n}static empty(){return new t(new kt(null))}};function Nc(t,n,e){if(ye(n))return new fn(new kt(e));{let r=t.writeTree_.findRootMostValueAndPath(n);if(r!=null){let i=r.path,o=r.value,s=Pt(i,n);return o=o.updateChild(s,e),new fn(t.writeTree_.set(i,o))}else{let i=new kt(e),o=t.writeTree_.setTree(n,i);return new fn(o)}}}function VN(t,n,e){let r=t;return bt(e,(i,o)=>{r=Nc(r,Ze(n,i),o)}),r}function WN(t,n){if(ye(n))return fn.empty();{let e=t.writeTree_.setTree(n,new kt(null));return new fn(e)}}function eE(t,n){return no(t,n)!=null}function no(t,n){let e=t.writeTree_.findRootMostValueAndPath(n);return e!=null?t.writeTree_.get(e.path).getChild(Pt(e.path,n)):null}function GN(t){let n=[],e=t.writeTree_.value;return e!=null?e.isLeafNode()||e.forEachChild(Ye,(r,i)=>{n.push(new ve(r,i))}):t.writeTree_.children.inorderTraversal((r,i)=>{i.value!=null&&n.push(new ve(r,i.value))}),n}function ti(t,n){if(ye(n))return t;{let e=no(t,n);return e!=null?new fn(new kt(e)):new fn(t.writeTree_.subtree(n))}}function tE(t){return t.writeTree_.isEmpty()}function Js(t,n){return kP(Ne(),t.writeTree_,n)}function kP(t,n,e){if(n.value!=null)return e.updateChild(t,n.value);{let r=null;return n.children.inorderTraversal((i,o)=>{i===".priority"?(A(o.value!==null,"Priority writes must always be leaf nodes"),r=o.value):e=kP(Ze(t,i),o,e)}),!e.getChild(t).isEmpty()&&r!==null&&(e=e.updateChild(Ze(t,".priority"),r)),e}}function ME(t,n){return $P(n,t)}function Mte(t,n,e,r,i){A(r>t.lastWriteId,"Stacking an older write on top of newer ones"),i===void 0&&(i=!0),t.allWrites.push({path:n,snap:e,writeId:r,visible:i}),i&&(t.visibleWrites=Nc(t.visibleWrites,n,e)),t.lastWriteId=r}function Ate(t,n){for(let e=0;e<t.allWrites.length;e++){let r=t.allWrites[e];if(r.writeId===n)return r}return null}function Nte(t,n){let e=t.allWrites.findIndex(a=>a.writeId===n);A(e>=0,"removeWrite called with nonexistent writeId.");let r=t.allWrites[e];t.allWrites.splice(e,1);let i=r.visible,o=!1,s=t.allWrites.length-1;for(;i&&s>=0;){let a=t.allWrites[s];a.visible&&(s>=e&&Pte(a,r.path)?i=!1:Xt(r.path,a.path)&&(o=!0)),s--}if(i){if(o)return Rte(t),!0;if(r.snap)t.visibleWrites=WN(t.visibleWrites,r.path);else{let a=r.children;bt(a,c=>{t.visibleWrites=WN(t.visibleWrites,Ze(r.path,c))})}return!0}else return!1}function Pte(t,n){if(t.snap)return Xt(t.path,n);for(let e in t.children)if(t.children.hasOwnProperty(e)&&Xt(Ze(t.path,e),n))return!0;return!1}function Rte(t){t.visibleWrites=LP(t.allWrites,kte,Ne()),t.allWrites.length>0?t.lastWriteId=t.allWrites[t.allWrites.length-1].writeId:t.lastWriteId=-1}function kte(t){return t.visible}function LP(t,n,e){let r=fn.empty();for(let i=0;i<t.length;++i){let o=t[i];if(n(o)){let s=o.path,a;if(o.snap)Xt(e,s)?(a=Pt(e,s),r=Nc(r,a,o.snap)):Xt(s,e)&&(a=Pt(s,e),r=Nc(r,Ne(),o.snap.getChild(a)));else if(o.children){if(Xt(e,s))a=Pt(e,s),r=VN(r,a,o.children);else if(Xt(s,e))if(a=Pt(s,e),ye(a))r=VN(r,Ne(),o.children);else{let c=Wi(o.children,he(a));if(c){let u=c.getChild(Fe(a));r=Nc(r,Ne(),u)}}}else throw Vi("WriteRecord should have .snap or .children")}}return r}function jP(t,n,e,r,i){if(!r&&!i){let o=no(t.visibleWrites,n);if(o!=null)return o;{let s=ti(t.visibleWrites,n);if(tE(s))return e;if(e==null&&!eE(s,Ne()))return null;{let a=e||ce.EMPTY_NODE;return Js(s,a)}}}else{let o=ti(t.visibleWrites,n);if(!i&&tE(o))return e;if(!i&&e==null&&!eE(o,Ne()))return null;{let s=function(u){return(u.visible||i)&&(!r||!~r.indexOf(u.writeId))&&(Xt(u.path,n)||Xt(n,u.path))},a=LP(t.allWrites,s,n),c=e||ce.EMPTY_NODE;return Js(a,c)}}}function Lte(t,n,e){let r=ce.EMPTY_NODE,i=no(t.visibleWrites,n);if(i)return i.isLeafNode()||i.forEachChild(Ye,(o,s)=>{r=r.updateImmediateChild(o,s)}),r;if(e){let o=ti(t.visibleWrites,n);return e.forEachChild(Ye,(s,a)=>{let c=Js(ti(o,new Pe(s)),a);r=r.updateImmediateChild(s,c)}),GN(o).forEach(s=>{r=r.updateImmediateChild(s.name,s.node)}),r}else{let o=ti(t.visibleWrites,n);return GN(o).forEach(s=>{r=r.updateImmediateChild(s.name,s.node)}),r}}function jte(t,n,e,r,i){A(r||i,"Either existingEventSnap or existingServerSnap must exist");let o=Ze(n,e);if(eE(t.visibleWrites,o))return null;{let s=ti(t.visibleWrites,o);return tE(s)?i.getChild(e):Js(s,i.getChild(e))}}function Fte(t,n,e,r){let i=Ze(n,e),o=no(t.visibleWrites,i);if(o!=null)return o;if(r.isCompleteForChild(e)){let s=ti(t.visibleWrites,i);return Js(s,r.getNode().getImmediateChild(e))}else return null}function $te(t,n){return no(t.visibleWrites,n)}function qte(t,n,e,r,i,o,s){let a,c=ti(t.visibleWrites,n),u=no(c,Ne());if(u!=null)a=u;else if(e!=null)a=Js(c,e);else return[];if(a=a.withIndex(s),!a.isEmpty()&&!a.isLeafNode()){let l=[],d=s.getCompare(),f=o?a.getReverseIteratorFrom(r,s):a.getIteratorFrom(r,s),p=f.getNext();for(;p&&l.length<i;)d(p,r)!==0&&l.push(p),p=f.getNext();return l}else return[]}function Bte(){return{visibleWrites:fn.empty(),allWrites:[],lastWriteId:-1}}function Hp(t,n,e,r){return jP(t.writeTree,t.treePath,n,e,r)}function AE(t,n){return Lte(t.writeTree,t.treePath,n)}function zN(t,n,e,r){return jte(t.writeTree,t.treePath,n,e,r)}function Up(t,n){return $te(t.writeTree,Ze(t.treePath,n))}function Hte(t,n,e,r,i,o){return qte(t.writeTree,t.treePath,n,e,r,i,o)}function NE(t,n,e){return Fte(t.writeTree,t.treePath,n,e)}function FP(t,n){return $P(Ze(t.treePath,n),t.writeTree)}function $P(t,n){return{treePath:t,writeTree:n}}var nE=class{constructor(){this.changeMap=new Map}trackChildChange(n){let e=n.type,r=n.childName;A(e==="child_added"||e==="child_changed"||e==="child_removed","Only child changes supported for tracking"),A(r!==".priority","Only non-priority child changes can be tracked.");let i=this.changeMap.get(r);if(i){let o=i.type;if(e==="child_added"&&o==="child_removed")this.changeMap.set(r,jc(r,n.snapshotNode,i.snapshotNode));else if(e==="child_removed"&&o==="child_added")this.changeMap.delete(r);else if(e==="child_removed"&&o==="child_changed")this.changeMap.set(r,Lc(r,i.oldSnap));else if(e==="child_changed"&&o==="child_added")this.changeMap.set(r,Zs(r,n.snapshotNode));else if(e==="child_changed"&&o==="child_changed")this.changeMap.set(r,jc(r,n.snapshotNode,i.oldSnap));else throw Vi("Illegal combination of changes: "+n+" occurred after "+i)}else this.changeMap.set(r,n)}getChanges(){return Array.from(this.changeMap.values())}};var rE=class{getCompleteChild(n){return null}getChildAfterChild(n,e,r){return null}},qP=new rE,$c=class{constructor(n,e,r=null){this.writes_=n,this.viewCache_=e,this.optCompleteServerCache_=r}getCompleteChild(n){let e=this.viewCache_.eventCache;if(e.isCompleteForChild(n))return e.getNode().getImmediateChild(n);{let r=this.optCompleteServerCache_!=null?new rr(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return NE(this.writes_,n,r)}}getChildAfterChild(n,e,r){let i=this.optCompleteServerCache_!=null?this.optCompleteServerCache_:eo(this.viewCache_),o=Hte(this.writes_,i,e,1,r,n);return o.length===0?null:o[0]}};function Ute(t){return{filter:t}}function Vte(t,n){A(n.eventCache.getNode().isIndexed(t.filter.getIndex()),"Event snap not indexed"),A(n.serverCache.getNode().isIndexed(t.filter.getIndex()),"Server snap not indexed")}function Wte(t,n,e,r,i){let o=new nE,s,a;if(e.type===Nn.OVERWRITE){let u=e;u.source.fromUser?s=iE(t,n,u.path,u.snap,r,i,o):(A(u.source.fromServer,"Unknown source."),a=u.source.tagged||n.serverCache.isFiltered()&&!ye(u.path),s=Vp(t,n,u.path,u.snap,r,i,a,o))}else if(e.type===Nn.MERGE){let u=e;u.source.fromUser?s=zte(t,n,u.path,u.children,r,i,o):(A(u.source.fromServer,"Unknown source."),a=u.source.tagged||n.serverCache.isFiltered(),s=oE(t,n,u.path,u.children,r,i,a,o))}else if(e.type===Nn.ACK_USER_WRITE){let u=e;u.revert?s=Zte(t,n,u.path,r,i,o):s=Kte(t,n,u.path,u.affectedTree,r,i,o)}else if(e.type===Nn.LISTEN_COMPLETE)s=Yte(t,n,e.path,r,o);else throw Vi("Unknown operation type: "+e.type);let c=o.getChanges();return Gte(n,s,c),{viewCache:s,changes:c}}function Gte(t,n,e){let r=n.eventCache;if(r.isFullyInitialized()){let i=r.getNode().isLeafNode()||r.getNode().isEmpty(),o=Xw(t);(e.length>0||!t.eventCache.isFullyInitialized()||i&&!r.getNode().equals(o)||!r.getNode().getPriority().equals(o.getPriority()))&&e.push(NP(Xw(n)))}}function BP(t,n,e,r,i,o){let s=n.eventCache;if(Up(r,e)!=null)return n;{let a,c;if(ye(e))if(A(n.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),n.serverCache.isFiltered()){let u=eo(n),l=u instanceof ce?u:ce.EMPTY_NODE,d=AE(r,l);a=t.filter.updateFullNode(n.eventCache.getNode(),d,o)}else{let u=Hp(r,eo(n));a=t.filter.updateFullNode(n.eventCache.getNode(),u,o)}else{let u=he(e);if(u===".priority"){A(ni(e)===1,"Can't have a priority with additional path components");let l=s.getNode();c=n.serverCache.getNode();let d=zN(r,e,l,c);d!=null?a=t.filter.updatePriority(l,d):a=s.getNode()}else{let l=Fe(e),d;if(s.isCompleteForChild(u)){c=n.serverCache.getNode();let f=zN(r,e,s.getNode(),c);f!=null?d=s.getNode().getImmediateChild(u).updateChild(l,f):d=s.getNode().getImmediateChild(u)}else d=NE(r,u,n.serverCache);d!=null?a=t.filter.updateChild(s.getNode(),u,d,l,i,o):a=s.getNode()}}return Ac(n,a,s.isFullyInitialized()||ye(e),t.filter.filtersNodes())}}function Vp(t,n,e,r,i,o,s,a){let c=n.serverCache,u,l=s?t.filter:t.filter.getIndexedFilter();if(ye(e))u=l.updateFullNode(c.getNode(),r,null);else if(l.filtersNodes()&&!c.isFiltered()){let p=c.getNode().updateChild(e,r);u=l.updateFullNode(c.getNode(),p,null)}else{let p=he(e);if(!c.isCompleteForPath(e)&&ni(e)>1)return n;let m=Fe(e),b=c.getNode().getImmediateChild(p).updateChild(m,r);p===".priority"?u=l.updatePriority(c.getNode(),b):u=l.updateChild(c.getNode(),p,b,m,qP,null)}let d=RP(n,u,c.isFullyInitialized()||ye(e),l.filtersNodes()),f=new $c(i,d,o);return BP(t,d,e,i,f,a)}function iE(t,n,e,r,i,o,s){let a=n.eventCache,c,u,l=new $c(i,n,o);if(ye(e))u=t.filter.updateFullNode(n.eventCache.getNode(),r,s),c=Ac(n,u,!0,t.filter.filtersNodes());else{let d=he(e);if(d===".priority")u=t.filter.updatePriority(n.eventCache.getNode(),r),c=Ac(n,u,a.isFullyInitialized(),a.isFiltered());else{let f=Fe(e),p=a.getNode().getImmediateChild(d),m;if(ye(f))m=r;else{let y=l.getCompleteChild(d);y!=null?CE(f)===".priority"&&y.getChild(TP(f)).isEmpty()?m=y:m=y.updateChild(f,r):m=ce.EMPTY_NODE}if(p.equals(m))c=n;else{let y=t.filter.updateChild(a.getNode(),d,m,f,l,s);c=Ac(n,y,a.isFullyInitialized(),t.filter.filtersNodes())}}}return c}function KN(t,n){return t.eventCache.isCompleteForChild(n)}function zte(t,n,e,r,i,o,s){let a=n;return r.foreach((c,u)=>{let l=Ze(e,c);KN(n,he(l))&&(a=iE(t,a,l,u,i,o,s))}),r.foreach((c,u)=>{let l=Ze(e,c);KN(n,he(l))||(a=iE(t,a,l,u,i,o,s))}),a}function YN(t,n,e){return e.foreach((r,i)=>{n=n.updateChild(r,i)}),n}function oE(t,n,e,r,i,o,s,a){if(n.serverCache.getNode().isEmpty()&&!n.serverCache.isFullyInitialized())return n;let c=n,u;ye(e)?u=r:u=new kt(null).setTree(e,r);let l=n.serverCache.getNode();return u.children.inorderTraversal((d,f)=>{if(l.hasChild(d)){let p=n.serverCache.getNode().getImmediateChild(d),m=YN(t,p,f);c=Vp(t,c,new Pe(d),m,i,o,s,a)}}),u.children.inorderTraversal((d,f)=>{let p=!n.serverCache.isCompleteForChild(d)&&f.value===null;if(!l.hasChild(d)&&!p){let m=n.serverCache.getNode().getImmediateChild(d),y=YN(t,m,f);c=Vp(t,c,new Pe(d),y,i,o,s,a)}}),c}function Kte(t,n,e,r,i,o,s){if(Up(i,e)!=null)return n;let a=n.serverCache.isFiltered(),c=n.serverCache;if(r.value!=null){if(ye(e)&&c.isFullyInitialized()||c.isCompleteForPath(e))return Vp(t,n,e,c.getNode().getChild(e),i,o,a,s);if(ye(e)){let u=new kt(null);return c.getNode().forEachChild(Vs,(l,d)=>{u=u.set(new Pe(l),d)}),oE(t,n,e,u,i,o,a,s)}else return n}else{let u=new kt(null);return r.foreach((l,d)=>{let f=Ze(e,l);c.isCompleteForPath(f)&&(u=u.set(l,c.getNode().getChild(f)))}),oE(t,n,e,u,i,o,a,s)}}function Yte(t,n,e,r,i){let o=n.serverCache,s=RP(n,o.getNode(),o.isFullyInitialized()||ye(e),o.isFiltered());return BP(t,s,e,r,qP,i)}function Zte(t,n,e,r,i,o){let s;if(Up(r,e)!=null)return n;{let a=new $c(r,n,i),c=n.eventCache.getNode(),u;if(ye(e)||he(e)===".priority"){let l;if(n.serverCache.isFullyInitialized())l=Hp(r,eo(n));else{let d=n.serverCache.getNode();A(d instanceof ce,"serverChildren would be complete if leaf node"),l=AE(r,d)}l=l,u=t.filter.updateFullNode(c,l,o)}else{let l=he(e),d=NE(r,l,n.serverCache);d==null&&n.serverCache.isCompleteForChild(l)&&(d=c.getImmediateChild(l)),d!=null?u=t.filter.updateChild(c,l,d,Fe(e),a,o):n.eventCache.getNode().hasChild(l)?u=t.filter.updateChild(c,l,ce.EMPTY_NODE,Fe(e),a,o):u=c,u.isEmpty()&&n.serverCache.isFullyInitialized()&&(s=Hp(r,eo(n)),s.isLeafNode()&&(u=t.filter.updateFullNode(u,s,o)))}return s=n.serverCache.isFullyInitialized()||Up(r,Ne())!=null,Ac(n,u,s,t.filter.filtersNodes())}}var sE=class{constructor(n,e){this.query_=n,this.eventRegistrations_=[];let r=this.query_._queryParams,i=new Fc(r.getIndex()),o=Ete(r);this.processor_=Ute(o);let s=e.serverCache,a=e.eventCache,c=i.updateFullNode(ce.EMPTY_NODE,s.getNode(),null),u=o.updateFullNode(ce.EMPTY_NODE,a.getNode(),null),l=new rr(c,s.isFullyInitialized(),i.filtersNodes()),d=new rr(u,a.isFullyInitialized(),o.filtersNodes());this.viewCache_=em(d,l),this.eventGenerator_=new Jw(this.query_)}get query(){return this.query_}};function Qte(t){return t.viewCache_.serverCache.getNode()}function Jte(t,n){let e=eo(t.viewCache_);return e&&(t.query._queryParams.loadsAllData()||!ye(n)&&!e.getImmediateChild(he(n)).isEmpty())?e.getChild(n):null}function ZN(t){return t.eventRegistrations_.length===0}function Xte(t,n){t.eventRegistrations_.push(n)}function QN(t,n,e){let r=[];if(e){A(n==null,"A cancel should cancel all event registrations.");let i=t.query._path;t.eventRegistrations_.forEach(o=>{let s=o.createCancelEvent(e,i);s&&r.push(s)})}if(n){let i=[];for(let o=0;o<t.eventRegistrations_.length;++o){let s=t.eventRegistrations_[o];if(!s.matches(n))i.push(s);else if(n.hasAnyCallback()){i=i.concat(t.eventRegistrations_.slice(o+1));break}}t.eventRegistrations_=i}else t.eventRegistrations_=[];return r}function JN(t,n,e,r){n.type===Nn.MERGE&&n.source.queryId!==null&&(A(eo(t.viewCache_),"We should always have a full cache before handling merges"),A(Xw(t.viewCache_),"Missing event cache, even though we have a server cache"));let i=t.viewCache_,o=Wte(t.processor_,i,n,e,r);return Vte(t.processor_,o.viewCache),A(o.viewCache.serverCache.isFullyInitialized()||!i.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),t.viewCache_=o.viewCache,HP(t,o.changes,o.viewCache.eventCache.getNode(),null)}function ene(t,n){let e=t.viewCache_.eventCache,r=[];return e.getNode().isLeafNode()||e.getNode().forEachChild(Ye,(o,s)=>{r.push(Zs(o,s))}),e.isFullyInitialized()&&r.push(NP(e.getNode())),HP(t,r,e.getNode(),n)}function HP(t,n,e,r){let i=r?[r]:t.eventRegistrations_;return Tte(t.eventGenerator_,n,e,i)}var Wp,aE=class{constructor(){this.views=new Map}};function tne(t){A(!Wp,"__referenceConstructor has already been defined"),Wp=t}function nne(){return A(Wp,"Reference.ts has not been loaded"),Wp}function rne(t){return t.views.size===0}function PE(t,n,e,r){let i=n.source.queryId;if(i!==null){let o=t.views.get(i);return A(o!=null,"SyncTree gave us an op for an invalid query."),JN(o,n,e,r)}else{let o=[];for(let s of t.views.values())o=o.concat(JN(s,n,e,r));return o}}function ine(t,n,e,r,i){let o=n._queryIdentifier,s=t.views.get(o);if(!s){let a=Hp(e,i?r:null),c=!1;a?c=!0:r instanceof ce?(a=AE(e,r),c=!1):(a=ce.EMPTY_NODE,c=!1);let u=em(new rr(a,c,!1),new rr(r,i,!1));return new sE(n,u)}return s}function one(t,n,e,r,i,o){let s=ine(t,n,r,i,o);return t.views.has(n._queryIdentifier)||t.views.set(n._queryIdentifier,s),Xte(s,e),ene(s,e)}function sne(t,n,e,r){let i=n._queryIdentifier,o=[],s=[],a=ri(t);if(i==="default")for(let[c,u]of t.views.entries())s=s.concat(QN(u,e,r)),ZN(u)&&(t.views.delete(c),u.query._queryParams.loadsAllData()||o.push(u.query));else{let c=t.views.get(i);c&&(s=s.concat(QN(c,e,r)),ZN(c)&&(t.views.delete(i),c.query._queryParams.loadsAllData()||o.push(c.query)))}return a&&!ri(t)&&o.push(new(nne())(n._repo,n._path)),{removed:o,events:s}}function UP(t){let n=[];for(let e of t.views.values())e.query._queryParams.loadsAllData()||n.push(e);return n}function Ws(t,n){let e=null;for(let r of t.views.values())e=e||Jte(r,n);return e}function VP(t,n){if(n._queryParams.loadsAllData())return tm(t);{let r=n._queryIdentifier;return t.views.get(r)}}function WP(t,n){return VP(t,n)!=null}function ri(t){return tm(t)!=null}function tm(t){for(let n of t.views.values())if(n.query._queryParams.loadsAllData())return n;return null}var Gp;function ane(t){A(!Gp,"__referenceConstructor has already been defined"),Gp=t}function cne(){return A(Gp,"Reference.ts has not been loaded"),Gp}var une=1,zp=class{constructor(n){this.listenProvider_=n,this.syncPointTree_=new kt(null),this.pendingWriteTree_=Bte(),this.tagToQueryMap=new Map,this.queryToTagMap=new Map}};function GP(t,n,e,r,i){return Mte(t.pendingWriteTree_,n,e,r,i),i?Vc(t,new Qs(PP(),n,e)):[]}function Zi(t,n,e=!1){let r=Ate(t.pendingWriteTree_,n);if(Nte(t.pendingWriteTree_,n)){let o=new kt(null);return r.snap!=null?o=o.set(Ne(),!0):bt(r.children,s=>{o=o.set(new Pe(s),!0)}),Vc(t,new Qw(r.path,o,e))}else return[]}function nm(t,n,e){return Vc(t,new Qs(DE(),n,e))}function lne(t,n,e){let r=kt.fromObject(e);return Vc(t,new Bp(DE(),n,r))}function dne(t,n){return Vc(t,new qp(DE(),n))}function fne(t,n,e){let r=kE(t,e);if(r){let i=LE(r),o=i.path,s=i.queryId,a=Pt(o,n),c=new qp(OE(s),a);return jE(t,o,c)}else return[]}function cE(t,n,e,r,i=!1){let o=n._path,s=t.syncPointTree_.get(o),a=[];if(s&&(n._queryIdentifier==="default"||WP(s,n))){let c=sne(s,n,e,r);rne(s)&&(t.syncPointTree_=t.syncPointTree_.remove(o));let u=c.removed;if(a=c.events,!i){let l=u.findIndex(f=>f._queryParams.loadsAllData())!==-1,d=t.syncPointTree_.findOnPath(o,(f,p)=>ri(p));if(l&&!d){let f=t.syncPointTree_.subtree(o);if(!f.isEmpty()){let p=mne(f);for(let m=0;m<p.length;++m){let y=p[m],b=y.query,E=YP(t,y);t.listenProvider_.startListening(Pc(b),Kp(t,b),E.hashFn,E.onComplete)}}}!d&&u.length>0&&!r&&(l?t.listenProvider_.stopListening(Pc(n),null):u.forEach(f=>{let p=t.queryToTagMap.get(rm(f));t.listenProvider_.stopListening(Pc(f),p)}))}gne(t,u)}return a}function hne(t,n,e,r){let i=kE(t,r);if(i!=null){let o=LE(i),s=o.path,a=o.queryId,c=Pt(s,n),u=new Qs(OE(a),c,e);return jE(t,s,u)}else return[]}function pne(t,n,e,r){let i=kE(t,r);if(i){let o=LE(i),s=o.path,a=o.queryId,c=Pt(s,n),u=kt.fromObject(e),l=new Bp(OE(a),c,u);return jE(t,s,l)}else return[]}function XN(t,n,e,r=!1){let i=n._path,o=null,s=!1;t.syncPointTree_.foreachOnPath(i,(f,p)=>{let m=Pt(f,i);o=o||Ws(p,m),s=s||ri(p)});let a=t.syncPointTree_.get(i);a?(s=s||ri(a),o=o||Ws(a,Ne())):(a=new aE,t.syncPointTree_=t.syncPointTree_.set(i,a));let c;o!=null?c=!0:(c=!1,o=ce.EMPTY_NODE,t.syncPointTree_.subtree(i).foreachChild((p,m)=>{let y=Ws(m,Ne());y&&(o=o.updateImmediateChild(p,y))}));let u=WP(a,n);if(!u&&!n._queryParams.loadsAllData()){let f=rm(n);A(!t.queryToTagMap.has(f),"View does not exist, but we have a tag");let p=yne();t.queryToTagMap.set(f,p),t.tagToQueryMap.set(p,f)}let l=ME(t.pendingWriteTree_,i),d=one(a,n,e,l,o,c);if(!u&&!s&&!r){let f=VP(a,n);d=d.concat(vne(t,n,f))}return d}function RE(t,n,e){let i=t.pendingWriteTree_,o=t.syncPointTree_.findOnPath(n,(s,a)=>{let c=Pt(s,n),u=Ws(a,c);if(u)return u});return jP(i,n,o,e,!0)}function Vc(t,n){return zP(n,t.syncPointTree_,null,ME(t.pendingWriteTree_,Ne()))}function zP(t,n,e,r){if(ye(t.path))return KP(t,n,e,r);{let i=n.get(Ne());e==null&&i!=null&&(e=Ws(i,Ne()));let o=[],s=he(t.path),a=t.operationForChild(s),c=n.children.get(s);if(c&&a){let u=e?e.getImmediateChild(s):null,l=FP(r,s);o=o.concat(zP(a,c,u,l))}return i&&(o=o.concat(PE(i,t,r,e))),o}}function KP(t,n,e,r){let i=n.get(Ne());e==null&&i!=null&&(e=Ws(i,Ne()));let o=[];return n.children.inorderTraversal((s,a)=>{let c=e?e.getImmediateChild(s):null,u=FP(r,s),l=t.operationForChild(s);l&&(o=o.concat(KP(l,a,c,u)))}),i&&(o=o.concat(PE(i,t,r,e))),o}function YP(t,n){let e=n.query,r=Kp(t,e);return{hashFn:()=>(Qte(n)||ce.EMPTY_NODE).hash(),onComplete:i=>{if(i==="ok")return r?fne(t,e._path,r):dne(t,e._path);{let o=Mee(i,e);return cE(t,e,null,o)}}}}function Kp(t,n){let e=rm(n);return t.queryToTagMap.get(e)}function rm(t){return t._path.toString()+"$"+t._queryIdentifier}function kE(t,n){return t.tagToQueryMap.get(n)}function LE(t){let n=t.indexOf("$");return A(n!==-1&&n<t.length-1,"Bad queryKey."),{queryId:t.substr(n+1),path:new Pe(t.substr(0,n))}}function jE(t,n,e){let r=t.syncPointTree_.get(n);A(r,"Missing sync point for query tag that we're tracking");let i=ME(t.pendingWriteTree_,n);return PE(r,e,i,null)}function mne(t){return t.fold((n,e,r)=>{if(e&&ri(e))return[tm(e)];{let i=[];return e&&(i=UP(e)),bt(r,(o,s)=>{i=i.concat(s)}),i}})}function Pc(t){return t._queryParams.loadsAllData()&&!t._queryParams.isDefault()?new(cne())(t._repo,t._path):t}function gne(t,n){for(let e=0;e<n.length;++e){let r=n[e];if(!r._queryParams.loadsAllData()){let i=rm(r),o=t.queryToTagMap.get(i);t.queryToTagMap.delete(i),t.tagToQueryMap.delete(o)}}}function yne(){return une++}function vne(t,n,e){let r=n._path,i=Kp(t,n),o=YP(t,e),s=t.listenProvider_.startListening(Pc(n),i,o.hashFn,o.onComplete),a=t.syncPointTree_.subtree(r);if(i)A(!ri(a.value),"If we're adding a query, it shouldn't be shadowed");else{let c=a.fold((u,l,d)=>{if(!ye(u)&&l&&ri(l))return[tm(l).query];{let f=[];return l&&(f=f.concat(UP(l).map(p=>p.query))),bt(d,(p,m)=>{f=f.concat(m)}),f}});for(let u=0;u<c.length;++u){let l=c[u];t.listenProvider_.stopListening(Pc(l),Kp(t,l))}}return s}var uE=class t{constructor(n){this.node_=n}getImmediateChild(n){let e=this.node_.getImmediateChild(n);return new t(e)}node(){return this.node_}},lE=class t{constructor(n,e){this.syncTree_=n,this.path_=e}getImmediateChild(n){let e=Ze(this.path_,n);return new t(this.syncTree_,e)}node(){return RE(this.syncTree_,this.path_)}},_ne=function(t){return t=t||{},t.timestamp=t.timestamp||new Date().getTime(),t},eP=function(t,n,e){if(!t||typeof t!="object")return t;if(A(".sv"in t,"Unexpected leaf node or priority contents"),typeof t[".sv"]=="string")return bne(t[".sv"],n,e);if(typeof t[".sv"]=="object")return wne(t[".sv"],n);A(!1,"Unexpected server value: "+JSON.stringify(t,null,2))},bne=function(t,n,e){if(t==="timestamp")return e.timestamp;A(!1,"Unexpected server value: "+t)},wne=function(t,n,e){t.hasOwnProperty("increment")||A(!1,"Unexpected server value: "+JSON.stringify(t,null,2));let r=t.increment;typeof r!="number"&&A(!1,"Unexpected increment value: "+r);let i=n.node();if(A(i!==null&&typeof i<"u","Expected ChildrenNode.EMPTY_NODE for nulls"),!i.isLeafNode())return r;let s=i.getValue();return typeof s!="number"?r:s+r},Ene=function(t,n,e,r){return FE(n,new lE(e,t),r)},ZP=function(t,n,e){return FE(t,new uE(n),e)};function FE(t,n,e){let r=t.getPriority().val(),i=eP(r,n.getImmediateChild(".priority"),e),o;if(t.isLeafNode()){let s=t,a=eP(s.getValue(),n,e);return a!==s.getValue()||i!==s.getPriority().val()?new Ks(a,Qe(i)):t}else{let s=t;return o=s,i!==s.getPriority().val()&&(o=o.updatePriority(new Ks(i))),s.forEachChild(Ye,(a,c)=>{let u=FE(c,n.getImmediateChild(a),e);u!==c&&(o=o.updateImmediateChild(a,u))}),o}}var qc=class{constructor(n="",e=null,r={children:{},childCount:0}){this.name=n,this.parent=e,this.node=r}};function $E(t,n){let e=n instanceof Pe?n:new Pe(n),r=t,i=he(e);for(;i!==null;){let o=Wi(r.node.children,i)||{children:{},childCount:0};r=new qc(i,r,o),e=Fe(e),i=he(e)}return r}function ra(t){return t.node.value}function QP(t,n){t.node.value=n,dE(t)}function JP(t){return t.node.childCount>0}function Sne(t){return ra(t)===void 0&&!JP(t)}function im(t,n){bt(t.node.children,(e,r)=>{n(new qc(e,t,r))})}function XP(t,n,e,r){e&&!r&&n(t),im(t,i=>{XP(i,n,!0,r)}),e&&r&&n(t)}function Cne(t,n,e){let r=e?t:t.parent;for(;r!==null;){if(n(r))return!0;r=r.parent}return!1}function Wc(t){return new Pe(t.parent===null?t.name:Wc(t.parent)+"/"+t.name)}function dE(t){t.parent!==null&&Ine(t.parent,t.name,t)}function Ine(t,n,e){let r=Sne(e),i=ln(t.node.children,n);r&&i?(delete t.node.children[n],t.node.childCount--,dE(t)):!r&&!i&&(t.node.children[n]=e.node,t.node.childCount++,dE(t))}var Tne=/[\[\].#$\/\u0000-\u001F\u007F]/,xne=/[\[\].#$\u0000-\u001F\u007F]/,bw=10*1024*1024,qE=function(t){return typeof t=="string"&&t.length!==0&&!Tne.test(t)},eR=function(t){return typeof t=="string"&&t.length!==0&&!xne.test(t)},Dne=function(t){return t&&(t=t.replace(/^\/*\.info(\/|$)/,"/")),eR(t)},tR=function(t){return t===null||typeof t=="string"||typeof t=="number"&&!Xp(t)||t&&typeof t=="object"&&ln(t,".sv")},Yp=function(t,n,e,r){r&&n===void 0||om(Gi(t,"value"),n,e)},om=function(t,n,e){let r=e instanceof Pe?new Rw(e,t):e;if(n===void 0)throw new Error(t+"contains undefined "+Ki(r));if(typeof n=="function")throw new Error(t+"contains a function "+Ki(r)+" with contents = "+n.toString());if(Xp(n))throw new Error(t+"contains "+n.toString()+" "+Ki(r));if(typeof n=="string"&&n.length>bw/3&&_c(n)>bw)throw new Error(t+"contains a string greater than "+bw+" utf8 bytes "+Ki(r)+" ('"+n.substring(0,50)+"...')");if(n&&typeof n=="object"){let i=!1,o=!1;if(bt(n,(s,a)=>{if(s===".value")i=!0;else if(s!==".priority"&&s!==".sv"&&(o=!0,!qE(s)))throw new Error(t+" contains an invalid key ("+s+") "+Ki(r)+`. Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"`);cte(r,s),om(t,a,r),ute(r)}),i&&o)throw new Error(t+' contains ".value" child '+Ki(r)+" in addition to actual children.")}},One=function(t,n){let e,r;for(e=0;e<n.length;e++){r=n[e];let o=kc(r);for(let s=0;s<o.length;s++)if(!(o[s]===".priority"&&s===o.length-1)){if(!qE(o[s]))throw new Error(t+"contains an invalid key ("+o[s]+") in path "+r.toString()+`. Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"`)}}n.sort(ate);let i=null;for(e=0;e<n.length;e++){if(r=n[e],i!==null&&Xt(i,r))throw new Error(t+"contains a path "+i.toString()+" that is ancestor of another path "+r.toString());i=r}},Mne=function(t,n,e,r){if(r&&n===void 0)return;let i=Gi(t,"values");if(!(n&&typeof n=="object")||Array.isArray(n))throw new Error(i+" must be an object containing the children to replace.");let o=[];bt(n,(s,a)=>{let c=new Pe(s);if(om(i,a,Ze(e,c)),CE(c)===".priority"&&!tR(a))throw new Error(i+"contains an invalid value for '"+c.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");o.push(c)}),One(i,o)},Ane=function(t,n,e){if(!(e&&n===void 0)){if(Xp(n))throw new Error(Gi(t,"priority")+"is "+n.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!tR(n))throw new Error(Gi(t,"priority")+"must be a valid Firebase priority (a string, finite number, server value, or null).")}};var nR=function(t,n,e,r){if(!(r&&e===void 0)&&!eR(e))throw new Error(Gi(t,n)+'was an invalid path = "'+e+`". Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]"`)},Nne=function(t,n,e,r){e&&(e=e.replace(/^\/*\.info(\/|$)/,"/")),nR(t,n,e,r)},Qi=function(t,n){if(he(n)===".info")throw new Error(t+" failed = Can't modify data under /.info/")},Pne=function(t,n){let e=n.path.toString();if(typeof n.repoInfo.host!="string"||n.repoInfo.host.length===0||!qE(n.repoInfo.namespace)&&n.repoInfo.host.split(":")[0]!=="localhost"||e.length!==0&&!Dne(e))throw new Error(Gi(t,"url")+`must be a valid firebase URL and the path can't contain ".", "#", "$", "[", or "]".`)};var fE=class{constructor(){this.eventLists_=[],this.recursionDepth_=0}};function BE(t,n){let e=null;for(let r=0;r<n.length;r++){let i=n[r],o=i.getPath();e!==null&&!IE(o,e.path)&&(t.eventLists_.push(e),e=null),e===null&&(e={events:[],path:o}),e.events.push(i)}e&&t.eventLists_.push(e)}function rR(t,n,e){BE(t,e),iR(t,r=>IE(r,n))}function ir(t,n,e){BE(t,e),iR(t,r=>Xt(r,n)||Xt(n,r))}function iR(t,n){t.recursionDepth_++;let e=!0;for(let r=0;r<t.eventLists_.length;r++){let i=t.eventLists_[r];if(i){let o=i.path;n(o)?(Rne(t.eventLists_[r]),t.eventLists_[r]=null):e=!1}}e&&(t.eventLists_=[]),t.recursionDepth_--}function Rne(t){for(let n=0;n<t.events.length;n++){let e=t.events[n];if(e!==null){t.events[n]=null;let r=e.getEventRunner();Ji&&pt("event: "+e.toString()),ta(r)}}}var kne="repo_interrupt",Lne=25,hE=class{constructor(n,e,r,i){this.repoInfo_=n,this.forceRestClient_=e,this.authTokenProvider_=r,this.appCheckProvider_=i,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new fE,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=$p(),this.transactionQueueTree_=new qc,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}};function jne(t,n,e){if(t.stats_=EE(t.repoInfo_),t.forceRestClient_||Ree())t.server_=new Ww(t.repoInfo_,(r,i,o,s)=>{tP(t,r,i,o,s)},t.authTokenProvider_,t.appCheckProvider_),setTimeout(()=>nP(t,!0),0);else{if(typeof e<"u"&&e!==null){if(typeof e!="object")throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{nt(e)}catch(r){throw new Error("Invalid authOverride provided: "+r)}}t.persistentConnection_=new TE(t.repoInfo_,n,(r,i,o,s)=>{tP(t,r,i,o,s)},r=>{nP(t,r)},r=>{Fne(t,r)},t.authTokenProvider_,t.appCheckProvider_,e),t.server_=t.persistentConnection_}t.authTokenProvider_.addTokenChangeListener(r=>{t.server_.refreshAuthToken(r)}),t.appCheckProvider_.addTokenChangeListener(r=>{t.server_.refreshAppCheckToken(r.token)}),t.statsReporter_=Lee(t.repoInfo_,()=>new Zw(t.stats_,t.server_)),t.infoData_=new Gw,t.infoSyncTree_=new zp({startListening:(r,i,o,s)=>{let a=[],c=t.infoData_.getNode(r._path);return c.isEmpty()||(a=nm(t.infoSyncTree_,r._path,c),setTimeout(()=>{s("ok")},0)),a},stopListening:()=>{}}),UE(t,"connected",!1),t.serverSyncTree_=new zp({startListening:(r,i,o,s)=>(t.server_.listen(r,o,i,(a,c)=>{let u=s(a,c);ir(t.eventQueue_,r._path,u)}),[]),stopListening:(r,i)=>{t.server_.unlisten(r,i)}})}function oR(t){let e=t.infoData_.getNode(new Pe(".info/serverTimeOffset")).val()||0;return new Date().getTime()+e}function HE(t){return _ne({timestamp:oR(t)})}function tP(t,n,e,r,i){t.dataUpdateCount++;let o=new Pe(n);e=t.interceptServerDataCallback_?t.interceptServerDataCallback_(n,e):e;let s=[];if(i)if(r){let c=vc(e,u=>Qe(u));s=pne(t.serverSyncTree_,o,c,i)}else{let c=Qe(e);s=hne(t.serverSyncTree_,o,c,i)}else if(r){let c=vc(e,u=>Qe(u));s=lne(t.serverSyncTree_,o,c)}else{let c=Qe(e);s=nm(t.serverSyncTree_,o,c)}let a=o;s.length>0&&(a=sm(t,o)),ir(t.eventQueue_,a,s)}function nP(t,n){UE(t,"connected",n),n===!1&&qne(t)}function Fne(t,n){bt(n,(e,r)=>{UE(t,e,r)})}function UE(t,n,e){let r=new Pe("/.info/"+n),i=Qe(e);t.infoData_.updateSnapshot(r,i);let o=nm(t.infoSyncTree_,r,i);ir(t.eventQueue_,r,o)}function sR(t){return t.nextWriteId_++}function $ne(t,n,e,r,i){VE(t,"set",{path:n.toString(),value:e,priority:r});let o=HE(t),s=Qe(e,r),a=RE(t.serverSyncTree_,n),c=ZP(s,a,o),u=sR(t),l=GP(t.serverSyncTree_,n,c,u,!0);BE(t.eventQueue_,l),t.server_.put(n.toString(),s.val(!0),(f,p)=>{let m=f==="ok";m||Rt("set at "+n+" failed: "+f);let y=Zi(t.serverSyncTree_,u,!m);ir(t.eventQueue_,n,y),Xs(t,i,f,p)});let d=dR(t,n);sm(t,d),ir(t.eventQueue_,d,[])}function qne(t){VE(t,"onDisconnectEvents");let n=HE(t),e=$p();Kw(t.onDisconnect_,Ne(),(i,o)=>{let s=Ene(i,o,t.serverSyncTree_,n);na(e,i,s)});let r=[];Kw(e,Ne(),(i,o)=>{r=r.concat(nm(t.serverSyncTree_,i,o));let s=dR(t,i);sm(t,s)}),t.onDisconnect_=$p(),ir(t.eventQueue_,Ne(),r)}function Bne(t,n,e){t.server_.onDisconnectCancel(n.toString(),(r,i)=>{r==="ok"&&zw(t.onDisconnect_,n),Xs(t,e,r,i)})}function rP(t,n,e,r){let i=Qe(e);t.server_.onDisconnectPut(n.toString(),i.val(!0),(o,s)=>{o==="ok"&&na(t.onDisconnect_,n,i),Xs(t,r,o,s)})}function Hne(t,n,e,r,i){let o=Qe(e,r);t.server_.onDisconnectPut(n.toString(),o.val(!0),(s,a)=>{s==="ok"&&na(t.onDisconnect_,n,o),Xs(t,i,s,a)})}function Une(t,n,e,r){if(xp(e)){pt("onDisconnect().update() called with empty data. Don't do anything."),Xs(t,r,"ok",void 0);return}t.server_.onDisconnectMerge(n.toString(),e,(i,o)=>{i==="ok"&&bt(e,(s,a)=>{let c=Qe(a);na(t.onDisconnect_,Ze(n,s),c)}),Xs(t,r,i,o)})}function Vne(t,n,e){let r;he(n._path)===".info"?r=XN(t.infoSyncTree_,n,e):r=XN(t.serverSyncTree_,n,e),rR(t.eventQueue_,n._path,r)}function iP(t,n,e){let r;he(n._path)===".info"?r=cE(t.infoSyncTree_,n,e):r=cE(t.serverSyncTree_,n,e),rR(t.eventQueue_,n._path,r)}function Wne(t){t.persistentConnection_&&t.persistentConnection_.interrupt(kne)}function VE(t,...n){let e="";t.persistentConnection_&&(e=t.persistentConnection_.id+":"),pt(e,...n)}function Xs(t,n,e,r){n&&ta(()=>{if(e==="ok")n(null);else{let i=(e||"error").toUpperCase(),o=i;r&&(o+=": "+r);let s=new Error(o);s.code=i,n(s)}})}function aR(t,n,e){return RE(t.serverSyncTree_,n,e)||ce.EMPTY_NODE}function WE(t,n=t.transactionQueueTree_){if(n||am(t,n),ra(n)){let e=uR(t,n);A(e.length>0,"Sending zero length transaction queue"),e.every(i=>i.status===0)&&Gne(t,Wc(n),e)}else JP(n)&&im(n,e=>{WE(t,e)})}function Gne(t,n,e){let r=e.map(u=>u.currentWriteId),i=aR(t,n,r),o=i,s=i.hash();for(let u=0;u<e.length;u++){let l=e[u];A(l.status===0,"tryToSendTransactionQueue_: items in queue should all be run."),l.status=1,l.retryCount++;let d=Pt(n,l.path);o=o.updateChild(d,l.currentOutputSnapshotRaw)}let a=o.val(!0),c=n;t.server_.put(c.toString(),a,u=>{VE(t,"transaction put response",{path:c.toString(),status:u});let l=[];if(u==="ok"){let d=[];for(let f=0;f<e.length;f++)e[f].status=2,l=l.concat(Zi(t.serverSyncTree_,e[f].currentWriteId)),e[f].onComplete&&d.push(()=>e[f].onComplete(null,!0,e[f].currentOutputSnapshotResolved)),e[f].unwatcher();am(t,$E(t.transactionQueueTree_,n)),WE(t,t.transactionQueueTree_),ir(t.eventQueue_,n,l);for(let f=0;f<d.length;f++)ta(d[f])}else{if(u==="datastale")for(let d=0;d<e.length;d++)e[d].status===3?e[d].status=4:e[d].status=0;else{Rt("transaction at "+c.toString()+" failed: "+u);for(let d=0;d<e.length;d++)e[d].status=4,e[d].abortReason=u}sm(t,n)}},s)}function sm(t,n){let e=cR(t,n),r=Wc(e),i=uR(t,e);return zne(t,i,r),r}function zne(t,n,e){if(n.length===0)return;let r=[],i=[],s=n.filter(a=>a.status===0).map(a=>a.currentWriteId);for(let a=0;a<n.length;a++){let c=n[a],u=Pt(e,c.path),l=!1,d;if(A(u!==null,"rerunTransactionsUnderNode_: relativePath should not be null."),c.status===4)l=!0,d=c.abortReason,i=i.concat(Zi(t.serverSyncTree_,c.currentWriteId,!0));else if(c.status===0)if(c.retryCount>=Lne)l=!0,d="maxretry",i=i.concat(Zi(t.serverSyncTree_,c.currentWriteId,!0));else{let f=aR(t,c.path,s);c.currentInputSnapshot=f;let p=n[a].update(f.val());if(p!==void 0){om("transaction failed: Data returned ",p,c.path);let m=Qe(p);typeof p=="object"&&p!=null&&ln(p,".priority")||(m=m.updatePriority(f.getPriority()));let b=c.currentWriteId,E=HE(t),D=ZP(m,f,E);c.currentOutputSnapshotRaw=m,c.currentOutputSnapshotResolved=D,c.currentWriteId=sR(t),s.splice(s.indexOf(b),1),i=i.concat(GP(t.serverSyncTree_,c.path,D,c.currentWriteId,c.applyLocally)),i=i.concat(Zi(t.serverSyncTree_,b,!0))}else l=!0,d="nodata",i=i.concat(Zi(t.serverSyncTree_,c.currentWriteId,!0))}ir(t.eventQueue_,e,i),i=[],l&&(n[a].status=2,(function(f){setTimeout(f,Math.floor(0))})(n[a].unwatcher),n[a].onComplete&&(d==="nodata"?r.push(()=>n[a].onComplete(null,!1,n[a].currentInputSnapshot)):r.push(()=>n[a].onComplete(new Error(d),!1,null))))}am(t,t.transactionQueueTree_);for(let a=0;a<r.length;a++)ta(r[a]);WE(t,t.transactionQueueTree_)}function cR(t,n){let e,r=t.transactionQueueTree_;for(e=he(n);e!==null&&ra(r)===void 0;)r=$E(r,e),n=Fe(n),e=he(n);return r}function uR(t,n){let e=[];return lR(t,n,e),e.sort((r,i)=>r.order-i.order),e}function lR(t,n,e){let r=ra(n);if(r)for(let i=0;i<r.length;i++)e.push(r[i]);im(n,i=>{lR(t,i,e)})}function am(t,n){let e=ra(n);if(e){let r=0;for(let i=0;i<e.length;i++)e[i].status!==2&&(e[r]=e[i],r++);e.length=r,QP(n,e.length>0?e:void 0)}im(n,r=>{am(t,r)})}function dR(t,n){let e=Wc(cR(t,n)),r=$E(t.transactionQueueTree_,n);return Cne(r,i=>{ww(t,i)}),ww(t,r),XP(r,i=>{ww(t,i)}),e}function ww(t,n){let e=ra(n);if(e){let r=[],i=[],o=-1;for(let s=0;s<e.length;s++)e[s].status===3||(e[s].status===1?(A(o===s-1,"All SENT items should be at beginning of queue."),o=s,e[s].status=3,e[s].abortReason="set"):(A(e[s].status===0,"Unexpected transaction status in abort"),e[s].unwatcher(),i=i.concat(Zi(t.serverSyncTree_,e[s].currentWriteId,!0)),e[s].onComplete&&r.push(e[s].onComplete.bind(null,new Error("set"),!1,null))));o===-1?QP(n,void 0):e.length=o+1,ir(t.eventQueue_,Wc(n),i);for(let s=0;s<r.length;s++)ta(r[s])}}function Kne(t){let n="",e=t.split("/");for(let r=0;r<e.length;r++)if(e[r].length>0){let i=e[r];try{i=decodeURIComponent(i.replace(/\+/g," "))}catch{}n+="/"+i}return n}function Yne(t){let n={};t.charAt(0)==="?"&&(t=t.substring(1));for(let e of t.split("&")){if(e.length===0)continue;let r=e.split("=");r.length===2?n[decodeURIComponent(r[0])]=decodeURIComponent(r[1]):Rt(`Invalid query segment '${e}' in query '${t}'`)}return n}var oP=function(t,n){let e=Zne(t),r=e.namespace;e.domain==="firebase.com"&&nr(e.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),(!r||r==="undefined")&&e.domain!=="localhost"&&nr("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),e.secure||Iee();let i=e.scheme==="ws"||e.scheme==="wss";return{repoInfo:new Np(e.host,e.secure,r,i,n,"",r!==e.subdomain),path:new Pe(e.pathString)}},Zne=function(t){let n="",e="",r="",i="",o="",s=!0,a="https",c=443;if(typeof t=="string"){let u=t.indexOf("//");u>=0&&(a=t.substring(0,u-1),t=t.substring(u+2));let l=t.indexOf("/");l===-1&&(l=t.length);let d=t.indexOf("?");d===-1&&(d=t.length),n=t.substring(0,Math.min(l,d)),l<d&&(i=Kne(t.substring(l,d)));let f=Yne(t.substring(Math.min(t.length,d)));u=n.indexOf(":"),u>=0?(s=a==="https"||a==="wss",c=parseInt(n.substring(u+1),10)):u=n.length;let p=n.slice(0,u);if(p.toLowerCase()==="localhost")e="localhost";else if(p.split(".").length<=2)e=p;else{let m=n.indexOf(".");r=n.substring(0,m).toLowerCase(),e=n.substring(m+1),o=r}"ns"in f&&(o=f.ns)}return{host:n,port:c,domain:e,subdomain:r,secure:s,scheme:a,pathString:i,namespace:o}};var sP="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",Qne=(function(){let t=0,n=[];return function(e){let r=e===t;t=e;let i,o=new Array(8);for(i=7;i>=0;i--)o[i]=sP.charAt(e%64),e=Math.floor(e/64);A(e===0,"Cannot push at time == 0");let s=o.join("");if(r){for(i=11;i>=0&&n[i]===63;i--)n[i]=0;n[i]++}else for(i=0;i<12;i++)n[i]=Math.floor(Math.random()*64);for(i=0;i<12;i++)s+=sP.charAt(n[i]);return A(s.length===20,"nextPushId: Length should be 20."),s}})();var Zp=class{constructor(n,e,r,i){this.eventType=n,this.eventRegistration=e,this.snapshot=r,this.prevName=i}getPath(){let n=this.snapshot.ref;return this.eventType==="value"?n._path:n.parent._path}getEventType(){return this.eventType}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.getPath().toString()+":"+this.eventType+":"+nt(this.snapshot.exportVal())}},Qp=class{constructor(n,e,r){this.eventRegistration=n,this.error=e,this.path=r}getPath(){return this.path}getEventType(){return"cancel"}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.path.toString()+":cancel"}};var pE=class{constructor(n,e){this.snapshotCallback=n,this.cancelCallback=e}onValue(n,e){this.snapshotCallback.call(null,n,e)}onCancel(n){return A(this.hasCancelCallback,"Raising a cancel event on a listener with no cancel callback"),this.cancelCallback.call(null,n)}get hasCancelCallback(){return!!this.cancelCallback}matches(n){return this.snapshotCallback===n.snapshotCallback||this.snapshotCallback.userCallback!==void 0&&this.snapshotCallback.userCallback===n.snapshotCallback.userCallback&&this.snapshotCallback.context===n.snapshotCallback.context}};var mE=class{constructor(n,e){this._repo=n,this._path=e}cancel(){let n=new Wt;return Bne(this._repo,this._path,n.wrapCallback(()=>{})),n.promise}remove(){Qi("OnDisconnect.remove",this._path);let n=new Wt;return rP(this._repo,this._path,null,n.wrapCallback(()=>{})),n.promise}set(n){Qi("OnDisconnect.set",this._path),Yp("OnDisconnect.set",n,this._path,!1);let e=new Wt;return rP(this._repo,this._path,n,e.wrapCallback(()=>{})),e.promise}setWithPriority(n,e){Qi("OnDisconnect.setWithPriority",this._path),Yp("OnDisconnect.setWithPriority",n,this._path,!1),Ane("OnDisconnect.setWithPriority",e,!1);let r=new Wt;return Hne(this._repo,this._path,n,e,r.wrapCallback(()=>{})),r.promise}update(n){Qi("OnDisconnect.update",this._path),Mne("OnDisconnect.update",n,this._path,!1);let e=new Wt;return Une(this._repo,this._path,n,e.wrapCallback(()=>{})),e.promise}};var gE=class t{constructor(n,e,r,i){this._repo=n,this._path=e,this._queryParams=r,this._orderByCalled=i}get key(){return ye(this._path)?null:CE(this._path)}get ref(){return new or(this._repo,this._path)}get _queryIdentifier(){let n=HN(this._queryParams),e=wE(n);return e==="{}"?"default":e}get _queryObject(){return HN(this._queryParams)}isEqual(n){if(n=Jr(n),!(n instanceof t))return!1;let e=this._repo===n._repo,r=IE(this._path,n._path),i=this._queryIdentifier===n._queryIdentifier;return e&&r&&i}toJSON(){return this.toString()}toString(){return this._repo.toString()+ste(this._path)}};var or=class t extends gE{constructor(n,e){super(n,e,new Vw,!1)}get parent(){let n=TP(this._path);return n===null?null:new t(this._repo,n)}get root(){let n=this;for(;n.parent!==null;)n=n.parent;return n}},Jp=class t{constructor(n,e,r){this._node=n,this.ref=e,this._index=r}get priority(){return this._node.getPriority().val()}get key(){return this.ref.key}get size(){return this._node.numChildren()}child(n){let e=new Pe(n),r=ea(this.ref,n);return new t(this._node.getChild(e),r,Ye)}exists(){return!this._node.isEmpty()}exportVal(){return this._node.val(!0)}forEach(n){return this._node.isLeafNode()?!1:!!this._node.forEachChild(this._index,(r,i)=>n(new t(i,ea(this.ref,r),Ye)))}hasChild(n){let e=new Pe(n);return!this._node.getChild(e).isEmpty()}hasChildren(){return this._node.isLeafNode()?!1:!this._node.isEmpty()}toJSON(){return this.exportVal()}val(){return this._node.val()}};function sr(t,n){return t=Jr(t),t._checkNotDeleted("ref"),n!==void 0?ea(t._root,n):t._root}function ea(t,n){return t=Jr(t),he(t._path)===null?Nne("child","path",n,!1):nR("child","path",n,!1),new or(t._repo,Ze(t._path,n))}function fR(t){return t=Jr(t),new mE(t._repo,t._path)}function GE(t,n){t=Jr(t),Qi("push",t._path),Yp("push",n,t._path,!0);let e=oR(t._repo),r=Qne(e),i=ea(t,r),o=ea(t,r),s;return n!=null?s=cm(o,n).then(()=>o):s=Promise.resolve(o),i.then=s.then.bind(s),i.catch=s.then.bind(s,void 0),i}function hR(t){return Qi("remove",t._path),cm(t,null)}function cm(t,n){t=Jr(t),Qi("set",t._path),Yp("set",n,t._path,!1);let e=new Wt;return $ne(t._repo,t._path,n,null,e.wrapCallback(()=>{})),e.promise}var yE=class t{constructor(n){this.callbackContext=n}respondsTo(n){return n==="value"}createEvent(n,e){let r=e._queryParams.getIndex();return new Zp("value",this,new Jp(n.snapshotNode,new or(e._repo,e._path),r))}getEventRunner(n){return n.getEventType()==="cancel"?()=>this.callbackContext.onCancel(n.error):()=>this.callbackContext.onValue(n.snapshot,null)}createCancelEvent(n,e){return this.callbackContext.hasCancelCallback?new Qp(this,n,e):null}matches(n){return n instanceof t?!n.callbackContext||!this.callbackContext?!0:n.callbackContext.matches(this.callbackContext):!1}hasAnyCallback(){return this.callbackContext!==null}},vE=class t{constructor(n,e){this.eventType=n,this.callbackContext=e}respondsTo(n){let e=n==="children_added"?"child_added":n;return e=e==="children_removed"?"child_removed":e,this.eventType===e}createCancelEvent(n,e){return this.callbackContext.hasCancelCallback?new Qp(this,n,e):null}createEvent(n,e){A(n.childName!=null,"Child events should have a childName.");let r=ea(new or(e._repo,e._path),n.childName),i=e._queryParams.getIndex();return new Zp(n.type,this,new Jp(n.snapshotNode,r,i),n.prevName)}getEventRunner(n){return n.getEventType()==="cancel"?()=>this.callbackContext.onCancel(n.error):()=>this.callbackContext.onValue(n.snapshot,n.prevName)}matches(n){return n instanceof t?this.eventType===n.eventType&&(!this.callbackContext||!n.callbackContext||this.callbackContext.matches(n.callbackContext)):!1}hasAnyCallback(){return!!this.callbackContext}};function pR(t,n,e,r,i){let o;if(typeof r=="object"&&(o=void 0,i=r),typeof r=="function"&&(o=r),i&&i.onlyOnce){let c=e,u=(l,d)=>{iP(t._repo,t,a),c(l,d)};u.userCallback=e.userCallback,u.context=e.context,e=u}let s=new pE(e,o||void 0),a=n==="value"?new yE(s):new vE(n,s);return Vne(t._repo,t,a),()=>iP(t._repo,t,a)}function um(t,n,e,r){return pR(t,"value",n,e,r)}function zE(t,n,e,r){return pR(t,"child_added",n,e,r)}tne(or);ane(or);var Jne="FIREBASE_DATABASE_EMULATOR_HOST",_E={},Xne=!1;function ere(t,n,e,r){let i=n.lastIndexOf(":"),o=n.substring(0,i),s=Tp(o);t.repoInfo_=new Np(n,s,t.repoInfo_.namespace,t.repoInfo_.webSocketOnly,t.repoInfo_.nodeAdmin,t.repoInfo_.persistenceKey,t.repoInfo_.includeNamespaceInQueryParams,!0,e),r&&(t.authTokenProvider_=r)}function tre(t,n,e,r,i){let o=r||t.options.databaseURL;o===void 0&&(t.options.projectId||nr("Can't determine Firebase Database URL. Be sure to include a Project ID when calling firebase.initializeApp()."),pt("Using default host for project ",t.options.projectId),o=`${t.options.projectId}-default-rtdb.firebaseio.com`);let s=oP(o,i),a=s.repoInfo,c,u;typeof process<"u"&&process.env&&(u=process.env[Jne]),u?(c=!0,o=`http://${u}?ns=${a.namespace}`,s=oP(o,i),a=s.repoInfo):c=!s.repoInfo.secure;let l=i&&c?new Mc(Mc.OWNER):new Ow(t.name,t.options,n);Pne("Invalid Firebase Database URL",s),ye(s.path)||nr("Database URL must point to the root of a Firebase Database (not including a child path).");let d=rre(a,t,l,new Dw(t,e));return new bE(d,t)}function nre(t,n){let e=_E[n];(!e||e[t.key]!==t)&&nr(`Database ${n}(${t.repoInfo_}) has already been deleted.`),Wne(t),delete e[t.key]}function rre(t,n,e,r){let i=_E[n.name];i||(i={},_E[n.name]=i);let o=i[t.toURLString()];return o&&nr("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),o=new hE(t,Xne,e,r),i[t.toURLString()]=o,o}var bE=class{constructor(n,e){this._repoInternal=n,this.app=e,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(jne(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new or(this._repo,Ne())),this._rootInternal}_delete(){return this._rootInternal!==null&&(nre(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(n){this._rootInternal===null&&nr("Cannot call "+n+" on a deleted database.")}};function mR(t=EN(),n){let e=_N(t,"database").getImmediate({identifier:n});if(!e._instanceStarted){let r=YA("database");r&&KE(e,...r)}return e}function KE(t,n,e,r={}){t=Jr(t),t._checkNotDeleted("useEmulator");let i=`${n}:${e}`,o=t._repoInternal;if(t._instanceStarted){if(i===t._repoInternal.repoInfo_.host&&$s(r,o.repoInfo_.emulatorOptions))return;nr("connectDatabaseEmulator() cannot initialize or alter the emulator configuration after the database instance has started.")}let s;if(o.repoInfo_.nodeAdmin)r.mockUserToken&&nr('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),s=new Mc(Mc.OWNER);else if(r.mockUserToken){let a=typeof r.mockUserToken=="string"?r.mockUserToken:QA(r.mockUserToken,t.app.options.projectId);s=new Mc(a)}Tp(n)&&(ZA(n),JA("Database",!0)),ere(o,i,r,s)}function ire(t){jee(wN),Ec(new er("database",(n,{instanceIdentifier:e})=>{let r=n.getProvider("app").getImmediate(),i=n.getProvider("auth-internal"),o=n.getProvider("app-check-internal");return tre(r,i,o,e)},"PUBLIC").setMultipleInstances(!0)),ei(xN,DN,t),ei(xN,DN,"esm2020")}TE.prototype.simpleListen=function(t,n){this.sendRequest("q",{p:t},n)};TE.prototype.echo=function(t,n){this.sendRequest("echo",{d:t},n)};qee(Eee.Client);ire("node");var m1e=j("FirebaseSignalingChannel"),g1e=240*1e3;function gR(t,n,e,r,i=new Date().toISOString()){let{component:o,package:s,...a}=e??{},c={ts:i,lvl:He[t],component:o??"unknown",msg:n};return s!=null&&(c.package=s),Object.keys(a).length>0&&(c.ctx=a),r!=null&&(c.err={message:r.message,stack:r.stack}),c}var ore={DEBUG:"\x1B[90m",INFO:"\x1B[36m",WARN:"\x1B[33m",ERROR:"\x1B[31m",FATAL:"\x1B[35m"},sre="\x1B[0m";function yR(t,n){let r=n?.color??!1?`${ore[t.lvl]??""}${t.lvl}${sre}`:t.lvl,i=t.package!=null?`[${t.package}][${t.component}]`:`[${t.component}]`,o=`[${t.ts}][${r}]${i} ${t.msg}`;return t.ctx!=null&&(o+=` ${JSON.stringify(t.ctx)}`),t.err!=null&&(o+=`
38
38
  Error: ${t.err.message}`,t.err.stack!=null&&(o+=`
39
- Stack: ${t.err.stack}`)),o}var YE=class extends j0{constructor(n){super(),this.minLevel=n?.minLevel??He.WARN,this.useStderr=n?.useStderr??!1,this.format=n?.format??"legacy",this.color=n?.color}log(n,e,r,i){if(n<this.minLevel)return;if(this.format==="pretty"){let l=gR(n,e,r,i),d=yR(l,{color:this.color??this.detectTty()});this.useStderr?console.error(d):console.log(d);return}let{component:o,package:s,...a}=r??{},c=o!=null?`[${o}] `:"",u=[`[${He[n]}] ${c}${e}`];Object.keys(a).length>0&&u.push(a),i!=null&&u.push(i),this.useStderr?console.error(...u):console.log(...u)}detectTty(){let n=globalThis.process;return!!(this.useStderr?n?.stderr:n?.stdout)?.isTTY}close(){}};function vR(t){return{provide:ph,multi:!0,useFactory:()=>new YE(t)}}var fm=U(Q()),sre="cloudflare-do",are=!1;function We(t){if(!are)return;let n=t();console.log(n);try{let e=globalThis;typeof e.postMessage=="function"&&e.postMessage({type:"diag",data:"[DIAG-RAW-CF] "+n})}catch{}}function cre(t){if(t.length!==lm.length)return!1;for(let n=0;n<lm.length;n++)if(t[n]!==lm.charCodeAt(n))return!1;return!0}var ure=3e3,lre=15e3,dre=45e3,lm="__pxecho__",dm=class{constructor(n,e,r,i={}){this.url=n,this.hashedSelfIdFn=e,this.codec=r,this.opts=i,this.name=sre,this.wsPool=new Map,this.inboxSendQueues=new Map}acceptsMessage(n){return!(this.opts.excludeAnnounce&&n.payload.type==="announce")}get hashedSelfId(){return this.hashedSelfIdFn()}get isAvailable(){return typeof this.url=="string"&&this.url.length>0}events(n,e){return this.listen(n,e)}listen(n,e){return new fm.Observable(r=>{let i=new fm.Subject,o=i.subscribe(r),s=e?.allowedFromPeers??[],a=new Set(n),c=this.hashedSelfId;We(()=>"[DIAG:CF-listen] called url="+this.url+" hashedSelfId="+c+" myIds="+JSON.stringify(n)+" allowedPeers="+s.length+" allowedFromPeers="+JSON.stringify(s)),We(()=>"[stream-check-064] CF-listen url="+this.url+" myIds="+JSON.stringify(n));let u=new Set;if(u.add(`inbox:${c}`),!this.opts.excludeAnnounce){u.add(`pub:${c}`);for(let d of s)u.add(`sub:${d}`)}We(()=>"[stream-check-065] CF desired="+JSON.stringify([...u])+" excludeAnnounce="+!!this.opts.excludeAnnounce);let l=[];for(let[d,f]of this.wsPool)if(u.has(d))fre(f.ws)?(this.stopPingTimer(f),l.push(d)):(f.subject=i,f.myIdSet=a);else{this.stopPingTimer(f);try{f.ws.close()}catch{}l.push(d)}for(let d of l)We(()=>`[CF DO diag] WS close (diff-remove): ${d}`),this.wsPool.delete(d);for(let d of u){if(this.wsPool.has(d))continue;let f=this.keyToUrl(d,c);We(()=>`[DIAG:CF-wsopen-add] ${f}`),We(()=>"[stream-check-066] CF openWs url="+f);let p=this.openWs(f),m={ws:p,subject:i,myIdSet:a,pingTimer:null,key:d,echoTimer:null,lastInboxDeliveryAt:Date.now()};this.wsPool.set(d,m),this.wireUp(p,m,d)}return()=>{o.unsubscribe(),i.complete()}})}async send(n){let e=this.codec.encode(n),r=hre(),i=n.payload.to;if(We(()=>"[stream-check-071] CF send type="+n.payload.type+" to="+i),i==="all"){let f=this.wsPool.get(`pub:${this.hashedSelfId}`)?.ws;if(!f)throw We(()=>"[DIAG:CF-send-broadcast] FAIL publish WS not open (listen\u672Asubscribe) hashedSelfId="+this.hashedSelfId),new Error("[CloudflareDoSignalingChannel.send] publish WS not open (listen() \u3092\u5148\u306B subscribe \u3057\u3066\u304F\u3060\u3055\u3044)");return f.readyState!==1&&(We(()=>"[DIAG:CF-send-broadcast] WAIT for ws open, readyState="+f.readyState),await new Promise((p,m)=>{let y=setTimeout(()=>m(new Error("[CloudflareDoSignalingChannel.send] publish WS open timeout 10s")),1e4),b=()=>{clearTimeout(y),f.removeEventListener("open",E),f.removeEventListener("error",D),f.removeEventListener("close",T)},E=()=>{b(),p()},D=()=>{b(),m(new Error("[CloudflareDoSignalingChannel.send] publish WS error before open"))},T=()=>{b(),m(new Error("[CloudflareDoSignalingChannel.send] publish WS closed before open"))};if(f.readyState===1){b(),p();return}f.addEventListener("open",E,{once:!0}),f.addEventListener("error",D,{once:!0}),f.addEventListener("close",T,{once:!0})}),We(()=>"[DIAG:CF-send-broadcast] ws opened after wait, readyState="+f.readyState)),We(()=>"[DIAG:CF-send-broadcast] type="+n.payload.type+" bytes="+e.byteLength+" wsReadyState="+f.readyState),f.send(e),We(()=>"[DIAG:CF-send-broadcast] OK sent"),{id:r,channel:this.name}}let o=typeof globalThis<"u"&&typeof globalThis.document<"u",s=`${this.url}/inbox/${i}`,a=/^(https?|wss?):\/\/(localhost|127\.0\.0\.1)/i.test(s),c=o&&!a,l=(this.inboxSendQueues.get(i)??Promise.resolve()).catch(()=>{}).then(async()=>{let f=c?{method:"POST",body:e,mode:"no-cors"}:{method:"POST",body:e};We(()=>"[CF DO diag] send direct to="+i+" type="+n.payload.type+" bytes="+e.byteLength),We(()=>"[stream-check-072] CF fetch POST target="+s);let p=await fetch(s,f);if(We(()=>"[CF DO diag] send direct done to="+i+" status="+p.status),We(()=>"[stream-check-073] CF fetch done status="+p.status),!o&&!p.ok&&p.status!==204)throw new Error(`[CloudflareDoSignalingChannel.send] POST ${s} -> ${p.status}`)}),d=l.catch(()=>{});return this.inboxSendQueues.set(i,d),d.finally(()=>{this.inboxSendQueues.get(i)===d&&this.inboxSendQueues.delete(i)}),await l,{id:r,channel:this.name}}keyToUrl(n,e){if(n===`inbox:${e}`)return`${this.url}/inbox/${e}`;if(n===`pub:${e}`)return`${this.url}/announce/${e}?role=publish`;let r=n.slice(4);return`${this.url}/announce/${r}?role=subscribe`}openWs(n){let e=n.replace(/^https:\/\//i,"wss://").replace(/^http:\/\//i,"ws://");return new WebSocket(e)}wireUp(n,e,r){n.binaryType="arraybuffer",n.onmessage=i=>{We(()=>"[stream-check-068] CF ws recv bytes="+(typeof i.data=="string"?"str:"+i.data.length:i.data?.byteLength??0));try{let o=i.data;if(typeof o=="string")return;let s=o instanceof ArrayBuffer?new Uint8Array(o):o instanceof Uint8Array?o:null;if(!s||(e.key.startsWith("inbox:")&&(e.lastInboxDeliveryAt=Date.now()),cre(s)))return;let{record:a}=this.codec.decode(s),c=a.payload.to,u=c==="all"||e.myIdSet.has(c);We(()=>"[CF DO diag] recv type="+a.payload.type+" from="+a.payload.from+" to="+c+" accept="+u),We(()=>"[stream-check-069] CF ws emit accept="+u+" type="+a.payload.type),u&&e.subject.next(a)}catch(o){e.subject.error(o)}},n.onopen=()=>{We(()=>`[DIAG:CF-ws-opened] ${n.url}`),We(()=>"[stream-check-067] CF ws OPENED url="+n.url),this.startPingTimer(e),e.key.startsWith("inbox:")&&this.startInboxEchoTimer(e)},n.onerror=i=>{We(()=>`[DIAG:CF-ws-error] ${n.url} ev=${i?.message??i?.type??"err"}`)},n.onclose=i=>{let o=i??{},{code:s,reason:a,wasClean:c}=o;We(()=>`[DIAG:CF-ws-close] ${n.url} code=${s} reason=${a} clean=${c}`),We(()=>"[stream-check-070] CF ws CLOSED code="+s+" clean="+c),this.stopPingTimer(e),this.wsPool.get(r)?.ws===n&&this.wsPool.delete(r)}}destroy(){for(let[,n]of this.wsPool){this.stopPingTimer(n);try{n.ws.close()}catch{}}this.wsPool.clear()}startPingTimer(n){n.pingTimer===null&&(n.pingTimer=setInterval(()=>{try{n.ws.readyState===1&&n.ws.send("ping")}catch{}},ure))}stopPingTimer(n){n.pingTimer!==null&&(clearInterval(n.pingTimer),n.pingTimer=null),n.echoTimer!==null&&(clearInterval(n.echoTimer),n.echoTimer=null)}startInboxEchoTimer(n){n.echoTimer===null&&(n.echoTimer=setInterval(()=>{if(Date.now()-n.lastInboxDeliveryAt>dre){We(()=>"[stream-check-073] CF inbox echo DEAD (deaf ws, pong \u751F\u5B58\u3067\u3082 DO \u672A\u767B\u9332) \u2192 force reopen key="+n.key),this.reopenDeadInboxWs(n.key,n);return}this.postInboxEcho()},lre))}postInboxEcho(){try{fetch(`${this.url}/inbox/${this.hashedSelfId}`,{method:"POST",body:lm}).catch(()=>{})}catch{}}reopenDeadInboxWs(n,e){this.stopPingTimer(e);try{e.ws.onclose=null,e.ws.onerror=null,e.ws.close()}catch{}if(this.wsPool.get(n)!==e)return;this.wsPool.delete(n);let r=this.keyToUrl(n,this.hashedSelfId);We(()=>"[stream-check-073] CF inbox reopen url="+r);let i=this.openWs(r),o={ws:i,subject:e.subject,myIdSet:e.myIdSet,pingTimer:null,key:n,echoTimer:null,lastInboxDeliveryAt:Date.now()};this.wsPool.set(n,o),this.wireUp(i,o,n)}};function fre(t){return t.readyState>=2}function hre(){return globalThis.crypto?.randomUUID?.()??`cf-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}var hm=class{constructor(){this.encoder=new TextEncoder,this.decoder=new TextDecoder}encode(n){return this.encoder.encode(JSON.stringify(n))}decode(n){let e=this.decoder.decode(n),r=JSON.parse(e),i=`${r.payload.from}-${r.payload.timestamp}`;return{id:i,record:{...r,id:i}}}};var ZE=U(Q());function _R(t){return hs(()=>{let n=t.urlFactory();if(console.log("[CF DO diag] provideCloudflareDoSignaling factory called, url=",n),!n)return console.warn("[CF DO diag] url \u672A\u8A2D\u5B9A/falsy \u2192 NoopCloudflareDoSignalingChannel \u767B\u9332 (no-op)"),new QE;let e=w(sn),r=()=>Oa(e,t.hashedSelfIdFactory);return console.log("[CF DO diag] CloudflareDoSignalingChannel instance \u751F\u6210 url=",n),new dm(n,r,t.codecFactory(),{excludeAnnounce:t.excludeAnnounce??!1})})}var QE=class{constructor(){this.name="cloudflare-do-disabled",this.isAvailable=!1}async send(){throw new Error("[NoopCloudflareDoSignalingChannel.send] disabled (cloudflareDoSignalingUrl \u672A\u8A2D\u5B9A)")}listen(){return ZE.EMPTY}events(){return ZE.EMPTY}};var ar=U(Q());var pre="announce",mre=["offer","answer","candidate"],pm=class{constructor(n){this.db=n,this.name="rtdb-announce",this.logger=j("RtdbAnnounceChannel"),this.onDisconnectRegisteredPaths=new Set,this.connectionWatchStarted=!1,this.reconnect$=new ar.Observable(e=>{this.logger.info("[stream-check-054] .info/connected subscribed");let r=um(sr(this.db,".info/connected"),i=>{this.logger.info("[stream-check-055] .info/connected snap",{connected:i.val()}),i.val()===!0&&e.next()});return()=>r()}).pipe((0,ar.share)()),this.logger.info("[stream-check-053] RTDB ctor",{dbAvailable:!!n})}ensureConnectionWatch(){this.connectionWatchStarted||(this.connectionWatchStarted=!0,um(sr(this.db,".info/connected"),n=>{n.val()===!1&&this.onDisconnectRegisteredPaths.clear()}))}get isAvailable(){return!!this.db}acceptsMessage(n){return n.payload.type===pre}acceptsFallback(n){return mre.includes(n.payload.type)}async sendFallbackMessage(n){let e=n.payload.to;if(!e||e==="all")throw new Error(`[RtdbAnnounceChannel] fallback message requires a concrete to, got ${String(e)}`);let r=sr(this.db,`signaling_messages/${e}`),i=await GE(r,{payload:n.payload,signature:n.signature??"",ts:Date.now()});return this.logger.warn("[fallback] delivered via RTDB inbox",{to:e,type:n.payload.type,id:i.key}),{id:i.key??"unknown",channel:this.name}}async send(n){if(this.logger.info("[stream-check-056] send() pre",{from:n.payload.from,to:n.payload.to}),this.acceptsFallback(n))return this.sendFallbackMessage(n);if(!this.acceptsMessage(n))throw new Error(`[RtdbAnnounceChannel] only accepts announce messages, got ${n.payload.type}`);let e=n.payload.from;if(!e)throw new Error("[RtdbAnnounceChannel] message.payload.from is required");let r=`signaling_announce/${e}`,i=sr(this.db,r);try{this.ensureConnectionWatch(),this.onDisconnectRegisteredPaths.has(r)||(await fR(i).remove(),this.onDisconnectRegisteredPaths.add(r)),await cm(i,Date.now()),this.logger.info("[stream-check-057] send() OK",{path:`signaling_announce/${e}`})}catch(o){let s=o,a={path:`signaling_announce/${e}`,message:s?.message,code:s?.code,stackHead:s?.stack?.split(`
40
- `).slice(0,3).join(" | ")};throw this.logger.error("[send] FAILED detail",a),new Error(`[RtdbAnnounceChannel.send] FAILED ${JSON.stringify(a)}`)}return{id:e,channel:this.name}}events(n,e){return n.length===0?ar.EMPTY:new ar.Observable(r=>{let i=n.map(o=>{let s=sr(this.db,`signaling_messages/${o}`);return zE(s,a=>{let c=a.val();c?.payload&&r.next({id:a.key??"unknown",payload:c.payload,signature:c.signature??""}),a.ref&&hR(a.ref).catch(()=>{})},a=>{this.logger.warn("[fallback] inbox listen error",{myId:o,message:a?.message})})});return()=>{for(let o of i)o()}}).pipe((0,ar.share)())}presence(n,e){return this.logger.info("[stream-check-058] presence() pre",{myIds:n}),new ar.Observable(r=>{let i=e?.allowedFromPeers??[];this.logger.info("[stream-check-059] presence() per-path subscribed",{watched:i.length});let o=i.map(s=>{let a=!1,c=sr(this.db,`signaling_announce/${s}`);return um(c,u=>{let l=u.val();if(typeof l=="number"){a=!0;let d={fromKey:s,generation:String(l),observedAt:Date.now()};this.logger.info("[stream-check-061] presence() emit",{fromKey:s}),r.next(d)}else a&&(a=!1,this.logger.info("[presence] lost",{fromKey:s}),r.next({fromKey:s,observedAt:Date.now(),lost:!0}))},u=>{this.logger.warn("[presence] onValue error:",{fromKey:s,error:u})})});return()=>{for(let s of o)s()}})}};function JE(t){return t.PLANX_SIGNALING_URL||L_.PLANX_SIGNALING_URL}function bR(t){let n=t.FIREBASE_DATABASE_EMULATOR_HOST,e=t.PLANX_FIREBASE_NAMESPACE;return n&&e?`http://${n}?ns=${e}`:t.PLANX_FIREBASE_DATABASE_URL||L_.PLANX_FIREBASE_DATABASE_URL}function wR(t,n){let e=!!n;return[...e&&n?hs(()=>new pm(n)):[],..._R({urlFactory:()=>JE(t),hashedSelfIdFactory:()=>w(Ce).config.config().identity?.signalingId??"",codecFactory:()=>new hm,excludeAnnounce:e})]}var gre="firebase",yre="12.7.0";ei(gre,yre,"app");console.error("[transport:boot:module-top] module-top-reached pid="+process.pid+" ts="+Date.now());console.error("[transport:boot:reflect-metadata] reflect-metadata-loaded pid="+process.pid);function vre(){let t=process.env.PLANX_IDENTITY_PUBLIC_KEY,n=process.env.PLANX_IDENTITY_PRIVATE_KEY;return!t||!n?null:{publicKey:t,privateKey:n,algorithm:"P-256",createdAt:new Date}}function _re(){let t=process.env.FIREBASE_DATABASE_EMULATOR_HOST,n=bR(process.env);!t&&!process.env.PLANX_FIREBASE_DATABASE_URL&&console.error(`[transport child] WARNING: PLANX_FIREBASE_DATABASE_URL not set. Falling back to prod default (${n})\u3002 supervisor parent (= cli / web-server) \u3067 env \u6CE8\u5165\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);try{let e=pw().length>0?pw()[0]:hw({databaseURL:n}),r=mR(e);if(t){let[i,o]=t.split(":"),s=Number(o??9e3);KE(r,i,s)}return r}catch(e){console.error("[transport child] firebase init failed, falling back to CF DO only:",e);return}}async function bre(){JE(process.env)||console.error("[transport child] WARNING: PLANX_SIGNALING_URL not set. Signaling will be no-op (NoopCloudflareDoSignalingChannel)\u3002 supervisor parent (= cli / web-server) \u3067 env \u6CE8\u5165\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002"),console.error("[transport:boot:env] main-aot env: PLANX_SERVER_NAME="+JSON.stringify(process.env.PLANX_SERVER_NAME)+" PLANX_TRANSPORT_TRPC_URL="+JSON.stringify(process.env.PLANX_TRANSPORT_TRPC_URL)+" WEBSERVER_INT_CF_SIGNALING="+JSON.stringify(process.env.WEBSERVER_INT_CF_SIGNALING)+" PLANX_FIREBASE_DATABASE_URL="+JSON.stringify(process.env.PLANX_FIREBASE_DATABASE_URL)+" PLANX_FIREBASE_NAMESPACE="+JSON.stringify(process.env.PLANX_FIREBASE_NAMESPACE)+" FIREBASE_DATABASE_EMULATOR_HOST="+JSON.stringify(process.env.FIREBASE_DATABASE_EMULATOR_HOST)+" PLANX_SIGNALING_URL="+JSON.stringify(process.env.PLANX_SIGNALING_URL)+" pid="+process.pid);let n=[],e=process.env.PLANX_TRANSPORT_KEY_FILE??`/tmp/transport-child-${process.pid}-keys.json`,r=await O0([...Yb(),...wp({keyFilePath:e,identityOverride:vre()}),vR({minLevel:He.INFO,useStderr:!0}),Ce,...wR(process.env,_re()),{provide:qa,useExisting:Wh},DO(()=>({roles:["server","client"],origin:"cli-server",allowPeersPublicKeys:[],connection:{timeoutMs:6e4,maxRetryCount:3,retryDelayMs:1e3},peerSessionOptions:{config:{iceServers:n,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",iceTransportPolicy:"all"}}}))]);$0(r.get(Ba));let i=fA({injector:r}),o=Number(process.env.PORT??0),s=process.env.HOST??"0.0.0.0";dT({fetch:i.fetch,port:o,hostname:s},d=>{console.log(`transport server is running at http://${d.address}:${d.port}`),hA(d.port,process.pid)});let a=r.get(Ce),c=process.env.PLANX_TRANSPORT_KEY_FILE,u;if(c){let d=r.get(k0);await d.initialize(),u=await P_(d,r.get(Ur)),await a.updateWebRTCConfig(f=>({...f,identity:u}))}else u=await(0,ER.firstValueFrom)(a.config.identity$);let l=a.config.config();console.error("[transport:boot:post-identity] main-aot post-identity: cfg.name="+JSON.stringify(l.name)+" cfg.serverName="+JSON.stringify(l.serverName)+" cfg.version="+JSON.stringify(l.version)+" cfg.roles="+JSON.stringify(l.roles)+" identity.peerId="+u.peerId+" pid="+process.pid),await a.start(),console.error("[transport:boot:start-done] main-aot transport.start done pid="+process.pid),pA(u.peerId),process.on("SIGTERM",()=>process.exit(0)),process.on("SIGINT",()=>process.exit(0)),process.on("uncaughtException",d=>{console.error("[transport] uncaughtException:",d?.stack??String(d)),process.exit(1)}),process.on("unhandledRejection",d=>{console.error("[transport] unhandledRejection:",d instanceof Error?d.stack:String(d)),process.exit(1)})}bre().catch(t=>{console.error("Failed to start transport server:",t),process.exit(1)});
39
+ Stack: ${t.err.stack}`)),o}var YE=class extends jD{constructor(n){super(),this.minLevel=n?.minLevel??He.WARN,this.useStderr=n?.useStderr??!1,this.format=n?.format??"legacy",this.color=n?.color}log(n,e,r,i){if(n<this.minLevel)return;if(this.format==="pretty"){let l=gR(n,e,r,i),d=yR(l,{color:this.color??this.detectTty()});this.useStderr?console.error(d):console.log(d);return}let{component:o,package:s,...a}=r??{},c=o!=null?`[${o}] `:"",u=[`[${He[n]}] ${c}${e}`];Object.keys(a).length>0&&u.push(a),i!=null&&u.push(i),this.useStderr?console.error(...u):console.log(...u)}detectTty(){let n=globalThis.process;return!!(this.useStderr?n?.stderr:n?.stdout)?.isTTY}close(){}};function vR(t){return{provide:ph,multi:!0,useFactory:()=>new YE(t)}}var fm=U(Q()),are="cloudflare-do",cre=!1;function We(t){if(!cre)return;let n=t();console.log(n);try{let e=globalThis;typeof e.postMessage=="function"&&e.postMessage({type:"diag",data:"[DIAG-RAW-CF] "+n})}catch{}}function ure(t){if(t.length!==lm.length)return!1;for(let n=0;n<lm.length;n++)if(t[n]!==lm.charCodeAt(n))return!1;return!0}var lre=3e3,dre=15e3,_R=45e3,lm="__pxecho__",dm=class{constructor(n,e,r,i={}){this.url=n,this.hashedSelfIdFn=e,this.codec=r,this.opts=i,this.name=are,this.wsPool=new Map,this.inboxSendQueues=new Map}acceptsMessage(n){return!(this.opts.excludeAnnounce&&n.payload.type==="announce")}get hashedSelfId(){return this.hashedSelfIdFn()}get echoIntervalMs(){return this.opts.echoIntervalMs??dre}get echoDeadlineMs(){return this.opts.echoDeadlineMs??_R}get isAvailable(){return typeof this.url=="string"&&this.url.length>0}events(n,e){return this.listen(n,e)}listen(n,e){return new fm.Observable(r=>{let i=new fm.Subject,o=i.subscribe(r),s=e?.allowedFromPeers??[],a=new Set(n),c=this.hashedSelfId;We(()=>"[DIAG:CF-listen] called url="+this.url+" hashedSelfId="+c+" myIds="+JSON.stringify(n)+" allowedPeers="+s.length+" allowedFromPeers="+JSON.stringify(s)),We(()=>"[stream-check-064] CF-listen url="+this.url+" myIds="+JSON.stringify(n));let u=new Set;if(u.add(`inbox:${c}`),!this.opts.excludeAnnounce){u.add(`pub:${c}`);for(let d of s)u.add(`sub:${d}`)}We(()=>"[stream-check-065] CF desired="+JSON.stringify([...u])+" excludeAnnounce="+!!this.opts.excludeAnnounce);let l=[];for(let[d,f]of this.wsPool)if(u.has(d))fre(f)?(this.stopPingTimer(f),l.push(d)):(f.subject=i,f.myIdSet=a);else{this.stopPingTimer(f);try{f.ws.close()}catch{}l.push(d)}for(let d of l)We(()=>`[CF DO diag] WS close (diff-remove): ${d}`),this.wsPool.delete(d);for(let d of u){if(this.wsPool.has(d))continue;let f=this.keyToUrl(d,c);We(()=>`[DIAG:CF-wsopen-add] ${f}`),We(()=>"[stream-check-066] CF openWs url="+f);let p=this.openWs(f),m={ws:p,subject:i,myIdSet:a,pingTimer:null,key:d,echoTimer:null,lastInboxDeliveryAt:Date.now(),createdAt:Date.now(),errored:!1};this.wsPool.set(d,m),this.wireUp(p,m,d)}return()=>{o.unsubscribe(),i.complete()}})}async send(n){let e=this.codec.encode(n),r=hre(),i=n.payload.to;if(We(()=>"[stream-check-071] CF send type="+n.payload.type+" to="+i),i==="all"){let f=this.wsPool.get(`pub:${this.hashedSelfId}`)?.ws;if(!f)throw We(()=>"[DIAG:CF-send-broadcast] FAIL publish WS not open (listen\u672Asubscribe) hashedSelfId="+this.hashedSelfId),new Error("[CloudflareDoSignalingChannel.send] publish WS not open (listen() \u3092\u5148\u306B subscribe \u3057\u3066\u304F\u3060\u3055\u3044)");return f.readyState!==1&&(We(()=>"[DIAG:CF-send-broadcast] WAIT for ws open, readyState="+f.readyState),await new Promise((p,m)=>{let y=setTimeout(()=>m(new Error("[CloudflareDoSignalingChannel.send] publish WS open timeout 10s")),1e4),b=()=>{clearTimeout(y),f.removeEventListener("open",E),f.removeEventListener("error",D),f.removeEventListener("close",T)},E=()=>{b(),p()},D=()=>{b(),m(new Error("[CloudflareDoSignalingChannel.send] publish WS error before open"))},T=()=>{b(),m(new Error("[CloudflareDoSignalingChannel.send] publish WS closed before open"))};if(f.readyState===1){b(),p();return}f.addEventListener("open",E,{once:!0}),f.addEventListener("error",D,{once:!0}),f.addEventListener("close",T,{once:!0})}),We(()=>"[DIAG:CF-send-broadcast] ws opened after wait, readyState="+f.readyState)),We(()=>"[DIAG:CF-send-broadcast] type="+n.payload.type+" bytes="+e.byteLength+" wsReadyState="+f.readyState),f.send(e),We(()=>"[DIAG:CF-send-broadcast] OK sent"),{id:r,channel:this.name}}let o=typeof globalThis<"u"&&typeof globalThis.document<"u",s=`${this.url}/inbox/${i}`,a=/^(https?|wss?):\/\/(localhost|127\.0\.0\.1)/i.test(s),c=o&&!a,l=(this.inboxSendQueues.get(i)??Promise.resolve()).catch(()=>{}).then(async()=>{let f=c?{method:"POST",body:e,mode:"no-cors"}:{method:"POST",body:e};We(()=>"[CF DO diag] send direct to="+i+" type="+n.payload.type+" bytes="+e.byteLength),We(()=>"[stream-check-072] CF fetch POST target="+s);let p=await fetch(s,f);if(We(()=>"[CF DO diag] send direct done to="+i+" status="+p.status),We(()=>"[stream-check-073] CF fetch done status="+p.status),!o&&!p.ok&&p.status!==204)throw new Error(`[CloudflareDoSignalingChannel.send] POST ${s} -> ${p.status}`)}),d=l.catch(()=>{});return this.inboxSendQueues.set(i,d),d.finally(()=>{this.inboxSendQueues.get(i)===d&&this.inboxSendQueues.delete(i)}),await l,{id:r,channel:this.name}}keyToUrl(n,e){if(n===`inbox:${e}`)return`${this.url}/inbox/${e}`;if(n===`pub:${e}`)return`${this.url}/announce/${e}?role=publish`;let r=n.slice(4);return`${this.url}/announce/${r}?role=subscribe`}openWs(n){let e=n.replace(/^https:\/\//i,"wss://").replace(/^http:\/\//i,"ws://");return new WebSocket(e)}wireUp(n,e,r){n.binaryType="arraybuffer",e.key.startsWith("inbox:")&&this.startInboxEchoTimer(e),n.onmessage=i=>{We(()=>"[stream-check-068] CF ws recv bytes="+(typeof i.data=="string"?"str:"+i.data.length:i.data?.byteLength??0));try{let o=i.data;if(typeof o=="string")return;let s=o instanceof ArrayBuffer?new Uint8Array(o):o instanceof Uint8Array?o:null;if(!s||(e.key.startsWith("inbox:")&&(e.lastInboxDeliveryAt=Date.now()),ure(s)))return;let{record:a}=this.codec.decode(s),c=a.payload.to,u=c==="all"||e.myIdSet.has(c);We(()=>"[CF DO diag] recv type="+a.payload.type+" from="+a.payload.from+" to="+c+" accept="+u),We(()=>"[stream-check-069] CF ws emit accept="+u+" type="+a.payload.type),u&&e.subject.next(a)}catch(o){e.subject.error(o)}},n.onopen=()=>{We(()=>`[DIAG:CF-ws-opened] ${n.url}`),We(()=>"[stream-check-067] CF ws OPENED url="+n.url),this.startPingTimer(e)},n.onerror=i=>{We(()=>`[DIAG:CF-ws-error] ${n.url} ev=${i?.message??i?.type??"err"}`),e.errored=!0},n.onclose=i=>{let o=i??{},{code:s,reason:a,wasClean:c}=o;We(()=>`[DIAG:CF-ws-close] ${n.url} code=${s} reason=${a} clean=${c}`),We(()=>"[stream-check-070] CF ws CLOSED code="+s+" clean="+c),this.stopPingTimer(e),this.wsPool.get(r)?.ws===n&&this.wsPool.delete(r)}}destroy(){for(let[,n]of this.wsPool){this.stopPingTimer(n);try{n.ws.close()}catch{}}this.wsPool.clear()}startPingTimer(n){n.pingTimer===null&&(n.pingTimer=setInterval(()=>{try{n.ws.readyState===1&&n.ws.send("ping")}catch{}},lre))}stopPingTimer(n){n.pingTimer!==null&&(clearInterval(n.pingTimer),n.pingTimer=null),n.echoTimer!==null&&(clearInterval(n.echoTimer),n.echoTimer=null)}startInboxEchoTimer(n){n.echoTimer===null&&(n.echoTimer=setInterval(()=>{if(n.errored||n.ws.readyState>=2){this.warnReopen(n.key,"ws errored/closed without close event"),this.reopenDeadInboxWs(n.key,n);return}if(n.ws.readyState===0){Date.now()-n.createdAt>this.echoDeadlineMs&&(this.warnReopen(n.key,"ws stuck in CONNECTING beyond deadline"),this.reopenDeadInboxWs(n.key,n));return}if(Date.now()-n.lastInboxDeliveryAt>this.echoDeadlineMs){this.warnReopen(n.key,"no inbox delivery beyond deadline"),this.reopenDeadInboxWs(n.key,n);return}this.postInboxEcho(n)},this.echoIntervalMs))}warnReopen(n,e){console.warn(`[cf-signaling] reopening deaf inbox WS (${e}) key=${n}`)}async postInboxEcho(n){try{(await fetch(`${this.url}/inbox/${this.hashedSelfId}`,{method:"POST",body:lm}).catch(()=>null))?.status===202&&this.wsPool.get(n.key)===n&&(this.warnReopen(n.key,"self-echo returned 202 (inbox WS orphaned on DO)"),this.reopenDeadInboxWs(n.key,n))}catch{}}reopenDeadInboxWs(n,e){this.stopPingTimer(e);try{e.ws.onclose=null,e.ws.onerror=null,e.ws.close()}catch{}if(this.wsPool.get(n)!==e)return;this.wsPool.delete(n);let r=this.keyToUrl(n,this.hashedSelfId);We(()=>"[stream-check-073] CF inbox reopen url="+r);let i=this.openWs(r),o={ws:i,subject:e.subject,myIdSet:e.myIdSet,pingTimer:null,key:n,echoTimer:null,lastInboxDeliveryAt:Date.now(),createdAt:Date.now(),errored:!1};this.wsPool.set(n,o),this.wireUp(i,o,n)}};function fre(t){return t.ws.readyState>=2||t.errored?!0:t.ws.readyState===0&&Date.now()-t.createdAt>_R}function hre(){return globalThis.crypto?.randomUUID?.()??`cf-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}var hm=class{constructor(){this.encoder=new TextEncoder,this.decoder=new TextDecoder}encode(n){return this.encoder.encode(JSON.stringify(n))}decode(n){let e=this.decoder.decode(n),r=JSON.parse(e),i=`${r.payload.from}-${r.payload.timestamp}`;return{id:i,record:{...r,id:i}}}};var ZE=U(Q());function bR(t){return hs(()=>{let n=t.urlFactory();if(console.log("[CF DO diag] provideCloudflareDoSignaling factory called, url=",n),!n)return console.warn("[CF DO diag] url \u672A\u8A2D\u5B9A/falsy \u2192 NoopCloudflareDoSignalingChannel \u767B\u9332 (no-op)"),new QE;let e=w(sn),r=()=>Oa(e,t.hashedSelfIdFactory);return console.log("[CF DO diag] CloudflareDoSignalingChannel instance \u751F\u6210 url=",n),new dm(n,r,t.codecFactory(),{excludeAnnounce:t.excludeAnnounce??!1})})}var QE=class{constructor(){this.name="cloudflare-do-disabled",this.isAvailable=!1}async send(){throw new Error("[NoopCloudflareDoSignalingChannel.send] disabled (cloudflareDoSignalingUrl \u672A\u8A2D\u5B9A)")}listen(){return ZE.EMPTY}events(){return ZE.EMPTY}};var ar=U(Q());var pre="announce",mre=["offer","answer","candidates"],pm=class{constructor(n){this.db=n,this.name="rtdb-announce",this.logger=j("RtdbAnnounceChannel"),this.onDisconnectRegisteredPaths=new Set,this.connectionWatchStarted=!1,this.reconnect$=new ar.Observable(e=>{this.logger.info("[stream-check-054] .info/connected subscribed");let r=um(sr(this.db,".info/connected"),i=>{this.logger.info("[stream-check-055] .info/connected snap",{connected:i.val()}),i.val()===!0&&e.next()});return()=>r()}).pipe((0,ar.share)()),this.logger.info("[stream-check-053] RTDB ctor",{dbAvailable:!!n})}ensureConnectionWatch(){this.connectionWatchStarted||(this.connectionWatchStarted=!0,um(sr(this.db,".info/connected"),n=>{n.val()===!1&&this.onDisconnectRegisteredPaths.clear()}))}get isAvailable(){return!!this.db}acceptsMessage(n){return n.payload.type===pre}acceptsFallback(n){return mre.includes(n.payload.type)}async sendFallbackMessage(n){let e=n.payload.to;if(!e||e==="all")throw new Error(`[RtdbAnnounceChannel] fallback message requires a concrete to, got ${String(e)}`);let r=sr(this.db,`signaling_messages/${e}`),i=JSON.parse(JSON.stringify(n.payload)),o=await GE(r,{payload:i,signature:n.signature??"",ts:Date.now()});return this.logger.warn("[fallback] delivered via RTDB inbox",{to:e,type:n.payload.type,id:o.key}),{id:o.key??"unknown",channel:this.name}}async send(n){if(this.logger.info("[stream-check-056] send() pre",{from:n.payload.from,to:n.payload.to}),this.acceptsFallback(n))return this.sendFallbackMessage(n);if(!this.acceptsMessage(n))throw new Error(`[RtdbAnnounceChannel] only accepts announce messages, got ${n.payload.type}`);let e=n.payload.from;if(!e)throw new Error("[RtdbAnnounceChannel] message.payload.from is required");let r=`signaling_announce/${e}`,i=sr(this.db,r);try{this.ensureConnectionWatch(),this.onDisconnectRegisteredPaths.has(r)||(await fR(i).remove(),this.onDisconnectRegisteredPaths.add(r)),await cm(i,Date.now()),this.logger.info("[stream-check-057] send() OK",{path:`signaling_announce/${e}`})}catch(o){let s=o,a={path:`signaling_announce/${e}`,message:s?.message,code:s?.code,stackHead:s?.stack?.split(`
40
+ `).slice(0,3).join(" | ")};throw this.logger.error("[send] FAILED detail",a),new Error(`[RtdbAnnounceChannel.send] FAILED ${JSON.stringify(a)}`)}return{id:e,channel:this.name}}events(n,e){return n.length===0?ar.EMPTY:new ar.Observable(r=>{let i=n.map(o=>{let s=sr(this.db,`signaling_messages/${o}`);return zE(s,a=>{let c=a.val();c?.payload&&r.next({id:a.key??"unknown",payload:c.payload,signature:c.signature??""}),a.ref&&hR(a.ref).catch(()=>{})},a=>{this.logger.warn("[fallback] inbox listen error",{myId:o,message:a?.message})})});return()=>{for(let o of i)o()}}).pipe((0,ar.share)())}presence(n,e){return this.logger.info("[stream-check-058] presence() pre",{myIds:n}),new ar.Observable(r=>{let i=e?.allowedFromPeers??[];this.logger.info("[stream-check-059] presence() per-path subscribed",{watched:i.length});let o=i.map(s=>{let a=!1,c=sr(this.db,`signaling_announce/${s}`);return um(c,u=>{let l=u.val();if(typeof l=="number"){a=!0;let d={fromKey:s,generation:String(l),observedAt:Date.now()};this.logger.info("[stream-check-061] presence() emit",{fromKey:s}),r.next(d)}else a&&(a=!1,this.logger.info("[presence] lost",{fromKey:s}),r.next({fromKey:s,observedAt:Date.now(),lost:!0}))},u=>{this.logger.warn("[presence] onValue error:",{fromKey:s,error:u})})});return()=>{for(let s of o)s()}})}};function JE(t){return t.PLANX_SIGNALING_URL||L_.PLANX_SIGNALING_URL}function wR(t){let n=t.FIREBASE_DATABASE_EMULATOR_HOST,e=t.PLANX_FIREBASE_NAMESPACE;return n&&e?`http://${n}?ns=${e}`:t.PLANX_FIREBASE_DATABASE_URL||L_.PLANX_FIREBASE_DATABASE_URL}function ER(t,n){let e=!!n;return[...e&&n?hs(()=>new pm(n)):[],...bR({urlFactory:()=>JE(t),hashedSelfIdFactory:()=>w(Ce).config.config().identity?.signalingId??"",codecFactory:()=>new hm,excludeAnnounce:e})]}var gre="firebase",yre="12.7.0";ei(gre,yre,"app");console.error("[transport:boot:module-top] module-top-reached pid="+process.pid+" ts="+Date.now());console.error("[transport:boot:reflect-metadata] reflect-metadata-loaded pid="+process.pid);function vre(){let t=process.env.PLANX_IDENTITY_PUBLIC_KEY,n=process.env.PLANX_IDENTITY_PRIVATE_KEY;return!t||!n?null:{publicKey:t,privateKey:n,algorithm:"P-256",createdAt:new Date}}function _re(){let t=process.env.FIREBASE_DATABASE_EMULATOR_HOST,n=wR(process.env);!t&&!process.env.PLANX_FIREBASE_DATABASE_URL&&console.error(`[transport child] WARNING: PLANX_FIREBASE_DATABASE_URL not set. Falling back to prod default (${n})\u3002 supervisor parent (= cli / web-server) \u3067 env \u6CE8\u5165\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);try{let e=pw().length>0?pw()[0]:hw({databaseURL:n}),r=mR(e);if(t){let[i,o]=t.split(":"),s=Number(o??9e3);KE(r,i,s)}return r}catch(e){console.error("[transport child] firebase init failed, falling back to CF DO only:",e);return}}async function bre(){JE(process.env)||console.error("[transport child] WARNING: PLANX_SIGNALING_URL not set. Signaling will be no-op (NoopCloudflareDoSignalingChannel)\u3002 supervisor parent (= cli / web-server) \u3067 env \u6CE8\u5165\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002"),console.error("[transport:boot:env] main-aot env: PLANX_SERVER_NAME="+JSON.stringify(process.env.PLANX_SERVER_NAME)+" PLANX_TRANSPORT_TRPC_URL="+JSON.stringify(process.env.PLANX_TRANSPORT_TRPC_URL)+" WEBSERVER_INT_CF_SIGNALING="+JSON.stringify(process.env.WEBSERVER_INT_CF_SIGNALING)+" PLANX_FIREBASE_DATABASE_URL="+JSON.stringify(process.env.PLANX_FIREBASE_DATABASE_URL)+" PLANX_FIREBASE_NAMESPACE="+JSON.stringify(process.env.PLANX_FIREBASE_NAMESPACE)+" FIREBASE_DATABASE_EMULATOR_HOST="+JSON.stringify(process.env.FIREBASE_DATABASE_EMULATOR_HOST)+" PLANX_SIGNALING_URL="+JSON.stringify(process.env.PLANX_SIGNALING_URL)+" pid="+process.pid);let n=[],e=process.env.PLANX_TRANSPORT_KEY_FILE??`/tmp/transport-child-${process.pid}-keys.json`,r=await OD([...Yb(),...wp({keyFilePath:e,identityOverride:vre()}),vR({minLevel:He.INFO,useStderr:!0}),Ce,...ER(process.env,_re()),{provide:qa,useExisting:Wh},DO(()=>({roles:["server","client"],origin:"cli-server",allowPeersPublicKeys:[],connection:{timeoutMs:6e4,maxRetryCount:3,retryDelayMs:1e3},peerSessionOptions:{config:{iceServers:n,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",iceTransportPolicy:"all"}}}))]);$D(r.get(Ba));let i=fA({injector:r}),o=Number(process.env.PORT??0),s=process.env.HOST??"0.0.0.0";dT({fetch:i.fetch,port:o,hostname:s},d=>{console.log(`transport server is running at http://${d.address}:${d.port}`),hA(d.port,process.pid)});let a=r.get(Ce),c=process.env.PLANX_TRANSPORT_KEY_FILE,u;if(c){let d=r.get(kD);await d.initialize(),u=await P_(d,r.get(Ur)),await a.updateWebRTCConfig(f=>({...f,identity:u}))}else u=await(0,SR.firstValueFrom)(a.config.identity$);let l=a.config.config();console.error("[transport:boot:post-identity] main-aot post-identity: cfg.name="+JSON.stringify(l.name)+" cfg.serverName="+JSON.stringify(l.serverName)+" cfg.version="+JSON.stringify(l.version)+" cfg.roles="+JSON.stringify(l.roles)+" identity.peerId="+u.peerId+" pid="+process.pid),await a.start(),console.error("[transport:boot:start-done] main-aot transport.start done pid="+process.pid),pA(u.peerId),process.on("SIGTERM",()=>process.exit(0)),process.on("SIGINT",()=>process.exit(0)),process.on("uncaughtException",d=>{console.error("[transport] uncaughtException:",d?.stack??String(d)),process.exit(1)}),process.on("unhandledRejection",d=>{console.error("[transport] unhandledRejection:",d instanceof Error?d.stack:String(d)),process.exit(1)})}bre().catch(t=>{console.error("Failed to start transport server:",t),process.exit(1)});
41
41
  /*! Bundled license information:
42
42
 
43
43
  reflect-metadata/Reflect.js: