firebase 13.2.0-eap-sql.a9a137e67 → 13.2.0-eap-sql.b903ef716

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.
Files changed (47) hide show
  1. package/app/dist/esm/index.esm.js +1 -1
  2. package/app/dist/index.cjs.js +1 -1
  3. package/app/dist/index.mjs +1 -1
  4. package/compat/app/dist/esm/index.esm.js +1 -1
  5. package/compat/app/dist/index.cjs.js +1 -1
  6. package/compat/app/dist/index.mjs +1 -1
  7. package/compat/dist/esm/index.esm.js +2 -2
  8. package/compat/dist/index.node.cjs +2 -2
  9. package/compat/dist/index.rn.cjs.js +2 -2
  10. package/firebase-ai.js +1 -1
  11. package/firebase-analytics-compat.js +1 -1
  12. package/firebase-analytics.js +1 -1
  13. package/firebase-app-check-compat.js +1 -1
  14. package/firebase-app-check.js +1 -1
  15. package/firebase-app-compat.js +2 -2
  16. package/firebase-app.js +5 -5
  17. package/firebase-auth-compat.js +1 -1
  18. package/firebase-auth-cordova.js +1 -1
  19. package/firebase-auth-web-extension.js +1 -1
  20. package/firebase-auth.js +1 -1
  21. package/firebase-compat.js +6 -6
  22. package/firebase-crashlytics.js +1 -1
  23. package/firebase-data-connect.js +1 -1
  24. package/firebase-database-compat.js +1 -1
  25. package/firebase-database.js +1 -1
  26. package/firebase-firestore-compat.js +2 -2
  27. package/firebase-firestore-lite-pipelines.js +1 -1
  28. package/firebase-firestore-lite.js +1 -1
  29. package/firebase-firestore-pipelines.js +1 -1
  30. package/firebase-firestore.js +1 -1
  31. package/firebase-functions-compat.js +1 -1
  32. package/firebase-functions.js +1 -1
  33. package/firebase-installations-compat.js +1 -1
  34. package/firebase-installations.js +1 -1
  35. package/firebase-messaging-compat.js +1 -1
  36. package/firebase-messaging-sw.js +1 -1
  37. package/firebase-messaging.js +1 -1
  38. package/firebase-performance-compat.js +1 -1
  39. package/firebase-performance-standalone-compat.js +7 -7
  40. package/firebase-performance.js +1 -1
  41. package/firebase-remote-config-compat.js +1 -1
  42. package/firebase-remote-config.js +1 -1
  43. package/firebase-sql.js +1 -1
  44. package/firebase-sql.js.map +1 -1
  45. package/firebase-storage-compat.js +1 -1
  46. package/firebase-storage.js +1 -1
  47. package/package.json +31 -31
@@ -1,3 +1,3 @@
1
- import"https://www.gstatic.com/firebasejs/13.2.0-eap-sql.a9a137e67/firebase-app.js";class FirebaseError extends Error{constructor(e,r,i){super(r),this.code=e,this.customData=i,this.name="FirebaseError",Object.setPrototypeOf(this,FirebaseError.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,ErrorFactory.prototype.create)}}class ErrorFactory{constructor(e,r,i){this.service=e,this.serviceName=r,this.errors=i}create(e,...r){const i=r[0]||{},s=`${this.service}/${e}`,o=this.errors[e],h=o?function replaceTemplate(e,r){try{let i=0,s="";for(;i<e.length;){const o=e.indexOf("{$",i);if(-1===o){s+=e.substring(i);break}const h=e.indexOf("}",o+2);if(-1===h){s+=e.substring(i);break}const E=e.substring(o+2,h),T=r[E];s+=e.substring(i,o)+(null!=T?String(T):`<${E}?>`),i=h+1}return s}catch(r){return e}}(o,i):"Error",E=`${this.serviceName}: ${h} (${s}).`;return new FirebaseError(s,E,i)}}function getModularInstance(e){return e&&e._delegate?e._delegate:e}var e;!function(e){e[e.DEBUG=0]="DEBUG",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.SILENT=5]="SILENT"}(e||(e={}));const r={debug:e.DEBUG,verbose:e.VERBOSE,info:e.INFO,warn:e.WARN,error:e.ERROR,silent:e.SILENT},i=e.INFO,s={[e.DEBUG]:"log",[e.VERBOSE]:"log",[e.INFO]:"info",[e.WARN]:"warn",[e.ERROR]:"error"},defaultLogHandler=(e,r,...i)=>{if(r<e.logLevel)return;const o=(new Date).toISOString(),h=s[r];if(!h)throw new Error(`Attempted to log a message with an invalid logType (value: ${r})`);console[h](`[${o}] ${e.name}:`,...i)};var o,h="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function __classPrivateFieldGet(e,r,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof r?e!==r||!s:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:r.get(e)}(function(){var e;function m(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.C=Array(this.blockSize),this.o=this.h=0,this.u()}function n(e,r,i){i||(i=0);const s=Array(16);if("string"==typeof r)for(var o=0;o<16;++o)s[o]=r.charCodeAt(i++)|r.charCodeAt(i++)<<8|r.charCodeAt(i++)<<16|r.charCodeAt(i++)<<24;else for(o=0;o<16;++o)s[o]=r[i++]|r[i++]<<8|r[i++]<<16|r[i++]<<24;r=e.g[0],i=e.g[1],o=e.g[2];let h,E=e.g[3];h=r+(E^i&(o^E))+s[0]+3614090360&4294967295,h=E+(o^(r=i+(h<<7&4294967295|h>>>25))&(i^o))+s[1]+3905402710&4294967295,E=r+(h<<12&4294967295|h>>>20),h=o+(i^E&(r^i))+s[2]+606105819&4294967295,h=i+(r^(o=E+(h<<17&4294967295|h>>>15))&(E^r))+s[3]+3250441966&4294967295,h=r+(E^(i=o+(h<<22&4294967295|h>>>10))&(o^E))+s[4]+4118548399&4294967295,h=E+(o^(r=i+(h<<7&4294967295|h>>>25))&(i^o))+s[5]+1200080426&4294967295,E=r+(h<<12&4294967295|h>>>20),h=o+(i^E&(r^i))+s[6]+2821735955&4294967295,h=i+(r^(o=E+(h<<17&4294967295|h>>>15))&(E^r))+s[7]+4249261313&4294967295,h=r+(E^(i=o+(h<<22&4294967295|h>>>10))&(o^E))+s[8]+1770035416&4294967295,h=E+(o^(r=i+(h<<7&4294967295|h>>>25))&(i^o))+s[9]+2336552879&4294967295,E=r+(h<<12&4294967295|h>>>20),h=o+(i^E&(r^i))+s[10]+4294925233&4294967295,h=i+(r^(o=E+(h<<17&4294967295|h>>>15))&(E^r))+s[11]+2304563134&4294967295,h=r+(E^(i=o+(h<<22&4294967295|h>>>10))&(o^E))+s[12]+1804603682&4294967295,h=E+(o^(r=i+(h<<7&4294967295|h>>>25))&(i^o))+s[13]+4254626195&4294967295,E=r+(h<<12&4294967295|h>>>20),h=o+(i^E&(r^i))+s[14]+2792965006&4294967295,h=i+(r^(o=E+(h<<17&4294967295|h>>>15))&(E^r))+s[15]+1236535329&4294967295,h=r+(o^E&((i=o+(h<<22&4294967295|h>>>10))^o))+s[1]+4129170786&4294967295,h=E+(i^o&((r=i+(h<<5&4294967295|h>>>27))^i))+s[6]+3225465664&4294967295,E=r+(h<<9&4294967295|h>>>23),h=o+(r^i&(E^r))+s[11]+643717713&4294967295,h=i+(E^r&((o=E+(h<<14&4294967295|h>>>18))^E))+s[0]+3921069994&4294967295,h=r+(o^E&((i=o+(h<<20&4294967295|h>>>12))^o))+s[5]+3593408605&4294967295,h=E+(i^o&((r=i+(h<<5&4294967295|h>>>27))^i))+s[10]+38016083&4294967295,E=r+(h<<9&4294967295|h>>>23),h=o+(r^i&(E^r))+s[15]+3634488961&4294967295,h=i+(E^r&((o=E+(h<<14&4294967295|h>>>18))^E))+s[4]+3889429448&4294967295,h=r+(o^E&((i=o+(h<<20&4294967295|h>>>12))^o))+s[9]+568446438&4294967295,h=E+(i^o&((r=i+(h<<5&4294967295|h>>>27))^i))+s[14]+3275163606&4294967295,E=r+(h<<9&4294967295|h>>>23),h=o+(r^i&(E^r))+s[3]+4107603335&4294967295,h=i+(E^r&((o=E+(h<<14&4294967295|h>>>18))^E))+s[8]+1163531501&4294967295,h=r+(o^E&((i=o+(h<<20&4294967295|h>>>12))^o))+s[13]+2850285829&4294967295,h=E+(i^o&((r=i+(h<<5&4294967295|h>>>27))^i))+s[2]+4243563512&4294967295,E=r+(h<<9&4294967295|h>>>23),h=o+(r^i&(E^r))+s[7]+1735328473&4294967295,h=i+(E^r&((o=E+(h<<14&4294967295|h>>>18))^E))+s[12]+2368359562&4294967295,h=r+((i=o+(h<<20&4294967295|h>>>12))^o^E)+s[5]+4294588738&4294967295,h=E+((r=i+(h<<4&4294967295|h>>>28))^i^o)+s[8]+2272392833&4294967295,E=r+(h<<11&4294967295|h>>>21),h=o+(E^r^i)+s[11]+1839030562&4294967295,h=i+((o=E+(h<<16&4294967295|h>>>16))^E^r)+s[14]+4259657740&4294967295,h=r+((i=o+(h<<23&4294967295|h>>>9))^o^E)+s[1]+2763975236&4294967295,h=E+((r=i+(h<<4&4294967295|h>>>28))^i^o)+s[4]+1272893353&4294967295,E=r+(h<<11&4294967295|h>>>21),h=o+(E^r^i)+s[7]+4139469664&4294967295,h=i+((o=E+(h<<16&4294967295|h>>>16))^E^r)+s[10]+3200236656&4294967295,h=r+((i=o+(h<<23&4294967295|h>>>9))^o^E)+s[13]+681279174&4294967295,h=E+((r=i+(h<<4&4294967295|h>>>28))^i^o)+s[0]+3936430074&4294967295,E=r+(h<<11&4294967295|h>>>21),h=o+(E^r^i)+s[3]+3572445317&4294967295,h=i+((o=E+(h<<16&4294967295|h>>>16))^E^r)+s[6]+76029189&4294967295,h=r+((i=o+(h<<23&4294967295|h>>>9))^o^E)+s[9]+3654602809&4294967295,h=E+((r=i+(h<<4&4294967295|h>>>28))^i^o)+s[12]+3873151461&4294967295,E=r+(h<<11&4294967295|h>>>21),h=o+(E^r^i)+s[15]+530742520&4294967295,h=i+((o=E+(h<<16&4294967295|h>>>16))^E^r)+s[2]+3299628645&4294967295,h=r+(o^((i=o+(h<<23&4294967295|h>>>9))|~E))+s[0]+4096336452&4294967295,h=E+(i^((r=i+(h<<6&4294967295|h>>>26))|~o))+s[7]+1126891415&4294967295,E=r+(h<<10&4294967295|h>>>22),h=o+(r^(E|~i))+s[14]+2878612391&4294967295,h=i+(E^((o=E+(h<<15&4294967295|h>>>17))|~r))+s[5]+4237533241&4294967295,h=r+(o^((i=o+(h<<21&4294967295|h>>>11))|~E))+s[12]+1700485571&4294967295,h=E+(i^((r=i+(h<<6&4294967295|h>>>26))|~o))+s[3]+2399980690&4294967295,E=r+(h<<10&4294967295|h>>>22),h=o+(r^(E|~i))+s[10]+4293915773&4294967295,h=i+(E^((o=E+(h<<15&4294967295|h>>>17))|~r))+s[1]+2240044497&4294967295,h=r+(o^((i=o+(h<<21&4294967295|h>>>11))|~E))+s[8]+1873313359&4294967295,h=E+(i^((r=i+(h<<6&4294967295|h>>>26))|~o))+s[15]+4264355552&4294967295,E=r+(h<<10&4294967295|h>>>22),h=o+(r^(E|~i))+s[6]+2734768916&4294967295,h=i+(E^((o=E+(h<<15&4294967295|h>>>17))|~r))+s[13]+1309151649&4294967295,h=r+(o^((i=o+(h<<21&4294967295|h>>>11))|~E))+s[4]+4149444226&4294967295,h=E+(i^((r=i+(h<<6&4294967295|h>>>26))|~o))+s[11]+3174756917&4294967295,E=r+(h<<10&4294967295|h>>>22),h=o+(r^(E|~i))+s[2]+718787259&4294967295,h=i+(E^((o=E+(h<<15&4294967295|h>>>17))|~r))+s[9]+3951481745&4294967295,e.g[0]=e.g[0]+r&4294967295,e.g[1]=e.g[1]+(o+(h<<21&4294967295|h>>>11))&4294967295,e.g[2]=e.g[2]+o&4294967295,e.g[3]=e.g[3]+E&4294967295}function t(e,r){this.h=r;const i=[];let s=!0;for(let o=e.length-1;o>=0;o--){const h=0|e[o];s&&h==r||(i[o]=h,s=!1)}this.g=i}!function k(e,r){function c(){}c.prototype=r.prototype,e.F=r.prototype,e.prototype=new c,e.prototype.constructor=e,e.D=function(e,i,s){for(var o=Array(arguments.length-2),h=2;h<arguments.length;h++)o[h-2]=arguments[h];return r.prototype[i].apply(e,o)}}(m,(function l(){this.blockSize=-1})),m.prototype.u=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0},m.prototype.v=function(e,r){void 0===r&&(r=e.length);const i=r-this.blockSize,s=this.C;let o=this.h,h=0;for(;h<r;){if(0==o)for(;h<=i;)n(this,e,h),h+=this.blockSize;if("string"==typeof e){for(;h<r;)if(s[o++]=e.charCodeAt(h++),o==this.blockSize){n(this,s),o=0;break}}else for(;h<r;)if(s[o++]=e[h++],o==this.blockSize){n(this,s),o=0;break}}this.h=o,this.o+=r},m.prototype.A=function(){var e=Array((this.h<56?this.blockSize:2*this.blockSize)-this.h);e[0]=128;for(var r=1;r<e.length-8;++r)e[r]=0;r=8*this.o;for(var i=e.length-8;i<e.length;++i)e[i]=255&r,r/=256;for(this.v(e),e=Array(16),r=0,i=0;i<4;++i)for(let s=0;s<32;s+=8)e[r++]=this.g[i]>>>s&255;return e};var r={};function u(e){return-128<=e&&e<128?function p(e,i){var s=r;return Object.prototype.hasOwnProperty.call(s,e)?s[e]:s[e]=i(e)}(e,(function(e){return new t([0|e],e<0?-1:0)})):new t([0|e],e<0?-1:0)}function v(e){if(isNaN(e)||!isFinite(e))return i;if(e<0)return x(v(-e));const r=[];let s=1;for(let i=0;e>=s;i++)r[i]=e/s|0,s*=4294967296;return new t(r,0)}var i=u(0),s=u(1),h=u(16777216);function C(e){if(0!=e.h)return!1;for(let r=0;r<e.g.length;r++)if(0!=e.g[r])return!1;return!0}function B(e){return-1==e.h}function x(e){const r=e.g.length,i=[];for(let s=0;s<r;s++)i[s]=~e.g[s];return new t(i,~e.h).add(s)}function F(e,r){return e.add(x(r))}function G(e,r){for(;(65535&e[r])!=e[r];)e[r+1]+=e[r]>>>16,e[r]&=65535,r++}function H(e,r){this.g=e,this.h=r}function D(e,r){if(C(r))throw Error("division by zero");if(C(e))return new H(i,i);if(B(e))return r=D(x(e),r),new H(x(r.g),x(r.h));if(B(r))return r=D(e,x(r)),new H(x(r.g),r.h);if(e.g.length>30){if(B(e)||B(r))throw Error("slowDivide_ only works with positive integers.");for(var o=s,h=r;h.l(e)<=0;)o=I(o),h=I(h);var E=J(o,1),T=J(h,1);for(h=J(h,2),o=J(o,2);!C(h);){var V=T.add(h);V.l(e)<=0&&(E=E.add(o),T=V),h=J(h,1),o=J(o,1)}return r=F(e,E.j(r)),new H(E,r)}for(E=i;e.l(r)>=0;){for(o=Math.max(1,Math.floor(e.m()/r.m())),h=(h=Math.ceil(Math.log(o)/Math.LN2))<=48?1:Math.pow(2,h-48),V=(T=v(o)).j(r);B(V)||V.l(e)>0;)V=(T=v(o-=h)).j(r);C(T)&&(T=s),E=E.add(T),e=F(e,V)}return new H(E,e)}function I(e){const r=e.g.length+1,i=[];for(let s=0;s<r;s++)i[s]=e.i(s)<<1|e.i(s-1)>>>31;return new t(i,e.h)}function J(e,r){const i=r>>5;r%=32;const s=e.g.length-i,o=[];for(let h=0;h<s;h++)o[h]=r>0?e.i(h+i)>>>r|e.i(h+i+1)<<32-r:e.i(h+i);return new t(o,e.h)}(e=t.prototype).m=function(){if(B(this))return-x(this).m();let e=0,r=1;for(let i=0;i<this.g.length;i++){const s=this.i(i);e+=(s>=0?s:4294967296+s)*r,r*=4294967296}return e},e.toString=function(e){if((e=e||10)<2||36<e)throw Error("radix out of range: "+e);if(C(this))return"0";if(B(this))return"-"+x(this).toString(e);const r=v(Math.pow(e,6));var i=this;let s="";for(;;){const o=D(i,r).g;let h=(((i=F(i,o.j(r))).g.length>0?i.g[0]:i.h)>>>0).toString(e);if(C(i=o))return h+s;for(;h.length<6;)h="0"+h;s=h+s}},e.i=function(e){return e<0?0:e<this.g.length?this.g[e]:this.h},e.l=function(e){return B(e=F(this,e))?-1:C(e)?0:1},e.abs=function(){return B(this)?x(this):this},e.add=function(e){const r=Math.max(this.g.length,e.g.length),i=[];let s=0;for(let o=0;o<=r;o++){let r=s+(65535&this.i(o))+(65535&e.i(o)),h=(r>>>16)+(this.i(o)>>>16)+(e.i(o)>>>16);s=h>>>16,r&=65535,h&=65535,i[o]=h<<16|r}return new t(i,-2147483648&i[i.length-1]?-1:0)},e.j=function(e){if(C(this)||C(e))return i;if(B(this))return B(e)?x(this).j(x(e)):x(x(this).j(e));if(B(e))return x(this.j(x(e)));if(this.l(h)<0&&e.l(h)<0)return v(this.m()*e.m());const r=this.g.length+e.g.length,s=[];for(var o=0;o<2*r;o++)s[o]=0;for(o=0;o<this.g.length;o++)for(let r=0;r<e.g.length;r++){const i=this.i(o)>>>16,h=65535&this.i(o),E=e.i(r)>>>16,T=65535&e.i(r);s[2*o+2*r]+=h*T,G(s,2*o+2*r),s[2*o+2*r+1]+=i*T,G(s,2*o+2*r+1),s[2*o+2*r+1]+=h*E,G(s,2*o+2*r+1),s[2*o+2*r+2]+=i*E,G(s,2*o+2*r+2)}for(e=0;e<r;e++)s[e]=s[2*e+1]<<16|s[2*e];for(e=r;e<2*r;e++)s[e]=0;return new t(s,0)},e.B=function(e){return D(this,e).h},e.and=function(e){const r=Math.max(this.g.length,e.g.length),i=[];for(let s=0;s<r;s++)i[s]=this.i(s)&e.i(s);return new t(i,this.h&e.h)},e.or=function(e){const r=Math.max(this.g.length,e.g.length),i=[];for(let s=0;s<r;s++)i[s]=this.i(s)|e.i(s);return new t(i,this.h|e.h)},e.xor=function(e){const r=Math.max(this.g.length,e.g.length),i=[];for(let s=0;s<r;s++)i[s]=this.i(s)^e.i(s);return new t(i,this.h^e.h)},m.prototype.digest=m.prototype.A,m.prototype.reset=m.prototype.u,m.prototype.update=m.prototype.v,t.prototype.add=t.prototype.add,t.prototype.multiply=t.prototype.j,t.prototype.modulo=t.prototype.B,t.prototype.compare=t.prototype.l,t.prototype.toNumber=t.prototype.m,t.prototype.toString=t.prototype.toString,t.prototype.getBits=t.prototype.i,t.fromNumber=v,t.fromString=function y(e,r){if(0==e.length)throw Error("number format error: empty string");if((r=r||10)<2||36<r)throw Error("radix out of range: "+r);if("-"==e.charAt(0))return x(y(e.substring(1),r));if(e.indexOf("-")>=0)throw Error('number format error: interior "-" character');const s=v(Math.pow(r,8));let o=i;for(let i=0;i<e.length;i+=8){var h=Math.min(8,e.length-i);const E=parseInt(e.substring(i,i+h),r);h<8?(h=v(Math.pow(r,h)),o=o.j(h).add(v(E))):(o=o.j(s),o=o.add(v(E)))}return o},o=t}).apply(void 0!==h?h:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{}),"function"==typeof SuppressedError&&SuppressedError;class User{constructor(e){this.uid=e}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}User.UNAUTHENTICATED=new User(null),User.GOOGLE_CREDENTIALS=new User("google-credentials-uid"),User.FIRST_PARTY=new User("first-party-uid"),User.MOCK_USER=new User("mock-user");let E="13.2.0-eap-sql.a9a137e67";const T=new class Logger{constructor(e){this.name=e,this._logLevel=i,this._logHandler=defaultLogHandler,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(r){if(!(r in e))throw new TypeError(`Invalid value "${r}" assigned to \`logLevel\``);this._logLevel=r}setLogLevel(e){this._logLevel="string"==typeof e?r[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...r){this._userLogHandler&&this._userLogHandler(this,e.DEBUG,...r),this._logHandler(this,e.DEBUG,...r)}log(...r){this._userLogHandler&&this._userLogHandler(this,e.VERBOSE,...r),this._logHandler(this,e.VERBOSE,...r)}info(...r){this._userLogHandler&&this._userLogHandler(this,e.INFO,...r),this._logHandler(this,e.INFO,...r)}warn(...r){this._userLogHandler&&this._userLogHandler(this,e.WARN,...r),this._logHandler(this,e.WARN,...r)}error(...r){this._userLogHandler&&this._userLogHandler(this,e.ERROR,...r),this._logHandler(this,e.ERROR,...r)}}("@firebase/firestore");function a(r,...i){if(T.logLevel<=e.DEBUG){const e=i.map(__PRIVATE_argToString);T.debug(`Firestore (${E}): ${r}`,...e)}}function st(r,...i){if(T.logLevel<=e.ERROR){const e=i.map(__PRIVATE_argToString);T.error(`Firestore (${E}): ${r}`,...e)}}function __PRIVATE_logWarn(r,...i){if(T.logLevel<=e.WARN){const e=i.map(__PRIVATE_argToString);T.warn(`Firestore (${E}): ${r}`,...e)}}function __PRIVATE_argToString(e){if("string"==typeof e)return e;try{return function __PRIVATE_formatJSON(e){return JSON.stringify(e)}(e)}catch(r){return e}}function z(e,r,i){let s="Unexpected state";"string"==typeof r?s=r:i=r,__PRIVATE__fail(e,s,i)}function __PRIVATE__fail(e,r,i){let s=`FIRESTORE (${E}) INTERNAL ASSERTION FAILED: ${r} (ID: ${e.toString(16)})`;if(void 0!==i)try{s+=" CONTEXT: "+JSON.stringify(i)}catch(e){s+=" CONTEXT: "+i}throw st(s),new Error(s)}function __PRIVATE_hardAssert(e,r,i,s){let o="Unexpected state";"string"==typeof i?o=i:s=i,e||__PRIVATE__fail(r,o,s)}function __PRIVATE_debugCast(e,r){return e}const V="ok",P="cancelled",R="unknown",b="invalid-argument",w="deadline-exceeded",S="not-found",O="permission-denied",N="unauthenticated",$="resource-exhausted",U="failed-precondition",L="aborted",M="out-of-range",Q="unimplemented",q="internal",K="unavailable";class k extends FirebaseError{constructor(e,r){super(e,r),this.code=e,this.message=r,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class __PRIVATE_EmptyAuthCredentialsProvider{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,r){e.enqueueRetryable((()=>r(User.UNAUTHENTICATED)))}shutdown(){}}class __PRIVATE_FirstPartyToken{constructor(e,r,i){this.ee=e,this.te=r,this.re=i,this.type="FirstParty",this.user=User.FIRST_PARTY,this.ne=new Map}ie(){return this.re?this.re():null}get headers(){this.ne.set("X-Goog-AuthUser",this.ee);const e=this.ie();return e&&this.ne.set("Authorization",e),this.te&&this.ne.set("X-Goog-Iam-Authorization-Token",this.te),this.ne}}class __PRIVATE_FirstPartyAuthCredentialsProvider{constructor(e,r,i){this.ee=e,this.te=r,this.re=i}getToken(){return Promise.resolve(new __PRIVATE_FirstPartyToken(this.ee,this.te,this.re))}start(e,r){e.enqueueRetryable((()=>r(User.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class DatabaseInfo{constructor(e,r,i,s,o,h,E,T,V,P,R,b,w){this.databaseId=e,this.appId=r,this.persistenceKey=i,this.host=s,this.ssl=o,this.forceLongPolling=h,this.autoDetectLongPolling=E,this.longPollingOptions=T,this.useFetchStreams=V,this.isUsingEmulator=P,this.apiKey=R,this._customHeaders=b,this.grpcFlowControlWindow=w}}const W="(default)";class DatabaseId{constructor(e,r){this.projectId=e,this.database=r||W}static empty(){return new DatabaseId("","")}get isDefaultDatabase(){return this.database===W}isEqual(e){return e instanceof DatabaseId&&e.projectId===this.projectId&&e.database===this.database}}function __PRIVATE_randomBytes(e){const r="undefined"!=typeof self&&(self.crypto||self.msCrypto),i=new Uint8Array(e);if(r&&"function"==typeof r.getRandomValues)r.getRandomValues(i);else for(let r=0;r<e;r++)i[r]=Math.floor(256*Math.random());return i}class __PRIVATE_AutoId{static newId(){const e=62*Math.floor(256/62);let r="";for(;r.length<20;){const i=__PRIVATE_randomBytes(40);for(let s=0;s<i.length;++s)r.length<20&&i[s]<e&&(r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(i[s]%62))}return r}}function __PRIVATE_primitiveComparator(e,r){return e<r?-1:e>r?1:0}function __PRIVATE_compareUtf8Strings(e,r){const i=Math.min(e.length,r.length);for(let s=0;s<i;s++){const i=e.charAt(s),o=r.charAt(s);if(i!==o)return __PRIVATE_isSurrogate(i)===__PRIVATE_isSurrogate(o)?__PRIVATE_primitiveComparator(i,o):__PRIVATE_isSurrogate(i)?1:-1}return __PRIVATE_primitiveComparator(e.length,r.length)}const X=55296,Y=57343;function __PRIVATE_isSurrogate(e){const r=e.charCodeAt(0);return r>=X&&r<=Y}const Z="__name__";class BasePath{constructor(e,r,i){void 0===r?r=0:r>e.length&&z(637,{offset:r,range:e.length}),void 0===i?i=e.length-r:i>e.length-r&&z(1746,{length:i,range:e.length-r}),this.segments=e,this.offset=r,this.len=i}get length(){return this.len}isEqual(e){return 0===BasePath.comparator(this,e)}child(e){const r=this.segments.slice(this.offset,this.limit());return e instanceof BasePath?e.forEach((e=>{r.push(e)})):r.push(e),this.construct(r)}limit(){return this.offset+this.length}popFirst(e){return e=void 0===e?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 0===this.length}isPrefixOf(e){if(e.length<this.length)return!1;for(let r=0;r<this.length;r++)if(this.get(r)!==e.get(r))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let r=0;r<this.length;r++)if(this.get(r)!==e.get(r))return!1;return!0}forEach(e){for(let r=this.offset,i=this.limit();r<i;r++)e(this.segments[r])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,r){const i=Math.min(e.length,r.length);for(let s=0;s<i;s++){const i=BasePath.compareSegments(e.get(s),r.get(s));if(0!==i)return i}return __PRIVATE_primitiveComparator(e.length,r.length)}static compareSegments(e,r){const i=BasePath.isNumericId(e),s=BasePath.isNumericId(r);return i&&!s?-1:!i&&s?1:i&&s?BasePath.extractNumericId(e).compare(BasePath.extractNumericId(r)):__PRIVATE_compareUtf8Strings(e,r)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return o.fromString(e.substring(4,e.length-2))}}class ResourcePath extends BasePath{construct(e,r,i){return new ResourcePath(e,r,i)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toStringWithLeadingSlash(){return`/${this.canonicalString()}`}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const r=[];for(const i of e){if(i.indexOf("//")>=0)throw new k(b,`Invalid segment (${i}). Paths must not contain // in them.`);r.push(...i.split("/").filter((e=>e.length>0)))}return new ResourcePath(r)}static emptyPath(){return new ResourcePath([])}}const ee=/^[_a-zA-Z][_a-zA-Z0-9]*$/;let te=class FieldPath extends BasePath{construct(e,r,i){return new FieldPath(e,r,i)}static isValidIdentifier(e){return ee.test(e)}canonicalString(){return this.toArray().map((e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),FieldPath.isValidIdentifier(e)||(e="`"+e+"`"),e))).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&this.get(0)===Z}static keyField(){return new FieldPath([Z])}static fromServerFormat(e){const r=[];let i="",s=0;const __PRIVATE_addCurrentSegment=()=>{if(0===i.length)throw new k(b,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);r.push(i),i=""};let o=!1;for(;s<e.length;){const r=e[s];if("\\"===r){if(s+1===e.length)throw new k(b,"Path has trailing escape character: "+e);const r=e[s+1];if("\\"!==r&&"."!==r&&"`"!==r)throw new k(b,"Path has invalid escape sequence: "+e);i+=r,s+=2}else"`"===r?(o=!o,s++):"."!==r||o?(i+=r,s++):(__PRIVATE_addCurrentSegment(),s++)}if(__PRIVATE_addCurrentSegment(),o)throw new k(b,"Unterminated ` in path: "+e);return new FieldPath(r)}static emptyPath(){return new FieldPath([])}};class C{constructor(e){this.path=e}static fromPath(e){return new C(ResourcePath.fromString(e))}static fromName(e){return new C(ResourcePath.fromString(e).popFirst(5))}static empty(){return new C(ResourcePath.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 null!==e&&0===ResourcePath.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,r){return ResourcePath.comparator(e.path,r.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new C(new ResourcePath(e.slice()))}}function __PRIVATE_validateNonEmptyArgument(e,r,i){if(!i)throw new k(b,`Function ${e}() cannot be called with an empty ${r}.`)}function __PRIVATE_validateDocumentPath(e){if(!C.isDocumentKey(e))throw new k(b,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function __PRIVATE_isPlainObject(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}function __PRIVATE_valueDescription(e){if(void 0===e)return"undefined";if(null===e)return"null";if("string"==typeof e)return e.length>20&&(e=`${e.substring(0,20)}...`),JSON.stringify(e);if("number"==typeof e||"boolean"==typeof e)return""+e;if("object"==typeof e){if(e instanceof Array)return"an array";{const r=function __PRIVATE_tryGetCustomObjectType(e){return e.constructor?e.constructor.name:null}(e);return r?`a custom ${r} object`:"an object"}}return"function"==typeof e?"a function":z(12329,{type:typeof e})}function __PRIVATE_cloneLongPollingOptions(e){const r={};return void 0!==e.timeoutSeconds&&(r.timeoutSeconds=e.timeoutSeconds),r}let re=null;function __PRIVATE_isNegativeZero(e){return 0===e&&1/e==-1/0}function __PRIVATE_isNumber(e){return"number"==typeof e}function __PRIVATE_isString(e){return"string"==typeof e}const ne="RestConnection",ie={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery",ExecutePipeline:"executePipeline"};class __PRIVATE_RestConnection{get ae(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const r=e.ssl?"https":"http",i=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.ue=r+"://"+e.host,this._e=`projects/${i}/databases/${s}`,this.ce=this.databaseId.database===W?`project_id=${i}`:`project_id=${i}&database_id=${s}`}le(e,r,i,s,o){const h=function __PRIVATE_generateUniqueDebugId(){return null===re?re=function __PRIVATE_generateInitialUniqueDebugId(){return 268435456+Math.round(2147483648*Math.random())}():re++,"0x"+re.toString(16)}(),E=this.fe(e,r.toUriEncodedString());a(ne,`Sending RPC '${e}' ${h}:`,E,i);const T={"google-cloud-resource-prefix":this._e,"x-goog-request-params":this.ce};this.he(T,s,o);const{host:V}=new URL(E),P=function isCloudWorkstation(e){try{return(e.startsWith("http://")||e.startsWith("https://")?new URL(e).hostname:e).endsWith(".cloudworkstations.dev")}catch{return!1}}(V);return this.de(e,E,T,i,P).then((r=>(a(ne,`Received RPC '${e}' ${h}: `,r),r)),(r=>{throw __PRIVATE_logWarn(ne,`RPC '${e}' ${h} failed with error: `,r,"url: ",E,"request:",i),r}))}me(e,r,i,s,o,h){return this.le(e,r,i,s,o)}he(e,r,i){if(e["X-Goog-Api-Client"]=function __PRIVATE_getGoogApiClientValue(){return"gl-js/ fire/"+E}(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),r&&r.headers.forEach(((r,i)=>e[i]=r)),i&&i.headers.forEach(((r,i)=>e[i]=r)),this.databaseInfo._customHeaders)for(const r of Object.keys(this.databaseInfo._customHeaders))e[r]=this.databaseInfo._customHeaders[r]}fe(e,r){const i=ie[e];let s=`${this.ue}/v1/${r}:${i}`;return this.databaseInfo.apiKey&&(s=`${s}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),s}terminate(){}}var se,ae,oe,ue,le,_e,ce,pe;function __PRIVATE_mapCodeFromHttpStatus(e){if(void 0===e)return st("RPC_ERROR","HTTP error has no status"),R;switch(e){case 200:return V;case 400:return U;case 401:return N;case 403:return O;case 404:return S;case 409:return L;case 416:return M;case 429:return $;case 499:return P;case 500:return R;case 501:return Q;case 503:return K;case 504:return w;default:return e>=200&&e<300?V:e>=400&&e<500?U:e>=500&&e<600?q:R}}(ae=se||(se={}))[ae.OK=0]="OK",ae[ae.CANCELLED=1]="CANCELLED",ae[ae.UNKNOWN=2]="UNKNOWN",ae[ae.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",ae[ae.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",ae[ae.NOT_FOUND=5]="NOT_FOUND",ae[ae.ALREADY_EXISTS=6]="ALREADY_EXISTS",ae[ae.PERMISSION_DENIED=7]="PERMISSION_DENIED",ae[ae.UNAUTHENTICATED=16]="UNAUTHENTICATED",ae[ae.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",ae[ae.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",ae[ae.ABORTED=10]="ABORTED",ae[ae.OUT_OF_RANGE=11]="OUT_OF_RANGE",ae[ae.UNIMPLEMENTED=12]="UNIMPLEMENTED",ae[ae.INTERNAL=13]="INTERNAL",ae[ae.UNAVAILABLE=14]="UNAVAILABLE",ae[ae.DATA_LOSS=15]="DATA_LOSS";class __PRIVATE_FetchConnection extends __PRIVATE_RestConnection{Ee(e,r){throw new Error("Not supported by FetchConnection")}async de(e,r,i,s,o){const h=JSON.stringify(s);let E;try{const e={method:"POST",headers:i,body:h};o&&(e.credentials="include"),E=await fetch(r,e)}catch(e){const r=e,i=r?.message,s=r?.cause?String(r.cause):void 0,o=(i&&s?`${i} (${s})`:i??s)??r?.statusText??String(e);throw new k(__PRIVATE_mapCodeFromHttpStatus(r?.status),`Request failed with error: ${o}`)}if(!E.ok){let e=await E.json();Array.isArray(e)&&(e=e[0]);const r=e?.error?.message;throw new k(__PRIVATE_mapCodeFromHttpStatus(E.status),`Request failed with error: ${r??E.statusText}`)}return E.json()}}class __PRIVATE_Base64DecodeError extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class ByteString{constructor(e){this.binaryString=e}static fromBase64String(e){const r=function __PRIVATE_decodeBase64(e){try{return atob(e)}catch(e){throw"undefined"!=typeof DOMException&&e instanceof DOMException?new __PRIVATE_Base64DecodeError("Invalid base64 string: "+e):e}}(e);return new ByteString(r)}static fromUint8Array(e){const r=function __PRIVATE_binaryStringFromUint8Array(e){let r="";for(let i=0;i<e.length;++i)r+=String.fromCharCode(e[i]);return r}(e);return new ByteString(r)}[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 __PRIVATE_encodeBase64(e){return btoa(e)}(this.binaryString)}toUint8Array(){return function __PRIVATE_uint8ArrayFromBinaryString(e){const r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i);return r}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return __PRIVATE_primitiveComparator(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}function __PRIVATE_objectSize(e){let r=0;for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&r++;return r}function forEach(e,r){for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&r(i,e[i])}ByteString.EMPTY_BYTE_STRING=new ByteString("");class __PRIVATE_QuadrupleBuilder{constructor(){this.exponent=0,this.Ve=0n,this.Te=0n,this.Ie=new Array(4).fill(0n),this.Ae=new Array(6).fill(0n),this.Re=new Array(6).fill(0n),this.Pe=new Array(6).fill(0n),this.pe=new Array(12).fill(0n)}static ye(e,r){let i=new __PRIVATE_QuadrupleBuilder;return i.parse(e,r),i}parse(e,r){r+=e.length-1,this.exponent=0,this.Ve=0n,this.Te=0n;let i=this.Pe,s=this.be(e,i);if(0==s&&this.isEmpty(i))return;if((r+=s)<__PRIVATE_QuadrupleBuilder.we)return;if(r>__PRIVATE_QuadrupleBuilder.ge)return void(this.exponent=Number(__PRIVATE_QuadrupleBuilder.Fe));let o=this.ve(r,i);this.xe(r,o,i)}be(e,r){for(let e=0;e<6;e++)r[e]=0n;let i=0;for(;i<e.length&&0==e[i];)i+=1;if(i==e.length)return 0;let s=-i;if(e.length-i>__PRIVATE_QuadrupleBuilder.De){let r=e[__PRIVATE_QuadrupleBuilder.De]>=5,o=new Array(__PRIVATE_QuadrupleBuilder.De).fill(0);for(let r=0;r<__PRIVATE_QuadrupleBuilder.De;r++)o[r]=e[r+i];r&&(s+=this.Ne(o)),e=o,i=0}for(let s=e.length-1;s>=i;s--)r[0]|=BigInt(e[s])<<32n,this.Se(r);return s}Se(e){let r=e.length;for(let i=0;i<r;i++){let s=e[i]%10n;e[i]=e[i]/10n,i+1<r&&(e[i+1]+=s<<32n)}}isEmpty(e){for(let r=0;r<e.length;r++)if(0n!=e[r])return!1;return!0}Ne(e){for(let r=e.length-1;r>=0;r--){if(9!=e[r])return e[r]=e[r]+1,0;e[r]=0}return e[0]=1,1}ve(e,r){let i=r[0]<<31n|r[1]>>1n,s=Number(i)/__PRIVATE_QuadrupleBuilder.Ce;return Math.floor(Number(e)*__PRIVATE_QuadrupleBuilder.Be+this.log2(s))}log2(e){return __PRIVATE_QuadrupleBuilder.Qe*Math.log(e)}xe(e,r,i){let s=this.Ie;this.Oe(-r,s);let o=this.pe;this.Me(i,s,o),this.qe(o),BigInt(s[0])!=BigInt(-e)&&this.qe(o),r+=this.Le(o),(r+=__PRIVATE_QuadrupleBuilder.Ue)<=0||(r+=this.$e(o),BigInt(r)>=__PRIVATE_QuadrupleBuilder.Fe?this.exponent=Number(__PRIVATE_QuadrupleBuilder.Fe):(this.exponent=Number(r),this.Ve=(o[0]<<32n)+o[1]&0xffffffffffffffffn,this.Te=(o[2]<<32n)+o[3]&0xffffffffffffffffn))}Oe(e,r){if(0==e)return void this.ke(__PRIVATE_QuadrupleBuilder.je[0],r);let i=__PRIVATE_QuadrupleBuilder.je;e<0&&(e=-e,i=__PRIVATE_QuadrupleBuilder.Ke);let s=__PRIVATE_QuadrupleBuilder.ze,o=32,h=!0;for(;e>0;)e>=s&&(h?(this.ke(i[o],r),h=!1):this.We(r,i[o],r),e-=s),o-=1,s*=.5}ke(e,r){for(let i=0;i<r.length;i++)r[i]=e[i]}We(e,r,i){this.Ge(e,r,this.pe);let s=this.Je(this.pe);this.He(this.pe,i),i[0]=e[0]+r[0]+BigInt(s)}Ge(e,r,i){for(let e=0;e<i.length;e++)i[e]=0n;this.Ye(e,this.Ae),this.Ye(r,this.Re);for(let e=5;e>=0;e--)for(let r=5;r>=0;r--){let s=this.Ae[e]*this.Re[r];i[r+e+1]=i[r+e+1]+(s&__PRIVATE_QuadrupleBuilder.Xe)&0xffffffffffffffffn,i[r+e]=i[r+e]+(s>>32n)&0xffffffffffffffffn}for(let e=11;e>=1;e--)i[e-1]=i[e-1]+(i[e]>>32n)&0xffffffffffffffffn,i[e]&=__PRIVATE_QuadrupleBuilder.Xe}Je(e){let r=0;for(;this.Ze(e);)this.qe(e),r-=1;return r}Ze(e){if(e[0]<0x19999999n)return!0;if(e[0]>0x19999999n)return!1;for(let r=1;r<e.length;r++){if(e[r]<0x99999999n)return!0;if(e[r]>0x99999999n)return!1}return!1}Me(e,r,i){for(let e=0;e<i.length;e++)i[e]=0n;let s=this.Re;this.Ye(r,s);let o=e.length;for(let r=o-1;r>=0;r--)for(let h=o-1;h>=0;h--){let o=e[r]*s[h];i[h+r+1]=i[h+r+1]+(o&__PRIVATE_QuadrupleBuilder.Xe)&0xffffffffffffffffn,i[h+r]=i[h+r]+(o>>32n)&0xffffffffffffffffn}for(let e=11;e>=1;e--)i[e-1]=i[e-1]+(i[e]>>32n)&0xffffffffffffffffn,i[e]&=__PRIVATE_QuadrupleBuilder.Xe}qe(e){let r=e.length-1;e[0]&=__PRIVATE_QuadrupleBuilder.Xe,e[r]*=10n;for(let i=r-1;i>=0;i--)e[i]=10n*e[i]+(e[i+1]>>32n)&0xffffffffffffffffn,e[i+1]&=__PRIVATE_QuadrupleBuilder.Xe}Le(e){let r=31-__PRIVATE_QuadrupleBuilder.et(e[0]);return 0!=r&&this.tt(e,r),r}$e(e){return this.rt(e,5,100n),this.rt(e,4,0x80000000n),0n!=(e[0]&__PRIVATE_QuadrupleBuilder.nt<<1n)?(this.tt(e,1),1):0}He(e,r){r[1]=(e[0]<<32n)+e[1],r[2]=(e[2]<<32n)+e[3],r[3]=(e[4]<<32n)+e[5]}Ye(e,r){r[0]=e[1]>>32n,r[1]=e[1]&__PRIVATE_QuadrupleBuilder.Xe,r[2]=e[2]>>32n,r[3]=e[2]&__PRIVATE_QuadrupleBuilder.Xe,r[4]=e[3]>>32n,r[5]=e[3]&__PRIVATE_QuadrupleBuilder.Xe}tt(e,r){let i=e.length-1,s=BigInt(32-Math.abs(r));if(r>0){let o=BigInt(r);for(let r=i+1-1;r>=1;r--)e[r]=e[r]>>o|e[r-1]<<s&__PRIVATE_QuadrupleBuilder.Xe;e[0]=e[0]>>o}else if(r<0){let o=BigInt(-r);e[0]=0xffffffffffffffffn&(e[0]<<o|e[1]>>s);for(let r=1;r<i;r++)e[r]=0xffffffffffffffffn&(e[r]<<o&__PRIVATE_QuadrupleBuilder.Xe|e[r+1]>>s);e[i]=e[i]<<o&__PRIVATE_QuadrupleBuilder.Xe}}rt(e,r,i){let s=r;e[s]=e[s]+i&0xffffffffffffffffn;for(let r=s+1-1;r>=1&&0n!=(e[r]&__PRIVATE_QuadrupleBuilder.nt);r--)e[r]&=__PRIVATE_QuadrupleBuilder.Xe,e[r-1]+=1n}static et(e){let r=Number(e>>32n);return 0==r?32+Math.clz32(Number(BigInt.asUintN(32,e))):Math.clz32(r)}}__PRIVATE_QuadrupleBuilder.De=59,__PRIVATE_QuadrupleBuilder.ge=646456993,__PRIVATE_QuadrupleBuilder.we=-646457032,__PRIVATE_QuadrupleBuilder.Ce=0xccccccccccccd00,__PRIVATE_QuadrupleBuilder.it=0x8000000000000000n,__PRIVATE_QuadrupleBuilder.ze=2147483648,__PRIVATE_QuadrupleBuilder.Xe=0x00000000ffffffffn,__PRIVATE_QuadrupleBuilder.nt=0xffffffff00000000n,__PRIVATE_QuadrupleBuilder.Be=Math.log(10)/Math.log(2),__PRIVATE_QuadrupleBuilder.Qe=1/Math.log(2),__PRIVATE_QuadrupleBuilder.Ue=2147483647,__PRIVATE_QuadrupleBuilder.Fe=0xffffffffn,__PRIVATE_QuadrupleBuilder.je=[[1n,0x1999999999999999n,0x9999999999999999n,0x999999999999999an],[1n,0x3333333333333333n,0x3333333333333333n,0x3333333333333334n],[1n,0x6666666666666666n,0x6666666666666666n,0x6666666666666667n],[2n,0x28f5c28f5c28f5c2n,0x8f5c28f5c28f5c28n,0xf5c28f5c28f5c290n],[3n,0x4189374bc6a7ef9dn,0xb22d0e5604189374n,0xbc6a7ef9db22d0e6n],[5n,0xa7c5ac471b478423n,0x0fcf80dc33721d53n,0xcddd6e04c0592104n],[10n,0x6df37f675ef6eadfn,0x5ab9a2072d44268dn,0x97df837e6748956en],[20n,0x2f394219248446ban,0xa23d2ec729af3d61n,0x0607aa0167dd94cbn],[39n,0x571cbec554b60dbbn,0xd5f64baf0506840dn,0x451db70d5904029bn],[78n,0x1da48ce468e7c702n,0x6520247d3556476dn,0x1469caf6db224cfan],[155n,0x2252f0e5b39769dcn,0x9ae2eea30ca3ade0n,0xeeaa3c08dfe84e30n],[309n,0x2e055c9a3f6ba793n,0x16583a816eb60a59n,0x22c4b0826cf1ebf7n],[617n,0x52bb45e9cf23f17fn,0x7688c07606e50364n,0xb34479aa9d449a57n],[1234n,0x1abc81c8ff5f846cn,0x8f5e3c9853e38c97n,0x45060097f3bf9296n],[2467n,0x1bec53b510daa7b4n,0x48369ed77dbb0eb1n,0x3b05587b2187b41en],[4933n,0x1e75063a5ba91326n,0x8abfb8e460016ae3n,0x28008702d29e8a3cn],[9865n,0x243c5d8bb5c5fa55n,0x40c6d248c5881915n,0x4c0fd99fd5befc22n],[19729n,0x334a5570c3f4ef3cn,0xa13c36c43f979c90n,0xda7ac473555fb7a8n],[39457n,0x66c304445dd98f3bn,0xa8c293a20e47a41bn,0x4c5b03dc12604964n],[78914n,0x293ffbf5fb028cc4n,0x89d3e5ff44238406n,0x369a339e1bfe8c9bn],[157827n,0x427792fbb68e5d20n,0x7b297cd9fc154b62n,0xf09142114aa9a20cn],[315653n,0xac92bc65ad5c08fcn,0x00beeb115a566c19n,0x4ba882d8a4622437n],[631306n,0x745581440f92e80en,0x4da822cf7f896f41n,0x509d598678164ecdn],[1262612n,0x34dd99b4c69523a5n,0x64bc2e8f0d8b1044n,0xb03b1c96da5dd349n],[2525223n,0x6d2bbea9d6d25a08n,0xa0a4606a88e96b70n,0x182063bbc2fe8520n],[5050446n,0x2e8e47d63bfdd6e3n,0x2b55fa8976eaa3e9n,0x1a6b9d3086412a73n],[10100891n,0x54aa68efa1d719dfn,0xd8505806612c5c8fn,0xad068837fee8b43an],[20201782n,0x1c00464ccb7bae77n,0x9e3877784c77982cn,0xd94af3b61717404fn],[40403563n,0x1ea099c8be2b6cd0n,0x8bfb6d539fa50466n,0x6d3bc37e69a84218n],[80807125n,0x24a457f466ce8d18n,0xf2c8f3b81bc6bb59n,0xa78c757692e02d49n],[161614249n,0x347256677aba6b53n,0x3fbf90d30611a67cn,0x1e039d87e0bdb32bn],[323228497n,0x6b727daf0fd3432an,0x71f71121f9e4200fn,0x8fcd9942d486c10cn],[646456994n,0x2d18e84484d91f78n,0x4079bfe7829dec6fn,0x21551643e365abc6n]],__PRIVATE_QuadrupleBuilder.Ke=[[1n,0x1999999999999999n,0x9999999999999999n,0x999999999999999an],[0n,0x8000000000000000n,0x0000000000000000n,0x0000000000000000n],[0n,0x4000000000000000n,0x0000000000000000n,0x0000000000000001n],[-1n,0xa000000000000000n,0x0000000000000000n,0x0000000000000000n],[-2n,0x6400000000000000n,0x0000000000000000n,0x0000000000000000n],[-4n,0x2710000000000000n,0x0000000000000000n,0x0000000000000001n],[-9n,0x3b9aca0000000000n,0x0000000000000000n,0x0000000000000001n],[-19n,0x8ac7230489e80000n,0x0000000000000000n,0x0000000000000000n],[-38n,0x4b3b4ca85a86c47an,0x098a224000000000n,0x0000000000000001n],[-77n,0xdd15fe86affad912n,0x49ef0eb713f39eben,0xaa987b6e6fd2a002n],[-154n,0xbeeefb584aff8603n,0xaafb550ffacfd8fan,0x5ca47e4f88d45371n],[-308n,0x8e679c2f5e44ff8fn,0x570f09eaa7ea7648n,0x5961db50c6d2b888n],[-616n,0x4f371b3399fc2ab0n,0x8170041c9feb05aan,0xc7c343447c75bcf6n],[-1233n,0xf51e928179013fd3n,0xde4bd12cde4d985cn,0x4a573ca6f94bff14n],[-2466n,0xeab388127bccaff7n,0x1667639142b9fbaen,0x775ec9995e1039fbn],[-4932n,0xd72cb2a95c7ef6ccn,0xe81bf1e825ba7515n,0xc2feb521d6cb5dcdn],[-9864n,0xb4dc1be6604502dcn,0xd491079b8eef6535n,0x578d3965d24de84dn],[-19728n,0x7fc6447bee60ea43n,0x2548da5c8b125b27n,0x5f42d1142f41d349n],[-39456n,0x3fc65180f88af8fbn,0x6a6915f383349413n,0x063c3708b6ceb291n],[-78913n,0x9ee0197c8dcd55bfn,0x2b2b9b942c38f4a2n,0x0f8ba634e9c706aen],[-157826n,0x629963a25b8b2d79n,0xd00b9d2286f70876n,0xe97004700c3644fcn],[-315652n,0x25f9cc308ceef4f3n,0x40f19543911a4546n,0xa2cd389452cfc366n],[-631305n,0x385597b0d47e76b8n,0x1b9f67e103bf2329n,0xc3119848595985f7n],[-1262611n,0x7bf795d276c12f66n,0x66a61d62a446659an,0xa1a4d73bebf093d5n],[-2525222n,0x3c07d96ab1ed7799n,0xcb7355c22cc05ac0n,0x4ffc0ab73b1f6a49n],[-5050445n,0x8cc4cd8c3edefb9an,0x6c8ff86a90a97e0cn,0x166cfddbf98b71bfn],[-10100890n,0x4d67d81cc88e1228n,0x1d7cfb06666b79b3n,0x7b916728aaa4e70dn],[-20201781n,0xea0c55494e7a552dn,0xb88cb9484bb86c61n,0x8d44893c610bb7dfn],[-40403562n,0xd5fa8c821ec0c24an,0xa80e46e764e0f8b0n,0xa7276bfa432fac7en],[-80807124n,0xb2dae307426f6791n,0xc970b82f58b12918n,0x0472592f7f39190en],[-161614248n,0x7cf51edd8a15f1c9n,0x656dab3498f8e697n,0x12daa2a80e53c807n],[-323228496n,0x3cfe609ab5883c50n,0xbec8b5d22b198871n,0xe18477703b4622b4n],[-646456993n,0x9152447b9d7cda9an,0x3b4d3f6110d77aadn,0xfa81bad1c394adb4n]];class __PRIVATE_Quadruple{constructor(e,r,i,s){this.negative=e,this.st=r,this.Ve=i,this.Te=s}exponent(){return this.st-__PRIVATE_QuadrupleBuilder.Ue}ot(){return 0===this.st&&0n===this.Ve&&0n===this.Te}ut(){return this.st===__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"f",ue)&&0n===this.Ve&&0n===this.Te}isNaN(){return this.st===__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"f",ue)&&!(0n===this.Ve&&0n===this.Te)}compareTo(e){if(this.isNaN())return e.isNaN()?0:1;if(e.isNaN())return-1;let r,i;if(this.negative){if(!e.negative)return-1;r=1,i=-1}else{if(e.negative)return 1;r=-1,i=1}return this.st<e.st?r:this.st>e.st?i:this.Ve<e.Ve?r:this.Ve>e.Ve?i:this.Te<e.Te?r:this.Te>e.Te?i:0}debug(){return(this.negative?"+":"-")+__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",le).call(__PRIVATE_Quadruple,this.Ve)+__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",le).call(__PRIVATE_Quadruple,this.Te)+"*2^"+this.exponent()}static fromNumber(e){if(isNaN(e))return __PRIVATE_Quadruple.NaN;if(!isFinite(e))return e<0?__PRIVATE_Quadruple._t:__PRIVATE_Quadruple.ct;if(0===e)return Math.sign(1/e)>0?__PRIVATE_Quadruple.lt:__PRIVATE_Quadruple.ft;const r=new DataView(new ArrayBuffer(8));r.setFloat64(0,e);const i=r.getBigUint64(0);let s=BigInt.asUintN(64,i<<12n),o=2047&Number(i>>52n);if(0===o){const e=__PRIVATE_QuadrupleBuilder.et(s);s=e<63?s<<BigInt(e+1):0n,o=-e}return new __PRIVATE_Quadruple(e<0,__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",pe).call(__PRIVATE_Quadruple,o-1023),s,0n)}static fromString(e){if("NaN"===e)return __PRIVATE_Quadruple.NaN;if("-Infinity"===e)return __PRIVATE_Quadruple._t;if("Infinity"===e||"+Infinity"===e)return __PRIVATE_Quadruple.ct;const r=new Array(e.length).fill(0);let i=0,s=0,o=0,h=!1;for("-"===e[i]?(h=!0,i++):"+"===e[i]&&i++;__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",_e).call(__PRIVATE_Quadruple,e,i);)r[s++]=__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",ce).call(__PRIVATE_Quadruple,e,i++);if("."===e[i]){const h=++i;for(;__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",_e).call(__PRIVATE_Quadruple,e,i);)r[s++]=__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",ce).call(__PRIVATE_Quadruple,e,i++);o=h-i}if("e"===e[i]||"E"===e[i]){let r=0;i++;let s=1;"-"===e[i]?(s=-1,i++):"+"===e[i]&&i++;const h=i;for(;__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",_e).call(__PRIVATE_Quadruple,e,i);)if(r=10*r+__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",ce).call(__PRIVATE_Quadruple,e,i++),i-h>9)throw new Error("Exponent too large "+e);if(i===h)throw new Error("Invalid number "+e);o+=r*s}if(0===s||i!==e.length)throw new Error("Invalid number "+e);const E=__PRIVATE_QuadrupleBuilder.ye(r.slice(0,s),o);return new __PRIVATE_Quadruple(h,E.exponent,E.Ve,E.Te)}}oe=__PRIVATE_Quadruple,le=function ___PRIVATE_Quadruple_hex(e){return e.toString(16).padStart(16,"0")},_e=function ___PRIVATE_Quadruple_isDigit(e,r){const i=e.codePointAt(r);return void 0!==i&&i>=48&&i<=57},ce=function ___PRIVATE_Quadruple_digit(e,r){return e.codePointAt(r)-48},pe=function ___PRIVATE_Quadruple_bias(e){return e+__PRIVATE_QuadrupleBuilder.Ue},ue={value:Number(__PRIVATE_QuadrupleBuilder.Fe)},__PRIVATE_Quadruple.lt=new __PRIVATE_Quadruple(!1,0,0n,0n),__PRIVATE_Quadruple.ft=new __PRIVATE_Quadruple(!0,0,0n,0n),__PRIVATE_Quadruple.NaN=new __PRIVATE_Quadruple(!1,__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"f",ue),1n<<63n,0n),__PRIVATE_Quadruple._t=new __PRIVATE_Quadruple(!0,__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"f",ue),0n,0n),__PRIVATE_Quadruple.ct=new __PRIVATE_Quadruple(!1,__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"f",ue),0n,0n),new __PRIVATE_Quadruple(!0,__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",pe).call(__PRIVATE_Quadruple,63),0n,0n),new __PRIVATE_Quadruple(!1,__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",pe).call(__PRIVATE_Quadruple,0),0n,0n),new __PRIVATE_Quadruple(!0,__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",pe).call(__PRIVATE_Quadruple,0),0n,0n);const de=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function __PRIVATE_normalizeTimestamp(e){if(__PRIVATE_hardAssert(!!e,39018),"string"==typeof e){let r=0;const i=de.exec(e);if(__PRIVATE_hardAssert(!!i,46558,{timestamp:e}),i[1]){let e=i[1];e=(e+"000000000").substr(0,9),r=Number(e)}const s=new Date(e);return{seconds:Math.floor(s.getTime()/1e3),nanos:r}}return{seconds:__PRIVATE_normalizeNumber(e.seconds),nanos:__PRIVATE_normalizeNumber(e.nanos)}}function __PRIVATE_normalizeNumber(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function __PRIVATE_normalizeByteString(e){return"string"==typeof e?ByteString.fromBase64String(e):ByteString.fromUint8Array(e)}function property(e,r){const i={typeString:e};return r&&(i.value=r),i}function __PRIVATE_validateJSON(e,r){if(!__PRIVATE_isPlainObject(e))throw new k(b,"JSON must be an object");let i;for(const s in r)if(r[s]){const o=r[s].typeString,h="value"in r[s]?{value:r[s].value}:void 0,E=r[s].optional;if(!(s in e)){if(E)continue;i=`JSON missing required field: '${s}'`;break}const T=e[s];if(o&&typeof T!==o){i=`JSON field '${s}' must be a ${o}.`;break}if(void 0!==h&&T!==h.value){i=`Expected '${s}' field to equal '${h.value}'`;break}}if(i)throw new k(b,i);return!0}const fe=-62135596800,he=1e6;class Timestamp{static now(){return Timestamp.fromMillis(Date.now())}static fromDate(e){return Timestamp.fromMillis(e.getTime())}static fromMillis(e){const r=Math.floor(e/1e3),i=Math.floor((e-1e3*r)*he);return new Timestamp(r,i)}static fromInstant(e){if(!e||"bigint"!=typeof e.ht)throw new k(b,"Invalid Temporal.Instant object provided.");return Timestamp._fromEpochNanoseconds(e.ht)}static _fromEpochNanoseconds(e){let r,i;if(e>=0n)r=Number(e/1000000000n),i=Number(e%1000000000n);else{const s=e%1000000000n;0n===s?(r=Number(e/1000000000n),i=0):(r=Number(e/1000000000n-1n),i=Number(s+1000000000n))}return new Timestamp(r,i)}constructor(e,r){if(this.seconds=e,this.nanoseconds=r,r<0)throw new k(b,"Timestamp nanoseconds out of range: "+r);if(r>=1e9)throw new k(b,"Timestamp nanoseconds out of range: "+r);if(e<fe)throw new k(b,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new k(b,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/he}toInstant(){if("undefined"==typeof Temporal||!Temporal.Instant)throw new k(U,"The Temporal object is not available in the current environment.");const e=1000000000n*BigInt(this.seconds)+BigInt(this.nanoseconds);return Temporal.Instant.__PRIVATE_fromEpochNanoseconds(e)}_compareTo(e){return this.seconds===e.seconds?__PRIVATE_primitiveComparator(this.nanoseconds,e.nanoseconds):__PRIVATE_primitiveComparator(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{type:Timestamp._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(__PRIVATE_validateJSON(e,Timestamp._jsonSchema))return new Timestamp(e.seconds,e.nanoseconds)}valueOf(){const e=this.seconds-fe;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}function __PRIVATE_getPreviousValue(e){const r=e.mapValue.fields.__previous_value__;return function __PRIVATE_isServerTimestamp(e){const r=(e?.mapValue?.fields||{}).__type__?.stringValue;return"server_timestamp"===r}(r)?__PRIVATE_getPreviousValue(r):r}function __PRIVATE_getLocalWriteTime(e){const r=__PRIVATE_normalizeTimestamp(e.mapValue.fields.__local_write_time__.timestampValue);return new Timestamp(r.seconds,r.nanos)}Timestamp._jsonSchemaVersion="firestore/timestamp/1.0",Timestamp._jsonSchema={type:property("string",Timestamp._jsonSchemaVersion),seconds:property("number"),nanoseconds:property("number")};const me="__type__",Ee="__vector__",Te="value",ge="server_timestamp",Ve="__min__",Pe="__max__",Ae="__regex__",Ie="pattern",Re="options",xe="__oid__",ye="__int__",be="__decimal128__",ve="__request_timestamp__",we="seconds",Se="increment",De="__binary__",Fe={};var Oe,Ne;(Ne=Oe||(Oe={})).dt="regexValue",Ne.Et="bsonObjectIdValue",Ne.Vt="int32Value",Ne.Tt="decimal128Value",Ne.It="bsonTimestampValue",Ne.At="bsonBinaryValue",Ne.Rt="minKeyValue",Ne.Pt="maxKeyValue",Ne.yt="maxValue",Ne.bt="vectorValue",Ne.wt="serverTimestampValue",Ne.gt="regularMapValue";const $e={[Ee]:Oe.bt,[Pe]:Oe.yt,[ge]:Oe.wt},Ue={[Ae]:Oe.dt,[xe]:Oe.Et,[ye]:Oe.Vt,[be]:Oe.Tt,[ve]:Oe.It,[De]:Oe.At,[Ve]:Oe.Rt,[Pe]:Oe.Pt};function __PRIVATE_typeOrder(e){if("nullValue"in e)return 0;if("booleanValue"in e)return 2;if("integerValue"in e||"doubleValue"in e)return 3;if("timestampValue"in e)return 4;if("stringValue"in e)return 7;if("bytesValue"in e)return 8;if("referenceValue"in e)return 9;if("geoPointValue"in e)return 11;if("arrayValue"in e)return 13;if(!("mapValue"in e))return z(28295,{value:e});{const r=function __PRIVATE_detectMapRepresentation(e){if(!e.mapValue?.fields)return Oe.gt;const r=e.mapValue.fields,i=r[me]?.stringValue;if(i&&$e[i])return $e[i];if(1===__PRIVATE_objectSize(r)){const e=Object.keys(r);return Ue[e[0]]??Oe.gt}return Oe.gt}(e);switch(r){case Oe.wt:return 6;case Oe.yt:return 9007199254740991;case Oe.bt:return 14;case Oe.dt:return 12;case Oe.Et:return 10;case Oe.Vt:case Oe.Tt:return 3;case Oe.It:return 5;case Oe.At:return 8;case Oe.Rt:return 1;case Oe.Pt:return 16;default:return 15}}}function __PRIVATE_valueEquals(e,r,i){if(e===r)return!0;const s=__PRIVATE_typeOrder(e);if(s!==__PRIVATE_typeOrder(r))return!1;switch(s){case 0:case 9007199254740991:case 16:case 1:return!0;case 2:return e.booleanValue===r.booleanValue;case 6:return __PRIVATE_getLocalWriteTime(e).isEqual(__PRIVATE_getLocalWriteTime(r));case 4:return function __PRIVATE_timestampEquals(e,r){if("string"==typeof e.timestampValue&&"string"==typeof r.timestampValue&&e.timestampValue.length===r.timestampValue.length)return e.timestampValue===r.timestampValue;const i=__PRIVATE_normalizeTimestamp(e.timestampValue),s=__PRIVATE_normalizeTimestamp(r.timestampValue);return i.seconds===s.seconds&&i.nanos===s.nanos}(e,r);case 7:return e.stringValue===r.stringValue;case 8:return function __PRIVATE_blobEquals(e,r){return 0===__PRIVATE_compareBlobsAndSubtype(e,r)}(e,r);case 9:return e.referenceValue===r.referenceValue;case 11:return function __PRIVATE_geoPointEquals(e,r){return __PRIVATE_normalizeNumber(e.geoPointValue.latitude)===__PRIVATE_normalizeNumber(r.geoPointValue.latitude)&&__PRIVATE_normalizeNumber(e.geoPointValue.longitude)===__PRIVATE_normalizeNumber(r.geoPointValue.longitude)}(e,r);case 3:return function __PRIVATE_numberEquals(e,r,i){if(__PRIVATE_isDecimal128Value(e)&&__PRIVATE_isDecimal128Value(r))return 0===__PRIVATE_compareQuadruples(e,r);if("integerValue"in e&&"integerValue"in r||__PRIVATE_isInt32Value(e)&&__PRIVATE_isInt32Value(r))return __PRIVATE_extractNumber(e)===__PRIVATE_extractNumber(r);let s,o;return"doubleValue"in e&&"doubleValue"in r&&(s=__PRIVATE_normalizeNumber(e.doubleValue),o=__PRIVATE_normalizeNumber(r.doubleValue),s===o?__PRIVATE_isNegativeZero(s)===__PRIVATE_isNegativeZero(o):!(void 0!==i&&!i.vt)&&isNaN(s)&&isNaN(o))}(e,r,i);case 13:return function __PRIVATE_arrayEquals(e,r,i){return e.length===r.length&&e.every(((e,s)=>i(e,r[s])))}(e.arrayValue.values||[],r.arrayValue.values||[],((e,r)=>__PRIVATE_valueEquals(e,r,i)));case 14:case 15:return function __PRIVATE_objectEquals(e,r,i){const s=e.mapValue.fields||{},o=r.mapValue.fields||{};if(__PRIVATE_objectSize(s)!==__PRIVATE_objectSize(o))return!1;for(const e in s)if(s.hasOwnProperty(e)&&(void 0===o[e]||!__PRIVATE_valueEquals(s[e],o[e],i)))return!1;return!0}(e,r,i);case 5:return 0===__PRIVATE_compareBsonTimestamps(e,r);case 12:return 0===__PRIVATE_compareRegex(e,r);case 10:return 0===__PRIVATE_compareBsonObjectIds(e,r);default:return z(52216,{left:e})}}function __PRIVATE_arrayValueContains(e,r){return void 0!==(e.values||[]).find((e=>__PRIVATE_valueEquals(e,r)))}function __PRIVATE_valueCompare(e,r){if(e===r)return 0;const i=__PRIVATE_typeOrder(e),s=__PRIVATE_typeOrder(r);if(i!==s)return __PRIVATE_primitiveComparator(i,s);switch(i){case 0:case 1:case 16:case 9007199254740991:return 0;case 2:return __PRIVATE_primitiveComparator(e.booleanValue,r.booleanValue);case 3:return __PRIVATE_compareNumbers(e,r);case 4:return __PRIVATE_compareTimestamps(e.timestampValue,r.timestampValue);case 6:return __PRIVATE_compareTimestamps(__PRIVATE_getLocalWriteTime(e),__PRIVATE_getLocalWriteTime(r));case 7:return __PRIVATE_compareUtf8Strings(e.stringValue,r.stringValue);case 8:return __PRIVATE_compareBlobsAndSubtype(e,r);case 9:return function __PRIVATE_compareReferences(e,r){const i=e.split("/"),s=r.split("/");for(let e=0;e<i.length&&e<s.length;e++){const r=__PRIVATE_primitiveComparator(i[e],s[e]);if(0!==r)return r}return __PRIVATE_primitiveComparator(i.length,s.length)}(e.referenceValue,r.referenceValue);case 11:return function __PRIVATE_compareGeoPoints(e,r){const i=__PRIVATE_primitiveComparator(__PRIVATE_normalizeNumber(e.latitude),__PRIVATE_normalizeNumber(r.latitude));return 0!==i?i:__PRIVATE_primitiveComparator(__PRIVATE_normalizeNumber(e.longitude),__PRIVATE_normalizeNumber(r.longitude))}(e.geoPointValue,r.geoPointValue);case 13:return __PRIVATE_compareArrays(e.arrayValue,r.arrayValue);case 14:return function __PRIVATE_compareVectors(e,r){const i=e.fields||{},s=r.fields||{},o=i[Te]?.arrayValue,h=s[Te]?.arrayValue,E=__PRIVATE_primitiveComparator(o?.values?.length||0,h?.values?.length||0);return 0!==E?E:__PRIVATE_compareArrays(o,h)}(e.mapValue,r.mapValue);case 15:return function __PRIVATE_compareMaps(e,r){if(e===Fe&&r===Fe)return 0;if(e===Fe)return 1;if(r===Fe)return-1;const i=e.fields||{},s=Object.keys(i),o=r.fields||{},h=Object.keys(o);s.sort(),h.sort();for(let e=0;e<s.length&&e<h.length;++e){const r=__PRIVATE_compareUtf8Strings(s[e],h[e]);if(0!==r)return r;const E=__PRIVATE_valueCompare(i[s[e]],o[h[e]]);if(0!==E)return E}return __PRIVATE_primitiveComparator(s.length,h.length)}(e.mapValue,r.mapValue);case 5:return __PRIVATE_compareBsonTimestamps(e,r);case 12:return __PRIVATE_compareRegex(e,r);case 10:return __PRIVATE_compareBsonObjectIds(e,r);default:throw z(23264,{xt:i})}}function __PRIVATE_extractNumber(e){let r;return r=__PRIVATE_isInt32Value(e)?e.mapValue.fields[ye].integerValue:e.integerValue||e.doubleValue,__PRIVATE_normalizeNumber(r)}function __PRIVATE_compareNumbers(e,r){if(__PRIVATE_isDecimal128Value(e)||__PRIVATE_isDecimal128Value(r))return __PRIVATE_compareQuadruples(e,r);const i=__PRIVATE_extractNumber(e),s=__PRIVATE_extractNumber(r);return isNaN(i)?isNaN(s)?0:-1:isNaN(s)?1:__PRIVATE_primitiveComparator(i,s)}function __PRIVATE_compareQuadruples(e,r){const i=__PRIVATE_convertNumberToQuadruple(e),s=__PRIVATE_convertNumberToQuadruple(r);return i.ot()&&s.ot()?0:i.isNaN()?s.isNaN()?0:-1:s.isNaN()?1:i.compareTo(s)}function __PRIVATE_convertNumberToQuadruple(e){return __PRIVATE_isDecimal128Value(e)?__PRIVATE_Quadruple.fromString(function __PRIVATE_getDecimal128StringValue(e){return e.mapValue.fields[be].stringValue}(e)):__PRIVATE_Quadruple.fromNumber(__PRIVATE_extractNumber(e))}function __PRIVATE_compareTimestamps(e,r){if("string"==typeof e&&"string"==typeof r&&e.length===r.length)return __PRIVATE_primitiveComparator(e,r);const i=__PRIVATE_normalizeTimestamp(e),s=__PRIVATE_normalizeTimestamp(r),o=__PRIVATE_primitiveComparator(i.seconds,s.seconds);return 0!==o?o:__PRIVATE_primitiveComparator(i.nanos,s.nanos)}function __PRIVATE_compareArrays(e,r){const i=e.values||[],s=r.values||[];for(let e=0;e<i.length&&e<s.length;++e){const r=__PRIVATE_valueCompare(i[e],s[e]);if(void 0!==r&&0!==r)return r}return __PRIVATE_primitiveComparator(i.length,s.length)}function __PRIVATE_compareBsonTimestamps(e,r){const i=e.mapValue.fields?.[ve].mapValue?.fields?.[we],s=r.mapValue.fields?.[ve].mapValue?.fields?.[we],o=e.mapValue.fields?.[ve].mapValue?.fields?.[Se],h=r.mapValue.fields?.[ve].mapValue?.fields?.[Se],E=__PRIVATE_compareNumbers(i,s);return 0!==E?E:__PRIVATE_compareNumbers(o,h)}function __PRIVATE_getBytesAndSubtype(e){if("bytesValue"in e)return{subtype:0,bytes:__PRIVATE_normalizeByteString(e.bytesValue)};const r=e.mapValue?.fields,i=r?.[De],s=i?.bytesValue;if(!s)throw new Error("Received incorrect value for BsonBinaryData");const o=__PRIVATE_normalizeByteString(s).toUint8Array();if(0===o.length)throw new Error("Received empty bytesValue for BsonBinaryData");const h=o[0],E=o.slice(1);return{subtype:h,bytes:ByteString.fromUint8Array(E)}}function __PRIVATE_compareBlobsAndSubtype(e,r){const i=__PRIVATE_getBytesAndSubtype(e),s=__PRIVATE_getBytesAndSubtype(r);return i.subtype!==s.subtype?i.subtype<s.subtype?-1:1:i.bytes.compareTo(s.bytes)}function __PRIVATE_compareRegex(e,r){const i=e.mapValue.fields,s=i?.[Ae]?.mapValue?.fields?.[Ie]?.stringValue??"",o=i?.[Ae]?.mapValue?.fields?.[Re]?.stringValue??"",h=r.mapValue.fields,E=h?.[Ae]?.mapValue?.fields?.[Ie]?.stringValue??"",T=h?.[Ae]?.mapValue?.fields?.[Re]?.stringValue??"",V=__PRIVATE_compareUtf8Strings(s,E);return 0!==V?V:__PRIVATE_primitiveComparator(o,T)}function __PRIVATE_compareBsonObjectIds(e,r){return __PRIVATE_compareUtf8Strings(e.mapValue.fields?.[xe]?.stringValue??"",r.mapValue.fields?.[xe]?.stringValue??"")}function __PRIVATE_isDecimal128Value(e){if(!e.mapValue?.fields)return!1;const r=e.mapValue.fields;return 1===__PRIVATE_objectSize(r)&&r[be]&&!!r[be].stringValue}function __PRIVATE_isInt32Value(e){if(!e.mapValue?.fields)return!1;const r=e.mapValue.fields;return 1===__PRIVATE_objectSize(r)&&void 0!==r[ye]?.integerValue}function isArray(e){return!!e&&"arrayValue"in e}function __PRIVATE_isMapValue(e){return!!e&&"mapValue"in e}function __PRIVATE_deepClone(e){if(e.geoPointValue)return{geoPointValue:{...e.geoPointValue}};if(e.timestampValue&&"object"==typeof e.timestampValue)return{timestampValue:{...e.timestampValue}};if(e.mapValue){const r={mapValue:{fields:{}}};return forEach(e.mapValue.fields,((e,i)=>r.mapValue.fields[e]=__PRIVATE_deepClone(i))),r}if(e.arrayValue){const r={arrayValue:{values:[]}};for(let i=0;i<(e.arrayValue.values||[]).length;++i)r.arrayValue.values[i]=__PRIVATE_deepClone(e.arrayValue.values[i]);return r}return{...e}}new Set(Object.values(Ue));class Filter{}class FieldFilter extends Filter{constructor(e,r,i){super(),this.field=e,this.op=r,this.value=i}static create(e,r,i){return e.isKeyField()?"in"===r||"not-in"===r?this.createKeyFieldInFilter(e,r,i):new __PRIVATE_KeyFieldFilter(e,r,i):"array-contains"===r?new __PRIVATE_ArrayContainsFilter(e,i):"in"===r?new __PRIVATE_InFilter(e,i):"not-in"===r?new __PRIVATE_NotInFilter(e,i):"array-contains-any"===r?new __PRIVATE_ArrayContainsAnyFilter(e,i):new FieldFilter(e,r,i)}static createKeyFieldInFilter(e,r,i){return"in"===r?new __PRIVATE_KeyFieldInFilter(e,i):new __PRIVATE_KeyFieldNotInFilter(e,i)}matches(e){const r=e.data.field(this.field);return"!="===this.op?null!==r&&void 0===r.nullValue&&this.matchesComparison(__PRIVATE_valueCompare(r,this.value)):null!==r&&__PRIVATE_typeOrder(this.value)===__PRIVATE_typeOrder(r)&&this.matchesComparison(__PRIVATE_valueCompare(r,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return 0===e;case"!=":return 0!==e;case">":return e>0;case">=":return e>=0;default:return z(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class CompositeFilter extends Filter{constructor(e,r){super(),this.filters=e,this.op=r,this.Dt=null}static create(e,r){return new CompositeFilter(e,r)}matches(e){return function __PRIVATE_compositeFilterIsConjunction(e){return"and"===e.op}(this)?void 0===this.filters.find((r=>!r.matches(e))):void 0!==this.filters.find((r=>r.matches(e)))}getFlattenedFilters(){return null!==this.Dt||(this.Dt=this.filters.reduce(((e,r)=>e.concat(r.getFlattenedFilters())),[])),this.Dt}getFilters(){return Object.assign([],this.filters)}}class __PRIVATE_KeyFieldFilter extends FieldFilter{constructor(e,r,i){super(e,r,i),this.key=C.fromName(i.referenceValue)}matches(e){const r=C.comparator(e.key,this.key);return this.matchesComparison(r)}}class __PRIVATE_KeyFieldInFilter extends FieldFilter{constructor(e,r){super(e,"in",r),this.keys=__PRIVATE_extractDocumentKeysFromArrayValue("in",r)}matches(e){return this.keys.some((r=>r.isEqual(e.key)))}}class __PRIVATE_KeyFieldNotInFilter extends FieldFilter{constructor(e,r){super(e,"not-in",r),this.keys=__PRIVATE_extractDocumentKeysFromArrayValue("not-in",r)}matches(e){return!this.keys.some((r=>r.isEqual(e.key)))}}function __PRIVATE_extractDocumentKeysFromArrayValue(e,r){return(r.arrayValue?.values||[]).map((e=>C.fromName(e.referenceValue)))}class __PRIVATE_ArrayContainsFilter extends FieldFilter{constructor(e,r){super(e,"array-contains",r)}matches(e){const r=e.data.field(this.field);return isArray(r)&&__PRIVATE_arrayValueContains(r.arrayValue,this.value)}}class __PRIVATE_InFilter extends FieldFilter{constructor(e,r){super(e,"in",r)}matches(e){const r=e.data.field(this.field);return null!==r&&__PRIVATE_arrayValueContains(this.value.arrayValue,r)}}class __PRIVATE_NotInFilter extends FieldFilter{constructor(e,r){super(e,"not-in",r)}matches(e){if(__PRIVATE_arrayValueContains(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const r=e.data.field(this.field);return null!==r&&void 0===r.nullValue&&!__PRIVATE_arrayValueContains(this.value.arrayValue,r)}}class __PRIVATE_ArrayContainsAnyFilter extends FieldFilter{constructor(e,r){super(e,"array-contains-any",r)}matches(e){const r=e.data.field(this.field);return!(!isArray(r)||!r.arrayValue.values)&&r.arrayValue.values.some((e=>__PRIVATE_arrayValueContains(this.value.arrayValue,e)))}}class OrderBy{constructor(e,r="asc"){this.field=e,this.dir=r}}class j{static fromTimestamp(e){return new j(e)}static min(){return new j(new Timestamp(0,0))}static max(){return new j(new Timestamp(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}}class SortedMap{constructor(e,r){this.comparator=e,this.root=r||LLRBNode.EMPTY}insert(e,r){return new SortedMap(this.comparator,this.root.insert(e,r,this.comparator).copy(null,null,LLRBNode.BLACK,null,null))}remove(e){return new SortedMap(this.comparator,this.root.remove(e,this.comparator).copy(null,null,LLRBNode.BLACK,null,null))}get(e){let r=this.root;for(;!r.isEmpty();){const i=this.comparator(e,r.key);if(0===i)return r.value;i<0?r=r.left:i>0&&(r=r.right)}return null}indexOf(e){let r=0,i=this.root;for(;!i.isEmpty();){const s=this.comparator(e,i.key);if(0===s)return r+i.left.size;s<0?i=i.left:(r+=i.left.size+1,i=i.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(((r,i)=>(e(r,i),!1)))}toString(){const e=[];return this.inorderTraversal(((r,i)=>(e.push(`${r}:${i}`),!1))),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new SortedMapIterator(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new SortedMapIterator(this.root,e,this.comparator,!1)}getReverseIterator(){return new SortedMapIterator(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new SortedMapIterator(this.root,e,this.comparator,!0)}}class SortedMapIterator{constructor(e,r,i,s){this.isReverse=s,this.nodeStack=[];let o=1;for(;!e.isEmpty();)if(o=r?i(e.key,r):1,r&&s&&(o*=-1),o<0)e=this.isReverse?e.left:e.right;else{if(0===o){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const r={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 r}hasNext(){return this.nodeStack.length>0}peek(){if(0===this.nodeStack.length)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class LLRBNode{constructor(e,r,i,s,o){this.key=e,this.value=r,this.color=null!=i?i:LLRBNode.RED,this.left=null!=s?s:LLRBNode.EMPTY,this.right=null!=o?o:LLRBNode.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,r,i,s,o){return new LLRBNode(null!=e?e:this.key,null!=r?r:this.value,null!=i?i:this.color,null!=s?s:this.left,null!=o?o: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,r,i){let s=this;const o=i(e,s.key);return s=o<0?s.copy(null,null,null,s.left.insert(e,r,i),null):0===o?s.copy(null,r,null,null,null):s.copy(null,null,null,null,s.right.insert(e,r,i)),s.fixUp()}removeMin(){if(this.left.isEmpty())return LLRBNode.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,r){let i,s=this;if(r(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,r),null);else{if(s.left.isRed()&&(s=s.rotateRight()),s.right.isEmpty()||s.right.isRed()||s.right.left.isRed()||(s=s.moveRedRight()),0===r(e,s.key)){if(s.right.isEmpty())return LLRBNode.EMPTY;i=s.right.min(),s=s.copy(i.key,i.value,null,null,s.right.removeMin())}s=s.copy(null,null,null,null,s.right.remove(e,r))}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(){const e=this.copy(null,null,LLRBNode.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,LLRBNode.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),r=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,r)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw z(43730,{key:this.key,value:this.value});if(this.right.isRed())throw z(14113,{key:this.key,value:this.value});const e=this.left.check();if(e!==this.right.check())throw z(27949);return e+(this.isRed()?0:1)}}LLRBNode.EMPTY=null,LLRBNode.RED=!0,LLRBNode.BLACK=!1,LLRBNode.EMPTY=new class LLRBEmptyNode{constructor(){this.size=0}get key(){throw z(57766)}get value(){throw z(16141)}get color(){throw z(16727)}get left(){throw z(29726)}get right(){throw z(36894)}copy(e,r,i,s,o){return this}insert(e,r,i){return new LLRBNode(e,r)}remove(e,r){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}};class SortedSet{constructor(e){this.comparator=e,this.data=new SortedMap(this.comparator)}has(e){return null!==this.data.get(e)}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(((r,i)=>(e(r),!1)))}forEachInRange(e,r){const i=this.data.getIteratorFrom(e[0]);for(;i.hasNext();){const s=i.getNext();if(this.comparator(s.key,e[1])>=0)return;r(s.key)}}forEachWhile(e,r){let i;for(i=void 0!==r?this.data.getIteratorFrom(r):this.data.getIterator();i.hasNext();)if(!e(i.getNext().key))return}firstAfterOrEqual(e){const r=this.data.getIteratorFrom(e);return r.hasNext()?r.getNext().key:null}getIterator(){return new SortedSetIterator(this.data.getIterator())}getIteratorFrom(e){return new SortedSetIterator(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 r=this;return r.size<e.size&&(r=e,e=this),e.forEach((e=>{r=r.add(e)})),r}isEqual(e){if(!(e instanceof SortedSet))return!1;if(this.size!==e.size)return!1;const r=this.data.getIterator(),i=e.data.getIterator();for(;r.hasNext();){const e=r.getNext().key,s=i.getNext().key;if(0!==this.comparator(e,s))return!1}return!0}toArray(){const e=[];return this.forEach((r=>{e.push(r)})),e}toString(){const e=[];return this.forEach((r=>e.push(r))),"SortedSet("+e.toString()+")"}copy(e){const r=new SortedSet(this.comparator);return r.data=e,r}}class SortedSetIterator{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}class u{constructor(e){this.value=e}static empty(){return new u({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let r=this.value;for(let i=0;i<e.length-1;++i)if(r=(r.mapValue.fields||{})[e.get(i)],!__PRIVATE_isMapValue(r))return null;return r=(r.mapValue.fields||{})[e.lastSegment()],r||null}}set(e,r){this.getFieldsMap(e.popLast())[e.lastSegment()]=__PRIVATE_deepClone(r)}setAll(e){let r=te.emptyPath(),i={},s=[];e.forEach(((e,o)=>{if(!r.isImmediateParentOf(o)){const e=this.getFieldsMap(r);this.applyChanges(e,i,s),i={},s=[],r=o.popLast()}e?i[o.lastSegment()]=__PRIVATE_deepClone(e):s.push(o.lastSegment())}));const o=this.getFieldsMap(r);this.applyChanges(o,i,s)}delete(e){const r=this.field(e.popLast());__PRIVATE_isMapValue(r)&&r.mapValue.fields&&delete r.mapValue.fields[e.lastSegment()]}isEqual(e){return __PRIVATE_valueEquals(this.value,e.value)}getFieldsMap(e){let r=this.value;r.mapValue.fields||(r.mapValue={fields:{}});for(let i=0;i<e.length;++i){let s=r.mapValue.fields[e.get(i)];__PRIVATE_isMapValue(s)&&s.mapValue.fields||(s={mapValue:{fields:{}}},r.mapValue.fields[e.get(i)]=s),r=s}return r.mapValue.fields}applyChanges(e,r,i){forEach(r,((r,i)=>e[r]=i));for(const r of i)delete e[r]}clone(){return new u(__PRIVATE_deepClone(this.value))}}class __PRIVATE_QueryImpl{constructor(e,r=null,i=[],s=[],o=null,h="F",E=null,T=null){this.path=e,this.collectionGroup=r,this.explicitOrderBy=i,this.filters=s,this.limit=o,this.limitType=h,this.startAt=E,this.endAt=T,this.St=null,this.Ct=null,this.Bt=null,this.startAt,this.endAt}}function __PRIVATE_toDouble(e,r){if(e.useProto3Json){if(isNaN(r))return{doubleValue:"NaN"};if(r===1/0)return{doubleValue:"Infinity"};if(r===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:__PRIVATE_isNegativeZero(r)?"-0":r}}function __PRIVATE_toInteger(e){return{integerValue:""+e}}function toNumber(e,r,i){return function isSafeInteger(e){return"number"==typeof e&&Number.isInteger(e)&&!__PRIVATE_isNegativeZero(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}(r)?__PRIVATE_toInteger(r):__PRIVATE_toDouble(e,r)}class JsonProtoSerializer{constructor(e,r){this.databaseId=e,this.useProto3Json=r}}function toTimestamp(e,r){return e.useProto3Json?`${new Date(1e3*r.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+r.nanoseconds).slice(-9)}Z`:{seconds:""+r.seconds,nanos:r.nanoseconds}}function __PRIVATE_toBytes(e,r){return e.useProto3Json?r.toBase64():r.toUint8Array()}function __PRIVATE_fromVersion(e){return __PRIVATE_hardAssert(!!e,49232),j.fromTimestamp(function fromTimestamp(e){const r=__PRIVATE_normalizeTimestamp(e);return new Timestamp(r.seconds,r.nanos)}(e))}function __PRIVATE_toResourceName(e,r){return __PRIVATE_toResourcePath(e,r).canonicalString()}function __PRIVATE_toResourcePath(e,r){const i=function __PRIVATE_fullyQualifiedPrefixPath(e){return new ResourcePath(["projects",e.projectId,"databases",e.database])}(e).child("documents");return void 0===r?i:i.child(r)}function __PRIVATE_fromPipelineResponse(e,r,i){const s={};r.transaction?.length&&(s.transaction=r.transaction);const o=r.executionTime?__PRIVATE_fromVersion(r.executionTime):void 0;return s.executionTime=o,i&&(s.key=i.name?function fromName(e,r){const i=function __PRIVATE_fromResourceName(e){const r=ResourcePath.fromString(e);return __PRIVATE_hardAssert(__PRIVATE_isValidResourceName(r),10190,{key:r.toString()}),r}(r);if(i.get(1)!==e.databaseId.projectId)throw new k(b,"Tried to deserialize key from different project: "+i.get(1)+" vs "+e.databaseId.projectId);if(i.get(3)!==e.databaseId.database)throw new k(b,"Tried to deserialize key from different database: "+i.get(3)+" vs "+e.databaseId.database);return new C(function __PRIVATE_extractLocalPathFromResourceName(e){return __PRIVATE_hardAssert(e.length>4&&"documents"===e.get(4),29091,{key:e.toString()}),e.popFirst(5)}(i))}(e,i.name):void 0,s.fields=new u({mapValue:{fields:i.fields}}),s.createTime=i.createTime?__PRIVATE_fromVersion(i.createTime):void 0,s.updateTime=i.updateTime?__PRIVATE_fromVersion(i.updateTime):void 0),s}function __PRIVATE_isValidResourceName(e){return e.length>=4&&"projects"===e.get(0)&&"databases"===e.get(2)}function __PRIVATE_isProtoValueSerializable(e){return!!e&&"function"==typeof e._toProto&&"ProtoValue"===e._protoValueType}function toMapValue(e,r){const i={fields:{}};return r.forEach(((r,s)=>{if("string"!=typeof s)throw new Error(`Cannot encode map with non-string key: ${s}`);i.fields[s]=r._toProto(e)})),{mapValue:i}}function __PRIVATE_toStringValue(e){return{stringValue:e}}function __PRIVATE_toPipelineValue(e){return{pipelineValue:e}}function __PRIVATE_newSerializer(e){return new JsonProtoSerializer(e,!0)}class Datastore{}class __PRIVATE_DatastoreImpl extends Datastore{constructor(e,r,i,s){super(),this.authCredentials=e,this.appCheckCredentials=r,this.connection=i,this.serializer=s,this.qt=!1}Lt(){if(this.qt)throw new k(U,"The client has already been terminated.")}le(e,r,i,s){return this.Lt(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([o,h])=>this.connection.le(e,__PRIVATE_toResourcePath(r,i),s,o,h))).catch((e=>{throw"FirebaseError"===e.name?(e.code===N&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new k(R,e.toString())}))}me(e,r,i,s,o){return this.Lt(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([h,E])=>this.connection.me(e,__PRIVATE_toResourcePath(r,i),s,h,E,o))).catch((e=>{throw"FirebaseError"===e.name?(e.code===N&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new k(R,e.toString())}))}terminate(){this.qt=!0,this.connection.terminate()}}const Ce="ComponentProvider",Be=new Map;const Le=!0;class FirestoreSettingsImpl{constructor(e){if(void 0===e.host){if(void 0!==e.ssl)throw new k(b,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=Le}else this.host=e.host,this.ssl=e.ssl??Le;if(this.isUsingEmulator=void 0!==e.emulatorOptions,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e._customHeaders&&(this._customHeaders={...e._customHeaders}),void 0===e.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==e.cacheSizeBytes&&e.cacheSizeBytes<1048576)throw new k(b,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}if(function __PRIVATE_validateIsNotUsedTogether(e,r,i,s){if(!0===r&&!0===s)throw new k(b,`${e} and ${i} cannot be used together.`)}("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:void 0===e.experimentalAutoDetectLongPolling?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=__PRIVATE_cloneLongPollingOptions(e.experimentalLongPollingOptions??{}),function __PRIVATE_validateLongPollingOptions(e){if(void 0!==e.timeoutSeconds){if(isNaN(e.timeoutSeconds))throw new k(b,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new k(b,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new k(b,`invalid long polling timeout: ${e.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams,void 0!==e.grpcFlowControlWindow){if("number"!=typeof e.grpcFlowControlWindow||e.grpcFlowControlWindow<=0||e.grpcFlowControlWindow>2147483647||!Number.isInteger(e.grpcFlowControlWindow))throw new k(b,"grpcFlowControlWindow must be a positive integer and cannot exceed 2147483647");this.grpcFlowControlWindow=e.grpcFlowControlWindow}}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 __PRIVATE_longPollingOptionsEqual(e,r){return e.timeoutSeconds===r.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams&&this.grpcFlowControlWindow===e.grpcFlowControlWindow&&function __PRIVATE_customHeadersEqual(e,r){if(e===r)return!0;if(!e||!r)return!1;const i=Object.keys(e),s=Object.keys(r);if(i.length!==s.length)return!1;for(const s of i)if(e[s]!==r[s])return!1;return!0}(this._customHeaders,e._customHeaders)}}class n{constructor(e,r,i,s){this._authCredentials=e,this._appCheckCredentials=r,this._databaseId=i,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new FirestoreSettingsImpl({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new k(U,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return"notTerminated"!==this._terminateTask}_setSettings(e){if(this._settingsFrozen)throw new k(U,"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 FirestoreSettingsImpl(e),this._emulatorOptions=e.emulatorOptions||{},void 0!==e.credentials&&(this._authCredentials=function __PRIVATE_makeAuthCredentialsProvider(e){if(!e)return new __PRIVATE_EmptyAuthCredentialsProvider;switch(e.type){case"firstParty":return new __PRIVATE_FirstPartyAuthCredentialsProvider(e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new k(b,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return"notTerminated"===this._terminateTask&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){"notTerminated"===this._terminateTask?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function __PRIVATE_removeComponents(e){const r=Be.get(e);r&&(a(Ce,"Removing Datastore"),Be.delete(e),r.terminate())}(this),Promise.resolve()}}class Query{constructor(e,r,i){this.converter=r,this._query=i,this.type="query",this.firestore=e}withConverter(e){return new Query(this.firestore,e,this._query)}}class DocumentReference{constructor(e,r,i){this.converter=r,this._key=i,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 CollectionReference(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new DocumentReference(this.firestore,e,this._key)}toJSON(){return{type:DocumentReference._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,r,i){if(__PRIVATE_validateJSON(r,DocumentReference._jsonSchema))return new DocumentReference(e,i||null,new C(ResourcePath.fromString(r.referencePath)))}}DocumentReference._jsonSchemaVersion="firestore/documentReference/1.0",DocumentReference._jsonSchema={type:property("string",DocumentReference._jsonSchemaVersion),referencePath:property("string")};class CollectionReference extends Query{constructor(e,r,i){super(e,r,function __PRIVATE_newQueryForPath(e){return new __PRIVATE_QueryImpl(e)}(i)),this._path=i,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new DocumentReference(this.firestore,null,new C(e))}withConverter(e){return new CollectionReference(this.firestore,e,this._path)}}function __PRIVATE_isCollectionReference(e){return e instanceof CollectionReference}function doc(e,r,...i){if(e=getModularInstance(e),1===arguments.length&&(r=__PRIVATE_AutoId.newId()),__PRIVATE_validateNonEmptyArgument("doc","path",r),e instanceof n){const s=ResourcePath.fromString(r,...i);return __PRIVATE_validateDocumentPath(s),new DocumentReference(e,null,new C(s))}{if(!(e instanceof DocumentReference||e instanceof CollectionReference))throw new k(b,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const s=e._path.child(ResourcePath.fromString(r,...i));return __PRIVATE_validateDocumentPath(s),new DocumentReference(e.firestore,e instanceof CollectionReference?e.converter:null,new C(s))}}class Bytes{constructor(e,r=0){if(this.subtype=r,!Number.isInteger(r)||r<0||r>255)throw new k(b,"The subtype for Bytes must be a value in the inclusive [0, 255] range.");this._byteString=e}static fromBase64String(e,r=0){try{return new Bytes(ByteString.fromBase64String(e),r)}catch(e){throw new k(b,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e,r=0){return new Bytes(ByteString.fromUint8Array(e),r)}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}get data(){return this.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+", subtype: "+this.subtype+")"}isEqual(e){return this.subtype===e.subtype&&this._byteString.isEqual(e._byteString)}toJSON(){const e={type:Bytes._jsonSchemaVersion,bytes:this.toBase64()};return 0!==this.subtype&&(e.subtype=this.subtype),e}static fromJSON(e){if(__PRIVATE_validateJSON(e,Bytes._jsonSchema)){const r=e.subtype??0;return Bytes.fromBase64String(e.bytes,r)}}}Bytes._jsonSchemaVersion="firestore/bytes/1.0",Bytes._jsonSchema={type:property("string",Bytes._jsonSchemaVersion),bytes:property("string"),subtype:{...property("number"),optional:!0}};class D{constructor(...e){for(let r=0;r<e.length;++r)if(0===e[r].length)throw new k(b,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new te(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}class BsonObjectId{constructor(e){this.value=e}isEqual(e){return this.value===e.value}}class BsonTimestamp{constructor(e,r){if(this.seconds=e,this.increment=r,!Number.isInteger(e)||e<0||e>4294967295)throw new Error("BsonTimestamp 'seconds' must be in the range of a 32-bit unsigned integer (0-4294967295).");if(!Number.isInteger(r)||r<0||r>4294967295)throw new Error("BsonTimestamp 'increment' must be in the range of a 32-bit unsigned integer (0-4294967295).")}isEqual(e){return this.seconds===e.seconds&&this.increment===e.increment}}class Decimal128Value{constructor(e){this.stringValue=e,this.value=__PRIVATE_Quadruple.fromString(e)}isEqual(e){return!(!this.value.ot()||!e.value.ot())||0===this.value.compareTo(e.value)}toJSON(){return{$t:{stringValue:this.stringValue}}}}class FieldValue{constructor(e){this._methodName=e}}class GeoPoint{constructor(e,r){if(!isFinite(e)||e<-90||e>90)throw new k(b,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(r)||r<-180||r>180)throw new k(b,"Longitude must be a number between -180 and 180, but was: "+r);this._lat=e,this._long=r}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}_compareTo(e){return __PRIVATE_primitiveComparator(this._lat,e._lat)||__PRIVATE_primitiveComparator(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:GeoPoint._jsonSchemaVersion}}static fromJSON(e){if(__PRIVATE_validateJSON(e,GeoPoint._jsonSchema))return new GeoPoint(e.latitude,e.longitude)}}GeoPoint._jsonSchemaVersion="firestore/geoPoint/1.0",GeoPoint._jsonSchema={type:property("string",GeoPoint._jsonSchemaVersion),latitude:property("number"),longitude:property("number")};class Int32Value{constructor(e){this.value=e}isEqual(e){return this.value===e.value}}class MaxKey{constructor(){this.type="MaxKey"}static instance(){return MaxKey.MAX_KEY_VALUE_INSTANCE||(MaxKey.MAX_KEY_VALUE_INSTANCE=new MaxKey),MaxKey.MAX_KEY_VALUE_INSTANCE}}MaxKey.MAX_KEY_VALUE_INSTANCE=null;class MinKey{constructor(){this.type="MinKey"}static instance(){return MinKey.MIN_KEY_VALUE_INSTANCE||(MinKey.MIN_KEY_VALUE_INSTANCE=new MinKey),MinKey.MIN_KEY_VALUE_INSTANCE}}MinKey.MIN_KEY_VALUE_INSTANCE=null;class RegexValue{constructor(e,r){this.pattern=e,this.options=r}isEqual(e){return this.pattern===e.pattern&&this.options===e.options}}class VectorValue{constructor(e){this._values=(e||[]).map((e=>e))}toArray(){return this._values.map((e=>e))}isEqual(e){return function __PRIVATE_isPrimitiveArrayEqual(e,r){if(e.length!==r.length)return!1;for(let i=0;i<e.length;++i)if(e[i]!==r[i])return!1;return!0}(this._values,e._values)}toJSON(){return{type:VectorValue._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(__PRIVATE_validateJSON(e,VectorValue._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every((e=>"number"==typeof e)))return new VectorValue(e.vectorValues);throw new k(b,"Expected 'vectorValues' field to be a number array")}}}VectorValue._jsonSchemaVersion="firestore/vectorValue/1.0",VectorValue._jsonSchema={type:property("string",VectorValue._jsonSchemaVersion),vectorValues:property("object")};const Me=/^__.*__$/;function __PRIVATE_isWrite(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw z(40011,{dataSource:e})}}class ParseContextImpl{constructor(e,r,i,s,o,h){this.settings=e,this.databaseId=r,this.serializer=i,this.ignoreUndefinedProperties=s,void 0===o&&this.validatePath(),this.fieldTransforms=o||[],this.fieldMask=h||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}contextWith(e){return new ParseContextImpl({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}childContextForField(e){const r=this.path?.child(e),i=this.contextWith({path:r,arrayElement:!1});return i.validatePathSegment(e),i}childContextForFieldPath(e){const r=this.path?.child(e),i=this.contextWith({path:r,arrayElement:!1});return i.validatePath(),i}childContextForArray(e){return this.contextWith({path:void 0,arrayElement:!0})}createError(e){return createError(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(e){return void 0!==this.fieldMask.find((r=>e.isPrefixOf(r)))||void 0!==this.fieldTransforms.find((r=>e.isPrefixOf(r.field)))}validatePath(){if(this.path)for(let e=0;e<this.path.length;e++)this.validatePathSegment(this.path.get(e))}validatePathSegment(e){if(0===e.length)throw this.createError("Document fields must not be empty");if(__PRIVATE_isWrite(this.dataSource)&&Me.test(e))throw this.createError('Document fields cannot begin and end with "__"')}}class UserDataReader{constructor(e,r,i){this.databaseId=e,this.ignoreUndefinedProperties=r,this.serializer=i||__PRIVATE_newSerializer(e)}createContext(e,r,i,s=!1){return new ParseContextImpl({dataSource:e,methodName:r,targetDoc:i,path:te.emptyPath(),arrayElement:!1,hasConverter:s},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function p(e){const r=e._freezeSettings(),i=__PRIVATE_newSerializer(e._databaseId);return new UserDataReader(e._databaseId,!!r.ignoreUndefinedProperties,i)}function __PRIVATE_parseData(e,r,i){if(__PRIVATE_looksLikeJsonObject(e=getModularInstance(e)))return function __PRIVATE_validatePlainObject(e,r,i){if(!__PRIVATE_looksLikeJsonObject(i)||!__PRIVATE_isPlainObject(i)){const s=__PRIVATE_valueDescription(i);throw"an object"===s?r.createError(e+" a custom object"):r.createError(e+" "+s)}}("Unsupported field value:",r,e),function __PRIVATE_parseObject(e,r){const i={};return function isEmpty(e){for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r))return!1;return!0}(e)?r.path&&r.path.length>0&&r.fieldMask.push(r.path):forEach(e,((e,s)=>{const o=__PRIVATE_parseData(s,r.childContextForField(e));null!=o&&(i[e]=o)})),{mapValue:{fields:i}}}(e,r);if(e instanceof FieldValue)return function __PRIVATE_parseSentinelFieldValue(e,r){if(!__PRIVATE_isWrite(r.dataSource))throw r.createError(`${e._methodName}() can only be used with update() and set()`);if(!r.path)throw r.createError(`${e._methodName}() is not currently supported inside arrays`);const i=e._toFieldTransform(r);i&&r.fieldTransforms.push(i)}(e,r),null;if(void 0===e&&r.ignoreUndefinedProperties)return null;if(r.path&&r.fieldMask.push(r.path),e instanceof Array){if(r.settings.arrayElement&&4!==r.dataSource)throw r.createError("Nested arrays are not supported");return function __PRIVATE_parseArray(e,r){const i=[];let s=0;for(const o of e){let e=__PRIVATE_parseData(o,r.childContextForArray(s));null==e&&(e={nullValue:"NULL_VALUE"}),i.push(e),s++}return{arrayValue:{values:i}}}(e,r)}return function __PRIVATE_parseScalarValue(e,r){if(null===(e=getModularInstance(e)))return{nullValue:"NULL_VALUE"};if("number"==typeof e)return toNumber(r.serializer,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){const i=Timestamp.fromDate(e);return{timestampValue:toTimestamp(r.serializer,i)}}if(e instanceof Timestamp){const i=new Timestamp(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:toTimestamp(r.serializer,i)}}if(__PRIVATE_isTemporalInstant(e)){const i=Timestamp.fromInstant(e),s=new Timestamp(i.seconds,1e3*Math.floor(i.nanoseconds/1e3));return{timestampValue:toTimestamp(r.serializer,s)}}if(e instanceof GeoPoint)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof Bytes)return 0===e.subtype?{bytesValue:__PRIVATE_toBytes(r.serializer,e._byteString)}:function __PRIVATE_parseBytesWithSubtype(e,r){const i=r.toUint8Array(),s=new Uint8Array(i.length+1);return s[0]=r.subtype,s.set(i,1),{mapValue:{fields:{[De]:{bytesValue:__PRIVATE_toBytes(e,ByteString.fromUint8Array(s))}}}}}(r.serializer,e);if(e instanceof DocumentReference){const i=r.databaseId,s=e.firestore._databaseId;if(!s.isEqual(i))throw r.createError(`Document reference is for database ${s.projectId}/${s.database} but should be for database ${i.projectId}/${i.database}`);return{referenceValue:__PRIVATE_toResourceName(e.firestore._databaseId||r.databaseId,e._key.path)}}if(e instanceof VectorValue)return function __PRIVATE_parseVectorValue(e,r){const i=e instanceof VectorValue?e.toArray():e,s={fields:{[me]:{stringValue:Ee},[Te]:{arrayValue:{values:i.map((e=>{if("number"!=typeof e)throw r.createError("VectorValues must only contain numeric values.");return __PRIVATE_toDouble(r.serializer,e)}))}}}};return{mapValue:s}}(e,r);if(e instanceof RegexValue)return function __PRIVATE_parseRegexValue(e){return{mapValue:{fields:{[Ae]:{mapValue:{fields:{[Ie]:{stringValue:e.pattern},[Re]:{stringValue:e.options}}}}}}}}(e);if(e instanceof BsonObjectId)return function __PRIVATE_parseBsonObjectId(e){return{mapValue:{fields:{[xe]:{stringValue:e.value}}}}}(e);if(e instanceof Int32Value)return function __PRIVATE_parseInt32Value(e){return{mapValue:{fields:{[ye]:__PRIVATE_toInteger(e.value)}}}}(e);if(e instanceof Decimal128Value)return function __PRIVATE_parseDecimal128Value(e){return{mapValue:{fields:{[be]:{stringValue:e.stringValue}}}}}(e);if(e instanceof BsonTimestamp)return function __PRIVATE_parseBsonTimestamp(e){return{mapValue:{fields:{[ve]:{mapValue:{fields:{[we]:__PRIVATE_toInteger(e.seconds),[Se]:__PRIVATE_toInteger(e.increment)}}}}}}}(e);if(e instanceof MinKey)return function __PRIVATE_parseMinKey(){return{mapValue:{fields:{[Ve]:{nullValue:"NULL_VALUE"}}}}}();if(e instanceof MaxKey)return function __PRIVATE_parseMaxKey(){return{mapValue:{fields:{[Pe]:{nullValue:"NULL_VALUE"}}}}}();if(__PRIVATE_isProtoValueSerializable(e))return e._toProto(r.serializer);throw r.createError(`Unsupported field value: ${__PRIVATE_valueDescription(e)}`)}(e,r)}function __PRIVATE_isTemporalInstant(e){if("object"!=typeof e||null===e)return!1;if("undefined"!=typeof Temporal&&"function"==typeof Temporal.Instant&&e instanceof Temporal.Instant)return!0;const r=e;return"Temporal.Instant"===r[Symbol.toStringTag]&&"bigint"==typeof r.ht}function __PRIVATE_looksLikeJsonObject(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof Timestamp||e instanceof GeoPoint||e instanceof Bytes||e instanceof DocumentReference||e instanceof FieldValue||e instanceof VectorValue||e instanceof MinKey||e instanceof MaxKey||e instanceof Int32Value||e instanceof Decimal128Value||e instanceof RegexValue||e instanceof BsonObjectId||e instanceof BsonTimestamp||__PRIVATE_isTemporalInstant(e)||__PRIVATE_isProtoValueSerializable(e))}function _(e,r,i){if((r=getModularInstance(r))instanceof D)return r._internalPath;if("string"==typeof r)return function __PRIVATE_fieldPathFromDotSeparatedString(e,r,i){if(r.search(ke)>=0)throw createError(`Invalid field path (${r}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,i);try{return new D(...r.split("."))._internalPath}catch(s){throw createError(`Invalid field path (${r}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,i)}}(e,r);throw createError("Field path arguments must be of type string or ",e,!1,void 0,i)}const ke=new RegExp("[~\\*/\\[\\]]");function createError(e,r,i,s,o){const h=s&&!s.isEmpty(),E=void 0!==o;let T=`Function ${r}() called with invalid data`;i&&(T+=" (via `toFirestore()`)"),T+=". ";let V="";return(h||E)&&(V+=" (found",h&&(V+=` in field ${s}`),E&&(V+=` in document ${o}`),V+=")"),new k(b,T+e+V)}class it{constructor(e,r,i,s,o){this._firestore=e,this._userDataWriter=r,this._key=i,this._document=s,this._converter=o}get id(){return this._key.path.lastSegment()}get ref(){return new DocumentReference(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){const e=new QueryDocumentSnapshot(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){return this._document?.data.clone().value.mapValue.fields??void 0}get(e){if(this._document){const r=this._document.data.field(_("DocumentSnapshot.get",e));if(null!==r)return this._userDataWriter.convertValue(r)}}}class QueryDocumentSnapshot extends it{data(){return super.data()}}class AbstractUserDataWriter{convertValue(e,r="none"){switch(__PRIVATE_typeOrder(e)){case 0:return null;case 2:return e.booleanValue;case 3:if("mapValue"in e){if(__PRIVATE_isInt32Value(e))return this.convertToInt32Value(e.mapValue);if(__PRIVATE_isDecimal128Value(e))return this.convertToDecimal128Value(e.mapValue)}return __PRIVATE_normalizeNumber(e.integerValue||e.doubleValue);case 4:return this.convertTimestamp(e.timestampValue);case 6:return this.convertServerTimestamp(e,r);case 7:return e.stringValue;case 8:return"bytesValue"in e?this.convertBytes(__PRIVATE_normalizeByteString(e.bytesValue)):this.convertToBytesWithSubtype(e.mapValue);case 9:return this.convertReference(e.referenceValue);case 11:return this.convertGeoPoint(e.geoPointValue);case 13:return this.convertArray(e.arrayValue,r);case 15:return this.convertObject(e.mapValue,r);case 14:return this.convertVectorValue(e.mapValue);case 12:return this.convertToRegexValue(e.mapValue);case 10:return this.convertToBsonObjectId(e.mapValue);case 5:return this.convertToBsonTimestamp(e.mapValue);case 16:return MaxKey.instance();case 1:return MinKey.instance();default:throw z(62114,{value:e})}}convertObject(e,r){return this.convertObjectMap(e.fields,r)}convertObjectMap(e,r="none"){const i={};return forEach(e,((e,s)=>{i[e]=this.convertValue(s,r)})),i}convertVectorValue(e){const r=e.fields?.[Te].arrayValue?.values?.map((e=>__PRIVATE_normalizeNumber(e.doubleValue)));return new VectorValue(r)}convertToBsonObjectId(e){const r=e.fields?.[xe]?.stringValue??"";return new BsonObjectId(r)}convertToBytesWithSubtype(e){const r=e.fields?.[De],i=r?.bytesValue;if(!i)throw new Error("Received incorrect bytesValue for Bytes with subtype");const s=__PRIVATE_normalizeByteString(i).toUint8Array();if(0===s.length)throw new Error("Received empty bytesValue for Bytes with subtype");const o=s[0],h=s.slice(1);return new Bytes(ByteString.fromUint8Array(h),o)}convertToBsonTimestamp(e){const r=e.fields?.[ve],i=Number(r?.mapValue?.fields?.[we]?.integerValue),s=Number(r?.mapValue?.fields?.[Se]?.integerValue);return new BsonTimestamp(i,s)}convertToRegexValue(e){const r=e.fields?.[Ae]?.mapValue?.fields?.[Ie]?.stringValue??"",i=e.fields?.[Ae]?.mapValue?.fields?.[Re]?.stringValue??"";return new RegexValue(r,i)}convertToInt32Value(e){const r=Number(e.fields?.[ye]?.integerValue);return new Int32Value(r)}convertToDecimal128Value(e){const r=e.fields?.[be]?.stringValue??"";return new Decimal128Value(r)}convertGeoPoint(e){return new GeoPoint(__PRIVATE_normalizeNumber(e.latitude),__PRIVATE_normalizeNumber(e.longitude))}convertArray(e,r){return(e.values||[]).map((e=>this.convertValue(e,r)))}convertServerTimestamp(e,r){switch(r){case"previous":const i=__PRIVATE_getPreviousValue(e);return null==i?null:this.convertValue(i,r);case"estimate":return this.convertTimestamp(__PRIVATE_getLocalWriteTime(e));default:return null}}convertTimestamp(e){const r=__PRIVATE_normalizeTimestamp(e);return new Timestamp(r.seconds,r.nanos)}convertDocumentKey(e,r){const i=ResourcePath.fromString(e);__PRIVATE_hardAssert(__PRIVATE_isValidResourceName(i),9688,{name:e});const s=new DatabaseId(i.get(1),i.get(3)),o=new C(i.popFirst(5));return s.isEqual(r)||st(`A document reference to ${o} refers to a different database (${s.projectId}/${s.database}), which is not supported. It will be treated as a reference in the current database (${r.projectId}/${r.database}) instead.`),o}}class A extends AbstractUserDataWriter{constructor(e){super(),this.firestore=e}convertBytes(e){return new Bytes(e)}convertReference(e){const r=this.convertDocumentKey(e,this.firestore._databaseId);return new DocumentReference(this.firestore,null,r)}}function vector(e){return new VectorValue(e)}class OptionsUtil{constructor(e){this.optionDefinitions=e}_getKnownOptions(e,r){const i=u.empty();for(const s in this.optionDefinitions)if(this.optionDefinitions.hasOwnProperty(s)){const o=this.optionDefinitions[s];if(s in e){const h=e[s];let E;o.nestedOptions&&__PRIVATE_isPlainObject(h)?E={mapValue:{fields:new OptionsUtil(o.nestedOptions).getOptionsProto(r,h)}}:h&&(E=__PRIVATE_parseData(h,r)??void 0),E&&i.set(te.fromServerFormat(o.serverName),E)}}return i}getOptionsProto(e,r,i){const s=this._getKnownOptions(r,e);if(i){const r=new Map(function g(e,r){const i=[];for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(r(e[s],s,e));return i}(i,((r,i)=>[te.fromServerFormat(i),void 0!==r?__PRIVATE_parseData(r,e):null])));s.setAll(r)}return s.value.mapValue.fields??{}}}function __PRIVATE_isFirestoreValue(e){return"object"==typeof e&&null!==e&&!!("nullValue"in e&&(null===e.nullValue||"NULL_VALUE"===e.nullValue)||"booleanValue"in e&&(null===e.booleanValue||"boolean"==typeof e.booleanValue)||"integerValue"in e&&(null===e.integerValue||"number"==typeof e.integerValue||"string"==typeof e.integerValue)||"doubleValue"in e&&(null===e.doubleValue||"number"==typeof e.doubleValue)||"timestampValue"in e&&(null===e.timestampValue||function __PRIVATE_isITimestamp(e){return"object"==typeof e&&null!==e&&"seconds"in e&&(null===e.seconds||"number"==typeof e.seconds||"string"==typeof e.seconds)&&"nanos"in e&&(null===e.nanos||"number"==typeof e.nanos)}(e.timestampValue))||"stringValue"in e&&(null===e.stringValue||"string"==typeof e.stringValue)||"bytesValue"in e&&(null===e.bytesValue||e.bytesValue instanceof Uint8Array)||"referenceValue"in e&&(null===e.referenceValue||"string"==typeof e.referenceValue)||"geoPointValue"in e&&(null===e.geoPointValue||function __PRIVATE_isILatLng(e){return"object"==typeof e&&null!==e&&"latitude"in e&&(null===e.latitude||"number"==typeof e.latitude)&&"longitude"in e&&(null===e.longitude||"number"==typeof e.longitude)}(e.geoPointValue))||"arrayValue"in e&&(null===e.arrayValue||function __PRIVATE_isIArrayValue(e){return"object"==typeof e&&null!==e&&!(!("values"in e)||null!==e.values&&!Array.isArray(e.values))}(e.arrayValue))||"mapValue"in e&&(null===e.mapValue||function __PRIVATE_isIMapValue(e){return"object"==typeof e&&null!==e&&!(!("fields"in e)||null!==e.fields&&!__PRIVATE_isPlainObject(e.fields))}(e.mapValue))||"fieldReferenceValue"in e&&(null===e.fieldReferenceValue||"string"==typeof e.fieldReferenceValue)||"functionValue"in e&&(null===e.functionValue||function __PRIVATE_isIFunction(e){return"object"==typeof e&&null!==e&&!(!("name"in e)||null!==e.name&&"string"!=typeof e.name||!("args"in e)||null!==e.args&&!Array.isArray(e.args))}(e.functionValue))||"pipelineValue"in e&&(null===e.pipelineValue||function __PRIVATE_isIPipeline(e){return"object"==typeof e&&null!==e&&!(!("stages"in e)||null!==e.stages&&!Array.isArray(e.stages))}(e.pipelineValue)))}function __PRIVATE_valueToDefaultExpr$1(e){let r;return e instanceof Expression?e:(r=__PRIVATE_isPlainObject(e)?__PRIVATE__map(e):e instanceof Array?array(e):__PRIVATE__constant(e,void 0),r)}function __PRIVATE_vectorToExpr$1(e){if(e instanceof Expression)return e;if(e instanceof VectorValue)return constant(e);if(Array.isArray(e))return constant(vector(e));throw new Error("Unsupported value: "+typeof e)}function __PRIVATE_fieldOrExpression$1(e){return __PRIVATE_isString(e)?field(e):__PRIVATE_valueToDefaultExpr$1(e)}class Expression{constructor(){this._protoValueType="ProtoValue"}add(e){return new FunctionExpression("add",[this,__PRIVATE_valueToDefaultExpr$1(e)],"add")}asBoolean(){if(this instanceof BooleanExpression)return this;if(this instanceof Constant)return new __PRIVATE_BooleanConstant(this);if(this instanceof Field)return new __PRIVATE_BooleanField(this);if(this instanceof FunctionExpression)return new __PRIVATE_BooleanFunctionExpression(this);throw new k("invalid-argument",`Conversion of type ${typeof this} to BooleanExpression not supported.`)}subtract(e){return new FunctionExpression("subtract",[this,__PRIVATE_valueToDefaultExpr$1(e)],"subtract")}multiply(e){return new FunctionExpression("multiply",[this,__PRIVATE_valueToDefaultExpr$1(e)],"multiply")}divide(e){return new FunctionExpression("divide",[this,__PRIVATE_valueToDefaultExpr$1(e)],"divide")}mod(e){return new FunctionExpression("mod",[this,__PRIVATE_valueToDefaultExpr$1(e)],"mod")}equal(e){return new FunctionExpression("equal",[this,__PRIVATE_valueToDefaultExpr$1(e)],"equal").asBoolean()}notEqual(e){return new FunctionExpression("not_equal",[this,__PRIVATE_valueToDefaultExpr$1(e)],"notEqual").asBoolean()}lessThan(e){return new FunctionExpression("less_than",[this,__PRIVATE_valueToDefaultExpr$1(e)],"lessThan").asBoolean()}lessThanOrEqual(e){return new FunctionExpression("less_than_or_equal",[this,__PRIVATE_valueToDefaultExpr$1(e)],"lessThanOrEqual").asBoolean()}greaterThan(e){return new FunctionExpression("greater_than",[this,__PRIVATE_valueToDefaultExpr$1(e)],"greaterThan").asBoolean()}greaterThanOrEqual(e){return new FunctionExpression("greater_than_or_equal",[this,__PRIVATE_valueToDefaultExpr$1(e)],"greaterThanOrEqual").asBoolean()}arrayConcat(e,...r){const i=[e,...r].map((e=>__PRIVATE_valueToDefaultExpr$1(e)));return new FunctionExpression("array_concat",[this,...i],"arrayConcat")}arrayContains(e){return new FunctionExpression("array_contains",[this,__PRIVATE_valueToDefaultExpr$1(e)],"arrayContains").asBoolean()}arrayContainsAll(e){const r=Array.isArray(e)?new __PRIVATE_ListOfExprs(e.map(__PRIVATE_valueToDefaultExpr$1),"arrayContainsAll"):e;return new FunctionExpression("array_contains_all",[this,r],"arrayContainsAll").asBoolean()}arrayContainsAny(e){const r=Array.isArray(e)?new __PRIVATE_ListOfExprs(e.map(__PRIVATE_valueToDefaultExpr$1),"arrayContainsAny"):e;return new FunctionExpression("array_contains_any",[this,r],"arrayContainsAny").asBoolean()}arrayReverse(){return new FunctionExpression("array_reverse",[this])}arrayLength(){return new FunctionExpression("array_length",[this],"arrayLength")}equalAny(e){const r=Array.isArray(e)?new __PRIVATE_ListOfExprs(e.map(__PRIVATE_valueToDefaultExpr$1),"equalAny"):e;return new FunctionExpression("equal_any",[this,r],"equalAny").asBoolean()}notEqualAny(e){const r=Array.isArray(e)?new __PRIVATE_ListOfExprs(e.map(__PRIVATE_valueToDefaultExpr$1),"notEqualAny"):e;return new FunctionExpression("not_equal_any",[this,r],"notEqualAny").asBoolean()}exists(){return new FunctionExpression("exists",[this],"exists").asBoolean()}charLength(){return new FunctionExpression("char_length",[this],"charLength")}like(e){return new FunctionExpression("like",[this,__PRIVATE_valueToDefaultExpr$1(e)],"like").asBoolean()}regexContains(e){return new FunctionExpression("regex_contains",[this,__PRIVATE_valueToDefaultExpr$1(e)],"regexContains").asBoolean()}regexFind(e){return new FunctionExpression("regex_find",[this,__PRIVATE_valueToDefaultExpr$1(e)],"regexFind")}regexFindAll(e){return new FunctionExpression("regex_find_all",[this,__PRIVATE_valueToDefaultExpr$1(e)],"regexFindAll")}regexMatch(e){return new FunctionExpression("regex_match",[this,__PRIVATE_valueToDefaultExpr$1(e)],"regexMatch").asBoolean()}stringContains(e){return new FunctionExpression("string_contains",[this,__PRIVATE_valueToDefaultExpr$1(e)],"stringContains").asBoolean()}startsWith(e){return new FunctionExpression("starts_with",[this,__PRIVATE_valueToDefaultExpr$1(e)],"startsWith").asBoolean()}endsWith(e){return new FunctionExpression("ends_with",[this,__PRIVATE_valueToDefaultExpr$1(e)],"endsWith").asBoolean()}toLower(){return new FunctionExpression("to_lower",[this],"toLower")}toUpper(){return new FunctionExpression("to_upper",[this],"toUpper")}trim(e){const r=[this];return e&&r.push(__PRIVATE_valueToDefaultExpr$1(e)),new FunctionExpression("trim",r,"trim")}ltrim(e){const r=[this];return e&&r.push(__PRIVATE_valueToDefaultExpr$1(e)),new FunctionExpression("ltrim",r,"ltrim")}rtrim(e){const r=[this];return e&&r.push(__PRIVATE_valueToDefaultExpr$1(e)),new FunctionExpression("rtrim",r,"rtrim")}type(){return new FunctionExpression("type",[this])}isType(e){return new FunctionExpression("is_type",[this,constant(e)],"isType").asBoolean()}stringConcat(e,...r){const i=[e,...r].map(__PRIVATE_valueToDefaultExpr$1);return new FunctionExpression("string_concat",[this,...i],"stringConcat")}stringIndexOf(e){return new FunctionExpression("string_index_of",[this,__PRIVATE_valueToDefaultExpr$1(e)],"stringIndexOf")}stringRepeat(e){return new FunctionExpression("string_repeat",[this,__PRIVATE_valueToDefaultExpr$1(e)],"stringRepeat")}stringReplaceAll(e,r){return new FunctionExpression("string_replace_all",[this,__PRIVATE_valueToDefaultExpr$1(e),__PRIVATE_valueToDefaultExpr$1(r)],"stringReplaceAll")}stringReplaceOne(e,r){return new FunctionExpression("string_replace_one",[this,__PRIVATE_valueToDefaultExpr$1(e),__PRIVATE_valueToDefaultExpr$1(r)],"stringReplaceOne")}concat(e,...r){const i=[e,...r].map(__PRIVATE_valueToDefaultExpr$1);return new FunctionExpression("concat",[this,...i],"concat")}reverse(){return new FunctionExpression("reverse",[this],"reverse")}arrayFilter(e,r){return new FunctionExpression("array_filter",[this,__PRIVATE_valueToDefaultExpr$1(e),r],"arrayFilter")}arrayTransform(e,r){return new FunctionExpression("array_transform",[this,__PRIVATE_valueToDefaultExpr$1(e),r],"arrayTransform")}arrayTransformWithIndex(e,r,i){return new FunctionExpression("array_transform",[this,__PRIVATE_valueToDefaultExpr$1(e),__PRIVATE_valueToDefaultExpr$1(r),i],"arrayTransformWithIndex")}arraySlice(e,r){const i=[this,__PRIVATE_valueToDefaultExpr$1(e)];return void 0!==r&&i.push(__PRIVATE_valueToDefaultExpr$1(r)),new FunctionExpression("array_slice",i,"arraySlice")}arrayFirst(){return new FunctionExpression("array_first",[this],"arrayFirst")}arrayFirstN(e){return new FunctionExpression("array_first_n",[this,__PRIVATE_valueToDefaultExpr$1(e)],"arrayFirstN")}arrayLast(){return new FunctionExpression("array_last",[this],"arrayLast")}arrayLastN(e){return new FunctionExpression("array_last_n",[this,__PRIVATE_valueToDefaultExpr$1(e)],"arrayLastN")}arrayMaximum(){return new FunctionExpression("maximum",[this],"arrayMaximum")}arrayMaximumN(e){return new FunctionExpression("maximum_n",[this,__PRIVATE_valueToDefaultExpr$1(e)],"arrayMaximumN")}arrayMinimum(){return new FunctionExpression("minimum",[this],"arrayMinimum")}arrayMinimumN(e){return new FunctionExpression("minimum_n",[this,__PRIVATE_valueToDefaultExpr$1(e)],"arrayMinimumN")}arrayIndexOf(e){return new FunctionExpression("array_index_of",[this,__PRIVATE_valueToDefaultExpr$1(e),__PRIVATE_valueToDefaultExpr$1("first")],"arrayIndexOf")}arrayLastIndexOf(e){return new FunctionExpression("array_index_of",[this,__PRIVATE_valueToDefaultExpr$1(e),__PRIVATE_valueToDefaultExpr$1("last")],"arrayLastIndexOf")}arrayIndexOfAll(e){return new FunctionExpression("array_index_of_all",[this,__PRIVATE_valueToDefaultExpr$1(e)],"arrayIndexOfAll")}byteLength(){return new FunctionExpression("byte_length",[this],"byteLength")}ceil(){return new FunctionExpression("ceil",[this])}floor(){return new FunctionExpression("floor",[this])}abs(){return new FunctionExpression("abs",[this])}exp(){return new FunctionExpression("exp",[this])}mapGet(e){return new FunctionExpression("map_get",[this,constant(e)],"mapGet")}mapSet(e,r,...i){const s=[this,__PRIVATE_valueToDefaultExpr$1(e),__PRIVATE_valueToDefaultExpr$1(r),...i.map(__PRIVATE_valueToDefaultExpr$1)];return new FunctionExpression("map_set",s,"mapSet")}mapKeys(){return new FunctionExpression("map_keys",[this],"mapKeys")}mapValues(){return new FunctionExpression("map_values",[this],"mapValues")}mapEntries(){return new FunctionExpression("map_entries",[this],"mapEntries")}getField(e){return new FunctionExpression("get_field",[this,__PRIVATE_valueToDefaultExpr$1(e)],"get_field")}count(){return AggregateFunction._create("count",[this],"count")}sum(){return AggregateFunction._create("sum",[this],"sum")}average(){return AggregateFunction._create("average",[this],"average")}minimum(){return AggregateFunction._create("minimum",[this],"minimum")}maximum(){return AggregateFunction._create("maximum",[this],"maximum")}first(){return AggregateFunction._create("first",[this],"first")}last(){return AggregateFunction._create("last",[this],"last")}arrayAgg(){return AggregateFunction._create("array_agg",[this],"arrayAgg")}arrayAggDistinct(){return AggregateFunction._create("array_agg_distinct",[this],"arrayAggDistinct")}countDistinct(){return AggregateFunction._create("count_distinct",[this],"countDistinct")}logicalMaximum(e,...r){const i=[e,...r];return new FunctionExpression("maximum",[this,...i.map(__PRIVATE_valueToDefaultExpr$1)],"logicalMaximum")}logicalMinimum(e,...r){const i=[e,...r];return new FunctionExpression("minimum",[this,...i.map(__PRIVATE_valueToDefaultExpr$1)],"minimum")}vectorLength(){return new FunctionExpression("vector_length",[this],"vectorLength")}cosineDistance(e){return new FunctionExpression("cosine_distance",[this,__PRIVATE_vectorToExpr$1(e)],"cosineDistance")}dotProduct(e){return new FunctionExpression("dot_product",[this,__PRIVATE_vectorToExpr$1(e)],"dotProduct")}euclideanDistance(e){return new FunctionExpression("euclidean_distance",[this,__PRIVATE_vectorToExpr$1(e)],"euclideanDistance")}unixMicrosToTimestamp(){return new FunctionExpression("unix_micros_to_timestamp",[this],"unixMicrosToTimestamp")}timestampToUnixMicros(){return new FunctionExpression("timestamp_to_unix_micros",[this],"timestampToUnixMicros")}unixMillisToTimestamp(){return new FunctionExpression("unix_millis_to_timestamp",[this],"unixMillisToTimestamp")}timestampToUnixMillis(){return new FunctionExpression("timestamp_to_unix_millis",[this],"timestampToUnixMillis")}unixSecondsToTimestamp(){return new FunctionExpression("unix_seconds_to_timestamp",[this],"unixSecondsToTimestamp")}timestampToUnixSeconds(){return new FunctionExpression("timestamp_to_unix_seconds",[this],"timestampToUnixSeconds")}timestampAdd(e,r){return new FunctionExpression("timestamp_add",[this,__PRIVATE_valueToDefaultExpr$1(e),__PRIVATE_valueToDefaultExpr$1(r)],"timestampAdd")}timestampSubtract(e,r){return new FunctionExpression("timestamp_subtract",[this,__PRIVATE_valueToDefaultExpr$1(e),__PRIVATE_valueToDefaultExpr$1(r)],"timestampSubtract")}timestampDiff(e,r){return new FunctionExpression("timestamp_diff",[this,__PRIVATE_fieldOrExpression$1(e),__PRIVATE_valueToDefaultExpr$1(r)],"timestampDiff")}timestampExtract(e,r){const i=[this,__PRIVATE_valueToDefaultExpr$1(e)];return r&&i.push(__PRIVATE_valueToDefaultExpr$1(r)),new FunctionExpression("timestamp_extract",i,"timestampExtract")}documentId(){return new FunctionExpression("document_id",[this],"documentId")}parent(){return new FunctionExpression("parent",[this],"parent")}substring(e,r){const i=__PRIVATE_valueToDefaultExpr$1(e);return new FunctionExpression("substring",void 0===r?[this,i]:[this,i,__PRIVATE_valueToDefaultExpr$1(r)],"substring")}arrayGet(e){return new FunctionExpression("array_get",[this,__PRIVATE_valueToDefaultExpr$1(e)],"arrayGet")}isError(){return new FunctionExpression("is_error",[this],"isError").asBoolean()}ifError(e){const r=new FunctionExpression("if_error",[this,__PRIVATE_valueToDefaultExpr$1(e)],"ifError");return e instanceof BooleanExpression?r.asBoolean():r}isAbsent(){return new FunctionExpression("is_absent",[this],"isAbsent").asBoolean()}mapRemove(e){return new FunctionExpression("map_remove",[this,__PRIVATE_valueToDefaultExpr$1(e)],"mapRemove")}mapMerge(e,...r){const i=__PRIVATE_valueToDefaultExpr$1(e),s=r.map(__PRIVATE_valueToDefaultExpr$1);return new FunctionExpression("map_merge",[this,i,...s],"mapMerge")}pow(e){return new FunctionExpression("pow",[this,__PRIVATE_valueToDefaultExpr$1(e)])}trunc(e){return void 0===e?new FunctionExpression("trunc",[this]):new FunctionExpression("trunc",[this,__PRIVATE_valueToDefaultExpr$1(e)],"trunc")}round(e){return void 0===e?new FunctionExpression("round",[this]):new FunctionExpression("round",[this,__PRIVATE_valueToDefaultExpr$1(e)],"round")}collectionId(){return new FunctionExpression("collection_id",[this])}length(){return new FunctionExpression("length",[this])}ln(){return new FunctionExpression("ln",[this])}sqrt(){return new FunctionExpression("sqrt",[this])}stringReverse(){return new FunctionExpression("string_reverse",[this])}ifAbsent(e){return new FunctionExpression("if_absent",[this,__PRIVATE_valueToDefaultExpr$1(e)],"ifAbsent")}ifNull(e){return new FunctionExpression("if_null",[this,__PRIVATE_valueToDefaultExpr$1(e)],"ifNull")}coalesce(e,...r){return new FunctionExpression("coalesce",[this,__PRIVATE_valueToDefaultExpr$1(e),...r.map(__PRIVATE_valueToDefaultExpr$1)],"coalesce")}join(e){return new FunctionExpression("join",[this,__PRIVATE_valueToDefaultExpr$1(e)],"join")}log10(){return new FunctionExpression("log10",[this])}arraySum(){return new FunctionExpression("sum",[this])}split(e){return new FunctionExpression("split",[this,__PRIVATE_valueToDefaultExpr$1(e)])}timestampTruncate(e,r){const i=[this,__PRIVATE_valueToDefaultExpr$1(e)];return r&&i.push(__PRIVATE_valueToDefaultExpr$1(r)),new FunctionExpression("timestamp_trunc",i)}ascending(){return ascending(this)}descending(){return descending(this)}as(e){return new AliasedExpression(this,e,"as")}}class AggregateFunction{constructor(e,r){this.name=e,this.params=r,this.exprType="AggregateFunction",this._protoValueType="ProtoValue"}static _create(e,r,i){const s=new AggregateFunction(e,r);return s._methodName=i,s}as(e){return new AliasedAggregate(this,e,"as")}_toProto(e){return{functionValue:{name:this.name,args:this.params.map((r=>r._toProto(e)))}}}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}):e,this.params.forEach((r=>r._readUserData(e)))}}class AliasedAggregate{constructor(e,r,i){this.aggregate=e,this.alias=r,this._methodName=i}_readUserData(e){this.aggregate._readUserData(e)}}class AliasedExpression{constructor(e,r,i){this.expr=e,this.alias=r,this._methodName=i,this.exprType="AliasedExpression",this.selectable=!0}_readUserData(e){this.expr._readUserData(e)}}class __PRIVATE_ListOfExprs extends Expression{constructor(e,r){super(),this.t=e,this._methodName=r,this.expressionType="ListOfExpressions"}_toProto(e){return{arrayValue:{values:this.t.map((r=>r._toProto(e)))}}}_readUserData(e){this.t.forEach((r=>r._readUserData(e)))}}class Field extends Expression{constructor(e,r){super(),this.fieldPath=e,this._methodName=r,this.expressionType="Field",this.selectable=!0}get _fieldPath(){return this.fieldPath}get fieldName(){return this.fieldPath.canonicalString()}get alias(){return this.fieldName}get expr(){return this}geoDistance(e){return new FunctionExpression("geo_distance",[this,__PRIVATE_valueToDefaultExpr$1(e)],"geoDistance")}_toProto(e){return{fieldReferenceValue:this.fieldPath.canonicalString()}}_readUserData(e){}}function field(e){return _field(e,"field")}function _field(e,r){return new Field("string"==typeof e?Z===e?function documentId$1(){return new D(Z)}()._internalPath:_("field",e):e._internalPath,r)}class Constant extends Expression{constructor(e,r){super(),this.value=e,this._methodName=r,this.expressionType="Constant"}static _fromProto(e){const r=new Constant(e,void 0);return r._protoValue=e,r}_toProto(e){return __PRIVATE_hardAssert(void 0!==this._protoValue,237),this._protoValue}_getValue(){return this._protoValue}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}):e,__PRIVATE_isFirestoreValue(this._protoValue)||(this._protoValue=__PRIVATE_parseData(this.value,e))}}function constant(e,r){return __PRIVATE__constant(e,"constant")}function __PRIVATE__constant(e,r){const i=new Constant(e,r);return"boolean"==typeof e?new __PRIVATE_BooleanConstant(i):i}class MapValue extends Expression{constructor(e,r){super(),this.i=e,this._methodName=r,this.expressionType="Constant"}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}):e,this.i.forEach((r=>{r._readUserData(e)}))}_toProto(e){return toMapValue(e,this.i)}}class FunctionExpression extends Expression{constructor(e,r,i,s){super(),this.name=e,this.params=r,this.expressionType="Function",this._optionsProto=void 0,void 0!==i&&(this._methodName=i),void 0!==s&&(this._options=s)}get _optionsUtil(){return new OptionsUtil({})}_toProto(e){const r={functionValue:{name:this.name,args:this.params.map((r=>r._toProto(e)))}};return this._optionsProto&&(r.functionValue.options=this._optionsProto),r}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}):e,this.params.forEach((r=>r._readUserData(e))),this._options&&(this._optionsProto=this._optionsUtil.getOptionsProto(e,this._options))}}class BooleanExpression extends Expression{get _methodName(){return this._expr._methodName}countIf(){return AggregateFunction._create("count_if",[this],"countIf")}not(){return new FunctionExpression("not",[this],"not").asBoolean()}conditional(e,r){return new FunctionExpression("conditional",[this,e,r],"conditional")}ifError(e){const r=__PRIVATE_valueToDefaultExpr$1(e),i=new FunctionExpression("if_error",[this,r],"ifError");return r instanceof BooleanExpression?i.asBoolean():i}_toProto(e){return this._expr._toProto(e)}_readUserData(e){this._expr._readUserData(e)}}class __PRIVATE_BooleanFunctionExpression extends BooleanExpression{constructor(e){super(),this._expr=e,this.expressionType="Function"}}class __PRIVATE_BooleanConstant extends BooleanExpression{constructor(e){super(),this._expr=e,this.expressionType="Constant"}_getValue(){return this._expr._getValue()}}class __PRIVATE_BooleanField extends BooleanExpression{constructor(e){super(),this._expr=e,this.expressionType="Field"}}function countIf(e){return e.countIf()}function arrayGet(e,r){return __PRIVATE_fieldOrExpression$1(e).arrayGet(__PRIVATE_valueToDefaultExpr$1(r))}function isError(e){return e.isError().asBoolean()}function ifError(e,r){return e instanceof BooleanExpression&&r instanceof BooleanExpression?e.ifError(r).asBoolean():e.ifError(__PRIVATE_valueToDefaultExpr$1(r))}function isAbsent(e){return __PRIVATE_fieldOrExpression$1(e).isAbsent()}function mapRemove(e,r){return __PRIVATE_fieldOrExpression$1(e).mapRemove(__PRIVATE_valueToDefaultExpr$1(r))}function mapMerge(e,r,...i){const s=__PRIVATE_valueToDefaultExpr$1(r),o=i.map(__PRIVATE_valueToDefaultExpr$1);return __PRIVATE_fieldOrExpression$1(e).mapMerge(s,...o)}function documentId(e){return __PRIVATE_valueToDefaultExpr$1(e).documentId()}function parent(e){return __PRIVATE_valueToDefaultExpr$1(e).parent()}function substring(e,r,i){const s=__PRIVATE_fieldOrExpression$1(e),o=__PRIVATE_valueToDefaultExpr$1(r),h=void 0===i?void 0:__PRIVATE_valueToDefaultExpr$1(i);return s.substring(o,h)}function add(e,r){return __PRIVATE_fieldOrExpression$1(e).add(__PRIVATE_valueToDefaultExpr$1(r))}function subtract(e,r){const i="string"==typeof e?field(e):e,s=__PRIVATE_valueToDefaultExpr$1(r);return i.subtract(s)}function multiply(e,r){return __PRIVATE_fieldOrExpression$1(e).multiply(__PRIVATE_valueToDefaultExpr$1(r))}function divide(e,r){const i="string"==typeof e?field(e):e,s=__PRIVATE_valueToDefaultExpr$1(r);return i.divide(s)}function mod(e,r){const i="string"==typeof e?field(e):e,s=__PRIVATE_valueToDefaultExpr$1(r);return i.mod(s)}function map(e){return __PRIVATE__map(e)}function __PRIVATE__map(e,r){const i=[];for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const s=e[r];i.push(constant(r)),i.push(__PRIVATE_valueToDefaultExpr$1(s))}return new FunctionExpression("map",i,"map")}function array(e){return function __PRIVATE__array(e,r){return new FunctionExpression("array",e.map((e=>__PRIVATE_valueToDefaultExpr$1(e))),r)}(e,"array")}function equal(e,r){const i=e instanceof Expression?e:field(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.equal(s)}function notEqual(e,r){const i=e instanceof Expression?e:field(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.notEqual(s)}function lessThan(e,r){const i=e instanceof Expression?e:field(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.lessThan(s)}function lessThanOrEqual(e,r){const i=e instanceof Expression?e:field(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.lessThanOrEqual(s)}function greaterThan(e,r){const i=e instanceof Expression?e:field(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.greaterThan(s)}function greaterThanOrEqual(e,r){const i=e instanceof Expression?e:field(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.greaterThanOrEqual(s)}function arrayConcat(e,r,...i){const s=i.map((e=>__PRIVATE_valueToDefaultExpr$1(e)));return __PRIVATE_fieldOrExpression$1(e).arrayConcat(__PRIVATE_fieldOrExpression$1(r),...s)}function arrayContains(e,r){const i=__PRIVATE_fieldOrExpression$1(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.arrayContains(s)}function arrayContainsAny(e,r){return __PRIVATE_fieldOrExpression$1(e).arrayContainsAny(r)}function arrayContainsAll(e,r){return __PRIVATE_fieldOrExpression$1(e).arrayContainsAll(r)}function arrayLength(e){return __PRIVATE_fieldOrExpression$1(e).arrayLength()}function equalAny(e,r){return __PRIVATE_fieldOrExpression$1(e).equalAny(r)}function notEqualAny(e,r){return __PRIVATE_fieldOrExpression$1(e).notEqualAny(r)}function xor(e,r,...i){return new FunctionExpression("xor",[e,r,...i],"xor").asBoolean()}function conditional(e,r,i){return new FunctionExpression("conditional",[e,r,i],"conditional")}function not(e){return e.not()}function logicalMaximum(e,r,...i){return __PRIVATE_fieldOrExpression$1(e).logicalMaximum(__PRIVATE_valueToDefaultExpr$1(r),...i.map((e=>__PRIVATE_valueToDefaultExpr$1(e))))}function logicalMinimum(e,r,...i){return __PRIVATE_fieldOrExpression$1(e).logicalMinimum(__PRIVATE_valueToDefaultExpr$1(r),...i.map((e=>__PRIVATE_valueToDefaultExpr$1(e))))}function exists(e){return __PRIVATE_fieldOrExpression$1(e).exists()}function reverse(e){return __PRIVATE_fieldOrExpression$1(e).reverse()}function byteLength(e){return __PRIVATE_fieldOrExpression$1(e).byteLength()}function exp(e){return __PRIVATE_fieldOrExpression$1(e).exp()}function ceil(e){return __PRIVATE_fieldOrExpression$1(e).ceil()}function floor(e){return __PRIVATE_fieldOrExpression$1(e).floor()}function countDistinct(e){return __PRIVATE_fieldOrExpression$1(e).countDistinct()}function charLength(e){return __PRIVATE_fieldOrExpression$1(e).charLength()}function like(e,r){const i=__PRIVATE_fieldOrExpression$1(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.like(s)}function regexContains(e,r){const i=__PRIVATE_fieldOrExpression$1(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.regexContains(s)}function arrayFilter(e,r,i){return __PRIVATE_fieldOrExpression$1(e).arrayFilter(r,i)}function arrayTransform(e,r,i){return __PRIVATE_fieldOrExpression$1(e).arrayTransform(r,i)}function arrayTransformWithIndex(e,r,i,s){return __PRIVATE_fieldOrExpression$1(e).arrayTransformWithIndex(r,i,s)}function arraySlice(e,r,i){return __PRIVATE_fieldOrExpression$1(e).arraySlice(r,i)}function arrayFirst(e){return __PRIVATE_fieldOrExpression$1(e).arrayFirst()}function arrayFirstN(e,r){return __PRIVATE_fieldOrExpression$1(e).arrayFirstN(__PRIVATE_valueToDefaultExpr$1(r))}function arrayLast(e){return __PRIVATE_fieldOrExpression$1(e).arrayLast()}function arrayLastN(e,r){return __PRIVATE_fieldOrExpression$1(e).arrayLastN(__PRIVATE_valueToDefaultExpr$1(r))}function arrayMaximum(e){return __PRIVATE_fieldOrExpression$1(e).arrayMaximum()}function arrayMaximumN(e,r){return __PRIVATE_fieldOrExpression$1(e).arrayMaximumN(__PRIVATE_valueToDefaultExpr$1(r))}function arrayMinimum(e){return __PRIVATE_fieldOrExpression$1(e).arrayMinimum()}function arrayMinimumN(e,r){return __PRIVATE_fieldOrExpression$1(e).arrayMinimumN(__PRIVATE_valueToDefaultExpr$1(r))}function arrayIndexOf(e,r){return __PRIVATE_fieldOrExpression$1(e).arrayIndexOf(__PRIVATE_valueToDefaultExpr$1(r))}function arrayLastIndexOf(e,r){return __PRIVATE_fieldOrExpression$1(e).arrayLastIndexOf(__PRIVATE_valueToDefaultExpr$1(r))}function arrayIndexOfAll(e,r){return __PRIVATE_fieldOrExpression$1(e).arrayIndexOfAll(__PRIVATE_valueToDefaultExpr$1(r))}function regexFind(e,r){const i=__PRIVATE_fieldOrExpression$1(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.regexFind(s)}function regexFindAll(e,r){const i=__PRIVATE_fieldOrExpression$1(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.regexFindAll(s)}function regexMatch(e,r){const i=__PRIVATE_fieldOrExpression$1(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.regexMatch(s)}function stringContains(e,r){const i=__PRIVATE_fieldOrExpression$1(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.stringContains(s)}function startsWith(e,r){return __PRIVATE_fieldOrExpression$1(e).startsWith(__PRIVATE_valueToDefaultExpr$1(r))}function endsWith(e,r){return __PRIVATE_fieldOrExpression$1(e).endsWith(__PRIVATE_valueToDefaultExpr$1(r))}function toLower(e){return __PRIVATE_fieldOrExpression$1(e).toLower()}function toUpper(e){return __PRIVATE_fieldOrExpression$1(e).toUpper()}function trim(e,r){return __PRIVATE_fieldOrExpression$1(e).trim(r)}function ltrim(e,r){return __PRIVATE_fieldOrExpression$1(e).ltrim(r)}function rtrim(e,r){return __PRIVATE_fieldOrExpression$1(e).rtrim(r)}function type(e){return __PRIVATE_fieldOrExpression$1(e).type()}function isType(e,r){return __PRIVATE_fieldOrExpression$1(e).isType(r)}function stringConcat(e,r,...i){return __PRIVATE_fieldOrExpression$1(e).stringConcat(__PRIVATE_valueToDefaultExpr$1(r),...i.map(__PRIVATE_valueToDefaultExpr$1))}function stringIndexOf(e,r){return __PRIVATE_fieldOrExpression$1(e).stringIndexOf(r)}function stringRepeat(e,r){return __PRIVATE_fieldOrExpression$1(e).stringRepeat(r)}function stringReplaceAll(e,r,i){return __PRIVATE_fieldOrExpression$1(e).stringReplaceAll(r,i)}function stringReplaceOne(e,r,i){return __PRIVATE_fieldOrExpression$1(e).stringReplaceOne(r,i)}function mapGet(e,r){return __PRIVATE_fieldOrExpression$1(e).mapGet(r)}function mapSet(e,r,i,...s){return __PRIVATE_fieldOrExpression$1(e).mapSet(r,i,...s)}function mapKeys(e){return __PRIVATE_fieldOrExpression$1(e).mapKeys()}function mapValues(e){return __PRIVATE_fieldOrExpression$1(e).mapValues()}function mapEntries(e){return __PRIVATE_fieldOrExpression$1(e).mapEntries()}function countAll(){return AggregateFunction._create("count",[],"count")}function count(e){return __PRIVATE_fieldOrExpression$1(e).count()}function sum(e){return __PRIVATE_fieldOrExpression$1(e).sum()}function average(e){return __PRIVATE_fieldOrExpression$1(e).average()}function minimum(e){return __PRIVATE_fieldOrExpression$1(e).minimum()}function maximum(e){return __PRIVATE_fieldOrExpression$1(e).maximum()}function first(e){return __PRIVATE_fieldOrExpression$1(e).first()}function last(e){return __PRIVATE_fieldOrExpression$1(e).last()}function arrayAgg(e){return __PRIVATE_fieldOrExpression$1(e).arrayAgg()}function arrayAggDistinct(e){return __PRIVATE_fieldOrExpression$1(e).arrayAggDistinct()}function cosineDistance(e,r){const i=__PRIVATE_fieldOrExpression$1(e),s=__PRIVATE_vectorToExpr$1(r);return i.cosineDistance(s)}function dotProduct(e,r){const i=__PRIVATE_fieldOrExpression$1(e),s=__PRIVATE_vectorToExpr$1(r);return i.dotProduct(s)}function euclideanDistance(e,r){const i=__PRIVATE_fieldOrExpression$1(e),s=__PRIVATE_vectorToExpr$1(r);return i.euclideanDistance(s)}function vectorLength(e){return __PRIVATE_fieldOrExpression$1(e).vectorLength()}function unixMicrosToTimestamp(e){return __PRIVATE_fieldOrExpression$1(e).unixMicrosToTimestamp()}function timestampToUnixMicros(e){return __PRIVATE_fieldOrExpression$1(e).timestampToUnixMicros()}function unixMillisToTimestamp(e){return __PRIVATE_fieldOrExpression$1(e).unixMillisToTimestamp()}function timestampToUnixMillis(e){return __PRIVATE_fieldOrExpression$1(e).timestampToUnixMillis()}function unixSecondsToTimestamp(e){return __PRIVATE_fieldOrExpression$1(e).unixSecondsToTimestamp()}function timestampToUnixSeconds(e){return __PRIVATE_fieldOrExpression$1(e).timestampToUnixSeconds()}function timestampAdd(e,r,i){const s=__PRIVATE_fieldOrExpression$1(e),o=__PRIVATE_valueToDefaultExpr$1(r),h=__PRIVATE_valueToDefaultExpr$1(i);return s.timestampAdd(o,h)}function timestampSubtract(e,r,i){const s=__PRIVATE_fieldOrExpression$1(e),o=__PRIVATE_valueToDefaultExpr$1(r),h=__PRIVATE_valueToDefaultExpr$1(i);return s.timestampSubtract(o,h)}function currentTimestamp(){return new FunctionExpression("current_timestamp",[],"currentTimestamp")}function and(e,r,...i){return new FunctionExpression("and",[e,r,...i],"and").asBoolean()}function or(e,r,...i){return new FunctionExpression("or",[e,r,...i],"xor").asBoolean()}function nor(e,r,...i){return new FunctionExpression("nor",[e,r,...i],"nor").asBoolean()}function pow(e,r){return __PRIVATE_fieldOrExpression$1(e).pow(r)}function rand(){return new FunctionExpression("rand",[],"rand")}function round(e,r){return void 0===r?__PRIVATE_fieldOrExpression$1(e).round():__PRIVATE_fieldOrExpression$1(e).round(__PRIVATE_valueToDefaultExpr$1(r))}function trunc(e,r){return void 0===r?__PRIVATE_fieldOrExpression$1(e).trunc():__PRIVATE_fieldOrExpression$1(e).trunc(__PRIVATE_valueToDefaultExpr$1(r))}function collectionId(e){return __PRIVATE_fieldOrExpression$1(e).collectionId()}function length(e){return __PRIVATE_fieldOrExpression$1(e).length()}function ln(e){return __PRIVATE_fieldOrExpression$1(e).ln()}function log(e,r){return new FunctionExpression("log",[__PRIVATE_fieldOrExpression$1(e),__PRIVATE_valueToDefaultExpr$1(r)])}function sqrt(e){return __PRIVATE_fieldOrExpression$1(e).sqrt()}function stringReverse(e){return __PRIVATE_fieldOrExpression$1(e).stringReverse()}function concat(e,r,...i){return new FunctionExpression("concat",[__PRIVATE_fieldOrExpression$1(e),__PRIVATE_valueToDefaultExpr$1(r),...i.map(__PRIVATE_valueToDefaultExpr$1)])}function abs(e){return __PRIVATE_fieldOrExpression$1(e).abs()}function ifAbsent(e,r){return __PRIVATE_fieldOrExpression$1(e).ifAbsent(__PRIVATE_valueToDefaultExpr$1(r))}function ifNull(e,r){return __PRIVATE_fieldOrExpression$1(e).ifNull(r)}function coalesce(e,r,...i){return __PRIVATE_fieldOrExpression$1(e).coalesce(r,...i)}function switchOn(e,r,...i){return new FunctionExpression("switch_on",[__PRIVATE_valueToDefaultExpr$1(e),__PRIVATE_valueToDefaultExpr$1(r),...i.map(__PRIVATE_valueToDefaultExpr$1)],"switchOn")}function join(e,r){return __PRIVATE_fieldOrExpression$1(e).join(__PRIVATE_valueToDefaultExpr$1(r))}function log10(e){return __PRIVATE_fieldOrExpression$1(e).log10()}function arraySum(e){return __PRIVATE_fieldOrExpression$1(e).arraySum()}function split(e,r){return __PRIVATE_fieldOrExpression$1(e).split(__PRIVATE_valueToDefaultExpr$1(r))}function timestampTruncate(e,r,i){const s=__PRIVATE_isString(r)?__PRIVATE_valueToDefaultExpr$1(r):r;return __PRIVATE_fieldOrExpression$1(e).timestampTruncate(s,i)}function variable(e){return new __PRIVATE_VariableExpression(e)}class __PRIVATE_VariableExpression extends Expression{constructor(e){super(),this.name=e,this.expressionType="Variable"}_toProto(e){return{variableReferenceValue:this.name}}_readUserData(e){}}function currentDocument(){return new FunctionExpression("current_document",[])}class __PRIVATE_PipelineValueExpression extends Expression{constructor(e){super(),this.pipeline=e,this.expressionType="PipelineValue"}_toProto(e){return __PRIVATE_toPipelineValue(this.pipeline._toProto(e))}_readUserData(e){this.pipeline._readUserData(e)}}function timestampDiff(e,r,i){const s=__PRIVATE_fieldOrExpression$1(e),o=__PRIVATE_fieldOrExpression$1(r),h=__PRIVATE_valueToDefaultExpr$1(i);return s.timestampDiff(o,h)}function timestampExtract(e,r,i){return __PRIVATE_fieldOrExpression$1(e).timestampExtract(__PRIVATE_valueToDefaultExpr$1(r),i)}function documentMatches(e){return new FunctionExpression("document_matches",[__PRIVATE_valueToDefaultExpr$1(e)],"documentMatches").asBoolean()}function score(){return new FunctionExpression("score",[],"score")}function geoDistance(e,r){return __PRIVATE_toField(e).geoDistance(r)}function ascending(e){return new Ordering(__PRIVATE_fieldOrExpression$1(e),"ascending","ascending")}function descending(e){return new Ordering(__PRIVATE_fieldOrExpression$1(e),"descending","descending")}class Ordering{constructor(e,r,i){this.expr=e,this.direction=r,this._methodName=i,this._protoValueType="ProtoValue"}_toProto(e){return{mapValue:{fields:{direction:__PRIVATE_toStringValue(this.direction),expression:this.expr._toProto(e)}}}}_readUserData(e){this.expr._readUserData(e)}}function __PRIVATE_isSelectable(e){const r=e;return r.selectable&&__PRIVATE_isString(r.alias)&&__PRIVATE_isExpr(r.expr)}function __PRIVATE_isOrdering(e){const r=e;return null!=r&&__PRIVATE_isExpr(r.expr)&&("ascending"===r.direction||"descending"===r.direction)}function __PRIVATE_isAliasedAggregate(e){const r=e;return __PRIVATE_isString(r.alias)&&r.aggregate instanceof AggregateFunction}function __PRIVATE_isExpr(e){return e instanceof Expression}function __PRIVATE_isBooleanExpr(e){return e instanceof BooleanExpression}function __PRIVATE_isAliasedExpr(e){return e instanceof AliasedExpression}function __PRIVATE_isField(e){return e instanceof Field}function __PRIVATE_toField(e){return __PRIVATE_isString(e)?field(e):e}function __PRIVATE_selectablesToMap(e){return new Map(Object.entries(__PRIVATE_selectablesToObject(e)))}function __PRIVATE_selectablesToObject(e){const r={};for(const i of e){let e,s;if("string"==typeof i?(e=i,s=field(i)):i instanceof Field||i instanceof AliasedExpression?(e=i.alias,s=i.expr):z(21273,{selectable:i}),void 0!==r[e])throw new k("invalid-argument",`Duplicate alias or field '${e}'`);r[e]=s}return r}function __PRIVATE_fieldOrExpression(e){return __PRIVATE_isString(e)?field(e):function __PRIVATE_valueToDefaultExpr(e){let r;return __PRIVATE_isFirestoreValue(e)?constant(e):e instanceof Expression?e:(r=__PRIVATE_isPlainObject(e)?map(e):e instanceof Array?array(e):function __PRIVATE_isPipeline$1(e){return"object"==typeof e&&null!==e&&"function"==typeof e.toArrayExpression}(e)?function pipelineValue(e){return new __PRIVATE_PipelineValueExpression(e)}(e):__PRIVATE__constant(e,void 0),r)}(e)}class Stage{constructor(e){this.optionsProto=void 0,({rawOptions:this.rawOptions,...this.knownOptions}=e)}_readUserData(e){this.optionsProto=this._optionsUtil.getOptionsProto(e,this.knownOptions,this.rawOptions)}_toProto(e){return{name:this._name,options:this.optionsProto}}}class __PRIVATE_AddFields extends Stage{get _name(){return"add_fields"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.fields=e}_toProto(e){return{...super._toProto(e),args:[toMapValue(e,this.fields)]}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.fields,e)}}class __PRIVATE_RemoveFields extends Stage{get _name(){return"remove_fields"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.fields=e}_toProto(e){return{...super._toProto(e),args:this.fields.map((r=>r._toProto(e)))}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.fields,e)}}class __PRIVATE_Define extends Stage{get _name(){return"let"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.o=e}_toProto(e){return{...super._toProto(e),args:[toMapValue(e,this.o)]}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.o,e)}}class __PRIVATE_Aggregate extends Stage{get _name(){return"aggregate"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r,i){super(i),this.groups=e,this.accumulators=r}_toProto(e){return{...super._toProto(e),args:[toMapValue(e,this.accumulators),toMapValue(e,this.groups)]}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.groups,e),__PRIVATE_readUserDataHelper(this.accumulators,e)}}class __PRIVATE_Distinct extends Stage{get _name(){return"distinct"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.groups=e}_toProto(e){return{...super._toProto(e),args:[toMapValue(e,this.groups)]}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.groups,e)}}class __PRIVATE_CollectionSource extends Stage{get _name(){return"collection"}get _optionsUtil(){return new OptionsUtil({forceIndex:{serverName:"force_index"}})}constructor(e,r){super(r),this.u=__PRIVATE_normalizeCollectionPath(e)}_toProto(e){return{...super._toProto(e),args:[{referenceValue:this.u}]}}_readUserData(e){super._readUserData(e)}}class __PRIVATE_CollectionGroupSource extends Stage{get _name(){return"collection_group"}get _optionsUtil(){return new OptionsUtil({forceIndex:{serverName:"force_index"}})}constructor(e,r){super(r),this.collectionId=e}_toProto(e){return{...super._toProto(e),args:[{referenceValue:""},{stringValue:this.collectionId}]}}_readUserData(e){super._readUserData(e)}}class __PRIVATE_SubcollectionSource extends Stage{get _name(){return"subcollection"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.path=e}_toProto(e){return{...super._toProto(e),args:[{stringValue:this.path}]}}_readUserData(e){super._readUserData(e)}}class __PRIVATE_DatabaseSource extends Stage{get _name(){return"database"}get _optionsUtil(){return new OptionsUtil({})}_toProto(e){return{...super._toProto(e)}}_readUserData(e){super._readUserData(e)}}class __PRIVATE_DocumentsSource extends Stage{get _name(){return"documents"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){if(super(r),!e||0===e.length)throw new k(b,"Empty document paths are not allowed in DocumentsSource");const i=e.map((e=>e.startsWith("/")?e:"/"+e)),s=new Set(i);if(s.size!==i.length)throw new k(b,"Duplicate document paths are not allowed in DocumentsSource");this._=i,this.l=s}_toProto(e){return{...super._toProto(e),args:this._.map((e=>({referenceValue:e})))}}_readUserData(e){super._readUserData(e)}}class __PRIVATE_LiteralsSource extends Stage{get _name(){return"literals"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r={}){super(r),this.documents=e}_readUserData(e){super._readUserData(e),this.p=this.documents.map((r=>function __PRIVATE_encodeLiteralDocument(e,r){const i=new Map;for(const s of Object.keys(e)){const o=r.childContextForField(s),h=e[s];void 0===h&&o.ignoreUndefinedProperties||i.set(s,__PRIVATE_encodeLiteralValue(h,o))}return i}(r,e)))}_toProto(e){const r=(this.p??[]).map((r=>toMapValue(e,r)));return{...super._toProto(e),args:r}}}function __PRIVATE_encodeLiteralValue(e,r){if(__PRIVATE_isExpr(e))return e._readUserData(r),e;if(__PRIVATE_isPlainObject(e)){const i=[],s=e;for(const e of Object.keys(s)){const o=r.childContextForField(e),h=s[e];if(void 0===h&&o.ignoreUndefinedProperties)continue;const E=__PRIVATE__constant(e,"literals");E._readUserData(o);const T=__PRIVATE_encodeLiteralValue(h,o);i.push(E,T)}return new FunctionExpression("map",i)}if(Array.isArray(e)){const i=e.map((e=>{if(void 0===e)throw r.createError("Unsupported field value: undefined");return __PRIVATE_encodeLiteralValue(e,r)}));return new FunctionExpression("array",i)}{const i=__PRIVATE__constant(e,"literals");return i._readUserData(r),i}}class __PRIVATE_Where extends Stage{get _name(){return"where"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.condition=e}_toProto(e){return{...super._toProto(e),args:[this.condition._toProto(e)]}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.condition,e)}}class __PRIVATE_FindNearest extends Stage{get _name(){return"find_nearest"}get _optionsUtil(){return new OptionsUtil({limit:{serverName:"limit"},distanceField:{serverName:"distance_field"}})}constructor(e,r,i,s){super(s),this.vectorValue=e,this.field=r,this.distanceMeasure=i}_toProto(e){return{...super._toProto(e),args:[this.field._toProto(e),this.vectorValue._toProto(e),__PRIVATE_toStringValue(this.distanceMeasure)]}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.vectorValue,e),__PRIVATE_readUserDataHelper(this.field,e)}}class __PRIVATE_Limit extends Stage{get _name(){return"limit"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){__PRIVATE_hardAssert(!isNaN(e)&&e!==1/0&&e!==-1/0,34860),super(r),this.limit=e}_toProto(e){return{...super._toProto(e),args:[toNumber(e,this.limit)]}}}class __PRIVATE_Offset extends Stage{get _name(){return"offset"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.offset=e}_toProto(e){return{...super._toProto(e),args:[toNumber(e,this.offset)]}}}class __PRIVATE_Select extends Stage{get _name(){return"select"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.selections=e}_toProto(e){return{...super._toProto(e),args:[toMapValue(e,this.selections)]}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.selections,e)}}class __PRIVATE_Sort extends Stage{get _name(){return"sort"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.orderings=e}_toProto(e){return{...super._toProto(e),args:this.orderings.map((r=>r._toProto(e)))}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.orderings,e)}}class __PRIVATE_Sample extends Stage{get _name(){return"sample"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r,i){super(i),this.rate=e,this.mode=r}_toProto(e){return{...super._toProto(e),args:[toNumber(e,this.rate),__PRIVATE_toStringValue(this.mode)]}}_readUserData(e){super._readUserData(e)}}class __PRIVATE_Union extends Stage{get _name(){return"union"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.other=e}_toProto(e){return{...super._toProto(e),args:[__PRIVATE_toPipelineValue(this.other._toProto(e))]}}_readUserData(e){this.other._readUserData(e),super._readUserData(e)}}class __PRIVATE_Unnest extends Stage{get _name(){return"unnest"}get _optionsUtil(){return new OptionsUtil({indexField:{serverName:"index_field"}})}constructor(e,r,i){super(i),this.alias=e,this.expr=r}_toProto(e){return{...super._toProto(e),args:[this.expr._toProto(e),field(this.alias)._toProto(e)]}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.expr,e)}}class __PRIVATE_Replace extends Stage{get _name(){return"replace_with"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.map=e}_toProto(e){return{...super._toProto(e),args:[this.map._toProto(e),__PRIVATE_toStringValue(__PRIVATE_Replace.T)]}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.map,e)}}__PRIVATE_Replace.T="full_replace";class __PRIVATE_Search extends Stage{constructor(e){super(e),this.h=e}get _name(){return"search"}get _optionsUtil(){return new OptionsUtil({query:{serverName:"query"},limit:{serverName:"limit"},retrievalDepth:{serverName:"retrieval_depth"},sort:{serverName:"sort"},addFields:{serverName:"add_fields"},select:{serverName:"select"},offset:{serverName:"offset"},A:{serverName:"query_enhancement"},languageCode:{serverName:"language_code"}})}_toProto(e){return{...super._toProto(e),args:[]}}_readUserData(e){__PRIVATE_readUserDataHelper(this.h.query,e),this.h.addFields&&__PRIVATE_readUserDataHelper(this.h.addFields,e),this.h.select&&__PRIVATE_readUserDataHelper(this.h.select,e),this.h.sort&&__PRIVATE_readUserDataHelper(this.h.sort,e),super._readUserData(e)}}class __PRIVATE_RawStage extends Stage{constructor(e,r,i){super({rawOptions:i}),this.name=e,this.params=r}_toProto(e){return{name:this.name,args:this.params.map((r=>r._toProto(e))),options:this.optionsProto}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.params,e)}get _name(){return this.name}get _optionsUtil(){return new OptionsUtil({})}}class Delete extends Stage{get _name(){return"delete"}get _optionsUtil(){return new OptionsUtil({})}constructor(e={}){super(e)}_toProto(e){return{...super._toProto(e),args:[]}}}class Update extends Stage{get _name(){return"update"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r={}){const{transformedFields:i,...s}=r;super(s),this.transformedFields=e}_toProto(e){const r=[];return this.transformedFields&&this.transformedFields.size>0?r.push(toMapValue(e,this.transformedFields)):r.push(toMapValue(e,new Map)),{...super._toProto(e),args:r}}_readUserData(e){super._readUserData(e),this.transformedFields&&__PRIVATE_readUserDataHelper(this.transformedFields,e)}}class __PRIVATE_Insert extends Stage{get _name(){return"insert"}get _optionsUtil(){return new OptionsUtil({})}constructor(e={}){const{collection:r,documentIdExpression:i,...s}=e;super(s),void 0!==r&&(__PRIVATE_validateNonEmptyArgument("insert","collection path","string"==typeof r?r:r.path),this.collectionPath=__PRIVATE_normalizeCollectionPath(r)),i&&(this.P=__PRIVATE_fieldOrExpression(i))}_toProto(e){const r=super._toProto(e),i={};return this.collectionPath&&(i.collection={referenceValue:this.collectionPath}),this.P&&(i.document_id=this.P._toProto(e)),r.options&&Object.assign(i,r.options),{...r,options:Object.keys(i).length>0?i:void 0,args:[]}}_readUserData(e){super._readUserData(e),this.P&&__PRIVATE_readUserDataHelper(this.P,e)}}class __PRIVATE_Upsert extends Stage{get _name(){return"upsert"}get _optionsUtil(){return new OptionsUtil({})}constructor(e={}){const{collection:r,documentIdExpression:i,additionalFields:s,...o}=e;super(o),this.additionalFields=__PRIVATE_selectablesToMap(s??[]),void 0!==r&&(__PRIVATE_validateNonEmptyArgument("upsert","collection path","string"==typeof r?r:r.path),this.collectionPath=__PRIVATE_normalizeCollectionPath(r)),i&&(this.P=__PRIVATE_fieldOrExpression(i))}_toProto(e){const r=super._toProto(e),i={};this.collectionPath&&(i.collection={referenceValue:this.collectionPath}),this.P&&(i.document_id=this.P._toProto(e)),r.options&&Object.assign(i,r.options);const s=[toMapValue(e,this.additionalFields)];return{...r,options:Object.keys(i).length>0?i:void 0,args:s}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.additionalFields,e),this.P&&__PRIVATE_readUserDataHelper(this.P,e)}}function __PRIVATE_normalizeCollectionPath(e){const r="string"==typeof e?e:e.path;return r.startsWith("/")?r:"/"+r}function __PRIVATE_readUserDataHelper(e,r){return function __PRIVATE_isUserData(e){return"function"==typeof e._readUserData}(e)?e._readUserData(r):Array.isArray(e)||e instanceof Map?e.forEach((e=>e._readUserData(r))):Object.values(e).forEach((e=>e._readUserData(r))),e}class Pipeline{constructor(e,r,i,s){this._db=e,this.userDataReader=r,this._userDataWriter=i,this.stages=s}_readUserData(e){this.stages.forEach((r=>{const i=e.contextWith({methodName:r._name});r._readUserData(i)}))}addFields(e,...r){let i,s;__PRIVATE_isSelectable(e)?(i=[e,...r],s={}):({fields:i,...s}=e);const o=__PRIVATE_selectablesToMap(i),h=new __PRIVATE_AddFields(o,s);return this._addStage(h)}removeFields(e,...r){const i=__PRIVATE_isField(e)||__PRIVATE_isString(e)?{}:e,s=(__PRIVATE_isField(e)||__PRIVATE_isString(e)?[e,...r]:e.fields).map((e=>__PRIVATE_isString(e)?field(e):e)),o=new __PRIVATE_RemoveFields(s,i);return this._addStage(o)}define(e,...r){const i=__PRIVATE_isAliasedExpr(e)?{}:e,s=__PRIVATE_selectablesToMap(__PRIVATE_isAliasedExpr(e)?[e,...r]:e.variables),o=new __PRIVATE_Define(s,i);return this._addStage(o)}toArrayExpression(){return new FunctionExpression("array",[__PRIVATE_fieldOrExpression(this)])}toScalarExpression(){return new FunctionExpression("scalar",[__PRIVATE_fieldOrExpression(this)])}select(e,...r){const i=__PRIVATE_isSelectable(e)||__PRIVATE_isString(e)?{}:e,s=__PRIVATE_selectablesToMap(__PRIVATE_isSelectable(e)||__PRIVATE_isString(e)?[e,...r]:e.selections),o=new __PRIVATE_Select(s,i);return this._addStage(o)}where(e){const r=__PRIVATE_isBooleanExpr(e)?{}:e,i=__PRIVATE_isBooleanExpr(e)?e:e.condition,s=new __PRIVATE_Where(i,r);return this._addStage(s)}offset(e){let r,i;__PRIVATE_isNumber(e)?(r={},i=e):(r=e,i=e.offset);const s=new __PRIVATE_Offset(i,r);return this._addStage(s)}limit(e){const r=__PRIVATE_isNumber(e)?{}:e,i=__PRIVATE_isNumber(e)?e:e.limit,s=new __PRIVATE_Limit(i,r);return this._addStage(s)}distinct(e,...r){const i=__PRIVATE_isString(e)||__PRIVATE_isSelectable(e)?{}:e,s=__PRIVATE_selectablesToMap(__PRIVATE_isString(e)||__PRIVATE_isSelectable(e)?[e,...r]:e.groups),o=new __PRIVATE_Distinct(s,i);return this._addStage(o)}aggregate(e,...r){const i=__PRIVATE_isAliasedAggregate(e)?{}:e,s=__PRIVATE_isAliasedAggregate(e)?[e,...r]:e.accumulators,o=__PRIVATE_isAliasedAggregate(e)?[]:e.groups??[],h=function __PRIVATE_aliasedAggregateToMap(e){return e.reduce(((e,r)=>{if(void 0!==e.get(r.alias))throw new k("invalid-argument",`Duplicate alias or field '${r.alias}'`);return e.set(r.alias,r.aggregate),e}),new Map)}(s),E=__PRIVATE_selectablesToMap(o),T=new __PRIVATE_Aggregate(E,h,i);return this._addStage(T)}findNearest(e){const r=__PRIVATE_toField(e.field),i=function __PRIVATE_vectorToExpr(e){if(e instanceof Expression)return e;if(e instanceof VectorValue)return constant(e);if(Array.isArray(e))return constant(vector(e));throw new Error("Unsupported value: "+typeof e)}(e.vectorValue),s={distanceField:e.distanceField?__PRIVATE_toField(e.distanceField):void 0,limit:e.limit,rawOptions:e.rawOptions},o=new __PRIVATE_FindNearest(i,r,e.distanceMeasure,s);return this._addStage(o)}search(e){const r=e.addFields?__PRIVATE_selectablesToObject(e.addFields):void 0,i=__PRIVATE_isExpr(e.query)?e.query:documentMatches(e.query),s=__PRIVATE_isOrdering(e.sort)?[e.sort]:e.sort,o={...e,addFields:r,select:void 0,query:i,sort:s},h=new __PRIVATE_Search(o);return this._addStage(h)}sort(e,...r){const i=__PRIVATE_isOrdering(e)?{}:e,s=__PRIVATE_isOrdering(e)?[e,...r]:e.orderings,o=new __PRIVATE_Sort(s,i);return this._addStage(o)}replaceWith(e){const r=__PRIVATE_isString(e)||__PRIVATE_isExpr(e)?{}:e,i=__PRIVATE_fieldOrExpression(__PRIVATE_isString(e)||__PRIVATE_isExpr(e)?e:e.map),s=new __PRIVATE_Replace(i,r);return this._addStage(s)}sample(e){const r=__PRIVATE_isNumber(e)?{}:e;let i,s;__PRIVATE_isNumber(e)?(i=e,s="documents"):__PRIVATE_isNumber(e.documents)?(i=e.documents,s="documents"):(i=e.percentage,s="percent");const o=new __PRIVATE_Sample(i,s,r);return this._addStage(o)}union(e){let r,i;!function __PRIVATE_isPipeline(e){return e instanceof Pipeline}(e)?({other:i,...r}=e):(r={},i=e);const s=new __PRIVATE_Union(i,r);return this._addStage(s)}unnest(e,r){let i,s,o;__PRIVATE_isSelectable(e)?(i={},s=e,o=r):({selectable:s,indexField:o,...i}=e);const h=s.alias,E=s.expr;__PRIVATE_isString(o)&&(i.indexField=_field(o,"unnest"));const T=new __PRIVATE_Unnest(h,E,i);return this._addStage(T)}rawStage(e,r,i){const s=r.map((e=>e instanceof Expression||e instanceof AggregateFunction?e:__PRIVATE_isPlainObject(e)?function __PRIVATE__mapValue(e){const r=new Map;for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)){const s=e[i];r.set(i,__PRIVATE_valueToDefaultExpr$1(s))}return new MapValue(r,void 0)}(e):__PRIVATE__constant(e,"rawStage"))),o=new __PRIVATE_RawStage(e,s,i??{});return this._addStage(o)}delete(e={}){return this._addStage(new Delete(e))}update(e,...r){let i,s={};__PRIVATE_isAliasedExpr(e)?i=[e,...r]:e&&({transformedFields:i,...s}=e);const o=i&&i.length>0?__PRIVATE_selectablesToMap(i):void 0;return this._addStage(new Update(o,s))}insert(e={}){return this._validateCollectionReference(e.collection),this._addStage(new __PRIVATE_Insert(e))}upsert(e,...r){let i={};return __PRIVATE_isAliasedExpr(e)?i={additionalFields:[e,...r]}:e&&(i=e),this._validateCollectionReference(i.collection),this._addStage(new __PRIVATE_Upsert(i))}_validateCollectionReference(e){if(!this._db||!__PRIVATE_isCollectionReference(e))return;const r=e.firestore._databaseId,i=this._db._databaseId;if(!r.isEqual(i))throw new k(b,`Invalid CollectionReference. The project ID ("${r.projectId}") or the database ("${r.database}") does not match the project ID ("${i.projectId}") and database ("${i.database}") of the target database of this Pipeline.`)}_toProto(e){return{stages:this.stages.map((r=>r._toProto(e)))}}_addStage(e){const r=this.stages.map((e=>e));return r.push(e),this.newPipeline(this._db,r)}newPipeline(e,r){return new Pipeline(e,this.userDataReader,this._userDataWriter,r)}}function __PRIVATE_toPipelineBooleanExpr(e){if(e instanceof FieldFilter){const r=field(e.field.toString()),i=e.value;switch(e.op){case"<":return and(r.exists(),r.lessThan(Constant._fromProto(i)));case"<=":return and(r.exists(),r.lessThanOrEqual(Constant._fromProto(i)));case">":return and(r.exists(),r.greaterThan(Constant._fromProto(i)));case">=":return and(r.exists(),r.greaterThanOrEqual(Constant._fromProto(i)));case"==":return and(r.exists(),r.equal(Constant._fromProto(i)));case"!=":return r.notEqual(Constant._fromProto(i));case"array-contains":return and(r.exists(),r.arrayContains(Constant._fromProto(i)));case"in":{const e=i?.arrayValue?.values?.map((e=>Constant._fromProto(e)));return e?1===e.length?and(r.exists(),r.equal(e[0])):and(r.exists(),r.equalAny(e)):and(r.exists(),r.equalAny([]))}case"array-contains-any":{const e=i?.arrayValue?.values?.map((e=>Constant._fromProto(e)));return and(r.exists(),r.arrayContainsAny(e))}case"not-in":{const e=i?.arrayValue?.values?.map((e=>Constant._fromProto(e)));return e?1===e.length?r.notEqual(e[0]):r.notEqualAny(e):r.notEqualAny([])}default:z(36935)}}else if(e instanceof CompositeFilter)switch(e.op){case"and":{const r=e.getFilters().map((e=>__PRIVATE_toPipelineBooleanExpr(e)));return and(r[0],r[1],...r.slice(2))}case"or":{const r=e.getFilters().map((e=>__PRIVATE_toPipelineBooleanExpr(e)));return or(r[0],r[1],...r.slice(2))}default:z(35306)}throw new Error(`Failed to convert filter to pipeline conditions: ${e}`)}function __PRIVATE_toPipelineStages(e,r){let i;i=function __PRIVATE_isCollectionGroupQuery(e){return null!==e.collectionGroup}(e)?r.pipeline().collectionGroup(e.collectionGroup):function __PRIVATE_isDocumentQuery(e){return C.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}(e)?r.pipeline().documents([doc(r,e.path.canonicalString())]):r.pipeline().collection(e.path.canonicalString());for(const r of e.filters)i=i.where(__PRIVATE_toPipelineBooleanExpr(r));const s=function __PRIVATE_queryNormalizedOrderBy(e){const r=__PRIVATE_debugCast(e);if(null===r.St){r.St=[];const e=new Set;for(const i of r.explicitOrderBy)r.St.push(i),e.add(i.field.canonicalString());const i=r.explicitOrderBy.length>0?r.explicitOrderBy[r.explicitOrderBy.length-1].dir:"asc",s=function __PRIVATE_getInequalityFilterFields(e){let r=new SortedSet(te.comparator);return e.filters.forEach((e=>{e.getFlattenedFilters().forEach((e=>{e.isInequality()&&(r=r.add(e.field))}))})),r}(r);s.forEach((s=>{e.has(s.canonicalString())||s.isKeyField()||r.St.push(new OrderBy(s,i))})),e.has(te.keyField().canonicalString())||r.St.push(new OrderBy(te.keyField(),i))}return r.St}(e),o=s.map((e=>field(e.field.canonicalString()).exists()));i=o.length>1?i.where(and(o[0],o[1],...o.slice(2))):i.where(o[0]);const h=s.map((e=>"asc"===e.dir?field(e.field.canonicalString()).ascending():field(e.field.canonicalString()).descending()));if(h.length>0)if("L"===e.limitType){const r=function __PRIVATE_reverseOrderings(e){return e.map((e=>new Ordering(e.expr,"ascending"===e.direction?"descending":"ascending",void 0)))}(h);i=i.sort(r[0],...r.slice(1)),null!==e.startAt&&(i=i.where(__PRIVATE_whereConditionsFromCursor(e.startAt,h,"after"))),null!==e.endAt&&(i=i.where(__PRIVATE_whereConditionsFromCursor(e.endAt,h,"before"))),i=i.limit(e.limit),i=i.sort(h[0],...h.slice(1))}else i=i.sort(h[0],...h.slice(1)),null!==e.startAt&&(i=i.where(__PRIVATE_whereConditionsFromCursor(e.startAt,h,"after"))),null!==e.endAt&&(i=i.where(__PRIVATE_whereConditionsFromCursor(e.endAt,h,"before"))),null!==e.limit&&(i=i.limit(e.limit));return i.stages}function __PRIVATE_whereConditionsFromCursor(e,r,i){const s="before"===i?lessThan:greaterThan,o=e.position.map((e=>Constant._fromProto(e))),h=o.length;let E=r[h-1].expr,T=o[h-1],V=s(E,T);e.inclusive&&(V=or(V,E.equal(T)));for(let e=h-2;e>=0;e--)E=r[e].expr,T=o[e],V=or(s(E,T),and(E.equal(T),V));return V}class PipelineSource{constructor(e,r,i){this.databaseId=e,this.userDataReader=r,this._createPipeline=i}collection(e){const r=__PRIVATE_isString(e)||__PRIVATE_isCollectionReference(e)?{}:e,i=__PRIVATE_isString(e)||__PRIVATE_isCollectionReference(e)?e:e.collection;__PRIVATE_isCollectionReference(i)&&this._validateReference(i);const s=__PRIVATE_isString(i)?i:i.path,o=new __PRIVATE_CollectionSource(s,r),h=this.userDataReader.createContext(3,"collection");return o._readUserData(h),this._createPipeline([o])}collectionGroup(e){let r,i;__PRIVATE_isString(e)?(r=e,i={}):({collectionId:r,...i}=e);const s=new __PRIVATE_CollectionGroupSource(r,i),o=this.userDataReader.createContext(3,"collectionGroup");return s._readUserData(o),this._createPipeline([s])}database(e){const r=new __PRIVATE_DatabaseSource(e=e??{}),i=this.userDataReader.createContext(3,"database");return r._readUserData(i),this._createPipeline([r])}documents(e){let r,i;Array.isArray(e)?(i=e,r={}):({docs:i,...r}=e),i.filter((e=>e instanceof DocumentReference)).forEach((e=>this._validateReference(e)));const s=i.map((e=>__PRIVATE_isString(e)?e:e.path)),o=new __PRIVATE_DocumentsSource(s,r),h=this.userDataReader.createContext(3,"documents");return o._readUserData(h),this._createPipeline([o])}literals(e){let r,i={};if(Array.isArray(e))r=e;else{if(!__PRIVATE_isPlainObject(e)||!Array.isArray(e.documents))throw new k(b,"Function literals() requires an array of document objects or a LiteralsStageOptions object with a documents array.");({documents:r,...i}=e)}const s=new __PRIVATE_LiteralsSource(r,i),o=this.userDataReader.createContext(3,"literals");return s._readUserData(o),this._createPipeline([s])}createFrom(e){return this._createPipeline(__PRIVATE_toPipelineStages(e._query,e.firestore))}_validateReference(e){const r=e.firestore._databaseId;if(!r.isEqual(this.databaseId))throw new k(b,`Invalid ${e instanceof CollectionReference?"CollectionReference":"DocumentReference"}. The project ID ("${r.projectId}") or the database ("${r.database}") does not match the project ID ("${this.databaseId.projectId}") and database ("${this.databaseId.database}") of the target database of this Pipeline.`)}}function subcollection(e){let r,i;__PRIVATE_isString(e)?(r=e,i={}):({path:r,...i}=e);const s=new __PRIVATE_SubcollectionSource(r,i);return new Pipeline(void 0,void 0,void 0,[s])}class PipelineSnapshot{constructor(e,r,i){this._pipeline=e,this._executionTime=i,this._results=r}get results(){return this._results}get executionTime(){if(void 0===this._executionTime)throw new Error("'executionTime' is expected to exist, but it is undefined");return this._executionTime}}class PipelineResult{constructor(e,r,i,s,o,h,E){this._ref=i,this._userDataWriter=e,this._createTime=s,this._updateTime=o,this._fields=r,this._metadata=h,this._listenOptions=E}static fromDocument(e,r,i,s,o){return new PipelineResult(e,r.data,i,r.createTime.toTimestamp(),r.version.toTimestamp(),s,o)}get ref(){return this._ref}get id(){return this._ref?.id}get createTime(){return this._createTime}get updateTime(){return this._updateTime}data(){return this._userDataWriter.convertValue(this._fields.value,this._listenOptions?.serverTimestampBehavior)}_fieldsProto(){return this._fields.clone().value.mapValue.fields}get(e){if(void 0===this._fields)return;__PRIVATE_isField(e)&&(e=e.fieldName);const r=this._fields.field(_("DocumentSnapshot.get",e));return null!==r?this._userDataWriter.convertValue(r,this._listenOptions?.serverTimestampBehavior):void 0}}class __PRIVATE_StructuredPipelineOptions{constructor(e={},r={}){this.V=e,this.I=r,this.R=new OptionsUtil({indexMode:{serverName:"index_mode"}})}_readUserData(e){this.proto=this.R.getOptionsProto(e,this.V,this.I)}}class StructuredPipeline{constructor(e,r){this.pipeline=e,this.options=r}_toProto(e){return{pipeline:this.pipeline._toProto(e),options:this.options.proto}}}function execute(e){const r=e instanceof Pipeline?{pipeline:e}:e,{pipeline:i,rawOptions:s,atomic:o,...h}=r;if(!i._db)return Promise.reject(new k(U,"This pipeline was created without a database (e.g., as a subcollection pipeline) and cannot be executed directly. It can only be used as part of another pipeline."));const E=function d(e){if(e._terminated)throw new k(U,"The client has already been terminated.");if(!Be.has(e)){a(Ce,"Initializing Datastore");const r=function __PRIVATE_newConnection(e){return new __PRIVATE_FetchConnection(e)}(function __PRIVATE_makeDatabaseInfo(e,r,i,s,o){return new DatabaseInfo(e,r,i,o.host,o.ssl,o.experimentalForceLongPolling,o.experimentalAutoDetectLongPolling,__PRIVATE_cloneLongPollingOptions(o.experimentalLongPollingOptions),o.useFetchStreams,o.isUsingEmulator,s,o._customHeaders,o.grpcFlowControlWindow)}(e._databaseId,e.app.options.appId||"",e._persistenceKey,e.app.options.apiKey,e._freezeSettings())),i=__PRIVATE_newSerializer(e._databaseId),s=function __PRIVATE_newDatastore(e,r,i,s){return new __PRIVATE_DatastoreImpl(e,r,i,s)}(e._authCredentials,e._appCheckCredentials,r,i);Be.set(e,s)}return Be.get(e)}(i._db),T=function f(e,r){if("_delegate"in e&&(e=e._delegate),!(e instanceof r)){if(r.name===e.constructor.name)throw new k(b,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const i=__PRIVATE_valueDescription(e);throw new k(b,`Expected type '${r.name}', but it was: ${i}`)}}return e}(i._db,n),V=p(T).createContext(3,"execute");i._readUserData(V);const P=new A(T),R=new __PRIVATE_StructuredPipelineOptions(h,s);R._readUserData(V);return async function __PRIVATE_invokeExecutePipeline(e,r,i){const s=__PRIVATE_debugCast(e),o={database:(h=s.serializer,new ResourcePath(["projects",h.databaseId.projectId,"databases",h.databaseId.database]).canonicalString()),structuredPipeline:r._toProto(s.serializer),...i?.atomic?{newTransaction:{readWrite:{concurrencyMode:"OPTIMISTIC"}},autoCommitTransaction:!0}:{}};var h;const E=await s.me("ExecutePipeline",s.serializer.databaseId,ResourcePath.emptyPath(),o),T=[];return E.forEach((e=>{if(e.results&&0!==e.results.length)return e.results.forEach((r=>T.push(__PRIVATE_fromPipelineResponse(s.serializer,e,r))));T.push(__PRIVATE_fromPipelineResponse(s.serializer,e))})),T}(E,new StructuredPipeline(i,R),{atomic:o}).then((e=>{const r=e.length>0?e[0].executionTime?.toTimestamp():void 0,s=e.filter((e=>!!e.fields)).map((e=>new PipelineResult(P,e.fields,e.key?.path?new DocumentReference(T,null,e.key):void 0,e.createTime?.toTimestamp(),e.updateTime?.toTimestamp())));return new PipelineSnapshot(i,s,r)}))}n.prototype.pipeline=function(){const e=new A(this),r=p(this);return new PipelineSource(this._databaseId,r,(i=>new Pipeline(this,r,e,i)))};export{AggregateFunction,AliasedAggregate,AliasedExpression,BooleanExpression,Bytes,Constant,DocumentReference,Expression,Field,D as FieldPath,FieldValue,n as Firestore,FunctionExpression,GeoPoint,Ordering,Pipeline,PipelineResult,PipelineSnapshot,PipelineSource,Query,QueryDocumentSnapshot,Timestamp,VectorValue,abs,add,and,array,arrayAgg,arrayAggDistinct,arrayConcat,arrayContains,arrayContainsAll,arrayContainsAny,arrayFilter,arrayFirst,arrayFirstN,arrayGet,arrayIndexOf,arrayIndexOfAll,arrayLast,arrayLastIndexOf,arrayLastN,arrayLength,arrayMaximum,arrayMaximumN,arrayMinimum,arrayMinimumN,arraySlice,arraySum,arrayTransform,arrayTransformWithIndex,ascending,average,byteLength,ceil,charLength,coalesce,collectionId,concat,conditional,constant,cosineDistance,count,countAll,countDistinct,countIf,currentDocument,currentTimestamp,descending,divide,documentId,documentMatches,dotProduct,endsWith,equal,equalAny,euclideanDistance,execute,exists,exp,field,first,floor,geoDistance,greaterThan,greaterThanOrEqual,ifAbsent,ifError,ifNull,isAbsent,isError,isType,join,last,length,lessThan,lessThanOrEqual,like,ln,log,log10,logicalMaximum,logicalMinimum,ltrim,map,mapEntries,mapGet,mapKeys,mapMerge,mapRemove,mapSet,mapValues,maximum,minimum,mod,multiply,nor,not,notEqual,notEqualAny,or,parent,pow,rand,regexContains,regexFind,regexFindAll,regexMatch,reverse,round,rtrim,score,split,sqrt,startsWith,stringConcat,stringContains,stringIndexOf,stringRepeat,stringReplaceAll,stringReplaceOne,stringReverse,subcollection,substring,subtract,sum,switchOn,timestampAdd,timestampDiff,timestampExtract,timestampSubtract,timestampToUnixMicros,timestampToUnixMillis,timestampToUnixSeconds,timestampTruncate,toLower,toUpper,trim,trunc,type,unixMicrosToTimestamp,unixMillisToTimestamp,unixSecondsToTimestamp,variable,vectorLength,xor};
1
+ import"https://www.gstatic.com/firebasejs/13.2.0-eap-sql.b903ef716/firebase-app.js";class FirebaseError extends Error{constructor(e,r,i){super(r),this.code=e,this.customData=i,this.name="FirebaseError",Object.setPrototypeOf(this,FirebaseError.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,ErrorFactory.prototype.create)}}class ErrorFactory{constructor(e,r,i){this.service=e,this.serviceName=r,this.errors=i}create(e,...r){const i=r[0]||{},s=`${this.service}/${e}`,o=this.errors[e],h=o?function replaceTemplate(e,r){try{let i=0,s="";for(;i<e.length;){const o=e.indexOf("{$",i);if(-1===o){s+=e.substring(i);break}const h=e.indexOf("}",o+2);if(-1===h){s+=e.substring(i);break}const E=e.substring(o+2,h),T=r[E];s+=e.substring(i,o)+(null!=T?String(T):`<${E}?>`),i=h+1}return s}catch(r){return e}}(o,i):"Error",E=`${this.serviceName}: ${h} (${s}).`;return new FirebaseError(s,E,i)}}function getModularInstance(e){return e&&e._delegate?e._delegate:e}var e;!function(e){e[e.DEBUG=0]="DEBUG",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.SILENT=5]="SILENT"}(e||(e={}));const r={debug:e.DEBUG,verbose:e.VERBOSE,info:e.INFO,warn:e.WARN,error:e.ERROR,silent:e.SILENT},i=e.INFO,s={[e.DEBUG]:"log",[e.VERBOSE]:"log",[e.INFO]:"info",[e.WARN]:"warn",[e.ERROR]:"error"},defaultLogHandler=(e,r,...i)=>{if(r<e.logLevel)return;const o=(new Date).toISOString(),h=s[r];if(!h)throw new Error(`Attempted to log a message with an invalid logType (value: ${r})`);console[h](`[${o}] ${e.name}:`,...i)};var o,h="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function __classPrivateFieldGet(e,r,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof r?e!==r||!s:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:r.get(e)}(function(){var e;function m(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.C=Array(this.blockSize),this.o=this.h=0,this.u()}function n(e,r,i){i||(i=0);const s=Array(16);if("string"==typeof r)for(var o=0;o<16;++o)s[o]=r.charCodeAt(i++)|r.charCodeAt(i++)<<8|r.charCodeAt(i++)<<16|r.charCodeAt(i++)<<24;else for(o=0;o<16;++o)s[o]=r[i++]|r[i++]<<8|r[i++]<<16|r[i++]<<24;r=e.g[0],i=e.g[1],o=e.g[2];let h,E=e.g[3];h=r+(E^i&(o^E))+s[0]+3614090360&4294967295,h=E+(o^(r=i+(h<<7&4294967295|h>>>25))&(i^o))+s[1]+3905402710&4294967295,E=r+(h<<12&4294967295|h>>>20),h=o+(i^E&(r^i))+s[2]+606105819&4294967295,h=i+(r^(o=E+(h<<17&4294967295|h>>>15))&(E^r))+s[3]+3250441966&4294967295,h=r+(E^(i=o+(h<<22&4294967295|h>>>10))&(o^E))+s[4]+4118548399&4294967295,h=E+(o^(r=i+(h<<7&4294967295|h>>>25))&(i^o))+s[5]+1200080426&4294967295,E=r+(h<<12&4294967295|h>>>20),h=o+(i^E&(r^i))+s[6]+2821735955&4294967295,h=i+(r^(o=E+(h<<17&4294967295|h>>>15))&(E^r))+s[7]+4249261313&4294967295,h=r+(E^(i=o+(h<<22&4294967295|h>>>10))&(o^E))+s[8]+1770035416&4294967295,h=E+(o^(r=i+(h<<7&4294967295|h>>>25))&(i^o))+s[9]+2336552879&4294967295,E=r+(h<<12&4294967295|h>>>20),h=o+(i^E&(r^i))+s[10]+4294925233&4294967295,h=i+(r^(o=E+(h<<17&4294967295|h>>>15))&(E^r))+s[11]+2304563134&4294967295,h=r+(E^(i=o+(h<<22&4294967295|h>>>10))&(o^E))+s[12]+1804603682&4294967295,h=E+(o^(r=i+(h<<7&4294967295|h>>>25))&(i^o))+s[13]+4254626195&4294967295,E=r+(h<<12&4294967295|h>>>20),h=o+(i^E&(r^i))+s[14]+2792965006&4294967295,h=i+(r^(o=E+(h<<17&4294967295|h>>>15))&(E^r))+s[15]+1236535329&4294967295,h=r+(o^E&((i=o+(h<<22&4294967295|h>>>10))^o))+s[1]+4129170786&4294967295,h=E+(i^o&((r=i+(h<<5&4294967295|h>>>27))^i))+s[6]+3225465664&4294967295,E=r+(h<<9&4294967295|h>>>23),h=o+(r^i&(E^r))+s[11]+643717713&4294967295,h=i+(E^r&((o=E+(h<<14&4294967295|h>>>18))^E))+s[0]+3921069994&4294967295,h=r+(o^E&((i=o+(h<<20&4294967295|h>>>12))^o))+s[5]+3593408605&4294967295,h=E+(i^o&((r=i+(h<<5&4294967295|h>>>27))^i))+s[10]+38016083&4294967295,E=r+(h<<9&4294967295|h>>>23),h=o+(r^i&(E^r))+s[15]+3634488961&4294967295,h=i+(E^r&((o=E+(h<<14&4294967295|h>>>18))^E))+s[4]+3889429448&4294967295,h=r+(o^E&((i=o+(h<<20&4294967295|h>>>12))^o))+s[9]+568446438&4294967295,h=E+(i^o&((r=i+(h<<5&4294967295|h>>>27))^i))+s[14]+3275163606&4294967295,E=r+(h<<9&4294967295|h>>>23),h=o+(r^i&(E^r))+s[3]+4107603335&4294967295,h=i+(E^r&((o=E+(h<<14&4294967295|h>>>18))^E))+s[8]+1163531501&4294967295,h=r+(o^E&((i=o+(h<<20&4294967295|h>>>12))^o))+s[13]+2850285829&4294967295,h=E+(i^o&((r=i+(h<<5&4294967295|h>>>27))^i))+s[2]+4243563512&4294967295,E=r+(h<<9&4294967295|h>>>23),h=o+(r^i&(E^r))+s[7]+1735328473&4294967295,h=i+(E^r&((o=E+(h<<14&4294967295|h>>>18))^E))+s[12]+2368359562&4294967295,h=r+((i=o+(h<<20&4294967295|h>>>12))^o^E)+s[5]+4294588738&4294967295,h=E+((r=i+(h<<4&4294967295|h>>>28))^i^o)+s[8]+2272392833&4294967295,E=r+(h<<11&4294967295|h>>>21),h=o+(E^r^i)+s[11]+1839030562&4294967295,h=i+((o=E+(h<<16&4294967295|h>>>16))^E^r)+s[14]+4259657740&4294967295,h=r+((i=o+(h<<23&4294967295|h>>>9))^o^E)+s[1]+2763975236&4294967295,h=E+((r=i+(h<<4&4294967295|h>>>28))^i^o)+s[4]+1272893353&4294967295,E=r+(h<<11&4294967295|h>>>21),h=o+(E^r^i)+s[7]+4139469664&4294967295,h=i+((o=E+(h<<16&4294967295|h>>>16))^E^r)+s[10]+3200236656&4294967295,h=r+((i=o+(h<<23&4294967295|h>>>9))^o^E)+s[13]+681279174&4294967295,h=E+((r=i+(h<<4&4294967295|h>>>28))^i^o)+s[0]+3936430074&4294967295,E=r+(h<<11&4294967295|h>>>21),h=o+(E^r^i)+s[3]+3572445317&4294967295,h=i+((o=E+(h<<16&4294967295|h>>>16))^E^r)+s[6]+76029189&4294967295,h=r+((i=o+(h<<23&4294967295|h>>>9))^o^E)+s[9]+3654602809&4294967295,h=E+((r=i+(h<<4&4294967295|h>>>28))^i^o)+s[12]+3873151461&4294967295,E=r+(h<<11&4294967295|h>>>21),h=o+(E^r^i)+s[15]+530742520&4294967295,h=i+((o=E+(h<<16&4294967295|h>>>16))^E^r)+s[2]+3299628645&4294967295,h=r+(o^((i=o+(h<<23&4294967295|h>>>9))|~E))+s[0]+4096336452&4294967295,h=E+(i^((r=i+(h<<6&4294967295|h>>>26))|~o))+s[7]+1126891415&4294967295,E=r+(h<<10&4294967295|h>>>22),h=o+(r^(E|~i))+s[14]+2878612391&4294967295,h=i+(E^((o=E+(h<<15&4294967295|h>>>17))|~r))+s[5]+4237533241&4294967295,h=r+(o^((i=o+(h<<21&4294967295|h>>>11))|~E))+s[12]+1700485571&4294967295,h=E+(i^((r=i+(h<<6&4294967295|h>>>26))|~o))+s[3]+2399980690&4294967295,E=r+(h<<10&4294967295|h>>>22),h=o+(r^(E|~i))+s[10]+4293915773&4294967295,h=i+(E^((o=E+(h<<15&4294967295|h>>>17))|~r))+s[1]+2240044497&4294967295,h=r+(o^((i=o+(h<<21&4294967295|h>>>11))|~E))+s[8]+1873313359&4294967295,h=E+(i^((r=i+(h<<6&4294967295|h>>>26))|~o))+s[15]+4264355552&4294967295,E=r+(h<<10&4294967295|h>>>22),h=o+(r^(E|~i))+s[6]+2734768916&4294967295,h=i+(E^((o=E+(h<<15&4294967295|h>>>17))|~r))+s[13]+1309151649&4294967295,h=r+(o^((i=o+(h<<21&4294967295|h>>>11))|~E))+s[4]+4149444226&4294967295,h=E+(i^((r=i+(h<<6&4294967295|h>>>26))|~o))+s[11]+3174756917&4294967295,E=r+(h<<10&4294967295|h>>>22),h=o+(r^(E|~i))+s[2]+718787259&4294967295,h=i+(E^((o=E+(h<<15&4294967295|h>>>17))|~r))+s[9]+3951481745&4294967295,e.g[0]=e.g[0]+r&4294967295,e.g[1]=e.g[1]+(o+(h<<21&4294967295|h>>>11))&4294967295,e.g[2]=e.g[2]+o&4294967295,e.g[3]=e.g[3]+E&4294967295}function t(e,r){this.h=r;const i=[];let s=!0;for(let o=e.length-1;o>=0;o--){const h=0|e[o];s&&h==r||(i[o]=h,s=!1)}this.g=i}!function k(e,r){function c(){}c.prototype=r.prototype,e.F=r.prototype,e.prototype=new c,e.prototype.constructor=e,e.D=function(e,i,s){for(var o=Array(arguments.length-2),h=2;h<arguments.length;h++)o[h-2]=arguments[h];return r.prototype[i].apply(e,o)}}(m,(function l(){this.blockSize=-1})),m.prototype.u=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0},m.prototype.v=function(e,r){void 0===r&&(r=e.length);const i=r-this.blockSize,s=this.C;let o=this.h,h=0;for(;h<r;){if(0==o)for(;h<=i;)n(this,e,h),h+=this.blockSize;if("string"==typeof e){for(;h<r;)if(s[o++]=e.charCodeAt(h++),o==this.blockSize){n(this,s),o=0;break}}else for(;h<r;)if(s[o++]=e[h++],o==this.blockSize){n(this,s),o=0;break}}this.h=o,this.o+=r},m.prototype.A=function(){var e=Array((this.h<56?this.blockSize:2*this.blockSize)-this.h);e[0]=128;for(var r=1;r<e.length-8;++r)e[r]=0;r=8*this.o;for(var i=e.length-8;i<e.length;++i)e[i]=255&r,r/=256;for(this.v(e),e=Array(16),r=0,i=0;i<4;++i)for(let s=0;s<32;s+=8)e[r++]=this.g[i]>>>s&255;return e};var r={};function u(e){return-128<=e&&e<128?function p(e,i){var s=r;return Object.prototype.hasOwnProperty.call(s,e)?s[e]:s[e]=i(e)}(e,(function(e){return new t([0|e],e<0?-1:0)})):new t([0|e],e<0?-1:0)}function v(e){if(isNaN(e)||!isFinite(e))return i;if(e<0)return x(v(-e));const r=[];let s=1;for(let i=0;e>=s;i++)r[i]=e/s|0,s*=4294967296;return new t(r,0)}var i=u(0),s=u(1),h=u(16777216);function C(e){if(0!=e.h)return!1;for(let r=0;r<e.g.length;r++)if(0!=e.g[r])return!1;return!0}function B(e){return-1==e.h}function x(e){const r=e.g.length,i=[];for(let s=0;s<r;s++)i[s]=~e.g[s];return new t(i,~e.h).add(s)}function F(e,r){return e.add(x(r))}function G(e,r){for(;(65535&e[r])!=e[r];)e[r+1]+=e[r]>>>16,e[r]&=65535,r++}function H(e,r){this.g=e,this.h=r}function D(e,r){if(C(r))throw Error("division by zero");if(C(e))return new H(i,i);if(B(e))return r=D(x(e),r),new H(x(r.g),x(r.h));if(B(r))return r=D(e,x(r)),new H(x(r.g),r.h);if(e.g.length>30){if(B(e)||B(r))throw Error("slowDivide_ only works with positive integers.");for(var o=s,h=r;h.l(e)<=0;)o=I(o),h=I(h);var E=J(o,1),T=J(h,1);for(h=J(h,2),o=J(o,2);!C(h);){var V=T.add(h);V.l(e)<=0&&(E=E.add(o),T=V),h=J(h,1),o=J(o,1)}return r=F(e,E.j(r)),new H(E,r)}for(E=i;e.l(r)>=0;){for(o=Math.max(1,Math.floor(e.m()/r.m())),h=(h=Math.ceil(Math.log(o)/Math.LN2))<=48?1:Math.pow(2,h-48),V=(T=v(o)).j(r);B(V)||V.l(e)>0;)V=(T=v(o-=h)).j(r);C(T)&&(T=s),E=E.add(T),e=F(e,V)}return new H(E,e)}function I(e){const r=e.g.length+1,i=[];for(let s=0;s<r;s++)i[s]=e.i(s)<<1|e.i(s-1)>>>31;return new t(i,e.h)}function J(e,r){const i=r>>5;r%=32;const s=e.g.length-i,o=[];for(let h=0;h<s;h++)o[h]=r>0?e.i(h+i)>>>r|e.i(h+i+1)<<32-r:e.i(h+i);return new t(o,e.h)}(e=t.prototype).m=function(){if(B(this))return-x(this).m();let e=0,r=1;for(let i=0;i<this.g.length;i++){const s=this.i(i);e+=(s>=0?s:4294967296+s)*r,r*=4294967296}return e},e.toString=function(e){if((e=e||10)<2||36<e)throw Error("radix out of range: "+e);if(C(this))return"0";if(B(this))return"-"+x(this).toString(e);const r=v(Math.pow(e,6));var i=this;let s="";for(;;){const o=D(i,r).g;let h=(((i=F(i,o.j(r))).g.length>0?i.g[0]:i.h)>>>0).toString(e);if(C(i=o))return h+s;for(;h.length<6;)h="0"+h;s=h+s}},e.i=function(e){return e<0?0:e<this.g.length?this.g[e]:this.h},e.l=function(e){return B(e=F(this,e))?-1:C(e)?0:1},e.abs=function(){return B(this)?x(this):this},e.add=function(e){const r=Math.max(this.g.length,e.g.length),i=[];let s=0;for(let o=0;o<=r;o++){let r=s+(65535&this.i(o))+(65535&e.i(o)),h=(r>>>16)+(this.i(o)>>>16)+(e.i(o)>>>16);s=h>>>16,r&=65535,h&=65535,i[o]=h<<16|r}return new t(i,-2147483648&i[i.length-1]?-1:0)},e.j=function(e){if(C(this)||C(e))return i;if(B(this))return B(e)?x(this).j(x(e)):x(x(this).j(e));if(B(e))return x(this.j(x(e)));if(this.l(h)<0&&e.l(h)<0)return v(this.m()*e.m());const r=this.g.length+e.g.length,s=[];for(var o=0;o<2*r;o++)s[o]=0;for(o=0;o<this.g.length;o++)for(let r=0;r<e.g.length;r++){const i=this.i(o)>>>16,h=65535&this.i(o),E=e.i(r)>>>16,T=65535&e.i(r);s[2*o+2*r]+=h*T,G(s,2*o+2*r),s[2*o+2*r+1]+=i*T,G(s,2*o+2*r+1),s[2*o+2*r+1]+=h*E,G(s,2*o+2*r+1),s[2*o+2*r+2]+=i*E,G(s,2*o+2*r+2)}for(e=0;e<r;e++)s[e]=s[2*e+1]<<16|s[2*e];for(e=r;e<2*r;e++)s[e]=0;return new t(s,0)},e.B=function(e){return D(this,e).h},e.and=function(e){const r=Math.max(this.g.length,e.g.length),i=[];for(let s=0;s<r;s++)i[s]=this.i(s)&e.i(s);return new t(i,this.h&e.h)},e.or=function(e){const r=Math.max(this.g.length,e.g.length),i=[];for(let s=0;s<r;s++)i[s]=this.i(s)|e.i(s);return new t(i,this.h|e.h)},e.xor=function(e){const r=Math.max(this.g.length,e.g.length),i=[];for(let s=0;s<r;s++)i[s]=this.i(s)^e.i(s);return new t(i,this.h^e.h)},m.prototype.digest=m.prototype.A,m.prototype.reset=m.prototype.u,m.prototype.update=m.prototype.v,t.prototype.add=t.prototype.add,t.prototype.multiply=t.prototype.j,t.prototype.modulo=t.prototype.B,t.prototype.compare=t.prototype.l,t.prototype.toNumber=t.prototype.m,t.prototype.toString=t.prototype.toString,t.prototype.getBits=t.prototype.i,t.fromNumber=v,t.fromString=function y(e,r){if(0==e.length)throw Error("number format error: empty string");if((r=r||10)<2||36<r)throw Error("radix out of range: "+r);if("-"==e.charAt(0))return x(y(e.substring(1),r));if(e.indexOf("-")>=0)throw Error('number format error: interior "-" character');const s=v(Math.pow(r,8));let o=i;for(let i=0;i<e.length;i+=8){var h=Math.min(8,e.length-i);const E=parseInt(e.substring(i,i+h),r);h<8?(h=v(Math.pow(r,h)),o=o.j(h).add(v(E))):(o=o.j(s),o=o.add(v(E)))}return o},o=t}).apply(void 0!==h?h:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{}),"function"==typeof SuppressedError&&SuppressedError;class User{constructor(e){this.uid=e}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}User.UNAUTHENTICATED=new User(null),User.GOOGLE_CREDENTIALS=new User("google-credentials-uid"),User.FIRST_PARTY=new User("first-party-uid"),User.MOCK_USER=new User("mock-user");let E="13.2.0-eap-sql.b903ef716";const T=new class Logger{constructor(e){this.name=e,this._logLevel=i,this._logHandler=defaultLogHandler,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(r){if(!(r in e))throw new TypeError(`Invalid value "${r}" assigned to \`logLevel\``);this._logLevel=r}setLogLevel(e){this._logLevel="string"==typeof e?r[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...r){this._userLogHandler&&this._userLogHandler(this,e.DEBUG,...r),this._logHandler(this,e.DEBUG,...r)}log(...r){this._userLogHandler&&this._userLogHandler(this,e.VERBOSE,...r),this._logHandler(this,e.VERBOSE,...r)}info(...r){this._userLogHandler&&this._userLogHandler(this,e.INFO,...r),this._logHandler(this,e.INFO,...r)}warn(...r){this._userLogHandler&&this._userLogHandler(this,e.WARN,...r),this._logHandler(this,e.WARN,...r)}error(...r){this._userLogHandler&&this._userLogHandler(this,e.ERROR,...r),this._logHandler(this,e.ERROR,...r)}}("@firebase/firestore");function a(r,...i){if(T.logLevel<=e.DEBUG){const e=i.map(__PRIVATE_argToString);T.debug(`Firestore (${E}): ${r}`,...e)}}function st(r,...i){if(T.logLevel<=e.ERROR){const e=i.map(__PRIVATE_argToString);T.error(`Firestore (${E}): ${r}`,...e)}}function __PRIVATE_logWarn(r,...i){if(T.logLevel<=e.WARN){const e=i.map(__PRIVATE_argToString);T.warn(`Firestore (${E}): ${r}`,...e)}}function __PRIVATE_argToString(e){if("string"==typeof e)return e;try{return function __PRIVATE_formatJSON(e){return JSON.stringify(e)}(e)}catch(r){return e}}function z(e,r,i){let s="Unexpected state";"string"==typeof r?s=r:i=r,__PRIVATE__fail(e,s,i)}function __PRIVATE__fail(e,r,i){let s=`FIRESTORE (${E}) INTERNAL ASSERTION FAILED: ${r} (ID: ${e.toString(16)})`;if(void 0!==i)try{s+=" CONTEXT: "+JSON.stringify(i)}catch(e){s+=" CONTEXT: "+i}throw st(s),new Error(s)}function __PRIVATE_hardAssert(e,r,i,s){let o="Unexpected state";"string"==typeof i?o=i:s=i,e||__PRIVATE__fail(r,o,s)}function __PRIVATE_debugCast(e,r){return e}const V="ok",P="cancelled",R="unknown",b="invalid-argument",w="deadline-exceeded",S="not-found",O="permission-denied",N="unauthenticated",$="resource-exhausted",U="failed-precondition",L="aborted",M="out-of-range",Q="unimplemented",q="internal",K="unavailable";class k extends FirebaseError{constructor(e,r){super(e,r),this.code=e,this.message=r,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class __PRIVATE_EmptyAuthCredentialsProvider{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,r){e.enqueueRetryable((()=>r(User.UNAUTHENTICATED)))}shutdown(){}}class __PRIVATE_FirstPartyToken{constructor(e,r,i){this.ee=e,this.te=r,this.re=i,this.type="FirstParty",this.user=User.FIRST_PARTY,this.ne=new Map}ie(){return this.re?this.re():null}get headers(){this.ne.set("X-Goog-AuthUser",this.ee);const e=this.ie();return e&&this.ne.set("Authorization",e),this.te&&this.ne.set("X-Goog-Iam-Authorization-Token",this.te),this.ne}}class __PRIVATE_FirstPartyAuthCredentialsProvider{constructor(e,r,i){this.ee=e,this.te=r,this.re=i}getToken(){return Promise.resolve(new __PRIVATE_FirstPartyToken(this.ee,this.te,this.re))}start(e,r){e.enqueueRetryable((()=>r(User.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class DatabaseInfo{constructor(e,r,i,s,o,h,E,T,V,P,R,b,w){this.databaseId=e,this.appId=r,this.persistenceKey=i,this.host=s,this.ssl=o,this.forceLongPolling=h,this.autoDetectLongPolling=E,this.longPollingOptions=T,this.useFetchStreams=V,this.isUsingEmulator=P,this.apiKey=R,this._customHeaders=b,this.grpcFlowControlWindow=w}}const W="(default)";class DatabaseId{constructor(e,r){this.projectId=e,this.database=r||W}static empty(){return new DatabaseId("","")}get isDefaultDatabase(){return this.database===W}isEqual(e){return e instanceof DatabaseId&&e.projectId===this.projectId&&e.database===this.database}}function __PRIVATE_randomBytes(e){const r="undefined"!=typeof self&&(self.crypto||self.msCrypto),i=new Uint8Array(e);if(r&&"function"==typeof r.getRandomValues)r.getRandomValues(i);else for(let r=0;r<e;r++)i[r]=Math.floor(256*Math.random());return i}class __PRIVATE_AutoId{static newId(){const e=62*Math.floor(256/62);let r="";for(;r.length<20;){const i=__PRIVATE_randomBytes(40);for(let s=0;s<i.length;++s)r.length<20&&i[s]<e&&(r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(i[s]%62))}return r}}function __PRIVATE_primitiveComparator(e,r){return e<r?-1:e>r?1:0}function __PRIVATE_compareUtf8Strings(e,r){const i=Math.min(e.length,r.length);for(let s=0;s<i;s++){const i=e.charAt(s),o=r.charAt(s);if(i!==o)return __PRIVATE_isSurrogate(i)===__PRIVATE_isSurrogate(o)?__PRIVATE_primitiveComparator(i,o):__PRIVATE_isSurrogate(i)?1:-1}return __PRIVATE_primitiveComparator(e.length,r.length)}const X=55296,Y=57343;function __PRIVATE_isSurrogate(e){const r=e.charCodeAt(0);return r>=X&&r<=Y}const Z="__name__";class BasePath{constructor(e,r,i){void 0===r?r=0:r>e.length&&z(637,{offset:r,range:e.length}),void 0===i?i=e.length-r:i>e.length-r&&z(1746,{length:i,range:e.length-r}),this.segments=e,this.offset=r,this.len=i}get length(){return this.len}isEqual(e){return 0===BasePath.comparator(this,e)}child(e){const r=this.segments.slice(this.offset,this.limit());return e instanceof BasePath?e.forEach((e=>{r.push(e)})):r.push(e),this.construct(r)}limit(){return this.offset+this.length}popFirst(e){return e=void 0===e?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 0===this.length}isPrefixOf(e){if(e.length<this.length)return!1;for(let r=0;r<this.length;r++)if(this.get(r)!==e.get(r))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let r=0;r<this.length;r++)if(this.get(r)!==e.get(r))return!1;return!0}forEach(e){for(let r=this.offset,i=this.limit();r<i;r++)e(this.segments[r])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,r){const i=Math.min(e.length,r.length);for(let s=0;s<i;s++){const i=BasePath.compareSegments(e.get(s),r.get(s));if(0!==i)return i}return __PRIVATE_primitiveComparator(e.length,r.length)}static compareSegments(e,r){const i=BasePath.isNumericId(e),s=BasePath.isNumericId(r);return i&&!s?-1:!i&&s?1:i&&s?BasePath.extractNumericId(e).compare(BasePath.extractNumericId(r)):__PRIVATE_compareUtf8Strings(e,r)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return o.fromString(e.substring(4,e.length-2))}}class ResourcePath extends BasePath{construct(e,r,i){return new ResourcePath(e,r,i)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toStringWithLeadingSlash(){return`/${this.canonicalString()}`}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const r=[];for(const i of e){if(i.indexOf("//")>=0)throw new k(b,`Invalid segment (${i}). Paths must not contain // in them.`);r.push(...i.split("/").filter((e=>e.length>0)))}return new ResourcePath(r)}static emptyPath(){return new ResourcePath([])}}const ee=/^[_a-zA-Z][_a-zA-Z0-9]*$/;let te=class FieldPath extends BasePath{construct(e,r,i){return new FieldPath(e,r,i)}static isValidIdentifier(e){return ee.test(e)}canonicalString(){return this.toArray().map((e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),FieldPath.isValidIdentifier(e)||(e="`"+e+"`"),e))).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&this.get(0)===Z}static keyField(){return new FieldPath([Z])}static fromServerFormat(e){const r=[];let i="",s=0;const __PRIVATE_addCurrentSegment=()=>{if(0===i.length)throw new k(b,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);r.push(i),i=""};let o=!1;for(;s<e.length;){const r=e[s];if("\\"===r){if(s+1===e.length)throw new k(b,"Path has trailing escape character: "+e);const r=e[s+1];if("\\"!==r&&"."!==r&&"`"!==r)throw new k(b,"Path has invalid escape sequence: "+e);i+=r,s+=2}else"`"===r?(o=!o,s++):"."!==r||o?(i+=r,s++):(__PRIVATE_addCurrentSegment(),s++)}if(__PRIVATE_addCurrentSegment(),o)throw new k(b,"Unterminated ` in path: "+e);return new FieldPath(r)}static emptyPath(){return new FieldPath([])}};class C{constructor(e){this.path=e}static fromPath(e){return new C(ResourcePath.fromString(e))}static fromName(e){return new C(ResourcePath.fromString(e).popFirst(5))}static empty(){return new C(ResourcePath.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 null!==e&&0===ResourcePath.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,r){return ResourcePath.comparator(e.path,r.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new C(new ResourcePath(e.slice()))}}function __PRIVATE_validateNonEmptyArgument(e,r,i){if(!i)throw new k(b,`Function ${e}() cannot be called with an empty ${r}.`)}function __PRIVATE_validateDocumentPath(e){if(!C.isDocumentKey(e))throw new k(b,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function __PRIVATE_isPlainObject(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}function __PRIVATE_valueDescription(e){if(void 0===e)return"undefined";if(null===e)return"null";if("string"==typeof e)return e.length>20&&(e=`${e.substring(0,20)}...`),JSON.stringify(e);if("number"==typeof e||"boolean"==typeof e)return""+e;if("object"==typeof e){if(e instanceof Array)return"an array";{const r=function __PRIVATE_tryGetCustomObjectType(e){return e.constructor?e.constructor.name:null}(e);return r?`a custom ${r} object`:"an object"}}return"function"==typeof e?"a function":z(12329,{type:typeof e})}function __PRIVATE_cloneLongPollingOptions(e){const r={};return void 0!==e.timeoutSeconds&&(r.timeoutSeconds=e.timeoutSeconds),r}let re=null;function __PRIVATE_isNegativeZero(e){return 0===e&&1/e==-1/0}function __PRIVATE_isNumber(e){return"number"==typeof e}function __PRIVATE_isString(e){return"string"==typeof e}const ne="RestConnection",ie={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery",ExecutePipeline:"executePipeline"};class __PRIVATE_RestConnection{get ae(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const r=e.ssl?"https":"http",i=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.ue=r+"://"+e.host,this._e=`projects/${i}/databases/${s}`,this.ce=this.databaseId.database===W?`project_id=${i}`:`project_id=${i}&database_id=${s}`}le(e,r,i,s,o){const h=function __PRIVATE_generateUniqueDebugId(){return null===re?re=function __PRIVATE_generateInitialUniqueDebugId(){return 268435456+Math.round(2147483648*Math.random())}():re++,"0x"+re.toString(16)}(),E=this.fe(e,r.toUriEncodedString());a(ne,`Sending RPC '${e}' ${h}:`,E,i);const T={"google-cloud-resource-prefix":this._e,"x-goog-request-params":this.ce};this.he(T,s,o);const{host:V}=new URL(E),P=function isCloudWorkstation(e){try{return(e.startsWith("http://")||e.startsWith("https://")?new URL(e).hostname:e).endsWith(".cloudworkstations.dev")}catch{return!1}}(V);return this.de(e,E,T,i,P).then((r=>(a(ne,`Received RPC '${e}' ${h}: `,r),r)),(r=>{throw __PRIVATE_logWarn(ne,`RPC '${e}' ${h} failed with error: `,r,"url: ",E,"request:",i),r}))}me(e,r,i,s,o,h){return this.le(e,r,i,s,o)}he(e,r,i){if(e["X-Goog-Api-Client"]=function __PRIVATE_getGoogApiClientValue(){return"gl-js/ fire/"+E}(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),r&&r.headers.forEach(((r,i)=>e[i]=r)),i&&i.headers.forEach(((r,i)=>e[i]=r)),this.databaseInfo._customHeaders)for(const r of Object.keys(this.databaseInfo._customHeaders))e[r]=this.databaseInfo._customHeaders[r]}fe(e,r){const i=ie[e];let s=`${this.ue}/v1/${r}:${i}`;return this.databaseInfo.apiKey&&(s=`${s}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),s}terminate(){}}var se,ae,oe,ue,le,_e,ce,pe;function __PRIVATE_mapCodeFromHttpStatus(e){if(void 0===e)return st("RPC_ERROR","HTTP error has no status"),R;switch(e){case 200:return V;case 400:return U;case 401:return N;case 403:return O;case 404:return S;case 409:return L;case 416:return M;case 429:return $;case 499:return P;case 500:return R;case 501:return Q;case 503:return K;case 504:return w;default:return e>=200&&e<300?V:e>=400&&e<500?U:e>=500&&e<600?q:R}}(ae=se||(se={}))[ae.OK=0]="OK",ae[ae.CANCELLED=1]="CANCELLED",ae[ae.UNKNOWN=2]="UNKNOWN",ae[ae.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",ae[ae.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",ae[ae.NOT_FOUND=5]="NOT_FOUND",ae[ae.ALREADY_EXISTS=6]="ALREADY_EXISTS",ae[ae.PERMISSION_DENIED=7]="PERMISSION_DENIED",ae[ae.UNAUTHENTICATED=16]="UNAUTHENTICATED",ae[ae.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",ae[ae.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",ae[ae.ABORTED=10]="ABORTED",ae[ae.OUT_OF_RANGE=11]="OUT_OF_RANGE",ae[ae.UNIMPLEMENTED=12]="UNIMPLEMENTED",ae[ae.INTERNAL=13]="INTERNAL",ae[ae.UNAVAILABLE=14]="UNAVAILABLE",ae[ae.DATA_LOSS=15]="DATA_LOSS";class __PRIVATE_FetchConnection extends __PRIVATE_RestConnection{Ee(e,r){throw new Error("Not supported by FetchConnection")}async de(e,r,i,s,o){const h=JSON.stringify(s);let E;try{const e={method:"POST",headers:i,body:h};o&&(e.credentials="include"),E=await fetch(r,e)}catch(e){const r=e,i=r?.message,s=r?.cause?String(r.cause):void 0,o=(i&&s?`${i} (${s})`:i??s)??r?.statusText??String(e);throw new k(__PRIVATE_mapCodeFromHttpStatus(r?.status),`Request failed with error: ${o}`)}if(!E.ok){let e=await E.json();Array.isArray(e)&&(e=e[0]);const r=e?.error?.message;throw new k(__PRIVATE_mapCodeFromHttpStatus(E.status),`Request failed with error: ${r??E.statusText}`)}return E.json()}}class __PRIVATE_Base64DecodeError extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class ByteString{constructor(e){this.binaryString=e}static fromBase64String(e){const r=function __PRIVATE_decodeBase64(e){try{return atob(e)}catch(e){throw"undefined"!=typeof DOMException&&e instanceof DOMException?new __PRIVATE_Base64DecodeError("Invalid base64 string: "+e):e}}(e);return new ByteString(r)}static fromUint8Array(e){const r=function __PRIVATE_binaryStringFromUint8Array(e){let r="";for(let i=0;i<e.length;++i)r+=String.fromCharCode(e[i]);return r}(e);return new ByteString(r)}[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 __PRIVATE_encodeBase64(e){return btoa(e)}(this.binaryString)}toUint8Array(){return function __PRIVATE_uint8ArrayFromBinaryString(e){const r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i);return r}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return __PRIVATE_primitiveComparator(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}function __PRIVATE_objectSize(e){let r=0;for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&r++;return r}function forEach(e,r){for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&r(i,e[i])}ByteString.EMPTY_BYTE_STRING=new ByteString("");class __PRIVATE_QuadrupleBuilder{constructor(){this.exponent=0,this.Ve=0n,this.Te=0n,this.Ie=new Array(4).fill(0n),this.Ae=new Array(6).fill(0n),this.Re=new Array(6).fill(0n),this.Pe=new Array(6).fill(0n),this.pe=new Array(12).fill(0n)}static ye(e,r){let i=new __PRIVATE_QuadrupleBuilder;return i.parse(e,r),i}parse(e,r){r+=e.length-1,this.exponent=0,this.Ve=0n,this.Te=0n;let i=this.Pe,s=this.be(e,i);if(0==s&&this.isEmpty(i))return;if((r+=s)<__PRIVATE_QuadrupleBuilder.we)return;if(r>__PRIVATE_QuadrupleBuilder.ge)return void(this.exponent=Number(__PRIVATE_QuadrupleBuilder.Fe));let o=this.ve(r,i);this.xe(r,o,i)}be(e,r){for(let e=0;e<6;e++)r[e]=0n;let i=0;for(;i<e.length&&0==e[i];)i+=1;if(i==e.length)return 0;let s=-i;if(e.length-i>__PRIVATE_QuadrupleBuilder.De){let r=e[__PRIVATE_QuadrupleBuilder.De]>=5,o=new Array(__PRIVATE_QuadrupleBuilder.De).fill(0);for(let r=0;r<__PRIVATE_QuadrupleBuilder.De;r++)o[r]=e[r+i];r&&(s+=this.Ne(o)),e=o,i=0}for(let s=e.length-1;s>=i;s--)r[0]|=BigInt(e[s])<<32n,this.Se(r);return s}Se(e){let r=e.length;for(let i=0;i<r;i++){let s=e[i]%10n;e[i]=e[i]/10n,i+1<r&&(e[i+1]+=s<<32n)}}isEmpty(e){for(let r=0;r<e.length;r++)if(0n!=e[r])return!1;return!0}Ne(e){for(let r=e.length-1;r>=0;r--){if(9!=e[r])return e[r]=e[r]+1,0;e[r]=0}return e[0]=1,1}ve(e,r){let i=r[0]<<31n|r[1]>>1n,s=Number(i)/__PRIVATE_QuadrupleBuilder.Ce;return Math.floor(Number(e)*__PRIVATE_QuadrupleBuilder.Be+this.log2(s))}log2(e){return __PRIVATE_QuadrupleBuilder.Qe*Math.log(e)}xe(e,r,i){let s=this.Ie;this.Oe(-r,s);let o=this.pe;this.Me(i,s,o),this.qe(o),BigInt(s[0])!=BigInt(-e)&&this.qe(o),r+=this.Le(o),(r+=__PRIVATE_QuadrupleBuilder.Ue)<=0||(r+=this.$e(o),BigInt(r)>=__PRIVATE_QuadrupleBuilder.Fe?this.exponent=Number(__PRIVATE_QuadrupleBuilder.Fe):(this.exponent=Number(r),this.Ve=(o[0]<<32n)+o[1]&0xffffffffffffffffn,this.Te=(o[2]<<32n)+o[3]&0xffffffffffffffffn))}Oe(e,r){if(0==e)return void this.ke(__PRIVATE_QuadrupleBuilder.je[0],r);let i=__PRIVATE_QuadrupleBuilder.je;e<0&&(e=-e,i=__PRIVATE_QuadrupleBuilder.Ke);let s=__PRIVATE_QuadrupleBuilder.ze,o=32,h=!0;for(;e>0;)e>=s&&(h?(this.ke(i[o],r),h=!1):this.We(r,i[o],r),e-=s),o-=1,s*=.5}ke(e,r){for(let i=0;i<r.length;i++)r[i]=e[i]}We(e,r,i){this.Ge(e,r,this.pe);let s=this.Je(this.pe);this.He(this.pe,i),i[0]=e[0]+r[0]+BigInt(s)}Ge(e,r,i){for(let e=0;e<i.length;e++)i[e]=0n;this.Ye(e,this.Ae),this.Ye(r,this.Re);for(let e=5;e>=0;e--)for(let r=5;r>=0;r--){let s=this.Ae[e]*this.Re[r];i[r+e+1]=i[r+e+1]+(s&__PRIVATE_QuadrupleBuilder.Xe)&0xffffffffffffffffn,i[r+e]=i[r+e]+(s>>32n)&0xffffffffffffffffn}for(let e=11;e>=1;e--)i[e-1]=i[e-1]+(i[e]>>32n)&0xffffffffffffffffn,i[e]&=__PRIVATE_QuadrupleBuilder.Xe}Je(e){let r=0;for(;this.Ze(e);)this.qe(e),r-=1;return r}Ze(e){if(e[0]<0x19999999n)return!0;if(e[0]>0x19999999n)return!1;for(let r=1;r<e.length;r++){if(e[r]<0x99999999n)return!0;if(e[r]>0x99999999n)return!1}return!1}Me(e,r,i){for(let e=0;e<i.length;e++)i[e]=0n;let s=this.Re;this.Ye(r,s);let o=e.length;for(let r=o-1;r>=0;r--)for(let h=o-1;h>=0;h--){let o=e[r]*s[h];i[h+r+1]=i[h+r+1]+(o&__PRIVATE_QuadrupleBuilder.Xe)&0xffffffffffffffffn,i[h+r]=i[h+r]+(o>>32n)&0xffffffffffffffffn}for(let e=11;e>=1;e--)i[e-1]=i[e-1]+(i[e]>>32n)&0xffffffffffffffffn,i[e]&=__PRIVATE_QuadrupleBuilder.Xe}qe(e){let r=e.length-1;e[0]&=__PRIVATE_QuadrupleBuilder.Xe,e[r]*=10n;for(let i=r-1;i>=0;i--)e[i]=10n*e[i]+(e[i+1]>>32n)&0xffffffffffffffffn,e[i+1]&=__PRIVATE_QuadrupleBuilder.Xe}Le(e){let r=31-__PRIVATE_QuadrupleBuilder.et(e[0]);return 0!=r&&this.tt(e,r),r}$e(e){return this.rt(e,5,100n),this.rt(e,4,0x80000000n),0n!=(e[0]&__PRIVATE_QuadrupleBuilder.nt<<1n)?(this.tt(e,1),1):0}He(e,r){r[1]=(e[0]<<32n)+e[1],r[2]=(e[2]<<32n)+e[3],r[3]=(e[4]<<32n)+e[5]}Ye(e,r){r[0]=e[1]>>32n,r[1]=e[1]&__PRIVATE_QuadrupleBuilder.Xe,r[2]=e[2]>>32n,r[3]=e[2]&__PRIVATE_QuadrupleBuilder.Xe,r[4]=e[3]>>32n,r[5]=e[3]&__PRIVATE_QuadrupleBuilder.Xe}tt(e,r){let i=e.length-1,s=BigInt(32-Math.abs(r));if(r>0){let o=BigInt(r);for(let r=i+1-1;r>=1;r--)e[r]=e[r]>>o|e[r-1]<<s&__PRIVATE_QuadrupleBuilder.Xe;e[0]=e[0]>>o}else if(r<0){let o=BigInt(-r);e[0]=0xffffffffffffffffn&(e[0]<<o|e[1]>>s);for(let r=1;r<i;r++)e[r]=0xffffffffffffffffn&(e[r]<<o&__PRIVATE_QuadrupleBuilder.Xe|e[r+1]>>s);e[i]=e[i]<<o&__PRIVATE_QuadrupleBuilder.Xe}}rt(e,r,i){let s=r;e[s]=e[s]+i&0xffffffffffffffffn;for(let r=s+1-1;r>=1&&0n!=(e[r]&__PRIVATE_QuadrupleBuilder.nt);r--)e[r]&=__PRIVATE_QuadrupleBuilder.Xe,e[r-1]+=1n}static et(e){let r=Number(e>>32n);return 0==r?32+Math.clz32(Number(BigInt.asUintN(32,e))):Math.clz32(r)}}__PRIVATE_QuadrupleBuilder.De=59,__PRIVATE_QuadrupleBuilder.ge=646456993,__PRIVATE_QuadrupleBuilder.we=-646457032,__PRIVATE_QuadrupleBuilder.Ce=0xccccccccccccd00,__PRIVATE_QuadrupleBuilder.it=0x8000000000000000n,__PRIVATE_QuadrupleBuilder.ze=2147483648,__PRIVATE_QuadrupleBuilder.Xe=0x00000000ffffffffn,__PRIVATE_QuadrupleBuilder.nt=0xffffffff00000000n,__PRIVATE_QuadrupleBuilder.Be=Math.log(10)/Math.log(2),__PRIVATE_QuadrupleBuilder.Qe=1/Math.log(2),__PRIVATE_QuadrupleBuilder.Ue=2147483647,__PRIVATE_QuadrupleBuilder.Fe=0xffffffffn,__PRIVATE_QuadrupleBuilder.je=[[1n,0x1999999999999999n,0x9999999999999999n,0x999999999999999an],[1n,0x3333333333333333n,0x3333333333333333n,0x3333333333333334n],[1n,0x6666666666666666n,0x6666666666666666n,0x6666666666666667n],[2n,0x28f5c28f5c28f5c2n,0x8f5c28f5c28f5c28n,0xf5c28f5c28f5c290n],[3n,0x4189374bc6a7ef9dn,0xb22d0e5604189374n,0xbc6a7ef9db22d0e6n],[5n,0xa7c5ac471b478423n,0x0fcf80dc33721d53n,0xcddd6e04c0592104n],[10n,0x6df37f675ef6eadfn,0x5ab9a2072d44268dn,0x97df837e6748956en],[20n,0x2f394219248446ban,0xa23d2ec729af3d61n,0x0607aa0167dd94cbn],[39n,0x571cbec554b60dbbn,0xd5f64baf0506840dn,0x451db70d5904029bn],[78n,0x1da48ce468e7c702n,0x6520247d3556476dn,0x1469caf6db224cfan],[155n,0x2252f0e5b39769dcn,0x9ae2eea30ca3ade0n,0xeeaa3c08dfe84e30n],[309n,0x2e055c9a3f6ba793n,0x16583a816eb60a59n,0x22c4b0826cf1ebf7n],[617n,0x52bb45e9cf23f17fn,0x7688c07606e50364n,0xb34479aa9d449a57n],[1234n,0x1abc81c8ff5f846cn,0x8f5e3c9853e38c97n,0x45060097f3bf9296n],[2467n,0x1bec53b510daa7b4n,0x48369ed77dbb0eb1n,0x3b05587b2187b41en],[4933n,0x1e75063a5ba91326n,0x8abfb8e460016ae3n,0x28008702d29e8a3cn],[9865n,0x243c5d8bb5c5fa55n,0x40c6d248c5881915n,0x4c0fd99fd5befc22n],[19729n,0x334a5570c3f4ef3cn,0xa13c36c43f979c90n,0xda7ac473555fb7a8n],[39457n,0x66c304445dd98f3bn,0xa8c293a20e47a41bn,0x4c5b03dc12604964n],[78914n,0x293ffbf5fb028cc4n,0x89d3e5ff44238406n,0x369a339e1bfe8c9bn],[157827n,0x427792fbb68e5d20n,0x7b297cd9fc154b62n,0xf09142114aa9a20cn],[315653n,0xac92bc65ad5c08fcn,0x00beeb115a566c19n,0x4ba882d8a4622437n],[631306n,0x745581440f92e80en,0x4da822cf7f896f41n,0x509d598678164ecdn],[1262612n,0x34dd99b4c69523a5n,0x64bc2e8f0d8b1044n,0xb03b1c96da5dd349n],[2525223n,0x6d2bbea9d6d25a08n,0xa0a4606a88e96b70n,0x182063bbc2fe8520n],[5050446n,0x2e8e47d63bfdd6e3n,0x2b55fa8976eaa3e9n,0x1a6b9d3086412a73n],[10100891n,0x54aa68efa1d719dfn,0xd8505806612c5c8fn,0xad068837fee8b43an],[20201782n,0x1c00464ccb7bae77n,0x9e3877784c77982cn,0xd94af3b61717404fn],[40403563n,0x1ea099c8be2b6cd0n,0x8bfb6d539fa50466n,0x6d3bc37e69a84218n],[80807125n,0x24a457f466ce8d18n,0xf2c8f3b81bc6bb59n,0xa78c757692e02d49n],[161614249n,0x347256677aba6b53n,0x3fbf90d30611a67cn,0x1e039d87e0bdb32bn],[323228497n,0x6b727daf0fd3432an,0x71f71121f9e4200fn,0x8fcd9942d486c10cn],[646456994n,0x2d18e84484d91f78n,0x4079bfe7829dec6fn,0x21551643e365abc6n]],__PRIVATE_QuadrupleBuilder.Ke=[[1n,0x1999999999999999n,0x9999999999999999n,0x999999999999999an],[0n,0x8000000000000000n,0x0000000000000000n,0x0000000000000000n],[0n,0x4000000000000000n,0x0000000000000000n,0x0000000000000001n],[-1n,0xa000000000000000n,0x0000000000000000n,0x0000000000000000n],[-2n,0x6400000000000000n,0x0000000000000000n,0x0000000000000000n],[-4n,0x2710000000000000n,0x0000000000000000n,0x0000000000000001n],[-9n,0x3b9aca0000000000n,0x0000000000000000n,0x0000000000000001n],[-19n,0x8ac7230489e80000n,0x0000000000000000n,0x0000000000000000n],[-38n,0x4b3b4ca85a86c47an,0x098a224000000000n,0x0000000000000001n],[-77n,0xdd15fe86affad912n,0x49ef0eb713f39eben,0xaa987b6e6fd2a002n],[-154n,0xbeeefb584aff8603n,0xaafb550ffacfd8fan,0x5ca47e4f88d45371n],[-308n,0x8e679c2f5e44ff8fn,0x570f09eaa7ea7648n,0x5961db50c6d2b888n],[-616n,0x4f371b3399fc2ab0n,0x8170041c9feb05aan,0xc7c343447c75bcf6n],[-1233n,0xf51e928179013fd3n,0xde4bd12cde4d985cn,0x4a573ca6f94bff14n],[-2466n,0xeab388127bccaff7n,0x1667639142b9fbaen,0x775ec9995e1039fbn],[-4932n,0xd72cb2a95c7ef6ccn,0xe81bf1e825ba7515n,0xc2feb521d6cb5dcdn],[-9864n,0xb4dc1be6604502dcn,0xd491079b8eef6535n,0x578d3965d24de84dn],[-19728n,0x7fc6447bee60ea43n,0x2548da5c8b125b27n,0x5f42d1142f41d349n],[-39456n,0x3fc65180f88af8fbn,0x6a6915f383349413n,0x063c3708b6ceb291n],[-78913n,0x9ee0197c8dcd55bfn,0x2b2b9b942c38f4a2n,0x0f8ba634e9c706aen],[-157826n,0x629963a25b8b2d79n,0xd00b9d2286f70876n,0xe97004700c3644fcn],[-315652n,0x25f9cc308ceef4f3n,0x40f19543911a4546n,0xa2cd389452cfc366n],[-631305n,0x385597b0d47e76b8n,0x1b9f67e103bf2329n,0xc3119848595985f7n],[-1262611n,0x7bf795d276c12f66n,0x66a61d62a446659an,0xa1a4d73bebf093d5n],[-2525222n,0x3c07d96ab1ed7799n,0xcb7355c22cc05ac0n,0x4ffc0ab73b1f6a49n],[-5050445n,0x8cc4cd8c3edefb9an,0x6c8ff86a90a97e0cn,0x166cfddbf98b71bfn],[-10100890n,0x4d67d81cc88e1228n,0x1d7cfb06666b79b3n,0x7b916728aaa4e70dn],[-20201781n,0xea0c55494e7a552dn,0xb88cb9484bb86c61n,0x8d44893c610bb7dfn],[-40403562n,0xd5fa8c821ec0c24an,0xa80e46e764e0f8b0n,0xa7276bfa432fac7en],[-80807124n,0xb2dae307426f6791n,0xc970b82f58b12918n,0x0472592f7f39190en],[-161614248n,0x7cf51edd8a15f1c9n,0x656dab3498f8e697n,0x12daa2a80e53c807n],[-323228496n,0x3cfe609ab5883c50n,0xbec8b5d22b198871n,0xe18477703b4622b4n],[-646456993n,0x9152447b9d7cda9an,0x3b4d3f6110d77aadn,0xfa81bad1c394adb4n]];class __PRIVATE_Quadruple{constructor(e,r,i,s){this.negative=e,this.st=r,this.Ve=i,this.Te=s}exponent(){return this.st-__PRIVATE_QuadrupleBuilder.Ue}ot(){return 0===this.st&&0n===this.Ve&&0n===this.Te}ut(){return this.st===__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"f",ue)&&0n===this.Ve&&0n===this.Te}isNaN(){return this.st===__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"f",ue)&&!(0n===this.Ve&&0n===this.Te)}compareTo(e){if(this.isNaN())return e.isNaN()?0:1;if(e.isNaN())return-1;let r,i;if(this.negative){if(!e.negative)return-1;r=1,i=-1}else{if(e.negative)return 1;r=-1,i=1}return this.st<e.st?r:this.st>e.st?i:this.Ve<e.Ve?r:this.Ve>e.Ve?i:this.Te<e.Te?r:this.Te>e.Te?i:0}debug(){return(this.negative?"+":"-")+__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",le).call(__PRIVATE_Quadruple,this.Ve)+__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",le).call(__PRIVATE_Quadruple,this.Te)+"*2^"+this.exponent()}static fromNumber(e){if(isNaN(e))return __PRIVATE_Quadruple.NaN;if(!isFinite(e))return e<0?__PRIVATE_Quadruple._t:__PRIVATE_Quadruple.ct;if(0===e)return Math.sign(1/e)>0?__PRIVATE_Quadruple.lt:__PRIVATE_Quadruple.ft;const r=new DataView(new ArrayBuffer(8));r.setFloat64(0,e);const i=r.getBigUint64(0);let s=BigInt.asUintN(64,i<<12n),o=2047&Number(i>>52n);if(0===o){const e=__PRIVATE_QuadrupleBuilder.et(s);s=e<63?s<<BigInt(e+1):0n,o=-e}return new __PRIVATE_Quadruple(e<0,__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",pe).call(__PRIVATE_Quadruple,o-1023),s,0n)}static fromString(e){if("NaN"===e)return __PRIVATE_Quadruple.NaN;if("-Infinity"===e)return __PRIVATE_Quadruple._t;if("Infinity"===e||"+Infinity"===e)return __PRIVATE_Quadruple.ct;const r=new Array(e.length).fill(0);let i=0,s=0,o=0,h=!1;for("-"===e[i]?(h=!0,i++):"+"===e[i]&&i++;__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",_e).call(__PRIVATE_Quadruple,e,i);)r[s++]=__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",ce).call(__PRIVATE_Quadruple,e,i++);if("."===e[i]){const h=++i;for(;__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",_e).call(__PRIVATE_Quadruple,e,i);)r[s++]=__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",ce).call(__PRIVATE_Quadruple,e,i++);o=h-i}if("e"===e[i]||"E"===e[i]){let r=0;i++;let s=1;"-"===e[i]?(s=-1,i++):"+"===e[i]&&i++;const h=i;for(;__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",_e).call(__PRIVATE_Quadruple,e,i);)if(r=10*r+__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",ce).call(__PRIVATE_Quadruple,e,i++),i-h>9)throw new Error("Exponent too large "+e);if(i===h)throw new Error("Invalid number "+e);o+=r*s}if(0===s||i!==e.length)throw new Error("Invalid number "+e);const E=__PRIVATE_QuadrupleBuilder.ye(r.slice(0,s),o);return new __PRIVATE_Quadruple(h,E.exponent,E.Ve,E.Te)}}oe=__PRIVATE_Quadruple,le=function ___PRIVATE_Quadruple_hex(e){return e.toString(16).padStart(16,"0")},_e=function ___PRIVATE_Quadruple_isDigit(e,r){const i=e.codePointAt(r);return void 0!==i&&i>=48&&i<=57},ce=function ___PRIVATE_Quadruple_digit(e,r){return e.codePointAt(r)-48},pe=function ___PRIVATE_Quadruple_bias(e){return e+__PRIVATE_QuadrupleBuilder.Ue},ue={value:Number(__PRIVATE_QuadrupleBuilder.Fe)},__PRIVATE_Quadruple.lt=new __PRIVATE_Quadruple(!1,0,0n,0n),__PRIVATE_Quadruple.ft=new __PRIVATE_Quadruple(!0,0,0n,0n),__PRIVATE_Quadruple.NaN=new __PRIVATE_Quadruple(!1,__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"f",ue),1n<<63n,0n),__PRIVATE_Quadruple._t=new __PRIVATE_Quadruple(!0,__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"f",ue),0n,0n),__PRIVATE_Quadruple.ct=new __PRIVATE_Quadruple(!1,__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"f",ue),0n,0n),new __PRIVATE_Quadruple(!0,__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",pe).call(__PRIVATE_Quadruple,63),0n,0n),new __PRIVATE_Quadruple(!1,__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",pe).call(__PRIVATE_Quadruple,0),0n,0n),new __PRIVATE_Quadruple(!0,__classPrivateFieldGet(__PRIVATE_Quadruple,oe,"m",pe).call(__PRIVATE_Quadruple,0),0n,0n);const de=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function __PRIVATE_normalizeTimestamp(e){if(__PRIVATE_hardAssert(!!e,39018),"string"==typeof e){let r=0;const i=de.exec(e);if(__PRIVATE_hardAssert(!!i,46558,{timestamp:e}),i[1]){let e=i[1];e=(e+"000000000").substr(0,9),r=Number(e)}const s=new Date(e);return{seconds:Math.floor(s.getTime()/1e3),nanos:r}}return{seconds:__PRIVATE_normalizeNumber(e.seconds),nanos:__PRIVATE_normalizeNumber(e.nanos)}}function __PRIVATE_normalizeNumber(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function __PRIVATE_normalizeByteString(e){return"string"==typeof e?ByteString.fromBase64String(e):ByteString.fromUint8Array(e)}function property(e,r){const i={typeString:e};return r&&(i.value=r),i}function __PRIVATE_validateJSON(e,r){if(!__PRIVATE_isPlainObject(e))throw new k(b,"JSON must be an object");let i;for(const s in r)if(r[s]){const o=r[s].typeString,h="value"in r[s]?{value:r[s].value}:void 0,E=r[s].optional;if(!(s in e)){if(E)continue;i=`JSON missing required field: '${s}'`;break}const T=e[s];if(o&&typeof T!==o){i=`JSON field '${s}' must be a ${o}.`;break}if(void 0!==h&&T!==h.value){i=`Expected '${s}' field to equal '${h.value}'`;break}}if(i)throw new k(b,i);return!0}const fe=-62135596800,he=1e6;class Timestamp{static now(){return Timestamp.fromMillis(Date.now())}static fromDate(e){return Timestamp.fromMillis(e.getTime())}static fromMillis(e){const r=Math.floor(e/1e3),i=Math.floor((e-1e3*r)*he);return new Timestamp(r,i)}static fromInstant(e){if(!e||"bigint"!=typeof e.ht)throw new k(b,"Invalid Temporal.Instant object provided.");return Timestamp._fromEpochNanoseconds(e.ht)}static _fromEpochNanoseconds(e){let r,i;if(e>=0n)r=Number(e/1000000000n),i=Number(e%1000000000n);else{const s=e%1000000000n;0n===s?(r=Number(e/1000000000n),i=0):(r=Number(e/1000000000n-1n),i=Number(s+1000000000n))}return new Timestamp(r,i)}constructor(e,r){if(this.seconds=e,this.nanoseconds=r,r<0)throw new k(b,"Timestamp nanoseconds out of range: "+r);if(r>=1e9)throw new k(b,"Timestamp nanoseconds out of range: "+r);if(e<fe)throw new k(b,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new k(b,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/he}toInstant(){if("undefined"==typeof Temporal||!Temporal.Instant)throw new k(U,"The Temporal object is not available in the current environment.");const e=1000000000n*BigInt(this.seconds)+BigInt(this.nanoseconds);return Temporal.Instant.__PRIVATE_fromEpochNanoseconds(e)}_compareTo(e){return this.seconds===e.seconds?__PRIVATE_primitiveComparator(this.nanoseconds,e.nanoseconds):__PRIVATE_primitiveComparator(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{type:Timestamp._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(__PRIVATE_validateJSON(e,Timestamp._jsonSchema))return new Timestamp(e.seconds,e.nanoseconds)}valueOf(){const e=this.seconds-fe;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}function __PRIVATE_getPreviousValue(e){const r=e.mapValue.fields.__previous_value__;return function __PRIVATE_isServerTimestamp(e){const r=(e?.mapValue?.fields||{}).__type__?.stringValue;return"server_timestamp"===r}(r)?__PRIVATE_getPreviousValue(r):r}function __PRIVATE_getLocalWriteTime(e){const r=__PRIVATE_normalizeTimestamp(e.mapValue.fields.__local_write_time__.timestampValue);return new Timestamp(r.seconds,r.nanos)}Timestamp._jsonSchemaVersion="firestore/timestamp/1.0",Timestamp._jsonSchema={type:property("string",Timestamp._jsonSchemaVersion),seconds:property("number"),nanoseconds:property("number")};const me="__type__",Ee="__vector__",Te="value",ge="server_timestamp",Ve="__min__",Pe="__max__",Ae="__regex__",Ie="pattern",Re="options",xe="__oid__",ye="__int__",be="__decimal128__",ve="__request_timestamp__",we="seconds",Se="increment",De="__binary__",Fe={};var Oe,Ne;(Ne=Oe||(Oe={})).dt="regexValue",Ne.Et="bsonObjectIdValue",Ne.Vt="int32Value",Ne.Tt="decimal128Value",Ne.It="bsonTimestampValue",Ne.At="bsonBinaryValue",Ne.Rt="minKeyValue",Ne.Pt="maxKeyValue",Ne.yt="maxValue",Ne.bt="vectorValue",Ne.wt="serverTimestampValue",Ne.gt="regularMapValue";const $e={[Ee]:Oe.bt,[Pe]:Oe.yt,[ge]:Oe.wt},Ue={[Ae]:Oe.dt,[xe]:Oe.Et,[ye]:Oe.Vt,[be]:Oe.Tt,[ve]:Oe.It,[De]:Oe.At,[Ve]:Oe.Rt,[Pe]:Oe.Pt};function __PRIVATE_typeOrder(e){if("nullValue"in e)return 0;if("booleanValue"in e)return 2;if("integerValue"in e||"doubleValue"in e)return 3;if("timestampValue"in e)return 4;if("stringValue"in e)return 7;if("bytesValue"in e)return 8;if("referenceValue"in e)return 9;if("geoPointValue"in e)return 11;if("arrayValue"in e)return 13;if(!("mapValue"in e))return z(28295,{value:e});{const r=function __PRIVATE_detectMapRepresentation(e){if(!e.mapValue?.fields)return Oe.gt;const r=e.mapValue.fields,i=r[me]?.stringValue;if(i&&$e[i])return $e[i];if(1===__PRIVATE_objectSize(r)){const e=Object.keys(r);return Ue[e[0]]??Oe.gt}return Oe.gt}(e);switch(r){case Oe.wt:return 6;case Oe.yt:return 9007199254740991;case Oe.bt:return 14;case Oe.dt:return 12;case Oe.Et:return 10;case Oe.Vt:case Oe.Tt:return 3;case Oe.It:return 5;case Oe.At:return 8;case Oe.Rt:return 1;case Oe.Pt:return 16;default:return 15}}}function __PRIVATE_valueEquals(e,r,i){if(e===r)return!0;const s=__PRIVATE_typeOrder(e);if(s!==__PRIVATE_typeOrder(r))return!1;switch(s){case 0:case 9007199254740991:case 16:case 1:return!0;case 2:return e.booleanValue===r.booleanValue;case 6:return __PRIVATE_getLocalWriteTime(e).isEqual(__PRIVATE_getLocalWriteTime(r));case 4:return function __PRIVATE_timestampEquals(e,r){if("string"==typeof e.timestampValue&&"string"==typeof r.timestampValue&&e.timestampValue.length===r.timestampValue.length)return e.timestampValue===r.timestampValue;const i=__PRIVATE_normalizeTimestamp(e.timestampValue),s=__PRIVATE_normalizeTimestamp(r.timestampValue);return i.seconds===s.seconds&&i.nanos===s.nanos}(e,r);case 7:return e.stringValue===r.stringValue;case 8:return function __PRIVATE_blobEquals(e,r){return 0===__PRIVATE_compareBlobsAndSubtype(e,r)}(e,r);case 9:return e.referenceValue===r.referenceValue;case 11:return function __PRIVATE_geoPointEquals(e,r){return __PRIVATE_normalizeNumber(e.geoPointValue.latitude)===__PRIVATE_normalizeNumber(r.geoPointValue.latitude)&&__PRIVATE_normalizeNumber(e.geoPointValue.longitude)===__PRIVATE_normalizeNumber(r.geoPointValue.longitude)}(e,r);case 3:return function __PRIVATE_numberEquals(e,r,i){if(__PRIVATE_isDecimal128Value(e)&&__PRIVATE_isDecimal128Value(r))return 0===__PRIVATE_compareQuadruples(e,r);if("integerValue"in e&&"integerValue"in r||__PRIVATE_isInt32Value(e)&&__PRIVATE_isInt32Value(r))return __PRIVATE_extractNumber(e)===__PRIVATE_extractNumber(r);let s,o;return"doubleValue"in e&&"doubleValue"in r&&(s=__PRIVATE_normalizeNumber(e.doubleValue),o=__PRIVATE_normalizeNumber(r.doubleValue),s===o?__PRIVATE_isNegativeZero(s)===__PRIVATE_isNegativeZero(o):!(void 0!==i&&!i.vt)&&isNaN(s)&&isNaN(o))}(e,r,i);case 13:return function __PRIVATE_arrayEquals(e,r,i){return e.length===r.length&&e.every(((e,s)=>i(e,r[s])))}(e.arrayValue.values||[],r.arrayValue.values||[],((e,r)=>__PRIVATE_valueEquals(e,r,i)));case 14:case 15:return function __PRIVATE_objectEquals(e,r,i){const s=e.mapValue.fields||{},o=r.mapValue.fields||{};if(__PRIVATE_objectSize(s)!==__PRIVATE_objectSize(o))return!1;for(const e in s)if(s.hasOwnProperty(e)&&(void 0===o[e]||!__PRIVATE_valueEquals(s[e],o[e],i)))return!1;return!0}(e,r,i);case 5:return 0===__PRIVATE_compareBsonTimestamps(e,r);case 12:return 0===__PRIVATE_compareRegex(e,r);case 10:return 0===__PRIVATE_compareBsonObjectIds(e,r);default:return z(52216,{left:e})}}function __PRIVATE_arrayValueContains(e,r){return void 0!==(e.values||[]).find((e=>__PRIVATE_valueEquals(e,r)))}function __PRIVATE_valueCompare(e,r){if(e===r)return 0;const i=__PRIVATE_typeOrder(e),s=__PRIVATE_typeOrder(r);if(i!==s)return __PRIVATE_primitiveComparator(i,s);switch(i){case 0:case 1:case 16:case 9007199254740991:return 0;case 2:return __PRIVATE_primitiveComparator(e.booleanValue,r.booleanValue);case 3:return __PRIVATE_compareNumbers(e,r);case 4:return __PRIVATE_compareTimestamps(e.timestampValue,r.timestampValue);case 6:return __PRIVATE_compareTimestamps(__PRIVATE_getLocalWriteTime(e),__PRIVATE_getLocalWriteTime(r));case 7:return __PRIVATE_compareUtf8Strings(e.stringValue,r.stringValue);case 8:return __PRIVATE_compareBlobsAndSubtype(e,r);case 9:return function __PRIVATE_compareReferences(e,r){const i=e.split("/"),s=r.split("/");for(let e=0;e<i.length&&e<s.length;e++){const r=__PRIVATE_primitiveComparator(i[e],s[e]);if(0!==r)return r}return __PRIVATE_primitiveComparator(i.length,s.length)}(e.referenceValue,r.referenceValue);case 11:return function __PRIVATE_compareGeoPoints(e,r){const i=__PRIVATE_primitiveComparator(__PRIVATE_normalizeNumber(e.latitude),__PRIVATE_normalizeNumber(r.latitude));return 0!==i?i:__PRIVATE_primitiveComparator(__PRIVATE_normalizeNumber(e.longitude),__PRIVATE_normalizeNumber(r.longitude))}(e.geoPointValue,r.geoPointValue);case 13:return __PRIVATE_compareArrays(e.arrayValue,r.arrayValue);case 14:return function __PRIVATE_compareVectors(e,r){const i=e.fields||{},s=r.fields||{},o=i[Te]?.arrayValue,h=s[Te]?.arrayValue,E=__PRIVATE_primitiveComparator(o?.values?.length||0,h?.values?.length||0);return 0!==E?E:__PRIVATE_compareArrays(o,h)}(e.mapValue,r.mapValue);case 15:return function __PRIVATE_compareMaps(e,r){if(e===Fe&&r===Fe)return 0;if(e===Fe)return 1;if(r===Fe)return-1;const i=e.fields||{},s=Object.keys(i),o=r.fields||{},h=Object.keys(o);s.sort(),h.sort();for(let e=0;e<s.length&&e<h.length;++e){const r=__PRIVATE_compareUtf8Strings(s[e],h[e]);if(0!==r)return r;const E=__PRIVATE_valueCompare(i[s[e]],o[h[e]]);if(0!==E)return E}return __PRIVATE_primitiveComparator(s.length,h.length)}(e.mapValue,r.mapValue);case 5:return __PRIVATE_compareBsonTimestamps(e,r);case 12:return __PRIVATE_compareRegex(e,r);case 10:return __PRIVATE_compareBsonObjectIds(e,r);default:throw z(23264,{xt:i})}}function __PRIVATE_extractNumber(e){let r;return r=__PRIVATE_isInt32Value(e)?e.mapValue.fields[ye].integerValue:e.integerValue||e.doubleValue,__PRIVATE_normalizeNumber(r)}function __PRIVATE_compareNumbers(e,r){if(__PRIVATE_isDecimal128Value(e)||__PRIVATE_isDecimal128Value(r))return __PRIVATE_compareQuadruples(e,r);const i=__PRIVATE_extractNumber(e),s=__PRIVATE_extractNumber(r);return isNaN(i)?isNaN(s)?0:-1:isNaN(s)?1:__PRIVATE_primitiveComparator(i,s)}function __PRIVATE_compareQuadruples(e,r){const i=__PRIVATE_convertNumberToQuadruple(e),s=__PRIVATE_convertNumberToQuadruple(r);return i.ot()&&s.ot()?0:i.isNaN()?s.isNaN()?0:-1:s.isNaN()?1:i.compareTo(s)}function __PRIVATE_convertNumberToQuadruple(e){return __PRIVATE_isDecimal128Value(e)?__PRIVATE_Quadruple.fromString(function __PRIVATE_getDecimal128StringValue(e){return e.mapValue.fields[be].stringValue}(e)):__PRIVATE_Quadruple.fromNumber(__PRIVATE_extractNumber(e))}function __PRIVATE_compareTimestamps(e,r){if("string"==typeof e&&"string"==typeof r&&e.length===r.length)return __PRIVATE_primitiveComparator(e,r);const i=__PRIVATE_normalizeTimestamp(e),s=__PRIVATE_normalizeTimestamp(r),o=__PRIVATE_primitiveComparator(i.seconds,s.seconds);return 0!==o?o:__PRIVATE_primitiveComparator(i.nanos,s.nanos)}function __PRIVATE_compareArrays(e,r){const i=e.values||[],s=r.values||[];for(let e=0;e<i.length&&e<s.length;++e){const r=__PRIVATE_valueCompare(i[e],s[e]);if(void 0!==r&&0!==r)return r}return __PRIVATE_primitiveComparator(i.length,s.length)}function __PRIVATE_compareBsonTimestamps(e,r){const i=e.mapValue.fields?.[ve].mapValue?.fields?.[we],s=r.mapValue.fields?.[ve].mapValue?.fields?.[we],o=e.mapValue.fields?.[ve].mapValue?.fields?.[Se],h=r.mapValue.fields?.[ve].mapValue?.fields?.[Se],E=__PRIVATE_compareNumbers(i,s);return 0!==E?E:__PRIVATE_compareNumbers(o,h)}function __PRIVATE_getBytesAndSubtype(e){if("bytesValue"in e)return{subtype:0,bytes:__PRIVATE_normalizeByteString(e.bytesValue)};const r=e.mapValue?.fields,i=r?.[De],s=i?.bytesValue;if(!s)throw new Error("Received incorrect value for BsonBinaryData");const o=__PRIVATE_normalizeByteString(s).toUint8Array();if(0===o.length)throw new Error("Received empty bytesValue for BsonBinaryData");const h=o[0],E=o.slice(1);return{subtype:h,bytes:ByteString.fromUint8Array(E)}}function __PRIVATE_compareBlobsAndSubtype(e,r){const i=__PRIVATE_getBytesAndSubtype(e),s=__PRIVATE_getBytesAndSubtype(r);return i.subtype!==s.subtype?i.subtype<s.subtype?-1:1:i.bytes.compareTo(s.bytes)}function __PRIVATE_compareRegex(e,r){const i=e.mapValue.fields,s=i?.[Ae]?.mapValue?.fields?.[Ie]?.stringValue??"",o=i?.[Ae]?.mapValue?.fields?.[Re]?.stringValue??"",h=r.mapValue.fields,E=h?.[Ae]?.mapValue?.fields?.[Ie]?.stringValue??"",T=h?.[Ae]?.mapValue?.fields?.[Re]?.stringValue??"",V=__PRIVATE_compareUtf8Strings(s,E);return 0!==V?V:__PRIVATE_primitiveComparator(o,T)}function __PRIVATE_compareBsonObjectIds(e,r){return __PRIVATE_compareUtf8Strings(e.mapValue.fields?.[xe]?.stringValue??"",r.mapValue.fields?.[xe]?.stringValue??"")}function __PRIVATE_isDecimal128Value(e){if(!e.mapValue?.fields)return!1;const r=e.mapValue.fields;return 1===__PRIVATE_objectSize(r)&&r[be]&&!!r[be].stringValue}function __PRIVATE_isInt32Value(e){if(!e.mapValue?.fields)return!1;const r=e.mapValue.fields;return 1===__PRIVATE_objectSize(r)&&void 0!==r[ye]?.integerValue}function isArray(e){return!!e&&"arrayValue"in e}function __PRIVATE_isMapValue(e){return!!e&&"mapValue"in e}function __PRIVATE_deepClone(e){if(e.geoPointValue)return{geoPointValue:{...e.geoPointValue}};if(e.timestampValue&&"object"==typeof e.timestampValue)return{timestampValue:{...e.timestampValue}};if(e.mapValue){const r={mapValue:{fields:{}}};return forEach(e.mapValue.fields,((e,i)=>r.mapValue.fields[e]=__PRIVATE_deepClone(i))),r}if(e.arrayValue){const r={arrayValue:{values:[]}};for(let i=0;i<(e.arrayValue.values||[]).length;++i)r.arrayValue.values[i]=__PRIVATE_deepClone(e.arrayValue.values[i]);return r}return{...e}}new Set(Object.values(Ue));class Filter{}class FieldFilter extends Filter{constructor(e,r,i){super(),this.field=e,this.op=r,this.value=i}static create(e,r,i){return e.isKeyField()?"in"===r||"not-in"===r?this.createKeyFieldInFilter(e,r,i):new __PRIVATE_KeyFieldFilter(e,r,i):"array-contains"===r?new __PRIVATE_ArrayContainsFilter(e,i):"in"===r?new __PRIVATE_InFilter(e,i):"not-in"===r?new __PRIVATE_NotInFilter(e,i):"array-contains-any"===r?new __PRIVATE_ArrayContainsAnyFilter(e,i):new FieldFilter(e,r,i)}static createKeyFieldInFilter(e,r,i){return"in"===r?new __PRIVATE_KeyFieldInFilter(e,i):new __PRIVATE_KeyFieldNotInFilter(e,i)}matches(e){const r=e.data.field(this.field);return"!="===this.op?null!==r&&void 0===r.nullValue&&this.matchesComparison(__PRIVATE_valueCompare(r,this.value)):null!==r&&__PRIVATE_typeOrder(this.value)===__PRIVATE_typeOrder(r)&&this.matchesComparison(__PRIVATE_valueCompare(r,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return 0===e;case"!=":return 0!==e;case">":return e>0;case">=":return e>=0;default:return z(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class CompositeFilter extends Filter{constructor(e,r){super(),this.filters=e,this.op=r,this.Dt=null}static create(e,r){return new CompositeFilter(e,r)}matches(e){return function __PRIVATE_compositeFilterIsConjunction(e){return"and"===e.op}(this)?void 0===this.filters.find((r=>!r.matches(e))):void 0!==this.filters.find((r=>r.matches(e)))}getFlattenedFilters(){return null!==this.Dt||(this.Dt=this.filters.reduce(((e,r)=>e.concat(r.getFlattenedFilters())),[])),this.Dt}getFilters(){return Object.assign([],this.filters)}}class __PRIVATE_KeyFieldFilter extends FieldFilter{constructor(e,r,i){super(e,r,i),this.key=C.fromName(i.referenceValue)}matches(e){const r=C.comparator(e.key,this.key);return this.matchesComparison(r)}}class __PRIVATE_KeyFieldInFilter extends FieldFilter{constructor(e,r){super(e,"in",r),this.keys=__PRIVATE_extractDocumentKeysFromArrayValue("in",r)}matches(e){return this.keys.some((r=>r.isEqual(e.key)))}}class __PRIVATE_KeyFieldNotInFilter extends FieldFilter{constructor(e,r){super(e,"not-in",r),this.keys=__PRIVATE_extractDocumentKeysFromArrayValue("not-in",r)}matches(e){return!this.keys.some((r=>r.isEqual(e.key)))}}function __PRIVATE_extractDocumentKeysFromArrayValue(e,r){return(r.arrayValue?.values||[]).map((e=>C.fromName(e.referenceValue)))}class __PRIVATE_ArrayContainsFilter extends FieldFilter{constructor(e,r){super(e,"array-contains",r)}matches(e){const r=e.data.field(this.field);return isArray(r)&&__PRIVATE_arrayValueContains(r.arrayValue,this.value)}}class __PRIVATE_InFilter extends FieldFilter{constructor(e,r){super(e,"in",r)}matches(e){const r=e.data.field(this.field);return null!==r&&__PRIVATE_arrayValueContains(this.value.arrayValue,r)}}class __PRIVATE_NotInFilter extends FieldFilter{constructor(e,r){super(e,"not-in",r)}matches(e){if(__PRIVATE_arrayValueContains(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const r=e.data.field(this.field);return null!==r&&void 0===r.nullValue&&!__PRIVATE_arrayValueContains(this.value.arrayValue,r)}}class __PRIVATE_ArrayContainsAnyFilter extends FieldFilter{constructor(e,r){super(e,"array-contains-any",r)}matches(e){const r=e.data.field(this.field);return!(!isArray(r)||!r.arrayValue.values)&&r.arrayValue.values.some((e=>__PRIVATE_arrayValueContains(this.value.arrayValue,e)))}}class OrderBy{constructor(e,r="asc"){this.field=e,this.dir=r}}class j{static fromTimestamp(e){return new j(e)}static min(){return new j(new Timestamp(0,0))}static max(){return new j(new Timestamp(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}}class SortedMap{constructor(e,r){this.comparator=e,this.root=r||LLRBNode.EMPTY}insert(e,r){return new SortedMap(this.comparator,this.root.insert(e,r,this.comparator).copy(null,null,LLRBNode.BLACK,null,null))}remove(e){return new SortedMap(this.comparator,this.root.remove(e,this.comparator).copy(null,null,LLRBNode.BLACK,null,null))}get(e){let r=this.root;for(;!r.isEmpty();){const i=this.comparator(e,r.key);if(0===i)return r.value;i<0?r=r.left:i>0&&(r=r.right)}return null}indexOf(e){let r=0,i=this.root;for(;!i.isEmpty();){const s=this.comparator(e,i.key);if(0===s)return r+i.left.size;s<0?i=i.left:(r+=i.left.size+1,i=i.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(((r,i)=>(e(r,i),!1)))}toString(){const e=[];return this.inorderTraversal(((r,i)=>(e.push(`${r}:${i}`),!1))),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new SortedMapIterator(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new SortedMapIterator(this.root,e,this.comparator,!1)}getReverseIterator(){return new SortedMapIterator(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new SortedMapIterator(this.root,e,this.comparator,!0)}}class SortedMapIterator{constructor(e,r,i,s){this.isReverse=s,this.nodeStack=[];let o=1;for(;!e.isEmpty();)if(o=r?i(e.key,r):1,r&&s&&(o*=-1),o<0)e=this.isReverse?e.left:e.right;else{if(0===o){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const r={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 r}hasNext(){return this.nodeStack.length>0}peek(){if(0===this.nodeStack.length)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class LLRBNode{constructor(e,r,i,s,o){this.key=e,this.value=r,this.color=null!=i?i:LLRBNode.RED,this.left=null!=s?s:LLRBNode.EMPTY,this.right=null!=o?o:LLRBNode.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,r,i,s,o){return new LLRBNode(null!=e?e:this.key,null!=r?r:this.value,null!=i?i:this.color,null!=s?s:this.left,null!=o?o: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,r,i){let s=this;const o=i(e,s.key);return s=o<0?s.copy(null,null,null,s.left.insert(e,r,i),null):0===o?s.copy(null,r,null,null,null):s.copy(null,null,null,null,s.right.insert(e,r,i)),s.fixUp()}removeMin(){if(this.left.isEmpty())return LLRBNode.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,r){let i,s=this;if(r(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,r),null);else{if(s.left.isRed()&&(s=s.rotateRight()),s.right.isEmpty()||s.right.isRed()||s.right.left.isRed()||(s=s.moveRedRight()),0===r(e,s.key)){if(s.right.isEmpty())return LLRBNode.EMPTY;i=s.right.min(),s=s.copy(i.key,i.value,null,null,s.right.removeMin())}s=s.copy(null,null,null,null,s.right.remove(e,r))}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(){const e=this.copy(null,null,LLRBNode.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,LLRBNode.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),r=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,r)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw z(43730,{key:this.key,value:this.value});if(this.right.isRed())throw z(14113,{key:this.key,value:this.value});const e=this.left.check();if(e!==this.right.check())throw z(27949);return e+(this.isRed()?0:1)}}LLRBNode.EMPTY=null,LLRBNode.RED=!0,LLRBNode.BLACK=!1,LLRBNode.EMPTY=new class LLRBEmptyNode{constructor(){this.size=0}get key(){throw z(57766)}get value(){throw z(16141)}get color(){throw z(16727)}get left(){throw z(29726)}get right(){throw z(36894)}copy(e,r,i,s,o){return this}insert(e,r,i){return new LLRBNode(e,r)}remove(e,r){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}};class SortedSet{constructor(e){this.comparator=e,this.data=new SortedMap(this.comparator)}has(e){return null!==this.data.get(e)}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(((r,i)=>(e(r),!1)))}forEachInRange(e,r){const i=this.data.getIteratorFrom(e[0]);for(;i.hasNext();){const s=i.getNext();if(this.comparator(s.key,e[1])>=0)return;r(s.key)}}forEachWhile(e,r){let i;for(i=void 0!==r?this.data.getIteratorFrom(r):this.data.getIterator();i.hasNext();)if(!e(i.getNext().key))return}firstAfterOrEqual(e){const r=this.data.getIteratorFrom(e);return r.hasNext()?r.getNext().key:null}getIterator(){return new SortedSetIterator(this.data.getIterator())}getIteratorFrom(e){return new SortedSetIterator(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 r=this;return r.size<e.size&&(r=e,e=this),e.forEach((e=>{r=r.add(e)})),r}isEqual(e){if(!(e instanceof SortedSet))return!1;if(this.size!==e.size)return!1;const r=this.data.getIterator(),i=e.data.getIterator();for(;r.hasNext();){const e=r.getNext().key,s=i.getNext().key;if(0!==this.comparator(e,s))return!1}return!0}toArray(){const e=[];return this.forEach((r=>{e.push(r)})),e}toString(){const e=[];return this.forEach((r=>e.push(r))),"SortedSet("+e.toString()+")"}copy(e){const r=new SortedSet(this.comparator);return r.data=e,r}}class SortedSetIterator{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}class u{constructor(e){this.value=e}static empty(){return new u({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let r=this.value;for(let i=0;i<e.length-1;++i)if(r=(r.mapValue.fields||{})[e.get(i)],!__PRIVATE_isMapValue(r))return null;return r=(r.mapValue.fields||{})[e.lastSegment()],r||null}}set(e,r){this.getFieldsMap(e.popLast())[e.lastSegment()]=__PRIVATE_deepClone(r)}setAll(e){let r=te.emptyPath(),i={},s=[];e.forEach(((e,o)=>{if(!r.isImmediateParentOf(o)){const e=this.getFieldsMap(r);this.applyChanges(e,i,s),i={},s=[],r=o.popLast()}e?i[o.lastSegment()]=__PRIVATE_deepClone(e):s.push(o.lastSegment())}));const o=this.getFieldsMap(r);this.applyChanges(o,i,s)}delete(e){const r=this.field(e.popLast());__PRIVATE_isMapValue(r)&&r.mapValue.fields&&delete r.mapValue.fields[e.lastSegment()]}isEqual(e){return __PRIVATE_valueEquals(this.value,e.value)}getFieldsMap(e){let r=this.value;r.mapValue.fields||(r.mapValue={fields:{}});for(let i=0;i<e.length;++i){let s=r.mapValue.fields[e.get(i)];__PRIVATE_isMapValue(s)&&s.mapValue.fields||(s={mapValue:{fields:{}}},r.mapValue.fields[e.get(i)]=s),r=s}return r.mapValue.fields}applyChanges(e,r,i){forEach(r,((r,i)=>e[r]=i));for(const r of i)delete e[r]}clone(){return new u(__PRIVATE_deepClone(this.value))}}class __PRIVATE_QueryImpl{constructor(e,r=null,i=[],s=[],o=null,h="F",E=null,T=null){this.path=e,this.collectionGroup=r,this.explicitOrderBy=i,this.filters=s,this.limit=o,this.limitType=h,this.startAt=E,this.endAt=T,this.St=null,this.Ct=null,this.Bt=null,this.startAt,this.endAt}}function __PRIVATE_toDouble(e,r){if(e.useProto3Json){if(isNaN(r))return{doubleValue:"NaN"};if(r===1/0)return{doubleValue:"Infinity"};if(r===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:__PRIVATE_isNegativeZero(r)?"-0":r}}function __PRIVATE_toInteger(e){return{integerValue:""+e}}function toNumber(e,r,i){return function isSafeInteger(e){return"number"==typeof e&&Number.isInteger(e)&&!__PRIVATE_isNegativeZero(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}(r)?__PRIVATE_toInteger(r):__PRIVATE_toDouble(e,r)}class JsonProtoSerializer{constructor(e,r){this.databaseId=e,this.useProto3Json=r}}function toTimestamp(e,r){return e.useProto3Json?`${new Date(1e3*r.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+r.nanoseconds).slice(-9)}Z`:{seconds:""+r.seconds,nanos:r.nanoseconds}}function __PRIVATE_toBytes(e,r){return e.useProto3Json?r.toBase64():r.toUint8Array()}function __PRIVATE_fromVersion(e){return __PRIVATE_hardAssert(!!e,49232),j.fromTimestamp(function fromTimestamp(e){const r=__PRIVATE_normalizeTimestamp(e);return new Timestamp(r.seconds,r.nanos)}(e))}function __PRIVATE_toResourceName(e,r){return __PRIVATE_toResourcePath(e,r).canonicalString()}function __PRIVATE_toResourcePath(e,r){const i=function __PRIVATE_fullyQualifiedPrefixPath(e){return new ResourcePath(["projects",e.projectId,"databases",e.database])}(e).child("documents");return void 0===r?i:i.child(r)}function __PRIVATE_fromPipelineResponse(e,r,i){const s={};r.transaction?.length&&(s.transaction=r.transaction);const o=r.executionTime?__PRIVATE_fromVersion(r.executionTime):void 0;return s.executionTime=o,i&&(s.key=i.name?function fromName(e,r){const i=function __PRIVATE_fromResourceName(e){const r=ResourcePath.fromString(e);return __PRIVATE_hardAssert(__PRIVATE_isValidResourceName(r),10190,{key:r.toString()}),r}(r);if(i.get(1)!==e.databaseId.projectId)throw new k(b,"Tried to deserialize key from different project: "+i.get(1)+" vs "+e.databaseId.projectId);if(i.get(3)!==e.databaseId.database)throw new k(b,"Tried to deserialize key from different database: "+i.get(3)+" vs "+e.databaseId.database);return new C(function __PRIVATE_extractLocalPathFromResourceName(e){return __PRIVATE_hardAssert(e.length>4&&"documents"===e.get(4),29091,{key:e.toString()}),e.popFirst(5)}(i))}(e,i.name):void 0,s.fields=new u({mapValue:{fields:i.fields}}),s.createTime=i.createTime?__PRIVATE_fromVersion(i.createTime):void 0,s.updateTime=i.updateTime?__PRIVATE_fromVersion(i.updateTime):void 0),s}function __PRIVATE_isValidResourceName(e){return e.length>=4&&"projects"===e.get(0)&&"databases"===e.get(2)}function __PRIVATE_isProtoValueSerializable(e){return!!e&&"function"==typeof e._toProto&&"ProtoValue"===e._protoValueType}function toMapValue(e,r){const i={fields:{}};return r.forEach(((r,s)=>{if("string"!=typeof s)throw new Error(`Cannot encode map with non-string key: ${s}`);i.fields[s]=r._toProto(e)})),{mapValue:i}}function __PRIVATE_toStringValue(e){return{stringValue:e}}function __PRIVATE_toPipelineValue(e){return{pipelineValue:e}}function __PRIVATE_newSerializer(e){return new JsonProtoSerializer(e,!0)}class Datastore{}class __PRIVATE_DatastoreImpl extends Datastore{constructor(e,r,i,s){super(),this.authCredentials=e,this.appCheckCredentials=r,this.connection=i,this.serializer=s,this.qt=!1}Lt(){if(this.qt)throw new k(U,"The client has already been terminated.")}le(e,r,i,s){return this.Lt(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([o,h])=>this.connection.le(e,__PRIVATE_toResourcePath(r,i),s,o,h))).catch((e=>{throw"FirebaseError"===e.name?(e.code===N&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new k(R,e.toString())}))}me(e,r,i,s,o){return this.Lt(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([h,E])=>this.connection.me(e,__PRIVATE_toResourcePath(r,i),s,h,E,o))).catch((e=>{throw"FirebaseError"===e.name?(e.code===N&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new k(R,e.toString())}))}terminate(){this.qt=!0,this.connection.terminate()}}const Ce="ComponentProvider",Be=new Map;const Le=!0;class FirestoreSettingsImpl{constructor(e){if(void 0===e.host){if(void 0!==e.ssl)throw new k(b,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=Le}else this.host=e.host,this.ssl=e.ssl??Le;if(this.isUsingEmulator=void 0!==e.emulatorOptions,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e._customHeaders&&(this._customHeaders={...e._customHeaders}),void 0===e.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==e.cacheSizeBytes&&e.cacheSizeBytes<1048576)throw new k(b,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}if(function __PRIVATE_validateIsNotUsedTogether(e,r,i,s){if(!0===r&&!0===s)throw new k(b,`${e} and ${i} cannot be used together.`)}("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:void 0===e.experimentalAutoDetectLongPolling?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=__PRIVATE_cloneLongPollingOptions(e.experimentalLongPollingOptions??{}),function __PRIVATE_validateLongPollingOptions(e){if(void 0!==e.timeoutSeconds){if(isNaN(e.timeoutSeconds))throw new k(b,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new k(b,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new k(b,`invalid long polling timeout: ${e.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams,void 0!==e.grpcFlowControlWindow){if("number"!=typeof e.grpcFlowControlWindow||e.grpcFlowControlWindow<=0||e.grpcFlowControlWindow>2147483647||!Number.isInteger(e.grpcFlowControlWindow))throw new k(b,"grpcFlowControlWindow must be a positive integer and cannot exceed 2147483647");this.grpcFlowControlWindow=e.grpcFlowControlWindow}}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 __PRIVATE_longPollingOptionsEqual(e,r){return e.timeoutSeconds===r.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams&&this.grpcFlowControlWindow===e.grpcFlowControlWindow&&function __PRIVATE_customHeadersEqual(e,r){if(e===r)return!0;if(!e||!r)return!1;const i=Object.keys(e),s=Object.keys(r);if(i.length!==s.length)return!1;for(const s of i)if(e[s]!==r[s])return!1;return!0}(this._customHeaders,e._customHeaders)}}class n{constructor(e,r,i,s){this._authCredentials=e,this._appCheckCredentials=r,this._databaseId=i,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new FirestoreSettingsImpl({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new k(U,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return"notTerminated"!==this._terminateTask}_setSettings(e){if(this._settingsFrozen)throw new k(U,"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 FirestoreSettingsImpl(e),this._emulatorOptions=e.emulatorOptions||{},void 0!==e.credentials&&(this._authCredentials=function __PRIVATE_makeAuthCredentialsProvider(e){if(!e)return new __PRIVATE_EmptyAuthCredentialsProvider;switch(e.type){case"firstParty":return new __PRIVATE_FirstPartyAuthCredentialsProvider(e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new k(b,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return"notTerminated"===this._terminateTask&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){"notTerminated"===this._terminateTask?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function __PRIVATE_removeComponents(e){const r=Be.get(e);r&&(a(Ce,"Removing Datastore"),Be.delete(e),r.terminate())}(this),Promise.resolve()}}class Query{constructor(e,r,i){this.converter=r,this._query=i,this.type="query",this.firestore=e}withConverter(e){return new Query(this.firestore,e,this._query)}}class DocumentReference{constructor(e,r,i){this.converter=r,this._key=i,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 CollectionReference(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new DocumentReference(this.firestore,e,this._key)}toJSON(){return{type:DocumentReference._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,r,i){if(__PRIVATE_validateJSON(r,DocumentReference._jsonSchema))return new DocumentReference(e,i||null,new C(ResourcePath.fromString(r.referencePath)))}}DocumentReference._jsonSchemaVersion="firestore/documentReference/1.0",DocumentReference._jsonSchema={type:property("string",DocumentReference._jsonSchemaVersion),referencePath:property("string")};class CollectionReference extends Query{constructor(e,r,i){super(e,r,function __PRIVATE_newQueryForPath(e){return new __PRIVATE_QueryImpl(e)}(i)),this._path=i,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new DocumentReference(this.firestore,null,new C(e))}withConverter(e){return new CollectionReference(this.firestore,e,this._path)}}function __PRIVATE_isCollectionReference(e){return e instanceof CollectionReference}function doc(e,r,...i){if(e=getModularInstance(e),1===arguments.length&&(r=__PRIVATE_AutoId.newId()),__PRIVATE_validateNonEmptyArgument("doc","path",r),e instanceof n){const s=ResourcePath.fromString(r,...i);return __PRIVATE_validateDocumentPath(s),new DocumentReference(e,null,new C(s))}{if(!(e instanceof DocumentReference||e instanceof CollectionReference))throw new k(b,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const s=e._path.child(ResourcePath.fromString(r,...i));return __PRIVATE_validateDocumentPath(s),new DocumentReference(e.firestore,e instanceof CollectionReference?e.converter:null,new C(s))}}class Bytes{constructor(e,r=0){if(this.subtype=r,!Number.isInteger(r)||r<0||r>255)throw new k(b,"The subtype for Bytes must be a value in the inclusive [0, 255] range.");this._byteString=e}static fromBase64String(e,r=0){try{return new Bytes(ByteString.fromBase64String(e),r)}catch(e){throw new k(b,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e,r=0){return new Bytes(ByteString.fromUint8Array(e),r)}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}get data(){return this.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+", subtype: "+this.subtype+")"}isEqual(e){return this.subtype===e.subtype&&this._byteString.isEqual(e._byteString)}toJSON(){const e={type:Bytes._jsonSchemaVersion,bytes:this.toBase64()};return 0!==this.subtype&&(e.subtype=this.subtype),e}static fromJSON(e){if(__PRIVATE_validateJSON(e,Bytes._jsonSchema)){const r=e.subtype??0;return Bytes.fromBase64String(e.bytes,r)}}}Bytes._jsonSchemaVersion="firestore/bytes/1.0",Bytes._jsonSchema={type:property("string",Bytes._jsonSchemaVersion),bytes:property("string"),subtype:{...property("number"),optional:!0}};class D{constructor(...e){for(let r=0;r<e.length;++r)if(0===e[r].length)throw new k(b,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new te(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}class BsonObjectId{constructor(e){this.value=e}isEqual(e){return this.value===e.value}}class BsonTimestamp{constructor(e,r){if(this.seconds=e,this.increment=r,!Number.isInteger(e)||e<0||e>4294967295)throw new Error("BsonTimestamp 'seconds' must be in the range of a 32-bit unsigned integer (0-4294967295).");if(!Number.isInteger(r)||r<0||r>4294967295)throw new Error("BsonTimestamp 'increment' must be in the range of a 32-bit unsigned integer (0-4294967295).")}isEqual(e){return this.seconds===e.seconds&&this.increment===e.increment}}class Decimal128Value{constructor(e){this.stringValue=e,this.value=__PRIVATE_Quadruple.fromString(e)}isEqual(e){return!(!this.value.ot()||!e.value.ot())||0===this.value.compareTo(e.value)}toJSON(){return{$t:{stringValue:this.stringValue}}}}class FieldValue{constructor(e){this._methodName=e}}class GeoPoint{constructor(e,r){if(!isFinite(e)||e<-90||e>90)throw new k(b,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(r)||r<-180||r>180)throw new k(b,"Longitude must be a number between -180 and 180, but was: "+r);this._lat=e,this._long=r}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}_compareTo(e){return __PRIVATE_primitiveComparator(this._lat,e._lat)||__PRIVATE_primitiveComparator(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:GeoPoint._jsonSchemaVersion}}static fromJSON(e){if(__PRIVATE_validateJSON(e,GeoPoint._jsonSchema))return new GeoPoint(e.latitude,e.longitude)}}GeoPoint._jsonSchemaVersion="firestore/geoPoint/1.0",GeoPoint._jsonSchema={type:property("string",GeoPoint._jsonSchemaVersion),latitude:property("number"),longitude:property("number")};class Int32Value{constructor(e){this.value=e}isEqual(e){return this.value===e.value}}class MaxKey{constructor(){this.type="MaxKey"}static instance(){return MaxKey.MAX_KEY_VALUE_INSTANCE||(MaxKey.MAX_KEY_VALUE_INSTANCE=new MaxKey),MaxKey.MAX_KEY_VALUE_INSTANCE}}MaxKey.MAX_KEY_VALUE_INSTANCE=null;class MinKey{constructor(){this.type="MinKey"}static instance(){return MinKey.MIN_KEY_VALUE_INSTANCE||(MinKey.MIN_KEY_VALUE_INSTANCE=new MinKey),MinKey.MIN_KEY_VALUE_INSTANCE}}MinKey.MIN_KEY_VALUE_INSTANCE=null;class RegexValue{constructor(e,r){this.pattern=e,this.options=r}isEqual(e){return this.pattern===e.pattern&&this.options===e.options}}class VectorValue{constructor(e){this._values=(e||[]).map((e=>e))}toArray(){return this._values.map((e=>e))}isEqual(e){return function __PRIVATE_isPrimitiveArrayEqual(e,r){if(e.length!==r.length)return!1;for(let i=0;i<e.length;++i)if(e[i]!==r[i])return!1;return!0}(this._values,e._values)}toJSON(){return{type:VectorValue._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(__PRIVATE_validateJSON(e,VectorValue._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every((e=>"number"==typeof e)))return new VectorValue(e.vectorValues);throw new k(b,"Expected 'vectorValues' field to be a number array")}}}VectorValue._jsonSchemaVersion="firestore/vectorValue/1.0",VectorValue._jsonSchema={type:property("string",VectorValue._jsonSchemaVersion),vectorValues:property("object")};const Me=/^__.*__$/;function __PRIVATE_isWrite(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw z(40011,{dataSource:e})}}class ParseContextImpl{constructor(e,r,i,s,o,h){this.settings=e,this.databaseId=r,this.serializer=i,this.ignoreUndefinedProperties=s,void 0===o&&this.validatePath(),this.fieldTransforms=o||[],this.fieldMask=h||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}contextWith(e){return new ParseContextImpl({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}childContextForField(e){const r=this.path?.child(e),i=this.contextWith({path:r,arrayElement:!1});return i.validatePathSegment(e),i}childContextForFieldPath(e){const r=this.path?.child(e),i=this.contextWith({path:r,arrayElement:!1});return i.validatePath(),i}childContextForArray(e){return this.contextWith({path:void 0,arrayElement:!0})}createError(e){return createError(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(e){return void 0!==this.fieldMask.find((r=>e.isPrefixOf(r)))||void 0!==this.fieldTransforms.find((r=>e.isPrefixOf(r.field)))}validatePath(){if(this.path)for(let e=0;e<this.path.length;e++)this.validatePathSegment(this.path.get(e))}validatePathSegment(e){if(0===e.length)throw this.createError("Document fields must not be empty");if(__PRIVATE_isWrite(this.dataSource)&&Me.test(e))throw this.createError('Document fields cannot begin and end with "__"')}}class UserDataReader{constructor(e,r,i){this.databaseId=e,this.ignoreUndefinedProperties=r,this.serializer=i||__PRIVATE_newSerializer(e)}createContext(e,r,i,s=!1){return new ParseContextImpl({dataSource:e,methodName:r,targetDoc:i,path:te.emptyPath(),arrayElement:!1,hasConverter:s},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function p(e){const r=e._freezeSettings(),i=__PRIVATE_newSerializer(e._databaseId);return new UserDataReader(e._databaseId,!!r.ignoreUndefinedProperties,i)}function __PRIVATE_parseData(e,r,i){if(__PRIVATE_looksLikeJsonObject(e=getModularInstance(e)))return function __PRIVATE_validatePlainObject(e,r,i){if(!__PRIVATE_looksLikeJsonObject(i)||!__PRIVATE_isPlainObject(i)){const s=__PRIVATE_valueDescription(i);throw"an object"===s?r.createError(e+" a custom object"):r.createError(e+" "+s)}}("Unsupported field value:",r,e),function __PRIVATE_parseObject(e,r){const i={};return function isEmpty(e){for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r))return!1;return!0}(e)?r.path&&r.path.length>0&&r.fieldMask.push(r.path):forEach(e,((e,s)=>{const o=__PRIVATE_parseData(s,r.childContextForField(e));null!=o&&(i[e]=o)})),{mapValue:{fields:i}}}(e,r);if(e instanceof FieldValue)return function __PRIVATE_parseSentinelFieldValue(e,r){if(!__PRIVATE_isWrite(r.dataSource))throw r.createError(`${e._methodName}() can only be used with update() and set()`);if(!r.path)throw r.createError(`${e._methodName}() is not currently supported inside arrays`);const i=e._toFieldTransform(r);i&&r.fieldTransforms.push(i)}(e,r),null;if(void 0===e&&r.ignoreUndefinedProperties)return null;if(r.path&&r.fieldMask.push(r.path),e instanceof Array){if(r.settings.arrayElement&&4!==r.dataSource)throw r.createError("Nested arrays are not supported");return function __PRIVATE_parseArray(e,r){const i=[];let s=0;for(const o of e){let e=__PRIVATE_parseData(o,r.childContextForArray(s));null==e&&(e={nullValue:"NULL_VALUE"}),i.push(e),s++}return{arrayValue:{values:i}}}(e,r)}return function __PRIVATE_parseScalarValue(e,r){if(null===(e=getModularInstance(e)))return{nullValue:"NULL_VALUE"};if("number"==typeof e)return toNumber(r.serializer,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){const i=Timestamp.fromDate(e);return{timestampValue:toTimestamp(r.serializer,i)}}if(e instanceof Timestamp){const i=new Timestamp(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:toTimestamp(r.serializer,i)}}if(__PRIVATE_isTemporalInstant(e)){const i=Timestamp.fromInstant(e),s=new Timestamp(i.seconds,1e3*Math.floor(i.nanoseconds/1e3));return{timestampValue:toTimestamp(r.serializer,s)}}if(e instanceof GeoPoint)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof Bytes)return 0===e.subtype?{bytesValue:__PRIVATE_toBytes(r.serializer,e._byteString)}:function __PRIVATE_parseBytesWithSubtype(e,r){const i=r.toUint8Array(),s=new Uint8Array(i.length+1);return s[0]=r.subtype,s.set(i,1),{mapValue:{fields:{[De]:{bytesValue:__PRIVATE_toBytes(e,ByteString.fromUint8Array(s))}}}}}(r.serializer,e);if(e instanceof DocumentReference){const i=r.databaseId,s=e.firestore._databaseId;if(!s.isEqual(i))throw r.createError(`Document reference is for database ${s.projectId}/${s.database} but should be for database ${i.projectId}/${i.database}`);return{referenceValue:__PRIVATE_toResourceName(e.firestore._databaseId||r.databaseId,e._key.path)}}if(e instanceof VectorValue)return function __PRIVATE_parseVectorValue(e,r){const i=e instanceof VectorValue?e.toArray():e,s={fields:{[me]:{stringValue:Ee},[Te]:{arrayValue:{values:i.map((e=>{if("number"!=typeof e)throw r.createError("VectorValues must only contain numeric values.");return __PRIVATE_toDouble(r.serializer,e)}))}}}};return{mapValue:s}}(e,r);if(e instanceof RegexValue)return function __PRIVATE_parseRegexValue(e){return{mapValue:{fields:{[Ae]:{mapValue:{fields:{[Ie]:{stringValue:e.pattern},[Re]:{stringValue:e.options}}}}}}}}(e);if(e instanceof BsonObjectId)return function __PRIVATE_parseBsonObjectId(e){return{mapValue:{fields:{[xe]:{stringValue:e.value}}}}}(e);if(e instanceof Int32Value)return function __PRIVATE_parseInt32Value(e){return{mapValue:{fields:{[ye]:__PRIVATE_toInteger(e.value)}}}}(e);if(e instanceof Decimal128Value)return function __PRIVATE_parseDecimal128Value(e){return{mapValue:{fields:{[be]:{stringValue:e.stringValue}}}}}(e);if(e instanceof BsonTimestamp)return function __PRIVATE_parseBsonTimestamp(e){return{mapValue:{fields:{[ve]:{mapValue:{fields:{[we]:__PRIVATE_toInteger(e.seconds),[Se]:__PRIVATE_toInteger(e.increment)}}}}}}}(e);if(e instanceof MinKey)return function __PRIVATE_parseMinKey(){return{mapValue:{fields:{[Ve]:{nullValue:"NULL_VALUE"}}}}}();if(e instanceof MaxKey)return function __PRIVATE_parseMaxKey(){return{mapValue:{fields:{[Pe]:{nullValue:"NULL_VALUE"}}}}}();if(__PRIVATE_isProtoValueSerializable(e))return e._toProto(r.serializer);throw r.createError(`Unsupported field value: ${__PRIVATE_valueDescription(e)}`)}(e,r)}function __PRIVATE_isTemporalInstant(e){if("object"!=typeof e||null===e)return!1;if("undefined"!=typeof Temporal&&"function"==typeof Temporal.Instant&&e instanceof Temporal.Instant)return!0;const r=e;return"Temporal.Instant"===r[Symbol.toStringTag]&&"bigint"==typeof r.ht}function __PRIVATE_looksLikeJsonObject(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof Timestamp||e instanceof GeoPoint||e instanceof Bytes||e instanceof DocumentReference||e instanceof FieldValue||e instanceof VectorValue||e instanceof MinKey||e instanceof MaxKey||e instanceof Int32Value||e instanceof Decimal128Value||e instanceof RegexValue||e instanceof BsonObjectId||e instanceof BsonTimestamp||__PRIVATE_isTemporalInstant(e)||__PRIVATE_isProtoValueSerializable(e))}function _(e,r,i){if((r=getModularInstance(r))instanceof D)return r._internalPath;if("string"==typeof r)return function __PRIVATE_fieldPathFromDotSeparatedString(e,r,i){if(r.search(ke)>=0)throw createError(`Invalid field path (${r}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,i);try{return new D(...r.split("."))._internalPath}catch(s){throw createError(`Invalid field path (${r}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,i)}}(e,r);throw createError("Field path arguments must be of type string or ",e,!1,void 0,i)}const ke=new RegExp("[~\\*/\\[\\]]");function createError(e,r,i,s,o){const h=s&&!s.isEmpty(),E=void 0!==o;let T=`Function ${r}() called with invalid data`;i&&(T+=" (via `toFirestore()`)"),T+=". ";let V="";return(h||E)&&(V+=" (found",h&&(V+=` in field ${s}`),E&&(V+=` in document ${o}`),V+=")"),new k(b,T+e+V)}class it{constructor(e,r,i,s,o){this._firestore=e,this._userDataWriter=r,this._key=i,this._document=s,this._converter=o}get id(){return this._key.path.lastSegment()}get ref(){return new DocumentReference(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){const e=new QueryDocumentSnapshot(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){return this._document?.data.clone().value.mapValue.fields??void 0}get(e){if(this._document){const r=this._document.data.field(_("DocumentSnapshot.get",e));if(null!==r)return this._userDataWriter.convertValue(r)}}}class QueryDocumentSnapshot extends it{data(){return super.data()}}class AbstractUserDataWriter{convertValue(e,r="none"){switch(__PRIVATE_typeOrder(e)){case 0:return null;case 2:return e.booleanValue;case 3:if("mapValue"in e){if(__PRIVATE_isInt32Value(e))return this.convertToInt32Value(e.mapValue);if(__PRIVATE_isDecimal128Value(e))return this.convertToDecimal128Value(e.mapValue)}return __PRIVATE_normalizeNumber(e.integerValue||e.doubleValue);case 4:return this.convertTimestamp(e.timestampValue);case 6:return this.convertServerTimestamp(e,r);case 7:return e.stringValue;case 8:return"bytesValue"in e?this.convertBytes(__PRIVATE_normalizeByteString(e.bytesValue)):this.convertToBytesWithSubtype(e.mapValue);case 9:return this.convertReference(e.referenceValue);case 11:return this.convertGeoPoint(e.geoPointValue);case 13:return this.convertArray(e.arrayValue,r);case 15:return this.convertObject(e.mapValue,r);case 14:return this.convertVectorValue(e.mapValue);case 12:return this.convertToRegexValue(e.mapValue);case 10:return this.convertToBsonObjectId(e.mapValue);case 5:return this.convertToBsonTimestamp(e.mapValue);case 16:return MaxKey.instance();case 1:return MinKey.instance();default:throw z(62114,{value:e})}}convertObject(e,r){return this.convertObjectMap(e.fields,r)}convertObjectMap(e,r="none"){const i={};return forEach(e,((e,s)=>{i[e]=this.convertValue(s,r)})),i}convertVectorValue(e){const r=e.fields?.[Te].arrayValue?.values?.map((e=>__PRIVATE_normalizeNumber(e.doubleValue)));return new VectorValue(r)}convertToBsonObjectId(e){const r=e.fields?.[xe]?.stringValue??"";return new BsonObjectId(r)}convertToBytesWithSubtype(e){const r=e.fields?.[De],i=r?.bytesValue;if(!i)throw new Error("Received incorrect bytesValue for Bytes with subtype");const s=__PRIVATE_normalizeByteString(i).toUint8Array();if(0===s.length)throw new Error("Received empty bytesValue for Bytes with subtype");const o=s[0],h=s.slice(1);return new Bytes(ByteString.fromUint8Array(h),o)}convertToBsonTimestamp(e){const r=e.fields?.[ve],i=Number(r?.mapValue?.fields?.[we]?.integerValue),s=Number(r?.mapValue?.fields?.[Se]?.integerValue);return new BsonTimestamp(i,s)}convertToRegexValue(e){const r=e.fields?.[Ae]?.mapValue?.fields?.[Ie]?.stringValue??"",i=e.fields?.[Ae]?.mapValue?.fields?.[Re]?.stringValue??"";return new RegexValue(r,i)}convertToInt32Value(e){const r=Number(e.fields?.[ye]?.integerValue);return new Int32Value(r)}convertToDecimal128Value(e){const r=e.fields?.[be]?.stringValue??"";return new Decimal128Value(r)}convertGeoPoint(e){return new GeoPoint(__PRIVATE_normalizeNumber(e.latitude),__PRIVATE_normalizeNumber(e.longitude))}convertArray(e,r){return(e.values||[]).map((e=>this.convertValue(e,r)))}convertServerTimestamp(e,r){switch(r){case"previous":const i=__PRIVATE_getPreviousValue(e);return null==i?null:this.convertValue(i,r);case"estimate":return this.convertTimestamp(__PRIVATE_getLocalWriteTime(e));default:return null}}convertTimestamp(e){const r=__PRIVATE_normalizeTimestamp(e);return new Timestamp(r.seconds,r.nanos)}convertDocumentKey(e,r){const i=ResourcePath.fromString(e);__PRIVATE_hardAssert(__PRIVATE_isValidResourceName(i),9688,{name:e});const s=new DatabaseId(i.get(1),i.get(3)),o=new C(i.popFirst(5));return s.isEqual(r)||st(`A document reference to ${o} refers to a different database (${s.projectId}/${s.database}), which is not supported. It will be treated as a reference in the current database (${r.projectId}/${r.database}) instead.`),o}}class A extends AbstractUserDataWriter{constructor(e){super(),this.firestore=e}convertBytes(e){return new Bytes(e)}convertReference(e){const r=this.convertDocumentKey(e,this.firestore._databaseId);return new DocumentReference(this.firestore,null,r)}}function vector(e){return new VectorValue(e)}class OptionsUtil{constructor(e){this.optionDefinitions=e}_getKnownOptions(e,r){const i=u.empty();for(const s in this.optionDefinitions)if(this.optionDefinitions.hasOwnProperty(s)){const o=this.optionDefinitions[s];if(s in e){const h=e[s];let E;o.nestedOptions&&__PRIVATE_isPlainObject(h)?E={mapValue:{fields:new OptionsUtil(o.nestedOptions).getOptionsProto(r,h)}}:h&&(E=__PRIVATE_parseData(h,r)??void 0),E&&i.set(te.fromServerFormat(o.serverName),E)}}return i}getOptionsProto(e,r,i){const s=this._getKnownOptions(r,e);if(i){const r=new Map(function g(e,r){const i=[];for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(r(e[s],s,e));return i}(i,((r,i)=>[te.fromServerFormat(i),void 0!==r?__PRIVATE_parseData(r,e):null])));s.setAll(r)}return s.value.mapValue.fields??{}}}function __PRIVATE_isFirestoreValue(e){return"object"==typeof e&&null!==e&&!!("nullValue"in e&&(null===e.nullValue||"NULL_VALUE"===e.nullValue)||"booleanValue"in e&&(null===e.booleanValue||"boolean"==typeof e.booleanValue)||"integerValue"in e&&(null===e.integerValue||"number"==typeof e.integerValue||"string"==typeof e.integerValue)||"doubleValue"in e&&(null===e.doubleValue||"number"==typeof e.doubleValue)||"timestampValue"in e&&(null===e.timestampValue||function __PRIVATE_isITimestamp(e){return"object"==typeof e&&null!==e&&"seconds"in e&&(null===e.seconds||"number"==typeof e.seconds||"string"==typeof e.seconds)&&"nanos"in e&&(null===e.nanos||"number"==typeof e.nanos)}(e.timestampValue))||"stringValue"in e&&(null===e.stringValue||"string"==typeof e.stringValue)||"bytesValue"in e&&(null===e.bytesValue||e.bytesValue instanceof Uint8Array)||"referenceValue"in e&&(null===e.referenceValue||"string"==typeof e.referenceValue)||"geoPointValue"in e&&(null===e.geoPointValue||function __PRIVATE_isILatLng(e){return"object"==typeof e&&null!==e&&"latitude"in e&&(null===e.latitude||"number"==typeof e.latitude)&&"longitude"in e&&(null===e.longitude||"number"==typeof e.longitude)}(e.geoPointValue))||"arrayValue"in e&&(null===e.arrayValue||function __PRIVATE_isIArrayValue(e){return"object"==typeof e&&null!==e&&!(!("values"in e)||null!==e.values&&!Array.isArray(e.values))}(e.arrayValue))||"mapValue"in e&&(null===e.mapValue||function __PRIVATE_isIMapValue(e){return"object"==typeof e&&null!==e&&!(!("fields"in e)||null!==e.fields&&!__PRIVATE_isPlainObject(e.fields))}(e.mapValue))||"fieldReferenceValue"in e&&(null===e.fieldReferenceValue||"string"==typeof e.fieldReferenceValue)||"functionValue"in e&&(null===e.functionValue||function __PRIVATE_isIFunction(e){return"object"==typeof e&&null!==e&&!(!("name"in e)||null!==e.name&&"string"!=typeof e.name||!("args"in e)||null!==e.args&&!Array.isArray(e.args))}(e.functionValue))||"pipelineValue"in e&&(null===e.pipelineValue||function __PRIVATE_isIPipeline(e){return"object"==typeof e&&null!==e&&!(!("stages"in e)||null!==e.stages&&!Array.isArray(e.stages))}(e.pipelineValue)))}function __PRIVATE_valueToDefaultExpr$1(e){let r;return e instanceof Expression?e:(r=__PRIVATE_isPlainObject(e)?__PRIVATE__map(e):e instanceof Array?array(e):__PRIVATE__constant(e,void 0),r)}function __PRIVATE_vectorToExpr$1(e){if(e instanceof Expression)return e;if(e instanceof VectorValue)return constant(e);if(Array.isArray(e))return constant(vector(e));throw new Error("Unsupported value: "+typeof e)}function __PRIVATE_fieldOrExpression$1(e){return __PRIVATE_isString(e)?field(e):__PRIVATE_valueToDefaultExpr$1(e)}class Expression{constructor(){this._protoValueType="ProtoValue"}add(e){return new FunctionExpression("add",[this,__PRIVATE_valueToDefaultExpr$1(e)],"add")}asBoolean(){if(this instanceof BooleanExpression)return this;if(this instanceof Constant)return new __PRIVATE_BooleanConstant(this);if(this instanceof Field)return new __PRIVATE_BooleanField(this);if(this instanceof FunctionExpression)return new __PRIVATE_BooleanFunctionExpression(this);throw new k("invalid-argument",`Conversion of type ${typeof this} to BooleanExpression not supported.`)}subtract(e){return new FunctionExpression("subtract",[this,__PRIVATE_valueToDefaultExpr$1(e)],"subtract")}multiply(e){return new FunctionExpression("multiply",[this,__PRIVATE_valueToDefaultExpr$1(e)],"multiply")}divide(e){return new FunctionExpression("divide",[this,__PRIVATE_valueToDefaultExpr$1(e)],"divide")}mod(e){return new FunctionExpression("mod",[this,__PRIVATE_valueToDefaultExpr$1(e)],"mod")}equal(e){return new FunctionExpression("equal",[this,__PRIVATE_valueToDefaultExpr$1(e)],"equal").asBoolean()}notEqual(e){return new FunctionExpression("not_equal",[this,__PRIVATE_valueToDefaultExpr$1(e)],"notEqual").asBoolean()}lessThan(e){return new FunctionExpression("less_than",[this,__PRIVATE_valueToDefaultExpr$1(e)],"lessThan").asBoolean()}lessThanOrEqual(e){return new FunctionExpression("less_than_or_equal",[this,__PRIVATE_valueToDefaultExpr$1(e)],"lessThanOrEqual").asBoolean()}greaterThan(e){return new FunctionExpression("greater_than",[this,__PRIVATE_valueToDefaultExpr$1(e)],"greaterThan").asBoolean()}greaterThanOrEqual(e){return new FunctionExpression("greater_than_or_equal",[this,__PRIVATE_valueToDefaultExpr$1(e)],"greaterThanOrEqual").asBoolean()}arrayConcat(e,...r){const i=[e,...r].map((e=>__PRIVATE_valueToDefaultExpr$1(e)));return new FunctionExpression("array_concat",[this,...i],"arrayConcat")}arrayContains(e){return new FunctionExpression("array_contains",[this,__PRIVATE_valueToDefaultExpr$1(e)],"arrayContains").asBoolean()}arrayContainsAll(e){const r=Array.isArray(e)?new __PRIVATE_ListOfExprs(e.map(__PRIVATE_valueToDefaultExpr$1),"arrayContainsAll"):e;return new FunctionExpression("array_contains_all",[this,r],"arrayContainsAll").asBoolean()}arrayContainsAny(e){const r=Array.isArray(e)?new __PRIVATE_ListOfExprs(e.map(__PRIVATE_valueToDefaultExpr$1),"arrayContainsAny"):e;return new FunctionExpression("array_contains_any",[this,r],"arrayContainsAny").asBoolean()}arrayReverse(){return new FunctionExpression("array_reverse",[this])}arrayLength(){return new FunctionExpression("array_length",[this],"arrayLength")}equalAny(e){const r=Array.isArray(e)?new __PRIVATE_ListOfExprs(e.map(__PRIVATE_valueToDefaultExpr$1),"equalAny"):e;return new FunctionExpression("equal_any",[this,r],"equalAny").asBoolean()}notEqualAny(e){const r=Array.isArray(e)?new __PRIVATE_ListOfExprs(e.map(__PRIVATE_valueToDefaultExpr$1),"notEqualAny"):e;return new FunctionExpression("not_equal_any",[this,r],"notEqualAny").asBoolean()}exists(){return new FunctionExpression("exists",[this],"exists").asBoolean()}charLength(){return new FunctionExpression("char_length",[this],"charLength")}like(e){return new FunctionExpression("like",[this,__PRIVATE_valueToDefaultExpr$1(e)],"like").asBoolean()}regexContains(e){return new FunctionExpression("regex_contains",[this,__PRIVATE_valueToDefaultExpr$1(e)],"regexContains").asBoolean()}regexFind(e){return new FunctionExpression("regex_find",[this,__PRIVATE_valueToDefaultExpr$1(e)],"regexFind")}regexFindAll(e){return new FunctionExpression("regex_find_all",[this,__PRIVATE_valueToDefaultExpr$1(e)],"regexFindAll")}regexMatch(e){return new FunctionExpression("regex_match",[this,__PRIVATE_valueToDefaultExpr$1(e)],"regexMatch").asBoolean()}stringContains(e){return new FunctionExpression("string_contains",[this,__PRIVATE_valueToDefaultExpr$1(e)],"stringContains").asBoolean()}startsWith(e){return new FunctionExpression("starts_with",[this,__PRIVATE_valueToDefaultExpr$1(e)],"startsWith").asBoolean()}endsWith(e){return new FunctionExpression("ends_with",[this,__PRIVATE_valueToDefaultExpr$1(e)],"endsWith").asBoolean()}toLower(){return new FunctionExpression("to_lower",[this],"toLower")}toUpper(){return new FunctionExpression("to_upper",[this],"toUpper")}trim(e){const r=[this];return e&&r.push(__PRIVATE_valueToDefaultExpr$1(e)),new FunctionExpression("trim",r,"trim")}ltrim(e){const r=[this];return e&&r.push(__PRIVATE_valueToDefaultExpr$1(e)),new FunctionExpression("ltrim",r,"ltrim")}rtrim(e){const r=[this];return e&&r.push(__PRIVATE_valueToDefaultExpr$1(e)),new FunctionExpression("rtrim",r,"rtrim")}type(){return new FunctionExpression("type",[this])}isType(e){return new FunctionExpression("is_type",[this,constant(e)],"isType").asBoolean()}stringConcat(e,...r){const i=[e,...r].map(__PRIVATE_valueToDefaultExpr$1);return new FunctionExpression("string_concat",[this,...i],"stringConcat")}stringIndexOf(e){return new FunctionExpression("string_index_of",[this,__PRIVATE_valueToDefaultExpr$1(e)],"stringIndexOf")}stringRepeat(e){return new FunctionExpression("string_repeat",[this,__PRIVATE_valueToDefaultExpr$1(e)],"stringRepeat")}stringReplaceAll(e,r){return new FunctionExpression("string_replace_all",[this,__PRIVATE_valueToDefaultExpr$1(e),__PRIVATE_valueToDefaultExpr$1(r)],"stringReplaceAll")}stringReplaceOne(e,r){return new FunctionExpression("string_replace_one",[this,__PRIVATE_valueToDefaultExpr$1(e),__PRIVATE_valueToDefaultExpr$1(r)],"stringReplaceOne")}concat(e,...r){const i=[e,...r].map(__PRIVATE_valueToDefaultExpr$1);return new FunctionExpression("concat",[this,...i],"concat")}reverse(){return new FunctionExpression("reverse",[this],"reverse")}arrayFilter(e,r){return new FunctionExpression("array_filter",[this,__PRIVATE_valueToDefaultExpr$1(e),r],"arrayFilter")}arrayTransform(e,r){return new FunctionExpression("array_transform",[this,__PRIVATE_valueToDefaultExpr$1(e),r],"arrayTransform")}arrayTransformWithIndex(e,r,i){return new FunctionExpression("array_transform",[this,__PRIVATE_valueToDefaultExpr$1(e),__PRIVATE_valueToDefaultExpr$1(r),i],"arrayTransformWithIndex")}arraySlice(e,r){const i=[this,__PRIVATE_valueToDefaultExpr$1(e)];return void 0!==r&&i.push(__PRIVATE_valueToDefaultExpr$1(r)),new FunctionExpression("array_slice",i,"arraySlice")}arrayFirst(){return new FunctionExpression("array_first",[this],"arrayFirst")}arrayFirstN(e){return new FunctionExpression("array_first_n",[this,__PRIVATE_valueToDefaultExpr$1(e)],"arrayFirstN")}arrayLast(){return new FunctionExpression("array_last",[this],"arrayLast")}arrayLastN(e){return new FunctionExpression("array_last_n",[this,__PRIVATE_valueToDefaultExpr$1(e)],"arrayLastN")}arrayMaximum(){return new FunctionExpression("maximum",[this],"arrayMaximum")}arrayMaximumN(e){return new FunctionExpression("maximum_n",[this,__PRIVATE_valueToDefaultExpr$1(e)],"arrayMaximumN")}arrayMinimum(){return new FunctionExpression("minimum",[this],"arrayMinimum")}arrayMinimumN(e){return new FunctionExpression("minimum_n",[this,__PRIVATE_valueToDefaultExpr$1(e)],"arrayMinimumN")}arrayIndexOf(e){return new FunctionExpression("array_index_of",[this,__PRIVATE_valueToDefaultExpr$1(e),__PRIVATE_valueToDefaultExpr$1("first")],"arrayIndexOf")}arrayLastIndexOf(e){return new FunctionExpression("array_index_of",[this,__PRIVATE_valueToDefaultExpr$1(e),__PRIVATE_valueToDefaultExpr$1("last")],"arrayLastIndexOf")}arrayIndexOfAll(e){return new FunctionExpression("array_index_of_all",[this,__PRIVATE_valueToDefaultExpr$1(e)],"arrayIndexOfAll")}byteLength(){return new FunctionExpression("byte_length",[this],"byteLength")}ceil(){return new FunctionExpression("ceil",[this])}floor(){return new FunctionExpression("floor",[this])}abs(){return new FunctionExpression("abs",[this])}exp(){return new FunctionExpression("exp",[this])}mapGet(e){return new FunctionExpression("map_get",[this,constant(e)],"mapGet")}mapSet(e,r,...i){const s=[this,__PRIVATE_valueToDefaultExpr$1(e),__PRIVATE_valueToDefaultExpr$1(r),...i.map(__PRIVATE_valueToDefaultExpr$1)];return new FunctionExpression("map_set",s,"mapSet")}mapKeys(){return new FunctionExpression("map_keys",[this],"mapKeys")}mapValues(){return new FunctionExpression("map_values",[this],"mapValues")}mapEntries(){return new FunctionExpression("map_entries",[this],"mapEntries")}getField(e){return new FunctionExpression("get_field",[this,__PRIVATE_valueToDefaultExpr$1(e)],"get_field")}count(){return AggregateFunction._create("count",[this],"count")}sum(){return AggregateFunction._create("sum",[this],"sum")}average(){return AggregateFunction._create("average",[this],"average")}minimum(){return AggregateFunction._create("minimum",[this],"minimum")}maximum(){return AggregateFunction._create("maximum",[this],"maximum")}first(){return AggregateFunction._create("first",[this],"first")}last(){return AggregateFunction._create("last",[this],"last")}arrayAgg(){return AggregateFunction._create("array_agg",[this],"arrayAgg")}arrayAggDistinct(){return AggregateFunction._create("array_agg_distinct",[this],"arrayAggDistinct")}countDistinct(){return AggregateFunction._create("count_distinct",[this],"countDistinct")}logicalMaximum(e,...r){const i=[e,...r];return new FunctionExpression("maximum",[this,...i.map(__PRIVATE_valueToDefaultExpr$1)],"logicalMaximum")}logicalMinimum(e,...r){const i=[e,...r];return new FunctionExpression("minimum",[this,...i.map(__PRIVATE_valueToDefaultExpr$1)],"minimum")}vectorLength(){return new FunctionExpression("vector_length",[this],"vectorLength")}cosineDistance(e){return new FunctionExpression("cosine_distance",[this,__PRIVATE_vectorToExpr$1(e)],"cosineDistance")}dotProduct(e){return new FunctionExpression("dot_product",[this,__PRIVATE_vectorToExpr$1(e)],"dotProduct")}euclideanDistance(e){return new FunctionExpression("euclidean_distance",[this,__PRIVATE_vectorToExpr$1(e)],"euclideanDistance")}unixMicrosToTimestamp(){return new FunctionExpression("unix_micros_to_timestamp",[this],"unixMicrosToTimestamp")}timestampToUnixMicros(){return new FunctionExpression("timestamp_to_unix_micros",[this],"timestampToUnixMicros")}unixMillisToTimestamp(){return new FunctionExpression("unix_millis_to_timestamp",[this],"unixMillisToTimestamp")}timestampToUnixMillis(){return new FunctionExpression("timestamp_to_unix_millis",[this],"timestampToUnixMillis")}unixSecondsToTimestamp(){return new FunctionExpression("unix_seconds_to_timestamp",[this],"unixSecondsToTimestamp")}timestampToUnixSeconds(){return new FunctionExpression("timestamp_to_unix_seconds",[this],"timestampToUnixSeconds")}timestampAdd(e,r){return new FunctionExpression("timestamp_add",[this,__PRIVATE_valueToDefaultExpr$1(e),__PRIVATE_valueToDefaultExpr$1(r)],"timestampAdd")}timestampSubtract(e,r){return new FunctionExpression("timestamp_subtract",[this,__PRIVATE_valueToDefaultExpr$1(e),__PRIVATE_valueToDefaultExpr$1(r)],"timestampSubtract")}timestampDiff(e,r){return new FunctionExpression("timestamp_diff",[this,__PRIVATE_fieldOrExpression$1(e),__PRIVATE_valueToDefaultExpr$1(r)],"timestampDiff")}timestampExtract(e,r){const i=[this,__PRIVATE_valueToDefaultExpr$1(e)];return r&&i.push(__PRIVATE_valueToDefaultExpr$1(r)),new FunctionExpression("timestamp_extract",i,"timestampExtract")}documentId(){return new FunctionExpression("document_id",[this],"documentId")}parent(){return new FunctionExpression("parent",[this],"parent")}substring(e,r){const i=__PRIVATE_valueToDefaultExpr$1(e);return new FunctionExpression("substring",void 0===r?[this,i]:[this,i,__PRIVATE_valueToDefaultExpr$1(r)],"substring")}arrayGet(e){return new FunctionExpression("array_get",[this,__PRIVATE_valueToDefaultExpr$1(e)],"arrayGet")}isError(){return new FunctionExpression("is_error",[this],"isError").asBoolean()}ifError(e){const r=new FunctionExpression("if_error",[this,__PRIVATE_valueToDefaultExpr$1(e)],"ifError");return e instanceof BooleanExpression?r.asBoolean():r}isAbsent(){return new FunctionExpression("is_absent",[this],"isAbsent").asBoolean()}mapRemove(e){return new FunctionExpression("map_remove",[this,__PRIVATE_valueToDefaultExpr$1(e)],"mapRemove")}mapMerge(e,...r){const i=__PRIVATE_valueToDefaultExpr$1(e),s=r.map(__PRIVATE_valueToDefaultExpr$1);return new FunctionExpression("map_merge",[this,i,...s],"mapMerge")}pow(e){return new FunctionExpression("pow",[this,__PRIVATE_valueToDefaultExpr$1(e)])}trunc(e){return void 0===e?new FunctionExpression("trunc",[this]):new FunctionExpression("trunc",[this,__PRIVATE_valueToDefaultExpr$1(e)],"trunc")}round(e){return void 0===e?new FunctionExpression("round",[this]):new FunctionExpression("round",[this,__PRIVATE_valueToDefaultExpr$1(e)],"round")}collectionId(){return new FunctionExpression("collection_id",[this])}length(){return new FunctionExpression("length",[this])}ln(){return new FunctionExpression("ln",[this])}sqrt(){return new FunctionExpression("sqrt",[this])}stringReverse(){return new FunctionExpression("string_reverse",[this])}ifAbsent(e){return new FunctionExpression("if_absent",[this,__PRIVATE_valueToDefaultExpr$1(e)],"ifAbsent")}ifNull(e){return new FunctionExpression("if_null",[this,__PRIVATE_valueToDefaultExpr$1(e)],"ifNull")}coalesce(e,...r){return new FunctionExpression("coalesce",[this,__PRIVATE_valueToDefaultExpr$1(e),...r.map(__PRIVATE_valueToDefaultExpr$1)],"coalesce")}join(e){return new FunctionExpression("join",[this,__PRIVATE_valueToDefaultExpr$1(e)],"join")}log10(){return new FunctionExpression("log10",[this])}arraySum(){return new FunctionExpression("sum",[this])}split(e){return new FunctionExpression("split",[this,__PRIVATE_valueToDefaultExpr$1(e)])}timestampTruncate(e,r){const i=[this,__PRIVATE_valueToDefaultExpr$1(e)];return r&&i.push(__PRIVATE_valueToDefaultExpr$1(r)),new FunctionExpression("timestamp_trunc",i)}ascending(){return ascending(this)}descending(){return descending(this)}as(e){return new AliasedExpression(this,e,"as")}}class AggregateFunction{constructor(e,r){this.name=e,this.params=r,this.exprType="AggregateFunction",this._protoValueType="ProtoValue"}static _create(e,r,i){const s=new AggregateFunction(e,r);return s._methodName=i,s}as(e){return new AliasedAggregate(this,e,"as")}_toProto(e){return{functionValue:{name:this.name,args:this.params.map((r=>r._toProto(e)))}}}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}):e,this.params.forEach((r=>r._readUserData(e)))}}class AliasedAggregate{constructor(e,r,i){this.aggregate=e,this.alias=r,this._methodName=i}_readUserData(e){this.aggregate._readUserData(e)}}class AliasedExpression{constructor(e,r,i){this.expr=e,this.alias=r,this._methodName=i,this.exprType="AliasedExpression",this.selectable=!0}_readUserData(e){this.expr._readUserData(e)}}class __PRIVATE_ListOfExprs extends Expression{constructor(e,r){super(),this.t=e,this._methodName=r,this.expressionType="ListOfExpressions"}_toProto(e){return{arrayValue:{values:this.t.map((r=>r._toProto(e)))}}}_readUserData(e){this.t.forEach((r=>r._readUserData(e)))}}class Field extends Expression{constructor(e,r){super(),this.fieldPath=e,this._methodName=r,this.expressionType="Field",this.selectable=!0}get _fieldPath(){return this.fieldPath}get fieldName(){return this.fieldPath.canonicalString()}get alias(){return this.fieldName}get expr(){return this}geoDistance(e){return new FunctionExpression("geo_distance",[this,__PRIVATE_valueToDefaultExpr$1(e)],"geoDistance")}_toProto(e){return{fieldReferenceValue:this.fieldPath.canonicalString()}}_readUserData(e){}}function field(e){return _field(e,"field")}function _field(e,r){return new Field("string"==typeof e?Z===e?function documentId$1(){return new D(Z)}()._internalPath:_("field",e):e._internalPath,r)}class Constant extends Expression{constructor(e,r){super(),this.value=e,this._methodName=r,this.expressionType="Constant"}static _fromProto(e){const r=new Constant(e,void 0);return r._protoValue=e,r}_toProto(e){return __PRIVATE_hardAssert(void 0!==this._protoValue,237),this._protoValue}_getValue(){return this._protoValue}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}):e,__PRIVATE_isFirestoreValue(this._protoValue)||(this._protoValue=__PRIVATE_parseData(this.value,e))}}function constant(e,r){return __PRIVATE__constant(e,"constant")}function __PRIVATE__constant(e,r){const i=new Constant(e,r);return"boolean"==typeof e?new __PRIVATE_BooleanConstant(i):i}class MapValue extends Expression{constructor(e,r){super(),this.i=e,this._methodName=r,this.expressionType="Constant"}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}):e,this.i.forEach((r=>{r._readUserData(e)}))}_toProto(e){return toMapValue(e,this.i)}}class FunctionExpression extends Expression{constructor(e,r,i,s){super(),this.name=e,this.params=r,this.expressionType="Function",this._optionsProto=void 0,void 0!==i&&(this._methodName=i),void 0!==s&&(this._options=s)}get _optionsUtil(){return new OptionsUtil({})}_toProto(e){const r={functionValue:{name:this.name,args:this.params.map((r=>r._toProto(e)))}};return this._optionsProto&&(r.functionValue.options=this._optionsProto),r}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}):e,this.params.forEach((r=>r._readUserData(e))),this._options&&(this._optionsProto=this._optionsUtil.getOptionsProto(e,this._options))}}class BooleanExpression extends Expression{get _methodName(){return this._expr._methodName}countIf(){return AggregateFunction._create("count_if",[this],"countIf")}not(){return new FunctionExpression("not",[this],"not").asBoolean()}conditional(e,r){return new FunctionExpression("conditional",[this,e,r],"conditional")}ifError(e){const r=__PRIVATE_valueToDefaultExpr$1(e),i=new FunctionExpression("if_error",[this,r],"ifError");return r instanceof BooleanExpression?i.asBoolean():i}_toProto(e){return this._expr._toProto(e)}_readUserData(e){this._expr._readUserData(e)}}class __PRIVATE_BooleanFunctionExpression extends BooleanExpression{constructor(e){super(),this._expr=e,this.expressionType="Function"}}class __PRIVATE_BooleanConstant extends BooleanExpression{constructor(e){super(),this._expr=e,this.expressionType="Constant"}_getValue(){return this._expr._getValue()}}class __PRIVATE_BooleanField extends BooleanExpression{constructor(e){super(),this._expr=e,this.expressionType="Field"}}function countIf(e){return e.countIf()}function arrayGet(e,r){return __PRIVATE_fieldOrExpression$1(e).arrayGet(__PRIVATE_valueToDefaultExpr$1(r))}function isError(e){return e.isError().asBoolean()}function ifError(e,r){return e instanceof BooleanExpression&&r instanceof BooleanExpression?e.ifError(r).asBoolean():e.ifError(__PRIVATE_valueToDefaultExpr$1(r))}function isAbsent(e){return __PRIVATE_fieldOrExpression$1(e).isAbsent()}function mapRemove(e,r){return __PRIVATE_fieldOrExpression$1(e).mapRemove(__PRIVATE_valueToDefaultExpr$1(r))}function mapMerge(e,r,...i){const s=__PRIVATE_valueToDefaultExpr$1(r),o=i.map(__PRIVATE_valueToDefaultExpr$1);return __PRIVATE_fieldOrExpression$1(e).mapMerge(s,...o)}function documentId(e){return __PRIVATE_valueToDefaultExpr$1(e).documentId()}function parent(e){return __PRIVATE_valueToDefaultExpr$1(e).parent()}function substring(e,r,i){const s=__PRIVATE_fieldOrExpression$1(e),o=__PRIVATE_valueToDefaultExpr$1(r),h=void 0===i?void 0:__PRIVATE_valueToDefaultExpr$1(i);return s.substring(o,h)}function add(e,r){return __PRIVATE_fieldOrExpression$1(e).add(__PRIVATE_valueToDefaultExpr$1(r))}function subtract(e,r){const i="string"==typeof e?field(e):e,s=__PRIVATE_valueToDefaultExpr$1(r);return i.subtract(s)}function multiply(e,r){return __PRIVATE_fieldOrExpression$1(e).multiply(__PRIVATE_valueToDefaultExpr$1(r))}function divide(e,r){const i="string"==typeof e?field(e):e,s=__PRIVATE_valueToDefaultExpr$1(r);return i.divide(s)}function mod(e,r){const i="string"==typeof e?field(e):e,s=__PRIVATE_valueToDefaultExpr$1(r);return i.mod(s)}function map(e){return __PRIVATE__map(e)}function __PRIVATE__map(e,r){const i=[];for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const s=e[r];i.push(constant(r)),i.push(__PRIVATE_valueToDefaultExpr$1(s))}return new FunctionExpression("map",i,"map")}function array(e){return function __PRIVATE__array(e,r){return new FunctionExpression("array",e.map((e=>__PRIVATE_valueToDefaultExpr$1(e))),r)}(e,"array")}function equal(e,r){const i=e instanceof Expression?e:field(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.equal(s)}function notEqual(e,r){const i=e instanceof Expression?e:field(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.notEqual(s)}function lessThan(e,r){const i=e instanceof Expression?e:field(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.lessThan(s)}function lessThanOrEqual(e,r){const i=e instanceof Expression?e:field(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.lessThanOrEqual(s)}function greaterThan(e,r){const i=e instanceof Expression?e:field(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.greaterThan(s)}function greaterThanOrEqual(e,r){const i=e instanceof Expression?e:field(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.greaterThanOrEqual(s)}function arrayConcat(e,r,...i){const s=i.map((e=>__PRIVATE_valueToDefaultExpr$1(e)));return __PRIVATE_fieldOrExpression$1(e).arrayConcat(__PRIVATE_fieldOrExpression$1(r),...s)}function arrayContains(e,r){const i=__PRIVATE_fieldOrExpression$1(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.arrayContains(s)}function arrayContainsAny(e,r){return __PRIVATE_fieldOrExpression$1(e).arrayContainsAny(r)}function arrayContainsAll(e,r){return __PRIVATE_fieldOrExpression$1(e).arrayContainsAll(r)}function arrayLength(e){return __PRIVATE_fieldOrExpression$1(e).arrayLength()}function equalAny(e,r){return __PRIVATE_fieldOrExpression$1(e).equalAny(r)}function notEqualAny(e,r){return __PRIVATE_fieldOrExpression$1(e).notEqualAny(r)}function xor(e,r,...i){return new FunctionExpression("xor",[e,r,...i],"xor").asBoolean()}function conditional(e,r,i){return new FunctionExpression("conditional",[e,r,i],"conditional")}function not(e){return e.not()}function logicalMaximum(e,r,...i){return __PRIVATE_fieldOrExpression$1(e).logicalMaximum(__PRIVATE_valueToDefaultExpr$1(r),...i.map((e=>__PRIVATE_valueToDefaultExpr$1(e))))}function logicalMinimum(e,r,...i){return __PRIVATE_fieldOrExpression$1(e).logicalMinimum(__PRIVATE_valueToDefaultExpr$1(r),...i.map((e=>__PRIVATE_valueToDefaultExpr$1(e))))}function exists(e){return __PRIVATE_fieldOrExpression$1(e).exists()}function reverse(e){return __PRIVATE_fieldOrExpression$1(e).reverse()}function byteLength(e){return __PRIVATE_fieldOrExpression$1(e).byteLength()}function exp(e){return __PRIVATE_fieldOrExpression$1(e).exp()}function ceil(e){return __PRIVATE_fieldOrExpression$1(e).ceil()}function floor(e){return __PRIVATE_fieldOrExpression$1(e).floor()}function countDistinct(e){return __PRIVATE_fieldOrExpression$1(e).countDistinct()}function charLength(e){return __PRIVATE_fieldOrExpression$1(e).charLength()}function like(e,r){const i=__PRIVATE_fieldOrExpression$1(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.like(s)}function regexContains(e,r){const i=__PRIVATE_fieldOrExpression$1(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.regexContains(s)}function arrayFilter(e,r,i){return __PRIVATE_fieldOrExpression$1(e).arrayFilter(r,i)}function arrayTransform(e,r,i){return __PRIVATE_fieldOrExpression$1(e).arrayTransform(r,i)}function arrayTransformWithIndex(e,r,i,s){return __PRIVATE_fieldOrExpression$1(e).arrayTransformWithIndex(r,i,s)}function arraySlice(e,r,i){return __PRIVATE_fieldOrExpression$1(e).arraySlice(r,i)}function arrayFirst(e){return __PRIVATE_fieldOrExpression$1(e).arrayFirst()}function arrayFirstN(e,r){return __PRIVATE_fieldOrExpression$1(e).arrayFirstN(__PRIVATE_valueToDefaultExpr$1(r))}function arrayLast(e){return __PRIVATE_fieldOrExpression$1(e).arrayLast()}function arrayLastN(e,r){return __PRIVATE_fieldOrExpression$1(e).arrayLastN(__PRIVATE_valueToDefaultExpr$1(r))}function arrayMaximum(e){return __PRIVATE_fieldOrExpression$1(e).arrayMaximum()}function arrayMaximumN(e,r){return __PRIVATE_fieldOrExpression$1(e).arrayMaximumN(__PRIVATE_valueToDefaultExpr$1(r))}function arrayMinimum(e){return __PRIVATE_fieldOrExpression$1(e).arrayMinimum()}function arrayMinimumN(e,r){return __PRIVATE_fieldOrExpression$1(e).arrayMinimumN(__PRIVATE_valueToDefaultExpr$1(r))}function arrayIndexOf(e,r){return __PRIVATE_fieldOrExpression$1(e).arrayIndexOf(__PRIVATE_valueToDefaultExpr$1(r))}function arrayLastIndexOf(e,r){return __PRIVATE_fieldOrExpression$1(e).arrayLastIndexOf(__PRIVATE_valueToDefaultExpr$1(r))}function arrayIndexOfAll(e,r){return __PRIVATE_fieldOrExpression$1(e).arrayIndexOfAll(__PRIVATE_valueToDefaultExpr$1(r))}function regexFind(e,r){const i=__PRIVATE_fieldOrExpression$1(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.regexFind(s)}function regexFindAll(e,r){const i=__PRIVATE_fieldOrExpression$1(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.regexFindAll(s)}function regexMatch(e,r){const i=__PRIVATE_fieldOrExpression$1(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.regexMatch(s)}function stringContains(e,r){const i=__PRIVATE_fieldOrExpression$1(e),s=__PRIVATE_valueToDefaultExpr$1(r);return i.stringContains(s)}function startsWith(e,r){return __PRIVATE_fieldOrExpression$1(e).startsWith(__PRIVATE_valueToDefaultExpr$1(r))}function endsWith(e,r){return __PRIVATE_fieldOrExpression$1(e).endsWith(__PRIVATE_valueToDefaultExpr$1(r))}function toLower(e){return __PRIVATE_fieldOrExpression$1(e).toLower()}function toUpper(e){return __PRIVATE_fieldOrExpression$1(e).toUpper()}function trim(e,r){return __PRIVATE_fieldOrExpression$1(e).trim(r)}function ltrim(e,r){return __PRIVATE_fieldOrExpression$1(e).ltrim(r)}function rtrim(e,r){return __PRIVATE_fieldOrExpression$1(e).rtrim(r)}function type(e){return __PRIVATE_fieldOrExpression$1(e).type()}function isType(e,r){return __PRIVATE_fieldOrExpression$1(e).isType(r)}function stringConcat(e,r,...i){return __PRIVATE_fieldOrExpression$1(e).stringConcat(__PRIVATE_valueToDefaultExpr$1(r),...i.map(__PRIVATE_valueToDefaultExpr$1))}function stringIndexOf(e,r){return __PRIVATE_fieldOrExpression$1(e).stringIndexOf(r)}function stringRepeat(e,r){return __PRIVATE_fieldOrExpression$1(e).stringRepeat(r)}function stringReplaceAll(e,r,i){return __PRIVATE_fieldOrExpression$1(e).stringReplaceAll(r,i)}function stringReplaceOne(e,r,i){return __PRIVATE_fieldOrExpression$1(e).stringReplaceOne(r,i)}function mapGet(e,r){return __PRIVATE_fieldOrExpression$1(e).mapGet(r)}function mapSet(e,r,i,...s){return __PRIVATE_fieldOrExpression$1(e).mapSet(r,i,...s)}function mapKeys(e){return __PRIVATE_fieldOrExpression$1(e).mapKeys()}function mapValues(e){return __PRIVATE_fieldOrExpression$1(e).mapValues()}function mapEntries(e){return __PRIVATE_fieldOrExpression$1(e).mapEntries()}function countAll(){return AggregateFunction._create("count",[],"count")}function count(e){return __PRIVATE_fieldOrExpression$1(e).count()}function sum(e){return __PRIVATE_fieldOrExpression$1(e).sum()}function average(e){return __PRIVATE_fieldOrExpression$1(e).average()}function minimum(e){return __PRIVATE_fieldOrExpression$1(e).minimum()}function maximum(e){return __PRIVATE_fieldOrExpression$1(e).maximum()}function first(e){return __PRIVATE_fieldOrExpression$1(e).first()}function last(e){return __PRIVATE_fieldOrExpression$1(e).last()}function arrayAgg(e){return __PRIVATE_fieldOrExpression$1(e).arrayAgg()}function arrayAggDistinct(e){return __PRIVATE_fieldOrExpression$1(e).arrayAggDistinct()}function cosineDistance(e,r){const i=__PRIVATE_fieldOrExpression$1(e),s=__PRIVATE_vectorToExpr$1(r);return i.cosineDistance(s)}function dotProduct(e,r){const i=__PRIVATE_fieldOrExpression$1(e),s=__PRIVATE_vectorToExpr$1(r);return i.dotProduct(s)}function euclideanDistance(e,r){const i=__PRIVATE_fieldOrExpression$1(e),s=__PRIVATE_vectorToExpr$1(r);return i.euclideanDistance(s)}function vectorLength(e){return __PRIVATE_fieldOrExpression$1(e).vectorLength()}function unixMicrosToTimestamp(e){return __PRIVATE_fieldOrExpression$1(e).unixMicrosToTimestamp()}function timestampToUnixMicros(e){return __PRIVATE_fieldOrExpression$1(e).timestampToUnixMicros()}function unixMillisToTimestamp(e){return __PRIVATE_fieldOrExpression$1(e).unixMillisToTimestamp()}function timestampToUnixMillis(e){return __PRIVATE_fieldOrExpression$1(e).timestampToUnixMillis()}function unixSecondsToTimestamp(e){return __PRIVATE_fieldOrExpression$1(e).unixSecondsToTimestamp()}function timestampToUnixSeconds(e){return __PRIVATE_fieldOrExpression$1(e).timestampToUnixSeconds()}function timestampAdd(e,r,i){const s=__PRIVATE_fieldOrExpression$1(e),o=__PRIVATE_valueToDefaultExpr$1(r),h=__PRIVATE_valueToDefaultExpr$1(i);return s.timestampAdd(o,h)}function timestampSubtract(e,r,i){const s=__PRIVATE_fieldOrExpression$1(e),o=__PRIVATE_valueToDefaultExpr$1(r),h=__PRIVATE_valueToDefaultExpr$1(i);return s.timestampSubtract(o,h)}function currentTimestamp(){return new FunctionExpression("current_timestamp",[],"currentTimestamp")}function and(e,r,...i){return new FunctionExpression("and",[e,r,...i],"and").asBoolean()}function or(e,r,...i){return new FunctionExpression("or",[e,r,...i],"xor").asBoolean()}function nor(e,r,...i){return new FunctionExpression("nor",[e,r,...i],"nor").asBoolean()}function pow(e,r){return __PRIVATE_fieldOrExpression$1(e).pow(r)}function rand(){return new FunctionExpression("rand",[],"rand")}function round(e,r){return void 0===r?__PRIVATE_fieldOrExpression$1(e).round():__PRIVATE_fieldOrExpression$1(e).round(__PRIVATE_valueToDefaultExpr$1(r))}function trunc(e,r){return void 0===r?__PRIVATE_fieldOrExpression$1(e).trunc():__PRIVATE_fieldOrExpression$1(e).trunc(__PRIVATE_valueToDefaultExpr$1(r))}function collectionId(e){return __PRIVATE_fieldOrExpression$1(e).collectionId()}function length(e){return __PRIVATE_fieldOrExpression$1(e).length()}function ln(e){return __PRIVATE_fieldOrExpression$1(e).ln()}function log(e,r){return new FunctionExpression("log",[__PRIVATE_fieldOrExpression$1(e),__PRIVATE_valueToDefaultExpr$1(r)])}function sqrt(e){return __PRIVATE_fieldOrExpression$1(e).sqrt()}function stringReverse(e){return __PRIVATE_fieldOrExpression$1(e).stringReverse()}function concat(e,r,...i){return new FunctionExpression("concat",[__PRIVATE_fieldOrExpression$1(e),__PRIVATE_valueToDefaultExpr$1(r),...i.map(__PRIVATE_valueToDefaultExpr$1)])}function abs(e){return __PRIVATE_fieldOrExpression$1(e).abs()}function ifAbsent(e,r){return __PRIVATE_fieldOrExpression$1(e).ifAbsent(__PRIVATE_valueToDefaultExpr$1(r))}function ifNull(e,r){return __PRIVATE_fieldOrExpression$1(e).ifNull(r)}function coalesce(e,r,...i){return __PRIVATE_fieldOrExpression$1(e).coalesce(r,...i)}function switchOn(e,r,...i){return new FunctionExpression("switch_on",[__PRIVATE_valueToDefaultExpr$1(e),__PRIVATE_valueToDefaultExpr$1(r),...i.map(__PRIVATE_valueToDefaultExpr$1)],"switchOn")}function join(e,r){return __PRIVATE_fieldOrExpression$1(e).join(__PRIVATE_valueToDefaultExpr$1(r))}function log10(e){return __PRIVATE_fieldOrExpression$1(e).log10()}function arraySum(e){return __PRIVATE_fieldOrExpression$1(e).arraySum()}function split(e,r){return __PRIVATE_fieldOrExpression$1(e).split(__PRIVATE_valueToDefaultExpr$1(r))}function timestampTruncate(e,r,i){const s=__PRIVATE_isString(r)?__PRIVATE_valueToDefaultExpr$1(r):r;return __PRIVATE_fieldOrExpression$1(e).timestampTruncate(s,i)}function variable(e){return new __PRIVATE_VariableExpression(e)}class __PRIVATE_VariableExpression extends Expression{constructor(e){super(),this.name=e,this.expressionType="Variable"}_toProto(e){return{variableReferenceValue:this.name}}_readUserData(e){}}function currentDocument(){return new FunctionExpression("current_document",[])}class __PRIVATE_PipelineValueExpression extends Expression{constructor(e){super(),this.pipeline=e,this.expressionType="PipelineValue"}_toProto(e){return __PRIVATE_toPipelineValue(this.pipeline._toProto(e))}_readUserData(e){this.pipeline._readUserData(e)}}function timestampDiff(e,r,i){const s=__PRIVATE_fieldOrExpression$1(e),o=__PRIVATE_fieldOrExpression$1(r),h=__PRIVATE_valueToDefaultExpr$1(i);return s.timestampDiff(o,h)}function timestampExtract(e,r,i){return __PRIVATE_fieldOrExpression$1(e).timestampExtract(__PRIVATE_valueToDefaultExpr$1(r),i)}function documentMatches(e){return new FunctionExpression("document_matches",[__PRIVATE_valueToDefaultExpr$1(e)],"documentMatches").asBoolean()}function score(){return new FunctionExpression("score",[],"score")}function geoDistance(e,r){return __PRIVATE_toField(e).geoDistance(r)}function ascending(e){return new Ordering(__PRIVATE_fieldOrExpression$1(e),"ascending","ascending")}function descending(e){return new Ordering(__PRIVATE_fieldOrExpression$1(e),"descending","descending")}class Ordering{constructor(e,r,i){this.expr=e,this.direction=r,this._methodName=i,this._protoValueType="ProtoValue"}_toProto(e){return{mapValue:{fields:{direction:__PRIVATE_toStringValue(this.direction),expression:this.expr._toProto(e)}}}}_readUserData(e){this.expr._readUserData(e)}}function __PRIVATE_isSelectable(e){const r=e;return r.selectable&&__PRIVATE_isString(r.alias)&&__PRIVATE_isExpr(r.expr)}function __PRIVATE_isOrdering(e){const r=e;return null!=r&&__PRIVATE_isExpr(r.expr)&&("ascending"===r.direction||"descending"===r.direction)}function __PRIVATE_isAliasedAggregate(e){const r=e;return __PRIVATE_isString(r.alias)&&r.aggregate instanceof AggregateFunction}function __PRIVATE_isExpr(e){return e instanceof Expression}function __PRIVATE_isBooleanExpr(e){return e instanceof BooleanExpression}function __PRIVATE_isAliasedExpr(e){return e instanceof AliasedExpression}function __PRIVATE_isField(e){return e instanceof Field}function __PRIVATE_toField(e){return __PRIVATE_isString(e)?field(e):e}function __PRIVATE_selectablesToMap(e){return new Map(Object.entries(__PRIVATE_selectablesToObject(e)))}function __PRIVATE_selectablesToObject(e){const r={};for(const i of e){let e,s;if("string"==typeof i?(e=i,s=field(i)):i instanceof Field||i instanceof AliasedExpression?(e=i.alias,s=i.expr):z(21273,{selectable:i}),void 0!==r[e])throw new k("invalid-argument",`Duplicate alias or field '${e}'`);r[e]=s}return r}function __PRIVATE_fieldOrExpression(e){return __PRIVATE_isString(e)?field(e):function __PRIVATE_valueToDefaultExpr(e){let r;return __PRIVATE_isFirestoreValue(e)?constant(e):e instanceof Expression?e:(r=__PRIVATE_isPlainObject(e)?map(e):e instanceof Array?array(e):function __PRIVATE_isPipeline$1(e){return"object"==typeof e&&null!==e&&"function"==typeof e.toArrayExpression}(e)?function pipelineValue(e){return new __PRIVATE_PipelineValueExpression(e)}(e):__PRIVATE__constant(e,void 0),r)}(e)}class Stage{constructor(e){this.optionsProto=void 0,({rawOptions:this.rawOptions,...this.knownOptions}=e)}_readUserData(e){this.optionsProto=this._optionsUtil.getOptionsProto(e,this.knownOptions,this.rawOptions)}_toProto(e){return{name:this._name,options:this.optionsProto}}}class __PRIVATE_AddFields extends Stage{get _name(){return"add_fields"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.fields=e}_toProto(e){return{...super._toProto(e),args:[toMapValue(e,this.fields)]}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.fields,e)}}class __PRIVATE_RemoveFields extends Stage{get _name(){return"remove_fields"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.fields=e}_toProto(e){return{...super._toProto(e),args:this.fields.map((r=>r._toProto(e)))}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.fields,e)}}class __PRIVATE_Define extends Stage{get _name(){return"let"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.o=e}_toProto(e){return{...super._toProto(e),args:[toMapValue(e,this.o)]}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.o,e)}}class __PRIVATE_Aggregate extends Stage{get _name(){return"aggregate"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r,i){super(i),this.groups=e,this.accumulators=r}_toProto(e){return{...super._toProto(e),args:[toMapValue(e,this.accumulators),toMapValue(e,this.groups)]}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.groups,e),__PRIVATE_readUserDataHelper(this.accumulators,e)}}class __PRIVATE_Distinct extends Stage{get _name(){return"distinct"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.groups=e}_toProto(e){return{...super._toProto(e),args:[toMapValue(e,this.groups)]}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.groups,e)}}class __PRIVATE_CollectionSource extends Stage{get _name(){return"collection"}get _optionsUtil(){return new OptionsUtil({forceIndex:{serverName:"force_index"}})}constructor(e,r){super(r),this.u=__PRIVATE_normalizeCollectionPath(e)}_toProto(e){return{...super._toProto(e),args:[{referenceValue:this.u}]}}_readUserData(e){super._readUserData(e)}}class __PRIVATE_CollectionGroupSource extends Stage{get _name(){return"collection_group"}get _optionsUtil(){return new OptionsUtil({forceIndex:{serverName:"force_index"}})}constructor(e,r){super(r),this.collectionId=e}_toProto(e){return{...super._toProto(e),args:[{referenceValue:""},{stringValue:this.collectionId}]}}_readUserData(e){super._readUserData(e)}}class __PRIVATE_SubcollectionSource extends Stage{get _name(){return"subcollection"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.path=e}_toProto(e){return{...super._toProto(e),args:[{stringValue:this.path}]}}_readUserData(e){super._readUserData(e)}}class __PRIVATE_DatabaseSource extends Stage{get _name(){return"database"}get _optionsUtil(){return new OptionsUtil({})}_toProto(e){return{...super._toProto(e)}}_readUserData(e){super._readUserData(e)}}class __PRIVATE_DocumentsSource extends Stage{get _name(){return"documents"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){if(super(r),!e||0===e.length)throw new k(b,"Empty document paths are not allowed in DocumentsSource");const i=e.map((e=>e.startsWith("/")?e:"/"+e)),s=new Set(i);if(s.size!==i.length)throw new k(b,"Duplicate document paths are not allowed in DocumentsSource");this._=i,this.l=s}_toProto(e){return{...super._toProto(e),args:this._.map((e=>({referenceValue:e})))}}_readUserData(e){super._readUserData(e)}}class __PRIVATE_LiteralsSource extends Stage{get _name(){return"literals"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r={}){super(r),this.documents=e}_readUserData(e){super._readUserData(e),this.p=this.documents.map((r=>function __PRIVATE_encodeLiteralDocument(e,r){const i=new Map;for(const s of Object.keys(e)){const o=r.childContextForField(s),h=e[s];void 0===h&&o.ignoreUndefinedProperties||i.set(s,__PRIVATE_encodeLiteralValue(h,o))}return i}(r,e)))}_toProto(e){const r=(this.p??[]).map((r=>toMapValue(e,r)));return{...super._toProto(e),args:r}}}function __PRIVATE_encodeLiteralValue(e,r){if(__PRIVATE_isExpr(e))return e._readUserData(r),e;if(__PRIVATE_isPlainObject(e)){const i=[],s=e;for(const e of Object.keys(s)){const o=r.childContextForField(e),h=s[e];if(void 0===h&&o.ignoreUndefinedProperties)continue;const E=__PRIVATE__constant(e,"literals");E._readUserData(o);const T=__PRIVATE_encodeLiteralValue(h,o);i.push(E,T)}return new FunctionExpression("map",i)}if(Array.isArray(e)){const i=e.map((e=>{if(void 0===e)throw r.createError("Unsupported field value: undefined");return __PRIVATE_encodeLiteralValue(e,r)}));return new FunctionExpression("array",i)}{const i=__PRIVATE__constant(e,"literals");return i._readUserData(r),i}}class __PRIVATE_Where extends Stage{get _name(){return"where"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.condition=e}_toProto(e){return{...super._toProto(e),args:[this.condition._toProto(e)]}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.condition,e)}}class __PRIVATE_FindNearest extends Stage{get _name(){return"find_nearest"}get _optionsUtil(){return new OptionsUtil({limit:{serverName:"limit"},distanceField:{serverName:"distance_field"}})}constructor(e,r,i,s){super(s),this.vectorValue=e,this.field=r,this.distanceMeasure=i}_toProto(e){return{...super._toProto(e),args:[this.field._toProto(e),this.vectorValue._toProto(e),__PRIVATE_toStringValue(this.distanceMeasure)]}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.vectorValue,e),__PRIVATE_readUserDataHelper(this.field,e)}}class __PRIVATE_Limit extends Stage{get _name(){return"limit"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){__PRIVATE_hardAssert(!isNaN(e)&&e!==1/0&&e!==-1/0,34860),super(r),this.limit=e}_toProto(e){return{...super._toProto(e),args:[toNumber(e,this.limit)]}}}class __PRIVATE_Offset extends Stage{get _name(){return"offset"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.offset=e}_toProto(e){return{...super._toProto(e),args:[toNumber(e,this.offset)]}}}class __PRIVATE_Select extends Stage{get _name(){return"select"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.selections=e}_toProto(e){return{...super._toProto(e),args:[toMapValue(e,this.selections)]}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.selections,e)}}class __PRIVATE_Sort extends Stage{get _name(){return"sort"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.orderings=e}_toProto(e){return{...super._toProto(e),args:this.orderings.map((r=>r._toProto(e)))}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.orderings,e)}}class __PRIVATE_Sample extends Stage{get _name(){return"sample"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r,i){super(i),this.rate=e,this.mode=r}_toProto(e){return{...super._toProto(e),args:[toNumber(e,this.rate),__PRIVATE_toStringValue(this.mode)]}}_readUserData(e){super._readUserData(e)}}class __PRIVATE_Union extends Stage{get _name(){return"union"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.other=e}_toProto(e){return{...super._toProto(e),args:[__PRIVATE_toPipelineValue(this.other._toProto(e))]}}_readUserData(e){this.other._readUserData(e),super._readUserData(e)}}class __PRIVATE_Unnest extends Stage{get _name(){return"unnest"}get _optionsUtil(){return new OptionsUtil({indexField:{serverName:"index_field"}})}constructor(e,r,i){super(i),this.alias=e,this.expr=r}_toProto(e){return{...super._toProto(e),args:[this.expr._toProto(e),field(this.alias)._toProto(e)]}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.expr,e)}}class __PRIVATE_Replace extends Stage{get _name(){return"replace_with"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r){super(r),this.map=e}_toProto(e){return{...super._toProto(e),args:[this.map._toProto(e),__PRIVATE_toStringValue(__PRIVATE_Replace.T)]}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.map,e)}}__PRIVATE_Replace.T="full_replace";class __PRIVATE_Search extends Stage{constructor(e){super(e),this.h=e}get _name(){return"search"}get _optionsUtil(){return new OptionsUtil({query:{serverName:"query"},limit:{serverName:"limit"},retrievalDepth:{serverName:"retrieval_depth"},sort:{serverName:"sort"},addFields:{serverName:"add_fields"},select:{serverName:"select"},offset:{serverName:"offset"},A:{serverName:"query_enhancement"},languageCode:{serverName:"language_code"}})}_toProto(e){return{...super._toProto(e),args:[]}}_readUserData(e){__PRIVATE_readUserDataHelper(this.h.query,e),this.h.addFields&&__PRIVATE_readUserDataHelper(this.h.addFields,e),this.h.select&&__PRIVATE_readUserDataHelper(this.h.select,e),this.h.sort&&__PRIVATE_readUserDataHelper(this.h.sort,e),super._readUserData(e)}}class __PRIVATE_RawStage extends Stage{constructor(e,r,i){super({rawOptions:i}),this.name=e,this.params=r}_toProto(e){return{name:this.name,args:this.params.map((r=>r._toProto(e))),options:this.optionsProto}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.params,e)}get _name(){return this.name}get _optionsUtil(){return new OptionsUtil({})}}class Delete extends Stage{get _name(){return"delete"}get _optionsUtil(){return new OptionsUtil({})}constructor(e={}){super(e)}_toProto(e){return{...super._toProto(e),args:[]}}}class Update extends Stage{get _name(){return"update"}get _optionsUtil(){return new OptionsUtil({})}constructor(e,r={}){const{transformedFields:i,...s}=r;super(s),this.transformedFields=e}_toProto(e){const r=[];return this.transformedFields&&this.transformedFields.size>0?r.push(toMapValue(e,this.transformedFields)):r.push(toMapValue(e,new Map)),{...super._toProto(e),args:r}}_readUserData(e){super._readUserData(e),this.transformedFields&&__PRIVATE_readUserDataHelper(this.transformedFields,e)}}class __PRIVATE_Insert extends Stage{get _name(){return"insert"}get _optionsUtil(){return new OptionsUtil({})}constructor(e={}){const{collection:r,documentIdExpression:i,...s}=e;super(s),void 0!==r&&(__PRIVATE_validateNonEmptyArgument("insert","collection path","string"==typeof r?r:r.path),this.collectionPath=__PRIVATE_normalizeCollectionPath(r)),i&&(this.P=__PRIVATE_fieldOrExpression(i))}_toProto(e){const r=super._toProto(e),i={};return this.collectionPath&&(i.collection={referenceValue:this.collectionPath}),this.P&&(i.document_id=this.P._toProto(e)),r.options&&Object.assign(i,r.options),{...r,options:Object.keys(i).length>0?i:void 0,args:[]}}_readUserData(e){super._readUserData(e),this.P&&__PRIVATE_readUserDataHelper(this.P,e)}}class __PRIVATE_Upsert extends Stage{get _name(){return"upsert"}get _optionsUtil(){return new OptionsUtil({})}constructor(e={}){const{collection:r,documentIdExpression:i,additionalFields:s,...o}=e;super(o),this.additionalFields=__PRIVATE_selectablesToMap(s??[]),void 0!==r&&(__PRIVATE_validateNonEmptyArgument("upsert","collection path","string"==typeof r?r:r.path),this.collectionPath=__PRIVATE_normalizeCollectionPath(r)),i&&(this.P=__PRIVATE_fieldOrExpression(i))}_toProto(e){const r=super._toProto(e),i={};this.collectionPath&&(i.collection={referenceValue:this.collectionPath}),this.P&&(i.document_id=this.P._toProto(e)),r.options&&Object.assign(i,r.options);const s=[toMapValue(e,this.additionalFields)];return{...r,options:Object.keys(i).length>0?i:void 0,args:s}}_readUserData(e){super._readUserData(e),__PRIVATE_readUserDataHelper(this.additionalFields,e),this.P&&__PRIVATE_readUserDataHelper(this.P,e)}}function __PRIVATE_normalizeCollectionPath(e){const r="string"==typeof e?e:e.path;return r.startsWith("/")?r:"/"+r}function __PRIVATE_readUserDataHelper(e,r){return function __PRIVATE_isUserData(e){return"function"==typeof e._readUserData}(e)?e._readUserData(r):Array.isArray(e)||e instanceof Map?e.forEach((e=>e._readUserData(r))):Object.values(e).forEach((e=>e._readUserData(r))),e}class Pipeline{constructor(e,r,i,s){this._db=e,this.userDataReader=r,this._userDataWriter=i,this.stages=s}_readUserData(e){this.stages.forEach((r=>{const i=e.contextWith({methodName:r._name});r._readUserData(i)}))}addFields(e,...r){let i,s;__PRIVATE_isSelectable(e)?(i=[e,...r],s={}):({fields:i,...s}=e);const o=__PRIVATE_selectablesToMap(i),h=new __PRIVATE_AddFields(o,s);return this._addStage(h)}removeFields(e,...r){const i=__PRIVATE_isField(e)||__PRIVATE_isString(e)?{}:e,s=(__PRIVATE_isField(e)||__PRIVATE_isString(e)?[e,...r]:e.fields).map((e=>__PRIVATE_isString(e)?field(e):e)),o=new __PRIVATE_RemoveFields(s,i);return this._addStage(o)}define(e,...r){const i=__PRIVATE_isAliasedExpr(e)?{}:e,s=__PRIVATE_selectablesToMap(__PRIVATE_isAliasedExpr(e)?[e,...r]:e.variables),o=new __PRIVATE_Define(s,i);return this._addStage(o)}toArrayExpression(){return new FunctionExpression("array",[__PRIVATE_fieldOrExpression(this)])}toScalarExpression(){return new FunctionExpression("scalar",[__PRIVATE_fieldOrExpression(this)])}select(e,...r){const i=__PRIVATE_isSelectable(e)||__PRIVATE_isString(e)?{}:e,s=__PRIVATE_selectablesToMap(__PRIVATE_isSelectable(e)||__PRIVATE_isString(e)?[e,...r]:e.selections),o=new __PRIVATE_Select(s,i);return this._addStage(o)}where(e){const r=__PRIVATE_isBooleanExpr(e)?{}:e,i=__PRIVATE_isBooleanExpr(e)?e:e.condition,s=new __PRIVATE_Where(i,r);return this._addStage(s)}offset(e){let r,i;__PRIVATE_isNumber(e)?(r={},i=e):(r=e,i=e.offset);const s=new __PRIVATE_Offset(i,r);return this._addStage(s)}limit(e){const r=__PRIVATE_isNumber(e)?{}:e,i=__PRIVATE_isNumber(e)?e:e.limit,s=new __PRIVATE_Limit(i,r);return this._addStage(s)}distinct(e,...r){const i=__PRIVATE_isString(e)||__PRIVATE_isSelectable(e)?{}:e,s=__PRIVATE_selectablesToMap(__PRIVATE_isString(e)||__PRIVATE_isSelectable(e)?[e,...r]:e.groups),o=new __PRIVATE_Distinct(s,i);return this._addStage(o)}aggregate(e,...r){const i=__PRIVATE_isAliasedAggregate(e)?{}:e,s=__PRIVATE_isAliasedAggregate(e)?[e,...r]:e.accumulators,o=__PRIVATE_isAliasedAggregate(e)?[]:e.groups??[],h=function __PRIVATE_aliasedAggregateToMap(e){return e.reduce(((e,r)=>{if(void 0!==e.get(r.alias))throw new k("invalid-argument",`Duplicate alias or field '${r.alias}'`);return e.set(r.alias,r.aggregate),e}),new Map)}(s),E=__PRIVATE_selectablesToMap(o),T=new __PRIVATE_Aggregate(E,h,i);return this._addStage(T)}findNearest(e){const r=__PRIVATE_toField(e.field),i=function __PRIVATE_vectorToExpr(e){if(e instanceof Expression)return e;if(e instanceof VectorValue)return constant(e);if(Array.isArray(e))return constant(vector(e));throw new Error("Unsupported value: "+typeof e)}(e.vectorValue),s={distanceField:e.distanceField?__PRIVATE_toField(e.distanceField):void 0,limit:e.limit,rawOptions:e.rawOptions},o=new __PRIVATE_FindNearest(i,r,e.distanceMeasure,s);return this._addStage(o)}search(e){const r=e.addFields?__PRIVATE_selectablesToObject(e.addFields):void 0,i=__PRIVATE_isExpr(e.query)?e.query:documentMatches(e.query),s=__PRIVATE_isOrdering(e.sort)?[e.sort]:e.sort,o={...e,addFields:r,select:void 0,query:i,sort:s},h=new __PRIVATE_Search(o);return this._addStage(h)}sort(e,...r){const i=__PRIVATE_isOrdering(e)?{}:e,s=__PRIVATE_isOrdering(e)?[e,...r]:e.orderings,o=new __PRIVATE_Sort(s,i);return this._addStage(o)}replaceWith(e){const r=__PRIVATE_isString(e)||__PRIVATE_isExpr(e)?{}:e,i=__PRIVATE_fieldOrExpression(__PRIVATE_isString(e)||__PRIVATE_isExpr(e)?e:e.map),s=new __PRIVATE_Replace(i,r);return this._addStage(s)}sample(e){const r=__PRIVATE_isNumber(e)?{}:e;let i,s;__PRIVATE_isNumber(e)?(i=e,s="documents"):__PRIVATE_isNumber(e.documents)?(i=e.documents,s="documents"):(i=e.percentage,s="percent");const o=new __PRIVATE_Sample(i,s,r);return this._addStage(o)}union(e){let r,i;!function __PRIVATE_isPipeline(e){return e instanceof Pipeline}(e)?({other:i,...r}=e):(r={},i=e);const s=new __PRIVATE_Union(i,r);return this._addStage(s)}unnest(e,r){let i,s,o;__PRIVATE_isSelectable(e)?(i={},s=e,o=r):({selectable:s,indexField:o,...i}=e);const h=s.alias,E=s.expr;__PRIVATE_isString(o)&&(i.indexField=_field(o,"unnest"));const T=new __PRIVATE_Unnest(h,E,i);return this._addStage(T)}rawStage(e,r,i){const s=r.map((e=>e instanceof Expression||e instanceof AggregateFunction?e:__PRIVATE_isPlainObject(e)?function __PRIVATE__mapValue(e){const r=new Map;for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)){const s=e[i];r.set(i,__PRIVATE_valueToDefaultExpr$1(s))}return new MapValue(r,void 0)}(e):__PRIVATE__constant(e,"rawStage"))),o=new __PRIVATE_RawStage(e,s,i??{});return this._addStage(o)}delete(e={}){return this._addStage(new Delete(e))}update(e,...r){let i,s={};__PRIVATE_isAliasedExpr(e)?i=[e,...r]:e&&({transformedFields:i,...s}=e);const o=i&&i.length>0?__PRIVATE_selectablesToMap(i):void 0;return this._addStage(new Update(o,s))}insert(e={}){return this._validateCollectionReference(e.collection),this._addStage(new __PRIVATE_Insert(e))}upsert(e,...r){let i={};return __PRIVATE_isAliasedExpr(e)?i={additionalFields:[e,...r]}:e&&(i=e),this._validateCollectionReference(i.collection),this._addStage(new __PRIVATE_Upsert(i))}_validateCollectionReference(e){if(!this._db||!__PRIVATE_isCollectionReference(e))return;const r=e.firestore._databaseId,i=this._db._databaseId;if(!r.isEqual(i))throw new k(b,`Invalid CollectionReference. The project ID ("${r.projectId}") or the database ("${r.database}") does not match the project ID ("${i.projectId}") and database ("${i.database}") of the target database of this Pipeline.`)}_toProto(e){return{stages:this.stages.map((r=>r._toProto(e)))}}_addStage(e){const r=this.stages.map((e=>e));return r.push(e),this.newPipeline(this._db,r)}newPipeline(e,r){return new Pipeline(e,this.userDataReader,this._userDataWriter,r)}}function __PRIVATE_toPipelineBooleanExpr(e){if(e instanceof FieldFilter){const r=field(e.field.toString()),i=e.value;switch(e.op){case"<":return and(r.exists(),r.lessThan(Constant._fromProto(i)));case"<=":return and(r.exists(),r.lessThanOrEqual(Constant._fromProto(i)));case">":return and(r.exists(),r.greaterThan(Constant._fromProto(i)));case">=":return and(r.exists(),r.greaterThanOrEqual(Constant._fromProto(i)));case"==":return and(r.exists(),r.equal(Constant._fromProto(i)));case"!=":return r.notEqual(Constant._fromProto(i));case"array-contains":return and(r.exists(),r.arrayContains(Constant._fromProto(i)));case"in":{const e=i?.arrayValue?.values?.map((e=>Constant._fromProto(e)));return e?1===e.length?and(r.exists(),r.equal(e[0])):and(r.exists(),r.equalAny(e)):and(r.exists(),r.equalAny([]))}case"array-contains-any":{const e=i?.arrayValue?.values?.map((e=>Constant._fromProto(e)));return and(r.exists(),r.arrayContainsAny(e))}case"not-in":{const e=i?.arrayValue?.values?.map((e=>Constant._fromProto(e)));return e?1===e.length?r.notEqual(e[0]):r.notEqualAny(e):r.notEqualAny([])}default:z(36935)}}else if(e instanceof CompositeFilter)switch(e.op){case"and":{const r=e.getFilters().map((e=>__PRIVATE_toPipelineBooleanExpr(e)));return and(r[0],r[1],...r.slice(2))}case"or":{const r=e.getFilters().map((e=>__PRIVATE_toPipelineBooleanExpr(e)));return or(r[0],r[1],...r.slice(2))}default:z(35306)}throw new Error(`Failed to convert filter to pipeline conditions: ${e}`)}function __PRIVATE_toPipelineStages(e,r){let i;i=function __PRIVATE_isCollectionGroupQuery(e){return null!==e.collectionGroup}(e)?r.pipeline().collectionGroup(e.collectionGroup):function __PRIVATE_isDocumentQuery(e){return C.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}(e)?r.pipeline().documents([doc(r,e.path.canonicalString())]):r.pipeline().collection(e.path.canonicalString());for(const r of e.filters)i=i.where(__PRIVATE_toPipelineBooleanExpr(r));const s=function __PRIVATE_queryNormalizedOrderBy(e){const r=__PRIVATE_debugCast(e);if(null===r.St){r.St=[];const e=new Set;for(const i of r.explicitOrderBy)r.St.push(i),e.add(i.field.canonicalString());const i=r.explicitOrderBy.length>0?r.explicitOrderBy[r.explicitOrderBy.length-1].dir:"asc",s=function __PRIVATE_getInequalityFilterFields(e){let r=new SortedSet(te.comparator);return e.filters.forEach((e=>{e.getFlattenedFilters().forEach((e=>{e.isInequality()&&(r=r.add(e.field))}))})),r}(r);s.forEach((s=>{e.has(s.canonicalString())||s.isKeyField()||r.St.push(new OrderBy(s,i))})),e.has(te.keyField().canonicalString())||r.St.push(new OrderBy(te.keyField(),i))}return r.St}(e),o=s.map((e=>field(e.field.canonicalString()).exists()));i=o.length>1?i.where(and(o[0],o[1],...o.slice(2))):i.where(o[0]);const h=s.map((e=>"asc"===e.dir?field(e.field.canonicalString()).ascending():field(e.field.canonicalString()).descending()));if(h.length>0)if("L"===e.limitType){const r=function __PRIVATE_reverseOrderings(e){return e.map((e=>new Ordering(e.expr,"ascending"===e.direction?"descending":"ascending",void 0)))}(h);i=i.sort(r[0],...r.slice(1)),null!==e.startAt&&(i=i.where(__PRIVATE_whereConditionsFromCursor(e.startAt,h,"after"))),null!==e.endAt&&(i=i.where(__PRIVATE_whereConditionsFromCursor(e.endAt,h,"before"))),i=i.limit(e.limit),i=i.sort(h[0],...h.slice(1))}else i=i.sort(h[0],...h.slice(1)),null!==e.startAt&&(i=i.where(__PRIVATE_whereConditionsFromCursor(e.startAt,h,"after"))),null!==e.endAt&&(i=i.where(__PRIVATE_whereConditionsFromCursor(e.endAt,h,"before"))),null!==e.limit&&(i=i.limit(e.limit));return i.stages}function __PRIVATE_whereConditionsFromCursor(e,r,i){const s="before"===i?lessThan:greaterThan,o=e.position.map((e=>Constant._fromProto(e))),h=o.length;let E=r[h-1].expr,T=o[h-1],V=s(E,T);e.inclusive&&(V=or(V,E.equal(T)));for(let e=h-2;e>=0;e--)E=r[e].expr,T=o[e],V=or(s(E,T),and(E.equal(T),V));return V}class PipelineSource{constructor(e,r,i){this.databaseId=e,this.userDataReader=r,this._createPipeline=i}collection(e){const r=__PRIVATE_isString(e)||__PRIVATE_isCollectionReference(e)?{}:e,i=__PRIVATE_isString(e)||__PRIVATE_isCollectionReference(e)?e:e.collection;__PRIVATE_isCollectionReference(i)&&this._validateReference(i);const s=__PRIVATE_isString(i)?i:i.path,o=new __PRIVATE_CollectionSource(s,r),h=this.userDataReader.createContext(3,"collection");return o._readUserData(h),this._createPipeline([o])}collectionGroup(e){let r,i;__PRIVATE_isString(e)?(r=e,i={}):({collectionId:r,...i}=e);const s=new __PRIVATE_CollectionGroupSource(r,i),o=this.userDataReader.createContext(3,"collectionGroup");return s._readUserData(o),this._createPipeline([s])}database(e){const r=new __PRIVATE_DatabaseSource(e=e??{}),i=this.userDataReader.createContext(3,"database");return r._readUserData(i),this._createPipeline([r])}documents(e){let r,i;Array.isArray(e)?(i=e,r={}):({docs:i,...r}=e),i.filter((e=>e instanceof DocumentReference)).forEach((e=>this._validateReference(e)));const s=i.map((e=>__PRIVATE_isString(e)?e:e.path)),o=new __PRIVATE_DocumentsSource(s,r),h=this.userDataReader.createContext(3,"documents");return o._readUserData(h),this._createPipeline([o])}literals(e){let r,i={};if(Array.isArray(e))r=e;else{if(!__PRIVATE_isPlainObject(e)||!Array.isArray(e.documents))throw new k(b,"Function literals() requires an array of document objects or a LiteralsStageOptions object with a documents array.");({documents:r,...i}=e)}const s=new __PRIVATE_LiteralsSource(r,i),o=this.userDataReader.createContext(3,"literals");return s._readUserData(o),this._createPipeline([s])}createFrom(e){return this._createPipeline(__PRIVATE_toPipelineStages(e._query,e.firestore))}_validateReference(e){const r=e.firestore._databaseId;if(!r.isEqual(this.databaseId))throw new k(b,`Invalid ${e instanceof CollectionReference?"CollectionReference":"DocumentReference"}. The project ID ("${r.projectId}") or the database ("${r.database}") does not match the project ID ("${this.databaseId.projectId}") and database ("${this.databaseId.database}") of the target database of this Pipeline.`)}}function subcollection(e){let r,i;__PRIVATE_isString(e)?(r=e,i={}):({path:r,...i}=e);const s=new __PRIVATE_SubcollectionSource(r,i);return new Pipeline(void 0,void 0,void 0,[s])}class PipelineSnapshot{constructor(e,r,i){this._pipeline=e,this._executionTime=i,this._results=r}get results(){return this._results}get executionTime(){if(void 0===this._executionTime)throw new Error("'executionTime' is expected to exist, but it is undefined");return this._executionTime}}class PipelineResult{constructor(e,r,i,s,o,h,E){this._ref=i,this._userDataWriter=e,this._createTime=s,this._updateTime=o,this._fields=r,this._metadata=h,this._listenOptions=E}static fromDocument(e,r,i,s,o){return new PipelineResult(e,r.data,i,r.createTime.toTimestamp(),r.version.toTimestamp(),s,o)}get ref(){return this._ref}get id(){return this._ref?.id}get createTime(){return this._createTime}get updateTime(){return this._updateTime}data(){return this._userDataWriter.convertValue(this._fields.value,this._listenOptions?.serverTimestampBehavior)}_fieldsProto(){return this._fields.clone().value.mapValue.fields}get(e){if(void 0===this._fields)return;__PRIVATE_isField(e)&&(e=e.fieldName);const r=this._fields.field(_("DocumentSnapshot.get",e));return null!==r?this._userDataWriter.convertValue(r,this._listenOptions?.serverTimestampBehavior):void 0}}class __PRIVATE_StructuredPipelineOptions{constructor(e={},r={}){this.V=e,this.I=r,this.R=new OptionsUtil({indexMode:{serverName:"index_mode"}})}_readUserData(e){this.proto=this.R.getOptionsProto(e,this.V,this.I)}}class StructuredPipeline{constructor(e,r){this.pipeline=e,this.options=r}_toProto(e){return{pipeline:this.pipeline._toProto(e),options:this.options.proto}}}function execute(e){const r=e instanceof Pipeline?{pipeline:e}:e,{pipeline:i,rawOptions:s,atomic:o,...h}=r;if(!i._db)return Promise.reject(new k(U,"This pipeline was created without a database (e.g., as a subcollection pipeline) and cannot be executed directly. It can only be used as part of another pipeline."));const E=function d(e){if(e._terminated)throw new k(U,"The client has already been terminated.");if(!Be.has(e)){a(Ce,"Initializing Datastore");const r=function __PRIVATE_newConnection(e){return new __PRIVATE_FetchConnection(e)}(function __PRIVATE_makeDatabaseInfo(e,r,i,s,o){return new DatabaseInfo(e,r,i,o.host,o.ssl,o.experimentalForceLongPolling,o.experimentalAutoDetectLongPolling,__PRIVATE_cloneLongPollingOptions(o.experimentalLongPollingOptions),o.useFetchStreams,o.isUsingEmulator,s,o._customHeaders,o.grpcFlowControlWindow)}(e._databaseId,e.app.options.appId||"",e._persistenceKey,e.app.options.apiKey,e._freezeSettings())),i=__PRIVATE_newSerializer(e._databaseId),s=function __PRIVATE_newDatastore(e,r,i,s){return new __PRIVATE_DatastoreImpl(e,r,i,s)}(e._authCredentials,e._appCheckCredentials,r,i);Be.set(e,s)}return Be.get(e)}(i._db),T=function f(e,r){if("_delegate"in e&&(e=e._delegate),!(e instanceof r)){if(r.name===e.constructor.name)throw new k(b,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const i=__PRIVATE_valueDescription(e);throw new k(b,`Expected type '${r.name}', but it was: ${i}`)}}return e}(i._db,n),V=p(T).createContext(3,"execute");i._readUserData(V);const P=new A(T),R=new __PRIVATE_StructuredPipelineOptions(h,s);R._readUserData(V);return async function __PRIVATE_invokeExecutePipeline(e,r,i){const s=__PRIVATE_debugCast(e),o={database:(h=s.serializer,new ResourcePath(["projects",h.databaseId.projectId,"databases",h.databaseId.database]).canonicalString()),structuredPipeline:r._toProto(s.serializer),...i?.atomic?{newTransaction:{readWrite:{concurrencyMode:"OPTIMISTIC"}},autoCommitTransaction:!0}:{}};var h;const E=await s.me("ExecutePipeline",s.serializer.databaseId,ResourcePath.emptyPath(),o),T=[];return E.forEach((e=>{if(e.results&&0!==e.results.length)return e.results.forEach((r=>T.push(__PRIVATE_fromPipelineResponse(s.serializer,e,r))));T.push(__PRIVATE_fromPipelineResponse(s.serializer,e))})),T}(E,new StructuredPipeline(i,R),{atomic:o}).then((e=>{const r=e.length>0?e[0].executionTime?.toTimestamp():void 0,s=e.filter((e=>!!e.fields)).map((e=>new PipelineResult(P,e.fields,e.key?.path?new DocumentReference(T,null,e.key):void 0,e.createTime?.toTimestamp(),e.updateTime?.toTimestamp())));return new PipelineSnapshot(i,s,r)}))}n.prototype.pipeline=function(){const e=new A(this),r=p(this);return new PipelineSource(this._databaseId,r,(i=>new Pipeline(this,r,e,i)))};export{AggregateFunction,AliasedAggregate,AliasedExpression,BooleanExpression,Bytes,Constant,DocumentReference,Expression,Field,D as FieldPath,FieldValue,n as Firestore,FunctionExpression,GeoPoint,Ordering,Pipeline,PipelineResult,PipelineSnapshot,PipelineSource,Query,QueryDocumentSnapshot,Timestamp,VectorValue,abs,add,and,array,arrayAgg,arrayAggDistinct,arrayConcat,arrayContains,arrayContainsAll,arrayContainsAny,arrayFilter,arrayFirst,arrayFirstN,arrayGet,arrayIndexOf,arrayIndexOfAll,arrayLast,arrayLastIndexOf,arrayLastN,arrayLength,arrayMaximum,arrayMaximumN,arrayMinimum,arrayMinimumN,arraySlice,arraySum,arrayTransform,arrayTransformWithIndex,ascending,average,byteLength,ceil,charLength,coalesce,collectionId,concat,conditional,constant,cosineDistance,count,countAll,countDistinct,countIf,currentDocument,currentTimestamp,descending,divide,documentId,documentMatches,dotProduct,endsWith,equal,equalAny,euclideanDistance,execute,exists,exp,field,first,floor,geoDistance,greaterThan,greaterThanOrEqual,ifAbsent,ifError,ifNull,isAbsent,isError,isType,join,last,length,lessThan,lessThanOrEqual,like,ln,log,log10,logicalMaximum,logicalMinimum,ltrim,map,mapEntries,mapGet,mapKeys,mapMerge,mapRemove,mapSet,mapValues,maximum,minimum,mod,multiply,nor,not,notEqual,notEqualAny,or,parent,pow,rand,regexContains,regexFind,regexFindAll,regexMatch,reverse,round,rtrim,score,split,sqrt,startsWith,stringConcat,stringContains,stringIndexOf,stringRepeat,stringReplaceAll,stringReplaceOne,stringReverse,subcollection,substring,subtract,sum,switchOn,timestampAdd,timestampDiff,timestampExtract,timestampSubtract,timestampToUnixMicros,timestampToUnixMillis,timestampToUnixSeconds,timestampTruncate,toLower,toUpper,trim,trunc,type,unixMicrosToTimestamp,unixMillisToTimestamp,unixSecondsToTimestamp,variable,vectorLength,xor};
2
2
 
3
3
  //# sourceMappingURL=firebase-firestore-lite-pipelines.js.map