PageSourceSearch

https://app.mential.io/static/js/4908.732f7d7b.chunk.js

js mential.io collected 2026-09-24 10:56:16 UTC 133,970 bytes, 3 lines download raw bytes

1/*! For license information please see 4908.732f7d7b.chunk.js.LICENSE.txt */
2(self.webpackChunkchibana_app=self.webpackChunkchibana_app||[]).push([[4908],{59865:(e,t,n)=>{"use strict";var i=n(64836);t.Z=void 0;var s=i(n(66830)),r=n(62559);t.Z=(0,s.default)((0,r.jsx)("path",{d:"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7m0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5"}),"LocationOn")},60064:function(e){e.exports=(()=>{return e={705:e=>{e.exports=function(e,t){const n=[];return 0===t.length?n.push({text:e,highlight:!1}):t[0][0]>0&&n.push({text:e.slice(0,t[0][0]),highlight:!1}),t.forEach(((i,s)=>{const r=i[0],o=i[1];n.push({text:e.slice(r,o),highlight:!0}),s===t.length-1?o<e.length&&n.push({text:e.slice(o,e.length),highlight:!1}):o<t[s+1][0]&&n.push({text:e.slice(o,t[s+1][0]),highlight:!1})})),n}}},t={},function n(i){var s=t[i];if(void 0!==s)return s.exports;var r=t[i]={exports:{}};return e[i](r,r.exports,n),r.exports}(705);var e,t})()},14173:(e,t,n)=>{"use strict";n.d(t,{U2:()=>qs,N8:()=>Xs,vh:()=>js,jM:()=>Us,g2:()=>Bs,VF:()=>Fs,iH:()=>Ds,t8:()=>As});var i=n(14318),s=n(13227),r=n(38134),o=n(39824);const a="@firebase/database",l="0.13.9";let h="";class c{constructor(e){this.domStorage_=e,this.prefix_="firebase:"}set(e,t){null==t?this.domStorage_.removeItem(this.prefixedName_(e)):this.domStorage_.setItem(this.prefixedName_(e),(0,r.Wl)(t))}get(e){const t=this.domStorage_.getItem(this.prefixedName_(e));return null==t?null:(0,r.cI)(t)}remove(e){this.domStorage_.removeItem(this.prefixedName_(e))}prefixedName_(e){return this.prefix_+e}toString(){return this.domStorage_.toString()}}class u{constructor(){this.cache_={},this.isInMemoryStorage=!0}set(e,t){null==t?delete this.cache_[e]:this.cache_[e]=t}get(e){return(0,r.r3)(this.cache_,e)?this.cache_[e]:null}remove(e){delete this.cache_[e]}}const d=function(e){try{if("undefined"!==typeof window&&"undefined"!==typeof window[e]){const t=window[e];return t.setItem("firebase:sentinel","cache"),t.removeItem("firebase:sentinel"),new c(t)}}catch(t){}return new u},_=d("localStorage"),p=d("sessionStorage"),f=new o.Yd("@firebase/database"),g=function(){let e=1;return function(){return e++}}(),m=function(e){const t=(0,r.dS)(e),n=new r.gQ;n.update(t);const i=n.digest();return r.US.encodeByteArray(i)},y=function(){let e="";for(let t=0;t<arguments.length;t++){const n=t<0||arguments.length<=t?void 0:arguments[t];Array.isArray(n)||n&&"object"===typeof n&&"number"===typeof n.length?e+=y.apply(null,n):e+="object"===typeof n?(0,r.Wl)(n):n,e+=" "}return e};let v=null,C=!0;const w=function(e,t){(0,r.hu)(!t||!0===e||!1===e,"Can't turn on custom loggers persistently."),!0===e?(f.logLevel=o.in.VERBOSE,v=f.log.bind(f),t&&p.set("logging_enabled",!0)):"function"===typeof e?v=e:(v=null,p.remove("logging_enabled"))},T=function(){if(!0===C&&(C=!1,null===v&&!0===p.get("logging_enabled")&&w(!0)),v){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const i=y.apply(null,t);v(i)}},I=function(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];T(e,...n)}},b=function(){const e="FIREBASE INTERNAL ERROR: "+y(...arguments);f.error(e)},k=function(){const e="FIREBASE FATAL ERROR: ".concat(y(...arguments));throw f.error(e),new Error(e)},E=function(){const e="FIREBASE WARNING: "+y(...arguments);f.warn(e)},S=function(e){return"number"===typeof e&&(e!==e||e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY)},N="[MIN_NAME]",P="[MAX_NAME]",x=function(e,t){if(e===t)return 0;if(e===N||t===P)return-1;if(t===N||e===P)return 1;{const n=U(e),i=U(t);return null!==n?null!==i?n-i===0?e.length-t.length:n-i:-1:null!==i?1:e<t?-1:1}},R=function(e,t){return e===t?0:e<t?-1:1},D=function(e,t){if(t&&e in t)return t[e];throw new Error("Missing required key ("+e+") in object: "+(0,r.Wl)(t))},M=function(e){if("object"!==typeof e||null===e)return(0,r.Wl)(e);const t=[];for(const i in e)t.push(i);t.sort();let n="{";for(let i=0;i<t.length;i++)0!==i&&(n+=","),n+=(0,r.Wl)(t[i]),n+=":",n+=M(e[t[i]]);return n+="}",n},F=function(e,t){const n=e.length;if(n<=t)return[e];const i=[];for(let s=0;s<n;s+=t)s+t>n?i.push(e.substring(s,n)):i.push(e.substring(s,s+t));return i};function A(e,t){for(const n in e)e.hasOwnProperty(n)&&t(n,e[n])}const q=function(e){(0,r.hu)(!S(e),"Invalid JSON number");const t=1023;let n,i,s,o,a;0===e?(i=0,s=0,n=1/e===-1/0?1:0):(n=e<0,(e=Math.abs(e))>=Math.pow(2,-1022)?(o=Math.min(Math.floor(Math.log(e)/Math.LN2),t),i=o+t,s=Math.round(e*Math.pow(2,52-o)-Math.pow(2,52))):(i=0,s=Math.round(e/Math.pow(2,-1074))));const l=[];for(a=52;a;a-=1)l.push(s%2?1:0),s=Math.floor(s/2);for(a=11;a;a-=1)l.push(i%2?1:0),i=Math.floor(i/2);l.push(n?1:0),l.reverse();const h=l.join("");let c="";for(a=0;a<64;a+=8){let e=parseInt(h.substr(a,8),2).toString(16);1===e.length&&(e="0"+e),c+=e}return c.toLowerCase()};const O=new RegExp("^-?(0*)\\d{1,10}$"),L=-2147483648,W=2147483647,U=function(e){if(O.test(e)){const t=Number(e);if(t>=L&&t<=W)return t}return null},H=function(e){try{e()}catch(t){setTimeout((()=>{const e=t.stack||"";throw E("Exception was thrown by user callback.",e),t}),Math.floor(0))}},Y=function(e,t){const n=setTimeout(e,t);return"number"===typeof n&&"undefined"!==typeof Deno&&Deno.unrefTimer?Deno.unrefTimer(n):"object"===typeof n&&n.unref&&n.unref(),n};
2class j{constructor(e,t){this.appName_=e,this.appCheckProvider=t,this.appCheck=null===t||void 0===t?void 0:t.getImmediate({optional:!0}),this.appCheck||null===t||void 0===t||t.get().then((e=>this.appCheck=e))}getToken(e){return this.appCheck?this.appCheck.getToken(e):new Promise(((t,n)=>{setTimeout((()=>{this.appCheck?this.getToken(e).then(t,n):t(null)}),0)}))}addTokenChangeListener(e){var t;null===(t=this.appCheckProvider)||void 0===t||t.get().then((t=>t.addTokenListener(e)))}notifyForInvalidToken(){E('Provided AppCheck credentials for the app named "'.concat(this.appName_,'" ')+"are invalid. This usually indicates your app was not initialized correctly.")}}class V{constructor(e,t,n){this.appName_=e,this.firebaseOptions_=t,this.authProvider_=n,this.auth_=null,this.auth_=n.getImmediate({optional:!0}),this.auth_||n.onInit((e=>this.auth_=e))}getToken(e){return this.auth_?this.auth_.getToken(e).catch((e=>e&&"auth/token-not-initialized"===e.code?(T("Got auth/token-not-initialized error.  Treating as null token."),null):Promise.reject(e))):new Promise(((t,n)=>{setTimeout((()=>{this.auth_?this.getToken(e).then(t,n):t(null)}),0)}))}addTokenChangeListener(e){this.auth_?this.auth_.addAuthTokenListener(e):this.authProvider_.get().then((t=>t.addAuthTokenListener(e)))}removeTokenChangeListener(e){this.authProvider_.get().then((t=>t.removeAuthTokenListener(e)))}notifyForInvalidToken(){let e='Provided authentication credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.firebaseOptions_?e+='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_?e+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':e+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',E(e)}}class B{constructor(e){this.accessToken=e}getToken(e){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(e){e(this.accessToken)}removeTokenChangeListener(e){}notifyForInvalidToken(){}}B.OWNER="owner";const z="5",K=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,Q="websocket",G="long_polling";class ${constructor(e,t,n,i){let s=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"",o=arguments.length>6&&void 0!==arguments[6]&&arguments[6];this.secure=t,this.namespace=n,this.webSocketOnly=i,this.nodeAdmin=s,this.persistenceKey=r,this.includeNamespaceInQueryParams=o,this._host=e.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=_.get("host:"+e)||this._host}isCacheableHost(){return"s-"===this.internalHost.substr(0,2)}isCustomHost(){return"firebaseio.com"!==this._domain&&"firebaseio-demo.com"!==this._domain}get host(){return this._host}set host(e){e!==this.internalHost&&(this.internalHost=e,this.isCacheableHost()&&_.set("host:"+this._host,this.internalHost))}toString(){let e=this.toURLString();return this.persistenceKey&&(e+="<"+this.persistenceKey+">"),e}toURLString(){const e=this.secure?"https://":"http://",t=this.includeNamespaceInQueryParams?"?ns=".concat(this.namespace):"";return"".concat(e).concat(this.host,"/").concat(t)}}function X(e,t,n){let i;if((0,r.hu)("string"===typeof t,"typeof type must == string"),(0,r.hu)("object"===typeof n,"typeof params must == object"),t===Q)i=(e.secure?"wss://":"ws://")+e.internalHost+"/.ws?";else{if(t!==G)throw new Error("Unknown connection type: "+t);i=(e.secure?"https://":"http://")+e.internalHost+"/.lp?"}(function(e){return e.host!==e.internalHost||e.isCustomHost()||e.includeNamespaceInQueryParams})(e)&&(n.ns=e.namespace);const s=[];return A(n,((e,t)=>{s.push(e+"="+t)})),i+s.join("&")}class J{constructor(){this.counters_={}}incrementCounter(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;(0,r.r3)(this.counters_,e)||(this.counters_[e]=0),this.counters_[e]+=t}get(){return(0,r.p$)(this.counters_)}}const Z={},ee={};function te(e){const t=e.toString();return Z[t]||(Z[t]=new J),Z[t]}class ne{constructor(e){this.onMessage_=e,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}closeAfter(e,t){this.closeAfterResponse=e,this.onClose=t,this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)}handleResponse(e,t){for(this.pendingResponses[e]=t;this.pendingResponses[this.currentResponseNum];){const e=this.pendingResponses[this.currentResponseNum];delete this.pendingResponses[this.currentResponseNum];for(let t=0;t<e.length;++t)e[t]&&H((()=>{this.onMessage_(e[t])}));if(this.currentResponseNum===this.closeAfterResponse){this.onClose&&(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}}const ie="start",se="close";class re{constructor(e,t,n,i,s,r,o){this.connId=e,this.repoInfo=t,this.applicationId=n,this.appCheckToken=i,this.authToken=s,this.transportSessionId=r,this.lastSessionId=o,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=I(e),this.stats_=te(t),this.urlFn=e
2=>(this.appCheckToken&&(e.ac=this.appCheckToken),X(t,G,e))}open(e,t){var n=this;this.curSegmentNum=0,this.onDisconnect_=t,this.myPacketOrderer=new ne(e),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout((()=>{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null}),Math.floor(3e4)),function(e){if((0,r.Yr)()||"complete"===document.readyState)e();else{let t=!1;const n=function(){document.body?t||(t=!0,e()):setTimeout(n,Math.floor(10))};document.addEventListener?(document.addEventListener("DOMContentLoaded",n,!1),window.addEventListener("load",n,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",(()=>{"complete"===document.readyState&&n()})),window.attachEvent("onload",n))}}((()=>{if(this.isClosed_)return;this.scriptTagHolder=new oe((function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];const[s,r,o,a,l]=t;if(n.incrementIncomingBytes_(t),n.scriptTagHolder)if(n.connectTimeoutTimer_&&(clearTimeout(n.connectTimeoutTimer_),n.connectTimeoutTimer_=null),n.everConnected_=!0,s===ie)n.id=r,n.password=o;else{if(s!==se)throw new Error("Unrecognized command received: "+s);r?(n.scriptTagHolder.sendNewPolls=!1,n.myPacketOrderer.closeAfter(r,(()=>{n.onClosed_()}))):n.onClosed_()}}),(function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];const[s,r]=t;n.incrementIncomingBytes_(t),n.myPacketOrderer.handleResponse(s,r)}),(()=>{this.onClosed_()}),this.urlFn);const e={start:"t"};e.ser=Math.floor(1e8*Math.random()),this.scriptTagHolder.uniqueCallbackIdentifier&&(e.cb=this.scriptTagHolder.uniqueCallbackIdentifier),e.v=z,this.transportSessionId&&(e.s=this.transportSessionId),this.lastSessionId&&(e.ls=this.lastSessionId),this.applicationId&&(e.p=this.applicationId),this.appCheckToken&&(e.ac=this.appCheckToken),"undefined"!==typeof location&&location.hostname&&K.test(location.hostname)&&(e.r="f");const t=this.urlFn(e);this.log_("Connecting via long-poll to "+t),this.scriptTagHolder.addTag(t,(()=>{}))}))}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){re.forceAllow_=!0}static forceDisallow(){re.forceDisallow_=!0}static isAvailable(){return!(0,r.Yr)()&&(!!re.forceAllow_||!re.forceDisallow_&&"undefined"!==typeof document&&null!=document.createElement&&!("object"===typeof window&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href))&&!("object"===typeof Windows&&"object"===typeof Windows.UI))}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(e){const t=(0,r.Wl)(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const n=(0,r.h$)(t),i=F(n,1840);for(let s=0;s<i.length;s++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,i.length,i[s]),this.curSegmentNum++}addDisconnectPingFrame(e,t){if((0,r.Yr)())return;this.myDisconnFrame=document.createElement("iframe");const n={dframe:"t"};n.id=e,n.pw=t,this.myDisconnFrame.src=this.urlFn(n),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}incrementIncomingBytes_(e){const t=(0,r.Wl)(e).length;this.bytesReceived+=t,this.stats_.incrementCounter("bytes_received",t)}}class oe{constructor(e,t,n,i){if(this.onDisconnect=n,this.urlFn=i,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(1e8*Math.random()),this.sendNewPolls=!0,(0,r.Yr)())this.commandCB=e,this.onMessageCB=t;else{this.uniqueCallbackIdentifier=g(),window["pLPCommand"+this.uniqueCallbackIdentifier]=e,window["pRTLPCB"+this.uniqueCallbackIdentifier]=t,this.myIFrame=oe.createI
2Frame_();let n="";if(this.myIFrame.src&&"javascript:"===this.myIFrame.src.substr(0,"javascript:".length)){n='<script>document.domain="'+document.domain+'";<\/script>'}const i="<html><body>"+n+"</body></html>";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(i),this.myIFrame.doc.close()}catch(s){T("frame writing exception"),s.stack&&T(s.stack),T(s)}}}static createIFrame_(){const e=document.createElement("iframe");if(e.style.display="none",!document.body)throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";document.body.appendChild(e);try{e.contentWindow.document||T("No IE domain setting required")}catch(t){const n=document.domain;e.src="javascript:void((function(){document.open();document.domain='"+n+"';document.close();})())"}return e.contentDocument?e.doc=e.contentDocument:e.contentWindow?e.doc=e.contentWindow.document:e.document&&(e.doc=e.document),e}close(){this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.innerHTML="",setTimeout((()=>{null!==this.myIFrame&&(document.body.removeChild(this.myIFrame),this.myIFrame=null)}),Math.floor(0)));const e=this.onDisconnect;e&&(this.onDisconnect=null,e())}startLongPoll(e,t){for(this.myID=e,this.myPW=t,this.alive=!0;this.newRequest_(););}newRequest_(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(this.pendingSegs.length>0?2:1)){this.currentSerial++;const e={};e.id=this.myID,e.pw=this.myPW,e.ser=this.currentSerial;let t=this.urlFn(e),n="",i=0;for(;this.pendingSegs.length>0;){if(!(this.pendingSegs[0].d.length+30+n.length<=1870))break;{const e=this.pendingSegs.shift();n=n+"&seg"+i+"="+e.seg+"&ts"+i+"="+e.ts+"&d"+i+"="+e.d,i++}}return t+=n,this.addLongPollTag_(t,this.currentSerial),!0}return!1}enqueueSegment(e,t,n){this.pendingSegs.push({seg:e,ts:t,d:n}),this.alive&&this.newRequest_()}addLongPollTag_(e,t){this.outstandingRequests.add(t);const n=()=>{this.outstandingRequests.delete(t),this.newRequest_()},i=setTimeout(n,Math.floor(25e3));this.addTag(e,(()=>{clearTimeout(i),n()}))}addTag(e,t){(0,r.Yr)()?this.doNodeLongPoll(e,t):setTimeout((()=>{try{if(!this.sendNewPolls)return;const n=this.myIFrame.doc.createElement("script");n.type="text/javascript",n.async=!0,n.src=e,n.onload=n.onreadystatechange=function(){const e=n.readyState;e&&"loaded"!==e&&"complete"!==e||(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),t())},n.onerror=()=>{T("Long-poll script failed to load: "+e),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(n)}catch(n){}}),Math.floor(1))}}let ae=null;"undefined"!==typeof MozWebSocket?ae=MozWebSocket:"undefined"!==typeof WebSocket&&(ae=WebSocket);class le{constructor(e,t,n,i,s,r,o){this.connId=e,this.applicationId=n,this.appCheckToken=i,this.authToken=s,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=I(this.connId),this.stats_=te(t),this.connURL=le.connectionURL_(t,r,o,i,n),this.nodeAdmin=t.nodeAdmin}static connectionURL_(e,t,n,i,s){const o={};return o.v=z,!(0,r.Yr)()&&"undefined"!==typeof location&&location.hostname&&K.test(location.hostname)&&(o.r="f"),t&&(o.s=t),n&&(o.ls=n),i&&(o.ac=i),s&&(o.p=s),X(e,Q,o)}open(e,t){this.onDisconnect=t,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,_.set("previous_websocket_failure",!0);try{let e;if((0,r.Yr)()){const t=this.nodeAdmin?"AdminNode":"Node";e={headers:{"User-Agent":"Firebase/".concat(z,"/").concat(h,"/").concat(process.platform,"/").concat(t),"X-Firebase-GMPID":this.applicationId||""}},this.authToken&&(e.headers.Authorization="Bearer ".concat(this.authToken)),this.appCheckToken&&(e.headers["X-Firebase-AppCheck"]=this.appCheckToken);const n={NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0},i=0===this.connURL.indexOf("wss://")?n.HTTPS_PROXY||n.https_proxy:n.HTTP_PROXY||n.http_proxy;i&&(e.proxy={origin:i})}this.mySock=new ae(this.connURL,[],e)}catch(n){this.log_("Error instantiating WebSocket.");const e=n.message||n.data;return e&&this.log_(e),void this.onClosed_()}this.mySock.onopen=()=>{this.log_("Websocket connected."),this.everConnected_=!0}
vendor: 13,088 bytes, line 2
2,this.mySock.onclose=()=>{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()},this.mySock.onmessage=e=>{this.handleIncomingFrame(e)},this.mySock.onerror=e=>{this.log_("WebSocket error.  Closing connection.");const t=e.message||e.data;t&&this.log_(t),this.onClosed_()}}start(){}static forceDisallow(){le.forceDisallow_=!0}static isAvailable(){let e=!1;if("undefined"!==typeof navigator&&navigator.userAgent){const t=/Android ([0-9]{0,}\.[0-9]{0,})/,n=navigator.userAgent.match(t);n&&n.length>1&&parseFloat(n[1])<4.4&&(e=!0)}return!e&&null!==ae&&!le.forceDisallow_}static previouslyFailed(){return _.isInMemoryStorage||!0===_.get("previous_websocket_failure")}markConnectionHealthy(){_.remove("previous_websocket_failure")}appendFrame_(e){if(this.frames.push(e),this.frames.length===this.totalFrames){const e=this.frames.join("");this.frames=null;const t=(0,r.cI)(e);this.onMessage(t)}}handleNewFrameCount_(e){this.totalFrames=e,this.frames=[]}extractFrameCount_(e){if((0,r.hu)(null===this.frames,"We already have a frame buffer"),e.length<=6){const t=Number(e);if(!isNaN(t))return this.handleNewFrameCount_(t),null}return this.handleNewFrameCount_(1),e}handleIncomingFrame(e){if(null===this.mySock)return;const t=e.data;if(this.bytesReceived+=t.length,this.stats_.incrementCounter("bytes_received",t.length),this.resetKeepAlive(),null!==this.frames)this.appendFrame_(t);else{const e=this.extractFrameCount_(t);null!==e&&this.appendFrame_(e)}}send(e){this.resetKeepAlive();const t=(0,r.Wl)(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const n=F(t,16384);n.length>1&&this.sendString_(String(n.length));for(let i=0;i<n.length;i++)this.sendString_(n[i])}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(45e3))}sendString_(e){try{this.mySock.send(e)}catch(t){this.log_("Exception thrown from WebSocket.send():",t.message||t.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}}}le.responsesRequiredToBeHealthy=2,le.healthyTimeout=3e4;class he{constructor(e){this.initTransports_(e)}static get ALL_TRANSPORTS(){return[re,le]}static get IS_TRANSPORT_INITIALIZED(){return this.globalTransportInitialized_}initTransports_(e){const t=le&&le.isAvailable();let n=t&&!le.previouslyFailed();if(e.webSocketOnly&&(t||E("wss:// URL used, but browser isn't known to support websockets.  Trying anyway."),n=!0),n)this.transports_=[le];else{const e=this.transports_=[];for(const t of he.ALL_TRANSPORTS)t&&t.isAvailable()&&e.push(t);he.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}}he.globalTransportInitialized_=!1;class ce{constructor(e,t,n,i,s,r,o,a,l,h){this.id=e,this.repoInfo_=t,this.applicationId_=n,this.appCheckToken_=i,this.authToken_=s,this.onMessage_=r,this.onReady_=o,this.onDisconnect_=a,this.onKill_=l,this.lastSessionId=h,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=I("c:"+this.id+":"),this.transportManager_=new he(t),this.log_("Connection created"),this.start_()}start_(){const e=this.transportManager_.initialTransport();this.conn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,null,this.lastSessionId),this.primaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.conn_),n=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout((()=>{this.conn_&&this.conn_.open(t,n)}),Math.floor(0));const i=e.healthyTimeout||0;i>0&&(this.healthyTimeout_=Y((()=>{this.healthyTimeout_=null,this.isHealthy_||(this.conn_&&this.conn_.bytesReceived>102400?(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>10240?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_(e){return t=>{e===this.conn_?this.onConnectionLost_(t):e===this.secondaryConn_?(this.log_("Secondary connection lost."),this.onSecondaryConnectionLost_()):this.log_("closing an old connection")}}connReceiver_(e){return t=>{2!==this.state_&&(e===this.rx_?this.onPrimaryMessageReceived_(t):e===this.secondaryConn_?this.onSecondaryMessageReceived_(t):this.log_("message on old connection"))}}sendRequest(e){const t={t:"d",d:e};this.sendData_(t)}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_(e){if("t"in e){const t=e.t;"a"===t?this.upgradeIfSecondaryHealthy_():"r"===t?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),this.tx_!==this.secondaryConn_&&this.rx_!==this.secondaryConn_||this.close()):"o"===t&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}}onSecondaryMessageReceived_(e){const t=D("t",e),n=D("d",e);if("c"===t)this.onSecondaryControl_(n);else{if("d"!==t)throw new Error("Unknown protocol layer: "+t);this.pendingDataMessages.push(n)}}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:"p",d:{}}}))}proceedWithUpgrade_(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:"a",d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:"n",d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()}onPrimaryMessageReceived_(e){const t=D("t",e),n=D("d",e);"c"===t?this.onControl_(n):"d"===t&&this.onDataMessage_(n)}onDataMessage_(e){this.onPrimaryResponse_(),this.onMessage_(e)}onPrimaryResponse_(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))}onControl_(e){const t=D("t",e);if("d"in e){const n=e.d;if("h"===t)this.onHandshake_(n);else if("n"===t){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(let e=0;e<this.pendingDataMessages.length;++e)this.onDataMessage_(this.pendingDataMessages[e]);this.pendingDataMessages=[],this.tryCleanupConnection()}else"s"===t?this.onConnectionShutdown_(n):"r"===t?this.onReset_(n):"e"===t?b("Server Error: "+n):"o"===t?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):b("Unknown control packet command: "+t)}}onHandshake_(e){const t=e.ts,n=e.v,i=e.h;this.sessionId=e.s,this.repoInfo_.host=i,0===this.state_&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,t),z!==n&&E("Protocol version mismatch detected"),this.tryStartUpgrade_())}tryStartUpgrade_(){const e=this.transportManager_.upgradeTransport();e&&this.startUpgrade_(e)}startUpgrade_(e){this.secondaryConn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,this.sessionId),this.secondaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.secondaryConn_),n=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(t,n),Y((()=>{this.secondaryConn_&&(this.log_("Timed out trying to upgrade."),this.secondaryConn_.close())}),Math.floor(6e4))}onReset_(e){this.log_("Reset packet received.  New host: "+e),this.repoInfo_.host=e,1===this.state_?this.close():(this.closeConnections_(),this.start_())}onConnectionEstablished_(e,t){this.log_("Realtime connection established."),this.conn_=e,this.state_=1,this.onReady_&&(this.onReady_(t,this.sessionId),this.onReady_=null),0===this.primaryResponsesRequired_?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):Y((()=>{this.sendPingOnPrimaryIfNecessary_()}),Math.floor(5e3))}sendPingOnPrimaryIfNecessary_(){this.isHealthy_||1!==this.state_||(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:"p",d:{}}}))}onSecondaryConnectionLost_(){const e=this.secondaryConn_;this.secondaryConn_=null,this.tx_!==e&&this.rx_!==e||this.close()}onConnectionLost_(e){this.conn_=null,e||0!==this.state_?1===this.state_&&this.log_("Realtime connection lost."):(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(_.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)),this.close()}onConnectionShutdown_(e){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&&(this.onKill_(e),this.onKill_=null),this.onDisconnect_=null,this.close()}sendData_(e){if(1!==this.state_)throw"Connection is not connected";this.tx_.send(e)}close(){2!==this.state_&&(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)}}class ue{put(e,t,n,i){}merge(e,t,n,i){}refreshAuthToken(e){}refreshAppCheckToken(e){}onDisconnectPut(e,t,n){}onDisconnectMerge(e,t,n){}onDisconnectCancel(e,t){}reportStats(e){}}class de{constructor(e){this.allowedEvents_=e,this.listeners_={},(0,r.hu)(Array.isArray(e)&&e.length>0,"Requires a non-empty array")}trigger(e){if(Array.isArray(this.listeners_[e])){const s=[...this.listeners_[e]];for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];for(let e=0;e<s.length;e++)s[e].callback.apply(s[e].context,n)}}on(e,t,n){this.validateEventType_(e),this.listeners_[e]=this.listeners_[e]||[],this.listeners_[e].push({callback:t,context:n});const i=this.getInitialEvent(e);i&&t.apply(n,i)}off(e,t,n){this.validateEventType_(e);const i=this.listeners_[e]||[];for(let s=0;s<i.length;s++)if(i[s].callback===t&&(!n||n===i[s].context))return void i.splice(s,1)}validateEventType_(e){(0,r.hu)(this.allowedEvents_.find((t=>t===e)),"Unknown event: "+e)}}class _e extends de{constructor(){super(["online"]),this.online_=!0,"undefined"===typeof window||"undefined"===typeof window.addEventListener||(0,r.uI)()||(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))}static getInstance(){return new _e}getInitialEvent(e){return(0,r.hu)("online"===e,"Unknown event type: "+e),[this.online_]}currentlyOnline(){return this.online_}}class pe{constructor(e,t){if(void 0===t){this.pieces_=e.split("/");let t=0;for(let e=0;e<this.pieces_.length;e++)this.pieces_[e].length>0&&(this.pieces_[t]=this.pieces_[e],t++);this.pieces_.length=t,this.pieceNum_=0}else this.pieces_=e,this.pieceNum_=t}toString(){let e="";for(let t=this.pieceNum_;t<this.pieces_.length;t++)""!==this.pieces_[t]&&(e+="/"+this.pieces_[t]);return e||"/"}}function fe(){return new pe("")}function ge(e){return e.pieceNum_>=e.pieces_.length?null:e.pieces_[e.pieceNum_]}function me(e){return e.pieces_.length-e.pieceNum_}function ye(e){let t=e.pieceNum_;return t<e.pieces_.length&&t++,new pe(e.pieces_,t)}function ve(e){return e.pieceNum_<e.pieces_.length?e.pieces_[e.pieces_.length-1]:null}function Ce(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e.pieces_.slice(e.pieceNum_+t)}function we(e){if(e.pieceNum_>=e.pieces_.length)return null;const t=[];for(let n=e.pieceNum_;n<e.pieces_.length-1;n++)t.push(e.pieces_[n]);return new pe(t,0)}function Te(e,t){const n=[];for(let i=e.pieceNum_;i<e.pieces_.length;i++)n.push(e.pieces_[i]);if(t instanceof pe)for(let i=t.pieceNum_;i<t.pieces_.length;i++)n.push(t.pieces_[i]);else{const e=t.split("/");for(let t=0;t<e.length;t++)e[t].length>0&&n.push(e[t])}return new pe(n,0)}function Ie(e){return e.pieceNum_>=e.pieces_.length}function be(e,t){const n=ge(e),i=ge(t);if(null===n)return t;if(n===i)return be(ye(e),ye(t));
2throw new Error("INTERNAL ERROR: innerPath ("+t+") is not within outerPath ("+e+")")}function ke(e,t){if(me(e)!==me(t))return!1;for(let n=e.pieceNum_,i=t.pieceNum_;n<=e.pieces_.length;n++,i++)if(e.pieces_[n]!==t.pieces_[i])return!1;return!0}function Ee(e,t){let n=e.pieceNum_,i=t.pieceNum_;if(me(e)>me(t))return!1;for(;n<e.pieces_.length;){if(e.pieces_[n]!==t.pieces_[i])return!1;++n,++i}return!0}class Se{constructor(e,t){this.errorPrefix_=t,this.parts_=Ce(e,0),this.byteLength_=Math.max(1,this.parts_.length);for(let n=0;n<this.parts_.length;n++)this.byteLength_+=(0,r.ug)(this.parts_[n]);Ne(this)}}function Ne(e){if(e.byteLength_>768)throw new Error(e.errorPrefix_+"has a key path longer than 768 bytes ("+e.byteLength_+").");if(e.parts_.length>32)throw new Error(e.errorPrefix_+"path specified exceeds the maximum depth that can be written (32) or object contains a cycle "+Pe(e))}function Pe(e){return 0===e.parts_.length?"":"in property '"+e.parts_.join(".")+"'"}class xe extends de{constructor(){let e,t;super(["visible"]),"undefined"!==typeof document&&"undefined"!==typeof document.addEventListener&&("undefined"!==typeof document.hidden?(t="visibilitychange",e="hidden"):"undefined"!==typeof document.mozHidden?(t="mozvisibilitychange",e="mozHidden"):"undefined"!==typeof document.msHidden?(t="msvisibilitychange",e="msHidden"):"undefined"!==typeof document.webkitHidden&&(t="webkitvisibilitychange",e="webkitHidden")),this.visible_=!0,t&&document.addEventListener(t,(()=>{const t=!document[e];t!==this.visible_&&(this.visible_=t,this.trigger("visible",t))}),!1)}static getInstance(){return new xe}getInitialEvent(e){return(0,r.hu)("visible"===e,"Unknown event type: "+e),[this.visible_]}}const Re=1e3;class De extends ue{constructor(e,t,n,i,s,o,a,l){if(super(),this.repoInfo_=e,this.applicationId_=t,this.onDataUpdate_=n,this.onConnectStatus_=i,this.onServerInfoUpdate_=s,this.authTokenProvider_=o,this.appCheckTokenProvider_=a,this.authOverride_=l,this.id=De.nextPersistentConnectionId_++,this.log_=I("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_=Re,this.maxReconnectDelay_=3e5,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,l&&!(0,r.Yr)())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");xe.getInstance().on("visible",this.onVisible_,this),-1===e.host.indexOf("fblocal")&&_e.getInstance().on("online",this.onOnline_,this)}sendRequest(e,t,n){const i=++this.requestNumber_,s={r:i,a:e,b:t};this.log_((0,r.Wl)(s)),(0,r.hu)(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(s),n&&(this.requestCBHash_[i]=n)}get(e){this.initConnection_();const t=new r.BH,n={action:"g",request:{p:e._path.toString(),q:e._queryObject},onComplete:e=>{const n=e.d;"ok"===e.s?t.resolve(n):t.reject(n)}};this.outstandingGets_.push(n),this.outstandingGetCount_++;const i=this.outstandingGets_.length-1;return this.connected_&&this.sendGet_(i),t.promise}listen(e,t,n,i){this.initConnection_();const s=e._queryIdentifier,o=e._path.toString();this.log_("Listen called for "+o+" "+s),this.listens.has(o)||this.listens.set(o,new Map),(0,r.hu)(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),(0,r.hu)(!this.listens.get(o).has(s),"listen() called twice for same path/queryId.");const a={onComplete:i,hashFn:t,query:e,tag:n};this.listens.get(o).set(s,a),this.connected_&&this.sendListen_(a)}sendGet_(e){const t=this.outstandingGets_[e];this.sendRequest("g",t.request,(n=>{delete this.outstandingGets_[e],this.outstandingGetCount_--,0===this.outstandingGetCount_&&(this.outstandingGets_=[]),t.onComplete&&t.onComplete(n)}))}sendListen_(e){const t=e.query,n=t._path.toString(),i=t._queryIdentifier;this.log_("Listen on "+n+" for "+i);const s={p:n};e.tag&&(s.q=t._queryObject,s.t=e.tag),s.h=e.hashFn(),this.sendRequest("q",s,(s=>{const r=s.d,o=s.s;De.warnOnListenWarnings_(r,t);(this.listens.get(n)&&this.listens.get(n).get(i))===e&&(this.log_("listen response",s),"ok"!==o&&this.removeListen_(n,i),e.onComplete&&e.onComplete(o,r))}))}static warnOnListenWarnings_(e,t){if(e&&"object"===typeof e&&(0,r.r3)(e,"w")){const n=(0,r.DV)(e,"w");if(Array.isArray(n)&&~n.indexOf("no_index")){const e='".indexOn": "'+t._queryParams.getIndex().toString()+'"',n=t._path.toString();E("Using an unspecified index. Your data will be downloaded and "+"filtered on the client. Consider adding ".concat(e," at ")+"".concat(n," 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&&40===e.length||(0,r.GJ)(e))&&(this.log_("Admin auth credential detected.  Reducing max reconnect time."),this.maxReconnectDelay_=3e4)}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_){const e=this.authToken_,t=(0,r.w9)(e)?"auth":"gauth",n={cred:e};null===this.authOverride_?n.noauth=!0:"object"===typeof this.authOverride_&&(n.authvar=this.authOverride_),this.sendRequest(t,n,(t=>{const n=t.s,i=t.d||"error";this.authToken_===e&&("ok"===n?this.invalidAuthTokenCount_=0:this.onAuthRevoked_(n,i))}))}}tryAppCheck(){this.connected_&&this.appCheckToken_&&this.sendRequest("appcheck",{token:this.appCheckToken_},(e=>{const t=e.s,n=e.d||"error";"ok"===t?this.invalidAppCheckTokenCount_=0:this.onAppCheckRevoked_(t,n)}
vendor: 4,437 bytes, line 2
2))}unlisten(e,t){const n=e._path.toString(),i=e._queryIdentifier;this.log_("Unlisten called for "+n+" "+i),(0,r.hu)(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"unlisten() called for non-default but complete query");this.removeListen_(n,i)&&this.connected_&&this.sendUnlisten_(n,i,e._queryObject,t)}sendUnlisten_(e,t,n,i){this.log_("Unlisten on "+e+" for "+t);const s={p:e};i&&(s.q=n,s.t=i),this.sendRequest("n",s)}onDisconnectPut(e,t,n){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",e,t,n):this.onDisconnectRequestQueue_.push({pathString:e,action:"o",data:t,onComplete:n})}onDisconnectMerge(e,t,n){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",e,t,n):this.onDisconnectRequestQueue_.push({pathString:e,action:"om",data:t,onComplete:n})}onDisconnectCancel(e,t){this.initConnection_(),this.connected_?this.sendOnDisconnect_("oc",e,null,t):this.onDisconnectRequestQueue_.push({pathString:e,action:"oc",data:null,onComplete:t})}sendOnDisconnect_(e,t,n,i){const s={p:t,d:n};this.log_("onDisconnect "+e,s),this.sendRequest(e,s,(e=>{i&&setTimeout((()=>{i(e.s,e.d)}),Math.floor(0))}))}put(e,t,n,i){this.putInternal("p",e,t,n,i)}merge(e,t,n,i){this.putInternal("m",e,t,n,i)}putInternal(e,t,n,i,s){this.initConnection_();const r={p:t,d:n};void 0!==s&&(r.h=s),this.outstandingPuts_.push({action:e,request:r,onComplete:i}),this.outstandingPutCount_++;const o=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(o):this.log_("Buffering put: "+t)}sendPut_(e){const t=this.outstandingPuts_[e].action,n=this.outstandingPuts_[e].request,i=this.outstandingPuts_[e].onComplete;this.outstandingPuts_[e].queued=this.connected_,this.sendRequest(t,n,(n=>{this.log_(t+" response",n),delete this.outstandingPuts_[e],this.outstandingPutCount_--,0===this.outstandingPutCount_&&(this.outstandingPuts_=[]),i&&i(n.s,n.d)}))}reportStats(e){if(this.connected_){const t={c:e};this.log_("reportStats",t),this.sendRequest("s",t,(e=>{if("ok"!==e.s){const t=e.d;this.log_("reportStats","Error sending stats: "+t)}}))}}onDataMessage_(e){if("r"in e){this.log_("from server: "+(0,r.Wl)(e));const t=e.r,n=this.requestCBHash_[t];n&&(delete this.requestCBHash_[t],n(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,t){this.log_("handleServerMessage",e,t),"d"===e?this.onDataUpdate_(t.p,t.d,!1,t.t):"m"===e?this.onDataUpdate_(t.p,t.d,!0,t.t):"c"===e?this.onListenRevoked_(t.p,t.q):"ac"===e?this.onAuthRevoked_(t.s,t.d):"apc"===e?this.onAppCheckRevoked_(t.s,t.d):"sd"===e?this.onSecurityDebugPacket_(t):b("Unrecognized action received from server: "+(0,r.Wl)(e)+"\nAre you using the latest client?")}onReady_(e,t){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=(new Date).getTime(),this.handleTimestamp_(e),this.lastSessionId=t,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)}scheduleConnect_(e){(0,r.hu)(!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_=Re,this.realtime_||this.scheduleConnect_(0)),this.visible_=e}onOnline_(e){e?(this.log_("Browser went online."),this.reconnectDelay_=Re,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_()){if(this.visible_){if(this.lastConnectionEstablishedTime_){(new Date).getTime()-this.lastConnectionEstablishedTime_>3e4&&(this.reconnectDelay_=Re),this.lastConnectionEstablishedTime_=null}}else this.log_("Window isn't visible.  Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=(new Date).getTime();const e=(new Date).getTime()-this.lastConnectionAttemptTime_;let t=Math.max(0,this.reconnectDelay_-e);
2t=Math.random()*t,this.log_("Trying to reconnect in "+t+"ms"),this.scheduleConnect_(t),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,1.3*this.reconnectDelay_)}this.onConnectStatus_(!1)}async establishConnection_(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=(new Date).getTime(),this.lastConnectionEstablishedTime_=null;const e=this.onDataMessage_.bind(this),t=this.onReady_.bind(this),n=this.onRealtimeDisconnect_.bind(this),i=this.id+":"+De.nextConnectionId_++,s=this.lastSessionId;let o=!1,a=null;const l=function(){a?a.close():(o=!0,n())},h=function(e){(0,r.hu)(a,"sendRequest call when we're not connected not allowed."),a.sendRequest(e)};this.realtime_={close:l,sendRequest:h};const c=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{const[r,l]=await Promise.all([this.authTokenProvider_.getToken(c),this.appCheckTokenProvider_.getToken(c)]);o?T("getToken() completed but was canceled"):(T("getToken() completed. Creating connection."),this.authToken_=r&&r.accessToken,this.appCheckToken_=l&&l.token,a=new ce(i,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,t,n,(e=>{E(e+" ("+this.repoInfo_.toString()+")"),this.interrupt("server_kill")}),s))}catch(b){this.log_("Failed to get token: "+b),o||(this.repoInfo_.nodeAdmin&&E(b),l())}}}interrupt(e){T("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){T("Resuming connection for reason: "+e),delete this.interruptReasons_[e],(0,r.xb)(this.interruptReasons_)&&(this.reconnectDelay_=Re,this.realtime_||this.scheduleConnect_(0))}handleTimestamp_(e){const t=e-(new Date).getTime();this.onServerInfoUpdate_({serverTimeOffset:t})}cancelSentTransactions_(){for(let e=0;e<this.outstandingPuts_.length;e++){const t=this.outstandingPuts_[e];t&&"h"in t.request&&t.queued&&(t.onComplete&&t.onComplete("disconnect"),delete this.outstandingPuts_[e],this.outstandingPutCount_--)}0===this.outstandingPutCount_&&(this.outstandingPuts_=[])}onListenRevoked_(e,t){let n;n=t?t.map((e=>M(e))).join("$"):"default";const i=this.removeListen_(e,n);i&&i.onComplete&&i.onComplete("permission_denied")}removeListen_(e,t){const n=new pe(e).toString();let i;if(this.listens.has(n)){const e=this.listens.get(n);i=e.get(t),e.delete(t),0===e.size&&this.listens.delete(n)}else i=void 0;return i}onAuthRevoked_(e,t){T("Auth token revoked: "+e+"/"+t),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),"invalid_token"!==e&&"permission_denied"!==e||(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_>=3&&(this.reconnectDelay_=3e4,this.authTokenProvider_.notifyForInvalidToken()))}onAppCheckRevoked_(e,t){T("App check token revoked: "+e+"/"+t),this.appCheckToken_=null,this.forceTokenRefresh_=!0,"invalid_token"!==e&&"permission_denied"!==e||(this.invalidAppCheckTokenCount_++,this.invalidAppCheckTokenCount_>=3&&this.appCheckTokenProvider_.notifyForInvalidToken())}onSecurityDebugPacket_(e){this.securityDebugCallback_?this.securityDebugCallback_(e):"msg"in e&&console.log("FIREBASE: "+e.msg.replace("\n","\nFIREBASE: "))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of this.listens.values())for(const t of e.values())this.sendListen_(t);for(let e=0;e<this.outstandingPuts_.length;e++)this.outstandingPuts_[e]&&this.sendPut_(e);for(;this.onDisconnectRequestQueue_.length;){const 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_(){const e={};let t="js";(0,r.Yr)()&&(t=this.repoInfo_.nodeAdmin?"admin_node":"node"),e["sdk."+t+"."+h.replace(/\./g,"-")]=1,(0,r.uI)()?e["framework.cordova"]=1:(0,r.b$)()&&(e["framework.reactnative"]=1),this.reportStats(e)}shouldReconnect_(){const e=_e.getInstance().currentlyOnline();return(0,r.xb)(this.interruptReasons_)&&e}}De.nextPersistentConnectionId_=0,De.nextConnectionId_=0;class Me{constructor(e,t){this.name=e,this.node=t}static Wrap(e,t){return new Me(e,t)}}class Fe{getCompare(){return this.compare.bind(this)}indexedValueChanged(e,t){const n=new Me(N,e),i=new Me(N,t);return 0!==this.compare(n,i)}
vendor: 4,135 bytes, line 2
2minPost(){return Me.MIN}}let Ae;class qe extends Fe{static get __EMPTY_NODE(){return Ae}static set __EMPTY_NODE(e){Ae=e}compare(e,t){return x(e.name,t.name)}isDefinedOn(e){throw(0,r.g5)("KeyIndex.isDefinedOn not expected to be called.")}indexedValueChanged(e,t){return!1}minPost(){return Me.MIN}maxPost(){return new Me(P,Ae)}makePost(e,t){return(0,r.hu)("string"===typeof e,"KeyIndex indexValue must always be a string."),new Me(e,Ae)}toString(){return".key"}}const Oe=new qe;class Le{constructor(e,t,n,i){let s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;this.isReverse_=i,this.resultGenerator_=s,this.nodeStack_=[];let r=1;for(;!e.isEmpty();)if(r=t?n(e.key,t):1,i&&(r*=-1),r<0)e=this.isReverse_?e.left:e.right;else{if(0===r){this.nodeStack_.push(e);break}this.nodeStack_.push(e),e=this.isReverse_?e.right:e.left}}getNext(){if(0===this.nodeStack_.length)return null;let e,t=this.nodeStack_.pop();if(e=this.resultGenerator_?this.resultGenerator_(t.key,t.value):{key:t.key,value:t.value},this.isReverse_)for(t=t.left;!t.isEmpty();)this.nodeStack_.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack_.push(t),t=t.left;return e}hasNext(){return this.nodeStack_.length>0}peek(){if(0===this.nodeStack_.length)return null;const e=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value}}}class We{constructor(e,t,n,i,s){this.key=e,this.value=t,this.color=null!=n?n:We.RED,this.left=null!=i?i:Ue.EMPTY_NODE,this.right=null!=s?s:Ue.EMPTY_NODE}copy(e,t,n,i,s){return new We(null!=e?e:this.key,null!=t?t:this.value,null!=n?n:this.color,null!=i?i:this.left,null!=s?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,t,n){let i=this;const s=n(e,i.key);return i=s<0?i.copy(null,null,null,i.left.insert(e,t,n),null):0===s?i.copy(null,t,null,null,null):i.copy(null,null,null,null,i.right.insert(e,t,n)),i.fixUp_()}removeMin_(){if(this.left.isEmpty())return Ue.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,t){let n,i;if(n=this,t(e,n.key)<0)n.left.isEmpty()||n.left.isRed_()||n.left.left.isRed_()||(n=n.moveRedLeft_()),n=n.copy(null,null,null,n.left.remove(e,t),null);else{if(n.left.isRed_()&&(n=n.rotateRight_()),n.right.isEmpty()||n.right.isRed_()||n.right.left.isRed_()||(n=n.moveRedRight_()),0===t(e,n.key)){if(n.right.isEmpty())return Ue.EMPTY_NODE;i=n.right.min_(),n=n.copy(i.key,i.value,null,null,n.right.removeMin_())}n=n.copy(null,null,null,null,n.right.remove(e,t))}return n.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_(){const e=this.copy(null,null,We.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight_(){const e=this.copy(null,null,We.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip_(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth_(){const 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+")");
2if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");const e=this.left.check_();if(e!==this.right.check_())throw new Error("Black depths differ");return e+(this.isRed_()?0:1)}}We.RED=!0,We.BLACK=!1;class Ue{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ue.EMPTY_NODE;this.comparator_=e,this.root_=t}insert(e,t){return new Ue(this.comparator_,this.root_.insert(e,t,this.comparator_).copy(null,null,We.BLACK,null,null))}remove(e){return new Ue(this.comparator_,this.root_.remove(e,this.comparator_).copy(null,null,We.BLACK,null,null))}get(e){let t,n=this.root_;for(;!n.isEmpty();){if(t=this.comparator_(e,n.key),0===t)return n.value;t<0?n=n.left:t>0&&(n=n.right)}return null}getPredecessorKey(e){let t,n=this.root_,i=null;for(;!n.isEmpty();){if(t=this.comparator_(e,n.key),0===t){if(n.left.isEmpty())return i?i.key:null;for(n=n.left;!n.right.isEmpty();)n=n.right;return n.key}t<0?n=n.left:t>0&&(i=n,n=n.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(e){return this.root_.inorderTraversal(e)}reverseTraversal(e){return this.root_.reverseTraversal(e)}getIterator(e){return new Le(this.root_,null,this.comparator_,!1,e)}getIteratorFrom(e,t){return new Le(this.root_,e,this.comparator_,!1,t)}getReverseIteratorFrom(e,t){return new Le(this.root_,e,this.comparator_,!0,t)}getReverseIterator(e){return new Le(this.root_,null,this.comparator_,!0,e)}}function He(e,t){return x(e.name,t.name)}function Ye(e,t){return x(e,t)}let je;Ue.EMPTY_NODE=new class{copy(e,t,n,i,s){return this}insert(e,t,n){return new We(e,t,null)}remove(e,t){return this}count(){return 0}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}check_(){return 0}isRed_(){return!1}};const Ve=function(e){return"number"===typeof e?"number:"+q(e):"string:"+e},Be=function(e){if(e.isLeafNode()){const t=e.val();(0,r.hu)("string"===typeof t||"number"===typeof t||"object"===typeof t&&(0,r.r3)(t,".sv"),"Priority must be a string or number.")}else(0,r.hu)(e===je||e.isEmpty(),"priority of unexpected type.");(0,r.hu)(e===je||e.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")};let ze,Ke,Qe;class Ge{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ge.__childrenNodeConstructor.EMPTY_NODE;this.value_=e,this.priorityNode_=t,this.lazyHash_=null,(0,r.hu)(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),Be(this.priorityNode_)}static set __childrenNodeConstructor(e){ze=e}static get __childrenNodeConstructor(){return ze}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new Ge(this.value_,e)}getImmediateChild(e){return".priority"===e?this.priorityNode_:Ge.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return Ie(e)?this:".priority"===ge(e)?this.priorityNode_:Ge.__childrenNodeConstructor.EMPTY_NODE}hasChild(){return!1}getPredecessorChildName(e,t){return null}updateImmediateChild(e,t){return".priority"===e?this.updatePriority(t):t.isEmpty()&&".priority"!==e?this:Ge.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,t).updatePriority(this.priorityNode_)}updateChild(e,t){const n=ge(e);return null===n?t:t.isEmpty()&&".priority"!==n?this:((0,r.hu)(".priority"!==n||1===me(e),".priority must be the last token in a path"),this.updateImmediateChild(n,Ge.__childrenNodeConstructor.EMPTY_NODE.updateChild(ye(e),t)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(e,t){return!1}val(e){return e&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()}hash(){if(null===this.lazyHash_){let e="";this.priorityNode_.isEmpty()||(e+="priority:"+Ve(this.priorityNode_.val())+":");const t=typeof this.value_;e+=t+":",e+="number"===t?q(this.value_):this.value_,this.lazyHash_=m(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===Ge.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof Ge.__childrenNodeConstructor?-1:((0,r.hu)(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){const t=typeof e.value_,n=typeof this.value_,i=Ge.VALUE_TYPE_ORDER.indexOf(t),s=Ge.VALUE_TYPE_ORDER.indexOf(n);return(0,r.hu)(i>=0,"Unknown leaf type: "+t),(0,r.hu)(s>=0,"Unknown leaf type: "+n),i===s?"object"===n?0:this.value_<e.value_?-1:this.value_===e.value_?0:1:s-i}withIndex(){return this}isIndexed(){return!0}equals(e){if(e===this)return!0;
2if(e.isLeafNode()){const t=e;return this.value_===t.value_&&this.priorityNode_.equals(t.priorityNode_)}return!1}}Ge.VALUE_TYPE_ORDER=["object","boolean","number","string"];const $e=new class extends Fe{compare(e,t){const n=e.node.getPriority(),i=t.node.getPriority(),s=n.compareTo(i);return 0===s?x(e.name,t.name):s}isDefinedOn(e){return!e.getPriority().isEmpty()}indexedValueChanged(e,t){return!e.getPriority().equals(t.getPriority())}minPost(){return Me.MIN}maxPost(){return new Me(P,new Ge("[PRIORITY-POST]",Qe))}makePost(e,t){const n=Ke(e);return new Me(t,new Ge("[PRIORITY-POST]",n))}toString(){return".priority"}},Xe=Math.log(2);class Je{constructor(e){var t;this.count=(t=e+1,parseInt(Math.log(t)/Xe,10)),this.current_=this.count-1;const n=(i=this.count,parseInt(Array(i+1).join("1"),2));var i;this.bits_=e+1&n}nextBitIsOne(){const e=!(this.bits_&1<<this.current_);return this.current_--,e}}const Ze=function(e,t,n,i){e.sort(t);const s=function(t,i){const r=i-t;let o,a;if(0===r)return null;if(1===r)return o=e[t],a=n?n(o):o,new We(a,o.node,We.BLACK,null,null);{const l=parseInt(r/2,10)+t,h=s(t,l),c=s(l+1,i);return o=e[l],a=n?n(o):o,new We(a,o.node,We.BLACK,h,c)}},r=function(t){let i=null,r=null,o=e.length;const a=function(t,i){const r=o-t,a=o;o-=t;const h=s(r+1,a),c=e[r],u=n?n(c):c;l(new We(u,c.node,i,null,h))},l=function(e){i?(i.left=e,i=e):(r=e,i=e)};for(let e=0;e<t.count;++e){const n=t.nextBitIsOne(),i=Math.pow(2,t.count-(e+1));n?a(i,We.BLACK):(a(i,We.BLACK),a(i,We.RED))}return r}(new Je(e.length));return new Ue(i||t,r)};let et;const tt={};class nt{constructor(e,t){this.indexes_=e,this.indexSet_=t}static get Default(){return(0,r.hu)(tt&&$e,"ChildrenNode.ts has not been loaded"),et=et||new nt({".priority":tt},{".priority":$e}),et}get(e){const t=(0,r.DV)(this.indexes_,e);if(!t)throw new Error("No index defined for "+e);return t instanceof Ue?t:null}hasIndex(e){return(0,r.r3)(this.indexSet_,e.toString())}addIndex(e,t){(0,r.hu)(e!==Oe,"KeyIndex always exists and isn't meant to be added to the IndexMap.");const n=[];let i=!1;const s=t.getIterator(Me.Wrap);let o,a=s.getNext();for(;a;)i=i||e.isDefinedOn(a.node),n.push(a),a=s.getNext();o=i?Ze(n,e.getCompare()):tt;const l=e.toString(),h=Object.assign({},this.indexSet_);h[l]=e;const c=Object.assign({},this.indexes_);return c[l]=o,new nt(c,h)}addToIndexes(e,t){const n=(0,r.UI)(this.indexes_,((n,i)=>{const s=(0,r.DV)(this.indexSet_,i);if((0,r.hu)(s,"Missing index implementation for "+i),n===tt){if(s.isDefinedOn(e.node)){const n=[],i=t.getIterator(Me.Wrap);let r=i.getNext();for(;r;)r.name!==e.name&&n.push(r),r=i.getNext();return n.push(e),Ze(n,s.getCompare())}return tt}{const i=t.get(e.name);let s=n;return i&&(s=s.remove(new Me(e.name,i))),s.insert(e,e.node)}}));return new nt(n,this.indexSet_)}removeFromIndexes(e,t){const n=(0,r.UI)(this.indexes_,(n=>{if(n===tt)return n;{const i=t.get(e.name);return i?n.remove(new Me(e.name,i)):n}}));return new nt(n,this.indexSet_)}}let it;class st{constructor(e,t,n){this.children_=e,this.priorityNode_=t,this.indexMap_=n,this.lazyHash_=null,this.priorityNode_&&Be(this.priorityNode_),this.children_.isEmpty()&&(0,r.hu)(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}static get EMPTY_NODE(){return it||(it=new st(new Ue(Ye),null,nt.Default))}isLeafNode(){return!1}getPriority(){return this.priorityNode_||it}updatePriority(e){return this.children_.isEmpty()?this:new st(this.children_,e,this.indexMap_)}getImmediateChild(e){if(".priority"===e)return this.getPriority();{const t=this.children_.get(e);return null===t?it:t}}getChild(e){const t=ge(e);return null===t?this:this.getImmediateChild(t).getChild(ye(e))}hasChild(e){return null!==this.children_.get(e)}updateImmediateChild(e,t){if((0,r.hu)(t,"We should always be passing snapshot nodes"),".priority"===e)return this.updatePriority(t);{const n=new Me(e,t);let i,s;t.isEmpty()?(i=this.children_.remove(e),s=this.indexMap_.removeFromIndexes(n,this.children_)):(i=this.children_.insert(e,t),s=this.indexMap_.addToIndexes(n,this.children_));const r=i.isEmpty()?it:this.priorityNode_;return new st(i,r,s)}}updateChild(e,t){const n=ge(e);if(null===n)return t;{(0,r.hu)(".priority"!==ge(e)||1===me(e),".priority must be the last token in a path");const i=this.getImmediateChild(n).updateChild(ye(e),t);return this.updateImmediateChild(n,i)}}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(e){if(this.isEmpty())return null;const t={};let n=0,i=0,s=!0;if(this.forEachChild($e,((r,o)=>{t[r]=o.val(e),n++,s&&st.INTEGER_REGEXP_.test(r)?i=Math.max(i,Number(r)):s=!1})),!e&&s&&i<2*n){const e=[];for(const n in t)e[n]=t[n];return e}
2return e&&!this.getPriority().isEmpty()&&(t[".priority"]=this.getPriority().val()),t}hash(){if(null===this.lazyHash_){let e="";this.getPriority().isEmpty()||(e+="priority:"+Ve(this.getPriority().val())+":"),this.forEachChild($e,((t,n)=>{const i=n.hash();""!==i&&(e+=":"+t+":"+i)})),this.lazyHash_=""===e?"":m(e)}return this.lazyHash_}getPredecessorChildName(e,t,n){const i=this.resolveIndex_(n);if(i){const n=i.getPredecessorKey(new Me(e,t));return n?n.name:null}return this.children_.getPredecessorKey(e)}getFirstChildName(e){const t=this.resolveIndex_(e);if(t){const e=t.minKey();return e&&e.name}return this.children_.minKey()}getFirstChild(e){const t=this.getFirstChildName(e);return t?new Me(t,this.children_.get(t)):null}getLastChildName(e){const t=this.resolveIndex_(e);if(t){const e=t.maxKey();return e&&e.name}return this.children_.maxKey()}getLastChild(e){const t=this.getLastChildName(e);return t?new Me(t,this.children_.get(t)):null}forEachChild(e,t){const n=this.resolveIndex_(e);return n?n.inorderTraversal((e=>t(e.name,e.node))):this.children_.inorderTraversal(t)}getIterator(e){return this.getIteratorFrom(e.minPost(),e)}getIteratorFrom(e,t){const n=this.resolveIndex_(t);if(n)return n.getIteratorFrom(e,(e=>e));{const n=this.children_.getIteratorFrom(e.name,Me.Wrap);let i=n.peek();for(;null!=i&&t.compare(i,e)<0;)n.getNext(),i=n.peek();return n}}getReverseIterator(e){return this.getReverseIteratorFrom(e.maxPost(),e)}getReverseIteratorFrom(e,t){const n=this.resolveIndex_(t);if(n)return n.getReverseIteratorFrom(e,(e=>e));{const n=this.children_.getReverseIteratorFrom(e.name,Me.Wrap);let i=n.peek();for(;null!=i&&t.compare(i,e)>0;)n.getNext(),i=n.peek();return n}}compareTo(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===rt?-1:0}withIndex(e){if(e===Oe||this.indexMap_.hasIndex(e))return this;{const t=this.indexMap_.addIndex(e,this.children_);return new st(this.children_,this.priorityNode_,t)}}isIndexed(e){return e===Oe||this.indexMap_.hasIndex(e)}equals(e){if(e===this)return!0;if(e.isLeafNode())return!1;{const t=e;if(this.getPriority().equals(t.getPriority())){if(this.children_.count()===t.children_.count()){const e=this.getIterator($e),n=t.getIterator($e);let i=e.getNext(),s=n.getNext();for(;i&&s;){if(i.name!==s.name||!i.node.equals(s.node))return!1;i=e.getNext(),s=n.getNext()}return null===i&&null===s}return!1}return!1}}resolveIndex_(e){return e===Oe?null:this.indexMap_.get(e.toString())}}st.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;const rt=new class extends st{constructor(){super(new Ue(Ye),st.EMPTY_NODE,nt.Default)}compareTo(e){return e===this?0:1}equals(e){return e===this}getPriority(){return this}getImmediateChild(e){return st.EMPTY_NODE}isEmpty(){return!1}};Object.defineProperties(Me,{MIN:{value:new Me(N,st.EMPTY_NODE)},MAX:{value:new Me(P,rt)}}),qe.__EMPTY_NODE=st.EMPTY_NODE,Ge.__childrenNodeConstructor=st,je=rt,function(e){Qe=e}(rt);function ot(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null===e)return st.EMPTY_NODE;if("object"===typeof e&&".priority"in e&&(t=e[".priority"]),(0,r.hu)(null===t||"string"===typeof t||"number"===typeof t||"object"===typeof t&&".sv"in t,"Invalid priority type found: "+typeof t),"object"===typeof e&&".value"in e&&null!==e[".value"]&&(e=e[".value"]),"object"!==typeof e||".sv"in e){return new Ge(e,ot(t))}if(e instanceof Array){let n=st.EMPTY_NODE;return A(e,((t,i)=>{if((0,r.r3)(e,t)&&"."!==t.substring(0,1)){const e=ot(i);!e.isLeafNode()&&e.isEmpty()||(n=n.updateImmediateChild(t,e))}})),n.updatePriority(ot(t))}{const n=[];let i=!1;if(A(e,((e,t)=>{if("."!==e.substring(0,1)){const s=ot(t);s.isEmpty()||(i=i||!s.getPriority().isEmpty(),n.push(new Me(e,s)))}})),0===n.length)return st.EMPTY_NODE;const s=Ze(n,He,(e=>e.name),Ye);if(i){const e=Ze(n,$e.getCompare());return new st(s,ot(t),new nt({".priority":e},{".priority":$e}))}return new st(s,ot(t),nt.Default)}}!function(e){Ke=e}(ot);class at extends Fe{constructor(e){super(),this.indexPath_=e,(0,r.hu)(!Ie(e)&&".priority"!==ge(e),"Can't create PathIndex with empty path or .priority key")}extractChild(e){return e.getChild(this.indexPath_)}isDefinedOn(e){return!e.getChild(this.indexPath_).isEmpty()}compare(e,t){const n=this.extractChild(e.node),i=this.extractChild(t.node),s=n.compareTo(i);return 0===s?x(e.name,t.name):s}
2makePost(e,t){const n=ot(e),i=st.EMPTY_NODE.updateChild(this.indexPath_,n);return new Me(t,i)}maxPost(){const e=st.EMPTY_NODE.updateChild(this.indexPath_,rt);return new Me(P,e)}toString(){return Ce(this.indexPath_,0).join("/")}}const lt=new class extends Fe{compare(e,t){const n=e.node.compareTo(t.node);return 0===n?x(e.name,t.name):n}isDefinedOn(e){return!0}indexedValueChanged(e,t){return!e.equals(t)}minPost(){return Me.MIN}maxPost(){return Me.MAX}makePost(e,t){const n=ot(e);return new Me(t,n)}toString(){return".value"}},ht="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",ct=function(){let e=0;const t=[];return function(n){const i=n===e;let s;e=n;const o=new Array(8);for(s=7;s>=0;s--)o[s]=ht.charAt(n%64),n=Math.floor(n/64);(0,r.hu)(0===n,"Cannot push at time == 0");let a=o.join("");if(i){for(s=11;s>=0&&63===t[s];s--)t[s]=0;t[s]++}else for(s=0;s<12;s++)t[s]=Math.floor(64*Math.random());for(s=0;s<12;s++)a+=ht.charAt(t[s]);return(0,r.hu)(20===a.length,"nextPushId: Length should be 20."),a}}();function ut(e){return{type:"value",snapshotNode:e}}function dt(e,t){return{type:"child_added",snapshotNode:t,childName:e}}function _t(e,t){return{type:"child_removed",snapshotNode:t,childName:e}}function pt(e,t,n){return{type:"child_changed",snapshotNode:t,childName:e,oldSnap:n}}class ft{constructor(e){this.index_=e}updateChild(e,t,n,i,s,o){(0,r.hu)(e.isIndexed(this.index_),"A node must be indexed if only a child is updated");const a=e.getImmediateChild(t);return a.getChild(i).equals(n.getChild(i))&&a.isEmpty()===n.isEmpty()?e:(null!=o&&(n.isEmpty()?e.hasChild(t)?o.trackChildChange(_t(t,a)):(0,r.hu)(e.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):a.isEmpty()?o.trackChildChange(dt(t,n)):o.trackChildChange(pt(t,n,a))),e.isLeafNode()&&n.isEmpty()?e:e.updateImmediateChild(t,n).withIndex(this.index_))}updateFullNode(e,t,n){return null!=n&&(e.isLeafNode()||e.forEachChild($e,((e,i)=>{t.hasChild(e)||n.trackChildChange(_t(e,i))})),t.isLeafNode()||t.forEachChild($e,((t,i)=>{if(e.hasChild(t)){const s=e.getImmediateChild(t);s.equals(i)||n.trackChildChange(pt(t,i,s))}else n.trackChildChange(dt(t,i))}))),t.withIndex(this.index_)}updatePriority(e,t){return e.isEmpty()?st.EMPTY_NODE:e.updatePriority(t)}filtersNodes(){return!1}getIndexedFilter(){return this}getIndex(){return this.index_}}class gt{constructor(e){this.indexedFilter_=new ft(e.getIndex()),this.index_=e.getIndex(),this.startPost_=gt.getStartPost_(e),this.endPost_=gt.getEndPost_(e)}getStartPost(){return this.startPost_}getEndPost(){return this.endPost_}matches(e){return this.index_.compare(this.getStartPost(),e)<=0&&this.index_.compare(e,this.getEndPost())<=0}updateChild(e,t,n,i,s,r){return this.matches(new Me(t,n))||(n=st.EMPTY_NODE),this.indexedFilter_.updateChild(e,t,n,i,s,r)}updateFullNode(e,t,n){t.isLeafNode()&&(t=st.EMPTY_NODE);let i=t.withIndex(this.index_);i=i.updatePriority(st.EMPTY_NODE);const s=this;return t.forEachChild($e,((e,t)=>{s.matches(new Me(e,t))||(i=i.updateImmediateChild(e,st.EMPTY_NODE))})),this.indexedFilter_.updateFullNode(e,i,n)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.indexedFilter_}getIndex(){return this.index_}static getStartPost_(e){if(e.hasStart()){const t=e.getIndexStartName();return e.getIndex().makePost(e.getIndexStartValue(),t)}return e.getIndex().minPost()}static getEndPost_(e){if(e.hasEnd()){const t=e.getIndexEndName();return e.getIndex().makePost(e.getIndexEndValue(),t)}return e.getIndex().maxPost()}}class mt{constructor(e){this.rangedFilter_=new gt(e),this.index_=e.getIndex(),this.limit_=e.getLimit(),this.reverse_=!e.isViewFromLeft()}updateChild(e,t,n,i,s,r){return this.rangedFilter_.matches(new Me(t,n))||(n=st.EMPTY_NODE),e.getImmediateChild(t).equals(n)?e:e.numChildren()<this.limit_?this.rangedFilter_.getIndexedFilter().updateChild(e,t,n,i,s,r):this.fullLimitUpdateChild_(e,t,n,s,r)}updateFullNode(e,t,n){let i;if(t.isLeafNode()||t.isEmpty())i=st.EMPTY_NODE.withIndex(this.index_);else if(2*this.limit_<t.numChildren()&&t.isIndexed(this.index_)){let e;i=st.EMPTY_NODE.withIndex(this.index_),e=this.reverse_?t.getReverseIteratorFrom(this.rangedFilter_.getEndPost(),this.index_):t.getIteratorFrom(this.rangedFilter_.getStartPost(),this.index_);let n=0;for(;e.hasNext()&&n<this.limit_;){const t=e.getNext();let s;if(s=this.reverse_?this.index_.compare(this.rangedFilter_.getStartPost(),t)<=0:this.index_.compare(t,this.rangedFilter_.getEndPost())<=0,!s)break;i=i.updateImmediateChild(t.name,t.node),n++}}else{let e,n,s,r;if(i=t.withIndex(this.index_),i=i.updatePriority(st.EMPTY_NODE),this.reverse_){r=i.getReverseIterator(this.index_),e=this.rangedFilter_.getEndPost(),n=this.rangedFilter_.getStartPost();const t=this.index_.getCompare();s=(e,n)=>t(n,e)}else r=i.getIterator(this.index_),e=this.rangedFilter_.getStartPost(),n=this.rangedFilter_.getEndPost(),s=this.index_.getCompare();let o=0,a=!1;for(;r.hasNext();){const t=r.getNext();!a&&s(e,t)<=0&&(a=!0);
2a&&o<this.limit_&&s(t,n)<=0?o++:i=i.updateImmediateChild(t.name,st.EMPTY_NODE)}}return this.rangedFilter_.getIndexedFilter().updateFullNode(e,i,n)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.rangedFilter_.getIndexedFilter()}getIndex(){return this.index_}fullLimitUpdateChild_(e,t,n,i,s){let o;if(this.reverse_){const e=this.index_.getCompare();o=(t,n)=>e(n,t)}else o=this.index_.getCompare();const a=e;(0,r.hu)(a.numChildren()===this.limit_,"");const l=new Me(t,n),h=this.reverse_?a.getFirstChild(this.index_):a.getLastChild(this.index_),c=this.rangedFilter_.matches(l);if(a.hasChild(t)){const e=a.getImmediateChild(t);let r=i.getChildAfterChild(this.index_,h,this.reverse_);for(;null!=r&&(r.name===t||a.hasChild(r.name));)r=i.getChildAfterChild(this.index_,r,this.reverse_);const u=null==r?1:o(r,l);if(c&&!n.isEmpty()&&u>=0)return null!=s&&s.trackChildChange(pt(t,n,e)),a.updateImmediateChild(t,n);{null!=s&&s.trackChildChange(_t(t,e));const n=a.updateImmediateChild(t,st.EMPTY_NODE);return null!=r&&this.rangedFilter_.matches(r)?(null!=s&&s.trackChildChange(dt(r.name,r.node)),n.updateImmediateChild(r.name,r.node)):n}}return n.isEmpty()?e:c&&o(h,l)>=0?(null!=s&&(s.trackChildChange(_t(h.name,h.node)),s.trackChildChange(dt(t,n))),a.updateImmediateChild(t,n).updateImmediateChild(h.name,st.EMPTY_NODE)):e}}class yt{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_=$e}hasStart(){return this.startSet_}hasStartAfter(){return this.startAfterSet_}hasEndBefore(){return this.endBeforeSet_}isViewFromLeft(){return""===this.viewFrom_?this.startSet_:"l"===this.viewFrom_}getIndexStartValue(){return(0,r.hu)(this.startSet_,"Only valid if start has been set"),this.indexStartValue_}getIndexStartName(){return(0,r.hu)(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:N}hasEnd(){return this.endSet_}getIndexEndValue(){return(0,r.hu)(this.endSet_,"Only valid if end has been set"),this.indexEndValue_}getIndexEndName(){return(0,r.hu)(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:P}hasLimit(){return this.limitSet_}hasAnchoredLimit(){return this.limitSet_&&""!==this.viewFrom_}getLimit(){return(0,r.hu)(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_===$e}copy(){const e=new yt;return e.limitSet_=this.limitSet_,e.limit_=this.limit_,e.startSet_=this.startSet_,e.indexStartValue_=this.indexStartValue_,e.startNameSet_=this.startNameSet_,e.indexStartName_=this.indexStartName_,e.endSet_=this.endSet_,e.indexEndValue_=this.indexEndValue_,e.endNameSet_=this.endNameSet_,e.indexEndName_=this.indexEndName_,e.index_=this.index_,e.viewFrom_=this.viewFrom_,e}}function vt(e,t){const n=e.copy();return n.index_=t,n}function Ct(e){const t={};if(e.isDefault())return t;let n;return e.index_===$e?n="$priority":e.index_===lt?n="$value":e.index_===Oe?n="$key":((0,r.hu)(e.index_ instanceof at,"Unrecognized index type!"),n=e.index_.toString()),t.orderBy=(0,r.Wl)(n),e.startSet_&&(t.startAt=(0,r.Wl)(e.indexStartValue_),e.startNameSet_&&(t.startAt+=","+(0,r.Wl)(e.indexStartName_))),e.endSet_&&(t.endAt=(0,r.Wl)(e.indexEndValue_),e.endNameSet_&&(t.endAt+=","+(0,r.Wl)(e.indexEndName_))),e.limitSet_&&(e.isViewFromLeft()?t.limitToFirst=e.limit_:t.limitToLast=e.limit_),t}function wt(e){const t={};if(e.startSet_&&(t.sp=e.indexStartValue_,e.startNameSet_&&(t.sn=e.indexStartName_)),e.endSet_&&(t.ep=e.indexEndValue_,e.endNameSet_&&(t.en=e.indexEndName_)),e.limitSet_){t.l=e.limit_;let n=e.viewFrom_;""===n&&(n=e.isViewFromLeft()?"l":"r"),t.vf=n}return e.index_!==$e&&(t.i=e.index_.toString()),t}class Tt extends ue{constructor(e,t,n,i){super(),this.repoInfo_=e,this.onDataUpdate_=t,this.authTokenProvider_=n,this.appCheckTokenProvider_=i,this.log_=I("p:rest:"),this.listens_={}}reportStats(e){throw new Error("Method not implemented.")}static getListenId_(e,t){return void 0!==t?"tag$"+t:((0,r.hu)(e._queryParams.isDefault(),"should have a tag if it's not a default query."),e._path.toString())}listen(e,t,n,i){const s=e._path.toString();this.log_("Listen called for "+s+" "+e._queryIdentifier);const o=Tt.getListenId_(e,n),a={};this.listens_[o]=a;const l=Ct(e._queryParams);this.restRequest_(s+".json",l,((e,t)=>
2{let l=t;if(404===e&&(l=null,e=null),null===e&&this.onDataUpdate_(s,l,!1,n),(0,r.DV)(this.listens_,o)===a){let t;t=e?401===e?"permission_denied":"rest_error:"+e:"ok",i(t,null)}}))}unlisten(e,t){const n=Tt.getListenId_(e,t);delete this.listens_[n]}get(e){const t=Ct(e._queryParams),n=e._path.toString(),i=new r.BH;return this.restRequest_(n+".json",t,((e,t)=>{let s=t;404===e&&(s=null,e=null),null===e?(this.onDataUpdate_(n,s,!1,null),i.resolve(s)):i.reject(new Error(s))})),i.promise}refreshAuthToken(e){}restRequest_(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;return t.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then((i=>{let[s,o]=i;s&&s.accessToken&&(t.auth=s.accessToken),o&&o.token&&(t.ac=o.token);const a=(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host+e+"?ns="+this.repoInfo_.namespace+(0,r.xO)(t);this.log_("Sending REST request for "+a);const l=new XMLHttpRequest;l.onreadystatechange=()=>{if(n&&4===l.readyState){this.log_("REST Response for "+a+" received. status:",l.status,"response:",l.responseText);let t=null;if(l.status>=200&&l.status<300){try{t=(0,r.cI)(l.responseText)}catch(e){E("Failed to parse JSON response for "+a+": "+l.responseText)}n(null,t)}else 401!==l.status&&404!==l.status&&E("Got unsuccessful REST response for "+a+" Status: "+l.status),n(l.status);n=null}},l.open("GET",a,!0),l.send()}))}}class It{constructor(){this.rootNode_=st.EMPTY_NODE}getNode(e){return this.rootNode_.getChild(e)}updateSnapshot(e,t){this.rootNode_=this.rootNode_.updateChild(e,t)}}function bt(){return{value:null,children:new Map}}function kt(e,t,n){if(Ie(t))e.value=n,e.children.clear();else if(null!==e.value)e.value=e.value.updateChild(t,n);else{const i=ge(t);e.children.has(i)||e.children.set(i,bt());kt(e.children.get(i),t=ye(t),n)}}function Et(e,t,n){null!==e.value?n(t,e.value):function(e,t){e.children.forEach(((e,n)=>{t(n,e)}))}(e,((e,i)=>{Et(i,new pe(t.toString()+"/"+e),n)}))}class St{constructor(e){this.collection_=e,this.last_=null}get(){const e=this.collection_.get(),t=Object.assign({},e);return this.last_&&A(this.last_,((e,n)=>{t[e]=t[e]-n})),this.last_=e,t}}class Nt{constructor(e,t){this.server_=t,this.statsToReport_={},this.statsListener_=new St(e);const n=1e4+2e4*Math.random();Y(this.reportStats_.bind(this),Math.floor(n))}reportStats_(){const e=this.statsListener_.get(),t={};let n=!1;A(e,((e,i)=>{i>0&&(0,r.r3)(this.statsToReport_,e)&&(t[e]=i,n=!0)})),n&&this.server_.reportStats(t),Y(this.reportStats_.bind(this),Math.floor(2*Math.random()*3e5))}}var Pt;function xt(e){return{fromUser:!1,fromServer:!0,queryId:e,tagged:!0}}!function(e){e[e.OVERWRITE=0]="OVERWRITE",e[e.MERGE=1]="MERGE",e[e.ACK_USER_WRITE=2]="ACK_USER_WRITE",e[e.LISTEN_COMPLETE=3]="LISTEN_COMPLETE"}(Pt||(Pt={}));class Rt{constructor(e,t,n){this.path=e,this.affectedTree=t,this.revert=n,this.type=Pt.ACK_USER_WRITE,this.source={fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}operationForChild(e){if(Ie(this.path)){if(null!=this.affectedTree.value)return(0,r.hu)(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;{const t=this.affectedTree.subtree(new pe(e));return new Rt(fe(),t,this.revert)}}return(0,r.hu)(ge(this.path)===e,"operationForChild called for unrelated child."),new Rt(ye(this.path),this.affectedTree,this.revert)}}class Dt{constructor(e,t){this.source=e,this.path=t,this.type=Pt.LISTEN_COMPLETE}operationForChild(e){return Ie(this.path)?new Dt(this.source,fe()):new Dt(this.source,ye(this.path))}}class Mt{constructor(e,t,n){this.source=e,this.path=t,this.snap=n,this.type=Pt.OVERWRITE}operationForChild(e){return Ie(this.path)?new Mt(this.source,fe(),this.snap.getImmediateChild(e)):new Mt(this.source,ye(this.path),this.snap)}}class Ft{constructor(e,t,n){this.source=e,this.path=t,this.children=n,this.type=Pt.MERGE}operationForChild(e){if(Ie(this.path)){const t=this.children.subtree(new pe(e));return t.isEmpty()?null:t.value?new Mt(this.source,fe(),t.value):new Ft(this.source,fe(),t)}return(0,r.hu)(ge(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new Ft(this.source,ye(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}class At{constructor(e,t,n){this.node_=e,this.fullyInitialized_=t,this.filtered_=n}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(e){if(Ie(e))return this.isFullyInitialized()&&!this.filtered_;const t=ge(e);return this.isCompleteForChild(t)}isCompleteForChild(e){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(e)}getNode(){return this.node_}}class qt{constructor(e){this.query_=e,this.index_=this.query_._queryParams.getIndex()}}function Ot(e,t,n,i,s,o){const a=i.filter((e=>e.type===n));a.sort(((t,n)=>function(e,t,n){if(null==t.childName||null==n.childName)throw(0,r.g5)("Should only compare child_ events.");const i=new Me(t.childName,t.snapshotNode),s=new Me(n.childName,n.snapshotNode);return e.index_.compare(i,s)}
vendor: 4,352 bytes, line 2
2(e,t,n))),a.forEach((n=>{const i=function(e,t,n){return"value"===t.type||"child_removed"===t.type||(t.prevName=n.getPredecessorChildName(t.childName,t.snapshotNode,e.index_)),t}(e,n,o);s.forEach((s=>{s.respondsTo(n.type)&&t.push(s.createEvent(i,e.query_))}))}))}function Lt(e,t){return{eventCache:e,serverCache:t}}function Wt(e,t,n,i){return Lt(new At(t,n,i),e.serverCache)}function Ut(e,t,n,i){return Lt(e.eventCache,new At(t,n,i))}function Ht(e){return e.eventCache.isFullyInitialized()?e.eventCache.getNode():null}function Yt(e){return e.serverCache.isFullyInitialized()?e.serverCache.getNode():null}let jt;class Vt{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(jt||(jt=new Ue(R)),jt);this.value=e,this.children=t}static fromObject(e){let t=new Vt(null);return A(e,((e,n)=>{t=t.set(new pe(e),n)})),t}isEmpty(){return null===this.value&&this.children.isEmpty()}findRootMostMatchingPathAndValue(e,t){if(null!=this.value&&t(this.value))return{path:fe(),value:this.value};if(Ie(e))return null;{const n=ge(e),i=this.children.get(n);if(null!==i){const s=i.findRootMostMatchingPathAndValue(ye(e),t);if(null!=s){return{path:Te(new pe(n),s.path),value:s.value}}return null}return null}}findRootMostValueAndPath(e){return this.findRootMostMatchingPathAndValue(e,(()=>!0))}subtree(e){if(Ie(e))return this;{const t=ge(e),n=this.children.get(t);return null!==n?n.subtree(ye(e)):new Vt(null)}}set(e,t){if(Ie(e))return new Vt(t,this.children);{const n=ge(e),i=(this.children.get(n)||new Vt(null)).set(ye(e),t),s=this.children.insert(n,i);return new Vt(this.value,s)}}remove(e){if(Ie(e))return this.children.isEmpty()?new Vt(null):new Vt(null,this.children);{const t=ge(e),n=this.children.get(t);if(n){const i=n.remove(ye(e));let s;return s=i.isEmpty()?this.children.remove(t):this.children.insert(t,i),null===this.value&&s.isEmpty()?new Vt(null):new Vt(this.value,s)}return this}}get(e){if(Ie(e))return this.value;{const t=ge(e),n=this.children.get(t);return n?n.get(ye(e)):null}}setTree(e,t){if(Ie(e))return t;{const n=ge(e),i=(this.children.get(n)||new Vt(null)).setTree(ye(e),t);let s;return s=i.isEmpty()?this.children.remove(n):this.children.insert(n,i),new Vt(this.value,s)}}fold(e){return this.fold_(fe(),e)}fold_(e,t){const n={};return this.children.inorderTraversal(((i,s)=>{n[i]=s.fold_(Te(e,i),t)})),t(e,this.value,n)}findOnPath(e,t){return this.findOnPath_(e,fe(),t)}findOnPath_(e,t,n){const i=!!this.value&&n(t,this.value);if(i)return i;if(Ie(e))return null;{const i=ge(e),s=this.children.get(i);return s?s.findOnPath_(ye(e),Te(t,i),n):null}}foreachOnPath(e,t){return this.foreachOnPath_(e,fe(),t)}foreachOnPath_(e,t,n){if(Ie(e))return this;{this.value&&n(t,this.value);const i=ge(e),s=this.children.get(i);return s?s.foreachOnPath_(ye(e),Te(t,i),n):new Vt(null)}}foreach(e){this.foreach_(fe(),e)}foreach_(e,t){this.children.inorderTraversal(((n,i)=>{i.foreach_(Te(e,n),t)})),this.value&&t(e,this.value)}foreachChild(e){this.children.inorderTraversal(((t,n)=>{n.value&&e(t,n.value)}))}}class Bt{constructor(e){this.writeTree_=e}static empty(){return new Bt(new Vt(null))}}function zt(e,t,n){if(Ie(t))return new Bt(new Vt(n));{const i=e.writeTree_.findRootMostValueAndPath(t);if(null!=i){const s=i.path;let r=i.value;const o=be(s,t);return r=r.updateChild(o,n),new Bt(e.writeTree_.set(s,r))}{const i=new Vt(n),s=e.writeTree_.setTree(t,i);return new Bt(s)}}}function Kt(e,t,n){let i=e;return A(n,((e,n)=>{i=zt(i,Te(t,e),n)})),i}function Qt(e,t){if(Ie(t))return Bt.empty();{const n=e.writeTree_.setTree(t,new Vt(null));return new Bt(n)}}function Gt(e,t){return null!=$t(e,t)}function $t(e,t){const n=e.writeTree_.findRootMostValueAndPath(t);return null!=n?e.writeTree_.get(n.path).getChild(be(n.path,t)):null}function Xt(e){const t=[],n=e.writeTree_.value;return null!=n?n.isLeafNode()||n.forEachChild($e,((e,n)=>{t.push(new Me(e,n))})):e.writeTree_.children.inorderTraversal(((e,n)=>{null!=n.value&&t.push(new Me(e,n.value))})),t}function Jt(e,t){if(Ie(t))return e;{const n=$t(e,t);return new Bt(null!=n?new Vt(n):e.writeTree_.subtree(t))}}function Zt(e){return e.writeTree_.isEmpty()}function en(e,t){return tn(fe(),e.writeTree_,t)}function tn(e,t,n){if(null!=t.value)return n.updateChild(e,t.value);{let i=null;return t.children.inorderTraversal(((t,s)=>{".priority"===t?((0,r.hu)(null!==s.value,"Priority writes must al
2ways be leaf nodes"),i=s.value):n=tn(Te(e,t),s,n)})),n.getChild(e).isEmpty()||null===i||(n=n.updateChild(Te(e,".priority"),i)),n}}function nn(e,t){return mn(t,e)}function sn(e,t){for(let n=0;n<e.allWrites.length;n++){const i=e.allWrites[n];if(i.writeId===t)return i}return null}function rn(e,t){const n=e.allWrites.findIndex((e=>e.writeId===t));(0,r.hu)(n>=0,"removeWrite called with nonexistent writeId.");const i=e.allWrites[n];e.allWrites.splice(n,1);let s=i.visible,o=!1,a=e.allWrites.length-1;for(;s&&a>=0;){const t=e.allWrites[a];t.visible&&(a>=n&&on(t,i.path)?s=!1:Ee(i.path,t.path)&&(o=!0)),a--}if(s){if(o)return function(e){e.visibleWrites=ln(e.allWrites,an,fe()),e.allWrites.length>0?e.lastWriteId=e.allWrites[e.allWrites.length-1].writeId:e.lastWriteId=-1}(e),!0;if(i.snap)e.visibleWrites=Qt(e.visibleWrites,i.path);else{A(i.children,(t=>{e.visibleWrites=Qt(e.visibleWrites,Te(i.path,t))}))}return!0}return!1}function on(e,t){if(e.snap)return Ee(e.path,t);for(const n in e.children)if(e.children.hasOwnProperty(n)&&Ee(Te(e.path,n),t))return!0;return!1}function an(e){return e.visible}
2function ln(e,t,n){let i=Bt.empty();for(let s=0;s<e.length;++s){const o=e[s];if(t(o)){const e=o.path;let t;if(o.snap)Ee(n,e)?(t=be(n,e),i=zt(i,t,o.snap)):Ee(e,n)&&(t=be(e,n),i=zt(i,fe(),o.snap.getChild(t)));else{if(!o.children)throw(0,r.g5)("WriteRecord should have .snap or .children");if(Ee(n,e))t=be(n,e),i=Kt(i,t,o.children);else if(Ee(e,n))if(t=be(e,n),Ie(t))i=Kt(i,fe(),o.children);else{const e=(0,r.DV)(o.children,ge(t));if(e){const n=e.getChild(ye(t));i=zt(i,fe(),n)}}}}}return i}function hn(e,t,n,i,s){if(i||s){const r=Jt(e.visibleWrites,t);if(!s&&Zt(r))return n;if(s||null!=n||Gt(r,fe())){const r=function(e){return(e.visible||s)&&(!i||!~i.indexOf(e.writeId))&&(Ee(e.path,t)||Ee(t,e.path))};return en(ln(e.allWrites,r,t),n||st.EMPTY_NODE)}return null}{const i=$t(e.visibleWrites,t);if(null!=i)return i;{const i=Jt(e.visibleWrites,t);if(Zt(i))return n;if(null!=n||Gt(i,fe())){return en(i,n||st.EMPTY_NODE)}return null}}}function cn(e,t,n,i){return hn(e.writeTree,e.treePath,t,n,i)}function un(e,t){return function(e,t,n){let i=st.EMPTY_NODE;const s=$t(e.visibleWrites,t);if(s)return s.isLeafNode()||s.forEachChild($e,((e,t)=>{i=i.updateImmediateChild(e,t)})),i;if(n){const s=Jt(e.visibleWrites,t);return n.forEachChild($e,((e,t)=>{const n=en(Jt(s,new pe(e)),t);i=i.updateImmediateChild(e,n)})),Xt(s).forEach((e=>{i=i.updateImmediateChild(e.name,e.node)})),i}
2return Xt(Jt(e.visibleWrites,t)).forEach((e=>{i=i.updateImmediateChild(e.name,e.node)})),i}(e.writeTree,e.treePath,t)}function dn(e,t,n,i){return function(e,t,n,i,s){(0,r.hu)(i||s,"Either existingEventSnap or existingServerSnap must exist");const o=Te(t,n);if(Gt(e.visibleWrites,o))return null;{const t=Jt(e.visibleWrites,o);return Zt(t)?s.getChild(n):en(t,s.getChild(n))}}(e.writeTree,e.treePath,t,n,i)}function _n(e,t){return function(e,t){return $t(e.visibleWrites,t)}(e.writeTree,Te(e.treePath,t))}function pn(e,t,n,i,s,r){return function(e,t,n,i,s,r,o){let a;const l=Jt(e.visibleWrites,t),h=$t(l,fe());if(null!=h)a=h;else{if(null==n)return[];a=en(l,n)}if(a=a.withIndex(o),a.isEmpty()||a.isLeafNode())return[];{const e=[],t=o.getCompare(),n=r?a.getReverseIteratorFrom(i,o):a.getIteratorFrom(i,o);let l=n.getNext();for(;l&&e.length<s;)0!==t(l,i)&&e.push(l),l=n.getNext();return e}}(e.writeTree,e.treePath,t,n,i,s,r)}function fn(e,t,n){return function(e,t,n,i){const s=Te(t,n),r=$t(e.visibleWrites,s);if(null!=r)return r;if(i.isCompleteForChild(n))return en(Jt(e.visibleWrites,s),i.getNode().getImmediateChild(n));return null}(e.writeTree,e.treePath,t,n)}function gn(e,t){return mn(Te(e.treePath,t),e.writeTree)}function mn(e,t){return{treePath:e,writeTree:t}}class yn{constructor(){this.changeMap=new Map}trackChildChange(e){const t=e.type,n=e.childName;(0,r.hu)("child_added"===t||"child_changed"===t||"child_removed"===t,"Only child changes supported for tracking"),(0,r.hu)(".priority"!==n,"Only non-priority child changes can be tracked.");const i=this.changeMap.get(n);if(i){const s=i.type;if("child_added"===t&&"child_removed"===s)this.changeMap.set(n,pt(n,e.snapshotNode,i.snapshotNode));else if("child_removed"===t&&"child_added"===s)this.changeMap.delete(n);else if("child_removed"===t&&"child_changed"===s)this.changeMap.set(n,_t(n,i.oldSnap));else if("child_changed"===t&&"child_added"===s)this.changeMap.set(n,dt(n,e.snapshotNode));else{if("child_changed"!==t||"child_changed"!==s)throw(0,r.g5)("Illegal combination of changes: "+e+" occurred after "+i);this.changeMap.set(n,pt(n,e.snapshotNode,i.oldSnap))}}else this.changeMap.set(n,e)}getChanges(){return Array.from(this.changeMap.values())}}const vn=new class{getCompleteChild(e){return null}getChildAfterChild(e,t,n){return null}};class Cn{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.writes_=e,this.viewCache_=t,this.optCompleteServerCache_=n}getCompleteChild(e){const t=this.viewCache_.eventCache;if(t.isCompleteForChild(e))return t.getNode().getImmediateChild(e);{const t=null!=this.optCompleteServerCache_?new At(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return fn(this.writes_,e,t)}}getChildAfterChild(e,t,n){const i=null!=this.optCompleteServerCache_?this.optCompleteServerCache_:Yt(this.viewCache_),s=pn(this.writes_,i,t,1,n,e);return 0===s.length?null:s[0]}}function wn(e,t,n,i,s){const o=new yn;let a,l;if(n.type===Pt.OVERWRITE){const h=n;h.source.fromUser?a=bn(e,t,h.path,h.snap,i,s,o):((0,r.hu)(h.source.fromServer,"Unknown source."),l=h.source.tagged||t.serverCache.isFiltered()&&!Ie(h.path),a=In(e,t,h.path,h.snap,i,s,l,o))}else if(n.type===Pt.MERGE){const h=n;h.source.fromUser?a=function(e,t,n,i,s,r,o){let a=t;return i.foreach(((i,l)=>{const h=Te(n,i);kn(t,ge(h))&&(a=bn(e,a,h,l,s,r,o))})),i.foreach(((i,l)=>{const h=Te(n,i);kn(t,ge(h))||(a=bn(e,a,h,l,s,r,o))})),a}(e,t,h.path,h.children,i,s,o):((0,r.hu)(h.source.fromServer,"Unknown source."),l=h.source.tagged||t.serverCache.isFiltered(),a=Sn(e,t,h.path,h.children,i,s,l,o))}else if(n.type===Pt.ACK_USER_WRITE){const l=n;a=l.revert?function(e,t,n,i,s,o){let a;if(null!=_n(i,n))return t;{const l=new Cn(i,t,s),h=t.eventCache.getNode();let c;if(Ie(n)||".priority"===ge(n)){let n;if(t.serverCache.isFullyInitialized())n=cn(i,Yt(t));else{const e=t.serverCache.getNode();(0,r.hu)(e instanceof st,"serverChildren would be complete if leaf node"),n=un(i,e)}c=e.filter.updateFullNode(h,n,o)}else{const s=ge(n);let r=fn(i,s,t.serverCache);null==r&&t.serverCache.isCompleteForChild(s)&&(r=h.getImmediateChild(s)),c=null!=r?e.filter.updateChild(h,s,r,ye(n),l,o):t.eventCache.getNode().hasChild(s)?e.filter.updateChild(h,s,st.EMPTY_NODE,ye(n),l,o):h,c.isEmpty()&&t.serverCache.isFullyInitialized()&&(a=cn(i,Yt(t)),a.isLeafNode()&&(c=e.filter.updateFullNode(c,a,o)))}return a=t.serverCache.isFullyInitialized()||null!=_n(i,fe()),Wt(t,c,a,e.filter.filtersNodes())}}(e,t,l.path,i,s,o):function(e,t,n,i,s,r,o){if(null!=_n(s,n))return t;const a=t.serverCache.isFiltered(),l=t.serverCache;if(null!=i.value){if(Ie(n)&&l.isFullyInitialized()||l.isCompleteForPath(n))return In(e,t,n,l.getNode().getChild(n),s,r,a,o);if(Ie(n)){let i=new Vt(null);
vendor: 5,208 bytes, line 2
2return l.getNode().forEachChild(Oe,((e,t)=>{i=i.set(new pe(e),t)})),Sn(e,t,n,i,s,r,a,o)}return t}{let h=new Vt(null);return i.foreach(((e,t)=>{const i=Te(n,e);l.isCompleteForPath(i)&&(h=h.set(e,l.getNode().getChild(i)))})),Sn(e,t,n,h,s,r,a,o)}}(e,t,l.path,l.affectedTree,i,s,o)}else{if(n.type!==Pt.LISTEN_COMPLETE)throw(0,r.g5)("Unknown operation type: "+n.type);a=function(e,t,n,i,s){const r=t.serverCache,o=Ut(t,r.getNode(),r.isFullyInitialized()||Ie(n),r.isFiltered());return Tn(e,o,n,i,vn,s)}(e,t,n.path,i,o)}const h=o.getChanges();return function(e,t,n){const i=t.eventCache;if(i.isFullyInitialized()){const s=i.getNode().isLeafNode()||i.getNode().isEmpty(),r=Ht(e);(n.length>0||!e.eventCache.isFullyInitialized()||s&&!i.getNode().equals(r)||!i.getNode().getPriority().equals(r.getPriority()))&&n.push(ut(Ht(t)))}}(t,a,h),{viewCache:a,changes:h}}function Tn(e,t,n,i,s,o){const a=t.eventCache;if(null!=_n(i,n))return t;{let l,h;if(Ie(n))if((0,r.hu)(t.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),t.serverCache.isFiltered()){const n=Yt(t),s=un(i,n instanceof st?n:st.EMPTY_NODE);l=e.filter.updateFullNode(t.eventCache.getNode(),s,o)}else{const n=cn(i,Yt(t));l=e.filter.updateFullNode(t.eventCache.getNode(),n,o)}else{const c=ge(n);if(".priority"===c){(0,r.hu)(1===me(n),"Can't have a priority with additional path components");const s=a.getNode();h=t.serverCache.getNode();const o=dn(i,n,s,h);l=null!=o?e.filter.updatePriority(s,o):a.getNode()}else{const r=ye(n);let u;if(a.isCompleteForChild(c)){h=t.serverCache.getNode();const e=dn(i,n,a.getNode(),h);u=null!=e?a.getNode().getImmediateChild(c).updateChild(r,e):a.getNode().getImmediateChild(c)}else u=fn(i,c,t.serverCache);l=null!=u?e.filter.updateChild(a.getNode(),c,u,r,s,o):a.getNode()}}return Wt(t,l,a.isFullyInitialized()||Ie(n),e.filter.filtersNodes())}}function In(e,t,n,i,s,r,o,a){const l=t.serverCache;let h;const c=o?e.filter:e.filter.getIndexedFilter();if(Ie(n))h=c.updateFullNode(l.getNode(),i,null);else if(c.filtersNodes()&&!l.isFiltered()){const e=l.getNode().updateChild(n,i);h=c.updateFullNode(l.getNode(),e,null)}else{const e=ge(n);if(!l.isCompleteForPath(n)&&me(n)>1)return t;const s=ye(n),r=l.getNode().getImmediateChild(e).updateChild(s,i);h=".priority"===e?c.updatePriority(l.getNode(),r):c.updateChild(l.getNode(),e,r,s,vn,null)}const u=Ut(t,h,l.isFullyInitialized()||Ie(n),c.filtersNodes());return Tn(e,u,n,s,new Cn(s,u,r),a)}function bn(e,t,n,i,s,r,o){const a=t.eventCache;let l,h;const c=new Cn(s,t,r);if(Ie(n))h=e.filter.updateFullNode(t.eventCache.getNode(),i,o),l=Wt(t,h,!0,e.filter.filtersNodes());else{const s=ge(n);if(".priority"===s)h=e.filter.updatePriority(t.eventCache.getNode(),i),l=Wt(t,h,a.isFullyInitialized(),a.isFiltered());else{const r=ye(n),h=a.getNode().getImmediateChild(s);let u;if(Ie(r))u=i;else{const e=c.getCompleteChild(s);u=null!=e?".priority"===ve(r)&&e.getChild(we(r)).isEmpty()?e:e.updateChild(r,i):st.EMPTY_NODE}if(h.equals(u))l=t;else{l=Wt(t,e.filter.updateChild(a.getNode(),s,u,r,c,o),a.isFullyInitialized(),e.filter.filtersNodes())}}}return l}function kn(e,t){return e.eventCache.isCompleteForChild(t)}function En(e,t,n){return n.foreach(((e,n)=>{t=t.updateChild(e,n)})),t}function Sn(e,t,n,i,s,r,o,a){if(t.serverCache.getNode().isEmpty()&&!t.serverCache.isFullyInitialized())return t;let l,h=t;l=Ie(n)?i:new Vt(null).setTree(n,i);const c=t.serverCache.getNode();return l.children.inorderTraversal(((n,i)=>{if(c.hasChild(n)){const l=En(0,t.serverCache.getNode().getImmediateChild(n),i);h=In(e,h,new pe(n),l,s,r,o,a)}})),l.children.inorderTraversal(((n,i)=>{const l=!t.serverCache.isCompleteForChild(n)&&null===i.value;if(!c.hasChild(n)&&!l){const l=En(0,t.serverCache.getNode().getImmediateChild(n),i);h=In(e,h,new pe(n),l,s,r,o,a)}})),h}class Nn{constructor(e,t){this.query_=e,this.eventRegistrations_=[];const n=this.query_._queryParams,i=new ft(n.getIndex()),s=(r=n).loadsAllData()?new ft(r.getIndex()):r.hasLimit()?new mt(r):new gt(r);var r;this.processor_=function(e){return{filter:e}}(s);const o=t.serverCache,a=t.eventCache,l=i.updateFullNode(st.EMPTY_NODE,o.getNode(),null),h=s.updateFullNode(st.EMPTY_NODE,a.getNode(),null),c=new At(l,o.isFullyInitialized(),i.filtersNodes()),u=new At(h,a.isFullyInitialized(),s.filtersNodes());this.viewCache_=Lt(u,c),this.eventGenerator_=new qt(this.query_)}get query(){return this.query_}}function Pn(e,t){const n=Yt(e.viewCache_);return n&&(e.query._queryParams.loadsAllData()||!Ie(t)&&!n.getImmediateChild(ge(t)).isEmpty())?n.getChild(t):null}function xn(e){return 0===e.eventRegistrations_.length}function Rn(e,t,n){const i=[];if(n){(0,r.hu)(null==t,"A cancel should cancel all event registrations.");const s=e.query._path;e.eventRegistrations_.forEach((e=>{const t=e.createCancelEvent(n,s);t&&i.push(t)}))}if(t){let n=[];for(let i=0;i<e.eventRegistrations_.length;++i){const s=e.eventRegistrations_[i];if(s.matches(t)){if(t.hasAnyCallback()){n=n.concat(e.eventRegistrations_.slice(i+1));break}}else n.push(s)}e.eventRegistrations_=n}else e.eventRegistrations_=[];return i}function Dn(e,t,n,i){t.type===Pt.MERGE&&null!==t.source.queryId&&((0,r.hu)(Yt(e.viewCache_),"We should always have a full c
2ache before handling merges"),(0,r.hu)(Ht(e.viewCache_),"Missing event cache, even though we have a server cache"));const s=e.viewCache_,o=wn(e.processor_,s,t,n,i);var a,l;return a=e.processor_,l=o.viewCache,(0,r.hu)(l.eventCache.getNode().isIndexed(a.filter.getIndex()),"Event snap not indexed"),(0,r.hu)(l.serverCache.getNode().isIndexed(a.filter.getIndex()),"Server snap not indexed"),(0,r.hu)(o.viewCache.serverCache.isFullyInitialized()||!s.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),e.viewCache_=o.viewCache,Mn(e,o.changes,o.viewCache.eventCache.getNode(),null)}function Mn(e,t,n,i){const s=i?[i]:e.eventRegistrations_;return function(e,t,n,i){const s=[],r=[];return t.forEach((t=>{var n;"child_changed"===t.type&&e.index_.indexedValueChanged(t.oldSnap,t.snapshotNode)&&r.push((n=t.childName,{type:"child_moved",snapshotNode:t.snapshotNode,childName:n}))})),Ot(e,s,"child_removed",t,i,n),Ot(e,s,"child_added",t,i,n),Ot(e,s,"child_moved",r,i,n),Ot(e,s,"child_changed",t,i,n),Ot(e,s,"value",t,i,n),s}(e.eventGenerator_,t,n,s)}let Fn,An;class qn{constructor(){this.views=new Map}}function On(e){return 0===e.views.size}function Ln(e,t,n,i){const s=t.source.queryId;if(null!==s){const o=e.views.get(s);return(0,r.hu)(null!=o,"SyncTree gave us an op for an invalid query."),Dn(o,t,n,i)}{let s=[];for(const r of e.views.values())s=s.concat(Dn(r,t,n,i));return s}}function Wn(e,t,n,i,s){const r=t._queryIdentifier,o=e.views.get(r);if(!o){let e=cn(n,s?i:null),r=!1;e?r=!0:i instanceof st?(e=un(n,i),r=!1):(e=st.EMPTY_NODE,r=!1);const o=Lt(new At(e,r,!1),new At(i,s,!1));return new Nn(t,o)}return o}function Un(e,t,n,i,s,r){const o=Wn(e,t,i,s,r);return e.views.has(t._queryIdentifier)||e.views.set(t._queryIdentifier,o),function(e,t){e.eventRegistrations_.push(t)}(o,n),function(e,t){const n=e.viewCache_.eventCache,i=[];n.getNode().isLeafNode()||n.getNode().forEachChild($e,((e,t)=>{i.push(dt(e,t))}));return n.isFullyInitialized()&&i.push(ut(n.getNode())),Mn(e,i,n.getNode(),t)}(o,n)}function Hn(e,t,n,i){const s=t._queryIdentifier,o=[];let a=[];const l=zn(e);if("default"===s)for(const[r,h]of e.views.entries())a=a.concat(Rn(h,n,i)),xn(h)&&(e.views.delete(r),h.query._queryParams.loadsAllData()||o.push(h.query));else{const t=e.views.get(s);t&&(a=a.concat(Rn(t,n,i)),xn(t)&&(e.views.delete(s),t.query._queryParams.loadsAllData()||o.push(t.query)))}return l&&!zn(e)&&o.push(new((0,r.hu)(Fn,"Reference.ts has not been loaded"),Fn)(t._repo,t._path)),{removed:o,events:a}}function Yn(e){const t=[];for(const n of e.views.values())n.query._queryParams.loadsAllData()||t.push(n);return t}function jn(e,t){let n=null;for(const i of e.views.values())n=n||Pn(i,t);return n}function Vn(e,t){if(t._queryParams.loadsAllData())return Kn(e);{const n=t._queryIdentifier;return e.views.get(n)}}function Bn(e,t){return null!=Vn(e,t)}function zn(e){return null!=Kn(e)}function Kn(e){for(const t of e.views.values())if(t.query._queryParams.loadsAllData())return t;return null}let Qn=1;class Gn{constructor(e){this.listenProvider_=e,this.syncPointTree_=new Vt(null),this.pendingWriteTree_={visibleWrites:Bt.empty(),allWrites:[],lastWriteId:-1},this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function $n(e,t,n,i,s){return function(e,t,n,i,s){(0,r.hu)(i>e.lastWriteId,"Stacking an older write on top of newer ones"),void 0===s&&(s=!0),e.allWrites.push({path:t,snap:n,writeId:i,visible:s}),s&&(e.visibleWrites=zt(e.visibleWrites,t,n)),e.lastWriteId=i}(e.pendingWriteTree_,t,n,i,s),s?si(e,new Mt({fromUser:!0,fromServer:!1,queryId:null,tagged:!1},t,n)):[]}function Xn(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const i=sn(e.pendingWriteTree_,t),s=rn(e.pendingWriteTree_,t);if(s){let t=new Vt(null);return null!=i.snap?t=t.set(fe(),!0):A(i.children,(e=>{t=t.set(new pe(e),!0)})),si(e,new Rt(i.path,t,n))}return[]}function Jn(e,t,n){return si(e,new Mt({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},t,n))}function Zn(e,t,n,i){let s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const r=t._path,o=e.syncPointTree_.get(r);let a=[];if(o&&("default"===t._queryIdentifier||Bn(o,t))){const l=Hn(o,t,n,i);On(o)&&(e.syncPointTree_=e.syncPointTree_.remove(r));const h=l.removed;if(a=l.events,!s){const n=-1!==h.findIndex((e=>e._queryParams.loadsAllData())),s=e.syncPointTree_.findOnPath(r,((e,t)=>
2zn(t)));if(n&&!s){const t=e.syncPointTree_.subtree(r);if(!t.isEmpty()){const n=_i(t);for(let t=0;t<n.length;++t){const i=n[t],s=i.query,r=ai(e,i);e.listenProvider_.startListening(pi(s),li(e,s),r.hashFn,r.onComplete)}}}if(!s&&h.length>0&&!i)if(n){const n=null;e.listenProvider_.stopListening(pi(t),n)}else h.forEach((t=>{const n=e.queryToTagMap.get(hi(t));e.listenProvider_.stopListening(pi(t),n)}))}fi(e,h)}return a}function ei(e,t,n,i){const s=ci(e,i);if(null!=s){const i=ui(s),r=i.path,o=i.queryId,a=be(r,t);return di(e,r,new Mt(xt(o),a,n))}return[]}function ti(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const s=t._path;let o=null,a=!1;e.syncPointTree_.foreachOnPath(s,((e,t)=>{const n=be(e,s);o=o||jn(t,n),a=a||zn(t)}));let l,h=e.syncPointTree_.get(s);if(h?(a=a||zn(h),o=o||jn(h,fe())):(h=new qn,e.syncPointTree_=e.syncPointTree_.set(s,h)),null!=o)l=!0;else{l=!1,o=st.EMPTY_NODE;e.syncPointTree_.subtree(s).foreachChild(((e,t)=>{const n=jn(t,fe());n&&(o=o.updateImmediateChild(e,n))}))}const c=Bn(h,t);if(!c&&!t._queryParams.loadsAllData()){const n=hi(t);(0,r.hu)(!e.queryToTagMap.has(n),"View does not exist, but we have a tag");const i=gi();e.queryToTagMap.set(n,i),e.tagToQueryMap.set(i,n)}const u=nn(e.pendingWriteTree_,s);let d=Un(h,t,n,u,o,l);if(!c&&!a&&!i){const n=Vn(h,t);d=d.concat(mi(e,t,n))}return d}function ni(e,t,n){const i=e.pendingWriteTree_,s=e.syncPointTree_.findOnPath(t,((e,n)=>{const i=jn(n,be(e,t));if(i)return i}));return hn(i,t,s,n,!0)}function ii(e,t){const n=t._path;let i=null;e.syncPointTree_.foreachOnPath(n,((e,t)=>{const s=be(e,n);i=i||jn(t,s)}));let s=e.syncPointTree_.get(n);s?i=i||jn(s,fe()):(s=new qn,e.syncPointTree_=e.syncPointTree_.set(n,s));const r=null!=i,o=r?new At(i,!0,!1):null;return function(e){return Ht(e.viewCache_)}(Wn(s,t,nn(e.pendingWriteTree_,t._path),r?o.getNode():st.EMPTY_NODE,r))}function si(e,t){return ri(t,e.syncPointTree_,null,nn(e.pendingWriteTree_,fe()))}function ri(e,t,n,i){if(Ie(e.path))return oi(e,t,n,i);
2{const s=t.get(fe());null==n&&null!=s&&(n=jn(s,fe()));let r=[];const o=ge(e.path),a=e.operationForChild(o),l=t.children.get(o);if(l&&a){const e=n?n.getImmediateChild(o):null,t=gn(i,o);r=r.concat(ri(a,l,e,t))}return s&&(r=r.concat(Ln(s,e,i,n))),r}}function oi(e,t,n,i){const s=t.get(fe());null==n&&null!=s&&(n=jn(s,fe()));let r=[];return t.children.inorderTraversal(((t,s)=>{const o=n?n.getImmediateChild(t):null,a=gn(i,t),l=e.operationForChild(t);l&&(r=r.concat(oi(l,s,o,a)))})),s&&(r=r.concat(Ln(s,e,i,n))),r}function ai(e,t){const n=t.query,i=li(e,n);return{hashFn:()=>{const e=function(e){return e.viewCache_.serverCache.getNode()}(t)||st.EMPTY_NODE;return e.hash()},onComplete:t=>{if("ok"===t)return i?function(e,t,n){const i=ci(e,n);if(i){const n=ui(i),s=n.path,r=n.queryId,o=be(s,t);return di(e,s,new Dt(xt(r),o))}return[]}(e,n._path,i):function(e,t){return si(e,new Dt({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},t))}(e,n._path);{const i=function(e,t){let n="Unknown Error";"too_big"===e?n="The data requested exceeds the maximum size that can be accessed with a single request.":"permission_denied"===e?n="Client doesn't have permission to access the desired data.":"unavailable"===e&&(n="The service is unavailable");const i=new Error(e+" at "+t._path.toString()+": "+n);return i.code=e.toUpperCase(),i}(t,n);return Zn(e,n,null,i)}}}}function li(e,t){const n=hi(t);return e.queryToTagMap.get(n)}function hi(e){return e._path.toString()+"$"+e._queryIdentifier}function ci(e,t){return e.tagToQueryMap.get(t)}function ui(e){const t=e.indexOf("$");return(0,r.hu)(-1!==t&&t<e.length-1,"Bad queryKey."),{queryId:e.substr(t+1),path:new pe(e.substr(0,t))}}function di(e,t,n){const i=e.syncPointTree_.get(t);(0,r.hu)(i,"Missing sync point for query tag that we're tracking");return Ln(i,n,nn(e.pendingWriteTree_,t),null)}function _i(e){return e.fold(((e,t,n)=>{if(t&&zn(t)){return[Kn(t)]}{let e=[];return t&&(e=Yn(t)),A(n,((t,n)=>{e=e.concat(n)})),e}}))}
2function pi(e){return e._queryParams.loadsAllData()&&!e._queryParams.isDefault()?new((0,r.hu)(An,"Reference.ts has not been loaded"),An)(e._repo,e._path):e}function fi(e,t){for(let n=0;n<t.length;++n){const i=t[n];if(!i._queryParams.loadsAllData()){const t=hi(i),n=e.queryToTagMap.get(t);e.queryToTagMap.delete(t),e.tagToQueryMap.delete(n)}}}function gi(){return Qn++}function mi(e,t,n){const i=t._path,s=li(e,t),o=ai(e,n),a=e.listenProvider_.startListening(pi(t),s,o.hashFn,o.onComplete),l=e.syncPointTree_.subtree(i);if(s)(0,r.hu)(!zn(l.value),"If we're adding a query, it shouldn't be shadowed");else{const t=l.fold(((e,t,n)=>{if(!Ie(e)&&t&&zn(t))return[Kn(t).query];{let e=[];return t&&(e=e.concat(Yn(t).map((e=>e.query)))),A(n,((t,n)=>{e=e.concat(n)})),e}}));for(let n=0;n<t.length;++n){const i=t[n];e.listenProvider_.stopListening(pi(i),li(e,i))}}return a}class yi{constructor(e){this.node_=e}getImmediateChild(e){const t=this.node_.getImmediateChild(e);return new yi(t)}node(){return this.node_}}class vi{constructor(e,t){this.syncTree_=e,this.path_=t}getImmediateChild(e){const t=Te(this.path_,e);return new vi(this.syncTree_,t)}node(){return ni(this.syncTree_,this.path_)}}const Ci=function(e,t,n){return e&&"object"===typeof e?((0,r.hu)(".sv"in e,"Unexpected leaf node or priority contents"),"string"===typeof e[".sv"]?wi(e[".sv"],t,n):"object"===typeof e[".sv"]?Ti(e[".sv"],t):void(0,r.hu)(!1,"Unexpected server value: "+JSON.stringify(e,null,2))):e},wi=function(e,t,n){if("timestamp"===e)return n.timestamp;(0,r.hu)(!1,"Unexpected server value: "+e)},Ti=function(e,t,n){e.hasOwnProperty("increment")||(0,r.hu)(!1,"Unexpected server value: "+JSON.stringify(e,null,2));const i=e.increment;"number"!==typeof i&&(0,r.hu)(!1,"Unexpected increment value: "+i);const s=t.node();if((0,r.hu)(null!==s&&"undefined"!==typeof s,"Expected ChildrenNode.EMPTY_NODE for nulls"),!s.isLeafNode())return i;const o=s.getValue();return"number"!==typeof o?i:o+i},Ii=function(e,t,n,i){return ki(t,new vi(n,e),i)},bi=function(e,t,n){return ki(e,new yi(t),n)};function ki(e,t,n){const i=e.getPriority().val(),s=Ci(i,t.getImmediateChild(".priority"),n);let r;if(e.isLeafNode()){const i=e,r=Ci(i.getValue(),t,n);return r!==i.getValue()||s!==i.getPriority().val()?new Ge(r,ot(s)):e}{const i=e;return r=i,s!==i.getPriority().val()&&(r=r.updatePriority(new Ge(s))),i.forEachChild($e,((e,i)=>{const s=ki(i,t.getImmediateChild(e),n);s!==i&&(r=r.updateImmediateChild(e,s))})),r}}class Ei{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{children:{},childCount:0};this.name=e,this.parent=t,this.node=n}}function Si(e,t){let n=t instanceof pe?t:new pe(t),i=e,s=ge(n);for(;null!==s;){const e=(0,r.DV)(i.node.children,s)||{children:{},childCount:0};i=new Ei(s,i,e),n=ye(n),s=ge(n)}return i}function Ni(e){return e.node.value}function Pi(e,t){e.node.value=t,Fi(e)}function xi(e){return e.node.childCount>0}function Ri(e,t){A(e.node.children,((n,i)=>{t(new Ei(n,e,i))}))}function Di(e,t,n,i){n&&!i&&t(e),Ri(e,(e=>{Di(e,t,!0,i)})),n&&i&&t(e)}function Mi(e){return new pe(null===e.parent?e.name:Mi(e.parent)+"/"+e.name)}function Fi(e){null!==e.parent&&function(e,t,n){const i=function(e){return void 0===Ni(e)&&!xi(e)}(n),s=(0,r.r3)(e.node.children,t);i&&s?(delete e.node.children[t],e.node.childCount--,Fi(e)):i||s||(e.node.children[t]=n.node,e.node.childCount++,Fi(e))}(e.parent,e.name,e)}const Ai=/[\[\].#$\/\u0000-\u001F\u007F]/,qi=/[\[\].#$\u0000-\u001F\u007F]/,Oi=10485760,Li=function(e){return"string"===typeof e&&0!==e.length&&!Ai.test(e)},Wi=function(e){return"string"===typeof e&&0!==e.length&&!qi.test(e)},Ui=function(e){return null===e||"string"===typeof e||"number"===typeof e&&!S(e)||e&&"object"===typeof e&&(0,r.r3)(e,".sv")},Hi=function(e,t,n,i){i&&void 0===t||Yi((0,r.gK)(e,"value"),t,n)},Yi=function(e,t,n){const i=n instanceof pe?new Se(n,e):n;if(void 0===t)throw new Error(e+"contains undefined "+Pe(i));if("function"===typeof t)throw new Error(e+"contains a function "+Pe(i)+" with contents = "+t.toString());if(S(t))throw new Error(e+"contains "+t.toString()+" "+Pe(i));if("string"===typeof t&&t.length>Oi/3&&(0,r.ug)(t)>Oi)throw new Error(e+"contains a string greater than "+"10485760 utf8 bytes "+Pe(i)+" ('"+t.substring(0,50)+"...')");if(t&&"object"===typeof t){let n=!1,s=!1;if(A(t,((t,o)=>{if(".value"===t)n=!0;else if(".priority"!==t&&".sv"!==t&&(s=!0,!Li(t)))throw new Error(e+" contains an invali
2d key ("+t+") "+Pe(i)+'.  Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');!function(e,t){e.parts_.length>0&&(e.byteLength_+=1),e.parts_.push(t),e.byteLength_+=(0,r.ug)(t),Ne(e)}(i,t),Yi(e,o,i),function(e){const t=e.parts_.pop();e.byteLength_-=(0,r.ug)(t),e.parts_.length>0&&(e.byteLength_-=1)}(i)})),n&&s)throw new Error(e+' contains ".value" child '+Pe(i)+" in addition to actual children.")}},ji=function(e,t,n,i){if((!i||void 0!==n)&&!Wi(n))throw new Error((0,r.gK)(e,t)+'was an invalid path = "'+n+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')},Vi=function(e,t){if(".info"===ge(t))throw new Error(e+" failed = Can't modify data under /.info/")},Bi=function(e,t){const n=t.path.toString();if("string"!==typeof t.repoInfo.host||0===t.repoInfo.host.length||!Li(t.repoInfo.namespace)&&"localhost"!==t.repoInfo.host.split(":")[0]||0!==n.length&&!function(e){return e&&(e=e.replace(/^\/*\.info(\/|$)/,"/")),Wi(e)}(n))throw new Error((0,r.gK)(e,"url")+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')};class zi{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function Ki(e,t){let n=null;for(let i=0;i<t.length;i++){const s=t[i],r=s.getPath();null===n||ke(r,n.path)||(e.eventLists_.push(n),n=null),null===n&&(n={events:[],path:r}),n.events.push(s)}n&&e.eventLists_.push(n)}function Qi(e,t,n){Ki(e,n),$i(e,(e=>ke(e,t)))}function Gi(e,t,n){Ki(e,n),$i(e,(e=>Ee(e,t)||Ee(t,e)))}function $i(e,t){e.recursionDepth_++;let n=!0;for(let i=0;i<e.eventLists_.length;i++){const s=e.eventLists_[i];if(s){t(s.path)?(Xi(e.eventLists_[i]),e.eventLists_[i]=null):n=!1}}n&&(e.eventLists_=[]),e.recursionDepth_--}function Xi(e){for(let t=0;t<e.events.length;t++){const n=e.events[t];if(null!==n){e.events[t]=null;const i=n.getEventRunner();v&&T("event: "+n.toString()),H(i)}}}const Ji="repo_interrupt";class Zi{constructor(e,t,n,i){this.repoInfo_=e,this.forceRestClient_=t,this.authTokenProvider_=n,this.appCheckProvider_=i,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new zi,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=bt(),this.transactionQueueTree_=new Ei,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}
2function es(e,t,n){if(e.stats_=te(e.repoInfo_),e.forceRestClient_||("object"===typeof window&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)>=0)e.server_=new Tt(e.repoInfo_,((t,n,i,s)=>{is(e,t,n,i,s)}),e.authTokenProvider_,e.appCheckProvider_),setTimeout((()=>ss(e,!0)),0);else{if("undefined"!==typeof n&&null!==n){if("object"!==typeof n)throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{(0,r.Wl)(n)}catch(i){throw new Error("Invalid authOverride provided: "+i)}}e.persistentConnection_=new De(e.repoInfo_,t,((t,n,i,s)=>{is(e,t,n,i,s)}),(t=>{ss(e,t)}),(t=>{!function(e,t){A(t,((t,n)=>{rs(e,t,n)}))}(e,t)}),e.authTokenProvider_,e.appCheckProvider_,n),e.server_=e.persistentConnection_}e.authTokenProvider_.addTokenChangeListener((t=>{e.server_.refreshAuthToken(t)})),e.appCheckProvider_.addTokenChangeListener((t=>{e.server_.refreshAppCheckToken(t.token)})),e.statsReporter_=function(e,t){const n=e.toString();return ee[n]||(ee[n]=t()),ee[n]}(e.repoInfo_,(()=>new Nt(e.stats_,e.server_))),e.infoData_=new It,e.infoSyncTree_=new Gn({startListening:(t,n,i,s)=>{let r=[];const o=e.infoData_.getNode(t._path);return o.isEmpty()||(r=Jn(e.infoSyncTree_,t._path,o),setTimeout((()=>{s("ok")}),0)),r},stopListening:()=>{}}),rs(e,"connected",!1),e.serverSyncTree_=new Gn({startListening:(t,n,i,s)=>(e.server_.listen(t,i,n,((n,i)=>{const r=s(n,i);Gi(e.eventQueue_,t._path,r)})),[]),stopListening:(t,n)=>{e.server_.unlisten(t,n)}})}function ts(e){const t=e.infoData_.getNode(new pe(".info/serverTimeOffset")).val()||0;return(new Date).getTime()+t}function ns(e){return(t=(t={timestamp:ts(e)})||{}).timestamp=t.timestamp||(new Date).getTime(),t;var t}function is(e,t,n,i,s){e.dataUpdateCount++;const o=new pe(t);n=e.interceptServerDataCallback_?e.interceptServerDataCallback_(t,n):n;let a=[];if(s)if(i){const t=(0,r.UI)(n,(e=>ot(e)));a=function(e,t,n,i){const s=ci(e,i);if(s){const i=ui(s),r=i.path,o=i.queryId,a=be(r,t),l=Vt.fromObject(n);return di(e,r,new Ft(xt(o),a,l))}return[]}(e.serverSyncTree_,o,t,s)}else{const t=ot(n);a=ei(e.serverSyncTree_,o,t,s)}else if(i){const t=(0,r.UI)(n,(e=>ot(e)));a=function(e,t,n){const i=Vt.fromObject(n);return si(e,new Ft({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},t,i))}(e.serverSyncTree_,o,t)}else{const t=ot(n);a=Jn(e.serverSyncTree_,o,t)}let l=o;a.length>0&&(l=fs(e,o)),Gi(e.eventQueue_,l,a)}function ss(e,t){rs(e,"connected",t),!1===t&&function(e){cs(e,"onDisconnectEvents");const t=ns(e),n=bt();Et(e.onDisconnect_,fe(),((i,s)=>{const r=Ii(i,s,e.serverSyncTree_,t);kt(n,i,r)}));let i=[];Et(n,fe(),((t,n)=>{i=i.concat(Jn(e.serverSyncTree_,t,n));const s=Cs(e,t);fs(e,s)})),e.onDisconnect_=bt(),Gi(e.eventQueue_,fe(),i)}(e)}function rs(e,t,n){const i=new pe("/.info/"+t),s=ot(n);e.infoData_.updateSnapshot(i,s);const r=Jn(e.infoSyncTree_,i,s);Gi(e.eventQueue_,i,r)}function os(e){return e.nextWriteId_++}function as(e,t,n,i,s){cs(e,"set",{path:t.toString(),value:n,priority:i});const r=ns(e),o=ot(n,i),a=ni(e.serverSyncTree_,t),l=bi(o,a,r),h=os(e),c=$n(e.serverSyncTree_,t,l,h,!0);Ki(e.eventQueue_,c),e.server_.put(t.toString(),o.val(!0),((n,i)=>{const r="ok"===n;r||E("set at "+t+" failed: "+n);const o=Xn(e.serverSyncTree_,h,!r);Gi(e.eventQueue_,t,o),us(e,s,n,i)}));const u=Cs(e,t);fs(e,u),Gi(e.eventQueue_,u,[])}function ls(e,t,n){let i;i=".info"===ge(t._path)?Zn(e.infoSyncTree_,t,n):Zn(e.serverSyncTree_,t,n),Qi(e.eventQueue_,t._path,i)}function hs(e){e.persistentConnection_&&e.persistentConnection_.interrupt(Ji)}function cs(e){let t="";e.persistentConnection_&&(t=e.persistentConnection_.id+":");for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];T(t,...i)}function us(e,t,n,i){t&&H((()=>{if("ok"===n)t(null);else{const e=(n||"error").toUpperCase();let s=e;i&&(s+=": "+i);const r=new Error(s);r.code=e,t(r)}}))}function ds(e,t,n){return ni(e.serverSyncTree_,t,n)||st.EMPTY_NODE}function _s(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.transactionQueueTree_;if(t||vs(e,t),Ni(t)){const n=ms(e,t);(0,r.hu)(n.length>0,"Sending zero length transaction queue");n.every((e=>0===e.status))&&ps(e,Mi(t),n)}else xi(t)&&Ri(t,(t=>{_s(e,t)}))}function ps(e,t,n){const i=n.map((e=>e.currentWriteId)),s=ds(e,t,i);let o=s;const a=s.hash();for(let c=0;c<n.length;c++){const e=n[c];(0,r.hu)(0===e.status,"tryToSendTransactionQueue_: items in queue should all be run."),e.status=1,e.retryCount++;const i=be(t,e.path);o=o.updateChild(i,e.currentOutputSnapshotRaw)}const l=o.val(!0),h=t;e.server_.put(h.toString(),l,(i=>{cs(e,"transaction put response",{path:h.toString(),status:i});let s=[];if("ok"===i){const i=[];for(let t=0;t<n.length;t++)n[t].status=2,s=s.concat(Xn(e.serverSyncTree_,n[t].currentWriteId)),n[t].onComplete&&i.push((()=>n[t].onComplete(null,!0,n[t].currentOutputSnapshotResolved))),n[t].unwatcher();vs(e,Si(e.transactionQueueTree_,t)),_s(e,e.transactionQueueTree_),Gi(e.eventQueue_,t,s);for(let e=0;e<i.length;e++)H(i[e])}else{if("datastale"===i)for(let e=0;e<n.length;e++)3===n[e].status?n[e].status=4:n[e].status=0;else{E("transaction at "+h.toString()+" failed: "+i);for(let e=0;e<n.length;e++)n[e].status=4,n[e].abortReason=i}fs(e,t)}}),a)}function fs(e,t){const n=gs(e,t),i=Mi(n);return function(e,t,n){if(0===t.length)return;const i=[];let s=[];const o=t.filter((e=>0===e.status)).map((e=>e.currentWriteId));for(let l=0;l<t.length;l++){const h=t[l],c=be(n,h.path);let u,d=!1;if((0,r.hu)(null!==c,"rerunTransactionsUnderNode_: relativePath should not be null."),4===h.status)d=!0,u=h.abortReason,s=s.concat(Xn(e.serverSyncTree_,h.currentWriteId,!0));else if(0===h.status)if(h.retryCount>=25)d=!0,u="maxretry",s=s.concat(Xn(e.serverSyncTree_,h.currentWriteId,!0));else{const n=ds(e,h.path,o);h.currentInputSnapshot=n;const i=t[l].update(n.val());if(void 0!==i){Yi("transaction failed: Data returned ",i,h.path);let t=ot(i);"object"===typeof i&&null!=i&&(0,r.r3)(i,".priority")||(t=t.updatePriority(n.getPri
vendor: 11,327 bytes, line 2
2ority()));const a=h.currentWriteId,l=ns(e),c=bi(t,n,l);h.currentOutputSnapshotRaw=t,h.currentOutputSnapshotResolved=c,h.currentWriteId=os(e),o.splice(o.indexOf(a),1),s=s.concat($n(e.serverSyncTree_,h.path,c,h.currentWriteId,h.applyLocally)),s=s.concat(Xn(e.serverSyncTree_,a,!0))}else d=!0,u="nodata",s=s.concat(Xn(e.serverSyncTree_,h.currentWriteId,!0))}Gi(e.eventQueue_,n,s),s=[],d&&(t[l].status=2,a=t[l].unwatcher,setTimeout(a,Math.floor(0)),t[l].onComplete&&("nodata"===u?i.push((()=>t[l].onComplete(null,!1,t[l].currentInputSnapshot))):i.push((()=>t[l].onComplete(new Error(u),!1,null)))))}var a;vs(e,e.transactionQueueTree_);for(let r=0;r<i.length;r++)H(i[r]);_s(e,e.transactionQueueTree_)}(e,ms(e,n),i),i}function gs(e,t){let n,i=e.transactionQueueTree_;for(n=ge(t);null!==n&&void 0===Ni(i);)i=Si(i,n),n=ge(t=ye(t));return i}function ms(e,t){const n=[];return ys(e,t,n),n.sort(((e,t)=>e.order-t.order)),n}function ys(e,t,n){const i=Ni(t);if(i)for(let s=0;s<i.length;s++)n.push(i[s]);Ri(t,(t=>{ys(e,t,n)}))}function vs(e,t){const n=Ni(t);if(n){let e=0;for(let t=0;t<n.length;t++)2!==n[t].status&&(n[e]=n[t],e++);n.length=e,Pi(t,n.length>0?n:void 0)}Ri(t,(t=>{vs(e,t)}))}function Cs(e,t){const n=Mi(gs(e,t)),i=Si(e.transactionQueueTree_,t);return function(e,t,n){let i=n?e:e.parent;for(;null!==i;){if(t(i))return!0;i=i.parent}}(i,(t=>{ws(e,t)})),ws(e,i),Di(i,(t=>{ws(e,t)})),n}function ws(e,t){const n=Ni(t);if(n){const i=[];let s=[],o=-1;for(let t=0;t<n.length;t++)3===n[t].status||(1===n[t].status?((0,r.hu)(o===t-1,"All SENT items should be at beginning of queue."),o=t,n[t].status=3,n[t].abortReason="set"):((0,r.hu)(0===n[t].status,"Unexpected transaction status in abort"),n[t].unwatcher(),s=s.concat(Xn(e.serverSyncTree_,n[t].currentWriteId,!0)),n[t].onComplete&&i.push(n[t].onComplete.bind(null,new Error("set"),!1,null))));-1===o?Pi(t,void 0):n.length=o+1,Gi(e.eventQueue_,Mi(t),s);for(let e=0;e<i.length;e++)H(i[e])}}const Ts=function(e,t){const n=Is(e),i=n.namespace;"firebase.com"===n.domain&&k(n.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),i&&"undefined"!==i||"localhost"===n.domain||k("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),n.secure||"undefined"!==typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&E("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().");const s="ws"===n.scheme||"wss"===n.scheme;return{repoInfo:new $(n.host,n.secure,i,s,t,"",i!==n.subdomain),path:new pe(n.pathString)}},Is=function(e){let t="",n="",i="",s="",r="",o=!0,a="https",l=443;if("string"===typeof e){let h=e.indexOf("//");h>=0&&(a=e.substring(0,h-1),e=e.substring(h+2));let c=e.indexOf("/");-1===c&&(c=e.length);let u=e.indexOf("?");-1===u&&(u=e.length),t=e.substring(0,Math.min(c,u)),c<u&&(s=function(e){let t="";const n=e.split("/");for(let s=0;s<n.length;s++)if(n[s].length>0){let e=n[s];try{e=decodeURIComponent(e.replace(/\+/g," "))}catch(i){}t+="/"+e}return t}(e.substring(c,u)));const d=function(e){const t={};"?"===e.charAt(0)&&(e=e.substring(1));for(const n of e.split("&")){if(0===n.length)continue;const i=n.split("=");2===i.length?t[decodeURIComponent(i[0])]=decodeURIComponent(i[1]):E("Invalid query segment '".concat(n,"' in query '").concat(e,"'"))}return t}(e.substring(Math.min(e.length,u)));h=t.indexOf(":"),h>=0?(o="https"===a||"wss"===a,l=parseInt(t.substring(h+1),10)):h=t.length;const _=t.slice(0,h);if("localhost"===_.toLowerCase())n="localhost";else if(_.split(".").length<=2)n=_;else{const e=t.indexOf(".");i=t.substring(0,e).toLowerCase(),n=t.substring(e+1),r=i}"ns"in d&&(r=d.ns)}return{host:t,port:l,domain:n,subdomain:i,secure:o,scheme:a,pathString:s,namespace:r}};class bs{constructor(e,t,n,i){this.eventType=e,this.eventRegistration=t,this.snapshot=n,this.prevName=i}getPath(){const e=this.snapshot.ref;return"value"===this.eventType?e._path:e.parent._path}getEventType(){return this.eventType}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.getPath().toString()+":"+this.eventType+":"+(0,r.Wl)(this.snapshot.exportVal())}}class ks{constructor(e,t,n){this.eventRegistration=e,this.error=t,this.path=n}getPath(){return this.path}getEventType(){return"cancel"}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.path.toString()+":cancel"}}class Es{constructor(e,t){this.snapshotCallback=e,this.cancelCallback=t}onValue(e,t){this.snapshotCallback.call(null,e,t)}onCancel(e){return(0,r.hu)(this.hasCancelCallback,"Raising a cancel event on a listener with no cancel callback"),this.cancelCallback.call(null,e)}get hasCancelCallback(){return!!this.cancelCallback}matches(e){return this.snapshotCallback===e.snapshotCallback||void 0!==this.snapshotCallback.userCallback&&this.snapshotCallback.userCallback===e.snapshotCallback.userCallback&&this.snapshotCallback.context===e.snapshotCallback.context}}class Ss{constructor(e,t,n,i){this._repo=e,this._path=t,this._queryParams=n,this._orderByCalled=i}get key(){return Ie(this._path)?null:ve(this._path)}get ref(){return new xs(this._repo,this._path)}get _queryIdentifier(){const e=wt(this._queryParams),t=M(e);return"{}"===t?"default":t}get _queryObject(){return wt(this._queryParams)}isEqual(e){if(!((e=(0,r.m9)(e))instanceof Ss))return!1;const t=this._repo===e._repo,n=ke(this._path,e._path),i=this._queryIdentifier===e._queryIdentifier;return t&&n&&i}toJSON(){return this.toString()}toString(){return this._repo.toString()+function(e){let t="";for(let n=e.pieceNum_;n<e.pieces_.length;n++)""!==e.pieces_[n]&&(t+="/"+encodeURIComponent(String(e.pieces_[n])));return t||"/"}(this._path)}}function Ns(e,t){if(!0===e._orderByCalled)throw new Error(t+": You can't combine multiple orderBy calls.")}function Ps(e){let t=null,n=null;if(e.hasStart()&&(t=e.getIndexStartValue()),e.hasEnd()&&(n=e.getIndexEndValue()),e.getIndex()===Oe){const i="Query: When ordering by key, you may only pass one argument to startAt(), endAt(), or equalTo().",s="Query: When ordering by key, the argument passed to startAt(), startAfter(), endAt(), endBefore(), or equalTo() must be a string.";if(e.hasStart()){if(e.getIndexStartName()!==N)throw new Error(i);if("string"!==typeof t)throw new Error(s)}if(e.hasEnd()){if(e.getIndexEndName()!==P)throw new Error(i);if("string"!==typeof n)throw new Error(s)}}else if(e.getIndex()===$e){if(null!=t&&!Ui(t)||null!=n&&!Ui(n))throw new Error("Query: When ordering by priority, the first argument passed to startAt(), startAfter() endAt(), endBefore(), or equalTo() must be a valid priority value (null, a number, or a string).")}else if((0,r.hu)(e.getIndex()instanceof at||e.getIndex()===lt,"unknown index type."),null!=t&&"object"===typeof t||null!=n&&"object"===typeof n)throw new Error("Query: First argument passed to startAt(), startAfter(), endAt(), endBefore(), or equalTo() cannot be an object.")}class xs extends Ss{constructor(e,t){super(e,t,new yt,!1)}get parent(){const e=we(this._path);return null===e?null:new xs(this._repo,e)}get root(){let e=this;for(;null!==e.parent;)e=e.parent;return e}}class Rs{constructor(e,t,n){this._node=e,this.ref=t,this._index=n}get priority(){return this._node.getPriority().val()}get key(){return this.ref.key}get size(){return this._node.numChildren()}child(e){const t=new pe(e),n=Ms(this.ref,e);return new Rs(this._node.getChild(t),n,$e)}exists(){return!this._node.isEmpty()}exportVal(){return this._node.val(!0)}forEach(e){if(this._node.isLeafNode())return!1;return!!this._node.forEachChild(this._index,((t,n)=>e(new Rs(n,Ms(this.ref,t),$e))))}hasChild(e){const t=new pe(e);return!this._node.getChild(t).isEmpty()}hasChildren(){return!this._node.isLeafNode()&&!this._node.isEmpty()}toJSON(){return this.exportVal()}val(){return this._node.val()}}function Ds(e,t){return(e=(0,r.m9)(e))._checkNotDeleted("ref"),void 0!==t?Ms(e._root,t):e._root}function Ms(e,t){var n,i,s,o;return null===ge((e=(0,r.m9)(e))._path)?(n="child",i="path",o=!1,(s=t)&&(s=s.replace(/^\/*\.info(\/|$)/,"/")),ji(n,i,s,o)):ji("child","path",t,!1),new xs(e._repo,Te(e._path,t))}function Fs(e,t){e=(0,r.m9)(e),Vi("push",e._path),Hi("push",t,e._path,!0);const n=ts(e._repo),i=ct(n),s=Ms(e,i),o=Ms(e,i);let a;return a=null!=t?As(o,t).then((()=>o)):Promise.resolve(o),s.then=a.then.bind(a),s.catch=a.then.bind(a,void 0),s}function As(e,t){e=(0,r.m9)(e),Vi("set",e._path),Hi("set",t,e._path,!1);const n=new r.BH;return as(e._repo,e._path,t,null,n.wrapCallback((()=>{}))),n.promise}function qs(e){e=(0,r.m9)(e);const t=new Es((()=>{})),n=new Os(t);return function(e,t,n){const i=ii(e.serverSyncTree_,t);return null!=i?Promise.resolve(i):e.server_.get(t).then((i=>{const s=ot(i).withIndex(t._queryParams.getIndex());let r;if(ti(e.serverSyncTree_,t,n,!0),t._queryParams.loadsAllData())r=Jn(e.serverSyncTree_,t._path,s);else{const n=li(e.serverSyncTree_,t);r=ei(e.serverSyncTree_,t._path,s,n)}return Gi(e.eventQueue_,t._path,r),Zn(e.serverSyncTree_,t,n,null,!0),s}),(n=>(cs(e,"get for query "+(0,r.Wl)(t)+" failed: "+n),Promise.reject(new Error(n)))))}(e._repo,e,n).then((t=>new Rs(t,new xs(e._repo,e._path),e._queryParams.getIndex())))}class Os{constructor(e){this.callbackContext=e}respondsTo(e){return"value"===e}createEvent(e,t){const n=t._queryParams.getIndex();return new bs("value",this,new Rs(e.snapshotNode,new xs(t._repo,t._path),n))}getEventRunner(e){return"cancel"===e.getEventType()?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,null)}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new ks(this,e,t):null}matches(e){return e instanceof Os&&(!e.callbackContext||!this.callbackContext||e.callbackContext.matches(this.callbackContext))}hasAnyCallback(){return null!==this.callbackContext}}class Ls{constructor(e,t){this.eventType=e,this.callbackContext=t}respondsTo(e){let t="children_added"===e?"child_added":e;return t="children_removed"===t?"child_removed":t,this.eventType===t}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new ks(this,e,t):null}createEvent(e,t){(0,r.hu)(null!=e.childName,"Child events should have a childName.");const n=Ms(new xs(t._repo,t._path),e.childName),i=t._queryParams.getIndex();return new bs(e.type,this,new Rs(e.snapshotNode,n,i),e.prevName)}getEventRunner(e){return"cancel"===e.getEventType()?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,e.prevName)}matches(e){return e instanceof Ls&&(this.eventType===e.eventType&&(!this.callbackContext||!e.callbackContext||this.callbackContext.matches(e.callbackContext)))}hasAnyCallback(){return!!this.callbackContext}}function Ws(e,t,n,i,s){let r;if("object"===typeof i&&(r=void 0,s=i),"function"===typeof i&&(r=i),s&&s.onlyOnce){const t=n,i=(n,i)=>{ls(e._repo,e,a),t(n,i)};i.userCallback=n.userCallback,i.context=n.context,n=i}const o=new Es(n,r||void 0),a="value"===t?new Os(o):new Ls(t,o);return function(e,t,n){let i;i=".info"===ge(t._path)?ti(e.infoSyncTree_,t,n):ti(e.serverSyncTree_,t,n),Qi(e.eventQueue_,t._path,i)}(e._repo,e,a),()=>ls(e._repo,e,a)}function Us(e,t,n,i){return Ws(e,"value",t,n,i)}class Hs{}class Ys extends Hs{constructor(e){super(),this._limit=e}_apply(e){if(e._queryParams.hasLimit())throw new Error("limitToLast: Limit was already set 
2(by another call to limitToFirst or limitToLast).");return new Ss(e._repo,e._path,function(e,t){const n=e.copy();return n.limitSet_=!0,n.limit_=t,n.viewFrom_="r",n}(e._queryParams,this._limit),e._orderByCalled)}}function js(e){if("number"!==typeof e||Math.floor(e)!==e||e<=0)throw new Error("limitToLast: First argument must be a positive integer.");return new Ys(e)}class Vs extends Hs{constructor(e){super(),this._path=e}_apply(e){Ns(e,"orderByChild");const t=new pe(this._path);if(Ie(t))throw new Error("orderByChild: cannot pass in empty path. Use orderByValue() instead.");const n=new at(t),i=vt(e._queryParams,n);return Ps(i),new Ss(e._repo,e._path,i,!0)}}function Bs(e){if("$key"===e)throw new Error('orderByChild: "$key" is invalid.  Use orderByKey() instead.');if("$priority"===e)throw new Error('orderByChild: "$priority" is invalid.  Use orderByPriority() instead.');if("$value"===e)throw new Error('orderByChild: "$value" is invalid.  Use orderByValue() instead.');return ji("orderByChild","path",e,!1),new Vs(e)}!function(e){(0,r.hu)(!Fn,"__referenceConstructor has already been defined"),Fn=e}(xs),function(e){(0,r.hu)(!An,"__referenceConstructor has already been defined"),An=e}(xs);const zs={};let Ks=!1;function Qs(e,t,n,i){e.repoInfo_=new $("".concat(t,":").concat(n),!1,e.repoInfo_.namespace,e.repoInfo_.webSocketOnly,e.repoInfo_.nodeAdmin,e.repoInfo_.persistenceKey,e.repoInfo_.includeNamespaceInQueryParams),i&&(e.authTokenProvider_=i)}function Gs(e,t,n,i,s){let r=i||e.options.databaseURL;void 0===r&&(e.options.projectId||k("Can't determine Firebase Database URL. Be sure to include  a Project ID when calling firebase.initializeApp()."),T("Using default host for project ",e.options.projectId),r="".concat(e.options.projectId,"-default-rtdb.firebaseio.com"));let o,a,l=Ts(r,s),h=l.repoInfo;"undefined"!==typeof process&&(a={NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}.FIREBASE_DATABASE_EMULATOR_HOST),a?(o=!0,r="http://".concat(a,"?ns=").concat(h.namespace),l=Ts(r,s),h=l.repoInfo):o=!l.repoInfo.secure;const c=s&&o?new B(B.OWNER):new V(e.name,e.options,t);Bi("Invalid Firebase Database URL",l),Ie(l.path)||k("Database URL must point to the root of a Firebase Database (not including a child path).");
2const u=function(e,t,n,i){let s=zs[t.name];s||(s={},zs[t.name]=s);let r=s[e.toURLString()];r&&k("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call.");return r=new Zi(e,Ks,n,i),s[e.toURLString()]=r,r}(h,e,c,new j(e.name,n));return new $s(u,e)}class $s{constructor(e,t){this._repoInternal=e,this.app=t,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(es(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new xs(this._repo,fe())),this._rootInternal}_delete(){return null!==this._rootInternal&&(!function(e,t){const n=zs[t];n&&n[e.key]===e||k("Database ".concat(t,"(").concat(e.repoInfo_,") has already been deleted.")),hs(e),delete n[e.key]}(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(e){null===this._rootInternal&&k("Cannot call "+e+" on a deleted database.")}}function Xs(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:(0,i.Mq)(),t=arguments.length>1?arguments[1]:void 0;const n=(0,i.qX)(e,"database").getImmediate({identifier:t}),s=(0,r.P0)("database");return s&&Js(n,...s),n}function Js(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};(e=(0,r.m9)(e))._checkNotDeleted("useEmulator"),e._instanceStarted&&k("Cannot call useEmulator() after instance has already been initialized.");const s=e._repoInternal;let o;if(s.repoInfo_.nodeAdmin)i.mockUserToken&&k('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),o=new B(B.OWNER);else if(i.mockUserToken){const t="string"===typeof i.mockUserToken?i.mockUserToken:(0,r.Sg)(i.mockUserToken,e.app.options.projectId);o=new B(t)}Qs(s,t,n,o)}De.prototype.simpleListen=function(e,t){this.sendRequest("q",{p:e},t)},De.prototype.echo=function(e,t){this.sendRequest("echo",{d:e},t)};var Zs;!function(e){h=e}(i.Jn),(0,i.Xd)(new s.wA("database",((e,t)=>{let{instanceIdentifier:n}=t;return Gs(e.getProvider("app").getImmediate(),e.getProvider("auth-internal"),e.getProvider("app-check-internal"),n)}),"PUBLIC").setMultipleInstances(!0)),(0,i.KN)(a,l,Zs),(0,i.KN)(a,l,"esm2017")},19432:(e,t,n)=>{"use strict";n.d(t,{ZP:()=>s});var i=n(64141);i.domToReact,i.htmlToDOM,i.attributesToProps,i.Element;const s=i}}]);
3//# sourceMappingURL=4908.732f7d7b.chunk.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.