@iebh/tera-fy 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,49 +1,49 @@
1
- var FP=Object.create;var Xa=Object.defineProperty;var UP=Object.getOwnPropertyDescriptor;var BP=Object.getOwnPropertyNames;var jP=Object.getPrototypeOf,$P=Object.prototype.hasOwnProperty;var qP=(n,e,t)=>e in n?Xa(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var zP=(n,e)=>()=>(n&&(e=n(n=0)),e);var cn=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),GP=(n,e)=>{for(var t in e)Xa(n,t,{get:e[t],enumerable:!0})},$y=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of BP(e))!$P.call(n,s)&&s!==t&&Xa(n,s,{get:()=>e[s],enumerable:!(r=UP(e,s))||r.enumerable});return n};var Cd=(n,e,t)=>(t=n!=null?FP(jP(n)):{},$y(e||!n||!n.__esModule?Xa(t,"default",{value:n,enumerable:!0}):t,n)),KP=n=>$y(Xa({},"__esModule",{value:!0}),n);var jt=(n,e,t)=>qP(n,typeof e!="symbol"?e+"":e,t);var gs={};GP(gs,{Headers:()=>bg,Request:()=>OF,Response:()=>kF,default:()=>wg,fetch:()=>DF});var CF,ea,DF,wg,bg,OF,kF,Ei=zP(()=>{"use strict";CF=function(){if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof global!="undefined")return global;throw new Error("unable to locate global object")},ea=CF(),DF=ea.fetch,wg=ea.fetch.bind(ea),bg=ea.Headers,OF=ea.Request,kF=ea.Response});var Ig=cn(Eg=>{"use strict";Object.defineProperty(Eg,"__esModule",{value:!0});var Tg=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};Eg.default=Tg});var Ag=cn(ku=>{"use strict";var iE=ku&&ku.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(ku,"__esModule",{value:!0});var VF=iE((Ei(),KP(gs))),LF=iE(Ig()),xg=class{constructor(e){this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=e.headers,this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=e.shouldThrowOnError,this.signal=e.signal,this.isMaybeSingle=e.isMaybeSingle,e.fetch?this.fetch=e.fetch:typeof fetch=="undefined"?this.fetch=VF.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=Object.assign({},this.headers),this.headers[e]=t,this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),this.method!=="GET"&&this.method!=="HEAD"&&(this.headers["Content-Type"]="application/json");let r=this.fetch,s=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async a=>{var c,h,f;let m=null,_=null,E=null,I=a.status,k=a.statusText;if(a.ok){if(this.method!=="HEAD"){let J=await a.text();J===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?_=J:_=JSON.parse(J))}let G=(c=this.headers.Prefer)===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),j=(h=a.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");G&&j&&j.length>1&&(E=parseInt(j[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(_)&&(_.length>1?(m={code:"PGRST116",details:`Results contain ${_.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},_=null,E=null,I=406,k="Not Acceptable"):_.length===1?_=_[0]:_=null)}else{let G=await a.text();try{m=JSON.parse(G),Array.isArray(m)&&a.status===404&&(_=[],m=null,I=200,k="OK")}catch{a.status===404&&G===""?(I=204,k="No Content"):m={message:G}}if(m&&this.isMaybeSingle&&(!((f=m==null?void 0:m.details)===null||f===void 0)&&f.includes("0 rows"))&&(m=null,I=200,k="OK"),m&&this.shouldThrowOnError)throw new LF.default(m)}return{error:m,data:_,count:E,status:I,statusText:k}});return this.shouldThrowOnError||(s=s.catch(a=>{var c,h,f;return{error:{message:`${(c=a==null?void 0:a.name)!==null&&c!==void 0?c:"FetchError"}: ${a==null?void 0:a.message}`,details:`${(h=a==null?void 0:a.stack)!==null&&h!==void 0?h:""}`,hint:"",code:`${(f=a==null?void 0:a.code)!==null&&f!==void 0?f:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}};ku.default=xg});var Rg=cn(Nu=>{"use strict";var MF=Nu&&Nu.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(Nu,"__esModule",{value:!0});var FF=MF(Ag()),Sg=class extends FF.default{select(e){let t=!1,r=(e!=null?e:"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",r),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:s,referencedTable:a=s}={}){let c=a?`${a}.order`:"order",h=this.url.searchParams.get(c);return this.url.searchParams.set(c,`${h?`${h},`:""}${e}.${t?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:r=t}={}){let s=typeof r=="undefined"?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:r,referencedTable:s=r}={}){let a=typeof s=="undefined"?"offset":`${s}.offset`,c=typeof s=="undefined"?"limit":`${s}.limit`;return this.url.searchParams.set(a,`${e}`),this.url.searchParams.set(c,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return this.method==="GET"?this.headers.Accept="application/json":this.headers.Accept="application/vnd.pgrst.object+json",this.isMaybeSingle=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:s=!1,wal:a=!1,format:c="text"}={}){var h;let f=[e?"analyze":null,t?"verbose":null,r?"settings":null,s?"buffers":null,a?"wal":null].filter(Boolean).join("|"),m=(h=this.headers.Accept)!==null&&h!==void 0?h:"application/json";return this.headers.Accept=`application/vnd.pgrst.plan+${c}; for="${m}"; options=${f};`,c==="json"?this:this}rollback(){var e;return((e=this.headers.Prefer)!==null&&e!==void 0?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}};Nu.default=Sg});var ef=cn(Vu=>{"use strict";var UF=Vu&&Vu.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(Vu,"__esModule",{value:!0});var BF=UF(Rg()),Pg=class extends BF.default{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){let r=Array.from(new Set(t)).map(s=>typeof s=="string"&&new RegExp("[,()]").test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:s}={}){let a="";s==="plain"?a="pl":s==="phrase"?a="ph":s==="websearch"&&(a="w");let c=r===void 0?"":`(${r})`;return this.url.searchParams.append(e,`${a}fts${c}.${t}`),this}match(e){return Object.entries(e).forEach(([t,r])=>{this.url.searchParams.append(t,`eq.${r}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t,referencedTable:r=t}={}){let s=r?`${r}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}};Vu.default=Pg});var Dg=cn(Mu=>{"use strict";var jF=Mu&&Mu.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(Mu,"__esModule",{value:!0});var Lu=jF(ef()),Cg=class{constructor(e,{headers:t={},schema:r,fetch:s}){this.url=e,this.headers=t,this.schema=r,this.fetch=s}select(e,{head:t=!1,count:r}={}){let s=t?"HEAD":"GET",a=!1,c=(e!=null?e:"*").split("").map(h=>/\s/.test(h)&&!a?"":(h==='"'&&(a=!a),h)).join("");return this.url.searchParams.set("select",c),r&&(this.headers.Prefer=`count=${r}`),new Lu.default({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:t,defaultToNull:r=!0}={}){let s="POST",a=[];if(this.headers.Prefer&&a.push(this.headers.Prefer),t&&a.push(`count=${t}`),r||a.push("missing=default"),this.headers.Prefer=a.join(","),Array.isArray(e)){let c=e.reduce((h,f)=>h.concat(Object.keys(f)),[]);if(c.length>0){let h=[...new Set(c)].map(f=>`"${f}"`);this.url.searchParams.set("columns",h.join(","))}}return new Lu.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:s,defaultToNull:a=!0}={}){let c="POST",h=[`resolution=${r?"ignore":"merge"}-duplicates`];if(t!==void 0&&this.url.searchParams.set("on_conflict",t),this.headers.Prefer&&h.push(this.headers.Prefer),s&&h.push(`count=${s}`),a||h.push("missing=default"),this.headers.Prefer=h.join(","),Array.isArray(e)){let f=e.reduce((m,_)=>m.concat(Object.keys(_)),[]);if(f.length>0){let m=[...new Set(f)].map(_=>`"${_}"`);this.url.searchParams.set("columns",m.join(","))}}return new Lu.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}update(e,{count:t}={}){let r="PATCH",s=[];return this.headers.Prefer&&s.push(this.headers.Prefer),t&&s.push(`count=${t}`),this.headers.Prefer=s.join(","),new Lu.default({method:r,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}delete({count:e}={}){let t="DELETE",r=[];return e&&r.push(`count=${e}`),this.headers.Prefer&&r.unshift(this.headers.Prefer),this.headers.Prefer=r.join(","),new Lu.default({method:t,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}};Mu.default=Cg});var sE=cn(tf=>{"use strict";Object.defineProperty(tf,"__esModule",{value:!0});tf.version=void 0;tf.version="0.0.0-automated"});var oE=cn(nf=>{"use strict";Object.defineProperty(nf,"__esModule",{value:!0});nf.DEFAULT_HEADERS=void 0;var $F=sE();nf.DEFAULT_HEADERS={"X-Client-Info":`postgrest-js/${$F.version}`}});var uE=cn(Fu=>{"use strict";var aE=Fu&&Fu.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(Fu,"__esModule",{value:!0});var qF=aE(Dg()),zF=aE(ef()),GF=oE(),Og=class n{constructor(e,{headers:t={},schema:r,fetch:s}={}){this.url=e,this.headers=Object.assign(Object.assign({},GF.DEFAULT_HEADERS),t),this.schemaName=r,this.fetch=s}from(e){let t=new URL(`${this.url}/${e}`);return new qF.default(t,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new n(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:r=!1,get:s=!1,count:a}={}){let c,h=new URL(`${this.url}/rpc/${e}`),f;r||s?(c=r?"HEAD":"GET",Object.entries(t).filter(([_,E])=>E!==void 0).map(([_,E])=>[_,Array.isArray(E)?`{${E.join(",")}}`:`${E}`]).forEach(([_,E])=>{h.searchParams.append(_,E)})):(c="POST",f=t);let m=Object.assign({},this.headers);return a&&(m.Prefer=`count=${a}`),new zF.default({method:c,url:h,headers:m,schema:this.schemaName,body:f,fetch:this.fetch,allowEmpty:!1})}};Fu.default=Og});var mE=cn(vt=>{"use strict";var ta=vt&&vt.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(vt,"__esModule",{value:!0});vt.PostgrestError=vt.PostgrestBuilder=vt.PostgrestTransformBuilder=vt.PostgrestFilterBuilder=vt.PostgrestQueryBuilder=vt.PostgrestClient=void 0;var cE=ta(uE());vt.PostgrestClient=cE.default;var lE=ta(Dg());vt.PostgrestQueryBuilder=lE.default;var hE=ta(ef());vt.PostgrestFilterBuilder=hE.default;var fE=ta(Rg());vt.PostgrestTransformBuilder=fE.default;var dE=ta(Ag());vt.PostgrestBuilder=dE.default;var pE=ta(Ig());vt.PostgrestError=pE.default;vt.default={PostgrestClient:cE.default,PostgrestQueryBuilder:lE.default,PostgrestFilterBuilder:hE.default,PostgrestTransformBuilder:fE.default,PostgrestBuilder:dE.default,PostgrestError:pE.default}});var IE=cn((XK,EE)=>{"use strict";EE.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var aI=cn((ha,tc)=>{(function(){var n,e="4.17.21",t=200,r="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",a="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",h=500,f="__lodash_placeholder__",m=1,_=2,E=4,I=1,k=2,B=1,G=2,j=4,J=8,ee=16,ne=32,le=64,de=128,ie=256,C=512,A=30,R="...",D=800,V=16,M=1,S=2,pn=3,Kt=1/0,Cn=9007199254740991,Ai=17976931348623157e292,Dn=NaN,Nt=4294967295,sc=Nt-1,yf=Nt>>>1,On=[["ary",de],["bind",B],["bindKey",G],["curry",J],["curryRight",ee],["flip",C],["partial",ne],["partialRight",le],["rearg",ie]],Ge="[object Arguments]",Cs="[object Array]",Si="[object AsyncFunction]",Ri="[object Boolean]",mn="[object Date]",vf="[object DOMException]",Ds="[object Error]",rr="[object Function]",Pi="[object GeneratorFunction]",St="[object Map]",ir="[object Number]",da="[object Null]",Wt="[object Object]",pa="[object Promise]",oc="[object Proxy]",Ci="[object RegExp]",Vt="[object Set]",Lr="[object String]",Mr="[object Symbol]",ac="[object Undefined]",Di="[object WeakMap]",ma="[object WeakSet]",sr="[object ArrayBuffer]",kn="[object DataView]",nt="[object Float32Array]",at="[object Float64Array]",Fr="[object Int8Array]",Os="[object Int16Array]",ks="[object Int32Array]",ga="[object Uint8Array]",or="[object Uint8ClampedArray]",Ns="[object Uint16Array]",Vs="[object Uint32Array]",_a=/\b__p \+= '';/g,wf=/\b(__p \+=) '' \+/g,bf=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ls=/&(?:amp|lt|gt|quot|#39);/g,ya=/[&<>"']/g,uc=RegExp(Ls.source),Oi=RegExp(ya.source),va=/<%-([\s\S]+?)%>/g,wa=/<%([\s\S]+?)%>/g,Nn=/<%=([\s\S]+?)%>/g,cc=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ms=/^\w*$/,lc=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ar=/[\\^$.*+?()[\]{}|]/g,hc=RegExp(ar.source),ut=/^\s+/,fc=/\s/,ki=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ni=/\{\n\/\* \[wrapped with (.+)\] \*/,Tf=/,? & /,Ef=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ur=/[()=,{}\[\]\/\s]/,If=/\\(\\)?/g,xf=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Vi=/\w*$/,dc=/^[-+]0x[0-9a-f]+$/i,ba=/^0b[01]+$/i,Fs=/^\[object .+?Constructor\]$/,Vn=/^0o[0-7]+$/i,pc=/^(?:0|[1-9]\d*)$/,mc=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Br=/($^)/,Ta=/['\n\r\u2028\u2029\\]/g,Li="\\ud800-\\udfff",gc="\\u0300-\\u036f",Af="\\ufe20-\\ufe2f",Us="\\u20d0-\\u20ff",Ea=gc+Af+Us,Bs="\\u2700-\\u27bf",jr="a-z\\xdf-\\xf6\\xf8-\\xff",ur="\\xac\\xb1\\xd7\\xf7",Ia="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Sf="\\u2000-\\u206f",_c=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",xa="A-Z\\xc0-\\xd6\\xd8-\\xde",Aa="\\ufe0e\\ufe0f",js=ur+Ia+Sf+_c,Mi="['\u2019]",yc="["+Li+"]",Sa="["+js+"]",$s="["+Ea+"]",vc="\\d+",wc="["+Bs+"]",Ra="["+jr+"]",bc="[^"+Li+js+vc+Bs+jr+xa+"]",gn="\\ud83c[\\udffb-\\udfff]",_n="(?:"+$s+"|"+gn+")",Fi="[^"+Li+"]",$r="(?:\\ud83c[\\udde6-\\uddff]){2}",qs="[\\ud800-\\udbff][\\udc00-\\udfff]",Ce="["+xa+"]",Ui="\\u200d",qr="(?:"+Ra+"|"+bc+")",Bi="(?:"+Ce+"|"+bc+")",Tc="(?:"+Mi+"(?:d|ll|m|re|s|t|ve))?",Pa="(?:"+Mi+"(?:D|LL|M|RE|S|T|VE))?",Ec=_n+"?",Ic="["+Aa+"]?",Rf="(?:"+Ui+"(?:"+[Fi,$r,qs].join("|")+")"+Ic+Ec+")*",Pf="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ji="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",yn=Ic+Ec+Rf,xc="(?:"+[wc,$r,qs].join("|")+")"+yn,Ac="(?:"+[Fi+$s+"?",$s,$r,qs,yc].join("|")+")",Sc=RegExp(Mi,"g"),zr=RegExp($s,"g"),Ca=RegExp(gn+"(?="+gn+")|"+Ac+yn,"g"),Cf=RegExp([Ce+"?"+Ra+"+"+Tc+"(?="+[Sa,Ce,"$"].join("|")+")",Bi+"+"+Pa+"(?="+[Sa,Ce+qr,"$"].join("|")+")",Ce+"?"+qr+"+"+Tc,Ce+"+"+Pa,ji,Pf,vc,xc].join("|"),"g"),Df=RegExp("["+Ui+Li+Ea+Aa+"]"),Ln=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Of=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],kf=-1,Oe={};Oe[nt]=Oe[at]=Oe[Fr]=Oe[Os]=Oe[ks]=Oe[ga]=Oe[or]=Oe[Ns]=Oe[Vs]=!0,Oe[Ge]=Oe[Cs]=Oe[sr]=Oe[Ri]=Oe[kn]=Oe[mn]=Oe[Ds]=Oe[rr]=Oe[St]=Oe[ir]=Oe[Wt]=Oe[Ci]=Oe[Vt]=Oe[Lr]=Oe[Di]=!1;var ke={};ke[Ge]=ke[Cs]=ke[sr]=ke[kn]=ke[Ri]=ke[mn]=ke[nt]=ke[at]=ke[Fr]=ke[Os]=ke[ks]=ke[St]=ke[ir]=ke[Wt]=ke[Ci]=ke[Vt]=ke[Lr]=ke[Mr]=ke[ga]=ke[or]=ke[Ns]=ke[Vs]=!0,ke[Ds]=ke[rr]=ke[Di]=!1;var Rc={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},$i={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},qi={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Pc={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Da=parseFloat,qe=parseInt,Cc=typeof global=="object"&&global&&global.Object===Object&&global,Nf=typeof self=="object"&&self&&self.Object===Object&&self,Ye=Cc||Nf||Function("return this")(),zs=typeof ha=="object"&&ha&&!ha.nodeType&&ha,Mn=zs&&typeof tc=="object"&&tc&&!tc.nodeType&&tc,zi=Mn&&Mn.exports===zs,Gs=zi&&Cc.process,We=function(){try{var O=Mn&&Mn.require&&Mn.require("util").types;return O||Gs&&Gs.binding&&Gs.binding("util")}catch{}}(),Oa=We&&We.isArrayBuffer,Dc=We&&We.isDate,Gr=We&&We.isMap,ka=We&&We.isRegExp,Ks=We&&We.isSet,Gi=We&&We.isTypedArray;function bt(O,$,U){switch(U.length){case 0:return O.call($);case 1:return O.call($,U[0]);case 2:return O.call($,U[0],U[1]);case 3:return O.call($,U[0],U[1],U[2])}return O.apply($,U)}function Ws(O,$,U,Z){for(var he=-1,Ne=O==null?0:O.length;++he<Ne;){var ht=O[he];$(Z,ht,U(ht),O)}return Z}function Lt(O,$){for(var U=-1,Z=O==null?0:O.length;++U<Z&&$(O[U],U,O)!==!1;);return O}function Oc(O,$){for(var U=O==null?0:O.length;U--&&$(O[U],U,O)!==!1;);return O}function Kr(O,$){for(var U=-1,Z=O==null?0:O.length;++U<Z;)if(!$(O[U],U,O))return!1;return!0}function vn(O,$){for(var U=-1,Z=O==null?0:O.length,he=0,Ne=[];++U<Z;){var ht=O[U];$(ht,U,O)&&(Ne[he++]=ht)}return Ne}function Ki(O,$){var U=O==null?0:O.length;return!!U&&bn(O,$,0)>-1}function Wi(O,$,U){for(var Z=-1,he=O==null?0:O.length;++Z<he;)if(U($,O[Z]))return!0;return!1}function Fe(O,$){for(var U=-1,Z=O==null?0:O.length,he=Array(Z);++U<Z;)he[U]=$(O[U],U,O);return he}function wn(O,$){for(var U=-1,Z=$.length,he=O.length;++U<Z;)O[he+U]=$[U];return O}function Wr(O,$,U,Z){var he=-1,Ne=O==null?0:O.length;for(Z&&Ne&&(U=O[++he]);++he<Ne;)U=$(U,O[he],he,O);return U}function kc(O,$,U,Z){var he=O==null?0:O.length;for(Z&&he&&(U=O[--he]);he--;)U=$(U,O[he],he,O);return U}function Hs(O,$){for(var U=-1,Z=O==null?0:O.length;++U<Z;)if($(O[U],U,O))return!0;return!1}var cr=Fn("length");function Nc(O){return O.split("")}function Vc(O){return O.match(Ef)||[]}function Na(O,$,U){var Z;return U(O,function(he,Ne,ht){if($(he,Ne,ht))return Z=Ne,!1}),Z}function Hi(O,$,U,Z){for(var he=O.length,Ne=U+(Z?1:-1);Z?Ne--:++Ne<he;)if($(O[Ne],Ne,O))return Ne;return-1}function bn(O,$,U){return $===$?II(O,$,U):Hi(O,Va,U)}function Rt(O,$,U,Z){for(var he=U-1,Ne=O.length;++he<Ne;)if(Z(O[he],$))return he;return-1}function Va(O){return O!==O}function La(O,$){var U=O==null?0:O.length;return U?b(O,$)/U:Dn}function Fn(O){return function($){return $==null?n:$[O]}}function u(O){return function($){return O==null?n:O[$]}}function d(O,$,U,Z,he){return he(O,function(Ne,ht,Ue){U=Z?(Z=!1,Ne):$(U,Ne,ht,Ue)}),U}function g(O,$){var U=O.length;for(O.sort($);U--;)O[U]=O[U].value;return O}function b(O,$){for(var U,Z=-1,he=O.length;++Z<he;){var Ne=$(O[Z]);Ne!==n&&(U=U===n?Ne:U+Ne)}return U}function L(O,$){for(var U=-1,Z=Array(O);++U<O;)Z[U]=$(U);return Z}function F(O,$){return Fe($,function(U){return[U,O[U]]})}function Q(O){return O&&O.slice(0,Xg(O)+1).replace(ut,"")}function _e(O){return function($){return O($)}}function Xe(O,$){return Fe($,function(U){return O[U]})}function be(O,$){return O.has($)}function ct(O,$){for(var U=-1,Z=O.length;++U<Z&&bn($,O[U],0)>-1;);return U}function lt(O,$){for(var U=O.length;U--&&bn($,O[U],0)>-1;);return U}function Hr(O,$){for(var U=O.length,Z=0;U--;)O[U]===$&&++Z;return Z}var Ht=u(Rc),Qs=u($i);function Ma(O){return"\\"+Pc[O]}function wI(O,$){return O==null?n:O[$]}function Js(O){return Df.test(O)}function bI(O){return Ln.test(O)}function TI(O){for(var $,U=[];!($=O.next()).done;)U.push($.value);return U}function Vf(O){var $=-1,U=Array(O.size);return O.forEach(function(Z,he){U[++$]=[he,Z]}),U}function Yg(O,$){return function(U){return O($(U))}}function Qr(O,$){for(var U=-1,Z=O.length,he=0,Ne=[];++U<Z;){var ht=O[U];(ht===$||ht===f)&&(O[U]=f,Ne[he++]=U)}return Ne}function Lc(O){var $=-1,U=Array(O.size);return O.forEach(function(Z){U[++$]=Z}),U}function EI(O){var $=-1,U=Array(O.size);return O.forEach(function(Z){U[++$]=[Z,Z]}),U}function II(O,$,U){for(var Z=U-1,he=O.length;++Z<he;)if(O[Z]===$)return Z;return-1}function xI(O,$,U){for(var Z=U+1;Z--;)if(O[Z]===$)return Z;return Z}function Ys(O){return Js(O)?SI(O):cr(O)}function Tn(O){return Js(O)?RI(O):Nc(O)}function Xg(O){for(var $=O.length;$--&&fc.test(O.charAt($)););return $}var AI=u(qi);function SI(O){for(var $=Ca.lastIndex=0;Ca.test(O);)++$;return $}function RI(O){return O.match(Ca)||[]}function PI(O){return O.match(Cf)||[]}var CI=function O($){$=$==null?Ye:Jr.defaults(Ye.Object(),$,Jr.pick(Ye,Of));var U=$.Array,Z=$.Date,he=$.Error,Ne=$.Function,ht=$.Math,Ue=$.Object,Lf=$.RegExp,DI=$.String,nn=$.TypeError,Mc=U.prototype,OI=Ne.prototype,Xs=Ue.prototype,Fc=$["__core-js_shared__"],Uc=OI.toString,Me=Xs.hasOwnProperty,kI=0,Zg=function(){var i=/[^.]+$/.exec(Fc&&Fc.keys&&Fc.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}(),Bc=Xs.toString,NI=Uc.call(Ue),VI=Ye._,LI=Lf("^"+Uc.call(Me).replace(ar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),jc=zi?$.Buffer:n,Yr=$.Symbol,$c=$.Uint8Array,e_=jc?jc.allocUnsafe:n,qc=Yg(Ue.getPrototypeOf,Ue),t_=Ue.create,n_=Xs.propertyIsEnumerable,zc=Mc.splice,r_=Yr?Yr.isConcatSpreadable:n,Fa=Yr?Yr.iterator:n,Qi=Yr?Yr.toStringTag:n,Gc=function(){try{var i=es(Ue,"defineProperty");return i({},"",{}),i}catch{}}(),MI=$.clearTimeout!==Ye.clearTimeout&&$.clearTimeout,FI=Z&&Z.now!==Ye.Date.now&&Z.now,UI=$.setTimeout!==Ye.setTimeout&&$.setTimeout,Kc=ht.ceil,Wc=ht.floor,Mf=Ue.getOwnPropertySymbols,BI=jc?jc.isBuffer:n,i_=$.isFinite,jI=Mc.join,$I=Yg(Ue.keys,Ue),ft=ht.max,Tt=ht.min,qI=Z.now,zI=$.parseInt,s_=ht.random,GI=Mc.reverse,Ff=es($,"DataView"),Ua=es($,"Map"),Uf=es($,"Promise"),Zs=es($,"Set"),Ba=es($,"WeakMap"),ja=es(Ue,"create"),Hc=Ba&&new Ba,eo={},KI=ts(Ff),WI=ts(Ua),HI=ts(Uf),QI=ts(Zs),JI=ts(Ba),Qc=Yr?Yr.prototype:n,$a=Qc?Qc.valueOf:n,o_=Qc?Qc.toString:n;function w(i){if(He(i)&&!pe(i)&&!(i instanceof Ie)){if(i instanceof rn)return i;if(Me.call(i,"__wrapped__"))return ay(i)}return new rn(i)}var to=function(){function i(){}return function(o){if(!Ke(o))return{};if(t_)return t_(o);i.prototype=o;var l=new i;return i.prototype=n,l}}();function Jc(){}function rn(i,o){this.__wrapped__=i,this.__actions__=[],this.__chain__=!!o,this.__index__=0,this.__values__=n}w.templateSettings={escape:va,evaluate:wa,interpolate:Nn,variable:"",imports:{_:w}},w.prototype=Jc.prototype,w.prototype.constructor=w,rn.prototype=to(Jc.prototype),rn.prototype.constructor=rn;function Ie(i){this.__wrapped__=i,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Nt,this.__views__=[]}function YI(){var i=new Ie(this.__wrapped__);return i.__actions__=Mt(this.__actions__),i.__dir__=this.__dir__,i.__filtered__=this.__filtered__,i.__iteratees__=Mt(this.__iteratees__),i.__takeCount__=this.__takeCount__,i.__views__=Mt(this.__views__),i}function XI(){if(this.__filtered__){var i=new Ie(this);i.__dir__=-1,i.__filtered__=!0}else i=this.clone(),i.__dir__*=-1;return i}function ZI(){var i=this.__wrapped__.value(),o=this.__dir__,l=pe(i),p=o<0,y=l?i.length:0,T=hA(0,y,this.__views__),x=T.start,P=T.end,N=P-x,q=p?P:x-1,z=this.__iteratees__,K=z.length,Y=0,te=Tt(N,this.__takeCount__);if(!l||!p&&y==N&&te==N)return C_(i,this.__actions__);var oe=[];e:for(;N--&&Y<te;){q+=o;for(var ve=-1,ae=i[q];++ve<K;){var Te=z[ve],Ae=Te.iteratee,Yt=Te.type,Dt=Ae(ae);if(Yt==S)ae=Dt;else if(!Dt){if(Yt==M)continue e;break e}}oe[Y++]=ae}return oe}Ie.prototype=to(Jc.prototype),Ie.prototype.constructor=Ie;function Ji(i){var o=-1,l=i==null?0:i.length;for(this.clear();++o<l;){var p=i[o];this.set(p[0],p[1])}}function ex(){this.__data__=ja?ja(null):{},this.size=0}function tx(i){var o=this.has(i)&&delete this.__data__[i];return this.size-=o?1:0,o}function nx(i){var o=this.__data__;if(ja){var l=o[i];return l===c?n:l}return Me.call(o,i)?o[i]:n}function rx(i){var o=this.__data__;return ja?o[i]!==n:Me.call(o,i)}function ix(i,o){var l=this.__data__;return this.size+=this.has(i)?0:1,l[i]=ja&&o===n?c:o,this}Ji.prototype.clear=ex,Ji.prototype.delete=tx,Ji.prototype.get=nx,Ji.prototype.has=rx,Ji.prototype.set=ix;function lr(i){var o=-1,l=i==null?0:i.length;for(this.clear();++o<l;){var p=i[o];this.set(p[0],p[1])}}function sx(){this.__data__=[],this.size=0}function ox(i){var o=this.__data__,l=Yc(o,i);if(l<0)return!1;var p=o.length-1;return l==p?o.pop():zc.call(o,l,1),--this.size,!0}function ax(i){var o=this.__data__,l=Yc(o,i);return l<0?n:o[l][1]}function ux(i){return Yc(this.__data__,i)>-1}function cx(i,o){var l=this.__data__,p=Yc(l,i);return p<0?(++this.size,l.push([i,o])):l[p][1]=o,this}lr.prototype.clear=sx,lr.prototype.delete=ox,lr.prototype.get=ax,lr.prototype.has=ux,lr.prototype.set=cx;function hr(i){var o=-1,l=i==null?0:i.length;for(this.clear();++o<l;){var p=i[o];this.set(p[0],p[1])}}function lx(){this.size=0,this.__data__={hash:new Ji,map:new(Ua||lr),string:new Ji}}function hx(i){var o=cl(this,i).delete(i);return this.size-=o?1:0,o}function fx(i){return cl(this,i).get(i)}function dx(i){return cl(this,i).has(i)}function px(i,o){var l=cl(this,i),p=l.size;return l.set(i,o),this.size+=l.size==p?0:1,this}hr.prototype.clear=lx,hr.prototype.delete=hx,hr.prototype.get=fx,hr.prototype.has=dx,hr.prototype.set=px;function Yi(i){var o=-1,l=i==null?0:i.length;for(this.__data__=new hr;++o<l;)this.add(i[o])}function mx(i){return this.__data__.set(i,c),this}function gx(i){return this.__data__.has(i)}Yi.prototype.add=Yi.prototype.push=mx,Yi.prototype.has=gx;function En(i){var o=this.__data__=new lr(i);this.size=o.size}function _x(){this.__data__=new lr,this.size=0}function yx(i){var o=this.__data__,l=o.delete(i);return this.size=o.size,l}function vx(i){return this.__data__.get(i)}function wx(i){return this.__data__.has(i)}function bx(i,o){var l=this.__data__;if(l instanceof lr){var p=l.__data__;if(!Ua||p.length<t-1)return p.push([i,o]),this.size=++l.size,this;l=this.__data__=new hr(p)}return l.set(i,o),this.size=l.size,this}En.prototype.clear=_x,En.prototype.delete=yx,En.prototype.get=vx,En.prototype.has=wx,En.prototype.set=bx;function a_(i,o){var l=pe(i),p=!l&&ns(i),y=!l&&!p&&ni(i),T=!l&&!p&&!y&&so(i),x=l||p||y||T,P=x?L(i.length,DI):[],N=P.length;for(var q in i)(o||Me.call(i,q))&&!(x&&(q=="length"||y&&(q=="offset"||q=="parent")||T&&(q=="buffer"||q=="byteLength"||q=="byteOffset")||mr(q,N)))&&P.push(q);return P}function u_(i){var o=i.length;return o?i[Jf(0,o-1)]:n}function Tx(i,o){return ll(Mt(i),Xi(o,0,i.length))}function Ex(i){return ll(Mt(i))}function Bf(i,o,l){(l!==n&&!In(i[o],l)||l===n&&!(o in i))&&fr(i,o,l)}function qa(i,o,l){var p=i[o];(!(Me.call(i,o)&&In(p,l))||l===n&&!(o in i))&&fr(i,o,l)}function Yc(i,o){for(var l=i.length;l--;)if(In(i[l][0],o))return l;return-1}function Ix(i,o,l,p){return Xr(i,function(y,T,x){o(p,y,l(y),x)}),p}function c_(i,o){return i&&Bn(o,pt(o),i)}function xx(i,o){return i&&Bn(o,Ut(o),i)}function fr(i,o,l){o=="__proto__"&&Gc?Gc(i,o,{configurable:!0,enumerable:!0,value:l,writable:!0}):i[o]=l}function jf(i,o){for(var l=-1,p=o.length,y=U(p),T=i==null;++l<p;)y[l]=T?n:bd(i,o[l]);return y}function Xi(i,o,l){return i===i&&(l!==n&&(i=i<=l?i:l),o!==n&&(i=i>=o?i:o)),i}function sn(i,o,l,p,y,T){var x,P=o&m,N=o&_,q=o&E;if(l&&(x=y?l(i,p,y,T):l(i)),x!==n)return x;if(!Ke(i))return i;var z=pe(i);if(z){if(x=dA(i),!P)return Mt(i,x)}else{var K=Et(i),Y=K==rr||K==Pi;if(ni(i))return k_(i,P);if(K==Wt||K==Ge||Y&&!y){if(x=N||Y?{}:X_(i),!P)return N?nA(i,xx(x,i)):tA(i,c_(x,i))}else{if(!ke[K])return y?i:{};x=pA(i,K,P)}}T||(T=new En);var te=T.get(i);if(te)return te;T.set(i,x),Sy(i)?i.forEach(function(ae){x.add(sn(ae,o,l,ae,i,T))}):xy(i)&&i.forEach(function(ae,Te){x.set(Te,sn(ae,o,l,Te,i,T))});var oe=q?N?ad:od:N?Ut:pt,ve=z?n:oe(i);return Lt(ve||i,function(ae,Te){ve&&(Te=ae,ae=i[Te]),qa(x,Te,sn(ae,o,l,Te,i,T))}),x}function Ax(i){var o=pt(i);return function(l){return l_(l,i,o)}}function l_(i,o,l){var p=l.length;if(i==null)return!p;for(i=Ue(i);p--;){var y=l[p],T=o[y],x=i[y];if(x===n&&!(y in i)||!T(x))return!1}return!0}function h_(i,o,l){if(typeof i!="function")throw new nn(s);return Ja(function(){i.apply(n,l)},o)}function za(i,o,l,p){var y=-1,T=Ki,x=!0,P=i.length,N=[],q=o.length;if(!P)return N;l&&(o=Fe(o,_e(l))),p?(T=Wi,x=!1):o.length>=t&&(T=be,x=!1,o=new Yi(o));e:for(;++y<P;){var z=i[y],K=l==null?z:l(z);if(z=p||z!==0?z:0,x&&K===K){for(var Y=q;Y--;)if(o[Y]===K)continue e;N.push(z)}else T(o,K,p)||N.push(z)}return N}var Xr=F_(Un),f_=F_(qf,!0);function Sx(i,o){var l=!0;return Xr(i,function(p,y,T){return l=!!o(p,y,T),l}),l}function Xc(i,o,l){for(var p=-1,y=i.length;++p<y;){var T=i[p],x=o(T);if(x!=null&&(P===n?x===x&&!Jt(x):l(x,P)))var P=x,N=T}return N}function Rx(i,o,l,p){var y=i.length;for(l=ye(l),l<0&&(l=-l>y?0:y+l),p=p===n||p>y?y:ye(p),p<0&&(p+=y),p=l>p?0:Py(p);l<p;)i[l++]=o;return i}function d_(i,o){var l=[];return Xr(i,function(p,y,T){o(p,y,T)&&l.push(p)}),l}function _t(i,o,l,p,y){var T=-1,x=i.length;for(l||(l=gA),y||(y=[]);++T<x;){var P=i[T];o>0&&l(P)?o>1?_t(P,o-1,l,p,y):wn(y,P):p||(y[y.length]=P)}return y}var $f=U_(),p_=U_(!0);function Un(i,o){return i&&$f(i,o,pt)}function qf(i,o){return i&&p_(i,o,pt)}function Zc(i,o){return vn(o,function(l){return gr(i[l])})}function Zi(i,o){o=ei(o,i);for(var l=0,p=o.length;i!=null&&l<p;)i=i[jn(o[l++])];return l&&l==p?i:n}function m_(i,o,l){var p=o(i);return pe(i)?p:wn(p,l(i))}function Pt(i){return i==null?i===n?ac:da:Qi&&Qi in Ue(i)?lA(i):EA(i)}function zf(i,o){return i>o}function Px(i,o){return i!=null&&Me.call(i,o)}function Cx(i,o){return i!=null&&o in Ue(i)}function Dx(i,o,l){return i>=Tt(o,l)&&i<ft(o,l)}function Gf(i,o,l){for(var p=l?Wi:Ki,y=i[0].length,T=i.length,x=T,P=U(T),N=1/0,q=[];x--;){var z=i[x];x&&o&&(z=Fe(z,_e(o))),N=Tt(z.length,N),P[x]=!l&&(o||y>=120&&z.length>=120)?new Yi(x&&z):n}z=i[0];var K=-1,Y=P[0];e:for(;++K<y&&q.length<N;){var te=z[K],oe=o?o(te):te;if(te=l||te!==0?te:0,!(Y?be(Y,oe):p(q,oe,l))){for(x=T;--x;){var ve=P[x];if(!(ve?be(ve,oe):p(i[x],oe,l)))continue e}Y&&Y.push(oe),q.push(te)}}return q}function Ox(i,o,l,p){return Un(i,function(y,T,x){o(p,l(y),T,x)}),p}function Ga(i,o,l){o=ei(o,i),i=ny(i,o);var p=i==null?i:i[jn(an(o))];return p==null?n:bt(p,i,l)}function g_(i){return He(i)&&Pt(i)==Ge}function kx(i){return He(i)&&Pt(i)==sr}function Nx(i){return He(i)&&Pt(i)==mn}function Ka(i,o,l,p,y){return i===o?!0:i==null||o==null||!He(i)&&!He(o)?i!==i&&o!==o:Vx(i,o,l,p,Ka,y)}function Vx(i,o,l,p,y,T){var x=pe(i),P=pe(o),N=x?Cs:Et(i),q=P?Cs:Et(o);N=N==Ge?Wt:N,q=q==Ge?Wt:q;var z=N==Wt,K=q==Wt,Y=N==q;if(Y&&ni(i)){if(!ni(o))return!1;x=!0,z=!1}if(Y&&!z)return T||(T=new En),x||so(i)?Q_(i,o,l,p,y,T):uA(i,o,N,l,p,y,T);if(!(l&I)){var te=z&&Me.call(i,"__wrapped__"),oe=K&&Me.call(o,"__wrapped__");if(te||oe){var ve=te?i.value():i,ae=oe?o.value():o;return T||(T=new En),y(ve,ae,l,p,T)}}return Y?(T||(T=new En),cA(i,o,l,p,y,T)):!1}function Lx(i){return He(i)&&Et(i)==St}function Kf(i,o,l,p){var y=l.length,T=y,x=!p;if(i==null)return!T;for(i=Ue(i);y--;){var P=l[y];if(x&&P[2]?P[1]!==i[P[0]]:!(P[0]in i))return!1}for(;++y<T;){P=l[y];var N=P[0],q=i[N],z=P[1];if(x&&P[2]){if(q===n&&!(N in i))return!1}else{var K=new En;if(p)var Y=p(q,z,N,i,o,K);if(!(Y===n?Ka(z,q,I|k,p,K):Y))return!1}}return!0}function __(i){if(!Ke(i)||yA(i))return!1;var o=gr(i)?LI:Fs;return o.test(ts(i))}function Mx(i){return He(i)&&Pt(i)==Ci}function Fx(i){return He(i)&&Et(i)==Vt}function Ux(i){return He(i)&&gl(i.length)&&!!Oe[Pt(i)]}function y_(i){return typeof i=="function"?i:i==null?Bt:typeof i=="object"?pe(i)?b_(i[0],i[1]):w_(i):By(i)}function Wf(i){if(!Qa(i))return $I(i);var o=[];for(var l in Ue(i))Me.call(i,l)&&l!="constructor"&&o.push(l);return o}function Bx(i){if(!Ke(i))return TA(i);var o=Qa(i),l=[];for(var p in i)p=="constructor"&&(o||!Me.call(i,p))||l.push(p);return l}function Hf(i,o){return i<o}function v_(i,o){var l=-1,p=Ft(i)?U(i.length):[];return Xr(i,function(y,T,x){p[++l]=o(y,T,x)}),p}function w_(i){var o=cd(i);return o.length==1&&o[0][2]?ey(o[0][0],o[0][1]):function(l){return l===i||Kf(l,i,o)}}function b_(i,o){return hd(i)&&Z_(o)?ey(jn(i),o):function(l){var p=bd(l,i);return p===n&&p===o?Td(l,i):Ka(o,p,I|k)}}function el(i,o,l,p,y){i!==o&&$f(o,function(T,x){if(y||(y=new En),Ke(T))jx(i,o,x,l,el,p,y);else{var P=p?p(dd(i,x),T,x+"",i,o,y):n;P===n&&(P=T),Bf(i,x,P)}},Ut)}function jx(i,o,l,p,y,T,x){var P=dd(i,l),N=dd(o,l),q=x.get(N);if(q){Bf(i,l,q);return}var z=T?T(P,N,l+"",i,o,x):n,K=z===n;if(K){var Y=pe(N),te=!Y&&ni(N),oe=!Y&&!te&&so(N);z=N,Y||te||oe?pe(P)?z=P:Ze(P)?z=Mt(P):te?(K=!1,z=k_(N,!0)):oe?(K=!1,z=N_(N,!0)):z=[]:Ya(N)||ns(N)?(z=P,ns(P)?z=Cy(P):(!Ke(P)||gr(P))&&(z=X_(N))):K=!1}K&&(x.set(N,z),y(z,N,p,T,x),x.delete(N)),Bf(i,l,z)}function T_(i,o){var l=i.length;if(l)return o+=o<0?l:0,mr(o,l)?i[o]:n}function E_(i,o,l){o.length?o=Fe(o,function(T){return pe(T)?function(x){return Zi(x,T.length===1?T[0]:T)}:T}):o=[Bt];var p=-1;o=Fe(o,_e(se()));var y=v_(i,function(T,x,P){var N=Fe(o,function(q){return q(T)});return{criteria:N,index:++p,value:T}});return g(y,function(T,x){return eA(T,x,l)})}function $x(i,o){return I_(i,o,function(l,p){return Td(i,p)})}function I_(i,o,l){for(var p=-1,y=o.length,T={};++p<y;){var x=o[p],P=Zi(i,x);l(P,x)&&Wa(T,ei(x,i),P)}return T}function qx(i){return function(o){return Zi(o,i)}}function Qf(i,o,l,p){var y=p?Rt:bn,T=-1,x=o.length,P=i;for(i===o&&(o=Mt(o)),l&&(P=Fe(i,_e(l)));++T<x;)for(var N=0,q=o[T],z=l?l(q):q;(N=y(P,z,N,p))>-1;)P!==i&&zc.call(P,N,1),zc.call(i,N,1);return i}function x_(i,o){for(var l=i?o.length:0,p=l-1;l--;){var y=o[l];if(l==p||y!==T){var T=y;mr(y)?zc.call(i,y,1):Zf(i,y)}}return i}function Jf(i,o){return i+Wc(s_()*(o-i+1))}function zx(i,o,l,p){for(var y=-1,T=ft(Kc((o-i)/(l||1)),0),x=U(T);T--;)x[p?T:++y]=i,i+=l;return x}function Yf(i,o){var l="";if(!i||o<1||o>Cn)return l;do o%2&&(l+=i),o=Wc(o/2),o&&(i+=i);while(o);return l}function we(i,o){return pd(ty(i,o,Bt),i+"")}function Gx(i){return u_(oo(i))}function Kx(i,o){var l=oo(i);return ll(l,Xi(o,0,l.length))}function Wa(i,o,l,p){if(!Ke(i))return i;o=ei(o,i);for(var y=-1,T=o.length,x=T-1,P=i;P!=null&&++y<T;){var N=jn(o[y]),q=l;if(N==="__proto__"||N==="constructor"||N==="prototype")return i;if(y!=x){var z=P[N];q=p?p(z,N,P):n,q===n&&(q=Ke(z)?z:mr(o[y+1])?[]:{})}qa(P,N,q),P=P[N]}return i}var A_=Hc?function(i,o){return Hc.set(i,o),i}:Bt,Wx=Gc?function(i,o){return Gc(i,"toString",{configurable:!0,enumerable:!1,value:Id(o),writable:!0})}:Bt;function Hx(i){return ll(oo(i))}function on(i,o,l){var p=-1,y=i.length;o<0&&(o=-o>y?0:y+o),l=l>y?y:l,l<0&&(l+=y),y=o>l?0:l-o>>>0,o>>>=0;for(var T=U(y);++p<y;)T[p]=i[p+o];return T}function Qx(i,o){var l;return Xr(i,function(p,y,T){return l=o(p,y,T),!l}),!!l}function tl(i,o,l){var p=0,y=i==null?p:i.length;if(typeof o=="number"&&o===o&&y<=yf){for(;p<y;){var T=p+y>>>1,x=i[T];x!==null&&!Jt(x)&&(l?x<=o:x<o)?p=T+1:y=T}return y}return Xf(i,o,Bt,l)}function Xf(i,o,l,p){var y=0,T=i==null?0:i.length;if(T===0)return 0;o=l(o);for(var x=o!==o,P=o===null,N=Jt(o),q=o===n;y<T;){var z=Wc((y+T)/2),K=l(i[z]),Y=K!==n,te=K===null,oe=K===K,ve=Jt(K);if(x)var ae=p||oe;else q?ae=oe&&(p||Y):P?ae=oe&&Y&&(p||!te):N?ae=oe&&Y&&!te&&(p||!ve):te||ve?ae=!1:ae=p?K<=o:K<o;ae?y=z+1:T=z}return Tt(T,sc)}function S_(i,o){for(var l=-1,p=i.length,y=0,T=[];++l<p;){var x=i[l],P=o?o(x):x;if(!l||!In(P,N)){var N=P;T[y++]=x===0?0:x}}return T}function R_(i){return typeof i=="number"?i:Jt(i)?Dn:+i}function Qt(i){if(typeof i=="string")return i;if(pe(i))return Fe(i,Qt)+"";if(Jt(i))return o_?o_.call(i):"";var o=i+"";return o=="0"&&1/i==-Kt?"-0":o}function Zr(i,o,l){var p=-1,y=Ki,T=i.length,x=!0,P=[],N=P;if(l)x=!1,y=Wi;else if(T>=t){var q=o?null:oA(i);if(q)return Lc(q);x=!1,y=be,N=new Yi}else N=o?[]:P;e:for(;++p<T;){var z=i[p],K=o?o(z):z;if(z=l||z!==0?z:0,x&&K===K){for(var Y=N.length;Y--;)if(N[Y]===K)continue e;o&&N.push(K),P.push(z)}else y(N,K,l)||(N!==P&&N.push(K),P.push(z))}return P}function Zf(i,o){return o=ei(o,i),i=ny(i,o),i==null||delete i[jn(an(o))]}function P_(i,o,l,p){return Wa(i,o,l(Zi(i,o)),p)}function nl(i,o,l,p){for(var y=i.length,T=p?y:-1;(p?T--:++T<y)&&o(i[T],T,i););return l?on(i,p?0:T,p?T+1:y):on(i,p?T+1:0,p?y:T)}function C_(i,o){var l=i;return l instanceof Ie&&(l=l.value()),Wr(o,function(p,y){return y.func.apply(y.thisArg,wn([p],y.args))},l)}function ed(i,o,l){var p=i.length;if(p<2)return p?Zr(i[0]):[];for(var y=-1,T=U(p);++y<p;)for(var x=i[y],P=-1;++P<p;)P!=y&&(T[y]=za(T[y]||x,i[P],o,l));return Zr(_t(T,1),o,l)}function D_(i,o,l){for(var p=-1,y=i.length,T=o.length,x={};++p<y;){var P=p<T?o[p]:n;l(x,i[p],P)}return x}function td(i){return Ze(i)?i:[]}function nd(i){return typeof i=="function"?i:Bt}function ei(i,o){return pe(i)?i:hd(i,o)?[i]:oy(Ve(i))}var Jx=we;function ti(i,o,l){var p=i.length;return l=l===n?p:l,!o&&l>=p?i:on(i,o,l)}var O_=MI||function(i){return Ye.clearTimeout(i)};function k_(i,o){if(o)return i.slice();var l=i.length,p=e_?e_(l):new i.constructor(l);return i.copy(p),p}function rd(i){var o=new i.constructor(i.byteLength);return new $c(o).set(new $c(i)),o}function Yx(i,o){var l=o?rd(i.buffer):i.buffer;return new i.constructor(l,i.byteOffset,i.byteLength)}function Xx(i){var o=new i.constructor(i.source,Vi.exec(i));return o.lastIndex=i.lastIndex,o}function Zx(i){return $a?Ue($a.call(i)):{}}function N_(i,o){var l=o?rd(i.buffer):i.buffer;return new i.constructor(l,i.byteOffset,i.length)}function V_(i,o){if(i!==o){var l=i!==n,p=i===null,y=i===i,T=Jt(i),x=o!==n,P=o===null,N=o===o,q=Jt(o);if(!P&&!q&&!T&&i>o||T&&x&&N&&!P&&!q||p&&x&&N||!l&&N||!y)return 1;if(!p&&!T&&!q&&i<o||q&&l&&y&&!p&&!T||P&&l&&y||!x&&y||!N)return-1}return 0}function eA(i,o,l){for(var p=-1,y=i.criteria,T=o.criteria,x=y.length,P=l.length;++p<x;){var N=V_(y[p],T[p]);if(N){if(p>=P)return N;var q=l[p];return N*(q=="desc"?-1:1)}}return i.index-o.index}function L_(i,o,l,p){for(var y=-1,T=i.length,x=l.length,P=-1,N=o.length,q=ft(T-x,0),z=U(N+q),K=!p;++P<N;)z[P]=o[P];for(;++y<x;)(K||y<T)&&(z[l[y]]=i[y]);for(;q--;)z[P++]=i[y++];return z}function M_(i,o,l,p){for(var y=-1,T=i.length,x=-1,P=l.length,N=-1,q=o.length,z=ft(T-P,0),K=U(z+q),Y=!p;++y<z;)K[y]=i[y];for(var te=y;++N<q;)K[te+N]=o[N];for(;++x<P;)(Y||y<T)&&(K[te+l[x]]=i[y++]);return K}function Mt(i,o){var l=-1,p=i.length;for(o||(o=U(p));++l<p;)o[l]=i[l];return o}function Bn(i,o,l,p){var y=!l;l||(l={});for(var T=-1,x=o.length;++T<x;){var P=o[T],N=p?p(l[P],i[P],P,l,i):n;N===n&&(N=i[P]),y?fr(l,P,N):qa(l,P,N)}return l}function tA(i,o){return Bn(i,ld(i),o)}function nA(i,o){return Bn(i,J_(i),o)}function rl(i,o){return function(l,p){var y=pe(l)?Ws:Ix,T=o?o():{};return y(l,i,se(p,2),T)}}function no(i){return we(function(o,l){var p=-1,y=l.length,T=y>1?l[y-1]:n,x=y>2?l[2]:n;for(T=i.length>3&&typeof T=="function"?(y--,T):n,x&&Ct(l[0],l[1],x)&&(T=y<3?n:T,y=1),o=Ue(o);++p<y;){var P=l[p];P&&i(o,P,p,T)}return o})}function F_(i,o){return function(l,p){if(l==null)return l;if(!Ft(l))return i(l,p);for(var y=l.length,T=o?y:-1,x=Ue(l);(o?T--:++T<y)&&p(x[T],T,x)!==!1;);return l}}function U_(i){return function(o,l,p){for(var y=-1,T=Ue(o),x=p(o),P=x.length;P--;){var N=x[i?P:++y];if(l(T[N],N,T)===!1)break}return o}}function rA(i,o,l){var p=o&B,y=Ha(i);function T(){var x=this&&this!==Ye&&this instanceof T?y:i;return x.apply(p?l:this,arguments)}return T}function B_(i){return function(o){o=Ve(o);var l=Js(o)?Tn(o):n,p=l?l[0]:o.charAt(0),y=l?ti(l,1).join(""):o.slice(1);return p[i]()+y}}function ro(i){return function(o){return Wr(Fy(My(o).replace(Sc,"")),i,"")}}function Ha(i){return function(){var o=arguments;switch(o.length){case 0:return new i;case 1:return new i(o[0]);case 2:return new i(o[0],o[1]);case 3:return new i(o[0],o[1],o[2]);case 4:return new i(o[0],o[1],o[2],o[3]);case 5:return new i(o[0],o[1],o[2],o[3],o[4]);case 6:return new i(o[0],o[1],o[2],o[3],o[4],o[5]);case 7:return new i(o[0],o[1],o[2],o[3],o[4],o[5],o[6])}var l=to(i.prototype),p=i.apply(l,o);return Ke(p)?p:l}}function iA(i,o,l){var p=Ha(i);function y(){for(var T=arguments.length,x=U(T),P=T,N=io(y);P--;)x[P]=arguments[P];var q=T<3&&x[0]!==N&&x[T-1]!==N?[]:Qr(x,N);if(T-=q.length,T<l)return G_(i,o,il,y.placeholder,n,x,q,n,n,l-T);var z=this&&this!==Ye&&this instanceof y?p:i;return bt(z,this,x)}return y}function j_(i){return function(o,l,p){var y=Ue(o);if(!Ft(o)){var T=se(l,3);o=pt(o),l=function(P){return T(y[P],P,y)}}var x=i(o,l,p);return x>-1?y[T?o[x]:x]:n}}function $_(i){return pr(function(o){var l=o.length,p=l,y=rn.prototype.thru;for(i&&o.reverse();p--;){var T=o[p];if(typeof T!="function")throw new nn(s);if(y&&!x&&ul(T)=="wrapper")var x=new rn([],!0)}for(p=x?p:l;++p<l;){T=o[p];var P=ul(T),N=P=="wrapper"?ud(T):n;N&&fd(N[0])&&N[1]==(de|J|ne|ie)&&!N[4].length&&N[9]==1?x=x[ul(N[0])].apply(x,N[3]):x=T.length==1&&fd(T)?x[P]():x.thru(T)}return function(){var q=arguments,z=q[0];if(x&&q.length==1&&pe(z))return x.plant(z).value();for(var K=0,Y=l?o[K].apply(this,q):z;++K<l;)Y=o[K].call(this,Y);return Y}})}function il(i,o,l,p,y,T,x,P,N,q){var z=o&de,K=o&B,Y=o&G,te=o&(J|ee),oe=o&C,ve=Y?n:Ha(i);function ae(){for(var Te=arguments.length,Ae=U(Te),Yt=Te;Yt--;)Ae[Yt]=arguments[Yt];if(te)var Dt=io(ae),Xt=Hr(Ae,Dt);if(p&&(Ae=L_(Ae,p,y,te)),T&&(Ae=M_(Ae,T,x,te)),Te-=Xt,te&&Te<q){var et=Qr(Ae,Dt);return G_(i,o,il,ae.placeholder,l,Ae,et,P,N,q-Te)}var xn=K?l:this,yr=Y?xn[i]:i;return Te=Ae.length,P?Ae=IA(Ae,P):oe&&Te>1&&Ae.reverse(),z&&N<Te&&(Ae.length=N),this&&this!==Ye&&this instanceof ae&&(yr=ve||Ha(yr)),yr.apply(xn,Ae)}return ae}function q_(i,o){return function(l,p){return Ox(l,i,o(p),{})}}function sl(i,o){return function(l,p){var y;if(l===n&&p===n)return o;if(l!==n&&(y=l),p!==n){if(y===n)return p;typeof l=="string"||typeof p=="string"?(l=Qt(l),p=Qt(p)):(l=R_(l),p=R_(p)),y=i(l,p)}return y}}function id(i){return pr(function(o){return o=Fe(o,_e(se())),we(function(l){var p=this;return i(o,function(y){return bt(y,p,l)})})})}function ol(i,o){o=o===n?" ":Qt(o);var l=o.length;if(l<2)return l?Yf(o,i):o;var p=Yf(o,Kc(i/Ys(o)));return Js(o)?ti(Tn(p),0,i).join(""):p.slice(0,i)}function sA(i,o,l,p){var y=o&B,T=Ha(i);function x(){for(var P=-1,N=arguments.length,q=-1,z=p.length,K=U(z+N),Y=this&&this!==Ye&&this instanceof x?T:i;++q<z;)K[q]=p[q];for(;N--;)K[q++]=arguments[++P];return bt(Y,y?l:this,K)}return x}function z_(i){return function(o,l,p){return p&&typeof p!="number"&&Ct(o,l,p)&&(l=p=n),o=_r(o),l===n?(l=o,o=0):l=_r(l),p=p===n?o<l?1:-1:_r(p),zx(o,l,p,i)}}function al(i){return function(o,l){return typeof o=="string"&&typeof l=="string"||(o=un(o),l=un(l)),i(o,l)}}function G_(i,o,l,p,y,T,x,P,N,q){var z=o&J,K=z?x:n,Y=z?n:x,te=z?T:n,oe=z?n:T;o|=z?ne:le,o&=~(z?le:ne),o&j||(o&=~(B|G));var ve=[i,o,y,te,K,oe,Y,P,N,q],ae=l.apply(n,ve);return fd(i)&&ry(ae,ve),ae.placeholder=p,iy(ae,i,o)}function sd(i){var o=ht[i];return function(l,p){if(l=un(l),p=p==null?0:Tt(ye(p),292),p&&i_(l)){var y=(Ve(l)+"e").split("e"),T=o(y[0]+"e"+(+y[1]+p));return y=(Ve(T)+"e").split("e"),+(y[0]+"e"+(+y[1]-p))}return o(l)}}var oA=Zs&&1/Lc(new Zs([,-0]))[1]==Kt?function(i){return new Zs(i)}:Sd;function K_(i){return function(o){var l=Et(o);return l==St?Vf(o):l==Vt?EI(o):F(o,i(o))}}function dr(i,o,l,p,y,T,x,P){var N=o&G;if(!N&&typeof i!="function")throw new nn(s);var q=p?p.length:0;if(q||(o&=~(ne|le),p=y=n),x=x===n?x:ft(ye(x),0),P=P===n?P:ye(P),q-=y?y.length:0,o&le){var z=p,K=y;p=y=n}var Y=N?n:ud(i),te=[i,o,l,p,y,z,K,T,x,P];if(Y&&bA(te,Y),i=te[0],o=te[1],l=te[2],p=te[3],y=te[4],P=te[9]=te[9]===n?N?0:i.length:ft(te[9]-q,0),!P&&o&(J|ee)&&(o&=~(J|ee)),!o||o==B)var oe=rA(i,o,l);else o==J||o==ee?oe=iA(i,o,P):(o==ne||o==(B|ne))&&!y.length?oe=sA(i,o,l,p):oe=il.apply(n,te);var ve=Y?A_:ry;return iy(ve(oe,te),i,o)}function W_(i,o,l,p){return i===n||In(i,Xs[l])&&!Me.call(p,l)?o:i}function H_(i,o,l,p,y,T){return Ke(i)&&Ke(o)&&(T.set(o,i),el(i,o,n,H_,T),T.delete(o)),i}function aA(i){return Ya(i)?n:i}function Q_(i,o,l,p,y,T){var x=l&I,P=i.length,N=o.length;if(P!=N&&!(x&&N>P))return!1;var q=T.get(i),z=T.get(o);if(q&&z)return q==o&&z==i;var K=-1,Y=!0,te=l&k?new Yi:n;for(T.set(i,o),T.set(o,i);++K<P;){var oe=i[K],ve=o[K];if(p)var ae=x?p(ve,oe,K,o,i,T):p(oe,ve,K,i,o,T);if(ae!==n){if(ae)continue;Y=!1;break}if(te){if(!Hs(o,function(Te,Ae){if(!be(te,Ae)&&(oe===Te||y(oe,Te,l,p,T)))return te.push(Ae)})){Y=!1;break}}else if(!(oe===ve||y(oe,ve,l,p,T))){Y=!1;break}}return T.delete(i),T.delete(o),Y}function uA(i,o,l,p,y,T,x){switch(l){case kn:if(i.byteLength!=o.byteLength||i.byteOffset!=o.byteOffset)return!1;i=i.buffer,o=o.buffer;case sr:return!(i.byteLength!=o.byteLength||!T(new $c(i),new $c(o)));case Ri:case mn:case ir:return In(+i,+o);case Ds:return i.name==o.name&&i.message==o.message;case Ci:case Lr:return i==o+"";case St:var P=Vf;case Vt:var N=p&I;if(P||(P=Lc),i.size!=o.size&&!N)return!1;var q=x.get(i);if(q)return q==o;p|=k,x.set(i,o);var z=Q_(P(i),P(o),p,y,T,x);return x.delete(i),z;case Mr:if($a)return $a.call(i)==$a.call(o)}return!1}function cA(i,o,l,p,y,T){var x=l&I,P=od(i),N=P.length,q=od(o),z=q.length;if(N!=z&&!x)return!1;for(var K=N;K--;){var Y=P[K];if(!(x?Y in o:Me.call(o,Y)))return!1}var te=T.get(i),oe=T.get(o);if(te&&oe)return te==o&&oe==i;var ve=!0;T.set(i,o),T.set(o,i);for(var ae=x;++K<N;){Y=P[K];var Te=i[Y],Ae=o[Y];if(p)var Yt=x?p(Ae,Te,Y,o,i,T):p(Te,Ae,Y,i,o,T);if(!(Yt===n?Te===Ae||y(Te,Ae,l,p,T):Yt)){ve=!1;break}ae||(ae=Y=="constructor")}if(ve&&!ae){var Dt=i.constructor,Xt=o.constructor;Dt!=Xt&&"constructor"in i&&"constructor"in o&&!(typeof Dt=="function"&&Dt instanceof Dt&&typeof Xt=="function"&&Xt instanceof Xt)&&(ve=!1)}return T.delete(i),T.delete(o),ve}function pr(i){return pd(ty(i,n,ly),i+"")}function od(i){return m_(i,pt,ld)}function ad(i){return m_(i,Ut,J_)}var ud=Hc?function(i){return Hc.get(i)}:Sd;function ul(i){for(var o=i.name+"",l=eo[o],p=Me.call(eo,o)?l.length:0;p--;){var y=l[p],T=y.func;if(T==null||T==i)return y.name}return o}function io(i){var o=Me.call(w,"placeholder")?w:i;return o.placeholder}function se(){var i=w.iteratee||xd;return i=i===xd?y_:i,arguments.length?i(arguments[0],arguments[1]):i}function cl(i,o){var l=i.__data__;return _A(o)?l[typeof o=="string"?"string":"hash"]:l.map}function cd(i){for(var o=pt(i),l=o.length;l--;){var p=o[l],y=i[p];o[l]=[p,y,Z_(y)]}return o}function es(i,o){var l=wI(i,o);return __(l)?l:n}function lA(i){var o=Me.call(i,Qi),l=i[Qi];try{i[Qi]=n;var p=!0}catch{}var y=Bc.call(i);return p&&(o?i[Qi]=l:delete i[Qi]),y}var ld=Mf?function(i){return i==null?[]:(i=Ue(i),vn(Mf(i),function(o){return n_.call(i,o)}))}:Rd,J_=Mf?function(i){for(var o=[];i;)wn(o,ld(i)),i=qc(i);return o}:Rd,Et=Pt;(Ff&&Et(new Ff(new ArrayBuffer(1)))!=kn||Ua&&Et(new Ua)!=St||Uf&&Et(Uf.resolve())!=pa||Zs&&Et(new Zs)!=Vt||Ba&&Et(new Ba)!=Di)&&(Et=function(i){var o=Pt(i),l=o==Wt?i.constructor:n,p=l?ts(l):"";if(p)switch(p){case KI:return kn;case WI:return St;case HI:return pa;case QI:return Vt;case JI:return Di}return o});function hA(i,o,l){for(var p=-1,y=l.length;++p<y;){var T=l[p],x=T.size;switch(T.type){case"drop":i+=x;break;case"dropRight":o-=x;break;case"take":o=Tt(o,i+x);break;case"takeRight":i=ft(i,o-x);break}}return{start:i,end:o}}function fA(i){var o=i.match(Ni);return o?o[1].split(Tf):[]}function Y_(i,o,l){o=ei(o,i);for(var p=-1,y=o.length,T=!1;++p<y;){var x=jn(o[p]);if(!(T=i!=null&&l(i,x)))break;i=i[x]}return T||++p!=y?T:(y=i==null?0:i.length,!!y&&gl(y)&&mr(x,y)&&(pe(i)||ns(i)))}function dA(i){var o=i.length,l=new i.constructor(o);return o&&typeof i[0]=="string"&&Me.call(i,"index")&&(l.index=i.index,l.input=i.input),l}function X_(i){return typeof i.constructor=="function"&&!Qa(i)?to(qc(i)):{}}function pA(i,o,l){var p=i.constructor;switch(o){case sr:return rd(i);case Ri:case mn:return new p(+i);case kn:return Yx(i,l);case nt:case at:case Fr:case Os:case ks:case ga:case or:case Ns:case Vs:return N_(i,l);case St:return new p;case ir:case Lr:return new p(i);case Ci:return Xx(i);case Vt:return new p;case Mr:return Zx(i)}}function mA(i,o){var l=o.length;if(!l)return i;var p=l-1;return o[p]=(l>1?"& ":"")+o[p],o=o.join(l>2?", ":" "),i.replace(ki,`{
1
+ var jP=Object.create;var Za=Object.defineProperty;var $P=Object.getOwnPropertyDescriptor;var qP=Object.getOwnPropertyNames;var zP=Object.getPrototypeOf,GP=Object.prototype.hasOwnProperty;var KP=(r,e,t)=>e in r?Za(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var WP=(r,e)=>()=>(r&&(e=r(r=0)),e);var cr=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),HP=(r,e)=>{for(var t in e)Za(r,t,{get:e[t],enumerable:!0})},zy=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of qP(e))!GP.call(r,s)&&s!==t&&Za(r,s,{get:()=>e[s],enumerable:!(n=$P(e,s))||n.enumerable});return r};var Dd=(r,e,t)=>(t=r!=null?jP(zP(r)):{},zy(e||!r||!r.__esModule?Za(t,"default",{value:r,enumerable:!0}):t,r)),QP=r=>zy(Za({},"__esModule",{value:!0}),r);var gt=(r,e,t)=>KP(r,typeof e!="symbol"?e+"":e,t);var gs={};HP(gs,{Headers:()=>Eg,Request:()=>LF,Response:()=>MF,default:()=>Tg,fetch:()=>VF});var NF,ta,VF,Tg,Eg,LF,MF,Ei=WP(()=>{"use strict";NF=function(){if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof global!="undefined")return global;throw new Error("unable to locate global object")},ta=NF(),VF=ta.fetch,Tg=ta.fetch.bind(ta),Eg=ta.Headers,LF=ta.Request,MF=ta.Response});var Ag=cr(xg=>{"use strict";Object.defineProperty(xg,"__esModule",{value:!0});var Ig=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};xg.default=Ig});var Rg=cr(Vu=>{"use strict";var sE=Vu&&Vu.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Vu,"__esModule",{value:!0});var UF=sE((Ei(),QP(gs))),BF=sE(Ag()),Sg=class{constructor(e){this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=e.headers,this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=e.shouldThrowOnError,this.signal=e.signal,this.isMaybeSingle=e.isMaybeSingle,e.fetch?this.fetch=e.fetch:typeof fetch=="undefined"?this.fetch=UF.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=Object.assign({},this.headers),this.headers[e]=t,this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),this.method!=="GET"&&this.method!=="HEAD"&&(this.headers["Content-Type"]="application/json");let n=this.fetch,s=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async a=>{var c,h,f;let m=null,_=null,E=null,I=a.status,k=a.statusText;if(a.ok){if(this.method!=="HEAD"){let J=await a.text();J===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?_=J:_=JSON.parse(J))}let G=(c=this.headers.Prefer)===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),j=(h=a.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");G&&j&&j.length>1&&(E=parseInt(j[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(_)&&(_.length>1?(m={code:"PGRST116",details:`Results contain ${_.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},_=null,E=null,I=406,k="Not Acceptable"):_.length===1?_=_[0]:_=null)}else{let G=await a.text();try{m=JSON.parse(G),Array.isArray(m)&&a.status===404&&(_=[],m=null,I=200,k="OK")}catch{a.status===404&&G===""?(I=204,k="No Content"):m={message:G}}if(m&&this.isMaybeSingle&&(!((f=m==null?void 0:m.details)===null||f===void 0)&&f.includes("0 rows"))&&(m=null,I=200,k="OK"),m&&this.shouldThrowOnError)throw new BF.default(m)}return{error:m,data:_,count:E,status:I,statusText:k}});return this.shouldThrowOnError||(s=s.catch(a=>{var c,h,f;return{error:{message:`${(c=a==null?void 0:a.name)!==null&&c!==void 0?c:"FetchError"}: ${a==null?void 0:a.message}`,details:`${(h=a==null?void 0:a.stack)!==null&&h!==void 0?h:""}`,hint:"",code:`${(f=a==null?void 0:a.code)!==null&&f!==void 0?f:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}};Vu.default=Sg});var Cg=cr(Lu=>{"use strict";var jF=Lu&&Lu.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Lu,"__esModule",{value:!0});var $F=jF(Rg()),Pg=class extends $F.default{select(e){let t=!1,n=(e!=null?e:"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",n),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(e,{ascending:t=!0,nullsFirst:n,foreignTable:s,referencedTable:a=s}={}){let c=a?`${a}.order`:"order",h=this.url.searchParams.get(c);return this.url.searchParams.set(c,`${h?`${h},`:""}${e}.${t?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:n=t}={}){let s=typeof n=="undefined"?"limit":`${n}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:n,referencedTable:s=n}={}){let a=typeof s=="undefined"?"offset":`${s}.offset`,c=typeof s=="undefined"?"limit":`${s}.limit`;return this.url.searchParams.set(a,`${e}`),this.url.searchParams.set(c,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return this.method==="GET"?this.headers.Accept="application/json":this.headers.Accept="application/vnd.pgrst.object+json",this.isMaybeSingle=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain({analyze:e=!1,verbose:t=!1,settings:n=!1,buffers:s=!1,wal:a=!1,format:c="text"}={}){var h;let f=[e?"analyze":null,t?"verbose":null,n?"settings":null,s?"buffers":null,a?"wal":null].filter(Boolean).join("|"),m=(h=this.headers.Accept)!==null&&h!==void 0?h:"application/json";return this.headers.Accept=`application/vnd.pgrst.plan+${c}; for="${m}"; options=${f};`,c==="json"?this:this}rollback(){var e;return((e=this.headers.Prefer)!==null&&e!==void 0?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}};Lu.default=Pg});var tf=cr(Mu=>{"use strict";var qF=Mu&&Mu.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Mu,"__esModule",{value:!0});var zF=qF(Cg()),Dg=class extends zF.default{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){let n=Array.from(new Set(t)).map(s=>typeof s=="string"&&new RegExp("[,()]").test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${n})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:n,type:s}={}){let a="";s==="plain"?a="pl":s==="phrase"?a="ph":s==="websearch"&&(a="w");let c=n===void 0?"":`(${n})`;return this.url.searchParams.append(e,`${a}fts${c}.${t}`),this}match(e){return Object.entries(e).forEach(([t,n])=>{this.url.searchParams.append(t,`eq.${n}`)}),this}not(e,t,n){return this.url.searchParams.append(e,`not.${t}.${n}`),this}or(e,{foreignTable:t,referencedTable:n=t}={}){let s=n?`${n}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,n){return this.url.searchParams.append(e,`${t}.${n}`),this}};Mu.default=Dg});var kg=cr(Uu=>{"use strict";var GF=Uu&&Uu.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Uu,"__esModule",{value:!0});var Fu=GF(tf()),Og=class{constructor(e,{headers:t={},schema:n,fetch:s}){this.url=e,this.headers=t,this.schema=n,this.fetch=s}select(e,{head:t=!1,count:n}={}){let s=t?"HEAD":"GET",a=!1,c=(e!=null?e:"*").split("").map(h=>/\s/.test(h)&&!a?"":(h==='"'&&(a=!a),h)).join("");return this.url.searchParams.set("select",c),n&&(this.headers.Prefer=`count=${n}`),new Fu.default({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:t,defaultToNull:n=!0}={}){let s="POST",a=[];if(this.headers.Prefer&&a.push(this.headers.Prefer),t&&a.push(`count=${t}`),n||a.push("missing=default"),this.headers.Prefer=a.join(","),Array.isArray(e)){let c=e.reduce((h,f)=>h.concat(Object.keys(f)),[]);if(c.length>0){let h=[...new Set(c)].map(f=>`"${f}"`);this.url.searchParams.set("columns",h.join(","))}}return new Fu.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:t,ignoreDuplicates:n=!1,count:s,defaultToNull:a=!0}={}){let c="POST",h=[`resolution=${n?"ignore":"merge"}-duplicates`];if(t!==void 0&&this.url.searchParams.set("on_conflict",t),this.headers.Prefer&&h.push(this.headers.Prefer),s&&h.push(`count=${s}`),a||h.push("missing=default"),this.headers.Prefer=h.join(","),Array.isArray(e)){let f=e.reduce((m,_)=>m.concat(Object.keys(_)),[]);if(f.length>0){let m=[...new Set(f)].map(_=>`"${_}"`);this.url.searchParams.set("columns",m.join(","))}}return new Fu.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}update(e,{count:t}={}){let n="PATCH",s=[];return this.headers.Prefer&&s.push(this.headers.Prefer),t&&s.push(`count=${t}`),this.headers.Prefer=s.join(","),new Fu.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}delete({count:e}={}){let t="DELETE",n=[];return e&&n.push(`count=${e}`),this.headers.Prefer&&n.unshift(this.headers.Prefer),this.headers.Prefer=n.join(","),new Fu.default({method:t,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}};Uu.default=Og});var oE=cr(rf=>{"use strict";Object.defineProperty(rf,"__esModule",{value:!0});rf.version=void 0;rf.version="0.0.0-automated"});var aE=cr(nf=>{"use strict";Object.defineProperty(nf,"__esModule",{value:!0});nf.DEFAULT_HEADERS=void 0;var KF=oE();nf.DEFAULT_HEADERS={"X-Client-Info":`postgrest-js/${KF.version}`}});var cE=cr(Bu=>{"use strict";var uE=Bu&&Bu.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Bu,"__esModule",{value:!0});var WF=uE(kg()),HF=uE(tf()),QF=aE(),Ng=class r{constructor(e,{headers:t={},schema:n,fetch:s}={}){this.url=e,this.headers=Object.assign(Object.assign({},QF.DEFAULT_HEADERS),t),this.schemaName=n,this.fetch=s}from(e){let t=new URL(`${this.url}/${e}`);return new WF.default(t,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new r(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:n=!1,get:s=!1,count:a}={}){let c,h=new URL(`${this.url}/rpc/${e}`),f;n||s?(c=n?"HEAD":"GET",Object.entries(t).filter(([_,E])=>E!==void 0).map(([_,E])=>[_,Array.isArray(E)?`{${E.join(",")}}`:`${E}`]).forEach(([_,E])=>{h.searchParams.append(_,E)})):(c="POST",f=t);let m=Object.assign({},this.headers);return a&&(m.Prefer=`count=${a}`),new HF.default({method:c,url:h,headers:m,schema:this.schemaName,body:f,fetch:this.fetch,allowEmpty:!1})}};Bu.default=Ng});var gE=cr(bt=>{"use strict";var ra=bt&&bt.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(bt,"__esModule",{value:!0});bt.PostgrestError=bt.PostgrestBuilder=bt.PostgrestTransformBuilder=bt.PostgrestFilterBuilder=bt.PostgrestQueryBuilder=bt.PostgrestClient=void 0;var lE=ra(cE());bt.PostgrestClient=lE.default;var hE=ra(kg());bt.PostgrestQueryBuilder=hE.default;var fE=ra(tf());bt.PostgrestFilterBuilder=fE.default;var dE=ra(Cg());bt.PostgrestTransformBuilder=dE.default;var pE=ra(Rg());bt.PostgrestBuilder=pE.default;var mE=ra(Ag());bt.PostgrestError=mE.default;bt.default={PostgrestClient:lE.default,PostgrestQueryBuilder:hE.default,PostgrestFilterBuilder:fE.default,PostgrestTransformBuilder:dE.default,PostgrestBuilder:pE.default,PostgrestError:mE.default}});var xE=cr((s3,IE)=>{"use strict";IE.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var uI=cr((fa,nc)=>{(function(){var r,e="4.17.21",t=200,n="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",a="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",h=500,f="__lodash_placeholder__",m=1,_=2,E=4,I=1,k=2,B=1,G=2,j=4,J=8,ee=16,re=32,le=64,de=128,ie=256,C=512,A=30,R="...",D=800,V=16,M=1,S=2,dr=3,Wt=1/0,Pr=9007199254740991,Ai=17976931348623157e292,Cr=NaN,Lt=4294967295,ac=Lt-1,vf=Lt>>>1,Dr=[["ary",de],["bind",B],["bindKey",G],["curry",J],["curryRight",ee],["flip",C],["partial",re],["partialRight",le],["rearg",ie]],Ke="[object Arguments]",Cs="[object Array]",Si="[object AsyncFunction]",Ri="[object Boolean]",pr="[object Date]",wf="[object DOMException]",Ds="[object Error]",rn="[object Function]",Pi="[object GeneratorFunction]",Pt="[object Map]",nn="[object Number]",pa="[object Null]",Ht="[object Object]",ma="[object Promise]",uc="[object Proxy]",Ci="[object RegExp]",Mt="[object Set]",Ln="[object String]",Mn="[object Symbol]",cc="[object Undefined]",Di="[object WeakMap]",ga="[object WeakSet]",sn="[object ArrayBuffer]",Or="[object DataView]",nt="[object Float32Array]",ut="[object Float64Array]",Fn="[object Int8Array]",Os="[object Int16Array]",ks="[object Int32Array]",_a="[object Uint8Array]",on="[object Uint8ClampedArray]",Ns="[object Uint16Array]",Vs="[object Uint32Array]",ya=/\b__p \+= '';/g,bf=/\b(__p \+=) '' \+/g,Tf=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ls=/&(?:amp|lt|gt|quot|#39);/g,va=/[&<>"']/g,lc=RegExp(Ls.source),Oi=RegExp(va.source),wa=/<%-([\s\S]+?)%>/g,ba=/<%([\s\S]+?)%>/g,kr=/<%=([\s\S]+?)%>/g,hc=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ms=/^\w*$/,fc=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,an=/[\\^$.*+?()[\]{}|]/g,dc=RegExp(an.source),ct=/^\s+/,pc=/\s/,ki=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ni=/\{\n\/\* \[wrapped with (.+)\] \*/,Ef=/,? & /,If=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Un=/[()=,{}\[\]\/\s]/,xf=/\\(\\)?/g,Af=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Vi=/\w*$/,mc=/^[-+]0x[0-9a-f]+$/i,Ta=/^0b[01]+$/i,Fs=/^\[object .+?Constructor\]$/,Nr=/^0o[0-7]+$/i,gc=/^(?:0|[1-9]\d*)$/,_c=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Bn=/($^)/,Ea=/['\n\r\u2028\u2029\\]/g,Li="\\ud800-\\udfff",yc="\\u0300-\\u036f",Sf="\\ufe20-\\ufe2f",Us="\\u20d0-\\u20ff",Ia=yc+Sf+Us,Bs="\\u2700-\\u27bf",jn="a-z\\xdf-\\xf6\\xf8-\\xff",un="\\xac\\xb1\\xd7\\xf7",xa="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Rf="\\u2000-\\u206f",vc=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Aa="A-Z\\xc0-\\xd6\\xd8-\\xde",Sa="\\ufe0e\\ufe0f",js=un+xa+Rf+vc,Mi="['\u2019]",wc="["+Li+"]",Ra="["+js+"]",$s="["+Ia+"]",bc="\\d+",Tc="["+Bs+"]",Pa="["+jn+"]",Ec="[^"+Li+js+bc+Bs+jn+Aa+"]",mr="\\ud83c[\\udffb-\\udfff]",gr="(?:"+$s+"|"+mr+")",Fi="[^"+Li+"]",$n="(?:\\ud83c[\\udde6-\\uddff]){2}",qs="[\\ud800-\\udbff][\\udc00-\\udfff]",Ce="["+Aa+"]",Ui="\\u200d",qn="(?:"+Pa+"|"+Ec+")",Bi="(?:"+Ce+"|"+Ec+")",Ic="(?:"+Mi+"(?:d|ll|m|re|s|t|ve))?",Ca="(?:"+Mi+"(?:D|LL|M|RE|S|T|VE))?",xc=gr+"?",Ac="["+Sa+"]?",Pf="(?:"+Ui+"(?:"+[Fi,$n,qs].join("|")+")"+Ac+xc+")*",Cf="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ji="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",_r=Ac+xc+Pf,Sc="(?:"+[Tc,$n,qs].join("|")+")"+_r,Rc="(?:"+[Fi+$s+"?",$s,$n,qs,wc].join("|")+")",Pc=RegExp(Mi,"g"),zn=RegExp($s,"g"),Da=RegExp(mr+"(?="+mr+")|"+Rc+_r,"g"),Df=RegExp([Ce+"?"+Pa+"+"+Ic+"(?="+[Ra,Ce,"$"].join("|")+")",Bi+"+"+Ca+"(?="+[Ra,Ce+qn,"$"].join("|")+")",Ce+"?"+qn+"+"+Ic,Ce+"+"+Ca,ji,Cf,bc,Sc].join("|"),"g"),Of=RegExp("["+Ui+Li+Ia+Sa+"]"),Vr=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,kf=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Nf=-1,Oe={};Oe[nt]=Oe[ut]=Oe[Fn]=Oe[Os]=Oe[ks]=Oe[_a]=Oe[on]=Oe[Ns]=Oe[Vs]=!0,Oe[Ke]=Oe[Cs]=Oe[sn]=Oe[Ri]=Oe[Or]=Oe[pr]=Oe[Ds]=Oe[rn]=Oe[Pt]=Oe[nn]=Oe[Ht]=Oe[Ci]=Oe[Mt]=Oe[Ln]=Oe[Di]=!1;var ke={};ke[Ke]=ke[Cs]=ke[sn]=ke[Or]=ke[Ri]=ke[pr]=ke[nt]=ke[ut]=ke[Fn]=ke[Os]=ke[ks]=ke[Pt]=ke[nn]=ke[Ht]=ke[Ci]=ke[Mt]=ke[Ln]=ke[Mn]=ke[_a]=ke[on]=ke[Ns]=ke[Vs]=!0,ke[Ds]=ke[rn]=ke[Di]=!1;var Cc={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},$i={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},qi={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Dc={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Oa=parseFloat,ze=parseInt,Oc=typeof global=="object"&&global&&global.Object===Object&&global,Vf=typeof self=="object"&&self&&self.Object===Object&&self,Xe=Oc||Vf||Function("return this")(),zs=typeof fa=="object"&&fa&&!fa.nodeType&&fa,Lr=zs&&typeof nc=="object"&&nc&&!nc.nodeType&&nc,zi=Lr&&Lr.exports===zs,Gs=zi&&Oc.process,He=function(){try{var O=Lr&&Lr.require&&Lr.require("util").types;return O||Gs&&Gs.binding&&Gs.binding("util")}catch{}}(),ka=He&&He.isArrayBuffer,kc=He&&He.isDate,Gn=He&&He.isMap,Na=He&&He.isRegExp,Ks=He&&He.isSet,Gi=He&&He.isTypedArray;function Et(O,$,U){switch(U.length){case 0:return O.call($);case 1:return O.call($,U[0]);case 2:return O.call($,U[0],U[1]);case 3:return O.call($,U[0],U[1],U[2])}return O.apply($,U)}function Ws(O,$,U,Z){for(var he=-1,Ne=O==null?0:O.length;++he<Ne;){var ft=O[he];$(Z,ft,U(ft),O)}return Z}function Ft(O,$){for(var U=-1,Z=O==null?0:O.length;++U<Z&&$(O[U],U,O)!==!1;);return O}function Nc(O,$){for(var U=O==null?0:O.length;U--&&$(O[U],U,O)!==!1;);return O}function Kn(O,$){for(var U=-1,Z=O==null?0:O.length;++U<Z;)if(!$(O[U],U,O))return!1;return!0}function yr(O,$){for(var U=-1,Z=O==null?0:O.length,he=0,Ne=[];++U<Z;){var ft=O[U];$(ft,U,O)&&(Ne[he++]=ft)}return Ne}function Ki(O,$){var U=O==null?0:O.length;return!!U&&wr(O,$,0)>-1}function Wi(O,$,U){for(var Z=-1,he=O==null?0:O.length;++Z<he;)if(U($,O[Z]))return!0;return!1}function Fe(O,$){for(var U=-1,Z=O==null?0:O.length,he=Array(Z);++U<Z;)he[U]=$(O[U],U,O);return he}function vr(O,$){for(var U=-1,Z=$.length,he=O.length;++U<Z;)O[he+U]=$[U];return O}function Wn(O,$,U,Z){var he=-1,Ne=O==null?0:O.length;for(Z&&Ne&&(U=O[++he]);++he<Ne;)U=$(U,O[he],he,O);return U}function Vc(O,$,U,Z){var he=O==null?0:O.length;for(Z&&he&&(U=O[--he]);he--;)U=$(U,O[he],he,O);return U}function Hs(O,$){for(var U=-1,Z=O==null?0:O.length;++U<Z;)if($(O[U],U,O))return!0;return!1}var cn=Mr("length");function Lc(O){return O.split("")}function Mc(O){return O.match(If)||[]}function Va(O,$,U){var Z;return U(O,function(he,Ne,ft){if($(he,Ne,ft))return Z=Ne,!1}),Z}function Hi(O,$,U,Z){for(var he=O.length,Ne=U+(Z?1:-1);Z?Ne--:++Ne<he;)if($(O[Ne],Ne,O))return Ne;return-1}function wr(O,$,U){return $===$?SI(O,$,U):Hi(O,La,U)}function Ct(O,$,U,Z){for(var he=U-1,Ne=O.length;++he<Ne;)if(Z(O[he],$))return he;return-1}function La(O){return O!==O}function Ma(O,$){var U=O==null?0:O.length;return U?b(O,$)/U:Cr}function Mr(O){return function($){return $==null?r:$[O]}}function u(O){return function($){return O==null?r:O[$]}}function d(O,$,U,Z,he){return he(O,function(Ne,ft,Ue){U=Z?(Z=!1,Ne):$(U,Ne,ft,Ue)}),U}function g(O,$){var U=O.length;for(O.sort($);U--;)O[U]=O[U].value;return O}function b(O,$){for(var U,Z=-1,he=O.length;++Z<he;){var Ne=$(O[Z]);Ne!==r&&(U=U===r?Ne:U+Ne)}return U}function L(O,$){for(var U=-1,Z=Array(O);++U<O;)Z[U]=$(U);return Z}function F(O,$){return Fe($,function(U){return[U,O[U]]})}function Q(O){return O&&O.slice(0,e_(O)+1).replace(ct,"")}function _e(O){return function($){return O($)}}function Ze(O,$){return Fe($,function(U){return O[U]})}function be(O,$){return O.has($)}function lt(O,$){for(var U=-1,Z=O.length;++U<Z&&wr($,O[U],0)>-1;);return U}function ht(O,$){for(var U=O.length;U--&&wr($,O[U],0)>-1;);return U}function Hn(O,$){for(var U=O.length,Z=0;U--;)O[U]===$&&++Z;return Z}var Qt=u(Cc),Qs=u($i);function Fa(O){return"\\"+Dc[O]}function EI(O,$){return O==null?r:O[$]}function Js(O){return Of.test(O)}function II(O){return Vr.test(O)}function xI(O){for(var $,U=[];!($=O.next()).done;)U.push($.value);return U}function Lf(O){var $=-1,U=Array(O.size);return O.forEach(function(Z,he){U[++$]=[he,Z]}),U}function Zg(O,$){return function(U){return O($(U))}}function Qn(O,$){for(var U=-1,Z=O.length,he=0,Ne=[];++U<Z;){var ft=O[U];(ft===$||ft===f)&&(O[U]=f,Ne[he++]=U)}return Ne}function Fc(O){var $=-1,U=Array(O.size);return O.forEach(function(Z){U[++$]=Z}),U}function AI(O){var $=-1,U=Array(O.size);return O.forEach(function(Z){U[++$]=[Z,Z]}),U}function SI(O,$,U){for(var Z=U-1,he=O.length;++Z<he;)if(O[Z]===$)return Z;return-1}function RI(O,$,U){for(var Z=U+1;Z--;)if(O[Z]===$)return Z;return Z}function Ys(O){return Js(O)?CI(O):cn(O)}function br(O){return Js(O)?DI(O):Lc(O)}function e_(O){for(var $=O.length;$--&&pc.test(O.charAt($)););return $}var PI=u(qi);function CI(O){for(var $=Da.lastIndex=0;Da.test(O);)++$;return $}function DI(O){return O.match(Da)||[]}function OI(O){return O.match(Df)||[]}var kI=function O($){$=$==null?Xe:Jn.defaults(Xe.Object(),$,Jn.pick(Xe,kf));var U=$.Array,Z=$.Date,he=$.Error,Ne=$.Function,ft=$.Math,Ue=$.Object,Mf=$.RegExp,NI=$.String,nr=$.TypeError,Uc=U.prototype,VI=Ne.prototype,Xs=Ue.prototype,Bc=$["__core-js_shared__"],jc=VI.toString,Me=Xs.hasOwnProperty,LI=0,t_=function(){var i=/[^.]+$/.exec(Bc&&Bc.keys&&Bc.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}(),$c=Xs.toString,MI=jc.call(Ue),FI=Xe._,UI=Mf("^"+jc.call(Me).replace(an,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),qc=zi?$.Buffer:r,Yn=$.Symbol,zc=$.Uint8Array,r_=qc?qc.allocUnsafe:r,Gc=Zg(Ue.getPrototypeOf,Ue),n_=Ue.create,i_=Xs.propertyIsEnumerable,Kc=Uc.splice,s_=Yn?Yn.isConcatSpreadable:r,Ua=Yn?Yn.iterator:r,Qi=Yn?Yn.toStringTag:r,Wc=function(){try{var i=es(Ue,"defineProperty");return i({},"",{}),i}catch{}}(),BI=$.clearTimeout!==Xe.clearTimeout&&$.clearTimeout,jI=Z&&Z.now!==Xe.Date.now&&Z.now,$I=$.setTimeout!==Xe.setTimeout&&$.setTimeout,Hc=ft.ceil,Qc=ft.floor,Ff=Ue.getOwnPropertySymbols,qI=qc?qc.isBuffer:r,o_=$.isFinite,zI=Uc.join,GI=Zg(Ue.keys,Ue),dt=ft.max,It=ft.min,KI=Z.now,WI=$.parseInt,a_=ft.random,HI=Uc.reverse,Uf=es($,"DataView"),Ba=es($,"Map"),Bf=es($,"Promise"),Zs=es($,"Set"),ja=es($,"WeakMap"),$a=es(Ue,"create"),Jc=ja&&new ja,eo={},QI=ts(Uf),JI=ts(Ba),YI=ts(Bf),XI=ts(Zs),ZI=ts(ja),Yc=Yn?Yn.prototype:r,qa=Yc?Yc.valueOf:r,u_=Yc?Yc.toString:r;function w(i){if(Qe(i)&&!pe(i)&&!(i instanceof Ie)){if(i instanceof ir)return i;if(Me.call(i,"__wrapped__"))return cy(i)}return new ir(i)}var to=function(){function i(){}return function(o){if(!We(o))return{};if(n_)return n_(o);i.prototype=o;var l=new i;return i.prototype=r,l}}();function Xc(){}function ir(i,o){this.__wrapped__=i,this.__actions__=[],this.__chain__=!!o,this.__index__=0,this.__values__=r}w.templateSettings={escape:wa,evaluate:ba,interpolate:kr,variable:"",imports:{_:w}},w.prototype=Xc.prototype,w.prototype.constructor=w,ir.prototype=to(Xc.prototype),ir.prototype.constructor=ir;function Ie(i){this.__wrapped__=i,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Lt,this.__views__=[]}function ex(){var i=new Ie(this.__wrapped__);return i.__actions__=Ut(this.__actions__),i.__dir__=this.__dir__,i.__filtered__=this.__filtered__,i.__iteratees__=Ut(this.__iteratees__),i.__takeCount__=this.__takeCount__,i.__views__=Ut(this.__views__),i}function tx(){if(this.__filtered__){var i=new Ie(this);i.__dir__=-1,i.__filtered__=!0}else i=this.clone(),i.__dir__*=-1;return i}function rx(){var i=this.__wrapped__.value(),o=this.__dir__,l=pe(i),p=o<0,y=l?i.length:0,T=pA(0,y,this.__views__),x=T.start,P=T.end,N=P-x,q=p?P:x-1,z=this.__iteratees__,K=z.length,Y=0,te=It(N,this.__takeCount__);if(!l||!p&&y==N&&te==N)return O_(i,this.__actions__);var oe=[];e:for(;N--&&Y<te;){q+=o;for(var ve=-1,ae=i[q];++ve<K;){var Te=z[ve],Ae=Te.iteratee,Xt=Te.type,kt=Ae(ae);if(Xt==S)ae=kt;else if(!kt){if(Xt==M)continue e;break e}}oe[Y++]=ae}return oe}Ie.prototype=to(Xc.prototype),Ie.prototype.constructor=Ie;function Ji(i){var o=-1,l=i==null?0:i.length;for(this.clear();++o<l;){var p=i[o];this.set(p[0],p[1])}}function nx(){this.__data__=$a?$a(null):{},this.size=0}function ix(i){var o=this.has(i)&&delete this.__data__[i];return this.size-=o?1:0,o}function sx(i){var o=this.__data__;if($a){var l=o[i];return l===c?r:l}return Me.call(o,i)?o[i]:r}function ox(i){var o=this.__data__;return $a?o[i]!==r:Me.call(o,i)}function ax(i,o){var l=this.__data__;return this.size+=this.has(i)?0:1,l[i]=$a&&o===r?c:o,this}Ji.prototype.clear=nx,Ji.prototype.delete=ix,Ji.prototype.get=sx,Ji.prototype.has=ox,Ji.prototype.set=ax;function ln(i){var o=-1,l=i==null?0:i.length;for(this.clear();++o<l;){var p=i[o];this.set(p[0],p[1])}}function ux(){this.__data__=[],this.size=0}function cx(i){var o=this.__data__,l=Zc(o,i);if(l<0)return!1;var p=o.length-1;return l==p?o.pop():Kc.call(o,l,1),--this.size,!0}function lx(i){var o=this.__data__,l=Zc(o,i);return l<0?r:o[l][1]}function hx(i){return Zc(this.__data__,i)>-1}function fx(i,o){var l=this.__data__,p=Zc(l,i);return p<0?(++this.size,l.push([i,o])):l[p][1]=o,this}ln.prototype.clear=ux,ln.prototype.delete=cx,ln.prototype.get=lx,ln.prototype.has=hx,ln.prototype.set=fx;function hn(i){var o=-1,l=i==null?0:i.length;for(this.clear();++o<l;){var p=i[o];this.set(p[0],p[1])}}function dx(){this.size=0,this.__data__={hash:new Ji,map:new(Ba||ln),string:new Ji}}function px(i){var o=hl(this,i).delete(i);return this.size-=o?1:0,o}function mx(i){return hl(this,i).get(i)}function gx(i){return hl(this,i).has(i)}function _x(i,o){var l=hl(this,i),p=l.size;return l.set(i,o),this.size+=l.size==p?0:1,this}hn.prototype.clear=dx,hn.prototype.delete=px,hn.prototype.get=mx,hn.prototype.has=gx,hn.prototype.set=_x;function Yi(i){var o=-1,l=i==null?0:i.length;for(this.__data__=new hn;++o<l;)this.add(i[o])}function yx(i){return this.__data__.set(i,c),this}function vx(i){return this.__data__.has(i)}Yi.prototype.add=Yi.prototype.push=yx,Yi.prototype.has=vx;function Tr(i){var o=this.__data__=new ln(i);this.size=o.size}function wx(){this.__data__=new ln,this.size=0}function bx(i){var o=this.__data__,l=o.delete(i);return this.size=o.size,l}function Tx(i){return this.__data__.get(i)}function Ex(i){return this.__data__.has(i)}function Ix(i,o){var l=this.__data__;if(l instanceof ln){var p=l.__data__;if(!Ba||p.length<t-1)return p.push([i,o]),this.size=++l.size,this;l=this.__data__=new hn(p)}return l.set(i,o),this.size=l.size,this}Tr.prototype.clear=wx,Tr.prototype.delete=bx,Tr.prototype.get=Tx,Tr.prototype.has=Ex,Tr.prototype.set=Ix;function c_(i,o){var l=pe(i),p=!l&&rs(i),y=!l&&!p&&ri(i),T=!l&&!p&&!y&&so(i),x=l||p||y||T,P=x?L(i.length,NI):[],N=P.length;for(var q in i)(o||Me.call(i,q))&&!(x&&(q=="length"||y&&(q=="offset"||q=="parent")||T&&(q=="buffer"||q=="byteLength"||q=="byteOffset")||mn(q,N)))&&P.push(q);return P}function l_(i){var o=i.length;return o?i[Yf(0,o-1)]:r}function xx(i,o){return fl(Ut(i),Xi(o,0,i.length))}function Ax(i){return fl(Ut(i))}function jf(i,o,l){(l!==r&&!Er(i[o],l)||l===r&&!(o in i))&&fn(i,o,l)}function za(i,o,l){var p=i[o];(!(Me.call(i,o)&&Er(p,l))||l===r&&!(o in i))&&fn(i,o,l)}function Zc(i,o){for(var l=i.length;l--;)if(Er(i[l][0],o))return l;return-1}function Sx(i,o,l,p){return Xn(i,function(y,T,x){o(p,y,l(y),x)}),p}function h_(i,o){return i&&Ur(o,mt(o),i)}function Rx(i,o){return i&&Ur(o,jt(o),i)}function fn(i,o,l){o=="__proto__"&&Wc?Wc(i,o,{configurable:!0,enumerable:!0,value:l,writable:!0}):i[o]=l}function $f(i,o){for(var l=-1,p=o.length,y=U(p),T=i==null;++l<p;)y[l]=T?r:Td(i,o[l]);return y}function Xi(i,o,l){return i===i&&(l!==r&&(i=i<=l?i:l),o!==r&&(i=i>=o?i:o)),i}function sr(i,o,l,p,y,T){var x,P=o&m,N=o&_,q=o&E;if(l&&(x=y?l(i,p,y,T):l(i)),x!==r)return x;if(!We(i))return i;var z=pe(i);if(z){if(x=gA(i),!P)return Ut(i,x)}else{var K=xt(i),Y=K==rn||K==Pi;if(ri(i))return V_(i,P);if(K==Ht||K==Ke||Y&&!y){if(x=N||Y?{}:ey(i),!P)return N?sA(i,Rx(x,i)):iA(i,h_(x,i))}else{if(!ke[K])return y?i:{};x=_A(i,K,P)}}T||(T=new Tr);var te=T.get(i);if(te)return te;T.set(i,x),Py(i)?i.forEach(function(ae){x.add(sr(ae,o,l,ae,i,T))}):Sy(i)&&i.forEach(function(ae,Te){x.set(Te,sr(ae,o,l,Te,i,T))});var oe=q?N?ud:ad:N?jt:mt,ve=z?r:oe(i);return Ft(ve||i,function(ae,Te){ve&&(Te=ae,ae=i[Te]),za(x,Te,sr(ae,o,l,Te,i,T))}),x}function Px(i){var o=mt(i);return function(l){return f_(l,i,o)}}function f_(i,o,l){var p=l.length;if(i==null)return!p;for(i=Ue(i);p--;){var y=l[p],T=o[y],x=i[y];if(x===r&&!(y in i)||!T(x))return!1}return!0}function d_(i,o,l){if(typeof i!="function")throw new nr(s);return Ya(function(){i.apply(r,l)},o)}function Ga(i,o,l,p){var y=-1,T=Ki,x=!0,P=i.length,N=[],q=o.length;if(!P)return N;l&&(o=Fe(o,_e(l))),p?(T=Wi,x=!1):o.length>=t&&(T=be,x=!1,o=new Yi(o));e:for(;++y<P;){var z=i[y],K=l==null?z:l(z);if(z=p||z!==0?z:0,x&&K===K){for(var Y=q;Y--;)if(o[Y]===K)continue e;N.push(z)}else T(o,K,p)||N.push(z)}return N}var Xn=B_(Fr),p_=B_(zf,!0);function Cx(i,o){var l=!0;return Xn(i,function(p,y,T){return l=!!o(p,y,T),l}),l}function el(i,o,l){for(var p=-1,y=i.length;++p<y;){var T=i[p],x=o(T);if(x!=null&&(P===r?x===x&&!Yt(x):l(x,P)))var P=x,N=T}return N}function Dx(i,o,l,p){var y=i.length;for(l=ye(l),l<0&&(l=-l>y?0:y+l),p=p===r||p>y?y:ye(p),p<0&&(p+=y),p=l>p?0:Dy(p);l<p;)i[l++]=o;return i}function m_(i,o){var l=[];return Xn(i,function(p,y,T){o(p,y,T)&&l.push(p)}),l}function vt(i,o,l,p,y){var T=-1,x=i.length;for(l||(l=vA),y||(y=[]);++T<x;){var P=i[T];o>0&&l(P)?o>1?vt(P,o-1,l,p,y):vr(y,P):p||(y[y.length]=P)}return y}var qf=j_(),g_=j_(!0);function Fr(i,o){return i&&qf(i,o,mt)}function zf(i,o){return i&&g_(i,o,mt)}function tl(i,o){return yr(o,function(l){return gn(i[l])})}function Zi(i,o){o=ei(o,i);for(var l=0,p=o.length;i!=null&&l<p;)i=i[Br(o[l++])];return l&&l==p?i:r}function __(i,o,l){var p=o(i);return pe(i)?p:vr(p,l(i))}function Dt(i){return i==null?i===r?cc:pa:Qi&&Qi in Ue(i)?dA(i):AA(i)}function Gf(i,o){return i>o}function Ox(i,o){return i!=null&&Me.call(i,o)}function kx(i,o){return i!=null&&o in Ue(i)}function Nx(i,o,l){return i>=It(o,l)&&i<dt(o,l)}function Kf(i,o,l){for(var p=l?Wi:Ki,y=i[0].length,T=i.length,x=T,P=U(T),N=1/0,q=[];x--;){var z=i[x];x&&o&&(z=Fe(z,_e(o))),N=It(z.length,N),P[x]=!l&&(o||y>=120&&z.length>=120)?new Yi(x&&z):r}z=i[0];var K=-1,Y=P[0];e:for(;++K<y&&q.length<N;){var te=z[K],oe=o?o(te):te;if(te=l||te!==0?te:0,!(Y?be(Y,oe):p(q,oe,l))){for(x=T;--x;){var ve=P[x];if(!(ve?be(ve,oe):p(i[x],oe,l)))continue e}Y&&Y.push(oe),q.push(te)}}return q}function Vx(i,o,l,p){return Fr(i,function(y,T,x){o(p,l(y),T,x)}),p}function Ka(i,o,l){o=ei(o,i),i=iy(i,o);var p=i==null?i:i[Br(ar(o))];return p==null?r:Et(p,i,l)}function y_(i){return Qe(i)&&Dt(i)==Ke}function Lx(i){return Qe(i)&&Dt(i)==sn}function Mx(i){return Qe(i)&&Dt(i)==pr}function Wa(i,o,l,p,y){return i===o?!0:i==null||o==null||!Qe(i)&&!Qe(o)?i!==i&&o!==o:Fx(i,o,l,p,Wa,y)}function Fx(i,o,l,p,y,T){var x=pe(i),P=pe(o),N=x?Cs:xt(i),q=P?Cs:xt(o);N=N==Ke?Ht:N,q=q==Ke?Ht:q;var z=N==Ht,K=q==Ht,Y=N==q;if(Y&&ri(i)){if(!ri(o))return!1;x=!0,z=!1}if(Y&&!z)return T||(T=new Tr),x||so(i)?Y_(i,o,l,p,y,T):hA(i,o,N,l,p,y,T);if(!(l&I)){var te=z&&Me.call(i,"__wrapped__"),oe=K&&Me.call(o,"__wrapped__");if(te||oe){var ve=te?i.value():i,ae=oe?o.value():o;return T||(T=new Tr),y(ve,ae,l,p,T)}}return Y?(T||(T=new Tr),fA(i,o,l,p,y,T)):!1}function Ux(i){return Qe(i)&&xt(i)==Pt}function Wf(i,o,l,p){var y=l.length,T=y,x=!p;if(i==null)return!T;for(i=Ue(i);y--;){var P=l[y];if(x&&P[2]?P[1]!==i[P[0]]:!(P[0]in i))return!1}for(;++y<T;){P=l[y];var N=P[0],q=i[N],z=P[1];if(x&&P[2]){if(q===r&&!(N in i))return!1}else{var K=new Tr;if(p)var Y=p(q,z,N,i,o,K);if(!(Y===r?Wa(z,q,I|k,p,K):Y))return!1}}return!0}function v_(i){if(!We(i)||bA(i))return!1;var o=gn(i)?UI:Fs;return o.test(ts(i))}function Bx(i){return Qe(i)&&Dt(i)==Ci}function jx(i){return Qe(i)&&xt(i)==Mt}function $x(i){return Qe(i)&&yl(i.length)&&!!Oe[Dt(i)]}function w_(i){return typeof i=="function"?i:i==null?$t:typeof i=="object"?pe(i)?E_(i[0],i[1]):T_(i):$y(i)}function Hf(i){if(!Ja(i))return GI(i);var o=[];for(var l in Ue(i))Me.call(i,l)&&l!="constructor"&&o.push(l);return o}function qx(i){if(!We(i))return xA(i);var o=Ja(i),l=[];for(var p in i)p=="constructor"&&(o||!Me.call(i,p))||l.push(p);return l}function Qf(i,o){return i<o}function b_(i,o){var l=-1,p=Bt(i)?U(i.length):[];return Xn(i,function(y,T,x){p[++l]=o(y,T,x)}),p}function T_(i){var o=ld(i);return o.length==1&&o[0][2]?ry(o[0][0],o[0][1]):function(l){return l===i||Wf(l,i,o)}}function E_(i,o){return fd(i)&&ty(o)?ry(Br(i),o):function(l){var p=Td(l,i);return p===r&&p===o?Ed(l,i):Wa(o,p,I|k)}}function rl(i,o,l,p,y){i!==o&&qf(o,function(T,x){if(y||(y=new Tr),We(T))zx(i,o,x,l,rl,p,y);else{var P=p?p(pd(i,x),T,x+"",i,o,y):r;P===r&&(P=T),jf(i,x,P)}},jt)}function zx(i,o,l,p,y,T,x){var P=pd(i,l),N=pd(o,l),q=x.get(N);if(q){jf(i,l,q);return}var z=T?T(P,N,l+"",i,o,x):r,K=z===r;if(K){var Y=pe(N),te=!Y&&ri(N),oe=!Y&&!te&&so(N);z=N,Y||te||oe?pe(P)?z=P:et(P)?z=Ut(P):te?(K=!1,z=V_(N,!0)):oe?(K=!1,z=L_(N,!0)):z=[]:Xa(N)||rs(N)?(z=P,rs(P)?z=Oy(P):(!We(P)||gn(P))&&(z=ey(N))):K=!1}K&&(x.set(N,z),y(z,N,p,T,x),x.delete(N)),jf(i,l,z)}function I_(i,o){var l=i.length;if(l)return o+=o<0?l:0,mn(o,l)?i[o]:r}function x_(i,o,l){o.length?o=Fe(o,function(T){return pe(T)?function(x){return Zi(x,T.length===1?T[0]:T)}:T}):o=[$t];var p=-1;o=Fe(o,_e(se()));var y=b_(i,function(T,x,P){var N=Fe(o,function(q){return q(T)});return{criteria:N,index:++p,value:T}});return g(y,function(T,x){return nA(T,x,l)})}function Gx(i,o){return A_(i,o,function(l,p){return Ed(i,p)})}function A_(i,o,l){for(var p=-1,y=o.length,T={};++p<y;){var x=o[p],P=Zi(i,x);l(P,x)&&Ha(T,ei(x,i),P)}return T}function Kx(i){return function(o){return Zi(o,i)}}function Jf(i,o,l,p){var y=p?Ct:wr,T=-1,x=o.length,P=i;for(i===o&&(o=Ut(o)),l&&(P=Fe(i,_e(l)));++T<x;)for(var N=0,q=o[T],z=l?l(q):q;(N=y(P,z,N,p))>-1;)P!==i&&Kc.call(P,N,1),Kc.call(i,N,1);return i}function S_(i,o){for(var l=i?o.length:0,p=l-1;l--;){var y=o[l];if(l==p||y!==T){var T=y;mn(y)?Kc.call(i,y,1):ed(i,y)}}return i}function Yf(i,o){return i+Qc(a_()*(o-i+1))}function Wx(i,o,l,p){for(var y=-1,T=dt(Hc((o-i)/(l||1)),0),x=U(T);T--;)x[p?T:++y]=i,i+=l;return x}function Xf(i,o){var l="";if(!i||o<1||o>Pr)return l;do o%2&&(l+=i),o=Qc(o/2),o&&(i+=i);while(o);return l}function we(i,o){return md(ny(i,o,$t),i+"")}function Hx(i){return l_(oo(i))}function Qx(i,o){var l=oo(i);return fl(l,Xi(o,0,l.length))}function Ha(i,o,l,p){if(!We(i))return i;o=ei(o,i);for(var y=-1,T=o.length,x=T-1,P=i;P!=null&&++y<T;){var N=Br(o[y]),q=l;if(N==="__proto__"||N==="constructor"||N==="prototype")return i;if(y!=x){var z=P[N];q=p?p(z,N,P):r,q===r&&(q=We(z)?z:mn(o[y+1])?[]:{})}za(P,N,q),P=P[N]}return i}var R_=Jc?function(i,o){return Jc.set(i,o),i}:$t,Jx=Wc?function(i,o){return Wc(i,"toString",{configurable:!0,enumerable:!1,value:xd(o),writable:!0})}:$t;function Yx(i){return fl(oo(i))}function or(i,o,l){var p=-1,y=i.length;o<0&&(o=-o>y?0:y+o),l=l>y?y:l,l<0&&(l+=y),y=o>l?0:l-o>>>0,o>>>=0;for(var T=U(y);++p<y;)T[p]=i[p+o];return T}function Xx(i,o){var l;return Xn(i,function(p,y,T){return l=o(p,y,T),!l}),!!l}function nl(i,o,l){var p=0,y=i==null?p:i.length;if(typeof o=="number"&&o===o&&y<=vf){for(;p<y;){var T=p+y>>>1,x=i[T];x!==null&&!Yt(x)&&(l?x<=o:x<o)?p=T+1:y=T}return y}return Zf(i,o,$t,l)}function Zf(i,o,l,p){var y=0,T=i==null?0:i.length;if(T===0)return 0;o=l(o);for(var x=o!==o,P=o===null,N=Yt(o),q=o===r;y<T;){var z=Qc((y+T)/2),K=l(i[z]),Y=K!==r,te=K===null,oe=K===K,ve=Yt(K);if(x)var ae=p||oe;else q?ae=oe&&(p||Y):P?ae=oe&&Y&&(p||!te):N?ae=oe&&Y&&!te&&(p||!ve):te||ve?ae=!1:ae=p?K<=o:K<o;ae?y=z+1:T=z}return It(T,ac)}function P_(i,o){for(var l=-1,p=i.length,y=0,T=[];++l<p;){var x=i[l],P=o?o(x):x;if(!l||!Er(P,N)){var N=P;T[y++]=x===0?0:x}}return T}function C_(i){return typeof i=="number"?i:Yt(i)?Cr:+i}function Jt(i){if(typeof i=="string")return i;if(pe(i))return Fe(i,Jt)+"";if(Yt(i))return u_?u_.call(i):"";var o=i+"";return o=="0"&&1/i==-Wt?"-0":o}function Zn(i,o,l){var p=-1,y=Ki,T=i.length,x=!0,P=[],N=P;if(l)x=!1,y=Wi;else if(T>=t){var q=o?null:cA(i);if(q)return Fc(q);x=!1,y=be,N=new Yi}else N=o?[]:P;e:for(;++p<T;){var z=i[p],K=o?o(z):z;if(z=l||z!==0?z:0,x&&K===K){for(var Y=N.length;Y--;)if(N[Y]===K)continue e;o&&N.push(K),P.push(z)}else y(N,K,l)||(N!==P&&N.push(K),P.push(z))}return P}function ed(i,o){return o=ei(o,i),i=iy(i,o),i==null||delete i[Br(ar(o))]}function D_(i,o,l,p){return Ha(i,o,l(Zi(i,o)),p)}function il(i,o,l,p){for(var y=i.length,T=p?y:-1;(p?T--:++T<y)&&o(i[T],T,i););return l?or(i,p?0:T,p?T+1:y):or(i,p?T+1:0,p?y:T)}function O_(i,o){var l=i;return l instanceof Ie&&(l=l.value()),Wn(o,function(p,y){return y.func.apply(y.thisArg,vr([p],y.args))},l)}function td(i,o,l){var p=i.length;if(p<2)return p?Zn(i[0]):[];for(var y=-1,T=U(p);++y<p;)for(var x=i[y],P=-1;++P<p;)P!=y&&(T[y]=Ga(T[y]||x,i[P],o,l));return Zn(vt(T,1),o,l)}function k_(i,o,l){for(var p=-1,y=i.length,T=o.length,x={};++p<y;){var P=p<T?o[p]:r;l(x,i[p],P)}return x}function rd(i){return et(i)?i:[]}function nd(i){return typeof i=="function"?i:$t}function ei(i,o){return pe(i)?i:fd(i,o)?[i]:uy(Ve(i))}var Zx=we;function ti(i,o,l){var p=i.length;return l=l===r?p:l,!o&&l>=p?i:or(i,o,l)}var N_=BI||function(i){return Xe.clearTimeout(i)};function V_(i,o){if(o)return i.slice();var l=i.length,p=r_?r_(l):new i.constructor(l);return i.copy(p),p}function id(i){var o=new i.constructor(i.byteLength);return new zc(o).set(new zc(i)),o}function eA(i,o){var l=o?id(i.buffer):i.buffer;return new i.constructor(l,i.byteOffset,i.byteLength)}function tA(i){var o=new i.constructor(i.source,Vi.exec(i));return o.lastIndex=i.lastIndex,o}function rA(i){return qa?Ue(qa.call(i)):{}}function L_(i,o){var l=o?id(i.buffer):i.buffer;return new i.constructor(l,i.byteOffset,i.length)}function M_(i,o){if(i!==o){var l=i!==r,p=i===null,y=i===i,T=Yt(i),x=o!==r,P=o===null,N=o===o,q=Yt(o);if(!P&&!q&&!T&&i>o||T&&x&&N&&!P&&!q||p&&x&&N||!l&&N||!y)return 1;if(!p&&!T&&!q&&i<o||q&&l&&y&&!p&&!T||P&&l&&y||!x&&y||!N)return-1}return 0}function nA(i,o,l){for(var p=-1,y=i.criteria,T=o.criteria,x=y.length,P=l.length;++p<x;){var N=M_(y[p],T[p]);if(N){if(p>=P)return N;var q=l[p];return N*(q=="desc"?-1:1)}}return i.index-o.index}function F_(i,o,l,p){for(var y=-1,T=i.length,x=l.length,P=-1,N=o.length,q=dt(T-x,0),z=U(N+q),K=!p;++P<N;)z[P]=o[P];for(;++y<x;)(K||y<T)&&(z[l[y]]=i[y]);for(;q--;)z[P++]=i[y++];return z}function U_(i,o,l,p){for(var y=-1,T=i.length,x=-1,P=l.length,N=-1,q=o.length,z=dt(T-P,0),K=U(z+q),Y=!p;++y<z;)K[y]=i[y];for(var te=y;++N<q;)K[te+N]=o[N];for(;++x<P;)(Y||y<T)&&(K[te+l[x]]=i[y++]);return K}function Ut(i,o){var l=-1,p=i.length;for(o||(o=U(p));++l<p;)o[l]=i[l];return o}function Ur(i,o,l,p){var y=!l;l||(l={});for(var T=-1,x=o.length;++T<x;){var P=o[T],N=p?p(l[P],i[P],P,l,i):r;N===r&&(N=i[P]),y?fn(l,P,N):za(l,P,N)}return l}function iA(i,o){return Ur(i,hd(i),o)}function sA(i,o){return Ur(i,X_(i),o)}function sl(i,o){return function(l,p){var y=pe(l)?Ws:Sx,T=o?o():{};return y(l,i,se(p,2),T)}}function ro(i){return we(function(o,l){var p=-1,y=l.length,T=y>1?l[y-1]:r,x=y>2?l[2]:r;for(T=i.length>3&&typeof T=="function"?(y--,T):r,x&&Ot(l[0],l[1],x)&&(T=y<3?r:T,y=1),o=Ue(o);++p<y;){var P=l[p];P&&i(o,P,p,T)}return o})}function B_(i,o){return function(l,p){if(l==null)return l;if(!Bt(l))return i(l,p);for(var y=l.length,T=o?y:-1,x=Ue(l);(o?T--:++T<y)&&p(x[T],T,x)!==!1;);return l}}function j_(i){return function(o,l,p){for(var y=-1,T=Ue(o),x=p(o),P=x.length;P--;){var N=x[i?P:++y];if(l(T[N],N,T)===!1)break}return o}}function oA(i,o,l){var p=o&B,y=Qa(i);function T(){var x=this&&this!==Xe&&this instanceof T?y:i;return x.apply(p?l:this,arguments)}return T}function $_(i){return function(o){o=Ve(o);var l=Js(o)?br(o):r,p=l?l[0]:o.charAt(0),y=l?ti(l,1).join(""):o.slice(1);return p[i]()+y}}function no(i){return function(o){return Wn(By(Uy(o).replace(Pc,"")),i,"")}}function Qa(i){return function(){var o=arguments;switch(o.length){case 0:return new i;case 1:return new i(o[0]);case 2:return new i(o[0],o[1]);case 3:return new i(o[0],o[1],o[2]);case 4:return new i(o[0],o[1],o[2],o[3]);case 5:return new i(o[0],o[1],o[2],o[3],o[4]);case 6:return new i(o[0],o[1],o[2],o[3],o[4],o[5]);case 7:return new i(o[0],o[1],o[2],o[3],o[4],o[5],o[6])}var l=to(i.prototype),p=i.apply(l,o);return We(p)?p:l}}function aA(i,o,l){var p=Qa(i);function y(){for(var T=arguments.length,x=U(T),P=T,N=io(y);P--;)x[P]=arguments[P];var q=T<3&&x[0]!==N&&x[T-1]!==N?[]:Qn(x,N);if(T-=q.length,T<l)return W_(i,o,ol,y.placeholder,r,x,q,r,r,l-T);var z=this&&this!==Xe&&this instanceof y?p:i;return Et(z,this,x)}return y}function q_(i){return function(o,l,p){var y=Ue(o);if(!Bt(o)){var T=se(l,3);o=mt(o),l=function(P){return T(y[P],P,y)}}var x=i(o,l,p);return x>-1?y[T?o[x]:x]:r}}function z_(i){return pn(function(o){var l=o.length,p=l,y=ir.prototype.thru;for(i&&o.reverse();p--;){var T=o[p];if(typeof T!="function")throw new nr(s);if(y&&!x&&ll(T)=="wrapper")var x=new ir([],!0)}for(p=x?p:l;++p<l;){T=o[p];var P=ll(T),N=P=="wrapper"?cd(T):r;N&&dd(N[0])&&N[1]==(de|J|re|ie)&&!N[4].length&&N[9]==1?x=x[ll(N[0])].apply(x,N[3]):x=T.length==1&&dd(T)?x[P]():x.thru(T)}return function(){var q=arguments,z=q[0];if(x&&q.length==1&&pe(z))return x.plant(z).value();for(var K=0,Y=l?o[K].apply(this,q):z;++K<l;)Y=o[K].call(this,Y);return Y}})}function ol(i,o,l,p,y,T,x,P,N,q){var z=o&de,K=o&B,Y=o&G,te=o&(J|ee),oe=o&C,ve=Y?r:Qa(i);function ae(){for(var Te=arguments.length,Ae=U(Te),Xt=Te;Xt--;)Ae[Xt]=arguments[Xt];if(te)var kt=io(ae),Zt=Hn(Ae,kt);if(p&&(Ae=F_(Ae,p,y,te)),T&&(Ae=U_(Ae,T,x,te)),Te-=Zt,te&&Te<q){var tt=Qn(Ae,kt);return W_(i,o,ol,ae.placeholder,l,Ae,tt,P,N,q-Te)}var Ir=K?l:this,yn=Y?Ir[i]:i;return Te=Ae.length,P?Ae=SA(Ae,P):oe&&Te>1&&Ae.reverse(),z&&N<Te&&(Ae.length=N),this&&this!==Xe&&this instanceof ae&&(yn=ve||Qa(yn)),yn.apply(Ir,Ae)}return ae}function G_(i,o){return function(l,p){return Vx(l,i,o(p),{})}}function al(i,o){return function(l,p){var y;if(l===r&&p===r)return o;if(l!==r&&(y=l),p!==r){if(y===r)return p;typeof l=="string"||typeof p=="string"?(l=Jt(l),p=Jt(p)):(l=C_(l),p=C_(p)),y=i(l,p)}return y}}function sd(i){return pn(function(o){return o=Fe(o,_e(se())),we(function(l){var p=this;return i(o,function(y){return Et(y,p,l)})})})}function ul(i,o){o=o===r?" ":Jt(o);var l=o.length;if(l<2)return l?Xf(o,i):o;var p=Xf(o,Hc(i/Ys(o)));return Js(o)?ti(br(p),0,i).join(""):p.slice(0,i)}function uA(i,o,l,p){var y=o&B,T=Qa(i);function x(){for(var P=-1,N=arguments.length,q=-1,z=p.length,K=U(z+N),Y=this&&this!==Xe&&this instanceof x?T:i;++q<z;)K[q]=p[q];for(;N--;)K[q++]=arguments[++P];return Et(Y,y?l:this,K)}return x}function K_(i){return function(o,l,p){return p&&typeof p!="number"&&Ot(o,l,p)&&(l=p=r),o=_n(o),l===r?(l=o,o=0):l=_n(l),p=p===r?o<l?1:-1:_n(p),Wx(o,l,p,i)}}function cl(i){return function(o,l){return typeof o=="string"&&typeof l=="string"||(o=ur(o),l=ur(l)),i(o,l)}}function W_(i,o,l,p,y,T,x,P,N,q){var z=o&J,K=z?x:r,Y=z?r:x,te=z?T:r,oe=z?r:T;o|=z?re:le,o&=~(z?le:re),o&j||(o&=~(B|G));var ve=[i,o,y,te,K,oe,Y,P,N,q],ae=l.apply(r,ve);return dd(i)&&sy(ae,ve),ae.placeholder=p,oy(ae,i,o)}function od(i){var o=ft[i];return function(l,p){if(l=ur(l),p=p==null?0:It(ye(p),292),p&&o_(l)){var y=(Ve(l)+"e").split("e"),T=o(y[0]+"e"+(+y[1]+p));return y=(Ve(T)+"e").split("e"),+(y[0]+"e"+(+y[1]-p))}return o(l)}}var cA=Zs&&1/Fc(new Zs([,-0]))[1]==Wt?function(i){return new Zs(i)}:Rd;function H_(i){return function(o){var l=xt(o);return l==Pt?Lf(o):l==Mt?AI(o):F(o,i(o))}}function dn(i,o,l,p,y,T,x,P){var N=o&G;if(!N&&typeof i!="function")throw new nr(s);var q=p?p.length:0;if(q||(o&=~(re|le),p=y=r),x=x===r?x:dt(ye(x),0),P=P===r?P:ye(P),q-=y?y.length:0,o&le){var z=p,K=y;p=y=r}var Y=N?r:cd(i),te=[i,o,l,p,y,z,K,T,x,P];if(Y&&IA(te,Y),i=te[0],o=te[1],l=te[2],p=te[3],y=te[4],P=te[9]=te[9]===r?N?0:i.length:dt(te[9]-q,0),!P&&o&(J|ee)&&(o&=~(J|ee)),!o||o==B)var oe=oA(i,o,l);else o==J||o==ee?oe=aA(i,o,P):(o==re||o==(B|re))&&!y.length?oe=uA(i,o,l,p):oe=ol.apply(r,te);var ve=Y?R_:sy;return oy(ve(oe,te),i,o)}function Q_(i,o,l,p){return i===r||Er(i,Xs[l])&&!Me.call(p,l)?o:i}function J_(i,o,l,p,y,T){return We(i)&&We(o)&&(T.set(o,i),rl(i,o,r,J_,T),T.delete(o)),i}function lA(i){return Xa(i)?r:i}function Y_(i,o,l,p,y,T){var x=l&I,P=i.length,N=o.length;if(P!=N&&!(x&&N>P))return!1;var q=T.get(i),z=T.get(o);if(q&&z)return q==o&&z==i;var K=-1,Y=!0,te=l&k?new Yi:r;for(T.set(i,o),T.set(o,i);++K<P;){var oe=i[K],ve=o[K];if(p)var ae=x?p(ve,oe,K,o,i,T):p(oe,ve,K,i,o,T);if(ae!==r){if(ae)continue;Y=!1;break}if(te){if(!Hs(o,function(Te,Ae){if(!be(te,Ae)&&(oe===Te||y(oe,Te,l,p,T)))return te.push(Ae)})){Y=!1;break}}else if(!(oe===ve||y(oe,ve,l,p,T))){Y=!1;break}}return T.delete(i),T.delete(o),Y}function hA(i,o,l,p,y,T,x){switch(l){case Or:if(i.byteLength!=o.byteLength||i.byteOffset!=o.byteOffset)return!1;i=i.buffer,o=o.buffer;case sn:return!(i.byteLength!=o.byteLength||!T(new zc(i),new zc(o)));case Ri:case pr:case nn:return Er(+i,+o);case Ds:return i.name==o.name&&i.message==o.message;case Ci:case Ln:return i==o+"";case Pt:var P=Lf;case Mt:var N=p&I;if(P||(P=Fc),i.size!=o.size&&!N)return!1;var q=x.get(i);if(q)return q==o;p|=k,x.set(i,o);var z=Y_(P(i),P(o),p,y,T,x);return x.delete(i),z;case Mn:if(qa)return qa.call(i)==qa.call(o)}return!1}function fA(i,o,l,p,y,T){var x=l&I,P=ad(i),N=P.length,q=ad(o),z=q.length;if(N!=z&&!x)return!1;for(var K=N;K--;){var Y=P[K];if(!(x?Y in o:Me.call(o,Y)))return!1}var te=T.get(i),oe=T.get(o);if(te&&oe)return te==o&&oe==i;var ve=!0;T.set(i,o),T.set(o,i);for(var ae=x;++K<N;){Y=P[K];var Te=i[Y],Ae=o[Y];if(p)var Xt=x?p(Ae,Te,Y,o,i,T):p(Te,Ae,Y,i,o,T);if(!(Xt===r?Te===Ae||y(Te,Ae,l,p,T):Xt)){ve=!1;break}ae||(ae=Y=="constructor")}if(ve&&!ae){var kt=i.constructor,Zt=o.constructor;kt!=Zt&&"constructor"in i&&"constructor"in o&&!(typeof kt=="function"&&kt instanceof kt&&typeof Zt=="function"&&Zt instanceof Zt)&&(ve=!1)}return T.delete(i),T.delete(o),ve}function pn(i){return md(ny(i,r,fy),i+"")}function ad(i){return __(i,mt,hd)}function ud(i){return __(i,jt,X_)}var cd=Jc?function(i){return Jc.get(i)}:Rd;function ll(i){for(var o=i.name+"",l=eo[o],p=Me.call(eo,o)?l.length:0;p--;){var y=l[p],T=y.func;if(T==null||T==i)return y.name}return o}function io(i){var o=Me.call(w,"placeholder")?w:i;return o.placeholder}function se(){var i=w.iteratee||Ad;return i=i===Ad?w_:i,arguments.length?i(arguments[0],arguments[1]):i}function hl(i,o){var l=i.__data__;return wA(o)?l[typeof o=="string"?"string":"hash"]:l.map}function ld(i){for(var o=mt(i),l=o.length;l--;){var p=o[l],y=i[p];o[l]=[p,y,ty(y)]}return o}function es(i,o){var l=EI(i,o);return v_(l)?l:r}function dA(i){var o=Me.call(i,Qi),l=i[Qi];try{i[Qi]=r;var p=!0}catch{}var y=$c.call(i);return p&&(o?i[Qi]=l:delete i[Qi]),y}var hd=Ff?function(i){return i==null?[]:(i=Ue(i),yr(Ff(i),function(o){return i_.call(i,o)}))}:Pd,X_=Ff?function(i){for(var o=[];i;)vr(o,hd(i)),i=Gc(i);return o}:Pd,xt=Dt;(Uf&&xt(new Uf(new ArrayBuffer(1)))!=Or||Ba&&xt(new Ba)!=Pt||Bf&&xt(Bf.resolve())!=ma||Zs&&xt(new Zs)!=Mt||ja&&xt(new ja)!=Di)&&(xt=function(i){var o=Dt(i),l=o==Ht?i.constructor:r,p=l?ts(l):"";if(p)switch(p){case QI:return Or;case JI:return Pt;case YI:return ma;case XI:return Mt;case ZI:return Di}return o});function pA(i,o,l){for(var p=-1,y=l.length;++p<y;){var T=l[p],x=T.size;switch(T.type){case"drop":i+=x;break;case"dropRight":o-=x;break;case"take":o=It(o,i+x);break;case"takeRight":i=dt(i,o-x);break}}return{start:i,end:o}}function mA(i){var o=i.match(Ni);return o?o[1].split(Ef):[]}function Z_(i,o,l){o=ei(o,i);for(var p=-1,y=o.length,T=!1;++p<y;){var x=Br(o[p]);if(!(T=i!=null&&l(i,x)))break;i=i[x]}return T||++p!=y?T:(y=i==null?0:i.length,!!y&&yl(y)&&mn(x,y)&&(pe(i)||rs(i)))}function gA(i){var o=i.length,l=new i.constructor(o);return o&&typeof i[0]=="string"&&Me.call(i,"index")&&(l.index=i.index,l.input=i.input),l}function ey(i){return typeof i.constructor=="function"&&!Ja(i)?to(Gc(i)):{}}function _A(i,o,l){var p=i.constructor;switch(o){case sn:return id(i);case Ri:case pr:return new p(+i);case Or:return eA(i,l);case nt:case ut:case Fn:case Os:case ks:case _a:case on:case Ns:case Vs:return L_(i,l);case Pt:return new p;case nn:case Ln:return new p(i);case Ci:return tA(i);case Mt:return new p;case Mn:return rA(i)}}function yA(i,o){var l=o.length;if(!l)return i;var p=l-1;return o[p]=(l>1?"& ":"")+o[p],o=o.join(l>2?", ":" "),i.replace(ki,`{
2
2
  /* [wrapped with `+o+`] */
3
- `)}function gA(i){return pe(i)||ns(i)||!!(r_&&i&&i[r_])}function mr(i,o){var l=typeof i;return o=o==null?Cn:o,!!o&&(l=="number"||l!="symbol"&&pc.test(i))&&i>-1&&i%1==0&&i<o}function Ct(i,o,l){if(!Ke(l))return!1;var p=typeof o;return(p=="number"?Ft(l)&&mr(o,l.length):p=="string"&&o in l)?In(l[o],i):!1}function hd(i,o){if(pe(i))return!1;var l=typeof i;return l=="number"||l=="symbol"||l=="boolean"||i==null||Jt(i)?!0:Ms.test(i)||!cc.test(i)||o!=null&&i in Ue(o)}function _A(i){var o=typeof i;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?i!=="__proto__":i===null}function fd(i){var o=ul(i),l=w[o];if(typeof l!="function"||!(o in Ie.prototype))return!1;if(i===l)return!0;var p=ud(l);return!!p&&i===p[0]}function yA(i){return!!Zg&&Zg in i}var vA=Fc?gr:Pd;function Qa(i){var o=i&&i.constructor,l=typeof o=="function"&&o.prototype||Xs;return i===l}function Z_(i){return i===i&&!Ke(i)}function ey(i,o){return function(l){return l==null?!1:l[i]===o&&(o!==n||i in Ue(l))}}function wA(i){var o=pl(i,function(p){return l.size===h&&l.clear(),p}),l=o.cache;return o}function bA(i,o){var l=i[1],p=o[1],y=l|p,T=y<(B|G|de),x=p==de&&l==J||p==de&&l==ie&&i[7].length<=o[8]||p==(de|ie)&&o[7].length<=o[8]&&l==J;if(!(T||x))return i;p&B&&(i[2]=o[2],y|=l&B?0:j);var P=o[3];if(P){var N=i[3];i[3]=N?L_(N,P,o[4]):P,i[4]=N?Qr(i[3],f):o[4]}return P=o[5],P&&(N=i[5],i[5]=N?M_(N,P,o[6]):P,i[6]=N?Qr(i[5],f):o[6]),P=o[7],P&&(i[7]=P),p&de&&(i[8]=i[8]==null?o[8]:Tt(i[8],o[8])),i[9]==null&&(i[9]=o[9]),i[0]=o[0],i[1]=y,i}function TA(i){var o=[];if(i!=null)for(var l in Ue(i))o.push(l);return o}function EA(i){return Bc.call(i)}function ty(i,o,l){return o=ft(o===n?i.length-1:o,0),function(){for(var p=arguments,y=-1,T=ft(p.length-o,0),x=U(T);++y<T;)x[y]=p[o+y];y=-1;for(var P=U(o+1);++y<o;)P[y]=p[y];return P[o]=l(x),bt(i,this,P)}}function ny(i,o){return o.length<2?i:Zi(i,on(o,0,-1))}function IA(i,o){for(var l=i.length,p=Tt(o.length,l),y=Mt(i);p--;){var T=o[p];i[p]=mr(T,l)?y[T]:n}return i}function dd(i,o){if(!(o==="constructor"&&typeof i[o]=="function")&&o!="__proto__")return i[o]}var ry=sy(A_),Ja=UI||function(i,o){return Ye.setTimeout(i,o)},pd=sy(Wx);function iy(i,o,l){var p=o+"";return pd(i,mA(p,xA(fA(p),l)))}function sy(i){var o=0,l=0;return function(){var p=qI(),y=V-(p-l);if(l=p,y>0){if(++o>=D)return arguments[0]}else o=0;return i.apply(n,arguments)}}function ll(i,o){var l=-1,p=i.length,y=p-1;for(o=o===n?p:o;++l<o;){var T=Jf(l,y),x=i[T];i[T]=i[l],i[l]=x}return i.length=o,i}var oy=wA(function(i){var o=[];return i.charCodeAt(0)===46&&o.push(""),i.replace(lc,function(l,p,y,T){o.push(y?T.replace(If,"$1"):p||l)}),o});function jn(i){if(typeof i=="string"||Jt(i))return i;var o=i+"";return o=="0"&&1/i==-Kt?"-0":o}function ts(i){if(i!=null){try{return Uc.call(i)}catch{}try{return i+""}catch{}}return""}function xA(i,o){return Lt(On,function(l){var p="_."+l[0];o&l[1]&&!Ki(i,p)&&i.push(p)}),i.sort()}function ay(i){if(i instanceof Ie)return i.clone();var o=new rn(i.__wrapped__,i.__chain__);return o.__actions__=Mt(i.__actions__),o.__index__=i.__index__,o.__values__=i.__values__,o}function AA(i,o,l){(l?Ct(i,o,l):o===n)?o=1:o=ft(ye(o),0);var p=i==null?0:i.length;if(!p||o<1)return[];for(var y=0,T=0,x=U(Kc(p/o));y<p;)x[T++]=on(i,y,y+=o);return x}function SA(i){for(var o=-1,l=i==null?0:i.length,p=0,y=[];++o<l;){var T=i[o];T&&(y[p++]=T)}return y}function RA(){var i=arguments.length;if(!i)return[];for(var o=U(i-1),l=arguments[0],p=i;p--;)o[p-1]=arguments[p];return wn(pe(l)?Mt(l):[l],_t(o,1))}var PA=we(function(i,o){return Ze(i)?za(i,_t(o,1,Ze,!0)):[]}),CA=we(function(i,o){var l=an(o);return Ze(l)&&(l=n),Ze(i)?za(i,_t(o,1,Ze,!0),se(l,2)):[]}),DA=we(function(i,o){var l=an(o);return Ze(l)&&(l=n),Ze(i)?za(i,_t(o,1,Ze,!0),n,l):[]});function OA(i,o,l){var p=i==null?0:i.length;return p?(o=l||o===n?1:ye(o),on(i,o<0?0:o,p)):[]}function kA(i,o,l){var p=i==null?0:i.length;return p?(o=l||o===n?1:ye(o),o=p-o,on(i,0,o<0?0:o)):[]}function NA(i,o){return i&&i.length?nl(i,se(o,3),!0,!0):[]}function VA(i,o){return i&&i.length?nl(i,se(o,3),!0):[]}function LA(i,o,l,p){var y=i==null?0:i.length;return y?(l&&typeof l!="number"&&Ct(i,o,l)&&(l=0,p=y),Rx(i,o,l,p)):[]}function uy(i,o,l){var p=i==null?0:i.length;if(!p)return-1;var y=l==null?0:ye(l);return y<0&&(y=ft(p+y,0)),Hi(i,se(o,3),y)}function cy(i,o,l){var p=i==null?0:i.length;if(!p)return-1;var y=p-1;return l!==n&&(y=ye(l),y=l<0?ft(p+y,0):Tt(y,p-1)),Hi(i,se(o,3),y,!0)}function ly(i){var o=i==null?0:i.length;return o?_t(i,1):[]}function MA(i){var o=i==null?0:i.length;return o?_t(i,Kt):[]}function FA(i,o){var l=i==null?0:i.length;return l?(o=o===n?1:ye(o),_t(i,o)):[]}function UA(i){for(var o=-1,l=i==null?0:i.length,p={};++o<l;){var y=i[o];p[y[0]]=y[1]}return p}function hy(i){return i&&i.length?i[0]:n}function BA(i,o,l){var p=i==null?0:i.length;if(!p)return-1;var y=l==null?0:ye(l);return y<0&&(y=ft(p+y,0)),bn(i,o,y)}function jA(i){var o=i==null?0:i.length;return o?on(i,0,-1):[]}var $A=we(function(i){var o=Fe(i,td);return o.length&&o[0]===i[0]?Gf(o):[]}),qA=we(function(i){var o=an(i),l=Fe(i,td);return o===an(l)?o=n:l.pop(),l.length&&l[0]===i[0]?Gf(l,se(o,2)):[]}),zA=we(function(i){var o=an(i),l=Fe(i,td);return o=typeof o=="function"?o:n,o&&l.pop(),l.length&&l[0]===i[0]?Gf(l,n,o):[]});function GA(i,o){return i==null?"":jI.call(i,o)}function an(i){var o=i==null?0:i.length;return o?i[o-1]:n}function KA(i,o,l){var p=i==null?0:i.length;if(!p)return-1;var y=p;return l!==n&&(y=ye(l),y=y<0?ft(p+y,0):Tt(y,p-1)),o===o?xI(i,o,y):Hi(i,Va,y,!0)}function WA(i,o){return i&&i.length?T_(i,ye(o)):n}var HA=we(fy);function fy(i,o){return i&&i.length&&o&&o.length?Qf(i,o):i}function QA(i,o,l){return i&&i.length&&o&&o.length?Qf(i,o,se(l,2)):i}function JA(i,o,l){return i&&i.length&&o&&o.length?Qf(i,o,n,l):i}var YA=pr(function(i,o){var l=i==null?0:i.length,p=jf(i,o);return x_(i,Fe(o,function(y){return mr(y,l)?+y:y}).sort(V_)),p});function XA(i,o){var l=[];if(!(i&&i.length))return l;var p=-1,y=[],T=i.length;for(o=se(o,3);++p<T;){var x=i[p];o(x,p,i)&&(l.push(x),y.push(p))}return x_(i,y),l}function md(i){return i==null?i:GI.call(i)}function ZA(i,o,l){var p=i==null?0:i.length;return p?(l&&typeof l!="number"&&Ct(i,o,l)?(o=0,l=p):(o=o==null?0:ye(o),l=l===n?p:ye(l)),on(i,o,l)):[]}function eS(i,o){return tl(i,o)}function tS(i,o,l){return Xf(i,o,se(l,2))}function nS(i,o){var l=i==null?0:i.length;if(l){var p=tl(i,o);if(p<l&&In(i[p],o))return p}return-1}function rS(i,o){return tl(i,o,!0)}function iS(i,o,l){return Xf(i,o,se(l,2),!0)}function sS(i,o){var l=i==null?0:i.length;if(l){var p=tl(i,o,!0)-1;if(In(i[p],o))return p}return-1}function oS(i){return i&&i.length?S_(i):[]}function aS(i,o){return i&&i.length?S_(i,se(o,2)):[]}function uS(i){var o=i==null?0:i.length;return o?on(i,1,o):[]}function cS(i,o,l){return i&&i.length?(o=l||o===n?1:ye(o),on(i,0,o<0?0:o)):[]}function lS(i,o,l){var p=i==null?0:i.length;return p?(o=l||o===n?1:ye(o),o=p-o,on(i,o<0?0:o,p)):[]}function hS(i,o){return i&&i.length?nl(i,se(o,3),!1,!0):[]}function fS(i,o){return i&&i.length?nl(i,se(o,3)):[]}var dS=we(function(i){return Zr(_t(i,1,Ze,!0))}),pS=we(function(i){var o=an(i);return Ze(o)&&(o=n),Zr(_t(i,1,Ze,!0),se(o,2))}),mS=we(function(i){var o=an(i);return o=typeof o=="function"?o:n,Zr(_t(i,1,Ze,!0),n,o)});function gS(i){return i&&i.length?Zr(i):[]}function _S(i,o){return i&&i.length?Zr(i,se(o,2)):[]}function yS(i,o){return o=typeof o=="function"?o:n,i&&i.length?Zr(i,n,o):[]}function gd(i){if(!(i&&i.length))return[];var o=0;return i=vn(i,function(l){if(Ze(l))return o=ft(l.length,o),!0}),L(o,function(l){return Fe(i,Fn(l))})}function dy(i,o){if(!(i&&i.length))return[];var l=gd(i);return o==null?l:Fe(l,function(p){return bt(o,n,p)})}var vS=we(function(i,o){return Ze(i)?za(i,o):[]}),wS=we(function(i){return ed(vn(i,Ze))}),bS=we(function(i){var o=an(i);return Ze(o)&&(o=n),ed(vn(i,Ze),se(o,2))}),TS=we(function(i){var o=an(i);return o=typeof o=="function"?o:n,ed(vn(i,Ze),n,o)}),ES=we(gd);function IS(i,o){return D_(i||[],o||[],qa)}function xS(i,o){return D_(i||[],o||[],Wa)}var AS=we(function(i){var o=i.length,l=o>1?i[o-1]:n;return l=typeof l=="function"?(i.pop(),l):n,dy(i,l)});function py(i){var o=w(i);return o.__chain__=!0,o}function SS(i,o){return o(i),i}function hl(i,o){return o(i)}var RS=pr(function(i){var o=i.length,l=o?i[0]:0,p=this.__wrapped__,y=function(T){return jf(T,i)};return o>1||this.__actions__.length||!(p instanceof Ie)||!mr(l)?this.thru(y):(p=p.slice(l,+l+(o?1:0)),p.__actions__.push({func:hl,args:[y],thisArg:n}),new rn(p,this.__chain__).thru(function(T){return o&&!T.length&&T.push(n),T}))});function PS(){return py(this)}function CS(){return new rn(this.value(),this.__chain__)}function DS(){this.__values__===n&&(this.__values__=Ry(this.value()));var i=this.__index__>=this.__values__.length,o=i?n:this.__values__[this.__index__++];return{done:i,value:o}}function OS(){return this}function kS(i){for(var o,l=this;l instanceof Jc;){var p=ay(l);p.__index__=0,p.__values__=n,o?y.__wrapped__=p:o=p;var y=p;l=l.__wrapped__}return y.__wrapped__=i,o}function NS(){var i=this.__wrapped__;if(i instanceof Ie){var o=i;return this.__actions__.length&&(o=new Ie(this)),o=o.reverse(),o.__actions__.push({func:hl,args:[md],thisArg:n}),new rn(o,this.__chain__)}return this.thru(md)}function VS(){return C_(this.__wrapped__,this.__actions__)}var LS=rl(function(i,o,l){Me.call(i,l)?++i[l]:fr(i,l,1)});function MS(i,o,l){var p=pe(i)?Kr:Sx;return l&&Ct(i,o,l)&&(o=n),p(i,se(o,3))}function FS(i,o){var l=pe(i)?vn:d_;return l(i,se(o,3))}var US=j_(uy),BS=j_(cy);function jS(i,o){return _t(fl(i,o),1)}function $S(i,o){return _t(fl(i,o),Kt)}function qS(i,o,l){return l=l===n?1:ye(l),_t(fl(i,o),l)}function my(i,o){var l=pe(i)?Lt:Xr;return l(i,se(o,3))}function gy(i,o){var l=pe(i)?Oc:f_;return l(i,se(o,3))}var zS=rl(function(i,o,l){Me.call(i,l)?i[l].push(o):fr(i,l,[o])});function GS(i,o,l,p){i=Ft(i)?i:oo(i),l=l&&!p?ye(l):0;var y=i.length;return l<0&&(l=ft(y+l,0)),_l(i)?l<=y&&i.indexOf(o,l)>-1:!!y&&bn(i,o,l)>-1}var KS=we(function(i,o,l){var p=-1,y=typeof o=="function",T=Ft(i)?U(i.length):[];return Xr(i,function(x){T[++p]=y?bt(o,x,l):Ga(x,o,l)}),T}),WS=rl(function(i,o,l){fr(i,l,o)});function fl(i,o){var l=pe(i)?Fe:v_;return l(i,se(o,3))}function HS(i,o,l,p){return i==null?[]:(pe(o)||(o=o==null?[]:[o]),l=p?n:l,pe(l)||(l=l==null?[]:[l]),E_(i,o,l))}var QS=rl(function(i,o,l){i[l?0:1].push(o)},function(){return[[],[]]});function JS(i,o,l){var p=pe(i)?Wr:d,y=arguments.length<3;return p(i,se(o,4),l,y,Xr)}function YS(i,o,l){var p=pe(i)?kc:d,y=arguments.length<3;return p(i,se(o,4),l,y,f_)}function XS(i,o){var l=pe(i)?vn:d_;return l(i,ml(se(o,3)))}function ZS(i){var o=pe(i)?u_:Gx;return o(i)}function eR(i,o,l){(l?Ct(i,o,l):o===n)?o=1:o=ye(o);var p=pe(i)?Tx:Kx;return p(i,o)}function tR(i){var o=pe(i)?Ex:Hx;return o(i)}function nR(i){if(i==null)return 0;if(Ft(i))return _l(i)?Ys(i):i.length;var o=Et(i);return o==St||o==Vt?i.size:Wf(i).length}function rR(i,o,l){var p=pe(i)?Hs:Qx;return l&&Ct(i,o,l)&&(o=n),p(i,se(o,3))}var iR=we(function(i,o){if(i==null)return[];var l=o.length;return l>1&&Ct(i,o[0],o[1])?o=[]:l>2&&Ct(o[0],o[1],o[2])&&(o=[o[0]]),E_(i,_t(o,1),[])}),dl=FI||function(){return Ye.Date.now()};function sR(i,o){if(typeof o!="function")throw new nn(s);return i=ye(i),function(){if(--i<1)return o.apply(this,arguments)}}function _y(i,o,l){return o=l?n:o,o=i&&o==null?i.length:o,dr(i,de,n,n,n,n,o)}function yy(i,o){var l;if(typeof o!="function")throw new nn(s);return i=ye(i),function(){return--i>0&&(l=o.apply(this,arguments)),i<=1&&(o=n),l}}var _d=we(function(i,o,l){var p=B;if(l.length){var y=Qr(l,io(_d));p|=ne}return dr(i,p,o,l,y)}),vy=we(function(i,o,l){var p=B|G;if(l.length){var y=Qr(l,io(vy));p|=ne}return dr(o,p,i,l,y)});function wy(i,o,l){o=l?n:o;var p=dr(i,J,n,n,n,n,n,o);return p.placeholder=wy.placeholder,p}function by(i,o,l){o=l?n:o;var p=dr(i,ee,n,n,n,n,n,o);return p.placeholder=by.placeholder,p}function Ty(i,o,l){var p,y,T,x,P,N,q=0,z=!1,K=!1,Y=!0;if(typeof i!="function")throw new nn(s);o=un(o)||0,Ke(l)&&(z=!!l.leading,K="maxWait"in l,T=K?ft(un(l.maxWait)||0,o):T,Y="trailing"in l?!!l.trailing:Y);function te(et){var xn=p,yr=y;return p=y=n,q=et,x=i.apply(yr,xn),x}function oe(et){return q=et,P=Ja(Te,o),z?te(et):x}function ve(et){var xn=et-N,yr=et-q,jy=o-xn;return K?Tt(jy,T-yr):jy}function ae(et){var xn=et-N,yr=et-q;return N===n||xn>=o||xn<0||K&&yr>=T}function Te(){var et=dl();if(ae(et))return Ae(et);P=Ja(Te,ve(et))}function Ae(et){return P=n,Y&&p?te(et):(p=y=n,x)}function Yt(){P!==n&&O_(P),q=0,p=N=y=P=n}function Dt(){return P===n?x:Ae(dl())}function Xt(){var et=dl(),xn=ae(et);if(p=arguments,y=this,N=et,xn){if(P===n)return oe(N);if(K)return O_(P),P=Ja(Te,o),te(N)}return P===n&&(P=Ja(Te,o)),x}return Xt.cancel=Yt,Xt.flush=Dt,Xt}var oR=we(function(i,o){return h_(i,1,o)}),aR=we(function(i,o,l){return h_(i,un(o)||0,l)});function uR(i){return dr(i,C)}function pl(i,o){if(typeof i!="function"||o!=null&&typeof o!="function")throw new nn(s);var l=function(){var p=arguments,y=o?o.apply(this,p):p[0],T=l.cache;if(T.has(y))return T.get(y);var x=i.apply(this,p);return l.cache=T.set(y,x)||T,x};return l.cache=new(pl.Cache||hr),l}pl.Cache=hr;function ml(i){if(typeof i!="function")throw new nn(s);return function(){var o=arguments;switch(o.length){case 0:return!i.call(this);case 1:return!i.call(this,o[0]);case 2:return!i.call(this,o[0],o[1]);case 3:return!i.call(this,o[0],o[1],o[2])}return!i.apply(this,o)}}function cR(i){return yy(2,i)}var lR=Jx(function(i,o){o=o.length==1&&pe(o[0])?Fe(o[0],_e(se())):Fe(_t(o,1),_e(se()));var l=o.length;return we(function(p){for(var y=-1,T=Tt(p.length,l);++y<T;)p[y]=o[y].call(this,p[y]);return bt(i,this,p)})}),yd=we(function(i,o){var l=Qr(o,io(yd));return dr(i,ne,n,o,l)}),Ey=we(function(i,o){var l=Qr(o,io(Ey));return dr(i,le,n,o,l)}),hR=pr(function(i,o){return dr(i,ie,n,n,n,o)});function fR(i,o){if(typeof i!="function")throw new nn(s);return o=o===n?o:ye(o),we(i,o)}function dR(i,o){if(typeof i!="function")throw new nn(s);return o=o==null?0:ft(ye(o),0),we(function(l){var p=l[o],y=ti(l,0,o);return p&&wn(y,p),bt(i,this,y)})}function pR(i,o,l){var p=!0,y=!0;if(typeof i!="function")throw new nn(s);return Ke(l)&&(p="leading"in l?!!l.leading:p,y="trailing"in l?!!l.trailing:y),Ty(i,o,{leading:p,maxWait:o,trailing:y})}function mR(i){return _y(i,1)}function gR(i,o){return yd(nd(o),i)}function _R(){if(!arguments.length)return[];var i=arguments[0];return pe(i)?i:[i]}function yR(i){return sn(i,E)}function vR(i,o){return o=typeof o=="function"?o:n,sn(i,E,o)}function wR(i){return sn(i,m|E)}function bR(i,o){return o=typeof o=="function"?o:n,sn(i,m|E,o)}function TR(i,o){return o==null||l_(i,o,pt(o))}function In(i,o){return i===o||i!==i&&o!==o}var ER=al(zf),IR=al(function(i,o){return i>=o}),ns=g_(function(){return arguments}())?g_:function(i){return He(i)&&Me.call(i,"callee")&&!n_.call(i,"callee")},pe=U.isArray,xR=Oa?_e(Oa):kx;function Ft(i){return i!=null&&gl(i.length)&&!gr(i)}function Ze(i){return He(i)&&Ft(i)}function AR(i){return i===!0||i===!1||He(i)&&Pt(i)==Ri}var ni=BI||Pd,SR=Dc?_e(Dc):Nx;function RR(i){return He(i)&&i.nodeType===1&&!Ya(i)}function PR(i){if(i==null)return!0;if(Ft(i)&&(pe(i)||typeof i=="string"||typeof i.splice=="function"||ni(i)||so(i)||ns(i)))return!i.length;var o=Et(i);if(o==St||o==Vt)return!i.size;if(Qa(i))return!Wf(i).length;for(var l in i)if(Me.call(i,l))return!1;return!0}function CR(i,o){return Ka(i,o)}function DR(i,o,l){l=typeof l=="function"?l:n;var p=l?l(i,o):n;return p===n?Ka(i,o,n,l):!!p}function vd(i){if(!He(i))return!1;var o=Pt(i);return o==Ds||o==vf||typeof i.message=="string"&&typeof i.name=="string"&&!Ya(i)}function OR(i){return typeof i=="number"&&i_(i)}function gr(i){if(!Ke(i))return!1;var o=Pt(i);return o==rr||o==Pi||o==Si||o==oc}function Iy(i){return typeof i=="number"&&i==ye(i)}function gl(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=Cn}function Ke(i){var o=typeof i;return i!=null&&(o=="object"||o=="function")}function He(i){return i!=null&&typeof i=="object"}var xy=Gr?_e(Gr):Lx;function kR(i,o){return i===o||Kf(i,o,cd(o))}function NR(i,o,l){return l=typeof l=="function"?l:n,Kf(i,o,cd(o),l)}function VR(i){return Ay(i)&&i!=+i}function LR(i){if(vA(i))throw new he(r);return __(i)}function MR(i){return i===null}function FR(i){return i==null}function Ay(i){return typeof i=="number"||He(i)&&Pt(i)==ir}function Ya(i){if(!He(i)||Pt(i)!=Wt)return!1;var o=qc(i);if(o===null)return!0;var l=Me.call(o,"constructor")&&o.constructor;return typeof l=="function"&&l instanceof l&&Uc.call(l)==NI}var wd=ka?_e(ka):Mx;function UR(i){return Iy(i)&&i>=-Cn&&i<=Cn}var Sy=Ks?_e(Ks):Fx;function _l(i){return typeof i=="string"||!pe(i)&&He(i)&&Pt(i)==Lr}function Jt(i){return typeof i=="symbol"||He(i)&&Pt(i)==Mr}var so=Gi?_e(Gi):Ux;function BR(i){return i===n}function jR(i){return He(i)&&Et(i)==Di}function $R(i){return He(i)&&Pt(i)==ma}var qR=al(Hf),zR=al(function(i,o){return i<=o});function Ry(i){if(!i)return[];if(Ft(i))return _l(i)?Tn(i):Mt(i);if(Fa&&i[Fa])return TI(i[Fa]());var o=Et(i),l=o==St?Vf:o==Vt?Lc:oo;return l(i)}function _r(i){if(!i)return i===0?i:0;if(i=un(i),i===Kt||i===-Kt){var o=i<0?-1:1;return o*Ai}return i===i?i:0}function ye(i){var o=_r(i),l=o%1;return o===o?l?o-l:o:0}function Py(i){return i?Xi(ye(i),0,Nt):0}function un(i){if(typeof i=="number")return i;if(Jt(i))return Dn;if(Ke(i)){var o=typeof i.valueOf=="function"?i.valueOf():i;i=Ke(o)?o+"":o}if(typeof i!="string")return i===0?i:+i;i=Q(i);var l=ba.test(i);return l||Vn.test(i)?qe(i.slice(2),l?2:8):dc.test(i)?Dn:+i}function Cy(i){return Bn(i,Ut(i))}function GR(i){return i?Xi(ye(i),-Cn,Cn):i===0?i:0}function Ve(i){return i==null?"":Qt(i)}var KR=no(function(i,o){if(Qa(o)||Ft(o)){Bn(o,pt(o),i);return}for(var l in o)Me.call(o,l)&&qa(i,l,o[l])}),Dy=no(function(i,o){Bn(o,Ut(o),i)}),yl=no(function(i,o,l,p){Bn(o,Ut(o),i,p)}),WR=no(function(i,o,l,p){Bn(o,pt(o),i,p)}),HR=pr(jf);function QR(i,o){var l=to(i);return o==null?l:c_(l,o)}var JR=we(function(i,o){i=Ue(i);var l=-1,p=o.length,y=p>2?o[2]:n;for(y&&Ct(o[0],o[1],y)&&(p=1);++l<p;)for(var T=o[l],x=Ut(T),P=-1,N=x.length;++P<N;){var q=x[P],z=i[q];(z===n||In(z,Xs[q])&&!Me.call(i,q))&&(i[q]=T[q])}return i}),YR=we(function(i){return i.push(n,H_),bt(Oy,n,i)});function XR(i,o){return Na(i,se(o,3),Un)}function ZR(i,o){return Na(i,se(o,3),qf)}function e1(i,o){return i==null?i:$f(i,se(o,3),Ut)}function t1(i,o){return i==null?i:p_(i,se(o,3),Ut)}function n1(i,o){return i&&Un(i,se(o,3))}function r1(i,o){return i&&qf(i,se(o,3))}function i1(i){return i==null?[]:Zc(i,pt(i))}function s1(i){return i==null?[]:Zc(i,Ut(i))}function bd(i,o,l){var p=i==null?n:Zi(i,o);return p===n?l:p}function o1(i,o){return i!=null&&Y_(i,o,Px)}function Td(i,o){return i!=null&&Y_(i,o,Cx)}var a1=q_(function(i,o,l){o!=null&&typeof o.toString!="function"&&(o=Bc.call(o)),i[o]=l},Id(Bt)),u1=q_(function(i,o,l){o!=null&&typeof o.toString!="function"&&(o=Bc.call(o)),Me.call(i,o)?i[o].push(l):i[o]=[l]},se),c1=we(Ga);function pt(i){return Ft(i)?a_(i):Wf(i)}function Ut(i){return Ft(i)?a_(i,!0):Bx(i)}function l1(i,o){var l={};return o=se(o,3),Un(i,function(p,y,T){fr(l,o(p,y,T),p)}),l}function h1(i,o){var l={};return o=se(o,3),Un(i,function(p,y,T){fr(l,y,o(p,y,T))}),l}var f1=no(function(i,o,l){el(i,o,l)}),Oy=no(function(i,o,l,p){el(i,o,l,p)}),d1=pr(function(i,o){var l={};if(i==null)return l;var p=!1;o=Fe(o,function(T){return T=ei(T,i),p||(p=T.length>1),T}),Bn(i,ad(i),l),p&&(l=sn(l,m|_|E,aA));for(var y=o.length;y--;)Zf(l,o[y]);return l});function p1(i,o){return ky(i,ml(se(o)))}var m1=pr(function(i,o){return i==null?{}:$x(i,o)});function ky(i,o){if(i==null)return{};var l=Fe(ad(i),function(p){return[p]});return o=se(o),I_(i,l,function(p,y){return o(p,y[0])})}function g1(i,o,l){o=ei(o,i);var p=-1,y=o.length;for(y||(y=1,i=n);++p<y;){var T=i==null?n:i[jn(o[p])];T===n&&(p=y,T=l),i=gr(T)?T.call(i):T}return i}function _1(i,o,l){return i==null?i:Wa(i,o,l)}function y1(i,o,l,p){return p=typeof p=="function"?p:n,i==null?i:Wa(i,o,l,p)}var Ny=K_(pt),Vy=K_(Ut);function v1(i,o,l){var p=pe(i),y=p||ni(i)||so(i);if(o=se(o,4),l==null){var T=i&&i.constructor;y?l=p?new T:[]:Ke(i)?l=gr(T)?to(qc(i)):{}:l={}}return(y?Lt:Un)(i,function(x,P,N){return o(l,x,P,N)}),l}function w1(i,o){return i==null?!0:Zf(i,o)}function b1(i,o,l){return i==null?i:P_(i,o,nd(l))}function T1(i,o,l,p){return p=typeof p=="function"?p:n,i==null?i:P_(i,o,nd(l),p)}function oo(i){return i==null?[]:Xe(i,pt(i))}function E1(i){return i==null?[]:Xe(i,Ut(i))}function I1(i,o,l){return l===n&&(l=o,o=n),l!==n&&(l=un(l),l=l===l?l:0),o!==n&&(o=un(o),o=o===o?o:0),Xi(un(i),o,l)}function x1(i,o,l){return o=_r(o),l===n?(l=o,o=0):l=_r(l),i=un(i),Dx(i,o,l)}function A1(i,o,l){if(l&&typeof l!="boolean"&&Ct(i,o,l)&&(o=l=n),l===n&&(typeof o=="boolean"?(l=o,o=n):typeof i=="boolean"&&(l=i,i=n)),i===n&&o===n?(i=0,o=1):(i=_r(i),o===n?(o=i,i=0):o=_r(o)),i>o){var p=i;i=o,o=p}if(l||i%1||o%1){var y=s_();return Tt(i+y*(o-i+Da("1e-"+((y+"").length-1))),o)}return Jf(i,o)}var S1=ro(function(i,o,l){return o=o.toLowerCase(),i+(l?Ly(o):o)});function Ly(i){return Ed(Ve(i).toLowerCase())}function My(i){return i=Ve(i),i&&i.replace(mc,Ht).replace(zr,"")}function R1(i,o,l){i=Ve(i),o=Qt(o);var p=i.length;l=l===n?p:Xi(ye(l),0,p);var y=l;return l-=o.length,l>=0&&i.slice(l,y)==o}function P1(i){return i=Ve(i),i&&Oi.test(i)?i.replace(ya,Qs):i}function C1(i){return i=Ve(i),i&&hc.test(i)?i.replace(ar,"\\$&"):i}var D1=ro(function(i,o,l){return i+(l?"-":"")+o.toLowerCase()}),O1=ro(function(i,o,l){return i+(l?" ":"")+o.toLowerCase()}),k1=B_("toLowerCase");function N1(i,o,l){i=Ve(i),o=ye(o);var p=o?Ys(i):0;if(!o||p>=o)return i;var y=(o-p)/2;return ol(Wc(y),l)+i+ol(Kc(y),l)}function V1(i,o,l){i=Ve(i),o=ye(o);var p=o?Ys(i):0;return o&&p<o?i+ol(o-p,l):i}function L1(i,o,l){i=Ve(i),o=ye(o);var p=o?Ys(i):0;return o&&p<o?ol(o-p,l)+i:i}function M1(i,o,l){return l||o==null?o=0:o&&(o=+o),zI(Ve(i).replace(ut,""),o||0)}function F1(i,o,l){return(l?Ct(i,o,l):o===n)?o=1:o=ye(o),Yf(Ve(i),o)}function U1(){var i=arguments,o=Ve(i[0]);return i.length<3?o:o.replace(i[1],i[2])}var B1=ro(function(i,o,l){return i+(l?"_":"")+o.toLowerCase()});function j1(i,o,l){return l&&typeof l!="number"&&Ct(i,o,l)&&(o=l=n),l=l===n?Nt:l>>>0,l?(i=Ve(i),i&&(typeof o=="string"||o!=null&&!wd(o))&&(o=Qt(o),!o&&Js(i))?ti(Tn(i),0,l):i.split(o,l)):[]}var $1=ro(function(i,o,l){return i+(l?" ":"")+Ed(o)});function q1(i,o,l){return i=Ve(i),l=l==null?0:Xi(ye(l),0,i.length),o=Qt(o),i.slice(l,l+o.length)==o}function z1(i,o,l){var p=w.templateSettings;l&&Ct(i,o,l)&&(o=n),i=Ve(i),o=yl({},o,p,W_);var y=yl({},o.imports,p.imports,W_),T=pt(y),x=Xe(y,T),P,N,q=0,z=o.interpolate||Br,K="__p += '",Y=Lf((o.escape||Br).source+"|"+z.source+"|"+(z===Nn?xf:Br).source+"|"+(o.evaluate||Br).source+"|$","g"),te="//# sourceURL="+(Me.call(o,"sourceURL")?(o.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++kf+"]")+`
4
- `;i.replace(Y,function(ae,Te,Ae,Yt,Dt,Xt){return Ae||(Ae=Yt),K+=i.slice(q,Xt).replace(Ta,Ma),Te&&(P=!0,K+=`' +
3
+ `)}function vA(i){return pe(i)||rs(i)||!!(s_&&i&&i[s_])}function mn(i,o){var l=typeof i;return o=o==null?Pr:o,!!o&&(l=="number"||l!="symbol"&&gc.test(i))&&i>-1&&i%1==0&&i<o}function Ot(i,o,l){if(!We(l))return!1;var p=typeof o;return(p=="number"?Bt(l)&&mn(o,l.length):p=="string"&&o in l)?Er(l[o],i):!1}function fd(i,o){if(pe(i))return!1;var l=typeof i;return l=="number"||l=="symbol"||l=="boolean"||i==null||Yt(i)?!0:Ms.test(i)||!hc.test(i)||o!=null&&i in Ue(o)}function wA(i){var o=typeof i;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?i!=="__proto__":i===null}function dd(i){var o=ll(i),l=w[o];if(typeof l!="function"||!(o in Ie.prototype))return!1;if(i===l)return!0;var p=cd(l);return!!p&&i===p[0]}function bA(i){return!!t_&&t_ in i}var TA=Bc?gn:Cd;function Ja(i){var o=i&&i.constructor,l=typeof o=="function"&&o.prototype||Xs;return i===l}function ty(i){return i===i&&!We(i)}function ry(i,o){return function(l){return l==null?!1:l[i]===o&&(o!==r||i in Ue(l))}}function EA(i){var o=gl(i,function(p){return l.size===h&&l.clear(),p}),l=o.cache;return o}function IA(i,o){var l=i[1],p=o[1],y=l|p,T=y<(B|G|de),x=p==de&&l==J||p==de&&l==ie&&i[7].length<=o[8]||p==(de|ie)&&o[7].length<=o[8]&&l==J;if(!(T||x))return i;p&B&&(i[2]=o[2],y|=l&B?0:j);var P=o[3];if(P){var N=i[3];i[3]=N?F_(N,P,o[4]):P,i[4]=N?Qn(i[3],f):o[4]}return P=o[5],P&&(N=i[5],i[5]=N?U_(N,P,o[6]):P,i[6]=N?Qn(i[5],f):o[6]),P=o[7],P&&(i[7]=P),p&de&&(i[8]=i[8]==null?o[8]:It(i[8],o[8])),i[9]==null&&(i[9]=o[9]),i[0]=o[0],i[1]=y,i}function xA(i){var o=[];if(i!=null)for(var l in Ue(i))o.push(l);return o}function AA(i){return $c.call(i)}function ny(i,o,l){return o=dt(o===r?i.length-1:o,0),function(){for(var p=arguments,y=-1,T=dt(p.length-o,0),x=U(T);++y<T;)x[y]=p[o+y];y=-1;for(var P=U(o+1);++y<o;)P[y]=p[y];return P[o]=l(x),Et(i,this,P)}}function iy(i,o){return o.length<2?i:Zi(i,or(o,0,-1))}function SA(i,o){for(var l=i.length,p=It(o.length,l),y=Ut(i);p--;){var T=o[p];i[p]=mn(T,l)?y[T]:r}return i}function pd(i,o){if(!(o==="constructor"&&typeof i[o]=="function")&&o!="__proto__")return i[o]}var sy=ay(R_),Ya=$I||function(i,o){return Xe.setTimeout(i,o)},md=ay(Jx);function oy(i,o,l){var p=o+"";return md(i,yA(p,RA(mA(p),l)))}function ay(i){var o=0,l=0;return function(){var p=KI(),y=V-(p-l);if(l=p,y>0){if(++o>=D)return arguments[0]}else o=0;return i.apply(r,arguments)}}function fl(i,o){var l=-1,p=i.length,y=p-1;for(o=o===r?p:o;++l<o;){var T=Yf(l,y),x=i[T];i[T]=i[l],i[l]=x}return i.length=o,i}var uy=EA(function(i){var o=[];return i.charCodeAt(0)===46&&o.push(""),i.replace(fc,function(l,p,y,T){o.push(y?T.replace(xf,"$1"):p||l)}),o});function Br(i){if(typeof i=="string"||Yt(i))return i;var o=i+"";return o=="0"&&1/i==-Wt?"-0":o}function ts(i){if(i!=null){try{return jc.call(i)}catch{}try{return i+""}catch{}}return""}function RA(i,o){return Ft(Dr,function(l){var p="_."+l[0];o&l[1]&&!Ki(i,p)&&i.push(p)}),i.sort()}function cy(i){if(i instanceof Ie)return i.clone();var o=new ir(i.__wrapped__,i.__chain__);return o.__actions__=Ut(i.__actions__),o.__index__=i.__index__,o.__values__=i.__values__,o}function PA(i,o,l){(l?Ot(i,o,l):o===r)?o=1:o=dt(ye(o),0);var p=i==null?0:i.length;if(!p||o<1)return[];for(var y=0,T=0,x=U(Hc(p/o));y<p;)x[T++]=or(i,y,y+=o);return x}function CA(i){for(var o=-1,l=i==null?0:i.length,p=0,y=[];++o<l;){var T=i[o];T&&(y[p++]=T)}return y}function DA(){var i=arguments.length;if(!i)return[];for(var o=U(i-1),l=arguments[0],p=i;p--;)o[p-1]=arguments[p];return vr(pe(l)?Ut(l):[l],vt(o,1))}var OA=we(function(i,o){return et(i)?Ga(i,vt(o,1,et,!0)):[]}),kA=we(function(i,o){var l=ar(o);return et(l)&&(l=r),et(i)?Ga(i,vt(o,1,et,!0),se(l,2)):[]}),NA=we(function(i,o){var l=ar(o);return et(l)&&(l=r),et(i)?Ga(i,vt(o,1,et,!0),r,l):[]});function VA(i,o,l){var p=i==null?0:i.length;return p?(o=l||o===r?1:ye(o),or(i,o<0?0:o,p)):[]}function LA(i,o,l){var p=i==null?0:i.length;return p?(o=l||o===r?1:ye(o),o=p-o,or(i,0,o<0?0:o)):[]}function MA(i,o){return i&&i.length?il(i,se(o,3),!0,!0):[]}function FA(i,o){return i&&i.length?il(i,se(o,3),!0):[]}function UA(i,o,l,p){var y=i==null?0:i.length;return y?(l&&typeof l!="number"&&Ot(i,o,l)&&(l=0,p=y),Dx(i,o,l,p)):[]}function ly(i,o,l){var p=i==null?0:i.length;if(!p)return-1;var y=l==null?0:ye(l);return y<0&&(y=dt(p+y,0)),Hi(i,se(o,3),y)}function hy(i,o,l){var p=i==null?0:i.length;if(!p)return-1;var y=p-1;return l!==r&&(y=ye(l),y=l<0?dt(p+y,0):It(y,p-1)),Hi(i,se(o,3),y,!0)}function fy(i){var o=i==null?0:i.length;return o?vt(i,1):[]}function BA(i){var o=i==null?0:i.length;return o?vt(i,Wt):[]}function jA(i,o){var l=i==null?0:i.length;return l?(o=o===r?1:ye(o),vt(i,o)):[]}function $A(i){for(var o=-1,l=i==null?0:i.length,p={};++o<l;){var y=i[o];p[y[0]]=y[1]}return p}function dy(i){return i&&i.length?i[0]:r}function qA(i,o,l){var p=i==null?0:i.length;if(!p)return-1;var y=l==null?0:ye(l);return y<0&&(y=dt(p+y,0)),wr(i,o,y)}function zA(i){var o=i==null?0:i.length;return o?or(i,0,-1):[]}var GA=we(function(i){var o=Fe(i,rd);return o.length&&o[0]===i[0]?Kf(o):[]}),KA=we(function(i){var o=ar(i),l=Fe(i,rd);return o===ar(l)?o=r:l.pop(),l.length&&l[0]===i[0]?Kf(l,se(o,2)):[]}),WA=we(function(i){var o=ar(i),l=Fe(i,rd);return o=typeof o=="function"?o:r,o&&l.pop(),l.length&&l[0]===i[0]?Kf(l,r,o):[]});function HA(i,o){return i==null?"":zI.call(i,o)}function ar(i){var o=i==null?0:i.length;return o?i[o-1]:r}function QA(i,o,l){var p=i==null?0:i.length;if(!p)return-1;var y=p;return l!==r&&(y=ye(l),y=y<0?dt(p+y,0):It(y,p-1)),o===o?RI(i,o,y):Hi(i,La,y,!0)}function JA(i,o){return i&&i.length?I_(i,ye(o)):r}var YA=we(py);function py(i,o){return i&&i.length&&o&&o.length?Jf(i,o):i}function XA(i,o,l){return i&&i.length&&o&&o.length?Jf(i,o,se(l,2)):i}function ZA(i,o,l){return i&&i.length&&o&&o.length?Jf(i,o,r,l):i}var eS=pn(function(i,o){var l=i==null?0:i.length,p=$f(i,o);return S_(i,Fe(o,function(y){return mn(y,l)?+y:y}).sort(M_)),p});function tS(i,o){var l=[];if(!(i&&i.length))return l;var p=-1,y=[],T=i.length;for(o=se(o,3);++p<T;){var x=i[p];o(x,p,i)&&(l.push(x),y.push(p))}return S_(i,y),l}function gd(i){return i==null?i:HI.call(i)}function rS(i,o,l){var p=i==null?0:i.length;return p?(l&&typeof l!="number"&&Ot(i,o,l)?(o=0,l=p):(o=o==null?0:ye(o),l=l===r?p:ye(l)),or(i,o,l)):[]}function nS(i,o){return nl(i,o)}function iS(i,o,l){return Zf(i,o,se(l,2))}function sS(i,o){var l=i==null?0:i.length;if(l){var p=nl(i,o);if(p<l&&Er(i[p],o))return p}return-1}function oS(i,o){return nl(i,o,!0)}function aS(i,o,l){return Zf(i,o,se(l,2),!0)}function uS(i,o){var l=i==null?0:i.length;if(l){var p=nl(i,o,!0)-1;if(Er(i[p],o))return p}return-1}function cS(i){return i&&i.length?P_(i):[]}function lS(i,o){return i&&i.length?P_(i,se(o,2)):[]}function hS(i){var o=i==null?0:i.length;return o?or(i,1,o):[]}function fS(i,o,l){return i&&i.length?(o=l||o===r?1:ye(o),or(i,0,o<0?0:o)):[]}function dS(i,o,l){var p=i==null?0:i.length;return p?(o=l||o===r?1:ye(o),o=p-o,or(i,o<0?0:o,p)):[]}function pS(i,o){return i&&i.length?il(i,se(o,3),!1,!0):[]}function mS(i,o){return i&&i.length?il(i,se(o,3)):[]}var gS=we(function(i){return Zn(vt(i,1,et,!0))}),_S=we(function(i){var o=ar(i);return et(o)&&(o=r),Zn(vt(i,1,et,!0),se(o,2))}),yS=we(function(i){var o=ar(i);return o=typeof o=="function"?o:r,Zn(vt(i,1,et,!0),r,o)});function vS(i){return i&&i.length?Zn(i):[]}function wS(i,o){return i&&i.length?Zn(i,se(o,2)):[]}function bS(i,o){return o=typeof o=="function"?o:r,i&&i.length?Zn(i,r,o):[]}function _d(i){if(!(i&&i.length))return[];var o=0;return i=yr(i,function(l){if(et(l))return o=dt(l.length,o),!0}),L(o,function(l){return Fe(i,Mr(l))})}function my(i,o){if(!(i&&i.length))return[];var l=_d(i);return o==null?l:Fe(l,function(p){return Et(o,r,p)})}var TS=we(function(i,o){return et(i)?Ga(i,o):[]}),ES=we(function(i){return td(yr(i,et))}),IS=we(function(i){var o=ar(i);return et(o)&&(o=r),td(yr(i,et),se(o,2))}),xS=we(function(i){var o=ar(i);return o=typeof o=="function"?o:r,td(yr(i,et),r,o)}),AS=we(_d);function SS(i,o){return k_(i||[],o||[],za)}function RS(i,o){return k_(i||[],o||[],Ha)}var PS=we(function(i){var o=i.length,l=o>1?i[o-1]:r;return l=typeof l=="function"?(i.pop(),l):r,my(i,l)});function gy(i){var o=w(i);return o.__chain__=!0,o}function CS(i,o){return o(i),i}function dl(i,o){return o(i)}var DS=pn(function(i){var o=i.length,l=o?i[0]:0,p=this.__wrapped__,y=function(T){return $f(T,i)};return o>1||this.__actions__.length||!(p instanceof Ie)||!mn(l)?this.thru(y):(p=p.slice(l,+l+(o?1:0)),p.__actions__.push({func:dl,args:[y],thisArg:r}),new ir(p,this.__chain__).thru(function(T){return o&&!T.length&&T.push(r),T}))});function OS(){return gy(this)}function kS(){return new ir(this.value(),this.__chain__)}function NS(){this.__values__===r&&(this.__values__=Cy(this.value()));var i=this.__index__>=this.__values__.length,o=i?r:this.__values__[this.__index__++];return{done:i,value:o}}function VS(){return this}function LS(i){for(var o,l=this;l instanceof Xc;){var p=cy(l);p.__index__=0,p.__values__=r,o?y.__wrapped__=p:o=p;var y=p;l=l.__wrapped__}return y.__wrapped__=i,o}function MS(){var i=this.__wrapped__;if(i instanceof Ie){var o=i;return this.__actions__.length&&(o=new Ie(this)),o=o.reverse(),o.__actions__.push({func:dl,args:[gd],thisArg:r}),new ir(o,this.__chain__)}return this.thru(gd)}function FS(){return O_(this.__wrapped__,this.__actions__)}var US=sl(function(i,o,l){Me.call(i,l)?++i[l]:fn(i,l,1)});function BS(i,o,l){var p=pe(i)?Kn:Cx;return l&&Ot(i,o,l)&&(o=r),p(i,se(o,3))}function jS(i,o){var l=pe(i)?yr:m_;return l(i,se(o,3))}var $S=q_(ly),qS=q_(hy);function zS(i,o){return vt(pl(i,o),1)}function GS(i,o){return vt(pl(i,o),Wt)}function KS(i,o,l){return l=l===r?1:ye(l),vt(pl(i,o),l)}function _y(i,o){var l=pe(i)?Ft:Xn;return l(i,se(o,3))}function yy(i,o){var l=pe(i)?Nc:p_;return l(i,se(o,3))}var WS=sl(function(i,o,l){Me.call(i,l)?i[l].push(o):fn(i,l,[o])});function HS(i,o,l,p){i=Bt(i)?i:oo(i),l=l&&!p?ye(l):0;var y=i.length;return l<0&&(l=dt(y+l,0)),vl(i)?l<=y&&i.indexOf(o,l)>-1:!!y&&wr(i,o,l)>-1}var QS=we(function(i,o,l){var p=-1,y=typeof o=="function",T=Bt(i)?U(i.length):[];return Xn(i,function(x){T[++p]=y?Et(o,x,l):Ka(x,o,l)}),T}),JS=sl(function(i,o,l){fn(i,l,o)});function pl(i,o){var l=pe(i)?Fe:b_;return l(i,se(o,3))}function YS(i,o,l,p){return i==null?[]:(pe(o)||(o=o==null?[]:[o]),l=p?r:l,pe(l)||(l=l==null?[]:[l]),x_(i,o,l))}var XS=sl(function(i,o,l){i[l?0:1].push(o)},function(){return[[],[]]});function ZS(i,o,l){var p=pe(i)?Wn:d,y=arguments.length<3;return p(i,se(o,4),l,y,Xn)}function e1(i,o,l){var p=pe(i)?Vc:d,y=arguments.length<3;return p(i,se(o,4),l,y,p_)}function t1(i,o){var l=pe(i)?yr:m_;return l(i,_l(se(o,3)))}function r1(i){var o=pe(i)?l_:Hx;return o(i)}function n1(i,o,l){(l?Ot(i,o,l):o===r)?o=1:o=ye(o);var p=pe(i)?xx:Qx;return p(i,o)}function i1(i){var o=pe(i)?Ax:Yx;return o(i)}function s1(i){if(i==null)return 0;if(Bt(i))return vl(i)?Ys(i):i.length;var o=xt(i);return o==Pt||o==Mt?i.size:Hf(i).length}function o1(i,o,l){var p=pe(i)?Hs:Xx;return l&&Ot(i,o,l)&&(o=r),p(i,se(o,3))}var a1=we(function(i,o){if(i==null)return[];var l=o.length;return l>1&&Ot(i,o[0],o[1])?o=[]:l>2&&Ot(o[0],o[1],o[2])&&(o=[o[0]]),x_(i,vt(o,1),[])}),ml=jI||function(){return Xe.Date.now()};function u1(i,o){if(typeof o!="function")throw new nr(s);return i=ye(i),function(){if(--i<1)return o.apply(this,arguments)}}function vy(i,o,l){return o=l?r:o,o=i&&o==null?i.length:o,dn(i,de,r,r,r,r,o)}function wy(i,o){var l;if(typeof o!="function")throw new nr(s);return i=ye(i),function(){return--i>0&&(l=o.apply(this,arguments)),i<=1&&(o=r),l}}var yd=we(function(i,o,l){var p=B;if(l.length){var y=Qn(l,io(yd));p|=re}return dn(i,p,o,l,y)}),by=we(function(i,o,l){var p=B|G;if(l.length){var y=Qn(l,io(by));p|=re}return dn(o,p,i,l,y)});function Ty(i,o,l){o=l?r:o;var p=dn(i,J,r,r,r,r,r,o);return p.placeholder=Ty.placeholder,p}function Ey(i,o,l){o=l?r:o;var p=dn(i,ee,r,r,r,r,r,o);return p.placeholder=Ey.placeholder,p}function Iy(i,o,l){var p,y,T,x,P,N,q=0,z=!1,K=!1,Y=!0;if(typeof i!="function")throw new nr(s);o=ur(o)||0,We(l)&&(z=!!l.leading,K="maxWait"in l,T=K?dt(ur(l.maxWait)||0,o):T,Y="trailing"in l?!!l.trailing:Y);function te(tt){var Ir=p,yn=y;return p=y=r,q=tt,x=i.apply(yn,Ir),x}function oe(tt){return q=tt,P=Ya(Te,o),z?te(tt):x}function ve(tt){var Ir=tt-N,yn=tt-q,qy=o-Ir;return K?It(qy,T-yn):qy}function ae(tt){var Ir=tt-N,yn=tt-q;return N===r||Ir>=o||Ir<0||K&&yn>=T}function Te(){var tt=ml();if(ae(tt))return Ae(tt);P=Ya(Te,ve(tt))}function Ae(tt){return P=r,Y&&p?te(tt):(p=y=r,x)}function Xt(){P!==r&&N_(P),q=0,p=N=y=P=r}function kt(){return P===r?x:Ae(ml())}function Zt(){var tt=ml(),Ir=ae(tt);if(p=arguments,y=this,N=tt,Ir){if(P===r)return oe(N);if(K)return N_(P),P=Ya(Te,o),te(N)}return P===r&&(P=Ya(Te,o)),x}return Zt.cancel=Xt,Zt.flush=kt,Zt}var c1=we(function(i,o){return d_(i,1,o)}),l1=we(function(i,o,l){return d_(i,ur(o)||0,l)});function h1(i){return dn(i,C)}function gl(i,o){if(typeof i!="function"||o!=null&&typeof o!="function")throw new nr(s);var l=function(){var p=arguments,y=o?o.apply(this,p):p[0],T=l.cache;if(T.has(y))return T.get(y);var x=i.apply(this,p);return l.cache=T.set(y,x)||T,x};return l.cache=new(gl.Cache||hn),l}gl.Cache=hn;function _l(i){if(typeof i!="function")throw new nr(s);return function(){var o=arguments;switch(o.length){case 0:return!i.call(this);case 1:return!i.call(this,o[0]);case 2:return!i.call(this,o[0],o[1]);case 3:return!i.call(this,o[0],o[1],o[2])}return!i.apply(this,o)}}function f1(i){return wy(2,i)}var d1=Zx(function(i,o){o=o.length==1&&pe(o[0])?Fe(o[0],_e(se())):Fe(vt(o,1),_e(se()));var l=o.length;return we(function(p){for(var y=-1,T=It(p.length,l);++y<T;)p[y]=o[y].call(this,p[y]);return Et(i,this,p)})}),vd=we(function(i,o){var l=Qn(o,io(vd));return dn(i,re,r,o,l)}),xy=we(function(i,o){var l=Qn(o,io(xy));return dn(i,le,r,o,l)}),p1=pn(function(i,o){return dn(i,ie,r,r,r,o)});function m1(i,o){if(typeof i!="function")throw new nr(s);return o=o===r?o:ye(o),we(i,o)}function g1(i,o){if(typeof i!="function")throw new nr(s);return o=o==null?0:dt(ye(o),0),we(function(l){var p=l[o],y=ti(l,0,o);return p&&vr(y,p),Et(i,this,y)})}function _1(i,o,l){var p=!0,y=!0;if(typeof i!="function")throw new nr(s);return We(l)&&(p="leading"in l?!!l.leading:p,y="trailing"in l?!!l.trailing:y),Iy(i,o,{leading:p,maxWait:o,trailing:y})}function y1(i){return vy(i,1)}function v1(i,o){return vd(nd(o),i)}function w1(){if(!arguments.length)return[];var i=arguments[0];return pe(i)?i:[i]}function b1(i){return sr(i,E)}function T1(i,o){return o=typeof o=="function"?o:r,sr(i,E,o)}function E1(i){return sr(i,m|E)}function I1(i,o){return o=typeof o=="function"?o:r,sr(i,m|E,o)}function x1(i,o){return o==null||f_(i,o,mt(o))}function Er(i,o){return i===o||i!==i&&o!==o}var A1=cl(Gf),S1=cl(function(i,o){return i>=o}),rs=y_(function(){return arguments}())?y_:function(i){return Qe(i)&&Me.call(i,"callee")&&!i_.call(i,"callee")},pe=U.isArray,R1=ka?_e(ka):Lx;function Bt(i){return i!=null&&yl(i.length)&&!gn(i)}function et(i){return Qe(i)&&Bt(i)}function P1(i){return i===!0||i===!1||Qe(i)&&Dt(i)==Ri}var ri=qI||Cd,C1=kc?_e(kc):Mx;function D1(i){return Qe(i)&&i.nodeType===1&&!Xa(i)}function O1(i){if(i==null)return!0;if(Bt(i)&&(pe(i)||typeof i=="string"||typeof i.splice=="function"||ri(i)||so(i)||rs(i)))return!i.length;var o=xt(i);if(o==Pt||o==Mt)return!i.size;if(Ja(i))return!Hf(i).length;for(var l in i)if(Me.call(i,l))return!1;return!0}function k1(i,o){return Wa(i,o)}function N1(i,o,l){l=typeof l=="function"?l:r;var p=l?l(i,o):r;return p===r?Wa(i,o,r,l):!!p}function wd(i){if(!Qe(i))return!1;var o=Dt(i);return o==Ds||o==wf||typeof i.message=="string"&&typeof i.name=="string"&&!Xa(i)}function V1(i){return typeof i=="number"&&o_(i)}function gn(i){if(!We(i))return!1;var o=Dt(i);return o==rn||o==Pi||o==Si||o==uc}function Ay(i){return typeof i=="number"&&i==ye(i)}function yl(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=Pr}function We(i){var o=typeof i;return i!=null&&(o=="object"||o=="function")}function Qe(i){return i!=null&&typeof i=="object"}var Sy=Gn?_e(Gn):Ux;function L1(i,o){return i===o||Wf(i,o,ld(o))}function M1(i,o,l){return l=typeof l=="function"?l:r,Wf(i,o,ld(o),l)}function F1(i){return Ry(i)&&i!=+i}function U1(i){if(TA(i))throw new he(n);return v_(i)}function B1(i){return i===null}function j1(i){return i==null}function Ry(i){return typeof i=="number"||Qe(i)&&Dt(i)==nn}function Xa(i){if(!Qe(i)||Dt(i)!=Ht)return!1;var o=Gc(i);if(o===null)return!0;var l=Me.call(o,"constructor")&&o.constructor;return typeof l=="function"&&l instanceof l&&jc.call(l)==MI}var bd=Na?_e(Na):Bx;function $1(i){return Ay(i)&&i>=-Pr&&i<=Pr}var Py=Ks?_e(Ks):jx;function vl(i){return typeof i=="string"||!pe(i)&&Qe(i)&&Dt(i)==Ln}function Yt(i){return typeof i=="symbol"||Qe(i)&&Dt(i)==Mn}var so=Gi?_e(Gi):$x;function q1(i){return i===r}function z1(i){return Qe(i)&&xt(i)==Di}function G1(i){return Qe(i)&&Dt(i)==ga}var K1=cl(Qf),W1=cl(function(i,o){return i<=o});function Cy(i){if(!i)return[];if(Bt(i))return vl(i)?br(i):Ut(i);if(Ua&&i[Ua])return xI(i[Ua]());var o=xt(i),l=o==Pt?Lf:o==Mt?Fc:oo;return l(i)}function _n(i){if(!i)return i===0?i:0;if(i=ur(i),i===Wt||i===-Wt){var o=i<0?-1:1;return o*Ai}return i===i?i:0}function ye(i){var o=_n(i),l=o%1;return o===o?l?o-l:o:0}function Dy(i){return i?Xi(ye(i),0,Lt):0}function ur(i){if(typeof i=="number")return i;if(Yt(i))return Cr;if(We(i)){var o=typeof i.valueOf=="function"?i.valueOf():i;i=We(o)?o+"":o}if(typeof i!="string")return i===0?i:+i;i=Q(i);var l=Ta.test(i);return l||Nr.test(i)?ze(i.slice(2),l?2:8):mc.test(i)?Cr:+i}function Oy(i){return Ur(i,jt(i))}function H1(i){return i?Xi(ye(i),-Pr,Pr):i===0?i:0}function Ve(i){return i==null?"":Jt(i)}var Q1=ro(function(i,o){if(Ja(o)||Bt(o)){Ur(o,mt(o),i);return}for(var l in o)Me.call(o,l)&&za(i,l,o[l])}),ky=ro(function(i,o){Ur(o,jt(o),i)}),wl=ro(function(i,o,l,p){Ur(o,jt(o),i,p)}),J1=ro(function(i,o,l,p){Ur(o,mt(o),i,p)}),Y1=pn($f);function X1(i,o){var l=to(i);return o==null?l:h_(l,o)}var Z1=we(function(i,o){i=Ue(i);var l=-1,p=o.length,y=p>2?o[2]:r;for(y&&Ot(o[0],o[1],y)&&(p=1);++l<p;)for(var T=o[l],x=jt(T),P=-1,N=x.length;++P<N;){var q=x[P],z=i[q];(z===r||Er(z,Xs[q])&&!Me.call(i,q))&&(i[q]=T[q])}return i}),eR=we(function(i){return i.push(r,J_),Et(Ny,r,i)});function tR(i,o){return Va(i,se(o,3),Fr)}function rR(i,o){return Va(i,se(o,3),zf)}function nR(i,o){return i==null?i:qf(i,se(o,3),jt)}function iR(i,o){return i==null?i:g_(i,se(o,3),jt)}function sR(i,o){return i&&Fr(i,se(o,3))}function oR(i,o){return i&&zf(i,se(o,3))}function aR(i){return i==null?[]:tl(i,mt(i))}function uR(i){return i==null?[]:tl(i,jt(i))}function Td(i,o,l){var p=i==null?r:Zi(i,o);return p===r?l:p}function cR(i,o){return i!=null&&Z_(i,o,Ox)}function Ed(i,o){return i!=null&&Z_(i,o,kx)}var lR=G_(function(i,o,l){o!=null&&typeof o.toString!="function"&&(o=$c.call(o)),i[o]=l},xd($t)),hR=G_(function(i,o,l){o!=null&&typeof o.toString!="function"&&(o=$c.call(o)),Me.call(i,o)?i[o].push(l):i[o]=[l]},se),fR=we(Ka);function mt(i){return Bt(i)?c_(i):Hf(i)}function jt(i){return Bt(i)?c_(i,!0):qx(i)}function dR(i,o){var l={};return o=se(o,3),Fr(i,function(p,y,T){fn(l,o(p,y,T),p)}),l}function pR(i,o){var l={};return o=se(o,3),Fr(i,function(p,y,T){fn(l,y,o(p,y,T))}),l}var mR=ro(function(i,o,l){rl(i,o,l)}),Ny=ro(function(i,o,l,p){rl(i,o,l,p)}),gR=pn(function(i,o){var l={};if(i==null)return l;var p=!1;o=Fe(o,function(T){return T=ei(T,i),p||(p=T.length>1),T}),Ur(i,ud(i),l),p&&(l=sr(l,m|_|E,lA));for(var y=o.length;y--;)ed(l,o[y]);return l});function _R(i,o){return Vy(i,_l(se(o)))}var yR=pn(function(i,o){return i==null?{}:Gx(i,o)});function Vy(i,o){if(i==null)return{};var l=Fe(ud(i),function(p){return[p]});return o=se(o),A_(i,l,function(p,y){return o(p,y[0])})}function vR(i,o,l){o=ei(o,i);var p=-1,y=o.length;for(y||(y=1,i=r);++p<y;){var T=i==null?r:i[Br(o[p])];T===r&&(p=y,T=l),i=gn(T)?T.call(i):T}return i}function wR(i,o,l){return i==null?i:Ha(i,o,l)}function bR(i,o,l,p){return p=typeof p=="function"?p:r,i==null?i:Ha(i,o,l,p)}var Ly=H_(mt),My=H_(jt);function TR(i,o,l){var p=pe(i),y=p||ri(i)||so(i);if(o=se(o,4),l==null){var T=i&&i.constructor;y?l=p?new T:[]:We(i)?l=gn(T)?to(Gc(i)):{}:l={}}return(y?Ft:Fr)(i,function(x,P,N){return o(l,x,P,N)}),l}function ER(i,o){return i==null?!0:ed(i,o)}function IR(i,o,l){return i==null?i:D_(i,o,nd(l))}function xR(i,o,l,p){return p=typeof p=="function"?p:r,i==null?i:D_(i,o,nd(l),p)}function oo(i){return i==null?[]:Ze(i,mt(i))}function AR(i){return i==null?[]:Ze(i,jt(i))}function SR(i,o,l){return l===r&&(l=o,o=r),l!==r&&(l=ur(l),l=l===l?l:0),o!==r&&(o=ur(o),o=o===o?o:0),Xi(ur(i),o,l)}function RR(i,o,l){return o=_n(o),l===r?(l=o,o=0):l=_n(l),i=ur(i),Nx(i,o,l)}function PR(i,o,l){if(l&&typeof l!="boolean"&&Ot(i,o,l)&&(o=l=r),l===r&&(typeof o=="boolean"?(l=o,o=r):typeof i=="boolean"&&(l=i,i=r)),i===r&&o===r?(i=0,o=1):(i=_n(i),o===r?(o=i,i=0):o=_n(o)),i>o){var p=i;i=o,o=p}if(l||i%1||o%1){var y=a_();return It(i+y*(o-i+Oa("1e-"+((y+"").length-1))),o)}return Yf(i,o)}var CR=no(function(i,o,l){return o=o.toLowerCase(),i+(l?Fy(o):o)});function Fy(i){return Id(Ve(i).toLowerCase())}function Uy(i){return i=Ve(i),i&&i.replace(_c,Qt).replace(zn,"")}function DR(i,o,l){i=Ve(i),o=Jt(o);var p=i.length;l=l===r?p:Xi(ye(l),0,p);var y=l;return l-=o.length,l>=0&&i.slice(l,y)==o}function OR(i){return i=Ve(i),i&&Oi.test(i)?i.replace(va,Qs):i}function kR(i){return i=Ve(i),i&&dc.test(i)?i.replace(an,"\\$&"):i}var NR=no(function(i,o,l){return i+(l?"-":"")+o.toLowerCase()}),VR=no(function(i,o,l){return i+(l?" ":"")+o.toLowerCase()}),LR=$_("toLowerCase");function MR(i,o,l){i=Ve(i),o=ye(o);var p=o?Ys(i):0;if(!o||p>=o)return i;var y=(o-p)/2;return ul(Qc(y),l)+i+ul(Hc(y),l)}function FR(i,o,l){i=Ve(i),o=ye(o);var p=o?Ys(i):0;return o&&p<o?i+ul(o-p,l):i}function UR(i,o,l){i=Ve(i),o=ye(o);var p=o?Ys(i):0;return o&&p<o?ul(o-p,l)+i:i}function BR(i,o,l){return l||o==null?o=0:o&&(o=+o),WI(Ve(i).replace(ct,""),o||0)}function jR(i,o,l){return(l?Ot(i,o,l):o===r)?o=1:o=ye(o),Xf(Ve(i),o)}function $R(){var i=arguments,o=Ve(i[0]);return i.length<3?o:o.replace(i[1],i[2])}var qR=no(function(i,o,l){return i+(l?"_":"")+o.toLowerCase()});function zR(i,o,l){return l&&typeof l!="number"&&Ot(i,o,l)&&(o=l=r),l=l===r?Lt:l>>>0,l?(i=Ve(i),i&&(typeof o=="string"||o!=null&&!bd(o))&&(o=Jt(o),!o&&Js(i))?ti(br(i),0,l):i.split(o,l)):[]}var GR=no(function(i,o,l){return i+(l?" ":"")+Id(o)});function KR(i,o,l){return i=Ve(i),l=l==null?0:Xi(ye(l),0,i.length),o=Jt(o),i.slice(l,l+o.length)==o}function WR(i,o,l){var p=w.templateSettings;l&&Ot(i,o,l)&&(o=r),i=Ve(i),o=wl({},o,p,Q_);var y=wl({},o.imports,p.imports,Q_),T=mt(y),x=Ze(y,T),P,N,q=0,z=o.interpolate||Bn,K="__p += '",Y=Mf((o.escape||Bn).source+"|"+z.source+"|"+(z===kr?Af:Bn).source+"|"+(o.evaluate||Bn).source+"|$","g"),te="//# sourceURL="+(Me.call(o,"sourceURL")?(o.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Nf+"]")+`
4
+ `;i.replace(Y,function(ae,Te,Ae,Xt,kt,Zt){return Ae||(Ae=Xt),K+=i.slice(q,Zt).replace(Ea,Fa),Te&&(P=!0,K+=`' +
5
5
  __e(`+Te+`) +
6
- '`),Dt&&(N=!0,K+=`';
7
- `+Dt+`;
6
+ '`),kt&&(N=!0,K+=`';
7
+ `+kt+`;
8
8
  __p += '`),Ae&&(K+=`' +
9
9
  ((__t = (`+Ae+`)) == null ? '' : __t) +
10
- '`),q=Xt+ae.length,ae}),K+=`';
10
+ '`),q=Zt+ae.length,ae}),K+=`';
11
11
  `;var oe=Me.call(o,"variable")&&o.variable;if(!oe)K=`with (obj) {
12
12
  `+K+`
13
13
  }
14
- `;else if(Ur.test(oe))throw new he(a);K=(N?K.replace(_a,""):K).replace(wf,"$1").replace(bf,"$1;"),K="function("+(oe||"obj")+`) {
14
+ `;else if(Un.test(oe))throw new he(a);K=(N?K.replace(ya,""):K).replace(bf,"$1").replace(Tf,"$1;"),K="function("+(oe||"obj")+`) {
15
15
  `+(oe?"":`obj || (obj = {});
16
16
  `)+"var __t, __p = ''"+(P?", __e = _.escape":"")+(N?`, __j = Array.prototype.join;
17
17
  function print() { __p += __j.call(arguments, '') }
18
18
  `:`;
19
19
  `)+K+`return __p
20
- }`;var ve=Uy(function(){return Ne(T,te+"return "+K).apply(n,x)});if(ve.source=K,vd(ve))throw ve;return ve}function G1(i){return Ve(i).toLowerCase()}function K1(i){return Ve(i).toUpperCase()}function W1(i,o,l){if(i=Ve(i),i&&(l||o===n))return Q(i);if(!i||!(o=Qt(o)))return i;var p=Tn(i),y=Tn(o),T=ct(p,y),x=lt(p,y)+1;return ti(p,T,x).join("")}function H1(i,o,l){if(i=Ve(i),i&&(l||o===n))return i.slice(0,Xg(i)+1);if(!i||!(o=Qt(o)))return i;var p=Tn(i),y=lt(p,Tn(o))+1;return ti(p,0,y).join("")}function Q1(i,o,l){if(i=Ve(i),i&&(l||o===n))return i.replace(ut,"");if(!i||!(o=Qt(o)))return i;var p=Tn(i),y=ct(p,Tn(o));return ti(p,y).join("")}function J1(i,o){var l=A,p=R;if(Ke(o)){var y="separator"in o?o.separator:y;l="length"in o?ye(o.length):l,p="omission"in o?Qt(o.omission):p}i=Ve(i);var T=i.length;if(Js(i)){var x=Tn(i);T=x.length}if(l>=T)return i;var P=l-Ys(p);if(P<1)return p;var N=x?ti(x,0,P).join(""):i.slice(0,P);if(y===n)return N+p;if(x&&(P+=N.length-P),wd(y)){if(i.slice(P).search(y)){var q,z=N;for(y.global||(y=Lf(y.source,Ve(Vi.exec(y))+"g")),y.lastIndex=0;q=y.exec(z);)var K=q.index;N=N.slice(0,K===n?P:K)}}else if(i.indexOf(Qt(y),P)!=P){var Y=N.lastIndexOf(y);Y>-1&&(N=N.slice(0,Y))}return N+p}function Y1(i){return i=Ve(i),i&&uc.test(i)?i.replace(Ls,AI):i}var X1=ro(function(i,o,l){return i+(l?" ":"")+o.toUpperCase()}),Ed=B_("toUpperCase");function Fy(i,o,l){return i=Ve(i),o=l?n:o,o===n?bI(i)?PI(i):Vc(i):i.match(o)||[]}var Uy=we(function(i,o){try{return bt(i,n,o)}catch(l){return vd(l)?l:new he(l)}}),Z1=pr(function(i,o){return Lt(o,function(l){l=jn(l),fr(i,l,_d(i[l],i))}),i});function eP(i){var o=i==null?0:i.length,l=se();return i=o?Fe(i,function(p){if(typeof p[1]!="function")throw new nn(s);return[l(p[0]),p[1]]}):[],we(function(p){for(var y=-1;++y<o;){var T=i[y];if(bt(T[0],this,p))return bt(T[1],this,p)}})}function tP(i){return Ax(sn(i,m))}function Id(i){return function(){return i}}function nP(i,o){return i==null||i!==i?o:i}var rP=$_(),iP=$_(!0);function Bt(i){return i}function xd(i){return y_(typeof i=="function"?i:sn(i,m))}function sP(i){return w_(sn(i,m))}function oP(i,o){return b_(i,sn(o,m))}var aP=we(function(i,o){return function(l){return Ga(l,i,o)}}),uP=we(function(i,o){return function(l){return Ga(i,l,o)}});function Ad(i,o,l){var p=pt(o),y=Zc(o,p);l==null&&!(Ke(o)&&(y.length||!p.length))&&(l=o,o=i,i=this,y=Zc(o,pt(o)));var T=!(Ke(l)&&"chain"in l)||!!l.chain,x=gr(i);return Lt(y,function(P){var N=o[P];i[P]=N,x&&(i.prototype[P]=function(){var q=this.__chain__;if(T||q){var z=i(this.__wrapped__),K=z.__actions__=Mt(this.__actions__);return K.push({func:N,args:arguments,thisArg:i}),z.__chain__=q,z}return N.apply(i,wn([this.value()],arguments))})}),i}function cP(){return Ye._===this&&(Ye._=VI),this}function Sd(){}function lP(i){return i=ye(i),we(function(o){return T_(o,i)})}var hP=id(Fe),fP=id(Kr),dP=id(Hs);function By(i){return hd(i)?Fn(jn(i)):qx(i)}function pP(i){return function(o){return i==null?n:Zi(i,o)}}var mP=z_(),gP=z_(!0);function Rd(){return[]}function Pd(){return!1}function _P(){return{}}function yP(){return""}function vP(){return!0}function wP(i,o){if(i=ye(i),i<1||i>Cn)return[];var l=Nt,p=Tt(i,Nt);o=se(o),i-=Nt;for(var y=L(p,o);++l<i;)o(l);return y}function bP(i){return pe(i)?Fe(i,jn):Jt(i)?[i]:Mt(oy(Ve(i)))}function TP(i){var o=++kI;return Ve(i)+o}var EP=sl(function(i,o){return i+o},0),IP=sd("ceil"),xP=sl(function(i,o){return i/o},1),AP=sd("floor");function SP(i){return i&&i.length?Xc(i,Bt,zf):n}function RP(i,o){return i&&i.length?Xc(i,se(o,2),zf):n}function PP(i){return La(i,Bt)}function CP(i,o){return La(i,se(o,2))}function DP(i){return i&&i.length?Xc(i,Bt,Hf):n}function OP(i,o){return i&&i.length?Xc(i,se(o,2),Hf):n}var kP=sl(function(i,o){return i*o},1),NP=sd("round"),VP=sl(function(i,o){return i-o},0);function LP(i){return i&&i.length?b(i,Bt):0}function MP(i,o){return i&&i.length?b(i,se(o,2)):0}return w.after=sR,w.ary=_y,w.assign=KR,w.assignIn=Dy,w.assignInWith=yl,w.assignWith=WR,w.at=HR,w.before=yy,w.bind=_d,w.bindAll=Z1,w.bindKey=vy,w.castArray=_R,w.chain=py,w.chunk=AA,w.compact=SA,w.concat=RA,w.cond=eP,w.conforms=tP,w.constant=Id,w.countBy=LS,w.create=QR,w.curry=wy,w.curryRight=by,w.debounce=Ty,w.defaults=JR,w.defaultsDeep=YR,w.defer=oR,w.delay=aR,w.difference=PA,w.differenceBy=CA,w.differenceWith=DA,w.drop=OA,w.dropRight=kA,w.dropRightWhile=NA,w.dropWhile=VA,w.fill=LA,w.filter=FS,w.flatMap=jS,w.flatMapDeep=$S,w.flatMapDepth=qS,w.flatten=ly,w.flattenDeep=MA,w.flattenDepth=FA,w.flip=uR,w.flow=rP,w.flowRight=iP,w.fromPairs=UA,w.functions=i1,w.functionsIn=s1,w.groupBy=zS,w.initial=jA,w.intersection=$A,w.intersectionBy=qA,w.intersectionWith=zA,w.invert=a1,w.invertBy=u1,w.invokeMap=KS,w.iteratee=xd,w.keyBy=WS,w.keys=pt,w.keysIn=Ut,w.map=fl,w.mapKeys=l1,w.mapValues=h1,w.matches=sP,w.matchesProperty=oP,w.memoize=pl,w.merge=f1,w.mergeWith=Oy,w.method=aP,w.methodOf=uP,w.mixin=Ad,w.negate=ml,w.nthArg=lP,w.omit=d1,w.omitBy=p1,w.once=cR,w.orderBy=HS,w.over=hP,w.overArgs=lR,w.overEvery=fP,w.overSome=dP,w.partial=yd,w.partialRight=Ey,w.partition=QS,w.pick=m1,w.pickBy=ky,w.property=By,w.propertyOf=pP,w.pull=HA,w.pullAll=fy,w.pullAllBy=QA,w.pullAllWith=JA,w.pullAt=YA,w.range=mP,w.rangeRight=gP,w.rearg=hR,w.reject=XS,w.remove=XA,w.rest=fR,w.reverse=md,w.sampleSize=eR,w.set=_1,w.setWith=y1,w.shuffle=tR,w.slice=ZA,w.sortBy=iR,w.sortedUniq=oS,w.sortedUniqBy=aS,w.split=j1,w.spread=dR,w.tail=uS,w.take=cS,w.takeRight=lS,w.takeRightWhile=hS,w.takeWhile=fS,w.tap=SS,w.throttle=pR,w.thru=hl,w.toArray=Ry,w.toPairs=Ny,w.toPairsIn=Vy,w.toPath=bP,w.toPlainObject=Cy,w.transform=v1,w.unary=mR,w.union=dS,w.unionBy=pS,w.unionWith=mS,w.uniq=gS,w.uniqBy=_S,w.uniqWith=yS,w.unset=w1,w.unzip=gd,w.unzipWith=dy,w.update=b1,w.updateWith=T1,w.values=oo,w.valuesIn=E1,w.without=vS,w.words=Fy,w.wrap=gR,w.xor=wS,w.xorBy=bS,w.xorWith=TS,w.zip=ES,w.zipObject=IS,w.zipObjectDeep=xS,w.zipWith=AS,w.entries=Ny,w.entriesIn=Vy,w.extend=Dy,w.extendWith=yl,Ad(w,w),w.add=EP,w.attempt=Uy,w.camelCase=S1,w.capitalize=Ly,w.ceil=IP,w.clamp=I1,w.clone=yR,w.cloneDeep=wR,w.cloneDeepWith=bR,w.cloneWith=vR,w.conformsTo=TR,w.deburr=My,w.defaultTo=nP,w.divide=xP,w.endsWith=R1,w.eq=In,w.escape=P1,w.escapeRegExp=C1,w.every=MS,w.find=US,w.findIndex=uy,w.findKey=XR,w.findLast=BS,w.findLastIndex=cy,w.findLastKey=ZR,w.floor=AP,w.forEach=my,w.forEachRight=gy,w.forIn=e1,w.forInRight=t1,w.forOwn=n1,w.forOwnRight=r1,w.get=bd,w.gt=ER,w.gte=IR,w.has=o1,w.hasIn=Td,w.head=hy,w.identity=Bt,w.includes=GS,w.indexOf=BA,w.inRange=x1,w.invoke=c1,w.isArguments=ns,w.isArray=pe,w.isArrayBuffer=xR,w.isArrayLike=Ft,w.isArrayLikeObject=Ze,w.isBoolean=AR,w.isBuffer=ni,w.isDate=SR,w.isElement=RR,w.isEmpty=PR,w.isEqual=CR,w.isEqualWith=DR,w.isError=vd,w.isFinite=OR,w.isFunction=gr,w.isInteger=Iy,w.isLength=gl,w.isMap=xy,w.isMatch=kR,w.isMatchWith=NR,w.isNaN=VR,w.isNative=LR,w.isNil=FR,w.isNull=MR,w.isNumber=Ay,w.isObject=Ke,w.isObjectLike=He,w.isPlainObject=Ya,w.isRegExp=wd,w.isSafeInteger=UR,w.isSet=Sy,w.isString=_l,w.isSymbol=Jt,w.isTypedArray=so,w.isUndefined=BR,w.isWeakMap=jR,w.isWeakSet=$R,w.join=GA,w.kebabCase=D1,w.last=an,w.lastIndexOf=KA,w.lowerCase=O1,w.lowerFirst=k1,w.lt=qR,w.lte=zR,w.max=SP,w.maxBy=RP,w.mean=PP,w.meanBy=CP,w.min=DP,w.minBy=OP,w.stubArray=Rd,w.stubFalse=Pd,w.stubObject=_P,w.stubString=yP,w.stubTrue=vP,w.multiply=kP,w.nth=WA,w.noConflict=cP,w.noop=Sd,w.now=dl,w.pad=N1,w.padEnd=V1,w.padStart=L1,w.parseInt=M1,w.random=A1,w.reduce=JS,w.reduceRight=YS,w.repeat=F1,w.replace=U1,w.result=g1,w.round=NP,w.runInContext=O,w.sample=ZS,w.size=nR,w.snakeCase=B1,w.some=rR,w.sortedIndex=eS,w.sortedIndexBy=tS,w.sortedIndexOf=nS,w.sortedLastIndex=rS,w.sortedLastIndexBy=iS,w.sortedLastIndexOf=sS,w.startCase=$1,w.startsWith=q1,w.subtract=VP,w.sum=LP,w.sumBy=MP,w.template=z1,w.times=wP,w.toFinite=_r,w.toInteger=ye,w.toLength=Py,w.toLower=G1,w.toNumber=un,w.toSafeInteger=GR,w.toString=Ve,w.toUpper=K1,w.trim=W1,w.trimEnd=H1,w.trimStart=Q1,w.truncate=J1,w.unescape=Y1,w.uniqueId=TP,w.upperCase=X1,w.upperFirst=Ed,w.each=my,w.eachRight=gy,w.first=hy,Ad(w,function(){var i={};return Un(w,function(o,l){Me.call(w.prototype,l)||(i[l]=o)}),i}(),{chain:!1}),w.VERSION=e,Lt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(i){w[i].placeholder=w}),Lt(["drop","take"],function(i,o){Ie.prototype[i]=function(l){l=l===n?1:ft(ye(l),0);var p=this.__filtered__&&!o?new Ie(this):this.clone();return p.__filtered__?p.__takeCount__=Tt(l,p.__takeCount__):p.__views__.push({size:Tt(l,Nt),type:i+(p.__dir__<0?"Right":"")}),p},Ie.prototype[i+"Right"]=function(l){return this.reverse()[i](l).reverse()}}),Lt(["filter","map","takeWhile"],function(i,o){var l=o+1,p=l==M||l==pn;Ie.prototype[i]=function(y){var T=this.clone();return T.__iteratees__.push({iteratee:se(y,3),type:l}),T.__filtered__=T.__filtered__||p,T}}),Lt(["head","last"],function(i,o){var l="take"+(o?"Right":"");Ie.prototype[i]=function(){return this[l](1).value()[0]}}),Lt(["initial","tail"],function(i,o){var l="drop"+(o?"":"Right");Ie.prototype[i]=function(){return this.__filtered__?new Ie(this):this[l](1)}}),Ie.prototype.compact=function(){return this.filter(Bt)},Ie.prototype.find=function(i){return this.filter(i).head()},Ie.prototype.findLast=function(i){return this.reverse().find(i)},Ie.prototype.invokeMap=we(function(i,o){return typeof i=="function"?new Ie(this):this.map(function(l){return Ga(l,i,o)})}),Ie.prototype.reject=function(i){return this.filter(ml(se(i)))},Ie.prototype.slice=function(i,o){i=ye(i);var l=this;return l.__filtered__&&(i>0||o<0)?new Ie(l):(i<0?l=l.takeRight(-i):i&&(l=l.drop(i)),o!==n&&(o=ye(o),l=o<0?l.dropRight(-o):l.take(o-i)),l)},Ie.prototype.takeRightWhile=function(i){return this.reverse().takeWhile(i).reverse()},Ie.prototype.toArray=function(){return this.take(Nt)},Un(Ie.prototype,function(i,o){var l=/^(?:filter|find|map|reject)|While$/.test(o),p=/^(?:head|last)$/.test(o),y=w[p?"take"+(o=="last"?"Right":""):o],T=p||/^find/.test(o);y&&(w.prototype[o]=function(){var x=this.__wrapped__,P=p?[1]:arguments,N=x instanceof Ie,q=P[0],z=N||pe(x),K=function(Te){var Ae=y.apply(w,wn([Te],P));return p&&Y?Ae[0]:Ae};z&&l&&typeof q=="function"&&q.length!=1&&(N=z=!1);var Y=this.__chain__,te=!!this.__actions__.length,oe=T&&!Y,ve=N&&!te;if(!T&&z){x=ve?x:new Ie(this);var ae=i.apply(x,P);return ae.__actions__.push({func:hl,args:[K],thisArg:n}),new rn(ae,Y)}return oe&&ve?i.apply(this,P):(ae=this.thru(K),oe?p?ae.value()[0]:ae.value():ae)})}),Lt(["pop","push","shift","sort","splice","unshift"],function(i){var o=Mc[i],l=/^(?:push|sort|unshift)$/.test(i)?"tap":"thru",p=/^(?:pop|shift)$/.test(i);w.prototype[i]=function(){var y=arguments;if(p&&!this.__chain__){var T=this.value();return o.apply(pe(T)?T:[],y)}return this[l](function(x){return o.apply(pe(x)?x:[],y)})}}),Un(Ie.prototype,function(i,o){var l=w[o];if(l){var p=l.name+"";Me.call(eo,p)||(eo[p]=[]),eo[p].push({name:o,func:l})}}),eo[il(n,G).name]=[{name:"wrapper",func:n}],Ie.prototype.clone=YI,Ie.prototype.reverse=XI,Ie.prototype.value=ZI,w.prototype.at=RS,w.prototype.chain=PS,w.prototype.commit=CS,w.prototype.next=DS,w.prototype.plant=kS,w.prototype.reverse=NS,w.prototype.toJSON=w.prototype.valueOf=w.prototype.value=VS,w.prototype.first=w.prototype.head,Fa&&(w.prototype[Fa]=OS),w},Jr=CI();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Ye._=Jr,define(function(){return Jr})):Mn?((Mn.exports=Jr)._=Jr,zs._=Jr):Ye._=Jr}).call(ha)});var lI=cn((zW,cI)=>{var _f=aI();function uI(n,e){var t={};return Object.keys(n).sort(e||void 0).forEach(function(r){t[r]=n[r]}),t}function Hg(n,e){if(_f.isArray(n))return _f.map(n,function(r){return Hg(r,e)});if(_f.isObject(n)){var t=uI(n,e);return _f.forEach(t,function(r,s){t[s]=Hg(r)}),t}else return n}cI.exports={keyArrange:uI,keyArrangeDeep:Hg}});var WP=typeof global=="object"&&global&&global.Object===Object&&global,vl=WP;var HP=typeof self=="object"&&self&&self.Object===Object&&self,QP=vl||HP||Function("return this")(),Qe=QP;var JP=Qe.Symbol,Ot=JP;var qy=Object.prototype,YP=qy.hasOwnProperty,XP=qy.toString,Za=Ot?Ot.toStringTag:void 0;function ZP(n){var e=YP.call(n,Za),t=n[Za];try{n[Za]=void 0;var r=!0}catch{}var s=XP.call(n);return r&&(e?n[Za]=t:delete n[Za]),s}var zy=ZP;var eC=Object.prototype,tC=eC.toString;function nC(n){return tC.call(n)}var Gy=nC;var rC="[object Null]",iC="[object Undefined]",Ky=Ot?Ot.toStringTag:void 0;function sC(n){return n==null?n===void 0?iC:rC:Ky&&Ky in Object(n)?zy(n):Gy(n)}var An=sC;function oC(n){return n!=null&&typeof n=="object"}var kt=oC;var aC="[object Symbol]";function uC(n){return typeof n=="symbol"||kt(n)&&An(n)==aC}var ri=uC;function cC(n,e){for(var t=-1,r=n==null?0:n.length,s=Array(r);++t<r;)s[t]=e(n[t],t,n);return s}var Wy=cC;var lC=Array.isArray,tt=lC;var hC=1/0,Hy=Ot?Ot.prototype:void 0,Qy=Hy?Hy.toString:void 0;function Jy(n){if(typeof n=="string")return n;if(tt(n))return Wy(n,Jy)+"";if(ri(n))return Qy?Qy.call(n):"";var e=n+"";return e=="0"&&1/n==-hC?"-0":e}var Yy=Jy;var fC=/\s/;function dC(n){for(var e=n.length;e--&&fC.test(n.charAt(e)););return e}var Xy=dC;var pC=/^\s+/;function mC(n){return n&&n.slice(0,Xy(n)+1).replace(pC,"")}var Zy=mC;function gC(n){var e=typeof n;return n!=null&&(e=="object"||e=="function")}var De=gC;var ev=NaN,_C=/^[-+]0x[0-9a-f]+$/i,yC=/^0b[01]+$/i,vC=/^0o[0-7]+$/i,wC=parseInt;function bC(n){if(typeof n=="number")return n;if(ri(n))return ev;if(De(n)){var e=typeof n.valueOf=="function"?n.valueOf():n;n=De(e)?e+"":e}if(typeof n!="string")return n===0?n:+n;n=Zy(n);var t=yC.test(n);return t||vC.test(n)?wC(n.slice(2),t?2:8):_C.test(n)?ev:+n}var Dd=bC;function TC(n){return n}var ao=TC;var EC="[object AsyncFunction]",IC="[object Function]",xC="[object GeneratorFunction]",AC="[object Proxy]";function SC(n){if(!De(n))return!1;var e=An(n);return e==IC||e==xC||e==EC||e==AC}var wl=SC;var RC=Qe["__core-js_shared__"],bl=RC;var tv=function(){var n=/[^.]+$/.exec(bl&&bl.keys&&bl.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function PC(n){return!!tv&&tv in n}var nv=PC;var CC=Function.prototype,DC=CC.toString;function OC(n){if(n!=null){try{return DC.call(n)}catch{}try{return n+""}catch{}}return""}var vr=OC;var kC=/[\\^$.*+?()[\]{}|]/g,NC=/^\[object .+?Constructor\]$/,VC=Function.prototype,LC=Object.prototype,MC=VC.toString,FC=LC.hasOwnProperty,UC=RegExp("^"+MC.call(FC).replace(kC,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function BC(n){if(!De(n)||nv(n))return!1;var e=wl(n)?UC:NC;return e.test(vr(n))}var rv=BC;function jC(n,e){return n==null?void 0:n[e]}var iv=jC;function $C(n,e){var t=iv(n,e);return rv(t)?t:void 0}var $t=$C;var qC=$t(Qe,"WeakMap"),Tl=qC;var sv=Object.create,zC=function(){function n(){}return function(e){if(!De(e))return{};if(sv)return sv(e);n.prototype=e;var t=new n;return n.prototype=void 0,t}}(),ov=zC;function GC(n,e,t){switch(t.length){case 0:return n.call(e);case 1:return n.call(e,t[0]);case 2:return n.call(e,t[0],t[1]);case 3:return n.call(e,t[0],t[1],t[2])}return n.apply(e,t)}var av=GC;function KC(n,e){var t=-1,r=n.length;for(e||(e=Array(r));++t<r;)e[t]=n[t];return e}var uv=KC;var WC=800,HC=16,QC=Date.now;function JC(n){var e=0,t=0;return function(){var r=QC(),s=HC-(r-t);if(t=r,s>0){if(++e>=WC)return arguments[0]}else e=0;return n.apply(void 0,arguments)}}var cv=JC;function YC(n){return function(){return n}}var lv=YC;var XC=function(){try{var n=$t(Object,"defineProperty");return n({},"",{}),n}catch{}}(),uo=XC;var ZC=uo?function(n,e){return uo(n,"toString",{configurable:!0,enumerable:!1,value:lv(e),writable:!0})}:ao,hv=ZC;var eD=cv(hv),fv=eD;function tD(n,e){for(var t=-1,r=n==null?0:n.length;++t<r&&e(n[t],t,n)!==!1;);return n}var dv=tD;var nD=9007199254740991,rD=/^(?:0|[1-9]\d*)$/;function iD(n,e){var t=typeof n;return e=e==null?nD:e,!!e&&(t=="number"||t!="symbol"&&rD.test(n))&&n>-1&&n%1==0&&n<e}var ii=iD;function sD(n,e,t){e=="__proto__"&&uo?uo(n,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):n[e]=t}var co=sD;function oD(n,e){return n===e||n!==n&&e!==e}var $n=oD;var aD=Object.prototype,uD=aD.hasOwnProperty;function cD(n,e,t){var r=n[e];(!(uD.call(n,e)&&$n(r,t))||t===void 0&&!(e in n))&&co(n,e,t)}var lo=cD;function lD(n,e,t,r){var s=!t;t||(t={});for(var a=-1,c=e.length;++a<c;){var h=e[a],f=r?r(t[h],n[h],h,t,n):void 0;f===void 0&&(f=n[h]),s?co(t,h,f):lo(t,h,f)}return t}var si=lD;var pv=Math.max;function hD(n,e,t){return e=pv(e===void 0?n.length-1:e,0),function(){for(var r=arguments,s=-1,a=pv(r.length-e,0),c=Array(a);++s<a;)c[s]=r[e+s];s=-1;for(var h=Array(e+1);++s<e;)h[s]=r[s];return h[e]=t(c),av(n,this,h)}}var mv=hD;function fD(n,e){return fv(mv(n,e,ao),n+"")}var gv=fD;var dD=9007199254740991;function pD(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=dD}var ho=pD;function mD(n){return n!=null&&ho(n.length)&&!wl(n)}var oi=mD;function gD(n,e,t){if(!De(t))return!1;var r=typeof e;return(r=="number"?oi(t)&&ii(e,t.length):r=="string"&&e in t)?$n(t[e],n):!1}var _v=gD;var _D=Object.prototype;function yD(n){var e=n&&n.constructor,t=typeof e=="function"&&e.prototype||_D;return n===t}var ai=yD;function vD(n,e){for(var t=-1,r=Array(n);++t<n;)r[t]=e(t);return r}var yv=vD;var wD="[object Arguments]";function bD(n){return kt(n)&&An(n)==wD}var Od=bD;var vv=Object.prototype,TD=vv.hasOwnProperty,ED=vv.propertyIsEnumerable,ID=Od(function(){return arguments}())?Od:function(n){return kt(n)&&TD.call(n,"callee")&&!ED.call(n,"callee")},fo=ID;function xD(){return!1}var wv=xD;var Ev=typeof exports=="object"&&exports&&!exports.nodeType&&exports,bv=Ev&&typeof module=="object"&&module&&!module.nodeType&&module,AD=bv&&bv.exports===Ev,Tv=AD?Qe.Buffer:void 0,SD=Tv?Tv.isBuffer:void 0,RD=SD||wv,wr=RD;var PD="[object Arguments]",CD="[object Array]",DD="[object Boolean]",OD="[object Date]",kD="[object Error]",ND="[object Function]",VD="[object Map]",LD="[object Number]",MD="[object Object]",FD="[object RegExp]",UD="[object Set]",BD="[object String]",jD="[object WeakMap]",$D="[object ArrayBuffer]",qD="[object DataView]",zD="[object Float32Array]",GD="[object Float64Array]",KD="[object Int8Array]",WD="[object Int16Array]",HD="[object Int32Array]",QD="[object Uint8Array]",JD="[object Uint8ClampedArray]",YD="[object Uint16Array]",XD="[object Uint32Array]",$e={};$e[zD]=$e[GD]=$e[KD]=$e[WD]=$e[HD]=$e[QD]=$e[JD]=$e[YD]=$e[XD]=!0;$e[PD]=$e[CD]=$e[$D]=$e[DD]=$e[qD]=$e[OD]=$e[kD]=$e[ND]=$e[VD]=$e[LD]=$e[MD]=$e[FD]=$e[UD]=$e[BD]=$e[jD]=!1;function ZD(n){return kt(n)&&ho(n.length)&&!!$e[An(n)]}var Iv=ZD;function eO(n){return function(e){return n(e)}}var po=eO;var xv=typeof exports=="object"&&exports&&!exports.nodeType&&exports,eu=xv&&typeof module=="object"&&module&&!module.nodeType&&module,tO=eu&&eu.exports===xv,kd=tO&&vl.process,nO=function(){try{var n=eu&&eu.require&&eu.require("util").types;return n||kd&&kd.binding&&kd.binding("util")}catch{}}(),br=nO;var Av=br&&br.isTypedArray,rO=Av?po(Av):Iv,mo=rO;var iO=Object.prototype,sO=iO.hasOwnProperty;function oO(n,e){var t=tt(n),r=!t&&fo(n),s=!t&&!r&&wr(n),a=!t&&!r&&!s&&mo(n),c=t||r||s||a,h=c?yv(n.length,String):[],f=h.length;for(var m in n)(e||sO.call(n,m))&&!(c&&(m=="length"||s&&(m=="offset"||m=="parent")||a&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||ii(m,f)))&&h.push(m);return h}var El=oO;function aO(n,e){return function(t){return n(e(t))}}var Il=aO;var uO=Il(Object.keys,Object),Sv=uO;var cO=Object.prototype,lO=cO.hasOwnProperty;function hO(n){if(!ai(n))return Sv(n);var e=[];for(var t in Object(n))lO.call(n,t)&&t!="constructor"&&e.push(t);return e}var xl=hO;function fO(n){return oi(n)?El(n):xl(n)}var It=fO;function dO(n){var e=[];if(n!=null)for(var t in Object(n))e.push(t);return e}var Rv=dO;var pO=Object.prototype,mO=pO.hasOwnProperty;function gO(n){if(!De(n))return Rv(n);var e=ai(n),t=[];for(var r in n)r=="constructor"&&(e||!mO.call(n,r))||t.push(r);return t}var Pv=gO;function _O(n){return oi(n)?El(n,!0):Pv(n)}var ui=_O;var yO=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,vO=/^\w*$/;function wO(n,e){if(tt(n))return!1;var t=typeof n;return t=="number"||t=="symbol"||t=="boolean"||n==null||ri(n)?!0:vO.test(n)||!yO.test(n)||e!=null&&n in Object(e)}var go=wO;var bO=$t(Object,"create"),Tr=bO;function TO(){this.__data__=Tr?Tr(null):{},this.size=0}var Cv=TO;function EO(n){var e=this.has(n)&&delete this.__data__[n];return this.size-=e?1:0,e}var Dv=EO;var IO="__lodash_hash_undefined__",xO=Object.prototype,AO=xO.hasOwnProperty;function SO(n){var e=this.__data__;if(Tr){var t=e[n];return t===IO?void 0:t}return AO.call(e,n)?e[n]:void 0}var Ov=SO;var RO=Object.prototype,PO=RO.hasOwnProperty;function CO(n){var e=this.__data__;return Tr?e[n]!==void 0:PO.call(e,n)}var kv=CO;var DO="__lodash_hash_undefined__";function OO(n,e){var t=this.__data__;return this.size+=this.has(n)?0:1,t[n]=Tr&&e===void 0?DO:e,this}var Nv=OO;function _o(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var r=n[e];this.set(r[0],r[1])}}_o.prototype.clear=Cv;_o.prototype.delete=Dv;_o.prototype.get=Ov;_o.prototype.has=kv;_o.prototype.set=Nv;var Nd=_o;function kO(){this.__data__=[],this.size=0}var Vv=kO;function NO(n,e){for(var t=n.length;t--;)if($n(n[t][0],e))return t;return-1}var ci=NO;var VO=Array.prototype,LO=VO.splice;function MO(n){var e=this.__data__,t=ci(e,n);if(t<0)return!1;var r=e.length-1;return t==r?e.pop():LO.call(e,t,1),--this.size,!0}var Lv=MO;function FO(n){var e=this.__data__,t=ci(e,n);return t<0?void 0:e[t][1]}var Mv=FO;function UO(n){return ci(this.__data__,n)>-1}var Fv=UO;function BO(n,e){var t=this.__data__,r=ci(t,n);return r<0?(++this.size,t.push([n,e])):t[r][1]=e,this}var Uv=BO;function yo(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var r=n[e];this.set(r[0],r[1])}}yo.prototype.clear=Vv;yo.prototype.delete=Lv;yo.prototype.get=Mv;yo.prototype.has=Fv;yo.prototype.set=Uv;var li=yo;var jO=$t(Qe,"Map"),hi=jO;function $O(){this.size=0,this.__data__={hash:new Nd,map:new(hi||li),string:new Nd}}var Bv=$O;function qO(n){var e=typeof n;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?n!=="__proto__":n===null}var jv=qO;function zO(n,e){var t=n.__data__;return jv(e)?t[typeof e=="string"?"string":"hash"]:t.map}var fi=zO;function GO(n){var e=fi(this,n).delete(n);return this.size-=e?1:0,e}var $v=GO;function KO(n){return fi(this,n).get(n)}var qv=KO;function WO(n){return fi(this,n).has(n)}var zv=WO;function HO(n,e){var t=fi(this,n),r=t.size;return t.set(n,e),this.size+=t.size==r?0:1,this}var Gv=HO;function vo(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var r=n[e];this.set(r[0],r[1])}}vo.prototype.clear=Bv;vo.prototype.delete=$v;vo.prototype.get=qv;vo.prototype.has=zv;vo.prototype.set=Gv;var rs=vo;var QO="Expected a function";function Vd(n,e){if(typeof n!="function"||e!=null&&typeof e!="function")throw new TypeError(QO);var t=function(){var r=arguments,s=e?e.apply(this,r):r[0],a=t.cache;if(a.has(s))return a.get(s);var c=n.apply(this,r);return t.cache=a.set(s,c)||a,c};return t.cache=new(Vd.Cache||rs),t}Vd.Cache=rs;var Kv=Vd;var JO=500;function YO(n){var e=Kv(n,function(r){return t.size===JO&&t.clear(),r}),t=e.cache;return e}var Wv=YO;var XO=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ZO=/\\(\\)?/g,ek=Wv(function(n){var e=[];return n.charCodeAt(0)===46&&e.push(""),n.replace(XO,function(t,r,s,a){e.push(s?a.replace(ZO,"$1"):r||t)}),e}),Hv=ek;function tk(n){return n==null?"":Yy(n)}var Qv=tk;function nk(n,e){return tt(n)?n:go(n,e)?[n]:Hv(Qv(n))}var wo=nk;var rk=1/0;function ik(n){if(typeof n=="string"||ri(n))return n;var e=n+"";return e=="0"&&1/n==-rk?"-0":e}var qn=ik;function sk(n,e){e=wo(e,n);for(var t=0,r=e.length;n!=null&&t<r;)n=n[qn(e[t++])];return t&&t==r?n:void 0}var Al=sk;function ok(n,e,t){var r=n==null?void 0:Al(n,e);return r===void 0?t:r}var tu=ok;function ak(n,e){for(var t=-1,r=e.length,s=n.length;++t<r;)n[s+t]=e[t];return n}var Sl=ak;var uk=Il(Object.getPrototypeOf,Object),Rl=uk;function ck(){this.__data__=new li,this.size=0}var Jv=ck;function lk(n){var e=this.__data__,t=e.delete(n);return this.size=e.size,t}var Yv=lk;function hk(n){return this.__data__.get(n)}var Xv=hk;function fk(n){return this.__data__.has(n)}var Zv=fk;var dk=200;function pk(n,e){var t=this.__data__;if(t instanceof li){var r=t.__data__;if(!hi||r.length<dk-1)return r.push([n,e]),this.size=++t.size,this;t=this.__data__=new rs(r)}return t.set(n,e),this.size=t.size,this}var ew=pk;function bo(n){var e=this.__data__=new li(n);this.size=e.size}bo.prototype.clear=Jv;bo.prototype.delete=Yv;bo.prototype.get=Xv;bo.prototype.has=Zv;bo.prototype.set=ew;var di=bo;function mk(n,e){return n&&si(e,It(e),n)}var tw=mk;function gk(n,e){return n&&si(e,ui(e),n)}var nw=gk;var ow=typeof exports=="object"&&exports&&!exports.nodeType&&exports,rw=ow&&typeof module=="object"&&module&&!module.nodeType&&module,_k=rw&&rw.exports===ow,iw=_k?Qe.Buffer:void 0,sw=iw?iw.allocUnsafe:void 0;function yk(n,e){if(e)return n.slice();var t=n.length,r=sw?sw(t):new n.constructor(t);return n.copy(r),r}var aw=yk;function vk(n,e){for(var t=-1,r=n==null?0:n.length,s=0,a=[];++t<r;){var c=n[t];e(c,t,n)&&(a[s++]=c)}return a}var uw=vk;function wk(){return[]}var Pl=wk;var bk=Object.prototype,Tk=bk.propertyIsEnumerable,cw=Object.getOwnPropertySymbols,Ek=cw?function(n){return n==null?[]:(n=Object(n),uw(cw(n),function(e){return Tk.call(n,e)}))}:Pl,To=Ek;function Ik(n,e){return si(n,To(n),e)}var lw=Ik;var xk=Object.getOwnPropertySymbols,Ak=xk?function(n){for(var e=[];n;)Sl(e,To(n)),n=Rl(n);return e}:Pl,Cl=Ak;function Sk(n,e){return si(n,Cl(n),e)}var hw=Sk;function Rk(n,e,t){var r=e(n);return tt(n)?r:Sl(r,t(n))}var Dl=Rk;function Pk(n){return Dl(n,It,To)}var nu=Pk;function Ck(n){return Dl(n,ui,Cl)}var fw=Ck;var Dk=$t(Qe,"DataView"),Ol=Dk;var Ok=$t(Qe,"Promise"),kl=Ok;var kk=$t(Qe,"Set"),Nl=kk;var dw="[object Map]",Nk="[object Object]",pw="[object Promise]",mw="[object Set]",gw="[object WeakMap]",_w="[object DataView]",Vk=vr(Ol),Lk=vr(hi),Mk=vr(kl),Fk=vr(Nl),Uk=vr(Tl),is=An;(Ol&&is(new Ol(new ArrayBuffer(1)))!=_w||hi&&is(new hi)!=dw||kl&&is(kl.resolve())!=pw||Nl&&is(new Nl)!=mw||Tl&&is(new Tl)!=gw)&&(is=function(n){var e=An(n),t=e==Nk?n.constructor:void 0,r=t?vr(t):"";if(r)switch(r){case Vk:return _w;case Lk:return dw;case Mk:return pw;case Fk:return mw;case Uk:return gw}return e});var Sn=is;var Bk=Object.prototype,jk=Bk.hasOwnProperty;function $k(n){var e=n.length,t=new n.constructor(e);return e&&typeof n[0]=="string"&&jk.call(n,"index")&&(t.index=n.index,t.input=n.input),t}var yw=$k;var qk=Qe.Uint8Array,Eo=qk;function zk(n){var e=new n.constructor(n.byteLength);return new Eo(e).set(new Eo(n)),e}var Io=zk;function Gk(n,e){var t=e?Io(n.buffer):n.buffer;return new n.constructor(t,n.byteOffset,n.byteLength)}var vw=Gk;var Kk=/\w*$/;function Wk(n){var e=new n.constructor(n.source,Kk.exec(n));return e.lastIndex=n.lastIndex,e}var ww=Wk;var bw=Ot?Ot.prototype:void 0,Tw=bw?bw.valueOf:void 0;function Hk(n){return Tw?Object(Tw.call(n)):{}}var Ew=Hk;function Qk(n,e){var t=e?Io(n.buffer):n.buffer;return new n.constructor(t,n.byteOffset,n.length)}var Iw=Qk;var Jk="[object Boolean]",Yk="[object Date]",Xk="[object Map]",Zk="[object Number]",eN="[object RegExp]",tN="[object Set]",nN="[object String]",rN="[object Symbol]",iN="[object ArrayBuffer]",sN="[object DataView]",oN="[object Float32Array]",aN="[object Float64Array]",uN="[object Int8Array]",cN="[object Int16Array]",lN="[object Int32Array]",hN="[object Uint8Array]",fN="[object Uint8ClampedArray]",dN="[object Uint16Array]",pN="[object Uint32Array]";function mN(n,e,t){var r=n.constructor;switch(e){case iN:return Io(n);case Jk:case Yk:return new r(+n);case sN:return vw(n,t);case oN:case aN:case uN:case cN:case lN:case hN:case fN:case dN:case pN:return Iw(n,t);case Xk:return new r;case Zk:case nN:return new r(n);case eN:return ww(n);case tN:return new r;case rN:return Ew(n)}}var xw=mN;function gN(n){return typeof n.constructor=="function"&&!ai(n)?ov(Rl(n)):{}}var Aw=gN;var _N="[object Map]";function yN(n){return kt(n)&&Sn(n)==_N}var Sw=yN;var Rw=br&&br.isMap,vN=Rw?po(Rw):Sw,Pw=vN;var wN="[object Set]";function bN(n){return kt(n)&&Sn(n)==wN}var Cw=bN;var Dw=br&&br.isSet,TN=Dw?po(Dw):Cw,Ow=TN;var EN=1,IN=2,xN=4,kw="[object Arguments]",AN="[object Array]",SN="[object Boolean]",RN="[object Date]",PN="[object Error]",Nw="[object Function]",CN="[object GeneratorFunction]",DN="[object Map]",ON="[object Number]",Vw="[object Object]",kN="[object RegExp]",NN="[object Set]",VN="[object String]",LN="[object Symbol]",MN="[object WeakMap]",FN="[object ArrayBuffer]",UN="[object DataView]",BN="[object Float32Array]",jN="[object Float64Array]",$N="[object Int8Array]",qN="[object Int16Array]",zN="[object Int32Array]",GN="[object Uint8Array]",KN="[object Uint8ClampedArray]",WN="[object Uint16Array]",HN="[object Uint32Array]",Be={};Be[kw]=Be[AN]=Be[FN]=Be[UN]=Be[SN]=Be[RN]=Be[BN]=Be[jN]=Be[$N]=Be[qN]=Be[zN]=Be[DN]=Be[ON]=Be[Vw]=Be[kN]=Be[NN]=Be[VN]=Be[LN]=Be[GN]=Be[KN]=Be[WN]=Be[HN]=!0;Be[PN]=Be[Nw]=Be[MN]=!1;function Vl(n,e,t,r,s,a){var c,h=e&EN,f=e&IN,m=e&xN;if(t&&(c=s?t(n,r,s,a):t(n)),c!==void 0)return c;if(!De(n))return n;var _=tt(n);if(_){if(c=yw(n),!h)return uv(n,c)}else{var E=Sn(n),I=E==Nw||E==CN;if(wr(n))return aw(n,h);if(E==Vw||E==kw||I&&!s){if(c=f||I?{}:Aw(n),!h)return f?hw(n,nw(c,n)):lw(n,tw(c,n))}else{if(!Be[E])return s?n:{};c=xw(n,E,h)}}a||(a=new di);var k=a.get(n);if(k)return k;a.set(n,c),Ow(n)?n.forEach(function(j){c.add(Vl(j,e,t,j,n,a))}):Pw(n)&&n.forEach(function(j,J){c.set(J,Vl(j,e,t,J,n,a))});var B=m?f?fw:nu:f?ui:It,G=_?void 0:B(n);return dv(G||n,function(j,J){G&&(J=j,j=n[J]),lo(c,J,Vl(j,e,t,J,n,a))}),c}var Lw=Vl;var QN=1,JN=4;function YN(n){return Lw(n,QN|JN)}var zn=YN;var XN="__lodash_hash_undefined__";function ZN(n){return this.__data__.set(n,XN),this}var Mw=ZN;function eV(n){return this.__data__.has(n)}var Fw=eV;function Ll(n){var e=-1,t=n==null?0:n.length;for(this.__data__=new rs;++e<t;)this.add(n[e])}Ll.prototype.add=Ll.prototype.push=Mw;Ll.prototype.has=Fw;var Uw=Ll;function tV(n,e){for(var t=-1,r=n==null?0:n.length;++t<r;)if(e(n[t],t,n))return!0;return!1}var Bw=tV;function nV(n,e){return n.has(e)}var jw=nV;var rV=1,iV=2;function sV(n,e,t,r,s,a){var c=t&rV,h=n.length,f=e.length;if(h!=f&&!(c&&f>h))return!1;var m=a.get(n),_=a.get(e);if(m&&_)return m==e&&_==n;var E=-1,I=!0,k=t&iV?new Uw:void 0;for(a.set(n,e),a.set(e,n);++E<h;){var B=n[E],G=e[E];if(r)var j=c?r(G,B,E,e,n,a):r(B,G,E,n,e,a);if(j!==void 0){if(j)continue;I=!1;break}if(k){if(!Bw(e,function(J,ee){if(!jw(k,ee)&&(B===J||s(B,J,t,r,a)))return k.push(ee)})){I=!1;break}}else if(!(B===G||s(B,G,t,r,a))){I=!1;break}}return a.delete(n),a.delete(e),I}var Ml=sV;function oV(n){var e=-1,t=Array(n.size);return n.forEach(function(r,s){t[++e]=[s,r]}),t}var $w=oV;function aV(n){var e=-1,t=Array(n.size);return n.forEach(function(r){t[++e]=r}),t}var qw=aV;var uV=1,cV=2,lV="[object Boolean]",hV="[object Date]",fV="[object Error]",dV="[object Map]",pV="[object Number]",mV="[object RegExp]",gV="[object Set]",_V="[object String]",yV="[object Symbol]",vV="[object ArrayBuffer]",wV="[object DataView]",zw=Ot?Ot.prototype:void 0,Ld=zw?zw.valueOf:void 0;function bV(n,e,t,r,s,a,c){switch(t){case wV:if(n.byteLength!=e.byteLength||n.byteOffset!=e.byteOffset)return!1;n=n.buffer,e=e.buffer;case vV:return!(n.byteLength!=e.byteLength||!a(new Eo(n),new Eo(e)));case lV:case hV:case pV:return $n(+n,+e);case fV:return n.name==e.name&&n.message==e.message;case mV:case _V:return n==e+"";case dV:var h=$w;case gV:var f=r&uV;if(h||(h=qw),n.size!=e.size&&!f)return!1;var m=c.get(n);if(m)return m==e;r|=cV,c.set(n,e);var _=Ml(h(n),h(e),r,s,a,c);return c.delete(n),_;case yV:if(Ld)return Ld.call(n)==Ld.call(e)}return!1}var Gw=bV;var TV=1,EV=Object.prototype,IV=EV.hasOwnProperty;function xV(n,e,t,r,s,a){var c=t&TV,h=nu(n),f=h.length,m=nu(e),_=m.length;if(f!=_&&!c)return!1;for(var E=f;E--;){var I=h[E];if(!(c?I in e:IV.call(e,I)))return!1}var k=a.get(n),B=a.get(e);if(k&&B)return k==e&&B==n;var G=!0;a.set(n,e),a.set(e,n);for(var j=c;++E<f;){I=h[E];var J=n[I],ee=e[I];if(r)var ne=c?r(ee,J,I,e,n,a):r(J,ee,I,n,e,a);if(!(ne===void 0?J===ee||s(J,ee,t,r,a):ne)){G=!1;break}j||(j=I=="constructor")}if(G&&!j){var le=n.constructor,de=e.constructor;le!=de&&"constructor"in n&&"constructor"in e&&!(typeof le=="function"&&le instanceof le&&typeof de=="function"&&de instanceof de)&&(G=!1)}return a.delete(n),a.delete(e),G}var Kw=xV;var AV=1,Ww="[object Arguments]",Hw="[object Array]",Fl="[object Object]",SV=Object.prototype,Qw=SV.hasOwnProperty;function RV(n,e,t,r,s,a){var c=tt(n),h=tt(e),f=c?Hw:Sn(n),m=h?Hw:Sn(e);f=f==Ww?Fl:f,m=m==Ww?Fl:m;var _=f==Fl,E=m==Fl,I=f==m;if(I&&wr(n)){if(!wr(e))return!1;c=!0,_=!1}if(I&&!_)return a||(a=new di),c||mo(n)?Ml(n,e,t,r,s,a):Gw(n,e,f,t,r,s,a);if(!(t&AV)){var k=_&&Qw.call(n,"__wrapped__"),B=E&&Qw.call(e,"__wrapped__");if(k||B){var G=k?n.value():n,j=B?e.value():e;return a||(a=new di),s(G,j,t,r,a)}}return I?(a||(a=new di),Kw(n,e,t,r,s,a)):!1}var Jw=RV;function Yw(n,e,t,r,s){return n===e?!0:n==null||e==null||!kt(n)&&!kt(e)?n!==n&&e!==e:Jw(n,e,t,r,Yw,s)}var Ul=Yw;var PV=1,CV=2;function DV(n,e,t,r){var s=t.length,a=s,c=!r;if(n==null)return!a;for(n=Object(n);s--;){var h=t[s];if(c&&h[2]?h[1]!==n[h[0]]:!(h[0]in n))return!1}for(;++s<a;){h=t[s];var f=h[0],m=n[f],_=h[1];if(c&&h[2]){if(m===void 0&&!(f in n))return!1}else{var E=new di;if(r)var I=r(m,_,f,n,e,E);if(!(I===void 0?Ul(_,m,PV|CV,r,E):I))return!1}}return!0}var Xw=DV;function OV(n){return n===n&&!De(n)}var Bl=OV;function kV(n){for(var e=It(n),t=e.length;t--;){var r=e[t],s=n[r];e[t]=[r,s,Bl(s)]}return e}var Zw=kV;function NV(n,e){return function(t){return t==null?!1:t[n]===e&&(e!==void 0||n in Object(t))}}var jl=NV;function VV(n){var e=Zw(n);return e.length==1&&e[0][2]?jl(e[0][0],e[0][1]):function(t){return t===n||Xw(t,n,e)}}var e0=VV;function LV(n,e){return n!=null&&e in Object(n)}var t0=LV;function MV(n,e,t){e=wo(e,n);for(var r=-1,s=e.length,a=!1;++r<s;){var c=qn(e[r]);if(!(a=n!=null&&t(n,c)))break;n=n[c]}return a||++r!=s?a:(s=n==null?0:n.length,!!s&&ho(s)&&ii(c,s)&&(tt(n)||fo(n)))}var n0=MV;function FV(n,e){return n!=null&&n0(n,e,t0)}var r0=FV;var UV=1,BV=2;function jV(n,e){return go(n)&&Bl(e)?jl(qn(n),e):function(t){var r=tu(t,n);return r===void 0&&r===e?r0(t,n):Ul(e,r,UV|BV)}}var i0=jV;function $V(n){return function(e){return e==null?void 0:e[n]}}var s0=$V;function qV(n){return function(e){return Al(e,n)}}var o0=qV;function zV(n){return go(n)?s0(qn(n)):o0(n)}var a0=zV;function GV(n){return typeof n=="function"?n:n==null?ao:typeof n=="object"?tt(n)?i0(n[0],n[1]):e0(n):a0(n)}var u0=GV;function KV(n){return function(e,t,r){for(var s=-1,a=Object(e),c=r(e),h=c.length;h--;){var f=c[n?h:++s];if(t(a[f],f,a)===!1)break}return e}}var c0=KV;var WV=c0(),l0=WV;function HV(n,e){return n&&l0(n,e,It)}var h0=HV;var QV=function(){return Qe.Date.now()},$l=QV;var JV="Expected a function",YV=Math.max,XV=Math.min;function ZV(n,e,t){var r,s,a,c,h,f,m=0,_=!1,E=!1,I=!0;if(typeof n!="function")throw new TypeError(JV);e=Dd(e)||0,De(t)&&(_=!!t.leading,E="maxWait"in t,a=E?YV(Dd(t.maxWait)||0,e):a,I="trailing"in t?!!t.trailing:I);function k(ie){var C=r,A=s;return r=s=void 0,m=ie,c=n.apply(A,C),c}function B(ie){return m=ie,h=setTimeout(J,e),_?k(ie):c}function G(ie){var C=ie-f,A=ie-m,R=e-C;return E?XV(R,a-A):R}function j(ie){var C=ie-f,A=ie-m;return f===void 0||C>=e||C<0||E&&A>=a}function J(){var ie=$l();if(j(ie))return ee(ie);h=setTimeout(J,G(ie))}function ee(ie){return h=void 0,I&&r?k(ie):(r=s=void 0,c)}function ne(){h!==void 0&&clearTimeout(h),m=0,r=f=s=h=void 0}function le(){return h===void 0?c:ee($l())}function de(){var ie=$l(),C=j(ie);if(r=arguments,s=this,f=ie,C){if(h===void 0)return B(f);if(E)return clearTimeout(h),h=setTimeout(J,e),k(f)}return h===void 0&&(h=setTimeout(J,e)),c}return de.cancel=ne,de.flush=le,de}var f0=ZV;var d0=Object.prototype,eL=d0.hasOwnProperty,tL=gv(function(n,e){n=Object(n);var t=-1,r=e.length,s=r>2?e[2]:void 0;for(s&&_v(e[0],e[1],s)&&(r=1);++t<r;)for(var a=e[t],c=ui(a),h=-1,f=c.length;++h<f;){var m=c[h],_=n[m];(_===void 0||$n(_,d0[m])&&!eL.call(n,m))&&(n[m]=a[m])}return n}),ql=tL;var nL="[object Map]",rL="[object Set]",iL=Object.prototype,sL=iL.hasOwnProperty;function oL(n){if(n==null)return!0;if(oi(n)&&(tt(n)||typeof n=="string"||typeof n.splice=="function"||wr(n)||mo(n)||fo(n)))return!n.length;var e=Sn(n);if(e==nL||e==rL)return!n.size;if(ai(n))return!xl(n).length;for(var t in n)if(sL.call(n,t))return!1;return!0}var Md=oL;function aL(n,e){var t={};return e=u0(e,3),h0(n,function(r,s,a){co(t,e(r,s,a),r)}),t}var Fd=aL;function uL(n,e,t,r){if(!De(n))return n;e=wo(e,n);for(var s=-1,a=e.length,c=a-1,h=n;h!=null&&++s<a;){var f=qn(e[s]),m=t;if(f==="__proto__"||f==="constructor"||f==="prototype")return n;if(s!=c){var _=h[f];m=r?r(_,f,h):void 0,m===void 0&&(m=De(_)?_:ii(e[s+1])?[]:{})}lo(h,f,m),h=h[f]}return n}var p0=uL;function cL(n,e,t){return n==null?n:p0(n,e,t)}var pi=cL;var lL="Expected a function";function hL(n,e,t){var r=!0,s=!0;if(typeof n!="function")throw new TypeError(lL);return De(t)&&(r="leading"in t?!!t.leading:r,s="trailing"in t?!!t.trailing:s),f0(n,e,{leading:r,maxWait:e,trailing:s})}var Ud=hL;var g0=function(n){let e=[],t=0;for(let r=0;r<n.length;r++){let s=n.charCodeAt(r);s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&r+1<n.length&&(n.charCodeAt(r+1)&64512)===56320?(s=65536+((s&1023)<<10)+(n.charCodeAt(++r)&1023),e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128)}return e},fL=function(n){let e=[],t=0,r=0;for(;t<n.length;){let s=n[t++];if(s<128)e[r++]=String.fromCharCode(s);else if(s>191&&s<224){let a=n[t++];e[r++]=String.fromCharCode((s&31)<<6|a&63)}else if(s>239&&s<365){let a=n[t++],c=n[t++],h=n[t++],f=((s&7)<<18|(a&63)<<12|(c&63)<<6|h&63)-65536;e[r++]=String.fromCharCode(55296+(f>>10)),e[r++]=String.fromCharCode(56320+(f&1023))}else{let a=n[t++],c=n[t++];e[r++]=String.fromCharCode((s&15)<<12|(a&63)<<6|c&63)}}return e.join("")},_0={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(n,e){if(!Array.isArray(n))throw Error("encodeByteArray takes an array as a parameter");this.init_();let t=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let s=0;s<n.length;s+=3){let a=n[s],c=s+1<n.length,h=c?n[s+1]:0,f=s+2<n.length,m=f?n[s+2]:0,_=a>>2,E=(a&3)<<4|h>>4,I=(h&15)<<2|m>>6,k=m&63;f||(k=64,c||(I=64)),r.push(t[_],t[E],t[I],t[k])}return r.join("")},encodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(n):this.encodeByteArray(g0(n),e)},decodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(n):fL(this.decodeStringToByteArray(n,e))},decodeStringToByteArray(n,e){this.init_();let t=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let s=0;s<n.length;){let a=t[n.charAt(s++)],h=s<n.length?t[n.charAt(s)]:0;++s;let m=s<n.length?t[n.charAt(s)]:64;++s;let E=s<n.length?t[n.charAt(s)]:64;if(++s,a==null||h==null||m==null||E==null)throw new Bd;let I=a<<2|h>>4;if(r.push(I),m!==64){let k=h<<4&240|m>>2;if(r.push(k),E!==64){let B=m<<6&192|E;r.push(B)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let n=0;n<this.ENCODED_VALS.length;n++)this.byteToCharMap_[n]=this.ENCODED_VALS.charAt(n),this.charToByteMap_[this.byteToCharMap_[n]]=n,this.byteToCharMapWebSafe_[n]=this.ENCODED_VALS_WEBSAFE.charAt(n),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[n]]=n,n>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(n)]=n,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(n)]=n)}}},Bd=class extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}},dL=function(n){let e=g0(n);return _0.encodeByteArray(e,!0)},ru=function(n){return dL(n).replace(/\./g,"")},y0=function(n){try{return _0.decodeString(n,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function pL(){if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof global!="undefined")return global;throw new Error("Unable to locate global object.")}var mL=()=>pL().__FIREBASE_DEFAULTS__,gL=()=>{if(typeof process=="undefined"||typeof process.env=="undefined")return;let n=process.env.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},_L=()=>{if(typeof document=="undefined")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}let e=n&&y0(n[1]);return e&&JSON.parse(e)},jd=()=>{try{return mL()||gL()||_L()}catch(n){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${n}`);return}},yL=n=>{var e,t;return(t=(e=jd())===null||e===void 0?void 0:e.emulatorHosts)===null||t===void 0?void 0:t[n]},v0=n=>{let e=yL(n);if(!e)return;let t=e.lastIndexOf(":");if(t<=0||t+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);let r=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),r]:[e.substring(0,t),r]},$d=()=>{var n;return(n=jd())===null||n===void 0?void 0:n.config};var zl=class{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,r)=>{t?this.reject(t):this.resolve(r),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,r))}}};function w0(n,e){if(n.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');let t={alg:"none",type:"JWT"},r=e||"demo-project",s=n.iat||0,a=n.sub||n.user_id;if(!a)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");let c=Object.assign({iss:`https://securetoken.google.com/${r}`,aud:r,iat:s,exp:s+3600,auth_time:s,sub:a,user_id:a,firebase:{sign_in_provider:"custom",identities:{}}},n);return[ru(JSON.stringify(t)),ru(JSON.stringify(c)),""].join(".")}function b0(){return typeof navigator!="undefined"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function vL(){var n;let e=(n=jd())===null||n===void 0?void 0:n.forceEnvironment;if(e==="node")return!0;if(e==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function T0(){return!vL()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function qd(){try{return typeof indexedDB=="object"}catch{return!1}}function E0(){return new Promise((n,e)=>{try{let t=!0,r="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(r);s.onsuccess=()=>{s.result.close(),t||self.indexedDB.deleteDatabase(r),n(!0)},s.onupgradeneeded=()=>{t=!1},s.onerror=()=>{var a;e(((a=s.error)===null||a===void 0?void 0:a.message)||"")}}catch(t){e(t)}})}var wL="FirebaseError",Er=class n extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name=wL,Object.setPrototypeOf(this,n.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,iu.prototype.create)}},iu=class{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){let r=t[0]||{},s=`${this.service}/${e}`,a=this.errors[e],c=a?bL(a,r):"Error",h=`${this.serviceName}: ${c} (${s}).`;return new Er(s,h,r)}};function bL(n,e){return n.replace(TL,(t,r)=>{let s=e[r];return s!=null?String(s):`<${r}?>`})}var TL=/\{\$([^}]+)}/g;function su(n,e){if(n===e)return!0;let t=Object.keys(n),r=Object.keys(e);for(let s of t){if(!r.includes(s))return!1;let a=n[s],c=e[s];if(m0(a)&&m0(c)){if(!su(a,c))return!1}else if(a!==c)return!1}for(let s of r)if(!t.includes(s))return!1;return!0}function m0(n){return n!==null&&typeof n=="object"}var C6=4*60*60*1e3;function Ir(n){return n&&n._delegate?n._delegate:n}var xr=class{constructor(e,t,r){this.name=e,this.instanceFactory=t,this.type=r,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}};var ss="[DEFAULT]";var zd=class{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){let t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){let r=new zl;if(this.instancesDeferred.set(t,r),this.isInitialized(t)||this.shouldAutoInitialize())try{let s=this.getOrInitializeService({instanceIdentifier:t});s&&r.resolve(s)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;let r=this.normalizeInstanceIdentifier(e==null?void 0:e.identifier),s=(t=e==null?void 0:e.optional)!==null&&t!==void 0?t:!1;if(this.isInitialized(r)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:r})}catch(a){if(s)return null;throw a}else{if(s)return null;throw Error(`Service ${this.name} is not available`)}}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(IL(e))try{this.getOrInitializeService({instanceIdentifier:ss})}catch{}for(let[t,r]of this.instancesDeferred.entries()){let s=this.normalizeInstanceIdentifier(t);try{let a=this.getOrInitializeService({instanceIdentifier:s});r.resolve(a)}catch{}}}}clearInstance(e=ss){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){let e=Array.from(this.instances.values());await Promise.all([...e.filter(t=>"INTERNAL"in t).map(t=>t.INTERNAL.delete()),...e.filter(t=>"_delete"in t).map(t=>t._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=ss){return this.instances.has(e)}getOptions(e=ss){return this.instancesOptions.get(e)||{}}initialize(e={}){let{options:t={}}=e,r=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(r))throw Error(`${this.name}(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);let s=this.getOrInitializeService({instanceIdentifier:r,options:t});for(let[a,c]of this.instancesDeferred.entries()){let h=this.normalizeInstanceIdentifier(a);r===h&&c.resolve(s)}return s}onInit(e,t){var r;let s=this.normalizeInstanceIdentifier(t),a=(r=this.onInitCallbacks.get(s))!==null&&r!==void 0?r:new Set;a.add(e),this.onInitCallbacks.set(s,a);let c=this.instances.get(s);return c&&e(c,s),()=>{a.delete(e)}}invokeOnInitCallbacks(e,t){let r=this.onInitCallbacks.get(t);if(r)for(let s of r)try{s(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let r=this.instances.get(e);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:EL(e),options:t}),this.instances.set(e,r),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(r,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,r)}catch{}return r||null}normalizeInstanceIdentifier(e=ss){return this.component?this.component.multipleInstances?e:ss:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}};function EL(n){return n===ss?void 0:n}function IL(n){return n.instantiationMode==="EAGER"}var Gl=class{constructor(e){this.name=e,this.providers=new Map}addComponent(e){let 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);let t=new zd(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}};var xL=[],Se;(function(n){n[n.DEBUG=0]="DEBUG",n[n.VERBOSE=1]="VERBOSE",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.SILENT=5]="SILENT"})(Se||(Se={}));var AL={debug:Se.DEBUG,verbose:Se.VERBOSE,info:Se.INFO,warn:Se.WARN,error:Se.ERROR,silent:Se.SILENT},SL=Se.INFO,RL={[Se.DEBUG]:"log",[Se.VERBOSE]:"log",[Se.INFO]:"info",[Se.WARN]:"warn",[Se.ERROR]:"error"},PL=(n,e,...t)=>{if(e<n.logLevel)return;let r=new Date().toISOString(),s=RL[e];if(s)console[s](`[${r}] ${n.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)},xo=class{constructor(e){this.name=e,this._logLevel=SL,this._logHandler=PL,this._userLogHandler=null,xL.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in Se))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?AL[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")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,Se.DEBUG,...e),this._logHandler(this,Se.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,Se.VERBOSE,...e),this._logHandler(this,Se.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,Se.INFO,...e),this._logHandler(this,Se.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,Se.WARN,...e),this._logHandler(this,Se.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,Se.ERROR,...e),this._logHandler(this,Se.ERROR,...e)}};var CL=(n,e)=>e.some(t=>n instanceof t),I0,x0;function DL(){return I0||(I0=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function OL(){return x0||(x0=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var A0=new WeakMap,Kd=new WeakMap,S0=new WeakMap,Gd=new WeakMap,Hd=new WeakMap;function kL(n){let e=new Promise((t,r)=>{let s=()=>{n.removeEventListener("success",a),n.removeEventListener("error",c)},a=()=>{t(Gn(n.result)),s()},c=()=>{r(n.error),s()};n.addEventListener("success",a),n.addEventListener("error",c)});return e.then(t=>{t instanceof IDBCursor&&A0.set(t,n)}).catch(()=>{}),Hd.set(e,n),e}function NL(n){if(Kd.has(n))return;let e=new Promise((t,r)=>{let s=()=>{n.removeEventListener("complete",a),n.removeEventListener("error",c),n.removeEventListener("abort",c)},a=()=>{t(),s()},c=()=>{r(n.error||new DOMException("AbortError","AbortError")),s()};n.addEventListener("complete",a),n.addEventListener("error",c),n.addEventListener("abort",c)});Kd.set(n,e)}var Wd={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return Kd.get(n);if(e==="objectStoreNames")return n.objectStoreNames||S0.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return Gn(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function R0(n){Wd=n(Wd)}function VL(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){let r=n.call(Kl(this),e,...t);return S0.set(r,e.sort?e.sort():[e]),Gn(r)}:OL().includes(n)?function(...e){return n.apply(Kl(this),e),Gn(A0.get(this))}:function(...e){return Gn(n.apply(Kl(this),e))}}function LL(n){return typeof n=="function"?VL(n):(n instanceof IDBTransaction&&NL(n),CL(n,DL())?new Proxy(n,Wd):n)}function Gn(n){if(n instanceof IDBRequest)return kL(n);if(Gd.has(n))return Gd.get(n);let e=LL(n);return e!==n&&(Gd.set(n,e),Hd.set(e,n)),e}var Kl=n=>Hd.get(n);function C0(n,e,{blocked:t,upgrade:r,blocking:s,terminated:a}={}){let c=indexedDB.open(n,e),h=Gn(c);return r&&c.addEventListener("upgradeneeded",f=>{r(Gn(c.result),f.oldVersion,f.newVersion,Gn(c.transaction),f)}),t&&c.addEventListener("blocked",f=>t(f.oldVersion,f.newVersion,f)),h.then(f=>{a&&f.addEventListener("close",()=>a()),s&&f.addEventListener("versionchange",m=>s(m.oldVersion,m.newVersion,m))}).catch(()=>{}),h}var ML=["get","getKey","getAll","getAllKeys","count"],FL=["put","add","delete","clear"],Qd=new Map;function P0(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(Qd.get(e))return Qd.get(e);let t=e.replace(/FromIndex$/,""),r=e!==t,s=FL.includes(t);if(!(t in(r?IDBIndex:IDBObjectStore).prototype)||!(s||ML.includes(t)))return;let a=async function(c,...h){let f=this.transaction(c,s?"readwrite":"readonly"),m=f.store;return r&&(m=m.index(h.shift())),(await Promise.all([m[t](...h),s&&f.done]))[0]};return Qd.set(e,a),a}R0(n=>({...n,get:(e,t,r)=>P0(e,t)||n.get(e,t,r),has:(e,t)=>!!P0(e,t)||n.has(e,t)}));var Yd=class{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(UL(t)){let r=t.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(t=>t).join(" ")}};function UL(n){let e=n.getComponent();return(e==null?void 0:e.type)==="VERSION"}var Xd="@firebase/app",D0="0.11.1";var Ar=new xo("@firebase/app"),BL="@firebase/app-compat",jL="@firebase/analytics-compat",$L="@firebase/analytics",qL="@firebase/app-check-compat",zL="@firebase/app-check",GL="@firebase/auth",KL="@firebase/auth-compat",WL="@firebase/database",HL="@firebase/data-connect",QL="@firebase/database-compat",JL="@firebase/functions",YL="@firebase/functions-compat",XL="@firebase/installations",ZL="@firebase/installations-compat",e2="@firebase/messaging",t2="@firebase/messaging-compat",n2="@firebase/performance",r2="@firebase/performance-compat",i2="@firebase/remote-config",s2="@firebase/remote-config-compat",o2="@firebase/storage",a2="@firebase/storage-compat",u2="@firebase/firestore",c2="@firebase/vertexai",l2="@firebase/firestore-compat",h2="firebase",f2="11.3.1";var Zd="[DEFAULT]",d2={[Xd]:"fire-core",[BL]:"fire-core-compat",[$L]:"fire-analytics",[jL]:"fire-analytics-compat",[zL]:"fire-app-check",[qL]:"fire-app-check-compat",[GL]:"fire-auth",[KL]:"fire-auth-compat",[WL]:"fire-rtdb",[HL]:"fire-data-connect",[QL]:"fire-rtdb-compat",[JL]:"fire-fn",[YL]:"fire-fn-compat",[XL]:"fire-iid",[ZL]:"fire-iid-compat",[e2]:"fire-fcm",[t2]:"fire-fcm-compat",[n2]:"fire-perf",[r2]:"fire-perf-compat",[i2]:"fire-rc",[s2]:"fire-rc-compat",[o2]:"fire-gcs",[a2]:"fire-gcs-compat",[u2]:"fire-fst",[l2]:"fire-fst-compat",[c2]:"fire-vertex","fire-js":"fire-js",[h2]:"fire-js-all"};var Wl=new Map,p2=new Map,ep=new Map;function O0(n,e){try{n.container.addComponent(e)}catch(t){Ar.debug(`Component ${e.name} failed to register with FirebaseApp ${n.name}`,t)}}function ou(n){let e=n.name;if(ep.has(e))return Ar.debug(`There were multiple attempts to register component ${e}.`),!1;ep.set(e,n);for(let t of Wl.values())O0(t,n);for(let t of p2.values())O0(t,n);return!0}function L0(n,e){let t=n.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),n.container.getProvider(e)}function M0(n){return n==null?!1:n.settings!==void 0}var m2={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},mi=new iu("app","Firebase",m2);var tp=class{constructor(e,t,r){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new xr("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 mi.create("app-deleted",{appName:this._name})}};var F0=f2;function ip(n,e={}){let t=n;typeof e!="object"&&(e={name:e});let r=Object.assign({name:Zd,automaticDataCollectionEnabled:!1},e),s=r.name;if(typeof s!="string"||!s)throw mi.create("bad-app-name",{appName:String(s)});if(t||(t=$d()),!t)throw mi.create("no-options");let a=Wl.get(s);if(a){if(su(t,a.options)&&su(r,a.config))return a;throw mi.create("duplicate-app",{appName:s})}let c=new Gl(s);for(let f of ep.values())c.addComponent(f);let h=new tp(t,r,c);return Wl.set(s,h),h}function U0(n=Zd){let e=Wl.get(n);if(!e&&n===Zd&&$d())return ip();if(!e)throw mi.create("no-app",{appName:n});return e}function gi(n,e,t){var r;let s=(r=d2[n])!==null&&r!==void 0?r:n;t&&(s+=`-${t}`);let a=s.match(/\s|\//),c=e.match(/\s|\//);if(a||c){let h=[`Unable to register library "${s}" with version "${e}":`];a&&h.push(`library name "${s}" contains illegal characters (whitespace or "/")`),a&&c&&h.push("and"),c&&h.push(`version name "${e}" contains illegal characters (whitespace or "/")`),Ar.warn(h.join(" "));return}ou(new xr(`${s}-version`,()=>({library:s,version:e}),"VERSION"))}var g2="firebase-heartbeat-database",_2=1,au="firebase-heartbeat-store",Jd=null;function B0(){return Jd||(Jd=C0(g2,_2,{upgrade:(n,e)=>{switch(e){case 0:try{n.createObjectStore(au)}catch(t){console.warn(t)}}}}).catch(n=>{throw mi.create("idb-open",{originalErrorMessage:n.message})})),Jd}async function y2(n){try{let t=(await B0()).transaction(au),r=await t.objectStore(au).get(j0(n));return await t.done,r}catch(e){if(e instanceof Er)Ar.warn(e.message);else{let t=mi.create("idb-get",{originalErrorMessage:e==null?void 0:e.message});Ar.warn(t.message)}}}async function k0(n,e){try{let r=(await B0()).transaction(au,"readwrite");await r.objectStore(au).put(e,j0(n)),await r.done}catch(t){if(t instanceof Er)Ar.warn(t.message);else{let r=mi.create("idb-set",{originalErrorMessage:t==null?void 0:t.message});Ar.warn(r.message)}}}function j0(n){return`${n.name}!${n.options.appId}`}var v2=1024,w2=30,np=class{constructor(e){this.container=e,this._heartbeatsCache=null;let t=this.container.getProvider("app").getImmediate();this._storage=new rp(t),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}async triggerHeartbeat(){var e,t;try{let s=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),a=N0();if(((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((t=this._heartbeatsCache)===null||t===void 0?void 0:t.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===a||this._heartbeatsCache.heartbeats.some(c=>c.date===a))return;if(this._heartbeatsCache.heartbeats.push({date:a,agent:s}),this._heartbeatsCache.heartbeats.length>w2){let c=T2(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(c,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(r){Ar.warn(r)}}async getHeartbeatsHeader(){var e;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";let t=N0(),{heartbeatsToSend:r,unsentEntries:s}=b2(this._heartbeatsCache.heartbeats),a=ru(JSON.stringify({version:2,heartbeats:r}));return this._heartbeatsCache.lastSentHeartbeatDate=t,s.length>0?(this._heartbeatsCache.heartbeats=s,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),a}catch(t){return Ar.warn(t),""}}};function N0(){return new Date().toISOString().substring(0,10)}function b2(n,e=v2){let t=[],r=n.slice();for(let s of n){let a=t.find(c=>c.agent===s.agent);if(a){if(a.dates.push(s.date),V0(t)>e){a.dates.pop();break}}else if(t.push({agent:s.agent,dates:[s.date]}),V0(t)>e){t.pop();break}r=r.slice(1)}return{heartbeatsToSend:t,unsentEntries:r}}var rp=class{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return qd()?E0().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){let t=await y2(this.app);return t!=null&&t.heartbeats?t:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){let s=await this.read();return k0(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:s.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){var t;if(await this._canUseIndexedDBPromise){let s=await this.read();return k0(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:s.lastSentHeartbeatDate,heartbeats:[...s.heartbeats,...e.heartbeats]})}else return}};function V0(n){return ru(JSON.stringify({version:2,heartbeats:n})).length}function T2(n){if(n.length===0)return-1;let e=0,t=n[0].date;for(let r=1;r<n.length;r++)n[r].date<t&&(t=n[r].date,e=r);return e}function E2(n){ou(new xr("platform-logger",e=>new Yd(e),"PRIVATE")),ou(new xr("heartbeat",e=>new np(e),"PRIVATE")),gi(Xd,D0,n),gi(Xd,D0,"esm2017"),gi("fire-js","")}E2("");var I2="firebase",x2="11.3.1";gi(I2,x2,"app");var $0=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},q0={};var Sr,sp;(function(){var n;function e(C,A){function R(){}R.prototype=A.prototype,C.D=A.prototype,C.prototype=new R,C.prototype.constructor=C,C.C=function(D,V,M){for(var S=Array(arguments.length-2),pn=2;pn<arguments.length;pn++)S[pn-2]=arguments[pn];return A.prototype[V].apply(D,S)}}function t(){this.blockSize=-1}function r(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.B=Array(this.blockSize),this.o=this.h=0,this.s()}e(r,t),r.prototype.s=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function s(C,A,R){R||(R=0);var D=Array(16);if(typeof A=="string")for(var V=0;16>V;++V)D[V]=A.charCodeAt(R++)|A.charCodeAt(R++)<<8|A.charCodeAt(R++)<<16|A.charCodeAt(R++)<<24;else for(V=0;16>V;++V)D[V]=A[R++]|A[R++]<<8|A[R++]<<16|A[R++]<<24;A=C.g[0],R=C.g[1],V=C.g[2];var M=C.g[3],S=A+(M^R&(V^M))+D[0]+3614090360&4294967295;A=R+(S<<7&4294967295|S>>>25),S=M+(V^A&(R^V))+D[1]+3905402710&4294967295,M=A+(S<<12&4294967295|S>>>20),S=V+(R^M&(A^R))+D[2]+606105819&4294967295,V=M+(S<<17&4294967295|S>>>15),S=R+(A^V&(M^A))+D[3]+3250441966&4294967295,R=V+(S<<22&4294967295|S>>>10),S=A+(M^R&(V^M))+D[4]+4118548399&4294967295,A=R+(S<<7&4294967295|S>>>25),S=M+(V^A&(R^V))+D[5]+1200080426&4294967295,M=A+(S<<12&4294967295|S>>>20),S=V+(R^M&(A^R))+D[6]+2821735955&4294967295,V=M+(S<<17&4294967295|S>>>15),S=R+(A^V&(M^A))+D[7]+4249261313&4294967295,R=V+(S<<22&4294967295|S>>>10),S=A+(M^R&(V^M))+D[8]+1770035416&4294967295,A=R+(S<<7&4294967295|S>>>25),S=M+(V^A&(R^V))+D[9]+2336552879&4294967295,M=A+(S<<12&4294967295|S>>>20),S=V+(R^M&(A^R))+D[10]+4294925233&4294967295,V=M+(S<<17&4294967295|S>>>15),S=R+(A^V&(M^A))+D[11]+2304563134&4294967295,R=V+(S<<22&4294967295|S>>>10),S=A+(M^R&(V^M))+D[12]+1804603682&4294967295,A=R+(S<<7&4294967295|S>>>25),S=M+(V^A&(R^V))+D[13]+4254626195&4294967295,M=A+(S<<12&4294967295|S>>>20),S=V+(R^M&(A^R))+D[14]+2792965006&4294967295,V=M+(S<<17&4294967295|S>>>15),S=R+(A^V&(M^A))+D[15]+1236535329&4294967295,R=V+(S<<22&4294967295|S>>>10),S=A+(V^M&(R^V))+D[1]+4129170786&4294967295,A=R+(S<<5&4294967295|S>>>27),S=M+(R^V&(A^R))+D[6]+3225465664&4294967295,M=A+(S<<9&4294967295|S>>>23),S=V+(A^R&(M^A))+D[11]+643717713&4294967295,V=M+(S<<14&4294967295|S>>>18),S=R+(M^A&(V^M))+D[0]+3921069994&4294967295,R=V+(S<<20&4294967295|S>>>12),S=A+(V^M&(R^V))+D[5]+3593408605&4294967295,A=R+(S<<5&4294967295|S>>>27),S=M+(R^V&(A^R))+D[10]+38016083&4294967295,M=A+(S<<9&4294967295|S>>>23),S=V+(A^R&(M^A))+D[15]+3634488961&4294967295,V=M+(S<<14&4294967295|S>>>18),S=R+(M^A&(V^M))+D[4]+3889429448&4294967295,R=V+(S<<20&4294967295|S>>>12),S=A+(V^M&(R^V))+D[9]+568446438&4294967295,A=R+(S<<5&4294967295|S>>>27),S=M+(R^V&(A^R))+D[14]+3275163606&4294967295,M=A+(S<<9&4294967295|S>>>23),S=V+(A^R&(M^A))+D[3]+4107603335&4294967295,V=M+(S<<14&4294967295|S>>>18),S=R+(M^A&(V^M))+D[8]+1163531501&4294967295,R=V+(S<<20&4294967295|S>>>12),S=A+(V^M&(R^V))+D[13]+2850285829&4294967295,A=R+(S<<5&4294967295|S>>>27),S=M+(R^V&(A^R))+D[2]+4243563512&4294967295,M=A+(S<<9&4294967295|S>>>23),S=V+(A^R&(M^A))+D[7]+1735328473&4294967295,V=M+(S<<14&4294967295|S>>>18),S=R+(M^A&(V^M))+D[12]+2368359562&4294967295,R=V+(S<<20&4294967295|S>>>12),S=A+(R^V^M)+D[5]+4294588738&4294967295,A=R+(S<<4&4294967295|S>>>28),S=M+(A^R^V)+D[8]+2272392833&4294967295,M=A+(S<<11&4294967295|S>>>21),S=V+(M^A^R)+D[11]+1839030562&4294967295,V=M+(S<<16&4294967295|S>>>16),S=R+(V^M^A)+D[14]+4259657740&4294967295,R=V+(S<<23&4294967295|S>>>9),S=A+(R^V^M)+D[1]+2763975236&4294967295,A=R+(S<<4&4294967295|S>>>28),S=M+(A^R^V)+D[4]+1272893353&4294967295,M=A+(S<<11&4294967295|S>>>21),S=V+(M^A^R)+D[7]+4139469664&4294967295,V=M+(S<<16&4294967295|S>>>16),S=R+(V^M^A)+D[10]+3200236656&4294967295,R=V+(S<<23&4294967295|S>>>9),S=A+(R^V^M)+D[13]+681279174&4294967295,A=R+(S<<4&4294967295|S>>>28),S=M+(A^R^V)+D[0]+3936430074&4294967295,M=A+(S<<11&4294967295|S>>>21),S=V+(M^A^R)+D[3]+3572445317&4294967295,V=M+(S<<16&4294967295|S>>>16),S=R+(V^M^A)+D[6]+76029189&4294967295,R=V+(S<<23&4294967295|S>>>9),S=A+(R^V^M)+D[9]+3654602809&4294967295,A=R+(S<<4&4294967295|S>>>28),S=M+(A^R^V)+D[12]+3873151461&4294967295,M=A+(S<<11&4294967295|S>>>21),S=V+(M^A^R)+D[15]+530742520&4294967295,V=M+(S<<16&4294967295|S>>>16),S=R+(V^M^A)+D[2]+3299628645&4294967295,R=V+(S<<23&4294967295|S>>>9),S=A+(V^(R|~M))+D[0]+4096336452&4294967295,A=R+(S<<6&4294967295|S>>>26),S=M+(R^(A|~V))+D[7]+1126891415&4294967295,M=A+(S<<10&4294967295|S>>>22),S=V+(A^(M|~R))+D[14]+2878612391&4294967295,V=M+(S<<15&4294967295|S>>>17),S=R+(M^(V|~A))+D[5]+4237533241&4294967295,R=V+(S<<21&4294967295|S>>>11),S=A+(V^(R|~M))+D[12]+1700485571&4294967295,A=R+(S<<6&4294967295|S>>>26),S=M+(R^(A|~V))+D[3]+2399980690&4294967295,M=A+(S<<10&4294967295|S>>>22),S=V+(A^(M|~R))+D[10]+4293915773&4294967295,V=M+(S<<15&4294967295|S>>>17),S=R+(M^(V|~A))+D[1]+2240044497&4294967295,R=V+(S<<21&4294967295|S>>>11),S=A+(V^(R|~M))+D[8]+1873313359&4294967295,A=R+(S<<6&4294967295|S>>>26),S=M+(R^(A|~V))+D[15]+4264355552&4294967295,M=A+(S<<10&4294967295|S>>>22),S=V+(A^(M|~R))+D[6]+2734768916&4294967295,V=M+(S<<15&4294967295|S>>>17),S=R+(M^(V|~A))+D[13]+1309151649&4294967295,R=V+(S<<21&4294967295|S>>>11),S=A+(V^(R|~M))+D[4]+4149444226&4294967295,A=R+(S<<6&4294967295|S>>>26),S=M+(R^(A|~V))+D[11]+3174756917&4294967295,M=A+(S<<10&4294967295|S>>>22),S=V+(A^(M|~R))+D[2]+718787259&4294967295,V=M+(S<<15&4294967295|S>>>17),S=R+(M^(V|~A))+D[9]+3951481745&4294967295,C.g[0]=C.g[0]+A&4294967295,C.g[1]=C.g[1]+(V+(S<<21&4294967295|S>>>11))&4294967295,C.g[2]=C.g[2]+V&4294967295,C.g[3]=C.g[3]+M&4294967295}r.prototype.u=function(C,A){A===void 0&&(A=C.length);for(var R=A-this.blockSize,D=this.B,V=this.h,M=0;M<A;){if(V==0)for(;M<=R;)s(this,C,M),M+=this.blockSize;if(typeof C=="string"){for(;M<A;)if(D[V++]=C.charCodeAt(M++),V==this.blockSize){s(this,D),V=0;break}}else for(;M<A;)if(D[V++]=C[M++],V==this.blockSize){s(this,D),V=0;break}}this.h=V,this.o+=A},r.prototype.v=function(){var C=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);C[0]=128;for(var A=1;A<C.length-8;++A)C[A]=0;var R=8*this.o;for(A=C.length-8;A<C.length;++A)C[A]=R&255,R/=256;for(this.u(C),C=Array(16),A=R=0;4>A;++A)for(var D=0;32>D;D+=8)C[R++]=this.g[A]>>>D&255;return C};function a(C,A){var R=h;return Object.prototype.hasOwnProperty.call(R,C)?R[C]:R[C]=A(C)}function c(C,A){this.h=A;for(var R=[],D=!0,V=C.length-1;0<=V;V--){var M=C[V]|0;D&&M==A||(R[V]=M,D=!1)}this.g=R}var h={};function f(C){return-128<=C&&128>C?a(C,function(A){return new c([A|0],0>A?-1:0)}):new c([C|0],0>C?-1:0)}function m(C){if(isNaN(C)||!isFinite(C))return E;if(0>C)return j(m(-C));for(var A=[],R=1,D=0;C>=R;D++)A[D]=C/R|0,R*=4294967296;return new c(A,0)}function _(C,A){if(C.length==0)throw Error("number format error: empty string");if(A=A||10,2>A||36<A)throw Error("radix out of range: "+A);if(C.charAt(0)=="-")return j(_(C.substring(1),A));if(0<=C.indexOf("-"))throw Error('number format error: interior "-" character');for(var R=m(Math.pow(A,8)),D=E,V=0;V<C.length;V+=8){var M=Math.min(8,C.length-V),S=parseInt(C.substring(V,V+M),A);8>M?(M=m(Math.pow(A,M)),D=D.j(M).add(m(S))):(D=D.j(R),D=D.add(m(S)))}return D}var E=f(0),I=f(1),k=f(16777216);n=c.prototype,n.m=function(){if(G(this))return-j(this).m();for(var C=0,A=1,R=0;R<this.g.length;R++){var D=this.i(R);C+=(0<=D?D:4294967296+D)*A,A*=4294967296}return C},n.toString=function(C){if(C=C||10,2>C||36<C)throw Error("radix out of range: "+C);if(B(this))return"0";if(G(this))return"-"+j(this).toString(C);for(var A=m(Math.pow(C,6)),R=this,D="";;){var V=le(R,A).g;R=J(R,V.j(A));var M=((0<R.g.length?R.g[0]:R.h)>>>0).toString(C);if(R=V,B(R))return M+D;for(;6>M.length;)M="0"+M;D=M+D}},n.i=function(C){return 0>C?0:C<this.g.length?this.g[C]:this.h};function B(C){if(C.h!=0)return!1;for(var A=0;A<C.g.length;A++)if(C.g[A]!=0)return!1;return!0}function G(C){return C.h==-1}n.l=function(C){return C=J(this,C),G(C)?-1:B(C)?0:1};function j(C){for(var A=C.g.length,R=[],D=0;D<A;D++)R[D]=~C.g[D];return new c(R,~C.h).add(I)}n.abs=function(){return G(this)?j(this):this},n.add=function(C){for(var A=Math.max(this.g.length,C.g.length),R=[],D=0,V=0;V<=A;V++){var M=D+(this.i(V)&65535)+(C.i(V)&65535),S=(M>>>16)+(this.i(V)>>>16)+(C.i(V)>>>16);D=S>>>16,M&=65535,S&=65535,R[V]=S<<16|M}return new c(R,R[R.length-1]&-2147483648?-1:0)};function J(C,A){return C.add(j(A))}n.j=function(C){if(B(this)||B(C))return E;if(G(this))return G(C)?j(this).j(j(C)):j(j(this).j(C));if(G(C))return j(this.j(j(C)));if(0>this.l(k)&&0>C.l(k))return m(this.m()*C.m());for(var A=this.g.length+C.g.length,R=[],D=0;D<2*A;D++)R[D]=0;for(D=0;D<this.g.length;D++)for(var V=0;V<C.g.length;V++){var M=this.i(D)>>>16,S=this.i(D)&65535,pn=C.i(V)>>>16,Kt=C.i(V)&65535;R[2*D+2*V]+=S*Kt,ee(R,2*D+2*V),R[2*D+2*V+1]+=M*Kt,ee(R,2*D+2*V+1),R[2*D+2*V+1]+=S*pn,ee(R,2*D+2*V+1),R[2*D+2*V+2]+=M*pn,ee(R,2*D+2*V+2)}for(D=0;D<A;D++)R[D]=R[2*D+1]<<16|R[2*D];for(D=A;D<2*A;D++)R[D]=0;return new c(R,0)};function ee(C,A){for(;(C[A]&65535)!=C[A];)C[A+1]+=C[A]>>>16,C[A]&=65535,A++}function ne(C,A){this.g=C,this.h=A}function le(C,A){if(B(A))throw Error("division by zero");if(B(C))return new ne(E,E);if(G(C))return A=le(j(C),A),new ne(j(A.g),j(A.h));if(G(A))return A=le(C,j(A)),new ne(j(A.g),A.h);if(30<C.g.length){if(G(C)||G(A))throw Error("slowDivide_ only works with positive integers.");for(var R=I,D=A;0>=D.l(C);)R=de(R),D=de(D);var V=ie(R,1),M=ie(D,1);for(D=ie(D,2),R=ie(R,2);!B(D);){var S=M.add(D);0>=S.l(C)&&(V=V.add(R),M=S),D=ie(D,1),R=ie(R,1)}return A=J(C,V.j(A)),new ne(V,A)}for(V=E;0<=C.l(A);){for(R=Math.max(1,Math.floor(C.m()/A.m())),D=Math.ceil(Math.log(R)/Math.LN2),D=48>=D?1:Math.pow(2,D-48),M=m(R),S=M.j(A);G(S)||0<S.l(C);)R-=D,M=m(R),S=M.j(A);B(M)&&(M=I),V=V.add(M),C=J(C,S)}return new ne(V,C)}n.A=function(C){return le(this,C).h},n.and=function(C){for(var A=Math.max(this.g.length,C.g.length),R=[],D=0;D<A;D++)R[D]=this.i(D)&C.i(D);return new c(R,this.h&C.h)},n.or=function(C){for(var A=Math.max(this.g.length,C.g.length),R=[],D=0;D<A;D++)R[D]=this.i(D)|C.i(D);return new c(R,this.h|C.h)},n.xor=function(C){for(var A=Math.max(this.g.length,C.g.length),R=[],D=0;D<A;D++)R[D]=this.i(D)^C.i(D);return new c(R,this.h^C.h)};function de(C){for(var A=C.g.length+1,R=[],D=0;D<A;D++)R[D]=C.i(D)<<1|C.i(D-1)>>>31;return new c(R,C.h)}function ie(C,A){var R=A>>5;A%=32;for(var D=C.g.length-R,V=[],M=0;M<D;M++)V[M]=0<A?C.i(M+R)>>>A|C.i(M+R+1)<<32-A:C.i(M+R);return new c(V,C.h)}r.prototype.digest=r.prototype.v,r.prototype.reset=r.prototype.s,r.prototype.update=r.prototype.u,sp=q0.Md5=r,c.prototype.add=c.prototype.add,c.prototype.multiply=c.prototype.j,c.prototype.modulo=c.prototype.A,c.prototype.compare=c.prototype.l,c.prototype.toNumber=c.prototype.m,c.prototype.toString=c.prototype.toString,c.prototype.getBits=c.prototype.i,c.fromNumber=m,c.fromString=_,Sr=q0.Integer=c}).apply(typeof $0!="undefined"?$0:typeof self!="undefined"?self:typeof window!="undefined"?window:{});var Hl=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},Rr={};var op,A2,Ao,ap,uu,Ql,up,cp,lp;(function(){var n,e=typeof Object.defineProperties=="function"?Object.defineProperty:function(u,d,g){return u==Array.prototype||u==Object.prototype||(u[d]=g.value),u};function t(u){u=[typeof globalThis=="object"&&globalThis,u,typeof window=="object"&&window,typeof self=="object"&&self,typeof Hl=="object"&&Hl];for(var d=0;d<u.length;++d){var g=u[d];if(g&&g.Math==Math)return g}throw Error("Cannot find global object")}var r=t(this);function s(u,d){if(d)e:{var g=r;u=u.split(".");for(var b=0;b<u.length-1;b++){var L=u[b];if(!(L in g))break e;g=g[L]}u=u[u.length-1],b=g[u],d=d(b),d!=b&&d!=null&&e(g,u,{configurable:!0,writable:!0,value:d})}}function a(u,d){u instanceof String&&(u+="");var g=0,b=!1,L={next:function(){if(!b&&g<u.length){var F=g++;return{value:d(F,u[F]),done:!1}}return b=!0,{done:!0,value:void 0}}};return L[Symbol.iterator]=function(){return L},L}s("Array.prototype.values",function(u){return u||function(){return a(this,function(d,g){return g})}});var c=c||{},h=this||self;function f(u){var d=typeof u;return d=d!="object"?d:u?Array.isArray(u)?"array":d:"null",d=="array"||d=="object"&&typeof u.length=="number"}function m(u){var d=typeof u;return d=="object"&&u!=null||d=="function"}function _(u,d,g){return u.call.apply(u.bind,arguments)}function E(u,d,g){if(!u)throw Error();if(2<arguments.length){var b=Array.prototype.slice.call(arguments,2);return function(){var L=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(L,b),u.apply(d,L)}}return function(){return u.apply(d,arguments)}}function I(u,d,g){return I=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?_:E,I.apply(null,arguments)}function k(u,d){var g=Array.prototype.slice.call(arguments,1);return function(){var b=g.slice();return b.push.apply(b,arguments),u.apply(this,b)}}function B(u,d){function g(){}g.prototype=d.prototype,u.aa=d.prototype,u.prototype=new g,u.prototype.constructor=u,u.Qb=function(b,L,F){for(var Q=Array(arguments.length-2),_e=2;_e<arguments.length;_e++)Q[_e-2]=arguments[_e];return d.prototype[L].apply(b,Q)}}function G(u){let d=u.length;if(0<d){let g=Array(d);for(let b=0;b<d;b++)g[b]=u[b];return g}return[]}function j(u,d){for(let g=1;g<arguments.length;g++){let b=arguments[g];if(f(b)){let L=u.length||0,F=b.length||0;u.length=L+F;for(let Q=0;Q<F;Q++)u[L+Q]=b[Q]}else u.push(b)}}class J{constructor(d,g){this.i=d,this.j=g,this.h=0,this.g=null}get(){let d;return 0<this.h?(this.h--,d=this.g,this.g=d.next,d.next=null):d=this.i(),d}}function ee(u){return/^[\s\xa0]*$/.test(u)}function ne(){var u=h.navigator;return u&&(u=u.userAgent)?u:""}function le(u){return le[" "](u),u}le[" "]=function(){};var de=ne().indexOf("Gecko")!=-1&&!(ne().toLowerCase().indexOf("webkit")!=-1&&ne().indexOf("Edge")==-1)&&!(ne().indexOf("Trident")!=-1||ne().indexOf("MSIE")!=-1)&&ne().indexOf("Edge")==-1;function ie(u,d,g){for(let b in u)d.call(g,u[b],b,u)}function C(u,d){for(let g in u)d.call(void 0,u[g],g,u)}function A(u){let d={};for(let g in u)d[g]=u[g];return d}let R="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function D(u,d){let g,b;for(let L=1;L<arguments.length;L++){b=arguments[L];for(g in b)u[g]=b[g];for(let F=0;F<R.length;F++)g=R[F],Object.prototype.hasOwnProperty.call(b,g)&&(u[g]=b[g])}}function V(u){var d=1;u=u.split(":");let g=[];for(;0<d&&u.length;)g.push(u.shift()),d--;return u.length&&g.push(u.join(":")),g}function M(u){h.setTimeout(()=>{throw u},0)}function S(){var u=Nt;let d=null;return u.g&&(d=u.g,u.g=u.g.next,u.g||(u.h=null),d.next=null),d}class pn{constructor(){this.h=this.g=null}add(d,g){let b=Kt.get();b.set(d,g),this.h?this.h.next=b:this.g=b,this.h=b}}var Kt=new J(()=>new Cn,u=>u.reset());class Cn{constructor(){this.next=this.g=this.h=null}set(d,g){this.h=d,this.g=g,this.next=null}reset(){this.next=this.g=this.h=null}}let Ai,Dn=!1,Nt=new pn,sc=()=>{let u=h.Promise.resolve(void 0);Ai=()=>{u.then(yf)}};var yf=()=>{for(var u;u=S();){try{u.h.call(u.g)}catch(g){M(g)}var d=Kt;d.j(u),100>d.h&&(d.h++,u.next=d.g,d.g=u)}Dn=!1};function On(){this.s=this.s,this.C=this.C}On.prototype.s=!1,On.prototype.ma=function(){this.s||(this.s=!0,this.N())},On.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function Ge(u,d){this.type=u,this.g=this.target=d,this.defaultPrevented=!1}Ge.prototype.h=function(){this.defaultPrevented=!0};var Cs=function(){if(!h.addEventListener||!Object.defineProperty)return!1;var u=!1,d=Object.defineProperty({},"passive",{get:function(){u=!0}});try{let g=()=>{};h.addEventListener("test",g,d),h.removeEventListener("test",g,d)}catch{}return u}();function Si(u,d){if(Ge.call(this,u?u.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,u){var g=this.type=u.type,b=u.changedTouches&&u.changedTouches.length?u.changedTouches[0]:null;if(this.target=u.target||u.srcElement,this.g=d,d=u.relatedTarget){if(de){e:{try{le(d.nodeName);var L=!0;break e}catch{}L=!1}L||(d=null)}}else g=="mouseover"?d=u.fromElement:g=="mouseout"&&(d=u.toElement);this.relatedTarget=d,b?(this.clientX=b.clientX!==void 0?b.clientX:b.pageX,this.clientY=b.clientY!==void 0?b.clientY:b.pageY,this.screenX=b.screenX||0,this.screenY=b.screenY||0):(this.clientX=u.clientX!==void 0?u.clientX:u.pageX,this.clientY=u.clientY!==void 0?u.clientY:u.pageY,this.screenX=u.screenX||0,this.screenY=u.screenY||0),this.button=u.button,this.key=u.key||"",this.ctrlKey=u.ctrlKey,this.altKey=u.altKey,this.shiftKey=u.shiftKey,this.metaKey=u.metaKey,this.pointerId=u.pointerId||0,this.pointerType=typeof u.pointerType=="string"?u.pointerType:Ri[u.pointerType]||"",this.state=u.state,this.i=u,u.defaultPrevented&&Si.aa.h.call(this)}}B(Si,Ge);var Ri={2:"touch",3:"pen",4:"mouse"};Si.prototype.h=function(){Si.aa.h.call(this);var u=this.i;u.preventDefault?u.preventDefault():u.returnValue=!1};var mn="closure_listenable_"+(1e6*Math.random()|0),vf=0;function Ds(u,d,g,b,L){this.listener=u,this.proxy=null,this.src=d,this.type=g,this.capture=!!b,this.ha=L,this.key=++vf,this.da=this.fa=!1}function rr(u){u.da=!0,u.listener=null,u.proxy=null,u.src=null,u.ha=null}function Pi(u){this.src=u,this.g={},this.h=0}Pi.prototype.add=function(u,d,g,b,L){var F=u.toString();u=this.g[F],u||(u=this.g[F]=[],this.h++);var Q=ir(u,d,b,L);return-1<Q?(d=u[Q],g||(d.fa=!1)):(d=new Ds(d,this.src,F,!!b,L),d.fa=g,u.push(d)),d};function St(u,d){var g=d.type;if(g in u.g){var b=u.g[g],L=Array.prototype.indexOf.call(b,d,void 0),F;(F=0<=L)&&Array.prototype.splice.call(b,L,1),F&&(rr(d),u.g[g].length==0&&(delete u.g[g],u.h--))}}function ir(u,d,g,b){for(var L=0;L<u.length;++L){var F=u[L];if(!F.da&&F.listener==d&&F.capture==!!g&&F.ha==b)return L}return-1}var da="closure_lm_"+(1e6*Math.random()|0),Wt={};function pa(u,d,g,b,L){if(b&&b.once)return Vt(u,d,g,b,L);if(Array.isArray(d)){for(var F=0;F<d.length;F++)pa(u,d[F],g,b,L);return null}return g=kn(g),u&&u[mn]?u.K(d,g,m(b)?!!b.capture:!!b,L):oc(u,d,g,!1,b,L)}function oc(u,d,g,b,L,F){if(!d)throw Error("Invalid event type");var Q=m(L)?!!L.capture:!!L,_e=ma(u);if(_e||(u[da]=_e=new Pi(u)),g=_e.add(d,g,b,Q,F),g.proxy)return g;if(b=Ci(),g.proxy=b,b.src=u,b.listener=g,u.addEventListener)Cs||(L=Q),L===void 0&&(L=!1),u.addEventListener(d.toString(),b,L);else if(u.attachEvent)u.attachEvent(ac(d.toString()),b);else if(u.addListener&&u.removeListener)u.addListener(b);else throw Error("addEventListener and attachEvent are unavailable.");return g}function Ci(){function u(g){return d.call(u.src,u.listener,g)}let d=Di;return u}function Vt(u,d,g,b,L){if(Array.isArray(d)){for(var F=0;F<d.length;F++)Vt(u,d[F],g,b,L);return null}return g=kn(g),u&&u[mn]?u.L(d,g,m(b)?!!b.capture:!!b,L):oc(u,d,g,!0,b,L)}function Lr(u,d,g,b,L){if(Array.isArray(d))for(var F=0;F<d.length;F++)Lr(u,d[F],g,b,L);else b=m(b)?!!b.capture:!!b,g=kn(g),u&&u[mn]?(u=u.i,d=String(d).toString(),d in u.g&&(F=u.g[d],g=ir(F,g,b,L),-1<g&&(rr(F[g]),Array.prototype.splice.call(F,g,1),F.length==0&&(delete u.g[d],u.h--)))):u&&(u=ma(u))&&(d=u.g[d.toString()],u=-1,d&&(u=ir(d,g,b,L)),(g=-1<u?d[u]:null)&&Mr(g))}function Mr(u){if(typeof u!="number"&&u&&!u.da){var d=u.src;if(d&&d[mn])St(d.i,u);else{var g=u.type,b=u.proxy;d.removeEventListener?d.removeEventListener(g,b,u.capture):d.detachEvent?d.detachEvent(ac(g),b):d.addListener&&d.removeListener&&d.removeListener(b),(g=ma(d))?(St(g,u),g.h==0&&(g.src=null,d[da]=null)):rr(u)}}}function ac(u){return u in Wt?Wt[u]:Wt[u]="on"+u}function Di(u,d){if(u.da)u=!0;else{d=new Si(d,this);var g=u.listener,b=u.ha||u.src;u.fa&&Mr(u),u=g.call(b,d)}return u}function ma(u){return u=u[da],u instanceof Pi?u:null}var sr="__closure_events_fn_"+(1e9*Math.random()>>>0);function kn(u){return typeof u=="function"?u:(u[sr]||(u[sr]=function(d){return u.handleEvent(d)}),u[sr])}function nt(){On.call(this),this.i=new Pi(this),this.M=this,this.F=null}B(nt,On),nt.prototype[mn]=!0,nt.prototype.removeEventListener=function(u,d,g,b){Lr(this,u,d,g,b)};function at(u,d){var g,b=u.F;if(b)for(g=[];b;b=b.F)g.push(b);if(u=u.M,b=d.type||d,typeof d=="string")d=new Ge(d,u);else if(d instanceof Ge)d.target=d.target||u;else{var L=d;d=new Ge(b,u),D(d,L)}if(L=!0,g)for(var F=g.length-1;0<=F;F--){var Q=d.g=g[F];L=Fr(Q,b,!0,d)&&L}if(Q=d.g=u,L=Fr(Q,b,!0,d)&&L,L=Fr(Q,b,!1,d)&&L,g)for(F=0;F<g.length;F++)Q=d.g=g[F],L=Fr(Q,b,!1,d)&&L}nt.prototype.N=function(){if(nt.aa.N.call(this),this.i){var u=this.i,d;for(d in u.g){for(var g=u.g[d],b=0;b<g.length;b++)rr(g[b]);delete u.g[d],u.h--}}this.F=null},nt.prototype.K=function(u,d,g,b){return this.i.add(String(u),d,!1,g,b)},nt.prototype.L=function(u,d,g,b){return this.i.add(String(u),d,!0,g,b)};function Fr(u,d,g,b){if(d=u.i.g[String(d)],!d)return!0;d=d.concat();for(var L=!0,F=0;F<d.length;++F){var Q=d[F];if(Q&&!Q.da&&Q.capture==g){var _e=Q.listener,Xe=Q.ha||Q.src;Q.fa&&St(u.i,Q),L=_e.call(Xe,b)!==!1&&L}}return L&&!b.defaultPrevented}function Os(u,d,g){if(typeof u=="function")g&&(u=I(u,g));else if(u&&typeof u.handleEvent=="function")u=I(u.handleEvent,u);else throw Error("Invalid listener argument");return 2147483647<Number(d)?-1:h.setTimeout(u,d||0)}function ks(u){u.g=Os(()=>{u.g=null,u.i&&(u.i=!1,ks(u))},u.l);let d=u.h;u.h=null,u.m.apply(null,d)}class ga extends On{constructor(d,g){super(),this.m=d,this.l=g,this.h=null,this.i=!1,this.g=null}j(d){this.h=arguments,this.g?this.i=!0:ks(this)}N(){super.N(),this.g&&(h.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function or(u){On.call(this),this.h=u,this.g={}}B(or,On);var Ns=[];function Vs(u){ie(u.g,function(d,g){this.g.hasOwnProperty(g)&&Mr(d)},u),u.g={}}or.prototype.N=function(){or.aa.N.call(this),Vs(this)},or.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var _a=h.JSON.stringify,wf=h.JSON.parse,bf=class{stringify(u){return h.JSON.stringify(u,void 0)}parse(u){return h.JSON.parse(u,void 0)}};function Ls(){}Ls.prototype.h=null;function ya(u){return u.h||(u.h=u.i())}function uc(){}var Oi={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function va(){Ge.call(this,"d")}B(va,Ge);function wa(){Ge.call(this,"c")}B(wa,Ge);var Nn={},cc=null;function Ms(){return cc=cc||new nt}Nn.La="serverreachability";function lc(u){Ge.call(this,Nn.La,u)}B(lc,Ge);function ar(u){let d=Ms();at(d,new lc(d))}Nn.STAT_EVENT="statevent";function hc(u,d){Ge.call(this,Nn.STAT_EVENT,u),this.stat=d}B(hc,Ge);function ut(u){let d=Ms();at(d,new hc(d,u))}Nn.Ma="timingevent";function fc(u,d){Ge.call(this,Nn.Ma,u),this.size=d}B(fc,Ge);function ki(u,d){if(typeof u!="function")throw Error("Fn must not be null and must be a function");return h.setTimeout(function(){u()},d)}function Ni(){this.g=!0}Ni.prototype.xa=function(){this.g=!1};function Tf(u,d,g,b,L,F){u.info(function(){if(u.g)if(F)for(var Q="",_e=F.split("&"),Xe=0;Xe<_e.length;Xe++){var be=_e[Xe].split("=");if(1<be.length){var ct=be[0];be=be[1];var lt=ct.split("_");Q=2<=lt.length&&lt[1]=="type"?Q+(ct+"="+be+"&"):Q+(ct+"=redacted&")}}else Q=null;else Q=F;return"XMLHTTP REQ ("+b+") [attempt "+L+"]: "+d+`
20
+ }`;var ve=jy(function(){return Ne(T,te+"return "+K).apply(r,x)});if(ve.source=K,wd(ve))throw ve;return ve}function HR(i){return Ve(i).toLowerCase()}function QR(i){return Ve(i).toUpperCase()}function JR(i,o,l){if(i=Ve(i),i&&(l||o===r))return Q(i);if(!i||!(o=Jt(o)))return i;var p=br(i),y=br(o),T=lt(p,y),x=ht(p,y)+1;return ti(p,T,x).join("")}function YR(i,o,l){if(i=Ve(i),i&&(l||o===r))return i.slice(0,e_(i)+1);if(!i||!(o=Jt(o)))return i;var p=br(i),y=ht(p,br(o))+1;return ti(p,0,y).join("")}function XR(i,o,l){if(i=Ve(i),i&&(l||o===r))return i.replace(ct,"");if(!i||!(o=Jt(o)))return i;var p=br(i),y=lt(p,br(o));return ti(p,y).join("")}function ZR(i,o){var l=A,p=R;if(We(o)){var y="separator"in o?o.separator:y;l="length"in o?ye(o.length):l,p="omission"in o?Jt(o.omission):p}i=Ve(i);var T=i.length;if(Js(i)){var x=br(i);T=x.length}if(l>=T)return i;var P=l-Ys(p);if(P<1)return p;var N=x?ti(x,0,P).join(""):i.slice(0,P);if(y===r)return N+p;if(x&&(P+=N.length-P),bd(y)){if(i.slice(P).search(y)){var q,z=N;for(y.global||(y=Mf(y.source,Ve(Vi.exec(y))+"g")),y.lastIndex=0;q=y.exec(z);)var K=q.index;N=N.slice(0,K===r?P:K)}}else if(i.indexOf(Jt(y),P)!=P){var Y=N.lastIndexOf(y);Y>-1&&(N=N.slice(0,Y))}return N+p}function eP(i){return i=Ve(i),i&&lc.test(i)?i.replace(Ls,PI):i}var tP=no(function(i,o,l){return i+(l?" ":"")+o.toUpperCase()}),Id=$_("toUpperCase");function By(i,o,l){return i=Ve(i),o=l?r:o,o===r?II(i)?OI(i):Mc(i):i.match(o)||[]}var jy=we(function(i,o){try{return Et(i,r,o)}catch(l){return wd(l)?l:new he(l)}}),rP=pn(function(i,o){return Ft(o,function(l){l=Br(l),fn(i,l,yd(i[l],i))}),i});function nP(i){var o=i==null?0:i.length,l=se();return i=o?Fe(i,function(p){if(typeof p[1]!="function")throw new nr(s);return[l(p[0]),p[1]]}):[],we(function(p){for(var y=-1;++y<o;){var T=i[y];if(Et(T[0],this,p))return Et(T[1],this,p)}})}function iP(i){return Px(sr(i,m))}function xd(i){return function(){return i}}function sP(i,o){return i==null||i!==i?o:i}var oP=z_(),aP=z_(!0);function $t(i){return i}function Ad(i){return w_(typeof i=="function"?i:sr(i,m))}function uP(i){return T_(sr(i,m))}function cP(i,o){return E_(i,sr(o,m))}var lP=we(function(i,o){return function(l){return Ka(l,i,o)}}),hP=we(function(i,o){return function(l){return Ka(i,l,o)}});function Sd(i,o,l){var p=mt(o),y=tl(o,p);l==null&&!(We(o)&&(y.length||!p.length))&&(l=o,o=i,i=this,y=tl(o,mt(o)));var T=!(We(l)&&"chain"in l)||!!l.chain,x=gn(i);return Ft(y,function(P){var N=o[P];i[P]=N,x&&(i.prototype[P]=function(){var q=this.__chain__;if(T||q){var z=i(this.__wrapped__),K=z.__actions__=Ut(this.__actions__);return K.push({func:N,args:arguments,thisArg:i}),z.__chain__=q,z}return N.apply(i,vr([this.value()],arguments))})}),i}function fP(){return Xe._===this&&(Xe._=FI),this}function Rd(){}function dP(i){return i=ye(i),we(function(o){return I_(o,i)})}var pP=sd(Fe),mP=sd(Kn),gP=sd(Hs);function $y(i){return fd(i)?Mr(Br(i)):Kx(i)}function _P(i){return function(o){return i==null?r:Zi(i,o)}}var yP=K_(),vP=K_(!0);function Pd(){return[]}function Cd(){return!1}function wP(){return{}}function bP(){return""}function TP(){return!0}function EP(i,o){if(i=ye(i),i<1||i>Pr)return[];var l=Lt,p=It(i,Lt);o=se(o),i-=Lt;for(var y=L(p,o);++l<i;)o(l);return y}function IP(i){return pe(i)?Fe(i,Br):Yt(i)?[i]:Ut(uy(Ve(i)))}function xP(i){var o=++LI;return Ve(i)+o}var AP=al(function(i,o){return i+o},0),SP=od("ceil"),RP=al(function(i,o){return i/o},1),PP=od("floor");function CP(i){return i&&i.length?el(i,$t,Gf):r}function DP(i,o){return i&&i.length?el(i,se(o,2),Gf):r}function OP(i){return Ma(i,$t)}function kP(i,o){return Ma(i,se(o,2))}function NP(i){return i&&i.length?el(i,$t,Qf):r}function VP(i,o){return i&&i.length?el(i,se(o,2),Qf):r}var LP=al(function(i,o){return i*o},1),MP=od("round"),FP=al(function(i,o){return i-o},0);function UP(i){return i&&i.length?b(i,$t):0}function BP(i,o){return i&&i.length?b(i,se(o,2)):0}return w.after=u1,w.ary=vy,w.assign=Q1,w.assignIn=ky,w.assignInWith=wl,w.assignWith=J1,w.at=Y1,w.before=wy,w.bind=yd,w.bindAll=rP,w.bindKey=by,w.castArray=w1,w.chain=gy,w.chunk=PA,w.compact=CA,w.concat=DA,w.cond=nP,w.conforms=iP,w.constant=xd,w.countBy=US,w.create=X1,w.curry=Ty,w.curryRight=Ey,w.debounce=Iy,w.defaults=Z1,w.defaultsDeep=eR,w.defer=c1,w.delay=l1,w.difference=OA,w.differenceBy=kA,w.differenceWith=NA,w.drop=VA,w.dropRight=LA,w.dropRightWhile=MA,w.dropWhile=FA,w.fill=UA,w.filter=jS,w.flatMap=zS,w.flatMapDeep=GS,w.flatMapDepth=KS,w.flatten=fy,w.flattenDeep=BA,w.flattenDepth=jA,w.flip=h1,w.flow=oP,w.flowRight=aP,w.fromPairs=$A,w.functions=aR,w.functionsIn=uR,w.groupBy=WS,w.initial=zA,w.intersection=GA,w.intersectionBy=KA,w.intersectionWith=WA,w.invert=lR,w.invertBy=hR,w.invokeMap=QS,w.iteratee=Ad,w.keyBy=JS,w.keys=mt,w.keysIn=jt,w.map=pl,w.mapKeys=dR,w.mapValues=pR,w.matches=uP,w.matchesProperty=cP,w.memoize=gl,w.merge=mR,w.mergeWith=Ny,w.method=lP,w.methodOf=hP,w.mixin=Sd,w.negate=_l,w.nthArg=dP,w.omit=gR,w.omitBy=_R,w.once=f1,w.orderBy=YS,w.over=pP,w.overArgs=d1,w.overEvery=mP,w.overSome=gP,w.partial=vd,w.partialRight=xy,w.partition=XS,w.pick=yR,w.pickBy=Vy,w.property=$y,w.propertyOf=_P,w.pull=YA,w.pullAll=py,w.pullAllBy=XA,w.pullAllWith=ZA,w.pullAt=eS,w.range=yP,w.rangeRight=vP,w.rearg=p1,w.reject=t1,w.remove=tS,w.rest=m1,w.reverse=gd,w.sampleSize=n1,w.set=wR,w.setWith=bR,w.shuffle=i1,w.slice=rS,w.sortBy=a1,w.sortedUniq=cS,w.sortedUniqBy=lS,w.split=zR,w.spread=g1,w.tail=hS,w.take=fS,w.takeRight=dS,w.takeRightWhile=pS,w.takeWhile=mS,w.tap=CS,w.throttle=_1,w.thru=dl,w.toArray=Cy,w.toPairs=Ly,w.toPairsIn=My,w.toPath=IP,w.toPlainObject=Oy,w.transform=TR,w.unary=y1,w.union=gS,w.unionBy=_S,w.unionWith=yS,w.uniq=vS,w.uniqBy=wS,w.uniqWith=bS,w.unset=ER,w.unzip=_d,w.unzipWith=my,w.update=IR,w.updateWith=xR,w.values=oo,w.valuesIn=AR,w.without=TS,w.words=By,w.wrap=v1,w.xor=ES,w.xorBy=IS,w.xorWith=xS,w.zip=AS,w.zipObject=SS,w.zipObjectDeep=RS,w.zipWith=PS,w.entries=Ly,w.entriesIn=My,w.extend=ky,w.extendWith=wl,Sd(w,w),w.add=AP,w.attempt=jy,w.camelCase=CR,w.capitalize=Fy,w.ceil=SP,w.clamp=SR,w.clone=b1,w.cloneDeep=E1,w.cloneDeepWith=I1,w.cloneWith=T1,w.conformsTo=x1,w.deburr=Uy,w.defaultTo=sP,w.divide=RP,w.endsWith=DR,w.eq=Er,w.escape=OR,w.escapeRegExp=kR,w.every=BS,w.find=$S,w.findIndex=ly,w.findKey=tR,w.findLast=qS,w.findLastIndex=hy,w.findLastKey=rR,w.floor=PP,w.forEach=_y,w.forEachRight=yy,w.forIn=nR,w.forInRight=iR,w.forOwn=sR,w.forOwnRight=oR,w.get=Td,w.gt=A1,w.gte=S1,w.has=cR,w.hasIn=Ed,w.head=dy,w.identity=$t,w.includes=HS,w.indexOf=qA,w.inRange=RR,w.invoke=fR,w.isArguments=rs,w.isArray=pe,w.isArrayBuffer=R1,w.isArrayLike=Bt,w.isArrayLikeObject=et,w.isBoolean=P1,w.isBuffer=ri,w.isDate=C1,w.isElement=D1,w.isEmpty=O1,w.isEqual=k1,w.isEqualWith=N1,w.isError=wd,w.isFinite=V1,w.isFunction=gn,w.isInteger=Ay,w.isLength=yl,w.isMap=Sy,w.isMatch=L1,w.isMatchWith=M1,w.isNaN=F1,w.isNative=U1,w.isNil=j1,w.isNull=B1,w.isNumber=Ry,w.isObject=We,w.isObjectLike=Qe,w.isPlainObject=Xa,w.isRegExp=bd,w.isSafeInteger=$1,w.isSet=Py,w.isString=vl,w.isSymbol=Yt,w.isTypedArray=so,w.isUndefined=q1,w.isWeakMap=z1,w.isWeakSet=G1,w.join=HA,w.kebabCase=NR,w.last=ar,w.lastIndexOf=QA,w.lowerCase=VR,w.lowerFirst=LR,w.lt=K1,w.lte=W1,w.max=CP,w.maxBy=DP,w.mean=OP,w.meanBy=kP,w.min=NP,w.minBy=VP,w.stubArray=Pd,w.stubFalse=Cd,w.stubObject=wP,w.stubString=bP,w.stubTrue=TP,w.multiply=LP,w.nth=JA,w.noConflict=fP,w.noop=Rd,w.now=ml,w.pad=MR,w.padEnd=FR,w.padStart=UR,w.parseInt=BR,w.random=PR,w.reduce=ZS,w.reduceRight=e1,w.repeat=jR,w.replace=$R,w.result=vR,w.round=MP,w.runInContext=O,w.sample=r1,w.size=s1,w.snakeCase=qR,w.some=o1,w.sortedIndex=nS,w.sortedIndexBy=iS,w.sortedIndexOf=sS,w.sortedLastIndex=oS,w.sortedLastIndexBy=aS,w.sortedLastIndexOf=uS,w.startCase=GR,w.startsWith=KR,w.subtract=FP,w.sum=UP,w.sumBy=BP,w.template=WR,w.times=EP,w.toFinite=_n,w.toInteger=ye,w.toLength=Dy,w.toLower=HR,w.toNumber=ur,w.toSafeInteger=H1,w.toString=Ve,w.toUpper=QR,w.trim=JR,w.trimEnd=YR,w.trimStart=XR,w.truncate=ZR,w.unescape=eP,w.uniqueId=xP,w.upperCase=tP,w.upperFirst=Id,w.each=_y,w.eachRight=yy,w.first=dy,Sd(w,function(){var i={};return Fr(w,function(o,l){Me.call(w.prototype,l)||(i[l]=o)}),i}(),{chain:!1}),w.VERSION=e,Ft(["bind","bindKey","curry","curryRight","partial","partialRight"],function(i){w[i].placeholder=w}),Ft(["drop","take"],function(i,o){Ie.prototype[i]=function(l){l=l===r?1:dt(ye(l),0);var p=this.__filtered__&&!o?new Ie(this):this.clone();return p.__filtered__?p.__takeCount__=It(l,p.__takeCount__):p.__views__.push({size:It(l,Lt),type:i+(p.__dir__<0?"Right":"")}),p},Ie.prototype[i+"Right"]=function(l){return this.reverse()[i](l).reverse()}}),Ft(["filter","map","takeWhile"],function(i,o){var l=o+1,p=l==M||l==dr;Ie.prototype[i]=function(y){var T=this.clone();return T.__iteratees__.push({iteratee:se(y,3),type:l}),T.__filtered__=T.__filtered__||p,T}}),Ft(["head","last"],function(i,o){var l="take"+(o?"Right":"");Ie.prototype[i]=function(){return this[l](1).value()[0]}}),Ft(["initial","tail"],function(i,o){var l="drop"+(o?"":"Right");Ie.prototype[i]=function(){return this.__filtered__?new Ie(this):this[l](1)}}),Ie.prototype.compact=function(){return this.filter($t)},Ie.prototype.find=function(i){return this.filter(i).head()},Ie.prototype.findLast=function(i){return this.reverse().find(i)},Ie.prototype.invokeMap=we(function(i,o){return typeof i=="function"?new Ie(this):this.map(function(l){return Ka(l,i,o)})}),Ie.prototype.reject=function(i){return this.filter(_l(se(i)))},Ie.prototype.slice=function(i,o){i=ye(i);var l=this;return l.__filtered__&&(i>0||o<0)?new Ie(l):(i<0?l=l.takeRight(-i):i&&(l=l.drop(i)),o!==r&&(o=ye(o),l=o<0?l.dropRight(-o):l.take(o-i)),l)},Ie.prototype.takeRightWhile=function(i){return this.reverse().takeWhile(i).reverse()},Ie.prototype.toArray=function(){return this.take(Lt)},Fr(Ie.prototype,function(i,o){var l=/^(?:filter|find|map|reject)|While$/.test(o),p=/^(?:head|last)$/.test(o),y=w[p?"take"+(o=="last"?"Right":""):o],T=p||/^find/.test(o);y&&(w.prototype[o]=function(){var x=this.__wrapped__,P=p?[1]:arguments,N=x instanceof Ie,q=P[0],z=N||pe(x),K=function(Te){var Ae=y.apply(w,vr([Te],P));return p&&Y?Ae[0]:Ae};z&&l&&typeof q=="function"&&q.length!=1&&(N=z=!1);var Y=this.__chain__,te=!!this.__actions__.length,oe=T&&!Y,ve=N&&!te;if(!T&&z){x=ve?x:new Ie(this);var ae=i.apply(x,P);return ae.__actions__.push({func:dl,args:[K],thisArg:r}),new ir(ae,Y)}return oe&&ve?i.apply(this,P):(ae=this.thru(K),oe?p?ae.value()[0]:ae.value():ae)})}),Ft(["pop","push","shift","sort","splice","unshift"],function(i){var o=Uc[i],l=/^(?:push|sort|unshift)$/.test(i)?"tap":"thru",p=/^(?:pop|shift)$/.test(i);w.prototype[i]=function(){var y=arguments;if(p&&!this.__chain__){var T=this.value();return o.apply(pe(T)?T:[],y)}return this[l](function(x){return o.apply(pe(x)?x:[],y)})}}),Fr(Ie.prototype,function(i,o){var l=w[o];if(l){var p=l.name+"";Me.call(eo,p)||(eo[p]=[]),eo[p].push({name:o,func:l})}}),eo[ol(r,G).name]=[{name:"wrapper",func:r}],Ie.prototype.clone=ex,Ie.prototype.reverse=tx,Ie.prototype.value=rx,w.prototype.at=DS,w.prototype.chain=OS,w.prototype.commit=kS,w.prototype.next=NS,w.prototype.plant=LS,w.prototype.reverse=MS,w.prototype.toJSON=w.prototype.valueOf=w.prototype.value=FS,w.prototype.first=w.prototype.head,Ua&&(w.prototype[Ua]=VS),w},Jn=kI();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Xe._=Jn,define(function(){return Jn})):Lr?((Lr.exports=Jn)._=Jn,zs._=Jn):Xe._=Jn}).call(fa)});var hI=cr((YW,lI)=>{var yf=uI();function cI(r,e){var t={};return Object.keys(r).sort(e||void 0).forEach(function(n){t[n]=r[n]}),t}function Jg(r,e){if(yf.isArray(r))return yf.map(r,function(n){return Jg(n,e)});if(yf.isObject(r)){var t=cI(r,e);return yf.forEach(t,function(n,s){t[s]=Jg(n)}),t}else return r}lI.exports={keyArrange:cI,keyArrangeDeep:Jg}});var JP=typeof global=="object"&&global&&global.Object===Object&&global,bl=JP;var YP=typeof self=="object"&&self&&self.Object===Object&&self,XP=bl||YP||Function("return this")(),Je=XP;var ZP=Je.Symbol,Nt=ZP;var Gy=Object.prototype,eC=Gy.hasOwnProperty,tC=Gy.toString,eu=Nt?Nt.toStringTag:void 0;function rC(r){var e=eC.call(r,eu),t=r[eu];try{r[eu]=void 0;var n=!0}catch{}var s=tC.call(r);return n&&(e?r[eu]=t:delete r[eu]),s}var Ky=rC;var nC=Object.prototype,iC=nC.toString;function sC(r){return iC.call(r)}var Wy=sC;var oC="[object Null]",aC="[object Undefined]",Hy=Nt?Nt.toStringTag:void 0;function uC(r){return r==null?r===void 0?aC:oC:Hy&&Hy in Object(r)?Ky(r):Wy(r)}var xr=uC;function cC(r){return r!=null&&typeof r=="object"}var Vt=cC;var lC="[object Symbol]";function hC(r){return typeof r=="symbol"||Vt(r)&&xr(r)==lC}var ni=hC;function fC(r,e){for(var t=-1,n=r==null?0:r.length,s=Array(n);++t<n;)s[t]=e(r[t],t,r);return s}var Qy=fC;var dC=Array.isArray,rt=dC;var pC=1/0,Jy=Nt?Nt.prototype:void 0,Yy=Jy?Jy.toString:void 0;function Xy(r){if(typeof r=="string")return r;if(rt(r))return Qy(r,Xy)+"";if(ni(r))return Yy?Yy.call(r):"";var e=r+"";return e=="0"&&1/r==-pC?"-0":e}var Zy=Xy;var mC=/\s/;function gC(r){for(var e=r.length;e--&&mC.test(r.charAt(e)););return e}var ev=gC;var _C=/^\s+/;function yC(r){return r&&r.slice(0,ev(r)+1).replace(_C,"")}var tv=yC;function vC(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var De=vC;var rv=NaN,wC=/^[-+]0x[0-9a-f]+$/i,bC=/^0b[01]+$/i,TC=/^0o[0-7]+$/i,EC=parseInt;function IC(r){if(typeof r=="number")return r;if(ni(r))return rv;if(De(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=De(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=tv(r);var t=bC.test(r);return t||TC.test(r)?EC(r.slice(2),t?2:8):wC.test(r)?rv:+r}var Od=IC;function xC(r){return r}var ao=xC;var AC="[object AsyncFunction]",SC="[object Function]",RC="[object GeneratorFunction]",PC="[object Proxy]";function CC(r){if(!De(r))return!1;var e=xr(r);return e==SC||e==RC||e==AC||e==PC}var Tl=CC;var DC=Je["__core-js_shared__"],El=DC;var nv=function(){var r=/[^.]+$/.exec(El&&El.keys&&El.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function OC(r){return!!nv&&nv in r}var iv=OC;var kC=Function.prototype,NC=kC.toString;function VC(r){if(r!=null){try{return NC.call(r)}catch{}try{return r+""}catch{}}return""}var vn=VC;var LC=/[\\^$.*+?()[\]{}|]/g,MC=/^\[object .+?Constructor\]$/,FC=Function.prototype,UC=Object.prototype,BC=FC.toString,jC=UC.hasOwnProperty,$C=RegExp("^"+BC.call(jC).replace(LC,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function qC(r){if(!De(r)||iv(r))return!1;var e=Tl(r)?$C:MC;return e.test(vn(r))}var sv=qC;function zC(r,e){return r==null?void 0:r[e]}var ov=zC;function GC(r,e){var t=ov(r,e);return sv(t)?t:void 0}var qt=GC;var KC=qt(Je,"WeakMap"),Il=KC;var av=Object.create,WC=function(){function r(){}return function(e){if(!De(e))return{};if(av)return av(e);r.prototype=e;var t=new r;return r.prototype=void 0,t}}(),uv=WC;function HC(r,e,t){switch(t.length){case 0:return r.call(e);case 1:return r.call(e,t[0]);case 2:return r.call(e,t[0],t[1]);case 3:return r.call(e,t[0],t[1],t[2])}return r.apply(e,t)}var cv=HC;function QC(r,e){var t=-1,n=r.length;for(e||(e=Array(n));++t<n;)e[t]=r[t];return e}var lv=QC;var JC=800,YC=16,XC=Date.now;function ZC(r){var e=0,t=0;return function(){var n=XC(),s=YC-(n-t);if(t=n,s>0){if(++e>=JC)return arguments[0]}else e=0;return r.apply(void 0,arguments)}}var hv=ZC;function eD(r){return function(){return r}}var fv=eD;var tD=function(){try{var r=qt(Object,"defineProperty");return r({},"",{}),r}catch{}}(),uo=tD;var rD=uo?function(r,e){return uo(r,"toString",{configurable:!0,enumerable:!1,value:fv(e),writable:!0})}:ao,dv=rD;var nD=hv(dv),pv=nD;function iD(r,e){for(var t=-1,n=r==null?0:r.length;++t<n&&e(r[t],t,r)!==!1;);return r}var mv=iD;var sD=9007199254740991,oD=/^(?:0|[1-9]\d*)$/;function aD(r,e){var t=typeof r;return e=e==null?sD:e,!!e&&(t=="number"||t!="symbol"&&oD.test(r))&&r>-1&&r%1==0&&r<e}var ii=aD;function uD(r,e,t){e=="__proto__"&&uo?uo(r,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):r[e]=t}var co=uD;function cD(r,e){return r===e||r!==r&&e!==e}var jr=cD;var lD=Object.prototype,hD=lD.hasOwnProperty;function fD(r,e,t){var n=r[e];(!(hD.call(r,e)&&jr(n,t))||t===void 0&&!(e in r))&&co(r,e,t)}var lo=fD;function dD(r,e,t,n){var s=!t;t||(t={});for(var a=-1,c=e.length;++a<c;){var h=e[a],f=n?n(t[h],r[h],h,t,r):void 0;f===void 0&&(f=r[h]),s?co(t,h,f):lo(t,h,f)}return t}var si=dD;var gv=Math.max;function pD(r,e,t){return e=gv(e===void 0?r.length-1:e,0),function(){for(var n=arguments,s=-1,a=gv(n.length-e,0),c=Array(a);++s<a;)c[s]=n[e+s];s=-1;for(var h=Array(e+1);++s<e;)h[s]=n[s];return h[e]=t(c),cv(r,this,h)}}var _v=pD;function mD(r,e){return pv(_v(r,e,ao),r+"")}var yv=mD;var gD=9007199254740991;function _D(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=gD}var ho=_D;function yD(r){return r!=null&&ho(r.length)&&!Tl(r)}var oi=yD;function vD(r,e,t){if(!De(t))return!1;var n=typeof e;return(n=="number"?oi(t)&&ii(e,t.length):n=="string"&&e in t)?jr(t[e],r):!1}var vv=vD;var wD=Object.prototype;function bD(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||wD;return r===t}var ai=bD;function TD(r,e){for(var t=-1,n=Array(r);++t<r;)n[t]=e(t);return n}var wv=TD;var ED="[object Arguments]";function ID(r){return Vt(r)&&xr(r)==ED}var kd=ID;var bv=Object.prototype,xD=bv.hasOwnProperty,AD=bv.propertyIsEnumerable,SD=kd(function(){return arguments}())?kd:function(r){return Vt(r)&&xD.call(r,"callee")&&!AD.call(r,"callee")},fo=SD;function RD(){return!1}var Tv=RD;var xv=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ev=xv&&typeof module=="object"&&module&&!module.nodeType&&module,PD=Ev&&Ev.exports===xv,Iv=PD?Je.Buffer:void 0,CD=Iv?Iv.isBuffer:void 0,DD=CD||Tv,wn=DD;var OD="[object Arguments]",kD="[object Array]",ND="[object Boolean]",VD="[object Date]",LD="[object Error]",MD="[object Function]",FD="[object Map]",UD="[object Number]",BD="[object Object]",jD="[object RegExp]",$D="[object Set]",qD="[object String]",zD="[object WeakMap]",GD="[object ArrayBuffer]",KD="[object DataView]",WD="[object Float32Array]",HD="[object Float64Array]",QD="[object Int8Array]",JD="[object Int16Array]",YD="[object Int32Array]",XD="[object Uint8Array]",ZD="[object Uint8ClampedArray]",eO="[object Uint16Array]",tO="[object Uint32Array]",qe={};qe[WD]=qe[HD]=qe[QD]=qe[JD]=qe[YD]=qe[XD]=qe[ZD]=qe[eO]=qe[tO]=!0;qe[OD]=qe[kD]=qe[GD]=qe[ND]=qe[KD]=qe[VD]=qe[LD]=qe[MD]=qe[FD]=qe[UD]=qe[BD]=qe[jD]=qe[$D]=qe[qD]=qe[zD]=!1;function rO(r){return Vt(r)&&ho(r.length)&&!!qe[xr(r)]}var Av=rO;function nO(r){return function(e){return r(e)}}var po=nO;var Sv=typeof exports=="object"&&exports&&!exports.nodeType&&exports,tu=Sv&&typeof module=="object"&&module&&!module.nodeType&&module,iO=tu&&tu.exports===Sv,Nd=iO&&bl.process,sO=function(){try{var r=tu&&tu.require&&tu.require("util").types;return r||Nd&&Nd.binding&&Nd.binding("util")}catch{}}(),bn=sO;var Rv=bn&&bn.isTypedArray,oO=Rv?po(Rv):Av,mo=oO;var aO=Object.prototype,uO=aO.hasOwnProperty;function cO(r,e){var t=rt(r),n=!t&&fo(r),s=!t&&!n&&wn(r),a=!t&&!n&&!s&&mo(r),c=t||n||s||a,h=c?wv(r.length,String):[],f=h.length;for(var m in r)(e||uO.call(r,m))&&!(c&&(m=="length"||s&&(m=="offset"||m=="parent")||a&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||ii(m,f)))&&h.push(m);return h}var xl=cO;function lO(r,e){return function(t){return r(e(t))}}var Al=lO;var hO=Al(Object.keys,Object),Pv=hO;var fO=Object.prototype,dO=fO.hasOwnProperty;function pO(r){if(!ai(r))return Pv(r);var e=[];for(var t in Object(r))dO.call(r,t)&&t!="constructor"&&e.push(t);return e}var Sl=pO;function mO(r){return oi(r)?xl(r):Sl(r)}var At=mO;function gO(r){var e=[];if(r!=null)for(var t in Object(r))e.push(t);return e}var Cv=gO;var _O=Object.prototype,yO=_O.hasOwnProperty;function vO(r){if(!De(r))return Cv(r);var e=ai(r),t=[];for(var n in r)n=="constructor"&&(e||!yO.call(r,n))||t.push(n);return t}var Dv=vO;function wO(r){return oi(r)?xl(r,!0):Dv(r)}var ui=wO;var bO=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,TO=/^\w*$/;function EO(r,e){if(rt(r))return!1;var t=typeof r;return t=="number"||t=="symbol"||t=="boolean"||r==null||ni(r)?!0:TO.test(r)||!bO.test(r)||e!=null&&r in Object(e)}var go=EO;var IO=qt(Object,"create"),Tn=IO;function xO(){this.__data__=Tn?Tn(null):{},this.size=0}var Ov=xO;function AO(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}var kv=AO;var SO="__lodash_hash_undefined__",RO=Object.prototype,PO=RO.hasOwnProperty;function CO(r){var e=this.__data__;if(Tn){var t=e[r];return t===SO?void 0:t}return PO.call(e,r)?e[r]:void 0}var Nv=CO;var DO=Object.prototype,OO=DO.hasOwnProperty;function kO(r){var e=this.__data__;return Tn?e[r]!==void 0:OO.call(e,r)}var Vv=kO;var NO="__lodash_hash_undefined__";function VO(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=Tn&&e===void 0?NO:e,this}var Lv=VO;function _o(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}_o.prototype.clear=Ov;_o.prototype.delete=kv;_o.prototype.get=Nv;_o.prototype.has=Vv;_o.prototype.set=Lv;var Vd=_o;function LO(){this.__data__=[],this.size=0}var Mv=LO;function MO(r,e){for(var t=r.length;t--;)if(jr(r[t][0],e))return t;return-1}var ci=MO;var FO=Array.prototype,UO=FO.splice;function BO(r){var e=this.__data__,t=ci(e,r);if(t<0)return!1;var n=e.length-1;return t==n?e.pop():UO.call(e,t,1),--this.size,!0}var Fv=BO;function jO(r){var e=this.__data__,t=ci(e,r);return t<0?void 0:e[t][1]}var Uv=jO;function $O(r){return ci(this.__data__,r)>-1}var Bv=$O;function qO(r,e){var t=this.__data__,n=ci(t,r);return n<0?(++this.size,t.push([r,e])):t[n][1]=e,this}var jv=qO;function yo(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}yo.prototype.clear=Mv;yo.prototype.delete=Fv;yo.prototype.get=Uv;yo.prototype.has=Bv;yo.prototype.set=jv;var li=yo;var zO=qt(Je,"Map"),hi=zO;function GO(){this.size=0,this.__data__={hash:new Vd,map:new(hi||li),string:new Vd}}var $v=GO;function KO(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}var qv=KO;function WO(r,e){var t=r.__data__;return qv(e)?t[typeof e=="string"?"string":"hash"]:t.map}var fi=WO;function HO(r){var e=fi(this,r).delete(r);return this.size-=e?1:0,e}var zv=HO;function QO(r){return fi(this,r).get(r)}var Gv=QO;function JO(r){return fi(this,r).has(r)}var Kv=JO;function YO(r,e){var t=fi(this,r),n=t.size;return t.set(r,e),this.size+=t.size==n?0:1,this}var Wv=YO;function vo(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}vo.prototype.clear=$v;vo.prototype.delete=zv;vo.prototype.get=Gv;vo.prototype.has=Kv;vo.prototype.set=Wv;var ns=vo;var XO="Expected a function";function Ld(r,e){if(typeof r!="function"||e!=null&&typeof e!="function")throw new TypeError(XO);var t=function(){var n=arguments,s=e?e.apply(this,n):n[0],a=t.cache;if(a.has(s))return a.get(s);var c=r.apply(this,n);return t.cache=a.set(s,c)||a,c};return t.cache=new(Ld.Cache||ns),t}Ld.Cache=ns;var Hv=Ld;var ZO=500;function ek(r){var e=Hv(r,function(n){return t.size===ZO&&t.clear(),n}),t=e.cache;return e}var Qv=ek;var tk=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rk=/\\(\\)?/g,nk=Qv(function(r){var e=[];return r.charCodeAt(0)===46&&e.push(""),r.replace(tk,function(t,n,s,a){e.push(s?a.replace(rk,"$1"):n||t)}),e}),Jv=nk;function ik(r){return r==null?"":Zy(r)}var Yv=ik;function sk(r,e){return rt(r)?r:go(r,e)?[r]:Jv(Yv(r))}var wo=sk;var ok=1/0;function ak(r){if(typeof r=="string"||ni(r))return r;var e=r+"";return e=="0"&&1/r==-ok?"-0":e}var $r=ak;function uk(r,e){e=wo(e,r);for(var t=0,n=e.length;r!=null&&t<n;)r=r[$r(e[t++])];return t&&t==n?r:void 0}var Rl=uk;function ck(r,e,t){var n=r==null?void 0:Rl(r,e);return n===void 0?t:n}var ru=ck;function lk(r,e){for(var t=-1,n=e.length,s=r.length;++t<n;)r[s+t]=e[t];return r}var Pl=lk;var hk=Al(Object.getPrototypeOf,Object),Cl=hk;function fk(){this.__data__=new li,this.size=0}var Xv=fk;function dk(r){var e=this.__data__,t=e.delete(r);return this.size=e.size,t}var Zv=dk;function pk(r){return this.__data__.get(r)}var ew=pk;function mk(r){return this.__data__.has(r)}var tw=mk;var gk=200;function _k(r,e){var t=this.__data__;if(t instanceof li){var n=t.__data__;if(!hi||n.length<gk-1)return n.push([r,e]),this.size=++t.size,this;t=this.__data__=new ns(n)}return t.set(r,e),this.size=t.size,this}var rw=_k;function bo(r){var e=this.__data__=new li(r);this.size=e.size}bo.prototype.clear=Xv;bo.prototype.delete=Zv;bo.prototype.get=ew;bo.prototype.has=tw;bo.prototype.set=rw;var di=bo;function yk(r,e){return r&&si(e,At(e),r)}var nw=yk;function vk(r,e){return r&&si(e,ui(e),r)}var iw=vk;var uw=typeof exports=="object"&&exports&&!exports.nodeType&&exports,sw=uw&&typeof module=="object"&&module&&!module.nodeType&&module,wk=sw&&sw.exports===uw,ow=wk?Je.Buffer:void 0,aw=ow?ow.allocUnsafe:void 0;function bk(r,e){if(e)return r.slice();var t=r.length,n=aw?aw(t):new r.constructor(t);return r.copy(n),n}var cw=bk;function Tk(r,e){for(var t=-1,n=r==null?0:r.length,s=0,a=[];++t<n;){var c=r[t];e(c,t,r)&&(a[s++]=c)}return a}var lw=Tk;function Ek(){return[]}var Dl=Ek;var Ik=Object.prototype,xk=Ik.propertyIsEnumerable,hw=Object.getOwnPropertySymbols,Ak=hw?function(r){return r==null?[]:(r=Object(r),lw(hw(r),function(e){return xk.call(r,e)}))}:Dl,To=Ak;function Sk(r,e){return si(r,To(r),e)}var fw=Sk;var Rk=Object.getOwnPropertySymbols,Pk=Rk?function(r){for(var e=[];r;)Pl(e,To(r)),r=Cl(r);return e}:Dl,Ol=Pk;function Ck(r,e){return si(r,Ol(r),e)}var dw=Ck;function Dk(r,e,t){var n=e(r);return rt(r)?n:Pl(n,t(r))}var kl=Dk;function Ok(r){return kl(r,At,To)}var nu=Ok;function kk(r){return kl(r,ui,Ol)}var pw=kk;var Nk=qt(Je,"DataView"),Nl=Nk;var Vk=qt(Je,"Promise"),Vl=Vk;var Lk=qt(Je,"Set"),Ll=Lk;var mw="[object Map]",Mk="[object Object]",gw="[object Promise]",_w="[object Set]",yw="[object WeakMap]",vw="[object DataView]",Fk=vn(Nl),Uk=vn(hi),Bk=vn(Vl),jk=vn(Ll),$k=vn(Il),is=xr;(Nl&&is(new Nl(new ArrayBuffer(1)))!=vw||hi&&is(new hi)!=mw||Vl&&is(Vl.resolve())!=gw||Ll&&is(new Ll)!=_w||Il&&is(new Il)!=yw)&&(is=function(r){var e=xr(r),t=e==Mk?r.constructor:void 0,n=t?vn(t):"";if(n)switch(n){case Fk:return vw;case Uk:return mw;case Bk:return gw;case jk:return _w;case $k:return yw}return e});var Ar=is;var qk=Object.prototype,zk=qk.hasOwnProperty;function Gk(r){var e=r.length,t=new r.constructor(e);return e&&typeof r[0]=="string"&&zk.call(r,"index")&&(t.index=r.index,t.input=r.input),t}var ww=Gk;var Kk=Je.Uint8Array,Eo=Kk;function Wk(r){var e=new r.constructor(r.byteLength);return new Eo(e).set(new Eo(r)),e}var Io=Wk;function Hk(r,e){var t=e?Io(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.byteLength)}var bw=Hk;var Qk=/\w*$/;function Jk(r){var e=new r.constructor(r.source,Qk.exec(r));return e.lastIndex=r.lastIndex,e}var Tw=Jk;var Ew=Nt?Nt.prototype:void 0,Iw=Ew?Ew.valueOf:void 0;function Yk(r){return Iw?Object(Iw.call(r)):{}}var xw=Yk;function Xk(r,e){var t=e?Io(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.length)}var Aw=Xk;var Zk="[object Boolean]",eN="[object Date]",tN="[object Map]",rN="[object Number]",nN="[object RegExp]",iN="[object Set]",sN="[object String]",oN="[object Symbol]",aN="[object ArrayBuffer]",uN="[object DataView]",cN="[object Float32Array]",lN="[object Float64Array]",hN="[object Int8Array]",fN="[object Int16Array]",dN="[object Int32Array]",pN="[object Uint8Array]",mN="[object Uint8ClampedArray]",gN="[object Uint16Array]",_N="[object Uint32Array]";function yN(r,e,t){var n=r.constructor;switch(e){case aN:return Io(r);case Zk:case eN:return new n(+r);case uN:return bw(r,t);case cN:case lN:case hN:case fN:case dN:case pN:case mN:case gN:case _N:return Aw(r,t);case tN:return new n;case rN:case sN:return new n(r);case nN:return Tw(r);case iN:return new n;case oN:return xw(r)}}var Sw=yN;function vN(r){return typeof r.constructor=="function"&&!ai(r)?uv(Cl(r)):{}}var Rw=vN;var wN="[object Map]";function bN(r){return Vt(r)&&Ar(r)==wN}var Pw=bN;var Cw=bn&&bn.isMap,TN=Cw?po(Cw):Pw,Dw=TN;var EN="[object Set]";function IN(r){return Vt(r)&&Ar(r)==EN}var Ow=IN;var kw=bn&&bn.isSet,xN=kw?po(kw):Ow,Nw=xN;var AN=1,SN=2,RN=4,Vw="[object Arguments]",PN="[object Array]",CN="[object Boolean]",DN="[object Date]",ON="[object Error]",Lw="[object Function]",kN="[object GeneratorFunction]",NN="[object Map]",VN="[object Number]",Mw="[object Object]",LN="[object RegExp]",MN="[object Set]",FN="[object String]",UN="[object Symbol]",BN="[object WeakMap]",jN="[object ArrayBuffer]",$N="[object DataView]",qN="[object Float32Array]",zN="[object Float64Array]",GN="[object Int8Array]",KN="[object Int16Array]",WN="[object Int32Array]",HN="[object Uint8Array]",QN="[object Uint8ClampedArray]",JN="[object Uint16Array]",YN="[object Uint32Array]",Be={};Be[Vw]=Be[PN]=Be[jN]=Be[$N]=Be[CN]=Be[DN]=Be[qN]=Be[zN]=Be[GN]=Be[KN]=Be[WN]=Be[NN]=Be[VN]=Be[Mw]=Be[LN]=Be[MN]=Be[FN]=Be[UN]=Be[HN]=Be[QN]=Be[JN]=Be[YN]=!0;Be[ON]=Be[Lw]=Be[BN]=!1;function Ml(r,e,t,n,s,a){var c,h=e&AN,f=e&SN,m=e&RN;if(t&&(c=s?t(r,n,s,a):t(r)),c!==void 0)return c;if(!De(r))return r;var _=rt(r);if(_){if(c=ww(r),!h)return lv(r,c)}else{var E=Ar(r),I=E==Lw||E==kN;if(wn(r))return cw(r,h);if(E==Mw||E==Vw||I&&!s){if(c=f||I?{}:Rw(r),!h)return f?dw(r,iw(c,r)):fw(r,nw(c,r))}else{if(!Be[E])return s?r:{};c=Sw(r,E,h)}}a||(a=new di);var k=a.get(r);if(k)return k;a.set(r,c),Nw(r)?r.forEach(function(j){c.add(Ml(j,e,t,j,r,a))}):Dw(r)&&r.forEach(function(j,J){c.set(J,Ml(j,e,t,J,r,a))});var B=m?f?pw:nu:f?ui:At,G=_?void 0:B(r);return mv(G||r,function(j,J){G&&(J=j,j=r[J]),lo(c,J,Ml(j,e,t,J,r,a))}),c}var Fw=Ml;var XN=1,ZN=4;function eV(r){return Fw(r,XN|ZN)}var qr=eV;var tV="__lodash_hash_undefined__";function rV(r){return this.__data__.set(r,tV),this}var Uw=rV;function nV(r){return this.__data__.has(r)}var Bw=nV;function Fl(r){var e=-1,t=r==null?0:r.length;for(this.__data__=new ns;++e<t;)this.add(r[e])}Fl.prototype.add=Fl.prototype.push=Uw;Fl.prototype.has=Bw;var jw=Fl;function iV(r,e){for(var t=-1,n=r==null?0:r.length;++t<n;)if(e(r[t],t,r))return!0;return!1}var $w=iV;function sV(r,e){return r.has(e)}var qw=sV;var oV=1,aV=2;function uV(r,e,t,n,s,a){var c=t&oV,h=r.length,f=e.length;if(h!=f&&!(c&&f>h))return!1;var m=a.get(r),_=a.get(e);if(m&&_)return m==e&&_==r;var E=-1,I=!0,k=t&aV?new jw:void 0;for(a.set(r,e),a.set(e,r);++E<h;){var B=r[E],G=e[E];if(n)var j=c?n(G,B,E,e,r,a):n(B,G,E,r,e,a);if(j!==void 0){if(j)continue;I=!1;break}if(k){if(!$w(e,function(J,ee){if(!qw(k,ee)&&(B===J||s(B,J,t,n,a)))return k.push(ee)})){I=!1;break}}else if(!(B===G||s(B,G,t,n,a))){I=!1;break}}return a.delete(r),a.delete(e),I}var Ul=uV;function cV(r){var e=-1,t=Array(r.size);return r.forEach(function(n,s){t[++e]=[s,n]}),t}var zw=cV;function lV(r){var e=-1,t=Array(r.size);return r.forEach(function(n){t[++e]=n}),t}var Gw=lV;var hV=1,fV=2,dV="[object Boolean]",pV="[object Date]",mV="[object Error]",gV="[object Map]",_V="[object Number]",yV="[object RegExp]",vV="[object Set]",wV="[object String]",bV="[object Symbol]",TV="[object ArrayBuffer]",EV="[object DataView]",Kw=Nt?Nt.prototype:void 0,Md=Kw?Kw.valueOf:void 0;function IV(r,e,t,n,s,a,c){switch(t){case EV:if(r.byteLength!=e.byteLength||r.byteOffset!=e.byteOffset)return!1;r=r.buffer,e=e.buffer;case TV:return!(r.byteLength!=e.byteLength||!a(new Eo(r),new Eo(e)));case dV:case pV:case _V:return jr(+r,+e);case mV:return r.name==e.name&&r.message==e.message;case yV:case wV:return r==e+"";case gV:var h=zw;case vV:var f=n&hV;if(h||(h=Gw),r.size!=e.size&&!f)return!1;var m=c.get(r);if(m)return m==e;n|=fV,c.set(r,e);var _=Ul(h(r),h(e),n,s,a,c);return c.delete(r),_;case bV:if(Md)return Md.call(r)==Md.call(e)}return!1}var Ww=IV;var xV=1,AV=Object.prototype,SV=AV.hasOwnProperty;function RV(r,e,t,n,s,a){var c=t&xV,h=nu(r),f=h.length,m=nu(e),_=m.length;if(f!=_&&!c)return!1;for(var E=f;E--;){var I=h[E];if(!(c?I in e:SV.call(e,I)))return!1}var k=a.get(r),B=a.get(e);if(k&&B)return k==e&&B==r;var G=!0;a.set(r,e),a.set(e,r);for(var j=c;++E<f;){I=h[E];var J=r[I],ee=e[I];if(n)var re=c?n(ee,J,I,e,r,a):n(J,ee,I,r,e,a);if(!(re===void 0?J===ee||s(J,ee,t,n,a):re)){G=!1;break}j||(j=I=="constructor")}if(G&&!j){var le=r.constructor,de=e.constructor;le!=de&&"constructor"in r&&"constructor"in e&&!(typeof le=="function"&&le instanceof le&&typeof de=="function"&&de instanceof de)&&(G=!1)}return a.delete(r),a.delete(e),G}var Hw=RV;var PV=1,Qw="[object Arguments]",Jw="[object Array]",Bl="[object Object]",CV=Object.prototype,Yw=CV.hasOwnProperty;function DV(r,e,t,n,s,a){var c=rt(r),h=rt(e),f=c?Jw:Ar(r),m=h?Jw:Ar(e);f=f==Qw?Bl:f,m=m==Qw?Bl:m;var _=f==Bl,E=m==Bl,I=f==m;if(I&&wn(r)){if(!wn(e))return!1;c=!0,_=!1}if(I&&!_)return a||(a=new di),c||mo(r)?Ul(r,e,t,n,s,a):Ww(r,e,f,t,n,s,a);if(!(t&PV)){var k=_&&Yw.call(r,"__wrapped__"),B=E&&Yw.call(e,"__wrapped__");if(k||B){var G=k?r.value():r,j=B?e.value():e;return a||(a=new di),s(G,j,t,n,a)}}return I?(a||(a=new di),Hw(r,e,t,n,s,a)):!1}var Xw=DV;function Zw(r,e,t,n,s){return r===e?!0:r==null||e==null||!Vt(r)&&!Vt(e)?r!==r&&e!==e:Xw(r,e,t,n,Zw,s)}var xo=Zw;var OV=1,kV=2;function NV(r,e,t,n){var s=t.length,a=s,c=!n;if(r==null)return!a;for(r=Object(r);s--;){var h=t[s];if(c&&h[2]?h[1]!==r[h[0]]:!(h[0]in r))return!1}for(;++s<a;){h=t[s];var f=h[0],m=r[f],_=h[1];if(c&&h[2]){if(m===void 0&&!(f in r))return!1}else{var E=new di;if(n)var I=n(m,_,f,r,e,E);if(!(I===void 0?xo(_,m,OV|kV,n,E):I))return!1}}return!0}var e0=NV;function VV(r){return r===r&&!De(r)}var jl=VV;function LV(r){for(var e=At(r),t=e.length;t--;){var n=e[t],s=r[n];e[t]=[n,s,jl(s)]}return e}var t0=LV;function MV(r,e){return function(t){return t==null?!1:t[r]===e&&(e!==void 0||r in Object(t))}}var $l=MV;function FV(r){var e=t0(r);return e.length==1&&e[0][2]?$l(e[0][0],e[0][1]):function(t){return t===r||e0(t,r,e)}}var r0=FV;function UV(r,e){return r!=null&&e in Object(r)}var n0=UV;function BV(r,e,t){e=wo(e,r);for(var n=-1,s=e.length,a=!1;++n<s;){var c=$r(e[n]);if(!(a=r!=null&&t(r,c)))break;r=r[c]}return a||++n!=s?a:(s=r==null?0:r.length,!!s&&ho(s)&&ii(c,s)&&(rt(r)||fo(r)))}var i0=BV;function jV(r,e){return r!=null&&i0(r,e,n0)}var s0=jV;var $V=1,qV=2;function zV(r,e){return go(r)&&jl(e)?$l($r(r),e):function(t){var n=ru(t,r);return n===void 0&&n===e?s0(t,r):xo(e,n,$V|qV)}}var o0=zV;function GV(r){return function(e){return e==null?void 0:e[r]}}var a0=GV;function KV(r){return function(e){return Rl(e,r)}}var u0=KV;function WV(r){return go(r)?a0($r(r)):u0(r)}var c0=WV;function HV(r){return typeof r=="function"?r:r==null?ao:typeof r=="object"?rt(r)?o0(r[0],r[1]):r0(r):c0(r)}var l0=HV;function QV(r){return function(e,t,n){for(var s=-1,a=Object(e),c=n(e),h=c.length;h--;){var f=c[r?h:++s];if(t(a[f],f,a)===!1)break}return e}}var h0=QV;var JV=h0(),f0=JV;function YV(r,e){return r&&f0(r,e,At)}var d0=YV;var XV=function(){return Je.Date.now()},ql=XV;var ZV="Expected a function",eL=Math.max,tL=Math.min;function rL(r,e,t){var n,s,a,c,h,f,m=0,_=!1,E=!1,I=!0;if(typeof r!="function")throw new TypeError(ZV);e=Od(e)||0,De(t)&&(_=!!t.leading,E="maxWait"in t,a=E?eL(Od(t.maxWait)||0,e):a,I="trailing"in t?!!t.trailing:I);function k(ie){var C=n,A=s;return n=s=void 0,m=ie,c=r.apply(A,C),c}function B(ie){return m=ie,h=setTimeout(J,e),_?k(ie):c}function G(ie){var C=ie-f,A=ie-m,R=e-C;return E?tL(R,a-A):R}function j(ie){var C=ie-f,A=ie-m;return f===void 0||C>=e||C<0||E&&A>=a}function J(){var ie=ql();if(j(ie))return ee(ie);h=setTimeout(J,G(ie))}function ee(ie){return h=void 0,I&&n?k(ie):(n=s=void 0,c)}function re(){h!==void 0&&clearTimeout(h),m=0,n=f=s=h=void 0}function le(){return h===void 0?c:ee(ql())}function de(){var ie=ql(),C=j(ie);if(n=arguments,s=this,f=ie,C){if(h===void 0)return B(f);if(E)return clearTimeout(h),h=setTimeout(J,e),k(f)}return h===void 0&&(h=setTimeout(J,e)),c}return de.cancel=re,de.flush=le,de}var p0=rL;var m0=Object.prototype,nL=m0.hasOwnProperty,iL=yv(function(r,e){r=Object(r);var t=-1,n=e.length,s=n>2?e[2]:void 0;for(s&&vv(e[0],e[1],s)&&(n=1);++t<n;)for(var a=e[t],c=ui(a),h=-1,f=c.length;++h<f;){var m=c[h],_=r[m];(_===void 0||jr(_,m0[m])&&!nL.call(r,m))&&(r[m]=a[m])}return r}),zl=iL;var sL="[object Map]",oL="[object Set]",aL=Object.prototype,uL=aL.hasOwnProperty;function cL(r){if(r==null)return!0;if(oi(r)&&(rt(r)||typeof r=="string"||typeof r.splice=="function"||wn(r)||mo(r)||fo(r)))return!r.length;var e=Ar(r);if(e==sL||e==oL)return!r.size;if(ai(r))return!Sl(r).length;for(var t in r)if(uL.call(r,t))return!1;return!0}var Fd=cL;function lL(r,e){return xo(r,e)}var Ud=lL;function hL(r,e){var t={};return e=l0(e,3),d0(r,function(n,s,a){co(t,e(n,s,a),n)}),t}var Bd=hL;function fL(r,e,t,n){if(!De(r))return r;e=wo(e,r);for(var s=-1,a=e.length,c=a-1,h=r;h!=null&&++s<a;){var f=$r(e[s]),m=t;if(f==="__proto__"||f==="constructor"||f==="prototype")return r;if(s!=c){var _=h[f];m=n?n(_,f,h):void 0,m===void 0&&(m=De(_)?_:ii(e[s+1])?[]:{})}lo(h,f,m),h=h[f]}return r}var g0=fL;function dL(r,e,t){return r==null?r:g0(r,e,t)}var pi=dL;var pL="Expected a function";function mL(r,e,t){var n=!0,s=!0;if(typeof r!="function")throw new TypeError(pL);return De(t)&&(n="leading"in t?!!t.leading:n,s="trailing"in t?!!t.trailing:s),p0(r,e,{leading:n,maxWait:e,trailing:s})}var jd=mL;var y0=function(r){let e=[],t=0;for(let n=0;n<r.length;n++){let s=r.charCodeAt(n);s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(s=65536+((s&1023)<<10)+(r.charCodeAt(++n)&1023),e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128)}return e},gL=function(r){let e=[],t=0,n=0;for(;t<r.length;){let s=r[t++];if(s<128)e[n++]=String.fromCharCode(s);else if(s>191&&s<224){let a=r[t++];e[n++]=String.fromCharCode((s&31)<<6|a&63)}else if(s>239&&s<365){let a=r[t++],c=r[t++],h=r[t++],f=((s&7)<<18|(a&63)<<12|(c&63)<<6|h&63)-65536;e[n++]=String.fromCharCode(55296+(f>>10)),e[n++]=String.fromCharCode(56320+(f&1023))}else{let a=r[t++],c=r[t++];e[n++]=String.fromCharCode((s&15)<<12|(a&63)<<6|c&63)}}return e.join("")},v0={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(r,e){if(!Array.isArray(r))throw Error("encodeByteArray takes an array as a parameter");this.init_();let t=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,n=[];for(let s=0;s<r.length;s+=3){let a=r[s],c=s+1<r.length,h=c?r[s+1]:0,f=s+2<r.length,m=f?r[s+2]:0,_=a>>2,E=(a&3)<<4|h>>4,I=(h&15)<<2|m>>6,k=m&63;f||(k=64,c||(I=64)),n.push(t[_],t[E],t[I],t[k])}return n.join("")},encodeString(r,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(r):this.encodeByteArray(y0(r),e)},decodeString(r,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(r):gL(this.decodeStringToByteArray(r,e))},decodeStringToByteArray(r,e){this.init_();let t=e?this.charToByteMapWebSafe_:this.charToByteMap_,n=[];for(let s=0;s<r.length;){let a=t[r.charAt(s++)],h=s<r.length?t[r.charAt(s)]:0;++s;let m=s<r.length?t[r.charAt(s)]:64;++s;let E=s<r.length?t[r.charAt(s)]:64;if(++s,a==null||h==null||m==null||E==null)throw new $d;let I=a<<2|h>>4;if(n.push(I),m!==64){let k=h<<4&240|m>>2;if(n.push(k),E!==64){let B=m<<6&192|E;n.push(B)}}}return n},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let r=0;r<this.ENCODED_VALS.length;r++)this.byteToCharMap_[r]=this.ENCODED_VALS.charAt(r),this.charToByteMap_[this.byteToCharMap_[r]]=r,this.byteToCharMapWebSafe_[r]=this.ENCODED_VALS_WEBSAFE.charAt(r),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[r]]=r,r>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(r)]=r,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(r)]=r)}}},$d=class extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}},_L=function(r){let e=y0(r);return v0.encodeByteArray(e,!0)},iu=function(r){return _L(r).replace(/\./g,"")},w0=function(r){try{return v0.decodeString(r,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function yL(){if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof global!="undefined")return global;throw new Error("Unable to locate global object.")}var vL=()=>yL().__FIREBASE_DEFAULTS__,wL=()=>{if(typeof process=="undefined"||typeof process.env=="undefined")return;let r=process.env.__FIREBASE_DEFAULTS__;if(r)return JSON.parse(r)},bL=()=>{if(typeof document=="undefined")return;let r;try{r=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}let e=r&&w0(r[1]);return e&&JSON.parse(e)},qd=()=>{try{return vL()||wL()||bL()}catch(r){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${r}`);return}},TL=r=>{var e,t;return(t=(e=qd())===null||e===void 0?void 0:e.emulatorHosts)===null||t===void 0?void 0:t[r]},b0=r=>{let e=TL(r);if(!e)return;let t=e.lastIndexOf(":");if(t<=0||t+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);let n=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),n]:[e.substring(0,t),n]},zd=()=>{var r;return(r=qd())===null||r===void 0?void 0:r.config};var Gl=class{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),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,n))}}};function T0(r,e){if(r.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');let t={alg:"none",type:"JWT"},n=e||"demo-project",s=r.iat||0,a=r.sub||r.user_id;if(!a)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");let c=Object.assign({iss:`https://securetoken.google.com/${n}`,aud:n,iat:s,exp:s+3600,auth_time:s,sub:a,user_id:a,firebase:{sign_in_provider:"custom",identities:{}}},r);return[iu(JSON.stringify(t)),iu(JSON.stringify(c)),""].join(".")}function E0(){return typeof navigator!="undefined"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function EL(){var r;let e=(r=qd())===null||r===void 0?void 0:r.forceEnvironment;if(e==="node")return!0;if(e==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function I0(){return!EL()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function Gd(){try{return typeof indexedDB=="object"}catch{return!1}}function x0(){return new Promise((r,e)=>{try{let t=!0,n="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(n);s.onsuccess=()=>{s.result.close(),t||self.indexedDB.deleteDatabase(n),r(!0)},s.onupgradeneeded=()=>{t=!1},s.onerror=()=>{var a;e(((a=s.error)===null||a===void 0?void 0:a.message)||"")}}catch(t){e(t)}})}var IL="FirebaseError",En=class r extends Error{constructor(e,t,n){super(t),this.code=e,this.customData=n,this.name=IL,Object.setPrototypeOf(this,r.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,su.prototype.create)}},su=class{constructor(e,t,n){this.service=e,this.serviceName=t,this.errors=n}create(e,...t){let n=t[0]||{},s=`${this.service}/${e}`,a=this.errors[e],c=a?xL(a,n):"Error",h=`${this.serviceName}: ${c} (${s}).`;return new En(s,h,n)}};function xL(r,e){return r.replace(AL,(t,n)=>{let s=e[n];return s!=null?String(s):`<${n}?>`})}var AL=/\{\$([^}]+)}/g;function ou(r,e){if(r===e)return!0;let t=Object.keys(r),n=Object.keys(e);for(let s of t){if(!n.includes(s))return!1;let a=r[s],c=e[s];if(_0(a)&&_0(c)){if(!ou(a,c))return!1}else if(a!==c)return!1}for(let s of n)if(!t.includes(s))return!1;return!0}function _0(r){return r!==null&&typeof r=="object"}var MG=4*60*60*1e3;function In(r){return r&&r._delegate?r._delegate:r}var xn=class{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}};var ss="[DEFAULT]";var Kd=class{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){let t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){let n=new Gl;if(this.instancesDeferred.set(t,n),this.isInitialized(t)||this.shouldAutoInitialize())try{let s=this.getOrInitializeService({instanceIdentifier:t});s&&n.resolve(s)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;let n=this.normalizeInstanceIdentifier(e==null?void 0:e.identifier),s=(t=e==null?void 0:e.optional)!==null&&t!==void 0?t:!1;if(this.isInitialized(n)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:n})}catch(a){if(s)return null;throw a}else{if(s)return null;throw Error(`Service ${this.name} is not available`)}}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(RL(e))try{this.getOrInitializeService({instanceIdentifier:ss})}catch{}for(let[t,n]of this.instancesDeferred.entries()){let s=this.normalizeInstanceIdentifier(t);try{let a=this.getOrInitializeService({instanceIdentifier:s});n.resolve(a)}catch{}}}}clearInstance(e=ss){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){let e=Array.from(this.instances.values());await Promise.all([...e.filter(t=>"INTERNAL"in t).map(t=>t.INTERNAL.delete()),...e.filter(t=>"_delete"in t).map(t=>t._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=ss){return this.instances.has(e)}getOptions(e=ss){return this.instancesOptions.get(e)||{}}initialize(e={}){let{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`);let s=this.getOrInitializeService({instanceIdentifier:n,options:t});for(let[a,c]of this.instancesDeferred.entries()){let h=this.normalizeInstanceIdentifier(a);n===h&&c.resolve(s)}return s}onInit(e,t){var n;let s=this.normalizeInstanceIdentifier(t),a=(n=this.onInitCallbacks.get(s))!==null&&n!==void 0?n:new Set;a.add(e),this.onInitCallbacks.set(s,a);let c=this.instances.get(s);return c&&e(c,s),()=>{a.delete(e)}}invokeOnInitCallbacks(e,t){let n=this.onInitCallbacks.get(t);if(n)for(let s of n)try{s(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:SL(e),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{}return n||null}normalizeInstanceIdentifier(e=ss){return this.component?this.component.multipleInstances?e:ss:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}};function SL(r){return r===ss?void 0:r}function RL(r){return r.instantiationMode==="EAGER"}var Kl=class{constructor(e){this.name=e,this.providers=new Map}addComponent(e){let 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);let t=new Kd(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}};var PL=[],Se;(function(r){r[r.DEBUG=0]="DEBUG",r[r.VERBOSE=1]="VERBOSE",r[r.INFO=2]="INFO",r[r.WARN=3]="WARN",r[r.ERROR=4]="ERROR",r[r.SILENT=5]="SILENT"})(Se||(Se={}));var CL={debug:Se.DEBUG,verbose:Se.VERBOSE,info:Se.INFO,warn:Se.WARN,error:Se.ERROR,silent:Se.SILENT},DL=Se.INFO,OL={[Se.DEBUG]:"log",[Se.VERBOSE]:"log",[Se.INFO]:"info",[Se.WARN]:"warn",[Se.ERROR]:"error"},kL=(r,e,...t)=>{if(e<r.logLevel)return;let n=new Date().toISOString(),s=OL[e];if(s)console[s](`[${n}] ${r.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)},Ao=class{constructor(e){this.name=e,this._logLevel=DL,this._logHandler=kL,this._userLogHandler=null,PL.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in Se))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?CL[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")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,Se.DEBUG,...e),this._logHandler(this,Se.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,Se.VERBOSE,...e),this._logHandler(this,Se.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,Se.INFO,...e),this._logHandler(this,Se.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,Se.WARN,...e),this._logHandler(this,Se.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,Se.ERROR,...e),this._logHandler(this,Se.ERROR,...e)}};var NL=(r,e)=>e.some(t=>r instanceof t),A0,S0;function VL(){return A0||(A0=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function LL(){return S0||(S0=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var R0=new WeakMap,Hd=new WeakMap,P0=new WeakMap,Wd=new WeakMap,Jd=new WeakMap;function ML(r){let e=new Promise((t,n)=>{let s=()=>{r.removeEventListener("success",a),r.removeEventListener("error",c)},a=()=>{t(zr(r.result)),s()},c=()=>{n(r.error),s()};r.addEventListener("success",a),r.addEventListener("error",c)});return e.then(t=>{t instanceof IDBCursor&&R0.set(t,r)}).catch(()=>{}),Jd.set(e,r),e}function FL(r){if(Hd.has(r))return;let e=new Promise((t,n)=>{let s=()=>{r.removeEventListener("complete",a),r.removeEventListener("error",c),r.removeEventListener("abort",c)},a=()=>{t(),s()},c=()=>{n(r.error||new DOMException("AbortError","AbortError")),s()};r.addEventListener("complete",a),r.addEventListener("error",c),r.addEventListener("abort",c)});Hd.set(r,e)}var Qd={get(r,e,t){if(r instanceof IDBTransaction){if(e==="done")return Hd.get(r);if(e==="objectStoreNames")return r.objectStoreNames||P0.get(r);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return zr(r[e])},set(r,e,t){return r[e]=t,!0},has(r,e){return r instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in r}};function C0(r){Qd=r(Qd)}function UL(r){return r===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){let n=r.call(Wl(this),e,...t);return P0.set(n,e.sort?e.sort():[e]),zr(n)}:LL().includes(r)?function(...e){return r.apply(Wl(this),e),zr(R0.get(this))}:function(...e){return zr(r.apply(Wl(this),e))}}function BL(r){return typeof r=="function"?UL(r):(r instanceof IDBTransaction&&FL(r),NL(r,VL())?new Proxy(r,Qd):r)}function zr(r){if(r instanceof IDBRequest)return ML(r);if(Wd.has(r))return Wd.get(r);let e=BL(r);return e!==r&&(Wd.set(r,e),Jd.set(e,r)),e}var Wl=r=>Jd.get(r);function O0(r,e,{blocked:t,upgrade:n,blocking:s,terminated:a}={}){let c=indexedDB.open(r,e),h=zr(c);return n&&c.addEventListener("upgradeneeded",f=>{n(zr(c.result),f.oldVersion,f.newVersion,zr(c.transaction),f)}),t&&c.addEventListener("blocked",f=>t(f.oldVersion,f.newVersion,f)),h.then(f=>{a&&f.addEventListener("close",()=>a()),s&&f.addEventListener("versionchange",m=>s(m.oldVersion,m.newVersion,m))}).catch(()=>{}),h}var jL=["get","getKey","getAll","getAllKeys","count"],$L=["put","add","delete","clear"],Yd=new Map;function D0(r,e){if(!(r instanceof IDBDatabase&&!(e in r)&&typeof e=="string"))return;if(Yd.get(e))return Yd.get(e);let t=e.replace(/FromIndex$/,""),n=e!==t,s=$L.includes(t);if(!(t in(n?IDBIndex:IDBObjectStore).prototype)||!(s||jL.includes(t)))return;let a=async function(c,...h){let f=this.transaction(c,s?"readwrite":"readonly"),m=f.store;return n&&(m=m.index(h.shift())),(await Promise.all([m[t](...h),s&&f.done]))[0]};return Yd.set(e,a),a}C0(r=>({...r,get:(e,t,n)=>D0(e,t)||r.get(e,t,n),has:(e,t)=>!!D0(e,t)||r.has(e,t)}));var Zd=class{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(qL(t)){let n=t.getImmediate();return`${n.library}/${n.version}`}else return null}).filter(t=>t).join(" ")}};function qL(r){let e=r.getComponent();return(e==null?void 0:e.type)==="VERSION"}var ep="@firebase/app",k0="0.11.1";var An=new Ao("@firebase/app"),zL="@firebase/app-compat",GL="@firebase/analytics-compat",KL="@firebase/analytics",WL="@firebase/app-check-compat",HL="@firebase/app-check",QL="@firebase/auth",JL="@firebase/auth-compat",YL="@firebase/database",XL="@firebase/data-connect",ZL="@firebase/database-compat",e2="@firebase/functions",t2="@firebase/functions-compat",r2="@firebase/installations",n2="@firebase/installations-compat",i2="@firebase/messaging",s2="@firebase/messaging-compat",o2="@firebase/performance",a2="@firebase/performance-compat",u2="@firebase/remote-config",c2="@firebase/remote-config-compat",l2="@firebase/storage",h2="@firebase/storage-compat",f2="@firebase/firestore",d2="@firebase/vertexai",p2="@firebase/firestore-compat",m2="firebase",g2="11.3.1";var tp="[DEFAULT]",_2={[ep]:"fire-core",[zL]:"fire-core-compat",[KL]:"fire-analytics",[GL]:"fire-analytics-compat",[HL]:"fire-app-check",[WL]:"fire-app-check-compat",[QL]:"fire-auth",[JL]:"fire-auth-compat",[YL]:"fire-rtdb",[XL]:"fire-data-connect",[ZL]:"fire-rtdb-compat",[e2]:"fire-fn",[t2]:"fire-fn-compat",[r2]:"fire-iid",[n2]:"fire-iid-compat",[i2]:"fire-fcm",[s2]:"fire-fcm-compat",[o2]:"fire-perf",[a2]:"fire-perf-compat",[u2]:"fire-rc",[c2]:"fire-rc-compat",[l2]:"fire-gcs",[h2]:"fire-gcs-compat",[f2]:"fire-fst",[p2]:"fire-fst-compat",[d2]:"fire-vertex","fire-js":"fire-js",[m2]:"fire-js-all"};var Hl=new Map,y2=new Map,rp=new Map;function N0(r,e){try{r.container.addComponent(e)}catch(t){An.debug(`Component ${e.name} failed to register with FirebaseApp ${r.name}`,t)}}function au(r){let e=r.name;if(rp.has(e))return An.debug(`There were multiple attempts to register component ${e}.`),!1;rp.set(e,r);for(let t of Hl.values())N0(t,r);for(let t of y2.values())N0(t,r);return!0}function F0(r,e){let t=r.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),r.container.getProvider(e)}function U0(r){return r==null?!1:r.settings!==void 0}var v2={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},mi=new su("app","Firebase",v2);var np=class{constructor(e,t,n){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new xn("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 mi.create("app-deleted",{appName:this._name})}};var B0=g2;function op(r,e={}){let t=r;typeof e!="object"&&(e={name:e});let n=Object.assign({name:tp,automaticDataCollectionEnabled:!1},e),s=n.name;if(typeof s!="string"||!s)throw mi.create("bad-app-name",{appName:String(s)});if(t||(t=zd()),!t)throw mi.create("no-options");let a=Hl.get(s);if(a){if(ou(t,a.options)&&ou(n,a.config))return a;throw mi.create("duplicate-app",{appName:s})}let c=new Kl(s);for(let f of rp.values())c.addComponent(f);let h=new np(t,n,c);return Hl.set(s,h),h}function j0(r=tp){let e=Hl.get(r);if(!e&&r===tp&&zd())return op();if(!e)throw mi.create("no-app",{appName:r});return e}function gi(r,e,t){var n;let s=(n=_2[r])!==null&&n!==void 0?n:r;t&&(s+=`-${t}`);let a=s.match(/\s|\//),c=e.match(/\s|\//);if(a||c){let h=[`Unable to register library "${s}" with version "${e}":`];a&&h.push(`library name "${s}" contains illegal characters (whitespace or "/")`),a&&c&&h.push("and"),c&&h.push(`version name "${e}" contains illegal characters (whitespace or "/")`),An.warn(h.join(" "));return}au(new xn(`${s}-version`,()=>({library:s,version:e}),"VERSION"))}var w2="firebase-heartbeat-database",b2=1,uu="firebase-heartbeat-store",Xd=null;function $0(){return Xd||(Xd=O0(w2,b2,{upgrade:(r,e)=>{switch(e){case 0:try{r.createObjectStore(uu)}catch(t){console.warn(t)}}}}).catch(r=>{throw mi.create("idb-open",{originalErrorMessage:r.message})})),Xd}async function T2(r){try{let t=(await $0()).transaction(uu),n=await t.objectStore(uu).get(q0(r));return await t.done,n}catch(e){if(e instanceof En)An.warn(e.message);else{let t=mi.create("idb-get",{originalErrorMessage:e==null?void 0:e.message});An.warn(t.message)}}}async function V0(r,e){try{let n=(await $0()).transaction(uu,"readwrite");await n.objectStore(uu).put(e,q0(r)),await n.done}catch(t){if(t instanceof En)An.warn(t.message);else{let n=mi.create("idb-set",{originalErrorMessage:t==null?void 0:t.message});An.warn(n.message)}}}function q0(r){return`${r.name}!${r.options.appId}`}var E2=1024,I2=30,ip=class{constructor(e){this.container=e,this._heartbeatsCache=null;let t=this.container.getProvider("app").getImmediate();this._storage=new sp(t),this._heartbeatsCachePromise=this._storage.read().then(n=>(this._heartbeatsCache=n,n))}async triggerHeartbeat(){var e,t;try{let s=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),a=L0();if(((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((t=this._heartbeatsCache)===null||t===void 0?void 0:t.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===a||this._heartbeatsCache.heartbeats.some(c=>c.date===a))return;if(this._heartbeatsCache.heartbeats.push({date:a,agent:s}),this._heartbeatsCache.heartbeats.length>I2){let c=A2(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(c,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(n){An.warn(n)}}async getHeartbeatsHeader(){var e;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";let t=L0(),{heartbeatsToSend:n,unsentEntries:s}=x2(this._heartbeatsCache.heartbeats),a=iu(JSON.stringify({version:2,heartbeats:n}));return this._heartbeatsCache.lastSentHeartbeatDate=t,s.length>0?(this._heartbeatsCache.heartbeats=s,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),a}catch(t){return An.warn(t),""}}};function L0(){return new Date().toISOString().substring(0,10)}function x2(r,e=E2){let t=[],n=r.slice();for(let s of r){let a=t.find(c=>c.agent===s.agent);if(a){if(a.dates.push(s.date),M0(t)>e){a.dates.pop();break}}else if(t.push({agent:s.agent,dates:[s.date]}),M0(t)>e){t.pop();break}n=n.slice(1)}return{heartbeatsToSend:t,unsentEntries:n}}var sp=class{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return Gd()?x0().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){let t=await T2(this.app);return t!=null&&t.heartbeats?t:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){let s=await this.read();return V0(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:s.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){var t;if(await this._canUseIndexedDBPromise){let s=await this.read();return V0(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:s.lastSentHeartbeatDate,heartbeats:[...s.heartbeats,...e.heartbeats]})}else return}};function M0(r){return iu(JSON.stringify({version:2,heartbeats:r})).length}function A2(r){if(r.length===0)return-1;let e=0,t=r[0].date;for(let n=1;n<r.length;n++)r[n].date<t&&(t=r[n].date,e=n);return e}function S2(r){au(new xn("platform-logger",e=>new Zd(e),"PRIVATE")),au(new xn("heartbeat",e=>new ip(e),"PRIVATE")),gi(ep,k0,r),gi(ep,k0,"esm2017"),gi("fire-js","")}S2("");var R2="firebase",P2="11.3.1";gi(R2,P2,"app");var z0=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},G0={};var Sn,ap;(function(){var r;function e(C,A){function R(){}R.prototype=A.prototype,C.D=A.prototype,C.prototype=new R,C.prototype.constructor=C,C.C=function(D,V,M){for(var S=Array(arguments.length-2),dr=2;dr<arguments.length;dr++)S[dr-2]=arguments[dr];return A.prototype[V].apply(D,S)}}function t(){this.blockSize=-1}function n(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.B=Array(this.blockSize),this.o=this.h=0,this.s()}e(n,t),n.prototype.s=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function s(C,A,R){R||(R=0);var D=Array(16);if(typeof A=="string")for(var V=0;16>V;++V)D[V]=A.charCodeAt(R++)|A.charCodeAt(R++)<<8|A.charCodeAt(R++)<<16|A.charCodeAt(R++)<<24;else for(V=0;16>V;++V)D[V]=A[R++]|A[R++]<<8|A[R++]<<16|A[R++]<<24;A=C.g[0],R=C.g[1],V=C.g[2];var M=C.g[3],S=A+(M^R&(V^M))+D[0]+3614090360&4294967295;A=R+(S<<7&4294967295|S>>>25),S=M+(V^A&(R^V))+D[1]+3905402710&4294967295,M=A+(S<<12&4294967295|S>>>20),S=V+(R^M&(A^R))+D[2]+606105819&4294967295,V=M+(S<<17&4294967295|S>>>15),S=R+(A^V&(M^A))+D[3]+3250441966&4294967295,R=V+(S<<22&4294967295|S>>>10),S=A+(M^R&(V^M))+D[4]+4118548399&4294967295,A=R+(S<<7&4294967295|S>>>25),S=M+(V^A&(R^V))+D[5]+1200080426&4294967295,M=A+(S<<12&4294967295|S>>>20),S=V+(R^M&(A^R))+D[6]+2821735955&4294967295,V=M+(S<<17&4294967295|S>>>15),S=R+(A^V&(M^A))+D[7]+4249261313&4294967295,R=V+(S<<22&4294967295|S>>>10),S=A+(M^R&(V^M))+D[8]+1770035416&4294967295,A=R+(S<<7&4294967295|S>>>25),S=M+(V^A&(R^V))+D[9]+2336552879&4294967295,M=A+(S<<12&4294967295|S>>>20),S=V+(R^M&(A^R))+D[10]+4294925233&4294967295,V=M+(S<<17&4294967295|S>>>15),S=R+(A^V&(M^A))+D[11]+2304563134&4294967295,R=V+(S<<22&4294967295|S>>>10),S=A+(M^R&(V^M))+D[12]+1804603682&4294967295,A=R+(S<<7&4294967295|S>>>25),S=M+(V^A&(R^V))+D[13]+4254626195&4294967295,M=A+(S<<12&4294967295|S>>>20),S=V+(R^M&(A^R))+D[14]+2792965006&4294967295,V=M+(S<<17&4294967295|S>>>15),S=R+(A^V&(M^A))+D[15]+1236535329&4294967295,R=V+(S<<22&4294967295|S>>>10),S=A+(V^M&(R^V))+D[1]+4129170786&4294967295,A=R+(S<<5&4294967295|S>>>27),S=M+(R^V&(A^R))+D[6]+3225465664&4294967295,M=A+(S<<9&4294967295|S>>>23),S=V+(A^R&(M^A))+D[11]+643717713&4294967295,V=M+(S<<14&4294967295|S>>>18),S=R+(M^A&(V^M))+D[0]+3921069994&4294967295,R=V+(S<<20&4294967295|S>>>12),S=A+(V^M&(R^V))+D[5]+3593408605&4294967295,A=R+(S<<5&4294967295|S>>>27),S=M+(R^V&(A^R))+D[10]+38016083&4294967295,M=A+(S<<9&4294967295|S>>>23),S=V+(A^R&(M^A))+D[15]+3634488961&4294967295,V=M+(S<<14&4294967295|S>>>18),S=R+(M^A&(V^M))+D[4]+3889429448&4294967295,R=V+(S<<20&4294967295|S>>>12),S=A+(V^M&(R^V))+D[9]+568446438&4294967295,A=R+(S<<5&4294967295|S>>>27),S=M+(R^V&(A^R))+D[14]+3275163606&4294967295,M=A+(S<<9&4294967295|S>>>23),S=V+(A^R&(M^A))+D[3]+4107603335&4294967295,V=M+(S<<14&4294967295|S>>>18),S=R+(M^A&(V^M))+D[8]+1163531501&4294967295,R=V+(S<<20&4294967295|S>>>12),S=A+(V^M&(R^V))+D[13]+2850285829&4294967295,A=R+(S<<5&4294967295|S>>>27),S=M+(R^V&(A^R))+D[2]+4243563512&4294967295,M=A+(S<<9&4294967295|S>>>23),S=V+(A^R&(M^A))+D[7]+1735328473&4294967295,V=M+(S<<14&4294967295|S>>>18),S=R+(M^A&(V^M))+D[12]+2368359562&4294967295,R=V+(S<<20&4294967295|S>>>12),S=A+(R^V^M)+D[5]+4294588738&4294967295,A=R+(S<<4&4294967295|S>>>28),S=M+(A^R^V)+D[8]+2272392833&4294967295,M=A+(S<<11&4294967295|S>>>21),S=V+(M^A^R)+D[11]+1839030562&4294967295,V=M+(S<<16&4294967295|S>>>16),S=R+(V^M^A)+D[14]+4259657740&4294967295,R=V+(S<<23&4294967295|S>>>9),S=A+(R^V^M)+D[1]+2763975236&4294967295,A=R+(S<<4&4294967295|S>>>28),S=M+(A^R^V)+D[4]+1272893353&4294967295,M=A+(S<<11&4294967295|S>>>21),S=V+(M^A^R)+D[7]+4139469664&4294967295,V=M+(S<<16&4294967295|S>>>16),S=R+(V^M^A)+D[10]+3200236656&4294967295,R=V+(S<<23&4294967295|S>>>9),S=A+(R^V^M)+D[13]+681279174&4294967295,A=R+(S<<4&4294967295|S>>>28),S=M+(A^R^V)+D[0]+3936430074&4294967295,M=A+(S<<11&4294967295|S>>>21),S=V+(M^A^R)+D[3]+3572445317&4294967295,V=M+(S<<16&4294967295|S>>>16),S=R+(V^M^A)+D[6]+76029189&4294967295,R=V+(S<<23&4294967295|S>>>9),S=A+(R^V^M)+D[9]+3654602809&4294967295,A=R+(S<<4&4294967295|S>>>28),S=M+(A^R^V)+D[12]+3873151461&4294967295,M=A+(S<<11&4294967295|S>>>21),S=V+(M^A^R)+D[15]+530742520&4294967295,V=M+(S<<16&4294967295|S>>>16),S=R+(V^M^A)+D[2]+3299628645&4294967295,R=V+(S<<23&4294967295|S>>>9),S=A+(V^(R|~M))+D[0]+4096336452&4294967295,A=R+(S<<6&4294967295|S>>>26),S=M+(R^(A|~V))+D[7]+1126891415&4294967295,M=A+(S<<10&4294967295|S>>>22),S=V+(A^(M|~R))+D[14]+2878612391&4294967295,V=M+(S<<15&4294967295|S>>>17),S=R+(M^(V|~A))+D[5]+4237533241&4294967295,R=V+(S<<21&4294967295|S>>>11),S=A+(V^(R|~M))+D[12]+1700485571&4294967295,A=R+(S<<6&4294967295|S>>>26),S=M+(R^(A|~V))+D[3]+2399980690&4294967295,M=A+(S<<10&4294967295|S>>>22),S=V+(A^(M|~R))+D[10]+4293915773&4294967295,V=M+(S<<15&4294967295|S>>>17),S=R+(M^(V|~A))+D[1]+2240044497&4294967295,R=V+(S<<21&4294967295|S>>>11),S=A+(V^(R|~M))+D[8]+1873313359&4294967295,A=R+(S<<6&4294967295|S>>>26),S=M+(R^(A|~V))+D[15]+4264355552&4294967295,M=A+(S<<10&4294967295|S>>>22),S=V+(A^(M|~R))+D[6]+2734768916&4294967295,V=M+(S<<15&4294967295|S>>>17),S=R+(M^(V|~A))+D[13]+1309151649&4294967295,R=V+(S<<21&4294967295|S>>>11),S=A+(V^(R|~M))+D[4]+4149444226&4294967295,A=R+(S<<6&4294967295|S>>>26),S=M+(R^(A|~V))+D[11]+3174756917&4294967295,M=A+(S<<10&4294967295|S>>>22),S=V+(A^(M|~R))+D[2]+718787259&4294967295,V=M+(S<<15&4294967295|S>>>17),S=R+(M^(V|~A))+D[9]+3951481745&4294967295,C.g[0]=C.g[0]+A&4294967295,C.g[1]=C.g[1]+(V+(S<<21&4294967295|S>>>11))&4294967295,C.g[2]=C.g[2]+V&4294967295,C.g[3]=C.g[3]+M&4294967295}n.prototype.u=function(C,A){A===void 0&&(A=C.length);for(var R=A-this.blockSize,D=this.B,V=this.h,M=0;M<A;){if(V==0)for(;M<=R;)s(this,C,M),M+=this.blockSize;if(typeof C=="string"){for(;M<A;)if(D[V++]=C.charCodeAt(M++),V==this.blockSize){s(this,D),V=0;break}}else for(;M<A;)if(D[V++]=C[M++],V==this.blockSize){s(this,D),V=0;break}}this.h=V,this.o+=A},n.prototype.v=function(){var C=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);C[0]=128;for(var A=1;A<C.length-8;++A)C[A]=0;var R=8*this.o;for(A=C.length-8;A<C.length;++A)C[A]=R&255,R/=256;for(this.u(C),C=Array(16),A=R=0;4>A;++A)for(var D=0;32>D;D+=8)C[R++]=this.g[A]>>>D&255;return C};function a(C,A){var R=h;return Object.prototype.hasOwnProperty.call(R,C)?R[C]:R[C]=A(C)}function c(C,A){this.h=A;for(var R=[],D=!0,V=C.length-1;0<=V;V--){var M=C[V]|0;D&&M==A||(R[V]=M,D=!1)}this.g=R}var h={};function f(C){return-128<=C&&128>C?a(C,function(A){return new c([A|0],0>A?-1:0)}):new c([C|0],0>C?-1:0)}function m(C){if(isNaN(C)||!isFinite(C))return E;if(0>C)return j(m(-C));for(var A=[],R=1,D=0;C>=R;D++)A[D]=C/R|0,R*=4294967296;return new c(A,0)}function _(C,A){if(C.length==0)throw Error("number format error: empty string");if(A=A||10,2>A||36<A)throw Error("radix out of range: "+A);if(C.charAt(0)=="-")return j(_(C.substring(1),A));if(0<=C.indexOf("-"))throw Error('number format error: interior "-" character');for(var R=m(Math.pow(A,8)),D=E,V=0;V<C.length;V+=8){var M=Math.min(8,C.length-V),S=parseInt(C.substring(V,V+M),A);8>M?(M=m(Math.pow(A,M)),D=D.j(M).add(m(S))):(D=D.j(R),D=D.add(m(S)))}return D}var E=f(0),I=f(1),k=f(16777216);r=c.prototype,r.m=function(){if(G(this))return-j(this).m();for(var C=0,A=1,R=0;R<this.g.length;R++){var D=this.i(R);C+=(0<=D?D:4294967296+D)*A,A*=4294967296}return C},r.toString=function(C){if(C=C||10,2>C||36<C)throw Error("radix out of range: "+C);if(B(this))return"0";if(G(this))return"-"+j(this).toString(C);for(var A=m(Math.pow(C,6)),R=this,D="";;){var V=le(R,A).g;R=J(R,V.j(A));var M=((0<R.g.length?R.g[0]:R.h)>>>0).toString(C);if(R=V,B(R))return M+D;for(;6>M.length;)M="0"+M;D=M+D}},r.i=function(C){return 0>C?0:C<this.g.length?this.g[C]:this.h};function B(C){if(C.h!=0)return!1;for(var A=0;A<C.g.length;A++)if(C.g[A]!=0)return!1;return!0}function G(C){return C.h==-1}r.l=function(C){return C=J(this,C),G(C)?-1:B(C)?0:1};function j(C){for(var A=C.g.length,R=[],D=0;D<A;D++)R[D]=~C.g[D];return new c(R,~C.h).add(I)}r.abs=function(){return G(this)?j(this):this},r.add=function(C){for(var A=Math.max(this.g.length,C.g.length),R=[],D=0,V=0;V<=A;V++){var M=D+(this.i(V)&65535)+(C.i(V)&65535),S=(M>>>16)+(this.i(V)>>>16)+(C.i(V)>>>16);D=S>>>16,M&=65535,S&=65535,R[V]=S<<16|M}return new c(R,R[R.length-1]&-2147483648?-1:0)};function J(C,A){return C.add(j(A))}r.j=function(C){if(B(this)||B(C))return E;if(G(this))return G(C)?j(this).j(j(C)):j(j(this).j(C));if(G(C))return j(this.j(j(C)));if(0>this.l(k)&&0>C.l(k))return m(this.m()*C.m());for(var A=this.g.length+C.g.length,R=[],D=0;D<2*A;D++)R[D]=0;for(D=0;D<this.g.length;D++)for(var V=0;V<C.g.length;V++){var M=this.i(D)>>>16,S=this.i(D)&65535,dr=C.i(V)>>>16,Wt=C.i(V)&65535;R[2*D+2*V]+=S*Wt,ee(R,2*D+2*V),R[2*D+2*V+1]+=M*Wt,ee(R,2*D+2*V+1),R[2*D+2*V+1]+=S*dr,ee(R,2*D+2*V+1),R[2*D+2*V+2]+=M*dr,ee(R,2*D+2*V+2)}for(D=0;D<A;D++)R[D]=R[2*D+1]<<16|R[2*D];for(D=A;D<2*A;D++)R[D]=0;return new c(R,0)};function ee(C,A){for(;(C[A]&65535)!=C[A];)C[A+1]+=C[A]>>>16,C[A]&=65535,A++}function re(C,A){this.g=C,this.h=A}function le(C,A){if(B(A))throw Error("division by zero");if(B(C))return new re(E,E);if(G(C))return A=le(j(C),A),new re(j(A.g),j(A.h));if(G(A))return A=le(C,j(A)),new re(j(A.g),A.h);if(30<C.g.length){if(G(C)||G(A))throw Error("slowDivide_ only works with positive integers.");for(var R=I,D=A;0>=D.l(C);)R=de(R),D=de(D);var V=ie(R,1),M=ie(D,1);for(D=ie(D,2),R=ie(R,2);!B(D);){var S=M.add(D);0>=S.l(C)&&(V=V.add(R),M=S),D=ie(D,1),R=ie(R,1)}return A=J(C,V.j(A)),new re(V,A)}for(V=E;0<=C.l(A);){for(R=Math.max(1,Math.floor(C.m()/A.m())),D=Math.ceil(Math.log(R)/Math.LN2),D=48>=D?1:Math.pow(2,D-48),M=m(R),S=M.j(A);G(S)||0<S.l(C);)R-=D,M=m(R),S=M.j(A);B(M)&&(M=I),V=V.add(M),C=J(C,S)}return new re(V,C)}r.A=function(C){return le(this,C).h},r.and=function(C){for(var A=Math.max(this.g.length,C.g.length),R=[],D=0;D<A;D++)R[D]=this.i(D)&C.i(D);return new c(R,this.h&C.h)},r.or=function(C){for(var A=Math.max(this.g.length,C.g.length),R=[],D=0;D<A;D++)R[D]=this.i(D)|C.i(D);return new c(R,this.h|C.h)},r.xor=function(C){for(var A=Math.max(this.g.length,C.g.length),R=[],D=0;D<A;D++)R[D]=this.i(D)^C.i(D);return new c(R,this.h^C.h)};function de(C){for(var A=C.g.length+1,R=[],D=0;D<A;D++)R[D]=C.i(D)<<1|C.i(D-1)>>>31;return new c(R,C.h)}function ie(C,A){var R=A>>5;A%=32;for(var D=C.g.length-R,V=[],M=0;M<D;M++)V[M]=0<A?C.i(M+R)>>>A|C.i(M+R+1)<<32-A:C.i(M+R);return new c(V,C.h)}n.prototype.digest=n.prototype.v,n.prototype.reset=n.prototype.s,n.prototype.update=n.prototype.u,ap=G0.Md5=n,c.prototype.add=c.prototype.add,c.prototype.multiply=c.prototype.j,c.prototype.modulo=c.prototype.A,c.prototype.compare=c.prototype.l,c.prototype.toNumber=c.prototype.m,c.prototype.toString=c.prototype.toString,c.prototype.getBits=c.prototype.i,c.fromNumber=m,c.fromString=_,Sn=G0.Integer=c}).apply(typeof z0!="undefined"?z0:typeof self!="undefined"?self:typeof window!="undefined"?window:{});var Ql=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},Rn={};var up,C2,So,cp,cu,Jl,lp,hp,fp;(function(){var r,e=typeof Object.defineProperties=="function"?Object.defineProperty:function(u,d,g){return u==Array.prototype||u==Object.prototype||(u[d]=g.value),u};function t(u){u=[typeof globalThis=="object"&&globalThis,u,typeof window=="object"&&window,typeof self=="object"&&self,typeof Ql=="object"&&Ql];for(var d=0;d<u.length;++d){var g=u[d];if(g&&g.Math==Math)return g}throw Error("Cannot find global object")}var n=t(this);function s(u,d){if(d)e:{var g=n;u=u.split(".");for(var b=0;b<u.length-1;b++){var L=u[b];if(!(L in g))break e;g=g[L]}u=u[u.length-1],b=g[u],d=d(b),d!=b&&d!=null&&e(g,u,{configurable:!0,writable:!0,value:d})}}function a(u,d){u instanceof String&&(u+="");var g=0,b=!1,L={next:function(){if(!b&&g<u.length){var F=g++;return{value:d(F,u[F]),done:!1}}return b=!0,{done:!0,value:void 0}}};return L[Symbol.iterator]=function(){return L},L}s("Array.prototype.values",function(u){return u||function(){return a(this,function(d,g){return g})}});var c=c||{},h=this||self;function f(u){var d=typeof u;return d=d!="object"?d:u?Array.isArray(u)?"array":d:"null",d=="array"||d=="object"&&typeof u.length=="number"}function m(u){var d=typeof u;return d=="object"&&u!=null||d=="function"}function _(u,d,g){return u.call.apply(u.bind,arguments)}function E(u,d,g){if(!u)throw Error();if(2<arguments.length){var b=Array.prototype.slice.call(arguments,2);return function(){var L=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(L,b),u.apply(d,L)}}return function(){return u.apply(d,arguments)}}function I(u,d,g){return I=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?_:E,I.apply(null,arguments)}function k(u,d){var g=Array.prototype.slice.call(arguments,1);return function(){var b=g.slice();return b.push.apply(b,arguments),u.apply(this,b)}}function B(u,d){function g(){}g.prototype=d.prototype,u.aa=d.prototype,u.prototype=new g,u.prototype.constructor=u,u.Qb=function(b,L,F){for(var Q=Array(arguments.length-2),_e=2;_e<arguments.length;_e++)Q[_e-2]=arguments[_e];return d.prototype[L].apply(b,Q)}}function G(u){let d=u.length;if(0<d){let g=Array(d);for(let b=0;b<d;b++)g[b]=u[b];return g}return[]}function j(u,d){for(let g=1;g<arguments.length;g++){let b=arguments[g];if(f(b)){let L=u.length||0,F=b.length||0;u.length=L+F;for(let Q=0;Q<F;Q++)u[L+Q]=b[Q]}else u.push(b)}}class J{constructor(d,g){this.i=d,this.j=g,this.h=0,this.g=null}get(){let d;return 0<this.h?(this.h--,d=this.g,this.g=d.next,d.next=null):d=this.i(),d}}function ee(u){return/^[\s\xa0]*$/.test(u)}function re(){var u=h.navigator;return u&&(u=u.userAgent)?u:""}function le(u){return le[" "](u),u}le[" "]=function(){};var de=re().indexOf("Gecko")!=-1&&!(re().toLowerCase().indexOf("webkit")!=-1&&re().indexOf("Edge")==-1)&&!(re().indexOf("Trident")!=-1||re().indexOf("MSIE")!=-1)&&re().indexOf("Edge")==-1;function ie(u,d,g){for(let b in u)d.call(g,u[b],b,u)}function C(u,d){for(let g in u)d.call(void 0,u[g],g,u)}function A(u){let d={};for(let g in u)d[g]=u[g];return d}let R="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function D(u,d){let g,b;for(let L=1;L<arguments.length;L++){b=arguments[L];for(g in b)u[g]=b[g];for(let F=0;F<R.length;F++)g=R[F],Object.prototype.hasOwnProperty.call(b,g)&&(u[g]=b[g])}}function V(u){var d=1;u=u.split(":");let g=[];for(;0<d&&u.length;)g.push(u.shift()),d--;return u.length&&g.push(u.join(":")),g}function M(u){h.setTimeout(()=>{throw u},0)}function S(){var u=Lt;let d=null;return u.g&&(d=u.g,u.g=u.g.next,u.g||(u.h=null),d.next=null),d}class dr{constructor(){this.h=this.g=null}add(d,g){let b=Wt.get();b.set(d,g),this.h?this.h.next=b:this.g=b,this.h=b}}var Wt=new J(()=>new Pr,u=>u.reset());class Pr{constructor(){this.next=this.g=this.h=null}set(d,g){this.h=d,this.g=g,this.next=null}reset(){this.next=this.g=this.h=null}}let Ai,Cr=!1,Lt=new dr,ac=()=>{let u=h.Promise.resolve(void 0);Ai=()=>{u.then(vf)}};var vf=()=>{for(var u;u=S();){try{u.h.call(u.g)}catch(g){M(g)}var d=Wt;d.j(u),100>d.h&&(d.h++,u.next=d.g,d.g=u)}Cr=!1};function Dr(){this.s=this.s,this.C=this.C}Dr.prototype.s=!1,Dr.prototype.ma=function(){this.s||(this.s=!0,this.N())},Dr.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function Ke(u,d){this.type=u,this.g=this.target=d,this.defaultPrevented=!1}Ke.prototype.h=function(){this.defaultPrevented=!0};var Cs=function(){if(!h.addEventListener||!Object.defineProperty)return!1;var u=!1,d=Object.defineProperty({},"passive",{get:function(){u=!0}});try{let g=()=>{};h.addEventListener("test",g,d),h.removeEventListener("test",g,d)}catch{}return u}();function Si(u,d){if(Ke.call(this,u?u.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,u){var g=this.type=u.type,b=u.changedTouches&&u.changedTouches.length?u.changedTouches[0]:null;if(this.target=u.target||u.srcElement,this.g=d,d=u.relatedTarget){if(de){e:{try{le(d.nodeName);var L=!0;break e}catch{}L=!1}L||(d=null)}}else g=="mouseover"?d=u.fromElement:g=="mouseout"&&(d=u.toElement);this.relatedTarget=d,b?(this.clientX=b.clientX!==void 0?b.clientX:b.pageX,this.clientY=b.clientY!==void 0?b.clientY:b.pageY,this.screenX=b.screenX||0,this.screenY=b.screenY||0):(this.clientX=u.clientX!==void 0?u.clientX:u.pageX,this.clientY=u.clientY!==void 0?u.clientY:u.pageY,this.screenX=u.screenX||0,this.screenY=u.screenY||0),this.button=u.button,this.key=u.key||"",this.ctrlKey=u.ctrlKey,this.altKey=u.altKey,this.shiftKey=u.shiftKey,this.metaKey=u.metaKey,this.pointerId=u.pointerId||0,this.pointerType=typeof u.pointerType=="string"?u.pointerType:Ri[u.pointerType]||"",this.state=u.state,this.i=u,u.defaultPrevented&&Si.aa.h.call(this)}}B(Si,Ke);var Ri={2:"touch",3:"pen",4:"mouse"};Si.prototype.h=function(){Si.aa.h.call(this);var u=this.i;u.preventDefault?u.preventDefault():u.returnValue=!1};var pr="closure_listenable_"+(1e6*Math.random()|0),wf=0;function Ds(u,d,g,b,L){this.listener=u,this.proxy=null,this.src=d,this.type=g,this.capture=!!b,this.ha=L,this.key=++wf,this.da=this.fa=!1}function rn(u){u.da=!0,u.listener=null,u.proxy=null,u.src=null,u.ha=null}function Pi(u){this.src=u,this.g={},this.h=0}Pi.prototype.add=function(u,d,g,b,L){var F=u.toString();u=this.g[F],u||(u=this.g[F]=[],this.h++);var Q=nn(u,d,b,L);return-1<Q?(d=u[Q],g||(d.fa=!1)):(d=new Ds(d,this.src,F,!!b,L),d.fa=g,u.push(d)),d};function Pt(u,d){var g=d.type;if(g in u.g){var b=u.g[g],L=Array.prototype.indexOf.call(b,d,void 0),F;(F=0<=L)&&Array.prototype.splice.call(b,L,1),F&&(rn(d),u.g[g].length==0&&(delete u.g[g],u.h--))}}function nn(u,d,g,b){for(var L=0;L<u.length;++L){var F=u[L];if(!F.da&&F.listener==d&&F.capture==!!g&&F.ha==b)return L}return-1}var pa="closure_lm_"+(1e6*Math.random()|0),Ht={};function ma(u,d,g,b,L){if(b&&b.once)return Mt(u,d,g,b,L);if(Array.isArray(d)){for(var F=0;F<d.length;F++)ma(u,d[F],g,b,L);return null}return g=Or(g),u&&u[pr]?u.K(d,g,m(b)?!!b.capture:!!b,L):uc(u,d,g,!1,b,L)}function uc(u,d,g,b,L,F){if(!d)throw Error("Invalid event type");var Q=m(L)?!!L.capture:!!L,_e=ga(u);if(_e||(u[pa]=_e=new Pi(u)),g=_e.add(d,g,b,Q,F),g.proxy)return g;if(b=Ci(),g.proxy=b,b.src=u,b.listener=g,u.addEventListener)Cs||(L=Q),L===void 0&&(L=!1),u.addEventListener(d.toString(),b,L);else if(u.attachEvent)u.attachEvent(cc(d.toString()),b);else if(u.addListener&&u.removeListener)u.addListener(b);else throw Error("addEventListener and attachEvent are unavailable.");return g}function Ci(){function u(g){return d.call(u.src,u.listener,g)}let d=Di;return u}function Mt(u,d,g,b,L){if(Array.isArray(d)){for(var F=0;F<d.length;F++)Mt(u,d[F],g,b,L);return null}return g=Or(g),u&&u[pr]?u.L(d,g,m(b)?!!b.capture:!!b,L):uc(u,d,g,!0,b,L)}function Ln(u,d,g,b,L){if(Array.isArray(d))for(var F=0;F<d.length;F++)Ln(u,d[F],g,b,L);else b=m(b)?!!b.capture:!!b,g=Or(g),u&&u[pr]?(u=u.i,d=String(d).toString(),d in u.g&&(F=u.g[d],g=nn(F,g,b,L),-1<g&&(rn(F[g]),Array.prototype.splice.call(F,g,1),F.length==0&&(delete u.g[d],u.h--)))):u&&(u=ga(u))&&(d=u.g[d.toString()],u=-1,d&&(u=nn(d,g,b,L)),(g=-1<u?d[u]:null)&&Mn(g))}function Mn(u){if(typeof u!="number"&&u&&!u.da){var d=u.src;if(d&&d[pr])Pt(d.i,u);else{var g=u.type,b=u.proxy;d.removeEventListener?d.removeEventListener(g,b,u.capture):d.detachEvent?d.detachEvent(cc(g),b):d.addListener&&d.removeListener&&d.removeListener(b),(g=ga(d))?(Pt(g,u),g.h==0&&(g.src=null,d[pa]=null)):rn(u)}}}function cc(u){return u in Ht?Ht[u]:Ht[u]="on"+u}function Di(u,d){if(u.da)u=!0;else{d=new Si(d,this);var g=u.listener,b=u.ha||u.src;u.fa&&Mn(u),u=g.call(b,d)}return u}function ga(u){return u=u[pa],u instanceof Pi?u:null}var sn="__closure_events_fn_"+(1e9*Math.random()>>>0);function Or(u){return typeof u=="function"?u:(u[sn]||(u[sn]=function(d){return u.handleEvent(d)}),u[sn])}function nt(){Dr.call(this),this.i=new Pi(this),this.M=this,this.F=null}B(nt,Dr),nt.prototype[pr]=!0,nt.prototype.removeEventListener=function(u,d,g,b){Ln(this,u,d,g,b)};function ut(u,d){var g,b=u.F;if(b)for(g=[];b;b=b.F)g.push(b);if(u=u.M,b=d.type||d,typeof d=="string")d=new Ke(d,u);else if(d instanceof Ke)d.target=d.target||u;else{var L=d;d=new Ke(b,u),D(d,L)}if(L=!0,g)for(var F=g.length-1;0<=F;F--){var Q=d.g=g[F];L=Fn(Q,b,!0,d)&&L}if(Q=d.g=u,L=Fn(Q,b,!0,d)&&L,L=Fn(Q,b,!1,d)&&L,g)for(F=0;F<g.length;F++)Q=d.g=g[F],L=Fn(Q,b,!1,d)&&L}nt.prototype.N=function(){if(nt.aa.N.call(this),this.i){var u=this.i,d;for(d in u.g){for(var g=u.g[d],b=0;b<g.length;b++)rn(g[b]);delete u.g[d],u.h--}}this.F=null},nt.prototype.K=function(u,d,g,b){return this.i.add(String(u),d,!1,g,b)},nt.prototype.L=function(u,d,g,b){return this.i.add(String(u),d,!0,g,b)};function Fn(u,d,g,b){if(d=u.i.g[String(d)],!d)return!0;d=d.concat();for(var L=!0,F=0;F<d.length;++F){var Q=d[F];if(Q&&!Q.da&&Q.capture==g){var _e=Q.listener,Ze=Q.ha||Q.src;Q.fa&&Pt(u.i,Q),L=_e.call(Ze,b)!==!1&&L}}return L&&!b.defaultPrevented}function Os(u,d,g){if(typeof u=="function")g&&(u=I(u,g));else if(u&&typeof u.handleEvent=="function")u=I(u.handleEvent,u);else throw Error("Invalid listener argument");return 2147483647<Number(d)?-1:h.setTimeout(u,d||0)}function ks(u){u.g=Os(()=>{u.g=null,u.i&&(u.i=!1,ks(u))},u.l);let d=u.h;u.h=null,u.m.apply(null,d)}class _a extends Dr{constructor(d,g){super(),this.m=d,this.l=g,this.h=null,this.i=!1,this.g=null}j(d){this.h=arguments,this.g?this.i=!0:ks(this)}N(){super.N(),this.g&&(h.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function on(u){Dr.call(this),this.h=u,this.g={}}B(on,Dr);var Ns=[];function Vs(u){ie(u.g,function(d,g){this.g.hasOwnProperty(g)&&Mn(d)},u),u.g={}}on.prototype.N=function(){on.aa.N.call(this),Vs(this)},on.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var ya=h.JSON.stringify,bf=h.JSON.parse,Tf=class{stringify(u){return h.JSON.stringify(u,void 0)}parse(u){return h.JSON.parse(u,void 0)}};function Ls(){}Ls.prototype.h=null;function va(u){return u.h||(u.h=u.i())}function lc(){}var Oi={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function wa(){Ke.call(this,"d")}B(wa,Ke);function ba(){Ke.call(this,"c")}B(ba,Ke);var kr={},hc=null;function Ms(){return hc=hc||new nt}kr.La="serverreachability";function fc(u){Ke.call(this,kr.La,u)}B(fc,Ke);function an(u){let d=Ms();ut(d,new fc(d))}kr.STAT_EVENT="statevent";function dc(u,d){Ke.call(this,kr.STAT_EVENT,u),this.stat=d}B(dc,Ke);function ct(u){let d=Ms();ut(d,new dc(d,u))}kr.Ma="timingevent";function pc(u,d){Ke.call(this,kr.Ma,u),this.size=d}B(pc,Ke);function ki(u,d){if(typeof u!="function")throw Error("Fn must not be null and must be a function");return h.setTimeout(function(){u()},d)}function Ni(){this.g=!0}Ni.prototype.xa=function(){this.g=!1};function Ef(u,d,g,b,L,F){u.info(function(){if(u.g)if(F)for(var Q="",_e=F.split("&"),Ze=0;Ze<_e.length;Ze++){var be=_e[Ze].split("=");if(1<be.length){var lt=be[0];be=be[1];var ht=lt.split("_");Q=2<=ht.length&&ht[1]=="type"?Q+(lt+"="+be+"&"):Q+(lt+"=redacted&")}}else Q=null;else Q=F;return"XMLHTTP REQ ("+b+") [attempt "+L+"]: "+d+`
21
21
  `+g+`
22
- `+Q})}function Ef(u,d,g,b,L,F,Q){u.info(function(){return"XMLHTTP RESP ("+b+") [ attempt "+L+"]: "+d+`
22
+ `+Q})}function If(u,d,g,b,L,F,Q){u.info(function(){return"XMLHTTP RESP ("+b+") [ attempt "+L+"]: "+d+`
23
23
  `+g+`
24
- `+F+" "+Q})}function Ur(u,d,g,b){u.info(function(){return"XMLHTTP TEXT ("+d+"): "+xf(u,g)+(b?" "+b:"")})}function If(u,d){u.info(function(){return"TIMEOUT: "+d})}Ni.prototype.info=function(){};function xf(u,d){if(!u.g)return d;if(!d)return null;try{var g=JSON.parse(d);if(g){for(u=0;u<g.length;u++)if(Array.isArray(g[u])){var b=g[u];if(!(2>b.length)){var L=b[1];if(Array.isArray(L)&&!(1>L.length)){var F=L[0];if(F!="noop"&&F!="stop"&&F!="close")for(var Q=1;Q<L.length;Q++)L[Q]=""}}}}return _a(g)}catch{return d}}var Vi={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},dc={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"},ba;function Fs(){}B(Fs,Ls),Fs.prototype.g=function(){return new XMLHttpRequest},Fs.prototype.i=function(){return{}},ba=new Fs;function Vn(u,d,g,b){this.j=u,this.i=d,this.l=g,this.R=b||1,this.U=new or(this),this.I=45e3,this.H=null,this.o=!1,this.m=this.A=this.v=this.L=this.F=this.S=this.B=null,this.D=[],this.g=null,this.C=0,this.s=this.u=null,this.X=-1,this.J=!1,this.O=0,this.M=null,this.W=this.K=this.T=this.P=!1,this.h=new pc}function pc(){this.i=null,this.g="",this.h=!1}var mc={},Br={};function Ta(u,d,g){u.L=1,u.v=Ui(_n(d)),u.m=g,u.P=!0,Li(u,null)}function Li(u,d){u.F=Date.now(),Us(u),u.A=_n(u.v);var g=u.A,b=u.R;Array.isArray(b)||(b=[String(b)]),Sc(g.i,"t",b),u.C=0,g=u.j.J,u.h=new pc,u.g=Na(u.j,g?d:null,!u.m),0<u.O&&(u.M=new ga(I(u.Y,u,u.g),u.O)),d=u.U,g=u.g,b=u.ca;var L="readystatechange";Array.isArray(L)||(L&&(Ns[0]=L.toString()),L=Ns);for(var F=0;F<L.length;F++){var Q=pa(g,L[F],b||d.handleEvent,!1,d.h||d);if(!Q)break;d.g[Q.key]=Q}d=u.H?A(u.H):{},u.m?(u.u||(u.u="POST"),d["Content-Type"]="application/x-www-form-urlencoded",u.g.ea(u.A,u.u,u.m,d)):(u.u="GET",u.g.ea(u.A,u.u,null,d)),ar(),Tf(u.i,u.u,u.A,u.l,u.R,u.m)}Vn.prototype.ca=function(u){u=u.target;let d=this.M;d&&We(u)==3?d.j():this.Y(u)},Vn.prototype.Y=function(u){try{if(u==this.g)e:{let lt=We(this.g);var d=this.g.Ba();let Hr=this.g.Z();if(!(3>lt)&&(lt!=3||this.g&&(this.h.h||this.g.oa()||Oa(this.g)))){this.J||lt!=4||d==7||(d==8||0>=Hr?ar(3):ar(2)),Bs(this);var g=this.g.Z();this.X=g;t:if(gc(this)){var b=Oa(this.g);u="";var L=b.length,F=We(this.g)==4;if(!this.h.i){if(typeof TextDecoder=="undefined"){ur(this),jr(this);var Q="";break t}this.h.i=new h.TextDecoder}for(d=0;d<L;d++)this.h.h=!0,u+=this.h.i.decode(b[d],{stream:!(F&&d==L-1)});b.length=0,this.h.g+=u,this.C=0,Q=this.h.g}else Q=this.g.oa();if(this.o=g==200,Ef(this.i,this.u,this.A,this.l,this.R,lt,g),this.o){if(this.T&&!this.K){t:{if(this.g){var _e,Xe=this.g;if((_e=Xe.g?Xe.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!ee(_e)){var be=_e;break t}}be=null}if(g=be)Ur(this.i,this.l,g,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,Ia(this,g);else{this.o=!1,this.s=3,ut(12),ur(this),jr(this);break e}}if(this.P){g=!0;let Ht;for(;!this.J&&this.C<Q.length;)if(Ht=Af(this,Q),Ht==Br){lt==4&&(this.s=4,ut(14),g=!1),Ur(this.i,this.l,null,"[Incomplete Response]");break}else if(Ht==mc){this.s=4,ut(15),Ur(this.i,this.l,Q,"[Invalid Chunk]"),g=!1;break}else Ur(this.i,this.l,Ht,null),Ia(this,Ht);if(gc(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),lt!=4||Q.length!=0||this.h.h||(this.s=1,ut(16),g=!1),this.o=this.o&&g,!g)Ur(this.i,this.l,Q,"[Invalid Chunked Response]"),ur(this),jr(this);else if(0<Q.length&&!this.W){this.W=!0;var ct=this.j;ct.g==this&&ct.ba&&!ct.M&&(ct.j.info("Great, no buffering proxy detected. Bytes received: "+Q.length),Fe(ct),ct.M=!0,ut(11))}}else Ur(this.i,this.l,Q,null),Ia(this,Q);lt==4&&ur(this),this.o&&!this.J&&(lt==4?kc(this.j,this):(this.o=!1,Us(this)))}else Dc(this.g),g==400&&0<Q.indexOf("Unknown SID")?(this.s=3,ut(12)):(this.s=0,ut(13)),ur(this),jr(this)}}}catch{}finally{}};function gc(u){return u.g?u.u=="GET"&&u.L!=2&&u.j.Ca:!1}function Af(u,d){var g=u.C,b=d.indexOf(`
25
- `,g);return b==-1?Br:(g=Number(d.substring(g,b)),isNaN(g)?mc:(b+=1,b+g>d.length?Br:(d=d.slice(b,b+g),u.C=b+g,d)))}Vn.prototype.cancel=function(){this.J=!0,ur(this)};function Us(u){u.S=Date.now()+u.I,Ea(u,u.I)}function Ea(u,d){if(u.B!=null)throw Error("WatchDog timer not null");u.B=ki(I(u.ba,u),d)}function Bs(u){u.B&&(h.clearTimeout(u.B),u.B=null)}Vn.prototype.ba=function(){this.B=null;let u=Date.now();0<=u-this.S?(If(this.i,this.A),this.L!=2&&(ar(),ut(17)),ur(this),this.s=2,jr(this)):Ea(this,this.S-u)};function jr(u){u.j.G==0||u.J||kc(u.j,u)}function ur(u){Bs(u);var d=u.M;d&&typeof d.ma=="function"&&d.ma(),u.M=null,Vs(u.U),u.g&&(d=u.g,u.g=null,d.abort(),d.ma())}function Ia(u,d){try{var g=u.j;if(g.G!=0&&(g.g==u||js(g.h,u))){if(!u.K&&js(g.h,u)&&g.G==3){try{var b=g.Da.g.parse(d)}catch{b=null}if(Array.isArray(b)&&b.length==3){var L=b;if(L[0]==0){e:if(!g.u){if(g.g)if(g.g.F+3e3<u.F)Wr(g),Gi(g);else break e;Wi(g),ut(18)}}else g.za=L[1],0<g.za-g.T&&37500>L[2]&&g.F&&g.v==0&&!g.C&&(g.C=ki(I(g.Za,g),6e3));if(1>=Aa(g.h)&&g.ca){try{g.ca()}catch{}g.ca=void 0}}else cr(g,11)}else if((u.K||g.g==u)&&Wr(g),!ee(d))for(L=g.Da.g.parse(d),d=0;d<L.length;d++){let be=L[d];if(g.T=be[0],be=be[1],g.G==2)if(be[0]=="c"){g.K=be[1],g.ia=be[2];let ct=be[3];ct!=null&&(g.la=ct,g.j.info("VER="+g.la));let lt=be[4];lt!=null&&(g.Aa=lt,g.j.info("SVER="+g.Aa));let Hr=be[5];Hr!=null&&typeof Hr=="number"&&0<Hr&&(b=1.5*Hr,g.L=b,g.j.info("backChannelRequestTimeoutMs_="+b)),b=g;let Ht=u.g;if(Ht){let Qs=Ht.g?Ht.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(Qs){var F=b.h;F.g||Qs.indexOf("spdy")==-1&&Qs.indexOf("quic")==-1&&Qs.indexOf("h2")==-1||(F.j=F.l,F.g=new Set,F.h&&(Mi(F,F.h),F.h=null))}if(b.D){let Ma=Ht.g?Ht.g.getResponseHeader("X-HTTP-Session-Id"):null;Ma&&(b.ya=Ma,Ce(b.I,b.D,Ma))}}g.G=3,g.l&&g.l.ua(),g.ba&&(g.R=Date.now()-u.F,g.j.info("Handshake RTT: "+g.R+"ms")),b=g;var Q=u;if(b.qa=Vc(b,b.J?b.ia:null,b.W),Q.K){yc(b.h,Q);var _e=Q,Xe=b.L;Xe&&(_e.I=Xe),_e.B&&(Bs(_e),Us(_e)),b.g=Q}else Ki(b);0<g.i.length&&Ws(g)}else be[0]!="stop"&&be[0]!="close"||cr(g,7);else g.G==3&&(be[0]=="stop"||be[0]=="close"?be[0]=="stop"?cr(g,7):Ks(g):be[0]!="noop"&&g.l&&g.l.ta(be),g.v=0)}}ar(4)}catch{}}var Sf=class{constructor(u,d){this.g=u,this.map=d}};function _c(u){this.l=u||10,h.PerformanceNavigationTiming?(u=h.performance.getEntriesByType("navigation"),u=0<u.length&&(u[0].nextHopProtocol=="hq"||u[0].nextHopProtocol=="h2")):u=!!(h.chrome&&h.chrome.loadTimes&&h.chrome.loadTimes()&&h.chrome.loadTimes().wasFetchedViaSpdy),this.j=u?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function xa(u){return u.h?!0:u.g?u.g.size>=u.j:!1}function Aa(u){return u.h?1:u.g?u.g.size:0}function js(u,d){return u.h?u.h==d:u.g?u.g.has(d):!1}function Mi(u,d){u.g?u.g.add(d):u.h=d}function yc(u,d){u.h&&u.h==d?u.h=null:u.g&&u.g.has(d)&&u.g.delete(d)}_c.prototype.cancel=function(){if(this.i=Sa(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(let u of this.g.values())u.cancel();this.g.clear()}};function Sa(u){if(u.h!=null)return u.i.concat(u.h.D);if(u.g!=null&&u.g.size!==0){let d=u.i;for(let g of u.g.values())d=d.concat(g.D);return d}return G(u.i)}function $s(u){if(u.V&&typeof u.V=="function")return u.V();if(typeof Map!="undefined"&&u instanceof Map||typeof Set!="undefined"&&u instanceof Set)return Array.from(u.values());if(typeof u=="string")return u.split("");if(f(u)){for(var d=[],g=u.length,b=0;b<g;b++)d.push(u[b]);return d}d=[],g=0;for(b in u)d[g++]=u[b];return d}function vc(u){if(u.na&&typeof u.na=="function")return u.na();if(!u.V||typeof u.V!="function"){if(typeof Map!="undefined"&&u instanceof Map)return Array.from(u.keys());if(!(typeof Set!="undefined"&&u instanceof Set)){if(f(u)||typeof u=="string"){var d=[];u=u.length;for(var g=0;g<u;g++)d.push(g);return d}d=[],g=0;for(let b in u)d[g++]=b;return d}}}function wc(u,d){if(u.forEach&&typeof u.forEach=="function")u.forEach(d,void 0);else if(f(u)||typeof u=="string")Array.prototype.forEach.call(u,d,void 0);else for(var g=vc(u),b=$s(u),L=b.length,F=0;F<L;F++)d.call(void 0,b[F],g&&g[F],u)}var Ra=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function bc(u,d){if(u){u=u.split("&");for(var g=0;g<u.length;g++){var b=u[g].indexOf("="),L=null;if(0<=b){var F=u[g].substring(0,b);L=u[g].substring(b+1)}else F=u[g];d(F,L?decodeURIComponent(L.replace(/\+/g," ")):"")}}}function gn(u){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,u instanceof gn){this.h=u.h,Fi(this,u.j),this.o=u.o,this.g=u.g,$r(this,u.s),this.l=u.l;var d=u.i,g=new ji;g.i=d.i,d.g&&(g.g=new Map(d.g),g.h=d.h),qs(this,g),this.m=u.m}else u&&(d=String(u).match(Ra))?(this.h=!1,Fi(this,d[1]||"",!0),this.o=qr(d[2]||""),this.g=qr(d[3]||"",!0),$r(this,d[4]),this.l=qr(d[5]||"",!0),qs(this,d[6]||"",!0),this.m=qr(d[7]||"")):(this.h=!1,this.i=new ji(null,this.h))}gn.prototype.toString=function(){var u=[],d=this.j;d&&u.push(Bi(d,Pa,!0),":");var g=this.g;return(g||d=="file")&&(u.push("//"),(d=this.o)&&u.push(Bi(d,Pa,!0),"@"),u.push(encodeURIComponent(String(g)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),g=this.s,g!=null&&u.push(":",String(g))),(g=this.l)&&(this.g&&g.charAt(0)!="/"&&u.push("/"),u.push(Bi(g,g.charAt(0)=="/"?Ic:Ec,!0))),(g=this.i.toString())&&u.push("?",g),(g=this.m)&&u.push("#",Bi(g,Pf)),u.join("")};function _n(u){return new gn(u)}function Fi(u,d,g){u.j=g?qr(d,!0):d,u.j&&(u.j=u.j.replace(/:$/,""))}function $r(u,d){if(d){if(d=Number(d),isNaN(d)||0>d)throw Error("Bad port number "+d);u.s=d}else u.s=null}function qs(u,d,g){d instanceof ji?(u.i=d,Ca(u.i,u.h)):(g||(d=Bi(d,Rf)),u.i=new ji(d,u.h))}function Ce(u,d,g){u.i.set(d,g)}function Ui(u){return Ce(u,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),u}function qr(u,d){return u?d?decodeURI(u.replace(/%25/g,"%2525")):decodeURIComponent(u):""}function Bi(u,d,g){return typeof u=="string"?(u=encodeURI(u).replace(d,Tc),g&&(u=u.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),u):null}function Tc(u){return u=u.charCodeAt(0),"%"+(u>>4&15).toString(16)+(u&15).toString(16)}var Pa=/[#\/\?@]/g,Ec=/[#\?:]/g,Ic=/[#\?]/g,Rf=/[#\?@]/g,Pf=/#/g;function ji(u,d){this.h=this.g=null,this.i=u||null,this.j=!!d}function yn(u){u.g||(u.g=new Map,u.h=0,u.i&&bc(u.i,function(d,g){u.add(decodeURIComponent(d.replace(/\+/g," ")),g)}))}n=ji.prototype,n.add=function(u,d){yn(this),this.i=null,u=zr(this,u);var g=this.g.get(u);return g||this.g.set(u,g=[]),g.push(d),this.h+=1,this};function xc(u,d){yn(u),d=zr(u,d),u.g.has(d)&&(u.i=null,u.h-=u.g.get(d).length,u.g.delete(d))}function Ac(u,d){return yn(u),d=zr(u,d),u.g.has(d)}n.forEach=function(u,d){yn(this),this.g.forEach(function(g,b){g.forEach(function(L){u.call(d,L,b,this)},this)},this)},n.na=function(){yn(this);let u=Array.from(this.g.values()),d=Array.from(this.g.keys()),g=[];for(let b=0;b<d.length;b++){let L=u[b];for(let F=0;F<L.length;F++)g.push(d[b])}return g},n.V=function(u){yn(this);let d=[];if(typeof u=="string")Ac(this,u)&&(d=d.concat(this.g.get(zr(this,u))));else{u=Array.from(this.g.values());for(let g=0;g<u.length;g++)d=d.concat(u[g])}return d},n.set=function(u,d){return yn(this),this.i=null,u=zr(this,u),Ac(this,u)&&(this.h-=this.g.get(u).length),this.g.set(u,[d]),this.h+=1,this},n.get=function(u,d){return u?(u=this.V(u),0<u.length?String(u[0]):d):d};function Sc(u,d,g){xc(u,d),0<g.length&&(u.i=null,u.g.set(zr(u,d),G(g)),u.h+=g.length)}n.toString=function(){if(this.i)return this.i;if(!this.g)return"";let u=[],d=Array.from(this.g.keys());for(var g=0;g<d.length;g++){var b=d[g];let F=encodeURIComponent(String(b)),Q=this.V(b);for(b=0;b<Q.length;b++){var L=F;Q[b]!==""&&(L+="="+encodeURIComponent(String(Q[b]))),u.push(L)}}return this.i=u.join("&")};function zr(u,d){return d=String(d),u.j&&(d=d.toLowerCase()),d}function Ca(u,d){d&&!u.j&&(yn(u),u.i=null,u.g.forEach(function(g,b){var L=b.toLowerCase();b!=L&&(xc(this,b),Sc(this,L,g))},u)),u.j=d}function Cf(u,d){let g=new Ni;if(h.Image){let b=new Image;b.onload=k(Ln,g,"TestLoadImage: loaded",!0,d,b),b.onerror=k(Ln,g,"TestLoadImage: error",!1,d,b),b.onabort=k(Ln,g,"TestLoadImage: abort",!1,d,b),b.ontimeout=k(Ln,g,"TestLoadImage: timeout",!1,d,b),h.setTimeout(function(){b.ontimeout&&b.ontimeout()},1e4),b.src=u}else d(!1)}function Df(u,d){let g=new Ni,b=new AbortController,L=setTimeout(()=>{b.abort(),Ln(g,"TestPingServer: timeout",!1,d)},1e4);fetch(u,{signal:b.signal}).then(F=>{clearTimeout(L),F.ok?Ln(g,"TestPingServer: ok",!0,d):Ln(g,"TestPingServer: server error",!1,d)}).catch(()=>{clearTimeout(L),Ln(g,"TestPingServer: error",!1,d)})}function Ln(u,d,g,b,L){try{L&&(L.onload=null,L.onerror=null,L.onabort=null,L.ontimeout=null),b(g)}catch{}}function Of(){this.g=new bf}function kf(u,d,g){let b=g||"";try{wc(u,function(L,F){let Q=L;m(L)&&(Q=_a(L)),d.push(b+F+"="+encodeURIComponent(Q))})}catch(L){throw d.push(b+"type="+encodeURIComponent("_badmap")),L}}function Oe(u){this.l=u.Ub||null,this.j=u.eb||!1}B(Oe,Ls),Oe.prototype.g=function(){return new ke(this.l,this.j)},Oe.prototype.i=function(u){return function(){return u}}({});function ke(u,d){nt.call(this),this.D=u,this.o=d,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}B(ke,nt),n=ke.prototype,n.open=function(u,d){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.B=u,this.A=d,this.readyState=1,qi(this)},n.send=function(u){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");this.g=!0;let d={headers:this.u,method:this.B,credentials:this.m,cache:void 0};u&&(d.body=u),(this.D||h).fetch(new Request(this.A,d)).then(this.Sa.bind(this),this.ga.bind(this))},n.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),1<=this.readyState&&this.g&&this.readyState!=4&&(this.g=!1,$i(this)),this.readyState=0},n.Sa=function(u){if(this.g&&(this.l=u,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=u.headers,this.readyState=2,qi(this)),this.g&&(this.readyState=3,qi(this),this.g)))if(this.responseType==="arraybuffer")u.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(typeof h.ReadableStream!="undefined"&&"body"in u){if(this.j=u.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;Rc(this)}else u.text().then(this.Ra.bind(this),this.ga.bind(this))};function Rc(u){u.j.read().then(u.Pa.bind(u)).catch(u.ga.bind(u))}n.Pa=function(u){if(this.g){if(this.o&&u.value)this.response.push(u.value);else if(!this.o){var d=u.value?u.value:new Uint8Array(0);(d=this.v.decode(d,{stream:!u.done}))&&(this.response=this.responseText+=d)}u.done?$i(this):qi(this),this.readyState==3&&Rc(this)}},n.Ra=function(u){this.g&&(this.response=this.responseText=u,$i(this))},n.Qa=function(u){this.g&&(this.response=u,$i(this))},n.ga=function(){this.g&&$i(this)};function $i(u){u.readyState=4,u.l=null,u.j=null,u.v=null,qi(u)}n.setRequestHeader=function(u,d){this.u.append(u,d)},n.getResponseHeader=function(u){return this.h&&this.h.get(u.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";let u=[],d=this.h.entries();for(var g=d.next();!g.done;)g=g.value,u.push(g[0]+": "+g[1]),g=d.next();return u.join(`\r
26
- `)};function qi(u){u.onreadystatechange&&u.onreadystatechange.call(u)}Object.defineProperty(ke.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(u){this.m=u?"include":"same-origin"}});function Pc(u){let d="";return ie(u,function(g,b){d+=b,d+=":",d+=g,d+=`\r
27
- `}),d}function Da(u,d,g){e:{for(b in g){var b=!1;break e}b=!0}b||(g=Pc(g),typeof u=="string"?g!=null&&encodeURIComponent(String(g)):Ce(u,d,g))}function qe(u){nt.call(this),this.headers=new Map,this.o=u||null,this.h=!1,this.v=this.g=null,this.D="",this.m=0,this.l="",this.j=this.B=this.u=this.A=!1,this.I=null,this.H="",this.J=!1}B(qe,nt);var Cc=/^https?$/i,Nf=["POST","PUT"];n=qe.prototype,n.Ha=function(u){this.J=u},n.ea=function(u,d,g,b){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+u);d=d?d.toUpperCase():"GET",this.D=u,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():ba.g(),this.v=this.o?ya(this.o):ya(ba),this.g.onreadystatechange=I(this.Ea,this);try{this.B=!0,this.g.open(d,String(u),!0),this.B=!1}catch(F){Ye(this,F);return}if(u=g||"",g=new Map(this.headers),b)if(Object.getPrototypeOf(b)===Object.prototype)for(var L in b)g.set(L,b[L]);else if(typeof b.keys=="function"&&typeof b.get=="function")for(let F of b.keys())g.set(F,b.get(F));else throw Error("Unknown input type for opt_headers: "+String(b));b=Array.from(g.keys()).find(F=>F.toLowerCase()=="content-type"),L=h.FormData&&u instanceof h.FormData,!(0<=Array.prototype.indexOf.call(Nf,d,void 0))||b||L||g.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(let[F,Q]of g)this.g.setRequestHeader(F,Q);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{Gs(this),this.u=!0,this.g.send(u),this.u=!1}catch(F){Ye(this,F)}};function Ye(u,d){u.h=!1,u.g&&(u.j=!0,u.g.abort(),u.j=!1),u.l=d,u.m=5,zs(u),zi(u)}function zs(u){u.A||(u.A=!0,at(u,"complete"),at(u,"error"))}n.abort=function(u){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=u||7,at(this,"complete"),at(this,"abort"),zi(this))},n.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),zi(this,!0)),qe.aa.N.call(this)},n.Ea=function(){this.s||(this.B||this.u||this.j?Mn(this):this.bb())},n.bb=function(){Mn(this)};function Mn(u){if(u.h&&typeof c!="undefined"&&(!u.v[1]||We(u)!=4||u.Z()!=2)){if(u.u&&We(u)==4)Os(u.Ea,0,u);else if(at(u,"readystatechange"),We(u)==4){u.h=!1;try{let Q=u.Z();e:switch(Q){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var d=!0;break e;default:d=!1}var g;if(!(g=d)){var b;if(b=Q===0){var L=String(u.D).match(Ra)[1]||null;!L&&h.self&&h.self.location&&(L=h.self.location.protocol.slice(0,-1)),b=!Cc.test(L?L.toLowerCase():"")}g=b}if(g)at(u,"complete"),at(u,"success");else{u.m=6;try{var F=2<We(u)?u.g.statusText:""}catch{F=""}u.l=F+" ["+u.Z()+"]",zs(u)}}finally{zi(u)}}}}function zi(u,d){if(u.g){Gs(u);let g=u.g,b=u.v[0]?()=>{}:null;u.g=null,u.v=null,d||at(u,"ready");try{g.onreadystatechange=b}catch{}}}function Gs(u){u.I&&(h.clearTimeout(u.I),u.I=null)}n.isActive=function(){return!!this.g};function We(u){return u.g?u.g.readyState:0}n.Z=function(){try{return 2<We(this)?this.g.status:-1}catch{return-1}},n.oa=function(){try{return this.g?this.g.responseText:""}catch{return""}},n.Oa=function(u){if(this.g){var d=this.g.responseText;return u&&d.indexOf(u)==0&&(d=d.substring(u.length)),wf(d)}};function Oa(u){try{if(!u.g)return null;if("response"in u.g)return u.g.response;switch(u.H){case"":case"text":return u.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in u.g)return u.g.mozResponseArrayBuffer}return null}catch{return null}}function Dc(u){let d={};u=(u.g&&2<=We(u)&&u.g.getAllResponseHeaders()||"").split(`\r
28
- `);for(let b=0;b<u.length;b++){if(ee(u[b]))continue;var g=V(u[b]);let L=g[0];if(g=g[1],typeof g!="string")continue;g=g.trim();let F=d[L]||[];d[L]=F,F.push(g)}C(d,function(b){return b.join(", ")})}n.Ba=function(){return this.m},n.Ka=function(){return typeof this.l=="string"?this.l:String(this.l)};function Gr(u,d,g){return g&&g.internalChannelParams&&g.internalChannelParams[u]||d}function ka(u){this.Aa=0,this.i=[],this.j=new Ni,this.ia=this.qa=this.I=this.W=this.g=this.ya=this.D=this.H=this.m=this.S=this.o=null,this.Ya=this.U=0,this.Va=Gr("failFast",!1,u),this.F=this.C=this.u=this.s=this.l=null,this.X=!0,this.za=this.T=-1,this.Y=this.v=this.B=0,this.Ta=Gr("baseRetryDelayMs",5e3,u),this.cb=Gr("retryDelaySeedMs",1e4,u),this.Wa=Gr("forwardChannelMaxRetries",2,u),this.wa=Gr("forwardChannelRequestTimeoutMs",2e4,u),this.pa=u&&u.xmlHttpFactory||void 0,this.Xa=u&&u.Tb||void 0,this.Ca=u&&u.useFetchStreams||!1,this.L=void 0,this.J=u&&u.supportsCrossDomainXhr||!1,this.K="",this.h=new _c(u&&u.concurrentRequestLimit),this.Da=new Of,this.P=u&&u.fastHandshake||!1,this.O=u&&u.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=u&&u.Rb||!1,u&&u.xa&&this.j.xa(),u&&u.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&u&&u.detectBufferingProxy||!1,this.ja=void 0,u&&u.longPollingTimeout&&0<u.longPollingTimeout&&(this.ja=u.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}n=ka.prototype,n.la=8,n.G=1,n.connect=function(u,d,g,b){ut(0),this.W=u,this.H=d||{},g&&b!==void 0&&(this.H.OSID=g,this.H.OAID=b),this.F=this.X,this.I=Vc(this,null,this.W),Ws(this)};function Ks(u){if(bt(u),u.G==3){var d=u.U++,g=_n(u.I);if(Ce(g,"SID",u.K),Ce(g,"RID",d),Ce(g,"TYPE","terminate"),Kr(u,g),d=new Vn(u,u.j,d),d.L=2,d.v=Ui(_n(g)),g=!1,h.navigator&&h.navigator.sendBeacon)try{g=h.navigator.sendBeacon(d.v.toString(),"")}catch{}!g&&h.Image&&(new Image().src=d.v,g=!0),g||(d.g=Na(d.j,null),d.g.ea(d.v)),d.F=Date.now(),Us(d)}Nc(u)}function Gi(u){u.g&&(Fe(u),u.g.cancel(),u.g=null)}function bt(u){Gi(u),u.u&&(h.clearTimeout(u.u),u.u=null),Wr(u),u.h.cancel(),u.s&&(typeof u.s=="number"&&h.clearTimeout(u.s),u.s=null)}function Ws(u){if(!xa(u.h)&&!u.s){u.s=!0;var d=u.Ga;Ai||sc(),Dn||(Ai(),Dn=!0),Nt.add(d,u),u.B=0}}function Lt(u,d){return Aa(u.h)>=u.h.j-(u.s?1:0)?!1:u.s?(u.i=d.D.concat(u.i),!0):u.G==1||u.G==2||u.B>=(u.Va?0:u.Wa)?!1:(u.s=ki(I(u.Ga,u,d),Hs(u,u.B)),u.B++,!0)}n.Ga=function(u){if(this.s)if(this.s=null,this.G==1){if(!u){this.U=Math.floor(1e5*Math.random()),u=this.U++;let L=new Vn(this,this.j,u),F=this.o;if(this.S&&(F?(F=A(F),D(F,this.S)):F=this.S),this.m!==null||this.O||(L.H=F,F=null),this.P)e:{for(var d=0,g=0;g<this.i.length;g++){t:{var b=this.i[g];if("__data__"in b.map&&(b=b.map.__data__,typeof b=="string")){b=b.length;break t}b=void 0}if(b===void 0)break;if(d+=b,4096<d){d=g;break e}if(d===4096||g===this.i.length-1){d=g+1;break e}}d=1e3}else d=1e3;d=vn(this,L,d),g=_n(this.I),Ce(g,"RID",u),Ce(g,"CVER",22),this.D&&Ce(g,"X-HTTP-Session-Id",this.D),Kr(this,g),F&&(this.O?d="headers="+encodeURIComponent(String(Pc(F)))+"&"+d:this.m&&Da(g,this.m,F)),Mi(this.h,L),this.Ua&&Ce(g,"TYPE","init"),this.P?(Ce(g,"$req",d),Ce(g,"SID","null"),L.T=!0,Ta(L,g,null)):Ta(L,g,d),this.G=2}}else this.G==3&&(u?Oc(this,u):this.i.length==0||xa(this.h)||Oc(this))};function Oc(u,d){var g;d?g=d.l:g=u.U++;let b=_n(u.I);Ce(b,"SID",u.K),Ce(b,"RID",g),Ce(b,"AID",u.T),Kr(u,b),u.m&&u.o&&Da(b,u.m,u.o),g=new Vn(u,u.j,g,u.B+1),u.m===null&&(g.H=u.o),d&&(u.i=d.D.concat(u.i)),d=vn(u,g,1e3),g.I=Math.round(.5*u.wa)+Math.round(.5*u.wa*Math.random()),Mi(u.h,g),Ta(g,b,d)}function Kr(u,d){u.H&&ie(u.H,function(g,b){Ce(d,b,g)}),u.l&&wc({},function(g,b){Ce(d,b,g)})}function vn(u,d,g){g=Math.min(u.i.length,g);var b=u.l?I(u.l.Na,u.l,u):null;e:{var L=u.i;let F=-1;for(;;){let Q=["count="+g];F==-1?0<g?(F=L[0].g,Q.push("ofs="+F)):F=0:Q.push("ofs="+F);let _e=!0;for(let Xe=0;Xe<g;Xe++){let be=L[Xe].g,ct=L[Xe].map;if(be-=F,0>be)F=Math.max(0,L[Xe].g-100),_e=!1;else try{kf(ct,Q,"req"+be+"_")}catch{b&&b(ct)}}if(_e){b=Q.join("&");break e}}}return u=u.i.splice(0,g),d.D=u,b}function Ki(u){if(!u.g&&!u.u){u.Y=1;var d=u.Fa;Ai||sc(),Dn||(Ai(),Dn=!0),Nt.add(d,u),u.v=0}}function Wi(u){return u.g||u.u||3<=u.v?!1:(u.Y++,u.u=ki(I(u.Fa,u),Hs(u,u.v)),u.v++,!0)}n.Fa=function(){if(this.u=null,wn(this),this.ba&&!(this.M||this.g==null||0>=this.R)){var u=2*this.R;this.j.info("BP detection timer enabled: "+u),this.A=ki(I(this.ab,this),u)}},n.ab=function(){this.A&&(this.A=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.M=!0,ut(10),Gi(this),wn(this))};function Fe(u){u.A!=null&&(h.clearTimeout(u.A),u.A=null)}function wn(u){u.g=new Vn(u,u.j,"rpc",u.Y),u.m===null&&(u.g.H=u.o),u.g.O=0;var d=_n(u.qa);Ce(d,"RID","rpc"),Ce(d,"SID",u.K),Ce(d,"AID",u.T),Ce(d,"CI",u.F?"0":"1"),!u.F&&u.ja&&Ce(d,"TO",u.ja),Ce(d,"TYPE","xmlhttp"),Kr(u,d),u.m&&u.o&&Da(d,u.m,u.o),u.L&&(u.g.I=u.L);var g=u.g;u=u.ia,g.L=1,g.v=Ui(_n(d)),g.m=null,g.P=!0,Li(g,u)}n.Za=function(){this.C!=null&&(this.C=null,Gi(this),Wi(this),ut(19))};function Wr(u){u.C!=null&&(h.clearTimeout(u.C),u.C=null)}function kc(u,d){var g=null;if(u.g==d){Wr(u),Fe(u),u.g=null;var b=2}else if(js(u.h,d))g=d.D,yc(u.h,d),b=1;else return;if(u.G!=0){if(d.o)if(b==1){g=d.m?d.m.length:0,d=Date.now()-d.F;var L=u.B;b=Ms(),at(b,new fc(b,g)),Ws(u)}else Ki(u);else if(L=d.s,L==3||L==0&&0<d.X||!(b==1&&Lt(u,d)||b==2&&Wi(u)))switch(g&&0<g.length&&(d=u.h,d.i=d.i.concat(g)),L){case 1:cr(u,5);break;case 4:cr(u,10);break;case 3:cr(u,6);break;default:cr(u,2)}}}function Hs(u,d){let g=u.Ta+Math.floor(Math.random()*u.cb);return u.isActive()||(g*=2),g*d}function cr(u,d){if(u.j.info("Error code "+d),d==2){var g=I(u.fb,u),b=u.Xa;let L=!b;b=new gn(b||"//www.google.com/images/cleardot.gif"),h.location&&h.location.protocol=="http"||Fi(b,"https"),Ui(b),L?Cf(b.toString(),g):Df(b.toString(),g)}else ut(2);u.G=0,u.l&&u.l.sa(d),Nc(u),bt(u)}n.fb=function(u){u?(this.j.info("Successfully pinged google.com"),ut(2)):(this.j.info("Failed to ping google.com"),ut(1))};function Nc(u){if(u.G=0,u.ka=[],u.l){let d=Sa(u.h);(d.length!=0||u.i.length!=0)&&(j(u.ka,d),j(u.ka,u.i),u.h.i.length=0,G(u.i),u.i.length=0),u.l.ra()}}function Vc(u,d,g){var b=g instanceof gn?_n(g):new gn(g);if(b.g!="")d&&(b.g=d+"."+b.g),$r(b,b.s);else{var L=h.location;b=L.protocol,d=d?d+"."+L.hostname:L.hostname,L=+L.port;var F=new gn(null);b&&Fi(F,b),d&&(F.g=d),L&&$r(F,L),g&&(F.l=g),b=F}return g=u.D,d=u.ya,g&&d&&Ce(b,g,d),Ce(b,"VER",u.la),Kr(u,b),b}function Na(u,d,g){if(d&&!u.J)throw Error("Can't create secondary domain capable XhrIo object.");return d=u.Ca&&!u.pa?new qe(new Oe({eb:g})):new qe(u.pa),d.Ha(u.J),d}n.isActive=function(){return!!this.l&&this.l.isActive(this)};function Hi(){}n=Hi.prototype,n.ua=function(){},n.ta=function(){},n.sa=function(){},n.ra=function(){},n.isActive=function(){return!0},n.Na=function(){};function bn(){}bn.prototype.g=function(u,d){return new Rt(u,d)};function Rt(u,d){nt.call(this),this.g=new ka(d),this.l=u,this.h=d&&d.messageUrlParams||null,u=d&&d.messageHeaders||null,d&&d.clientProtocolHeaderRequired&&(u?u["X-Client-Protocol"]="webchannel":u={"X-Client-Protocol":"webchannel"}),this.g.o=u,u=d&&d.initMessageHeaders||null,d&&d.messageContentType&&(u?u["X-WebChannel-Content-Type"]=d.messageContentType:u={"X-WebChannel-Content-Type":d.messageContentType}),d&&d.va&&(u?u["X-WebChannel-Client-Profile"]=d.va:u={"X-WebChannel-Client-Profile":d.va}),this.g.S=u,(u=d&&d.Sb)&&!ee(u)&&(this.g.m=u),this.v=d&&d.supportsCrossDomainXhr||!1,this.u=d&&d.sendRawJson||!1,(d=d&&d.httpSessionIdParam)&&!ee(d)&&(this.g.D=d,u=this.h,u!==null&&d in u&&(u=this.h,d in u&&delete u[d])),this.j=new Fn(this)}B(Rt,nt),Rt.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},Rt.prototype.close=function(){Ks(this.g)},Rt.prototype.o=function(u){var d=this.g;if(typeof u=="string"){var g={};g.__data__=u,u=g}else this.u&&(g={},g.__data__=_a(u),u=g);d.i.push(new Sf(d.Ya++,u)),d.G==3&&Ws(d)},Rt.prototype.N=function(){this.g.l=null,delete this.j,Ks(this.g),delete this.g,Rt.aa.N.call(this)};function Va(u){va.call(this),u.__headers__&&(this.headers=u.__headers__,this.statusCode=u.__status__,delete u.__headers__,delete u.__status__);var d=u.__sm__;if(d){e:{for(let g in d){u=g;break e}u=void 0}(this.i=u)&&(u=this.i,d=d!==null&&u in d?d[u]:void 0),this.data=d}else this.data=u}B(Va,va);function La(){wa.call(this),this.status=1}B(La,wa);function Fn(u){this.g=u}B(Fn,Hi),Fn.prototype.ua=function(){at(this.g,"a")},Fn.prototype.ta=function(u){at(this.g,new Va(u))},Fn.prototype.sa=function(u){at(this.g,new La)},Fn.prototype.ra=function(){at(this.g,"b")},bn.prototype.createWebChannel=bn.prototype.g,Rt.prototype.send=Rt.prototype.o,Rt.prototype.open=Rt.prototype.m,Rt.prototype.close=Rt.prototype.close,lp=Rr.createWebChannelTransport=function(){return new bn},cp=Rr.getStatEventTarget=function(){return Ms()},up=Rr.Event=Nn,Ql=Rr.Stat={mb:0,pb:1,qb:2,Jb:3,Ob:4,Lb:5,Mb:6,Kb:7,Ib:8,Nb:9,PROXY:10,NOPROXY:11,Gb:12,Cb:13,Db:14,Bb:15,Eb:16,Fb:17,ib:18,hb:19,jb:20},Vi.NO_ERROR=0,Vi.TIMEOUT=8,Vi.HTTP_ERROR=6,uu=Rr.ErrorCode=Vi,dc.COMPLETE="complete",ap=Rr.EventType=dc,uc.EventType=Oi,Oi.OPEN="a",Oi.CLOSE="b",Oi.ERROR="c",Oi.MESSAGE="d",nt.prototype.listen=nt.prototype.K,Ao=Rr.WebChannel=uc,A2=Rr.FetchXmlHttpFactory=Oe,qe.prototype.listenOnce=qe.prototype.L,qe.prototype.getLastError=qe.prototype.Ka,qe.prototype.getLastErrorCode=qe.prototype.Ba,qe.prototype.getStatus=qe.prototype.Z,qe.prototype.getResponseJson=qe.prototype.Oa,qe.prototype.getResponseText=qe.prototype.oa,qe.prototype.send=qe.prototype.ea,qe.prototype.setWithCredentials=qe.prototype.Ha,op=Rr.XhrIo=qe}).apply(typeof Hl!="undefined"?Hl:typeof self!="undefined"?self:typeof window!="undefined"?window:{});var z0="@firebase/firestore",G0="4.7.8";var mt=class{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}};mt.UNAUTHENTICATED=new mt(null),mt.GOOGLE_CREDENTIALS=new mt("google-credentials-uid"),mt.FIRST_PARTY=new mt("first-party-uid"),mt.MOCK_USER=new mt("mock-user");var Jo="11.3.1";var cs=new xo("@firebase/firestore");function So(){return cs.logLevel}function X(n,...e){if(cs.logLevel<=Se.DEBUG){let t=e.map(Jm);cs.debug(`Firestore (${Jo}): ${n}`,...t)}}function Pr(n,...e){if(cs.logLevel<=Se.ERROR){let t=e.map(Jm);cs.error(`Firestore (${Jo}): ${n}`,...t)}}function No(n,...e){if(cs.logLevel<=Se.WARN){let t=e.map(Jm);cs.warn(`Firestore (${Jo}): ${n}`,...t)}}function Jm(n){if(typeof n=="string")return n;try{return function(t){return JSON.stringify(t)}(n)}catch{return n}}function ue(n="Unexpected state"){let e=`FIRESTORE (${Jo}) INTERNAL ASSERTION FAILED: `+n;throw Pr(e),new Error(e)}function Le(n,e){n||ue()}function fe(n,e){return n}var H={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"},re=class extends Er{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}};var Kn=class{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}};var nh=class{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}},mp=class{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(mt.UNAUTHENTICATED))}shutdown(){}},gp=class{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable(()=>t(this.token.user))}shutdown(){this.changeListener=null}},_p=class{constructor(e){this.t=e,this.currentUser=mt.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){Le(this.o===void 0);let r=this.i,s=f=>this.i!==r?(r=this.i,t(f)):Promise.resolve(),a=new Kn;this.o=()=>{this.i++,this.currentUser=this.u(),a.resolve(),a=new Kn,e.enqueueRetryable(()=>s(this.currentUser))};let c=()=>{let f=a;e.enqueueRetryable(async()=>{await f.promise,await s(this.currentUser)})},h=f=>{X("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=f,this.o&&(this.auth.addAuthTokenListener(this.o),c())};this.t.onInit(f=>h(f)),setTimeout(()=>{if(!this.auth){let f=this.t.getImmediate({optional:!0});f?h(f):(X("FirebaseAuthCredentialsProvider","Auth not yet detected"),a.resolve(),a=new Kn)}},0),c()}getToken(){let e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(r=>this.i!==e?(X("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):r?(Le(typeof r.accessToken=="string"),new nh(r.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){let e=this.auth&&this.auth.getUid();return Le(e===null||typeof e=="string"),new mt(e)}},yp=class{constructor(e,t,r){this.l=e,this.h=t,this.P=r,this.type="FirstParty",this.user=mt.FIRST_PARTY,this.T=new Map}I(){return this.P?this.P():null}get headers(){this.T.set("X-Goog-AuthUser",this.l);let e=this.I();return e&&this.T.set("Authorization",e),this.h&&this.T.set("X-Goog-Iam-Authorization-Token",this.h),this.T}},vp=class{constructor(e,t,r){this.l=e,this.h=t,this.P=r}getToken(){return Promise.resolve(new yp(this.l,this.h,this.P))}start(e,t){e.enqueueRetryable(()=>t(mt.FIRST_PARTY))}shutdown(){}invalidateToken(){}},rh=class{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}},wp=class{constructor(e,t){this.A=t,this.forceRefresh=!1,this.appCheck=null,this.R=null,this.V=null,M0(e)&&e.settings.appCheckToken&&(this.V=e.settings.appCheckToken)}start(e,t){Le(this.o===void 0);let r=a=>{a.error!=null&&X("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${a.error.message}`);let c=a.token!==this.R;return this.R=a.token,X("FirebaseAppCheckTokenProvider",`Received ${c?"new":"existing"} token.`),c?t(a.token):Promise.resolve()};this.o=a=>{e.enqueueRetryable(()=>r(a))};let s=a=>{X("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=a,this.o&&this.appCheck.addTokenListener(this.o)};this.A.onInit(a=>s(a)),setTimeout(()=>{if(!this.appCheck){let a=this.A.getImmediate({optional:!0});a?s(a):X("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.V)return Promise.resolve(new rh(this.V));let e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(t=>t?(Le(typeof t.token=="string"),this.R=t.token,new rh(t.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}};function S2(n){let e=typeof self!="undefined"&&(self.crypto||self.msCrypto),t=new Uint8Array(n);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let r=0;r<n;r++)t[r]=Math.floor(256*Math.random());return t}var ih=class{static newId(){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=62*Math.floor(4.129032258064516),r="";for(;r.length<20;){let s=S2(40);for(let a=0;a<s.length;++a)r.length<20&&s[a]<t&&(r+=e.charAt(s[a]%62))}return r}};function Re(n,e){return n<e?-1:n>e?1:0}function Vo(n,e,t){return n.length===e.length&&n.every((r,s)=>t(r,e[s]))}var K0=-62135596800,W0=1e6,yt=class n{static now(){return n.fromMillis(Date.now())}static fromDate(e){return n.fromMillis(e.getTime())}static fromMillis(e){let t=Math.floor(e/1e3),r=Math.floor((e-1e3*t)*W0);return new n(t,r)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new re(H.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new re(H.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<K0)throw new re(H.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new re(H.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/W0}_compareTo(e){return this.seconds===e.seconds?Re(this.nanoseconds,e.nanoseconds):Re(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){let e=this.seconds-K0;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}};var me=class n{static fromTimestamp(e){return new n(e)}static min(){return new n(new yt(0,0))}static max(){return new n(new yt(253402300799,999999999))}constructor(e){this.timestamp=e}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}};var H0="__name__",sh=class n{constructor(e,t,r){t===void 0?t=0:t>e.length&&ue(),r===void 0?r=e.length-t:r>e.length-t&&ue(),this.segments=e,this.offset=t,this.len=r}get length(){return this.len}isEqual(e){return n.comparator(this,e)===0}child(e){let t=this.segments.slice(this.offset,this.limit());return e instanceof n?e.forEach(r=>{t.push(r)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,r=this.limit();t<r;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){let r=Math.min(e.length,t.length);for(let s=0;s<r;s++){let a=n.compareSegments(e.get(s),t.get(s));if(a!==0)return a}return Math.sign(e.length-t.length)}static compareSegments(e,t){let r=n.isNumericId(e),s=n.isNumericId(t);return r&&!s?-1:!r&&s?1:r&&s?n.extractNumericId(e).compare(n.extractNumericId(t)):e<t?-1:e>t?1:0}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return Sr.fromString(e.substring(4,e.length-2))}},st=class n extends sh{construct(e,t,r){return new n(e,t,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){let t=[];for(let r of e){if(r.indexOf("//")>=0)throw new re(H.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);t.push(...r.split("/").filter(s=>s.length>0))}return new n(t)}static emptyPath(){return new n([])}},R2=/^[_a-zA-Z][_a-zA-Z0-9]*$/,en=class n extends sh{construct(e,t,r){return new n(e,t,r)}static isValidIdentifier(e){return R2.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),n.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===H0}static keyField(){return new n([H0])}static fromServerFormat(e){let t=[],r="",s=0,a=()=>{if(r.length===0)throw new re(H.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(r),r=""},c=!1;for(;s<e.length;){let h=e[s];if(h==="\\"){if(s+1===e.length)throw new re(H.INVALID_ARGUMENT,"Path has trailing escape character: "+e);let f=e[s+1];if(f!=="\\"&&f!=="."&&f!=="`")throw new re(H.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=f,s+=2}else h==="`"?(c=!c,s++):h!=="."||c?(r+=h,s++):(a(),s++)}if(a(),c)throw new re(H.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new n(t)}static emptyPath(){return new n([])}};var ce=class n{constructor(e){this.path=e}static fromPath(e){return new n(st.fromString(e))}static fromName(e){return new n(st.fromString(e).popFirst(5))}static empty(){return new n(st.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&st.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return st.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new n(new st(e.slice()))}};var pu=-1,bp=class{constructor(e,t,r,s){this.indexId=e,this.collectionGroup=t,this.fields=r,this.indexState=s}};bp.UNKNOWN_ID=-1;function P2(n,e){let t=n.toTimestamp().seconds,r=n.toTimestamp().nanoseconds+1,s=me.fromTimestamp(r===1e9?new yt(t+1,0):new yt(t,r));return new ls(s,ce.empty(),e)}function C2(n){return new ls(n.readTime,n.key,pu)}var ls=class n{constructor(e,t,r){this.readTime=e,this.documentKey=t,this.largestBatchId=r}static min(){return new n(me.min(),ce.empty(),pu)}static max(){return new n(me.max(),ce.empty(),pu)}};function D2(n,e){let t=n.readTime.compareTo(e.readTime);return t!==0?t:(t=ce.comparator(n.documentKey,e.documentKey),t!==0?t:Re(n.largestBatchId,e.largestBatchId))}var O2="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",Tp=class{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}};async function Yo(n){if(n.code!==H.FAILED_PRECONDITION||n.message!==O2)throw n;X("LocalStore","Unexpectedly lost primary lease")}var W=class n{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)},t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)})}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&ue(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new n((r,s)=>{this.nextCallback=a=>{this.wrapSuccess(e,a).next(r,s)},this.catchCallback=a=>{this.wrapFailure(t,a).next(r,s)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{let t=e();return t instanceof n?t:n.resolve(t)}catch(t){return n.reject(t)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):n.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):n.reject(t)}static resolve(e){return new n((t,r)=>{t(e)})}static reject(e){return new n((t,r)=>{r(e)})}static waitFor(e){return new n((t,r)=>{let s=0,a=0,c=!1;e.forEach(h=>{++s,h.next(()=>{++a,c&&a===s&&t()},f=>r(f))}),c=!0,a===s&&t()})}static or(e){let t=n.resolve(!1);for(let r of e)t=t.next(s=>s?n.resolve(s):r());return t}static forEach(e,t){let r=[];return e.forEach((s,a)=>{r.push(t.call(this,s,a))}),this.waitFor(r)}static mapArray(e,t){return new n((r,s)=>{let a=e.length,c=new Array(a),h=0;for(let f=0;f<a;f++){let m=f;t(e[m]).next(_=>{c[m]=_,++h,h===a&&r(c)},_=>s(_))}})}static doWhile(e,t){return new n((r,s)=>{let a=()=>{e()===!0?t().next(()=>{a()},s):r()};a()})}};function k2(n){let e=n.match(/Android ([\d.]+)/i),t=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(t)}function Xo(n){return n.name==="IndexedDbTransactionError"}var Lo=class{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=r=>this.oe(r),this._e=r=>t.writeSequenceNumber(r))}oe(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){let e=++this.previousValue;return this._e&&this._e(e),e}};Lo.ae=-1;var Ym=-1;function Bh(n){return n==null}function mu(n){return n===0&&1/n==-1/0}function N2(n){return typeof n=="number"&&Number.isInteger(n)&&!mu(n)&&n<=Number.MAX_SAFE_INTEGER&&n>=Number.MIN_SAFE_INTEGER}var Db="";function V2(n){let e="";for(let t=0;t<n.length;t++)e.length>0&&(e=Q0(e)),e=L2(n.get(t),e);return Q0(e)}function L2(n,e){let t=e,r=n.length;for(let s=0;s<r;s++){let a=n.charAt(s);switch(a){case"\0":t+="";break;case Db:t+="";break;default:t+=a}}return t}function Q0(n){return n+Db+""}var M2="remoteDocuments",Ob="owner";var kb="mutationQueues";var Nb="mutations";var Vb="documentMutations",F2="remoteDocumentsV14";var Lb="remoteDocumentGlobal";var Mb="targets";var Fb="targetDocuments";var Ub="targetGlobal",Bb="collectionParents";var jb="clientMetadata";var $b="bundles";var qb="namedQueries";var U2="indexConfiguration";var B2="indexState";var j2="indexEntries";var zb="documentOverlays";var $2="globals";var q2=[kb,Nb,Vb,M2,Mb,Ob,Ub,Fb,jb,Lb,Bb,$b,qb],cK=[...q2,zb],z2=[kb,Nb,Vb,F2,Mb,Ob,Ub,Fb,jb,Lb,Bb,$b,qb,zb],G2=z2,K2=[...G2,U2,B2,j2];var lK=[...K2,$2];function J0(n){let e=0;for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&e++;return e}function Ti(n,e){for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&e(t,n[t])}function Gb(n){for(let e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}var Je=class n{constructor(e,t){this.comparator=e,this.root=t||Wn.EMPTY}insert(e,t){return new n(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,Wn.BLACK,null,null))}remove(e){return new n(this.comparator,this.root.remove(e,this.comparator).copy(null,null,Wn.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){let r=this.comparator(e,t.key);if(r===0)return t.value;r<0?t=t.left:r>0&&(t=t.right)}return null}indexOf(e){let t=0,r=this.root;for(;!r.isEmpty();){let s=this.comparator(e,r.key);if(s===0)return t+r.left.size;s<0?r=r.left:(t+=r.left.size+1,r=r.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal((t,r)=>(e(t,r),!1))}toString(){let e=[];return this.inorderTraversal((t,r)=>(e.push(`${t}:${r}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new Do(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Do(this.root,e,this.comparator,!1)}getReverseIterator(){return new Do(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Do(this.root,e,this.comparator,!0)}},Do=class{constructor(e,t,r,s){this.isReverse=s,this.nodeStack=[];let a=1;for(;!e.isEmpty();)if(a=t?r(e.key,t):1,t&&s&&(a*=-1),a<0)e=this.isReverse?e.left:e.right;else{if(a===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop(),t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;let e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}},Wn=class n{constructor(e,t,r,s,a){this.key=e,this.value=t,this.color=r!=null?r:n.RED,this.left=s!=null?s:n.EMPTY,this.right=a!=null?a:n.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,r,s,a){return new n(e!=null?e:this.key,t!=null?t:this.value,r!=null?r:this.color,s!=null?s:this.left,a!=null?a:this.right)}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,r){let s=this,a=r(e,s.key);return s=a<0?s.copy(null,null,null,s.left.insert(e,t,r),null):a===0?s.copy(null,t,null,null,null):s.copy(null,null,null,null,s.right.insert(e,t,r)),s.fixUp()}removeMin(){if(this.left.isEmpty())return n.EMPTY;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 r,s=this;if(t(e,s.key)<0)s.left.isEmpty()||s.left.isRed()||s.left.left.isRed()||(s=s.moveRedLeft()),s=s.copy(null,null,null,s.left.remove(e,t),null);else{if(s.left.isRed()&&(s=s.rotateRight()),s.right.isEmpty()||s.right.isRed()||s.right.left.isRed()||(s=s.moveRedRight()),t(e,s.key)===0){if(s.right.isEmpty())return n.EMPTY;r=s.right.min(),s=s.copy(r.key,r.value,null,null,s.right.removeMin())}s=s.copy(null,null,null,null,s.right.remove(e,t))}return s.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){let e=this.copy(null,null,n.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){let e=this.copy(null,null,n.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){let e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){let e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed()||this.right.isRed())throw ue();let e=this.left.check();if(e!==this.right.check())throw ue();return e+(this.isRed()?0:1)}};Wn.EMPTY=null,Wn.RED=!0,Wn.BLACK=!1;Wn.EMPTY=new class{constructor(){this.size=0}get key(){throw ue()}get value(){throw ue()}get color(){throw ue()}get left(){throw ue()}get right(){throw ue()}copy(e,t,r,s,a){return this}insert(e,t,r){return new Wn(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};var gt=class n{constructor(e){this.comparator=e,this.data=new Je(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((t,r)=>(e(t),!1))}forEachInRange(e,t){let r=this.data.getIteratorFrom(e[0]);for(;r.hasNext();){let s=r.getNext();if(this.comparator(s.key,e[1])>=0)return;t(s.key)}}forEachWhile(e,t){let r;for(r=t!==void 0?this.data.getIteratorFrom(t):this.data.getIterator();r.hasNext();)if(!e(r.getNext().key))return}firstAfterOrEqual(e){let t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new oh(this.data.getIterator())}getIteratorFrom(e){return new oh(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach(r=>{t=t.add(r)}),t}isEqual(e){if(!(e instanceof n)||this.size!==e.size)return!1;let t=this.data.getIterator(),r=e.data.getIterator();for(;t.hasNext();){let s=t.getNext().key,a=r.getNext().key;if(this.comparator(s,a)!==0)return!1}return!0}toArray(){let e=[];return this.forEach(t=>{e.push(t)}),e}toString(){let e=[];return this.forEach(t=>e.push(t)),"SortedSet("+e.toString()+")"}copy(e){let t=new n(this.comparator);return t.data=e,t}},oh=class{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}};var hn=class n{constructor(e){this.fields=e,e.sort(en.comparator)}static empty(){return new n([])}unionWith(e){let t=new gt(en.comparator);for(let r of this.fields)t=t.add(r);for(let r of e)t=t.add(r);return new n(t.toArray())}covers(e){for(let t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return Vo(this.fields,e.fields,(t,r)=>t.isEqual(r))}};var ah=class extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}};var At=class n{constructor(e){this.binaryString=e}static fromBase64String(e){let t=function(s){try{return atob(s)}catch(a){throw typeof DOMException!="undefined"&&a instanceof DOMException?new ah("Invalid base64 string: "+a):a}}(e);return new n(t)}static fromUint8Array(e){let t=function(s){let a="";for(let c=0;c<s.length;++c)a+=String.fromCharCode(s[c]);return a}(e);return new n(t)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return function(t){return btoa(t)}(this.binaryString)}toUint8Array(){return function(t){let r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return Re(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}};At.EMPTY_BYTE_STRING=new At("");var W2=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Cr(n){if(Le(!!n),typeof n=="string"){let e=0,t=W2.exec(n);if(Le(!!t),t[1]){let s=t[1];s=(s+"000000000").substr(0,9),e=Number(s)}let r=new Date(n);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}return{seconds:ze(n.seconds),nanos:ze(n.nanos)}}function ze(n){return typeof n=="number"?n:typeof n=="string"?Number(n):0}function Dr(n){return typeof n=="string"?At.fromBase64String(n):At.fromUint8Array(n)}var Kb="server_timestamp",Wb="__type__",Hb="__previous_value__",Qb="__local_write_time__";function Xm(n){var e,t;return((t=(((e=n==null?void 0:n.mapValue)===null||e===void 0?void 0:e.fields)||{})[Wb])===null||t===void 0?void 0:t.stringValue)===Kb}function jh(n){let e=n.mapValue.fields[Hb];return Xm(e)?jh(e):e}function gu(n){let e=Cr(n.mapValue.fields[Qb].timestampValue);return new yt(e.seconds,e.nanos)}var Ep=class{constructor(e,t,r,s,a,c,h,f,m){this.databaseId=e,this.appId=t,this.persistenceKey=r,this.host=s,this.ssl=a,this.forceLongPolling=c,this.autoDetectLongPolling=h,this.longPollingOptions=f,this.useFetchStreams=m}},uh="(default)",ch=class n{constructor(e,t){this.projectId=e,this.database=t||uh}static empty(){return new n("","")}get isDefaultDatabase(){return this.database===uh}isEqual(e){return e instanceof n&&e.projectId===this.projectId&&e.database===this.database}};var Zm="__type__",Jb="__max__",Jl={mapValue:{fields:{__type__:{stringValue:Jb}}}},eg="__vector__",Mo="value";function yi(n){return"nullValue"in n?0:"booleanValue"in n?1:"integerValue"in n||"doubleValue"in n?2:"timestampValue"in n?3:"stringValue"in n?5:"bytesValue"in n?6:"referenceValue"in n?7:"geoPointValue"in n?8:"arrayValue"in n?9:"mapValue"in n?Xm(n)?4:Xb(n)?9007199254740991:Yb(n)?10:11:ue()}function Yn(n,e){if(n===e)return!0;let t=yi(n);if(t!==yi(e))return!1;switch(t){case 0:case 9007199254740991:return!0;case 1:return n.booleanValue===e.booleanValue;case 4:return gu(n).isEqual(gu(e));case 3:return function(s,a){if(typeof s.timestampValue=="string"&&typeof a.timestampValue=="string"&&s.timestampValue.length===a.timestampValue.length)return s.timestampValue===a.timestampValue;let c=Cr(s.timestampValue),h=Cr(a.timestampValue);return c.seconds===h.seconds&&c.nanos===h.nanos}(n,e);case 5:return n.stringValue===e.stringValue;case 6:return function(s,a){return Dr(s.bytesValue).isEqual(Dr(a.bytesValue))}(n,e);case 7:return n.referenceValue===e.referenceValue;case 8:return function(s,a){return ze(s.geoPointValue.latitude)===ze(a.geoPointValue.latitude)&&ze(s.geoPointValue.longitude)===ze(a.geoPointValue.longitude)}(n,e);case 2:return function(s,a){if("integerValue"in s&&"integerValue"in a)return ze(s.integerValue)===ze(a.integerValue);if("doubleValue"in s&&"doubleValue"in a){let c=ze(s.doubleValue),h=ze(a.doubleValue);return c===h?mu(c)===mu(h):isNaN(c)&&isNaN(h)}return!1}(n,e);case 9:return Vo(n.arrayValue.values||[],e.arrayValue.values||[],Yn);case 10:case 11:return function(s,a){let c=s.mapValue.fields||{},h=a.mapValue.fields||{};if(J0(c)!==J0(h))return!1;for(let f in c)if(c.hasOwnProperty(f)&&(h[f]===void 0||!Yn(c[f],h[f])))return!1;return!0}(n,e);default:return ue()}}function _u(n,e){return(n.values||[]).find(t=>Yn(t,e))!==void 0}function Fo(n,e){if(n===e)return 0;let t=yi(n),r=yi(e);if(t!==r)return Re(t,r);switch(t){case 0:case 9007199254740991:return 0;case 1:return Re(n.booleanValue,e.booleanValue);case 2:return function(a,c){let h=ze(a.integerValue||a.doubleValue),f=ze(c.integerValue||c.doubleValue);return h<f?-1:h>f?1:h===f?0:isNaN(h)?isNaN(f)?0:-1:1}(n,e);case 3:return Y0(n.timestampValue,e.timestampValue);case 4:return Y0(gu(n),gu(e));case 5:return Re(n.stringValue,e.stringValue);case 6:return function(a,c){let h=Dr(a),f=Dr(c);return h.compareTo(f)}(n.bytesValue,e.bytesValue);case 7:return function(a,c){let h=a.split("/"),f=c.split("/");for(let m=0;m<h.length&&m<f.length;m++){let _=Re(h[m],f[m]);if(_!==0)return _}return Re(h.length,f.length)}(n.referenceValue,e.referenceValue);case 8:return function(a,c){let h=Re(ze(a.latitude),ze(c.latitude));return h!==0?h:Re(ze(a.longitude),ze(c.longitude))}(n.geoPointValue,e.geoPointValue);case 9:return X0(n.arrayValue,e.arrayValue);case 10:return function(a,c){var h,f,m,_;let E=a.fields||{},I=c.fields||{},k=(h=E[Mo])===null||h===void 0?void 0:h.arrayValue,B=(f=I[Mo])===null||f===void 0?void 0:f.arrayValue,G=Re(((m=k==null?void 0:k.values)===null||m===void 0?void 0:m.length)||0,((_=B==null?void 0:B.values)===null||_===void 0?void 0:_.length)||0);return G!==0?G:X0(k,B)}(n.mapValue,e.mapValue);case 11:return function(a,c){if(a===Jl.mapValue&&c===Jl.mapValue)return 0;if(a===Jl.mapValue)return 1;if(c===Jl.mapValue)return-1;let h=a.fields||{},f=Object.keys(h),m=c.fields||{},_=Object.keys(m);f.sort(),_.sort();for(let E=0;E<f.length&&E<_.length;++E){let I=Re(f[E],_[E]);if(I!==0)return I;let k=Fo(h[f[E]],m[_[E]]);if(k!==0)return k}return Re(f.length,_.length)}(n.mapValue,e.mapValue);default:throw ue()}}function Y0(n,e){if(typeof n=="string"&&typeof e=="string"&&n.length===e.length)return Re(n,e);let t=Cr(n),r=Cr(e),s=Re(t.seconds,r.seconds);return s!==0?s:Re(t.nanos,r.nanos)}function X0(n,e){let t=n.values||[],r=e.values||[];for(let s=0;s<t.length&&s<r.length;++s){let a=Fo(t[s],r[s]);if(a)return a}return Re(t.length,r.length)}function Uo(n){return Ip(n)}function Ip(n){return"nullValue"in n?"null":"booleanValue"in n?""+n.booleanValue:"integerValue"in n?""+n.integerValue:"doubleValue"in n?""+n.doubleValue:"timestampValue"in n?function(t){let r=Cr(t);return`time(${r.seconds},${r.nanos})`}(n.timestampValue):"stringValue"in n?n.stringValue:"bytesValue"in n?function(t){return Dr(t).toBase64()}(n.bytesValue):"referenceValue"in n?function(t){return ce.fromName(t).toString()}(n.referenceValue):"geoPointValue"in n?function(t){return`geo(${t.latitude},${t.longitude})`}(n.geoPointValue):"arrayValue"in n?function(t){let r="[",s=!0;for(let a of t.values||[])s?s=!1:r+=",",r+=Ip(a);return r+"]"}(n.arrayValue):"mapValue"in n?function(t){let r=Object.keys(t.fields||{}).sort(),s="{",a=!0;for(let c of r)a?a=!1:s+=",",s+=`${c}:${Ip(t.fields[c])}`;return s+"}"}(n.mapValue):ue()}function Zl(n){switch(yi(n)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:let e=jh(n);return e?16+Zl(e):16;case 5:return 2*n.stringValue.length;case 6:return Dr(n.bytesValue).approximateByteSize();case 7:return n.referenceValue.length;case 9:return function(r){return(r.values||[]).reduce((s,a)=>s+Zl(a),0)}(n.arrayValue);case 10:case 11:return function(r){let s=0;return Ti(r.fields,(a,c)=>{s+=a.length+Zl(c)}),s}(n.mapValue);default:throw ue()}}function xp(n){return!!n&&"integerValue"in n}function tg(n){return!!n&&"arrayValue"in n}function Z0(n){return!!n&&"nullValue"in n}function eb(n){return!!n&&"doubleValue"in n&&isNaN(Number(n.doubleValue))}function eh(n){return!!n&&"mapValue"in n}function Yb(n){var e,t;return((t=(((e=n==null?void 0:n.mapValue)===null||e===void 0?void 0:e.fields)||{})[Zm])===null||t===void 0?void 0:t.stringValue)===eg}function lu(n){if(n.geoPointValue)return{geoPointValue:Object.assign({},n.geoPointValue)};if(n.timestampValue&&typeof n.timestampValue=="object")return{timestampValue:Object.assign({},n.timestampValue)};if(n.mapValue){let e={mapValue:{fields:{}}};return Ti(n.mapValue.fields,(t,r)=>e.mapValue.fields[t]=lu(r)),e}if(n.arrayValue){let e={arrayValue:{values:[]}};for(let t=0;t<(n.arrayValue.values||[]).length;++t)e.arrayValue.values[t]=lu(n.arrayValue.values[t]);return e}return Object.assign({},n)}function Xb(n){return(((n.mapValue||{}).fields||{}).__type__||{}).stringValue===Jb}var fK={mapValue:{fields:{[Zm]:{stringValue:eg},[Mo]:{arrayValue:{}}}}};var Zt=class n{constructor(e){this.value=e}static empty(){return new n({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let r=0;r<e.length-1;++r)if(t=(t.mapValue.fields||{})[e.get(r)],!eh(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=lu(t)}setAll(e){let t=en.emptyPath(),r={},s=[];e.forEach((c,h)=>{if(!t.isImmediateParentOf(h)){let f=this.getFieldsMap(t);this.applyChanges(f,r,s),r={},s=[],t=h.popLast()}c?r[h.lastSegment()]=lu(c):s.push(h.lastSegment())});let a=this.getFieldsMap(t);this.applyChanges(a,r,s)}delete(e){let t=this.field(e.popLast());eh(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return Yn(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let r=0;r<e.length;++r){let s=t.mapValue.fields[e.get(r)];eh(s)&&s.mapValue.fields||(s={mapValue:{fields:{}}},t.mapValue.fields[e.get(r)]=s),t=s}return t.mapValue.fields}applyChanges(e,t,r){Ti(t,(s,a)=>e[s]=a);for(let s of r)delete e[s]}clone(){return new n(lu(this.value))}};function Zb(n){let e=[];return Ti(n.fields,(t,r)=>{let s=new en([t]);if(eh(r)){let a=Zb(r.mapValue).fields;if(a.length===0)e.push(s);else for(let c of a)e.push(s.child(c))}else e.push(s)}),new hn(e)}var Rn=class n{constructor(e,t,r,s,a,c,h){this.key=e,this.documentType=t,this.version=r,this.readTime=s,this.createTime=a,this.data=c,this.documentState=h}static newInvalidDocument(e){return new n(e,0,me.min(),me.min(),me.min(),Zt.empty(),0)}static newFoundDocument(e,t,r,s){return new n(e,1,t,me.min(),r,s,0)}static newNoDocument(e,t){return new n(e,2,t,me.min(),me.min(),Zt.empty(),0)}static newUnknownDocument(e,t){return new n(e,3,t,me.min(),me.min(),Zt.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(me.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=Zt.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Zt.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=me.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(e){return e instanceof n&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new n(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}};var Bo=class{constructor(e,t){this.position=e,this.inclusive=t}};function tb(n,e,t){let r=0;for(let s=0;s<n.position.length;s++){let a=e[s],c=n.position[s];if(a.field.isKeyField()?r=ce.comparator(ce.fromName(c.referenceValue),t.key):r=Fo(c,t.data.field(a.field)),a.dir==="desc"&&(r*=-1),r!==0)break}return r}function nb(n,e){if(n===null)return e===null;if(e===null||n.inclusive!==e.inclusive||n.position.length!==e.position.length)return!1;for(let t=0;t<n.position.length;t++)if(!Yn(n.position[t],e.position[t]))return!1;return!0}var jo=class{constructor(e,t="asc"){this.field=e,this.dir=t}};function H2(n,e){return n.dir===e.dir&&n.field.isEqual(e.field)}var lh=class{},dt=class n extends lh{constructor(e,t,r){super(),this.field=e,this.op=t,this.value=r}static create(e,t,r){return e.isKeyField()?t==="in"||t==="not-in"?this.createKeyFieldInFilter(e,t,r):new Sp(e,t,r):t==="array-contains"?new Cp(e,r):t==="in"?new Dp(e,r):t==="not-in"?new Op(e,r):t==="array-contains-any"?new kp(e,r):new n(e,t,r)}static createKeyFieldInFilter(e,t,r){return t==="in"?new Rp(e,r):new Pp(e,r)}matches(e){let t=e.data.field(this.field);return this.op==="!="?t!==null&&this.matchesComparison(Fo(t,this.value)):t!==null&&yi(this.value)===yi(t)&&this.matchesComparison(Fo(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return ue()}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}},Xn=class n extends lh{constructor(e,t){super(),this.filters=e,this.op=t,this.ce=null}static create(e,t){return new n(e,t)}matches(e){return eT(this)?this.filters.find(t=>!t.matches(e))===void 0:this.filters.find(t=>t.matches(e))!==void 0}getFlattenedFilters(){return this.ce!==null||(this.ce=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.ce}getFilters(){return Object.assign([],this.filters)}};function eT(n){return n.op==="and"}function tT(n){return Q2(n)&&eT(n)}function Q2(n){for(let e of n.filters)if(e instanceof Xn)return!1;return!0}function Ap(n){if(n instanceof dt)return n.field.canonicalString()+n.op.toString()+Uo(n.value);if(tT(n))return n.filters.map(e=>Ap(e)).join(",");{let e=n.filters.map(t=>Ap(t)).join(",");return`${n.op}(${e})`}}function nT(n,e){return n instanceof dt?function(r,s){return s instanceof dt&&r.op===s.op&&r.field.isEqual(s.field)&&Yn(r.value,s.value)}(n,e):n instanceof Xn?function(r,s){return s instanceof Xn&&r.op===s.op&&r.filters.length===s.filters.length?r.filters.reduce((a,c,h)=>a&&nT(c,s.filters[h]),!0):!1}(n,e):void ue()}function rT(n){return n instanceof dt?function(t){return`${t.field.canonicalString()} ${t.op} ${Uo(t.value)}`}(n):n instanceof Xn?function(t){return t.op.toString()+" {"+t.getFilters().map(rT).join(" ,")+"}"}(n):"Filter"}var Sp=class extends dt{constructor(e,t,r){super(e,t,r),this.key=ce.fromName(r.referenceValue)}matches(e){let t=ce.comparator(e.key,this.key);return this.matchesComparison(t)}},Rp=class extends dt{constructor(e,t){super(e,"in",t),this.keys=iT("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}},Pp=class extends dt{constructor(e,t){super(e,"not-in",t),this.keys=iT("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}};function iT(n,e){var t;return(((t=e.arrayValue)===null||t===void 0?void 0:t.values)||[]).map(r=>ce.fromName(r.referenceValue))}var Cp=class extends dt{constructor(e,t){super(e,"array-contains",t)}matches(e){let t=e.data.field(this.field);return tg(t)&&_u(t.arrayValue,this.value)}},Dp=class extends dt{constructor(e,t){super(e,"in",t)}matches(e){let t=e.data.field(this.field);return t!==null&&_u(this.value.arrayValue,t)}},Op=class extends dt{constructor(e,t){super(e,"not-in",t)}matches(e){if(_u(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;let t=e.data.field(this.field);return t!==null&&!_u(this.value.arrayValue,t)}},kp=class extends dt{constructor(e,t){super(e,"array-contains-any",t)}matches(e){let t=e.data.field(this.field);return!(!tg(t)||!t.arrayValue.values)&&t.arrayValue.values.some(r=>_u(this.value.arrayValue,r))}};var Np=class{constructor(e,t=null,r=[],s=[],a=null,c=null,h=null){this.path=e,this.collectionGroup=t,this.orderBy=r,this.filters=s,this.limit=a,this.startAt=c,this.endAt=h,this.le=null}};function rb(n,e=null,t=[],r=[],s=null,a=null,c=null){return new Np(n,e,t,r,s,a,c)}function ng(n){let e=fe(n);if(e.le===null){let t=e.path.canonicalString();e.collectionGroup!==null&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map(r=>Ap(r)).join(","),t+="|ob:",t+=e.orderBy.map(r=>function(a){return a.field.canonicalString()+a.dir}(r)).join(","),Bh(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(r=>Uo(r)).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(r=>Uo(r)).join(",")),e.le=t}return e.le}function rg(n,e){if(n.limit!==e.limit||n.orderBy.length!==e.orderBy.length)return!1;for(let t=0;t<n.orderBy.length;t++)if(!H2(n.orderBy[t],e.orderBy[t]))return!1;if(n.filters.length!==e.filters.length)return!1;for(let t=0;t<n.filters.length;t++)if(!nT(n.filters[t],e.filters[t]))return!1;return n.collectionGroup===e.collectionGroup&&!!n.path.isEqual(e.path)&&!!nb(n.startAt,e.startAt)&&nb(n.endAt,e.endAt)}function Vp(n){return ce.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}var $o=class{constructor(e,t=null,r=[],s=[],a=null,c="F",h=null,f=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=r,this.filters=s,this.limit=a,this.limitType=c,this.startAt=h,this.endAt=f,this.he=null,this.Pe=null,this.Te=null,this.startAt,this.endAt}};function J2(n,e,t,r,s,a,c,h){return new $o(n,e,t,r,s,a,c,h)}function $h(n){return new $o(n)}function ib(n){return n.filters.length===0&&n.limit===null&&n.startAt==null&&n.endAt==null&&(n.explicitOrderBy.length===0||n.explicitOrderBy.length===1&&n.explicitOrderBy[0].field.isKeyField())}function Y2(n){return n.collectionGroup!==null}function hu(n){let e=fe(n);if(e.he===null){e.he=[];let t=new Set;for(let a of e.explicitOrderBy)e.he.push(a),t.add(a.field.canonicalString());let r=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(c){let h=new gt(en.comparator);return c.filters.forEach(f=>{f.getFlattenedFilters().forEach(m=>{m.isInequality()&&(h=h.add(m.field))})}),h})(e).forEach(a=>{t.has(a.canonicalString())||a.isKeyField()||e.he.push(new jo(a,r))}),t.has(en.keyField().canonicalString())||e.he.push(new jo(en.keyField(),r))}return e.he}function Hn(n){let e=fe(n);return e.Pe||(e.Pe=X2(e,hu(n))),e.Pe}function X2(n,e){if(n.limitType==="F")return rb(n.path,n.collectionGroup,e,n.filters,n.limit,n.startAt,n.endAt);{e=e.map(s=>{let a=s.dir==="desc"?"asc":"desc";return new jo(s.field,a)});let t=n.endAt?new Bo(n.endAt.position,n.endAt.inclusive):null,r=n.startAt?new Bo(n.startAt.position,n.startAt.inclusive):null;return rb(n.path,n.collectionGroup,e,n.filters,n.limit,t,r)}}function Lp(n,e,t){return new $o(n.path,n.collectionGroup,n.explicitOrderBy.slice(),n.filters.slice(),e,t,n.startAt,n.endAt)}function qh(n,e){return rg(Hn(n),Hn(e))&&n.limitType===e.limitType}function sT(n){return`${ng(Hn(n))}|lt:${n.limitType}`}function Ro(n){return`Query(target=${function(t){let r=t.path.canonicalString();return t.collectionGroup!==null&&(r+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(r+=`, filters: [${t.filters.map(s=>rT(s)).join(", ")}]`),Bh(t.limit)||(r+=", limit: "+t.limit),t.orderBy.length>0&&(r+=`, orderBy: [${t.orderBy.map(s=>function(c){return`${c.field.canonicalString()} (${c.dir})`}(s)).join(", ")}]`),t.startAt&&(r+=", startAt: ",r+=t.startAt.inclusive?"b:":"a:",r+=t.startAt.position.map(s=>Uo(s)).join(",")),t.endAt&&(r+=", endAt: ",r+=t.endAt.inclusive?"a:":"b:",r+=t.endAt.position.map(s=>Uo(s)).join(",")),`Target(${r})`}(Hn(n))}; limitType=${n.limitType})`}function zh(n,e){return e.isFoundDocument()&&function(r,s){let a=s.key.path;return r.collectionGroup!==null?s.key.hasCollectionId(r.collectionGroup)&&r.path.isPrefixOf(a):ce.isDocumentKey(r.path)?r.path.isEqual(a):r.path.isImmediateParentOf(a)}(n,e)&&function(r,s){for(let a of hu(r))if(!a.field.isKeyField()&&s.data.field(a.field)===null)return!1;return!0}(n,e)&&function(r,s){for(let a of r.filters)if(!a.matches(s))return!1;return!0}(n,e)&&function(r,s){return!(r.startAt&&!function(c,h,f){let m=tb(c,h,f);return c.inclusive?m<=0:m<0}(r.startAt,hu(r),s)||r.endAt&&!function(c,h,f){let m=tb(c,h,f);return c.inclusive?m>=0:m>0}(r.endAt,hu(r),s))}(n,e)}function Z2(n){return n.collectionGroup||(n.path.length%2==1?n.path.lastSegment():n.path.get(n.path.length-2))}function oT(n){return(e,t)=>{let r=!1;for(let s of hu(n)){let a=eM(s,e,t);if(a!==0)return a;r=r||s.field.isKeyField()}return 0}}function eM(n,e,t){let r=n.field.isKeyField()?ce.comparator(e.key,t.key):function(a,c,h){let f=c.data.field(a),m=h.data.field(a);return f!==null&&m!==null?Fo(f,m):ue()}(n.field,e,t);switch(n.dir){case"asc":return r;case"desc":return-1*r;default:return ue()}}var Or=class{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){let t=this.mapKeyFn(e),r=this.inner[t];if(r!==void 0){for(let[s,a]of r)if(this.equalsFn(s,e))return a}}has(e){return this.get(e)!==void 0}set(e,t){let r=this.mapKeyFn(e),s=this.inner[r];if(s===void 0)return this.inner[r]=[[e,t]],void this.innerSize++;for(let a=0;a<s.length;a++)if(this.equalsFn(s[a][0],e))return void(s[a]=[e,t]);s.push([e,t]),this.innerSize++}delete(e){let t=this.mapKeyFn(e),r=this.inner[t];if(r===void 0)return!1;for(let s=0;s<r.length;s++)if(this.equalsFn(r[s][0],e))return r.length===1?delete this.inner[t]:r.splice(s,1),this.innerSize--,!0;return!1}forEach(e){Ti(this.inner,(t,r)=>{for(let[s,a]of r)e(s,a)})}isEmpty(){return Gb(this.inner)}size(){return this.innerSize}};var tM=new Je(ce.comparator);function kr(){return tM}var aT=new Je(ce.comparator);function cu(...n){let e=aT;for(let t of n)e=e.insert(t.key,t);return e}function uT(n){let e=aT;return n.forEach((t,r)=>e=e.insert(t,r.overlayedDocument)),e}function os(){return fu()}function cT(){return fu()}function fu(){return new Or(n=>n.toString(),(n,e)=>n.isEqual(e))}var nM=new Je(ce.comparator),rM=new gt(ce.comparator);function xe(...n){let e=rM;for(let t of n)e=e.add(t);return e}var iM=new gt(Re);function sM(){return iM}function ig(n,e){if(n.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:mu(e)?"-0":e}}function lT(n){return{integerValue:""+n}}function oM(n,e){return N2(e)?lT(e):ig(n,e)}var qo=class{constructor(){this._=void 0}};function aM(n,e,t){return n instanceof zo?function(s,a){let c={fields:{[Wb]:{stringValue:Kb},[Qb]:{timestampValue:{seconds:s.seconds,nanos:s.nanoseconds}}}};return a&&Xm(a)&&(a=jh(a)),a&&(c.fields[Hb]=a),{mapValue:c}}(t,e):n instanceof hs?fT(n,e):n instanceof fs?dT(n,e):function(s,a){let c=hT(s,a),h=sb(c)+sb(s.Ie);return xp(c)&&xp(s.Ie)?lT(h):ig(s.serializer,h)}(n,e)}function uM(n,e,t){return n instanceof hs?fT(n,e):n instanceof fs?dT(n,e):t}function hT(n,e){return n instanceof Go?function(r){return xp(r)||function(a){return!!a&&"doubleValue"in a}(r)}(e)?e:{integerValue:0}:null}var zo=class extends qo{},hs=class extends qo{constructor(e){super(),this.elements=e}};function fT(n,e){let t=pT(e);for(let r of n.elements)t.some(s=>Yn(s,r))||t.push(r);return{arrayValue:{values:t}}}var fs=class extends qo{constructor(e){super(),this.elements=e}};function dT(n,e){let t=pT(e);for(let r of n.elements)t=t.filter(s=>!Yn(s,r));return{arrayValue:{values:t}}}var Go=class extends qo{constructor(e,t){super(),this.serializer=e,this.Ie=t}};function sb(n){return ze(n.integerValue||n.doubleValue)}function pT(n){return tg(n)&&n.arrayValue.values?n.arrayValue.values.slice():[]}function cM(n,e){return n.field.isEqual(e.field)&&function(r,s){return r instanceof hs&&s instanceof hs||r instanceof fs&&s instanceof fs?Vo(r.elements,s.elements,Yn):r instanceof Go&&s instanceof Go?Yn(r.Ie,s.Ie):r instanceof zo&&s instanceof zo}(n.transform,e.transform)}var Mp=class{constructor(e,t){this.version=e,this.transformResults=t}},_i=class n{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new n}static exists(e){return new n(void 0,e)}static updateTime(e){return new n(e)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}};function th(n,e){return n.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(n.updateTime):n.exists===void 0||n.exists===e.isFoundDocument()}var Ko=class{};function mT(n,e){if(!n.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return n.isNoDocument()?new hh(n.key,_i.none()):new ds(n.key,n.data,_i.none());{let t=n.data,r=Zt.empty(),s=new gt(en.comparator);for(let a of e.fields)if(!s.has(a)){let c=t.field(a);c===null&&a.length>1&&(a=a.popLast(),c=t.field(a)),c===null?r.delete(a):r.set(a,c),s=s.add(a)}return new Zn(n.key,r,new hn(s.toArray()),_i.none())}}function lM(n,e,t){n instanceof ds?function(s,a,c){let h=s.value.clone(),f=ab(s.fieldTransforms,a,c.transformResults);h.setAll(f),a.convertToFoundDocument(c.version,h).setHasCommittedMutations()}(n,e,t):n instanceof Zn?function(s,a,c){if(!th(s.precondition,a))return void a.convertToUnknownDocument(c.version);let h=ab(s.fieldTransforms,a,c.transformResults),f=a.data;f.setAll(gT(s)),f.setAll(h),a.convertToFoundDocument(c.version,f).setHasCommittedMutations()}(n,e,t):function(s,a,c){a.convertToNoDocument(c.version).setHasCommittedMutations()}(0,e,t)}function du(n,e,t,r){return n instanceof ds?function(a,c,h,f){if(!th(a.precondition,c))return h;let m=a.value.clone(),_=ub(a.fieldTransforms,f,c);return m.setAll(_),c.convertToFoundDocument(c.version,m).setHasLocalMutations(),null}(n,e,t,r):n instanceof Zn?function(a,c,h,f){if(!th(a.precondition,c))return h;let m=ub(a.fieldTransforms,f,c),_=c.data;return _.setAll(gT(a)),_.setAll(m),c.convertToFoundDocument(c.version,_).setHasLocalMutations(),h===null?null:h.unionWith(a.fieldMask.fields).unionWith(a.fieldTransforms.map(E=>E.field))}(n,e,t,r):function(a,c,h){return th(a.precondition,c)?(c.convertToNoDocument(c.version).setHasLocalMutations(),null):h}(n,e,t)}function hM(n,e){let t=null;for(let r of n.fieldTransforms){let s=e.data.field(r.field),a=hT(r.transform,s||null);a!=null&&(t===null&&(t=Zt.empty()),t.set(r.field,a))}return t||null}function ob(n,e){return n.type===e.type&&!!n.key.isEqual(e.key)&&!!n.precondition.isEqual(e.precondition)&&!!function(r,s){return r===void 0&&s===void 0||!(!r||!s)&&Vo(r,s,(a,c)=>cM(a,c))}(n.fieldTransforms,e.fieldTransforms)&&(n.type===0?n.value.isEqual(e.value):n.type!==1||n.data.isEqual(e.data)&&n.fieldMask.isEqual(e.fieldMask))}var ds=class extends Ko{constructor(e,t,r,s=[]){super(),this.key=e,this.value=t,this.precondition=r,this.fieldTransforms=s,this.type=0}getFieldMask(){return null}},Zn=class extends Ko{constructor(e,t,r,s,a=[]){super(),this.key=e,this.data=t,this.fieldMask=r,this.precondition=s,this.fieldTransforms=a,this.type=1}getFieldMask(){return this.fieldMask}};function gT(n){let e=new Map;return n.fieldMask.fields.forEach(t=>{if(!t.isEmpty()){let r=n.data.field(t);e.set(t,r)}}),e}function ab(n,e,t){let r=new Map;Le(n.length===t.length);for(let s=0;s<t.length;s++){let a=n[s],c=a.transform,h=e.data.field(a.field);r.set(a.field,uM(c,h,t[s]))}return r}function ub(n,e,t){let r=new Map;for(let s of n){let a=s.transform,c=t.data.field(s.field);r.set(s.field,aM(a,c,e))}return r}var hh=class extends Ko{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}},Fp=class extends Ko{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}};var Up=class{constructor(e,t,r,s){this.batchId=e,this.localWriteTime=t,this.baseMutations=r,this.mutations=s}applyToRemoteDocument(e,t){let r=t.mutationResults;for(let s=0;s<this.mutations.length;s++){let a=this.mutations[s];a.key.isEqual(e.key)&&lM(a,e,r[s])}}applyToLocalView(e,t){for(let r of this.baseMutations)r.key.isEqual(e.key)&&(t=du(r,e,t,this.localWriteTime));for(let r of this.mutations)r.key.isEqual(e.key)&&(t=du(r,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){let r=cT();return this.mutations.forEach(s=>{let a=e.get(s.key),c=a.overlayedDocument,h=this.applyToLocalView(c,a.mutatedFields);h=t.has(s.key)?null:h;let f=mT(c,h);f!==null&&r.set(s.key,f),c.isValidDocument()||c.convertToNoDocument(me.min())}),r}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),xe())}isEqual(e){return this.batchId===e.batchId&&Vo(this.mutations,e.mutations,(t,r)=>ob(t,r))&&Vo(this.baseMutations,e.baseMutations,(t,r)=>ob(t,r))}},Bp=class n{constructor(e,t,r,s){this.batch=e,this.commitVersion=t,this.mutationResults=r,this.docVersions=s}static from(e,t,r){Le(e.mutations.length===r.length);let s=function(){return nM}(),a=e.mutations;for(let c=0;c<a.length;c++)s=s.insert(a[c].key,r[c].version);return new n(e,t,r,s)}};var jp=class{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{
24
+ `+F+" "+Q})}function Un(u,d,g,b){u.info(function(){return"XMLHTTP TEXT ("+d+"): "+Af(u,g)+(b?" "+b:"")})}function xf(u,d){u.info(function(){return"TIMEOUT: "+d})}Ni.prototype.info=function(){};function Af(u,d){if(!u.g)return d;if(!d)return null;try{var g=JSON.parse(d);if(g){for(u=0;u<g.length;u++)if(Array.isArray(g[u])){var b=g[u];if(!(2>b.length)){var L=b[1];if(Array.isArray(L)&&!(1>L.length)){var F=L[0];if(F!="noop"&&F!="stop"&&F!="close")for(var Q=1;Q<L.length;Q++)L[Q]=""}}}}return ya(g)}catch{return d}}var Vi={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},mc={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"},Ta;function Fs(){}B(Fs,Ls),Fs.prototype.g=function(){return new XMLHttpRequest},Fs.prototype.i=function(){return{}},Ta=new Fs;function Nr(u,d,g,b){this.j=u,this.i=d,this.l=g,this.R=b||1,this.U=new on(this),this.I=45e3,this.H=null,this.o=!1,this.m=this.A=this.v=this.L=this.F=this.S=this.B=null,this.D=[],this.g=null,this.C=0,this.s=this.u=null,this.X=-1,this.J=!1,this.O=0,this.M=null,this.W=this.K=this.T=this.P=!1,this.h=new gc}function gc(){this.i=null,this.g="",this.h=!1}var _c={},Bn={};function Ea(u,d,g){u.L=1,u.v=Ui(gr(d)),u.m=g,u.P=!0,Li(u,null)}function Li(u,d){u.F=Date.now(),Us(u),u.A=gr(u.v);var g=u.A,b=u.R;Array.isArray(b)||(b=[String(b)]),Pc(g.i,"t",b),u.C=0,g=u.j.J,u.h=new gc,u.g=Va(u.j,g?d:null,!u.m),0<u.O&&(u.M=new _a(I(u.Y,u,u.g),u.O)),d=u.U,g=u.g,b=u.ca;var L="readystatechange";Array.isArray(L)||(L&&(Ns[0]=L.toString()),L=Ns);for(var F=0;F<L.length;F++){var Q=ma(g,L[F],b||d.handleEvent,!1,d.h||d);if(!Q)break;d.g[Q.key]=Q}d=u.H?A(u.H):{},u.m?(u.u||(u.u="POST"),d["Content-Type"]="application/x-www-form-urlencoded",u.g.ea(u.A,u.u,u.m,d)):(u.u="GET",u.g.ea(u.A,u.u,null,d)),an(),Ef(u.i,u.u,u.A,u.l,u.R,u.m)}Nr.prototype.ca=function(u){u=u.target;let d=this.M;d&&He(u)==3?d.j():this.Y(u)},Nr.prototype.Y=function(u){try{if(u==this.g)e:{let ht=He(this.g);var d=this.g.Ba();let Hn=this.g.Z();if(!(3>ht)&&(ht!=3||this.g&&(this.h.h||this.g.oa()||ka(this.g)))){this.J||ht!=4||d==7||(d==8||0>=Hn?an(3):an(2)),Bs(this);var g=this.g.Z();this.X=g;t:if(yc(this)){var b=ka(this.g);u="";var L=b.length,F=He(this.g)==4;if(!this.h.i){if(typeof TextDecoder=="undefined"){un(this),jn(this);var Q="";break t}this.h.i=new h.TextDecoder}for(d=0;d<L;d++)this.h.h=!0,u+=this.h.i.decode(b[d],{stream:!(F&&d==L-1)});b.length=0,this.h.g+=u,this.C=0,Q=this.h.g}else Q=this.g.oa();if(this.o=g==200,If(this.i,this.u,this.A,this.l,this.R,ht,g),this.o){if(this.T&&!this.K){t:{if(this.g){var _e,Ze=this.g;if((_e=Ze.g?Ze.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!ee(_e)){var be=_e;break t}}be=null}if(g=be)Un(this.i,this.l,g,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,xa(this,g);else{this.o=!1,this.s=3,ct(12),un(this),jn(this);break e}}if(this.P){g=!0;let Qt;for(;!this.J&&this.C<Q.length;)if(Qt=Sf(this,Q),Qt==Bn){ht==4&&(this.s=4,ct(14),g=!1),Un(this.i,this.l,null,"[Incomplete Response]");break}else if(Qt==_c){this.s=4,ct(15),Un(this.i,this.l,Q,"[Invalid Chunk]"),g=!1;break}else Un(this.i,this.l,Qt,null),xa(this,Qt);if(yc(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),ht!=4||Q.length!=0||this.h.h||(this.s=1,ct(16),g=!1),this.o=this.o&&g,!g)Un(this.i,this.l,Q,"[Invalid Chunked Response]"),un(this),jn(this);else if(0<Q.length&&!this.W){this.W=!0;var lt=this.j;lt.g==this&&lt.ba&&!lt.M&&(lt.j.info("Great, no buffering proxy detected. Bytes received: "+Q.length),Fe(lt),lt.M=!0,ct(11))}}else Un(this.i,this.l,Q,null),xa(this,Q);ht==4&&un(this),this.o&&!this.J&&(ht==4?Vc(this.j,this):(this.o=!1,Us(this)))}else kc(this.g),g==400&&0<Q.indexOf("Unknown SID")?(this.s=3,ct(12)):(this.s=0,ct(13)),un(this),jn(this)}}}catch{}finally{}};function yc(u){return u.g?u.u=="GET"&&u.L!=2&&u.j.Ca:!1}function Sf(u,d){var g=u.C,b=d.indexOf(`
25
+ `,g);return b==-1?Bn:(g=Number(d.substring(g,b)),isNaN(g)?_c:(b+=1,b+g>d.length?Bn:(d=d.slice(b,b+g),u.C=b+g,d)))}Nr.prototype.cancel=function(){this.J=!0,un(this)};function Us(u){u.S=Date.now()+u.I,Ia(u,u.I)}function Ia(u,d){if(u.B!=null)throw Error("WatchDog timer not null");u.B=ki(I(u.ba,u),d)}function Bs(u){u.B&&(h.clearTimeout(u.B),u.B=null)}Nr.prototype.ba=function(){this.B=null;let u=Date.now();0<=u-this.S?(xf(this.i,this.A),this.L!=2&&(an(),ct(17)),un(this),this.s=2,jn(this)):Ia(this,this.S-u)};function jn(u){u.j.G==0||u.J||Vc(u.j,u)}function un(u){Bs(u);var d=u.M;d&&typeof d.ma=="function"&&d.ma(),u.M=null,Vs(u.U),u.g&&(d=u.g,u.g=null,d.abort(),d.ma())}function xa(u,d){try{var g=u.j;if(g.G!=0&&(g.g==u||js(g.h,u))){if(!u.K&&js(g.h,u)&&g.G==3){try{var b=g.Da.g.parse(d)}catch{b=null}if(Array.isArray(b)&&b.length==3){var L=b;if(L[0]==0){e:if(!g.u){if(g.g)if(g.g.F+3e3<u.F)Wn(g),Gi(g);else break e;Wi(g),ct(18)}}else g.za=L[1],0<g.za-g.T&&37500>L[2]&&g.F&&g.v==0&&!g.C&&(g.C=ki(I(g.Za,g),6e3));if(1>=Sa(g.h)&&g.ca){try{g.ca()}catch{}g.ca=void 0}}else cn(g,11)}else if((u.K||g.g==u)&&Wn(g),!ee(d))for(L=g.Da.g.parse(d),d=0;d<L.length;d++){let be=L[d];if(g.T=be[0],be=be[1],g.G==2)if(be[0]=="c"){g.K=be[1],g.ia=be[2];let lt=be[3];lt!=null&&(g.la=lt,g.j.info("VER="+g.la));let ht=be[4];ht!=null&&(g.Aa=ht,g.j.info("SVER="+g.Aa));let Hn=be[5];Hn!=null&&typeof Hn=="number"&&0<Hn&&(b=1.5*Hn,g.L=b,g.j.info("backChannelRequestTimeoutMs_="+b)),b=g;let Qt=u.g;if(Qt){let Qs=Qt.g?Qt.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(Qs){var F=b.h;F.g||Qs.indexOf("spdy")==-1&&Qs.indexOf("quic")==-1&&Qs.indexOf("h2")==-1||(F.j=F.l,F.g=new Set,F.h&&(Mi(F,F.h),F.h=null))}if(b.D){let Fa=Qt.g?Qt.g.getResponseHeader("X-HTTP-Session-Id"):null;Fa&&(b.ya=Fa,Ce(b.I,b.D,Fa))}}g.G=3,g.l&&g.l.ua(),g.ba&&(g.R=Date.now()-u.F,g.j.info("Handshake RTT: "+g.R+"ms")),b=g;var Q=u;if(b.qa=Mc(b,b.J?b.ia:null,b.W),Q.K){wc(b.h,Q);var _e=Q,Ze=b.L;Ze&&(_e.I=Ze),_e.B&&(Bs(_e),Us(_e)),b.g=Q}else Ki(b);0<g.i.length&&Ws(g)}else be[0]!="stop"&&be[0]!="close"||cn(g,7);else g.G==3&&(be[0]=="stop"||be[0]=="close"?be[0]=="stop"?cn(g,7):Ks(g):be[0]!="noop"&&g.l&&g.l.ta(be),g.v=0)}}an(4)}catch{}}var Rf=class{constructor(u,d){this.g=u,this.map=d}};function vc(u){this.l=u||10,h.PerformanceNavigationTiming?(u=h.performance.getEntriesByType("navigation"),u=0<u.length&&(u[0].nextHopProtocol=="hq"||u[0].nextHopProtocol=="h2")):u=!!(h.chrome&&h.chrome.loadTimes&&h.chrome.loadTimes()&&h.chrome.loadTimes().wasFetchedViaSpdy),this.j=u?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function Aa(u){return u.h?!0:u.g?u.g.size>=u.j:!1}function Sa(u){return u.h?1:u.g?u.g.size:0}function js(u,d){return u.h?u.h==d:u.g?u.g.has(d):!1}function Mi(u,d){u.g?u.g.add(d):u.h=d}function wc(u,d){u.h&&u.h==d?u.h=null:u.g&&u.g.has(d)&&u.g.delete(d)}vc.prototype.cancel=function(){if(this.i=Ra(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(let u of this.g.values())u.cancel();this.g.clear()}};function Ra(u){if(u.h!=null)return u.i.concat(u.h.D);if(u.g!=null&&u.g.size!==0){let d=u.i;for(let g of u.g.values())d=d.concat(g.D);return d}return G(u.i)}function $s(u){if(u.V&&typeof u.V=="function")return u.V();if(typeof Map!="undefined"&&u instanceof Map||typeof Set!="undefined"&&u instanceof Set)return Array.from(u.values());if(typeof u=="string")return u.split("");if(f(u)){for(var d=[],g=u.length,b=0;b<g;b++)d.push(u[b]);return d}d=[],g=0;for(b in u)d[g++]=u[b];return d}function bc(u){if(u.na&&typeof u.na=="function")return u.na();if(!u.V||typeof u.V!="function"){if(typeof Map!="undefined"&&u instanceof Map)return Array.from(u.keys());if(!(typeof Set!="undefined"&&u instanceof Set)){if(f(u)||typeof u=="string"){var d=[];u=u.length;for(var g=0;g<u;g++)d.push(g);return d}d=[],g=0;for(let b in u)d[g++]=b;return d}}}function Tc(u,d){if(u.forEach&&typeof u.forEach=="function")u.forEach(d,void 0);else if(f(u)||typeof u=="string")Array.prototype.forEach.call(u,d,void 0);else for(var g=bc(u),b=$s(u),L=b.length,F=0;F<L;F++)d.call(void 0,b[F],g&&g[F],u)}var Pa=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function Ec(u,d){if(u){u=u.split("&");for(var g=0;g<u.length;g++){var b=u[g].indexOf("="),L=null;if(0<=b){var F=u[g].substring(0,b);L=u[g].substring(b+1)}else F=u[g];d(F,L?decodeURIComponent(L.replace(/\+/g," ")):"")}}}function mr(u){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,u instanceof mr){this.h=u.h,Fi(this,u.j),this.o=u.o,this.g=u.g,$n(this,u.s),this.l=u.l;var d=u.i,g=new ji;g.i=d.i,d.g&&(g.g=new Map(d.g),g.h=d.h),qs(this,g),this.m=u.m}else u&&(d=String(u).match(Pa))?(this.h=!1,Fi(this,d[1]||"",!0),this.o=qn(d[2]||""),this.g=qn(d[3]||"",!0),$n(this,d[4]),this.l=qn(d[5]||"",!0),qs(this,d[6]||"",!0),this.m=qn(d[7]||"")):(this.h=!1,this.i=new ji(null,this.h))}mr.prototype.toString=function(){var u=[],d=this.j;d&&u.push(Bi(d,Ca,!0),":");var g=this.g;return(g||d=="file")&&(u.push("//"),(d=this.o)&&u.push(Bi(d,Ca,!0),"@"),u.push(encodeURIComponent(String(g)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),g=this.s,g!=null&&u.push(":",String(g))),(g=this.l)&&(this.g&&g.charAt(0)!="/"&&u.push("/"),u.push(Bi(g,g.charAt(0)=="/"?Ac:xc,!0))),(g=this.i.toString())&&u.push("?",g),(g=this.m)&&u.push("#",Bi(g,Cf)),u.join("")};function gr(u){return new mr(u)}function Fi(u,d,g){u.j=g?qn(d,!0):d,u.j&&(u.j=u.j.replace(/:$/,""))}function $n(u,d){if(d){if(d=Number(d),isNaN(d)||0>d)throw Error("Bad port number "+d);u.s=d}else u.s=null}function qs(u,d,g){d instanceof ji?(u.i=d,Da(u.i,u.h)):(g||(d=Bi(d,Pf)),u.i=new ji(d,u.h))}function Ce(u,d,g){u.i.set(d,g)}function Ui(u){return Ce(u,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),u}function qn(u,d){return u?d?decodeURI(u.replace(/%25/g,"%2525")):decodeURIComponent(u):""}function Bi(u,d,g){return typeof u=="string"?(u=encodeURI(u).replace(d,Ic),g&&(u=u.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),u):null}function Ic(u){return u=u.charCodeAt(0),"%"+(u>>4&15).toString(16)+(u&15).toString(16)}var Ca=/[#\/\?@]/g,xc=/[#\?:]/g,Ac=/[#\?]/g,Pf=/[#\?@]/g,Cf=/#/g;function ji(u,d){this.h=this.g=null,this.i=u||null,this.j=!!d}function _r(u){u.g||(u.g=new Map,u.h=0,u.i&&Ec(u.i,function(d,g){u.add(decodeURIComponent(d.replace(/\+/g," ")),g)}))}r=ji.prototype,r.add=function(u,d){_r(this),this.i=null,u=zn(this,u);var g=this.g.get(u);return g||this.g.set(u,g=[]),g.push(d),this.h+=1,this};function Sc(u,d){_r(u),d=zn(u,d),u.g.has(d)&&(u.i=null,u.h-=u.g.get(d).length,u.g.delete(d))}function Rc(u,d){return _r(u),d=zn(u,d),u.g.has(d)}r.forEach=function(u,d){_r(this),this.g.forEach(function(g,b){g.forEach(function(L){u.call(d,L,b,this)},this)},this)},r.na=function(){_r(this);let u=Array.from(this.g.values()),d=Array.from(this.g.keys()),g=[];for(let b=0;b<d.length;b++){let L=u[b];for(let F=0;F<L.length;F++)g.push(d[b])}return g},r.V=function(u){_r(this);let d=[];if(typeof u=="string")Rc(this,u)&&(d=d.concat(this.g.get(zn(this,u))));else{u=Array.from(this.g.values());for(let g=0;g<u.length;g++)d=d.concat(u[g])}return d},r.set=function(u,d){return _r(this),this.i=null,u=zn(this,u),Rc(this,u)&&(this.h-=this.g.get(u).length),this.g.set(u,[d]),this.h+=1,this},r.get=function(u,d){return u?(u=this.V(u),0<u.length?String(u[0]):d):d};function Pc(u,d,g){Sc(u,d),0<g.length&&(u.i=null,u.g.set(zn(u,d),G(g)),u.h+=g.length)}r.toString=function(){if(this.i)return this.i;if(!this.g)return"";let u=[],d=Array.from(this.g.keys());for(var g=0;g<d.length;g++){var b=d[g];let F=encodeURIComponent(String(b)),Q=this.V(b);for(b=0;b<Q.length;b++){var L=F;Q[b]!==""&&(L+="="+encodeURIComponent(String(Q[b]))),u.push(L)}}return this.i=u.join("&")};function zn(u,d){return d=String(d),u.j&&(d=d.toLowerCase()),d}function Da(u,d){d&&!u.j&&(_r(u),u.i=null,u.g.forEach(function(g,b){var L=b.toLowerCase();b!=L&&(Sc(this,b),Pc(this,L,g))},u)),u.j=d}function Df(u,d){let g=new Ni;if(h.Image){let b=new Image;b.onload=k(Vr,g,"TestLoadImage: loaded",!0,d,b),b.onerror=k(Vr,g,"TestLoadImage: error",!1,d,b),b.onabort=k(Vr,g,"TestLoadImage: abort",!1,d,b),b.ontimeout=k(Vr,g,"TestLoadImage: timeout",!1,d,b),h.setTimeout(function(){b.ontimeout&&b.ontimeout()},1e4),b.src=u}else d(!1)}function Of(u,d){let g=new Ni,b=new AbortController,L=setTimeout(()=>{b.abort(),Vr(g,"TestPingServer: timeout",!1,d)},1e4);fetch(u,{signal:b.signal}).then(F=>{clearTimeout(L),F.ok?Vr(g,"TestPingServer: ok",!0,d):Vr(g,"TestPingServer: server error",!1,d)}).catch(()=>{clearTimeout(L),Vr(g,"TestPingServer: error",!1,d)})}function Vr(u,d,g,b,L){try{L&&(L.onload=null,L.onerror=null,L.onabort=null,L.ontimeout=null),b(g)}catch{}}function kf(){this.g=new Tf}function Nf(u,d,g){let b=g||"";try{Tc(u,function(L,F){let Q=L;m(L)&&(Q=ya(L)),d.push(b+F+"="+encodeURIComponent(Q))})}catch(L){throw d.push(b+"type="+encodeURIComponent("_badmap")),L}}function Oe(u){this.l=u.Ub||null,this.j=u.eb||!1}B(Oe,Ls),Oe.prototype.g=function(){return new ke(this.l,this.j)},Oe.prototype.i=function(u){return function(){return u}}({});function ke(u,d){nt.call(this),this.D=u,this.o=d,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}B(ke,nt),r=ke.prototype,r.open=function(u,d){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.B=u,this.A=d,this.readyState=1,qi(this)},r.send=function(u){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");this.g=!0;let d={headers:this.u,method:this.B,credentials:this.m,cache:void 0};u&&(d.body=u),(this.D||h).fetch(new Request(this.A,d)).then(this.Sa.bind(this),this.ga.bind(this))},r.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),1<=this.readyState&&this.g&&this.readyState!=4&&(this.g=!1,$i(this)),this.readyState=0},r.Sa=function(u){if(this.g&&(this.l=u,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=u.headers,this.readyState=2,qi(this)),this.g&&(this.readyState=3,qi(this),this.g)))if(this.responseType==="arraybuffer")u.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(typeof h.ReadableStream!="undefined"&&"body"in u){if(this.j=u.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;Cc(this)}else u.text().then(this.Ra.bind(this),this.ga.bind(this))};function Cc(u){u.j.read().then(u.Pa.bind(u)).catch(u.ga.bind(u))}r.Pa=function(u){if(this.g){if(this.o&&u.value)this.response.push(u.value);else if(!this.o){var d=u.value?u.value:new Uint8Array(0);(d=this.v.decode(d,{stream:!u.done}))&&(this.response=this.responseText+=d)}u.done?$i(this):qi(this),this.readyState==3&&Cc(this)}},r.Ra=function(u){this.g&&(this.response=this.responseText=u,$i(this))},r.Qa=function(u){this.g&&(this.response=u,$i(this))},r.ga=function(){this.g&&$i(this)};function $i(u){u.readyState=4,u.l=null,u.j=null,u.v=null,qi(u)}r.setRequestHeader=function(u,d){this.u.append(u,d)},r.getResponseHeader=function(u){return this.h&&this.h.get(u.toLowerCase())||""},r.getAllResponseHeaders=function(){if(!this.h)return"";let u=[],d=this.h.entries();for(var g=d.next();!g.done;)g=g.value,u.push(g[0]+": "+g[1]),g=d.next();return u.join(`\r
26
+ `)};function qi(u){u.onreadystatechange&&u.onreadystatechange.call(u)}Object.defineProperty(ke.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(u){this.m=u?"include":"same-origin"}});function Dc(u){let d="";return ie(u,function(g,b){d+=b,d+=":",d+=g,d+=`\r
27
+ `}),d}function Oa(u,d,g){e:{for(b in g){var b=!1;break e}b=!0}b||(g=Dc(g),typeof u=="string"?g!=null&&encodeURIComponent(String(g)):Ce(u,d,g))}function ze(u){nt.call(this),this.headers=new Map,this.o=u||null,this.h=!1,this.v=this.g=null,this.D="",this.m=0,this.l="",this.j=this.B=this.u=this.A=!1,this.I=null,this.H="",this.J=!1}B(ze,nt);var Oc=/^https?$/i,Vf=["POST","PUT"];r=ze.prototype,r.Ha=function(u){this.J=u},r.ea=function(u,d,g,b){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+u);d=d?d.toUpperCase():"GET",this.D=u,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():Ta.g(),this.v=this.o?va(this.o):va(Ta),this.g.onreadystatechange=I(this.Ea,this);try{this.B=!0,this.g.open(d,String(u),!0),this.B=!1}catch(F){Xe(this,F);return}if(u=g||"",g=new Map(this.headers),b)if(Object.getPrototypeOf(b)===Object.prototype)for(var L in b)g.set(L,b[L]);else if(typeof b.keys=="function"&&typeof b.get=="function")for(let F of b.keys())g.set(F,b.get(F));else throw Error("Unknown input type for opt_headers: "+String(b));b=Array.from(g.keys()).find(F=>F.toLowerCase()=="content-type"),L=h.FormData&&u instanceof h.FormData,!(0<=Array.prototype.indexOf.call(Vf,d,void 0))||b||L||g.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(let[F,Q]of g)this.g.setRequestHeader(F,Q);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{Gs(this),this.u=!0,this.g.send(u),this.u=!1}catch(F){Xe(this,F)}};function Xe(u,d){u.h=!1,u.g&&(u.j=!0,u.g.abort(),u.j=!1),u.l=d,u.m=5,zs(u),zi(u)}function zs(u){u.A||(u.A=!0,ut(u,"complete"),ut(u,"error"))}r.abort=function(u){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=u||7,ut(this,"complete"),ut(this,"abort"),zi(this))},r.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),zi(this,!0)),ze.aa.N.call(this)},r.Ea=function(){this.s||(this.B||this.u||this.j?Lr(this):this.bb())},r.bb=function(){Lr(this)};function Lr(u){if(u.h&&typeof c!="undefined"&&(!u.v[1]||He(u)!=4||u.Z()!=2)){if(u.u&&He(u)==4)Os(u.Ea,0,u);else if(ut(u,"readystatechange"),He(u)==4){u.h=!1;try{let Q=u.Z();e:switch(Q){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var d=!0;break e;default:d=!1}var g;if(!(g=d)){var b;if(b=Q===0){var L=String(u.D).match(Pa)[1]||null;!L&&h.self&&h.self.location&&(L=h.self.location.protocol.slice(0,-1)),b=!Oc.test(L?L.toLowerCase():"")}g=b}if(g)ut(u,"complete"),ut(u,"success");else{u.m=6;try{var F=2<He(u)?u.g.statusText:""}catch{F=""}u.l=F+" ["+u.Z()+"]",zs(u)}}finally{zi(u)}}}}function zi(u,d){if(u.g){Gs(u);let g=u.g,b=u.v[0]?()=>{}:null;u.g=null,u.v=null,d||ut(u,"ready");try{g.onreadystatechange=b}catch{}}}function Gs(u){u.I&&(h.clearTimeout(u.I),u.I=null)}r.isActive=function(){return!!this.g};function He(u){return u.g?u.g.readyState:0}r.Z=function(){try{return 2<He(this)?this.g.status:-1}catch{return-1}},r.oa=function(){try{return this.g?this.g.responseText:""}catch{return""}},r.Oa=function(u){if(this.g){var d=this.g.responseText;return u&&d.indexOf(u)==0&&(d=d.substring(u.length)),bf(d)}};function ka(u){try{if(!u.g)return null;if("response"in u.g)return u.g.response;switch(u.H){case"":case"text":return u.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in u.g)return u.g.mozResponseArrayBuffer}return null}catch{return null}}function kc(u){let d={};u=(u.g&&2<=He(u)&&u.g.getAllResponseHeaders()||"").split(`\r
28
+ `);for(let b=0;b<u.length;b++){if(ee(u[b]))continue;var g=V(u[b]);let L=g[0];if(g=g[1],typeof g!="string")continue;g=g.trim();let F=d[L]||[];d[L]=F,F.push(g)}C(d,function(b){return b.join(", ")})}r.Ba=function(){return this.m},r.Ka=function(){return typeof this.l=="string"?this.l:String(this.l)};function Gn(u,d,g){return g&&g.internalChannelParams&&g.internalChannelParams[u]||d}function Na(u){this.Aa=0,this.i=[],this.j=new Ni,this.ia=this.qa=this.I=this.W=this.g=this.ya=this.D=this.H=this.m=this.S=this.o=null,this.Ya=this.U=0,this.Va=Gn("failFast",!1,u),this.F=this.C=this.u=this.s=this.l=null,this.X=!0,this.za=this.T=-1,this.Y=this.v=this.B=0,this.Ta=Gn("baseRetryDelayMs",5e3,u),this.cb=Gn("retryDelaySeedMs",1e4,u),this.Wa=Gn("forwardChannelMaxRetries",2,u),this.wa=Gn("forwardChannelRequestTimeoutMs",2e4,u),this.pa=u&&u.xmlHttpFactory||void 0,this.Xa=u&&u.Tb||void 0,this.Ca=u&&u.useFetchStreams||!1,this.L=void 0,this.J=u&&u.supportsCrossDomainXhr||!1,this.K="",this.h=new vc(u&&u.concurrentRequestLimit),this.Da=new kf,this.P=u&&u.fastHandshake||!1,this.O=u&&u.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=u&&u.Rb||!1,u&&u.xa&&this.j.xa(),u&&u.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&u&&u.detectBufferingProxy||!1,this.ja=void 0,u&&u.longPollingTimeout&&0<u.longPollingTimeout&&(this.ja=u.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}r=Na.prototype,r.la=8,r.G=1,r.connect=function(u,d,g,b){ct(0),this.W=u,this.H=d||{},g&&b!==void 0&&(this.H.OSID=g,this.H.OAID=b),this.F=this.X,this.I=Mc(this,null,this.W),Ws(this)};function Ks(u){if(Et(u),u.G==3){var d=u.U++,g=gr(u.I);if(Ce(g,"SID",u.K),Ce(g,"RID",d),Ce(g,"TYPE","terminate"),Kn(u,g),d=new Nr(u,u.j,d),d.L=2,d.v=Ui(gr(g)),g=!1,h.navigator&&h.navigator.sendBeacon)try{g=h.navigator.sendBeacon(d.v.toString(),"")}catch{}!g&&h.Image&&(new Image().src=d.v,g=!0),g||(d.g=Va(d.j,null),d.g.ea(d.v)),d.F=Date.now(),Us(d)}Lc(u)}function Gi(u){u.g&&(Fe(u),u.g.cancel(),u.g=null)}function Et(u){Gi(u),u.u&&(h.clearTimeout(u.u),u.u=null),Wn(u),u.h.cancel(),u.s&&(typeof u.s=="number"&&h.clearTimeout(u.s),u.s=null)}function Ws(u){if(!Aa(u.h)&&!u.s){u.s=!0;var d=u.Ga;Ai||ac(),Cr||(Ai(),Cr=!0),Lt.add(d,u),u.B=0}}function Ft(u,d){return Sa(u.h)>=u.h.j-(u.s?1:0)?!1:u.s?(u.i=d.D.concat(u.i),!0):u.G==1||u.G==2||u.B>=(u.Va?0:u.Wa)?!1:(u.s=ki(I(u.Ga,u,d),Hs(u,u.B)),u.B++,!0)}r.Ga=function(u){if(this.s)if(this.s=null,this.G==1){if(!u){this.U=Math.floor(1e5*Math.random()),u=this.U++;let L=new Nr(this,this.j,u),F=this.o;if(this.S&&(F?(F=A(F),D(F,this.S)):F=this.S),this.m!==null||this.O||(L.H=F,F=null),this.P)e:{for(var d=0,g=0;g<this.i.length;g++){t:{var b=this.i[g];if("__data__"in b.map&&(b=b.map.__data__,typeof b=="string")){b=b.length;break t}b=void 0}if(b===void 0)break;if(d+=b,4096<d){d=g;break e}if(d===4096||g===this.i.length-1){d=g+1;break e}}d=1e3}else d=1e3;d=yr(this,L,d),g=gr(this.I),Ce(g,"RID",u),Ce(g,"CVER",22),this.D&&Ce(g,"X-HTTP-Session-Id",this.D),Kn(this,g),F&&(this.O?d="headers="+encodeURIComponent(String(Dc(F)))+"&"+d:this.m&&Oa(g,this.m,F)),Mi(this.h,L),this.Ua&&Ce(g,"TYPE","init"),this.P?(Ce(g,"$req",d),Ce(g,"SID","null"),L.T=!0,Ea(L,g,null)):Ea(L,g,d),this.G=2}}else this.G==3&&(u?Nc(this,u):this.i.length==0||Aa(this.h)||Nc(this))};function Nc(u,d){var g;d?g=d.l:g=u.U++;let b=gr(u.I);Ce(b,"SID",u.K),Ce(b,"RID",g),Ce(b,"AID",u.T),Kn(u,b),u.m&&u.o&&Oa(b,u.m,u.o),g=new Nr(u,u.j,g,u.B+1),u.m===null&&(g.H=u.o),d&&(u.i=d.D.concat(u.i)),d=yr(u,g,1e3),g.I=Math.round(.5*u.wa)+Math.round(.5*u.wa*Math.random()),Mi(u.h,g),Ea(g,b,d)}function Kn(u,d){u.H&&ie(u.H,function(g,b){Ce(d,b,g)}),u.l&&Tc({},function(g,b){Ce(d,b,g)})}function yr(u,d,g){g=Math.min(u.i.length,g);var b=u.l?I(u.l.Na,u.l,u):null;e:{var L=u.i;let F=-1;for(;;){let Q=["count="+g];F==-1?0<g?(F=L[0].g,Q.push("ofs="+F)):F=0:Q.push("ofs="+F);let _e=!0;for(let Ze=0;Ze<g;Ze++){let be=L[Ze].g,lt=L[Ze].map;if(be-=F,0>be)F=Math.max(0,L[Ze].g-100),_e=!1;else try{Nf(lt,Q,"req"+be+"_")}catch{b&&b(lt)}}if(_e){b=Q.join("&");break e}}}return u=u.i.splice(0,g),d.D=u,b}function Ki(u){if(!u.g&&!u.u){u.Y=1;var d=u.Fa;Ai||ac(),Cr||(Ai(),Cr=!0),Lt.add(d,u),u.v=0}}function Wi(u){return u.g||u.u||3<=u.v?!1:(u.Y++,u.u=ki(I(u.Fa,u),Hs(u,u.v)),u.v++,!0)}r.Fa=function(){if(this.u=null,vr(this),this.ba&&!(this.M||this.g==null||0>=this.R)){var u=2*this.R;this.j.info("BP detection timer enabled: "+u),this.A=ki(I(this.ab,this),u)}},r.ab=function(){this.A&&(this.A=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.M=!0,ct(10),Gi(this),vr(this))};function Fe(u){u.A!=null&&(h.clearTimeout(u.A),u.A=null)}function vr(u){u.g=new Nr(u,u.j,"rpc",u.Y),u.m===null&&(u.g.H=u.o),u.g.O=0;var d=gr(u.qa);Ce(d,"RID","rpc"),Ce(d,"SID",u.K),Ce(d,"AID",u.T),Ce(d,"CI",u.F?"0":"1"),!u.F&&u.ja&&Ce(d,"TO",u.ja),Ce(d,"TYPE","xmlhttp"),Kn(u,d),u.m&&u.o&&Oa(d,u.m,u.o),u.L&&(u.g.I=u.L);var g=u.g;u=u.ia,g.L=1,g.v=Ui(gr(d)),g.m=null,g.P=!0,Li(g,u)}r.Za=function(){this.C!=null&&(this.C=null,Gi(this),Wi(this),ct(19))};function Wn(u){u.C!=null&&(h.clearTimeout(u.C),u.C=null)}function Vc(u,d){var g=null;if(u.g==d){Wn(u),Fe(u),u.g=null;var b=2}else if(js(u.h,d))g=d.D,wc(u.h,d),b=1;else return;if(u.G!=0){if(d.o)if(b==1){g=d.m?d.m.length:0,d=Date.now()-d.F;var L=u.B;b=Ms(),ut(b,new pc(b,g)),Ws(u)}else Ki(u);else if(L=d.s,L==3||L==0&&0<d.X||!(b==1&&Ft(u,d)||b==2&&Wi(u)))switch(g&&0<g.length&&(d=u.h,d.i=d.i.concat(g)),L){case 1:cn(u,5);break;case 4:cn(u,10);break;case 3:cn(u,6);break;default:cn(u,2)}}}function Hs(u,d){let g=u.Ta+Math.floor(Math.random()*u.cb);return u.isActive()||(g*=2),g*d}function cn(u,d){if(u.j.info("Error code "+d),d==2){var g=I(u.fb,u),b=u.Xa;let L=!b;b=new mr(b||"//www.google.com/images/cleardot.gif"),h.location&&h.location.protocol=="http"||Fi(b,"https"),Ui(b),L?Df(b.toString(),g):Of(b.toString(),g)}else ct(2);u.G=0,u.l&&u.l.sa(d),Lc(u),Et(u)}r.fb=function(u){u?(this.j.info("Successfully pinged google.com"),ct(2)):(this.j.info("Failed to ping google.com"),ct(1))};function Lc(u){if(u.G=0,u.ka=[],u.l){let d=Ra(u.h);(d.length!=0||u.i.length!=0)&&(j(u.ka,d),j(u.ka,u.i),u.h.i.length=0,G(u.i),u.i.length=0),u.l.ra()}}function Mc(u,d,g){var b=g instanceof mr?gr(g):new mr(g);if(b.g!="")d&&(b.g=d+"."+b.g),$n(b,b.s);else{var L=h.location;b=L.protocol,d=d?d+"."+L.hostname:L.hostname,L=+L.port;var F=new mr(null);b&&Fi(F,b),d&&(F.g=d),L&&$n(F,L),g&&(F.l=g),b=F}return g=u.D,d=u.ya,g&&d&&Ce(b,g,d),Ce(b,"VER",u.la),Kn(u,b),b}function Va(u,d,g){if(d&&!u.J)throw Error("Can't create secondary domain capable XhrIo object.");return d=u.Ca&&!u.pa?new ze(new Oe({eb:g})):new ze(u.pa),d.Ha(u.J),d}r.isActive=function(){return!!this.l&&this.l.isActive(this)};function Hi(){}r=Hi.prototype,r.ua=function(){},r.ta=function(){},r.sa=function(){},r.ra=function(){},r.isActive=function(){return!0},r.Na=function(){};function wr(){}wr.prototype.g=function(u,d){return new Ct(u,d)};function Ct(u,d){nt.call(this),this.g=new Na(d),this.l=u,this.h=d&&d.messageUrlParams||null,u=d&&d.messageHeaders||null,d&&d.clientProtocolHeaderRequired&&(u?u["X-Client-Protocol"]="webchannel":u={"X-Client-Protocol":"webchannel"}),this.g.o=u,u=d&&d.initMessageHeaders||null,d&&d.messageContentType&&(u?u["X-WebChannel-Content-Type"]=d.messageContentType:u={"X-WebChannel-Content-Type":d.messageContentType}),d&&d.va&&(u?u["X-WebChannel-Client-Profile"]=d.va:u={"X-WebChannel-Client-Profile":d.va}),this.g.S=u,(u=d&&d.Sb)&&!ee(u)&&(this.g.m=u),this.v=d&&d.supportsCrossDomainXhr||!1,this.u=d&&d.sendRawJson||!1,(d=d&&d.httpSessionIdParam)&&!ee(d)&&(this.g.D=d,u=this.h,u!==null&&d in u&&(u=this.h,d in u&&delete u[d])),this.j=new Mr(this)}B(Ct,nt),Ct.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},Ct.prototype.close=function(){Ks(this.g)},Ct.prototype.o=function(u){var d=this.g;if(typeof u=="string"){var g={};g.__data__=u,u=g}else this.u&&(g={},g.__data__=ya(u),u=g);d.i.push(new Rf(d.Ya++,u)),d.G==3&&Ws(d)},Ct.prototype.N=function(){this.g.l=null,delete this.j,Ks(this.g),delete this.g,Ct.aa.N.call(this)};function La(u){wa.call(this),u.__headers__&&(this.headers=u.__headers__,this.statusCode=u.__status__,delete u.__headers__,delete u.__status__);var d=u.__sm__;if(d){e:{for(let g in d){u=g;break e}u=void 0}(this.i=u)&&(u=this.i,d=d!==null&&u in d?d[u]:void 0),this.data=d}else this.data=u}B(La,wa);function Ma(){ba.call(this),this.status=1}B(Ma,ba);function Mr(u){this.g=u}B(Mr,Hi),Mr.prototype.ua=function(){ut(this.g,"a")},Mr.prototype.ta=function(u){ut(this.g,new La(u))},Mr.prototype.sa=function(u){ut(this.g,new Ma)},Mr.prototype.ra=function(){ut(this.g,"b")},wr.prototype.createWebChannel=wr.prototype.g,Ct.prototype.send=Ct.prototype.o,Ct.prototype.open=Ct.prototype.m,Ct.prototype.close=Ct.prototype.close,fp=Rn.createWebChannelTransport=function(){return new wr},hp=Rn.getStatEventTarget=function(){return Ms()},lp=Rn.Event=kr,Jl=Rn.Stat={mb:0,pb:1,qb:2,Jb:3,Ob:4,Lb:5,Mb:6,Kb:7,Ib:8,Nb:9,PROXY:10,NOPROXY:11,Gb:12,Cb:13,Db:14,Bb:15,Eb:16,Fb:17,ib:18,hb:19,jb:20},Vi.NO_ERROR=0,Vi.TIMEOUT=8,Vi.HTTP_ERROR=6,cu=Rn.ErrorCode=Vi,mc.COMPLETE="complete",cp=Rn.EventType=mc,lc.EventType=Oi,Oi.OPEN="a",Oi.CLOSE="b",Oi.ERROR="c",Oi.MESSAGE="d",nt.prototype.listen=nt.prototype.K,So=Rn.WebChannel=lc,C2=Rn.FetchXmlHttpFactory=Oe,ze.prototype.listenOnce=ze.prototype.L,ze.prototype.getLastError=ze.prototype.Ka,ze.prototype.getLastErrorCode=ze.prototype.Ba,ze.prototype.getStatus=ze.prototype.Z,ze.prototype.getResponseJson=ze.prototype.Oa,ze.prototype.getResponseText=ze.prototype.oa,ze.prototype.send=ze.prototype.ea,ze.prototype.setWithCredentials=ze.prototype.Ha,up=Rn.XhrIo=ze}).apply(typeof Ql!="undefined"?Ql:typeof self!="undefined"?self:typeof window!="undefined"?window:{});var K0="@firebase/firestore",W0="4.7.8";var _t=class{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}};_t.UNAUTHENTICATED=new _t(null),_t.GOOGLE_CREDENTIALS=new _t("google-credentials-uid"),_t.FIRST_PARTY=new _t("first-party-uid"),_t.MOCK_USER=new _t("mock-user");var Yo="11.3.1";var cs=new Ao("@firebase/firestore");function Ro(){return cs.logLevel}function X(r,...e){if(cs.logLevel<=Se.DEBUG){let t=e.map(Xm);cs.debug(`Firestore (${Yo}): ${r}`,...t)}}function Pn(r,...e){if(cs.logLevel<=Se.ERROR){let t=e.map(Xm);cs.error(`Firestore (${Yo}): ${r}`,...t)}}function Vo(r,...e){if(cs.logLevel<=Se.WARN){let t=e.map(Xm);cs.warn(`Firestore (${Yo}): ${r}`,...t)}}function Xm(r){if(typeof r=="string")return r;try{return function(t){return JSON.stringify(t)}(r)}catch{return r}}function ue(r="Unexpected state"){let e=`FIRESTORE (${Yo}) INTERNAL ASSERTION FAILED: `+r;throw Pn(e),new Error(e)}function Le(r,e){r||ue()}function fe(r,e){return r}var H={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"},ne=class extends En{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}};var Gr=class{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}};var nh=class{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}},_p=class{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(_t.UNAUTHENTICATED))}shutdown(){}},yp=class{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable(()=>t(this.token.user))}shutdown(){this.changeListener=null}},vp=class{constructor(e){this.t=e,this.currentUser=_t.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){Le(this.o===void 0);let n=this.i,s=f=>this.i!==n?(n=this.i,t(f)):Promise.resolve(),a=new Gr;this.o=()=>{this.i++,this.currentUser=this.u(),a.resolve(),a=new Gr,e.enqueueRetryable(()=>s(this.currentUser))};let c=()=>{let f=a;e.enqueueRetryable(async()=>{await f.promise,await s(this.currentUser)})},h=f=>{X("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=f,this.o&&(this.auth.addAuthTokenListener(this.o),c())};this.t.onInit(f=>h(f)),setTimeout(()=>{if(!this.auth){let f=this.t.getImmediate({optional:!0});f?h(f):(X("FirebaseAuthCredentialsProvider","Auth not yet detected"),a.resolve(),a=new Gr)}},0),c()}getToken(){let e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(n=>this.i!==e?(X("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):n?(Le(typeof n.accessToken=="string"),new nh(n.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){let e=this.auth&&this.auth.getUid();return Le(e===null||typeof e=="string"),new _t(e)}},wp=class{constructor(e,t,n){this.l=e,this.h=t,this.P=n,this.type="FirstParty",this.user=_t.FIRST_PARTY,this.T=new Map}I(){return this.P?this.P():null}get headers(){this.T.set("X-Goog-AuthUser",this.l);let e=this.I();return e&&this.T.set("Authorization",e),this.h&&this.T.set("X-Goog-Iam-Authorization-Token",this.h),this.T}},bp=class{constructor(e,t,n){this.l=e,this.h=t,this.P=n}getToken(){return Promise.resolve(new wp(this.l,this.h,this.P))}start(e,t){e.enqueueRetryable(()=>t(_t.FIRST_PARTY))}shutdown(){}invalidateToken(){}},ih=class{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}},Tp=class{constructor(e,t){this.A=t,this.forceRefresh=!1,this.appCheck=null,this.R=null,this.V=null,U0(e)&&e.settings.appCheckToken&&(this.V=e.settings.appCheckToken)}start(e,t){Le(this.o===void 0);let n=a=>{a.error!=null&&X("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${a.error.message}`);let c=a.token!==this.R;return this.R=a.token,X("FirebaseAppCheckTokenProvider",`Received ${c?"new":"existing"} token.`),c?t(a.token):Promise.resolve()};this.o=a=>{e.enqueueRetryable(()=>n(a))};let s=a=>{X("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=a,this.o&&this.appCheck.addTokenListener(this.o)};this.A.onInit(a=>s(a)),setTimeout(()=>{if(!this.appCheck){let a=this.A.getImmediate({optional:!0});a?s(a):X("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.V)return Promise.resolve(new ih(this.V));let e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(t=>t?(Le(typeof t.token=="string"),this.R=t.token,new ih(t.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}};function D2(r){let e=typeof self!="undefined"&&(self.crypto||self.msCrypto),t=new Uint8Array(r);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let n=0;n<r;n++)t[n]=Math.floor(256*Math.random());return t}var sh=class{static newId(){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=62*Math.floor(4.129032258064516),n="";for(;n.length<20;){let s=D2(40);for(let a=0;a<s.length;++a)n.length<20&&s[a]<t&&(n+=e.charAt(s[a]%62))}return n}};function Re(r,e){return r<e?-1:r>e?1:0}function Lo(r,e,t){return r.length===e.length&&r.every((n,s)=>t(n,e[s]))}var H0=-62135596800,Q0=1e6,wt=class r{static now(){return r.fromMillis(Date.now())}static fromDate(e){return r.fromMillis(e.getTime())}static fromMillis(e){let t=Math.floor(e/1e3),n=Math.floor((e-1e3*t)*Q0);return new r(t,n)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new ne(H.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new ne(H.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<H0)throw new ne(H.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new ne(H.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/Q0}_compareTo(e){return this.seconds===e.seconds?Re(this.nanoseconds,e.nanoseconds):Re(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){let e=this.seconds-H0;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}};var me=class r{static fromTimestamp(e){return new r(e)}static min(){return new r(new wt(0,0))}static max(){return new r(new wt(253402300799,999999999))}constructor(e){this.timestamp=e}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}};var J0="__name__",oh=class r{constructor(e,t,n){t===void 0?t=0:t>e.length&&ue(),n===void 0?n=e.length-t:n>e.length-t&&ue(),this.segments=e,this.offset=t,this.len=n}get length(){return this.len}isEqual(e){return r.comparator(this,e)===0}child(e){let t=this.segments.slice(this.offset,this.limit());return e instanceof r?e.forEach(n=>{t.push(n)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,n=this.limit();t<n;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){let n=Math.min(e.length,t.length);for(let s=0;s<n;s++){let a=r.compareSegments(e.get(s),t.get(s));if(a!==0)return a}return Math.sign(e.length-t.length)}static compareSegments(e,t){let n=r.isNumericId(e),s=r.isNumericId(t);return n&&!s?-1:!n&&s?1:n&&s?r.extractNumericId(e).compare(r.extractNumericId(t)):e<t?-1:e>t?1:0}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return Sn.fromString(e.substring(4,e.length-2))}},ot=class r extends oh{construct(e,t,n){return new r(e,t,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){let t=[];for(let n of e){if(n.indexOf("//")>=0)throw new ne(H.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);t.push(...n.split("/").filter(s=>s.length>0))}return new r(t)}static emptyPath(){return new r([])}},O2=/^[_a-zA-Z][_a-zA-Z0-9]*$/,tr=class r extends oh{construct(e,t,n){return new r(e,t,n)}static isValidIdentifier(e){return O2.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),r.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===J0}static keyField(){return new r([J0])}static fromServerFormat(e){let t=[],n="",s=0,a=()=>{if(n.length===0)throw new ne(H.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(n),n=""},c=!1;for(;s<e.length;){let h=e[s];if(h==="\\"){if(s+1===e.length)throw new ne(H.INVALID_ARGUMENT,"Path has trailing escape character: "+e);let f=e[s+1];if(f!=="\\"&&f!=="."&&f!=="`")throw new ne(H.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);n+=f,s+=2}else h==="`"?(c=!c,s++):h!=="."||c?(n+=h,s++):(a(),s++)}if(a(),c)throw new ne(H.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new r(t)}static emptyPath(){return new r([])}};var ce=class r{constructor(e){this.path=e}static fromPath(e){return new r(ot.fromString(e))}static fromName(e){return new r(ot.fromString(e).popFirst(5))}static empty(){return new r(ot.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&ot.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return ot.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new r(new ot(e.slice()))}};var mu=-1,Ep=class{constructor(e,t,n,s){this.indexId=e,this.collectionGroup=t,this.fields=n,this.indexState=s}};Ep.UNKNOWN_ID=-1;function k2(r,e){let t=r.toTimestamp().seconds,n=r.toTimestamp().nanoseconds+1,s=me.fromTimestamp(n===1e9?new wt(t+1,0):new wt(t,n));return new ls(s,ce.empty(),e)}function N2(r){return new ls(r.readTime,r.key,mu)}var ls=class r{constructor(e,t,n){this.readTime=e,this.documentKey=t,this.largestBatchId=n}static min(){return new r(me.min(),ce.empty(),mu)}static max(){return new r(me.max(),ce.empty(),mu)}};function V2(r,e){let t=r.readTime.compareTo(e.readTime);return t!==0?t:(t=ce.comparator(r.documentKey,e.documentKey),t!==0?t:Re(r.largestBatchId,e.largestBatchId))}var L2="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",Ip=class{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}};async function Xo(r){if(r.code!==H.FAILED_PRECONDITION||r.message!==L2)throw r;X("LocalStore","Unexpectedly lost primary lease")}var W=class r{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)},t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)})}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&ue(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new r((n,s)=>{this.nextCallback=a=>{this.wrapSuccess(e,a).next(n,s)},this.catchCallback=a=>{this.wrapFailure(t,a).next(n,s)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{let t=e();return t instanceof r?t:r.resolve(t)}catch(t){return r.reject(t)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):r.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):r.reject(t)}static resolve(e){return new r((t,n)=>{t(e)})}static reject(e){return new r((t,n)=>{n(e)})}static waitFor(e){return new r((t,n)=>{let s=0,a=0,c=!1;e.forEach(h=>{++s,h.next(()=>{++a,c&&a===s&&t()},f=>n(f))}),c=!0,a===s&&t()})}static or(e){let t=r.resolve(!1);for(let n of e)t=t.next(s=>s?r.resolve(s):n());return t}static forEach(e,t){let n=[];return e.forEach((s,a)=>{n.push(t.call(this,s,a))}),this.waitFor(n)}static mapArray(e,t){return new r((n,s)=>{let a=e.length,c=new Array(a),h=0;for(let f=0;f<a;f++){let m=f;t(e[m]).next(_=>{c[m]=_,++h,h===a&&n(c)},_=>s(_))}})}static doWhile(e,t){return new r((n,s)=>{let a=()=>{e()===!0?t().next(()=>{a()},s):n()};a()})}};function M2(r){let e=r.match(/Android ([\d.]+)/i),t=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(t)}function Zo(r){return r.name==="IndexedDbTransactionError"}var Mo=class{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=n=>this.oe(n),this._e=n=>t.writeSequenceNumber(n))}oe(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){let e=++this.previousValue;return this._e&&this._e(e),e}};Mo.ae=-1;var Zm=-1;function jh(r){return r==null}function gu(r){return r===0&&1/r==-1/0}function F2(r){return typeof r=="number"&&Number.isInteger(r)&&!gu(r)&&r<=Number.MAX_SAFE_INTEGER&&r>=Number.MIN_SAFE_INTEGER}var kb="";function U2(r){let e="";for(let t=0;t<r.length;t++)e.length>0&&(e=Y0(e)),e=B2(r.get(t),e);return Y0(e)}function B2(r,e){let t=e,n=r.length;for(let s=0;s<n;s++){let a=r.charAt(s);switch(a){case"\0":t+="";break;case kb:t+="";break;default:t+=a}}return t}function Y0(r){return r+kb+""}var j2="remoteDocuments",Nb="owner";var Vb="mutationQueues";var Lb="mutations";var Mb="documentMutations",$2="remoteDocumentsV14";var Fb="remoteDocumentGlobal";var Ub="targets";var Bb="targetDocuments";var jb="targetGlobal",$b="collectionParents";var qb="clientMetadata";var zb="bundles";var Gb="namedQueries";var q2="indexConfiguration";var z2="indexState";var G2="indexEntries";var Kb="documentOverlays";var K2="globals";var W2=[Vb,Lb,Mb,j2,Ub,Nb,jb,Bb,qb,Fb,$b,zb,Gb],gK=[...W2,Kb],H2=[Vb,Lb,Mb,$2,Ub,Nb,jb,Bb,qb,Fb,$b,zb,Gb,Kb],Q2=H2,J2=[...Q2,q2,z2,G2];var _K=[...J2,K2];function X0(r){let e=0;for(let t in r)Object.prototype.hasOwnProperty.call(r,t)&&e++;return e}function Ti(r,e){for(let t in r)Object.prototype.hasOwnProperty.call(r,t)&&e(t,r[t])}function Wb(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(r,e))return!1;return!0}var Ye=class r{constructor(e,t){this.comparator=e,this.root=t||Kr.EMPTY}insert(e,t){return new r(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,Kr.BLACK,null,null))}remove(e){return new r(this.comparator,this.root.remove(e,this.comparator).copy(null,null,Kr.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){let n=this.comparator(e,t.key);if(n===0)return t.value;n<0?t=t.left:n>0&&(t=t.right)}return null}indexOf(e){let t=0,n=this.root;for(;!n.isEmpty();){let s=this.comparator(e,n.key);if(s===0)return t+n.left.size;s<0?n=n.left:(t+=n.left.size+1,n=n.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal((t,n)=>(e(t,n),!1))}toString(){let e=[];return this.inorderTraversal((t,n)=>(e.push(`${t}:${n}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new Oo(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Oo(this.root,e,this.comparator,!1)}getReverseIterator(){return new Oo(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Oo(this.root,e,this.comparator,!0)}},Oo=class{constructor(e,t,n,s){this.isReverse=s,this.nodeStack=[];let a=1;for(;!e.isEmpty();)if(a=t?n(e.key,t):1,t&&s&&(a*=-1),a<0)e=this.isReverse?e.left:e.right;else{if(a===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop(),t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;let e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}},Kr=class r{constructor(e,t,n,s,a){this.key=e,this.value=t,this.color=n!=null?n:r.RED,this.left=s!=null?s:r.EMPTY,this.right=a!=null?a:r.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,n,s,a){return new r(e!=null?e:this.key,t!=null?t:this.value,n!=null?n:this.color,s!=null?s:this.left,a!=null?a:this.right)}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 s=this,a=n(e,s.key);return s=a<0?s.copy(null,null,null,s.left.insert(e,t,n),null):a===0?s.copy(null,t,null,null,null):s.copy(null,null,null,null,s.right.insert(e,t,n)),s.fixUp()}removeMin(){if(this.left.isEmpty())return r.EMPTY;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,s=this;if(t(e,s.key)<0)s.left.isEmpty()||s.left.isRed()||s.left.left.isRed()||(s=s.moveRedLeft()),s=s.copy(null,null,null,s.left.remove(e,t),null);else{if(s.left.isRed()&&(s=s.rotateRight()),s.right.isEmpty()||s.right.isRed()||s.right.left.isRed()||(s=s.moveRedRight()),t(e,s.key)===0){if(s.right.isEmpty())return r.EMPTY;n=s.right.min(),s=s.copy(n.key,n.value,null,null,s.right.removeMin())}s=s.copy(null,null,null,null,s.right.remove(e,t))}return s.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){let e=this.copy(null,null,r.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){let e=this.copy(null,null,r.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){let e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){let e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed()||this.right.isRed())throw ue();let e=this.left.check();if(e!==this.right.check())throw ue();return e+(this.isRed()?0:1)}};Kr.EMPTY=null,Kr.RED=!0,Kr.BLACK=!1;Kr.EMPTY=new class{constructor(){this.size=0}get key(){throw ue()}get value(){throw ue()}get color(){throw ue()}get left(){throw ue()}get right(){throw ue()}copy(e,t,n,s,a){return this}insert(e,t,n){return new Kr(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};var yt=class r{constructor(e){this.comparator=e,this.data=new Ye(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((t,n)=>(e(t),!1))}forEachInRange(e,t){let n=this.data.getIteratorFrom(e[0]);for(;n.hasNext();){let s=n.getNext();if(this.comparator(s.key,e[1])>=0)return;t(s.key)}}forEachWhile(e,t){let n;for(n=t!==void 0?this.data.getIteratorFrom(t):this.data.getIterator();n.hasNext();)if(!e(n.getNext().key))return}firstAfterOrEqual(e){let t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new ah(this.data.getIterator())}getIteratorFrom(e){return new ah(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach(n=>{t=t.add(n)}),t}isEqual(e){if(!(e instanceof r)||this.size!==e.size)return!1;let t=this.data.getIterator(),n=e.data.getIterator();for(;t.hasNext();){let s=t.getNext().key,a=n.getNext().key;if(this.comparator(s,a)!==0)return!1}return!0}toArray(){let e=[];return this.forEach(t=>{e.push(t)}),e}toString(){let e=[];return this.forEach(t=>e.push(t)),"SortedSet("+e.toString()+")"}copy(e){let t=new r(this.comparator);return t.data=e,t}},ah=class{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}};var hr=class r{constructor(e){this.fields=e,e.sort(tr.comparator)}static empty(){return new r([])}unionWith(e){let t=new yt(tr.comparator);for(let n of this.fields)t=t.add(n);for(let n of e)t=t.add(n);return new r(t.toArray())}covers(e){for(let t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return Lo(this.fields,e.fields,(t,n)=>t.isEqual(n))}};var uh=class extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}};var Rt=class r{constructor(e){this.binaryString=e}static fromBase64String(e){let t=function(s){try{return atob(s)}catch(a){throw typeof DOMException!="undefined"&&a instanceof DOMException?new uh("Invalid base64 string: "+a):a}}(e);return new r(t)}static fromUint8Array(e){let t=function(s){let a="";for(let c=0;c<s.length;++c)a+=String.fromCharCode(s[c]);return a}(e);return new r(t)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return function(t){return btoa(t)}(this.binaryString)}toUint8Array(){return function(t){let n=new Uint8Array(t.length);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return Re(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}};Rt.EMPTY_BYTE_STRING=new Rt("");var Y2=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Cn(r){if(Le(!!r),typeof r=="string"){let e=0,t=Y2.exec(r);if(Le(!!t),t[1]){let s=t[1];s=(s+"000000000").substr(0,9),e=Number(s)}let n=new Date(r);return{seconds:Math.floor(n.getTime()/1e3),nanos:e}}return{seconds:Ge(r.seconds),nanos:Ge(r.nanos)}}function Ge(r){return typeof r=="number"?r:typeof r=="string"?Number(r):0}function Dn(r){return typeof r=="string"?Rt.fromBase64String(r):Rt.fromUint8Array(r)}var Hb="server_timestamp",Qb="__type__",Jb="__previous_value__",Yb="__local_write_time__";function eg(r){var e,t;return((t=(((e=r==null?void 0:r.mapValue)===null||e===void 0?void 0:e.fields)||{})[Qb])===null||t===void 0?void 0:t.stringValue)===Hb}function $h(r){let e=r.mapValue.fields[Jb];return eg(e)?$h(e):e}function _u(r){let e=Cn(r.mapValue.fields[Yb].timestampValue);return new wt(e.seconds,e.nanos)}var xp=class{constructor(e,t,n,s,a,c,h,f,m){this.databaseId=e,this.appId=t,this.persistenceKey=n,this.host=s,this.ssl=a,this.forceLongPolling=c,this.autoDetectLongPolling=h,this.longPollingOptions=f,this.useFetchStreams=m}},ch="(default)",lh=class r{constructor(e,t){this.projectId=e,this.database=t||ch}static empty(){return new r("","")}get isDefaultDatabase(){return this.database===ch}isEqual(e){return e instanceof r&&e.projectId===this.projectId&&e.database===this.database}};var tg="__type__",Xb="__max__",Yl={mapValue:{fields:{__type__:{stringValue:Xb}}}},rg="__vector__",Fo="value";function yi(r){return"nullValue"in r?0:"booleanValue"in r?1:"integerValue"in r||"doubleValue"in r?2:"timestampValue"in r?3:"stringValue"in r?5:"bytesValue"in r?6:"referenceValue"in r?7:"geoPointValue"in r?8:"arrayValue"in r?9:"mapValue"in r?eg(r)?4:eT(r)?9007199254740991:Zb(r)?10:11:ue()}function Jr(r,e){if(r===e)return!0;let t=yi(r);if(t!==yi(e))return!1;switch(t){case 0:case 9007199254740991:return!0;case 1:return r.booleanValue===e.booleanValue;case 4:return _u(r).isEqual(_u(e));case 3:return function(s,a){if(typeof s.timestampValue=="string"&&typeof a.timestampValue=="string"&&s.timestampValue.length===a.timestampValue.length)return s.timestampValue===a.timestampValue;let c=Cn(s.timestampValue),h=Cn(a.timestampValue);return c.seconds===h.seconds&&c.nanos===h.nanos}(r,e);case 5:return r.stringValue===e.stringValue;case 6:return function(s,a){return Dn(s.bytesValue).isEqual(Dn(a.bytesValue))}(r,e);case 7:return r.referenceValue===e.referenceValue;case 8:return function(s,a){return Ge(s.geoPointValue.latitude)===Ge(a.geoPointValue.latitude)&&Ge(s.geoPointValue.longitude)===Ge(a.geoPointValue.longitude)}(r,e);case 2:return function(s,a){if("integerValue"in s&&"integerValue"in a)return Ge(s.integerValue)===Ge(a.integerValue);if("doubleValue"in s&&"doubleValue"in a){let c=Ge(s.doubleValue),h=Ge(a.doubleValue);return c===h?gu(c)===gu(h):isNaN(c)&&isNaN(h)}return!1}(r,e);case 9:return Lo(r.arrayValue.values||[],e.arrayValue.values||[],Jr);case 10:case 11:return function(s,a){let c=s.mapValue.fields||{},h=a.mapValue.fields||{};if(X0(c)!==X0(h))return!1;for(let f in c)if(c.hasOwnProperty(f)&&(h[f]===void 0||!Jr(c[f],h[f])))return!1;return!0}(r,e);default:return ue()}}function yu(r,e){return(r.values||[]).find(t=>Jr(t,e))!==void 0}function Uo(r,e){if(r===e)return 0;let t=yi(r),n=yi(e);if(t!==n)return Re(t,n);switch(t){case 0:case 9007199254740991:return 0;case 1:return Re(r.booleanValue,e.booleanValue);case 2:return function(a,c){let h=Ge(a.integerValue||a.doubleValue),f=Ge(c.integerValue||c.doubleValue);return h<f?-1:h>f?1:h===f?0:isNaN(h)?isNaN(f)?0:-1:1}(r,e);case 3:return Z0(r.timestampValue,e.timestampValue);case 4:return Z0(_u(r),_u(e));case 5:return Re(r.stringValue,e.stringValue);case 6:return function(a,c){let h=Dn(a),f=Dn(c);return h.compareTo(f)}(r.bytesValue,e.bytesValue);case 7:return function(a,c){let h=a.split("/"),f=c.split("/");for(let m=0;m<h.length&&m<f.length;m++){let _=Re(h[m],f[m]);if(_!==0)return _}return Re(h.length,f.length)}(r.referenceValue,e.referenceValue);case 8:return function(a,c){let h=Re(Ge(a.latitude),Ge(c.latitude));return h!==0?h:Re(Ge(a.longitude),Ge(c.longitude))}(r.geoPointValue,e.geoPointValue);case 9:return eb(r.arrayValue,e.arrayValue);case 10:return function(a,c){var h,f,m,_;let E=a.fields||{},I=c.fields||{},k=(h=E[Fo])===null||h===void 0?void 0:h.arrayValue,B=(f=I[Fo])===null||f===void 0?void 0:f.arrayValue,G=Re(((m=k==null?void 0:k.values)===null||m===void 0?void 0:m.length)||0,((_=B==null?void 0:B.values)===null||_===void 0?void 0:_.length)||0);return G!==0?G:eb(k,B)}(r.mapValue,e.mapValue);case 11:return function(a,c){if(a===Yl.mapValue&&c===Yl.mapValue)return 0;if(a===Yl.mapValue)return 1;if(c===Yl.mapValue)return-1;let h=a.fields||{},f=Object.keys(h),m=c.fields||{},_=Object.keys(m);f.sort(),_.sort();for(let E=0;E<f.length&&E<_.length;++E){let I=Re(f[E],_[E]);if(I!==0)return I;let k=Uo(h[f[E]],m[_[E]]);if(k!==0)return k}return Re(f.length,_.length)}(r.mapValue,e.mapValue);default:throw ue()}}function Z0(r,e){if(typeof r=="string"&&typeof e=="string"&&r.length===e.length)return Re(r,e);let t=Cn(r),n=Cn(e),s=Re(t.seconds,n.seconds);return s!==0?s:Re(t.nanos,n.nanos)}function eb(r,e){let t=r.values||[],n=e.values||[];for(let s=0;s<t.length&&s<n.length;++s){let a=Uo(t[s],n[s]);if(a)return a}return Re(t.length,n.length)}function Bo(r){return Ap(r)}function Ap(r){return"nullValue"in r?"null":"booleanValue"in r?""+r.booleanValue:"integerValue"in r?""+r.integerValue:"doubleValue"in r?""+r.doubleValue:"timestampValue"in r?function(t){let n=Cn(t);return`time(${n.seconds},${n.nanos})`}(r.timestampValue):"stringValue"in r?r.stringValue:"bytesValue"in r?function(t){return Dn(t).toBase64()}(r.bytesValue):"referenceValue"in r?function(t){return ce.fromName(t).toString()}(r.referenceValue):"geoPointValue"in r?function(t){return`geo(${t.latitude},${t.longitude})`}(r.geoPointValue):"arrayValue"in r?function(t){let n="[",s=!0;for(let a of t.values||[])s?s=!1:n+=",",n+=Ap(a);return n+"]"}(r.arrayValue):"mapValue"in r?function(t){let n=Object.keys(t.fields||{}).sort(),s="{",a=!0;for(let c of n)a?a=!1:s+=",",s+=`${c}:${Ap(t.fields[c])}`;return s+"}"}(r.mapValue):ue()}function eh(r){switch(yi(r)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:let e=$h(r);return e?16+eh(e):16;case 5:return 2*r.stringValue.length;case 6:return Dn(r.bytesValue).approximateByteSize();case 7:return r.referenceValue.length;case 9:return function(n){return(n.values||[]).reduce((s,a)=>s+eh(a),0)}(r.arrayValue);case 10:case 11:return function(n){let s=0;return Ti(n.fields,(a,c)=>{s+=a.length+eh(c)}),s}(r.mapValue);default:throw ue()}}function Sp(r){return!!r&&"integerValue"in r}function ng(r){return!!r&&"arrayValue"in r}function tb(r){return!!r&&"nullValue"in r}function rb(r){return!!r&&"doubleValue"in r&&isNaN(Number(r.doubleValue))}function th(r){return!!r&&"mapValue"in r}function Zb(r){var e,t;return((t=(((e=r==null?void 0:r.mapValue)===null||e===void 0?void 0:e.fields)||{})[tg])===null||t===void 0?void 0:t.stringValue)===rg}function hu(r){if(r.geoPointValue)return{geoPointValue:Object.assign({},r.geoPointValue)};if(r.timestampValue&&typeof r.timestampValue=="object")return{timestampValue:Object.assign({},r.timestampValue)};if(r.mapValue){let e={mapValue:{fields:{}}};return Ti(r.mapValue.fields,(t,n)=>e.mapValue.fields[t]=hu(n)),e}if(r.arrayValue){let e={arrayValue:{values:[]}};for(let t=0;t<(r.arrayValue.values||[]).length;++t)e.arrayValue.values[t]=hu(r.arrayValue.values[t]);return e}return Object.assign({},r)}function eT(r){return(((r.mapValue||{}).fields||{}).__type__||{}).stringValue===Xb}var vK={mapValue:{fields:{[tg]:{stringValue:rg},[Fo]:{arrayValue:{}}}}};var er=class r{constructor(e){this.value=e}static empty(){return new r({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let n=0;n<e.length-1;++n)if(t=(t.mapValue.fields||{})[e.get(n)],!th(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=hu(t)}setAll(e){let t=tr.emptyPath(),n={},s=[];e.forEach((c,h)=>{if(!t.isImmediateParentOf(h)){let f=this.getFieldsMap(t);this.applyChanges(f,n,s),n={},s=[],t=h.popLast()}c?n[h.lastSegment()]=hu(c):s.push(h.lastSegment())});let a=this.getFieldsMap(t);this.applyChanges(a,n,s)}delete(e){let t=this.field(e.popLast());th(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return Jr(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let n=0;n<e.length;++n){let s=t.mapValue.fields[e.get(n)];th(s)&&s.mapValue.fields||(s={mapValue:{fields:{}}},t.mapValue.fields[e.get(n)]=s),t=s}return t.mapValue.fields}applyChanges(e,t,n){Ti(t,(s,a)=>e[s]=a);for(let s of n)delete e[s]}clone(){return new r(hu(this.value))}};function tT(r){let e=[];return Ti(r.fields,(t,n)=>{let s=new tr([t]);if(th(n)){let a=tT(n.mapValue).fields;if(a.length===0)e.push(s);else for(let c of a)e.push(s.child(c))}else e.push(s)}),new hr(e)}var Sr=class r{constructor(e,t,n,s,a,c,h){this.key=e,this.documentType=t,this.version=n,this.readTime=s,this.createTime=a,this.data=c,this.documentState=h}static newInvalidDocument(e){return new r(e,0,me.min(),me.min(),me.min(),er.empty(),0)}static newFoundDocument(e,t,n,s){return new r(e,1,t,me.min(),n,s,0)}static newNoDocument(e,t){return new r(e,2,t,me.min(),me.min(),er.empty(),0)}static newUnknownDocument(e,t){return new r(e,3,t,me.min(),me.min(),er.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(me.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=er.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=er.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=me.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(e){return e instanceof r&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new r(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}};var jo=class{constructor(e,t){this.position=e,this.inclusive=t}};function nb(r,e,t){let n=0;for(let s=0;s<r.position.length;s++){let a=e[s],c=r.position[s];if(a.field.isKeyField()?n=ce.comparator(ce.fromName(c.referenceValue),t.key):n=Uo(c,t.data.field(a.field)),a.dir==="desc"&&(n*=-1),n!==0)break}return n}function ib(r,e){if(r===null)return e===null;if(e===null||r.inclusive!==e.inclusive||r.position.length!==e.position.length)return!1;for(let t=0;t<r.position.length;t++)if(!Jr(r.position[t],e.position[t]))return!1;return!0}var $o=class{constructor(e,t="asc"){this.field=e,this.dir=t}};function X2(r,e){return r.dir===e.dir&&r.field.isEqual(e.field)}var hh=class{},pt=class r extends hh{constructor(e,t,n){super(),this.field=e,this.op=t,this.value=n}static create(e,t,n){return e.isKeyField()?t==="in"||t==="not-in"?this.createKeyFieldInFilter(e,t,n):new Pp(e,t,n):t==="array-contains"?new Op(e,n):t==="in"?new kp(e,n):t==="not-in"?new Np(e,n):t==="array-contains-any"?new Vp(e,n):new r(e,t,n)}static createKeyFieldInFilter(e,t,n){return t==="in"?new Cp(e,n):new Dp(e,n)}matches(e){let t=e.data.field(this.field);return this.op==="!="?t!==null&&this.matchesComparison(Uo(t,this.value)):t!==null&&yi(this.value)===yi(t)&&this.matchesComparison(Uo(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return ue()}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}},Yr=class r extends hh{constructor(e,t){super(),this.filters=e,this.op=t,this.ce=null}static create(e,t){return new r(e,t)}matches(e){return rT(this)?this.filters.find(t=>!t.matches(e))===void 0:this.filters.find(t=>t.matches(e))!==void 0}getFlattenedFilters(){return this.ce!==null||(this.ce=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.ce}getFilters(){return Object.assign([],this.filters)}};function rT(r){return r.op==="and"}function nT(r){return Z2(r)&&rT(r)}function Z2(r){for(let e of r.filters)if(e instanceof Yr)return!1;return!0}function Rp(r){if(r instanceof pt)return r.field.canonicalString()+r.op.toString()+Bo(r.value);if(nT(r))return r.filters.map(e=>Rp(e)).join(",");{let e=r.filters.map(t=>Rp(t)).join(",");return`${r.op}(${e})`}}function iT(r,e){return r instanceof pt?function(n,s){return s instanceof pt&&n.op===s.op&&n.field.isEqual(s.field)&&Jr(n.value,s.value)}(r,e):r instanceof Yr?function(n,s){return s instanceof Yr&&n.op===s.op&&n.filters.length===s.filters.length?n.filters.reduce((a,c,h)=>a&&iT(c,s.filters[h]),!0):!1}(r,e):void ue()}function sT(r){return r instanceof pt?function(t){return`${t.field.canonicalString()} ${t.op} ${Bo(t.value)}`}(r):r instanceof Yr?function(t){return t.op.toString()+" {"+t.getFilters().map(sT).join(" ,")+"}"}(r):"Filter"}var Pp=class extends pt{constructor(e,t,n){super(e,t,n),this.key=ce.fromName(n.referenceValue)}matches(e){let t=ce.comparator(e.key,this.key);return this.matchesComparison(t)}},Cp=class extends pt{constructor(e,t){super(e,"in",t),this.keys=oT("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}},Dp=class extends pt{constructor(e,t){super(e,"not-in",t),this.keys=oT("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}};function oT(r,e){var t;return(((t=e.arrayValue)===null||t===void 0?void 0:t.values)||[]).map(n=>ce.fromName(n.referenceValue))}var Op=class extends pt{constructor(e,t){super(e,"array-contains",t)}matches(e){let t=e.data.field(this.field);return ng(t)&&yu(t.arrayValue,this.value)}},kp=class extends pt{constructor(e,t){super(e,"in",t)}matches(e){let t=e.data.field(this.field);return t!==null&&yu(this.value.arrayValue,t)}},Np=class extends pt{constructor(e,t){super(e,"not-in",t)}matches(e){if(yu(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;let t=e.data.field(this.field);return t!==null&&!yu(this.value.arrayValue,t)}},Vp=class extends pt{constructor(e,t){super(e,"array-contains-any",t)}matches(e){let t=e.data.field(this.field);return!(!ng(t)||!t.arrayValue.values)&&t.arrayValue.values.some(n=>yu(this.value.arrayValue,n))}};var Lp=class{constructor(e,t=null,n=[],s=[],a=null,c=null,h=null){this.path=e,this.collectionGroup=t,this.orderBy=n,this.filters=s,this.limit=a,this.startAt=c,this.endAt=h,this.le=null}};function sb(r,e=null,t=[],n=[],s=null,a=null,c=null){return new Lp(r,e,t,n,s,a,c)}function ig(r){let e=fe(r);if(e.le===null){let t=e.path.canonicalString();e.collectionGroup!==null&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map(n=>Rp(n)).join(","),t+="|ob:",t+=e.orderBy.map(n=>function(a){return a.field.canonicalString()+a.dir}(n)).join(","),jh(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(n=>Bo(n)).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(n=>Bo(n)).join(",")),e.le=t}return e.le}function sg(r,e){if(r.limit!==e.limit||r.orderBy.length!==e.orderBy.length)return!1;for(let t=0;t<r.orderBy.length;t++)if(!X2(r.orderBy[t],e.orderBy[t]))return!1;if(r.filters.length!==e.filters.length)return!1;for(let t=0;t<r.filters.length;t++)if(!iT(r.filters[t],e.filters[t]))return!1;return r.collectionGroup===e.collectionGroup&&!!r.path.isEqual(e.path)&&!!ib(r.startAt,e.startAt)&&ib(r.endAt,e.endAt)}function Mp(r){return ce.isDocumentKey(r.path)&&r.collectionGroup===null&&r.filters.length===0}var qo=class{constructor(e,t=null,n=[],s=[],a=null,c="F",h=null,f=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=n,this.filters=s,this.limit=a,this.limitType=c,this.startAt=h,this.endAt=f,this.he=null,this.Pe=null,this.Te=null,this.startAt,this.endAt}};function eM(r,e,t,n,s,a,c,h){return new qo(r,e,t,n,s,a,c,h)}function qh(r){return new qo(r)}function ob(r){return r.filters.length===0&&r.limit===null&&r.startAt==null&&r.endAt==null&&(r.explicitOrderBy.length===0||r.explicitOrderBy.length===1&&r.explicitOrderBy[0].field.isKeyField())}function tM(r){return r.collectionGroup!==null}function fu(r){let e=fe(r);if(e.he===null){e.he=[];let t=new Set;for(let a of e.explicitOrderBy)e.he.push(a),t.add(a.field.canonicalString());let n=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(c){let h=new yt(tr.comparator);return c.filters.forEach(f=>{f.getFlattenedFilters().forEach(m=>{m.isInequality()&&(h=h.add(m.field))})}),h})(e).forEach(a=>{t.has(a.canonicalString())||a.isKeyField()||e.he.push(new $o(a,n))}),t.has(tr.keyField().canonicalString())||e.he.push(new $o(tr.keyField(),n))}return e.he}function Wr(r){let e=fe(r);return e.Pe||(e.Pe=rM(e,fu(r))),e.Pe}function rM(r,e){if(r.limitType==="F")return sb(r.path,r.collectionGroup,e,r.filters,r.limit,r.startAt,r.endAt);{e=e.map(s=>{let a=s.dir==="desc"?"asc":"desc";return new $o(s.field,a)});let t=r.endAt?new jo(r.endAt.position,r.endAt.inclusive):null,n=r.startAt?new jo(r.startAt.position,r.startAt.inclusive):null;return sb(r.path,r.collectionGroup,e,r.filters,r.limit,t,n)}}function Fp(r,e,t){return new qo(r.path,r.collectionGroup,r.explicitOrderBy.slice(),r.filters.slice(),e,t,r.startAt,r.endAt)}function zh(r,e){return sg(Wr(r),Wr(e))&&r.limitType===e.limitType}function aT(r){return`${ig(Wr(r))}|lt:${r.limitType}`}function Po(r){return`Query(target=${function(t){let n=t.path.canonicalString();return t.collectionGroup!==null&&(n+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(n+=`, filters: [${t.filters.map(s=>sT(s)).join(", ")}]`),jh(t.limit)||(n+=", limit: "+t.limit),t.orderBy.length>0&&(n+=`, orderBy: [${t.orderBy.map(s=>function(c){return`${c.field.canonicalString()} (${c.dir})`}(s)).join(", ")}]`),t.startAt&&(n+=", startAt: ",n+=t.startAt.inclusive?"b:":"a:",n+=t.startAt.position.map(s=>Bo(s)).join(",")),t.endAt&&(n+=", endAt: ",n+=t.endAt.inclusive?"a:":"b:",n+=t.endAt.position.map(s=>Bo(s)).join(",")),`Target(${n})`}(Wr(r))}; limitType=${r.limitType})`}function Gh(r,e){return e.isFoundDocument()&&function(n,s){let a=s.key.path;return n.collectionGroup!==null?s.key.hasCollectionId(n.collectionGroup)&&n.path.isPrefixOf(a):ce.isDocumentKey(n.path)?n.path.isEqual(a):n.path.isImmediateParentOf(a)}(r,e)&&function(n,s){for(let a of fu(n))if(!a.field.isKeyField()&&s.data.field(a.field)===null)return!1;return!0}(r,e)&&function(n,s){for(let a of n.filters)if(!a.matches(s))return!1;return!0}(r,e)&&function(n,s){return!(n.startAt&&!function(c,h,f){let m=nb(c,h,f);return c.inclusive?m<=0:m<0}(n.startAt,fu(n),s)||n.endAt&&!function(c,h,f){let m=nb(c,h,f);return c.inclusive?m>=0:m>0}(n.endAt,fu(n),s))}(r,e)}function nM(r){return r.collectionGroup||(r.path.length%2==1?r.path.lastSegment():r.path.get(r.path.length-2))}function uT(r){return(e,t)=>{let n=!1;for(let s of fu(r)){let a=iM(s,e,t);if(a!==0)return a;n=n||s.field.isKeyField()}return 0}}function iM(r,e,t){let n=r.field.isKeyField()?ce.comparator(e.key,t.key):function(a,c,h){let f=c.data.field(a),m=h.data.field(a);return f!==null&&m!==null?Uo(f,m):ue()}(r.field,e,t);switch(r.dir){case"asc":return n;case"desc":return-1*n;default:return ue()}}var On=class{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){let t=this.mapKeyFn(e),n=this.inner[t];if(n!==void 0){for(let[s,a]of n)if(this.equalsFn(s,e))return a}}has(e){return this.get(e)!==void 0}set(e,t){let n=this.mapKeyFn(e),s=this.inner[n];if(s===void 0)return this.inner[n]=[[e,t]],void this.innerSize++;for(let a=0;a<s.length;a++)if(this.equalsFn(s[a][0],e))return void(s[a]=[e,t]);s.push([e,t]),this.innerSize++}delete(e){let t=this.mapKeyFn(e),n=this.inner[t];if(n===void 0)return!1;for(let s=0;s<n.length;s++)if(this.equalsFn(n[s][0],e))return n.length===1?delete this.inner[t]:n.splice(s,1),this.innerSize--,!0;return!1}forEach(e){Ti(this.inner,(t,n)=>{for(let[s,a]of n)e(s,a)})}isEmpty(){return Wb(this.inner)}size(){return this.innerSize}};var sM=new Ye(ce.comparator);function kn(){return sM}var cT=new Ye(ce.comparator);function lu(...r){let e=cT;for(let t of r)e=e.insert(t.key,t);return e}function lT(r){let e=cT;return r.forEach((t,n)=>e=e.insert(t,n.overlayedDocument)),e}function os(){return du()}function hT(){return du()}function du(){return new On(r=>r.toString(),(r,e)=>r.isEqual(e))}var oM=new Ye(ce.comparator),aM=new yt(ce.comparator);function xe(...r){let e=aM;for(let t of r)e=e.add(t);return e}var uM=new yt(Re);function cM(){return uM}function og(r,e){if(r.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:gu(e)?"-0":e}}function fT(r){return{integerValue:""+r}}function lM(r,e){return F2(e)?fT(e):og(r,e)}var zo=class{constructor(){this._=void 0}};function hM(r,e,t){return r instanceof Go?function(s,a){let c={fields:{[Qb]:{stringValue:Hb},[Yb]:{timestampValue:{seconds:s.seconds,nanos:s.nanoseconds}}}};return a&&eg(a)&&(a=$h(a)),a&&(c.fields[Jb]=a),{mapValue:c}}(t,e):r instanceof hs?pT(r,e):r instanceof fs?mT(r,e):function(s,a){let c=dT(s,a),h=ab(c)+ab(s.Ie);return Sp(c)&&Sp(s.Ie)?fT(h):og(s.serializer,h)}(r,e)}function fM(r,e,t){return r instanceof hs?pT(r,e):r instanceof fs?mT(r,e):t}function dT(r,e){return r instanceof Ko?function(n){return Sp(n)||function(a){return!!a&&"doubleValue"in a}(n)}(e)?e:{integerValue:0}:null}var Go=class extends zo{},hs=class extends zo{constructor(e){super(),this.elements=e}};function pT(r,e){let t=gT(e);for(let n of r.elements)t.some(s=>Jr(s,n))||t.push(n);return{arrayValue:{values:t}}}var fs=class extends zo{constructor(e){super(),this.elements=e}};function mT(r,e){let t=gT(e);for(let n of r.elements)t=t.filter(s=>!Jr(s,n));return{arrayValue:{values:t}}}var Ko=class extends zo{constructor(e,t){super(),this.serializer=e,this.Ie=t}};function ab(r){return Ge(r.integerValue||r.doubleValue)}function gT(r){return ng(r)&&r.arrayValue.values?r.arrayValue.values.slice():[]}function dM(r,e){return r.field.isEqual(e.field)&&function(n,s){return n instanceof hs&&s instanceof hs||n instanceof fs&&s instanceof fs?Lo(n.elements,s.elements,Jr):n instanceof Ko&&s instanceof Ko?Jr(n.Ie,s.Ie):n instanceof Go&&s instanceof Go}(r.transform,e.transform)}var Up=class{constructor(e,t){this.version=e,this.transformResults=t}},_i=class r{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new r}static exists(e){return new r(void 0,e)}static updateTime(e){return new r(e)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}};function rh(r,e){return r.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(r.updateTime):r.exists===void 0||r.exists===e.isFoundDocument()}var Wo=class{};function _T(r,e){if(!r.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return r.isNoDocument()?new fh(r.key,_i.none()):new ds(r.key,r.data,_i.none());{let t=r.data,n=er.empty(),s=new yt(tr.comparator);for(let a of e.fields)if(!s.has(a)){let c=t.field(a);c===null&&a.length>1&&(a=a.popLast(),c=t.field(a)),c===null?n.delete(a):n.set(a,c),s=s.add(a)}return new Xr(r.key,n,new hr(s.toArray()),_i.none())}}function pM(r,e,t){r instanceof ds?function(s,a,c){let h=s.value.clone(),f=cb(s.fieldTransforms,a,c.transformResults);h.setAll(f),a.convertToFoundDocument(c.version,h).setHasCommittedMutations()}(r,e,t):r instanceof Xr?function(s,a,c){if(!rh(s.precondition,a))return void a.convertToUnknownDocument(c.version);let h=cb(s.fieldTransforms,a,c.transformResults),f=a.data;f.setAll(yT(s)),f.setAll(h),a.convertToFoundDocument(c.version,f).setHasCommittedMutations()}(r,e,t):function(s,a,c){a.convertToNoDocument(c.version).setHasCommittedMutations()}(0,e,t)}function pu(r,e,t,n){return r instanceof ds?function(a,c,h,f){if(!rh(a.precondition,c))return h;let m=a.value.clone(),_=lb(a.fieldTransforms,f,c);return m.setAll(_),c.convertToFoundDocument(c.version,m).setHasLocalMutations(),null}(r,e,t,n):r instanceof Xr?function(a,c,h,f){if(!rh(a.precondition,c))return h;let m=lb(a.fieldTransforms,f,c),_=c.data;return _.setAll(yT(a)),_.setAll(m),c.convertToFoundDocument(c.version,_).setHasLocalMutations(),h===null?null:h.unionWith(a.fieldMask.fields).unionWith(a.fieldTransforms.map(E=>E.field))}(r,e,t,n):function(a,c,h){return rh(a.precondition,c)?(c.convertToNoDocument(c.version).setHasLocalMutations(),null):h}(r,e,t)}function mM(r,e){let t=null;for(let n of r.fieldTransforms){let s=e.data.field(n.field),a=dT(n.transform,s||null);a!=null&&(t===null&&(t=er.empty()),t.set(n.field,a))}return t||null}function ub(r,e){return r.type===e.type&&!!r.key.isEqual(e.key)&&!!r.precondition.isEqual(e.precondition)&&!!function(n,s){return n===void 0&&s===void 0||!(!n||!s)&&Lo(n,s,(a,c)=>dM(a,c))}(r.fieldTransforms,e.fieldTransforms)&&(r.type===0?r.value.isEqual(e.value):r.type!==1||r.data.isEqual(e.data)&&r.fieldMask.isEqual(e.fieldMask))}var ds=class extends Wo{constructor(e,t,n,s=[]){super(),this.key=e,this.value=t,this.precondition=n,this.fieldTransforms=s,this.type=0}getFieldMask(){return null}},Xr=class extends Wo{constructor(e,t,n,s,a=[]){super(),this.key=e,this.data=t,this.fieldMask=n,this.precondition=s,this.fieldTransforms=a,this.type=1}getFieldMask(){return this.fieldMask}};function yT(r){let e=new Map;return r.fieldMask.fields.forEach(t=>{if(!t.isEmpty()){let n=r.data.field(t);e.set(t,n)}}),e}function cb(r,e,t){let n=new Map;Le(r.length===t.length);for(let s=0;s<t.length;s++){let a=r[s],c=a.transform,h=e.data.field(a.field);n.set(a.field,fM(c,h,t[s]))}return n}function lb(r,e,t){let n=new Map;for(let s of r){let a=s.transform,c=t.data.field(s.field);n.set(s.field,hM(a,c,e))}return n}var fh=class extends Wo{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}},Bp=class extends Wo{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}};var jp=class{constructor(e,t,n,s){this.batchId=e,this.localWriteTime=t,this.baseMutations=n,this.mutations=s}applyToRemoteDocument(e,t){let n=t.mutationResults;for(let s=0;s<this.mutations.length;s++){let a=this.mutations[s];a.key.isEqual(e.key)&&pM(a,e,n[s])}}applyToLocalView(e,t){for(let n of this.baseMutations)n.key.isEqual(e.key)&&(t=pu(n,e,t,this.localWriteTime));for(let n of this.mutations)n.key.isEqual(e.key)&&(t=pu(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){let n=hT();return this.mutations.forEach(s=>{let a=e.get(s.key),c=a.overlayedDocument,h=this.applyToLocalView(c,a.mutatedFields);h=t.has(s.key)?null:h;let f=_T(c,h);f!==null&&n.set(s.key,f),c.isValidDocument()||c.convertToNoDocument(me.min())}),n}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),xe())}isEqual(e){return this.batchId===e.batchId&&Lo(this.mutations,e.mutations,(t,n)=>ub(t,n))&&Lo(this.baseMutations,e.baseMutations,(t,n)=>ub(t,n))}},$p=class r{constructor(e,t,n,s){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=s}static from(e,t,n){Le(e.mutations.length===n.length);let s=function(){return oM}(),a=e.mutations;for(let c=0;c<a.length;c++)s=s.insert(a[c].key,n[c].version);return new r(e,t,n,s)}};var qp=class{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{
29
29
  largestBatchId: ${this.largestBatchId},
30
30
  mutation: ${this.mutation.toString()}
31
- }`}};var $p=class{constructor(e,t){this.count=e,this.unchangedNames=t}};var rt,Pe;function fM(n){switch(n){case H.OK:return ue();case H.CANCELLED:case H.UNKNOWN:case H.DEADLINE_EXCEEDED:case H.RESOURCE_EXHAUSTED:case H.INTERNAL:case H.UNAVAILABLE:case H.UNAUTHENTICATED:return!1;case H.INVALID_ARGUMENT:case H.NOT_FOUND:case H.ALREADY_EXISTS:case H.PERMISSION_DENIED:case H.FAILED_PRECONDITION:case H.ABORTED:case H.OUT_OF_RANGE:case H.UNIMPLEMENTED:case H.DATA_LOSS:return!0;default:return ue()}}function _T(n){if(n===void 0)return Pr("GRPC error has no .code"),H.UNKNOWN;switch(n){case rt.OK:return H.OK;case rt.CANCELLED:return H.CANCELLED;case rt.UNKNOWN:return H.UNKNOWN;case rt.DEADLINE_EXCEEDED:return H.DEADLINE_EXCEEDED;case rt.RESOURCE_EXHAUSTED:return H.RESOURCE_EXHAUSTED;case rt.INTERNAL:return H.INTERNAL;case rt.UNAVAILABLE:return H.UNAVAILABLE;case rt.UNAUTHENTICATED:return H.UNAUTHENTICATED;case rt.INVALID_ARGUMENT:return H.INVALID_ARGUMENT;case rt.NOT_FOUND:return H.NOT_FOUND;case rt.ALREADY_EXISTS:return H.ALREADY_EXISTS;case rt.PERMISSION_DENIED:return H.PERMISSION_DENIED;case rt.FAILED_PRECONDITION:return H.FAILED_PRECONDITION;case rt.ABORTED:return H.ABORTED;case rt.OUT_OF_RANGE:return H.OUT_OF_RANGE;case rt.UNIMPLEMENTED:return H.UNIMPLEMENTED;case rt.DATA_LOSS:return H.DATA_LOSS;default:return ue()}}(Pe=rt||(rt={}))[Pe.OK=0]="OK",Pe[Pe.CANCELLED=1]="CANCELLED",Pe[Pe.UNKNOWN=2]="UNKNOWN",Pe[Pe.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Pe[Pe.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Pe[Pe.NOT_FOUND=5]="NOT_FOUND",Pe[Pe.ALREADY_EXISTS=6]="ALREADY_EXISTS",Pe[Pe.PERMISSION_DENIED=7]="PERMISSION_DENIED",Pe[Pe.UNAUTHENTICATED=16]="UNAUTHENTICATED",Pe[Pe.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Pe[Pe.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Pe[Pe.ABORTED=10]="ABORTED",Pe[Pe.OUT_OF_RANGE=11]="OUT_OF_RANGE",Pe[Pe.UNIMPLEMENTED=12]="UNIMPLEMENTED",Pe[Pe.INTERNAL=13]="INTERNAL",Pe[Pe.UNAVAILABLE=14]="UNAVAILABLE",Pe[Pe.DATA_LOSS=15]="DATA_LOSS";var cb=null;function dM(){return new TextEncoder}var pM=new Sr([4294967295,4294967295],0);function lb(n){let e=dM().encode(n),t=new sp;return t.update(e),new Uint8Array(t.digest())}function hb(n){let e=new DataView(n.buffer),t=e.getUint32(0,!0),r=e.getUint32(4,!0),s=e.getUint32(8,!0),a=e.getUint32(12,!0);return[new Sr([t,r],0),new Sr([s,a],0)]}var qp=class n{constructor(e,t,r){if(this.bitmap=e,this.padding=t,this.hashCount=r,t<0||t>=8)throw new as(`Invalid padding: ${t}`);if(r<0)throw new as(`Invalid hash count: ${r}`);if(e.length>0&&this.hashCount===0)throw new as(`Invalid hash count: ${r}`);if(e.length===0&&t!==0)throw new as(`Invalid padding when bitmap length is 0: ${t}`);this.Ee=8*e.length-t,this.de=Sr.fromNumber(this.Ee)}Ae(e,t,r){let s=e.add(t.multiply(Sr.fromNumber(r)));return s.compare(pM)===1&&(s=new Sr([s.getBits(0),s.getBits(1)],0)),s.modulo(this.de).toNumber()}Re(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(this.Ee===0)return!1;let t=lb(e),[r,s]=hb(t);for(let a=0;a<this.hashCount;a++){let c=this.Ae(r,s,a);if(!this.Re(c))return!1}return!0}static create(e,t,r){let s=e%8==0?0:8-e%8,a=new Uint8Array(Math.ceil(e/8)),c=new n(a,s,t);return r.forEach(h=>c.insert(h)),c}insert(e){if(this.Ee===0)return;let t=lb(e),[r,s]=hb(t);for(let a=0;a<this.hashCount;a++){let c=this.Ae(r,s,a);this.Ve(c)}}Ve(e){let t=Math.floor(e/8),r=e%8;this.bitmap[t]|=1<<r}},as=class extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}};var fh=class n{constructor(e,t,r,s,a){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=r,this.documentUpdates=s,this.resolvedLimboDocuments=a}static createSynthesizedRemoteEventForCurrentChange(e,t,r){let s=new Map;return s.set(e,yu.createSynthesizedTargetChangeForCurrentChange(e,t,r)),new n(me.min(),s,new Je(Re),kr(),xe())}},yu=class n{constructor(e,t,r,s,a){this.resumeToken=e,this.current=t,this.addedDocuments=r,this.modifiedDocuments=s,this.removedDocuments=a}static createSynthesizedTargetChangeForCurrentChange(e,t,r){return new n(r,t,xe(),xe(),xe())}};var Oo=class{constructor(e,t,r,s){this.me=e,this.removedTargetIds=t,this.key=r,this.fe=s}},dh=class{constructor(e,t){this.targetId=e,this.ge=t}},ph=class{constructor(e,t,r=At.EMPTY_BYTE_STRING,s=null){this.state=e,this.targetIds=t,this.resumeToken=r,this.cause=s}},mh=class{constructor(){this.pe=0,this.ye=fb(),this.we=At.EMPTY_BYTE_STRING,this.Se=!1,this.be=!0}get current(){return this.Se}get resumeToken(){return this.we}get De(){return this.pe!==0}get ve(){return this.be}Ce(e){e.approximateByteSize()>0&&(this.be=!0,this.we=e)}Fe(){let e=xe(),t=xe(),r=xe();return this.ye.forEach((s,a)=>{switch(a){case 0:e=e.add(s);break;case 2:t=t.add(s);break;case 1:r=r.add(s);break;default:ue()}}),new yu(this.we,this.Se,e,t,r)}Me(){this.be=!1,this.ye=fb()}xe(e,t){this.be=!0,this.ye=this.ye.insert(e,t)}Oe(e){this.be=!0,this.ye=this.ye.remove(e)}Ne(){this.pe+=1}Be(){this.pe-=1,Le(this.pe>=0)}Le(){this.be=!0,this.Se=!0}},zp=class{constructor(e){this.ke=e,this.qe=new Map,this.Qe=kr(),this.$e=Yl(),this.Ke=Yl(),this.Ue=new Je(Re)}We(e){for(let t of e.me)e.fe&&e.fe.isFoundDocument()?this.Ge(t,e.fe):this.ze(t,e.key,e.fe);for(let t of e.removedTargetIds)this.ze(t,e.key,e.fe)}je(e){this.forEachTarget(e,t=>{let r=this.He(t);switch(e.state){case 0:this.Je(t)&&r.Ce(e.resumeToken);break;case 1:r.Be(),r.De||r.Me(),r.Ce(e.resumeToken);break;case 2:r.Be(),r.De||this.removeTarget(t);break;case 3:this.Je(t)&&(r.Le(),r.Ce(e.resumeToken));break;case 4:this.Je(t)&&(this.Ye(t),r.Ce(e.resumeToken));break;default:ue()}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.qe.forEach((r,s)=>{this.Je(s)&&t(s)})}Ze(e){let t=e.targetId,r=e.ge.count,s=this.Xe(t);if(s){let a=s.target;if(Vp(a))if(r===0){let c=new ce(a.path);this.ze(t,c,Rn.newNoDocument(c,me.min()))}else Le(r===1);else{let c=this.et(t);if(c!==r){let h=this.tt(e),f=h?this.nt(h,e,c):1;if(f!==0){this.Ye(t);let m=f===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Ue=this.Ue.insert(t,m)}cb==null||cb.rt(function(_,E,I,k,B){var G,j,J,ee,ne,le;let de={localCacheCount:_,existenceFilterCount:E.count,databaseId:I.database,projectId:I.projectId},ie=E.unchangedNames;return ie&&(de.bloomFilter={applied:B===0,hashCount:(G=ie==null?void 0:ie.hashCount)!==null&&G!==void 0?G:0,bitmapLength:(ee=(J=(j=ie==null?void 0:ie.bits)===null||j===void 0?void 0:j.bitmap)===null||J===void 0?void 0:J.length)!==null&&ee!==void 0?ee:0,padding:(le=(ne=ie==null?void 0:ie.bits)===null||ne===void 0?void 0:ne.padding)!==null&&le!==void 0?le:0,mightContain:C=>{var A;return(A=k==null?void 0:k.mightContain(C))!==null&&A!==void 0&&A}}),de}(c,e.ge,this.ke.it(),h,f))}}}}tt(e){let t=e.ge.unchangedNames;if(!t||!t.bits)return null;let{bits:{bitmap:r="",padding:s=0},hashCount:a=0}=t,c,h;try{c=Dr(r).toUint8Array()}catch(f){if(f instanceof ah)return No("Decoding the base64 bloom filter in existence filter failed ("+f.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw f}try{h=new qp(c,s,a)}catch(f){return No(f instanceof as?"BloomFilter error: ":"Applying bloom filter failed: ",f),null}return h.Ee===0?null:h}nt(e,t,r){return t.ge.count===r-this.st(e,t.targetId)?0:2}st(e,t){let r=this.ke.getRemoteKeysForTarget(t),s=0;return r.forEach(a=>{let c=this.ke.it(),h=`projects/${c.projectId}/databases/${c.database}/documents/${a.path.canonicalString()}`;e.mightContain(h)||(this.ze(t,a,null),s++)}),s}ot(e){let t=new Map;this.qe.forEach((a,c)=>{let h=this.Xe(c);if(h){if(a.current&&Vp(h.target)){let f=new ce(h.target.path);this._t(f).has(c)||this.ut(c,f)||this.ze(c,f,Rn.newNoDocument(f,e))}a.ve&&(t.set(c,a.Fe()),a.Me())}});let r=xe();this.Ke.forEach((a,c)=>{let h=!0;c.forEachWhile(f=>{let m=this.Xe(f);return!m||m.purpose==="TargetPurposeLimboResolution"||(h=!1,!1)}),h&&(r=r.add(a))}),this.Qe.forEach((a,c)=>c.setReadTime(e));let s=new fh(e,t,this.Ue,this.Qe,r);return this.Qe=kr(),this.$e=Yl(),this.Ke=Yl(),this.Ue=new Je(Re),s}Ge(e,t){if(!this.Je(e))return;let r=this.ut(e,t.key)?2:0;this.He(e).xe(t.key,r),this.Qe=this.Qe.insert(t.key,t),this.$e=this.$e.insert(t.key,this._t(t.key).add(e)),this.Ke=this.Ke.insert(t.key,this.ct(t.key).add(e))}ze(e,t,r){if(!this.Je(e))return;let s=this.He(e);this.ut(e,t)?s.xe(t,1):s.Oe(t),this.Ke=this.Ke.insert(t,this.ct(t).delete(e)),this.Ke=this.Ke.insert(t,this.ct(t).add(e)),r&&(this.Qe=this.Qe.insert(t,r))}removeTarget(e){this.qe.delete(e)}et(e){let t=this.He(e).Fe();return this.ke.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}Ne(e){this.He(e).Ne()}He(e){let t=this.qe.get(e);return t||(t=new mh,this.qe.set(e,t)),t}ct(e){let t=this.Ke.get(e);return t||(t=new gt(Re),this.Ke=this.Ke.insert(e,t)),t}_t(e){let t=this.$e.get(e);return t||(t=new gt(Re),this.$e=this.$e.insert(e,t)),t}Je(e){let t=this.Xe(e)!==null;return t||X("WatchChangeAggregator","Detected inactive target",e),t}Xe(e){let t=this.qe.get(e);return t&&t.De?null:this.ke.lt(e)}Ye(e){this.qe.set(e,new mh),this.ke.getRemoteKeysForTarget(e).forEach(t=>{this.ze(e,t,null)})}ut(e,t){return this.ke.getRemoteKeysForTarget(e).has(t)}};function Yl(){return new Je(ce.comparator)}function fb(){return new Je(ce.comparator)}var mM={asc:"ASCENDING",desc:"DESCENDING"},gM={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},_M={and:"AND",or:"OR"},Gp=class{constructor(e,t){this.databaseId=e,this.useProto3Json=t}};function Kp(n,e){return n.useProto3Json||Bh(e)?e:{value:e}}function gh(n,e){return n.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function yT(n,e){return n.useProto3Json?e.toBase64():e.toUint8Array()}function yM(n,e){return gh(n,e.toTimestamp())}function Qn(n){return Le(!!n),me.fromTimestamp(function(t){let r=Cr(t);return new yt(r.seconds,r.nanos)}(n))}function sg(n,e){return Wp(n,e).canonicalString()}function Wp(n,e){let t=function(s){return new st(["projects",s.projectId,"databases",s.database])}(n).child("documents");return e===void 0?t:t.child(e)}function vT(n){let e=st.fromString(n);return Le(IT(e)),e}function Hp(n,e){return sg(n.databaseId,e.path)}function hp(n,e){let t=vT(e);if(t.get(1)!==n.databaseId.projectId)throw new re(H.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+t.get(1)+" vs "+n.databaseId.projectId);if(t.get(3)!==n.databaseId.database)throw new re(H.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+t.get(3)+" vs "+n.databaseId.database);return new ce(bT(t))}function wT(n,e){return sg(n.databaseId,e)}function vM(n){let e=vT(n);return e.length===4?st.emptyPath():bT(e)}function Qp(n){return new st(["projects",n.databaseId.projectId,"databases",n.databaseId.database]).canonicalString()}function bT(n){return Le(n.length>4&&n.get(4)==="documents"),n.popFirst(5)}function db(n,e,t){return{name:Hp(n,e),fields:t.value.mapValue.fields}}function wM(n,e){let t;if("targetChange"in e){e.targetChange;let r=function(m){return m==="NO_CHANGE"?0:m==="ADD"?1:m==="REMOVE"?2:m==="CURRENT"?3:m==="RESET"?4:ue()}(e.targetChange.targetChangeType||"NO_CHANGE"),s=e.targetChange.targetIds||[],a=function(m,_){return m.useProto3Json?(Le(_===void 0||typeof _=="string"),At.fromBase64String(_||"")):(Le(_===void 0||_ instanceof Buffer||_ instanceof Uint8Array),At.fromUint8Array(_||new Uint8Array))}(n,e.targetChange.resumeToken),c=e.targetChange.cause,h=c&&function(m){let _=m.code===void 0?H.UNKNOWN:_T(m.code);return new re(_,m.message||"")}(c);t=new ph(r,s,a,h||null)}else if("documentChange"in e){e.documentChange;let r=e.documentChange;r.document,r.document.name,r.document.updateTime;let s=hp(n,r.document.name),a=Qn(r.document.updateTime),c=r.document.createTime?Qn(r.document.createTime):me.min(),h=new Zt({mapValue:{fields:r.document.fields}}),f=Rn.newFoundDocument(s,a,c,h),m=r.targetIds||[],_=r.removedTargetIds||[];t=new Oo(m,_,f.key,f)}else if("documentDelete"in e){e.documentDelete;let r=e.documentDelete;r.document;let s=hp(n,r.document),a=r.readTime?Qn(r.readTime):me.min(),c=Rn.newNoDocument(s,a),h=r.removedTargetIds||[];t=new Oo([],h,c.key,c)}else if("documentRemove"in e){e.documentRemove;let r=e.documentRemove;r.document;let s=hp(n,r.document),a=r.removedTargetIds||[];t=new Oo([],a,s,null)}else{if(!("filter"in e))return ue();{e.filter;let r=e.filter;r.targetId;let{count:s=0,unchangedNames:a}=r,c=new $p(s,a),h=r.targetId;t=new dh(h,c)}}return t}function bM(n,e){let t;if(e instanceof ds)t={update:db(n,e.key,e.value)};else if(e instanceof hh)t={delete:Hp(n,e.key)};else if(e instanceof Zn)t={update:db(n,e.key,e.data),updateMask:CM(e.fieldMask)};else{if(!(e instanceof Fp))return ue();t={verify:Hp(n,e.key)}}return e.fieldTransforms.length>0&&(t.updateTransforms=e.fieldTransforms.map(r=>function(a,c){let h=c.transform;if(h instanceof zo)return{fieldPath:c.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(h instanceof hs)return{fieldPath:c.field.canonicalString(),appendMissingElements:{values:h.elements}};if(h instanceof fs)return{fieldPath:c.field.canonicalString(),removeAllFromArray:{values:h.elements}};if(h instanceof Go)return{fieldPath:c.field.canonicalString(),increment:h.Ie};throw ue()}(0,r))),e.precondition.isNone||(t.currentDocument=function(s,a){return a.updateTime!==void 0?{updateTime:yM(s,a.updateTime)}:a.exists!==void 0?{exists:a.exists}:ue()}(n,e.precondition)),t}function TM(n,e){return n&&n.length>0?(Le(e!==void 0),n.map(t=>function(s,a){let c=s.updateTime?Qn(s.updateTime):Qn(a);return c.isEqual(me.min())&&(c=Qn(a)),new Mp(c,s.transformResults||[])}(t,e))):[]}function EM(n,e){return{documents:[wT(n,e.path)]}}function IM(n,e){let t={structuredQuery:{}},r=e.path,s;e.collectionGroup!==null?(s=r,t.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(s=r.popLast(),t.structuredQuery.from=[{collectionId:r.lastSegment()}]),t.parent=wT(n,s);let a=function(m){if(m.length!==0)return ET(Xn.create(m,"and"))}(e.filters);a&&(t.structuredQuery.where=a);let c=function(m){if(m.length!==0)return m.map(_=>function(I){return{field:Po(I.field),direction:SM(I.dir)}}(_))}(e.orderBy);c&&(t.structuredQuery.orderBy=c);let h=Kp(n,e.limit);return h!==null&&(t.structuredQuery.limit=h),e.startAt&&(t.structuredQuery.startAt=function(m){return{before:m.inclusive,values:m.position}}(e.startAt)),e.endAt&&(t.structuredQuery.endAt=function(m){return{before:!m.inclusive,values:m.position}}(e.endAt)),{ht:t,parent:s}}function xM(n){let e=vM(n.parent),t=n.structuredQuery,r=t.from?t.from.length:0,s=null;if(r>0){Le(r===1);let _=t.from[0];_.allDescendants?s=_.collectionId:e=e.child(_.collectionId)}let a=[];t.where&&(a=function(E){let I=TT(E);return I instanceof Xn&&tT(I)?I.getFilters():[I]}(t.where));let c=[];t.orderBy&&(c=function(E){return E.map(I=>function(B){return new jo(Co(B.field),function(j){switch(j){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(B.direction))}(I))}(t.orderBy));let h=null;t.limit&&(h=function(E){let I;return I=typeof E=="object"?E.value:E,Bh(I)?null:I}(t.limit));let f=null;t.startAt&&(f=function(E){let I=!!E.before,k=E.values||[];return new Bo(k,I)}(t.startAt));let m=null;return t.endAt&&(m=function(E){let I=!E.before,k=E.values||[];return new Bo(k,I)}(t.endAt)),J2(e,s,c,a,h,"F",f,m)}function AM(n,e){let t=function(s){switch(s){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return ue()}}(e.purpose);return t==null?null:{"goog-listen-tags":t}}function TT(n){return n.unaryFilter!==void 0?function(t){switch(t.unaryFilter.op){case"IS_NAN":let r=Co(t.unaryFilter.field);return dt.create(r,"==",{doubleValue:NaN});case"IS_NULL":let s=Co(t.unaryFilter.field);return dt.create(s,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":let a=Co(t.unaryFilter.field);return dt.create(a,"!=",{doubleValue:NaN});case"IS_NOT_NULL":let c=Co(t.unaryFilter.field);return dt.create(c,"!=",{nullValue:"NULL_VALUE"});default:return ue()}}(n):n.fieldFilter!==void 0?function(t){return dt.create(Co(t.fieldFilter.field),function(s){switch(s){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return ue()}}(t.fieldFilter.op),t.fieldFilter.value)}(n):n.compositeFilter!==void 0?function(t){return Xn.create(t.compositeFilter.filters.map(r=>TT(r)),function(s){switch(s){case"AND":return"and";case"OR":return"or";default:return ue()}}(t.compositeFilter.op))}(n):ue()}function SM(n){return mM[n]}function RM(n){return gM[n]}function PM(n){return _M[n]}function Po(n){return{fieldPath:n.canonicalString()}}function Co(n){return en.fromServerFormat(n.fieldPath)}function ET(n){return n instanceof dt?function(t){if(t.op==="=="){if(eb(t.value))return{unaryFilter:{field:Po(t.field),op:"IS_NAN"}};if(Z0(t.value))return{unaryFilter:{field:Po(t.field),op:"IS_NULL"}}}else if(t.op==="!="){if(eb(t.value))return{unaryFilter:{field:Po(t.field),op:"IS_NOT_NAN"}};if(Z0(t.value))return{unaryFilter:{field:Po(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Po(t.field),op:RM(t.op),value:t.value}}}(n):n instanceof Xn?function(t){let r=t.getFilters().map(s=>ET(s));return r.length===1?r[0]:{compositeFilter:{op:PM(t.op),filters:r}}}(n):ue()}function CM(n){let e=[];return n.fields.forEach(t=>e.push(t.canonicalString())),{fieldPaths:e}}function IT(n){return n.length>=4&&n.get(0)==="projects"&&n.get(2)==="databases"}var vu=class n{constructor(e,t,r,s,a=me.min(),c=me.min(),h=At.EMPTY_BYTE_STRING,f=null){this.target=e,this.targetId=t,this.purpose=r,this.sequenceNumber=s,this.snapshotVersion=a,this.lastLimboFreeSnapshotVersion=c,this.resumeToken=h,this.expectedCount=f}withSequenceNumber(e){return new n(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new n(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new n(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new n(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}};var Jp=class{constructor(e){this.Tt=e}};function DM(n){let e=xM({parent:n.parent,structuredQuery:n.structuredQuery});return n.limitType==="LAST"?Lp(e,e.limit,"L"):e}var _h=class{constructor(){}At(e,t){this.Rt(e,t),t.Vt()}Rt(e,t){if("nullValue"in e)this.ft(t,5);else if("booleanValue"in e)this.ft(t,10),t.gt(e.booleanValue?1:0);else if("integerValue"in e)this.ft(t,15),t.gt(ze(e.integerValue));else if("doubleValue"in e){let r=ze(e.doubleValue);isNaN(r)?this.ft(t,13):(this.ft(t,15),mu(r)?t.gt(0):t.gt(r))}else if("timestampValue"in e){let r=e.timestampValue;this.ft(t,20),typeof r=="string"&&(r=Cr(r)),t.yt(`${r.seconds||""}`),t.gt(r.nanos||0)}else if("stringValue"in e)this.wt(e.stringValue,t),this.St(t);else if("bytesValue"in e)this.ft(t,30),t.bt(Dr(e.bytesValue)),this.St(t);else if("referenceValue"in e)this.Dt(e.referenceValue,t);else if("geoPointValue"in e){let r=e.geoPointValue;this.ft(t,45),t.gt(r.latitude||0),t.gt(r.longitude||0)}else"mapValue"in e?Xb(e)?this.ft(t,Number.MAX_SAFE_INTEGER):Yb(e)?this.vt(e.mapValue,t):(this.Ct(e.mapValue,t),this.St(t)):"arrayValue"in e?(this.Ft(e.arrayValue,t),this.St(t)):ue()}wt(e,t){this.ft(t,25),this.Mt(e,t)}Mt(e,t){t.yt(e)}Ct(e,t){let r=e.fields||{};this.ft(t,55);for(let s of Object.keys(r))this.wt(s,t),this.Rt(r[s],t)}vt(e,t){var r,s;let a=e.fields||{};this.ft(t,53);let c=Mo,h=((s=(r=a[c].arrayValue)===null||r===void 0?void 0:r.values)===null||s===void 0?void 0:s.length)||0;this.ft(t,15),t.gt(ze(h)),this.wt(c,t),this.Rt(a[c],t)}Ft(e,t){let r=e.values||[];this.ft(t,50);for(let s of r)this.Rt(s,t)}Dt(e,t){this.ft(t,37),ce.fromName(e).path.forEach(r=>{this.ft(t,60),this.Mt(r,t)})}ft(e,t){e.gt(t)}St(e){e.gt(2)}};_h.xt=new _h;var Yp=class{constructor(){this.Tn=new Xp}addToCollectionParentIndex(e,t){return this.Tn.add(t),W.resolve()}getCollectionParents(e,t){return W.resolve(this.Tn.getEntries(t))}addFieldIndex(e,t){return W.resolve()}deleteFieldIndex(e,t){return W.resolve()}deleteAllFieldIndexes(e){return W.resolve()}createTargetIndexes(e,t){return W.resolve()}getDocumentsMatchingTarget(e,t){return W.resolve(null)}getIndexType(e,t){return W.resolve(0)}getFieldIndexes(e,t){return W.resolve([])}getNextCollectionGroupToUpdate(e){return W.resolve(null)}getMinOffset(e,t){return W.resolve(ls.min())}getMinOffsetFromCollectionGroup(e,t){return W.resolve(ls.min())}updateCollectionGroup(e,t,r){return W.resolve()}updateIndexEntries(e,t){return W.resolve()}},Xp=class{constructor(){this.index={}}add(e){let t=e.lastSegment(),r=e.popLast(),s=this.index[t]||new gt(st.comparator),a=!s.has(r);return this.index[t]=s.add(r),a}has(e){let t=e.lastSegment(),r=e.popLast(),s=this.index[t];return s&&s.has(r)}getEntries(e){return(this.index[e]||new gt(st.comparator)).toArray()}};var dK=new Uint8Array(0);var pb={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},xT=41943040,ln=class n{static withCacheSize(e){return new n(e,n.DEFAULT_COLLECTION_PERCENTILE,n.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,r){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=r}};ln.DEFAULT_COLLECTION_PERCENTILE=10,ln.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,ln.DEFAULT=new ln(xT,ln.DEFAULT_COLLECTION_PERCENTILE,ln.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),ln.DISABLED=new ln(-1,0,0);var wu=class n{constructor(e){this.$n=e}next(){return this.$n+=2,this.$n}static Kn(){return new n(0)}static Un(){return new n(-1)}};var mb="LruGarbageCollector",OM=1048576;function gb([n,e],[t,r]){let s=Re(n,t);return s===0?Re(e,r):s}var Zp=class{constructor(e){this.Hn=e,this.buffer=new gt(gb),this.Jn=0}Yn(){return++this.Jn}Zn(e){let t=[e,this.Yn()];if(this.buffer.size<this.Hn)this.buffer=this.buffer.add(t);else{let r=this.buffer.last();gb(t,r)<0&&(this.buffer=this.buffer.delete(r).add(t))}}get maxValue(){return this.buffer.last()[0]}},em=class{constructor(e,t,r){this.garbageCollector=e,this.asyncQueue=t,this.localStore=r,this.Xn=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.er(6e4)}stop(){this.Xn&&(this.Xn.cancel(),this.Xn=null)}get started(){return this.Xn!==null}er(e){X(mb,`Garbage collection scheduled in ${e}ms`),this.Xn=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,async()=>{this.Xn=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(t){Xo(t)?X(mb,"Ignoring IndexedDB error during garbage collection: ",t):await Yo(t)}await this.er(3e5)})}},tm=class{constructor(e,t){this.tr=e,this.params=t}calculateTargetCount(e,t){return this.tr.nr(e).next(r=>Math.floor(t/100*r))}nthSequenceNumber(e,t){if(t===0)return W.resolve(Lo.ae);let r=new Zp(t);return this.tr.forEachTarget(e,s=>r.Zn(s.sequenceNumber)).next(()=>this.tr.rr(e,s=>r.Zn(s))).next(()=>r.maxValue)}removeTargets(e,t,r){return this.tr.removeTargets(e,t,r)}removeOrphanedDocuments(e,t){return this.tr.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(X("LruGarbageCollector","Garbage collection skipped; disabled"),W.resolve(pb)):this.getCacheSize(e).next(r=>r<this.params.cacheSizeCollectionThreshold?(X("LruGarbageCollector",`Garbage collection skipped; Cache size ${r} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),pb):this.ir(e,t))}getCacheSize(e){return this.tr.getCacheSize(e)}ir(e,t){let r,s,a,c,h,f,m,_=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(E=>(E>this.params.maximumSequenceNumbersToCollect?(X("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${E}`),s=this.params.maximumSequenceNumbersToCollect):s=E,c=Date.now(),this.nthSequenceNumber(e,s))).next(E=>(r=E,h=Date.now(),this.removeTargets(e,r,t))).next(E=>(a=E,f=Date.now(),this.removeOrphanedDocuments(e,r))).next(E=>(m=Date.now(),So()<=Se.DEBUG&&X("LruGarbageCollector",`LRU Garbage Collection
31
+ }`}};var zp=class{constructor(e,t){this.count=e,this.unchangedNames=t}};var it,Pe;function gM(r){switch(r){case H.OK:return ue();case H.CANCELLED:case H.UNKNOWN:case H.DEADLINE_EXCEEDED:case H.RESOURCE_EXHAUSTED:case H.INTERNAL:case H.UNAVAILABLE:case H.UNAUTHENTICATED:return!1;case H.INVALID_ARGUMENT:case H.NOT_FOUND:case H.ALREADY_EXISTS:case H.PERMISSION_DENIED:case H.FAILED_PRECONDITION:case H.ABORTED:case H.OUT_OF_RANGE:case H.UNIMPLEMENTED:case H.DATA_LOSS:return!0;default:return ue()}}function vT(r){if(r===void 0)return Pn("GRPC error has no .code"),H.UNKNOWN;switch(r){case it.OK:return H.OK;case it.CANCELLED:return H.CANCELLED;case it.UNKNOWN:return H.UNKNOWN;case it.DEADLINE_EXCEEDED:return H.DEADLINE_EXCEEDED;case it.RESOURCE_EXHAUSTED:return H.RESOURCE_EXHAUSTED;case it.INTERNAL:return H.INTERNAL;case it.UNAVAILABLE:return H.UNAVAILABLE;case it.UNAUTHENTICATED:return H.UNAUTHENTICATED;case it.INVALID_ARGUMENT:return H.INVALID_ARGUMENT;case it.NOT_FOUND:return H.NOT_FOUND;case it.ALREADY_EXISTS:return H.ALREADY_EXISTS;case it.PERMISSION_DENIED:return H.PERMISSION_DENIED;case it.FAILED_PRECONDITION:return H.FAILED_PRECONDITION;case it.ABORTED:return H.ABORTED;case it.OUT_OF_RANGE:return H.OUT_OF_RANGE;case it.UNIMPLEMENTED:return H.UNIMPLEMENTED;case it.DATA_LOSS:return H.DATA_LOSS;default:return ue()}}(Pe=it||(it={}))[Pe.OK=0]="OK",Pe[Pe.CANCELLED=1]="CANCELLED",Pe[Pe.UNKNOWN=2]="UNKNOWN",Pe[Pe.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Pe[Pe.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Pe[Pe.NOT_FOUND=5]="NOT_FOUND",Pe[Pe.ALREADY_EXISTS=6]="ALREADY_EXISTS",Pe[Pe.PERMISSION_DENIED=7]="PERMISSION_DENIED",Pe[Pe.UNAUTHENTICATED=16]="UNAUTHENTICATED",Pe[Pe.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Pe[Pe.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Pe[Pe.ABORTED=10]="ABORTED",Pe[Pe.OUT_OF_RANGE=11]="OUT_OF_RANGE",Pe[Pe.UNIMPLEMENTED=12]="UNIMPLEMENTED",Pe[Pe.INTERNAL=13]="INTERNAL",Pe[Pe.UNAVAILABLE=14]="UNAVAILABLE",Pe[Pe.DATA_LOSS=15]="DATA_LOSS";var hb=null;function _M(){return new TextEncoder}var yM=new Sn([4294967295,4294967295],0);function fb(r){let e=_M().encode(r),t=new ap;return t.update(e),new Uint8Array(t.digest())}function db(r){let e=new DataView(r.buffer),t=e.getUint32(0,!0),n=e.getUint32(4,!0),s=e.getUint32(8,!0),a=e.getUint32(12,!0);return[new Sn([t,n],0),new Sn([s,a],0)]}var Gp=class r{constructor(e,t,n){if(this.bitmap=e,this.padding=t,this.hashCount=n,t<0||t>=8)throw new as(`Invalid padding: ${t}`);if(n<0)throw new as(`Invalid hash count: ${n}`);if(e.length>0&&this.hashCount===0)throw new as(`Invalid hash count: ${n}`);if(e.length===0&&t!==0)throw new as(`Invalid padding when bitmap length is 0: ${t}`);this.Ee=8*e.length-t,this.de=Sn.fromNumber(this.Ee)}Ae(e,t,n){let s=e.add(t.multiply(Sn.fromNumber(n)));return s.compare(yM)===1&&(s=new Sn([s.getBits(0),s.getBits(1)],0)),s.modulo(this.de).toNumber()}Re(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(this.Ee===0)return!1;let t=fb(e),[n,s]=db(t);for(let a=0;a<this.hashCount;a++){let c=this.Ae(n,s,a);if(!this.Re(c))return!1}return!0}static create(e,t,n){let s=e%8==0?0:8-e%8,a=new Uint8Array(Math.ceil(e/8)),c=new r(a,s,t);return n.forEach(h=>c.insert(h)),c}insert(e){if(this.Ee===0)return;let t=fb(e),[n,s]=db(t);for(let a=0;a<this.hashCount;a++){let c=this.Ae(n,s,a);this.Ve(c)}}Ve(e){let t=Math.floor(e/8),n=e%8;this.bitmap[t]|=1<<n}},as=class extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}};var dh=class r{constructor(e,t,n,s,a){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=n,this.documentUpdates=s,this.resolvedLimboDocuments=a}static createSynthesizedRemoteEventForCurrentChange(e,t,n){let s=new Map;return s.set(e,vu.createSynthesizedTargetChangeForCurrentChange(e,t,n)),new r(me.min(),s,new Ye(Re),kn(),xe())}},vu=class r{constructor(e,t,n,s,a){this.resumeToken=e,this.current=t,this.addedDocuments=n,this.modifiedDocuments=s,this.removedDocuments=a}static createSynthesizedTargetChangeForCurrentChange(e,t,n){return new r(n,t,xe(),xe(),xe())}};var ko=class{constructor(e,t,n,s){this.me=e,this.removedTargetIds=t,this.key=n,this.fe=s}},ph=class{constructor(e,t){this.targetId=e,this.ge=t}},mh=class{constructor(e,t,n=Rt.EMPTY_BYTE_STRING,s=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=s}},gh=class{constructor(){this.pe=0,this.ye=pb(),this.we=Rt.EMPTY_BYTE_STRING,this.Se=!1,this.be=!0}get current(){return this.Se}get resumeToken(){return this.we}get De(){return this.pe!==0}get ve(){return this.be}Ce(e){e.approximateByteSize()>0&&(this.be=!0,this.we=e)}Fe(){let e=xe(),t=xe(),n=xe();return this.ye.forEach((s,a)=>{switch(a){case 0:e=e.add(s);break;case 2:t=t.add(s);break;case 1:n=n.add(s);break;default:ue()}}),new vu(this.we,this.Se,e,t,n)}Me(){this.be=!1,this.ye=pb()}xe(e,t){this.be=!0,this.ye=this.ye.insert(e,t)}Oe(e){this.be=!0,this.ye=this.ye.remove(e)}Ne(){this.pe+=1}Be(){this.pe-=1,Le(this.pe>=0)}Le(){this.be=!0,this.Se=!0}},Kp=class{constructor(e){this.ke=e,this.qe=new Map,this.Qe=kn(),this.$e=Xl(),this.Ke=Xl(),this.Ue=new Ye(Re)}We(e){for(let t of e.me)e.fe&&e.fe.isFoundDocument()?this.Ge(t,e.fe):this.ze(t,e.key,e.fe);for(let t of e.removedTargetIds)this.ze(t,e.key,e.fe)}je(e){this.forEachTarget(e,t=>{let n=this.He(t);switch(e.state){case 0:this.Je(t)&&n.Ce(e.resumeToken);break;case 1:n.Be(),n.De||n.Me(),n.Ce(e.resumeToken);break;case 2:n.Be(),n.De||this.removeTarget(t);break;case 3:this.Je(t)&&(n.Le(),n.Ce(e.resumeToken));break;case 4:this.Je(t)&&(this.Ye(t),n.Ce(e.resumeToken));break;default:ue()}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.qe.forEach((n,s)=>{this.Je(s)&&t(s)})}Ze(e){let t=e.targetId,n=e.ge.count,s=this.Xe(t);if(s){let a=s.target;if(Mp(a))if(n===0){let c=new ce(a.path);this.ze(t,c,Sr.newNoDocument(c,me.min()))}else Le(n===1);else{let c=this.et(t);if(c!==n){let h=this.tt(e),f=h?this.nt(h,e,c):1;if(f!==0){this.Ye(t);let m=f===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Ue=this.Ue.insert(t,m)}hb==null||hb.rt(function(_,E,I,k,B){var G,j,J,ee,re,le;let de={localCacheCount:_,existenceFilterCount:E.count,databaseId:I.database,projectId:I.projectId},ie=E.unchangedNames;return ie&&(de.bloomFilter={applied:B===0,hashCount:(G=ie==null?void 0:ie.hashCount)!==null&&G!==void 0?G:0,bitmapLength:(ee=(J=(j=ie==null?void 0:ie.bits)===null||j===void 0?void 0:j.bitmap)===null||J===void 0?void 0:J.length)!==null&&ee!==void 0?ee:0,padding:(le=(re=ie==null?void 0:ie.bits)===null||re===void 0?void 0:re.padding)!==null&&le!==void 0?le:0,mightContain:C=>{var A;return(A=k==null?void 0:k.mightContain(C))!==null&&A!==void 0&&A}}),de}(c,e.ge,this.ke.it(),h,f))}}}}tt(e){let t=e.ge.unchangedNames;if(!t||!t.bits)return null;let{bits:{bitmap:n="",padding:s=0},hashCount:a=0}=t,c,h;try{c=Dn(n).toUint8Array()}catch(f){if(f instanceof uh)return Vo("Decoding the base64 bloom filter in existence filter failed ("+f.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw f}try{h=new Gp(c,s,a)}catch(f){return Vo(f instanceof as?"BloomFilter error: ":"Applying bloom filter failed: ",f),null}return h.Ee===0?null:h}nt(e,t,n){return t.ge.count===n-this.st(e,t.targetId)?0:2}st(e,t){let n=this.ke.getRemoteKeysForTarget(t),s=0;return n.forEach(a=>{let c=this.ke.it(),h=`projects/${c.projectId}/databases/${c.database}/documents/${a.path.canonicalString()}`;e.mightContain(h)||(this.ze(t,a,null),s++)}),s}ot(e){let t=new Map;this.qe.forEach((a,c)=>{let h=this.Xe(c);if(h){if(a.current&&Mp(h.target)){let f=new ce(h.target.path);this._t(f).has(c)||this.ut(c,f)||this.ze(c,f,Sr.newNoDocument(f,e))}a.ve&&(t.set(c,a.Fe()),a.Me())}});let n=xe();this.Ke.forEach((a,c)=>{let h=!0;c.forEachWhile(f=>{let m=this.Xe(f);return!m||m.purpose==="TargetPurposeLimboResolution"||(h=!1,!1)}),h&&(n=n.add(a))}),this.Qe.forEach((a,c)=>c.setReadTime(e));let s=new dh(e,t,this.Ue,this.Qe,n);return this.Qe=kn(),this.$e=Xl(),this.Ke=Xl(),this.Ue=new Ye(Re),s}Ge(e,t){if(!this.Je(e))return;let n=this.ut(e,t.key)?2:0;this.He(e).xe(t.key,n),this.Qe=this.Qe.insert(t.key,t),this.$e=this.$e.insert(t.key,this._t(t.key).add(e)),this.Ke=this.Ke.insert(t.key,this.ct(t.key).add(e))}ze(e,t,n){if(!this.Je(e))return;let s=this.He(e);this.ut(e,t)?s.xe(t,1):s.Oe(t),this.Ke=this.Ke.insert(t,this.ct(t).delete(e)),this.Ke=this.Ke.insert(t,this.ct(t).add(e)),n&&(this.Qe=this.Qe.insert(t,n))}removeTarget(e){this.qe.delete(e)}et(e){let t=this.He(e).Fe();return this.ke.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}Ne(e){this.He(e).Ne()}He(e){let t=this.qe.get(e);return t||(t=new gh,this.qe.set(e,t)),t}ct(e){let t=this.Ke.get(e);return t||(t=new yt(Re),this.Ke=this.Ke.insert(e,t)),t}_t(e){let t=this.$e.get(e);return t||(t=new yt(Re),this.$e=this.$e.insert(e,t)),t}Je(e){let t=this.Xe(e)!==null;return t||X("WatchChangeAggregator","Detected inactive target",e),t}Xe(e){let t=this.qe.get(e);return t&&t.De?null:this.ke.lt(e)}Ye(e){this.qe.set(e,new gh),this.ke.getRemoteKeysForTarget(e).forEach(t=>{this.ze(e,t,null)})}ut(e,t){return this.ke.getRemoteKeysForTarget(e).has(t)}};function Xl(){return new Ye(ce.comparator)}function pb(){return new Ye(ce.comparator)}var vM={asc:"ASCENDING",desc:"DESCENDING"},wM={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},bM={and:"AND",or:"OR"},Wp=class{constructor(e,t){this.databaseId=e,this.useProto3Json=t}};function Hp(r,e){return r.useProto3Json||jh(e)?e:{value:e}}function _h(r,e){return r.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function wT(r,e){return r.useProto3Json?e.toBase64():e.toUint8Array()}function TM(r,e){return _h(r,e.toTimestamp())}function Hr(r){return Le(!!r),me.fromTimestamp(function(t){let n=Cn(t);return new wt(n.seconds,n.nanos)}(r))}function ag(r,e){return Qp(r,e).canonicalString()}function Qp(r,e){let t=function(s){return new ot(["projects",s.projectId,"databases",s.database])}(r).child("documents");return e===void 0?t:t.child(e)}function bT(r){let e=ot.fromString(r);return Le(AT(e)),e}function Jp(r,e){return ag(r.databaseId,e.path)}function dp(r,e){let t=bT(e);if(t.get(1)!==r.databaseId.projectId)throw new ne(H.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+t.get(1)+" vs "+r.databaseId.projectId);if(t.get(3)!==r.databaseId.database)throw new ne(H.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+t.get(3)+" vs "+r.databaseId.database);return new ce(ET(t))}function TT(r,e){return ag(r.databaseId,e)}function EM(r){let e=bT(r);return e.length===4?ot.emptyPath():ET(e)}function Yp(r){return new ot(["projects",r.databaseId.projectId,"databases",r.databaseId.database]).canonicalString()}function ET(r){return Le(r.length>4&&r.get(4)==="documents"),r.popFirst(5)}function mb(r,e,t){return{name:Jp(r,e),fields:t.value.mapValue.fields}}function IM(r,e){let t;if("targetChange"in e){e.targetChange;let n=function(m){return m==="NO_CHANGE"?0:m==="ADD"?1:m==="REMOVE"?2:m==="CURRENT"?3:m==="RESET"?4:ue()}(e.targetChange.targetChangeType||"NO_CHANGE"),s=e.targetChange.targetIds||[],a=function(m,_){return m.useProto3Json?(Le(_===void 0||typeof _=="string"),Rt.fromBase64String(_||"")):(Le(_===void 0||_ instanceof Buffer||_ instanceof Uint8Array),Rt.fromUint8Array(_||new Uint8Array))}(r,e.targetChange.resumeToken),c=e.targetChange.cause,h=c&&function(m){let _=m.code===void 0?H.UNKNOWN:vT(m.code);return new ne(_,m.message||"")}(c);t=new mh(n,s,a,h||null)}else if("documentChange"in e){e.documentChange;let n=e.documentChange;n.document,n.document.name,n.document.updateTime;let s=dp(r,n.document.name),a=Hr(n.document.updateTime),c=n.document.createTime?Hr(n.document.createTime):me.min(),h=new er({mapValue:{fields:n.document.fields}}),f=Sr.newFoundDocument(s,a,c,h),m=n.targetIds||[],_=n.removedTargetIds||[];t=new ko(m,_,f.key,f)}else if("documentDelete"in e){e.documentDelete;let n=e.documentDelete;n.document;let s=dp(r,n.document),a=n.readTime?Hr(n.readTime):me.min(),c=Sr.newNoDocument(s,a),h=n.removedTargetIds||[];t=new ko([],h,c.key,c)}else if("documentRemove"in e){e.documentRemove;let n=e.documentRemove;n.document;let s=dp(r,n.document),a=n.removedTargetIds||[];t=new ko([],a,s,null)}else{if(!("filter"in e))return ue();{e.filter;let n=e.filter;n.targetId;let{count:s=0,unchangedNames:a}=n,c=new zp(s,a),h=n.targetId;t=new ph(h,c)}}return t}function xM(r,e){let t;if(e instanceof ds)t={update:mb(r,e.key,e.value)};else if(e instanceof fh)t={delete:Jp(r,e.key)};else if(e instanceof Xr)t={update:mb(r,e.key,e.data),updateMask:NM(e.fieldMask)};else{if(!(e instanceof Bp))return ue();t={verify:Jp(r,e.key)}}return e.fieldTransforms.length>0&&(t.updateTransforms=e.fieldTransforms.map(n=>function(a,c){let h=c.transform;if(h instanceof Go)return{fieldPath:c.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(h instanceof hs)return{fieldPath:c.field.canonicalString(),appendMissingElements:{values:h.elements}};if(h instanceof fs)return{fieldPath:c.field.canonicalString(),removeAllFromArray:{values:h.elements}};if(h instanceof Ko)return{fieldPath:c.field.canonicalString(),increment:h.Ie};throw ue()}(0,n))),e.precondition.isNone||(t.currentDocument=function(s,a){return a.updateTime!==void 0?{updateTime:TM(s,a.updateTime)}:a.exists!==void 0?{exists:a.exists}:ue()}(r,e.precondition)),t}function AM(r,e){return r&&r.length>0?(Le(e!==void 0),r.map(t=>function(s,a){let c=s.updateTime?Hr(s.updateTime):Hr(a);return c.isEqual(me.min())&&(c=Hr(a)),new Up(c,s.transformResults||[])}(t,e))):[]}function SM(r,e){return{documents:[TT(r,e.path)]}}function RM(r,e){let t={structuredQuery:{}},n=e.path,s;e.collectionGroup!==null?(s=n,t.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(s=n.popLast(),t.structuredQuery.from=[{collectionId:n.lastSegment()}]),t.parent=TT(r,s);let a=function(m){if(m.length!==0)return xT(Yr.create(m,"and"))}(e.filters);a&&(t.structuredQuery.where=a);let c=function(m){if(m.length!==0)return m.map(_=>function(I){return{field:Co(I.field),direction:DM(I.dir)}}(_))}(e.orderBy);c&&(t.structuredQuery.orderBy=c);let h=Hp(r,e.limit);return h!==null&&(t.structuredQuery.limit=h),e.startAt&&(t.structuredQuery.startAt=function(m){return{before:m.inclusive,values:m.position}}(e.startAt)),e.endAt&&(t.structuredQuery.endAt=function(m){return{before:!m.inclusive,values:m.position}}(e.endAt)),{ht:t,parent:s}}function PM(r){let e=EM(r.parent),t=r.structuredQuery,n=t.from?t.from.length:0,s=null;if(n>0){Le(n===1);let _=t.from[0];_.allDescendants?s=_.collectionId:e=e.child(_.collectionId)}let a=[];t.where&&(a=function(E){let I=IT(E);return I instanceof Yr&&nT(I)?I.getFilters():[I]}(t.where));let c=[];t.orderBy&&(c=function(E){return E.map(I=>function(B){return new $o(Do(B.field),function(j){switch(j){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(B.direction))}(I))}(t.orderBy));let h=null;t.limit&&(h=function(E){let I;return I=typeof E=="object"?E.value:E,jh(I)?null:I}(t.limit));let f=null;t.startAt&&(f=function(E){let I=!!E.before,k=E.values||[];return new jo(k,I)}(t.startAt));let m=null;return t.endAt&&(m=function(E){let I=!E.before,k=E.values||[];return new jo(k,I)}(t.endAt)),eM(e,s,c,a,h,"F",f,m)}function CM(r,e){let t=function(s){switch(s){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return ue()}}(e.purpose);return t==null?null:{"goog-listen-tags":t}}function IT(r){return r.unaryFilter!==void 0?function(t){switch(t.unaryFilter.op){case"IS_NAN":let n=Do(t.unaryFilter.field);return pt.create(n,"==",{doubleValue:NaN});case"IS_NULL":let s=Do(t.unaryFilter.field);return pt.create(s,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":let a=Do(t.unaryFilter.field);return pt.create(a,"!=",{doubleValue:NaN});case"IS_NOT_NULL":let c=Do(t.unaryFilter.field);return pt.create(c,"!=",{nullValue:"NULL_VALUE"});default:return ue()}}(r):r.fieldFilter!==void 0?function(t){return pt.create(Do(t.fieldFilter.field),function(s){switch(s){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return ue()}}(t.fieldFilter.op),t.fieldFilter.value)}(r):r.compositeFilter!==void 0?function(t){return Yr.create(t.compositeFilter.filters.map(n=>IT(n)),function(s){switch(s){case"AND":return"and";case"OR":return"or";default:return ue()}}(t.compositeFilter.op))}(r):ue()}function DM(r){return vM[r]}function OM(r){return wM[r]}function kM(r){return bM[r]}function Co(r){return{fieldPath:r.canonicalString()}}function Do(r){return tr.fromServerFormat(r.fieldPath)}function xT(r){return r instanceof pt?function(t){if(t.op==="=="){if(rb(t.value))return{unaryFilter:{field:Co(t.field),op:"IS_NAN"}};if(tb(t.value))return{unaryFilter:{field:Co(t.field),op:"IS_NULL"}}}else if(t.op==="!="){if(rb(t.value))return{unaryFilter:{field:Co(t.field),op:"IS_NOT_NAN"}};if(tb(t.value))return{unaryFilter:{field:Co(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Co(t.field),op:OM(t.op),value:t.value}}}(r):r instanceof Yr?function(t){let n=t.getFilters().map(s=>xT(s));return n.length===1?n[0]:{compositeFilter:{op:kM(t.op),filters:n}}}(r):ue()}function NM(r){let e=[];return r.fields.forEach(t=>e.push(t.canonicalString())),{fieldPaths:e}}function AT(r){return r.length>=4&&r.get(0)==="projects"&&r.get(2)==="databases"}var wu=class r{constructor(e,t,n,s,a=me.min(),c=me.min(),h=Rt.EMPTY_BYTE_STRING,f=null){this.target=e,this.targetId=t,this.purpose=n,this.sequenceNumber=s,this.snapshotVersion=a,this.lastLimboFreeSnapshotVersion=c,this.resumeToken=h,this.expectedCount=f}withSequenceNumber(e){return new r(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new r(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new r(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new r(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}};var Xp=class{constructor(e){this.Tt=e}};function VM(r){let e=PM({parent:r.parent,structuredQuery:r.structuredQuery});return r.limitType==="LAST"?Fp(e,e.limit,"L"):e}var yh=class{constructor(){}At(e,t){this.Rt(e,t),t.Vt()}Rt(e,t){if("nullValue"in e)this.ft(t,5);else if("booleanValue"in e)this.ft(t,10),t.gt(e.booleanValue?1:0);else if("integerValue"in e)this.ft(t,15),t.gt(Ge(e.integerValue));else if("doubleValue"in e){let n=Ge(e.doubleValue);isNaN(n)?this.ft(t,13):(this.ft(t,15),gu(n)?t.gt(0):t.gt(n))}else if("timestampValue"in e){let n=e.timestampValue;this.ft(t,20),typeof n=="string"&&(n=Cn(n)),t.yt(`${n.seconds||""}`),t.gt(n.nanos||0)}else if("stringValue"in e)this.wt(e.stringValue,t),this.St(t);else if("bytesValue"in e)this.ft(t,30),t.bt(Dn(e.bytesValue)),this.St(t);else if("referenceValue"in e)this.Dt(e.referenceValue,t);else if("geoPointValue"in e){let n=e.geoPointValue;this.ft(t,45),t.gt(n.latitude||0),t.gt(n.longitude||0)}else"mapValue"in e?eT(e)?this.ft(t,Number.MAX_SAFE_INTEGER):Zb(e)?this.vt(e.mapValue,t):(this.Ct(e.mapValue,t),this.St(t)):"arrayValue"in e?(this.Ft(e.arrayValue,t),this.St(t)):ue()}wt(e,t){this.ft(t,25),this.Mt(e,t)}Mt(e,t){t.yt(e)}Ct(e,t){let n=e.fields||{};this.ft(t,55);for(let s of Object.keys(n))this.wt(s,t),this.Rt(n[s],t)}vt(e,t){var n,s;let a=e.fields||{};this.ft(t,53);let c=Fo,h=((s=(n=a[c].arrayValue)===null||n===void 0?void 0:n.values)===null||s===void 0?void 0:s.length)||0;this.ft(t,15),t.gt(Ge(h)),this.wt(c,t),this.Rt(a[c],t)}Ft(e,t){let n=e.values||[];this.ft(t,50);for(let s of n)this.Rt(s,t)}Dt(e,t){this.ft(t,37),ce.fromName(e).path.forEach(n=>{this.ft(t,60),this.Mt(n,t)})}ft(e,t){e.gt(t)}St(e){e.gt(2)}};yh.xt=new yh;var Zp=class{constructor(){this.Tn=new em}addToCollectionParentIndex(e,t){return this.Tn.add(t),W.resolve()}getCollectionParents(e,t){return W.resolve(this.Tn.getEntries(t))}addFieldIndex(e,t){return W.resolve()}deleteFieldIndex(e,t){return W.resolve()}deleteAllFieldIndexes(e){return W.resolve()}createTargetIndexes(e,t){return W.resolve()}getDocumentsMatchingTarget(e,t){return W.resolve(null)}getIndexType(e,t){return W.resolve(0)}getFieldIndexes(e,t){return W.resolve([])}getNextCollectionGroupToUpdate(e){return W.resolve(null)}getMinOffset(e,t){return W.resolve(ls.min())}getMinOffsetFromCollectionGroup(e,t){return W.resolve(ls.min())}updateCollectionGroup(e,t,n){return W.resolve()}updateIndexEntries(e,t){return W.resolve()}},em=class{constructor(){this.index={}}add(e){let t=e.lastSegment(),n=e.popLast(),s=this.index[t]||new yt(ot.comparator),a=!s.has(n);return this.index[t]=s.add(n),a}has(e){let t=e.lastSegment(),n=e.popLast(),s=this.index[t];return s&&s.has(n)}getEntries(e){return(this.index[e]||new yt(ot.comparator)).toArray()}};var wK=new Uint8Array(0);var gb={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},ST=41943040,lr=class r{static withCacheSize(e){return new r(e,r.DEFAULT_COLLECTION_PERCENTILE,r.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,n){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=n}};lr.DEFAULT_COLLECTION_PERCENTILE=10,lr.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,lr.DEFAULT=new lr(ST,lr.DEFAULT_COLLECTION_PERCENTILE,lr.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),lr.DISABLED=new lr(-1,0,0);var bu=class r{constructor(e){this.$n=e}next(){return this.$n+=2,this.$n}static Kn(){return new r(0)}static Un(){return new r(-1)}};var _b="LruGarbageCollector",LM=1048576;function yb([r,e],[t,n]){let s=Re(r,t);return s===0?Re(e,n):s}var tm=class{constructor(e){this.Hn=e,this.buffer=new yt(yb),this.Jn=0}Yn(){return++this.Jn}Zn(e){let t=[e,this.Yn()];if(this.buffer.size<this.Hn)this.buffer=this.buffer.add(t);else{let n=this.buffer.last();yb(t,n)<0&&(this.buffer=this.buffer.delete(n).add(t))}}get maxValue(){return this.buffer.last()[0]}},rm=class{constructor(e,t,n){this.garbageCollector=e,this.asyncQueue=t,this.localStore=n,this.Xn=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.er(6e4)}stop(){this.Xn&&(this.Xn.cancel(),this.Xn=null)}get started(){return this.Xn!==null}er(e){X(_b,`Garbage collection scheduled in ${e}ms`),this.Xn=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,async()=>{this.Xn=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(t){Zo(t)?X(_b,"Ignoring IndexedDB error during garbage collection: ",t):await Xo(t)}await this.er(3e5)})}},nm=class{constructor(e,t){this.tr=e,this.params=t}calculateTargetCount(e,t){return this.tr.nr(e).next(n=>Math.floor(t/100*n))}nthSequenceNumber(e,t){if(t===0)return W.resolve(Mo.ae);let n=new tm(t);return this.tr.forEachTarget(e,s=>n.Zn(s.sequenceNumber)).next(()=>this.tr.rr(e,s=>n.Zn(s))).next(()=>n.maxValue)}removeTargets(e,t,n){return this.tr.removeTargets(e,t,n)}removeOrphanedDocuments(e,t){return this.tr.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(X("LruGarbageCollector","Garbage collection skipped; disabled"),W.resolve(gb)):this.getCacheSize(e).next(n=>n<this.params.cacheSizeCollectionThreshold?(X("LruGarbageCollector",`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),gb):this.ir(e,t))}getCacheSize(e){return this.tr.getCacheSize(e)}ir(e,t){let n,s,a,c,h,f,m,_=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(E=>(E>this.params.maximumSequenceNumbersToCollect?(X("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${E}`),s=this.params.maximumSequenceNumbersToCollect):s=E,c=Date.now(),this.nthSequenceNumber(e,s))).next(E=>(n=E,h=Date.now(),this.removeTargets(e,n,t))).next(E=>(a=E,f=Date.now(),this.removeOrphanedDocuments(e,n))).next(E=>(m=Date.now(),Ro()<=Se.DEBUG&&X("LruGarbageCollector",`LRU Garbage Collection
32
32
  Counted targets in ${c-_}ms
33
33
  Determined least recently used ${s} in `+(h-c)+`ms
34
34
  Removed ${a} targets in `+(f-h)+`ms
35
35
  Removed ${E} documents in `+(m-f)+`ms
36
- Total Duration: ${m-_}ms`),W.resolve({didRun:!0,sequenceNumbersCollected:s,targetsRemoved:a,documentsRemoved:E})))}};function kM(n,e){return new tm(n,e)}var nm=class{constructor(){this.changes=new Or(e=>e.toString(),(e,t)=>e.isEqual(t)),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,Rn.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();let r=this.changes.get(t);return r!==void 0?W.resolve(r):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}};var rm=class{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}};var im=class{constructor(e,t,r,s){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=r,this.indexManager=s}getDocument(e,t){let r=null;return this.documentOverlayCache.getOverlay(e,t).next(s=>(r=s,this.remoteDocumentCache.getEntry(e,t))).next(s=>(r!==null&&du(r.mutation,s,hn.empty(),yt.now()),s))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(r=>this.getLocalViewOfDocuments(e,r,xe()).next(()=>r))}getLocalViewOfDocuments(e,t,r=xe()){let s=os();return this.populateOverlays(e,s,t).next(()=>this.computeViews(e,t,s,r).next(a=>{let c=cu();return a.forEach((h,f)=>{c=c.insert(h,f.overlayedDocument)}),c}))}getOverlayedDocuments(e,t){let r=os();return this.populateOverlays(e,r,t).next(()=>this.computeViews(e,t,r,xe()))}populateOverlays(e,t,r){let s=[];return r.forEach(a=>{t.has(a)||s.push(a)}),this.documentOverlayCache.getOverlays(e,s).next(a=>{a.forEach((c,h)=>{t.set(c,h)})})}computeViews(e,t,r,s){let a=kr(),c=fu(),h=function(){return fu()}();return t.forEach((f,m)=>{let _=r.get(m.key);s.has(m.key)&&(_===void 0||_.mutation instanceof Zn)?a=a.insert(m.key,m):_!==void 0?(c.set(m.key,_.mutation.getFieldMask()),du(_.mutation,m,_.mutation.getFieldMask(),yt.now())):c.set(m.key,hn.empty())}),this.recalculateAndSaveOverlays(e,a).next(f=>(f.forEach((m,_)=>c.set(m,_)),t.forEach((m,_)=>{var E;return h.set(m,new rm(_,(E=c.get(m))!==null&&E!==void 0?E:null))}),h))}recalculateAndSaveOverlays(e,t){let r=fu(),s=new Je((c,h)=>c-h),a=xe();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(c=>{for(let h of c)h.keys().forEach(f=>{let m=t.get(f);if(m===null)return;let _=r.get(f)||hn.empty();_=h.applyToLocalView(m,_),r.set(f,_);let E=(s.get(h.batchId)||xe()).add(f);s=s.insert(h.batchId,E)})}).next(()=>{let c=[],h=s.getReverseIterator();for(;h.hasNext();){let f=h.getNext(),m=f.key,_=f.value,E=cT();_.forEach(I=>{if(!a.has(I)){let k=mT(t.get(I),r.get(I));k!==null&&E.set(I,k),a=a.add(I)}}),c.push(this.documentOverlayCache.saveOverlays(e,m,E))}return W.waitFor(c)}).next(()=>r)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(r=>this.recalculateAndSaveOverlays(e,r))}getDocumentsMatchingQuery(e,t,r,s){return function(c){return ce.isDocumentKey(c.path)&&c.collectionGroup===null&&c.filters.length===0}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):Y2(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,r,s):this.getDocumentsMatchingCollectionQuery(e,t,r,s)}getNextDocuments(e,t,r,s){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,r,s).next(a=>{let c=s-a.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,r.largestBatchId,s-a.size):W.resolve(os()),h=pu,f=a;return c.next(m=>W.forEach(m,(_,E)=>(h<E.largestBatchId&&(h=E.largestBatchId),a.get(_)?W.resolve():this.remoteDocumentCache.getEntry(e,_).next(I=>{f=f.insert(_,I)}))).next(()=>this.populateOverlays(e,m,a)).next(()=>this.computeViews(e,f,m,xe())).next(_=>({batchId:h,changes:uT(_)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new ce(t)).next(r=>{let s=cu();return r.isFoundDocument()&&(s=s.insert(r.key,r)),s})}getDocumentsMatchingCollectionGroupQuery(e,t,r,s){let a=t.collectionGroup,c=cu();return this.indexManager.getCollectionParents(e,a).next(h=>W.forEach(h,f=>{let m=function(E,I){return new $o(I,null,E.explicitOrderBy.slice(),E.filters.slice(),E.limit,E.limitType,E.startAt,E.endAt)}(t,f.child(a));return this.getDocumentsMatchingCollectionQuery(e,m,r,s).next(_=>{_.forEach((E,I)=>{c=c.insert(E,I)})})}).next(()=>c))}getDocumentsMatchingCollectionQuery(e,t,r,s){let a;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,r.largestBatchId).next(c=>(a=c,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,r,a,s))).next(c=>{a.forEach((f,m)=>{let _=m.getKey();c.get(_)===null&&(c=c.insert(_,Rn.newInvalidDocument(_)))});let h=cu();return c.forEach((f,m)=>{let _=a.get(f);_!==void 0&&du(_.mutation,m,hn.empty(),yt.now()),zh(t,m)&&(h=h.insert(f,m))}),h})}};var sm=class{constructor(e){this.serializer=e,this.dr=new Map,this.Ar=new Map}getBundleMetadata(e,t){return W.resolve(this.dr.get(t))}saveBundleMetadata(e,t){return this.dr.set(t.id,function(s){return{id:s.id,version:s.version,createTime:Qn(s.createTime)}}(t)),W.resolve()}getNamedQuery(e,t){return W.resolve(this.Ar.get(t))}saveNamedQuery(e,t){return this.Ar.set(t.name,function(s){return{name:s.name,query:DM(s.bundledQuery),readTime:Qn(s.readTime)}}(t)),W.resolve()}};var om=class{constructor(){this.overlays=new Je(ce.comparator),this.Rr=new Map}getOverlay(e,t){return W.resolve(this.overlays.get(t))}getOverlays(e,t){let r=os();return W.forEach(t,s=>this.getOverlay(e,s).next(a=>{a!==null&&r.set(s,a)})).next(()=>r)}saveOverlays(e,t,r){return r.forEach((s,a)=>{this.Et(e,t,a)}),W.resolve()}removeOverlaysForBatchId(e,t,r){let s=this.Rr.get(r);return s!==void 0&&(s.forEach(a=>this.overlays=this.overlays.remove(a)),this.Rr.delete(r)),W.resolve()}getOverlaysForCollection(e,t,r){let s=os(),a=t.length+1,c=new ce(t.child("")),h=this.overlays.getIteratorFrom(c);for(;h.hasNext();){let f=h.getNext().value,m=f.getKey();if(!t.isPrefixOf(m.path))break;m.path.length===a&&f.largestBatchId>r&&s.set(f.getKey(),f)}return W.resolve(s)}getOverlaysForCollectionGroup(e,t,r,s){let a=new Je((m,_)=>m-_),c=this.overlays.getIterator();for(;c.hasNext();){let m=c.getNext().value;if(m.getKey().getCollectionGroup()===t&&m.largestBatchId>r){let _=a.get(m.largestBatchId);_===null&&(_=os(),a=a.insert(m.largestBatchId,_)),_.set(m.getKey(),m)}}let h=os(),f=a.getIterator();for(;f.hasNext()&&(f.getNext().value.forEach((m,_)=>h.set(m,_)),!(h.size()>=s)););return W.resolve(h)}Et(e,t,r){let s=this.overlays.get(r.key);if(s!==null){let c=this.Rr.get(s.largestBatchId).delete(r.key);this.Rr.set(s.largestBatchId,c)}this.overlays=this.overlays.insert(r.key,new jp(t,r));let a=this.Rr.get(t);a===void 0&&(a=xe(),this.Rr.set(t,a)),this.Rr.set(t,a.add(r.key))}};var am=class{constructor(){this.sessionToken=At.EMPTY_BYTE_STRING}getSessionToken(e){return W.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,W.resolve()}};var bu=class{constructor(){this.Vr=new gt(it.mr),this.gr=new gt(it.pr)}isEmpty(){return this.Vr.isEmpty()}addReference(e,t){let r=new it(e,t);this.Vr=this.Vr.add(r),this.gr=this.gr.add(r)}yr(e,t){e.forEach(r=>this.addReference(r,t))}removeReference(e,t){this.wr(new it(e,t))}Sr(e,t){e.forEach(r=>this.removeReference(r,t))}br(e){let t=new ce(new st([])),r=new it(t,e),s=new it(t,e+1),a=[];return this.gr.forEachInRange([r,s],c=>{this.wr(c),a.push(c.key)}),a}Dr(){this.Vr.forEach(e=>this.wr(e))}wr(e){this.Vr=this.Vr.delete(e),this.gr=this.gr.delete(e)}vr(e){let t=new ce(new st([])),r=new it(t,e),s=new it(t,e+1),a=xe();return this.gr.forEachInRange([r,s],c=>{a=a.add(c.key)}),a}containsKey(e){let t=new it(e,0),r=this.Vr.firstAfterOrEqual(t);return r!==null&&e.isEqual(r.key)}},it=class{constructor(e,t){this.key=e,this.Cr=t}static mr(e,t){return ce.comparator(e.key,t.key)||Re(e.Cr,t.Cr)}static pr(e,t){return Re(e.Cr,t.Cr)||ce.comparator(e.key,t.key)}};var um=class{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Fr=1,this.Mr=new gt(it.mr)}checkEmpty(e){return W.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,r,s){let a=this.Fr;this.Fr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];let c=new Up(a,t,r,s);this.mutationQueue.push(c);for(let h of s)this.Mr=this.Mr.add(new it(h.key,a)),this.indexManager.addToCollectionParentIndex(e,h.key.path.popLast());return W.resolve(c)}lookupMutationBatch(e,t){return W.resolve(this.Or(t))}getNextMutationBatchAfterBatchId(e,t){let r=t+1,s=this.Nr(r),a=s<0?0:s;return W.resolve(this.mutationQueue.length>a?this.mutationQueue[a]:null)}getHighestUnacknowledgedBatchId(){return W.resolve(this.mutationQueue.length===0?Ym:this.Fr-1)}getAllMutationBatches(e){return W.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){let r=new it(t,0),s=new it(t,Number.POSITIVE_INFINITY),a=[];return this.Mr.forEachInRange([r,s],c=>{let h=this.Or(c.Cr);a.push(h)}),W.resolve(a)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new gt(Re);return t.forEach(s=>{let a=new it(s,0),c=new it(s,Number.POSITIVE_INFINITY);this.Mr.forEachInRange([a,c],h=>{r=r.add(h.Cr)})}),W.resolve(this.Br(r))}getAllMutationBatchesAffectingQuery(e,t){let r=t.path,s=r.length+1,a=r;ce.isDocumentKey(a)||(a=a.child(""));let c=new it(new ce(a),0),h=new gt(Re);return this.Mr.forEachWhile(f=>{let m=f.key.path;return!!r.isPrefixOf(m)&&(m.length===s&&(h=h.add(f.Cr)),!0)},c),W.resolve(this.Br(h))}Br(e){let t=[];return e.forEach(r=>{let s=this.Or(r);s!==null&&t.push(s)}),t}removeMutationBatch(e,t){Le(this.Lr(t.batchId,"removed")===0),this.mutationQueue.shift();let r=this.Mr;return W.forEach(t.mutations,s=>{let a=new it(s.key,t.batchId);return r=r.delete(a),this.referenceDelegate.markPotentiallyOrphaned(e,s.key)}).next(()=>{this.Mr=r})}qn(e){}containsKey(e,t){let r=new it(t,0),s=this.Mr.firstAfterOrEqual(r);return W.resolve(t.isEqual(s&&s.key))}performConsistencyCheck(e){return this.mutationQueue.length,W.resolve()}Lr(e,t){return this.Nr(e)}Nr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Or(e){let t=this.Nr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}};var cm=class{constructor(e){this.kr=e,this.docs=function(){return new Je(ce.comparator)}(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){let r=t.key,s=this.docs.get(r),a=s?s.size:0,c=this.kr(t);return this.docs=this.docs.insert(r,{document:t.mutableCopy(),size:c}),this.size+=c-a,this.indexManager.addToCollectionParentIndex(e,r.path.popLast())}removeEntry(e){let t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){let r=this.docs.get(t);return W.resolve(r?r.document.mutableCopy():Rn.newInvalidDocument(t))}getEntries(e,t){let r=kr();return t.forEach(s=>{let a=this.docs.get(s);r=r.insert(s,a?a.document.mutableCopy():Rn.newInvalidDocument(s))}),W.resolve(r)}getDocumentsMatchingQuery(e,t,r,s){let a=kr(),c=t.path,h=new ce(c.child("__id-9223372036854775808__")),f=this.docs.getIteratorFrom(h);for(;f.hasNext();){let{key:m,value:{document:_}}=f.getNext();if(!c.isPrefixOf(m.path))break;m.path.length>c.length+1||D2(C2(_),r)<=0||(s.has(_.key)||zh(t,_))&&(a=a.insert(_.key,_.mutableCopy()))}return W.resolve(a)}getAllFromCollectionGroup(e,t,r,s){ue()}qr(e,t){return W.forEach(this.docs,r=>t(r))}newChangeBuffer(e){return new lm(this)}getSize(e){return W.resolve(this.size)}},lm=class extends nm{constructor(e){super(),this.Ir=e}applyChanges(e){let t=[];return this.changes.forEach((r,s)=>{s.isValidDocument()?t.push(this.Ir.addEntry(e,s)):this.Ir.removeEntry(r)}),W.waitFor(t)}getFromCache(e,t){return this.Ir.getEntry(e,t)}getAllFromCache(e,t){return this.Ir.getEntries(e,t)}};var hm=class{constructor(e){this.persistence=e,this.Qr=new Or(t=>ng(t),rg),this.lastRemoteSnapshotVersion=me.min(),this.highestTargetId=0,this.$r=0,this.Kr=new bu,this.targetCount=0,this.Ur=wu.Kn()}forEachTarget(e,t){return this.Qr.forEach((r,s)=>t(s)),W.resolve()}getLastRemoteSnapshotVersion(e){return W.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return W.resolve(this.$r)}allocateTargetId(e){return this.highestTargetId=this.Ur.next(),W.resolve(this.highestTargetId)}setTargetsMetadata(e,t,r){return r&&(this.lastRemoteSnapshotVersion=r),t>this.$r&&(this.$r=t),W.resolve()}zn(e){this.Qr.set(e.target,e);let t=e.targetId;t>this.highestTargetId&&(this.Ur=new wu(t),this.highestTargetId=t),e.sequenceNumber>this.$r&&(this.$r=e.sequenceNumber)}addTargetData(e,t){return this.zn(t),this.targetCount+=1,W.resolve()}updateTargetData(e,t){return this.zn(t),W.resolve()}removeTargetData(e,t){return this.Qr.delete(t.target),this.Kr.br(t.targetId),this.targetCount-=1,W.resolve()}removeTargets(e,t,r){let s=0,a=[];return this.Qr.forEach((c,h)=>{h.sequenceNumber<=t&&r.get(h.targetId)===null&&(this.Qr.delete(c),a.push(this.removeMatchingKeysForTargetId(e,h.targetId)),s++)}),W.waitFor(a).next(()=>s)}getTargetCount(e){return W.resolve(this.targetCount)}getTargetData(e,t){let r=this.Qr.get(t)||null;return W.resolve(r)}addMatchingKeys(e,t,r){return this.Kr.yr(t,r),W.resolve()}removeMatchingKeys(e,t,r){this.Kr.Sr(t,r);let s=this.persistence.referenceDelegate,a=[];return s&&t.forEach(c=>{a.push(s.markPotentiallyOrphaned(e,c))}),W.waitFor(a)}removeMatchingKeysForTargetId(e,t){return this.Kr.br(t),W.resolve()}getMatchingKeysForTargetId(e,t){let r=this.Kr.vr(t);return W.resolve(r)}containsKey(e,t){return W.resolve(this.Kr.containsKey(t))}};var yh=class{constructor(e,t){this.Wr={},this.overlays={},this.Gr=new Lo(0),this.zr=!1,this.zr=!0,this.jr=new am,this.referenceDelegate=e(this),this.Hr=new hm(this),this.indexManager=new Yp,this.remoteDocumentCache=function(s){return new cm(s)}(r=>this.referenceDelegate.Jr(r)),this.serializer=new Jp(t),this.Yr=new sm(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.zr=!1,Promise.resolve()}get started(){return this.zr}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new om,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let r=this.Wr[e.toKey()];return r||(r=new um(t,this.referenceDelegate),this.Wr[e.toKey()]=r),r}getGlobalsCache(){return this.jr}getTargetCache(){return this.Hr}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Yr}runTransaction(e,t,r){X("MemoryPersistence","Starting transaction:",e);let s=new fm(this.Gr.next());return this.referenceDelegate.Zr(),r(s).next(a=>this.referenceDelegate.Xr(s).next(()=>a)).toPromise().then(a=>(s.raiseOnCommittedEvent(),a))}ei(e,t){return W.or(Object.values(this.Wr).map(r=>()=>r.containsKey(e,t)))}},fm=class extends Tp{constructor(e){super(),this.currentSequenceNumber=e}},dm=class n{constructor(e){this.persistence=e,this.ti=new bu,this.ni=null}static ri(e){return new n(e)}get ii(){if(this.ni)return this.ni;throw ue()}addReference(e,t,r){return this.ti.addReference(r,t),this.ii.delete(r.toString()),W.resolve()}removeReference(e,t,r){return this.ti.removeReference(r,t),this.ii.add(r.toString()),W.resolve()}markPotentiallyOrphaned(e,t){return this.ii.add(t.toString()),W.resolve()}removeTarget(e,t){this.ti.br(t.targetId).forEach(s=>this.ii.add(s.toString()));let r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next(s=>{s.forEach(a=>this.ii.add(a.toString()))}).next(()=>r.removeTargetData(e,t))}Zr(){this.ni=new Set}Xr(e){let t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return W.forEach(this.ii,r=>{let s=ce.fromPath(r);return this.si(e,s).next(a=>{a||t.removeEntry(s,me.min())})}).next(()=>(this.ni=null,t.apply(e)))}updateLimboDocument(e,t){return this.si(e,t).next(r=>{r?this.ii.delete(t.toString()):this.ii.add(t.toString())})}Jr(e){return 0}si(e,t){return W.or([()=>W.resolve(this.ti.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.ei(e,t)])}},vh=class n{constructor(e,t){this.persistence=e,this.oi=new Or(r=>V2(r.path),(r,s)=>r.isEqual(s)),this.garbageCollector=kM(this,t)}static ri(e,t){return new n(e,t)}Zr(){}Xr(e){return W.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}nr(e){let t=this.sr(e);return this.persistence.getTargetCache().getTargetCount(e).next(r=>t.next(s=>r+s))}sr(e){let t=0;return this.rr(e,r=>{t++}).next(()=>t)}rr(e,t){return W.forEach(this.oi,(r,s)=>this.ar(e,r,s).next(a=>a?W.resolve():t(s)))}removeTargets(e,t,r){return this.persistence.getTargetCache().removeTargets(e,t,r)}removeOrphanedDocuments(e,t){let r=0,s=this.persistence.getRemoteDocumentCache(),a=s.newChangeBuffer();return s.qr(e,c=>this.ar(e,c,t).next(h=>{h||(r++,a.removeEntry(c,me.min()))})).next(()=>a.apply(e)).next(()=>r)}markPotentiallyOrphaned(e,t){return this.oi.set(t,e.currentSequenceNumber),W.resolve()}removeTarget(e,t){let r=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,r)}addReference(e,t,r){return this.oi.set(r,e.currentSequenceNumber),W.resolve()}removeReference(e,t,r){return this.oi.set(r,e.currentSequenceNumber),W.resolve()}updateLimboDocument(e,t){return this.oi.set(t,e.currentSequenceNumber),W.resolve()}Jr(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=Zl(e.data.value)),t}ar(e,t,r){return W.or([()=>this.persistence.ei(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{let s=this.oi.get(t);return W.resolve(s!==void 0&&s>r)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}};var pm=class n{constructor(e,t,r,s){this.targetId=e,this.fromCache=t,this.Hi=r,this.Ji=s}static Yi(e,t){let r=xe(),s=xe();for(let a of t.docChanges)switch(a.type){case 0:r=r.add(a.doc.key);break;case 1:s=s.add(a.doc.key)}return new n(e,t.fromCache,r,s)}};var mm=class{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}};var gm=class{constructor(){this.Zi=!1,this.Xi=!1,this.es=100,this.ts=function(){return T0()?8:k2(b0())>0?6:4}()}initialize(e,t){this.ns=e,this.indexManager=t,this.Zi=!0}getDocumentsMatchingQuery(e,t,r,s){let a={result:null};return this.rs(e,t).next(c=>{a.result=c}).next(()=>{if(!a.result)return this.ss(e,t,s,r).next(c=>{a.result=c})}).next(()=>{if(a.result)return;let c=new mm;return this._s(e,t,c).next(h=>{if(a.result=h,this.Xi)return this.us(e,t,c,h.size)})}).next(()=>a.result)}us(e,t,r,s){return r.documentReadCount<this.es?(So()<=Se.DEBUG&&X("QueryEngine","SDK will not create cache indexes for query:",Ro(t),"since it only creates cache indexes for collection contains","more than or equal to",this.es,"documents"),W.resolve()):(So()<=Se.DEBUG&&X("QueryEngine","Query:",Ro(t),"scans",r.documentReadCount,"local documents and returns",s,"documents as results."),r.documentReadCount>this.ts*s?(So()<=Se.DEBUG&&X("QueryEngine","The SDK decides to create cache indexes for query:",Ro(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,Hn(t))):W.resolve())}rs(e,t){if(ib(t))return W.resolve(null);let r=Hn(t);return this.indexManager.getIndexType(e,r).next(s=>s===0?null:(t.limit!==null&&s===1&&(t=Lp(t,null,"F"),r=Hn(t)),this.indexManager.getDocumentsMatchingTarget(e,r).next(a=>{let c=xe(...a);return this.ns.getDocuments(e,c).next(h=>this.indexManager.getMinOffset(e,r).next(f=>{let m=this.cs(t,h);return this.ls(t,m,c,f.readTime)?this.rs(e,Lp(t,null,"F")):this.hs(e,m,t,f)}))})))}ss(e,t,r,s){return ib(t)||s.isEqual(me.min())?W.resolve(null):this.ns.getDocuments(e,r).next(a=>{let c=this.cs(t,a);return this.ls(t,c,r,s)?W.resolve(null):(So()<=Se.DEBUG&&X("QueryEngine","Re-using previous result from %s to execute query: %s",s.toString(),Ro(t)),this.hs(e,c,t,P2(s,pu)).next(h=>h))})}cs(e,t){let r=new gt(oT(e));return t.forEach((s,a)=>{zh(e,a)&&(r=r.add(a))}),r}ls(e,t,r,s){if(e.limit===null)return!1;if(r.size!==t.size)return!0;let a=e.limitType==="F"?t.last():t.first();return!!a&&(a.hasPendingWrites||a.version.compareTo(s)>0)}_s(e,t,r){return So()<=Se.DEBUG&&X("QueryEngine","Using full collection scan to execute query:",Ro(t)),this.ns.getDocumentsMatchingQuery(e,t,ls.min(),r)}hs(e,t,r,s){return this.ns.getDocumentsMatchingQuery(e,r,s).next(a=>(t.forEach(c=>{a=a.insert(c.key,c)}),a))}};var og="LocalStore",NM=3e8,_m=class{constructor(e,t,r,s){this.persistence=e,this.Ps=t,this.serializer=s,this.Ts=new Je(Re),this.Is=new Or(a=>ng(a),rg),this.Es=new Map,this.ds=e.getRemoteDocumentCache(),this.Hr=e.getTargetCache(),this.Yr=e.getBundleCache(),this.As(r)}As(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new im(this.ds,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.ds.setIndexManager(this.indexManager),this.Ps.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.Ts))}};function VM(n,e,t,r){return new _m(n,e,t,r)}async function AT(n,e){let t=fe(n);return await t.persistence.runTransaction("Handle user change","readonly",r=>{let s;return t.mutationQueue.getAllMutationBatches(r).next(a=>(s=a,t.As(e),t.mutationQueue.getAllMutationBatches(r))).next(a=>{let c=[],h=[],f=xe();for(let m of s){c.push(m.batchId);for(let _ of m.mutations)f=f.add(_.key)}for(let m of a){h.push(m.batchId);for(let _ of m.mutations)f=f.add(_.key)}return t.localDocuments.getDocuments(r,f).next(m=>({Rs:m,removedBatchIds:c,addedBatchIds:h}))})})}function LM(n,e){let t=fe(n);return t.persistence.runTransaction("Acknowledge batch","readwrite-primary",r=>{let s=e.batch.keys(),a=t.ds.newChangeBuffer({trackRemovals:!0});return function(h,f,m,_){let E=m.batch,I=E.keys(),k=W.resolve();return I.forEach(B=>{k=k.next(()=>_.getEntry(f,B)).next(G=>{let j=m.docVersions.get(B);Le(j!==null),G.version.compareTo(j)<0&&(E.applyToRemoteDocument(G,m),G.isValidDocument()&&(G.setReadTime(m.commitVersion),_.addEntry(G)))})}),k.next(()=>h.mutationQueue.removeMutationBatch(f,E))}(t,r,e,a).next(()=>a.apply(r)).next(()=>t.mutationQueue.performConsistencyCheck(r)).next(()=>t.documentOverlayCache.removeOverlaysForBatchId(r,s,e.batch.batchId)).next(()=>t.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(r,function(h){let f=xe();for(let m=0;m<h.mutationResults.length;++m)h.mutationResults[m].transformResults.length>0&&(f=f.add(h.batch.mutations[m].key));return f}(e))).next(()=>t.localDocuments.getDocuments(r,s))})}function ST(n){let e=fe(n);return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.Hr.getLastRemoteSnapshotVersion(t))}function MM(n,e){let t=fe(n),r=e.snapshotVersion,s=t.Ts;return t.persistence.runTransaction("Apply remote event","readwrite-primary",a=>{let c=t.ds.newChangeBuffer({trackRemovals:!0});s=t.Ts;let h=[];e.targetChanges.forEach((_,E)=>{let I=s.get(E);if(!I)return;h.push(t.Hr.removeMatchingKeys(a,_.removedDocuments,E).next(()=>t.Hr.addMatchingKeys(a,_.addedDocuments,E)));let k=I.withSequenceNumber(a.currentSequenceNumber);e.targetMismatches.get(E)!==null?k=k.withResumeToken(At.EMPTY_BYTE_STRING,me.min()).withLastLimboFreeSnapshotVersion(me.min()):_.resumeToken.approximateByteSize()>0&&(k=k.withResumeToken(_.resumeToken,r)),s=s.insert(E,k),function(G,j,J){return G.resumeToken.approximateByteSize()===0||j.snapshotVersion.toMicroseconds()-G.snapshotVersion.toMicroseconds()>=NM?!0:J.addedDocuments.size+J.modifiedDocuments.size+J.removedDocuments.size>0}(I,k,_)&&h.push(t.Hr.updateTargetData(a,k))});let f=kr(),m=xe();if(e.documentUpdates.forEach(_=>{e.resolvedLimboDocuments.has(_)&&h.push(t.persistence.referenceDelegate.updateLimboDocument(a,_))}),h.push(FM(a,c,e.documentUpdates).next(_=>{f=_.Vs,m=_.fs})),!r.isEqual(me.min())){let _=t.Hr.getLastRemoteSnapshotVersion(a).next(E=>t.Hr.setTargetsMetadata(a,a.currentSequenceNumber,r));h.push(_)}return W.waitFor(h).next(()=>c.apply(a)).next(()=>t.localDocuments.getLocalViewOfDocuments(a,f,m)).next(()=>f)}).then(a=>(t.Ts=s,a))}function FM(n,e,t){let r=xe(),s=xe();return t.forEach(a=>r=r.add(a)),e.getEntries(n,r).next(a=>{let c=kr();return t.forEach((h,f)=>{let m=a.get(h);f.isFoundDocument()!==m.isFoundDocument()&&(s=s.add(h)),f.isNoDocument()&&f.version.isEqual(me.min())?(e.removeEntry(h,f.readTime),c=c.insert(h,f)):!m.isValidDocument()||f.version.compareTo(m.version)>0||f.version.compareTo(m.version)===0&&m.hasPendingWrites?(e.addEntry(f),c=c.insert(h,f)):X(og,"Ignoring outdated watch update for ",h,". Current version:",m.version," Watch version:",f.version)}),{Vs:c,fs:s}})}function UM(n,e){let t=fe(n);return t.persistence.runTransaction("Get next mutation batch","readonly",r=>(e===void 0&&(e=Ym),t.mutationQueue.getNextMutationBatchAfterBatchId(r,e)))}function BM(n,e){let t=fe(n);return t.persistence.runTransaction("Allocate target","readwrite",r=>{let s;return t.Hr.getTargetData(r,e).next(a=>a?(s=a,W.resolve(s)):t.Hr.allocateTargetId(r).next(c=>(s=new vu(e,c,"TargetPurposeListen",r.currentSequenceNumber),t.Hr.addTargetData(r,s).next(()=>s))))}).then(r=>{let s=t.Ts.get(r.targetId);return(s===null||r.snapshotVersion.compareTo(s.snapshotVersion)>0)&&(t.Ts=t.Ts.insert(r.targetId,r),t.Is.set(e,r.targetId)),r})}async function ym(n,e,t){let r=fe(n),s=r.Ts.get(e),a=t?"readwrite":"readwrite-primary";try{t||await r.persistence.runTransaction("Release target",a,c=>r.persistence.referenceDelegate.removeTarget(c,s))}catch(c){if(!Xo(c))throw c;X(og,`Failed to update sequence numbers for target ${e}: ${c}`)}r.Ts=r.Ts.remove(e),r.Is.delete(s.target)}function _b(n,e,t){let r=fe(n),s=me.min(),a=xe();return r.persistence.runTransaction("Execute query","readwrite",c=>function(f,m,_){let E=fe(f),I=E.Is.get(_);return I!==void 0?W.resolve(E.Ts.get(I)):E.Hr.getTargetData(m,_)}(r,c,Hn(e)).next(h=>{if(h)return s=h.lastLimboFreeSnapshotVersion,r.Hr.getMatchingKeysForTargetId(c,h.targetId).next(f=>{a=f})}).next(()=>r.Ps.getDocumentsMatchingQuery(c,e,t?s:me.min(),t?a:xe())).next(h=>(jM(r,Z2(e),h),{documents:h,gs:a})))}function jM(n,e,t){let r=n.Es.get(e)||me.min();t.forEach((s,a)=>{a.readTime.compareTo(r)>0&&(r=a.readTime)}),n.Es.set(e,r)}var wh=class{constructor(){this.activeTargetIds=sM()}Ds(e){this.activeTargetIds=this.activeTargetIds.add(e)}vs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}bs(){let e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}};var vm=class{constructor(){this.ho=new wh,this.Po={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,r){}addLocalQueryTarget(e,t=!0){return t&&this.ho.Ds(e),this.Po[e]||"not-current"}updateQueryState(e,t,r){this.Po[e]=t}removeLocalQueryTarget(e){this.ho.vs(e)}isLocalQueryTarget(e){return this.ho.activeTargetIds.has(e)}clearQueryState(e){delete this.Po[e]}getAllActiveQueryTargets(){return this.ho.activeTargetIds}isActiveQueryTarget(e){return this.ho.activeTargetIds.has(e)}start(){return this.ho=new wh,Promise.resolve()}handleUserChange(e,t,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}};var wm=class{To(e){}shutdown(){}};var yb="ConnectivityMonitor",bh=class{constructor(){this.Io=()=>this.Eo(),this.Ao=()=>this.Ro(),this.Vo=[],this.mo()}To(e){this.Vo.push(e)}shutdown(){window.removeEventListener("online",this.Io),window.removeEventListener("offline",this.Ao)}mo(){window.addEventListener("online",this.Io),window.addEventListener("offline",this.Ao)}Eo(){X(yb,"Network connectivity changed: AVAILABLE");for(let e of this.Vo)e(0)}Ro(){X(yb,"Network connectivity changed: UNAVAILABLE");for(let e of this.Vo)e(1)}static D(){return typeof window!="undefined"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}};var Xl=null;function bm(){return Xl===null?Xl=function(){return 268435456+Math.round(2147483648*Math.random())}():Xl++,"0x"+Xl.toString(16)}var fp="RestConnection",$M={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"},Tm=class{get fo(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;let t=e.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.po=t+"://"+e.host,this.yo=`projects/${r}/databases/${s}`,this.wo=this.databaseId.database===uh?`project_id=${r}`:`project_id=${r}&database_id=${s}`}So(e,t,r,s,a){let c=bm(),h=this.bo(e,t.toUriEncodedString());X(fp,`Sending RPC '${e}' ${c}:`,h,r);let f={"google-cloud-resource-prefix":this.yo,"x-goog-request-params":this.wo};return this.Do(f,s,a),this.vo(e,h,f,r).then(m=>(X(fp,`Received RPC '${e}' ${c}: `,m),m),m=>{throw No(fp,`RPC '${e}' ${c} failed with error: `,m,"url: ",h,"request:",r),m})}Co(e,t,r,s,a,c){return this.So(e,t,r,s,a)}Do(e,t,r){e["X-Goog-Api-Client"]=function(){return"gl-js/ fire/"+Jo}(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach((s,a)=>e[a]=s),r&&r.headers.forEach((s,a)=>e[a]=s)}bo(e,t){let r=$M[e];return`${this.po}/v1/${t}:${r}`}terminate(){}};var Em=class{constructor(e){this.Fo=e.Fo,this.Mo=e.Mo}xo(e){this.Oo=e}No(e){this.Bo=e}Lo(e){this.ko=e}onMessage(e){this.qo=e}close(){this.Mo()}send(e){this.Fo(e)}Qo(){this.Oo()}$o(){this.Bo()}Ko(e){this.ko(e)}Uo(e){this.qo(e)}};var xt="WebChannelConnection",Im=class extends Tm{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}vo(e,t,r,s){let a=bm();return new Promise((c,h)=>{let f=new op;f.setWithCredentials(!0),f.listenOnce(ap.COMPLETE,()=>{try{switch(f.getLastErrorCode()){case uu.NO_ERROR:let _=f.getResponseJson();X(xt,`XHR for RPC '${e}' ${a} received:`,JSON.stringify(_)),c(_);break;case uu.TIMEOUT:X(xt,`RPC '${e}' ${a} timed out`),h(new re(H.DEADLINE_EXCEEDED,"Request time out"));break;case uu.HTTP_ERROR:let E=f.getStatus();if(X(xt,`RPC '${e}' ${a} failed with status:`,E,"response text:",f.getResponseText()),E>0){let I=f.getResponseJson();Array.isArray(I)&&(I=I[0]);let k=I==null?void 0:I.error;if(k&&k.status&&k.message){let B=function(j){let J=j.toLowerCase().replace(/_/g,"-");return Object.values(H).indexOf(J)>=0?J:H.UNKNOWN}(k.status);h(new re(B,k.message))}else h(new re(H.UNKNOWN,"Server responded with status "+f.getStatus()))}else h(new re(H.UNAVAILABLE,"Connection failed."));break;default:ue()}}finally{X(xt,`RPC '${e}' ${a} completed.`)}});let m=JSON.stringify(s);X(xt,`RPC '${e}' ${a} sending request:`,s),f.send(t,"POST",m,r,15)})}Wo(e,t,r){let s=bm(),a=[this.po,"/","google.firestore.v1.Firestore","/",e,"/channel"],c=lp(),h=cp(),f={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},m=this.longPollingOptions.timeoutSeconds;m!==void 0&&(f.longPollingTimeout=Math.round(1e3*m)),this.useFetchStreams&&(f.useFetchStreams=!0),this.Do(f.initMessageHeaders,t,r),f.encodeInitMessageHeaders=!0;let _=a.join("");X(xt,`Creating RPC '${e}' stream ${s}: ${_}`,f);let E=c.createWebChannel(_,f),I=!1,k=!1,B=new Em({Fo:j=>{k?X(xt,`Not sending because RPC '${e}' stream ${s} is closed:`,j):(I||(X(xt,`Opening RPC '${e}' stream ${s} transport.`),E.open(),I=!0),X(xt,`RPC '${e}' stream ${s} sending:`,j),E.send(j))},Mo:()=>E.close()}),G=(j,J,ee)=>{j.listen(J,ne=>{try{ee(ne)}catch(le){setTimeout(()=>{throw le},0)}})};return G(E,Ao.EventType.OPEN,()=>{k||(X(xt,`RPC '${e}' stream ${s} transport opened.`),B.Qo())}),G(E,Ao.EventType.CLOSE,()=>{k||(k=!0,X(xt,`RPC '${e}' stream ${s} transport closed`),B.Ko())}),G(E,Ao.EventType.ERROR,j=>{k||(k=!0,No(xt,`RPC '${e}' stream ${s} transport errored:`,j),B.Ko(new re(H.UNAVAILABLE,"The operation could not be completed")))}),G(E,Ao.EventType.MESSAGE,j=>{var J;if(!k){let ee=j.data[0];Le(!!ee);let ne=ee,le=(ne==null?void 0:ne.error)||((J=ne[0])===null||J===void 0?void 0:J.error);if(le){X(xt,`RPC '${e}' stream ${s} received error:`,le);let de=le.status,ie=function(R){let D=rt[R];if(D!==void 0)return _T(D)}(de),C=le.message;ie===void 0&&(ie=H.INTERNAL,C="Unknown error status: "+de+" with message "+le.message),k=!0,B.Ko(new re(ie,C)),E.close()}else X(xt,`RPC '${e}' stream ${s} received:`,ee),B.Uo(ee)}}),G(h,up.STAT_EVENT,j=>{j.stat===Ql.PROXY?X(xt,`RPC '${e}' stream ${s} detected buffering proxy`):j.stat===Ql.NOPROXY&&X(xt,`RPC '${e}' stream ${s} detected no buffering proxy`)}),setTimeout(()=>{B.$o()},0),B}};function dp(){return typeof document!="undefined"?document:null}function Gh(n){return new Gp(n,!0)}var Th=class{constructor(e,t,r=1e3,s=1.5,a=6e4){this.Ti=e,this.timerId=t,this.Go=r,this.zo=s,this.jo=a,this.Ho=0,this.Jo=null,this.Yo=Date.now(),this.reset()}reset(){this.Ho=0}Zo(){this.Ho=this.jo}Xo(e){this.cancel();let t=Math.floor(this.Ho+this.e_()),r=Math.max(0,Date.now()-this.Yo),s=Math.max(0,t-r);s>0&&X("ExponentialBackoff",`Backing off for ${s} ms (base delay: ${this.Ho} ms, delay with jitter: ${t} ms, last attempt: ${r} ms ago)`),this.Jo=this.Ti.enqueueAfterDelay(this.timerId,s,()=>(this.Yo=Date.now(),e())),this.Ho*=this.zo,this.Ho<this.Go&&(this.Ho=this.Go),this.Ho>this.jo&&(this.Ho=this.jo)}t_(){this.Jo!==null&&(this.Jo.skipDelay(),this.Jo=null)}cancel(){this.Jo!==null&&(this.Jo.cancel(),this.Jo=null)}e_(){return(Math.random()-.5)*this.Ho}};var vb="PersistentStream",Eh=class{constructor(e,t,r,s,a,c,h,f){this.Ti=e,this.n_=r,this.r_=s,this.connection=a,this.authCredentialsProvider=c,this.appCheckCredentialsProvider=h,this.listener=f,this.state=0,this.i_=0,this.s_=null,this.o_=null,this.stream=null,this.__=0,this.a_=new Th(e,t)}u_(){return this.state===1||this.state===5||this.c_()}c_(){return this.state===2||this.state===3}start(){this.__=0,this.state!==4?this.auth():this.l_()}async stop(){this.u_()&&await this.close(0)}h_(){this.state=0,this.a_.reset()}P_(){this.c_()&&this.s_===null&&(this.s_=this.Ti.enqueueAfterDelay(this.n_,6e4,()=>this.T_()))}I_(e){this.E_(),this.stream.send(e)}async T_(){if(this.c_())return this.close(0)}E_(){this.s_&&(this.s_.cancel(),this.s_=null)}d_(){this.o_&&(this.o_.cancel(),this.o_=null)}async close(e,t){this.E_(),this.d_(),this.a_.cancel(),this.i_++,e!==4?this.a_.reset():t&&t.code===H.RESOURCE_EXHAUSTED?(Pr(t.toString()),Pr("Using maximum backoff delay to prevent overloading the backend."),this.a_.Zo()):t&&t.code===H.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.A_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.Lo(t)}A_(){}auth(){this.state=1;let e=this.R_(this.i_),t=this.i_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([r,s])=>{this.i_===t&&this.V_(r,s)},r=>{e(()=>{let s=new re(H.UNKNOWN,"Fetching auth token failed: "+r.message);return this.m_(s)})})}V_(e,t){let r=this.R_(this.i_);this.stream=this.f_(e,t),this.stream.xo(()=>{r(()=>this.listener.xo())}),this.stream.No(()=>{r(()=>(this.state=2,this.o_=this.Ti.enqueueAfterDelay(this.r_,1e4,()=>(this.c_()&&(this.state=3),Promise.resolve())),this.listener.No()))}),this.stream.Lo(s=>{r(()=>this.m_(s))}),this.stream.onMessage(s=>{r(()=>++this.__==1?this.g_(s):this.onNext(s))})}l_(){this.state=5,this.a_.Xo(async()=>{this.state=0,this.start()})}m_(e){return X(vb,`close with error: ${e}`),this.stream=null,this.close(4,e)}R_(e){return t=>{this.Ti.enqueueAndForget(()=>this.i_===e?t():(X(vb,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}},xm=class extends Eh{constructor(e,t,r,s,a,c){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,r,s,c),this.serializer=a}f_(e,t){return this.connection.Wo("Listen",e,t)}g_(e){return this.onNext(e)}onNext(e){this.a_.reset();let t=wM(this.serializer,e),r=function(a){if(!("targetChange"in a))return me.min();let c=a.targetChange;return c.targetIds&&c.targetIds.length?me.min():c.readTime?Qn(c.readTime):me.min()}(e);return this.listener.p_(t,r)}y_(e){let t={};t.database=Qp(this.serializer),t.addTarget=function(a,c){let h,f=c.target;if(h=Vp(f)?{documents:EM(a,f)}:{query:IM(a,f).ht},h.targetId=c.targetId,c.resumeToken.approximateByteSize()>0){h.resumeToken=yT(a,c.resumeToken);let m=Kp(a,c.expectedCount);m!==null&&(h.expectedCount=m)}else if(c.snapshotVersion.compareTo(me.min())>0){h.readTime=gh(a,c.snapshotVersion.toTimestamp());let m=Kp(a,c.expectedCount);m!==null&&(h.expectedCount=m)}return h}(this.serializer,e);let r=AM(this.serializer,e);r&&(t.labels=r),this.I_(t)}w_(e){let t={};t.database=Qp(this.serializer),t.removeTarget=e,this.I_(t)}},Am=class extends Eh{constructor(e,t,r,s,a,c){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,r,s,c),this.serializer=a}get S_(){return this.__>0}start(){this.lastStreamToken=void 0,super.start()}A_(){this.S_&&this.b_([])}f_(e,t){return this.connection.Wo("Write",e,t)}g_(e){return Le(!!e.streamToken),this.lastStreamToken=e.streamToken,Le(!e.writeResults||e.writeResults.length===0),this.listener.D_()}onNext(e){Le(!!e.streamToken),this.lastStreamToken=e.streamToken,this.a_.reset();let t=TM(e.writeResults,e.commitTime),r=Qn(e.commitTime);return this.listener.v_(r,t)}C_(){let e={};e.database=Qp(this.serializer),this.I_(e)}b_(e){let t={streamToken:this.lastStreamToken,writes:e.map(r=>bM(this.serializer,r))};this.I_(t)}};var Sm=class{},Rm=class extends Sm{constructor(e,t,r,s){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=r,this.serializer=s,this.F_=!1}M_(){if(this.F_)throw new re(H.FAILED_PRECONDITION,"The client has already been terminated.")}So(e,t,r,s){return this.M_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([a,c])=>this.connection.So(e,Wp(t,r),s,a,c)).catch(a=>{throw a.name==="FirebaseError"?(a.code===H.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),a):new re(H.UNKNOWN,a.toString())})}Co(e,t,r,s,a){return this.M_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([c,h])=>this.connection.Co(e,Wp(t,r),s,c,h,a)).catch(c=>{throw c.name==="FirebaseError"?(c.code===H.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),c):new re(H.UNKNOWN,c.toString())})}terminate(){this.F_=!0,this.connection.terminate()}},Pm=class{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.x_=0,this.O_=null,this.N_=!0}B_(){this.x_===0&&(this.L_("Unknown"),this.O_=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.O_=null,this.k_("Backend didn't respond within 10 seconds."),this.L_("Offline"),Promise.resolve())))}q_(e){this.state==="Online"?this.L_("Unknown"):(this.x_++,this.x_>=1&&(this.Q_(),this.k_(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.L_("Offline")))}set(e){this.Q_(),this.x_=0,e==="Online"&&(this.N_=!1),this.L_(e)}L_(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}k_(e){let t=`Could not reach Cloud Firestore backend. ${e}
37
- This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.N_?(Pr(t),this.N_=!1):X("OnlineStateTracker",t)}Q_(){this.O_!==null&&(this.O_.cancel(),this.O_=null)}};var ps="RemoteStore",Cm=class{constructor(e,t,r,s,a){this.localStore=e,this.datastore=t,this.asyncQueue=r,this.remoteSyncer={},this.K_=[],this.U_=new Map,this.W_=new Set,this.G_=[],this.z_=a,this.z_.To(c=>{r.enqueueAndForget(async()=>{ms(this)&&(X(ps,"Restarting streams for network reachability change."),await async function(f){let m=fe(f);m.W_.add(4),await Pu(m),m.j_.set("Unknown"),m.W_.delete(4),await Kh(m)}(this))})}),this.j_=new Pm(r,s)}};async function Kh(n){if(ms(n))for(let e of n.G_)await e(!0)}async function Pu(n){for(let e of n.G_)await e(!1)}function RT(n,e){let t=fe(n);t.U_.has(e.targetId)||(t.U_.set(e.targetId,e),lg(t)?cg(t):Zo(t).c_()&&ug(t,e))}function ag(n,e){let t=fe(n),r=Zo(t);t.U_.delete(e),r.c_()&&PT(t,e),t.U_.size===0&&(r.c_()?r.P_():ms(t)&&t.j_.set("Unknown"))}function ug(n,e){if(n.H_.Ne(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo(me.min())>0){let t=n.remoteSyncer.getRemoteKeysForTarget(e.targetId).size;e=e.withExpectedCount(t)}Zo(n).y_(e)}function PT(n,e){n.H_.Ne(e),Zo(n).w_(e)}function cg(n){n.H_=new zp({getRemoteKeysForTarget:e=>n.remoteSyncer.getRemoteKeysForTarget(e),lt:e=>n.U_.get(e)||null,it:()=>n.datastore.serializer.databaseId}),Zo(n).start(),n.j_.B_()}function lg(n){return ms(n)&&!Zo(n).u_()&&n.U_.size>0}function ms(n){return fe(n).W_.size===0}function CT(n){n.H_=void 0}async function qM(n){n.j_.set("Online")}async function zM(n){n.U_.forEach((e,t)=>{ug(n,e)})}async function GM(n,e){CT(n),lg(n)?(n.j_.q_(e),cg(n)):n.j_.set("Unknown")}async function KM(n,e,t){if(n.j_.set("Online"),e instanceof ph&&e.state===2&&e.cause)try{await async function(s,a){let c=a.cause;for(let h of a.targetIds)s.U_.has(h)&&(await s.remoteSyncer.rejectListen(h,c),s.U_.delete(h),s.H_.removeTarget(h))}(n,e)}catch(r){X(ps,"Failed to remove targets %s: %s ",e.targetIds.join(","),r),await Ih(n,r)}else if(e instanceof Oo?n.H_.We(e):e instanceof dh?n.H_.Ze(e):n.H_.je(e),!t.isEqual(me.min()))try{let r=await ST(n.localStore);t.compareTo(r)>=0&&await function(a,c){let h=a.H_.ot(c);return h.targetChanges.forEach((f,m)=>{if(f.resumeToken.approximateByteSize()>0){let _=a.U_.get(m);_&&a.U_.set(m,_.withResumeToken(f.resumeToken,c))}}),h.targetMismatches.forEach((f,m)=>{let _=a.U_.get(f);if(!_)return;a.U_.set(f,_.withResumeToken(At.EMPTY_BYTE_STRING,_.snapshotVersion)),PT(a,f);let E=new vu(_.target,f,m,_.sequenceNumber);ug(a,E)}),a.remoteSyncer.applyRemoteEvent(h)}(n,t)}catch(r){X(ps,"Failed to raise snapshot:",r),await Ih(n,r)}}async function Ih(n,e,t){if(!Xo(e))throw e;n.W_.add(1),await Pu(n),n.j_.set("Offline"),t||(t=()=>ST(n.localStore)),n.asyncQueue.enqueueRetryable(async()=>{X(ps,"Retrying IndexedDB access"),await t(),n.W_.delete(1),await Kh(n)})}function DT(n,e){return e().catch(t=>Ih(n,t,e))}async function Wh(n){let e=fe(n),t=vi(e),r=e.K_.length>0?e.K_[e.K_.length-1].batchId:Ym;for(;WM(e);)try{let s=await UM(e.localStore,r);if(s===null){e.K_.length===0&&t.P_();break}r=s.batchId,HM(e,s)}catch(s){await Ih(e,s)}OT(e)&&kT(e)}function WM(n){return ms(n)&&n.K_.length<10}function HM(n,e){n.K_.push(e);let t=vi(n);t.c_()&&t.S_&&t.b_(e.mutations)}function OT(n){return ms(n)&&!vi(n).u_()&&n.K_.length>0}function kT(n){vi(n).start()}async function QM(n){vi(n).C_()}async function JM(n){let e=vi(n);for(let t of n.K_)e.b_(t.mutations)}async function YM(n,e,t){let r=n.K_.shift(),s=Bp.from(r,e,t);await DT(n,()=>n.remoteSyncer.applySuccessfulWrite(s)),await Wh(n)}async function XM(n,e){e&&vi(n).S_&&await async function(r,s){if(function(c){return fM(c)&&c!==H.ABORTED}(s.code)){let a=r.K_.shift();vi(r).h_(),await DT(r,()=>r.remoteSyncer.rejectFailedWrite(a.batchId,s)),await Wh(r)}}(n,e),OT(n)&&kT(n)}async function wb(n,e){let t=fe(n);t.asyncQueue.verifyOperationInProgress(),X(ps,"RemoteStore received new credentials");let r=ms(t);t.W_.add(3),await Pu(t),r&&t.j_.set("Unknown"),await t.remoteSyncer.handleCredentialChange(e),t.W_.delete(3),await Kh(t)}async function ZM(n,e){let t=fe(n);e?(t.W_.delete(2),await Kh(t)):e||(t.W_.add(2),await Pu(t),t.j_.set("Unknown"))}function Zo(n){return n.J_||(n.J_=function(t,r,s){let a=fe(t);return a.M_(),new xm(r,a.connection,a.authCredentials,a.appCheckCredentials,a.serializer,s)}(n.datastore,n.asyncQueue,{xo:qM.bind(null,n),No:zM.bind(null,n),Lo:GM.bind(null,n),p_:KM.bind(null,n)}),n.G_.push(async e=>{e?(n.J_.h_(),lg(n)?cg(n):n.j_.set("Unknown")):(await n.J_.stop(),CT(n))})),n.J_}function vi(n){return n.Y_||(n.Y_=function(t,r,s){let a=fe(t);return a.M_(),new Am(r,a.connection,a.authCredentials,a.appCheckCredentials,a.serializer,s)}(n.datastore,n.asyncQueue,{xo:()=>Promise.resolve(),No:QM.bind(null,n),Lo:XM.bind(null,n),D_:JM.bind(null,n),v_:YM.bind(null,n)}),n.G_.push(async e=>{e?(n.Y_.h_(),await Wh(n)):(await n.Y_.stop(),n.K_.length>0&&(X(ps,`Stopping write stream with ${n.K_.length} pending writes`),n.K_=[]))})),n.Y_}var Dm=class n{constructor(e,t,r,s,a){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=r,this.op=s,this.removalCallback=a,this.deferred=new Kn,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(c=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,t,r,s,a){let c=Date.now()+r,h=new n(e,t,c,s,a);return h.start(r),h}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new re(H.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then(e=>this.deferred.resolve(e))):Promise.resolve())}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}};function hg(n,e){if(Pr("AsyncQueue",`${e}: ${n}`),Xo(n))return new re(H.UNAVAILABLE,`${e}: ${n}`);throw n}var xh=class n{static emptySet(e){return new n(e.comparator)}constructor(e){this.comparator=e?(t,r)=>e(t,r)||ce.comparator(t.key,r.key):(t,r)=>ce.comparator(t.key,r.key),this.keyedMap=cu(),this.sortedSet=new Je(this.comparator)}has(e){return this.keyedMap.get(e)!=null}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){let t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal((t,r)=>(e(t),!1))}add(e){let t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){let t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof n)||this.size!==e.size)return!1;let t=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();for(;t.hasNext();){let s=t.getNext().key,a=r.getNext().key;if(!s.isEqual(a))return!1}return!0}toString(){let e=[];return this.forEach(t=>{e.push(t.toString())}),e.length===0?"DocumentSet ()":`DocumentSet (
36
+ Total Duration: ${m-_}ms`),W.resolve({didRun:!0,sequenceNumbersCollected:s,targetsRemoved:a,documentsRemoved:E})))}};function MM(r,e){return new nm(r,e)}var im=class{constructor(){this.changes=new On(e=>e.toString(),(e,t)=>e.isEqual(t)),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,Sr.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();let n=this.changes.get(t);return n!==void 0?W.resolve(n):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}};var sm=class{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}};var om=class{constructor(e,t,n,s){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=n,this.indexManager=s}getDocument(e,t){let n=null;return this.documentOverlayCache.getOverlay(e,t).next(s=>(n=s,this.remoteDocumentCache.getEntry(e,t))).next(s=>(n!==null&&pu(n.mutation,s,hr.empty(),wt.now()),s))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(n=>this.getLocalViewOfDocuments(e,n,xe()).next(()=>n))}getLocalViewOfDocuments(e,t,n=xe()){let s=os();return this.populateOverlays(e,s,t).next(()=>this.computeViews(e,t,s,n).next(a=>{let c=lu();return a.forEach((h,f)=>{c=c.insert(h,f.overlayedDocument)}),c}))}getOverlayedDocuments(e,t){let n=os();return this.populateOverlays(e,n,t).next(()=>this.computeViews(e,t,n,xe()))}populateOverlays(e,t,n){let s=[];return n.forEach(a=>{t.has(a)||s.push(a)}),this.documentOverlayCache.getOverlays(e,s).next(a=>{a.forEach((c,h)=>{t.set(c,h)})})}computeViews(e,t,n,s){let a=kn(),c=du(),h=function(){return du()}();return t.forEach((f,m)=>{let _=n.get(m.key);s.has(m.key)&&(_===void 0||_.mutation instanceof Xr)?a=a.insert(m.key,m):_!==void 0?(c.set(m.key,_.mutation.getFieldMask()),pu(_.mutation,m,_.mutation.getFieldMask(),wt.now())):c.set(m.key,hr.empty())}),this.recalculateAndSaveOverlays(e,a).next(f=>(f.forEach((m,_)=>c.set(m,_)),t.forEach((m,_)=>{var E;return h.set(m,new sm(_,(E=c.get(m))!==null&&E!==void 0?E:null))}),h))}recalculateAndSaveOverlays(e,t){let n=du(),s=new Ye((c,h)=>c-h),a=xe();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(c=>{for(let h of c)h.keys().forEach(f=>{let m=t.get(f);if(m===null)return;let _=n.get(f)||hr.empty();_=h.applyToLocalView(m,_),n.set(f,_);let E=(s.get(h.batchId)||xe()).add(f);s=s.insert(h.batchId,E)})}).next(()=>{let c=[],h=s.getReverseIterator();for(;h.hasNext();){let f=h.getNext(),m=f.key,_=f.value,E=hT();_.forEach(I=>{if(!a.has(I)){let k=_T(t.get(I),n.get(I));k!==null&&E.set(I,k),a=a.add(I)}}),c.push(this.documentOverlayCache.saveOverlays(e,m,E))}return W.waitFor(c)}).next(()=>n)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(n=>this.recalculateAndSaveOverlays(e,n))}getDocumentsMatchingQuery(e,t,n,s){return function(c){return ce.isDocumentKey(c.path)&&c.collectionGroup===null&&c.filters.length===0}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):tM(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,n,s):this.getDocumentsMatchingCollectionQuery(e,t,n,s)}getNextDocuments(e,t,n,s){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,n,s).next(a=>{let c=s-a.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,n.largestBatchId,s-a.size):W.resolve(os()),h=mu,f=a;return c.next(m=>W.forEach(m,(_,E)=>(h<E.largestBatchId&&(h=E.largestBatchId),a.get(_)?W.resolve():this.remoteDocumentCache.getEntry(e,_).next(I=>{f=f.insert(_,I)}))).next(()=>this.populateOverlays(e,m,a)).next(()=>this.computeViews(e,f,m,xe())).next(_=>({batchId:h,changes:lT(_)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new ce(t)).next(n=>{let s=lu();return n.isFoundDocument()&&(s=s.insert(n.key,n)),s})}getDocumentsMatchingCollectionGroupQuery(e,t,n,s){let a=t.collectionGroup,c=lu();return this.indexManager.getCollectionParents(e,a).next(h=>W.forEach(h,f=>{let m=function(E,I){return new qo(I,null,E.explicitOrderBy.slice(),E.filters.slice(),E.limit,E.limitType,E.startAt,E.endAt)}(t,f.child(a));return this.getDocumentsMatchingCollectionQuery(e,m,n,s).next(_=>{_.forEach((E,I)=>{c=c.insert(E,I)})})}).next(()=>c))}getDocumentsMatchingCollectionQuery(e,t,n,s){let a;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,n.largestBatchId).next(c=>(a=c,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,n,a,s))).next(c=>{a.forEach((f,m)=>{let _=m.getKey();c.get(_)===null&&(c=c.insert(_,Sr.newInvalidDocument(_)))});let h=lu();return c.forEach((f,m)=>{let _=a.get(f);_!==void 0&&pu(_.mutation,m,hr.empty(),wt.now()),Gh(t,m)&&(h=h.insert(f,m))}),h})}};var am=class{constructor(e){this.serializer=e,this.dr=new Map,this.Ar=new Map}getBundleMetadata(e,t){return W.resolve(this.dr.get(t))}saveBundleMetadata(e,t){return this.dr.set(t.id,function(s){return{id:s.id,version:s.version,createTime:Hr(s.createTime)}}(t)),W.resolve()}getNamedQuery(e,t){return W.resolve(this.Ar.get(t))}saveNamedQuery(e,t){return this.Ar.set(t.name,function(s){return{name:s.name,query:VM(s.bundledQuery),readTime:Hr(s.readTime)}}(t)),W.resolve()}};var um=class{constructor(){this.overlays=new Ye(ce.comparator),this.Rr=new Map}getOverlay(e,t){return W.resolve(this.overlays.get(t))}getOverlays(e,t){let n=os();return W.forEach(t,s=>this.getOverlay(e,s).next(a=>{a!==null&&n.set(s,a)})).next(()=>n)}saveOverlays(e,t,n){return n.forEach((s,a)=>{this.Et(e,t,a)}),W.resolve()}removeOverlaysForBatchId(e,t,n){let s=this.Rr.get(n);return s!==void 0&&(s.forEach(a=>this.overlays=this.overlays.remove(a)),this.Rr.delete(n)),W.resolve()}getOverlaysForCollection(e,t,n){let s=os(),a=t.length+1,c=new ce(t.child("")),h=this.overlays.getIteratorFrom(c);for(;h.hasNext();){let f=h.getNext().value,m=f.getKey();if(!t.isPrefixOf(m.path))break;m.path.length===a&&f.largestBatchId>n&&s.set(f.getKey(),f)}return W.resolve(s)}getOverlaysForCollectionGroup(e,t,n,s){let a=new Ye((m,_)=>m-_),c=this.overlays.getIterator();for(;c.hasNext();){let m=c.getNext().value;if(m.getKey().getCollectionGroup()===t&&m.largestBatchId>n){let _=a.get(m.largestBatchId);_===null&&(_=os(),a=a.insert(m.largestBatchId,_)),_.set(m.getKey(),m)}}let h=os(),f=a.getIterator();for(;f.hasNext()&&(f.getNext().value.forEach((m,_)=>h.set(m,_)),!(h.size()>=s)););return W.resolve(h)}Et(e,t,n){let s=this.overlays.get(n.key);if(s!==null){let c=this.Rr.get(s.largestBatchId).delete(n.key);this.Rr.set(s.largestBatchId,c)}this.overlays=this.overlays.insert(n.key,new qp(t,n));let a=this.Rr.get(t);a===void 0&&(a=xe(),this.Rr.set(t,a)),this.Rr.set(t,a.add(n.key))}};var cm=class{constructor(){this.sessionToken=Rt.EMPTY_BYTE_STRING}getSessionToken(e){return W.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,W.resolve()}};var Tu=class{constructor(){this.Vr=new yt(st.mr),this.gr=new yt(st.pr)}isEmpty(){return this.Vr.isEmpty()}addReference(e,t){let n=new st(e,t);this.Vr=this.Vr.add(n),this.gr=this.gr.add(n)}yr(e,t){e.forEach(n=>this.addReference(n,t))}removeReference(e,t){this.wr(new st(e,t))}Sr(e,t){e.forEach(n=>this.removeReference(n,t))}br(e){let t=new ce(new ot([])),n=new st(t,e),s=new st(t,e+1),a=[];return this.gr.forEachInRange([n,s],c=>{this.wr(c),a.push(c.key)}),a}Dr(){this.Vr.forEach(e=>this.wr(e))}wr(e){this.Vr=this.Vr.delete(e),this.gr=this.gr.delete(e)}vr(e){let t=new ce(new ot([])),n=new st(t,e),s=new st(t,e+1),a=xe();return this.gr.forEachInRange([n,s],c=>{a=a.add(c.key)}),a}containsKey(e){let t=new st(e,0),n=this.Vr.firstAfterOrEqual(t);return n!==null&&e.isEqual(n.key)}},st=class{constructor(e,t){this.key=e,this.Cr=t}static mr(e,t){return ce.comparator(e.key,t.key)||Re(e.Cr,t.Cr)}static pr(e,t){return Re(e.Cr,t.Cr)||ce.comparator(e.key,t.key)}};var lm=class{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Fr=1,this.Mr=new yt(st.mr)}checkEmpty(e){return W.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,n,s){let a=this.Fr;this.Fr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];let c=new jp(a,t,n,s);this.mutationQueue.push(c);for(let h of s)this.Mr=this.Mr.add(new st(h.key,a)),this.indexManager.addToCollectionParentIndex(e,h.key.path.popLast());return W.resolve(c)}lookupMutationBatch(e,t){return W.resolve(this.Or(t))}getNextMutationBatchAfterBatchId(e,t){let n=t+1,s=this.Nr(n),a=s<0?0:s;return W.resolve(this.mutationQueue.length>a?this.mutationQueue[a]:null)}getHighestUnacknowledgedBatchId(){return W.resolve(this.mutationQueue.length===0?Zm:this.Fr-1)}getAllMutationBatches(e){return W.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){let n=new st(t,0),s=new st(t,Number.POSITIVE_INFINITY),a=[];return this.Mr.forEachInRange([n,s],c=>{let h=this.Or(c.Cr);a.push(h)}),W.resolve(a)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new yt(Re);return t.forEach(s=>{let a=new st(s,0),c=new st(s,Number.POSITIVE_INFINITY);this.Mr.forEachInRange([a,c],h=>{n=n.add(h.Cr)})}),W.resolve(this.Br(n))}getAllMutationBatchesAffectingQuery(e,t){let n=t.path,s=n.length+1,a=n;ce.isDocumentKey(a)||(a=a.child(""));let c=new st(new ce(a),0),h=new yt(Re);return this.Mr.forEachWhile(f=>{let m=f.key.path;return!!n.isPrefixOf(m)&&(m.length===s&&(h=h.add(f.Cr)),!0)},c),W.resolve(this.Br(h))}Br(e){let t=[];return e.forEach(n=>{let s=this.Or(n);s!==null&&t.push(s)}),t}removeMutationBatch(e,t){Le(this.Lr(t.batchId,"removed")===0),this.mutationQueue.shift();let n=this.Mr;return W.forEach(t.mutations,s=>{let a=new st(s.key,t.batchId);return n=n.delete(a),this.referenceDelegate.markPotentiallyOrphaned(e,s.key)}).next(()=>{this.Mr=n})}qn(e){}containsKey(e,t){let n=new st(t,0),s=this.Mr.firstAfterOrEqual(n);return W.resolve(t.isEqual(s&&s.key))}performConsistencyCheck(e){return this.mutationQueue.length,W.resolve()}Lr(e,t){return this.Nr(e)}Nr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Or(e){let t=this.Nr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}};var hm=class{constructor(e){this.kr=e,this.docs=function(){return new Ye(ce.comparator)}(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){let n=t.key,s=this.docs.get(n),a=s?s.size:0,c=this.kr(t);return this.docs=this.docs.insert(n,{document:t.mutableCopy(),size:c}),this.size+=c-a,this.indexManager.addToCollectionParentIndex(e,n.path.popLast())}removeEntry(e){let t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){let n=this.docs.get(t);return W.resolve(n?n.document.mutableCopy():Sr.newInvalidDocument(t))}getEntries(e,t){let n=kn();return t.forEach(s=>{let a=this.docs.get(s);n=n.insert(s,a?a.document.mutableCopy():Sr.newInvalidDocument(s))}),W.resolve(n)}getDocumentsMatchingQuery(e,t,n,s){let a=kn(),c=t.path,h=new ce(c.child("__id-9223372036854775808__")),f=this.docs.getIteratorFrom(h);for(;f.hasNext();){let{key:m,value:{document:_}}=f.getNext();if(!c.isPrefixOf(m.path))break;m.path.length>c.length+1||V2(N2(_),n)<=0||(s.has(_.key)||Gh(t,_))&&(a=a.insert(_.key,_.mutableCopy()))}return W.resolve(a)}getAllFromCollectionGroup(e,t,n,s){ue()}qr(e,t){return W.forEach(this.docs,n=>t(n))}newChangeBuffer(e){return new fm(this)}getSize(e){return W.resolve(this.size)}},fm=class extends im{constructor(e){super(),this.Ir=e}applyChanges(e){let t=[];return this.changes.forEach((n,s)=>{s.isValidDocument()?t.push(this.Ir.addEntry(e,s)):this.Ir.removeEntry(n)}),W.waitFor(t)}getFromCache(e,t){return this.Ir.getEntry(e,t)}getAllFromCache(e,t){return this.Ir.getEntries(e,t)}};var dm=class{constructor(e){this.persistence=e,this.Qr=new On(t=>ig(t),sg),this.lastRemoteSnapshotVersion=me.min(),this.highestTargetId=0,this.$r=0,this.Kr=new Tu,this.targetCount=0,this.Ur=bu.Kn()}forEachTarget(e,t){return this.Qr.forEach((n,s)=>t(s)),W.resolve()}getLastRemoteSnapshotVersion(e){return W.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return W.resolve(this.$r)}allocateTargetId(e){return this.highestTargetId=this.Ur.next(),W.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.$r&&(this.$r=t),W.resolve()}zn(e){this.Qr.set(e.target,e);let t=e.targetId;t>this.highestTargetId&&(this.Ur=new bu(t),this.highestTargetId=t),e.sequenceNumber>this.$r&&(this.$r=e.sequenceNumber)}addTargetData(e,t){return this.zn(t),this.targetCount+=1,W.resolve()}updateTargetData(e,t){return this.zn(t),W.resolve()}removeTargetData(e,t){return this.Qr.delete(t.target),this.Kr.br(t.targetId),this.targetCount-=1,W.resolve()}removeTargets(e,t,n){let s=0,a=[];return this.Qr.forEach((c,h)=>{h.sequenceNumber<=t&&n.get(h.targetId)===null&&(this.Qr.delete(c),a.push(this.removeMatchingKeysForTargetId(e,h.targetId)),s++)}),W.waitFor(a).next(()=>s)}getTargetCount(e){return W.resolve(this.targetCount)}getTargetData(e,t){let n=this.Qr.get(t)||null;return W.resolve(n)}addMatchingKeys(e,t,n){return this.Kr.yr(t,n),W.resolve()}removeMatchingKeys(e,t,n){this.Kr.Sr(t,n);let s=this.persistence.referenceDelegate,a=[];return s&&t.forEach(c=>{a.push(s.markPotentiallyOrphaned(e,c))}),W.waitFor(a)}removeMatchingKeysForTargetId(e,t){return this.Kr.br(t),W.resolve()}getMatchingKeysForTargetId(e,t){let n=this.Kr.vr(t);return W.resolve(n)}containsKey(e,t){return W.resolve(this.Kr.containsKey(t))}};var vh=class{constructor(e,t){this.Wr={},this.overlays={},this.Gr=new Mo(0),this.zr=!1,this.zr=!0,this.jr=new cm,this.referenceDelegate=e(this),this.Hr=new dm(this),this.indexManager=new Zp,this.remoteDocumentCache=function(s){return new hm(s)}(n=>this.referenceDelegate.Jr(n)),this.serializer=new Xp(t),this.Yr=new am(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.zr=!1,Promise.resolve()}get started(){return this.zr}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new um,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this.Wr[e.toKey()];return n||(n=new lm(t,this.referenceDelegate),this.Wr[e.toKey()]=n),n}getGlobalsCache(){return this.jr}getTargetCache(){return this.Hr}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Yr}runTransaction(e,t,n){X("MemoryPersistence","Starting transaction:",e);let s=new pm(this.Gr.next());return this.referenceDelegate.Zr(),n(s).next(a=>this.referenceDelegate.Xr(s).next(()=>a)).toPromise().then(a=>(s.raiseOnCommittedEvent(),a))}ei(e,t){return W.or(Object.values(this.Wr).map(n=>()=>n.containsKey(e,t)))}},pm=class extends Ip{constructor(e){super(),this.currentSequenceNumber=e}},mm=class r{constructor(e){this.persistence=e,this.ti=new Tu,this.ni=null}static ri(e){return new r(e)}get ii(){if(this.ni)return this.ni;throw ue()}addReference(e,t,n){return this.ti.addReference(n,t),this.ii.delete(n.toString()),W.resolve()}removeReference(e,t,n){return this.ti.removeReference(n,t),this.ii.add(n.toString()),W.resolve()}markPotentiallyOrphaned(e,t){return this.ii.add(t.toString()),W.resolve()}removeTarget(e,t){this.ti.br(t.targetId).forEach(s=>this.ii.add(s.toString()));let n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next(s=>{s.forEach(a=>this.ii.add(a.toString()))}).next(()=>n.removeTargetData(e,t))}Zr(){this.ni=new Set}Xr(e){let t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return W.forEach(this.ii,n=>{let s=ce.fromPath(n);return this.si(e,s).next(a=>{a||t.removeEntry(s,me.min())})}).next(()=>(this.ni=null,t.apply(e)))}updateLimboDocument(e,t){return this.si(e,t).next(n=>{n?this.ii.delete(t.toString()):this.ii.add(t.toString())})}Jr(e){return 0}si(e,t){return W.or([()=>W.resolve(this.ti.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.ei(e,t)])}},wh=class r{constructor(e,t){this.persistence=e,this.oi=new On(n=>U2(n.path),(n,s)=>n.isEqual(s)),this.garbageCollector=MM(this,t)}static ri(e,t){return new r(e,t)}Zr(){}Xr(e){return W.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}nr(e){let t=this.sr(e);return this.persistence.getTargetCache().getTargetCount(e).next(n=>t.next(s=>n+s))}sr(e){let t=0;return this.rr(e,n=>{t++}).next(()=>t)}rr(e,t){return W.forEach(this.oi,(n,s)=>this.ar(e,n,s).next(a=>a?W.resolve():t(s)))}removeTargets(e,t,n){return this.persistence.getTargetCache().removeTargets(e,t,n)}removeOrphanedDocuments(e,t){let n=0,s=this.persistence.getRemoteDocumentCache(),a=s.newChangeBuffer();return s.qr(e,c=>this.ar(e,c,t).next(h=>{h||(n++,a.removeEntry(c,me.min()))})).next(()=>a.apply(e)).next(()=>n)}markPotentiallyOrphaned(e,t){return this.oi.set(t,e.currentSequenceNumber),W.resolve()}removeTarget(e,t){let n=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,n)}addReference(e,t,n){return this.oi.set(n,e.currentSequenceNumber),W.resolve()}removeReference(e,t,n){return this.oi.set(n,e.currentSequenceNumber),W.resolve()}updateLimboDocument(e,t){return this.oi.set(t,e.currentSequenceNumber),W.resolve()}Jr(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=eh(e.data.value)),t}ar(e,t,n){return W.or([()=>this.persistence.ei(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{let s=this.oi.get(t);return W.resolve(s!==void 0&&s>n)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}};var gm=class r{constructor(e,t,n,s){this.targetId=e,this.fromCache=t,this.Hi=n,this.Ji=s}static Yi(e,t){let n=xe(),s=xe();for(let a of t.docChanges)switch(a.type){case 0:n=n.add(a.doc.key);break;case 1:s=s.add(a.doc.key)}return new r(e,t.fromCache,n,s)}};var _m=class{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}};var ym=class{constructor(){this.Zi=!1,this.Xi=!1,this.es=100,this.ts=function(){return I0()?8:M2(E0())>0?6:4}()}initialize(e,t){this.ns=e,this.indexManager=t,this.Zi=!0}getDocumentsMatchingQuery(e,t,n,s){let a={result:null};return this.rs(e,t).next(c=>{a.result=c}).next(()=>{if(!a.result)return this.ss(e,t,s,n).next(c=>{a.result=c})}).next(()=>{if(a.result)return;let c=new _m;return this._s(e,t,c).next(h=>{if(a.result=h,this.Xi)return this.us(e,t,c,h.size)})}).next(()=>a.result)}us(e,t,n,s){return n.documentReadCount<this.es?(Ro()<=Se.DEBUG&&X("QueryEngine","SDK will not create cache indexes for query:",Po(t),"since it only creates cache indexes for collection contains","more than or equal to",this.es,"documents"),W.resolve()):(Ro()<=Se.DEBUG&&X("QueryEngine","Query:",Po(t),"scans",n.documentReadCount,"local documents and returns",s,"documents as results."),n.documentReadCount>this.ts*s?(Ro()<=Se.DEBUG&&X("QueryEngine","The SDK decides to create cache indexes for query:",Po(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,Wr(t))):W.resolve())}rs(e,t){if(ob(t))return W.resolve(null);let n=Wr(t);return this.indexManager.getIndexType(e,n).next(s=>s===0?null:(t.limit!==null&&s===1&&(t=Fp(t,null,"F"),n=Wr(t)),this.indexManager.getDocumentsMatchingTarget(e,n).next(a=>{let c=xe(...a);return this.ns.getDocuments(e,c).next(h=>this.indexManager.getMinOffset(e,n).next(f=>{let m=this.cs(t,h);return this.ls(t,m,c,f.readTime)?this.rs(e,Fp(t,null,"F")):this.hs(e,m,t,f)}))})))}ss(e,t,n,s){return ob(t)||s.isEqual(me.min())?W.resolve(null):this.ns.getDocuments(e,n).next(a=>{let c=this.cs(t,a);return this.ls(t,c,n,s)?W.resolve(null):(Ro()<=Se.DEBUG&&X("QueryEngine","Re-using previous result from %s to execute query: %s",s.toString(),Po(t)),this.hs(e,c,t,k2(s,mu)).next(h=>h))})}cs(e,t){let n=new yt(uT(e));return t.forEach((s,a)=>{Gh(e,a)&&(n=n.add(a))}),n}ls(e,t,n,s){if(e.limit===null)return!1;if(n.size!==t.size)return!0;let a=e.limitType==="F"?t.last():t.first();return!!a&&(a.hasPendingWrites||a.version.compareTo(s)>0)}_s(e,t,n){return Ro()<=Se.DEBUG&&X("QueryEngine","Using full collection scan to execute query:",Po(t)),this.ns.getDocumentsMatchingQuery(e,t,ls.min(),n)}hs(e,t,n,s){return this.ns.getDocumentsMatchingQuery(e,n,s).next(a=>(t.forEach(c=>{a=a.insert(c.key,c)}),a))}};var ug="LocalStore",FM=3e8,vm=class{constructor(e,t,n,s){this.persistence=e,this.Ps=t,this.serializer=s,this.Ts=new Ye(Re),this.Is=new On(a=>ig(a),sg),this.Es=new Map,this.ds=e.getRemoteDocumentCache(),this.Hr=e.getTargetCache(),this.Yr=e.getBundleCache(),this.As(n)}As(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new om(this.ds,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.ds.setIndexManager(this.indexManager),this.Ps.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.Ts))}};function UM(r,e,t,n){return new vm(r,e,t,n)}async function RT(r,e){let t=fe(r);return await t.persistence.runTransaction("Handle user change","readonly",n=>{let s;return t.mutationQueue.getAllMutationBatches(n).next(a=>(s=a,t.As(e),t.mutationQueue.getAllMutationBatches(n))).next(a=>{let c=[],h=[],f=xe();for(let m of s){c.push(m.batchId);for(let _ of m.mutations)f=f.add(_.key)}for(let m of a){h.push(m.batchId);for(let _ of m.mutations)f=f.add(_.key)}return t.localDocuments.getDocuments(n,f).next(m=>({Rs:m,removedBatchIds:c,addedBatchIds:h}))})})}function BM(r,e){let t=fe(r);return t.persistence.runTransaction("Acknowledge batch","readwrite-primary",n=>{let s=e.batch.keys(),a=t.ds.newChangeBuffer({trackRemovals:!0});return function(h,f,m,_){let E=m.batch,I=E.keys(),k=W.resolve();return I.forEach(B=>{k=k.next(()=>_.getEntry(f,B)).next(G=>{let j=m.docVersions.get(B);Le(j!==null),G.version.compareTo(j)<0&&(E.applyToRemoteDocument(G,m),G.isValidDocument()&&(G.setReadTime(m.commitVersion),_.addEntry(G)))})}),k.next(()=>h.mutationQueue.removeMutationBatch(f,E))}(t,n,e,a).next(()=>a.apply(n)).next(()=>t.mutationQueue.performConsistencyCheck(n)).next(()=>t.documentOverlayCache.removeOverlaysForBatchId(n,s,e.batch.batchId)).next(()=>t.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(n,function(h){let f=xe();for(let m=0;m<h.mutationResults.length;++m)h.mutationResults[m].transformResults.length>0&&(f=f.add(h.batch.mutations[m].key));return f}(e))).next(()=>t.localDocuments.getDocuments(n,s))})}function PT(r){let e=fe(r);return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.Hr.getLastRemoteSnapshotVersion(t))}function jM(r,e){let t=fe(r),n=e.snapshotVersion,s=t.Ts;return t.persistence.runTransaction("Apply remote event","readwrite-primary",a=>{let c=t.ds.newChangeBuffer({trackRemovals:!0});s=t.Ts;let h=[];e.targetChanges.forEach((_,E)=>{let I=s.get(E);if(!I)return;h.push(t.Hr.removeMatchingKeys(a,_.removedDocuments,E).next(()=>t.Hr.addMatchingKeys(a,_.addedDocuments,E)));let k=I.withSequenceNumber(a.currentSequenceNumber);e.targetMismatches.get(E)!==null?k=k.withResumeToken(Rt.EMPTY_BYTE_STRING,me.min()).withLastLimboFreeSnapshotVersion(me.min()):_.resumeToken.approximateByteSize()>0&&(k=k.withResumeToken(_.resumeToken,n)),s=s.insert(E,k),function(G,j,J){return G.resumeToken.approximateByteSize()===0||j.snapshotVersion.toMicroseconds()-G.snapshotVersion.toMicroseconds()>=FM?!0:J.addedDocuments.size+J.modifiedDocuments.size+J.removedDocuments.size>0}(I,k,_)&&h.push(t.Hr.updateTargetData(a,k))});let f=kn(),m=xe();if(e.documentUpdates.forEach(_=>{e.resolvedLimboDocuments.has(_)&&h.push(t.persistence.referenceDelegate.updateLimboDocument(a,_))}),h.push($M(a,c,e.documentUpdates).next(_=>{f=_.Vs,m=_.fs})),!n.isEqual(me.min())){let _=t.Hr.getLastRemoteSnapshotVersion(a).next(E=>t.Hr.setTargetsMetadata(a,a.currentSequenceNumber,n));h.push(_)}return W.waitFor(h).next(()=>c.apply(a)).next(()=>t.localDocuments.getLocalViewOfDocuments(a,f,m)).next(()=>f)}).then(a=>(t.Ts=s,a))}function $M(r,e,t){let n=xe(),s=xe();return t.forEach(a=>n=n.add(a)),e.getEntries(r,n).next(a=>{let c=kn();return t.forEach((h,f)=>{let m=a.get(h);f.isFoundDocument()!==m.isFoundDocument()&&(s=s.add(h)),f.isNoDocument()&&f.version.isEqual(me.min())?(e.removeEntry(h,f.readTime),c=c.insert(h,f)):!m.isValidDocument()||f.version.compareTo(m.version)>0||f.version.compareTo(m.version)===0&&m.hasPendingWrites?(e.addEntry(f),c=c.insert(h,f)):X(ug,"Ignoring outdated watch update for ",h,". Current version:",m.version," Watch version:",f.version)}),{Vs:c,fs:s}})}function qM(r,e){let t=fe(r);return t.persistence.runTransaction("Get next mutation batch","readonly",n=>(e===void 0&&(e=Zm),t.mutationQueue.getNextMutationBatchAfterBatchId(n,e)))}function zM(r,e){let t=fe(r);return t.persistence.runTransaction("Allocate target","readwrite",n=>{let s;return t.Hr.getTargetData(n,e).next(a=>a?(s=a,W.resolve(s)):t.Hr.allocateTargetId(n).next(c=>(s=new wu(e,c,"TargetPurposeListen",n.currentSequenceNumber),t.Hr.addTargetData(n,s).next(()=>s))))}).then(n=>{let s=t.Ts.get(n.targetId);return(s===null||n.snapshotVersion.compareTo(s.snapshotVersion)>0)&&(t.Ts=t.Ts.insert(n.targetId,n),t.Is.set(e,n.targetId)),n})}async function wm(r,e,t){let n=fe(r),s=n.Ts.get(e),a=t?"readwrite":"readwrite-primary";try{t||await n.persistence.runTransaction("Release target",a,c=>n.persistence.referenceDelegate.removeTarget(c,s))}catch(c){if(!Zo(c))throw c;X(ug,`Failed to update sequence numbers for target ${e}: ${c}`)}n.Ts=n.Ts.remove(e),n.Is.delete(s.target)}function vb(r,e,t){let n=fe(r),s=me.min(),a=xe();return n.persistence.runTransaction("Execute query","readwrite",c=>function(f,m,_){let E=fe(f),I=E.Is.get(_);return I!==void 0?W.resolve(E.Ts.get(I)):E.Hr.getTargetData(m,_)}(n,c,Wr(e)).next(h=>{if(h)return s=h.lastLimboFreeSnapshotVersion,n.Hr.getMatchingKeysForTargetId(c,h.targetId).next(f=>{a=f})}).next(()=>n.Ps.getDocumentsMatchingQuery(c,e,t?s:me.min(),t?a:xe())).next(h=>(GM(n,nM(e),h),{documents:h,gs:a})))}function GM(r,e,t){let n=r.Es.get(e)||me.min();t.forEach((s,a)=>{a.readTime.compareTo(n)>0&&(n=a.readTime)}),r.Es.set(e,n)}var bh=class{constructor(){this.activeTargetIds=cM()}Ds(e){this.activeTargetIds=this.activeTargetIds.add(e)}vs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}bs(){let e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}};var bm=class{constructor(){this.ho=new bh,this.Po={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e,t=!0){return t&&this.ho.Ds(e),this.Po[e]||"not-current"}updateQueryState(e,t,n){this.Po[e]=t}removeLocalQueryTarget(e){this.ho.vs(e)}isLocalQueryTarget(e){return this.ho.activeTargetIds.has(e)}clearQueryState(e){delete this.Po[e]}getAllActiveQueryTargets(){return this.ho.activeTargetIds}isActiveQueryTarget(e){return this.ho.activeTargetIds.has(e)}start(){return this.ho=new bh,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}};var Tm=class{To(e){}shutdown(){}};var wb="ConnectivityMonitor",Th=class{constructor(){this.Io=()=>this.Eo(),this.Ao=()=>this.Ro(),this.Vo=[],this.mo()}To(e){this.Vo.push(e)}shutdown(){window.removeEventListener("online",this.Io),window.removeEventListener("offline",this.Ao)}mo(){window.addEventListener("online",this.Io),window.addEventListener("offline",this.Ao)}Eo(){X(wb,"Network connectivity changed: AVAILABLE");for(let e of this.Vo)e(0)}Ro(){X(wb,"Network connectivity changed: UNAVAILABLE");for(let e of this.Vo)e(1)}static D(){return typeof window!="undefined"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}};var Zl=null;function Em(){return Zl===null?Zl=function(){return 268435456+Math.round(2147483648*Math.random())}():Zl++,"0x"+Zl.toString(16)}var pp="RestConnection",KM={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"},Im=class{get fo(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;let t=e.ssl?"https":"http",n=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.po=t+"://"+e.host,this.yo=`projects/${n}/databases/${s}`,this.wo=this.databaseId.database===ch?`project_id=${n}`:`project_id=${n}&database_id=${s}`}So(e,t,n,s,a){let c=Em(),h=this.bo(e,t.toUriEncodedString());X(pp,`Sending RPC '${e}' ${c}:`,h,n);let f={"google-cloud-resource-prefix":this.yo,"x-goog-request-params":this.wo};return this.Do(f,s,a),this.vo(e,h,f,n).then(m=>(X(pp,`Received RPC '${e}' ${c}: `,m),m),m=>{throw Vo(pp,`RPC '${e}' ${c} failed with error: `,m,"url: ",h,"request:",n),m})}Co(e,t,n,s,a,c){return this.So(e,t,n,s,a)}Do(e,t,n){e["X-Goog-Api-Client"]=function(){return"gl-js/ fire/"+Yo}(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach((s,a)=>e[a]=s),n&&n.headers.forEach((s,a)=>e[a]=s)}bo(e,t){let n=KM[e];return`${this.po}/v1/${t}:${n}`}terminate(){}};var xm=class{constructor(e){this.Fo=e.Fo,this.Mo=e.Mo}xo(e){this.Oo=e}No(e){this.Bo=e}Lo(e){this.ko=e}onMessage(e){this.qo=e}close(){this.Mo()}send(e){this.Fo(e)}Qo(){this.Oo()}$o(){this.Bo()}Ko(e){this.ko(e)}Uo(e){this.qo(e)}};var St="WebChannelConnection",Am=class extends Im{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}vo(e,t,n,s){let a=Em();return new Promise((c,h)=>{let f=new up;f.setWithCredentials(!0),f.listenOnce(cp.COMPLETE,()=>{try{switch(f.getLastErrorCode()){case cu.NO_ERROR:let _=f.getResponseJson();X(St,`XHR for RPC '${e}' ${a} received:`,JSON.stringify(_)),c(_);break;case cu.TIMEOUT:X(St,`RPC '${e}' ${a} timed out`),h(new ne(H.DEADLINE_EXCEEDED,"Request time out"));break;case cu.HTTP_ERROR:let E=f.getStatus();if(X(St,`RPC '${e}' ${a} failed with status:`,E,"response text:",f.getResponseText()),E>0){let I=f.getResponseJson();Array.isArray(I)&&(I=I[0]);let k=I==null?void 0:I.error;if(k&&k.status&&k.message){let B=function(j){let J=j.toLowerCase().replace(/_/g,"-");return Object.values(H).indexOf(J)>=0?J:H.UNKNOWN}(k.status);h(new ne(B,k.message))}else h(new ne(H.UNKNOWN,"Server responded with status "+f.getStatus()))}else h(new ne(H.UNAVAILABLE,"Connection failed."));break;default:ue()}}finally{X(St,`RPC '${e}' ${a} completed.`)}});let m=JSON.stringify(s);X(St,`RPC '${e}' ${a} sending request:`,s),f.send(t,"POST",m,n,15)})}Wo(e,t,n){let s=Em(),a=[this.po,"/","google.firestore.v1.Firestore","/",e,"/channel"],c=fp(),h=hp(),f={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},m=this.longPollingOptions.timeoutSeconds;m!==void 0&&(f.longPollingTimeout=Math.round(1e3*m)),this.useFetchStreams&&(f.useFetchStreams=!0),this.Do(f.initMessageHeaders,t,n),f.encodeInitMessageHeaders=!0;let _=a.join("");X(St,`Creating RPC '${e}' stream ${s}: ${_}`,f);let E=c.createWebChannel(_,f),I=!1,k=!1,B=new xm({Fo:j=>{k?X(St,`Not sending because RPC '${e}' stream ${s} is closed:`,j):(I||(X(St,`Opening RPC '${e}' stream ${s} transport.`),E.open(),I=!0),X(St,`RPC '${e}' stream ${s} sending:`,j),E.send(j))},Mo:()=>E.close()}),G=(j,J,ee)=>{j.listen(J,re=>{try{ee(re)}catch(le){setTimeout(()=>{throw le},0)}})};return G(E,So.EventType.OPEN,()=>{k||(X(St,`RPC '${e}' stream ${s} transport opened.`),B.Qo())}),G(E,So.EventType.CLOSE,()=>{k||(k=!0,X(St,`RPC '${e}' stream ${s} transport closed`),B.Ko())}),G(E,So.EventType.ERROR,j=>{k||(k=!0,Vo(St,`RPC '${e}' stream ${s} transport errored:`,j),B.Ko(new ne(H.UNAVAILABLE,"The operation could not be completed")))}),G(E,So.EventType.MESSAGE,j=>{var J;if(!k){let ee=j.data[0];Le(!!ee);let re=ee,le=(re==null?void 0:re.error)||((J=re[0])===null||J===void 0?void 0:J.error);if(le){X(St,`RPC '${e}' stream ${s} received error:`,le);let de=le.status,ie=function(R){let D=it[R];if(D!==void 0)return vT(D)}(de),C=le.message;ie===void 0&&(ie=H.INTERNAL,C="Unknown error status: "+de+" with message "+le.message),k=!0,B.Ko(new ne(ie,C)),E.close()}else X(St,`RPC '${e}' stream ${s} received:`,ee),B.Uo(ee)}}),G(h,lp.STAT_EVENT,j=>{j.stat===Jl.PROXY?X(St,`RPC '${e}' stream ${s} detected buffering proxy`):j.stat===Jl.NOPROXY&&X(St,`RPC '${e}' stream ${s} detected no buffering proxy`)}),setTimeout(()=>{B.$o()},0),B}};function mp(){return typeof document!="undefined"?document:null}function Kh(r){return new Wp(r,!0)}var Eh=class{constructor(e,t,n=1e3,s=1.5,a=6e4){this.Ti=e,this.timerId=t,this.Go=n,this.zo=s,this.jo=a,this.Ho=0,this.Jo=null,this.Yo=Date.now(),this.reset()}reset(){this.Ho=0}Zo(){this.Ho=this.jo}Xo(e){this.cancel();let t=Math.floor(this.Ho+this.e_()),n=Math.max(0,Date.now()-this.Yo),s=Math.max(0,t-n);s>0&&X("ExponentialBackoff",`Backing off for ${s} ms (base delay: ${this.Ho} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),this.Jo=this.Ti.enqueueAfterDelay(this.timerId,s,()=>(this.Yo=Date.now(),e())),this.Ho*=this.zo,this.Ho<this.Go&&(this.Ho=this.Go),this.Ho>this.jo&&(this.Ho=this.jo)}t_(){this.Jo!==null&&(this.Jo.skipDelay(),this.Jo=null)}cancel(){this.Jo!==null&&(this.Jo.cancel(),this.Jo=null)}e_(){return(Math.random()-.5)*this.Ho}};var bb="PersistentStream",Ih=class{constructor(e,t,n,s,a,c,h,f){this.Ti=e,this.n_=n,this.r_=s,this.connection=a,this.authCredentialsProvider=c,this.appCheckCredentialsProvider=h,this.listener=f,this.state=0,this.i_=0,this.s_=null,this.o_=null,this.stream=null,this.__=0,this.a_=new Eh(e,t)}u_(){return this.state===1||this.state===5||this.c_()}c_(){return this.state===2||this.state===3}start(){this.__=0,this.state!==4?this.auth():this.l_()}async stop(){this.u_()&&await this.close(0)}h_(){this.state=0,this.a_.reset()}P_(){this.c_()&&this.s_===null&&(this.s_=this.Ti.enqueueAfterDelay(this.n_,6e4,()=>this.T_()))}I_(e){this.E_(),this.stream.send(e)}async T_(){if(this.c_())return this.close(0)}E_(){this.s_&&(this.s_.cancel(),this.s_=null)}d_(){this.o_&&(this.o_.cancel(),this.o_=null)}async close(e,t){this.E_(),this.d_(),this.a_.cancel(),this.i_++,e!==4?this.a_.reset():t&&t.code===H.RESOURCE_EXHAUSTED?(Pn(t.toString()),Pn("Using maximum backoff delay to prevent overloading the backend."),this.a_.Zo()):t&&t.code===H.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.A_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.Lo(t)}A_(){}auth(){this.state=1;let e=this.R_(this.i_),t=this.i_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([n,s])=>{this.i_===t&&this.V_(n,s)},n=>{e(()=>{let s=new ne(H.UNKNOWN,"Fetching auth token failed: "+n.message);return this.m_(s)})})}V_(e,t){let n=this.R_(this.i_);this.stream=this.f_(e,t),this.stream.xo(()=>{n(()=>this.listener.xo())}),this.stream.No(()=>{n(()=>(this.state=2,this.o_=this.Ti.enqueueAfterDelay(this.r_,1e4,()=>(this.c_()&&(this.state=3),Promise.resolve())),this.listener.No()))}),this.stream.Lo(s=>{n(()=>this.m_(s))}),this.stream.onMessage(s=>{n(()=>++this.__==1?this.g_(s):this.onNext(s))})}l_(){this.state=5,this.a_.Xo(async()=>{this.state=0,this.start()})}m_(e){return X(bb,`close with error: ${e}`),this.stream=null,this.close(4,e)}R_(e){return t=>{this.Ti.enqueueAndForget(()=>this.i_===e?t():(X(bb,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}},Sm=class extends Ih{constructor(e,t,n,s,a,c){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,n,s,c),this.serializer=a}f_(e,t){return this.connection.Wo("Listen",e,t)}g_(e){return this.onNext(e)}onNext(e){this.a_.reset();let t=IM(this.serializer,e),n=function(a){if(!("targetChange"in a))return me.min();let c=a.targetChange;return c.targetIds&&c.targetIds.length?me.min():c.readTime?Hr(c.readTime):me.min()}(e);return this.listener.p_(t,n)}y_(e){let t={};t.database=Yp(this.serializer),t.addTarget=function(a,c){let h,f=c.target;if(h=Mp(f)?{documents:SM(a,f)}:{query:RM(a,f).ht},h.targetId=c.targetId,c.resumeToken.approximateByteSize()>0){h.resumeToken=wT(a,c.resumeToken);let m=Hp(a,c.expectedCount);m!==null&&(h.expectedCount=m)}else if(c.snapshotVersion.compareTo(me.min())>0){h.readTime=_h(a,c.snapshotVersion.toTimestamp());let m=Hp(a,c.expectedCount);m!==null&&(h.expectedCount=m)}return h}(this.serializer,e);let n=CM(this.serializer,e);n&&(t.labels=n),this.I_(t)}w_(e){let t={};t.database=Yp(this.serializer),t.removeTarget=e,this.I_(t)}},Rm=class extends Ih{constructor(e,t,n,s,a,c){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,n,s,c),this.serializer=a}get S_(){return this.__>0}start(){this.lastStreamToken=void 0,super.start()}A_(){this.S_&&this.b_([])}f_(e,t){return this.connection.Wo("Write",e,t)}g_(e){return Le(!!e.streamToken),this.lastStreamToken=e.streamToken,Le(!e.writeResults||e.writeResults.length===0),this.listener.D_()}onNext(e){Le(!!e.streamToken),this.lastStreamToken=e.streamToken,this.a_.reset();let t=AM(e.writeResults,e.commitTime),n=Hr(e.commitTime);return this.listener.v_(n,t)}C_(){let e={};e.database=Yp(this.serializer),this.I_(e)}b_(e){let t={streamToken:this.lastStreamToken,writes:e.map(n=>xM(this.serializer,n))};this.I_(t)}};var Pm=class{},Cm=class extends Pm{constructor(e,t,n,s){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=n,this.serializer=s,this.F_=!1}M_(){if(this.F_)throw new ne(H.FAILED_PRECONDITION,"The client has already been terminated.")}So(e,t,n,s){return this.M_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([a,c])=>this.connection.So(e,Qp(t,n),s,a,c)).catch(a=>{throw a.name==="FirebaseError"?(a.code===H.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),a):new ne(H.UNKNOWN,a.toString())})}Co(e,t,n,s,a){return this.M_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([c,h])=>this.connection.Co(e,Qp(t,n),s,c,h,a)).catch(c=>{throw c.name==="FirebaseError"?(c.code===H.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),c):new ne(H.UNKNOWN,c.toString())})}terminate(){this.F_=!0,this.connection.terminate()}},Dm=class{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.x_=0,this.O_=null,this.N_=!0}B_(){this.x_===0&&(this.L_("Unknown"),this.O_=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.O_=null,this.k_("Backend didn't respond within 10 seconds."),this.L_("Offline"),Promise.resolve())))}q_(e){this.state==="Online"?this.L_("Unknown"):(this.x_++,this.x_>=1&&(this.Q_(),this.k_(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.L_("Offline")))}set(e){this.Q_(),this.x_=0,e==="Online"&&(this.N_=!1),this.L_(e)}L_(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}k_(e){let t=`Could not reach Cloud Firestore backend. ${e}
37
+ This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.N_?(Pn(t),this.N_=!1):X("OnlineStateTracker",t)}Q_(){this.O_!==null&&(this.O_.cancel(),this.O_=null)}};var ps="RemoteStore",Om=class{constructor(e,t,n,s,a){this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.K_=[],this.U_=new Map,this.W_=new Set,this.G_=[],this.z_=a,this.z_.To(c=>{n.enqueueAndForget(async()=>{ms(this)&&(X(ps,"Restarting streams for network reachability change."),await async function(f){let m=fe(f);m.W_.add(4),await Cu(m),m.j_.set("Unknown"),m.W_.delete(4),await Wh(m)}(this))})}),this.j_=new Dm(n,s)}};async function Wh(r){if(ms(r))for(let e of r.G_)await e(!0)}async function Cu(r){for(let e of r.G_)await e(!1)}function CT(r,e){let t=fe(r);t.U_.has(e.targetId)||(t.U_.set(e.targetId,e),fg(t)?hg(t):ea(t).c_()&&lg(t,e))}function cg(r,e){let t=fe(r),n=ea(t);t.U_.delete(e),n.c_()&&DT(t,e),t.U_.size===0&&(n.c_()?n.P_():ms(t)&&t.j_.set("Unknown"))}function lg(r,e){if(r.H_.Ne(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo(me.min())>0){let t=r.remoteSyncer.getRemoteKeysForTarget(e.targetId).size;e=e.withExpectedCount(t)}ea(r).y_(e)}function DT(r,e){r.H_.Ne(e),ea(r).w_(e)}function hg(r){r.H_=new Kp({getRemoteKeysForTarget:e=>r.remoteSyncer.getRemoteKeysForTarget(e),lt:e=>r.U_.get(e)||null,it:()=>r.datastore.serializer.databaseId}),ea(r).start(),r.j_.B_()}function fg(r){return ms(r)&&!ea(r).u_()&&r.U_.size>0}function ms(r){return fe(r).W_.size===0}function OT(r){r.H_=void 0}async function WM(r){r.j_.set("Online")}async function HM(r){r.U_.forEach((e,t)=>{lg(r,e)})}async function QM(r,e){OT(r),fg(r)?(r.j_.q_(e),hg(r)):r.j_.set("Unknown")}async function JM(r,e,t){if(r.j_.set("Online"),e instanceof mh&&e.state===2&&e.cause)try{await async function(s,a){let c=a.cause;for(let h of a.targetIds)s.U_.has(h)&&(await s.remoteSyncer.rejectListen(h,c),s.U_.delete(h),s.H_.removeTarget(h))}(r,e)}catch(n){X(ps,"Failed to remove targets %s: %s ",e.targetIds.join(","),n),await xh(r,n)}else if(e instanceof ko?r.H_.We(e):e instanceof ph?r.H_.Ze(e):r.H_.je(e),!t.isEqual(me.min()))try{let n=await PT(r.localStore);t.compareTo(n)>=0&&await function(a,c){let h=a.H_.ot(c);return h.targetChanges.forEach((f,m)=>{if(f.resumeToken.approximateByteSize()>0){let _=a.U_.get(m);_&&a.U_.set(m,_.withResumeToken(f.resumeToken,c))}}),h.targetMismatches.forEach((f,m)=>{let _=a.U_.get(f);if(!_)return;a.U_.set(f,_.withResumeToken(Rt.EMPTY_BYTE_STRING,_.snapshotVersion)),DT(a,f);let E=new wu(_.target,f,m,_.sequenceNumber);lg(a,E)}),a.remoteSyncer.applyRemoteEvent(h)}(r,t)}catch(n){X(ps,"Failed to raise snapshot:",n),await xh(r,n)}}async function xh(r,e,t){if(!Zo(e))throw e;r.W_.add(1),await Cu(r),r.j_.set("Offline"),t||(t=()=>PT(r.localStore)),r.asyncQueue.enqueueRetryable(async()=>{X(ps,"Retrying IndexedDB access"),await t(),r.W_.delete(1),await Wh(r)})}function kT(r,e){return e().catch(t=>xh(r,t,e))}async function Hh(r){let e=fe(r),t=vi(e),n=e.K_.length>0?e.K_[e.K_.length-1].batchId:Zm;for(;YM(e);)try{let s=await qM(e.localStore,n);if(s===null){e.K_.length===0&&t.P_();break}n=s.batchId,XM(e,s)}catch(s){await xh(e,s)}NT(e)&&VT(e)}function YM(r){return ms(r)&&r.K_.length<10}function XM(r,e){r.K_.push(e);let t=vi(r);t.c_()&&t.S_&&t.b_(e.mutations)}function NT(r){return ms(r)&&!vi(r).u_()&&r.K_.length>0}function VT(r){vi(r).start()}async function ZM(r){vi(r).C_()}async function eF(r){let e=vi(r);for(let t of r.K_)e.b_(t.mutations)}async function tF(r,e,t){let n=r.K_.shift(),s=$p.from(n,e,t);await kT(r,()=>r.remoteSyncer.applySuccessfulWrite(s)),await Hh(r)}async function rF(r,e){e&&vi(r).S_&&await async function(n,s){if(function(c){return gM(c)&&c!==H.ABORTED}(s.code)){let a=n.K_.shift();vi(n).h_(),await kT(n,()=>n.remoteSyncer.rejectFailedWrite(a.batchId,s)),await Hh(n)}}(r,e),NT(r)&&VT(r)}async function Tb(r,e){let t=fe(r);t.asyncQueue.verifyOperationInProgress(),X(ps,"RemoteStore received new credentials");let n=ms(t);t.W_.add(3),await Cu(t),n&&t.j_.set("Unknown"),await t.remoteSyncer.handleCredentialChange(e),t.W_.delete(3),await Wh(t)}async function nF(r,e){let t=fe(r);e?(t.W_.delete(2),await Wh(t)):e||(t.W_.add(2),await Cu(t),t.j_.set("Unknown"))}function ea(r){return r.J_||(r.J_=function(t,n,s){let a=fe(t);return a.M_(),new Sm(n,a.connection,a.authCredentials,a.appCheckCredentials,a.serializer,s)}(r.datastore,r.asyncQueue,{xo:WM.bind(null,r),No:HM.bind(null,r),Lo:QM.bind(null,r),p_:JM.bind(null,r)}),r.G_.push(async e=>{e?(r.J_.h_(),fg(r)?hg(r):r.j_.set("Unknown")):(await r.J_.stop(),OT(r))})),r.J_}function vi(r){return r.Y_||(r.Y_=function(t,n,s){let a=fe(t);return a.M_(),new Rm(n,a.connection,a.authCredentials,a.appCheckCredentials,a.serializer,s)}(r.datastore,r.asyncQueue,{xo:()=>Promise.resolve(),No:ZM.bind(null,r),Lo:rF.bind(null,r),D_:eF.bind(null,r),v_:tF.bind(null,r)}),r.G_.push(async e=>{e?(r.Y_.h_(),await Hh(r)):(await r.Y_.stop(),r.K_.length>0&&(X(ps,`Stopping write stream with ${r.K_.length} pending writes`),r.K_=[]))})),r.Y_}var km=class r{constructor(e,t,n,s,a){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=n,this.op=s,this.removalCallback=a,this.deferred=new Gr,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(c=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,t,n,s,a){let c=Date.now()+n,h=new r(e,t,c,s,a);return h.start(n),h}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new ne(H.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then(e=>this.deferred.resolve(e))):Promise.resolve())}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}};function dg(r,e){if(Pn("AsyncQueue",`${e}: ${r}`),Zo(r))return new ne(H.UNAVAILABLE,`${e}: ${r}`);throw r}var Ah=class r{static emptySet(e){return new r(e.comparator)}constructor(e){this.comparator=e?(t,n)=>e(t,n)||ce.comparator(t.key,n.key):(t,n)=>ce.comparator(t.key,n.key),this.keyedMap=lu(),this.sortedSet=new Ye(this.comparator)}has(e){return this.keyedMap.get(e)!=null}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){let t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal((t,n)=>(e(t),!1))}add(e){let t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){let t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof r)||this.size!==e.size)return!1;let t=this.sortedSet.getIterator(),n=e.sortedSet.getIterator();for(;t.hasNext();){let s=t.getNext().key,a=n.getNext().key;if(!s.isEqual(a))return!1}return!0}toString(){let e=[];return this.forEach(t=>{e.push(t.toString())}),e.length===0?"DocumentSet ()":`DocumentSet (
38
38
  `+e.join(`
39
39
  `)+`
40
- )`}copy(e,t){let r=new n;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=t,r}};var Ah=class{constructor(){this.Z_=new Je(ce.comparator)}track(e){let t=e.doc.key,r=this.Z_.get(t);r?e.type!==0&&r.type===3?this.Z_=this.Z_.insert(t,e):e.type===3&&r.type!==1?this.Z_=this.Z_.insert(t,{type:r.type,doc:e.doc}):e.type===2&&r.type===2?this.Z_=this.Z_.insert(t,{type:2,doc:e.doc}):e.type===2&&r.type===0?this.Z_=this.Z_.insert(t,{type:0,doc:e.doc}):e.type===1&&r.type===0?this.Z_=this.Z_.remove(t):e.type===1&&r.type===2?this.Z_=this.Z_.insert(t,{type:1,doc:r.doc}):e.type===0&&r.type===1?this.Z_=this.Z_.insert(t,{type:2,doc:e.doc}):ue():this.Z_=this.Z_.insert(t,e)}X_(){let e=[];return this.Z_.inorderTraversal((t,r)=>{e.push(r)}),e}},Wo=class n{constructor(e,t,r,s,a,c,h,f,m){this.query=e,this.docs=t,this.oldDocs=r,this.docChanges=s,this.mutatedKeys=a,this.fromCache=c,this.syncStateChanged=h,this.excludesMetadataChanges=f,this.hasCachedResults=m}static fromInitialDocuments(e,t,r,s,a){let c=[];return t.forEach(h=>{c.push({type:0,doc:h})}),new n(e,t,xh.emptySet(t),c,r,s,!0,!1,a)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&qh(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;let t=this.docChanges,r=e.docChanges;if(t.length!==r.length)return!1;for(let s=0;s<t.length;s++)if(t[s].type!==r[s].type||!t[s].doc.isEqual(r[s].doc))return!1;return!0}};var Om=class{constructor(){this.ea=void 0,this.ta=[]}na(){return this.ta.some(e=>e.ra())}},km=class{constructor(){this.queries=bb(),this.onlineState="Unknown",this.ia=new Set}terminate(){(function(t,r){let s=fe(t),a=s.queries;s.queries=bb(),a.forEach((c,h)=>{for(let f of h.ta)f.onError(r)})})(this,new re(H.ABORTED,"Firestore shutting down"))}};function bb(){return new Or(n=>sT(n),qh)}async function NT(n,e){let t=fe(n),r=3,s=e.query,a=t.queries.get(s);a?!a.na()&&e.ra()&&(r=2):(a=new Om,r=e.ra()?0:1);try{switch(r){case 0:a.ea=await t.onListen(s,!0);break;case 1:a.ea=await t.onListen(s,!1);break;case 2:await t.onFirstRemoteStoreListen(s)}}catch(c){let h=hg(c,`Initialization of query '${Ro(e.query)}' failed`);return void e.onError(h)}t.queries.set(s,a),a.ta.push(e),e.sa(t.onlineState),a.ea&&e.oa(a.ea)&&fg(t)}async function VT(n,e){let t=fe(n),r=e.query,s=3,a=t.queries.get(r);if(a){let c=a.ta.indexOf(e);c>=0&&(a.ta.splice(c,1),a.ta.length===0?s=e.ra()?0:1:!a.na()&&e.ra()&&(s=2))}switch(s){case 0:return t.queries.delete(r),t.onUnlisten(r,!0);case 1:return t.queries.delete(r),t.onUnlisten(r,!1);case 2:return t.onLastRemoteStoreUnlisten(r);default:return}}function eF(n,e){let t=fe(n),r=!1;for(let s of e){let a=s.query,c=t.queries.get(a);if(c){for(let h of c.ta)h.oa(s)&&(r=!0);c.ea=s}}r&&fg(t)}function tF(n,e,t){let r=fe(n),s=r.queries.get(e);if(s)for(let a of s.ta)a.onError(t);r.queries.delete(e)}function fg(n){n.ia.forEach(e=>{e.next()})}var Nm,Tb;(Tb=Nm||(Nm={}))._a="default",Tb.Cache="cache";var Sh=class{constructor(e,t,r){this.query=e,this.aa=t,this.ua=!1,this.ca=null,this.onlineState="Unknown",this.options=r||{}}oa(e){if(!this.options.includeMetadataChanges){let r=[];for(let s of e.docChanges)s.type!==3&&r.push(s);e=new Wo(e.query,e.docs,e.oldDocs,r,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.ua?this.la(e)&&(this.aa.next(e),t=!0):this.ha(e,this.onlineState)&&(this.Pa(e),t=!0),this.ca=e,t}onError(e){this.aa.error(e)}sa(e){this.onlineState=e;let t=!1;return this.ca&&!this.ua&&this.ha(this.ca,e)&&(this.Pa(this.ca),t=!0),t}ha(e,t){if(!e.fromCache||!this.ra())return!0;let r=t!=="Offline";return(!this.options.Ta||!r)&&(!e.docs.isEmpty()||e.hasCachedResults||t==="Offline")}la(e){if(e.docChanges.length>0)return!0;let t=this.ca&&this.ca.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&this.options.includeMetadataChanges===!0}Pa(e){e=Wo.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.ua=!0,this.aa.next(e)}ra(){return this.options.source!==Nm.Cache}};var Rh=class{constructor(e){this.key=e}},Ph=class{constructor(e){this.key=e}},Vm=class{constructor(e,t){this.query=e,this.fa=t,this.ga=null,this.hasCachedResults=!1,this.current=!1,this.pa=xe(),this.mutatedKeys=xe(),this.ya=oT(e),this.wa=new xh(this.ya)}get Sa(){return this.fa}ba(e,t){let r=t?t.Da:new Ah,s=t?t.wa:this.wa,a=t?t.mutatedKeys:this.mutatedKeys,c=s,h=!1,f=this.query.limitType==="F"&&s.size===this.query.limit?s.last():null,m=this.query.limitType==="L"&&s.size===this.query.limit?s.first():null;if(e.inorderTraversal((_,E)=>{let I=s.get(_),k=zh(this.query,E)?E:null,B=!!I&&this.mutatedKeys.has(I.key),G=!!k&&(k.hasLocalMutations||this.mutatedKeys.has(k.key)&&k.hasCommittedMutations),j=!1;I&&k?I.data.isEqual(k.data)?B!==G&&(r.track({type:3,doc:k}),j=!0):this.va(I,k)||(r.track({type:2,doc:k}),j=!0,(f&&this.ya(k,f)>0||m&&this.ya(k,m)<0)&&(h=!0)):!I&&k?(r.track({type:0,doc:k}),j=!0):I&&!k&&(r.track({type:1,doc:I}),j=!0,(f||m)&&(h=!0)),j&&(k?(c=c.add(k),a=G?a.add(_):a.delete(_)):(c=c.delete(_),a=a.delete(_)))}),this.query.limit!==null)for(;c.size>this.query.limit;){let _=this.query.limitType==="F"?c.last():c.first();c=c.delete(_.key),a=a.delete(_.key),r.track({type:1,doc:_})}return{wa:c,Da:r,ls:h,mutatedKeys:a}}va(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,r,s){let a=this.wa;this.wa=e.wa,this.mutatedKeys=e.mutatedKeys;let c=e.Da.X_();c.sort((_,E)=>function(k,B){let G=j=>{switch(j){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return ue()}};return G(k)-G(B)}(_.type,E.type)||this.ya(_.doc,E.doc)),this.Ca(r),s=s!=null&&s;let h=t&&!s?this.Fa():[],f=this.pa.size===0&&this.current&&!s?1:0,m=f!==this.ga;return this.ga=f,c.length!==0||m?{snapshot:new Wo(this.query,e.wa,a,c,e.mutatedKeys,f===0,m,!1,!!r&&r.resumeToken.approximateByteSize()>0),Ma:h}:{Ma:h}}sa(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({wa:this.wa,Da:new Ah,mutatedKeys:this.mutatedKeys,ls:!1},!1)):{Ma:[]}}xa(e){return!this.fa.has(e)&&!!this.wa.has(e)&&!this.wa.get(e).hasLocalMutations}Ca(e){e&&(e.addedDocuments.forEach(t=>this.fa=this.fa.add(t)),e.modifiedDocuments.forEach(t=>{}),e.removedDocuments.forEach(t=>this.fa=this.fa.delete(t)),this.current=e.current)}Fa(){if(!this.current)return[];let e=this.pa;this.pa=xe(),this.wa.forEach(r=>{this.xa(r.key)&&(this.pa=this.pa.add(r.key))});let t=[];return e.forEach(r=>{this.pa.has(r)||t.push(new Ph(r))}),this.pa.forEach(r=>{e.has(r)||t.push(new Rh(r))}),t}Oa(e){this.fa=e.gs,this.pa=xe();let t=this.ba(e.documents);return this.applyChanges(t,!0)}Na(){return Wo.fromInitialDocuments(this.query,this.wa,this.mutatedKeys,this.ga===0,this.hasCachedResults)}},dg="SyncEngine",Lm=class{constructor(e,t,r){this.query=e,this.targetId=t,this.view=r}},Mm=class{constructor(e){this.key=e,this.Ba=!1}},Fm=class{constructor(e,t,r,s,a,c){this.localStore=e,this.remoteStore=t,this.eventManager=r,this.sharedClientState=s,this.currentUser=a,this.maxConcurrentLimboResolutions=c,this.La={},this.ka=new Or(h=>sT(h),qh),this.qa=new Map,this.Qa=new Set,this.$a=new Je(ce.comparator),this.Ka=new Map,this.Ua=new bu,this.Wa={},this.Ga=new Map,this.za=wu.Un(),this.onlineState="Unknown",this.ja=void 0}get isPrimaryClient(){return this.ja===!0}};async function nF(n,e,t=!0){let r=jT(n),s,a=r.ka.get(e);return a?(r.sharedClientState.addLocalQueryTarget(a.targetId),s=a.view.Na()):s=await LT(r,e,t,!0),s}async function rF(n,e){let t=jT(n);await LT(t,e,!0,!1)}async function LT(n,e,t,r){let s=await BM(n.localStore,Hn(e)),a=s.targetId,c=n.sharedClientState.addLocalQueryTarget(a,t),h;return r&&(h=await iF(n,e,a,c==="current",s.resumeToken)),n.isPrimaryClient&&t&&RT(n.remoteStore,s),h}async function iF(n,e,t,r,s){n.Ha=(E,I,k)=>async function(G,j,J,ee){let ne=j.view.ba(J);ne.ls&&(ne=await _b(G.localStore,j.query,!1).then(({documents:C})=>j.view.ba(C,ne)));let le=ee&&ee.targetChanges.get(j.targetId),de=ee&&ee.targetMismatches.get(j.targetId)!=null,ie=j.view.applyChanges(ne,G.isPrimaryClient,le,de);return Ib(G,j.targetId,ie.Ma),ie.snapshot}(n,E,I,k);let a=await _b(n.localStore,e,!0),c=new Vm(e,a.gs),h=c.ba(a.documents),f=yu.createSynthesizedTargetChangeForCurrentChange(t,r&&n.onlineState!=="Offline",s),m=c.applyChanges(h,n.isPrimaryClient,f);Ib(n,t,m.Ma);let _=new Lm(e,t,c);return n.ka.set(e,_),n.qa.has(t)?n.qa.get(t).push(e):n.qa.set(t,[e]),m.snapshot}async function sF(n,e,t){let r=fe(n),s=r.ka.get(e),a=r.qa.get(s.targetId);if(a.length>1)return r.qa.set(s.targetId,a.filter(c=>!qh(c,e))),void r.ka.delete(e);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(s.targetId),r.sharedClientState.isActiveQueryTarget(s.targetId)||await ym(r.localStore,s.targetId,!1).then(()=>{r.sharedClientState.clearQueryState(s.targetId),t&&ag(r.remoteStore,s.targetId),Um(r,s.targetId)}).catch(Yo)):(Um(r,s.targetId),await ym(r.localStore,s.targetId,!0))}async function oF(n,e){let t=fe(n),r=t.ka.get(e),s=t.qa.get(r.targetId);t.isPrimaryClient&&s.length===1&&(t.sharedClientState.removeLocalQueryTarget(r.targetId),ag(t.remoteStore,r.targetId))}async function aF(n,e,t){let r=pF(n);try{let s=await function(c,h){let f=fe(c),m=yt.now(),_=h.reduce((k,B)=>k.add(B.key),xe()),E,I;return f.persistence.runTransaction("Locally write mutations","readwrite",k=>{let B=kr(),G=xe();return f.ds.getEntries(k,_).next(j=>{B=j,B.forEach((J,ee)=>{ee.isValidDocument()||(G=G.add(J))})}).next(()=>f.localDocuments.getOverlayedDocuments(k,B)).next(j=>{E=j;let J=[];for(let ee of h){let ne=hM(ee,E.get(ee.key).overlayedDocument);ne!=null&&J.push(new Zn(ee.key,ne,Zb(ne.value.mapValue),_i.exists(!0)))}return f.mutationQueue.addMutationBatch(k,m,J,h)}).next(j=>{I=j;let J=j.applyToLocalDocumentSet(E,G);return f.documentOverlayCache.saveOverlays(k,j.batchId,J)})}).then(()=>({batchId:I.batchId,changes:uT(E)}))}(r.localStore,e);r.sharedClientState.addPendingMutation(s.batchId),function(c,h,f){let m=c.Wa[c.currentUser.toKey()];m||(m=new Je(Re)),m=m.insert(h,f),c.Wa[c.currentUser.toKey()]=m}(r,s.batchId,t),await Cu(r,s.changes),await Wh(r.remoteStore)}catch(s){let a=hg(s,"Failed to persist write");t.reject(a)}}async function MT(n,e){let t=fe(n);try{let r=await MM(t.localStore,e);e.targetChanges.forEach((s,a)=>{let c=t.Ka.get(a);c&&(Le(s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size<=1),s.addedDocuments.size>0?c.Ba=!0:s.modifiedDocuments.size>0?Le(c.Ba):s.removedDocuments.size>0&&(Le(c.Ba),c.Ba=!1))}),await Cu(t,r,e)}catch(r){await Yo(r)}}function Eb(n,e,t){let r=fe(n);if(r.isPrimaryClient&&t===0||!r.isPrimaryClient&&t===1){let s=[];r.ka.forEach((a,c)=>{let h=c.view.sa(e);h.snapshot&&s.push(h.snapshot)}),function(c,h){let f=fe(c);f.onlineState=h;let m=!1;f.queries.forEach((_,E)=>{for(let I of E.ta)I.sa(h)&&(m=!0)}),m&&fg(f)}(r.eventManager,e),s.length&&r.La.p_(s),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}async function uF(n,e,t){let r=fe(n);r.sharedClientState.updateQueryState(e,"rejected",t);let s=r.Ka.get(e),a=s&&s.key;if(a){let c=new Je(ce.comparator);c=c.insert(a,Rn.newNoDocument(a,me.min()));let h=xe().add(a),f=new fh(me.min(),new Map,new Je(Re),c,h);await MT(r,f),r.$a=r.$a.remove(a),r.Ka.delete(e),pg(r)}else await ym(r.localStore,e,!1).then(()=>Um(r,e,t)).catch(Yo)}async function cF(n,e){let t=fe(n),r=e.batch.batchId;try{let s=await LM(t.localStore,e);UT(t,r,null),FT(t,r),t.sharedClientState.updateMutationState(r,"acknowledged"),await Cu(t,s)}catch(s){await Yo(s)}}async function lF(n,e,t){let r=fe(n);try{let s=await function(c,h){let f=fe(c);return f.persistence.runTransaction("Reject batch","readwrite-primary",m=>{let _;return f.mutationQueue.lookupMutationBatch(m,h).next(E=>(Le(E!==null),_=E.keys(),f.mutationQueue.removeMutationBatch(m,E))).next(()=>f.mutationQueue.performConsistencyCheck(m)).next(()=>f.documentOverlayCache.removeOverlaysForBatchId(m,_,h)).next(()=>f.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(m,_)).next(()=>f.localDocuments.getDocuments(m,_))})}(r.localStore,e);UT(r,e,t),FT(r,e),r.sharedClientState.updateMutationState(e,"rejected",t),await Cu(r,s)}catch(s){await Yo(s)}}function FT(n,e){(n.Ga.get(e)||[]).forEach(t=>{t.resolve()}),n.Ga.delete(e)}function UT(n,e,t){let r=fe(n),s=r.Wa[r.currentUser.toKey()];if(s){let a=s.get(e);a&&(t?a.reject(t):a.resolve(),s=s.remove(e)),r.Wa[r.currentUser.toKey()]=s}}function Um(n,e,t=null){n.sharedClientState.removeLocalQueryTarget(e);for(let r of n.qa.get(e))n.ka.delete(r),t&&n.La.Ja(r,t);n.qa.delete(e),n.isPrimaryClient&&n.Ua.br(e).forEach(r=>{n.Ua.containsKey(r)||BT(n,r)})}function BT(n,e){n.Qa.delete(e.path.canonicalString());let t=n.$a.get(e);t!==null&&(ag(n.remoteStore,t),n.$a=n.$a.remove(e),n.Ka.delete(t),pg(n))}function Ib(n,e,t){for(let r of t)r instanceof Rh?(n.Ua.addReference(r.key,e),hF(n,r)):r instanceof Ph?(X(dg,"Document no longer in limbo: "+r.key),n.Ua.removeReference(r.key,e),n.Ua.containsKey(r.key)||BT(n,r.key)):ue()}function hF(n,e){let t=e.key,r=t.path.canonicalString();n.$a.get(t)||n.Qa.has(r)||(X(dg,"New document in limbo: "+t),n.Qa.add(r),pg(n))}function pg(n){for(;n.Qa.size>0&&n.$a.size<n.maxConcurrentLimboResolutions;){let e=n.Qa.values().next().value;n.Qa.delete(e);let t=new ce(st.fromString(e)),r=n.za.next();n.Ka.set(r,new Mm(t)),n.$a=n.$a.insert(t,r),RT(n.remoteStore,new vu(Hn($h(t.path)),r,"TargetPurposeLimboResolution",Lo.ae))}}async function Cu(n,e,t){let r=fe(n),s=[],a=[],c=[];r.ka.isEmpty()||(r.ka.forEach((h,f)=>{c.push(r.Ha(f,e,t).then(m=>{var _;if((m||t)&&r.isPrimaryClient){let E=m?!m.fromCache:(_=t==null?void 0:t.targetChanges.get(f.targetId))===null||_===void 0?void 0:_.current;r.sharedClientState.updateQueryState(f.targetId,E?"current":"not-current")}if(m){s.push(m);let E=pm.Yi(f.targetId,m);a.push(E)}}))}),await Promise.all(c),r.La.p_(s),await async function(f,m){let _=fe(f);try{await _.persistence.runTransaction("notifyLocalViewChanges","readwrite",E=>W.forEach(m,I=>W.forEach(I.Hi,k=>_.persistence.referenceDelegate.addReference(E,I.targetId,k)).next(()=>W.forEach(I.Ji,k=>_.persistence.referenceDelegate.removeReference(E,I.targetId,k)))))}catch(E){if(!Xo(E))throw E;X(og,"Failed to update sequence numbers: "+E)}for(let E of m){let I=E.targetId;if(!E.fromCache){let k=_.Ts.get(I),B=k.snapshotVersion,G=k.withLastLimboFreeSnapshotVersion(B);_.Ts=_.Ts.insert(I,G)}}}(r.localStore,a))}async function fF(n,e){let t=fe(n);if(!t.currentUser.isEqual(e)){X(dg,"User change. New user:",e.toKey());let r=await AT(t.localStore,e);t.currentUser=e,function(a,c){a.Ga.forEach(h=>{h.forEach(f=>{f.reject(new re(H.CANCELLED,c))})}),a.Ga.clear()}(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedClientState.handleUserChange(e,r.removedBatchIds,r.addedBatchIds),await Cu(t,r.Rs)}}function dF(n,e){let t=fe(n),r=t.Ka.get(e);if(r&&r.Ba)return xe().add(r.key);{let s=xe(),a=t.qa.get(e);if(!a)return s;for(let c of a){let h=t.ka.get(c);s=s.unionWith(h.view.Sa)}return s}}function jT(n){let e=fe(n);return e.remoteStore.remoteSyncer.applyRemoteEvent=MT.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=dF.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=uF.bind(null,e),e.La.p_=eF.bind(null,e.eventManager),e.La.Ja=tF.bind(null,e.eventManager),e}function pF(n){let e=fe(n);return e.remoteStore.remoteSyncer.applySuccessfulWrite=cF.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=lF.bind(null,e),e}var Ho=class{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=Gh(e.databaseInfo.databaseId),this.sharedClientState=this.Za(e),this.persistence=this.Xa(e),await this.persistence.start(),this.localStore=this.eu(e),this.gcScheduler=this.tu(e,this.localStore),this.indexBackfillerScheduler=this.nu(e,this.localStore)}tu(e,t){return null}nu(e,t){return null}eu(e){return VM(this.persistence,new gm,e.initialUser,this.serializer)}Xa(e){return new yh(dm.ri,this.serializer)}Za(e){return new vm}async terminate(){var e,t;(e=this.gcScheduler)===null||e===void 0||e.stop(),(t=this.indexBackfillerScheduler)===null||t===void 0||t.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}};Ho.provider={build:()=>new Ho};var Bm=class extends Ho{constructor(e){super(),this.cacheSizeBytes=e}tu(e,t){Le(this.persistence.referenceDelegate instanceof vh);let r=this.persistence.referenceDelegate.garbageCollector;return new em(r,e.asyncQueue,t)}Xa(e){let t=this.cacheSizeBytes!==void 0?ln.withCacheSize(this.cacheSizeBytes):ln.DEFAULT;return new yh(r=>vh.ri(r,t),this.serializer)}};var Tu=class{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=r=>Eb(this.syncEngine,r,1),this.remoteStore.remoteSyncer.handleCredentialChange=fF.bind(null,this.syncEngine),await ZM(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return function(){return new km}()}createDatastore(e){let t=Gh(e.databaseInfo.databaseId),r=function(a){return new Im(a)}(e.databaseInfo);return function(a,c,h,f){return new Rm(a,c,h,f)}(e.authCredentials,e.appCheckCredentials,r,t)}createRemoteStore(e){return function(r,s,a,c,h){return new Cm(r,s,a,c,h)}(this.localStore,this.datastore,e.asyncQueue,t=>Eb(this.syncEngine,t,0),function(){return bh.D()?new bh:new wm}())}createSyncEngine(e,t){return function(s,a,c,h,f,m,_){let E=new Fm(s,a,c,h,f,m);return _&&(E.ja=!0),E}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){var e,t;await async function(s){let a=fe(s);X(ps,"RemoteStore shutting down."),a.W_.add(5),await Pu(a),a.z_.shutdown(),a.j_.set("Unknown")}(this.remoteStore),(e=this.datastore)===null||e===void 0||e.terminate(),(t=this.eventManager)===null||t===void 0||t.terminate()}};Tu.provider={build:()=>new Tu};var Ch=class{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.iu(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.iu(this.observer.error,e):Pr("Uncaught Error in snapshot listener:",e.toString()))}su(){this.muted=!0}iu(e,t){setTimeout(()=>{this.muted||e(t)},0)}};var wi="FirestoreClient",jm=class{constructor(e,t,r,s,a){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=r,this.databaseInfo=s,this.user=mt.UNAUTHENTICATED,this.clientId=ih.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=a,this.authCredentials.start(r,async c=>{X(wi,"Received user=",c.uid),await this.authCredentialListener(c),this.user=c}),this.appCheckCredentials.start(r,c=>(X(wi,"Received new app check token=",c),this.appCheckCredentialListener(c,this.user)))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();let e=new Kn;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){let r=hg(t,"Failed to shutdown persistence");e.reject(r)}}),e.promise}};async function pp(n,e){n.asyncQueue.verifyOperationInProgress(),X(wi,"Initializing OfflineComponentProvider");let t=n.configuration;await e.initialize(t);let r=t.initialUser;n.setCredentialChangeListener(async s=>{r.isEqual(s)||(await AT(e.localStore,s),r=s)}),e.persistence.setDatabaseDeletedListener(()=>n.terminate()),n._offlineComponents=e}async function xb(n,e){n.asyncQueue.verifyOperationInProgress();let t=await mF(n);X(wi,"Initializing OnlineComponentProvider"),await e.initialize(t,n.configuration),n.setCredentialChangeListener(r=>wb(e.remoteStore,r)),n.setAppCheckTokenChangeListener((r,s)=>wb(e.remoteStore,s)),n._onlineComponents=e}async function mF(n){if(!n._offlineComponents)if(n._uninitializedComponentsProvider){X(wi,"Using user provided OfflineComponentProvider");try{await pp(n,n._uninitializedComponentsProvider._offline)}catch(e){let t=e;if(!function(s){return s.name==="FirebaseError"?s.code===H.FAILED_PRECONDITION||s.code===H.UNIMPLEMENTED:!(typeof DOMException!="undefined"&&s instanceof DOMException)||s.code===22||s.code===20||s.code===11}(t))throw t;No("Error using user provided cache. Falling back to memory cache: "+t),await pp(n,new Ho)}}else X(wi,"Using default OfflineComponentProvider"),await pp(n,new Bm(void 0));return n._offlineComponents}async function $T(n){return n._onlineComponents||(n._uninitializedComponentsProvider?(X(wi,"Using user provided OnlineComponentProvider"),await xb(n,n._uninitializedComponentsProvider._online)):(X(wi,"Using default OnlineComponentProvider"),await xb(n,new Tu))),n._onlineComponents}function gF(n){return $T(n).then(e=>e.syncEngine)}async function $m(n){let e=await $T(n),t=e.eventManager;return t.onListen=nF.bind(null,e.syncEngine),t.onUnlisten=sF.bind(null,e.syncEngine),t.onFirstRemoteStoreListen=rF.bind(null,e.syncEngine),t.onLastRemoteStoreUnlisten=oF.bind(null,e.syncEngine),t}function _F(n,e,t={}){let r=new Kn;return n.asyncQueue.enqueueAndForget(async()=>function(a,c,h,f,m){let _=new Ch({next:I=>{_.su(),c.enqueueAndForget(()=>VT(a,E));let k=I.docs.has(h);!k&&I.fromCache?m.reject(new re(H.UNAVAILABLE,"Failed to get document because the client is offline.")):k&&I.fromCache&&f&&f.source==="server"?m.reject(new re(H.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):m.resolve(I)},error:I=>m.reject(I)}),E=new Sh($h(h.path),_,{includeMetadataChanges:!0,Ta:!0});return NT(a,E)}(await $m(n),n.asyncQueue,e,t,r)),r.promise}function qT(n){let e={};return n.timeoutSeconds!==void 0&&(e.timeoutSeconds=n.timeoutSeconds),e}var Ab=new Map;function yF(n,e,t){if(!t)throw new re(H.INVALID_ARGUMENT,`Function ${n}() cannot be called with an empty ${e}.`)}function vF(n,e,t,r){if(e===!0&&r===!0)throw new re(H.INVALID_ARGUMENT,`${n} and ${t} cannot be used together.`)}function Sb(n){if(!ce.isDocumentKey(n))throw new re(H.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${n} has ${n.length}.`)}function mg(n){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n.length>20&&(n=`${n.substring(0,20)}...`),JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean")return""+n;if(typeof n=="object"){if(n instanceof Array)return"an array";{let e=function(r){return r.constructor?r.constructor.name:null}(n);return e?`a custom ${e} object`:"an object"}}return typeof n=="function"?"a function":ue()}function Jn(n,e){if("_delegate"in n&&(n=n._delegate),!(n instanceof e)){if(e.name===n.constructor.name)throw new re(H.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{let t=mg(n);throw new re(H.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${t}`)}}return n}var zT="firestore.googleapis.com",Rb=!0,Dh=class{constructor(e){var t,r;if(e.host===void 0){if(e.ssl!==void 0)throw new re(H.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=zT,this.ssl=Rb}else this.host=e.host,this.ssl=(t=e.ssl)!==null&&t!==void 0?t:Rb;if(this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=xT;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<OM)throw new re(H.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}vF("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=qT((r=e.experimentalLongPollingOptions)!==null&&r!==void 0?r:{}),function(a){if(a.timeoutSeconds!==void 0){if(isNaN(a.timeoutSeconds))throw new re(H.INVALID_ARGUMENT,`invalid long polling timeout: ${a.timeoutSeconds} (must not be NaN)`);if(a.timeoutSeconds<5)throw new re(H.INVALID_ARGUMENT,`invalid long polling timeout: ${a.timeoutSeconds} (minimum allowed value is 5)`);if(a.timeoutSeconds>30)throw new re(H.INVALID_ARGUMENT,`invalid long polling timeout: ${a.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&function(r,s){return r.timeoutSeconds===s.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}},Eu=class{constructor(e,t,r,s){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=r,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Dh({}),this._settingsFrozen=!1,this._terminateTask="notTerminated"}get app(){if(!this._app)throw new re(H.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!=="notTerminated"}_setSettings(e){if(this._settingsFrozen)throw new re(H.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new Dh(e),e.credentials!==void 0&&(this._authCredentials=function(r){if(!r)return new mp;switch(r.type){case"firstParty":return new vp(r.sessionIndex||"0",r.iamToken||null,r.authTokenFactory||null);case"provider":return r.client;default:throw new re(H.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}_getSettings(){return this._settings}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(t){let r=Ab.get(t);r&&(X("ComponentProvider","Removing Datastore"),Ab.delete(t),r.terminate())}(this),Promise.resolve()}};function wF(n,e,t,r={}){var s;let a=(n=Jn(n,Eu))._getSettings(),c=`${e}:${t}`;if(a.host!==zT&&a.host!==c&&No("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used."),n._setSettings(Object.assign(Object.assign({},a),{host:c,ssl:!1})),r.mockUserToken){let h,f;if(typeof r.mockUserToken=="string")h=r.mockUserToken,f=mt.MOCK_USER;else{h=w0(r.mockUserToken,(s=n._app)===null||s===void 0?void 0:s.options.projectId);let m=r.mockUserToken.sub||r.mockUserToken.user_id;if(!m)throw new re(H.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");f=new mt(m)}n._authCredentials=new gp(new nh(h,f))}}var Oh=class n{constructor(e,t,r){this.converter=t,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new n(this.firestore,e,this._query)}},qt=class n{constructor(e,t,r){this.converter=t,this._key=r,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new Iu(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new n(this.firestore,e,this._key)}},Iu=class n extends Oh{constructor(e,t,r){super(e,t,$h(r)),this._path=r,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){let e=this._path.popLast();return e.isEmpty()?null:new qt(this.firestore,null,new ce(e))}withConverter(e){return new n(this.firestore,e,this._path)}};function Hh(n,e,...t){if(n=Ir(n),arguments.length===1&&(e=ih.newId()),yF("doc","path",e),n instanceof Eu){let r=st.fromString(e,...t);return Sb(r),new qt(n,null,new ce(r))}{if(!(n instanceof qt||n instanceof Iu))throw new re(H.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let r=n._path.child(st.fromString(e,...t));return Sb(r),new qt(n.firestore,n instanceof Iu?n.converter:null,new ce(r))}}var Pb="AsyncQueue",kh=class{constructor(e=Promise.resolve()){this.Vu=[],this.mu=!1,this.fu=[],this.gu=null,this.pu=!1,this.yu=!1,this.wu=[],this.a_=new Th(this,"async_queue_retry"),this.Su=()=>{let r=dp();r&&X(Pb,"Visibility state changed to "+r.visibilityState),this.a_.t_()},this.bu=e;let t=dp();t&&typeof t.addEventListener=="function"&&t.addEventListener("visibilitychange",this.Su)}get isShuttingDown(){return this.mu}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.Du(),this.vu(e)}enterRestrictedMode(e){if(!this.mu){this.mu=!0,this.yu=e||!1;let t=dp();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this.Su)}}enqueue(e){if(this.Du(),this.mu)return new Promise(()=>{});let t=new Kn;return this.vu(()=>this.mu&&this.yu?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Vu.push(e),this.Cu()))}async Cu(){if(this.Vu.length!==0){try{await this.Vu[0](),this.Vu.shift(),this.a_.reset()}catch(e){if(!Xo(e))throw e;X(Pb,"Operation failed with retryable error: "+e)}this.Vu.length>0&&this.a_.Xo(()=>this.Cu())}}vu(e){let t=this.bu.then(()=>(this.pu=!0,e().catch(r=>{this.gu=r,this.pu=!1;let s=function(c){let h=c.message||"";return c.stack&&(h=c.stack.includes(c.message)?c.stack:c.message+`
41
- `+c.stack),h}(r);throw Pr("INTERNAL UNHANDLED ERROR: ",s),r}).then(r=>(this.pu=!1,r))));return this.bu=t,t}enqueueAfterDelay(e,t,r){this.Du(),this.wu.indexOf(e)>-1&&(t=0);let s=Dm.createAndSchedule(this,e,t,r,a=>this.Fu(a));return this.fu.push(s),s}Du(){this.gu&&ue()}verifyOperationInProgress(){}async Mu(){let e;do e=this.bu,await e;while(e!==this.bu)}xu(e){for(let t of this.fu)if(t.timerId===e)return!0;return!1}Ou(e){return this.Mu().then(()=>{this.fu.sort((t,r)=>t.targetTimeMs-r.targetTimeMs);for(let t of this.fu)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.Mu()})}Nu(e){this.wu.push(e)}Fu(e){let t=this.fu.indexOf(e);this.fu.splice(t,1)}};function Cb(n){return function(t,r){if(typeof t!="object"||t===null)return!1;let s=t;for(let a of r)if(a in s&&typeof s[a]=="function")return!0;return!1}(n,["next","error","complete"])}var bi=class extends Eu{constructor(e,t,r,s){super(e,t,r,s),this.type="firestore",this._queue=new kh,this._persistenceKey=(s==null?void 0:s.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new kh(e),this._firestoreClient=void 0,await e}}};function GT(n,e){let t=typeof n=="object"?n:U0(),r=typeof n=="string"?n:e||uh,s=L0(t,"firestore").getImmediate({identifier:r});if(!s._initialized){let a=v0("firestore");a&&wF(s,...a)}return s}function gg(n){if(n._terminated)throw new re(H.FAILED_PRECONDITION,"The client has already been terminated.");return n._firestoreClient||bF(n),n._firestoreClient}function bF(n){var e,t,r;let s=n._freezeSettings(),a=function(h,f,m,_){return new Ep(h,f,m,_.host,_.ssl,_.experimentalForceLongPolling,_.experimentalAutoDetectLongPolling,qT(_.experimentalLongPollingOptions),_.useFetchStreams)}(n._databaseId,((e=n._app)===null||e===void 0?void 0:e.options.appId)||"",n._persistenceKey,s);n._componentsProvider||!((t=s.localCache)===null||t===void 0)&&t._offlineComponentProvider&&(!((r=s.localCache)===null||r===void 0)&&r._onlineComponentProvider)&&(n._componentsProvider={_offline:s.localCache._offlineComponentProvider,_online:s.localCache._onlineComponentProvider}),n._firestoreClient=new jm(n._authCredentials,n._appCheckCredentials,n._queue,a,n._componentsProvider&&function(h){let f=h==null?void 0:h._online.build();return{_offline:h==null?void 0:h._offline.build(f),_online:f}}(n._componentsProvider))}var xu=class n{constructor(e){this._byteString=e}static fromBase64String(e){try{return new n(At.fromBase64String(e))}catch(t){throw new re(H.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new n(At.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}};var Qo=class{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new re(H.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new en(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}};var Au=class{constructor(e){this._methodName=e}};var Su=class{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new re(H.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new re(H.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(e){return Re(this._lat,e._lat)||Re(this._long,e._long)}};var Ru=class{constructor(e){this._values=(e||[]).map(t=>t)}toArray(){return this._values.map(e=>e)}isEqual(e){return function(r,s){if(r.length!==s.length)return!1;for(let a=0;a<r.length;++a)if(r[a]!==s[a])return!1;return!0}(this._values,e._values)}};var TF=/^__.*__$/,qm=class{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return this.fieldMask!==null?new Zn(e,this.data,this.fieldMask,t,this.fieldTransforms):new ds(e,this.data,t,this.fieldTransforms)}},Nh=class{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return new Zn(e,this.data,this.fieldMask,t,this.fieldTransforms)}};function KT(n){switch(n){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw ue()}}var zm=class n{constructor(e,t,r,s,a,c){this.settings=e,this.databaseId=t,this.serializer=r,this.ignoreUndefinedProperties=s,a===void 0&&this.Bu(),this.fieldTransforms=a||[],this.fieldMask=c||[]}get path(){return this.settings.path}get Lu(){return this.settings.Lu}ku(e){return new n(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}qu(e){var t;let r=(t=this.path)===null||t===void 0?void 0:t.child(e),s=this.ku({path:r,Qu:!1});return s.$u(e),s}Ku(e){var t;let r=(t=this.path)===null||t===void 0?void 0:t.child(e),s=this.ku({path:r,Qu:!1});return s.Bu(),s}Uu(e){return this.ku({path:void 0,Qu:!0})}Wu(e){return Lh(e,this.settings.methodName,this.settings.Gu||!1,this.path,this.settings.zu)}contains(e){return this.fieldMask.find(t=>e.isPrefixOf(t))!==void 0||this.fieldTransforms.find(t=>e.isPrefixOf(t.field))!==void 0}Bu(){if(this.path)for(let e=0;e<this.path.length;e++)this.$u(this.path.get(e))}$u(e){if(e.length===0)throw this.Wu("Document fields must not be empty");if(KT(this.Lu)&&TF.test(e))throw this.Wu('Document fields cannot begin and end with "__"')}},Gm=class{constructor(e,t,r){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=r||Gh(e)}ju(e,t,r,s=!1){return new zm({Lu:e,methodName:t,zu:r,path:en.emptyPath(),Qu:!1,Gu:s},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}};function WT(n){let e=n._freezeSettings(),t=Gh(n._databaseId);return new Gm(n._databaseId,!!e.ignoreUndefinedProperties,t)}function EF(n,e,t,r,s,a={}){let c=n.ju(a.merge||a.mergeFields?2:0,e,t,s);_g("Data must be an object, but it was:",c,r);let h=HT(r,c),f,m;if(a.merge)f=new hn(c.fieldMask),m=c.fieldTransforms;else if(a.mergeFields){let _=[];for(let E of a.mergeFields){let I=Km(e,E,t);if(!c.contains(I))throw new re(H.INVALID_ARGUMENT,`Field '${I}' is specified in your field mask but missing from your input data.`);JT(_,I)||_.push(I)}f=new hn(_),m=c.fieldTransforms.filter(E=>f.covers(E.field))}else f=null,m=c.fieldTransforms;return new qm(new Zt(h),f,m)}var Vh=class n extends Au{_toFieldTransform(e){if(e.Lu!==2)throw e.Lu===1?e.Wu(`${this._methodName}() can only appear at the top level of your update data`):e.Wu(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof n}};function IF(n,e,t,r){let s=n.ju(1,e,t);_g("Data must be an object, but it was:",s,r);let a=[],c=Zt.empty();Ti(r,(f,m)=>{let _=yg(e,f,t);m=Ir(m);let E=s.Ku(_);if(m instanceof Vh)a.push(_);else{let I=Qh(m,E);I!=null&&(a.push(_),c.set(_,I))}});let h=new hn(a);return new Nh(c,h,s.fieldTransforms)}function xF(n,e,t,r,s,a){let c=n.ju(1,e,t),h=[Km(e,r,t)],f=[s];if(a.length%2!=0)throw new re(H.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let I=0;I<a.length;I+=2)h.push(Km(e,a[I])),f.push(a[I+1]);let m=[],_=Zt.empty();for(let I=h.length-1;I>=0;--I)if(!JT(m,h[I])){let k=h[I],B=f[I];B=Ir(B);let G=c.Ku(k);if(B instanceof Vh)m.push(k);else{let j=Qh(B,G);j!=null&&(m.push(k),_.set(k,j))}}let E=new hn(m);return new Nh(_,E,c.fieldTransforms)}function Qh(n,e){if(QT(n=Ir(n)))return _g("Unsupported field value:",e,n),HT(n,e);if(n instanceof Au)return function(r,s){if(!KT(s.Lu))throw s.Wu(`${r._methodName}() can only be used with update() and set()`);if(!s.path)throw s.Wu(`${r._methodName}() is not currently supported inside arrays`);let a=r._toFieldTransform(s);a&&s.fieldTransforms.push(a)}(n,e),null;if(n===void 0&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),n instanceof Array){if(e.settings.Qu&&e.Lu!==4)throw e.Wu("Nested arrays are not supported");return function(r,s){let a=[],c=0;for(let h of r){let f=Qh(h,s.Uu(c));f==null&&(f={nullValue:"NULL_VALUE"}),a.push(f),c++}return{arrayValue:{values:a}}}(n,e)}return function(r,s){if((r=Ir(r))===null)return{nullValue:"NULL_VALUE"};if(typeof r=="number")return oM(s.serializer,r);if(typeof r=="boolean")return{booleanValue:r};if(typeof r=="string")return{stringValue:r};if(r instanceof Date){let a=yt.fromDate(r);return{timestampValue:gh(s.serializer,a)}}if(r instanceof yt){let a=new yt(r.seconds,1e3*Math.floor(r.nanoseconds/1e3));return{timestampValue:gh(s.serializer,a)}}if(r instanceof Su)return{geoPointValue:{latitude:r.latitude,longitude:r.longitude}};if(r instanceof xu)return{bytesValue:yT(s.serializer,r._byteString)};if(r instanceof qt){let a=s.databaseId,c=r.firestore._databaseId;if(!c.isEqual(a))throw s.Wu(`Document reference is for database ${c.projectId}/${c.database} but should be for database ${a.projectId}/${a.database}`);return{referenceValue:sg(r.firestore._databaseId||s.databaseId,r._key.path)}}if(r instanceof Ru)return function(c,h){return{mapValue:{fields:{[Zm]:{stringValue:eg},[Mo]:{arrayValue:{values:c.toArray().map(m=>{if(typeof m!="number")throw h.Wu("VectorValues must only contain numeric values.");return ig(h.serializer,m)})}}}}}}(r,s);throw s.Wu(`Unsupported field value: ${mg(r)}`)}(n,e)}function HT(n,e){let t={};return Gb(n)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):Ti(n,(r,s)=>{let a=Qh(s,e.qu(r));a!=null&&(t[r]=a)}),{mapValue:{fields:t}}}function QT(n){return!(typeof n!="object"||n===null||n instanceof Array||n instanceof Date||n instanceof yt||n instanceof Su||n instanceof xu||n instanceof qt||n instanceof Au||n instanceof Ru)}function _g(n,e,t){if(!QT(t)||!function(s){return typeof s=="object"&&s!==null&&(Object.getPrototypeOf(s)===Object.prototype||Object.getPrototypeOf(s)===null)}(t)){let r=mg(t);throw r==="an object"?e.Wu(n+" a custom object"):e.Wu(n+" "+r)}}function Km(n,e,t){if((e=Ir(e))instanceof Qo)return e._internalPath;if(typeof e=="string")return yg(n,e);throw Lh("Field path arguments must be of type string or ",n,!1,void 0,t)}var AF=new RegExp("[~\\*/\\[\\]]");function yg(n,e,t){if(e.search(AF)>=0)throw Lh(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,n,!1,void 0,t);try{return new Qo(...e.split("."))._internalPath}catch{throw Lh(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,n,!1,void 0,t)}}function Lh(n,e,t,r,s){let a=r&&!r.isEmpty(),c=s!==void 0,h=`Function ${e}() called with invalid data`;t&&(h+=" (via `toFirestore()`)"),h+=". ";let f="";return(a||c)&&(f+=" (found",a&&(f+=` in field ${r}`),c&&(f+=` in document ${s}`),f+=")"),new re(H.INVALID_ARGUMENT,h+n+f)}function JT(n,e){return n.some(t=>t.isEqual(e))}var Mh=class{constructor(e,t,r,s,a){this._firestore=e,this._userDataWriter=t,this._key=r,this._document=s,this._converter=a}get id(){return this._key.path.lastSegment()}get ref(){return new qt(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){let e=new Wm(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}get(e){if(this._document){let t=this._document.data.field(YT("DocumentSnapshot.get",e));if(t!==null)return this._userDataWriter.convertValue(t)}}},Wm=class extends Mh{data(){return super.data()}};function YT(n,e){return typeof e=="string"?yg(n,e):e instanceof Qo?e._internalPath:e._delegate._internalPath}function SF(n){if(n.limitType==="L"&&n.explicitOrderBy.length===0)throw new re(H.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}var Hm=class{convertValue(e,t="none"){switch(yi(e)){case 0:return null;case 1:return e.booleanValue;case 2:return ze(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(Dr(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw ue()}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){let r={};return Ti(e,(s,a)=>{r[s]=this.convertValue(a,t)}),r}convertVectorValue(e){var t,r,s;let a=(s=(r=(t=e.fields)===null||t===void 0?void 0:t[Mo].arrayValue)===null||r===void 0?void 0:r.values)===null||s===void 0?void 0:s.map(c=>ze(c.doubleValue));return new Ru(a)}convertGeoPoint(e){return new Su(ze(e.latitude),ze(e.longitude))}convertArray(e,t){return(e.values||[]).map(r=>this.convertValue(r,t))}convertServerTimestamp(e,t){switch(t){case"previous":let r=jh(e);return r==null?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(gu(e));default:return null}}convertTimestamp(e){let t=Cr(e);return new yt(t.seconds,t.nanos)}convertDocumentKey(e,t){let r=st.fromString(e);Le(IT(r));let s=new ch(r.get(1),r.get(3)),a=new ce(r.popFirst(5));return s.isEqual(t)||Pr(`Document ${a} contains a document reference within a different database (${s.projectId}/${s.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),a}};function RF(n,e,t){let r;return r=n?t&&(t.merge||t.mergeFields)?n.toFirestore(e,t):n.toFirestore(e):e,r}var us=class{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}},Fh=class extends Mh{constructor(e,t,r,s,a,c){super(e,t,r,s,c),this._firestore=e,this._firestoreImpl=e,this.metadata=a}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){let t=new ko(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){let r=this._document.data.field(YT("DocumentSnapshot.get",e));if(r!==null)return this._userDataWriter.convertValue(r,t.serverTimestamps)}}},ko=class extends Fh{data(e={}){return super.data(e)}},Qm=class{constructor(e,t,r,s){this._firestore=e,this._userDataWriter=t,this._snapshot=s,this.metadata=new us(s.hasPendingWrites,s.fromCache),this.query=r}get docs(){let e=[];return this.forEach(t=>e.push(t)),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach(r=>{e.call(t,new ko(this._firestore,this._userDataWriter,r.key,r,new us(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){let t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new re(H.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(s,a){if(s._snapshot.oldDocs.isEmpty()){let c=0;return s._snapshot.docChanges.map(h=>{let f=new ko(s._firestore,s._userDataWriter,h.doc.key,h.doc,new us(s._snapshot.mutatedKeys.has(h.doc.key),s._snapshot.fromCache),s.query.converter);return h.doc,{type:"added",doc:f,oldIndex:-1,newIndex:c++}})}{let c=s._snapshot.oldDocs;return s._snapshot.docChanges.filter(h=>a||h.type!==3).map(h=>{let f=new ko(s._firestore,s._userDataWriter,h.doc.key,h.doc,new us(s._snapshot.mutatedKeys.has(h.doc.key),s._snapshot.fromCache),s.query.converter),m=-1,_=-1;return h.type!==0&&(m=c.indexOf(h.doc.key),c=c.delete(h.doc.key)),h.type!==1&&(c=c.add(h.doc),_=c.indexOf(h.doc.key)),{type:PF(h.type),doc:f,oldIndex:m,newIndex:_}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}};function PF(n){switch(n){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return ue()}}function vg(n){n=Jn(n,qt);let e=Jn(n.firestore,bi);return _F(gg(e),n._key).then(t=>nE(e,n,t))}var Uh=class extends Hm{constructor(e){super(),this.firestore=e}convertBytes(e){return new xu(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new qt(this.firestore,null,t)}};function XT(n,e,t){n=Jn(n,qt);let r=Jn(n.firestore,bi),s=RF(n.converter,e,t);return tE(r,[EF(WT(r),"setDoc",n._key,s,n.converter!==null,t).toMutation(n._key,_i.none())])}function ZT(n,e,t,...r){n=Jn(n,qt);let s=Jn(n.firestore,bi),a=WT(s),c;return c=typeof(e=Ir(e))=="string"||e instanceof Qo?xF(a,"updateDoc",n._key,e,t,r):IF(a,"updateDoc",n._key,e),tE(s,[c.toMutation(n._key,_i.exists(!0))])}function eE(n,...e){var t,r,s;n=Ir(n);let a={includeMetadataChanges:!1,source:"default"},c=0;typeof e[c]!="object"||Cb(e[c])||(a=e[c],c++);let h={includeMetadataChanges:a.includeMetadataChanges,source:a.source};if(Cb(e[c])){let E=e[c];e[c]=(t=E.next)===null||t===void 0?void 0:t.bind(E),e[c+1]=(r=E.error)===null||r===void 0?void 0:r.bind(E),e[c+2]=(s=E.complete)===null||s===void 0?void 0:s.bind(E)}let f,m,_;if(n instanceof qt)m=Jn(n.firestore,bi),_=$h(n._key.path),f={next:E=>{e[c]&&e[c](nE(m,n,E))},error:e[c+1],complete:e[c+2]};else{let E=Jn(n,Oh);m=Jn(E.firestore,bi),_=E._query;let I=new Uh(m);f={next:k=>{e[c]&&e[c](new Qm(m,I,E,k))},error:e[c+1],complete:e[c+2]},SF(n._query)}return function(I,k,B,G){let j=new Ch(G),J=new Sh(k,j,B);return I.asyncQueue.enqueueAndForget(async()=>NT(await $m(I),J)),()=>{j.su(),I.asyncQueue.enqueueAndForget(async()=>VT(await $m(I),J))}}(gg(m),_,h,f)}function tE(n,e){return function(r,s){let a=new Kn;return r.asyncQueue.enqueueAndForget(async()=>aF(await gF(r),s,a)),a.promise}(gg(n),e)}function nE(n,e,t){let r=t.docs.get(e._key),s=new Uh(n);return new Fh(n,s,e._key,r,new us(t.hasPendingWrites,t.fromCache),e.converter)}(function(e,t=!0){(function(s){Jo=s})(F0),ou(new xr("firestore",(r,{instanceIdentifier:s,options:a})=>{let c=r.getProvider("app").getImmediate(),h=new bi(new _p(r.getProvider("auth-internal")),new wp(c,r.getProvider("app-check-internal")),function(m,_){if(!Object.prototype.hasOwnProperty.apply(m.options,["projectId"]))throw new re(H.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new ch(m.options.projectId,_)}(c,s),c);return a=Object.assign({useFetchStreams:t},a),h._setSettings(a),h},"PUBLIC").setMultipleInstances(!0)),gi(z0,G0,e),gi(z0,G0,"esm2017")})();var rE=n=>{let e;return n?e=n:typeof fetch=="undefined"?e=(...t)=>Promise.resolve().then(()=>(Ei(),gs)).then(({default:r})=>r(...t)):e=fetch,(...t)=>e(...t)};var Du=class extends Error{constructor(e,t="FunctionsError",r){super(e),this.name=t,this.context=r}},Jh=class extends Du{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}},Yh=class extends Du{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}},Xh=class extends Du{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}},Zh;(function(n){n.Any="any",n.ApNortheast1="ap-northeast-1",n.ApNortheast2="ap-northeast-2",n.ApSouth1="ap-south-1",n.ApSoutheast1="ap-southeast-1",n.ApSoutheast2="ap-southeast-2",n.CaCentral1="ca-central-1",n.EuCentral1="eu-central-1",n.EuWest1="eu-west-1",n.EuWest2="eu-west-2",n.EuWest3="eu-west-3",n.SaEast1="sa-east-1",n.UsEast1="us-east-1",n.UsWest1="us-west-1",n.UsWest2="us-west-2"})(Zh||(Zh={}));var NF=function(n,e,t,r){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(r.next(_))}catch(E){c(E)}}function f(_){try{m(r.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((r=r.apply(n,e||[])).next())})},Ou=class{constructor(e,{headers:t={},customFetch:r,region:s=Zh.Any}={}){this.url=e,this.headers=t,this.region=s,this.fetch=rE(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,t={}){var r;return NF(this,void 0,void 0,function*(){try{let{headers:s,method:a,body:c}=t,h={},{region:f}=t;f||(f=this.region),f&&f!=="any"&&(h["x-region"]=f);let m;c&&(s&&!Object.prototype.hasOwnProperty.call(s,"Content-Type")||!s)&&(typeof Blob!="undefined"&&c instanceof Blob||c instanceof ArrayBuffer?(h["Content-Type"]="application/octet-stream",m=c):typeof c=="string"?(h["Content-Type"]="text/plain",m=c):typeof FormData!="undefined"&&c instanceof FormData?m=c:(h["Content-Type"]="application/json",m=JSON.stringify(c)));let _=yield this.fetch(`${this.url}/${e}`,{method:a||"POST",headers:Object.assign(Object.assign(Object.assign({},h),this.headers),s),body:m}).catch(B=>{throw new Jh(B)}),E=_.headers.get("x-relay-error");if(E&&E==="true")throw new Yh(_);if(!_.ok)throw new Xh(_);let I=((r=_.headers.get("Content-Type"))!==null&&r!==void 0?r:"text/plain").split(";")[0].trim(),k;return I==="application/json"?k=yield _.json():I==="application/octet-stream"?k=yield _.blob():I==="text/event-stream"?k=_:I==="multipart/form-data"?k=yield _.formData():k=yield _.text(),{data:k,error:null}}catch(s){return{data:null,error:s}}})}};var gE=Cd(mE(),1),{PostgrestClient:_E,PostgrestQueryBuilder:kK,PostgrestFilterBuilder:NK,PostgrestTransformBuilder:VK,PostgrestBuilder:LK,PostgrestError:KF}=gE.default;var yE="2.11.2";var vE={"X-Client-Info":`realtime-js/${yE}`},wE="1.0.0",sf=1e4,bE=1e3,_s;(function(n){n[n.connecting=0]="connecting",n[n.open=1]="open",n[n.closing=2]="closing",n[n.closed=3]="closed"})(_s||(_s={}));var zt;(function(n){n.closed="closed",n.errored="errored",n.joined="joined",n.joining="joining",n.leaving="leaving"})(zt||(zt={}));var tn;(function(n){n.close="phx_close",n.error="phx_error",n.join="phx_join",n.reply="phx_reply",n.leave="phx_leave",n.access_token="access_token"})(tn||(tn={}));var rf;(function(n){n.websocket="websocket"})(rf||(rf={}));var Ii;(function(n){n.Connecting="connecting",n.Open="open",n.Closing="closing",n.Closed="closed"})(Ii||(Ii={}));var Uu=class{constructor(){this.HEADER_LENGTH=1}decode(e,t){return e.constructor===ArrayBuffer?t(this._binaryDecode(e)):t(typeof e=="string"?JSON.parse(e):{})}_binaryDecode(e){let t=new DataView(e),r=new TextDecoder;return this._decodeBroadcast(e,t,r)}_decodeBroadcast(e,t,r){let s=t.getUint8(1),a=t.getUint8(2),c=this.HEADER_LENGTH+2,h=r.decode(e.slice(c,c+s));c=c+s;let f=r.decode(e.slice(c,c+a));c=c+a;let m=JSON.parse(r.decode(e.slice(c,e.byteLength)));return{ref:null,topic:h,event:f,payload:m}}};var ys=class{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=t}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}};var je;(function(n){n.abstime="abstime",n.bool="bool",n.date="date",n.daterange="daterange",n.float4="float4",n.float8="float8",n.int2="int2",n.int4="int4",n.int4range="int4range",n.int8="int8",n.int8range="int8range",n.json="json",n.jsonb="jsonb",n.money="money",n.numeric="numeric",n.oid="oid",n.reltime="reltime",n.text="text",n.time="time",n.timestamp="timestamp",n.timestamptz="timestamptz",n.timetz="timetz",n.tsrange="tsrange",n.tstzrange="tstzrange"})(je||(je={}));var Ng=(n,e,t={})=>{var r;let s=(r=t.skipTypes)!==null&&r!==void 0?r:[];return Object.keys(e).reduce((a,c)=>(a[c]=WF(c,n,e,s),a),{})},WF=(n,e,t,r)=>{let s=e.find(h=>h.name===n),a=s==null?void 0:s.type,c=t[n];return a&&!r.includes(a)?TE(a,c):kg(c)},TE=(n,e)=>{if(n.charAt(0)==="_"){let t=n.slice(1,n.length);return YF(e,t)}switch(n){case je.bool:return HF(e);case je.float4:case je.float8:case je.int2:case je.int4:case je.int8:case je.numeric:case je.oid:return QF(e);case je.json:case je.jsonb:return JF(e);case je.timestamp:return XF(e);case je.abstime:case je.date:case je.daterange:case je.int4range:case je.int8range:case je.money:case je.reltime:case je.text:case je.time:case je.timestamptz:case je.timetz:case je.tsrange:case je.tstzrange:return kg(e);default:return kg(e)}},kg=n=>n,HF=n=>{switch(n){case"t":return!0;case"f":return!1;default:return n}},QF=n=>{if(typeof n=="string"){let e=parseFloat(n);if(!Number.isNaN(e))return e}return n},JF=n=>{if(typeof n=="string")try{return JSON.parse(n)}catch(e){return console.log(`JSON parse error: ${e}`),n}return n},YF=(n,e)=>{if(typeof n!="string")return n;let t=n.length-1,r=n[t];if(n[0]==="{"&&r==="}"){let a,c=n.slice(1,t);try{a=JSON.parse("["+c+"]")}catch{a=c?c.split(","):[]}return a.map(h=>TE(e,h))}return n},XF=n=>typeof n=="string"?n.replace(" ","T"):n,of=n=>{let e=n;return e=e.replace(/^ws/i,"http"),e=e.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),e.replace(/\/+$/,"")};var vs=class{constructor(e,t,r={},s=sf){this.channel=e,this.event=t,this.payload=r,this.timeout=s,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,t){var r;return this._hasReceived(e)&&t((r=this.receivedResp)===null||r===void 0?void 0:r.response),this.recHooks.push({status:e,callback:t}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);let e=t=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=t,this._matchReceive(t)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,t){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:t})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:t}){this.recHooks.filter(r=>r.status===e).forEach(r=>r.callback(t))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}};var Vg;(function(n){n.SYNC="sync",n.JOIN="join",n.LEAVE="leave"})(Vg||(Vg={}));var na=class n{constructor(e,t){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};let r=(t==null?void 0:t.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(r.state,{},s=>{let{onJoin:a,onLeave:c,onSync:h}=this.caller;this.joinRef=this.channel._joinRef(),this.state=n.syncState(this.state,s,a,c),this.pendingDiffs.forEach(f=>{this.state=n.syncDiff(this.state,f,a,c)}),this.pendingDiffs=[],h()}),this.channel._on(r.diff,{},s=>{let{onJoin:a,onLeave:c,onSync:h}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(s):(this.state=n.syncDiff(this.state,s,a,c),h())}),this.onJoin((s,a,c)=>{this.channel._trigger("presence",{event:"join",key:s,currentPresences:a,newPresences:c})}),this.onLeave((s,a,c)=>{this.channel._trigger("presence",{event:"leave",key:s,currentPresences:a,leftPresences:c})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,t,r,s){let a=this.cloneDeep(e),c=this.transformState(t),h={},f={};return this.map(a,(m,_)=>{c[m]||(f[m]=_)}),this.map(c,(m,_)=>{let E=a[m];if(E){let I=_.map(j=>j.presence_ref),k=E.map(j=>j.presence_ref),B=_.filter(j=>k.indexOf(j.presence_ref)<0),G=E.filter(j=>I.indexOf(j.presence_ref)<0);B.length>0&&(h[m]=B),G.length>0&&(f[m]=G)}else h[m]=_}),this.syncDiff(a,{joins:h,leaves:f},r,s)}static syncDiff(e,t,r,s){let{joins:a,leaves:c}={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)};return r||(r=()=>{}),s||(s=()=>{}),this.map(a,(h,f)=>{var m;let _=(m=e[h])!==null&&m!==void 0?m:[];if(e[h]=this.cloneDeep(f),_.length>0){let E=e[h].map(k=>k.presence_ref),I=_.filter(k=>E.indexOf(k.presence_ref)<0);e[h].unshift(...I)}r(h,_,f)}),this.map(c,(h,f)=>{let m=e[h];if(!m)return;let _=f.map(E=>E.presence_ref);m=m.filter(E=>_.indexOf(E.presence_ref)<0),e[h]=m,s(h,m,f),m.length===0&&delete e[h]}),e}static map(e,t){return Object.getOwnPropertyNames(e).map(r=>t(r,e[r]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((t,r)=>{let s=e[r];return"metas"in s?t[r]=s.metas.map(a=>(a.presence_ref=a.phx_ref,delete a.phx_ref,delete a.phx_ref_prev,a)):t[r]=s,t},{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}};var Lg;(function(n){n.ALL="*",n.INSERT="INSERT",n.UPDATE="UPDATE",n.DELETE="DELETE"})(Lg||(Lg={}));var Mg;(function(n){n.BROADCAST="broadcast",n.PRESENCE="presence",n.POSTGRES_CHANGES="postgres_changes",n.SYSTEM="system"})(Mg||(Mg={}));var er;(function(n){n.SUBSCRIBED="SUBSCRIBED",n.TIMED_OUT="TIMED_OUT",n.CLOSED="CLOSED",n.CHANNEL_ERROR="CHANNEL_ERROR"})(er||(er={}));var ra=class n{constructor(e,t={config:{}},r){this.topic=e,this.params=t,this.socket=r,this.bindings={},this.state=zt.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""},private:!1},t.config),this.timeout=this.socket.timeout,this.joinPush=new vs(this,tn.join,this.params,this.timeout),this.rejoinTimer=new ys(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=zt.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=zt.closed,this.socket._remove(this)}),this._onError(s=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,s),this.state=zt.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=zt.errored,this.rejoinTimer.scheduleTimeout())}),this._on(tn.reply,{},(s,a)=>{this._trigger(this._replyEventName(a),s)}),this.presence=new na(this),this.broadcastEndpointURL=of(this.socket.endPoint)+"/api/broadcast",this.private=this.params.config.private||!1}subscribe(e,t=this.timeout){var r,s;if(this.socket.isConnected()||this.socket.connect(),this.joinedOnce)throw"tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";{let{config:{broadcast:a,presence:c,private:h}}=this.params;this._onError(_=>e==null?void 0:e(er.CHANNEL_ERROR,_)),this._onClose(()=>e==null?void 0:e(er.CLOSED));let f={},m={broadcast:a,presence:c,postgres_changes:(s=(r=this.bindings.postgres_changes)===null||r===void 0?void 0:r.map(_=>_.filter))!==null&&s!==void 0?s:[],private:h};this.socket.accessTokenValue&&(f.access_token=this.socket.accessTokenValue),this.updateJoinPayload(Object.assign({config:m},f)),this.joinedOnce=!0,this._rejoin(t),this.joinPush.receive("ok",async({postgres_changes:_})=>{var E;if(this.socket.setAuth(),_===void 0){e==null||e(er.SUBSCRIBED);return}else{let I=this.bindings.postgres_changes,k=(E=I==null?void 0:I.length)!==null&&E!==void 0?E:0,B=[];for(let G=0;G<k;G++){let j=I[G],{filter:{event:J,schema:ee,table:ne,filter:le}}=j,de=_&&_[G];if(de&&de.event===J&&de.schema===ee&&de.table===ne&&de.filter===le)B.push(Object.assign(Object.assign({},j),{id:de.id}));else{this.unsubscribe(),e==null||e(er.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=B,e&&e(er.SUBSCRIBED);return}}).receive("error",_=>{e==null||e(er.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(_).join(", ")||"error")))}).receive("timeout",()=>{e==null||e(er.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(e,t={}){return await this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,t,r){return this._on(e,t,r)}async send(e,t={}){var r,s;if(!this._canPush()&&e.type==="broadcast"){let{event:a,payload:c}=e,f={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:a,payload:c,private:this.private}]})};try{let m=await this._fetchWithTimeout(this.broadcastEndpointURL,f,(r=t.timeout)!==null&&r!==void 0?r:this.timeout);return await((s=m.body)===null||s===void 0?void 0:s.cancel()),m.ok?"ok":"error"}catch(m){return m.name==="AbortError"?"timed out":"error"}}else return new Promise(a=>{var c,h,f;let m=this._push(e.type,e,t.timeout||this.timeout);e.type==="broadcast"&&!(!((f=(h=(c=this.params)===null||c===void 0?void 0:c.config)===null||h===void 0?void 0:h.broadcast)===null||f===void 0)&&f.ack)&&a("ok"),m.receive("ok",()=>a("ok")),m.receive("error",()=>a("error")),m.receive("timeout",()=>a("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=zt.leaving;let t=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(tn.close,"leave",this._joinRef())};return this.rejoinTimer.reset(),this.joinPush.destroy(),new Promise(r=>{let s=new vs(this,tn.leave,{},e);s.receive("ok",()=>{t(),r("ok")}).receive("timeout",()=>{t(),r("timed out")}).receive("error",()=>{r("error")}),s.send(),this._canPush()||s.trigger("ok",{})})}async _fetchWithTimeout(e,t,r){let s=new AbortController,a=setTimeout(()=>s.abort(),r),c=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:s.signal}));return clearTimeout(a),c}_push(e,t,r=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let s=new vs(this,e,t,r);return this._canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}_onMessage(e,t,r){return t}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,t,r){var s,a;let c=e.toLocaleLowerCase(),{close:h,error:f,leave:m,join:_}=tn;if(r&&[h,f,m,_].indexOf(c)>=0&&r!==this._joinRef())return;let I=this._onMessage(c,t,r);if(t&&!I)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(c)?(s=this.bindings.postgres_changes)===null||s===void 0||s.filter(k=>{var B,G,j;return((B=k.filter)===null||B===void 0?void 0:B.event)==="*"||((j=(G=k.filter)===null||G===void 0?void 0:G.event)===null||j===void 0?void 0:j.toLocaleLowerCase())===c}).map(k=>k.callback(I,r)):(a=this.bindings[c])===null||a===void 0||a.filter(k=>{var B,G,j,J,ee,ne;if(["broadcast","presence","postgres_changes"].includes(c))if("id"in k){let le=k.id,de=(B=k.filter)===null||B===void 0?void 0:B.event;return le&&((G=t.ids)===null||G===void 0?void 0:G.includes(le))&&(de==="*"||(de==null?void 0:de.toLocaleLowerCase())===((j=t.data)===null||j===void 0?void 0:j.type.toLocaleLowerCase()))}else{let le=(ee=(J=k==null?void 0:k.filter)===null||J===void 0?void 0:J.event)===null||ee===void 0?void 0:ee.toLocaleLowerCase();return le==="*"||le===((ne=t==null?void 0:t.event)===null||ne===void 0?void 0:ne.toLocaleLowerCase())}else return k.type.toLocaleLowerCase()===c}).map(k=>{if(typeof I=="object"&&"ids"in I){let B=I.data,{schema:G,table:j,commit_timestamp:J,type:ee,errors:ne}=B;I=Object.assign(Object.assign({},{schema:G,table:j,commit_timestamp:J,eventType:ee,new:{},old:{},errors:ne}),this._getPayloadRecords(B))}k.callback(I,r)})}_isClosed(){return this.state===zt.closed}_isJoined(){return this.state===zt.joined}_isJoining(){return this.state===zt.joining}_isLeaving(){return this.state===zt.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,t,r){let s=e.toLocaleLowerCase(),a={type:s,filter:t,callback:r};return this.bindings[s]?this.bindings[s].push(a):this.bindings[s]=[a],this}_off(e,t){let r=e.toLocaleLowerCase();return this.bindings[r]=this.bindings[r].filter(s=>{var a;return!(((a=s.type)===null||a===void 0?void 0:a.toLocaleLowerCase())===r&&n.isEqual(s.filter,t))}),this}static isEqual(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e)if(e[r]!==t[r])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(tn.close,{},e)}_onError(e){this._on(tn.error,{},t=>e(t))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=zt.joining,this.joinPush.resend(e))}_getPayloadRecords(e){let t={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(t.new=Ng(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(t.old=Ng(e.columns,e.old_record)),t}};var eU=()=>{},tU=typeof WebSocket!="undefined",nU=`
40
+ )`}copy(e,t){let n=new r;return n.comparator=this.comparator,n.keyedMap=e,n.sortedSet=t,n}};var Sh=class{constructor(){this.Z_=new Ye(ce.comparator)}track(e){let t=e.doc.key,n=this.Z_.get(t);n?e.type!==0&&n.type===3?this.Z_=this.Z_.insert(t,e):e.type===3&&n.type!==1?this.Z_=this.Z_.insert(t,{type:n.type,doc:e.doc}):e.type===2&&n.type===2?this.Z_=this.Z_.insert(t,{type:2,doc:e.doc}):e.type===2&&n.type===0?this.Z_=this.Z_.insert(t,{type:0,doc:e.doc}):e.type===1&&n.type===0?this.Z_=this.Z_.remove(t):e.type===1&&n.type===2?this.Z_=this.Z_.insert(t,{type:1,doc:n.doc}):e.type===0&&n.type===1?this.Z_=this.Z_.insert(t,{type:2,doc:e.doc}):ue():this.Z_=this.Z_.insert(t,e)}X_(){let e=[];return this.Z_.inorderTraversal((t,n)=>{e.push(n)}),e}},Ho=class r{constructor(e,t,n,s,a,c,h,f,m){this.query=e,this.docs=t,this.oldDocs=n,this.docChanges=s,this.mutatedKeys=a,this.fromCache=c,this.syncStateChanged=h,this.excludesMetadataChanges=f,this.hasCachedResults=m}static fromInitialDocuments(e,t,n,s,a){let c=[];return t.forEach(h=>{c.push({type:0,doc:h})}),new r(e,t,Ah.emptySet(t),c,n,s,!0,!1,a)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&zh(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;let t=this.docChanges,n=e.docChanges;if(t.length!==n.length)return!1;for(let s=0;s<t.length;s++)if(t[s].type!==n[s].type||!t[s].doc.isEqual(n[s].doc))return!1;return!0}};var Nm=class{constructor(){this.ea=void 0,this.ta=[]}na(){return this.ta.some(e=>e.ra())}},Vm=class{constructor(){this.queries=Eb(),this.onlineState="Unknown",this.ia=new Set}terminate(){(function(t,n){let s=fe(t),a=s.queries;s.queries=Eb(),a.forEach((c,h)=>{for(let f of h.ta)f.onError(n)})})(this,new ne(H.ABORTED,"Firestore shutting down"))}};function Eb(){return new On(r=>aT(r),zh)}async function LT(r,e){let t=fe(r),n=3,s=e.query,a=t.queries.get(s);a?!a.na()&&e.ra()&&(n=2):(a=new Nm,n=e.ra()?0:1);try{switch(n){case 0:a.ea=await t.onListen(s,!0);break;case 1:a.ea=await t.onListen(s,!1);break;case 2:await t.onFirstRemoteStoreListen(s)}}catch(c){let h=dg(c,`Initialization of query '${Po(e.query)}' failed`);return void e.onError(h)}t.queries.set(s,a),a.ta.push(e),e.sa(t.onlineState),a.ea&&e.oa(a.ea)&&pg(t)}async function MT(r,e){let t=fe(r),n=e.query,s=3,a=t.queries.get(n);if(a){let c=a.ta.indexOf(e);c>=0&&(a.ta.splice(c,1),a.ta.length===0?s=e.ra()?0:1:!a.na()&&e.ra()&&(s=2))}switch(s){case 0:return t.queries.delete(n),t.onUnlisten(n,!0);case 1:return t.queries.delete(n),t.onUnlisten(n,!1);case 2:return t.onLastRemoteStoreUnlisten(n);default:return}}function iF(r,e){let t=fe(r),n=!1;for(let s of e){let a=s.query,c=t.queries.get(a);if(c){for(let h of c.ta)h.oa(s)&&(n=!0);c.ea=s}}n&&pg(t)}function sF(r,e,t){let n=fe(r),s=n.queries.get(e);if(s)for(let a of s.ta)a.onError(t);n.queries.delete(e)}function pg(r){r.ia.forEach(e=>{e.next()})}var Lm,Ib;(Ib=Lm||(Lm={}))._a="default",Ib.Cache="cache";var Rh=class{constructor(e,t,n){this.query=e,this.aa=t,this.ua=!1,this.ca=null,this.onlineState="Unknown",this.options=n||{}}oa(e){if(!this.options.includeMetadataChanges){let n=[];for(let s of e.docChanges)s.type!==3&&n.push(s);e=new Ho(e.query,e.docs,e.oldDocs,n,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.ua?this.la(e)&&(this.aa.next(e),t=!0):this.ha(e,this.onlineState)&&(this.Pa(e),t=!0),this.ca=e,t}onError(e){this.aa.error(e)}sa(e){this.onlineState=e;let t=!1;return this.ca&&!this.ua&&this.ha(this.ca,e)&&(this.Pa(this.ca),t=!0),t}ha(e,t){if(!e.fromCache||!this.ra())return!0;let n=t!=="Offline";return(!this.options.Ta||!n)&&(!e.docs.isEmpty()||e.hasCachedResults||t==="Offline")}la(e){if(e.docChanges.length>0)return!0;let t=this.ca&&this.ca.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&this.options.includeMetadataChanges===!0}Pa(e){e=Ho.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.ua=!0,this.aa.next(e)}ra(){return this.options.source!==Lm.Cache}};var Ph=class{constructor(e){this.key=e}},Ch=class{constructor(e){this.key=e}},Mm=class{constructor(e,t){this.query=e,this.fa=t,this.ga=null,this.hasCachedResults=!1,this.current=!1,this.pa=xe(),this.mutatedKeys=xe(),this.ya=uT(e),this.wa=new Ah(this.ya)}get Sa(){return this.fa}ba(e,t){let n=t?t.Da:new Sh,s=t?t.wa:this.wa,a=t?t.mutatedKeys:this.mutatedKeys,c=s,h=!1,f=this.query.limitType==="F"&&s.size===this.query.limit?s.last():null,m=this.query.limitType==="L"&&s.size===this.query.limit?s.first():null;if(e.inorderTraversal((_,E)=>{let I=s.get(_),k=Gh(this.query,E)?E:null,B=!!I&&this.mutatedKeys.has(I.key),G=!!k&&(k.hasLocalMutations||this.mutatedKeys.has(k.key)&&k.hasCommittedMutations),j=!1;I&&k?I.data.isEqual(k.data)?B!==G&&(n.track({type:3,doc:k}),j=!0):this.va(I,k)||(n.track({type:2,doc:k}),j=!0,(f&&this.ya(k,f)>0||m&&this.ya(k,m)<0)&&(h=!0)):!I&&k?(n.track({type:0,doc:k}),j=!0):I&&!k&&(n.track({type:1,doc:I}),j=!0,(f||m)&&(h=!0)),j&&(k?(c=c.add(k),a=G?a.add(_):a.delete(_)):(c=c.delete(_),a=a.delete(_)))}),this.query.limit!==null)for(;c.size>this.query.limit;){let _=this.query.limitType==="F"?c.last():c.first();c=c.delete(_.key),a=a.delete(_.key),n.track({type:1,doc:_})}return{wa:c,Da:n,ls:h,mutatedKeys:a}}va(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,n,s){let a=this.wa;this.wa=e.wa,this.mutatedKeys=e.mutatedKeys;let c=e.Da.X_();c.sort((_,E)=>function(k,B){let G=j=>{switch(j){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return ue()}};return G(k)-G(B)}(_.type,E.type)||this.ya(_.doc,E.doc)),this.Ca(n),s=s!=null&&s;let h=t&&!s?this.Fa():[],f=this.pa.size===0&&this.current&&!s?1:0,m=f!==this.ga;return this.ga=f,c.length!==0||m?{snapshot:new Ho(this.query,e.wa,a,c,e.mutatedKeys,f===0,m,!1,!!n&&n.resumeToken.approximateByteSize()>0),Ma:h}:{Ma:h}}sa(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({wa:this.wa,Da:new Sh,mutatedKeys:this.mutatedKeys,ls:!1},!1)):{Ma:[]}}xa(e){return!this.fa.has(e)&&!!this.wa.has(e)&&!this.wa.get(e).hasLocalMutations}Ca(e){e&&(e.addedDocuments.forEach(t=>this.fa=this.fa.add(t)),e.modifiedDocuments.forEach(t=>{}),e.removedDocuments.forEach(t=>this.fa=this.fa.delete(t)),this.current=e.current)}Fa(){if(!this.current)return[];let e=this.pa;this.pa=xe(),this.wa.forEach(n=>{this.xa(n.key)&&(this.pa=this.pa.add(n.key))});let t=[];return e.forEach(n=>{this.pa.has(n)||t.push(new Ch(n))}),this.pa.forEach(n=>{e.has(n)||t.push(new Ph(n))}),t}Oa(e){this.fa=e.gs,this.pa=xe();let t=this.ba(e.documents);return this.applyChanges(t,!0)}Na(){return Ho.fromInitialDocuments(this.query,this.wa,this.mutatedKeys,this.ga===0,this.hasCachedResults)}},mg="SyncEngine",Fm=class{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}},Um=class{constructor(e){this.key=e,this.Ba=!1}},Bm=class{constructor(e,t,n,s,a,c){this.localStore=e,this.remoteStore=t,this.eventManager=n,this.sharedClientState=s,this.currentUser=a,this.maxConcurrentLimboResolutions=c,this.La={},this.ka=new On(h=>aT(h),zh),this.qa=new Map,this.Qa=new Set,this.$a=new Ye(ce.comparator),this.Ka=new Map,this.Ua=new Tu,this.Wa={},this.Ga=new Map,this.za=bu.Un(),this.onlineState="Unknown",this.ja=void 0}get isPrimaryClient(){return this.ja===!0}};async function oF(r,e,t=!0){let n=qT(r),s,a=n.ka.get(e);return a?(n.sharedClientState.addLocalQueryTarget(a.targetId),s=a.view.Na()):s=await FT(n,e,t,!0),s}async function aF(r,e){let t=qT(r);await FT(t,e,!0,!1)}async function FT(r,e,t,n){let s=await zM(r.localStore,Wr(e)),a=s.targetId,c=r.sharedClientState.addLocalQueryTarget(a,t),h;return n&&(h=await uF(r,e,a,c==="current",s.resumeToken)),r.isPrimaryClient&&t&&CT(r.remoteStore,s),h}async function uF(r,e,t,n,s){r.Ha=(E,I,k)=>async function(G,j,J,ee){let re=j.view.ba(J);re.ls&&(re=await vb(G.localStore,j.query,!1).then(({documents:C})=>j.view.ba(C,re)));let le=ee&&ee.targetChanges.get(j.targetId),de=ee&&ee.targetMismatches.get(j.targetId)!=null,ie=j.view.applyChanges(re,G.isPrimaryClient,le,de);return Ab(G,j.targetId,ie.Ma),ie.snapshot}(r,E,I,k);let a=await vb(r.localStore,e,!0),c=new Mm(e,a.gs),h=c.ba(a.documents),f=vu.createSynthesizedTargetChangeForCurrentChange(t,n&&r.onlineState!=="Offline",s),m=c.applyChanges(h,r.isPrimaryClient,f);Ab(r,t,m.Ma);let _=new Fm(e,t,c);return r.ka.set(e,_),r.qa.has(t)?r.qa.get(t).push(e):r.qa.set(t,[e]),m.snapshot}async function cF(r,e,t){let n=fe(r),s=n.ka.get(e),a=n.qa.get(s.targetId);if(a.length>1)return n.qa.set(s.targetId,a.filter(c=>!zh(c,e))),void n.ka.delete(e);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(s.targetId),n.sharedClientState.isActiveQueryTarget(s.targetId)||await wm(n.localStore,s.targetId,!1).then(()=>{n.sharedClientState.clearQueryState(s.targetId),t&&cg(n.remoteStore,s.targetId),jm(n,s.targetId)}).catch(Xo)):(jm(n,s.targetId),await wm(n.localStore,s.targetId,!0))}async function lF(r,e){let t=fe(r),n=t.ka.get(e),s=t.qa.get(n.targetId);t.isPrimaryClient&&s.length===1&&(t.sharedClientState.removeLocalQueryTarget(n.targetId),cg(t.remoteStore,n.targetId))}async function hF(r,e,t){let n=yF(r);try{let s=await function(c,h){let f=fe(c),m=wt.now(),_=h.reduce((k,B)=>k.add(B.key),xe()),E,I;return f.persistence.runTransaction("Locally write mutations","readwrite",k=>{let B=kn(),G=xe();return f.ds.getEntries(k,_).next(j=>{B=j,B.forEach((J,ee)=>{ee.isValidDocument()||(G=G.add(J))})}).next(()=>f.localDocuments.getOverlayedDocuments(k,B)).next(j=>{E=j;let J=[];for(let ee of h){let re=mM(ee,E.get(ee.key).overlayedDocument);re!=null&&J.push(new Xr(ee.key,re,tT(re.value.mapValue),_i.exists(!0)))}return f.mutationQueue.addMutationBatch(k,m,J,h)}).next(j=>{I=j;let J=j.applyToLocalDocumentSet(E,G);return f.documentOverlayCache.saveOverlays(k,j.batchId,J)})}).then(()=>({batchId:I.batchId,changes:lT(E)}))}(n.localStore,e);n.sharedClientState.addPendingMutation(s.batchId),function(c,h,f){let m=c.Wa[c.currentUser.toKey()];m||(m=new Ye(Re)),m=m.insert(h,f),c.Wa[c.currentUser.toKey()]=m}(n,s.batchId,t),await Du(n,s.changes),await Hh(n.remoteStore)}catch(s){let a=dg(s,"Failed to persist write");t.reject(a)}}async function UT(r,e){let t=fe(r);try{let n=await jM(t.localStore,e);e.targetChanges.forEach((s,a)=>{let c=t.Ka.get(a);c&&(Le(s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size<=1),s.addedDocuments.size>0?c.Ba=!0:s.modifiedDocuments.size>0?Le(c.Ba):s.removedDocuments.size>0&&(Le(c.Ba),c.Ba=!1))}),await Du(t,n,e)}catch(n){await Xo(n)}}function xb(r,e,t){let n=fe(r);if(n.isPrimaryClient&&t===0||!n.isPrimaryClient&&t===1){let s=[];n.ka.forEach((a,c)=>{let h=c.view.sa(e);h.snapshot&&s.push(h.snapshot)}),function(c,h){let f=fe(c);f.onlineState=h;let m=!1;f.queries.forEach((_,E)=>{for(let I of E.ta)I.sa(h)&&(m=!0)}),m&&pg(f)}(n.eventManager,e),s.length&&n.La.p_(s),n.onlineState=e,n.isPrimaryClient&&n.sharedClientState.setOnlineState(e)}}async function fF(r,e,t){let n=fe(r);n.sharedClientState.updateQueryState(e,"rejected",t);let s=n.Ka.get(e),a=s&&s.key;if(a){let c=new Ye(ce.comparator);c=c.insert(a,Sr.newNoDocument(a,me.min()));let h=xe().add(a),f=new dh(me.min(),new Map,new Ye(Re),c,h);await UT(n,f),n.$a=n.$a.remove(a),n.Ka.delete(e),gg(n)}else await wm(n.localStore,e,!1).then(()=>jm(n,e,t)).catch(Xo)}async function dF(r,e){let t=fe(r),n=e.batch.batchId;try{let s=await BM(t.localStore,e);jT(t,n,null),BT(t,n),t.sharedClientState.updateMutationState(n,"acknowledged"),await Du(t,s)}catch(s){await Xo(s)}}async function pF(r,e,t){let n=fe(r);try{let s=await function(c,h){let f=fe(c);return f.persistence.runTransaction("Reject batch","readwrite-primary",m=>{let _;return f.mutationQueue.lookupMutationBatch(m,h).next(E=>(Le(E!==null),_=E.keys(),f.mutationQueue.removeMutationBatch(m,E))).next(()=>f.mutationQueue.performConsistencyCheck(m)).next(()=>f.documentOverlayCache.removeOverlaysForBatchId(m,_,h)).next(()=>f.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(m,_)).next(()=>f.localDocuments.getDocuments(m,_))})}(n.localStore,e);jT(n,e,t),BT(n,e),n.sharedClientState.updateMutationState(e,"rejected",t),await Du(n,s)}catch(s){await Xo(s)}}function BT(r,e){(r.Ga.get(e)||[]).forEach(t=>{t.resolve()}),r.Ga.delete(e)}function jT(r,e,t){let n=fe(r),s=n.Wa[n.currentUser.toKey()];if(s){let a=s.get(e);a&&(t?a.reject(t):a.resolve(),s=s.remove(e)),n.Wa[n.currentUser.toKey()]=s}}function jm(r,e,t=null){r.sharedClientState.removeLocalQueryTarget(e);for(let n of r.qa.get(e))r.ka.delete(n),t&&r.La.Ja(n,t);r.qa.delete(e),r.isPrimaryClient&&r.Ua.br(e).forEach(n=>{r.Ua.containsKey(n)||$T(r,n)})}function $T(r,e){r.Qa.delete(e.path.canonicalString());let t=r.$a.get(e);t!==null&&(cg(r.remoteStore,t),r.$a=r.$a.remove(e),r.Ka.delete(t),gg(r))}function Ab(r,e,t){for(let n of t)n instanceof Ph?(r.Ua.addReference(n.key,e),mF(r,n)):n instanceof Ch?(X(mg,"Document no longer in limbo: "+n.key),r.Ua.removeReference(n.key,e),r.Ua.containsKey(n.key)||$T(r,n.key)):ue()}function mF(r,e){let t=e.key,n=t.path.canonicalString();r.$a.get(t)||r.Qa.has(n)||(X(mg,"New document in limbo: "+t),r.Qa.add(n),gg(r))}function gg(r){for(;r.Qa.size>0&&r.$a.size<r.maxConcurrentLimboResolutions;){let e=r.Qa.values().next().value;r.Qa.delete(e);let t=new ce(ot.fromString(e)),n=r.za.next();r.Ka.set(n,new Um(t)),r.$a=r.$a.insert(t,n),CT(r.remoteStore,new wu(Wr(qh(t.path)),n,"TargetPurposeLimboResolution",Mo.ae))}}async function Du(r,e,t){let n=fe(r),s=[],a=[],c=[];n.ka.isEmpty()||(n.ka.forEach((h,f)=>{c.push(n.Ha(f,e,t).then(m=>{var _;if((m||t)&&n.isPrimaryClient){let E=m?!m.fromCache:(_=t==null?void 0:t.targetChanges.get(f.targetId))===null||_===void 0?void 0:_.current;n.sharedClientState.updateQueryState(f.targetId,E?"current":"not-current")}if(m){s.push(m);let E=gm.Yi(f.targetId,m);a.push(E)}}))}),await Promise.all(c),n.La.p_(s),await async function(f,m){let _=fe(f);try{await _.persistence.runTransaction("notifyLocalViewChanges","readwrite",E=>W.forEach(m,I=>W.forEach(I.Hi,k=>_.persistence.referenceDelegate.addReference(E,I.targetId,k)).next(()=>W.forEach(I.Ji,k=>_.persistence.referenceDelegate.removeReference(E,I.targetId,k)))))}catch(E){if(!Zo(E))throw E;X(ug,"Failed to update sequence numbers: "+E)}for(let E of m){let I=E.targetId;if(!E.fromCache){let k=_.Ts.get(I),B=k.snapshotVersion,G=k.withLastLimboFreeSnapshotVersion(B);_.Ts=_.Ts.insert(I,G)}}}(n.localStore,a))}async function gF(r,e){let t=fe(r);if(!t.currentUser.isEqual(e)){X(mg,"User change. New user:",e.toKey());let n=await RT(t.localStore,e);t.currentUser=e,function(a,c){a.Ga.forEach(h=>{h.forEach(f=>{f.reject(new ne(H.CANCELLED,c))})}),a.Ga.clear()}(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedClientState.handleUserChange(e,n.removedBatchIds,n.addedBatchIds),await Du(t,n.Rs)}}function _F(r,e){let t=fe(r),n=t.Ka.get(e);if(n&&n.Ba)return xe().add(n.key);{let s=xe(),a=t.qa.get(e);if(!a)return s;for(let c of a){let h=t.ka.get(c);s=s.unionWith(h.view.Sa)}return s}}function qT(r){let e=fe(r);return e.remoteStore.remoteSyncer.applyRemoteEvent=UT.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=_F.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=fF.bind(null,e),e.La.p_=iF.bind(null,e.eventManager),e.La.Ja=sF.bind(null,e.eventManager),e}function yF(r){let e=fe(r);return e.remoteStore.remoteSyncer.applySuccessfulWrite=dF.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=pF.bind(null,e),e}var Qo=class{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=Kh(e.databaseInfo.databaseId),this.sharedClientState=this.Za(e),this.persistence=this.Xa(e),await this.persistence.start(),this.localStore=this.eu(e),this.gcScheduler=this.tu(e,this.localStore),this.indexBackfillerScheduler=this.nu(e,this.localStore)}tu(e,t){return null}nu(e,t){return null}eu(e){return UM(this.persistence,new ym,e.initialUser,this.serializer)}Xa(e){return new vh(mm.ri,this.serializer)}Za(e){return new bm}async terminate(){var e,t;(e=this.gcScheduler)===null||e===void 0||e.stop(),(t=this.indexBackfillerScheduler)===null||t===void 0||t.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}};Qo.provider={build:()=>new Qo};var $m=class extends Qo{constructor(e){super(),this.cacheSizeBytes=e}tu(e,t){Le(this.persistence.referenceDelegate instanceof wh);let n=this.persistence.referenceDelegate.garbageCollector;return new rm(n,e.asyncQueue,t)}Xa(e){let t=this.cacheSizeBytes!==void 0?lr.withCacheSize(this.cacheSizeBytes):lr.DEFAULT;return new vh(n=>wh.ri(n,t),this.serializer)}};var Eu=class{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=n=>xb(this.syncEngine,n,1),this.remoteStore.remoteSyncer.handleCredentialChange=gF.bind(null,this.syncEngine),await nF(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return function(){return new Vm}()}createDatastore(e){let t=Kh(e.databaseInfo.databaseId),n=function(a){return new Am(a)}(e.databaseInfo);return function(a,c,h,f){return new Cm(a,c,h,f)}(e.authCredentials,e.appCheckCredentials,n,t)}createRemoteStore(e){return function(n,s,a,c,h){return new Om(n,s,a,c,h)}(this.localStore,this.datastore,e.asyncQueue,t=>xb(this.syncEngine,t,0),function(){return Th.D()?new Th:new Tm}())}createSyncEngine(e,t){return function(s,a,c,h,f,m,_){let E=new Bm(s,a,c,h,f,m);return _&&(E.ja=!0),E}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){var e,t;await async function(s){let a=fe(s);X(ps,"RemoteStore shutting down."),a.W_.add(5),await Cu(a),a.z_.shutdown(),a.j_.set("Unknown")}(this.remoteStore),(e=this.datastore)===null||e===void 0||e.terminate(),(t=this.eventManager)===null||t===void 0||t.terminate()}};Eu.provider={build:()=>new Eu};var Dh=class{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.iu(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.iu(this.observer.error,e):Pn("Uncaught Error in snapshot listener:",e.toString()))}su(){this.muted=!0}iu(e,t){setTimeout(()=>{this.muted||e(t)},0)}};var wi="FirestoreClient",qm=class{constructor(e,t,n,s,a){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this.databaseInfo=s,this.user=_t.UNAUTHENTICATED,this.clientId=sh.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=a,this.authCredentials.start(n,async c=>{X(wi,"Received user=",c.uid),await this.authCredentialListener(c),this.user=c}),this.appCheckCredentials.start(n,c=>(X(wi,"Received new app check token=",c),this.appCheckCredentialListener(c,this.user)))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();let e=new Gr;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){let n=dg(t,"Failed to shutdown persistence");e.reject(n)}}),e.promise}};async function gp(r,e){r.asyncQueue.verifyOperationInProgress(),X(wi,"Initializing OfflineComponentProvider");let t=r.configuration;await e.initialize(t);let n=t.initialUser;r.setCredentialChangeListener(async s=>{n.isEqual(s)||(await RT(e.localStore,s),n=s)}),e.persistence.setDatabaseDeletedListener(()=>r.terminate()),r._offlineComponents=e}async function Sb(r,e){r.asyncQueue.verifyOperationInProgress();let t=await vF(r);X(wi,"Initializing OnlineComponentProvider"),await e.initialize(t,r.configuration),r.setCredentialChangeListener(n=>Tb(e.remoteStore,n)),r.setAppCheckTokenChangeListener((n,s)=>Tb(e.remoteStore,s)),r._onlineComponents=e}async function vF(r){if(!r._offlineComponents)if(r._uninitializedComponentsProvider){X(wi,"Using user provided OfflineComponentProvider");try{await gp(r,r._uninitializedComponentsProvider._offline)}catch(e){let t=e;if(!function(s){return s.name==="FirebaseError"?s.code===H.FAILED_PRECONDITION||s.code===H.UNIMPLEMENTED:!(typeof DOMException!="undefined"&&s instanceof DOMException)||s.code===22||s.code===20||s.code===11}(t))throw t;Vo("Error using user provided cache. Falling back to memory cache: "+t),await gp(r,new Qo)}}else X(wi,"Using default OfflineComponentProvider"),await gp(r,new $m(void 0));return r._offlineComponents}async function zT(r){return r._onlineComponents||(r._uninitializedComponentsProvider?(X(wi,"Using user provided OnlineComponentProvider"),await Sb(r,r._uninitializedComponentsProvider._online)):(X(wi,"Using default OnlineComponentProvider"),await Sb(r,new Eu))),r._onlineComponents}function wF(r){return zT(r).then(e=>e.syncEngine)}async function zm(r){let e=await zT(r),t=e.eventManager;return t.onListen=oF.bind(null,e.syncEngine),t.onUnlisten=cF.bind(null,e.syncEngine),t.onFirstRemoteStoreListen=aF.bind(null,e.syncEngine),t.onLastRemoteStoreUnlisten=lF.bind(null,e.syncEngine),t}function bF(r,e,t={}){let n=new Gr;return r.asyncQueue.enqueueAndForget(async()=>function(a,c,h,f,m){let _=new Dh({next:I=>{_.su(),c.enqueueAndForget(()=>MT(a,E));let k=I.docs.has(h);!k&&I.fromCache?m.reject(new ne(H.UNAVAILABLE,"Failed to get document because the client is offline.")):k&&I.fromCache&&f&&f.source==="server"?m.reject(new ne(H.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):m.resolve(I)},error:I=>m.reject(I)}),E=new Rh(qh(h.path),_,{includeMetadataChanges:!0,Ta:!0});return LT(a,E)}(await zm(r),r.asyncQueue,e,t,n)),n.promise}function GT(r){let e={};return r.timeoutSeconds!==void 0&&(e.timeoutSeconds=r.timeoutSeconds),e}var Rb=new Map;function TF(r,e,t){if(!t)throw new ne(H.INVALID_ARGUMENT,`Function ${r}() cannot be called with an empty ${e}.`)}function EF(r,e,t,n){if(e===!0&&n===!0)throw new ne(H.INVALID_ARGUMENT,`${r} and ${t} cannot be used together.`)}function Pb(r){if(!ce.isDocumentKey(r))throw new ne(H.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${r} has ${r.length}.`)}function _g(r){if(r===void 0)return"undefined";if(r===null)return"null";if(typeof r=="string")return r.length>20&&(r=`${r.substring(0,20)}...`),JSON.stringify(r);if(typeof r=="number"||typeof r=="boolean")return""+r;if(typeof r=="object"){if(r instanceof Array)return"an array";{let e=function(n){return n.constructor?n.constructor.name:null}(r);return e?`a custom ${e} object`:"an object"}}return typeof r=="function"?"a function":ue()}function Qr(r,e){if("_delegate"in r&&(r=r._delegate),!(r instanceof e)){if(e.name===r.constructor.name)throw new ne(H.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{let t=_g(r);throw new ne(H.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${t}`)}}return r}var KT="firestore.googleapis.com",Cb=!0,Oh=class{constructor(e){var t,n;if(e.host===void 0){if(e.ssl!==void 0)throw new ne(H.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=KT,this.ssl=Cb}else this.host=e.host,this.ssl=(t=e.ssl)!==null&&t!==void 0?t:Cb;if(this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=ST;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<LM)throw new ne(H.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}EF("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=GT((n=e.experimentalLongPollingOptions)!==null&&n!==void 0?n:{}),function(a){if(a.timeoutSeconds!==void 0){if(isNaN(a.timeoutSeconds))throw new ne(H.INVALID_ARGUMENT,`invalid long polling timeout: ${a.timeoutSeconds} (must not be NaN)`);if(a.timeoutSeconds<5)throw new ne(H.INVALID_ARGUMENT,`invalid long polling timeout: ${a.timeoutSeconds} (minimum allowed value is 5)`);if(a.timeoutSeconds>30)throw new ne(H.INVALID_ARGUMENT,`invalid long polling timeout: ${a.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&function(n,s){return n.timeoutSeconds===s.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}},Iu=class{constructor(e,t,n,s){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=n,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Oh({}),this._settingsFrozen=!1,this._terminateTask="notTerminated"}get app(){if(!this._app)throw new ne(H.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!=="notTerminated"}_setSettings(e){if(this._settingsFrozen)throw new ne(H.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new Oh(e),e.credentials!==void 0&&(this._authCredentials=function(n){if(!n)return new _p;switch(n.type){case"firstParty":return new bp(n.sessionIndex||"0",n.iamToken||null,n.authTokenFactory||null);case"provider":return n.client;default:throw new ne(H.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}_getSettings(){return this._settings}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(t){let n=Rb.get(t);n&&(X("ComponentProvider","Removing Datastore"),Rb.delete(t),n.terminate())}(this),Promise.resolve()}};function IF(r,e,t,n={}){var s;let a=(r=Qr(r,Iu))._getSettings(),c=`${e}:${t}`;if(a.host!==KT&&a.host!==c&&Vo("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used."),r._setSettings(Object.assign(Object.assign({},a),{host:c,ssl:!1})),n.mockUserToken){let h,f;if(typeof n.mockUserToken=="string")h=n.mockUserToken,f=_t.MOCK_USER;else{h=T0(n.mockUserToken,(s=r._app)===null||s===void 0?void 0:s.options.projectId);let m=n.mockUserToken.sub||n.mockUserToken.user_id;if(!m)throw new ne(H.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");f=new _t(m)}r._authCredentials=new yp(new nh(h,f))}}var kh=class r{constructor(e,t,n){this.converter=t,this._query=n,this.type="query",this.firestore=e}withConverter(e){return new r(this.firestore,e,this._query)}},zt=class r{constructor(e,t,n){this.converter=t,this._key=n,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new xu(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new r(this.firestore,e,this._key)}},xu=class r extends kh{constructor(e,t,n){super(e,t,qh(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){let e=this._path.popLast();return e.isEmpty()?null:new zt(this.firestore,null,new ce(e))}withConverter(e){return new r(this.firestore,e,this._path)}};function Ou(r,e,...t){if(r=In(r),arguments.length===1&&(e=sh.newId()),TF("doc","path",e),r instanceof Iu){let n=ot.fromString(e,...t);return Pb(n),new zt(r,null,new ce(n))}{if(!(r instanceof zt||r instanceof xu))throw new ne(H.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let n=r._path.child(ot.fromString(e,...t));return Pb(n),new zt(r.firestore,r instanceof xu?r.converter:null,new ce(n))}}var Db="AsyncQueue",Nh=class{constructor(e=Promise.resolve()){this.Vu=[],this.mu=!1,this.fu=[],this.gu=null,this.pu=!1,this.yu=!1,this.wu=[],this.a_=new Eh(this,"async_queue_retry"),this.Su=()=>{let n=mp();n&&X(Db,"Visibility state changed to "+n.visibilityState),this.a_.t_()},this.bu=e;let t=mp();t&&typeof t.addEventListener=="function"&&t.addEventListener("visibilitychange",this.Su)}get isShuttingDown(){return this.mu}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.Du(),this.vu(e)}enterRestrictedMode(e){if(!this.mu){this.mu=!0,this.yu=e||!1;let t=mp();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this.Su)}}enqueue(e){if(this.Du(),this.mu)return new Promise(()=>{});let t=new Gr;return this.vu(()=>this.mu&&this.yu?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Vu.push(e),this.Cu()))}async Cu(){if(this.Vu.length!==0){try{await this.Vu[0](),this.Vu.shift(),this.a_.reset()}catch(e){if(!Zo(e))throw e;X(Db,"Operation failed with retryable error: "+e)}this.Vu.length>0&&this.a_.Xo(()=>this.Cu())}}vu(e){let t=this.bu.then(()=>(this.pu=!0,e().catch(n=>{this.gu=n,this.pu=!1;let s=function(c){let h=c.message||"";return c.stack&&(h=c.stack.includes(c.message)?c.stack:c.message+`
41
+ `+c.stack),h}(n);throw Pn("INTERNAL UNHANDLED ERROR: ",s),n}).then(n=>(this.pu=!1,n))));return this.bu=t,t}enqueueAfterDelay(e,t,n){this.Du(),this.wu.indexOf(e)>-1&&(t=0);let s=km.createAndSchedule(this,e,t,n,a=>this.Fu(a));return this.fu.push(s),s}Du(){this.gu&&ue()}verifyOperationInProgress(){}async Mu(){let e;do e=this.bu,await e;while(e!==this.bu)}xu(e){for(let t of this.fu)if(t.timerId===e)return!0;return!1}Ou(e){return this.Mu().then(()=>{this.fu.sort((t,n)=>t.targetTimeMs-n.targetTimeMs);for(let t of this.fu)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.Mu()})}Nu(e){this.wu.push(e)}Fu(e){let t=this.fu.indexOf(e);this.fu.splice(t,1)}};function Ob(r){return function(t,n){if(typeof t!="object"||t===null)return!1;let s=t;for(let a of n)if(a in s&&typeof s[a]=="function")return!0;return!1}(r,["next","error","complete"])}var bi=class extends Iu{constructor(e,t,n,s){super(e,t,n,s),this.type="firestore",this._queue=new Nh,this._persistenceKey=(s==null?void 0:s.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new Nh(e),this._firestoreClient=void 0,await e}}};function WT(r,e){let t=typeof r=="object"?r:j0(),n=typeof r=="string"?r:e||ch,s=F0(t,"firestore").getImmediate({identifier:n});if(!s._initialized){let a=b0("firestore");a&&IF(s,...a)}return s}function yg(r){if(r._terminated)throw new ne(H.FAILED_PRECONDITION,"The client has already been terminated.");return r._firestoreClient||xF(r),r._firestoreClient}function xF(r){var e,t,n;let s=r._freezeSettings(),a=function(h,f,m,_){return new xp(h,f,m,_.host,_.ssl,_.experimentalForceLongPolling,_.experimentalAutoDetectLongPolling,GT(_.experimentalLongPollingOptions),_.useFetchStreams)}(r._databaseId,((e=r._app)===null||e===void 0?void 0:e.options.appId)||"",r._persistenceKey,s);r._componentsProvider||!((t=s.localCache)===null||t===void 0)&&t._offlineComponentProvider&&(!((n=s.localCache)===null||n===void 0)&&n._onlineComponentProvider)&&(r._componentsProvider={_offline:s.localCache._offlineComponentProvider,_online:s.localCache._onlineComponentProvider}),r._firestoreClient=new qm(r._authCredentials,r._appCheckCredentials,r._queue,a,r._componentsProvider&&function(h){let f=h==null?void 0:h._online.build();return{_offline:h==null?void 0:h._offline.build(f),_online:f}}(r._componentsProvider))}var Au=class r{constructor(e){this._byteString=e}static fromBase64String(e){try{return new r(Rt.fromBase64String(e))}catch(t){throw new ne(H.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new r(Rt.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}};var Jo=class{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new ne(H.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new tr(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}};var Su=class{constructor(e){this._methodName=e}};var Ru=class{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new ne(H.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new ne(H.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(e){return Re(this._lat,e._lat)||Re(this._long,e._long)}};var Pu=class{constructor(e){this._values=(e||[]).map(t=>t)}toArray(){return this._values.map(e=>e)}isEqual(e){return function(n,s){if(n.length!==s.length)return!1;for(let a=0;a<n.length;++a)if(n[a]!==s[a])return!1;return!0}(this._values,e._values)}};var AF=/^__.*__$/,Gm=class{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return this.fieldMask!==null?new Xr(e,this.data,this.fieldMask,t,this.fieldTransforms):new ds(e,this.data,t,this.fieldTransforms)}},Vh=class{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new Xr(e,this.data,this.fieldMask,t,this.fieldTransforms)}};function HT(r){switch(r){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw ue()}}var Km=class r{constructor(e,t,n,s,a,c){this.settings=e,this.databaseId=t,this.serializer=n,this.ignoreUndefinedProperties=s,a===void 0&&this.Bu(),this.fieldTransforms=a||[],this.fieldMask=c||[]}get path(){return this.settings.path}get Lu(){return this.settings.Lu}ku(e){return new r(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}qu(e){var t;let n=(t=this.path)===null||t===void 0?void 0:t.child(e),s=this.ku({path:n,Qu:!1});return s.$u(e),s}Ku(e){var t;let n=(t=this.path)===null||t===void 0?void 0:t.child(e),s=this.ku({path:n,Qu:!1});return s.Bu(),s}Uu(e){return this.ku({path:void 0,Qu:!0})}Wu(e){return Mh(e,this.settings.methodName,this.settings.Gu||!1,this.path,this.settings.zu)}contains(e){return this.fieldMask.find(t=>e.isPrefixOf(t))!==void 0||this.fieldTransforms.find(t=>e.isPrefixOf(t.field))!==void 0}Bu(){if(this.path)for(let e=0;e<this.path.length;e++)this.$u(this.path.get(e))}$u(e){if(e.length===0)throw this.Wu("Document fields must not be empty");if(HT(this.Lu)&&AF.test(e))throw this.Wu('Document fields cannot begin and end with "__"')}},Wm=class{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=n||Kh(e)}ju(e,t,n,s=!1){return new Km({Lu:e,methodName:t,zu:n,path:tr.emptyPath(),Qu:!1,Gu:s},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}};function QT(r){let e=r._freezeSettings(),t=Kh(r._databaseId);return new Wm(r._databaseId,!!e.ignoreUndefinedProperties,t)}function SF(r,e,t,n,s,a={}){let c=r.ju(a.merge||a.mergeFields?2:0,e,t,s);vg("Data must be an object, but it was:",c,n);let h=JT(n,c),f,m;if(a.merge)f=new hr(c.fieldMask),m=c.fieldTransforms;else if(a.mergeFields){let _=[];for(let E of a.mergeFields){let I=Hm(e,E,t);if(!c.contains(I))throw new ne(H.INVALID_ARGUMENT,`Field '${I}' is specified in your field mask but missing from your input data.`);XT(_,I)||_.push(I)}f=new hr(_),m=c.fieldTransforms.filter(E=>f.covers(E.field))}else f=null,m=c.fieldTransforms;return new Gm(new er(h),f,m)}var Lh=class r extends Su{_toFieldTransform(e){if(e.Lu!==2)throw e.Lu===1?e.Wu(`${this._methodName}() can only appear at the top level of your update data`):e.Wu(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof r}};function RF(r,e,t,n){let s=r.ju(1,e,t);vg("Data must be an object, but it was:",s,n);let a=[],c=er.empty();Ti(n,(f,m)=>{let _=wg(e,f,t);m=In(m);let E=s.Ku(_);if(m instanceof Lh)a.push(_);else{let I=Qh(m,E);I!=null&&(a.push(_),c.set(_,I))}});let h=new hr(a);return new Vh(c,h,s.fieldTransforms)}function PF(r,e,t,n,s,a){let c=r.ju(1,e,t),h=[Hm(e,n,t)],f=[s];if(a.length%2!=0)throw new ne(H.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let I=0;I<a.length;I+=2)h.push(Hm(e,a[I])),f.push(a[I+1]);let m=[],_=er.empty();for(let I=h.length-1;I>=0;--I)if(!XT(m,h[I])){let k=h[I],B=f[I];B=In(B);let G=c.Ku(k);if(B instanceof Lh)m.push(k);else{let j=Qh(B,G);j!=null&&(m.push(k),_.set(k,j))}}let E=new hr(m);return new Vh(_,E,c.fieldTransforms)}function Qh(r,e){if(YT(r=In(r)))return vg("Unsupported field value:",e,r),JT(r,e);if(r instanceof Su)return function(n,s){if(!HT(s.Lu))throw s.Wu(`${n._methodName}() can only be used with update() and set()`);if(!s.path)throw s.Wu(`${n._methodName}() is not currently supported inside arrays`);let a=n._toFieldTransform(s);a&&s.fieldTransforms.push(a)}(r,e),null;if(r===void 0&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),r instanceof Array){if(e.settings.Qu&&e.Lu!==4)throw e.Wu("Nested arrays are not supported");return function(n,s){let a=[],c=0;for(let h of n){let f=Qh(h,s.Uu(c));f==null&&(f={nullValue:"NULL_VALUE"}),a.push(f),c++}return{arrayValue:{values:a}}}(r,e)}return function(n,s){if((n=In(n))===null)return{nullValue:"NULL_VALUE"};if(typeof n=="number")return lM(s.serializer,n);if(typeof n=="boolean")return{booleanValue:n};if(typeof n=="string")return{stringValue:n};if(n instanceof Date){let a=wt.fromDate(n);return{timestampValue:_h(s.serializer,a)}}if(n instanceof wt){let a=new wt(n.seconds,1e3*Math.floor(n.nanoseconds/1e3));return{timestampValue:_h(s.serializer,a)}}if(n instanceof Ru)return{geoPointValue:{latitude:n.latitude,longitude:n.longitude}};if(n instanceof Au)return{bytesValue:wT(s.serializer,n._byteString)};if(n instanceof zt){let a=s.databaseId,c=n.firestore._databaseId;if(!c.isEqual(a))throw s.Wu(`Document reference is for database ${c.projectId}/${c.database} but should be for database ${a.projectId}/${a.database}`);return{referenceValue:ag(n.firestore._databaseId||s.databaseId,n._key.path)}}if(n instanceof Pu)return function(c,h){return{mapValue:{fields:{[tg]:{stringValue:rg},[Fo]:{arrayValue:{values:c.toArray().map(m=>{if(typeof m!="number")throw h.Wu("VectorValues must only contain numeric values.");return og(h.serializer,m)})}}}}}}(n,s);throw s.Wu(`Unsupported field value: ${_g(n)}`)}(r,e)}function JT(r,e){let t={};return Wb(r)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):Ti(r,(n,s)=>{let a=Qh(s,e.qu(n));a!=null&&(t[n]=a)}),{mapValue:{fields:t}}}function YT(r){return!(typeof r!="object"||r===null||r instanceof Array||r instanceof Date||r instanceof wt||r instanceof Ru||r instanceof Au||r instanceof zt||r instanceof Su||r instanceof Pu)}function vg(r,e,t){if(!YT(t)||!function(s){return typeof s=="object"&&s!==null&&(Object.getPrototypeOf(s)===Object.prototype||Object.getPrototypeOf(s)===null)}(t)){let n=_g(t);throw n==="an object"?e.Wu(r+" a custom object"):e.Wu(r+" "+n)}}function Hm(r,e,t){if((e=In(e))instanceof Jo)return e._internalPath;if(typeof e=="string")return wg(r,e);throw Mh("Field path arguments must be of type string or ",r,!1,void 0,t)}var CF=new RegExp("[~\\*/\\[\\]]");function wg(r,e,t){if(e.search(CF)>=0)throw Mh(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,r,!1,void 0,t);try{return new Jo(...e.split("."))._internalPath}catch{throw Mh(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,r,!1,void 0,t)}}function Mh(r,e,t,n,s){let a=n&&!n.isEmpty(),c=s!==void 0,h=`Function ${e}() called with invalid data`;t&&(h+=" (via `toFirestore()`)"),h+=". ";let f="";return(a||c)&&(f+=" (found",a&&(f+=` in field ${n}`),c&&(f+=` in document ${s}`),f+=")"),new ne(H.INVALID_ARGUMENT,h+r+f)}function XT(r,e){return r.some(t=>t.isEqual(e))}var Fh=class{constructor(e,t,n,s,a){this._firestore=e,this._userDataWriter=t,this._key=n,this._document=s,this._converter=a}get id(){return this._key.path.lastSegment()}get ref(){return new zt(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){let e=new Qm(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}get(e){if(this._document){let t=this._document.data.field(ZT("DocumentSnapshot.get",e));if(t!==null)return this._userDataWriter.convertValue(t)}}},Qm=class extends Fh{data(){return super.data()}};function ZT(r,e){return typeof e=="string"?wg(r,e):e instanceof Jo?e._internalPath:e._delegate._internalPath}function DF(r){if(r.limitType==="L"&&r.explicitOrderBy.length===0)throw new ne(H.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}var Jm=class{convertValue(e,t="none"){switch(yi(e)){case 0:return null;case 1:return e.booleanValue;case 2:return Ge(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(Dn(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw ue()}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){let n={};return Ti(e,(s,a)=>{n[s]=this.convertValue(a,t)}),n}convertVectorValue(e){var t,n,s;let a=(s=(n=(t=e.fields)===null||t===void 0?void 0:t[Fo].arrayValue)===null||n===void 0?void 0:n.values)===null||s===void 0?void 0:s.map(c=>Ge(c.doubleValue));return new Pu(a)}convertGeoPoint(e){return new Ru(Ge(e.latitude),Ge(e.longitude))}convertArray(e,t){return(e.values||[]).map(n=>this.convertValue(n,t))}convertServerTimestamp(e,t){switch(t){case"previous":let n=$h(e);return n==null?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(_u(e));default:return null}}convertTimestamp(e){let t=Cn(e);return new wt(t.seconds,t.nanos)}convertDocumentKey(e,t){let n=ot.fromString(e);Le(AT(n));let s=new lh(n.get(1),n.get(3)),a=new ce(n.popFirst(5));return s.isEqual(t)||Pn(`Document ${a} contains a document reference within a different database (${s.projectId}/${s.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),a}};function OF(r,e,t){let n;return n=r?t&&(t.merge||t.mergeFields)?r.toFirestore(e,t):r.toFirestore(e):e,n}var us=class{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}},Uh=class extends Fh{constructor(e,t,n,s,a,c){super(e,t,n,s,c),this._firestore=e,this._firestoreImpl=e,this.metadata=a}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){let t=new No(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){let n=this._document.data.field(ZT("DocumentSnapshot.get",e));if(n!==null)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}},No=class extends Uh{data(e={}){return super.data(e)}},Ym=class{constructor(e,t,n,s){this._firestore=e,this._userDataWriter=t,this._snapshot=s,this.metadata=new us(s.hasPendingWrites,s.fromCache),this.query=n}get docs(){let e=[];return this.forEach(t=>e.push(t)),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach(n=>{e.call(t,new No(this._firestore,this._userDataWriter,n.key,n,new us(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){let t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new ne(H.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(s,a){if(s._snapshot.oldDocs.isEmpty()){let c=0;return s._snapshot.docChanges.map(h=>{let f=new No(s._firestore,s._userDataWriter,h.doc.key,h.doc,new us(s._snapshot.mutatedKeys.has(h.doc.key),s._snapshot.fromCache),s.query.converter);return h.doc,{type:"added",doc:f,oldIndex:-1,newIndex:c++}})}{let c=s._snapshot.oldDocs;return s._snapshot.docChanges.filter(h=>a||h.type!==3).map(h=>{let f=new No(s._firestore,s._userDataWriter,h.doc.key,h.doc,new us(s._snapshot.mutatedKeys.has(h.doc.key),s._snapshot.fromCache),s.query.converter),m=-1,_=-1;return h.type!==0&&(m=c.indexOf(h.doc.key),c=c.delete(h.doc.key)),h.type!==1&&(c=c.add(h.doc),_=c.indexOf(h.doc.key)),{type:kF(h.type),doc:f,oldIndex:m,newIndex:_}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}};function kF(r){switch(r){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return ue()}}function Jh(r){r=Qr(r,zt);let e=Qr(r.firestore,bi);return bF(yg(e),r._key).then(t=>nE(e,r,t))}var Bh=class extends Jm{constructor(e){super(),this.firestore=e}convertBytes(e){return new Au(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new zt(this.firestore,null,t)}};function bg(r,e,t){r=Qr(r,zt);let n=Qr(r.firestore,bi),s=OF(r.converter,e,t);return rE(n,[SF(QT(n),"setDoc",r._key,s,r.converter!==null,t).toMutation(r._key,_i.none())])}function eE(r,e,t,...n){r=Qr(r,zt);let s=Qr(r.firestore,bi),a=QT(s),c;return c=typeof(e=In(e))=="string"||e instanceof Jo?PF(a,"updateDoc",r._key,e,t,n):RF(a,"updateDoc",r._key,e),rE(s,[c.toMutation(r._key,_i.exists(!0))])}function tE(r,...e){var t,n,s;r=In(r);let a={includeMetadataChanges:!1,source:"default"},c=0;typeof e[c]!="object"||Ob(e[c])||(a=e[c],c++);let h={includeMetadataChanges:a.includeMetadataChanges,source:a.source};if(Ob(e[c])){let E=e[c];e[c]=(t=E.next)===null||t===void 0?void 0:t.bind(E),e[c+1]=(n=E.error)===null||n===void 0?void 0:n.bind(E),e[c+2]=(s=E.complete)===null||s===void 0?void 0:s.bind(E)}let f,m,_;if(r instanceof zt)m=Qr(r.firestore,bi),_=qh(r._key.path),f={next:E=>{e[c]&&e[c](nE(m,r,E))},error:e[c+1],complete:e[c+2]};else{let E=Qr(r,kh);m=Qr(E.firestore,bi),_=E._query;let I=new Bh(m);f={next:k=>{e[c]&&e[c](new Ym(m,I,E,k))},error:e[c+1],complete:e[c+2]},DF(r._query)}return function(I,k,B,G){let j=new Dh(G),J=new Rh(k,j,B);return I.asyncQueue.enqueueAndForget(async()=>LT(await zm(I),J)),()=>{j.su(),I.asyncQueue.enqueueAndForget(async()=>MT(await zm(I),J))}}(yg(m),_,h,f)}function rE(r,e){return function(n,s){let a=new Gr;return n.asyncQueue.enqueueAndForget(async()=>hF(await wF(n),s,a)),a.promise}(yg(r),e)}function nE(r,e,t){let n=t.docs.get(e._key),s=new Bh(r);return new Uh(r,s,e._key,n,new us(t.hasPendingWrites,t.fromCache),e.converter)}(function(e,t=!0){(function(s){Yo=s})(B0),au(new xn("firestore",(n,{instanceIdentifier:s,options:a})=>{let c=n.getProvider("app").getImmediate(),h=new bi(new vp(n.getProvider("auth-internal")),new Tp(c,n.getProvider("app-check-internal")),function(m,_){if(!Object.prototype.hasOwnProperty.apply(m.options,["projectId"]))throw new ne(H.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new lh(m.options.projectId,_)}(c,s),c);return a=Object.assign({useFetchStreams:t},a),h._setSettings(a),h},"PUBLIC").setMultipleInstances(!0)),gi(K0,W0,e),gi(K0,W0,"esm2017")})();var iE=r=>{let e;return r?e=r:typeof fetch=="undefined"?e=(...t)=>Promise.resolve().then(()=>(Ei(),gs)).then(({default:n})=>n(...t)):e=fetch,(...t)=>e(...t)};var ku=class extends Error{constructor(e,t="FunctionsError",n){super(e),this.name=t,this.context=n}},Yh=class extends ku{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}},Xh=class extends ku{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}},Zh=class extends ku{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}},ef;(function(r){r.Any="any",r.ApNortheast1="ap-northeast-1",r.ApNortheast2="ap-northeast-2",r.ApSouth1="ap-south-1",r.ApSoutheast1="ap-southeast-1",r.ApSoutheast2="ap-southeast-2",r.CaCentral1="ca-central-1",r.EuCentral1="eu-central-1",r.EuWest1="eu-west-1",r.EuWest2="eu-west-2",r.EuWest3="eu-west-3",r.SaEast1="sa-east-1",r.UsEast1="us-east-1",r.UsWest1="us-west-1",r.UsWest2="us-west-2"})(ef||(ef={}));var FF=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})},Nu=class{constructor(e,{headers:t={},customFetch:n,region:s=ef.Any}={}){this.url=e,this.headers=t,this.region=s,this.fetch=iE(n)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,t={}){var n;return FF(this,void 0,void 0,function*(){try{let{headers:s,method:a,body:c}=t,h={},{region:f}=t;f||(f=this.region),f&&f!=="any"&&(h["x-region"]=f);let m;c&&(s&&!Object.prototype.hasOwnProperty.call(s,"Content-Type")||!s)&&(typeof Blob!="undefined"&&c instanceof Blob||c instanceof ArrayBuffer?(h["Content-Type"]="application/octet-stream",m=c):typeof c=="string"?(h["Content-Type"]="text/plain",m=c):typeof FormData!="undefined"&&c instanceof FormData?m=c:(h["Content-Type"]="application/json",m=JSON.stringify(c)));let _=yield this.fetch(`${this.url}/${e}`,{method:a||"POST",headers:Object.assign(Object.assign(Object.assign({},h),this.headers),s),body:m}).catch(B=>{throw new Yh(B)}),E=_.headers.get("x-relay-error");if(E&&E==="true")throw new Xh(_);if(!_.ok)throw new Zh(_);let I=((n=_.headers.get("Content-Type"))!==null&&n!==void 0?n:"text/plain").split(";")[0].trim(),k;return I==="application/json"?k=yield _.json():I==="application/octet-stream"?k=yield _.blob():I==="text/event-stream"?k=_:I==="multipart/form-data"?k=yield _.formData():k=yield _.text(),{data:k,error:null}}catch(s){return{data:null,error:s}}})}};var _E=Dd(gE(),1),{PostgrestClient:yE,PostgrestQueryBuilder:BK,PostgrestFilterBuilder:jK,PostgrestTransformBuilder:$K,PostgrestBuilder:qK,PostgrestError:JF}=_E.default;var vE="2.11.2";var wE={"X-Client-Info":`realtime-js/${vE}`},bE="1.0.0",of=1e4,TE=1e3,_s;(function(r){r[r.connecting=0]="connecting",r[r.open=1]="open",r[r.closing=2]="closing",r[r.closed=3]="closed"})(_s||(_s={}));var Gt;(function(r){r.closed="closed",r.errored="errored",r.joined="joined",r.joining="joining",r.leaving="leaving"})(Gt||(Gt={}));var rr;(function(r){r.close="phx_close",r.error="phx_error",r.join="phx_join",r.reply="phx_reply",r.leave="phx_leave",r.access_token="access_token"})(rr||(rr={}));var sf;(function(r){r.websocket="websocket"})(sf||(sf={}));var Ii;(function(r){r.Connecting="connecting",r.Open="open",r.Closing="closing",r.Closed="closed"})(Ii||(Ii={}));var ju=class{constructor(){this.HEADER_LENGTH=1}decode(e,t){return e.constructor===ArrayBuffer?t(this._binaryDecode(e)):t(typeof e=="string"?JSON.parse(e):{})}_binaryDecode(e){let t=new DataView(e),n=new TextDecoder;return this._decodeBroadcast(e,t,n)}_decodeBroadcast(e,t,n){let s=t.getUint8(1),a=t.getUint8(2),c=this.HEADER_LENGTH+2,h=n.decode(e.slice(c,c+s));c=c+s;let f=n.decode(e.slice(c,c+a));c=c+a;let m=JSON.parse(n.decode(e.slice(c,e.byteLength)));return{ref:null,topic:h,event:f,payload:m}}};var ys=class{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=t}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}};var je;(function(r){r.abstime="abstime",r.bool="bool",r.date="date",r.daterange="daterange",r.float4="float4",r.float8="float8",r.int2="int2",r.int4="int4",r.int4range="int4range",r.int8="int8",r.int8range="int8range",r.json="json",r.jsonb="jsonb",r.money="money",r.numeric="numeric",r.oid="oid",r.reltime="reltime",r.text="text",r.time="time",r.timestamp="timestamp",r.timestamptz="timestamptz",r.timetz="timetz",r.tsrange="tsrange",r.tstzrange="tstzrange"})(je||(je={}));var Lg=(r,e,t={})=>{var n;let s=(n=t.skipTypes)!==null&&n!==void 0?n:[];return Object.keys(e).reduce((a,c)=>(a[c]=YF(c,r,e,s),a),{})},YF=(r,e,t,n)=>{let s=e.find(h=>h.name===r),a=s==null?void 0:s.type,c=t[r];return a&&!n.includes(a)?EE(a,c):Vg(c)},EE=(r,e)=>{if(r.charAt(0)==="_"){let t=r.slice(1,r.length);return tU(e,t)}switch(r){case je.bool:return XF(e);case je.float4:case je.float8:case je.int2:case je.int4:case je.int8:case je.numeric:case je.oid:return ZF(e);case je.json:case je.jsonb:return eU(e);case je.timestamp:return rU(e);case je.abstime:case je.date:case je.daterange:case je.int4range:case je.int8range:case je.money:case je.reltime:case je.text:case je.time:case je.timestamptz:case je.timetz:case je.tsrange:case je.tstzrange:return Vg(e);default:return Vg(e)}},Vg=r=>r,XF=r=>{switch(r){case"t":return!0;case"f":return!1;default:return r}},ZF=r=>{if(typeof r=="string"){let e=parseFloat(r);if(!Number.isNaN(e))return e}return r},eU=r=>{if(typeof r=="string")try{return JSON.parse(r)}catch(e){return console.log(`JSON parse error: ${e}`),r}return r},tU=(r,e)=>{if(typeof r!="string")return r;let t=r.length-1,n=r[t];if(r[0]==="{"&&n==="}"){let a,c=r.slice(1,t);try{a=JSON.parse("["+c+"]")}catch{a=c?c.split(","):[]}return a.map(h=>EE(e,h))}return r},rU=r=>typeof r=="string"?r.replace(" ","T"):r,af=r=>{let e=r;return e=e.replace(/^ws/i,"http"),e=e.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),e.replace(/\/+$/,"")};var vs=class{constructor(e,t,n={},s=of){this.channel=e,this.event=t,this.payload=n,this.timeout=s,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,t){var n;return this._hasReceived(e)&&t((n=this.receivedResp)===null||n===void 0?void 0:n.response),this.recHooks.push({status:e,callback:t}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);let e=t=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=t,this._matchReceive(t)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,t){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:t})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:t}){this.recHooks.filter(n=>n.status===e).forEach(n=>n.callback(t))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}};var Mg;(function(r){r.SYNC="sync",r.JOIN="join",r.LEAVE="leave"})(Mg||(Mg={}));var na=class r{constructor(e,t){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};let n=(t==null?void 0:t.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(n.state,{},s=>{let{onJoin:a,onLeave:c,onSync:h}=this.caller;this.joinRef=this.channel._joinRef(),this.state=r.syncState(this.state,s,a,c),this.pendingDiffs.forEach(f=>{this.state=r.syncDiff(this.state,f,a,c)}),this.pendingDiffs=[],h()}),this.channel._on(n.diff,{},s=>{let{onJoin:a,onLeave:c,onSync:h}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(s):(this.state=r.syncDiff(this.state,s,a,c),h())}),this.onJoin((s,a,c)=>{this.channel._trigger("presence",{event:"join",key:s,currentPresences:a,newPresences:c})}),this.onLeave((s,a,c)=>{this.channel._trigger("presence",{event:"leave",key:s,currentPresences:a,leftPresences:c})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,t,n,s){let a=this.cloneDeep(e),c=this.transformState(t),h={},f={};return this.map(a,(m,_)=>{c[m]||(f[m]=_)}),this.map(c,(m,_)=>{let E=a[m];if(E){let I=_.map(j=>j.presence_ref),k=E.map(j=>j.presence_ref),B=_.filter(j=>k.indexOf(j.presence_ref)<0),G=E.filter(j=>I.indexOf(j.presence_ref)<0);B.length>0&&(h[m]=B),G.length>0&&(f[m]=G)}else h[m]=_}),this.syncDiff(a,{joins:h,leaves:f},n,s)}static syncDiff(e,t,n,s){let{joins:a,leaves:c}={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)};return n||(n=()=>{}),s||(s=()=>{}),this.map(a,(h,f)=>{var m;let _=(m=e[h])!==null&&m!==void 0?m:[];if(e[h]=this.cloneDeep(f),_.length>0){let E=e[h].map(k=>k.presence_ref),I=_.filter(k=>E.indexOf(k.presence_ref)<0);e[h].unshift(...I)}n(h,_,f)}),this.map(c,(h,f)=>{let m=e[h];if(!m)return;let _=f.map(E=>E.presence_ref);m=m.filter(E=>_.indexOf(E.presence_ref)<0),e[h]=m,s(h,m,f),m.length===0&&delete e[h]}),e}static map(e,t){return Object.getOwnPropertyNames(e).map(n=>t(n,e[n]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((t,n)=>{let s=e[n];return"metas"in s?t[n]=s.metas.map(a=>(a.presence_ref=a.phx_ref,delete a.phx_ref,delete a.phx_ref_prev,a)):t[n]=s,t},{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}};var Fg;(function(r){r.ALL="*",r.INSERT="INSERT",r.UPDATE="UPDATE",r.DELETE="DELETE"})(Fg||(Fg={}));var Ug;(function(r){r.BROADCAST="broadcast",r.PRESENCE="presence",r.POSTGRES_CHANGES="postgres_changes",r.SYSTEM="system"})(Ug||(Ug={}));var Zr;(function(r){r.SUBSCRIBED="SUBSCRIBED",r.TIMED_OUT="TIMED_OUT",r.CLOSED="CLOSED",r.CHANNEL_ERROR="CHANNEL_ERROR"})(Zr||(Zr={}));var ia=class r{constructor(e,t={config:{}},n){this.topic=e,this.params=t,this.socket=n,this.bindings={},this.state=Gt.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""},private:!1},t.config),this.timeout=this.socket.timeout,this.joinPush=new vs(this,rr.join,this.params,this.timeout),this.rejoinTimer=new ys(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=Gt.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=Gt.closed,this.socket._remove(this)}),this._onError(s=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,s),this.state=Gt.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=Gt.errored,this.rejoinTimer.scheduleTimeout())}),this._on(rr.reply,{},(s,a)=>{this._trigger(this._replyEventName(a),s)}),this.presence=new na(this),this.broadcastEndpointURL=af(this.socket.endPoint)+"/api/broadcast",this.private=this.params.config.private||!1}subscribe(e,t=this.timeout){var n,s;if(this.socket.isConnected()||this.socket.connect(),this.joinedOnce)throw"tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";{let{config:{broadcast:a,presence:c,private:h}}=this.params;this._onError(_=>e==null?void 0:e(Zr.CHANNEL_ERROR,_)),this._onClose(()=>e==null?void 0:e(Zr.CLOSED));let f={},m={broadcast:a,presence:c,postgres_changes:(s=(n=this.bindings.postgres_changes)===null||n===void 0?void 0:n.map(_=>_.filter))!==null&&s!==void 0?s:[],private:h};this.socket.accessTokenValue&&(f.access_token=this.socket.accessTokenValue),this.updateJoinPayload(Object.assign({config:m},f)),this.joinedOnce=!0,this._rejoin(t),this.joinPush.receive("ok",async({postgres_changes:_})=>{var E;if(this.socket.setAuth(),_===void 0){e==null||e(Zr.SUBSCRIBED);return}else{let I=this.bindings.postgres_changes,k=(E=I==null?void 0:I.length)!==null&&E!==void 0?E:0,B=[];for(let G=0;G<k;G++){let j=I[G],{filter:{event:J,schema:ee,table:re,filter:le}}=j,de=_&&_[G];if(de&&de.event===J&&de.schema===ee&&de.table===re&&de.filter===le)B.push(Object.assign(Object.assign({},j),{id:de.id}));else{this.unsubscribe(),e==null||e(Zr.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=B,e&&e(Zr.SUBSCRIBED);return}}).receive("error",_=>{e==null||e(Zr.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(_).join(", ")||"error")))}).receive("timeout",()=>{e==null||e(Zr.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(e,t={}){return await this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,t,n){return this._on(e,t,n)}async send(e,t={}){var n,s;if(!this._canPush()&&e.type==="broadcast"){let{event:a,payload:c}=e,f={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:a,payload:c,private:this.private}]})};try{let m=await this._fetchWithTimeout(this.broadcastEndpointURL,f,(n=t.timeout)!==null&&n!==void 0?n:this.timeout);return await((s=m.body)===null||s===void 0?void 0:s.cancel()),m.ok?"ok":"error"}catch(m){return m.name==="AbortError"?"timed out":"error"}}else return new Promise(a=>{var c,h,f;let m=this._push(e.type,e,t.timeout||this.timeout);e.type==="broadcast"&&!(!((f=(h=(c=this.params)===null||c===void 0?void 0:c.config)===null||h===void 0?void 0:h.broadcast)===null||f===void 0)&&f.ack)&&a("ok"),m.receive("ok",()=>a("ok")),m.receive("error",()=>a("error")),m.receive("timeout",()=>a("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=Gt.leaving;let t=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(rr.close,"leave",this._joinRef())};return this.rejoinTimer.reset(),this.joinPush.destroy(),new Promise(n=>{let s=new vs(this,rr.leave,{},e);s.receive("ok",()=>{t(),n("ok")}).receive("timeout",()=>{t(),n("timed out")}).receive("error",()=>{n("error")}),s.send(),this._canPush()||s.trigger("ok",{})})}async _fetchWithTimeout(e,t,n){let s=new AbortController,a=setTimeout(()=>s.abort(),n),c=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:s.signal}));return clearTimeout(a),c}_push(e,t,n=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let s=new vs(this,e,t,n);return this._canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}_onMessage(e,t,n){return t}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,t,n){var s,a;let c=e.toLocaleLowerCase(),{close:h,error:f,leave:m,join:_}=rr;if(n&&[h,f,m,_].indexOf(c)>=0&&n!==this._joinRef())return;let I=this._onMessage(c,t,n);if(t&&!I)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(c)?(s=this.bindings.postgres_changes)===null||s===void 0||s.filter(k=>{var B,G,j;return((B=k.filter)===null||B===void 0?void 0:B.event)==="*"||((j=(G=k.filter)===null||G===void 0?void 0:G.event)===null||j===void 0?void 0:j.toLocaleLowerCase())===c}).map(k=>k.callback(I,n)):(a=this.bindings[c])===null||a===void 0||a.filter(k=>{var B,G,j,J,ee,re;if(["broadcast","presence","postgres_changes"].includes(c))if("id"in k){let le=k.id,de=(B=k.filter)===null||B===void 0?void 0:B.event;return le&&((G=t.ids)===null||G===void 0?void 0:G.includes(le))&&(de==="*"||(de==null?void 0:de.toLocaleLowerCase())===((j=t.data)===null||j===void 0?void 0:j.type.toLocaleLowerCase()))}else{let le=(ee=(J=k==null?void 0:k.filter)===null||J===void 0?void 0:J.event)===null||ee===void 0?void 0:ee.toLocaleLowerCase();return le==="*"||le===((re=t==null?void 0:t.event)===null||re===void 0?void 0:re.toLocaleLowerCase())}else return k.type.toLocaleLowerCase()===c}).map(k=>{if(typeof I=="object"&&"ids"in I){let B=I.data,{schema:G,table:j,commit_timestamp:J,type:ee,errors:re}=B;I=Object.assign(Object.assign({},{schema:G,table:j,commit_timestamp:J,eventType:ee,new:{},old:{},errors:re}),this._getPayloadRecords(B))}k.callback(I,n)})}_isClosed(){return this.state===Gt.closed}_isJoined(){return this.state===Gt.joined}_isJoining(){return this.state===Gt.joining}_isLeaving(){return this.state===Gt.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,t,n){let s=e.toLocaleLowerCase(),a={type:s,filter:t,callback:n};return this.bindings[s]?this.bindings[s].push(a):this.bindings[s]=[a],this}_off(e,t){let n=e.toLocaleLowerCase();return this.bindings[n]=this.bindings[n].filter(s=>{var a;return!(((a=s.type)===null||a===void 0?void 0:a.toLocaleLowerCase())===n&&r.isEqual(s.filter,t))}),this}static isEqual(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(rr.close,{},e)}_onError(e){this._on(rr.error,{},t=>e(t))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=Gt.joining,this.joinPush.resend(e))}_getPayloadRecords(e){let t={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(t.new=Lg(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(t.old=Lg(e.columns,e.old_record)),t}};var iU=()=>{},sU=typeof WebSocket!="undefined",oU=`
42
42
  addEventListener("message", (e) => {
43
43
  if (e.data.event === "start") {
44
44
  setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
45
45
  }
46
- });`,ia=class{constructor(e,t){var r;this.accessTokenValue=null,this.apiKey=null,this.channels=[],this.endPoint="",this.httpEndpoint="",this.headers=vE,this.params={},this.timeout=sf,this.heartbeatIntervalMs=3e4,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.ref=0,this.logger=eU,this.conn=null,this.sendBuffer=[],this.serializer=new Uu,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._resolveFetch=a=>{let c;return a?c=a:typeof fetch=="undefined"?c=(...h)=>Promise.resolve().then(()=>(Ei(),gs)).then(({default:f})=>f(...h)):c=fetch,(...h)=>c(...h)},this.endPoint=`${e}/${rf.websocket}`,this.httpEndpoint=of(e),t!=null&&t.transport?this.transport=t.transport:this.transport=null,t!=null&&t.params&&(this.params=t.params),t!=null&&t.headers&&(this.headers=Object.assign(Object.assign({},this.headers),t.headers)),t!=null&&t.timeout&&(this.timeout=t.timeout),t!=null&&t.logger&&(this.logger=t.logger),t!=null&&t.heartbeatIntervalMs&&(this.heartbeatIntervalMs=t.heartbeatIntervalMs);let s=(r=t==null?void 0:t.params)===null||r===void 0?void 0:r.apikey;if(s&&(this.accessTokenValue=s,this.apiKey=s),this.reconnectAfterMs=t!=null&&t.reconnectAfterMs?t.reconnectAfterMs:a=>[1e3,2e3,5e3,1e4][a-1]||1e4,this.encode=t!=null&&t.encode?t.encode:(a,c)=>c(JSON.stringify(a)),this.decode=t!=null&&t.decode?t.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new ys(async()=>{this.disconnect(),this.connect()},this.reconnectAfterMs),this.fetch=this._resolveFetch(t==null?void 0:t.fetch),t!=null&&t.worker){if(typeof window!="undefined"&&!window.Worker)throw new Error("Web Worker is not supported");this.worker=(t==null?void 0:t.worker)||!1,this.workerUrl=t==null?void 0:t.workerUrl}this.accessToken=(t==null?void 0:t.accessToken)||null}connect(){if(!this.conn){if(this.transport){this.conn=new this.transport(this.endpointURL(),void 0,{headers:this.headers});return}if(tU){this.conn=new WebSocket(this.endpointURL()),this.setupConnection();return}this.conn=new Fg(this.endpointURL(),void 0,{close:()=>{this.conn=null}}),Promise.resolve().then(()=>Cd(IE())).then(({default:e})=>{this.conn=new e(this.endpointURL(),void 0,{headers:this.headers}),this.setupConnection()})}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:wE}))}disconnect(e,t){this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,t!=null?t:""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset())}getChannels(){return this.channels}async removeChannel(e){let t=await e.unsubscribe();return this.channels.length===0&&this.disconnect(),t}async removeAllChannels(){let e=await Promise.all(this.channels.map(t=>t.unsubscribe()));return this.disconnect(),e}log(e,t,r){this.logger(e,t,r)}connectionState(){switch(this.conn&&this.conn.readyState){case _s.connecting:return Ii.Connecting;case _s.open:return Ii.Open;case _s.closing:return Ii.Closing;default:return Ii.Closed}}isConnected(){return this.connectionState()===Ii.Open}channel(e,t={config:{}}){let r=new ra(`realtime:${e}`,t,this);return this.channels.push(r),r}push(e){let{topic:t,event:r,payload:s,ref:a}=e,c=()=>{this.encode(e,h=>{var f;(f=this.conn)===null||f===void 0||f.send(h)})};this.log("push",`${t} ${r} (${a})`,s),this.isConnected()?c():this.sendBuffer.push(c)}async setAuth(e=null){let t=e||this.accessToken&&await this.accessToken()||this.accessTokenValue;if(t){let r=null;try{r=JSON.parse(atob(t.split(".")[1]))}catch{}if(r&&r.exp&&!(Math.floor(Date.now()/1e3)-r.exp<0))return this.log("auth",`InvalidJWTToken: Invalid value for JWT claim "exp" with value ${r.exp}`),Promise.reject(`InvalidJWTToken: Invalid value for JWT claim "exp" with value ${r.exp}`);this.accessTokenValue=t,this.channels.forEach(s=>{t&&s.updateJoinPayload({access_token:t}),s.joinedOnce&&s._isJoined()&&s._push(tn.access_token,{access_token:t})})}}async sendHeartbeat(){var e;if(this.isConnected()){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),(e=this.conn)===null||e===void 0||e.close(bE,"hearbeat timeout");return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.setAuth()}}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let t=this.channels.find(r=>r.topic===e&&(r._isJoined()||r._isJoining()));t&&(this.log("transport",`leaving duplicate topic "${e}"`),t.unsubscribe())}_remove(e){this.channels=this.channels.filter(t=>t._joinRef()!==e._joinRef())}setupConnection(){this.conn&&(this.conn.binaryType="arraybuffer",this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e))}_onConnMessage(e){this.decode(e.data,t=>{let{topic:r,event:s,payload:a,ref:c}=t;c&&c===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null),this.log("receive",`${a.status||""} ${r} ${s} ${c&&"("+c+")"||""}`,a),this.channels.filter(h=>h._isMember(r)).forEach(h=>h._trigger(s,a,c)),this.stateChangeCallbacks.message.forEach(h=>h(t))})}async _onConnOpen(){if(this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this.reconnectTimer.reset(),!this.worker)this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs);else{this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");let e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=t=>{this.log("worker","worker error",t.message),this.workerRef.terminate()},this.workerRef.onmessage=t=>{t.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}this.stateChangeCallbacks.open.forEach(e=>e())}_onConnClose(e){this.log("transport","close",e),this._triggerChanError(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(t=>t(e))}_onConnError(e){this.log("transport",e.message),this._triggerChanError(),this.stateChangeCallbacks.error.forEach(t=>t(e))}_triggerChanError(){this.channels.forEach(e=>e._trigger(tn.error))}_appendParams(e,t){if(Object.keys(t).length===0)return e;let r=e.match(/\?/)?"&":"?",s=new URLSearchParams(t);return`${e}${r}${s}`}_workerObjectUrl(e){let t;if(e)t=e;else{let r=new Blob([nU],{type:"application/javascript"});t=URL.createObjectURL(r)}return t}},Fg=class{constructor(e,t,r){this.binaryType="arraybuffer",this.onclose=()=>{},this.onerror=()=>{},this.onmessage=()=>{},this.onopen=()=>{},this.readyState=_s.connecting,this.send=()=>{},this.url=null,this.url=e,this.close=r.close}};var sa=class extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}};function ot(n){return typeof n=="object"&&n!==null&&"__isStorageError"in n}var af=class extends sa{constructor(e,t){super(e),this.name="StorageApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}},ws=class extends sa{constructor(e,t){super(e),this.name="StorageUnknownError",this.originalError=t}};var rU=function(n,e,t,r){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(r.next(_))}catch(E){c(E)}}function f(_){try{m(r.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((r=r.apply(n,e||[])).next())})},cf=n=>{let e;return n?e=n:typeof fetch=="undefined"?e=(...t)=>Promise.resolve().then(()=>(Ei(),gs)).then(({default:r})=>r(...t)):e=fetch,(...t)=>e(...t)},xE=()=>rU(void 0,void 0,void 0,function*(){return typeof Response=="undefined"?(yield Promise.resolve().then(()=>(Ei(),gs))).Response:Response}),uf=n=>{if(Array.isArray(n))return n.map(t=>uf(t));if(typeof n=="function"||n!==Object(n))return n;let e={};return Object.entries(n).forEach(([t,r])=>{let s=t.replace(/([-_][a-z])/gi,a=>a.toUpperCase().replace(/[-_]/g,""));e[s]=uf(r)}),e};var bs=function(n,e,t,r){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(r.next(_))}catch(E){c(E)}}function f(_){try{m(r.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((r=r.apply(n,e||[])).next())})},Ug=n=>n.msg||n.message||n.error_description||n.error||JSON.stringify(n),iU=(n,e,t)=>bs(void 0,void 0,void 0,function*(){let r=yield xE();n instanceof r&&!(t!=null&&t.noResolveJson)?n.json().then(s=>{e(new af(Ug(s),n.status||500))}).catch(s=>{e(new ws(Ug(s),s))}):e(new ws(Ug(n),n))}),sU=(n,e,t,r)=>{let s={method:n,headers:(e==null?void 0:e.headers)||{}};return n==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json"},e==null?void 0:e.headers),r&&(s.body=JSON.stringify(r)),Object.assign(Object.assign({},s),t))};function Bu(n,e,t,r,s,a){return bs(this,void 0,void 0,function*(){return new Promise((c,h)=>{n(t,sU(e,r,s,a)).then(f=>{if(!f.ok)throw f;return r!=null&&r.noResolveJson?f:f.json()}).then(f=>c(f)).catch(f=>iU(f,h,r))})})}function oa(n,e,t,r){return bs(this,void 0,void 0,function*(){return Bu(n,"GET",e,t,r)})}function tr(n,e,t,r,s){return bs(this,void 0,void 0,function*(){return Bu(n,"POST",e,r,s,t)})}function AE(n,e,t,r,s){return bs(this,void 0,void 0,function*(){return Bu(n,"PUT",e,r,s,t)})}function SE(n,e,t,r){return bs(this,void 0,void 0,function*(){return Bu(n,"HEAD",e,Object.assign(Object.assign({},t),{noResolveJson:!0}),r)})}function lf(n,e,t,r,s){return bs(this,void 0,void 0,function*(){return Bu(n,"DELETE",e,r,s,t)})}var Gt=function(n,e,t,r){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(r.next(_))}catch(E){c(E)}}function f(_){try{m(r.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((r=r.apply(n,e||[])).next())})},oU={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},RE={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1},ju=class{constructor(e,t={},r,s){this.url=e,this.headers=t,this.bucketId=r,this.fetch=cf(s)}uploadOrUpdate(e,t,r,s){return Gt(this,void 0,void 0,function*(){try{let a,c=Object.assign(Object.assign({},RE),s),h=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(c.upsert)}),f=c.metadata;typeof Blob!="undefined"&&r instanceof Blob?(a=new FormData,a.append("cacheControl",c.cacheControl),f&&a.append("metadata",this.encodeMetadata(f)),a.append("",r)):typeof FormData!="undefined"&&r instanceof FormData?(a=r,a.append("cacheControl",c.cacheControl),f&&a.append("metadata",this.encodeMetadata(f))):(a=r,h["cache-control"]=`max-age=${c.cacheControl}`,h["content-type"]=c.contentType,f&&(h["x-metadata"]=this.toBase64(this.encodeMetadata(f)))),s!=null&&s.headers&&(h=Object.assign(Object.assign({},h),s.headers));let m=this._removeEmptyFolders(t),_=this._getFinalPath(m),E=yield this.fetch(`${this.url}/object/${_}`,Object.assign({method:e,body:a,headers:h},c!=null&&c.duplex?{duplex:c.duplex}:{})),I=yield E.json();return E.ok?{data:{path:m,id:I.Id,fullPath:I.Key},error:null}:{data:null,error:I}}catch(a){if(ot(a))return{data:null,error:a};throw a}})}upload(e,t,r){return Gt(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,t,r)})}uploadToSignedUrl(e,t,r,s){return Gt(this,void 0,void 0,function*(){let a=this._removeEmptyFolders(e),c=this._getFinalPath(a),h=new URL(this.url+`/object/upload/sign/${c}`);h.searchParams.set("token",t);try{let f,m=Object.assign({upsert:RE.upsert},s),_=Object.assign(Object.assign({},this.headers),{"x-upsert":String(m.upsert)});typeof Blob!="undefined"&&r instanceof Blob?(f=new FormData,f.append("cacheControl",m.cacheControl),f.append("",r)):typeof FormData!="undefined"&&r instanceof FormData?(f=r,f.append("cacheControl",m.cacheControl)):(f=r,_["cache-control"]=`max-age=${m.cacheControl}`,_["content-type"]=m.contentType);let E=yield this.fetch(h.toString(),{method:"PUT",body:f,headers:_}),I=yield E.json();return E.ok?{data:{path:a,fullPath:I.Key},error:null}:{data:null,error:I}}catch(f){if(ot(f))return{data:null,error:f};throw f}})}createSignedUploadUrl(e,t){return Gt(this,void 0,void 0,function*(){try{let r=this._getFinalPath(e),s=Object.assign({},this.headers);t!=null&&t.upsert&&(s["x-upsert"]="true");let a=yield tr(this.fetch,`${this.url}/object/upload/sign/${r}`,{},{headers:s}),c=new URL(this.url+a.url),h=c.searchParams.get("token");if(!h)throw new sa("No token returned by API");return{data:{signedUrl:c.toString(),path:e,token:h},error:null}}catch(r){if(ot(r))return{data:null,error:r};throw r}})}update(e,t,r){return Gt(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,t,r)})}move(e,t,r){return Gt(this,void 0,void 0,function*(){try{return{data:yield tr(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:r==null?void 0:r.destinationBucket},{headers:this.headers}),error:null}}catch(s){if(ot(s))return{data:null,error:s};throw s}})}copy(e,t,r){return Gt(this,void 0,void 0,function*(){try{return{data:{path:(yield tr(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:r==null?void 0:r.destinationBucket},{headers:this.headers})).Key},error:null}}catch(s){if(ot(s))return{data:null,error:s};throw s}})}createSignedUrl(e,t,r){return Gt(this,void 0,void 0,function*(){try{let s=this._getFinalPath(e),a=yield tr(this.fetch,`${this.url}/object/sign/${s}`,Object.assign({expiresIn:t},r!=null&&r.transform?{transform:r.transform}:{}),{headers:this.headers}),c=r!=null&&r.download?`&download=${r.download===!0?"":r.download}`:"";return a={signedUrl:encodeURI(`${this.url}${a.signedURL}${c}`)},{data:a,error:null}}catch(s){if(ot(s))return{data:null,error:s};throw s}})}createSignedUrls(e,t,r){return Gt(this,void 0,void 0,function*(){try{let s=yield tr(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers}),a=r!=null&&r.download?`&download=${r.download===!0?"":r.download}`:"";return{data:s.map(c=>Object.assign(Object.assign({},c),{signedUrl:c.signedURL?encodeURI(`${this.url}${c.signedURL}${a}`):null})),error:null}}catch(s){if(ot(s))return{data:null,error:s};throw s}})}download(e,t){return Gt(this,void 0,void 0,function*(){let s=typeof(t==null?void 0:t.transform)!="undefined"?"render/image/authenticated":"object",a=this.transformOptsToQueryString((t==null?void 0:t.transform)||{}),c=a?`?${a}`:"";try{let h=this._getFinalPath(e);return{data:yield(yield oa(this.fetch,`${this.url}/${s}/${h}${c}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(h){if(ot(h))return{data:null,error:h};throw h}})}info(e){return Gt(this,void 0,void 0,function*(){let t=this._getFinalPath(e);try{let r=yield oa(this.fetch,`${this.url}/object/info/${t}`,{headers:this.headers});return{data:uf(r),error:null}}catch(r){if(ot(r))return{data:null,error:r};throw r}})}exists(e){return Gt(this,void 0,void 0,function*(){let t=this._getFinalPath(e);try{return yield SE(this.fetch,`${this.url}/object/${t}`,{headers:this.headers}),{data:!0,error:null}}catch(r){if(ot(r)&&r instanceof ws){let s=r.originalError;if([400,404].includes(s==null?void 0:s.status))return{data:!1,error:r}}throw r}})}getPublicUrl(e,t){let r=this._getFinalPath(e),s=[],a=t!=null&&t.download?`download=${t.download===!0?"":t.download}`:"";a!==""&&s.push(a);let h=typeof(t==null?void 0:t.transform)!="undefined"?"render/image":"object",f=this.transformOptsToQueryString((t==null?void 0:t.transform)||{});f!==""&&s.push(f);let m=s.join("&");return m!==""&&(m=`?${m}`),{data:{publicUrl:encodeURI(`${this.url}/${h}/public/${r}${m}`)}}}remove(e){return Gt(this,void 0,void 0,function*(){try{return{data:yield lf(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(t){if(ot(t))return{data:null,error:t};throw t}})}list(e,t,r){return Gt(this,void 0,void 0,function*(){try{let s=Object.assign(Object.assign(Object.assign({},oU),t),{prefix:e||""});return{data:yield tr(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},r),error:null}}catch(s){if(ot(s))return{data:null,error:s};throw s}})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return typeof Buffer!="undefined"?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){let t=[];return e.width&&t.push(`width=${e.width}`),e.height&&t.push(`height=${e.height}`),e.resize&&t.push(`resize=${e.resize}`),e.format&&t.push(`format=${e.format}`),e.quality&&t.push(`quality=${e.quality}`),t.join("&")}};var PE="2.7.1";var CE={"X-Client-Info":`storage-js/${PE}`};var aa=function(n,e,t,r){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(r.next(_))}catch(E){c(E)}}function f(_){try{m(r.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((r=r.apply(n,e||[])).next())})},$u=class{constructor(e,t={},r){this.url=e,this.headers=Object.assign(Object.assign({},CE),t),this.fetch=cf(r)}listBuckets(){return aa(this,void 0,void 0,function*(){try{return{data:yield oa(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(ot(e))return{data:null,error:e};throw e}})}getBucket(e){return aa(this,void 0,void 0,function*(){try{return{data:yield oa(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(t){if(ot(t))return{data:null,error:t};throw t}})}createBucket(e,t={public:!1}){return aa(this,void 0,void 0,function*(){try{return{data:yield tr(this.fetch,`${this.url}/bucket`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}),error:null}}catch(r){if(ot(r))return{data:null,error:r};throw r}})}updateBucket(e,t){return aa(this,void 0,void 0,function*(){try{return{data:yield AE(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}),error:null}}catch(r){if(ot(r))return{data:null,error:r};throw r}})}emptyBucket(e){return aa(this,void 0,void 0,function*(){try{return{data:yield tr(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(t){if(ot(t))return{data:null,error:t};throw t}})}deleteBucket(e){return aa(this,void 0,void 0,function*(){try{return{data:yield lf(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(t){if(ot(t))return{data:null,error:t};throw t}})}};var qu=class extends $u{constructor(e,t={},r){super(e,t,r)}from(e){return new ju(this.url,this.headers,e,this.fetch)}};var DE="2.48.1";var zu="";typeof Deno!="undefined"?zu="deno":typeof document!="undefined"?zu="web":typeof navigator!="undefined"&&navigator.product==="ReactNative"?zu="react-native":zu="node";var aU={"X-Client-Info":`supabase-js-${zu}/${DE}`},OE={headers:aU},kE={schema:"public"},NE={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},VE={};Ei();var uU=function(n,e,t,r){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(r.next(_))}catch(E){c(E)}}function f(_){try{m(r.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((r=r.apply(n,e||[])).next())})},cU=n=>{let e;return n?e=n:typeof fetch=="undefined"?e=wg:e=fetch,(...t)=>e(...t)},lU=()=>typeof Headers=="undefined"?bg:Headers,LE=(n,e,t)=>{let r=cU(t),s=lU();return(a,c)=>uU(void 0,void 0,void 0,function*(){var h;let f=(h=yield e())!==null&&h!==void 0?h:n,m=new s(c==null?void 0:c.headers);return m.has("apikey")||m.set("apikey",n),m.has("Authorization")||m.set("Authorization",`Bearer ${f}`),r(a,Object.assign(Object.assign({},c),{headers:m}))})};var hU=function(n,e,t,r){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(r.next(_))}catch(E){c(E)}}function f(_){try{m(r.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((r=r.apply(n,e||[])).next())})};function ME(n){return n.replace(/\/$/,"")}function FE(n,e){let{db:t,auth:r,realtime:s,global:a}=n,{db:c,auth:h,realtime:f,global:m}=e,_={db:Object.assign(Object.assign({},c),t),auth:Object.assign(Object.assign({},h),r),realtime:Object.assign(Object.assign({},f),s),global:Object.assign(Object.assign({},m),a),accessToken:()=>hU(this,void 0,void 0,function*(){return""})};return n.accessToken?_.accessToken=n.accessToken:delete _.accessToken,_}var hf="2.67.3";var UE="http://localhost:9999",BE="supabase.auth.token";var jE={"X-Client-Info":`gotrue-js/${hf}`},Bg=10;var Gu="X-Supabase-Api-Version",jg={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}};function $E(n){return Math.round(Date.now()/1e3)+n}function qE(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){let e=Math.random()*16|0;return(n=="x"?e:e&3|8).toString(16)})}var Pn=()=>typeof window!="undefined"&&typeof document!="undefined",Ts={tested:!1,writable:!1},xi=()=>{if(!Pn())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Ts.tested)return Ts.writable;let n=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(n,n),globalThis.localStorage.removeItem(n),Ts.tested=!0,Ts.writable=!0}catch{Ts.tested=!0,Ts.writable=!1}return Ts.writable};function zE(n){let e={},t=new URL(n);if(t.hash&&t.hash[0]==="#")try{new URLSearchParams(t.hash.substring(1)).forEach((s,a)=>{e[a]=s})}catch{}return t.searchParams.forEach((r,s)=>{e[s]=r}),e}var ff=n=>{let e;return n?e=n:typeof fetch=="undefined"?e=(...t)=>Promise.resolve().then(()=>(Ei(),gs)).then(({default:r})=>r(...t)):e=fetch,(...t)=>e(...t)},GE=n=>typeof n=="object"&&n!==null&&"status"in n&&"ok"in n&&"json"in n&&typeof n.json=="function",$g=async(n,e,t)=>{await n.setItem(e,JSON.stringify(t))},Wu=async(n,e)=>{let t=await n.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch{return t}},Hu=async(n,e)=>{await n.removeItem(e)};function fU(n){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",t="",r,s,a,c,h,f,m,_=0;for(n=n.replace("-","+").replace("_","/");_<n.length;)c=e.indexOf(n.charAt(_++)),h=e.indexOf(n.charAt(_++)),f=e.indexOf(n.charAt(_++)),m=e.indexOf(n.charAt(_++)),r=c<<2|h>>4,s=(h&15)<<4|f>>2,a=(f&3)<<6|m,t=t+String.fromCharCode(r),f!=64&&s!=0&&(t=t+String.fromCharCode(s)),m!=64&&a!=0&&(t=t+String.fromCharCode(a));return t}var Ku=class n{constructor(){this.promise=new n.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}};Ku.promiseConstructor=Promise;function qg(n){let e=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}=?$|[a-z0-9_-]{2}(==)?$)$/i,t=n.split(".");if(t.length!==3)throw new Error("JWT is not valid: not a JWT structure");if(!e.test(t[1]))throw new Error("JWT is not valid: payload is not in base64url format");let r=t[1];return JSON.parse(fU(r))}async function KE(n){return await new Promise(e=>{setTimeout(()=>e(null),n)})}function WE(n,e){return new Promise((r,s)=>{(async()=>{for(let a=0;a<1/0;a++)try{let c=await n(a);if(!e(a,null,c)){r(c);return}}catch(c){if(!e(a,c)){s(c);return}}})()})}function dU(n){return("0"+n.toString(16)).substr(-2)}function pU(){let e=new Uint32Array(56);if(typeof crypto=="undefined"){let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",r=t.length,s="";for(let a=0;a<56;a++)s+=t.charAt(Math.floor(Math.random()*r));return s}return crypto.getRandomValues(e),Array.from(e,dU).join("")}async function mU(n){let t=new TextEncoder().encode(n),r=await crypto.subtle.digest("SHA-256",t),s=new Uint8Array(r);return Array.from(s).map(a=>String.fromCharCode(a)).join("")}function gU(n){return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function _U(n){if(!(typeof crypto!="undefined"&&typeof crypto.subtle!="undefined"&&typeof TextEncoder!="undefined"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),n;let t=await mU(n);return gU(t)}async function Es(n,e,t=!1){let r=pU(),s=r;t&&(s+="/PASSWORD_RECOVERY"),await $g(n,`${e}-code-verifier`,s);let a=await _U(r);return[a,r===a?"plain":"s256"]}var yU=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function HE(n){let e=n.headers.get(Gu);if(!e||!e.match(yU))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}var Qu=class extends Error{constructor(e,t,r){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t,this.code=r}};function ge(n){return typeof n=="object"&&n!==null&&"__isAuthError"in n}var df=class extends Qu{constructor(e,t,r){super(e,t,r),this.name="AuthApiError",this.status=t,this.code=r}};function QE(n){return ge(n)&&n.name==="AuthApiError"}var ua=class extends Qu{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}},Nr=class extends Qu{constructor(e,t,r,s){super(e,r,s),this.name=t,this.status=r}},fn=class extends Nr{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}};function JE(n){return ge(n)&&n.name==="AuthSessionMissingError"}var ca=class extends Nr{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}},Is=class extends Nr{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}},xs=class extends Nr{constructor(e,t=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}};function YE(n){return ge(n)&&n.name==="AuthImplicitGrantRedirectError"}var Ju=class extends Nr{constructor(e,t=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}},la=class extends Nr{constructor(e,t){super(e,"AuthRetryableFetchError",t,void 0)}};function pf(n){return ge(n)&&n.name==="AuthRetryableFetchError"}var Yu=class extends Nr{constructor(e,t,r){super(e,"AuthWeakPasswordError",t,"weak_password"),this.reasons=r}};var vU=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t},As=n=>n.msg||n.message||n.error_description||n.error||JSON.stringify(n),wU=[502,503,504];async function XE(n){var e;if(!GE(n))throw new la(As(n),0);if(wU.includes(n.status))throw new la(As(n),n.status);let t;try{t=await n.json()}catch(a){throw new ua(As(a),a)}let r,s=HE(n);if(s&&s.getTime()>=jg["2024-01-01"].timestamp&&typeof t=="object"&&t&&typeof t.code=="string"?r=t.code:typeof t=="object"&&t&&typeof t.error_code=="string"&&(r=t.error_code),r){if(r==="weak_password")throw new Yu(As(t),n.status,((e=t.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(r==="session_not_found")throw new fn}else if(typeof t=="object"&&t&&typeof t.weak_password=="object"&&t.weak_password&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.reasons.reduce((a,c)=>a&&typeof c=="string",!0))throw new Yu(As(t),n.status,t.weak_password.reasons);throw new df(As(t),n.status||500,r)}var bU=(n,e,t,r)=>{let s={method:n,headers:(e==null?void 0:e.headers)||{}};return n==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e==null?void 0:e.headers),s.body=JSON.stringify(r),Object.assign(Object.assign({},s),t))};async function Ee(n,e,t,r){var s;let a=Object.assign({},r==null?void 0:r.headers);a[Gu]||(a[Gu]=jg["2024-01-01"].name),r!=null&&r.jwt&&(a.Authorization=`Bearer ${r.jwt}`);let c=(s=r==null?void 0:r.query)!==null&&s!==void 0?s:{};r!=null&&r.redirectTo&&(c.redirect_to=r.redirectTo);let h=Object.keys(c).length?"?"+new URLSearchParams(c).toString():"",f=await TU(n,e,t+h,{headers:a,noResolveJson:r==null?void 0:r.noResolveJson},{},r==null?void 0:r.body);return r!=null&&r.xform?r==null?void 0:r.xform(f):{data:Object.assign({},f),error:null}}async function TU(n,e,t,r,s,a){let c=bU(e,r,s,a),h;try{h=await n(t,Object.assign({},c))}catch(f){throw console.error(f),new la(As(f),0)}if(h.ok||await XE(h),r!=null&&r.noResolveJson)return h;try{return await h.json()}catch(f){await XE(f)}}function Vr(n){var e;let t=null;EU(n)&&(t=Object.assign({},n),n.expires_at||(t.expires_at=$E(n.expires_in)));let r=(e=n.user)!==null&&e!==void 0?e:n;return{data:{session:t,user:r},error:null}}function zg(n){let e=Vr(n);return!e.error&&n.weak_password&&typeof n.weak_password=="object"&&Array.isArray(n.weak_password.reasons)&&n.weak_password.reasons.length&&n.weak_password.message&&typeof n.weak_password.message=="string"&&n.weak_password.reasons.reduce((t,r)=>t&&typeof r=="string",!0)&&(e.data.weak_password=n.weak_password),e}function nr(n){var e;return{data:{user:(e=n.user)!==null&&e!==void 0?e:n},error:null}}function ZE(n){return{data:n,error:null}}function eI(n){let{action_link:e,email_otp:t,hashed_token:r,redirect_to:s,verification_type:a}=n,c=vU(n,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),h={action_link:e,email_otp:t,hashed_token:r,redirect_to:s,verification_type:a},f=Object.assign({},c);return{data:{properties:h,user:f},error:null}}function tI(n){return n}function EU(n){return n.access_token&&n.refresh_token&&n.expires_in}var IU=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t},Ss=class{constructor({url:e="",headers:t={},fetch:r}){this.url=e,this.headers=t,this.fetch=ff(r),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)}}async signOut(e,t="global"){try{return await Ee(this.fetch,"POST",`${this.url}/logout?scope=${t}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(r){if(ge(r))return{data:null,error:r};throw r}}async inviteUserByEmail(e,t={}){try{return await Ee(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:nr})}catch(r){if(ge(r))return{data:{user:null},error:r};throw r}}async generateLink(e){try{let{options:t}=e,r=IU(e,["options"]),s=Object.assign(Object.assign({},r),t);return"newEmail"in r&&(s.new_email=r==null?void 0:r.newEmail,delete s.newEmail),await Ee(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:eI,redirectTo:t==null?void 0:t.redirectTo})}catch(t){if(ge(t))return{data:{properties:null,user:null},error:t};throw t}}async createUser(e){try{return await Ee(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:nr})}catch(t){if(ge(t))return{data:{user:null},error:t};throw t}}async listUsers(e){var t,r,s,a,c,h,f;try{let m={nextPage:null,lastPage:0,total:0},_=await Ee(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(t=e==null?void 0:e.page)===null||t===void 0?void 0:t.toString())!==null&&r!==void 0?r:"",per_page:(a=(s=e==null?void 0:e.perPage)===null||s===void 0?void 0:s.toString())!==null&&a!==void 0?a:""},xform:tI});if(_.error)throw _.error;let E=await _.json(),I=(c=_.headers.get("x-total-count"))!==null&&c!==void 0?c:0,k=(f=(h=_.headers.get("link"))===null||h===void 0?void 0:h.split(","))!==null&&f!==void 0?f:[];return k.length>0&&(k.forEach(B=>{let G=parseInt(B.split(";")[0].split("=")[1].substring(0,1)),j=JSON.parse(B.split(";")[1].split("=")[1]);m[`${j}Page`]=G}),m.total=parseInt(I)),{data:Object.assign(Object.assign({},E),m),error:null}}catch(m){if(ge(m))return{data:{users:[]},error:m};throw m}}async getUserById(e){try{return await Ee(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:nr})}catch(t){if(ge(t))return{data:{user:null},error:t};throw t}}async updateUserById(e,t){try{return await Ee(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:nr})}catch(r){if(ge(r))return{data:{user:null},error:r};throw r}}async deleteUser(e,t=!1){try{return await Ee(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:nr})}catch(r){if(ge(r))return{data:{user:null},error:r};throw r}}async _listFactors(e){try{let{data:t,error:r}=await Ee(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:s=>({data:{factors:s},error:null})});return{data:t,error:r}}catch(t){if(ge(t))return{data:null,error:t};throw t}}async _deleteFactor(e){try{return{data:await Ee(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(t){if(ge(t))return{data:null,error:t};throw t}}};var nI={getItem:n=>xi()?globalThis.localStorage.getItem(n):null,setItem:(n,e)=>{xi()&&globalThis.localStorage.setItem(n,e)},removeItem:n=>{xi()&&globalThis.localStorage.removeItem(n)}};function Gg(n={}){return{getItem:e=>n[e]||null,setItem:(e,t)=>{n[e]=t},removeItem:e=>{delete n[e]}}}function rI(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self!="undefined"&&(self.globalThis=self)}}var Rs={debug:!!(globalThis&&xi()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")},Xu=class extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}},mf=class extends Xu{};async function Kg(n,e,t){Rs.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",n,e);let r=new globalThis.AbortController;return e>0&&setTimeout(()=>{r.abort(),Rs.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",n)},e),await Promise.resolve().then(()=>globalThis.navigator.locks.request(n,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:r.signal},async s=>{if(s){Rs.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",n,s.name);try{return await t()}finally{Rs.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",n,s.name)}}else{if(e===0)throw Rs.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",n),new mf(`Acquiring an exclusive Navigator LockManager lock "${n}" immediately failed`);if(Rs.debug)try{let a=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(a,null," "))}catch(a){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",a)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await t()}}))}rI();var xU={url:UE,storageKey:BE,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:jE,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1},Zu=30*1e3,iI=3;async function sI(n,e,t){return await t()}var Ps=class n{constructor(e){var t,r;this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=n.nextInstanceID,n.nextInstanceID+=1,this.instanceID>0&&Pn()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");let s=Object.assign(Object.assign({},xU),e);if(this.logDebugMessages=!!s.debug,typeof s.debug=="function"&&(this.logger=s.debug),this.persistSession=s.persistSession,this.storageKey=s.storageKey,this.autoRefreshToken=s.autoRefreshToken,this.admin=new Ss({url:s.url,headers:s.headers,fetch:s.fetch}),this.url=s.url,this.headers=s.headers,this.fetch=ff(s.fetch),this.lock=s.lock||sI,this.detectSessionInUrl=s.detectSessionInUrl,this.flowType=s.flowType,this.hasCustomAuthorizationHeader=s.hasCustomAuthorizationHeader,s.lock?this.lock=s.lock:Pn()&&(!((t=globalThis==null?void 0:globalThis.navigator)===null||t===void 0)&&t.locks)?this.lock=Kg:this.lock=sI,this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},this.persistSession?s.storage?this.storage=s.storage:xi()?this.storage=nI:(this.memoryStorage={},this.storage=Gg(this.memoryStorage)):(this.memoryStorage={},this.storage=Gg(this.memoryStorage)),Pn()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(a){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",a)}(r=this.broadcastChannel)===null||r===void 0||r.addEventListener("message",async a=>{this._debug("received broadcast notification from other tab or client",a),await this._notifyAllSubscribers(a.data.event,a.data.session,!1)})}this.initialize()}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${hf}) ${new Date().toISOString()}`,...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var e;try{let t=zE(window.location.href),r="none";if(this._isImplicitGrantCallback(t)?r="implicit":await this._isPKCECallback(t)&&(r="pkce"),Pn()&&this.detectSessionInUrl&&r!=="none"){let{data:s,error:a}=await this._getSessionFromURL(t,r);if(a){if(this._debug("#_initialize()","error detecting session from URL",a),YE(a)){let f=(e=a.details)===null||e===void 0?void 0:e.code;if(f==="identity_already_exists"||f==="identity_not_found"||f==="single_identity_not_deletable")return{error:a}}return await this._removeSession(),{error:a}}let{session:c,redirectType:h}=s;return this._debug("#_initialize()","detected session in URL",c,"redirect type",h),await this._saveSession(c),setTimeout(async()=>{h==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",c):await this._notifyAllSubscribers("SIGNED_IN",c)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(t){return ge(t)?{error:t}:{error:new ua("Unexpected error during initialization",t)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var t,r,s;try{let a=await Ee(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(r=(t=e==null?void 0:e.options)===null||t===void 0?void 0:t.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.captchaToken}},xform:Vr}),{data:c,error:h}=a;if(h||!c)return{data:{user:null,session:null},error:h};let f=c.session,m=c.user;return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",f)),{data:{user:m,session:f},error:null}}catch(a){if(ge(a))return{data:{user:null,session:null},error:a};throw a}}async signUp(e){var t,r,s;try{let a;if("email"in e){let{email:_,password:E,options:I}=e,k=null,B=null;this.flowType==="pkce"&&([k,B]=await Es(this.storage,this.storageKey)),a=await Ee(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:I==null?void 0:I.emailRedirectTo,body:{email:_,password:E,data:(t=I==null?void 0:I.data)!==null&&t!==void 0?t:{},gotrue_meta_security:{captcha_token:I==null?void 0:I.captchaToken},code_challenge:k,code_challenge_method:B},xform:Vr})}else if("phone"in e){let{phone:_,password:E,options:I}=e;a=await Ee(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:_,password:E,data:(r=I==null?void 0:I.data)!==null&&r!==void 0?r:{},channel:(s=I==null?void 0:I.channel)!==null&&s!==void 0?s:"sms",gotrue_meta_security:{captcha_token:I==null?void 0:I.captchaToken}},xform:Vr})}else throw new Is("You must provide either an email or phone number and a password");let{data:c,error:h}=a;if(h||!c)return{data:{user:null,session:null},error:h};let f=c.session,m=c.user;return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",f)),{data:{user:m,session:f},error:null}}catch(a){if(ge(a))return{data:{user:null,session:null},error:a};throw a}}async signInWithPassword(e){try{let t;if("email"in e){let{email:a,password:c,options:h}=e;t=await Ee(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:a,password:c,gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken}},xform:zg})}else if("phone"in e){let{phone:a,password:c,options:h}=e;t=await Ee(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:a,password:c,gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken}},xform:zg})}else throw new Is("You must provide either an email or phone number and a password");let{data:r,error:s}=t;return s?{data:{user:null,session:null},error:s}:!r||!r.session||!r.user?{data:{user:null,session:null},error:new ca}:(r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),{data:Object.assign({user:r.user,session:r.session},r.weak_password?{weakPassword:r.weak_password}:null),error:s})}catch(t){if(ge(t))return{data:{user:null,session:null},error:t};throw t}}async signInWithOAuth(e){var t,r,s,a;return await this._handleProviderSignIn(e.provider,{redirectTo:(t=e.options)===null||t===void 0?void 0:t.redirectTo,scopes:(r=e.options)===null||r===void 0?void 0:r.scopes,queryParams:(s=e.options)===null||s===void 0?void 0:s.queryParams,skipBrowserRedirect:(a=e.options)===null||a===void 0?void 0:a.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async _exchangeCodeForSession(e){let t=await Wu(this.storage,`${this.storageKey}-code-verifier`),[r,s]=(t!=null?t:"").split("/");try{let{data:a,error:c}=await Ee(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:r},xform:Vr});if(await Hu(this.storage,`${this.storageKey}-code-verifier`),c)throw c;return!a||!a.session||!a.user?{data:{user:null,session:null,redirectType:null},error:new ca}:(a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",a.session)),{data:Object.assign(Object.assign({},a),{redirectType:s!=null?s:null}),error:c})}catch(a){if(ge(a))return{data:{user:null,session:null,redirectType:null},error:a};throw a}}async signInWithIdToken(e){try{let{options:t,provider:r,token:s,access_token:a,nonce:c}=e,h=await Ee(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:s,access_token:a,nonce:c,gotrue_meta_security:{captcha_token:t==null?void 0:t.captchaToken}},xform:Vr}),{data:f,error:m}=h;return m?{data:{user:null,session:null},error:m}:!f||!f.session||!f.user?{data:{user:null,session:null},error:new ca}:(f.session&&(await this._saveSession(f.session),await this._notifyAllSubscribers("SIGNED_IN",f.session)),{data:f,error:m})}catch(t){if(ge(t))return{data:{user:null,session:null},error:t};throw t}}async signInWithOtp(e){var t,r,s,a,c;try{if("email"in e){let{email:h,options:f}=e,m=null,_=null;this.flowType==="pkce"&&([m,_]=await Es(this.storage,this.storageKey));let{error:E}=await Ee(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:h,data:(t=f==null?void 0:f.data)!==null&&t!==void 0?t:{},create_user:(r=f==null?void 0:f.shouldCreateUser)!==null&&r!==void 0?r:!0,gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken},code_challenge:m,code_challenge_method:_},redirectTo:f==null?void 0:f.emailRedirectTo});return{data:{user:null,session:null},error:E}}if("phone"in e){let{phone:h,options:f}=e,{data:m,error:_}=await Ee(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:h,data:(s=f==null?void 0:f.data)!==null&&s!==void 0?s:{},create_user:(a=f==null?void 0:f.shouldCreateUser)!==null&&a!==void 0?a:!0,gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken},channel:(c=f==null?void 0:f.channel)!==null&&c!==void 0?c:"sms"}});return{data:{user:null,session:null,messageId:m==null?void 0:m.message_id},error:_}}throw new Is("You must provide either an email or phone number.")}catch(h){if(ge(h))return{data:{user:null,session:null},error:h};throw h}}async verifyOtp(e){var t,r;try{let s,a;"options"in e&&(s=(t=e.options)===null||t===void 0?void 0:t.redirectTo,a=(r=e.options)===null||r===void 0?void 0:r.captchaToken);let{data:c,error:h}=await Ee(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:a}}),redirectTo:s,xform:Vr});if(h)throw h;if(!c)throw new Error("An error occurred on token verification.");let f=c.session,m=c.user;return f!=null&&f.access_token&&(await this._saveSession(f),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",f)),{data:{user:m,session:f},error:null}}catch(s){if(ge(s))return{data:{user:null,session:null},error:s};throw s}}async signInWithSSO(e){var t,r,s;try{let a=null,c=null;return this.flowType==="pkce"&&([a,c]=await Es(this.storage,this.storageKey)),await Ee(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(r=(t=e.options)===null||t===void 0?void 0:t.redirectTo)!==null&&r!==void 0?r:void 0}),!((s=e==null?void 0:e.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:a,code_challenge_method:c}),headers:this.headers,xform:ZE})}catch(a){if(ge(a))return{data:null,error:a};throw a}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{let{data:{session:t},error:r}=e;if(r)throw r;if(!t)throw new fn;let{error:s}=await Ee(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:t.access_token});return{data:{user:null,session:null},error:s}})}catch(e){if(ge(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{let t=`${this.url}/resend`;if("email"in e){let{email:r,type:s,options:a}=e,{error:c}=await Ee(this.fetch,"POST",t,{headers:this.headers,body:{email:r,type:s,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},redirectTo:a==null?void 0:a.emailRedirectTo});return{data:{user:null,session:null},error:c}}else if("phone"in e){let{phone:r,type:s,options:a}=e,{data:c,error:h}=await Ee(this.fetch,"POST",t,{headers:this.headers,body:{phone:r,type:s,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}}});return{data:{user:null,session:null,messageId:c==null?void 0:c.message_id},error:h}}throw new Is("You must provide either an email or phone number and a type")}catch(t){if(ge(t))return{data:{user:null,session:null},error:t};throw t}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async t=>t))}async _acquireLock(e,t){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){let r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),s=(async()=>(await r,await t()))();return this.pendingInLock.push((async()=>{try{await s}catch{}})()),s}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;let r=t();for(this.pendingInLock.push((async()=>{try{await r}catch{}})()),await r;this.pendingInLock.length;){let s=[...this.pendingInLock];await Promise.all(s),this.pendingInLock.splice(0,s.length)}return await r}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{let t=await this.__loadSession();return await e(t)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null,t=await Wu(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",t),t!==null&&(this._isValidSession(t)?e=t:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};let r=e.expires_at?e.expires_at<=Date.now()/1e3:!1;if(this._debug("#__loadSession()",`session has${r?"":" not"} expired`,"expires_at",e.expires_at),!r){if(this.storage.isServer){let c=this.suppressGetSessionWarning;e=new Proxy(e,{get:(f,m,_)=>(!c&&m==="user"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),c=!0,this.suppressGetSessionWarning=!0),Reflect.get(f,m,_))})}return{data:{session:e},error:null}}let{session:s,error:a}=await this._callRefreshToken(e.refresh_token);return a?{data:{session:null},error:a}:{data:{session:s},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(e){return e?await this._getUser(e):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(e){try{return e?await Ee(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:nr}):await this._useSession(async t=>{var r,s,a;let{data:c,error:h}=t;if(h)throw h;return!(!((r=c.session)===null||r===void 0)&&r.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new fn}:await Ee(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(a=(s=c.session)===null||s===void 0?void 0:s.access_token)!==null&&a!==void 0?a:void 0,xform:nr})})}catch(t){if(ge(t))return JE(t)&&(await this._removeSession(),await Hu(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:t};throw t}}async updateUser(e,t={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(e,t))}async _updateUser(e,t={}){try{return await this._useSession(async r=>{let{data:s,error:a}=r;if(a)throw a;if(!s.session)throw new fn;let c=s.session,h=null,f=null;this.flowType==="pkce"&&e.email!=null&&([h,f]=await Es(this.storage,this.storageKey));let{data:m,error:_}=await Ee(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:t==null?void 0:t.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:h,code_challenge_method:f}),jwt:c.access_token,xform:nr});if(_)throw _;return c.user=m.user,await this._saveSession(c),await this._notifyAllSubscribers("USER_UPDATED",c),{data:{user:c.user},error:null}})}catch(r){if(ge(r))return{data:{user:null},error:r};throw r}}_decodeJWT(e){return qg(e)}async setSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new fn;let t=Date.now()/1e3,r=t,s=!0,a=null,c=qg(e.access_token);if(c.exp&&(r=c.exp,s=r<=t),s){let{session:h,error:f}=await this._callRefreshToken(e.refresh_token);if(f)return{data:{user:null,session:null},error:f};if(!h)return{data:{user:null,session:null},error:null};a=h}else{let{data:h,error:f}=await this._getUser(e.access_token);if(f)throw f;a={access_token:e.access_token,refresh_token:e.refresh_token,user:h.user,token_type:"bearer",expires_in:r-t,expires_at:r},await this._saveSession(a),await this._notifyAllSubscribers("SIGNED_IN",a)}return{data:{user:a.user,session:a},error:null}}catch(t){if(ge(t))return{data:{session:null,user:null},error:t};throw t}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async t=>{var r;if(!e){let{data:c,error:h}=t;if(h)throw h;e=(r=c.session)!==null&&r!==void 0?r:void 0}if(!(e!=null&&e.refresh_token))throw new fn;let{session:s,error:a}=await this._callRefreshToken(e.refresh_token);return a?{data:{user:null,session:null},error:a}:s?{data:{user:s.user,session:s},error:null}:{data:{user:null,session:null},error:null}})}catch(t){if(ge(t))return{data:{user:null,session:null},error:t};throw t}}async _getSessionFromURL(e,t){try{if(!Pn())throw new xs("No browser detected.");if(e.error||e.error_description||e.error_code)throw new xs(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(t){case"implicit":if(this.flowType==="pkce")throw new Ju("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new xs("Not a valid implicit grant flow url.");break;default:}if(t==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new Ju("No code detected.");let{data:ee,error:ne}=await this._exchangeCodeForSession(e.code);if(ne)throw ne;let le=new URL(window.location.href);return le.searchParams.delete("code"),window.history.replaceState(window.history.state,"",le.toString()),{data:{session:ee.session,redirectType:null},error:null}}let{provider_token:r,provider_refresh_token:s,access_token:a,refresh_token:c,expires_in:h,expires_at:f,token_type:m}=e;if(!a||!h||!c||!m)throw new xs("No session defined in URL");let _=Math.round(Date.now()/1e3),E=parseInt(h),I=_+E;f&&(I=parseInt(f));let k=I-_;k*1e3<=Zu&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${k}s, should have been closer to ${E}s`);let B=I-E;_-B>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",B,I,_):_-B<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",B,I,_);let{data:G,error:j}=await this._getUser(a);if(j)throw j;let J={provider_token:r,provider_refresh_token:s,access_token:a,expires_in:E,expires_at:I,refresh_token:c,token_type:m,user:G.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:J,redirectType:e.type},error:null}}catch(r){if(ge(r))return{data:{session:null,redirectType:null},error:r};throw r}}_isImplicitGrantCallback(e){return!!(e.access_token||e.error_description)}async _isPKCECallback(e){let t=await Wu(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&t)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async t=>{var r;let{data:s,error:a}=t;if(a)return{error:a};let c=(r=s.session)===null||r===void 0?void 0:r.access_token;if(c){let{error:h}=await this.admin.signOut(c,e);if(h&&!(QE(h)&&(h.status===404||h.status===401||h.status===403)))return{error:h}}return e!=="others"&&(await this._removeSession(),await Hu(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(e){let t=qE(),r={id:t,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",t),this.stateChangeEmitters.delete(t)}};return this._debug("#onAuthStateChange()","registered callback with id",t),this.stateChangeEmitters.set(t,r),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(t)})))(),{data:{subscription:r}}}async _emitInitialSession(e){return await this._useSession(async t=>{var r,s;try{let{data:{session:a},error:c}=t;if(c)throw c;await((r=this.stateChangeEmitters.get(e))===null||r===void 0?void 0:r.callback("INITIAL_SESSION",a)),this._debug("INITIAL_SESSION","callback id",e,"session",a)}catch(a){await((s=this.stateChangeEmitters.get(e))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",a),console.error(a)}})}async resetPasswordForEmail(e,t={}){let r=null,s=null;this.flowType==="pkce"&&([r,s]=await Es(this.storage,this.storageKey,!0));try{return await Ee(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:r,code_challenge_method:s,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})}catch(a){if(ge(a))return{data:null,error:a};throw a}}async getUserIdentities(){var e;try{let{data:t,error:r}=await this.getUser();if(r)throw r;return{data:{identities:(e=t.user.identities)!==null&&e!==void 0?e:[]},error:null}}catch(t){if(ge(t))return{data:null,error:t};throw t}}async linkIdentity(e){var t;try{let{data:r,error:s}=await this._useSession(async a=>{var c,h,f,m,_;let{data:E,error:I}=a;if(I)throw I;let k=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(c=e.options)===null||c===void 0?void 0:c.redirectTo,scopes:(h=e.options)===null||h===void 0?void 0:h.scopes,queryParams:(f=e.options)===null||f===void 0?void 0:f.queryParams,skipBrowserRedirect:!0});return await Ee(this.fetch,"GET",k,{headers:this.headers,jwt:(_=(m=E.session)===null||m===void 0?void 0:m.access_token)!==null&&_!==void 0?_:void 0})});if(s)throw s;return Pn()&&!(!((t=e.options)===null||t===void 0)&&t.skipBrowserRedirect)&&window.location.assign(r==null?void 0:r.url),{data:{provider:e.provider,url:r==null?void 0:r.url},error:null}}catch(r){if(ge(r))return{data:{provider:e.provider,url:null},error:r};throw r}}async unlinkIdentity(e){try{return await this._useSession(async t=>{var r,s;let{data:a,error:c}=t;if(c)throw c;return await Ee(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(s=(r=a.session)===null||r===void 0?void 0:r.access_token)!==null&&s!==void 0?s:void 0})})}catch(t){if(ge(t))return{data:null,error:t};throw t}}async _refreshAccessToken(e){let t=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(t,"begin");try{let r=Date.now();return await WE(async s=>(s>0&&await KE(200*Math.pow(2,s-1)),this._debug(t,"refreshing attempt",s),await Ee(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:Vr})),(s,a)=>{let c=200*Math.pow(2,s);return a&&pf(a)&&Date.now()+c-r<Zu})}catch(r){if(this._debug(t,"error",r),ge(r))return{data:{session:null,user:null},error:r};throw r}finally{this._debug(t,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,t){let r=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:t.redirectTo,scopes:t.scopes,queryParams:t.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",t,"url",r),Pn()&&!t.skipBrowserRedirect&&window.location.assign(r),{data:{provider:e,url:r},error:null}}async _recoverAndRefresh(){var e;let t="#_recoverAndRefresh()";this._debug(t,"begin");try{let r=await Wu(this.storage,this.storageKey);if(this._debug(t,"session from storage",r),!this._isValidSession(r)){this._debug(t,"session is not valid"),r!==null&&await this._removeSession();return}let s=Math.round(Date.now()/1e3),a=((e=r.expires_at)!==null&&e!==void 0?e:1/0)<s+Bg;if(this._debug(t,`session has${a?"":" not"} expired with margin of ${Bg}s`),a){if(this.autoRefreshToken&&r.refresh_token){let{error:c}=await this._callRefreshToken(r.refresh_token);c&&(console.error(c),pf(c)||(this._debug(t,"refresh failed with a non-retryable error, removing the session",c),await this._removeSession()))}}else await this._notifyAllSubscribers("SIGNED_IN",r)}catch(r){this._debug(t,"error",r),console.error(r);return}finally{this._debug(t,"end")}}async _callRefreshToken(e){var t,r;if(!e)throw new fn;if(this.refreshingDeferred)return this.refreshingDeferred.promise;let s=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{this.refreshingDeferred=new Ku;let{data:a,error:c}=await this._refreshAccessToken(e);if(c)throw c;if(!a.session)throw new fn;await this._saveSession(a.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",a.session);let h={session:a.session,error:null};return this.refreshingDeferred.resolve(h),h}catch(a){if(this._debug(s,"error",a),ge(a)){let c={session:null,error:a};return pf(a)||await this._removeSession(),(t=this.refreshingDeferred)===null||t===void 0||t.resolve(c),c}throw(r=this.refreshingDeferred)===null||r===void 0||r.reject(a),a}finally{this.refreshingDeferred=null,this._debug(s,"end")}}async _notifyAllSubscribers(e,t,r=!0){let s=`#_notifyAllSubscribers(${e})`;this._debug(s,"begin",t,`broadcast = ${r}`);try{this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:t});let a=[],c=Array.from(this.stateChangeEmitters.values()).map(async h=>{try{await h.callback(e,t)}catch(f){a.push(f)}});if(await Promise.all(c),a.length>0){for(let h=0;h<a.length;h+=1)console.error(a[h]);throw a[0]}}finally{this._debug(s,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await $g(this.storage,this.storageKey,e)}async _removeSession(){this._debug("#_removeSession()"),await Hu(this.storage,this.storageKey),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");let e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&Pn()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}catch(t){console.error("removing visibilitychange callback failed",t)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");let e=setInterval(()=>this._autoRefreshTokenTick(),Zu);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno!="undefined"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");let e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{let e=Date.now();try{return await this._useSession(async t=>{let{data:{session:r}}=t;if(!r||!r.refresh_token||!r.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}let s=Math.floor((r.expires_at*1e3-e)/Zu);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts ${Zu}ms, refresh threshold is ${iI} ticks`),s<=iI&&await this._callRefreshToken(r.refresh_token)})}catch(t){console.error("Auto refresh tick failed with error. This is likely a transient error.",t)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof Xu)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Pn()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){let t=`#_onVisibilityChanged(${e})`;this._debug(t,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(t,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,t,r){let s=[`provider=${encodeURIComponent(t)}`];if(r!=null&&r.redirectTo&&s.push(`redirect_to=${encodeURIComponent(r.redirectTo)}`),r!=null&&r.scopes&&s.push(`scopes=${encodeURIComponent(r.scopes)}`),this.flowType==="pkce"){let[a,c]=await Es(this.storage,this.storageKey),h=new URLSearchParams({code_challenge:`${encodeURIComponent(a)}`,code_challenge_method:`${encodeURIComponent(c)}`});s.push(h.toString())}if(r!=null&&r.queryParams){let a=new URLSearchParams(r.queryParams);s.push(a.toString())}return r!=null&&r.skipBrowserRedirect&&s.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${e}?${s.join("&")}`}async _unenroll(e){try{return await this._useSession(async t=>{var r;let{data:s,error:a}=t;return a?{data:null,error:a}:await Ee(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(r=s==null?void 0:s.session)===null||r===void 0?void 0:r.access_token})})}catch(t){if(ge(t))return{data:null,error:t};throw t}}async _enroll(e){try{return await this._useSession(async t=>{var r,s;let{data:a,error:c}=t;if(c)return{data:null,error:c};let h=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:{issuer:e.issuer}),{data:f,error:m}=await Ee(this.fetch,"POST",`${this.url}/factors`,{body:h,headers:this.headers,jwt:(r=a==null?void 0:a.session)===null||r===void 0?void 0:r.access_token});return m?{data:null,error:m}:(e.factorType==="totp"&&(!((s=f==null?void 0:f.totp)===null||s===void 0)&&s.qr_code)&&(f.totp.qr_code=`data:image/svg+xml;utf-8,${f.totp.qr_code}`),{data:f,error:null})})}catch(t){if(ge(t))return{data:null,error:t};throw t}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var r;let{data:s,error:a}=t;if(a)return{data:null,error:a};let{data:c,error:h}=await Ee(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:(r=s==null?void 0:s.session)===null||r===void 0?void 0:r.access_token});return h?{data:null,error:h}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+c.expires_in},c)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",c),{data:c,error:h})})}catch(t){if(ge(t))return{data:null,error:t};throw t}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var r;let{data:s,error:a}=t;return a?{data:null,error:a}:await Ee(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:{channel:e.channel},headers:this.headers,jwt:(r=s==null?void 0:s.session)===null||r===void 0?void 0:r.access_token})})}catch(t){if(ge(t))return{data:null,error:t};throw t}})}async _challengeAndVerify(e){let{data:t,error:r}=await this._challenge({factorId:e.factorId});return r?{data:null,error:r}:await this._verify({factorId:e.factorId,challengeId:t.id,code:e.code})}async _listFactors(){let{data:{user:e},error:t}=await this.getUser();if(t)return{data:null,error:t};let r=(e==null?void 0:e.factors)||[],s=r.filter(c=>c.factor_type==="totp"&&c.status==="verified"),a=r.filter(c=>c.factor_type==="phone"&&c.status==="verified");return{data:{all:r,totp:s,phone:a},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async e=>{var t,r;let{data:{session:s},error:a}=e;if(a)return{data:null,error:a};if(!s)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};let c=this._decodeJWT(s.access_token),h=null;c.aal&&(h=c.aal);let f=h;((r=(t=s.user.factors)===null||t===void 0?void 0:t.filter(E=>E.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(f="aal2");let _=c.amr||[];return{data:{currentLevel:h,nextLevel:f,currentAuthenticationMethods:_},error:null}}))}};Ps.nextInstanceID=0;var AU=Ps,Wg=AU;var gf=class extends Wg{constructor(e){super(e)}};var SU=function(n,e,t,r){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(r.next(_))}catch(E){c(E)}}function f(_){try{m(r.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((r=r.apply(n,e||[])).next())})},ec=class{constructor(e,t,r){var s,a,c;if(this.supabaseUrl=e,this.supabaseKey=t,!e)throw new Error("supabaseUrl is required.");if(!t)throw new Error("supabaseKey is required.");let h=ME(e);this.realtimeUrl=`${h}/realtime/v1`.replace(/^http/i,"ws"),this.authUrl=`${h}/auth/v1`,this.storageUrl=`${h}/storage/v1`,this.functionsUrl=`${h}/functions/v1`;let f=`sb-${new URL(this.authUrl).hostname.split(".")[0]}-auth-token`,m={db:kE,realtime:VE,auth:Object.assign(Object.assign({},NE),{storageKey:f}),global:OE},_=FE(r!=null?r:{},m);this.storageKey=(s=_.auth.storageKey)!==null&&s!==void 0?s:"",this.headers=(a=_.global.headers)!==null&&a!==void 0?a:{},_.accessToken?(this.accessToken=_.accessToken,this.auth=new Proxy({},{get:(E,I)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(I)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((c=_.auth)!==null&&c!==void 0?c:{},this.headers,_.global.fetch),this.fetch=LE(t,this._getAccessToken.bind(this),_.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},_.realtime)),this.rest=new _E(`${h}/rest/v1`,{headers:this.headers,schema:_.db.schema,fetch:this.fetch}),_.accessToken||this._listenForAuthEvents()}get functions(){return new Ou(this.functionsUrl,{headers:this.headers,customFetch:this.fetch})}get storage(){return new qu(this.storageUrl,this.headers,this.fetch)}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,t={},r={}){return this.rest.rpc(e,t,r)}channel(e,t={config:{}}){return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var e,t;return SU(this,void 0,void 0,function*(){if(this.accessToken)return yield this.accessToken();let{data:r}=yield this.auth.getSession();return(t=(e=r.session)===null||e===void 0?void 0:e.access_token)!==null&&t!==void 0?t:null})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,storageKey:a,flowType:c,lock:h,debug:f},m,_){let E={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new gf({url:this.authUrl,headers:Object.assign(Object.assign({},E),m),storageKey:a,autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,flowType:c,lock:h,debug:f,fetch:_,hasCustomAuthorizationHeader:"Authorization"in this.headers})}_initRealtimeClient(e){return new ia(this.realtimeUrl,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e==null?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,r)=>{this._handleTokenChanged(t,"CLIENT",r==null?void 0:r.access_token)})}_handleTokenChanged(e,t,r){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==r?this.changedAccessToken=r:e==="SIGNED_OUT"&&(this.realtime.setAuth(),t=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};var oI=(n,e,t)=>new ec(n,e,t);var yI=Cd(lI(),1);var hI={id:"~date",test:n=>n instanceof Date,serialize:n=>({_:"~date",v:n.toISOString()}),deserialize:n=>new Date(n.v)};var fI={id:"~function",test:n=>typeof n=="function",serialize:n=>({_:"~function",v:n.toString()}),deserialize:v=>eval(v.v.toString())};var dI={id:"~infinity",test:n=>n===1/0||n===-1/0,serialize:n=>({_:"~infinity",v:n===1/0?1:0}),deserialize:n=>n.v==1?1/0:-1/0};var pI={id:"~nan",test:n=>Number.isNaN(n),serialize:n=>({_:"~nan"}),deserialize:n=>NaN};var mI={id:"~regexp",test:n=>n instanceof RegExp,serialize:n=>({_:"~regexp",v:n.source,f:n.flags}),deserialize:n=>new RegExp(n.v,n.f)};var gI={id:"~set",test:n=>n instanceof Set,serialize:n=>({_:"~set",v:Array.from(n)}),deserialize:n=>new Set(n.v)};var _I={id:"~undefined",test:n=>n===void 0,serialize:n=>({_:"~undefined"}),deserialize:n=>{}};var fa={settings:{stringify:!0,destringify:!0,clone:!1,depth:0,modules:[hI,fI,dI,pI,mI,gI,_I],circular:!0,symetric:!1},loadedModules:{},loadModules(n){return n.map(e=>{if(De(e)){if(!e.id)throw new Error("Provided custom module does not expose an `id` property");return fa.loadedModules[e.id]=e}else throw new Error("Unknown module type")})},serialize(n,e){let t=ql(e,fa.settings),r=fa.loadModules(t.modules),s=t.symetric?(0,yI.keyArrangeDeep)(n):t.clone?zn(n):n,a=new Map,c=(h,f)=>{let m=De(h);if(m&&t.circular){let I=a.get(h);if(I)return pi(s,f,{_:"~circular",p:I.join(".")});a.set(h,f)}let _=r.find(I=>I.test(h)),E=(!t.depth||f.length<t.depth)&&m;if(_){let I=_.serialize(h);if(_.recursive&&E){let k=It(h);t.symetric&&k.sort(),pi(s,f,I),k.forEach(B=>c(h[B],f.concat(B)))}else f.length?pi(s,f,I):s=I}else if(E){let I=It(h);t.symetric&&I.sort(),I.forEach(k=>c(h[k],f.concat(k)))}};return c(s,[]),t.stringify?JSON.stringify(s):s},deserialize(n,e){let t=ql(e,fa.settings),r=fa.loadModules(t.modules),s=Fd(r,"id"),a=t.destringify?JSON.parse(n):t.clone?zn(n):n,c=(h,f)=>{if(De(h)&&h._&&h._.startsWith("~")&&s[h._]){let m=s[h._].deserialize(h);f.length?s[h._].recursive&&De(m)?(pi(a,f,m),It(m).forEach(_=>c(h[_],[...f,_]))):pi(a,f,m):a=m}else t.circular&&De(h)&&h._&&h._=="~circular"?pi(a,f,tu(a,h.p)):(!t.depth||f.length<t.depth)&&De(h)&&It(h).forEach(m=>c(h[m],f.concat(m)))};return c(a,[]),a}},nc=fa;var wt=class wt{constructor(e,t){jt(this,"path");jt(this,"docRef");jt(this,"value");jt(this,"throttle",250);this.path=e,Object.assign(this,t)}debug(...e){}getReactive(e){console.warn("Syncro.getReactive has not been subclassed, assuming a POJO response");let t={...e};return{doc:t,setState(r){Object.entries(r||{}).forEach(([s,a])=>t[s]=a)},getState(){return zn(t)},watch(r){}}}static pathSplit(e){var r;let t={...(r=/^(?<entity>\w+?)::(?<id>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:::(?<relation>\w+?))?$/.exec(e))==null?void 0:r.groups};if(!t)throw new Error(`Invalid session path syntax "${e}"`);if(!t.entity in Qg)throw new Error(`Unsupported entity "${e}" -> Entity="${t.entity}"`);return{...t,fsCollection:t.entity,fsId:t.relation?`${t.id}::${t.relation}`:t.id}}static toFirestore(e={}){return nc.serialize(this.cleanPojo(e),{clone:!0,modules:[vI,...nc.settings.modules],stringify:!1})}static fromFirestore(e={}){return nc.deserialize(this.cleanPojo(e),{modules:[vI,...nc.settings.modules],destringify:!1})}static getSnapshot(e){let{fsCollection:t,fsId:r}=wt.pathSplit(e);return Promise.resolve().then(async()=>{let s=Hh(wt.firestore,t,r);return vg(s)}).then(s=>s?wt.fromFirestore(snapshot.data()):null)}static setSnapshot(e,t,r){let s={method:"merge",...r},{fsCollection:a,fsId:c}=wt.pathSplit(e);return Promise.resolve().then(()=>(s.method=="merge"?"FirestoreUpdateDoc":"FirestoreSetDoc")(Hh(this.firestore,a,c),wt.toFirestore(t))).then(()=>t)}static cleanPojo(e){return Object.fromEntries(Object.entries(e).filter(([t])=>!/^[\$_]/.test(t)&&t!=="metadata"))}static wrapSupabase(e){return Promise.resolve(e).then(t=>{var r,s;if(t!=null&&t.error)throw/JSON object requested, multiple \(or no\) rows returned$/.test(t.error.message)?(console.warn("Supabase query threw record not found against query",e.url.search),console.warn("Supabase raw error",t),new Error("NOT-FOUND")):(console.warn("Supabase query threw",t.error.message),new Error(`${((r=t.error)==null?void 0:r.code)||"UnknownError"}: ${((s=t.error)==null?void 0:s.message)||"Unknown Supabase error"}`));if(t.data)return t.data})}mount(){let{fsCollection:e,fsId:t,entity:r,id:s,relation:a}=wt.pathSplit(this.path),c,h;return Promise.resolve().then(async()=>{this.docRef=Hh(wt.firestore,e,t);let f=wt.fromFirestore((await vg(this.docRef)).data());if(c=this.getReactive(f),!c.doc||!c.setState||!c.getState||!c.watch)throw new Error("Syncro.getReactive() requires a returned `doc`, `setState()`, `getState()` + `watch()`");this.value=h=c.doc,this.debug("Initial state",{doc:h}),eE(this.docRef,m=>{let _=wt.fromFirestore(m.data());this.debug("Incoming snapshot",{snapshotData:_}),c.setState(_)})}).then(()=>{if(Md(h))return this.debug("Populate initial state"),Promise.resolve().then(()=>Qg[r]||Promise.reject(`Unknown Sync entity "${r}"`)).then(()=>Qg[r].initState({supabase:wt.supabase,entity:r,id:s,relation:a})).then(f=>XT(this.docRef,wt.toFirestore(f)))}).then(()=>{c.watch(Ud(f=>{this.debug("Local change",{newState:f}),ZT(this.docRef,wt.toFirestore(f))},this.throttle))}).then(()=>this)}};jt(wt,"firebase"),jt(wt,"firestore"),jt(wt,"supabase");var dn=wt,Qg={projects:{singular:"project",initState({supabase:n,id:e}){return dn.wrapSupabase(n.from("projects").select("data").limit(1).eq("id",e)).then(t=>t.length==1?t[0]:Promise.reject(`Syncro project "${e}" not found`)).then(t=>t.data)}},project_namespaces:{singular:"project namespace",initState({supabase:n,id:e,relation:t}){if(!t)throw new Error('Project namespace relation missing, path should resemble "project_namespaces::${PROJECT}::${RELATION}"');return dn.wrapSupabase(n.from("project_namespaces").select("data").limit(1).eq("project",e).eq("name",t)).then(r=>r.length==1?r[0]:Promise.reject(`Syncro project ("${e}") namespace ("${t}") not found`)).then(r=>r.data)}},test:{singular:"test",initState({supabase:n,id:e}){return dn.wrapSupabase(n.from("test").select("data").limit(1).eq("id",e)).then(t=>t.length==1?t[0]:Promise.reject(`Syncro test item "${e}" not found`)).then(t=>t.data)}},users:{singular:"user",initState({supabase:n,id:e}){return dn.wrapSupabase(n.from("users").select("data").limit(1).eq("id",e)).then(t=>t.length==1?t[0]:Promise.reject(`Syncro user "${e}" not found`)).then(t=>t.data)}}},vI={id:"~array",recursive:!0,test:n=>Array.isArray(n),serialize:n=>({_:"~array",...n}),deserialize:n=>{let e=Array.from({length:Object.keys(n).length-1});return Object.entries(n).filter(([t])=>t!=="_").forEach(([t,r])=>e[+t]=r),e}};var rc=class{init(){}constructor(e,t){}};var ic=class extends rc{constructor(){super(...arguments);jt(this,"syncros",{})}async init(t){let r={firebaseApiKey:null,firebaseAuthDomain:null,firebaseProjectId:null,firebaseAppId:null,supabaseUrl:null,supabaseKey:null,...await this.getCredentials(),...t},s=Object.keys(r).filter(a=>a===null);if(s.length>0)throw new Error("Firebase plugin requires mandatory options: "+s.join(", "));dn.firebase=ip({apiKey:r.firebaseApiKey,authDomain:r.firebaseAuthDomain,projectId:r.firebaseProjectId,appId:r.firebaseAppId}),dn.firestore=GT(this.firebase),dn.supabase=oI(r.supabaseUrl,r.supabaseKey)}_mountNamespace(t){let r;return Promise.resolve().then(()=>this.requireProject()).then(s=>{let a=t=="_PROJECT"?`projects::${s.id}`:`project_namespaces::${s.id}::${t}`;return r=this.syncros[t]=new dn(a,{debug:(...c)=>this.debug(`SYNCRO://${a}`,...c),getReactive:this.getReactive}),r.mount()}).then(()=>{this.namespaces[t]=r.value})}_unmountNamespace(t){let r=this.syncros[t];return delete this.namespaces[t],delete this.syncros[t],r.destroy()}};var Jg=class extends ic{constructor(){super(...arguments);jt(this,"Vue");jt(this,"project",null);jt(this,"reactiveId",1001)}async init(t){let r={app:null,Vue:null,globalName:"$tera",...t};if(!r.Vue)throw new Error("Vue instance to use must be specified in init options as `Vue`");if(this.Vue=r.Vue,!r.app)throw new Error("Vue Root / App instance to use must be specified in init options as `app`");this.app=r.app,r.globalName&&(this.Vue.prototype[r.globalName]=this),await super.init(r),this.project=await this.mountNamespace("_PROJECT")}getReactive(t){let r=this.Vue.observable(t),s=`_teraFy_${this.reactiveId++}`;return this.app[s]=r,{doc:r,setState(a){Object.entries(a||{}).forEach(([c,h])=>r[c]=h)},getState(){return zn(r)},watch:a=>{this.app.$watch(s,a,{deep:!0})}}}bindProjectState(t){let r={component:null,componentKey:null,autoRequire:!0,read:!0,write:!0,throttle:{wait:200,maxWait:2e3,leading:!1,trailing:!0},...t};return Promise.resolve().then(()=>Promise.all([this.getProjectState({autoRequire:r.autoRequire}),(()=>{if(!r.componentKey){for(let s=0;s<50;s++){let a=`terafy_${s}`;if(!Object.hasOwnProperty(r.component,a)){r.componentKey=a;return}}throw new Error("Unable to find unique key to allocate against Vue2 component")}})()])).then(([s])=>{this.debug("INFO",2,"Got project snapshot",s);let a=this.Vue.observable(s);if(r.component[r.componentKey]=a,r.read&&this.events.on(`update:projects/${a.id}`,c=>{var h;(h=c==null?void 0:c.lastPatch)!=null&&h.session&&c.lastPatch.session==this.settings.session||(this.debug("INFO",5,"Update Vue2 Remote->Local",{new:c,old:a}),this.merge(a,c))}),r.write){if(!r.component)throw new Error("bindProjectState requires a VueComponent specified as `component`");let c=zn(s),h=()=>{let f=zn(s);this.debug("INFO",5,"Update Vue2 Local->Remote",{new:f,old:c}),this.createProjectStatePatch(f,c),c=f};r.component.$watch(r.componentKey,r.throttle?debounce(h,r.throttle.wait,r.throttle):h,{deep:!0})}return a})}merge(t,...r){return r.forEach(s=>Object.keys(s).forEach(a=>{isPlainObject(s[a])?(a in t||this.Vue.set(t,a,{}),this.merge(t[a],s[a])):this.Vue.set(t,a,s[a])})),t}};export{Jg as default};
46
+ });`,sa=class{constructor(e,t){var n;this.accessTokenValue=null,this.apiKey=null,this.channels=[],this.endPoint="",this.httpEndpoint="",this.headers=wE,this.params={},this.timeout=of,this.heartbeatIntervalMs=3e4,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.ref=0,this.logger=iU,this.conn=null,this.sendBuffer=[],this.serializer=new ju,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._resolveFetch=a=>{let c;return a?c=a:typeof fetch=="undefined"?c=(...h)=>Promise.resolve().then(()=>(Ei(),gs)).then(({default:f})=>f(...h)):c=fetch,(...h)=>c(...h)},this.endPoint=`${e}/${sf.websocket}`,this.httpEndpoint=af(e),t!=null&&t.transport?this.transport=t.transport:this.transport=null,t!=null&&t.params&&(this.params=t.params),t!=null&&t.headers&&(this.headers=Object.assign(Object.assign({},this.headers),t.headers)),t!=null&&t.timeout&&(this.timeout=t.timeout),t!=null&&t.logger&&(this.logger=t.logger),t!=null&&t.heartbeatIntervalMs&&(this.heartbeatIntervalMs=t.heartbeatIntervalMs);let s=(n=t==null?void 0:t.params)===null||n===void 0?void 0:n.apikey;if(s&&(this.accessTokenValue=s,this.apiKey=s),this.reconnectAfterMs=t!=null&&t.reconnectAfterMs?t.reconnectAfterMs:a=>[1e3,2e3,5e3,1e4][a-1]||1e4,this.encode=t!=null&&t.encode?t.encode:(a,c)=>c(JSON.stringify(a)),this.decode=t!=null&&t.decode?t.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new ys(async()=>{this.disconnect(),this.connect()},this.reconnectAfterMs),this.fetch=this._resolveFetch(t==null?void 0:t.fetch),t!=null&&t.worker){if(typeof window!="undefined"&&!window.Worker)throw new Error("Web Worker is not supported");this.worker=(t==null?void 0:t.worker)||!1,this.workerUrl=t==null?void 0:t.workerUrl}this.accessToken=(t==null?void 0:t.accessToken)||null}connect(){if(!this.conn){if(this.transport){this.conn=new this.transport(this.endpointURL(),void 0,{headers:this.headers});return}if(sU){this.conn=new WebSocket(this.endpointURL()),this.setupConnection();return}this.conn=new Bg(this.endpointURL(),void 0,{close:()=>{this.conn=null}}),Promise.resolve().then(()=>Dd(xE())).then(({default:e})=>{this.conn=new e(this.endpointURL(),void 0,{headers:this.headers}),this.setupConnection()})}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:bE}))}disconnect(e,t){this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,t!=null?t:""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset())}getChannels(){return this.channels}async removeChannel(e){let t=await e.unsubscribe();return this.channels.length===0&&this.disconnect(),t}async removeAllChannels(){let e=await Promise.all(this.channels.map(t=>t.unsubscribe()));return this.disconnect(),e}log(e,t,n){this.logger(e,t,n)}connectionState(){switch(this.conn&&this.conn.readyState){case _s.connecting:return Ii.Connecting;case _s.open:return Ii.Open;case _s.closing:return Ii.Closing;default:return Ii.Closed}}isConnected(){return this.connectionState()===Ii.Open}channel(e,t={config:{}}){let n=new ia(`realtime:${e}`,t,this);return this.channels.push(n),n}push(e){let{topic:t,event:n,payload:s,ref:a}=e,c=()=>{this.encode(e,h=>{var f;(f=this.conn)===null||f===void 0||f.send(h)})};this.log("push",`${t} ${n} (${a})`,s),this.isConnected()?c():this.sendBuffer.push(c)}async setAuth(e=null){let t=e||this.accessToken&&await this.accessToken()||this.accessTokenValue;if(t){let n=null;try{n=JSON.parse(atob(t.split(".")[1]))}catch{}if(n&&n.exp&&!(Math.floor(Date.now()/1e3)-n.exp<0))return this.log("auth",`InvalidJWTToken: Invalid value for JWT claim "exp" with value ${n.exp}`),Promise.reject(`InvalidJWTToken: Invalid value for JWT claim "exp" with value ${n.exp}`);this.accessTokenValue=t,this.channels.forEach(s=>{t&&s.updateJoinPayload({access_token:t}),s.joinedOnce&&s._isJoined()&&s._push(rr.access_token,{access_token:t})})}}async sendHeartbeat(){var e;if(this.isConnected()){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),(e=this.conn)===null||e===void 0||e.close(TE,"hearbeat timeout");return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.setAuth()}}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let t=this.channels.find(n=>n.topic===e&&(n._isJoined()||n._isJoining()));t&&(this.log("transport",`leaving duplicate topic "${e}"`),t.unsubscribe())}_remove(e){this.channels=this.channels.filter(t=>t._joinRef()!==e._joinRef())}setupConnection(){this.conn&&(this.conn.binaryType="arraybuffer",this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e))}_onConnMessage(e){this.decode(e.data,t=>{let{topic:n,event:s,payload:a,ref:c}=t;c&&c===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null),this.log("receive",`${a.status||""} ${n} ${s} ${c&&"("+c+")"||""}`,a),this.channels.filter(h=>h._isMember(n)).forEach(h=>h._trigger(s,a,c)),this.stateChangeCallbacks.message.forEach(h=>h(t))})}async _onConnOpen(){if(this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this.reconnectTimer.reset(),!this.worker)this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs);else{this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");let e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=t=>{this.log("worker","worker error",t.message),this.workerRef.terminate()},this.workerRef.onmessage=t=>{t.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}this.stateChangeCallbacks.open.forEach(e=>e())}_onConnClose(e){this.log("transport","close",e),this._triggerChanError(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(t=>t(e))}_onConnError(e){this.log("transport",e.message),this._triggerChanError(),this.stateChangeCallbacks.error.forEach(t=>t(e))}_triggerChanError(){this.channels.forEach(e=>e._trigger(rr.error))}_appendParams(e,t){if(Object.keys(t).length===0)return e;let n=e.match(/\?/)?"&":"?",s=new URLSearchParams(t);return`${e}${n}${s}`}_workerObjectUrl(e){let t;if(e)t=e;else{let n=new Blob([oU],{type:"application/javascript"});t=URL.createObjectURL(n)}return t}},Bg=class{constructor(e,t,n){this.binaryType="arraybuffer",this.onclose=()=>{},this.onerror=()=>{},this.onmessage=()=>{},this.onopen=()=>{},this.readyState=_s.connecting,this.send=()=>{},this.url=null,this.url=e,this.close=n.close}};var oa=class extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}};function at(r){return typeof r=="object"&&r!==null&&"__isStorageError"in r}var uf=class extends oa{constructor(e,t){super(e),this.name="StorageApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}},ws=class extends oa{constructor(e,t){super(e),this.name="StorageUnknownError",this.originalError=t}};var aU=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})},lf=r=>{let e;return r?e=r:typeof fetch=="undefined"?e=(...t)=>Promise.resolve().then(()=>(Ei(),gs)).then(({default:n})=>n(...t)):e=fetch,(...t)=>e(...t)},AE=()=>aU(void 0,void 0,void 0,function*(){return typeof Response=="undefined"?(yield Promise.resolve().then(()=>(Ei(),gs))).Response:Response}),cf=r=>{if(Array.isArray(r))return r.map(t=>cf(t));if(typeof r=="function"||r!==Object(r))return r;let e={};return Object.entries(r).forEach(([t,n])=>{let s=t.replace(/([-_][a-z])/gi,a=>a.toUpperCase().replace(/[-_]/g,""));e[s]=cf(n)}),e};var bs=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})},jg=r=>r.msg||r.message||r.error_description||r.error||JSON.stringify(r),uU=(r,e,t)=>bs(void 0,void 0,void 0,function*(){let n=yield AE();r instanceof n&&!(t!=null&&t.noResolveJson)?r.json().then(s=>{e(new uf(jg(s),r.status||500))}).catch(s=>{e(new ws(jg(s),s))}):e(new ws(jg(r),r))}),cU=(r,e,t,n)=>{let s={method:r,headers:(e==null?void 0:e.headers)||{}};return r==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json"},e==null?void 0:e.headers),n&&(s.body=JSON.stringify(n)),Object.assign(Object.assign({},s),t))};function $u(r,e,t,n,s,a){return bs(this,void 0,void 0,function*(){return new Promise((c,h)=>{r(t,cU(e,n,s,a)).then(f=>{if(!f.ok)throw f;return n!=null&&n.noResolveJson?f:f.json()}).then(f=>c(f)).catch(f=>uU(f,h,n))})})}function aa(r,e,t,n){return bs(this,void 0,void 0,function*(){return $u(r,"GET",e,t,n)})}function en(r,e,t,n,s){return bs(this,void 0,void 0,function*(){return $u(r,"POST",e,n,s,t)})}function SE(r,e,t,n,s){return bs(this,void 0,void 0,function*(){return $u(r,"PUT",e,n,s,t)})}function RE(r,e,t,n){return bs(this,void 0,void 0,function*(){return $u(r,"HEAD",e,Object.assign(Object.assign({},t),{noResolveJson:!0}),n)})}function hf(r,e,t,n,s){return bs(this,void 0,void 0,function*(){return $u(r,"DELETE",e,n,s,t)})}var Kt=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})},lU={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},PE={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1},qu=class{constructor(e,t={},n,s){this.url=e,this.headers=t,this.bucketId=n,this.fetch=lf(s)}uploadOrUpdate(e,t,n,s){return Kt(this,void 0,void 0,function*(){try{let a,c=Object.assign(Object.assign({},PE),s),h=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(c.upsert)}),f=c.metadata;typeof Blob!="undefined"&&n instanceof Blob?(a=new FormData,a.append("cacheControl",c.cacheControl),f&&a.append("metadata",this.encodeMetadata(f)),a.append("",n)):typeof FormData!="undefined"&&n instanceof FormData?(a=n,a.append("cacheControl",c.cacheControl),f&&a.append("metadata",this.encodeMetadata(f))):(a=n,h["cache-control"]=`max-age=${c.cacheControl}`,h["content-type"]=c.contentType,f&&(h["x-metadata"]=this.toBase64(this.encodeMetadata(f)))),s!=null&&s.headers&&(h=Object.assign(Object.assign({},h),s.headers));let m=this._removeEmptyFolders(t),_=this._getFinalPath(m),E=yield this.fetch(`${this.url}/object/${_}`,Object.assign({method:e,body:a,headers:h},c!=null&&c.duplex?{duplex:c.duplex}:{})),I=yield E.json();return E.ok?{data:{path:m,id:I.Id,fullPath:I.Key},error:null}:{data:null,error:I}}catch(a){if(at(a))return{data:null,error:a};throw a}})}upload(e,t,n){return Kt(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,t,n)})}uploadToSignedUrl(e,t,n,s){return Kt(this,void 0,void 0,function*(){let a=this._removeEmptyFolders(e),c=this._getFinalPath(a),h=new URL(this.url+`/object/upload/sign/${c}`);h.searchParams.set("token",t);try{let f,m=Object.assign({upsert:PE.upsert},s),_=Object.assign(Object.assign({},this.headers),{"x-upsert":String(m.upsert)});typeof Blob!="undefined"&&n instanceof Blob?(f=new FormData,f.append("cacheControl",m.cacheControl),f.append("",n)):typeof FormData!="undefined"&&n instanceof FormData?(f=n,f.append("cacheControl",m.cacheControl)):(f=n,_["cache-control"]=`max-age=${m.cacheControl}`,_["content-type"]=m.contentType);let E=yield this.fetch(h.toString(),{method:"PUT",body:f,headers:_}),I=yield E.json();return E.ok?{data:{path:a,fullPath:I.Key},error:null}:{data:null,error:I}}catch(f){if(at(f))return{data:null,error:f};throw f}})}createSignedUploadUrl(e,t){return Kt(this,void 0,void 0,function*(){try{let n=this._getFinalPath(e),s=Object.assign({},this.headers);t!=null&&t.upsert&&(s["x-upsert"]="true");let a=yield en(this.fetch,`${this.url}/object/upload/sign/${n}`,{},{headers:s}),c=new URL(this.url+a.url),h=c.searchParams.get("token");if(!h)throw new oa("No token returned by API");return{data:{signedUrl:c.toString(),path:e,token:h},error:null}}catch(n){if(at(n))return{data:null,error:n};throw n}})}update(e,t,n){return Kt(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,t,n)})}move(e,t,n){return Kt(this,void 0,void 0,function*(){try{return{data:yield en(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers}),error:null}}catch(s){if(at(s))return{data:null,error:s};throw s}})}copy(e,t,n){return Kt(this,void 0,void 0,function*(){try{return{data:{path:(yield en(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers})).Key},error:null}}catch(s){if(at(s))return{data:null,error:s};throw s}})}createSignedUrl(e,t,n){return Kt(this,void 0,void 0,function*(){try{let s=this._getFinalPath(e),a=yield en(this.fetch,`${this.url}/object/sign/${s}`,Object.assign({expiresIn:t},n!=null&&n.transform?{transform:n.transform}:{}),{headers:this.headers}),c=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return a={signedUrl:encodeURI(`${this.url}${a.signedURL}${c}`)},{data:a,error:null}}catch(s){if(at(s))return{data:null,error:s};throw s}})}createSignedUrls(e,t,n){return Kt(this,void 0,void 0,function*(){try{let s=yield en(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers}),a=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return{data:s.map(c=>Object.assign(Object.assign({},c),{signedUrl:c.signedURL?encodeURI(`${this.url}${c.signedURL}${a}`):null})),error:null}}catch(s){if(at(s))return{data:null,error:s};throw s}})}download(e,t){return Kt(this,void 0,void 0,function*(){let s=typeof(t==null?void 0:t.transform)!="undefined"?"render/image/authenticated":"object",a=this.transformOptsToQueryString((t==null?void 0:t.transform)||{}),c=a?`?${a}`:"";try{let h=this._getFinalPath(e);return{data:yield(yield aa(this.fetch,`${this.url}/${s}/${h}${c}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(h){if(at(h))return{data:null,error:h};throw h}})}info(e){return Kt(this,void 0,void 0,function*(){let t=this._getFinalPath(e);try{let n=yield aa(this.fetch,`${this.url}/object/info/${t}`,{headers:this.headers});return{data:cf(n),error:null}}catch(n){if(at(n))return{data:null,error:n};throw n}})}exists(e){return Kt(this,void 0,void 0,function*(){let t=this._getFinalPath(e);try{return yield RE(this.fetch,`${this.url}/object/${t}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(at(n)&&n instanceof ws){let s=n.originalError;if([400,404].includes(s==null?void 0:s.status))return{data:!1,error:n}}throw n}})}getPublicUrl(e,t){let n=this._getFinalPath(e),s=[],a=t!=null&&t.download?`download=${t.download===!0?"":t.download}`:"";a!==""&&s.push(a);let h=typeof(t==null?void 0:t.transform)!="undefined"?"render/image":"object",f=this.transformOptsToQueryString((t==null?void 0:t.transform)||{});f!==""&&s.push(f);let m=s.join("&");return m!==""&&(m=`?${m}`),{data:{publicUrl:encodeURI(`${this.url}/${h}/public/${n}${m}`)}}}remove(e){return Kt(this,void 0,void 0,function*(){try{return{data:yield hf(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(t){if(at(t))return{data:null,error:t};throw t}})}list(e,t,n){return Kt(this,void 0,void 0,function*(){try{let s=Object.assign(Object.assign(Object.assign({},lU),t),{prefix:e||""});return{data:yield en(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},n),error:null}}catch(s){if(at(s))return{data:null,error:s};throw s}})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return typeof Buffer!="undefined"?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){let t=[];return e.width&&t.push(`width=${e.width}`),e.height&&t.push(`height=${e.height}`),e.resize&&t.push(`resize=${e.resize}`),e.format&&t.push(`format=${e.format}`),e.quality&&t.push(`quality=${e.quality}`),t.join("&")}};var CE="2.7.1";var DE={"X-Client-Info":`storage-js/${CE}`};var ua=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})},zu=class{constructor(e,t={},n){this.url=e,this.headers=Object.assign(Object.assign({},DE),t),this.fetch=lf(n)}listBuckets(){return ua(this,void 0,void 0,function*(){try{return{data:yield aa(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(at(e))return{data:null,error:e};throw e}})}getBucket(e){return ua(this,void 0,void 0,function*(){try{return{data:yield aa(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(t){if(at(t))return{data:null,error:t};throw t}})}createBucket(e,t={public:!1}){return ua(this,void 0,void 0,function*(){try{return{data:yield en(this.fetch,`${this.url}/bucket`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if(at(n))return{data:null,error:n};throw n}})}updateBucket(e,t){return ua(this,void 0,void 0,function*(){try{return{data:yield SE(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if(at(n))return{data:null,error:n};throw n}})}emptyBucket(e){return ua(this,void 0,void 0,function*(){try{return{data:yield en(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(t){if(at(t))return{data:null,error:t};throw t}})}deleteBucket(e){return ua(this,void 0,void 0,function*(){try{return{data:yield hf(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(t){if(at(t))return{data:null,error:t};throw t}})}};var Gu=class extends zu{constructor(e,t={},n){super(e,t,n)}from(e){return new qu(this.url,this.headers,e,this.fetch)}};var OE="2.48.1";var Ku="";typeof Deno!="undefined"?Ku="deno":typeof document!="undefined"?Ku="web":typeof navigator!="undefined"&&navigator.product==="ReactNative"?Ku="react-native":Ku="node";var hU={"X-Client-Info":`supabase-js-${Ku}/${OE}`},kE={headers:hU},NE={schema:"public"},VE={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},LE={};Ei();var fU=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})},dU=r=>{let e;return r?e=r:typeof fetch=="undefined"?e=Tg:e=fetch,(...t)=>e(...t)},pU=()=>typeof Headers=="undefined"?Eg:Headers,ME=(r,e,t)=>{let n=dU(t),s=pU();return(a,c)=>fU(void 0,void 0,void 0,function*(){var h;let f=(h=yield e())!==null&&h!==void 0?h:r,m=new s(c==null?void 0:c.headers);return m.has("apikey")||m.set("apikey",r),m.has("Authorization")||m.set("Authorization",`Bearer ${f}`),n(a,Object.assign(Object.assign({},c),{headers:m}))})};var mU=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})};function FE(r){return r.replace(/\/$/,"")}function UE(r,e){let{db:t,auth:n,realtime:s,global:a}=r,{db:c,auth:h,realtime:f,global:m}=e,_={db:Object.assign(Object.assign({},c),t),auth:Object.assign(Object.assign({},h),n),realtime:Object.assign(Object.assign({},f),s),global:Object.assign(Object.assign({},m),a),accessToken:()=>mU(this,void 0,void 0,function*(){return""})};return r.accessToken?_.accessToken=r.accessToken:delete _.accessToken,_}var ff="2.67.3";var BE="http://localhost:9999",jE="supabase.auth.token";var $E={"X-Client-Info":`gotrue-js/${ff}`},$g=10;var Wu="X-Supabase-Api-Version",qg={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}};function qE(r){return Math.round(Date.now()/1e3)+r}function zE(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){let e=Math.random()*16|0;return(r=="x"?e:e&3|8).toString(16)})}var Rr=()=>typeof window!="undefined"&&typeof document!="undefined",Ts={tested:!1,writable:!1},xi=()=>{if(!Rr())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Ts.tested)return Ts.writable;let r=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(r,r),globalThis.localStorage.removeItem(r),Ts.tested=!0,Ts.writable=!0}catch{Ts.tested=!0,Ts.writable=!1}return Ts.writable};function GE(r){let e={},t=new URL(r);if(t.hash&&t.hash[0]==="#")try{new URLSearchParams(t.hash.substring(1)).forEach((s,a)=>{e[a]=s})}catch{}return t.searchParams.forEach((n,s)=>{e[s]=n}),e}var df=r=>{let e;return r?e=r:typeof fetch=="undefined"?e=(...t)=>Promise.resolve().then(()=>(Ei(),gs)).then(({default:n})=>n(...t)):e=fetch,(...t)=>e(...t)},KE=r=>typeof r=="object"&&r!==null&&"status"in r&&"ok"in r&&"json"in r&&typeof r.json=="function",zg=async(r,e,t)=>{await r.setItem(e,JSON.stringify(t))},Qu=async(r,e)=>{let t=await r.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch{return t}},Ju=async(r,e)=>{await r.removeItem(e)};function gU(r){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",t="",n,s,a,c,h,f,m,_=0;for(r=r.replace("-","+").replace("_","/");_<r.length;)c=e.indexOf(r.charAt(_++)),h=e.indexOf(r.charAt(_++)),f=e.indexOf(r.charAt(_++)),m=e.indexOf(r.charAt(_++)),n=c<<2|h>>4,s=(h&15)<<4|f>>2,a=(f&3)<<6|m,t=t+String.fromCharCode(n),f!=64&&s!=0&&(t=t+String.fromCharCode(s)),m!=64&&a!=0&&(t=t+String.fromCharCode(a));return t}var Hu=class r{constructor(){this.promise=new r.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}};Hu.promiseConstructor=Promise;function Gg(r){let e=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}=?$|[a-z0-9_-]{2}(==)?$)$/i,t=r.split(".");if(t.length!==3)throw new Error("JWT is not valid: not a JWT structure");if(!e.test(t[1]))throw new Error("JWT is not valid: payload is not in base64url format");let n=t[1];return JSON.parse(gU(n))}async function WE(r){return await new Promise(e=>{setTimeout(()=>e(null),r)})}function HE(r,e){return new Promise((n,s)=>{(async()=>{for(let a=0;a<1/0;a++)try{let c=await r(a);if(!e(a,null,c)){n(c);return}}catch(c){if(!e(a,c)){s(c);return}}})()})}function _U(r){return("0"+r.toString(16)).substr(-2)}function yU(){let e=new Uint32Array(56);if(typeof crypto=="undefined"){let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",n=t.length,s="";for(let a=0;a<56;a++)s+=t.charAt(Math.floor(Math.random()*n));return s}return crypto.getRandomValues(e),Array.from(e,_U).join("")}async function vU(r){let t=new TextEncoder().encode(r),n=await crypto.subtle.digest("SHA-256",t),s=new Uint8Array(n);return Array.from(s).map(a=>String.fromCharCode(a)).join("")}function wU(r){return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function bU(r){if(!(typeof crypto!="undefined"&&typeof crypto.subtle!="undefined"&&typeof TextEncoder!="undefined"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),r;let t=await vU(r);return wU(t)}async function Es(r,e,t=!1){let n=yU(),s=n;t&&(s+="/PASSWORD_RECOVERY"),await zg(r,`${e}-code-verifier`,s);let a=await bU(n);return[a,n===a?"plain":"s256"]}var TU=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function QE(r){let e=r.headers.get(Wu);if(!e||!e.match(TU))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}var Yu=class extends Error{constructor(e,t,n){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t,this.code=n}};function ge(r){return typeof r=="object"&&r!==null&&"__isAuthError"in r}var pf=class extends Yu{constructor(e,t,n){super(e,t,n),this.name="AuthApiError",this.status=t,this.code=n}};function JE(r){return ge(r)&&r.name==="AuthApiError"}var ca=class extends Yu{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}},Nn=class extends Yu{constructor(e,t,n,s){super(e,n,s),this.name=t,this.status=n}},fr=class extends Nn{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}};function YE(r){return ge(r)&&r.name==="AuthSessionMissingError"}var la=class extends Nn{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}},Is=class extends Nn{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}},xs=class extends Nn{constructor(e,t=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}};function XE(r){return ge(r)&&r.name==="AuthImplicitGrantRedirectError"}var Xu=class extends Nn{constructor(e,t=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}},ha=class extends Nn{constructor(e,t){super(e,"AuthRetryableFetchError",t,void 0)}};function mf(r){return ge(r)&&r.name==="AuthRetryableFetchError"}var Zu=class extends Nn{constructor(e,t,n){super(e,"AuthWeakPasswordError",t,"weak_password"),this.reasons=n}};var EU=function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t},As=r=>r.msg||r.message||r.error_description||r.error||JSON.stringify(r),IU=[502,503,504];async function ZE(r){var e;if(!KE(r))throw new ha(As(r),0);if(IU.includes(r.status))throw new ha(As(r),r.status);let t;try{t=await r.json()}catch(a){throw new ca(As(a),a)}let n,s=QE(r);if(s&&s.getTime()>=qg["2024-01-01"].timestamp&&typeof t=="object"&&t&&typeof t.code=="string"?n=t.code:typeof t=="object"&&t&&typeof t.error_code=="string"&&(n=t.error_code),n){if(n==="weak_password")throw new Zu(As(t),r.status,((e=t.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(n==="session_not_found")throw new fr}else if(typeof t=="object"&&t&&typeof t.weak_password=="object"&&t.weak_password&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.reasons.reduce((a,c)=>a&&typeof c=="string",!0))throw new Zu(As(t),r.status,t.weak_password.reasons);throw new pf(As(t),r.status||500,n)}var xU=(r,e,t,n)=>{let s={method:r,headers:(e==null?void 0:e.headers)||{}};return r==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e==null?void 0:e.headers),s.body=JSON.stringify(n),Object.assign(Object.assign({},s),t))};async function Ee(r,e,t,n){var s;let a=Object.assign({},n==null?void 0:n.headers);a[Wu]||(a[Wu]=qg["2024-01-01"].name),n!=null&&n.jwt&&(a.Authorization=`Bearer ${n.jwt}`);let c=(s=n==null?void 0:n.query)!==null&&s!==void 0?s:{};n!=null&&n.redirectTo&&(c.redirect_to=n.redirectTo);let h=Object.keys(c).length?"?"+new URLSearchParams(c).toString():"",f=await AU(r,e,t+h,{headers:a,noResolveJson:n==null?void 0:n.noResolveJson},{},n==null?void 0:n.body);return n!=null&&n.xform?n==null?void 0:n.xform(f):{data:Object.assign({},f),error:null}}async function AU(r,e,t,n,s,a){let c=xU(e,n,s,a),h;try{h=await r(t,Object.assign({},c))}catch(f){throw console.error(f),new ha(As(f),0)}if(h.ok||await ZE(h),n!=null&&n.noResolveJson)return h;try{return await h.json()}catch(f){await ZE(f)}}function Vn(r){var e;let t=null;SU(r)&&(t=Object.assign({},r),r.expires_at||(t.expires_at=qE(r.expires_in)));let n=(e=r.user)!==null&&e!==void 0?e:r;return{data:{session:t,user:n},error:null}}function Kg(r){let e=Vn(r);return!e.error&&r.weak_password&&typeof r.weak_password=="object"&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.message&&typeof r.weak_password.message=="string"&&r.weak_password.reasons.reduce((t,n)=>t&&typeof n=="string",!0)&&(e.data.weak_password=r.weak_password),e}function tn(r){var e;return{data:{user:(e=r.user)!==null&&e!==void 0?e:r},error:null}}function eI(r){return{data:r,error:null}}function tI(r){let{action_link:e,email_otp:t,hashed_token:n,redirect_to:s,verification_type:a}=r,c=EU(r,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),h={action_link:e,email_otp:t,hashed_token:n,redirect_to:s,verification_type:a},f=Object.assign({},c);return{data:{properties:h,user:f},error:null}}function rI(r){return r}function SU(r){return r.access_token&&r.refresh_token&&r.expires_in}var RU=function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t},Ss=class{constructor({url:e="",headers:t={},fetch:n}){this.url=e,this.headers=t,this.fetch=df(n),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)}}async signOut(e,t="global"){try{return await Ee(this.fetch,"POST",`${this.url}/logout?scope=${t}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(n){if(ge(n))return{data:null,error:n};throw n}}async inviteUserByEmail(e,t={}){try{return await Ee(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:tn})}catch(n){if(ge(n))return{data:{user:null},error:n};throw n}}async generateLink(e){try{let{options:t}=e,n=RU(e,["options"]),s=Object.assign(Object.assign({},n),t);return"newEmail"in n&&(s.new_email=n==null?void 0:n.newEmail,delete s.newEmail),await Ee(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:tI,redirectTo:t==null?void 0:t.redirectTo})}catch(t){if(ge(t))return{data:{properties:null,user:null},error:t};throw t}}async createUser(e){try{return await Ee(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:tn})}catch(t){if(ge(t))return{data:{user:null},error:t};throw t}}async listUsers(e){var t,n,s,a,c,h,f;try{let m={nextPage:null,lastPage:0,total:0},_=await Ee(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(t=e==null?void 0:e.page)===null||t===void 0?void 0:t.toString())!==null&&n!==void 0?n:"",per_page:(a=(s=e==null?void 0:e.perPage)===null||s===void 0?void 0:s.toString())!==null&&a!==void 0?a:""},xform:rI});if(_.error)throw _.error;let E=await _.json(),I=(c=_.headers.get("x-total-count"))!==null&&c!==void 0?c:0,k=(f=(h=_.headers.get("link"))===null||h===void 0?void 0:h.split(","))!==null&&f!==void 0?f:[];return k.length>0&&(k.forEach(B=>{let G=parseInt(B.split(";")[0].split("=")[1].substring(0,1)),j=JSON.parse(B.split(";")[1].split("=")[1]);m[`${j}Page`]=G}),m.total=parseInt(I)),{data:Object.assign(Object.assign({},E),m),error:null}}catch(m){if(ge(m))return{data:{users:[]},error:m};throw m}}async getUserById(e){try{return await Ee(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:tn})}catch(t){if(ge(t))return{data:{user:null},error:t};throw t}}async updateUserById(e,t){try{return await Ee(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:tn})}catch(n){if(ge(n))return{data:{user:null},error:n};throw n}}async deleteUser(e,t=!1){try{return await Ee(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:tn})}catch(n){if(ge(n))return{data:{user:null},error:n};throw n}}async _listFactors(e){try{let{data:t,error:n}=await Ee(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:s=>({data:{factors:s},error:null})});return{data:t,error:n}}catch(t){if(ge(t))return{data:null,error:t};throw t}}async _deleteFactor(e){try{return{data:await Ee(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(t){if(ge(t))return{data:null,error:t};throw t}}};var nI={getItem:r=>xi()?globalThis.localStorage.getItem(r):null,setItem:(r,e)=>{xi()&&globalThis.localStorage.setItem(r,e)},removeItem:r=>{xi()&&globalThis.localStorage.removeItem(r)}};function Wg(r={}){return{getItem:e=>r[e]||null,setItem:(e,t)=>{r[e]=t},removeItem:e=>{delete r[e]}}}function iI(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self!="undefined"&&(self.globalThis=self)}}var Rs={debug:!!(globalThis&&xi()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")},ec=class extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}},gf=class extends ec{};async function Hg(r,e,t){Rs.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",r,e);let n=new globalThis.AbortController;return e>0&&setTimeout(()=>{n.abort(),Rs.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",r)},e),await Promise.resolve().then(()=>globalThis.navigator.locks.request(r,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:n.signal},async s=>{if(s){Rs.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",r,s.name);try{return await t()}finally{Rs.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",r,s.name)}}else{if(e===0)throw Rs.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",r),new gf(`Acquiring an exclusive Navigator LockManager lock "${r}" immediately failed`);if(Rs.debug)try{let a=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(a,null," "))}catch(a){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",a)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await t()}}))}iI();var PU={url:BE,storageKey:jE,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:$E,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1},tc=30*1e3,sI=3;async function oI(r,e,t){return await t()}var Ps=class r{constructor(e){var t,n;this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=r.nextInstanceID,r.nextInstanceID+=1,this.instanceID>0&&Rr()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");let s=Object.assign(Object.assign({},PU),e);if(this.logDebugMessages=!!s.debug,typeof s.debug=="function"&&(this.logger=s.debug),this.persistSession=s.persistSession,this.storageKey=s.storageKey,this.autoRefreshToken=s.autoRefreshToken,this.admin=new Ss({url:s.url,headers:s.headers,fetch:s.fetch}),this.url=s.url,this.headers=s.headers,this.fetch=df(s.fetch),this.lock=s.lock||oI,this.detectSessionInUrl=s.detectSessionInUrl,this.flowType=s.flowType,this.hasCustomAuthorizationHeader=s.hasCustomAuthorizationHeader,s.lock?this.lock=s.lock:Rr()&&(!((t=globalThis==null?void 0:globalThis.navigator)===null||t===void 0)&&t.locks)?this.lock=Hg:this.lock=oI,this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},this.persistSession?s.storage?this.storage=s.storage:xi()?this.storage=nI:(this.memoryStorage={},this.storage=Wg(this.memoryStorage)):(this.memoryStorage={},this.storage=Wg(this.memoryStorage)),Rr()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(a){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",a)}(n=this.broadcastChannel)===null||n===void 0||n.addEventListener("message",async a=>{this._debug("received broadcast notification from other tab or client",a),await this._notifyAllSubscribers(a.data.event,a.data.session,!1)})}this.initialize()}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${ff}) ${new Date().toISOString()}`,...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var e;try{let t=GE(window.location.href),n="none";if(this._isImplicitGrantCallback(t)?n="implicit":await this._isPKCECallback(t)&&(n="pkce"),Rr()&&this.detectSessionInUrl&&n!=="none"){let{data:s,error:a}=await this._getSessionFromURL(t,n);if(a){if(this._debug("#_initialize()","error detecting session from URL",a),XE(a)){let f=(e=a.details)===null||e===void 0?void 0:e.code;if(f==="identity_already_exists"||f==="identity_not_found"||f==="single_identity_not_deletable")return{error:a}}return await this._removeSession(),{error:a}}let{session:c,redirectType:h}=s;return this._debug("#_initialize()","detected session in URL",c,"redirect type",h),await this._saveSession(c),setTimeout(async()=>{h==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",c):await this._notifyAllSubscribers("SIGNED_IN",c)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(t){return ge(t)?{error:t}:{error:new ca("Unexpected error during initialization",t)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var t,n,s;try{let a=await Ee(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(n=(t=e==null?void 0:e.options)===null||t===void 0?void 0:t.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.captchaToken}},xform:Vn}),{data:c,error:h}=a;if(h||!c)return{data:{user:null,session:null},error:h};let f=c.session,m=c.user;return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",f)),{data:{user:m,session:f},error:null}}catch(a){if(ge(a))return{data:{user:null,session:null},error:a};throw a}}async signUp(e){var t,n,s;try{let a;if("email"in e){let{email:_,password:E,options:I}=e,k=null,B=null;this.flowType==="pkce"&&([k,B]=await Es(this.storage,this.storageKey)),a=await Ee(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:I==null?void 0:I.emailRedirectTo,body:{email:_,password:E,data:(t=I==null?void 0:I.data)!==null&&t!==void 0?t:{},gotrue_meta_security:{captcha_token:I==null?void 0:I.captchaToken},code_challenge:k,code_challenge_method:B},xform:Vn})}else if("phone"in e){let{phone:_,password:E,options:I}=e;a=await Ee(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:_,password:E,data:(n=I==null?void 0:I.data)!==null&&n!==void 0?n:{},channel:(s=I==null?void 0:I.channel)!==null&&s!==void 0?s:"sms",gotrue_meta_security:{captcha_token:I==null?void 0:I.captchaToken}},xform:Vn})}else throw new Is("You must provide either an email or phone number and a password");let{data:c,error:h}=a;if(h||!c)return{data:{user:null,session:null},error:h};let f=c.session,m=c.user;return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",f)),{data:{user:m,session:f},error:null}}catch(a){if(ge(a))return{data:{user:null,session:null},error:a};throw a}}async signInWithPassword(e){try{let t;if("email"in e){let{email:a,password:c,options:h}=e;t=await Ee(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:a,password:c,gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken}},xform:Kg})}else if("phone"in e){let{phone:a,password:c,options:h}=e;t=await Ee(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:a,password:c,gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken}},xform:Kg})}else throw new Is("You must provide either an email or phone number and a password");let{data:n,error:s}=t;return s?{data:{user:null,session:null},error:s}:!n||!n.session||!n.user?{data:{user:null,session:null},error:new la}:(n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),{data:Object.assign({user:n.user,session:n.session},n.weak_password?{weakPassword:n.weak_password}:null),error:s})}catch(t){if(ge(t))return{data:{user:null,session:null},error:t};throw t}}async signInWithOAuth(e){var t,n,s,a;return await this._handleProviderSignIn(e.provider,{redirectTo:(t=e.options)===null||t===void 0?void 0:t.redirectTo,scopes:(n=e.options)===null||n===void 0?void 0:n.scopes,queryParams:(s=e.options)===null||s===void 0?void 0:s.queryParams,skipBrowserRedirect:(a=e.options)===null||a===void 0?void 0:a.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async _exchangeCodeForSession(e){let t=await Qu(this.storage,`${this.storageKey}-code-verifier`),[n,s]=(t!=null?t:"").split("/");try{let{data:a,error:c}=await Ee(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:n},xform:Vn});if(await Ju(this.storage,`${this.storageKey}-code-verifier`),c)throw c;return!a||!a.session||!a.user?{data:{user:null,session:null,redirectType:null},error:new la}:(a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",a.session)),{data:Object.assign(Object.assign({},a),{redirectType:s!=null?s:null}),error:c})}catch(a){if(ge(a))return{data:{user:null,session:null,redirectType:null},error:a};throw a}}async signInWithIdToken(e){try{let{options:t,provider:n,token:s,access_token:a,nonce:c}=e,h=await Ee(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:n,id_token:s,access_token:a,nonce:c,gotrue_meta_security:{captcha_token:t==null?void 0:t.captchaToken}},xform:Vn}),{data:f,error:m}=h;return m?{data:{user:null,session:null},error:m}:!f||!f.session||!f.user?{data:{user:null,session:null},error:new la}:(f.session&&(await this._saveSession(f.session),await this._notifyAllSubscribers("SIGNED_IN",f.session)),{data:f,error:m})}catch(t){if(ge(t))return{data:{user:null,session:null},error:t};throw t}}async signInWithOtp(e){var t,n,s,a,c;try{if("email"in e){let{email:h,options:f}=e,m=null,_=null;this.flowType==="pkce"&&([m,_]=await Es(this.storage,this.storageKey));let{error:E}=await Ee(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:h,data:(t=f==null?void 0:f.data)!==null&&t!==void 0?t:{},create_user:(n=f==null?void 0:f.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken},code_challenge:m,code_challenge_method:_},redirectTo:f==null?void 0:f.emailRedirectTo});return{data:{user:null,session:null},error:E}}if("phone"in e){let{phone:h,options:f}=e,{data:m,error:_}=await Ee(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:h,data:(s=f==null?void 0:f.data)!==null&&s!==void 0?s:{},create_user:(a=f==null?void 0:f.shouldCreateUser)!==null&&a!==void 0?a:!0,gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken},channel:(c=f==null?void 0:f.channel)!==null&&c!==void 0?c:"sms"}});return{data:{user:null,session:null,messageId:m==null?void 0:m.message_id},error:_}}throw new Is("You must provide either an email or phone number.")}catch(h){if(ge(h))return{data:{user:null,session:null},error:h};throw h}}async verifyOtp(e){var t,n;try{let s,a;"options"in e&&(s=(t=e.options)===null||t===void 0?void 0:t.redirectTo,a=(n=e.options)===null||n===void 0?void 0:n.captchaToken);let{data:c,error:h}=await Ee(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:a}}),redirectTo:s,xform:Vn});if(h)throw h;if(!c)throw new Error("An error occurred on token verification.");let f=c.session,m=c.user;return f!=null&&f.access_token&&(await this._saveSession(f),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",f)),{data:{user:m,session:f},error:null}}catch(s){if(ge(s))return{data:{user:null,session:null},error:s};throw s}}async signInWithSSO(e){var t,n,s;try{let a=null,c=null;return this.flowType==="pkce"&&([a,c]=await Es(this.storage,this.storageKey)),await Ee(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(n=(t=e.options)===null||t===void 0?void 0:t.redirectTo)!==null&&n!==void 0?n:void 0}),!((s=e==null?void 0:e.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:a,code_challenge_method:c}),headers:this.headers,xform:eI})}catch(a){if(ge(a))return{data:null,error:a};throw a}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{let{data:{session:t},error:n}=e;if(n)throw n;if(!t)throw new fr;let{error:s}=await Ee(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:t.access_token});return{data:{user:null,session:null},error:s}})}catch(e){if(ge(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{let t=`${this.url}/resend`;if("email"in e){let{email:n,type:s,options:a}=e,{error:c}=await Ee(this.fetch,"POST",t,{headers:this.headers,body:{email:n,type:s,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},redirectTo:a==null?void 0:a.emailRedirectTo});return{data:{user:null,session:null},error:c}}else if("phone"in e){let{phone:n,type:s,options:a}=e,{data:c,error:h}=await Ee(this.fetch,"POST",t,{headers:this.headers,body:{phone:n,type:s,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}}});return{data:{user:null,session:null,messageId:c==null?void 0:c.message_id},error:h}}throw new Is("You must provide either an email or phone number and a type")}catch(t){if(ge(t))return{data:{user:null,session:null},error:t};throw t}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async t=>t))}async _acquireLock(e,t){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){let n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),s=(async()=>(await n,await t()))();return this.pendingInLock.push((async()=>{try{await s}catch{}})()),s}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;let n=t();for(this.pendingInLock.push((async()=>{try{await n}catch{}})()),await n;this.pendingInLock.length;){let s=[...this.pendingInLock];await Promise.all(s),this.pendingInLock.splice(0,s.length)}return await n}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{let t=await this.__loadSession();return await e(t)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null,t=await Qu(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",t),t!==null&&(this._isValidSession(t)?e=t:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};let n=e.expires_at?e.expires_at<=Date.now()/1e3:!1;if(this._debug("#__loadSession()",`session has${n?"":" not"} expired`,"expires_at",e.expires_at),!n){if(this.storage.isServer){let c=this.suppressGetSessionWarning;e=new Proxy(e,{get:(f,m,_)=>(!c&&m==="user"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),c=!0,this.suppressGetSessionWarning=!0),Reflect.get(f,m,_))})}return{data:{session:e},error:null}}let{session:s,error:a}=await this._callRefreshToken(e.refresh_token);return a?{data:{session:null},error:a}:{data:{session:s},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(e){return e?await this._getUser(e):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(e){try{return e?await Ee(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:tn}):await this._useSession(async t=>{var n,s,a;let{data:c,error:h}=t;if(h)throw h;return!(!((n=c.session)===null||n===void 0)&&n.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new fr}:await Ee(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(a=(s=c.session)===null||s===void 0?void 0:s.access_token)!==null&&a!==void 0?a:void 0,xform:tn})})}catch(t){if(ge(t))return YE(t)&&(await this._removeSession(),await Ju(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:t};throw t}}async updateUser(e,t={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(e,t))}async _updateUser(e,t={}){try{return await this._useSession(async n=>{let{data:s,error:a}=n;if(a)throw a;if(!s.session)throw new fr;let c=s.session,h=null,f=null;this.flowType==="pkce"&&e.email!=null&&([h,f]=await Es(this.storage,this.storageKey));let{data:m,error:_}=await Ee(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:t==null?void 0:t.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:h,code_challenge_method:f}),jwt:c.access_token,xform:tn});if(_)throw _;return c.user=m.user,await this._saveSession(c),await this._notifyAllSubscribers("USER_UPDATED",c),{data:{user:c.user},error:null}})}catch(n){if(ge(n))return{data:{user:null},error:n};throw n}}_decodeJWT(e){return Gg(e)}async setSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new fr;let t=Date.now()/1e3,n=t,s=!0,a=null,c=Gg(e.access_token);if(c.exp&&(n=c.exp,s=n<=t),s){let{session:h,error:f}=await this._callRefreshToken(e.refresh_token);if(f)return{data:{user:null,session:null},error:f};if(!h)return{data:{user:null,session:null},error:null};a=h}else{let{data:h,error:f}=await this._getUser(e.access_token);if(f)throw f;a={access_token:e.access_token,refresh_token:e.refresh_token,user:h.user,token_type:"bearer",expires_in:n-t,expires_at:n},await this._saveSession(a),await this._notifyAllSubscribers("SIGNED_IN",a)}return{data:{user:a.user,session:a},error:null}}catch(t){if(ge(t))return{data:{session:null,user:null},error:t};throw t}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async t=>{var n;if(!e){let{data:c,error:h}=t;if(h)throw h;e=(n=c.session)!==null&&n!==void 0?n:void 0}if(!(e!=null&&e.refresh_token))throw new fr;let{session:s,error:a}=await this._callRefreshToken(e.refresh_token);return a?{data:{user:null,session:null},error:a}:s?{data:{user:s.user,session:s},error:null}:{data:{user:null,session:null},error:null}})}catch(t){if(ge(t))return{data:{user:null,session:null},error:t};throw t}}async _getSessionFromURL(e,t){try{if(!Rr())throw new xs("No browser detected.");if(e.error||e.error_description||e.error_code)throw new xs(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(t){case"implicit":if(this.flowType==="pkce")throw new Xu("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new xs("Not a valid implicit grant flow url.");break;default:}if(t==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new Xu("No code detected.");let{data:ee,error:re}=await this._exchangeCodeForSession(e.code);if(re)throw re;let le=new URL(window.location.href);return le.searchParams.delete("code"),window.history.replaceState(window.history.state,"",le.toString()),{data:{session:ee.session,redirectType:null},error:null}}let{provider_token:n,provider_refresh_token:s,access_token:a,refresh_token:c,expires_in:h,expires_at:f,token_type:m}=e;if(!a||!h||!c||!m)throw new xs("No session defined in URL");let _=Math.round(Date.now()/1e3),E=parseInt(h),I=_+E;f&&(I=parseInt(f));let k=I-_;k*1e3<=tc&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${k}s, should have been closer to ${E}s`);let B=I-E;_-B>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",B,I,_):_-B<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",B,I,_);let{data:G,error:j}=await this._getUser(a);if(j)throw j;let J={provider_token:n,provider_refresh_token:s,access_token:a,expires_in:E,expires_at:I,refresh_token:c,token_type:m,user:G.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:J,redirectType:e.type},error:null}}catch(n){if(ge(n))return{data:{session:null,redirectType:null},error:n};throw n}}_isImplicitGrantCallback(e){return!!(e.access_token||e.error_description)}async _isPKCECallback(e){let t=await Qu(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&t)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async t=>{var n;let{data:s,error:a}=t;if(a)return{error:a};let c=(n=s.session)===null||n===void 0?void 0:n.access_token;if(c){let{error:h}=await this.admin.signOut(c,e);if(h&&!(JE(h)&&(h.status===404||h.status===401||h.status===403)))return{error:h}}return e!=="others"&&(await this._removeSession(),await Ju(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(e){let t=zE(),n={id:t,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",t),this.stateChangeEmitters.delete(t)}};return this._debug("#onAuthStateChange()","registered callback with id",t),this.stateChangeEmitters.set(t,n),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(t)})))(),{data:{subscription:n}}}async _emitInitialSession(e){return await this._useSession(async t=>{var n,s;try{let{data:{session:a},error:c}=t;if(c)throw c;await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",a)),this._debug("INITIAL_SESSION","callback id",e,"session",a)}catch(a){await((s=this.stateChangeEmitters.get(e))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",a),console.error(a)}})}async resetPasswordForEmail(e,t={}){let n=null,s=null;this.flowType==="pkce"&&([n,s]=await Es(this.storage,this.storageKey,!0));try{return await Ee(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:n,code_challenge_method:s,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})}catch(a){if(ge(a))return{data:null,error:a};throw a}}async getUserIdentities(){var e;try{let{data:t,error:n}=await this.getUser();if(n)throw n;return{data:{identities:(e=t.user.identities)!==null&&e!==void 0?e:[]},error:null}}catch(t){if(ge(t))return{data:null,error:t};throw t}}async linkIdentity(e){var t;try{let{data:n,error:s}=await this._useSession(async a=>{var c,h,f,m,_;let{data:E,error:I}=a;if(I)throw I;let k=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(c=e.options)===null||c===void 0?void 0:c.redirectTo,scopes:(h=e.options)===null||h===void 0?void 0:h.scopes,queryParams:(f=e.options)===null||f===void 0?void 0:f.queryParams,skipBrowserRedirect:!0});return await Ee(this.fetch,"GET",k,{headers:this.headers,jwt:(_=(m=E.session)===null||m===void 0?void 0:m.access_token)!==null&&_!==void 0?_:void 0})});if(s)throw s;return Rr()&&!(!((t=e.options)===null||t===void 0)&&t.skipBrowserRedirect)&&window.location.assign(n==null?void 0:n.url),{data:{provider:e.provider,url:n==null?void 0:n.url},error:null}}catch(n){if(ge(n))return{data:{provider:e.provider,url:null},error:n};throw n}}async unlinkIdentity(e){try{return await this._useSession(async t=>{var n,s;let{data:a,error:c}=t;if(c)throw c;return await Ee(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(s=(n=a.session)===null||n===void 0?void 0:n.access_token)!==null&&s!==void 0?s:void 0})})}catch(t){if(ge(t))return{data:null,error:t};throw t}}async _refreshAccessToken(e){let t=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(t,"begin");try{let n=Date.now();return await HE(async s=>(s>0&&await WE(200*Math.pow(2,s-1)),this._debug(t,"refreshing attempt",s),await Ee(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:Vn})),(s,a)=>{let c=200*Math.pow(2,s);return a&&mf(a)&&Date.now()+c-n<tc})}catch(n){if(this._debug(t,"error",n),ge(n))return{data:{session:null,user:null},error:n};throw n}finally{this._debug(t,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,t){let n=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:t.redirectTo,scopes:t.scopes,queryParams:t.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",t,"url",n),Rr()&&!t.skipBrowserRedirect&&window.location.assign(n),{data:{provider:e,url:n},error:null}}async _recoverAndRefresh(){var e;let t="#_recoverAndRefresh()";this._debug(t,"begin");try{let n=await Qu(this.storage,this.storageKey);if(this._debug(t,"session from storage",n),!this._isValidSession(n)){this._debug(t,"session is not valid"),n!==null&&await this._removeSession();return}let s=Math.round(Date.now()/1e3),a=((e=n.expires_at)!==null&&e!==void 0?e:1/0)<s+$g;if(this._debug(t,`session has${a?"":" not"} expired with margin of ${$g}s`),a){if(this.autoRefreshToken&&n.refresh_token){let{error:c}=await this._callRefreshToken(n.refresh_token);c&&(console.error(c),mf(c)||(this._debug(t,"refresh failed with a non-retryable error, removing the session",c),await this._removeSession()))}}else await this._notifyAllSubscribers("SIGNED_IN",n)}catch(n){this._debug(t,"error",n),console.error(n);return}finally{this._debug(t,"end")}}async _callRefreshToken(e){var t,n;if(!e)throw new fr;if(this.refreshingDeferred)return this.refreshingDeferred.promise;let s=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{this.refreshingDeferred=new Hu;let{data:a,error:c}=await this._refreshAccessToken(e);if(c)throw c;if(!a.session)throw new fr;await this._saveSession(a.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",a.session);let h={session:a.session,error:null};return this.refreshingDeferred.resolve(h),h}catch(a){if(this._debug(s,"error",a),ge(a)){let c={session:null,error:a};return mf(a)||await this._removeSession(),(t=this.refreshingDeferred)===null||t===void 0||t.resolve(c),c}throw(n=this.refreshingDeferred)===null||n===void 0||n.reject(a),a}finally{this.refreshingDeferred=null,this._debug(s,"end")}}async _notifyAllSubscribers(e,t,n=!0){let s=`#_notifyAllSubscribers(${e})`;this._debug(s,"begin",t,`broadcast = ${n}`);try{this.broadcastChannel&&n&&this.broadcastChannel.postMessage({event:e,session:t});let a=[],c=Array.from(this.stateChangeEmitters.values()).map(async h=>{try{await h.callback(e,t)}catch(f){a.push(f)}});if(await Promise.all(c),a.length>0){for(let h=0;h<a.length;h+=1)console.error(a[h]);throw a[0]}}finally{this._debug(s,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await zg(this.storage,this.storageKey,e)}async _removeSession(){this._debug("#_removeSession()"),await Ju(this.storage,this.storageKey),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");let e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&Rr()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}catch(t){console.error("removing visibilitychange callback failed",t)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");let e=setInterval(()=>this._autoRefreshTokenTick(),tc);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno!="undefined"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");let e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{let e=Date.now();try{return await this._useSession(async t=>{let{data:{session:n}}=t;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}let s=Math.floor((n.expires_at*1e3-e)/tc);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts ${tc}ms, refresh threshold is ${sI} ticks`),s<=sI&&await this._callRefreshToken(n.refresh_token)})}catch(t){console.error("Auto refresh tick failed with error. This is likely a transient error.",t)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof ec)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Rr()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){let t=`#_onVisibilityChanged(${e})`;this._debug(t,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(t,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,t,n){let s=[`provider=${encodeURIComponent(t)}`];if(n!=null&&n.redirectTo&&s.push(`redirect_to=${encodeURIComponent(n.redirectTo)}`),n!=null&&n.scopes&&s.push(`scopes=${encodeURIComponent(n.scopes)}`),this.flowType==="pkce"){let[a,c]=await Es(this.storage,this.storageKey),h=new URLSearchParams({code_challenge:`${encodeURIComponent(a)}`,code_challenge_method:`${encodeURIComponent(c)}`});s.push(h.toString())}if(n!=null&&n.queryParams){let a=new URLSearchParams(n.queryParams);s.push(a.toString())}return n!=null&&n.skipBrowserRedirect&&s.push(`skip_http_redirect=${n.skipBrowserRedirect}`),`${e}?${s.join("&")}`}async _unenroll(e){try{return await this._useSession(async t=>{var n;let{data:s,error:a}=t;return a?{data:null,error:a}:await Ee(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token})})}catch(t){if(ge(t))return{data:null,error:t};throw t}}async _enroll(e){try{return await this._useSession(async t=>{var n,s;let{data:a,error:c}=t;if(c)return{data:null,error:c};let h=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:{issuer:e.issuer}),{data:f,error:m}=await Ee(this.fetch,"POST",`${this.url}/factors`,{body:h,headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token});return m?{data:null,error:m}:(e.factorType==="totp"&&(!((s=f==null?void 0:f.totp)===null||s===void 0)&&s.qr_code)&&(f.totp.qr_code=`data:image/svg+xml;utf-8,${f.totp.qr_code}`),{data:f,error:null})})}catch(t){if(ge(t))return{data:null,error:t};throw t}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var n;let{data:s,error:a}=t;if(a)return{data:null,error:a};let{data:c,error:h}=await Ee(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token});return h?{data:null,error:h}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+c.expires_in},c)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",c),{data:c,error:h})})}catch(t){if(ge(t))return{data:null,error:t};throw t}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var n;let{data:s,error:a}=t;return a?{data:null,error:a}:await Ee(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:{channel:e.channel},headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token})})}catch(t){if(ge(t))return{data:null,error:t};throw t}})}async _challengeAndVerify(e){let{data:t,error:n}=await this._challenge({factorId:e.factorId});return n?{data:null,error:n}:await this._verify({factorId:e.factorId,challengeId:t.id,code:e.code})}async _listFactors(){let{data:{user:e},error:t}=await this.getUser();if(t)return{data:null,error:t};let n=(e==null?void 0:e.factors)||[],s=n.filter(c=>c.factor_type==="totp"&&c.status==="verified"),a=n.filter(c=>c.factor_type==="phone"&&c.status==="verified");return{data:{all:n,totp:s,phone:a},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async e=>{var t,n;let{data:{session:s},error:a}=e;if(a)return{data:null,error:a};if(!s)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};let c=this._decodeJWT(s.access_token),h=null;c.aal&&(h=c.aal);let f=h;((n=(t=s.user.factors)===null||t===void 0?void 0:t.filter(E=>E.status==="verified"))!==null&&n!==void 0?n:[]).length>0&&(f="aal2");let _=c.amr||[];return{data:{currentLevel:h,nextLevel:f,currentAuthenticationMethods:_},error:null}}))}};Ps.nextInstanceID=0;var CU=Ps,Qg=CU;var _f=class extends Qg{constructor(e){super(e)}};var DU=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})},rc=class{constructor(e,t,n){var s,a,c;if(this.supabaseUrl=e,this.supabaseKey=t,!e)throw new Error("supabaseUrl is required.");if(!t)throw new Error("supabaseKey is required.");let h=FE(e);this.realtimeUrl=`${h}/realtime/v1`.replace(/^http/i,"ws"),this.authUrl=`${h}/auth/v1`,this.storageUrl=`${h}/storage/v1`,this.functionsUrl=`${h}/functions/v1`;let f=`sb-${new URL(this.authUrl).hostname.split(".")[0]}-auth-token`,m={db:NE,realtime:LE,auth:Object.assign(Object.assign({},VE),{storageKey:f}),global:kE},_=UE(n!=null?n:{},m);this.storageKey=(s=_.auth.storageKey)!==null&&s!==void 0?s:"",this.headers=(a=_.global.headers)!==null&&a!==void 0?a:{},_.accessToken?(this.accessToken=_.accessToken,this.auth=new Proxy({},{get:(E,I)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(I)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((c=_.auth)!==null&&c!==void 0?c:{},this.headers,_.global.fetch),this.fetch=ME(t,this._getAccessToken.bind(this),_.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},_.realtime)),this.rest=new yE(`${h}/rest/v1`,{headers:this.headers,schema:_.db.schema,fetch:this.fetch}),_.accessToken||this._listenForAuthEvents()}get functions(){return new Nu(this.functionsUrl,{headers:this.headers,customFetch:this.fetch})}get storage(){return new Gu(this.storageUrl,this.headers,this.fetch)}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,t={},n={}){return this.rest.rpc(e,t,n)}channel(e,t={config:{}}){return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var e,t;return DU(this,void 0,void 0,function*(){if(this.accessToken)return yield this.accessToken();let{data:n}=yield this.auth.getSession();return(t=(e=n.session)===null||e===void 0?void 0:e.access_token)!==null&&t!==void 0?t:null})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:n,storage:s,storageKey:a,flowType:c,lock:h,debug:f},m,_){let E={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new _f({url:this.authUrl,headers:Object.assign(Object.assign({},E),m),storageKey:a,autoRefreshToken:e,persistSession:t,detectSessionInUrl:n,storage:s,flowType:c,lock:h,debug:f,fetch:_,hasCustomAuthorizationHeader:"Authorization"in this.headers})}_initRealtimeClient(e){return new sa(this.realtimeUrl,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e==null?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,n)=>{this._handleTokenChanged(t,"CLIENT",n==null?void 0:n.access_token)})}_handleTokenChanged(e,t,n){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==n?this.changedAccessToken=n:e==="SIGNED_OUT"&&(this.realtime.setAuth(),t=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};var aI=(r,e,t)=>new rc(r,e,t);var vI=Dd(hI(),1);var fI={id:"~date",test:r=>r instanceof Date,serialize:r=>({_:"~date",v:r.toISOString()}),deserialize:r=>new Date(r.v)};var dI={id:"~function",test:r=>typeof r=="function",serialize:r=>({_:"~function",v:r.toString()}),deserialize:v=>eval(v.v.toString())};var pI={id:"~infinity",test:r=>r===1/0||r===-1/0,serialize:r=>({_:"~infinity",v:r===1/0?1:0}),deserialize:r=>r.v==1?1/0:-1/0};var mI={id:"~nan",test:r=>Number.isNaN(r),serialize:r=>({_:"~nan"}),deserialize:r=>NaN};var gI={id:"~regexp",test:r=>r instanceof RegExp,serialize:r=>({_:"~regexp",v:r.source,f:r.flags}),deserialize:r=>new RegExp(r.v,r.f)};var _I={id:"~set",test:r=>r instanceof Set,serialize:r=>({_:"~set",v:Array.from(r)}),deserialize:r=>new Set(r.v)};var yI={id:"~undefined",test:r=>r===void 0,serialize:r=>({_:"~undefined"}),deserialize:r=>{}};var da={settings:{stringify:!0,destringify:!0,clone:!1,depth:0,modules:[fI,dI,pI,mI,gI,_I,yI],circular:!0,symetric:!1},loadedModules:{},loadModules(r){return r.map(e=>{if(De(e)){if(!e.id)throw new Error("Provided custom module does not expose an `id` property");return da.loadedModules[e.id]=e}else throw new Error("Unknown module type")})},serialize(r,e){let t=zl(e,da.settings),n=da.loadModules(t.modules),s=t.symetric?(0,vI.keyArrangeDeep)(r):t.clone?qr(r):r,a=new Map,c=(h,f)=>{let m=De(h);if(m&&t.circular){let I=a.get(h);if(I)return pi(s,f,{_:"~circular",p:I.join(".")});a.set(h,f)}let _=n.find(I=>I.test(h)),E=(!t.depth||f.length<t.depth)&&m;if(_){let I=_.serialize(h);if(_.recursive&&E){let k=At(h);t.symetric&&k.sort(),pi(s,f,I),k.forEach(B=>c(h[B],f.concat(B)))}else f.length?pi(s,f,I):s=I}else if(E){let I=At(h);t.symetric&&I.sort(),I.forEach(k=>c(h[k],f.concat(k)))}};return c(s,[]),t.stringify?JSON.stringify(s):s},deserialize(r,e){let t=zl(e,da.settings),n=da.loadModules(t.modules),s=Bd(n,"id"),a=t.destringify?JSON.parse(r):t.clone?qr(r):r,c=(h,f)=>{if(De(h)&&h._&&typeof h._=="string"&&h._.startsWith("~")&&s[h._]){let m=s[h._].deserialize(h);f.length?s[h._].recursive&&De(m)?(pi(a,f,m),At(m).forEach(_=>c(h[_],[...f,_]))):pi(a,f,m):a=m}else t.circular&&De(h)&&h._&&h._=="~circular"?pi(a,f,ru(a,h.p)):(!t.depth||f.length<t.depth)&&De(h)&&At(h).forEach(m=>c(h[m],f.concat(m)))};return c(a,[]),a}},ic=da;var wI="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var bI=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)e+=wI[t[r]&63];return e};var $e=class $e{constructor(e,t){gt(this,"path");gt(this,"docRef");gt(this,"value");gt(this,"throttle",250);gt(this,"heartbeatInterval",3e4);gt(this,"_destroyActions",[]);gt(this,"_heartbeatTimer");this.path=e,Object.assign(this,t),$e.session||($e.session=`syncro_${bI()}`)}debug(...e){}destroy(){return this.debug("Destroy!"),Promise.all(this._destroyActions.map(e=>e())).then(()=>this._destroyActions=[])}getReactive(e){console.warn("Syncro.getReactive has not been subclassed, assuming a POJO response");let t={...e};return{doc:t,setState(n){Object.entries(n||{}).forEach(([s,a])=>t[s]=a)},getState(){return qr(t)},watch(n){}}}static pathSplit(e){var n;let t={...(n=/^(?<entity>\w+?)::(?<id>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:::(?<relation>\w+?))?$/.exec(e))==null?void 0:n.groups};if(!t)throw new Error(`Invalid session path syntax "${e}"`);if(!(t.entity in Yg))throw new Error(`Unsupported entity "${e}" -> Entity="${t.entity}"`);return{...t,fsCollection:t.entity,fsId:t.relation?`${t.id}::${t.relation}`:t.id}}static toFirestore(e={}){return ic.serialize(e,{circular:!1,clone:!0,modules:[TI,...ic.settings.modules],stringify:!1})}static fromFirestore(e={}){return ic.deserialize(e,{circular:!1,clone:!0,modules:[TI,...ic.settings.modules],destringify:!1})}static fromFirestoreFields(e={}){let t={};for(let n in e){let s=e[n];if(["stringValue","booleanValue","doubleValue","integerValue","timestampValue","mapValue","arrayValue"].find(c=>c===n)){if(["stringValue","booleanValue","doubleValue","integerValue","timestampValue"].find(h=>h===n))return s;if(n=="mapValue")return $e.fromFirestoreFields(s.fields||{});if(n=="arrayValue"){let h=s.values;return h?h.map(f=>$e.fromFirestoreFields(f)):[]}}else t[n]=$e.fromFirestoreFields(s)}return t}static getSnapshot(e){let{fsCollection:t,fsId:n}=$e.pathSplit(e);return Promise.resolve().then(async()=>{let s=Ou($e.firestore,t,n);return Jh(s)}).then(s=>s?$e.fromFirestore(snapshot.data()):null)}static setSnapshot(e,t,n){let s={method:"merge",...n},{fsCollection:a,fsId:c}=$e.pathSplit(e);return Promise.resolve().then(()=>(s.method=="merge"?"FirestoreUpdateDoc":"FirestoreSetDoc")(Ou($e.firestore,a,c),$e.toFirestore(t))).then(()=>t)}static wrapSupabase(e){return Promise.resolve(e).then(t=>{var n,s;if(t!=null&&t.error)throw/JSON object requested, multiple \(or no\) rows returned$/.test(t.error.message)?(console.warn("Supabase query threw record not found against query",e.url.search),console.warn("Supabase raw error",t),new Error("NOT-FOUND")):(console.warn("Supabase query threw",t.error.message),new Error(`${((n=t.error)==null?void 0:n.code)||"UnknownError"}: ${((s=t.error)==null?void 0:s.message)||"Unknown Supabase error"}`));if(t.data)return t.data})}mount(){let{fsCollection:e,fsId:t,entity:n,id:s,relation:a}=$e.pathSplit(this.path),c,h;return Promise.resolve().then(()=>this.setHeartbeat(!1)).then(async()=>{this.docRef=Ou($e.firestore,e,t);let f=$e.fromFirestore((await Jh(this.docRef)).data());if(c=this.getReactive(f),!c.doc||!c.setState||!c.getState||!c.watch)throw new Error("Syncro.getReactive() requires a returned `doc`, `setState()`, `getState()` + `watch()`");this.value=h=c.doc,this.debug("Initial state",{doc:h}),this._destroyActions.push(tE(this.docRef,m=>{let _=$e.fromFirestore(m.data());this.debug("Incoming snapshot",{snapshotData:_}),c.setState(_)}))}).then(()=>{if(Fd(h))return this.debug("Populate initial state"),Promise.resolve().then(()=>Yg[n]||Promise.reject(`Unknown Sync entity "${n}"`)).then(()=>Yg[n].initState({supabase:$e.supabase,fsCollection:e,fsId:t,entity:n,id:s,relation:a})).then(f=>bg(this.docRef,$e.toFirestore(f)))}).then(()=>{c.watch(jd(f=>{this.debug("Local change",{newState:f}),eE(this.docRef,$e.toFirestore(f))},this.throttle))}).then(()=>this.setHeartbeat(!0,{immediate:!0})).then(()=>this)}setHeartbeat(e=!0,t){let n={immediate:!0,...t};clearTimeout(this._heartbeatTimer),e&&(this._heartbeatTimer=setTimeout(async()=>{await this.heartbeat(),e&&this.setHeartbeat(!0)},this.heartbeatInterval),n.immediate&&this.heartbeat())}async heartbeat(){this.debug("heartbeat!");let e=new Date().toISOString(),t=Ou($e.firestore,"presence",this.path),n=await Jh(t);await bg(t,{latest:e,...!n.exists()&&{created:e,lastFlush:null},sessions:{[$e.session]:e}},{merge:!0})}flush(e){let t={destroy:!1,...e};return fetch(`https://tera-tools.com/api/sync/${this.path}/flush`+(t.destroy?"?destroy=1":""),{method:"post"}).then(n=>n.ok?null:Promise.reject(n.statusText||"An error occured"))}};gt($e,"firebase"),gt($e,"firestore"),gt($e,"supabase"),gt($e,"session");var Tt=$e;var Yg={projects:{singular:"project",initState({supabase:r,id:e}){return Tt.wrapSupabase(r.from("projects").select("data").limit(1).eq("id",e)).then(t=>t.length==1?t[0]:Promise.reject(`Syncro project "${e}" not found`)).then(t=>t.data)},flushState({supabase:r,state:e,fsId:t}){return Tt.wrapSupabase(r.rpc("syncro_merge_data",{table_name:"projects",entity_id:t,new_data:e}))}},project_namespaces:{singular:"project namespace",initState({supabase:r,id:e,relation:t}){if(!t)throw new Error('Project namespace relation missing, path should resemble "project_namespaces::${PROJECT}::${RELATION}"');return Tt.wrapSupabase(r.from("project_namespaces").select("data").limit(1).eq("project",e).eq("name",t)).then(n=>n.length==1?n[0]:Tt.wrapSupabase(r.from("project_namespaces").insert({project:e,name:t,data:{}}).select("data"))).then(n=>n.data)},flushState({supabase:r,state:e,id:t,relation:n}){return Tt.wrapSupabase(r.from("project_namespaces").update({edited_at:new Date,data:e}).eq("project",t).eq("name",n))}},test:{singular:"test",initState({supabase:r,id:e}){return Tt.wrapSupabase(r.from("test").select("data").limit(1).eq("id",e)).then(t=>t.length==1?t[0]:Promise.reject(`Syncro test item "${e}" not found`)).then(t=>t.data)},flushState({supabase:r,state:e,fsId:t}){return Tt.wrapSupabase(r.rpc("syncro_merge_data",{table_name:"test",entity_id:t,new_data:e}))}},users:{singular:"user",initState({supabase:r,id:e}){return Tt.wrapSupabase(r.from("users").select("data").limit(1).eq("id",e)).then(t=>t.length==1?t[0]:Promise.reject(`Syncro user "${e}" not found`)).then(t=>t.data)},flushState({supabase:r,state:e,fsId:t}){return Tt.wrapSupabase(r.rpc("syncro_merge_data",{table_name:"users",entity_id:t,new_data:e}))}}},TI={id:"~array",recursive:!0,test:r=>Array.isArray(r),serialize:r=>({_:"~array",...r}),deserialize:r=>{let e=Array.from({length:Object.keys(r).length-1});return Object.entries(r).filter(([t])=>t!=="_").forEach(([t,n])=>e[+t]=n),e}};var sc=class{init(){}constructor(e,t){}};var oc=class extends sc{constructor(){super(...arguments);gt(this,"syncros",{})}async init(t){let n={firebaseApiKey:null,firebaseAuthDomain:null,firebaseProjectId:null,firebaseAppId:null,supabaseUrl:null,supabaseKey:null,...await this.getCredentials(),...t},s=Object.keys(n).filter(a=>a===null);if(s.length>0)throw new Error("Firebase plugin requires mandatory options: "+s.join(", "));Tt.firebase=op({apiKey:n.firebaseApiKey,authDomain:n.firebaseAuthDomain,projectId:n.firebaseProjectId,appId:n.firebaseAppId}),Tt.firestore=WT(this.firebase),Tt.supabase=aI(n.supabaseUrl,n.supabaseKey)}_mountNamespace(t){let n;return Promise.resolve().then(()=>this.requireProject()).then(s=>{let a=t=="_PROJECT"?`projects::${s.id}`:`project_namespaces::${s.id}::${t}`;return n=this.syncros[t]=new Tt(a,{debug:(...c)=>this.debug(`SYNCRO://${a}`,...c),getReactive:this.getReactive}),n.mount()}).then(()=>{this.namespaces[t]=n.value})}_unmountNamespace(t){let n=this.syncros[t];return delete this.namespaces[t],delete this.syncros[t],n.destroy()}};var Xg=class extends oc{constructor(){super(...arguments);gt(this,"Vue");gt(this,"project",null);gt(this,"reactiveId",1001)}async init(t){let n={app:null,Vue:null,globalName:"$tera",...t};if(!n.Vue)throw new Error("Vue instance to use must be specified in init options as `Vue`");if(this.Vue=n.Vue,!n.app)throw new Error("Vue Root / App instance to use must be specified in init options as `app`");this.app=n.app,n.globalName&&(this.Vue.prototype[n.globalName]=this),await super.init(n),this.project=await this.mountNamespace("_PROJECT")}getReactive(t){let n=this.Vue.observable(t),s=`_teraFy_${this.reactiveId++}`;return this.app[s]=n,{doc:n,setState(a){Object.entries(a||{}).filter(([c])=>!Ud(n[c],a[c])).forEach(([c,h])=>n[c]=h)},getState(){return qr(n)},watch:a=>{this.app.$watch(s,a,{deep:!0})}}}bindProjectState(t){let n={component:null,componentKey:null,autoRequire:!0,read:!0,write:!0,throttle:{wait:200,maxWait:2e3,leading:!1,trailing:!0},...t};return Promise.resolve().then(()=>Promise.all([this.getProjectState({autoRequire:n.autoRequire}),(()=>{if(!n.componentKey){for(let s=0;s<50;s++){let a=`terafy_${s}`;if(!Object.hasOwnProperty(n.component,a)){n.componentKey=a;return}}throw new Error("Unable to find unique key to allocate against Vue2 component")}})()])).then(([s])=>{this.debug("INFO",2,"Got project snapshot",s);let a=this.Vue.observable(s);if(n.component[n.componentKey]=a,n.read&&this.events.on(`update:projects/${a.id}`,c=>{var h;(h=c==null?void 0:c.lastPatch)!=null&&h.session&&c.lastPatch.session==this.settings.session||(this.debug("INFO",5,"Update Vue2 Remote->Local",{new:c,old:a}),this.merge(a,c))}),n.write){if(!n.component)throw new Error("bindProjectState requires a VueComponent specified as `component`");let c=qr(s),h=()=>{let f=qr(s);this.debug("INFO",5,"Update Vue2 Local->Remote",{new:f,old:c}),this.createProjectStatePatch(f,c),c=f};n.component.$watch(n.componentKey,n.throttle?debounce(h,n.throttle.wait,n.throttle):h,{deep:!0})}return a})}merge(t,...n){return n.forEach(s=>Object.keys(s).forEach(a=>{isPlainObject(s[a])?(a in t||this.Vue.set(t,a,{}),this.merge(t[a],s[a])):this.Vue.set(t,a,s[a])})),t}};export{Xg as default};
47
47
  /*! Bundled license information:
48
48
 
49
49
  lodash/lodash.js: