1(function(){try{var Fe=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},Ye=new Fe.Error().stack;Ye&&(Fe._sentryDebugIds=Fe._sentryDebugIds||{},Fe._sentryDebugIds[Ye]="80fd6af4-a83a-4679-b486-8f8dbe32cdf0",Fe._sentryDebugIdIdentifier="sentry-dbid-80fd6af4-a83a-4679-b486-8f8dbe32cdf0")}catch{}})();var _global=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};_global.SENTRY_RELEASE={id:"6b3b5bcd49ac3ca4e22832378da81add8169a867"},(self.webpackChunk_maestro_io_client=self.webpackChunk_maestro_io_client||[]).push([[8531],{288531:(Fe,Ye,L)=>{var Pe=L(329833),oe=L(700134),N=L(569971),Te=L(80247),Je=L(288538);/** 2 * @license 3 * Copyright 2017 Google LLC 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */const Be={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"};/** 17 * @license 18 * Copyright 2017 Google LLC 19 * 20 * Licensed under the Apache License, Version 2.0 (the "License"); 21 * you may not use this file except in compliance with the License. 22 * You may obtain a copy of the License at 23 * 24 * http://www.apache.org/licenses/LICENSE-2.0 25 * 26 * Unless required by applicable law or agreed to in writing, software 27 * distributed under the License is distributed on an "AS IS" BASIS, 28 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 * See the License for the specific language governing permissions and 30 * limitations under the License. 31 */const y=function(n,e){if(!n)throw ye(e)},ye=function(n){return new Error("Firebase Database ("+Be.SDK_VERSION+") INTERNAL ASSERT FAILED: "+n)};/** 32 * @license 33 * Copyright 2017 Google LLC 34 * 35 * Licensed under the Apache License, Version 2.0 (the "License"); 36 * you may not use this file except in compliance with the License. 37 * You may obtain a copy of the License at 38 * 39 * http://www.apache.org/licenses/LICENSE-2.0 40 * 41 * Unless required by applicable law or agreed to in writing, software 42 * distributed under the License is distributed on an "AS IS" BASIS, 43 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 44 * See the License for the specific language governing permissions and 45 * limitations under the License. 46 */const lt=function(n){const e=[];let t=0;for(let i=0;i<n.length;i++){let s=n.charCodeAt(i);s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&i+1<n.length&&(n.charCodeAt(i+1)&64512)===56320?(s=65536+((s&1023)<<10)+(n.charCodeAt(++i)&1023),e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128)}return e},ct=function(n){const e=[];let t=0,i=0;for(;t<n.length;){const s=n[t++];if(s<128)e[i++]=String.fromCharCode(s);else if(s>191&&s<224){const r=n[t++];e[i++]=String.fromCharCode((s&31)<<6|r&63)}else if(s>239&&s<365){const r=n[t++],o=n[t++],a=n[t++],c=((s&7)<<18|(r&63)<<12|(o&63)<<6|a&63)-65536;e[i++]=String.fromCharCode(55296+(c>>10)),e[i++]=String.fromCharCode(56320+(c&1023))}else{const r=n[t++],o=n[t++];e[i++]=String.fromCharCode((s&15)<<12|(r&63)<<6|o&63)}}return e.join("")},D={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(n,e){if(!Array.isArray(n))throw Error("encodeByteArray takes an array as a parameter");this.init_();const t=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,i=[];for(let s=0;s<n.length;s+=3){const r=n[s],o=s+1<n.length,a=o?n[s+1]:0,c=s+2<n.length,h=c?n[s+2]:0,p=r>>2,f=(r&3)<<4|a>>4;let m=(a&15)<<2|h>>6,v=h&63;c||(v=64,o||(m=64)),i.push(t[p],t[f],t[m],t[v])}return i.join("")},encodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(n):this.encodeByteArray(lt(n),e)},decodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(n):ct(this.decodeStringToByteArray(n,e))},decodeStringToByteArray(n,e){this.init_();const t=e?this.charToByteMapWebSafe_:this.charToByteMap_,i=[];for(let s=0;s<n.length;){const r=t[n.charAt(s++)],a=s<n.length?t[n.charAt(s)]:0;++s;const h=s<n.length?t[n.charAt(s)]:64;++s;const f=s<n.length?t[n.charAt(s)]:64;if(++s,r==null||a==null||h==null||f==null)throw Error();const m=r<<2|a>>4;if(i.push(m),h!==64){const v=a<<4&240|h>>2;if(i.push(v),f!==64){const C=h<<6&192|f;i.push(C)}}}return i},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let n=0;n<this.ENCODED_VALS.length;n++)this.byteToCharMap_[n]=this.ENCODED_VALS.charAt(n),this.charToByteMap_[this.byteToCharMap_[n]]=n,this.byteToCharMapWebSafe_[n]=this.ENCODED_VALS_WEBSAFE.charAt(n),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[n]]=n,n>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(n)]=n,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(n)]=n)}}},T=function(n){const e=lt(n);return D.encodeByteArray(e,!0)},xe=function(n){return T(n).replace(/\./g,"")},he=function(n){try{return D.decodeString(n,!0)}catch(e){Te.error("base64Decode failed: ",e)}return null};/** 47 * @license 48 * Copyright 2017 Google LLC 49 * 50 * Licensed under the Apache License, Version 2.0 (the "License");
51 * you may not use this file except in compliance with the License. 52 * You may obtain a copy of the License at 53 * 54 * http://www.apache.org/licenses/LICENSE-2.0 55 * 56 * Unless required by applicable law or agreed to in writing, software 57 * distributed under the License is distributed on an "AS IS" BASIS, 58 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 59 * See the License for the specific language governing permissions and 60 * limitations under the License. 61 */function ue(n){return ht(void 0,n)}function ht(n,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:const t=e;return new Date(t.getTime());case Object:n===void 0&&(n={});break;case Array:n=[];break;default:return e}for(const t in e)!e.hasOwnProperty(t)||!ut(t)||(n[t]=ht(n[t],e[t]));return n}function ut(n){return n!=="__proto__"}/** 62 * @license 63 * Copyright 2017 Google LLC 64 * 65 * Licensed under the Apache License, Version 2.0 (the "License"); 66 * you may not use this file except in compliance with the License. 67 * You may obtain a copy of the License at 68 * 69 * http://www.apache.org/licenses/LICENSE-2.0 70 * 71 * Unless required by applicable law or agreed to in writing, software 72 * distributed under the License is distributed on an "AS IS" BASIS, 73 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 74 * See the License for the specific language governing permissions and 75 * limitations under the License. 76 */function Xe(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function ee(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(Xe())}function Zn(){try{return Object.prototype.toString.call(L.g.process)==="[object process]"}catch{return!1}}function na(){return typeof self=="object"&&self.self===self}function ia(){const n=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof n=="object"&&n.id!==void 0}function Ts(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function sa(){return Xe().indexOf("Electron/")>=0}function ra(){const n=Xe();return n.indexOf("MSIE ")>=0||n.indexOf("Trident/")>=0}function oa(){return Xe().indexOf("MSAppHost/")>=0}function Ie(){return Be.NODE_CLIENT===!0||Be.NODE_ADMIN===!0}function aa(){return!Zn()&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function xs(){return typeof indexedDB=="object"}function Is(){return new Promise((n,e)=>{try{let t=!0;const i="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(i);s.onsuccess=()=>{s.result.close(),t||self.indexedDB.deleteDatabase(i),n(!0)},s.onupgradeneeded=()=>{t=!1},s.onerror=()=>{var r;e(((r=s.error)===null||r===void 0?void 0:r.message)||"")}}catch(t){e(t)}})}function As(){return!(typeof navigator>"u"||!navigator.cookieEnabled)}function ei(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof L.g<"u")return L.g;throw new Error("Unable to locate global object.")}/** 77 * @license 78 * Copyright 2022 Google LLC 79 * 80 * Licensed under the Apache License, Version 2.0 (the "License"); 81 * you may not use this file except in compliance with the License. 82 * You may obtain a copy of the License at 83 * 84 * http://www.apache.org/licenses/LICENSE-2.0 85 * 86 * Unless required by applicable law or agreed to in writing, software 87 * distributed under the License is distributed on an "AS IS" BASIS, 88 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 89 * See the License for the specific language governing permissions and 90 * limitations under the License. 91 */const Nt=()=>ei().__FIREBASE_DEFAULTS__,ti=()=>{if(typeof Je>"u"||typeof Je.env>"u")return;const n=Je.env.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},Ns=()=>{if(typeof document>"u")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=n&&he(n[1]);return e&&JSON.parse(e)},hn=()=>{try{return Nt()||ti()||Ns()}catch(n){Te.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${n}`);return}},Rs=n=>{var e,t;return(t=(e=hn())===null||e===void 0?void 0:e.emulatorHosts)===null||t===void 0?void 0:t[n]},ni=n=>{const e=Rs(n);if(!e)return;const t=e.lastIndexOf(":");if(t<=0||t+1===e.length)throw new Error(`Invalid host ${e}
91 with no separate hostname and port!`);const i=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),i]:[e.substring(0,t),i]},la=()=>{var n;return(n=hn())===null||n===void 0?void 0:n.config},Os=n=>{var e;return(e=hn())===null||e===void 0?void 0:e[`_${n}`]};/** 92 * @license 93 * Copyright 2017 Google LLC 94 * 95 * Licensed under the Apache License, Version 2.0 (the "License"); 96 * you may not use this file except in compliance with the License. 97 * You may obtain a copy of the License at 98 * 99 * http://www.apache.org/licenses/LICENSE-2.0 100 * 101 * Unless required by applicable law or agreed to in writing, software 102 * distributed under the License is distributed on an "AS IS" BASIS, 103 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 104 * See the License for the specific language governing permissions and 105 * limitations under the License. 106 */class q{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,i)=>{t?this.reject(t):this.resolve(i),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,i))}}}/** 107 * @license 108 * Copyright 2021 Google LLC 109 * 110 * Licensed under the Apache License, Version 2.0 (the "License"); 111 * you may not use this file except in compliance with the License. 112 * You may obtain a copy of the License at 113 * 114 * http://www.apache.org/licenses/LICENSE-2.0 115 * 116 * Unless required by applicable law or agreed to in writing, software 117 * distributed under the License is distributed on an "AS IS" BASIS, 118 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 119 * See the License for the specific language governing permissions and 120 * limitations under the License. 121 */function ii(n,e){if(n.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const t={alg:"none",type:"JWT"},i=e||"demo-project",s=n.iat||0,r=n.sub||n.user_id;if(!r)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const o=Object.assign({iss:`https://securetoken.google.com/${i}`,aud:i,iat:s,exp:s+3600,auth_time:s,sub:r,user_id:r,firebase:{sign_in_provider:"custom",identities:{}}},n),a="";return[xe(JSON.stringify(t)),xe(JSON.stringify(o)),a].join(".")}/** 122 * @license 123 * Copyright 2017 Google LLC 124 * 125 * Licensed under the Apache License, Version 2.0 (the "License"); 126 * you may not use this file except in compliance with the License. 127 * You may obtain a copy of the License at 128 * 129 * http://www.apache.org/licenses/LICENSE-2.0 130 * 131 * Unless required by applicable law or agreed to in writing, software 132 * distributed under the License is distributed on an "AS IS" BASIS, 133 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 134 * See the License for the specific language governing permissions and 135 * limitations under the License. 136 */const si="FirebaseError";class Rt extends Error{constructor(e,t,i){super(t),this.code=e,this.customData=i,this.name=si,Object.setPrototypeOf(this,Rt.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,un.prototype.create)}}class un{constructor(e,t,i){this.service=e,this.serviceName=t,this.errors=i}create(e,...t){const i=t[0]||{},s=`${this.service}/${e}`,r=this.errors[e],o=r?Ps(r,i):"Error",a=`${this.serviceName}: ${o} (${s}).`;return new Rt(s,a,i)}}function Ps(n,e){return n.replace(dt,(t,i)=>{const s=e[i];return s!=null?String(s):`<${i}?>`})}const dt=/\{\$([^}]+)}/g;/** 137 * @license 138 * Copyright 2017 Google LLC 139 * 140 * Licensed under the Apache License, Version 2.0 (the "License"); 141 * you may not use this file except in compliance with the License. 142 * You may obtain a copy of the License at 143 * 144 * http://www.apache.org/licenses/LICENSE-2.0 145 * 146 * Unless required by applicable law or agreed to in writing, software 147 * distributed under the License is distributed on an "AS IS" BASIS, 148 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 149 * See the License for the specific language governing permissions and 150 * limitations under the License. 151 */function ft(n){return JSON.parse(n)}function j(n){return JSON.stringify(n)}/** 152 * @license 153 * Copyright 2017 Google LLC 154 * 155 * Licensed under the Apache License, Version 2.0 (the "License");
156 * you may not use this file except in compliance with the License. 157 * You may obtain a copy of the License at 158 * 159 * http://www.apache.org/licenses/LICENSE-2.0 160 * 161 * Unless required by applicable law or agreed to in writing, software 162 * distributed under the License is distributed on an "AS IS" BASIS, 163 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 164 * See the License for the specific language governing permissions and 165 * limitations under the License. 166 */const Ot=function(n){let e={},t={},i={},s="";try{const r=n.split(".");e=ft(he(r[0])||""),t=ft(he(r[1])||""),s=r[2],i=t.d||{},delete t.d}catch{}return{header:e,claims:t,data:i,signature:s}},ca=function(n){const e=Ot(n).claims,t=Math.floor(new Date().getTime()/1e3);let i=0,s=0;return typeof e=="object"&&(e.hasOwnProperty("nbf")?i=e.nbf:e.hasOwnProperty("iat")&&(i=e.iat),e.hasOwnProperty("exp")?s=e.exp:s=i+86400),!!t&&!!i&&!!s&&t>=i&&t<=s},ha=function(n){const e=Ot(n).claims;return typeof e=="object"&&e.hasOwnProperty("iat")?e.iat:null},ks=function(n){const e=Ot(n),t=e.claims;return!!t&&typeof t=="object"&&t.hasOwnProperty("iat")},Ds=function(n){const e=Ot(n).claims;return typeof e=="object"&&e.admin===!0};/** 167 * @license 168 * Copyright 2017 Google LLC 169 * 170 * Licensed under the Apache License, Version 2.0 (the "License"); 171 * you may not use this file except in compliance with the License. 172 * You may obtain a copy of the License at 173 * 174 * http://www.apache.org/licenses/LICENSE-2.0 175 * 176 * Unless required by applicable law or agreed to in writing, software 177 * distributed under the License is distributed on an "AS IS" BASIS, 178 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 179 * See the License for the specific language governing permissions and 180 * limitations under the License. 181 */function de(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function ke(n,e){if(Object.prototype.hasOwnProperty.call(n,e))return n[e]}function _t(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function Pt(n,e,t){const i={};for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=e.call(t,n[s],s,n));return i}function Ms(n,e){if(n===e)return!0;const t=Object.keys(n),i=Object.keys(e);for(const s of t){if(!i.includes(s))return!1;const r=n[s],o=e[s];if(ri(r)&&ri(o)){if(!Ms(r,o))return!1}else if(r!==o)return!1}for(const s of i)if(!t.includes(s))return!1;return!0}function ri(n){return n!==null&&typeof n=="object"}/** 182 * @license 183 * Copyright 2022 Google LLC 184 * 185 * Licensed under the Apache License, Version 2.0 (the "License"); 186 * you may not use this file except in compliance with the License. 187 * You may obtain a copy of the License at 188 * 189 * http://www.apache.org/licenses/LICENSE-2.0 190 * 191 * Unless required by applicable law or agreed to in writing, software 192 * distributed under the License is distributed on an "AS IS" BASIS, 193 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 194 * See the License for the specific language governing permissions and 195 * limitations under the License. 196 */function ua(n,e=2e3){const t=new q;return setTimeout(()=>t.reject("timeout!"),e),n.then(t.resolve,t.reject),t.promise}/** 197 * @license 198 * Copyright 2017 Google LLC 199 * 200 * Licensed under the Apache License, Version 2.0 (the "License"); 201 * you may not use this file except in compliance with the License. 202 * You may obtain a copy of the License at 203 * 204 * http://www.apache.org/licenses/LICENSE-2.0 205 * 206 * Unless required by applicable law or agreed to in writing, software 207 * distributed under the License is distributed on an "AS IS" BASIS, 208 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 209 * See the License for the specific language governing permissions and 210 * limitations under the License. 211 */function Ls(n){const e=[];for(const[t,i]of Object.entries(n))Array.isArray(i)?i.forEach(s=>{e.push(encodeURIComponent(t)+"="+encodeURIComponent(s))}):e.push(encodeURIComponent(t)+"="+encodeURIComponent(i));return e.length?"&"+e.join("&"):""}function da(n){const e={};return n.replace(/^\?/,"").split("&").forEach(i=>
211{if(i){const[s,r]=i.split("=");e[decodeURIComponent(s)]=decodeURIComponent(r)}}),e}function Fs(n){const e=n.indexOf("?");if(!e)return"";const t=n.indexOf("#",e);return n.substring(e,t>0?t:void 0)}/** 212 * @license 213 * Copyright 2017 Google LLC 214 * 215 * Licensed under the Apache License, Version 2.0 (the "License"); 216 * you may not use this file except in compliance with the License. 217 * You may obtain a copy of the License at 218 * 219 * http://www.apache.org/licenses/LICENSE-2.0 220 * 221 * Unless required by applicable law or agreed to in writing, software 222 * distributed under the License is distributed on an "AS IS" BASIS, 223 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 224 * See the License for the specific language governing permissions and 225 * limitations under the License. 226 */class Bs{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=512/8,this.pad_[0]=128;for(let e=1;e<this.blockSize;++e)this.pad_[e]=0;this.reset()}reset(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0}compress_(e,t){t||(t=0);const i=this.W_;if(typeof e=="string")for(let f=0;f<16;f++)i[f]=e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3),t+=4;else for(let f=0;f<16;f++)i[f]=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3],t+=4;for(let f=16;f<80;f++){const m=i[f-3]^i[f-8]^i[f-14]^i[f-16];i[f]=(m<<1|m>>>31)&4294967295}let s=this.chain_[0],r=this.chain_[1],o=this.chain_[2],a=this.chain_[3],c=this.chain_[4],h,p;for(let f=0;f<80;f++){f<40?f<20?(h=a^r&(o^a),p=1518500249):(h=r^o^a,p=1859775393):f<60?(h=r&o|a&(r|o),p=2400959708):(h=r^o^a,p=3395469782);const m=(s<<5|s>>>27)+h+c+p+i[f]&4294967295;c=a,a=o,o=(r<<30|r>>>2)&4294967295,r=s,s=m}this.chain_[0]=this.chain_[0]+s&4294967295,this.chain_[1]=this.chain_[1]+r&4294967295,this.chain_[2]=this.chain_[2]+o&4294967295,this.chain_[3]=this.chain_[3]+a&4294967295,this.chain_[4]=this.chain_[4]+c&4294967295}update(e,t){if(e==null)return;t===void 0&&(t=e.length);const i=t-this.blockSize;let s=0;const r=this.buf_;let o=this.inbuf_;for(;s<t;){if(o===0)for(;s<=i;)this.compress_(e,s),s+=this.blockSize;if(typeof e=="string"){for(;s<t;)if(r[o]=e.charCodeAt(s),++o,++s,o===this.blockSize){this.compress_(r),o=0;break}}else for(;s<t;)if(r[o]=e[s],++o,++s,o===this.blockSize){this.compress_(r),o=0;break}}this.inbuf_=o,this.total_+=t}digest(){const e=[];let t=this.total_*8;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let s=this.blockSize-1;s>=56;s--)this.buf_[s]=t&255,t/=256;this.compress_(this.buf_);let i=0;for(let s=0;s<5;s++)for(let r=24;r>=0;r-=8)e[i]=this.chain_[s]>>r&255,++i;return e}}function Ws(n,e){const t=new kt(n,e);return t.subscribe.bind(t)}class kt{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(i=>{this.error(i)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,i){let s;if(e===void 0&&t===void 0&&i===void 0)throw new Error("Missing Observer.");Dt(e,["next","error","complete"])?s=e:s={next:e,error:t,complete:i},s.next===void 0&&(s.next=dn),s.error===void 0&&(s.error=dn),s.complete===void 0&&(s.complete=dn);const r=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?s.error(this.finalError):s.complete()}catch{}}),this.observers.push(s),r}unsubscribeOne(e){this.observers===void 0||this.observers[e]===void 0||(delete this.observers[e],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>{if(this.observers!==void 0&&this.observers[e]!==void 0)try{t(this.observers[e])}catch(i){typeof Te<"u"&&Te.error&&Te.error(i)}})}close(e){this.finalized||(this.finalized=!0,e!==void 0&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function fa(n,e){return(...t)=>{Promise.resolve(!0).then(()=>{n(...t)}).catch(i=>{e&&e(i)})}}function Dt(n,e){if(typeof n!="object"||n===null)return!1;for(const t of e)if(t in n&&typeof n[t]=="function")return!0;return!1}function dn(){}/** 227 * @license 228 * Copyright 2017 Google LLC 229 * 230 * Licensed under the Apache License, Version 2.0 (the "License");
231 * you may not use this file except in compliance with the License. 232 * You may obtain a copy of the License at 233 * 234 * http://www.apache.org/licenses/LICENSE-2.0 235 * 236 * Unless required by applicable law or agreed to in writing, software 237 * distributed under the License is distributed on an "AS IS" BASIS, 238 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 239 * See the License for the specific language governing permissions and 240 * limitations under the License. 241 */const _a=function(n,e,t,i){let s;if(i<e?s="at least "+e:i>t&&(s=t===0?"none":"no more than "+t),s){const r=n+" failed: Was called with "+i+(i===1?" argument.":" arguments.")+" Expects "+s+".";throw new Error(r)}};function ve(n,e){return`${n} failed: ${e} argument `}function pa(n,e,t){if(!(t&&!e)&&typeof e!="string")throw new Error(ve(n,"namespace")+"must be a valid firebase namespace.")}function ga(n,e,t,i){if(!(i&&!t)&&typeof t!="function")throw new Error(ve(n,e)+"must be a valid function.")}function ma(n,e,t,i){if(!(i&&!t)&&(typeof t!="object"||t===null))throw new Error(ve(n,e)+"must be a valid context object.")}/** 242 * @license 243 * Copyright 2017 Google LLC 244 * 245 * Licensed under the Apache License, Version 2.0 (the "License"); 246 * you may not use this file except in compliance with the License. 247 * You may obtain a copy of the License at 248 * 249 * http://www.apache.org/licenses/LICENSE-2.0 250 * 251 * Unless required by applicable law or agreed to in writing, software 252 * distributed under the License is distributed on an "AS IS" BASIS, 253 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 254 * See the License for the specific language governing permissions and 255 * limitations under the License. 256 */const oi=function(n){const e=[];let t=0;for(let i=0;i<n.length;i++){let s=n.charCodeAt(i);if(s>=55296&&s<=56319){const r=s-55296;i++,y(i<n.length,"Surrogate pair missing trail surrogate.");const o=n.charCodeAt(i)-56320;s=65536+(r<<10)+o}s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):s<65536?(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128)}return e},pt=function(n){let e=0;for(let t=0;t<n.length;t++){const i=n.charCodeAt(t);i<128?e++:i<2048?e+=2:i>=55296&&i<=56319?(e+=4,t++):e+=3}return e};/** 257 * @license 258 * Copyright 2022 Google LLC 259 * 260 * Licensed under the Apache License, Version 2.0 (the "License"); 261 * you may not use this file except in compliance with the License. 262 * You may obtain a copy of the License at 263 * 264 * http://www.apache.org/licenses/LICENSE-2.0 265 * 266 * Unless required by applicable law or agreed to in writing, software 267 * distributed under the License is distributed on an "AS IS" BASIS, 268 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 269 * See the License for the specific language governing permissions and 270 * limitations under the License. 271 */const Us=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)})};/** 272 * @license 273 * Copyright 2019 Google LLC 274 * 275 * Licensed under the Apache License, Version 2.0 (the "License"); 276 * you may not use this file except in compliance with the License. 277 * You may obtain a copy of the License at 278 * 279 * http://www.apache.org/licenses/LICENSE-2.0 280 * 281 * Unless required by applicable law or agreed to in writing, software 282 * distributed under the License is distributed on an "AS IS" BASIS, 283 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 284 * See the License for the specific language governing permissions and 285 * limitations under the License. 286 */const ai=1e3,Vs=2,js=null,li=.5;function ya(n,e=ai,t=Vs){const i=e*Math.pow(t,n),s=Math.round(li*i*(Math.random()-.5)*2);return Math.min(js,i+s)}/** 287 * @license 288 * Copyright 2020 Google LLC 289 * 290 * Licensed under the Apache License, Version 2.0 (the "License"); 291 * you may not use this file except in compliance with the License. 292 * You may obtain a copy of the License at 293 * 294 * http://www.apache.org/licenses/LICENSE-2.0 295 * 296 * Unless required by applicable law or agreed to in writing, softw
296are 297 * distributed under the License is distributed on an "AS IS" BASIS, 298 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 299 * See the License for the specific language governing permissions and 300 * limitations under the License. 301 */function Hs(n){return Number.isFinite(n)?n+De(n):`${n}`}function De(n){n=Math.abs(n);const e=n%100;if(e>=10&&e<=20)return"th";const t=n%10;return t===1?"st":t===2?"nd":t===3?"rd":"th"}/** 302 * @license 303 * Copyright 2021 Google LLC 304 * 305 * Licensed under the Apache License, Version 2.0 (the "License"); 306 * you may not use this file except in compliance with the License. 307 * You may obtain a copy of the License at 308 * 309 * http://www.apache.org/licenses/LICENSE-2.0 310 * 311 * Unless required by applicable law or agreed to in writing, software 312 * distributed under the License is distributed on an "AS IS" BASIS, 313 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 314 * See the License for the specific language governing permissions and 315 * limitations under the License. 316 */function X(n){return n&&n._delegate?n._delegate:n}var Mt=L(790938),Ze=L(288538),ci=L(80247);const d="@firebase/database",l="0.13.10";/** 317 * @license 318 * Copyright 2019 Google LLC 319 * 320 * Licensed under the Apache License, Version 2.0 (the "License"); 321 * you may not use this file except in compliance with the License. 322 * You may obtain a copy of the License at 323 * 324 * http://www.apache.org/licenses/LICENSE-2.0 325 * 326 * Unless required by applicable law or agreed to in writing, software 327 * distributed under the License is distributed on an "AS IS" BASIS, 328 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 329 * See the License for the specific language governing permissions and 330 * limitations under the License. 331 */let u="";function g(n){u=n}/** 332 * @license 333 * Copyright 2017 Google LLC 334 * 335 * Licensed under the Apache License, Version 2.0 (the "License"); 336 * you may not use this file except in compliance with the License. 337 * You may obtain a copy of the License at 338 * 339 * http://www.apache.org/licenses/LICENSE-2.0 340 * 341 * Unless required by applicable law or agreed to in writing, software 342 * distributed under the License is distributed on an "AS IS" BASIS, 343 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 344 * See the License for the specific language governing permissions and 345 * limitations under the License. 346 */class _{constructor(e){this.domStorage_=e,this.prefix_="firebase:"}set(e,t){t==null?this.domStorage_.removeItem(this.prefixedName_(e)):this.domStorage_.setItem(this.prefixedName_(e),j(t))}get(e){const t=this.domStorage_.getItem(this.prefixedName_(e));return t==null?null:ft(t)}remove(e){this.domStorage_.removeItem(this.prefixedName_(e))}prefixedName_(e){return this.prefix_+e}toString(){return this.domStorage_.toString()}}/** 347 * @license 348 * Copyright 2017 Google LLC 349 * 350 * Licensed under the Apache License, Version 2.0 (the "License"); 351 * you may not use this file except in compliance with the License. 352 * You may obtain a copy of the License at 353 * 354 * http://www.apache.org/licenses/LICENSE-2.0 355 * 356 * Unless required by applicable law or agreed to in writing, software 357 * distributed under the License is distributed on an "AS IS" BASIS, 358 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 359 * See the License for the specific language governing permissions and 360 * limitations under the License. 361 */class E{constructor(){this.cache_={},this.isInMemoryStorage=!0}set(e,t){t==null?delete this.cache_[e]:this.cache_[e]=t}get(e){return de(this.cache_,e)?this.cache_[e]:null}remove(e){delete this.cache_[e]}}/** 362 * @license 363 * Copyright 2017 Google LLC 364 * 365 * Licensed under the Apache License, Version 2.0 (the "License"); 366 * you may not use this file except in compliance with the License. 367 * You may obtain a copy of the License at 368 * 369 * http://www.apache.org/licenses/LICENSE-2.0 370 * 371 * Unless required by applicable law or agreed to in writing, software 372 * distributed under the License is distributed on an "AS IS" BASIS, 373 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 374 * See the License for the specific language governing permissions and 375 * limitations under the License. 376 */const S=function(n){try{if(typeof window<"u"&&typeof window[n]<"u"){const e=window[n];return e.setItem("firebase:sentinel","cache"),e.removeItem("firebase:sentinel"),new _(e)}}catch{}return new E},O=S("localStorage"),te=S("sessionStorage");/** 377 * @license 378 * Copyright 2017 Google LLC 379 * 380 * Licensed under the Apache License, Version 2.0 (the "License");
381 * you may not use this file except in compliance with the License. 382 * You may obtain a copy of the License at 383 * 384 * http://www.apache.org/licenses/LICENSE-2.0 385 * 386 * Unless required by applicable law or agreed to in writing, software 387 * distributed under the License is distributed on an "AS IS" BASIS, 388 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 389 * See the License for the specific language governing permissions and 390 * limitations under the License. 391 */const H=new Mt.Vy("@firebase/database"),Ee=function(){let n=1;return function(){return n++}}(),P=function(n){const e=oi(n),t=new Bs;t.update(e);const i=t.digest();return D.encodeByteArray(i)},ne=function(...n){let e="";for(let t=0;t<n.length;t++){const i=n[t];Array.isArray(i)||i&&typeof i=="object"&&typeof i.length=="number"?e+=ne.apply(null,i):typeof i=="object"?e+=j(i):e+=i,e+=" "}return e};let fe=null,fn=!0;const zs=function(n,e){y(!e||n===!0||n===!1,"Can't turn on custom loggers persistently."),n===!0?(H.logLevel=Mt.$b.VERBOSE,fe=H.log.bind(H),e&&te.set("logging_enabled",!0)):typeof n=="function"?fe=n:(fe=null,te.remove("logging_enabled"))},z=function(...n){if(fn===!0&&(fn=!1,fe===null&&te.get("logging_enabled")===!0&&zs(!0)),fe){const e=ne.apply(null,n);fe(e)}},Lt=function(n){return function(...e){z(n,...e)}},hi=function(...n){const e="FIREBASE INTERNAL ERROR: "+ne(...n);H.error(e)},Ae=function(...n){const e=`FIREBASE FATAL ERROR: ${ne(...n)}`;throw H.error(e),new Error(e)},Z=function(...n){const e="FIREBASE WARNING: "+ne(...n);H.warn(e)},va=function(){typeof window<"u"&&window.location&&window.location.protocol&&window.location.protocol.indexOf("https:")!==-1&&Z("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().")},_n=function(n){return typeof n=="number"&&(n!==n||n===Number.POSITIVE_INFINITY||n===Number.NEGATIVE_INFINITY)},Ea=function(n){if(Ie()||document.readyState==="complete")n();else{let e=!1;const t=function(){if(!document.body){setTimeout(t,Math.floor(10));return}e||(e=!0,n())};document.addEventListener?(document.addEventListener("DOMContentLoaded",t,!1),window.addEventListener("load",t,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",()=>{document.readyState==="complete"&&t()}),window.attachEvent("onload",t))}},Me="[MIN_NAME]",Ne="[MAX_NAME]",et=function(n,e){if(n===e)return 0;if(n===Me||e===Ne)return-1;if(e===Me||n===Ne)return 1;{const t=pn(n),i=pn(e);return t!==null?i!==null?t-i===0?n.length-e.length:t-i:-1:i!==null?1:n<e?-1:1}},Ca=function(n,e){return n===e?0:n<e?-1:1},Ft=function(n,e){if(e&&n in e)return e[n];throw new Error("Missing required key ("+n+") in object: "+j(e))},ui=function(n){if(typeof n!="object"||n===null)return j(n);const e=[];for(const i in n)e.push(i);e.sort();let t="{";for(let i=0;i<e.length;i++)i!==0&&(t+=","),t+=j(e[i]),t+=":",t+=ui(n[e[i]]);return t+="}",t},Gs=function(n,e){const t=n.length;if(t<=e)return[n];const i=[];for(let s=0;s<t;s+=e)s+e>t?i.push(n.substring(s,t)):i.push(n.substring(s,s+e));return i};function G(n,e){for(const t in n)n.hasOwnProperty(t)&&e(t,n[t])}const Qs=function(n){y(!_n(n),"Invalid JSON number");const e=11,t=52,i=(1<<e-1)-1;let s,r,o,a,c;n===0?(r=0,o=0,s=1/n===-1/0?1:0):(s=n<0,n=Math.abs(n),n>=Math.pow(2,1-i)?(a=Math.min(Math.floor(Math.log(n)/Math.LN2),i),r=a+i,o=Math.round(n*Math.pow(2,t-a)-Math.pow(2,t))):(r=0,o=Math.round(n/Math.pow(2,1-i-t))));const h=[];for(c=t;c;c-=1)h.push(o%2?1:0),o=Math.floor(o/2);for(c=e;c;c-=1)h.push(r%2?1:0),r=Math.floor(r/2);h.push(s?1:0),h.reverse();const p=h.join("");let f="";for(c=0;c<64;c+=8){let m=parseInt(p.substr(c,8),2).toString(16);m.length===1&&(m="0"+m),f=f+m}return f.toLowerCase()},wa=function(){return!!(typeof window=="object"&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href))},ba=function(){return typeof Windows=="object"&&typeof Windows.UI=="object"};function Sa(n,e){let t="Unknown Error";n==="too_big"?t="The data requested exceeds the maximum size that can be accessed with a single request.":n==="permission_denied"?t="Client doesn't have permission to access the desired data.":n==="unavailable"&&(t="The service is unavailable");const i=new Error(n+" at "+e._path.toString()+": "+t);return i.code=n.toUpperCase(),i}const Ta=new RegExp("^-?(0*)\\d{1,10}$"),$s=-2147483648,di=2147483647,pn=function(n){if(Ta.test(n)){const e=Number(n);if(e>=$s&&e<=di)return e}return null},gt=function(n){try{n()}catch(e){setTimeout(()=>{const t=e.stack||"";throw Z("Exception was thrown by user callback.",t),e},Math.floor(0))}},xa=function(){return(typeof window=="object"&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)>=0},Bt=function(n,e){const t=setTimeout(n,e);return typeof t=="number"&&typeof Deno<"u"&&Deno.unrefTimer?Deno.unrefTimer(t):typeof t=="object"&&t.unref&&t.unref(),t};/** 392 * @license 393 * Copyright 2021 Google LLC 394 * 395 * Licensed under the Apache License, Version 2.0 (the "License");
396 * you may not use this file except in compliance with the License. 397 * You may obtain a copy of the License at 398 * 399 * http://www.apache.org/licenses/LICENSE-2.0 400 * 401 * Unless required by applicable law or agreed to in writing, software 402 * distributed under the License is distributed on an "AS IS" BASIS, 403 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 404 * See the License for the specific language governing permissions and 405 * limitations under the License. 406 */class Ia{constructor(e,t){this.appName_=e,this.appCheckProvider=t,this.appCheck=t?.getImmediate({optional:!0}),this.appCheck||t?.get().then(i=>this.appCheck=i)}getToken(e){return this.appCheck?this.appCheck.getToken(e):new Promise((t,i)=>{setTimeout(()=>{this.appCheck?this.getToken(e).then(t,i):t(null)},0)})}addTokenChangeListener(e){var t;(t=this.appCheckProvider)===null||t===void 0||t.get().then(i=>i.addTokenListener(e))}notifyForInvalidToken(){Z(`Provided AppCheck credentials for the app named "${this.appName_}" are invalid. This usually indicates your app was not initialized correctly.`)}}/** 407 * @license 408 * Copyright 2017 Google LLC 409 * 410 * Licensed under the Apache License, Version 2.0 (the "License"); 411 * you may not use this file except in compliance with the License. 412 * You may obtain a copy of the License at 413 * 414 * http://www.apache.org/licenses/LICENSE-2.0 415 * 416 * Unless required by applicable law or agreed to in writing, software 417 * distributed under the License is distributed on an "AS IS" BASIS, 418 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 419 * See the License for the specific language governing permissions and 420 * limitations under the License. 421 */class Aa{constructor(e,t,i){this.appName_=e,this.firebaseOptions_=t,this.authProvider_=i,this.auth_=null,this.auth_=i.getImmediate({optional:!0}),this.auth_||i.onInit(s=>this.auth_=s)}getToken(e){return this.auth_?this.auth_.getToken(e).catch(t=>t&&t.code==="auth/token-not-initialized"?(z("Got auth/token-not-initialized error. Treating as null token."),null):Promise.reject(t)):new Promise((t,i)=>{setTimeout(()=>{this.auth_?this.getToken(e).then(t,i):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/.',Z(e)}}class mt{constructor(e){this.accessToken=e}getToken(e){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(e){e(this.accessToken)}removeTokenChangeListener(e){}notifyForInvalidToken(){}}mt.OWNER="owner";/** 422 * @license 423 * Copyright 2017 Google LLC 424 * 425 * Licensed under the Apache License, Version 2.0 (the "License"); 426 * you may not use this file except in compliance with the License. 427 * You may obtain a copy of the License at 428 * 429 * http://www.apache.org/licenses/LICENSE-2.0 430 * 431 * Unless required by applicable law or agreed to in writing, software 432 * distributed under the License is distributed on an "AS IS" BASIS, 433 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 434 * See the License for the specific language governing permissions and 435 * limitations under the License. 436 */const gn="5",Ks="v",qs="s",Ys="r",Js="f",Xs=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,Zs="ls",er="p",fi="ac",tr="websocket",nr="long_polling";/** 437 * @license 438 * Copyright 2017 Google LLC 439 * 440 * Licensed under the Apache License, Version 2.0 (the "License");
441 * you may not use this file except in compliance with the License. 442 * You may obtain a copy of the License at 443 * 444 * http://www.apache.org/licenses/LICENSE-2.0 445 * 446 * Unless required by applicable law or agreed to in writing, software 447 * distributed under the License is distributed on an "AS IS" BASIS, 448 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 449 * See the License for the specific language governing permissions and 450 * limitations under the License. 451 */class _i{constructor(e,t,i,s,r=!1,o="",a=!1){this.secure=t,this.namespace=i,this.webSocketOnly=s,this.nodeAdmin=r,this.persistenceKey=o,this.includeNamespaceInQueryParams=a,this._host=e.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=O.get("host:"+e)||this._host}isCacheableHost(){return this.internalHost.substr(0,2)==="s-"}isCustomHost(){return this._domain!=="firebaseio.com"&&this._domain!=="firebaseio-demo.com"}get host(){return this._host}set host(e){e!==this.internalHost&&(this.internalHost=e,this.isCacheableHost()&&O.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=${this.namespace}`:"";return`${e}${this.host}/${t}`}}function Na(n){return n.host!==n.internalHost||n.isCustomHost()||n.includeNamespaceInQueryParams}function ir(n,e,t){y(typeof e=="string","typeof type must == string"),y(typeof t=="object","typeof params must == object");let i;if(e===tr)i=(n.secure?"wss://":"ws://")+n.internalHost+"/.ws?";else if(e===nr)i=(n.secure?"https://":"http://")+n.internalHost+"/.lp?";else throw new Error("Unknown connection type: "+e);Na(n)&&(t.ns=n.namespace);const s=[];return G(t,(r,o)=>{s.push(r+"="+o)}),i+s.join("&")}/** 452 * @license 453 * Copyright 2017 Google LLC 454 * 455 * Licensed under the Apache License, Version 2.0 (the "License"); 456 * you may not use this file except in compliance with the License. 457 * You may obtain a copy of the License at 458 * 459 * http://www.apache.org/licenses/LICENSE-2.0 460 * 461 * Unless required by applicable law or agreed to in writing, software 462 * distributed under the License is distributed on an "AS IS" BASIS, 463 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 464 * See the License for the specific language governing permissions and 465 * limitations under the License. 466 */class Ra{constructor(){this.counters_={}}incrementCounter(e,t=1){de(this.counters_,e)||(this.counters_[e]=0),this.counters_[e]+=t}get(){return ue(this.counters_)}}/** 467 * @license 468 * Copyright 2017 Google LLC 469 * 470 * Licensed under the Apache License, Version 2.0 (the "License"); 471 * you may not use this file except in compliance with the License. 472 * You may obtain a copy of the License at 473 * 474 * http://www.apache.org/licenses/LICENSE-2.0 475 * 476 * Unless required by applicable law or agreed to in writing, software 477 * distributed under the License is distributed on an "AS IS" BASIS, 478 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 479 * See the License for the specific language governing permissions and 480 * limitations under the License. 481 */const pi={},gi={};function mi(n){const e=n.toString();return pi[e]||(pi[e]=new Ra),pi[e]}function Oa(n,e){const t=n.toString();return gi[t]||(gi[t]=e()),gi[t]}/** 482 * @license 483 * Copyright 2017 Google LLC 484 * 485 * Licensed under the Apache License, Version 2.0 (the "License"); 486 * you may not use this file except in compliance with the License. 487 * You may obtain a copy of the License at 488 * 489 * http://www.apache.org/licenses/LICENSE-2.0 490 * 491 * Unless required by applicable law or agreed to in writing, software 492 * distributed under the License is distributed on an "AS IS" BASIS, 493 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 494 * See the License for the specific language governing permissions and 495 * limitations under the License. 496 */class Pa{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 i=this.pendingResponses[this.currentResponseNum];delete this.pendingResponses[this.currentResponseNum];for(let s=0;s<i.length;++s)i[s]&>(()=>{this.onMessage_(i[s])});if(this.currentResponseNum===this.closeAfterResponse){this.onClose&&(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}}/** 497 * @license 498 * Copyright 2017 Google LLC 499 * 500 * Licensed under the Apache License, Version 2.0 (the "License");
501 * you may not use this file except in compliance with the License. 502 * You may obtain a copy of the License at 503 * 504 * http://www.apache.org/licenses/LICENSE-2.0 505 * 506 * Unless required by applicable law or agreed to in writing, software 507 * distributed under the License is distributed on an "AS IS" BASIS, 508 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 509 * See the License for the specific language governing permissions and 510 * limitations under the License. 511 */const sr="start",ka="close",Da="pLPCommand",Ma="pRTLPCB",rr="id",or="pw",ar="ser",La="cb",Fa="seg",Ba="ts",Wa="d",Ua="dframe",lr=1870,cr=30,Va=lr-cr,ja=25e3,Ha=3e4;class We{constructor(e,t,i,s,r,o,a){this.connId=e,this.repoInfo=t,this.applicationId=i,this.appCheckToken=s,this.authToken=r,this.transportSessionId=o,this.lastSessionId=a,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=Lt(e),this.stats_=mi(t),this.urlFn=c=>(this.appCheckToken&&(c[fi]=this.appCheckToken),ir(t,nr,c))}open(e,t){this.curSegmentNum=0,this.onDisconnect_=t,this.myPacketOrderer=new Pa(e),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(()=>{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null},Math.floor(Ha)),Ea(()=>{if(this.isClosed_)return;this.scriptTagHolder=new yi((...r)=>{const[o,a,c,h,p]=r;if(this.incrementIncomingBytes_(r),!!this.scriptTagHolder)if(this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null),this.everConnected_=!0,o===sr)this.id=a,this.password=c;else if(o===ka)a?(this.scriptTagHolder.sendNewPolls=!1,this.myPacketOrderer.closeAfter(a,()=>{this.onClosed_()})):this.onClosed_();else throw new Error("Unrecognized command received: "+o)},(...r)=>{const[o,a]=r;this.incrementIncomingBytes_(r),this.myPacketOrderer.handleResponse(o,a)},()=>{this.onClosed_()},this.urlFn);const i={};i[sr]="t",i[ar]=Math.floor(Math.random()*1e8),this.scriptTagHolder.uniqueCallbackIdentifier&&(i[La]=this.scriptTagHolder.uniqueCallbackIdentifier),i[Ks]=gn,this.transportSessionId&&(i[qs]=this.transportSessionId),this.lastSessionId&&(i[Zs]=this.lastSessionId),this.applicationId&&(i[er]=this.applicationId),this.appCheckToken&&(i[fi]=this.appCheckToken),typeof location<"u"&&location.hostname&&Xs.test(location.hostname)&&(i[Ys]=Js);const s=this.urlFn(i);this.log_("Connecting via long-poll to "+s),this.scriptTagHolder.addTag(s,()=>{})})}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){We.forceAllow_=!0}static forceDisallow(){We.forceDisallow_=!0}static isAvailable(){return Ie()?!1:We.forceAllow_?!0:!We.forceDisallow_&&typeof document<"u"&&document.createElement!=null&&!wa()&&!ba()}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=j(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const i=T(t),s=Gs(i,Va);for(let r=0;r<s.length;r++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,s.length,s[r]),this.curSegmentNum++}addDisconnectPingFrame(e,t){if(Ie())return;this.myDisconnFrame=document.createElement("iframe");const i={};i[Ua]="t",i[rr]=e,i[or]=t,this.myDisconnFrame.src=this.urlFn(i),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}incrementIncomingBytes_(e){const t=j(e).length;this.bytesReceived+=t,this.stats_.incrementCounter("bytes_received",t)}}class yi{constructor(e,t,i,s){if(this.onDisconnect=i,this.urlFn=s,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(Math.random()*1e8),this.sendNewPolls=!0,Ie())this.commandCB=e,this.onMessageCB=t;else{this.uniqueCallbackIdentifier=Ee(),window[Da+this.uniqueCallbackIdentifier]=e,window[Ma+this.uniqueCallbackIdentifier]=t,this.myIFrame=yi.createIFrame_();let r="";this.myIFrame.src&&this.myIFrame.src.substr(0,11)==="javascript:"&&(r='<script>document.domain="'+document.domain+'";<\/script>');const o="<html><body>"+r+"</body></html>";
511try{this.myIFrame.doc.open(),this.myIFrame.doc.write(o),this.myIFrame.doc.close()}catch(a){z("frame writing exception"),a.stack&&z(a.stack),z(a)}}}static createIFrame_(){const e=document.createElement("iframe");if(e.style.display="none",document.body){document.body.appendChild(e);try{e.contentWindow.document||z("No IE domain setting required")}catch{const i=document.domain;e.src="javascript:void((function(){document.open();document.domain='"+i+"';document.close();})())"}}else throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";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(()=>{this.myIFrame!==null&&(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[rr]=this.myID,e[or]=this.myPW,e[ar]=this.currentSerial;let t=this.urlFn(e),i="",s=0;for(;this.pendingSegs.length>0&&this.pendingSegs[0].d.length+cr+i.length<=lr;){const o=this.pendingSegs.shift();i=i+"&"+Fa+s+"="+o.seg+"&"+Ba+s+"="+o.ts+"&"+Wa+s+"="+o.d,s++}return t=t+i,this.addLongPollTag_(t,this.currentSerial),!0}else return!1}enqueueSegment(e,t,i){this.pendingSegs.push({seg:e,ts:t,d:i}),this.alive&&this.newRequest_()}addLongPollTag_(e,t){this.outstandingRequests.add(t);const i=()=>{this.outstandingRequests.delete(t),this.newRequest_()},s=setTimeout(i,Math.floor(ja)),r=()=>{clearTimeout(s),i()};this.addTag(e,r)}addTag(e,t){Ie()?this.doNodeLongPoll(e,t):setTimeout(()=>{try{if(!this.sendNewPolls)return;const i=this.myIFrame.doc.createElement("script");i.type="text/javascript",i.async=!0,i.src=e,i.onload=i.onreadystatechange=function(){const s=i.readyState;(!s||s==="loaded"||s==="complete")&&(i.onload=i.onreadystatechange=null,i.parentNode&&i.parentNode.removeChild(i),t())},i.onerror=()=>{z("Long-poll script failed to load: "+e),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(i)}catch{}},Math.floor(1))}}/** 512 * @license 513 * Copyright 2017 Google LLC 514 * 515 * Licensed under the Apache License, Version 2.0 (the "License"); 516 * you may not use this file except in compliance with the License. 517 * You may obtain a copy of the License at 518 * 519 * http://www.apache.org/licenses/LICENSE-2.0 520 * 521 * Unless required by applicable law or agreed to in writing, software 522 * distributed under the License is distributed on an "AS IS" BASIS, 523 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 524 * See the License for the specific language governing permissions and 525 * limitations under the License. 526 */const za=16384,Ga=45e3;let mn=null;typeof MozWebSocket<"u"?mn=MozWebSocket:typeof WebSocket<"u"&&(mn=WebSocket);class _e{constructor(e,t,i,s,r,o,a){this.connId=e,this.applicationId=i,this.appCheckToken=s,this.authToken=r,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=Lt(this.connId),this.stats_=mi(t),this.connURL=_e.connectionURL_(t,o,a,s,i),this.nodeAdmin=t.nodeAdmin}static connectionURL_(e,t,i,s,r){const o={};return o[Ks]=gn,!Ie()&&typeof location<"u"&&location.hostname&&Xs.test(location.hostname)&&(o[Ys]=Js),t&&(o[qs]=t),i&&(o[Zs]=i),s&&(o[fi]=s),r&&(o[er]=r),ir(e,tr,o)}open(e,t){this.onDisconnect=t,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,O.set("previous_websocket_failure",!0);try{let i;if(Ie()){const s=this.nodeAdmin?"AdminNode":"Node";i={headers:{"User-Agent":`Firebase/${gn}/${u}/${Ze.platform}/${s}`,"X-Firebase-GMPID":this.applicationId||""}},this.authToken&&(i.headers.Authorization=`Bearer ${this.authToken}`),this.appCheckToken&&(i.headers["X-Firebase-AppCheck"]=this.appCheckToken);const r=Ze.env,o=this.connURL.indexOf("wss://")===0?r.HTTPS_PROXY||r.https_proxy:r.HTTP_PROXY||r.http_proxy;o&&(i.proxy={origin:o})}this.mySock=new mn(this.connURL,[],i)}catch(i){this.log_("Error instantiating WebSocket.");const s=i.message||i.data;s&&this.log_(s),this.onClosed_();return}this.mySock.onopen=()=>{this.log_("Websocket connected."),this.everConnected_=!0}
526,this.mySock.onclose=()=>{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()},this.mySock.onmessage=i=>{this.handleIncomingFrame(i)},this.mySock.onerror=i=>{this.log_("WebSocket error. Closing connection.");const s=i.message||i.data;s&&this.log_(s),this.onClosed_()}}start(){}static forceDisallow(){_e.forceDisallow_=!0}static isAvailable(){let e=!1;if(typeof navigator<"u"&&navigator.userAgent){const t=/Android ([0-9]{0,}\.[0-9]{0,})/,i=navigator.userAgent.match(t);i&&i.length>1&&parseFloat(i[1])<4.4&&(e=!0)}return!e&&mn!==null&&!_e.forceDisallow_}static previouslyFailed(){return O.isInMemoryStorage||O.get("previous_websocket_failure")===!0}markConnectionHealthy(){O.remove("previous_websocket_failure")}appendFrame_(e){if(this.frames.push(e),this.frames.length===this.totalFrames){const t=this.frames.join("");this.frames=null;const i=ft(t);this.onMessage(i)}}handleNewFrameCount_(e){this.totalFrames=e,this.frames=[]}extractFrameCount_(e){if(y(this.frames===null,"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(this.mySock===null)return;const t=e.data;if(this.bytesReceived+=t.length,this.stats_.incrementCounter("bytes_received",t.length),this.resetKeepAlive(),this.frames!==null)this.appendFrame_(t);else{const i=this.extractFrameCount_(t);i!==null&&this.appendFrame_(i)}}send(e){this.resetKeepAlive();const t=j(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const i=Gs(t,za);i.length>1&&this.sendString_(String(i.length));for(let s=0;s<i.length;s++)this.sendString_(i[s])}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(Ga))}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)}}}_e.responsesRequiredToBeHealthy=2,_e.healthyTimeout=3e4;/** 527 * @license 528 * Copyright 2017 Google LLC 529 * 530 * Licensed under the Apache License, Version 2.0 (the "License"); 531 * you may not use this file except in compliance with the License. 532 * You may obtain a copy of the License at 533 * 534 * http://www.apache.org/licenses/LICENSE-2.0 535 * 536 * Unless required by applicable law or agreed to in writing, software 537 * distributed under the License is distributed on an "AS IS" BASIS, 538 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 539 * See the License for the specific language governing permissions and 540 * limitations under the License. 541 */class yt{constructor(e){this.initTransports_(e)}static get ALL_TRANSPORTS(){return[We,_e]}static get IS_TRANSPORT_INITIALIZED(){return this.globalTransportInitialized_}initTransports_(e){const t=_e&&_e.isAvailable();let i=t&&!_e.previouslyFailed();if(e.webSocketOnly&&(t||Z("wss:// URL used, but browser isn't known to support websockets. Trying anyway."),i=!0),i)this.transports_=[_e];else{const s=this.transports_=[];for(const r of yt.ALL_TRANSPORTS)r&&r.isAvailable()&&s.push(r);yt.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}}yt.globalTransportInitialized_=!1;/** 542 * @license 543 * Copyright 2017 Google LLC 544 * 545 * Licensed under the Apache License, Version 2.0 (the "License"); 546 * you may not use this file except in compliance with the License. 547 * You may obtain a copy of the License at 548 * 549 * http://www.apache.org/licenses/LICENSE-2.0 550 * 551 * Unless required by applicable law or agreed to in writing, softw
551are 552 * distributed under the License is distributed on an "AS IS" BASIS, 553 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 554 * See the License for the specific language governing permissions and 555 * limitations under the License. 556 */const Qa=6e4,$a=5e3,Ka=10*1024,qa=100*1024,vi="t",hr="d",Ya="s",ur="r",Ja="e",dr="o",fr="a",_r="n",pr="p",Xa="h";class gr{constructor(e,t,i,s,r,o,a,c,h,p){this.id=e,this.repoInfo_=t,this.applicationId_=i,this.appCheckToken_=s,this.authToken_=r,this.onMessage_=o,this.onReady_=a,this.onDisconnect_=c,this.onKill_=h,this.lastSessionId=p,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=Lt("c:"+this.id+":"),this.transportManager_=new yt(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_),i=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,i)},Math.floor(0));const s=e.healthyTimeout||0;s>0&&(this.healthyTimeout_=Bt(()=>{this.healthyTimeout_=null,this.isHealthy_||(this.conn_&&this.conn_.bytesReceived>qa?(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>Ka?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(s)))}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=>{this.state_!==2&&(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(vi in e){const t=e[vi];t===fr?this.upgradeIfSecondaryHealthy_():t===ur?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),(this.tx_===this.secondaryConn_||this.rx_===this.secondaryConn_)&&this.close()):t===dr&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}}onSecondaryMessageReceived_(e){const t=Ft("t",e),i=Ft("d",e);if(t==="c")this.onSecondaryControl_(i);else if(t==="d")this.pendingDataMessages.push(i);else throw new Error("Unknown protocol layer: "+t)}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:pr,d:{}}}))}proceedWithUpgrade_(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:fr,d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:_r,d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()}onPrimaryMessageReceived_(e){const t=Ft("t",e),i=Ft("d",e);t==="c"?this.onControl_(i):t==="d"&&this.onDataMessage_(i)}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=Ft(vi,e);
vendor: 4,229 bytes, lines 556-581
556if(hr in e){const i=e[hr];if(t===Xa)this.onHandshake_(i);else if(t===_r){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(let s=0;s<this.pendingDataMessages.length;++s)this.onDataMessage_(this.pendingDataMessages[s]);this.pendingDataMessages=[],this.tryCleanupConnection()}else t===Ya?this.onConnectionShutdown_(i):t===ur?this.onReset_(i):t===Ja?hi("Server Error: "+i):t===dr?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):hi("Unknown control packet command: "+t)}}onHandshake_(e){const t=e.ts,i=e.v,s=e.h;this.sessionId=e.s,this.repoInfo_.host=s,this.state_===0&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,t),gn!==i&&Z("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_),i=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(t,i),Bt(()=>{this.secondaryConn_&&(this.log_("Timed out trying to upgrade."),this.secondaryConn_.close())},Math.floor(Qa))}onReset_(e){this.log_("Reset packet received. New host: "+e),this.repoInfo_.host=e,this.state_===1?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),this.primaryResponsesRequired_===0?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):Bt(()=>{this.sendPingOnPrimaryIfNecessary_()},Math.floor($a))}sendPingOnPrimaryIfNecessary_(){!this.isHealthy_&&this.state_===1&&(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:pr,d:{}}}))}onSecondaryConnectionLost_(){const e=this.secondaryConn_;this.secondaryConn_=null,(this.tx_===e||this.rx_===e)&&this.close()}onConnectionLost_(e){this.conn_=null,!e&&this.state_===0?(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(O.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)):this.state_===1&&this.log_("Realtime connection lost."),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(this.state_!==1)throw"Connection is not connected";this.tx_.send(e)}close(){this.state_!==2&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))}closeConnections_(){this.log_("Shutting down all connections"),this.conn_&&(this.conn_.close(),this.conn_=null),this.secondaryConn_&&(this.secondaryConn_.close(),this.secondaryConn_=null),this.healthyTimeout_&&(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)}}/** 557 * @license 558 * Copyright 2017 Google LLC 559 * 560 * Licensed under the Apache License, Version 2.0 (the "License"); 561 * you may not use this file except in compliance with the License. 562 * You may obtain a copy of the License at 563 * 564 * http://www.apache.org/licenses/LICENSE-2.0 565 * 566 * Unless required by applicable law or agreed to in writing, software 567 * distributed under the License is distributed on an "AS IS" BASIS, 568 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 569 * See the License for the specific language governing permissions and 570 * limitations under the License. 571 */class mr{put(e,t,i,s){}merge(e,t,i,s){}refreshAuthToken(e){}refreshAppCheckToken(e){}onDisconnectPut(e,t,i){}onDisconnectMerge(e,t,i){}onDisconnectCancel(e,t){}reportStats(e){}}/** 572 * @license 573 * Copyright 2017 Google LLC 574 * 575 * Licensed under the Apache License, Version 2.0 (the "License"); 576 * you may not use this file except in compliance with the License. 577 * You may obtain a copy of the License at 578 * 579 * http://www.apache.org/licenses/LICENSE-2.0 580 * 581 * Unless required by applicable law or agreed to in writing, softw
581are 582 * distributed under the License is distributed on an "AS IS" BASIS, 583 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 584 * See the License for the specific language governing permissions and 585 * limitations under the License. 586 */class yr{constructor(e){this.allowedEvents_=e,this.listeners_={},y(Array.isArray(e)&&e.length>0,"Requires a non-empty array")}trigger(e,...t){if(Array.isArray(this.listeners_[e])){const i=[...this.listeners_[e]];for(let s=0;s<i.length;s++)i[s].callback.apply(i[s].context,t)}}on(e,t,i){this.validateEventType_(e),this.listeners_[e]=this.listeners_[e]||[],this.listeners_[e].push({callback:t,context:i});const s=this.getInitialEvent(e);s&&t.apply(i,s)}off(e,t,i){this.validateEventType_(e);const s=this.listeners_[e]||[];for(let r=0;r<s.length;r++)if(s[r].callback===t&&(!i||i===s[r].context)){s.splice(r,1);return}}validateEventType_(e){y(this.allowedEvents_.find(t=>t===e),"Unknown event: "+e)}}/** 587 * @license 588 * Copyright 2017 Google LLC 589 * 590 * Licensed under the Apache License, Version 2.0 (the "License"); 591 * you may not use this file except in compliance with the License. 592 * You may obtain a copy of the License at 593 * 594 * http://www.apache.org/licenses/LICENSE-2.0 595 * 596 * Unless required by applicable law or agreed to in writing, software 597 * distributed under the License is distributed on an "AS IS" BASIS, 598 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 599 * See the License for the specific language governing permissions and 600 * limitations under the License. 601 */class yn extends yr{constructor(){super(["online"]),this.online_=!0,typeof window<"u"&&typeof window.addEventListener<"u"&&!ee()&&(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 yn}getInitialEvent(e){return y(e==="online","Unknown event type: "+e),[this.online_]}currentlyOnline(){return this.online_}}/** 602 * @license 603 * Copyright 2017 Google LLC 604 * 605 * Licensed under the Apache License, Version 2.0 (the "License"); 606 * you may not use this file except in compliance with the License. 607 * You may obtain a copy of the License at 608 * 609 * http://www.apache.org/licenses/LICENSE-2.0 610 * 611 * Unless required by applicable law or agreed to in writing, software 612 * distributed under the License is distributed on an "AS IS" BASIS, 613 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 614 * See the License for the specific language governing permissions and 615 * limitations under the License. 616 */const vr=32,Er=768;class k{constructor(e,t){if(t===void 0){this.pieces_=e.split("/");let i=0;for(let s=0;s<this.pieces_.length;s++)this.pieces_[s].length>0&&(this.pieces_[i]=this.pieces_[s],i++);this.pieces_.length=i,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 R(){return new k("")}function x(n){return n.pieceNum_>=n.pieces_.length?null:n.pieces_[n.pieceNum_]}function Ue(n){return n.pieces_.length-n.pieceNum_}function F(n){let e=n.pieceNum_;return e<n.pieces_.length&&e++,new k(n.pieces_,e)}function Ei(n){return n.pieceNum_<n.pieces_.length?n.pieces_[n.pieces_.length-1]:null}function Za(n){let e="";for(let t=n.pieceNum_;t<n.pieces_.length;t++)n.pieces_[t]!==""&&(e+="/"+encodeURIComponent(String(n.pieces_[t])));return e||"/"}function Wt(n,e=0){return n.pieces_.slice(n.pieceNum_+e)}function Cr(n){if(n.pieceNum_>=n.pieces_.length)return null;const e=[];for(let t=n.pieceNum_;t<n.pieces_.length-1;t++)e.push(n.pieces_[t]);return new k(e,0)}function U(n,e){const t=[];for(let i=n.pieceNum_;i<n.pieces_.length;i++)t.push(n.pieces_[i]);if(e instanceof k)for(let i=e.pieceNum_;i<e.pieces_.length;i++)t.push(e.pieces_[i]);else{const i=e.split("/");for(let s=0;s<i.length;s++)i[s].length>0&&t.push(i[s])}return new k(t,0)}function I(n){return n.pieceNum_>=n.pieces_.length}function ie(n,e){const t=x(n),i=x(e);if(t===null)return e;if(t===i)return ie(F(n),F(e));
vendor: 12,073 bytes, lines 616-647
616throw new Error("INTERNAL ERROR: innerPath ("+e+") is not within outerPath ("+n+")")}function el(n,e){const t=Wt(n,0),i=Wt(e,0);for(let s=0;s<t.length&&s<i.length;s++){const r=et(t[s],i[s]);if(r!==0)return r}return t.length===i.length?0:t.length<i.length?-1:1}function Ci(n,e){if(Ue(n)!==Ue(e))return!1;for(let t=n.pieceNum_,i=e.pieceNum_;t<=n.pieces_.length;t++,i++)if(n.pieces_[t]!==e.pieces_[i])return!1;return!0}function pe(n,e){let t=n.pieceNum_,i=e.pieceNum_;if(Ue(n)>Ue(e))return!1;for(;t<n.pieces_.length;){if(n.pieces_[t]!==e.pieces_[i])return!1;++t,++i}return!0}class tl{constructor(e,t){this.errorPrefix_=t,this.parts_=Wt(e,0),this.byteLength_=Math.max(1,this.parts_.length);for(let i=0;i<this.parts_.length;i++)this.byteLength_+=pt(this.parts_[i]);wr(this)}}function nl(n,e){n.parts_.length>0&&(n.byteLength_+=1),n.parts_.push(e),n.byteLength_+=pt(e),wr(n)}function il(n){const e=n.parts_.pop();n.byteLength_-=pt(e),n.parts_.length>0&&(n.byteLength_-=1)}function wr(n){if(n.byteLength_>Er)throw new Error(n.errorPrefix_+"has a key path longer than "+Er+" bytes ("+n.byteLength_+").");if(n.parts_.length>vr)throw new Error(n.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+vr+") or object contains a cycle "+tt(n))}function tt(n){return n.parts_.length===0?"":"in property '"+n.parts_.join(".")+"'"}/** 617 * @license 618 * Copyright 2017 Google LLC 619 * 620 * Licensed under the Apache License, Version 2.0 (the "License"); 621 * you may not use this file except in compliance with the License. 622 * You may obtain a copy of the License at 623 * 624 * http://www.apache.org/licenses/LICENSE-2.0 625 * 626 * Unless required by applicable law or agreed to in writing, software 627 * distributed under the License is distributed on an "AS IS" BASIS, 628 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 629 * See the License for the specific language governing permissions and 630 * limitations under the License. 631 */class wi extends yr{constructor(){super(["visible"]);let e,t;typeof document<"u"&&typeof document.addEventListener<"u"&&(typeof document.hidden<"u"?(t="visibilitychange",e="hidden"):typeof document.mozHidden<"u"?(t="mozvisibilitychange",e="mozHidden"):typeof document.msHidden<"u"?(t="msvisibilitychange",e="msHidden"):typeof document.webkitHidden<"u"&&(t="webkitvisibilitychange",e="webkitHidden")),this.visible_=!0,t&&document.addEventListener(t,()=>{const i=!document[e];i!==this.visible_&&(this.visible_=i,this.trigger("visible",i))},!1)}static getInstance(){return new wi}getInitialEvent(e){return y(e==="visible","Unknown event type: "+e),[this.visible_]}}/** 632 * @license 633 * Copyright 2017 Google LLC 634 * 635 * Licensed under the Apache License, Version 2.0 (the "License"); 636 * you may not use this file except in compliance with the License. 637 * You may obtain a copy of the License at 638 * 639 * http://www.apache.org/licenses/LICENSE-2.0 640 * 641 * Unless required by applicable law or agreed to in writing, software 642 * distributed under the License is distributed on an "AS IS" BASIS, 643 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 644 * See the License for the specific language governing permissions and 645 * limitations under the License. 646 */const Ut=1e3,sl=60*5*1e3,br=30*1e3,rl=1.3,ol=3e4,al="server_kill",Sr=3;class ae extends mr{constructor(e,t,i,s,r,o,a,c){if(super(),this.repoInfo_=e,this.applicationId_=t,this.onDataUpdate_=i,this.onConnectStatus_=s,this.onServerInfoUpdate_=r,this.authTokenProvider_=o,this.appCheckTokenProvider_=a,this.authOverride_=c,this.id=ae.nextPersistentConnectionId_++,this.log_=Lt("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_=Ut,this.maxReconnectDelay_=sl,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,c&&!Ie())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");wi.getInstance().on("visible",this.onVisible_,this),e.host.indexOf("fblocal")===-1&&yn.getInstance().on("online",this.onOnline_,this)}sendRequest(e,t,i){const s=++this.requestNumber_,r={r:s,a:e,b:t};this.log_(j(r)),y(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(r),i&&(this.requestCBHash_[s]=i)}get(e){this.initConnection_();const t=new q,s={action:"g",request:{p:e._path.toString(),q:e._queryObject},onComplete:o=>{const a=o.d;o.s==="ok"?t.resolve(a):t.reject(a)}};this.outstandingGets_.push(s),this.outstandingGetCount_++;const r=this.outstandingGets_.length-1;return this.connected_&&this.sendGet_(r),t.promise}listen(e,t,i,s){this.initConnection_();const r=e._queryIdentifier,o=e._path.toString();this.log_("Listen called for "+o+" "+r),this.listens.has(o)||this.listens.set(o,new Map),y(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),y(!this.listens.get(o).has(r),"listen() called twice for same path/queryId.");const a={onComplete:s,hashFn:t,query:e,tag:i};this.listens.get(o).set(r,a),this.connected_&&this.sendListen_(a)}sendGet_(e){const t=this.outstandingGets_[e];this.sendRequest("g",t.request,i=>{delete this.outstandingGets_[e],this.outstandingGetCount_--,this.outstandingGetCount_===0&&(this.outstandingGets_=[]),t.onComplete&&t.onComplete(i)})}sendListen_(e){const t=e.query,i=t._path.toString(),s=t._queryIdentifier;this.log_("Listen on "+i+" for "+s);const r={p:i},o="q";e.tag&&(r.q=t._queryObject,r.t=e.tag),r.h=e.hashFn(),this.sendRequest(o,r,a=>{const c=a.d,h=a.s;ae.warnOnListenWarnings_(c,t),(this.listens.get(i)&&this.listens.get(i).get(s))===e&&(this.log_("listen response",a),h!=="ok"&&this.removeListen_(i,s),e.onComplete&&e.onComplete(h,c))})}static warnOnListenWarnings_(e,t){if(e&&typeof e=="object"&&de(e,"w")){const i=ke(e,"w");if(Array.isArray(i)&&~i.indexOf("no_index")){const s='".indexOn": "'+t._queryParams.getIndex().toString()+'"',r=t._path.toString();Z(`Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ${s} at ${r} to your security rules for better performance.`)}}}refreshAuthToken(e){this.authToken_=e,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},()=>{}),this.reduceReconnectDelayIfAdminCredential_(e)}reduceReconnectDelayIfAdminCredential_(e){(e&&e.length===40||Ds(e))&&(this.log_("Admin auth credential detected. Reducing max reconnect time."),this.maxReconnectDelay_=br)}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=ks(e)?"auth":"gauth",i={cred:e};this.authOverride_===null?i.noauth=!0:typeof this.authOverride_=="object"&&(i.authvar=this.authOverride_),this.sendRequest(t,i,s=>{const r=s.s,o=s.d||"error";this.authToken_===e&&(r==="ok"?this.invalidAuthTokenCount_=0:this.onAuthRevoked_(r,o))})}}tryAppCheck(){this.connected_&&this.appCheckToken_&&this.sendRequest("appcheck",{token:this.appCheckToken_},e=>{const t=e.s,i=e.d||"error";t==="ok"?this.invalidAppCheckTokenCount_=0:this.onAppCheckRevoked_(t,i)})}unlisten(e,t){const i=e._path.toString(),s=e._queryIdentifier;this.log_("Unlisten called for "+i+" "+s),y(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(i,s)&&this.connected_&&this.sendUnlisten_(i,s,e._queryObject,t)}sendUnlisten_(e,t,i,s){this.log_("Unlisten on "+e+" for "+t);const r={p:e},o="n";s&&(r.q=i,r.t=s),this.sendRequest(o,r)}onDisconnectPut(e,t,i){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",e,t,i):this.onDisconnectRequestQueue_.push({pathString:e,action:"o",data:t,onComplete:i})}onDisconnectMerge(e,t,i){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",e,t,i):this.onDisconnectRequestQueue_.push({pathString:e,action:"om",data:t,onComplete:i})}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,i,s){const r={p:t,d:i};this.log_("onDisconnect "+e,r),this.sendRequest(e,r,o=>{s&&setTimeout(()=>{s(o.s,o.d)},Math.floor(0))})}put(e,t,i,s){this.putInternal("p",e,t,i,s)}merge(e,t,i,s){this.putInternal("m",e,t,i,s)}putInternal(e,t,i,s,r){this.initConnection_();const o={p:t,d:i};r!==void 0&&(o.h=r),this.outstandingPuts_.push({action:e,request:o,onComplete:s}),this.outstandingPutCount_++;const a=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(a):this.log_("Buffering put: "+t)}sendPut_(e){const t=this.outstandingPuts_[e].action,i=this.outstandingPuts_[e].request,s=this.outstandingPuts_[e].onComplete;this.outstandingPuts_[e].queued=this.connected_,this.sendRequest(t,i,r=>{this.log_(t+" response",r),delete this.outstandingPuts_[e],this.outstandingPutCount_--,this.outstandingPutCount_===0&&(this.outstandingPuts_=[]),s&&s(r.s,r.d)})}reportStats(e){if(this.connected_){const t={c:e};this.log_("reportStats",t),this.sendRequest("s",t,i=>{if(i.s!=="ok"){const r=i.d;this.log_("reportStats","Error sending stats: "+r)}})}}onDataMessage_(e){if("r"in e){this.log_("from server: "+j(e));const t=e.r,i=this.requestCBHash_[t];i&&(delete this.requestCBHash_[t],i(e.b))}else{if("error"in e)throw"A server-side error has occurred: "+e.error;"a"in e&&this.onDataPush_(e.a,e.b)}}onDataPush_(e,t){this.log_("handleServerMessage",e,t),e==="d"?this.onDataUpdate_(t.p,t.d,!1,t.t):e==="m"?this.onDataUpdate_(t.p,t.d,!0,t.t):e==="c"?this.onListenRevoked_(t.p,t.q):e==="ac"?this.onAuthRevoked_(t.s,t.d):e==="apc"?this.onAppCheckRevoked_(t.s,t.d):e==="sd"?this.onSecurityDebugPacket_(t):hi("Unrecognized action received from server: "+j(e)+` 647Are 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){y(!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_=Ut,this.realtime_||this.scheduleConnect_(0)),this.visible_=e}onOnline_(e){e?(this.log_("Browser went online."),this.reconnectDelay_=Ut,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline. Killing connection."),this.realtime_&&this.realtime_.close())}onRealtimeDisconnect_(){if(this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()){this.visible_?this.lastConnectionEstablishedTime_&&(new Date().getTime()-this.lastConnectionEstablishedTime_>ol&&(this.reconnectDelay_=Ut),this.lastConnectionEstablishedTime_=null):(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);
647t=Math.random()*t,this.log_("Trying to reconnect in "+t+"ms"),this.scheduleConnect_(t),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,this.reconnectDelay_*rl)}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),i=this.onRealtimeDisconnect_.bind(this),s=this.id+":"+ae.nextConnectionId_++,r=this.lastSessionId;let o=!1,a=null;const c=function(){a?a.close():(o=!0,i())},h=function(f){y(a,"sendRequest call when we're not connected not allowed."),a.sendRequest(f)};this.realtime_={close:c,sendRequest:h};const p=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{const[f,m]=await Promise.all([this.authTokenProvider_.getToken(p),this.appCheckTokenProvider_.getToken(p)]);o?z("getToken() completed but was canceled"):(z("getToken() completed. Creating connection."),this.authToken_=f&&f.accessToken,this.appCheckToken_=m&&m.token,a=new gr(s,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,t,i,v=>{Z(v+" ("+this.repoInfo_.toString()+")"),this.interrupt(al)},r))}catch(f){this.log_("Failed to get token: "+f),o||(this.repoInfo_.nodeAdmin&&Z(f),c())}}}interrupt(e){z("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){z("Resuming connection for reason: "+e),delete this.interruptReasons_[e],_t(this.interruptReasons_)&&(this.reconnectDelay_=Ut,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_--)}this.outstandingPutCount_===0&&(this.outstandingPuts_=[])}onListenRevoked_(e,t){let i;t?i=t.map(r=>ui(r)).join("$"):i="default";const s=this.removeListen_(e,i);s&&s.onComplete&&s.onComplete("permission_denied")}removeListen_(e,t){const i=new k(e).toString();let s;if(this.listens.has(i)){const r=this.listens.get(i);s=r.get(t),r.delete(t),r.size===0&&this.listens.delete(i)}else s=void 0;return s}onAuthRevoked_(e,t){z("Auth token revoked: "+e+"/"+t),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),(e==="invalid_token"||e==="permission_denied")&&(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_>=Sr&&(this.reconnectDelay_=br,this.authTokenProvider_.notifyForInvalidToken()))}onAppCheckRevoked_(e,t){z("App check token revoked: "+e+"/"+t),this.appCheckToken_=null,this.forceTokenRefresh_=!0,(e==="invalid_token"||e==="permission_denied")&&(this.invalidAppCheckTokenCount_++,this.invalidAppCheckTokenCount_>=Sr&&this.appCheckTokenProvider_.notifyForInvalidToken())}onSecurityDebugPacket_(e){this.securityDebugCallback_?this.securityDebugCallback_(e):"msg"in e&&ci.log("FIREBASE: "+e.msg.replace(` 648`,` 649FIREBASE: `))}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";Ie()&&(this.repoInfo_.nodeAdmin?t="admin_node":t="node"),e["sdk."+t+"."+u.replace(/\./g,"-")]=1,ee()?e["framework.cordova"]=1:Ts()&&(e["framework.reactnative"]=1),this.reportStats(e)}shouldReconnect_(){const e=yn.getInstance().currentlyOnline();return _t(this.interruptReasons_)&&e}}ae.nextPersistentConnectionId_=0,ae.nextConnectionId_=0;/** 650 * @license 651 * Copyright 2017 Google LLC 652 * 653 * Licensed under the Apache License, Version 2.0 (the "License");
654 * you may not use this file except in compliance with the License. 655 * You may obtain a copy of the License at 656 * 657 * http://www.apache.org/licenses/LICENSE-2.0 658 * 659 * Unless required by applicable law or agreed to in writing, software 660 * distributed under the License is distributed on an "AS IS" BASIS, 661 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 662 * See the License for the specific language governing permissions and 663 * limitations under the License. 664 */class A{constructor(e,t){this.name=e,this.node=t}static Wrap(e,t){return new A(e,t)}}/** 665 * @license 666 * Copyright 2017 Google LLC 667 * 668 * Licensed under the Apache License, Version 2.0 (the "License"); 669 * you may not use this file except in compliance with the License. 670 * You may obtain a copy of the License at 671 * 672 * http://www.apache.org/licenses/LICENSE-2.0 673 * 674 * Unless required by applicable law or agreed to in writing, software 675 * distributed under the License is distributed on an "AS IS" BASIS, 676 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 677 * See the License for the specific language governing permissions and 678 * limitations under the License. 679 */class vn{getCompare(){return this.compare.bind(this)}indexedValueChanged(e,t){const i=new A(Me,e),s=new A(Me,t);return this.compare(i,s)!==0}minPost(){return A.MIN}}/** 680 * @license 681 * Copyright 2017 Google LLC 682 * 683 * Licensed under the Apache License, Version 2.0 (the "License"); 684 * you may not use this file except in compliance with the License. 685 * You may obtain a copy of the License at 686 * 687 * http://www.apache.org/licenses/LICENSE-2.0 688 * 689 * Unless required by applicable law or agreed to in writing, software 690 * distributed under the License is distributed on an "AS IS" BASIS, 691 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 692 * See the License for the specific language governing permissions and 693 * limitations under the License. 694 */let En;class Tr extends vn{static get __EMPTY_NODE(){return En}static set __EMPTY_NODE(e){En=e}compare(e,t){return et(e.name,t.name)}isDefinedOn(e){throw ye("KeyIndex.isDefinedOn not expected to be called.")}indexedValueChanged(e,t){return!1}minPost(){return A.MIN}maxPost(){return new A(Ne,En)}makePost(e,t){return y(typeof e=="string","KeyIndex indexValue must always be a string."),new A(e,En)}toString(){return".key"}}const Re=new Tr;/** 695 * @license 696 * Copyright 2017 Google LLC 697 * 698 * Licensed under the Apache License, Version 2.0 (the "License"); 699 * you may not use this file except in compliance with the License. 700 * You may obtain a copy of the License at 701 * 702 * http://www.apache.org/licenses/LICENSE-2.0 703 * 704 * Unless required by applicable law or agreed to in writing, software 705 * distributed under the License is distributed on an "AS IS" BASIS, 706 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 707 * See the License for the specific language governing permissions and 708 * limitations under the License. 709 */class Cn{constructor(e,t,i,s,r=null){this.isReverse_=s,this.resultGenerator_=r,this.nodeStack_=[];let o=1;for(;!e.isEmpty();)if(e=e,o=t?i(e.key,t):1,s&&(o*=-1),o<0)this.isReverse_?e=e.left:e=e.right;else if(o===0){this.nodeStack_.push(e);break}else this.nodeStack_.push(e),this.isReverse_?e=e.right:e=e.left}getNext(){if(this.nodeStack_.length===0)return null;let e=this.nodeStack_.pop(),t;if(this.resultGenerator_?t=this.resultGenerator_(e.key,e.value):t={key:e.key,value:e.value},this.isReverse_)for(e=e.left;!e.isEmpty();)this.nodeStack_.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack_.push(e),e=e.left;return t}hasNext(){return this.nodeStack_.length>0}peek(){if(this.nodeStack_.length===0)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 Q{constructor(e,t,i,s,r){this.key=e,this.value=t,this.color=i??Q.RED,this.left=s??se.EMPTY_NODE,this.right=r??se.EMPTY_NODE}copy(e,t,i,s,r){return new Q(e??this.key,t??this.value,i??this.color,s??this.left,r??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,i){let s=this;const r=i(e,s.key);return r<0?s=s.copy(null,null,null,s.left.insert(e,t,i),null):r===0?s=s.copy(null,t,null,null,null):s=s.copy(null,null,null,null,s.right.insert(e,t,i)),s.fixUp_()}removeMin_(){if(this.left.isEmpty())return se.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 i,s;if(i=this,t(e,i.key)<0)!i.left.isEmpty()&&!i.left.isRed_()&&!i.left.left.isRed_()&&(i=i.moveRedLeft_()),i=i.copy(null,null,null,i.left.remove(e,t),null);else{if(i.left.isRed_()&&(i=i.rotateRight_()),!i.right.isEmpty()&&!i.right.isRed_()&&!i.right.left.isRed_()&&(i=i.moveRedRight_()),t(e,i.key)===0){if(i.right.isEmpty())return se.EMPTY_NODE;
vendor: 1,248 bytes, line 709
709s=i.right.min_(),i=i.copy(s.key,s.value,null,null,i.right.removeMin_())}i=i.copy(null,null,null,null,i.right.remove(e,t))}return i.fixUp_()}isRed_(){return this.color}fixUp_(){let e=this;return e.right.isRed_()&&!e.left.isRed_()&&(e=e.rotateLeft_()),e.left.isRed_()&&e.left.left.isRed_()&&(e=e.rotateRight_()),e.left.isRed_()&&e.right.isRed_()&&(e=e.colorFlip_()),e}moveRedLeft_(){let e=this.colorFlip_();return e.right.left.isRed_()&&(e=e.copy(null,null,null,null,e.right.rotateRight_()),e=e.rotateLeft_(),e=e.colorFlip_()),e}moveRedRight_(){let e=this.colorFlip_();return e.left.left.isRed_()&&(e=e.rotateRight_(),e=e.colorFlip_()),e}rotateLeft_(){const e=this.copy(null,null,Q.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight_(){const e=this.copy(null,null,Q.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+")");
709if(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)}}Q.RED=!0,Q.BLACK=!1;class ll{copy(e,t,i,s,r){return this}insert(e,t,i){return new Q(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}}class se{constructor(e,t=se.EMPTY_NODE){this.comparator_=e,this.root_=t}insert(e,t){return new se(this.comparator_,this.root_.insert(e,t,this.comparator_).copy(null,null,Q.BLACK,null,null))}remove(e){return new se(this.comparator_,this.root_.remove(e,this.comparator_).copy(null,null,Q.BLACK,null,null))}get(e){let t,i=this.root_;for(;!i.isEmpty();){if(t=this.comparator_(e,i.key),t===0)return i.value;t<0?i=i.left:t>0&&(i=i.right)}return null}getPredecessorKey(e){let t,i=this.root_,s=null;for(;!i.isEmpty();)if(t=this.comparator_(e,i.key),t===0){if(i.left.isEmpty())return s?s.key:null;for(i=i.left;!i.right.isEmpty();)i=i.right;return i.key}else t<0?i=i.left:t>0&&(s=i,i=i.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 Cn(this.root_,null,this.comparator_,!1,e)}getIteratorFrom(e,t){return new Cn(this.root_,e,this.comparator_,!1,t)}getReverseIteratorFrom(e,t){return new Cn(this.root_,e,this.comparator_,!0,t)}getReverseIterator(e){return new Cn(this.root_,null,this.comparator_,!0,e)}}se.EMPTY_NODE=new ll;/** 710 * @license 711 * Copyright 2017 Google LLC 712 * 713 * Licensed under the Apache License, Version 2.0 (the "License"); 714 * you may not use this file except in compliance with the License. 715 * You may obtain a copy of the License at 716 * 717 * http://www.apache.org/licenses/LICENSE-2.0 718 * 719 * Unless required by applicable law or agreed to in writing, software 720 * distributed under the License is distributed on an "AS IS" BASIS, 721 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 722 * See the License for the specific language governing permissions and 723 * limitations under the License. 724 */function cl(n,e){return et(n.name,e.name)}function bi(n,e){return et(n,e)}/** 725 * @license 726 * Copyright 2017 Google LLC 727 * 728 * Licensed under the Apache License, Version 2.0 (the "License"); 729 * you may not use this file except in compliance with the License. 730 * You may obtain a copy of the License at 731 * 732 * http://www.apache.org/licenses/LICENSE-2.0 733 * 734 * Unless required by applicable law or agreed to in writing, software 735 * distributed under the License is distributed on an "AS IS" BASIS, 736 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 737 * See the License for the specific language governing permissions and 738 * limitations under the License. 739 */let Si;function hl(n){Si=n}const xr=function(n){return typeof n=="number"?"number:"+Qs(n):"string:"+n},Ir=function(n){if(n.isLeafNode()){const e=n.val();y(typeof e=="string"||typeof e=="number"||typeof e=="object"&&de(e,".sv"),"Priority must be a string or number.")}else y(n===Si||n.isEmpty(),"priority of unexpected type.");y(n===Si||n.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")};/** 740 * @license 741 * Copyright 2017 Google LLC 742 * 743 * Licensed under the Apache License, Version 2.0 (the "License"); 744 * you may not use this file except in compliance with the License. 745 * You may obtain a copy of the License at 746 * 747 * http://www.apache.org/licenses/LICENSE-2.0 748 * 749 * Unless required by applicable law or agreed to in writing, software 750 * distributed under the License is distributed on an "AS IS" BASIS, 751 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 752 * See the License for the specific language governing permissions and 753 * limitations under the License. 754 */let Ar;class ${constructor(e,t=$.__childrenNodeConstructor.EMPTY_NODE){this.value_=e,this.priorityNode_=t,this.lazyHash_=null,y(this.value_!==void 0&&this.value_!==null,"LeafNode shouldn't be created with null/undefined value."),Ir(this.priorityNode_)}static set __childrenNodeConstructor(e){Ar=e}static get __childrenNodeConstructor(){return Ar}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new $(this.value_,e)}getImmediateChild(e){return e===".priority"?this.priorityNode_:$.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return I(e)?this:x(e)===".priority"?this.priorityNode_:$.__childrenNodeConstructor.EMPTY_NODE}hasChild(){return!1}getPredecessorChildName(e,t){return null}updateImmediateChild(e,t){return e===".priority"?this.updatePriority(t):t.isEmpty()&&e!==".priority"?this:$.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,t).updatePriority(this.priorityNode_)}updateChild(e,t){const i=x(e);return i===null?t:t.isEmpty()&&i!==".priority"?this:(y(i!==".priority"||Ue(e)===1,".priority must be the last token in a path"),this.updateImmediateChild(i,$.__childrenNodeConstructor.EMPTY_NODE.updateChild(F(e),t)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(e,t){return!1}
754val(e){return e&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()}hash(){if(this.lazyHash_===null){let e="";this.priorityNode_.isEmpty()||(e+="priority:"+xr(this.priorityNode_.val())+":");const t=typeof this.value_;e+=t+":",t==="number"?e+=Qs(this.value_):e+=this.value_,this.lazyHash_=P(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===$.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof $.__childrenNodeConstructor?-1:(y(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){const t=typeof e.value_,i=typeof this.value_,s=$.VALUE_TYPE_ORDER.indexOf(t),r=$.VALUE_TYPE_ORDER.indexOf(i);return y(s>=0,"Unknown leaf type: "+t),y(r>=0,"Unknown leaf type: "+i),s===r?i==="object"?0:this.value_<e.value_?-1:this.value_===e.value_?0:1:r-s}withIndex(){return this}isIndexed(){return!0}equals(e){if(e===this)return!0;if(e.isLeafNode()){const t=e;return this.value_===t.value_&&this.priorityNode_.equals(t.priorityNode_)}else return!1}}$.VALUE_TYPE_ORDER=["object","boolean","number","string"];/** 755 * @license 756 * Copyright 2017 Google LLC 757 * 758 * Licensed under the Apache License, Version 2.0 (the "License"); 759 * you may not use this file except in compliance with the License. 760 * You may obtain a copy of the License at 761 * 762 * http://www.apache.org/licenses/LICENSE-2.0 763 * 764 * Unless required by applicable law or agreed to in writing, software 765 * distributed under the License is distributed on an "AS IS" BASIS, 766 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 767 * See the License for the specific language governing permissions and 768 * limitations under the License. 769 */let Nr,Rr;function ul(n){Nr=n}function dl(n){Rr=n}class fl extends vn{compare(e,t){const i=e.node.getPriority(),s=t.node.getPriority(),r=i.compareTo(s);return r===0?et(e.name,t.name):r}isDefinedOn(e){return!e.getPriority().isEmpty()}indexedValueChanged(e,t){return!e.getPriority().equals(t.getPriority())}minPost(){return A.MIN}maxPost(){return new A(Ne,new $("[PRIORITY-POST]",Rr))}makePost(e,t){const i=Nr(e);return new A(t,new $("[PRIORITY-POST]",i))}toString(){return".priority"}}const B=new fl;/** 770 * @license 771 * Copyright 2017 Google LLC 772 * 773 * Licensed under the Apache License, Version 2.0 (the "License"); 774 * you may not use this file except in compliance with the License. 775 * You may obtain a copy of the License at 776 * 777 * http://www.apache.org/licenses/LICENSE-2.0 778 * 779 * Unless required by applicable law or agreed to in writing, software 780 * distributed under the License is distributed on an "AS IS" BASIS, 781 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 782 * See the License for the specific language governing permissions and 783 * limitations under the License. 784 */const _l=Math.log(2);class pl{constructor(e){const t=r=>parseInt(Math.log(r)/_l,10),i=r=>parseInt(Array(r+1).join("1"),2);this.count=t(e+1),this.current_=this.count-1;const s=i(this.count);this.bits_=e+1&s}nextBitIsOne(){const e=!(this.bits_&1<<this.current_);return this.current_--,e}}const wn=function(n,e,t,i){n.sort(e);const s=function(c,h){const p=h-c;let f,m;if(p===0)return null;if(p===1)return f=n[c],m=t?t(f):f,new Q(m,f.node,Q.BLACK,null,null);{const v=parseInt(p/2,10)+c,C=s(c,v),M=s(v+1,h);return f=n[v],m=t?t(f):f,new Q(m,f.node,Q.BLACK,C,M)}},r=function(c){let h=null,p=null,f=n.length;const m=function(C,M){const J=f-C,At=f;f-=C;const Xn=s(J+1,At),Ss=n[J],Pu=t?t(Ss):Ss;v(new Q(Pu,Ss.node,M,null,Xn))},v=function(C){h?(h.left=C,h=C):(p=C,h=C)};for(let C=0;C<c.count;++C){const M=c.nextBitIsOne(),J=Math.pow(2,c.count-(C+1));M?m(J,Q.BLACK):(m(J,Q.BLACK),m(J,Q.RED))}return p},o=new pl(n.length),a=r(o);return new se(i||e,a)};/** 785 * @license 786 * Copyright 2017 Google LLC 787 * 788 * Licensed under the Apache License, Version 2.0 (the "License"); 789 * you may not use this file except in compliance with the License. 790 * You may obtain a copy of the License at 791 * 792 * http://www.apache.org/licenses/LICENSE-2.0 793 * 794 * Unless required by applicable law or agreed to in writing, softw
794are 795 * distributed under the License is distributed on an "AS IS" BASIS, 796 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 797 * See the License for the specific language governing permissions and 798 * limitations under the License. 799 */let Ti;const vt={};class Le{constructor(e,t){this.indexes_=e,this.indexSet_=t}static get Default(){return y(vt&&B,"ChildrenNode.ts has not been loaded"),Ti=Ti||new Le({".priority":vt},{".priority":B}),Ti}get(e){const t=ke(this.indexes_,e);if(!t)throw new Error("No index defined for "+e);return t instanceof se?t:null}hasIndex(e){return de(this.indexSet_,e.toString())}addIndex(e,t){y(e!==Re,"KeyIndex always exists and isn't meant to be added to the IndexMap.");const i=[];let s=!1;const r=t.getIterator(A.Wrap);let o=r.getNext();for(;o;)s=s||e.isDefinedOn(o.node),i.push(o),o=r.getNext();let a;s?a=wn(i,e.getCompare()):a=vt;const c=e.toString(),h=Object.assign({},this.indexSet_);h[c]=e;const p=Object.assign({},this.indexes_);return p[c]=a,new Le(p,h)}addToIndexes(e,t){const i=Pt(this.indexes_,(s,r)=>{const o=ke(this.indexSet_,r);if(y(o,"Missing index implementation for "+r),s===vt)if(o.isDefinedOn(e.node)){const a=[],c=t.getIterator(A.Wrap);let h=c.getNext();for(;h;)h.name!==e.name&&a.push(h),h=c.getNext();return a.push(e),wn(a,o.getCompare())}else return vt;else{const a=t.get(e.name);let c=s;return a&&(c=c.remove(new A(e.name,a))),c.insert(e,e.node)}});return new Le(i,this.indexSet_)}removeFromIndexes(e,t){const i=Pt(this.indexes_,s=>{if(s===vt)return s;{const r=t.get(e.name);return r?s.remove(new A(e.name,r)):s}});return new Le(i,this.indexSet_)}}/** 800 * @license 801 * Copyright 2017 Google LLC 802 * 803 * Licensed under the Apache License, Version 2.0 (the "License"); 804 * you may not use this file except in compliance with the License. 805 * You may obtain a copy of the License at 806 * 807 * http://www.apache.org/licenses/LICENSE-2.0 808 * 809 * Unless required by applicable law or agreed to in writing, software 810 * distributed under the License is distributed on an "AS IS" BASIS, 811 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 812 * See the License for the specific language governing permissions and 813 * limitations under the License. 814 */let Vt;class w{constructor(e,t,i){this.children_=e,this.priorityNode_=t,this.indexMap_=i,this.lazyHash_=null,this.priorityNode_&&Ir(this.priorityNode_),this.children_.isEmpty()&&y(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}static get EMPTY_NODE(){return Vt||(Vt=new w(new se(bi),null,Le.Default))}isLeafNode(){return!1}getPriority(){return this.priorityNode_||Vt}updatePriority(e){return this.children_.isEmpty()?this:new w(this.children_,e,this.indexMap_)}getImmediateChild(e){if(e===".priority")return this.getPriority();{const t=this.children_.get(e);return t===null?Vt:t}}getChild(e){const t=x(e);return t===null?this:this.getImmediateChild(t).getChild(F(e))}hasChild(e){return this.children_.get(e)!==null}updateImmediateChild(e,t){if(y(t,"We should always be passing snapshot nodes"),e===".priority")return this.updatePriority(t);{const i=new A(e,t);let s,r;t.isEmpty()?(s=this.children_.remove(e),r=this.indexMap_.removeFromIndexes(i,this.children_)):(s=this.children_.insert(e,t),r=this.indexMap_.addToIndexes(i,this.children_));const o=s.isEmpty()?Vt:this.priorityNode_;return new w(s,o,r)}}updateChild(e,t){const i=x(e);if(i===null)return t;{y(x(e)!==".priority"||Ue(e)===1,".priority must be the last token in a path");const s=this.getImmediateChild(i).updateChild(F(e),t);return this.updateImmediateChild(i,s)}}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(e){if(this.isEmpty())return null;const t={};let i=0,s=0,r=!0;if(this.forEachChild(B,(o,a)=>{t[o]=a.val(e),i++,r&&w.INTEGER_REGEXP_.test(o)?s=Math.max(s,Number(o)):r=!1}),!e&&r&&s<2*i){const o=[];for(const a in t)o[a]=t[a];return o}else return e&&!this.getPriority().isEmpty()&&(t[".priority"]=this.getPriority().val()),t}hash(){if(this.lazyHash_===null){let e="";
814this.getPriority().isEmpty()||(e+="priority:"+xr(this.getPriority().val())+":"),this.forEachChild(B,(t,i)=>{const s=i.hash();s!==""&&(e+=":"+t+":"+s)}),this.lazyHash_=e===""?"":P(e)}return this.lazyHash_}getPredecessorChildName(e,t,i){const s=this.resolveIndex_(i);if(s){const r=s.getPredecessorKey(new A(e,t));return r?r.name:null}else return this.children_.getPredecessorKey(e)}getFirstChildName(e){const t=this.resolveIndex_(e);if(t){const i=t.minKey();return i&&i.name}else return this.children_.minKey()}getFirstChild(e){const t=this.getFirstChildName(e);return t?new A(t,this.children_.get(t)):null}getLastChildName(e){const t=this.resolveIndex_(e);if(t){const i=t.maxKey();return i&&i.name}else return this.children_.maxKey()}getLastChild(e){const t=this.getLastChildName(e);return t?new A(t,this.children_.get(t)):null}forEachChild(e,t){const i=this.resolveIndex_(e);return i?i.inorderTraversal(s=>t(s.name,s.node)):this.children_.inorderTraversal(t)}getIterator(e){return this.getIteratorFrom(e.minPost(),e)}getIteratorFrom(e,t){const i=this.resolveIndex_(t);if(i)return i.getIteratorFrom(e,s=>s);{const s=this.children_.getIteratorFrom(e.name,A.Wrap);let r=s.peek();for(;r!=null&&t.compare(r,e)<0;)s.getNext(),r=s.peek();return s}}getReverseIterator(e){return this.getReverseIteratorFrom(e.maxPost(),e)}getReverseIteratorFrom(e,t){const i=this.resolveIndex_(t);if(i)return i.getReverseIteratorFrom(e,s=>s);{const s=this.children_.getReverseIteratorFrom(e.name,A.Wrap);let r=s.peek();for(;r!=null&&t.compare(r,e)>0;)s.getNext(),r=s.peek();return s}}compareTo(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===jt?-1:0}withIndex(e){if(e===Re||this.indexMap_.hasIndex(e))return this;{const t=this.indexMap_.addIndex(e,this.children_);return new w(this.children_,this.priorityNode_,t)}}isIndexed(e){return e===Re||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 i=this.getIterator(B),s=t.getIterator(B);let r=i.getNext(),o=s.getNext();for(;r&&o;){if(r.name!==o.name||!r.node.equals(o.node))return!1;r=i.getNext(),o=s.getNext()}return r===null&&o===null}else return!1;else return!1}}resolveIndex_(e){return e===Re?null:this.indexMap_.get(e.toString())}}w.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;class gl extends w{constructor(){super(new se(bi),w.EMPTY_NODE,Le.Default)}compareTo(e){return e===this?0:1}equals(e){return e===this}getPriority(){return this}getImmediateChild(e){return w.EMPTY_NODE}isEmpty(){return!1}}const jt=new gl;Object.defineProperties(A,{MIN:{value:new A(Me,w.EMPTY_NODE)},MAX:{value:new A(Ne,jt)}}),Tr.__EMPTY_NODE=w.EMPTY_NODE,$.__childrenNodeConstructor=w,hl(jt),dl(jt);/** 815 * @license 816 * Copyright 2017 Google LLC 817 * 818 * Licensed under the Apache License, Version 2.0 (the "License"); 819 * you may not use this file except in compliance with the License. 820 * You may obtain a copy of the License at 821 * 822 * http://www.apache.org/licenses/LICENSE-2.0 823 * 824 * Unless required by applicable law or agreed to in writing, software 825 * distributed under the License is distributed on an "AS IS" BASIS, 826 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 827 * See the License for the specific language governing permissions and 828 * limitations under the License. 829 */const ml=!0;function V(n,e=null){if(n===null)return w.EMPTY_NODE;if(typeof n=="object"&&".priority"in n&&(e=n[".priority"]),y(e===null||typeof e=="string"||typeof e=="number"||typeof e=="object"&&".sv"in e,"Invalid priority type found: "+typeof e),typeof n=="object"&&".value"in n&&n[".value"]!==null&&(n=n[".value"]),typeof n!="object"||".sv"in n){const t=n;return new $(t,V(e))}if(!(n instanceof Array)&&ml){const t=[];let i=!1;if(G(n,(o,a)=>{if(o.substring(0,1)!=="."){const c=V(a);c.isEmpty()||(i=i||!c.getPriority().isEmpty(),t.push(new A(o,c)))}}),t.length===0)return w.EMPTY_NODE;const r=wn(t,cl,o=>o.name,bi);if(i){const o=wn(t,B.getCompare());return new w(r,V(e),new Le({".priority":o},{".priority":B}))}else return new w(r,V(e),Le.Default)}else{let t=w.EMPTY_NODE;return G(n,(i,s)=>{if(de(n,i)&&i.substring(0,1)!=="."){const r=V(s);(r.isLeafNode()||!r.isEmpty())&&(t=t.updateImmediateChild(i,r))}}),t.updatePriority(V(e))}}ul(V);/** 830 * @license 831 * Copyright 2017 Google LLC 832 * 833 * Licensed under the Apache License, Version 2.0 (the "License");
834 * you may not use this file except in compliance with the License. 835 * You may obtain a copy of the License at 836 * 837 * http://www.apache.org/licenses/LICENSE-2.0 838 * 839 * Unless required by applicable law or agreed to in writing, software 840 * distributed under the License is distributed on an "AS IS" BASIS, 841 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 842 * See the License for the specific language governing permissions and 843 * limitations under the License. 844 */class xi extends vn{constructor(e){super(),this.indexPath_=e,y(!I(e)&&x(e)!==".priority","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 i=this.extractChild(e.node),s=this.extractChild(t.node),r=i.compareTo(s);return r===0?et(e.name,t.name):r}makePost(e,t){const i=V(e),s=w.EMPTY_NODE.updateChild(this.indexPath_,i);return new A(t,s)}maxPost(){const e=w.EMPTY_NODE.updateChild(this.indexPath_,jt);return new A(Ne,e)}toString(){return Wt(this.indexPath_,0).join("/")}}/** 845 * @license 846 * Copyright 2017 Google LLC 847 * 848 * Licensed under the Apache License, Version 2.0 (the "License"); 849 * you may not use this file except in compliance with the License. 850 * You may obtain a copy of the License at 851 * 852 * http://www.apache.org/licenses/LICENSE-2.0 853 * 854 * Unless required by applicable law or agreed to in writing, software 855 * distributed under the License is distributed on an "AS IS" BASIS, 856 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 857 * See the License for the specific language governing permissions and 858 * limitations under the License. 859 */class yl extends vn{compare(e,t){const i=e.node.compareTo(t.node);return i===0?et(e.name,t.name):i}isDefinedOn(e){return!0}indexedValueChanged(e,t){return!e.equals(t)}minPost(){return A.MIN}maxPost(){return A.MAX}makePost(e,t){const i=V(e);return new A(t,i)}toString(){return".value"}}const Ii=new yl;/** 860 * @license 861 * Copyright 2017 Google LLC 862 * 863 * Licensed under the Apache License, Version 2.0 (the "License"); 864 * you may not use this file except in compliance with the License. 865 * You may obtain a copy of the License at 866 * 867 * http://www.apache.org/licenses/LICENSE-2.0 868 * 869 * Unless required by applicable law or agreed to in writing, software 870 * distributed under the License is distributed on an "AS IS" BASIS, 871 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 872 * See the License for the specific language governing permissions and 873 * limitations under the License. 874 */const Et="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",Ai="-",Or="z",Pr=786,vl=function(){let n=0;const e=[];return function(t){const i=t===n;n=t;let s;const r=new Array(8);for(s=7;s>=0;s--)r[s]=Et.charAt(t%64),t=Math.floor(t/64);y(t===0,"Cannot push at time == 0");let o=r.join("");if(i){for(s=11;s>=0&&e[s]===63;s--)e[s]=0;e[s]++}else for(s=0;s<12;s++)e[s]=Math.floor(Math.random()*64);for(s=0;s<12;s++)o+=Et.charAt(e[s]);return y(o.length===20,"nextPushId: Length should be 20."),o}}(),kr=function(n){if(n===""+di)return Ai;const e=pn(n);if(e!=null)return""+(e+1);const t=new Array(n.length);for(let o=0;o<t.length;o++)t[o]=n.charAt(o);if(t.length<Pr)return t.push(Ai),t.join("");let i=t.length-1;for(;i>=0&&t[i]===Or;)i--;if(i===-1)return Ne;const s=t[i],r=Et.charAt(Et.indexOf(s)+1);return t[i]=r,t.slice(0,i+1).join("")},Dr=function(n){if(n===""+$s)return Me;const e=pn(n);if(e!=null)return""+(e-1);const t=new Array(n.length);for(let i=0;i<t.length;i++)t[i]=n.charAt(i);return t[t.length-1]===Ai?t.length===1?""+di:(delete t[t.length-1],t.join("")):(t[t.length-1]=Et.charAt(Et.indexOf(t[t.length-1])-1),t.join("")+Or.repeat(Pr-t.length))};/** 875 * @license 876 * Copyright 2017 Google LLC 877 * 878 * Licensed under the Apache License, Version 2.0 (the "License"); 879 * you may not use this file except in compliance with the License. 880 * You may obtain a copy of the License at 881 * 882 * http://www.apache.org/licenses/LICENSE-2.0 883 * 884 * Unless required by applicable law or agreed to in writing, softw
884are 885 * distributed under the License is distributed on an "AS IS" BASIS, 886 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 887 * See the License for the specific language governing permissions and 888 * limitations under the License. 889 */function Mr(n){return{type:"value",snapshotNode:n}}function Ct(n,e){return{type:"child_added",snapshotNode:e,childName:n}}function Ht(n,e){return{type:"child_removed",snapshotNode:e,childName:n}}function zt(n,e,t){return{type:"child_changed",snapshotNode:e,childName:n,oldSnap:t}}function El(n,e){return{type:"child_moved",snapshotNode:e,childName:n}}/** 890 * @license 891 * Copyright 2017 Google LLC 892 * 893 * Licensed under the Apache License, Version 2.0 (the "License"); 894 * you may not use this file except in compliance with the License. 895 * You may obtain a copy of the License at 896 * 897 * http://www.apache.org/licenses/LICENSE-2.0 898 * 899 * Unless required by applicable law or agreed to in writing, software 900 * distributed under the License is distributed on an "AS IS" BASIS, 901 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 902 * See the License for the specific language governing permissions and 903 * limitations under the License. 904 */class Ni{constructor(e){this.index_=e}updateChild(e,t,i,s,r,o){y(e.isIndexed(this.index_),"A node must be indexed if only a child is updated");const a=e.getImmediateChild(t);return a.getChild(s).equals(i.getChild(s))&&a.isEmpty()===i.isEmpty()||(o!=null&&(i.isEmpty()?e.hasChild(t)?o.trackChildChange(Ht(t,a)):y(e.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):a.isEmpty()?o.trackChildChange(Ct(t,i)):o.trackChildChange(zt(t,i,a))),e.isLeafNode()&&i.isEmpty())?e:e.updateImmediateChild(t,i).withIndex(this.index_)}updateFullNode(e,t,i){return i!=null&&(e.isLeafNode()||e.forEachChild(B,(s,r)=>{t.hasChild(s)||i.trackChildChange(Ht(s,r))}),t.isLeafNode()||t.forEachChild(B,(s,r)=>{if(e.hasChild(s)){const o=e.getImmediateChild(s);o.equals(r)||i.trackChildChange(zt(s,r,o))}else i.trackChildChange(Ct(s,r))})),t.withIndex(this.index_)}updatePriority(e,t){return e.isEmpty()?w.EMPTY_NODE:e.updatePriority(t)}filtersNodes(){return!1}getIndexedFilter(){return this}getIndex(){return this.index_}}/** 905 * @license 906 * Copyright 2017 Google LLC 907 * 908 * Licensed under the Apache License, Version 2.0 (the "License"); 909 * you may not use this file except in compliance with the License. 910 * You may obtain a copy of the License at 911 * 912 * http://www.apache.org/licenses/LICENSE-2.0 913 * 914 * Unless required by applicable law or agreed to in writing, software 915 * distributed under the License is distributed on an "AS IS" BASIS, 916 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 917 * See the License for the specific language governing permissions and 918 * limitations under the License. 919 */class Gt{constructor(e){this.indexedFilter_=new Ni(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,i,s,r,o){return this.matches(new A(t,i))||(i=w.EMPTY_NODE),this.indexedFilter_.updateChild(e,t,i,s,r,o)}updateFullNode(e,t,i){t.isLeafNode()&&(t=w.EMPTY_NODE);let s=t.withIndex(this.index_);s=s.updatePriority(w.EMPTY_NODE);const r=this;return t.forEachChild(B,(o,a)=>{r.matches(new A(o,a))||(s=s.updateImmediateChild(o,w.EMPTY_NODE))}),this.indexedFilter_.updateFullNode(e,s,i)}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)}else return e.getIndex().minPost()}static getEndPost_(e){if(e.hasEnd()){const t=e.getIndexEndName();return e.getIndex().makePost(e.getIndexEndValue(),t)}else return e.getIndex().maxPost()}}/** 920 * @license 921 * Copyright 2017 Google LLC 922 * 923 * Licensed under the Apache License, Version 2.0 (the "License");
924 * you may not use this file except in compliance with the License. 925 * You may obtain a copy of the License at 926 * 927 * http://www.apache.org/licenses/LICENSE-2.0 928 * 929 * Unless required by applicable law or agreed to in writing, software 930 * distributed under the License is distributed on an "AS IS" BASIS, 931 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 932 * See the License for the specific language governing permissions and 933 * limitations under the License. 934 */class Cl{constructor(e){this.rangedFilter_=new Gt(e),this.index_=e.getIndex(),this.limit_=e.getLimit(),this.reverse_=!e.isViewFromLeft()}updateChild(e,t,i,s,r,o){return this.rangedFilter_.matches(new A(t,i))||(i=w.EMPTY_NODE),e.getImmediateChild(t).equals(i)?e:e.numChildren()<this.limit_?this.rangedFilter_.getIndexedFilter().updateChild(e,t,i,s,r,o):this.fullLimitUpdateChild_(e,t,i,r,o)}updateFullNode(e,t,i){let s;if(t.isLeafNode()||t.isEmpty())s=w.EMPTY_NODE.withIndex(this.index_);else if(this.limit_*2<t.numChildren()&&t.isIndexed(this.index_)){s=w.EMPTY_NODE.withIndex(this.index_);let r;this.reverse_?r=t.getReverseIteratorFrom(this.rangedFilter_.getEndPost(),this.index_):r=t.getIteratorFrom(this.rangedFilter_.getStartPost(),this.index_);let o=0;for(;r.hasNext()&&o<this.limit_;){const a=r.getNext();let c;if(this.reverse_?c=this.index_.compare(this.rangedFilter_.getStartPost(),a)<=0:c=this.index_.compare(a,this.rangedFilter_.getEndPost())<=0,c)s=s.updateImmediateChild(a.name,a.node),o++;else break}}else{s=t.withIndex(this.index_),s=s.updatePriority(w.EMPTY_NODE);let r,o,a,c;if(this.reverse_){c=s.getReverseIterator(this.index_),r=this.rangedFilter_.getEndPost(),o=this.rangedFilter_.getStartPost();const f=this.index_.getCompare();a=(m,v)=>f(v,m)}else c=s.getIterator(this.index_),r=this.rangedFilter_.getStartPost(),o=this.rangedFilter_.getEndPost(),a=this.index_.getCompare();let h=0,p=!1;for(;c.hasNext();){const f=c.getNext();!p&&a(r,f)<=0&&(p=!0),p&&h<this.limit_&&a(f,o)<=0?h++:s=s.updateImmediateChild(f.name,w.EMPTY_NODE)}}return this.rangedFilter_.getIndexedFilter().updateFullNode(e,s,i)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.rangedFilter_.getIndexedFilter()}getIndex(){return this.index_}fullLimitUpdateChild_(e,t,i,s,r){let o;if(this.reverse_){const f=this.index_.getCompare();o=(m,v)=>f(v,m)}else o=this.index_.getCompare();const a=e;y(a.numChildren()===this.limit_,"");const c=new A(t,i),h=this.reverse_?a.getFirstChild(this.index_):a.getLastChild(this.index_),p=this.rangedFilter_.matches(c);if(a.hasChild(t)){const f=a.getImmediateChild(t);let m=s.getChildAfterChild(this.index_,h,this.reverse_);for(;m!=null&&(m.name===t||a.hasChild(m.name));)m=s.getChildAfterChild(this.index_,m,this.reverse_);const v=m==null?1:o(m,c);if(p&&!i.isEmpty()&&v>=0)return r?.trackChildChange(zt(t,i,f)),a.updateImmediateChild(t,i);{r?.trackChildChange(Ht(t,f));const M=a.updateImmediateChild(t,w.EMPTY_NODE);return m!=null&&this.rangedFilter_.matches(m)?(r?.trackChildChange(Ct(m.name,m.node)),M.updateImmediateChild(m.name,m.node)):M}}else return i.isEmpty()?e:p&&o(h,c)>=0?(r!=null&&(r.trackChildChange(Ht(h.name,h.node)),r.trackChildChange(Ct(t,i))),a.updateImmediateChild(t,i).updateImmediateChild(h.name,w.EMPTY_NODE)):e}}/** 935 * @license 936 * Copyright 2017 Google LLC 937 * 938 * Licensed under the Apache License, Version 2.0 (the "License"); 939 * you may not use this file except in compliance with the License. 940 * You may obtain a copy of the License at 941 * 942 * http://www.apache.org/licenses/LICENSE-2.0 943 * 944 * Unless required by applicable law or agreed to in writing, software 945 * distributed under the License is distributed on an "AS IS" BASIS, 946 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 947 * See the License for the specific language governing permissions and 948 * limitations under the License. 949 */class bn{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_=B}hasStart(){return this.startSet_}hasStartAfter(){return this.startAfterSet_}hasEndBefore(){return this.endBeforeSet_}isViewFromLeft(){return this.viewFrom_===""?this.startSet_:this.viewFrom_==="l"}getIndexStartValue(){return y(this.startSet_,"Only valid if start has been set"),this.indexStartValue_}getIndexStartName(){return y(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:Me}hasEnd(){return this.endSet_}getIndexEndValue(){return y(this.endSet_,"Only valid if end has been set"),this.indexEndValue_}getIndexEndName(){return y(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:Ne}hasLimit(){return this.limitSet_}hasAnchoredLimit(){return this.limitSet_&&this.viewFrom_!==""}getLimit(){return y(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_===B}copy(){const e=new bn;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 wl(n){return n.loadsAllData()?new Ni(n.getIndex()):n.hasLimit()?new Cl(n):new Gt(n)}function bl(n,e){const t=n.copy();return t.limitSet_=!0,t.limit_=e,t.viewFrom_="l",t}function Sl(n,e){const t=n.copy();return t.limitSet_=!0,t.limit_=e,t.viewFrom_="r",t}function Ri(n,e,t){const i=n.copy();return i.startSet_=!0,e===void 0&&(e=null),i.indexStartValue_=e,t!=null?(i.startNameSet_=!0,i.indexStartName_=t):(i.startNameSet_=!1,i.indexStartName_=""),i}function Tl(n,e,t){let i;if(n.index_===Re)typeof e=="string"&&(e=kr(e)),i=Ri(n,e,t);else{let s;t==null?s=Ne:s=kr(t),i=Ri(n,e,s)}return i.startAfterSet_=!0,i}function Oi(n,e,t){const i=n.copy();return i.endSet_=!0,e===void 0&&(e=null),i.indexEndValue_=e,t!==void 0?(i.endNameSet_=!0,i.indexEndName_=t):(i.endNameSet_=!1,i.indexEndName_=""),i}function xl(n,e,t){let i,s;return n.index_===Re?(typeof e=="string"&&(e=Dr(e)),s=Oi(n,e,t)):(t==null?i=Me:i=Dr(t),s=Oi(n,e,i)),s.endBeforeSet_=!0,s}function Sn(n,e){const t=n.copy();
949return t.index_=e,t}function Lr(n){const e={};if(n.isDefault())return e;let t;return n.index_===B?t="$priority":n.index_===Ii?t="$value":n.index_===Re?t="$key":(y(n.index_ instanceof xi,"Unrecognized index type!"),t=n.index_.toString()),e.orderBy=j(t),n.startSet_&&(e.startAt=j(n.indexStartValue_),n.startNameSet_&&(e.startAt+=","+j(n.indexStartName_))),n.endSet_&&(e.endAt=j(n.indexEndValue_),n.endNameSet_&&(e.endAt+=","+j(n.indexEndName_))),n.limitSet_&&(n.isViewFromLeft()?e.limitToFirst=n.limit_:e.limitToLast=n.limit_),e}function Fr(n){const e={};if(n.startSet_&&(e.sp=n.indexStartValue_,n.startNameSet_&&(e.sn=n.indexStartName_)),n.endSet_&&(e.ep=n.indexEndValue_,n.endNameSet_&&(e.en=n.indexEndName_)),n.limitSet_){e.l=n.limit_;let t=n.viewFrom_;t===""&&(n.isViewFromLeft()?t="l":t="r"),e.vf=t}return n.index_!==B&&(e.i=n.index_.toString()),e}/** 950 * @license 951 * Copyright 2017 Google LLC 952 * 953 * Licensed under the Apache License, Version 2.0 (the "License"); 954 * you may not use this file except in compliance with the License. 955 * You may obtain a copy of the License at 956 * 957 * http://www.apache.org/licenses/LICENSE-2.0 958 * 959 * Unless required by applicable law or agreed to in writing, software 960 * distributed under the License is distributed on an "AS IS" BASIS, 961 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 962 * See the License for the specific language governing permissions and 963 * limitations under the License. 964 */class Tn extends mr{constructor(e,t,i,s){super(),this.repoInfo_=e,this.onDataUpdate_=t,this.authTokenProvider_=i,this.appCheckTokenProvider_=s,this.log_=Lt("p:rest:"),this.listens_={}}reportStats(e){throw new Error("Method not implemented.")}static getListenId_(e,t){return t!==void 0?"tag$"+t:(y(e._queryParams.isDefault(),"should have a tag if it's not a default query."),e._path.toString())}listen(e,t,i,s){const r=e._path.toString();this.log_("Listen called for "+r+" "+e._queryIdentifier);const o=Tn.getListenId_(e,i),a={};this.listens_[o]=a;const c=Lr(e._queryParams);this.restRequest_(r+".json",c,(h,p)=>{let f=p;if(h===404&&(f=null,h=null),h===null&&this.onDataUpdate_(r,f,!1,i),ke(this.listens_,o)===a){let m;h?h===401?m="permission_denied":m="rest_error:"+h:m="ok",s(m,null)}})}unlisten(e,t){const i=Tn.getListenId_(e,t);delete this.listens_[i]}get(e){const t=Lr(e._queryParams),i=e._path.toString(),s=new q;return this.restRequest_(i+".json",t,(r,o)=>{let a=o;r===404&&(a=null,r=null),r===null?(this.onDataUpdate_(i,a,!1,null),s.resolve(a)):s.reject(new Error(a))}),s.promise}refreshAuthToken(e){}restRequest_(e,t={},i){return t.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then(([s,r])=>{s&&s.accessToken&&(t.auth=s.accessToken),r&&r.token&&(t.ac=r.token);const o=(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host+e+"?ns="+this.repoInfo_.namespace+Ls(t);this.log_("Sending REST request for "+o);const a=new XMLHttpRequest;a.onreadystatechange=()=>{if(i&&a.readyState===4){this.log_("REST Response for "+o+" received. status:",a.status,"response:",a.responseText);let c=null;if(a.status>=200&&a.status<300){try{c=ft(a.responseText)}catch{Z("Failed to parse JSON response for "+o+": "+a.responseText)}i(null,c)}else a.status!==401&&a.status!==404&&Z("Got unsuccessful REST response for "+o+" Status: "+a.status),i(a.status);i=null}},a.open("GET",o,!0),a.send()})}}/** 965 * @license 966 * Copyright 2017 Google LLC 967 * 968 * Licensed under the Apache License, Version 2.0 (the "License"); 969 * you may not use this file except in compliance with the License. 970 * You may obtain a copy of the License at 971 * 972 * http://www.apache.org/licenses/LICENSE-2.0 973 * 974 * Unless required by applicable law or agreed to in writing, software 975 * distributed under the License is distributed on an "AS IS" BASIS, 976 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 977 * See the License for the specific language governing permissions and 978 * limitations under the License. 979 */class Il{constructor(){this.rootNode_=w.EMPTY_NODE}getNode(e){return this.rootNode_.getChild(e)}updateSnapshot(e,t){this.rootNode_=this.rootNode_.updateChild(e,t)}}/** 980 * @license 981 * Copyright 2017 Google LLC 982 * 983 * Licensed under the Apache License, Version 2.0 (the "License");
984 * you may not use this file except in compliance with the License. 985 * You may obtain a copy of the License at 986 * 987 * http://www.apache.org/licenses/LICENSE-2.0 988 * 989 * Unless required by applicable law or agreed to in writing, software 990 * distributed under the License is distributed on an "AS IS" BASIS, 991 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 992 * See the License for the specific language governing permissions and 993 * limitations under the License. 994 */function xn(){return{value:null,children:new Map}}function wt(n,e,t){if(I(e))n.value=t,n.children.clear();else if(n.value!==null)n.value=n.value.updateChild(e,t);else{const i=x(e);n.children.has(i)||n.children.set(i,xn());const s=n.children.get(i);e=F(e),wt(s,e,t)}}function Pi(n,e){if(I(e))return n.value=null,n.children.clear(),!0;if(n.value!==null){if(n.value.isLeafNode())return!1;{const t=n.value;return n.value=null,t.forEachChild(B,(i,s)=>{wt(n,new k(i),s)}),Pi(n,e)}}else if(n.children.size>0){const t=x(e);return e=F(e),n.children.has(t)&&Pi(n.children.get(t),e)&&n.children.delete(t),n.children.size===0}else return!0}function ki(n,e,t){n.value!==null?t(e,n.value):Al(n,(i,s)=>{const r=new k(e.toString()+"/"+i);ki(s,r,t)})}function Al(n,e){n.children.forEach((t,i)=>{e(i,t)})}/** 995 * @license 996 * Copyright 2017 Google LLC 997 * 998 * Licensed under the Apache License, Version 2.0 (the "License"); 999 * you may not use this file except in compliance with the License. 1000 * You may obtain a copy of the License at 1001 * 1002 * http://www.apache.org/licenses/LICENSE-2.0 1003 * 1004 * Unless required by applicable law or agreed to in writing, software 1005 * distributed under the License is distributed on an "AS IS" BASIS, 1006 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1007 * See the License for the specific language governing permissions and 1008 * limitations under the License. 1009 */class Nl{constructor(e){this.collection_=e,this.last_=null}get(){const e=this.collection_.get(),t=Object.assign({},e);return this.last_&&G(this.last_,(i,s)=>{t[i]=t[i]-s}),this.last_=e,t}}/** 1010 * @license 1011 * Copyright 2017 Google LLC 1012 * 1013 * Licensed under the Apache License, Version 2.0 (the "License"); 1014 * you may not use this file except in compliance with the License. 1015 * You may obtain a copy of the License at 1016 * 1017 * http://www.apache.org/licenses/LICENSE-2.0 1018 * 1019 * Unless required by applicable law or agreed to in writing, software 1020 * distributed under the License is distributed on an "AS IS" BASIS, 1021 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1022 * See the License for the specific language governing permissions and 1023 * limitations under the License. 1024 */const Br=10*1e3,Rl=30*1e3,Ol=5*60*1e3;class Pl{constructor(e,t){this.server_=t,this.statsToReport_={},this.statsListener_=new Nl(e);const i=Br+(Rl-Br)*Math.random();Bt(this.reportStats_.bind(this),Math.floor(i))}reportStats_(){const e=this.statsListener_.get(),t={};let i=!1;G(e,(s,r)=>{r>0&&de(this.statsToReport_,s)&&(t[s]=r,i=!0)}),i&&this.server_.reportStats(t),Bt(this.reportStats_.bind(this),Math.floor(Math.random()*2*Ol))}}/** 1025 * @license 1026 * Copyright 2017 Google LLC 1027 * 1028 * Licensed under the Apache License, Version 2.0 (the "License"); 1029 * you may not use this file except in compliance with the License. 1030 * You may obtain a copy of the License at 1031 * 1032 * http://www.apache.org/licenses/LICENSE-2.0 1033 * 1034 * Unless required by applicable law or agreed to in writing, software 1035 * distributed under the License is distributed on an "AS IS" BASIS, 1036 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1037 * See the License for the specific language governing permissions and 1038 * limitations under the License. 1039 */var Ce;(function(n){n[n.OVERWRITE=0]="OVERWRITE",n[n.MERGE=1]="MERGE",n[n.ACK_USER_WRITE=2]="ACK_USER_WRITE",n[n.LISTEN_COMPLETE=3]="LISTEN_COMPLETE"})(Ce||(Ce={}));function Di(){return{fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}function Mi(){return{fromUser:!1,fromServer:!0,queryId:null,tagged:!1}}function Li(n){return{fromUser:!1,fromServer:!0,queryId:n,tagged:!0}}/** 1040 * @license 1041 * Copyright 2017 Google LLC 1042 * 1043 * Licensed under the Apache License, Version 2.0 (the "License");
1044 * you may not use this file except in compliance with the License. 1045 * You may obtain a copy of the License at 1046 * 1047 * http://www.apache.org/licenses/LICENSE-2.0 1048 * 1049 * Unless required by applicable law or agreed to in writing, software 1050 * distributed under the License is distributed on an "AS IS" BASIS, 1051 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1052 * See the License for the specific language governing permissions and 1053 * limitations under the License. 1054 */class In{constructor(e,t,i){this.path=e,this.affectedTree=t,this.revert=i,this.type=Ce.ACK_USER_WRITE,this.source=Di()}operationForChild(e){if(I(this.path)){if(this.affectedTree.value!=null)return y(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;{const t=this.affectedTree.subtree(new k(e));return new In(R(),t,this.revert)}}else return y(x(this.path)===e,"operationForChild called for unrelated child."),new In(F(this.path),this.affectedTree,this.revert)}}/** 1055 * @license 1056 * Copyright 2017 Google LLC 1057 * 1058 * Licensed under the Apache License, Version 2.0 (the "License"); 1059 * you may not use this file except in compliance with the License. 1060 * You may obtain a copy of the License at 1061 * 1062 * http://www.apache.org/licenses/LICENSE-2.0 1063 * 1064 * Unless required by applicable law or agreed to in writing, software 1065 * distributed under the License is distributed on an "AS IS" BASIS, 1066 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1067 * See the License for the specific language governing permissions and 1068 * limitations under the License. 1069 */class Qt{constructor(e,t){this.source=e,this.path=t,this.type=Ce.LISTEN_COMPLETE}operationForChild(e){return I(this.path)?new Qt(this.source,R()):new Qt(this.source,F(this.path))}}/** 1070 * @license 1071 * Copyright 2017 Google LLC 1072 * 1073 * Licensed under the Apache License, Version 2.0 (the "License"); 1074 * you may not use this file except in compliance with the License. 1075 * You may obtain a copy of the License at 1076 * 1077 * http://www.apache.org/licenses/LICENSE-2.0 1078 * 1079 * Unless required by applicable law or agreed to in writing, software 1080 * distributed under the License is distributed on an "AS IS" BASIS, 1081 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1082 * See the License for the specific language governing permissions and 1083 * limitations under the License. 1084 */class nt{constructor(e,t,i){this.source=e,this.path=t,this.snap=i,this.type=Ce.OVERWRITE}operationForChild(e){return I(this.path)?new nt(this.source,R(),this.snap.getImmediateChild(e)):new nt(this.source,F(this.path),this.snap)}}/** 1085 * @license 1086 * Copyright 2017 Google LLC 1087 * 1088 * Licensed under the Apache License, Version 2.0 (the "License"); 1089 * you may not use this file except in compliance with the License. 1090 * You may obtain a copy of the License at 1091 * 1092 * http://www.apache.org/licenses/LICENSE-2.0 1093 * 1094 * Unless required by applicable law or agreed to in writing, software 1095 * distributed under the License is distributed on an "AS IS" BASIS, 1096 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1097 * See the License for the specific language governing permissions and 1098 * limitations under the License. 1099 */class bt{constructor(e,t,i){this.source=e,this.path=t,this.children=i,this.type=Ce.MERGE}operationForChild(e){if(I(this.path)){const t=this.children.subtree(new k(e));return t.isEmpty()?null:t.value?new nt(this.source,R(),t.value):new bt(this.source,R(),t)}else return y(x(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new bt(this.source,F(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}/** 1100 * @license 1101 * Copyright 2017 Google LLC 1102 * 1103 * Licensed under the Apache License, Version 2.0 (the "License"); 1104 * you may not use this file except in compliance with the License. 1105 * You may obtain a copy of the License at 1106 * 1107 * http://www.apache.org/licenses/LICENSE-2.0 1108 * 1109 * Unless required by applicable law or agreed to in writing, software 1110 * distributed under the License is distributed on an "AS IS" BASIS, 1111 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1112 * See the License for the specific language governing permissions and 1113 * limitations under the License. 1114 */class Ve{constructor(e,t,i){this.node_=e,this.fullyInitialized_=t,this.filtered_=i}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(e){if(I(e))return this.isFullyInitialized()&&!this.filtered_;const t=x(e);return this.isCompleteForChild(t)}isCompleteForChild(e){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(e)}getNode(){return this.node_}}/** 1115 * @license 1116 * Copyright 2017 Google LLC 1117 * 1118 * Licensed under the Apache License, Version 2.0 (the "License");
1119 * you may not use this file except in compliance with the License. 1120 * You may obtain a copy of the License at 1121 * 1122 * http://www.apache.org/licenses/LICENSE-2.0 1123 * 1124 * Unless required by applicable law or agreed to in writing, software 1125 * distributed under the License is distributed on an "AS IS" BASIS, 1126 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1127 * See the License for the specific language governing permissions and 1128 * limitations under the License. 1129 */class kl{constructor(e){this.query_=e,this.index_=this.query_._queryParams.getIndex()}}function Dl(n,e,t,i){const s=[],r=[];return e.forEach(o=>{o.type==="child_changed"&&n.index_.indexedValueChanged(o.oldSnap,o.snapshotNode)&&r.push(El(o.childName,o.snapshotNode))}),$t(n,s,"child_removed",e,i,t),$t(n,s,"child_added",e,i,t),$t(n,s,"child_moved",r,i,t),$t(n,s,"child_changed",e,i,t),$t(n,s,"value",e,i,t),s}function $t(n,e,t,i,s,r){const o=i.filter(a=>a.type===t);o.sort((a,c)=>Ll(n,a,c)),o.forEach(a=>{const c=Ml(n,a,r);s.forEach(h=>{h.respondsTo(a.type)&&e.push(h.createEvent(c,n.query_))})})}function Ml(n,e,t){return e.type==="value"||e.type==="child_removed"||(e.prevName=t.getPredecessorChildName(e.childName,e.snapshotNode,n.index_)),e}function Ll(n,e,t){if(e.childName==null||t.childName==null)throw ye("Should only compare child_ events.");const i=new A(e.childName,e.snapshotNode),s=new A(t.childName,t.snapshotNode);return n.index_.compare(i,s)}/** 1130 * @license 1131 * Copyright 2017 Google LLC 1132 * 1133 * Licensed under the Apache License, Version 2.0 (the "License"); 1134 * you may not use this file except in compliance with the License. 1135 * You may obtain a copy of the License at 1136 * 1137 * http://www.apache.org/licenses/LICENSE-2.0 1138 * 1139 * Unless required by applicable law or agreed to in writing, software 1140 * distributed under the License is distributed on an "AS IS" BASIS, 1141 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1142 * See the License for the specific language governing permissions and 1143 * limitations under the License. 1144 */function An(n,e){return{eventCache:n,serverCache:e}}function Kt(n,e,t,i){return An(new Ve(e,t,i),n.serverCache)}function Wr(n,e,t,i){return An(n.eventCache,new Ve(e,t,i))}function Nn(n){return n.eventCache.isFullyInitialized()?n.eventCache.getNode():null}function it(n){return n.serverCache.isFullyInitialized()?n.serverCache.getNode():null}/** 1145 * @license 1146 * Copyright 2017 Google LLC 1147 * 1148 * Licensed under the Apache License, Version 2.0 (the "License"); 1149 * you may not use this file except in compliance with the License. 1150 * You may obtain a copy of the License at 1151 * 1152 * http://www.apache.org/licenses/LICENSE-2.0 1153 * 1154 * Unless required by applicable law or agreed to in writing, software 1155 * distributed under the License is distributed on an "AS IS" BASIS, 1156 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1157 * See the License for the specific language governing permissions and 1158 * limitations under the License. 1159 */let Fi;const Fl=()=>(Fi||(Fi=new se(Ca)),Fi);class W{constructor(e,t=Fl()){this.value=e,this.children=t}static fromObject(e){let t=new W(null);return G(e,(i,s)=>{t=t.set(new k(i),s)}),t}isEmpty(){return this.value===null&&this.children.isEmpty()}findRootMostMatchingPathAndValue(e,t){if(this.value!=null&&t(this.value))return{path:R(),value:this.value};if(I(e))return null;{const i=x(e),s=this.children.get(i);if(s!==null){const r=s.findRootMostMatchingPathAndValue(F(e),t);return r!=null?{path:U(new k(i),r.path),value:r.value}:null}else return null}}findRootMostValueAndPath(e){return this.findRootMostMatchingPathAndValue(e,()=>!0)}subtree(e){if(I(e))return this;{const t=x(e),i=this.children.get(t);return i!==null?i.subtree(F(e)):new W(null)}}set(e,t){if(I(e))return new W(t,this.children);{const i=x(e),r=(this.children.get(i)||new W(null)).set(F(e),t),o=this.children.insert(i,r);return new W(this.value,o)}}remove(e){if(I(e))return this.children.isEmpty()?new W(null):new W(null,this.children);{const t=x(e),i=this.children.get(t);if(i){const s=i.remove(F(e));let r;return s.isEmpty()?r=this.children.remove(t):r=this.children.insert(t,s),this.value===null&&r.isEmpty()?new W(null):new W(this.value,r)}else return this}}get(e){if(I(e))return this.value;{const t=x(e),i=this.children.get(t);return i?i.get(F(e)):null}}setTree(e,t){if(I(e))return t;{const i=x(e),r=(this.children.get(i)||new W(null)).setTree(F(e),t);let o;return r.isEmpty()?o=this.children.remove(i):o=this.children.insert(i,r),new W(this.value,o)}}fold(e){return this.fold_(R(),e)}fold_(e,t){const i={};return this.children.inorderTraversal((s,r)=>{i[s]=r.fold_(U(e,s),t)}),t(e,this.value,i)}findOnPath(e,t){return this.findOnPath_(e,R(),t)}findOnPath_(e,t,i){const s=this.value?i(t,this.value):!1;if(s)return s;if(I(e))return null;{const r=x(e),o=this.children.get(r);return o?o.findOnPath_(F(e),U(t,r),i):null}}foreachOnPath(e,t){return this.foreachOnPath_(e,R(),t)}foreachOnPath_(e,t,i){if(I(e))return this;{this.value&&i(t,this.value);const s=x(e),r=this.children.get(s);return r?r.foreachOnPath_(F(e),U(t,s),i):new W(null)}}foreach(e){this.foreach_(R(),e)}foreach_(e,t){this.children.inorderTraversal((i,s)=>{s.foreach_(U(e,i),t)}),this.value&&t(e,this.value)}foreachChild(e){this.children.inorderTraversal((t,i)=>{i.value&&e(t,i.value)})}}/** 1160 * @license 1161 * Copyright 2017 Google LLC 1162 * 1163 * Licensed under the Apache License, Version 2.0 (the "License");
1164 * you may not use this file except in compliance with the License. 1165 * You may obtain a copy of the License at 1166 * 1167 * http://www.apache.org/licenses/LICENSE-2.0 1168 * 1169 * Unless required by applicable law or agreed to in writing, software 1170 * distributed under the License is distributed on an "AS IS" BASIS, 1171 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1172 * See the License for the specific language governing permissions and 1173 * limitations under the License. 1174 */class we{constructor(e){this.writeTree_=e}static empty(){return new we(new W(null))}}function qt(n,e,t){if(I(e))return new we(new W(t));{const i=n.writeTree_.findRootMostValueAndPath(e);if(i!=null){const s=i.path;let r=i.value;const o=ie(s,e);return r=r.updateChild(o,t),new we(n.writeTree_.set(s,r))}else{const s=new W(t),r=n.writeTree_.setTree(e,s);return new we(r)}}}function Bi(n,e,t){let i=n;return G(t,(s,r)=>{i=qt(i,U(e,s),r)}),i}function Ur(n,e){if(I(e))return we.empty();{const t=n.writeTree_.setTree(e,new W(null));return new we(t)}}function Wi(n,e){return st(n,e)!=null}function st(n,e){const t=n.writeTree_.findRootMostValueAndPath(e);return t!=null?n.writeTree_.get(t.path).getChild(ie(t.path,e)):null}function Vr(n){const e=[],t=n.writeTree_.value;return t!=null?t.isLeafNode()||t.forEachChild(B,(i,s)=>{e.push(new A(i,s))}):n.writeTree_.children.inorderTraversal((i,s)=>{s.value!=null&&e.push(new A(i,s.value))}),e}function je(n,e){if(I(e))return n;{const t=st(n,e);return t!=null?new we(new W(t)):new we(n.writeTree_.subtree(e))}}function Ui(n){return n.writeTree_.isEmpty()}function St(n,e){return jr(R(),n.writeTree_,e)}function jr(n,e,t){if(e.value!=null)return t.updateChild(n,e.value);{let i=null;return e.children.inorderTraversal((s,r)=>{s===".priority"?(y(r.value!==null,"Priority writes must always be leaf nodes"),i=r.value):t=jr(U(n,s),r,t)}),!t.getChild(n).isEmpty()&&i!==null&&(t=t.updateChild(U(n,".priority"),i)),t}}/** 1175 * @license 1176 * Copyright 2017 Google LLC 1177 * 1178 * Licensed under the Apache License, Version 2.0 (the "License"); 1179 * you may not use this file except in compliance with the License. 1180 * You may obtain a copy of the License at 1181 * 1182 * http://www.apache.org/licenses/LICENSE-2.0 1183 * 1184 * Unless required by applicable law or agreed to in writing, software 1185 * distributed under the License is distributed on an "AS IS" BASIS, 1186 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1187 * See the License for the specific language governing permissions and 1188 * limitations under the License. 1189 */function Rn(n,e){return $r(e,n)}function Bl(n,e,t,i,s){y(i>n.lastWriteId,"Stacking an older write on top of newer ones"),s===void 0&&(s=!0),n.allWrites.push({path:e,snap:t,writeId:i,visible:s}),s&&(n.visibleWrites=qt(n.visibleWrites,e,t)),n.lastWriteId=i}function Wl(n,e,t,i){y(i>n.lastWriteId,"Stacking an older merge on top of newer ones"),n.allWrites.push({path:e,children:t,writeId:i,visible:!0}),n.visibleWrites=Bi(n.visibleWrites,e,t),n.lastWriteId=i}function Ul(n,e){for(let t=0;t<n.allWrites.length;t++){const i=n.allWrites[t];if(i.writeId===e)return i}return null}function Vl(n,e){const t=n.allWrites.findIndex(a=>a.writeId===e);y(t>=0,"removeWrite called with nonexistent writeId.");const i=n.allWrites[t];n.allWrites.splice(t,1);let s=i.visible,r=!1,o=n.allWrites.length-1;for(;s&&o>=0;){const a=n.allWrites[o];a.visible&&(o>=t&&jl(a,i.path)?s=!1:pe(i.path,a.path)&&(r=!0)),o--}if(s){if(r)return Hl(n),!0;if(i.snap)n.visibleWrites=Ur(n.visibleWrites,i.path);else{const a=i.children;G(a,c=>{n.visibleWrites=Ur(n.visibleWrites,U(i.path,c))})}return!0}else return!1}function jl(n,e){if(n.snap)return pe(n.path,e);for(const t in n.children)if(n.children.hasOwnProperty(t)&&pe(U(n.path,t),e))return!0;return!1}function Hl(n){n.visibleWrites=Hr(n.allWrites,zl,R()),n.allWrites.length>0?n.lastWriteId=n.allWrites[n.allWrites.length-1].writeId:n.lastWriteId=-1}function zl(n){return n.visible}function Hr(n,e,t){let i=we.empty();for(let s=0;s<n.length;++s){const r=n[s];if(e(r)){const o=r.path;let a;if(r.snap)pe(t,o)?(a=ie(t,o),i=qt(i,a,r.snap)):pe(o,t)&&(a=ie(o,t),i=qt(i,R(),r.snap.getChild(a)));else if(r.children){if(pe(t,o))a=ie(t,o),i=Bi(i,a,r.children);else if(pe(o,t))if(a=ie(o,t),I(a))i=Bi(i,R(),r.children);else{const c=ke(r.children,x(a));if(c){const h=c.getChild(F(a));i=qt(i,R(),h)}}}else throw ye("WriteRecord should have .snap or .children")}}return i}function zr(n,e,t,i,s){if(!i&&!s){const r=st(n.visibleWrites,e);if(r!=null)return r;{const o=je(n.visibleWrites,e);if(Ui(o))return t;if(t==null&&!Wi(o,R()))return null;{const a=t||w.EMPTY_NODE;return St(o,a)}}}else{const r=je(n.visibleWrites,e);if(!s&&Ui(r))return t;if(!s&&t==null&&!Wi(r,R()))return null;
1189{const o=function(h){return(h.visible||s)&&(!i||!~i.indexOf(h.writeId))&&(pe(h.path,e)||pe(e,h.path))},a=Hr(n.allWrites,o,e),c=t||w.EMPTY_NODE;return St(a,c)}}}function Gl(n,e,t){let i=w.EMPTY_NODE;const s=st(n.visibleWrites,e);if(s)return s.isLeafNode()||s.forEachChild(B,(r,o)=>{i=i.updateImmediateChild(r,o)}),i;if(t){const r=je(n.visibleWrites,e);return t.forEachChild(B,(o,a)=>{const c=St(je(r,new k(o)),a);i=i.updateImmediateChild(o,c)}),Vr(r).forEach(o=>{i=i.updateImmediateChild(o.name,o.node)}),i}else{const r=je(n.visibleWrites,e);return Vr(r).forEach(o=>{i=i.updateImmediateChild(o.name,o.node)}),i}}function Ql(n,e,t,i,s){y(i||s,"Either existingEventSnap or existingServerSnap must exist");const r=U(e,t);if(Wi(n.visibleWrites,r))return null;{const o=je(n.visibleWrites,r);return Ui(o)?s.getChild(t):St(o,s.getChild(t))}}function $l(n,e,t,i){const s=U(e,t),r=st(n.visibleWrites,s);if(r!=null)return r;if(i.isCompleteForChild(t)){const o=je(n.visibleWrites,s);return St(o,i.getNode().getImmediateChild(t))}else return null}function Kl(n,e){return st(n.visibleWrites,e)}function ql(n,e,t,i,s,r,o){let a;const c=je(n.visibleWrites,e),h=st(c,R());if(h!=null)a=h;else if(t!=null)a=St(c,t);else return[];if(a=a.withIndex(o),!a.isEmpty()&&!a.isLeafNode()){const p=[],f=o.getCompare(),m=r?a.getReverseIteratorFrom(i,o):a.getIteratorFrom(i,o);let v=m.getNext();for(;v&&p.length<s;)f(v,i)!==0&&p.push(v),v=m.getNext();return p}else return[]}function Yl(){return{visibleWrites:we.empty(),allWrites:[],lastWriteId:-1}}function On(n,e,t,i){return zr(n.writeTree,n.treePath,e,t,i)}function Vi(n,e){return Gl(n.writeTree,n.treePath,e)}function Gr(n,e,t,i){return Ql(n.writeTree,n.treePath,e,t,i)}function Pn(n,e){return Kl(n.writeTree,U(n.treePath,e))}function Jl(n,e,t,i,s,r){return ql(n.writeTree,n.treePath,e,t,i,s,r)}function ji(n,e,t){return $l(n.writeTree,n.treePath,e,t)}function Qr(n,e){return $r(U(n.treePath,e),n.writeTree)}function $r(n,e){return{treePath:n,writeTree:e}}/** 1190 * @license 1191 * Copyright 2017 Google LLC 1192 * 1193 * Licensed under the Apache License, Version 2.0 (the "License"); 1194 * you may not use this file except in compliance with the License. 1195 * You may obtain a copy of the License at 1196 * 1197 * http://www.apache.org/licenses/LICENSE-2.0 1198 * 1199 * Unless required by applicable law or agreed to in writing, software 1200 * distributed under the License is distributed on an "AS IS" BASIS, 1201 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1202 * See the License for the specific language governing permissions and 1203 * limitations under the License. 1204 */class Xl{constructor(){this.changeMap=new Map}trackChildChange(e){const t=e.type,i=e.childName;y(t==="child_added"||t==="child_changed"||t==="child_removed","Only child changes supported for tracking"),y(i!==".priority","Only non-priority child changes can be tracked.");const s=this.changeMap.get(i);if(s){const r=s.type;if(t==="child_added"&&r==="child_removed")this.changeMap.set(i,zt(i,e.snapshotNode,s.snapshotNode));else if(t==="child_removed"&&r==="child_added")this.changeMap.delete(i);else if(t==="child_removed"&&r==="child_changed")this.changeMap.set(i,Ht(i,s.oldSnap));else if(t==="child_changed"&&r==="child_added")this.changeMap.set(i,Ct(i,e.snapshotNode));else if(t==="child_changed"&&r==="child_changed")this.changeMap.set(i,zt(i,e.snapshotNode,s.oldSnap));else throw ye("Illegal combination of changes: "+e+" occurred after "+s)}else this.changeMap.set(i,e)}getChanges(){return Array.from(this.changeMap.values())}}/** 1205 * @license 1206 * Copyright 2017 Google LLC 1207 * 1208 * Licensed under the Apache License, Version 2.0 (the "License"); 1209 * you may not use this file except in compliance with the License. 1210 * You may obtain a copy of the License at 1211 * 1212 * http://www.apache.org/licenses/LICENSE-2.0 1213 * 1214 * Unless required by applicable law or agreed to in writing, software 1215 * distributed under the License is distributed on an "AS IS" BASIS, 1216 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1217 * See the License for the specific language governing permissions and 1218 * limitations under the License. 1219 */class Zl{getCompleteChild(e){return null}getChildAfterChild(e,t,i){return null}}const Kr=new Zl;class Hi{constructor(e,t,i=null){this.writes_=e,this.viewCache_=t,this.optCompleteServerCache_=i}getCompleteChild(e){const t=this.viewCache_.eventCache;if(t.isCompleteForChild(e))return t.getNode().getImmediateChild(e);{const i=this.optCompleteServerCache_!=null?new Ve(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return ji(this.writes_,e,i)}}getChildAfterChild(e,t,i){const s=this.optCompleteServerCache_!=null?this.optCompleteServerCache_:it(this.viewCache_),r=Jl(this.writes_,s,t,1,i,e);return r.length===0?null:r[0]}}/** 1220 * @license 1221 * Copyright 2017 Google LLC 1222 * 1223 * Licensed under the Apache License, Version 2.0 (the "License");
1224 * you may not use this file except in compliance with the License. 1225 * You may obtain a copy of the License at 1226 * 1227 * http://www.apache.org/licenses/LICENSE-2.0 1228 * 1229 * Unless required by applicable law or agreed to in writing, software 1230 * distributed under the License is distributed on an "AS IS" BASIS, 1231 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1232 * See the License for the specific language governing permissions and 1233 * limitations under the License. 1234 */function ec(n){return{filter:n}}function tc(n,e){y(e.eventCache.getNode().isIndexed(n.filter.getIndex()),"Event snap not indexed"),y(e.serverCache.getNode().isIndexed(n.filter.getIndex()),"Server snap not indexed")}function nc(n,e,t,i,s){const r=new Xl;let o,a;if(t.type===Ce.OVERWRITE){const h=t;h.source.fromUser?o=zi(n,e,h.path,h.snap,i,s,r):(y(h.source.fromServer,"Unknown source."),a=h.source.tagged||e.serverCache.isFiltered()&&!I(h.path),o=kn(n,e,h.path,h.snap,i,s,a,r))}else if(t.type===Ce.MERGE){const h=t;h.source.fromUser?o=sc(n,e,h.path,h.children,i,s,r):(y(h.source.fromServer,"Unknown source."),a=h.source.tagged||e.serverCache.isFiltered(),o=Gi(n,e,h.path,h.children,i,s,a,r))}else if(t.type===Ce.ACK_USER_WRITE){const h=t;h.revert?o=ac(n,e,h.path,i,s,r):o=rc(n,e,h.path,h.affectedTree,i,s,r)}else if(t.type===Ce.LISTEN_COMPLETE)o=oc(n,e,t.path,i,r);else throw ye("Unknown operation type: "+t.type);const c=r.getChanges();return ic(e,o,c),{viewCache:o,changes:c}}function ic(n,e,t){const i=e.eventCache;if(i.isFullyInitialized()){const s=i.getNode().isLeafNode()||i.getNode().isEmpty(),r=Nn(n);(t.length>0||!n.eventCache.isFullyInitialized()||s&&!i.getNode().equals(r)||!i.getNode().getPriority().equals(r.getPriority()))&&t.push(Mr(Nn(e)))}}function qr(n,e,t,i,s,r){const o=e.eventCache;if(Pn(i,t)!=null)return e;{let a,c;if(I(t))if(y(e.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),e.serverCache.isFiltered()){const h=it(e),p=h instanceof w?h:w.EMPTY_NODE,f=Vi(i,p);a=n.filter.updateFullNode(e.eventCache.getNode(),f,r)}else{const h=On(i,it(e));a=n.filter.updateFullNode(e.eventCache.getNode(),h,r)}else{const h=x(t);if(h===".priority"){y(Ue(t)===1,"Can't have a priority with additional path components");const p=o.getNode();c=e.serverCache.getNode();const f=Gr(i,t,p,c);f!=null?a=n.filter.updatePriority(p,f):a=o.getNode()}else{const p=F(t);let f;if(o.isCompleteForChild(h)){c=e.serverCache.getNode();const m=Gr(i,t,o.getNode(),c);m!=null?f=o.getNode().getImmediateChild(h).updateChild(p,m):f=o.getNode().getImmediateChild(h)}else f=ji(i,h,e.serverCache);f!=null?a=n.filter.updateChild(o.getNode(),h,f,p,s,r):a=o.getNode()}}return Kt(e,a,o.isFullyInitialized()||I(t),n.filter.filtersNodes())}}function kn(n,e,t,i,s,r,o,a){const c=e.serverCache;let h;const p=o?n.filter:n.filter.getIndexedFilter();if(I(t))h=p.updateFullNode(c.getNode(),i,null);else if(p.filtersNodes()&&!c.isFiltered()){const v=c.getNode().updateChild(t,i);h=p.updateFullNode(c.getNode(),v,null)}else{const v=x(t);if(!c.isCompleteForPath(t)&&Ue(t)>1)return e;const C=F(t),J=c.getNode().getImmediateChild(v).updateChild(C,i);v===".priority"?h=p.updatePriority(c.getNode(),J):h=p.updateChild(c.getNode(),v,J,C,Kr,null)}
1234const f=Wr(e,h,c.isFullyInitialized()||I(t),p.filtersNodes()),m=new Hi(s,f,r);return qr(n,f,t,s,m,a)}function zi(n,e,t,i,s,r,o){const a=e.eventCache;let c,h;const p=new Hi(s,e,r);if(I(t))h=n.filter.updateFullNode(e.eventCache.getNode(),i,o),c=Kt(e,h,!0,n.filter.filtersNodes());else{const f=x(t);if(f===".priority")h=n.filter.updatePriority(e.eventCache.getNode(),i),c=Kt(e,h,a.isFullyInitialized(),a.isFiltered());else{const m=F(t),v=a.getNode().getImmediateChild(f);let C;if(I(m))C=i;else{const M=p.getCompleteChild(f);M!=null?Ei(m)===".priority"&&M.getChild(Cr(m)).isEmpty()?C=M:C=M.updateChild(m,i):C=w.EMPTY_NODE}if(v.equals(C))c=e;else{const M=n.filter.updateChild(a.getNode(),f,C,m,p,o);c=Kt(e,M,a.isFullyInitialized(),n.filter.filtersNodes())}}}return c}function Yr(n,e){return n.eventCache.isCompleteForChild(e)}function sc(n,e,t,i,s,r,o){let a=e;return i.foreach((c,h)=>{const p=U(t,c);Yr(e,x(p))&&(a=zi(n,a,p,h,s,r,o))}),i.foreach((c,h)=>{const p=U(t,c);Yr(e,x(p))||(a=zi(n,a,p,h,s,r,o))}),a}function Jr(n,e,t){return t.foreach((i,s)=>{e=e.updateChild(i,s)}),e}function Gi(n,e,t,i,s,r,o,a){if(e.serverCache.getNode().isEmpty()&&!e.serverCache.isFullyInitialized())return e;let c=e,h;I(t)?h=i:h=new W(null).setTree(t,i);const p=e.serverCache.getNode();return h.children.inorderTraversal((f,m)=>{if(p.hasChild(f)){const v=e.serverCache.getNode().getImmediateChild(f),C=Jr(n,v,m);c=kn(n,c,new k(f),C,s,r,o,a)}}),h.children.inorderTraversal((f,m)=>{const v=!e.serverCache.isCompleteForChild(f)&&m.value===null;if(!p.hasChild(f)&&!v){const C=e.serverCache.getNode().getImmediateChild(f),M=Jr(n,C,m);c=kn(n,c,new k(f),M,s,r,o,a)}}),c}function rc(n,e,t,i,s,r,o){if(Pn(s,t)!=null)return e;const a=e.serverCache.isFiltered(),c=e.serverCache;if(i.value!=null){if(I(t)&&c.isFullyInitialized()||c.isCompleteForPath(t))return kn(n,e,t,c.getNode().getChild(t),s,r,a,o);if(I(t)){let h=new W(null);return c.getNode().forEachChild(Re,(p,f)=>{h=h.set(new k(p),f)}),Gi(n,e,t,h,s,r,a,o)}else return e}else{let h=new W(null);return i.foreach((p,f)=>{const m=U(t,p);c.isCompleteForPath(m)&&(h=h.set(p,c.getNode().getChild(m)))}),Gi(n,e,t,h,s,r,a,o)}}function oc(n,e,t,i,s){const r=e.serverCache,o=Wr(e,r.getNode(),r.isFullyInitialized()||I(t),r.isFiltered());return qr(n,o,t,i,Kr,s)}function ac(n,e,t,i,s,r){let o;if(Pn(i,t)!=null)return e;{const a=new Hi(i,e,s),c=e.eventCache.getNode();let h;if(I(t)||x(t)===".priority"){let p;if(e.serverCache.isFullyInitialized())p=On(i,it(e));else{const f=e.serverCache.getNode();y(f instanceof w,"serverChildren would be complete if leaf node"),p=Vi(i,f)}p=p,h=n.filter.updateFullNode(c,p,r)}else{const p=x(t);let f=ji(i,p,e.serverCache);f==null&&e.serverCache.isCompleteForChild(p)&&(f=c.getImmediateChild(p)),f!=null?h=n.filter.updateChild(c,p,f,F(t),a,r):e.eventCache.getNode().hasChild(p)?h=n.filter.updateChild(c,p,w.EMPTY_NODE,F(t),a,r):h=c,h.isEmpty()&&e.serverCache.isFullyInitialized()&&(o=On(i,it(e)),o.isLeafNode()&&(h=n.filter.updateFullNode(h,o,r)))}return o=e.serverCache.isFullyInitialized()||Pn(i,R())!=null,Kt(e,h,o,n.filter.filtersNodes())}}/** 1235 * @license 1236 * Copyright 2017 Google LLC 1237 * 1238 * Licensed under the Apache License, Version 2.0 (the "License"); 1239 * you may not use this file except in compliance with the License. 1240 * You may obtain a copy of the License at 1241 * 1242 * http://www.apache.org/licenses/LICENSE-2.0 1243 * 1244 * Unless required by applicable law or agreed to in writing, software 1245 * distributed under the License is distributed on an "AS IS" BASIS, 1246 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1247 * See the License for the specific language governing permissions and 1248 * limitations under the License. 1249 */class lc{constructor(e,t){this.query_=e,this.eventRegistrations_=[];const i=this.query_._queryParams,s=new Ni(i.getIndex()),r=wl(i);this.processor_=ec(r);const o=t.serverCache,a=t.eventCache,c=s.updateFullNode(w.EMPTY_NODE,o.getNode(),null),h=r.updateFullNode(w.EMPTY_NODE,a.getNode(),null),p=new Ve(c,o.isFullyInitialized(),s.filtersNodes()),f=new Ve(h,a.isFullyInitialized(),r.filtersNodes());this.viewCache_=An(f,p),this.eventGenerator_=new kl(this.query_)}get query(){return this.query_}}function cc(n){return n.viewCache_.serverCache.getNode()}function hc(n){return Nn(n.viewCache_)}function uc(n,e){const t=it(n.viewCache_);return t&&(n.query._queryParams.loadsAllData()||!I(e)&&!t.getImmediateChild(x(e)).isEmpty())?t.getChild(e):null}function Xr(n){return n.eventRegistrations_.length===0}function dc(n,e){n.eventRegistrations_.push(e)}function Zr(n,e,t){const i=[];if(t){y(e==null,"A cancel should cancel all event registrations.");const s=n.query._path;n.eventRegistrations_.forEach(r=>{const o=r.createCancelEvent(t,s);o&&i.push(o)})}if(e){let s=[];for(let r=0;r<n.eventRegistrations_.length;++r){const o=n.eventRegistrations_[r];if(!o.matches(e))s.push(o);else if(e.hasAnyCallback()){s=s.concat(n.eventRegistrations_.slice(r+1));break}}n.eventRegistrations_=s}else n.eventRegistrations_=[];return i}function eo(n,e,t,i){e.type===Ce.MERGE&&e.source.queryId!==null&&(y(it(n.viewCache_),"We should always have a full c
1249ache before handling merges"),y(Nn(n.viewCache_),"Missing event cache, even though we have a server cache"));const s=n.viewCache_,r=nc(n.processor_,s,e,t,i);return tc(n.processor_,r.viewCache),y(r.viewCache.serverCache.isFullyInitialized()||!s.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),n.viewCache_=r.viewCache,to(n,r.changes,r.viewCache.eventCache.getNode(),null)}function fc(n,e){const t=n.viewCache_.eventCache,i=[];return t.getNode().isLeafNode()||t.getNode().forEachChild(B,(r,o)=>{i.push(Ct(r,o))}),t.isFullyInitialized()&&i.push(Mr(t.getNode())),to(n,i,t.getNode(),e)}function to(n,e,t,i){const s=i?[i]:n.eventRegistrations_;return Dl(n.eventGenerator_,e,t,s)}/** 1250 * @license 1251 * Copyright 2017 Google LLC 1252 * 1253 * Licensed under the Apache License, Version 2.0 (the "License"); 1254 * you may not use this file except in compliance with the License. 1255 * You may obtain a copy of the License at 1256 * 1257 * http://www.apache.org/licenses/LICENSE-2.0 1258 * 1259 * Unless required by applicable law or agreed to in writing, software 1260 * distributed under the License is distributed on an "AS IS" BASIS, 1261 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1262 * See the License for the specific language governing permissions and 1263 * limitations under the License. 1264 */let Dn;class no{constructor(){this.views=new Map}}function _c(n){y(!Dn,"__referenceConstructor has already been defined"),Dn=n}function pc(){return y(Dn,"Reference.ts has not been loaded"),Dn}function gc(n){return n.views.size===0}function Qi(n,e,t,i){const s=e.source.queryId;if(s!==null){const r=n.views.get(s);return y(r!=null,"SyncTree gave us an op for an invalid query."),eo(r,e,t,i)}else{let r=[];for(const o of n.views.values())r=r.concat(eo(o,e,t,i));return r}}function io(n,e,t,i,s){const r=e._queryIdentifier,o=n.views.get(r);if(!o){let a=On(t,s?i:null),c=!1;a?c=!0:i instanceof w?(a=Vi(t,i),c=!1):(a=w.EMPTY_NODE,c=!1);const h=An(new Ve(a,c,!1),new Ve(i,s,!1));return new lc(e,h)}return o}function mc(n,e,t,i,s,r){const o=io(n,e,i,s,r);return n.views.has(e._queryIdentifier)||n.views.set(e._queryIdentifier,o),dc(o,t),fc(o,t)}function yc(n,e,t,i){const s=e._queryIdentifier,r=[];let o=[];const a=ze(n);if(s==="default")for(const[c,h]of n.views.entries())o=o.concat(Zr(h,t,i)),Xr(h)&&(n.views.delete(c),h.query._queryParams.loadsAllData()||r.push(h.query));else{const c=n.views.get(s);c&&(o=o.concat(Zr(c,t,i)),Xr(c)&&(n.views.delete(s),c.query._queryParams.loadsAllData()||r.push(c.query)))}return a&&!ze(n)&&r.push(new(pc())(e._repo,e._path)),{removed:r,events:o}}function so(n){const e=[];for(const t of n.views.values())t.query._queryParams.loadsAllData()||e.push(t);return e}function He(n,e){let t=null;for(const i of n.views.values())t=t||uc(i,e);return t}function ro(n,e){if(e._queryParams.loadsAllData())return Mn(n);{const i=e._queryIdentifier;return n.views.get(i)}}function oo(n,e){return ro(n,e)!=null}function ze(n){return Mn(n)!=null}function Mn(n){for(const e of n.views.values())if(e.query._queryParams.loadsAllData())return e;return null}/** 1265 * @license 1266 * Copyright 2017 Google LLC 1267 * 1268 * Licensed under the Apache License, Version 2.0 (the "License"); 1269 * you may not use this file except in compliance with the License. 1270 * You may obtain a copy of the License at 1271 * 1272 * http://www.apache.org/licenses/LICENSE-2.0 1273 * 1274 * Unless required by applicable law or agreed to in writing, software 1275 * distributed under the License is distributed on an "AS IS" BASIS, 1276 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1277 * See the License for the specific language governing permissions and 1278 * limitations under the License. 1279 */let Ln;function vc(n){y(!Ln,"__referenceConstructor has already been defined"),Ln=n}function Ec(){return y(Ln,"Reference.ts has not been loaded"),Ln}let Cc=1;class ao{constructor(e){this.listenProvider_=e,this.syncPointTree_=new W(null),this.pendingWriteTree_=Yl(),this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function $i(n,e,t,i,s){return Bl(n.pendingWriteTree_,e,t,i,s),s?Tt(n,new nt(Di(),e,t)):[]}function wc(n,e,t,i){Wl(n.pendingWriteTree_,e,t,i);const s=W.fromObject(t);return Tt(n,new bt(Di(),e,s))}function Ge(n,e,t=!1){const i=Ul(n.pendingWriteTree_,e);if(Vl(n.pendingWriteTree_,e)){let r=new W(null);return i.snap!=null?r=r.set(R(),!0):G(i.children,o=>{r=r.set(new k(o),!0)}),Tt(n,new In(i.path,r,t))}else return[]}function Yt(n,e,t){return Tt(n,new nt(Mi(),e,t))}function bc(n,e,t){const i=W.fromObject(t);return Tt(n,new bt(Mi(),e,i))}function Sc(n,e){return Tt(n,new Qt(Mi(),e))}function Tc(n,e,t){const i=qi(n,t);if(i){const s=Yi(i),r=s.path,o=s.queryId,a=ie(r,e),c=new Qt(Li(o),a);return Ji(n,r,c)}else return[]}function Fn(n,e,t,i,s=!1){const r=e._path,o=n.syncPointTree_.get(r);let a=[];if(o&&(e._queryIdentifier==="default"||oo(o,e))){const c=yc(o,e,t,i);gc(o)&&(n.syncPointTree_=n.syncPointTree_.remove(r));const h=c.removed;if(a=c.events,!s){const p=h.findIndex(m=>m._queryParams.loadsAllData())!==-1,f=n.syncPointTree_.findOnPath(r,(m,v)=>ze(v));if(p&&!f){const m=n.syncPointTree_.subtree(r);if(!m.isEmpty()){const v=Ac(m);for(let C=0;C<v.length;++C){const M=v[C],J=M.query,At=uo(n,M);
1279n.listenProvider_.startListening(Xt(J),Jt(n,J),At.hashFn,At.onComplete)}}}!f&&h.length>0&&!i&&(p?n.listenProvider_.stopListening(Xt(e),null):h.forEach(m=>{const v=n.queryToTagMap.get(Wn(m));n.listenProvider_.stopListening(Xt(m),v)}))}Nc(n,h)}return a}function lo(n,e,t,i){const s=qi(n,i);if(s!=null){const r=Yi(s),o=r.path,a=r.queryId,c=ie(o,e),h=new nt(Li(a),c,t);return Ji(n,o,h)}else return[]}function xc(n,e,t,i){const s=qi(n,i);if(s){const r=Yi(s),o=r.path,a=r.queryId,c=ie(o,e),h=W.fromObject(t),p=new bt(Li(a),c,h);return Ji(n,o,p)}else return[]}function Ki(n,e,t,i=!1){const s=e._path;let r=null,o=!1;n.syncPointTree_.foreachOnPath(s,(m,v)=>{const C=ie(m,s);r=r||He(v,C),o=o||ze(v)});let a=n.syncPointTree_.get(s);a?(o=o||ze(a),r=r||He(a,R())):(a=new no,n.syncPointTree_=n.syncPointTree_.set(s,a));let c;r!=null?c=!0:(c=!1,r=w.EMPTY_NODE,n.syncPointTree_.subtree(s).foreachChild((v,C)=>{const M=He(C,R());M&&(r=r.updateImmediateChild(v,M))}));const h=oo(a,e);if(!h&&!e._queryParams.loadsAllData()){const m=Wn(e);y(!n.queryToTagMap.has(m),"View does not exist, but we have a tag");const v=Rc();n.queryToTagMap.set(m,v),n.tagToQueryMap.set(v,m)}const p=Rn(n.pendingWriteTree_,s);let f=mc(a,e,t,p,r,c);if(!h&&!o&&!i){const m=ro(a,e);f=f.concat(Oc(n,e,m))}return f}function Bn(n,e,t){const s=n.pendingWriteTree_,r=n.syncPointTree_.findOnPath(e,(o,a)=>{const c=ie(o,e),h=He(a,c);if(h)return h});return zr(s,e,r,t,!0)}function Ic(n,e){const t=e._path;let i=null;n.syncPointTree_.foreachOnPath(t,(h,p)=>{const f=ie(h,t);i=i||He(p,f)});let s=n.syncPointTree_.get(t);s?i=i||He(s,R()):(s=new no,n.syncPointTree_=n.syncPointTree_.set(t,s));const r=i!=null,o=r?new Ve(i,!0,!1):null,a=Rn(n.pendingWriteTree_,e._path),c=io(s,e,a,r?o.getNode():w.EMPTY_NODE,r);return hc(c)}function Tt(n,e){return co(e,n.syncPointTree_,null,Rn(n.pendingWriteTree_,R()))}function co(n,e,t,i){if(I(n.path))return ho(n,e,t,i);{const s=e.get(R());t==null&&s!=null&&(t=He(s,R()));let r=[];const o=x(n.path),a=n.operationForChild(o),c=e.children.get(o);if(c&&a){const h=t?t.getImmediateChild(o):null,p=Qr(i,o);r=r.concat(co(a,c,h,p))}return s&&(r=r.concat(Qi(s,n,i,t))),r}}function ho(n,e,t,i){const s=e.get(R());t==null&&s!=null&&(t=He(s,R()));let r=[];return e.children.inorderTraversal((o,a)=>{const c=t?t.getImmediateChild(o):null,h=Qr(i,o),p=n.operationForChild(o);p&&(r=r.concat(ho(p,a,c,h)))}),s&&(r=r.concat(Qi(s,n,i,t))),r}function uo(n,e){const t=e.query,i=Jt(n,t);return{hashFn:()=>(cc(e)||w.EMPTY_NODE).hash(),onComplete:s=>{if(s==="ok")return i?Tc(n,t._path,i):Sc(n,t._path);{const r=Sa(s,t);return Fn(n,t,null,r)}}}}function Jt(n,e){const t=Wn(e);return n.queryToTagMap.get(t)}function Wn(n){return n._path.toString()+"$"+n._queryIdentifier}function qi(n,e){return n.tagToQueryMap.get(e)}function Yi(n){const e=n.indexOf("$");return y(e!==-1&&e<n.length-1,"Bad queryKey."),{queryId:n.substr(e+1),path:new k(n.substr(0,e))}}function Ji(n,e,t){const i=n.syncPointTree_.get(e);y(i,"Missing sync point for query tag that we're tracking");const s=Rn(n.pendingWriteTree_,e);return Qi(i,t,s,null)}function Ac(n){return n.fold((e,t,i)=>{if(t&&ze(t))return[Mn(t)];{let s=[];return t&&(s=so(t)),G(i,(r,o)=>{s=s.concat(o)}),s}})}
1279function Xt(n){return n._queryParams.loadsAllData()&&!n._queryParams.isDefault()?new(Ec())(n._repo,n._path):n}function Nc(n,e){for(let t=0;t<e.length;++t){const i=e[t];if(!i._queryParams.loadsAllData()){const s=Wn(i),r=n.queryToTagMap.get(s);n.queryToTagMap.delete(s),n.tagToQueryMap.delete(r)}}}function Rc(){return Cc++}function Oc(n,e,t){const i=e._path,s=Jt(n,e),r=uo(n,t),o=n.listenProvider_.startListening(Xt(e),s,r.hashFn,r.onComplete),a=n.syncPointTree_.subtree(i);if(s)y(!ze(a.value),"If we're adding a query, it shouldn't be shadowed");else{const c=a.fold((h,p,f)=>{if(!I(h)&&p&&ze(p))return[Mn(p).query];{let m=[];return p&&(m=m.concat(so(p).map(v=>v.query))),G(f,(v,C)=>{m=m.concat(C)}),m}});for(let h=0;h<c.length;++h){const p=c[h];n.listenProvider_.stopListening(Xt(p),Jt(n,p))}}return o}/** 1280 * @license 1281 * Copyright 2017 Google LLC 1282 * 1283 * Licensed under the Apache License, Version 2.0 (the "License"); 1284 * you may not use this file except in compliance with the License. 1285 * You may obtain a copy of the License at 1286 * 1287 * http://www.apache.org/licenses/LICENSE-2.0 1288 * 1289 * Unless required by applicable law or agreed to in writing, software 1290 * distributed under the License is distributed on an "AS IS" BASIS, 1291 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1292 * See the License for the specific language governing permissions and 1293 * limitations under the License. 1294 */class Xi{constructor(e){this.node_=e}getImmediateChild(e){const t=this.node_.getImmediateChild(e);return new Xi(t)}node(){return this.node_}}class Zi{constructor(e,t){this.syncTree_=e,this.path_=t}getImmediateChild(e){const t=U(this.path_,e);return new Zi(this.syncTree_,t)}node(){return Bn(this.syncTree_,this.path_)}}const Pc=function(n){return n=n||{},n.timestamp=n.timestamp||new Date().getTime(),n},fo=function(n,e,t){if(!n||typeof n!="object")return n;if(y(".sv"in n,"Unexpected leaf node or priority contents"),typeof n[".sv"]=="string")return kc(n[".sv"],e,t);if(typeof n[".sv"]=="object")return Dc(n[".sv"],e);y(!1,"Unexpected server value: "+JSON.stringify(n,null,2))},kc=function(n,e,t){switch(n){case"timestamp":return t.timestamp;default:y(!1,"Unexpected server value: "+n)}},Dc=function(n,e,t){n.hasOwnProperty("increment")||y(!1,"Unexpected server value: "+JSON.stringify(n,null,2));const i=n.increment;typeof i!="number"&&y(!1,"Unexpected increment value: "+i);const s=e.node();if(y(s!==null&&typeof s<"u","Expected ChildrenNode.EMPTY_NODE for nulls"),!s.isLeafNode())return i;const o=s.getValue();return typeof o!="number"?i:o+i},_o=function(n,e,t,i){return ts(e,new Zi(t,n),i)},es=function(n,e,t){return ts(n,new Xi(e),t)};function ts(n,e,t){const i=n.getPriority().val(),s=fo(i,e.getImmediateChild(".priority"),t);let r;if(n.isLeafNode()){const o=n,a=fo(o.getValue(),e,t);return a!==o.getValue()||s!==o.getPriority().val()?new $(a,V(s)):n}else{const o=n;return r=o,s!==o.getPriority().val()&&(r=r.updatePriority(new $(s))),o.forEachChild(B,(a,c)=>{const h=ts(c,e.getImmediateChild(a),t);h!==c&&(r=r.updateImmediateChild(a,h))}),r}}/** 1295 * @license 1296 * Copyright 2017 Google LLC 1297 * 1298 * Licensed under the Apache License, Version 2.0 (the "License"); 1299 * you may not use this file except in compliance with the License. 1300 * You may obtain a copy of the License at 1301 * 1302 * http://www.apache.org/licenses/LICENSE-2.0 1303 * 1304 * Unless required by applicable law or agreed to in writing, software 1305 * distributed under the License is distributed on an "AS IS" BASIS, 1306 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1307 * See the License for the specific language governing permissions and 1308 * limitations under the License. 1309 */class ns{constructor(e="",t=null,i={children:{},childCount:0}){this.name=e,this.parent=t,this.node=i}}function Un(n,e){let t=e instanceof k?e:new k(e),i=n,s=x(t);for(;s!==null;){const r=ke(i.node.children,s)||{children:{},childCount:0};i=new ns(s,i,r),t=F(t),s=x(t)}return i}function rt(n){return n.node.value}function is(n,e){n.node.value=e,ss(n)}function po(n){return n.node.childCount>0}function Mc(n){return rt(n)===void 0&&!po(n)}function Vn(n,e){G(n.node.children,(t,i)=>{e(new ns(t,n,i))})}function go(n,e,t,i){t&&!i&&e(n),Vn(n,s=>{go(s,e,!0,i)}),t&&i&&e(n)}function Lc(n,e,t){let i=t?n:n.parent;for(;i!==null;){if(e(i))return!0;
vendor: 4,360 bytes, lines 1309-1324
1309i=i.parent}return!1}function Zt(n){return new k(n.parent===null?n.name:Zt(n.parent)+"/"+n.name)}function ss(n){n.parent!==null&&Fc(n.parent,n.name,n)}function Fc(n,e,t){const i=Mc(t),s=de(n.node.children,e);i&&s?(delete n.node.children[e],n.node.childCount--,ss(n)):!i&&!s&&(n.node.children[e]=t.node,n.node.childCount++,ss(n))}/** 1310 * @license 1311 * Copyright 2017 Google LLC 1312 * 1313 * Licensed under the Apache License, Version 2.0 (the "License"); 1314 * you may not use this file except in compliance with the License. 1315 * You may obtain a copy of the License at 1316 * 1317 * http://www.apache.org/licenses/LICENSE-2.0 1318 * 1319 * Unless required by applicable law or agreed to in writing, software 1320 * distributed under the License is distributed on an "AS IS" BASIS, 1321 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1322 * See the License for the specific language governing permissions and 1323 * limitations under the License. 1324 */const Bc=/[\[\].#$\/\u0000-\u001F\u007F]/,Wc=/[\[\].#$\u0000-\u001F\u007F]/,rs=10*1024*1024,jn=function(n){return typeof n=="string"&&n.length!==0&&!Bc.test(n)},mo=function(n){return typeof n=="string"&&n.length!==0&&!Wc.test(n)},Uc=function(n){return n&&(n=n.replace(/^\/*\.info(\/|$)/,"/")),mo(n)},en=function(n){return n===null||typeof n=="string"||typeof n=="number"&&!_n(n)||n&&typeof n=="object"&&de(n,".sv")},Oe=function(n,e,t,i){i&&e===void 0||tn(ve(n,"value"),e,t)},tn=function(n,e,t){const i=t instanceof k?new tl(t,n):t;if(e===void 0)throw new Error(n+"contains undefined "+tt(i));if(typeof e=="function")throw new Error(n+"contains a function "+tt(i)+" with contents = "+e.toString());if(_n(e))throw new Error(n+"contains "+e.toString()+" "+tt(i));if(typeof e=="string"&&e.length>rs/3&&pt(e)>rs)throw new Error(n+"contains a string greater than "+rs+" utf8 bytes "+tt(i)+" ('"+e.substring(0,50)+"...')");if(e&&typeof e=="object"){let s=!1,r=!1;if(G(e,(o,a)=>{if(o===".value")s=!0;else if(o!==".priority"&&o!==".sv"&&(r=!0,!jn(o)))throw new Error(n+" contains an invalid key ("+o+") "+tt(i)+`. Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"`);nl(i,o),tn(n,a,i),il(i)}),s&&r)throw new Error(n+' contains ".value" child '+tt(i)+" in addition to actual children.")}},Vc=function(n,e){let t,i;for(t=0;t<e.length;t++){i=e[t];const r=Wt(i);for(let o=0;o<r.length;o++)if(!(r[o]===".priority"&&o===r.length-1)){if(!jn(r[o]))throw new Error(n+"contains an invalid key ("+r[o]+") in path "+i.toString()+`. Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"`)}}e.sort(el);let s=null;for(t=0;t<e.length;t++){if(i=e[t],s!==null&&pe(s,i))throw new Error(n+"contains a path "+s.toString()+" that is ancestor of another path "+i.toString());s=i}},yo=function(n,e,t,i){if(i&&e===void 0)return;const s=ve(n,"values");if(!(e&&typeof e=="object")||Array.isArray(e))throw new Error(s+" must be an object containing the children to replace.");const r=[];G(e,(o,a)=>{const c=new k(o);if(tn(s,a,U(t,c)),Ei(c)===".priority"&&!en(a))throw new Error(s+"contains an invalid value for '"+c.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");r.push(c)}),Vc(s,r)},os=function(n,e,t){if(!(t&&e===void 0)){if(_n(e))throw new Error(ve(n,"priority")+"is "+e.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!en(e))throw new Error(ve(n,"priority")+"must be a valid Firebase priority (a string, finite number, server value, or null).")}},nn=function(n,e,t,i){if(!(i&&t===void 0)&&!jn(t))throw new Error(ve(n,e)+'was an invalid key = "'+t+`". Firebase keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]").`)},sn=function(n,e,t,i){if(!(i&&t===void 0)&&!mo(t))throw new Error(ve(n,e)+'was an invalid path = "'+t+`". Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]"`)},jc=function(n,e,t,i){t&&(t=t.replace(/^\/*\.info(\/|$)/,"/")),sn(n,e,t,i)},ge=function(n,e){if(x(e)===".info")throw new Error(n+" failed = Can't modify data under /.info/")},vo=function(n,e){const t=e.path.toString();if(typeof e.repoInfo.host!="string"||e.repoInfo.host.length===0||!jn(e.repoInfo.namespace)&&e.repoInfo.host.split(":")[0]!=="localhost"||t.length!==0&&!Uc(t))throw new Error(ve(n,"url")+`must be a valid firebase URL and the path can't
1324contain ".", "#", "$", "[", or "]".`)};/** 1325 * @license 1326 * Copyright 2017 Google LLC 1327 * 1328 * Licensed under the Apache License, Version 2.0 (the "License"); 1329 * you may not use this file except in compliance with the License. 1330 * You may obtain a copy of the License at 1331 * 1332 * http://www.apache.org/licenses/LICENSE-2.0 1333 * 1334 * Unless required by applicable law or agreed to in writing, software 1335 * distributed under the License is distributed on an "AS IS" BASIS, 1336 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1337 * See the License for the specific language governing permissions and 1338 * limitations under the License. 1339 */class Hc{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function Hn(n,e){let t=null;for(let i=0;i<e.length;i++){const s=e[i],r=s.getPath();t!==null&&!Ci(r,t.path)&&(n.eventLists_.push(t),t=null),t===null&&(t={events:[],path:r}),t.events.push(s)}t&&n.eventLists_.push(t)}function Eo(n,e,t){Hn(n,t),Co(n,i=>Ci(i,e))}function le(n,e,t){Hn(n,t),Co(n,i=>pe(i,e)||pe(e,i))}function Co(n,e){n.recursionDepth_++;let t=!0;for(let i=0;i<n.eventLists_.length;i++){const s=n.eventLists_[i];if(s){const r=s.path;e(r)?(zc(n.eventLists_[i]),n.eventLists_[i]=null):t=!1}}t&&(n.eventLists_=[]),n.recursionDepth_--}function zc(n){for(let e=0;e<n.events.length;e++){const t=n.events[e];if(t!==null){n.events[e]=null;const i=t.getEventRunner();fe&&z("event: "+t.toString()),gt(i)}}}/** 1340 * @license 1341 * Copyright 2017 Google LLC 1342 * 1343 * Licensed under the Apache License, Version 2.0 (the "License"); 1344 * you may not use this file except in compliance with the License. 1345 * You may obtain a copy of the License at 1346 * 1347 * http://www.apache.org/licenses/LICENSE-2.0 1348 * 1349 * Unless required by applicable law or agreed to in writing, software 1350 * distributed under the License is distributed on an "AS IS" BASIS, 1351 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1352 * See the License for the specific language governing permissions and 1353 * limitations under the License. 1354 */const wo="repo_interrupt",Gc=25;class Qc{constructor(e,t,i,s){this.repoInfo_=e,this.forceRestClient_=t,this.authTokenProvider_=i,this.appCheckProvider_=s,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new Hc,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=xn(),this.transactionQueueTree_=new ns,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}function $c(n,e,t){if(n.stats_=mi(n.repoInfo_),n.forceRestClient_||xa())n.server_=new Tn(n.repoInfo_,(i,s,r,o)=>{So(n,i,s,r,o)},n.authTokenProvider_,n.appCheckProvider_),setTimeout(()=>To(n,!0),0);else{if(typeof t<"u"&&t!==null){if(typeof t!="object")throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{j(t)}catch(i){throw new Error("Invalid authOverride provided: "+i)}}n.persistentConnection_=new ae(n.repoInfo_,e,(i,s,r,o)=>{So(n,i,s,r,o)},i=>{To(n,i)},i=>{Kc(n,i)},n.authTokenProvider_,n.appCheckProvider_,t),n.server_=n.persistentConnection_}n.authTokenProvider_.addTokenChangeListener(i=>{n.server_.refreshAuthToken(i)}),n.appCheckProvider_.addTokenChangeListener(i=>{n.server_.refreshAppCheckToken(i.token)}),n.statsReporter_=Oa(n.repoInfo_,()=>new Pl(n.stats_,n.server_)),n.infoData_=new Il,n.infoSyncTree_=new ao({startListening:(i,s,r,o)=>{let a=[];const c=n.infoData_.getNode(i._path);return c.isEmpty()||(a=Yt(n.infoSyncTree_,i._path,c),setTimeout(()=>{o("ok")},0)),a},stopListening:()=>{}}),as(n,"connected",!1),n.serverSyncTree_=new ao({startListening:(i,s,r,o)=>(n.server_.listen(i,r,s,(a,c)=>{const h=o(a,c);le(n.eventQueue_,i._path,h)}),[]),stopListening:(i,s)=>{n.server_.unlisten(i,s)}})}function bo(n){const t=n.infoData_.getNode(new k(".info/serverTimeOffset")).val()||0;return new Date().getTime()+t}function rn(n){return Pc({timestamp:bo(n)})}function So(n,e,t,i,s){n.dataUpdateCount++;const r=new k(e);t=n.interceptServerDataCallback_?n.interceptServerDataCallback_(e,t):t;let o=[];if(s)if(i){const c=Pt(t,h=>V(h));o=xc(n.serverSyncTree_,r,c,s)}else{const c=V(t);o=lo(n.serverSyncTree_,r,c,s)}else if(i){const c=Pt(t,h=>V(h));o=bc(n.serverSyncTree_,r,c)}else{const c=V(t);o=Yt(n.serverSyncTree_,r,c)}let a=r;o.length>0&&(a=It(n,r)),le(n.eventQueue_,a,o)}function To(n,e){as(n,"connected",e),e===!1&&Jc(n)}function Kc(n,e){G(e,(t,i)=>{as(n,t,i)})}function as(n,e,t){const i=new k("/.info/"+e),s=V(t);n.infoData_.updateSnapshot(i,s);const r=Yt(n.infoSyncTree_,i,s);le(n.eventQueue_,i,r)}function zn(n){return n.nextWriteId_++}function qc(n,e,t){const i=Ic(n.serverSyncTree_,e);return i!=null?Promise.resolve(i):n.server_.get(e).then(s=>{const r=V(s).withIndex(e._queryParams.getIndex());Ki(n.serverSyncTree_,e,t,!0);let o;if(e._queryParams.loadsAllData())o=Yt(n.serverSyncTree_,e._path,r);else{const a=Jt(n.serverSyncTree_,e);o=lo(n.serverSyncTree_,e._path,r,a)}return le(n.eventQueue_,e._path,o),Fn(n.serverSyncTree_,e,t,null,!0),r},s=>(xt(n,"get for query "+j(e)+" failed: "+s),Promise.reject(new Error(s))))}function ls(n,e,t,i,s){xt(n,"set",{path:e.toString(),value:t,priority:i});const r=rn(n),o=V(t,i),a=Bn(n.serverSyncTree_,e),c=es(o,a,r),h=zn(n),p=$i(n.serverSyncTree_,e,c,h,!0);Hn(n.eventQueue_,p),n.server_.put(e.toString(),o.val(!0),(m,v)=>{const C=m==="ok";C||Z("set at "+e+" failed: "+m);const M=Ge(n.serverSyncTree_,h,!C);le(n.eventQueue_,e,M),Qe(n,s,m,v)});const f=us(n,e);It(n,f),le(n.eventQueue_,f,[])}function Yc(n,e,t,i){xt(n,"update",{path:e.toString(),value:t});let s=!0;const r=rn(n),o={};if(G(t,(a,c)=>{s=!1,o[a]=_o(U(e,a),V(c),n.serverSyncTree_,r)}),s)z("update() called with empty data. Don't do anything."),Qe(n,i,"ok",void 0);else{const a=zn(n),c=wc(n.serverSyncTree_,e,o,a);Hn(n.eventQueue_,c),n.server_.merge(e.toString(),t,(h,p)=>{const f=h==="ok";f||Z("update at "+e+" failed: "+h);const m=Ge(n.serverSyncTree_,a,!f),v=m.length>0?It(n,e):e;le(n.eventQueue_,v,m),Qe(n,i,h,p)}),G(t,h=>{const p=us(n,U(e,h));It(n,p)}),le(n.eventQueue_,e,[])}}
1354function Jc(n){xt(n,"onDisconnectEvents");const e=rn(n),t=xn();ki(n.onDisconnect_,R(),(s,r)=>{const o=_o(s,r,n.serverSyncTree_,e);wt(t,s,o)});let i=[];ki(t,R(),(s,r)=>{i=i.concat(Yt(n.serverSyncTree_,s,r));const o=us(n,s);It(n,o)}),n.onDisconnect_=xn(),le(n.eventQueue_,R(),i)}function Xc(n,e,t){n.server_.onDisconnectCancel(e.toString(),(i,s)=>{i==="ok"&&Pi(n.onDisconnect_,e),Qe(n,t,i,s)})}function xo(n,e,t,i){const s=V(t);n.server_.onDisconnectPut(e.toString(),s.val(!0),(r,o)=>{r==="ok"&&wt(n.onDisconnect_,e,s),Qe(n,i,r,o)})}function Zc(n,e,t,i,s){const r=V(t,i);n.server_.onDisconnectPut(e.toString(),r.val(!0),(o,a)=>{o==="ok"&&wt(n.onDisconnect_,e,r),Qe(n,s,o,a)})}function eh(n,e,t,i){if(_t(t)){z("onDisconnect().update() called with empty data. Don't do anything."),Qe(n,i,"ok",void 0);return}n.server_.onDisconnectMerge(e.toString(),t,(s,r)=>{s==="ok"&&G(t,(o,a)=>{const c=V(a);wt(n.onDisconnect_,U(e,o),c)}),Qe(n,i,s,r)})}function th(n,e,t){let i;x(e._path)===".info"?i=Ki(n.infoSyncTree_,e,t):i=Ki(n.serverSyncTree_,e,t),Eo(n.eventQueue_,e._path,i)}function cs(n,e,t){let i;x(e._path)===".info"?i=Fn(n.infoSyncTree_,e,t):i=Fn(n.serverSyncTree_,e,t),Eo(n.eventQueue_,e._path,i)}function Io(n){n.persistentConnection_&&n.persistentConnection_.interrupt(wo)}function nh(n){n.persistentConnection_&&n.persistentConnection_.resume(wo)}function xt(n,...e){let t="";n.persistentConnection_&&(t=n.persistentConnection_.id+":"),z(t,...e)}function Qe(n,e,t,i){e&>(()=>{if(t==="ok")e(null);else{const s=(t||"error").toUpperCase();let r=s;i&&(r+=": "+i);const o=new Error(r);o.code=s,e(o)}})}function ih(n,e,t,i,s,r){xt(n,"transaction on "+e);const o={path:e,update:t,onComplete:i,status:null,order:Ee(),applyLocally:r,retryCount:0,unwatcher:s,abortReason:null,currentWriteId:null,currentInputSnapshot:null,currentOutputSnapshotRaw:null,currentOutputSnapshotResolved:null},a=hs(n,e,void 0);o.currentInputSnapshot=a;const c=o.update(a.val());if(c===void 0)o.unwatcher(),o.currentOutputSnapshotRaw=null,o.currentOutputSnapshotResolved=null,o.onComplete&&o.onComplete(null,!1,o.currentInputSnapshot);else{tn("transaction failed: Data returned ",c,o.path),o.status=0;const h=Un(n.transactionQueueTree_,e),p=rt(h)||[];p.push(o),is(h,p);let f;typeof c=="object"&&c!==null&&de(c,".priority")?(f=ke(c,".priority"),y(en(f),"Invalid priority returned by transaction. Priority must be a valid string, finite number, server value, or null.")):f=(Bn(n.serverSyncTree_,e)||w.EMPTY_NODE).getPriority().val();const m=rn(n),v=V(c,f),C=es(v,a,m);o.currentOutputSnapshotRaw=v,o.currentOutputSnapshotResolved=C,o.currentWriteId=zn(n);const M=$i(n.serverSyncTree_,e,C,o.currentWriteId,o.applyLocally);le(n.eventQueue_,e,M),Gn(n,n.transactionQueueTree_)}}function hs(n,e,t){return Bn(n.serverSyncTree_,e,t)||w.EMPTY_NODE}function Gn(n,e=n.transactionQueueTree_){if(e||Qn(n,e),rt(e)){const t=No(n,e);y(t.length>0,"Sending zero length transaction queue"),t.every(s=>s.status===0)&&sh(n,Zt(e),t)}else po(e)&&Vn(e,t=>{Gn(n,t)})}function sh(n,e,t){const i=t.map(h=>h.currentWriteId),s=hs(n,e,i);let r=s;const o=s.hash();for(let h=0;h<t.length;h++){const p=t[h];y(p.status===0,"tryToSendTransactionQueue_: items in queue should all be run."),p.status=1,p.retryCount++;const f=ie(e,p.path);r=r.updateChild(f,p.currentOutputSnapshotRaw)}const a=r.val(!0),c=e;n.server_.put(c.toString(),a,h=>{xt(n,"transaction put response",{path:c.toString(),status:h});let p=[];if(h==="ok"){const f=[];for(let m=0;m<t.length;m++)t[m].status=2,p=p.concat(Ge(n.serverSyncTree_,t[m].currentWriteId)),t[m].onComplete&&f.push(()=>t[m].onComplete(null,!0,t[m].currentOutputSnapshotResolved)),t[m].unwatcher();Qn(n,Un(n.transactionQueueTree_,e)),Gn(n,n.transactionQueueTree_),le(n.eventQueue_,e,p);for(let m=0;m<f.length;m++)gt(f[m])}else{if(h==="datastale")for(let f=0;f<t.length;f++)t[f].status===3?t[f].status=4:t[f].status=0;else{Z("transaction at "+c.toString()+" failed: "+h);for(let f=0;f<t.length;f++)t[f].status=4,t[f].abortReason=h}It(n,e)}},o)}function It(n,e){const t=Ao(n,e),i=Zt(t),s=No(n,t);return rh(n,s,i),i}function rh(n,e,t){if(e.length===0)return;const i=[];let s=[];const o=e.filter(a=>a.status===0).map(a=>a.currentWriteId);for(let a=0;a<e.length;a++){const c=e[a],h=ie(t,c.path);let p=!1,f;if(y(h!==null,"rerunTransactionsUnderNode_: relativePath should not be null."),c.status===4)p=!0,f=c.abortReason,s=s.concat(Ge(n.serverSyncTree_,c.currentWriteId,!0));else if(c.status===0)if(c.retryCount>=Gc)p=!0,f="maxretry",s=s.concat(Ge(n.serverSyncTree_,c.currentWriteId,!0));else{const m=hs(n,c.path,o);c.currentInputSnapshot=m;const v=e[a].update(m.val());if(v!==void 0){tn("transaction failed: Data returned ",v,c.path);let C=V(v);typeof v=="object"&&v!=null&&de(v,".priority")||(C=C.updatePriority(m.getPriority()));const J=c.currentWriteId,At=rn(n),Xn=es(C,m,At);c.currentOutputSnapshotRaw=C,c.currentOutputSnapshotResolved=Xn,c.currentWriteId=zn(n),o.splice(o.indexOf(J),1),s=s.concat($i(n.serverSyncTree_,c.path,Xn,c.currentWriteId,c.applyLocally)),s=s.concat(Ge(n.serverSyncTree_,J,!0))}
1354else p=!0,f="nodata",s=s.concat(Ge(n.serverSyncTree_,c.currentWriteId,!0))}le(n.eventQueue_,t,s),s=[],p&&(e[a].status=2,function(m){setTimeout(m,Math.floor(0))}(e[a].unwatcher),e[a].onComplete&&(f==="nodata"?i.push(()=>e[a].onComplete(null,!1,e[a].currentInputSnapshot)):i.push(()=>e[a].onComplete(new Error(f),!1,null))))}Qn(n,n.transactionQueueTree_);for(let a=0;a<i.length;a++)gt(i[a]);Gn(n,n.transactionQueueTree_)}function Ao(n,e){let t,i=n.transactionQueueTree_;for(t=x(e);t!==null&&rt(i)===void 0;)i=Un(i,t),e=F(e),t=x(e);return i}function No(n,e){const t=[];return Ro(n,e,t),t.sort((i,s)=>i.order-s.order),t}function Ro(n,e,t){const i=rt(e);if(i)for(let s=0;s<i.length;s++)t.push(i[s]);Vn(e,s=>{Ro(n,s,t)})}function Qn(n,e){const t=rt(e);if(t){let i=0;for(let s=0;s<t.length;s++)t[s].status!==2&&(t[i]=t[s],i++);t.length=i,is(e,t.length>0?t:void 0)}Vn(e,i=>{Qn(n,i)})}function us(n,e){const t=Zt(Ao(n,e)),i=Un(n.transactionQueueTree_,e);return Lc(i,s=>{ds(n,s)}),ds(n,i),go(i,s=>{ds(n,s)}),t}function ds(n,e){const t=rt(e);if(t){const i=[];let s=[],r=-1;for(let o=0;o<t.length;o++)t[o].status===3||(t[o].status===1?(y(r===o-1,"All SENT items should be at beginning of queue."),r=o,t[o].status=3,t[o].abortReason="set"):(y(t[o].status===0,"Unexpected transaction status in abort"),t[o].unwatcher(),s=s.concat(Ge(n.serverSyncTree_,t[o].currentWriteId,!0)),t[o].onComplete&&i.push(t[o].onComplete.bind(null,new Error("set"),!1,null))));r===-1?is(e,void 0):t.length=r+1,le(n.eventQueue_,Zt(e),s);for(let o=0;o<i.length;o++)gt(i[o])}}/** 1355 * @license 1356 * Copyright 2017 Google LLC 1357 * 1358 * Licensed under the Apache License, Version 2.0 (the "License"); 1359 * you may not use this file except in compliance with the License. 1360 * You may obtain a copy of the License at 1361 * 1362 * http://www.apache.org/licenses/LICENSE-2.0 1363 * 1364 * Unless required by applicable law or agreed to in writing, software 1365 * distributed under the License is distributed on an "AS IS" BASIS, 1366 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1367 * See the License for the specific language governing permissions and 1368 * limitations under the License. 1369 */function oh(n){let e="";const t=n.split("/");for(let i=0;i<t.length;i++)if(t[i].length>0){let s=t[i];try{s=decodeURIComponent(s.replace(/\+/g," "))}catch{}e+="/"+s}return e}function ah(n){const e={};n.charAt(0)==="?"&&(n=n.substring(1));for(const t of n.split("&")){if(t.length===0)continue;const i=t.split("=");i.length===2?e[decodeURIComponent(i[0])]=decodeURIComponent(i[1]):Z(`Invalid query segment '${t}' in query '${n}'`)}return e}const fs=function(n,e){const t=lh(n),i=t.namespace;t.domain==="firebase.com"&&Ae(t.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),(!i||i==="undefined")&&t.domain!=="localhost"&&Ae("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),t.secure||va();const s=t.scheme==="ws"||t.scheme==="wss";return{repoInfo:new _i(t.host,t.secure,i,s,e,"",i!==t.subdomain),path:new k(t.pathString)}},lh=function(n){let e="",t="",i="",s="",r="",o=!0,a="https",c=443;if(typeof n=="string"){let h=n.indexOf("//");h>=0&&(a=n.substring(0,h-1),n=n.substring(h+2));let p=n.indexOf("/");p===-1&&(p=n.length);let f=n.indexOf("?");f===-1&&(f=n.length),e=n.substring(0,Math.min(p,f)),p<f&&(s=oh(n.substring(p,f)));const m=ah(n.substring(Math.min(n.length,f)));h=e.indexOf(":"),h>=0?(o=a==="https"||a==="wss",c=parseInt(e.substring(h+1),10)):h=e.length;const v=e.slice(0,h);if(v.toLowerCase()==="localhost")t="localhost";else if(v.split(".").length<=2)t=v;else{const C=e.indexOf(".");i=e.substring(0,C).toLowerCase(),t=e.substring(C+1),r=i}"ns"in m&&(r=m.ns)}return{host:e,port:c,domain:t,subdomain:i,secure:o,scheme:a,pathString:s,namespace:r}};/** 1370 * @license 1371 * Copyright 2017 Google LLC 1372 * 1373 * Licensed under the Apache License, Version 2.0 (the "License"); 1374 * you may not use this file except in compliance with the License. 1375 * You may obtain a copy of the License at 1376 * 1377 * http://www.apache.org/licenses/LICENSE-2.0 1378 * 1379 * Unless required by applicable law or agreed to in writing, softw
1379are 1380 * distributed under the License is distributed on an "AS IS" BASIS, 1381 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1382 * See the License for the specific language governing permissions and 1383 * limitations under the License. 1384 */class Oo{constructor(e,t,i,s){this.eventType=e,this.eventRegistration=t,this.snapshot=i,this.prevName=s}getPath(){const e=this.snapshot.ref;return this.eventType==="value"?e._path:e.parent._path}getEventType(){return this.eventType}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.getPath().toString()+":"+this.eventType+":"+j(this.snapshot.exportVal())}}class Po{constructor(e,t,i){this.eventRegistration=e,this.error=t,this.path=i}getPath(){return this.path}getEventType(){return"cancel"}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.path.toString()+":cancel"}}/** 1385 * @license 1386 * Copyright 2017 Google LLC 1387 * 1388 * Licensed under the Apache License, Version 2.0 (the "License"); 1389 * you may not use this file except in compliance with the License. 1390 * You may obtain a copy of the License at 1391 * 1392 * http://www.apache.org/licenses/LICENSE-2.0 1393 * 1394 * Unless required by applicable law or agreed to in writing, software 1395 * distributed under the License is distributed on an "AS IS" BASIS, 1396 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1397 * See the License for the specific language governing permissions and 1398 * limitations under the License. 1399 */class _s{constructor(e,t){this.snapshotCallback=e,this.cancelCallback=t}onValue(e,t){this.snapshotCallback.call(null,e,t)}onCancel(e){return y(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||this.snapshotCallback.userCallback!==void 0&&this.snapshotCallback.userCallback===e.snapshotCallback.userCallback&&this.snapshotCallback.context===e.snapshotCallback.context}}/** 1400 * @license 1401 * Copyright 2021 Google LLC 1402 * 1403 * Licensed under the Apache License, Version 2.0 (the "License"); 1404 * you may not use this file except in compliance with the License. 1405 * You may obtain a copy of the License at 1406 * 1407 * http://www.apache.org/licenses/LICENSE-2.0 1408 * 1409 * Unless required by applicable law or agreed to in writing, software 1410 * distributed under the License is distributed on an "AS IS" BASIS, 1411 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1412 * See the License for the specific language governing permissions and 1413 * limitations under the License. 1414 */class ko{constructor(e,t){this._repo=e,this._path=t}cancel(){const e=new q;return Xc(this._repo,this._path,e.wrapCallback(()=>{})),e.promise}remove(){ge("OnDisconnect.remove",this._path);const e=new q;return xo(this._repo,this._path,null,e.wrapCallback(()=>{})),e.promise}set(e){ge("OnDisconnect.set",this._path),Oe("OnDisconnect.set",e,this._path,!1);const t=new q;return xo(this._repo,this._path,e,t.wrapCallback(()=>{})),t.promise}setWithPriority(e,t){ge("OnDisconnect.setWithPriority",this._path),Oe("OnDisconnect.setWithPriority",e,this._path,!1),os("OnDisconnect.setWithPriority",t,!1);const i=new q;return Zc(this._repo,this._path,e,t,i.wrapCallback(()=>{})),i.promise}update(e){ge("OnDisconnect.update",this._path),yo("OnDisconnect.update",e,this._path,!1);const t=new q;return eh(this._repo,this._path,e,t.wrapCallback(()=>{})),t.promise}}/** 1415 * @license 1416 * Copyright 2020 Google LLC 1417 * 1418 * Licensed under the Apache License, Version 2.0 (the "License"); 1419 * you may not use this file except in compliance with the License. 1420 * You may obtain a copy of the License at 1421 * 1422 * http://www.apache.org/licenses/LICENSE-2.0 1423 * 1424 * Unless required by applicable law or agreed to in writing, software 1425 * distributed under the License is distributed on an "AS IS" BASIS, 1426 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1427 * See the License for the specific language governing permissions and 1428 * limitations under the License. 1429 */class re{constructor(e,t,i,s){this._repo=e,this._path=t,this._queryParams=i,this._orderByCalled=s}get key(){return I(this._path)?null:Ei(this._path)}get ref(){return new me(this._repo,this._path)}get _queryIdentifier(){const e=Fr(this._queryParams),t=ui(e);return t==="{}"?"default":t}get _queryObject(){return Fr(this._queryParams)}isEqual(e){if(e=X(e),!(e instanceof re))return!1;const t=this._repo===e._repo,i=Ci(this._path,e._path),s=this._queryIdentifier===e._queryIdentifier;return t&&i&&s}toJSON(){return this.toString()}toString(){return this._repo.toString()+Za(this._path)}}function $n(n,e){if(n._orderByCalled===!0)throw new Error(e+": You can't combine multiple orderBy calls.")}function $e(n){let e=null,t=null;if(n.hasStart()&&(e=n.getIndexStartValue()),n.hasEnd()&&(t=n.getIndexEndValue()),n.getIndex()===Re){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(n.hasStart()){if(n.getIndexStartName()!==Me)throw new Error(i);if(typeof e!="string")throw new Error(s)}if(n.hasEnd()){if(n.getIndexEndName()!==Ne)throw new Error(i);if(typeof t!="string")throw new Error(s)}}else if(n.getIndex()===B){if(e!=null&&!en(e)||t!=null&&!en(t))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(y(n.getIndex()instanceof xi||n.getIndex()===Ii,"unknown index type."),e!=null&&typeof e=="object"||t!=null&&typeof t=="object")throw new Error("Query: First argument passed to startAt(), startAfter(), endAt(), endBefore(), or equalTo() cannot be an object.")}function Kn(n){if(n.hasStart()&&n.hasEnd()&&n.hasLimit()&&!n.hasAnchoredLimit())throw new Error("Query: Can't combine startAt(), startAfter(), endAt(), endBefore(), and limit(). Use limitToFirst() or limitToLast() instead.")}class me extends re{constructor(e,t){super(e,t,new bn,!1)}get parent(){const e=Cr(this._path);return e===null?null:new me(this._repo,e)}get root(){let e=this;for(;e.parent!==null;)e=e.parent;return e}}
1429class ot{constructor(e,t,i){this._node=e,this.ref=t,this._index=i}get priority(){return this._node.getPriority().val()}get key(){return this.ref.key}get size(){return this._node.numChildren()}child(e){const t=new k(e),i=at(this.ref,e);return new ot(this._node.getChild(t),i,B)}exists(){return!this._node.isEmpty()}exportVal(){return this._node.val(!0)}forEach(e){return this._node.isLeafNode()?!1:!!this._node.forEachChild(this._index,(i,s)=>e(new ot(s,at(this.ref,i),B)))}hasChild(e){const t=new k(e);return!this._node.getChild(t).isEmpty()}hasChildren(){return this._node.isLeafNode()?!1:!this._node.isEmpty()}toJSON(){return this.exportVal()}val(){return this._node.val()}}function Do(n,e){return n=X(n),n._checkNotDeleted("ref"),e!==void 0?at(n._root,e):n._root}function Mo(n,e){n=X(n),n._checkNotDeleted("refFromURL");const t=fs(e,n._repo.repoInfo_.nodeAdmin);vo("refFromURL",t);const i=t.repoInfo;return!n._repo.repoInfo_.isCustomHost()&&i.host!==n._repo.repoInfo_.host&&Ae("refFromURL: Host name does not match the current database: (found "+i.host+" but expected "+n._repo.repoInfo_.host+")"),Do(n,t.path.toString())}function at(n,e){return n=X(n),x(n._path)===null?jc("child","path",e,!1):sn("child","path",e,!1),new me(n._repo,U(n._path,e))}function ku(n){return n=getModularInstance(n),new ko(n._repo,n._path)}function ch(n,e){n=X(n),ge("push",n._path),Oe("push",e,n._path,!0);const t=bo(n._repo),i=vl(t),s=at(n,i),r=at(n,i);let o;return e!=null?o=ps(r,e).then(()=>r):o=Promise.resolve(r),s.then=o.then.bind(o),s.catch=o.then.bind(o,void 0),s}function hh(n){return ge("remove",n._path),ps(n,null)}function ps(n,e){n=X(n),ge("set",n._path),Oe("set",e,n._path,!1);const t=new q;return ls(n._repo,n._path,e,null,t.wrapCallback(()=>{})),t.promise}function uh(n,e){n=X(n),ge("setPriority",n._path),os("setPriority",e,!1);const t=new q;return ls(n._repo,U(n._path,".priority"),e,null,t.wrapCallback(()=>{})),t.promise}function dh(n,e,t){if(ge("setWithPriority",n._path),Oe("setWithPriority",e,n._path,!1),os("setWithPriority",t,!1),n.key===".length"||n.key===".keys")throw"setWithPriority failed: "+n.key+" is a read-only object.";const i=new q;return ls(n._repo,n._path,e,t,i.wrapCallback(()=>{})),i.promise}function fh(n,e){yo("update",e,n._path,!1);const t=new q;return Yc(n._repo,n._path,e,t.wrapCallback(()=>{})),t.promise}function _h(n){n=X(n);const e=new _s(()=>{}),t=new on(e);return qc(n._repo,n,t).then(i=>new ot(i,new me(n._repo,n._path),n._queryParams.getIndex()))}class on{constructor(e){this.callbackContext=e}respondsTo(e){return e==="value"}createEvent(e,t){const i=t._queryParams.getIndex();return new Oo("value",this,new ot(e.snapshotNode,new me(t._repo,t._path),i))}getEventRunner(e){return e.getEventType()==="cancel"?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,null)}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new Po(this,e,t):null}matches(e){return e instanceof on?!e.callbackContext||!this.callbackContext?!0:e.callbackContext.matches(this.callbackContext):!1}hasAnyCallback(){return this.callbackContext!==null}}class qn{constructor(e,t){this.eventType=e,this.callbackContext=t}respondsTo(e){let t=e==="children_added"?"child_added":e;return t=t==="children_removed"?"child_removed":t,this.eventType===t}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new Po(this,e,t):null}createEvent(e,t){y(e.childName!=null,"Child events should have a childName.");const i=at(new me(t._repo,t._path),e.childName),s=t._queryParams.getIndex();return new Oo(e.type,this,new ot(e.snapshotNode,i,s),e.prevName)}getEventRunner(e){return e.getEventType()==="cancel"?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,e.prevName)}matches(e){return e instanceof qn?this.eventType===e.eventType&&(!this.callbackContext||!e.callbackContext||this.callbackContext.matches(e.callbackContext)):!1}hasAnyCallback(){return!!this.callbackContext}}function an(n,e,t,i,s){let r;if(typeof i=="object"&&(r=void 0,s=i),typeof i=="function"&&(r=i),s&&s.onlyOnce){const c=t,h=(p,f)=>{cs(n._repo,n,a),c(p,f)};h.userCallback=t.userCallback,h.context=t.context,t=h}const o=new _s(t,r||void 0),a=e==="value"?new on(o):new qn(e,o);return th(n._repo,n,a),()=>cs(n._repo,n,a)}function gs(n,e,t,i){return an(n,"value",e,t,i)}function Lo(n,e,t,i){return an(n,"child_added",e,t,i)}function Fo(n,e,t,i){return an(n,"child_changed",e,t,i)}function Bo(n,e,t,i){return an(n,"child_moved",e,t,i)}function Wo(n,e,t,i){return an(n,"child_removed",e,t,i)}function Uo(n,e,t){let i=null;const s=t?new _s(t):null;e==="value"?i=new on(s):e&&(i=new qn(e,s)),cs(n._repo,n,i)}class be{}class Vo extends be{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){Oe("endAt",this._value,e._path,!0);const t=Oi(e._queryParams,this._value,this._key);if(Kn(t),$e(t),e._queryParams.hasEnd())throw new Error("endAt: Starting point was already set
1429(by another call to endAt, endBefore or equalTo).");return new re(e._repo,e._path,t,e._orderByCalled)}}function ph(n,e){return nn("endAt","key",e,!0),new Vo(n,e)}class gh extends be{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){Oe("endBefore",this._value,e._path,!1);const t=xl(e._queryParams,this._value,this._key);if(Kn(t),$e(t),e._queryParams.hasEnd())throw new Error("endBefore: Starting point was already set (by another call to endAt, endBefore or equalTo).");return new re(e._repo,e._path,t,e._orderByCalled)}}function mh(n,e){return nn("endBefore","key",e,!0),new gh(n,e)}class jo extends be{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){Oe("startAt",this._value,e._path,!0);const t=Ri(e._queryParams,this._value,this._key);if(Kn(t),$e(t),e._queryParams.hasStart())throw new Error("startAt: Starting point was already set (by another call to startAt, startBefore or equalTo).");return new re(e._repo,e._path,t,e._orderByCalled)}}function yh(n=null,e){return nn("startAt","key",e,!0),new jo(n,e)}class vh extends be{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){Oe("startAfter",this._value,e._path,!1);const t=Tl(e._queryParams,this._value,this._key);if(Kn(t),$e(t),e._queryParams.hasStart())throw new Error("startAfter: Starting point was already set (by another call to startAt, startAfter, or equalTo).");return new re(e._repo,e._path,t,e._orderByCalled)}}function Eh(n,e){return nn("startAfter","key",e,!0),new vh(n,e)}class Ch extends be{constructor(e){super(),this._limit=e}_apply(e){if(e._queryParams.hasLimit())throw new Error("limitToFirst: Limit was already set (by another call to limitToFirst or limitToLast).");return new re(e._repo,e._path,bl(e._queryParams,this._limit),e._orderByCalled)}}function wh(n){if(typeof n!="number"||Math.floor(n)!==n||n<=0)throw new Error("limitToFirst: First argument must be a positive integer.");return new Ch(n)}class bh extends be{constructor(e){super(),this._limit=e}_apply(e){if(e._queryParams.hasLimit())throw new Error("limitToLast: Limit was already set (by another call to limitToFirst or limitToLast).");return new re(e._repo,e._path,Sl(e._queryParams,this._limit),e._orderByCalled)}}function Sh(n){if(typeof n!="number"||Math.floor(n)!==n||n<=0)throw new Error("limitToLast: First argument must be a positive integer.");return new bh(n)}class Th extends be{constructor(e){super(),this._path=e}_apply(e){$n(e,"orderByChild");const t=new k(this._path);if(I(t))throw new Error("orderByChild: cannot pass in empty path. Use orderByValue() instead.");const i=new xi(t),s=Sn(e._queryParams,i);return $e(s),new re(e._repo,e._path,s,!0)}}function xh(n){if(n==="$key")throw new Error('orderByChild: "$key" is invalid. Use orderByKey() instead.');if(n==="$priority")throw new Error('orderByChild: "$priority" is invalid. Use orderByPriority() instead.');if(n==="$value")throw new Error('orderByChild: "$value" is invalid. Use orderByValue() instead.');return sn("orderByChild","path",n,!1),new Th(n)}class Ih extends be{_apply(e){$n(e,"orderByKey");const t=Sn(e._queryParams,Re);return $e(t),new re(e._repo,e._path,t,!0)}}function Ah(){return new Ih}class Nh extends be{_apply(e){$n(e,"orderByPriority");const t=Sn(e._queryParams,B);return $e(t),new re(e._repo,e._path,t,!0)}}function Rh(){return new Nh}class Oh extends be{_apply(e){$n(e,"orderByValue");const t=Sn(e._queryParams,Ii);return $e(t),new re(e._repo,e._path,t,!0)}}function Ph(){return new Oh}class kh extends be{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){if(Oe("equalTo",this._value,e._path,!1),e._queryParams.hasStart())throw new Error("equalTo: Starting point was already set (by another call to startAt/startAfter or equalTo).");if(e._queryParams.hasEnd())throw new Error("equalTo: Ending point was already set (by another call to endAt/endBefore or equalTo).");return new Vo(this._value,this._key)._apply(new jo(this._value,this._key)._apply(e))}}function Dh(n,e){return nn("equalTo","key",e,!0),new kh(n,e)}function Se(n,...e){let t=X(n);for(const i of e)t=i._apply(t);return t}_c(me),vc(me);/** 1430 * @license 1431 * Copyright 2020 Google LLC 1432 * 1433 * Licensed under the Apache License, Version 2.0 (the "License");
1434 * you may not use this file except in compliance with the License. 1435 * You may obtain a copy of the License at 1436 * 1437 * http://www.apache.org/licenses/LICENSE-2.0 1438 * 1439 * Unless required by applicable law or agreed to in writing, software 1440 * distributed under the License is distributed on an "AS IS" BASIS, 1441 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1442 * See the License for the specific language governing permissions and 1443 * limitations under the License. 1444 */const Mh="FIREBASE_DATABASE_EMULATOR_HOST",ms={};let Ho=!1;function Lh(n,e,t,i){n.repoInfo_=new _i(`${e}:${t}`,!1,n.repoInfo_.namespace,n.repoInfo_.webSocketOnly,n.repoInfo_.nodeAdmin,n.repoInfo_.persistenceKey,n.repoInfo_.includeNamespaceInQueryParams),i&&(n.authTokenProvider_=i)}function zo(n,e,t,i,s){let r=i||n.options.databaseURL;r===void 0&&(n.options.projectId||Ae("Can't determine Firebase Database URL. Be sure to include a Project ID when calling firebase.initializeApp()."),z("Using default host for project ",n.options.projectId),r=`${n.options.projectId}-default-rtdb.firebaseio.com`);let o=fs(r,s),a=o.repoInfo,c,h;typeof Ze<"u"&&Ze.env&&(h=Ze.env[Mh]),h?(c=!0,r=`http://${h}?ns=${a.namespace}`,o=fs(r,s),a=o.repoInfo):c=!o.repoInfo.secure;const p=s&&c?new mt(mt.OWNER):new Aa(n.name,n.options,e);vo("Invalid Firebase Database URL",o),I(o.path)||Ae("Database URL must point to the root of a Firebase Database (not including a child path).");const f=Bh(a,n,p,new Ia(n.name,t));return new Uh(f,n)}function Fh(n,e){const t=ms[e];(!t||t[n.key]!==n)&&Ae(`Database ${e}(${n.repoInfo_}) has already been deleted.`),Io(n),delete t[n.key]}function Bh(n,e,t,i){let s=ms[e.name];s||(s={},ms[e.name]=s);let r=s[n.toURLString()];return r&&Ae("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),r=new Qc(n,Ho,t,i),s[n.toURLString()]=r,r}function Wh(n){Ho=n}class Uh{constructor(e,t){this._repoInternal=e,this.app=t,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||($c(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new me(this._repo,R())),this._rootInternal}_delete(){return this._rootInternal!==null&&(Fh(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(e){this._rootInternal===null&&Ae("Cannot call "+e+" on a deleted database.")}}function Go(){yt.IS_TRANSPORT_INITIALIZED&&Z("Transport has already been initialized. Please call this function before calling ref or setting up a listener")}function Vh(){Go(),We.forceDisallow()}function jh(){Go(),_e.forceDisallow(),We.forceAllow()}function Du(n=getApp(),e){const t=_getProvider(n,"database").getImmediate({identifier:e}),i=getDefaultEmulatorHostnameAndPort("database");return i&&Qo(t,...i),t}function Qo(n,e,t,i={}){n=X(n),n._checkNotDeleted("useEmulator"),n._instanceStarted&&Ae("Cannot call useEmulator() after instance has already been initialized.");const s=n._repoInternal;let r;if(s.repoInfo_.nodeAdmin)i.mockUserToken&&Ae('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),r=new mt(mt.OWNER);else if(i.mockUserToken){const o=typeof i.mockUserToken=="string"?i.mockUserToken:ii(i.mockUserToken,n.app.options.projectId);r=new mt(o)}Lh(s,e,t,r)}function Hh(n){n=X(n),n._checkNotDeleted("goOffline"),Io(n._repo)}function zh(n){n=X(n),n._checkNotDeleted("goOnline"),nh(n._repo)}function Gh(n,e){zs(n,e)}/** 1445 * @license 1446 * Copyright 2021 Google LLC 1447 * 1448 * Licensed under the Apache License, Version 2.0 (the "License"); 1449 * you may not use this file except in compliance with the License. 1450 * You may obtain a copy of the License at 1451 * 1452 * http://www.apache.org/licenses/LICENSE-2.0 1453 * 1454 * Unless required by applicable law or agreed to in writing, software 1455 * distributed under the License is distributed on an "AS IS" BASIS, 1456 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1457 * See the License for the specific language governing permissions and 1458 * limitations under the License. 1459 */function Qh(n){g(N.SDK_VERSION),(0,N._registerComponent)(new oe.uA("database",(e,{instanceIdentifier:t})=>{const i=e.getProvider("app").getImmediate(),s=e.getProvider("auth-internal"),r=e.getProvider("app-check-internal");return zo(i,s,r,t)},"PUBLIC").setMultipleInstances(!0)),(0,N.registerVersion)(d,l,n),(0,N.registerVersion)(d,l,"esm2017")}/** 1460 * @license 1461 * Copyright 2020 Google LLC 1462 * 1463 * Licensed under the Apache License, Version 2.0 (the "License");
1464 * you may not use this file except in compliance with the License. 1465 * You may obtain a copy of the License at 1466 * 1467 * http://www.apache.org/licenses/LICENSE-2.0 1468 * 1469 * Unless required by applicable law or agreed to in writing, software 1470 * distributed under the License is distributed on an "AS IS" BASIS, 1471 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1472 * See the License for the specific language governing permissions and 1473 * limitations under the License. 1474 */const $h={".sv":"timestamp"};function Kh(){return $h}function qh(n){return{".sv":{increment:n}}}/** 1475 * @license 1476 * Copyright 2020 Google LLC 1477 * 1478 * Licensed under the Apache License, Version 2.0 (the "License"); 1479 * you may not use this file except in compliance with the License. 1480 * You may obtain a copy of the License at 1481 * 1482 * http://www.apache.org/licenses/LICENSE-2.0 1483 * 1484 * Unless required by applicable law or agreed to in writing, software 1485 * distributed under the License is distributed on an "AS IS" BASIS, 1486 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1487 * See the License for the specific language governing permissions and 1488 * limitations under the License. 1489 */class Yh{constructor(e,t){this.committed=e,this.snapshot=t}toJSON(){return{committed:this.committed,snapshot:this.snapshot.toJSON()}}}function Jh(n,e,t){var i;if(n=X(n),ge("Reference.transaction",n._path),n.key===".length"||n.key===".keys")throw"Reference.transaction failed: "+n.key+" is a read-only object.";const s=(i=t?.applyLocally)!==null&&i!==void 0?i:!0,r=new q,o=(c,h,p)=>{let f=null;c?r.reject(c):(f=new ot(p,new me(n._repo,n._path),B),r.resolve(new Yh(h,f)))},a=gs(n,()=>{});return ih(n._repo,n._path,e,o,a,s),r.promise}/** 1490 * @license 1491 * Copyright 2017 Google LLC 1492 * 1493 * Licensed under the Apache License, Version 2.0 (the "License"); 1494 * you may not use this file except in compliance with the License. 1495 * You may obtain a copy of the License at 1496 * 1497 * http://www.apache.org/licenses/LICENSE-2.0 1498 * 1499 * Unless required by applicable law or agreed to in writing, software 1500 * distributed under the License is distributed on an "AS IS" BASIS, 1501 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1502 * See the License for the specific language governing permissions and 1503 * limitations under the License. 1504 */ae.prototype.simpleListen=function(n,e){this.sendRequest("q",{p:n},e)},ae.prototype.echo=function(n,e){this.sendRequest("echo",{d:n},e)};const Mu=function(n){const e=ae.prototype.put;return ae.prototype.put=function(t,i,s,r){r!==void 0&&(r=n()),e.call(this,t,i,s,r)},function(){ae.prototype.put=e}},Lu=function(n){Wh(n)};Qh();var ln=L(80247),ys=L(288538);/** 1505 * @license 1506 * Copyright 2017 Google LLC 1507 * 1508 * Licensed under the Apache License, Version 2.0 (the "License"); 1509 * you may not use this file except in compliance with the License. 1510 * You may obtain a copy of the License at 1511 * 1512 * http://www.apache.org/licenses/LICENSE-2.0 1513 * 1514 * Unless required by applicable law or agreed to in writing, software 1515 * distributed under the License is distributed on an "AS IS" BASIS, 1516 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1517 * See the License for the specific language governing permissions and 1518 * limitations under the License. 1519 */const vs={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"};/** 1520 * @license 1521 * Copyright 2017 Google LLC 1522 * 1523 * Licensed under the Apache License, Version 2.0 (the "License"); 1524 * you may not use this file except in compliance with the License. 1525 * You may obtain a copy of the License at 1526 * 1527 * http://www.apache.org/licenses/LICENSE-2.0 1528 * 1529 * Unless required by applicable law or agreed to in writing, software 1530 * distributed under the License is distributed on an "AS IS" BASIS, 1531 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1532 * See the License for the specific language governing permissions and 1533 * limitations under the License. 1534 */const Xh=function(n,e){if(!n)throw Zh(e)},Zh=function(n){return new Error("Firebase Database ("+vs.SDK_VERSION+") INTERNAL ASSERT FAILED: "+n)};/** 1535 * @license 1536 * Copyright 2017 Google LLC 1537 * 1538 * Licensed under the Apache License, Version 2.0 (the "License");
1539 * you may not use this file except in compliance with the License. 1540 * You may obtain a copy of the License at 1541 * 1542 * http://www.apache.org/licenses/LICENSE-2.0 1543 * 1544 * Unless required by applicable law or agreed to in writing, software 1545 * distributed under the License is distributed on an "AS IS" BASIS, 1546 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1547 * See the License for the specific language governing permissions and 1548 * limitations under the License. 1549 */const $o=function(n){const e=[];let t=0;for(let i=0;i<n.length;i++){let s=n.charCodeAt(i);s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&i+1<n.length&&(n.charCodeAt(i+1)&64512)===56320?(s=65536+((s&1023)<<10)+(n.charCodeAt(++i)&1023),e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128)}return e},eu=function(n){const e=[];let t=0,i=0;for(;t<n.length;){const s=n[t++];if(s<128)e[i++]=String.fromCharCode(s);else if(s>191&&s<224){const r=n[t++];e[i++]=String.fromCharCode((s&31)<<6|r&63)}else if(s>239&&s<365){const r=n[t++],o=n[t++],a=n[t++],c=((s&7)<<18|(r&63)<<12|(o&63)<<6|a&63)-65536;e[i++]=String.fromCharCode(55296+(c>>10)),e[i++]=String.fromCharCode(56320+(c&1023))}else{const r=n[t++],o=n[t++];e[i++]=String.fromCharCode((s&15)<<12|(r&63)<<6|o&63)}}return e.join("")},Ko={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(n,e){if(!Array.isArray(n))throw Error("encodeByteArray takes an array as a parameter");this.init_();const t=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,i=[];for(let s=0;s<n.length;s+=3){const r=n[s],o=s+1<n.length,a=o?n[s+1]:0,c=s+2<n.length,h=c?n[s+2]:0,p=r>>2,f=(r&3)<<4|a>>4;let m=(a&15)<<2|h>>6,v=h&63;c||(v=64,o||(m=64)),i.push(t[p],t[f],t[m],t[v])}return i.join("")},encodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(n):this.encodeByteArray($o(n),e)},decodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(n):eu(this.decodeStringToByteArray(n,e))},decodeStringToByteArray(n,e){this.init_();const t=e?this.charToByteMapWebSafe_:this.charToByteMap_,i=[];for(let s=0;s<n.length;){const r=t[n.charAt(s++)],a=s<n.length?t[n.charAt(s)]:0;++s;const h=s<n.length?t[n.charAt(s)]:64;++s;const f=s<n.length?t[n.charAt(s)]:64;if(++s,r==null||a==null||h==null||f==null)throw Error();const m=r<<2|a>>4;if(i.push(m),h!==64){const v=a<<4&240|h>>2;if(i.push(v),f!==64){const C=h<<6&192|f;i.push(C)}}}return i},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let n=0;n<this.ENCODED_VALS.length;n++)this.byteToCharMap_[n]=this.ENCODED_VALS.charAt(n),this.charToByteMap_[this.byteToCharMap_[n]]=n,this.byteToCharMapWebSafe_[n]=this.ENCODED_VALS_WEBSAFE.charAt(n),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[n]]=n,n>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(n)]=n,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(n)]=n)}}},tu=function(n){const e=$o(n);return Ko.encodeByteArray(e,!0)},qo=function(n){return tu(n).replace(/\./g,"")},Es=function(n){try{return Ko.decodeString(n,!0)}catch(e){ln.error("base64Decode failed: ",e)}return null};/** 1550 * @license 1551 * Copyright 2017 Google LLC 1552 * 1553 * Licensed under the Apache License, Version 2.0 (the "License"); 1554 * you may not use this file except in compliance with the License. 1555 * You may obtain a copy of the License at 1556 * 1557 * http://www.apache.org/licenses/LICENSE-2.0 1558 * 1559 * Unless required by applicable law or agreed to in writing, software 1560 * distributed under the License is distributed on an "AS IS" BASIS, 1561 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1562 * See the License for the specific language governing permissions and 1563 * limitations under the License. 1564 */function Fu(n){return Yo(void 0,n)}function Yo(n,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:const t=e;return new Date(t.getTime());case Object:n===void 0&&(n={});break;case Array:n=[];break;default:return e}for(const t in e)!e.hasOwnProperty(t)||!nu(t)||(n[t]=Yo(n[t],e[t]));return n}function nu(n){return n!=="__proto__"}/** 1565 * @license 1566 * Copyright 2017 Google LLC 1567 * 1568 * Licensed under the Apache License, Version 2.0 (the "License");
1569 * you may not use this file except in compliance with the License. 1570 * You may obtain a copy of the License at 1571 * 1572 * http://www.apache.org/licenses/LICENSE-2.0 1573 * 1574 * Unless required by applicable law or agreed to in writing, software 1575 * distributed under the License is distributed on an "AS IS" BASIS, 1576 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1577 * See the License for the specific language governing permissions and 1578 * limitations under the License. 1579 */function Yn(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function Bu(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(Yn())}function iu(){try{return Object.prototype.toString.call(L.g.process)==="[object process]"}catch{return!1}}function Wu(){return typeof self=="object"&&self.self===self}function Uu(){const n=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof n=="object"&&n.id!==void 0}function Vu(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function ju(){return Yn().indexOf("Electron/")>=0}function Hu(){const n=Yn();return n.indexOf("MSIE ")>=0||n.indexOf("Trident/")>=0}function zu(){return Yn().indexOf("MSAppHost/")>=0}function Gu(){return vs.NODE_CLIENT===!0||vs.NODE_ADMIN===!0}function Qu(){return!iu()&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function $u(){return typeof indexedDB=="object"}function Ku(){return new Promise((n,e)=>{try{let t=!0;const i="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(i);s.onsuccess=()=>{s.result.close(),t||self.indexedDB.deleteDatabase(i),n(!0)},s.onupgradeneeded=()=>{t=!1},s.onerror=()=>{var r;e(((r=s.error)===null||r===void 0?void 0:r.message)||"")}}catch(t){e(t)}})}function qu(){return!(typeof navigator>"u"||!navigator.cookieEnabled)}function su(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof L.g<"u")return L.g;throw new Error("Unable to locate global object.")}/** 1580 * @license 1581 * Copyright 2022 Google LLC 1582 * 1583 * Licensed under the Apache License, Version 2.0 (the "License"); 1584 * you may not use this file except in compliance with the License. 1585 * You may obtain a copy of the License at 1586 * 1587 * http://www.apache.org/licenses/LICENSE-2.0 1588 * 1589 * Unless required by applicable law or agreed to in writing, software 1590 * distributed under the License is distributed on an "AS IS" BASIS, 1591 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1592 * See the License for the specific language governing permissions and 1593 * limitations under the License. 1594 */const ru=()=>su().__FIREBASE_DEFAULTS__,ou=()=>{if(typeof ys>"u"||typeof ys.env>"u")return;const n=ys.env.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},au=()=>{if(typeof document>"u")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=n&&Es(n[1]);return e&&JSON.parse(e)},Cs=()=>{try{return ru()||ou()||au()}catch(n){ln.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${n}`);return}},lu=n=>{var e,t;return(t=(e=Cs())===null||e===void 0?void 0:e.emulatorHosts)===null||t===void 0?void 0:t[n]},Yu=n=>{const e=lu(n);if(!e)return;const t=e.lastIndexOf(":");if(t<=0||t+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const i=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),i]:[e.substring(0,t),i]},Ju=()=>{var n;return(n=Cs())===null||n===void 0?void 0:n.config},Xu=n=>{var e;return(e=Cs())===null||e===void 0?void 0:e[`_${n}`]};/** 1595 * @license 1596 * Copyright 2017 Google LLC 1597 * 1598 * Licensed under the Apache License, Version 2.0 (the "License"); 1599 * you may not use this file except in compliance with the License. 1600 * You may obtain a copy of the License at 1601 * 1602 * http://www.apache.org/licenses/LICENSE-2.0 1603 * 1604 * Unless required by applicable law or agreed to in writing, software 1605 * distributed under the License is distributed on an "AS IS" BASIS, 1606 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1607 * See the License for the specific language governing permissions and 1608 * limitations under the License. 1609 */class Jo{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>
1609{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,i)=>{t?this.reject(t):this.resolve(i),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,i))}}}/** 1610 * @license 1611 * Copyright 2021 Google LLC 1612 * 1613 * Licensed under the Apache License, Version 2.0 (the "License"); 1614 * you may not use this file except in compliance with the License. 1615 * You may obtain a copy of the License at 1616 * 1617 * http://www.apache.org/licenses/LICENSE-2.0 1618 * 1619 * Unless required by applicable law or agreed to in writing, software 1620 * distributed under the License is distributed on an "AS IS" BASIS, 1621 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1622 * See the License for the specific language governing permissions and 1623 * limitations under the License. 1624 */function Zu(n,e){if(n.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const t={alg:"none",type:"JWT"},i=e||"demo-project",s=n.iat||0,r=n.sub||n.user_id;if(!r)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const o=Object.assign({iss:`https://securetoken.google.com/${i}`,aud:i,iat:s,exp:s+3600,auth_time:s,sub:r,user_id:r,firebase:{sign_in_provider:"custom",identities:{}}},n),a="";return[qo(JSON.stringify(t)),qo(JSON.stringify(o)),a].join(".")}/** 1625 * @license 1626 * Copyright 2017 Google LLC 1627 * 1628 * Licensed under the Apache License, Version 2.0 (the "License"); 1629 * you may not use this file except in compliance with the License. 1630 * You may obtain a copy of the License at 1631 * 1632 * http://www.apache.org/licenses/LICENSE-2.0 1633 * 1634 * Unless required by applicable law or agreed to in writing, software 1635 * distributed under the License is distributed on an "AS IS" BASIS, 1636 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1637 * See the License for the specific language governing permissions and 1638 * limitations under the License. 1639 */const cu="FirebaseError";
1639class ws extends Error{constructor(e,t,i){super(t),this.code=e,this.customData=i,this.name=cu,Object.setPrototypeOf(this,ws.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,hu.prototype.create)}}class hu{constructor(e,t,i){this.service=e,this.serviceName=t,this.errors=i}create(e,...t){const i=t[0]||{},s=`${this.service}/${e}`,r=this.errors[e],o=r?uu(r,i):"Error",a=`${this.serviceName}: ${o} (${s}).`;return new ws(s,a,i)}}function uu(n,e){return n.replace(du,(t,i)=>{const s=e[i];return s!=null?String(s):`<${i}?>`})}const du=/\{\$([^}]+)}/g;/** 1640 * @license 1641 * Copyright 2017 Google LLC 1642 * 1643 * Licensed under the Apache License, Version 2.0 (the "License"); 1644 * you may not use this file except in compliance with the License. 1645 * You may obtain a copy of the License at 1646 * 1647 * http://www.apache.org/licenses/LICENSE-2.0 1648 * 1649 * Unless required by applicable law or agreed to in writing, software 1650 * distributed under the License is distributed on an "AS IS" BASIS, 1651 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1652 * See the License for the specific language governing permissions and 1653 * limitations under the License. 1654 */function Xo(n){return JSON.parse(n)}function ed(n){return JSON.stringify(n)}/** 1655 * @license 1656 * Copyright 2017 Google LLC 1657 * 1658 * Licensed under the Apache License, Version 2.0 (the "License"); 1659 * you may not use this file except in compliance with the License. 1660 * You may obtain a copy of the License at 1661 * 1662 * http://www.apache.org/licenses/LICENSE-2.0 1663 * 1664 * Unless required by applicable law or agreed to in writing, software 1665 * distributed under the License is distributed on an "AS IS" BASIS, 1666 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1667 * See the License for the specific language governing permissions and 1668 * limitations under the License. 1669 */const Jn=function(n){let e={},t={},i={},s="";try{const r=n.split(".");e=Xo(Es(r[0])||""),t=Xo(Es(r[1])||""),s=r[2],i=t.d||{},delete t.d}catch{}return{header:e,claims:t,data:i,signature:s}},td=function(n){const e=Jn(n).claims,t=Math.floor(new Date().getTime()/1e3);let i=0,s=0;return typeof e=="object"&&(e.hasOwnProperty("nbf")?i=e.nbf:e.hasOwnProperty("iat")&&(i=e.iat),e.hasOwnProperty("exp")?s=e.exp:s=i+86400),!!t&&!!i&&!!s&&t>=i&&t<=s},nd=function(n){const e=Jn(n).claims;return typeof e=="object"&&e.hasOwnProperty("iat")?e.iat:null},id=function(n){const e=Jn(n),t=e.claims;return!!t&&typeof t=="object"&&t.hasOwnProperty("iat")},sd=function(n){const e=Jn(n).claims;return typeof e=="object"&&e.admin===!0};/** 1670 * @license 1671 * Copyright 2017 Google LLC 1672 * 1673 * Licensed under the Apache License, Version 2.0 (the "License"); 1674 * you may not use this file except in compliance with the License. 1675 * You may obtain a copy of the License at 1676 * 1677 * http://www.apache.org/licenses/LICENSE-2.0 1678 * 1679 * Unless required by applicable law or agreed to in writing, software 1680 * distributed under the License is distributed on an "AS IS" BASIS, 1681 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1682 * See the License for the specific language governing permissions and 1683 * limitations under the License. 1684 */function rd(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function od(n,e){if(Object.prototype.hasOwnProperty.call(n,e))return n[e]}function ad(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function ld(n,e,t){const i={};for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=e.call(t,n[s],s,n));return i}function fu(n,e){if(n===e)return!0;const t=Object.keys(n),i=Object.keys(e);for(const s of t){if(!i.includes(s))return!1;const r=n[s],o=e[s];if(Zo(r)&&Zo(o)){if(!fu(r,o))return!1}else if(r!==o)return!1}for(const s of i)if(!t.includes(s))return!1;return!0}function Zo(n){return n!==null&&typeof n=="object"}/** 1685 * @license 1686 * Copyright 2022 Google LLC 1687 * 1688 * Licensed under the Apache License, Version 2.0 (the "License"); 1689 * you may not use this file except in compliance with the License. 1690 * You may obtain a copy of the License at 1691 * 1692 * http://www.apache.org/licenses/LICENSE-2.0 1693 * 1694 * Unless required by applicable law or agreed to in writing, softw
1694are 1695 * distributed under the License is distributed on an "AS IS" BASIS, 1696 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1697 * See the License for the specific language governing permissions and 1698 * limitations under the License. 1699 */function cd(n,e=2e3){const t=new Jo;return setTimeout(()=>t.reject("timeout!"),e),n.then(t.resolve,t.reject),t.promise}/** 1700 * @license 1701 * Copyright 2017 Google LLC 1702 * 1703 * Licensed under the Apache License, Version 2.0 (the "License"); 1704 * you may not use this file except in compliance with the License. 1705 * You may obtain a copy of the License at 1706 * 1707 * http://www.apache.org/licenses/LICENSE-2.0 1708 * 1709 * Unless required by applicable law or agreed to in writing, software 1710 * distributed under the License is distributed on an "AS IS" BASIS, 1711 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1712 * See the License for the specific language governing permissions and 1713 * limitations under the License. 1714 */function hd(n){const e=[];for(const[t,i]of Object.entries(n))Array.isArray(i)?i.forEach(s=>{e.push(encodeURIComponent(t)+"="+encodeURIComponent(s))}):e.push(encodeURIComponent(t)+"="+encodeURIComponent(i));return e.length?"&"+e.join("&"):""}function ud(n){const e={};return n.replace(/^\?/,"").split("&").forEach(i=>{if(i){const[s,r]=i.split("=");e[decodeURIComponent(s)]=decodeURIComponent(r)}}),e}function dd(n){const e=n.indexOf("?");if(!e)return"";const t=n.indexOf("#",e);return n.substring(e,t>0?t:void 0)}/** 1715 * @license 1716 * Copyright 2017 Google LLC 1717 * 1718 * Licensed under the Apache License, Version 2.0 (the "License"); 1719 * you may not use this file except in compliance with the License. 1720 * You may obtain a copy of the License at 1721 * 1722 * http://www.apache.org/licenses/LICENSE-2.0 1723 * 1724 * Unless required by applicable law or agreed to in writing, software 1725 * distributed under the License is distributed on an "AS IS" BASIS, 1726 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1727 * See the License for the specific language governing permissions and 1728 * limitations under the License. 1729 */class fd{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=512/8,this.pad_[0]=128;for(let e=1;e<this.blockSize;++e)this.pad_[e]=0;this.reset()}reset(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0}compress_(e,t){t||(t=0);const i=this.W_;if(typeof e=="string")for(let f=0;f<16;f++)i[f]=e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3),t+=4;else for(let f=0;f<16;f++)i[f]=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3],t+=4;for(let f=16;f<80;f++){const m=i[f-3]^i[f-8]^i[f-14]^i[f-16];i[f]=(m<<1|m>>>31)&4294967295}let s=this.chain_[0],r=this.chain_[1],o=this.chain_[2],a=this.chain_[3],c=this.chain_[4],h,p;for(let f=0;f<80;f++){f<40?f<20?(h=a^r&(o^a),p=1518500249):(h=r^o^a,p=1859775393):f<60?(h=r&o|a&(r|o),p=2400959708):(h=r^o^a,p=3395469782);const m=(s<<5|s>>>27)+h+c+p+i[f]&4294967295;c=a,a=o,o=(r<<30|r>>>2)&4294967295,r=s,s=m}this.chain_[0]=this.chain_[0]+s&4294967295,this.chain_[1]=this.chain_[1]+r&4294967295,this.chain_[2]=this.chain_[2]+o&4294967295,this.chain_[3]=this.chain_[3]+a&4294967295,this.chain_[4]=this.chain_[4]+c&4294967295}update(e,t){if(e==null)return;t===void 0&&(t=e.length);const i=t-this.blockSize;let s=0;const r=this.buf_;let o=this.inbuf_;for(;s<t;){if(o===0)for(;s<=i;)this.compress_(e,s),s+=this.blockSize;if(typeof e=="string"){for(;s<t;)if(r[o]=e.charCodeAt(s),++o,++s,o===this.blockSize){this.compress_(r),o=0;break}}else for(;s<t;)if(r[o]=e[s],++o,++s,o===this.blockSize){this.compress_(r),o=0;break}}this.inbuf_=o,this.total_+=t}digest(){const e=[];let t=this.total_*8;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let s=this.blockSize-1;s>=56;s--)this.buf_[s]=t&255,t/=256;this.compress_(this.buf_);let i=0;for(let s=0;s<5;s++)for(let r=24;r>=0;r-=8)e[i]=this.chain_[s]>>r&255,++i;return e}}function _d(n,e){const t=new _u(n,e);return t.subscribe.bind(t)}class _u{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Prom
1729ise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(i=>{this.error(i)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,i){let s;if(e===void 0&&t===void 0&&i===void 0)throw new Error("Missing Observer.");pu(e,["next","error","complete"])?s=e:s={next:e,error:t,complete:i},s.next===void 0&&(s.next=bs),s.error===void 0&&(s.error=bs),s.complete===void 0&&(s.complete=bs);const r=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?s.error(this.finalError):s.complete()}catch{}}),this.observers.push(s),r}unsubscribeOne(e){this.observers===void 0||this.observers[e]===void 0||(delete this.observers[e],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>{if(this.observers!==void 0&&this.observers[e]!==void 0)try{t(this.observers[e])}catch(i){typeof ln<"u"&&ln.error&&ln.error(i)}})}close(e){this.finalized||(this.finalized=!0,e!==void 0&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function pd(n,e){return(...t)=>{Promise.resolve(!0).then(()=>{n(...t)}).catch(i=>{e&&e(i)})}}function pu(n,e){if(typeof n!="object"||n===null)return!1;for(const t of e)if(t in n&&typeof n[t]=="function")return!0;return!1}function bs(){}/** 1730 * @license 1731 * Copyright 2017 Google LLC 1732 * 1733 * Licensed under the Apache License, Version 2.0 (the "License"); 1734 * you may not use this file except in compliance with the License. 1735 * You may obtain a copy of the License at 1736 * 1737 * http://www.apache.org/licenses/LICENSE-2.0 1738 * 1739 * Unless required by applicable law or agreed to in writing, software 1740 * distributed under the License is distributed on an "AS IS" BASIS, 1741 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1742 * See the License for the specific language governing permissions and 1743 * limitations under the License. 1744 */const b=function(n,e,t,i){let s;if(i<e?s="at least "+e:i>t&&(s=t===0?"none":"no more than "+t),s){const r=n+" failed: Was called with "+i+(i===1?" argument.":" arguments.")+" Expects "+s+".";throw new Error(r)}};function Ke(n,e){return`${n} failed: ${e} argument `}function gd(n,e,t){if(!(t&&!e)&&typeof e!="string")throw new Error(Ke(n,"namespace")+"must be a valid firebase namespace.")}function K(n,e,t,i){if(!(i&&!t)&&typeof t!="function")throw new Error(Ke(n,e)+"must be a valid function.")}function ea(n,e,t,i){if(!(i&&!t)&&(typeof t!="object"||t===null))throw new Error(Ke(n,e)+"must be a valid context object.")}/** 1745 * @license 1746 * Copyright 2017 Google LLC 1747 * 1748 * Licensed under the Apache License, Version 2.0 (the "License"); 1749 * you may not use this file except in compliance with the License. 1750 * You may obtain a copy of the License at 1751 * 1752 * http://www.apache.org/licenses/LICENSE-2.0 1753 * 1754 * Unless required by applicable law or agreed to in writing, software 1755 * distributed under the License is distributed on an "AS IS" BASIS, 1756 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1757 * See the License for the specific language governing permissions and 1758 * limitations under the License. 1759 */const md=function(n){const e=[];let t=0;for(let i=0;i<n.length;i++){let s=n.charCodeAt(i);if(s>=55296&&s<=56319){const r=s-55296;i++,Xh(i<n.length,"Surrogate pair missing trail surrogate.");const o=n.charCodeAt(i)-56320;s=65536+(r<<10)+o}s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):s<65536?(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128)}return e},yd=function(n){let e=0;for(let t=0;t<n.length;t++){const i=n.charCodeAt(t);i<128?e++:i<2048?e+=2:i>=55296&&i<=56319?(e+=4,t++):e+=3}return e};/** 1760 * @license 1761 * Copyright 2022 Google LLC 1762 * 1763 * Licensed under the Apache License, Version 2.0 (the "License");
1764 * you may not use this file except in compliance with the License. 1765 * You may obtain a copy of the License at 1766 * 1767 * http://www.apache.org/licenses/LICENSE-2.0 1768 * 1769 * Unless required by applicable law or agreed to in writing, software 1770 * distributed under the License is distributed on an "AS IS" BASIS, 1771 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1772 * See the License for the specific language governing permissions and 1773 * limitations under the License. 1774 */const vd=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)})};/** 1775 * @license 1776 * Copyright 2019 Google LLC 1777 * 1778 * Licensed under the Apache License, Version 2.0 (the "License"); 1779 * you may not use this file except in compliance with the License. 1780 * You may obtain a copy of the License at 1781 * 1782 * http://www.apache.org/licenses/LICENSE-2.0 1783 * 1784 * Unless required by applicable law or agreed to in writing, software 1785 * distributed under the License is distributed on an "AS IS" BASIS, 1786 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1787 * See the License for the specific language governing permissions and 1788 * limitations under the License. 1789 */const gu=1e3,mu=2,yu=null,vu=.5;function Ed(n,e=gu,t=mu){const i=e*Math.pow(t,n),s=Math.round(vu*i*(Math.random()-.5)*2);return Math.min(yu,i+s)}/** 1790 * @license 1791 * Copyright 2020 Google LLC 1792 * 1793 * Licensed under the Apache License, Version 2.0 (the "License"); 1794 * you may not use this file except in compliance with the License. 1795 * You may obtain a copy of the License at 1796 * 1797 * http://www.apache.org/licenses/LICENSE-2.0 1798 * 1799 * Unless required by applicable law or agreed to in writing, software 1800 * distributed under the License is distributed on an "AS IS" BASIS, 1801 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1802 * See the License for the specific language governing permissions and 1803 * limitations under the License. 1804 */function Cd(n){return Number.isFinite(n)?n+Eu(n):`${n}`}function Eu(n){n=Math.abs(n);const e=n%100;if(e>=10&&e<=20)return"th";const t=n%10;return t===1?"st":t===2?"nd":t===3?"rd":"th"}/** 1805 * @license 1806 * Copyright 2021 Google LLC 1807 * 1808 * Licensed under the Apache License, Version 2.0 (the "License"); 1809 * you may not use this file except in compliance with the License. 1810 * You may obtain a copy of the License at 1811 * 1812 * http://www.apache.org/licenses/LICENSE-2.0 1813 * 1814 * Unless required by applicable law or agreed to in writing, software 1815 * distributed under the License is distributed on an "AS IS" BASIS, 1816 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1817 * See the License for the specific language governing permissions and 1818 * limitations under the License. 1819 */function wd(n){return n&&n._delegate?n._delegate:n}const Cu="@firebase/database-compat",wu="0.2.10";/** 1820 * @license 1821 * Copyright 2021 Google LLC 1822 * 1823 * Licensed under the Apache License, Version 2.0 (the "License"); 1824 * you may not use this file except in compliance with the License. 1825 * You may obtain a copy of the License at 1826 * 1827 * http://www.apache.org/licenses/LICENSE-2.0 1828 * 1829 * Unless required by applicable law or agreed to in writing, software 1830 * distributed under the License is distributed on an "AS IS" BASIS, 1831 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1832 * See the License for the specific language governing permissions and 1833 * limitations under the License. 1834 */const bu=new Mt.Vy("@firebase/database-compat"),ta=function(n){const e="FIREBASE WARNING: "+n;bu.warn(e)};/** 1835 * @license 1836 * Copyright 2021 Google LLC 1837 * 1838 * Licensed under the Apache License, Version 2.0 (the "License"); 1839 * you may not use this file except in compliance with the License. 1840 * You may obtain a copy of the License at 1841 * 1842 * http://www.apache.org/licenses/LICENSE-2.0 1843 * 1844 * Unless required by applicable law or agreed to in writing, software 1845 * distributed under the License is distributed on an "AS IS" BASIS, 1846 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1847 * See the License for the specific language governing permissions and 1848 * limitations under the License. 1849 */const Su=function(n,e,t,i){if(!(i&&t===void 0)&&typeof t!="boolean")throw new Error(Ke(n,e)+"must be a boolean.")},Tu=function(n,e,t){if(!(t&&e===void 0))switch(e){case"value":case"child_added":case"child_removed":case"child_changed":case"child_moved":break;default:throw new Error(Ke(n,"eventType")+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}};/** 1850 * @license 1851 * Copyright 2017 Google LLC 1852 * 1853 * Licensed under the Apache License, Version 2.0 (the "License");
1854 * you may not use this file except in compliance with the License. 1855 * You may obtain a copy of the License at 1856 * 1857 * http://www.apache.org/licenses/LICENSE-2.0 1858 * 1859 * Unless required by applicable law or agreed to in writing, software 1860 * distributed under the License is distributed on an "AS IS" BASIS, 1861 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1862 * See the License for the specific language governing permissions and 1863 * limitations under the License. 1864 */class xu{constructor(e){this._delegate=e}cancel(e){b("OnDisconnect.cancel",0,1,arguments.length),K("OnDisconnect.cancel","onComplete",e,!0);const t=this._delegate.cancel();return e&&t.then(()=>e(null),i=>e(i)),t}remove(e){b("OnDisconnect.remove",0,1,arguments.length),K("OnDisconnect.remove","onComplete",e,!0);const t=this._delegate.remove();return e&&t.then(()=>e(null),i=>e(i)),t}set(e,t){b("OnDisconnect.set",1,2,arguments.length),K("OnDisconnect.set","onComplete",t,!0);const i=this._delegate.set(e);return t&&i.then(()=>t(null),s=>t(s)),i}setWithPriority(e,t,i){b("OnDisconnect.setWithPriority",2,3,arguments.length),K("OnDisconnect.setWithPriority","onComplete",i,!0);const s=this._delegate.setWithPriority(e,t);return i&&s.then(()=>i(null),r=>i(r)),s}update(e,t){if(b("OnDisconnect.update",1,2,arguments.length),Array.isArray(e)){const s={};for(let r=0;r<e.length;++r)s[""+r]=e[r];e=s,ta("Passing an Array to firebase.database.onDisconnect().update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}K("OnDisconnect.update","onComplete",t,!0);const i=this._delegate.update(e);return t&&i.then(()=>t(null),s=>t(s)),i}}/** 1865 * @license 1866 * Copyright 2017 Google LLC 1867 * 1868 * Licensed under the Apache License, Version 2.0 (the "License"); 1869 * you may not use this file except in compliance with the License. 1870 * You may obtain a copy of the License at 1871 * 1872 * http://www.apache.org/licenses/LICENSE-2.0 1873 * 1874 * Unless required by applicable law or agreed to in writing, software 1875 * distributed under the License is distributed on an "AS IS" BASIS, 1876 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1877 * See the License for the specific language governing permissions and 1878 * limitations under the License. 1879 */class Iu{constructor(e,t){this.committed=e,this.snapshot=t}toJSON(){return b("TransactionResult.toJSON",0,1,arguments.length),{committed:this.committed,snapshot:this.snapshot.toJSON()}}}/** 1880 * @license 1881 * Copyright 2017 Google LLC 1882 * 1883 * Licensed under the Apache License, Version 2.0 (the "License"); 1884 * you may not use this file except in compliance with the License. 1885 * You may obtain a copy of the License at 1886 * 1887 * http://www.apache.org/licenses/LICENSE-2.0 1888 * 1889 * Unless required by applicable law or agreed to in writing, software 1890 * distributed under the License is distributed on an "AS IS" BASIS, 1891 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1892 * See the License for the specific language governing permissions and 1893 * limitations under the License. 1894 */class qe{constructor(e,t){this._database=e,this._delegate=t}val(){return b("DataSnapshot.val",0,0,arguments.length),this._delegate.val()}exportVal(){return b("DataSnapshot.exportVal",0,0,arguments.length),this._delegate.exportVal()}toJSON(){return b("DataSnapshot.toJSON",0,1,arguments.length),this._delegate.toJSON()}exists(){return b("DataSnapshot.exists",0,0,arguments.length),this._delegate.exists()}child(e){return b("DataSnapshot.child",0,1,arguments.length),e=String(e),sn("DataSnapshot.child","path",e,!1),new qe(this._database,this._delegate.child(e))}hasChild(e){return b("DataSnapshot.hasChild",1,1,arguments.length),sn("DataSnapshot.hasChild","path",e,!1),this._delegate.hasChild(e)}getPriority(){return b("DataSnapshot.getPriority",0,0,arguments.length),this._delegate.priority}forEach(e){return b("DataSnapshot.forEach",1,1,arguments.length),K("DataSnapshot.forEach","action",e,!1),this._delegate.forEach(t=>e(new qe(this._database,t)))}hasChildren(){return b("DataSnapshot.hasChildren",0,0,arguments.length),this._delegate.hasChildren()}get key(){return this._delegate.key}numChildren(){return b("DataSnapshot.numChildren",0,0,arguments.length),this._delegate.size}getRef(){return b("DataSnapshot.ref",0,0,arguments.length),new ce(this._database,this._delegate.ref)}get ref(){return this.getRef()}}class Y{constructor(e,t){this.database=e,this._delegate=t}on(e,t,i,s){var r;b("Query.on",2,4,arguments.length),K("Query.on","callback",t,!1);const o=Y.getCancelAndContextArgs_("Query.on",i,s),a=(h,p)=>{t.call(o.context,new qe(this.database,h),p)};a.userCallback=t,a.context=o.context;const c=(r=o.cancel)===null||r===void 0?void 0:r.bind(o.context);switch(e){case"value":return gs(this._delegate,a,c),t;case"child_added":return Lo(this._delegate,a,c),t;case"child_removed":return Wo(this._delegate,a,c),t;case"child_changed":return Fo(this._delegate,a,c),t;case"child_moved":return Bo(this._delegate,a,c),t;default:throw new Error(Ke("Query.on","eventType")+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}}off(e,t,i){if(b("Query.off",0,3,arguments.length),Tu("Query.off",e,!0),K("Query.off","callback",t,!0),ea("Query.off","context",i,!0),t){const s=()=>{};s.userCallback=t,s.context=i,Uo(this._delegate,e,s)}else Uo(this._delegate,e)}get(){return _h(this._delegate).then(e=>new qe(this.database,e))}once(e,t,i,s){b("Query.once",1,4,arguments.length),K("Query.once","callback",t,!0);const r=Y.getCancelAndContextArgs_("Query.once",i,s),o=new Jo,a=(h,p)=>{const f=new qe(this.database,h);t&&t.call(r.context,f,p),o.resolve(f)};a.userCallback=t,a.context=r.context;const c=h=>{r.cancel&&r.cancel.call(r.context,h),o.reject(h)};switch(e){case"value":gs(this._delegate,a,c,{onlyOnce:!0});break;case"child_added":Lo(this._delegate,a,c,{onlyOnce:!0});break;case"child_removed":Wo(this._delegate,a,c,{onlyOnce:!0});break;case"child_changed":Fo(this._delegate,a,c,{onlyOnce:!0});break;case"child_moved":Bo(this._delegate,a,c,{onlyOnce:!0});break;default:throw new Error(Ke("Query.once","eventType")+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}return o.promise}limitToFirst(e){return b("Query.limitToFirst",1,1,arguments.length),new Y(this.database,Se(this._delegate,wh(e)))}limitToLast(e){return b("Query.limitToLast",1,1,arguments.length),new Y(this.database,Se(this._delegate,Sh(e)))}orderByChild(e){return b("Query.orderByChild",1,1,arguments.length),new Y(this.database,Se(this._delegate,xh(e)))}orderByKey(){return b("Query.orderByKey",0,0,arguments.length),new Y(this.database,Se(this._delegate,Ah()))}orderByPriority(){return b("Query.orderByPriority",0,0,arguments.length),new Y(this.database,Se(this._delegate,Rh()))}orderByValue(){return b("Query.orderByValue",0,0,arguments.length),new Y(this.database,Se(this._delegate,Ph()))}startAt(e=null,t){return b("Query.startAt",0,2,arguments.length),new Y(this.database,Se(this._delegate,yh(e,t)))}startAfter(e=null,t){return b("Query.startAfter",0,2,arguments.length),new Y(this.database,Se(this._delegate,Eh(e,t)))}endAt(e=null,t){return b("Query.endAt",0,2,arguments.length),new Y(this.database,Se(this._delegate,ph(e,t)))}endBefore(e=null,t){return b("Query.endBefore",0,2,arguments.length),new Y(this.database,Se(this._delegate,mh(e,t)))}equalTo(e,t){return b("Query.equalTo",1,2,arguments.length),new Y(this.database,Se(this._delegate,Dh(e,t)))}toString(){return b("Query.toString",0,0,arguments.length),this._delegate.toString()}toJSON(){return b("Query.toJSON",0,1,arguments.length),this._delegate.toJSON()}isEqual(e){if(b("Query.isEqual",1,1,arguments.length),!(e instanceof Y)){const t="Query.isEqual failed: First argument must be an instance of firebase.database.Query.";throw new Error(t)}return this._delegate.isEqual(e._delegate)}static getCancelAndContextArgs_(e,t,i){const s={cancel:void 0,context:void 0};if(t&&i)s.cancel=t,K(e,"cancel",s.cancel,!0),s.context=i,ea(e,"context",s.context,!0);else if(t)if(typeof t=="object"&&t!==null)s.context=t;else if(typeof t=="function")s.cancel=t;else throw new Error(Ke(e,"cancelOrContext")+" must either be a cancel callback or a context object.");return s}get ref(){return new ce(this.database,new me(this._delegate._repo,this._delegate._path))}}class ce extends Y{constructor(e,t){super(e,new re(t._repo,t._path,new bn,!1)),this.database=e,this._delegate=t}getKey(){return b("Reference.key",0,0,arguments.length),this._delegate.key}child(e){return b("Reference.child",1,1,arguments.length),typeof e=="number"&&(e=String(e)),new ce(this.database,at(this._delegate,e))}getParent(){b("Reference.parent",0,0,arguments.length);const e=this._delegate.parent;return e?new ce(this.database,e):null}getRoot(){return b("Reference.root",0,0,arguments.length),new ce(this.database,this._delegate.root)}set(e,t){b("Reference.set",1,2,arguments.length),K("Reference.set","onComplete",t,!0);const i=ps(this._delegate,e);return t&&i.then(()=>t(null),s=>t(s)),i}update(e,t){if(b("Reference.update",1,2,arguments.length),Array.isArray(e)){const s={};for(let r=0;r<e.length;++r)s[""+r]=e[r];
1894e=s,ta("Passing an Array to Firebase.update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}ge("Reference.update",this._delegate._path),K("Reference.update","onComplete",t,!0);const i=fh(this._delegate,e);return t&&i.then(()=>t(null),s=>t(s)),i}setWithPriority(e,t,i){b("Reference.setWithPriority",2,3,arguments.length),K("Reference.setWithPriority","onComplete",i,!0);const s=dh(this._delegate,e,t);return i&&s.then(()=>i(null),r=>i(r)),s}remove(e){b("Reference.remove",0,1,arguments.length),K("Reference.remove","onComplete",e,!0);const t=hh(this._delegate);return e&&t.then(()=>e(null),i=>e(i)),t}transaction(e,t,i){b("Reference.transaction",1,3,arguments.length),K("Reference.transaction","transactionUpdate",e,!1),K("Reference.transaction","onComplete",t,!0),Su("Reference.transaction","applyLocally",i,!0);const s=Jh(this._delegate,e,{applyLocally:i}).then(r=>new Iu(r.committed,new qe(this.database,r.snapshot)));return t&&s.then(r=>t(null,r.committed,r.snapshot),r=>t(r,!1,null)),s}setPriority(e,t){b("Reference.setPriority",1,2,arguments.length),K("Reference.setPriority","onComplete",t,!0);const i=uh(this._delegate,e);return t&&i.then(()=>t(null),s=>t(s)),i}push(e,t){b("Reference.push",0,2,arguments.length),K("Reference.push","onComplete",t,!0);const i=ch(this._delegate,e),s=i.then(o=>new ce(this.database,o));t&&s.then(()=>t(null),o=>t(o));const r=new ce(this.database,i);return r.then=s.then.bind(s),r.catch=s.catch.bind(s,void 0),r}onDisconnect(){return ge("Reference.onDisconnect",this._delegate._path),new xu(new ko(this._delegate._repo,this._delegate._path))}get key(){return this.getKey()}get parent(){return this.getParent()}get root(){return this.getRoot()}}/** 1895 * @license 1896 * Copyright 2017 Google LLC 1897 * 1898 * Licensed under the Apache License, Version 2.0 (the "License"); 1899 * you may not use this file except in compliance with the License. 1900 * You may obtain a copy of the License at 1901 * 1902 * http://www.apache.org/licenses/LICENSE-2.0 1903 * 1904 * Unless required by applicable law or agreed to in writing, software 1905 * distributed under the License is distributed on an "AS IS" BASIS, 1906 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1907 * See the License for the specific language governing permissions and 1908 * limitations under the License. 1909 */class cn{constructor(e,t){this._delegate=e,this.app=t,this.INTERNAL={delete:()=>this._delegate._delete(),forceWebSockets:Vh,forceLongPolling:jh}}useEmulator(e,t,i={}){Qo(this._delegate,e,t,i)}ref(e){if(b("database.ref",0,1,arguments.length),e instanceof ce){const t=Mo(this._delegate,e.toString());return new ce(this,t)}else{const t=Do(this._delegate,e);return new ce(this,t)}}refFromURL(e){b("database.refFromURL",1,1,arguments.length);const i=Mo(this._delegate,e);return new ce(this,i)}goOffline(){return b("database.goOffline",0,0,arguments.length),Hh(this._delegate)}goOnline(){return b("database.goOnline",0,0,arguments.length),zh(this._delegate)}}cn.ServerValue={TIMESTAMP:Kh(),increment:n=>qh(n)};/** 1910 * @license 1911 * Copyright 2017 Google LLC 1912 * 1913 * Licensed under the Apache License, Version 2.0 (the "License"); 1914 * you may not use this file except in compliance with the License. 1915 * You may obtain a copy of the License at 1916 * 1917 * http://www.apache.org/licenses/LICENSE-2.0 1918 * 1919 * Unless required by applicable law or agreed to in writing, software 1920 * distributed under the License is distributed on an "AS IS" BASIS, 1921 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1922 * See the License for the specific language governing permissions and 1923 * limitations under the License. 1924 */function Au({app:n,url:e,version:t,customAuthImpl:i,namespace:s,nodeAdmin:r=!1}){g(t);const o=new oe.Kq("auth-internal",new oe.h1("database-standalone"));return o.setComponent(new oe.uA("auth-internal",()=>i,"PRIVATE")),{instance:new cn(zo(n,o,void 0,e,r),n),namespace:s}}var Nu=Object.freeze({__proto__:null,initStandalone:Au});/** 1925 * @license 1926 * Copyright 2021 Google LLC 1927 * 1928 * Licensed under the Apache License, Version 2.0 (the "License");
1929 * you may not use this file except in compliance with the License. 1930 * You may obtain a copy of the License at 1931 * 1932 * http://www.apache.org/licenses/LICENSE-2.0 1933 * 1934 * Unless required by applicable law or agreed to in writing, software 1935 * distributed under the License is distributed on an "AS IS" BASIS, 1936 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1937 * See the License for the specific language governing permissions and 1938 * limitations under the License. 1939 */const Ru=cn.ServerValue;function Ou(n){n.INTERNAL.registerComponent(new oe.uA("database-compat",(e,{instanceIdentifier:t})=>{const i=e.getProvider("app-compat").getImmediate(),s=e.getProvider("database").getImmediate({identifier:t});return new cn(s,i)},"PUBLIC").setServiceProps({Reference:ce,Query:Y,Database:cn,DataSnapshot:qe,enableLogging:Gh,INTERNAL:Nu,ServerValue:Ru}).setMultipleInstances(!0)),n.registerVersion(Cu,wu)}Ou(Pe.A)},700134:(Fe,Ye,L)=>{L.d(Ye,{uA:()=>Hs,h1:()=>ci,Kq:()=>X});var Pe=L(80247),oe=L(288538);/** 1940 * @license 1941 * Copyright 2017 Google LLC 1942 * 1943 * Licensed under the Apache License, Version 2.0 (the "License"); 1944 * you may not use this file except in compliance with the License. 1945 * You may obtain a copy of the License at 1946 * 1947 * http://www.apache.org/licenses/LICENSE-2.0 1948 * 1949 * Unless required by applicable law or agreed to in writing, software 1950 * distributed under the License is distributed on an "AS IS" BASIS, 1951 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1952 * See the License for the specific language governing permissions and 1953 * limitations under the License. 1954 */const N={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"};/** 1955 * @license 1956 * Copyright 2017 Google LLC 1957 * 1958 * Licensed under the Apache License, Version 2.0 (the "License"); 1959 * you may not use this file except in compliance with the License. 1960 * You may obtain a copy of the License at 1961 * 1962 * http://www.apache.org/licenses/LICENSE-2.0 1963 * 1964 * Unless required by applicable law or agreed to in writing, software 1965 * distributed under the License is distributed on an "AS IS" BASIS, 1966 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1967 * See the License for the specific language governing permissions and 1968 * limitations under the License. 1969 */const Te=function(d,l){if(!d)throw Je(l)},Je=function(d){return new Error("Firebase Database ("+N.SDK_VERSION+") INTERNAL ASSERT FAILED: "+d)};/** 1970 * @license 1971 * Copyright 2017 Google LLC 1972 * 1973 * Licensed under the Apache License, Version 2.0 (the "License"); 1974 * you may not use this file except in compliance with the License. 1975 * You may obtain a copy of the License at 1976 * 1977 * http://www.apache.org/licenses/LICENSE-2.0 1978 * 1979 * Unless required by applicable law or agreed to in writing, software 1980 * distributed under the License is distributed on an "AS IS" BASIS, 1981 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1982 * See the License for the specific language governing permissions and 1983 * limitations under the License. 1984 */const Be=function(d){const l=[];let u=0;for(let g=0;g<d.length;g++){let _=d.charCodeAt(g);_<128?l[u++]=_:_<2048?(l[u++]=_>>6|192,l[u++]=_&63|128):(_&64512)===55296&&g+1<d.length&&(d.charCodeAt(g+1)&64512)===56320?(_=65536+((_&1023)<<10)+(d.charCodeAt(++g)&1023),l[u++]=_>>18|240,l[u++]=_>>12&63|128,l[u++]=_>>6&63|128,l[u++]=_&63|128):(l[u++]=_>>12|224,l[u++]=_>>6&63|128,l[u++]=_&63|128)}return l},y=function(d){const l=[];let u=0,g=0;for(;u<d.length;){const _=d[u++];if(_<128)l[g++]=String.fromCharCode(_);else if(_>191&&_<224){const E=d[u++];l[g++]=String.fromCharCode((_&31)<<6|E&63)}else if(_>239&&_<365){const E=d[u++],S=d[u++],O=d[u++],te=((_&7)<<18|(E&63)<<12|(S&63)<<6|O&63)-65536;l[g++]=String.fromCharCode(55296+(te>>10)),l[g++]=String.fromCharCode(56320+(te&1023))}else{const E=d[u++],S=d[u++];l[g++]=String.fromCharCode((_&15)<<12|(E&63)<<6|S&63)}}return l.join("")},ye={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(d,l){if(!Array.isArray(d))throw Error("encodeByteArray takes an array as a parameter");this.init_();const u=l?this.byteToCharMapWebSafe_:this.byteToCharMap_,g=[];for(let _=0;_<d.length;_+=3){const E=d[_],S=_+1<d.length,O=S?d[_+1]:0,te=_+2<d.length,H=te?d[_+2]:0,Ee=E>>2,P=(E&3)<<4|O>>4;let ne=(O&15)<<2|H>>6,fe=H&63;
1984te||(fe=64,S||(ne=64)),g.push(u[Ee],u[P],u[ne],u[fe])}return g.join("")},encodeString(d,l){return this.HAS_NATIVE_SUPPORT&&!l?btoa(d):this.encodeByteArray(Be(d),l)},decodeString(d,l){return this.HAS_NATIVE_SUPPORT&&!l?atob(d):y(this.decodeStringToByteArray(d,l))},decodeStringToByteArray(d,l){this.init_();const u=l?this.charToByteMapWebSafe_:this.charToByteMap_,g=[];for(let _=0;_<d.length;){const E=u[d.charAt(_++)],O=_<d.length?u[d.charAt(_)]:0;++_;const H=_<d.length?u[d.charAt(_)]:64;++_;const P=_<d.length?u[d.charAt(_)]:64;if(++_,E==null||O==null||H==null||P==null)throw Error();const ne=E<<2|O>>4;if(g.push(ne),H!==64){const fe=O<<4&240|H>>2;if(g.push(fe),P!==64){const fn=H<<6&192|P;g.push(fn)}}}return g},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let d=0;d<this.ENCODED_VALS.length;d++)this.byteToCharMap_[d]=this.ENCODED_VALS.charAt(d),this.charToByteMap_[this.byteToCharMap_[d]]=d,this.byteToCharMapWebSafe_[d]=this.ENCODED_VALS_WEBSAFE.charAt(d),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[d]]=d,d>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(d)]=d,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(d)]=d)}}},lt=function(d){const l=Be(d);return ye.encodeByteArray(l,!0)},ct=function(d){return lt(d).replace(/\./g,"")},D=function(d){try{return ye.decodeString(d,!0)}catch(l){Pe.error("base64Decode failed: ",l)}return null};/** 1985 * @license 1986 * Copyright 2017 Google LLC 1987 * 1988 * Licensed under the Apache License, Version 2.0 (the "License"); 1989 * you may not use this file except in compliance with the License. 1990 * You may obtain a copy of the License at 1991 * 1992 * http://www.apache.org/licenses/LICENSE-2.0 1993 * 1994 * Unless required by applicable law or agreed to in writing, software 1995 * distributed under the License is distributed on an "AS IS" BASIS, 1996 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1997 * See the License for the specific language governing permissions and 1998 * limitations under the License. 1999 */function T(d){return xe(void 0,d)}function xe(d,l){if(!(l instanceof Object))return l;switch(l.constructor){case Date:const u=l;return new Date(u.getTime());case Object:d===void 0&&(d={});break;case Array:d=[];break;default:return l}for(const u in l)!l.hasOwnProperty(u)||!he(u)||(d[u]=xe(d[u],l[u]));return d}function he(d){return d!=="__proto__"}/** 2000 * @license 2001 * Copyright 2017 Google LLC 2002 * 2003 * Licensed under the Apache License, Version 2.0 (the "License"); 2004 * you may not use this file except in compliance with the License. 2005 * You may obtain a copy of the License at 2006 * 2007 * http://www.apache.org/licenses/LICENSE-2.0 2008 * 2009 * Unless required by applicable law or agreed to in writing, software 2010 * distributed under the License is distributed on an "AS IS" BASIS, 2011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2012 * See the License for the specific language governing permissions and 2013 * limitations under the License. 2014 */function ue(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function ht(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(ue())}function ut(){try{return Object.prototype.toString.call(L.g.process)==="[object process]"}catch{return!1}}function Xe(){return typeof self=="object"&&self.self===self}function ee(){const d=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof d=="object"&&d.id!==void 0}function Zn(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function na(){return ue().indexOf("Electron/")>=0}function ia(){const d=ue();return d.indexOf("MSIE ")>=0||d.indexOf("Trident/")>=0}function Ts(){return ue().indexOf("MSAppHost/")>=0}function sa(){return N.NODE_CLIENT===!0||N.NODE_ADMIN===!0}function ra(){return!ut()&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function oa(){return typeof indexedDB=="object"}function Ie(){return new Promise((d,l)=>{try{let u=!0;const g="validate-browser-context-for-indexeddb-analytics-module",_=self.indexedDB.open(g);_.onsuccess=()=>{_.result.close(),u||self.indexedDB.deleteDatabase(g),d(!0)},_.onupgradeneeded=()=>{u=!1},_.onerror=()=>{var E;l(((E=_.error)===null||E===void 0?void 0:E.message)||"")}}catch(u){l(u)}})}function aa(){return!(typeof navigator>"u"||!navigator.cookieEnabled)}function xs(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof L.g<"u")return L.g;throw new Error("Unable to locate global object.")}/** 2015 * @license 2016 * Copyright 2022 Google LLC 2017 * 2018 * Licensed under the Apache License, Version 2.0 (the "License");
2019 * you may not use this file except in compliance with the License. 2020 * You may obtain a copy of the License at 2021 * 2022 * http://www.apache.org/licenses/LICENSE-2.0 2023 * 2024 * Unless required by applicable law or agreed to in writing, software 2025 * distributed under the License is distributed on an "AS IS" BASIS, 2026 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2027 * See the License for the specific language governing permissions and 2028 * limitations under the License. 2029 */const Is=()=>xs().__FIREBASE_DEFAULTS__,As=()=>{if(typeof oe>"u"||typeof oe.env>"u")return;const d=oe.env.__FIREBASE_DEFAULTS__;if(d)return JSON.parse(d)},ei=()=>{if(typeof document>"u")return;let d;try{d=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const l=d&&D(d[1]);return l&&JSON.parse(l)},Nt=()=>{try{return Is()||As()||ei()}catch(d){Pe.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${d}`);return}},ti=d=>{var l,u;return(u=(l=Nt())===null||l===void 0?void 0:l.emulatorHosts)===null||u===void 0?void 0:u[d]},Ns=d=>{const l=ti(d);if(!l)return;const u=l.lastIndexOf(":");if(u<=0||u+1===l.length)throw new Error(`Invalid host ${l} with no separate hostname and port!`);const g=parseInt(l.substring(u+1),10);return l[0]==="["?[l.substring(1,u-1),g]:[l.substring(0,u),g]},hn=()=>{var d;return(d=Nt())===null||d===void 0?void 0:d.config},Rs=d=>{var l;return(l=Nt())===null||l===void 0?void 0:l[`_${d}`]};/** 2030 * @license 2031 * Copyright 2017 Google LLC 2032 * 2033 * Licensed under the Apache License, Version 2.0 (the "License"); 2034 * you may not use this file except in compliance with the License. 2035 * You may obtain a copy of the License at 2036 * 2037 * http://www.apache.org/licenses/LICENSE-2.0 2038 * 2039 * Unless required by applicable law or agreed to in writing, software 2040 * distributed under the License is distributed on an "AS IS" BASIS, 2041 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2042 * See the License for the specific language governing permissions and 2043 * limitations under the License. 2044 */class ni{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((l,u)=>{this.resolve=l,this.reject=u})}wrapCallback(l){return(u,g)=>{u?this.reject(u):this.resolve(g),typeof l=="function"&&(this.promise.catch(()=>{}),l.length===1?l(u):l(u,g))}}}/** 2045 * @license 2046 * Copyright 2021 Google LLC 2047 * 2048 * Licensed under the Apache License, Version 2.0 (the "License"); 2049 * you may not use this file except in compliance with the License. 2050 * You may obtain a copy of the License at 2051 * 2052 * http://www.apache.org/licenses/LICENSE-2.0 2053 * 2054 * Unless required by applicable law or agreed to in writing, software 2055 * distributed under the License is distributed on an "AS IS" BASIS, 2056 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2057 * See the License for the specific language governing permissions and 2058 * limitations under the License. 2059 */function la(d,l){if(d.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const u={alg:"none",type:"JWT"},g=l||"demo-project",_=d.iat||0,E=d.sub||d.user_id;if(!E)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const S=Object.assign({iss:`https://securetoken.google.com/${g}`,aud:g,iat:_,exp:_+3600,auth_time:_,sub:E,user_id:E,firebase:{sign_in_provider:"custom",identities:{}}},d),O="";return[ct(JSON.stringify(u)),ct(JSON.stringify(S)),O].join(".")}/** 2060 * @license 2061 * Copyright 2017 Google LLC 2062 * 2063 * Licensed under the Apache License, Version 2.0 (the "License"); 2064 * you may not use this file except in compliance with the License. 2065 * You may obtain a copy of the License at 2066 * 2067 * http://www.apache.org/licenses/LICENSE-2.0 2068 * 2069 * Unless required by applicable law or agreed to in writing, software 2070 * distributed under the License is distributed on an "AS IS" BASIS, 2071 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2072 * See the License for the specific language governing permissions and 2073 * limitations under the License. 2074 */const Os="FirebaseError";class q extends Error{constructor(l,u,g){super(u),this.code=l,this.customData=g,this.name=Os,Object.setPrototypeOf(this,q.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,ii.prototype.create)}}class ii{constructor(l,u,g){this.service=l,this.serviceName=u,this.errors=g}create(l,...u){const g=u[0]||{},_=`${this.service}/${l}`,E=this.errors[l],S=E?si(E,g):"Error",O=`${this.serviceName}: ${S} (${_}).`;return new q(_,O,g)}}function si(d,l){return d.replace(Rt,(u,g)=>{const _=l[g];return _!=null?String(_):`<${g}?>`})}const Rt=/\{\$([^}]+)}/g;/** 2075 * @license 2076 * Copyright 2017 Google LLC 2077 * 2078 * Licensed under the Apache License, Version 2.0 (the "License");
2079 * you may not use this file except in compliance with the License. 2080 * You may obtain a copy of the License at 2081 * 2082 * http://www.apache.org/licenses/LICENSE-2.0 2083 * 2084 * Unless required by applicable law or agreed to in writing, software 2085 * distributed under the License is distributed on an "AS IS" BASIS, 2086 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2087 * See the License for the specific language governing permissions and 2088 * limitations under the License. 2089 */function un(d){return JSON.parse(d)}function Ps(d){return JSON.stringify(d)}/** 2090 * @license 2091 * Copyright 2017 Google LLC 2092 * 2093 * Licensed under the Apache License, Version 2.0 (the "License"); 2094 * you may not use this file except in compliance with the License. 2095 * You may obtain a copy of the License at 2096 * 2097 * http://www.apache.org/licenses/LICENSE-2.0 2098 * 2099 * Unless required by applicable law or agreed to in writing, software 2100 * distributed under the License is distributed on an "AS IS" BASIS, 2101 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2102 * See the License for the specific language governing permissions and 2103 * limitations under the License. 2104 */const dt=function(d){let l={},u={},g={},_="";try{const E=d.split(".");l=un(D(E[0])||""),u=un(D(E[1])||""),_=E[2],g=u.d||{},delete u.d}catch{}return{header:l,claims:u,data:g,signature:_}},ft=function(d){const l=dt(d).claims,u=Math.floor(new Date().getTime()/1e3);let g=0,_=0;return typeof l=="object"&&(l.hasOwnProperty("nbf")?g=l.nbf:l.hasOwnProperty("iat")&&(g=l.iat),l.hasOwnProperty("exp")?_=l.exp:_=g+86400),!!u&&!!g&&!!_&&u>=g&&u<=_},j=function(d){const l=dt(d).claims;return typeof l=="object"&&l.hasOwnProperty("iat")?l.iat:null},Ot=function(d){const l=dt(d),u=l.claims;return!!u&&typeof u=="object"&&u.hasOwnProperty("iat")},ca=function(d){const l=dt(d).claims;return typeof l=="object"&&l.admin===!0};/** 2105 * @license 2106 * Copyright 2017 Google LLC 2107 * 2108 * Licensed under the Apache License, Version 2.0 (the "License"); 2109 * you may not use this file except in compliance with the License. 2110 * You may obtain a copy of the License at 2111 * 2112 * http://www.apache.org/licenses/LICENSE-2.0 2113 * 2114 * Unless required by applicable law or agreed to in writing, software 2115 * distributed under the License is distributed on an "AS IS" BASIS, 2116 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2117 * See the License for the specific language governing permissions and 2118 * limitations under the License. 2119 */function ha(d,l){return Object.prototype.hasOwnProperty.call(d,l)}function ks(d,l){if(Object.prototype.hasOwnProperty.call(d,l))return d[l]}function Ds(d){for(const l in d)if(Object.prototype.hasOwnProperty.call(d,l))return!1;return!0}function de(d,l,u){const g={};for(const _ in d)Object.prototype.hasOwnProperty.call(d,_)&&(g[_]=l.call(u,d[_],_,d));return g}function ke(d,l){if(d===l)return!0;const u=Object.keys(d),g=Object.keys(l);for(const _ of u){if(!g.includes(_))return!1;const E=d[_],S=l[_];if(_t(E)&&_t(S)){if(!ke(E,S))return!1}else if(E!==S)return!1}for(const _ of g)if(!u.includes(_))return!1;return!0}function _t(d){return d!==null&&typeof d=="object"}/** 2120 * @license 2121 * Copyright 2022 Google LLC 2122 * 2123 * Licensed under the Apache License, Version 2.0 (the "License"); 2124 * you may not use this file except in compliance with the License. 2125 * You may obtain a copy of the License at 2126 * 2127 * http://www.apache.org/licenses/LICENSE-2.0 2128 * 2129 * Unless required by applicable law or agreed to in writing, software 2130 * distributed under the License is distributed on an "AS IS" BASIS, 2131 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2132 * See the License for the specific language governing permissions and 2133 * limitations under the License. 2134 */function Pt(d,l=2e3){const u=new ni;return setTimeout(()=>u.reject("timeout!"),l),d.then(u.resolve,u.reject),u.promise}/** 2135 * @license 2136 * Copyright 2017 Google LLC 2137 * 2138 * Licensed under the Apache License, Version 2.0 (the "License"); 2139 * you may not use this file except in compliance with the License. 2140 * You may obtain a copy of the License at 2141 * 2142 * http://www.apache.org/licenses/LICENSE-2.0 2143 * 2144 * Unless required by applicable law or agreed to in writing, softw
2144are 2145 * distributed under the License is distributed on an "AS IS" BASIS, 2146 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2147 * See the License for the specific language governing permissions and 2148 * limitations under the License. 2149 */function Ms(d){const l=[];for(const[u,g]of Object.entries(d))Array.isArray(g)?g.forEach(_=>{l.push(encodeURIComponent(u)+"="+encodeURIComponent(_))}):l.push(encodeURIComponent(u)+"="+encodeURIComponent(g));return l.length?"&"+l.join("&"):""}function ri(d){const l={};return d.replace(/^\?/,"").split("&").forEach(g=>{if(g){const[_,E]=g.split("=");l[decodeURIComponent(_)]=decodeURIComponent(E)}}),l}function ua(d){const l=d.indexOf("?");if(!l)return"";const u=d.indexOf("#",l);return d.substring(l,u>0?u:void 0)}/** 2150 * @license 2151 * Copyright 2017 Google LLC 2152 * 2153 * Licensed under the Apache License, Version 2.0 (the "License"); 2154 * you may not use this file except in compliance with the License. 2155 * You may obtain a copy of the License at 2156 * 2157 * http://www.apache.org/licenses/LICENSE-2.0 2158 * 2159 * Unless required by applicable law or agreed to in writing, software 2160 * distributed under the License is distributed on an "AS IS" BASIS, 2161 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2162 * See the License for the specific language governing permissions and 2163 * limitations under the License. 2164 */class Ls{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=512/8,this.pad_[0]=128;for(let l=1;l<this.blockSize;++l)this.pad_[l]=0;this.reset()}reset(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0}compress_(l,u){u||(u=0);const g=this.W_;if(typeof l=="string")for(let P=0;P<16;P++)g[P]=l.charCodeAt(u)<<24|l.charCodeAt(u+1)<<16|l.charCodeAt(u+2)<<8|l.charCodeAt(u+3),u+=4;else for(let P=0;P<16;P++)g[P]=l[u]<<24|l[u+1]<<16|l[u+2]<<8|l[u+3],u+=4;for(let P=16;P<80;P++){const ne=g[P-3]^g[P-8]^g[P-14]^g[P-16];g[P]=(ne<<1|ne>>>31)&4294967295}let _=this.chain_[0],E=this.chain_[1],S=this.chain_[2],O=this.chain_[3],te=this.chain_[4],H,Ee;for(let P=0;P<80;P++){P<40?P<20?(H=O^E&(S^O),Ee=1518500249):(H=E^S^O,Ee=1859775393):P<60?(H=E&S|O&(E|S),Ee=2400959708):(H=E^S^O,Ee=3395469782);const ne=(_<<5|_>>>27)+H+te+Ee+g[P]&4294967295;te=O,O=S,S=(E<<30|E>>>2)&4294967295,E=_,_=ne}this.chain_[0]=this.chain_[0]+_&4294967295,this.chain_[1]=this.chain_[1]+E&4294967295,this.chain_[2]=this.chain_[2]+S&4294967295,this.chain_[3]=this.chain_[3]+O&4294967295,this.chain_[4]=this.chain_[4]+te&4294967295}update(l,u){if(l==null)return;u===void 0&&(u=l.length);const g=u-this.blockSize;let _=0;const E=this.buf_;let S=this.inbuf_;for(;_<u;){if(S===0)for(;_<=g;)this.compress_(l,_),_+=this.blockSize;if(typeof l=="string"){for(;_<u;)if(E[S]=l.charCodeAt(_),++S,++_,S===this.blockSize){this.compress_(E),S=0;break}}else for(;_<u;)if(E[S]=l[_],++S,++_,S===this.blockSize){this.compress_(E),S=0;break}}this.inbuf_=S,this.total_+=u}digest(){const l=[];let u=this.total_*8;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let _=this.blockSize-1;_>=56;_--)this.buf_[_]=u&255,u/=256;this.compress_(this.buf_);let g=0;for(let _=0;_<5;_++)for(let E=24;E>=0;E-=8)l[g]=this.chain_[_]>>E&255,++g;return l}}function da(d,l){const u=new Fs(d,l);return u.subscribe.bind(u)}class Fs{constructor(l,u){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=u,this.task.then(()=>{l(this)}).catch(g=>{this.error(g)})}next(l){this.forEachObserver(u=>{u.next(l)})}error(l){this.forEachObserver(u=>{u.error(l)}),this.close(l)}complete(){this.forEachObserver(l=>{l.complete()}),this.close()}subscribe(l,u,g){let _;if(l===void 0&&u===void 0&&g===void 0)throw new Error("Missing Observer.");Ws(l,["next","error","complete"])?_=l:_={next:l,error:u,complete:g},_.next===void 0&&(_.next=kt),_.error===void 0&&(_.error=kt),_.complete===void 0&&(_.complete=kt);const E=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?_.error(this.finalError):_.complete()}catch{}}),this.observers.push(_),E}unsubscribeOne(l){this.observers===void 0||this.observers[l]===void 0||(delete this.observers[l],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(l){if(!this.finalized)for(let u=0;u<this.observers.length;u++)this.sendOne(u,l)}sendOne(l,u){this.task.then(()=>
2164{if(this.observers!==void 0&&this.observers[l]!==void 0)try{u(this.observers[l])}catch(g){typeof Pe<"u"&&Pe.error&&Pe.error(g)}})}close(l){this.finalized||(this.finalized=!0,l!==void 0&&(this.finalError=l),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function Bs(d,l){return(...u)=>{Promise.resolve(!0).then(()=>{d(...u)}).catch(g=>{l&&l(g)})}}function Ws(d,l){if(typeof d!="object"||d===null)return!1;for(const u of l)if(u in d&&typeof d[u]=="function")return!0;return!1}function kt(){}/** 2165 * @license 2166 * Copyright 2017 Google LLC 2167 * 2168 * Licensed under the Apache License, Version 2.0 (the "License"); 2169 * you may not use this file except in compliance with the License. 2170 * You may obtain a copy of the License at 2171 * 2172 * http://www.apache.org/licenses/LICENSE-2.0 2173 * 2174 * Unless required by applicable law or agreed to in writing, software 2175 * distributed under the License is distributed on an "AS IS" BASIS, 2176 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2177 * See the License for the specific language governing permissions and 2178 * limitations under the License. 2179 */const fa=function(d,l,u,g){let _;if(g<l?_="at least "+l:g>u&&(_=u===0?"none":"no more than "+u),_){const E=d+" failed: Was called with "+g+(g===1?" argument.":" arguments.")+" Expects "+_+".";throw new Error(E)}};function Dt(d,l){return`${d} failed: ${l} argument `}function dn(d,l,u){if(!(u&&!l)&&typeof l!="string")throw new Error(Dt(d,"namespace")+"must be a valid firebase namespace.")}function _a(d,l,u,g){if(!(g&&!u)&&typeof u!="function")throw new Error(Dt(d,l)+"must be a valid function.")}function ve(d,l,u,g){if(!(g&&!u)&&(typeof u!="object"||u===null))throw new Error(Dt(d,l)+"must be a valid context object.")}/** 2180 * @license 2181 * Copyright 2017 Google LLC 2182 * 2183 * Licensed under the Apache License, Version 2.0 (the "License"); 2184 * you may not use this file except in compliance with the License. 2185 * You may obtain a copy of the License at 2186 * 2187 * http://www.apache.org/licenses/LICENSE-2.0 2188 * 2189 * Unless required by applicable law or agreed to in writing, software 2190 * distributed under the License is distributed on an "AS IS" BASIS, 2191 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2192 * See the License for the specific language governing permissions and 2193 * limitations under the License. 2194 */const pa=function(d){const l=[];let u=0;for(let g=0;g<d.length;g++){let _=d.charCodeAt(g);if(_>=55296&&_<=56319){const E=_-55296;g++,Te(g<d.length,"Surrogate pair missing trail surrogate.");const S=d.charCodeAt(g)-56320;_=65536+(E<<10)+S}_<128?l[u++]=_:_<2048?(l[u++]=_>>6|192,l[u++]=_&63|128):_<65536?(l[u++]=_>>12|224,l[u++]=_>>6&63|128,l[u++]=_&63|128):(l[u++]=_>>18|240,l[u++]=_>>12&63|128,l[u++]=_>>6&63|128,l[u++]=_&63|128)}return l},ga=function(d){let l=0;for(let u=0;u<d.length;
2194u++){const g=d.charCodeAt(u);g<128?l++:g<2048?l+=2:g>=55296&&g<=56319?(l+=4,u++):l+=3}return l};/** 2195 * @license 2196 * Copyright 2022 Google LLC 2197 * 2198 * Licensed under the Apache License, Version 2.0 (the "License"); 2199 * you may not use this file except in compliance with the License. 2200 * You may obtain a copy of the License at 2201 * 2202 * http://www.apache.org/licenses/LICENSE-2.0 2203 * 2204 * Unless required by applicable law or agreed to in writing, software 2205 * distributed under the License is distributed on an "AS IS" BASIS, 2206 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2207 * See the License for the specific language governing permissions and 2208 * limitations under the License. 2209 */const ma=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,d=>{const l=Math.random()*16|0;return(d==="x"?l:l&3|8).toString(16)})};/** 2210 * @license 2211 * Copyright 2019 Google LLC 2212 * 2213 * Licensed under the Apache License, Version 2.0 (the "License"); 2214 * you may not use this file except in compliance with the License. 2215 * You may obtain a copy of the License at 2216 * 2217 * http://www.apache.org/licenses/LICENSE-2.0 2218 * 2219 * Unless required by applicable law or agreed to in writing, software 2220 * distributed under the License is distributed on an "AS IS" BASIS, 2221 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2222 * See the License for the specific language governing permissions and 2223 * limitations under the License. 2224 */const oi=1e3,pt=2,Us=null,ai=.5;function Vs(d,l=oi,u=pt){const g=l*Math.pow(u,d),_=Math.round(ai*g*(Math.random()-.5)*2);return Math.min(Us,g+_)}/** 2225 * @license 2226 * Copyright 2020 Google LLC 2227 * 2228 * Licensed under the Apache License, Version 2.0 (the "License"); 2229 * you may not use this file except in compliance with the License. 2230 * You may obtain a copy of the License at 2231 * 2232 * http://www.apache.org/licenses/LICENSE-2.0 2233 * 2234 * Unless required by applicable law or agreed to in writing, software 2235 * distributed under the License is distributed on an "AS IS" BASIS, 2236 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2237 * See the License for the specific language governing permissions and 2238 * limitations under the License. 2239 */function js(d){return Number.isFinite(d)?d+li(d):`${d}`}function li(d){d=Math.abs(d);const l=d%100;if(l>=10&&l<=20)return"th";const u=d%10;return u===1?"st":u===2?"nd":u===3?"rd":"th"}/** 2240 * @license 2241 * Copyright 2021 Google LLC 2242 * 2243 * Licensed under the Apache License, Version 2.0 (the "License"); 2244 * you may not use this file except in compliance with the License. 2245 * You may obtain a copy of the License at 2246 * 2247 * http://www.apache.org/licenses/LICENSE-2.0 2248 * 2249 * Unless required by applicable law or agreed to in writing, software 2250 * distributed under the License is distributed on an "AS IS" BASIS, 2251 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2252 * See the License for the specific language governing permissions and 2253 * limitations under the License. 2254 */function ya(d){return d&&d._delegate?d._delegate:d}class Hs{constructor(l,u,g){this.name=l,this.instanceFactory=u,this.type=g,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(l){return this.instantiationMode=l,this}setMultipleInstances(l){return this.multipleInstances=l,this}setServiceProps(l){return this.serviceProps=l,this}setInstanceCreatedCallback(l){return this.onInstanceCreated=l,this}}/** 2255 * @license 2256 * Copyright 2019 Google LLC 2257 * 2258 * Licensed under the Apache License, Version 2.0 (the "License"); 2259 * you may not use this file except in compliance with the License. 2260 * You may obtain a copy of the License at 2261 * 2262 * http://www.apache.org/licenses/LICENSE-2.0 2263 * 2264 * Unless required by applicable law or agreed to in writing, software 2265 * distributed under the License is distributed on an "AS IS" BASIS, 2266 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2267 * See the License for the specific language governing permissions and 2268 * limitations under the License. 2269 */const De="[DEFAULT]";/** 2270 * @license 2271 * Copyright 2019 Google LLC 2272 * 2273 * Licensed under the Apache License, Version 2.0 (the "License");
2274 * you may not use this file except in compliance with the License. 2275 * You may obtain a copy of the License at 2276 * 2277 * http://www.apache.org/licenses/LICENSE-2.0 2278 * 2279 * Unless required by applicable law or agreed to in writing, software 2280 * distributed under the License is distributed on an "AS IS" BASIS, 2281 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2282 * See the License for the specific language governing permissions and 2283 * limitations under the License. 2284 */class X{constructor(l,u){this.name=l,this.container=u,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(l){const u=this.normalizeInstanceIdentifier(l);if(!this.instancesDeferred.has(u)){const g=new ni;if(this.instancesDeferred.set(u,g),this.isInitialized(u)||this.shouldAutoInitialize())try{const _=this.getOrInitializeService({instanceIdentifier:u});_&&g.resolve(_)}catch{}}return this.instancesDeferred.get(u).promise}getImmediate(l){var u;const g=this.normalizeInstanceIdentifier(l?.identifier),_=(u=l?.optional)!==null&&u!==void 0?u:!1;if(this.isInitialized(g)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:g})}catch(E){if(_)return null;throw E}else{if(_)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(l){if(l.name!==this.name)throw Error(`Mismatching Component ${l.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=l,!!this.shouldAutoInitialize()){if(Ze(l))try{this.getOrInitializeService({instanceIdentifier:De})}catch{}for(const[u,g]of this.instancesDeferred.entries()){const _=this.normalizeInstanceIdentifier(u);try{const E=this.getOrInitializeService({instanceIdentifier:_});g.resolve(E)}catch{}}}}clearInstance(l=De){this.instancesDeferred.delete(l),this.instancesOptions.delete(l),this.instances.delete(l)}async delete(){const l=Array.from(this.instances.values());await Promise.all([...l.filter(u=>"INTERNAL"in u).map(u=>u.INTERNAL.delete()),...l.filter(u=>"_delete"in u).map(u=>u._delete())])}isComponentSet(){return this.component!=null}isInitialized(l=De){return this.instances.has(l)}getOptions(l=De){return this.instancesOptions.get(l)||{}}initialize(l={}){const{options:u={}}=l,g=this.normalizeInstanceIdentifier(l.instanceIdentifier);if(this.isInitialized(g))throw Error(`${this.name}(${g}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const _=this.getOrInitializeService({instanceIdentifier:g,options:u});for(const[E,S]of this.instancesDeferred.entries()){const O=this.normalizeInstanceIdentifier(E);g===O&&S.resolve(_)}return _}onInit(l,u){var g;const _=this.normalizeInstanceIdentifier(u),E=(g=this.onInitCallbacks.get(_))!==null&&g!==void 0?g:new Set;E.add(l),this.onInitCallbacks.set(_,E);const S=this.instances.get(_);return S&&l(S,_),()=>{E.delete(l)}}invokeOnInitCallbacks(l,u){const g=this.onInitCallbacks.get(u);if(g)for(const _ of g)try{_(l,u)}catch{}}getOrInitializeService({instanceIdentifier:l,options:u={}}){let g=this.instances.get(l);if(!g&&this.component&&(g=this.component.instanceFactory(this.container,{instanceIdentifier:Mt(l),options:u}),this.instances.set(l,g),this.instancesOptions.set(l,u),this.invokeOnInitCallbacks(g,l),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,l,g)}catch{}return g||null}normalizeInstanceIdentifier(l=De){return this.component?this.component.multipleInstances?l:De:l}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function Mt(d){return d===De?void 0:d}function Ze(d){return d.instantiationMode==="EAGER"}/** 2285 * @license 2286 * Copyright 2019 Google LLC 2287 * 2288 * Licensed under the Apache License, Version 2.0 (the "License"); 2289 * you may not use this file except in compliance with the License. 2290 * You may obtain a copy of the License at 2291 * 2292 * http://www.apache.org/licenses/LICENSE-2.0 2293 * 2294 * Unless required by applicable law or agreed to in writing, softw
2294are 2295 * distributed under the License is distributed on an "AS IS" BASIS, 2296 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2297 * See the License for the specific language governing permissions and 2298 * limitations under the License. 2299 */class ci{constructor(l){this.name=l,this.providers=new Map}addComponent(l){const u=this.getProvider(l.name);if(u.isComponentSet())throw new Error(`Component ${l.name} has already been registered with ${this.name}`);u.setComponent(l)}addOrOverwriteComponent(l){this.getProvider(l.name).isComponentSet()&&this.providers.delete(l.name),this.addComponent(l)}getProvider(l){if(this.providers.has(l))return this.providers.get(l);const u=new X(l,this);return this.providers.set(l,u),u}getProviders(){return Array.from(this.providers.values())}}},790938:(Fe,Ye,L)=>{L.d(Ye,{$b:()=>N,Ey:()=>ct,He:()=>lt,Vy:()=>ye});var Pe=L(80247);/** 2300 * @license 2301 * Copyright 2017 Google LLC 2302 * 2303 * Licensed under the Apache License, Version 2.0 (the "License"); 2304 * you may not use this file except in compliance with the License. 2305 * You may obtain a copy of the License at 2306 * 2307 * http://www.apache.org/licenses/LICENSE-2.0 2308 * 2309 * Unless required by applicable law or agreed to in writing, software 2310 * distributed under the License is distributed on an "AS IS" BASIS, 2311 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2312 * See the License for the specific language governing permissions and 2313 * limitations under the License. 2314 */const oe=[];var N;(function(D){D[D.DEBUG=0]="DEBUG",D[D.VERBOSE=1]="VERBOSE",D[D.INFO=2]="INFO",D[D.WARN=3]="WARN",D[D.ERROR=4]="ERROR",D[D.SILENT=5]="SILENT"})(N||(N={}));const Te={debug:N.DEBUG,verbose:N.VERBOSE,info:N.INFO,warn:N.WARN,error:N.ERROR,silent:N.SILENT},Je=N.INFO,Be={[N.DEBUG]:"log",[N.VERBOSE]:"log",[N.INFO]:"info",[N.WARN]:"warn",[N.ERROR]:"error"},y=(D,T,...xe)=>{if(T<D.logLevel)return;const he=new Date().toISOString(),ue=Be[T];if(ue)Pe[ue](`[${he}] ${D.name}:`,...xe);else throw new Error(`Attempted to log a message with an invalid logType (value: ${T})`)};class ye{constructor(T){this.name=T,this._logLevel=Je,this._logHandler=y,this._userLogHandler=null,oe.push(this)}get logLevel(){return this._logLevel}set logLevel(T){if(!(T in N))throw new TypeError(`Invalid value "${T}" assigned to \`logLevel\``);this._logLevel=T}setLogLevel(T){this._logLevel=typeof T=="string"?Te[T]:T}get logHandler(){return this._logHandler}set logHandler(T){if(typeof T!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=T}get userLogHandler(){return this._userLogHandler}set userLogHandler(T){this._userLogHandler=T}debug(...T){this._userLogHandler&&this._userLogHandler(this,N.DEBUG,...T),this._logHandler(this,N.DEBUG,...T)}log(...T){this._userLogHandler&&this._userLogHandler(this,N.VERBOSE,...T),this._logHandler(this,N.VERBOSE,...T)}info(...T){this._userLogHandler&&this._userLogHandler(this,N.INFO,...T),this._logHandler(this,N.INFO,...T)}warn(...T){this._userLogHandler&&this._userLogHandler(this,N.WARN,...T),this._logHandler(this,N.WARN,...T)}error(...T){this._userLogHandler&&this._userLogHandler(this,N.ERROR,...T),this._logHandler(this,N.ERROR,...T)}}function lt(D){oe.forEach(T=>{T.setLogLevel(D)})}function ct(D,T){for(const xe of oe){let he=null;T&&T.level&&(he=Te[T.level]),D===null?xe.userLogHandler=null:xe.userLogHandler=(ue,ht,...ut)=>{const Xe=ut.map(ee=>{if(ee==null)return null;if(typeof ee=="string")return ee;if(typeof ee=="number"||typeof ee=="boolean")return ee.toString();if(ee instanceof Error)return ee.message;try{return JSON.stringify(ee)}catch{return null}}).filter(ee=>ee).join(" ");ht>=(he??ue.logLevel)&&D({level:N[ht].toLowerCase(),message:Xe,args:ut,type:ue.name})}}}}}]);
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.