PageSourceSearch

https://code.issimo.com/releases/prod/tangle-3464.2d269624a0ed38822699.js

js issimo.com collected 2026-10-08 12:07:20 UTC 170,813 bytes, 2 lines download raw bytes

1/*! For license information please see tangle-3464.2d269624a0ed38822699.js.LICENSE.txt */
2"use strict";(self.webpackChunk_issimo_tangle=self.webpackChunk_issimo_tangle||[]).push([[3464],{12172:function(e,t,n){n.d(t,{d:function(){return c},x:function(){return l}});var i=n(32709),s=n(34e3),r=n(11979);const o=Object.assign({},{isMobileEdit:!1,editMode:2,editingArticleID:void 0,cards:{},layout:void 0,selection:void 0,selectionPath:[],showPublishModal:!1,writeModal:void 0}),a=(e=o,t)=>{switch(t.type){case"SET_MOBILE_EDIT":return{...e,isMobileEdit:t.isMobileEdit};case"SET_WRITE_MODAL":return{...e,writeModal:t.writeModal};case"EDIT_ARTICLE":return{...e,editingArticleID:t.articleID,editMode:2};case"EDITOR_SECTIONS_UPDATED":return null==e.editingArticleID?e:{...e,layout:{articleID:e.editingArticleID,...e.layout||{},sections:t.sections}};case"EDIT_MODE_UPDATED":{const n=2===t.editMode?e.selection:void 0,i=2===t.editMode?e.selectionPath:[];return{...e,editMode:t.editMode,selection:n,selectionPath:i}}case"EDIT_SELECTION_UPDATED":return{...e,selection:t.selection,selectionPath:t.selectionPath};case"EDITOR_CARD_UPDATED":return{...e,cards:{...e.cards,[t.card.cardID]:t.card}};default:return e}},c=()=>{const[e,t]=(0,r.useReducer)(a,o),n=(0,r.useCallback)(async e=>{t(e)},[t]),i=(0,r.useCallback)(async e=>{await n({type:"SET_MOBILE_EDIT",isMobileEdit:e})},[]),s=(0,r.useCallback)(async e=>{await n({type:"SET_WRITE_MODAL",writeModal:e})},[]),c=(0,r.useCallback)(async e=>{await n({type:"EDIT_ARTICLE",articleID:e})},[]),l=(0,r.useCallback)(async e=>{console.log("sections:"),console.log(e),await n({type:"EDITOR_SECTIONS_UPDATED",sections:e})},[]),h=(0,r.useCallback)(async e=>{await n({type:"EDIT_MODE_UPDATED",editMode:e})},[]),u=(0,r.useCallback)(async(e,t=[])=>{await n({type:"EDIT_SELECTION_UPDATED",selection:e,selectionPath:t})},[]),d=(0,r.useCallback)(async t=>{const n=e.editingArticleID;if(!n)return Promise.resolve();{const i=e.cards[n];if(!i)return Promise.resolve();if(i.imageID)return Promise.resolve();if(!e.cards[t])return Promise.resolve()}},[]);return{...e,dispatch:n,setMobileEdit:i,setWriteModal:s,editArticle:c,sectionsUpdated:l,setEditMode:h,setEditSelection:u,editorImageUploaded:d}},l=()=>(0,s.x)(i.B,"write")},32709:function(e,t,n){n.d(t,{B:function(){return i}});const i=(0,n(11979).createContext)(null)},26900:function(e,t,n){n.d(t,{A:function(){return r}});var i=n(45951),s=n(82702);function r(e){return async t=>{const n=await s.d.createCard(e);return t((0,i.iO)(n)),n}}},35937:function(e,t,n){n.d(t,{A:function(){return a}});var i=n(82702),s=n(45951),r=n(68318),o=n.n(r);function a(e,t,n,r){return a=>{if(!t)return Promise.resolve();r||a((0,s.Od)(e,t,n));const c=o()(t,{replaceAll:{$set:n}});return Number(e)?i.d.updateCard(e,c,n).then(i=>(r&&a((0,s.Od)(e,t,n)),i)):Promise.resolve()}}},21464:function(e,t,n){n.d(t,{M:function(){return l}});var i=n(87280),s=n(64169),r=n(11979),o=n(36116),a=n(19135),c=n(41627);const l=(0,i.fc)("StoryButton",e=>{const{text:t="Button",icon:n,style:i={},activeStyle:l={},depth:h=1,hover:u=1,border:d=!1,onClick:p,noRoundCorners:_=!1,sizeMultiplier:f=1}=e,g=(0,s.G)()(6.6)*f,[m,y]=(0,r.useState)(!1),v="rgba(0,0,0,0.8)",C="white",w=m?l.color||i.color||v:i.color||v,b=m?l.backgroundColor||i.backgroundColor||C:i.backgroundColor||C,I=g,T=(0,o.xc)({outer:{lineHeight:`${g}px`,backgroundColor:b,color:w,fontSize:I,marginTop:i.marginTop,padding:`${g/3}px ${g/3}px`,borderRadius:_?0:g/4,boxShadow:(0,a.k)(h+(m?u:0)),display:"inline-flex",cursor:"pointer",fontFamily:"'Lato', helvetica, sans-serif",textTransform:"uppercase",transition:`${(0,a.k)("transition")}, color 0.25s ease-in-out, background-color 0.25s ease-in-out, border 0.25s ease-in-out`,border:d?`1px solid ${w}`:"none",boxSizing:"border-box"},icon:{lineHeight:.66*g+"px",fontSize:.66*g},text:{lineHeight:.66*g+"px",padding:`0px ${g/4}px`,fontSize:.5*g,display:0===t.length?"none":"auto",textAlign:"center"}});let E;return n&&(E=(0,c.jsx)("span",{className:`issimo-${n} ${T.icon}`})),(0,c.jsxs)("div",{onClick:p,className:T.outer,onMouseOver:()=>y(!0),onMouseOut:()=>y(!1),children:[E,(0,c.jsx)("div",{className:T.text,children:t})]})})},70668:function(e,t,n){n.d(t,{J:function(){return g},K:function(){return f}});var i=n(83799),s=n(14593),r=n(34263),o=n(87280),a=n(68617),c=n(694),l=n(23997),h=n(64169),u=n(21464),d=n(19721),p=n(36116),_=n(41627);const f=(0,o.fc)("HeroSection",e=>{const{backgroundImageID:t,title:n,subtitle:o,focusX:d,focusY:f,heightPercent:g=100,hideArrow:m,navigate:y}=e,[v]=(0,r.c)(),C=(0,h.G)()(6.6),{width:w}=(0,c.o)(),[b]=(0,l.E)(),I=w/window.innerHeight/(g/100);let T;b&&b.mainColor&&(T=b.mainColor);const E=(0,p.iF)({position:"relative",height:"100%"}),S=(0,p.iF)({position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:2,backgroundColor:"rgba(0,0,0,0.5)"}),k=(0,p.iF)({position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:2,color:"white",display:"flex",flexDirection:"column",padding:C/2}),N=(0,p.iF)({flex:1,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),P=(0,p.iF)({flex:1,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),x=(0,p.iF)({flex:1,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),R=(0,p.iF)({position:"absolute",width:2*C/3,left:"50%",bottom:C/4,transform:"rotate(90deg) translateX(-50%)"});
2return(0,_.jsxs)("div",{className:E,children:[t&&(0,_.jsx)(s.$,{imageId:t,displayRatio:I,focusX:d,focusY:f,isProgressive:!0},t),(0,_.jsx)("div",{className:S}),(0,_.jsxs)("div",{className:k,children:[(0,_.jsx)("div",{className:N}),(0,_.jsxs)("div",{className:P,children:[28693===v.cardId?(0,_.jsx)("div",{style:{maxWidth:16*C,width:"100%"},children:(0,_.jsx)(s.$,{imageId:28826})}):(0,_.jsx)(a.Y,{align:"center",size:2,children:n}),(0,_.jsx)(a.Y,{align:"center",size:5,marginTop:.5,children:o})]}),28693===v.cardId&&(0,_.jsx)("div",{className:x,children:(0,_.jsx)("a",{href:"/contact",onClick:e=>{y&&(e.preventDefault(),y("/contact"))},children:(0,_.jsx)(u.M,{text:"Contact",icon:"call",style:{backgroundColor:T,color:"white"}})})}),m&&(0,_.jsx)("div",{className:R,children:(0,_.jsx)(i.p,{id:"chevron-right",iconColor:"rgba(255,255,255,0.6)"})})]})]})}),g=(0,o.fc)("HeroSectionEditMenu",e=>{const{section:t,onChange:n}=e;let i=t?.focusX;void 0===i&&(i=50);let s=t?.focusY;return void 0===s&&(s=50),(0,_.jsxs)("div",{children:[(0,_.jsx)(d.L0,{value:t?.backgroundImageID,onChange:n,attribute:"backgroundImageID",name:"Background Image",marginTop:.5,focusX:i,focusY:s}),(0,_.jsx)(d.Q6,{name:`Focus X (${i}%)`,attribute:"focusX",value:i,marginTop:.5,onChange:n}),(0,_.jsx)(d.Q6,{name:`Focus Y (${s}%)`,attribute:"focusY",value:s,marginTop:.5,onChange:n}),(0,_.jsx)(d.pd,{name:"Title",attribute:"title",value:t?.title,marginTop:.5,onChange:n}),(0,_.jsx)(d.pd,{name:"Subtitle",attribute:"subtitle",value:t?.subtitle,marginTop:.5,onChange:n})]})})},93464:function(e,t,n){n.r(t),n.d(t,{PagesSectionEditMenuLoader:function(){return l},PagesSectionLoader:function(){return c}});var i=n(87280),s=n(14522),r=n(44223),o=n(70668),a=n(41627);const c=(0,i.fc)("PagesSectionLoader",e=>{const{componentName:t,NotFound:n,section:i}=e;return"HeroSection"===t?(0,a.jsx)(o.K,{...i}):(0,a.jsx)(n,{componentName:t,...i})}),l=(0,i.fc)("PagesSectionLoader",({pageId:e,sectionId:t})=>{const[n,i]=(0,s.y)(e,t),c=i?.update,{componentName:l=""}=(0,r.Y)(n?.type);if(void 0===n||null==c)return null;{const e={section:n,onChange:c};return"HeroSection"===l?(0,a.jsx)(o.J,{...e}):null}})},10471:function(e,t,n){n.d(t,{r:function(){return a}});var i=n(12172),s=n(11979),r=n(16030),o=n(22124);function a(e){const[t,n]=(0,s.useState)(null),a=(0,i.x)().dispatch,c=(0,r.F)();return(0,s.useEffect)(()=>{null!=e&&new o.A(e,a,c).initialize().then(e=>n(e))},[e,a]),[t,(0,s.useMemo)(()=>({}),[e])]}},14522:function(e,t,n){n.d(t,{y:function(){return r}});var i=n(11979),s=n(10471);function r(e,t){const[n]=(0,s.r)(e),[r,o]=(0,i.useState)(void 0),a=(0,i.useCallback)(e=>o(e.val()),[]);return(0,i.useEffect)(()=>{if(null!=n){const e=n.sectionsRef.child(t);return e.on("value",a),()=>e.off("value",a)}return()=>null},[e,t,null!=n]),[r,(0,i.useMemo)(()=>({update:(e,i)=>{if(null!=n&&null!=e){const s=t+"/"+e.replace(/\./g,"/");n.sectionsRef.child(s).set(i)}}}),[e,t,null!=n])]}},22124:function(e,t,n){n.d(t,{A:function(){return yo}});var i=n(26900),s=n(35937),r=n(82702),o=n(44392),a=class{static objToArray(e){return e?Object.keys(e).map(t=>({key:t,order:e[t]})).sort((e,t)=>e.order-t.order).map(e=>e.key):[]}static arrayToObj(e){let t={};for(let n=0;n<e.length;n++)t[e[n]]=n;return t}static toStack(e){return e?"number"==typeof e?{[e.toString()]:0}:"string"==typeof e?{[e]:0}:Array.isArray(e)?this.arrayToObj(e):"object"==typeof e?e:{}:{}}static add(e,t,n){const i=this.objToArray(e),s="number"==typeof n?n:i.length;return i.splice(s,0,t),this.arrayToObj(i)}static remove(e,t){if(!t)return e;const n=this.objToArray(e).filter(e=>e!==t.toString());return this.arrayToObj(n)}static move(e,t,n){if("number"!=typeof n||!t)return e;const i=e[t];if("number"!=typeof i)return e;const s=this.objToArray(e);return s.splice(n,0,s.splice(i,1)[0]),this.arrayToObj(s)}static fromStack(e){if(!e)return e;const t=Object.keys(e);return 1===t.length?t[0]:e}static objToArrayWithDragging(e,t,n){const i=this.objToArray(e).filter(t);return i.splice(t,n),i}};const c=function(e,t){if(!e)throw l(t)},l=function(e){return new Error("Firebase Database (${JSCORE_VERSION}) INTERNAL ASSERT FAILED: "+e)},h=function(e){const t=[];let n=0;for(let i=0;i<e.length;i++){let s=e.charCodeAt(i);s<128?t[n++]=s:s<2048?(t[n++]=s>>6|192,t[n++]=63&s|128):55296==(64512&s)&&i+1<e.length&&56320==(64512&e.charCodeAt(i+1))?(s=65536+((1023&s)<<10)+(1023&e.charCodeAt(++i)),t[
vendor: 4,312 bytes, line 2
2n++]=s>>18|240,t[n++]=s>>12&63|128,t[n++]=s>>6&63|128,t[n++]=63&s|128):(t[n++]=s>>12|224,t[n++]=s>>6&63|128,t[n++]=63&s|128)}return t},u={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:"function"==typeof atob,encodeByteArray(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,i=[];for(let t=0;t<e.length;t+=3){const s=e[t],r=t+1<e.length,o=r?e[t+1]:0,a=t+2<e.length,c=a?e[t+2]:0,l=s>>2,h=(3&s)<<4|o>>4;let u=(15&o)<<2|c>>6,d=63&c;a||(d=64,r||(u=64)),i.push(n[l],n[h],n[u],n[d])}return i.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(h(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){const t=[];let n=0,i=0;for(;n<e.length;){const s=e[n++];if(s<128)t[i++]=String.fromCharCode(s);else if(s>191&&s<224){const r=e[n++];t[i++]=String.fromCharCode((31&s)<<6|63&r)}else if(s>239&&s<365){const r=((7&s)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536;t[i++]=String.fromCharCode(55296+(r>>10)),t[i++]=String.fromCharCode(56320+(1023&r))}else{const r=e[n++],o=e[n++];t[i++]=String.fromCharCode((15&s)<<12|(63&r)<<6|63&o)}}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();const n=t?this.charToByteMapWebSafe_:this.charToByteMap_,i=[];for(let t=0;t<e.length;){const s=n[e.charAt(t++)],r=t<e.length?n[e.charAt(t)]:0;++t;const o=t<e.length?n[e.charAt(t)]:64;++t;const a=t<e.length?n[e.charAt(t)]:64;if(++t,null==s||null==r||null==o||null==a)throw new d;const c=s<<2|r>>4;if(i.push(c),64!==o){const e=r<<4&240|o>>2;if(i.push(e),64!==a){const e=o<<6&192|a;i.push(e)}}}return i},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e,e>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class d extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const p=function(e){const t=h(e);return u.encodeByteArray(t,!0)},_=function(e){return p(e).replace(/\./g,"")},f=function(e){try{return u.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function g(e){return m(void 0,e)}function m(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return t}for(const n in t)t.hasOwnProperty(n)&&y(n)&&(e[n]=m(e[n],t[n]));return e}function y(e){return"__proto__"!==e}const v=()=>{try{return function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n.g)return n.g;throw new Error("Unable to locate global object.")}().__FIREBASE_DEFAULTS__||(()=>{if("undefined"==typeof process)return;const e="production".__FIREBASE_DEFAULTS__;return e?JSON.parse(e):void 0})()||(()=>{if("undefined"==typeof document)return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}const t=e&&f(e[1]);return t&&JSON.parse(t)})()}catch(e){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`)}},C=()=>v()?.config;class w{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,n)=>{t?this.reject(t):this.resolve(n),"function"==typeof e&&(this.promise.catch(()=>{}),1===e.length?e(t):e(t,n))}}}function b(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test("undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:"")}
vendor: 8,191 bytes, line 2
2class I extends Error{constructor(e,t,n){super(t),this.code=e,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,I.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,T.prototype.create)}}class T{constructor(e,t,n){this.service=e,this.serviceName=t,this.errors=n}create(e,...t){const n=t[0]||{},i=`${this.service}/${e}`,s=this.errors[e],r=s?function(e,t){return e.replace(E,(e,n)=>{const i=t[n];return null!=i?String(i):`<${n}?>`})}(s,n):"Error",o=`${this.serviceName}: ${r} (${i}).`;return new I(i,o,n)}}const E=/\{\$([^}]+)}/g;function S(e){return JSON.parse(e)}function k(e){return JSON.stringify(e)}const N=function(e){let t={},n={},i={},s="";try{const r=e.split(".");t=S(f(r[0])||""),n=S(f(r[1])||""),s=r[2],i=n.d||{},delete n.d}catch(e){}return{header:t,claims:n,data:i,signature:s}};function P(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function x(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function R(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function D(e,t,n){const i={};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(i[s]=t.call(n,e[s],s,e));return i}function A(e,t){if(e===t)return!0;const n=Object.keys(e),i=Object.keys(t);for(const s of n){if(!i.includes(s))return!1;const n=e[s],r=t[s];if(O(n)&&O(r)){if(!A(n,r))return!1}else if(n!==r)return!1}for(const e of i)if(!n.includes(e))return!1;return!0}function O(e){return null!==e&&"object"==typeof e}class M{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=64,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 n=this.W_;if("string"==typeof e)for(let i=0;i<16;i++)n[i]=e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3),t+=4;else for(let i=0;i<16;i++)n[i]=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3],t+=4;for(let e=16;e<80;e++){const t=n[e-3]^n[e-8]^n[e-14]^n[e-16];n[e]=4294967295&(t<<1|t>>>31)}let i,s,r=this.chain_[0],o=this.chain_[1],a=this.chain_[2],c=this.chain_[3],l=this.chain_[4];for(let e=0;e<80;e++){e<40?e<20?(i=c^o&(a^c),s=1518500249):(i=o^a^c,s=1859775393):e<60?(i=o&a|c&(o|a),s=2400959708):(i=o^a^c,s=3395469782);const t=(r<<5|r>>>27)+i+l+s+n[e]&4294967295;l=c,c=a,a=4294967295&(o<<30|o>>>2),o=r,r=t}this.chain_[0]=this.chain_[0]+r&4294967295,this.chain_[1]=this.chain_[1]+o&4294967295,this.chain_[2]=this.chain_[2]+a&4294967295,this.chain_[3]=this.chain_[3]+c&4294967295,this.chain_[4]=this.chain_[4]+l&4294967295}update(e,t){if(null==e)return;void 0===t&&(t=e.length);const n=t-this.blockSize;let i=0;const s=this.buf_;let r=this.inbuf_;for(;i<t;){if(0===r)for(;i<=n;)this.compress_(e,i),i+=this.blockSize;if("string"==typeof e){for(;i<t;)if(s[r]=e.charCodeAt(i),++r,++i,r===this.blockSize){this.compress_(s),r=0;break}}else for(;i<t;)if(s[r]=e[i],++r,++i,r===this.blockSize){this.compress_(s),r=0;break}}this.inbuf_=r,this.total_+=t}digest(){const e=[];let t=8*this.total_;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let e=this.blockSize-1;e>=56;e--)this.buf_[e]=255&t,t/=256;this.compress_(this.buf_);let n=0;for(let t=0;t<5;t++)for(let i=24;i>=0;i-=8)e[n]=this.chain_[t]>>i&255,++n;return e}}function L(e,t){return`${e} failed: ${t} argument `}const F=function(e){let t=0;for(let n=0;n<e.length;n++){const i=e.charCodeAt(n);i<128?t++:i<2048?t+=2:i>=55296&&i<=56319?(t+=4,n++):t+=3}return t};function q(e){return e&&e._delegate?e._delegate:e}function j(e){try{return(e.startsWith("http://")||e.startsWith("https://")?new URL(e).hostname:e).endsWith(".cloudworkstations.dev")}catch{return!1}}class U{constructor(e,t,n){this.name=e,this.instanceFactory=t,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}const W="[DEFAULT]";class B{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const e=new w;if(this.instancesDeferred.set(t,e),this.isInitialized(t)||this.shouldAutoInitialize())try{const n=this.getOrInitializeService({instanceIdentifier:t});n&&e.resolve(n)}catch(e){}}return this.instancesDeferred.get(t).promise}getImmediate(e){const t=this.normalizeInstanceIdentifier(e?.identifier),n=e?.optional??!1;if(!this.isInitialized(t)&&!this.shouldAutoInitialize()){if(n)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:t})}catch(e){if(n)return null;throw e}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,this.shouldAutoInitialize()){if(function(e){return"EAGER"===e.instantiationMode}(e))try{this.getOrInitializeService({instanceIdentifier:W})}catch(e){}for(const[e,t]of this.instancesDeferred.entries()){const n=this.normalizeInstanceIdentifier(e);try{const e=this.getOrInitializeService({instanceIdentifier:n});t.resolve(e)}catch(e){}}}}clearInstance(e=W){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(e=>"INTERNAL"in e).map(e=>e.INTERNAL.delete()),...e.filter(e=>"_delete"in e).map(e=>e._delete())])}isComponentSet(){return null!=this.component}isInitialized(e=W){return this.instances.has(e)}getOptions(e=W){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,n=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(n))throw Error(`${this.name}(${n}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const i=this.getOrInitializeService({instanceIdentifier:n,options:t});for(const[e,t]of this.instancesDeferred.entries())n===this.normalizeInstanceIdentifier(e)&&t.resolve(i);return i}onInit(e,t){const n=this.normalizeInstanceIdentifier(t),i=this.onInitCallbacks.get(n)??new Set;i.add(e),this.onInitCallbacks.set(n,i);const s=this.instances.get(n);return s&&e(s,n),()=>{i.delete(e)}}invokeOnInitCallbacks(e,t){const n=this.onInitCallbacks.get(t);if(n)for(const i of n)try{i(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let n=this.instances.get(e);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:(i=e,i===W?void 0:i),options:t}),this.instances.set(e,n),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(n,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,n)}catch{}var i;return n||null}normalizeInstanceIdentifier(e=W){return this.component?this.component.multipleInstances?e:W:e}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}class H{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const t=new B(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}const z=[];var $;!function(e){e[e.DEBUG=0]="DEBUG",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.E
2RROR=4]="ERROR",e[e.SILENT=5]="SILENT"}($||($={}));const V={debug:$.DEBUG,verbose:$.VERBOSE,info:$.INFO,warn:$.WARN,error:$.ERROR,silent:$.SILENT},Y=$.INFO,K={[$.DEBUG]:"log",[$.VERBOSE]:"log",[$.INFO]:"info",[$.WARN]:"warn",[$.ERROR]:"error"},G=(e,t,...n)=>{if(t<e.logLevel)return;const i=(new Date).toISOString(),s=K[t];if(!s)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[s](`[${i}]  ${e.name}:`,...n)};class Q{constructor(e){this.name=e,this._logLevel=Y,this._logHandler=G,this._userLogHandler=null,z.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in $))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?V[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,$.DEBUG,...e),this._logHandler(this,$.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,$.VERBOSE,...e),this._logHandler(this,$.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,$.INFO,...e),this._logHandler(this,$.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,$.WARN,...e),this._logHandler(this,$.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,$.ERROR,...e),this._logHandler(this,$.ERROR,...e)}}let J,X;const Z=new WeakMap,ee=new WeakMap,te=new WeakMap,ne=new WeakMap,ie=new WeakMap;let se={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return ee.get(e);if("objectStoreNames"===t)return e.objectStoreNames||te.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return re(e[t])},set(e,t,n){return e[t]=n,!0},has(e,t){return e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e}};function re(e){if(e instanceof IDBRequest)return function(e){const t=new Promise((t,n)=>{const i=()=>{e.removeEventListener("success",s),e.removeEventListener("error",r)},s=()=>{t(re(e.result)),i()},r=()=>{n(e.error),i()};e.addEventListener("success",s),e.addEventListener("error",r)});return t.then(t=>{t instanceof IDBCursor&&Z.set(t,e)}).catch(()=>{}),ie.set(t,e),t}(e);if(ne.has(e))return ne.get(e);const t=function(e){return"function"==typeof e?(t=e)!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(X||(X=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(...e){return t.apply(oe(this),e),re(Z.get(this))}:function(...e){return re(t.apply(oe(this),e))}:function(e,...n){const i=t.call(oe(this),e,...n);return te.set(i,e.sort?e.sort():[e]),re(i)}:(e instanceof IDBTransaction&&function(e){if(ee.has(e))return;const t=new Promise((t,n)=>{const i=()=>{e.removeEventListener("complete",s),e.removeEventListener("error",r),e.removeEventListener("abort",r)},s=()=>{t(),i()},r=()=>{n(e.error||new DOMException("AbortError","AbortError")),i()};e.addEventListener("complete",s),e.addEventListener("error",r),e.addEventListener("abort",r)});ee.set(e,t)}(e),n=e,(J||(J=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some(e=>n instanceof e)?new Proxy(e,se):e);var t,n}(e);return t!==e&&(ne.set(e,t),ie.set(t,e)),t}const oe=e=>ie.get(e),ae=["get","getKey","getAll","getAllKeys","count"],ce=["put","add","delete","clear"],le=new Map;function he(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(le.get(t))return le.get(t);const n=t.replace(/FromIndex$/,""),i=t!==n,s=ce.includes(n);if(!(n in(i?IDBIndex:IDBObjectStore).prototype)||!s&&!ae.includes(n))return;const r=async function(e,...t){const r=this.transaction(e,s?"readwrite":"readonly");let o=r.store;return i&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),s&&r.done]))[0]};return le.set(t,r),r}var ue;ue=se,se={...ue,get:(e,t,n)=>he(e,t)||ue.get(e,t,n),has:(e,t)=>!!he(e,t)||ue.has(e,t)};class de{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(e=>{if(function(e){const t=e.getComponent();return"VERSION"===t?.type}(e)){const t=e.getImmediate();return`${t.library}/${t.version}`}return null}).filter(e=>e).join(" ")}}const pe="@firebase/app",_e="0.14.11",fe=new Q("@firebase/app"),ge="@firebase/app-compat",me="@firebase/analytics-compat",ye="@firebase/analytics",ve="@firebase/app-check-compat",Ce="@firebase/app-check",we="@firebase/auth",be="@firebase/auth-compat",Ie="@firebase/database",Te="@firebase/data-connect",Ee="@firebase/database-compat",Se="@firebase/functions",ke="@firebase/functions-compat",Ne="@firebase/installations",Pe="@firebase/installations-compat",xe
vendor: 1,890 bytes, line 2
2="@firebase/messaging",Re="@firebase/messaging-compat",De="@firebase/performance",Ae="@firebase/performance-compat",Oe="@firebase/remote-config",Me="@firebase/remote-config-compat",Le="@firebase/storage",Fe="@firebase/storage-compat",qe="@firebase/firestore",je="@firebase/ai",Ue="@firebase/firestore-compat",We="firebase",Be="[DEFAULT]",He={[pe]:"fire-core",[ge]:"fire-core-compat",[ye]:"fire-analytics",[me]:"fire-analytics-compat",[Ce]:"fire-app-check",[ve]:"fire-app-check-compat",[we]:"fire-auth",[be]:"fire-auth-compat",[Ie]:"fire-rtdb",[Te]:"fire-data-connect",[Ee]:"fire-rtdb-compat",[Se]:"fire-fn",[ke]:"fire-fn-compat",[Ne]:"fire-iid",[Pe]:"fire-iid-compat",[xe]:"fire-fcm",[Re]:"fire-fcm-compat",[De]:"fire-perf",[Ae]:"fire-perf-compat",[Oe]:"fire-rc",[Me]:"fire-rc-compat",[Le]:"fire-gcs",[Fe]:"fire-gcs-compat",[qe]:"fire-fst",[Ue]:"fire-fst-compat",[je]:"fire-vertex","fire-js":"fire-js",[We]:"fire-js-all"},ze=new Map,$e=new Map,Ve=new Map;function Ye(e,t){try{e.container.addComponent(t)}catch(n){fe.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,n)}}function Ke(e){const t=e.name;if(Ve.has(t))return fe.debug(`There were multiple attempts to register component ${t}.`),!1;Ve.set(t,e);for(const t of ze.values())Ye(t,e);for(const t of $e.values())Ye(t,e);return!0}const Ge=new T("app","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invali
2d-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."});class Qe{constructor(e,t,n){this._isDeleted=!1,this._options={...e},this._config={...t},this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new U("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw Ge.create("app-deleted",{appName:this._name})}}function Je(e,t={}){let n=e;"object"!=typeof t&&(t={name:t});const i={name:Be,automaticDataCollectionEnabled:!0,...t},s=i.name;if("string"!=typeof s||!s)throw Ge.create("bad-app-name",{appName:String(s)});if(n||(n=C()),!n)throw Ge.create("no-options");const r=ze.get(s);if(r){if(A(n,r.options)&&A(i,r.config))return r;throw Ge.create("duplicate-app",{appName:s})}const o=new H(s);for(const e of Ve.values())o.addComponent(e);const a=new Qe(n,i,o);return ze.set(s,a),a}function Xe(e,t,n){let i=He[e]??e;n&&(i+=`-${n}`);const s=i.match(/\s|\//),r=t.match(/\s|\//);if(s||r){const e=[`Unable to register library "${i}" with version "${t}":`];return s&&e.push(`library name "${i}" contains illegal characters (whitespace or "/")`),s&&r&&e.push("and"),r&&e.push(`version name "${t}" contains illegal characters (whitespace or "/")`),void fe.warn(e.join(" "))}Ke(new U(`${i}-version`,()=>({library:i,version:t}),"VERSION"))}const Ze="firebase-heartbeat-store";let et=null;function tt(){return et||(et=function(e,t,{blocked:n,upgrade:i,blocking:s,terminated:r}={}){const o=indexedDB.open(e,t),a=re(o);return i&&o.addEventListener("upgradeneeded",e=>{i(re(o.result),e.oldVersion,e.newVersion,re(o.transaction),e)}),n&&o.addEventListener("blocked",e=>n(e.oldVersion,e.newVersion,e)),a.then(e=>{r&&e.addEventListener("close",()=>r()),s&&e.addEventListener("versionchange",e=>s(e.oldVersion,e.newVersion,e))}).catch(()=>{}),a}("firebase-heartbeat-database",1,{upgrade:(e,t)=>{if(0===t)try{e.createObjectStore(Ze)}catch(e){console.warn(e)}}}).catch(e=>{throw Ge.create("idb-open",{originalErrorMessage:e.message})})),et}async function nt(e,t){try{const n=(await tt()).transaction(Ze,"readwrite"),i=n.objectStore(Ze);await i.put(t,it(e)),await n.done}catch(e){if(e instanceof I)fe.warn(e.message);else{const t=Ge.create("idb-set",{originalErrorMessage:e?.message});fe.warn(t.message)}}}function it(e){return`${e.name}!${e.options.appId}`}class st{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new ot(t),this._heartbeatsCachePromise=this._storage.read().then(e=>(this._heartbeatsCache=e,e))}async triggerHeartbeat(){try{const e=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),t=rt();if(null==this._heartbeatsCache?.heartbeats&&(this._heartbeatsCache=await this._heartbeatsCachePromise,null==this._heartbeatsCache?.heartbeats))return;if(this._heartbeatsCache.lastSentHeartbeatDate===t||this._heartbeatsCache.heartbeats.some(e=>e.date===t))return;if(this._heartbeatsCache.heartbeats.push({date:t,agent:e}),this._heartbeatsCache.heartbeats.length>30){const e=function(e){if(0===e.length)return-1;let t=0,n=e[0].date;for(let i=1;i<e.length;i++)e[i].date<n&&(n=e[i].date,t=i);return t}(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(e,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){fe.warn(e)}}async getHeartbeatsHeader(){try{if(null===this._heartbeatsCache&&await this._heartbeatsCachePromise,null==this._heartbeatsCache?.heartbeats||0===this._heartbeatsCache.heartbeats.length)return"";const e=rt(),{heartbeatsToSend:t,unsentEntries:n}=function(e,t=1024){const n=[];let i=e.slice();for(const s of e){const e=n.find(e=>e.agent===s.agent);if(e){if(e.dates.push(s.date),at(n)>t){e.dates.pop();break}}else if(n.push({agent:s.agent,dates:[s.date]}),at(n)>t){n.pop();break}i=i.slice(1)}return{heartbeatsToSend:n,unsentEntries:i}}(this._heartbeatsCache.heartbeats),i=_(JSON.stringify({version:2,heartbeats:t}));return this._heartbeatsCache.lastSentHeartbeatDate=e,n.length>0?(this._heartbeatsCache.heartbeats=n,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),i}catch(e){return fe.warn(e),""}}}function rt(){return(new Date).toISOString().substring(0,10)}
2class ot{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return!!function(){try{return"object"==typeof indexedDB}catch(e){return!1}}()&&new Promise((e,t)=>{try{let n=!0;const i="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(i);s.onsuccess=()=>{s.result.close(),n||self.indexedDB.deleteDatabase(i),e(!0)},s.onupgradeneeded=()=>{n=!1},s.onerror=()=>{t(s.error?.message||"")}}catch(e){t(e)}}).then(()=>!0).catch(()=>!1)}async read(){if(await this._canUseIndexedDBPromise){const e=await async function(e){try{const t=(await tt()).transaction(Ze),n=await t.objectStore(Ze).get(it(e));return await t.done,n}catch(e){if(e instanceof I)fe.warn(e.message);else{const t=Ge.create("idb-get",{originalErrorMessage:e?.message});fe.warn(t.message)}}}(this.app);return e?.heartbeats?e:{heartbeats:[]}}return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){const t=await this.read();return nt(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??t.lastSentHeartbeatDate,heartbeats:e.heartbeats})}}async add(e){if(await this._canUseIndexedDBPromise){const t=await this.read();return nt(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??t.lastSentHeartbeatDate,heartbeats:[...t.heartbeats,...e.heartbeats]})}}}function at(e){return _(JSON.stringify({version:2,heartbeats:e})).length}Ke(new U("platform-logger",e=>new de(e),"PRIVATE")),Ke(new U("heartbeat",e=>new st(e),"PRIVATE")),Xe(pe,_e,""),Xe(pe,_e,"esm2020"),Xe("fire-js",""),Xe("firebase","12.12.1","app");const ct="@firebase/database",lt="1.1.2";let ht="";class ut{constructor(e){this.domStorage_=e,this.prefix_="firebase:"}set(e,t){null==t?this.domStorage_.removeItem(this.prefixedName_(e)):this.domStorage_.setItem(this.prefixedName_(e),k(t))}get(e){const t=this.domStorage_.getItem(this.prefixedName_(e));return null==t?null:S(t)}remove(e){this.domStorage_.removeItem(this.prefixedName_(e))}prefixedName_(e){return this.prefix_+e}toString(){return this.domStorage_.toString()}}class dt{constructor(){this.cache_={},this.isInMemoryStorage=!0}set(e,t){null==t?delete this.cache_[e]:this.cache_[e]=t}get(e){return P(this.cache_,e)?this.cache_[e]:null}remove(e){delete this.cache_[e]}}const pt=function(e){try{if("undefined"!=typeof window&&void 0!==window[e]){const t=window[e];return t.setItem("firebase:sentinel","cache"),t.removeItem("firebase:sentinel"),new ut(t)}}catch(e){}return new dt},_t=pt("localStorage"),ft=pt("sessionStorage"),gt=new Q("@firebase/database"),mt=function(){let e=1;return function(){return e++}}(),yt=function(e){const t=function(e){const t=[];let n=0;for(let i=0;i<e.length;i++){let s=e.charCodeAt(i);if(s>=55296&&s<=56319){const t=s-55296;i++,c(i<e.length,"Surrogate pair missing trail surrogate."),s=65536+(t<<10)+(e.charCodeAt(i)-56320)}s<128?t[n++]=s:s<2048?(t[n++]=s>>6|192,t[n++]=63&s|128):s<65536?(t[n++]=s>>12|224,t[n++]=s>>6&63|128,t[n++]=63&s|128):(t[n++]=s>>18|240,t[n++]=s>>12&63|128,t[n++]=s>>6&63|128,t[n++]=63&s|128)}return t}(e),n=new M;n.update(t);const i=n.digest();return u.encodeByteArray(i)},vt=function(...e){let t="";for(let n=0;n<e.length;n++){const i=e[n];Array.isArray(i)||i&&"object"==typeof i&&"number"==typeof i.length?t+=vt.apply(null,i):t+="object"==typeof i?k(i):i,t+=" "}return t};let Ct=null,wt=!0;const bt=function(...e){if(!0===wt&&(wt=!1,null===Ct&&!0===ft.get("logging_enabled")&&(c(!0,"Can't turn on custom loggers persistently."),gt.logLevel=$.VERBOSE,Ct=gt.log.bind(gt))),Ct){const t=vt.apply(null,e);Ct(t)}},It=function(e){return function(...t){bt(e,...t)}},Tt=function(...e){const t="FIREBASE INTERNAL ERROR: "+vt(...e);gt.error(t)},Et=function(...e){const t=`FIREBASE FATAL ERROR: ${vt(...e)}`;throw gt.error(t),new Error(t)},St=function(...e){const t="FIREBASE WARNING: "+vt(...e);gt.warn(t)},kt=function(e){return"number"==typeof e&&(e!=e||e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY)},Nt="[MIN_NAME]",Pt="[MAX_NAME]",xt=function(e,t){if(e===t)return 0;if(e===Nt||t===Pt)return-1;if(t===Nt||e===Pt)return 1;{const n=qt(e),i=qt(t);return null!==n?null!==i?n-i===0?e.length-t.length:n-i:-1:null!==i?1:e<t?-1:1}},Rt=function(e,t){return e===t?0:e<t?-1:1},Dt=function(e,t){if(t&&e in t)return t[e];throw new Error("Missing required key ("+e+") in object: "+k(t))},At=function(e){if("object"!=typeof e||null===e)return k(e);const t=[];for(const n in e)t.push(n);
2t.sort();let n="{";for(let i=0;i<t.length;i++)0!==i&&(n+=","),n+=k(t[i]),n+=":",n+=At(e[t[i]]);return n+="}",n},Ot=function(e,t){const n=e.length;if(n<=t)return[e];const i=[];for(let s=0;s<n;s+=t)s+t>n?i.push(e.substring(s,n)):i.push(e.substring(s,s+t));return i};function Mt(e,t){for(const n in e)e.hasOwnProperty(n)&&t(n,e[n])}const Lt=function(e){let t,n,i,s,r;c(!kt(e),"Invalid JSON number"),0===e?(n=0,i=0,t=1/e==-1/0?1:0):(t=e<0,(e=Math.abs(e))>=Math.pow(2,-1022)?(s=Math.min(Math.floor(Math.log(e)/Math.LN2),1023),n=s+1023,i=Math.round(e*Math.pow(2,52-s)-Math.pow(2,52))):(n=0,i=Math.round(e/Math.pow(2,-1074))));const o=[];for(r=52;r;r-=1)o.push(i%2?1:0),i=Math.floor(i/2);for(r=11;r;r-=1)o.push(n%2?1:0),n=Math.floor(n/2);o.push(t?1:0),o.reverse();const a=o.join("");let l="";for(r=0;r<64;r+=8){let e=parseInt(a.substr(r,8),2).toString(16);1===e.length&&(e="0"+e),l+=e}return l.toLowerCase()},Ft=new RegExp("^-?(0*)\\d{1,10}$"),qt=function(e){if(Ft.test(e)){const t=Number(e);if(t>=-2147483648&&t<=2147483647)return t}return null},jt=function(e){try{e()}catch(e){setTimeout(()=>{const t=e.stack||"";throw St("Exception was thrown by user callback.",t),e},Math.floor(0))}},Ut=function(e,t){const n=setTimeout(e,t);return"number"==typeof n&&"undefined"!=typeof Deno&&Deno.unrefTimer?Deno.unrefTimer(n):"object"==typeof n&&n.unref&&n.unref(),n};class Wt{constructor(e,t){var n;this.appCheckProvider=t,this.appName=e.name,null!=(n=e)&&void 0!==n.settings&&e.settings.appCheckToken&&(this.serverAppAppCheckToken=e.settings.appCheckToken),this.appCheck=t?.getImmediate({optional:!0}),this.appCheck||t?.get().then(e=>this.appCheck=e)}getToken(e){if(this.serverAppAppCheckToken){if(e)throw new Error("Attempted reuse of `FirebaseServerApp.appCheckToken` after previous usage failed.");return Promise.resolve({token:this.serverAppAppCheckToken})}return this.appCheck?this.appCheck.getToken(e):new Promise((t,n)=>{setTimeout(()=>{this.appCheck?this.getToken(e).then(t,n):t(null)},0)})}addTokenChangeListener(e){this.appCheckProvider?.get().then(t=>t.addTokenListener(e))}notifyForInvalidToken(){St(`Provided AppCheck credentials for the app named "${this.appName}" are invalid. This usually indicates your app was not initialized correctly.`)}}class Bt{constructor(e,t,n){this.appName_=e,this.firebaseOptions_=t,this.authProvider_=n,this.auth_=null,this.auth_=n.getImmediate({optional:!0}),this.auth_||n.onInit(e=>this.auth_=e)}getToken(e){return this.auth_?this.auth_.getToken(e).catch(e=>e&&"auth/token-not-initialized"===e.code?(bt("Got auth/token-not-initialized error.  Treating as null token."),null):Promise.reject(e)):new Promise((t,n)=>{setTimeout(()=>{this.auth_?this.getToken(e).then(t,n):t(null)},0)})}addTokenChangeListener(e){this.auth_?this.auth_.addAuthTokenListener(e):this.authProvider_.get().then(t=>t.addAuthTokenListener(e))}removeTokenChangeListener(e){this.authProvider_.get().then(t=>t.removeAuthTokenListener(e))}notifyForInvalidToken(){let e='Provided authentication credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.firebaseOptions_?e+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.firebaseOptions_?e+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':e+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',St(e)}}class Ht{constructor(e){this.accessToken=e}getToken(e){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(e){e(this.accessToken)}removeTokenChangeListener(e){}notifyForInvalidToken(){}}Ht.OWNER="owner";const zt=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,$t="ac",Vt="websocket",Yt="long_polling";class Kt{constructor(e,t,n,i,s=!1,r="",o=!1,a=!1,c=null){this.secure=t,this.namespace=n,this.webSocketOnly=i,this.nodeAdmin=s,this.persistenceKey=r,this.includeNamespaceInQueryParams=o,this.isUsingEmulator=a,this.emulatorOptions=c,this._host=e.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=_t.get("host:"+e)||this._host}isCacheableHost(){return"s-"===this.internalHost.substr(0,2)}isCustomHost(){return"firebaseio.com"!==this._domain&&"firebaseio-demo.com"!==this._domain}get host(){return this._host}set host(e){e!==this.internalHost&&(this.internalHost=e,this.isCacheableHost()&&_t.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 Gt(e,t,n){let i;if(c("string"==typeof t,"typeof type must == string"),c("object"==typeof n,"typeof params must == object"),t===Vt)i=(e.secure?"wss://":"ws://")+e.internalHost+"/.ws?";else{if(t!==Yt)throw new Error("Unknown connection type: "+t);i=(e.secure?"https://":"http://")+e.internalHost+"/.lp?"}(function(e){return e.host!==e.internalHost||e.isCustomHost()||e.includeNamespaceInQueryParams})(e)&&(n.ns=e.namespace);const s=[];return Mt(n,(e,t)=>{s.push(e+"="+t)}
2),i+s.join("&")}class Qt{constructor(){this.counters_={}}incrementCounter(e,t=1){P(this.counters_,e)||(this.counters_[e]=0),this.counters_[e]+=t}get(){return g(this.counters_)}}const Jt={},Xt={};function Zt(e){const t=e.toString();return Jt[t]||(Jt[t]=new Qt),Jt[t]}class en{constructor(e){this.onMessage_=e,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}closeAfter(e,t){this.closeAfterResponse=e,this.onClose=t,this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)}handleResponse(e,t){for(this.pendingResponses[e]=t;this.pendingResponses[this.currentResponseNum];){const e=this.pendingResponses[this.currentResponseNum];delete this.pendingResponses[this.currentResponseNum];for(let t=0;t<e.length;++t)e[t]&&jt(()=>{this.onMessage_(e[t])});if(this.currentResponseNum===this.closeAfterResponse){this.onClose&&(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}}const tn="start";class nn{constructor(e,t,n,i,s,r,o){this.connId=e,this.repoInfo=t,this.applicationId=n,this.appCheckToken=i,this.authToken=s,this.transportSessionId=r,this.lastSessionId=o,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=It(e),this.stats_=Zt(t),this.urlFn=e=>(this.appCheckToken&&(e[$t]=this.appCheckToken),Gt(t,Yt,e))}open(e,t){this.curSegmentNum=0,this.onDisconnect_=t,this.myPacketOrderer=new en(e),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(()=>{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null},Math.floor(3e4)),function(e){if("complete"===document.readyState)e();else{let t=!1;const n=function(){document.body?t||(t=!0,e()):setTimeout(n,Math.floor(10))};document.addEventListener?(document.addEventListener("DOMContentLoaded",n,!1),window.addEventListener("load",n,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",()=>{"complete"===document.readyState&&n()}),window.attachEvent("onload",n))}}(()=>{if(this.isClosed_)return;this.scriptTagHolder=new sn((...e)=>{const[t,n,i,s,r]=e;if(this.incrementIncomingBytes_(e),this.scriptTagHolder)if(this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null),this.everConnected_=!0,t===tn)this.id=n,this.password=i;else{if("close"!==t)throw new Error("Unrecognized command received: "+t);n?(this.scriptTagHolder.sendNewPolls=!1,this.myPacketOrderer.closeAfter(n,()=>{this.onClosed_()})):this.onClosed_()}},(...e)=>{const[t,n]=e;this.incrementIncomingBytes_(e),this.myPacketOrderer.handleResponse(t,n)},()=>{this.onClosed_()},this.urlFn);const e={};e[tn]="t",e.ser=Math.floor(1e8*Math.random()),this.scriptTagHolder.uniqueCallbackIdentifier&&(e.cb=this.scriptTagHolder.uniqueCallbackIdentifier),e.v="5",this.transportSessionId&&(e.s=this.transportSessionId),this.lastSessionId&&(e.ls=this.lastSessionId),this.applicationId&&(e.p=this.applicationId),this.appCheckToken&&(e[$t]=this.appCheckToken),"undefined"!=typeof location&&location.hostname&&zt.test(location.hostname)&&(e.r="f");const t=this.urlFn(e);this.log_("Connecting via long-poll to "+t),this.scriptTagHolder.addTag(t,()=>{})})}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){nn.forceAllow_=!0}static forceDisallow(){nn.forceDisallow_=!0}static isAvailable(){return!(!nn.forceAllow_&&(nn.forceDisallow_||"undefined"==typeof document||null==document.createElement||"object"==typeof window&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href)||"object"==typeof Windows&&"object"==typeof Windows.UI))}markConnectionHealthy(){}shutdown_(){this.isClosed_=!0,this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)}onClosed_(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))}close(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())}send(e){const t=k(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const n=p(t),i=Ot(n,1840);for(let e=0;e<i.length;e++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,i.length,i[e]),this.curSegmentNum++}addDisconnectPingFrame(e,t){this.myDisconnFrame=document.createElement("iframe");const n={dframe:"t"};n.id=e,n.pw=t,this.myDisconnFrame.src=this.urlFn(n),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}incrementIncomingBytes_(e){const t=k(e).length;this.bytesReceived+=t,this.stats_.incrementCounter("bytes_received",t)}}class sn{constructor(e,t,n,i){this.onDisconnect=n,this.urlFn=i,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(1e8*Math.random()),this.sendNewPolls=!0;{this.uniqueCallbackIdentifier=mt(),window["pLPCommand"+this.uniqueCallbackIdentifier]=e,window["pRTLPCB"+this.uniqueCallbackIdentifier]=t,this.myIFrame=sn.createIFrame_();let n="";this.myIFrame.src&&"javascript:"===this.myIFrame.src.substr(0,11)&&(n='<script>document.domain="'+document.domain+'";<\/script>');const i="<html><body>"+n+"</body></html>";
vendor: 27,064 bytes, line 2
2try{this.myIFrame.doc.open(),this.myIFrame.doc.write(i),this.myIFrame.doc.close()}catch(e){bt("frame writing exception"),e.stack&&bt(e.stack),bt(e)}}}static createIFrame_(){const e=document.createElement("iframe");if(e.style.display="none",!document.body)throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";document.body.appendChild(e);try{e.contentWindow.document||bt("No IE domain setting required")}catch(t){const n=document.domain;e.src="javascript:void((function(){document.open();document.domain='"+n+"';document.close();})())"}return e.contentDocument?e.doc=e.contentDocument:e.contentWindow?e.doc=e.contentWindow.document:e.document&&(e.doc=e.document),e}close(){this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.textContent="",setTimeout(()=>{null!==this.myIFrame&&(document.body.removeChild(this.myIFrame),this.myIFrame=null)},Math.floor(0)));const e=this.onDisconnect;e&&(this.onDisconnect=null,e())}startLongPoll(e,t){for(this.myID=e,this.myPW=t,this.alive=!0;this.newRequest_(););}newRequest_(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(this.pendingSegs.length>0?2:1)){this.currentSerial++;const e={};e.id=this.myID,e.pw=this.myPW,e.ser=this.currentSerial;let t=this.urlFn(e),n="",i=0;for(;this.pendingSegs.length>0&&this.pendingSegs[0].d.length+30+n.length<=1870;){const e=this.pendingSegs.shift();n=n+"&seg"+i+"="+e.seg+"&ts"+i+"="+e.ts+"&d"+i+"="+e.d,i++}return t+=n,this.addLongPollTag_(t,this.currentSerial),!0}return!1}enqueueSegment(e,t,n){this.pendingSegs.push({seg:e,ts:t,d:n}),this.alive&&this.newRequest_()}addLongPollTag_(e,t){this.outstandingRequests.add(t);const n=()=>{this.outstandingRequests.delete(t),this.newRequest_()},i=setTimeout(n,Math.floor(25e3));this.addTag(e,()=>{clearTimeout(i),n()})}addTag(e,t){setTimeout(()=>{try{if(!this.sendNewPolls)return;const n=this.myIFrame.doc.createElement("script");n.type="text/javascript",n.async=!0,n.src=e,n.onload=n.onreadystatechange=function(){const e=n.readyState;e&&"loaded"!==e&&"complete"!==e||(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),t())},n.onerror=()=>{bt("Long-poll script failed to load: "+e),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(n)}catch(e){}},Math.floor(1))}}let rn=null;"undefined"!=typeof MozWebSocket?rn=MozWebSocket:"undefined"!=typeof WebSocket&&(rn=WebSocket);class on{constructor(e,t,n,i,s,r,o){this.connId=e,this.applicationId=n,this.appCheckToken=i,this.authToken=s,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=It(this.connId),this.stats_=Zt(t),this.connURL=on.connectionURL_(t,r,o,i,n),this.nodeAdmin=t.nodeAdmin}static connectionURL_(e,t,n,i,s){const r={v:"5"};return"undefined"!=typeof location&&location.hostname&&zt.test(location.hostname)&&(r.r="f"),t&&(r.s=t),n&&(r.ls=n),i&&(r[$t]=i),s&&(r.p=s),Gt(e,Vt,r)}open(e,t){this.onDisconnect=t,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,_t.set("previous_websocket_failure",!0);try{let e;this.mySock=new rn(this.connURL,[],e)}catch(e){this.log_("Error instantiating WebSocket.");const t=e.message||e.data;return t&&this.log_(t),void this.onClosed_()}this.mySock.onopen=()=>{this.log_("Websocket connected."),this.everConnected_=!0},this.mySock.onclose=()=>{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()},this.mySock.onmessage=e=>{this.handleIncomingFrame(e)},this.mySock.onerror=e=>{this.log_("WebSocket error.  Closing connection.");const t=e.message||e.data;t&&this.log_(t),this.onClosed_()}}start(){}static forceDisallow(){on.forceDisallow_=!0}static isAvailable(){let e=!1;if("undefined"!=typeof navigator&&navigator.userAgent){const t=/Android ([0-9]{0,}\.[0-9]{0,})/,n=navigator.userAgent.match(t);n&&n.length>1&&parseFloat(n[1])<4.4&&(e=!0)}return!e&&null!==rn&&!on.forceDisallow_}static previouslyFailed(){return _t.isInMemoryStorage||!0===_t.get("previous_websocket_failure")}markConnectionHealthy(){_t.remove("previous_websocket_failure")}appendFrame_(e){if(this.frames.push(e),this.frames.length===this.totalFrames){const e=this.frames.join("");this.frames=null;const t=S(e);this.onMessage(t)}}handleNewFrameCount_(e){this.totalFrames=e,this.frames=[]}extractFrameCount_(e){if(c(null===this.frames,"We already have a frame buffer"),e.length<=6){const t=Number(e);if(!isNaN(t))return this.handleNewFrameCount_(t),null}return this.handleNewFrameCount_(1),e}handleIncomingFrame(e){if(null===this.mySock)return;const t=e.data;if(this.bytesReceived+=t.length,this.stats_.incrementCounter("bytes_received",t.length),this.resetKeepAlive(),null!==this.frames)this.appendFrame_(t);else{const e=this.extractFrameCount_(t);null!==e&&this.appendFrame_(e)}}send(e){this.resetKeepAlive();const t=k(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const n=Ot(t,16384);n.length>1&&this.sendString_(String(n.length));for(let e=0;e<n.length;e++)this.sendString_(n[e])}shutdown_(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)}onClosed_(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))}close(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())}resetKeepAlive(){clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(()=>{this.mySock&&this.sendString_("0"),this.resetKeepAlive()},Math.floor(45e3))}sendString_(e){try{this.mySock.send(e)}catch(e){this.log_("Exception thrown from WebSocket.send():",e.message||e.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}}}on.responsesRequiredToBeHealthy=2,on.healthyTimeout=3e4;class an{static get ALL_TRANSPORTS(){return[nn,on]}static get IS_TRANSPORT_INITIALIZED(){return this.globalTransportInitialized_}constructor(e){this.initTransports_(e)}initTransports_(e){const t=on&&on.isAvailable();let n=t&&!on.previouslyFailed();if(e.webSocketOnly&&(t||St("wss:// URL used, but browser isn't known to support websockets.  Trying anyway."),n=!0),n)this.transports_=[on];else{const e=this.transports_=[];for(const t of an.ALL_TRANSPORTS)t&&t.isAvailable()&&e.push(t);an.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}}an.globalTransportInitialized_=!1;class cn{constructor(e,t,n,i,s,r,o,a,c,l){this.id=e,this.repoInfo_=t,this.applicationId_=n,this.appCheckToken_=i,this.authToken_=s,this.onMessage_=r,this.onReady_=o,this.onDisconnect_=a,this.onKill_=c,this.lastSessionId=l,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=It("c:"+this.id+":"),this.transportManager_=new an(t),this.log_("Connection created"),this.start_()}start_(){const e=this.transportManager_.initialTransport();this.conn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,null,this.lastSessionId),this.primaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.conn_),n=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout(()=>{this.conn_&&this.conn_.open(t,n)},Math.floor(0));const i=e.healthyTimeout||0;i>0&&(this.healthyTimeout_=Ut(()=>{this.healthyTimeout_=null,this.isHealthy_||(this.conn_&&this.conn_.bytesReceived>102400?(this.log_("Connection exceeded healthy timeout but has received "+this.conn_.bytesReceived+" bytes.  Marking connection healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()):this.conn_&&this.conn_.bytesSent>10240?this.log_("Connection exceeded healthy timeout but has sent "+this.conn_.bytesSent+" bytes.  Leaving connection alive."):(this.log_("Closing unhealthy connection after timeout."),this.close()))},Math.floor(i)))}nextTransportId_(){return"c:"+this.id+":"+this.connectionCount++}disconnReceiver_(e){return t=>{e===this.conn_?this.onConnectionLost_(t):e===this.secondaryConn_?(this.log_("Secondary connection lost."),this.onSecondaryConnectionLost_()):this.log_("closing an old connection")}}connReceiver_(e){return t=>{2!==this.state_&&(e===this.rx_?this.onPrimaryMessageReceived_(t):e===this.secondaryConn_?this.onSecondaryMessageReceived_(t):this.log_("message on old connection"))}}sendRequest(e){const t={t:"d",d:e};this.sendData_(t)}tryCleanupConnection(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)}onSecondaryControl_(e){if("t"in e){const t=e.t;"a"===t?this.upgradeIfSecondaryHealthy_():"r"===t?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),this.tx_!==this.secondaryConn_&&this.rx_!==this.secondaryConn_||this.close()):"o"===t&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}}onSecondaryMessageReceived_(e){const t=Dt("t",e),n=Dt("d",e);if("c"===t)this.onSecondaryControl_(n);else{if("d"!==t)throw new Error("Unknown protocol layer: "+t);this.pendingDataMessages.push(n)}}upgradeIfSecondaryHealthy_(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t:"c",d:{t:"p",d:{}}}))}proceedWithUpgrade_(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:"a",d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:"n",d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()}onPrimaryMessageReceived_(e){const t=Dt("t",e),n=Dt("d",e);"c"===t?this.onControl_(n):"d"===t&&this.onDataMessage_(n)}onDataMessage_(e){this.onPrimaryResponse_(),this.onMessage_(e)}onPrimaryResponse_(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))}onControl_(e){const t=Dt("t",e);if("d"in e){const n=e.d;if("h"===t){const e={...n};this.repoInfo_.isUsingEmulator&&(e.h=this.repoInfo_.host),this.onHandshake_(e)}else if("n"===t){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(let e=0;e<this.pendingDataMessages.length;++e)this.onDataMessage_(this.pendingDataMessages[e]);this.pendingDataMessages=[],this.tryCleanupConnection()}else"s"===t?this.onConnectionShutdown_(n):"r"===t?this.onReset_(n):"e"===t?Tt("Server Error: "+n):"o"===t?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):Tt("Unknown control packet command: "+t)}}onHandshake_(e){const t=e.ts,n=e.v,i=e.h;this.sessionId=e.s,this.repoInfo_.host=i,0===this.state_&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,t),"5"!==n&&St("Protocol version mismatch detected"),this.tryStartUpgrade_())}tryStartUpgrade_(){const e=this.transportManager_.upgradeTransport();e&&this.startUpgrade_(e)}startUpgrade_(e){this.secondaryConn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,this.sessionId),this.secondaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.secondaryConn_),n=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(t,n),Ut(()=>{this.secondaryConn_&&(this.log_("Timed out trying to upgrade."),this.secondaryConn_.close())},Math.floor(6e4))}onReset_(e){this.log_("Reset packet received.  New host: "+e),this.repoInfo_.host=e,1===this.state_?this.close():(this.closeConnections_(),this.start_())}onConnectionEstablished_(e,t){this.log_("Realtime connection established."),this.conn_=e,this.state_=1,this.onReady_&&(this.onReady_(t,this.sessionId),this.onReady_=null),0===this.primaryResponsesRequired_?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):Ut(()=>{this.sendPingOnPrimaryIfNecessary_()},Math.floor(5e3))}sendPingOnPrimaryIfNecessary_(){this.isHealthy_||1!==this.state_||(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:"p",d:{}}}))}onSecondaryConnectionLost_(){const e=this.secondaryConn_;this.secondaryConn_=null,this.tx_!==e&&this.rx_!==e||this.close()}onConnectionLost_(e){this.conn_=null,e||0!==this.state_?1===this.state_&&this.log_("Realtime connection lost."):(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(_t.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)),this.close()}onConnectionShutdown_(e){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&&(this.onKill_(e),this.onKill_=null),this.onDisconnect_=null,this.close()}sendData_(e){if(1!==this.state_)throw"Connection is not connected";this.tx_.send(e)}close(){2!==this.state_&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))}closeConnections_(){this.log_("Shutting down all connections"),this.conn_&&(this.conn_.close(),this.conn_=null),this.secondaryConn_&&(this.secondaryConn_.close(),this.secondaryConn_=null),this.healthyTimeout_&&(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)}}class ln{put(e,t,n,i){}merge(e,t,n,i){}refreshAuthToken(e){}refreshAppCheckToken(e){}onDisconnectPut(e,t,n){}onDisconnectMerge(e,t,n){}onDisconnectCancel(e,t){}reportStats(e){}}class hn{constructor(e){this.allowedEvents_=e,this.listeners_={},c(Array.isArray(e)&&e.length>0,"Requires a non-empty array")}trigger(e,...t){if(Array.isArray(this.listeners_[e])){const n=[...this.listeners_[e]];for(let e=0;e<n.length;e++)n[e].callback.apply(n[e].context,t)}}on(e,t,n){this.validateEventType_(e),this.listeners_[e]=this.listeners_[e]||[],this.listeners_[e].push({callback:t,context:n});const i=this.getInitialEvent(e);i&&t.apply(n,i)}off(e,t,n){this.validateEventType_(e);const i=this.listeners_[e]||[];for(let e=0;e<i.length;e++)if(i[e].callback===t&&(!n||n===i[e].context))return void i.splice(e,1)}validateEventType_(e){c(this.allowedEvents_.find(t=>t===e),"Unknown event: "+e)}}class un extends hn{static getInstance(){return new un}constructor(){super(["online"]),this.online_=!0,"undefined"==typeof window||void 0===window.addEventListener||b()||(window.addEventListener("online",()=>{this.online_||(this.online_=!0,this.trigger("online",!0))},!1),window.addEventListener("offline",()=>{this.online_&&(this.online_=!1,this.trigger("online",!1))},!1))}getInitialEvent(e){return c("online"===e,"Unknown event type: "+e),[this.online_]}currentlyOnline(){return this.online_}}class dn{constructor(e,t){if(void 0===t){this.pieces_=e.split("/");let t=0;for(let e=0;e<this.pieces_.length;e++)this.pieces_[e].length>0&&(this.pieces_[t]=this.pieces_[e],t++);this.pieces_.length=t,this.pieceNum_=0}else this.pieces_=e,this.pieceNum_=t}toString(){let e="";for(let t=this.pieceNum_;t<this.pieces_.length;t++)""!==this.pieces_[t]&&(e+="/"+this.pieces_[t]);return e||"/"}}function pn(){return new dn("")}function _n(e){return e.pieceNum_>=e.pieces_.length?null:e.pieces_[e.pieceNum_]}function fn(e){return e.pieces_.length-e.pieceNum_}function gn(e){let t=e.pieceNum_;return t<e.pieces_.length&&t++,new dn(e.pieces_,t)}function mn(e){return e.pieceNum_<e.pieces_.length?e.pieces_[e.pieces_.length-1]:null}function yn(e,t=0){return e.pieces_.slice(e.pieceNum_+t)}function vn(e){if(e.pieceNum_>=e.pieces_.length)return null;const t=[];for(let n=e.pieceNum_;n<e.pieces_.length-1;n++)t.push(e.pieces_[n]);return new dn(t,0)}function Cn(e,t){const n=[];for(let t=e.pieceNum_;t<e.pieces_.length;t++)n.push(e.pieces_[t]);if(t instanceof dn)for(let e=t.pieceNum_;e<t.pieces_.length;e++)n.push(t.pieces_[e]);else{const e=t.split("/");for(let t=0;t<e.length;t++)e[t].length>0&&n.push(e[t])}return new dn(n,0)}function wn(e){return e.pieceNum_>=e.pieces_.length}function bn(e,t){const n=_n(e),i=_n(t);if(null===n)return t;if(n===i)return bn(gn(e),gn(t));throw new Error("INTERNAL ERROR: innerPath ("+t+") is not within outerPath ("+e+")")}function In(e,t){const n=yn(e,0),i=yn(t,0);for(let e=0;e<n.length&&e<i.length;e++){const t=xt(n[e],i[e]);if(0!==t)return t}return n.length===i.length?0:n.length<i.length?-1:1}function Tn(e,t){if(fn(e)!==fn(t))return!1;for(let n=e.pieceNum_,i=t.pieceNum_;n<=e.pieces_.length;n++,i++)if(e.pieces_[n]!==t.pieces_[i])return!1;return!0}function En(e,t){let n=e.pieceNum_,i=t.pieceNum_;if(fn(e)>fn(t))return!1;for(;n<e.pieces_.length;){if(e.pieces_[n]!==t.pieces_[i])return!1;++n,++i}return!0}class Sn{constructor(e,t){this.errorPrefix_=t,this.parts_=yn(e,0),this.byteLength_=Math.max(1,this.parts_.length);for(let e=0;e<this.parts_.length;e++)this.byteLength_+=F(this.parts_[e]);kn(this)}}function kn(e){if(e.byteLength_>768)throw new Error(e.errorPrefix_+"has a key path longer than 768 bytes ("+e.byteLength_+").");if(e.parts_.length>32)throw new Error(e.errorPrefix_+"path specified exceeds the maximum depth that can be written (32) or object contains a cycle "+Nn(e))}function Nn(e){return 0===e.parts_.length?"":"in property '"+e.parts_.join(".")+"'"}class Pn extends hn{static getInstance(){return new Pn}constructor(){let e,t;super(["visible"]),"undefined"!=typeof document&&void 0!==document.addEventListener&&(void 0!==document.hidden?(t="visibilitychange",e="hidden"):void 0!==document.mozHidden?(t="mozvisibilitychange",e="mozHidden"):void 0!==document.msHidden?(t="msvisibilitychange",e="msHidden"):void 0!==document.webkitHidden&&(t="webkitvisibilitychange",e="webkitHidden")),this.visible_=!0,t&&document.addEventListener(t,()=>{const t=!document[e];t!==this.visible_&&(this.visible_=t,this.trigger("visible",t))},!1)}getInitialEvent(e){return c("visible"===e,"Unknown event type: "+e),[this.visible_]}}const xn=1e3;class Rn extends ln{constructor(e,t,n,i,s,r,o,a){if(super(),this.repoInfo_=e,this.applicationId_=t,this.onDataUpdate_=n,this.onConnectStatus_=i,this.onServerInfoUpdate_=s,this.authTokenProvider_=r,this.appCheckTokenProvider_=o,this.authOverride_=a,this.id=Rn.nextPersistentConnectionId_++,this.log_=It("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_=xn,this.maxReconnectDelay_=3e5,this.securityDebugCallback_=null,this.lastSessionId=null,this.establishConnectionTimer_=null,this.visible_=!1,this.requestCBHash_={},this.requestNumber_=0,this.realtime_=null,this.authToken_=null,this.appCheckToken_=null,this.forceTokenRefresh_=!1,this.invalidAuthTokenCount_=0,this.invalidAppCheckTokenCount_=0,this.firstConnection_=!0,this.lastConnectionAttemptTime_=null,this.lastConnectionEstablishedTime_=null,a)throw new Error("Auth override specified in options, but not supported on non Node.js platforms");Pn.getInstance().on("visible",this.onVisible_,this),-1===e.host.indexOf("fblocal")&&un.getInstance().on("online",this.onOnline_,this)}sendRequest(e,t,n){const i=++this.requestNumber_,s={r:i,a:e,b:t};this.log_(k(s)),c(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(s),n&&(this.requestCBHash_[i]=n)}get(e){this.initConnection_();const t=new w,n={action:"g",request:{p:e._path.toString(),q:e._queryObject},onComplete:e=>{const n=e.d;"ok"===e.s?t.resolve(n):t.reject(n)}};this.outstandingGets_.push(n),this.outstandingGetCount_++;const i=this.outstandingGets_.length-1;return this.connected_&&this.sendGet_(i),t.promise}listen(e,t,n,i){this.initConnection_();const s=e._queryIdentifier,r=e._path.toString();this.log_("Listen called for "+r+" "+s),this.listens.has(r)||this.listens.set(r,new Map),c(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),c(!this.listens.get(r).has(s),"listen() called twice for same path/queryId.");const o={onComplete:i,hashFn:t,query:e,tag:n};this.listens.get(r).set(s,o),this.connected_&&this.sendListen_(o)}sendGet_(e){const t=this.outstandingGets_[e];this.sendRequest("g",t.request,n=>{delete this.outstandingGets_[e],this.outstandingGetCount_--,0===this.outstandingGetCount_&&(this.outstandingGets_=[]),t.onComplete&&t.onComplete(n)})}sendListen_(e){const t=e.query,n=t._path.toString(),i=t._queryIdentifier;this.log_("Listen on "+n+" for "+i);const s={p:n};e.tag&&(s.q=t._queryObject,s.t=e.tag),s.h=e.hashFn(),this.sendRequest("q",s,s=>{const r=s.d,o=s.s;Rn.warnOnListenWarnings_(r,t),(this.listens.get(n)&&this.listens.get(n).get(i))===e&&(this.log_("listen response",s),"ok"!==o&&this.removeListen_(n,i),e.onComplete&&e.onComplete(o,r))})}static warnOnListenWarnings_(e,t){if(e&&"object"==typeof e&&P(e,"w")){const n=x(e,"w");if(Array.isArray(n)&&~n.indexOf("no_index")){const e='".indexOn": "'+t._queryParams.getIndex().toString()+'"',n=t._path.toString();St(`Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ${e} at ${n} to your security rules for better performance.`)}}}refreshAuthToken(e){this.authToken_=e,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},()=>{}),this.reduceReconnectDelayIfAdminCredential_(e)}reduceReconnectDelayIfAdminCredential_(e){(e&&40===e.length||function(e){const t=N(e).claims;return"object"==typeof t&&!0===t.admin}(e))&&(this.log_("Admin auth credential detected.  Reducing max reconnect time."),this.maxReconnectDelay_=3e4)}refreshAppCheckToken(e){this.appCheckToken_=e,this.log_("App check token refreshed"),this.appCheckToken_?this.tryAppCheck():this.connected_&&this.sendRequest("unappeck",{},()=>{})}tryAuth(){if(this.connected_&&this.authToken_){const e=this.authToken_,t=function(e){const t=N(e).claims;return!!t&&"object"==typeof t&&t.hasOwnProperty("iat")}(e)?"auth":"gauth",n={cred:e};null===this.authOverride_?n.noauth=!0:"object"==typeof this.authOverride_&&(n.authvar=this.authOverride_),this.sendRequest(t,n,t=>{const n=t.s,i=t.d||"error";this.authToken_===e&&("ok"===n?this.invalidAuthTokenCount_=0:this.onAuthRevoked_(n,i))})}}tryAppCheck(){this.connected_&&this.appCheckToken_&&this.sendRequest("appcheck",{token:this.appCheckToken_},e=>{const t=e.s,n=e.d||"error";"ok"===t?this.invalidAppCheckTokenCount_=0:this.onAppCheckRevoked_(t,n)})}unlisten(e,t){const n=e._path.toString(),i=e._queryIdentifier;this.log_("Unlisten called for "+n+" "+i),c(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(n,i)&&this.connected_&&this.sendUnlisten_(n,i,e._queryObject,t)}sendUnlisten_(e,t,n,i){this.log_("Unlisten on "+e+" for "+t);const s={p:e};i&&(s.q=n,s.t=i),this.sendRequest("n",s)}onDisconnectPut(e,t,n){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",e,t,n):this.onDisconnectRequestQueue_.push({pathString:e,action:"o",data:t,onComplete:n})}onDisconnectMerge(e,t,n){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",e,t,n):this.onDisconnectRequestQueue_.push({pathString:e,action:"om",data:t,onComplete:n})}onDisconnectCancel(e,t){this.initConnection_(),this.connected_?this.sendOnDisconnect_("oc",e,null,t):this.onDisconnectRequestQueue_.push({pathString:e,action:"oc",data:null,onComplete:t})}sendOnDisconnect_(e,t,n,i){const s={p:t,d:n};this.log_("onDisconnect "+e,s),this.sendRequest(e,s,e=>{i&&setTimeout(()=>{i(e.s,e.d)},Math.floor(0))})}put(e,t,n,i){this.putInternal("p",e,t,n,i)}merge(e,t,n,i){this.putInternal("m",e,t,n,i)}putInternal(e,t,n,i,s){this.initConnection_();const r={p:t,d:n};void 0!==s&&(r.h=s),this.outstandingPuts_.push({action:e,request:r,onComplete:i}),this.outstandingPutCount_++;const o=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(o):this.log_("Buffering put: "+t)}sendPut_(e){const t=this.outstandingPuts_[e].action,n=this.outstandingPuts_[e].request,i=this.outstandingPuts_[e].onComplete;this.outstandingPuts_[e].queued=this.connected_,this.sendRequest(t,n,n=>{this.log_(t+" response",n),delete this.outstandingPuts_[e],this.outstandingPutCount_--,0===this.outstandingPutCount_&&(this.outstandingPuts_=[]),i&&i(n.s,n.d)})}reportStats(e){if(this.connected_){const t={c:e};this.log_("reportStats",t),this.sendRequest("s",t,e=>{if("ok"!==e.s){const t=e.d;this.log_("reportStats","Error sending stats: "+t)}})}}onDataMessage_(e){if("r"in e){this.log_("from server: "+k(e));const t=e.r,n=this.requestCBHash_[t];n&&(delete this.requestCBHash_[t],n(e.b))}else{if("error"in e)throw"A server-side error has occurred: "+e.error;"a"in e&&this.onDataPush_(e.a,e.b)}}onDataPush_(e,t){this.log_("handleServerMessage",e,t),"d"===e?this.onDataUpdate_(t.p,t.d,!1,t.t):"m"===e?this.onDataUpdate_(t.p,t.d,!0,t.t):"c"===e?this.onListenRevoked_(t.p,t.q):"ac"===e?this.onAuthRevoked_(t.s,t.d):"apc"===e?this.onAppCheckRevoked_(t.s,t.d):"sd"===e?this.onSecurityDebugPacket_(t):Tt("Unrecognized action received from server: "+k(e)+"\nAre you using the latest client?")}onReady_(e,t){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=(new Date).getTime(),this.handleTimestamp_(e),this.lastSessionId=t,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)}scheduleConnect_(e){c(!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_=xn,this.realtime_||this.scheduleConnect_(0)),this.visible_=e}onOnline_(e){e?(this.log_("Browser went online."),this.reconnectDelay_=xn,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_>3e4&&(this.reconnectDelay_=xn),this.lastConnectionEstablishedTime_=null):(this.log_("Window isn't visible.  Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=(new Date).getTime());const e=Math.max(0,(new Date).getTime()-this.lastConnectionAttemptTime_);let t=Math.max(0,this.reconnectDelay_-e);
vendor: 4,350 bytes, line 2
2t=Math.random()*t,this.log_("Trying to reconnect in "+t+"ms"),this.scheduleConnect_(t),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,1.3*this.reconnectDelay_)}this.onConnectStatus_(!1)}async establishConnection_(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=(new Date).getTime(),this.lastConnectionEstablishedTime_=null;const e=this.onDataMessage_.bind(this),t=this.onReady_.bind(this),n=this.onRealtimeDisconnect_.bind(this),i=this.id+":"+Rn.nextConnectionId_++,s=this.lastSessionId;let r=!1,o=null;const a=function(){o?o.close():(r=!0,n())},l=function(e){c(o,"sendRequest call when we're not connected not allowed."),o.sendRequest(e)};this.realtime_={close:a,sendRequest:l};const h=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{const[a,c]=await Promise.all([this.authTokenProvider_.getToken(h),this.appCheckTokenProvider_.getToken(h)]);r?bt("getToken() completed but was canceled"):(bt("getToken() completed. Creating connection."),this.authToken_=a&&a.accessToken,this.appCheckToken_=c&&c.token,o=new cn(i,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,t,n,e=>{St(e+" ("+this.repoInfo_.toString()+")"),this.interrupt("server_kill")},s))}catch(e){this.log_("Failed to get token: "+e),r||(this.repoInfo_.nodeAdmin&&St(e),a())}}}interrupt(e){bt("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){bt("Resuming connection for reason: "+e),delete this.interruptReasons_[e],R(this.interruptReasons_)&&(this.reconnectDelay_=xn,this.realtime_||this.scheduleConnect_(0))}handleTimestamp_(e){const t=e-(new Date).getTime();this.onServerInfoUpdate_({serverTimeOffset:t})}cancelSentTransactions_(){for(let e=0;e<this.outstandingPuts_.length;e++){const t=this.outstandingPuts_[e];t&&"h"in t.request&&t.queued&&(t.onComplete&&t.onComplete("disconnect"),delete this.outstandingPuts_[e],this.outstandingPutCount_--)}0===this.outstandingPutCount_&&(this.outstandingPuts_=[])}onListenRevoked_(e,t){let n;n=t?t.map(e=>At(e)).join("$"):"default";const i=this.removeListen_(e,n);i&&i.onComplete&&i.onComplete("permission_denied")}removeListen_(e,t){const n=new dn(e).toString();let i;if(this.listens.has(n)){const e=this.listens.get(n);i=e.get(t),e.delete(t),0===e.size&&this.listens.delete(n)}else i=void 0;return i}onAuthRevoked_(e,t){bt("Auth token revoked: "+e+"/"+t),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),"invalid_token"!==e&&"permission_denied"!==e||(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_>=3&&(this.reconnectDelay_=3e4,this.authTokenProvider_.notifyForInvalidToken()))}onAppCheckRevoked_(e,t){bt("App check token revoked: "+e+"/"+t),this.appCheckToken_=null,this.forceTokenRefresh_=!0,"invalid_token"!==e&&"permission_denied"!==e||(this.invalidAppCheckTokenCount_++,this.invalidAppCheckTokenCount_>=3&&this.appCheckTokenProvider_.notifyForInvalidToken())}onSecurityDebugPacket_(e){this.securityDebugCallback_?this.securityDebugCallback_(e):"msg"in e&&console.log("FIREBASE: "+e.msg.replace("\n","\nFIREBASE: "))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of this.listens.values())for(const t of e.values())this.sendListen_(t);for(let e=0;e<this.outstandingPuts_.length;e++)this.outstandingPuts_[e]&&this.sendPut_(e);for(;this.onDisconnectRequestQueue_.length;){const e=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(e.action,e.pathString,e.data,e.onComplete)}for(let e=0;e<this.outstandingGets_.length;e++)this.outstandingGets_[e]&&this.sendGet_(e)}sendConnectStats_(){const e={};e["sdk.js."+ht.replace(/\./g,"-")]=1,b()?e["framework.cordova"]=1:"object"==typeof navigator&&"ReactNative"===navigator.product&&(e["framework.reactnative"]=1),this.reportStats(e)}shouldReconnect_(){const e=un.getInstance().currentlyOnline();return R(this.interruptReasons_)&&e}}Rn.nextPersistentConnectionId_=0,Rn.nextConnectionId_=0;class Dn{constructor(e,t){this.name=e,this.node=t}static Wrap(e,t){return new Dn(e,t)}}class An{getCompare(){return this.compare.bind(this)}indexedValueChanged(e,t){const n=new Dn(Nt,e),i=new Dn(Nt,t);return 0!==this.compare(n,i)}
vendor: 13,152 bytes, line 2
2minPost(){return Dn.MIN}}let On;class Mn extends An{static get __EMPTY_NODE(){return On}static set __EMPTY_NODE(e){On=e}compare(e,t){return xt(e.name,t.name)}isDefinedOn(e){throw l("KeyIndex.isDefinedOn not expected to be called.")}indexedValueChanged(e,t){return!1}minPost(){return Dn.MIN}maxPost(){return new Dn(Pt,On)}makePost(e,t){return c("string"==typeof e,"KeyIndex indexValue must always be a string."),new Dn(e,On)}toString(){return".key"}}const Ln=new Mn;class Fn{constructor(e,t,n,i,s=null){this.isReverse_=i,this.resultGenerator_=s,this.nodeStack_=[];let r=1;for(;!e.isEmpty();)if(r=t?n(e.key,t):1,i&&(r*=-1),r<0)e=this.isReverse_?e.left:e.right;else{if(0===r){this.nodeStack_.push(e);break}this.nodeStack_.push(e),e=this.isReverse_?e.right:e.left}}getNext(){if(0===this.nodeStack_.length)return null;let e,t=this.nodeStack_.pop();if(e=this.resultGenerator_?this.resultGenerator_(t.key,t.value):{key:t.key,value:t.value},this.isReverse_)for(t=t.left;!t.isEmpty();)this.nodeStack_.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack_.push(t),t=t.left;return e}hasNext(){return this.nodeStack_.length>0}peek(){if(0===this.nodeStack_.length)return null;const e=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value}}}class qn{constructor(e,t,n,i,s){this.key=e,this.value=t,this.color=null!=n?n:qn.RED,this.left=null!=i?i:jn.EMPTY_NODE,this.right=null!=s?s:jn.EMPTY_NODE}copy(e,t,n,i,s){return new qn(null!=e?e:this.key,null!=t?t:this.value,null!=n?n:this.color,null!=i?i:this.left,null!=s?s:this.right)}count(){return this.left.count()+1+this.right.count()}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||!!e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min_(){return this.left.isEmpty()?this:this.left.min_()}minKey(){return this.min_().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,n){let i=this;const s=n(e,i.key);return i=s<0?i.copy(null,null,null,i.left.insert(e,t,n),null):0===s?i.copy(null,t,null,null,null):i.copy(null,null,null,null,i.right.insert(e,t,n)),i.fixUp_()}removeMin_(){if(this.left.isEmpty())return jn.EMPTY_NODE;let e=this;return e.left.isRed_()||e.left.left.isRed_()||(e=e.moveRedLeft_()),e=e.copy(null,null,null,e.left.removeMin_(),null),e.fixUp_()}remove(e,t){let n,i;if(n=this,t(e,n.key)<0)n.left.isEmpty()||n.left.isRed_()||n.left.left.isRed_()||(n=n.moveRedLeft_()),n=n.copy(null,null,null,n.left.remove(e,t),null);else{if(n.left.isRed_()&&(n=n.rotateRight_()),n.right.isEmpty()||n.right.isRed_()||n.right.left.isRed_()||(n=n.moveRedRight_()),0===t(e,n.key)){if(n.right.isEmpty())return jn.EMPTY_NODE;i=n.right.min_(),n=n.copy(i.key,i.value,null,null,n.right.removeMin_())}n=n.copy(null,null,null,null,n.right.remove(e,t))}return n.fixUp_()}isRed_(){return this.color}fixUp_(){let e=this;return e.right.isRed_()&&!e.left.isRed_()&&(e=e.rotateLeft_()),e.left.isRed_()&&e.left.left.isRed_()&&(e=e.rotateRight_()),e.left.isRed_()&&e.right.isRed_()&&(e=e.colorFlip_()),e}moveRedLeft_(){let e=this.colorFlip_();return e.right.left.isRed_()&&(e=e.copy(null,null,null,null,e.right.rotateRight_()),e=e.rotateLeft_(),e=e.colorFlip_()),e}moveRedRight_(){let e=this.colorFlip_();return e.left.left.isRed_()&&(e=e.rotateRight_(),e=e.colorFlip_()),e}rotateLeft_(){const e=this.copy(null,null,qn.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight_(){const e=this.copy(null,null,qn.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+")");if(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)}}qn.RED=!0,qn.BLACK=!1;class jn{constructor(e,t=jn.EMPTY_NODE){this.comparator_=e,this.root_=t}insert(e,t){return new jn(this.comparator_,this.root_.insert(e,t,this.comparator_).copy(null,null,qn.BLACK,null,null))}remove(e){return new jn(this.comparator_,this.root_.remove(e,this.comparator_).copy(null,null,qn.BLACK,null,null))}get(e){let t,n=this.root_;for(;!n.isEmpty();){if(t=this.comparator_(e,n.key),0===t)return n.value;t<0?n=n.left:t>0&&(n=n.right)}return null}getPredecessorKey(e){let t,n=this.root_,i=null;for(;!n.isEmpty();){if(t=this.comparator_(e,n.key),0===t){if(n.left.isEmpty())return i?i.key:null;for(n=n.left;!n.right.isEmpty();)n=n.right;return n.key}t<0?n=n.left:t>0&&(i=n,n=n.right)}throw new Error("Attempted to find predecessor key for a nonexistent key.  What gives?")}isEmpty(){return this.root_.isEmpty()}count(){return this.root_.count()}minKey(){return this.root_.minKey()}maxKey(){return this.root_.maxKey()}inorderTraversal(e){return this.root_.inorderTraversal(e)}reverseTraversal(e){return this.root_.reverseTraversal(e)}getIterator(e){return new Fn(this.root_,null,this.comparator_,!1,e)}getIteratorFrom(e,t){return new Fn(this.root_,e,this.comparator_,!1,t)}getReverseIteratorFrom(e,t){return new Fn(this.root_,e,this.comparator_,!0,t)}getReverseIterator(e){return new Fn(this.root_,null,this.comparator_,!0,e)}}function Un(e,t){return xt(e.name,t.name)}function Wn(e,t){return xt(e,t)}let Bn;jn.EMPTY_NODE=new class{copy(e,t,n,i,s){return this}insert(e,t,n){return new qn(e,t,null)}remove(e,t){return this}count(){return 0}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}check_(){return 0}isRed_(){return!1}};const Hn=function(e){return"number"==typeof e?"number:"+Lt(e):"string:"+e},zn=function(e){if(e.isLeafNode()){const t=e.val();c("string"==typeof t||"number"==typeof t||"object"==typeof t&&P(t,".sv"),"Priority must be a string or number.")}else c(e===Bn||e.isEmpty(),"priority of unexpected type.");c(e===Bn||e.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")};let $n,Vn,Yn;class Kn{static set __childrenNodeConstructor(e){$n=e}static get __childrenNodeConstructor(){return $n}constructor(e,t=Kn.__childrenNodeConstructor.EMPTY_NODE){this.value_=e,this.priorityNode_=t,this.lazyHash_=null,c(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),zn(this.priorityNode_)}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new Kn(this.value_,e)}getImmediateChild(e){return".priority"===e?this.priorityNode_:Kn.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return wn(e)?this:".priority"===_n(e)?this.priorityNode_:Kn.__childrenNodeConstructor.EMPTY_NODE}hasChild(){return!1}getPredecessorChildName(e,t){return null}updateImmediateChild(e,t){return".priority"===e?this.updatePriority(t):t.isEmpty()&&".priority"!==e?this:Kn.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,t).updatePriority(this.priorityNode_)}updateChild(e,t){const n=_n(e);return null===n?t:t.isEmpty()&&".priority"!==n?this:(c(".priority"!==n||1===fn(e),".priority must be the last token in a path"),this.updateImmediateChild(n,Kn.__childrenNodeConstructor.EMPTY_NODE.updateChild(gn(e),t)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(e,t){return!1}val(e){return e&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()}hash(){if(null===this.lazyHash_){let e="";this.priorityNode_.isEmpty()||(e+="priority:"+Hn(this.priorityNode_.val())+":");const t=typeof this.value_;e+=t+":",e+="number"===t?Lt(this.value_):this.value_,this.lazyHash_=yt(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===Kn.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof Kn.__childrenNodeConstructor?-1:(c(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){const t=typeof e.value_,n=typeof this.value_,i=Kn.VALUE_TYPE_ORDER.indexOf(t),s=Kn.VALUE_TYPE_ORDER.indexOf(n);return c(i>=0,"Unknown leaf type: "+t),c(s>=0,"Unknown leaf type: "+n),i===s?"object"===n?0:this.value_<e.value_?-1:this.value_===e.value_?0:1:s-i}withIndex(){return this}isIndexed(){return!0}equals(e){if(e===this)return!0;if(e.isLeafNode()){const t=e;return this.value_===t.value_&&this.priorityNode_.equals(t.priorityNode_)}return!1}}Kn.VALUE_TYPE_ORDER=["object","boolean","number","string"];const Gn=new class extends An{compare(e,t){const n=e.node.getPriority(),i=t.node.getPriority(),s=n.compareTo(i);return 0===s?xt(e.name,t.name):s}isDefinedOn(e){return!e.getPriority().isEmpty()}indexedValueChanged(e,t){return!e.getPriority().equals(t.getPriority())}minPost(){return Dn.MIN}maxPost(){return new Dn(Pt,new Kn("[PRIORITY-POST]",Yn))}makePost(e,t){const n=Vn(e);return new Dn(t,new Kn("[PRIORITY-POST]",n))}toString(){return".priority"}},Qn=Math.log(2);class Jn{constructor(e){var t;this.count=(t=e+1,parseInt(Math.log(t)/Qn,10)),this.current_=this.count-1;const n=(i=this.count,parseInt(Array(i+1).join("1"),2));var i;this.bits_=e+1&n}nextBitIsOne(){const e=!(this.bits_&1<<this.current_);return this.current_--,e}}const Xn=function(e,t,n,i){e.sort(t);const s=function(t,i){const r=i-t;let o,a;if(0===r)return null;if(1===r)return o=e[t],a=n?n(o):o,new qn(a,o.node,qn.BLACK,null,null);{const c=parseInt(r/2,10)+t,l=s(t,c),h=s(c+1,i);return o=e[c],a=n?n(o):o,new qn(a,o.node,qn.BLACK,l,h)}},r=function(t){let i=null,r=null,o=e.length;const a=function(t,i){const r=o-t,a=o;o-=t;const l=s(r+1,a),h=e[r],u=n?n(h):h;c(new qn(u,h.node,i,null,l))},c=function(e){i?(i.left=e,i=e):(r=e,i=e)};for(let e=0;e<t.count;++e){const n=t.nextBitIsOne(),i=Math.pow(2,t.count-(e+1));n?a(i,qn.BLACK):(a(i,qn.BLACK),a(i,qn.RED))}return r}(new Jn(e.length));return new jn(i||t,r)};let Zn;const ei={};class ti{static get Default(){return c(ei&&Gn,"ChildrenNode.ts has not been loaded"),Zn=Zn||new ti({".priority":ei},{".priority":Gn}),Zn}constructor(e,t){this.indexes_=e,this.indexSet_=t}get(e){const t=x(this.indexes_,e);if(!t)throw new Error("No index defined for "+e);return t instanceof jn?t:null}hasIndex(e){return P(this.indexSet_,e.toString())}addIndex(e,t){c(e!==Ln,"KeyIndex always exists and isn't meant to be added to the IndexMap.");const n=[];let i=!1;const s=t.getIterator(Dn.Wrap);let r,o=s.getNext();for(;o;)i=i||e.isDefinedOn(o.node),n.push(o),o=s.getNext();r=i?Xn(n,e.getCompare()):ei;const a=e.toString(),l={...this.indexSet_};l[a]=e;const h={...this.indexes_};return h[a]=r,new ti(h,l)}addToIndexes(e,t){const n=D(this.indexes_,(n,i)=>{const s=x(this.indexSet_,i);if(c(s,"Missing index implementation for "+i),n===ei){if(s.isDefinedOn(e.node)){const n=[],i=t.getIterator(Dn.Wrap);let r=i.getNext();for(;r;)r.name!==e.name&&n.push(r),r=i.getNext();return n.push(e),Xn(n,s.getCompare())}return ei}{const i=t.get(e.name);let s=n;return i&&(s=s.remove(new Dn(e.name,i))),s.insert(e,e.node)}});return new ti(n,this.indexSet_)}removeFromIndexes(e,t){const n=D(this.indexes_,n=>{if(n===ei)return n;{const i=t.get(e.name);return i?n.remove(new Dn(e.name,i)):n}});return new ti(n,this.indexSet_)}}let ni;class ii{static get EMPTY_NODE(){return ni||(ni=new ii(new jn(Wn),null,ti.Default))}constructor(e,t,n){this.children_=e,this.priorityNode_=t,this.indexMap_=n,this.lazyHash_=null,this.priorityNode_&&zn(this.priorityNode_),this.children_.isEmpty()&&c(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}isLeafNode(){return!1}getPriority(){return this.priorityNode_||ni}updatePriority(e){return this.children_.isEmpty()?this:new ii(this.children_,e,this.indexMap_)}getImmediateChild(e){if(".priority"===e)return this.getPriority();{const t=this.children_.get(e);return null===t?ni:t}}getChild(e){const t=_n(e);return null===t?this:this.getImmediateChild(t).getChild(gn(e))}hasChild(e){return null!==this.children_.get(e)}updateImmediateChild(e,t){if(c(t,"We should always be passing snapshot nodes"),".priority"===e)return this.updatePriority(t);{const n=new Dn(e,t);let i,s;t.isEmpty()?(i=this.children_.remove(e),s=this.indexMap_.removeFromIndexes(n,this.children_)):(i=this.children_.insert(e,t),s=this.indexMap_.addToIndexes(n,this.children_));const r=i.isEmpty()?ni:this.priorityNode_;return new ii(i,r,s)}}updateChild(e,t){const n=_n(e);if(null===n)return t;{c(".priority"!==_n(e)||1===fn(e),".priority must be the last token in a path");const i=this.getImmediateChild(n).updateChild(gn(e),t);return this.updateImmediateChild(n,i)}}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(e){if(this.isEmpty())return null;const t={};let n=0,i=0,s=!0;if(this.forEachChild(Gn,(r,o)=>{t[r]=o.val(e),n++,s&&ii.INTEGER_REGEXP_.test(r)?i=Math.max(i,Number(r)):s=!1}),!e&&s&&i<2*n){const e=[];for(const n in t)e[n]=t[n];return e}
2return e&&!this.getPriority().isEmpty()&&(t[".priority"]=this.getPriority().val()),t}hash(){if(null===this.lazyHash_){let e="";this.getPriority().isEmpty()||(e+="priority:"+Hn(this.getPriority().val())+":"),this.forEachChild(Gn,(t,n)=>{const i=n.hash();""!==i&&(e+=":"+t+":"+i)}),this.lazyHash_=""===e?"":yt(e)}return this.lazyHash_}getPredecessorChildName(e,t,n){const i=this.resolveIndex_(n);if(i){const n=i.getPredecessorKey(new Dn(e,t));return n?n.name:null}return this.children_.getPredecessorKey(e)}getFirstChildName(e){const t=this.resolveIndex_(e);if(t){const e=t.minKey();return e&&e.name}return this.children_.minKey()}getFirstChild(e){const t=this.getFirstChildName(e);return t?new Dn(t,this.children_.get(t)):null}getLastChildName(e){const t=this.resolveIndex_(e);if(t){const e=t.maxKey();return e&&e.name}return this.children_.maxKey()}getLastChild(e){const t=this.getLastChildName(e);return t?new Dn(t,this.children_.get(t)):null}forEachChild(e,t){const n=this.resolveIndex_(e);return n?n.inorderTraversal(e=>t(e.name,e.node)):this.children_.inorderTraversal(t)}getIterator(e){return this.getIteratorFrom(e.minPost(),e)}getIteratorFrom(e,t){const n=this.resolveIndex_(t);if(n)return n.getIteratorFrom(e,e=>e);{const n=this.children_.getIteratorFrom(e.name,Dn.Wrap);let i=n.peek();for(;null!=i&&t.compare(i,e)<0;)n.getNext(),i=n.peek();return n}}getReverseIterator(e){return this.getReverseIteratorFrom(e.maxPost(),e)}getReverseIteratorFrom(e,t){const n=this.resolveIndex_(t);if(n)return n.getReverseIteratorFrom(e,e=>e);{const n=this.children_.getReverseIteratorFrom(e.name,Dn.Wrap);let i=n.peek();for(;null!=i&&t.compare(i,e)>0;)n.getNext(),i=n.peek();return n}}compareTo(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===si?-1:0}withIndex(e){if(e===Ln||this.indexMap_.hasIndex(e))return this;{const t=this.indexMap_.addIndex(e,this.children_);return new ii(this.children_,this.priorityNode_,t)}}isIndexed(e){return e===Ln||this.indexMap_.hasIndex(e)}equals(e){if(e===this)return!0;if(e.isLeafNode())return!1;{const t=e;if(this.getPriority().equals(t.getPriority())){if(this.children_.count()===t.children_.count()){const e=this.getIterator(Gn),n=t.getIterator(Gn);let i=e.getNext(),s=n.getNext();for(;i&&s;){if(i.name!==s.name||!i.node.equals(s.node))return!1;i=e.getNext(),s=n.getNext()}return null===i&&null===s}return!1}return!1}}resolveIndex_(e){return e===Ln?null:this.indexMap_.get(e.toString())}}ii.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;const si=new class extends ii{constructor(){super(new jn(Wn),ii.EMPTY_NODE,ti.Default)}compareTo(e){return e===this?0:1}equals(e){return e===this}getPriority(){return this}getImmediateChild(e){return ii.EMPTY_NODE}isEmpty(){return!1}};function ri(e,t=null){if(null===e)return ii.EMPTY_NODE;if("object"==typeof e&&".priority"in e&&(t=e[".priority"]),c(null===t||"string"==typeof t||"number"==typeof t||"object"==typeof t&&".sv"in t,"Invalid priority type found: "+typeof t),"object"==typeof e&&".value"in e&&null!==e[".value"]&&(e=e[".value"]),"object"!=typeof e||".sv"in e)return new Kn(e,ri(t));if(e instanceof Array){let n=ii.EMPTY_NODE;return Mt(e,(t,i)=>{if(P(e,t)&&"."!==t.substring(0,1)){const e=ri(i);!e.isLeafNode()&&e.isEmpty()||(n=n.updateImmediateChild(t,e))}}),n.updatePriority(ri(t))}{const n=[];let i=!1;if(Mt(e,(e,t)=>{if("."!==e.substring(0,1)){const s=ri(t);s.isEmpty()||(i=i||!s.getPriority().isEmpty(),n.push(new Dn(e,s)))}}),0===n.length)return ii.EMPTY_NODE;const s=Xn(n,Un,e=>e.name,Wn);if(i){const e=Xn(n,Gn.getCompare());return new ii(s,ri(t),new ti({".priority":e},{".priority":Gn}))}return new ii(s,ri(t),ti.Default)}}Object.defineProperties(Dn,{MIN:{value:new Dn(Nt,ii.EMPTY_NODE)},MAX:{value:new Dn(Pt,si)}}),Mn.__EMPTY_NODE=ii.EMPTY_NODE,Kn.__childrenNodeConstructor=ii,Bn=si,Yn=si,Vn=ri;class oi extends An{constructor(e){super(),this.indexPath_=e,c(!wn(e)&&".priority"!==_n(e),"Can't create PathIndex with empty path or .priority key")}extractChild(e){return e.getChild(this.indexPath_)}isDefinedOn(e){return!e.getChild(this.indexPath_).isEmpty()}compare(e,t){const n=this.extractChild(e.node),i=this.extractChild(t.node),s=n.compareTo(i);return 0===s?xt(e.name,t.name):s}makePost(e,t){const n=ri(e),i=ii.EMPTY_NODE.updateChild(this.indexPath_,n);return new Dn(t,i)}maxPost(){const e=ii.EMPTY_NODE.updateChild(this.indexPath_,si);return new Dn(Pt,e)}toString(){return yn(this.indexPath_,0).join("/")}}const ai=new class extends An{compare(e,t){const n=e.node.compareTo(t.node);return 0===n?xt(e.name,t.name):n}isDefinedOn(e){return!0}indexedValueChanged(e,t){return!e.equals(t)}
vendor: 9,962 bytes, line 2
2minPost(){return Dn.MIN}maxPost(){return Dn.MAX}makePost(e,t){const n=ri(e);return new Dn(t,n)}toString(){return".value"}};function ci(e){return{type:"value",snapshotNode:e}}function li(e,t){return{type:"child_added",snapshotNode:t,childName:e}}function hi(e,t){return{type:"child_removed",snapshotNode:t,childName:e}}function ui(e,t,n){return{type:"child_changed",snapshotNode:t,childName:e,oldSnap:n}}class di{constructor(e){this.index_=e}updateChild(e,t,n,i,s,r){c(e.isIndexed(this.index_),"A node must be indexed if only a child is updated");const o=e.getImmediateChild(t);return o.getChild(i).equals(n.getChild(i))&&o.isEmpty()===n.isEmpty()?e:(null!=r&&(n.isEmpty()?e.hasChild(t)?r.trackChildChange(hi(t,o)):c(e.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):o.isEmpty()?r.trackChildChange(li(t,n)):r.trackChildChange(ui(t,n,o))),e.isLeafNode()&&n.isEmpty()?e:e.updateImmediateChild(t,n).withIndex(this.index_))}updateFullNode(e,t,n){return null!=n&&(e.isLeafNode()||e.forEachChild(Gn,(e,i)=>{t.hasChild(e)||n.trackChildChange(hi(e,i))}),t.isLeafNode()||t.forEachChild(Gn,(t,i)=>{if(e.hasChild(t)){const s=e.getImmediateChild(t);s.equals(i)||n.trackChildChange(ui(t,i,s))}else n.trackChildChange(li(t,i))})),t.withIndex(this.index_)}updatePriority(e,t){return e.isEmpty()?ii.EMPTY_NODE:e.updatePriority(t)}filtersNodes(){return!1}getIndexedFilter(){return this}getIndex(){return this.index_}}class pi{constructor(e){this.indexedFilter_=new di(e.getIndex()),this.index_=e.getIndex(),this.startPost_=pi.getStartPost_(e),this.endPost_=pi.getEndPost_(e),this.startIsInclusive_=!e.startAfterSet_,this.endIsInclusive_=!e.endBeforeSet_}getStartPost(){return this.startPost_}getEndPost(){return this.endPost_}matches(e){const t=this.startIsInclusive_?this.index_.compare(this.getStartPost(),e)<=0:this.index_.compare(this.getStartPost(),e)<0,n=this.endIsInclusive_?this.index_.compare(e,this.getEndPost())<=0:this.index_.compare(e,this.getEndPost())<0;return t&&n}updateChild(e,t,n,i,s,r){return this.matches(new Dn(t,n))||(n=ii.EMPTY_NODE),this.indexedFilter_.updateChild(e,t,n,i,s,r)}updateFullNode(e,t,n){t.isLeafNode()&&(t=ii.EMPTY_NODE);let i=t.withIndex(this.index_);i=i.updatePriority(ii.EMPTY_NODE);const s=this;return t.forEachChild(Gn,(e,t)=>{s.matches(new Dn(e,t))||(i=i.updateImmediateChild(e,ii.EMPTY_NODE))}),this.indexedFilter_.updateFullNode(e,i,n)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.indexedFilter_}getIndex(){return this.index_}static getStartPost_(e){if(e.hasStart()){const t=e.getIndexStartName();return e.getIndex().makePost(e.getIndexStartValue(),t)}return e.getIndex().minPost()}static getEndPost_(e){if(e.hasEnd()){const t=e.getIndexEndName();return e.getIndex().makePost(e.getIndexEndValue(),t)}return e.getIndex().maxPost()}}class _i{constructor(e){this.withinDirectionalStart=e=>this.reverse_?this.withinEndPost(e):this.withinStartPost(e),this.withinDirectionalEnd=e=>this.reverse_?this.withinStartPost(e):this.withinEndPost(e),this.withinStartPost=e=>{const t=this.index_.compare(this.rangedFilter_.getStartPost(),e);return this.startIsInclusive_?t<=0:t<0},this.withinEndPost=e=>{const t=this.index_.compare(e,this.rangedFilter_.getEndPost());return this.endIsInclusive_?t<=0:t<0},this.rangedFilter_=new pi(e),this.index_=e.getIndex(),this.limit_=e.getLimit(),this.reverse_=!e.isViewFromLeft(),this.startIsInclusive_=!e.startAfterSet_,this.endIsInclusive_=!e.endBeforeSet_}updateChild(e,t,n,i,s,r){return this.rangedFilter_.matches(new Dn(t,n))||(n=ii.EMPTY_NODE),e.getImmediateChild(t).equals(n)?e:e.numChildren()<this.limit_?this.rangedFilter_.getIndexedFilter().updateChild(e,t,n,i,s,r):this.fullLimitUpdateChild_(e,t,n,s,r)}updateFullNode(e,t,n){let i;if(t.isLeafNode()||t.isEmpty())i=ii.EMPTY_NODE.withIndex(this.index_);else if(2*this.limit_<t.numChildren()&&t.isIndexed(this.index_)){let e;i=ii.EMPTY_NODE.withIndex(this.index_),e=this.reverse_?t.getReverseIteratorFrom(this.rangedFilter_.getEndPost(),this.index_):t.getIteratorFrom(this.rangedFilter_.getStartPost(),this.index_);let n=0;for(;e.hasNext()&&n<this.limit_;){const t=e.getNext();if(this.withinDirectionalStart(t)){if(!this.withinDirectionalEnd(t))break;i=i.updateImmediateChild(t.name,t.node),n++}}}else{let e;i=t.withIndex(this.index_),i=i.updatePriority(ii.EMPTY_NODE),e=this.reverse_?i.getReverseIterator(this.index_):i.getIterator(this.index_);let n=0;for(;e.hasNext();){const t=e.getNext();n<this.limit_&&this.withinDirectionalStart(t)&&this.withinDirectionalEnd(t)?n++:i=i.updateImmediateChild(t.name,ii.EMPTY_NODE)}}return this.rangedFilter_.getIndexedFilter().updateFullNode(e,i,n)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.rangedFilter_.getIndexedFilter()}getIndex(){return this.index_}fullLimitUpdateChild_(e,t,n,i,s){let r;if(this.reverse_){const e=this.index_.getCompare();r=(t,n)=>e(n,t)}else r=this.index_.getCompare();const o=e;c(o.numChildren()===this.limit_,"");const a=new Dn(t,n),l=this.reverse_?o.getFirstChild(this.index_):o.getLastChild(this.index_),h=this.rangedFilter_.matches(a);if(o.hasChild(t)){const e=o.getImmediateChild(t);let c=i.getChildAfterChild(this.index_,l,this.reverse_);for(;null!=c&&(c.name===t||o.hasChild(c.name));)c=i.getChildAfterChild(this.index_,c,this.reverse_);const u=null==c?1:r(c,a);if(h&&!n.isEmpty()&&u>=0)return null!=s&&s.trackChildChange(ui(t,n,e)),o.updateImmediateChild(t,n);{null!=s&&s.trackChildChange(hi(t,e));const n=o.updateImmediateChild(t,ii.EMPTY_NODE);return null!=c&&this.rangedFilter_.matches(c)?(null!=s&&s.trackChildChange(li(c.name,c.node)),n.updateImmediateChild(c.name,c.node)):n}}return n.isEmpty()?e:h&&r(l,a)>=0?(null!=s&&(s.trackChildChange(hi(l.name,l.node)),s.trackChildChange(li(t,n))),o.updateImmediateChild(t,n).updateImmediateChild(l.name,ii.EMPTY_NODE)):e}}class fi{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_=Gn}hasStart(){return this.startSet_}isViewFromLeft(){return""===this.viewFrom_?this.startSet_:"l"===this.viewFrom_}getIndexStartValue(){return c(this.startSet_,"Only valid if start has been set"),this.indexStartValue_}getIndexStartName(){return c(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:Nt}hasEnd(){return this.endSet_}getIndexEndValue(){return c(this.endSet_,"Only valid if end has been set"),this.indexEndValue_}getIndexEndName(){return c(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:Pt}hasLimit(){return this.limitSet_}hasAnchoredLimit(){return this.limitSet_&&""!==this.viewFrom_}getLimit(){return c(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_===Gn}copy(){const e=new fi;return e.limitSet_=this.limitSet_,e.limit_=this.limit_,e.startSet_=this.startSet_,e.startAfterSet_=this.startAfterSet_,e.indexStartValue_=this.indexStartValue_,e.startNameSet_=this.startNameSet_,e.indexStartName_=this.indexStartName_,e.endSet_=this.endSet_,e.endBeforeSet_=this.endBeforeSet_,e.indexEndValue_=this.indexEndValue_,e.endNameSet_=this.endNameSet_,e.indexEndName_=this.indexEndName_,e.index_=this.index_,e.viewFrom_=this.viewFrom_,e}}function gi(e){const t={};if(e.isDefault())return t;let n;if(e.index_===Gn?n="$priority":e.index_===ai?n="$value":e.index_===Ln?n="$key":(c(e.index_ instanceof oi,"Unrecognized index type!"),n=e.index_.toString()),t.orderBy=k(n),e.startSet_){const n=e.startAfterSet_?"startAfter":"startAt";t[n]=k(e.indexStartValue_),e.startNameSet_&&(t[n]+=","+k(e.indexStartName_))}if(e.endSet_){const n=e.endBeforeSet_?"endBefore":"endAt";t[n]=k(e.indexEndValue_),e.endNameSet_&&(t[n]+=","+k(e.indexEndName_))}return e.limitSet_&&(e.isViewFromLeft()?t.limitToFirst=e.limit_:t.limitToLast=e.limit_),t}function mi(e){const t={};if(e.startSet_&&(t.sp=e.indexStartValue_,e.startNameSet_&&(t.sn=e.indexStartName_),t.sin=!e.startAfterSet_),e.endSet_&&(t.ep=e.indexEndValue_,e.endNameSet_&&(t.en=e.indexEndName_),t.ein=!e.endBeforeSet_),e.limitSet_){t.l=e.limit_;let n=e.viewFrom_;""===n&&(n=e.isViewFromLeft()?"l":"r"),t.vf=n}return e.index_!==Gn&&(t.i=e.index_.toString()),t}class yi extends ln{reportStats(e){throw new Error("Method not implemented.")}static getListenId_(e,t){return void 0!==t?"tag$"+t:(c(e._queryParams.isDefault(),"should have a tag if it's not a default query."),e._path.toString())}constructor(e,t,n,i){super(),this.repoInfo_=e,this.onDataUpdate_=t,this.authTokenProvider_=n,this.appCheckTokenProvider_=i,this.log_=It("p:rest:"),this.listens_={}}listen(e,t,n,i){const s=e._path.toString();this.log_("Listen called for "+s+" "+e._queryIdentifier);const r=yi.getListenId_(e,n),o={};this.listens_[r]=o;const a=gi(e._queryParams);this.restRequest_(s+".json",a,(e,t)=>{let a=t;if(404===e&&(a=null,e=null),null===e&&this.onDataUpdate_(s,a,!1,n),x(this.listens_,r)===o){let t;t=e?401===e?"permission_denied":"rest_error:"+e:"ok",i(t,null)}})}unlisten(e,t){const n=yi.getListenId_(e,t);delete this.listens_[n]}get(e){const t=gi(e._queryParams),n=e._path.toString(),i=new w;return this.restRequest_(n+".json",t,(e,t)=>{let s=t;404===e&&(s=null,e=null),null===e?(this.onDataUpdate_(n,s,!1,null),i.resolve(s)):i.reject(new Error(s))}),i.promise}refreshAuthToken(e){}restRequest_(e,t={},n){return t.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then(([i,s])=>{i&&i.accessToken&&(t.auth=i.accessToken),s&&s.token&&(t.ac=s.token);const r=(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host+e+"?ns="+this.repoInfo_.namespace+function(e){const t=[];
2for(const[n,i]of Object.entries(e))Array.isArray(i)?i.forEach(e=>{t.push(encodeURIComponent(n)+"="+encodeURIComponent(e))}):t.push(encodeURIComponent(n)+"="+encodeURIComponent(i));return t.length?"&"+t.join("&"):""}(t);this.log_("Sending REST request for "+r);const o=new XMLHttpRequest;o.onreadystatechange=()=>{if(n&&4===o.readyState){this.log_("REST Response for "+r+" received. status:",o.status,"response:",o.responseText);let e=null;if(o.status>=200&&o.status<300){try{e=S(o.responseText)}catch(e){St("Failed to parse JSON response for "+r+": "+o.responseText)}n(null,e)}else 401!==o.status&&404!==o.status&&St("Got unsuccessful REST response for "+r+" Status: "+o.status),n(o.status);n=null}},o.open("GET",r,!0),o.send()})}}class vi{constructor(){this.rootNode_=ii.EMPTY_NODE}getNode(e){return this.rootNode_.getChild(e)}updateSnapshot(e,t){this.rootNode_=this.rootNode_.updateChild(e,t)}}function Ci(){return{value:null,children:new Map}}function wi(e,t,n){if(wn(t))e.value=n,e.children.clear();else if(null!==e.value)e.value=e.value.updateChild(t,n);else{const i=_n(t);e.children.has(i)||e.children.set(i,Ci()),wi(e.children.get(i),t=gn(t),n)}}function bi(e,t,n){null!==e.value?n(t,e.value):function(e,t){e.children.forEach((e,n)=>{t(n,e)})}(e,(e,i)=>{bi(i,new dn(t.toString()+"/"+e),n)})}class Ii{constructor(e){this.collection_=e,this.last_=null}get(){const e=this.collection_.get(),t={...e};return this.last_&&Mt(this.last_,(e,n)=>{t[e]=t[e]-n}),this.last_=e,t}}class Ti{constructor(e,t){this.server_=t,this.statsToReport_={},this.statsListener_=new Ii(e);const n=1e4+2e4*Math.random();Ut(this.reportStats_.bind(this),Math.floor(n))}reportStats_(){const e=this.statsListener_.get(),t={};let n=!1;Mt(e,(e,i)=>{i>0&&P(this.statsToReport_,e)&&(t[e]=i,n=!0)}),n&&this.server_.reportStats(t),Ut(this.reportStats_.bind(this),Math.floor(2*Math.random()*3e5))}}var Ei;function Si(e){return{fromUser:!1,fromServer:!0,queryId:e,tagged:!0}}!function(e){e[e.OVERWRITE=0]="OVERWRITE",e[e.MERGE=1]="MERGE",e[e.ACK_USER_WRITE=2]="ACK_USER_WRITE",e[e.LISTEN_COMPLETE=3]="LISTEN_COMPLETE"}(Ei||(Ei={}));class ki{constructor(e,t,n){this.path=e,this.affectedTree=t,this.revert=n,this.type=Ei.ACK_USER_WRITE,this.source={fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}operationForChild(e){if(wn(this.path)){if(null!=this.affectedTree.value)return c(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;{const t=this.affectedTree.subtree(new dn(e));return new ki(pn(),t,this.revert)}}return c(_n(this.path)===e,"operationForChild called for unrelated child."),new ki(gn(this.path),this.affectedTree,this.revert)}}class Ni{constructor(e,t){this.source=e,this.path=t,this.type=Ei.LISTEN_COMPLETE}operationForChild(e){return wn(this.path)?new Ni(this.source,pn()):new Ni(this.source,gn(this.path))}}class Pi{constructor(e,t,n){this.source=e,this.path=t,this.snap=n,this.type=Ei.OVERWRITE}operationForChild(e){return wn(this.path)?new Pi(this.source,pn(),this.snap.getImmediateChild(e)):new Pi(this.source,gn(this.path),this.snap)}}class xi{constructor(e,t,n){this.source=e,this.path=t,this.children=n,this.type=Ei.MERGE}operationForChild(e){if(wn(this.path)){const t=this.children.subtree(new dn(e));return t.isEmpty()?null:t.value?new Pi(this.source,pn(),t.value):new xi(this.source,pn(),t)}return c(_n(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new xi(this.source,gn(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}class Ri{constructor(e,t,n){this.node_=e,this.fullyInitialized_=t,this.filtered_=n}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(e){if(wn(e))return this.isFullyInitialized()&&!this.filtered_;const t=_n(e);return this.isCompleteForChild(t)}isCompleteForChild(e){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(e)}getNode(){return this.node_}}class Di{constructor(e){this.query_=e,this.index_=this.query_._queryParams.getIndex()}}function Ai(e,t,n,i,s,r){const o=i.filter(e=>e.type===n);o.sort((t,n)=>function(e,t,n){if(null==t.childName||null==n.childName)throw l("Should only compare child_ events.");const i=new Dn(t.childName,t.snapshotNode),s=new Dn(n.childName,n.snapshotNode);return e.index_.compare(i,s)}
2(e,t,n)),o.forEach(n=>{const i=function(e,t,n){return"value"===t.type||"child_removed"===t.type||(t.prevName=n.getPredecessorChildName(t.childName,t.snapshotNode,e.index_)),t}(e,n,r);s.forEach(s=>{s.respondsTo(n.type)&&t.push(s.createEvent(i,e.query_))})})}function Oi(e,t){return{eventCache:e,serverCache:t}}function Mi(e,t,n,i){return Oi(new Ri(t,n,i),e.serverCache)}function Li(e,t,n,i){return Oi(e.eventCache,new Ri(t,n,i))}function Fi(e){return e.eventCache.isFullyInitialized()?e.eventCache.getNode():null}function qi(e){return e.serverCache.isFullyInitialized()?e.serverCache.getNode():null}let ji;class Ui{static fromObject(e){let t=new Ui(null);return Mt(e,(e,n)=>{t=t.set(new dn(e),n)}),t}constructor(e,t=(()=>(ji||(ji=new jn(Rt)),ji))()){this.value=e,this.children=t}isEmpty(){return null===this.value&&this.children.isEmpty()}findRootMostMatchingPathAndValue(e,t){if(null!=this.value&&t(this.value))return{path:pn(),value:this.value};if(wn(e))return null;{const n=_n(e),i=this.children.get(n);if(null!==i){const s=i.findRootMostMatchingPathAndValue(gn(e),t);return null!=s?{path:Cn(new dn(n),s.path),value:s.value}:null}return null}}findRootMostValueAndPath(e){return this.findRootMostMatchingPathAndValue(e,()=>!0)}subtree(e){if(wn(e))return this;{const t=_n(e),n=this.children.get(t);return null!==n?n.subtree(gn(e)):new Ui(null)}}set(e,t){if(wn(e))return new Ui(t,this.children);{const n=_n(e),i=(this.children.get(n)||new Ui(null)).set(gn(e),t),s=this.children.insert(n,i);return new Ui(this.value,s)}}remove(e){if(wn(e))return this.children.isEmpty()?new Ui(null):new Ui(null,this.children);{const t=_n(e),n=this.children.get(t);if(n){const i=n.remove(gn(e));let s;return s=i.isEmpty()?this.children.remove(t):this.children.insert(t,i),null===this.value&&s.isEmpty()?new Ui(null):new Ui(this.value,s)}return this}}get(e){if(wn(e))return this.value;{const t=_n(e),n=this.children.get(t);return n?n.get(gn(e)):null}}setTree(e,t){if(wn(e))return t;{const n=_n(e),i=(this.children.get(n)||new Ui(null)).setTree(gn(e),t);let s;return s=i.isEmpty()?this.children.remove(n):this.children.insert(n,i),new Ui(this.value,s)}}fold(e){return this.fold_(pn(),e)}fold_(e,t){const n={};return this.children.inorderTraversal((i,s)=>{n[i]=s.fold_(Cn(e,i),t)}),t(e,this.value,n)}findOnPath(e,t){return this.findOnPath_(e,pn(),t)}findOnPath_(e,t,n){const i=!!this.value&&n(t,this.value);if(i)return i;if(wn(e))return null;{const i=_n(e),s=this.children.get(i);return s?s.findOnPath_(gn(e),Cn(t,i),n):null}}foreachOnPath(e,t){return this.foreachOnPath_(e,pn(),t)}foreachOnPath_(e,t,n){if(wn(e))return this;{this.value&&n(t,this.value);const i=_n(e),s=this.children.get(i);return s?s.foreachOnPath_(gn(e),Cn(t,i),n):new Ui(null)}}foreach(e){this.foreach_(pn(),e)}foreach_(e,t){this.children.inorderTraversal((n,i)=>{i.foreach_(Cn(e,n),t)}),this.value&&t(e,this.value)}foreachChild(e){this.children.inorderTraversal((t,n)=>{n.value&&e(t,n.value)})}}class Wi{constructor(e){this.writeTree_=e}static empty(){return new Wi(new Ui(null))}}function Bi(e,t,n){if(wn(t))return new Wi(new Ui(n));{const i=e.writeTree_.findRootMostValueAndPath(t);if(null!=i){const s=i.path;let r=i.value;const o=bn(s,t);return r=r.updateChild(o,n),new Wi(e.writeTree_.set(s,r))}{const i=new Ui(n),s=e.writeTree_.setTree(t,i);return new Wi(s)}}}function Hi(e,t,n){let i=e;return Mt(n,(e,n)=>{i=Bi(i,Cn(t,e),n)}),i}function zi(e,t){if(wn(t))return Wi.empty();{const n=e.writeTree_.setTree(t,new Ui(null));return new Wi(n)}}function $i(e,t){return null!=Vi(e,t)}function Vi(e,t){const n=e.writeTree_.findRootMostValueAndPath(t);return null!=n?e.writeTree_.get(n.path).getChild(bn(n.path,t)):null}function Yi(e){const t=[],n=e.writeTree_.value;return null!=n?n.isLeafNode()||n.forEachChild(Gn,(e,n)=>{t.push(new Dn(e,n))}):e.writeTree_.children.inorderTraversal((e,n)=>{null!=n.value&&t.push(new Dn(e,n.value))}),t}function Ki(e,t){if(wn(t))return e;{const n=Vi(e,t);return new Wi(null!=n?new Ui(n):e.writeTree_.subtree(t))}}function Gi(e){return e.writeTree_.isEmpty()}function Qi(e,t){return Ji(pn(),e.writeTree_,t)}
2function Ji(e,t,n){if(null!=t.value)return n.updateChild(e,t.value);{let i=null;return t.children.inorderTraversal((t,s)=>{".priority"===t?(c(null!==s.value,"Priority writes must always be leaf nodes"),i=s.value):n=Ji(Cn(e,t),s,n)}),n.getChild(e).isEmpty()||null===i||(n=n.updateChild(Cn(e,".priority"),i)),n}}function Xi(e,t){return ls(t,e)}function Zi(e,t){if(e.snap)return En(e.path,t);for(const n in e.children)if(e.children.hasOwnProperty(n)&&En(Cn(e.path,n),t))return!0;return!1}function es(e){return e.visible}function ts(e,t,n){let i=Wi.empty();for(let s=0;s<e.length;++s){const r=e[s];if(t(r)){const e=r.path;let t;if(r.snap)En(n,e)?(t=bn(n,e),i=Bi(i,t,r.snap)):En(e,n)&&(t=bn(e,n),i=Bi(i,pn(),r.snap.getChild(t)));else{if(!r.children)throw l("WriteRecord should have .snap or .children");if(En(n,e))t=bn(n,e),i=Hi(i,t,r.children);else if(En(e,n))if(t=bn(e,n),wn(t))i=Hi(i,pn(),r.children);else{const e=x(r.children,_n(t));if(e){const n=e.getChild(gn(t));i=Bi(i,pn(),n)}}}}}return i}function ns(e,t,n,i,s){if(i||s){const r=Ki(e.visibleWrites,t);if(!s&&Gi(r))return n;if(s||null!=n||$i(r,pn())){const r=function(e){return(e.visible||s)&&(!i||!~i.indexOf(e.writeId))&&(En(e.path,t)||En(t,e.path))};return Qi(ts(e.allWrites,r,t),n||ii.EMPTY_NODE)}return null}{const i=Vi(e.visibleWrites,t);if(null!=i)return i;{const i=Ki(e.visibleWrites,t);return Gi(i)?n:null!=n||$i(i,pn())?Qi(i,n||ii.EMPTY_NODE):null}}}function is(e,t,n,i){return ns(e.writeTree,e.treePath,t,n,i)}function ss(e,t){return function(e,t,n){let i=ii.EMPTY_NODE;const s=Vi(e.visibleWrites,t);if(s)return s.isLeafNode()||s.forEachChild(Gn,(e,t)=>{i=i.updateImmediateChild(e,t)}),i;if(n){const s=Ki(e.visibleWrites,t);return n.forEachChild(Gn,(e,t)=>{const n=Qi(Ki(s,new dn(e)),t);i=i.updateImmediateChild(e,n)}),Yi(s).forEach(e=>{i=i.updateImmediateChild(e.name,e.node)}),i}
vendor: 9,027 bytes, line 2
2return Yi(Ki(e.visibleWrites,t)).forEach(e=>{i=i.updateImmediateChild(e.name,e.node)}),i}(e.writeTree,e.treePath,t)}function rs(e,t,n,i){return function(e,t,n,i,s){c(i||s,"Either existingEventSnap or existingServerSnap must exist");const r=Cn(t,n);if($i(e.visibleWrites,r))return null;{const t=Ki(e.visibleWrites,r);return Gi(t)?s.getChild(n):Qi(t,s.getChild(n))}}(e.writeTree,e.treePath,t,n,i)}function os(e,t){return function(e,t){return Vi(e.visibleWrites,t)}(e.writeTree,Cn(e.treePath,t))}function as(e,t,n){return function(e,t,n,i){const s=Cn(t,n),r=Vi(e.visibleWrites,s);return null!=r?r:i.isCompleteForChild(n)?Qi(Ki(e.visibleWrites,s),i.getNode().getImmediateChild(n)):null}(e.writeTree,e.treePath,t,n)}function cs(e,t){return ls(Cn(e.treePath,t),e.writeTree)}function ls(e,t){return{treePath:e,writeTree:t}}class hs{constructor(){this.changeMap=new Map}trackChildChange(e){const t=e.type,n=e.childName;c("child_added"===t||"child_changed"===t||"child_removed"===t,"Only child changes supported for tracking"),c(".priority"!==n,"Only non-priority child changes can be tracked.");const i=this.changeMap.get(n);if(i){const s=i.type;if("child_added"===t&&"child_removed"===s)this.changeMap.set(n,ui(n,e.snapshotNode,i.snapshotNode));else if("child_removed"===t&&"child_added"===s)this.changeMap.delete(n);else if("child_removed"===t&&"child_changed"===s)this.changeMap.set(n,hi(n,i.oldSnap));else if("child_changed"===t&&"child_added"===s)this.changeMap.set(n,li(n,e.snapshotNode));else{if("child_changed"!==t||"child_changed"!==s)throw l("Illegal combination of changes: "+e+" occurred after "+i);this.changeMap.set(n,ui(n,e.snapshotNode,i.oldSnap))}}else this.changeMap.set(n,e)}getChanges(){return Array.from(this.changeMap.values())}}const us=new class{getCompleteChild(e){return null}getChildAfterChild(e,t,n){return null}};class ds{constructor(e,t,n=null){this.writes_=e,this.viewCache_=t,this.optCompleteServerCache_=n}getCompleteChild(e){const t=this.viewCache_.eventCache;if(t.isCompleteForChild(e))return t.getNode().getImmediateChild(e);{const t=null!=this.optCompleteServerCache_?new Ri(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return as(this.writes_,e,t)}}getChildAfterChild(e,t,n){const i=null!=this.optCompleteServerCache_?this.optCompleteServerCache_:qi(this.viewCache_),s=function(e,t,n,i,s,r){return function(e,t,n,i,s,r,o){let a;const c=Ki(e.visibleWrites,t),l=Vi(c,pn());if(null!=l)a=l;else{if(null==n)return[];a=Qi(c,n)}if(a=a.withIndex(o),a.isEmpty()||a.isLeafNode())return[];{const e=[],t=o.getCompare(),n=r?a.getReverseIteratorFrom(i,o):a.getIteratorFrom(i,o);let s=n.getNext();for(;s&&e.length<1;)0!==t(s,i)&&e.push(s),s=n.getNext();return e}}(e.writeTree,e.treePath,t,n,0,s,r)}(this.writes_,i,t,0,n,e);return 0===s.length?null:s[0]}}function ps(e,t,n,i,s,r){const o=t.eventCache;if(null!=os(i,n))return t;{let a,l;if(wn(n))if(c(t.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),t.serverCache.isFiltered()){const n=qi(t),s=ss(i,n instanceof ii?n:ii.EMPTY_NODE);a=e.filter.updateFullNode(t.eventCache.getNode(),s,r)}else{const n=is(i,qi(t));a=e.filter.updateFullNode(t.eventCache.getNode(),n,r)}else{const h=_n(n);if(".priority"===h){c(1===fn(n),"Can't have a priority with additional path components");const s=o.getNode();l=t.serverCache.getNode();const r=rs(i,n,s,l);a=null!=r?e.filter.updatePriority(s,r):o.getNode()}else{const c=gn(n);let u;if(o.isCompleteForChild(h)){l=t.serverCache.getNode();const e=rs(i,n,o.getNode(),l);u=null!=e?o.getNode().getImmediateChild(h).updateChild(c,e):o.getNode().getImmediateChild(h)}else u=as(i,h,t.serverCache);a=null!=u?e.filter.updateChild(o.getNode(),h,u,c,s,r):o.getNode()}}return Mi(t,a,o.isFullyInitialized()||wn(n),e.filter.filtersNodes())}}function _s(e,t,n,i,s,r,o,a){const c=t.serverCache;let l;const h=o?e.filter:e.filter.getIndexedFilter();if(wn(n))l=h.updateFullNode(c.getNode(),i,null);else if(h.filtersNodes()&&!c.isFiltered()){const e=c.getNode().updateChild(n,i);l=h.updateFullNode(c.getNode(),e,null)}else{const e=_n(n);if(!c.isCompleteForPath(n)&&fn(n)>1)return t;const s=gn(n),r=c.getNode().getImmediateChild(e).updateChild(s,i);l=".priority"===e?h.updatePriority(c.getNode(),r):h.updateChild(c.getNode(),e,r,s,us,null)}const u=Li(t,l,c.isFullyInitialized()||wn(n),h.filtersNodes());return ps(e,u,n,s,new ds(s,u,r),a)}function fs(e,t,n,i,s,r,o){const a=t.eventCache;let c,l;const h=new ds(s,t,r);if(wn(n))l=e.filter.updateFullNode(t.eventCache.getNode(),i,o),c=Mi(t,l,!0,e.filter.filtersNodes());else{const s=_n(n);if(".priority"===s)l=e.filter.updatePriority(t.eventCache.getNode(),i),c=Mi(t,l,a.isFullyInitialized(),a.isFiltered());else{const r=gn(n),l=a.getNode().getImmediateChild(s);let u;if(wn(r))u=i;else{const e=h.getCompleteChild(s);u=null!=e?".priority"===mn(r)&&e.getChild(vn(r)).isEmpty()?e:e.updateChild(r,i):ii.EMPTY_NODE}c=l.equals(u)?t:Mi(t,e.filter.updateChild(a.getNode(),s,u,r,h,o),a.isFullyInitialized(),e.filter.filtersNodes())}}return c}function gs(e,t){return e.eventCache.isCompleteForChild(t)}function ms(e,t,n){return n.foreach((e,n)=>{t=t.updateChild(e,n)}),t}function ys(e,t,n,i,s,r,o,a){if(t.serverCache.getNode().isEmpty()&&!t.serverCache.isFullyInitialized())return t;let c,l=t;c=wn(n)?i:new Ui(null).setTree(n,i);const h=t.serverCache.getNode();return c.children.inorderTraversal((n,i)=>{if(h.hasChild(n)){const c=ms(0,t.serverCache.getNode().getImmediateChild(n),i);l=_s(e,l,new dn(n),c,s,r,o,a)}}),c.children.inorderTraversal((n,i)=>{const c=!t.serverCache.isCompleteForChild(n)&&null===i.value;if(!h.hasChild(n)&&!c){const c=ms(0,t.serverCache.getNode().getImmediateChild(n),i);l=_s(e,l,new dn(n),c,s,r,o,a)}}),l}class vs{constructor(e,t){this.query_=e,this.eventRegistrations_=[];const n=this.query_._queryParams,i=new di(n.getIndex()),s=(r=n).loadsAllData()?new di(r.getIndex()):r.hasLimit()?new _i(r):new pi(r);var r;this.processor_=function(e){return{filter:e}}(s);const o=t.serverCache,a=t.eventCache,c=i.updateFullNode(ii.EMPTY_NODE,o.getNode(),null),l=s.updateFullNode(ii.EMPTY_NODE,a.getNode(),null),h=new Ri(c,o.isFullyInitialized(),i.filtersNodes()),u=new Ri(l,a.isFullyInitialized(),s.filtersNodes());this.viewCache_=Oi(u,h),this.eventGenerator_=new Di(this.query_)}get query(){return this.query_}}function Cs(e,t){const n=qi(e.viewCache_);return n&&(e.query._queryParams.loadsAllData()||!wn(t)&&!n.getImmediateChild(_n(t)).isEmpty())?n.getChild(t):null}function ws(e){return 0===e.eventRegistrations_.length}function bs(e,t,n){const i=[];if(n){c(null==t,"A cancel should cancel all event registrations.");const s=e.query._path;e.eventRegistrations_.forEach(e=>{const t=e.createCancelEvent(n,s);t&&i.push(t)})}if(t){let n=[];for(let i=0;i<e.eventRegistrations_.length;++i){const s=e.eventRegistrations_[i];if(s.matches(t)){if(t.hasAnyCallback()){n=n.concat(e.eventRegistrations_.slice(i+1));break}}else n.push(s)}e.eventRegistrations_=n}else e.eventRegistrations_=[];return i}function Is(e,t,n,i){t.type===Ei.MERGE&&null!==t.source.queryId&&(c(qi(e.viewCache_),"We should always have a full cache before handling merges"),c(Fi(e.viewCache_),"Missing event cache, even though we have a server cache"));const s=e.viewCache_,r=function(e,t,n,i,s){const r=new hs;let o,a;if(n.type===Ei.OVERWRITE){const l=n;l.source.fromUser?o=fs(e,t,l.path,l.snap,i,s,r):(c(l.source.fromServer,"Unknown source."),a=l.source.tagged||t.serverCache.isFiltered()&&!wn(l.path),o=_s(e,t,l.path,l.snap,i,s,a,r))}else if(n.type===Ei.MERGE){const l=n;l.source.fromUser?o=function(e,t,n,i,s,r,o){let a=t;return i.foreach((i,c)=>{const l=Cn(n,i);gs(t,_n(l))&&(a=fs(e,a,l,c,s,r,o))}),i.foreach((i,c)=>{const l=Cn(n,i);gs(t,_n(l))||(a=fs(e,a,l,c,s,r,o))}),a}(e,t,l.path,l.children,i,s,r):(c(l.source.fromServer,"Unknown source."),a=l.source.tagged||t.serverCache.isFiltered(),o=ys(e,t,l.path,l.children,i,s,a,r))}else if(n.type===Ei.ACK_USER_WRITE){const a=n;o=a.revert?function(e,t,n,i,s,r){let o;if(null!=os(i,n))return t;{const a=new ds(i,t,s),l=t.eventCache.getNode();let h;if(wn(n)||".priority"===_n(n)){let n;if(t.serverCache.isFullyInitialized())n=is(i,qi(t));else{const e=t.serverCache.getNode();c(e instanceof ii,"serverChildren would be complete if leaf node"),n=ss(i,e)}h=e.filter.updateFullNode(l,n,r)}else{const s=_n(n);let c=as(i,s,t.serverCache);null==c&&t.serverCache.isCompleteForChild(s)&&(c=l.getImmediateChild(s)),h=null!=c?e.filter.updateChild(l,s,c,gn(n),a,r):t.eventCache.getNode().hasChild(s)?e.filter.updateChild(l,s,ii.EMPTY_NODE,gn(n),a,r):l,h.isEmpty()&&t.serverCache.isFullyInitialized()&&(o=is(i,qi(t)),o.isLeafNode()&&(h=e.filter.updateFullNode(h,o,r)))}return o=t.serverCache.isFullyInitialized()||null!=os(i,pn()),Mi(t,h,o,e.filter.filtersNodes())}}(e,t,a.path,i,s,r):function(e,t,n,i,s,r,o){if(null!=os(s,n))return t;const a=t.serverCache.isFiltered(),c=t.serverCache;if(null!=i.value){if(wn(n)&&c.isFullyInitialized()||c.isCompleteForPath(n))return _s(e,t,n,c.getNode().getChild(n),s,r,a,o);if(wn(n)){let i=new Ui(null);
2return c.getNode().forEachChild(Ln,(e,t)=>{i=i.set(new dn(e),t)}),ys(e,t,n,i,s,r,a,o)}return t}{let l=new Ui(null);return i.foreach((e,t)=>{const i=Cn(n,e);c.isCompleteForPath(i)&&(l=l.set(e,c.getNode().getChild(i)))}),ys(e,t,n,l,s,r,a,o)}}(e,t,a.path,a.affectedTree,i,s,r)}else{if(n.type!==Ei.LISTEN_COMPLETE)throw l("Unknown operation type: "+n.type);o=function(e,t,n,i,s){const r=t.serverCache;return ps(e,Li(t,r.getNode(),r.isFullyInitialized()||wn(n),r.isFiltered()),n,i,us,s)}(e,t,n.path,i,r)}const h=r.getChanges();return function(e,t,n){const i=t.eventCache;if(i.isFullyInitialized()){const s=i.getNode().isLeafNode()||i.getNode().isEmpty(),r=Fi(e);(n.length>0||!e.eventCache.isFullyInitialized()||s&&!i.getNode().equals(r)||!i.getNode().getPriority().equals(r.getPriority()))&&n.push(ci(Fi(t)))}}(t,o,h),{viewCache:o,changes:h}}(e.processor_,s,t,n,i);var o,a;return o=e.processor_,a=r.viewCache,c(a.eventCache.getNode().isIndexed(o.filter.getIndex()),"Event snap not indexed"),c(a.serverCache.getNode().isIndexed(o.filter.getIndex()),"Server snap not indexed"),c(r.viewCache.serverCache.isFullyInitialized()||!s.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),e.viewCache_=r.viewCache,Ts(e,r.changes,r.viewCache.eventCache.getNode(),null)}function Ts(e,t,n,i){const s=i?[i]:e.eventRegistrations_;return function(e,t,n,i){const s=[],r=[];return t.forEach(t=>{var n;"child_changed"===t.type&&e.index_.indexedValueChanged(t.oldSnap,t.snapshotNode)&&r.push((n=t.childName,{type:"child_moved",snapshotNode:t.snapshotNode,childName:n}))}),Ai(e,s,"child_removed",t,i,n),Ai(e,s,"child_added",t,i,n),Ai(e,s,"child_moved",r,i,n),Ai(e,s,"child_changed",t,i,n),Ai(e,s,"value",t,i,n),s}(e.eventGenerator_,t,n,s)}let Es,Ss;class ks{constructor(){this.views=new Map}}function Ns(e,t,n,i){const s=t.source.queryId;if(null!==s){const r=e.views.get(s);return c(null!=r,"SyncTree gave us an op for an invalid query."),Is(r,t,n,i)}{let s=[];for(const r of e.views.values())s=s.concat(Is(r,t,n,i));return s}}function Ps(e,t,n,i,s){const r=t._queryIdentifier,o=e.views.get(r);if(!o){let e=is(n,s?i:null),r=!1;e?r=!0:i instanceof ii?(e=ss(n,i),r=!1):(e=ii.EMPTY_NODE,r=!1);const o=Oi(new Ri(e,r,!1),new Ri(i,s,!1));return new vs(t,o)}return o}function xs(e){const t=[];for(const n of e.views.values())n.query._queryParams.loadsAllData()||t.push(n);return t}function Rs(e,t){let n=null;for(const i of e.views.values())n=n||Cs(i,t);return n}function Ds(e,t){if(t._queryParams.loadsAllData())return Ms(e);{const n=t._queryIdentifier;return e.views.get(n)}}function As(e,t){return null!=Ds(e,t)}function Os(e){return null!=Ms(e)}function Ms(e){for(const t of e.views.values())if(t.query._queryParams.loadsAllData())return t;return null}let Ls=1;class Fs{constructor(e){this.listenProvider_=e,this.syncPointTree_=new Ui(null),this.pendingWriteTree_={visibleWrites:Wi.empty(),allWrites:[],lastWriteId:-1},this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function qs(e,t,n,i,s){return function(e,t,n,i,s){c(i>e.lastWriteId,"Stacking an older write on top of newer ones"),void 0===s&&(s=!0),e.allWrites.push({path:t,snap:n,writeId:i,visible:s}),s&&(e.visibleWrites=Bi(e.visibleWrites,t,n)),e.lastWriteId=i}(e.pendingWriteTree_,t,n,i,s),s?$s(e,new Pi({fromUser:!0,fromServer:!1,queryId:null,tagged:!1},t,n)):[]}function js(e,t,n=!1){const i=function(e,t){for(let n=0;n<e.allWrites.length;n++){const i=e.allWrites[n];if(i.writeId===t)return i}return null}(e.pendingWriteTree_,t);if(function(e,t){const n=e.allWrites.findIndex(e=>e.writeId===t);c(n>=0,"removeWrite called with nonexistent writeId.");const i=e.allWrites[n];e.allWrites.splice(n,1);let s=i.visible,r=!1,o=e.allWrites.length-1;for(;s&&o>=0;){const t=e.allWrites[o];t.visible&&(o>=n&&Zi(t,i.path)?s=!1:En(i.path,t.path)&&(r=!0)),o--}return!!s&&(r?(function(e){e.visibleWrites=ts(e.allWrites,es,pn()),e.allWrites.length>0?e.lastWriteId=e.allWrites[e.allWrites.length-1].writeId:e.lastWriteId=-1}(e),!0):(i.snap?e.visibleWrites=zi(e.visibleWrites,i.path):Mt(i.children,t=>{e.visibleWrites=zi(e.visibleWrites,Cn(i.path,t))}),!0))}(e.pendingWriteTree_,t)){let t=new Ui(null);return null!=i.snap?t=t.set(pn(),!0):Mt(i.children,e=>{t=t.set(new dn(e),!0)}),$s(e,new ki(i.path,t,n))}return[]}function Us(e,t,n){return $s(e,new Pi({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},t,n))}function Ws(e,t,n,i,s=!1){const r=t._path,o=e.syncPointTree_.get(r);let a=[];if(o&&("default"===t._queryIdentifier||As(o,t))){const l=function(e,t,n,i){const s=t._queryIdentifier,r=[];let o=[];const a=Os(e);if("default"===s)for(const[t,s]of e.views.entries())o=o.concat(bs(s,n,i)),ws(s)&&(e.views.delete(t),s.query._queryParams.loadsAllData()||r.push(s.query));else{const t=e.views.get(s);t&&(o=o.concat(bs(t,n,i)),ws(t)&&(e.views.delete(s),t.query._queryParams.loadsAllData()||r.push(t.query)))}return a&&!Os(e)&&r.push(new(c(Es,"Reference.ts has not been loaded"),Es)(t._repo,t._path)),{removed:r,events:o}}(o,t,n,i);0===o.views.size&&(e.syncPointTree_=e.syncPointTree_.remove(r));const h=l.removed;if(a=l.events,!s){const n=-1!==h.findIndex(e=>e._queryParams.loadsAllData()),s=e.syncPointTree_.findOnPath(r,(e,t)=>Os(t));if(n&&!s){const t=e.syncPointTree_.subtree(r);if(!t.isEmpty()){const n=function(e){return e.fold((e,t,n)=>{if(t&&Os(t))return[Ms(t)];{let e=[];return t&&(e=xs(t)),Mt(n,(t,n)=>{e=e.concat(n)}),e}})}(t);for(let t=0;t<n.length;++t){const i=n[t],s=i.query,r=Ks(e,i);
2e.listenProvider_.startListening(er(s),Gs(e,s),r.hashFn,r.onComplete)}}}if(!s&&h.length>0&&!i)if(n){const n=null;e.listenProvider_.stopListening(er(t),n)}else h.forEach(t=>{const n=e.queryToTagMap.get(Qs(t));e.listenProvider_.stopListening(er(t),n)})}!function(e,t){for(let n=0;n<t.length;++n){const i=t[n];if(!i._queryParams.loadsAllData()){const t=Qs(i),n=e.queryToTagMap.get(t);e.queryToTagMap.delete(t),e.tagToQueryMap.delete(n)}}}(e,h)}return a}function Bs(e,t,n,i){const s=Js(e,i);if(null!=s){const i=Xs(s),r=i.path,o=i.queryId,a=bn(r,t);return Zs(e,r,new Pi(Si(o),a,n))}return[]}function Hs(e,t,n,i=!1){const s=t._path;let r=null,o=!1;e.syncPointTree_.foreachOnPath(s,(e,t)=>{const n=bn(e,s);r=r||Rs(t,n),o=o||Os(t)});let a,l=e.syncPointTree_.get(s);l?(o=o||Os(l),r=r||Rs(l,pn())):(l=new ks,e.syncPointTree_=e.syncPointTree_.set(s,l)),null!=r?a=!0:(a=!1,r=ii.EMPTY_NODE,e.syncPointTree_.subtree(s).foreachChild((e,t)=>{const n=Rs(t,pn());n&&(r=r.updateImmediateChild(e,n))}));const h=As(l,t);if(!h&&!t._queryParams.loadsAllData()){const n=Qs(t);c(!e.queryToTagMap.has(n),"View does not exist, but we have a tag");const i=Ls++;e.queryToTagMap.set(n,i),e.tagToQueryMap.set(i,n)}let u=function(e,t,n,i,s,r){const o=Ps(e,t,i,s,r);return e.views.has(t._queryIdentifier)||e.views.set(t._queryIdentifier,o),function(e,t){e.eventRegistrations_.push(t)}(o,n),function(e,t){const n=e.viewCache_.eventCache,i=[];return n.getNode().isLeafNode()||n.getNode().forEachChild(Gn,(e,t)=>{i.push(li(e,t))}),n.isFullyInitialized()&&i.push(ci(n.getNode())),Ts(e,i,n.getNode(),t)}(o,n)}(l,t,n,Xi(e.pendingWriteTree_,s),r,a);if(!h&&!o&&!i){const n=Ds(l,t);u=u.concat(function(e,t,n){const i=t._path,s=Gs(e,t),r=Ks(e,n),o=e.listenProvider_.startListening(er(t),s,r.hashFn,r.onComplete),a=e.syncPointTree_.subtree(i);if(s)c(!Os(a.value),"If we're adding a query, it shouldn't be shadowed");else{const t=a.fold((e,t,n)=>{if(!wn(e)&&t&&Os(t))return[Ms(t).query];{let e=[];return t&&(e=e.concat(xs(t).map(e=>e.query))),Mt(n,(t,n)=>{e=e.concat(n)}),e}});for(let n=0;n<t.length;++n){const i=t[n];e.listenProvider_.stopListening(er(i),Gs(e,i))}}return o}(e,t,n))}return u}function zs(e,t,n){const i=e.pendingWriteTree_,s=e.syncPointTree_.findOnPath(t,(e,n)=>{const i=Rs(n,bn(e,t));if(i)return i});return ns(i,t,s,n,!0)}function $s(e,t){return Vs(t,e.syncPointTree_,null,Xi(e.pendingWriteTree_,pn()))}function Vs(e,t,n,i){if(wn(e.path))return Ys(e,t,n,i);
vendor: 1,813 bytes, line 2
2{const s=t.get(pn());null==n&&null!=s&&(n=Rs(s,pn()));let r=[];const o=_n(e.path),a=e.operationForChild(o),c=t.children.get(o);if(c&&a){const e=n?n.getImmediateChild(o):null,t=cs(i,o);r=r.concat(Vs(a,c,e,t))}return s&&(r=r.concat(Ns(s,e,i,n))),r}}function Ys(e,t,n,i){const s=t.get(pn());null==n&&null!=s&&(n=Rs(s,pn()));let r=[];return t.children.inorderTraversal((t,s)=>{const o=n?n.getImmediateChild(t):null,a=cs(i,t),c=e.operationForChild(t);c&&(r=r.concat(Ys(c,s,o,a)))}),s&&(r=r.concat(Ns(s,e,i,n))),r}function Ks(e,t){const n=t.query,i=Gs(e,n);return{hashFn:()=>{const e=function(e){return e.viewCache_.serverCache.getNode()}(t)||ii.EMPTY_NODE;return e.hash()},onComplete:t=>{if("ok"===t)return i?function(e,t,n){const i=Js(e,n);if(i){const n=Xs(i),s=n.path,r=n.queryId,o=bn(s,t);return Zs(e,s,new Ni(Si(r),o))}return[]}(e,n._path,i):function(e,t){return $s(e,new Ni({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},t))}(e,n._path);{const i=function(e,t){let n="Unknown Error";"too_big"===e?n="The data requested exceeds the maximum size that can be accessed with a single request.":"permission_denied"===e?n="Client doesn't have permission to access the desired data.":"unavailable"===e&&(n="The service is unavailable");const i=new Error(e+" at "+t._path.toString()+": "+n);return i.code=e.toUpperCase(),i}(t,n);return Ws(e,n,null,i)}}}}function Gs(e,t){const n=Qs(t);return e.queryToTagMap.get(n)}function Qs(e){return e._path.toString()+"$"+e._queryIdentifier}function Js(e,t){return e.tagToQueryMap.get(t)}function Xs(e){const t=e.indexOf("$");return c(-1!==t&&t<e.length-1,"Bad queryKey."),{queryId:e.substr(t+1),path:new dn(e.substr(0,t))}}function Zs(e,t,n){const i=e.syncPointTree_.get(t);return c(i,"Missing sync point for query tag that we're tracking"),Ns(i,n,Xi(e.pendingWriteTree_,t),null)}
2function er(e){return e._queryParams.loadsAllData()&&!e._queryParams.isDefault()?new(c(Ss,"Reference.ts has not been loaded"),Ss)(e._repo,e._path):e}class tr{constructor(e){this.node_=e}getImmediateChild(e){const t=this.node_.getImmediateChild(e);return new tr(t)}node(){return this.node_}}class nr{constructor(e,t){this.syncTree_=e,this.path_=t}getImmediateChild(e){const t=Cn(this.path_,e);return new nr(this.syncTree_,t)}node(){return zs(this.syncTree_,this.path_)}}const ir=function(e,t,n){return e&&"object"==typeof e?(c(".sv"in e,"Unexpected leaf node or priority contents"),"string"==typeof e[".sv"]?sr(e[".sv"],t,n):"object"==typeof e[".sv"]?rr(e[".sv"],t):void c(!1,"Unexpected server value: "+JSON.stringify(e,null,2))):e},sr=function(e,t,n){if("timestamp"===e)return n.timestamp;c(!1,"Unexpected server value: "+e)},rr=function(e,t,n){e.hasOwnProperty("increment")||c(!1,"Unexpected server value: "+JSON.stringify(e,null,2));const i=e.increment;"number"!=typeof i&&c(!1,"Unexpected increment value: "+i);const s=t.node();if(c(null!=s,"Expected ChildrenNode.EMPTY_NODE for nulls"),!s.isLeafNode())return i;const r=s.getValue();return"number"!=typeof r?i:r+i},or=function(e,t,n,i){return cr(t,new nr(n,e),i)},ar=function(e,t,n){return cr(e,new tr(t),n)};function cr(e,t,n){const i=e.getPriority().val(),s=ir(i,t.getImmediateChild(".priority"),n);let r;if(e.isLeafNode()){const i=e,r=ir(i.getValue(),t,n);return r!==i.getValue()||s!==i.getPriority().val()?new Kn(r,ri(s)):e}{const i=e;return r=i,s!==i.getPriority().val()&&(r=r.updatePriority(new Kn(s))),i.forEachChild(Gn,(e,i)=>{const s=cr(i,t.getImmediateChild(e),n);s!==i&&(r=r.updateImmediateChild(e,s))}),r}}class lr{constructor(e="",t=null,n={children:{},childCount:0}){this.name=e,this.parent=t,this.node=n}}function hr(e,t){let n=t instanceof dn?t:new dn(t),i=e,s=_n(n);for(;null!==s;){const e=x(i.node.children,s)||{children:{},childCount:0};i=new lr(s,i,e),n=gn(n),s=_n(n)}return i}function ur(e){return e.node.value}function dr(e,t){e.node.value=t,mr(e)}function pr(e){return e.node.childCount>0}function _r(e,t){Mt(e.node.children,(n,i)=>{t(new lr(n,e,i))})}function fr(e,t,n,i){n&&!i&&t(e),_r(e,e=>{fr(e,t,!0,i)}),n&&i&&t(e)}function gr(e){return new dn(null===e.parent?e.name:gr(e.parent)+"/"+e.name)}function mr(e){null!==e.parent&&function(e,t,n){const i=function(e){return void 0===ur(e)&&!pr(e)}(n),s=P(e.node.children,t);i&&s?(delete e.node.children[t],e.node.childCount--,mr(e)):i||s||(e.node.children[t]=n.node,e.node.childCount++,mr(e))}(e.parent,e.name,e)}const yr=/[\[\].#$\/\u0000-\u001F\u007F]/,vr=/[\[\].#$\u0000-\u001F\u007F]/,Cr=10485760,wr=function(e){return"string"==typeof e&&0!==e.length&&!yr.test(e)},br=function(e){return"string"==typeof e&&0!==e.length&&!vr.test(e)},Ir=function(e,t,n,i){i&&void 0===t||Tr(L(e,"value"),t,n)},Tr=function(e,t,n){const i=n instanceof dn?new Sn(n,e):n;if(void 0===t)throw new Error(e+"contains undefined "+Nn(i));if("function"==typeof t)throw new Error(e+"contains a function "+Nn(i)+" with contents = "+t.toString());if(kt(t))throw new Error(e+"contains "+t.toString()+" "+Nn(i));if("string"==typeof t&&t.length>Cr/3&&F(t)>Cr)throw new Error(e+"contains a string greater than "+Cr+" utf8 bytes "+Nn(i)+" ('"+t.substring(0,50)+"...')");if(t&&"object"==typeof t){let n=!1,s=!1;if(Mt(t,(t,r)=>{if(".value"===t)n=!0;else if(".priority"!==t&&".sv"!==t&&(s=!0,!wr(t)))throw new Error(e+" contains an invalid key ("+t+") "+Nn(i)+'.  Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');!function(e,t){e.parts_.length>0&&(e.byteLength_+=1),e.parts_.push(t),e.byteLength_+=F(t),kn(e)}(i,t),Tr(e,r,i),function(e){const t=e.parts_.pop();e.byteLength_-=F(t),e.parts_.length>0&&(e.byteLength_-=1)}(i)}),n&&s)throw new Error(e+' contains ".value" child '+Nn(i)+" in addition to actual children.")}},Er=function(e,t,n,i){if(!(i&&void 0===n||br(n)))throw new Error(L(e,t)+'was an invalid path = "'+n+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')},Sr=function(e,t){if(".info"===_n(t))throw new Error(e+" failed = Can't modify data under /.info/")};class kr{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function Nr(e,t){let n=null;for(let i=0;i<t.length;i++){const s=t[i],r=s.getPath();null===n||Tn(r,n.path)||(e.eventLists_.push(n),n=null),null===n&&(n={events:[],path:r}),n.events.push(s)}n&&e.eventLists_.push(n)}function Pr(e,t,n){Nr(e,n),Rr(e,e=>Tn(e,t))}function xr(e,t,n){Nr(e,n),Rr(e,e=>En(e,t)||En(t,e))}function Rr(e,t){e.recursionDepth_++;let n=!0;for(let i=0;i<e.eventLists_.length;i++){const s=e.eventLists_[i];s&&(t(s.path)?(Dr(e.eventLists_[i]),e.eventLists_[i]=null):n=!1)}n&&(e.eventLists_=[]),e.recursionDepth_--}function Dr(e){for(let t=0;t<e.events.length;t++){const n=e.events[t];if(null!==n){e.events[t]=null;const i=n.getEventRunner();Ct&&bt("event: "+n.toString()),jt(i)}}}class Ar{constructor(e,t,n,i){this.repoInfo_=e,this.forceRestClient_=t,this.authTokenProvider_=n,this.appCheckProvider_=i,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new kr,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=Ci(),this.transactionQueueTree_=new lr,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}function Or(e){const t=e.infoData_.getNode(new dn(".info/serverTimeOffset")).val()||0;return(new Date).getTime()+t}function Mr(e){return(t=(t={timestamp:Or(e)})||{}).timestamp=t.timestamp||(new Date).getTime(),t;var t}function Lr(e,t,n,i,s){e.dataUpdateCount++;const r=new dn(t);n=e.interceptServerDataCallback_?e.interceptServerDataCallback_(t,n):n;let o=[];if(s)if(i){const t=D(n,e=>ri(e));o=function(e,t,n,i){const s=Js(e,i);if(s){const i=Xs(s),r=i.path,o=i.queryId,a=bn(r,t),c=Ui.fromObject(n);return Zs(e,r,new xi(Si(o),a,c))}return[]}
2(e.serverSyncTree_,r,t,s)}else{const t=ri(n);o=Bs(e.serverSyncTree_,r,t,s)}else if(i){const t=D(n,e=>ri(e));o=function(e,t,n){const i=Ui.fromObject(n);return $s(e,new xi({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},t,i))}(e.serverSyncTree_,r,t)}else{const t=ri(n);o=Us(e.serverSyncTree_,r,t)}let a=r;o.length>0&&(a=$r(e,r)),xr(e.eventQueue_,a,o)}function Fr(e,t){qr(e,"connected",t),!1===t&&function(e){Wr(e,"onDisconnectEvents");const t=Mr(e),n=Ci();bi(e.onDisconnect_,pn(),(i,s)=>{const r=or(i,s,e.serverSyncTree_,t);wi(n,i,r)});let i=[];bi(n,pn(),(t,n)=>{i=i.concat(Us(e.serverSyncTree_,t,n));const s=Qr(e,t);$r(e,s)}),e.onDisconnect_=Ci(),xr(e.eventQueue_,pn(),i)}(e)}function qr(e,t,n){const i=new dn("/.info/"+t),s=ri(n);e.infoData_.updateSnapshot(i,s);const r=Us(e.infoSyncTree_,i,s);xr(e.eventQueue_,i,r)}function jr(e){return e.nextWriteId_++}function Ur(e,t,n){let i;i=".info"===_n(t._path)?Ws(e.infoSyncTree_,t,n):Ws(e.serverSyncTree_,t,n),Pr(e.eventQueue_,t._path,i)}function Wr(e,...t){let n="";e.persistentConnection_&&(n=e.persistentConnection_.id+":"),bt(n,...t)}function Br(e,t,n,i){t&&jt(()=>{if("ok"===n)t(null);else{const e=(n||"error").toUpperCase();let s=e;i&&(s+=": "+i);const r=new Error(s);r.code=e,t(r)}})}function Hr(e,t,n){return zs(e.serverSyncTree_,t,n)||ii.EMPTY_NODE}function zr(e,t=e.transactionQueueTree_){if(t||Gr(e,t),ur(t)){const n=Yr(e,t);c(n.length>0,"Sending zero length transaction queue"),n.every(e=>0===e.status)&&function(e,t,n){const i=n.map(e=>e.currentWriteId),s=Hr(e,t,i);let r=s;const o=s.hash();for(let e=0;e<n.length;e++){const i=n[e];c(0===i.status,"tryToSendTransactionQueue_: items in queue should all be run."),i.status=1,i.retryCount++;const s=bn(t,i.path);r=r.updateChild(s,i.currentOutputSnapshotRaw)}const a=r.val(!0),l=t;e.server_.put(l.toString(),a,i=>{Wr(e,"transaction put response",{path:l.toString(),status:i});let s=[];if("ok"===i){const i=[];for(let t=0;t<n.length;t++)n[t].status=2,s=s.concat(js(e.serverSyncTree_,n[t].currentWriteId)),n[t].onComplete&&i.push(()=>n[t].onComplete(null,!0,n[t].currentOutputSnapshotResolved)),n[t].unwatcher();Gr(e,hr(e.transactionQueueTree_,t)),zr(e,e.transactionQueueTree_),xr(e.eventQueue_,t,s);for(let e=0;e<i.length;e++)jt(i[e])}else{if("datastale"===i)for(let e=0;e<n.length;e++)3===n[e].status?n[e].status=4:n[e].status=0;else{St("transaction at "+l.toString()+" failed: "+i);for(let e=0;e<n.length;e++)n[e].status=4,n[e].abortReason=i}$r(e,t)}},o)}(e,gr(t),n)}else pr(t)&&_r(t,t=>{zr(e,t)})}function $r(e,t){const n=Vr(e,t),i=gr(n);return function(e,t,n){if(0===t.length)return;const i=[];let s=[];const r=t.filter(e=>0===e.status).map(e=>e.currentWriteId);for(let o=0;o<t.length;o++){const a=t[o],l=bn(n,a.path);let h,u=!1;if(c(null!==l,"rerunTransactionsUnderNode_: relativePath should not be null."),4===a.status)u=!0,h=a.abortReason,s=s.concat(js(e.serverSyncTree_,a.currentWriteId,!0));else if(0===a.status)if(a.retryCount>=25)u=!0,h="maxretry",s=s.concat(js(e.serverSyncTree_,a.currentWriteId,!0));else{const n=Hr(e,a.path,r);a.currentInputSnapshot=n;const i=t[o].update(n.val());if(void 0!==i){Tr("transaction failed: Data returned ",i,a.path);let t=ri(i);"object"==typeof i&&null!=i&&P(i,".priority")||(t=t.updatePriority(n.getPriority()));const o=a.currentWriteId,c=Mr(e),l=ar(t,n,c);a.currentOutputSnapshotRaw=t,a.currentOutputSnapshotResolved=l,a.currentWriteId=jr(e),r.splice(r.indexOf(o),1),s=s.concat(qs(e.serverSyncTree_,a.path,l,a.currentWriteId,a.applyLocally)),s=s.concat(js(e.serverSyncTree_,o,!0))}else u=!0,h="nodata",s=s.concat(js(e.serverSyncTree_,a.currentWriteId,!0))}xr(e.eventQueue_,n,s),s=[],u&&(t[o].status=2,function(e){setTimeout(e,Math.floor(0))}(t[o].unwatcher),t[o].onComplete&&("nodata"===h?i.push(()=>t[o].onComplete(null,!1,t[o].currentInputSnapshot)):i.push(()=>t[o].onComplete(new Error(h),!1,null))))}Gr(e,e.transactionQueueTree_);for(let e=0;e<i.length;e++)jt(i[e]);zr(e,e.transactionQueueTree_)}(e,Yr(e,n),i),i}function Vr(e,t){let n,i=e.transactionQueueTree_;for(n=_n(t);null!==n&&void 0===ur(i);)i=hr(i,n),n=_n(t=gn(t));return i}function Yr(e,t){const n=[];return Kr(e,t,n),n.sort((e,t)=>
2e.order-t.order),n}function Kr(e,t,n){const i=ur(t);if(i)for(let e=0;e<i.length;e++)n.push(i[e]);_r(t,t=>{Kr(e,t,n)})}function Gr(e,t){const n=ur(t);if(n){let e=0;for(let t=0;t<n.length;t++)2!==n[t].status&&(n[e]=n[t],e++);n.length=e,dr(t,n.length>0?n:void 0)}_r(t,t=>{Gr(e,t)})}function Qr(e,t){const n=gr(Vr(e,t)),i=hr(e.transactionQueueTree_,t);return function(e,t){let n=e.parent;for(;null!==n;){if(t(n))return!0;n=n.parent}}(i,t=>{Jr(e,t)}),Jr(e,i),fr(i,t=>{Jr(e,t)}),n}function Jr(e,t){const n=ur(t);if(n){const i=[];let s=[],r=-1;for(let t=0;t<n.length;t++)3===n[t].status||(1===n[t].status?(c(r===t-1,"All SENT items should be at beginning of queue."),r=t,n[t].status=3,n[t].abortReason="set"):(c(0===n[t].status,"Unexpected transaction status in abort"),n[t].unwatcher(),s=s.concat(js(e.serverSyncTree_,n[t].currentWriteId,!0)),n[t].onComplete&&i.push(n[t].onComplete.bind(null,new Error("set"),!1,null))));-1===r?dr(t,void 0):n.length=r+1,xr(e.eventQueue_,gr(t),s);for(let e=0;e<i.length;e++)jt(i[e])}}const Xr=function(e,t){const n=Zr(e),i=n.namespace;"firebase.com"===n.domain&&Et(n.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),i&&"undefined"!==i||"localhost"===n.domain||Et("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),n.secure||"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&St("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().");const s="ws"===n.scheme||"wss"===n.scheme;return{repoInfo:new Kt(n.host,n.secure,i,s,t,"",i!==n.subdomain),path:new dn(n.pathString)}},Zr=function(e){let t="",n="",i="",s="",r="",o=!0,a="https",c=443;if("string"==typeof e){let l=e.indexOf("//");l>=0&&(a=e.substring(0,l-1),e=e.substring(l+2));let h=e.indexOf("/");-1===h&&(h=e.length);let u=e.indexOf("?");-1===u&&(u=e.length),t=e.substring(0,Math.min(h,u)),h<u&&(s=function(e){let t="";const n=e.split("/");for(let e=0;e<n.length;e++)if(n[e].length>0){let i=n[e];try{i=decodeURIComponent(i.replace(/\+/g," "))}catch(e){}t+="/"+i}return t}(e.substring(h,u)));const d=function(e){const t={};"?"===e.charAt(0)&&(e=e.substring(1));for(const n of e.split("&")){if(0===n.length)continue;const i=n.split("=");2===i.length?t[decodeURIComponent(i[0])]=decodeURIComponent(i[1]):St(`Invalid query segment '${n}' in query '${e}'`)}return t}(e.substring(Math.min(e.length,u)));l=t.indexOf(":"),l>=0?(o="https"===a||"wss"===a,c=parseInt(t.substring(l+1),10)):l=t.length;const p=t.slice(0,l);if("localhost"===p.toLowerCase())n="localhost";else if(p.split(".").length<=2)n=p;else{const e=t.indexOf(".");i=t.substring(0,e).toLowerCase(),n=t.substring(e+1),r=i}"ns"in d&&(r=d.ns)}return{host:t,port:c,domain:n,subdomain:i,secure:o,scheme:a,pathString:s,namespace:r}},eo="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",to=function(){let e=0;const t=[];return function(n){const i=n===e;let s;e=n;const r=new Array(8);for(s=7;s>=0;s--)r[s]=eo.charAt(n%64),n=Math.floor(n/64);c(0===n,"Cannot push at time == 0");let o=r.join("");if(i){for(s=11;s>=0&&63===t[s];s--)t[s]=0;t[s]++}else for(s=0;s<12;s++)t[s]=Math.floor(64*Math.random());for(s=0;s<12;s++)o+=eo.charAt(t[s]);return c(20===o.length,"nextPushId: Length should be 20."),o}}();class no{constructor(e,t,n,i){this.eventType=e,this.eventRegistration=t,this.snapshot=n,this.prevName=i}getPath(){const e=this.snapshot.ref;return"value"===this.eventType?e._path:e.parent._path}getEventType(){return this.eventType}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.getPath().toString()+":"+this.eventType+":"+k(this.snapshot.exportVal())}}class io{constructor(e,t,n){this.eventRegistration=e,this.error=t,this.path=n}getPath(){return this.path}getEventType(){return"cancel"}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.path.toString()+":cancel"}}class so{constructor(e,t){this.snapshotCallback=e,this.cancelCallback=t}onValue(e,t){this.snapshotCallback.call(null,e,t)}onCancel(e){return c(this.hasCancelCallback,"Raising a cancel event on a listener with no cancel callback"),this.cancelCallback.call(null,e)}get hasCancelCallback(){return!!this.cancelCallback}matches(e){return this.snapshotCallback===e.snapshotCallback||void 0!==this.snapshotCallback.userCallback&&this.snapshotCallback.userCallback===e.snapshotCallback.userCallback&&this.snapshotCallback.context===e.snapshotCallback.context}}class ro{constructor(e,t,n,i){this._repo=e,this._path=t,this._queryParams=n,this._orderByCalled=i}get key(){return wn(this._path)?null:mn(this._path)}get ref(){return new oo(this._repo,this._path)}get _queryIdentifier(){const e=mi(this._queryParams),t=At(e);return"{}"===t?"default":t}get _queryObject(){return mi(this._queryParams)}isEqual(e){if(!((e=q(e))instanceof ro))return!1;const t=this._repo===e._repo,n=Tn(this._path,e._path),i=this._queryIdentifier===e._queryIdentifier;return t&&n&&i}toJSON(){return this.toString()}toString(){return this._repo.toString()+function(e){let t="";for(let n=e.pieceNum_;n<e.pieces_.length;n++)""!==e.pieces_[n]&&(t+="/"+encodeURIComponent(String(e.pieces_[n])));return t||"/"}(this._path)}}class oo extends ro{constructor(e,t){super(e,t,new fi,!1)}get parent(){const e=vn(this._path);return null===e?null:new oo(this._repo,e)}get root(){let e=this;for(;null!==e.parent;)e=e.parent;return e}}class ao{constructor(e,t,n){this._node=e,this.ref=t,this._index=n}get priority(){return this._node.getPriority().val()}get key(){return this.ref.key}get size(){return this._node.numChildren()}child(e){const t=new dn(e),n=co(this.ref,e);return new ao(this._node.getChild(t),n,Gn)}exists(){return!this._node.isEmpty()}exportVal(){return this._node.val(!0)}forEach(e){return!this._node.isLeafNode()&&!!this._node.forEachChild(this._index,(t,n)=>e(new ao(n,co(this.ref,t),Gn)))}hasChild(e){const t=new dn(e);return!this._node.getChild(t).isEmpty()}hasChildren(){return!this._node.isLeafNode()&&!this._node.isEmpty()}toJSON(){return this.exportVal()}val(){return this._node.val()}}function co(e,t){var n;return null===_n((e=q(e))._path)?((n=t)&&(n=n.replace(/^\/*\.info(\/|$)/,"/")),Er("child","path",n,!1)):Er("child","path",t,!1),new oo(e._repo,Cn(e._path,t))}function lo(e,t){e=q(e),Sr("push",e._path),Ir("push",t,e._path,!0);const n=Or(e._repo),i=to(n),s=co(e,i),r=co(e,i);let o;return o=null!=t?ho(r,t).then(()=>r):Promise.resolve(r),s.then=o.then.bind(o),s.catch=o.then.bind(o,void 0),s}function ho(e,t){e=q(e),Sr("set",e._path),Ir("set",t,e._path,!1);const n=new w;return function(e,t,n,i,s){Wr(e,"set",{path:t.toString(),value:n,priority:null});const r=Mr(e),o=ri(n,null),a=zs(e.serverSyncTree_,t),c=ar(o,a,r),l=jr(e),h=qs(e.serverSyncTree_,t,c,l,!0);Nr(e.eventQueue_,h),e.server_.put(t.toString(),o.val(!0),(n,i)=>{const r="ok"===n;r||St("set at "+t+" failed: "+n);const o=js(e.serverSyncTree_,l,!r);xr(e.eventQueue_,t,o),Br(0,s,n,i)});const u=Qr(e,t);$r(e,u),xr(e.eventQueue_,u,[])}(e._repo,e._path,t,0,n.wrapCallback(()=>{})),n.promise}function uo(e,t){!function(e,t,n,i){if(i&&void 0===t)return;const s=L(e,"values");if(!t||"object"!=typeof t||Array.isArray(t))throw new Error(s+" must be an object c
2ontaining the children to replace.");const r=[];Mt(t,(e,t)=>{const i=new dn(e);if(Tr(s,t,Cn(n,i)),".priority"===mn(i)&&!(null===(o=t)||"string"==typeof o||"number"==typeof o&&!kt(o)||o&&"object"==typeof o&&P(o,".sv")))throw new Error(s+"contains an invalid value for '"+i.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");var o;r.push(i)}),function(e,t){let n,i;for(n=0;n<t.length;n++){i=t[n];const s=yn(i);for(let t=0;t<s.length;t++)if(".priority"===s[t]&&t===s.length-1);else if(!wr(s[t]))throw new Error(e+"contains an invalid key ("+s[t]+") in path "+i.toString()+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"')}t.sort(In);let s=null;for(n=0;n<t.length;n++){if(i=t[n],null!==s&&En(s,i))throw new Error(e+"contains a path "+s.toString()+" that is ancestor of another path "+i.toString());s=i}}(s,r)}("update",t,e._path,!1);const n=new w;return function(e,t,n,i){Wr(e,"update",{path:t.toString(),value:n});let s=!0;const r=Mr(e),o={};if(Mt(n,(n,i)=>{s=!1,o[n]=or(Cn(t,n),ri(i),e.serverSyncTree_,r)}),s)bt("update() called with empty data.  Don't do anything."),Br(0,i,"ok",void 0);else{const s=jr(e),r=function(e,t,n,i){!function(e,t,n,i){c(i>e.lastWriteId,"Stacking an older merge on top of newer ones"),e.allWrites.push({path:t,children:n,writeId:i,visible:!0}),e.visibleWrites=Hi(e.visibleWrites,t,n),e.lastWriteId=i}(e.pendingWriteTree_,t,n,i);const s=Ui.fromObject(n);return $s(e,new xi({fromUser:!0,fromServer:!1,queryId:null,tagged:!1},t,s))}(e.serverSyncTree_,t,o,s);Nr(e.eventQueue_,r),e.server_.merge(t.toString(),n,(n,r)=>{const o="ok"===n;o||St("update at "+t+" failed: "+n);const a=js(e.serverSyncTree_,s,!o),c=a.length>0?$r(e,t):t;xr(e.eventQueue_,c,a),Br(0,i,n,r)}),Mt(n,n=>{const i=Qr(e,Cn(t,n));$r(e,i)}),xr(e.eventQueue_,t,[])}}(e._repo,e._path,t,n.wrapCallback(()=>{})),n.promise}function po(e){e=q(e);const t=new so(()=>{}),n=new _o(t);return function(e,t,n){const i=function(e,t){const n=t._path;let i=null;e.syncPointTree_.foreachOnPath(n,(e,t)=>{const s=bn(e,n);i=i||Rs(t,s)});let s=e.syncPointTree_.get(n);s?i=i||Rs(s,pn()):(s=new ks,e.syncPointTree_=e.syncPointTree_.set(n,s));const r=null!=i,o=r?new Ri(i,!0,!1):null;return Fi(Ps(s,t,Xi(e.pendingWriteTree_,t._path),r?o.getNode():ii.EMPTY_NODE,r).viewCache_)}(e.serverSyncTree_,t);return null!=i?Promise.resolve(i):e.server_.get(t).then(i=>{const s=ri(i).withIndex(t._queryParams.getIndex());let r;if(Hs(e.serverSyncTree_,t,n,!0),t._queryParams.loadsAllData())r=Us(e.serverSyncTree_,t._path,s);else{const n=Gs(e.serverSyncTree_,t);r=Bs(e.serverSyncTree_,t._path,s,n)}return xr(e.eventQueue_,t._path,r),Ws(e.serverSyncTree_,t,n,null,!0),s},n=>(Wr(e,"get for query "+k(t)+" failed: "+n),Promise.reject(new Error(n))))}(e._repo,e,n).then(t=>new ao(t,new oo(e._repo,e._path),e._queryParams.getIndex()))}class _o{constructor(e){this.callbackContext=e}respondsTo(e){return"value"===e}createEvent(e,t){const n=t._queryParams.getIndex();return new no("value",this,new ao(e.snapshotNode,new oo(t._repo,t._path),n))}getEventRunner(e){return"cancel"===e.getEventType()?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,null)}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new io(this,e,t):null}matches(e){return e instanceof _o&&(!e.callbackContext||!this.callbackContext||e.callbackContext.matches(this.callbackContext))}hasAnyCallback(){return null!==this.callbackContext}}!function(e){c(!Es,"__referenceConstructor has already been defined"),Es=e}(oo),function(e){c(!Ss,"__referenceConstructor has already been defined"),Ss=e}(oo);const fo={};class go{constructor(e,t){this._repoInternal=e,this.app=t,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(function(e,t,n){if(e.stats_=Zt(e.repoInfo_),e.forceRestClient_||("object"==typeof window&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)>=0)e.server_=new yi(e.repoInfo_,(t,n,i,s)=>{Lr(e,t,n,i,s)},e.authTokenProvider_,e.appCheckProvider_),setTimeout(()=>Fr(e,!0),0);else{if(null!=n){if("object"!=typeof n)throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{k(n)}catch(e){throw new Error("Invalid authOverride provided: "+e)}}e.persistentConnection_=new Rn(e.repoInfo_,t,(t,n,i,s)=>{Lr(e,t,n,i,s)},t=>{Fr(e,t)},t=>{!function(e,t){Mt(t,(t,n)=>{qr(e,t,n)})}(e,t)},e.authTokenProvider_,e.appCheckProvider_,n),e.server_=e.persistentConnection_}e.authTokenProvider_.addTokenChangeListener(t=>{e.server_.refreshAuthToken(t)}),e.appCheckProvider_.addTokenChangeListener(t=>{e.server_.refreshAppCheckToken(t.token)}),e.statsReporter_=function(t){const n=t.toString();return Xt[n]||(Xt[n]=new Ti(e.stats_,e.server_)),Xt[n]}(e.repoInfo_),e.infoData_=new vi,e.infoSyncTree_=new Fs({startListening:(t,n,i,s)=>{let r=[];const o=e.infoData_.getNode(t._path);return o.isEmpty()||(r=Us(e.infoSyncTree_,t._path,o),setTimeout(()=>{s("ok")},0)),r},stopListening:()=>{}}),qr(e,"connected",!1),e.serverSyncTree_=new Fs({startListening:(t,n,i,s)=>(e.server_.listen(t,i,n,(n,i)=>{const r=s(n,i);xr(e.eventQueue_,t._path,r)}),[]),stopListening:(t,n)=>{e.server_.unlisten(t,n)}})}(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new oo(this._repo,pn())),this._rootInternal}_delete(){return null!==this._rootInternal&&(function(e,t){const n=fo[t];n&&n[e.key]===e||Et(`Database ${t}(${e.repoInfo_}) has already been deleted.`),function(e){e.persistentConnection_&&e.persistentConnection_.interrupt("repo_interrupt")}(e),delete n[e.key]}(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(e){null===this._rootInternal&&Et("Cannot call "+e+" on a deleted database.")}}Rn.prototype.simpleListen=function(e,t){this.sendRequest("q",{p:e},t)},Rn.prototype.echo=function(e,t){this.sendRequest("echo",{d:e},t)},ht="12.12.0",Ke(new U("database",(e,{instanceIdentifier:t})=>function(e,t,n,i,s){let r=i||e.options.databaseURL;void 0===r&&(e.options.projectId||Et("Can't determine Firebase Database URL. Be sure to include  a Project ID when calling firebase.initializeApp()."),bt("Using default host for project ",e.options.projectId),r=`${e.o
2ptions.projectId}-default-rtdb.firebaseio.com`);let o,a,c=Xr(r,s),l=c.repoInfo;"undefined"!=typeof process&&(a="production".FIREBASE_DATABASE_EMULATOR_HOST),a?(o=!0,r=`http://${a}?ns=${l.namespace}`,c=Xr(r,s),l=c.repoInfo):o=!c.repoInfo.secure;const h=s&&o?new Ht(Ht.OWNER):new Bt(e.name,e.options,t);(function(e,t){const n=t.path.toString();if("string"!=typeof t.repoInfo.host||0===t.repoInfo.host.length||!wr(t.repoInfo.namespace)&&"localhost"!==t.repoInfo.host.split(":")[0]||0!==n.length&&!function(e){return e&&(e=e.replace(/^\/*\.info(\/|$)/,"/")),br(e)}(n))throw new Error(L("Invalid Firebase Database URL","url")+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')})(0,c),wn(c.path)||Et("Database URL must point to the root of a Firebase Database (not including a child path).");const u=function(e,t,n,i){let s=fo[t.name];s||(s={},fo[t.name]=s);let r=s[e.toURLString()];return r&&Et("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),r=new Ar(e,!1,n,i),s[e.toURLString()]=r,r}(l,e,h,new Wt(e,n));return new go(u,e)}(e.getProvider("app").getImmediate(),e.getProvider("auth-internal"),e.getProvider("app-check-internal"),t),"PUBLIC").setMultipleInstances(!0)),Xe(ct,lt,void 0),Xe(ct,lt,"esm2020");const mo=window.FIREBASE_ENV;var yo=class{constructor(e,t,n){this.articleID=e,this.writeDispatch=t,this.dispatch=n,this.initialize()}initialize(){return new Promise(e=>{0===Array.from(ze.values()).length&&Je({apiKey:{issimodev:"AIzaSyBPgb6ClcJI6VyB8d2jcixDzJ5D2aFLP9w",issimouat:"AIzaSyAOFI_qhGx9m0D8-_lmn_eK1GUQzLQpYtQ"}[mo],databaseURL:`https://${mo}.firebaseio.com`});const t=function(e=function(e=Be){const t=ze.get(e);if(!t&&e===Be&&C())return Je();if(!t)throw Ge.create("no-app",{appName:e});return t}(),t){const n=function(e){const t=e.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),e.container.getProvider("database")}(e).getImmediate({identifier:t});if(!n._instanceStarted){const e=(()=>{const e=(t="database",v()?.emulatorHosts?.[t]);var t;if(!e)return;const n=e.lastIndexOf(":");if(n<=0||n+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const i=parseInt(e.substring(n+1),10);return"["===e[0]?[e.substring(1,n-1),i]:[e.substring(0,n),i]})();e&&function(e,t,n,i={}){(e=q(e))._checkNotDeleted("useEmulator");const s=`${t}:${n}`,r=e._repoInternal;if(e._instanceStarted){if(s===e._repoInternal.repoInfo_.host&&A(i,r.repoInfo_.emulatorOptions))return;Et("connectDatabaseEmulator() cannot initialize or alter the emulator configuration after the database instance has started.")}let o;if(r.repoInfo_.nodeAdmin)i.mockUserToken&&Et('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),o=new Ht(Ht.OWNER);else if(i.mockUserToken){const t="string"==typeof i.mockUserToken?i.mockUserToken:function(e,t){if(e.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const n=t||"demo-project",i=e.iat||0,s=e.sub||e.user_id;if(!s)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const r={iss:`https://securetoken.google.com/${n}`,aud:n,iat:i,exp:i+3600,auth_time:i,sub:s,user_id:s,firebase:{sign_in_provider:"custom",identities:{}},...e};return[_(JSON.stringify({alg:"none",type:"JWT"})),_(JSON.stringify(r)),""].join(".")}(i.mockUserToken,e.app.options.projectId);o=new Ht(t)}j(t)&&async function(e){(await fetch(e,{credentials:"include"})).ok}(t),function(e,t,n,i){const s=t.lastIndexOf(":"),r=j(t.substring(0,s));e.repoInfo_=new Kt(t,r,e.repoInfo_.namespace,e.repoInfo_.webSocketOnly,e.repoInfo_.nodeAdmin,e.repoInfo_.persistenceKey,e.repoInfo_.includeNamespaceInQueryParams,!0,n),i&&(e.authTokenProvider_=i)}(r,s,i,o)}(n,...e)}return n}();var n,i;this.articleRef=(n=t,i=`/articles/${this.articleID}`,(n=q(n))._checkNotDeleted("ref"),void 0!==i?co(n._root,i):n._root),this.layoutRef=co(this.articleRef,"layout"),this.sectionsRef=co(this.articleRef,"sections"),this.cardsRef=co(this.articleRef,"cards"),e(this)})}subscribe(e,t){return console.log("Subscribe:"),console.log("subscription:"),console.log(e),function(e,t,n,i,s){let r;if("object"==typeof i&&(r=void 0,s=i),"function"==typeof i&&(r=i),s&&s.onlyOnce){const t=n,i=(n,i)=>{Ur(e._repo,e,a),t(n,i)};i.userCallback=n.userCallback,i.context=n.context,n=i}const o=new so(n,r||void 0),a=new _o(o);return function(e,t,n){let i;i=".info"===_n(t._path)?Hs(e.infoSyncTree_,t,n):Hs(e.serverSyncTree_,t,n),Pr(e.eventQueue_,t._path,i)}(e._repo,e,a),()=>Ur(e._repo,e,a)}(t?co(this.cardsRef,t):this.sectionsRef,0,e,n,i);var n,i}addSection(e,t){const n={type:e};po(this.sectionsRef).then(e=>{const i=e.val(),s=lo(this.sectionsRef,n).key,r=this.toSectionsArray(i);let o=0;r.forEach((e,n)=>{e.sectionId===t&&(o=n)}),r.splice(o+1,0,{section:n,sectionId:s}),r.map((e,t)=>{e.section.order!==t&&uo(co(this.sectionsRef,e.sectionId),{order:t})}),this.writeDispatch({type:"EDIT_SELECTION_UPDATED",selection:{type:"section",sectionId:s}})})}toSectionsArray(e){return null!==e&&e?Object.keys(e).map(t=>{const n=e[t];return{section:n,order:n.order||n.priority||0,sectionId:t}}
2).sort((e,t)=>e.order-t.order):[]}updateSectionOrder(e,t){po(this.sectionsRef).then(n=>{const i=n.val(),s=this.toSectionsArray(i);let r=-1;s.forEach((t,n)=>{t.sectionId===e&&(r=n)}),r>-1&&s.splice(t,0,s.splice(r,1)[0]),s.map((e,t)=>{e.section.order!==t&&uo(co(this.sectionsRef,e.sectionId),{order:t})})})}updateSection(e,t,n){const i=e+"/"+t.replace(/\./g,"/");return ho(co(this.sectionsRef,i),n)}deleteSection(e){ho(co(this.sectionsRef,e),null),po(this.sectionsRef).then(e=>{const t=e.val();this.toSectionsArray(t).map((e,t)=>{e.section.order!==t&&uo(co(this.sectionsRef,e.sectionId),{order:t})})})}addCard(e,t){console.log("Add Card"),console.log(e),po(co(this.sectionsRef,e)).then(n=>{const i=n.val();console.log(i),console.log(i.cards);const s=a.objToArray(i.cards),r=lo(this.cardsRef,t).key,o=[...s,Number(r)||r],c=a.arrayToObj(o);ho(co(co(this.sectionsRef,e),"cards"),c),this.writeDispatch({type:"EDIT_SELECTION_UPDATED",selection:{type:"card",cardID:r}})})}updateCardNested(e,t,n){const i=e+"/"+t.replace(/\./g,"/");return ho(co(this.cardsRef,i),n)}deleteCard(e,t){e&&t?(uo(this.cardsRef,{[e]:null}),po(co(this.sectionsRef,t)).then(n=>{const i=n.val();console.log(i),console.log(i.cards);const s=a.objToArray(i.cards).filter(t=>t!==e),r=a.arrayToObj(s);ho(co(co(this.sectionsRef,t),"cards"),r)})):console.log("Need cardID and sectionId")}moveCardOne(e,t,n){t&&e&&po(co(this.sectionsRef,t)).then(i=>{const{cards:s={}}=i.val();console.log(s);const r=s[e],o=a.objToArray(s),c=n?r-1:r+1;console.log(`${r} -> ${c}`),o.splice(c,0,o.splice(r,1)[0]),console.log(o),o.map((e,n)=>{s[e]!==n&&ho(co(co(co(this.sectionsRef,t),"cards"),e.toString()),n)})})}copyCard(e,t){t&&e&&po(co(this.sectionsRef,t)).then(n=>{const{cards:i={}}=n.val(),s=i[e];po(co(this.cardsRef,e)).then(e=>{const n=e.val();this.addCard(t,n,s)})})}loadNewLayoutFromTemplate(){ho(co(this.sectionsRef,`${window.pushId()}`),{type:"text"})}saveLayout(){return new Promise(e=>{r.d.loadCard(Number(this.articleID)).then(t=>{po(this.articleRef).then(n=>{const i=n.val();if(!i)return e();const{sections:s,cards:r}=i,a=Object.keys(s).map(n=>{const i=s[n];return"text"===i.type?this.saveTextSectionCards(n,i,r,t.publicationID):e()});Promise.all(a).then(()=>{console.log("All promises finished"),po(this.articleRef).then(e=>{const t=e.val();console.log(t);const n={articleID:Number(this.articleID),sections:t.sections};t?this.dispatch((0,o.Q)(this.articleID,n)):console.log("No layout"),console.log("End of save")})})})})})}saveTextSectionCards(e,t,n,r){return console.log("Text section"),console.log(t),console.log(n),console.log("PublicationID: "+r),new Promise(o=>{const a=Object.keys(t.cards||{}).map(a=>{const c=n[a];if(Number(a)){const e=n[a],t={...e,articleID:this.articleID,publicationID:r},i=!0,c=!0;return this.dispatch((0,s.A)(e.cardID,t,i,c)),o()}if(console.log("Not saved: "+a),console.log("Creating card:"),console.log(c),c){const n={...c,articleID:this.articleID,publicationID:r};return this.dispatch((0,i.A)(n)).then(n=>{console.log("Created card:"),console.log(n);const i=t.cards[a]||0;return ho(co(co(co(this.sectionsRef,e),"cards"),a),null),ho(co(co(co(this.sectionsRef,e),"cards"),n.cardID),i),uo(this.cardsRef,{[n.cardID]:n}),o()})}return o()});console.log(a),0===a.length?o():Promise.all(a)})}createLayoutFromTemplate(e){switch(e){case"newspaper":{ho(co(co(this.articleRef,"sections"),`${window.pushId()}`),{type:"title",title:"New Article",order:0});const e=window.pushId();ho(co(this.cardsRef,e),{type:"text"}),ho(co(co(this.articleRef,"sections"),`${window.pushId()}`),{type:"text",cards:{[e]:0},order:1})}break;case"magazine":{ho(co(co(this.articleRef,"sections"),`${window.pushId()}`),{type:"cover",title:"New Article",order:0});const e=window.pushId();ho(co(this.cardsRef,e),{type:"text"}),ho(co(co(this.articleRef,"sections"),`${window.pushId()}`),{type:"text",cards:{[e]:0},order:1})}}}off(){console.log("off() called - in Firebase v10, use the unsubscribe function returned from onValue")}}}}]);

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.